]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vsrc_nullsrc.c
rtpproto: Check for the right feature when reading a sockaddr_in6
[ffmpeg] / libavfilter / vsrc_nullsrc.c
index 1cd06e13f37f90f8c246c8e481c6f8392929625b..85fb4205dd70a9c7eac64be923d62dded5fde834 100644 (file)
@@ -1,18 +1,18 @@
 /*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
  *
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
  * null video source
  */
 
+#include <stdio.h>
+
 #include "libavutil/avstring.h"
 #include "libavutil/eval.h"
-#include "libavcore/parseutils.h"
+#include "libavutil/internal.h"
+#include "libavutil/mathematics.h"
+#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
 #include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
 
-static const char *var_names[] = {
+static const char *const var_names[] = {
     "E",
     "PHI",
     "PI",
@@ -43,30 +50,12 @@ enum var_name {
 };
 
 typedef struct {
+    const AVClass *class;
     int w, h;
-    char tb_expr[256];
+    char *tb_expr;
     double var_values[VAR_VARS_NB];
 } NullContext;
 
-static int init(AVFilterContext *ctx, const char *args, void *opaque)
-{
-    NullContext *priv = ctx->priv;
-
-    priv->w = 352;
-    priv->h = 288;
-    av_strlcpy(priv->tb_expr, "AVTB", sizeof(priv->tb_expr));
-
-    if (args)
-        sscanf(args, "%d:%d:%255[^:]", &priv->w, &priv->h, priv->tb_expr);
-
-    if (priv->w <= 0 || priv->h <= 0) {
-        av_log(ctx, AV_LOG_ERROR, "Non-positive size values are not acceptable.\n");
-        return AVERROR(EINVAL);
-    }
-
-    return 0;
-}
-
 static int config_props(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
@@ -97,7 +86,7 @@ static int config_props(AVFilterLink *outlink)
     outlink->h = priv->h;
     outlink->time_base = tb;
 
-    av_log(outlink->src, AV_LOG_INFO, "w:%d h:%d tb:%d/%d\n", priv->w, priv->h,
+    av_log(outlink->src, AV_LOG_VERBOSE, "w:%d h:%d tb:%d/%d\n", priv->w, priv->h,
            tb.num, tb.den);
 
     return 0;
@@ -108,22 +97,40 @@ static int request_frame(AVFilterLink *link)
     return -1;
 }
 
+#define OFFSET(x) offsetof(NullContext, x)
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
+static const AVOption options[] = {
+    { "width",    NULL, OFFSET(w),       AV_OPT_TYPE_INT,    { .i64 = 352    }, 1, INT_MAX, FLAGS },
+    { "height",   NULL, OFFSET(h),       AV_OPT_TYPE_INT,    { .i64 = 288    }, 1, INT_MAX, FLAGS },
+    { "timebase", NULL, OFFSET(tb_expr), AV_OPT_TYPE_STRING, { .str = "AVTB" }, 0, 0,      FLAGS },
+    { NULL },
+};
+
+static const AVClass nullsrc_class = {
+    .class_name = "nullsrc",
+    .item_name  = av_default_item_name,
+    .option     = options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+static const AVFilterPad avfilter_vsrc_nullsrc_outputs[] = {
+    {
+        .name          = "default",
+        .type          = AVMEDIA_TYPE_VIDEO,
+        .config_props  = config_props,
+        .request_frame = request_frame,
+    },
+    { NULL }
+};
+
 AVFilter avfilter_vsrc_nullsrc = {
     .name        = "nullsrc",
     .description = NULL_IF_CONFIG_SMALL("Null video source, never return images."),
 
-    .init       = init,
     .priv_size = sizeof(NullContext),
+    .priv_class = &nullsrc_class,
 
-    .inputs    = (AVFilterPad[]) {{ .name = NULL}},
+    .inputs    = NULL,
 
-    .outputs   = (AVFilterPad[]) {
-        {
-            .name            = "default",
-            .type            = AVMEDIA_TYPE_VIDEO,
-            .config_props    = config_props,
-            .request_frame   = request_frame,
-        },
-        { .name = NULL}
-    },
+    .outputs   = avfilter_vsrc_nullsrc_outputs,
 };