69 #define OFFSET(x) offsetof(ChannelMapContext, x)
70 #define A AV_OPT_FLAG_AUDIO_PARAM
72 {
"map",
"A comma-separated list of input channel numbers in output order.",
74 {
"channel_layout",
"Output channel layout.",
86 static char*
split(
char *message,
char delim) {
87 char *next = strchr(message, delim);
95 char *next =
split(*map, delim);
98 if (!next && delim ==
'-')
101 sscanf(*map,
"%d%n", ch, &n);
104 if (*ch < 0 || *ch > max_ch)
112 char *next =
split(*map, delim);
113 if (!next && delim ==
'-')
125 char *mapping, separator =
'|';
129 uint64_t out_ch_mask = 0;
137 char *dash = strchr(mapping,
'-');
154 #if FF_API_OLD_FILTER_OPTS
155 if (strchr(mapping,
',')) {
157 "'|' to separate the mappings.\n");
166 while ((sep = strchr(sep, separator))) {
172 if (map_entries >
MAX_CH) {
177 for (i = 0; i < map_entries; i++) {
178 int in_ch_idx = -1, out_ch_idx = -1;
179 uint64_t in_ch = 0, out_ch = 0;
180 static const char err[] =
"Failed to parse channel map\n";
191 if (
get_channel(&mapping, &in_ch, separator) < 0) {
210 out_ch & out_ch_mask) {
216 out_ch_mask |= out_ch;
230 out_ch & out_ch_mask) {
236 out_ch_mask |= out_ch;
241 s->
nch = map_entries;
255 for (i = 0; i < s->
nch; i++) {
259 }
else if (out_ch_mask && out_ch_mask != fmt) {
262 "Output channel layout '%s' does not match the list of channel mapped: '%s'.\n",
267 "Output channel layout %s does not match the number of channels mapped %d.\n",
275 "cannot be guessed from the maps.\n");
282 for (i = 0; i < s->
nch; i++) {
309 const int nch_out = s->
nch;
314 nch_in *
sizeof(source_planes[0]));
316 if (nch_out > nch_in) {
320 if (!new_extended_data) {
336 for (ch = 0; ch < nch_out; ch++) {
354 const char *channel_name;
355 char layout_name[256];
357 for (i = 0; i < s->
nch; i++) {
371 "input channel '%s' not available from input layout '%s'\n",
372 channel_name, layout_name);
375 "input channel #%d not available from input layout '%s'\n",
404 .
name =
"channelmap",
409 .priv_class = &channelmap_class,
411 .
inputs = avfilter_af_channelmap_inputs,
412 .
outputs = avfilter_af_channelmap_outputs,