FFmpeg
Loading...
Searching...
No Matches
vf_vif.c File Reference

Calculate VIF between two input videos. More...

#include <float.h>
#include "libavutil/internal.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "filters.h"
#include "framesync.h"

Go to the source code of this file.

Data Structures

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

Macros

#define NUM_DATA_BUFS   13
 
#define OFFSET(x)
 
#define offset_fn(type, bits)
 
#define PF(suf)
 

Functions

 FRAMESYNC_DEFINE_CLASS (vif, VIFContext, fs)
 
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)
 
static int compute_vif2 (AVFilterContext *ctx, const float *ref, const float *main, int w, int h, int ref_stride, int main_stride, float *score, float *const data_buf[NUM_DATA_BUFS], float **temp, int gnb_threads)
 
 offset_fn (uint8_t, 8)
 
static AVFramedo_vif (AVFilterContext *ctx, AVFrame *main, const AVFrame *ref)
 
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 enum AVPixelFormat pix_fmts []
 
static const AVFilterPad vif_inputs []
 
static const AVFilterPad vif_outputs []
 
const FFFilter ff_vf_vif
 

Detailed Description

Calculate VIF between two input videos.

Definition in file vf_vif.c.

Macro Definition Documentation

◆ NUM_DATA_BUFS

#define NUM_DATA_BUFS   13

Definition at line 38 of file vf_vif.c.

Referenced by compute_vif2(), config_input_ref(), and uninit().

◆ OFFSET

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

Definition at line 58 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; \
} \
}
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define bit(string, value)
Definition cbs_mpeg2.c:56
#define s(width, name)
Definition cbs_vp9.c:198
int main
Definition dovi_rpuenc.c:38
static const uint8_t bits[8]
Definition fastaudio.c:100
cl_device_type type
static const int factor[16]
Definition vf_pp7.c:98
uint8_t w
Definition llvidencdsp.c:39
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
#define stride
static int ref[MAX_W *MAX_W]

Definition at line 396 of file vf_vif.c.

Referenced by offset_fn().

◆ PF

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

Function Documentation

◆ FRAMESYNC_DEFINE_CLASS()

FRAMESYNC_DEFINE_CLASS ( vif ,
VIFContext ,
fs  )

◆ 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 99 of file vf_vif.c.

Referenced by 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 110 of file vf_vif.c.

Referenced by 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 183 of file vf_vif.c.

Referenced by 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 207 of file vf_vif.c.

Referenced by compute_vif2().

◆ compute_vif2()

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

Definition at line 285 of file vf_vif.c.

Referenced by do_vif().

◆ offset_fn()

offset_fn ( uint8_t ,
8  )

Definition at line 427 of file vf_vif.c.

◆ do_vif()

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

Definition at line 437 of file vf_vif.c.

Referenced by process_frame().

◆ config_input_ref()

static int config_input_ref ( AVFilterLink * inlink)
static

Definition at line 482 of file vf_vif.c.

◆ process_frame()

static int process_frame ( FFFrameSync * fs)
static

Definition at line 525 of file vf_vif.c.

◆ config_output()

static int config_output ( AVFilterLink * outlink)
static

Definition at line 549 of file vf_vif.c.

◆ activate()

static int activate ( AVFilterContext * ctx)
static

Definition at line 582 of file vf_vif.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 588 of file vf_vif.c.

Variable Documentation

◆ vif_options

const AVOption vif_options[]
static
Initial value:
= {
{ NULL }
}
#define NULL
Definition coverity.c:32

Definition at line 60 of file vf_vif.c.

◆ vif_filter1d_width1

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

Definition at line 66 of file vf_vif.c.

Referenced by 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 68 of file vf_vif.c.

Referenced by compute_vif2().

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static
Initial value:
= {
#define PF(suf)
PF(P9), PF(P10), PF(P12), PF(P14), PF(P16),
}
#define AV_PIX_FMT_GRAY9
Definition pixfmt.h:524
#define AV_PIX_FMT_GRAY12
Definition pixfmt.h:526
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition pixfmt.h:106
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition pixfmt.h:107
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition pixfmt.h:79
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition pixfmt.h:80
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition pixfmt.h:283
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition pixfmt.h:86
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition pixfmt.h:87
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition pixfmt.h:85
#define AV_PIX_FMT_GRAY10
Definition pixfmt.h:525
#define AV_PIX_FMT_GRAY14
Definition pixfmt.h:527
#define AV_PIX_FMT_GRAY16
Definition pixfmt.h:528
#define PF(suf)

Definition at line 470 of file vf_vif.c.

◆ vif_inputs

const AVFilterPad vif_inputs[]
static
Initial value:
= {
{
.name = "main",
},{
.name = "reference",
.config_props = config_input_ref,
},
}
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static int config_input_ref(AVFilterLink *inlink)
Definition vf_corr.c:287

Definition at line 612 of file vf_vif.c.

◆ vif_outputs

const AVFilterPad vif_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}
static int config_output(AVBitStreamFilterLink *outlink)

Definition at line 623 of file vf_vif.c.

◆ ff_vf_vif

const FFFilter ff_vf_vif
Initial value:
= {
.p.name = "vif",
.p.description = NULL_IF_CONFIG_SMALL("Calculate the VIF between two video streams."),
.p.priv_class = &vif_class,
.preinit = vif_framesync_preinit,
.uninit = uninit,
.priv_size = sizeof(VIFContext),
}
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
#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:204
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
Definition avfilter.h:182
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:244
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
static const AVFilterPad vif_inputs[]
Definition vf_vif.c:612
static const AVFilterPad vif_outputs[]
Definition vf_vif.c:623

Definition at line 631 of file vf_vif.c.