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 "internal.h"
31 #include "video.h"
32 
33 typedef struct ThreadData {
34  AVFrame *m, *a, *d;
35 } ThreadData;
36 
37 typedef struct PreMultiplyContext {
38  const AVClass *class;
41  int nb_planes;
42  int planes;
43  int inverse;
44  int inplace;
45  int half, depth, offset, max;
47 
48  void (*premultiply[AV_VIDEO_MAX_PLANES])(const uint8_t *msrc, const uint8_t *asrc,
49  uint8_t *dst,
50  ptrdiff_t mlinesize, ptrdiff_t alinesize,
51  ptrdiff_t dlinesize,
52  int w, int h,
53  int half, int shift, int offset);
55 
56 #define OFFSET(x) offsetof(PreMultiplyContext, x)
57 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
58 
59 static const AVOption options[] = {
60  { "planes", "set planes", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF, FLAGS },
61  { "inplace","enable inplace mode", OFFSET(inplace), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
62  { NULL }
63 };
64 
65 AVFILTER_DEFINE_CLASS_EXT(premultiply, "(un)premultiply", options);
66 
68 {
69  PreMultiplyContext *s = ctx->priv;
70 
71  static const enum AVPixelFormat no_alpha_pix_fmts[] = {
80  };
81 
82  static const enum AVPixelFormat alpha_pix_fmts[] = {
88  };
89 
90  return ff_set_common_formats_from_list(ctx, s->inplace ? alpha_pix_fmts : no_alpha_pix_fmts);
91 }
92 
93 static void premultiply8(const uint8_t *msrc, const uint8_t *asrc,
94  uint8_t *dst,
95  ptrdiff_t mlinesize, ptrdiff_t alinesize,
96  ptrdiff_t dlinesize,
97  int w, int h,
98  int half, int shift, int offset)
99 {
100  int x, y;
101 
102  for (y = 0; y < h; y++) {
103  for (x = 0; x < w; x++) {
104  dst[x] = ((msrc[x] * (((asrc[x] >> 1) & 1) + asrc[x])) + 128) >> 8;
105  }
106 
107  dst += dlinesize;
108  msrc += mlinesize;
109  asrc += alinesize;
110  }
111 }
112 
113 static void premultiply8yuv(const uint8_t *msrc, const uint8_t *asrc,
114  uint8_t *dst,
115  ptrdiff_t mlinesize, ptrdiff_t alinesize,
116  ptrdiff_t dlinesize,
117  int w, int h,
118  int half, int shift, int offset)
119 {
120  int x, y;
121 
122  for (y = 0; y < h; y++) {
123  for (x = 0; x < w; x++) {
124  dst[x] = ((((msrc[x] - 128) * (((asrc[x] >> 1) & 1) + asrc[x]))) >> 8) + 128;
125  }
126 
127  dst += dlinesize;
128  msrc += mlinesize;
129  asrc += alinesize;
130  }
131 }
132 
133 static void premultiply8offset(const uint8_t *msrc, const uint8_t *asrc,
134  uint8_t *dst,
135  ptrdiff_t mlinesize, ptrdiff_t alinesize,
136  ptrdiff_t dlinesize,
137  int w, int h,
138  int half, int shift, int offset)
139 {
140  int x, y;
141 
142  for (y = 0; y < h; y++) {
143  for (x = 0; x < w; x++) {
144  dst[x] = ((((msrc[x] - offset) * (((asrc[x] >> 1) & 1) + asrc[x])) + 128) >> 8) + offset;
145  }
146 
147  dst += dlinesize;
148  msrc += mlinesize;
149  asrc += alinesize;
150  }
151 }
152 
153 static void premultiply16(const uint8_t *mmsrc, const uint8_t *aasrc,
154  uint8_t *ddst,
155  ptrdiff_t mlinesize, ptrdiff_t alinesize,
156  ptrdiff_t dlinesize,
157  int w, int h,
158  int half, int shift, int offset)
159 {
160  const uint16_t *msrc = (const uint16_t *)mmsrc;
161  const uint16_t *asrc = (const uint16_t *)aasrc;
162  uint16_t *dst = (uint16_t *)ddst;
163  int x, y;
164 
165  for (y = 0; y < h; y++) {
166  for (x = 0; x < w; x++) {
167  dst[x] = ((msrc[x] * (((asrc[x] >> 1) & 1) + asrc[x])) + half) >> shift;
168  }
169 
170  dst += dlinesize / 2;
171  msrc += mlinesize / 2;
172  asrc += alinesize / 2;
173  }
174 }
175 
176 static void premultiply16yuv(const uint8_t *mmsrc, const uint8_t *aasrc,
177  uint8_t *ddst,
178  ptrdiff_t mlinesize, ptrdiff_t alinesize,
179  ptrdiff_t dlinesize,
180  int w, int h,
181  int half, int shift, int offset)
182 {
183  const uint16_t *msrc = (const uint16_t *)mmsrc;
184  const uint16_t *asrc = (const uint16_t *)aasrc;
185  uint16_t *dst = (uint16_t *)ddst;
186  int x, y;
187 
188  for (y = 0; y < h; y++) {
189  for (x = 0; x < w; x++) {
190  dst[x] = ((((msrc[x] - half) * (int64_t)(((asrc[x] >> 1) & 1) + asrc[x]))) >> shift) + half;
191  }
192 
193  dst += dlinesize / 2;
194  msrc += mlinesize / 2;
195  asrc += alinesize / 2;
196  }
197 }
198 
199 static void premultiply16offset(const uint8_t *mmsrc, const uint8_t *aasrc,
200  uint8_t *ddst,
201  ptrdiff_t mlinesize, ptrdiff_t alinesize,
202  ptrdiff_t dlinesize,
203  int w, int h,
204  int half, int shift, int offset)
205 {
206  const uint16_t *msrc = (const uint16_t *)mmsrc;
207  const uint16_t *asrc = (const uint16_t *)aasrc;
208  uint16_t *dst = (uint16_t *)ddst;
209  int x, y;
210 
211  for (y = 0; y < h; y++) {
212  for (x = 0; x < w; x++) {
213  dst[x] = ((((msrc[x] - offset) * (int64_t)(((asrc[x] >> 1) & 1) + asrc[x])) + half) >> shift) + offset;
214  }
215 
216  dst += dlinesize / 2;
217  msrc += mlinesize / 2;
218  asrc += alinesize / 2;
219  }
220 }
221 
222 static void premultiplyf32(const uint8_t *mmsrc, const uint8_t *aasrc,
223  uint8_t *ddst,
224  ptrdiff_t mlinesize, ptrdiff_t alinesize,
225  ptrdiff_t dlinesize,
226  int w, int h,
227  int half, int shift, int offset)
228 {
229  const float *msrc = (const float *)mmsrc;
230  const float *asrc = (const float *)aasrc;
231  float *dst = (float *)ddst;
232  int x, y;
233 
234  for (y = 0; y < h; y++) {
235  for (x = 0; x < w; x++) {
236  dst[x] = msrc[x] * asrc[x];
237  }
238 
239  dst += dlinesize / 4;
240  msrc += mlinesize / 4;
241  asrc += alinesize / 4;
242  }
243 }
244 
245 static void premultiplyf32offset(const uint8_t *mmsrc, const uint8_t *aasrc,
246  uint8_t *ddst,
247  ptrdiff_t mlinesize, ptrdiff_t alinesize,
248  ptrdiff_t dlinesize,
249  int w, int h,
250  int half, int shift, int offset)
251 {
252  const float *msrc = (const float *)mmsrc;
253  const float *asrc = (const float *)aasrc;
254  float *dst = (float *)ddst;
255  int x, y;
256 
257  float offsetf = offset / 65535.0f;
258 
259  for (y = 0; y < h; y++) {
260  for (x = 0; x < w; x++) {
261  dst[x] = ((msrc[x] - offsetf) * asrc[x]) + offsetf;
262  }
263 
264  dst += dlinesize / 4;
265  msrc += mlinesize / 4;
266  asrc += alinesize / 4;
267  }
268 }
269 
270 static void unpremultiply8(const uint8_t *msrc, const uint8_t *asrc,
271  uint8_t *dst,
272  ptrdiff_t mlinesize, ptrdiff_t alinesize,
273  ptrdiff_t dlinesize,
274  int w, int h,
275  int half, int max, int offset)
276 {
277  int x, y;
278 
279  for (y = 0; y < h; y++) {
280  for (x = 0; x < w; x++) {
281  if (asrc[x] > 0 && asrc[x] < 255)
282  dst[x] = FFMIN(msrc[x] * 255 / asrc[x], 255);
283  else
284  dst[x] = msrc[x];
285  }
286 
287  dst += dlinesize;
288  msrc += mlinesize;
289  asrc += alinesize;
290  }
291 }
292 
293 static void unpremultiply8yuv(const uint8_t *msrc, const uint8_t *asrc,
294  uint8_t *dst,
295  ptrdiff_t mlinesize, ptrdiff_t alinesize,
296  ptrdiff_t dlinesize,
297  int w, int h,
298  int half, int max, int offset)
299 {
300  int x, y;
301 
302  for (y = 0; y < h; y++) {
303  for (x = 0; x < w; x++) {
304  if (asrc[x] > 0 && asrc[x] < 255)
305  dst[x] = FFMIN((msrc[x] - 128) * 255 / asrc[x] + 128, 255);
306  else
307  dst[x] = msrc[x];
308  }
309 
310  dst += dlinesize;
311  msrc += mlinesize;
312  asrc += alinesize;
313  }
314 }
315 
316 static void unpremultiply8offset(const uint8_t *msrc, const uint8_t *asrc,
317  uint8_t *dst,
318  ptrdiff_t mlinesize, ptrdiff_t alinesize,
319  ptrdiff_t dlinesize,
320  int w, int h,
321  int half, int max, int offset)
322 {
323  int x, y;
324 
325  for (y = 0; y < h; y++) {
326  for (x = 0; x < w; x++) {
327  if (asrc[x] > 0 && asrc[x] < 255)
328  dst[x] = FFMIN(FFMAX(msrc[x] - offset, 0) * 255 / asrc[x] + offset, 255);
329  else
330  dst[x] = msrc[x];
331  }
332 
333  dst += dlinesize;
334  msrc += mlinesize;
335  asrc += alinesize;
336  }
337 }
338 
339 static void unpremultiply16(const uint8_t *mmsrc, const uint8_t *aasrc,
340  uint8_t *ddst,
341  ptrdiff_t mlinesize, ptrdiff_t alinesize,
342  ptrdiff_t dlinesize,
343  int w, int h,
344  int half, int max, int offset)
345 {
346  const uint16_t *msrc = (const uint16_t *)mmsrc;
347  const uint16_t *asrc = (const uint16_t *)aasrc;
348  uint16_t *dst = (uint16_t *)ddst;
349  int x, y;
350 
351  for (y = 0; y < h; y++) {
352  for (x = 0; x < w; x++) {
353  if (asrc[x] > 0 && asrc[x] < max)
354  dst[x] = FFMIN(msrc[x] * (unsigned)max / asrc[x], max);
355  else
356  dst[x] = msrc[x];
357  }
358 
359  dst += dlinesize / 2;
360  msrc += mlinesize / 2;
361  asrc += alinesize / 2;
362  }
363 }
364 
365 static void unpremultiply16yuv(const uint8_t *mmsrc, const uint8_t *aasrc,
366  uint8_t *ddst,
367  ptrdiff_t mlinesize, ptrdiff_t alinesize,
368  ptrdiff_t dlinesize,
369  int w, int h,
370  int half, int max, int offset)
371 {
372  const uint16_t *msrc = (const uint16_t *)mmsrc;
373  const uint16_t *asrc = (const uint16_t *)aasrc;
374  uint16_t *dst = (uint16_t *)ddst;
375  int x, y;
376 
377  for (y = 0; y < h; y++) {
378  for (x = 0; x < w; x++) {
379  if (asrc[x] > 0 && asrc[x] < max)
380  dst[x] = FFMAX(FFMIN((msrc[x] - half) * max / asrc[x], half - 1), -half) + half;
381  else
382  dst[x] = msrc[x];
383  }
384 
385  dst += dlinesize / 2;
386  msrc += mlinesize / 2;
387  asrc += alinesize / 2;
388  }
389 }
390 
391 static void unpremultiply16offset(const uint8_t *mmsrc, const uint8_t *aasrc,
392  uint8_t *ddst,
393  ptrdiff_t mlinesize, ptrdiff_t alinesize,
394  ptrdiff_t dlinesize,
395  int w, int h,
396  int half, int max, int offset)
397 {
398  const uint16_t *msrc = (const uint16_t *)mmsrc;
399  const uint16_t *asrc = (const uint16_t *)aasrc;
400  uint16_t *dst = (uint16_t *)ddst;
401  int x, y;
402 
403  for (y = 0; y < h; y++) {
404  for (x = 0; x < w; x++) {
405  if (asrc[x] > 0 && asrc[x] < max)
406  dst[x] = FFMAX(FFMIN(FFMAX(msrc[x] - offset, 0) * (unsigned)max / asrc[x] + offset, max), 0);
407  else
408  dst[x] = msrc[x];
409  }
410 
411  dst += dlinesize / 2;
412  msrc += mlinesize / 2;
413  asrc += alinesize / 2;
414  }
415 }
416 
417 static void unpremultiplyf32(const uint8_t *mmsrc, const uint8_t *aasrc,
418  uint8_t *ddst,
419  ptrdiff_t mlinesize, ptrdiff_t alinesize,
420  ptrdiff_t dlinesize,
421  int w, int h,
422  int half, int max, int offset)
423 {
424  const float *msrc = (const float *)mmsrc;
425  const float *asrc = (const float *)aasrc;
426 
427  float *dst = (float *)ddst;
428  int x, y;
429 
430  for (y = 0; y < h; y++) {
431  for (x = 0; x < w; x++) {
432  if (asrc[x] > 0.0f)
433  dst[x] = msrc[x] / asrc[x];
434  else
435  dst[x] = msrc[x];
436  }
437 
438  dst += dlinesize / 4;
439  msrc += mlinesize / 4;
440  asrc += alinesize / 4;
441  }
442 }
443 
444 static void unpremultiplyf32offset(const uint8_t *mmsrc, const uint8_t *aasrc,
445  uint8_t *ddst,
446  ptrdiff_t mlinesize, ptrdiff_t alinesize,
447  ptrdiff_t dlinesize,
448  int w, int h,
449  int half, int max, int offset)
450 {
451  const float *msrc = (const float *)mmsrc;
452  const float *asrc = (const float *)aasrc;
453 
454  float *dst = (float *)ddst;
455  int x, y;
456 
457  float offsetf = offset / 65535.0f;
458 
459  for (y = 0; y < h; y++) {
460  for (x = 0; x < w; x++) {
461  if (asrc[x] > 0.0f)
462  dst[x] = (msrc[x] - offsetf) / asrc[x] + offsetf;
463  else
464  dst[x] = msrc[x];
465  }
466 
467  dst += dlinesize / 4;
468  msrc += mlinesize / 4;
469  asrc += alinesize / 4;
470  }
471 }
472 
473 static int premultiply_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
474 {
475  PreMultiplyContext *s = ctx->priv;
476  ThreadData *td = arg;
477  AVFrame *out = td->d;
478  AVFrame *alpha = td->a;
479  AVFrame *base = td->m;
480  int p;
481 
482  for (p = 0; p < s->nb_planes; p++) {
483  const int slice_start = (s->height[p] * jobnr) / nb_jobs;
484  const int slice_end = (s->height[p] * (jobnr+1)) / nb_jobs;
485 
486  if (!((1 << p) & s->planes) || p == 3) {
487  av_image_copy_plane(out->data[p] + slice_start * out->linesize[p],
488  out->linesize[p],
489  base->data[p] + slice_start * base->linesize[p],
490  base->linesize[p],
491  s->linesize[p], slice_end - slice_start);
492  continue;
493  }
494 
495  s->premultiply[p](base->data[p] + slice_start * base->linesize[p],
496  s->inplace ? alpha->data[3] + slice_start * alpha->linesize[3] :
497  alpha->data[0] + slice_start * alpha->linesize[0],
498  out->data[p] + slice_start * out->linesize[p],
499  base->linesize[p], s->inplace ? alpha->linesize[3] : alpha->linesize[0],
500  out->linesize[p],
501  s->width[p], slice_end - slice_start,
502  s->half, s->inverse ? s->max : s->depth, s->offset);
503  }
504 
505  return 0;
506 }
507 
510 {
511  PreMultiplyContext *s = ctx->priv;
512  AVFilterLink *outlink = ctx->outputs[0];
513 
514  if (ctx->is_disabled) {
515  *out = av_frame_clone(base);
516  if (!*out)
517  return AVERROR(ENOMEM);
518  } else {
519  ThreadData td;
520  int full, limited;
521 
522  *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
523  if (!*out)
524  return AVERROR(ENOMEM);
526 
527  full = base->color_range == AVCOL_RANGE_JPEG;
528  limited = base->color_range == AVCOL_RANGE_MPEG;
529 
530  if (s->inverse) {
531  switch (outlink->format) {
532  case AV_PIX_FMT_YUV444P:
533  case AV_PIX_FMT_YUVA444P:
534  s->premultiply[0] = full ? unpremultiply8 : unpremultiply8offset;
535  s->premultiply[1] = s->premultiply[2] = unpremultiply8yuv;
536  break;
537  case AV_PIX_FMT_YUVJ444P:
538  s->premultiply[0] = unpremultiply8;
539  s->premultiply[1] = s->premultiply[2] = unpremultiply8yuv;
540  break;
541  case AV_PIX_FMT_GBRP:
542  case AV_PIX_FMT_GBRAP:
543  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? unpremultiply8offset : unpremultiply8;
544  break;
545  case AV_PIX_FMT_YUV444P9:
554  s->premultiply[0] = full ? unpremultiply16 : unpremultiply16offset;
555  s->premultiply[1] = s->premultiply[2] = unpremultiply16yuv;
556  break;
557  case AV_PIX_FMT_GBRP9:
558  case AV_PIX_FMT_GBRP10:
559  case AV_PIX_FMT_GBRAP10:
560  case AV_PIX_FMT_GBRP12:
561  case AV_PIX_FMT_GBRAP12:
562  case AV_PIX_FMT_GBRP14:
563  case AV_PIX_FMT_GBRP16:
564  case AV_PIX_FMT_GBRAP16:
565  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? unpremultiply16offset : unpremultiply16;
566  break;
567  case AV_PIX_FMT_GBRPF32:
568  case AV_PIX_FMT_GBRAPF32:
569  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? unpremultiplyf32offset : unpremultiplyf32;
570  break;
571  case AV_PIX_FMT_GRAY8:
572  s->premultiply[0] = limited ? unpremultiply8offset : unpremultiply8;
573  break;
574  case AV_PIX_FMT_GRAY9:
575  case AV_PIX_FMT_GRAY10:
576  case AV_PIX_FMT_GRAY12:
577  case AV_PIX_FMT_GRAY14:
578  case AV_PIX_FMT_GRAY16:
579  s->premultiply[0] = limited ? unpremultiply16offset : unpremultiply16;
580  break;
581  }
582  } else {
583  switch (outlink->format) {
584  case AV_PIX_FMT_YUV444P:
585  case AV_PIX_FMT_YUVA444P:
586  s->premultiply[0] = full ? premultiply8 : premultiply8offset;
587  s->premultiply[1] = s->premultiply[2] = premultiply8yuv;
588  break;
589  case AV_PIX_FMT_YUVJ444P:
590  s->premultiply[0] = premultiply8;
591  s->premultiply[1] = s->premultiply[2] = premultiply8yuv;
592  break;
593  case AV_PIX_FMT_GBRP:
594  case AV_PIX_FMT_GBRAP:
595  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? premultiply8offset : premultiply8;
596  break;
597  case AV_PIX_FMT_YUV444P9:
606  s->premultiply[0] = full ? premultiply16 : premultiply16offset;
607  s->premultiply[1] = s->premultiply[2] = premultiply16yuv;
608  break;
609  case AV_PIX_FMT_GBRP9:
610  case AV_PIX_FMT_GBRP10:
611  case AV_PIX_FMT_GBRAP10:
612  case AV_PIX_FMT_GBRP12:
613  case AV_PIX_FMT_GBRAP12:
614  case AV_PIX_FMT_GBRP14:
615  case AV_PIX_FMT_GBRP16:
616  case AV_PIX_FMT_GBRAP16:
617  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? premultiply16offset : premultiply16;
618  break;
619  case AV_PIX_FMT_GBRPF32:
620  case AV_PIX_FMT_GBRAPF32:
621  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? premultiplyf32offset: premultiplyf32;
622  break;
623  case AV_PIX_FMT_GRAY8:
624  s->premultiply[0] = limited ? premultiply8offset : premultiply8;
625  break;
626  case AV_PIX_FMT_GRAY9:
627  case AV_PIX_FMT_GRAY10:
628  case AV_PIX_FMT_GRAY12:
629  case AV_PIX_FMT_GRAY14:
630  case AV_PIX_FMT_GRAY16:
631  s->premultiply[0] = limited ? premultiply16offset : premultiply16;
632  break;
633  }
634  }
635 
636  td.d = *out;
637  td.a = alpha;
638  td.m = base;
640  FFMIN(s->height[0], ff_filter_get_nb_threads(ctx)));
641  }
642 
643  return 0;
644 }
645 
647 {
648  AVFilterContext *ctx = fs->parent;
649  PreMultiplyContext *s = fs->opaque;
650  AVFilterLink *outlink = ctx->outputs[0];
651  AVFrame *out = NULL, *base, *alpha;
652  int ret;
653 
654  if ((ret = ff_framesync_get_frame(&s->fs, 0, &base, 0)) < 0 ||
655  (ret = ff_framesync_get_frame(&s->fs, 1, &alpha, 0)) < 0)
656  return ret;
657 
658  if ((ret = filter_frame(ctx, &out, base, alpha)) < 0)
659  return ret;
660 
661  out->pts = av_rescale_q(base->pts, s->fs.time_base, outlink->time_base);
662 
663  return ff_filter_frame(outlink, out);
664 }
665 
667 {
668  AVFilterContext *ctx = inlink->dst;
669  PreMultiplyContext *s = ctx->priv;
671  int vsub, hsub, ret;
672 
673  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
674 
675  if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
676  return ret;
677 
678  hsub = desc->log2_chroma_w;
679  vsub = desc->log2_chroma_h;
680  s->height[1] = s->height[2] = AV_CEIL_RSHIFT(inlink->h, vsub);
681  s->height[0] = s->height[3] = inlink->h;
682  s->width[1] = s->width[2] = AV_CEIL_RSHIFT(inlink->w, hsub);
683  s->width[0] = s->width[3] = inlink->w;
684 
685  s->depth = desc->flags & AV_PIX_FMT_FLAG_FLOAT ? 16 : desc->comp[0].depth;
686  s->max = (1 << s->depth) - 1;
687  s->half = (1 << s->depth) / 2;
688  s->offset = 16 << (s->depth - 8);
689 
690  return 0;
691 }
692 
693 static int config_output(AVFilterLink *outlink)
694 {
695  AVFilterContext *ctx = outlink->src;
696  PreMultiplyContext *s = ctx->priv;
697  AVFilterLink *base = ctx->inputs[0];
699  FFFrameSyncIn *in;
700  int ret;
701 
702  if (!s->inplace) {
703  alpha = ctx->inputs[1];
704 
705  if (base->w != alpha->w ||
706  base->h != alpha->h) {
707  av_log(ctx, AV_LOG_ERROR, "First input link %s parameters "
708  "(size %dx%d) do not match the corresponding "
709  "second input link %s parameters (%dx%d) ",
710  ctx->input_pads[0].name, base->w, base->h,
711  ctx->input_pads[1].name, alpha->w, alpha->h);
712  return AVERROR(EINVAL);
713  }
714  }
715 
716  outlink->w = base->w;
717  outlink->h = base->h;
718  outlink->time_base = base->time_base;
719  outlink->sample_aspect_ratio = base->sample_aspect_ratio;
720  outlink->frame_rate = base->frame_rate;
721 
722  if (s->inplace)
723  return 0;
724 
725  if ((ret = ff_framesync_init(&s->fs, ctx, 2)) < 0)
726  return ret;
727 
728  in = s->fs.in;
729  in[0].time_base = base->time_base;
730  in[1].time_base = alpha->time_base;
731  in[0].sync = 1;
732  in[0].before = EXT_STOP;
733  in[0].after = EXT_INFINITY;
734  in[1].sync = 1;
735  in[1].before = EXT_STOP;
736  in[1].after = EXT_INFINITY;
737  s->fs.opaque = s;
738  s->fs.on_event = process_frame;
739 
740  return ff_framesync_configure(&s->fs);
741 }
742 
744 {
745  PreMultiplyContext *s = ctx->priv;
746 
747  if (s->inplace) {
748  AVFrame *frame = NULL;
749  AVFrame *out = NULL;
750  int ret, status;
751  int64_t pts;
752 
754 
755  if ((ret = ff_inlink_consume_frame(ctx->inputs[0], &frame)) > 0) {
758  if (ret < 0)
759  return ret;
760  ret = ff_filter_frame(ctx->outputs[0], out);
761  }
762  if (ret < 0) {
763  return ret;
764  } else if (ff_inlink_acknowledge_status(ctx->inputs[0], &status, &pts)) {
765  ff_outlink_set_status(ctx->outputs[0], status, pts);
766  return 0;
767  } else {
768  if (ff_outlink_frame_wanted(ctx->outputs[0]))
769  ff_inlink_request_frame(ctx->inputs[0]);
770  return 0;
771  }
772  } else {
773  return ff_framesync_activate(&s->fs);
774  }
775 }
776 
778 {
779  PreMultiplyContext *s = ctx->priv;
780  AVFilterPad pad = { 0 };
781  int ret;
782 
783  if (!strcmp(ctx->filter->name, "unpremultiply"))
784  s->inverse = 1;
785 
786  pad.type = AVMEDIA_TYPE_VIDEO;
787  pad.name = "main";
789 
790  if ((ret = ff_append_inpad(ctx, &pad)) < 0)
791  return ret;
792 
793  if (!s->inplace) {
794  pad.type = AVMEDIA_TYPE_VIDEO;
795  pad.name = "alpha";
796  pad.config_props = NULL;
797 
798  if ((ret = ff_append_inpad(ctx, &pad)) < 0)
799  return ret;
800  }
801 
802  return 0;
803 }
804 
806 {
807  PreMultiplyContext *s = ctx->priv;
808 
809  if (!s->inplace)
810  ff_framesync_uninit(&s->fs);
811 }
812 
814  {
815  .name = "default",
816  .type = AVMEDIA_TYPE_VIDEO,
817  .config_props = config_output,
818  },
819 };
820 
821 #if CONFIG_PREMULTIPLY_FILTER
822 
823 const AVFilter ff_vf_premultiply = {
824  .name = "premultiply",
825  .description = NULL_IF_CONFIG_SMALL("PreMultiply first stream with first plane of second stream."),
826  .priv_size = sizeof(PreMultiplyContext),
827  .init = init,
828  .uninit = uninit,
829  .activate = activate,
830  .inputs = NULL,
833  .priv_class = &premultiply_class,
837 };
838 
839 #endif /* CONFIG_PREMULTIPLY_FILTER */
840 
841 #if CONFIG_UNPREMULTIPLY_FILTER
842 
844  .name = "unpremultiply",
845  .description = NULL_IF_CONFIG_SMALL("UnPreMultiply first stream with first plane of second stream."),
846  .priv_class = &premultiply_class,
847  .priv_size = sizeof(PreMultiplyContext),
848  .init = init,
849  .uninit = uninit,
850  .activate = activate,
851  .inputs = NULL,
857 };
858 
859 #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:112
PreMultiplyContext::offset
int offset
Definition: vf_premultiply.c:45
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:134
td
#define td
Definition: regdef.h:70
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:304
out
FILE * out
Definition: movenc.c:54
PreMultiplyContext::planes
int planes
Definition: vf_premultiply.c:42
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
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:267
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:365
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:130
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
PreMultiplyContext::depth
int depth
Definition: vf_premultiply.c:45
pixdesc.h
w
uint8_t w
Definition: llviddspenc.c:38
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:683
AVOption
AVOption.
Definition: opt.h:346
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:159
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:316
half
static uint8_t half(int a, int b)
Definition: mobiclip.c:538
PreMultiplyContext
Definition: vf_premultiply.c:37
base
uint8_t base
Definition: vp3data.h:128
PreMultiplyContext::linesize
int linesize[AV_VIDEO_MAX_PLANES]
Definition: vf_premultiply.c:40
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:417
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
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:73
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:1445
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3002
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:245
options
static const AVOption options[]
Definition: vf_premultiply.c:59
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:212
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
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:39
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:293
pts
static int64_t pts
Definition: transcode_aac.c:643
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:106
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:481
slice_start
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
Definition: vvcdec.c:694
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
premultiply_slice
static int premultiply_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_premultiply.c:473
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:189
process_frame
static int process_frame(FFFrameSync *fs)
Definition: vf_premultiply.c:646
ff_inlink_request_frame
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1571
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:58
PreMultiplyContext::half
int half
Definition: vf_premultiply.c:45
PreMultiplyContext::max
int max
Definition: vf_premultiply.c:45
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:1725
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:67
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:520
ctx
AVFormatContext * ctx
Definition: movenc.c:48
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:563
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:270
FLAGS
#define FLAGS
Definition: vf_premultiply.c:57
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
frame
static AVFrame * frame
Definition: demux_decode.c:54
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
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:199
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:679
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:133
AVFILTER_DEFINE_CLASS_EXT
AVFILTER_DEFINE_CLASS_EXT(premultiply, "(un)premultiply", options)
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_premultiply.c:777
OFFSET
#define OFFSET(x)
Definition: vf_premultiply.c:56
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:1392
ff_vf_premultiply
const AVFilter ff_vf_premultiply
activate
static int activate(AVFilterContext *ctx)
Definition: vf_premultiply.c:743
AVFilterPad::config_props
int(* config_props)(AVFilterLink *link)
Link configuration callback.
Definition: internal.h:113
f
f
Definition: af_crystalizer.c:121
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:106
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:222
shift
static int shift(int a, int b)
Definition: bonk.c:262
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:391
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:444
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:693
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:113
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:93
internal.h
ThreadData::d
void ** d
Definition: af_crystalizer.c:46
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_premultiply.c:805
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:48
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
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:339
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:666
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:477
AVFilter
Filter definition.
Definition: avfilter.h:166
ret
ret
Definition: filter_design.txt:187
AVFilterPad::type
enum AVMediaType type
AVFilterPad type.
Definition: internal.h:44
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:43
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:46
status
ov_status_e status
Definition: dnn_backend_openvino.c:120
framesync.h
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:176
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
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:153
ThreadData::a
AVFrame * a
Definition: vf_premultiply.c:34
premultiply_outputs
static const AVFilterPad premultiply_outputs[]
Definition: vf_premultiply.c:813
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:407
PreMultiplyContext::inplace
int inplace
Definition: vf_premultiply.c:44
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
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:666
planes
static const struct @386 planes[]
alpha
static const int16_t alpha[]
Definition: ilbcdata.h:55
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
PreMultiplyContext::nb_planes
int nb_planes
Definition: vf_premultiply.c:41
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
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:2038
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:355
PreMultiplyContext::width
int width[AV_VIDEO_MAX_PLANES]
Definition: vf_premultiply.c:39
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:508
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