[FFmpeg-cvslog] avfilter/avf_showspectrum: stop rewriting pts

Paul B Mahol git at videolan.org
Sun Mar 13 19:01:03 EET 2022


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Mar 13 18:00:18 2022 +0100| [07b8d6a897b927a187c3d3268202e7160aa93900] | committer: Paul B Mahol

avfilter/avf_showspectrum: stop rewriting pts

Also fix dropping of first frame for fullframe sliding.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=07b8d6a897b927a187c3d3268202e7160aa93900
---

 libavfilter/avf_showspectrum.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c
index 610dc98c93..237b5955bb 100644
--- a/libavfilter/avf_showspectrum.c
+++ b/libavfilter/avf_showspectrum.c
@@ -93,12 +93,12 @@ typedef struct ShowSpectrumContext {
     double win_scale;
     float overlap;
     float gain;
-    int consumed;
     int hop_size;
     float *combine_buffer;      ///< color combining buffer (3 * h items)
     float **color_buffer;       ///< color buffer (3 * h * ch items)
     int64_t pts;
     int64_t old_pts;
+    int64_t in_pts;
     int old_len;
     int single_pic;
     int legend;
@@ -1464,7 +1464,7 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples)
     }
 
     if (s->sliding != FULLFRAME || s->xpos == 0)
-        s->pts = outpicref->pts = av_rescale_q(insamples->pts, inlink->time_base, outlink->time_base);
+        s->pts = outpicref->pts = av_rescale_q(s->in_pts, inlink->time_base, outlink->time_base);
 
     if (s->sliding == LREPLACE) {
         s->xpos--;
@@ -1481,7 +1481,7 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples)
     }
 
     if (!s->single_pic && (s->sliding != FULLFRAME || s->xpos == 0)) {
-        if (s->old_pts < outpicref->pts) {
+        if (s->old_pts < outpicref->pts || s->sliding == FULLFRAME) {
             AVFrame *clone;
 
             if (s->legend) {
@@ -1544,7 +1544,6 @@ static int activate(AVFilterContext *ctx)
         if (ret < 0)
             return ret;
         if (ret > 0) {
-            s->consumed += fin->nb_samples;
             ff_filter_execute(ctx, run_channel_fft, fin, NULL, s->nb_display_channels);
 
             if (s->data == D_MAGNITUDE)
@@ -1556,6 +1555,8 @@ static int activate(AVFilterContext *ctx)
             if (s->data == D_UPHASE)
                 ff_filter_execute(ctx, calc_channel_uphases, NULL, NULL, s->nb_display_channels);
 
+            if (s->xpos == 0 || s->sliding != FULLFRAME)
+                s->in_pts = fin->pts;
             ret = plot_spectrum_column(inlink, fin);
             av_frame_free(&fin);
             if (ret <= 0)
@@ -1580,7 +1581,7 @@ static int activate(AVFilterContext *ctx)
                 memset(s->outpicref->data[2] + i * s->outpicref->linesize[2], 128, outlink->w);
             }
         }
-        s->outpicref->pts += av_rescale_q(s->consumed, inlink->time_base, outlink->time_base);
+        s->outpicref->pts = av_rescale_q(s->in_pts, inlink->time_base, outlink->time_base);
         pts = s->outpicref->pts;
         ret = ff_filter_frame(outlink, s->outpicref);
         s->outpicref = NULL;



More information about the ffmpeg-cvslog mailing list