Commit 8493e8bad3 for ffmpeg

commit 8493e8bad3d99c6eba0d01145f8624f83493323e
Author: Michael Niedermayer <michael@niedermayer.cc>
Date:   Sun Oct 4 03:36:13 2026 +0200

    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

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