From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id B1EA4446B9 for ; Tue, 20 Sep 2022 22:47:23 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5451D68BAB7; Wed, 21 Sep 2022 01:47:20 +0300 (EEST) Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6604268B737 for ; Wed, 21 Sep 2022 01:47:14 +0300 (EEST) Received: by mail-oo1-f52.google.com with SMTP id u3-20020a4ab5c3000000b0044b125e5d9eso614568ooo.12 for ; Tue, 20 Sep 2022 15:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=GUOt0DaQffUV4JhI8IKv7Ki2MTitMwmeDAAfVdaR1Fw=; b=ZeWngwllJehuBoPDqNZSsFy1VWtd5kWzy2GW4eZx7j4OUD5MKkWeTlwnXnzueGc9Iu uTv2Ry4P5/DkmoDTlNMLW02NgHQvERgK2/iQXhlpWShS3SdTjEoWvCvDuSQyehLWZ/3G OkElj/r/F5fXrcjvD5/ft4PrH4Mjd3SyA1Q/uxAFxFOCJqJpmrmMgFBtYa/opucxJ2M4 uWwnhQCt2y61dlF+fPvWWiIPF91evbXdrbA3y3muhD11sWhoer7FRDJQJE16+aXBpzws k6DDR6gEZkAc6h4reUtuvbuHODkzuNXCABnoluGRxw4QX78TeUdsYxFpisoIQObR6Ebo dIbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=GUOt0DaQffUV4JhI8IKv7Ki2MTitMwmeDAAfVdaR1Fw=; b=51AVPxGNvCh60NZ+wyJ079dLht7xHu/tbm0wc6/Bc2Gb5e5L0k/jzzWCqZgAQEE8rk B29Hx2ymlh+luQSw/F9pYUVDx5u1On7Ze9xIskgIBAnah99G7spzGHz1l8GEeMLHAR7F dZvvaERTdY2IKKQOZgz/efzDCE9K0QEbNPjJAtti7V4dtsgbxDJjwZKheipQc2djmm7v epK/wIZc5yUFyK6Um2V/FsHvdq4Kr5UAkd+l/Xm1b1tFBbuolC2NNLQnukPq1j7bX28b pmXVB+sfS+lenaLryV+OjUz6Nx4l1iRfgSFt1hSKSwP5iYW4n01C11L1J88BZaad0FO5 LhFQ== X-Gm-Message-State: ACrzQf1MjsV+D+atJiem857Mz7XGrWUAi3/Pdbs4KMMdeC+X7V6AA7by V6SMYp/giarUIuXFVEVMGHTiJumNhSA= X-Google-Smtp-Source: AMsMyM6Algy5ShaD7vfd9XEFmLmm9OMAi1yhGr36qqKqZ+sGeApzEPrI6iHGui5GnE0vKjsmuNOvNA== X-Received: by 2002:a4a:ba91:0:b0:475:76d0:696d with SMTP id d17-20020a4aba91000000b0047576d0696dmr9480032oop.73.1663714032333; Tue, 20 Sep 2022 15:47:12 -0700 (PDT) Received: from [192.168.0.13] ([191.97.187.183]) by smtp.gmail.com with ESMTPSA id y17-20020a056870419100b0010d7242b623sm661853oac.21.2022.09.20.15.47.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Sep 2022 15:47:12 -0700 (PDT) Message-ID: Date: Tue, 20 Sep 2022 19:47:10 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: From: James Almer In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH 03/17] avcodec/avcodec: Check for more invalid channel layouts X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 9/18/2022 5:27 PM, Andreas Rheinhardt wrote: > In particular, check the provided channel layout for encoders > without AVCodec.ch_layouts set. This fixes an infinite loop > in the WavPack encoder (and maybe other issues in other encoders > as well) in case the channel count is zero. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/avcodec.c | 11 +++++++++++ > libavcodec/decode.c | 5 ----- > libavcodec/encode.c | 5 ----- > 3 files changed, 11 insertions(+), 10 deletions(-) > > diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c > index a165cdea95..96b69e0a17 100644 > --- a/libavcodec/avcodec.c > +++ b/libavcodec/avcodec.c > @@ -246,6 +246,17 @@ FF_DISABLE_DEPRECATION_WARNINGS > FF_ENABLE_DEPRECATION_WARNINGS > #endif > > + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && !avctx->ch_layout.nb_channels > + && !(codec->capabilities & AV_CODEC_CAP_CHANNEL_CONF)) { nit: Might be a good idea to add a comment that this decoder-only flag is being checked here even for encoders as it will be a no-op for those. > + av_log(avctx, AV_LOG_ERROR, "Codec requires channel layout to be set\n"); const char *codec_string = av_codec_is_encoder(codec) ? "Encoder" : "Decoder"; av_log(avctx, AV_LOG_ERROR, "%s requires channel layout to be set\n", codec_string); > + ret = AVERROR(EINVAL); > + goto free_and_end; > + } > + if (avctx->ch_layout.nb_channels && !av_channel_layout_check(&avctx->ch_layout)) { > + av_log(avctx, AV_LOG_ERROR, "Invalid channel layout\n"); > + ret = AVERROR(EINVAL); > + goto free_and_end; > + } > if (avctx->ch_layout.nb_channels > FF_SANE_NB_CHANNELS) { > av_log(avctx, AV_LOG_ERROR, "Too many channels: %d\n", avctx->ch_layout.nb_channels); > ret = AVERROR(EINVAL); > diff --git a/libavcodec/decode.c b/libavcodec/decode.c > index 2961705c9d..6be2d3d6ed 100644 > --- a/libavcodec/decode.c > +++ b/libavcodec/decode.c > @@ -1595,11 +1595,6 @@ FF_DISABLE_DEPRECATION_WARNINGS > FF_ENABLE_DEPRECATION_WARNINGS > #endif > > - if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && avctx->ch_layout.nb_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); > diff --git a/libavcodec/encode.c b/libavcodec/encode.c > index 2168b88ea8..92e8337227 100644 > --- a/libavcodec/encode.c > +++ b/libavcodec/encode.c > @@ -600,11 +600,6 @@ static int encode_preinit_audio(AVCodecContext *avctx) > return AVERROR(EINVAL); > } > if (avctx->codec->ch_layouts) { > - if (!av_channel_layout_check(&avctx->ch_layout)) { > - av_log(avctx, AV_LOG_WARNING, "Channel layout not specified correctly\n"); > - return AVERROR(EINVAL); > - } > - > for (i = 0; avctx->codec->ch_layouts[i].nb_channels; i++) { > if (!av_channel_layout_compare(&avctx->ch_layout, &avctx->codec->ch_layouts[i])) > break; _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".