From f8a237a3074b444a8d88d92d9fcce10508479d35 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 11 Apr 2012 13:27:22 +0200 Subject: [PATCH] swr: add triangular highpass dither Signed-off-by: Michael Niedermayer --- libswresample/dither.c | 23 ++++++++++++++++++++++- libswresample/swresample.c | 1 + libswresample/swresample.h | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) 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