53 const uint8_t *
m[4],
const int ml[4],
54 const uint8_t *
r[4],
const int rl[4],
55 int w,
int h,
double mse[4]);
58 #define OFFSET(x) offsetof(PSNRContext, x)
59 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
69 static inline unsigned pow2(
unsigned base)
76 return 10.0 * log(
pow2(max) / (mse / nb_frames)) / log(10.0);
81 const uint8_t *main_data[4],
const int main_linesizes[4],
82 const uint8_t *ref_data[4],
const int ref_linesizes[4],
83 int w,
int h,
double mse[4])
90 const uint8_t *main_line = main_data[
c];
91 const uint8_t *ref_line = ref_data[
c];
92 const int ref_linesize = ref_linesizes[
c];
93 const int main_linesize = main_linesizes[
c];
96 for (i = 0; i < outh; i++) {
98 for (j = 0; j < outw; j++)
99 m2 +=
pow2(main_line[j] - ref_line[j]);
101 ref_line += ref_linesize;
102 main_line += main_linesize;
104 mse[
c] = m / (double)(outw * outh);
110 const uint8_t *main_data[4],
const int main_linesizes[4],
111 const uint8_t *ref_data[4],
const int ref_linesizes[4],
112 int w,
int h,
double mse[4])
119 const uint16_t *main_line = (uint16_t *)main_data[c];
120 const uint16_t *ref_line = (uint16_t *)ref_data[c];
121 const int ref_linesize = ref_linesizes[
c] / 2;
122 const int main_linesize = main_linesizes[
c] / 2;
125 for (i = 0; i < outh; i++) {
126 for (j = 0; j < outw; j++)
127 m +=
pow2(main_line[j] - ref_line[j]);
128 ref_line += ref_linesize;
129 main_line += main_linesize;
131 mse[
c] = m / (double)(outw * outh);
138 snprintf(value,
sizeof(value),
"%0.2f", d);
141 snprintf(key2,
sizeof(key2),
"%s%c", key, comp);
152 double comp_mse[4],
mse = 0;
172 set_meta(metadata,
"lavfi.psnr.mse.", s->
comps[j], comp_mse[c]);
173 set_meta(metadata,
"lavfi.psnr.mse_avg", 0, mse);
222 #define PF_NOALPHA(suf) AV_PIX_FMT_YUV420##suf, AV_PIX_FMT_YUV422##suf, AV_PIX_FMT_YUV444##suf
223 #define PF_ALPHA(suf) AV_PIX_FMT_YUVA420##suf, AV_PIX_FMT_YUVA422##suf, AV_PIX_FMT_YUVA444##suf
224 #define PF(suf) PF_NOALPHA(suf), PF_ALPHA(suf)
314 outlink->
w = mainlink->
w;
315 outlink->
h = mainlink->
h;
385 .priv_class = &psnr_class,
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
static const AVFilterPad outputs[]
Main libavfilter public API header.
int h
agreed upon image height
static AVFrame * do_psnr(AVFilterContext *ctx, AVFrame *main, const AVFrame *ref)
#define AV_PIX_FMT_GBRP10
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
static int request_frame(AVFilterLink *outlink)
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
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 double psnr(double d)
static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
A filter pad used for either input or output.
A link between two filters.
uint16_t depth_minus1
Number of bits in the component minus 1.
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown; if left to 0/0, will be automatically be cop...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int config_input_ref(AVFilterLink *inlink)
void * priv
private data for use by the filter
FFDualInputContext dinput
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
static av_cold void uninit(AVFilterContext *ctx)
#define AV_PIX_FMT_GBRAP16
int w
agreed upon image width
uint8_t nb_components
The number of components each pixel has, (1-4)
#define AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GRAY16
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
static void set_meta(AVDictionary **metadata, const char *key, char comp, float d)
GLsizei GLboolean const GLfloat * value
#define FF_CEIL_RSHIFT(a, b)
static int config_output(AVFilterLink *outlink)
static av_cold int init(AVFilterContext *ctx)
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])
AVFilterContext * src
source filter
AVFrame *(* process)(AVFilterContext *ctx, AVFrame *main, const AVFrame *second)
static unsigned pow2(unsigned base)
#define AV_PIX_FMT_GBRP14
int format
agreed upon media format
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
#define AV_LOG_INFO
Standard information.
AVDictionary ** avpriv_frame_get_metadatap(AVFrame *frame)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
const char * name
Filter name.
void(* compute_mse)(struct PSNRContext *s, const uint8_t *m[4], const int ml[4], const uint8_t *r[4], const int rl[4], int w, int h, double mse[4])
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
#define AV_PIX_FMT_GBRP12
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
static const AVFilterPad psnr_inputs[]
planar GBRA 4:4:4:4 32bpp
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
static const AVFilterPad psnr_outputs[]
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static const AVOption psnr_options[]
static int query_formats(AVFilterContext *ctx)
AVFilterContext * dst
dest filter
AVFILTER_DEFINE_CLASS(psnr)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
int main(int argc, char **argv)
AVPixelFormat
Pixel format.