[FFmpeg-devel] [RFC] Channel layouts

Michael Niedermayer michaelni
Sat Oct 25 11:32:46 CEST 2008


On Sat, Oct 25, 2008 at 03:34:16PM +1100, Peter Ross wrote:
> On Tue, Sep 23, 2008 at 10:43:22PM +1000, Peter Ross wrote:
> > On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote:
> > > On Sat, Aug 30, 2008 at 11:05:43AM +1000, Peter Ross wrote:
> > > > On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
> > > > > Hi.
> > > > > 
> > > > > This patch adds the notion of channel layouts to libavcodec.
> > > > 
> > > > Patch updated. Thanks for the feedback.
> > > 
> > > Patch updated.
> > 
> > Patch updated.
> 
> Patch updated. (See the parent post for the RIFF/WAV patch.)
> 
> -- Peter
> (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)

[...]
> +        snprintf(buf + strlen(buf), buf_size - strlen(buf), ", ");

av_strlcat()


> +        avcodec_get_channel_layout_string(buf + strlen(buf), buf_size - strlen(buf), enc->channels, enc->channel_layout);
>          if (enc->sample_fmt != SAMPLE_FMT_NONE) {
>              snprintf(buf + strlen(buf), buf_size - strlen(buf),
>                       ", %s", avcodec_get_sample_fmt_name(enc->sample_fmt));
> Index: libavcodec/audioconvert.c
> ===================================================================
> --- libavcodec/audioconvert.c	(revision 15697)
> +++ libavcodec/audioconvert.c	(working copy)
> @@ -27,6 +27,7 @@
>  
>  #include "avcodec.h"
>  #include "audioconvert.h"
> +#include <libavutil/avstring.h>
>  
>  typedef struct SampleFmtInfo {
>      const char *name;

> @@ -70,6 +71,100 @@
>      }
>  }
>  
> +static const char* channel_names[]={

static const char* const channel_names[]={


[...]
> +const char * get_channel_name(int channel_id)
> +{
> +    if (channel_id<0 || channel_id>=sizeof(channel_names)/sizeof(char*))

FF_ARRAY_ELEMS


> +        return NULL;
> +    return channel_names[channel_id];
> +}
> +
> +int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name)
> +{
> +    switch(nb_channels) {
> +    case 1: return CHANNEL_LAYOUT_MONO;
> +    case 2: return CHANNEL_LAYOUT_STEREO;
> +    case 3: return CHANNEL_LAYOUT_SURROUND;
> +    case 4: return CHANNEL_LAYOUT_QUAD;
> +    case 5: return CHANNEL_LAYOUT_5POINT0;
> +    case 6: return CHANNEL_LAYOUT_5POINT1;
> +    case 8: return CHANNEL_LAYOUT_7POINT1;
> +    default: return 0;
> +    }
> +}
> +
> +static const struct {

> +    const char *name;
> +    int      nb_channels;
> +    int64_t  layout;

was this supposed to be vertically aligned? if so it seems not anymore


> +} channel_layout_map[] = {
> +    { "mono",        1, CHANNEL_LAYOUT_MONO },
> +    { "stereo",      2, CHANNEL_LAYOUT_STEREO },
> +    { "surround",    3, CHANNEL_LAYOUT_SURROUND },
> +    { "quad",        4, CHANNEL_LAYOUT_QUAD },
> +    { "5.0",         5, CHANNEL_LAYOUT_5POINT0 },
> +    { "5.1",         6,  CHANNEL_LAYOUT_5POINT1 },
> +    { "5.1+downmix", 8,  CHANNEL_LAYOUT_5POINT1|CHANNEL_LAYOUT_STEREO_DOWNMIX, },
> +    { "7.1",         8,  CHANNEL_LAYOUT_7POINT1 },
> +    { "7.1(wide)",   8,  CHANNEL_LAYOUT_7POINT1_WIDE },
> +    { "7.1+downmix", 10, CHANNEL_LAYOUT_7POINT1|CHANNEL_LAYOUT_STEREO_DOWNMIX, },
> +    { 0 }
> +};

this also seems half vertically aligned

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081025/b377e28d/attachment.pgp>



More information about the ffmpeg-devel mailing list