Revision 16134b7c

View differences:

doc/filters.texi
653 653
template and to be employed in analysis / debugging tools.
654 654

  
655 655
It accepts as optional parameter a string of the form
656
@var{width}:@var{height}, where @var{width} and @var{height} specify the size of
657
the configured source.
656
@var{width}:@var{height}:@var{timebase}.
658 657

  
659
The default values of @var{width} and @var{height} are respectively 352
660
and 288 (corresponding to the CIF size format).
658
@var{width} and @var{height} specify the size of the configured
659
source. The default values of @var{width} and @var{height} are
660
respectively 352 and 288 (corresponding to the CIF size format).
661

  
662
@var{timebase} specifies an arithmetic expression representing a
663
timebase. The expression can contain the constants "PI", "E", "PHI",
664
"AVTB" (the default timebase), and defaults to the value "AVTB".
661 665

  
662 666
@c man end VIDEO SOURCES
663 667

  
libavfilter/avfilter.h
26 26

  
27 27
#define LIBAVFILTER_VERSION_MAJOR  1
28 28
#define LIBAVFILTER_VERSION_MINOR 50
29
#define LIBAVFILTER_VERSION_MICRO  0
29
#define LIBAVFILTER_VERSION_MICRO  1
30 30

  
31 31
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
32 32
                                               LIBAVFILTER_VERSION_MINOR, \
libavfilter/vsrc_nullsrc.c
21 21
 * null video source
22 22
 */
23 23

  
24
#include "libavutil/avstring.h"
25
#include "libavutil/eval.h"
26
#include "libavcore/parseutils.h"
24 27
#include "avfilter.h"
25 28

  
29
static const char *var_names[] = {
30
    "E",
31
    "PHI",
32
    "PI",
33
    "AVTB",   /* default timebase 1/AV_TIME_BASE */
34
    NULL
35
};
36

  
37
enum var_name {
38
    VAR_E,
39
    VAR_PHI,
40
    VAR_PI,
41
    VAR_AVTB,
42
    VAR_INTB,
43
    VAR_VARS_NB
44
};
45

  
26 46
typedef struct {
27 47
    int w, h;
48
    char tb_expr[256];
49
    double var_values[VAR_VARS_NB];
28 50
} NullContext;
29 51

  
30 52
static int init(AVFilterContext *ctx, const char *args, void *opaque)
......
33 55

  
34 56
    priv->w = 352;
35 57
    priv->h = 288;
58
    av_strlcpy(priv->tb_expr, "AVTB", sizeof(priv->tb_expr));
36 59

  
37 60
    if (args)
38
        sscanf(args, "%d:%d", &priv->w, &priv->h);
61
        sscanf(args, "%d:%d:%255[^:]", &priv->w, &priv->h, priv->tb_expr);
39 62

  
40 63
    if (priv->w <= 0 || priv->h <= 0) {
41 64
        av_log(ctx, AV_LOG_ERROR, "Non-positive size values are not acceptable.\n");
......
47 70

  
48 71
static int config_props(AVFilterLink *outlink)
49 72
{
50
    NullContext *priv = outlink->src->priv;
73
    AVFilterContext *ctx = outlink->src;
74
    NullContext *priv = ctx->priv;
75
    AVRational tb;
76
    int ret;
77
    double res;
78

  
79
    priv->var_values[VAR_E]    = M_E;
80
    priv->var_values[VAR_PHI]  = M_PHI;
81
    priv->var_values[VAR_PI]   = M_PI;
82
    priv->var_values[VAR_AVTB] = av_q2d(AV_TIME_BASE_Q);
83

  
84
    if ((ret = av_parse_and_eval_expr(&res, priv->tb_expr, var_names, priv->var_values,
85
                                      NULL, NULL, NULL, NULL, NULL, 0, NULL)) < 0) {
86
        av_log(ctx, AV_LOG_ERROR, "Invalid expression '%s' for timebase.\n", priv->tb_expr);
87
        return ret;
88
    }
89
    tb = av_d2q(res, INT_MAX);
90
    if (tb.num <= 0 || tb.den <= 0) {
91
        av_log(ctx, AV_LOG_ERROR,
92
               "Invalid non-positive value for the timebase %d/%d.\n",
93
               tb.num, tb.den);
94
        return AVERROR(EINVAL);
95
    }
51 96

  
52 97
    outlink->w = priv->w;
53 98
    outlink->h = priv->h;
99
    outlink->time_base = tb;
54 100

  
55
    av_log(outlink->src, AV_LOG_INFO, "w:%d h:%d\n", priv->w, priv->h);
101
    av_log(outlink->src, AV_LOG_INFO, "w:%d h:%d tb:%d/%d\n", priv->w, priv->h,
102
           tb.num, tb.den);
56 103

  
57 104
    return 0;
58 105
}

Also available in: Unified diff