Showing the changes to libavfilter/vsrc_nullsrc.c (1 of 1 file). Show all
Unified · Split
| @@ -27,6 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | #include "libavutil/eval.h" |
| 28 | 28 | #include "libavutil/internal.h" |
| 29 | 29 | #include "libavutil/mathematics.h" |
| 30 | +#include "libavutil/opt.h" | |
| 30 | 31 | #include "libavutil/parseutils.h" |
| 31 | 32 | #include "avfilter.h" |
| 32 | 33 | #include "formats.h" |
| @@ -49,30 +50,12 @@ enum var_name { · 16 unmodified lines | ||
| 49 | 50 | }; |
| 50 | 51 | |
| 51 | 52 | typedef struct { |
| 53 | + const AVClass *class; | |
| 52 | 54 | int w, h; |
| 53 | − char tb_expr[256]; | |
| 55 | + char *tb_expr; | |
| 54 | 56 | double var_values[VAR_VARS_NB]; |
| 55 | 57 | } NullContext; |
| 56 | 58 | |
| 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 | − | |
| 76 | 59 | static int config_props(AVFilterLink *outlink) |
| 77 | 60 | { |
| 78 | 61 | AVFilterContext *ctx = outlink->src; |
| @@ -114,6 +97,22 @@ static int request_frame(AVFilterLink *link) · 35 unmodified lines | ||
| 114 | 97 | return -1; |
| 115 | 98 | } |
| 116 | 99 | |
| 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 | + | |
| 117 | 116 | static const AVFilterPad avfilter_vsrc_nullsrc_outputs[] = { |
| 118 | 117 | { |
| 119 | 118 | .name = "default", |
| @@ -128,8 +127,8 @@ AVFilter avfilter_vsrc_nullsrc = { · 8 unmodified lines | ||
| 128 | 127 | .name = "nullsrc", |
| 129 | 128 | .description = NULL_IF_CONFIG_SMALL("Null video source, never return images."), |
| 130 | 129 | |
| 131 | − .init = init, | |
| 132 | 130 | .priv_size = sizeof(NullContext), |
| 131 | + .priv_class = &nullsrc_class, | |
| 133 | 132 | |
| 134 | 133 | .inputs = NULL, |
| 135 | 134 | |