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 2E9064082C for ; Wed, 23 Mar 2022 15:58:29 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0E2E668B195; Wed, 23 Mar 2022 17:57:46 +0200 (EET) 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 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: --- 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; -- 2.34.1 _______________________________________________ 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".