summaryrefslogtreecommitdiff
path: root/libavcodec/ac3dec.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2010-01-28 23:19:33 +0000
committerJustin Ruggles <justin.ruggles@gmail.com>2010-01-28 23:19:33 +0000
commit2c2cdc0bfbe14710c321c1a9beb2605d89950557 (patch)
tree4f07a257e132542950216ba2f2657006927be1e3 /libavcodec/ac3dec.c
parent836fc7778513fa97c1852444155f82627ecbb8cd (diff)
downloadffmpeg-2c2cdc0bfbe14710c321c1a9beb2605d89950557.tar.gz
Simplify error handling by processing header errors separate from CRC and
buffer size vs. frame size errors. Originally committed as revision 21519 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/ac3dec.c')
-rw-r--r--libavcodec/ac3dec.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 8b78a0a50c..9f45af3280 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -1236,21 +1236,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
*data_size = 0;
err = parse_frame_header(s);
- /* check that reported frame size fits in input buffer */
- if(!err && s->frame_size > buf_size) {
- av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
- err = AAC_AC3_PARSE_ERROR_FRAME_SIZE;
- }
-
- /* check for crc mismatch */
- if(err != AAC_AC3_PARSE_ERROR_FRAME_SIZE && avctx->error_recognition >= FF_ER_CAREFUL) {
- if(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) {
- av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n");
- err = AAC_AC3_PARSE_ERROR_CRC;
- }
- }
-
- if(err && err != AAC_AC3_PARSE_ERROR_CRC) {
+ if (err) {
switch(err) {
case AAC_AC3_PARSE_ERROR_SYNC:
av_log(avctx, AV_LOG_ERROR, "frame sync error\n");
@@ -1278,6 +1264,18 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
av_log(avctx, AV_LOG_ERROR, "invalid header\n");
break;
}
+ } else {
+ /* check that reported frame size fits in input buffer */
+ if (s->frame_size > buf_size) {
+ av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
+ err = AAC_AC3_PARSE_ERROR_FRAME_SIZE;
+ } else if (avctx->error_recognition >= FF_ER_CAREFUL) {
+ /* check for crc mismatch */
+ if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) {
+ av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n");
+ err = AAC_AC3_PARSE_ERROR_CRC;
+ }
+ }
}
/* if frame is ok, set audio parameters */