FFmpeg
vf_premultiply.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 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 #include "config_components.h"
22 
23 #include "libavutil/imgutils.h"
24 #include "libavutil/pixdesc.h"
25 #include "libavutil/opt.h"
26 #include "avfilter.h"
27 #include "filters.h"
28 #include "formats.h"
29 #include "framesync.h"
30 #include "video.h"
31 
32 typedef struct ThreadData {
33  AVFrame *m, *a, *d;
34 } ThreadData;
35 
36 typedef struct PreMultiplyContext {
37  const AVClass *class;
40  int nb_planes;
41  int planes;
42  int inverse;
43  int inplace;
44  int half, depth, offset, max;
46 
47  void (*premultiply[AV_VIDEO_MAX_PLANES])(const uint8_t *msrc, const uint8_t *asrc,
48  uint8_t *dst,
49  ptrdiff_t mlinesize, ptrdiff_t alinesize,
50  ptrdiff_t dlinesize,
51  int w, int h,
52  int half, int shift, int offset);
54 
55 #define OFFSET(x) offsetof(PreMultiplyContext, x)
56 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
57 
58 static const AVOption options[] = {
59  { "planes", "set planes", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF, FLAGS },
60  { "inplace","enable inplace mode", OFFSET(inplace), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
61  { NULL }
62 };
63 
64 AVFILTER_DEFINE_CLASS_EXT(premultiply, "(un)premultiply", options);
65 
67 {
68  PreMultiplyContext *s = ctx->priv;
69 
70  static const enum AVPixelFormat no_alpha_pix_fmts[] = {
79  };
80 
81  static const enum AVPixelFormat alpha_pix_fmts[] = {
87  };
88 
89  return ff_set_common_formats_from_list(ctx, s->inplace ? alpha_pix_fmts : no_alpha_pix_fmts);
90 }
91 
92 static void premultiply8(const uint8_t *msrc, const uint8_t *asrc,
93  uint8_t *dst,
94  ptrdiff_t mlinesize, ptrdiff_t alinesize,
95  ptrdiff_t dlinesize,
96  int w, int h,
97  int half, int shift, int offset)
98 {
99  int x, y;
100 
101  for (y = 0; y < h; y++) {
102  for (x = 0; x < w; x++) {
103  dst[x] = ((msrc[x] * (((asrc[x] >> 1) & 1) + asrc[x])) + 128) >> 8;
104  }
105 
106  dst += dlinesize;
107  msrc += mlinesize;
108  asrc += alinesize;
109  }
110 }
111 
112 static void premultiply8yuv(const uint8_t *msrc, const uint8_t *asrc,
113  uint8_t *dst,
114  ptrdiff_t mlinesize, ptrdiff_t alinesize,
115  ptrdiff_t dlinesize,
116  int w, int h,
117  int half, int shift, int offset)
118 {
119  int x, y;
120 
121  for (y = 0; y < h; y++) {
122  for (x = 0; x < w; x++) {
123  dst[x] = ((((msrc[x] - 128) * (((asrc[x] >> 1) & 1) + asrc[x]))) >> 8) + 128;
124  }
125 
126  dst += dlinesize;
127  msrc += mlinesize;
128  asrc += alinesize;
129  }
130 }
131 
132 static void premultiply8offset(const uint8_t *msrc, const uint8_t *asrc,
133  uint8_t *dst,
134  ptrdiff_t mlinesize, ptrdiff_t alinesize,
135  ptrdiff_t dlinesize,
136  int w, int h,
137  int half, int shift, int offset)
138 {
139  int x, y;
140 
141  for (y = 0; y < h; y++) {
142  for (x = 0; x < w; x++) {
143  dst[x] = ((((msrc[x] - offset) * (((asrc[x] >> 1) & 1) + asrc[x])) + 128) >> 8) + offset;
144  }
145 
146  dst += dlinesize;
147  msrc += mlinesize;
148  asrc += alinesize;
149  }
150 }
151 
152 static void premultiply16(const uint8_t *mmsrc, const uint8_t *aasrc,
153  uint8_t *ddst,
154  ptrdiff_t mlinesize, ptrdiff_t alinesize,
155  ptrdiff_t dlinesize,
156  int w, int h,
157  int half, int shift, int offset)
158 {
159  const uint16_t *msrc = (const uint16_t *)mmsrc;
160  const uint16_t *asrc = (const uint16_t *)aasrc;
161  uint16_t *dst = (uint16_t *)ddst;
162  int x, y;
163 
164  for (y = 0; y < h; y++) {
165  for (x = 0; x < w; x++) {
166  dst[x] = ((msrc[x] * (((asrc[x] >> 1) & 1) + asrc[x])) + half) >> shift;
167  }
168 
169  dst += dlinesize / 2;
170  msrc += mlinesize / 2;
171  asrc += alinesize / 2;
172  }
173 }
174 
175 static void premultiply16yuv(const uint8_t *mmsrc, const uint8_t *aasrc,
176  uint8_t *ddst,
177  ptrdiff_t mlinesize, ptrdiff_t alinesize,
178  ptrdiff_t dlinesize,
179  int w, int h,
180  int half, int shift, int offset)
181 {
182  const uint16_t *msrc = (const uint16_t *)mmsrc;
183  const uint16_t *asrc = (const uint16_t *)aasrc;
184  uint16_t *dst = (uint16_t *)ddst;
185  int x, y;
186 
187  for (y = 0; y < h; y++) {
188  for (x = 0; x < w; x++) {
189  dst[x] = ((((msrc[x] - half) * (int64_t)(((asrc[x] >> 1) & 1) + asrc[x]))) >> shift) + half;
190  }
191 
192  dst += dlinesize / 2;
193  msrc += mlinesize / 2;
194  asrc += alinesize / 2;
195  }
196 }
197 
198 static void premultiply16offset(const uint8_t *mmsrc, const uint8_t *aasrc,
199  uint8_t *ddst,
200  ptrdiff_t mlinesize, ptrdiff_t alinesize,
201  ptrdiff_t dlinesize,
202  int w, int h,
203  int half, int shift, int offset)
204 {
205  const uint16_t *msrc = (const uint16_t *)mmsrc;
206  const uint16_t *asrc = (const uint16_t *)aasrc;
207  uint16_t *dst = (uint16_t *)ddst;
208  int x, y;
209 
210  for (y = 0; y < h; y++) {
211  for (x = 0; x < w; x++) {
212  dst[x] = ((((msrc[x] - offset) * (int64_t)(((asrc[x] >> 1) & 1) + asrc[x])) + half) >> shift) + offset;
213  }
214 
215  dst += dlinesize / 2;
216  msrc += mlinesize / 2;
217  asrc += alinesize / 2;
218  }
219 }
220 
221 static void premultiplyf32(const uint8_t *mmsrc, const uint8_t *aasrc,
222  uint8_t *ddst,
223  ptrdiff_t mlinesize, ptrdiff_t alinesize,
224  ptrdiff_t dlinesize,
225  int w, int h,
226  int half, int shift, int offset)
227 {
228  const float *msrc = (const float *)mmsrc;
229  const float *asrc = (const float *)aasrc;
230  float *dst = (float *)ddst;
231  int x, y;
232 
233  for (y = 0; y < h; y++) {
234  for (x = 0; x < w; x++) {
235  dst[x] = msrc[x] * asrc[x];
236  }
237 
238  dst += dlinesize / 4;
239  msrc += mlinesize / 4;
240  asrc += alinesize / 4;
241  }
242 }
243 
244 static void premultiplyf32offset(const uint8_t *mmsrc, const uint8_t *aasrc,
245  uint8_t *ddst,
246  ptrdiff_t mlinesize, ptrdiff_t alinesize,
247  ptrdiff_t dlinesize,
248  int w, int h,
249  int half, int shift, int offset)
250 {
251  const float *msrc = (const float *)mmsrc;
252  const float *asrc = (const float *)aasrc;
253  float *dst = (float *)ddst;
254  int x, y;
255 
256  float offsetf = offset / 65535.0f;
257 
258  for (y = 0; y < h; y++) {
259  for (x = 0; x < w; x++) {
260  dst[x] = ((msrc[x] - offsetf) * asrc[x]) + offsetf;
261  }
262 
263  dst += dlinesize / 4;
264  msrc += mlinesize / 4;
265  asrc += alinesize / 4;
266  }
267 }
268 
269 static void unpremultiply8(const uint8_t *msrc, const uint8_t *asrc,
270  uint8_t *dst,
271  ptrdiff_t mlinesize, ptrdiff_t alinesize,
272  ptrdiff_t dlinesize,
273  int w, int h,
274  int half, int max, int offset)
275 {
276  int x, y;
277 
278  for (y = 0; y < h; y++) {
279  for (x = 0; x < w; x++) {
280  if (asrc[x] > 0 && asrc[x] < 255)
281  dst[x] = FFMIN(msrc[x] * 255 / asrc[x], 255);
282  else
283  dst[x] = msrc[x];
284  }
285 
286  dst += dlinesize;
287  msrc += mlinesize;
288  asrc += alinesize;
289  }
290 }
291 
292 static void unpremultiply8yuv(const uint8_t *msrc, const uint8_t *asrc,
293  uint8_t *dst,
294  ptrdiff_t mlinesize, ptrdiff_t alinesize,
295  ptrdiff_t dlinesize,
296  int w, int h,
297  int half, int max, int offset)
298 {
299  int x, y;
300 
301  for (y = 0; y < h; y++) {
302  for (x = 0; x < w; x++) {
303  if (asrc[x] > 0 && asrc[x] < 255)
304  dst[x] = FFMIN((msrc[x] - 128) * 255 / asrc[x] + 128, 255);
305  else
306  dst[x] = msrc[x];
307  }
308 
309  dst += dlinesize;
310  msrc += mlinesize;
311  asrc += alinesize;
312  }
313 }
314 
315 static void unpremultiply8offset(const uint8_t *msrc, const uint8_t *asrc,
316  uint8_t *dst,
317  ptrdiff_t mlinesize, ptrdiff_t alinesize,
318  ptrdiff_t dlinesize,
319  int w, int h,
320  int half, int max, int offset)
321 {
322  int x, y;
323 
324  for (y = 0; y < h; y++) {
325  for (x = 0; x < w; x++) {
326  if (asrc[x] > 0 && asrc[x] < 255)
327  dst[x] = FFMIN(FFMAX(msrc[x] - offset, 0) * 255 / asrc[x] + offset, 255);
328  else
329  dst[x] = msrc[x];
330  }
331 
332  dst += dlinesize;
333  msrc += mlinesize;
334  asrc += alinesize;
335  }
336 }
337 
338 static void unpremultiply16(const uint8_t *mmsrc, const uint8_t *aasrc,
339  uint8_t *ddst,
340  ptrdiff_t mlinesize, ptrdiff_t alinesize,
341  ptrdiff_t dlinesize,
342  int w, int h,
343  int half, int max, int offset)
344 {
345  const uint16_t *msrc = (const uint16_t *)mmsrc;
346  const uint16_t *asrc = (const uint16_t *)aasrc;
347  uint16_t *dst = (uint16_t *)ddst;
348  int x, y;
349 
350  for (y = 0; y < h; y++) {
351  for (x = 0; x < w; x++) {
352  if (asrc[x] > 0 && asrc[x] < max)
353  dst[x] = FFMIN(msrc[x] * (unsigned)max / asrc[x], max);
354  else
355  dst[x] = msrc[x];
356  }
357 
358  dst += dlinesize / 2;
359  msrc += mlinesize / 2;
360  asrc += alinesize / 2;
361  }
362 }
363 
364 static void unpremultiply16yuv(const uint8_t *mmsrc, const uint8_t *aasrc,
365  uint8_t *ddst,
366  ptrdiff_t mlinesize, ptrdiff_t alinesize,
367  ptrdiff_t dlinesize,
368  int w, int h,
369  int half, int max, int offset)
370 {
371  const uint16_t *msrc = (const uint16_t *)mmsrc;
372  const uint16_t *asrc = (const uint16_t *)aasrc;
373  uint16_t *dst = (uint16_t *)ddst;
374  int x, y;
375 
376  for (y = 0; y < h; y++) {
377  for (x = 0; x < w; x++) {
378  if (asrc[x] > 0 && asrc[x] < max)
379  dst[x] = FFMAX(FFMIN((msrc[x] - half) * max / asrc[x], half - 1), -half) + half;
380  else
381  dst[x] = msrc[x];
382  }
383 
384  dst += dlinesize / 2;
385  msrc += mlinesize / 2;
386  asrc += alinesize / 2;
387  }
388 }
389 
390 static void unpremultiply16offset(const uint8_t *mmsrc, const uint8_t *aasrc,
391  uint8_t *ddst,
392  ptrdiff_t mlinesize, ptrdiff_t alinesize,
393  ptrdiff_t dlinesize,
394  int w, int h,
395  int half, int max, int offset)
396 {
397  const uint16_t *msrc = (const uint16_t *)mmsrc;
398  const uint16_t *asrc = (const uint16_t *)aasrc;
399  uint16_t *dst = (uint16_t *)ddst;
400  int x, y;
401 
402  for (y = 0; y < h; y++) {
403  for (x = 0; x < w; x++) {
404  if (asrc[x] > 0 && asrc[x] < max)
405  dst[x] = FFMAX(FFMIN(FFMAX(msrc[x] - offset, 0) * (unsigned)max / asrc[x] + offset, max), 0);
406  else
407  dst[x] = msrc[x];
408  }
409 
410  dst += dlinesize / 2;
411  msrc += mlinesize / 2;
412  asrc += alinesize / 2;
413  }
414 }
415 
416 static void unpremultiplyf32(const uint8_t *mmsrc, const uint8_t *aasrc,
417  uint8_t *ddst,
418  ptrdiff_t mlinesize, ptrdiff_t alinesize,
419  ptrdiff_t dlinesize,
420  int w, int h,
421  int half, int max, int offset)
422 {
423  const float *msrc = (const float *)mmsrc;
424  const float *asrc = (const float *)aasrc;
425 
426  float *dst = (float *)ddst;
427  int x, y;
428 
429  for (y = 0; y < h; y++) {
430  for (x = 0; x < w; x++) {
431  if (asrc[x] > 0.0f)
432  dst[x] = msrc[x] / asrc[x];
433  else
434  dst[x] = msrc[x];
435  }
436 
437  dst += dlinesize / 4;
438  msrc += mlinesize / 4;
439  asrc += alinesize / 4;
440  }
441 }
442 
443 static void unpremultiplyf32offset(const uint8_t *mmsrc, const uint8_t *aasrc,
444  uint8_t *ddst,
445  ptrdiff_t mlinesize, ptrdiff_t alinesize,
446  ptrdiff_t dlinesize,
447  int w, int h,
448  int half, int max, int offset)
449 {
450  const float *msrc = (const float *)mmsrc;
451  const float *asrc = (const float *)aasrc;
452 
453  float *dst = (float *)ddst;
454  int x, y;
455 
456  float offsetf = offset / 65535.0f;
457 
458  for (y = 0; y < h; y++) {
459  for (x = 0; x < w; x++) {
460  if (asrc[x] > 0.0f)
461  dst[x] = (msrc[x] - offsetf) / asrc[x] + offsetf;
462  else
463  dst[x] = msrc[x];
464  }
465 
466  dst += dlinesize / 4;
467  msrc += mlinesize / 4;
468  asrc += alinesize / 4;
469  }
470 }
471 
472 static int premultiply_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
473 {
474  PreMultiplyContext *s = ctx->priv;
475  ThreadData *td = arg;
476  AVFrame *out = td->d;
477  AVFrame *alpha = td->a;
478  AVFrame *base = td->m;
479  int p;
480 
481  for (p = 0; p < s->nb_planes; p++) {
482  const int slice_start = (s->height[p] * jobnr) / nb_jobs;
483  const int slice_end = (s->height[p] * (jobnr+1)) / nb_jobs;
484 
485  if (!((1 << p) & s->planes) || p == 3) {
486  av_image_copy_plane(out->data[p] + slice_start * out->linesize[p],
487  out->linesize[p],
488  base->data[p] + slice_start * base->linesize[p],
489  base->linesize[p],
490  s->linesize[p], slice_end - slice_start);
491  continue;
492  }
493 
494  s->premultiply[p](base->data[p] + slice_start * base->linesize[p],
495  s->inplace ? alpha->data[3] + slice_start * alpha->linesize[3] :
496  alpha->data[0] + slice_start * alpha->linesize[0],
497  out->data[p] + slice_start * out->linesize[p],
498  base->linesize[p], s->inplace ? alpha->linesize[3] : alpha->linesize[0],
499  out->linesize[p],
500  s->width[p], slice_end - slice_start,
501  s->half, s->inverse ? s->max : s->depth, s->offset);
502  }
503 
504  return 0;
505 }
506 
509 {
510  PreMultiplyContext *s = ctx->priv;
511  AVFilterLink *outlink = ctx->outputs[0];
512 
513  if (ctx->is_disabled) {
514  *out = av_frame_clone(base);
515  if (!*out)
516  return AVERROR(ENOMEM);
517  } else {
518  ThreadData td;
519  int full, limited;
520 
521  *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
522  if (!*out)
523  return AVERROR(ENOMEM);
525 
526  full = base->color_range == AVCOL_RANGE_JPEG;
527  limited = base->color_range == AVCOL_RANGE_MPEG;
528 
529  if (s->inverse) {
530  switch (outlink->format) {
531  case AV_PIX_FMT_YUV444P:
532  case AV_PIX_FMT_YUVA444P:
533  s->premultiply[0] = full ? unpremultiply8 : unpremultiply8offset;
534  s->premultiply[1] = s->premultiply[2] = unpremultiply8yuv;
535  break;
536  case AV_PIX_FMT_YUVJ444P:
537  s->premultiply[0] = unpremultiply8;
538  s->premultiply[1] = s->premultiply[2] = unpremultiply8yuv;
539  break;
540  case AV_PIX_FMT_GBRP:
541  case AV_PIX_FMT_GBRAP:
542  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? unpremultiply8offset : unpremultiply8;
543  break;
544  case AV_PIX_FMT_YUV444P9:
553  s->premultiply[0] = full ? unpremultiply16 : unpremultiply16offset;
554  s->premultiply[1] = s->premultiply[2] = unpremultiply16yuv;
555  break;
556  case AV_PIX_FMT_GBRP9:
557  case AV_PIX_FMT_GBRP10:
558  case AV_PIX_FMT_GBRAP10:
559  case AV_PIX_FMT_GBRP12:
560  case AV_PIX_FMT_GBRAP12:
561  case AV_PIX_FMT_GBRP14:
562  case AV_PIX_FMT_GBRP16:
563  case AV_PIX_FMT_GBRAP16:
564  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? unpremultiply16offset : unpremultiply16;
565  break;
566  case AV_PIX_FMT_GBRPF32:
567  case AV_PIX_FMT_GBRAPF32:
568  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? unpremultiplyf32offset : unpremultiplyf32;
569  break;
570  case AV_PIX_FMT_GRAY8:
571  s->premultiply[0] = limited ? unpremultiply8offset : unpremultiply8;
572  break;
573  case AV_PIX_FMT_GRAY9:
574  case AV_PIX_FMT_GRAY10:
575  case AV_PIX_FMT_GRAY12:
576  case AV_PIX_FMT_GRAY14:
577  case AV_PIX_FMT_GRAY16:
578  s->premultiply[0] = limited ? unpremultiply16offset : unpremultiply16;
579  break;
580  }
581  } else {
582  switch (outlink->format) {
583  case AV_PIX_FMT_YUV444P:
584  case AV_PIX_FMT_YUVA444P:
585  s->premultiply[0] = full ? premultiply8 : premultiply8offset;
586  s->premultiply[1] = s->premultiply[2] = premultiply8yuv;
587  break;
588  case AV_PIX_FMT_YUVJ444P:
589  s->premultiply[0] = premultiply8;
590  s->premultiply[1] = s->premultiply[2] = premultiply8yuv;
591  break;
592  case AV_PIX_FMT_GBRP:
593  case AV_PIX_FMT_GBRAP:
594  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? premultiply8offset : premultiply8;
595  break;
596  case AV_PIX_FMT_YUV444P9:
605  s->premultiply[0] = full ? premultiply16 : premultiply16offset;
606  s->premultiply[1] = s->premultiply[2] = premultiply16yuv;
607  break;
608  case AV_PIX_FMT_GBRP9:
609  case AV_PIX_FMT_GBRP10:
610  case AV_PIX_FMT_GBRAP10:
611  case AV_PIX_FMT_GBRP12:
612  case AV_PIX_FMT_GBRAP12:
613  case AV_PIX_FMT_GBRP14:
614  case AV_PIX_FMT_GBRP16:
615  case AV_PIX_FMT_GBRAP16:
616  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? premultiply16offset : premultiply16;
617  break;
618  case AV_PIX_FMT_GBRPF32:
619  case AV_PIX_FMT_GBRAPF32:
620  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? premultiplyf32offset: premultiplyf32;
621  break;
622  case AV_PIX_FMT_GRAY8:
623  s->premultiply[0] = limited ? premultiply8offset : premultiply8;
624  break;
625  case AV_PIX_FMT_GRAY9:
626  case AV_PIX_FMT_GRAY10:
627  case AV_PIX_FMT_GRAY12:
628  case AV_PIX_FMT_GRAY14:
629  case AV_PIX_FMT_GRAY16:
630  s->premultiply[0] = limited ? premultiply16offset : premultiply16;
631  break;
632  }
633  }
634 
635  td.d = *out;
636  td.a = alpha;
637  td.m = base;
639  FFMIN(s->height[0], ff_filter_get_nb_threads(ctx)));
640  }
641 
642  return 0;
643 }
644 
646 {
647  AVFilterContext *ctx = fs->parent;
648  PreMultiplyContext *s = fs->opaque;
649  AVFilterLink *outlink = ctx->outputs[0];
650  AVFrame *out = NULL, *base, *alpha;
651  int ret;
652 
653  if ((ret = ff_framesync_get_frame(&s->fs, 0, &base, 0)) < 0 ||
654  (ret = ff_framesync_get_frame(&s->fs, 1, &alpha, 0)) < 0)
655  return ret;
656 
657  if ((ret = filter_frame(ctx, &out, base, alpha)) < 0)
658  return ret;
659 
660  out->pts = av_rescale_q(base->pts, s->fs.time_base, outlink->time_base);
661 
662  return ff_filter_frame(outlink, out);
663 }
664 
666 {
667  AVFilterContext *ctx = inlink->dst;
668  PreMultiplyContext *s = ctx->priv;
670  int vsub, hsub, ret;
671 
672  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
673 
674  if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
675  return ret;
676 
677  hsub = desc->log2_chroma_w;
678  vsub = desc->log2_chroma_h;
679  s->height[1] = s->height[2] = AV_CEIL_RSHIFT(inlink->h, vsub);
680  s->height[0] = s->height[3] = inlink->h;
681  s->width[1] = s->width[2] = AV_CEIL_RSHIFT(inlink->w, hsub);
682  s->width[0] = s->width[3] = inlink->w;
683 
684  s->depth = desc->flags & AV_PIX_FMT_FLAG_FLOAT ? 16 : desc->comp[0].depth;
685  s->max = (1 << s->depth) - 1;
686  s->half = (1 << s->depth) / 2;
687  s->offset = 16 << (s->depth - 8);
688 
689  return 0;
690 }
691 
692 static int config_output(AVFilterLink *outlink)
693 {
694  AVFilterContext *ctx = outlink->src;
695  PreMultiplyContext *s = ctx->priv;
696  AVFilterLink *base = ctx->inputs[0];
699  FilterLink *ol = ff_filter_link(outlink);
700  FFFrameSyncIn *in;
701  int ret;
702 
703  if (!s->inplace) {
704  alpha = ctx->inputs[1];
705 
706  if (base->w != alpha->w ||
707  base->h != alpha->h) {
708  av_log(ctx, AV_LOG_ERROR, "First input link %s parameters "
709  "(size %dx%d) do not match the corresponding "
710  "second input link %s parameters (%dx%d) ",
711  ctx->input_pads[0].name, base->w, base->h,
712  ctx->input_pads[1].name, alpha->w, alpha->h);
713  return AVERROR(EINVAL);
714  }
715  }
716 
717  outlink->w = base->w;
718  outlink->h = base->h;
719  outlink->time_base = base->time_base;
720  outlink->sample_aspect_ratio = base->sample_aspect_ratio;
721  ol->frame_rate = il->frame_rate;
722 
723  if (s->inplace)
724  return 0;
725 
726  if ((ret = ff_framesync_init(&s->fs, ctx, 2)) < 0)
727  return ret;
728 
729  in = s->fs.in;
730  in[0].time_base = base->time_base;
731  in[1].time_base = alpha->time_base;
732  in[0].sync = 1;
733  in[0].before = EXT_STOP;
734  in[0].after = EXT_INFINITY;
735  in[1].sync = 1;
736  in[1].before = EXT_STOP;
737  in[1].after = EXT_INFINITY;
738  s->fs.opaque = s;
739  s->fs.on_event = process_frame;
740 
741  return ff_framesync_configure(&s->fs);
742 }
743 
745 {
746  PreMultiplyContext *s = ctx->priv;
747 
748  if (s->inplace) {
749  AVFrame *frame = NULL;
750  AVFrame *out = NULL;
751  int ret, status;
752  int64_t pts;
753 
755 
756  if ((ret = ff_inlink_consume_frame(ctx->inputs[0], &frame)) > 0) {
759  if (ret < 0)
760  return ret;
761  ret = ff_filter_frame(ctx->outputs[0], out);
762  }
763  if (ret < 0) {
764  return ret;
765  } else if (ff_inlink_acknowledge_status(ctx->inputs[0], &status, &pts)) {
766  ff_outlink_set_status(ctx->outputs[0], status, pts);
767  return 0;
768  } else {
769  if (ff_outlink_frame_wanted(ctx->outputs[0]))
770  ff_inlink_request_frame(ctx->inputs[0]);
771  return 0;
772  }
773  } else {
774  return ff_framesync_activate(&s->fs);
775  }
776 }
777 
779 {
780  PreMultiplyContext *s = ctx->priv;
781  AVFilterPad pad = { 0 };
782  int ret;
783 
784  if (!strcmp(ctx->filter->name, "unpremultiply"))
785  s->inverse = 1;
786 
787  pad.type = AVMEDIA_TYPE_VIDEO;
788  pad.name = "main";
790 
791  if ((ret = ff_append_inpad(ctx, &pad)) < 0)
792  return ret;
793 
794  if (!s->inplace) {
795  pad.type = AVMEDIA_TYPE_VIDEO;
796  pad.name = "alpha";
797  pad.config_props = NULL;
798 
799  if ((ret = ff_append_inpad(ctx, &pad)) < 0)
800  return ret;
801  }
802 
803  return 0;
804 }
805 
807 {
808  PreMultiplyContext *s = ctx->priv;
809 
810  if (!s->inplace)
811  ff_framesync_uninit(&s->fs);
812 }
813 
815  {
816  .name = "default",
817  .type = AVMEDIA_TYPE_VIDEO,
818  .config_props = config_output,
819  },
820 };
821 
822 #if CONFIG_PREMULTIPLY_FILTER
823 
824 const AVFilter ff_vf_premultiply = {
825  .name = "premultiply",
826  .description = NULL_IF_CONFIG_SMALL("PreMultiply first stream with first plane of second stream."),
827  .priv_size = sizeof(PreMultiplyContext),
828  .init = init,
829  .uninit = uninit,
830  .activate = activate,
831  .inputs = NULL,
834  .priv_class = &premultiply_class,
838 };
839 
840 #endif /* CONFIG_PREMULTIPLY_FILTER */
841 
842 #if CONFIG_UNPREMULTIPLY_FILTER
843 
845  .name = "unpremultiply",
846  .description = NULL_IF_CONFIG_SMALL("UnPreMultiply first stream with first plane of second stream."),
847  .priv_class = &premultiply_class,
848  .priv_size = sizeof(PreMultiplyContext),
849  .init = init,
850  .uninit = uninit,
851  .activate = activate,
852  .inputs = NULL,
858 };
859 
860 #endif /* CONFIG_UNPREMULTIPLY_FILTER */
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:116
PreMultiplyContext::offset
int offset
Definition: vf_premultiply.c:44
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:501
FFFrameSyncIn::time_base
AVRational time_base
Time base for the incoming frames.
Definition: framesync.h:117
ff_framesync_configure
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:137
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
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:302
out
FILE * out
Definition: movenc.c:55
PreMultiplyContext::planes
int planes
Definition: vf_premultiply.c:41
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1025
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2965
ff_framesync_get_frame
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
Definition: framesync.c:270
int64_t
long long int64_t
Definition: coverity.c:34
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
AV_VIDEO_MAX_PLANES
#define AV_VIDEO_MAX_PLANES
Maximum number of planes in any pixel format.
Definition: pixfmt.h:40
AV_PIX_FMT_FLAG_FLOAT
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
Definition: pixdesc.h:158
unpremultiply16yuv
static void unpremultiply16yuv(const uint8_t *mmsrc, const uint8_t *aasrc, uint8_t *ddst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int max, int offset)
Definition: vf_premultiply.c:364
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:162
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
PreMultiplyContext::depth
int depth
Definition: vf_premultiply.c:44
pixdesc.h
w
uint8_t w
Definition: llviddspenc.c:38
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:686
AVOption
AVOption.
Definition: opt.h:429
unpremultiply8offset
static void unpremultiply8offset(const uint8_t *msrc, const uint8_t *asrc, uint8_t *dst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int max, int offset)
Definition: vf_premultiply.c:315
half
static uint8_t half(int a, int b)
Definition: mobiclip.c:539
PreMultiplyContext
Definition: vf_premultiply.c:36
base
uint8_t base
Definition: vp3data.h:128
PreMultiplyContext::linesize
int linesize[AV_VIDEO_MAX_PLANES]
Definition: vf_premultiply.c:39
max
#define max(a, b)
Definition: cuda_runtime.h:33
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
unpremultiplyf32
static void unpremultiplyf32(const uint8_t *mmsrc, const uint8_t *aasrc, uint8_t *ddst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int max, int offset)
Definition: vf_premultiply.c:416
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:205
FFFrameSync
Frame sync structure.
Definition: framesync.h:168
EXT_INFINITY
@ EXT_INFINITY
Extend the frame to infinity.
Definition: framesync.h:75
video.h
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:458
av_image_copy_plane
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Definition: imgutils.c:374
hsub
static void hsub(htype *dst, const htype *src, int bins)
Definition: vf_median.c:74
formats.h
ff_inlink_consume_frame
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Definition: avfilter.c:1453
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3005
premultiplyf32offset
static void premultiplyf32offset(const uint8_t *mmsrc, const uint8_t *aasrc, uint8_t *ddst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int shift, int offset)
Definition: vf_premultiply.c:244
options
static const AVOption options[]
Definition: vf_premultiply.c:58
EXT_STOP
@ EXT_STOP
Completely stop all streams with this one.
Definition: framesync.h:65
FF_FILTER_FORWARD_STATUS_BACK_ALL
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
Definition: filters.h:447
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:496
ff_append_inpad
int ff_append_inpad(AVFilterContext *f, AVFilterPad *p)
Append a new input/output pad to the filter's list of such pads.
Definition: avfilter.c:126
ff_vf_unpremultiply
const AVFilter ff_vf_unpremultiply
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
Definition: mpeg12dec.c:1719
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
PreMultiplyContext::height
int height[AV_VIDEO_MAX_PLANES]
Definition: vf_premultiply.c:38
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:494
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:523
FFFrameSyncIn
Input stream structure.
Definition: framesync.h:102
unpremultiply8yuv
static void unpremultiply8yuv(const uint8_t *msrc, const uint8_t *asrc, uint8_t *dst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int max, int offset)
Definition: vf_premultiply.c:292
pts
static int64_t pts
Definition: transcode_aac.c:644
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:462
FFFrameSyncIn::sync
unsigned sync
Synchronization level: frames on input at the highest sync level will generate output frame events.
Definition: framesync.h:160
AVFILTER_FLAG_DYNAMIC_INPUTS
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
Definition: avfilter.h:141
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:38
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:481
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
av_cold
#define av_cold
Definition: attributes.h:90
premultiply_slice
static int premultiply_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_premultiply.c:472
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:498
ff_outlink_set_status
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
Definition: filters.h:424
process_frame
static int process_frame(FFFrameSync *fs)
Definition: vf_premultiply.c:645
ff_inlink_request_frame
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1580
av_image_fill_linesizes
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
Definition: imgutils.c:89
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:499
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:491
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:60
PreMultiplyContext::half
int half
Definition: vf_premultiply.c:44
PreMultiplyContext::max
int max
Definition: vf_premultiply.c:44
ff_set_common_formats_from_list
int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts)
Equivalent to ff_set_common_formats(ctx, ff_make_format_list(fmts))
Definition: formats.c:873
filters.h
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_premultiply.c:66
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:520
ctx
AVFormatContext * ctx
Definition: movenc.c:49
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:461
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:597
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
unpremultiply8
static void unpremultiply8(const uint8_t *msrc, const uint8_t *asrc, uint8_t *dst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int max, int offset)
Definition: vf_premultiply.c:269
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
FLAGS
#define FLAGS
Definition: vf_premultiply.c:56
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:75
premultiply16offset
static void premultiply16offset(const uint8_t *mmsrc, const uint8_t *aasrc, uint8_t *ddst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int shift, int offset)
Definition: vf_premultiply.c:198
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:713
fs
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:200
premultiply8offset
static void premultiply8offset(const uint8_t *msrc, const uint8_t *asrc, uint8_t *dst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int shift, int offset)
Definition: vf_premultiply.c:132
AVFILTER_DEFINE_CLASS_EXT
AVFILTER_DEFINE_CLASS_EXT(premultiply, "(un)premultiply", options)
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_premultiply.c:778
OFFSET
#define OFFSET(x)
Definition: vf_premultiply.c:55
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
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
ff_inlink_acknowledge_status
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
Definition: avfilter.c:1400
ff_vf_premultiply
const AVFilter ff_vf_premultiply
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:197
activate
static int activate(AVFilterContext *ctx)
Definition: vf_premultiply.c:744
AVFilterPad::config_props
int(* config_props)(AVFilterLink *link)
Link configuration callback.
Definition: filters.h:118
f
f
Definition: af_crystalizer.c:122
ThreadData::m
AVFrame * m
Definition: vf_maskedclamp.c:34
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:94
premultiplyf32
static void premultiplyf32(const uint8_t *mmsrc, const uint8_t *aasrc, uint8_t *ddst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int shift, int offset)
Definition: vf_premultiply.c:221
shift
static int shift(int a, int b)
Definition: bonk.c:261
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
unpremultiply16offset
static void unpremultiply16offset(const uint8_t *mmsrc, const uint8_t *aasrc, uint8_t *ddst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int max, int offset)
Definition: vf_premultiply.c:390
unpremultiplyf32offset
static void unpremultiplyf32offset(const uint8_t *mmsrc, const uint8_t *aasrc, uint8_t *ddst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int max, int offset)
Definition: vf_premultiply.c:443
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:508
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:485
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_premultiply.c:692
premultiply8yuv
static void premultiply8yuv(const uint8_t *msrc, const uint8_t *asrc, uint8_t *dst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int shift, int offset)
Definition: vf_premultiply.c:112
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:174
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:518
offset
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 offset
Definition: writing_filters.txt:86
premultiply8
static void premultiply8(const uint8_t *msrc, const uint8_t *asrc, uint8_t *dst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int shift, int offset)
Definition: vf_premultiply.c:92
ThreadData::d
void ** d
Definition: af_crystalizer.c:47
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_premultiply.c:806
PreMultiplyContext::premultiply
void(* premultiply[AV_VIDEO_MAX_PLANES])(const uint8_t *msrc, const uint8_t *asrc, uint8_t *dst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int shift, int offset)
Definition: vf_premultiply.c:47
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:836
ThreadData
Used for passing data between threads.
Definition: dsddec.c:71
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
unpremultiply16
static void unpremultiply16(const uint8_t *mmsrc, const uint8_t *aasrc, uint8_t *ddst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int max, int offset)
Definition: vf_premultiply.c:338
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:44
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:669
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:477
slice_start
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
Definition: dec.c:737
AVFilter
Filter definition.
Definition: avfilter.h:201
ret
ret
Definition: filter_design.txt:187
AVFilterPad::type
enum AVMediaType type
AVFilterPad type.
Definition: filters.h:49
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:515
ff_framesync_init
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
Definition: framesync.c:86
PreMultiplyContext::inverse
int inverse
Definition: vf_premultiply.c:42
FFFrameSyncIn::before
enum FFFrameSyncExtMode before
Extrapolation mode for timestamps before the first frame.
Definition: framesync.h:107
PreMultiplyContext::fs
FFFrameSync fs
Definition: vf_premultiply.c:45
status
ov_status_e status
Definition: dnn_backend_openvino.c:100
framesync.h
ff_filter_execute
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: avfilter.c:1653
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
premultiply16yuv
static void premultiply16yuv(const uint8_t *mmsrc, const uint8_t *aasrc, uint8_t *ddst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int shift, int offset)
Definition: vf_premultiply.c:175
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avfilter.h
AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:509
premultiply16
static void premultiply16(const uint8_t *mmsrc, const uint8_t *aasrc, uint8_t *ddst, ptrdiff_t mlinesize, ptrdiff_t alinesize, ptrdiff_t dlinesize, int w, int h, int half, int shift, int offset)
Definition: vf_premultiply.c:152
ThreadData::a
AVFrame * a
Definition: vf_premultiply.c:33
premultiply_outputs
static const AVFilterPad premultiply_outputs[]
Definition: vf_premultiply.c:814
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
PreMultiplyContext::inplace
int inplace
Definition: vf_premultiply.c:43
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:152
desc
const char * desc
Definition: libsvtav1.c:79
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
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_premultiply.c:665
alpha
static const int16_t alpha[]
Definition: ilbcdata.h:55
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
PreMultiplyContext::nb_planes
int nb_planes
Definition: vf_premultiply.c:40
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:190
imgutils.h
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
FFFrameSyncIn::after
enum FFFrameSyncExtMode after
Extrapolation mode for timestamps after the last frame.
Definition: framesync.h:112
h
h
Definition: vp9dsp_template.c:2070
ff_outlink_frame_wanted
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:488
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:353
PreMultiplyContext::width
int width[AV_VIDEO_MAX_PLANES]
Definition: vf_premultiply.c:38
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:460
alpha_pix_fmts
static enum AVPixelFormat alpha_pix_fmts[]
Definition: vf_overlay.c:157
filter_frame
static int filter_frame(AVFilterContext *ctx, AVFrame **out, AVFrame *base, AVFrame *alpha)
Definition: vf_premultiply.c:507
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: filters.h:236
planes
static const struct @458 planes[]