diff options
author | James Almer <jamrial@gmail.com> | 2017-10-30 16:52:36 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2017-10-30 16:52:36 -0300 |
commit | e3ebc293c624ff4cb9e225c269a466290788bb55 (patch) | |
tree | 792f73e38fac802369f02a9beb76b76fd4c3ec72 /libavcodec/mlp_parser.c | |
parent | 1242a6170e93351b519a0b92861654d5ff14d8dc (diff) | |
parent | 94c54d97e7f4fe90570c323803f2bdf6246c1010 (diff) | |
download | ffmpeg-e3ebc293c624ff4cb9e225c269a466290788bb55.tar.gz |
Merge commit '94c54d97e7f4fe90570c323803f2bdf6246c1010'
* commit '94c54d97e7f4fe90570c323803f2bdf6246c1010':
mlp: Factor out channel layout subset checks
Merged-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/mlp_parser.c')
-rw-r--r-- | libavcodec/mlp_parser.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/libavcodec/mlp_parser.c b/libavcodec/mlp_parser.c index d131106cfc..379c644e36 100644 --- a/libavcodec/mlp_parser.c +++ b/libavcodec/mlp_parser.c @@ -119,6 +119,11 @@ uint64_t ff_truehd_layout(int chanmap) return layout; } +int ff_mlp_channel_layout_subset(uint64_t channel_layout, uint64_t mask) +{ + return channel_layout && ((channel_layout & mask) == channel_layout); +} + static int mlp_get_major_sync_size(const uint8_t * buf, int bufsize) { int has_extension, extensions = 0; @@ -341,6 +346,8 @@ static int mlp_parse(AVCodecParserContext *s, } else { GetBitContext gb; MLPHeaderInfo mh; + int stereo_requested = ff_mlp_channel_layout_subset(avctx->request_channel_layout, + AV_CH_LAYOUT_STEREO); init_get_bits(&gb, buf + 4, (buf_size - 4) << 3); if (ff_mlp_read_major_sync(avctx, &mh, &gb) < 0) @@ -357,10 +364,7 @@ static int mlp_parse(AVCodecParserContext *s, if(!avctx->channels || !avctx->channel_layout) { if (mh.stream_type == 0xbb) { /* MLP stream */ - if (avctx->request_channel_layout && - (avctx->request_channel_layout & AV_CH_LAYOUT_STEREO) == - avctx->request_channel_layout && - mh.num_substreams > 1) { + if (stereo_requested && mh.num_substreams > 1) { avctx->channels = 2; avctx->channel_layout = AV_CH_LAYOUT_STEREO; } else { @@ -369,16 +373,12 @@ static int mlp_parse(AVCodecParserContext *s, } } else { /* mh.stream_type == 0xba */ /* TrueHD stream */ - if (avctx->request_channel_layout && - (avctx->request_channel_layout & AV_CH_LAYOUT_STEREO) == - avctx->request_channel_layout && - mh.num_substreams > 1) { + if (stereo_requested && mh.num_substreams > 1) { avctx->channels = 2; avctx->channel_layout = AV_CH_LAYOUT_STEREO; } else if (!mh.channels_thd_stream2 || - (avctx->request_channel_layout && - (avctx->request_channel_layout & mh.channel_layout_thd_stream1) == - avctx->request_channel_layout)) { + ff_mlp_channel_layout_subset(avctx->request_channel_layout, + mh.channel_layout_thd_stream1)) { avctx->channels = mh.channels_thd_stream1; avctx->channel_layout = mh.channel_layout_thd_stream1; } else { |