69 #define OFFSET(x) offsetof(ChannelMapContext, x)
70 #define A AV_OPT_FLAG_AUDIO_PARAM
72 {
"map",
"A comma-separated list of input channel numbers in output order.",
74 {
"channel_layout",
"Output channel layout.",
86 static char*
split(
char *message,
char delim) {
87 char *next = strchr(message, delim);
95 char *next =
split(*map, delim);
98 if (!next && delim ==
'-')
101 sscanf(*map,
"%d%n", ch, &n);
104 if (*ch < 0 || *ch > max_ch)
112 char *next =
split(*map, delim);
113 if (!next && delim ==
'-')
130 uint64_t out_ch_mask = 0;
151 char *dash = strchr(mapping,
'-');
153 if (isdigit(*mapping))
157 }
else if (isdigit(*mapping)) {
158 if (isdigit(*(dash+1)))
163 if (isdigit(*(dash+1)))
171 char *comma = mapping;
173 while ((comma = strchr(comma,
','))) {
179 if (map_entries >
MAX_CH) {
185 for (i = 0; i < map_entries; i++) {
186 int in_ch_idx = -1, out_ch_idx = -1;
187 uint64_t in_ch = 0, out_ch = 0;
188 static const char err[] =
"Failed to parse channel map\n";
221 out_ch & out_ch_mask) {
228 out_ch_mask |= out_ch;
243 out_ch & out_ch_mask) {
250 out_ch_mask |= out_ch;
255 s->
nch = map_entries;
270 for (i = 0; i < s->
nch; i++) {
274 }
else if (out_ch_mask && out_ch_mask != fmt) {
277 "Output channel layout '%s' does not match the list of channel mapped: '%s'.\n",
283 "Output channel layout %s does not match the number of channels mapped %d.\n",
293 for (i = 0; i < s->
nch; i++) {
322 const int nch_out = s->
nch;
327 nch_in *
sizeof(source_planes[0]));
329 if (nch_out > nch_in) {
333 if (!new_extended_data) {
349 for (ch = 0; ch < nch_out; ch++) {
367 const char *channel_name;
368 char layout_name[256];
370 for (i = 0; i < s->
nch; i++) {
383 "input channel '%s' not available from input layout '%s'\n",
384 channel_name, layout_name);
387 "input channel #%d not available from input layout '%s'\n",
416 .
name =
"channelmap",
422 .
inputs = avfilter_af_channelmap_inputs,
423 .
outputs = avfilter_af_channelmap_outputs,
uint8_t ** extended_data
pointers to the data planes/channels.
uint64_t av_get_default_channel_layout(int nb_channels)
Return default channel layout for a given number of channels.
static const AVOption options[]
uint64_t in_channel
layout describing the input channel
static const AVFilterPad outputs[]
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
int ff_filter_frame(AVFilterLink *link, AVFilterBufferRef *frame)
Send a frame of data to the next filter.
int av_set_options_string(void *ctx, const char *opts, const char *key_val_sep, const char *pairs_sep)
Parse the key/value pairs list in opts.
AVFilter avfilter_af_channelmap
struct AVFilterChannelLayouts * in_channel_layouts
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Remove a reference to a buffer.
const char * name
Pad name.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVFilterLink ** inputs
array of pointers to input links
char * channel_layout_str
static int channelmap_query_formats(AVFilterContext *ctx)
int av_get_channel_layout_channel_index(uint64_t channel_layout, uint64_t channel)
Get the index of a channel in channel_layout.
A filter pad used for either input or output.
A link between two filters.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
AVFilterChannelLayouts * channel_layouts
struct ChannelMapContext ChannelMapContext
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
struct AVFilterChannelLayouts * out_channel_layouts
void av_log(void *avcl, int level, const char *fmt,...)
const char * av_get_channel_name(uint64_t channel)
Get the name of a given channel.
static char * split(char *message, char delim)
audio channel layout utility functions
static av_cold int channelmap_init(AVFilterContext *ctx, const char *args)
static int channelmap_filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)
int in_channel_idx
index of in_channel in the input stream data
A reference to an AVFilterBuffer.
static const AVClass channelmap_class
struct ChannelMap map[MAX_CH]
Describe the class of an AVClass context structure.
#define FF_ARRAY_ELEMS(a)
static const AVFilterPad inputs[]
uint64_t out_channel
layout describing the output channel
const char * name
filter name
AVFilterLink ** outputs
array of pointers to output links
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, int max_ch)
void av_opt_free(void *obj)
Free all string and binary options in obj.
common internal and external API header
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
AVFilterContext * dst
dest filter
uint8_t * data[8]
picture/audio data for each plane
uint64_t av_get_channel_layout(const char *name)
Return a channel layout id that matches name, or 0 if no match is found.
static int get_channel(char **map, uint64_t *ch, char delim)
static const AVFilterPad avfilter_af_channelmap_outputs[]
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.