[FFmpeg-devel] [GSoC] Qualification Task

Mina Nagy Zaki mnzaki at gmail.com
Wed Mar 23 05:25:15 CET 2011

On Tuesday 22 March 2011 17:35:39 Stefano Sabatini wrote:
> > In both cases I can't seem to figure out how I can find the end of
> > stream, which is important for some effects as they need to 'drain'
> > (like the echo effect).
> I suppose you read AVERROR_EOF from avfilter_request_frame() when you
> reach the end of a stream. Note that I'm a bit rusty with libavfilter
> audio, as it is some months I don't touch that code and I don't have a
> good memory ;-), but I remember there was a problem with some filters
> which needed that (in particular a video concatenation filter).
> Check: cmdutils.c:get_filtered_audio_buffer(), it implements a pull
> model, correct me if I'm wrong.

I have already checked that, which is what lead me to the question in the first 
place. I can't really read AVERROR_EOF from request_frame() because audio 
filters don't(/shouldn't?) use it. get_filtered_audio_buffer() does a 
request_frame() on aout which propagates all the way to asrc (without passing 
through intermediate filters, because they don't/shouldn't use it) which then 
does a filter_samples that propagates all the way to aout! If I try to 
request_frame from the previous buffer it will reach asrc then eventually lead 
to calling my own effect's filter_samples, so now do I filter in filter_samples or 
request_frame :D  And in any case, asrc never returns AVERROR_EOF anyway.

I have examined most of the RFC thread about lavfi audio, but I couldn't really 
find a discussion about push/pull models. The current mixture is a slight mess.

> > Another major problem is what you asked at the very end: more than two
> > channels in the widen effect. I was actually planning to send a separate
> > email about this: Channel Negotiation. Not all effects can handle any
> > number of channels, and there's no way to do anything about it (except
> > fail loudly) in the current API.
> > 
> > Again looking at sox, it does this by having effects declare
> > whether or not they can handle multiple channels. If they can then it
> > simply sends in the entire stream. If they can't then it creates an
> > effect instance for each channel, splits the stream, and 'flows' samples
> > of one channel into each of the effect instances. IMHO we _could_
> > improve on this.
> I suppose the lavfi way would be to let the various filters declare
> which are the supported channel layouts during the init stage, and
> auto-insert an aconvert filter when it is needed.  For example you
> could have:
> aconvert=s16:mono, widen
> -> an aconvert is automatically inserted before widen
> aconvert=s16:mono, aconvert=s16:stereo, widen

Seems reasonable.

> BTW, thinking at it since this is a port I think it would be better to
> use the same name of the original effect, so it's easier for people to
> spot the correspondence between the two.

Sure. I've attached the latest patch, after all modifications.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: earwax_filter.patch
Type: text/x-patch
Size: 6847 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110323/c152ba8e/attachment.bin>

More information about the ffmpeg-devel mailing list