121 }
else if (d > INT_MAX || d < INT_MIN) {
122 *n = d > INT_MAX ? INT_MAX : INT_MIN;
141 s->var_values[
VAR_A] = (float) link->
w / link->
h;
183 "Too big value or invalid expression for out_w/ow or out_h/oh. "
184 "Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n",
185 s->w_expr,
s->h_expr);
190 s->w &= ~((1 <<
s->hsub) - 1);
191 s->h &= ~((1 <<
s->vsub) - 1);
196 s->x_pexpr =
s->y_pexpr =
NULL;
203 if (
s->keep_aspect) {
207 dar.
num *
s->h, dar.
den *
s->w, INT_MAX);
213 s->w,
s->h,
s->out_sar.num,
s->out_sar.den);
215 if (
s->w <= 0 ||
s->h <= 0 ||
216 s->w > link->
w ||
s->h > link->
h) {
218 "Invalid too big or non positive size for width '%d' or height '%d'\n",
224 s->x = (link->
w -
s->w) / 2;
225 s->y = (link->
h -
s->h) / 2;
227 s->x &= ~((1 <<
s->hsub) - 1);
228 s->y &= ~((1 <<
s->vsub) - 1);
278 if ((
unsigned)
s->x + (
unsigned)
s->w > link->
w)
279 s->x = link->
w -
s->w;
280 if ((
unsigned)
s->y + (
unsigned)
s->h > link->
h)
281 s->y = link->
h -
s->h;
283 s->x &= ~((1 <<
s->hsub) - 1);
284 s->y &= ~((1 <<
s->vsub) - 1);
289 s->x,
s->y,
s->x+
s->w,
s->y+
s->h);
304 for (
i = 1;
i < 3;
i ++) {
323 char *res,
int res_len,
int flags)
328 if ( !strcmp(cmd,
"out_w") || !strcmp(cmd,
"w")
329 || !strcmp(cmd,
"out_h") || !strcmp(cmd,
"h")
330 || !strcmp(cmd,
"x") || !strcmp(cmd,
"y")) {
358 #define OFFSET(x) offsetof(CropContext, x)
359 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
360 #define TFLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
399 .priv_class = &crop_class,
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define flags(name, subs,...)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
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.
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
simple arithmetic expression evaluator
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], const AVPixFmtDescriptor *pixdesc)
Compute the max pixel step for each plane of an image with a format described by pixdesc.
#define AV_NOPTS_VALUE
Undefined timestamp value.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Replacements for frequently missing libm functions.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
Describe the class of an AVClass context structure.
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 time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
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.
const char * name
Pad name.
const char * name
Filter name.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int64_t pkt_pos
reordered pos from the last AVPacket that has been input into the decoder
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Rational number (pair of numerator and denominator).
int exact
exact cropping, for subsampled formats
int w
width of the cropped area
int h
height of the cropped area
int y
y offset of the non-cropped area with respect to the input area
AVRational out_sar
output sample aspect ratio
int x
x offset of the non-cropped area with respect to the input area
int max_step[4]
max pixel step for each plane, expressed as a number of bytes
int vsub
chroma subsampling
int keep_aspect
keep display aspect ratio when cropping
double var_values[VAR_VARS_NB]
AVFILTER_DEFINE_CLASS(crop)
static int normalize_double(int *n, double d)
static int query_formats(AVFilterContext *ctx)
static const AVFilterPad avfilter_vf_crop_outputs[]
static const AVFilterPad avfilter_vf_crop_inputs[]
static const AVOption crop_options[]
static int filter_frame(AVFilterLink *link, AVFrame *frame)
static const char *const var_names[]
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static int config_input(AVFilterLink *link)
static av_cold void uninit(AVFilterContext *ctx)
static int config_output(AVFilterLink *link)