mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
lavfi/tile: allow named arguments.
This commit is contained in:
parent
5aedee4fac
commit
aa5a029091
@ -23,6 +23,7 @@
|
|||||||
* tile video filter
|
* tile video filter
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "libavutil/opt.h"
|
||||||
#include "libavutil/pixdesc.h"
|
#include "libavutil/pixdesc.h"
|
||||||
#include "avfilter.h"
|
#include "avfilter.h"
|
||||||
#include "drawutils.h"
|
#include "drawutils.h"
|
||||||
@ -31,6 +32,7 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
const AVClass *class;
|
||||||
unsigned w, h;
|
unsigned w, h;
|
||||||
unsigned current;
|
unsigned current;
|
||||||
FFDrawContext draw;
|
FFDrawContext draw;
|
||||||
@ -39,17 +41,29 @@ typedef struct {
|
|||||||
|
|
||||||
#define REASONABLE_SIZE 1024
|
#define REASONABLE_SIZE 1024
|
||||||
|
|
||||||
|
#define OFFSET(x) offsetof(TileContext, x)
|
||||||
|
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
|
||||||
|
|
||||||
|
static const AVOption tile_options[] = {
|
||||||
|
{ "layout", "set grid size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE,
|
||||||
|
{.str = "6x5"}, 0, 0, FLAGS },
|
||||||
|
{NULL},
|
||||||
|
};
|
||||||
|
|
||||||
|
AVFILTER_DEFINE_CLASS(tile);
|
||||||
|
|
||||||
static av_cold int init(AVFilterContext *ctx, const char *args)
|
static av_cold int init(AVFilterContext *ctx, const char *args)
|
||||||
{
|
{
|
||||||
TileContext *tile = ctx->priv;
|
TileContext *tile = ctx->priv;
|
||||||
int r;
|
static const char *shorthand[] = { "layout", NULL };
|
||||||
char dummy;
|
int ret;
|
||||||
|
|
||||||
|
tile->class = &tile_class;
|
||||||
|
av_opt_set_defaults(tile);
|
||||||
|
|
||||||
|
if ((ret = av_opt_set_from_string(tile, args, shorthand, "=", ":")) < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
if (!args)
|
|
||||||
args = "6x5";
|
|
||||||
r = sscanf(args, "%ux%u%c", &tile->w, &tile->h, &dummy);
|
|
||||||
if (r != 2 || !tile->w || !tile->h)
|
|
||||||
return AVERROR(EINVAL);
|
|
||||||
if (tile->w > REASONABLE_SIZE || tile->h > REASONABLE_SIZE) {
|
if (tile->w > REASONABLE_SIZE || tile->h > REASONABLE_SIZE) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Tile size %ux%u is insane.\n",
|
av_log(ctx, AV_LOG_ERROR, "Tile size %ux%u is insane.\n",
|
||||||
tile->w, tile->h);
|
tile->w, tile->h);
|
||||||
@ -212,4 +226,5 @@ AVFilter avfilter_vf_tile = {
|
|||||||
.request_frame = request_frame },
|
.request_frame = request_frame },
|
||||||
{ .name = NULL }
|
{ .name = NULL }
|
||||||
},
|
},
|
||||||
|
.priv_class = &tile_class,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user