Browse code

lavfi/geq: add T variable and example

Stefano Sabatini authored on 2012/12/01 20:47:51
Showing 3 changed files
... ...
@@ -2473,6 +2473,9 @@ ratio between the corresponding luma plane number of pixels and the current
2473 2473
 plane ones. E.g. for YUV4:2:0 the values are @code{1,1} for the luma plane, and
2474 2474
 @code{0.5,0.5} for chroma planes.
2475 2475
 
2476
+@item T
2477
+Time of the current frame, expressed in seconds.
2478
+
2476 2479
 @item p(x, y)
2477 2480
 Return the value of the pixel at location (@var{x},@var{y}) of the current
2478 2481
 plane.
... ...
@@ -2503,6 +2506,13 @@ geq=p(W-X\,Y)
2503 2503
 @end example
2504 2504
 
2505 2505
 @item
2506
+Generate a bidimensional sine wave, with angle @code{PI/3} and a
2507
+wavelength of 100 pixels:
2508
+@example
2509
+geq=128 + 100*sin(2*(PI/100)*(cos(PI/3)*(X-50*T) + sin(PI/3)*Y)):128:128
2510
+@end example
2511
+
2512
+@item
2506 2513
 Generate a fancy enigmatic moving light:
2507 2514
 @example
2508 2515
 nullsrc=s=256x256,geq=random(1)/hypot(X-cos(N*0.07)*W/2-W/2\,Y-sin(N*0.09)*H/2-H/2)^2*1000000*sin(N*0.02):128:128
... ...
@@ -30,7 +30,7 @@
30 30
 
31 31
 #define LIBAVFILTER_VERSION_MAJOR  3
32 32
 #define LIBAVFILTER_VERSION_MINOR  23
33
-#define LIBAVFILTER_VERSION_MICRO 104
33
+#define LIBAVFILTER_VERSION_MICRO 105
34 34
 
35 35
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
36 36
                                                LIBAVFILTER_VERSION_MINOR, \
... ...
@@ -79,8 +79,8 @@ static double lum(void *priv, double x, double y) { return getpix(priv, x, y, 0)
79 79
 static double  cb(void *priv, double x, double y) { return getpix(priv, x, y, 1); }
80 80
 static double  cr(void *priv, double x, double y) { return getpix(priv, x, y, 2); }
81 81
 
82
-static const char *const var_names[] = {   "X",   "Y",   "W",   "H",   "N",   "SW",   "SH",        NULL };
83
-enum                                   { VAR_X, VAR_Y, VAR_W, VAR_H, VAR_N, VAR_SW, VAR_SH, VAR_VARS_NB };
82
+static const char *const var_names[] = {   "X",   "Y",   "W",   "H",   "N",   "SW",   "SH",   "T",        NULL };
83
+enum                                   { VAR_X, VAR_Y, VAR_W, VAR_H, VAR_N, VAR_SW, VAR_SH, VAR_T, VAR_VARS_NB };
84 84
 
85 85
 static av_cold int geq_init(AVFilterContext *ctx, const char *args)
86 86
 {
... ...
@@ -160,6 +160,7 @@ static int geq_filter_frame(AVFilterLink *inlink, AVFilterBufferRef *in)
160 160
     AVFilterBufferRef *out;
161 161
     double values[VAR_VARS_NB] = {
162 162
         [VAR_N] = geq->framenum++,
163
+        [VAR_T] = in->pts == AV_NOPTS_VALUE ? NAN : in->pts * av_q2d(inlink->time_base),
163 164
     };
164 165
 
165 166
     geq->picref = in;