]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_psnr.c
avfilter: add vif filter
[ffmpeg] / libavfilter / vf_psnr.c
index 0675a17c5dba8078cfdcb3d65b4c4ce0b23d711b..0d6bbad42fbd93258c46004834dd90ed59354ed8 100644 (file)
@@ -132,7 +132,7 @@ void compute_images_mse(PSNRContext *s,
 static void set_meta(AVDictionary **metadata, const char *key, char comp, float d)
 {
     char value[128];
-    snprintf(value, sizeof(value), "%0.2f", d);
+    snprintf(value, sizeof(value), "%f", d);
     if (comp) {
         char key2[128];
         snprintf(key2, sizeof(key2), "%s%c", key, comp);
@@ -154,7 +154,7 @@ static int do_psnr(FFFrameSync *fs)
     ret = ff_framesync_dualinput_get(fs, &master, &ref);
     if (ret < 0)
         return ret;
-    if (!ref)
+    if (ctx->is_disabled || !ref)
         return ff_filter_frame(ctx->outputs[0], master);
     metadata = &master->metadata;
 
@@ -350,6 +350,14 @@ static int config_output(AVFilterLink *outlink)
     if ((ret = ff_framesync_configure(&s->fs)) < 0)
         return ret;
 
+    outlink->time_base = s->fs.time_base;
+
+    if (av_cmp_q(mainlink->time_base, outlink->time_base) ||
+        av_cmp_q(ctx->inputs[1]->time_base, outlink->time_base))
+        av_log(ctx, AV_LOG_WARNING, "not matching timebases found between first input: %d/%d and second input %d/%d, results may be incorrect!\n",
+               mainlink->time_base.num, mainlink->time_base.den,
+               ctx->inputs[1]->time_base.num, ctx->inputs[1]->time_base.den);
+
     return 0;
 }
 
@@ -419,4 +427,5 @@ AVFilter ff_vf_psnr = {
     .priv_class    = &psnr_class,
     .inputs        = psnr_inputs,
     .outputs       = psnr_outputs,
+    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
 };