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 "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 unpremultiply8(const uint8_t *msrc, const uint8_t *asrc,
222  uint8_t *dst,
223  ptrdiff_t mlinesize, ptrdiff_t alinesize,
224  ptrdiff_t dlinesize,
225  int w, int h,
226  int half, int max, int offset)
227 {
228  int x, y;
229 
230  for (y = 0; y < h; y++) {
231  for (x = 0; x < w; x++) {
232  if (asrc[x] > 0 && asrc[x] < 255)
233  dst[x] = FFMIN(msrc[x] * 255 / asrc[x], 255);
234  else
235  dst[x] = msrc[x];
236  }
237 
238  dst += dlinesize;
239  msrc += mlinesize;
240  asrc += alinesize;
241  }
242 }
243 
244 static void unpremultiply8yuv(const uint8_t *msrc, const uint8_t *asrc,
245  uint8_t *dst,
246  ptrdiff_t mlinesize, ptrdiff_t alinesize,
247  ptrdiff_t dlinesize,
248  int w, int h,
249  int half, int max, int offset)
250 {
251  int x, y;
252 
253  for (y = 0; y < h; y++) {
254  for (x = 0; x < w; x++) {
255  if (asrc[x] > 0 && asrc[x] < 255)
256  dst[x] = FFMIN((msrc[x] - 128) * 255 / asrc[x] + 128, 255);
257  else
258  dst[x] = msrc[x];
259  }
260 
261  dst += dlinesize;
262  msrc += mlinesize;
263  asrc += alinesize;
264  }
265 }
266 
267 static void unpremultiply8offset(const uint8_t *msrc, const uint8_t *asrc,
268  uint8_t *dst,
269  ptrdiff_t mlinesize, ptrdiff_t alinesize,
270  ptrdiff_t dlinesize,
271  int w, int h,
272  int half, int max, int offset)
273 {
274  int x, y;
275 
276  for (y = 0; y < h; y++) {
277  for (x = 0; x < w; x++) {
278  if (asrc[x] > 0 && asrc[x] < 255)
279  dst[x] = FFMIN(FFMAX(msrc[x] - offset, 0) * 255 / asrc[x] + offset, 255);
280  else
281  dst[x] = msrc[x];
282  }
283 
284  dst += dlinesize;
285  msrc += mlinesize;
286  asrc += alinesize;
287  }
288 }
289 
290 static void unpremultiply16(const uint8_t *mmsrc, const uint8_t *aasrc,
291  uint8_t *ddst,
292  ptrdiff_t mlinesize, ptrdiff_t alinesize,
293  ptrdiff_t dlinesize,
294  int w, int h,
295  int half, int max, int offset)
296 {
297  const uint16_t *msrc = (const uint16_t *)mmsrc;
298  const uint16_t *asrc = (const uint16_t *)aasrc;
299  uint16_t *dst = (uint16_t *)ddst;
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] < max)
305  dst[x] = FFMIN(msrc[x] * (unsigned)max / asrc[x], max);
306  else
307  dst[x] = msrc[x];
308  }
309 
310  dst += dlinesize / 2;
311  msrc += mlinesize / 2;
312  asrc += alinesize / 2;
313  }
314 }
315 
316 static void unpremultiply16yuv(const uint8_t *mmsrc, const uint8_t *aasrc,
317  uint8_t *ddst,
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  const uint16_t *msrc = (const uint16_t *)mmsrc;
324  const uint16_t *asrc = (const uint16_t *)aasrc;
325  uint16_t *dst = (uint16_t *)ddst;
326  int x, y;
327 
328  for (y = 0; y < h; y++) {
329  for (x = 0; x < w; x++) {
330  if (asrc[x] > 0 && asrc[x] < max)
331  dst[x] = FFMAX(FFMIN((msrc[x] - half) * max / asrc[x], half - 1), -half) + half;
332  else
333  dst[x] = msrc[x];
334  }
335 
336  dst += dlinesize / 2;
337  msrc += mlinesize / 2;
338  asrc += alinesize / 2;
339  }
340 }
341 
342 static void unpremultiply16offset(const uint8_t *mmsrc, const uint8_t *aasrc,
343  uint8_t *ddst,
344  ptrdiff_t mlinesize, ptrdiff_t alinesize,
345  ptrdiff_t dlinesize,
346  int w, int h,
347  int half, int max, int offset)
348 {
349  const uint16_t *msrc = (const uint16_t *)mmsrc;
350  const uint16_t *asrc = (const uint16_t *)aasrc;
351  uint16_t *dst = (uint16_t *)ddst;
352  int x, y;
353 
354  for (y = 0; y < h; y++) {
355  for (x = 0; x < w; x++) {
356  if (asrc[x] > 0 && asrc[x] < max)
357  dst[x] = FFMAX(FFMIN(FFMAX(msrc[x] - offset, 0) * (unsigned)max / asrc[x] + offset, max), 0);
358  else
359  dst[x] = msrc[x];
360  }
361 
362  dst += dlinesize / 2;
363  msrc += mlinesize / 2;
364  asrc += alinesize / 2;
365  }
366 }
367 
368 static int premultiply_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
369 {
370  PreMultiplyContext *s = ctx->priv;
371  ThreadData *td = arg;
372  AVFrame *out = td->d;
373  AVFrame *alpha = td->a;
374  AVFrame *base = td->m;
375  int p;
376 
377  for (p = 0; p < s->nb_planes; p++) {
378  const int slice_start = (s->height[p] * jobnr) / nb_jobs;
379  const int slice_end = (s->height[p] * (jobnr+1)) / nb_jobs;
380 
381  if (!((1 << p) & s->planes) || p == 3) {
382  av_image_copy_plane(out->data[p] + slice_start * out->linesize[p],
383  out->linesize[p],
384  base->data[p] + slice_start * base->linesize[p],
385  base->linesize[p],
386  s->linesize[p], slice_end - slice_start);
387  continue;
388  }
389 
390  s->premultiply[p](base->data[p] + slice_start * base->linesize[p],
391  s->inplace ? alpha->data[3] + slice_start * alpha->linesize[3] :
392  alpha->data[0] + slice_start * alpha->linesize[0],
393  out->data[p] + slice_start * out->linesize[p],
394  base->linesize[p], s->inplace ? alpha->linesize[3] : alpha->linesize[0],
395  out->linesize[p],
396  s->width[p], slice_end - slice_start,
397  s->half, s->inverse ? s->max : s->depth, s->offset);
398  }
399 
400  return 0;
401 }
402 
405 {
406  PreMultiplyContext *s = ctx->priv;
407  AVFilterLink *outlink = ctx->outputs[0];
408 
409  if (ctx->is_disabled) {
410  *out = av_frame_clone(base);
411  if (!*out)
412  return AVERROR(ENOMEM);
413  } else {
414  ThreadData td;
415  int full, limited;
416 
417  *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
418  if (!*out)
419  return AVERROR(ENOMEM);
421 
422  full = base->color_range == AVCOL_RANGE_JPEG;
423  limited = base->color_range == AVCOL_RANGE_MPEG;
424 
425  if (s->inverse) {
426  switch (outlink->format) {
427  case AV_PIX_FMT_YUV444P:
428  case AV_PIX_FMT_YUVA444P:
429  s->premultiply[0] = full ? unpremultiply8 : unpremultiply8offset;
430  s->premultiply[1] = s->premultiply[2] = unpremultiply8yuv;
431  break;
432  case AV_PIX_FMT_YUVJ444P:
433  s->premultiply[0] = unpremultiply8;
434  s->premultiply[1] = s->premultiply[2] = unpremultiply8yuv;
435  break;
436  case AV_PIX_FMT_GBRP:
437  case AV_PIX_FMT_GBRAP:
438  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? unpremultiply8offset : unpremultiply8;
439  break;
440  case AV_PIX_FMT_YUV444P9:
448  s->premultiply[0] = full ? unpremultiply16 : unpremultiply16offset;
449  s->premultiply[1] = s->premultiply[2] = unpremultiply16yuv;
450  break;
451  case AV_PIX_FMT_GBRP9:
452  case AV_PIX_FMT_GBRP10:
453  case AV_PIX_FMT_GBRAP10:
454  case AV_PIX_FMT_GBRP12:
455  case AV_PIX_FMT_GBRAP12:
456  case AV_PIX_FMT_GBRP14:
457  case AV_PIX_FMT_GBRP16:
458  case AV_PIX_FMT_GBRAP16:
459  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? unpremultiply16offset : unpremultiply16;
460  break;
461  case AV_PIX_FMT_GRAY8:
462  s->premultiply[0] = limited ? unpremultiply8offset : unpremultiply8;
463  break;
464  case AV_PIX_FMT_GRAY9:
465  case AV_PIX_FMT_GRAY10:
466  case AV_PIX_FMT_GRAY12:
467  case AV_PIX_FMT_GRAY14:
468  case AV_PIX_FMT_GRAY16:
469  s->premultiply[0] = limited ? unpremultiply16offset : unpremultiply16;
470  break;
471  }
472  } else {
473  switch (outlink->format) {
474  case AV_PIX_FMT_YUV444P:
475  case AV_PIX_FMT_YUVA444P:
476  s->premultiply[0] = full ? premultiply8 : premultiply8offset;
477  s->premultiply[1] = s->premultiply[2] = premultiply8yuv;
478  break;
479  case AV_PIX_FMT_YUVJ444P:
480  s->premultiply[0] = premultiply8;
481  s->premultiply[1] = s->premultiply[2] = premultiply8yuv;
482  break;
483  case AV_PIX_FMT_GBRP:
484  case AV_PIX_FMT_GBRAP:
485  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? premultiply8offset : premultiply8;
486  break;
487  case AV_PIX_FMT_YUV444P9:
495  s->premultiply[0] = full ? premultiply16 : premultiply16offset;
496  s->premultiply[1] = s->premultiply[2] = premultiply16yuv;
497  break;
498  case AV_PIX_FMT_GBRP9:
499  case AV_PIX_FMT_GBRP10:
500  case AV_PIX_FMT_GBRAP10:
501  case AV_PIX_FMT_GBRP12:
502  case AV_PIX_FMT_GBRAP12:
503  case AV_PIX_FMT_GBRP14:
504  case AV_PIX_FMT_GBRP16:
505  case AV_PIX_FMT_GBRAP16:
506  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? premultiply16offset : premultiply16;
507  break;
508  case AV_PIX_FMT_GRAY8:
509  s->premultiply[0] = limited ? premultiply8offset : premultiply8;
510  break;
511  case AV_PIX_FMT_GRAY9:
512  case AV_PIX_FMT_GRAY10:
513  case AV_PIX_FMT_GRAY12:
514  case AV_PIX_FMT_GRAY14:
515  case AV_PIX_FMT_GRAY16:
516  s->premultiply[0] = limited ? premultiply16offset : premultiply16;
517  break;
518  }
519  }
520 
521  td.d = *out;
522  td.a = alpha;
523  td.m = base;
524  ctx->internal->execute(ctx, premultiply_slice, &td, NULL, FFMIN(s->height[0],
526  }
527 
528  return 0;
529 }
530 
532 {
533  AVFilterContext *ctx = fs->parent;
534  PreMultiplyContext *s = fs->opaque;
535  AVFilterLink *outlink = ctx->outputs[0];
536  AVFrame *out = NULL, *base, *alpha;
537  int ret;
538 
539  if ((ret = ff_framesync_get_frame(&s->fs, 0, &base, 0)) < 0 ||
540  (ret = ff_framesync_get_frame(&s->fs, 1, &alpha, 0)) < 0)
541  return ret;
542 
543  if ((ret = filter_frame(ctx, &out, base, alpha)) < 0)
544  return ret;
545 
546  out->pts = av_rescale_q(base->pts, s->fs.time_base, outlink->time_base);
547 
548  return ff_filter_frame(outlink, out);
549 }
550 
552 {
553  AVFilterContext *ctx = inlink->dst;
554  PreMultiplyContext *s = ctx->priv;
556  int vsub, hsub, ret;
557 
558  s->nb_planes = av_pix_fmt_count_planes(inlink->format);
559 
560  if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
561  return ret;
562 
563  hsub = desc->log2_chroma_w;
564  vsub = desc->log2_chroma_h;
565  s->height[1] = s->height[2] = AV_CEIL_RSHIFT(inlink->h, vsub);
566  s->height[0] = s->height[3] = inlink->h;
567  s->width[1] = s->width[2] = AV_CEIL_RSHIFT(inlink->w, hsub);
568  s->width[0] = s->width[3] = inlink->w;
569 
570  s->depth = desc->comp[0].depth;
571  s->max = (1 << s->depth) - 1;
572  s->half = (1 << s->depth) / 2;
573  s->offset = 16 << (s->depth - 8);
574 
575  return 0;
576 }
577 
578 static int config_output(AVFilterLink *outlink)
579 {
580  AVFilterContext *ctx = outlink->src;
581  PreMultiplyContext *s = ctx->priv;
582  AVFilterLink *base = ctx->inputs[0];
584  FFFrameSyncIn *in;
585  int ret;
586 
587  if (!s->inplace) {
588  alpha = ctx->inputs[1];
589 
590  if (base->format != alpha->format) {
591  av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n");
592  return AVERROR(EINVAL);
593  }
594  if (base->w != alpha->w ||
595  base->h != alpha->h) {
596  av_log(ctx, AV_LOG_ERROR, "First input link %s parameters "
597  "(size %dx%d) do not match the corresponding "
598  "second input link %s parameters (%dx%d) ",
599  ctx->input_pads[0].name, base->w, base->h,
600  ctx->input_pads[1].name, alpha->w, alpha->h);
601  return AVERROR(EINVAL);
602  }
603  }
604 
605  outlink->w = base->w;
606  outlink->h = base->h;
607  outlink->time_base = base->time_base;
608  outlink->sample_aspect_ratio = base->sample_aspect_ratio;
609  outlink->frame_rate = base->frame_rate;
610 
611  if (s->inplace)
612  return 0;
613 
614  if ((ret = ff_framesync_init(&s->fs, ctx, 2)) < 0)
615  return ret;
616 
617  in = s->fs.in;
618  in[0].time_base = base->time_base;
619  in[1].time_base = alpha->time_base;
620  in[0].sync = 1;
621  in[0].before = EXT_STOP;
622  in[0].after = EXT_INFINITY;
623  in[1].sync = 1;
624  in[1].before = EXT_STOP;
625  in[1].after = EXT_INFINITY;
626  s->fs.opaque = s;
627  s->fs.on_event = process_frame;
628 
629  return ff_framesync_configure(&s->fs);
630 }
631 
633 {
634  PreMultiplyContext *s = ctx->priv;
635 
636  if (s->inplace) {
637  AVFrame *frame = NULL;
638  AVFrame *out = NULL;
639  int ret, status;
640  int64_t pts;
641 
643 
644  if ((ret = ff_inlink_consume_frame(ctx->inputs[0], &frame)) > 0) {
647  if (ret < 0)
648  return ret;
649  ret = ff_filter_frame(ctx->outputs[0], out);
650  }
651  if (ret < 0) {
652  return ret;
653  } else if (ff_inlink_acknowledge_status(ctx->inputs[0], &status, &pts)) {
654  ff_outlink_set_status(ctx->outputs[0], status, pts);
655  return 0;
656  } else {
657  if (ff_outlink_frame_wanted(ctx->outputs[0]))
658  ff_inlink_request_frame(ctx->inputs[0]);
659  return 0;
660  }
661  } else {
662  return ff_framesync_activate(&s->fs);
663  }
664 }
665 
667 {
668  PreMultiplyContext *s = ctx->priv;
669  AVFilterPad pad = { 0 };
670  int ret;
671 
672  if (!strcmp(ctx->filter->name, "unpremultiply"))
673  s->inverse = 1;
674 
675  pad.type = AVMEDIA_TYPE_VIDEO;
676  pad.name = "main";
678 
679  if ((ret = ff_insert_inpad(ctx, 0, &pad)) < 0)
680  return ret;
681 
682  if (!s->inplace) {
683  pad.type = AVMEDIA_TYPE_VIDEO;
684  pad.name = "alpha";
685  pad.config_props = NULL;
686 
687  if ((ret = ff_insert_inpad(ctx, 1, &pad)) < 0)
688  return ret;
689  }
690 
691  return 0;
692 }
693 
695 {
696  PreMultiplyContext *s = ctx->priv;
697 
698  if (!s->inplace)
699  ff_framesync_uninit(&s->fs);
700 }
701 
703  {
704  .name = "default",
705  .type = AVMEDIA_TYPE_VIDEO,
706  .config_props = config_output,
707  },
708  { NULL }
709 };
710 
711 #if CONFIG_PREMULTIPLY_FILTER
712 
714  .name = "premultiply",
715  .description = NULL_IF_CONFIG_SMALL("PreMultiply first stream with first plane of second stream."),
716  .priv_size = sizeof(PreMultiplyContext),
717  .init = init,
718  .uninit = uninit,
720  .activate = activate,
721  .inputs = NULL,
723  .priv_class = &premultiply_class,
727 };
728 
729 #endif /* CONFIG_PREMULTIPLY_FILTER */
730 
731 #if CONFIG_UNPREMULTIPLY_FILTER
732 
733 #define unpremultiply_options options
734 AVFILTER_DEFINE_CLASS(unpremultiply);
735 
737  .name = "unpremultiply",
738  .description = NULL_IF_CONFIG_SMALL("UnPreMultiply first stream with first plane of second stream."),
739  .priv_size = sizeof(PreMultiplyContext),
740  .init = init,
741  .uninit = uninit,
743  .activate = activate,
744  .inputs = NULL,
746  .priv_class = &unpremultiply_class,
750 };
751 
752 #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:99
PreMultiplyContext::offset
int offset
Definition: vf_premultiply.c:43
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:419
ff_framesync_configure
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:117
td
#define td
Definition: regdef.h:70
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
status
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
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_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:300
ff_framesync_uninit
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:283
out
FILE * out
Definition: movenc.c:54
PreMultiplyContext::planes
int planes
Definition: vf_premultiply.c:40
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1075
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2549
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:246
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
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:316
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:300
PreMultiplyContext::depth
int depth
Definition: vf_premultiply.c:43
pixdesc.h
w
uint8_t w
Definition: llviddspenc.c:38
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
the normal 2^n-1 "JPEG" YUV ranges
Definition: pixfmt.h:535
AVOption
AVOption.
Definition: opt.h:246
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:267
PreMultiplyContext
Definition: vf_premultiply.c:35
base
uint8_t base
Definition: vp3data.h:202
max
#define max(a, b)
Definition: cuda_runtime.h:33
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:148
FFFrameSync
Frame sync structure.
Definition: framesync.h:146
EXT_INFINITY
@ EXT_INFINITY
Extend the frame to infinity.
Definition: framesync.h:75
video.h
AVFormatContext::internal
AVFormatInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1788
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:377
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:338
hsub
static void hsub(htype *dst, const htype *src, int bins)
Definition: vf_median.c:75
formats.h
ff_insert_inpad
static int ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.
Definition: internal.h:266
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:1476
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2589
options
static const AVOption options[]
Definition: vf_premultiply.c:57
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:415
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:413
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:441
FFFrameSyncIn
Input stream structure.
Definition: framesync.h:81
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:244
pts
static int64_t pts
Definition: transcode_aac.c:647
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:381
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:105
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:400
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
av_cold
#define av_cold
Definition: attributes.h:90
ff_set_common_formats
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:605
premultiply_slice
static int premultiply_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_premultiply.c:368
ff_vf_unpremultiply
AVFilter ff_vf_unpremultiply
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:417
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:531
ff_inlink_request_frame
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1602
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:257
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:418
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:410
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
PreMultiplyContext::half
int half
Definition: vf_premultiply.c:43
PreMultiplyContext::max
int max
Definition: vf_premultiply.c:43
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2040
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
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:438
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:380
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:541
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:221
FLAGS
#define FLAGS
Definition: vf_premultiply.c:55
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:80
arg
const char * arg
Definition: jacosubdec.c:66
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:378
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:416
ff_vf_premultiply
AVFilter ff_vf_premultiply
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
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:659
fs
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:259
PreMultiplyContext::width
int width[4]
Definition: vf_premultiply.c:37
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
PreMultiplyContext::linesize
int linesize[4]
Definition: vf_premultiply.c:38
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_premultiply.c:666
OFFSET
#define OFFSET(x)
Definition: vf_premultiply.c:54
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:74
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:412
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:1431
activate
static int activate(AVFilterContext *ctx)
Definition: vf_premultiply.c:632
AVFilterPad::config_props
int(* config_props)(AVFilterLink *link)
Link configuration callback.
Definition: internal.h:118
desc
const char * desc
Definition: nvenc.c:79
ThreadData::m
AVFrame * m
Definition: vf_maskedclamp.c:35
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:188
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:342
FFMAX
#define FFMAX(a, b)
Definition: common.h:94
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:404
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_premultiply.c:578
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
FFMIN
#define FFMIN(a, b)
Definition: common.h:96
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:177
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:436
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
internal.h
planes
static const struct @315 planes[]
ThreadData::d
void ** d
Definition: af_crystalizer.c:77
in
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
Definition: audio_convert.c:326
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_premultiply.c:694
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:414
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:784
ThreadData
Used for passing data between threads.
Definition: dsddec.c:67
uint8_t
uint8_t
Definition: audio_convert.c:194
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:290
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
the normal 219*2^(n-8) "MPEG" YUV ranges
Definition: pixfmt.h:534
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:396
AVFilter
Filter definition.
Definition: avfilter.h:144
ret
ret
Definition: filter_design.txt:187
AVFilterPad::type
enum AVMediaType type
AVFilterPad type.
Definition: internal.h:65
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
PreMultiplyContext::premultiply
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)
Definition: vf_premultiply.c:46
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:433
ff_framesync_init
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
Definition: framesync.c:77
PreMultiplyContext::inverse
int inverse
Definition: vf_premultiply.c:41
PreMultiplyContext::fs
FFFrameSync fs
Definition: vf_premultiply.c:44
framesync.h
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
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
Definition: opt.h:223
avfilter.h
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:32
premultiply_outputs
static const AVFilterPad premultiply_outputs[]
Definition: vf_premultiply.c:702
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:71
AVFilterContext
An instance of a filter.
Definition: avfilter.h:338
shift
static int shift(int a, int b)
Definition: sonic.c:82
PreMultiplyContext::inplace
int inplace
Definition: vf_premultiply.c:42
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
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:116
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:81
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(premultiply)
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_premultiply.c:551
alpha
static const int16_t alpha[]
Definition: ilbcdata.h:55
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:240
PreMultiplyContext::nb_planes
int nb_planes
Definition: vf_premultiply.c:39
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:133
imgutils.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:565
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
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:407
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:334
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:379
alpha_pix_fmts
static enum AVPixelFormat alpha_pix_fmts[]
Definition: vf_overlay.c:155
filter_frame
static int filter_frame(AVFilterContext *ctx, AVFrame **out, AVFrame *base, AVFrame *alpha)
Definition: vf_premultiply.c:403
PreMultiplyContext::height
int height[4]
Definition: vf_premultiply.c:37