[FFmpeg-cvslog] avfilter/avf_showspectrum: improve pts handling
Paul B Mahol
git at videolan.org
Fri Feb 12 17:16:24 CET 2016
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Feb 12 17:14:30 2016 +0100| [13ea7c9780575ff63230c2614c54eaf28064f8c6] | committer: Paul B Mahol
avfilter/avf_showspectrum: improve pts handling
Signed-off-by: Paul B Mahol <onemda at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=13ea7c9780575ff63230c2614c54eaf28064f8c6
---
libavfilter/avf_showspectrum.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c
index 3efd000..6be97af 100644
--- a/libavfilter/avf_showspectrum.c
+++ b/libavfilter/avf_showspectrum.c
@@ -793,7 +793,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
AVFilterContext *ctx = inlink->dst;
ShowSpectrumContext *s = ctx->priv;
AVFrame *fin = NULL;
- int ret = 0;
+ int ret = 0, consumed = 0;
+
+ if (s->pts == AV_NOPTS_VALUE)
+ s->pts = insamples->pts - av_audio_fifo_size(s->fifo);
av_audio_fifo_write(s->fifo, (void **)insamples->extended_data, insamples->nb_samples);
av_frame_free(&insamples);
@@ -804,8 +807,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
goto fail;
}
- fin->pts = s->pts;
- s->pts += s->hop_size;
+ fin->pts = s->pts + consumed;
+ consumed += s->hop_size;
ret = av_audio_fifo_peek(s->fifo, (void **)fin->extended_data, s->win_size);
if (ret < 0)
goto fail;
@@ -826,6 +829,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
}
fail:
+ s->pts = AV_NOPTS_VALUE;
av_frame_free(&fin);
return ret;
}
More information about the ffmpeg-cvslog
mailing list