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

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

Definition at line 72 of file vf_ssim.c.

Definition at line 73 of file vf_ssim.c.

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

Definition at line 222 of file vf_ssim.c.

Referenced by config_input_ref(), ssim_plane(), and ssim_plane_16bit().

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

Referenced by query_formats().

Function Documentation

FRAMESYNC_DEFINE_CLASS ( ssim  ,
SSIMContext  ,
fs   
)
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().

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().

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().

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().

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().

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().

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().

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().

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.

static double ssim_db ( double  ssim,
double  weight 
)
static

Definition at line 280 of file vf_ssim.c.

Referenced by do_ssim(), and uninit().

static int do_ssim ( FFFrameSync fs)
static

Definition at line 285 of file vf_ssim.c.

Referenced by init().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 334 of file vf_ssim.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 358 of file vf_ssim.c.

static int config_input_ref ( AVFilterLink inlink)
static

Definition at line 379 of file vf_ssim.c.

static int config_output ( AVFilterLink outlink)
static

Definition at line 427 of file vf_ssim.c.

static int activate ( AVFilterContext ctx)
static

Definition at line 449 of file vf_ssim.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 455 of file vf_ssim.c.

Variable Documentation

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 }
}
#define NULL
Definition: coverity.c:32
#define FLAGS
Definition: vf_ssim.c:73
#define OFFSET(x)
Definition: vf_ssim.c:72

Definition at line 75 of file vf_ssim.c.

const AVFilterPad ssim_inputs[]
static
Initial value:
= {
{
.name = "main",
},{
.name = "reference",
.config_props = config_input_ref,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_input_ref(AVFilterLink *inlink)
Definition: vf_ssim.c:379

Definition at line 480 of file vf_ssim.c.

const AVFilterPad ssim_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_output(AVFilterLink *outlink)
Definition: vf_ssim.c:427

Definition at line 492 of file vf_ssim.c.

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,
}
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_ssim.c:455
static av_cold int init(AVFilterContext *ctx)
Definition: vf_ssim.c:334
static const AVFilterPad ssim_inputs[]
Definition: vf_ssim.c:480
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
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
static int activate(AVFilterContext *ctx)
Definition: vf_ssim.c:449
static const AVFilterPad ssim_outputs[]
Definition: vf_ssim.c:492
static int query_formats(AVFilterContext *ctx)
Definition: vf_ssim.c:358

Definition at line 501 of file vf_ssim.c.