From patchwork Fri Sep 16 14:37:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 37955 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1013827pzh; Fri, 16 Sep 2022 07:38:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5EpO8LxjjuoMjLVInp9jVcmPtPMwbp0XcRXq2ilYk3VT0y6+Jy2aNVFpZuqlxa0iosAoax X-Received: by 2002:aa7:c61a:0:b0:44e:7d1d:7814 with SMTP id h26-20020aa7c61a000000b0044e7d1d7814mr4172398edq.44.1663339109399; Fri, 16 Sep 2022 07:38:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663339109; cv=none; d=google.com; s=arc-20160816; b=HD+z+UiCUg0613QJMQ0z8YmvqDQb2hsgfxj6Is35TjmpnUpqYKsWC5PkalxAMbGETR Jyk4m40ErPEO0JaPbOLoKjOKaMVSc/hm4oHjXWbW0C30X7feGQ9bOLPV9kHgGcF34Utb eSore07n7BtgiL5V97bciOc3nqDvgQLYoHxvYUtmvcy97hIti2Tpx7QnH3YVhRVni3WO 1w+eVzj8BK3MsJtzlTII6iAqPdsEAuNZfnKRsTLZJ3sL1YIZZ7UFL3z7ZunWvlCRpQGB 3E+Evyq0nDLcsRBOkCfdStmDnCB6PAgzVZFp+ttXGxiYxgYagMD7ETrXRAjhu6LC3OaS ppSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=XWCMxXAbcw9pnK4nmVq5kq9mOt1dHMpMPYqofNDdRO8=; b=O/Ymsr9CrzMqu+wF0BD0wzh91R1kzOwzd0hs5/LfRKw5wezChlR7ZeseqZjnnrEInl +SDaeOy0hP8eooh9xh+BeTDek+etweyw/Sv/3+qobXXdh8Uo+oteIlFWBbOsEA6x1CcE 58mB5YA5t+jZJONjlHfJcKlx80m34U7FUH9vXZTyr8eGBXLTiTAHIXd+RbVVoI8gZuzo DSJe+xqczzRHlrtImsHJpj5BBSeyku/X9DulW2T49MihqMwSNrnA51wxbfmvkuU8lFNp P51IloKZs6fTh0xRSpPgdmuzXVJ2x4v2F4VUvrM39DDesQRSnu8s4MFiEDQyeVoLY9MR X8Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=jnmUCXAl; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i24-20020a50d758000000b004515a8c347dsi2169222edj.500.2022.09.16.07.38.28; Fri, 16 Sep 2022 07:38:29 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=jnmUCXAl; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2F84968BBE5; Fri, 16 Sep 2022 17:38:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C152F68BBDC for ; Fri, 16 Sep 2022 17:38:18 +0300 (EEST) Received: by mail-ot1-f46.google.com with SMTP id e35-20020a9d01a6000000b0065798eb8754so5891153ote.2 for ; Fri, 16 Sep 2022 07:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date; bh=EpX/CFsRg7io9/8WtO9kU44Js5JdNxi9N0JS/kbtn0E=; b=jnmUCXAlEP/O2mnAzKpPPE5fPuXxk3UXj5BmJTL/jEuVssFSuxT6+YzAXn2h0ldRur h9pBeYH2ZOn0C98mOqcyBC3B+q+n7rbg1WHLQkjwyGvsVjWg/GVJNbjpnzw/5WHnGz/a BASdoZeCQW7z/Wxz01azVhJeToLAheyF6LKt4xZ9U45lHB3dPlivVCFrtD8GFhuTpU/i UrRYDeT5fOoySHgYX4Ee9AudjLYCC8961NaWXruPwwKKv4/4CN4OSY6LyKVww55UpaX+ cBXIofcMu2VSFymjbKJTx5o7VCvQpybqIKn5V8DyfeHhbSj4SeFjdy9MTw4hnGgMARqq wYaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date; bh=EpX/CFsRg7io9/8WtO9kU44Js5JdNxi9N0JS/kbtn0E=; b=EYokGGyyL8a8qj2uOek0eq8syNwIgIu/zHJzdVS2kUNJ6NhFXAuES7rmGsO9ikxB21 /oqYKGMlCxJ/74/4llOdfQwdqQJpgn4kNICg+hsTH5aHaRLRV5zNBayaSzGOEE+MjbWR fFTYRuF2tWNB5hFL2cKlFJLZfUQ37MhZO5XovYgn5R+LySL+M3PTzHasypnrLiCrhDlB xNkcBKYOBZiCkPwj1YTGcDcIKcZHx1gLS2/Fvs9uxmDgAcfUH91O8er8tCWBwrE+043h xtzCteGBK+KcJTPUgNNAR50OCvdVz2eGl6z1Vp98UFIGPez/1YC4U5evJmi9dgeph14C RXRQ== X-Gm-Message-State: ACrzQf1NBa2rjqHmLQCnz0MW/QaScKt7DLfpz5UEgxtE84E7WTkC/jow 8MI6XEDk17FATVNlAElOqn6GvJVNOhk= X-Received: by 2002:a9d:6a87:0:b0:655:c206:2437 with SMTP id l7-20020a9d6a87000000b00655c2062437mr2483380otq.74.1663339096538; Fri, 16 Sep 2022 07:38:16 -0700 (PDT) Received: from localhost.localdomain ([191.97.187.183]) by smtp.gmail.com with ESMTPSA id t25-20020a056870f21900b0012779ba00fesm2955117oao.2.2022.09.16.07.38.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 07:38:16 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Sep 2022 11:37:43 -0300 Message-Id: <20220916143743.1704-1-jamrial@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: B17YpvcLC68Q 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..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)