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 B12BB401C2 for ; Fri, 16 Sep 2022 14:49:40 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 466B468BBE2; Fri, 16 Sep 2022 17:49:37 +0300 (EEST) Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 89ADA68BB11 for ; Fri, 16 Sep 2022 17:49:31 +0300 (EEST) Received: by mail-oi1-f174.google.com with SMTP id p187so6424783oia.9 for ; Fri, 16 Sep 2022 07:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=xuCB3WRopCViOQzW22RyC1JZoytk2VoP6ktAyxUcwSQ=; b=nJnOx4AOut4dDmR1AyCwA7Dc0CnPB1lJ5hDxzGYVvbZD3qhPbo4rHOAKnv45UdnnED Mh/Zy5esWLVkkBU7Mb2wVWe2ursbV9lYqetMCnC9tJtJ2Yz/Opl0sq95ZKCCQdGKkZC8 OwgM1xcfvaXeQ5DP/9Rlj7pS+9MaAAp9GSythq4V13N7mbFj/F+Icg50lSLxpfngiuov Meilf3cxGar7ZlaLM+TL/0YXhAnRcfDmiqcNnjV9oT3ksv1ms5tTpCRmFsOPmS67I0Ow na0DWyNKq47qLGqQjbE4m6v+dEjt55vlxSq4m0tAyq+qlEljVKtELc60aYlPgEVCZj1y MHCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=xuCB3WRopCViOQzW22RyC1JZoytk2VoP6ktAyxUcwSQ=; b=xF6UBrQDAMusH7K2VytY+EBdOAOEYIE4NVUNuBmcs62xaedz6hcMu3WVOtt0Zx27IM z+wln3ymArvlRJFbuhFoCf7MqCDf/CN+QHmOoSNQhALwCkJheqfF1rydFisVI6xUYDu4 7VdKp+WVzBALfN6qTSPwaWurCzJJ1NteJgwFcy8xOAFnYRcAJQXgEpnInYR0DkzoDcKl qpFYMOsHvSIw+b+SYbLsvsr2av7p+mDyQQv4ZOciA6o9ZNG+JQdyiGy3AfxLKsP0BcNN sjXIfxwEr0/Unyz1xvFP7E30RR+7zbM1h0jRLYIFzGo9Yq2ZO1QWUTL8cHGSXF/3NpBh zNTw== X-Gm-Message-State: ACrzQf1/ECaFk8iyGWxCzLwPyRqz5f/i5Yr3aoH55jdk1B0zW36XwAGh YpjIjqBYGEj5iEJfZ68ptpTYbhbr7dc= X-Google-Smtp-Source: AMsMyM7yEFJfLCDItHc3pxfdWwm1dvAIE9Eu9dtYo/KBH/V/oLcYHH1hX9Ocsny+jqL96Aj0lJ7WmA== X-Received: by 2002:a54:438f:0:b0:34f:53b:2418 with SMTP id u15-20020a54438f000000b0034f053b2418mr2501539oiv.59.1663339769443; Fri, 16 Sep 2022 07:49:29 -0700 (PDT) Received: from localhost.localdomain ([191.97.187.183]) by smtp.gmail.com with ESMTPSA id a13-20020a544e0d000000b00342d207e68bsm8990783oiy.37.2022.09.16.07.49.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 07:49:29 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Sep 2022 11:49:17 -0300 Message-Id: <20220916144917.1723-1-jamrial@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220916143743.1704-1-jamrial@gmail.com> References: <20220916143743.1704-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] avcodec/avcodec: Use the new API fields to validate the layout returned by decoders 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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 --- libavcodec/avcodec.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 29643199be..1f8ab37abb 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 ((avctx->ch_layout.nb_channels && !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) -- 2.37.3 _______________________________________________ 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".