FFmpeg
Loading...
Searching...
No Matches
vf_psnr.c File Reference

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

#include "libavutil/avstring.h"
#include "libavutil/file_open.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "drawutils.h"
#include "filters.h"
#include "framesync.h"
#include "psnr.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)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define PF_NOALPHA(suf)
 
#define PF_ALPHA(suf)
 
#define PF(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 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 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 enum AVPixelFormat pix_fmts []
 
static const AVFilterPad psnr_inputs []
 
static const AVFilterPad psnr_outputs []
 
const FFFilter ff_vf_psnr
 

Detailed Description

Calculate the PSNR between two input videos.

Definition in file vf_psnr.c.

Macro Definition Documentation

◆ OFFSET

#define OFFSET ( x)
Value:
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)
Value:
AV_PIX_FMT_YUV420##suf, AV_PIX_FMT_YUV422##suf, AV_PIX_FMT_YUV444##suf

◆ PF_ALPHA

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

◆ PF

#define PF ( suf)
Value:
PF_NOALPHA(suf), PF_ALPHA(suf)
#define PF_NOALPHA(suf)
#define 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().

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

◆ compute_images_mse()

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

Definition at line 98 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 125 of file vf_psnr.c.

Referenced by do_psnr().

◆ do_psnr()

static int do_psnr ( FFFrameSync * fs)
static

Definition at line 138 of file vf_psnr.c.

Referenced by init().

◆ init()

static av_cold int init ( AVFilterContext * ctx)
static

Definition at line 250 of file vf_psnr.c.

◆ config_input_ref()

static int config_input_ref ( AVFilterLink * inlink)
static

Definition at line 295 of file vf_psnr.c.

◆ config_output()

static int config_output ( AVFilterLink * outlink)
static

Definition at line 352 of file vf_psnr.c.

◆ activate()

static int activate ( AVFilterContext * ctx)
static

Definition at line 383 of file vf_psnr.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 389 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 }
}
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275

Definition at line 65 of file vf_psnr.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static
Initial value:
= {
#define PF_NOALPHA(suf)
#define PF_ALPHA(suf)
#define PF(suf)
PF(P), PF(P9), PF(P10), PF_NOALPHA(P12), PF_NOALPHA(P14), PF(P16),
}
#define P
#define AV_PIX_FMT_GBRAP12
Definition pixfmt.h:569
#define AV_PIX_FMT_GRAY9
Definition pixfmt.h:524
#define AV_PIX_FMT_GBRAP16
Definition pixfmt.h:571
#define AV_PIX_FMT_GBRP9
Definition pixfmt.h:563
#define AV_PIX_FMT_GBRP10
Definition pixfmt.h:564
#define AV_PIX_FMT_GRAY12
Definition pixfmt.h:526
#define AV_PIX_FMT_GBRP12
Definition pixfmt.h:565
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition pixfmt.h:106
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition pixfmt.h:107
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition pixfmt.h:79
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition pixfmt.h:80
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition pixfmt.h:283
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition pixfmt.h:212
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition pixfmt.h:86
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition pixfmt.h:165
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition pixfmt.h:87
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition pixfmt.h:85
#define AV_PIX_FMT_GRAY10
Definition pixfmt.h:525
#define AV_PIX_FMT_GRAY14
Definition pixfmt.h:527
#define AV_PIX_FMT_GRAY16
Definition pixfmt.h:528
#define AV_PIX_FMT_GBRAP10
Definition pixfmt.h:568
#define AV_PIX_FMT_GBRP16
Definition pixfmt.h:567
#define AV_PIX_FMT_GBRP14
Definition pixfmt.h:566
#define PF(suf)

Definition at line 280 of file vf_psnr.c.

◆ psnr_inputs

const AVFilterPad psnr_inputs[]
static
Initial value:
= {
{
.name = "main",
},{
.name = "reference",
.config_props = config_input_ref,
},
}
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static int config_input_ref(AVFilterLink *inlink)
Definition vf_corr.c:287

Definition at line 419 of file vf_psnr.c.

◆ psnr_outputs

const AVFilterPad psnr_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}
static int config_output(AVBitStreamFilterLink *outlink)

Definition at line 430 of file vf_psnr.c.

◆ ff_vf_psnr

const FFFilter ff_vf_psnr
Initial value:
= {
.p.name = "psnr",
.p.description = NULL_IF_CONFIG_SMALL("Calculate the PSNR between two video streams."),
.p.priv_class = &psnr_class,
.preinit = psnr_framesync_preinit,
.init = init,
.uninit = uninit,
.activate = activate,
.priv_size = sizeof(PSNRContext),
}
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
#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:204
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
Definition avfilter.h:182
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:244
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
static const AVFilterPad psnr_outputs[]
Definition vf_psnr.c:430
static const AVFilterPad psnr_inputs[]
Definition vf_psnr.c:419

Definition at line 438 of file vf_psnr.c.