114 double var_values[
VARS_NB], res;
132 var_values[
VAR_HSUB] = 1 <<
s->draw.hsub_max;
133 var_values[
VAR_VSUB] = 1 <<
s->draw.vsub_max;
157 if (adjusted_aspect.
num && adjusted_aspect.
den) {
170 s->x = var_values[
VAR_X] = res;
175 s->y = var_values[
VAR_Y] = res;
181 s->x = var_values[
VAR_X] = res;
183 if (
s->x < 0 ||
s->x + inlink->
w >
s->w)
184 s->x = var_values[
VAR_X] = (
s->w - inlink->
w) / 2;
185 if (
s->y < 0 ||
s->y + inlink->
h >
s->h)
186 s->y = var_values[
VAR_Y] = (
s->h - inlink->
h) / 2;
191 if (
s->w < inlink->
w ||
s->h < inlink->
h) {
200 s->inlink_w = inlink->
w;
201 s->inlink_h = inlink->
h;
204 inlink->
w, inlink->
h,
s->w,
s->h,
s->x,
s->y,
205 s->rgba_color[0],
s->rgba_color[1],
s->rgba_color[2],
s->rgba_color[3]);
207 if (
s->x < 0 ||
s->y < 0 ||
208 s->w <= 0 ||
s->h <= 0 ||
209 (
unsigned)
s->x + (
unsigned)inlink->
w >
s->w ||
210 (
unsigned)
s->y + (
unsigned)inlink->
h >
s->h) {
212 "Input area %d:%d:%d:%d not within the padded area 0:0:%d:%d or zero-sized\n",
213 s->x,
s->y,
s->x + inlink->
w,
s->y + inlink->
h,
s->w,
s->h);
221 "Error when evaluating the expression '%s'\n", expr);
241 if (
s->inlink_w <= 0)
245 w + (
s->w -
s->in_w),
246 h + (
s->h -
s->in_h) + (
s->x > 0));
254 for (plane = 0; plane < 4 &&
frame->data[plane] &&
frame->linesize[plane]; plane++) {
255 int hsub =
s->draw.hsub[plane];
256 int vsub =
s->draw.vsub[plane];
257 frame->data[plane] += (
s->x >>
hsub) *
s->draw.pixelstep[plane] +
258 (
s->y >> vsub) *
frame->linesize[plane];
283 uint8_t *end = start + (
frame->height >> vsub) *
288 ptrdiff_t req_start = (
s->x >>
hsub) *
s->draw.pixelstep[
planes[
i]] +
290 ptrdiff_t req_end = ((
s->w -
s->x -
frame->width) >>
hsub) *
296 if (start - buf->
data < req_start ||
297 (buf->
data + buf->
size) - end < req_end)
301 int vsub1 =
s->draw.vsub[
planes[j]];
303 uint8_t *end1 = start1 + (
frame->height >> vsub1) *
308 if (
FFSIGN(start - end1) !=
FFSIGN(start - end1 - req_start) ||
378 for (
i = 0;
i < 4 &&
out->data[
i] &&
out->linesize[
i];
i++) {
379 int hsub =
s->draw.hsub[
i];
380 int vsub =
s->draw.vsub[
i];
381 out->data[
i] -= (
s->x >>
hsub) *
s->draw.pixelstep[
i] +
382 (
s->y >> vsub) *
out->linesize[
i];
394 if (
s->h >
s->y +
s->in_h) {
397 0,
s->y +
s->in_h,
s->w,
s->h -
s->y -
s->in_h);
412 s->x +
s->in_w,
s->y,
s->w -
s->x -
s->in_w,
423#define OFFSET(x) offsetof(PadContext, x)
424#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
464 .p.priv_class = &pad_class,
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int config_input(AVFilterLink *inlink)
static AVFrame * get_video_buffer(AVFilterLink *inlink, int w, int h)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
common internal and external API header
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
void ff_copy_rectangle2(FFDrawContext *draw, uint8_t *dst[], int dst_linesize[], uint8_t *src[], int src_linesize[], int dst_x, int dst_y, int src_x, int src_y, int w, int h)
Copy a rectangle from an image to another.
int ff_draw_round_to_sub(FFDrawContext *draw, int sub_dir, int round_dir, int value)
Round a dimension according to subsampling.
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions.
void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_x, int dst_y, int w, int h)
Fill a rectangle with an uniform color.
int ff_draw_init_from_link(FFDrawContext *draw, const AVFilterLink *link, unsigned flags)
Init a draw context, taking the format, colorspace and range from the given filter link.
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
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_RATIONAL
Underlying C type is AVRational.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ 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...
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVBufferRef * av_frame_get_plane_buffer(const AVFrame *frame, int plane)
Get the buffer reference a given data plane is stored in.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static int config_output(AVBitStreamFilterLink *outlink)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
Various defines for YUV<->RGB conversion.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const struct @257111027162314367033347246032313251342043035002 planes[]
static const char *const var_names[]
#define FF_ARRAY_ELEMS(a)
A reference to a data buffer.
uint8_t * data
The data buffer.
size_t size
Size of data in bytes.
Describe the class of an AVClass context structure.
AVFilterLink ** inputs
array of pointers to input links
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
AVFilterContext * src
source filter
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.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Rational number (pair of numerator and denominator).
char * w_expr
width expression string
int eval_mode
expression evaluation mode
uint8_t rgba_color[4]
color for the padding area
int in_h
width and height for the padded input video, which has to be aligned to the chroma values in order to...
int h
output dimensions, a value of 0 will result in the input size
char * h_expr
height expression string
char * y_expr
height expression string
char * x_expr
width expression string
int y
offsets of the input area with respect to the padded area
static AVFormatContext * ctx
static const AVFilterPad avfilter_vf_pad_inputs[]
static const AVFilterPad avfilter_vf_pad_outputs[]
static int buffer_needs_copy(PadContext *s, AVFrame *frame, AVBufferRef *buf)
static const AVOption pad_options[]
static AVFrame * get_video_buffer(AVFilterLink *inlink, int w, int h)
static int config_input(AVFilterLink *inlink)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int config_output(AVFilterLink *outlink)
static int frame_needs_copy(PadContext *s, AVFrame *frame)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.