mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-05 14:30:00 +01:00
avcodec/mlpdec: don't depend on context channel layout when setting substream masks
If avctx->ch_layout is unset (as it's allowed and even expeced by the AV_CODEC_CAP_CHANNEL_CONF flag), the code setting substream masks will fail for stereo and mono layouts unless a downmix channel was requested. Fix this by deriving the mask with coded values only. Fixes issue #20764. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
@@ -319,8 +319,10 @@ static av_cold int mlp_decode_init(AVCodecContext *avctx)
|
||||
av_channel_layout_uninit(&avctx->ch_layout);
|
||||
avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1;
|
||||
}
|
||||
else
|
||||
else {
|
||||
av_log(avctx, AV_LOG_WARNING, "Invalid downmix layout\n");
|
||||
av_channel_layout_uninit(&m->downmix_layout);
|
||||
}
|
||||
}
|
||||
|
||||
ff_thread_once(&init_static_once, init_static);
|
||||
@@ -453,26 +455,22 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
|
||||
}
|
||||
m->substream[1].mask = mh.channel_layout_thd_stream1;
|
||||
if (mh.channels_thd_stream1 == 2 &&
|
||||
mh.channels_thd_stream2 == 2 &&
|
||||
m->avctx->ch_layout.nb_channels == 2)
|
||||
mh.channels_thd_stream2 == 2)
|
||||
m->substream[0].mask = AV_CH_LAYOUT_STEREO;
|
||||
if ((substr = (mh.num_substreams > 1)))
|
||||
m->substream[0].mask = AV_CH_LAYOUT_STEREO;
|
||||
if (mh.num_substreams == 1 &&
|
||||
mh.channels_thd_stream1 == 1 &&
|
||||
mh.channels_thd_stream2 == 1 &&
|
||||
m->avctx->ch_layout.nb_channels == 1)
|
||||
mh.channels_thd_stream2 == 1)
|
||||
m->substream[0].mask = AV_CH_LAYOUT_MONO;
|
||||
if (mh.num_substreams > 2)
|
||||
if (mh.channel_layout_thd_stream2)
|
||||
m->substream[2].mask = mh.channel_layout_thd_stream2;
|
||||
else
|
||||
m->substream[2].mask = mh.channel_layout_thd_stream1;
|
||||
if (m->avctx->ch_layout.nb_channels > 2)
|
||||
if (mh.num_substreams > 2)
|
||||
m->substream[1].mask = mh.channel_layout_thd_stream1;
|
||||
else
|
||||
m->substream[mh.num_substreams > 1].mask = mh.channel_layout_thd_stream2;
|
||||
if (mh.num_substreams == 2 && (!m->downmix_layout.nb_channels ||
|
||||
m->downmix_layout.nb_channels > 2))
|
||||
m->substream[1].mask = mh.channel_layout_thd_stream2;
|
||||
}
|
||||
|
||||
m->needs_reordering = mh.channel_arrangement >= 18 && mh.channel_arrangement <= 20;
|
||||
|
||||
Reference in New Issue
Block a user