diff options
author | Paul B Mahol <onemda@gmail.com> | 2022-03-13 18:00:18 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2022-03-13 18:02:24 +0100 |
commit | 07b8d6a897b927a187c3d3268202e7160aa93900 (patch) | |
tree | 42bab510937800e1dcc20cc021fff168c4e5ef80 /libavfilter/avf_showspectrum.c | |
parent | 61224c856c9c7de598970b1aaa7b74b366f9b82a (diff) |
avfilter/avf_showspectrum: stop rewriting pts
Also fix dropping of first frame for fullframe sliding.
Diffstat (limited to 'libavfilter/avf_showspectrum.c')
-rw-r--r-- | libavfilter/avf_showspectrum.c | 11 |
1 files 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; |