Commit 5ac6d116e7 for ffmpeg

commit 5ac6d116e7cb52d1262b3dfb0640dac3505eeac7
Author: Michael Niedermayer <michael@niedermayer.cc>
Date:   Sun Oct 4 03:34:44 2026 +0200

    avutil/hwcontext: pool the frames av_hwframe_transfer_data() allocates

    A destination frame without buffers was allocated anew for every
    download. For large frames the allocation costs more than the
    transfer.

    ffmpeg -hwaccel cuda -i hevc.mp4 -f null - on a RTX 5090, mean of 10
    runs: 2160p 390 -> 497 fps, 4320p 33 -> 112 fps, 1080p unchanged at
    1772 fps.

    Assisted-by: Claude

diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index 2c3bd2eeaa..d5cf6dc012 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -461,7 +461,7 @@ static int transfer_data_alloc(AVFrame *dst, const AVFrame *src, int flags)
     frame_tmp->width  = ctx->width;
     frame_tmp->height = ctx->height;

-    ret = av_frame_get_buffer(frame_tmp, 0);
+    ret = av_hwframe_get_transfer_buffer(src->hw_frames_ctx, frame_tmp);
     if (ret < 0)
         goto fail;

diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
index 5a73f368a1..8e414f4863 100644
--- a/libavutil/hwcontext.h
+++ b/libavutil/hwcontext.h
@@ -399,7 +399,7 @@ int av_hwframe_get_transfer_buffer(AVBufferRef *hwframe_ctx, AVFrame *frame);
  * AV_HWFRAME_TRANSFER_DIRECTION_TO)
  *
  * dst may be "clean" (i.e. with data/buf pointers unset), in which case the
- * data buffers will be allocated by this function using av_frame_get_buffer().
+ * data buffers will be allocated by this function.
  * If dst->format is set, then this format will be used, otherwise (when
  * dst->format is AV_PIX_FMT_NONE) the first acceptable format will be chosen.
  *