summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-09-18 21:38:08 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-09-22 01:05:59 +0200
commit90edbd3185e6fac04aed739e2bdef9c69d574b17 (patch)
treeb60f252f1dbec352e86c541a06d6b52888d378e1 /libavcodec
parenta06a2d89434abd8feb760a943924f3cfacedfda6 (diff)
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>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/avcodec.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 737c4bcd04..a85d3c2309 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -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