summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorVladimir Pantelic <vladoman@gmail.com>2013-01-23 13:54:08 +0100
committerLuca Barbato <lu_zero@gentoo.org>2013-01-25 10:50:09 +0100
commit0b55b16abc15c3fad0ae8b7cedc8f63f1162e89c (patch)
treec976bd2893e03f2e7476e47c562105f198436f88 /libavfilter
parentb85a5e87af4254b80913fe33591d96361f30832b (diff)
avfilter: allow setpts filter to use wallclock time for calculations
Signed-off-by: Vladimir Pantelic <vladoman@gmail.com> Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_setpts.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavfilter/vf_setpts.c b/libavfilter/vf_setpts.c
index 0c4881efc1..79cadd41ca 100644
--- a/libavfilter/vf_setpts.c
+++ b/libavfilter/vf_setpts.c
@@ -29,6 +29,7 @@
#include "libavutil/eval.h"
#include "libavutil/internal.h"
#include "libavutil/mathematics.h"
+#include "libavutil/time.h"
#include "avfilter.h"
#include "internal.h"
#include "video.h"
@@ -45,6 +46,8 @@ static const char *const var_names[] = {
"PTS", ///< original pts in the file of the frame
"STARTPTS", ///< PTS at start of movie
"TB", ///< timebase
+ "RTCTIME", ///< wallclock (RTC) time in micro seconds
+ "RTCSTART", ///< wallclock (RTC) time at the start of the movie in micro seconds
NULL
};
@@ -60,6 +63,8 @@ enum var_name {
VAR_PTS,
VAR_STARTPTS,
VAR_TB,
+ VAR_RTCTIME,
+ VAR_RTCSTART,
VAR_VARS_NB
};
@@ -94,6 +99,7 @@ static int config_input(AVFilterLink *inlink)
SetPTSContext *setpts = inlink->dst->priv;
setpts->var_values[VAR_TB] = av_q2d(inlink->time_base);
+ setpts->var_values[VAR_RTCSTART] = av_gettime();
av_log(inlink->src, AV_LOG_VERBOSE, "TB:%f\n", setpts->var_values[VAR_TB]);
return 0;
@@ -114,6 +120,7 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
setpts->var_values[VAR_INTERLACED] = frame->video->interlaced;
setpts->var_values[VAR_PTS ] = TS2D(frame->pts);
setpts->var_values[VAR_POS ] = frame->pos == -1 ? NAN : frame->pos;
+ setpts->var_values[VAR_RTCTIME ] = av_gettime();
d = av_expr_eval(setpts->expr, setpts->var_values, NULL);
frame->pts = D2TS(d);