mirror of https://git.ffmpeg.org/ffmpeg.git
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>
This commit is contained in:
parent
c4c702b6d3
commit
8b3affda87
|
@ -94,6 +94,9 @@ int swri_dither_init(SwrContext *s, enum AVSampleFormat out_fmt, enum AVSampleFo
|
||||||
|
|
||||||
scale *= s->dither.scale;
|
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.ns_pos = 0;
|
||||||
s->dither.noise_scale= scale;
|
s->dither.noise_scale= scale;
|
||||||
s->dither.ns_scale = scale;
|
s->dither.ns_scale = scale;
|
||||||
|
|
|
@ -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 },
|
{ "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}
|
{0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ struct DitherContext {
|
||||||
float ns_errors[SWR_CH_MAX][2*NS_TAPS];
|
float ns_errors[SWR_CH_MAX][2*NS_TAPS];
|
||||||
AudioData noise; ///< noise used for dithering
|
AudioData noise; ///< noise used for dithering
|
||||||
AudioData temp; ///< temporary storage when writing into the input buffer isnt possible
|
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 {
|
struct SwrContext {
|
||||||
|
|
Loading…
Reference in New Issue