Skip to content

Instantly share code, notes, and snippets.

@1480c1
Last active June 17, 2021 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1480c1/50660a0970e8738ba36f14c8e8045de8 to your computer and use it in GitHub Desktop.
Save 1480c1/50660a0970e8738ba36f14c8e8045de8 to your computer and use it in GitHub Desktop.
vf_libvmaf.c stuff
diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c
index 4c99a32e8c..eb006fb2f2 100644
--- a/libavfilter/vf_libvmaf.c
+++ b/libavfilter/vf_libvmaf.c
@@ -503,24 +503,24 @@ static av_cold void uninit(AVFilterContext *ctx)
ff_framesync_uninit(&s->fs);
- if (!s->frame_cnt) return;
-
- err = vmaf_read_pictures(s->vmaf, NULL, NULL, 0);
- if (err) {
- av_log(ctx, AV_LOG_ERROR,
- "problem flushing libvmaf context.\n");
+ if (s->frame_cnt) {
+ err = vmaf_read_pictures(s->vmaf, NULL, NULL, 0);
+ if (err)
+ av_log(ctx, AV_LOG_ERROR,
+ "problem flushing libvmaf context.\n");
}
- for (unsigned i = 0; i < s->model_cnt; i++) {
+ for (unsigned i = 0; i < s->model_cnt; vmaf_model_destroy(s->model[i]), i++)
+ {
double vmaf_score;
+ if (!s->frame_cnt)
+ continue;
err = vmaf_score_pooled(s->vmaf, s->model[i], VMAF_POOL_METHOD_MEAN,
&vmaf_score, 0, s->frame_cnt - 1);
- if (err) {
+ if (err)
av_log(ctx, AV_LOG_ERROR,
"problem getting pooled vmaf score.\n");
- }
av_log(ctx, AV_LOG_INFO, "VMAF score: %f\n", vmaf_score);
- vmaf_model_destroy(s->model[i]);
}
if (s->vmaf) {

to use aom_ctc v1.0

ffmpeg -i dist.y4m -i ref.y4m \
    -lavfi '
libvmaf=model=version=vmaf_v0.6.1\\:name=vmaf|
version=vmaf_v0.6.1neg\\:name=vmaf_neg:feature=name=psnr\\:reduced_hbd_peak=true\\:enable_apsnr=true\\:min_sse=0.5|
name=ciede|
name=float_ssim\\:enable_db=true\\:clip_db=true|
name=float_ms_ssim\\:enable_db=true\\:clip_db=true|
name=psnr_hvs' -f null -
diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c
index 8f25596525..4c99a32e8c 100644
--- a/libavfilter/vf_libvmaf.c
+++ b/libavfilter/vf_libvmaf.c
@@ -143,7 +143,7 @@ static int do_vmaf(FFFrameSync *fs)
return AVERROR(EINVAL);
}
- return 0;
+ return ff_filter_frame(ctx->outputs[0], dist);
}
static AVDictionary **delimited_dict_parse(char *str, unsigned *cnt)
@@ -519,6 +519,7 @@ static av_cold void uninit(AVFilterContext *ctx)
av_log(ctx, AV_LOG_ERROR,
"problem getting pooled vmaf score.\n");
}
+ av_log(ctx, AV_LOG_INFO, "VMAF score: %f\n", vmaf_score);
vmaf_model_destroy(s->model[i]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment