aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/af_aresample.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-11-06 22:59:16 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-11-06 23:54:02 +0100
commitea6331b2c6025819cf56b0c104b1a26b08818435 (patch)
tree1fcba4527fb667ba99b12d2d5b99216577974d72 /libavfilter/af_aresample.c
parent3e6b7bbce510c53b4d7962f29aaf745c9b729775 (diff)
downloadffmpeg-ea6331b2c6025819cf56b0c104b1a26b08818435.tar.gz
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>
Diffstat (limited to 'libavfilter/af_aresample.c')
-rw-r--r--libavfilter/af_aresample.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c
index 86e7b74b46..e21b3e4a04 100644
--- a/libavfilter/af_aresample.c
+++ b/libavfilter/af_aresample.c
@@ -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);