FFmpeg  4.4.8
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 "filters.h"
33 #include "drawutils.h"
34 #include "formats.h"
35 #include "framesync.h"
36 #include "internal.h"
37 #include "psnr.h"
38 #include "video.h"
39 
40 typedef struct PSNRContext {
41  const AVClass *class;
43  double mse, min_mse, max_mse, mse_comp[4];
44  uint64_t nb_frames;
45  FILE *stats_file;
50  int max[4], average_max;
51  int is_rgb;
53  char comps[4];
56  int planewidth[4];
57  int planeheight[4];
58  double planeweight[4];
59  uint64_t **score;
61 } PSNRContext;
62 
63 #define OFFSET(x) offsetof(PSNRContext, x)
64 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
65 
66 static const AVOption psnr_options[] = {
67  {"stats_file", "Set file where to store per-frame difference information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
68  {"f", "Set file where to store per-frame difference information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
69  {"stats_version", "Set the format version for the stats file.", OFFSET(stats_version), AV_OPT_TYPE_INT, {.i64=1}, 1, 2, FLAGS },
70  {"output_max", "Add raw stats (max values) to the output log.", OFFSET(stats_add_max), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
71  { NULL }
72 };
73 
75 
76 static inline unsigned pow_2(unsigned base)
77 {
78  return base*base;
79 }
80 
81 static inline double get_psnr(double mse, uint64_t nb_frames, int max)
82 {
83  return 10.0 * log10(pow_2(max) / (mse / nb_frames));
84 }
85 
86 static uint64_t sse_line_8bit(const uint8_t *main_line, const uint8_t *ref_line, int outw)
87 {
88  int j;
89  unsigned m2 = 0;
90 
91  for (j = 0; j < outw; j++)
92  m2 += pow_2(main_line[j] - ref_line[j]);
93 
94  return m2;
95 }
96 
97 static uint64_t sse_line_16bit(const uint8_t *_main_line, const uint8_t *_ref_line, int outw)
98 {
99  int j;
100  uint64_t m2 = 0;
101  const uint16_t *main_line = (const uint16_t *) _main_line;
102  const uint16_t *ref_line = (const uint16_t *) _ref_line;
103 
104  for (j = 0; j < outw; j++)
105  m2 += pow_2(main_line[j] - ref_line[j]);
106 
107  return m2;
108 }
109 
110 typedef struct ThreadData {
111  const uint8_t *main_data[4];
112  const uint8_t *ref_data[4];
113  int main_linesize[4];
114  int ref_linesize[4];
115  int planewidth[4];
116  int planeheight[4];
117  uint64_t **score;
118  int nb_components;
120 } ThreadData;
121 
122 static
124  int jobnr, int nb_jobs)
125 {
126  ThreadData *td = arg;
127  uint64_t *score = td->score[jobnr];
128 
129  for (int c = 0; c < td->nb_components; c++) {
130  const int outw = td->planewidth[c];
131  const int outh = td->planeheight[c];
132  const int slice_start = ff_slice_pos(outh, jobnr, nb_jobs);
133  const int slice_end = ff_slice_pos(outh, jobnr + 1, nb_jobs);
134  const int ref_linesize = td->ref_linesize[c];
135  const int main_linesize = td->main_linesize[c];
136  const uint8_t *main_line = td->main_data[c] + main_linesize * slice_start;
137  const uint8_t *ref_line = td->ref_data[c] + ref_linesize * slice_start;
138  uint64_t m = 0;
139  for (int i = slice_start; i < slice_end; i++) {
140  m += td->dsp->sse_line(main_line, ref_line, outw);
141  ref_line += ref_linesize;
142  main_line += main_linesize;
143  }
144  score[c] = m;
145  }
146 
147  return 0;
148 }
149 
150 static void set_meta(AVDictionary **metadata, const char *key, char comp, float d)
151 {
152  char value[128];
153  snprintf(value, sizeof(value), "%f", d);
154  if (comp) {
155  char key2[128];
156  snprintf(key2, sizeof(key2), "%s%c", key, comp);
157  av_dict_set(metadata, key2, value, 0);
158  } else {
159  av_dict_set(metadata, key, value, 0);
160  }
161 }
162 
163 static int do_psnr(FFFrameSync *fs)
164 {
165  AVFilterContext *ctx = fs->parent;
166  PSNRContext *s = ctx->priv;
167  AVFrame *master, *ref;
168  double comp_mse[4], mse = 0.;
169  uint64_t comp_sum[4] = { 0 };
170  AVDictionary **metadata;
171  ThreadData td;
172  int ret;
173 
175  if (ret < 0)
176  return ret;
177  if (ctx->is_disabled || !ref)
178  return ff_filter_frame(ctx->outputs[0], master);
179  metadata = &master->metadata;
180 
181  td.nb_components = s->nb_components;
182  td.dsp = &s->dsp;
183  td.score = s->score;
184  for (int c = 0; c < s->nb_components; c++) {
185  td.main_data[c] = master->data[c];
186  td.ref_data[c] = ref->data[c];
187  td.main_linesize[c] = master->linesize[c];
188  td.ref_linesize[c] = ref->linesize[c];
189  td.planewidth[c] = s->planewidth[c];
190  td.planeheight[c] = s->planeheight[c];
191  }
192 
193  ctx->internal->execute(ctx, compute_images_mse, &td, NULL, FFMIN(s->planeheight[1], s->nb_threads));
194 
195  for (int j = 0; j < s->nb_threads; j++) {
196  for (int c = 0; c < s->nb_components; c++)
197  comp_sum[c] += s->score[j][c];
198  }
199 
200  for (int c = 0; c < s->nb_components; c++)
201  comp_mse[c] = comp_sum[c] / ((double)s->planewidth[c] * s->planeheight[c]);
202 
203  for (int c = 0; c < s->nb_components; c++)
204  mse += comp_mse[c] * s->planeweight[c];
205 
206  s->min_mse = FFMIN(s->min_mse, mse);
207  s->max_mse = FFMAX(s->max_mse, mse);
208 
209  s->mse += mse;
210 
211  for (int j = 0; j < s->nb_components; j++)
212  s->mse_comp[j] += comp_mse[j];
213  s->nb_frames++;
214 
215  for (int j = 0; j < s->nb_components; j++) {
216  int c = s->is_rgb ? s->rgba_map[j] : j;
217  set_meta(metadata, "lavfi.psnr.mse.", s->comps[j], comp_mse[c]);
218  set_meta(metadata, "lavfi.psnr.psnr.", s->comps[j], get_psnr(comp_mse[c], 1, s->max[c]));
219  }
220  set_meta(metadata, "lavfi.psnr.mse_avg", 0, mse);
221  set_meta(metadata, "lavfi.psnr.psnr_avg", 0, get_psnr(mse, 1, s->average_max));
222 
223  if (s->stats_file) {
224  if (s->stats_version == 2 && !s->stats_header_written) {
225  fprintf(s->stats_file, "psnr_log_version:2 fields:n");
226  fprintf(s->stats_file, ",mse_avg");
227  for (int j = 0; j < s->nb_components; j++) {
228  fprintf(s->stats_file, ",mse_%c", s->comps[j]);
229  }
230  fprintf(s->stats_file, ",psnr_avg");
231  for (int j = 0; j < s->nb_components; j++) {
232  fprintf(s->stats_file, ",psnr_%c", s->comps[j]);
233  }
234  if (s->stats_add_max) {
235  fprintf(s->stats_file, ",max_avg");
236  for (int j = 0; j < s->nb_components; j++) {
237  fprintf(s->stats_file, ",max_%c", s->comps[j]);
238  }
239  }
240  fprintf(s->stats_file, "\n");
241  s->stats_header_written = 1;
242  }
243  fprintf(s->stats_file, "n:%"PRId64" mse_avg:%0.2f ", s->nb_frames, mse);
244  for (int j = 0; j < s->nb_components; j++) {
245  int c = s->is_rgb ? s->rgba_map[j] : j;
246  fprintf(s->stats_file, "mse_%c:%0.2f ", s->comps[j], comp_mse[c]);
247  }
248  fprintf(s->stats_file, "psnr_avg:%0.2f ", get_psnr(mse, 1, s->average_max));
249  for (int j = 0; j < s->nb_components; j++) {
250  int c = s->is_rgb ? s->rgba_map[j] : j;
251  fprintf(s->stats_file, "psnr_%c:%0.2f ", s->comps[j],
252  get_psnr(comp_mse[c], 1, s->max[c]));
253  }
254  if (s->stats_version == 2 && s->stats_add_max) {
255  fprintf(s->stats_file, "max_avg:%d ", s->average_max);
256  for (int j = 0; j < s->nb_components; j++) {
257  int c = s->is_rgb ? s->rgba_map[j] : j;
258  fprintf(s->stats_file, "max_%c:%d ", s->comps[j], s->max[c]);
259  }
260  }
261  fprintf(s->stats_file, "\n");
262  }
263 
264  return ff_filter_frame(ctx->outputs[0], master);
265 }
266 
268 {
269  PSNRContext *s = ctx->priv;
270 
271  s->min_mse = +INFINITY;
272  s->max_mse = -INFINITY;
273 
274  if (s->stats_file_str) {
275  if (s->stats_version < 2 && s->stats_add_max) {
277  "stats_add_max was specified but stats_version < 2.\n" );
278  return AVERROR(EINVAL);
279  }
280  if (!strcmp(s->stats_file_str, "-")) {
281  s->stats_file = stdout;
282  } else {
283  s->stats_file = fopen(s->stats_file_str, "w");
284  if (!s->stats_file) {
285  int err = AVERROR(errno);
286  char buf[128];
287  av_strerror(err, buf, sizeof(buf));
288  av_log(ctx, AV_LOG_ERROR, "Could not open stats file %s: %s\n",
289  s->stats_file_str, buf);
290  return err;
291  }
292  }
293  }
294 
295  s->fs.on_event = do_psnr;
296  return 0;
297 }
298 
300 {
301  static const enum AVPixelFormat pix_fmts[] = {
303 #define PF_NOALPHA(suf) AV_PIX_FMT_YUV420##suf, AV_PIX_FMT_YUV422##suf, AV_PIX_FMT_YUV444##suf
304 #define PF_ALPHA(suf) AV_PIX_FMT_YUVA420##suf, AV_PIX_FMT_YUVA422##suf, AV_PIX_FMT_YUVA444##suf
305 #define PF(suf) PF_NOALPHA(suf), PF_ALPHA(suf)
306  PF(P), PF(P9), PF(P10), PF_NOALPHA(P12), PF_NOALPHA(P14), PF(P16),
314  };
315 
317  if (!fmts_list)
318  return AVERROR(ENOMEM);
319  return ff_set_common_formats(ctx, fmts_list);
320 }
321 
322 static int config_input_ref(AVFilterLink *inlink)
323 {
325  AVFilterContext *ctx = inlink->dst;
326  PSNRContext *s = ctx->priv;
327  double average_max;
328  unsigned sum;
329  int j;
330 
331  s->nb_threads = ff_filter_get_nb_threads(ctx);
332  s->nb_components = desc->nb_components;
333  if (ctx->inputs[0]->w != ctx->inputs[1]->w ||
334  ctx->inputs[0]->h != ctx->inputs[1]->h) {
335  av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n");
336  return AVERROR(EINVAL);
337  }
338  if (ctx->inputs[0]->format != ctx->inputs[1]->format) {
339  av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n");
340  return AVERROR(EINVAL);
341  }
342 
343  s->max[0] = (1 << desc->comp[0].depth) - 1;
344  s->max[1] = (1 << desc->comp[1].depth) - 1;
345  s->max[2] = (1 << desc->comp[2].depth) - 1;
346  s->max[3] = (1 << desc->comp[3].depth) - 1;
347 
348  s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0;
349  s->comps[0] = s->is_rgb ? 'r' : 'y' ;
350  s->comps[1] = s->is_rgb ? 'g' : 'u' ;
351  s->comps[2] = s->is_rgb ? 'b' : 'v' ;
352  s->comps[3] = 'a';
353 
354  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
355  s->planeheight[0] = s->planeheight[3] = inlink->h;
356  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
357  s->planewidth[0] = s->planewidth[3] = inlink->w;
358  sum = 0;
359  for (j = 0; j < s->nb_components; j++)
360  sum += s->planeheight[j] * s->planewidth[j];
361  average_max = 0;
362  for (j = 0; j < s->nb_components; j++) {
363  s->planeweight[j] = (double) s->planeheight[j] * s->planewidth[j] / sum;
364  average_max += s->max[j] * s->planeweight[j];
365  }
366  s->average_max = lrint(average_max);
367 
368  s->dsp.sse_line = desc->comp[0].depth > 8 ? sse_line_16bit : sse_line_8bit;
369  if (ARCH_X86)
370  ff_psnr_init_x86(&s->dsp, desc->comp[0].depth);
371 
372  s->score = av_calloc(s->nb_threads, sizeof(*s->score));
373  if (!s->score)
374  return AVERROR(ENOMEM);
375 
376  for (int t = 0; t < s->nb_threads && s->score; t++) {
377  s->score[t] = av_calloc(s->nb_components, sizeof(*s->score[0]));
378  if (!s->score[t])
379  return AVERROR(ENOMEM);
380  }
381 
382  return 0;
383 }
384 
385 static int config_output(AVFilterLink *outlink)
386 {
387  AVFilterContext *ctx = outlink->src;
388  PSNRContext *s = ctx->priv;
389  AVFilterLink *mainlink = ctx->inputs[0];
390  int ret;
391 
392  ret = ff_framesync_init_dualinput(&s->fs, ctx);
393  if (ret < 0)
394  return ret;
395  outlink->w = mainlink->w;
396  outlink->h = mainlink->h;
397  outlink->time_base = mainlink->time_base;
398  outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio;
399  outlink->frame_rate = mainlink->frame_rate;
400  if ((ret = ff_framesync_configure(&s->fs)) < 0)
401  return ret;
402 
403  outlink->time_base = s->fs.time_base;
404 
405  if (av_cmp_q(mainlink->time_base, outlink->time_base) ||
406  av_cmp_q(ctx->inputs[1]->time_base, outlink->time_base))
407  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",
408  mainlink->time_base.num, mainlink->time_base.den,
409  ctx->inputs[1]->time_base.num, ctx->inputs[1]->time_base.den);
410 
411  return 0;
412 }
413 
415 {
416  PSNRContext *s = ctx->priv;
417  return ff_framesync_activate(&s->fs);
418 }
419 
421 {
422  PSNRContext *s = ctx->priv;
423 
424  if (s->nb_frames > 0) {
425  int j;
426  char buf[256];
427 
428  buf[0] = 0;
429  for (j = 0; j < s->nb_components; j++) {
430  int c = s->is_rgb ? s->rgba_map[j] : j;
431  av_strlcatf(buf, sizeof(buf), " %c:%f", s->comps[j],
432  get_psnr(s->mse_comp[c], s->nb_frames, s->max[c]));
433  }
434  av_log(ctx, AV_LOG_INFO, "PSNR%s average:%f min:%f max:%f\n",
435  buf,
436  get_psnr(s->mse, s->nb_frames, s->average_max),
437  get_psnr(s->max_mse, 1, s->average_max),
438  get_psnr(s->min_mse, 1, s->average_max));
439  }
440 
441  ff_framesync_uninit(&s->fs);
442  for (int t = 0; t < s->nb_threads && s->score; t++)
443  av_freep(&s->score[t]);
444  av_freep(&s->score);
445 
446  if (s->stats_file && s->stats_file != stdout)
447  fclose(s->stats_file);
448 }
449 
450 static const AVFilterPad psnr_inputs[] = {
451  {
452  .name = "main",
453  .type = AVMEDIA_TYPE_VIDEO,
454  },{
455  .name = "reference",
456  .type = AVMEDIA_TYPE_VIDEO,
457  .config_props = config_input_ref,
458  },
459  { NULL }
460 };
461 
462 static const AVFilterPad psnr_outputs[] = {
463  {
464  .name = "default",
465  .type = AVMEDIA_TYPE_VIDEO,
466  .config_props = config_output,
467  },
468  { NULL }
469 };
470 
472  .name = "psnr",
473  .description = NULL_IF_CONFIG_SMALL("Calculate the PSNR between two video streams."),
474  .preinit = psnr_framesync_preinit,
475  .init = init,
476  .uninit = uninit,
477  .query_formats = query_formats,
478  .activate = activate,
479  .priv_size = sizeof(PSNRContext),
480  .priv_class = &psnr_class,
481  .inputs = psnr_inputs,
484 };
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:1096
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:572
#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:100
static double psnr(double d)
Definition: ffmpeg.c:1436
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
Definition: filters.h:271
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:309
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:55
FILE * stats_file
Definition: vf_psnr.c:45
uint64_t nb_frames
Definition: vf_psnr.c:44
int stats_version
Definition: vf_psnr.c:47
int max[4]
Definition: vf_psnr.c:50
uint8_t rgba_map[4]
Definition: vf_psnr.c:52
char comps[4]
Definition: vf_psnr.c:53
double min_mse
Definition: vf_psnr.c:43
int planeheight[4]
Definition: vf_psnr.c:57
int planewidth[4]
Definition: vf_psnr.c:56
int stats_add_max
Definition: vf_psnr.c:49
PSNRDSPContext dsp
Definition: vf_psnr.c:60
int stats_header_written
Definition: vf_psnr.c:48
int average_max
Definition: vf_psnr.c:50
double planeweight[4]
Definition: vf_psnr.c:58
int nb_components
Definition: vf_psnr.c:54
int is_rgb
Definition: vf_psnr.c:51
double max_mse
Definition: vf_psnr.c:43
double mse_comp[4]
Definition: vf_psnr.c:43
FFFrameSync fs
Definition: vf_psnr.c:42
uint64_t ** score
Definition: vf_psnr.c:59
double mse
Definition: vf_psnr.c:43
char * stats_file_str
Definition: vf_psnr.c:46
Used for passing data between threads.
Definition: dsddec.c:67
int nb_components
Definition: vf_identity.c:92
int planeheight[4]
Definition: vf_identity.c:90
uint64_t ** score
Definition: vf_identity.c:91
const uint8_t * ref_data[4]
Definition: vf_identity.c:86
int main_linesize[4]
Definition: vf_identity.c:87
int planewidth[4]
Definition: vf_identity.c:89
PSNRDSPContext * dsp
Definition: vf_psnr.c:119
const uint8_t * main_data[4]
Definition: vf_identity.c:85
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:120
AVFilter ff_vf_psnr
Definition: vf_psnr.c:471
static const AVOption psnr_options[]
Definition: vf_psnr.c:66
static unsigned pow_2(unsigned base)
Definition: vf_psnr.c:76
#define PF_NOALPHA(suf)
static int compute_images_mse(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_psnr.c:123
FRAMESYNC_DEFINE_CLASS(psnr, PSNRContext, fs)
static int query_formats(AVFilterContext *ctx)
Definition: vf_psnr.c:299
static uint64_t sse_line_8bit(const uint8_t *main_line, const uint8_t *ref_line, int outw)
Definition: vf_psnr.c:86
static const AVFilterPad psnr_outputs[]
Definition: vf_psnr.c:462
#define FLAGS
Definition: vf_psnr.c:64
static int config_input_ref(AVFilterLink *inlink)
Definition: vf_psnr.c:322
static void set_meta(AVDictionary **metadata, const char *key, char comp, float d)
Definition: vf_psnr.c:150
#define PF(suf)
static double get_psnr(double mse, uint64_t nb_frames, int max)
Definition: vf_psnr.c:81
static const AVFilterPad psnr_inputs[]
Definition: vf_psnr.c:450
static int activate(AVFilterContext *ctx)
Definition: vf_psnr.c:414
static av_cold int init(AVFilterContext *ctx)
Definition: vf_psnr.c:267
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_psnr.c:420
#define OFFSET(x)
Definition: vf_psnr.c:63
static int config_output(AVFilterLink *outlink)
Definition: vf_psnr.c:385
static uint64_t sse_line_16bit(const uint8_t *_main_line, const uint8_t *_ref_line, int outw)
Definition: vf_psnr.c:97
static int do_psnr(FFFrameSync *fs)
Definition: vf_psnr.c:163
uint8_t base
Definition: vp3data.h:141
static double c[64]