Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] lavc/threadframe: allow decoders to attach buffers to ThreadFrame
@ 2022-03-15 10:49 Anton Khirnov
  2022-03-15 10:49 ` [FFmpeg-devel] [PATCH 2/2] lavc/vp9: fix the race in exporting video enc params Anton Khirnov
  2022-03-15 13:59 ` [FFmpeg-devel] [PATCH 1/2] lavc/threadframe: allow decoders to attach buffers to ThreadFrame Andreas Rheinhardt
  0 siblings, 2 replies; 3+ messages in thread
From: Anton Khirnov @ 2022-03-15 10:49 UTC (permalink / raw)
  To: ffmpeg-devel

This may be useful for synchronizing side data that only becomes
available after ff_thread_finish_setup() is called.
---
 libavcodec/pthread_frame.c | 1 +
 libavcodec/threadframe.h   | 3 +++
 libavcodec/utils.c         | 7 +++++++
 3 files changed, 11 insertions(+)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 33b5a2e628..4da3832942 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -1138,6 +1138,7 @@ fail:
 void ff_thread_release_ext_buffer(AVCodecContext *avctx, ThreadFrame *f)
 {
     av_buffer_unref(&f->progress);
+    av_buffer_unref(&f->priv_buf);
     f->owner[0] = f->owner[1] = NULL;
     ff_thread_release_buffer(avctx, f->f);
 }
diff --git a/libavcodec/threadframe.h b/libavcodec/threadframe.h
index dea4dadc6d..c2ddc2969f 100644
--- a/libavcodec/threadframe.h
+++ b/libavcodec/threadframe.h
@@ -30,6 +30,9 @@ typedef struct ThreadFrame {
     // progress->data is an array of 2 ints holding progress for top/bottom
     // fields
     AVBufferRef *progress;
+
+    /* arbitrary user data propagated along with the frame */
+    AVBufferRef *priv_buf;
 } ThreadFrame;
 
 /**
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 066da76e16..cc2c2715b3 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -881,6 +881,12 @@ int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src)
         return AVERROR(ENOMEM);
     }
 
+    if (src->priv_buf) {
+        dst->priv_buf = av_buffer_ref(src->priv_buf);
+        if (!dst->priv_buf)
+            return AVERROR(ENOMEM);
+    }
+
     return 0;
 }
 
@@ -913,6 +919,7 @@ void ff_thread_release_ext_buffer(AVCodecContext *avctx, ThreadFrame *f)
     f->owner[0] = f->owner[1] = NULL;
     if (f->f)
         av_frame_unref(f->f);
+    av_buffer_unref(&f->priv_buf);
 }
 
 void ff_thread_finish_setup(AVCodecContext *avctx)
-- 
2.34.1

_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2022-03-15 13:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-15 10:49 [FFmpeg-devel] [PATCH 1/2] lavc/threadframe: allow decoders to attach buffers to ThreadFrame Anton Khirnov
2022-03-15 10:49 ` [FFmpeg-devel] [PATCH 2/2] lavc/vp9: fix the race in exporting video enc params Anton Khirnov
2022-03-15 13:59 ` [FFmpeg-devel] [PATCH 1/2] lavc/threadframe: allow decoders to attach buffers to ThreadFrame Andreas Rheinhardt

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