Commit 826188d2 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'ed1b0113'

* commit 'ed1b0113':
  mlp: implement support for AVCodecContext.request_channel_layout.

Conflicts:
	libavcodec/mlpdec.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 86b892af ed1b0113
...@@ -328,28 +328,45 @@ static int mlp_parse(AVCodecParserContext *s, ...@@ -328,28 +328,45 @@ static int mlp_parse(AVCodecParserContext *s,
if(!avctx->channels || !avctx->channel_layout) { if(!avctx->channels || !avctx->channel_layout) {
if (mh.stream_type == 0xbb) { if (mh.stream_type == 0xbb) {
/* MLP stream */ /* MLP stream */
#if FF_API_REQUEST_CHANNELS
if (avctx->request_channels > 0 && avctx->request_channels <= 2 && if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
mh.num_substreams > 1) { mh.num_substreams > 1) {
avctx->channels = 2; avctx->channels = 2;
avctx->channel_layout = AV_CH_LAYOUT_STEREO; avctx->channel_layout = AV_CH_LAYOUT_STEREO;
} 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 { } else {
avctx->channels = mh.channels_mlp; avctx->channels = mh.channels_mlp;
avctx->channel_layout = mh.channel_layout_mlp; avctx->channel_layout = mh.channel_layout_mlp;
} }
} else { /* mh.stream_type == 0xba */ } else { /* mh.stream_type == 0xba */
/* TrueHD stream */ /* TrueHD stream */
#if FF_API_REQUEST_CHANNELS
if (avctx->request_channels > 0 && avctx->request_channels <= 2 && if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
mh.num_substreams > 1) { mh.num_substreams > 1) {
avctx->channels = 2; avctx->channels = 2;
avctx->channel_layout = AV_CH_LAYOUT_STEREO; avctx->channel_layout = AV_CH_LAYOUT_STEREO;
} else if (mh.channels_thd_stream2 && } else if (avctx->request_channels > 0 &&
(avctx->request_channels <= 0 || avctx->request_channels <= mh.channels_thd_stream1) {
avctx->request_channels > mh.channels_thd_stream1)) { avctx->channels = mh.channels_thd_stream1;
avctx->channels = mh.channels_thd_stream2; avctx->channel_layout = mh.channel_layout_thd_stream1;
avctx->channel_layout = mh.channel_layout_thd_stream2; } else
} 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->channels = mh.channels_thd_stream1;
avctx->channel_layout = mh.channel_layout_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;
} }
} }
} }
......
...@@ -490,14 +490,24 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, ...@@ -490,14 +490,24 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
s->max_channel = max_channel; s->max_channel = max_channel;
s->max_matrix_channel = matrix_channel; s->max_matrix_channel = matrix_channel;
if (m->avctx->request_channels > 0 #if FF_API_REQUEST_CHANNELS
&& s->max_channel + 1 >= m->avctx->request_channels if (m->avctx->request_channels > 0 &&
&& substr < m->max_decoded_substream) { m->avctx->request_channels <= s->max_channel + 1 &&
m->max_decoded_substream > substr) {
av_log(m->avctx, AV_LOG_DEBUG, 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", "Further substreams will be skipped.\n",
s->max_channel + 1, substr); s->max_channel + 1, substr);
m->max_decoded_substream = substr; m->max_decoded_substream = substr;
} else
#endif
if (m->avctx->request_channel_layout == s->ch_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",
s->max_channel + 1, s->ch_layout, substr);
m->max_decoded_substream = substr;
} }
s->noise_shift = get_bits(gbp, 4); s->noise_shift = get_bits(gbp, 4);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment