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 fd9a8f25a0 avfilter/vf_tonemap_opencl: zero the peak detection buffer
fd9a8f25a0 is described below

commit fd9a8f25a07bbec3e6b25339177ef1e2d49cbf05
Author:     dhalsimax <[email protected]>
AuthorDate: Thu Oct 1 08:38:55 2026 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Mon Oct 19 14:58:14 2026 +0000

    avfilter/vf_tonemap_opencl: zero the peak detection buffer
    
    The kernel keeps its peak detection state in util_mem (frame index,
    frame count, running totals of peak and average) and expects it to
    start at zero. The buffer is created without a host pointer, so per the
    OpenCL spec its contents are undefined. Intel's compute-runtime (NEO
    24.35, legacy branch, on a Gen9 Apollo Lake) hands out recycled memory,
    and the totals can start as garbage: the detected peak is then huge and
    the whole stream comes out black (Y=16), or with the wrong brightness.
    The same command gave black video every time on one film and a correct
    picture on another; with the buffer zeroed both are correct.
    
    Create the buffer from a zeroed array with CL_MEM_COPY_HOST_PTR.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Claude-Session: https://claude.ai/code/session_01VB8Q6zwZGmj1CET8B15HLg
---
 libavfilter/vf_tonemap_opencl.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_tonemap_opencl.c b/libavfilter/vf_tonemap_opencl.c
index 2f47cfd49f..aa8f50b6d6 100644
--- a/libavfilter/vf_tonemap_opencl.c
+++ b/libavfilter/vf_tonemap_opencl.c
@@ -116,6 +116,7 @@ static const float sdr_avg = 0.25f;
 
 static int tonemap_opencl_init(AVFilterContext *avctx)
 {
+    unsigned util_init[2 * DETECTION_FRAMES + 7] = { 0 };
     TonemapOpenCLContext *ctx = avctx->priv;
     int rgb2rgb_passthrough = 1;
     double rgb2rgb[3][3], rgb2yuv[3][3], yuv2rgb[3][3];
@@ -258,10 +259,12 @@ static int tonemap_opencl_init(AVFilterContext *avctx)
     ctx->kernel = clCreateKernel(ctx->ocf.program, "tonemap", &cle);
     CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to create kernel %d.\n", cle);
 
+    // The kernel keeps its peak detection state here and expects it to
+    // start at zero, but a buffer created without a host pointer has
+    // undefined contents.
     ctx->util_mem =
-        clCreateBuffer(ctx->ocf.hwctx->context, 0,
-                       (2 * DETECTION_FRAMES + 7) * sizeof(unsigned),
-                       NULL, &cle);
+        clCreateBuffer(ctx->ocf.hwctx->context, CL_MEM_COPY_HOST_PTR,
+                       sizeof(util_init), util_init, &cle);
     CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to create util buffer: %d.\n", cle);
 
     ctx->initialised = 1;

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