128 double var_values[
VARS_NB], res;
156 s->
x = var_values[
VAR_X] = res;
163 s->
y = var_values[
VAR_Y] = res;
170 s->
w = var_values[
VAR_W] = res;
177 s->
h = var_values[
VAR_H] = res;
188 s->
w = (s->
w > 0) ? s->
w : inlink->
w;
189 s->
h = (s->
h > 0) ? s->
h : inlink->
h;
192 if (s->
w < 0 || s->
h < 0) {
198 s->
x, s->
y, s->
w, s->
h,
205 "Error when evaluating the expression '%s'.\n",
213 int plane, x, y, xb = s->
x, yb = s->
y;
214 unsigned char *row[4];
217 for (y =
FFMAX(yb, 0); y < frame->
height && y < (yb + s->
h); y++) {
221 for (plane = 1; plane < 3; plane++)
222 row[plane] = frame->
data[plane] +
226 for (x =
FFMAX(xb, 0); x < xb + s->
w && x < frame->
width; x++)
227 if ((y - yb < s->thickness) || (yb + s->
h - 1 - y < s->
thickness) ||
228 (x - xb < s->thickness) || (xb + s->
w - 1 - x < s->
thickness))
229 row[0][x] = 0xff - row[0][x];
231 for (x =
FFMAX(xb, 0); x < xb + s->
w && x < frame->
width; x++) {
232 if ((y - yb < s->thickness) || (yb + s->
h - 1 - y < s->
thickness) ||
233 (x - xb < s->thickness) || (xb + s->
w - 1 - x < s->
thickness)) {
243 for (y =
FFMAX(yb, 0); y < frame->
height && y < (yb + s->
h); y++) {
246 for (plane = 1; plane < 3; plane++)
247 row[plane] = frame->
data[plane] +
251 for (x =
FFMAX(xb, 0); x < xb + s->
w && x < frame->
width; x++)
252 if ((y - yb < s->thickness) || (yb + s->
h - 1 - y < s->
thickness) ||
253 (x - xb < s->thickness) || (xb + s->
w - 1 - x < s->
thickness))
254 row[0][x] = 0xff - row[0][x];
256 for (x =
FFMAX(xb, 0); x < xb + s->
w && x < frame->
width; x++) {
259 if ((y - yb < s->thickness) || (yb + s->
h - 1 - y < s->
thickness) ||
260 (x - xb < s->thickness) || (xb + s->
w - 1 - x < s->
thickness)) {
273 #define OFFSET(x) offsetof(DrawBoxContext, x)
274 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
276 #if CONFIG_DRAWBOX_FILTER
278 static const AVOption drawbox_options[] = {
317 .priv_class = &drawbox_class,
326 #if CONFIG_DRAWGRID_FILTER
338 x_modulo = x % drawgrid->
w;
339 y_modulo = y % drawgrid->
h;
343 x_modulo += drawgrid->
w;
345 y_modulo += drawgrid->
h;
358 for (y = 0; y < frame->
height; y++) {
362 for (plane = 1; plane < 3; plane++)
363 row[plane] = frame->
data[plane] +
367 for (x = 0; x < frame->
width; x++)
368 if (pixel_belongs_to_grid(drawgrid, x, y))
369 row[0][x] = 0xff - row[0][x];
371 for (x = 0; x < frame->
width; x++) {
372 if (pixel_belongs_to_grid(drawgrid, x, y)) {
382 for (y = 0; y < frame->
height; y++) {
385 for (plane = 1; plane < 3; plane++)
386 row[plane] = frame->
data[plane] +
390 for (x = 0; x < frame->
width; x++)
391 if (pixel_belongs_to_grid(drawgrid, x, y))
392 row[0][x] = 0xff - row[0][x];
394 for (x = 0; x < frame->
width; x++) {
397 if (pixel_belongs_to_grid(drawgrid, x, y)) {
398 row[0][x ] = (1 -
alpha) * row[0][x ] + alpha * drawgrid->
yuv_color[
Y];
399 row[1][x >> drawgrid->
hsub] = (1 - alpha) * row[1][x >> drawgrid->
hsub] + alpha * drawgrid->
yuv_color[
U];
410 static const AVOption drawgrid_options[] = {
431 .filter_frame = drawgrid_filter_frame,
449 .priv_class = &drawgrid_class,
452 .
inputs = drawgrid_inputs,
static float alpha(float a)
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
Various defines for YUV<->RGB conversion.
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.
#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.
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 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.
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. ...
void * priv
private data for use by the filter
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...
static const AVFilterPad outputs[]
char * h_expr
expression for width and height
int format
agreed upon media format
static const AVFilterPad inputs[]
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...
int hsub
chroma subsampling
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 RGB_TO_U_CCIR(r1, g1, b1, shift)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define RGB_TO_V_CCIR(r1, g1, b1, shift)
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)
#define RGB_TO_Y_CCIR(r, g, b)
AVFilterContext * dst
dest filter
#define AVFILTER_DEFINE_CLASS(fname)
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
unsigned char yuv_color[4]
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
AVPixelFormat
Pixel format.
simple arithmetic expression evaluator