FFmpeg  4.4
vf_psnr.c
Go to the documentation of this file.
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  * Caculate the PSNR between two input videos.
26  */
27 
28 #include "libavutil/avstring.h"
29 #include "libavutil/opt.h"
30 #include "libavutil/pixdesc.h"
31 #include "avfilter.h"
32 #include "drawutils.h"
33 #include "formats.h"
34 #include "framesync.h"
35 #include "internal.h"
36 #include "psnr.h"
37 #include "video.h"
38 
39 typedef struct PSNRContext {
40  const AVClass *class;
42  double mse, min_mse, max_mse, mse_comp[4];
43  uint64_t nb_frames;
44  FILE *stats_file;
49  int max[4], average_max;
50  int is_rgb;
52  char comps[4];
55  int planewidth[4];
56  int planeheight[4];
57  double planeweight[4];
58  uint64_t **score;
60 } PSNRContext;
61 
62 #define OFFSET(x) offsetof(PSNRContext, x)
63 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
64 
65 static const AVOption psnr_options[] = {
66  {"stats_file", "Set file where to store per-frame difference information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
67  {"f", "Set file where to store per-frame difference information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
68  {"stats_version", "Set the format version for the stats file.", OFFSET(stats_version), AV_OPT_TYPE_INT, {.i64=1}, 1, 2, FLAGS },
69  {"output_max", "Add raw stats (max values) to the output log.", OFFSET(stats_add_max), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
70  { NULL }
71 };
72 
74 
75 static inline unsigned pow_2(unsigned base)
76 {
77  return base*base;
78 }
79 
80 static inline double get_psnr(double mse, uint64_t nb_frames, int max)
81 {
82  return 10.0 * log10(pow_2(max) / (mse / nb_frames));
83 }
84 
85 static uint64_t sse_line_8bit(const uint8_t *main_line, const uint8_t *ref_line, int outw)
86 {
87  int j;
88  unsigned m2 = 0;
89 
90  for (j = 0; j < outw; j++)
91  m2 += pow_2(main_line[j] - ref_line[j]);
92 
93  return m2;
94 }
95 
96 static uint64_t sse_line_16bit(const uint8_t *_main_line, const uint8_t *_ref_line, int outw)
97 {
98  int j;
99  uint64_t m2 = 0;
100  const uint16_t *main_line = (const uint16_t *) _main_line;
101  const uint16_t *ref_line = (const uint16_t *) _ref_line;
102 
103  for (j = 0; j < outw; j++)
104  m2 += pow_2(main_line[j] - ref_line[j]);
105 
106  return m2;
107 }
108 
109 typedef struct ThreadData {
110  const uint8_t *main_data[4];
111  const uint8_t *ref_data[4];
112  int main_linesize[4];
113  int ref_linesize[4];
114  int planewidth[4];
115  int planeheight[4];
116  uint64_t **score;
117  int nb_components;
119 } ThreadData;
120 
121 static
123  int jobnr, int nb_jobs)
124 {
125  ThreadData *td = arg;
126  uint64_t *score = td->score[jobnr];
127 
128  for (int c = 0; c < td->nb_components; c++) {
129  const int outw = td->planewidth[c];
130  const int outh = td->planeheight[c];
131  const int slice_start = (outh * jobnr) / nb_jobs;
132  const int slice_end = (outh * (jobnr+1)) / nb_jobs;
133  const int ref_linesize = td->ref_linesize[c];
134  const int main_linesize = td->main_linesize[c];
135  const uint8_t *main_line = td->main_data[c] + main_linesize * slice_start;
136  const uint8_t *ref_line = td->ref_data[c] + ref_linesize * slice_start;
137  uint64_t m = 0;
138  for (int i = slice_start; i < slice_end; i++) {
139  m += td->dsp->sse_line(main_line, ref_line, outw);
140  ref_line += ref_linesize;
141  main_line += main_linesize;
142  }
143  score[c] = m;
144  }
145 
146  return 0;
147 }
148 
149 static void set_meta(AVDictionary **metadata, const char *key, char comp, float d)
150 {
151  char value[128];
152  snprintf(value, sizeof(value), "%f", d);
153  if (comp) {
154  char key2[128];
155  snprintf(key2, sizeof(key2), "%s%c", key, comp);
156  av_dict_set(metadata, key2, value, 0);
157  } else {
158  av_dict_set(metadata, key, value, 0);
159  }
160 }
161 
162 static int do_psnr(FFFrameSync *fs)
163 {
164  AVFilterContext *ctx = fs->parent;
165  PSNRContext *s = ctx->priv;
166  AVFrame *master, *ref;
167  double comp_mse[4], mse = 0.;
168  uint64_t comp_sum[4] = { 0 };
169  AVDictionary **metadata;
170  ThreadData td;
171  int ret;
172 
174  if (ret < 0)
175  return ret;
176  if (ctx->is_disabled || !ref)
177  return ff_filter_frame(ctx->outputs[0], master);
178  metadata = &master->metadata;
179 
180  td.nb_components = s->nb_components;
181  td.dsp = &s->dsp;
182  td.score = s->score;
183  for (int c = 0; c < s->nb_components; c++) {
184  td.main_data[c] = master->data[c];
185  td.ref_data[c] = ref->data[c];
186  td.main_linesize[c] = master->linesize[c];
187  td.ref_linesize[c] = ref->linesize[c];
188  td.planewidth[c] = s->planewidth[c];
189  td.planeheight[c] = s->planeheight[c];
190  }
191 
192  ctx->internal->execute(ctx, compute_images_mse, &td, NULL, FFMIN(s->planeheight[1], s->nb_threads));
193 
194  for (int j = 0; j < s->nb_threads; j++) {
195  for (int c = 0; c < s->nb_components; c++)
196  comp_sum[c] += s->score[j][c];
197  }
198 
199  for (int c = 0; c < s->nb_components; c++)
200  comp_mse[c] = comp_sum[c] / ((double)s->planewidth[c] * s->planeheight[c]);
201 
202  for (int c = 0; c < s->nb_components; c++)
203  mse += comp_mse[c] * s->planeweight[c];
204 
205  s->min_mse = FFMIN(s->min_mse, mse);
206  s->max_mse = FFMAX(s->max_mse, mse);
207 
208  s->mse += mse;
209 
210  for (int j = 0; j < s->nb_components; j++)
211  s->mse_comp[j] += comp_mse[j];
212  s->nb_frames++;
213 
214  for (int j = 0; j < s->nb_components; j++) {
215  int c = s->is_rgb ? s->rgba_map[j] : j;
216  set_meta(metadata, "lavfi.psnr.mse.", s->comps[j], comp_mse[c]);
217  set_meta(metadata, "lavfi.psnr.psnr.", s->comps[j], get_psnr(comp_mse[c], 1, s->max[c]));
218  }
219  set_meta(metadata, "lavfi.psnr.mse_avg", 0, mse);
220  set_meta(metadata, "lavfi.psnr.psnr_avg", 0, get_psnr(mse, 1, s->average_max));
221 
222  if (s->stats_file) {
223  if (s->stats_version == 2 && !s->stats_header_written) {
224  fprintf(s->stats_file, "psnr_log_version:2 fields:n");
225  fprintf(s->stats_file, ",mse_avg");
226  for (int j = 0; j < s->nb_components; j++) {
227  fprintf(s->stats_file, ",mse_%c", s->comps[j]);
228  }
229  fprintf(s->stats_file, ",psnr_avg");
230  for (int j = 0; j < s->nb_components; j++) {
231  fprintf(s->stats_file, ",psnr_%c", s->comps[j]);
232  }
233  if (s->stats_add_max) {
234  fprintf(s->stats_file, ",max_avg");
235  for (int j = 0; j < s->nb_components; j++) {
236  fprintf(s->stats_file, ",max_%c", s->comps[j]);
237  }
238  }
239  fprintf(s->stats_file, "\n");
240  s->stats_header_written = 1;
241  }
242  fprintf(s->stats_file, "n:%"PRId64" mse_avg:%0.2f ", s->nb_frames, mse);
243  for (int j = 0; j < s->nb_components; j++) {
244  int c = s->is_rgb ? s->rgba_map[j] : j;
245  fprintf(s->stats_file, "mse_%c:%0.2f ", s->comps[j], comp_mse[c]);
246  }
247  fprintf(s->stats_file, "psnr_avg:%0.2f ", get_psnr(mse, 1, s->average_max));
248  for (int j = 0; j < s->nb_components; j++) {
249  int c = s->is_rgb ? s->rgba_map[j] : j;
250  fprintf(s->stats_file, "psnr_%c:%0.2f ", s->comps[j],
251  get_psnr(comp_mse[c], 1, s->max[c]));
252  }
253  if (s->stats_version == 2 && s->stats_add_max) {
254  fprintf(s->stats_file, "max_avg:%d ", 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, "max_%c:%d ", s->comps[j], s->max[c]);
258  }
259  }
260  fprintf(s->stats_file, "\n");
261  }
262 
263  return ff_filter_frame(ctx->outputs[0], master);
264 }
265 
267 {
268  PSNRContext *s = ctx->priv;
269 
270  s->min_mse = +INFINITY;
271  s->max_mse = -INFINITY;
272 
273  if (s->stats_file_str) {
274  if (s->stats_version < 2 && s->stats_add_max) {
276  "stats_add_max was specified but stats_version < 2.\n" );
277  return AVERROR(EINVAL);
278  }
279  if (!strcmp(s->stats_file_str, "-")) {
280  s->stats_file = stdout;
281  } else {
282  s->stats_file = fopen(s->stats_file_str, "w");
283  if (!s->stats_file) {
284  int err = AVERROR(errno);
285  char buf[128];
286  av_strerror(err, buf, sizeof(buf));
287  av_log(ctx, AV_LOG_ERROR, "Could not open stats file %s: %s\n",
288  s->stats_file_str, buf);
289  return err;
290  }
291  }
292  }
293 
294  s->fs.on_event = do_psnr;
295  return 0;
296 }
297 
299 {
300  static const enum AVPixelFormat pix_fmts[] = {
302 #define PF_NOALPHA(suf) AV_PIX_FMT_YUV420##suf, AV_PIX_FMT_YUV422##suf, AV_PIX_FMT_YUV444##suf
303 #define PF_ALPHA(suf) AV_PIX_FMT_YUVA420##suf, AV_PIX_FMT_YUVA422##suf, AV_PIX_FMT_YUVA444##suf
304 #define PF(suf) PF_NOALPHA(suf), PF_ALPHA(suf)
305  PF(P), PF(P9), PF(P10), PF_NOALPHA(P12), PF_NOALPHA(P14), PF(P16),
313  };
314 
316  if (!fmts_list)
317  return AVERROR(ENOMEM);
318  return ff_set_common_formats(ctx, fmts_list);
319 }
320 
321 static int config_input_ref(AVFilterLink *inlink)
322 {
324  AVFilterContext *ctx = inlink->dst;
325  PSNRContext *s = ctx->priv;
326  double average_max;
327  unsigned sum;
328  int j;
329 
330  s->nb_threads = ff_filter_get_nb_threads(ctx);
331  s->nb_components = desc->nb_components;
332  if (ctx->inputs[0]->w != ctx->inputs[1]->w ||
333  ctx->inputs[0]->h != ctx->inputs[1]->h) {
334  av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n");
335  return AVERROR(EINVAL);
336  }
337  if (ctx->inputs[0]->format != ctx->inputs[1]->format) {
338  av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n");
339  return AVERROR(EINVAL);
340  }
341 
342  s->max[0] = (1 << desc->comp[0].depth) - 1;
343  s->max[1] = (1 << desc->comp[1].depth) - 1;
344  s->max[2] = (1 << desc->comp[2].depth) - 1;
345  s->max[3] = (1 << desc->comp[3].depth) - 1;
346 
347  s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0;
348  s->comps[0] = s->is_rgb ? 'r' : 'y' ;
349  s->comps[1] = s->is_rgb ? 'g' : 'u' ;
350  s->comps[2] = s->is_rgb ? 'b' : 'v' ;
351  s->comps[3] = 'a';
352 
353  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
354  s->planeheight[0] = s->planeheight[3] = inlink->h;
355  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
356  s->planewidth[0] = s->planewidth[3] = inlink->w;
357  sum = 0;
358  for (j = 0; j < s->nb_components; j++)
359  sum += s->planeheight[j] * s->planewidth[j];
360  average_max = 0;
361  for (j = 0; j < s->nb_components; j++) {
362  s->planeweight[j] = (double) s->planeheight[j] * s->planewidth[j] / sum;
363  average_max += s->max[j] * s->planeweight[j];
364  }
365  s->average_max = lrint(average_max);
366 
367  s->dsp.sse_line = desc->comp[0].depth > 8 ? sse_line_16bit : sse_line_8bit;
368  if (ARCH_X86)
369  ff_psnr_init_x86(&s->dsp, desc->comp[0].depth);
370 
371  s->score = av_calloc(s->nb_threads, sizeof(*s->score));
372  if (!s->score)
373  return AVERROR(ENOMEM);
374 
375  for (int t = 0; t < s->nb_threads && s->score; t++) {
376  s->score[t] = av_calloc(s->nb_components, sizeof(*s->score[0]));
377  if (!s->score[t])
378  return AVERROR(ENOMEM);
379  }
380 
381  return 0;
382 }
383 
384 static int config_output(AVFilterLink *outlink)
385 {
386  AVFilterContext *ctx = outlink->src;
387  PSNRContext *s = ctx->priv;
388  AVFilterLink *mainlink = ctx->inputs[0];
389  int ret;
390 
391  ret = ff_framesync_init_dualinput(&s->fs, ctx);
392  if (ret < 0)
393  return ret;
394  outlink->w = mainlink->w;
395  outlink->h = mainlink->h;
396  outlink->time_base = mainlink->time_base;
397  outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio;
398  outlink->frame_rate = mainlink->frame_rate;
399  if ((ret = ff_framesync_configure(&s->fs)) < 0)
400  return ret;
401 
402  outlink->time_base = s->fs.time_base;
403 
404  if (av_cmp_q(mainlink->time_base, outlink->time_base) ||
405  av_cmp_q(ctx->inputs[1]->time_base, outlink->time_base))
406  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",
407  mainlink->time_base.num, mainlink->time_base.den,
408  ctx->inputs[1]->time_base.num, ctx->inputs[1]->time_base.den);
409 
410  return 0;
411 }
412 
414 {
415  PSNRContext *s = ctx->priv;
416  return ff_framesync_activate(&s->fs);
417 }
418 
420 {
421  PSNRContext *s = ctx->priv;
422 
423  if (s->nb_frames > 0) {
424  int j;
425  char buf[256];
426 
427  buf[0] = 0;
428  for (j = 0; j < s->nb_components; j++) {
429  int c = s->is_rgb ? s->rgba_map[j] : j;
430  av_strlcatf(buf, sizeof(buf), " %c:%f", s->comps[j],
431  get_psnr(s->mse_comp[c], s->nb_frames, s->max[c]));
432  }
433  av_log(ctx, AV_LOG_INFO, "PSNR%s average:%f min:%f max:%f\n",
434  buf,
435  get_psnr(s->mse, s->nb_frames, s->average_max),
436  get_psnr(s->max_mse, 1, s->average_max),
437  get_psnr(s->min_mse, 1, s->average_max));
438  }
439 
440  ff_framesync_uninit(&s->fs);
441  for (int t = 0; t < s->nb_threads && s->score; t++)
442  av_freep(&s->score[t]);
443  av_freep(&s->score);
444 
445  if (s->stats_file && s->stats_file != stdout)
446  fclose(s->stats_file);
447 }
448 
449 static const AVFilterPad psnr_inputs[] = {
450  {
451  .name = "main",
452  .type = AVMEDIA_TYPE_VIDEO,
453  },{
454  .name = "reference",
455  .type = AVMEDIA_TYPE_VIDEO,
456  .config_props = config_input_ref,
457  },
458  { NULL }
459 };
460 
461 static const AVFilterPad psnr_outputs[] = {
462  {
463  .name = "default",
464  .type = AVMEDIA_TYPE_VIDEO,
465  .config_props = config_output,
466  },
467  { NULL }
468 };
469 
471  .name = "psnr",
472  .description = NULL_IF_CONFIG_SMALL("Calculate the PSNR between two video streams."),
473  .preinit = psnr_framesync_preinit,
474  .init = init,
475  .uninit = uninit,
476  .query_formats = query_formats,
477  .activate = activate,
478  .priv_size = sizeof(PSNRContext),
479  .priv_class = &psnr_class,
480  .inputs = psnr_inputs,
483 };
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
#define av_cold
Definition: attributes.h:88
uint8_t
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1094
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:802
Main libavfilter public API header.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
Definition: avstring.c:101
#define flags(name, subs,...)
Definition: cbs_av1.c:561
#define s(width, name)
Definition: cbs_vp9.c:257
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:259
#define FFMIN(a, b)
Definition: common.h:105
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
#define FFMAX(a, b)
Definition: common.h:103
#define ARCH_X86
Definition: config.h:39
#define NULL
Definition: coverity.c:32
#define max(a, b)
Definition: cuda_runtime.h:33
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
Definition: drawutils.c:35
misc drawing utilities
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
Definition: eamad.c:85
double value
Definition: eval.c:98
static double psnr(double d)
Definition: ffmpeg.c:1435
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:587
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:286
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:124
int ff_framesync_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
Definition: framesync.c:376
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
Definition: framesync.c:341
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
Definition: framesync.c:358
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:290
@ AV_OPT_TYPE_INT
Definition: opt.h:225
@ AV_OPT_TYPE_BOOL
Definition: opt.h:242
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
#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:134
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:70
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
Definition: error.c:105
#define AVERROR(e)
Definition: error.h:43
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:200
#define AV_LOG_INFO
Standard information.
Definition: log.h:205
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
Definition: rational.h:89
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:245
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
for(j=16;j >0;--j)
const char * key
int i
Definition: input.c:407
const char * arg
Definition: jacosubdec.c:66
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:303
const char * desc
Definition: libsvtav1.c:79
#define INFINITY
Definition: mathematics.h:67
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2033
#define P
AVOptions.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2573
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:420
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:379
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:421
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:414
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:415
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:381
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:416
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
@ 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:100
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
@ 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:258
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
@ 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:79
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
@ 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:80
@ 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:78
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:380
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:382
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:383
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:419
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:418
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:417
void ff_psnr_init_x86(PSNRDSPContext *dsp, int bpp)
Definition: vf_psnr_init.c:28
#define td
Definition: regdef.h:70
#define snprintf
Definition: snprintf.h:34
Describe the class of an AVClass context structure.
Definition: log.h:67
An instance of a filter.
Definition: avfilter.h:341
A list of supported formats for one end of a filter link.
Definition: formats.h:65
A filter pad used for either input or output.
Definition: internal.h:54
const char * name
Pad name.
Definition: internal.h:60
Filter definition.
Definition: avfilter.h:145
const char * name
Filter name.
Definition: avfilter.h:149
AVFormatInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1699
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
AVOption.
Definition: opt.h:248
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
int num
Numerator.
Definition: rational.h:59
int den
Denominator.
Definition: rational.h:60
Frame sync structure.
Definition: framesync.h:146
int nb_threads
Definition: vf_psnr.c:54
FILE * stats_file
Definition: vf_psnr.c:44
uint64_t nb_frames
Definition: vf_psnr.c:43
int stats_version
Definition: vf_psnr.c:46
int max[4]
Definition: vf_psnr.c:49
uint8_t rgba_map[4]
Definition: vf_psnr.c:51
char comps[4]
Definition: vf_psnr.c:52
double min_mse
Definition: vf_psnr.c:42
int planeheight[4]
Definition: vf_psnr.c:56
int planewidth[4]
Definition: vf_psnr.c:55
int stats_add_max
Definition: vf_psnr.c:48
PSNRDSPContext dsp
Definition: vf_psnr.c:59
int stats_header_written
Definition: vf_psnr.c:47
int average_max
Definition: vf_psnr.c:49
double planeweight[4]
Definition: vf_psnr.c:57
int nb_components
Definition: vf_psnr.c:53
int is_rgb
Definition: vf_psnr.c:50
double max_mse
Definition: vf_psnr.c:42
double mse_comp[4]
Definition: vf_psnr.c:42
FFFrameSync fs
Definition: vf_psnr.c:41
uint64_t ** score
Definition: vf_psnr.c:58
double mse
Definition: vf_psnr.c:42
char * stats_file_str
Definition: vf_psnr.c:45
Used for passing data between threads.
Definition: dsddec.c:67
int nb_components
Definition: vf_identity.c:91
int planeheight[4]
Definition: vf_identity.c:89
uint64_t ** score
Definition: vf_identity.c:90
const uint8_t * ref_data[4]
Definition: vf_identity.c:85
int main_linesize[4]
Definition: vf_identity.c:86
int planewidth[4]
Definition: vf_identity.c:88
PSNRDSPContext * dsp
Definition: vf_psnr.c:118
const uint8_t * main_data[4]
Definition: vf_identity.c:84
int ref_linesize
Definition: vf_bm3d.c:59
#define lrint
Definition: tablegen.h:53
#define av_freep(p)
#define av_log(a,...)
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:107
AVFormatContext * ctx
Definition: movenc.c:48
const char * master
Definition: vf_curves.c:119
AVFilter ff_vf_psnr
Definition: vf_psnr.c:470
static const AVOption psnr_options[]
Definition: vf_psnr.c:65
static unsigned pow_2(unsigned base)
Definition: vf_psnr.c:75
#define PF_NOALPHA(suf)
static int compute_images_mse(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_psnr.c:122
FRAMESYNC_DEFINE_CLASS(psnr, PSNRContext, fs)
static int query_formats(AVFilterContext *ctx)
Definition: vf_psnr.c:298
static uint64_t sse_line_8bit(const uint8_t *main_line, const uint8_t *ref_line, int outw)
Definition: vf_psnr.c:85
static const AVFilterPad psnr_outputs[]
Definition: vf_psnr.c:461
#define FLAGS
Definition: vf_psnr.c:63
static int config_input_ref(AVFilterLink *inlink)
Definition: vf_psnr.c:321
static void set_meta(AVDictionary **metadata, const char *key, char comp, float d)
Definition: vf_psnr.c:149
#define PF(suf)
static double get_psnr(double mse, uint64_t nb_frames, int max)
Definition: vf_psnr.c:80
static const AVFilterPad psnr_inputs[]
Definition: vf_psnr.c:449
static int activate(AVFilterContext *ctx)
Definition: vf_psnr.c:413
static av_cold int init(AVFilterContext *ctx)
Definition: vf_psnr.c:266
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_psnr.c:419
#define OFFSET(x)
Definition: vf_psnr.c:62
static int config_output(AVFilterLink *outlink)
Definition: vf_psnr.c:384
static uint64_t sse_line_16bit(const uint8_t *_main_line, const uint8_t *_ref_line, int outw)
Definition: vf_psnr.c:96
static int do_psnr(FFFrameSync *fs)
Definition: vf_psnr.c:162
uint8_t base
Definition: vp3data.h:141
static double c[64]