aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2021-11-07 20:44:22 +0100
committerPaul B Mahol <onemda@gmail.com>2021-11-07 20:47:21 +0100
commit45dc668aea0edac34969b5a1ff76cf9ad3a09be1 (patch)
treefcfedf1510b6d41459d1ae73310066e303421e0f
parent0370c3e3d4dda36a18fe640bd318b937ee98874d (diff)
downloadffmpeg-45dc668aea0edac34969b5a1ff76cf9ad3a09be1.tar.gz
avfilter/f_reverse: readjust frame timestamps for areverse
-rw-r--r--libavfilter/f_reverse.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavfilter/f_reverse.c b/libavfilter/f_reverse.c
index 586d95c063..f7a7e716fa 100644
--- a/libavfilter/f_reverse.c
+++ b/libavfilter/f_reverse.c
@@ -33,6 +33,7 @@ typedef struct ReverseContext {
unsigned int pts_size;
int64_t *pts;
int flush_idx;
+ int64_t nb_samples;
} ReverseContext;
static av_cold int init(AVFilterContext *ctx)
@@ -249,7 +250,8 @@ static int areverse_request_frame(AVFilterLink *outlink)
if (ret == AVERROR_EOF && s->nb_frames > 0) {
AVFrame *out = s->frames[s->nb_frames - 1];
- out->pts = s->pts[s->flush_idx++];
+ out->pts = s->pts[s->flush_idx++] - s->nb_samples;
+ s->nb_samples += s->pts[s->flush_idx] - s->pts[s->flush_idx - 1] - out->nb_samples;
if (av_sample_fmt_is_planar(out->format))
reverse_samples_planar(out);