[FFmpeg-cvslog] avfilter/f_loop: fix pts handling when timebase and 1/samplerate differ
Paul B Mahol
git at videolan.org
Sun Nov 17 17:28:20 EET 2019
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Nov 17 15:21:07 2019 +0100| [2e7ccd493aec98c19f788f2e330bfaf97ac9fbea] | committer: Paul B Mahol
avfilter/f_loop: fix pts handling when timebase and 1/samplerate differ
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2e7ccd493aec98c19f788f2e330bfaf97ac9fbea
---
libavfilter/f_loop.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libavfilter/f_loop.c b/libavfilter/f_loop.c
index 5ec44d9da2..879db621ef 100644
--- a/libavfilter/f_loop.c
+++ b/libavfilter/f_loop.c
@@ -107,7 +107,7 @@ static int push_samples(AVFilterContext *ctx, int nb_samples)
}
out->pts = s->pts;
out->nb_samples = ret;
- s->pts += out->nb_samples;
+ s->pts += av_rescale_q(out->nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
i += out->nb_samples;
s->current_sample += out->nb_samples;
@@ -145,7 +145,7 @@ static int afilter_frame(AVFilterLink *inlink, AVFrame *frame)
drain = FFMAX(0, s->start - s->ignored_samples);
s->pts = frame->pts;
av_audio_fifo_drain(s->fifo, drain);
- s->pts += s->start - s->ignored_samples;
+ s->pts += av_rescale_q(s->start - s->ignored_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
}
s->nb_samples += ret - drain;
drain = frame->nb_samples - written;
@@ -158,7 +158,7 @@ static int afilter_frame(AVFilterLink *inlink, AVFrame *frame)
av_audio_fifo_drain(s->left, drain);
}
frame->nb_samples = ret;
- s->pts += ret;
+ s->pts += av_rescale_q(ret, (AVRational){1, outlink->sample_rate}, outlink->time_base);
ret = ff_filter_frame(outlink, frame);
} else {
int nb_samples = frame->nb_samples;
@@ -169,7 +169,7 @@ static int afilter_frame(AVFilterLink *inlink, AVFrame *frame)
} else {
s->ignored_samples += frame->nb_samples;
frame->pts = s->pts;
- s->pts += frame->nb_samples;
+ s->pts += av_rescale_q(frame->nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
ret = ff_filter_frame(outlink, frame);
}
@@ -195,7 +195,7 @@ static int arequest_frame(AVFilterLink *outlink)
return AVERROR(ENOMEM);
av_audio_fifo_read(s->left, (void **)out->extended_data, nb_samples);
out->pts = s->pts;
- s->pts += nb_samples;
+ s->pts += av_rescale_q(nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
ret = ff_filter_frame(outlink, out);
if (ret < 0)
return ret;
More information about the ffmpeg-cvslog
mailing list