diff options
author | Paul B Mahol <onemda@gmail.com> | 2019-01-11 16:51:49 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2019-01-11 16:51:49 +0100 |
commit | c65c4ce773656c41d58ab6d26bea6e1a97ee2751 (patch) | |
tree | e82bc6a0d944620f7c6e5201cdfdcc57921bda12 /libavfilter | |
parent | 127564b3f114da4a08883a533411f83584874aac (diff) | |
download | ffmpeg-c65c4ce773656c41d58ab6d26bea6e1a97ee2751.tar.gz |
avfilter/af_anlmdn: do not output more samples than received
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/af_anlmdn.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libavfilter/af_anlmdn.c b/libavfilter/af_anlmdn.c index e36e78edd5..7cd6f2c477 100644 --- a/libavfilter/af_anlmdn.c +++ b/libavfilter/af_anlmdn.c @@ -270,6 +270,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) if (out) { out->pts = s->pts; out->nb_samples = s->offset; + if (s->eof_left >= 0) { + out->nb_samples = FFMIN(s->eof_left, s->offset); + s->eof_left -= out->nb_samples; + } s->pts += s->offset; return ff_filter_frame(outlink, out); @@ -290,15 +294,13 @@ static int request_frame(AVFilterLink *outlink) 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)); + s->eof_left = av_audio_fifo_size(s->fifo) - (s->S + s->K); + if (s->eof_left < 0) + return AVERROR_EOF; + in = ff_get_audio_buffer(outlink, s->H); 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); } |