21#include "config_components.h"
52#define OFFSET(x) offsetof(ExtractPlanesContext, x)
53#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
68#define EIGHTBIT_FORMATS \
72 AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, \
73 AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVA422P, \
74 AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, \
75 AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ444P, \
76 AV_PIX_FMT_YUVJ411P, \
77 AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA444P, \
78 AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY8A, \
79 AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24, \
80 AV_PIX_FMT_RGBA, AV_PIX_FMT_BGRA, \
81 AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR, \
82 AV_PIX_FMT_RGB0, AV_PIX_FMT_BGR0, \
83 AV_PIX_FMT_0RGB, AV_PIX_FMT_0BGR, \
84 AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP
86#define HIGHDEPTH_FORMATS(suf) \
87 AV_PIX_FMT_YA16##suf, \
88 AV_PIX_FMT_GRAY9##suf, \
89 AV_PIX_FMT_GRAY10##suf, \
90 AV_PIX_FMT_GRAY12##suf, \
91 AV_PIX_FMT_GRAY14##suf, \
92 AV_PIX_FMT_GRAY16##suf, \
93 AV_PIX_FMT_YUV420P16##suf, AV_PIX_FMT_YUVA420P16##suf, \
94 AV_PIX_FMT_YUV422P16##suf, AV_PIX_FMT_YUVA422P16##suf, \
95 AV_PIX_FMT_YUV444P16##suf, AV_PIX_FMT_YUVA444P16##suf, \
96 AV_PIX_FMT_RGB48##suf, AV_PIX_FMT_BGR48##suf, \
97 AV_PIX_FMT_RGBA64##suf, AV_PIX_FMT_BGRA64##suf, \
98 AV_PIX_FMT_GBRP16##suf, AV_PIX_FMT_GBRAP16##suf, \
99 AV_PIX_FMT_YUV420P10##suf, \
100 AV_PIX_FMT_YUV422P10##suf, \
101 AV_PIX_FMT_YUV444P10##suf, \
102 AV_PIX_FMT_YUV440P10##suf, \
103 AV_PIX_FMT_YUVA420P10##suf, \
104 AV_PIX_FMT_YUVA422P10##suf, \
105 AV_PIX_FMT_YUVA444P10##suf, \
106 AV_PIX_FMT_YUV420P12##suf, \
107 AV_PIX_FMT_YUV422P12##suf, \
108 AV_PIX_FMT_YUV444P12##suf, \
109 AV_PIX_FMT_YUV440P12##suf, \
110 AV_PIX_FMT_YUVA422P12##suf, \
111 AV_PIX_FMT_YUVA444P12##suf, \
112 AV_PIX_FMT_GBRP10##suf, AV_PIX_FMT_GBRAP10##suf, \
113 AV_PIX_FMT_GBRP12##suf, AV_PIX_FMT_GBRAP12##suf, \
114 AV_PIX_FMT_YUV420P9##suf, \
115 AV_PIX_FMT_YUV422P9##suf, \
116 AV_PIX_FMT_YUV444P9##suf, \
117 AV_PIX_FMT_YUVA420P9##suf, \
118 AV_PIX_FMT_YUVA422P9##suf, \
119 AV_PIX_FMT_YUVA444P9##suf, \
120 AV_PIX_FMT_GBRP9##suf, \
121 AV_PIX_FMT_GBRP14##suf, AV_PIX_FMT_GBRAP14##suf, \
122 AV_PIX_FMT_YUV420P14##suf, \
123 AV_PIX_FMT_YUV422P14##suf, \
124 AV_PIX_FMT_YUV444P14##suf
126#define FLOAT_FORMATS(suf) \
127 AV_PIX_FMT_GRAYF32##suf, \
128 AV_PIX_FMT_RGBF32##suf, AV_PIX_FMT_RGBAF32##suf, \
129 AV_PIX_FMT_GBRPF32##suf, AV_PIX_FMT_GBRAPF32##suf \
161 int i, ret, depth = 0, be = 0;
163 if (!
ctx->inputs[0]->incfg.formats ||
164 !
ctx->inputs[0]->incfg.formats->nb_formats) {
168 avff =
ctx->inputs[0]->incfg.formats;
170 depth =
desc->comp[0].depth;
173 in_pixfmts = in_pixfmts_be;
175 in_pixfmts = in_pixfmts_le;
177 if (!
ctx->inputs[0]->outcfg.formats)
183 if (depth !=
desc->comp[0].depth ||
190 out_pixfmts = out8_pixfmts;
191 else if (!be && depth == 9)
192 out_pixfmts = out9le_pixfmts;
193 else if (be && depth == 9)
194 out_pixfmts = out9be_pixfmts;
195 else if (!be && depth == 10)
196 out_pixfmts = out10le_pixfmts;
197 else if (be && depth == 10)
198 out_pixfmts = out10be_pixfmts;
199 else if (!be && depth == 12)
200 out_pixfmts = out12le_pixfmts;
201 else if (be && depth == 12)
202 out_pixfmts = out12be_pixfmts;
203 else if (!be && depth == 14)
204 out_pixfmts = out14le_pixfmts;
205 else if (be && depth == 14)
206 out_pixfmts = out14be_pixfmts;
207 else if (be && depth == 16)
208 out_pixfmts = out16be_pixfmts;
209 else if (!be && depth == 16)
210 out_pixfmts = out16le_pixfmts;
211 else if (be && depth == 32)
212 out_pixfmts = out32be_pixfmts;
214 out_pixfmts = out32le_pixfmts;
220 for (
i = 0;
i <
ctx->nb_outputs;
i++)
231 int plane_avail, ret,
i;
238 if (
s->requested_planes & ~plane_avail) {
245 s->depth =
desc->comp[0].depth >> 3;
248 (
desc->nb_components > 1);
251 for (
i = 0;
i < 4;
i++)
252 s->map[
i] = rgba_map[
s->map[
i]];
264 const int output = outlink->
srcpad -
ctx->output_pads;
266 if (
s->map[output] == 1 ||
s->map[output] == 2) {
275 const uint8_t *
src,
int src_linesize,
277 int depth,
int step,
int comp)
281 for (y = 0; y <
height; y++) {
284 for (x = 0; x <
width; x++)
288 for (x = 0; x <
width; x++) {
290 dst[x * 2 + 1] =
src[x * step +
comp * 2 + 1];
294 for (x = 0; x <
width; x++) {
296 dst[x * 4 + 1] =
src[x * step +
comp * 4 + 1];
297 dst[x * 4 + 2] =
src[x * step +
comp * 4 + 2];
298 dst[x * 4 + 3] =
src[x * step +
comp * 4 + 3];
324 outlink->
w, outlink->
h,
330 s->linesize[idx], outlink->
h);
343 for (
int i = 0;
i <
ctx->nb_outputs;
i++) {
351 for (
int i = 0;
i <
ctx->nb_outputs;
i++) {
366 for (
int i = 0;
i <
ctx->nb_outputs;
i++) {
382 int planes = (
s->requested_planes & 0xf) | (
s->requested_planes >> 4);
385 for (
i = 0;
i < 4;
i++) {
395 s->map[
ctx->nb_outputs] =
i;
416 .p.name =
"extractplanes",
418 .p.priv_class = &extractplanes_class,
428#if CONFIG_ALPHAEXTRACT_FILTER
449 .p.name =
"alphaextract",
451 "grayscale image component."),
453 .
init = init_alphaextract,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int config_input(AVFilterLink *inlink)
const FFFilter ff_vf_alphaextract
const FFFilter ff_vf_extractplanes
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_append_outpad_free_name(AVFilterContext *f, AVFilterPad *p)
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Main libavfilter public API header.
char * av_asprintf(const char *fmt,...)
#define i(width, name, range_min, range_max)
#define AV_CEIL_RSHIFT(a, b)
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
int(* init)(AVBSFContext *ctx)
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
#define AVFILTER_FLAG_DYNAMIC_OUTPUTS
The number of the filter outputs is not determined just by AVFilter.outputs.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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.
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.
static int activate(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FF_FILTER_FORWARD_WANTED_ANY(filter, inlink)
Forward the frame_wanted_out flag from any of the output links to an input link.
#define FILTER_QUERY_FUNC(func)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
#define FFERROR_NOT_READY
Filters implementation helper functions and internal structures.
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
#define AVFILTER_DEFINE_CLASS(fname)
#define FF_OUTLINK_IDX(link)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const struct @257111027162314367033347246032313251342043035002 planes[]
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 ...
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
@ AVCOL_RANGE_JPEG
Full range content.
@ AVALPHA_MODE_STRAIGHT
Alpha channel is independent of color values.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_GRAY16BE
Y , 16bpp, big-endian.
@ AV_PIX_FMT_GRAY10LE
Y , 10bpp, little-endian.
@ AV_PIX_FMT_GRAYF32LE
IEEE-754 single precision Y, 32bpp, little-endian.
@ AV_PIX_FMT_GRAY12LE
Y , 12bpp, little-endian.
@ AV_PIX_FMT_GRAY12BE
Y , 12bpp, big-endian.
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_GRAY14LE
Y , 14bpp, little-endian.
@ AV_PIX_FMT_GRAY9BE
Y , 9bpp, big-endian.
@ AV_PIX_FMT_GRAYF32BE
IEEE-754 single precision Y, 32bpp, big-endian.
@ AV_PIX_FMT_GRAY16LE
Y , 16bpp, little-endian.
@ AV_PIX_FMT_GRAY9LE
Y , 9bpp, little-endian.
@ AV_PIX_FMT_GRAY10BE
Y , 10bpp, big-endian.
@ AV_PIX_FMT_GRAY14BE
Y , 14bpp, big-endian.
Describe the class of an AVClass context structure.
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVFilterPad * srcpad
output pad on the source filter
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
int(* config_props)(AVFilterLink *link)
Link configuration callback.
enum AVMediaType type
AVFilterPad type.
const char * name
Pad name.
This structure describes decoded (raw) audio or video data.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static AVFormatContext * ctx
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.