diff --git a/libswresample/dither.c b/libswresample/dither.c index 663e2007ba..88f788066e 100644 --- a/libswresample/dither.c +++ b/libswresample/dither.c @@ -23,6 +23,8 @@ void swri_get_dither(void *dst, int len, unsigned seed, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, enum SwrDitherType method) { double scale = 0; +#define TMP_EXTRA 2 + double *tmp = av_malloc((len + TMP_EXTRA) * sizeof(double)); int i; if(in_fmt == AV_SAMPLE_FMT_FLT || in_fmt == AV_SAMPLE_FMT_DBL){ @@ -34,19 +36,36 @@ void swri_get_dither(void *dst, int len, unsigned seed, enum AVSampleFormat out_ if(in_fmt == AV_SAMPLE_FMT_S32 && out_fmt == AV_SAMPLE_FMT_U8 ) scale = 1L<<24; if(in_fmt == AV_SAMPLE_FMT_S16 && out_fmt == AV_SAMPLE_FMT_U8 ) scale = 1L<<8; - for(i=0; i