diff options
author | jstebbins <[email protected]> | 2013-01-06 01:11:37 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2013-01-06 01:11:37 +0000 |
commit | c21c7152558140154fc16bb6cad06bcdf4ffce81 (patch) | |
tree | b6bf8130d0091957e82d92457930fa848ef6e53c /contrib | |
parent | 9d275cd77140538e1fee3c0740f6922fcb635673 (diff) |
Fix dts-hd regression
The previous dca-resync libav patch broke dts-hd
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5151 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/ffmpeg/A05-dca-resync.patch | 86 |
1 files changed, 60 insertions, 26 deletions
diff --git a/contrib/ffmpeg/A05-dca-resync.patch b/contrib/ffmpeg/A05-dca-resync.patch index edc2e76fa..3e32c7a74 100644 --- a/contrib/ffmpeg/A05-dca-resync.patch +++ b/contrib/ffmpeg/A05-dca-resync.patch @@ -1,37 +1,71 @@ -From 280e670dd039d7ba628bc47f1cdee72df9658094 Mon Sep 17 00:00:00 2001 +From 021a7700ff839b295b5776d4552563de1a448df6 Mon Sep 17 00:00:00 2001 From: John Stebbins <[email protected]> -Date: Wed, 2 Jan 2013 11:32:40 -0800 -Subject: [PATCH] dca_parser: Handle loss of bitstream sync better +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 -when the sync pattern is not found where it is expected, reset and -recalculate the framesize. +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 | 11 +++++++++++ - 1 file changed, 11 insertions(+) + 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..ad441f8 100644 +index ab235cf..75e9321 100644 --- a/libavcodec/dca_parser.c +++ b/libavcodec/dca_parser.c -@@ -88,6 +88,17 @@ static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf, - pc1->size = 0; - return i - 3; +@@ -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; + } } -+ else if (pc1->size == pc1->framesize) -+ { -+ // Lost sync, search for sync and reset framesize as it may -+ // have changed mid-stream -+ pc->frame_start_found = 0; -+ pc->state = -1; -+ pc1->size = 0; -+ pc1->framesize = 0; -+ pc1->lastmarker = 0; -+ return END_NOT_FOUND; -+ } - } +@@ -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, } - pc->frame_start_found = start_found; + + /* 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.11.7 +1.7.10.4 |