29 #include "libavutil/common.h"
30 #include "libavutil/opt.h"
31 #include "libavutil/eval.h"
32 #include "libavutil/pixdesc.h"
33 #include "libavutil/parseutils.h"
74 unsigned char yuv_color[4];
147 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i ==
NUM_EXPR_EVALS)
153 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i ==
NUM_EXPR_EVALS)
159 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i ==
NUM_EXPR_EVALS)
165 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i ==
NUM_EXPR_EVALS)
171 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0 && i ==
NUM_EXPR_EVALS)
177 s->
w = (s->
w > 0) ? s->
w : inlink->
w;
178 s->
h = (s->
h > 0) ? s->
h : inlink->
h;
181 if (s->
w < 0 || s->
h < 0) {
187 s->
x, s->
y, s->
w, s->
h,
194 "Error when evaluating the expression '%s'.\n",
202 int plane, x,
y, xb = s->
x, yb = s->
y;
203 unsigned char *row[4];
205 for (y =
FFMAX(yb, 0); y < frame->
height && y < (yb + s->
h); y++) {
208 for (plane = 1; plane < 3; plane++)
209 row[plane] = frame->
data[plane] +
213 for (x =
FFMAX(xb, 0); x < xb + s->
w && x < frame->
width; x++)
214 if ((y - yb < s->thickness) || (yb + s->
h - 1 - y < s->
thickness) ||
215 (x - xb < s->thickness) || (xb + s->
w - 1 - x < s->
thickness))
216 row[0][x] = 0xff - row[0][x];
218 for (x =
FFMAX(xb, 0); x < xb + s->
w && x < frame->
width; x++) {
221 if ((y - yb < s->thickness) || (yb + s->
h - 1 - y < s->
thickness) ||
222 (x - xb < s->thickness) || (xb + s->
w - 1 - x < s->
thickness)) {
234 #define OFFSET(x) offsetof(DrawBoxContext, x)
235 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
237 #if CONFIG_DRAWBOX_FILTER
239 static const AVOption drawbox_options[] = {
278 .priv_class = &drawbox_class,
287 #if CONFIG_DRAWGRID_FILTER
299 x_modulo = x % drawgrid->
w;
300 y_modulo = y % drawgrid->
h;
304 x_modulo += drawgrid->
w;
306 y_modulo += drawgrid->
h;
318 for (y = 0; y < frame->
height; y++) {
321 for (plane = 1; plane < 3; plane++)
322 row[plane] = frame->
data[plane] +
326 for (x = 0; x < frame->
width; x++)
327 if (pixel_belongs_to_grid(drawgrid, x, y))
328 row[0][x] = 0xff - row[0][x];
330 for (x = 0; x < frame->
width; x++) {
333 if (pixel_belongs_to_grid(drawgrid, x, y)) {
334 row[0][x ] = (1 -
alpha) * row[0][x ] + alpha * drawgrid->
yuv_color[
Y];
335 row[1][x >> drawgrid->
hsub] = (1 - alpha) * row[1][x >> drawgrid->
hsub] + alpha * drawgrid->
yuv_color[
U];
345 static const AVOption drawgrid_options[] = {
366 .filter_frame = drawgrid_filter_frame,
384 .priv_class = &drawgrid_class,
387 .
inputs = drawgrid_inputs,
This structure describes decoded (raw) audio or video data.
const char * name
Filter name.
void * priv
private data for use by the filter
static const AVFilterPad outputs[]
int h
agreed upon image height
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Various defines for YUV<->RGB conversion.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
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.
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
#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.
static int query_formats(AVFilterContext *ctx)
static double av_q2d(AVRational a)
Convert rational to double.
#define AV_LOG_VERBOSE
Detailed information.
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)
static double alpha(void *priv, double x, double y)
int width
width and height of the video frame
#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.
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
AVPixelFormat
Pixel format.
int w
agreed upon image width
char * t_expr
expression for thickness
int av_expr_parse_and_eval(double *res, 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.
char * h_expr
expression for width and height
int format
agreed upon media format
Main libavfilter public API header.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
AVFilterLink ** outputs
array of pointers to output links
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
static const int NUM_EXPR_EVALS
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int hsub
chroma subsampling
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterContext * dst
dest filter
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.
#define RGB_TO_U_CCIR(r1, g1, b1, shift)
#define RGB_TO_V_CCIR(r1, g1, b1, shift)
static av_cold int init(AVFilterContext *ctx)
#define RGB_TO_Y_CCIR(r, g, b)
#define AVFILTER_DEFINE_CLASS(fname)
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
unsigned char yuv_color[4]
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)