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 0AD1646235 for ; Tue, 13 Jun 2023 04:48:34 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0307068C3D9; Tue, 13 Jun 2023 07:48:32 +0300 (EEST) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5C54268C378 for ; Tue, 13 Jun 2023 07:48:25 +0300 (EEST) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id 5B4581060152 for ; Tue, 13 Jun 2023 04:48:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1686631704; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=2FD3vApaB13iSbU1MZitjFW606RLDnU5ZjI6tSBp1XE=; b=gnFJK/Fi6kgA8DNqgxhNUWRmsiWS+UYzw2nVafY4ESAlQjMd9PwviK0O1TVtR/r/ AtELK9VWWRWkiLf7rBfLElDbDBip49YwEANECjPCZpptzcm3ma4ViJQ7zjFLk+i1390 vCpzonvkLOYlFnylwPO+npvfTYHgz8X5Ty2plFS60gddoV7FvP9ANWdjFxA/b2EokU5 wvxxtFlsX0VE6+O75FlVctaONKx5AMoPFTpXR882HReSSfv+F2TUM/YLxugnameG7sQ KWLNPjZ+6uKECZ/qAiAqUjc/XW4qpgmAMDyg7IidHbiOWqPpOy+ZJGz4t2oQy7PXLVQ fXK4dmueDA== Date: Tue, 13 Jun 2023 06:48:24 +0200 (CEST) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_229317_132558502.1686631705014" Subject: Re: [FFmpeg-devel] [RFC] [PATCH 1/5] hwcontext: add a new AVHWFramesContext.opaque field 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" Archived-At: List-Archive: List-Post: ------=_Part_229317_132558502.1686631705014 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Jun 13, 2023, 06:43 by andreas.rheinhardt@outlook.com: > Lynne: > >> + dst->opaque = av_buffer_ref(src->opaque); >> + if (!dst->internal->source_frames) { >> + ret = AVERROR(ENOMEM); >> + goto fail; >> + } >> > > Don't you want to check for !dst->opaque? > > - Andreas > Yes, copy and paste error. Fixed. ------=_Part_229317_132558502.1686631705014 Content-Type: text/x-diff; charset=us-ascii; name=0001-hwcontext-add-a-new-AVHWFramesContext.opaque-field.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-hwcontext-add-a-new-AVHWFramesContext.opaque-field.patch >From f1d59fc0e6377c0c3ce2a4182a8c187b46382d4e Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 13 Jun 2023 06:10:50 +0200 Subject: [PATCH 1/5] hwcontext: add a new AVHWFramesContext.opaque field This is a public field, settable before frames context initialization, and propagated to any derived contexts. API users can use it to store state and determine which context is one of theirs. This also allows decoders which create their own contexts to store some state which would be freed only at context destruction. --- libavutil/hwcontext.c | 6 ++++++ libavutil/hwcontext.h | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c index 3396598269..dc4be45d4b 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -238,6 +238,7 @@ static void hwframe_ctx_free(void *opaque, uint8_t *data) av_buffer_unref(&ctx->internal->source_frames); av_buffer_unref(&ctx->device_ref); + av_buffer_unref(&ctx->opaque); av_freep(&ctx->hwctx); av_freep(&ctx->internal->priv); @@ -913,6 +914,11 @@ int av_hwframe_ctx_create_derived(AVBufferRef **derived_frame_ctx, dst->sw_format = src->sw_format; dst->width = src->width; dst->height = src->height; + dst->opaque = av_buffer_ref(src->opaque); + if (!dst->opaque) { + ret = AVERROR(ENOMEM); + goto fail; + } dst->internal->source_frames = av_buffer_ref(source_frame_ctx); if (!dst->internal->source_frames) { diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index 7ff08c8608..7655bee33f 100644 --- a/libavutil/hwcontext.h +++ b/libavutil/hwcontext.h @@ -227,6 +227,15 @@ typedef struct AVHWFramesContext { * Must be set by the user before calling av_hwframe_ctx_init(). */ int width, height; + + /** + * Opaque data. Can be set before calling av_hwframe_ctx_init(). + * MUST NOT be set afterwards. Will be unref'd along with the + * main context at closure. + * + * Will be propagated to any derived contexts. + */ + AVBufferRef *opaque; } AVHWFramesContext; /** -- 2.40.1 ------=_Part_229317_132558502.1686631705014 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". ------=_Part_229317_132558502.1686631705014--