This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit e058e8c0c533add4878bf73ff1f148c5ea879360 Author: Vladimir Panteleev <[email protected]> AuthorDate: Mon Jun 15 20:46:19 2026 +0000 Commit: michaelni <[email protected]> CommitDate: Sun Jul 5 00:41:30 2026 +0000 vf_photosensitivity: fix metadata when duplicating frames When the blending factor was calculated to be 0, the hot path skipped updating variables later emitted in metadata. Fix the flow to ensure they are populated consistently. Extend the FATE test suite to check metadata output. --- libavfilter/vf_photosensitivity.c | 10 +++++----- tests/fate/filter-video.mak | 5 +++++ tests/ref/fate/filter-metadata-photosensitivity-blend0 | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libavfilter/vf_photosensitivity.c b/libavfilter/vf_photosensitivity.c index 9819d77bf0..3f040f8c89 100644 --- a/libavfilter/vf_photosensitivity.c +++ b/libavfilter/vf_photosensitivity.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, 2022 Vladimir Panteleev + * Copyright (c) 2019, 2020, 2022, 2026 Vladimir Panteleev * * This file is part of FFmpeg. * @@ -234,18 +234,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) current_badness, new_badness, badness_threshold, 100 * new_badness / badness_threshold, new_badness < badness_threshold ? "OK" : "EXCEEDED"); - fixed_badness = new_badness; if (new_badness < badness_threshold || !s->last_frame_av || s->bypass) { factor = 1; /* for metadata */ av_frame_free(&s->last_frame_av); s->last_frame_av = src = in; s->last_frame_e = ef; - s->history[s->history_pos] = this_badness; + fixed_badness = new_badness; } else { factor = (float)(badness_threshold - current_badness) / (new_badness - current_badness) * s->blend_factor; if (factor <= 0) { /* just duplicate the frame */ - s->history[s->history_pos] = 0; /* frame was duplicated, thus, delta is zero */ + this_badness = 0; /* frame was duplicated, thus, delta is zero */ + fixed_badness = current_badness; } else { res = ff_inlink_make_frame_writable(inlink, &s->last_frame_av); if (res) { @@ -261,11 +261,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) current_badness, fixed_badness, badness_threshold, 100 * new_badness / badness_threshold, factor); s->last_frame_e = ef; - s->history[s->history_pos] = this_badness; } src = s->last_frame_av; free_in = 1; } + s->history[s->history_pos] = this_badness; s->history_pos = (s->history_pos + 1) % s->nb_frames; if (s->history_size < s->nb_frames) s->history_size++; diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index f0f9e92834..7c5c15ff46 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -323,6 +323,11 @@ fate-filter-phase: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf phase FATE_FILTER-$(call FILTERFRAMECRC, COLOR CONCAT FORMAT PHOTOSENSITIVITY) += fate-filter-photosensitivity-blend fate-filter-photosensitivity-blend: CMD = framecrc -lavfi "color=black:s=16x16:r=1:d=1[black];color=white:s=16x16:r=1:d=2[white];[black][white]concat=n=2:v=1:a=0,format=rgb24,photosensitivity=frames=2:threshold=95:blend=0.5" -pix_fmt rgb24 +PHOTOSENSITIVITY_METADATA_DEPS = FFPROBE LAVFI_INDEV COLOR_FILTER CONCAT_FILTER FORMAT_FILTER \ + PHOTOSENSITIVITY_FILTER WRAPPED_AVFRAME_DECODER +FATE_FILTER_FFPROBE-$(call ALLYES, $(PHOTOSENSITIVITY_METADATA_DEPS)) += fate-filter-metadata-photosensitivity-blend0 +fate-filter-metadata-photosensitivity-blend0: CMD = run $(FILTER_METADATA_COMMAND) "color=black:s=16x16:r=1:d=1[black];color=white:s=16x16:r=1:d=1[white];[black][white]concat=n=2:v=1:a=0,format=rgb24,photosensitivity=frames=2:threshold=95:blend=0" + FATE_REMOVEGRAIN := 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 \ 16 17 18 19 20 21 22 23 24 FATE_REMOVEGRAIN := $(addprefix fate-filter-removegrain-mode-, $(FATE_REMOVEGRAIN)) diff --git a/tests/ref/fate/filter-metadata-photosensitivity-blend0 b/tests/ref/fate/filter-metadata-photosensitivity-blend0 new file mode 100644 index 0000000000..d8d5c58991 --- /dev/null +++ b/tests/ref/fate/filter-metadata-photosensitivity-blend0 @@ -0,0 +1,2 @@ +pts=0|tag:lavfi.photosensitivity.frame-badness=0.000000|tag:lavfi.photosensitivity.badness=0.000000|tag:lavfi.photosensitivity.fixed-badness=0.000000|tag:lavfi.photosensitivity.factor=1.000000 +pts=0|tag:lavfi.photosensitivity.frame-badness=0.000000|tag:lavfi.photosensitivity.badness=1.006579|tag:lavfi.photosensitivity.fixed-badness=0.000000|tag:lavfi.photosensitivity.factor=0.000000 _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
