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 A5E7345E5B for ; Tue, 13 Jun 2023 04:18:29 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7377268C33F; Tue, 13 Jun 2023 07:18:25 +0300 (EEST) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ECA3168C180 for ; Tue, 13 Jun 2023 07:18:18 +0300 (EEST) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id B593C10601A7 for ; Tue, 13 Jun 2023 04:18:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1686629898; 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:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:Sender; bh=GnTnYYi5Tv6cCO4LKmOVxrxGbxdKg1uAXiIh5NNLn/M=; b=JoiNL9Z/fpOHLIamSMlQDm8IDUtm9sfFt7eUZKeVJGnKKROd5ySeggROiuRuFk2B wKeMcX2iJIwTHzPDzy4gnGyZVzHOhfYgpIctj6rulrmag77TJBizP0uLP/v5BwQXY6f u77l/d3xe2Dq52NLs3OPlNI4nqyy+ZdDmsLpzOdD4CfESRqf3WHB8I8wXZGfX2erYSh zvBRet6PjMYjJCZrs3e8CflbB+Z5eb7TszuWzkbnLhoZOfwC0DW6vInl/qI5q1GxAD3 x1pszdG/ZU/OtdDfwK3tR8NckwFJAPzd/yag5k5IUjuIO1hO0CatPrYq+7LqiCZbmg9 4+X4MvWwyw== Date: Tue, 13 Jun 2023 06:18:18 +0200 (CEST) From: Lynne To: Ffmpeg Devel Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_228432_1121748799.1686629898236" Subject: [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_228432_1121748799.1686629898236 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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. Request for comments. Patch attached. ------=_Part_228432_1121748799.1686629898236 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 a9bdbbb64acfcb0540727895b7be4027ab9955f9 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..92a8cc907a 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->internal->source_frames) { + 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_228432_1121748799.1686629898236 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_228432_1121748799.1686629898236--