FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavfilter/vf_psnr.c
Date: 2024-02-29 09:57:37
Exec Total Coverage
Lines: 156 216 72.2%
Functions: 12 14 85.7%
Branches: 64 124 51.6%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2011 Roger Pau Monné <roger.pau@entel.upc.edu>
3 * Copyright (c) 2011 Stefano Sabatini
4 * Copyright (c) 2013 Paul B Mahol
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 /**
24 * @file
25 * Calculate the PSNR between two input videos.
26 */
27
28 #include "libavutil/avstring.h"
29 #include "libavutil/file_open.h"
30 #include "libavutil/opt.h"
31 #include "libavutil/pixdesc.h"
32 #include "avfilter.h"
33 #include "drawutils.h"
34 #include "framesync.h"
35 #include "internal.h"
36 #include "psnr.h"
37
38 typedef struct PSNRContext {
39 const AVClass *class;
40 FFFrameSync fs;
41 double mse, min_mse, max_mse, mse_comp[4];
42 uint64_t nb_frames;
43 FILE *stats_file;
44 char *stats_file_str;
45 int stats_version;
46 int stats_header_written;
47 int stats_add_max;
48 int max[4], average_max;
49 int is_rgb;
50 uint8_t rgba_map[4];
51 char comps[4];
52 int nb_components;
53 int nb_threads;
54 int planewidth[4];
55 int planeheight[4];
56 double planeweight[4];
57 uint64_t **score;
58 PSNRDSPContext dsp;
59 } PSNRContext;
60
61 #define OFFSET(x) offsetof(PSNRContext, x)
62 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
63
64 static const AVOption psnr_options[] = {
65 {"stats_file", "Set file where to store per-frame difference information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
66 {"f", "Set file where to store per-frame difference information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
67 {"stats_version", "Set the format version for the stats file.", OFFSET(stats_version), AV_OPT_TYPE_INT, {.i64=1}, 1, 2, FLAGS },
68 {"output_max", "Add raw stats (max values) to the output log.", OFFSET(stats_add_max), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
69 { NULL }
70 };
71
72
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
24 FRAMESYNC_DEFINE_CLASS(psnr, PSNRContext, fs);
73
74 1745858 static inline unsigned pow_2(unsigned base)
75 {
76 1745858 return base*base;
77 }
78
79 98 static inline double get_psnr(double mse, uint64_t nb_frames, int max)
80 {
81 98 return 10.0 * log10(pow_2(max) / (mse / nb_frames));
82 }
83
84 7920 static uint64_t sse_line_8bit(const uint8_t *main_line, const uint8_t *ref_line, int outw)
85 {
86 int j;
87 7920 unsigned m2 = 0;
88
89
2/2
✓ Branch 0 taken 1745760 times.
✓ Branch 1 taken 7920 times.
1753680 for (j = 0; j < outw; j++)
90 1745760 m2 += pow_2(main_line[j] - ref_line[j]);
91
92 7920 return m2;
93 }
94
95 static uint64_t sse_line_16bit(const uint8_t *_main_line, const uint8_t *_ref_line, int outw)
96 {
97 int j;
98 uint64_t m2 = 0;
99 const uint16_t *main_line = (const uint16_t *) _main_line;
100 const uint16_t *ref_line = (const uint16_t *) _ref_line;
101
102 for (j = 0; j < outw; j++)
103 m2 += pow_2(main_line[j] - ref_line[j]);
104
105 return m2;
106 }
107
108 typedef struct ThreadData {
109 const uint8_t *main_data[4];
110 const uint8_t *ref_data[4];
111 int main_linesize[4];
112 int ref_linesize[4];
113 int planewidth[4];
114 int planeheight[4];
115 uint64_t **score;
116 int nb_components;
117 PSNRDSPContext *dsp;
118 } ThreadData;
119
120 static
121 126 int compute_images_mse(AVFilterContext *ctx, void *arg,
122 int jobnr, int nb_jobs)
123 {
124 126 ThreadData *td = arg;
125 126 uint64_t *score = td->score[jobnr];
126
127
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 126 times.
531 for (int c = 0; c < td->nb_components; c++) {
128 405 const int outw = td->planewidth[c];
129 405 const int outh = td->planeheight[c];
130 405 const int slice_start = (outh * jobnr) / nb_jobs;
131 405 const int slice_end = (outh * (jobnr+1)) / nb_jobs;
132 405 const int ref_linesize = td->ref_linesize[c];
133 405 const int main_linesize = td->main_linesize[c];
134 405 const uint8_t *main_line = td->main_data[c] + main_linesize * slice_start;
135 405 const uint8_t *ref_line = td->ref_data[c] + ref_linesize * slice_start;
136 405 uint64_t m = 0;
137
2/2
✓ Branch 0 taken 7920 times.
✓ Branch 1 taken 405 times.
8325 for (int i = slice_start; i < slice_end; i++) {
138 7920 m += td->dsp->sse_line(main_line, ref_line, outw);
139 7920 ref_line += ref_linesize;
140 7920 main_line += main_linesize;
141 }
142 405 score[c] = m;
143 }
144
145 126 return 0;
146 }
147
148 118 static void set_meta(AVDictionary **metadata, const char *key, char comp, float d)
149 {
150 char value[128];
151 118 snprintf(value, sizeof(value), "%f", d);
152
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 28 times.
118 if (comp) {
153 char key2[128];
154 90 snprintf(key2, sizeof(key2), "%s%c", key, comp);
155 90 av_dict_set(metadata, key2, value, 0);
156 } else {
157 28 av_dict_set(metadata, key, value, 0);
158 }
159 118 }
160
161 14 static int do_psnr(FFFrameSync *fs)
162 {
163 14 AVFilterContext *ctx = fs->parent;
164 14 PSNRContext *s = ctx->priv;
165 AVFrame *master, *ref;
166 14 double comp_mse[4], mse = 0.;
167 14 uint64_t comp_sum[4] = { 0 };
168 AVDictionary **metadata;
169 ThreadData td;
170 int ret;
171
172 14 ret = ff_framesync_dualinput_get(fs, &master, &ref);
173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (ret < 0)
174 return ret;
175
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if (ctx->is_disabled || !ref)
176 return ff_filter_frame(ctx->outputs[0], master);
177 14 metadata = &master->metadata;
178
179 14 td.nb_components = s->nb_components;
180 14 td.dsp = &s->dsp;
181 14 td.score = s->score;
182
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 for (int c = 0; c < s->nb_components; c++) {
183 45 td.main_data[c] = master->data[c];
184 45 td.ref_data[c] = ref->data[c];
185 45 td.main_linesize[c] = master->linesize[c];
186 45 td.ref_linesize[c] = ref->linesize[c];
187 45 td.planewidth[c] = s->planewidth[c];
188 45 td.planeheight[c] = s->planeheight[c];
189 }
190
191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (master->color_range != ref->color_range) {
192 av_log(ctx, AV_LOG_WARNING, "master and reference "
193 "frames use different color ranges (%s != %s)\n",
194 av_color_range_name(master->color_range),
195 av_color_range_name(ref->color_range));
196 }
197
198 14 ff_filter_execute(ctx, compute_images_mse, &td, NULL,
199 14 FFMIN(s->planeheight[1], s->nb_threads));
200
201
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 14 times.
140 for (int j = 0; j < s->nb_threads; j++) {
202
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 126 times.
531 for (int c = 0; c < s->nb_components; c++)
203 405 comp_sum[c] += s->score[j][c];
204 }
205
206
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 for (int c = 0; c < s->nb_components; c++)
207 45 comp_mse[c] = comp_sum[c] / ((double)s->planewidth[c] * s->planeheight[c]);
208
209
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 for (int c = 0; c < s->nb_components; c++)
210 45 mse += comp_mse[c] * s->planeweight[c];
211
212
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 8 times.
14 s->min_mse = FFMIN(s->min_mse, mse);
213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 s->max_mse = FFMAX(s->max_mse, mse);
214
215 14 s->mse += mse;
216
217
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 for (int j = 0; j < s->nb_components; j++)
218 45 s->mse_comp[j] += comp_mse[j];
219 14 s->nb_frames++;
220
221
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 for (int j = 0; j < s->nb_components; j++) {
222
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 15 times.
45 int c = s->is_rgb ? s->rgba_map[j] : j;
223 45 set_meta(metadata, "lavfi.psnr.mse.", s->comps[j], comp_mse[c]);
224 45 set_meta(metadata, "lavfi.psnr.psnr.", s->comps[j], get_psnr(comp_mse[c], 1, s->max[c]));
225 }
226 14 set_meta(metadata, "lavfi.psnr.mse_avg", 0, mse);
227 14 set_meta(metadata, "lavfi.psnr.psnr_avg", 0, get_psnr(mse, 1, s->average_max));
228
229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (s->stats_file) {
230 if (s->stats_version == 2 && !s->stats_header_written) {
231 fprintf(s->stats_file, "psnr_log_version:2 fields:n");
232 fprintf(s->stats_file, ",mse_avg");
233 for (int j = 0; j < s->nb_components; j++) {
234 fprintf(s->stats_file, ",mse_%c", s->comps[j]);
235 }
236 fprintf(s->stats_file, ",psnr_avg");
237 for (int j = 0; j < s->nb_components; j++) {
238 fprintf(s->stats_file, ",psnr_%c", s->comps[j]);
239 }
240 if (s->stats_add_max) {
241 fprintf(s->stats_file, ",max_avg");
242 for (int j = 0; j < s->nb_components; j++) {
243 fprintf(s->stats_file, ",max_%c", s->comps[j]);
244 }
245 }
246 fprintf(s->stats_file, "\n");
247 s->stats_header_written = 1;
248 }
249 fprintf(s->stats_file, "n:%"PRId64" mse_avg:%0.2f ", s->nb_frames, mse);
250 for (int j = 0; j < s->nb_components; j++) {
251 int c = s->is_rgb ? s->rgba_map[j] : j;
252 fprintf(s->stats_file, "mse_%c:%0.2f ", s->comps[j], comp_mse[c]);
253 }
254 fprintf(s->stats_file, "psnr_avg:%0.2f ", get_psnr(mse, 1, s->average_max));
255 for (int j = 0; j < s->nb_components; j++) {
256 int c = s->is_rgb ? s->rgba_map[j] : j;
257 fprintf(s->stats_file, "psnr_%c:%0.2f ", s->comps[j],
258 get_psnr(comp_mse[c], 1, s->max[c]));
259 }
260 if (s->stats_version == 2 && s->stats_add_max) {
261 fprintf(s->stats_file, "max_avg:%d ", s->average_max);
262 for (int j = 0; j < s->nb_components; j++) {
263 int c = s->is_rgb ? s->rgba_map[j] : j;
264 fprintf(s->stats_file, "max_%c:%d ", s->comps[j], s->max[c]);
265 }
266 }
267 fprintf(s->stats_file, "\n");
268 }
269
270 14 return ff_filter_frame(ctx->outputs[0], master);
271 }
272
273 12 static av_cold int init(AVFilterContext *ctx)
274 {
275 12 PSNRContext *s = ctx->priv;
276
277 12 s->min_mse = +INFINITY;
278 12 s->max_mse = -INFINITY;
279
280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (s->stats_file_str) {
281 if (s->stats_version < 2 && s->stats_add_max) {
282 av_log(ctx, AV_LOG_ERROR,
283 "stats_add_max was specified but stats_version < 2.\n" );
284 return AVERROR(EINVAL);
285 }
286 if (!strcmp(s->stats_file_str, "-")) {
287 s->stats_file = stdout;
288 } else {
289 s->stats_file = avpriv_fopen_utf8(s->stats_file_str, "w");
290 if (!s->stats_file) {
291 int err = AVERROR(errno);
292 char buf[128];
293 av_strerror(err, buf, sizeof(buf));
294 av_log(ctx, AV_LOG_ERROR, "Could not open stats file %s: %s\n",
295 s->stats_file_str, buf);
296 return err;
297 }
298 }
299 }
300
301 12 s->fs.on_event = do_psnr;
302 12 return 0;
303 }
304
305 static const enum AVPixelFormat pix_fmts[] = {
306 AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16,
307 #define PF_NOALPHA(suf) AV_PIX_FMT_YUV420##suf, AV_PIX_FMT_YUV422##suf, AV_PIX_FMT_YUV444##suf
308 #define PF_ALPHA(suf) AV_PIX_FMT_YUVA420##suf, AV_PIX_FMT_YUVA422##suf, AV_PIX_FMT_YUVA444##suf
309 #define PF(suf) PF_NOALPHA(suf), PF_ALPHA(suf)
310 PF(P), PF(P9), PF(P10), PF_NOALPHA(P12), PF_NOALPHA(P14), PF(P16),
311 AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P,
312 AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
313 AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P,
314 AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
315 AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
316 AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16,
317 AV_PIX_FMT_NONE
318 };
319
320 6 static int config_input_ref(AVFilterLink *inlink)
321 {
322 6 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
323 6 AVFilterContext *ctx = inlink->dst;
324 6 PSNRContext *s = ctx->priv;
325 double average_max;
326 unsigned sum;
327 int j;
328
329 6 s->nb_threads = ff_filter_get_nb_threads(ctx);
330 6 s->nb_components = desc->nb_components;
331
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (ctx->inputs[0]->w != ctx->inputs[1]->w ||
332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 ctx->inputs[0]->h != ctx->inputs[1]->h) {
333 av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n");
334 return AVERROR(EINVAL);
335 }
336
337 6 s->max[0] = (1 << desc->comp[0].depth) - 1;
338 6 s->max[1] = (1 << desc->comp[1].depth) - 1;
339 6 s->max[2] = (1 << desc->comp[2].depth) - 1;
340 6 s->max[3] = (1 << desc->comp[3].depth) - 1;
341
342 6 s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0;
343
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 s->comps[0] = s->is_rgb ? 'r' : 'y' ;
344
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 s->comps[1] = s->is_rgb ? 'g' : 'u' ;
345
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 s->comps[2] = s->is_rgb ? 'b' : 'v' ;
346 6 s->comps[3] = 'a';
347
348 6 s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
349 6 s->planeheight[0] = s->planeheight[3] = inlink->h;
350 6 s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
351 6 s->planewidth[0] = s->planewidth[3] = inlink->w;
352 6 sum = 0;
353
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 6 times.
27 for (j = 0; j < s->nb_components; j++)
354 21 sum += s->planeheight[j] * s->planewidth[j];
355 6 average_max = 0;
356
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 6 times.
27 for (j = 0; j < s->nb_components; j++) {
357 21 s->planeweight[j] = (double) s->planeheight[j] * s->planewidth[j] / sum;
358 21 average_max += s->max[j] * s->planeweight[j];
359 }
360 6 s->average_max = lrint(average_max);
361
362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 s->dsp.sse_line = desc->comp[0].depth > 8 ? sse_line_16bit : sse_line_8bit;
363 #if ARCH_X86
364 6 ff_psnr_init_x86(&s->dsp, desc->comp[0].depth);
365 #endif
366
367 6 s->score = av_calloc(s->nb_threads, sizeof(*s->score));
368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (!s->score)
369 return AVERROR(ENOMEM);
370
371
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 6 times.
60 for (int t = 0; t < s->nb_threads; t++) {
372 54 s->score[t] = av_calloc(s->nb_components, sizeof(*s->score[0]));
373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if (!s->score[t])
374 return AVERROR(ENOMEM);
375 }
376
377 6 return 0;
378 }
379
380 6 static int config_output(AVFilterLink *outlink)
381 {
382 6 AVFilterContext *ctx = outlink->src;
383 6 PSNRContext *s = ctx->priv;
384 6 AVFilterLink *mainlink = ctx->inputs[0];
385 int ret;
386
387 6 ret = ff_framesync_init_dualinput(&s->fs, ctx);
388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (ret < 0)
389 return ret;
390 6 outlink->w = mainlink->w;
391 6 outlink->h = mainlink->h;
392 6 outlink->time_base = mainlink->time_base;
393 6 outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio;
394 6 outlink->frame_rate = mainlink->frame_rate;
395
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
6 if ((ret = ff_framesync_configure(&s->fs)) < 0)
396 return ret;
397
398 6 outlink->time_base = s->fs.time_base;
399
400
2/4
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
12 if (av_cmp_q(mainlink->time_base, outlink->time_base) ||
401 6 av_cmp_q(ctx->inputs[1]->time_base, outlink->time_base))
402 av_log(ctx, AV_LOG_WARNING, "not matching timebases found between first input: %d/%d and second input %d/%d, results may be incorrect!\n",
403 mainlink->time_base.num, mainlink->time_base.den,
404 ctx->inputs[1]->time_base.num, ctx->inputs[1]->time_base.den);
405
406 6 return 0;
407 }
408
409 57 static int activate(AVFilterContext *ctx)
410 {
411 57 PSNRContext *s = ctx->priv;
412 57 return ff_framesync_activate(&s->fs);
413 }
414
415 12 static av_cold void uninit(AVFilterContext *ctx)
416 {
417 12 PSNRContext *s = ctx->priv;
418
419
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if (s->nb_frames > 0) {
420 int j;
421 char buf[256];
422
423 6 buf[0] = 0;
424
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 6 times.
27 for (j = 0; j < s->nb_components; j++) {
425
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 3 times.
21 int c = s->is_rgb ? s->rgba_map[j] : j;
426 21 av_strlcatf(buf, sizeof(buf), " %c:%f", s->comps[j],
427 get_psnr(s->mse_comp[c], s->nb_frames, s->max[c]));
428 }
429 6 av_log(ctx, AV_LOG_INFO, "PSNR%s average:%f min:%f max:%f\n",
430 buf,
431 get_psnr(s->mse, s->nb_frames, s->average_max),
432 get_psnr(s->max_mse, 1, s->average_max),
433 get_psnr(s->min_mse, 1, s->average_max));
434 }
435
436 12 ff_framesync_uninit(&s->fs);
437
3/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
66 for (int t = 0; t < s->nb_threads && s->score; t++)
438 54 av_freep(&s->score[t]);
439 12 av_freep(&s->score);
440
441
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if (s->stats_file && s->stats_file != stdout)
442 fclose(s->stats_file);
443 12 }
444
445 static const AVFilterPad psnr_inputs[] = {
446 {
447 .name = "main",
448 .type = AVMEDIA_TYPE_VIDEO,
449 },{
450 .name = "reference",
451 .type = AVMEDIA_TYPE_VIDEO,
452 .config_props = config_input_ref,
453 },
454 };
455
456 static const AVFilterPad psnr_outputs[] = {
457 {
458 .name = "default",
459 .type = AVMEDIA_TYPE_VIDEO,
460 .config_props = config_output,
461 },
462 };
463
464 const AVFilter ff_vf_psnr = {
465 .name = "psnr",
466 .description = NULL_IF_CONFIG_SMALL("Calculate the PSNR between two video streams."),
467 .preinit = psnr_framesync_preinit,
468 .init = init,
469 .uninit = uninit,
470 .activate = activate,
471 .priv_size = sizeof(PSNRContext),
472 .priv_class = &psnr_class,
473 FILTER_INPUTS(psnr_inputs),
474 FILTER_OUTPUTS(psnr_outputs),
475 FILTER_PIXFMTS_ARRAY(pix_fmts),
476 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL |
477 AVFILTER_FLAG_SLICE_THREADS |
478 AVFILTER_FLAG_METADATA_ONLY,
479 };
480