diff options
author | Paul B Mahol <onemda@gmail.com> | 2019-01-11 11:45:42 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2019-01-11 11:54:15 +0100 |
commit | c563513fdf7281e2a348fc18c58c51ad5608ed6a (patch) | |
tree | 6587758dbd8912f6d78f528b0f68ffa8fd8ccd17 /libavfilter | |
parent | b5ae61d2c0ae3b7609bfc896d71b88bdba76e7b3 (diff) | |
download | ffmpeg-c563513fdf7281e2a348fc18c58c51ad5608ed6a.tar.gz |
avfilter/af_anlmdn: drain samples at end
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/af_anlmdn.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libavfilter/af_anlmdn.c b/libavfilter/af_anlmdn.c index efc261e16a..e36e78edd5 100644 --- a/libavfilter/af_anlmdn.c +++ b/libavfilter/af_anlmdn.c @@ -57,6 +57,7 @@ typedef struct AudioNLMeansContext { int64_t pts; AVAudioFifo *fifo; + int eof_left; AudioNLMDNDSPContext dsp; } AudioNLMeansContext; @@ -140,6 +141,7 @@ static int config_output(AVFilterLink *outlink) s->K = av_rescale(s->pd, outlink->sample_rate, AV_TIME_BASE); s->S = av_rescale(s->rd, outlink->sample_rate, AV_TIME_BASE); + s->eof_left = -1; s->pts = AV_NOPTS_VALUE; s->H = s->K * 2 + 1; s->N = s->H + (s->K + s->S) * 2; @@ -276,6 +278,33 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) return ret; } +static int request_frame(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + AudioNLMeansContext *s = ctx->priv; + int ret; + + ret = ff_request_frame(ctx->inputs[0]); + + if (ret == AVERROR_EOF && s->eof_left != 0) { + AVFrame *in; + + if (s->eof_left < 0) + s->eof_left = av_audio_fifo_size(s->fifo); + in = ff_get_audio_buffer(outlink, FFMIN(s->H, s->N - s->eof_left)); + if (!in) + return AVERROR(ENOMEM); + + if (s->eof_left < s->H) + s->eof_left = 0; + else + s->eof_left -= s->H; + return filter_frame(ctx->inputs[0], in); + } + + return ret; +} + static av_cold void uninit(AVFilterContext *ctx) { AudioNLMeansContext *s = ctx->priv; @@ -299,6 +328,7 @@ static const AVFilterPad outputs[] = { .name = "default", .type = AVMEDIA_TYPE_AUDIO, .config_props = config_output, + .request_frame = request_frame, }, { NULL } }; |