mirror of https://git.ffmpeg.org/ffmpeg.git
mlp_parser: Drop in-parser downmix functionality
request_channel_layout is a decoder option and it makes no sense to have it in a parser. This feature was needed in the past when the decoder was allowed to reuse the avctx from the demuxer. Nowadays the decoder receives only the parameters from it, already containing the real channel layout (and the correct request_channel_layout option). After initialization the decoder overwrites the channel layout with the downmixed one that is actually output, so there is no need to preserve this functionality in the parser. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
This commit is contained in:
parent
dd3aa85b68
commit
970c76f322
|
@ -120,11 +120,6 @@ static uint64_t truehd_layout(int chanmap)
|
||||||
return layout;
|
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)
|
static int mlp_get_major_sync_size(const uint8_t * buf, int bufsize)
|
||||||
{
|
{
|
||||||
int has_extension, extensions = 0;
|
int has_extension, extensions = 0;
|
||||||
|
@ -336,8 +331,6 @@ static int mlp_parse(AVCodecParserContext *s,
|
||||||
} else {
|
} else {
|
||||||
BitstreamContext bc;
|
BitstreamContext bc;
|
||||||
MLPHeaderInfo mh;
|
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);
|
bitstream_init8(&bc, buf + 4, buf_size - 4);
|
||||||
if (ff_mlp_read_major_sync(avctx, &mh, &bc) < 0)
|
if (ff_mlp_read_major_sync(avctx, &mh, &bc) < 0)
|
||||||
|
@ -353,21 +346,11 @@ static int mlp_parse(AVCodecParserContext *s,
|
||||||
|
|
||||||
if (mh.stream_type == 0xbb) {
|
if (mh.stream_type == 0xbb) {
|
||||||
/* MLP stream */
|
/* 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->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 (stereo_requested && mh.num_substreams > 1) {
|
if (!mh.channels_thd_stream2) {
|
||||||
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)) {
|
|
||||||
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 {
|
} else {
|
||||||
|
|
|
@ -63,6 +63,4 @@ typedef struct MLPHeaderInfo
|
||||||
|
|
||||||
int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, BitstreamContext *bc);
|
int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, BitstreamContext *bc);
|
||||||
|
|
||||||
int ff_mlp_channel_layout_subset(uint64_t channel_layout, uint64_t mask);
|
|
||||||
|
|
||||||
#endif /* AVCODEC_MLP_PARSER_H */
|
#endif /* AVCODEC_MLP_PARSER_H */
|
||||||
|
|
|
@ -178,6 +178,11 @@ static const uint64_t thd_channel_order[] = {
|
||||||
AV_CH_LOW_FREQUENCY_2, // LFE2
|
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,
|
static uint64_t thd_channel_layout_extract_channel(uint64_t channel_layout,
|
||||||
int index)
|
int index)
|
||||||
{
|
{
|
||||||
|
@ -511,7 +516,7 @@ static int read_restart_header(MLPDecodeContext *m, BitstreamContext *bc,
|
||||||
s->max_channel = max_channel;
|
s->max_channel = max_channel;
|
||||||
s->max_matrix_channel = max_matrix_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) {
|
m->max_decoded_substream > substr) {
|
||||||
av_log(m->avctx, AV_LOG_DEBUG,
|
av_log(m->avctx, AV_LOG_DEBUG,
|
||||||
"Extracting %d-channel downmix (0x%"PRIx64") from substream %d. "
|
"Extracting %d-channel downmix (0x%"PRIx64") from substream %d. "
|
||||||
|
|
Loading…
Reference in New Issue