69#define OFFSET(x) offsetof(JoinContext, x)
70#define A AV_OPT_FLAG_AUDIO_PARAM
71#define F AV_OPT_FLAG_FILTERING_PARAM
74 {
"channel_layout",
"Channel layout of the "
76 {
"map",
"A comma-separated list of channels maps in the format "
77 "'input_stream.input_channel-output_channel.",
82#define MAP_SEPARATOR '|'
94 int input_idx, out_ch_idx;
101 if (!(sep = strchr(cur,
'-'))) {
110 if (out_ch_idx < 0) {
115 map = &
s->channels[out_ch_idx];
117 if (
map->input >= 0) {
124 input_idx = strtol(cur, &cur, 0);
125 if (input_idx < 0 || input_idx >=
s->inputs) {
134 map->input = input_idx;
136 map->in_channel_idx = strtol(cur, &p, 0);
140 if (
map->in_channel < 0) {
144 }
else if (
map->in_channel_idx < 0) {
159 s->channels =
av_calloc(
s->ch_layout.nb_channels,
sizeof(*
s->channels));
160 s->buffers =
av_calloc(
s->ch_layout.nb_channels,
sizeof(*
s->buffers));
161 s->input_frames =
av_calloc(
s->inputs,
sizeof(*
s->input_frames));
162 if (!
s->channels || !
s->buffers|| !
s->input_frames)
165 for (
i = 0;
i <
s->ch_layout.nb_channels;
i++) {
167 s->channels[
i].input = -1;
168 s->channels[
i].in_channel_idx = -1;
175 for (
i = 0;
i <
s->inputs;
i++) {
195 for (
i = 0;
i <
s->inputs &&
s->input_frames;
i++) {
216 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
236 memmove(chl->
ch + idx, chl->
ch + idx + 1,
237 (chl->
nb_ch - idx - 1) *
sizeof(*chl->
ch));
248 for (
int i = 0;
i < chl->
nb_ch;
i++)
249 if (chl->
ch[
i] == ch)
259 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
273 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
288 char inbuf[64], outbuf[64];
292 inputs_unused =
av_calloc(
ctx->nb_inputs,
sizeof(*inputs_unused));
295 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
307 for (
int ch_idx = 0; ch_idx < iu->
nb_ch; ch_idx++) {
309 if (iu->
ch[ch_idx] < 0) {
319 for (
i = 0;
i <
s->ch_layout.nb_channels;
i++) {
330 iu = &inputs_unused[ch->
input];
338 "input stream #%d.\n", inbuf,
358 for (
i = 0;
i <
s->ch_layout.nb_channels;
i++) {
366 for (
i = 0;
i <
s->ch_layout.nb_channels;
i++) {
375 "output channel '%s'.\n",
391 for (
i = 0;
i <
s->ch_layout.nb_channels;
i++) {
406 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
407 if (inputs_unused[
i].nb_ch ==
ctx->inputs[
i]->ch_layout.nb_channels)
413 for (
i = 0;
i <
ctx->nb_inputs;
i++)
424 int linesize = INT_MAX;
425 int nb_samples = INT_MAX;
429 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
430 if (!
s->input_frames[
i]) {
434 nb_samples =
FFMIN(nb_samples,
s->input_frames[
i]->nb_samples);
446 sizeof(*
frame->extended_data));
447 if (!
frame->extended_data) {
454 for (
i = 0;
i <
s->ch_layout.nb_channels;
i++) {
469 for (j = 0; j < nb_buffers; j++)
470 if (
s->buffers[j]->buffer == buf->
buffer)
473 s->buffers[nb_buffers++] = buf;
480 sizeof(*
frame->extended_buf));
481 if (!
frame->extended_buf) {
482 frame->nb_extended_buf = 0;
494 for (
i = 0;
i <
frame->nb_extended_buf;
i++) {
497 if (!
frame->extended_buf[
i]) {
503 frame->nb_samples = nb_samples;
512 frame->pts =
s->input_frames[0]->pts;
513 frame->linesize[0] = linesize;
524 for (
i = 0;
i <
ctx->nb_inputs;
i++)
533 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
536 !
s->input_frames[
i]) {
554 if (!
s->input_frames[0]) {
568 if (
s->input_frames[0])
569 nb_samples =
s->input_frames[0]->nb_samples;
571 for (
i = 1;
i <
ctx->nb_inputs && nb_samples > 0;
i++) {
572 if (
s->input_frames[
i])
581 if (!
s->eof && !
s->input_frames[
i]) {
601 "multi-channel output."),
602 .p.priv_class = &join_class,
static const AVFilterPad inputs[]
static int join_query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static enum AVChannel channel_list_pop_ch(ChannelList *chl, enum AVChannel ch)
static void guess_map_matching(AVFilterContext *ctx, ChannelMap *ch, ChannelList *inputs)
static int parse_maps(AVFilterContext *ctx)
static enum AVChannel channel_list_pop(ChannelList *chl, int idx)
static int join_config_output(AVFilterLink *outlink)
static void guess_map_any(AVFilterContext *ctx, ChannelMap *ch, ChannelList *inputs)
static const AVOption join_options[]
static av_cold void join_uninit(AVFilterContext *ctx)
const FFFilter ff_af_join
static const AVFilterPad avfilter_af_join_outputs[]
static int activate(AVFilterContext *ctx)
static int try_push_frame(AVFilterContext *ctx)
static av_cold int join_init(AVFilterContext *ctx)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_append_inpad_free_name(AVFilterContext *f, AVFilterPad *p)
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
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.
int ff_inlink_queued_samples(AVFilterLink *link)
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Main libavfilter public API header.
char * av_asprintf(const char *fmt,...)
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
common internal and external API header
static const uint16_t channel_layouts[7]
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
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_index_from_string(const AVChannelLayout *channel_layout, const char *str)
Get the index in a channel layout of a channel described by the given string.
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.
enum AVChannel av_channel_layout_channel_from_index(const AVChannelLayout *channel_layout, unsigned int idx)
Get the channel with the given index in a channel layout.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
enum AVChannel av_channel_from_string(const char *str)
This is the inverse function of av_channel_name().
@ AV_CHAN_NONE
Invalid channel index.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AVERROR_EOF
End of file.
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.
AVBufferRef * av_frame_get_plane_buffer(const AVFrame *frame, int plane)
Get the buffer reference a given data plane is stored in.
#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.
static AVRational av_make_q(int num, int den)
Create an AVRational.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
const VDPAUPixFmtMap * map
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_OUTPUTS(array)
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.
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
enum MovChannelLayoutTag * layouts
#define FF_ARRAY_ELEMS(a)
A reference to a data buffer.
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
A list of supported channel layouts.
A link between two filters.
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
int sample_rate
samples per second
AVChannelLayout ch_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.
This structure describes decoded (raw) audio or video data.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
uint8_t ** extended_data
pointers to the data planes/channels.
int in_channel_idx
index of in_channel in the input stream data
int input
input stream index
AVBufferRef ** buffers
Temporary storage for buffer references, for assembling the output frame.
AVFrame ** input_frames
Temporary storage for input frames, until we get one on each input.
AVChannelLayout ch_layout
#define av_malloc_array(a, b)
static AVFormatContext * ctx