FFmpeg
vf_corr.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /**
20  * @file
21  * Calculate the correlation between two input videos.
22  */
23 
24 #include "libavutil/avstring.h"
25 #include "libavutil/opt.h"
26 #include "libavutil/pixdesc.h"
27 #include "avfilter.h"
28 #include "drawutils.h"
29 #include "framesync.h"
30 #include "internal.h"
31 
32 typedef struct Sums {
33  uint64_t s[2];
34 } Sums;
35 
36 typedef struct QSums {
37  float s[3];
38 } QSums;
39 
40 typedef struct CorrContext {
41  const AVClass *class;
44  uint64_t nb_frames;
46  int is_rgb;
47  uint8_t rgba_map[4];
48  int max[4];
49  char comps[4];
50  float mean[4][2];
54  int planewidth[4];
55  int planeheight[4];
57  int jobnr, int nb_jobs);
59  int jobnr, int nb_jobs);
60 } CorrContext;
61 
62 typedef struct ThreadData {
64 } ThreadData;
65 
66 #define OFFSET(x) offsetof(CorrContext, x)
67 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
68 
70  AVDictionary **metadata, const char *key, char comp, float d)
71 {
72  char value[128];
73  snprintf(value, sizeof(value), "%f", d);
74  if (comp) {
75  char key2[128];
76  snprintf(key2, sizeof(key2), "lavfi.%s.%s%s%c",
77  ctx->filter->name, ctx->filter->name, key, comp);
78  av_dict_set(metadata, key2, value, 0);
79  } else {
80  char key2[128];
81  snprintf(key2, sizeof(key2), "lavfi.%s.%s%s",
82  ctx->filter->name, ctx->filter->name, key);
83  av_dict_set(metadata, key2, value, 0);
84  }
85 }
86 
87 #define SUM(type, name) \
88 static int sum_##name(AVFilterContext *ctx, void *arg, \
89  int jobnr, int nb_jobs) \
90 { \
91  CorrContext *s = ctx->priv; \
92  ThreadData *td = arg; \
93  AVFrame *master = td->master; \
94  AVFrame *ref = td->ref; \
95  \
96  for (int c = 0; c < s->nb_components; c++) { \
97  const ptrdiff_t linesize1 = master->linesize[c] / \
98  sizeof(type); \
99  const ptrdiff_t linesize2 = ref->linesize[c] / \
100  sizeof(type); \
101  const int h = s->planeheight[c]; \
102  const int w = s->planewidth[c]; \
103  const int slice_start = (h * jobnr) / nb_jobs; \
104  const int slice_end = (h * (jobnr+1)) / nb_jobs; \
105  const type *src1 = (const type *)master->data[c] + \
106  linesize1 * slice_start; \
107  const type *src2 = (const type *)ref->data[c] + \
108  linesize2 * slice_start; \
109  uint64_t sum1 = 0, sum2 = 0; \
110  \
111  for (int y = slice_start; y < slice_end; y++) { \
112  for (int x = 0; x < w; x++) { \
113  sum1 += src1[x]; \
114  sum2 += src2[x]; \
115  } \
116  \
117  src1 += linesize1; \
118  src2 += linesize2; \
119  } \
120  \
121  s->sums[jobnr * s->nb_components + c].s[0] = sum1; \
122  s->sums[jobnr * s->nb_components + c].s[1] = sum2; \
123  } \
124  \
125  return 0; \
126 }
127 
128 SUM(uint8_t, slice8)
129 SUM(uint16_t, slice16)
130 
131 #define CORR(type, name) \
132 static int corr_##name(AVFilterContext *ctx, void *arg, \
133  int jobnr, int nb_jobs) \
134 { \
135  CorrContext *s = ctx->priv; \
136  ThreadData *td = arg; \
137  AVFrame *master = td->master; \
138  AVFrame *ref = td->ref; \
139  \
140  for (int c = 0; c < s->nb_components; c++) { \
141  const ptrdiff_t linesize1 = master->linesize[c] / \
142  sizeof(type); \
143  const ptrdiff_t linesize2 = ref->linesize[c] / \
144  sizeof(type); \
145  const type *src1 = (const type *)master->data[c]; \
146  const type *src2 = (const type *)ref->data[c]; \
147  const int h = s->planeheight[c]; \
148  const int w = s->planewidth[c]; \
149  const int slice_start = (h * jobnr) / nb_jobs; \
150  const int slice_end = (h * (jobnr+1)) / nb_jobs; \
151  const float scale = 1.f / s->max[c]; \
152  const float mean1 = s->mean[c][0]; \
153  const float mean2 = s->mean[c][1]; \
154  float sum12 = 0.f, sum1q = 0.f, sum2q = 0.f; \
155  \
156  src1 = (const type *)master->data[c] + \
157  slice_start * linesize1; \
158  src2 = (const type *)ref->data[c] + \
159  slice_start * linesize2; \
160  \
161  for (int y = slice_start; y < slice_end; y++) { \
162  for (int x = 0; x < w; x++) { \
163  const float f1 = scale * src1[x] - mean1; \
164  const float f2 = scale * src2[x] - mean2; \
165  \
166  sum12 += f1 * f2; \
167  sum1q += f1 * f1; \
168  sum2q += f2 * f2; \
169  } \
170  \
171  src1 += linesize1; \
172  src2 += linesize2; \
173  } \
174  \
175  s->qsums[jobnr * s->nb_components + c].s[0] = sum12; \
176  s->qsums[jobnr * s->nb_components + c].s[1] = sum1q; \
177  s->qsums[jobnr * s->nb_components + c].s[2] = sum2q; \
178  } \
179  \
180  return 0; \
181 }
182 
183 CORR(uint8_t, slice8)
184 CORR(uint16_t, slice16)
185 
186 static int do_corr(FFFrameSync *fs)
187 {
188  AVFilterContext *ctx = fs->parent;
189  CorrContext *s = ctx->priv;
190  AVFrame *master, *ref;
191  double comp_score[4], score = 0.;
192  AVDictionary **metadata;
193  ThreadData td;
194  int ret;
195 
197  if (ret < 0)
198  return ret;
199  if (ctx->is_disabled || !ref)
200  return ff_filter_frame(ctx->outputs[0], master);
201  metadata = &master->metadata;
202 
203  td.master = master;
204  td.ref = ref;
205  ff_filter_execute(ctx, s->sum_slice, &td, NULL,
206  FFMIN(s->planeheight[1], s->nb_threads));
207 
208  for (int c = 0; c < s->nb_components; c++) {
209  const double scale = 1.f / s->max[c];
210  uint64_t sum1 = 0, sum2 = 0;
211 
212  for (int n = 0; n < s->nb_threads; n++) {
213  sum1 += s->sums[n * s->nb_components + c].s[0];
214  sum2 += s->sums[n * s->nb_components + c].s[1];
215  }
216 
217  s->mean[c][0] = scale * (sum1 /(double)(s->planewidth[c] * s->planeheight[c]));
218  s->mean[c][1] = scale * (sum2 /(double)(s->planewidth[c] * s->planeheight[c]));
219  }
220 
221  ff_filter_execute(ctx, s->corr_slice, &td, NULL,
222  FFMIN(s->planeheight[1], s->nb_threads));
223 
224  for (int c = 0; c < s->nb_components; c++) {
225  double sumq, sum12 = 0.0, sum1q = 0.0, sum2q = 0.0;
226 
227  for (int n = 0; n < s->nb_threads; n++) {
228  sum12 += s->qsums[n * s->nb_components + c].s[0];
229  sum1q += s->qsums[n * s->nb_components + c].s[1];
230  sum2q += s->qsums[n * s->nb_components + c].s[2];
231  }
232 
233  sumq = sqrt(sum1q * sum2q);
234  if (sumq > 0.0) {
235  comp_score[c] = av_clipd(sum12 / sumq,-1.0,1.0);
236  } else {
237  comp_score[c] = 0.f;
238  }
239  }
240 
241  for (int c = 0; c < s->nb_components; c++)
242  score += comp_score[c];
243  score /= s->nb_components;
244  s->score += score;
245 
246  s->min_score = fmin(s->min_score, score);
247  s->max_score = fmax(s->max_score, score);
248 
249  for (int c = 0; c < s->nb_components; c++)
250  s->score_comp[c] += comp_score[c];
251  s->nb_frames++;
252 
253  for (int j = 0; j < s->nb_components; j++) {
254  int c = s->is_rgb ? s->rgba_map[j] : j;
255  set_meta(ctx, metadata, ".", s->comps[j], comp_score[c]);
256  }
257  set_meta(ctx, metadata, "_avg", 0, score);
258 
259  return ff_filter_frame(ctx->outputs[0], master);
260 }
261 
263 {
264  CorrContext *s = ctx->priv;
265 
266  s->fs.on_event = do_corr;
267 
268  return 0;
269 }
270 
271 static const enum AVPixelFormat pix_fmts[] = {
273 #define PF_NOALPHA(suf) AV_PIX_FMT_YUV420##suf, AV_PIX_FMT_YUV422##suf, AV_PIX_FMT_YUV444##suf
274 #define PF_ALPHA(suf) AV_PIX_FMT_YUVA420##suf, AV_PIX_FMT_YUVA422##suf, AV_PIX_FMT_YUVA444##suf
275 #define PF(suf) PF_NOALPHA(suf), PF_ALPHA(suf)
276  PF(P), PF(P9), PF(P10), PF_NOALPHA(P12), PF_NOALPHA(P14), PF(P16),
284 };
285 
287 {
289  AVFilterContext *ctx = inlink->dst;
290  CorrContext *s = ctx->priv;
291 
292  s->nb_threads = ff_filter_get_nb_threads(ctx);
293  s->nb_components = desc->nb_components;
294  if (ctx->inputs[0]->w != ctx->inputs[1]->w ||
295  ctx->inputs[0]->h != ctx->inputs[1]->h) {
296  av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n");
297  return AVERROR(EINVAL);
298  }
299 
300  s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0;
301  s->comps[0] = s->is_rgb ? 'R' : 'Y' ;
302  s->comps[1] = s->is_rgb ? 'G' : 'U' ;
303  s->comps[2] = s->is_rgb ? 'B' : 'V' ;
304  s->comps[3] = 'A';
305 
306  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
307  s->planeheight[0] = s->planeheight[3] = inlink->h;
308  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
309  s->planewidth[0] = s->planewidth[3] = inlink->w;
310 
311  s->sums = av_calloc(s->nb_threads * s->nb_components, sizeof(*s->sums));
312  s->qsums = av_calloc(s->nb_threads * s->nb_components, sizeof(*s->qsums));
313  if (!s->qsums || !s->sums)
314  return AVERROR(ENOMEM);
315 
316  s->min_score = +INFINITY;
317  s->max_score = -INFINITY;
318 
319  s->max[0] = (1 << desc->comp[0].depth) - 1;
320  s->max[1] = (1 << desc->comp[1].depth) - 1;
321  s->max[2] = (1 << desc->comp[2].depth) - 1;
322  s->max[3] = (1 << desc->comp[3].depth) - 1;
323 
324  s->sum_slice = desc->comp[0].depth > 8 ? sum_slice16 : sum_slice8;
325  s->corr_slice = desc->comp[0].depth > 8 ? corr_slice16 : corr_slice8;
326 
327  return 0;
328 }
329 
330 static int config_output(AVFilterLink *outlink)
331 {
332  AVFilterContext *ctx = outlink->src;
333  CorrContext *s = ctx->priv;
334  AVFilterLink *mainlink = ctx->inputs[0];
335  int ret;
336 
338  if (ret < 0)
339  return ret;
340  outlink->w = mainlink->w;
341  outlink->h = mainlink->h;
342  outlink->time_base = mainlink->time_base;
343  outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio;
344  outlink->frame_rate = mainlink->frame_rate;
345  if ((ret = ff_framesync_configure(&s->fs)) < 0)
346  return ret;
347 
348  outlink->time_base = s->fs.time_base;
349 
350  if (av_cmp_q(mainlink->time_base, outlink->time_base) ||
351  av_cmp_q(ctx->inputs[1]->time_base, outlink->time_base))
352  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",
353  mainlink->time_base.num, mainlink->time_base.den,
354  ctx->inputs[1]->time_base.num, ctx->inputs[1]->time_base.den);
355 
356  return 0;
357 }
358 
360 {
361  CorrContext *s = ctx->priv;
362  return ff_framesync_activate(&s->fs);
363 }
364 
366 {
367  CorrContext *s = ctx->priv;
368 
369  if (s->nb_frames > 0) {
370  char buf[256];
371 
372  buf[0] = 0;
373  for (int j = 0; j < s->nb_components; j++) {
374  int c = s->is_rgb ? s->rgba_map[j] : j;
375  av_strlcatf(buf, sizeof(buf), " %c:%f", s->comps[j], s->score_comp[c] / s->nb_frames);
376  }
377 
378  av_log(ctx, AV_LOG_INFO, "%s%s average:%f min:%f max:%f\n",
379  ctx->filter->name,
380  buf,
381  s->score / s->nb_frames,
382  s->min_score,
383  s->max_score);
384  }
385 
386  ff_framesync_uninit(&s->fs);
387  av_freep(&s->qsums);
388  av_freep(&s->sums);
389 }
390 
391 static const AVFilterPad corr_inputs[] = {
392  {
393  .name = "main",
394  .type = AVMEDIA_TYPE_VIDEO,
395  },{
396  .name = "reference",
397  .type = AVMEDIA_TYPE_VIDEO,
398  .config_props = config_input_ref,
399  },
400 };
401 
402 static const AVFilterPad corr_outputs[] = {
403  {
404  .name = "default",
405  .type = AVMEDIA_TYPE_VIDEO,
406  .config_props = config_output,
407  },
408 };
409 
410 static const AVOption options[] = {
411  { NULL }
412 };
413 
414 #define corr_options options
416 
418  .name = "corr",
419  .description = NULL_IF_CONFIG_SMALL("Calculate the correlation between two video streams."),
420  .preinit = corr_framesync_preinit,
421  .init = init,
422  .uninit = uninit,
423  .activate = activate,
424  .priv_size = sizeof(CorrContext),
425  .priv_class = &corr_class,
432 };
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:501
ff_framesync_configure
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:134
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
td
#define td
Definition: regdef.h:70
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
INFINITY
#define INFINITY
Definition: mathematics.h:118
CorrContext::max
int max[4]
Definition: vf_corr.c:48
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
ff_framesync_uninit
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:304
CorrContext::planeheight
int planeheight[4]
Definition: vf_corr.c:55
comp
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
Definition: eamad.c:80
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2962
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:162
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
pixdesc.h
QSums::s
float s[3]
Definition: vf_corr.c:37
AVOption
AVOption.
Definition: opt.h:346
CorrContext::min_score
double min_score
Definition: vf_corr.c:43
CorrContext::is_rgb
int is_rgb
Definition: vf_corr.c:46
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
AVDictionary
Definition: dict.c:34
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
FFFrameSync
Frame sync structure.
Definition: framesync.h:168
av_strlcatf
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
Definition: avstring.c:103
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_corr.c:330
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:458
FRAMESYNC_DEFINE_CLASS
FRAMESYNC_DEFINE_CLASS(corr, CorrContext, fs)
Sums
Definition: vf_corr.c:32
corr_inputs
static const AVFilterPad corr_inputs[]
Definition: vf_corr.c:391
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:496
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
corr_outputs
static const AVFilterPad corr_outputs[]
Definition: vf_corr.c:402
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:494
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:462
ff_vf_corr
const AVFilter ff_vf_corr
Definition: vf_corr.c:417
AVRational::num
int num
Numerator.
Definition: rational.h:59
CorrContext::rgba_map
uint8_t rgba_map[4]
Definition: vf_corr.c:47
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
ThreadData::master
AVFrame * master
Definition: vf_corr.c:63
AV_PIX_FMT_YUVJ411P
@ 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:283
CorrContext::corr_slice
int(* corr_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_corr.c:58
CorrContext::score
double score
Definition: vf_corr.c:43
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_corr.c:262
AV_PIX_FMT_YUVJ422P
@ 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:86
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:498
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:499
CorrContext::sum_slice
int(* sum_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_corr.c:56
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
activate
static int activate(AVFilterContext *ctx)
Definition: vf_corr.c:359
CorrContext::fs
FFFrameSync fs
Definition: vf_corr.c:42
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:461
options
static const AVOption options[]
Definition: vf_corr.c:410
CorrContext
Definition: vf_corr.c:40
key
const char * key
Definition: hwcontext_opencl.c:189
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
AV_PIX_FMT_YUVJ444P
@ 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:87
arg
const char * arg
Definition: jacosubdec.c:67
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:459
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:497
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
fs
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:200
CorrContext::score_comp
double score_comp[4]
Definition: vf_corr.c:43
AV_PIX_FMT_YUVJ420P
@ 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:85
CorrContext::planewidth
int planewidth[4]
Definition: vf_corr.c:54
double
double
Definition: af_crystalizer.c:131
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
PF
#define PF(suf)
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:493
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
CORR
#define CORR(type, name)
Definition: vf_corr.c:131
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: vvc_intra.c:291
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:106
ff_framesync_init_dualinput
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
Definition: framesync.c:375
master
const char * master
Definition: vf_curves.c:129
P
#define P
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
fmin
double fmin(double, double)
CorrContext::nb_threads
int nb_threads
Definition: vf_corr.c:45
CorrContext::nb_components
int nb_components
Definition: vf_corr.c:53
CorrContext::qsums
QSums * qsums
Definition: vf_corr.c:52
SUM
#define SUM(type, name)
Definition: vf_corr.c:87
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
internal.h
PF_NOALPHA
#define PF_NOALPHA(suf)
CorrContext::sums
Sums * sums
Definition: vf_corr.c:51
config_input_ref
static int config_input_ref(AVFilterLink *inlink)
Definition: vf_corr.c:286
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:495
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:825
ThreadData
Used for passing data between threads.
Definition: dsddec.c:69
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_corr.c:271
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_corr.c:365
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV_PIX_FMT_YUVJ440P
@ 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:107
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
av_cmp_q
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
Definition: rational.h:89
AVFilter
Filter definition.
Definition: avfilter.h:166
set_meta
static void set_meta(AVFilterContext *ctx, AVDictionary **metadata, const char *key, char comp, float d)
Definition: vf_corr.c:69
ret
ret
Definition: filter_design.txt:187
ThreadData::ref
AVFrame * ref
Definition: vf_corr.c:63
fmax
double fmax(double, double)
framesync.h
CorrContext::nb_frames
uint64_t nb_frames
Definition: vf_corr.c:44
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
avfilter.h
AVFILTER_FLAG_METADATA_ONLY
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
Definition: avfilter.h:133
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
desc
const char * desc
Definition: libsvtav1.c:75
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
CorrContext::max_score
double max_score
Definition: vf_corr.c:43
QSums
Definition: vf_corr.c:36
CorrContext::comps
char comps[4]
Definition: vf_corr.c:49
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
av_dict_set
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:88
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:80
ff_fill_rgba_map
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
Definition: drawutils.c:35
d
d
Definition: ffmpeg_filter.c:409
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#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:155
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:79
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_framesync_activate
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
Definition: framesync.c:355
avstring.h
ff_framesync_dualinput_get
int ff_framesync_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
Definition: framesync.c:393
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:460
drawutils.h
ff_filter_execute
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: internal.h:134
int
int
Definition: ffmpeg_filter.c:409
CorrContext::mean
float mean[4][2]
Definition: vf_corr.c:50
snprintf
#define snprintf
Definition: snprintf.h:34
Sums::s
uint64_t s[2]
Definition: vf_corr.c:33
av_clipd
av_clipd
Definition: af_crystalizer.c:131
do_corr
static int do_corr(FFFrameSync *fs)
Definition: vf_corr.c:186