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

Git pushed a commit to branch master
in repository ffmpeg.

commit 722493d3e13b81a45c6ca021a8c684d2d73d042a
Author:     Vladimir Panteleev <[email protected]>
AuthorDate: Sat Nov 19 20:23:59 2022 +0000
Commit:     michaelni <[email protected]>
CommitDate: Sun Jul 5 00:41:30 2026 +0000

    vf_photosensitivity: add blend option
    
    This commit attempts to address feedback from this filter's users, by
    introducing a new option which controls the amelioration mechanism.
    
    The "blend" option is a factor which is multiplied by the difference
    in badness (between the threshold and the currently accumulated
    badness). This difference normally controls how much of the next frame
    we can let through without making it exceed the badness threshold.
    
    Setting the option to zero effectively puts the filter into a mode
    where it always duplicates the last frame (which did not put
    accumulated badness over the threshold) instead of attempting to blend
    in new frames.  I have received reports that this mode is preferable
    to users for some types of media.
---
 doc/filters.texi                  | 6 ++++++
 libavfilter/vf_photosensitivity.c | 7 ++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index aa0059f9cc..5497421f34 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -20012,6 +20012,12 @@ Allowed range is from 1 to 1024.
 
 @item bypass
 Leave frames unchanged. Default is disabled.
+
+@item blend
+Set the blending factor for frames that exceed the detection threshold.
+A value of 0 duplicates the last accepted frame, and a value of 1 blends up to
+the detection threshold. Default is 1.
+Allowed range is from 0 to 1.
 @end table
 
 @section pixdesctest
diff --git a/libavfilter/vf_photosensitivity.c 
b/libavfilter/vf_photosensitivity.c
index 6ec5fd75e4..9819d77bf0 100644
--- a/libavfilter/vf_photosensitivity.c
+++ b/libavfilter/vf_photosensitivity.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2020 Vladimir Panteleev
+ * Copyright (c) 2019, 2020, 2022 Vladimir Panteleev
  *
  * This file is part of FFmpeg.
  *
@@ -39,7 +39,7 @@ typedef struct PhotosensitivityContext {
 
     int nb_frames;
     int skip;
-    float threshold_multiplier;
+    float threshold_multiplier, blend_factor;
     int bypass;
 
     int badness_threshold;
@@ -62,6 +62,7 @@ static const AVOption photosensitivity_options[] = {
     { "t",         "set detection threshold factor (lower is stricter)",  
OFFSET(threshold_multiplier), AV_OPT_TYPE_FLOAT, {.dbl=1},  0.1, FLT_MAX,  
FLAGS },
     { "skip",      "set pixels to skip when sampling frames",             
OFFSET(skip),                 AV_OPT_TYPE_INT,   {.i64=1},  1, 1024,       
FLAGS },
     { "bypass",    "leave frames unchanged",                              
OFFSET(bypass),               AV_OPT_TYPE_BOOL,  {.i64=0},  0, 1,          
FLAGS },
+    { "blend",     "set blending factor (0 always duplicates frames)",    
OFFSET(blend_factor),         AV_OPT_TYPE_FLOAT, {.dbl=1},  0, 1,          
FLAGS },
     { NULL }
 };
 
@@ -241,7 +242,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         s->last_frame_e = ef;
         s->history[s->history_pos] = this_badness;
     } else {
-        factor = (float)(badness_threshold - current_badness) / (new_badness - 
current_badness);
+        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 */

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to