Line | Branch | Exec | Source |
---|---|---|---|
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 "filters.h" | ||
30 | #include "formats.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 | #if FF_API_FRAME_PKT | ||
54 | "pos", ///< position in the file | ||
55 | #endif | ||
56 | "t", ///< timestamp expressed in seconds | ||
57 | NULL | ||
58 | }; | ||
59 | |||
60 | enum var_name { | ||
61 | VAR_IN_W, VAR_IW, | ||
62 | VAR_IN_H, VAR_IH, | ||
63 | VAR_OUT_W, VAR_OW, | ||
64 | VAR_OUT_H, VAR_OH, | ||
65 | VAR_A, | ||
66 | VAR_SAR, | ||
67 | VAR_DAR, | ||
68 | VAR_HSUB, | ||
69 | VAR_VSUB, | ||
70 | VAR_X, | ||
71 | VAR_Y, | ||
72 | VAR_N, | ||
73 | #if FF_API_FRAME_PKT | ||
74 | VAR_POS, | ||
75 | #endif | ||
76 | VAR_T, | ||
77 | VAR_VARS_NB | ||
78 | }; | ||
79 | |||
80 | typedef struct CropContext { | ||
81 | const AVClass *class; | ||
82 | int x; ///< x offset of the non-cropped area with respect to the input area | ||
83 | int y; ///< y offset of the non-cropped area with respect to the input area | ||
84 | int w; ///< width of the cropped area | ||
85 | int h; ///< height of the cropped area | ||
86 | |||
87 | AVRational out_sar; ///< output sample aspect ratio | ||
88 | int keep_aspect; ///< keep display aspect ratio when cropping | ||
89 | int exact; ///< exact cropping, for subsampled formats | ||
90 | |||
91 | int max_step[4]; ///< max pixel step for each plane, expressed as a number of bytes | ||
92 | int hsub, vsub; ///< chroma subsampling | ||
93 | char *x_expr, *y_expr, *w_expr, *h_expr; | ||
94 | AVExpr *x_pexpr, *y_pexpr; /* parsed expressions for x and y */ | ||
95 | double var_values[VAR_VARS_NB]; | ||
96 | } CropContext; | ||
97 | |||
98 | 193 | static int query_formats(AVFilterContext *ctx) | |
99 | { | ||
100 | 193 | int reject_flags = AV_PIX_FMT_FLAG_BITSTREAM | FF_PIX_FMT_FLAG_SW_FLAT_SUB; | |
101 | |||
102 | 193 | return ff_set_common_formats(ctx, ff_formats_pixdesc_filter(0, reject_flags)); | |
103 | } | ||
104 | |||
105 | 381 | static av_cold void uninit(AVFilterContext *ctx) | |
106 | { | ||
107 | 381 | CropContext *s = ctx->priv; | |
108 | |||
109 | 381 | av_expr_free(s->x_pexpr); | |
110 | 381 | s->x_pexpr = NULL; | |
111 | 381 | av_expr_free(s->y_pexpr); | |
112 | 381 | s->y_pexpr = NULL; | |
113 | 381 | } | |
114 | |||
115 | 3214 | static inline int normalize_double(int *n, double d) | |
116 | { | ||
117 | 3214 | int ret = 0; | |
118 | |||
119 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3214 times.
|
3214 | if (isnan(d)) { |
120 | ✗ | ret = AVERROR(EINVAL); | |
121 |
2/4✓ Branch 0 taken 3214 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3214 times.
|
3214 | } else if (d > INT_MAX || d < INT_MIN) { |
122 | ✗ | *n = d > INT_MAX ? INT_MAX : INT_MIN; | |
123 | ✗ | ret = AVERROR(EINVAL); | |
124 | } else | ||
125 | 3214 | *n = lrint(d); | |
126 | |||
127 | 3214 | return ret; | |
128 | } | ||
129 | |||
130 | 192 | static int config_input(AVFilterLink *link) | |
131 | { | ||
132 | 192 | AVFilterContext *ctx = link->dst; | |
133 | 192 | CropContext *s = ctx->priv; | |
134 | 192 | const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(link->format); | |
135 | int ret; | ||
136 | const char *expr; | ||
137 | double res; | ||
138 | |||
139 | 192 | s->var_values[VAR_IN_W] = s->var_values[VAR_IW] = ctx->inputs[0]->w; | |
140 | 192 | s->var_values[VAR_IN_H] = s->var_values[VAR_IH] = ctx->inputs[0]->h; | |
141 | 192 | s->var_values[VAR_A] = (float) link->w / link->h; | |
142 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 188 times.
|
192 | s->var_values[VAR_SAR] = link->sample_aspect_ratio.num ? av_q2d(link->sample_aspect_ratio) : 1; |
143 | 192 | s->var_values[VAR_DAR] = s->var_values[VAR_A] * s->var_values[VAR_SAR]; | |
144 | 192 | s->var_values[VAR_HSUB] = 1<<pix_desc->log2_chroma_w; | |
145 | 192 | s->var_values[VAR_VSUB] = 1<<pix_desc->log2_chroma_h; | |
146 | 192 | s->var_values[VAR_X] = NAN; | |
147 | 192 | s->var_values[VAR_Y] = NAN; | |
148 | 192 | s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = NAN; | |
149 | 192 | s->var_values[VAR_OUT_H] = s->var_values[VAR_OH] = NAN; | |
150 | 192 | s->var_values[VAR_N] = 0; | |
151 | 192 | s->var_values[VAR_T] = NAN; | |
152 | #if FF_API_FRAME_PKT | ||
153 | 192 | s->var_values[VAR_POS] = NAN; | |
154 | #endif | ||
155 | |||
156 | 192 | av_image_fill_max_pixsteps(s->max_step, NULL, pix_desc); | |
157 | |||
158 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
|
192 | if (pix_desc->flags & AV_PIX_FMT_FLAG_HWACCEL) { |
159 | ✗ | s->hsub = 1; | |
160 | ✗ | s->vsub = 1; | |
161 | } else { | ||
162 | 192 | s->hsub = pix_desc->log2_chroma_w; | |
163 | 192 | s->vsub = pix_desc->log2_chroma_h; | |
164 | } | ||
165 | |||
166 | 192 | av_expr_parse_and_eval(&res, (expr = s->w_expr), | |
167 | 192 | var_names, s->var_values, | |
168 | NULL, NULL, NULL, NULL, NULL, 0, ctx); | ||
169 | 192 | s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = res; | |
170 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
|
192 | if ((ret = av_expr_parse_and_eval(&res, (expr = s->h_expr), |
171 | 192 | var_names, s->var_values, | |
172 | NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) | ||
173 | ✗ | goto fail_expr; | |
174 | 192 | s->var_values[VAR_OUT_H] = s->var_values[VAR_OH] = res; | |
175 | /* evaluate again ow as it may depend on oh */ | ||
176 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
|
192 | if ((ret = av_expr_parse_and_eval(&res, (expr = s->w_expr), |
177 | 192 | var_names, s->var_values, | |
178 | NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) | ||
179 | ✗ | goto fail_expr; | |
180 | |||
181 | 192 | s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = res; | |
182 |
2/4✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 192 times.
|
384 | if (normalize_double(&s->w, s->var_values[VAR_OUT_W]) < 0 || |
183 | 192 | normalize_double(&s->h, s->var_values[VAR_OUT_H]) < 0) { | |
184 | ✗ | av_log(ctx, AV_LOG_ERROR, | |
185 | "Too big value or invalid expression for out_w/ow or out_h/oh. " | ||
186 | "Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n", | ||
187 | s->w_expr, s->h_expr); | ||
188 | ✗ | return AVERROR(EINVAL); | |
189 | } | ||
190 | |||
191 |
1/2✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
|
192 | if (!s->exact) { |
192 | 192 | s->w &= ~((1 << s->hsub) - 1); | |
193 | 192 | s->h &= ~((1 << s->vsub) - 1); | |
194 | } | ||
195 | |||
196 | 192 | av_expr_free(s->x_pexpr); | |
197 | 192 | av_expr_free(s->y_pexpr); | |
198 | 192 | s->x_pexpr = s->y_pexpr = NULL; | |
199 |
1/2✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
|
192 | if ((ret = av_expr_parse(&s->x_pexpr, s->x_expr, var_names, |
200 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
|
192 | NULL, NULL, NULL, NULL, 0, ctx)) < 0 || |
201 | 192 | (ret = av_expr_parse(&s->y_pexpr, s->y_expr, var_names, | |
202 | NULL, NULL, NULL, NULL, 0, ctx)) < 0) | ||
203 | ✗ | return AVERROR(EINVAL); | |
204 | |||
205 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
|
192 | if (s->keep_aspect) { |
206 | ✗ | AVRational dar = av_mul_q(link->sample_aspect_ratio, | |
207 | ✗ | (AVRational){ link->w, link->h }); | |
208 | ✗ | av_reduce(&s->out_sar.num, &s->out_sar.den, | |
209 | ✗ | (int64_t)dar.num * s->h, (int64_t)dar.den * s->w, INT_MAX); | |
210 | } else | ||
211 | 192 | s->out_sar = link->sample_aspect_ratio; | |
212 | |||
213 | 192 | av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d sar:%d/%d -> w:%d h:%d sar:%d/%d\n", | |
214 | link->w, link->h, link->sample_aspect_ratio.num, link->sample_aspect_ratio.den, | ||
215 | s->w, s->h, s->out_sar.num, s->out_sar.den); | ||
216 | |||
217 |
2/4✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
|
192 | if (s->w <= 0 || s->h <= 0 || |
218 |
2/4✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 192 times.
|
192 | s->w > link->w || s->h > link->h) { |
219 | ✗ | av_log(ctx, AV_LOG_ERROR, | |
220 | "Invalid too big or non positive size for width '%d' or height '%d'\n", | ||
221 | s->w, s->h); | ||
222 | ✗ | return AVERROR(EINVAL); | |
223 | } | ||
224 | |||
225 | /* set default, required in the case the first computed value for x/y is NAN */ | ||
226 | 192 | s->x = (link->w - s->w) / 2; | |
227 | 192 | s->y = (link->h - s->h) / 2; | |
228 |
1/2✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
|
192 | if (!s->exact) { |
229 | 192 | s->x &= ~((1 << s->hsub) - 1); | |
230 | 192 | s->y &= ~((1 << s->vsub) - 1); | |
231 | } | ||
232 | 192 | return 0; | |
233 | |||
234 | ✗ | fail_expr: | |
235 | ✗ | av_log(ctx, AV_LOG_ERROR, "Error when evaluating the expression '%s'\n", expr); | |
236 | ✗ | return ret; | |
237 | } | ||
238 | |||
239 | 192 | static int config_output(AVFilterLink *link) | |
240 | { | ||
241 | 192 | CropContext *s = link->src->priv; | |
242 | 192 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format); | |
243 | |||
244 |
1/2✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
|
192 | if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) { |
245 | // Hardware frames adjust the cropping regions rather than | ||
246 | // changing the frame size. | ||
247 | } else { | ||
248 | 192 | link->w = s->w; | |
249 | 192 | link->h = s->h; | |
250 | } | ||
251 | 192 | link->sample_aspect_ratio = s->out_sar; | |
252 | |||
253 | 192 | return 0; | |
254 | } | ||
255 | |||
256 | 1415 | static int filter_frame(AVFilterLink *link, AVFrame *frame) | |
257 | { | ||
258 | 1415 | FilterLink *l = ff_filter_link(link); | |
259 | 1415 | AVFilterContext *ctx = link->dst; | |
260 | 1415 | CropContext *s = ctx->priv; | |
261 | 1415 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format); | |
262 | int i; | ||
263 | |||
264 | 1415 | s->var_values[VAR_N] = l->frame_count_out; | |
265 | 2830 | s->var_values[VAR_T] = frame->pts == AV_NOPTS_VALUE ? | |
266 |
1/2✓ Branch 0 taken 1415 times.
✗ Branch 1 not taken.
|
1415 | NAN : frame->pts * av_q2d(link->time_base); |
267 | #if FF_API_FRAME_PKT | ||
268 | FF_DISABLE_DEPRECATION_WARNINGS | ||
269 | 2830 | s->var_values[VAR_POS] = frame->pkt_pos == -1 ? | |
270 |
2/2✓ Branch 0 taken 1198 times.
✓ Branch 1 taken 217 times.
|
1415 | NAN : frame->pkt_pos; |
271 | FF_ENABLE_DEPRECATION_WARNINGS | ||
272 | #endif | ||
273 | 1415 | s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, NULL); | |
274 | 1415 | s->var_values[VAR_Y] = av_expr_eval(s->y_pexpr, s->var_values, NULL); | |
275 | /* It is necessary if x is expressed from y */ | ||
276 | 1415 | s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, NULL); | |
277 | |||
278 | 1415 | normalize_double(&s->x, s->var_values[VAR_X]); | |
279 | 1415 | normalize_double(&s->y, s->var_values[VAR_Y]); | |
280 | |||
281 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1415 times.
|
1415 | if (s->x < 0) |
282 | ✗ | s->x = 0; | |
283 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1415 times.
|
1415 | if (s->y < 0) |
284 | ✗ | s->y = 0; | |
285 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1415 times.
|
1415 | if ((unsigned)s->x + (unsigned)s->w > link->w) |
286 | ✗ | s->x = link->w - s->w; | |
287 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1415 times.
|
1415 | if ((unsigned)s->y + (unsigned)s->h > link->h) |
288 | ✗ | s->y = link->h - s->h; | |
289 |
1/2✓ Branch 0 taken 1415 times.
✗ Branch 1 not taken.
|
1415 | if (!s->exact) { |
290 | 1415 | s->x &= ~((1 << s->hsub) - 1); | |
291 | 1415 | s->y &= ~((1 << s->vsub) - 1); | |
292 | } | ||
293 | |||
294 | 1415 | av_log(ctx, AV_LOG_TRACE, "n:%d t:%f x:%d y:%d x+w:%d y+h:%d\n", | |
295 | 1415 | (int)s->var_values[VAR_N], s->var_values[VAR_T], | |
296 | 1415 | s->x, s->y, s->x+s->w, s->y+s->h); | |
297 | |||
298 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1415 times.
|
1415 | if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) { |
299 | ✗ | frame->crop_top += s->y; | |
300 | ✗ | frame->crop_left += s->x; | |
301 | ✗ | frame->crop_bottom = frame->height - frame->crop_top - frame->crop_bottom - s->h; | |
302 | ✗ | frame->crop_right = frame->width - frame->crop_left - frame->crop_right - s->w; | |
303 | } else { | ||
304 | 1415 | frame->width = s->w; | |
305 | 1415 | frame->height = s->h; | |
306 | |||
307 | 1415 | frame->data[0] += s->y * frame->linesize[0]; | |
308 | 1415 | frame->data[0] += s->x * s->max_step[0]; | |
309 | |||
310 |
2/2✓ Branch 0 taken 1414 times.
✓ Branch 1 taken 1 times.
|
1415 | if (!(desc->flags & AV_PIX_FMT_FLAG_PAL)) { |
311 |
2/2✓ Branch 0 taken 2828 times.
✓ Branch 1 taken 1414 times.
|
4242 | for (i = 1; i < 3; i ++) { |
312 |
2/2✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 141 times.
|
2828 | if (frame->data[i]) { |
313 | 2687 | frame->data[i] += (s->y >> s->vsub) * frame->linesize[i]; | |
314 | 2687 | frame->data[i] += (s->x * s->max_step[i]) >> s->hsub; | |
315 | } | ||
316 | } | ||
317 | } | ||
318 | |||
319 | /* alpha plane */ | ||
320 |
2/2✓ Branch 0 taken 37 times.
✓ Branch 1 taken 1378 times.
|
1415 | if (frame->data[3]) { |
321 | 37 | frame->data[3] += s->y * frame->linesize[3]; | |
322 | 37 | frame->data[3] += s->x * s->max_step[3]; | |
323 | } | ||
324 | } | ||
325 | |||
326 | 1415 | return ff_filter_frame(link->dst->outputs[0], frame); | |
327 | } | ||
328 | |||
329 | ✗ | static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, | |
330 | char *res, int res_len, int flags) | ||
331 | { | ||
332 | ✗ | CropContext *s = ctx->priv; | |
333 | int ret; | ||
334 | |||
335 | ✗ | if ( !strcmp(cmd, "out_w") || !strcmp(cmd, "w") | |
336 | ✗ | || !strcmp(cmd, "out_h") || !strcmp(cmd, "h") | |
337 | ✗ | || !strcmp(cmd, "x") || !strcmp(cmd, "y")) { | |
338 | |||
339 | ✗ | int old_x = s->x; | |
340 | ✗ | int old_y = s->y; | |
341 | ✗ | int old_w = s->w; | |
342 | ✗ | int old_h = s->h; | |
343 | |||
344 | ✗ | AVFilterLink *outlink = ctx->outputs[0]; | |
345 | ✗ | AVFilterLink *inlink = ctx->inputs[0]; | |
346 | |||
347 | ✗ | av_opt_set(s, cmd, args, 0); | |
348 | |||
349 | ✗ | if ((ret = config_input(inlink)) < 0) { | |
350 | ✗ | s->x = old_x; | |
351 | ✗ | s->y = old_y; | |
352 | ✗ | s->w = old_w; | |
353 | ✗ | s->h = old_h; | |
354 | ✗ | return ret; | |
355 | } | ||
356 | |||
357 | ✗ | ret = config_output(outlink); | |
358 | |||
359 | } else | ||
360 | ✗ | ret = AVERROR(ENOSYS); | |
361 | |||
362 | ✗ | return ret; | |
363 | } | ||
364 | |||
365 | #define OFFSET(x) offsetof(CropContext, x) | ||
366 | #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM | ||
367 | #define TFLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM | ||
368 | |||
369 | static const AVOption crop_options[] = { | ||
370 | { "out_w", "set the width crop area expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, 0, 0, TFLAGS }, | ||
371 | { "w", "set the width crop area expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, 0, 0, TFLAGS }, | ||
372 | { "out_h", "set the height crop area expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, 0, 0, TFLAGS }, | ||
373 | { "h", "set the height crop area expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, 0, 0, TFLAGS }, | ||
374 | { "x", "set the x crop area expression", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str = "(in_w-out_w)/2"}, 0, 0, TFLAGS }, | ||
375 | { "y", "set the y crop area expression", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str = "(in_h-out_h)/2"}, 0, 0, TFLAGS }, | ||
376 | { "keep_aspect", "keep aspect ratio", OFFSET(keep_aspect), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS }, | ||
377 | { "exact", "do exact cropping", OFFSET(exact), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS }, | ||
378 | { NULL } | ||
379 | }; | ||
380 | |||
381 | AVFILTER_DEFINE_CLASS(crop); | ||
382 | |||
383 | static const AVFilterPad avfilter_vf_crop_inputs[] = { | ||
384 | { | ||
385 | .name = "default", | ||
386 | .type = AVMEDIA_TYPE_VIDEO, | ||
387 | .filter_frame = filter_frame, | ||
388 | .config_props = config_input, | ||
389 | }, | ||
390 | }; | ||
391 | |||
392 | static const AVFilterPad avfilter_vf_crop_outputs[] = { | ||
393 | { | ||
394 | .name = "default", | ||
395 | .type = AVMEDIA_TYPE_VIDEO, | ||
396 | .config_props = config_output, | ||
397 | }, | ||
398 | }; | ||
399 | |||
400 | const AVFilter ff_vf_crop = { | ||
401 | .name = "crop", | ||
402 | .description = NULL_IF_CONFIG_SMALL("Crop the input video."), | ||
403 | .priv_size = sizeof(CropContext), | ||
404 | .priv_class = &crop_class, | ||
405 | .uninit = uninit, | ||
406 | FILTER_INPUTS(avfilter_vf_crop_inputs), | ||
407 | FILTER_OUTPUTS(avfilter_vf_crop_outputs), | ||
408 | FILTER_QUERY_FUNC(query_formats), | ||
409 | .process_command = process_command, | ||
410 | }; | ||
411 |