Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Bœsch <ubitux@gmail.com>2012-11-12 01:36:26 +0400
committerClément Bœsch <ubitux@gmail.com>2012-11-12 01:43:17 +0400
commitaa5a029091327468a9664fc9c4d44b857d316791 (patch)
tree84735ca152a44e1e9ef1d817188e34714a10bc27 /libavfilter/vf_tile.c
parent5aedee4facb2295cfdeaf322bc67fd15323862d9 (diff)
lavfi/tile: allow named arguments.
Diffstat (limited to 'libavfilter/vf_tile.c')
-rw-r--r--libavfilter/vf_tile.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/libavfilter/vf_tile.c b/libavfilter/vf_tile.c
index 52d53ebcc1..cfddab05ad 100644
--- a/libavfilter/vf_tile.c
+++ b/libavfilter/vf_tile.c
@@ -23,6 +23,7 @@
* tile video filter
*/
+#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "drawutils.h"
@@ -31,6 +32,7 @@
#include "internal.h"
typedef struct {
+ const AVClass *class;
unsigned w, h;
unsigned current;
FFDrawContext draw;
@@ -39,17 +41,29 @@ typedef struct {
#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)
{
TileContext *tile = ctx->priv;
- int r;
- char dummy;
+ static const char *shorthand[] = { "layout", NULL };
+ 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) {
av_log(ctx, AV_LOG_ERROR, "Tile size %ux%u is insane.\n",
tile->w, tile->h);
@@ -212,4 +226,5 @@ AVFilter avfilter_vf_tile = {
.request_frame = request_frame },
{ .name = NULL }
},
+ .priv_class = &tile_class,
};