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
11051105 }
11061106
11071107 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;
11091109 avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
11101110
11111111 i = s->metadata.nb_channels / 2;
libavcodec/dolby_e.h+2−4
@@ -58,6 +58,8 @@ typedef struct DolbyEHeaderInfo { · 57 unmodified lines
5858 * @{
5959 */
6060 int multi_prog_warned;
61+
62+ int sample_rate;
6163 /** @} */
6264 } DolbyEHeaderInfo;
6365
@@ -81,10 +83,6 @@ typedef struct DBEContext { · 17 unmodified lines
8183 uint8_t buffer[1024 * 3 + AV_INPUT_BUFFER_PADDING_SIZE];
8284 } DBEContext;
8385
84−static const uint16_t sample_rate_tab[16] = {
85− 0, 42965, 43008, 44800, 53706, 53760
86−};
87−
8886 /**
8987 * Use the provided key to transform the input into data (put into s->buffer)
9088 * 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
3030 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 4, 8, 8
3131 };
3232
33+static const uint16_t sample_rate_tab[16] = {
34+ 0, 42965, 43008, 44800, 53706, 53760
35+};
36+
3337 static int skip_input(DBEContext *s, int nb_words)
3438 {
3539 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
145149
146150 header->fr_code = get_bits(&s->gb, 4);
147151 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]) ||
149153 !sample_rate_tab[header->fr_code_orig]) {
150154 if (s->avctx)
151155 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
5151 }
5252
5353 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;
5555 avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
5656
5757 end:

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