Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [RFC] [PATCH 1/5] hwcontext: add a new AVHWFramesContext.opaque field
@ 2023-06-13  4:18 Lynne
       [not found] ` <NXmySQC--3-9@lynne.ee-NXmyWRF----9>
  2023-06-13  4:44 ` [FFmpeg-devel] [RFC] [PATCH 1/5] hwcontext: add a new AVHWFramesContext.opaque field Andreas Rheinhardt
  0 siblings, 2 replies; 17+ messages in thread
From: Lynne @ 2023-06-13  4:18 UTC (permalink / raw)
  To: Ffmpeg Devel

[-- Attachment #1: Type: text/plain, Size: 364 bytes --]

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.


[-- Attachment #2: 0001-hwcontext-add-a-new-AVHWFramesContext.opaque-field.patch --]
[-- Type: text/x-diff, Size: 2157 bytes --]

From a9bdbbb64acfcb0540727895b7be4027ab9955f9 Mon Sep 17 00:00:00 2001
From: Lynne <dev@lynne.ee>
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


[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2023-06-18 12:20 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13  4:18 [FFmpeg-devel] [RFC] [PATCH 1/5] hwcontext: add a new AVHWFramesContext.opaque field Lynne
     [not found] ` <NXmySQC--3-9@lynne.ee-NXmyWRF----9>
2023-06-13  4:19   ` [FFmpeg-devel] [PATCH 2/5] vulkan_decode: use the " Lynne
2023-06-13 12:28     ` Anton Khirnov
2023-06-13 12:53       ` Lynne
2023-06-18 11:10         ` Anton Khirnov
2023-06-18 12:20           ` Lynne
     [not found]   ` <NXmyk7P--3-9@lynne.ee-NXmynAe----9>
2023-06-13  4:20     ` [FFmpeg-devel] [PATCH 3/5] hwcontext_vulkan: call ff_vk_uninit() on device uninit Lynne
     [not found]     ` <NXmyvDO--3-9@lynne.ee-NXmyy7U----9>
2023-06-13  4:21       ` [FFmpeg-devel] [PATCH 4/5] hwcontext_vulkan: free temporary array once unneeded Lynne
     [not found]       ` <NXmz5vr-03-9@lynne.ee-NXmz8rg----9>
2023-06-13  4:24         ` [FFmpeg-devel] [PATCH 5/5] vulkan_decode: fix small memory leak Lynne
2023-06-15 20:03         ` [FFmpeg-devel] [PATCH 4/5] hwcontext_vulkan: free temporary array once unneeded Lynne
2023-06-15 20:03       ` [FFmpeg-devel] [PATCH 3/5] hwcontext_vulkan: call ff_vk_uninit() on device uninit Lynne
2023-06-13  4:44 ` [FFmpeg-devel] [RFC] [PATCH 1/5] hwcontext: add a new AVHWFramesContext.opaque field Andreas Rheinhardt
2023-06-13  4:48   ` Lynne
2023-06-13 16:57     ` Andreas Rheinhardt
2023-06-13 17:17       ` Lynne
     [not found]       ` <NXpkssV--3-9@lynne.ee-NXpkwTT----9>
2023-06-16 11:02         ` Lynne
     [not found]         ` <NY2rkbx--3-9@lynne.ee-NY2rofi----9>
2023-06-18 10:58           ` Lynne

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git