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 ESMTPS id 907C74CB94 for ; Mon, 24 Feb 2025 08:06:55 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 210AC68CDC3; Mon, 24 Feb 2025 10:05:21 +0200 (EET) Received: from vidala.pars.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6249E68CDC9 for ; Mon, 24 Feb 2025 10:05:19 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; s=202405r; d=lynne.ee; c=relaxed/relaxed; h=Message-ID:Date:Subject:To:From; t=1740384318; bh=P3hTPA/UNP9UQQAgtrTzi0+ gX331yUlN+ZdSVl/Ubu4=; b=TMbIt+/BBFM8Ol3ddaAqTnDwV9lwc48J5ZGKJewroqzQbiu9Lk e7hEQqW+0P30LiRXoJIqep4t69KlbZRjwUw37gvRX518xP317YhEwxiYMbluPRgMJb0v/Stw0bo QUILMTwtNbgZiCmul8WFln6/pq1oBXjA84FJIMwIrKxGpYa1u8ddlXly9q6qMvbFsYb3F4XfjAl c1f3gVyPNlYkj9FI3WYYWkAVxBJAL7wlvqwy8ebhEApU+xmlnjkwh6o1CuqjY6sySBYhT62Z/Kw HlkfO/v0u6fgSHpWCWwbJx+kB2NDRTrXtcU/g7Vqpr3IjAvaIKdR2vxKTfPcknOVj7Q==; DKIM-Signature: v=1; a=ed25519-sha256; s=202405e; d=lynne.ee; c=relaxed/relaxed; h=Message-ID:Date:Subject:To:From; t=1740384318; bh=P3hTPA/UNP9UQQAgtrTzi0+ gX331yUlN+ZdSVl/Ubu4=; b=ZRA0G9x9e6nmC77uJgaUWO2jVND1nVNrc6JqEbjaWF8z3Clb84 RB1D9Jc76fqyzuwTjc0aEFrTLHLbt9zyThDQ==; From: Lynne To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Feb 2025 09:05:08 +0100 Message-ID: <20250224080516.5711-1-dev@lynne.ee> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250224080434.5632-1-dev@lynne.ee> References: <20250224080434.5632-1-dev@lynne.ee> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 11/12] ffv1dec: reference the current packet into the main context 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 Cc: Lynne 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/ffv1.h | 3 +++ libavcodec/ffv1dec.c | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index 22acac35e4..9af17326b3 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -169,6 +169,9 @@ typedef struct FFV1Context { * NOT shared between frame threads. */ uint8_t frame_damaged; + + /* Reference to the current packet */ + AVPacket *pkt_ref; } FFV1Context; int ff_ffv1_common_init(AVCodecContext *avctx, FFV1Context *s); diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 990fdc3711..5ab41da1b7 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -455,6 +455,10 @@ static av_cold int decode_init(AVCodecContext *avctx) FFV1Context *f = avctx->priv_data; int ret; + f->pkt_ref = av_packet_alloc(); + if (!f->pkt_ref) + return AVERROR(ENOMEM); + if ((ret = ff_ffv1_common_init(avctx, f)) < 0) return ret; @@ -686,6 +690,10 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, /* Start */ if (hwaccel) { + ret = av_packet_ref(f->pkt_ref, avpkt); + if (ret < 0) + return ret; + ret = hwaccel->start_frame(avctx, avpkt->data, avpkt->size); if (ret < 0) return ret; @@ -705,15 +713,21 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, uint32_t len; ret = find_next_slice(avctx, avpkt->data, buf_end, i, &pos, &len); - if (ret < 0) + if (ret < 0) { + av_packet_unref(f->pkt_ref); return ret; + } buf_end -= len; ret = hwaccel->decode_slice(avctx, pos, len); - if (ret < 0) + if (ret < 0) { + av_packet_unref(f->pkt_ref); return ret; + } } + + av_packet_unref(f->pkt_ref); } else { ret = decode_slices(avctx, c, avpkt); if (ret < 0) @@ -809,6 +823,7 @@ static av_cold int ffv1_decode_close(AVCodecContext *avctx) ff_progress_frame_unref(&s->last_picture); av_refstruct_unref(&s->hwaccel_last_picture_private); + av_packet_free(&s->pkt_ref); ff_ffv1_close(s); return 0; -- 2.47.2 _______________________________________________ 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".