summaryrefslogtreecommitdiff
authorMichael Niedermayer <michaelni@gmx.at>2013-02-24 18:05:54 (GMT)
committer Michael Niedermayer <michaelni@gmx.at>2013-02-24 19:31:56 (GMT)
commit8b3affda87e45165bd7d968a8cad82fe700f60b7 (patch)
treecc4dc3a3a0045ed097d310b5099a470768335c1b
parentc4c702b6d3b42b5ae25d96982f283b4028a83574 (diff)
downloadffmpeg-8b3affda87e45165bd7d968a8cad82fe700f60b7.zip
ffmpeg-8b3affda87e45165bd7d968a8cad82fe700f60b7.tar.gz
ffmpeg-8b3affda87e45165bd7d968a8cad82fe700f60b7.tar.bz2
swr: support a seperate output sample bits.
This avoids user apps having to mangle dither scale. for pcm24 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat
-rw-r--r--libswresample/dither.c3
-rw-r--r--libswresample/swresample.c1
-rw-r--r--libswresample/swresample_internal.h1
3 files changed, 5 insertions, 0 deletions
diff --git a/libswresample/dither.c b/libswresample/dither.c
index d70505c..d0193dd 100644
--- a/libswresample/dither.c
+++ b/libswresample/dither.c
@@ -94,6 +94,9 @@ int swri_dither_init(SwrContext *s, enum AVSampleFormat out_fmt, enum AVSampleFo
scale *= s->dither.scale;
+ if (out_fmt == AV_SAMPLE_FMT_S32 && s->dither.output_sample_bits)
+ scale *= 1<<(32-s->dither.output_sample_bits);
+
s->dither.ns_pos = 0;
s->dither.noise_scale= scale;
s->dither.ns_scale = scale;
diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index f69e36e..f85f88f 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -127,6 +127,7 @@ static const AVOption options[]={
{ "kaiser_beta" , "set swr Kaiser Window Beta" , OFFSET(kaiser_beta) , AV_OPT_TYPE_INT , {.i64=9 }, 2 , 16 , PARAM },
+{ "output_sample_bits" , "" , OFFSET(dither.output_sample_bits) , AV_OPT_TYPE_INT , {.i64=0 }, 0 , 64 , 0 },
{0}
};
diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h
index 3f80904..17b85d5 100644
--- a/libswresample/swresample_internal.h
+++ b/libswresample/swresample_internal.h
@@ -63,6 +63,7 @@ struct DitherContext {
float ns_errors[SWR_CH_MAX][2*NS_TAPS];
AudioData noise; ///< noise used for dithering
AudioData temp; ///< temporary storage when writing into the input buffer isnt possible
+ int output_sample_bits; ///< the number of used output bits, needed to scale dither correctly
};
struct SwrContext {