FFmpeg  4.4.4
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 "libavutil/imgutils.h"
22 #include "libavutil/pixdesc.h"
23 #include "libavutil/opt.h"
24 #include "avfilter.h"
25 #include "filters.h"
26 #include "formats.h"
27 #include "framesync.h"
28 #include "internal.h"
29 #include "video.h"
30 
31 typedef struct ThreadData {
32  AVFrame *m, *a, *d;
33 } ThreadData;
34 
35 typedef struct PreMultiplyContext {
36  const AVClass *class;
37  int width[4], height[4];
38  int linesize[4];
39  int nb_planes;
40  int planes;
41  int inverse;
42  int inplace;
43  int half, depth, offset, max;
45 
46  void (*premultiply[4])(const uint8_t *msrc, const uint8_t *asrc,
47  uint8_t *dst,
48  ptrdiff_t mlinesize, ptrdiff_t alinesize,
49  ptrdiff_t dlinesize,
50  int w, int h,
51  int half, int shift, int offset);
53 
54 #define OFFSET(x) offsetof(PreMultiplyContext, x)
55 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
56 
57 static const AVOption options[] = {
58  { "planes", "set planes", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF, FLAGS },
59  { "inplace","enable inplace mode", OFFSET(inplace), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
60  { NULL }
61 };
62 
63 #define premultiply_options options
64 AVFILTER_DEFINE_CLASS(premultiply);
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(ctx, ff_make_format_list(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;
638  ctx->internal->execute(ctx, premultiply_slice, &td, NULL, FFMIN(s->height[0],
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 
665 static int config_input(AVFilterLink *inlink)
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];
698  FFFrameSyncIn *in;
699  int ret;
700 
701  if (!s->inplace) {
702  alpha = ctx->inputs[1];
703 
704  if (base->format != alpha->format) {
705  av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n");
706  return AVERROR(EINVAL);
707  }
708  if (base->w != alpha->w ||
709  base->h != alpha->h) {
710  av_log(ctx, AV_LOG_ERROR, "First input link %s parameters "
711  "(size %dx%d) do not match the corresponding "
712  "second input link %s parameters (%dx%d) ",
713  ctx->input_pads[0].name, base->w, base->h,
714  ctx->input_pads[1].name, alpha->w, alpha->h);
715  return AVERROR(EINVAL);
716  }
717  }
718 
719  outlink->w = base->w;
720  outlink->h = base->h;
721  outlink->time_base = base->time_base;
722  outlink->sample_aspect_ratio = base->sample_aspect_ratio;
723  outlink->frame_rate = base->frame_rate;
724 
725  if (s->inplace)
726  return 0;
727 
728  if ((ret = ff_framesync_init(&s->fs, ctx, 2)) < 0)
729  return ret;
730 
731  in = s->fs.in;
732  in[0].time_base = base->time_base;
733  in[1].time_base = alpha->time_base;
734  in[0].sync = 1;
735  in[0].before = EXT_STOP;
736  in[0].after = EXT_INFINITY;
737  in[1].sync = 1;
738  in[1].before = EXT_STOP;
739  in[1].after = EXT_INFINITY;
740  s->fs.opaque = s;
741  s->fs.on_event = process_frame;
742 
743  return ff_framesync_configure(&s->fs);
744 }
745 
747 {
748  PreMultiplyContext *s = ctx->priv;
749 
750  if (s->inplace) {
751  AVFrame *frame = NULL;
752  AVFrame *out = NULL;
753  int ret, status;
754  int64_t pts;
755 
757 
758  if ((ret = ff_inlink_consume_frame(ctx->inputs[0], &frame)) > 0) {
759  ret = filter_frame(ctx, &out, frame, frame);
761  if (ret < 0)
762  return ret;
763  ret = ff_filter_frame(ctx->outputs[0], out);
764  }
765  if (ret < 0) {
766  return ret;
767  } else if (ff_inlink_acknowledge_status(ctx->inputs[0], &status, &pts)) {
768  ff_outlink_set_status(ctx->outputs[0], status, pts);
769  return 0;
770  } else {
771  if (ff_outlink_frame_wanted(ctx->outputs[0]))
772  ff_inlink_request_frame(ctx->inputs[0]);
773  return 0;
774  }
775  } else {
776  return ff_framesync_activate(&s->fs);
777  }
778 }
779 
781 {
782  PreMultiplyContext *s = ctx->priv;
783  AVFilterPad pad = { 0 };
784  int ret;
785 
786  if (!strcmp(ctx->filter->name, "unpremultiply"))
787  s->inverse = 1;
788 
789  pad.type = AVMEDIA_TYPE_VIDEO;
790  pad.name = "main";
792 
793  if ((ret = ff_insert_inpad(ctx, 0, &pad)) < 0)
794  return ret;
795 
796  if (!s->inplace) {
797  pad.type = AVMEDIA_TYPE_VIDEO;
798  pad.name = "alpha";
799  pad.config_props = NULL;
800 
801  if ((ret = ff_insert_inpad(ctx, 1, &pad)) < 0)
802  return ret;
803  }
804 
805  return 0;
806 }
807 
809 {
810  PreMultiplyContext *s = ctx->priv;
811 
812  if (!s->inplace)
813  ff_framesync_uninit(&s->fs);
814 }
815 
817  {
818  .name = "default",
819  .type = AVMEDIA_TYPE_VIDEO,
820  .config_props = config_output,
821  },
822  { NULL }
823 };
824 
825 #if CONFIG_PREMULTIPLY_FILTER
826 
828  .name = "premultiply",
829  .description = NULL_IF_CONFIG_SMALL("PreMultiply first stream with first plane of second stream."),
830  .priv_size = sizeof(PreMultiplyContext),
831  .init = init,
832  .uninit = uninit,
834  .activate = activate,
835  .inputs = NULL,
837  .priv_class = &premultiply_class,
841 };
842 
843 #endif /* CONFIG_PREMULTIPLY_FILTER */
844 
845 #if CONFIG_UNPREMULTIPLY_FILTER
846 
847 #define unpremultiply_options options
848 AVFILTER_DEFINE_CLASS(unpremultiply);
849 
851  .name = "unpremultiply",
852  .description = NULL_IF_CONFIG_SMALL("UnPreMultiply first stream with first plane of second stream."),
853  .priv_size = sizeof(PreMultiplyContext),
854  .init = init,
855  .uninit = uninit,
857  .activate = activate,
858  .inputs = NULL,
860  .priv_class = &unpremultiply_class,
864 };
865 
866 #endif /* CONFIG_UNPREMULTIPLY_FILTER */
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
AVFilter ff_vf_unpremultiply
AVFilter ff_vf_premultiply
#define av_cold
Definition: attributes.h:88
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
uint8_t
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:1449
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1096
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:802
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:1494
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1620
Main libavfilter public API header.
#define flags(name, subs,...)
Definition: cbs_av1.c:561
#define s(width, name)
Definition: cbs_vp9.c:257
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:259
#define FFMIN(a, b)
Definition: common.h:105
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
#define FFMAX(a, b)
Definition: common.h:103
#define NULL
Definition: coverity.c:32
#define max(a, b)
Definition: cuda_runtime.h:33
static AVFrame * frame
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
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
Definition: filters.h:212
static int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
Definition: filters.h:172
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:587
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:286
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:124
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
Definition: framesync.c:341
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
Definition: framesync.c:253
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:290
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
Definition: framesync.c:84
@ EXT_STOP
Completely stop all streams with this one.
Definition: framesync.h:65
@ EXT_INFINITY
Extend the frame to infinity.
Definition: framesync.h:75
@ AV_OPT_TYPE_INT
Definition: opt.h:225
@ AV_OPT_TYPE_BOOL
Definition: opt.h:242
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:134
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
Definition: avfilter.h:106
#define AVERROR(e)
Definition: error.h:43
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:540
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:658
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
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
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
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:373
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
static const int16_t alpha[]
Definition: ilbcdata.h:55
misc image utilities
const char * arg
Definition: jacosubdec.c:66
static int ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.
Definition: internal.h:240
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
const char * desc
Definition: libsvtav1.c:79
uint8_t w
Definition: llviddspenc.c:39
static const struct @322 planes[]
static uint8_t half(int a, int b)
Definition: mobiclip.c:541
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2033
AVOptions.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2613
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2573
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
Definition: pixdesc.h:190
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:420
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:428
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:406
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:398
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:379
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:421
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:414
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:569
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:586
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:438
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:415
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:381
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:416
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:177
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:380
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:382
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:383
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:419
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:443
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:418
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:409
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:435
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:417
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:440
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:429
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:412
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:402
#define td
Definition: regdef.h:70
typedef void(RENAME(mix_any_func_type))
static int shift(int a, int b)
Definition: sonic.c:82
Describe the class of an AVClass context structure.
Definition: log.h:67
An instance of a filter.
Definition: avfilter.h:341
A filter pad used for either input or output.
Definition: internal.h:54
int(* config_props)(AVFilterLink *link)
Link configuration callback.
Definition: internal.h:118
enum AVMediaType type
AVFilterPad type.
Definition: internal.h:65
const char * name
Pad name.
Definition: internal.h:60
Filter definition.
Definition: avfilter.h:145
const char * name
Filter name.
Definition: avfilter.h:149
AVFormatInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1699
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
AVOption.
Definition: opt.h:248
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
Input stream structure.
Definition: framesync.h:81
Frame sync structure.
Definition: framesync.h:146
void(* premultiply[4])(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)
Used for passing data between threads.
Definition: dsddec.c:67
AVFrame * m
AVFrame * a
#define av_log(a,...)
FILE * out
Definition: movenc.c:54
AVFormatContext * ctx
Definition: movenc.c:48
static int64_t pts
static void hsub(htype *dst, const htype *src, int bins)
Definition: vf_median.c:75
static enum AVPixelFormat alpha_pix_fmts[]
Definition: vf_overlay.c:155
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)
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)
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)
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)
static const AVOption options[]
static const AVFilterPad premultiply_outputs[]
static int query_formats(AVFilterContext *ctx)
static int config_input(AVFilterLink *inlink)
#define FLAGS
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)
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)
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)
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)
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)
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)
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)
AVFILTER_DEFINE_CLASS(premultiply)
static int activate(AVFilterContext *ctx)
static av_cold int init(AVFilterContext *ctx)
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)
static av_cold void uninit(AVFilterContext *ctx)
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)
#define OFFSET(x)
static int config_output(AVFilterLink *outlink)
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)
static int premultiply_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int process_frame(FFFrameSync *fs)
static int filter_frame(AVFilterContext *ctx, AVFrame **out, AVFrame *base, AVFrame *alpha)
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)
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)
static const uint8_t offset[127][2]
Definition: vf_spp.c:107
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:104
uint8_t base
Definition: vp3data.h:141