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++) {
363 char layout_name[256];
365 for (i = 0; i < s->
nch; i++) {
379 "input channel '%s' not available from input layout '%s'\n",
380 channel_name, layout_name);
383 "input channel #%d not available from input layout '%s'\n",
413 .
name =
"channelmap",
418 .priv_class = &channelmap_class,
419 .
inputs = avfilter_af_channelmap_inputs,
420 .
outputs = avfilter_af_channelmap_outputs,
void av_frame_set_channels(AVFrame *frame, int val)
int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
AVFILTER_DEFINE_CLASS(channelmap)
uint64_t in_channel
layout describing the input channel
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
static const AVFilterPad outputs[]
Main libavfilter public API header.
AVFilter ff_af_channelmap
static const AVOption channelmap_options[]
#define FF_ARRAY_ELEMS(a)
struct AVFilterChannelLayouts * in_channel_layouts
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
const char * name
Pad name.
uint64_t av_get_channel_layout(const char *name)
Return a channel layout id that matches name, or 0 if no match is found.
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static int channelmap_filter_frame(AVFilterLink *inlink, AVFrame *buf)
char * channel_layout_str
static int channelmap_query_formats(AVFilterContext *ctx)
A filter pad used for either input or output.
A link between two filters.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVFilterChannelLayouts * channel_layouts
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#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
struct AVFilterChannelLayouts * out_channel_layouts
static char * split(char *message, char delim)
uint64_t channel_layout
Channel layout of the audio data.
audio channel layout utility functions
int in_channel_idx
index of in_channel in the input stream data
A list of supported channel layouts.
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.
struct ChannelMap map[MAX_CH]
Describe the class of an AVClass context structure.
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
enum MovChannelLayoutTag * layouts
int av_get_channel_layout_channel_index(uint64_t channel_layout, uint64_t channel)
Get the index of a channel in channel_layout.
static int channelmap_config_input(AVFilterLink *inlink)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static const AVFilterPad avfilter_af_channelmap_inputs[]
static int get_channel_idx(char **map, int *ch, char delim, int max_ch)
common internal and external API header
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
int channels
Number of channels.
const char * av_get_channel_name(uint64_t channel)
Get the name of a given channel.
AVFilterContext * dst
dest filter
static int get_channel(char **map, uint64_t *ch, char delim)
int64_t av_get_default_channel_layout(int nb_channels)
Return default channel layout for a given number of channels.
static void * av_mallocz_array(size_t nmemb, size_t size)
static av_cold int channelmap_init(AVFilterContext *ctx)
static const AVFilterPad avfilter_af_channelmap_outputs[]
uint8_t ** extended_data
pointers to the data planes/channels.