Merge commit 'ed1b01131e662c9086b27aaaea69684d8575fbea'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 23 Jan 2013 15:44:30 +0000 (16:44 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 23 Jan 2013 15:44:30 +0000 (16:44 +0100)
* commit 'ed1b01131e662c9086b27aaaea69684d8575fbea':
  mlp: implement support for AVCodecContext.request_channel_layout.

Conflicts:
libavcodec/mlpdec.c

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

@@@ -325,9 -320,9 +325,10 @@@ 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 */
+ #if FF_API_REQUEST_CHANNELS
              if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
                  mh.num_substreams > 1) {
                  avctx->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 {
+             } else if (avctx->request_channels > 0 &&
+                        avctx->request_channels <= mh.channels_thd_stream1) {
+                 avctx->channels       = mh.channels_thd_stream1;
+                 avctx->channel_layout = mh.channel_layout_thd_stream1;
+             } else
+ #endif
+             if (avctx->request_channel_layout == AV_CH_LAYOUT_STEREO &&
+                 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) {
                  avctx->channels       = mh.channels_thd_stream1;
                  avctx->channel_layout = mh.channel_layout_thd_stream1;
+             } else {
+                 avctx->channels       = mh.channels_thd_stream2;
+                 avctx->channel_layout = mh.channel_layout_thd_stream2;
              }
          }
 +        }
  
          if (!mh.is_vbr) /* Stream is CBR */
              avctx->bit_rate = mh.peak_bitrate;
@@@ -486,15 -445,12 +486,16 @@@ static int read_restart_header(MLPDecod
          return AVERROR_INVALIDDATA;
      }
  
-     if (m->avctx->request_channels > 0
-         && s->max_channel + 1 >= m->avctx->request_channels
-         && substr < m->max_decoded_substream) {
 +    s->min_channel = min_channel;
 +    s->max_channel = max_channel;
 +    s->max_matrix_channel = matrix_channel;
 +
+ #if FF_API_REQUEST_CHANNELS
+     if (m->avctx->request_channels > 0 &&
+         m->avctx->request_channels <= s->max_channel + 1 &&
+         m->max_decoded_substream > substr) {
          av_log(m->avctx, AV_LOG_DEBUG,
-                "Extracting %d channel downmix from substream %d. "
+                "Extracting %d-channel downmix from substream %d. "
                 "Further substreams will be skipped.\n",
                 s->max_channel + 1, substr);
          m->max_decoded_substream = substr;