2010-01-16 12:43:53 +02:00
|
|
|
/*
|
2011-03-18 19:35:10 +02:00
|
|
|
* This file is part of Libav.
|
2010-01-16 12:43:53 +02:00
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* Libav is free software; you can redistribute it and/or
|
2010-01-16 12:43:53 +02:00
|
|
|
* 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.
|
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* Libav is distributed in the hope that it will be useful,
|
2010-01-16 12:43:53 +02:00
|
|
|
* 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
|
2011-03-18 19:35:10 +02:00
|
|
|
* License along with Libav; if not, write to the Free Software
|
2010-01-16 12:43:53 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-04-20 17:45:34 +03:00
|
|
|
* @file
|
2010-01-16 12:43:53 +02:00
|
|
|
* null video source
|
|
|
|
*/
|
|
|
|
|
2010-10-12 02:27:33 +03:00
|
|
|
#include "libavutil/avstring.h"
|
|
|
|
#include "libavutil/eval.h"
|
2011-06-04 14:58:23 +03:00
|
|
|
#include "libavutil/mathematics.h"
|
2011-02-07 15:37:08 +02:00
|
|
|
#include "libavutil/parseutils.h"
|
2010-01-16 12:43:53 +02:00
|
|
|
#include "avfilter.h"
|
2012-05-30 11:12:55 +03:00
|
|
|
#include "formats.h"
|
2012-06-12 21:12:42 +03:00
|
|
|
#include "internal.h"
|
2010-01-16 12:43:53 +02:00
|
|
|
|
2012-02-20 11:42:33 +03:00
|
|
|
static const char *const var_names[] = {
|
2010-10-12 02:27:33 +03:00
|
|
|
"E",
|
|
|
|
"PHI",
|
|
|
|
"PI",
|
|
|
|
"AVTB", /* default timebase 1/AV_TIME_BASE */
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum var_name {
|
|
|
|
VAR_E,
|
|
|
|
VAR_PHI,
|
|
|
|
VAR_PI,
|
|
|
|
VAR_AVTB,
|
|
|
|
VAR_VARS_NB
|
|
|
|
};
|
|
|
|
|
2010-01-16 12:43:53 +02:00
|
|
|
typedef struct {
|
|
|
|
int w, h;
|
2010-10-12 02:27:33 +03:00
|
|
|
char tb_expr[256];
|
|
|
|
double var_values[VAR_VARS_NB];
|
2010-01-16 12:43:53 +02:00
|
|
|
} NullContext;
|
|
|
|
|
2012-06-21 08:55:56 +03:00
|
|
|
static int init(AVFilterContext *ctx, const char *args)
|
2010-01-16 12:43:53 +02:00
|
|
|
{
|
|
|
|
NullContext *priv = ctx->priv;
|
|
|
|
|
|
|
|
priv->w = 352;
|
|
|
|
priv->h = 288;
|
2010-10-12 02:27:33 +03:00
|
|
|
av_strlcpy(priv->tb_expr, "AVTB", sizeof(priv->tb_expr));
|
2010-01-16 12:43:53 +02:00
|
|
|
|
|
|
|
if (args)
|
2010-10-12 02:27:33 +03:00
|
|
|
sscanf(args, "%d:%d:%255[^:]", &priv->w, &priv->h, priv->tb_expr);
|
2010-01-16 12:43:53 +02:00
|
|
|
|
|
|
|
if (priv->w <= 0 || priv->h <= 0) {
|
|
|
|
av_log(ctx, AV_LOG_ERROR, "Non-positive size values are not acceptable.\n");
|
2010-09-30 23:24:49 +03:00
|
|
|
return AVERROR(EINVAL);
|
2010-01-16 12:43:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int config_props(AVFilterLink *outlink)
|
|
|
|
{
|
2010-10-12 02:27:33 +03:00
|
|
|
AVFilterContext *ctx = outlink->src;
|
|
|
|
NullContext *priv = ctx->priv;
|
|
|
|
AVRational tb;
|
|
|
|
int ret;
|
|
|
|
double res;
|
|
|
|
|
|
|
|
priv->var_values[VAR_E] = M_E;
|
|
|
|
priv->var_values[VAR_PHI] = M_PHI;
|
|
|
|
priv->var_values[VAR_PI] = M_PI;
|
|
|
|
priv->var_values[VAR_AVTB] = av_q2d(AV_TIME_BASE_Q);
|
|
|
|
|
2010-11-08 16:06:49 +02:00
|
|
|
if ((ret = av_expr_parse_and_eval(&res, priv->tb_expr, var_names, priv->var_values,
|
2010-10-12 02:27:33 +03:00
|
|
|
NULL, NULL, NULL, NULL, NULL, 0, NULL)) < 0) {
|
|
|
|
av_log(ctx, AV_LOG_ERROR, "Invalid expression '%s' for timebase.\n", priv->tb_expr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
tb = av_d2q(res, INT_MAX);
|
|
|
|
if (tb.num <= 0 || tb.den <= 0) {
|
|
|
|
av_log(ctx, AV_LOG_ERROR,
|
|
|
|
"Invalid non-positive value for the timebase %d/%d.\n",
|
|
|
|
tb.num, tb.den);
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
}
|
2010-01-16 12:43:53 +02:00
|
|
|
|
|
|
|
outlink->w = priv->w;
|
|
|
|
outlink->h = priv->h;
|
2010-10-12 02:27:33 +03:00
|
|
|
outlink->time_base = tb;
|
2010-01-16 12:43:53 +02:00
|
|
|
|
2012-06-25 07:31:38 +03:00
|
|
|
av_log(outlink->src, AV_LOG_VERBOSE, "w:%d h:%d tb:%d/%d\n", priv->w, priv->h,
|
2010-10-12 02:27:33 +03:00
|
|
|
tb.num, tb.den);
|
2010-01-16 12:43:53 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int request_frame(AVFilterLink *link)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AVFilter avfilter_vsrc_nullsrc = {
|
|
|
|
.name = "nullsrc",
|
2010-09-24 23:41:14 +03:00
|
|
|
.description = NULL_IF_CONFIG_SMALL("Null video source, never return images."),
|
2010-01-16 12:43:53 +02:00
|
|
|
|
|
|
|
.init = init,
|
|
|
|
.priv_size = sizeof(NullContext),
|
|
|
|
|
|
|
|
.inputs = (AVFilterPad[]) {{ .name = NULL}},
|
|
|
|
|
|
|
|
.outputs = (AVFilterPad[]) {
|
|
|
|
{
|
|
|
|
.name = "default",
|
2010-03-31 02:30:55 +03:00
|
|
|
.type = AVMEDIA_TYPE_VIDEO,
|
2010-01-16 12:43:53 +02:00
|
|
|
.config_props = config_props,
|
|
|
|
.request_frame = request_frame,
|
|
|
|
},
|
|
|
|
{ .name = NULL}
|
|
|
|
},
|
|
|
|
};
|