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

Calculate the extended perceptually weighted PSNR (XPSNR) 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"
#include "xpsnr.h"

Go to the source code of this file.

Data Structures

struct  XPSNRContext
 

Macros

#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
 
#define OFFSET(x)
 
#define XPSNR_GAMMA   2
 
#define PF_NOALPHA(suf)
 
#define PF_ALPHA(suf)
 
#define PF(suf)
 

Functions

 FRAMESYNC_DEFINE_CLASS (xpsnr, XPSNRContext, fs)
 
static uint64_t highds (const int x_act, const int y_act, const int w_act, const int h_act, const int16_t *o_m0, const int o)
 
static uint64_t diff1st (const uint32_t w_act, const uint32_t h_act, const int16_t *o_m0, int16_t *o_m1, const int o)
 
static uint64_t diff2nd (const uint32_t w_act, const uint32_t h_act, const int16_t *o_m0, int16_t *o_m1, int16_t *o_m2, const int o)
 
static uint64_t calc_squared_error (XPSNRContext const *s, const int16_t *blk_org, const uint32_t stride_org, const int16_t *blk_rec, const uint32_t stride_rec, const uint32_t block_width, const uint32_t block_height)
 
static double calc_squared_error_and_weight (XPSNRContext const *s, const int16_t *pic_org, const uint32_t stride_org, int16_t *pic_org_m1, int16_t *pic_org_m2, const int16_t *pic_rec, const uint32_t stride_rec, const uint32_t offset_x, const uint32_t offset_y, const uint32_t block_width, const uint32_t block_height, const uint32_t bit_depth, const uint32_t int_frame_rate, double *ms_act)
 
static double get_avg_xpsnr (const double sqrt_wsse_val, const double sum_xpsnr_val, const uint32_t image_width, const uint32_t image_height, const uint64_t max_error_64, const uint64_t num_frames_64)
 
static int get_wsse (AVFilterContext *ctx, int16_t **org, int16_t *org_m1, int16_t *org_m2, int16_t **rec, uint64_t *const wsse64)
 
static void set_meta (AVDictionary **metadata, const char *key, char comp, float d)
 
static int do_xpsnr (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 xpsnr_options []
 
static enum AVPixelFormat xpsnr_formats []
 
static const AVFilterPad xpsnr_inputs []
 
static const AVFilterPad xpsnr_outputs []
 
const FFFilter ff_vf_xpsnr
 

Detailed Description

Calculate the extended perceptually weighted PSNR (XPSNR) between two input videos.

Authors: Christian Helmrich, Lehmann, and Stoffers, Fraunhofer HHI, Berlin, Germany

Definition in file vf_xpsnr.c.

Macro Definition Documentation

◆ FLAGS

Definition at line 78 of file vf_xpsnr.c.

◆ OFFSET

#define OFFSET ( x)
Value:
offsetof(XPSNRContext, x)

Definition at line 79 of file vf_xpsnr.c.

◆ XPSNR_GAMMA

#define XPSNR_GAMMA   2

Definition at line 80 of file vf_xpsnr.c.

Referenced by calc_squared_error_and_weight(), diff1st(), and diff2nd().

◆ 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 ( xpsnr ,
XPSNRContext ,
fs  )

◆ highds()

static uint64_t highds ( const int x_act,
const int y_act,
const int w_act,
const int h_act,
const int16_t * o_m0,
const int o )
static

Definition at line 92 of file vf_xpsnr.c.

Referenced by calc_squared_error_and_weight(), and config_input_ref().

◆ diff1st()

static uint64_t diff1st ( const uint32_t w_act,
const uint32_t h_act,
const int16_t * o_m0,
int16_t * o_m1,
const int o )
static

Definition at line 112 of file vf_xpsnr.c.

Referenced by config_input_ref().

◆ diff2nd()

static uint64_t diff2nd ( const uint32_t w_act,
const uint32_t h_act,
const int16_t * o_m0,
int16_t * o_m1,
int16_t * o_m2,
const int o )
static

Definition at line 128 of file vf_xpsnr.c.

Referenced by config_input_ref().

◆ calc_squared_error()

static uint64_t calc_squared_error ( XPSNRContext const * s,
const int16_t * blk_org,
const uint32_t stride_org,
const int16_t * blk_rec,
const uint32_t stride_rec,
const uint32_t block_width,
const uint32_t block_height )
inlinestatic

Definition at line 147 of file vf_xpsnr.c.

Referenced by calc_squared_error_and_weight(), and get_wsse().

◆ calc_squared_error_and_weight()

static double calc_squared_error_and_weight ( XPSNRContext const * s,
const int16_t * pic_org,
const uint32_t stride_org,
int16_t * pic_org_m1,
int16_t * pic_org_m2,
const int16_t * pic_rec,
const uint32_t stride_rec,
const uint32_t offset_x,
const uint32_t offset_y,
const uint32_t block_width,
const uint32_t block_height,
const uint32_t bit_depth,
const uint32_t int_frame_rate,
double * ms_act )
inlinestatic

Definition at line 164 of file vf_xpsnr.c.

Referenced by get_wsse().

◆ get_avg_xpsnr()

static double get_avg_xpsnr ( const double sqrt_wsse_val,
const double sum_xpsnr_val,
const uint32_t image_width,
const uint32_t image_height,
const uint64_t max_error_64,
const uint64_t num_frames_64 )
inlinestatic

Definition at line 252 of file vf_xpsnr.c.

Referenced by do_xpsnr(), and uninit().

◆ get_wsse()

static int get_wsse ( AVFilterContext * ctx,
int16_t ** org,
int16_t * org_m1,
int16_t * org_m2,
int16_t ** rec,
uint64_t *const wsse64 )
static

Definition at line 269 of file vf_xpsnr.c.

Referenced by do_xpsnr().

◆ set_meta()

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

Definition at line 383 of file vf_xpsnr.c.

Referenced by do_xpsnr().

◆ do_xpsnr()

static int do_xpsnr ( FFFrameSync * fs)
static

Definition at line 396 of file vf_xpsnr.c.

Referenced by init().

◆ init()

static av_cold int init ( AVFilterContext * ctx)
static

Definition at line 496 of file vf_xpsnr.c.

◆ config_input_ref()

static int config_input_ref ( AVFilterLink * inlink)
static

Definition at line 548 of file vf_xpsnr.c.

◆ config_output()

static int config_output ( AVFilterLink * outlink)
static

Definition at line 597 of file vf_xpsnr.c.

◆ activate()

static int activate ( AVFilterContext * ctx)
static

Definition at line 629 of file vf_xpsnr.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 636 of file vf_xpsnr.c.

Variable Documentation

◆ xpsnr_options

const AVOption xpsnr_options[]
static
Initial value:
= {
{"stats_file", "Set file where to store per-frame XPSNR information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS},
{"f", "Set file where to store per-frame XPSNR information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS},
{ NULL }
}
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ 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 82 of file vf_xpsnr.c.

◆ xpsnr_formats

enum AVPixelFormat xpsnr_formats[]
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 533 of file vf_xpsnr.c.

◆ xpsnr_inputs

const AVFilterPad xpsnr_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 694 of file vf_xpsnr.c.

◆ xpsnr_outputs

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

Definition at line 705 of file vf_xpsnr.c.

◆ ff_vf_xpsnr

const FFFilter ff_vf_xpsnr
Initial value:
= {
.p.name = "xpsnr",
.p.description = NULL_IF_CONFIG_SMALL("Calculate the extended perceptually weighted peak signal-to-noise ratio (XPSNR) between two video streams."),
.p.priv_class = &xpsnr_class,
.preinit = xpsnr_framesync_preinit,
.init = init,
.uninit = uninit,
.activate = activate,
.priv_size = sizeof(XPSNRContext),
}
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#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 const AVFilterPad xpsnr_outputs[]
Definition vf_xpsnr.c:705
static const AVFilterPad xpsnr_inputs[]
Definition vf_xpsnr.c:694
static enum AVPixelFormat xpsnr_formats[]
Definition vf_xpsnr.c:533

Definition at line 713 of file vf_xpsnr.c.