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 "libavutil/avstring.h"
22 #include "libavutil/imgutils.h"
23 #include "libavutil/opt.h"
24 #include "libavutil/pixdesc.h"
25 
26 #include "avfilter.h"
27 #include "drawutils.h"
28 #include "filters.h"
29 #include "internal.h"
30 
31 #define PLANE_R 0x01
32 #define PLANE_G 0x02
33 #define PLANE_B 0x04
34 #define PLANE_A 0x08
35 #define PLANE_Y 0x10
36 #define PLANE_U 0x20
37 #define PLANE_V 0x40
38 
39 typedef struct ExtractPlanesContext {
40  const AVClass *class;
42  int map[4];
43  int linesize[4];
44  int is_packed;
45  int depth;
46  int step;
48 
49 #define OFFSET(x) offsetof(ExtractPlanesContext, x)
50 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
51 static const AVOption extractplanes_options[] = {
52  { "planes", "set planes", OFFSET(requested_planes), AV_OPT_TYPE_FLAGS, {.i64=1}, 1, 0xff, FLAGS, "flags"},
53  { "y", "set luma plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_Y}, 0, 0, FLAGS, "flags"},
54  { "u", "set u plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_U}, 0, 0, FLAGS, "flags"},
55  { "v", "set v plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_V}, 0, 0, FLAGS, "flags"},
56  { "r", "set red plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_R}, 0, 0, FLAGS, "flags"},
57  { "g", "set green plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_G}, 0, 0, FLAGS, "flags"},
58  { "b", "set blue plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_B}, 0, 0, FLAGS, "flags"},
59  { "a", "set alpha plane", 0, AV_OPT_TYPE_CONST, {.i64=PLANE_A}, 0, 0, FLAGS, "flags"},
60  { NULL }
61 };
62 
63 AVFILTER_DEFINE_CLASS(extractplanes);
64 
65 #define EIGHTBIT_FORMATS \
66  AV_PIX_FMT_YUV410P, \
67  AV_PIX_FMT_YUV411P, \
68  AV_PIX_FMT_YUV440P, \
69  AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, \
70  AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVA422P, \
71  AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, \
72  AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P, \
73  AV_PIX_FMT_YUVJ411P, \
74  AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA444P, \
75  AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY8A, \
76  AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24, \
77  AV_PIX_FMT_RGBA, AV_PIX_FMT_BGRA, \
78  AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR, \
79  AV_PIX_FMT_RGB0, AV_PIX_FMT_BGR0, \
80  AV_PIX_FMT_0RGB, AV_PIX_FMT_0BGR, \
81  AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP
82 
83 #define HIGHDEPTH_FORMATS(suf) \
84  AV_PIX_FMT_YA16##suf, AV_PIX_FMT_GRAY16##suf, \
85  AV_PIX_FMT_YUV420P16##suf, AV_PIX_FMT_YUVA420P16##suf, \
86  AV_PIX_FMT_YUV422P16##suf, AV_PIX_FMT_YUVA422P16##suf, \
87  AV_PIX_FMT_YUV444P16##suf, AV_PIX_FMT_YUVA444P16##suf, \
88  AV_PIX_FMT_RGB48##suf, AV_PIX_FMT_BGR48##suf, \
89  AV_PIX_FMT_RGBA64##suf, AV_PIX_FMT_BGRA64##suf, \
90  AV_PIX_FMT_GBRP16##suf, AV_PIX_FMT_GBRAP16##suf, \
91  AV_PIX_FMT_YUV420P10##suf, \
92  AV_PIX_FMT_YUV422P10##suf, \
93  AV_PIX_FMT_YUV444P10##suf, \
94  AV_PIX_FMT_YUV440P10##suf, \
95  AV_PIX_FMT_YUVA420P10##suf, \
96  AV_PIX_FMT_YUVA422P10##suf, \
97  AV_PIX_FMT_YUVA444P10##suf, \
98  AV_PIX_FMT_YUV420P12##suf, \
99  AV_PIX_FMT_YUV422P12##suf, \
100  AV_PIX_FMT_YUV444P12##suf, \
101  AV_PIX_FMT_YUV440P12##suf, \
102  AV_PIX_FMT_YUVA422P12##suf, \
103  AV_PIX_FMT_YUVA444P12##suf, \
104  AV_PIX_FMT_GBRP10##suf, AV_PIX_FMT_GBRAP10##suf, \
105  AV_PIX_FMT_GBRP12##suf, AV_PIX_FMT_GBRAP12##suf, \
106  AV_PIX_FMT_YUV420P9##suf, \
107  AV_PIX_FMT_YUV422P9##suf, \
108  AV_PIX_FMT_YUV444P9##suf, \
109  AV_PIX_FMT_YUVA420P9##suf, \
110  AV_PIX_FMT_YUVA422P9##suf, \
111  AV_PIX_FMT_YUVA444P9##suf, \
112  AV_PIX_FMT_GBRP9##suf, \
113  AV_PIX_FMT_GBRP14##suf, \
114  AV_PIX_FMT_YUV420P14##suf, \
115  AV_PIX_FMT_YUV422P14##suf, \
116  AV_PIX_FMT_YUV444P14##suf
117 
119 {
120  static const enum AVPixelFormat in_pixfmts_le[] = {
122  HIGHDEPTH_FORMATS(LE),
124  };
125  static const enum AVPixelFormat in_pixfmts_be[] = {
127  HIGHDEPTH_FORMATS(BE),
129  };
130  static const enum AVPixelFormat out8_pixfmts[] = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE };
131  static const enum AVPixelFormat out9le_pixfmts[] = { AV_PIX_FMT_GRAY9LE, AV_PIX_FMT_NONE };
132  static const enum AVPixelFormat out9be_pixfmts[] = { AV_PIX_FMT_GRAY9BE, AV_PIX_FMT_NONE };
133  static const enum AVPixelFormat out10le_pixfmts[] = { AV_PIX_FMT_GRAY10LE, AV_PIX_FMT_NONE };
134  static const enum AVPixelFormat out10be_pixfmts[] = { AV_PIX_FMT_GRAY10BE, AV_PIX_FMT_NONE };
135  static const enum AVPixelFormat out12le_pixfmts[] = { AV_PIX_FMT_GRAY12LE, AV_PIX_FMT_NONE };
136  static const enum AVPixelFormat out12be_pixfmts[] = { AV_PIX_FMT_GRAY12BE, AV_PIX_FMT_NONE };
137  static const enum AVPixelFormat out14le_pixfmts[] = { AV_PIX_FMT_GRAY14LE, AV_PIX_FMT_NONE };
138  static const enum AVPixelFormat out14be_pixfmts[] = { AV_PIX_FMT_GRAY14BE, AV_PIX_FMT_NONE };
139  static const enum AVPixelFormat out16le_pixfmts[] = { AV_PIX_FMT_GRAY16LE, AV_PIX_FMT_NONE };
140  static const enum AVPixelFormat out16be_pixfmts[] = { AV_PIX_FMT_GRAY16BE, AV_PIX_FMT_NONE };
141  const enum AVPixelFormat *out_pixfmts, *in_pixfmts;
142  const AVPixFmtDescriptor *desc;
143  AVFilterFormats *avff;
144  int i, ret, depth = 0, be = 0;
145 
146  if (!ctx->inputs[0]->in_formats ||
147  !ctx->inputs[0]->in_formats->nb_formats) {
148  return AVERROR(EAGAIN);
149  }
150 
151  avff = ctx->inputs[0]->in_formats;
152  desc = av_pix_fmt_desc_get(avff->formats[0]);
153  depth = desc->comp[0].depth;
154  be = desc->flags & AV_PIX_FMT_FLAG_BE;
155  if (be) {
156  in_pixfmts = in_pixfmts_be;
157  } else {
158  in_pixfmts = in_pixfmts_le;
159  }
160  if (!ctx->inputs[0]->out_formats)
161  if ((ret = ff_formats_ref(ff_make_format_list(in_pixfmts), &ctx->inputs[0]->out_formats)) < 0)
162  return ret;
163 
164  for (i = 1; i < avff->nb_formats; i++) {
165  desc = av_pix_fmt_desc_get(avff->formats[i]);
166  if (depth != desc->comp[0].depth ||
167  be != (desc->flags & AV_PIX_FMT_FLAG_BE)) {
168  return AVERROR(EAGAIN);
169  }
170  }
171 
172  if (depth == 8)
173  out_pixfmts = out8_pixfmts;
174  else if (!be && depth == 9)
175  out_pixfmts = out9le_pixfmts;
176  else if (be && depth == 9)
177  out_pixfmts = out9be_pixfmts;
178  else if (!be && depth == 10)
179  out_pixfmts = out10le_pixfmts;
180  else if (be && depth == 10)
181  out_pixfmts = out10be_pixfmts;
182  else if (!be && depth == 12)
183  out_pixfmts = out12le_pixfmts;
184  else if (be && depth == 12)
185  out_pixfmts = out12be_pixfmts;
186  else if (!be && depth == 14)
187  out_pixfmts = out14le_pixfmts;
188  else if (be && depth == 14)
189  out_pixfmts = out14be_pixfmts;
190  else if (be)
191  out_pixfmts = out16be_pixfmts;
192  else
193  out_pixfmts = out16le_pixfmts;
194 
195  for (i = 0; i < ctx->nb_outputs; i++)
196  if ((ret = ff_formats_ref(ff_make_format_list(out_pixfmts), &ctx->outputs[i]->in_formats)) < 0)
197  return ret;
198  return 0;
199 }
200 
202 {
203  AVFilterContext *ctx = inlink->dst;
204  ExtractPlanesContext *s = ctx->priv;
206  int plane_avail, ret, i;
207  uint8_t rgba_map[4];
208 
209  plane_avail = ((desc->flags & AV_PIX_FMT_FLAG_RGB) ? PLANE_R|PLANE_G|PLANE_B :
210  PLANE_Y |
211  ((desc->nb_components > 2) ? PLANE_U|PLANE_V : 0)) |
212  ((desc->flags & AV_PIX_FMT_FLAG_ALPHA) ? PLANE_A : 0);
213  if (s->requested_planes & ~plane_avail) {
214  av_log(ctx, AV_LOG_ERROR, "Requested planes not available.\n");
215  return AVERROR(EINVAL);
216  }
217  if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
218  return ret;
219 
220  s->depth = desc->comp[0].depth >> 3;
221  s->step = av_get_padded_bits_per_pixel(desc) >> 3;
222  s->is_packed = !(desc->flags & AV_PIX_FMT_FLAG_PLANAR) &&
223  (desc->nb_components > 1);
224  if (desc->flags & AV_PIX_FMT_FLAG_RGB) {
225  ff_fill_rgba_map(rgba_map, inlink->format);
226  for (i = 0; i < 4; i++)
227  s->map[i] = rgba_map[s->map[i]];
228  }
229 
230  return 0;
231 }
232 
233 static int config_output(AVFilterLink *outlink)
234 {
235  AVFilterContext *ctx = outlink->src;
236  AVFilterLink *inlink = ctx->inputs[0];
237  ExtractPlanesContext *s = ctx->priv;
239  const int output = outlink->srcpad - ctx->output_pads;
240 
241  if (s->map[output] == 1 || s->map[output] == 2) {
242  outlink->h = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
243  outlink->w = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
244  }
245 
246  return 0;
247 }
248 
249 static void extract_from_packed(uint8_t *dst, int dst_linesize,
250  const uint8_t *src, int src_linesize,
251  int width, int height,
252  int depth, int step, int comp)
253 {
254  int x, y;
255 
256  for (y = 0; y < height; y++) {
257  switch (depth) {
258  case 1:
259  for (x = 0; x < width; x++)
260  dst[x] = src[x * step + comp];
261  break;
262  case 2:
263  for (x = 0; x < width; x++) {
264  dst[x * 2 ] = src[x * step + comp * 2 ];
265  dst[x * 2 + 1] = src[x * step + comp * 2 + 1];
266  }
267  break;
268  }
269  dst += dst_linesize;
270  src += src_linesize;
271  }
272 }
273 
275 {
276  AVFilterContext *ctx = inlink->dst;
277  ExtractPlanesContext *s = ctx->priv;
278  int i, eof = 0, ret = 0;
279 
280  for (i = 0; i < ctx->nb_outputs; i++) {
281  AVFilterLink *outlink = ctx->outputs[i];
282  const int idx = s->map[i];
283  AVFrame *out;
284 
285  if (ff_outlink_get_status(outlink))
286  continue;
287 
288  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
289  if (!out) {
290  ret = AVERROR(ENOMEM);
291  break;
292  }
293  av_frame_copy_props(out, frame);
294 
295  if (s->is_packed) {
296  extract_from_packed(out->data[0], out->linesize[0],
297  frame->data[0], frame->linesize[0],
298  outlink->w, outlink->h,
299  s->depth,
300  s->step, idx);
301  } else {
302  av_image_copy_plane(out->data[0], out->linesize[0],
303  frame->data[idx], frame->linesize[idx],
304  s->linesize[idx], outlink->h);
305  }
306 
307  ret = ff_filter_frame(outlink, out);
308  if (ret == AVERROR_EOF)
309  eof++;
310  else if (ret < 0)
311  break;
312  }
313  av_frame_free(&frame);
314 
315  if (eof == ctx->nb_outputs)
316  ret = AVERROR_EOF;
317  else if (ret == AVERROR_EOF)
318  ret = 0;
319  return ret;
320 }
321 
323 {
324  ExtractPlanesContext *s = ctx->priv;
325  int planes = (s->requested_planes & 0xf) | (s->requested_planes >> 4);
326  int i, ret;
327 
328  for (i = 0; i < 4; i++) {
329  char *name;
330  AVFilterPad pad = { 0 };
331 
332  if (!(planes & (1 << i)))
333  continue;
334 
335  name = av_asprintf("out%d", ctx->nb_outputs);
336  if (!name)
337  return AVERROR(ENOMEM);
338  s->map[ctx->nb_outputs] = i;
339  pad.name = name;
340  pad.type = AVMEDIA_TYPE_VIDEO;
342 
343  if ((ret = ff_insert_outpad(ctx, ctx->nb_outputs, &pad)) < 0) {
344  av_freep(&pad.name);
345  return ret;
346  }
347  }
348 
349  return 0;
350 }
351 
353 {
354  int i;
355 
356  for (i = 0; i < ctx->nb_outputs; i++)
357  av_freep(&ctx->output_pads[i].name);
358 }
359 
361  {
362  .name = "default",
363  .type = AVMEDIA_TYPE_VIDEO,
364  .filter_frame = filter_frame,
365  .config_props = config_input,
366  },
367  { NULL }
368 };
369 
371  .name = "extractplanes",
372  .description = NULL_IF_CONFIG_SMALL("Extract planes as grayscale frames."),
373  .priv_size = sizeof(ExtractPlanesContext),
374  .priv_class = &extractplanes_class,
375  .init = init,
376  .uninit = uninit,
378  .inputs = extractplanes_inputs,
379  .outputs = NULL,
381 };
382 
383 #if CONFIG_ALPHAEXTRACT_FILTER
384 
385 static av_cold int init_alphaextract(AVFilterContext *ctx)
386 {
387  ExtractPlanesContext *s = ctx->priv;
388 
390 
391  return init(ctx);
392 }
393 
395  .name = "alphaextract",
396  .description = NULL_IF_CONFIG_SMALL("Extract an alpha channel as a "
397  "grayscale image component."),
398  .priv_size = sizeof(ExtractPlanesContext),
399  .init = init_alphaextract,
400  .uninit = uninit,
402  .inputs = extractplanes_inputs,
403  .outputs = NULL,
405 };
406 #endif /* CONFIG_ALPHAEXTRACT_FILTER */
#define NULL
Definition: coverity.c:32
static const AVFilterPad extractplanes_inputs[]
#define PLANE_U
#define PLANE_A
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2522
This structure describes decoded (raw) audio or video data.
Definition: frame.h:295
AVFILTER_DEFINE_CLASS(extractplanes)
AVOption.
Definition: opt.h:246
static av_cold void uninit(AVFilterContext *ctx)
misc image utilities
#define OFFSET(x)
Main libavfilter public API header.
const char * desc
Definition: nvenc.c:68
enum AVMediaType type
AVFilterPad type.
Definition: internal.h:65
static int config_input(AVFilterLink *inlink)
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
#define HIGHDEPTH_FORMATS(suf)
#define src
Definition: vp8dsp.c:254
#define FLAGS
Y , 12bpp, little-endian.
Definition: pixfmt.h:296
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
#define EIGHTBIT_FORMATS
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
const char * name
Pad name.
Definition: internal.h:60
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:346
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1080
AVFilterPad * output_pads
array of output pads
Definition: avfilter.h:349
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
uint8_t
#define av_cold
Definition: attributes.h:82
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:177
AVOptions.
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
#define height
Y , 9bpp, little-endian.
Definition: pixfmt.h:316
#define AVERROR_EOF
End of file.
Definition: error.h:55
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)
Y , 10bpp, little-endian.
Definition: pixfmt.h:298
#define AVFILTER_FLAG_DYNAMIC_OUTPUTS
The number of the filter outputs is not determined just by AVFilter.outputs.
Definition: avfilter.h:111
#define av_log(a,...)
A filter pad used for either input or output.
Definition: internal.h:54
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
static const AVOption extractplanes_options[]
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:148
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:202
unsigned nb_outputs
number of output pads
Definition: avfilter.h:351
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
void * priv
private data for use by the filter
Definition: avfilter.h:353
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:2487
static int config_output(AVFilterLink *outlink)
char * av_asprintf(const char *fmt,...)
Definition: avstring.c:113
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:106
AVFilter ff_vf_extractplanes
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:83
int(* config_props)(AVFilterLink *link)
Link configuration callback.
Definition: internal.h:129
#define width
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:440
AVFormatContext * ctx
Definition: movenc.c:48
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
#define s(width, name)
Definition: cbs_vp9.c:257
unsigned nb_formats
number of formats
Definition: formats.h:65
#define PLANE_Y
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
Definition: drawutils.c:35
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
Definition: eamad.c:83
#define PLANE_V
#define PLANE_R
misc drawing utilities
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:326
static int query_formats(AVFilterContext *ctx)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
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
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
AVFilter ff_vf_alphaextract
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:144
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
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
Definition: avfilter.c:1630
Y , 16bpp, big-endian.
Definition: pixfmt.h:97
#define PLANE_G
const char * name
Filter name.
Definition: avfilter.h:148
Y , 9bpp, big-endian.
Definition: pixfmt.h:315
Y , 14bpp, little-endian.
Definition: pixfmt.h:338
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:350
static av_cold int init(AVFilterContext *ctx)
#define flags(name, subs,...)
Definition: cbs_av1.c:561
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:309
Y , 10bpp, big-endian.
Definition: pixfmt.h:297
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
Y , 8bpp.
Definition: pixfmt.h:74
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
Definition: pixdesc.h:128
static const struct @317 planes[]
Y , 14bpp, big-endian.
Definition: pixfmt.h:337
Y , 16bpp, little-endian.
Definition: pixfmt.h:98
A list of supported formats for one end of a filter link.
Definition: formats.h:64
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
An instance of a filter.
Definition: avfilter.h:338
Y , 12bpp, big-endian.
Definition: pixfmt.h:295
#define PLANE_B
FILE * out
Definition: movenc.c:54
#define av_freep(p)
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
internal API functions
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
int depth
Number of bits in the component.
Definition: pixdesc.h:58
static int ff_insert_outpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new output pad for the filter.
Definition: internal.h:285
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition: pixdesc.h:144
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:654
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
const char * name
Definition: opengl_enc.c:102
int * formats
list of media formats
Definition: formats.h:66