40#define CHAN_IS_AMBI(x) ((x) >= AV_CHAN_AMBISONIC_BASE &&\
41 (x) <= AV_CHAN_AMBISONIC_END)
109 if (!buf && buf_size)
115 if (bp.len >= INT_MAX)
142 if (!buf && buf_size)
148 if (bp.len >= INT_MAX)
156 char *endptr = (
char *)str;
159 if (!strncmp(str,
"AMBI", 4)) {
160 i = strtol(str + 4,
NULL, 0);
170 if (!strcmp(str,
"UNK"))
172 if (!strcmp(str,
"UNSD"))
175 if (!strncmp(str,
"USR", 3)) {
176 const char *p = str + 3;
177 id = strtol(p, &endptr, 0);
179 if (
id >= 0 && !*endptr)
237 if (nb_channels <= 0)
243 for (
int i = 0;
i < nb_channels;
i++)
331 memset(channel_layout, 0,
sizeof(*channel_layout));
334 if (!strncmp(str,
"ambisonic ", 10)) {
335 const char *p = str + 10;
340 order = strtol(p, &endptr, 0);
341 if (order < 0 || order + 1 > INT_MAX / (order + 1) ||
342 (*endptr && *endptr !=
'+'))
346 channel_layout->
nb_channels = (order + 1) * (order + 1);
361 channel_layout->
u.
map =
363 sizeof(*channel_layout->
u.
map));
364 if (!channel_layout->
u.
map) {
398 matches =
av_sscanf(str,
"%d channels (%[^)]", &nb_channels, chlist);
401 if (ret < 0 && ret !=
AVERROR(EINVAL))
405 const char *end_par = strchr(str,
')');
406 if (matches == 2 && (nb_channels != channel_layout->
nb_channels || !end_par || *++end_par)) {
414 mask = strtoull(str, &end, 0);
417 if (!errno && !*end && !strchr(str,
'-') &&
mask) {
426 if (!errno && !strcmp(end,
"c") &&
channels > 0) {
433 if (!errno && (!strcmp(end,
"C") || !strcmp(end,
" channels"))
447 memset(channel_layout, 0,
sizeof(*channel_layout));
458 memcpy(
dst->u.map,
src->u.map,
src->nb_channels *
sizeof(*
src->u.map));
466 for (
int i = start_channel;
i < channel_layout->
nb_channels;
i++) {
468 if (ch >= 0 && ch < 63 &&
mask < (1ULL << ch))
469 mask |= (1ULL << ch);
488 int i, highest_ambi, order;
517 if (highest_ambi < 0)
520 order =
floor(sqrt(highest_ambi));
522 if ((order + 1) * (order + 1) != highest_ambi + 1)
530 int has_known_channel = 0;
534 return channel_layout->
order;
539 for (
int i = 0;
i < channel_layout->
nb_channels && !has_known_channel;
i++)
541 has_known_channel = 1;
542 if (!has_known_channel)
562 int nb_ambi_channels;
570 nb_ambi_channels = (order + 1) * (order + 1);
571 if (nb_ambi_channels < channel_layout->nb_channels) {
588 extra.
u.
map = channel_layout->
u.
map + nb_ambi_channels;
605 switch (channel_layout->
order) {
655 char *buf,
size_t buf_size)
660 if (!buf && buf_size)
668 if (bp.len >= INT_MAX)
682 switch (channel_layout->
order) {
684 return channel_layout->
u.
map[idx].
id;
687 if (idx < ambi_channels)
689 idx -= ambi_channels;
693 for (
i = 0;
i < 64;
i++) {
694 if ((1ULL <<
i) & channel_layout->
u.
mask && !idx--)
723 switch (channel_layout->
order) {
755 switch (channel_layout->
order) {
757 chname = strstr(str,
"@");
769 if (!strcmp(chname, channel_layout->
u.
map[
i].
name) &&
790 switch (channel_layout->
order) {
794 if (!channel_layout->
u.
map)
856 uintptr_t
i = (uintptr_t)*opaque;
861 *opaque = (
void*)(
i + 1);
873 switch (channel_layout->
order) {
878 for (
i = 0;
i < 64;
i++)
898 if (channel_layout->
order == order)
906 for (
int i = 0;
i < nb_channels;
i++) {
915 if (!lossy || allow_lossy) {
916 void *opaque = channel_layout->
opaque;
920 channel_layout->
opaque = opaque;
931 if (!lossy || allow_lossy) {
932 void *opaque = channel_layout->
opaque;
935 channel_layout->
opaque = opaque;
943 void *opaque = channel_layout->
opaque;
950 *channel_layout = custom;
951 channel_layout->
opaque = opaque;
965 if (!lossy || allow_lossy) {
966 void *opaque = channel_layout->
opaque;
971 channel_layout->
opaque = opaque;
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int av_sscanf(const char *string, const char *format,...)
void av_bprintf(AVBPrint *buf, const char *fmt,...)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int64_t masked_description(const AVChannelLayout *channel_layout, int start_channel)
static const struct channel_layout_name channel_layout_map[]
static const struct channel_name channel_names[]
static int has_channel_names(const AVChannelLayout *channel_layout)
static int try_describe_ambisonic(AVBPrint *bp, const AVChannelLayout *channel_layout)
If the custom layout is n-th order standard-order ambisonic, with optional extra non-diegetic channel...
static enum AVChannelOrder canonical_order(AVChannelLayout *channel_layout)
static int parse_channel_list(AVChannelLayout *ch_layout, const char *str)
Public libavutil channel layout APIs header.
common internal and external API header
static __device__ float floor(float a)
channel
Use these values when setting the channel map with ebur128_set_channel().
#define AV_CHANNEL_LAYOUT_4POINT0
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
enum AVChannel av_channel_layout_channel_from_string(const AVChannelLayout *channel_layout, const char *str)
Get a channel described by the given string.
#define AV_CHANNEL_LAYOUT_HEXADECAGONAL
#define AV_CHANNEL_LAYOUT_7POINT2POINT3
#define AV_CHANNEL_LAYOUT_5POINT1POINT2
#define AV_CHANNEL_LAYOUT_HEXAGONAL
int av_channel_layout_from_string(AVChannelLayout *channel_layout, const char *str)
Initialize a channel layout from a given string description.
#define AV_CHANNEL_LAYOUT_4POINT1
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.
#define AV_CHANNEL_LAYOUT_3POINT1
#define AV_CHANNEL_LAYOUT_BINAURAL
int av_channel_layout_index_from_string(const AVChannelLayout *channel_layout, const char *str)
Get the index in a channel layout of a channel described by the given string.
#define AV_CHANNEL_LAYOUT_7POINT0_FRONT
#define AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK
int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrder order, int flags)
Change the AVChannelOrder of a channel layout.
int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout, AVBPrint *bp)
bprint variant of av_channel_layout_describe().
#define AV_CHANNEL_LAYOUT_5POINT1_BACK
#define AV_CHANNEL_LAYOUT_7POINT1_WIDE
#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL
The specified retype target order is ignored and the simplest possible (canonical) order is used for ...
#define AV_CHANNEL_LAYOUT_7POINT1POINT2
#define AV_CHANNEL_LAYOUT_6POINT1_FRONT
#define AV_CHANNEL_LAYOUT_5POINT0
#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_LOSSLESS
The conversion must be lossless.
void av_channel_description_bprint(AVBPrint *bp, enum AVChannel channel_id)
bprint variant of av_channel_description().
#define AV_CHANNEL_LAYOUT_CUBE
int av_channel_layout_ambisonic_order(const AVChannelLayout *channel_layout)
Return the order if the layout is n-th order standard-order ambisonic.
#define AV_CHANNEL_LAYOUT_STEREO
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_name(char *buf, size_t buf_size, enum AVChannel channel_id)
Get a human readable string in an abbreviated form describing a given channel.
#define AV_CHANNEL_LAYOUT_6POINT0
#define AV_CHANNEL_LAYOUT_2_2
int av_channel_description(char *buf, size_t buf_size, enum AVChannel channel_id)
Get a human readable string describing a given channel.
#define AV_CHANNEL_LAYOUT_6POINT1_BACK
#define AV_CHANNEL_LAYOUT_5POINT0_BACK
#define AV_CHANNEL_LAYOUT_5POINT1
#define AV_CHANNEL_LAYOUT_MONO
int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels)
Initialize a custom channel layout with the specified number of channels.
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.
#define AV_CHANNEL_LAYOUT_7POINT0
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
#define AV_CHANNEL_LAYOUT_5POINT1POINT4_BACK
#define AV_CHANNEL_LAYOUT_SURROUND
#define AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK
#define AV_CHANNEL_LAYOUT_2_1
#define AV_CHANNEL_LAYOUT_OCTAGONAL
void av_channel_name_bprint(AVBPrint *bp, enum AVChannel channel_id)
bprint variant of av_channel_name().
#define AV_CHANNEL_LAYOUT_22POINT2
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_describe(const AVChannelLayout *channel_layout, char *buf, size_t buf_size)
Get a human-readable string describing the channel layout properties.
#define AV_CHANNEL_LAYOUT_7POINT1
int av_channel_layout_check(const AVChannelLayout *channel_layout)
Check whether a channel layout is valid, i.e.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
#define AV_CHANNEL_LAYOUT_7POINT1POINT4_BACK
#define AV_CHANNEL_LAYOUT_STEREO_DOWNMIX
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 pos...
#define AV_CHANNEL_LAYOUT_9POINT1POINT6
const AVChannelLayout * av_channel_layout_standard(void **opaque)
Iterate over all standard channel layouts.
#define AV_CHANNEL_LAYOUT_QUAD
#define AV_CHANNEL_LAYOUT_6POINT0_FRONT
#define AV_CHANNEL_LAYOUT_3POINT1POINT2
#define AV_CHANNEL_LAYOUT_2POINT1
enum AVChannel av_channel_from_string(const char *str)
This is the inverse function of av_channel_name().
#define AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK
#define AV_CHANNEL_LAYOUT_6POINT1
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
@ AV_CHANNEL_ORDER_CUSTOM
The channel order does not correspond to any other predefined order and is stored as an explicit map.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
@ AV_CHANNEL_ORDER_AMBISONIC
The audio is represented as the decomposition of the sound field into spherical harmonics.
@ AV_CHAN_UNUSED
Channel is empty can be safely skipped.
@ AV_CHAN_TOP_SURROUND_RIGHT
-110 degrees, Rvs, TpRS
@ AV_CHAN_FRONT_RIGHT_OF_CENTER
@ AV_CHAN_SIDE_SURROUND_RIGHT
-90 degrees, Rss, SiR
@ AV_CHAN_TOP_FRONT_RIGHT
@ AV_CHAN_AMBISONIC_BASE
Range of channels between AV_CHAN_AMBISONIC_BASE and AV_CHAN_AMBISONIC_END represent Ambisonic compon...
@ AV_CHAN_TOP_SURROUND_LEFT
+110 degrees, Lvs, TpLS
@ AV_CHAN_SIDE_SURROUND_LEFT
+90 degrees, Lss, SiL
@ AV_CHAN_FRONT_LEFT_OF_CENTER
@ AV_CHAN_NONE
Invalid channel index.
@ AV_CHAN_LOW_FREQUENCY_2
@ AV_CHAN_TOP_BACK_CENTER
@ AV_CHAN_UNKNOWN
Channel contains data, but its position is unknown.
@ AV_CHAN_SURROUND_DIRECT_RIGHT
@ AV_CHAN_BOTTOM_FRONT_CENTER
@ AV_CHAN_BOTTOM_FRONT_RIGHT
@ AV_CHAN_STEREO_RIGHT
See above.
@ AV_CHAN_BOTTOM_FRONT_LEFT
@ AV_CHAN_SURROUND_DIRECT_LEFT
@ AV_CHAN_STEREO_LEFT
Stereo downmix.
@ AV_CHAN_TOP_FRONT_CENTER
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size)
Init a print buffer using a pre-existing buffer.
void * av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size, const uint8_t *elem_data)
Add an element of size elem_size to a dynamic array.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int av_opt_get_key_value(const char **ropts, const char *key_val_sep, const char *pairs_sep, unsigned flags, char **rkey, char **rval)
Extract a key-value pair from the beginning of a string.
@ AV_OPT_FLAG_IMPLICIT_KEY
Accept to parse a value without a key; the key will then be returned as NULL.
const VDPAUPixFmtMap * map
Macro definitions for various function/variable attributes.
static const uint16_t mask[17]
Utility Preprocessor macros.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
#define FF_ARRAY_ELEMS(a)
An AVChannelCustom defines a single channel within a custom order layout.
An AVChannelLayout holds information about the channel layout of audio data.
enum AVChannelOrder order
Channel order used in this layout.
uint64_t mask
This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC ...
union AVChannelLayout::@162063043056170047076125117143030261346263330336 u
Details about which channels are present in this layout.
int nb_channels
Number of channels in this layout.
void * opaque
For some private data of the user.
AVChannelCustom * map
This member must be used when the channel order is AV_CHANNEL_ORDER_CUSTOM.
#define av_malloc_array(a, b)