History

avcodec/dca_parser: skip initial padding

Padding before the first sync word can be very large for DTS-in-WAV streams. There is no reason to include this padding in parsed packet.

foo86 committed 10 years ago

Commit 214e63f1 parent 1f7b67a1 file · +28 −13Browse files

Showing the changes to libavcodec/dca_parser.c (1 of 1 file). Show all

Unified · Split

libavcodec/dca_parser.c+28−13
@@ -33,6 +33,7 @@ typedef struct DCAParseContext { · 32 unmodified lines
3333 uint32_t lastmarker;
3434 int size;
3535 int framesize;
36+ unsigned int startpos;
3637 DCAExssParser exss;
3738 unsigned int sr_code;
3839 } DCAParseContext;
@@ -75,20 +76,27 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, · 36 unmodified lines
7576
7677 i = 0;
7778 if (!start_found) {
78− for (i = 0; i < buf_size; i++) {
79+ for (; i < buf_size; i++) {
80+ size++;
7981 state = (state << 8) | buf[i];
80− if (IS_MARKER(state)) {
81− if (!pc1->lastmarker ||
82− pc1->lastmarker == CORE_MARKER(state) ||
83− pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM) {
84− start_found = 1;
85− if (IS_EXSS_MARKER(state))
86− pc1->lastmarker = EXSS_MARKER(state);
87− else
88− pc1->lastmarker = CORE_MARKER(state);
89− i++;
90− break;
91− }
82+
83+ if (IS_MARKER(state) &&
84+ (!pc1->lastmarker ||
85+ pc1->lastmarker == CORE_MARKER(state) ||
86+ pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM)) {
87+ if (!pc1->lastmarker)
88+ pc1->startpos = IS_EXSS_MARKER(state) ? size - 4 : size - 6;
89+
90+ if (IS_EXSS_MARKER(state))
91+ pc1->lastmarker = EXSS_MARKER(state);
92+ else
93+ pc1->lastmarker = CORE_MARKER(state);
94+
95+ start_found = 1;
96+ size = 0;
97+
98+ i++;
99+ break;
92100 }
93101 }
94102 }
@@ -284,6 +292,13 @@ static int dca_parse(AVCodecParserContext *s, AVCodecContext *avctx, · 189 unmodified lines
284292 *poutbuf_size = 0;
285293 return buf_size;
286294 }
295+
296+ /* skip initial padding */
297+ if (buf_size > pc1->startpos) {
298+ buf += pc1->startpos;
299+ buf_size -= pc1->startpos;
300+ }
301+ pc1->startpos = 0;
287302 }
288303
289304 /* read the duration and sample rate from the frame header */

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