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 | avctx->channels = s->metadata.nb_channels; | 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 | avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; | 1109 | avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; |
| 1110 | 1110 | ||
| 1111 | i = s->metadata.nb_channels / 2; | 1111 | i = s->metadata.nb_channels / 2; |
| @@ -58,6 +58,8 @@ typedef struct DolbyEHeaderInfo { · 57 unmodified lines | |||
| 58 | * @{ | 58 | * @{ |
| 59 | */ | 59 | */ |
| 60 | int multi_prog_warned; | 60 | int multi_prog_warned; |
| 61 | |||
| 62 | int sample_rate; | ||
| 61 | /** @} */ | 63 | /** @} */ |
| 62 | } DolbyEHeaderInfo; | 64 | } DolbyEHeaderInfo; |
| 63 | 65 | ||
| @@ -81,10 +83,6 @@ typedef struct DBEContext { · 17 unmodified lines | |||
| 81 | uint8_t buffer[1024 * 3 + AV_INPUT_BUFFER_PADDING_SIZE]; | 83 | uint8_t buffer[1024 * 3 + AV_INPUT_BUFFER_PADDING_SIZE]; |
| 82 | } DBEContext; | 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 | * Use the provided key to transform the input into data (put into s->buffer) | 87 | * Use the provided key to transform the input into data (put into s->buffer) |
| 90 | * suitable for further processing and initialize s->gb to read said data. | 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 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 4, 8, 8 | 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 | static int skip_input(DBEContext *s, int nb_words) | 37 | static int skip_input(DBEContext *s, int nb_words) |
| 34 | { | 38 | { |
| 35 | if (nb_words > s->input_size) { | 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 | header->fr_code = get_bits(&s->gb, 4); | 150 | header->fr_code = get_bits(&s->gb, 4); |
| 147 | header->fr_code_orig = get_bits(&s->gb, 4); | 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 | !sample_rate_tab[header->fr_code_orig]) { | 153 | !sample_rate_tab[header->fr_code_orig]) { |
| 150 | if (s->avctx) | 154 | if (s->avctx) |
| 151 | av_log(s->avctx, AV_LOG_ERROR, "Invalid frame rate code\n"); | 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 | avctx->channels = s->metadata.nb_channels; | 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 | avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; | 55 | avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; |
| 56 | 56 | ||
| 57 | end: | 57 | end: |