Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfoo86 <foobaz86@gmail.com>2016-05-31 14:46:14 +0300
committerJames Almer <jamrial@gmail.com>2016-05-31 17:45:59 +0300
commit214e63f8511330e8da8d69b5ea402ff0a4f17316 (patch)
tree524903ab404c868eed1f836484bcd73b3dc8c95d /libavcodec/dca_parser.c
parent1f7b67a1caef19842533e2831350312d5b6c3f5f (diff)
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. Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/dca_parser.c')
-rw-r--r--libavcodec/dca_parser.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c
index 1521a5b348..e5bea3347c 100644
--- a/libavcodec/dca_parser.c
+++ b/libavcodec/dca_parser.c
@@ -33,6 +33,7 @@ typedef struct DCAParseContext {
uint32_t lastmarker;
int size;
int framesize;
+ unsigned int startpos;
DCAExssParser exss;
unsigned int sr_code;
} DCAParseContext;
@@ -75,20 +76,27 @@ static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf,
i = 0;
if (!start_found) {
- for (i = 0; i < buf_size; i++) {
+ for (; i < buf_size; i++) {
+ size++;
state = (state << 8) | buf[i];
- if (IS_MARKER(state)) {
- if (!pc1->lastmarker ||
- pc1->lastmarker == CORE_MARKER(state) ||
- pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM) {
- start_found = 1;
- if (IS_EXSS_MARKER(state))
- pc1->lastmarker = EXSS_MARKER(state);
- else
- pc1->lastmarker = CORE_MARKER(state);
- i++;
- break;
- }
+
+ if (IS_MARKER(state) &&
+ (!pc1->lastmarker ||
+ pc1->lastmarker == CORE_MARKER(state) ||
+ pc1->lastmarker == DCA_SYNCWORD_SUBSTREAM)) {
+ if (!pc1->lastmarker)
+ pc1->startpos = IS_EXSS_MARKER(state) ? size - 4 : size - 6;
+
+ if (IS_EXSS_MARKER(state))
+ pc1->lastmarker = EXSS_MARKER(state);
+ else
+ pc1->lastmarker = CORE_MARKER(state);
+
+ start_found = 1;
+ size = 0;
+
+ i++;
+ break;
}
}
}
@@ -284,6 +292,13 @@ static int dca_parse(AVCodecParserContext *s, AVCodecContext *avctx,
*poutbuf_size = 0;
return buf_size;
}
+
+ /* skip initial padding */
+ if (buf_size > pc1->startpos) {
+ buf += pc1->startpos;
+ buf_size -= pc1->startpos;
+ }
+ pc1->startpos = 0;
}
/* read the duration and sample rate from the frame header */