mlp: improve request_channel_layout behavior.
authorTim Walker <tdskywalker@gmail.com>
Thu, 6 Feb 2014 21:50:38 +0000 (21:50 +0000)
committerTim Walker <tdskywalker@gmail.com>
Sat, 8 Feb 2014 12:39:37 +0000 (13:39 +0100)
Don't decode further substreams if request_channel_layout
is a subset of the current substream's channel_layout.

Before, we would only discard further substreams if
request_channel_layout matched the substream's
channel_layout extactly, thus decoding additional
channels which the caller would probably end up downmixing.

libavcodec/mlp_parser.c
libavcodec/mlpdec.c

index 8766bd0..a30cd05 100644 (file)
@@ -362,8 +362,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
                 mh.num_substreams > 1) {
                 avctx->channels       = 2;
                 avctx->channel_layout = AV_CH_LAYOUT_STEREO;
-            } else if (avctx->request_channel_layout == mh.channel_layout_thd_stream1 ||
-                       !mh.channels_thd_stream2) {
+            } else if (!mh.channels_thd_stream2 ||
+                       (mh.channel_layout_thd_stream1 & avctx->request_channel_layout) ==
+                       avctx->request_channel_layout) {
                 avctx->channels       = mh.channels_thd_stream1;
                 avctx->channel_layout = mh.channel_layout_thd_stream1;
             } else {
index 76ce4c4..d8a76f5 100644 (file)
@@ -504,8 +504,8 @@ FF_DISABLE_DEPRECATION_WARNINGS
     } else
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
-    if (m->avctx->request_channel_layout == s->ch_layout &&
-        m->max_decoded_substream > substr) {
+    if ((s->ch_layout & m->avctx->request_channel_layout) ==
+        m->avctx->request_channel_layout && m->max_decoded_substream > substr) {
         av_log(m->avctx, AV_LOG_DEBUG,
                "Extracting %d-channel downmix (0x%"PRIx64") from substream %d. "
                "Further substreams will be skipped.\n",