FFmpeg
Data Structures | Macros | Functions | Variables
vf_psnr.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 "psnr.h"
#include "video.h"

Go to the source code of this file.

Data Structures

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

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 int compute_images_mse (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
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 []
 
const AVFilter ff_vf_psnr
 

Detailed Description

Caculate the PSNR between two input videos.

Definition in file vf_psnr.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 62 of file vf_psnr.c.

◆ FLAGS

Definition at line 63 of file vf_psnr.c.

◆ PF_NOALPHA

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

◆ PF_ALPHA

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

◆ PF

#define PF (   suf)    PF_NOALPHA(suf), PF_ALPHA(suf)

Function Documentation

◆ FRAMESYNC_DEFINE_CLASS()

FRAMESYNC_DEFINE_CLASS ( psnr  ,
PSNRContext  ,
fs   
)

◆ pow_2()

static unsigned pow_2 ( unsigned  base)
inlinestatic

Definition at line 75 of file vf_psnr.c.

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

◆ get_psnr()

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

Definition at line 80 of file vf_psnr.c.

Referenced by do_psnr(), and uninit().

◆ sse_line_8bit()

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

Definition at line 85 of file vf_psnr.c.

Referenced by config_input_ref().

◆ sse_line_16bit()

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

Definition at line 96 of file vf_psnr.c.

Referenced by config_input_ref().

◆ compute_images_mse()

static int compute_images_mse ( AVFilterContext ctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 122 of file vf_psnr.c.

Referenced by do_psnr().

◆ set_meta()

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

Definition at line 149 of file vf_psnr.c.

Referenced by do_psnr().

◆ do_psnr()

static int do_psnr ( FFFrameSync fs)
static

Definition at line 162 of file vf_psnr.c.

Referenced by init().

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 266 of file vf_psnr.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 298 of file vf_psnr.c.

◆ config_input_ref()

static int config_input_ref ( AVFilterLink inlink)
static

Definition at line 321 of file vf_psnr.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 384 of file vf_psnr.c.

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 413 of file vf_psnr.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 419 of file vf_psnr.c.

Variable Documentation

◆ psnr_options

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 }
}

Definition at line 65 of file vf_psnr.c.

◆ psnr_inputs

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

Definition at line 449 of file vf_psnr.c.

◆ psnr_outputs

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

Definition at line 461 of file vf_psnr.c.

◆ ff_vf_psnr

const 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,
}

Definition at line 470 of file vf_psnr.c.

config_input_ref
static int config_input_ref(AVFilterLink *inlink)
Definition: vf_psnr.c:321
PSNRContext
Definition: vf_psnr.c:39
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_psnr.c:266
psnr_inputs
static const AVFilterPad psnr_inputs[]
Definition: vf_psnr.c:449
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
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_psnr.c:298
NULL
#define NULL
Definition: coverity.c:32
psnr_outputs
static const AVFilterPad psnr_outputs[]
Definition: vf_psnr.c:461
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:117
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_psnr.c:419
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_psnr.c:384
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
activate
static int activate(AVFilterContext *ctx)
Definition: vf_psnr.c:413
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:242
FLAGS
#define FLAGS
Definition: vf_psnr.c:63
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#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:134
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
OFFSET
#define OFFSET(x)
Definition: vf_psnr.c:62