111 double var_values[
VARS_NB], res;
121 var_values[
VAR_A] = (double) inlink->
w / inlink->
h;
150 if (adjusted_aspect.
num && adjusted_aspect.
den) {
163 s->
x = var_values[
VAR_X] = res;
168 s->
y = var_values[
VAR_Y] = res;
174 s->
x = var_values[
VAR_X] = res;
176 if (s->
x < 0 || s->
x + inlink->
w > s->
w)
177 s->
x = var_values[
VAR_X] = (s->
w - inlink->
w) / 2;
178 if (s->
y < 0 || s->
y + inlink->
h > s->
h)
179 s->
y = var_values[
VAR_Y] = (s->
h - inlink->
h) / 2;
182 if (s->
w < 0 || s->
h < 0) {
197 inlink->
w, inlink->
h, s->
w, s->
h, s->
x, s->
y,
200 if (s->
x < 0 || s->
y < 0 ||
201 s->
w <= 0 || s->
h <= 0 ||
202 (
unsigned)s->
x + (
unsigned)inlink->
w > s->
w ||
203 (
unsigned)s->
y + (
unsigned)inlink->
h > s->
h) {
205 "Input area %d:%d:%d:%d not within the padded area 0:0:%d:%d or zero-sized\n",
206 s->
x, s->
y, s->
x + inlink->
w, s->
y + inlink->
h, s->
w, s->
h);
214 "Error when evaluating the expression '%s'\n", expr);
238 w + (s->
w - s->
in_w),
239 h + (s->
h - s->
in_h) + (s->
x > 0));
260 int planes[4] = { -1, -1, -1, -1}, *p = planes;
271 for (i = 0; i < FF_ARRAY_ELEMS(planes) && planes[i] >= 0; i++) {
281 ptrdiff_t req_start = (s->
x >> hsub) * s->
draw.
pixelstep[planes[i]] +
282 (s->
y >> vsub) * frame->
linesize[planes[i]];
283 ptrdiff_t req_end = ((s->
w - s->
x - frame->
width) >> hsub) *
289 if (start - buf->
data < req_start ||
290 (buf->
data + buf->
size) - end < req_end)
293 for (j = 0; j < FF_ARRAY_ELEMS(planes) && planes[j] >= 0; j++) {
294 int vsub1 = s->
draw.
vsub[planes[j]];
301 if (
FFSIGN(start - end1) !=
FFSIGN(start - end1 - req_start) ||
317 for (i = 0; i < 4 && frame->
buf[i]; i++)
371 for (i = 0; i < 4 && out->
data[i] && out->
linesize[i]; i++) {
387 if (s->
h > s->
y + s->
in_h) {
416 #define OFFSET(x) offsetof(PadContext, x)
417 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
424 {
"x",
"set the x offset expression for the input image position",
OFFSET(x_expr),
AV_OPT_TYPE_STRING, {.str =
"0"}, CHAR_MIN, CHAR_MAX,
FLAGS },
425 {
"y",
"set the y offset expression for the input image position",
OFFSET(y_expr),
AV_OPT_TYPE_STRING, {.str =
"0"}, CHAR_MIN, CHAR_MAX,
FLAGS },
460 .priv_class = &pad_class,
462 .
inputs = avfilter_vf_pad_inputs,
463 .
outputs = avfilter_vf_pad_outputs,
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions.
static AVFrame * get_video_buffer(AVFilterLink *inlink, int w, int h)
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
This structure describes decoded (raw) audio or video data.
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.
Main libavfilter public API header.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int h
agreed upon image height
int in_h
width and height for the padded input video, which has to be aligned to the chroma values in order to...
Various defines for YUV<->RGB conversion.
char * x_expr
width expression string
static const AVFilterPad avfilter_vf_pad_outputs[]
static int config_output(AVFilterLink *outlink)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
int ff_draw_round_to_sub(FFDrawContext *draw, int sub_dir, int round_dir, int value)
Round a dimension according to subsampling.
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
AVFILTER_DEFINE_CLASS(pad)
static av_cold int end(AVCodecContext *avctx)
static const char *const var_names[]
#define AV_LOG_VERBOSE
Detailed information.
A filter pad used for either input or output.
A link between two filters.
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.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int config_input(AVFilterLink *inlink)
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
static const AVOption pad_options[]
int w
agreed upon image width
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static int frame_needs_copy(PadContext *s, AVFrame *frame)
static int buffer_needs_copy(PadContext *s, AVFrame *frame, AVBufferRef *buf)
AVBufferRef * av_frame_get_plane_buffer(AVFrame *frame, int plane)
Get the buffer reference a given data plane is stored in.
char * w_expr
width expression string
int y
offsets of the input area with respect to the padded area
AVFilterContext * src
source filter
static const AVFilterPad outputs[]
int format
agreed upon media format
#define FF_ARRAY_ELEMS(a)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
uint8_t rgba_color[4]
color for the padding area
static const AVFilterPad inputs[]
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static const AVFilterPad avfilter_vf_pad_inputs[]
int eval_mode
expression evaluation mode
uint8_t * data
The data buffer.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
const char * name
Filter name.
int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
Init a draw context.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterLink ** outputs
array of pointers to output links
int size
Size of data in bytes.
static int query_formats(AVFilterContext *ctx)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
A reference to a data buffer.
common internal and external API header
char * y_expr
height expression string
AVFilterContext * dst
dest filter
int pixelstep[MAX_PLANES]
int h
output dimensions, a value of 0 will result in the input size
char * h_expr
height expression string
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.
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
simple arithmetic expression evaluator