67 #define OFFSET(x) offsetof(LIBVMAFContext, x)
68 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
71 {
"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},
75 {
"phone_model",
"Invokes the phone model that will generate higher VMAF scores.",
OFFSET(phone_model),
AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1,
FLAGS},
85 #define read_frame_fn(type, bits) \
86 static int read_frame_##bits##bit(float *ref_data, float *main_data, \
87 float *temp_data, int stride, void *ctx) \
89 LIBVMAFContext *s = (LIBVMAFContext *) ctx; \
92 pthread_mutex_lock(&s->lock); \
94 while (!s->frame_set && !s->eof) { \
95 pthread_cond_wait(&s->cond, &s->lock); \
99 int ref_stride = s->gref->linesize[0]; \
100 int main_stride = s->gmain->linesize[0]; \
102 const type *ref_ptr = (const type *) s->gref->data[0]; \
103 const type *main_ptr = (const type *) s->gmain->data[0]; \
105 float *ptr = ref_data; \
112 for (i = 0; i < h; i++) { \
113 for ( j = 0; j < w; j++) { \
114 ptr[j] = (float)ref_ptr[j]; \
116 ref_ptr += ref_stride / sizeof(*ref_ptr); \
117 ptr += stride / sizeof(*ptr); \
122 for (i = 0; i < h; i++) { \
123 for (j = 0; j < w; j++) { \
124 ptr[j] = (float)main_ptr[j]; \
126 main_ptr += main_stride / sizeof(*main_ptr); \
127 ptr += stride / sizeof(*ptr); \
131 ret = !s->frame_set; \
135 pthread_cond_signal(&s->cond); \
136 pthread_mutex_unlock(&s->lock); \
150 int (*
read_frame)(
float *ref_data,
float *main_data,
float *temp_data,
272 outlink->
w = mainlink->
w;
273 outlink->
h = mainlink->
h;
333 .preinit = libvmaf_framesync_preinit,
339 .priv_class = &libvmaf_class,
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
#define pthread_mutex_lock(a)
static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
static int do_vmaf(FFFrameSync *fs)
static int query_formats(AVFilterContext *ctx)
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Main libavfilter public API header.
const AVPixFmtDescriptor * desc
int h
agreed upon image height
int(* on_event)(struct FFFrameSync *fs)
Callback called when a frame event is ready.
static const AVFilterPad libvmaf_outputs[]
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
const char * name
Pad name.
AVFilterContext * parent
Parent filter context.
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
int ff_framesync_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
static double psnr(double d)
static av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
int main(int argc, char *argv[])
A filter pad used for either input or output.
A link between two filters.
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0, will be automatically copied from the first input of the source filter if it exists.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
static const AVOption libvmaf_options[]
static av_cold int init(AVFilterContext *ctx)
#define read_frame_fn(type, bits)
static av_always_inline int pthread_join(pthread_t thread, void **value_ptr)
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
static int activate(AVFilterContext *ctx)
AVFilterContext * src
source filter
static const AVFilterPad outputs[]
#define pthread_mutex_unlock(a)
int format
agreed upon media format
static av_cold void uninit(AVFilterContext *ctx)
static av_always_inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
#define AV_LOG_INFO
Standard information.
static const AVFilterPad inputs[]
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Describe the class of an AVClass context structure.
static const AVFilterPad libvmaf_inputs[]
const char * name
Filter name.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt, uint8_t block_type, AVFormatContext *s)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static void compute_vmaf_score(LIBVMAFContext *s)
static int ref[MAX_W *MAX_W]
static void * call_vmaf(void *ctx)
static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
AVFilterContext * dst
dest filter
FRAMESYNC_DEFINE_CLASS(libvmaf, LIBVMAFContext, fs)
static int config_output(AVFilterLink *outlink)
int depth
Number of bits in the component.
static int config_input_ref(AVFilterLink *inlink)
AVPixelFormat
Pixel format.