FFmpeg
vf_extractplanes.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 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/avstring.h"
24 #include "libavutil/imgutils.h"
25 #include "libavutil/opt.h"
26 #include "libavutil/pixdesc.h"
27 
28 #include "avfilter.h"
29 #include "drawutils.h"
30 #include "filters.h"
31 #include "formats.h"
32 #include "internal.h"
33 #include "video.h"
34 
35 #define PLANE_R 0x01
36 #define PLANE_G 0x02
37 #define PLANE_B 0x04
38 #define PLANE_A 0x08
39 #define PLANE_Y 0x10
40 #define PLANE_U 0x20
41 #define PLANE_V 0x40
42 
43 typedef struct ExtractPlanesContext {
44  const AVClass *class;
46  int map[4];
47  int linesize[4];
48  int is_packed;
49  int depth;
50  int step;
52 
53 #define OFFSET(x) offsetof(ExtractPlanesContext, x)
54 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
55 static const AVOption extractplanes_options[] = {
56  { "planes", "set planes", OFFSET(requested_planes), AV_OPT_TYPE_FLAGS, {.i64=1}, 1, 0xff, FLAGS, .unit = "flags"},
57  { "y", "set luma plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_Y}, 0, 0, FLAGS, .unit = "flags"},
58  { "u", "set u plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_U}, 0, 0, FLAGS, .unit = "flags"},
59  { "v", "set v plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_V}, 0, 0, FLAGS, .unit = "flags"},
60  { "r", "set red plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_R}, 0, 0, FLAGS, .unit = "flags"},
61  { "g", "set green plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_G}, 0, 0, FLAGS, .unit = "flags"},
62  { "b", "set blue plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_B}, 0, 0, FLAGS, .unit = "flags"},
63  { "a", "set alpha plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_A}, 0, 0, FLAGS, .unit = "flags"},
64  { NULL }
65 };
66 
67 AVFILTER_DEFINE_CLASS(extractplanes);
68 
69 #define EIGHTBIT_FORMATS \
70  AV_PIX_FMT_YUV410P, \
71  AV_PIX_FMT_YUV411P, \
72  AV_PIX_FMT_YUV440P, \
73  AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, \
74  AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVA422P, \
75  AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, \
76  AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P, \
77  AV_PIX_FMT_YUVJ411P, \
78  AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA444P, \
79  AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY8A, \
80  AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24, \
81  AV_PIX_FMT_RGBA, AV_PIX_FMT_BGRA, \
82  AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR, \
83  AV_PIX_FMT_RGB0, AV_PIX_FMT_BGR0, \
84  AV_PIX_FMT_0RGB, AV_PIX_FMT_0BGR, \
85  AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP
86 
87 #define HIGHDEPTH_FORMATS(suf) \
88  AV_PIX_FMT_YA16##suf, \
89  AV_PIX_FMT_GRAY9##suf, \
90  AV_PIX_FMT_GRAY10##suf, \
91  AV_PIX_FMT_GRAY12##suf, \
92  AV_PIX_FMT_GRAY14##suf, \
93  AV_PIX_FMT_GRAY16##suf, \
94  AV_PIX_FMT_YUV420P16##suf, AV_PIX_FMT_YUVA420P16##suf, \
95  AV_PIX_FMT_YUV422P16##suf, AV_PIX_FMT_YUVA422P16##suf, \
96  AV_PIX_FMT_YUV444P16##suf, AV_PIX_FMT_YUVA444P16##suf, \
97  AV_PIX_FMT_RGB48##suf, AV_PIX_FMT_BGR48##suf, \
98  AV_PIX_FMT_RGBA64##suf, AV_PIX_FMT_BGRA64##suf, \
99  AV_PIX_FMT_GBRP16##suf, AV_PIX_FMT_GBRAP16##suf, \
100  AV_PIX_FMT_YUV420P10##suf, \
101  AV_PIX_FMT_YUV422P10##suf, \
102  AV_PIX_FMT_YUV444P10##suf, \
103  AV_PIX_FMT_YUV440P10##suf, \
104  AV_PIX_FMT_YUVA420P10##suf, \
105  AV_PIX_FMT_YUVA422P10##suf, \
106  AV_PIX_FMT_YUVA444P10##suf, \
107  AV_PIX_FMT_YUV420P12##suf, \
108  AV_PIX_FMT_YUV422P12##suf, \
109  AV_PIX_FMT_YUV444P12##suf, \
110  AV_PIX_FMT_YUV440P12##suf, \
111  AV_PIX_FMT_YUVA422P12##suf, \
112  AV_PIX_FMT_YUVA444P12##suf, \
113  AV_PIX_FMT_GBRP10##suf, AV_PIX_FMT_GBRAP10##suf, \
114  AV_PIX_FMT_GBRP12##suf, AV_PIX_FMT_GBRAP12##suf, \
115  AV_PIX_FMT_YUV420P9##suf, \
116  AV_PIX_FMT_YUV422P9##suf, \
117  AV_PIX_FMT_YUV444P9##suf, \
118  AV_PIX_FMT_YUVA420P9##suf, \
119  AV_PIX_FMT_YUVA422P9##suf, \
120  AV_PIX_FMT_YUVA444P9##suf, \
121  AV_PIX_FMT_GBRP9##suf, \
122  AV_PIX_FMT_GBRP14##suf, AV_PIX_FMT_GBRAP14##suf, \
123  AV_PIX_FMT_YUV420P14##suf, \
124  AV_PIX_FMT_YUV422P14##suf, \
125  AV_PIX_FMT_YUV444P14##suf
126 
127 #define FLOAT_FORMATS(suf) \
128  AV_PIX_FMT_GRAYF32##suf, \
129  AV_PIX_FMT_RGBF32##suf, AV_PIX_FMT_RGBAF32##suf, \
130  AV_PIX_FMT_GBRPF32##suf, AV_PIX_FMT_GBRAPF32##suf \
131 
133 {
134  static const enum AVPixelFormat in_pixfmts_le[] = {
136  HIGHDEPTH_FORMATS(LE),
137  FLOAT_FORMATS(LE),
139  };
140  static const enum AVPixelFormat in_pixfmts_be[] = {
142  HIGHDEPTH_FORMATS(BE),
143  FLOAT_FORMATS(BE),
145  };
146  static const enum AVPixelFormat out8_pixfmts[] = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE };
147  static const enum AVPixelFormat out9le_pixfmts[] = { AV_PIX_FMT_GRAY9LE, AV_PIX_FMT_NONE };
148  static const enum AVPixelFormat out9be_pixfmts[] = { AV_PIX_FMT_GRAY9BE, AV_PIX_FMT_NONE };
149  static const enum AVPixelFormat out10le_pixfmts[] = { AV_PIX_FMT_GRAY10LE, AV_PIX_FMT_NONE };
150  static const enum AVPixelFormat out10be_pixfmts[] = { AV_PIX_FMT_GRAY10BE, AV_PIX_FMT_NONE };
151  static const enum AVPixelFormat out12le_pixfmts[] = { AV_PIX_FMT_GRAY12LE, AV_PIX_FMT_NONE };
152  static const enum AVPixelFormat out12be_pixfmts[] = { AV_PIX_FMT_GRAY12BE, AV_PIX_FMT_NONE };
153  static const enum AVPixelFormat out14le_pixfmts[] = { AV_PIX_FMT_GRAY14LE, AV_PIX_FMT_NONE };
154  static const enum AVPixelFormat out14be_pixfmts[] = { AV_PIX_FMT_GRAY14BE, AV_PIX_FMT_NONE };
155  static const enum AVPixelFormat out16le_pixfmts[] = { AV_PIX_FMT_GRAY16LE, AV_PIX_FMT_NONE };
156  static const enum AVPixelFormat out16be_pixfmts[] = { AV_PIX_FMT_GRAY16BE, AV_PIX_FMT_NONE };
157  static const enum AVPixelFormat out32le_pixfmts[] = { AV_PIX_FMT_GRAYF32LE, AV_PIX_FMT_NONE };
158  static const enum AVPixelFormat out32be_pixfmts[] = { AV_PIX_FMT_GRAYF32BE, AV_PIX_FMT_NONE };
159  const enum AVPixelFormat *out_pixfmts, *in_pixfmts;
160  const AVPixFmtDescriptor *desc;
161  AVFilterFormats *avff;
162  int i, ret, depth = 0, be = 0;
163 
164  if (!ctx->inputs[0]->incfg.formats ||
165  !ctx->inputs[0]->incfg.formats->nb_formats) {
166  return AVERROR(EAGAIN);
167  }
168 
169  avff = ctx->inputs[0]->incfg.formats;
170  desc = av_pix_fmt_desc_get(avff->formats[0]);
171  depth = desc->comp[0].depth;
172  be = desc->flags & AV_PIX_FMT_FLAG_BE;
173  if (be) {
174  in_pixfmts = in_pixfmts_be;
175  } else {
176  in_pixfmts = in_pixfmts_le;
177  }
178  if (!ctx->inputs[0]->outcfg.formats)
179  if ((ret = ff_formats_ref(ff_make_format_list(in_pixfmts), &ctx->inputs[0]->outcfg.formats)) < 0)
180  return ret;
181 
182  for (i = 1; i < avff->nb_formats; i++) {
183  desc = av_pix_fmt_desc_get(avff->formats[i]);
184  if (depth != desc->comp[0].depth ||
185  be != (desc->flags & AV_PIX_FMT_FLAG_BE)) {
186  return AVERROR(EAGAIN);
187  }
188  }
189 
190  if (depth == 8)
191  out_pixfmts = out8_pixfmts;
192  else if (!be && depth == 9)
193  out_pixfmts = out9le_pixfmts;
194  else if (be && depth == 9)
195  out_pixfmts = out9be_pixfmts;
196  else if (!be && depth == 10)
197  out_pixfmts = out10le_pixfmts;
198  else if (be && depth == 10)
199  out_pixfmts = out10be_pixfmts;
200  else if (!be && depth == 12)
201  out_pixfmts = out12le_pixfmts;
202  else if (be && depth == 12)
203  out_pixfmts = out12be_pixfmts;
204  else if (!be && depth == 14)
205  out_pixfmts = out14le_pixfmts;
206  else if (be && depth == 14)
207  out_pixfmts = out14be_pixfmts;
208  else if (be && depth == 16)
209  out_pixfmts = out16be_pixfmts;
210  else if (!be && depth == 16)
211  out_pixfmts = out16le_pixfmts;
212  else if (be && depth == 32)
213  out_pixfmts = out32be_pixfmts;
214  else
215  out_pixfmts = out32le_pixfmts;
216 
217  for (i = 0; i < ctx->nb_outputs; i++)
218  if ((ret = ff_formats_ref(ff_make_format_list(out_pixfmts), &ctx->outputs[i]->incfg.formats)) < 0)
219  return ret;
220  return 0;
221 }
222 
224 {
225  AVFilterContext *ctx = inlink->dst;
226  ExtractPlanesContext *s = ctx->priv;
228  int plane_avail, ret, i;
229  uint8_t rgba_map[4];
230 
231  plane_avail = ((desc->flags & AV_PIX_FMT_FLAG_RGB) ? PLANE_R|PLANE_G|PLANE_B :
232  PLANE_Y |
233  ((desc->nb_components > 2) ? PLANE_U|PLANE_V : 0)) |
234  ((desc->flags & AV_PIX_FMT_FLAG_ALPHA) ? PLANE_A : 0);
235  if (s->requested_planes & ~plane_avail) {
236  av_log(ctx, AV_LOG_ERROR, "Requested planes not available.\n");
237  return AVERROR(EINVAL);
238  }
239  if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
240  return ret;
241 
242  s->depth = desc->comp[0].depth >> 3;
243  s->step = av_get_padded_bits_per_pixel(desc) >> 3;
244  s->is_packed = !(desc->flags & AV_PIX_FMT_FLAG_PLANAR) &&
245  (desc->nb_components > 1);
246  if (desc->flags & AV_PIX_FMT_FLAG_RGB) {
247  ff_fill_rgba_map(rgba_map, inlink->format);
248  for (i = 0; i < 4; i++)
249  s->map[i] = rgba_map[s->map[i]];
250  }
251 
252  return 0;
253 }
254 
255 static int config_output(AVFilterLink *outlink)
256 {
257  AVFilterContext *ctx = outlink->src;
258  AVFilterLink *inlink = ctx->inputs[0];
259  ExtractPlanesContext *s = ctx->priv;
261  const int output = outlink->srcpad - ctx->output_pads;
262 
263  if (s->map[output] == 1 || s->map[output] == 2) {
264  outlink->h = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
265  outlink->w = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
266  }
267 
268  return 0;
269 }
270 
271 static void extract_from_packed(uint8_t *dst, int dst_linesize,
272  const uint8_t *src, int src_linesize,
273  int width, int height,
274  int depth, int step, int comp)
275 {
276  int x, y;
277 
278  for (y = 0; y < height; y++) {
279  switch (depth) {
280  case 1:
281  for (x = 0; x < width; x++)
282  dst[x] = src[x * step + comp];
283  break;
284  case 2:
285  for (x = 0; x < width; x++) {
286  dst[x * 2 ] = src[x * step + comp * 2 ];
287  dst[x * 2 + 1] = src[x * step + comp * 2 + 1];
288  }
289  break;
290  case 4:
291  for (x = 0; x < width; x++) {
292  dst[x * 4 ] = src[x * step + comp * 4 ];
293  dst[x * 4 + 1] = src[x * step + comp * 4 + 1];
294  dst[x * 4 + 2] = src[x * step + comp * 4 + 2];
295  dst[x * 4 + 3] = src[x * step + comp * 4 + 3];
296  }
297  break;
298  }
299  dst += dst_linesize;
300  src += src_linesize;
301  }
302 }
303 
304 static int extract_plane(AVFilterLink *outlink, AVFrame *frame)
305 {
306  AVFilterContext *ctx = outlink->src;
307  ExtractPlanesContext *s = ctx->priv;
308  const int idx = s->map[FF_OUTLINK_IDX(outlink)];
309  AVFrame *out;
310 
311  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
312  if (!out)
313  return AVERROR(ENOMEM);
315  if (idx == 3 /* alpha */)
316  out->color_range = AVCOL_RANGE_JPEG;
317 
318  if (s->is_packed) {
319  extract_from_packed(out->data[0], out->linesize[0],
320  frame->data[0], frame->linesize[0],
321  outlink->w, outlink->h,
322  s->depth,
323  s->step, idx);
324  } else {
325  av_image_copy_plane(out->data[0], out->linesize[0],
326  frame->data[idx], frame->linesize[idx],
327  s->linesize[idx], outlink->h);
328  }
329 
330  return ff_filter_frame(outlink, out);
331 }
332 
334 {
335  AVFilterLink *inlink = ctx->inputs[0];
336  int status, ret;
337  AVFrame *in;
338  int64_t pts;
339 
340  for (int i = 0; i < ctx->nb_outputs; i++) {
342  }
343 
345  if (ret < 0)
346  return ret;
347  if (ret > 0) {
348  for (int i = 0; i < ctx->nb_outputs; i++) {
349  if (ff_outlink_get_status(ctx->outputs[i]))
350  continue;
351 
352  ret = extract_plane(ctx->outputs[i], in);
353  if (ret < 0)
354  break;
355  }
356 
357  av_frame_free(&in);
358  if (ret < 0)
359  return ret;
360  }
361 
363  for (int i = 0; i < ctx->nb_outputs; i++) {
364  if (ff_outlink_get_status(ctx->outputs[i]))
365  continue;
366  ff_outlink_set_status(ctx->outputs[i], status, pts);
367  }
368  return 0;
369  }
370 
371  for (int i = 0; i < ctx->nb_outputs; i++) {
372  if (ff_outlink_get_status(ctx->outputs[i]))
373  continue;
374 
375  if (ff_outlink_frame_wanted(ctx->outputs[i])) {
377  return 0;
378  }
379  }
380 
381  return FFERROR_NOT_READY;
382 }
383 
385 {
386  ExtractPlanesContext *s = ctx->priv;
387  int planes = (s->requested_planes & 0xf) | (s->requested_planes >> 4);
388  int i, ret;
389 
390  for (i = 0; i < 4; i++) {
391  char *name;
392  AVFilterPad pad = { 0 };
393 
394  if (!(planes & (1 << i)))
395  continue;
396 
397  name = av_asprintf("out%d", ctx->nb_outputs);
398  if (!name)
399  return AVERROR(ENOMEM);
400  s->map[ctx->nb_outputs] = i;
401  pad.name = name;
402  pad.type = AVMEDIA_TYPE_VIDEO;
404 
405  if ((ret = ff_append_outpad_free_name(ctx, &pad)) < 0)
406  return ret;
407  }
408 
409  return 0;
410 }
411 
413  {
414  .name = "default",
415  .type = AVMEDIA_TYPE_VIDEO,
416  .config_props = config_input,
417  },
418 };
419 
421  .name = "extractplanes",
422  .description = NULL_IF_CONFIG_SMALL("Extract planes as grayscale frames."),
423  .priv_size = sizeof(ExtractPlanesContext),
424  .priv_class = &extractplanes_class,
425  .init = init,
426  .activate = activate,
428  .outputs = NULL,
431 };
432 
433 #if CONFIG_ALPHAEXTRACT_FILTER
434 
435 static av_cold int init_alphaextract(AVFilterContext *ctx)
436 {
437  ExtractPlanesContext *s = ctx->priv;
438 
439  s->requested_planes = PLANE_A;
440  s->map[0] = 3;
441 
442  return 0;
443 }
444 
445 static const AVFilterPad alphaextract_outputs[] = {
446  {
447  .name = "default",
448  .type = AVMEDIA_TYPE_VIDEO,
449  .config_props = config_output,
450  },
451 };
452 
454  .name = "alphaextract",
455  .description = NULL_IF_CONFIG_SMALL("Extract an alpha channel as a "
456  "grayscale image component."),
457  .priv_size = sizeof(ExtractPlanesContext),
458  .init = init_alphaextract,
459  .activate = activate,
461  FILTER_OUTPUTS(alphaextract_outputs),
463 };
464 #endif /* CONFIG_ALPHAEXTRACT_FILTER */
ff_vf_extractplanes
const AVFilter ff_vf_extractplanes
Definition: vf_extractplanes.c:420
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
be
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 be(in the first position) for now. Options ------- Then comes the options array. This is what will define the user accessible options. For example
AV_PIX_FMT_GRAY10BE
@ AV_PIX_FMT_GRAY10BE
Y , 10bpp, big-endian.
Definition: pixfmt.h:320
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
extractplanes_options
static const AVOption extractplanes_options[]
Definition: vf_extractplanes.c:55
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:435
out
FILE * out
Definition: movenc.c:54
comp
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
Definition: eamad.c:80
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2962
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
int64_t
long long int64_t
Definition: coverity.c:34
output
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
Definition: filter_design.txt:225
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_asprintf
char * av_asprintf(const char *fmt,...)
Definition: avstring.c:115
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
pixdesc.h
step
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
Definition: rate_distortion.txt:58
ExtractPlanesContext::requested_planes
int requested_planes
Definition: vf_extractplanes.c:45
ExtractPlanesContext::linesize
int linesize[4]
Definition: vf_extractplanes.c:47
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:683
FLAGS
#define FLAGS
Definition: vf_extractplanes.c:54
AVOption
AVOption.
Definition: opt.h:346
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:159
AVFilterFormats::formats
int * formats
list of media formats
Definition: formats.h:66
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
video.h
AV_PIX_FMT_GRAY10LE
@ AV_PIX_FMT_GRAY10LE
Y , 10bpp, little-endian.
Definition: pixfmt.h:321
AV_PIX_FMT_GRAYF32LE
@ AV_PIX_FMT_GRAYF32LE
IEEE-754 single precision Y, 32bpp, little-endian.
Definition: pixfmt.h:364
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:365
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
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
AV_PIX_FMT_GRAY16BE
@ AV_PIX_FMT_GRAY16BE
Y , 16bpp, big-endian.
Definition: pixfmt.h:104
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
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
PLANE_A
#define PLANE_A
Definition: vf_extractplanes.c:38
ExtractPlanesContext::map
int map[4]
Definition: vf_extractplanes.c:46
ff_vf_alphaextract
const AVFilter ff_vf_alphaextract
AV_PIX_FMT_GRAY9LE
@ AV_PIX_FMT_GRAY9LE
Y , 9bpp, little-endian.
Definition: pixfmt.h:339
PLANE_B
#define PLANE_B
Definition: vf_extractplanes.c:37
pts
static int64_t pts
Definition: transcode_aac.c:643
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
extract_from_packed
static void extract_from_packed(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int width, int height, int depth, int step, int comp)
Definition: vf_extractplanes.c:271
activate
static int activate(AVFilterContext *ctx)
Definition: vf_extractplanes.c:333
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
extract_plane
static int extract_plane(AVFilterLink *outlink, AVFrame *frame)
Definition: vf_extractplanes.c:304
PLANE_Y
#define PLANE_Y
Definition: vf_extractplanes.c:39
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
ff_inlink_request_frame
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1571
width
#define width
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_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:678
FF_OUTLINK_IDX
#define FF_OUTLINK_IDX(link)
Definition: internal.h:332
filters.h
AV_PIX_FMT_FLAG_ALPHA
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:147
ctx
AVFormatContext * ctx
Definition: movenc.c:48
ExtractPlanesContext
Definition: vf_extractplanes.c:43
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_extractplanes.c:384
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
frame
static AVFrame * frame
Definition: demux_decode.c:54
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
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
AVFilterFormats::nb_formats
unsigned nb_formats
number of formats
Definition: formats.h:65
PLANE_G
#define PLANE_G
Definition: vf_extractplanes.c:36
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
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
AVFILTER_FLAG_DYNAMIC_OUTPUTS
#define AVFILTER_FLAG_DYNAMIC_OUTPUTS
The number of the filter outputs is not determined just by AVFilter.outputs.
Definition: avfilter.h:112
AVFilterPad::config_props
int(* config_props)(AVFilterLink *link)
Link configuration callback.
Definition: internal.h:113
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
av_get_padded_bits_per_pixel
int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel for the pixel format described by pixdesc, including any padding ...
Definition: pixdesc.c:2927
AV_PIX_FMT_FLAG_RGB
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:136
AV_PIX_FMT_GRAY12LE
@ AV_PIX_FMT_GRAY12LE
Y , 12bpp, little-endian.
Definition: pixfmt.h:319
ExtractPlanesContext::is_packed
int is_packed
Definition: vf_extractplanes.c:48
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_extractplanes.c:255
height
#define height
OFFSET
#define OFFSET(x)
Definition: vf_extractplanes.c:53
extractplanes_inputs
static const AVFilterPad extractplanes_inputs[]
Definition: vf_extractplanes.c:412
internal.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AV_PIX_FMT_GRAY9BE
@ AV_PIX_FMT_GRAY9BE
Y , 9bpp, big-endian.
Definition: pixfmt.h:338
FLOAT_FORMATS
#define FLOAT_FORMATS(suf)
Definition: vf_extractplanes.c:127
AV_PIX_FMT_FLAG_BE
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
Definition: pixdesc.h:116
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
AVFilter
Filter definition.
Definition: avfilter.h:166
AV_PIX_FMT_GRAY12BE
@ AV_PIX_FMT_GRAY12BE
Y , 12bpp, big-endian.
Definition: pixfmt.h:318
ret
ret
Definition: filter_design.txt:187
AVFilterPad::type
enum AVMediaType type
AVFilterPad type.
Definition: internal.h:44
AV_PIX_FMT_GRAYF32BE
@ AV_PIX_FMT_GRAYF32BE
IEEE-754 single precision Y, 32bpp, big-endian.
Definition: pixfmt.h:363
status
ov_status_e status
Definition: dnn_backend_openvino.c:120
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
avfilter.h
AV_PIX_FMT_FLAG_PLANAR
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition: pixdesc.h:132
ff_outlink_get_status
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
Definition: avfilter.c:1596
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
desc
const char * desc
Definition: libsvtav1.c:75
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_GRAY16LE
@ AV_PIX_FMT_GRAY16LE
Y , 16bpp, little-endian.
Definition: pixfmt.h:105
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
ExtractPlanesContext::depth
int depth
Definition: vf_extractplanes.c:49
planes
static const struct @386 planes[]
PLANE_U
#define PLANE_U
Definition: vf_extractplanes.c:40
AV_PIX_FMT_GRAY14LE
@ AV_PIX_FMT_GRAY14LE
Y , 14bpp, little-endian.
Definition: pixfmt.h:361
ExtractPlanesContext::step
int step
Definition: vf_extractplanes.c:50
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
ff_append_outpad_free_name
int ff_append_outpad_free_name(AVFilterContext *f, AVFilterPad *p)
Definition: avfilter.c:142
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
AV_PIX_FMT_GRAY14BE
@ AV_PIX_FMT_GRAY14BE
Y , 14bpp, big-endian.
Definition: pixfmt.h:360
ff_fill_rgba_map
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
Definition: drawutils.c:35
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:234
imgutils.h
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:389
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
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
avstring.h
drawutils.h
HIGHDEPTH_FORMATS
#define HIGHDEPTH_FORMATS(suf)
Definition: vf_extractplanes.c:87
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_extractplanes.c:223
PLANE_V
#define PLANE_V
Definition: vf_extractplanes.c:41
PLANE_R
#define PLANE_R
Definition: vf_extractplanes.c:35
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(extractplanes)
EIGHTBIT_FORMATS
#define EIGHTBIT_FORMATS
Definition: vf_extractplanes.c:69
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_extractplanes.c:132