FFmpeg  4.4.9
vf_crop.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007 Bobby Bingham
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * video crop filter
24  */
25 
26 #include <stdio.h>
27 
28 #include "avfilter.h"
29 #include "formats.h"
30 #include "internal.h"
31 #include "video.h"
32 #include "libavutil/eval.h"
33 #include "libavutil/avstring.h"
34 #include "libavutil/internal.h"
35 #include "libavutil/libm.h"
36 #include "libavutil/imgutils.h"
37 #include "libavutil/mathematics.h"
38 #include "libavutil/opt.h"
39 
40 static const char *const var_names[] = {
41  "in_w", "iw", ///< width of the input video
42  "in_h", "ih", ///< height of the input video
43  "out_w", "ow", ///< width of the cropped video
44  "out_h", "oh", ///< height of the cropped video
45  "a",
46  "sar",
47  "dar",
48  "hsub",
49  "vsub",
50  "x",
51  "y",
52  "n", ///< number of frame
53  "pos", ///< position in the file
54  "t", ///< timestamp expressed in seconds
55  NULL
56 };
57 
58 enum var_name {
74 };
75 
76 typedef struct CropContext {
77  const AVClass *class;
78  int x; ///< x offset of the non-cropped area with respect to the input area
79  int y; ///< y offset of the non-cropped area with respect to the input area
80  int w; ///< width of the cropped area
81  int h; ///< height of the cropped area
82  int in_w, in_h; ///< input size the cropped area was computed for
83 
84  AVRational out_sar; ///< output sample aspect ratio
85  int keep_aspect; ///< keep display aspect ratio when cropping
86  int exact; ///< exact cropping, for subsampled formats
87 
88  int max_step[4]; ///< max pixel step for each plane, expressed as a number of bytes
89  int hsub, vsub; ///< chroma subsampling
90  char *x_expr, *y_expr, *w_expr, *h_expr;
91  AVExpr *x_pexpr, *y_pexpr; /* parsed expressions for x and y */
93 } CropContext;
94 
96 {
98  int ret;
99 
101  if (ret < 0)
102  return ret;
104 }
105 
107 {
108  CropContext *s = ctx->priv;
109 
110  av_expr_free(s->x_pexpr);
111  s->x_pexpr = NULL;
112  av_expr_free(s->y_pexpr);
113  s->y_pexpr = NULL;
114 }
115 
116 static inline int normalize_double(int *n, double d)
117 {
118  int ret = 0;
119 
120  if (isnan(d)) {
121  ret = AVERROR(EINVAL);
122  } else if (d > INT_MAX || d < INT_MIN) {
123  *n = d > INT_MAX ? INT_MAX : INT_MIN;
124  ret = AVERROR(EINVAL);
125  } else
126  *n = lrint(d);
127 
128  return ret;
129 }
130 
132 {
133  AVFilterContext *ctx = link->dst;
134  CropContext *s = ctx->priv;
135  const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(link->format);
136  int ret;
137  const char *expr;
138  double res;
139 
140  s->var_values[VAR_IN_W] = s->var_values[VAR_IW] = ctx->inputs[0]->w;
141  s->var_values[VAR_IN_H] = s->var_values[VAR_IH] = ctx->inputs[0]->h;
142  s->var_values[VAR_A] = (float) link->w / link->h;
143  s->var_values[VAR_SAR] = link->sample_aspect_ratio.num ? av_q2d(link->sample_aspect_ratio) : 1;
144  s->var_values[VAR_DAR] = s->var_values[VAR_A] * s->var_values[VAR_SAR];
145  s->var_values[VAR_HSUB] = 1<<pix_desc->log2_chroma_w;
146  s->var_values[VAR_VSUB] = 1<<pix_desc->log2_chroma_h;
147  s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = NAN;
148  s->var_values[VAR_OUT_H] = s->var_values[VAR_OH] = NAN;
149  s->var_values[VAR_N] = 0;
150  s->var_values[VAR_T] = NAN;
151  s->var_values[VAR_POS] = NAN;
152 
153  av_image_fill_max_pixsteps(s->max_step, NULL, pix_desc);
154 
155  if (pix_desc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
156  s->hsub = 1;
157  s->vsub = 1;
158  } else {
159  s->hsub = pix_desc->log2_chroma_w;
160  s->vsub = pix_desc->log2_chroma_h;
161  }
162 
163  av_expr_parse_and_eval(&res, (expr = s->w_expr),
164  var_names, s->var_values,
165  NULL, NULL, NULL, NULL, NULL, 0, ctx);
166  s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = res;
167  if ((ret = av_expr_parse_and_eval(&res, (expr = s->h_expr),
168  var_names, s->var_values,
169  NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
170  goto fail_expr;
171  s->var_values[VAR_OUT_H] = s->var_values[VAR_OH] = res;
172  /* evaluate again ow as it may depend on oh */
173  if ((ret = av_expr_parse_and_eval(&res, (expr = s->w_expr),
174  var_names, s->var_values,
175  NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
176  goto fail_expr;
177 
178  s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = res;
179  if (normalize_double(&s->w, s->var_values[VAR_OUT_W]) < 0 ||
180  normalize_double(&s->h, s->var_values[VAR_OUT_H]) < 0) {
182  "Too big value or invalid expression for out_w/ow or out_h/oh. "
183  "Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n",
184  s->w_expr, s->h_expr);
185  return AVERROR(EINVAL);
186  }
187 
188  if (!s->exact) {
189  s->w &= ~((1 << s->hsub) - 1);
190  s->h &= ~((1 << s->vsub) - 1);
191  }
192 
193  if (s->keep_aspect) {
195  (AVRational){ link->w, link->h });
196  av_reduce(&s->out_sar.num, &s->out_sar.den,
197  (int64_t)dar.num * s->h, (int64_t)dar.den * s->w, INT_MAX);
198  } else
199  s->out_sar = link->sample_aspect_ratio;
200 
201  av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d sar:%d/%d -> w:%d h:%d sar:%d/%d\n",
202  link->w, link->h, link->sample_aspect_ratio.num, link->sample_aspect_ratio.den,
203  s->w, s->h, s->out_sar.num, s->out_sar.den);
204 
205  if (s->w <= 0 || s->h <= 0 ||
206  s->w > link->w || s->h > link->h) {
208  "Invalid too big or non positive size for width '%d' or height '%d'\n",
209  s->w, s->h);
210  return AVERROR(EINVAL);
211  }
212 
213  /* set default, required in the case the first computed value for x/y is NAN */
214  s->x = (link->w - s->w) / 2;
215  s->y = (link->h - s->h) / 2;
216  if (!s->exact) {
217  s->x &= ~((1 << s->hsub) - 1);
218  s->y &= ~((1 << s->vsub) - 1);
219  }
220  s->in_w = link->w;
221  s->in_h = link->h;
222  return 0;
223 
224 fail_expr:
225  av_log(ctx, AV_LOG_ERROR, "Error when evaluating the expression '%s'\n", expr);
226  return ret;
227 }
228 
229 static int config_input(AVFilterLink *link)
230 {
231  CropContext *s = link->dst->priv;
232  AVExpr *x_pexpr = NULL, *y_pexpr = NULL;
233 
234  s->var_values[VAR_X] = NAN;
235  s->var_values[VAR_Y] = NAN;
236  if (av_expr_parse(&x_pexpr, s->x_expr, var_names,
237  NULL, NULL, NULL, NULL, 0, link->dst) < 0 ||
238  av_expr_parse(&y_pexpr, s->y_expr, var_names,
239  NULL, NULL, NULL, NULL, 0, link->dst) < 0) {
240  av_expr_free(x_pexpr);
241  return AVERROR(EINVAL);
242  }
243  av_expr_free(s->x_pexpr);
244  av_expr_free(s->y_pexpr);
245  s->x_pexpr = x_pexpr;
246  s->y_pexpr = y_pexpr;
247 
248  return config_crop_area(link);
249 }
250 
251 static int config_output(AVFilterLink *link)
252 {
253  CropContext *s = link->src->priv;
255 
256  if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
257  // Hardware frames adjust the cropping regions rather than
258  // changing the frame size.
259  } else {
260  link->w = s->w;
261  link->h = s->h;
262  }
263  link->sample_aspect_ratio = s->out_sar;
264 
265  return 0;
266 }
267 
269 {
270  AVFilterContext *ctx = link->dst;
271  CropContext *s = ctx->priv;
273  int i, ret;
274 
275  if (frame->width != s->in_w || frame->height != s->in_h) {
276  link->w = frame->width;
277  link->h = frame->height;
278  if ((ret = config_crop_area(link)) < 0 ||
279  (ret = config_output(ctx->outputs[0])) < 0) {
280  s->in_w = -1;
282  return ret;
283  }
284  }
285 
286  s->var_values[VAR_N] = link->frame_count_out;
287  s->var_values[VAR_T] = frame->pts == AV_NOPTS_VALUE ?
288  NAN : frame->pts * av_q2d(link->time_base);
289  s->var_values[VAR_POS] = frame->pkt_pos == -1 ?
290  NAN : frame->pkt_pos;
291  s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, NULL);
292  s->var_values[VAR_Y] = av_expr_eval(s->y_pexpr, s->var_values, NULL);
293  /* It is necessary if x is expressed from y */
294  s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, NULL);
295 
296  normalize_double(&s->x, s->var_values[VAR_X]);
297  normalize_double(&s->y, s->var_values[VAR_Y]);
298 
299  if (s->x < 0)
300  s->x = 0;
301  if (s->y < 0)
302  s->y = 0;
303  if ((unsigned)s->x + (unsigned)s->w > link->w)
304  s->x = link->w - s->w;
305  if ((unsigned)s->y + (unsigned)s->h > link->h)
306  s->y = link->h - s->h;
307  if (!s->exact) {
308  s->x &= ~((1 << s->hsub) - 1);
309  s->y &= ~((1 << s->vsub) - 1);
310  }
311 
312  av_log(ctx, AV_LOG_TRACE, "n:%d t:%f pos:%f x:%d y:%d x+w:%d y+h:%d\n",
313  (int)s->var_values[VAR_N], s->var_values[VAR_T], s->var_values[VAR_POS],
314  s->x, s->y, s->x+s->w, s->y+s->h);
315 
316  if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
317  frame->crop_top += s->y;
318  frame->crop_left += s->x;
321  } else {
322  frame->width = s->w;
323  frame->height = s->h;
324 
325  frame->data[0] += s->y * frame->linesize[0];
326  frame->data[0] += s->x * s->max_step[0];
327 
328  if (!(desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & FF_PSEUDOPAL)) {
329  for (i = 1; i < 3; i ++) {
330  if (frame->data[i]) {
331  frame->data[i] += (s->y >> s->vsub) * frame->linesize[i];
332  frame->data[i] += (s->x * s->max_step[i]) >> s->hsub;
333  }
334  }
335  }
336 
337  /* alpha plane */
338  if (frame->data[3]) {
339  frame->data[3] += s->y * frame->linesize[3];
340  frame->data[3] += s->x * s->max_step[3];
341  }
342  }
343 
344  return ff_filter_frame(link->dst->outputs[0], frame);
345 }
346 
347 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
348  char *res, int res_len, int flags)
349 {
350  CropContext *s = ctx->priv;
351  int ret;
352 
353  if ( !strcmp(cmd, "out_w") || !strcmp(cmd, "w")
354  || !strcmp(cmd, "out_h") || !strcmp(cmd, "h")
355  || !strcmp(cmd, "x") || !strcmp(cmd, "y")) {
356 
357  int old_x = s->x;
358  int old_y = s->y;
359  int old_w = s->w;
360  int old_h = s->h;
361 
362  AVFilterLink *outlink = ctx->outputs[0];
363  AVFilterLink *inlink = ctx->inputs[0];
364 
365  av_opt_set(s, cmd, args, 0);
366 
367  if ((ret = config_input(inlink)) < 0) {
368  s->x = old_x;
369  s->y = old_y;
370  s->w = old_w;
371  s->h = old_h;
372  return ret;
373  }
374 
375  ret = config_output(outlink);
376 
377  } else
378  ret = AVERROR(ENOSYS);
379 
380  return ret;
381 }
382 
383 #define OFFSET(x) offsetof(CropContext, x)
384 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
385 #define TFLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
386 
387 static const AVOption crop_options[] = {
388  { "out_w", "set the width crop area expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, 0, 0, TFLAGS },
389  { "w", "set the width crop area expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, 0, 0, TFLAGS },
390  { "out_h", "set the height crop area expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, 0, 0, TFLAGS },
391  { "h", "set the height crop area expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, 0, 0, TFLAGS },
392  { "x", "set the x crop area expression", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str = "(in_w-out_w)/2"}, 0, 0, TFLAGS },
393  { "y", "set the y crop area expression", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str = "(in_h-out_h)/2"}, 0, 0, TFLAGS },
394  { "keep_aspect", "keep aspect ratio", OFFSET(keep_aspect), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
395  { "exact", "do exact cropping", OFFSET(exact), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
396  { NULL }
397 };
398 
400 
402  {
403  .name = "default",
404  .type = AVMEDIA_TYPE_VIDEO,
405  .filter_frame = filter_frame,
406  .config_props = config_input,
407  },
408  { NULL }
409 };
410 
412  {
413  .name = "default",
414  .type = AVMEDIA_TYPE_VIDEO,
415  .config_props = config_output,
416  },
417  { NULL }
418 };
419 
421  .name = "crop",
422  .description = NULL_IF_CONFIG_SMALL("Crop the input video."),
423  .priv_size = sizeof(CropContext),
424  .priv_class = &crop_class,
426  .uninit = uninit,
430  .flags_internal = FF_FILTER_FLAG_DYNAMIC_FRAME_SIZE,
431 };
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
#define av_cold
Definition: attributes.h:88
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1099
Main libavfilter public API header.
#define flags(name, subs,...)
Definition: cbs_av1.c:572
#define s(width, name)
Definition: cbs_vp9.c:257
#define NULL
Definition: coverity.c:32
long long int64_t
Definition: coverity.c:34
static AVFrame * frame
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition: eval.c:339
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:781
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.
Definition: eval.c:791
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.
Definition: eval.c:700
simple arithmetic expression evaluator
int ff_formats_pixdesc_filter(AVFilterFormats **rfmts, unsigned want, unsigned rej)
Construct a formats list containing all pixel formats with certain properties.
Definition: formats.c:367
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:587
#define FF_PIX_FMT_FLAG_SW_FLAT_SUB
Definition: formats.h:240
@ AV_OPT_TYPE_BOOL
Definition: opt.h:242
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:220
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:210
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
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.
Definition: imgutils.c:35
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition: opt.c:475
misc image utilities
int i
Definition: input.c:407
#define FF_FILTER_FLAG_DYNAMIC_FRAME_SIZE
The filter handles input frames whose size differs from the one its input link was configured with.
Definition: internal.h:345
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
#define FF_PSEUDOPAL
Definition: internal.h:299
Replacements for frequently missing libm functions.
#define isnan(x)
Definition: libm.h:340
const char * desc
Definition: libsvtav1.c:83
#define NAN
Definition: mathematics.h:64
AVOptions.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2573
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
Definition: pixdesc.h:136
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition: pixdesc.h:140
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
Definition: pixdesc.h:132
var_name
Definition: setts_bsf.c:50
formats
Definition: signature.h:48
Describe the class of an AVClass context structure.
Definition: log.h:67
Definition: eval.c:159
An instance of a filter.
Definition: avfilter.h:341
void * priv
private data for use by the filter
Definition: avfilter.h:356
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:353
A list of supported formats for one end of a filter link.
Definition: formats.h:65
A filter pad used for either input or output.
Definition: internal.h:54
const char * name
Pad name.
Definition: internal.h:60
Filter definition.
Definition: avfilter.h:145
const char * name
Filter name.
Definition: avfilter.h:149
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:411
size_t crop_right
Definition: frame.h:681
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:332
int width
Definition: frame.h:376
int64_t pkt_pos
reordered pos from the last AVPacket that has been input into the decoder
Definition: frame.h:589
int height
Definition: frame.h:376
size_t crop_top
Definition: frame.h:678
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:349
size_t crop_left
Definition: frame.h:680
size_t crop_bottom
Definition: frame.h:679
AVOption.
Definition: opt.h:248
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:106
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
Rational number (pair of numerator and denominator).
Definition: rational.h:58
int num
Numerator.
Definition: rational.h:59
int den
Denominator.
Definition: rational.h:60
char * y_expr
Definition: vf_crop.c:90
int exact
exact cropping, for subsampled formats
Definition: vf_crop.c:86
int in_h
input size the cropped area was computed for
Definition: vf_crop.c:82
int in_w
Definition: vf_crop.c:82
int w
width of the cropped area
Definition: vf_crop.c:80
int h
height of the cropped area
Definition: vf_crop.c:81
int y
y offset of the non-cropped area with respect to the input area
Definition: vf_crop.c:79
char * w_expr
Definition: vf_crop.c:90
AVRational out_sar
output sample aspect ratio
Definition: vf_crop.c:84
char * x_expr
Definition: vf_crop.c:90
char * h_expr
Definition: vf_crop.c:90
AVExpr * x_pexpr
Definition: vf_crop.c:91
int x
x offset of the non-cropped area with respect to the input area
Definition: vf_crop.c:78
int max_step[4]
max pixel step for each plane, expressed as a number of bytes
Definition: vf_crop.c:88
int vsub
chroma subsampling
Definition: vf_crop.c:89
int keep_aspect
keep display aspect ratio when cropping
Definition: vf_crop.c:85
double var_values[VAR_VARS_NB]
Definition: vf_crop.c:92
int hsub
Definition: vf_crop.c:89
AVExpr * y_pexpr
Definition: vf_crop.c:91
#define lrint
Definition: tablegen.h:53
#define av_log(a,...)
AVFormatContext * ctx
Definition: movenc.c:48
@ VAR_VSUB
Definition: vf_crop.c:67
@ VAR_OUT_H
Definition: vf_crop.c:62
@ VAR_POS
Definition: vf_crop.c:71
@ VAR_SAR
Definition: vf_crop.c:64
@ VAR_OH
Definition: vf_crop.c:62
@ VAR_IN_W
Definition: vf_crop.c:59
@ VAR_IW
Definition: vf_crop.c:59
@ VAR_OW
Definition: vf_crop.c:61
@ VAR_N
Definition: vf_crop.c:70
@ VAR_IH
Definition: vf_crop.c:60
@ VAR_A
Definition: vf_crop.c:63
@ VAR_VARS_NB
Definition: vf_crop.c:73
@ VAR_OUT_W
Definition: vf_crop.c:61
@ VAR_HSUB
Definition: vf_crop.c:66
@ VAR_X
Definition: vf_crop.c:68
@ VAR_IN_H
Definition: vf_crop.c:60
@ VAR_DAR
Definition: vf_crop.c:65
@ VAR_T
Definition: vf_crop.c:72
@ VAR_Y
Definition: vf_crop.c:69
AVFILTER_DEFINE_CLASS(crop)
static int config_crop_area(AVFilterLink *link)
Definition: vf_crop.c:131
static int normalize_double(int *n, double d)
Definition: vf_crop.c:116
#define TFLAGS
Definition: vf_crop.c:385
static int query_formats(AVFilterContext *ctx)
Definition: vf_crop.c:95
#define FLAGS
Definition: vf_crop.c:384
static const AVFilterPad avfilter_vf_crop_outputs[]
Definition: vf_crop.c:411
static const AVFilterPad avfilter_vf_crop_inputs[]
Definition: vf_crop.c:401
static const AVOption crop_options[]
Definition: vf_crop.c:387
static int filter_frame(AVFilterLink *link, AVFrame *frame)
Definition: vf_crop.c:268
static const char *const var_names[]
Definition: vf_crop.c:40
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_crop.c:347
static int config_input(AVFilterLink *link)
Definition: vf_crop.c:229
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_crop.c:106
#define OFFSET(x)
Definition: vf_crop.c:383
static int config_output(AVFilterLink *link)
Definition: vf_crop.c:251
AVFilter ff_vf_crop
Definition: vf_crop.c:420