summaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2012-08-23 12:29:20 +0200
committerStefano Sabatini <stefasab@gmail.com>2012-08-24 13:32:21 +0200
commit1181461ca5852206793a77d5856559c2face9263 (patch)
tree79ab19e3ed08ee6e8c126a83c1ba1d1cb8f4e707 /libavfilter
parent3d6d59ef35d22b895645de455bd7a0772951bee2 (diff)
downloadffmpeg-streaming-1181461ca5852206793a77d5856559c2face9263.zip
ffmpeg-streaming-1181461ca5852206793a77d5856559c2face9263.tar.gz
lavfi/asetpts,setpts: add variables T, STARTT, PREV_INT and PREV_OUTT
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/f_setpts.c22
-rw-r--r--libavfilter/version.h2
2 files changed, 19 insertions, 5 deletions
diff --git a/libavfilter/f_setpts.c b/libavfilter/f_setpts.c
index 62ac9ab..738fbf3 100644
--- a/libavfilter/f_setpts.c
+++ b/libavfilter/f_setpts.c
@@ -41,10 +41,14 @@ static const char *const var_names[] = {
"NB_SAMPLES", ///< number of samples in the current frame (only audio)
"POS", ///< original position in the file of the frame
"PREV_INPTS", ///< previous input PTS
+ "PREV_INT", ///< previous input time in seconds
"PREV_OUTPTS", ///< previous output PTS
+ "PREV_OUTT", ///< previous output time in seconds
"PTS", ///< original pts in the file of the frame
"SAMPLE_RATE", ///< sample rate (only audio)
"STARTPTS", ///< PTS at start of movie
+ "STARTT", ///< time at start of movie
+ "T", ///< original time in the file of the frame
"TB", ///< timebase
NULL
};
@@ -56,10 +60,14 @@ enum var_name {
VAR_NB_SAMPLES,
VAR_POS,
VAR_PREV_INPTS,
+ VAR_PREV_INT,
VAR_PREV_OUTPTS,
+ VAR_PREV_OUTT,
VAR_PTS,
VAR_SAMPLE_RATE,
VAR_STARTPTS,
+ VAR_STARTT,
+ VAR_T,
VAR_TB,
VAR_VARS_NB
};
@@ -82,9 +90,9 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
}
setpts->var_values[VAR_N ] = 0.0;
- setpts->var_values[VAR_PREV_INPTS ] = NAN;
- setpts->var_values[VAR_PREV_OUTPTS] = NAN;
- setpts->var_values[VAR_STARTPTS ] = NAN;
+ setpts->var_values[VAR_PREV_INPTS ] = setpts->var_values[VAR_PREV_INT ] = NAN;
+ setpts->var_values[VAR_PREV_OUTPTS] = setpts->var_values[VAR_PREV_OUTT] = NAN;
+ setpts->var_values[VAR_STARTPTS ] = setpts->var_values[VAR_STARTT ] = NAN;
return 0;
}
@@ -106,6 +114,7 @@ static int config_input(AVFilterLink *inlink)
#define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
#define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
+#define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
{
@@ -116,9 +125,12 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
if (!outpicref)
return AVERROR(ENOMEM);
- if (isnan(setpts->var_values[VAR_STARTPTS]))
+ if (isnan(setpts->var_values[VAR_STARTPTS])) {
setpts->var_values[VAR_STARTPTS] = TS2D(inpicref->pts);
+ setpts->var_values[VAR_STARTT ] = TS2T(inpicref->pts, inlink->time_base);
+ }
setpts->var_values[VAR_PTS ] = TS2D(inpicref->pts);
+ setpts->var_values[VAR_T ] = TS2T(inpicref->pts, inlink->time_base);
setpts->var_values[VAR_POS ] = inpicref->pos == -1 ? NAN : inpicref->pos;
switch (inlink->type) {
@@ -150,7 +162,9 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
setpts->var_values[VAR_N] += 1.0;
setpts->var_values[VAR_PREV_INPTS ] = TS2D(inpicref ->pts);
+ setpts->var_values[VAR_PREV_INT ] = TS2T(inpicref ->pts, inlink->time_base);
setpts->var_values[VAR_PREV_OUTPTS] = TS2D(outpicref->pts);
+ setpts->var_values[VAR_PREV_OUTT] = TS2T(outpicref->pts, inlink->time_base);
if (setpts->type == AVMEDIA_TYPE_AUDIO) {
setpts->var_values[VAR_NB_CONSUMED_SAMPLES] += inpicref->audio->nb_samples;
diff --git a/libavfilter/version.h b/libavfilter/version.h
index a008d94..ea70d80 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,7 +30,7 @@
#define LIBAVFILTER_VERSION_MAJOR 3
#define LIBAVFILTER_VERSION_MINOR 13
-#define LIBAVFILTER_VERSION_MICRO 100
+#define LIBAVFILTER_VERSION_MICRO 101
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
OpenPOWER on IntegriCloud