aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2019-11-17 15:21:07 +0100
committerPaul B Mahol <onemda@gmail.com>2019-11-17 16:19:07 +0100
commit2e7ccd493aec98c19f788f2e330bfaf97ac9fbea (patch)
tree51e87cfeb333b9743616aa47dc3828346440031e
parentf7ad9a6c168a086a4a135ddbe1e112c48c96e8d7 (diff)
downloadffmpeg-2e7ccd493aec98c19f788f2e330bfaf97ac9fbea.tar.gz
avfilter/f_loop: fix pts handling when timebase and 1/samplerate differ
-rw-r--r--libavfilter/f_loop.c10
1 files 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;