If AVCodecContext.channel_layout and AVCodecContext.channels are both
authorJustin Ruggles <justin.ruggles@gmail.com>
Tue, 19 Apr 2011 23:02:32 +0000 (19:02 -0400)
committerJustin Ruggles <justin.ruggles@gmail.com>
Wed, 27 Apr 2011 16:57:43 +0000 (12:57 -0400)
non-zero, check to make sure they do not contradict eachother.

libavcodec/utils.c

index 8bb4d19..e4ea1e5 100644 (file)
@@ -578,6 +578,13 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
                 }
             }
         }
+        if (avctx->channel_layout && avctx->channels) {
+            if (av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels) {
+                av_log(avctx, AV_LOG_ERROR, "channel layout does not match number of channels\n");
+                ret = AVERROR(EINVAL);
+                goto free_and_end;
+            }
+        }
     }
 
     if(avctx->codec->init && !(avctx->active_thread_type&FF_THREAD_FRAME)){