47 #define OFFSET(x) offsetof(AMergeContext, x) 48 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM 76 int i, ret, overlap = 0,
nb_ch = 0;
82 "No channel layout for input %d\n", i + 1);
96 if (outlayout & inlayout[i])
98 outlayout |= inlayout[
i];
108 "Input channel layouts overlap: " 109 "output layout will be determined by the number of distinct input channels\n");
110 for (i = 0; i <
nb_ch; i++)
113 if (!outlayout && nb_ch)
114 outlayout = 0xFFFFFFFFFFFFFFFFULL >> (64 -
nb_ch);
117 int c, out_ch_number = 0;
121 route[i] = route[i - 1] + s->
in[i - 1].
nb_ch;
122 for (c = 0; c < 64; c++)
124 if ((inlayout[i] >> c) & 1)
125 *(route[i]++) = out_ch_number++;
156 "Inputs must have the same sample rate " 157 "%d for in%d vs %d\n",
168 av_bprintf(&bp,
"%sin%d:", i ?
" + " :
"", i);
202 nb_ch += in[i].nb_ch;
206 for (c = 0; c < in[
i].nb_ch; c++) {
207 memcpy((*outs) + bps * *(route_cur++), ins[i], bps);
211 *outs += nb_ch *
bps;
236 ins[
i] = inbuf[
i]->
data[0];
245 outs = outbuf->
data[0];
246 outbuf->
pts = inbuf[0]->
pts;
286 for (i = 1; i < ctx->
nb_inputs && nb_samples > 0; i++) {
348 "a single multi-channel stream."),
356 .priv_class = &amerge_class,
struct AMergeContext::amerge_input * in
void av_bprintf(AVBPrint *buf, const char *fmt,...)
int nb_ch
number of channels for the input
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
Main libavfilter public API header.
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
AVFILTER_DEFINE_CLASS(amerge)
struct AVFilterChannelLayouts * in_channel_layouts
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
static int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
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.
AVFilterLink ** inputs
array of pointers to input links
static int activate(AVFilterContext *ctx)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static enum AVSampleFormat ff_packed_sample_fmts_array[]
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static av_cold int init(AVFilterContext *ctx)
#define AV_LOG_VERBOSE
Detailed information.
static void free_frames(int nb_inputs, AVFrame **input_frames)
static av_cold void uninit(AVFilterContext *ctx)
A filter pad used for either input or output.
A link between two filters.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
static const AVFilterPad amerge_outputs[]
AVFilterPad * input_pads
array of input pads
#define i(width, name, range_min, range_max)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const AVOption amerge_options[]
int sample_rate
samples per second
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
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 av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
void * priv
private data for use by the filter
uint64_t * channel_layouts
list of channel layouts
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
struct AVFilterChannelLayouts * out_channel_layouts
uint64_t channel_layout
Channel layout of the audio data.
char * av_asprintf(const char *fmt,...)
static int config_output(AVFilterLink *outlink)
int channels
number of audio channels, only used for audio.
audio channel layout utility functions
unsigned nb_inputs
number of input pads
int ff_inlink_queued_samples(AVFilterLink *link)
AVFilterContext * src
source filter
static int try_push_frame(AVFilterContext *ctx, int nb_samples)
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
int format
agreed upon media format
A list of supported channel layouts.
void av_bprint_channel_layout(struct AVBPrint *bp, int nb_channels, uint64_t channel_layout)
Append a description of a channel layout to a bprint buffer.
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.
static int query_formats(AVFilterContext *ctx)
#define AV_LOG_INFO
Standard information.
#define AV_BPRINT_SIZE_AUTOMATIC
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.
Describe the class of an AVClass context structure.
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
#define flags(name, subs,...)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
#define ns(max_value, name, subs,...)
int nb_channel_layouts
number of channel layouts
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
int channels
Number of channels.
int route[SWR_CH_MAX]
channels routing, see copy_samples
int64_t av_get_default_channel_layout(int nb_channels)
Return default channel layout for a given number of channels.
static void copy_samples(int nb_inputs, struct amerge_input in[], int *route, uint8_t *ins[], uint8_t **outs, int ns, int bps)
Copy samples from several input streams to one output stream.
int nb_samples
number of audio samples (per channel) described by this frame
static int ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.