[FFmpeg-devel] [PATCH] audio fifo filter for lavfi

S.N. Hemanth Meenakshisundaram smeenaks
Thu Sep 23 17:41:40 CEST 2010

 On 09/22/2010 07:32 PM, Michael Niedermayer wrote:
> On Wed, Sep 22, 2010 at 07:05:16PM -0700, S.N. Hemanth Meenakshisundaram wrote:
> [...]
>> +
>> +static int request_frame(AVFilterLink *link)
>> +{
>> +    FifoContext *fifo = link->src->priv;
>> +    BufSamples *tmp;
>> +    int err;
>> +
>> +    if (!fifo->root.next)
>> +        if ((err = avfilter_request_frame(link->src->inputs[0])) < 0) {
>> +            fifo->frame_requests_pending++;
>> +            return err;
>> +        }
> elaborate please on how this can work
> frames have no known size, anything calling request_frame() 5 times could
> as a result get 5 samples or 5 billion samples
> simply setting frame_requests_pending=1 would likely do the same
> but this seems not what you intended it to do

Isn't that what we want here? The number of samples in the frame would
depend on how the decoder produces frames or on how any preceding filter
in the chain puts new frames together. The fifo would simply queue these
frames (whatever their size) and then send them to the next filter.
If the next filter called request frame n times without getting any
data, then the fifo filter would skip queueing and directly pass frames
the next n times.

I guess poll frame too should then report the number of frames instead
of samples.

Though the size of a 'frame' is undefined, it should be a reasonable
number of samples unless the decoder or any other filters are written to
produce frames of too few/too many samples.

One alternative would be to allow a filter to specify the number of
samples it expects during initial configuration (including an option to
just accept whatever the preceding filter gives). If a filter will only
accept a specific number of samples per frame, we can have an
auto-inserted filter manage unpacking, buffering and repacking samples
into frames as required. Would this be a better idea?


More information about the ffmpeg-devel mailing list