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
1074510745 Set color for pixels in fixed mode. Default is @var{black}.
1074610746 @end table
1074710747
10748+@subsection Commands
10749+This filter supports same @ref{commands} as options.
10750+The command accepts the same syntax of the corresponding option.
10751+
10752+If the specified expression is not valid, it is kept at its current
10753+value.
10754+
1074810755 @section find_rect
1074910756
1075010757 Find a rectangular object
libavfilter/vf_fillborders.c+28−15
@@ -292,6 +292,20 @@ static int config_input(AVFilterLink *inlink) · 291 unmodified lines
292292 s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
293293 s->planewidth[0] = s->planewidth[3] = inlink->w;
294294
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+
295309 s->borders[0].left = s->borders[3].left = s->left;
296310 s->borders[0].right = s->borders[3].right = s->right;
297311 s->borders[0].top = s->borders[3].top = s->top;
@@ -307,20 +321,6 @@ static int config_input(AVFilterLink *inlink) · 9 unmodified lines
307321 s->borders[2].top = s->top >> desc->log2_chroma_h;
308322 s->borders[2].bottom = s->bottom >> desc->log2_chroma_h;
309323
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−
324324 switch (s->mode) {
325325 case FM_SMEAR: s->fillborders = s->depth <= 8 ? smear_borders8 : smear_borders16; break;
326326 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
346346 return 0;
347347 }
348348
349+static 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+
349361 #define OFFSET(x) offsetof(FillBordersContext, x)
350−#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
362+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
351363
352364 static const AVOption fillborders_options[] = {
353365 { "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
392404 .inputs = fillborders_inputs,
393405 .outputs = fillborders_outputs,
394406 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
407+ .process_command = process_command,
395408 };

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