History

vsrc_nullsrc: switch to an AVOptions-based system.

Anton Khirnov committed 13 years ago

Commit b7b33021 parent 7bc1a881 file · +20 −21Browse files

Showing the changes to libavfilter/vsrc_nullsrc.c (1 of 1 file). Show all

Unified · Split

libavfilter/vsrc_nullsrc.c+20−21
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include "libavutil/eval.h"
2828 #include "libavutil/internal.h"
2929 #include "libavutil/mathematics.h"
30+#include "libavutil/opt.h"
3031 #include "libavutil/parseutils.h"
3132 #include "avfilter.h"
3233 #include "formats.h"
@@ -49,30 +50,12 @@ enum var_name { · 16 unmodified lines
4950 };
5051
5152 typedef struct {
53+ const AVClass *class;
5254 int w, h;
53− char tb_expr[256];
55+ char *tb_expr;
5456 double var_values[VAR_VARS_NB];
5557 } NullContext;
5658
57−static int init(AVFilterContext *ctx, const char *args)
58−{
59− NullContext *priv = ctx->priv;
60−
61− priv->w = 352;
62− priv->h = 288;
63− av_strlcpy(priv->tb_expr, "AVTB", sizeof(priv->tb_expr));
64−
65− if (args)
66− sscanf(args, "%d:%d:%255[^:]", &priv->w, &priv->h, priv->tb_expr);
67−
68− if (priv->w <= 0 || priv->h <= 0) {
69− av_log(ctx, AV_LOG_ERROR, "Non-positive size values are not acceptable.\n");
70− return AVERROR(EINVAL);
71− }
72−
73− return 0;
74−}
75−
7659 static int config_props(AVFilterLink *outlink)
7760 {
7861 AVFilterContext *ctx = outlink->src;
@@ -114,6 +97,22 @@ static int request_frame(AVFilterLink *link) · 35 unmodified lines
11497 return -1;
11598 }
11699
100+#define OFFSET(x) offsetof(NullContext, x)
101+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
102+static const AVOption options[] = {
103+ { "width", NULL, OFFSET(w), AV_OPT_TYPE_INT, { .i64 = 352 }, 1, INT_MAX, FLAGS },
104+ { "height", NULL, OFFSET(h), AV_OPT_TYPE_INT, { .i64 = 288 }, 1, INT_MAX, FLAGS },
105+ { "timebase", NULL, OFFSET(tb_expr), AV_OPT_TYPE_STRING, { .str = "AVTB" }, 0, 0, FLAGS },
106+ { NULL },
107+};
108+
109+static const AVClass nullsrc_class = {
110+ .class_name = "nullsrc",
111+ .item_name = av_default_item_name,
112+ .option = options,
113+ .version = LIBAVUTIL_VERSION_INT,
114+};
115+
117116 static const AVFilterPad avfilter_vsrc_nullsrc_outputs[] = {
118117 {
119118 .name = "default",
@@ -128,8 +127,8 @@ AVFilter avfilter_vsrc_nullsrc = { · 8 unmodified lines
128127 .name = "nullsrc",
129128 .description = NULL_IF_CONFIG_SMALL("Null video source, never return images."),
130129
131− .init = init,
132130 .priv_size = sizeof(NullContext),
131+ .priv_class = &nullsrc_class,
133132
134133 .inputs = NULL,
135134

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