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

Git pushed a commit to branch master
in repository ffmpeg.

The following commit(s) were added to refs/heads/master by this push:
     new 0f1e971089 avutil/hwcontext_cuda: drain queued copies on transfer error
0f1e971089 is described below

commit 0f1e9710896108e8aa7f60f8b1c6d16333eab2ae
Author:     KawaiiEngine (Sashimiso) 
<[email protected]>
AuthorDate: Wed Jul 15 05:39:29 2026 +0900
Commit:     Timo Rothenpieler <[email protected]>
CommitDate: Tue Jul 21 22:39:35 2026 +0000

    avutil/hwcontext_cuda: drain queued copies on transfer error
    
    cuda_transfer_data() can enqueue copies for earlier planes before a
    later cuArrayGetPlane() or cuMemcpy2DAsync() fails. Returning at that
    point can let queued work outlive caller-owned AVFrame buffers.
    
    Track whether a copy was successfully queued and synchronize the stream
    on these later failures. Synchronization is best-effort: its errors and
    cuCtxPopCurrent() errors stay logged without replacing the primary
    failure.
    
    Successful H2D and D2D transfers remain asynchronous, and the normal
    host-download synchronization path is unchanged.
    
    Signed-off-by: KawaiiEngine (Sashimiso) 
<[email protected]>
---
 libavutil/hwcontext_cuda.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c
index 5f0ff73327..a057c36b20 100644
--- a/libavutil/hwcontext_cuda.c
+++ b/libavutil/hwcontext_cuda.c
@@ -544,7 +544,7 @@ static int cuda_transfer_data(AVHWFramesContext *ctx, 
AVFrame *dst,
     CudaFunctions             *cu = hwctx->internal->cuda_dl;
 
     CUcontext dummy;
-    int i, ret;
+    int i, ret, copy_queued = 0;
 
     {
         enum AVPixelFormat src_fmt = cuda_frame_hw_format(src);
@@ -603,7 +603,7 @@ static int cuda_transfer_data(AVHWFramesContext *ctx, 
AVFrame *dst,
                 src_is_nonplanar_cuarray = 1;
             } else if (cures != CUDA_SUCCESS) {
                 ret = CHECK_CU(cures);
-                goto exit;
+                goto fail;
             }
 
             cpy.srcMemoryType = CU_MEMORYTYPE_ARRAY;
@@ -631,7 +631,7 @@ static int cuda_transfer_data(AVHWFramesContext *ctx, 
AVFrame *dst,
                 dst_is_nonplanar_cuarray = 1;
             } else if (cures != CUDA_SUCCESS) {
                 ret = CHECK_CU(cures);
-                goto exit;
+                goto fail;
             }
 
             cpy.dstMemoryType = CU_MEMORYTYPE_ARRAY;
@@ -647,7 +647,8 @@ static int cuda_transfer_data(AVHWFramesContext *ctx, 
AVFrame *dst,
 
         ret = CHECK_CU(cu->cuMemcpy2DAsync(&cpy, hwctx->stream));
         if (ret < 0)
-            goto exit;
+            goto fail;
+        copy_queued = 1;
 
         if (src_is_nonplanar_cuarray || dst_is_nonplanar_cuarray)
             break;
@@ -659,6 +660,9 @@ static int cuda_transfer_data(AVHWFramesContext *ctx, 
AVFrame *dst,
             goto exit;
     }
 
+fail:
+    if (ret < 0 && copy_queued)
+        CHECK_CU(cu->cuStreamSynchronize(hwctx->stream));
 exit:
     CHECK_CU(cu->cuCtxPopCurrent(&dummy));
 

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to