1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avfilter/vf_fillborders: add support for commands

This commit is contained in:
Paul B Mahol 2019-11-21 12:07:58 +01:00
parent 84e9a55d8e
commit fbcb141c06
2 changed files with 35 additions and 15 deletions

View File

@ -10745,6 +10745,13 @@ Default is @var{smear}.
Set color for pixels in fixed mode. Default is @var{black}. Set color for pixels in fixed mode. Default is @var{black}.
@end table @end table
@subsection Commands
This filter supports same @ref{commands} as options.
The command accepts the same syntax of the corresponding option.
If the specified expression is not valid, it is kept at its current
value.
@section find_rect @section find_rect
Find a rectangular object Find a rectangular object

View File

@ -292,6 +292,20 @@ static int config_input(AVFilterLink *inlink)
s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w); s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
s->planewidth[0] = s->planewidth[3] = inlink->w; s->planewidth[0] = s->planewidth[3] = inlink->w;
if (inlink->w < s->left + s->right ||
inlink->w <= s->left ||
inlink->w <= s->right ||
inlink->h < s->top + s->bottom ||
inlink->h <= s->top ||
inlink->h <= s->bottom ||
inlink->w < s->left * 2 ||
inlink->w < s->right * 2 ||
inlink->h < s->top * 2 ||
inlink->h < s->bottom * 2) {
av_log(ctx, AV_LOG_ERROR, "Borders are bigger than input frame size.\n");
return AVERROR(EINVAL);
}
s->borders[0].left = s->borders[3].left = s->left; s->borders[0].left = s->borders[3].left = s->left;
s->borders[0].right = s->borders[3].right = s->right; s->borders[0].right = s->borders[3].right = s->right;
s->borders[0].top = s->borders[3].top = s->top; s->borders[0].top = s->borders[3].top = s->top;
@ -307,20 +321,6 @@ static int config_input(AVFilterLink *inlink)
s->borders[2].top = s->top >> desc->log2_chroma_h; s->borders[2].top = s->top >> desc->log2_chroma_h;
s->borders[2].bottom = s->bottom >> desc->log2_chroma_h; s->borders[2].bottom = s->bottom >> desc->log2_chroma_h;
if (inlink->w < s->left + s->right ||
inlink->w <= s->left ||
inlink->w <= s->right ||
inlink->h < s->top + s->bottom ||
inlink->h <= s->top ||
inlink->h <= s->bottom ||
inlink->w < s->left * 2 ||
inlink->w < s->right * 2 ||
inlink->h < s->top * 2 ||
inlink->h < s->bottom * 2) {
av_log(ctx, AV_LOG_ERROR, "Borders are bigger than input frame size.\n");
return AVERROR(EINVAL);
}
switch (s->mode) { switch (s->mode) {
case FM_SMEAR: s->fillborders = s->depth <= 8 ? smear_borders8 : smear_borders16; break; case FM_SMEAR: s->fillborders = s->depth <= 8 ? smear_borders8 : smear_borders16; break;
case FM_MIRROR: s->fillborders = s->depth <= 8 ? mirror_borders8 : mirror_borders16; break; case FM_MIRROR: s->fillborders = s->depth <= 8 ? mirror_borders8 : mirror_borders16; break;
@ -346,8 +346,20 @@ static int config_input(AVFilterLink *inlink)
return 0; return 0;
} }
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
char *res, int res_len, int flags)
{
int ret;
ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
if (ret < 0)
return ret;
return config_input(ctx->inputs[0]);
}
#define OFFSET(x) offsetof(FillBordersContext, x) #define OFFSET(x) offsetof(FillBordersContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
static const AVOption fillborders_options[] = { static const AVOption fillborders_options[] = {
{ "left", "set the left fill border", OFFSET(left), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS }, { "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 = {
.inputs = fillborders_inputs, .inputs = fillborders_inputs,
.outputs = fillborders_outputs, .outputs = fillborders_outputs,
.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
.process_command = process_command,
}; };