mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-17 04:17:05 +00:00
avcodec/ac3dec: add consistent noise generation option.
use av_lfg_init_from_data() to seed AC-3 dithering from the AC-3 frame data to make it consistent given the same AC-3 frame, if option is set. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
76c5a69e26
commit
d5d474aea5
@ -1426,6 +1426,13 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
|
|||||||
(const uint16_t *) buf, cnt);
|
(const uint16_t *) buf, cnt);
|
||||||
} else
|
} else
|
||||||
memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE));
|
memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE));
|
||||||
|
|
||||||
|
/* if consistent noise generation is enabled, seed the linear feedback generator
|
||||||
|
* with the contents of the AC-3 frame so that the noise is identical across
|
||||||
|
* decodes given the same AC-3 frame data, for use with non-linear edititing software. */
|
||||||
|
if (s->consistent_noise_generation)
|
||||||
|
av_lfg_init_from_data(&s->dith_state, s->input_buffer, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE));
|
||||||
|
|
||||||
buf = s->input_buffer;
|
buf = s->input_buffer;
|
||||||
/* initialize the GetBitContext with the start of valid AC-3 Frame */
|
/* initialize the GetBitContext with the start of valid AC-3 Frame */
|
||||||
if ((ret = init_get_bits8(&s->gbc, buf, buf_size)) < 0)
|
if ((ret = init_get_bits8(&s->gbc, buf, buf_size)) < 0)
|
||||||
|
@ -177,6 +177,10 @@ typedef struct AC3DecodeContext {
|
|||||||
int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin (endmant)
|
int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin (endmant)
|
||||||
///@}
|
///@}
|
||||||
|
|
||||||
|
///@name Consistent noise generation
|
||||||
|
int consistent_noise_generation; ///< seed noise generation with AC-3 frame on decode
|
||||||
|
///@}
|
||||||
|
|
||||||
///@name Rematrixing
|
///@name Rematrixing
|
||||||
int num_rematrixing_bands; ///< number of rematrixing bands (nrematbnd)
|
int num_rematrixing_bands; ///< number of rematrixing bands (nrematbnd)
|
||||||
int rematrixing_flags[4]; ///< rematrixing flags (rematflg)
|
int rematrixing_flags[4]; ///< rematrixing flags (rematflg)
|
||||||
|
@ -168,6 +168,7 @@ static void ac3_downmix_c_fixed16(int16_t **samples, int16_t (*matrix)[2],
|
|||||||
#include "ac3dec.c"
|
#include "ac3dec.c"
|
||||||
|
|
||||||
static const AVOption options[] = {
|
static const AVOption options[] = {
|
||||||
|
{ "cons_noisegen", "enable consistent noise generation", OFFSET(consistent_noise_generation), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, PAR },
|
||||||
{ "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 6.0, PAR },
|
{ "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 6.0, PAR },
|
||||||
{ "heavy_compr", "enable heavy dynamic range compression", OFFSET(heavy_compression), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, PAR },
|
{ "heavy_compr", "enable heavy dynamic range compression", OFFSET(heavy_compression), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, PAR },
|
||||||
{ NULL},
|
{ NULL},
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "ac3dec.c"
|
#include "ac3dec.c"
|
||||||
|
|
||||||
static const AVOption options[] = {
|
static const AVOption options[] = {
|
||||||
|
{ "cons_noisegen", "enable consistent noise generation", OFFSET(consistent_noise_generation), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, PAR },
|
||||||
{ "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 6.0, PAR },
|
{ "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 6.0, PAR },
|
||||||
{ "heavy_compr", "enable heavy dynamic range compression", OFFSET(heavy_compression), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, PAR },
|
{ "heavy_compr", "enable heavy dynamic range compression", OFFSET(heavy_compression), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, PAR },
|
||||||
{ "target_level", "target level in -dBFS (0 not applied)", OFFSET(target_level), AV_OPT_TYPE_INT, {.i64 = 0 }, -31, 0, PAR },
|
{ "target_level", "target level in -dBFS (0 not applied)", OFFSET(target_level), AV_OPT_TYPE_INT, {.i64 = 0 }, -31, 0, PAR },
|
||||||
|
Loading…
Reference in New Issue
Block a user