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

Unified · Split

libavcodec/dca_parser.c+28−13
@@ -33,6 +33,7 @@ typedef struct DCAParseContext { · 32 unmodified lines
33 uint32_t lastmarker;33 uint32_t lastmarker;
34 int size;34 int size;
35 int framesize;35 int framesize;
36 unsigned int startpos;
36 DCAExssParser exss;37 DCAExssParser exss;
37 unsigned int sr_code;38 unsigned int sr_code;
38} DCAParseContext;39} DCAParseContext;
@@ -75,20 +76,27 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, · 36 unmodified lines
75 76
76 i = 0;77 i = 0;
77 if (!start_found) {78 if (!start_found) {
78 for (i = 0; i < buf_size; i++) {79 for (; i < buf_size; i++) {
80 size++;
79 state = (state << 8) | buf[i];81 state = (state << 8) | buf[i];
80 if (IS_MARKER(state)) {82
81 if (!pc1->lastmarker ||83 if (IS_MARKER(state) &&
82 pc1->lastmarker == CORE_MARKER(state) ||84 (!pc1->lastmarker ||
83 pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM) {85 pc1->lastmarker == CORE_MARKER(state) ||
84 start_found = 1;86 pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM)) {
85 if (IS_EXSS_MARKER(state))87 if (!pc1->lastmarker)
86 pc1->lastmarker = EXSS_MARKER(state);88 pc1->startpos = IS_EXSS_MARKER(state) ? size - 4 : size - 6;
87 else89
88 pc1->lastmarker = CORE_MARKER(state);90 if (IS_EXSS_MARKER(state))
89 i++;91 pc1->lastmarker = EXSS_MARKER(state);
90 break;92 else
91 }93 pc1->lastmarker = CORE_MARKER(state);
94
95 start_found = 1;
96 size = 0;
97
98 i++;
99 break;
92 }100 }
93 }101 }
94 }102 }
@@ -284,6 +292,13 @@ static int dca_parse(AVCodecParserContext *s, AVCodecContext *avctx, · 189 unmodified lines
284 *poutbuf_size = 0;292 *poutbuf_size = 0;
285 return buf_size;293 return buf_size;
286 }294 }
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;
287 }302 }
288 303
289 /* read the duration and sample rate from the frame header */304 /* 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