[FFmpeg-devel] Channel layouts (was: [PATCH] lavfi: store and propagate number of channels information in audio buffer properties)

Nicolas George nicolas.george at normalesup.org
Mon Nov 12 17:49:01 CET 2012


Le duodi 22 brumaire, an CCXXI, Michael Niedermayer a écrit :
> We need the channel number. We have a patch that solves this
> for the long term in a very simple and clean way.
>
> Problem is we need to know the size of the array, its a security matter
> The array size is the channel count EVERYWHERE in libavcodec and
> libavformat and ffmpeg*.c ffplay*.c libavdevice and others.
> Its a major issue if its done differently in libavfilter, it will be
> a neverending source of bugs if this is done differently in
> libavfilter.
> 
> The question or rather what i dont get is what problem (if any) this
> trivial patch has?

Sorry if I seemed to object to the patch: I do not, the patch is fine. I
just took the occasion to raise the issues.

But the lavfi ABI mandates a valid channel layout that gives the number of
channels correctly using av_get_channel_layout_nb_channels(). Having an
additional field with the channel count directly  is not a problem. Changing
the semantic of the channel_layout field would be an ABI break.

> I want to store more than 64 channels, nothing you suggest allows this
> how can this hack even be related to a solution, it plain and simple
> does not solve it.
> and 64 doesnt work either due to various special bits and special
> cases

Yes. Going beyond the 63 limit falls in the category "long-term solution",
not "immediate workaround".

> i want 8 mono channels or 4 stereo channels and i want to be able
> to know which.

You take an easy situation, where it could work. But what about the other
example you suggested: 7.1+5.1+stereo+mono = 17 channels?

There is no way around it: 

> Add a channel count and the channel layout will just tell us which
> your system will mark either as "7.1 strange"
> No muxer can make any sense of "7.1 strange"

The point would be to have "8-channels unknown layout" instead of an invalid
"7.1".

> but with a channel count we can just preserve the layout as it IS
> from the input file.

No, we can not. The documented API is that channel_layout = 0 means unknown
layout and anything else has the property that
av_get_channel_layout_nb_channels() returns the number of channels.

>			with your hack we have no place to preserve then
> TRUELY stored channel layout because you would use the layout as
> nothing but a channel count.

Yes, because  the current API is not capable of expressing complex channel
layouts. We want to fix that, but that will require careful design, and
therefore take a bit of time.

>			 NOT something that in libavcodec means A
> and in libavfilter means B

The channel layout has exactly the same semantic in lavc and lavfi. The only
difference is that lavc considers it optional while lavfi considers it
mandatory.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121112/d7238261/attachment.asc>


More information about the ffmpeg-devel mailing list