]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/avcodec: Move decoder channel count check to ff_decode_preinit
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 16 Mar 2021 19:07:20 +0000 (20:07 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 20 Mar 2021 01:45:10 +0000 (02:45 +0100)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/avcodec.c
libavcodec/decode.c

index b3940b97e0bb3bc139888b45e88d378273314cf2..2f3896dcc48eb80224fb59539516f78826799831 100644 (file)
@@ -270,14 +270,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
         ret = AVERROR(EINVAL);
         goto free_and_end;
     }
-    if (av_codec_is_decoder(codec) &&
-        codec->type == AVMEDIA_TYPE_AUDIO &&
-        !(codec->capabilities & AV_CODEC_CAP_CHANNEL_CONF) &&
-        avctx->channels == 0) {
-        av_log(avctx, AV_LOG_ERROR, "Decoder requires channel count but channels not set\n");
-        ret = AVERROR(EINVAL);
-        goto free_and_end;
-    }
 
     if (avctx->sample_rate < 0) {
         av_log(avctx, AV_LOG_ERROR, "Invalid sample rate: %d\n", avctx->sample_rate);
index cbd41c8cc8467ee3d795bd2737c5bc6b510dab38..390147908d08b2cc81b75149ec968353a0985266 100644 (file)
@@ -2026,6 +2026,11 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
+    if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && avctx->channels == 0 &&
+        !(avctx->codec->capabilities & AV_CODEC_CAP_CHANNEL_CONF)) {
+        av_log(avctx, AV_LOG_ERROR, "Decoder requires channel count but channels not set\n");
+        return AVERROR(EINVAL);
+    }
     if (avctx->codec->max_lowres < avctx->lowres || avctx->lowres < 0) {
         av_log(avctx, AV_LOG_WARNING, "The maximum value for lowres supported by the decoder is %d\n",
                avctx->codec->max_lowres);