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";
187 if (
get_channel(&mapping, &in_ch, separator) < 0) {
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++) {
311 const int nch_out = s->
nch;
316 nch_in *
sizeof(source_planes[0]));
318 if (nch_out > nch_in) {
322 if (!new_extended_data) {
338 for (ch = 0; ch < nch_out; ch++) {
359 char layout_name[256];
361 for (i = 0; i < s->
nch; i++) {
375 "input channel '%s' not available from input layout '%s'\n",
376 channel_name, layout_name);
379 "input channel #%d not available from input layout '%s'\n",
409 .
name =
"channelmap",
414 .priv_class = &channelmap_class,
415 .
inputs = avfilter_af_channelmap_inputs,
416 .
outputs = avfilter_af_channelmap_outputs,