[FFmpeg-devel] [PATCH] lavfi/vf_decimate: do not compare the first frame to itself.

Nicolas George george at nsup.org
Sat Oct 24 19:45:49 CEST 2015


This is a waste of computing power and will result to 0,
making it always dropped.
Use maximum difference values instead.

Signed-off-by: Nicolas George <george at nsup.org>
---
 libavfilter/vf_decimate.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_decimate.c b/libavfilter/vf_decimate.c
index 26f3ce0..3b146cd 100644
--- a/libavfilter/vf_decimate.c
+++ b/libavfilter/vf_decimate.c
@@ -167,9 +167,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     if (in) {
         /* update frame metrics */
         prv = dm->fid ? dm->queue[dm->fid - 1].frame : dm->last;
-        if (!prv)
-            prv = in;
-        calc_diffs(dm, &dm->queue[dm->fid], prv, in);
+        if (!prv) {
+            dm->queue[dm->fid].maxbdiff = INT64_MAX;
+            dm->queue[dm->fid].totdiff  = INT64_MAX;
+        } else {
+            calc_diffs(dm, &dm->queue[dm->fid], prv, in);
+        }
         if (++dm->fid != dm->cycle)
             return 0;
         av_frame_free(&dm->last);
-- 
2.6.1



More information about the ffmpeg-devel mailing list