Go to the documentation of this file.
106 if ((
desc->log2_chroma_w ||
desc->log2_chroma_h) &&
134 }
else if (d > INT_MAX || d < INT_MIN) {
135 *
n = d > INT_MAX ? INT_MAX : INT_MIN;
197 "Too big value or invalid expression for out_w/ow or out_h/oh. "
198 "Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n",
199 s->w_expr,
s->h_expr);
204 s->w &= ~((1 <<
s->hsub) - 1);
205 s->h &= ~((1 <<
s->vsub) - 1);
210 s->x_pexpr =
s->y_pexpr =
NULL;
217 if (
s->keep_aspect) {
221 dar.
num *
s->h, dar.
den *
s->w, INT_MAX);
227 s->w,
s->h,
s->out_sar.num,
s->out_sar.den);
229 if (
s->w <= 0 ||
s->h <= 0 ||
232 "Invalid too big or non positive size for width '%d' or height '%d'\n",
238 s->x = (
link->w -
s->w) / 2;
239 s->y = (
link->h -
s->h) / 2;
241 s->x &= ~((1 <<
s->hsub) - 1);
242 s->y &= ~((1 <<
s->vsub) - 1);
292 if ((
unsigned)
s->x + (
unsigned)
s->w >
link->w)
294 if ((
unsigned)
s->y + (
unsigned)
s->h >
link->h)
297 s->x &= ~((1 <<
s->hsub) - 1);
298 s->y &= ~((1 <<
s->vsub) - 1);
303 s->x,
s->y,
s->x+
s->w,
s->y+
s->h);
315 frame->data[0] +=
s->x *
s->max_step[0];
318 for (
i = 1;
i < 3;
i ++) {
321 frame->data[
i] += (
s->x *
s->max_step[
i]) >>
s->hsub;
327 if (
frame->data[3]) {
329 frame->data[3] +=
s->x *
s->max_step[3];
337 char *res,
int res_len,
int flags)
342 if ( !strcmp(cmd,
"out_w") || !strcmp(cmd,
"w")
343 || !strcmp(cmd,
"out_h") || !strcmp(cmd,
"h")
344 || !strcmp(cmd,
"x") || !strcmp(cmd,
"y")) {
372 #define OFFSET(x) offsetof(CropContext, x)
373 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
412 .priv_class = &crop_class,
static int query_formats(AVFilterContext *ctx)
double var_values[VAR_VARS_NB]
static av_cold void uninit(AVFilterContext *ctx)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int x
x offset of the non-cropped area with respect to the input area
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
int y
y offset of the non-cropped area with respect to the input area
This structure describes decoded (raw) audio or video data.
int keep_aspect
keep display aspect ratio when cropping
static const AVOption crop_options[]
#define AV_LOG_VERBOSE
Detailed information.
const char * name
Filter name.
A link between two filters.
static int normalize_double(int *n, double d)
int w
width of the cropped area
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.
int vsub
chroma subsampling
static int config_output(AVFilterLink *link)
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
A filter pad used for either input or output.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
static const char *const var_names[]
static const AVFilterPad outputs[]
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
Describe the class of an AVClass context structure.
AVFILTER_DEFINE_CLASS(crop)
Rational number (pair of numerator and denominator).
int h
height of the cropped area
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
static int filter_frame(AVFilterLink *link, AVFrame *frame)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
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_NOPTS_VALUE
Undefined timestamp value.
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
int max_step[4]
max pixel step for each plane, expressed as a number of bytes
#define i(width, name, range_min, range_max)
static int config_input(AVFilterLink *link)
static const AVFilterPad avfilter_vf_crop_inputs[]
const char AVS_Value args
const char * name
Pad name.
AVRational out_sar
output sample aspect ratio
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
int exact
exact cropping, for subsampled formats
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
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.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static const AVFilterPad avfilter_vf_crop_outputs[]
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
#define flags(name, subs,...)
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.