diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2008-05-31 15:30:55 +0000 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2008-05-31 15:30:55 +0000 |
commit | c78c6d6c588c1db60cf2a1bd5bc65095852f91fc (patch) | |
tree | 3cd29963c751893f7f7dd37d85ef5e5ad7f2e8e8 /libavcodec | |
parent | 4dc471c30cb9c2671ae6c9cee783704a4d6d422d (diff) | |
download | ffmpeg-c78c6d6c588c1db60cf2a1bd5bc65095852f91fc.tar.gz |
move header error logging to after CRC check
Originally committed as revision 13579 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/ac3dec.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index bb81ff6916..0829784f27 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -1144,12 +1144,29 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, } /* parse the syncinfo */ + *data_size = 0; err = ac3_parse_header(s); - if(err) { + + /* 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 = AC3_PARSE_ERROR_FRAME_SIZE; + } + + /* check for crc mismatch */ + if(err != AC3_PARSE_ERROR_FRAME_SIZE && avctx->error_resilience >= 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 = 1; + } + } + + /* parse the syncinfo */ + if(err && err != 1) { switch(err) { case AC3_PARSE_ERROR_SYNC: - av_log(avctx, AV_LOG_ERROR, "frame sync error : cannot use error concealment\n"); - return -1; + av_log(avctx, AV_LOG_ERROR, "frame sync error\n"); + break; case AC3_PARSE_ERROR_BSID: av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n"); break; @@ -1168,20 +1185,6 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, } } - /* check that reported frame size fits in input buffer */ - if(s->frame_size > buf_size) { - av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); - return -1; - } - - /* check for crc mismatch */ - if(!err && avctx->error_resilience >= 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 = 1; - } - } - /* if frame is ok, set audio parameters */ if (!err) { avctx->sample_rate = s->sample_rate; |