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 ==
'-')
130 uint64_t out_ch_mask = 0;
151 char *dash = strchr(mapping,
'-');
153 if (isdigit(*mapping))
157 }
else if (isdigit(*mapping)) {
158 if (isdigit(*(dash+1)))
163 if (isdigit(*(dash+1)))
171 char *comma = mapping;
173 while ((comma = strchr(comma,
','))) {
179 if (map_entries >
MAX_CH) {
185 for (i = 0; i < map_entries; i++) {
186 int in_ch_idx = -1, out_ch_idx = -1;
187 uint64_t in_ch = 0, out_ch = 0;
188 static const char err[] =
"Failed to parse channel map\n";
221 out_ch & out_ch_mask) {
228 out_ch_mask |= out_ch;
243 out_ch & out_ch_mask) {
250 out_ch_mask |= out_ch;
255 s->
nch = map_entries;
270 for (i = 0; i < s->
nch; i++) {
274 }
else if (out_ch_mask && out_ch_mask != fmt) {
277 "Output channel layout '%s' does not match the list of channel mapped: '%s'.\n",
283 "Output channel layout %s does not match the number of channels mapped %d.\n",
293 for (i = 0; i < s->
nch; i++) {
322 const int nch_out = s->
nch;
327 nch_in *
sizeof(source_planes[0]));
329 if (nch_out > nch_in) {
333 if (!new_extended_data) {
349 for (ch = 0; ch < nch_out; ch++) {
367 const char *channel_name;
368 char layout_name[256];
370 for (i = 0; i < s->
nch; i++) {
383 "input channel '%s' not available from input layout '%s'\n",
384 channel_name, layout_name);
387 "input channel #%d not available from input layout '%s'\n",
416 .
name =
"channelmap",
422 .
inputs = avfilter_af_channelmap_inputs,
423 .
outputs = avfilter_af_channelmap_outputs,