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/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "dualinput.h"
#include "drawutils.h"
#include "formats.h"
#include "internal.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

 AVFILTER_DEFINE_CLASS (psnr)
 
static unsigned pow2 (unsigned base)
 
static double get_psnr (double mse, uint64_t nb_frames, int max)
 
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 compute_images_mse_16bit (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 AVFramedo_psnr (AVFilterContext *ctx, AVFrame *main, const AVFrame *ref)
 
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 filter_frame (AVFilterLink *inlink, AVFrame *inpicref)
 
static int request_frame (AVFilterLink *outlink)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption psnr_options []
 
static const AVFilterPad psnr_inputs []
 
static const AVFilterPad psnr_outputs []
 
AVFilter avfilter_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 58 of file vf_psnr.c.

Definition at line 59 of file vf_psnr.c.

#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)

Function Documentation

AVFILTER_DEFINE_CLASS ( psnr  )
static unsigned pow2 ( unsigned  base)
inlinestatic

Definition at line 69 of file vf_psnr.c.

Referenced by compute_images_mse(), compute_images_mse_16bit(), and get_psnr().

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

Definition at line 74 of file vf_psnr.c.

Referenced by do_psnr(), and uninit().

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 80 of file vf_psnr.c.

Referenced by config_input_ref().

static void compute_images_mse_16bit ( 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 109 of file vf_psnr.c.

Referenced by config_input_ref().

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

Definition at line 135 of file vf_psnr.c.

Referenced by do_psnr().

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

Definition at line 148 of file vf_psnr.c.

Referenced by init().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 195 of file vf_psnr.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 218 of file vf_psnr.c.

static int config_input_ref ( AVFilterLink inlink)
static

Definition at line 239 of file vf_psnr.c.

static int config_output ( AVFilterLink outlink)
static

Definition at line 305 of file vf_psnr.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame inpicref 
)
static

Definition at line 323 of file vf_psnr.c.

static int request_frame ( AVFilterLink outlink)
static

Definition at line 329 of file vf_psnr.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 335 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 },
{ NULL }
}

Definition at line 61 of file vf_psnr.c.

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

Definition at line 352 of file vf_psnr.c.

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

Definition at line 366 of file vf_psnr.c.

AVFilter avfilter_vf_psnr
Initial value:
= {
.name = "psnr",
.description = NULL_IF_CONFIG_SMALL("Calculate the PSNR between two video streams."),
.init = init,
.uninit = uninit,
.query_formats = query_formats,
.priv_size = sizeof(PSNRContext),
.priv_class = &psnr_class,
}

Definition at line 376 of file vf_psnr.c.