[PR] avfilter/vf_histogram: fix thistogram parade scroll overflow (PR #24315)

michaelni via ffmpeg-devel <[email protected]>
Newsgroups gmane.comp.video.ffmpeg.devel
Message-ID <[email protected]>
PR #24315 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24315
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24315.patch

Use the width of one component section for the scroll write position.
The full output width includes every parade section, so adding the later
sections start offsets to it writes past the output frame.

Add a FATE test covering multiple components in parade scroll mode.

Signed-off-by: Michael Niedermayer <[email protected]>



>From 68ef51e4166d1c2eae3bdfa869d90f08333f5b0a Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Fri, 28 Aug 2026 17:40:59 +0000
Subject: [PATCH] avfilter/vf_histogram: fix thistogram parade scroll overflow

Use the width of one component section for the scroll write position.
The full output width includes every parade section, so adding the later
sections start offsets to it writes past the output frame.

Add a FATE test covering multiple components in parade scroll mode.

Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavfilter/vf_histogram.c              | 2 +-
 tests/fate/filter-video.mak             | 3 +++
 tests/ref/fate/filter-thistogram-scroll | 6 ++++++
 3 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/fate/filter-thistogram-scroll

diff --git a/libavfilter/vf_histogram.c b/libavfilter/vf_histogram.c
index 0dfebc62d1..d9bba08134 100644
--- a/libavfilter/vf_histogram.c
+++ b/libavfilter/vf_histogram.c
@@ -480,7 +480,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             int minh = s->histogram_size - 1, maxh = 0;
 
             if (s->slide == 2) {
-                s->x_pos = out->width - 1;
+                s->x_pos = s->width - 1;
                 for (j = 0; j < outlink->h; j++) {
                     memmove(out->data[p] + j * out->linesize[p] ,
                             out->data[p] + j * out->linesize[p] + bpp,
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index e2164de1c4..23cd18c41d 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -239,6 +239,9 @@ fate-filter-negate: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf perms=random,negate
 FATE_FILTER_VSYNTH_PGMYUV-$(CONFIG_HISTOGRAM_FILTER) += fate-filter-histogram-levels
 fate-filter-histogram-levels: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf histogram -flags +bitexact -sws_flags +accurate_rnd+bitexact
 
+FATE_FILTER-$(call FILTERFRAMECRC, TESTSRC2 FORMAT THISTOGRAM) += fate-filter-thistogram-scroll
+fate-filter-thistogram-scroll: CMD = framecrc -lavfi testsrc2=s=65x49:r=1:d=1,format=yuv420p,thistogram=display_mode=parade:components=7:slide=scroll -flags +bitexact
+
 FATE_FILTER_VSYNTH_PGMYUV-$(CONFIG_WAVEFORM_FILTER) += fate-filter-waveform_column
 fate-filter-waveform_column: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf waveform -flags +bitexact -sws_flags +accurate_rnd+bitexact
 
diff --git a/tests/ref/fate/filter-thistogram-scroll b/tests/ref/fate/filter-thistogram-scroll
new file mode 100644
index 0000000000..dfe2063243
--- /dev/null
+++ b/tests/ref/fate/filter-thistogram-scroll
@@ -0,0 +1,6 @@
+#tb 0: 1/1
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 192x256
+#sar 0: 1/1
+0,          0,          0,        1,   147456, 0x14029e94
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.