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

Go to the source code of this file.

Data Structures

struct  VIFContext
 
struct  ThreadData
 Used for passing data between threads. More...
 

Macros

#define OFFSET(x)   offsetof(VIFContext, x)
 
#define offset_fn(type, bits)
 
#define PF(suf)   AV_PIX_FMT_YUV420##suf, AV_PIX_FMT_YUV422##suf, AV_PIX_FMT_YUV444##suf
 

Functions

 AVFILTER_DEFINE_CLASS (vif)
 
static void vif_dec2 (const float *src, float *dst, int w, int h, int src_stride, int dst_stride)
 
static void vif_statistic (const float *mu1_sq, const float *mu2_sq, const float *mu1_mu2, const float *xx_filt, const float *yy_filt, const float *xy_filt, float *num, float *den, int w, int h)
 
static void vif_xx_yy_xy (const float *x, const float *y, float *xx, float *yy, float *xy, int w, int h)
 
static int vif_filter1d (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
int ff_compute_vif2 (AVFilterContext *ctx, const float *ref, const float *main, int w, int h, int ref_stride, int main_stride, float *score, float *data_buf[14], float **temp, int gnb_threads)
 
 offset_fn (uint8_t, 8)
 
static AVFramedo_vif (AVFilterContext *ctx, AVFrame *main, const AVFrame *ref)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_input_ref (AVFilterLink *inlink)
 
static int process_frame (FFFrameSync *fs)
 
static int config_output (AVFilterLink *outlink)
 
static int activate (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption vif_options []
 
static const uint8_t vif_filter1d_width1 [4] = { 17, 9, 5, 3 }
 
static const float vif_filter1d_table [4][17]
 
static const AVFilterPad vif_inputs []
 
static const AVFilterPad vif_outputs []
 
const AVFilter ff_vf_vif
 

Detailed Description

Calculate VIF between two input videos.

Definition in file vf_vif.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 59 of file vf_vif.c.

◆ offset_fn

#define offset_fn (   type,
  bits 
)
Value:
static void offset_##bits##bit(VIFContext *s, \
const AVFrame *ref, \
{ \
int w = s->width; \
int h = s->height; \
\
int ref_stride = ref->linesize[0]; \
int main_stride = main->linesize[0]; \
\
const type *ref_ptr = (const type *) ref->data[0]; \
const type *main_ptr = (const type *) main->data[0]; \
\
const float factor = s->factor; \
\
float *ref_ptr_data = s->ref_data; \
float *main_ptr_data = s->main_data; \
for (int i = 0; i < h; i++) { \
for (int j = 0; j < w; j++) { \
ref_ptr_data[j] = ref_ptr[j] * factor - 128.f; \
main_ptr_data[j] = main_ptr[j] * factor - 128.f; \
} \
ref_ptr += ref_stride / sizeof(type); \
ref_ptr_data += w; \
main_ptr += main_stride / sizeof(type); \
main_ptr_data += w; \
} \
}

Definition at line 397 of file vf_vif.c.

◆ PF

#define PF (   suf)    AV_PIX_FMT_YUV420##suf, AV_PIX_FMT_YUV422##suf, AV_PIX_FMT_YUV444##suf

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( vif  )

◆ vif_dec2()

static void vif_dec2 ( const float *  src,
float *  dst,
int  w,
int  h,
int  src_stride,
int  dst_stride 
)
static

Definition at line 100 of file vf_vif.c.

Referenced by ff_compute_vif2().

◆ vif_statistic()

static void vif_statistic ( const float *  mu1_sq,
const float *  mu2_sq,
const float *  mu1_mu2,
const float *  xx_filt,
const float *  yy_filt,
const float *  xy_filt,
float *  num,
float *  den,
int  w,
int  h 
)
static

Definition at line 111 of file vf_vif.c.

Referenced by ff_compute_vif2().

◆ vif_xx_yy_xy()

static void vif_xx_yy_xy ( const float *  x,
const float *  y,
float *  xx,
float *  yy,
float *  xy,
int  w,
int  h 
)
static

Definition at line 184 of file vf_vif.c.

Referenced by ff_compute_vif2().

◆ vif_filter1d()

static int vif_filter1d ( AVFilterContext ctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Vertical pass.

Horizontal pass.

Definition at line 208 of file vf_vif.c.

Referenced by ff_compute_vif2().

◆ ff_compute_vif2()

int ff_compute_vif2 ( AVFilterContext ctx,
const float *  ref,
const float *  main,
int  w,
int  h,
int  ref_stride,
int  main_stride,
float *  score,
float *  data_buf[14],
float **  temp,
int  gnb_threads 
)

Definition at line 286 of file vf_vif.c.

Referenced by do_vif().

◆ offset_fn()

offset_fn ( uint8_t  ,
 
)

Definition at line 428 of file vf_vif.c.

◆ do_vif()

static AVFrame* do_vif ( AVFilterContext ctx,
AVFrame main,
const AVFrame ref 
)
static

Definition at line 438 of file vf_vif.c.

Referenced by process_frame().

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 473 of file vf_vif.c.

◆ config_input_ref()

static int config_input_ref ( AVFilterLink inlink)
static

Definition at line 493 of file vf_vif.c.

◆ process_frame()

static int process_frame ( FFFrameSync fs)
static

Definition at line 540 of file vf_vif.c.

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 564 of file vf_vif.c.

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 595 of file vf_vif.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 601 of file vf_vif.c.

Variable Documentation

◆ vif_options

const AVOption vif_options[]
static
Initial value:
= {
{ NULL }
}

Definition at line 61 of file vf_vif.c.

◆ vif_filter1d_width1

const uint8_t vif_filter1d_width1[4] = { 17, 9, 5, 3 }
static

Definition at line 67 of file vf_vif.c.

Referenced by ff_compute_vif2().

◆ vif_filter1d_table

const float vif_filter1d_table[4][17]
static
Initial value:
=
{
{
0.00745626912, 0.0142655009, 0.0250313189, 0.0402820669, 0.0594526194,
0.0804751068, 0.0999041125, 0.113746084, 0.118773937, 0.113746084,
0.0999041125, 0.0804751068, 0.0594526194, 0.0402820669, 0.0250313189,
0.0142655009, 0.00745626912
},
{
0.0189780835, 0.0558981746, 0.120920904, 0.192116052, 0.224173605,
0.192116052, 0.120920904, 0.0558981746, 0.0189780835
},
{
0.054488685, 0.244201347, 0.402619958, 0.244201347, 0.054488685
},
{
0.166378498, 0.667243004, 0.166378498
}
}

Definition at line 69 of file vf_vif.c.

Referenced by ff_compute_vif2().

◆ vif_inputs

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

Definition at line 625 of file vf_vif.c.

◆ vif_outputs

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

Definition at line 637 of file vf_vif.c.

◆ ff_vf_vif

const AVFilter ff_vf_vif
Initial value:
= {
.name = "vif",
.description = NULL_IF_CONFIG_SMALL("Calculate the VIF between two video streams."),
.uninit = uninit,
.query_formats = query_formats,
.priv_size = sizeof(VIFContext),
.priv_class = &vif_class,
}

Definition at line 646 of file vf_vif.c.

vif_outputs
static const AVFilterPad vif_outputs[]
Definition: vf_vif.c:637
stride
int stride
Definition: mace.c:144
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:303
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_vif.c:601
w
uint8_t w
Definition: llviddspenc.c:39
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_vif.c:473
bit
#define bit(string, value)
Definition: cbs_mpeg2.c:58
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
inputs
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
Definition: filter_design.txt:243
s
#define s(width, name)
Definition: cbs_vp9.c:257
bits
uint8_t bits
Definition: vp3data.h:141
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
main
int main(int argc, char *argv[])
Definition: avio_list_dir.c:112
NULL
#define NULL
Definition: coverity.c:32
for
for(j=16;j >0;--j)
Definition: h264pred_template.c:469
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
i
int i
Definition: input.c:407
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_vif.c:564
vif_inputs
static const AVFilterPad vif_inputs[]
Definition: vf_vif.c:625
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:107
factor
static const int factor[16]
Definition: vf_pp7.c:77
activate
static int activate(AVFilterContext *ctx)
Definition: vf_vif.c:595
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:134
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
h
h
Definition: vp9dsp_template.c:2038
VIFContext
Definition: vf_vif.c:41
config_input_ref
static int config_input_ref(AVFilterLink *inlink)
Definition: vf_vif.c:493