FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
vf_psnr.c File Reference

Caculate the PSNR between two input videos. More...

#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 "psnr.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  PSNRContext
 

Macros

#define OFFSET(x)   offsetof(PSNRContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define PF_NOALPHA(suf)   AV_PIX_FMT_YUV420##suf, AV_PIX_FMT_YUV422##suf, AV_PIX_FMT_YUV444##suf
 
#define PF_ALPHA(suf)   AV_PIX_FMT_YUVA420##suf, AV_PIX_FMT_YUVA422##suf, AV_PIX_FMT_YUVA444##suf
 
#define PF(suf)   PF_NOALPHA(suf), PF_ALPHA(suf)
 

Functions

 FRAMESYNC_DEFINE_CLASS (psnr, PSNRContext, fs)
 
static unsigned pow_2 (unsigned base)
 
static double get_psnr (double mse, uint64_t nb_frames, int max)
 
static uint64_t sse_line_8bit (const uint8_t *main_line, const uint8_t *ref_line, int outw)
 
static uint64_t sse_line_16bit (const uint8_t *_main_line, const uint8_t *_ref_line, int outw)
 
static void compute_images_mse (PSNRContext *s, const uint8_t *main_data[4], const int main_linesizes[4], const uint8_t *ref_data[4], const int ref_linesizes[4], int w, int h, double mse[4])
 
static void set_meta (AVDictionary **metadata, const char *key, char comp, float d)
 
static int do_psnr (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 psnr_options []
 
static const AVFilterPad psnr_inputs []
 
static const AVFilterPad psnr_outputs []
 
AVFilter ff_vf_psnr
 

Detailed Description

Caculate the PSNR between two input videos.

Definition in file vf_psnr.c.

Macro Definition Documentation

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

Definition at line 60 of file vf_psnr.c.

Definition at line 61 of file vf_psnr.c.

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

Referenced by query_formats().

#define PF_ALPHA (   suf)    AV_PIX_FMT_YUVA420##suf, AV_PIX_FMT_YUVA422##suf, AV_PIX_FMT_YUVA444##suf
#define PF (   suf)    PF_NOALPHA(suf), PF_ALPHA(suf)

Referenced by query_formats().

Function Documentation

FRAMESYNC_DEFINE_CLASS ( psnr  ,
PSNRContext  ,
fs   
)
static unsigned pow_2 ( unsigned  base)
inlinestatic

Definition at line 73 of file vf_psnr.c.

Referenced by get_psnr(), sse_line_16bit(), and sse_line_8bit().

static double get_psnr ( double  mse,
uint64_t  nb_frames,
int  max 
)
inlinestatic

Definition at line 78 of file vf_psnr.c.

Referenced by do_psnr(), and uninit().

static uint64_t sse_line_8bit ( const uint8_t main_line,
const uint8_t ref_line,
int  outw 
)
static

Definition at line 83 of file vf_psnr.c.

Referenced by config_input_ref().

static uint64_t sse_line_16bit ( const uint8_t _main_line,
const uint8_t _ref_line,
int  outw 
)
static

Definition at line 94 of file vf_psnr.c.

Referenced by config_input_ref().

static void compute_images_mse ( PSNRContext s,
const uint8_t main_data[4],
const int  main_linesizes[4],
const uint8_t ref_data[4],
const int  ref_linesizes[4],
int  w,
int  h,
double  mse[4] 
)
inlinestatic

Definition at line 108 of file vf_psnr.c.

Referenced by do_psnr().

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

Definition at line 132 of file vf_psnr.c.

Referenced by do_psnr().

static int do_psnr ( FFFrameSync fs)
static

Definition at line 145 of file vf_psnr.c.

Referenced by init().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 228 of file vf_psnr.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 260 of file vf_psnr.c.

static int config_input_ref ( AVFilterLink inlink)
static

Definition at line 283 of file vf_psnr.c.

static int config_output ( AVFilterLink outlink)
static

Definition at line 335 of file vf_psnr.c.

static int activate ( AVFilterContext ctx)
static

Definition at line 356 of file vf_psnr.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 362 of file vf_psnr.c.

Variable Documentation

const AVOption psnr_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 },
{"stats_version", "Set the format version for the stats file.", OFFSET(stats_version), AV_OPT_TYPE_INT, {.i64=1}, 1, 2, FLAGS },
{"output_max", "Add raw stats (max values) to the output log.", OFFSET(stats_add_max), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
{ NULL }
}
#define NULL
Definition: coverity.c:32
#define OFFSET(x)
Definition: vf_psnr.c:60
#define FLAGS
Definition: vf_psnr.c:61

Definition at line 63 of file vf_psnr.c.

const AVFilterPad psnr_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_psnr.c:283

Definition at line 389 of file vf_psnr.c.

const AVFilterPad psnr_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_psnr.c:335

Definition at line 401 of file vf_psnr.c.

AVFilter ff_vf_psnr
Initial value:
= {
.name = "psnr",
.description = NULL_IF_CONFIG_SMALL("Calculate the PSNR between two video streams."),
.preinit = psnr_framesync_preinit,
.init = init,
.uninit = uninit,
.query_formats = query_formats,
.activate = activate,
.priv_size = sizeof(PSNRContext),
.priv_class = &psnr_class,
}
static int activate(AVFilterContext *ctx)
Definition: vf_psnr.c:356
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_psnr.c:362
static av_cold int init(AVFilterContext *ctx)
Definition: vf_psnr.c:228
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:389
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:379
static const AVFilterPad psnr_inputs[]
Definition: vf_psnr.c:389
static const AVFilterPad psnr_outputs[]
Definition: vf_psnr.c:401
static int query_formats(AVFilterContext *ctx)
Definition: vf_psnr.c:260

Definition at line 410 of file vf_psnr.c.