Skip to content

Commit 786dadc

Browse files
author
Nicolas George
committed
cmdutils: add -layouts option.
Extract of the output: | Individual channels: | NAME DESCRIPTION | FL front left | FR front right | <snip> | SDR surround direct right | | Standard channel layouts: | NAME DECOMPOSITION | mono FC | stereo FL+FR | <snip> | octagonal FL+FR+FC+BL+BR+BC+SL+SR | downmix DL+DR
1 parent 61e262f commit 786dadc

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

cmdutils.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,35 @@ int show_pix_fmts(const char *opt, const char *arg)
10871087
return 0;
10881088
}
10891089

1090+
int show_layouts(const char *opt, const char *arg)
1091+
{
1092+
int i = 0;
1093+
uint64_t layout, j;
1094+
const char *name, *descr;
1095+
1096+
printf("Individual channels:\n"
1097+
"NAME DESCRIPTION\n");
1098+
for (i = 0; i < 63; i++) {
1099+
name = av_get_channel_name((uint64_t)1 << i);
1100+
if (!name)
1101+
continue;
1102+
descr = av_get_channel_description((uint64_t)1 << i);
1103+
printf("%-12s%s\n", name, descr);
1104+
}
1105+
printf("\nStandard channel layouts:\n"
1106+
"NAME DECOMPOSITION\n");
1107+
for (i = 0; !av_get_standard_channel_layout(i, &layout, &name); i++) {
1108+
if (name) {
1109+
printf("%-12s", name);
1110+
for (j = 1; j; j <<= 1)
1111+
if ((layout & j))
1112+
printf("%s%s", (layout & (j - 1)) ? "+" : "", av_get_channel_name(j));
1113+
printf("\n");
1114+
}
1115+
}
1116+
return 0;
1117+
}
1118+
10901119
int show_sample_fmts(const char *opt, const char *arg)
10911120
{
10921121
int i;

cmdutils.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,13 @@ int show_protocols(const char *opt, const char *arg);
359359
*/
360360
int show_pix_fmts(const char *opt, const char *arg);
361361

362+
/**
363+
* Print a listing containing all the standard channel layouts supported by
364+
* the program.
365+
* This option processing function does not utilize the arguments.
366+
*/
367+
int show_layouts(const char *opt, const char *arg);
368+
362369
/**
363370
* Print a listing containing all the sample formats supported by the
364371
* program.

cmdutils_common_opts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
{ "protocols" , OPT_EXIT, {.func_arg = show_protocols}, "show available protocols" },
1313
{ "filters" , OPT_EXIT, {.func_arg = show_filters }, "show available filters" },
1414
{ "pix_fmts" , OPT_EXIT, {.func_arg = show_pix_fmts }, "show available pixel formats" },
15+
{ "layouts" , OPT_EXIT, {.func_arg = show_layouts }, "show standard channel layouts" },
1516
{ "sample_fmts", OPT_EXIT, {.func_arg = show_sample_fmts }, "show available audio sample formats" },
1617
{ "loglevel" , HAS_ARG, {.func_arg = opt_loglevel}, "set libav* logging level", "loglevel" },
1718
{ "v", HAS_ARG, {.func_arg = opt_loglevel}, "set libav* logging level", "loglevel" },

doc/avtools-common-opts.texi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ Show available pixel formats.
119119
@item -sample_fmts
120120
Show available sample formats.
121121

122+
@item -layouts
123+
Show channel names and standard channel layouts.
124+
122125
@item -loglevel @var{loglevel} | -v @var{loglevel}
123126
Set the logging level used by the library.
124127
@var{loglevel} is a number or a string containing one of the following values:

0 commit comments

Comments
 (0)