From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 326BC4D12F for ; Fri, 9 Jan 2026 20:36:03 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'v/A4f9EFsTg2Dy9Ztqalvxb/qcadfG4PfCycFUYXsxU=', expected b'MMdlQFq/VZEgXTWS0ZTEgTulGLnuy7OzARdkE6h+P+M=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1767990954; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=v/A4f9EFsTg2Dy9Ztqalvxb/qcadfG4PfCycFUYXsxU=; b=Wcnlm/PRLAVQyEH0YsJLhyhmzbt8Zguv8RoIAYVFiC+qv5kp8WAPeEiyYdvIhqBFXrDxL i1FINCDy8JLeiLuL0jaKemWl2BdtYbfekSIZfD8SXXp4ct7xFEjwVbHDeM4FrGiDYscko0f k8Ub+RYE2SozdW62h4dU677FNc+lO2aWcPu7TIL/R/Jtbniar8PCIEoG8j0AxJcI9rKvUWk fpUzANV9EyRMnxt1QSdFP5G0c8QUoccuKdTeifrkmMZXgI+BA3Z4ADjtFZ4hfLUKFrAuyQL yGsYr9TsQDg0R17TK12Aze9CghFTgpugfwHxE5XWopA9WBpnK7nWyRP5hHOA== Received: from [172.20.0.4] (unknown [172.20.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 1EF86690DEE; Fri, 9 Jan 2026 22:35:54 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1767990937; b=rmB8Bb96Vpik8W1m5UnI/1wBLv3lY3Q8iI2U8DvQeySCy7iuIv4O57Y82YOoTqlH/E06y UFDaBW2j9xjLvnFAAbh4yEAi9NuStlyaB4/cVZ08NuuYaTrATcdFgQVXEYrA+AQETgho7S+ TW60QXKEAlmR93/W2Hlw/SmdUQT+Lp1OiueioBHmKG6zp359aq/OqTitsFHkd3qeSUenxff P+fVSeQamzxJ1vsvurBXOQWgNbDVYScMOcJl97uO9M2nnEZ8dIV83uqcQKnUgdJIltvMuPj 6+p6VKrl0pUqM4HsE8h9Rvz0JiTJ8GYGn7cbN9liGVSdgBqt2C5MsyfghRrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1767990937; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=NGTMJn+f4uNKBHLdSupkG27/DJ3zZDFRdm7S32Ox6zc=; b=ebJ0xw37acI4rTYTvTb9onATnBqPuhyUNbzsPsIm8Iu1xqUDWxHUGRJNGFSN/HsTS6aAl ZqKwrptIcZFIR+nv4t1mvAuMylYxA+QxYrvW0orucgIBBoQ+PBEy0l5LtT7KndIMHM7g/0f VQNmRSi5NuqPdv0Id0kywrJ26XLFb1o71Nj3d3OED3TggsE0MfCeKajFYv7SkAIk1kxMQSs zR5o6IB/Mrwbghq8R9/3kefQ9bFMTLPbVs3HF47eyLB/8LVjqbzi1bfTwZnr1KEyvDQAVs/ 13TFNDHST/RulOLkwoIf6dx49++g3qxla0euRGpQ9m4zTEdjLqutibrn/n2Q== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1767990930; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=MMdlQFq/VZEgXTWS0ZTEgTulGLnuy7OzARdkE6h+P+M=; b=PNhkiJhJ9RZCKQjq7B66GBwDO3mUzyfOS1tqE1nFGcVq92edePQFznar1EOy4VOTjfw6G tbHnU+NihmZbTUyRpPbevS7t01qf1RhCzedhJh69YTGFYEAb0P+XE71G40mog5APdGGy60s YLUTPC4ntjdR4Us9hCmSuE1m5QfpT5nSCQoQDw/PuoC5SpWBIZ16l2Y9IfCX/Nz4U6FDorl 4+U7o4iyFAuU6C65HgDraGsJKXZQtbTQ9G3LKFRGcDKXeMcPeb5FPB++KcwqUWYqAhUPcdh UInObDoo1XjqD6Ah/HyL6I70yz364FipuO0iXOkWBEAsdtZe01CPqSI+0ZMQ== Received: from f7c34508609e (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 2A918690D6E for ; Fri, 9 Jan 2026 22:35:30 +0200 (EET) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Fri, 09 Jan 2026 20:35:29 -0000 Message-ID: <176799093035.25.2766450463378227296@4457048688e7> Message-ID-Hash: JXZ2NYNIWSFXZBPCNUPG2MGSAQ7F4YGF X-Message-ID-Hash: JXZ2NYNIWSFXZBPCNUPG2MGSAQ7F4YGF X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PR] avcodec/lcevc: attach a reference to the source frame to each passed in base picture (PR #21423) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: James Almer via ffmpeg-devel Cc: James Almer Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #21423 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21423 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21423.patch This way we can ensure a frame reference will always exists for as long as the external library needs the base picture. >>From 644f1eaa829956060c2cf589fc7ddee9599a21ca Mon Sep 17 00:00:00 2001 From: James Almer Date: Wed, 7 Jan 2026 12:16:27 -0300 Subject: [PATCH] avcodec/lcevc: attach a reference to the source frame to each passed in base picture This way we can ensure a frame reference will always exists for as long as the external library needs the base picture. Signed-off-by: James Almer --- libavcodec/lcevcdec.c | 46 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/libavcodec/lcevcdec.c b/libavcodec/lcevcdec.c index 4f6d793625..865903bbd9 100644 --- a/libavcodec/lcevcdec.c +++ b/libavcodec/lcevcdec.c @@ -110,6 +110,7 @@ static int lcevc_send_frame(void *logctx, FFLCEVCFrame *frame_ctx, const AVFrame { FFLCEVCContext *lcevc = frame_ctx->lcevc; const AVFrameSideData *sd = av_frame_get_side_data(in, AV_FRAME_DATA_LCEVC); + AVFrame *opaque; LCEVC_PictureHandle picture; LCEVC_ReturnCode res; int ret = 0; @@ -125,9 +126,23 @@ static int lcevc_send_frame(void *logctx, FFLCEVCFrame *frame_ctx, const AVFrame if (ret < 0) return ret; + opaque = av_frame_clone(in); + if (!opaque) { + LCEVC_FreePicture(lcevc->decoder, picture); + return AVERROR(ENOMEM); + } + + res = LCEVC_SetPictureUserData(lcevc->decoder, picture, opaque); + if (res != LCEVC_Success) { + LCEVC_FreePicture(lcevc->decoder, picture); + av_frame_free(&opaque); + return AVERROR_EXTERNAL; + } + res = LCEVC_SendDecoderBase(lcevc->decoder, in->pts, picture, -1, NULL); if (res != LCEVC_Success) { LCEVC_FreePicture(lcevc->decoder, picture); + av_frame_free(&opaque); return AVERROR_EXTERNAL; } @@ -184,18 +199,13 @@ static int generate_output(void *logctx, FFLCEVCFrame *frame_ctx, AVFrame *out) return 0; } -static int lcevc_receive_frame(void *logctx, FFLCEVCFrame *frame_ctx, AVFrame *out) +static int lcevc_flush_pictures(FFLCEVCContext *lcevc) { - FFLCEVCContext *lcevc = frame_ctx->lcevc; LCEVC_PictureHandle picture; LCEVC_ReturnCode res; - int ret; - - ret = generate_output(logctx, frame_ctx, out); - if (ret < 0) - return ret; while (1) { + AVFrame *base = NULL; res = LCEVC_ReceiveDecoderBase (lcevc->decoder, &picture); if (res != LCEVC_Success && res != LCEVC_Again) return AVERROR_EXTERNAL; @@ -203,6 +213,9 @@ static int lcevc_receive_frame(void *logctx, FFLCEVCFrame *frame_ctx, AVFrame *o if (res == LCEVC_Again) break; + LCEVC_GetPictureUserData(lcevc->decoder, picture, (void **)&base); + av_frame_free(&base); + res = LCEVC_FreePicture(lcevc->decoder, picture); if (res != LCEVC_Success) return AVERROR_EXTERNAL; @@ -211,6 +224,18 @@ static int lcevc_receive_frame(void *logctx, FFLCEVCFrame *frame_ctx, AVFrame *o return 0; } +static int lcevc_receive_frame(void *logctx, FFLCEVCFrame *frame_ctx, AVFrame *out) +{ + FFLCEVCContext *lcevc = frame_ctx->lcevc; + int ret; + + ret = generate_output(logctx, frame_ctx, out); + if (ret < 0) + return ret; + + return lcevc_flush_pictures(lcevc); +} + static void event_callback(LCEVC_DecoderHandle dec, LCEVC_Event event, LCEVC_PictureHandle pic, const LCEVC_DecodeInformation *info, const uint8_t *data, uint32_t size, void *logctx) @@ -227,8 +252,11 @@ static void event_callback(LCEVC_DecoderHandle dec, LCEVC_Event event, static void lcevc_free(AVRefStructOpaque unused, void *obj) { FFLCEVCContext *lcevc = obj; - if (lcevc->initialized) + if (lcevc->initialized) { + LCEVC_FlushDecoder(lcevc->decoder); + lcevc_flush_pictures(lcevc); LCEVC_DestroyDecoder(lcevc->decoder); + } memset(lcevc, 0, sizeof(*lcevc)); } @@ -277,7 +305,7 @@ int ff_lcevc_process(void *logctx, AVFrame *frame) if (ret) return ret < 0 ? ret : 0; - lcevc_receive_frame(logctx, frame_ctx, frame); + ret = lcevc_receive_frame(logctx, frame_ctx, frame); if (ret < 0) return ret; -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org