FFmpeg
Data Structures | Macros | Functions | Variables
vf_ssim.c File Reference
#include "libavutil/avstring.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "drawutils.h"
#include "formats.h"
#include "framesync.h"
#include "internal.h"
#include "ssim.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  SSIMContext
 

Macros

#define OFFSET(x)   offsetof(SSIMContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define SUM_LEN(w)   (((w) >> 2) + 3)
 
#define PF(suf)   AV_PIX_FMT_YUV420##suf, AV_PIX_FMT_YUV422##suf, AV_PIX_FMT_YUV444##suf, AV_PIX_FMT_GBR##suf
 

Functions

 FRAMESYNC_DEFINE_CLASS (ssim, SSIMContext, fs)
 
static void set_meta (AVDictionary **metadata, const char *key, char comp, float d)
 
static void ssim_4x4xn_16bit (const uint8_t *main8, ptrdiff_t main_stride, const uint8_t *ref8, ptrdiff_t ref_stride, int64_t(*sums)[4], int width)
 
static void ssim_4x4xn_8bit (const uint8_t *main, ptrdiff_t main_stride, const uint8_t *ref, ptrdiff_t ref_stride, int(*sums)[4], int width)
 
static float ssim_end1x (int64_t s1, int64_t s2, int64_t ss, int64_t s12, int max)
 
static float ssim_end1 (int s1, int s2, int ss, int s12)
 
static float ssim_endn_16bit (const int64_t(*sum0)[4], const int64_t(*sum1)[4], int width, int max)
 
static float ssim_endn_8bit (const int(*sum0)[4], const int(*sum1)[4], int width)
 
static float ssim_plane_16bit (SSIMDSPContext *dsp, uint8_t *main, int main_stride, uint8_t *ref, int ref_stride, int width, int height, void *temp, int max)
 
static float ssim_plane (SSIMDSPContext *dsp, uint8_t *main, int main_stride, uint8_t *ref, int ref_stride, int width, int height, void *temp, int max)
 
static double ssim_db (double ssim, double weight)
 
static int do_ssim (FFFrameSync *fs)
 
static av_cold int init (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_input_ref (AVFilterLink *inlink)
 
static int config_output (AVFilterLink *outlink)
 
static int activate (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption ssim_options []
 
static const AVFilterPad ssim_inputs []
 
static const AVFilterPad ssim_outputs []
 
AVFilter ff_vf_ssim
 

Macro Definition Documentation

◆ OFFSET

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

Definition at line 72 of file vf_ssim.c.

◆ FLAGS

Definition at line 73 of file vf_ssim.c.

◆ SUM_LEN

#define SUM_LEN (   w)    (((w) >> 2) + 3)

Definition at line 222 of file vf_ssim.c.

◆ PF

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

Function Documentation

◆ FRAMESYNC_DEFINE_CLASS()

FRAMESYNC_DEFINE_CLASS ( ssim  ,
SSIMContext  ,
fs   
)

◆ set_meta()

static void set_meta ( AVDictionary **  metadata,
const char *  key,
char  comp,
float  d 
)
static

Definition at line 83 of file vf_ssim.c.

Referenced by do_ssim().

◆ ssim_4x4xn_16bit()

static void ssim_4x4xn_16bit ( const uint8_t main8,
ptrdiff_t  main_stride,
const uint8_t ref8,
ptrdiff_t  ref_stride,
int64_t(*)  sums[4],
int  width 
)
static

Definition at line 96 of file vf_ssim.c.

Referenced by ssim_plane_16bit().

◆ ssim_4x4xn_8bit()

static void ssim_4x4xn_8bit ( const uint8_t main,
ptrdiff_t  main_stride,
const uint8_t ref,
ptrdiff_t  ref_stride,
int(*)  sums[4],
int  width 
)
static

Definition at line 132 of file vf_ssim.c.

Referenced by config_input_ref().

◆ ssim_end1x()

static float ssim_end1x ( int64_t  s1,
int64_t  s2,
int64_t  ss,
int64_t  s12,
int  max 
)
static

Definition at line 163 of file vf_ssim.c.

Referenced by ssim_endn_16bit().

◆ ssim_end1()

static float ssim_end1 ( int  s1,
int  s2,
int  ss,
int  s12 
)
static

Definition at line 179 of file vf_ssim.c.

Referenced by ssim_endn_8bit().

◆ ssim_endn_16bit()

static float ssim_endn_16bit ( const int64_t(*)  sum0[4],
const int64_t(*)  sum1[4],
int  width,
int  max 
)
static

Definition at line 195 of file vf_ssim.c.

Referenced by ssim_plane_16bit().

◆ ssim_endn_8bit()

static float ssim_endn_8bit ( const int(*)  sum0[4],
const int(*)  sum1[4],
int  width 
)
static

Definition at line 209 of file vf_ssim.c.

Referenced by config_input_ref().

◆ ssim_plane_16bit()

static float ssim_plane_16bit ( SSIMDSPContext dsp,
uint8_t main,
int  main_stride,
uint8_t ref,
int  ref_stride,
int  width,
int  height,
void *  temp,
int  max 
)
static

Definition at line 224 of file vf_ssim.c.

Referenced by config_input_ref().

◆ ssim_plane()

static float ssim_plane ( SSIMDSPContext dsp,
uint8_t main,
int  main_stride,
uint8_t ref,
int  ref_stride,
int  width,
int  height,
void *  temp,
int  max 
)
static

Definition at line 252 of file vf_ssim.c.

Referenced by config_input_ref().

◆ ssim_db()

static double ssim_db ( double  ssim,
double  weight 
)
static

Definition at line 280 of file vf_ssim.c.

Referenced by do_ssim(), and uninit().

◆ do_ssim()

static int do_ssim ( FFFrameSync fs)
static

Definition at line 285 of file vf_ssim.c.

Referenced by init().

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 334 of file vf_ssim.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 358 of file vf_ssim.c.

◆ config_input_ref()

static int config_input_ref ( AVFilterLink inlink)
static

Definition at line 379 of file vf_ssim.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 427 of file vf_ssim.c.

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 449 of file vf_ssim.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 455 of file vf_ssim.c.

Variable Documentation

◆ ssim_options

const AVOption ssim_options[]
static
Initial value:
= {
{"stats_file", "Set file where to store per-frame difference information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
{"f", "Set file where to store per-frame difference information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
{ NULL }
}

Definition at line 75 of file vf_ssim.c.

◆ ssim_inputs

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

Definition at line 480 of file vf_ssim.c.

◆ ssim_outputs

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

Definition at line 492 of file vf_ssim.c.

◆ ff_vf_ssim

AVFilter ff_vf_ssim
Initial value:
= {
.name = "ssim",
.description = NULL_IF_CONFIG_SMALL("Calculate the SSIM between two video streams."),
.preinit = ssim_framesync_preinit,
.init = init,
.uninit = uninit,
.query_formats = query_formats,
.activate = activate,
.priv_size = sizeof(SSIMContext),
.priv_class = &ssim_class,
}

Definition at line 501 of file vf_ssim.c.

activate
static int activate(AVFilterContext *ctx)
Definition: vf_ssim.c:449
config_input_ref
static int config_input_ref(AVFilterLink *inlink)
Definition: vf_ssim.c:379
FLAGS
#define FLAGS
Definition: vf_ssim.c:73
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_ssim.c:358
ssim_inputs
static const AVFilterPad ssim_inputs[]
Definition: vf_ssim.c:480
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
NULL
#define NULL
Definition: coverity.c:32
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
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:188
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_ssim.c:334
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_ssim.c:455
ssim_outputs
static const AVFilterPad ssim_outputs[]
Definition: vf_ssim.c:492
OFFSET
#define OFFSET(x)
Definition: vf_ssim.c:72
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_ssim.c:427
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
SSIMContext
Definition: vf_ssim.c:48
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:227