History

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.

Andreas Rheinhardt committed 5 years ago

Commit 44e27d91 parent 7c275134 files · +9 −7Browse files

Unified · Split

4 files
  1. libavcodec/dolby_e.c +1 −1
  2. libavcodec/dolby_e.h +2 −4
  3. libavcodec/dolby_e_parse.c +5 −1
  4. libavcodec/dolby_e_parser.c +1 −1
libavcodec/dolby_e.c+1−1
@@ -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;
libavcodec/dolby_e.h+2−4
@@ -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
84static 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.
libavcodec/dolby_e_parse.c+5−1
@@ -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, 830 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
33static const uint16_t sample_rate_tab[16] = {
34 0, 42965, 43008, 44800, 53706, 53760
35};
36
33static int skip_input(DBEContext *s, int nb_words)37static 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");
libavcodec/dolby_e_parser.c+1−1
@@ -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
57end:57end:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t