FFmpeg
vf_identity.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 Paul B Mahol
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * Calculate the Identity between two input videos.
24  */
25 
26 #include "config_components.h"
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 "framesync.h"
34 #include "internal.h"
35 #include "scene_sad.h"
36 
37 typedef struct IdentityContext {
38  const AVClass *class;
41  uint64_t nb_frames;
42  int is_rgb;
43  int is_msad;
44  uint8_t rgba_map[4];
45  int max[4];
46  char comps[4];
49  int planewidth[4];
50  int planeheight[4];
51  uint64_t **scores;
52  unsigned (*filter_line)(const uint8_t *buf, const uint8_t *ref, int w);
54  int jobnr, int nb_jobs);
57 
58 #define OFFSET(x) offsetof(IdentityContext, x)
59 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
60 
61 static unsigned identity_line_8bit(const uint8_t *main_line, const uint8_t *ref_line, int outw)
62 {
63  unsigned score = 0;
64 
65  for (int j = 0; j < outw; j++)
66  score += main_line[j] == ref_line[j];
67 
68  return score;
69 }
70 
71 static unsigned identity_line_16bit(const uint8_t *mmain_line, const uint8_t *rref_line, int outw)
72 {
73  const uint16_t *main_line = (const uint16_t *)mmain_line;
74  const uint16_t *ref_line = (const uint16_t *)rref_line;
75  unsigned score = 0;
76 
77  for (int j = 0; j < outw; j++)
78  score += main_line[j] == ref_line[j];
79 
80  return score;
81 }
82 
83 typedef struct ThreadData {
84  const uint8_t *main_data[4];
85  const uint8_t *ref_data[4];
86  int main_linesize[4];
87  int ref_linesize[4];
88  int planewidth[4];
89  int planeheight[4];
90  uint64_t **score;
92 } ThreadData;
93 
94 static
96  int jobnr, int nb_jobs)
97 {
98  IdentityContext *s = ctx->priv;
99  ThreadData *td = arg;
100  uint64_t *score = td->score[jobnr];
101 
102  for (int c = 0; c < td->nb_components; c++) {
103  const int outw = td->planewidth[c];
104  const int outh = td->planeheight[c];
105  const int slice_start = (outh * jobnr) / nb_jobs;
106  const int slice_end = (outh * (jobnr+1)) / nb_jobs;
107  const int ref_linesize = td->ref_linesize[c];
108  const int main_linesize = td->main_linesize[c];
109  const uint8_t *main_line = td->main_data[c] + main_linesize * slice_start;
110  const uint8_t *ref_line = td->ref_data[c] + ref_linesize * slice_start;
111  uint64_t m = 0;
112 
113  s->sad(main_line, main_linesize, ref_line, ref_linesize,
114  outw, slice_end - slice_start, &m);
115 
116  score[c] = m;
117  }
118 
119  return 0;
120 }
121 
122 static
124  int jobnr, int nb_jobs)
125 {
126  IdentityContext *s = ctx->priv;
127  ThreadData *td = arg;
128  uint64_t *score = td->score[jobnr];
129 
130  for (int c = 0; c < td->nb_components; c++) {
131  const int outw = td->planewidth[c];
132  const int outh = td->planeheight[c];
133  const int slice_start = (outh * jobnr) / nb_jobs;
134  const int slice_end = (outh * (jobnr+1)) / nb_jobs;
135  const int ref_linesize = td->ref_linesize[c];
136  const int main_linesize = td->main_linesize[c];
137  const uint8_t *main_line = td->main_data[c] + main_linesize * slice_start;
138  const uint8_t *ref_line = td->ref_data[c] + ref_linesize * slice_start;
139  uint64_t m = 0;
140 
141  for (int i = slice_start; i < slice_end; i++) {
142  m += s->filter_line(main_line, ref_line, outw);
143  ref_line += ref_linesize;
144  main_line += main_linesize;
145  }
146  score[c] = m;
147  }
148 
149  return 0;
150 }
151 
153  AVDictionary **metadata, const char *key, char comp, float d)
154 {
155  char value[128];
156  snprintf(value, sizeof(value), "%f", d);
157  if (comp) {
158  char key2[128];
159  snprintf(key2, sizeof(key2), "lavfi.%s.%s%s%c",
160  ctx->filter->name, ctx->filter->name, key, comp);
161  av_dict_set(metadata, key2, value, 0);
162  } else {
163  char key2[128];
164  snprintf(key2, sizeof(key2), "lavfi.%s.%s%s",
165  ctx->filter->name, ctx->filter->name, key);
166  av_dict_set(metadata, key2, value, 0);
167  }
168 }
169 
171 {
172  AVFilterContext *ctx = fs->parent;
173  IdentityContext *s = ctx->priv;
174  AVFrame *master, *ref;
175  double comp_score[4], score = 0.;
176  uint64_t comp_sum[4] = { 0 };
177  AVDictionary **metadata;
178  ThreadData td;
179  int ret;
180 
182  if (ret < 0)
183  return ret;
184  if (ctx->is_disabled || !ref)
185  return ff_filter_frame(ctx->outputs[0], master);
186  metadata = &master->metadata;
187 
188  td.nb_components = s->nb_components;
189  td.score = s->scores;
190  for (int c = 0; c < s->nb_components; c++) {
191  td.main_data[c] = master->data[c];
192  td.ref_data[c] = ref->data[c];
193  td.main_linesize[c] = master->linesize[c];
194  td.ref_linesize[c] = ref->linesize[c];
195  td.planewidth[c] = s->planewidth[c];
196  td.planeheight[c] = s->planeheight[c];
197  }
198 
199  ff_filter_execute(ctx, s->filter_slice, &td, NULL,
200  FFMIN(s->planeheight[1], s->nb_threads));
201 
202  for (int j = 0; j < s->nb_threads; j++) {
203  for (int c = 0; c < s->nb_components; c++)
204  comp_sum[c] += s->scores[j][c];
205  }
206 
207  for (int c = 0; c < s->nb_components; c++)
208  comp_score[c] = comp_sum[c] / ((double)s->planewidth[c] * s->planeheight[c]);
209 
210  for (int c = 0; c < s->nb_components && s->is_msad; c++)
211  comp_score[c] /= (double)s->max[c];
212 
213  for (int c = 0; c < s->nb_components; c++)
214  score += comp_score[c];
215  score /= s->nb_components;
216 
217  s->min_score = FFMIN(s->min_score, score);
218  s->max_score = FFMAX(s->max_score, score);
219 
220  s->score += score;
221 
222  for (int j = 0; j < s->nb_components; j++)
223  s->score_comp[j] += comp_score[j];
224  s->nb_frames++;
225 
226  for (int j = 0; j < s->nb_components; j++) {
227  int c = s->is_rgb ? s->rgba_map[j] : j;
228  set_meta(ctx, metadata, ".", s->comps[j], comp_score[c]);
229  }
230  set_meta(ctx, metadata, "_avg", 0, score);
231 
232  return ff_filter_frame(ctx->outputs[0], master);
233 }
234 
236 {
237  IdentityContext *s = ctx->priv;
238 
239  s->fs.on_event = do_identity;
240 
241  return 0;
242 }
243 
244 static const enum AVPixelFormat pix_fmts[] = {
246 #define PF_NOALPHA(suf) AV_PIX_FMT_YUV420##suf, AV_PIX_FMT_YUV422##suf, AV_PIX_FMT_YUV444##suf
247 #define PF_ALPHA(suf) AV_PIX_FMT_YUVA420##suf, AV_PIX_FMT_YUVA422##suf, AV_PIX_FMT_YUVA444##suf
248 #define PF(suf) PF_NOALPHA(suf), PF_ALPHA(suf)
249  PF(P), PF(P9), PF(P10), PF_NOALPHA(P12), PF_NOALPHA(P14), PF(P16),
257 };
258 
260 {
262  AVFilterContext *ctx = inlink->dst;
263  IdentityContext *s = ctx->priv;
264 
265  s->nb_threads = ff_filter_get_nb_threads(ctx);
266  s->nb_components = desc->nb_components;
267  if (ctx->inputs[0]->w != ctx->inputs[1]->w ||
268  ctx->inputs[0]->h != ctx->inputs[1]->h) {
269  av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n");
270  return AVERROR(EINVAL);
271  }
272 
273  s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0;
274  s->comps[0] = s->is_rgb ? 'R' : 'Y' ;
275  s->comps[1] = s->is_rgb ? 'G' : 'U' ;
276  s->comps[2] = s->is_rgb ? 'B' : 'V' ;
277  s->comps[3] = 'A';
278 
279  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
280  s->planeheight[0] = s->planeheight[3] = inlink->h;
281  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
282  s->planewidth[0] = s->planewidth[3] = inlink->w;
283 
284  s->scores = av_calloc(s->nb_threads, sizeof(*s->scores));
285  if (!s->scores)
286  return AVERROR(ENOMEM);
287 
288  for (int t = 0; t < s->nb_threads; t++) {
289  s->scores[t] = av_calloc(s->nb_components, sizeof(*s->scores[0]));
290  if (!s->scores[t])
291  return AVERROR(ENOMEM);
292  }
293 
294  s->min_score = +INFINITY;
295  s->max_score = -INFINITY;
296 
297  s->max[0] = (1 << desc->comp[0].depth) - 1;
298  s->max[1] = (1 << desc->comp[1].depth) - 1;
299  s->max[2] = (1 << desc->comp[2].depth) - 1;
300  s->max[3] = (1 << desc->comp[3].depth) - 1;
301 
302  s->is_msad = !strcmp(ctx->filter->name, "msad");
303  s->filter_slice = !s->is_msad ? compute_images_identity : compute_images_msad;
304  s->filter_line = desc->comp[0].depth > 8 ? identity_line_16bit : identity_line_8bit;
305 
306  s->sad = ff_scene_sad_get_fn(desc->comp[0].depth <= 8 ? 8 : 16);
307  if (!s->sad)
308  return AVERROR(EINVAL);
309 
310  return 0;
311 }
312 
313 static int config_output(AVFilterLink *outlink)
314 {
315  AVFilterContext *ctx = outlink->src;
316  IdentityContext *s = ctx->priv;
317  AVFilterLink *mainlink = ctx->inputs[0];
318  int ret;
319 
321  if (ret < 0)
322  return ret;
323  outlink->w = mainlink->w;
324  outlink->h = mainlink->h;
325  outlink->time_base = mainlink->time_base;
326  outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio;
327  outlink->frame_rate = mainlink->frame_rate;
328  if ((ret = ff_framesync_configure(&s->fs)) < 0)
329  return ret;
330 
331  outlink->time_base = s->fs.time_base;
332 
333  if (av_cmp_q(mainlink->time_base, outlink->time_base) ||
334  av_cmp_q(ctx->inputs[1]->time_base, outlink->time_base))
335  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",
336  mainlink->time_base.num, mainlink->time_base.den,
337  ctx->inputs[1]->time_base.num, ctx->inputs[1]->time_base.den);
338 
339  return 0;
340 }
341 
343 {
344  IdentityContext *s = ctx->priv;
345  return ff_framesync_activate(&s->fs);
346 }
347 
349 {
350  IdentityContext *s = ctx->priv;
351 
352  if (s->nb_frames > 0) {
353  char buf[256];
354 
355  buf[0] = 0;
356  for (int j = 0; j < s->nb_components; j++) {
357  int c = s->is_rgb ? s->rgba_map[j] : j;
358  av_strlcatf(buf, sizeof(buf), " %c:%f", s->comps[j], s->score_comp[c] / s->nb_frames);
359  }
360 
361  av_log(ctx, AV_LOG_INFO, "%s%s average:%f min:%f max:%f\n",
362  ctx->filter->name,
363  buf,
364  s->score / s->nb_frames,
365  s->min_score,
366  s->max_score);
367  }
368 
369  ff_framesync_uninit(&s->fs);
370  for (int t = 0; t < s->nb_threads && s->scores; t++)
371  av_freep(&s->scores[t]);
372  av_freep(&s->scores);
373 }
374 
375 static const AVFilterPad identity_inputs[] = {
376  {
377  .name = "main",
378  .type = AVMEDIA_TYPE_VIDEO,
379  },{
380  .name = "reference",
381  .type = AVMEDIA_TYPE_VIDEO,
382  .config_props = config_input_ref,
383  },
384 };
385 
386 static const AVFilterPad identity_outputs[] = {
387  {
388  .name = "default",
389  .type = AVMEDIA_TYPE_VIDEO,
390  .config_props = config_output,
391  },
392 };
393 
394 static const AVOption options[] = {
395  { NULL }
396 };
397 
398 #if CONFIG_IDENTITY_FILTER
399 
400 #define identity_options options
402 
403 const AVFilter ff_vf_identity = {
404  .name = "identity",
405  .description = NULL_IF_CONFIG_SMALL("Calculate the Identity between two video streams."),
406  .preinit = identity_framesync_preinit,
407  .init = init,
408  .uninit = uninit,
409  .activate = activate,
410  .priv_size = sizeof(IdentityContext),
411  .priv_class = &identity_class,
418 };
419 
420 #endif /* CONFIG_IDENTITY_FILTER */
421 
422 #if CONFIG_MSAD_FILTER
423 
424 #define msad_options options
426 
427 const AVFilter ff_vf_msad = {
428  .name = "msad",
429  .description = NULL_IF_CONFIG_SMALL("Calculate the MSAD between two video streams."),
430  .preinit = msad_framesync_preinit,
431  .init = init,
432  .uninit = uninit,
433  .activate = activate,
434  .priv_size = sizeof(IdentityContext),
435  .priv_class = &msad_class,
442 };
443 
444 #endif /* CONFIG_MSAD_FILTER */
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
IdentityContext::nb_components
int nb_components
Definition: vf_identity.c:47
td
#define td
Definition: regdef.h:70
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
IdentityContext::sad
ff_scene_sad_fn sad
Definition: vf_identity.c:55
INFINITY
#define INFINITY
Definition: mathematics.h:118
ff_vf_identity
const AVFilter ff_vf_identity
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
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
IdentityContext::fs
FFFrameSync fs
Definition: vf_identity.c:39
config_input_ref
static int config_input_ref(AVFilterLink *inlink)
Definition: vf_identity.c:259
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
pixdesc.h
w
uint8_t w
Definition: llviddspenc.c:38
ThreadData::ref_linesize
int ref_linesize
Definition: vf_bm3d.c:57
IdentityContext::score
double score
Definition: vf_identity.c:40
do_identity
static int do_identity(FFFrameSync *fs)
Definition: vf_identity.c:170
AVOption
AVOption.
Definition: opt.h:346
PF_NOALPHA
#define PF_NOALPHA(suf)
FRAMESYNC_DEFINE_CLASS
#define FRAMESYNC_DEFINE_CLASS(name, context, field)
Definition: framesync.h:351
IdentityContext::is_msad
int is_msad
Definition: vf_identity.c:43
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
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
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
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:458
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
set_meta
static void set_meta(AVFilterContext *ctx, AVDictionary **metadata, const char *key, char comp, float d)
Definition: vf_identity.c:152
IdentityContext::filter_line
unsigned(* filter_line)(const uint8_t *buf, const uint8_t *ref, int w)
Definition: vf_identity.c:52
IdentityContext::comps
char comps[4]
Definition: vf_identity.c:46
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
IdentityContext
Definition: vf_identity.c:37
AVRational::num
int num
Numerator.
Definition: rational.h:59
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
identity_line_16bit
static unsigned identity_line_16bit(const uint8_t *mmain_line, const uint8_t *rref_line, int outw)
Definition: vf_identity.c:71
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
slice_start
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
Definition: vvcdec.c:685
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
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
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
IdentityContext::max
int max[4]
Definition: vf_identity.c:45
identity_outputs
static const AVFilterPad identity_outputs[]
Definition: vf_identity.c:386
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:1717
ctx
AVFormatContext * ctx
Definition: movenc.c:48
IdentityContext::nb_frames
uint64_t nb_frames
Definition: vf_identity.c:41
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:461
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
ff_scene_sad_get_fn
ff_scene_sad_fn ff_scene_sad_get_fn(int depth)
Definition: scene_sad.c:59
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
IdentityContext::filter_slice
int(* filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_identity.c:53
fs
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:200
IdentityContext::max_score
double max_score
Definition: vf_identity.c:40
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
ThreadData::planewidth
int planewidth[4]
Definition: vf_identity.c:88
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:493
IdentityContext::rgba_map
uint8_t rgba_map[4]
Definition: vf_identity.c:44
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
scene_sad.h
compute_images_identity
static int compute_images_identity(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_identity.c:123
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
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_identity.c:244
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_identity.c:348
ff_vf_msad
const AVFilter ff_vf_msad
ff_scene_sad_fn
void(* ff_scene_sad_fn)(SCENE_SAD_PARAMS)
Definition: scene_sad.h:34
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
internal.h
ThreadData::score
uint64_t ** score
Definition: vf_identity.c:90
identity_line_8bit
static unsigned identity_line_8bit(const uint8_t *main_line, const uint8_t *ref_line, int outw)
Definition: vf_identity.c:61
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
options
static const AVOption options[]
Definition: vf_identity.c:394
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
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
IdentityContext::nb_threads
int nb_threads
Definition: vf_identity.c:48
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
ret
ret
Definition: filter_design.txt:187
IdentityContext::min_score
double min_score
Definition: vf_identity.c:40
activate
static int activate(AVFilterContext *ctx)
Definition: vf_identity.c:342
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_identity.c:235
framesync.h
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
IdentityContext::scores
uint64_t ** scores
Definition: vf_identity.c:51
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
ThreadData::main_linesize
int main_linesize[4]
Definition: vf_identity.c:86
identity_inputs
static const AVFilterPad identity_inputs[]
Definition: vf_identity.c:375
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
IdentityContext::planeheight
int planeheight[4]
Definition: vf_identity.c:50
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:73
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
IdentityContext::is_rgb
int is_rgb
Definition: vf_identity.c:42
ThreadData::nb_components
int nb_components
Definition: vf_identity.c:91
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
ThreadData::planeheight
int planeheight[4]
Definition: vf_identity.c:89
d
d
Definition: ffmpeg_filter.c:425
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
PF
#define PF(suf)
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
compute_images_msad
static int compute_images_msad(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_identity.c:95
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
IdentityContext::planewidth
int planewidth[4]
Definition: vf_identity.c:49
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
ThreadData::ref_data
const uint8_t * ref_data[4]
Definition: vf_identity.c:85
int
int
Definition: ffmpeg_filter.c:425
snprintf
#define snprintf
Definition: snprintf.h:34
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_identity.c:313
IdentityContext::score_comp
double score_comp[4]
Definition: vf_identity.c:40
ThreadData::main_data
const uint8_t * main_data[4]
Definition: vf_identity.c:84