[FFmpeg-devel] [PATCH] lavfi: asetnsamples: fix enlarging fifo
Stefano Sabatini
stefasab at gmail.com
Mon Aug 6 23:14:03 CEST 2012
On date Monday 2012-08-06 23:04:44 +0300, Andrey Utkin encoded:
> ---
> libavfilter/af_asetnsamples.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/libavfilter/af_asetnsamples.c b/libavfilter/af_asetnsamples.c
> index 8805d53..e00980e 100644
> --- a/libavfilter/af_asetnsamples.c
> +++ b/libavfilter/af_asetnsamples.c
> @@ -141,7 +141,7 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples)
>
> if (av_audio_fifo_space(asns->fifo) < nb_samples) {
> av_log(ctx, AV_LOG_DEBUG, "No space for %d samples, stretching audio fifo\n", nb_samples);
> - ret = av_audio_fifo_realloc(asns->fifo, av_audio_fifo_size(asns->fifo) + nb_samples);
> + ret = av_audio_fifo_realloc(asns->fifo, av_audio_fifo_size(asns->fifo) + av_audio_fifo_space(asns->fifo) + nb_samples);
This is overallocating the fifo.
We need to add nb_samples to the fifo, but only FIFO_SPACE <
nb_samples are available, so we increase the fifo max size to
FIFO_SIZE + nb_samples.
We have:
FIFO_SIZE + FIFO_SPACE = AVAILABLE_SIZE
FIFO_SPACE = nb_samples
so it must result:
FIFO_SIZE + nb_samples = AVAILABLE_SIZE
What am I missing?
[...]
--
FFmpeg = Funny & Fundamental MultiPurpose Energized Gargoyle
More information about the ffmpeg-devel
mailing list