Commit c65c4ce7 authored by Paul B Mahol's avatar Paul B Mahol

avfilter/af_anlmdn: do not output more samples than received

parent 127564b3
...@@ -270,6 +270,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) ...@@ -270,6 +270,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
if (out) { if (out) {
out->pts = s->pts; out->pts = s->pts;
out->nb_samples = s->offset; 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; s->pts += s->offset;
return ff_filter_frame(outlink, out); return ff_filter_frame(outlink, out);
...@@ -290,15 +294,13 @@ static int request_frame(AVFilterLink *outlink) ...@@ -290,15 +294,13 @@ static int request_frame(AVFilterLink *outlink)
AVFrame *in; AVFrame *in;
if (s->eof_left < 0) if (s->eof_left < 0)
s->eof_left = av_audio_fifo_size(s->fifo); s->eof_left = av_audio_fifo_size(s->fifo) - (s->S + s->K);
in = ff_get_audio_buffer(outlink, FFMIN(s->H, s->N - s->eof_left)); if (s->eof_left < 0)
return AVERROR_EOF;
in = ff_get_audio_buffer(outlink, s->H);
if (!in) if (!in)
return AVERROR(ENOMEM); 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 filter_frame(ctx->inputs[0], in);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment