summaryrefslogtreecommitdiffstats
path: root/contrib/ffmpeg/A04-dca-resync.patch
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ffmpeg/A04-dca-resync.patch')
-rw-r--r--contrib/ffmpeg/A04-dca-resync.patch71
1 files changed, 71 insertions, 0 deletions
diff --git a/contrib/ffmpeg/A04-dca-resync.patch b/contrib/ffmpeg/A04-dca-resync.patch
new file mode 100644
index 000000000..3e32c7a74
--- /dev/null
+++ b/contrib/ffmpeg/A04-dca-resync.patch
@@ -0,0 +1,71 @@
+From 021a7700ff839b295b5776d4552563de1a448df6 Mon Sep 17 00:00:00 2001
+From: John Stebbins <[email protected]>
+Date: Sat, 5 Jan 2013 16:57:06 -0800
+Subject: [PATCH] dca_parser: Handle changes in dca frame size
+
+A change in framesize caused a perpetual loss of synchronization.
+So read (and use) the frame size from the frame header instead of
+setting it only once.
+---
+ libavcodec/dca_parser.c | 13 ++++++++-----
+ 1 file changed, 8 insertions(+), 5 deletions(-)
+
+diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c
+index ab235cf..75e9321 100644
+--- a/libavcodec/dca_parser.c
++++ b/libavcodec/dca_parser.c
+@@ -62,10 +62,12 @@ static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf,
+ if (IS_MARKER(state, i, buf, buf_size)) {
+ if (pc1->lastmarker && state == pc1->lastmarker) {
+ start_found = 1;
++ i++;
+ break;
+ } else if (!pc1->lastmarker) {
+ start_found = 1;
+ pc1->lastmarker = state;
++ i++;
+ break;
+ }
+ }
+@@ -80,9 +82,6 @@ static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf,
+ if (state == pc1->lastmarker && IS_MARKER(state, i, buf, buf_size)) {
+ if(pc1->framesize > pc1->size)
+ continue;
+- if(!pc1->framesize){
+- pc1->framesize = pc1->hd_pos ? pc1->hd_pos : pc1->size;
+- }
+ pc->frame_start_found = 0;
+ pc->state = -1;
+ pc1->size = 0;
+@@ -139,7 +138,7 @@ int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
+ }
+
+ static int dca_parse_params(const uint8_t *buf, int buf_size, int *duration,
+- int *sample_rate)
++ int *sample_rate, int *framesize)
+ {
+ GetBitContext gb;
+ uint8_t hdr[12 + FF_INPUT_BUFFER_PADDING_SIZE] = { 0 };
+@@ -159,6 +158,10 @@ static int dca_parse_params(const uint8_t *buf, int buf_size, int *duration,
+ return AVERROR_INVALIDDATA;
+ *duration = 256 * (sample_blocks / 8);
+
++ *framesize = get_bits(&gb, 14) + 1;
++ if (*framesize < 95)
++ return AVERROR_INVALIDDATA;
++
+ skip_bits(&gb, 20);
+ sr_code = get_bits(&gb, 4);
+ *sample_rate = avpriv_dca_sample_rates[sr_code];
+@@ -190,7 +193,7 @@ static int dca_parse(AVCodecParserContext * s,
+ }
+
+ /* read the duration and sample rate from the frame header */
+- if (!dca_parse_params(buf, buf_size, &duration, &sample_rate)) {
++ if (!dca_parse_params(buf, buf_size, &duration, &sample_rate, &pc1->framesize)) {
+ s->duration = duration;
+ avctx->sample_rate = sample_rate;
+ } else
+--
+1.7.10.4
+