Go to the documentation of this file.
30 #define BPRINT_ARGS1(bp, ...) (bp), __VA_ARGS__
31 #define BPRINT_ARGS0(bp, ...) __VA_ARGS__, (bp)
32 #define ORD_ARGS1(str, size, ...) (str), (size), __VA_ARGS__
33 #define ORD_ARGS0(str, size, ...) __VA_ARGS__, (str), (size)
36 #define CMP_BPRINT_AND_NONBPRINT(bp, func_name, ARG_ORDER, ...) do { \
39 func_name ## _bprint(BPRINT_ARGS ## ARG_ORDER((bp), __VA_ARGS__)); \
40 if (strlen((bp)->str) != (bp)->len) { \
41 printf("strlen of AVBPrint-string returned by "#func_name"_bprint" \
42 " differs from AVBPrint.len: %"SIZE_SPECIFIER" vs. %u\n", \
43 strlen((bp)->str), (bp)->len); \
46 size = func_name(ORD_ARGS ## ARG_ORDER(NULL, 0, __VA_ARGS__)); \
48 printf(#func_name " returned %d\n", size); \
51 if ((bp)->len != size - 1) { \
52 printf("Return value %d of " #func_name " inconsistent with length"\
53 " %u obtained from corresponding bprint version\n", \
57 str = av_malloc(size); \
59 printf("string of size %d could not be allocated.\n", size); \
62 size = func_name(ORD_ARGS ## ARG_ORDER(str, size, __VA_ARGS__)); \
63 if (size <= 0 || (bp)->len != size - 1) { \
64 printf("Return value %d of " #func_name " inconsistent with length"\
65 " %d obtained in first pass.\n", size, (bp)->len); \
69 if (strcmp(str, (bp)->str)) { \
70 printf("Ordinary and _bprint versions of "#func_name" disagree: " \
71 "'%s' vs. '%s'\n", str, (bp)->str); \
92 AVBPrint *bp, uint64_t channel_layout)
104 AVBPrint *bp,
const char *channel_layout)
115 #define CHANNEL_NAME(x) \
116 channel_name(&bp, (x));
118 #define CHANNEL_DESCRIPTION(x) \
119 channel_description(&bp, (x));
121 #define CHANNEL_LAYOUT_FROM_MASK(x) \
122 channel_layout_from_mask(&layout, &bp, (x));
124 #define CHANNEL_LAYOUT_FROM_STRING(x) \
125 channel_layout_from_string(&layout, &bp, (x));
127 #define CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(x) \
128 ret = av_channel_layout_channel_from_index(&layout, x); \
132 #define CHANNEL_LAYOUT_SUBSET(x) \
133 mask = av_channel_layout_subset(&layout, x)
135 #define CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(x) \
136 ret = av_channel_layout_index_from_channel(&layout, x); \
140 #define CHANNEL_LAYOUT_CHANNEL_FROM_STRING(x) \
141 ret = av_channel_layout_channel_from_string(&layout, x); \
145 #define CHANNEL_LAYOUT_INDEX_FROM_STRING(x) \
146 ret = av_channel_layout_index_from_string(&layout, x); \
161 printf(
"Testing av_channel_layout_standard\n");
166 for (
int i = 0;
i < 63;
i++) {
178 printf(
"\nTesting av_channel_name\n");
180 printf(
"With AV_CHAN_FRONT_LEFT: %27s\n", bp.str);
182 printf(
"With AV_CHAN_FRONT_RIGHT: %26s\n", bp.str);
184 printf(
"With 63: %43s\n", bp.str);
186 printf(
"With AV_CHAN_AMBISONIC_BASE: %23s\n", bp.str);
188 printf(
"With AV_CHAN_AMBISONIC_END: %24s\n", bp.str);
190 printf(
"Testing av_channel_description\n");
192 printf(
"With AV_CHAN_FRONT_LEFT: %27s\n", bp.str);
194 printf(
"With AV_CHAN_FRONT_RIGHT: %26s\n", bp.str);
196 printf(
"With 63: %43s\n", bp.str);
198 printf(
"With AV_CHAN_AMBISONIC_BASE: %23s\n", bp.str);
200 printf(
"With AV_CHAN_AMBISONIC_END: %24s\n", bp.str);
202 printf(
"\nTesting av_channel_from_string\n");
209 printf(
"\n==Native layouts==\n");
211 printf(
"\nTesting av_channel_layout_from_string\n");
213 printf(
"With \"0x3f\": %39s\n", bp.str);
215 printf(
"With \"63\": %41s\n", bp.str);
217 printf(
"With \"6c\": %41s\n", bp.str);
219 printf(
"With \"6C\": %41s\n", bp.str);
221 printf(
"With \"6 channels\": %33s\n", bp.str);
223 printf(
"With \"6 channels (FL+FR+FC+LFE+BL+BR)\": %12s\n", bp.str);
225 printf(
"With \"FL+FR+FC+LFE+BL+BR\": %25s\n", bp.str);
227 printf(
"With \"5.1\": %40s\n", bp.str);
229 printf(
"With \"FL+FR+USR63\": %32s\n", bp.str);
231 printf(
"With \"FL+FR+FC+LFE+SL+SR\": %25s\n", bp.str);
233 printf(
"With \"5.1(side)\": %34s\n", bp.str);
235 printf(
"\nTesting av_channel_layout_from_mask\n");
237 printf(
"With AV_CH_LAYOUT_5POINT1: %25s\n", bp.str);
239 printf(
"\nTesting av_channel_layout_channel_from_index\n");
241 printf(
"On 5.1(side) layout with 0: %24d\n",
ret);
243 printf(
"On 5.1(side) layout with 1: %24d\n",
ret);
245 printf(
"On 5.1(side) layout with 2: %24d\n",
ret);
247 printf(
"On 5.1(side) layout with 3: %24d\n",
ret);
249 printf(
"On 5.1(side) layout with 4: %24d\n",
ret);
251 printf(
"On 5.1(side) layout with 5: %24d\n",
ret);
253 printf(
"On 5.1(side) layout with 6: %24d\n",
ret);
255 printf(
"\nTesting av_channel_layout_index_from_channel\n");
257 printf(
"On 5.1(side) layout with AV_CHAN_FRONT_LEFT: %7d\n",
ret);
259 printf(
"On 5.1(side) layout with AV_CHAN_FRONT_RIGHT: %6d\n",
ret);
261 printf(
"On 5.1(side) layout with AV_CHAN_FRONT_CENTER: %5d\n",
ret);
263 printf(
"On 5.1(side) layout with AV_CHAN_LOW_FREQUENCY: %4d\n",
ret);
265 printf(
"On 5.1(side) layout with AV_CHAN_SIDE_LEFT: %8d\n",
ret);
267 printf(
"On 5.1(side) layout with AV_CHAN_SIDE_RIGHT: %7d\n",
ret);
269 printf(
"On 5.1(side) layout with AV_CHAN_BACK_CENTER: %6d\n",
ret);
271 printf(
"\nTesting av_channel_layout_channel_from_string\n");
273 printf(
"On 5.1(side) layout with \"FL\": %21d\n",
ret);
275 printf(
"On 5.1(side) layout with \"FR\": %21d\n",
ret);
277 printf(
"On 5.1(side) layout with \"FC\": %21d\n",
ret);
279 printf(
"On 5.1(side) layout with \"LFE\": %20d\n",
ret);
281 printf(
"On 5.1(side) layout with \"SL\": %21d\n",
ret);
283 printf(
"On 5.1(side) layout with \"SR\": %21d\n",
ret);
285 printf(
"On 5.1(side) layout with \"BC\": %21d\n",
ret);
287 printf(
"\nTesting av_channel_layout_index_from_string\n");
289 printf(
"On 5.1(side) layout with \"FL\": %21d\n",
ret);
291 printf(
"On 5.1(side) layout with \"FR\": %21d\n",
ret);
293 printf(
"On 5.1(side) layout with \"FC\": %21d\n",
ret);
295 printf(
"On 5.1(side) layout with \"LFE\": %20d\n",
ret);
297 printf(
"On 5.1(side) layout with \"SL\": %21d\n",
ret);
299 printf(
"On 5.1(side) layout with \"SR\": %21d\n",
ret);
301 printf(
"On 5.1(side) layout with \"BC\": %21d\n",
ret);
303 printf(
"\nTesting av_channel_layout_subset\n");
305 printf(
"On 5.1(side) layout with AV_CH_LAYOUT_STEREO: 0x%"PRIx64
"\n",
mask);
307 printf(
"On 5.1(side) layout with AV_CH_LAYOUT_2POINT1: 0x%"PRIx64
"\n",
mask);
309 printf(
"On 5.1(side) layout with AV_CH_LAYOUT_4POINT1: 0x%"PRIx64
"\n",
mask);
311 printf(
"\n==Custom layouts==\n");
313 printf(
"\nTesting av_channel_layout_from_string\n");
315 printf(
"With \"FL+FR+FC+BL+BR+LFE\": %34s\n", bp.str);
317 printf(
"With \"2 channels (FR+FL)\": %34s\n", bp.str);
319 printf(
"With \"ambisonic 1+FR+FL\": %35s\n", bp.str);
321 printf(
"With \"ambisonic 2+FC@Foo\": %34s\n", bp.str);
323 printf(
"With \"FL@Foo+FR@Bar\": %39s\n", bp.str);
325 printf(
"With \"FR+FL@Foo+USR63@Foo\": %33s\n", bp.str);
329 printf(
"Copying channel layout \"FR+FL@Foo+USR63@Foo\" failed; "
334 printf(
"Channel layout and its copy compare unequal; ret: %d\n",
ret);
336 printf(
"\nTesting av_channel_layout_index_from_string\n");
338 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"FR\": %18d\n",
ret);
340 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"FL\": %18d\n",
ret);
342 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"USR63\": %15d\n",
ret);
344 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"Foo\": %17d\n",
ret);
346 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"@Foo\": %16d\n",
ret);
348 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"FR@Foo\": %14d\n",
ret);
350 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"FL@Foo\": %14d\n",
ret);
352 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"USR63@Foo\": %11d\n",
ret);
354 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"BC\": %18d\n",
ret);
356 printf(
"\nTesting av_channel_layout_channel_from_string\n");
358 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"FR\": %18d\n",
ret);
360 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"FL\": %18d\n",
ret);
362 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"USR63\": %15d\n",
ret);
364 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"Foo\": %17d\n",
ret);
366 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"@Foo\": %16d\n",
ret);
368 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"FR@Foo\": %14d\n",
ret);
370 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"FL@Foo\": %14d\n",
ret);
372 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"USR63@Foo\": %11d\n",
ret);
374 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with \"BC\": %18d\n",
ret);
376 printf(
"\nTesting av_channel_layout_index_from_channel\n");
378 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with AV_CHAN_FRONT_RIGHT: %3d\n",
ret);
380 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with AV_CHAN_FRONT_LEFT: %4d\n",
ret);
382 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with 63: %20d\n",
ret);
384 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with AV_CHAN_BACK_CENTER: %3d\n",
ret);
386 printf(
"\nTesting av_channel_layout_channel_from_index\n");
388 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with 0: %21d\n",
ret);
390 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with 1: %21d\n",
ret);
392 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with 2: %21d\n",
ret);
394 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with 3: %21d\n",
ret);
396 printf(
"\nTesting av_channel_layout_subset\n");
398 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with AV_CH_LAYOUT_STEREO: 0x%"PRIx64
"\n",
mask);
400 printf(
"On \"FR+FL@Foo+USR63@Foo\" layout with AV_CH_LAYOUT_QUAD: 0x%"PRIx64
"\n",
mask);
402 printf(
"\n==Ambisonic layouts==\n");
404 printf(
"\nTesting av_channel_layout_from_string\n");
406 printf(
"With \"ambisonic 1\": %41s\n", bp.str);
408 printf(
"With \"ambisonic 2+stereo\": %34s\n", bp.str);
410 printf(
"\nTesting av_channel_layout_index_from_channel\n");
412 printf(
"On \"ambisonic 2+stereo\" layout with AV_CHAN_AMBISONIC_BASE: %d\n",
ret);
414 printf(
"On \"ambisonic 2+stereo\" layout with AV_CHAN_FRONT_LEFT: %5d\n",
ret);
416 printf(
"On \"ambisonic 2+stereo\" layout with AV_CHAN_FRONT_RIGHT: %4d\n",
ret);
418 printf(
"On \"ambisonic 2+stereo\" layout with AV_CHAN_BACK_CENTER: %4d\n",
ret);
420 printf(
"\nTesting av_channel_layout_channel_from_index\n");
422 printf(
"On \"ambisonic 2+stereo\" layout with 0: %22d\n",
ret);
424 printf(
"On \"ambisonic 2+stereo\" layout with 9: %22d\n",
ret);
426 printf(
"On \"ambisonic 2+stereo\" layout with 10: %21d\n",
ret);
428 printf(
"On \"ambisonic 2+stereo\" layout with 11: %21d\n",
ret);
430 printf(
"\nTesting av_channel_layout_subset\n");
432 printf(
"On \"ambisonic 2+stereo\" layout with AV_CH_LAYOUT_STEREO: 0x%"PRIx64
"\n",
mask);
434 printf(
"On \"ambisonic 2+stereo\" layout with AV_CH_LAYOUT_QUAD: 0x%"PRIx64
"\n",
mask);
#define CHANNEL_DESCRIPTION(x)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define CHANNEL_LAYOUT_FROM_STRING(x)
int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout, AVBPrint *bp)
bprint variant of av_channel_layout_describe().
#define AV_BPRINT_SIZE_AUTOMATIC
#define AV_CH_LAYOUT_STEREO
static void channel_name(AVBPrint *bp, enum AVChannel channel)
#define AV_CH_LAYOUT_QUAD
static const uint16_t mask[17]
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 CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(x)
#define CHANNEL_LAYOUT_CHANNEL_FROM_STRING(x)
FF_ENABLE_DEPRECATION_WARNINGS 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.
const AVChannelLayout * av_channel_layout_standard(void **opaque)
Iterate over all standard channel layouts.
static void channel_description(AVBPrint *bp, enum AVChannel channel)
#define CHANNEL_LAYOUT_SUBSET(x)
#define AV_CH_LAYOUT_5POINT1
static void channel_layout_from_string(AVChannelLayout *layout, AVBPrint *bp, const char *channel_layout)
#define CHANNEL_LAYOUT_FROM_MASK(x)
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
An AVChannelLayout holds information about the channel layout of audio data.
printf("static const uint8_t my_array[100] = {\n")
int av_channel_description(char *buf, size_t buf_size, enum AVChannel channel_id)
Get a human readable string describing a given channel.
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel layout
int av_channel_layout_from_string(AVChannelLayout *channel_layout, const char *str)
Initialize a channel layout from a given string description.
#define i(width, name, range_min, range_max)
#define AV_CH_LAYOUT_2POINT1
static void channel_layout_from_mask(AVChannelLayout *layout, AVBPrint *bp, uint64_t channel_layout)
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_CH_LAYOUT_4POINT1
#define CHANNEL_LAYOUT_INDEX_FROM_STRING(x)
#define CMP_BPRINT_AND_NONBPRINT(bp, func_name, ARG_ORDER,...)
int av_channel_layout_check(const AVChannelLayout *channel_layout)
Check whether a channel layout is valid, i.e.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
enum AVChannel av_channel_from_string(const char *str)
This is the inverse function of av_channel_name().
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.
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
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.
@ AV_CHAN_AMBISONIC_BASE
Range of channels between AV_CHAN_AMBISONIC_BASE and AV_CHAN_AMBISONIC_END represent Ambisonic compon...
void av_channel_name_bprint(AVBPrint *bp, enum AVChannel channel_id)
bprint variant of av_channel_name().
#define CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(x)