Merge commit 'b0c7e3ffd09f68022429920da483ad7abed84aa1'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 23 Jan 2013 15:34:34 +0000 (16:34 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 23 Jan 2013 15:34:52 +0000 (16:34 +0100)
* commit 'b0c7e3ffd09f68022429920da483ad7abed84aa1':
  mlp_parser: account for AVCodecContext.request_channels when setting the channel layout.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/mlp_parser.c

@@@ -325,14 -320,25 +325,26 @@@ static int mlp_parse(AVCodecParserConte
          avctx->sample_rate = mh.group1_samplerate;
          s->duration = mh.access_unit_size;
  
 +        if(!avctx->channels || !avctx->channel_layout) {
          if (mh.stream_type == 0xbb) {
              /* MLP stream */
-             avctx->channels       = mh.channels_mlp;
-             avctx->channel_layout = mh.channel_layout_mlp;
+             if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
+                 mh.num_substreams > 1) {
+                 avctx->channels       = 2;
+                 avctx->channel_layout = AV_CH_LAYOUT_STEREO;
+             } else {
+                 avctx->channels       = mh.channels_mlp;
+                 avctx->channel_layout = mh.channel_layout_mlp;
+             }
          } else { /* mh.stream_type == 0xba */
              /* TrueHD stream */
-             if (mh.channels_thd_stream2) {
+             if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
+                 mh.num_substreams > 1) {
+                 avctx->channels       = 2;
+                 avctx->channel_layout = AV_CH_LAYOUT_STEREO;
+             } else if (mh.channels_thd_stream2 &&
+                        (avctx->request_channels <= 0 ||
+                         avctx->request_channels > mh.channels_thd_stream1)) {
                  avctx->channels       = mh.channels_thd_stream2;
                  avctx->channel_layout = mh.channel_layout_thd_stream2;
              } else {