51 #define OFFSET(x) offsetof(PSNRContext, x)
52 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
55 {
"stats_file",
"Set file where to store per-frame difference information",
OFFSET(stats_file_str),
AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0,
FLAGS },
62 static inline int pow2(
int base)
67 static inline double get_psnr(
double mse, uint64_t nb_frames,
int max)
69 return 10.0 * log(
pow2(max) / (mse / nb_frames)) / log(10.0);
74 const uint8_t *ref_data[4],
const int ref_linesizes[4],
85 const uint8_t *main_line = main_data[
c];
86 const uint8_t *ref_line = ref_data[
c];
87 const int ref_linesize = ref_linesizes[
c];
88 const int main_linesize = main_linesizes[
c];
91 for (i = 0; i < outh; i++) {
92 for (j = 0; j < outw; j++)
93 m +=
pow2(main_line[j] - ref_line[j]);
94 ref_line += ref_linesize;
95 main_line += main_linesize;
97 mse[
c] = m / (outw * outh);
104 snprintf(value,
sizeof(value),
"%0.2f", d);
107 snprintf(key2,
sizeof(key2),
"%s%c", key, comp);
118 double comp_mse[4], mse = 0;
138 set_meta(metadata,
"lavfi.psnr.mse.", s->
comps[j], comp_mse[c]);
139 set_meta(metadata,
"lavfi.psnr.mse_avg", 0, mse);
186 static const enum PixelFormat pix_fmts[] = {
230 s->
max[1] = s->
max[2] = 240;
254 outlink->
w = mainlink->
w;
255 outlink->
h = mainlink->
h;
329 .priv_class = &psnr_class,