32 #include "libavutil/eval.h"
33 #include "libavutil/avstring.h"
36 #include "libavutil/imgutils.h"
37 #include "libavutil/mathematics.h"
38 #include "libavutil/opt.h"
134 }
else if (d > INT_MAX || d < INT_MIN) {
135 *n = d > INT_MAX ? INT_MAX : INT_MIN;
188 "Too big value or invalid expression for out_w/ow or out_h/oh. "
189 "Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n",
193 s->
w &= ~((1 << s->
hsub) - 1);
194 s->
h &= ~((1 << s->
vsub) - 1);
206 link->
w, link->
h, s->
w, s->
h);
208 if (s->
w <= 0 || s->
h <= 0 ||
209 s->
w > link->
w || s->
h > link->
h) {
211 "Invalid too big or non positive size for width '%d' or height '%d'\n",
217 s->
x = (link->
w - s->
w) / 2;
218 s->
y = (link->
h - s->
h) / 2;
219 s->
x &= ~((1 << s->
hsub) - 1);
220 s->
y &= ~((1 << s->
vsub) - 1);
261 if ((
unsigned)s->
x + (
unsigned)s->
w > link->
w)
262 s->
x = link->
w - s->
w;
263 if ((
unsigned)s->
y + (
unsigned)s->
h > link->
h)
264 s->
y = link->
h - s->
h;
265 s->
x &= ~((1 << s->
hsub) - 1);
266 s->
y &= ~((1 << s->
vsub) - 1);
268 av_dlog(ctx,
"n:%d t:%f x:%d y:%d x+w:%d y+h:%d\n",
270 s->
y, s->
x+s->
w, s->
y+s->
h);
276 for (i = 1; i < 3; i ++) {
277 if (frame->
data[i]) {
285 if (frame->
data[3]) {
295 #define OFFSET(x) offsetof(CropContext, x)
296 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM
300 {
"x",
"Horizontal position in the input video of the left edge of the cropped output video",
302 {
"y",
"Vertical position in the input video of the top edge of the cropped output video",
339 .priv_class = &crop_class,
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
This structure describes decoded (raw) audio or video data.
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
const char * name
Filter name.
packed RGB 8:8:8, 24bpp, RGBRGB...
static int config_input(AVFilterLink *link)
void * priv
private data for use by the filter
static const AVFilterPad outputs[]
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
int h
agreed upon image height
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
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.
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
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.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
int x
x offset of the non-cropped area with respect to the input area
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int y
y offset of the non-cropped area with respect to the input area
static av_always_inline av_const int isnan(float x)
int max_step[4]
max pixel step for each plane, expressed as a number of bytes
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
static const AVFilterPad avfilter_vf_crop_outputs[]
static double av_q2d(AVRational a)
Convert rational to double.
#define AV_LOG_VERBOSE
Detailed information.
static const AVFilterPad avfilter_vf_crop_inputs[]
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 ...
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1 ...
#define AV_PIX_FMT_FLAG_PSEUDOPAL
The pixel format is "pseudo-paletted".
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
A link between two filters.
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
double var_values[VAR_VARS_NB]
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
AVFilterContext * src
source filter
static av_always_inline av_const double round(double x)
AVPixelFormat
Pixel format.
static const AVClass crop_class
int w
agreed upon image width
common internal API header
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
int av_expr_parse_and_eval(double *res, 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:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
static int query_formats(AVFilterContext *ctx)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
int format
agreed upon media format
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
Main libavfilter public API header.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
int h
height of the cropped area
8 bit with PIX_FMT_RGB32 palette
int vsub
chroma subsampling
AVFilterLink ** outputs
array of pointers to output links
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 RGB 8:8:8, 24bpp, BGRBGR...
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
Replacements for frequently missing libm functions.
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
AVFilterLink ** inputs
array of pointers to input links
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
AVFilterContext * dst
dest filter
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
static const char *const var_names[]
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1 ...
static int normalize_double(int *n, double d)
static int config_output(AVFilterLink *link)
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as lit...
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
struct AVFilterPad AVFilterPad
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Y , 16bpp, little-endian.
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
static const AVOption options[]
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big...
int w
width of the cropped area
av_default_item_name
Return the context name.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define AV_NOPTS_VALUE
Undefined timestamp value.
static int filter_frame(AVFilterLink *link, AVFrame *frame)