From patchwork Fri Sep 16 14:49:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 37957 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1019877pzh; Fri, 16 Sep 2022 07:49:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4/4vJVcKjOlibcCidey5DZI4ZzsHbiaH0hnkjhUhiEmoZOlI9iLsrqQ2bN5DQfMiBsNnsW X-Received: by 2002:a17:907:2e01:b0:77e:d84d:9e07 with SMTP id ig1-20020a1709072e0100b0077ed84d9e07mr3882819ejc.674.1663339780834; Fri, 16 Sep 2022 07:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663339780; cv=none; d=google.com; s=arc-20160816; b=Qb5FXKzL+TMXhGp6qcXpKeKLJTCCk5rqygA4gcntOuVOPMTi4sgQMkyt2TdrQ/ikHY tA5KJwCHafsgYSnB00WxC12o5PHgDvFCYEUvfl1NfmeIMZN9oEQpaxle6lqcSv8UvsRA ogxk9r7nhHzVXBkOQNA2FO78/yFMjbiUUUO6SyBbGq6kXvn1dmVaniKJM4Ax6tmdCCpJ Ybc2duopIPhNd+0NCdK/S2vvUhkbIj/zR4Jd/B54m1UWyJsGgApvcB1EvEf9cnLwzXon 7mGZ9MzeWHi35AF63boMAchjs3k8NAK/83MF4cTPR4fT4tQJOvwlPYcy/wGoQko2IaOL cfwA== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=wjzlWYROQKMoSkDxA7HeAqYWApFbHhMTR/O8746XQ9g=; b=SPS0rM28P+gpw2V4qUrjCttqsL++r5gJJYa2tZ60wLgfBe60tRQVH7Iw2spU50xuDr 2Bxq/XAATUPUrjzRy2dBEtu9qe4LhQMiUWhly4pEuEi4ut7E4TifZifXj9jrSOQN8yEM Ib7RD4UySVgUxECv623wD/eZjjRv/MKD5HvW24mYcomlN7deHnFJ9WlwBAvap4UP4cAo x7xscmXtMsfJVXGxHySlGRqPC2Bl7YHeSZk7FwVAlCGuh15cXdYI4fHATyI1TQQOVkjB KUXL/6oZRIYAYeR401OfXoJzloh3mMSJt5YkDb/SrF//D0TytceZqjXngC1jsj3x5Ah5 sPGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=nJnOx4AO; 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 oz35-20020a1709077da300b007413f3cdd18si16296322ejc.238.2022.09.16.07.49.40; Fri, 16 Sep 2022 07:49:40 -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=nJnOx4AO; 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 865BE68BBE3; Fri, 16 Sep 2022 17:49:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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-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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: WIRpHyBA3HmX 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)