ffmpeg | branch: master | James Almer <jamr...@gmail.com> | Mon Oct 30 17:20:45 2017 -0300| [34542ac033f81601fd4dd684e993cc1716bb9a4d] | committer: James Almer
Merge commit '970c76f32283bddf3a5afd24fe52db7a96186244' * commit '970c76f32283bddf3a5afd24fe52db7a96186244': mlp_parser: Drop in-parser downmix functionality Merged-by: James Almer <jamr...@gmail.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=34542ac033f81601fd4dd684e993cc1716bb9a4d --- libavcodec/mlp_parser.c | 23 +++-------------------- libavcodec/mlp_parser.h | 2 -- libavcodec/mlpdec.c | 7 ++++++- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/libavcodec/mlp_parser.c b/libavcodec/mlp_parser.c index 379c644e36..3c0330f777 100644 --- a/libavcodec/mlp_parser.c +++ b/libavcodec/mlp_parser.c @@ -119,11 +119,6 @@ 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; @@ -346,8 +341,6 @@ 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) @@ -364,21 +357,11 @@ static int mlp_parse(AVCodecParserContext *s, if(!avctx->channels || !avctx->channel_layout) { if (mh.stream_type == 0xbb) { /* MLP stream */ - if (stereo_requested && 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; - } + avctx->channels = mh.channels_mlp; + avctx->channel_layout = mh.channel_layout_mlp; } else { /* mh.stream_type == 0xba */ /* TrueHD stream */ - if (stereo_requested && mh.num_substreams > 1) { - avctx->channels = 2; - avctx->channel_layout = AV_CH_LAYOUT_STEREO; - } else if (!mh.channels_thd_stream2 || - ff_mlp_channel_layout_subset(avctx->request_channel_layout, - mh.channel_layout_thd_stream1)) { + if (!mh.channels_thd_stream2) { avctx->channels = mh.channels_thd_stream1; avctx->channel_layout = mh.channel_layout_thd_stream1; } else { diff --git a/libavcodec/mlp_parser.h b/libavcodec/mlp_parser.h index 79c4efdb9a..c5a2883920 100644 --- a/libavcodec/mlp_parser.h +++ b/libavcodec/mlp_parser.h @@ -68,6 +68,4 @@ uint64_t ff_truehd_layout(int chanmap); extern const uint64_t ff_mlp_layout[32]; -int ff_mlp_channel_layout_subset(uint64_t channel_layout, uint64_t mask); - #endif /* AVCODEC_MLP_PARSER_H */ diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index 4d40e18f6e..63ec3e64bd 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -180,6 +180,11 @@ static const uint64_t thd_channel_order[] = { AV_CH_LOW_FREQUENCY_2, // LFE2 }; +static int mlp_channel_layout_subset(uint64_t channel_layout, uint64_t mask) +{ + return channel_layout && ((channel_layout & mask) == channel_layout); +} + static uint64_t thd_channel_layout_extract_channel(uint64_t channel_layout, int index) { @@ -533,7 +538,7 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, s->max_channel = max_channel; s->max_matrix_channel = max_matrix_channel; - if (ff_mlp_channel_layout_subset(m->avctx->request_channel_layout, s->mask) && + if (mlp_channel_layout_subset(m->avctx->request_channel_layout, s->mask) && m->max_decoded_substream > substr) { av_log(m->avctx, AV_LOG_DEBUG, "Extracting %d-channel downmix (0x%"PRIx64") from substream %d. " ====================================================================== diff --cc libavcodec/mlp_parser.c index 379c644e36,bff6258cba..3c0330f777 --- a/libavcodec/mlp_parser.c +++ b/libavcodec/mlp_parser.c @@@ -344,13 -329,11 +339,11 @@@ static int mlp_parse(AVCodecParserConte goto lost_sync; } } else { - BitstreamContext bc; + GetBitContext gb; MLPHeaderInfo mh; - int stereo_requested = ff_mlp_channel_layout_subset(avctx->request_channel_layout, - AV_CH_LAYOUT_STEREO); - bitstream_init8(&bc, buf + 4, buf_size - 4); - if (ff_mlp_read_major_sync(avctx, &mh, &bc) < 0) + init_get_bits(&gb, buf + 4, (buf_size - 4) << 3); + if (ff_mlp_read_major_sync(avctx, &mh, &gb) < 0) goto lost_sync; avctx->bits_per_raw_sample = mh.group1_bits; @@@ -361,24 -344,13 +354,14 @@@ 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 (stereo_requested && 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; - } + avctx->channels = mh.channels_mlp; + avctx->channel_layout = mh.channel_layout_mlp; } else { /* mh.stream_type == 0xba */ /* TrueHD stream */ - if (stereo_requested && mh.num_substreams > 1) { - avctx->channels = 2; - avctx->channel_layout = AV_CH_LAYOUT_STEREO; - } else if (!mh.channels_thd_stream2 || - ff_mlp_channel_layout_subset(avctx->request_channel_layout, - mh.channel_layout_thd_stream1)) { + if (!mh.channels_thd_stream2) { avctx->channels = mh.channels_thd_stream1; avctx->channel_layout = mh.channel_layout_thd_stream1; } else { diff --cc libavcodec/mlp_parser.h index 79c4efdb9a,871b96db20..c5a2883920 --- a/libavcodec/mlp_parser.h +++ b/libavcodec/mlp_parser.h @@@ -63,11 -61,6 +63,9 @@@ typedef struct MLPHeaderInf } MLPHeaderInfo; -int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, BitstreamContext *bc); +int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb); +uint64_t ff_truehd_layout(int chanmap); + +extern const uint64_t ff_mlp_layout[32]; - int ff_mlp_channel_layout_subset(uint64_t channel_layout, uint64_t mask); - #endif /* AVCODEC_MLP_PARSER_H */ _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog