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.",
82 static char*
split(
char *message,
char delim) {
83 char *next = strchr(message, delim);
91 char *next =
split(*map, delim);
94 if (!next && delim ==
'-')
97 sscanf(*map,
"%d%n", ch, &n);
100 if (*ch < 0 || *ch > max_ch)
108 char *next =
split(*map, delim);
109 if (!next && delim ==
'-')
121 char *mapping, separator =
'|';
125 uint64_t out_ch_mask = 0;
133 char *dash = strchr(mapping,
'-');
150 #if FF_API_OLD_FILTER_OPTS
151 if (strchr(mapping,
',')) {
153 "'|' to separate the mappings.\n");
162 while ((sep = strchr(sep, separator))) {
168 if (map_entries >
MAX_CH) {
173 for (i = 0; i < map_entries; i++) {
174 int in_ch_idx = -1, out_ch_idx = -1;
175 uint64_t in_ch = 0, out_ch = 0;
176 static const char err[] =
"Failed to parse channel map\n";
206 out_ch & out_ch_mask) {
212 out_ch_mask |= out_ch;
226 out_ch & out_ch_mask) {
232 out_ch_mask |= out_ch;
237 s->
nch = map_entries;
251 for (i = 0; i < s->
nch; i++) {
255 }
else if (out_ch_mask && out_ch_mask != fmt) {
258 "Output channel layout '%s' does not match the list of channel mapped: '%s'.\n",
263 "Output channel layout %s does not match the number of channels mapped %d.\n",
271 "cannot be guessed from the maps.\n");
278 for (i = 0; i < s->
nch; i++) {
305 const int nch_out = s->
nch;
310 nch_in *
sizeof(source_planes[0]));
312 if (nch_out > nch_in) {
316 if (!new_extended_data) {
332 for (ch = 0; ch < nch_out; ch++) {
351 char layout_name[256];
353 for (i = 0; i < s->
nch; i++) {
367 "input channel '%s' not available from input layout '%s'\n",
368 channel_name, layout_name);
371 "input channel #%d not available from input layout '%s'\n",
401 .
name =
"channelmap",
406 .priv_class = &channelmap_class,
408 .
inputs = avfilter_af_channelmap_inputs,
409 .
outputs = avfilter_af_channelmap_outputs,