# HG changeset patch # User jbr # Date 1212247855 0 # Node ID ec4e01cb00897011131c484786cf10ab2c97d280 # Parent 8e907d8094f5b58d0b2955deb89fa3db47c38fb7 move header error logging to after CRC check diff -r 8e907d8094f5 -r ec4e01cb0089 ac3dec.c --- a/ac3dec.c Sat May 31 14:38:34 2008 +0000 +++ b/ac3dec.c Sat May 31 15:30:55 2008 +0000 @@ -1144,12 +1144,29 @@ } /* 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 @@ } } - /* 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;