69 #define OFFSET(x) offsetof(ChannelMapContext, x)
70 #define A AV_OPT_FLAG_AUDIO_PARAM
71 #define F AV_OPT_FLAG_FILTERING_PARAM
73 {
"map",
"A comma-separated list of input channel numbers in output order.",
75 {
"channel_layout",
"Output channel layout.",
87 static char*
split(
char *message,
char delim) {
88 char *next = strchr(message, delim);
96 char *next =
split(*map, delim);
99 if (!next && delim ==
'-')
102 sscanf(*map,
"%d%n", ch, &n);
105 if (*ch < 0 || *ch > max_ch)
113 char *next =
split(*map, delim);
114 if (!next && delim ==
'-')
131 uint64_t out_ch_mask = 0;
150 char *dash = strchr(mapping,
'-');
152 if (isdigit(*mapping))
156 }
else if (isdigit(*mapping)) {
157 if (isdigit(*(dash+1)))
162 if (isdigit(*(dash+1)))
170 char *comma = mapping;
172 while ((comma = strchr(comma,
','))) {
178 if (map_entries >
MAX_CH) {
184 for (i = 0; i < map_entries; i++) {
185 int in_ch_idx = -1, out_ch_idx = -1;
186 uint64_t in_ch = 0, out_ch = 0;
187 static const char err[] =
"Failed to parse channel map\n";
220 out_ch & out_ch_mask) {
227 out_ch_mask |= out_ch;
242 out_ch & out_ch_mask) {
249 out_ch_mask |= out_ch;
254 s->
nch = map_entries;
269 for (i = 0; i < s->
nch; i++) {
273 }
else if (out_ch_mask && out_ch_mask != fmt) {
276 "Output channel layout '%s' does not match the list of channel mapped: '%s'.\n",
282 "Output channel layout %s does not match the number of channels mapped %d.\n",
292 for (i = 0; i < s->
nch; i++) {
321 const int nch_out = s->
nch;
326 nch_in *
sizeof(source_planes[0]));
328 if (nch_out > nch_in) {
332 if (!new_extended_data) {
348 for (ch = 0; ch < nch_out; ch++) {
366 char layout_name[256];
369 for (i = 0; i < s->
nch; i++) {
377 "input channel '%s' not available from input layout '%s'\n",
378 channel_name, layout_name);
407 .
name =
"channelmap",
413 .
inputs = avfilter_af_channelmap_inputs,
414 .
outputs = avfilter_af_channelmap_outputs,
415 .priv_class = &channelmap_class,