Commit 34db6507 authored by Michael Niedermayer's avatar Michael Niedermayer

swresample/resample_template: Reorder operations to avoid one addition

Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent b3928a1c
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment