77 #define OFFSET(x) offsetof(JoinContext, x)
78 #define A AV_OPT_FLAG_AUDIO_PARAM
81 {
"channel_layout",
"Channel layout of the "
83 {
"map",
"A comma-separated list of channels maps in the format "
84 "'input_stream.input_channel-output_channel.",
103 if (link == ctx->
inputs[i])
117 while (cur && *cur) {
118 char *sep, *next, *p;
119 uint64_t in_channel = 0, out_channel = 0;
120 int input_idx, out_ch_idx, in_ch_idx;
122 next = strchr(cur,
',');
127 if (!(sep = strchr(cur,
'-'))) {
134 #define PARSE_CHANNEL(str, var, inout) \
135 if (!(var = av_get_channel_layout(str))) { \
136 av_log(ctx, AV_LOG_ERROR, "Invalid " inout " channel: %s.\n", str);\
137 return AVERROR(EINVAL); \
139 if (av_get_channel_layout_nb_channels(var) != 1) { \
140 av_log(ctx, AV_LOG_ERROR, "Channel map describes more than one " \
141 inout " channel.\n"); \
142 return AVERROR(EINVAL); \
149 "requested channel layout.\n", sep);
162 input_idx = strtol(cur, &cur, 0);
163 if (input_idx < 0 || input_idx >= s->
inputs) {
172 in_ch_idx = strtol(cur, &p, 0);
226 for (i = 0; i < s->
inputs; i++) {
230 snprintf(name,
sizeof(name),
"input%d", i);
368 "output channel '%s'.\n",
423 int linesize = INT_MAX;
440 for (j = 1; !i && j < ctx->
nb_inputs; j++)
451 perms &= cur_buf->
perms;
456 nb_samples, outlink->
format,
501 "multi-channel output"),
509 .
outputs = avfilter_af_join_outputs,
uint8_t * data[8]
buffer data for each plane/channel
uint8_t ** extended_data
pointers to the data planes/channels.
static void uninit(AVFilterContext *ctx)
uint64_t in_channel
layout describing the input channel
int nb_samples
number of audio samples
AVFilterBufferRefAudioProps * audio
audio buffer specific properties
int linesize[8]
number of bytes per line
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.
struct ChannelMap ChannelMap
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.
int request_samples
Audio only, the destination filter sets this to a non-zero value to request that buffers with the giv...
void * priv
private data to be used by a custom free function
int(* filter_frame)(AVFilterLink *link, AVFilterBufferRef *frame)
Filtering callback.
A reference-counted buffer data type used by the filter system.
enum AVMediaType type
AVFilterPad type.
struct AVFilterChannelLayouts * in_channel_layouts
static void join_free_buffer(AVFilterBuffer *buf)
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Remove a reference to a buffer.
To avoid copying the data from input buffers, this filter creates a custom output buffer that stores ...
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
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
#define av_assert0(cond)
assert() equivalent, that is always enabled.
uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index)
Get the channel with the given index in channel_layout.
void avfilter_unref_bufferp(AVFilterBufferRef **ref)
Remove a reference to a buffer and set the pointer to NULL.
static void join_uninit(AVFilterContext *ctx)
static void guess_map_matching(AVFilterContext *ctx, ChannelMap *ch, uint64_t *inputs)
int av_get_channel_layout_channel_index(uint64_t channel_layout, uint64_t channel)
Get the index of a channel in channel_layout.
int input
input stream index
AVFilterBufferRef ** in_buffers
static int init(AVCodecParserContext *s)
int64_t pts
presentation timestamp.
static int join_query_formats(AVFilterContext *ctx)
A filter pad used for either input or output.
A link between two filters.
AVFilterPad * input_pads
array of input pads
AVFilterBuffer * buf
the buffer that this is a reference to
#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.
simple assert() macros that are a bit more flexible than ISO C assert().
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 int join_init(AVFilterContext *ctx, const char *args)
static const AVOption join_options[]
audio channel layout utility functions
unsigned nb_inputs
number of input pads
static const AVClass join_class
AVFilterBufferRef ** input_frames
Temporary storage for input frames, until we get one on each input.
struct JoinContext JoinContext
AVFilterContext * src
source filter
static const AVFilterPad avfilter_af_join_outputs[]
int format
agreed upon media format
int in_channel_idx
index of in_channel in the input stream data
void(* free)(struct AVFilterBuffer *buf)
A pointer to the function to deallocate this buffer if the default function is not sufficient...
A reference to an AVFilterBuffer.
struct JoinBufferPriv JoinBufferPriv
To avoid copying the data from input buffers, this filter creates a custom output buffer that stores ...
char * av_strdup(const char *s)
Duplicate the string s.
int perms
permissions, see the AV_PERM_* flags
Describe the class of an AVClass context structure.
#define PARSE_CHANNEL(str, var, inout)
static const AVFilterPad inputs[]
uint64_t out_channel
layout describing the output channel
const char * name
filter name
uint8_t ** extended_data
pointers to the data planes/channels.
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
AVFilterBufferRef * avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, int linesize, int perms, int nb_samples, enum AVSampleFormat sample_fmt, uint64_t channel_layout)
Create an audio buffer reference wrapped around an already allocated samples buffer.
uint8_t ** data
Temporary storage for data pointers, for assembling the output buffer.
void av_opt_free(void *obj)
Free all string and binary options in obj.
static void guess_map_any(AVFilterContext *ctx, ChannelMap *ch, uint64_t *inputs)
common internal and external API header
static int parse_maps(AVFilterContext *ctx)
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
static int join_request_frame(AVFilterLink *outlink)
char * channel_layout_str
AVFilterContext * dst
dest filter
AVFilter avfilter_af_join
static void ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.
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 join_config_output(AVFilterLink *outlink)
int needs_fifo
The filter expects a fifo to be inserted on its input link, typically because it has a delay...
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int filter_frame(AVFilterLink *link, AVFilterBufferRef *buf)