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

video padding filter More...

#include <float.h>
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "video.h"
#include "libavutil/avstring.h"
#include "libavutil/common.h"
#include "libavutil/eval.h"
#include "libavutil/pixdesc.h"
#include "libavutil/colorspace.h"
#include "libavutil/imgutils.h"
#include "libavutil/parseutils.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "drawutils.h"

Go to the source code of this file.

Data Structures

struct  PadContext
 

Macros

#define OFFSET(x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 

Enumerations

enum  var_name {
  VAR_IN_W , VAR_IW , VAR_IN_H , VAR_IH ,
  VAR_OUT_W , VAR_OW , VAR_OUT_H , VAR_OH ,
  VAR_X , VAR_Y , VAR_A , VAR_SAR ,
  VAR_DAR , VAR_HSUB , VAR_VSUB , VARS_NB
}
 
enum  EvalMode { EVAL_MODE_INIT , EVAL_MODE_FRAME , EVAL_MODE_NB }
 

Functions

static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
static int config_input (AVFilterLink *inlink)
 
static int config_output (AVFilterLink *outlink)
 
static AVFrameget_video_buffer (AVFilterLink *inlink, int w, int h)
 
static int buffer_needs_copy (PadContext *s, AVFrame *frame, AVBufferRef *buf)
 
static int frame_needs_copy (PadContext *s, AVFrame *frame)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
 AVFILTER_DEFINE_CLASS (pad)
 

Variables

static const char *const var_names []
 
static const AVOption pad_options []
 
static const AVFilterPad avfilter_vf_pad_inputs []
 
static const AVFilterPad avfilter_vf_pad_outputs []
 
const FFFilter ff_vf_pad
 

Detailed Description

video padding filter

Definition in file vf_pad.c.

Macro Definition Documentation

◆ OFFSET

#define OFFSET ( x)
Value:
offsetof(PadContext, x)

Definition at line 423 of file vf_pad.c.

◆ FLAGS

Definition at line 424 of file vf_pad.c.

Enumeration Type Documentation

◆ var_name

enum var_name
Enumerator
VAR_IN_W 
VAR_IW 
VAR_IN_H 
VAR_IH 
VAR_OUT_W 
VAR_OW 
VAR_OUT_H 
VAR_OH 
VAR_X 
VAR_Y 
VAR_A 
VAR_SAR 
VAR_DAR 
VAR_HSUB 
VAR_VSUB 
VARS_NB 

Definition at line 60 of file vf_pad.c.

◆ EvalMode

enum EvalMode
Enumerator
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 

Definition at line 83 of file vf_pad.c.

Function Documentation

◆ query_formats()

static int query_formats ( const AVFilterContext * ctx,
AVFilterFormatsConfig ** cfg_in,
AVFilterFormatsConfig ** cfg_out )
static

Definition at line 75 of file vf_pad.c.

◆ config_input()

static int config_input ( AVFilterLink * inlink)
static

Definition at line 108 of file vf_pad.c.

Referenced by filter_frame().

◆ config_output()

static int config_output ( AVFilterLink * outlink)
static

Definition at line 226 of file vf_pad.c.

Referenced by filter_frame().

◆ get_video_buffer()

static AVFrame * get_video_buffer ( AVFilterLink * inlink,
int w,
int h )
static

Definition at line 235 of file vf_pad.c.

◆ buffer_needs_copy()

static int buffer_needs_copy ( PadContext * s,
AVFrame * frame,
AVBufferRef * buf )
static

Definition at line 265 of file vf_pad.c.

Referenced by frame_needs_copy().

◆ frame_needs_copy()

static int frame_needs_copy ( PadContext * s,
AVFrame * frame )
static

Definition at line 317 of file vf_pad.c.

Referenced by filter_frame().

◆ filter_frame()

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

Definition at line 330 of file vf_pad.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( pad )

Variable Documentation

◆ var_names

const char* const var_names[]
static
Initial value:
= {
"in_w", "iw",
"in_h", "ih",
"out_w", "ow",
"out_h", "oh",
"x",
"y",
"a",
"sar",
"dar",
"hsub",
"vsub",
}
#define NULL
Definition coverity.c:32

Definition at line 45 of file vf_pad.c.

◆ pad_options

const AVOption pad_options[]
static
Initial value:
= {
{ "width", "set the pad area width expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, 0, 0, FLAGS },
{ "w", "set the pad area width expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, 0, 0, FLAGS },
{ "height", "set the pad area height expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, 0, 0, FLAGS },
{ "h", "set the pad area height expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, 0, 0, FLAGS },
{ "x", "set the x offset expression for the input image position", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str = "0"}, 0, 0, FLAGS },
{ "y", "set the y offset expression for the input image position", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str = "0"}, 0, 0, FLAGS },
{ "color", "set the color of the padded area border", OFFSET(rgba_color), AV_OPT_TYPE_COLOR, {.str = "black"}, .flags = FLAGS },
{ "eval", "specify when to evaluate expressions", OFFSET(eval_mode), AV_OPT_TYPE_INT, {.i64 = EVAL_MODE_INIT}, 0, EVAL_MODE_NB-1, FLAGS, .unit = "eval" },
{ "init", "eval expressions once during initialization", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_INIT}, .flags = FLAGS, .unit = "eval" },
{ "frame", "eval expressions during initialization and per-frame", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_FRAME}, .flags = FLAGS, .unit = "eval" },
{ "aspect", "pad to fit an aspect instead of a resolution", OFFSET(aspect), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, DBL_MAX, FLAGS },
{ NULL }
}
@ EVAL_MODE_NB
Definition af_volume.h:42
@ EVAL_MODE_FRAME
Definition af_volume.h:41
#define FLAGS
Definition cmdutils.c:598
#define OFFSET(x)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_RATIONAL
Underlying C type is AVRational.
Definition opt.h:279
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
Definition opt.h:322
@ EVAL_MODE_INIT
Definition vf_fftfilt.c:41

Definition at line 426 of file vf_pad.c.

◆ avfilter_vf_pad_inputs

const AVFilterPad avfilter_vf_pad_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
.get_buffer.video = get_video_buffer,
.filter_frame = filter_frame,
},
}
static int config_input(AVFilterLink *inlink)
static AVFrame * get_video_buffer(AVFilterLink *inlink, int w, int h)
Definition avf_concat.c:205
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200

Definition at line 443 of file vf_pad.c.

◆ avfilter_vf_pad_outputs

const AVFilterPad avfilter_vf_pad_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}
static int config_output(AVBitStreamFilterLink *outlink)

Definition at line 453 of file vf_pad.c.

◆ ff_vf_pad

const FFFilter ff_vf_pad
Initial value:
= {
.p.name = "pad",
.p.description = NULL_IF_CONFIG_SMALL("Pad the input video."),
.p.priv_class = &pad_class,
.priv_size = sizeof(PadContext),
}
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:241
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static const AVFilterPad avfilter_vf_pad_inputs[]
Definition vf_pad.c:443
static const AVFilterPad avfilter_vf_pad_outputs[]
Definition vf_pad.c:453

Definition at line 461 of file vf_pad.c.