FFmpeg
Loading...
Searching...
No Matches
vf_drawbox.c File Reference

Box and grid drawing filters. More...

#include "config_components.h"
#include "libavutil/colorspace.h"
#include "libavutil/common.h"
#include "libavutil/opt.h"
#include "libavutil/eval.h"
#include "libavutil/pixdesc.h"
#include "libavutil/parseutils.h"
#include "libavutil/detection_bbox.h"
#include "avfilter.h"
#include "drawutils.h"
#include "filters.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  DrawBoxContext
 

Macros

#define ASSIGN_THREE_CHANNELS
 
#define ASSIGN_FOUR_CHANNELS
 
#define ASSIGN_THREE_CHANNELS_PACKED
 
#define ASSIGN_FOUR_CHANNELS_PACKED
 
#define OFFSET(x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 

Typedefs

typedef int(* PixelBelongsToRegion) (struct DrawBoxContext *s, int x, int y)
 

Enumerations

enum  { Y , U , V , A }
 
enum  { R , G , B }
 
enum  var_name {
  VAR_DAR , VAR_HSUB , VAR_VSUB , VAR_IN_H ,
  VAR_IH , VAR_IN_W , VAR_IW , VAR_SAR ,
  VAR_X , VAR_Y , VAR_H , VAR_W ,
  VAR_T , VAR_MAX , VARS_NB
}
 

Functions

static void draw_region (AVFrame *frame, DrawBoxContext *ctx, int left, int top, int right, int down, PixelBelongsToRegion pixel_belongs_to_region)
 
static void draw_region_rgb_packed (AVFrame *frame, DrawBoxContext *ctx, int left, int top, int right, int down, PixelBelongsToRegion pixel_belongs_to_region)
 
static enum AVFrameSideDataType box_source_string_parse (const char *box_source_string)
 
static av_cold int init (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static av_pure av_always_inline int pixel_belongs_to_box (DrawBoxContext *s, int x, int y)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *frame)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 

Variables

static const char *const var_names []
 
static const int NUM_EXPR_EVALS = 5
 
static enum AVPixelFormat pix_fmts []
 

Detailed Description

Box and grid drawing filters.

Also a nice template for a filter that needs to write in the input frame.

Definition in file vf_drawbox.c.

Macro Definition Documentation

◆ ASSIGN_THREE_CHANNELS

#define ASSIGN_THREE_CHANNELS
Value:
row[0] = frame->data[0] + y * frame->linesize[0]; \
row[1] = frame->data[1] + (y >> ctx->vsub) * frame->linesize[1]; \
row[2] = frame->data[2] + (y >> ctx->vsub) * frame->linesize[2];
static AVFrame * frame
static AVFormatContext * ctx
Definition movenc.c:49

Definition at line 104 of file vf_drawbox.c.

Referenced by draw_region().

◆ ASSIGN_FOUR_CHANNELS

#define ASSIGN_FOUR_CHANNELS
Value:
ASSIGN_THREE_CHANNELS \
row[3] = frame->data[3] + y * frame->linesize[3];

Definition at line 109 of file vf_drawbox.c.

Referenced by draw_region().

◆ ASSIGN_THREE_CHANNELS_PACKED

#define ASSIGN_THREE_CHANNELS_PACKED
Value:
row[0] = frame->data[0] + y * frame->linesize[0] + ctx->rgba_map[0]; \
row[1] = frame->data[0] + y * frame->linesize[0] + ctx->rgba_map[1]; \
row[2] = frame->data[0] + y * frame->linesize[0] + ctx->rgba_map[2];

Definition at line 158 of file vf_drawbox.c.

Referenced by draw_region_rgb_packed().

◆ ASSIGN_FOUR_CHANNELS_PACKED

#define ASSIGN_FOUR_CHANNELS_PACKED
Value:
ASSIGN_THREE_CHANNELS_PACKED \
row[3] = frame->data[0] + y * frame->linesize[0] + ctx->rgba_map[3];

Definition at line 163 of file vf_drawbox.c.

Referenced by draw_region_rgb_packed().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 441 of file vf_drawbox.c.

◆ FLAGS

Typedef Documentation

◆ PixelBelongsToRegion

typedef int(* PixelBelongsToRegion) (struct DrawBoxContext *s, int x, int y)

Definition at line 77 of file vf_drawbox.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator

Definition at line 57 of file vf_drawbox.c.

◆ anonymous enum

anonymous enum
Enumerator

Definition at line 58 of file vf_drawbox.c.

◆ var_name

enum var_name
Enumerator
VAR_DAR 
VAR_HSUB 
VAR_VSUB 
VAR_IN_H 
VAR_IH 
VAR_IN_W 
VAR_IW 
VAR_SAR 
VAR_X 
VAR_Y 
VAR_H 
VAR_W 
VAR_T 
VAR_MAX 
VARS_NB 

Definition at line 60 of file vf_drawbox.c.

Function Documentation

◆ draw_region()

static void draw_region ( AVFrame * frame,
DrawBoxContext * ctx,
int left,
int top,
int right,
int down,
PixelBelongsToRegion pixel_belongs_to_region )
static

Definition at line 113 of file vf_drawbox.c.

Referenced by config_input().

◆ draw_region_rgb_packed()

static void draw_region_rgb_packed ( AVFrame * frame,
DrawBoxContext * ctx,
int left,
int top,
int right,
int down,
PixelBelongsToRegion pixel_belongs_to_region )
static

Definition at line 167 of file vf_drawbox.c.

Referenced by config_input().

◆ box_source_string_parse()

static enum AVFrameSideDataType box_source_string_parse ( const char * box_source_string)
static

Definition at line 219 of file vf_drawbox.c.

Referenced by init().

◆ init()

static av_cold int init ( AVFilterContext * ctx)
static

Definition at line 230 of file vf_drawbox.c.

◆ config_input()

static int config_input ( AVFilterLink * inlink)
static

Definition at line 271 of file vf_drawbox.c.

Referenced by process_command().

◆ pixel_belongs_to_box()

static av_pure av_always_inline int pixel_belongs_to_box ( DrawBoxContext * s,
int x,
int y )
static

Definition at line 366 of file vf_drawbox.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink * inlink,
AVFrame * frame )
static

Definition at line 372 of file vf_drawbox.c.

◆ process_command()

static int process_command ( AVFilterContext * ctx,
const char * cmd,
const char * args,
char * res,
int res_len,
int flags )
static

Definition at line 408 of file vf_drawbox.c.

Variable Documentation

◆ var_names

const char* const var_names[]
static
Initial value:
= {
"dar",
"hsub", "vsub",
"in_h", "ih",
"in_w", "iw",
"sar",
"x",
"y",
"h",
"w",
"t",
"fill",
}
#define NULL
Definition coverity.c:32

Definition at line 42 of file vf_drawbox.c.

◆ NUM_EXPR_EVALS

const int NUM_EXPR_EVALS = 5
static

Definition at line 102 of file vf_drawbox.c.

Referenced by config_input(), and drawbox_vaapi_config_output().

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static
Initial value:
= {
}
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition pixfmt.h:75
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition pixfmt.h:106
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition pixfmt.h:265
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition pixfmt.h:99
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition pixfmt.h:102
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition pixfmt.h:101
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition pixfmt.h:108
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition pixfmt.h:107
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition pixfmt.h:79
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition pixfmt.h:264
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition pixfmt.h:80
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition pixfmt.h:100
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition pixfmt.h:174
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition pixfmt.h:86
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition pixfmt.h:263
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition pixfmt.h:173
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition pixfmt.h:76
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition pixfmt.h:262
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition pixfmt.h:87
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition pixfmt.h:85

Definition at line 257 of file vf_drawbox.c.