FFmpeg
Data Structures | Macros | Functions | Variables
vf_libvmaf.c File Reference
#include "config_components.h"
#include <libvmaf.h>
#include "libavutil/avstring.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "drawutils.h"
#include "filters.h"
#include "formats.h"
#include "framesync.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
 

Functions

 FRAMESYNC_DEFINE_CLASS (libvmaf, LIBVMAFContext, fs)
 
static enum VmafPixelFormat pix_fmt_map (enum AVPixelFormat av_pix_fmt)
 
static int copy_picture_data (AVFrame *src, VmafPicture *dst, unsigned bpc)
 
static int do_vmaf (FFFrameSync *fs)
 
static AVDictionary ** delimited_dict_parse (char *str, unsigned *cnt)
 
static int parse_features (AVFilterContext *ctx)
 
static int parse_models (AVFilterContext *ctx)
 
static enum VmafLogLevel log_level_map (int log_level)
 
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 enum VmafOutputFormat log_fmt_map (const char *log_fmt)
 
static enum VmafPoolingMethod pool_method_map (const char *pool_method)
 
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 69 of file vf_libvmaf.c.

◆ FLAGS

Definition at line 70 of file vf_libvmaf.c.

Function Documentation

◆ FRAMESYNC_DEFINE_CLASS()

FRAMESYNC_DEFINE_CLASS ( libvmaf  ,
LIBVMAFContext  ,
fs   
)

◆ pix_fmt_map()

static enum VmafPixelFormat pix_fmt_map ( enum AVPixelFormat  av_pix_fmt)
static

Definition at line 85 of file vf_libvmaf.c.

Referenced by copy_picture_data().

◆ copy_picture_data()

static int copy_picture_data ( AVFrame src,
VmafPicture *  dst,
unsigned  bpc 
)
static

Definition at line 108 of file vf_libvmaf.c.

Referenced by do_vmaf().

◆ do_vmaf()

static int do_vmaf ( FFFrameSync fs)
static

Definition at line 129 of file vf_libvmaf.c.

Referenced by init().

◆ delimited_dict_parse()

static AVDictionary** delimited_dict_parse ( char *  str,
unsigned *  cnt 
)
static

Definition at line 172 of file vf_libvmaf.c.

Referenced by parse_features(), and parse_models().

◆ parse_features()

static int parse_features ( AVFilterContext ctx)
static

Definition at line 224 of file vf_libvmaf.c.

Referenced by init().

◆ parse_models()

static int parse_models ( AVFilterContext ctx)
static

Definition at line 279 of file vf_libvmaf.c.

Referenced by init().

◆ log_level_map()

static enum VmafLogLevel log_level_map ( int  log_level)
static

Definition at line 411 of file vf_libvmaf.c.

Referenced by init().

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 429 of file vf_libvmaf.c.

◆ config_input_ref()

static int config_input_ref ( AVFilterLink inlink)
static

Definition at line 464 of file vf_libvmaf.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 495 of file vf_libvmaf.c.

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 518 of file vf_libvmaf.c.

◆ log_fmt_map()

static enum VmafOutputFormat log_fmt_map ( const char *  log_fmt)
static

Definition at line 524 of file vf_libvmaf.c.

Referenced by uninit().

◆ pool_method_map()

static enum VmafPoolingMethod pool_method_map ( const char *  pool_method)
static

Definition at line 540 of file vf_libvmaf.c.

Referenced by uninit().

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 554 of file vf_libvmaf.c.

Variable Documentation

◆ libvmaf_options

const AVOption libvmaf_options[]
static
Initial value:
= {
{"log_path", "Set the file path to be used to write log.", OFFSET(log_path), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS},
{"log_fmt", "Set the format of the log (csv, json, xml, or sub).", OFFSET(log_fmt), AV_OPT_TYPE_STRING, {.str="xml"}, 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},
{"model", "Set the model to be used for computing vmaf.", OFFSET(model_cfg), AV_OPT_TYPE_STRING, {.str="version=vmaf_v0.6.1"}, 0, 1, FLAGS},
{"feature", "Set the feature to be used for computing vmaf.", OFFSET(feature_cfg), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS},
{ NULL }
}

Definition at line 72 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 600 of file vf_libvmaf.c.

◆ libvmaf_outputs

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

Definition at line 612 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 620 of file vf_libvmaf.c.

libvmaf_inputs
static const AVFilterPad libvmaf_inputs[]
Definition: vf_libvmaf.c:600
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
LIBVMAFContext
Definition: vf_libvmaf.c:49
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AV_PIX_FMT_YUV420P16LE
@ AV_PIX_FMT_YUV420P16LE
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:128
AV_PIX_FMT_YUV444P16LE
@ AV_PIX_FMT_YUV444P16LE
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:132
AV_PIX_FMT_YUV420P12LE
@ AV_PIX_FMT_YUV420P12LE
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:268
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:156
AV_PIX_FMT_YUV444P12LE
@ AV_PIX_FMT_YUV444P12LE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:276
config_input_ref
static int config_input_ref(AVFilterLink *inlink)
Definition: vf_libvmaf.c:464
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:73
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
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:162
activate
static int activate(AVFilterContext *ctx)
Definition: vf_libvmaf.c:518
AV_PIX_FMT_YUV422P16LE
@ AV_PIX_FMT_YUV422P16LE
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:130
NULL
#define NULL
Definition: coverity.c:32
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_libvmaf.c:554
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_libvmaf.c:456
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_libvmaf.c:495
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:94
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:158
libvmaf_outputs
static const AVFilterPad libvmaf_outputs[]
Definition: vf_libvmaf.c:612
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
OFFSET
#define OFFSET(x)
Definition: vf_libvmaf.c:69
FLAGS
#define FLAGS
Definition: vf_libvmaf.c:70
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:78
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:77
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_libvmaf.c:429
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
AV_PIX_FMT_YUV422P12LE
@ AV_PIX_FMT_YUV422P12LE
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:272