[FFmpeg-cvslog] r21519 - trunk/libavcodec/ac3dec.c

jbr subversion
Fri Jan 29 00:19:33 CET 2010


Author: jbr
Date: Fri Jan 29 00:19:33 2010
New Revision: 21519

Log:
Simplify error handling by processing header errors separate from CRC and 
buffer size vs. frame size errors.

Modified:
   trunk/libavcodec/ac3dec.c

Modified: trunk/libavcodec/ac3dec.c
==============================================================================
--- trunk/libavcodec/ac3dec.c	Thu Jan 28 22:01:50 2010	(r21518)
+++ trunk/libavcodec/ac3dec.c	Fri Jan 29 00:19:33 2010	(r21519)
@@ -1236,21 +1236,7 @@ static int ac3_decode_frame(AVCodecConte
     *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(AVCodecConte
                 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 */



More information about the ffmpeg-cvslog mailing list