Go to the documentation of this file.
68 #define OFFSET(x) offsetof(ChannelMapContext, x)
69 #define A AV_OPT_FLAG_AUDIO_PARAM
70 #define F AV_OPT_FLAG_FILTERING_PARAM
72 {
"map",
"A comma-separated list of input channel numbers in output order.",
74 {
"channel_layout",
"Output channel layout.",
82 char *next = strchr(
message, delim);
96 if (!next && delim ==
'-')
99 sscanf(*
map,
"%d%n", ch, &n);
102 if (*ch < 0 || *ch > max_ch)
111 if (!next && delim ==
'-')
123 char *mapping, separator =
'|';
127 uint64_t out_ch_mask = 0;
130 mapping =
s->mapping_str;
135 char *dash = strchr(mapping,
'-');
157 while ((sep = strchr(sep, separator))) {
163 if (map_entries >
MAX_CH) {
168 for (
i = 0;
i < map_entries;
i++) {
169 int in_ch_idx = -1, out_ch_idx = -1;
170 int in_ch = 0, out_ch = 0;
171 static const char err[] =
"Failed to parse channel map\n";
178 s->map[
i].in_channel_idx = in_ch_idx;
179 s->map[
i].out_channel_idx =
i;
182 if (
get_channel(&mapping, &in_ch, separator) < 0) {
186 s->map[
i].in_channel = in_ch;
187 s->map[
i].out_channel_idx =
i;
195 s->map[
i].in_channel_idx = in_ch_idx;
196 s->map[
i].out_channel_idx = out_ch_idx;
201 (1ULL << out_ch) & out_ch_mask) {
205 s->map[
i].in_channel_idx = in_ch_idx;
206 s->map[
i].out_channel = out_ch;
207 out_ch_mask |= 1ULL << out_ch;
215 s->map[
i].in_channel = in_ch;
216 s->map[
i].out_channel_idx = out_ch_idx;
221 (1ULL << out_ch) & out_ch_mask) {
225 s->map[
i].in_channel = in_ch;
226 s->map[
i].out_channel = out_ch;
227 out_ch_mask |= 1ULL << out_ch;
232 s->nch = map_entries;
238 if (
s->channel_layout_str) {
242 #if FF_API_OLD_CHANNEL_LAYOUT
248 s->channel_layout_str);
250 #if FF_API_OLD_CHANNEL_LAYOUT
254 s->channel_layout_str);
261 for (
i = 0;
i <
s->nch;
i++) {
262 s->map[
i].in_channel_idx =
i;
263 s->map[
i].out_channel_idx =
i;
268 "Output channel layout '%s' does not match the list of channel mapped: '%s'.\n",
269 s->channel_layout_str, buf);
273 "Output channel layout %s does not match the number of channels mapped %d.\n",
274 s->channel_layout_str,
s->nch);
277 s->output_layout = fmt;
279 if (!
s->output_layout.nb_channels) {
281 "cannot be guessed from the maps.\n");
286 for (
i = 0;
i <
s->nch;
i++) {
288 &
s->output_layout,
s->map[
i].out_channel);
305 &
ctx->outputs[0]->incfg.channel_layouts)) < 0)
309 &
ctx->inputs[0]->outcfg.channel_layouts);
317 const int nch_in =
inlink->ch_layout.nb_channels;
318 const int nch_out =
s->nch;
320 uint8_t *source_planes[
MAX_CH];
323 nch_in *
sizeof(source_planes[0]));
325 if (nch_out > nch_in) {
327 uint8_t **new_extended_data =
329 if (!new_extended_data) {
345 for (ch = 0; ch < nch_out; ch++) {
347 source_planes[
s->map[ch].in_channel_idx];
354 #if FF_API_OLD_CHANNEL_LAYOUT
370 int nb_channels =
inlink->ch_layout.nb_channels;
373 char layout_name[256];
375 for (
i = 0;
i <
s->nch;
i++) {
388 "input channel '%s' not available from input layout '%s'\n",
392 "input channel #%d not available from input layout '%s'\n",
420 .
name =
"channelmap",
424 .priv_class = &channelmap_class,
#define FF_ENABLE_DEPRECATION_WARNINGS
A list of supported channel layouts.
#define AV_LOG_WARNING
Something somehow does not look correct.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
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)
static av_cold int channelmap_init(AVFilterContext *ctx)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
#define FILTER_QUERY_FUNC(func)
static const AVFilterPad avfilter_af_channelmap_outputs[]
static int get_channel(char **map, int *ch, char delim)
const char * name
Filter name.
int nb_channels
Number of channels in this layout.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
char * channel_layout_str
const AVFilter ff_af_channelmap
AVChannelLayout ch_layout
Channel layout of the audio data.
attribute_deprecated int channels
number of audio channels, only used for audio.
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
attribute_deprecated uint64_t channel_layout
Channel layout of the audio data.
static const uint16_t mask[17]
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.
static const AVOption channelmap_options[]
FF_ENABLE_DEPRECATION_WARNINGS 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.
#define FILTER_INPUTS(array)
Describe the class of an AVClass context structure.
AVChannelLayout output_layout
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 channelmap_query_formats(AVFilterContext *ctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
An AVChannelLayout holds information about the channel layout of audio data.
static const AVFilterPad avfilter_af_channelmap_inputs[]
static int channelmap_config_input(AVFilterLink *inlink)
static char * split(char *message, char delim)
static av_const int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
static int get_channel_idx(char **map, int *ch, char delim, int max_ch)
int in_channel_idx
index of in_channel in the input stream data
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
struct ChannelMap map[MAX_CH]
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_from_string(AVChannelLayout *channel_layout, const char *str)
Initialize a channel layout from a given string description.
#define i(width, name, range_min, range_max)
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.
uint8_t ** extended_data
pointers to the data planes/channels.
const char * name
Pad name.
void * av_calloc(size_t nmemb, size_t size)
enum AVChannel av_channel_from_string(const char *str)
This is the inverse function of av_channel_name().
AVFILTER_DEFINE_CLASS(channelmap)
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_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
#define FF_DISABLE_DEPRECATION_WARNINGS
const VDPAUPixFmtMap * map
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
static const uint16_t channel_layouts[7]
#define FILTER_OUTPUTS(array)
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.