diff options
author | Tim Walker <tdskywalker@gmail.com> | 2012-12-31 15:33:26 +0100 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2013-01-22 16:10:02 -0500 |
commit | b0c7e3ffd09f68022429920da483ad7abed84aa1 (patch) | |
tree | bb7a5478b6474177fc0d76c963c3b4ade135e6fd /libavcodec | |
parent | 1fd2deedcc6400e08b31566a547a5fac3b38cefb (diff) | |
download | ffmpeg-b0c7e3ffd09f68022429920da483ad7abed84aa1.tar.gz |
mlp_parser: account for AVCodecContext.request_channels when setting the channel layout.
Allows users to configure the output based on what's actually decoded, rather than the full native layout.
Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/mlp_parser.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/libavcodec/mlp_parser.c b/libavcodec/mlp_parser.c index 31c79c9ca2..8c57840bd8 100644 --- a/libavcodec/mlp_parser.c +++ b/libavcodec/mlp_parser.c @@ -322,11 +322,23 @@ static int mlp_parse(AVCodecParserContext *s, 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 { |