diff mbox series

[FFmpeg-devel] avcodec/avcodec: Use the new API fields to validate the layout returned by decoders

Message ID 20220916143743.1704-1-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel] avcodec/avcodec: Use the new API fields to validate the layout returned by decoders | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 fail Make fate failed
andriy/make_x86 success Make finished
andriy/make_fate_x86 fail Make fate failed

Commit Message

James Almer Sept. 16, 2022, 2:37 p.m. UTC
This block was scheduled for removal, which means that no validation would have
taken place after the old API was removed.
It was algo going to mistakenly remove an unrelated bits_per_coded_sample
check.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/avcodec.c | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 29643199be..8fdb25961b 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -321,24 +321,12 @@  FF_DISABLE_DEPRECATION_WARNINGS
         avctx->channels = avctx->ch_layout.nb_channels;
         avctx->channel_layout = avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ?
                                 avctx->ch_layout.u.mask : 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
         /* validate channel layout from the decoder */
-        if (avctx->channel_layout) {
-            int channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
-            if (!avctx->channels)
-                avctx->channels = channels;
-            else if (channels != avctx->channels) {
-                char buf[512];
-                av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout);
-                av_log(avctx, AV_LOG_WARNING,
-                       "Channel layout '%s' with %d channels does not match specified number of channels %d: "
-                       "ignoring specified channel layout\n",
-                       buf, channels, avctx->channels);
-                avctx->channel_layout = 0;
-            }
-        }
-        if (avctx->channels && avctx->channels < 0 ||
-            avctx->channels > FF_SANE_NB_CHANNELS) {
+        if (!av_channel_layout_check(&avctx->ch_layout) ||
+            avctx->ch_layout.nb_channels > FF_SANE_NB_CHANNELS) {
             ret = AVERROR(EINVAL);
             goto free_and_end;
         }
@@ -346,8 +334,6 @@  FF_DISABLE_DEPRECATION_WARNINGS
             ret = AVERROR(EINVAL);
             goto free_and_end;
         }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
 
 #if FF_API_AVCTX_TIMEBASE
         if (avctx->framerate.num > 0 && avctx->framerate.den > 0)