1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

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>
This commit is contained in:
Andreas Rheinhardt 2021-01-26 17:14:05 +01:00
parent 7c27513d04
commit 44e27d937d
4 changed files with 9 additions and 7 deletions

View File

@ -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;

View File

@ -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.

View File

@ -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");

View File

@ -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: