[FFmpeg-devel] [PATCH] lavfi: asetnsamples: fix enlarging fifo

Stefano Sabatini stefasab at gmail.com
Tue Aug 7 23:10:16 CEST 2012


On date Tuesday 2012-08-07 00:33:40 +0300, Andrey Utkin encoded:
> 2012/8/7 Stefano Sabatini <stefasab at gmail.com>:
> > 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?
> 
> You're missing the fact that av_audio_fifo_size() returns not the full
> memory capacity of the object, but the amount of data loaded into it.
> The same principle applies to AVFifoBuffer. This is confusing moment
> indeed.

Yes, I took that into account. fifo_size() returns (quite confusingly)
the *used* number of samples in the fifo, the new total allocated size
is still FIFO_SIZE+nb_samples.

Or in other words, does the patch fix a problem?
 
> /**
>  * Get the current number of samples in the AVAudioFifo available for reading.
>  *
>  * @param af  the AVAudioFifo to query
>  * @return    number of samples available for reading
>  */
> int av_audio_fifo_size(AVAudioFifo *af);

[...]
-- 
FFmpeg = Faithful Frenzy Mournful Ponderous Educated Gargoyle


More information about the ffmpeg-devel mailing list