FFmpeg
Data Structures | Macros | Functions | Variables
vf_libvmaf.c File Reference
#include <pthread.h>
#include <libvmaf.h>
#include "libavutil/avstring.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "drawutils.h"
#include "formats.h"
#include "framesync.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  LIBVMAFContext
 

Macros

#define OFFSET(x)   offsetof(LIBVMAFContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define read_frame_fn(type, bits)
 

Functions

 FRAMESYNC_DEFINE_CLASS (libvmaf, LIBVMAFContext, fs)
 
 read_frame_fn (uint8_t, 8)
 
 read_frame_fn (uint16_t, 10)
 
static void compute_vmaf_score (LIBVMAFContext *s)
 
static void * call_vmaf (void *ctx)
 
static int do_vmaf (FFFrameSync *fs)
 
static av_cold int init (AVFilterContext *ctx)
 
static int config_input_ref (AVFilterLink *inlink)
 
static int config_output (AVFilterLink *outlink)
 
static int activate (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption libvmaf_options []
 
static enum AVPixelFormat pix_fmts []
 
static const AVFilterPad libvmaf_inputs []
 
static const AVFilterPad libvmaf_outputs []
 
const AVFilter ff_vf_libvmaf
 

Detailed Description

Calculate the VMAF between two input videos.

Definition in file vf_libvmaf.c.

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   x)    offsetof(LIBVMAFContext, x)

Definition at line 71 of file vf_libvmaf.c.

◆ FLAGS

Definition at line 72 of file vf_libvmaf.c.

◆ read_frame_fn

#define read_frame_fn (   type,
  bits 
)

Definition at line 92 of file vf_libvmaf.c.

Function Documentation

◆ FRAMESYNC_DEFINE_CLASS()

FRAMESYNC_DEFINE_CLASS ( libvmaf  ,
LIBVMAFContext  ,
fs   
)

◆ read_frame_fn() [1/2]

read_frame_fn ( uint8_t  ,
 
)

◆ read_frame_fn() [2/2]

read_frame_fn ( uint16_t  ,
10   
)

◆ compute_vmaf_score()

static void compute_vmaf_score ( LIBVMAFContext s)
static

Definition at line 158 of file vf_libvmaf.c.

Referenced by call_vmaf().

◆ call_vmaf()

static void* call_vmaf ( void *  ctx)
static

Definition at line 180 of file vf_libvmaf.c.

Referenced by config_input_ref().

◆ do_vmaf()

static int do_vmaf ( FFFrameSync fs)
static

Definition at line 195 of file vf_libvmaf.c.

Referenced by init().

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 232 of file vf_libvmaf.c.

◆ config_input_ref()

static int config_input_ref ( AVFilterLink inlink)
static

Definition at line 257 of file vf_libvmaf.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 283 of file vf_libvmaf.c.

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 304 of file vf_libvmaf.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 310 of file vf_libvmaf.c.

Variable Documentation

◆ libvmaf_options

const AVOption libvmaf_options[]
static
Initial value:
= {
{"model_path", "Set the model to be used for computing vmaf.", OFFSET(model_path), AV_OPT_TYPE_STRING, {.str="/usr/local/share/model/vmaf_v0.6.1.pkl"}, 0, 1, FLAGS},
{"log_path", "Set the file path to be used to store logs.", OFFSET(log_path), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS},
{"log_fmt", "Set the format of the log (csv, json or xml).", OFFSET(log_fmt), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS},
{"enable_transform", "Enables transform for computing vmaf.", OFFSET(enable_transform), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
{"phone_model", "Invokes the phone model that will generate higher VMAF scores.", OFFSET(phone_model), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
{"psnr", "Enables computing psnr along with vmaf.", OFFSET(psnr), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
{"ssim", "Enables computing ssim along with vmaf.", OFFSET(ssim), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
{"ms_ssim", "Enables computing ms-ssim along with vmaf.", OFFSET(ms_ssim), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
{"pool", "Set the pool method to be used for computing vmaf.", OFFSET(pool), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS},
{"n_threads", "Set number of threads to be used when computing vmaf.", OFFSET(n_threads), AV_OPT_TYPE_INT, {.i64=0}, 0, UINT_MAX, FLAGS},
{"n_subsample", "Set interval for frame subsampling used when computing vmaf.", OFFSET(n_subsample), AV_OPT_TYPE_INT, {.i64=1}, 1, UINT_MAX, FLAGS},
{"enable_conf_interval", "Enables confidence interval.", OFFSET(enable_conf_interval), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
{ NULL }
}

Definition at line 74 of file vf_libvmaf.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ libvmaf_inputs

const AVFilterPad libvmaf_inputs[]
static
Initial value:
= {
{
.name = "main",
},{
.name = "reference",
.config_props = config_input_ref,
},
}

Definition at line 334 of file vf_libvmaf.c.

◆ libvmaf_outputs

const AVFilterPad libvmaf_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}

Definition at line 345 of file vf_libvmaf.c.

◆ ff_vf_libvmaf

const AVFilter ff_vf_libvmaf
Initial value:
= {
.name = "libvmaf",
.description = NULL_IF_CONFIG_SMALL("Calculate the VMAF between two video streams."),
.preinit = libvmaf_framesync_preinit,
.init = init,
.uninit = uninit,
.activate = activate,
.priv_size = sizeof(LIBVMAFContext),
.priv_class = &libvmaf_class,
}

Definition at line 353 of file vf_libvmaf.c.

psnr
static double psnr(double d)
Definition: ffmpeg.c:1415
libvmaf_inputs
static const AVFilterPad libvmaf_inputs[]
Definition: vf_libvmaf.c:334
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:171
LIBVMAFContext
Definition: vf_libvmaf.c:39
AV_PIX_FMT_YUV420P10LE
@ AV_PIX_FMT_YUV420P10LE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:149
config_input_ref
static int config_input_ref(AVFilterLink *inlink)
Definition: vf_libvmaf.c:257
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
AV_PIX_FMT_YUV444P10LE
@ AV_PIX_FMT_YUV444P10LE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:155
activate
static int activate(AVFilterContext *ctx)
Definition: vf_libvmaf.c:304
NULL
#define NULL
Definition: coverity.c:32
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_libvmaf.c:310
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_libvmaf.c:251
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_libvmaf.c:283
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
AV_PIX_FMT_YUV422P10LE
@ AV_PIX_FMT_YUV422P10LE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:151
libvmaf_outputs
static const AVFilterPad libvmaf_outputs[]
Definition: vf_libvmaf.c:345
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
OFFSET
#define OFFSET(x)
Definition: vf_libvmaf.c:71
FLAGS
#define FLAGS
Definition: vf_libvmaf.c:72
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_libvmaf.c:232
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:241
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:228