Loading...
Searching...
No Matches
AVChannelLayout Struct Reference
libavutil » Audio related » Audio channels

An AVChannelLayout holds information about the channel layout of audio data. More...

`#include <libavutil/channel_layout.h>`

## Data Fields

enum AVChannelOrder | order
| Channel order used in this layout.
int | nb_channels
| Number of channels in this layout.
union { |
uint64_t mask |
| This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC to signal non-diegetic channels. More...
AVChannelCustom * map |
| This member must be used when the channel order is AV_CHANNEL_ORDER_CUSTOM. More...
} | u
| Details about which channels are present in this layout.
void * | opaque
| For some private data of the user.

## Detailed Description

An AVChannelLayout holds information about the channel layout of audio data.

A channel layout here is defined as a set of channels ordered in a specific way (unless the channel order is AV_CHANNEL_ORDER_UNSPEC, in which case an AVChannelLayout carries only the channel count). All orders may be treated as if they were AV_CHANNEL_ORDER_UNSPEC by ignoring everything but the channel count, as long as av_channel_layout_check() considers they are valid.

Unlike most structures in FFmpeg, sizeof(AVChannelLayout) is a part of the public ABI and may be used by the caller. E.g. it may be allocated on stack or embedded in caller-defined structs.

AVChannelLayout can be initialized as follows:

- default initialization with {0}, followed by setting all used fields correctly;
- by assigning one of the predefined AV_CHANNEL_LAYOUT_* initializers;
- with a constructor function, such as av_channel_layout_default(), av_channel_layout_from_mask() or av_channel_layout_from_string().

The channel layout must be uninitialized with av_channel_layout_uninit()

Copying an AVChannelLayout via assigning is forbidden, av_channel_layout_copy() must be used instead (and its return value should be checked)

No new fields may be added to it without a major version bump, except for new elements of the union fitting in sizeof(uint64_t).

Examples
  encode_audio.c, mux.c, and resample_audio.c.

Definition at line 319 of file channel_layout.h.

## Field Documentation

## order

enum AVChannelOrder AVChannelLayout::order

Channel order used in this layout.

This is a mandatory field.

Definition at line 324 of file channel_layout.h.

## nb_channels

int AVChannelLayout::nb_channels

Number of channels in this layout.

Mandatory field.

Examples
  decode_audio.c, encode_audio.c, resample_audio.c, and transcode_aac.c.

Definition at line 329 of file channel_layout.h.

Referenced by init_converted_samples(), init_fifo(), main(), and select_channel_layout().

## mask

uint64_t AVChannelLayout::mask

This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC to signal non-diegetic channels.

It is a bitmask, where the position of each set bit means that the AVChannel with the corresponding value is present.

I.e. when (mask & (1 << AV_CHAN_FOO)) is non-zero, then AV_CHAN_FOO is present in the layout. Otherwise it is not present.

Note
  when a channel layout using a bitmask is constructed or modified manually (i.e. not using any of the av_channel_layout_* functions), the code doing it must ensure that the number of set bits is equal to nb_channels.

Definition at line 351 of file channel_layout.h.

## map

AVChannelCustom* AVChannelLayout::map

This member must be used when the channel order is AV_CHANNEL_ORDER_CUSTOM.

It is a nb_channels-sized array, with each element signalling the presence of the AVChannel with the corresponding value in map[i].id.

I.e. when map[i].id is equal to AV_CHAN_FOO, then AV_CH_FOO is the i-th channel in the audio data.

When map[i].id is in the range between AV_CHAN_AMBISONIC_BASE and AV_CHAN_AMBISONIC_END (inclusive), the channel contains an ambisonic component with ACN index (as defined above) n = map[i].id - AV_CHAN_AMBISONIC_BASE.

map[i].name may be filled with a 0-terminated string, in which case it will be used for the purpose of identifying the channel with the convenience functions below. Otherwise it must be zeroed.

Definition at line 370 of file channel_layout.h.

## [union]

union { ... } AVChannelLayout::u

Details about which channels are present in this layout.

For AV_CHANNEL_ORDER_UNSPEC, this field is undefined and must not be used.

## opaque

void* AVChannelLayout::opaque

For some private data of the user.

Definition at line 376 of file channel_layout.h.

The documentation for this struct was generated from the following file:

- libavutil/channel_layout.h