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)
312 outlink->
w = mainlink->
w;
313 outlink->
h = mainlink->
h;
383 .priv_class = &psnr_class,