Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 1/2] lavc/threadframe: allow decoders to attach buffers to ThreadFrame
Date: Tue, 15 Mar 2022 11:49:31 +0100
Message-ID: <20220315104932.25496-1-anton@khirnov.net> (raw)

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

             reply	other threads:[~2022-03-15 10:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15 10:49 Anton Khirnov [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220315104932.25496-1-anton@khirnov.net \
    --to=anton@khirnov.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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