2 * This file is part of FFmpeg.
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "libavutil/avstring.h"
25 #include "libavutil/eval.h"
26 #include "libavutil/parseutils.h"
29 static const char *var_names[] = {
33 "AVTB", /* default timebase 1/AV_TIME_BASE */
48 double var_values[VAR_VARS_NB];
51 static int init(AVFilterContext *ctx, const char *args, void *opaque)
53 NullContext *priv = ctx->priv;
57 av_strlcpy(priv->tb_expr, "AVTB", sizeof(priv->tb_expr));
60 sscanf(args, "%d:%d:%255[^:]", &priv->w, &priv->h, priv->tb_expr);
62 if (priv->w <= 0 || priv->h <= 0) {
63 av_log(ctx, AV_LOG_ERROR, "Non-positive size values are not acceptable.\n");
64 return AVERROR(EINVAL);
70 static int config_props(AVFilterLink *outlink)
72 AVFilterContext *ctx = outlink->src;
73 NullContext *priv = ctx->priv;
78 priv->var_values[VAR_E] = M_E;
79 priv->var_values[VAR_PHI] = M_PHI;
80 priv->var_values[VAR_PI] = M_PI;
81 priv->var_values[VAR_AVTB] = av_q2d(AV_TIME_BASE_Q);
83 if ((ret = av_expr_parse_and_eval(&res, priv->tb_expr, var_names, priv->var_values,
84 NULL, NULL, NULL, NULL, NULL, 0, NULL)) < 0) {
85 av_log(ctx, AV_LOG_ERROR, "Invalid expression '%s' for timebase.\n", priv->tb_expr);
88 tb = av_d2q(res, INT_MAX);
89 if (tb.num <= 0 || tb.den <= 0) {
90 av_log(ctx, AV_LOG_ERROR,
91 "Invalid non-positive value for the timebase %d/%d.\n",
93 return AVERROR(EINVAL);
98 outlink->time_base = tb;
100 av_log(outlink->src, AV_LOG_INFO, "w:%d h:%d tb:%d/%d\n", priv->w, priv->h,
106 static int request_frame(AVFilterLink *link)
111 AVFilter avfilter_vsrc_nullsrc = {
113 .description = NULL_IF_CONFIG_SMALL("Null video source, never return images."),
116 .priv_size = sizeof(NullContext),
118 .inputs = (AVFilterPad[]) {{ .name = NULL}},
120 .outputs = (AVFilterPad[]) {
123 .type = AVMEDIA_TYPE_VIDEO,
124 .config_props = config_props,
125 .request_frame = request_frame,