avfilter/af_aresample: Calculate output buffer size more precisely.
Fixes accumulation of data in case of significant silence injections Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
3e6b7bbce5
commit
ea6331b2c6
@ -170,11 +170,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref)
|
||||
{
|
||||
AResampleContext *aresample = inlink->dst->priv;
|
||||
const int n_in = insamplesref->nb_samples;
|
||||
int n_out = n_in * aresample->ratio * 2 + 256;
|
||||
int64_t delay;
|
||||
int n_out = n_in * aresample->ratio + 32;
|
||||
AVFilterLink *const outlink = inlink->dst->outputs[0];
|
||||
AVFrame *outsamplesref = ff_get_audio_buffer(outlink, n_out);
|
||||
AVFrame *outsamplesref;
|
||||
int ret;
|
||||
|
||||
delay = swr_get_delay(aresample->swr, outlink->sample_rate);
|
||||
if (delay > 0)
|
||||
n_out += delay;
|
||||
|
||||
outsamplesref = ff_get_audio_buffer(outlink, n_out);
|
||||
|
||||
if(!outsamplesref)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user