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

Git pushed a commit to branch master
in repository ffmpeg.

commit 6f7ca90701ab4478ea42a7245ad88da45921e420
Author:     romainhedouin <[email protected]>
AuthorDate: Thu Oct 15 12:55:22 2026 +0200
Commit:     Baptiste Coudurier <[email protected]>
CommitDate: Sat Oct 17 18:41:36 2026 +0000

    avfilter/vf_drawbox: compute alpha once in draw_region_rgb_packed
    
    alpha only depends on the box colour, so compute it once per call
    instead of for every pixel. The output is unchanged.
    
    About 10-25% less CPU on full-frame boxes and grids (rgb24/rgba,
    1080p, arm64). Small boxes are not affected.
    
    Found during a code review sweep of ffmpeg using an LLM.
---
 libavfilter/vf_drawbox.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_drawbox.c b/libavfilter/vf_drawbox.c
index ec409603d3..d44dc04171 100644
--- a/libavfilter/vf_drawbox.c
+++ b/libavfilter/vf_drawbox.c
@@ -192,6 +192,8 @@ static void draw_region_rgb_packed(AVFrame *frame, 
DrawBoxContext *ctx, int left
             }
         }
     } else {
+        const float alpha = (float)ctx->rgba_color[A] / 255.f;
+
         for (int y = top; y < down; y++) {
             ASSIGN_THREE_CHANNELS_PACKED
             if (ctx->invert_color) {
@@ -203,8 +205,6 @@ static void draw_region_rgb_packed(AVFrame *frame, 
DrawBoxContext *ctx, int left
                     }
             } else {
                 for (int x = left; x < right; x++) {
-                    float alpha = (float)ctx->rgba_color[A] / 255.f;
-
                     if (pixel_belongs_to_region(ctx, x, y)) {
                         row[0][x*C] = (1.f - alpha) * row[0][x*C] + alpha * 
ctx->rgba_color[R];
                         row[1][x*C] = (1.f - alpha) * row[1][x*C] + alpha * 
ctx->rgba_color[G];

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