This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 8493e8bad3d99c6eba0d01145f8624f83493323e
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Sun Oct 4 03:36:13 2026 +0200
Commit:     michaelni <[email protected]>
CommitDate: Wed Oct 21 19:32:23 2026 +0000

    avfilter/vf_hwupload_cuda: give the preceding filter transfer buffers to 
write into
    
    The frames a filter in front of hwupload_cuda produces are allocated
    with av_hwframe_get_transfer_buffer(), so that the upload reads from
    memory the device transfers directly from.
    
    Assisted-by: Claude
---
 libavfilter/vf_hwupload_cuda.c |  1 +
 libavfilter/video.c            | 25 +++++++++++++++++++++++++
 libavfilter/video.h            |  6 ++++++
 3 files changed, 32 insertions(+)

diff --git a/libavfilter/vf_hwupload_cuda.c b/libavfilter/vf_hwupload_cuda.c
index 9920bbcfc8..1478b02359 100644
--- a/libavfilter/vf_hwupload_cuda.c
+++ b/libavfilter/vf_hwupload_cuda.c
@@ -195,6 +195,7 @@ static const AVFilterPad cudaupload_inputs[] = {
         .name         = "default",
         .type         = AVMEDIA_TYPE_VIDEO,
         .filter_frame = cudaupload_filter_frame,
+        .get_buffer.video = ff_hwupload_get_video_buffer,
     },
 };
 
diff --git a/libavfilter/video.c b/libavfilter/video.c
index 46956b2d27..6e20794d43 100644
--- a/libavfilter/video.c
+++ b/libavfilter/video.c
@@ -92,6 +92,31 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int 
w, int h)
     return ff_default_get_video_buffer2(link, w, h, av_cpu_max_align());
 }
 
+AVFrame *ff_hwupload_get_video_buffer(AVFilterLink *link, int w, int h)
+{
+    AVBufferRef *hw_frames_ctx = 
ff_filter_link(link->dst->outputs[0])->hw_frames_ctx;
+    AVFrame *frame;
+
+    if (!hw_frames_ctx || ff_filter_link(link)->hw_frames_ctx)
+        return ff_default_get_video_buffer(link, w, h);
+
+    frame = av_frame_alloc();
+    if (!frame)
+        return NULL;
+
+    frame->format = link->format;
+    frame->width  = w;
+    frame->height = h;
+    if (av_hwframe_get_transfer_buffer(hw_frames_ctx, frame) < 0) {
+        av_frame_free(&frame);
+        return NULL;
+    }
+
+    set_link_props(frame, link);
+
+    return frame;
+}
+
 AVFrame *ff_get_video_buffer(AVFilterLink *link, int w, int h)
 {
     AVFrame *ret = NULL;
diff --git a/libavfilter/video.h b/libavfilter/video.h
index f44d3445dc..08d434f1e2 100644
--- a/libavfilter/video.h
+++ b/libavfilter/video.h
@@ -34,6 +34,12 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int 
w, int h);
 AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int 
align);
 AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h);
 
+/**
+ * get_buffer.video() of the input of a filter that uploads software frames
+ * to the hardware frames context of its output link.
+ */
+AVFrame *ff_hwupload_get_video_buffer(AVFilterLink *link, int w, int h);
+
 /**
  * Request a picture buffer with a specific set of permissions.
  *

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to