History

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

Stefano Sabatini committed 16 years ago

Commit 16134b71 parent 214c0d43 files · +59 −8Browse files

Showing the changes to libavfilter/vsrc_nullsrc.c (1 of 3 files). Show all

Unified · Split

libavfilter/vsrc_nullsrc.c+50−3
@@ -21,10 +21,32 @@ · 20 unmodified lines
2121 * null video source
2222 */
2323
24+#include "libavutil/avstring.h"
25+#include "libavutil/eval.h"
26+#include "libavcore/parseutils.h"
2427 #include "avfilter.h"
2528
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+
2646 typedef struct {
2747 int w, h;
48+ char tb_expr[256];
49+ double var_values[VAR_VARS_NB];
2850 } NullContext;
2951
3052 static int init(AVFilterContext *ctx, const char *args, void *opaque)
@@ -33,9 +55,10 @@ static int init(AVFilterContext *ctx, const char *args, void *opaque) · 2 unmodified lines
3355
3456 priv->w = 352;
3557 priv->h = 288;
58+ av_strlcpy(priv->tb_expr, "AVTB", sizeof(priv->tb_expr));
3659
3760 if (args)
38− sscanf(args, "%d:%d", &priv->w, &priv->h);
61+ sscanf(args, "%d:%d:%255[^:]", &priv->w, &priv->h, priv->tb_expr);
3962
4063 if (priv->w <= 0 || priv->h <= 0) {
4164 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) · 5 unmodified lines
4770
4871 static int config_props(AVFilterLink *outlink)
4972 {
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+ }
5196
5297 outlink->w = priv->w;
5398 outlink->h = priv->h;
99+ outlink->time_base = tb;
54100
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);
56103
57104 return 0;
58105 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t