71 #define OFFSET(x) offsetof(LIBVMAFContext, x) 72 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM 92 #define read_frame_fn(type, bits) \ 93 static int read_frame_##bits##bit(float *ref_data, float *main_data, \ 94 float *temp_data, int stride, void *ctx) \ 96 LIBVMAFContext *s = (LIBVMAFContext *) ctx; \ 99 pthread_mutex_lock(&s->lock); \ 101 while (!s->frame_set && !s->eof) { \ 102 pthread_cond_wait(&s->cond, &s->lock); \ 105 if (s->frame_set) { \ 106 int ref_stride = s->gref->linesize[0]; \ 107 int main_stride = s->gmain->linesize[0]; \ 109 const type *ref_ptr = (const type *) s->gref->data[0]; \ 110 const type *main_ptr = (const type *) s->gmain->data[0]; \ 112 float *ptr = ref_data; \ 113 float factor = 1.f / (1 << (bits - 8)); \ 120 for (i = 0; i < h; i++) { \ 121 for ( j = 0; j < w; j++) { \ 122 ptr[j] = ref_ptr[j] * factor; \ 124 ref_ptr += ref_stride / sizeof(*ref_ptr); \ 125 ptr += stride / sizeof(*ptr); \ 130 for (i = 0; i < h; i++) { \ 131 for (j = 0; j < w; j++) { \ 132 ptr[j] = main_ptr[j] * factor; \ 134 main_ptr += main_stride / sizeof(*main_ptr); \ 135 ptr += stride / sizeof(*ptr); \ 139 ret = !s->frame_set; \ 141 av_frame_unref(s->gref); \ 142 av_frame_unref(s->gmain); \ 145 pthread_cond_signal(&s->cond); \ 146 pthread_mutex_unlock(&s->lock); \ 160 int (*
read_frame)(
float *ref_data,
float *main_data,
float *temp_data,
216 "libvmaf encountered an error, check log for details\n");
306 outlink->
w = mainlink->
w;
307 outlink->
h = mainlink->
h;
371 .preinit = libvmaf_framesync_preinit,
377 .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
static const AVFilterPad libvmaf_outputs[]
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate.The lists are not just lists
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 av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
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.
int(* on_event)(struct FFFrameSync *fs)
Callback called when a frame event is ready.
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)
static int read_frame(AVFilterContext *ctx, FPSContext *s, AVFilterLink *inlink, AVFilterLink *outlink)
#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
#define pthread_mutex_unlock(a)
static const AVFilterPad outputs[]
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.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
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[]
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
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)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
int depth
Number of bits in the component.
static int config_input_ref(AVFilterLink *inlink)
AVPixelFormat
Pixel format.