1 /*
2 * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * 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 of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file
23 * audio channel layout utility functions
24 */
25
26 #include <stdint.h>
27
33
37 };
38
40 [0] = { "FL", "front left" },
41 [1] = { "FR", "front right" },
42 [2] = { "FC", "front center" },
43 [3] = { "LFE", "low frequency" },
44 [4] = { "BL", "back left" },
45 [5] = { "BR", "back right" },
46 [6] = { "FLC", "front left-of-center" },
47 [7] = { "FRC", "front right-of-center" },
48 [8] = { "BC", "back center" },
49 [9] = { "SL", "side left" },
50 [10] = { "SR", "side right" },
51 [11] = { "TC", "top center" },
52 [12] = { "TFL", "top front left" },
53 [13] = { "TFC", "top front center" },
54 [14] = { "TFR", "top front right" },
55 [15] = { "TBL", "top back left" },
56 [16] = { "TBC", "top back center" },
57 [17] = { "TBR", "top back right" },
58 [29] = { "DL", "downmix left" },
59 [30] = { "DR", "downmix right" },
60 [31] = { "WL", "wide left" },
61 [32] = { "WR", "wide right" },
62 [33] = { "SDL", "surround direct left" },
63 [34] = { "SDR", "surround direct right" },
64 [35] = { "LFE2", "low frequency 2" },
65 [36] = { "TSL", "top side left" },
66 [37] = { "TSR", "top side right" },
67 [38] = { "BFC", "bottom front center" },
68 [39] = { "BFL", "bottom front left" },
69 [40] = { "BFR", "bottom front right" },
70 };
71
73 {
77 }
78
79 static const struct {
113 };
114
116 {
118 char *end;
120
125 }
130 return (int64_t)1 <<
i;
131
132 errno = 0;
133 i = strtol(
name, &end, 10);
134
135 if (!errno && (end + 1 -
name == name_len && *end ==
'c'))
137
138 errno = 0;
140 if (!errno && end -
name == name_len)
142 return 0;
143 }
144
146 {
147 const char *n, *e;
148 const char *name_end =
name + strlen(
name);
149 int64_t
layout = 0, layout_single;
150
151 for (n =
name; n < name_end; n = e + 1) {
152 for (e = n; e < name_end && *e != '+' && *e != '|'; e++);
154 if (!layout_single)
155 return 0;
157 }
159 }
160
162 {
163 int nb = 0;
164 char *end;
166
170 return 0;
171 }
172
173 nb = strtol(
name, &end, 10);
174 if (!errno && *end == 'C' && *(end + 1) == '0円' && nb > 0 && nb < 64) {
175 *channel_layout = 0;
177 return 0;
178 }
179
181 }
182
185 {
187
190
195 return;
196 }
197
199 if (channel_layout) {
202 for (
i = 0, ch = 0;
i < 64;
i++) {
203 if ((channel_layout & (UINT64_C(1) <<
i))) {
206 if (ch > 0)
209 }
210 ch++;
211 }
212 }
214 }
215 }
216
219 {
220 AVBPrint bp;
221
224 }
225
227 {
229 }
230
236 return 0;
237 }
238
241 {
242 if (!(channel_layout &
channel) ||
247 }
248
250 {
254 for (
i = 0;
i < 64;
i++)
258 }
259
261 {
269 }
270
272 {
274
276 return 0;
277
278 for (
i = 0;
i < 64;
i++) {
279 if ((1ULL <<
i) & channel_layout && !
index--)
281 }
282 return 0;
283 }
284
287 {
292 return 0;
293 }