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 B8DCB43ED6 for ; Fri, 16 Sep 2022 14:38:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DB72568BBE2; Fri, 16 Sep 2022 17:38:24 +0300 (EEST) 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-Google-Smtp-Source: AMsMyM7rxxCLf2rU1boeEm78FlwP/VmAV8ujrvVBjSqHXKAdKJAuxDo0WzB1e5HzYsulnDJft8gBzA== 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 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..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) -- 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".