From 6908ded20e8040a48f6e281e665aabd6b1066a9e Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 9 Jan 2013 23:20:24 +0100 Subject: swr: fix the noise sample type for noise shaping Signed-off-by: Michael Niedermayer --- libswresample/dither.c | 19 ++++++++++--------- libswresample/swresample.c | 2 +- libswresample/swresample_internal.h | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) (limited to 'libswresample') diff --git a/libswresample/dither.c b/libswresample/dither.c index 05c75fc..d7cb8a1 100644 --- a/libswresample/dither.c +++ b/libswresample/dither.c @@ -23,15 +23,12 @@ #include "noise_shaping_data.c" -void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt) { +void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat noise_fmt) { double scale = s->dither.ns_scale; #define TMP_EXTRA 2 double *tmp = av_malloc((len + TMP_EXTRA) * sizeof(double)); int i; - out_fmt = av_get_packed_sample_fmt(out_fmt); - in_fmt = av_get_packed_sample_fmt( in_fmt); - for(i=0; idither.noise = s->preout; + if (s->dither.method > SWR_DITHER_NS) { + s->dither.noise.bps = 4; + s->dither.noise.fmt = AV_SAMPLE_FMT_FLTP; + } return 0; } diff --git a/libswresample/swresample.c b/libswresample/swresample.c index 5e0e4aa..b311419 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -654,7 +654,7 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co return ret; if(ret) for(ch=0; chdither.noise.ch_count; ch++) - swri_get_dither(s, s->dither.noise.ch[ch], s->dither.noise.count, 12345678913579<out_sample_fmt, s->int_sample_fmt); + swri_get_dither(s, s->dither.noise.ch[ch], s->dither.noise.count, 12345678913579<dither.noise.fmt); av_assert0(s->dither.noise.ch_count == preout->ch_count); if(s->dither.dither_pos + out_count > s->dither.noise.count) diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h index 1b0167c..5236098 100644 --- a/libswresample/swresample_internal.h +++ b/libswresample/swresample_internal.h @@ -176,7 +176,7 @@ void swri_rematrix_free(SwrContext *s); int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mustcopy); void swri_rematrix_init_x86(struct SwrContext *s); -void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt); +void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat noise_fmt); int swri_dither_init(SwrContext *s, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt); void swri_audio_convert_init_arm(struct AudioConvert *ac, -- cgit v1.1