[FFmpeg-cvslog] avfilter/vf_decimate: fix broken logic with ppsrc handling

Paul B Mahol git at videolan.org
Sun Dec 27 22:23:12 EET 2020


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Dec 27 21:01:38 2020 +0100| [89dcef90af5b444b446ed888486ea9326e9a1141] | committer: Paul B Mahol

avfilter/vf_decimate: fix broken logic with ppsrc handling

Make output bit exact with VIVTC VDecimate filter.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=89dcef90af5b444b446ed888486ea9326e9a1141
---

 libavfilter/vf_decimate.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vf_decimate.c b/libavfilter/vf_decimate.c
index 25bd5bda57..93509d6ab3 100644
--- a/libavfilter/vf_decimate.c
+++ b/libavfilter/vf_decimate.c
@@ -167,11 +167,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     dm->got_frame[INPUT_MAIN] = dm->got_frame[INPUT_CLEANSRC] = 0;
 
     if (dm->ppsrc)
-        in = dm->clean_src[dm->fid];
+        in = dm->queue[dm->fid].frame;
 
     if (in) {
         /* update frame metrics */
-        prv = dm->fid ? (dm->ppsrc ? dm->clean_src[dm->fid - 1] : dm->queue[dm->fid - 1].frame) : dm->last;
+        prv = dm->fid ? dm->queue[dm->fid - 1].frame : dm->last;
         if (!prv) {
             dm->queue[dm->fid].maxbdiff = INT64_MAX;
             dm->queue[dm->fid].totdiff  = INT64_MAX;
@@ -219,8 +219,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             av_frame_free(&dm->queue[i].frame);
         } else {
             AVFrame *frame = dm->queue[i].frame;
-            if (!frame)
-                continue;
             dm->queue[i].frame = NULL;
             if (frame->pts != AV_NOPTS_VALUE && dm->start_pts == AV_NOPTS_VALUE)
                 dm->start_pts = frame->pts;
@@ -367,8 +365,7 @@ static int config_output(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
     DecimateContext *dm = ctx->priv;
-    const AVFilterLink *inlink =
-        ctx->inputs[dm->ppsrc ? INPUT_CLEANSRC : INPUT_MAIN];
+    const AVFilterLink *inlink = ctx->inputs[INPUT_MAIN];
     AVRational fps = inlink->frame_rate;
     int max_value;
     const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
@@ -407,8 +404,13 @@ static int config_output(AVFilterLink *outlink)
     outlink->time_base  = inlink->time_base;
     outlink->frame_rate = fps;
     outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
-    outlink->w = inlink->w;
-    outlink->h = inlink->h;
+    if (dm->ppsrc) {
+        outlink->w = ctx->inputs[INPUT_CLEANSRC]->w;
+        outlink->h = ctx->inputs[INPUT_CLEANSRC]->h;
+    } else {
+        outlink->w = inlink->w;
+        outlink->h = inlink->h;
+    }
     dm->ts_unit = av_inv_q(av_mul_q(fps, outlink->time_base));
     return 0;
 }



More information about the ffmpeg-cvslog mailing list