PR #25173 opened by Marti2203
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25173
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25173.patch
`init()` is re-run by `process_command()`, but `invert_color` is only ever set
to 1 and never cleared. After `color=invert`, a runtime command that changes
the color to a real one keeps drawing inverted. `drawgrid` shares `init()` and
is affected the same way.
Reproduction (grey 64x64 input, box pixel at (16,16), color changed to red at
t=0.05):
```
ffmpeg -f lavfi -i color=c=0x808080:s=64x64:r=25:d=0.12 \
-vf "sendcmd=c='0.05 drawbox color
red',drawbox=x=8:y=8:w=32:h=32:t=fill:color=invert,format=rgb24" \
-f rawvideo out.raw
```
| start color -> red | frame 2, master | frame 2, patched |
|--------------------|-----------------|------------------|
| invert | 130 130 130 | 252 0 0 |
| blue | 252 0 0 | 252 0 0 |
Changing red -> invert still inverts with the patch. `fate-filter-drawbox`
passes.
This issue was found by an LLM-Enhanced Static Analysis Engine and verified
manually.
>From 37d05d2bd29a294e874fda7ffb4a1afd95ed3929 Mon Sep 17 00:00:00 2001
From: Martin Mirchev <[email protected]>
Date: Sun, 18 Oct 2026 16:33:06 +0800
Subject: [PATCH] avfilter/vf_drawbox: reset invert_color when the color is
changed
init() is re-run by process_command(), but invert_color was only ever set,
never cleared. After color=invert, a runtime command changing the color to
a real one (e.g. "drawbox color red" via sendcmd) kept drawing inverted.
This also applies to drawgrid, which shares init().
Signed-off-by: Martin Mirchev <[email protected]>
---
libavfilter/vf_drawbox.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavfilter/vf_drawbox.c b/libavfilter/vf_drawbox.c
index deb117376b..74b4432fec 100644
--- a/libavfilter/vf_drawbox.c
+++ b/libavfilter/vf_drawbox.c
@@ -243,9 +243,9 @@ static av_cold int init(AVFilterContext *ctx)
}
}
- if (!strcmp(s->color_str, "invert"))
- s->invert_color = 1;
- else if (av_parse_color(s->rgba_color, s->color_str, -1, ctx) < 0)
+ s->invert_color = !strcmp(s->color_str, "invert");
+ if (!s->invert_color &&
+ av_parse_color(s->rgba_color, s->color_str, -1, ctx) < 0)
return AVERROR(EINVAL);
if (!s->invert_color) {
--
2.54.0
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]