mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-08 13:22:53 +02:00
Merge commit '40c885c589808455a1c4b473509f1e6cd4908f55'
* commit '40c885c589808455a1c4b473509f1e6cd4908f55': vf_pad: switch to an AVOptions-based system. Conflicts: doc/filters.texi libavfilter/vf_pad.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
7e99ccf5d8
@ -4469,14 +4469,7 @@ testsrc=s=100x100, split=4 [in0][in1][in2][in3];
|
|||||||
Add paddings to the input image, and place the original input at the
|
Add paddings to the input image, and place the original input at the
|
||||||
given coordinates @var{x}, @var{y}.
|
given coordinates @var{x}, @var{y}.
|
||||||
|
|
||||||
The filter accepts parameters as a list of @var{key}=@var{value} pairs,
|
This filter accepts the following parameters:
|
||||||
separated by ":".
|
|
||||||
|
|
||||||
If the key of the first options is omitted, the arguments are
|
|
||||||
interpreted according to the syntax
|
|
||||||
@var{width}:@var{height}:@var{x}:@var{y}:@var{color}.
|
|
||||||
|
|
||||||
A description of the accepted options follows.
|
|
||||||
|
|
||||||
@table @option
|
@table @option
|
||||||
@item width, w
|
@item width, w
|
||||||
|
@ -677,6 +677,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
|
|||||||
!strcmp(filter->filter->name, "lutrgb" ) ||
|
!strcmp(filter->filter->name, "lutrgb" ) ||
|
||||||
!strcmp(filter->filter->name, "negate" ) ||
|
!strcmp(filter->filter->name, "negate" ) ||
|
||||||
!strcmp(filter->filter->name, "overlay" ) ||
|
!strcmp(filter->filter->name, "overlay" ) ||
|
||||||
|
!strcmp(filter->filter->name, "pad" ) ||
|
||||||
!strcmp(filter->filter->name, "format") ||
|
!strcmp(filter->filter->name, "format") ||
|
||||||
!strcmp(filter->filter->name, "noformat") ||
|
!strcmp(filter->filter->name, "noformat") ||
|
||||||
!strcmp(filter->filter->name, "resample") ||
|
!strcmp(filter->filter->name, "resample") ||
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
#include "libavutil/opt.h"
|
#include "libavutil/opt.h"
|
||||||
#include "libavutil/parseutils.h"
|
#include "libavutil/parseutils.h"
|
||||||
#include "libavutil/mathematics.h"
|
#include "libavutil/mathematics.h"
|
||||||
|
#include "libavutil/opt.h"
|
||||||
|
|
||||||
#include "drawutils.h"
|
#include "drawutils.h"
|
||||||
|
|
||||||
static const char *const var_names[] = {
|
static const char *const var_names[] = {
|
||||||
@ -82,32 +84,16 @@ typedef struct {
|
|||||||
int x, y; ///< offsets of the input area with respect to the padded area
|
int x, y; ///< offsets of the input area with respect to the padded area
|
||||||
int in_w, in_h; ///< width and height for the padded input video, which has to be aligned to the chroma values in order to avoid chroma issues
|
int in_w, in_h; ///< width and height for the padded input video, which has to be aligned to the chroma values in order to avoid chroma issues
|
||||||
|
|
||||||
char *w_expr; ///< width expression string
|
char *w_expr; ///< width expression string
|
||||||
char *h_expr; ///< height expression string
|
char *h_expr; ///< height expression string
|
||||||
char *x_expr; ///< width expression string
|
char *x_expr; ///< width expression string
|
||||||
char *y_expr; ///< height expression string
|
char *y_expr; ///< height expression string
|
||||||
char *color_str;
|
char *color_str;
|
||||||
uint8_t rgba_color[4]; ///< color for the padding area
|
uint8_t rgba_color[4]; ///< color for the padding area
|
||||||
FFDrawContext draw;
|
FFDrawContext draw;
|
||||||
FFDrawColor color;
|
FFDrawColor color;
|
||||||
} PadContext;
|
} PadContext;
|
||||||
|
|
||||||
#define OFFSET(x) offsetof(PadContext, x)
|
|
||||||
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
|
|
||||||
|
|
||||||
static const AVOption pad_options[] = {
|
|
||||||
{ "width", "set the pad area width expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, CHAR_MIN, CHAR_MAX, FLAGS },
|
|
||||||
{ "w", "set the pad area width expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, CHAR_MIN, CHAR_MAX, FLAGS },
|
|
||||||
{ "height", "set the pad area height expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, CHAR_MIN, CHAR_MAX, FLAGS },
|
|
||||||
{ "h", "set the pad area height expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, CHAR_MIN, CHAR_MAX, FLAGS },
|
|
||||||
{ "x", "set the x offset expression for the input image position", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX, FLAGS },
|
|
||||||
{ "y", "set the y offset expression for the input image position", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX, FLAGS },
|
|
||||||
{ "color", "set the color of the padded area border", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = "black"}, .flags = FLAGS },
|
|
||||||
{NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
AVFILTER_DEFINE_CLASS(pad);
|
|
||||||
|
|
||||||
static av_cold int init(AVFilterContext *ctx, const char *args)
|
static av_cold int init(AVFilterContext *ctx, const char *args)
|
||||||
{
|
{
|
||||||
PadContext *pad = ctx->priv;
|
PadContext *pad = ctx->priv;
|
||||||
@ -382,6 +368,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
return ff_filter_frame(inlink->dst->outputs[0], out);
|
return ff_filter_frame(inlink->dst->outputs[0], out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define OFFSET(x) offsetof(PadContext, x)
|
||||||
|
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
|
||||||
|
|
||||||
|
static const AVOption pad_options[] = {
|
||||||
|
{ "width", "set the pad area width expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, CHAR_MIN, CHAR_MAX, FLAGS },
|
||||||
|
{ "w", "set the pad area width expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, CHAR_MIN, CHAR_MAX, FLAGS },
|
||||||
|
{ "height", "set the pad area height expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, CHAR_MIN, CHAR_MAX, FLAGS },
|
||||||
|
{ "h", "set the pad area height expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, CHAR_MIN, CHAR_MAX, FLAGS },
|
||||||
|
{ "x", "set the x offset expression for the input image position", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX, FLAGS },
|
||||||
|
{ "y", "set the y offset expression for the input image position", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX, FLAGS },
|
||||||
|
{ "color", "set the color of the padded area border", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = "black"}, .flags = FLAGS },
|
||||||
|
{ NULL },
|
||||||
|
};
|
||||||
|
|
||||||
|
AVFILTER_DEFINE_CLASS(pad);
|
||||||
|
|
||||||
static const AVFilterPad avfilter_vf_pad_inputs[] = {
|
static const AVFilterPad avfilter_vf_pad_inputs[] = {
|
||||||
{
|
{
|
||||||
.name = "default",
|
.name = "default",
|
||||||
@ -402,19 +404,16 @@ static const AVFilterPad avfilter_vf_pad_outputs[] = {
|
|||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *const shorthand[] = { "width", "height", "x", "y", "color", NULL };
|
|
||||||
|
|
||||||
AVFilter avfilter_vf_pad = {
|
AVFilter avfilter_vf_pad = {
|
||||||
.name = "pad",
|
.name = "pad",
|
||||||
.description = NULL_IF_CONFIG_SMALL("Pad input image to width:height[:x:y[:color]] (default x and y: 0, default color: black)."),
|
.description = NULL_IF_CONFIG_SMALL("Pad input image to width:height[:x:y[:color]] (default x and y: 0, default color: black)."),
|
||||||
|
|
||||||
.priv_size = sizeof(PadContext),
|
.priv_size = sizeof(PadContext),
|
||||||
|
.priv_class = &pad_class,
|
||||||
.init = init,
|
.init = init,
|
||||||
.query_formats = query_formats,
|
.query_formats = query_formats,
|
||||||
|
|
||||||
.inputs = avfilter_vf_pad_inputs,
|
.inputs = avfilter_vf_pad_inputs,
|
||||||
|
|
||||||
.outputs = avfilter_vf_pad_outputs,
|
.outputs = avfilter_vf_pad_outputs,
|
||||||
.priv_class = &pad_class,
|
|
||||||
.shorthand = shorthand,
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user