[FFmpeg-cvslog] resample2: fix potential overflow
Michael Niedermayer
git at videolan.org
Thu Oct 27 14:45:24 CEST 2011
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Oct 27 14:34:45 2011 +0200| [1b9ca38d9d06d319fffd61d27e4eb385d6572ba8] | committer: Michael Niedermayer
resample2: fix potential overflow
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1b9ca38d9d06d319fffd61d27e4eb385d6572ba8
---
libavcodec/resample2.c | 5 ++---
libswresample/resample2.c | 5 ++---
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/libavcodec/resample2.c b/libavcodec/resample2.c
index fc8ffea..5c42558 100644
--- a/libavcodec/resample2.c
+++ b/libavcodec/resample2.c
@@ -248,10 +248,9 @@ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int
dst[dst_index] = src[index2>>32];
index2 += incr;
}
- frac += dst_index * dst_incr_frac;
index += dst_index * dst_incr;
- index += frac / c->src_incr;
- frac %= c->src_incr;
+ index += (frac + dst_index * (int64_t)dst_incr_frac) / c->src_incr;
+ frac = (frac + dst_index * (int64_t)dst_incr_frac) % c->src_incr;
}else{
for(dst_index=0; dst_index < dst_size; dst_index++){
FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask);
diff --git a/libswresample/resample2.c b/libswresample/resample2.c
index 5a20824..02f29ba 100644
--- a/libswresample/resample2.c
+++ b/libswresample/resample2.c
@@ -269,10 +269,9 @@ int swr_resample(AVResampleContext *c, short *dst, const short *src, int *consum
dst[dst_index] = src[index2>>32];
index2 += incr;
}
- frac += dst_index * dst_incr_frac;
index += dst_index * dst_incr;
- index += frac / c->src_incr;
- frac %= c->src_incr;
+ index += (frac + dst_index * (int64_t)dst_incr_frac) / c->src_incr;
+ frac = (frac + dst_index * (int64_t)dst_incr_frac) % c->src_incr;
}else{
for(dst_index=0; dst_index < dst_size; dst_index++){
FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask);
More information about the ffmpeg-cvslog
mailing list