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.",
90 char *next = strchr(
message, delim);
104 if (!next && delim ==
'-')
107 sscanf(*
map,
"%d%n", ch, &n);
119 if (!next && delim ==
'-')
131 char layout_name[256];
139 "%sput channel '%s' not available from %sput layout '%s'\n",
143 "%sput channel #%d not available from %sput layout '%s'\n",
159 uint8_t *presence_map =
NULL;
163 mapping =
s->mapping_str;
168 char *dash = strchr(mapping,
'-');
200 for (
i = 0;
i < map_entries;
i++) {
201 int in_ch_idx = -1, out_ch_idx = -1;
202 int in_ch = -1, out_ch = -1;
203 static const char err[] =
"Failed to parse channel map\n";
205 s->map[
i].in_channel_idx = -1;
206 s->map[
i].out_channel_idx = -1;
207 s->map[
i].in_channel = -1;
208 s->map[
i].out_channel = -1;
216 s->map[
i].in_channel_idx = in_ch_idx;
217 s->map[
i].out_channel_idx =
i;
224 s->map[
i].in_channel = in_ch;
225 s->map[
i].out_channel_idx =
i;
233 s->map[
i].in_channel_idx = in_ch_idx;
234 s->map[
i].out_channel_idx = out_ch_idx;
242 s->map[
i].in_channel_idx = in_ch_idx;
243 s->map[
i].out_channel = out_ch;
245 out_ch_mask |= 1ULL << out_ch;
255 s->map[
i].in_channel = in_ch;
256 s->map[
i].out_channel_idx = out_ch_idx;
264 s->map[
i].in_channel = in_ch;
265 s->map[
i].out_channel = out_ch;
267 out_ch_mask |= 1ULL << out_ch;
274 s->nch = map_entries;
275 if (
s->output_layout.nb_channels == 0) {
278 else if (map_entries)
284 s->nch =
s->output_layout.nb_channels;
290 for (
i = 0;
i <
s->nch;
i++) {
291 s->map[
i].in_channel_idx =
i;
292 s->map[
i].out_channel_idx =
i;
295 }
else if (
s->nch !=
s->output_layout.nb_channels) {
299 "Output channel layout %s does not match the number of channels mapped %d.\n",
304 if (!
s->output_layout.nb_channels) {
306 "cannot be guessed from the maps.\n");
311 for (
i = 0;
i <
s->nch;
i++) {
313 &
s->output_layout,
s->map[
i].out_channel);
317 presence_map =
av_calloc(
s->nch,
sizeof(*presence_map));
318 for (
i = 0;
i <
s->nch;
i++) {
319 const int out_idx =
s->map[
i].out_channel_idx;
323 if (presence_map[out_idx]) {
324 char layout_name[256];
327 i + 1,
s->map[
i].out_channel_idx, layout_name);
331 presence_map[out_idx] = 1;
370 const int nch_out =
s->nch;
374 nch_in *
sizeof(
s->source_planes[0]));
376 if (nch_out > nch_in) {
378 uint8_t **new_extended_data =
380 if (!new_extended_data) {
396 for (ch = 0; ch < nch_out; ch++) {
398 s->source_planes[
s->map[ch].in_channel_idx];
417 for (
i = 0;
i <
s->nch;
i++) {
431 sizeof(*
s->source_planes));
432 if (!
s->source_planes)
449 .p.name =
"channelmap",
451 .p.priv_class = &channelmap_class,
static int get_channel(char **map, int *ch, char delim)
static int channelmap_config_input(AVFilterLink *inlink)
static const AVFilterPad avfilter_af_channelmap_inputs[]
static int get_channel_idx(char **map, int *ch, char delim)
static int channelmap_query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
const FFFilter ff_af_channelmap
static av_cold int channelmap_init(AVFilterContext *ctx)
static const AVOption channelmap_options[]
static int channelmap_filter_frame(AVFilterLink *inlink, AVFrame *buf)
static char * split(char *message, char delim)
static int check_idx_and_id(AVFilterContext *ctx, int channel_idx, int channel, AVChannelLayout *ch_layout, const char *io)
static void channelmap_uninit(AVFilterContext *ctx)
static AVFormatContext * ctx
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
common internal and external API header
static const uint16_t channel_layouts[7]
channel
Use these values when setting the channel map with ebur128_set_channel().
static char separator(CheckasmFormat format)
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout, enum AVChannel channel)
Get the index of a given channel in a channel layout.
int av_channel_name(char *buf, size_t buf_size, enum AVChannel channel_id)
Get a human readable string in an abbreviated form describing a given channel.
enum AVChannel av_channel_layout_channel_from_index(const AVChannelLayout *channel_layout, unsigned int idx)
Get the channel with the given index in a channel layout.
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
int av_channel_layout_describe(const AVChannelLayout *channel_layout, char *buf, size_t buf_size)
Get a human-readable string describing the channel layout properties.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
enum AVChannel av_channel_from_string(const char *str)
This is the inverse function of av_channel_name().
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_const int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
const VDPAUPixFmtMap * map
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
#define FF_ARRAY_ELEMS(a)
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
A list of supported channel layouts.
A link between two filters.
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVChannelLayout ch_layout
Channel layout of the audio data.
uint8_t ** extended_data
pointers to the data planes/channels.
AVChannelLayout output_layout
int in_channel_idx
index of in_channel in the input stream data
#define av_malloc_array(a, b)