[FFmpeg-cvslog] swresample/resample_template: flip order of operations in swri_resample_linear() for 32bit

Michael Niedermayer git at videolan.org
Sun Jun 29 22:24:58 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Jun 29 13:55:29 2014 +0200| [c5a405c4f07066efa786b75865c2c9c8f2a399ed] | committer: Michael Niedermayer

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

Fixes integer overflow

Found-by: BBB
Reviewed-by: "Ronald S. Bultje" <rsbultje at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c5a405c4f07066efa786b75865c2c9c8f2a399ed
---

 libswresample/resample_template.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libswresample/resample_template.c b/libswresample/resample_template.c
index db208e3..5983d46 100644
--- a/libswresample/resample_template.c
+++ b/libswresample/resample_template.c
@@ -62,7 +62,6 @@
 #    define DELEM  int32_t
 #    define FELEM  int32_t
 #    define FELEM2 int64_t
-#    define FELEML int64_t
 #    define FELEM_MAX INT32_MAX
 #    define FELEM_MIN INT32_MIN
 #    define OUT(d, v) v = (v + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;\
@@ -174,7 +173,11 @@ int RENAME(swri_resample_linear)(ResampleContext *c,
             v2  += src[sample_index + i] * (FELEM2)filter[i + c->filter_alloc];
         }
 #endif
+#ifdef FELEML
         val += (v2 - val) * (FELEML) frac / c->src_incr;
+#else
+        val += (v2 - val) / c->src_incr * frac;
+#endif
         OUT(dst[dst_index], val);
 
         frac += c->dst_incr_mod;



More information about the ffmpeg-cvslog mailing list