[FFmpeg-devel] [PATCH]Plausibility check for TrueHD channel_layout

Carl Eugen Hoyos cehoyos at ag.or.at
Thu Mar 31 18:41:07 CEST 2011


Hi!

I believe libavcodec should not set channel_layout to values that must be 
wrong.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/mlp_parser.c b/libavcodec/mlp_parser.c
index 90b0d00..fa51747 100644
--- a/libavcodec/mlp_parser.c
+++ b/libavcodec/mlp_parser.c
@@ -325,6 +325,10 @@ static int mlp_parse(AVCodecParserContext *s,
                 avctx->channels = truehd_channels(mh.channels_thd_stream1);
                 avctx->channel_layout = truehd_layout(mh.channels_thd_stream1);
             }
+            if (av_popcount(avctx->channel_layout) != avctx->channels) {
+                avctx->channel_layout = 0;
+                av_log_ask_for_sample(avctx, "Unknown channel layout.");
+            }
         }
 
         if (!mh.is_vbr) /* Stream is CBR */


More information about the ffmpeg-devel mailing list