From patchwork Wed Mar 23 15:57:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 34940 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:ab0:5fda:0:0:0:0:0 with SMTP id g26csp922223uaj; Wed, 23 Mar 2022 08:58:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzx1lWf2tJKE5VTlR8lkU51r1QvbsTkl12ZmT1NU1Ylw0ALiUVKkMtYId6fvZYK92GbmRPZ X-Received: by 2002:a17:906:99c2:b0:6d7:4a6a:e35d with SMTP id s2-20020a17090699c200b006d74a6ae35dmr651413ejn.633.1648051112365; Wed, 23 Mar 2022 08:58:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648051112; cv=none; d=google.com; s=arc-20160816; b=ziJcgZRib+yN6+A00ek8k4aIHOXnzNjxT8+y9hhZ0jd9yS+ca6VKkeEMUu7g+NGqiB FLSoTKB2pvalLltjRW4+QPyLra87FyE95UVlr7yYqnwcBYty4bT60Zxu9znXq0qjpIZX Pw1WlR6g89F/t9SzuAlmSG3YApW/wKZLkqFoS3o1Aa++78Xdkr6rXGkKqmU/P2Z8pz8B 8cSTfLhu3aDZD+58+CCA07sJbuPdnydYKyPm0zTH9u8sbSSm+rwsFZ7L7KUzCnNYMRnK G+/hGWKcFJlGKq+TP2v9fIlK8CJUF9j4oL7sJXJF2Ho7wo8v/xeu9vdZQsCaRik+riha D4LQ== 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=QmlrSRylJnMYzTM+G7ysz8tIZmVOsKrdnC69ZY5ruQo=; b=idFUuLwpxkN8fJr85wxHm8cFMZHyi2oOK4jby7TRS/6w9LWY/6I4cp1VoobXrkO8NX Z0l4lpsic+dXIoEwzj0+0e8knw+yIZLXxdk1ZeXx7eg3NYNVdYOleIn2gzIPY4wRKEr5 5LWpSWGuCWNyU+cyxAHwH/Rl6JEBw5jKIKy1O1RteQ8moNOAQE3Cik/I4mpk9A+E9GxR Yg860vsvKWNyy3heGFRwm6DwDc8MKrV8HNgB0bwI2BOgmhYcabX9bxfcxSmEYKUQLON8 W/IiwW45W4ltjofIiv9i4GTZKwPTqOXgUpasxsqUDgHqWFt+51fMJHsYYgkUfx0cLFit npZA== 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 ss24-20020a170907c01800b006dfd81499c7si9414166ejc.828.2022.03.23.08.58.31; Wed, 23 Mar 2022 08:58:32 -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 4009168B167; Wed, 23 Mar 2022 17:57:46 +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 11A7068B15A for ; Wed, 23 Mar 2022 17:57:38 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 8235424017E for ; Wed, 23 Mar 2022 16:57:37 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id UgPqCYMOfApd for ; Wed, 23 Mar 2022 16:57:37 +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 B98D2240506 for ; Wed, 23 Mar 2022 16:57:34 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id A37F93A0763; Wed, 23 Mar 2022 16:57:34 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 23 Mar 2022 16:57:18 +0100 Message-Id: <20220323155720.20017-6-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 6/8] lavc/avcodec: only allocate decoding packets for 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: 6bdq0Bwc5q4s --- libavcodec/avcodec.c | 7 +------ libavcodec/decode.c | 8 ++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index c7daa385e7..5fd988a41c 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -180,12 +180,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code avci->buffer_frame = av_frame_alloc(); avci->buffer_pkt = av_packet_alloc(); - avci->in_pkt = av_packet_alloc(); - avci->last_pkt_props = av_packet_alloc(); - avci->pkt_props = av_fifo_alloc2(1, sizeof(*avci->last_pkt_props), - AV_FIFO_FLAG_AUTO_GROW); - if (!avci->buffer_frame || !avci->buffer_pkt || - !avci->in_pkt || !avci->last_pkt_props || !avci->pkt_props) { + if (!avci->buffer_frame || !avci->buffer_pkt) { ret = AVERROR(ENOMEM); goto free_and_end; } diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 3733e6d4b8..bb3857afd9 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1527,6 +1527,7 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) int ff_decode_preinit(AVCodecContext *avctx) { + AVCodecInternal *avci = avctx->internal; int ret = 0; /* if the decoder init function was already called previously, @@ -1605,6 +1606,13 @@ FF_ENABLE_DEPRECATION_WARNINGS avctx->export_side_data |= AV_CODEC_EXPORT_DATA_MVS; } + avci->in_pkt = av_packet_alloc(); + avci->last_pkt_props = av_packet_alloc(); + avci->pkt_props = av_fifo_alloc2(1, sizeof(*avci->last_pkt_props), + AV_FIFO_FLAG_AUTO_GROW); + if (!avci->in_pkt || !avci->last_pkt_props || !avci->pkt_props) + return AVERROR(ENOMEM); + ret = decode_bsfs_init(avctx); if (ret < 0) return ret;