diff options
Diffstat (limited to 'libswresample')
-rw-r--r-- | libswresample/resample_template.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libswresample/resample_template.c b/libswresample/resample_template.c index 1636f4e95d..31cf3500ab 100644 --- a/libswresample/resample_template.c +++ b/libswresample/resample_template.c @@ -32,6 +32,7 @@ # define DELEM double # define FELEM double # define FELEM2 double +# define FOFFSET 0 # define OUT(d, v) d = v #elif defined(TEMPLATE_RESAMPLE_FLT) @@ -41,6 +42,7 @@ # define DELEM float # define FELEM float # define FELEM2 float +# define FOFFSET 0 # define OUT(d, v) d = v #elif defined(TEMPLATE_RESAMPLE_S32) @@ -52,8 +54,8 @@ # define FELEM2 int64_t # define FELEM_MAX INT32_MAX # define FELEM_MIN INT32_MIN -# define OUT(d, v) (v) = ((v) + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;\ - (d) = av_clipl_int32(v) +# define FOFFSET (1<<(FILTER_SHIFT-1)) +# define OUT(d, v) (d) = av_clipl_int32((v)>>FILTER_SHIFT) #elif defined(TEMPLATE_RESAMPLE_S16) @@ -65,8 +67,8 @@ # define FELEML int64_t # define FELEM_MAX INT16_MAX # define FELEM_MIN INT16_MIN -# define OUT(d, v) (v) = ((v) + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;\ - (d) = av_clip_int16(v) +# define FOFFSET (1<<(FILTER_SHIFT-1)) +# define OUT(d, v) (d) = av_clip_int16((v)>>FILTER_SHIFT) #endif @@ -102,7 +104,7 @@ static int RENAME(resample_common)(ResampleContext *c, for (dst_index = 0; dst_index < n; dst_index++) { FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index; - FELEM2 val=0; + FELEM2 val= FOFFSET; int i; for (i = 0; i < c->filter_length; i++) { val += src[sample_index + i] * (FELEM2)filter[i]; @@ -151,7 +153,7 @@ static int RENAME(resample_linear)(ResampleContext *c, for (dst_index = 0; dst_index < n; dst_index++) { FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index; - FELEM2 val=0, v2 = 0; + FELEM2 val = FOFFSET, v2 = FOFFSET; int i; for (i = 0; i < c->filter_length; i++) { @@ -199,3 +201,4 @@ static int RENAME(resample_linear)(ResampleContext *c, #undef FELEM_MAX #undef FELEM_MIN #undef OUT +#undef FOFFSET |