Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Koshevoy <pkoshevoy@gmail.com>2019-05-08 07:39:45 +0300
committerPavel Koshevoy <pkoshevoy@gmail.com>2019-05-09 08:38:10 +0300
commit181031906e4984c1c539dc84d21386a4397e257e (patch)
treef816f18c1aaf3488ba14a8a16438efd6bd5b81bb /libavfilter/af_atempo.c
parent48539b62fcbd994723a71cbc1750476cbee8eaac (diff)
avfilter/af_atempo: Make ffplay display correct timestamps when seeking
NOTE: this is a refinement of the patch from Paul B Mahol offset all output timestamps by same amount of first input timestamp
Diffstat (limited to 'libavfilter/af_atempo.c')
-rw-r--r--libavfilter/af_atempo.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c
index bfdad7d76b..688dac5464 100644
--- a/libavfilter/af_atempo.c
+++ b/libavfilter/af_atempo.c
@@ -103,6 +103,9 @@ typedef struct ATempoContext {
// 1: output sample position
int64_t position[2];
+ // first input timestamp, all other timestamps are offset by this one
+ int64_t start_pts;
+
// sample format:
enum AVSampleFormat format;
@@ -186,6 +189,7 @@ static void yae_clear(ATempoContext *atempo)
atempo->nfrag = 0;
atempo->state = YAE_LOAD_FRAGMENT;
+ atempo->start_pts = AV_NOPTS_VALUE;
atempo->position[0] = 0;
atempo->position[1] = 0;
@@ -1068,7 +1072,7 @@ static int push_samples(ATempoContext *atempo,
atempo->dst_buffer->nb_samples = n_out;
// adjust the PTS:
- atempo->dst_buffer->pts =
+ atempo->dst_buffer->pts = atempo->start_pts +
av_rescale_q(atempo->nsamples_out,
(AVRational){ 1, outlink->sample_rate },
outlink->time_base);
@@ -1097,6 +1101,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *src_buffer)
const uint8_t *src = src_buffer->data[0];
const uint8_t *src_end = src + n_in * atempo->stride;
+ if (atempo->start_pts == AV_NOPTS_VALUE)
+ atempo->start_pts = av_rescale_q(src_buffer->pts,
+ inlink->time_base,
+ outlink->time_base);
+
while (src < src_end) {
if (!atempo->dst_buffer) {
atempo->dst_buffer = ff_get_audio_buffer(outlink, n_out);