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 9C34240993 for ; Wed, 23 Mar 2022 16:29:24 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9016A68B14F; Wed, 23 Mar 2022 18:29:22 +0200 (EET) Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9B93768AA63 for ; Wed, 23 Mar 2022 18:29:16 +0200 (EET) Received: by mail-ot1-f49.google.com with SMTP id e25-20020a0568301e5900b005b236d5d74fso1441002otj.0 for ; Wed, 23 Mar 2022 09:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=xhYazy0IN9sbE5h6PKQiPOIetBxoEDQowgFf36o9dqA=; b=D9A46DRdxAUBG45Mrq3PGpuQnPSf4Q2XuF9iEuCOWGRGZyFevPkuLyYk1zNAicKYVe jAPVrS0Y4kvbHvBYI1wjSulbRMA9z3wbzlhW+0RgwL4v2b2MqgH98UnZNrrUZVxLgOGL 9zGUIdrtsE8eVvIinVT9zlT1kWf++KGKhhhdPHHnalKOcM0+ikkkkSn5/aBOvyo/PVcY lCiWnZMRE21TKcQyBGnbiIwRyCvlUGL9FWZ6Ol+kQ1Z1GO2WZLYWTB5Crc/Ibs+e2g5f re9G+aKClwM1Qpblc8llMiDw0QmcDuhfE6W+EPqCO/sz1MnYDgSWlXwncdE6wiFBiDl+ O1/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=xhYazy0IN9sbE5h6PKQiPOIetBxoEDQowgFf36o9dqA=; b=1Vv/Zs9Qvm3FEFYNTk6bbRVg9GzjcU3NCTAsKpWY+tLcx7qH33SKcsKBMt8R39K7O4 cGZLRGazkGwiDD1/0Il1L+1Emy0mgzdqLsKUnnSbrLE/9MtTWZyWndzvHtWMlcXeOBIx REQ5Mgt3qxHK0vDvY8Mb7HVzE5WXJnOyiHY6PiHv3Ftv5T+OJ0W6ryfMer6ytarfjdbu jzW6ch4nPagYTXqsI0EhQ0XzwqhNgb72c8lBvdBYxMT5wK5MmMtfCs2eylL3xJpVOqYk K34TQCc91v94+bmDRbwIMNkaFI8CC468dMS7B16eKATerGMYqBuAYd9D2BN0DvzZnlz+ yAeA== X-Gm-Message-State: AOAM532tXgOT05htOyFzqNvj2B8SKZLOQ9iSVIdC+OwntrwVtRRGNmtj YshFUzXGHZydMJd8LsV6h35rZJC2JG3atQ== X-Google-Smtp-Source: ABdhPJyXdhQwJR3Jc3ITR5xTW54H0uoODvAXJcLuzp/38OMaeFmMKDm0BG8hplOG3bOIRCLeQG1WrA== X-Received: by 2002:a05:6830:1498:b0:5cd:a787:e8c1 with SMTP id s24-20020a056830149800b005cda787e8c1mr308036otq.11.1648052954459; Wed, 23 Mar 2022 09:29:14 -0700 (PDT) Received: from [192.168.0.13] ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id o2-20020a05687072c200b000d9ae3e1fabsm149854oak.12.2022.03.23.09.29.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Mar 2022 09:29:13 -0700 (PDT) Message-ID: <367f4d8c-5a36-af62-b4de-f2b0f69458d0@gmail.com> Date: Wed, 23 Mar 2022 13:29:11 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20220323155720.20017-1-anton@khirnov.net> <20220323155720.20017-2-anton@khirnov.net> From: James Almer In-Reply-To: <20220323155720.20017-2-anton@khirnov.net> Subject: Re: [FFmpeg-devel] [PATCH 2/8] lavc/avcodec: only allocate the encoding frame for encoders 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 3/23/2022 12:57 PM, Anton Khirnov wrote: > And only when needed, i.e. for encoders using the simple API. > --- > libavcodec/avcodec.c | 4 +--- > libavcodec/encode.c | 7 +++++++ > 2 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c > index dbaa9f78a2..c7daa385e7 100644 > --- a/libavcodec/avcodec.c > +++ b/libavcodec/avcodec.c > @@ -180,14 +180,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code > > avci->buffer_frame = av_frame_alloc(); > avci->buffer_pkt = av_packet_alloc(); > - avci->es.in_frame = av_frame_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->es.in_frame || !avci->in_pkt || > - !avci->last_pkt_props || !avci->pkt_props) { > + !avci->in_pkt || !avci->last_pkt_props || !avci->pkt_props) { > ret = AVERROR(ENOMEM); > goto free_and_end; > } > diff --git a/libavcodec/encode.c b/libavcodec/encode.c > index 70bd8da81f..837ffaa40d 100644 > --- a/libavcodec/encode.c > +++ b/libavcodec/encode.c > @@ -412,6 +412,7 @@ int attribute_align_arg avcodec_receive_packet(AVCodecContext *avctx, AVPacket * > > int ff_encode_preinit(AVCodecContext *avctx) > { > + AVCodecInternal *avci = avctx->internal; > int i; > > if (avctx->time_base.num <= 0 || avctx->time_base.den <= 0) { > @@ -563,5 +564,11 @@ FF_ENABLE_DEPRECATION_WARNINGS > if (avctx->codec_descriptor->props & AV_CODEC_PROP_INTRA_ONLY) > avctx->internal->intra_only_flag = AV_PKT_FLAG_KEY; > > + if (ffcodec(avctx->codec)->encode2) { > + avci->es.in_frame = av_frame_alloc(); Could use the chance to remove the EncodeSimpleContext struct and just have in_frame in AVCodecInternal. DecodeSimpleContext was removed the same way some time ago when it became a struct for a single field. > + if (!avci->es.in_frame) > + return AVERROR(ENOMEM); > + } > + > return 0; > } _______________________________________________ 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".