diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2021-01-26 17:14:05 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2021-01-30 05:14:45 +0100 |
commit | 44e27d937d88f3e7cdc83f4de1b9d3a590bcaa04 (patch) | |
tree | d5ac6333547dc0103848dcbe2b893e114d727feb | |
parent | 7c27513d0458c7e80925e27529acee4473baedf6 (diff) | |
download | ffmpeg-44e27d937d88f3e7cdc83f4de1b9d3a590bcaa04.tar.gz |
avcodec/dolby_e: Avoid duplicating sample rate table
Set the sample rate when parsing the header instead and only copy the
value in the decoder and the parser.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
-rw-r--r-- | libavcodec/dolby_e.c | 2 | ||||
-rw-r--r-- | libavcodec/dolby_e.h | 6 | ||||
-rw-r--r-- | libavcodec/dolby_e_parse.c | 6 | ||||
-rw-r--r-- | libavcodec/dolby_e_parser.c | 2 |
4 files changed, 9 insertions, 7 deletions
diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c index 9031c18210..ecb2f4802a 100644 --- a/libavcodec/dolby_e.c +++ b/libavcodec/dolby_e.c @@ -1105,7 +1105,7 @@ static int dolby_e_decode_frame(AVCodecContext *avctx, void *data, } avctx->channels = s->metadata.nb_channels; - avctx->sample_rate = sample_rate_tab[s->metadata.fr_code]; + avctx->sample_rate = s->metadata.sample_rate; avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; i = s->metadata.nb_channels / 2; diff --git a/libavcodec/dolby_e.h b/libavcodec/dolby_e.h index 32471bce80..9f0c065729 100644 --- a/libavcodec/dolby_e.h +++ b/libavcodec/dolby_e.h @@ -58,6 +58,8 @@ typedef struct DolbyEHeaderInfo { * @{ */ int multi_prog_warned; + + int sample_rate; /** @} */ } DolbyEHeaderInfo; @@ -81,10 +83,6 @@ typedef struct DBEContext { uint8_t buffer[1024 * 3 + AV_INPUT_BUFFER_PADDING_SIZE]; } DBEContext; -static const uint16_t sample_rate_tab[16] = { - 0, 42965, 43008, 44800, 53706, 53760 -}; - /** * Use the provided key to transform the input into data (put into s->buffer) * suitable for further processing and initialize s->gb to read said data. diff --git a/libavcodec/dolby_e_parse.c b/libavcodec/dolby_e_parse.c index 00b5536020..ffedcd99a4 100644 --- a/libavcodec/dolby_e_parse.c +++ b/libavcodec/dolby_e_parse.c @@ -30,6 +30,10 @@ static const uint8_t nb_channels_tab[MAX_PROG_CONF + 1] = { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 4, 8, 8 }; +static const uint16_t sample_rate_tab[16] = { + 0, 42965, 43008, 44800, 53706, 53760 +}; + static int skip_input(DBEContext *s, int nb_words) { if (nb_words > s->input_size) { @@ -145,7 +149,7 @@ int ff_dolby_e_parse_header(DBEContext *s, const uint8_t *buf, int buf_size) header->fr_code = get_bits(&s->gb, 4); header->fr_code_orig = get_bits(&s->gb, 4); - if (!sample_rate_tab[header->fr_code] || + if (!(header->sample_rate = sample_rate_tab[header->fr_code]) || !sample_rate_tab[header->fr_code_orig]) { if (s->avctx) av_log(s->avctx, AV_LOG_ERROR, "Invalid frame rate code\n"); diff --git a/libavcodec/dolby_e_parser.c b/libavcodec/dolby_e_parser.c index 8e713b44ed..3ae973bddf 100644 --- a/libavcodec/dolby_e_parser.c +++ b/libavcodec/dolby_e_parser.c @@ -51,7 +51,7 @@ static int dolby_e_parse(AVCodecParserContext *s2, AVCodecContext *avctx, } avctx->channels = s->metadata.nb_channels; - avctx->sample_rate = sample_rate_tab[s->metadata.fr_code]; + avctx->sample_rate = s->metadata.sample_rate; avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; end: |