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-requ...@ffmpeg.org with subject "unsubscribe".