1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

avcodec/avcodec: Always use old channel count/layout if set

This ensures that if AVCodecContext.channels or
AVCodecContext.channel_layout are set, AVCodecContext.ch_layout
has the equivalent values after this block.

(In case these values are set inconsistently, the consistency check
for ch_layout below will error out.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-09-18 21:38:08 +02:00
parent a06a2d8943
commit 90edbd3185

View File

@ -232,7 +232,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->channel_layout && !avctx->channels)
avctx->channels = av_popcount64(avctx->channel_layout);
if ((avctx->channels > 0 && avctx->ch_layout.nb_channels != avctx->channels) ||
if ((avctx->channels && avctx->ch_layout.nb_channels != avctx->channels) ||
(avctx->channel_layout && (avctx->ch_layout.order != AV_CHANNEL_ORDER_NATIVE ||
avctx->ch_layout.u.mask != avctx->channel_layout))) {
av_channel_layout_uninit(&avctx->ch_layout);
@ -240,8 +240,8 @@ FF_DISABLE_DEPRECATION_WARNINGS
av_channel_layout_from_mask(&avctx->ch_layout, avctx->channel_layout);
} else {
avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
avctx->ch_layout.nb_channels = avctx->channels;
}
avctx->ch_layout.nb_channels = avctx->channels;
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif