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);
96 next =
split(*map, delim);
97 if (!next && delim ==
'-')
100 sscanf(*map,
"%d%n", ch, &n);
103 if (*ch < 0 || *ch > max_ch)
111 char *next =
split(*map, delim);
112 if (!next && delim ==
'-')
124 char *mapping, separator =
'|';
128 uint64_t out_ch_mask = 0;
136 char *dash = strchr(mapping,
'-');
153 #if FF_API_OLD_FILTER_OPTS
154 if (strchr(mapping,
',')) {
156 "'|' to separate the mappings.\n");
165 while ((sep = strchr(sep, separator))) {
171 if (map_entries >
MAX_CH) {
176 for (i = 0; i < map_entries; i++) {
177 int in_ch_idx = -1, out_ch_idx = -1;
178 uint64_t in_ch = 0, out_ch = 0;
179 static const char err[] =
"Failed to parse channel map\n";
190 if (
get_channel(&mapping, &in_ch, separator) < 0) {
209 out_ch & out_ch_mask) {
215 out_ch_mask |= out_ch;
229 out_ch & out_ch_mask) {
235 out_ch_mask |= out_ch;
240 s->
nch = map_entries;
254 for (i = 0; i < s->
nch; i++) {
258 }
else if (out_ch_mask && out_ch_mask != fmt) {
261 "Output channel layout '%s' does not match the list of channel mapped: '%s'.\n",
266 "Output channel layout %s does not match the number of channels mapped %d.\n",
274 "cannot be guessed from the maps.\n");
281 for (i = 0; i < s->
nch; i++) {
314 const int nch_out = s->
nch;
319 nch_in *
sizeof(source_planes[0]));
321 if (nch_out > nch_in) {
325 if (!new_extended_data) {
341 for (ch = 0; ch < nch_out; ch++) {
362 char layout_name[256];
364 for (i = 0; i < s->
nch; i++) {
378 "input channel '%s' not available from input layout '%s'\n",
379 channel_name, layout_name);
382 "input channel #%d not available from input layout '%s'\n",
412 .
name =
"channelmap",
417 .priv_class = &channelmap_class,
418 .
inputs = avfilter_af_channelmap_inputs,
419 .
outputs = avfilter_af_channelmap_outputs,