2012-06-09 01:42:53 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2012 Google, Inc.
|
|
|
|
*
|
2012-06-24 00:09:53 +00:00
|
|
|
* This file is part of FFmpeg.
|
2012-06-09 01:42:53 +00:00
|
|
|
*
|
2012-06-24 00:09:53 +00:00
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2012-06-09 01:42:53 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
2012-06-24 00:09:53 +00:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2012-06-09 01:42:53 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-06-24 00:09:53 +00:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2012-06-09 01:42:53 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* audio channel mapping filter
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#include "libavutil/avstring.h"
|
2012-11-10 15:00:00 +00:00
|
|
|
#include "libavutil/channel_layout.h"
|
2012-08-06 13:49:32 +00:00
|
|
|
#include "libavutil/common.h"
|
2012-06-09 01:42:53 +00:00
|
|
|
#include "libavutil/mathematics.h"
|
|
|
|
#include "libavutil/opt.h"
|
|
|
|
#include "libavutil/samplefmt.h"
|
|
|
|
|
|
|
|
#include "audio.h"
|
|
|
|
#include "avfilter.h"
|
|
|
|
#include "formats.h"
|
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
struct ChannelMap {
|
|
|
|
uint64_t in_channel;
|
|
|
|
uint64_t out_channel;
|
|
|
|
int in_channel_idx;
|
|
|
|
int out_channel_idx;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum MappingMode {
|
|
|
|
MAP_NONE,
|
|
|
|
MAP_ONE_INT,
|
|
|
|
MAP_ONE_STR,
|
|
|
|
MAP_PAIR_INT_INT,
|
|
|
|
MAP_PAIR_INT_STR,
|
|
|
|
MAP_PAIR_STR_INT,
|
|
|
|
MAP_PAIR_STR_STR
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_CH 64
|
|
|
|
typedef struct ChannelMapContext {
|
|
|
|
const AVClass *class;
|
|
|
|
char *mapping_str;
|
|
|
|
char *channel_layout_str;
|
|
|
|
uint64_t output_layout;
|
|
|
|
struct ChannelMap map[MAX_CH];
|
|
|
|
int nch;
|
|
|
|
enum MappingMode mode;
|
|
|
|
} ChannelMapContext;
|
|
|
|
|
|
|
|
#define OFFSET(x) offsetof(ChannelMapContext, x)
|
|
|
|
#define A AV_OPT_FLAG_AUDIO_PARAM
|
2012-08-13 11:40:01 +00:00
|
|
|
#define F AV_OPT_FLAG_FILTERING_PARAM
|
2013-05-27 11:30:31 +00:00
|
|
|
static const AVOption channelmap_options[] = {
|
2012-06-09 01:42:53 +00:00
|
|
|
{ "map", "A comma-separated list of input channel numbers in output order.",
|
2012-08-13 11:40:01 +00:00
|
|
|
OFFSET(mapping_str), AV_OPT_TYPE_STRING, .flags = A|F },
|
2012-06-09 01:42:53 +00:00
|
|
|
{ "channel_layout", "Output channel layout.",
|
2012-08-13 11:40:01 +00:00
|
|
|
OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, .flags = A|F },
|
2013-09-07 12:13:50 +00:00
|
|
|
{ NULL }
|
2012-06-09 01:42:53 +00:00
|
|
|
};
|
|
|
|
|
2013-05-27 11:30:31 +00:00
|
|
|
AVFILTER_DEFINE_CLASS(channelmap);
|
2012-06-09 01:42:53 +00:00
|
|
|
|
|
|
|
static char* split(char *message, char delim) {
|
|
|
|
char *next = strchr(message, delim);
|
|
|
|
if (next)
|
|
|
|
*next++ = '\0';
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int get_channel_idx(char **map, int *ch, char delim, int max_ch)
|
|
|
|
{
|
2015-02-18 12:40:39 +00:00
|
|
|
char *next;
|
2012-06-09 01:42:53 +00:00
|
|
|
int len;
|
|
|
|
int n = 0;
|
2015-01-23 14:03:40 +00:00
|
|
|
if (!*map)
|
|
|
|
return AVERROR(EINVAL);
|
2015-02-18 12:40:39 +00:00
|
|
|
next = split(*map, delim);
|
|
|
|
if (!next && delim == '-')
|
|
|
|
return AVERROR(EINVAL);
|
2012-06-09 01:42:53 +00:00
|
|
|
len = strlen(*map);
|
|
|
|
sscanf(*map, "%d%n", ch, &n);
|
|
|
|
if (n != len)
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
if (*ch < 0 || *ch > max_ch)
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
*map = next;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int get_channel(char **map, uint64_t *ch, char delim)
|
|
|
|
{
|
|
|
|
char *next = split(*map, delim);
|
|
|
|
if (!next && delim == '-')
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
*ch = av_get_channel_layout(*map);
|
|
|
|
if (av_get_channel_layout_nb_channels(*ch) != 1)
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
*map = next;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-13 07:26:39 +00:00
|
|
|
static av_cold int channelmap_init(AVFilterContext *ctx)
|
2012-06-09 01:42:53 +00:00
|
|
|
{
|
|
|
|
ChannelMapContext *s = ctx->priv;
|
2013-02-25 20:21:29 +00:00
|
|
|
char *mapping, separator = '|';
|
2012-06-09 01:42:53 +00:00
|
|
|
int map_entries = 0;
|
|
|
|
char buf[256];
|
|
|
|
enum MappingMode mode;
|
|
|
|
uint64_t out_ch_mask = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
mapping = s->mapping_str;
|
|
|
|
|
|
|
|
if (!mapping) {
|
|
|
|
mode = MAP_NONE;
|
|
|
|
} else {
|
|
|
|
char *dash = strchr(mapping, '-');
|
|
|
|
if (!dash) { // short mapping
|
2013-03-03 10:17:50 +00:00
|
|
|
if (av_isdigit(*mapping))
|
2012-06-09 01:42:53 +00:00
|
|
|
mode = MAP_ONE_INT;
|
|
|
|
else
|
|
|
|
mode = MAP_ONE_STR;
|
2013-03-03 10:17:50 +00:00
|
|
|
} else if (av_isdigit(*mapping)) {
|
|
|
|
if (av_isdigit(*(dash+1)))
|
2012-06-09 01:42:53 +00:00
|
|
|
mode = MAP_PAIR_INT_INT;
|
|
|
|
else
|
|
|
|
mode = MAP_PAIR_INT_STR;
|
|
|
|
} else {
|
2013-03-03 10:17:50 +00:00
|
|
|
if (av_isdigit(*(dash+1)))
|
2012-06-09 01:42:53 +00:00
|
|
|
mode = MAP_PAIR_STR_INT;
|
|
|
|
else
|
|
|
|
mode = MAP_PAIR_STR_STR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode != MAP_NONE) {
|
2013-02-25 20:21:29 +00:00
|
|
|
char *sep = mapping;
|
2012-06-09 01:42:53 +00:00
|
|
|
map_entries = 1;
|
2013-02-25 20:21:29 +00:00
|
|
|
while ((sep = strchr(sep, separator))) {
|
|
|
|
if (*++sep) // Allow trailing comma
|
2012-06-09 01:42:53 +00:00
|
|
|
map_entries++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (map_entries > MAX_CH) {
|
|
|
|
av_log(ctx, AV_LOG_ERROR, "Too many channels mapped: '%d'.\n", map_entries);
|
2013-04-10 10:28:51 +00:00
|
|
|
return AVERROR(EINVAL);
|
2012-06-09 01:42:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < map_entries; i++) {
|
|
|
|
int in_ch_idx = -1, out_ch_idx = -1;
|
|
|
|
uint64_t in_ch = 0, out_ch = 0;
|
|
|
|
static const char err[] = "Failed to parse channel map\n";
|
|
|
|
switch (mode) {
|
|
|
|
case MAP_ONE_INT:
|
2013-02-25 20:21:29 +00:00
|
|
|
if (get_channel_idx(&mapping, &in_ch_idx, separator, MAX_CH) < 0) {
|
2012-06-09 01:42:53 +00:00
|
|
|
av_log(ctx, AV_LOG_ERROR, err);
|
2013-04-10 10:28:51 +00:00
|
|
|
return AVERROR(EINVAL);
|
2012-06-09 01:42:53 +00:00
|
|
|
}
|
|
|
|
s->map[i].in_channel_idx = in_ch_idx;
|
|
|
|
s->map[i].out_channel_idx = i;
|
|
|
|
break;
|
|
|
|
case MAP_ONE_STR:
|
2014-03-04 06:19:46 +00:00
|
|
|
if (get_channel(&mapping, &in_ch, separator) < 0) {
|
2012-06-09 01:42:53 +00:00
|
|
|
av_log(ctx, AV_LOG_ERROR, err);
|
2013-04-10 10:28:51 +00:00
|
|
|
return AVERROR(EINVAL);
|
2012-06-09 01:42:53 +00:00
|
|
|
}
|
|
|
|
s->map[i].in_channel = in_ch;
|
|
|
|
s->map[i].out_channel_idx = i;
|
|
|
|
break;
|
|
|
|
case MAP_PAIR_INT_INT:
|
|
|
|
if (get_channel_idx(&mapping, &in_ch_idx, '-', MAX_CH) < 0 ||
|
2013-02-25 20:21:29 +00:00
|
|
|
get_channel_idx(&mapping, &out_ch_idx, separator, MAX_CH) < 0) {
|
2012-06-09 01:42:53 +00:00
|
|
|
av_log(ctx, AV_LOG_ERROR, err);
|
2013-04-10 10:28:51 +00:00
|
|
|
return AVERROR(EINVAL);
|
2012-06-09 01:42:53 +00:00
|
|
|
}
|
|
|
|
s->map[i].in_channel_idx = in_ch_idx;
|
|
|
|
s->map[i].out_channel_idx = out_ch_idx;
|
|
|
|
break;
|
|
|
|
case MAP_PAIR_INT_STR:
|
|
|
|
if (get_channel_idx(&mapping, &in_ch_idx, '-', MAX_CH) < 0 ||
|
2013-02-25 20:21:29 +00:00
|
|
|
get_channel(&mapping, &out_ch, separator) < 0 ||
|
2012-06-09 01:42:53 +00:00
|
|
|
out_ch & out_ch_mask) {
|
|
|
|
av_log(ctx, AV_LOG_ERROR, err);
|
2013-04-10 10:28:51 +00:00
|
|
|
return AVERROR(EINVAL);
|
2012-06-09 01:42:53 +00:00
|
|
|
}
|
|
|
|
s->map[i].in_channel_idx = in_ch_idx;
|
|
|
|
s->map[i].out_channel = out_ch;
|
|
|
|
out_ch_mask |= out_ch;
|
|
|
|
break;
|
|
|
|
case MAP_PAIR_STR_INT:
|
|
|
|
if (get_channel(&mapping, &in_ch, '-') < 0 ||
|
2013-02-25 20:21:29 +00:00
|
|
|
get_channel_idx(&mapping, &out_ch_idx, separator, MAX_CH) < 0) {
|
2012-06-09 01:42:53 +00:00
|
|
|
av_log(ctx, AV_LOG_ERROR, err);
|
2013-04-10 10:28:51 +00:00
|
|
|
return AVERROR(EINVAL);
|
2012-06-09 01:42:53 +00:00
|
|
|
}
|
|
|
|
s->map[i].in_channel = in_ch;
|
|
|
|
s->map[i].out_channel_idx = out_ch_idx;
|
|
|
|
break;
|
|
|
|
case MAP_PAIR_STR_STR:
|
|
|
|
if (get_channel(&mapping, &in_ch, '-') < 0 ||
|
2013-02-25 20:21:29 +00:00
|
|
|
get_channel(&mapping, &out_ch, separator) < 0 ||
|
2012-06-09 01:42:53 +00:00
|
|
|
out_ch & out_ch_mask) {
|
|
|
|
av_log(ctx, AV_LOG_ERROR, err);
|
2013-04-10 10:28:51 +00:00
|
|
|
return AVERROR(EINVAL);
|
2012-06-09 01:42:53 +00:00
|
|
|
}
|
|
|
|
s->map[i].in_channel = in_ch;
|
|
|
|
s->map[i].out_channel = out_ch;
|
|
|
|
out_ch_mask |= out_ch;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s->mode = mode;
|
|
|
|
s->nch = map_entries;
|
|
|
|
s->output_layout = out_ch_mask ? out_ch_mask :
|
|
|
|
av_get_default_channel_layout(map_entries);
|
|
|
|
|
|
|
|
if (s->channel_layout_str) {
|
|
|
|
uint64_t fmt;
|
|
|
|
if ((fmt = av_get_channel_layout(s->channel_layout_str)) == 0) {
|
|
|
|
av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout: '%s'.\n",
|
|
|
|
s->channel_layout_str);
|
2013-04-10 10:28:51 +00:00
|
|
|
return AVERROR(EINVAL);
|
2012-06-09 01:42:53 +00:00
|
|
|
}
|
|
|
|
if (mode == MAP_NONE) {
|
|
|
|
int i;
|
|
|
|
s->nch = av_get_channel_layout_nb_channels(fmt);
|
|
|
|
for (i = 0; i < s->nch; i++) {
|
|
|
|
s->map[i].in_channel_idx = i;
|
|
|
|
s->map[i].out_channel_idx = i;
|
|
|
|
}
|
|
|
|
} else if (out_ch_mask && out_ch_mask != fmt) {
|
|
|
|
av_get_channel_layout_string(buf, sizeof(buf), 0, out_ch_mask);
|
|
|
|
av_log(ctx, AV_LOG_ERROR,
|
|
|
|
"Output channel layout '%s' does not match the list of channel mapped: '%s'.\n",
|
|
|
|
s->channel_layout_str, buf);
|
2013-04-10 10:28:51 +00:00
|
|
|
return AVERROR(EINVAL);
|
2012-06-09 01:42:53 +00:00
|
|
|
} else if (s->nch != av_get_channel_layout_nb_channels(fmt)) {
|
|
|
|
av_log(ctx, AV_LOG_ERROR,
|
|
|
|
"Output channel layout %s does not match the number of channels mapped %d.\n",
|
|
|
|
s->channel_layout_str, s->nch);
|
2013-04-10 10:28:51 +00:00
|
|
|
return AVERROR(EINVAL);
|
2012-06-09 01:42:53 +00:00
|
|
|
}
|
|
|
|
s->output_layout = fmt;
|
|
|
|
}
|
2013-04-10 10:40:04 +00:00
|
|
|
if (!s->output_layout) {
|
|
|
|
av_log(ctx, AV_LOG_ERROR, "Output channel layout is not set and "
|
|
|
|
"cannot be guessed from the maps.\n");
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
}
|
|
|
|
|
2012-06-09 01:42:53 +00:00
|
|
|
if (mode == MAP_PAIR_INT_STR || mode == MAP_PAIR_STR_STR) {
|
|
|
|
for (i = 0; i < s->nch; i++) {
|
|
|
|
s->map[i].out_channel_idx = av_get_channel_layout_channel_index(
|
|
|
|
s->output_layout, s->map[i].out_channel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-10 10:28:51 +00:00
|
|
|
return 0;
|
2012-06-09 01:42:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int channelmap_query_formats(AVFilterContext *ctx)
|
|
|
|
{
|
|
|
|
ChannelMapContext *s = ctx->priv;
|
2015-07-22 09:30:37 +00:00
|
|
|
AVFilterChannelLayouts *channel_layouts = NULL;
|
2015-10-05 03:39:25 +00:00
|
|
|
int ret;
|
2015-07-22 09:30:37 +00:00
|
|
|
|
2020-08-07 16:54:18 +00:00
|
|
|
if ((ret = ff_set_common_formats (ctx, ff_planar_sample_fmts())) < 0 ||
|
2021-08-09 23:25:31 +00:00
|
|
|
(ret = ff_set_common_all_samplerates(ctx )) < 0 ||
|
2020-08-07 16:54:18 +00:00
|
|
|
(ret = ff_add_channel_layout(&channel_layouts, s->output_layout)) < 0 ||
|
|
|
|
(ret = ff_channel_layouts_ref(channel_layouts,
|
2020-08-24 10:16:34 +00:00
|
|
|
&ctx->outputs[0]->incfg.channel_layouts)) < 0)
|
2020-08-07 16:54:18 +00:00
|
|
|
return ret;
|
2012-06-09 01:42:53 +00:00
|
|
|
|
2020-08-07 16:54:18 +00:00
|
|
|
return ff_channel_layouts_ref(ff_all_channel_counts(),
|
2020-08-24 10:16:34 +00:00
|
|
|
&ctx->inputs[0]->outcfg.channel_layouts);
|
2012-06-09 01:42:53 +00:00
|
|
|
}
|
|
|
|
|
2012-11-28 07:41:07 +00:00
|
|
|
static int channelmap_filter_frame(AVFilterLink *inlink, AVFrame *buf)
|
2012-06-09 01:42:53 +00:00
|
|
|
{
|
|
|
|
AVFilterContext *ctx = inlink->dst;
|
|
|
|
AVFilterLink *outlink = ctx->outputs[0];
|
|
|
|
const ChannelMapContext *s = ctx->priv;
|
2016-12-03 19:02:47 +00:00
|
|
|
const int nch_in = inlink->channels;
|
2012-06-09 01:42:53 +00:00
|
|
|
const int nch_out = s->nch;
|
|
|
|
int ch;
|
|
|
|
uint8_t *source_planes[MAX_CH];
|
|
|
|
|
|
|
|
memcpy(source_planes, buf->extended_data,
|
|
|
|
nch_in * sizeof(source_planes[0]));
|
|
|
|
|
|
|
|
if (nch_out > nch_in) {
|
|
|
|
if (nch_out > FF_ARRAY_ELEMS(buf->data)) {
|
|
|
|
uint8_t **new_extended_data =
|
2021-09-14 19:31:53 +00:00
|
|
|
av_calloc(nch_out, sizeof(*buf->extended_data));
|
2012-07-02 18:13:40 +00:00
|
|
|
if (!new_extended_data) {
|
2012-11-28 07:41:07 +00:00
|
|
|
av_frame_free(&buf);
|
2012-07-02 18:13:40 +00:00
|
|
|
return AVERROR(ENOMEM);
|
|
|
|
}
|
2012-06-09 01:42:53 +00:00
|
|
|
if (buf->extended_data == buf->data) {
|
|
|
|
buf->extended_data = new_extended_data;
|
|
|
|
} else {
|
|
|
|
av_free(buf->extended_data);
|
2012-10-09 13:41:24 +00:00
|
|
|
buf->extended_data = new_extended_data;
|
2012-06-09 01:42:53 +00:00
|
|
|
}
|
|
|
|
} else if (buf->extended_data != buf->data) {
|
|
|
|
av_free(buf->extended_data);
|
|
|
|
buf->extended_data = buf->data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (ch = 0; ch < nch_out; ch++) {
|
|
|
|
buf->extended_data[s->map[ch].out_channel_idx] =
|
|
|
|
source_planes[s->map[ch].in_channel_idx];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buf->data != buf->extended_data)
|
|
|
|
memcpy(buf->data, buf->extended_data,
|
|
|
|
FFMIN(FF_ARRAY_ELEMS(buf->data), nch_out) * sizeof(buf->data[0]));
|
|
|
|
|
2014-08-01 21:32:40 +00:00
|
|
|
buf->channel_layout = outlink->channel_layout;
|
2017-04-22 08:57:18 +00:00
|
|
|
buf->channels = outlink->channels;
|
2014-08-01 21:32:40 +00:00
|
|
|
|
2012-11-28 12:53:48 +00:00
|
|
|
return ff_filter_frame(outlink, buf);
|
2012-06-09 01:42:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int channelmap_config_input(AVFilterLink *inlink)
|
|
|
|
{
|
|
|
|
AVFilterContext *ctx = inlink->dst;
|
|
|
|
ChannelMapContext *s = ctx->priv;
|
2016-12-03 19:02:47 +00:00
|
|
|
int nb_channels = inlink->channels;
|
2012-06-09 01:42:53 +00:00
|
|
|
int i, err = 0;
|
|
|
|
const char *channel_name;
|
|
|
|
char layout_name[256];
|
|
|
|
|
2013-04-14 10:07:24 +00:00
|
|
|
for (i = 0; i < s->nch; i++) {
|
2013-04-14 10:10:50 +00:00
|
|
|
struct ChannelMap *m = &s->map[i];
|
|
|
|
|
2013-04-14 10:07:24 +00:00
|
|
|
if (s->mode == MAP_PAIR_STR_INT || s->mode == MAP_PAIR_STR_STR) {
|
2013-04-14 10:10:50 +00:00
|
|
|
m->in_channel_idx = av_get_channel_layout_channel_index(
|
|
|
|
inlink->channel_layout, m->in_channel);
|
2013-04-14 10:07:24 +00:00
|
|
|
}
|
|
|
|
|
2013-04-14 10:10:50 +00:00
|
|
|
if (m->in_channel_idx < 0 || m->in_channel_idx >= nb_channels) {
|
2013-04-14 10:07:24 +00:00
|
|
|
av_get_channel_layout_string(layout_name, sizeof(layout_name),
|
2016-12-03 19:02:47 +00:00
|
|
|
nb_channels, inlink->channel_layout);
|
2013-04-14 10:10:50 +00:00
|
|
|
if (m->in_channel) {
|
|
|
|
channel_name = av_get_channel_name(m->in_channel);
|
2012-06-09 01:42:53 +00:00
|
|
|
av_log(ctx, AV_LOG_ERROR,
|
|
|
|
"input channel '%s' not available from input layout '%s'\n",
|
|
|
|
channel_name, layout_name);
|
2013-04-14 10:07:24 +00:00
|
|
|
} else {
|
|
|
|
av_log(ctx, AV_LOG_ERROR,
|
|
|
|
"input channel #%d not available from input layout '%s'\n",
|
2013-04-14 10:10:50 +00:00
|
|
|
m->in_channel_idx, layout_name);
|
2012-06-09 01:42:53 +00:00
|
|
|
}
|
2013-04-14 10:07:24 +00:00
|
|
|
err = AVERROR(EINVAL);
|
2012-06-09 01:42:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2012-07-24 13:14:01 +00:00
|
|
|
static const AVFilterPad avfilter_af_channelmap_inputs[] = {
|
|
|
|
{
|
|
|
|
.name = "default",
|
|
|
|
.type = AVMEDIA_TYPE_AUDIO,
|
2021-08-15 22:07:41 +00:00
|
|
|
.flags = AVFILTERPAD_FLAG_NEEDS_WRITABLE,
|
2012-11-28 12:53:48 +00:00
|
|
|
.filter_frame = channelmap_filter_frame,
|
2013-03-10 01:32:35 +00:00
|
|
|
.config_props = channelmap_config_input,
|
2012-07-24 13:14:01 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const AVFilterPad avfilter_af_channelmap_outputs[] = {
|
|
|
|
{
|
|
|
|
.name = "default",
|
|
|
|
.type = AVMEDIA_TYPE_AUDIO
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-04-19 16:33:56 +00:00
|
|
|
const AVFilter ff_af_channelmap = {
|
2012-06-09 01:42:53 +00:00
|
|
|
.name = "channelmap",
|
|
|
|
.description = NULL_IF_CONFIG_SMALL("Remap audio channels."),
|
|
|
|
.init = channelmap_init,
|
|
|
|
.priv_size = sizeof(ChannelMapContext),
|
2013-02-25 20:21:29 +00:00
|
|
|
.priv_class = &channelmap_class,
|
2021-08-12 11:05:31 +00:00
|
|
|
FILTER_INPUTS(avfilter_af_channelmap_inputs),
|
|
|
|
FILTER_OUTPUTS(avfilter_af_channelmap_outputs),
|
2021-09-27 10:07:35 +00:00
|
|
|
FILTER_QUERY_FUNC(channelmap_query_formats),
|
2012-06-09 01:42:53 +00:00
|
|
|
};
|