History

avfilter/vf_fillborders: add support for commands

Paul B Mahol committed 6 years ago

Commit fbcb1411 parent 84e9a552 files · +35 −15Browse files

Unified · Split

2 files
  1. doc/filters.texi +7 −0
  2. libavfilter/vf_fillborders.c +28 −15
doc/filters.texi+7−0
@@ -10745,6 +10745,13 @@ Default is @var{smear}. · 10744 unmodified lines
10745Set color for pixels in fixed mode. Default is @var{black}.10745Set color for pixels in fixed mode. Default is @var{black}.
10746@end table10746@end table
10747 10747
10748@subsection Commands
10749This filter supports same @ref{commands} as options.
10750The command accepts the same syntax of the corresponding option.
10751
10752If the specified expression is not valid, it is kept at its current
10753value.
10754
10748@section find_rect10755@section find_rect
10749 10756
10750Find a rectangular object10757Find a rectangular object
libavfilter/vf_fillborders.c+28−15
@@ -292,6 +292,20 @@ static int config_input(AVFilterLink *inlink) · 291 unmodified lines
292 s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);292 s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
293 s->planewidth[0] = s->planewidth[3] = inlink->w;293 s->planewidth[0] = s->planewidth[3] = inlink->w;
294 294
295 if (inlink->w < s->left + s->right ||
296 inlink->w <= s->left ||
297 inlink->w <= s->right ||
298 inlink->h < s->top + s->bottom ||
299 inlink->h <= s->top ||
300 inlink->h <= s->bottom ||
301 inlink->w < s->left * 2 ||
302 inlink->w < s->right * 2 ||
303 inlink->h < s->top * 2 ||
304 inlink->h < s->bottom * 2) {
305 av_log(ctx, AV_LOG_ERROR, "Borders are bigger than input frame size.\n");
306 return AVERROR(EINVAL);
307 }
308
295 s->borders[0].left = s->borders[3].left = s->left;309 s->borders[0].left = s->borders[3].left = s->left;
296 s->borders[0].right = s->borders[3].right = s->right;310 s->borders[0].right = s->borders[3].right = s->right;
297 s->borders[0].top = s->borders[3].top = s->top;311 s->borders[0].top = s->borders[3].top = s->top;
@@ -307,20 +321,6 @@ static int config_input(AVFilterLink *inlink) · 9 unmodified lines
307 s->borders[2].top = s->top >> desc->log2_chroma_h;321 s->borders[2].top = s->top >> desc->log2_chroma_h;
308 s->borders[2].bottom = s->bottom >> desc->log2_chroma_h;322 s->borders[2].bottom = s->bottom >> desc->log2_chroma_h;
309 323
310 if (inlink->w < s->left + s->right ||
311 inlink->w <= s->left ||
312 inlink->w <= s->right ||
313 inlink->h < s->top + s->bottom ||
314 inlink->h <= s->top ||
315 inlink->h <= s->bottom ||
316 inlink->w < s->left * 2 ||
317 inlink->w < s->right * 2 ||
318 inlink->h < s->top * 2 ||
319 inlink->h < s->bottom * 2) {
320 av_log(ctx, AV_LOG_ERROR, "Borders are bigger than input frame size.\n");
321 return AVERROR(EINVAL);
322 }
323
324 switch (s->mode) {324 switch (s->mode) {
325 case FM_SMEAR: s->fillborders = s->depth <= 8 ? smear_borders8 : smear_borders16; break;325 case FM_SMEAR: s->fillborders = s->depth <= 8 ? smear_borders8 : smear_borders16; break;
326 case FM_MIRROR: s->fillborders = s->depth <= 8 ? mirror_borders8 : mirror_borders16; break;326 case FM_MIRROR: s->fillborders = s->depth <= 8 ? mirror_borders8 : mirror_borders16; break;
@@ -346,8 +346,20 @@ static int config_input(AVFilterLink *inlink) · 19 unmodified lines
346 return 0;346 return 0;
347}347}
348 348
349static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
350 char *res, int res_len, int flags)
351{
352 int ret;
353
354 ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
355 if (ret < 0)
356 return ret;
357
358 return config_input(ctx->inputs[0]);
359}
360
349#define OFFSET(x) offsetof(FillBordersContext, x)361#define OFFSET(x) offsetof(FillBordersContext, x)
350#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM362#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
351 363
352static const AVOption fillborders_options[] = {364static const AVOption fillborders_options[] = {
353 { "left", "set the left fill border", OFFSET(left), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },365 { "left", "set the left fill border", OFFSET(left), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
@@ -392,4 +404,5 @@ AVFilter ff_vf_fillborders = { · 38 unmodified lines
392 .inputs = fillborders_inputs,404 .inputs = fillborders_inputs,
393 .outputs = fillborders_outputs,405 .outputs = fillborders_outputs,
394 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,406 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
407 .process_command = process_command,
395};408};

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t