FFmpeg 7.1.1
|
Audio channel layout utility functions. More...
Modules | |
Audio channel masks | |
A channel layout is a 64-bits integer with a bit set for every channel. | |
Audio channel layouts | |
Files | |
file | channel_layout.h |
Public libavutil channel layout APIs header. | |
Data Structures | |
struct | AVChannelCustom |
An AVChannelCustom defines a single channel within a custom order layout. More... | |
struct | AVChannelLayout |
An AVChannelLayout holds information about the channel layout of audio data. More... | |
Macros | |
#define | AV_CHANNEL_LAYOUT_MASK(nb, m) |
Macro to define native channel layouts. | |
#define | AV_CHANNEL_LAYOUT_RETYPE_FLAG_LOSSLESS (1 << 0) |
The conversion must be lossless. | |
#define | AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL (1 << 1) |
The specified retype target order is ignored and the simplest possible (canonical) order is used for which the input layout can be losslessy represented. | |
Functions | |
int | av_channel_name (char *buf, size_t buf_size, enum AVChannel channel) |
Get a human readable string in an abbreviated form describing a given channel. | |
void | av_channel_name_bprint (struct AVBPrint *bp, enum AVChannel channel_id) |
bprint variant of av_channel_name(). | |
int | av_channel_description (char *buf, size_t buf_size, enum AVChannel channel) |
Get a human readable string describing a given channel. | |
void | av_channel_description_bprint (struct AVBPrint *bp, enum AVChannel channel_id) |
bprint variant of av_channel_description(). | |
enum AVChannel | av_channel_from_string (const char *name) |
This is the inverse function of av_channel_name(). | |
int | av_channel_layout_custom_init (AVChannelLayout *channel_layout, int nb_channels) |
Initialize a custom channel layout with the specified number of channels. | |
int | av_channel_layout_from_mask (AVChannelLayout *channel_layout, uint64_t mask) |
Initialize a native channel layout from a bitmask indicating which channels are present. | |
int | av_channel_layout_from_string (AVChannelLayout *channel_layout, const char *str) |
Initialize a channel layout from a given string description. | |
void | av_channel_layout_default (AVChannelLayout *ch_layout, int nb_channels) |
Get the default channel layout for a given number of channels. | |
const AVChannelLayout * | av_channel_layout_standard (void **opaque) |
Iterate over all standard channel layouts. | |
void | av_channel_layout_uninit (AVChannelLayout *channel_layout) |
Free any allocated data in the channel layout and reset the channel count to 0. | |
int | av_channel_layout_copy (AVChannelLayout *dst, const AVChannelLayout *src) |
Make a copy of a channel layout. | |
int | av_channel_layout_describe (const AVChannelLayout *channel_layout, char *buf, size_t buf_size) |
Get a human-readable string describing the channel layout properties. | |
int | av_channel_layout_describe_bprint (const AVChannelLayout *channel_layout, struct AVBPrint *bp) |
bprint variant of av_channel_layout_describe(). | |
enum AVChannel | av_channel_layout_channel_from_index (const AVChannelLayout *channel_layout, unsigned int idx) |
Get the channel with the given index in a channel layout. | |
int | av_channel_layout_index_from_channel (const AVChannelLayout *channel_layout, enum AVChannel channel) |
Get the index of a given channel in a channel layout. | |
int | av_channel_layout_index_from_string (const AVChannelLayout *channel_layout, const char *name) |
Get the index in a channel layout of a channel described by the given string. | |
enum AVChannel | av_channel_layout_channel_from_string (const AVChannelLayout *channel_layout, const char *name) |
Get a channel described by the given string. | |
uint64_t | av_channel_layout_subset (const AVChannelLayout *channel_layout, uint64_t mask) |
Find out what channels from a given set are present in a channel layout, without regard for their positions. | |
int | av_channel_layout_check (const AVChannelLayout *channel_layout) |
Check whether a channel layout is valid, i.e. | |
int | av_channel_layout_compare (const AVChannelLayout *chl, const AVChannelLayout *chl1) |
Check whether two channel layouts are semantically the same, i.e. | |
int | av_channel_layout_ambisonic_order (const AVChannelLayout *channel_layout) |
Return the order if the layout is n-th order standard-order ambisonic. | |
int | av_channel_layout_retype (AVChannelLayout *channel_layout, enum AVChannelOrder order, int flags) |
Change the AVChannelOrder of a channel layout. | |
Audio channel layout utility functions.
#define AV_CHANNEL_LAYOUT_MASK | ( | nb, | |
m | |||
) |
Macro to define native channel layouts.
Definition at line 376 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_MONO AV_CHANNEL_LAYOUT_MASK(1, AV_CH_LAYOUT_MONO) |
Definition at line 386 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_STEREO AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_STEREO) |
Definition at line 387 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_2POINT1 AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_2POINT1) |
Definition at line 388 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_2_1 AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_2_1) |
Definition at line 389 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_SURROUND AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_SURROUND) |
Definition at line 390 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_3POINT1 AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_3POINT1) |
Definition at line 391 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_4POINT0 AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_4POINT0) |
Definition at line 392 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_4POINT1 AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_4POINT1) |
Definition at line 393 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_2_2 AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_2_2) |
Definition at line 394 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_QUAD AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_QUAD) |
Definition at line 395 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_5POINT0 AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_5POINT0) |
Definition at line 396 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_5POINT1 AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_5POINT1) |
Definition at line 397 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_5POINT0_BACK AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_5POINT0_BACK) |
Definition at line 398 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_5POINT1_BACK AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_5POINT1_BACK) |
Definition at line 399 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_6POINT0 AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_6POINT0) |
Definition at line 400 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_6POINT0_FRONT AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_6POINT0_FRONT) |
Definition at line 401 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_3POINT1POINT2 AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_3POINT1POINT2) |
Definition at line 402 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_HEXAGONAL AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_HEXAGONAL) |
Definition at line 403 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_6POINT1 AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1) |
Definition at line 404 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_6POINT1_BACK AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1_BACK) |
Definition at line 405 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_6POINT1_FRONT AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1_FRONT) |
Definition at line 406 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_7POINT0 AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_7POINT0) |
Definition at line 407 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_7POINT0_FRONT AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_7POINT0_FRONT) |
Definition at line 408 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_7POINT1 AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1) |
Definition at line 409 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_7POINT1_WIDE AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1_WIDE) |
Definition at line 410 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1_WIDE_BACK) |
Definition at line 411 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_5POINT1POINT2_BACK) |
Definition at line 412 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_OCTAGONAL AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_OCTAGONAL) |
Definition at line 413 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_CUBE AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_CUBE) |
Definition at line 414 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_5POINT1POINT4_BACK AV_CHANNEL_LAYOUT_MASK(10, AV_CH_LAYOUT_5POINT1POINT4_BACK) |
Definition at line 415 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_7POINT1POINT2 AV_CHANNEL_LAYOUT_MASK(10, AV_CH_LAYOUT_7POINT1POINT2) |
Definition at line 416 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_7POINT1POINT4_BACK AV_CHANNEL_LAYOUT_MASK(12, AV_CH_LAYOUT_7POINT1POINT4_BACK) |
Definition at line 417 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_7POINT2POINT3 AV_CHANNEL_LAYOUT_MASK(12, AV_CH_LAYOUT_7POINT2POINT3) |
Definition at line 418 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK AV_CHANNEL_LAYOUT_MASK(14, AV_CH_LAYOUT_9POINT1POINT4_BACK) |
Definition at line 419 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_HEXADECAGONAL AV_CHANNEL_LAYOUT_MASK(16, AV_CH_LAYOUT_HEXADECAGONAL) |
Definition at line 420 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_STEREO_DOWNMIX AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_STEREO_DOWNMIX) |
Definition at line 421 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_22POINT2 AV_CHANNEL_LAYOUT_MASK(24, AV_CH_LAYOUT_22POINT2) |
Definition at line 422 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_7POINT1_TOP_BACK AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK |
Definition at line 424 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_AMBISONIC_FIRST_ORDER |
Definition at line 426 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_LOSSLESS (1 << 0) |
The conversion must be lossless.
Definition at line 703 of file channel_layout.h.
#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL (1 << 1) |
The specified retype target order is ignored and the simplest possible (canonical) order is used for which the input layout can be losslessy represented.
Definition at line 710 of file channel_layout.h.
enum AVChannel |
Definition at line 47 of file channel_layout.h.
enum AVChannelOrder |
Definition at line 111 of file channel_layout.h.
int av_channel_name | ( | char * | buf, |
size_t | buf_size, | ||
enum AVChannel | channel | ||
) |
Get a human readable string in an abbreviated form describing a given channel.
This is the inverse function of av_channel_from_string().
buf | pre-allocated buffer where to put the generated string |
buf_size | size in bytes of the buffer. |
channel | the AVChannel whose name to get |
bprint variant of av_channel_name().
int av_channel_description | ( | char * | buf, |
size_t | buf_size, | ||
enum AVChannel | channel | ||
) |
Get a human readable string describing a given channel.
buf | pre-allocated buffer where to put the generated string |
buf_size | size in bytes of the buffer. |
channel | the AVChannel whose description to get |
bprint variant of av_channel_description().
enum AVChannel av_channel_from_string | ( | const char * | name | ) |
This is the inverse function of av_channel_name().
int av_channel_layout_custom_init | ( | AVChannelLayout * | channel_layout, |
int | nb_channels | ||
) |
Initialize a custom channel layout with the specified number of channels.
The channel map will be allocated and the designation of all channels will be set to AV_CHAN_UNKNOWN.
This is only a convenience helper function, a custom channel layout can also be constructed without using this.
channel_layout | the layout structure to be initialized |
nb_channels | the number of channels |
int av_channel_layout_from_mask | ( | AVChannelLayout * | channel_layout, |
uint64_t | mask | ||
) |
Initialize a native channel layout from a bitmask indicating which channels are present.
channel_layout | the layout structure to be initialized |
mask | bitmask describing the channel layout |
int av_channel_layout_from_string | ( | AVChannelLayout * | channel_layout, |
const char * | str | ||
) |
Initialize a channel layout from a given string description.
The input string can be represented by:
channel_layout | uninitialized channel layout for the result |
str | string describing the channel layout |
void av_channel_layout_default | ( | AVChannelLayout * | ch_layout, |
int | nb_channels | ||
) |
Get the default channel layout for a given number of channels.
ch_layout | the layout structure to be initialized |
nb_channels | number of channels |
Referenced by init_filter(), init_filters(), and open_output_file().
const AVChannelLayout * av_channel_layout_standard | ( | void ** | opaque | ) |
Iterate over all standard channel layouts.
opaque | a pointer where libavutil will store the iteration state. Must point to NULL to start the iteration. |
void av_channel_layout_uninit | ( | AVChannelLayout * | channel_layout | ) |
Free any allocated data in the channel layout and reset the channel count to 0.
channel_layout | the layout structure to be uninitialized |
int av_channel_layout_copy | ( | AVChannelLayout * | dst, |
const AVChannelLayout * | src | ||
) |
Make a copy of a channel layout.
This differs from just assigning src to dst in that it allocates and copies the map for AV_CHANNEL_ORDER_CUSTOM.
dst | destination channel layout |
src | source channel layout |
Referenced by add_stream(), alloc_audio_frame(), get_input(), init_output_frame(), main(), open_output_file(), and select_channel_layout().
int av_channel_layout_describe | ( | const AVChannelLayout * | channel_layout, |
char * | buf, | ||
size_t | buf_size | ||
) |
Get a human-readable string describing the channel layout properties.
The string will be in the same format that is accepted by av_channel_layout_from_string(), allowing to rebuild the same channel layout, except for opaque pointers.
channel_layout | channel layout to be described |
buf | pre-allocated buffer where to put the generated string |
buf_size | size in bytes of the buffer. |
Referenced by init_filter(), init_filter_graph(), init_filters(), and main().
int av_channel_layout_describe_bprint | ( | const AVChannelLayout * | channel_layout, |
struct AVBPrint * | bp | ||
) |
bprint variant of av_channel_layout_describe().
enum AVChannel av_channel_layout_channel_from_index | ( | const AVChannelLayout * | channel_layout, |
unsigned int | idx | ||
) |
Get the channel with the given index in a channel layout.
channel_layout | input channel layout |
idx | index of the channel |
int av_channel_layout_index_from_channel | ( | const AVChannelLayout * | channel_layout, |
enum AVChannel | channel | ||
) |
Get the index of a given channel in a channel layout.
In case multiple channels are found, only the first match will be returned.
channel_layout | input channel layout |
channel | the channel whose index to obtain |
int av_channel_layout_index_from_string | ( | const AVChannelLayout * | channel_layout, |
const char * | name | ||
) |
Get the index in a channel layout of a channel described by the given string.
In case multiple channels are found, only the first match will be returned.
This function accepts channel names in the same format as av_channel_from_string().
channel_layout | input channel layout |
name | string describing the channel whose index to obtain |
enum AVChannel av_channel_layout_channel_from_string | ( | const AVChannelLayout * | channel_layout, |
const char * | name | ||
) |
Get a channel described by the given string.
This function accepts channel names in the same format as av_channel_from_string().
channel_layout | input channel layout |
name | string describing the channel to obtain |
uint64_t av_channel_layout_subset | ( | const AVChannelLayout * | channel_layout, |
uint64_t | mask | ||
) |
Find out what channels from a given set are present in a channel layout, without regard for their positions.
channel_layout | input channel layout |
mask | a combination of AV_CH_* representing a set of channels |
int av_channel_layout_check | ( | const AVChannelLayout * | channel_layout | ) |
Check whether a channel layout is valid, i.e.
can possibly describe audio data.
channel_layout | input channel layout |
int av_channel_layout_compare | ( | const AVChannelLayout * | chl, |
const AVChannelLayout * | chl1 | ||
) |
Check whether two channel layouts are semantically the same, i.e.
the same channels are present on the same positions in both.
If one of the channel layouts is AV_CHANNEL_ORDER_UNSPEC, while the other is not, they are considered to be unequal. If both are AV_CHANNEL_ORDER_UNSPEC, they are considered equal iff the channel counts are the same in both.
chl | input channel layout |
chl1 | input channel layout |
int av_channel_layout_ambisonic_order | ( | const AVChannelLayout * | channel_layout | ) |
Return the order if the layout is n-th order standard-order ambisonic.
The presence of optional extra non-diegetic channels at the end is not taken into account.
channel_layout | input channel layout |
int av_channel_layout_retype | ( | AVChannelLayout * | channel_layout, |
enum AVChannelOrder | order, | ||
int | flags | ||
) |
Change the AVChannelOrder of a channel layout.
Change of AVChannelOrder can be either lossless or lossy. In case of a lossless conversion all the channel designations and the associated channel names (if any) are kept. On a lossy conversion the channel names and channel designations might be lost depending on the capabilities of the desired AVChannelOrder. Note that some conversions are simply not possible in which case this function returns AVERROR(ENOSYS).
The following conversions are supported:
Any -> Custom : Always possible, always lossless. Any -> Unspecified: Always possible, lossless if channel designations are all unknown and channel names are not used, lossy otherwise. Custom -> Ambisonic : Possible if it contains ambisonic channels with optional non-diegetic channels in the end. Lossy if the channels have custom names, lossless otherwise. Custom -> Native : Possible if it contains native channels in native order. Lossy if the channels have custom names, lossless otherwise.
On error this function keeps the original channel layout untouched.
channel_layout | channel layout which will be changed |
order | the desired channel layout order |
flags | a combination of AV_CHANNEL_LAYOUT_RETYPE_FLAG_* constants |