75 char x_expr[256], y_expr[256], ow_expr[256], oh_expr[256];
142 }
else if (d > INT_MAX || d < INT_MIN) {
143 *n = d > INT_MAX ? INT_MAX : INT_MIN;
193 "Too big value or invalid expression for out_w/ow or out_h/oh. "
194 "Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n",
198 crop->
w &= ~((1 << crop->
hsub) - 1);
199 crop->
h &= ~((1 << crop->
vsub) - 1);
208 link->
w, link->
h, crop->
w, crop->
h);
210 if (crop->
w <= 0 || crop->
h <= 0 ||
211 crop->
w > link->
w || crop->
h > link->
h) {
213 "Invalid too big or non positive size for width '%d' or height '%d'\n",
219 crop->
x = (link->
w - crop->
w) / 2;
220 crop->
y = (link->
h - crop->
h) / 2;
221 crop->
x &= ~((1 << crop->
hsub) - 1);
222 crop->
y &= ~((1 << crop->
vsub) - 1);
261 if (crop->
x < 0) crop->
x = 0;
262 if (crop->
y < 0) crop->
y = 0;
263 if ((
unsigned)crop->
x + (
unsigned)crop->
w > link->
w) crop->
x = link->
w - crop->
w;
264 if ((
unsigned)crop->
y + (
unsigned)crop->
h > link->
h) crop->
y = link->
h - crop->
h;
265 crop->
x &= ~((1 << crop->
hsub) - 1);
266 crop->
y &= ~((1 << crop->
vsub) - 1);
268 av_dlog(ctx,
"n:%d t:%f x:%d y:%d x+w:%d y+h:%d\n",
270 crop->
y, crop->
x+crop->
w, crop->
y+crop->
h);
276 for (i = 1; i < 3; i ++) {
298 if (y >= crop->
y + crop->
h || y + h <= crop->y)
305 if (y + h > crop->
y + crop->
h)
306 h = crop->
y + crop->
h - y;
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
AVFilterBufferRefVideoProps * video
video buffer specific properties
int linesize[8]
number of bytes per line
static int config_input(AVFilterLink *link)
int h
agreed upon image height
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static const char * var_names[]
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.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
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.
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
AVFilterLink ** inputs
array of pointers to input links
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1 ...
int x
x offset of the non-cropped area with respect to the input area
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
int y
y offset of the non-cropped area with respect to the input area
static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
int max_step[4]
max pixel step for each plane, expressed as a number of bytes
void avfilter_end_frame(AVFilterLink *link)
Notifie the next filter that the current frame has finished.
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
static double av_q2d(AVRational a)
Convert rational to double.
AVFilter avfilter_vf_crop
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
int64_t pts
presentation timestamp.
A filter pad used for either input or output.
Y , 16bpp, little-endian.
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.
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
double var_values[VAR_VARS_NB]
#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
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
#define PIX_FMT_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
void av_log(void *avcl, int level, const char *fmt,...)
AVFilterFormats * avfilter_make_format_list(const int *fmts)
Create a list of supported formats.
static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB]
The array of all the pixel format descriptors.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
int w
agreed upon image width
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big...
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
AVFilterContext * src
source filter
void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
Send a slice to the next filter.
static int query_formats(AVFilterContext *ctx)
#define av_dlog(pctx,...)
av_dlog macros Useful to print debug messages that shouldn't get compiled in normally.
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
int format
agreed upon media format
int h
height of the cropped area
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Remove a reference to a buffer.
int vsub
chroma subsampling
A reference to an AVFilterBuffer.
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static av_cold void uninit(AVFilterContext *ctx)
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 ...
Replacements for frequently missing libm functions.
AVFilterBufferRef * avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
Add a new reference to a buffer.
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1 ...
void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
Notify the next filter of the start of a frame.
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
const char * name
filter name
packed RGB 8:8:8, 24bpp, BGRBGR...
AVFilterBufferRef * avfilter_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
get_video_buffer() handler for filters which simply pass video along
AVFilterLink ** outputs
array of pointers to output links
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as lit...
static int normalize_double(int *n, double d)
static int config_output(AVFilterLink *link)
8 bit with PIX_FMT_RGB32 palette
packed RGB 8:8:8, 24bpp, RGBRGB...
int64_t pos
byte position in stream, -1 if unknown
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
AVFilterContext * dst
dest filter
uint8_t * data[8]
picture/audio data for each plane
AVFilterBufferRef * cur_buf
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
static void end_frame(AVFilterLink *link)
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
int w
width of the cropped area
#define AV_NOPTS_VALUE
Undefined timestamp value.
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
simple arithmetic expression evaluator
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)