68 #define OFFSET(x) offsetof(JoinContext, x)
69 #define A AV_OPT_FLAG_AUDIO_PARAM
70 #define F AV_OPT_FLAG_FILTERING_PARAM
73 {
"channel_layout",
"Channel layout of the "
75 {
"map",
"A comma-separated list of channels maps in the format "
76 "'input_stream.input_channel-output_channel.",
91 uint64_t in_channel = 0, out_channel = 0;
92 int input_idx, out_ch_idx, in_ch_idx;
94 next = strchr(cur, separator);
99 if (!(sep = strchr(cur,
'-'))) {
106 #define PARSE_CHANNEL(str, var, inout) \
107 if (!(var = av_get_channel_layout(str))) { \
108 av_log(ctx, AV_LOG_ERROR, "Invalid " inout " channel: %s.\n", str);\
109 return AVERROR(EINVAL); \
111 if (av_get_channel_layout_nb_channels(var) != 1) { \
112 av_log(ctx, AV_LOG_ERROR, "Channel map describes more than one " \
113 inout " channel.\n"); \
114 return AVERROR(EINVAL); \
119 if (!(out_channel &
s->channel_layout)) {
121 "requested channel layout.\n", sep);
127 if (
s->channels[out_ch_idx].input >= 0) {
134 input_idx = strtol(cur, &cur, 0);
135 if (input_idx < 0 || input_idx >=
s->inputs) {
144 in_ch_idx = strtol(cur, &p, 0);
151 s->channels[out_ch_idx].input = input_idx;
153 s->channels[out_ch_idx].in_channel = in_channel;
155 s->channels[out_ch_idx].in_channel_idx = in_ch_idx;
169 s->channel_layout_str);
177 if (!
s->channels || !
s->buffers|| !
s->input_frames)
180 for (
i = 0;
i <
s->nb_channels;
i++) {
182 s->channels[
i].input = -1;
188 for (
i = 0;
i <
s->inputs;
i++) {
210 for (
i = 0;
i <
s->inputs &&
s->input_frames;
i++) {
214 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
233 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
251 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
269 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
293 for (
i = 0;
i <
s->nb_channels;
i++) {
319 for (
i = 0;
i <
s->nb_channels;
i++) {
327 for (
i = 0;
i <
s->nb_channels;
i++) {
335 "output channel '%s'.\n",
346 for (
i = 0;
i <
s->nb_channels;
i++) {
354 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
370 int linesize = INT_MAX;
371 int nb_samples = INT_MAX;
375 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
376 if (!
s->input_frames[
i])
378 nb_samples =
FFMIN(nb_samples,
s->input_frames[
i]->nb_samples);
397 for (
i = 0;
i <
s->nb_channels;
i++) {
412 for (j = 0; j < nb_buffers; j++)
413 if (
s->buffers[j]->buffer == buf->
buffer)
416 s->buffers[nb_buffers++] = buf;
460 for (
i = 0;
i <
ctx->nb_inputs;
i++)
479 if (!
s->input_frames[0]) {
492 if (!
s->input_frames[0]) {
497 nb_samples =
s->input_frames[0]->nb_samples;
499 for (
i = 1;
i <
ctx->nb_inputs && nb_samples > 0;
i++) {
500 if (
s->input_frames[
i])
534 "multi-channel output."),
536 .priv_class = &join_class,
static int query_formats(AVFilterContext *ctx)
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
static int parse_maps(AVFilterContext *ctx)
static int join_config_output(AVFilterLink *outlink)
static const AVOption join_options[]
static void guess_map_any(AVFilterContext *ctx, ChannelMap *ch, uint64_t *inputs)
static av_cold void join_uninit(AVFilterContext *ctx)
#define PARSE_CHANNEL(str, var, inout)
AVFILTER_DEFINE_CLASS(join)
static const AVFilterPad avfilter_af_join_outputs[]
static int activate(AVFilterContext *ctx)
static int join_query_formats(AVFilterContext *ctx)
static int try_push_frame(AVFilterContext *ctx)
static void guess_map_matching(AVFilterContext *ctx, ChannelMap *ch, uint64_t *inputs)
static av_cold int join_init(AVFilterContext *ctx)
simple assert() macros that are a bit more flexible than ISO C assert().
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
int ff_inlink_check_available_samples(AVFilterLink *link, unsigned min)
Test if enough samples are available on the link.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Main libavfilter public API header.
static av_cold int init(AVCodecContext *avctx)
char * av_asprintf(const char *fmt,...)
#define flags(name, subs,...)
audio channel layout utility functions
common internal and external API header
static av_cold int uninit(AVCodecContext *avctx)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
static int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
int av_get_channel_layout_channel_index(uint64_t channel_layout, uint64_t channel)
Get the index of a channel in channel_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.
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index)
Get the channel with the given index in channel_layout.
const char * av_get_channel_name(uint64_t channel)
Get the name of a given channel.
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
AVBufferRef * av_frame_get_plane_buffer(AVFrame *frame, int plane)
Get the buffer reference a given data plane is stored in.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
const VDPAUPixFmtMap * map
static int ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
enum MovChannelLayoutTag * layouts
#define FF_ARRAY_ELEMS(a)
A reference to a data buffer.
Describe the class of an AVClass context structure.
A list of supported channel layouts.
A link between two filters.
int channels
Number of channels.
AVFilterContext * src
source filter
int sample_rate
samples per second
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
int format
agreed upon media format
A filter pad used for either input or output.
enum AVMediaType type
AVFilterPad type.
const char * name
Pad name.
const char * name
Filter name.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVBufferRef ** extended_buf
For planar audio which requires more than AV_NUM_DATA_POINTERS AVBufferRef pointers,...
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int channels
number of audio channels, only used for audio.
uint64_t channel_layout
Channel layout of the audio data.
int nb_extended_buf
Number of elements in extended_buf.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int sample_rate
Sample rate of the audio data.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
uint8_t ** extended_data
pointers to the data planes/channels.
uint64_t out_channel
layout describing the output channel
int in_channel_idx
index of in_channel in the input stream data
uint64_t in_channel
layout describing the input channel
int input
input stream index
AVBufferRef ** buffers
Temporary storage for buffer references, for assembling the output frame.
char * channel_layout_str
AVFrame ** input_frames
Temporary storage for input frames, until we get one on each input.