Set the sample rate when parsing the header instead and only copy the value in the decoder and the parser.
Unified · Split
| @@ -1105,7 +1105,7 @@ static int dolby_e_decode_frame(AVCodecContext *avctx, void *data, · 1104 unmodified lines | ||
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | 1107 | avctx->channels = s->metadata.nb_channels; |
| 1108 | − avctx->sample_rate = sample_rate_tab[s->metadata.fr_code]; | |
| 1108 | + avctx->sample_rate = s->metadata.sample_rate; | |
| 1109 | 1109 | avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; |
| 1110 | 1110 | |
| 1111 | 1111 | i = s->metadata.nb_channels / 2; |
| @@ -58,6 +58,8 @@ typedef struct DolbyEHeaderInfo { · 57 unmodified lines | ||
| 58 | 58 | * @{ |
| 59 | 59 | */ |
| 60 | 60 | int multi_prog_warned; |
| 61 | + | |
| 62 | + int sample_rate; | |
| 61 | 63 | /** @} */ |
| 62 | 64 | } DolbyEHeaderInfo; |
| 63 | 65 | |
| @@ -81,10 +83,6 @@ typedef struct DBEContext { · 17 unmodified lines | ||
| 81 | 83 | uint8_t buffer[1024 * 3 + AV_INPUT_BUFFER_PADDING_SIZE]; |
| 82 | 84 | } DBEContext; |
| 83 | 85 | |
| 84 | −static const uint16_t sample_rate_tab[16] = { | |
| 85 | − 0, 42965, 43008, 44800, 53706, 53760 | |
| 86 | −}; | |
| 87 | − | |
| 88 | 86 | /** |
| 89 | 87 | * Use the provided key to transform the input into data (put into s->buffer) |
| 90 | 88 | * suitable for further processing and initialize s->gb to read said data. |
| @@ -30,6 +30,10 @@ static const uint8_t nb_channels_tab[MAX_PROG_CONF + 1] = { · 29 unmodified lines | ||
| 30 | 30 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 4, 8, 8 |
| 31 | 31 | }; |
| 32 | 32 | |
| 33 | +static const uint16_t sample_rate_tab[16] = { | |
| 34 | + 0, 42965, 43008, 44800, 53706, 53760 | |
| 35 | +}; | |
| 36 | + | |
| 33 | 37 | static int skip_input(DBEContext *s, int nb_words) |
| 34 | 38 | { |
| 35 | 39 | 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) · 109 unmodified lines | ||
| 145 | 149 | |
| 146 | 150 | header->fr_code = get_bits(&s->gb, 4); |
| 147 | 151 | header->fr_code_orig = get_bits(&s->gb, 4); |
| 148 | − if (!sample_rate_tab[header->fr_code] || | |
| 152 | + if (!(header->sample_rate = sample_rate_tab[header->fr_code]) || | |
| 149 | 153 | !sample_rate_tab[header->fr_code_orig]) { |
| 150 | 154 | if (s->avctx) |
| 151 | 155 | av_log(s->avctx, AV_LOG_ERROR, "Invalid frame rate code\n"); |
| @@ -51,7 +51,7 @@ static int dolby_e_parse(AVCodecParserContext *s2, AVCodecContext *avctx, · 50 unmodified lines | ||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | avctx->channels = s->metadata.nb_channels; |
| 54 | − avctx->sample_rate = sample_rate_tab[s->metadata.fr_code]; | |
| 54 | + avctx->sample_rate = s->metadata.sample_rate; | |
| 55 | 55 | avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; |
| 56 | 56 | |
| 57 | 57 | end: |