Skip to content
Snippets Groups Projects
Commit c5a405c4 authored by Michael Niedermayer's avatar Michael Niedermayer
Browse files

swresample/resample_template: flip order of operations in swri_resample_linear() for 32bit


Fixes integer overflow

Found-by: BBB
Reviewed-by: default avatar"Ronald S. Bultje" <rsbultje@gmail.com>
Signed-off-by: default avatarMichael Niedermayer <michaelni@gmx.at>
parent 7f5d75f9
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,6 @@ ...@@ -62,7 +62,6 @@
# define DELEM int32_t # define DELEM int32_t
# define FELEM int32_t # define FELEM int32_t
# define FELEM2 int64_t # define FELEM2 int64_t
# define FELEML int64_t
# define FELEM_MAX INT32_MAX # define FELEM_MAX INT32_MAX
# define FELEM_MIN INT32_MIN # define FELEM_MIN INT32_MIN
# define OUT(d, v) v = (v + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;\ # define OUT(d, v) v = (v + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;\
...@@ -174,7 +173,11 @@ int RENAME(swri_resample_linear)(ResampleContext *c, ...@@ -174,7 +173,11 @@ int RENAME(swri_resample_linear)(ResampleContext *c,
v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_alloc]; v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_alloc];
} }
#endif #endif
#ifdef FELEML
val += (v2 - val) * (FELEML) frac / c->src_incr; val += (v2 - val) * (FELEML) frac / c->src_incr;
#else
val += (v2 - val) / c->src_incr * frac;
#endif
OUT(dst[dst_index], val); OUT(dst[dst_index], val);
frac += c->dst_incr_mod; frac += c->dst_incr_mod;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment