diff ac3dec.c @ 5680:5ae5a74b0e4b libavcodec

better AC3 header error reporting
author jbr
date Sat, 15 Sep 2007 02:41:24 +0000
parents 8f64e86e1b63
children ed3e9456f295
line wrap: on
line diff
--- a/ac3dec.c	Sat Sep 15 00:43:40 2007 +0000
+++ b/ac3dec.c	Sat Sep 15 02:41:24 2007 +0000
@@ -1089,16 +1089,32 @@
 {
     AC3DecodeContext *ctx = (AC3DecodeContext *)avctx->priv_data;
     int16_t *out_samples = (int16_t *)data;
-    int i, blk, ch;
+    int i, blk, ch, err;
 
     /* initialize the GetBitContext with the start of valid AC-3 Frame */
     init_get_bits(&ctx->gb, buf, buf_size * 8);
 
     /* parse the syncinfo */
-    if (ac3_parse_header(ctx)) {
-        av_log(avctx, AV_LOG_ERROR, "\n");
-        *data_size = 0;
-        return buf_size;
+    err = ac3_parse_header(ctx);
+    if(err) {
+        switch(err) {
+            case AC3_PARSE_ERROR_SYNC:
+                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;
+            case AC3_PARSE_ERROR_SAMPLE_RATE:
+                av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n");
+                break;
+            case AC3_PARSE_ERROR_FRAME_SIZE:
+                av_log(avctx, AV_LOG_ERROR, "invalid frame size\n");
+                break;
+            default:
+                av_log(avctx, AV_LOG_ERROR, "invalid header\n");
+                break;
+        }
+        return -1;
     }
 
     avctx->sample_rate = ctx->sampling_rate;