129 double var_values[
VARS_NB], res;
157 s->
x = var_values[
VAR_X] = res;
164 s->
y = var_values[
VAR_Y] = res;
171 s->
w = var_values[
VAR_W] = res;
178 s->
h = var_values[
VAR_H] = res;
189 s->
w = (s->
w > 0) ? s->
w : inlink->
w;
190 s->
h = (s->
h > 0) ? s->
h : inlink->
h;
193 if (s->
w < 0 || s->
h < 0) {
199 s->
x, s->
y, s->
w, s->
h,
206 "Error when evaluating the expression '%s'.\n",
220 int plane,
x,
y, xb = s->
x, yb = s->
y;
221 unsigned char *row[4];
224 for (y =
FFMAX(yb, 0); y < frame->
height && y < (yb + s->
h); y++) {
228 for (plane = 1; plane < 3; plane++)
229 row[plane] = frame->
data[plane] +
233 for (x =
FFMAX(xb, 0); x < xb + s->
w && x < frame->
width; x++)
235 row[0][x] = 0xff - row[0][x];
237 for (x =
FFMAX(xb, 0); x < xb + s->
w && x < frame->
width; x++) {
248 for (y =
FFMAX(yb, 0); y < frame->
height && y < (yb + s->
h); y++) {
251 for (plane = 1; plane < 3; plane++)
252 row[plane] = frame->
data[plane] +
256 for (x =
FFMAX(xb, 0); x < xb + s->
w && x < frame->
width; x++)
258 row[0][x] = 0xff - row[0][x];
260 for (x =
FFMAX(xb, 0); x < xb + s->
w && x < frame->
width; x++) {
309 #define OFFSET(x) offsetof(DrawBoxContext, x) 310 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM 312 #if CONFIG_DRAWBOX_FILTER 314 static const AVOption drawbox_options[] = {
354 .priv_class = &drawbox_class,
364 #if CONFIG_DRAWGRID_FILTER 376 x_modulo =
x % drawgrid->
w;
377 y_modulo = y % drawgrid->
h;
381 x_modulo += drawgrid->
w;
383 y_modulo += drawgrid->
h;
396 for (y = 0; y < frame->
height; y++) {
400 for (plane = 1; plane < 3; plane++)
401 row[plane] = frame->
data[plane] +
405 for (x = 0; x < frame->
width; x++)
406 if (pixel_belongs_to_grid(drawgrid, x, y))
407 row[0][
x] = 0xff - row[0][
x];
409 for (x = 0; x < frame->
width; x++) {
410 if (pixel_belongs_to_grid(drawgrid, x, y)) {
420 for (y = 0; y < frame->
height; y++) {
423 for (plane = 1; plane < 3; plane++)
424 row[plane] = frame->
data[plane] +
428 for (x = 0; x < frame->
width; x++)
429 if (pixel_belongs_to_grid(drawgrid, x, y))
430 row[0][
x] = 0xff - row[0][
x];
432 for (x = 0; x < frame->
width; x++) {
435 if (pixel_belongs_to_grid(drawgrid, x, y)) {
437 row[1][x >> drawgrid->
hsub] = (1 - alpha) * row[1][x >> drawgrid->
hsub] + alpha * drawgrid->
yuv_color[
U];
448 static const AVOption drawgrid_options[] = {
470 .filter_frame = drawgrid_filter_frame,
488 .priv_class = &drawgrid_class,
491 .
inputs = drawgrid_inputs,
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Main libavfilter public API header.
int h
agreed upon image height
static const char *const var_names[]
char * y_expr
expression for x and y
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
static av_cold int end(AVCodecContext *avctx)
static int query_formats(AVFilterContext *ctx)
static double av_q2d(AVRational a)
Convert an AVRational to a double.
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
#define AV_LOG_VERBOSE
Detailed information.
int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, void *log_ctx)
Put the RGBA values that correspond to color_string in rgba_color.
int invert_color
invert luma color
A filter pad used for either input or output.
A link between two filters.
static int config_input(AVFilterLink *inlink)
int av_expr_parse_and_eval(double *d, const char *s, const char *const *const_names, const double *const_values, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), void *opaque, int log_offset, void *log_ctx)
Parse and evaluate an expression.
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Various defines for YUV<->RGB conversion.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options...
void * priv
private data for use by the filter
#define RGB_TO_U_CCIR(r1, g1, b1, shift)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
char * t_expr
expression for thickness
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
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
static av_pure av_always_inline int pixel_belongs_to_box(DrawBoxContext *s, int x, int y)
char * h_expr
expression for width and height
static const AVFilterPad outputs[]
int format
agreed upon media format
static const int NUM_EXPR_EVALS
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static const int16_t alpha[]
int hsub
chroma subsampling
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
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Describe the class of an AVClass context structure.
const char * name
Filter name.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
#define flags(name, subs,...)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal and external API header
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static av_cold int init(AVFilterContext *ctx)
AVFilterContext * dst
dest filter
#define AVFILTER_DEFINE_CLASS(fname)
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
#define RGB_TO_V_CCIR(r1, g1, b1, shift)
unsigned char yuv_color[4]
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
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
#define RGB_TO_Y_CCIR(r, g, b)
AVPixelFormat
Pixel format.
simple arithmetic expression evaluator