93 if (!strcmp(
s->color_str,
"invert"))
98 if (!
s->invert_color) {
99 s->yuv_color[
Y] =
RGB_TO_Y_CCIR(rgba_color[0], rgba_color[1], rgba_color[2]);
100 s->yuv_color[
U] =
RGB_TO_U_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
101 s->yuv_color[
V] =
RGB_TO_V_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
102 s->yuv_color[
A] = rgba_color[3];
129 double var_values[
VARS_NB], res;
134 s->hsub =
desc->log2_chroma_w;
135 s->vsub =
desc->log2_chroma_h;
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;
185 s->thickness = var_values[
VAR_T] = 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,
200 s->yuv_color[
Y],
s->yuv_color[
U],
s->yuv_color[
V],
s->yuv_color[
A]);
206 "Error when evaluating the expression '%s'.\n",
213 return (y -
s->y <
s->thickness) || (
s->y +
s->h - 1 - y <
s->thickness) ||
214 (x -
s->x <
s->thickness) || (
s->x +
s->w - 1 - x <
s->thickness);
220 int plane, x, y, xb =
s->x, yb =
s->y;
221 unsigned char *row[4];
223 if (
s->have_alpha &&
s->replace) {
228 for (plane = 1; plane < 3; plane++)
232 if (
s->invert_color) {
235 row[0][x] = 0xff - row[0][x];
239 row[0][x ] =
s->yuv_color[
Y];
240 row[1][x >>
s->hsub] =
s->yuv_color[
U];
241 row[2][x >>
s->hsub] =
s->yuv_color[
V];
242 row[3][x ] =
s->yuv_color[
A];
251 for (plane = 1; plane < 3; plane++)
255 if (
s->invert_color) {
258 row[0][x] = 0xff - row[0][x];
261 double alpha = (double)
s->yuv_color[
A] / 255;
264 row[0][x ] = (1 -
alpha) * row[0][x ] +
alpha *
s->yuv_color[
Y];
265 row[1][x >>
s->hsub] = (1 -
alpha) * row[1][x >>
s->hsub] +
alpha *
s->yuv_color[
U];
266 row[2][x >>
s->hsub] = (1 -
alpha) * row[2][x >>
s->hsub] +
alpha *
s->yuv_color[
V];
284 int old_t =
s->thickness;
285 int old_r =
s->replace;
302 s->thickness = old_t;
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;
400 for (plane = 1; plane < 3; plane++)
406 if (pixel_belongs_to_grid(drawgrid, x, y))
407 row[0][x] = 0xff - row[0][x];
410 if (pixel_belongs_to_grid(drawgrid, x, y)) {
423 for (plane = 1; plane < 3; plane++)
429 if (pixel_belongs_to_grid(drawgrid, x, y))
430 row[0][x] = 0xff - row[0][x];
435 if (pixel_belongs_to_grid(drawgrid, x, y)) {
448 static const AVOption drawgrid_options[] = {
470 .filter_frame = drawgrid_filter_frame,
488 .priv_class = &drawgrid_class,
491 .
inputs = drawgrid_inputs,
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
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.
Main libavfilter public API header.
#define flags(name, subs,...)
common internal and external API header
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.
simple arithmetic expression evaluator
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
static const int16_t alpha[]
#define AVFILTER_DEFINE_CLASS(fname)
Various defines for YUV<->RGB conversion.
#define RGB_TO_U_CCIR(r1, g1, b1, shift)
#define RGB_TO_Y_CCIR(r, g, b)
#define RGB_TO_V_CCIR(r1, g1, b1, shift)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
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.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Describe the class of an AVClass context structure.
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
const char * name
Pad name.
const char * name
Filter name.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
char * y_expr
expression for x and y
char * h_expr
expression for width and height
int invert_color
invert luma color
char * t_expr
expression for thickness
int hsub
chroma subsampling
unsigned char yuv_color[4]
static const int NUM_EXPR_EVALS
static int query_formats(AVFilterContext *ctx)
static int config_input(AVFilterLink *inlink)
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
static av_pure av_always_inline int pixel_belongs_to_box(DrawBoxContext *s, int x, int y)
static const char *const var_names[]
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static av_cold int init(AVFilterContext *ctx)