1 /*
2  * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3  * Copyright (c) 2008 Peter Ross
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 module ffmpeg.libavutil.channel_layout;
22 
23 extern (C) @nogc nothrow:
24 
25 /**
26  * @file
27  * audio channel layout utility functions
28  */
29 
30 /**
31  * @addtogroup lavu_audio
32  * @{
33  */
34 
35 /**
36  * @defgroup channel_masks Audio channel masks
37  *
38  * A channel layout is a 64-bits integer with a bit set for every channel.
39  * The number of bits set must be equal to the number of channels.
40  * The value 0 means that the channel layout is not known.
41  * @note this data structure is not powerful enough to handle channels
42  * combinations that have the same channel multiple times, such as
43  * dual-mono.
44  *
45  * @{
46  */
47 enum AV_CH_FRONT_LEFT = 0x00000001;
48 enum AV_CH_FRONT_RIGHT = 0x00000002;
49 enum AV_CH_FRONT_CENTER = 0x00000004;
50 enum AV_CH_LOW_FREQUENCY = 0x00000008;
51 enum AV_CH_BACK_LEFT = 0x00000010;
52 enum AV_CH_BACK_RIGHT = 0x00000020;
53 enum AV_CH_FRONT_LEFT_OF_CENTER = 0x00000040;
54 enum AV_CH_FRONT_RIGHT_OF_CENTER = 0x00000080;
55 enum AV_CH_BACK_CENTER = 0x00000100;
56 enum AV_CH_SIDE_LEFT = 0x00000200;
57 enum AV_CH_SIDE_RIGHT = 0x00000400;
58 enum AV_CH_TOP_CENTER = 0x00000800;
59 enum AV_CH_TOP_FRONT_LEFT = 0x00001000;
60 enum AV_CH_TOP_FRONT_CENTER = 0x00002000;
61 enum AV_CH_TOP_FRONT_RIGHT = 0x00004000;
62 enum AV_CH_TOP_BACK_LEFT = 0x00008000;
63 enum AV_CH_TOP_BACK_CENTER = 0x00010000;
64 enum AV_CH_TOP_BACK_RIGHT = 0x00020000;
65 enum AV_CH_STEREO_LEFT = 0x20000000; ///< Stereo downmix.
66 enum AV_CH_STEREO_RIGHT = 0x40000000; ///< See AV_CH_STEREO_LEFT.
67 enum AV_CH_WIDE_LEFT = 0x0000000080000000UL;
68 enum AV_CH_WIDE_RIGHT = 0x0000000100000000UL;
69 enum AV_CH_SURROUND_DIRECT_LEFT = 0x0000000200000000UL;
70 enum AV_CH_SURROUND_DIRECT_RIGHT = 0x0000000400000000UL;
71 enum AV_CH_LOW_FREQUENCY_2 = 0x0000000800000000UL;
72 enum AV_CH_TOP_SIDE_LEFT = 0x0000001000000000UL;
73 enum AV_CH_TOP_SIDE_RIGHT = 0x0000002000000000UL;
74 enum AV_CH_BOTTOM_FRONT_CENTER = 0x0000004000000000UL;
75 enum AV_CH_BOTTOM_FRONT_LEFT = 0x0000008000000000UL;
76 enum AV_CH_BOTTOM_FRONT_RIGHT = 0x0000010000000000UL;
77 
78 /** Channel mask value used for AVCodecContext.request_channel_layout
79     to indicate that the user requests the channel order of the decoder output
80     to be the native codec channel order. */
81 enum AV_CH_LAYOUT_NATIVE = 0x8000000000000000UL;
82 
83 /**
84  * @}
85  * @defgroup channel_mask_c Audio channel layouts
86  * @{
87  * */
88 enum AV_CH_LAYOUT_MONO = AV_CH_FRONT_CENTER;
89 enum AV_CH_LAYOUT_STEREO = AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT;
90 enum AV_CH_LAYOUT_2POINT1 = AV_CH_LAYOUT_STEREO | AV_CH_LOW_FREQUENCY;
91 enum AV_CH_LAYOUT_2_1 = AV_CH_LAYOUT_STEREO | AV_CH_BACK_CENTER;
92 enum AV_CH_LAYOUT_SURROUND = AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER;
93 enum AV_CH_LAYOUT_3POINT1 = AV_CH_LAYOUT_SURROUND | AV_CH_LOW_FREQUENCY;
94 enum AV_CH_LAYOUT_4POINT0 = AV_CH_LAYOUT_SURROUND | AV_CH_BACK_CENTER;
95 enum AV_CH_LAYOUT_4POINT1 = AV_CH_LAYOUT_4POINT0 | AV_CH_LOW_FREQUENCY;
96 enum AV_CH_LAYOUT_2_2 = AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT;
97 enum AV_CH_LAYOUT_QUAD = AV_CH_LAYOUT_STEREO | AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT;
98 enum AV_CH_LAYOUT_5POINT0 = AV_CH_LAYOUT_SURROUND | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT;
99 enum AV_CH_LAYOUT_5POINT1 = AV_CH_LAYOUT_5POINT0 | AV_CH_LOW_FREQUENCY;
100 enum AV_CH_LAYOUT_5POINT0_BACK = AV_CH_LAYOUT_SURROUND | AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT;
101 enum AV_CH_LAYOUT_5POINT1_BACK = AV_CH_LAYOUT_5POINT0_BACK | AV_CH_LOW_FREQUENCY;
102 enum AV_CH_LAYOUT_6POINT0 = AV_CH_LAYOUT_5POINT0 | AV_CH_BACK_CENTER;
103 enum AV_CH_LAYOUT_6POINT0_FRONT = AV_CH_LAYOUT_2_2 | AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER;
104 enum AV_CH_LAYOUT_HEXAGONAL = AV_CH_LAYOUT_5POINT0_BACK | AV_CH_BACK_CENTER;
105 enum AV_CH_LAYOUT_6POINT1 = AV_CH_LAYOUT_5POINT1 | AV_CH_BACK_CENTER;
106 enum AV_CH_LAYOUT_6POINT1_BACK = AV_CH_LAYOUT_5POINT1_BACK | AV_CH_BACK_CENTER;
107 enum AV_CH_LAYOUT_6POINT1_FRONT = AV_CH_LAYOUT_6POINT0_FRONT | AV_CH_LOW_FREQUENCY;
108 enum AV_CH_LAYOUT_7POINT0 = AV_CH_LAYOUT_5POINT0 | AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT;
109 enum AV_CH_LAYOUT_7POINT0_FRONT = AV_CH_LAYOUT_5POINT0 | AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER;
110 enum AV_CH_LAYOUT_7POINT1 = AV_CH_LAYOUT_5POINT1 | AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT;
111 enum AV_CH_LAYOUT_7POINT1_WIDE = AV_CH_LAYOUT_5POINT1 | AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER;
112 enum AV_CH_LAYOUT_7POINT1_WIDE_BACK = AV_CH_LAYOUT_5POINT1_BACK | AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER;
113 enum AV_CH_LAYOUT_OCTAGONAL = AV_CH_LAYOUT_5POINT0 | AV_CH_BACK_LEFT | AV_CH_BACK_CENTER | AV_CH_BACK_RIGHT;
114 enum 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;
115 enum AV_CH_LAYOUT_STEREO_DOWNMIX = AV_CH_STEREO_LEFT | AV_CH_STEREO_RIGHT;
116 enum 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;
117 
118 enum AVMatrixEncoding
119 {
120     AV_MATRIX_ENCODING_NONE = 0,
121     AV_MATRIX_ENCODING_DOLBY = 1,
122     AV_MATRIX_ENCODING_DPLII = 2,
123     AV_MATRIX_ENCODING_DPLIIX = 3,
124     AV_MATRIX_ENCODING_DPLIIZ = 4,
125     AV_MATRIX_ENCODING_DOLBYEX = 5,
126     AV_MATRIX_ENCODING_DOLBYHEADPHONE = 6,
127     AV_MATRIX_ENCODING_NB = 7
128 }
129 
130 /**
131  * Return a channel layout id that matches name, or 0 if no match is found.
132  *
133  * name can be one or several of the following notations,
134  * separated by '+' or '|':
135  * - the name of an usual channel layout (mono, stereo, 4.0, quad, 5.0,
136  *   5.0(side), 5.1, 5.1(side), 7.1, 7.1(wide), downmix);
137  * - the name of a single channel (FL, FR, FC, LFE, BL, BR, FLC, FRC, BC,
138  *   SL, SR, TC, TFL, TFC, TFR, TBL, TBC, TBR, DL, DR);
139  * - a number of channels, in decimal, followed by 'c', yielding
140  *   the default channel layout for that number of channels (@see
141  *   av_get_default_channel_layout);
142  * - a channel layout mask, in hexadecimal starting with "0x" (see the
143  *   AV_CH_* macros).
144  *
145  * Example: "stereo+FC" = "2c+FC" = "2c+1c" = "0x7"
146  */
147 ulong av_get_channel_layout (const(char)* name);
148 
149 /**
150  * Return a channel layout and the number of channels based on the specified name.
151  *
152  * This function is similar to (@see av_get_channel_layout), but can also parse
153  * unknown channel layout specifications.
154  *
155  * @param[in]  name             channel layout specification string
156  * @param[out] channel_layout   parsed channel layout (0 if unknown)
157  * @param[out] nb_channels      number of channels
158  *
159  * @return 0 on success, AVERROR(EINVAL) if the parsing fails.
160  */
161 int av_get_extended_channel_layout (const(char)* name, ulong* channel_layout, int* nb_channels);
162 
163 /**
164  * Return a description of a channel layout.
165  * If nb_channels is <= 0, it is guessed from the channel_layout.
166  *
167  * @param buf put here the string containing the channel layout
168  * @param buf_size size in bytes of the buffer
169  */
170 void av_get_channel_layout_string (char* buf, int buf_size, int nb_channels, ulong channel_layout);
171 
172 struct AVBPrint;
173 /**
174  * Append a description of a channel layout to a bprint buffer.
175  */
176 void av_bprint_channel_layout (AVBPrint* bp, int nb_channels, ulong channel_layout);
177 
178 /**
179  * Return the number of channels in the channel layout.
180  */
181 int av_get_channel_layout_nb_channels (ulong channel_layout);
182 
183 /**
184  * Return default channel layout for a given number of channels.
185  */
186 long av_get_default_channel_layout (int nb_channels);
187 
188 /**
189  * Get the index of a channel in channel_layout.
190  *
191  * @param channel a channel layout describing exactly one channel which must be
192  *                present in channel_layout.
193  *
194  * @return index of channel in channel_layout on success, a negative AVERROR
195  *         on error.
196  */
197 int av_get_channel_layout_channel_index (ulong channel_layout, ulong channel);
198 
199 /**
200  * Get the channel with the given index in channel_layout.
201  */
202 ulong av_channel_layout_extract_channel (ulong channel_layout, int index);
203 
204 /**
205  * Get the name of a given channel.
206  *
207  * @return channel name on success, NULL on error.
208  */
209 const(char)* av_get_channel_name (ulong channel);
210 
211 /**
212  * Get the description of a given channel.
213  *
214  * @param channel  a channel layout with a single channel
215  * @return  channel description on success, NULL on error
216  */
217 const(char)* av_get_channel_description (ulong channel);
218 
219 /**
220  * Get the value and name of a standard channel layout.
221  *
222  * @param[in]  index   index in an internal list, starting at 0
223  * @param[out] layout  channel layout mask
224  * @param[out] name    name of the layout
225  * @return  0  if the layout exists,
226  *          <0 if index is beyond the limits
227  */
228 int av_get_standard_channel_layout (
229     uint index,
230     ulong* layout,
231     const(char*)* name);
232 
233 /**
234  * @}
235  * @}
236  */
237 
238 /* AVUTIL_CHANNEL_LAYOUT_H */