Path: blob/a-new-beginning/libavutil.xcframework/ios-arm64/libavutil.framework/Headers/channel_layout.h
2 views
/*1* Copyright (c) 2006 Michael Niedermayer <[email protected]>2* Copyright (c) 2008 Peter Ross3*4* This file is part of FFmpeg.5*6* FFmpeg is free software; you can redistribute it and/or7* modify it under the terms of the GNU Lesser General Public8* License as published by the Free Software Foundation; either9* version 2.1 of the License, or (at your option) any later version.10*11* FFmpeg is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU14* Lesser General Public License for more details.15*16* You should have received a copy of the GNU Lesser General Public17* License along with FFmpeg; if not, write to the Free Software18* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA19*/2021#ifndef AVUTIL_CHANNEL_LAYOUT_H22#define AVUTIL_CHANNEL_LAYOUT_H2324#include <stdint.h>25#include <stdlib.h>2627#include "version.h"28#include "attributes.h"2930/**31* @file32* @ingroup lavu_audio_channels33* Public libavutil channel layout APIs header.34*/353637/**38* @defgroup lavu_audio_channels Audio channels39* @ingroup lavu_audio40*41* Audio channel layout utility functions42*43* @{44*/4546enum AVChannel {47///< Invalid channel index48AV_CHAN_NONE = -1,49AV_CHAN_FRONT_LEFT,50AV_CHAN_FRONT_RIGHT,51AV_CHAN_FRONT_CENTER,52AV_CHAN_LOW_FREQUENCY,53AV_CHAN_BACK_LEFT,54AV_CHAN_BACK_RIGHT,55AV_CHAN_FRONT_LEFT_OF_CENTER,56AV_CHAN_FRONT_RIGHT_OF_CENTER,57AV_CHAN_BACK_CENTER,58AV_CHAN_SIDE_LEFT,59AV_CHAN_SIDE_RIGHT,60AV_CHAN_TOP_CENTER,61AV_CHAN_TOP_FRONT_LEFT,62AV_CHAN_TOP_FRONT_CENTER,63AV_CHAN_TOP_FRONT_RIGHT,64AV_CHAN_TOP_BACK_LEFT,65AV_CHAN_TOP_BACK_CENTER,66AV_CHAN_TOP_BACK_RIGHT,67/** Stereo downmix. */68AV_CHAN_STEREO_LEFT = 29,69/** See above. */70AV_CHAN_STEREO_RIGHT,71AV_CHAN_WIDE_LEFT,72AV_CHAN_WIDE_RIGHT,73AV_CHAN_SURROUND_DIRECT_LEFT,74AV_CHAN_SURROUND_DIRECT_RIGHT,75AV_CHAN_LOW_FREQUENCY_2,76AV_CHAN_TOP_SIDE_LEFT,77AV_CHAN_TOP_SIDE_RIGHT,78AV_CHAN_BOTTOM_FRONT_CENTER,79AV_CHAN_BOTTOM_FRONT_LEFT,80AV_CHAN_BOTTOM_FRONT_RIGHT,8182/** Channel is empty can be safely skipped. */83AV_CHAN_UNUSED = 0x200,8485/** Channel contains data, but its position is unknown. */86AV_CHAN_UNKNOWN = 0x300,8788/**89* Range of channels between AV_CHAN_AMBISONIC_BASE and90* AV_CHAN_AMBISONIC_END represent Ambisonic components using the ACN system.91*92* Given a channel id `<i>` between AV_CHAN_AMBISONIC_BASE and93* AV_CHAN_AMBISONIC_END (inclusive), the ACN index of the channel `<n>` is94* `<n> = <i> - AV_CHAN_AMBISONIC_BASE`.95*96* @note these values are only used for AV_CHANNEL_ORDER_CUSTOM channel97* orderings, the AV_CHANNEL_ORDER_AMBISONIC ordering orders the channels98* implicitly by their position in the stream.99*/100AV_CHAN_AMBISONIC_BASE = 0x400,101// leave space for 1024 ids, which correspond to maximum order-32 harmonics,102// which should be enough for the foreseeable use cases103AV_CHAN_AMBISONIC_END = 0x7ff,104};105106enum AVChannelOrder {107/**108* Only the channel count is specified, without any further information109* about the channel order.110*/111AV_CHANNEL_ORDER_UNSPEC,112/**113* The native channel order, i.e. the channels are in the same order in114* which they are defined in the AVChannel enum. This supports up to 63115* different channels.116*/117AV_CHANNEL_ORDER_NATIVE,118/**119* The channel order does not correspond to any other predefined order and120* is stored as an explicit map. For example, this could be used to support121* layouts with 64 or more channels, or with empty/skipped (AV_CHAN_SILENCE)122* channels at arbitrary positions.123*/124AV_CHANNEL_ORDER_CUSTOM,125/**126* The audio is represented as the decomposition of the sound field into127* spherical harmonics. Each channel corresponds to a single expansion128* component. Channels are ordered according to ACN (Ambisonic Channel129* Number).130*131* The channel with the index n in the stream contains the spherical132* harmonic of degree l and order m given by133* @code{.unparsed}134* l = floor(sqrt(n)),135* m = n - l * (l + 1).136* @endcode137*138* Conversely given a spherical harmonic of degree l and order m, the139* corresponding channel index n is given by140* @code{.unparsed}141* n = l * (l + 1) + m.142* @endcode143*144* Normalization is assumed to be SN3D (Schmidt Semi-Normalization)145* as defined in AmbiX format $ 2.1.146*/147AV_CHANNEL_ORDER_AMBISONIC,148};149150151/**152* @defgroup channel_masks Audio channel masks153*154* A channel layout is a 64-bits integer with a bit set for every channel.155* The number of bits set must be equal to the number of channels.156* The value 0 means that the channel layout is not known.157* @note this data structure is not powerful enough to handle channels158* combinations that have the same channel multiple times, such as159* dual-mono.160*161* @{162*/163#define AV_CH_FRONT_LEFT (1ULL << AV_CHAN_FRONT_LEFT )164#define AV_CH_FRONT_RIGHT (1ULL << AV_CHAN_FRONT_RIGHT )165#define AV_CH_FRONT_CENTER (1ULL << AV_CHAN_FRONT_CENTER )166#define AV_CH_LOW_FREQUENCY (1ULL << AV_CHAN_LOW_FREQUENCY )167#define AV_CH_BACK_LEFT (1ULL << AV_CHAN_BACK_LEFT )168#define AV_CH_BACK_RIGHT (1ULL << AV_CHAN_BACK_RIGHT )169#define AV_CH_FRONT_LEFT_OF_CENTER (1ULL << AV_CHAN_FRONT_LEFT_OF_CENTER )170#define AV_CH_FRONT_RIGHT_OF_CENTER (1ULL << AV_CHAN_FRONT_RIGHT_OF_CENTER)171#define AV_CH_BACK_CENTER (1ULL << AV_CHAN_BACK_CENTER )172#define AV_CH_SIDE_LEFT (1ULL << AV_CHAN_SIDE_LEFT )173#define AV_CH_SIDE_RIGHT (1ULL << AV_CHAN_SIDE_RIGHT )174#define AV_CH_TOP_CENTER (1ULL << AV_CHAN_TOP_CENTER )175#define AV_CH_TOP_FRONT_LEFT (1ULL << AV_CHAN_TOP_FRONT_LEFT )176#define AV_CH_TOP_FRONT_CENTER (1ULL << AV_CHAN_TOP_FRONT_CENTER )177#define AV_CH_TOP_FRONT_RIGHT (1ULL << AV_CHAN_TOP_FRONT_RIGHT )178#define AV_CH_TOP_BACK_LEFT (1ULL << AV_CHAN_TOP_BACK_LEFT )179#define AV_CH_TOP_BACK_CENTER (1ULL << AV_CHAN_TOP_BACK_CENTER )180#define AV_CH_TOP_BACK_RIGHT (1ULL << AV_CHAN_TOP_BACK_RIGHT )181#define AV_CH_STEREO_LEFT (1ULL << AV_CHAN_STEREO_LEFT )182#define AV_CH_STEREO_RIGHT (1ULL << AV_CHAN_STEREO_RIGHT )183#define AV_CH_WIDE_LEFT (1ULL << AV_CHAN_WIDE_LEFT )184#define AV_CH_WIDE_RIGHT (1ULL << AV_CHAN_WIDE_RIGHT )185#define AV_CH_SURROUND_DIRECT_LEFT (1ULL << AV_CHAN_SURROUND_DIRECT_LEFT )186#define AV_CH_SURROUND_DIRECT_RIGHT (1ULL << AV_CHAN_SURROUND_DIRECT_RIGHT)187#define AV_CH_LOW_FREQUENCY_2 (1ULL << AV_CHAN_LOW_FREQUENCY_2 )188#define AV_CH_TOP_SIDE_LEFT (1ULL << AV_CHAN_TOP_SIDE_LEFT )189#define AV_CH_TOP_SIDE_RIGHT (1ULL << AV_CHAN_TOP_SIDE_RIGHT )190#define AV_CH_BOTTOM_FRONT_CENTER (1ULL << AV_CHAN_BOTTOM_FRONT_CENTER )191#define AV_CH_BOTTOM_FRONT_LEFT (1ULL << AV_CHAN_BOTTOM_FRONT_LEFT )192#define AV_CH_BOTTOM_FRONT_RIGHT (1ULL << AV_CHAN_BOTTOM_FRONT_RIGHT )193194#if FF_API_OLD_CHANNEL_LAYOUT195/** Channel mask value used for AVCodecContext.request_channel_layout196to indicate that the user requests the channel order of the decoder output197to be the native codec channel order.198@deprecated channel order is now indicated in a special field in199AVChannelLayout200*/201#define AV_CH_LAYOUT_NATIVE 0x8000000000000000ULL202#endif203204/**205* @}206* @defgroup channel_mask_c Audio channel layouts207* @{208* */209#define AV_CH_LAYOUT_MONO (AV_CH_FRONT_CENTER)210#define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT)211#define AV_CH_LAYOUT_2POINT1 (AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY)212#define AV_CH_LAYOUT_2_1 (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER)213#define AV_CH_LAYOUT_SURROUND (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER)214#define AV_CH_LAYOUT_3POINT1 (AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY)215#define AV_CH_LAYOUT_4POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER)216#define AV_CH_LAYOUT_4POINT1 (AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY)217#define AV_CH_LAYOUT_2_2 (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)218#define AV_CH_LAYOUT_QUAD (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)219#define AV_CH_LAYOUT_5POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)220#define AV_CH_LAYOUT_5POINT1 (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY)221#define AV_CH_LAYOUT_5POINT0_BACK (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)222#define AV_CH_LAYOUT_5POINT1_BACK (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY)223#define AV_CH_LAYOUT_6POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_CENTER)224#define AV_CH_LAYOUT_6POINT0_FRONT (AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)225#define AV_CH_LAYOUT_HEXAGONAL (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_BACK_CENTER)226#define AV_CH_LAYOUT_6POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER)227#define AV_CH_LAYOUT_6POINT1_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_BACK_CENTER)228#define AV_CH_LAYOUT_6POINT1_FRONT (AV_CH_LAYOUT_6POINT0_FRONT|AV_CH_LOW_FREQUENCY)229#define AV_CH_LAYOUT_7POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)230#define AV_CH_LAYOUT_7POINT0_FRONT (AV_CH_LAYOUT_5POINT0|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)231#define AV_CH_LAYOUT_7POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)232#define AV_CH_LAYOUT_7POINT1_WIDE (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)233#define AV_CH_LAYOUT_7POINT1_WIDE_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)234#define AV_CH_LAYOUT_7POINT1_TOP_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT)235#define AV_CH_LAYOUT_OCTAGONAL (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)236#define AV_CH_LAYOUT_CUBE (AV_CH_LAYOUT_QUAD|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT)237#define AV_CH_LAYOUT_HEXADECAGONAL (AV_CH_LAYOUT_OCTAGONAL|AV_CH_WIDE_LEFT|AV_CH_WIDE_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT)238#define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)239#define AV_CH_LAYOUT_22POINT2 (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_LOW_FREQUENCY_2|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_CENTER|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_BOTTOM_FRONT_CENTER|AV_CH_BOTTOM_FRONT_LEFT|AV_CH_BOTTOM_FRONT_RIGHT)240241enum AVMatrixEncoding {242AV_MATRIX_ENCODING_NONE,243AV_MATRIX_ENCODING_DOLBY,244AV_MATRIX_ENCODING_DPLII,245AV_MATRIX_ENCODING_DPLIIX,246AV_MATRIX_ENCODING_DPLIIZ,247AV_MATRIX_ENCODING_DOLBYEX,248AV_MATRIX_ENCODING_DOLBYHEADPHONE,249AV_MATRIX_ENCODING_NB250};251252/**253* @}254*/255256/**257* An AVChannelCustom defines a single channel within a custom order layout258*259* Unlike most structures in FFmpeg, sizeof(AVChannelCustom) is a part of the260* public ABI.261*262* No new fields may be added to it without a major version bump.263*/264typedef struct AVChannelCustom {265enum AVChannel id;266char name[16];267void *opaque;268} AVChannelCustom;269270/**271* An AVChannelLayout holds information about the channel layout of audio data.272*273* A channel layout here is defined as a set of channels ordered in a specific274* way (unless the channel order is AV_CHANNEL_ORDER_UNSPEC, in which case an275* AVChannelLayout carries only the channel count).276* All orders may be treated as if they were AV_CHANNEL_ORDER_UNSPEC by277* ignoring everything but the channel count, as long as av_channel_layout_check()278* considers they are valid.279*280* Unlike most structures in FFmpeg, sizeof(AVChannelLayout) is a part of the281* public ABI and may be used by the caller. E.g. it may be allocated on stack282* or embedded in caller-defined structs.283*284* AVChannelLayout can be initialized as follows:285* - default initialization with {0}, followed by setting all used fields286* correctly;287* - by assigning one of the predefined AV_CHANNEL_LAYOUT_* initializers;288* - with a constructor function, such as av_channel_layout_default(),289* av_channel_layout_from_mask() or av_channel_layout_from_string().290*291* The channel layout must be unitialized with av_channel_layout_uninit()292*293* Copying an AVChannelLayout via assigning is forbidden,294* av_channel_layout_copy() must be used instead (and its return value should295* be checked)296*297* No new fields may be added to it without a major version bump, except for298* new elements of the union fitting in sizeof(uint64_t).299*/300typedef struct AVChannelLayout {301/**302* Channel order used in this layout.303* This is a mandatory field.304*/305enum AVChannelOrder order;306307/**308* Number of channels in this layout. Mandatory field.309*/310int nb_channels;311312/**313* Details about which channels are present in this layout.314* For AV_CHANNEL_ORDER_UNSPEC, this field is undefined and must not be315* used.316*/317union {318/**319* This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used320* for AV_CHANNEL_ORDER_AMBISONIC to signal non-diegetic channels.321* It is a bitmask, where the position of each set bit means that the322* AVChannel with the corresponding value is present.323*324* I.e. when (mask & (1 << AV_CHAN_FOO)) is non-zero, then AV_CHAN_FOO325* is present in the layout. Otherwise it is not present.326*327* @note when a channel layout using a bitmask is constructed or328* modified manually (i.e. not using any of the av_channel_layout_*329* functions), the code doing it must ensure that the number of set bits330* is equal to nb_channels.331*/332uint64_t mask;333/**334* This member must be used when the channel order is335* AV_CHANNEL_ORDER_CUSTOM. It is a nb_channels-sized array, with each336* element signalling the presence of the AVChannel with the337* corresponding value in map[i].id.338*339* I.e. when map[i].id is equal to AV_CHAN_FOO, then AV_CH_FOO is the340* i-th channel in the audio data.341*342* When map[i].id is in the range between AV_CHAN_AMBISONIC_BASE and343* AV_CHAN_AMBISONIC_END (inclusive), the channel contains an ambisonic344* component with ACN index (as defined above)345* n = map[i].id - AV_CHAN_AMBISONIC_BASE.346*347* map[i].name may be filled with a 0-terminated string, in which case348* it will be used for the purpose of identifying the channel with the349* convenience functions below. Otherise it must be zeroed.350*/351AVChannelCustom *map;352} u;353354/**355* For some private data of the user.356*/357void *opaque;358} AVChannelLayout;359360#define AV_CHANNEL_LAYOUT_MASK(nb, m) \361{ .order = AV_CHANNEL_ORDER_NATIVE, .nb_channels = (nb), .u = { .mask = (m) }}362363/**364* @name Common pre-defined channel layouts365* @{366*/367#define AV_CHANNEL_LAYOUT_MONO AV_CHANNEL_LAYOUT_MASK(1, AV_CH_LAYOUT_MONO)368#define AV_CHANNEL_LAYOUT_STEREO AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_STEREO)369#define AV_CHANNEL_LAYOUT_2POINT1 AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_2POINT1)370#define AV_CHANNEL_LAYOUT_2_1 AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_2_1)371#define AV_CHANNEL_LAYOUT_SURROUND AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_SURROUND)372#define AV_CHANNEL_LAYOUT_3POINT1 AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_3POINT1)373#define AV_CHANNEL_LAYOUT_4POINT0 AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_4POINT0)374#define AV_CHANNEL_LAYOUT_4POINT1 AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_4POINT1)375#define AV_CHANNEL_LAYOUT_2_2 AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_2_2)376#define AV_CHANNEL_LAYOUT_QUAD AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_QUAD)377#define AV_CHANNEL_LAYOUT_5POINT0 AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_5POINT0)378#define AV_CHANNEL_LAYOUT_5POINT1 AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_5POINT1)379#define AV_CHANNEL_LAYOUT_5POINT0_BACK AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_5POINT0_BACK)380#define AV_CHANNEL_LAYOUT_5POINT1_BACK AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_5POINT1_BACK)381#define AV_CHANNEL_LAYOUT_6POINT0 AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_6POINT0)382#define AV_CHANNEL_LAYOUT_6POINT0_FRONT AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_6POINT0_FRONT)383#define AV_CHANNEL_LAYOUT_HEXAGONAL AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_HEXAGONAL)384#define AV_CHANNEL_LAYOUT_6POINT1 AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1)385#define AV_CHANNEL_LAYOUT_6POINT1_BACK AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1_BACK)386#define AV_CHANNEL_LAYOUT_6POINT1_FRONT AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1_FRONT)387#define AV_CHANNEL_LAYOUT_7POINT0 AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_7POINT0)388#define AV_CHANNEL_LAYOUT_7POINT0_FRONT AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_7POINT0_FRONT)389#define AV_CHANNEL_LAYOUT_7POINT1 AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1)390#define AV_CHANNEL_LAYOUT_7POINT1_WIDE AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1_WIDE)391#define AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1_WIDE_BACK)392#define AV_CHANNEL_LAYOUT_7POINT1_TOP_BACK AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1_TOP_BACK)393#define AV_CHANNEL_LAYOUT_OCTAGONAL AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_OCTAGONAL)394#define AV_CHANNEL_LAYOUT_CUBE AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_CUBE)395#define AV_CHANNEL_LAYOUT_HEXADECAGONAL AV_CHANNEL_LAYOUT_MASK(16, AV_CH_LAYOUT_HEXADECAGONAL)396#define AV_CHANNEL_LAYOUT_STEREO_DOWNMIX AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_STEREO_DOWNMIX)397#define AV_CHANNEL_LAYOUT_22POINT2 AV_CHANNEL_LAYOUT_MASK(24, AV_CH_LAYOUT_22POINT2)398#define AV_CHANNEL_LAYOUT_AMBISONIC_FIRST_ORDER \399{ .order = AV_CHANNEL_ORDER_AMBISONIC, .nb_channels = 4, .u = { .mask = 0 }}400/** @} */401402struct AVBPrint;403404#if FF_API_OLD_CHANNEL_LAYOUT405/**406* @name Deprecated Functions407* @{408*/409410/**411* Return a channel layout id that matches name, or 0 if no match is found.412*413* name can be one or several of the following notations,414* separated by '+' or '|':415* - the name of an usual channel layout (mono, stereo, 4.0, quad, 5.0,416* 5.0(side), 5.1, 5.1(side), 7.1, 7.1(wide), downmix);417* - the name of a single channel (FL, FR, FC, LFE, BL, BR, FLC, FRC, BC,418* SL, SR, TC, TFL, TFC, TFR, TBL, TBC, TBR, DL, DR);419* - a number of channels, in decimal, followed by 'c', yielding420* the default channel layout for that number of channels (@see421* av_get_default_channel_layout);422* - a channel layout mask, in hexadecimal starting with "0x" (see the423* AV_CH_* macros).424*425* Example: "stereo+FC" = "2c+FC" = "2c+1c" = "0x7"426*427* @deprecated use av_channel_layout_from_string()428*/429attribute_deprecated430uint64_t av_get_channel_layout(const char *name);431432/**433* Return a channel layout and the number of channels based on the specified name.434*435* This function is similar to (@see av_get_channel_layout), but can also parse436* unknown channel layout specifications.437*438* @param[in] name channel layout specification string439* @param[out] channel_layout parsed channel layout (0 if unknown)440* @param[out] nb_channels number of channels441*442* @return 0 on success, AVERROR(EINVAL) if the parsing fails.443* @deprecated use av_channel_layout_from_string()444*/445attribute_deprecated446int av_get_extended_channel_layout(const char *name, uint64_t* channel_layout, int* nb_channels);447448/**449* Return a description of a channel layout.450* If nb_channels is <= 0, it is guessed from the channel_layout.451*452* @param buf put here the string containing the channel layout453* @param buf_size size in bytes of the buffer454* @param nb_channels number of channels455* @param channel_layout channel layout bitset456* @deprecated use av_channel_layout_describe()457*/458attribute_deprecated459void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout);460461/**462* Append a description of a channel layout to a bprint buffer.463* @deprecated use av_channel_layout_describe()464*/465attribute_deprecated466void av_bprint_channel_layout(struct AVBPrint *bp, int nb_channels, uint64_t channel_layout);467468/**469* Return the number of channels in the channel layout.470* @deprecated use AVChannelLayout.nb_channels471*/472attribute_deprecated473int av_get_channel_layout_nb_channels(uint64_t channel_layout);474475/**476* Return default channel layout for a given number of channels.477*478* @deprecated use av_channel_layout_default()479*/480attribute_deprecated481int64_t av_get_default_channel_layout(int nb_channels);482483/**484* Get the index of a channel in channel_layout.485*486* @param channel_layout channel layout bitset487* @param channel a channel layout describing exactly one channel which must be488* present in channel_layout.489*490* @return index of channel in channel_layout on success, a negative AVERROR491* on error.492*493* @deprecated use av_channel_layout_index_from_channel()494*/495attribute_deprecated496int av_get_channel_layout_channel_index(uint64_t channel_layout,497uint64_t channel);498499/**500* Get the channel with the given index in channel_layout.501* @deprecated use av_channel_layout_channel_from_index()502*/503attribute_deprecated504uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index);505506/**507* Get the name of a given channel.508*509* @return channel name on success, NULL on error.510*511* @deprecated use av_channel_name()512*/513attribute_deprecated514const char *av_get_channel_name(uint64_t channel);515516/**517* Get the description of a given channel.518*519* @param channel a channel layout with a single channel520* @return channel description on success, NULL on error521* @deprecated use av_channel_description()522*/523attribute_deprecated524const char *av_get_channel_description(uint64_t channel);525526/**527* Get the value and name of a standard channel layout.528*529* @param[in] index index in an internal list, starting at 0530* @param[out] layout channel layout mask531* @param[out] name name of the layout532* @return 0 if the layout exists,533* <0 if index is beyond the limits534* @deprecated use av_channel_layout_standard()535*/536attribute_deprecated537int av_get_standard_channel_layout(unsigned index, uint64_t *layout,538const char **name);539/**540* @}541*/542#endif543544/**545* Get a human readable string in an abbreviated form describing a given channel.546* This is the inverse function of @ref av_channel_from_string().547*548* @param buf pre-allocated buffer where to put the generated string549* @param buf_size size in bytes of the buffer.550* @param channel the AVChannel whose name to get551* @return amount of bytes needed to hold the output string, or a negative AVERROR552* on failure. If the returned value is bigger than buf_size, then the553* string was truncated.554*/555int av_channel_name(char *buf, size_t buf_size, enum AVChannel channel);556557/**558* bprint variant of av_channel_name().559*560* @note the string will be appended to the bprint buffer.561*/562void av_channel_name_bprint(struct AVBPrint *bp, enum AVChannel channel_id);563564/**565* Get a human readable string describing a given channel.566*567* @param buf pre-allocated buffer where to put the generated string568* @param buf_size size in bytes of the buffer.569* @param channel the AVChannel whose description to get570* @return amount of bytes needed to hold the output string, or a negative AVERROR571* on failure. If the returned value is bigger than buf_size, then the572* string was truncated.573*/574int av_channel_description(char *buf, size_t buf_size, enum AVChannel channel);575576/**577* bprint variant of av_channel_description().578*579* @note the string will be appended to the bprint buffer.580*/581void av_channel_description_bprint(struct AVBPrint *bp, enum AVChannel channel_id);582583/**584* This is the inverse function of @ref av_channel_name().585*586* @return the channel with the given name587* AV_CHAN_NONE when name does not identify a known channel588*/589enum AVChannel av_channel_from_string(const char *name);590591/**592* Initialize a native channel layout from a bitmask indicating which channels593* are present.594*595* @param channel_layout the layout structure to be initialized596* @param mask bitmask describing the channel layout597*598* @return 0 on success599* AVERROR(EINVAL) for invalid mask values600*/601int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask);602603/**604* Initialize a channel layout from a given string description.605* The input string can be represented by:606* - the formal channel layout name (returned by av_channel_layout_describe())607* - single or multiple channel names (returned by av_channel_name(), eg. "FL",608* or concatenated with "+", each optionally containing a custom name after609* a "@", eg. "FL@Left+FR@Right+LFE")610* - a decimal or hexadecimal value of a native channel layout (eg. "4" or "0x4")611* - the number of channels with default layout (eg. "4c")612* - the number of unordered channels (eg. "4C" or "4 channels")613* - the ambisonic order followed by optional non-diegetic channels (eg.614* "ambisonic 2+stereo")615*616* @param channel_layout input channel layout617* @param str string describing the channel layout618* @return 0 channel layout was detected, AVERROR_INVALIDATATA otherwise619*/620int av_channel_layout_from_string(AVChannelLayout *channel_layout,621const char *str);622623/**624* Get the default channel layout for a given number of channels.625*626* @param ch_layout the layout structure to be initialized627* @param nb_channels number of channels628*/629void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels);630631/**632* Iterate over all standard channel layouts.633*634* @param opaque a pointer where libavutil will store the iteration state. Must635* point to NULL to start the iteration.636*637* @return the standard channel layout or NULL when the iteration is638* finished639*/640const AVChannelLayout *av_channel_layout_standard(void **opaque);641642/**643* Free any allocated data in the channel layout and reset the channel644* count to 0.645*646* @param channel_layout the layout structure to be uninitialized647*/648void av_channel_layout_uninit(AVChannelLayout *channel_layout);649650/**651* Make a copy of a channel layout. This differs from just assigning src to dst652* in that it allocates and copies the map for AV_CHANNEL_ORDER_CUSTOM.653*654* @note the destination channel_layout will be always uninitialized before copy.655*656* @param dst destination channel layout657* @param src source channel layout658* @return 0 on success, a negative AVERROR on error.659*/660int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src);661662/**663* Get a human-readable string describing the channel layout properties.664* The string will be in the same format that is accepted by665* @ref av_channel_layout_from_string(), allowing to rebuild the same666* channel layout, except for opaque pointers.667*668* @param channel_layout channel layout to be described669* @param buf pre-allocated buffer where to put the generated string670* @param buf_size size in bytes of the buffer.671* @return amount of bytes needed to hold the output string, or a negative AVERROR672* on failure. If the returned value is bigger than buf_size, then the673* string was truncated.674*/675int av_channel_layout_describe(const AVChannelLayout *channel_layout,676char *buf, size_t buf_size);677678/**679* bprint variant of av_channel_layout_describe().680*681* @note the string will be appended to the bprint buffer.682* @return 0 on success, or a negative AVERROR value on failure.683*/684int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout,685struct AVBPrint *bp);686687/**688* Get the channel with the given index in a channel layout.689*690* @param channel_layout input channel layout691* @param idx index of the channel692* @return channel with the index idx in channel_layout on success or693* AV_CHAN_NONE on failure (if idx is not valid or the channel order is694* unspecified)695*/696enum AVChannel697av_channel_layout_channel_from_index(const AVChannelLayout *channel_layout, unsigned int idx);698699/**700* Get the index of a given channel in a channel layout. In case multiple701* channels are found, only the first match will be returned.702*703* @param channel_layout input channel layout704* @param channel the channel whose index to obtain705* @return index of channel in channel_layout on success or a negative number if706* channel is not present in channel_layout.707*/708int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout,709enum AVChannel channel);710711/**712* Get the index in a channel layout of a channel described by the given string.713* In case multiple channels are found, only the first match will be returned.714*715* This function accepts channel names in the same format as716* @ref av_channel_from_string().717*718* @param channel_layout input channel layout719* @param name string describing the channel whose index to obtain720* @return a channel index described by the given string, or a negative AVERROR721* value.722*/723int av_channel_layout_index_from_string(const AVChannelLayout *channel_layout,724const char *name);725726/**727* Get a channel described by the given string.728*729* This function accepts channel names in the same format as730* @ref av_channel_from_string().731*732* @param channel_layout input channel layout733* @param name string describing the channel to obtain734* @return a channel described by the given string in channel_layout on success735* or AV_CHAN_NONE on failure (if the string is not valid or the channel736* order is unspecified)737*/738enum AVChannel739av_channel_layout_channel_from_string(const AVChannelLayout *channel_layout,740const char *name);741742/**743* Find out what channels from a given set are present in a channel layout,744* without regard for their positions.745*746* @param channel_layout input channel layout747* @param mask a combination of AV_CH_* representing a set of channels748* @return a bitfield representing all the channels from mask that are present749* in channel_layout750*/751uint64_t av_channel_layout_subset(const AVChannelLayout *channel_layout,752uint64_t mask);753754/**755* Check whether a channel layout is valid, i.e. can possibly describe audio756* data.757*758* @param channel_layout input channel layout759* @return 1 if channel_layout is valid, 0 otherwise.760*/761int av_channel_layout_check(const AVChannelLayout *channel_layout);762763/**764* Check whether two channel layouts are semantically the same, i.e. the same765* channels are present on the same positions in both.766*767* If one of the channel layouts is AV_CHANNEL_ORDER_UNSPEC, while the other is768* not, they are considered to be unequal. If both are AV_CHANNEL_ORDER_UNSPEC,769* they are considered equal iff the channel counts are the same in both.770*771* @param chl input channel layout772* @param chl1 input channel layout773* @return 0 if chl and chl1 are equal, 1 if they are not equal. A negative774* AVERROR code if one or both are invalid.775*/776int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1);777778/**779* @}780*/781782#endif /* AVUTIL_CHANNEL_LAYOUT_H */783784785