summaryrefslogtreecommitdiff
path: root/libavcodec/dca_parser.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-09-18 10:39:34 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-09-18 10:39:34 +0200
commitf9ccdcb6ce0a874c81c41c2a42f609a8cdc5ddae (patch)
tree9201e8d218dbd86c009055c11f6daeed0d7a0404 /libavcodec/dca_parser.c
parent2dd38a1d486a1abc3ccb76c963424f23d162be51 (diff)
parent8411baf6f0a42bdd61f00f34aa9efec7e138b5f2 (diff)
Merge commit '8411baf6f0a42bdd61f00f34aa9efec7e138b5f2'
* commit '8411baf6f0a42bdd61f00f34aa9efec7e138b5f2': dca_parser: Handle changes in DCA frame size Conflicts: libavcodec/dca_parser.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/dca_parser.c')
-rw-r--r--libavcodec/dca_parser.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c
index c10426845f..9b73371128 100644
--- a/libavcodec/dca_parser.c
+++ b/libavcodec/dca_parser.c
@@ -61,6 +61,7 @@ static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf,
if (!pc1->lastmarker || state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER) {
start_found = 1;
pc1->lastmarker = state;
+ i++;
break;
}
}
@@ -75,10 +76,6 @@ static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf,
if (IS_MARKER(state, i, buf, buf_size) && (state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER)) {
if(pc1->framesize > pc1->size)
continue;
- // We have to check that we really read a full frame here, and that it isn't a pure HD frame, because their size is not constant.
- if(!pc1->framesize && state == pc1->lastmarker && state != DCA_HD_MARKER){
- pc1->framesize = pc1->hd_pos ? pc1->hd_pos : pc1->size;
- }
pc->frame_start_found = 0;
pc->state = -1;
pc1->size = 0;
@@ -100,7 +97,7 @@ static av_cold int dca_parse_init(AVCodecParserContext * s)
}
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 };
@@ -120,7 +117,11 @@ static int dca_parse_params(const uint8_t *buf, int buf_size, int *duration,
return AVERROR_INVALIDDATA;
*duration = 256 * (sample_blocks / 8);
- skip_bits(&gb, 20);
+ *framesize = get_bits(&gb, 14) + 1;
+ if (*framesize < 95)
+ return AVERROR_INVALIDDATA;
+
+ skip_bits(&gb, 6);
sr_code = get_bits(&gb, 4);
*sample_rate = avpriv_dca_sample_rates[sr_code];
if (*sample_rate == 0)
@@ -151,7 +152,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