[FFmpeg-cvslog] r18153 - trunk/libavcodec/flacdec.c

jbr subversion
Sun Mar 22 22:07:43 CET 2009


Author: jbr
Date: Sun Mar 22 22:07:43 2009
New Revision: 18153

Log:
flacdec: give a more accurate error message when validating channel 
layout. differentiates between invalid values and unsupported values.

Modified:
   trunk/libavcodec/flacdec.c

Modified: trunk/libavcodec/flacdec.c
==============================================================================
--- trunk/libavcodec/flacdec.c	Sun Mar 22 22:01:08 2009	(r18152)
+++ trunk/libavcodec/flacdec.c	Sun Mar 22 22:07:43 2009	(r18153)
@@ -483,7 +483,7 @@ static inline int decode_subframe(FLACCo
 static int decode_frame(FLACContext *s)
 {
     int bs_code, sr_code, bps_code, i;
-    int ch_mode, bps, blocksize, samplerate;
+    int ch_mode, bps, blocksize, samplerate, channels;
     GetBitContext *gb = &s->gb;
 
     /* frame sync code */
@@ -496,10 +496,17 @@ static int decode_frame(FLACContext *s)
     /* channels and decorrelation */
     ch_mode = get_bits(gb, 4);
     if (ch_mode < FLAC_MAX_CHANNELS && s->channels == ch_mode+1) {
+        channels = ch_mode + 1;
         ch_mode = FLAC_CHMODE_INDEPENDENT;
-    } else if (ch_mode > FLAC_CHMODE_MID_SIDE || s->channels != 2) {
-        av_log(s->avctx, AV_LOG_ERROR, "unsupported channel assignment %d (channels=%d)\n",
-               ch_mode, s->channels);
+    } else if (ch_mode <= FLAC_CHMODE_MID_SIDE) {
+        channels = 2;
+    } else {
+        av_log(s->avctx, AV_LOG_ERROR, "invalid channel mode: %d\n", ch_mode);
+        return -1;
+    }
+    if (channels != s->channels) {
+        av_log(s->avctx, AV_LOG_ERROR, "switching channel layout mid-stream "
+                                       "is not supported\n");
         return -1;
     }
 



More information about the ffmpeg-cvslog mailing list