aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2010-10-11 23:27:33 +0000
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2010-10-11 23:27:33 +0000
commit16134b7c4041406e288c652596acbc872367fae1 (patch)
treeb4feeeb0c617aec128d8ad5f6ddf74b3546d2cde
parent214c0d420b696318329aa7da0aeb439970e5bb79 (diff)
downloadffmpeg-16134b7c4041406e288c652596acbc872367fae1.tar.gz
Extend the nullsrc source, make it accept a parameter for specifying
the timebase. Useful for debugging timebase configuration issues. Originally committed as revision 25446 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--doc/filters.texi12
-rw-r--r--libavfilter/avfilter.h2
-rw-r--r--libavfilter/vsrc_nullsrc.c53
3 files changed, 59 insertions, 8 deletions
diff --git a/doc/filters.texi b/doc/filters.texi
index 3fadd9a1d2..e85e9effec 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -653,11 +653,15 @@ Null video source, never return images. It is mainly useful as a
template and to be employed in analysis / debugging tools.
It accepts as optional parameter a string of the form
-@var{width}:@var{height}, where @var{width} and @var{height} specify the size of
-the configured source.
+@var{width}:@var{height}:@var{timebase}.
-The default values of @var{width} and @var{height} are respectively 352
-and 288 (corresponding to the CIF size format).
+@var{width} and @var{height} specify the size of the configured
+source. The default values of @var{width} and @var{height} are
+respectively 352 and 288 (corresponding to the CIF size format).
+
+@var{timebase} specifies an arithmetic expression representing a
+timebase. The expression can contain the constants "PI", "E", "PHI",
+"AVTB" (the default timebase), and defaults to the value "AVTB".
@c man end VIDEO SOURCES
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 13b6d024a1..374f699b17 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -26,7 +26,7 @@
#define LIBAVFILTER_VERSION_MAJOR 1
#define LIBAVFILTER_VERSION_MINOR 50
-#define LIBAVFILTER_VERSION_MICRO 0
+#define LIBAVFILTER_VERSION_MICRO 1
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
diff --git a/libavfilter/vsrc_nullsrc.c b/libavfilter/vsrc_nullsrc.c
index f319ceb980..76271bbced 100644
--- a/libavfilter/vsrc_nullsrc.c
+++ b/libavfilter/vsrc_nullsrc.c
@@ -21,10 +21,32 @@
* null video source
*/
+#include "libavutil/avstring.h"
+#include "libavutil/eval.h"
+#include "libavcore/parseutils.h"
#include "avfilter.h"
+static const char *var_names[] = {
+ "E",
+ "PHI",
+ "PI",
+ "AVTB", /* default timebase 1/AV_TIME_BASE */
+ NULL
+};
+
+enum var_name {
+ VAR_E,
+ VAR_PHI,
+ VAR_PI,
+ VAR_AVTB,
+ VAR_INTB,
+ VAR_VARS_NB
+};
+
typedef struct {
int w, h;
+ char tb_expr[256];
+ double var_values[VAR_VARS_NB];
} NullContext;
static int init(AVFilterContext *ctx, const char *args, void *opaque)
@@ -33,9 +55,10 @@ static int init(AVFilterContext *ctx, const char *args, void *opaque)
priv->w = 352;
priv->h = 288;
+ av_strlcpy(priv->tb_expr, "AVTB", sizeof(priv->tb_expr));
if (args)
- sscanf(args, "%d:%d", &priv->w, &priv->h);
+ 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");
@@ -47,12 +70,36 @@ static int init(AVFilterContext *ctx, const char *args, void *opaque)
static int config_props(AVFilterLink *outlink)
{
- NullContext *priv = outlink->src->priv;
+ 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);
+
+ if ((ret = av_parse_and_eval_expr(&res, priv->tb_expr, var_names, priv->var_values,
+ 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);
+ }
outlink->w = priv->w;
outlink->h = priv->h;
+ outlink->time_base = tb;
- av_log(outlink->src, AV_LOG_INFO, "w:%d h:%d\n", priv->w, priv->h);
+ av_log(outlink->src, AV_LOG_INFO, "w:%d h:%d tb:%d/%d\n", priv->w, priv->h,
+ tb.num, tb.den);
return 0;
}