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 20f4d72bb3 avfilter/vf_chromakey: read the neighbours of interior 
pixels directly
20f4d72bb3 is described below

commit 20f4d72bb335b4fd8a6559a5686331e19ddf658b
Author:     Nathan Moinvaziri <[email protected]>
AuthorDate: Sun Oct 18 12:58:34 2026 -0700
Commit:     michaelni <[email protected]>
CommitDate: Mon Nov 23 04:17:51 2026 +0000

    avfilter/vf_chromakey: read the neighbours of interior pixels directly
    
    Each of the nine neighbours of every pixel went through a bounds check
    and its own address computation. Pixels away from the frame edges now
    read them from three precomputed rows, which keeps the output identical
    and cuts the time of the filter by about a quarter.
    
    Signed-off-by: Nathan Moinvaziri <[email protected]>
---
 libavfilter/vf_chromakey.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_chromakey.c b/libavfilter/vf_chromakey.c
index 7ef75f2d07..6c9b6c0083 100644
--- a/libavfilter/vf_chromakey.c
+++ b/libavfilter/vf_chromakey.c
@@ -128,10 +128,28 @@ static int do_chromakey_slice(AVFilterContext *avctx, 
void *arg, int jobnr, int
     memset(v, ctx->chromakey_uv[1], sizeof(v));
 
     for (y = slice_start; y < slice_end; ++y) {
+        const int interior = y > 0 && y < frame->height - 1;
+        const uint8_t *urow[3], *vrow[3];
+
+        for (yo = 0; yo < 3 && interior; ++yo) {
+            urow[yo] = frame->data[1] + frame->linesize[1] * ((y + yo - 1) >> 
ctx->vsub_log2);
+            vrow[yo] = frame->data[2] + frame->linesize[2] * ((y + yo - 1) >> 
ctx->vsub_log2);
+        }
+
         for (x = 0; x < frame->width; ++x) {
-            for (yo = 0; yo < 3; ++yo) {
-                for (xo = 0; xo < 3; ++xo) {
-                    get_pixel_uv(frame, ctx->hsub_log2, ctx->vsub_log2, x + xo 
- 1, y + yo - 1, &u[yo * 3 + xo], &v[yo * 3 + xo]);
+            if (interior && x > 0 && x < frame->width - 1) {
+                /* all nine neighbours lie inside the frame */
+                for (yo = 0; yo < 3; ++yo) {
+                    for (xo = 0; xo < 3; ++xo) {
+                        u[yo * 3 + xo] = urow[yo][(x + xo - 1) >> 
ctx->hsub_log2];
+                        v[yo * 3 + xo] = vrow[yo][(x + xo - 1) >> 
ctx->hsub_log2];
+                    }
+                }
+            } else {
+                for (yo = 0; yo < 3; ++yo) {
+                    for (xo = 0; xo < 3; ++xo) {
+                        get_pixel_uv(frame, ctx->hsub_log2, ctx->vsub_log2, x 
+ xo - 1, y + yo - 1, &u[yo * 3 + xo], &v[yo * 3 + xo]);
+                    }
                 }
             }
 

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