Go to the documentation of this file.
21 #include "config_components.h"
53 #define OFFSET(x) offsetof(ExtractPlanesContext, x)
54 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
69 #define EIGHTBIT_FORMATS \
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
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
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 \
162 int i,
ret, depth = 0,
be = 0;
164 if (!
ctx->inputs[0]->incfg.formats ||
165 !
ctx->inputs[0]->incfg.formats->nb_formats) {
169 avff =
ctx->inputs[0]->incfg.formats;
171 depth =
desc->comp[0].depth;
174 in_pixfmts = in_pixfmts_be;
176 in_pixfmts = in_pixfmts_le;
178 if (!
ctx->inputs[0]->outcfg.formats)
184 if (depth !=
desc->comp[0].depth ||
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;
215 out_pixfmts = out32le_pixfmts;
217 for (
i = 0;
i <
ctx->nb_outputs;
i++)
228 int plane_avail,
ret,
i;
235 if (
s->requested_planes & ~plane_avail) {
242 s->depth =
desc->comp[0].depth >> 3;
245 (
desc->nb_components > 1);
248 for (
i = 0;
i < 4;
i++)
249 s->map[
i] = rgba_map[
s->map[
i]];
272 const uint8_t *
src,
int src_linesize,
278 for (y = 0; y <
height; y++) {
281 for (x = 0; x <
width; x++)
285 for (x = 0; x <
width; x++) {
291 for (x = 0; x <
width; x++) {
321 outlink->
w, outlink->
h,
327 s->linesize[idx], outlink->
h);
340 for (
int i = 0;
i <
ctx->nb_outputs;
i++) {
348 for (
int i = 0;
i <
ctx->nb_outputs;
i++) {
363 for (
int i = 0;
i <
ctx->nb_outputs;
i++) {
371 for (
int i = 0;
i <
ctx->nb_outputs;
i++) {
387 int planes = (
s->requested_planes & 0xf) | (
s->requested_planes >> 4);
390 for (
i = 0;
i < 4;
i++) {
400 s->map[
ctx->nb_outputs] =
i;
421 .
name =
"extractplanes",
424 .priv_class = &extractplanes_class,
433 #if CONFIG_ALPHAEXTRACT_FILTER
445 static const AVFilterPad alphaextract_outputs[] = {
454 .
name =
"alphaextract",
456 "grayscale image component."),
458 .
init = init_alphaextract,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
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
Y , 10bpp, big-endian.
AVPixelFormat
Pixel format.
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
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
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
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
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
char * av_asprintf(const char *fmt,...)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
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
@ AVCOL_RANGE_JPEG
Full range content.
#define FILTER_QUERY_FUNC(func)
const char * name
Filter name.
A link between two filters.
@ AV_PIX_FMT_GRAY10LE
Y , 10bpp, little-endian.
@ AV_PIX_FMT_GRAYF32LE
IEEE-754 single precision Y, 32bpp, little-endian.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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.
@ AV_PIX_FMT_GRAY16BE
Y , 16bpp, big-endian.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
const AVFilter ff_vf_alphaextract
@ AV_PIX_FMT_GRAY9LE
Y , 9bpp, little-endian.
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
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.
#define AV_CEIL_RSHIFT(a, b)
#define FF_OUTLINK_IDX(link)
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
#define FILTER_INPUTS(array)
Describe the class of an AVClass context structure.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
#define AVFILTER_FLAG_DYNAMIC_OUTPUTS
The number of the filter outputs is not determined just by AVFilter.outputs.
int(* config_props)(AVFilterLink *link)
Link configuration callback.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
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 ...
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
@ AV_PIX_FMT_GRAY12LE
Y , 12bpp, little-endian.
AVFilterPad * srcpad
output pad on the source filter
AVFilterContext * src
source filter
#define i(width, name, range_min, range_max)
int w
agreed upon image width
@ AV_PIX_FMT_GRAY9BE
Y , 9bpp, big-endian.
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
const char * name
Pad name.
@ AV_PIX_FMT_GRAY12BE
Y , 12bpp, big-endian.
enum AVMediaType type
AVFilterPad type.
@ AV_PIX_FMT_GRAYF32BE
IEEE-754 single precision Y, 32bpp, big-endian.
int h
agreed upon image height
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
@ AV_PIX_FMT_GRAY16LE
Y , 16bpp, little-endian.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static const struct @386 planes[]
@ AV_PIX_FMT_GRAY14LE
Y , 14bpp, little-endian.
#define FILTER_OUTPUTS(array)
int ff_append_outpad_free_name(AVFilterContext *f, AVFilterPad *p)
@ AV_PIX_FMT_GRAY14BE
Y , 14bpp, big-endian.
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
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