From patchwork Wed Mar 23 15:57:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 34938 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:ab0:5fda:0:0:0:0:0 with SMTP id g26csp922147uaj; Wed, 23 Mar 2022 08:58:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQYCsT65BYB27XFDS1cpoCJzg4B7+Y/ESFU2AJu2V/VcaofVJJwQqIPxAX74y8+wXV2wQD X-Received: by 2002:a17:907:da6:b0:6e0:c59:f3ad with SMTP id go38-20020a1709070da600b006e00c59f3admr718419ejc.85.1648051088466; Wed, 23 Mar 2022 08:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648051088; cv=none; d=google.com; s=arc-20160816; b=fDlwztN9jPCLHeRSrctLFz/ManIhehZwikNG1sbPSVKKOFICTydbBUrqtFz+1OzWWS 7Xlf+Ab7kh5ZkK45yp+taQvm2KkYiunU8cA726MKKCeCguEebMZdbdsYgonA8/2kvaZc 5t7kGzhkyWhwe0GMCNDhKViu9EAYeVUIikm2FrR4RGfayyykTQUl7UGXqN9R/wAWgQt4 vzYn21OKHqrROqieuRe8xsPFG/kGDHaxWMFkqPdH5vT5nPK+Vd9ULshmFkSvbm4JTsTj CGVdECvorwyqHaE7n6H6cC0v3C436aZR2qVv3/4ubHPej7btrWRrHom+JJWsjja2oC8k yP6Q== 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:delivered-to; bh=S813cgAkXmMcdk87/UOkQVGcu+Z2y6wSnthtWH28cus=; b=qz3YYrdHiucrK9rlMGOl01Snhpv2ViqX1bl0lxLvB13/zk8xPFiqlQ4XyRd4lcKzRu LGkRKnVkbmCGsGk7V/bTQNTeBaGEdNwfgt5tEU/Is16O/avhQOoMS6a7Y5Uv5pMiofdS pbccmfD5UKpe4zLapBZxqmCk1Zn7PmhXgLn41Zuq8nKytEgMQSOzg+kfePYyKJVRlV3D G/GECLfjO3gb4hOslnFnlFEFoxXHsEprRIe6ouyQkmJS5mDxD+IhM+cHdK5QESPu6eSZ 5/+XxDgyzHIUAZ02liZNvj2/u6kyxrGwnR+j7jNXToxF7HDRHislL4qCWMemCg6faiR0 EMLA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hr39-20020a1709073fa700b006df76385d16si14190616ejc.438.2022.03.23.08.58.08; Wed, 23 Mar 2022 08:58:08 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8642368B185; Wed, 23 Mar 2022 17:57:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0E69768B03F for ; Wed, 23 Mar 2022 17:57:37 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 862DC2400F5 for ; Wed, 23 Mar 2022 16:57:36 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id x1YIMnopV-Qz for ; Wed, 23 Mar 2022 16:57:36 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 995172404FE for ; Wed, 23 Mar 2022 16:57:34 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 9C28A3A06CD; Wed, 23 Mar 2022 16:57:34 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 23 Mar 2022 16:57:16 +0100 Message-Id: <20220323155720.20017-4-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220323155720.20017-1-anton@khirnov.net> References: <20220323155720.20017-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/8] lavc/snow: only allocate mconly_picture for decoding 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: mnV05FoMKQPE It is not used in the encoder. --- libavcodec/snow.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 0a500695ce..1224b95491 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -513,20 +513,23 @@ int ff_snow_common_init_after_header(AVCodecContext *avctx) { int ret, emu_buf_size; if(!s->scratchbuf) { - if ((ret = ff_get_buffer(s->avctx, s->mconly_picture, - AV_GET_BUFFER_FLAG_REF)) < 0) - return ret; + if (av_codec_is_decoder(avctx->codec)) { + if ((ret = ff_get_buffer(s->avctx, s->mconly_picture, + AV_GET_BUFFER_FLAG_REF)) < 0) + return ret; + + if (s->mconly_picture->format != avctx->pix_fmt) { + av_log(avctx, AV_LOG_ERROR, "pixel format changed\n"); + return AVERROR_INVALIDDATA; + } + } + emu_buf_size = FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * (2 * MB_SIZE + HTAPS_MAX - 1); if (!FF_ALLOCZ_TYPED_ARRAY(s->scratchbuf, FFMAX(s->mconly_picture->linesize[0], 2*avctx->width+256) * 7 * MB_SIZE) || !FF_ALLOCZ_TYPED_ARRAY(s->emu_edge_buffer, emu_buf_size)) return AVERROR(ENOMEM); } - if(s->mconly_picture->format != avctx->pix_fmt) { - av_log(avctx, AV_LOG_ERROR, "pixel format changed\n"); - return AVERROR_INVALIDDATA; - } - for(plane_index=0; plane_index < s->nb_planes; plane_index++){ int w= s->avctx->width; int h= s->avctx->height;