50#define OFFSET(x) offsetof(AMergeContext, x)
51#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
61 {
"inputs",
"specify the number of inputs",
OFFSET(nb_inputs),
63 {
"layout_mode",
"method used to determine the output channel layout",
OFFSET(layout_mode),
80#define INLAYOUT(ctx, i) (&(ctx)->inputs[i]->incfg.channel_layouts->channel_layouts[0])
96 int i, ret, nb_ch = 0;
99 for (
i = 0;
i <
s->nb_inputs;
i++) {
100 if (!
ctx->inputs[
i]->incfg.channel_layouts ||
101 !
ctx->inputs[
i]->incfg.channel_layouts->nb_channel_layouts) {
103 "No channel layout for input %d\n",
i + 1);
106 if (
ctx->inputs[
i]->incfg.channel_layouts->nb_channel_layouts > 1) {
112 nb_ch +=
s->in[
i].nb_ch;
121 for (
int i = 0, ch_idx = 0;
i <
s->nb_inputs;
i++) {
122 for (
int j = 0; j <
s->in[
i].nb_ch; j++) {
128 if (
id >= 0 &&
id < 64) {
129 outmask |= (1ULL <<
id);
130 native_layout_routes[
id] = ch_idx;
132 s->route[ch_idx] = ch_idx;
136 switch (
s->layout_mode) {
141 "Input channel layouts overlap: "
142 "output layout will be determined by the number of distinct input channels\n");
144 if (!
KNOWN(&outlayout) && nb_ch)
147 for (
int c = 0, ch_idx = 0;
c < 64;
c++)
148 if ((1ULL <<
c) & outmask)
149 s->route[native_layout_routes[
c]] = ch_idx++;
168 for (
i = 0;
i <
s->nb_inputs;
i++) {
198 for (
i = 0;
i <
s->nb_inputs;
i++) {
225static inline void copy_samples(
int nb_inputs,
struct amerge_input in[],
226 int *route, uint8_t *ins[],
227 uint8_t **outs,
int ns,
int bps)
232 for (
i = 0;
i < nb_inputs;
i++)
233 nb_ch += in[
i].nb_ch;
236 for (
i = 0;
i < nb_inputs;
i++) {
237 for (
c = 0;
c < in[
i].nb_ch;
c++) {
238 memcpy((*outs) +
bps * *(route_cur++), ins[
i],
bps);
242 *outs += nb_ch *
bps;
249 for (
i = 0;
i < nb_inputs;
i++)
261 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
267 ins[
i] = inbuf[
i]->
data[0];
276 outs = outbuf->
data[0];
277 outbuf->
pts = inbuf[0]->
pts;
295 copy_samples(
s->nb_inputs,
s->in,
s->route, ins, &outs, nb_samples, 1);
298 copy_samples(
s->nb_inputs,
s->in,
s->route, ins, &outs, nb_samples, 2);
301 copy_samples(
s->nb_inputs,
s->in,
s->route, ins, &outs, nb_samples, 4);
304 copy_samples(
s->nb_inputs,
s->in,
s->route, ins, &outs, nb_samples,
s->bps);
324 for (
i = 1;
i <
ctx->nb_inputs && nb_samples > 0;
i++) {
334 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
358 for (
i = 0;
i <
s->nb_inputs;
i++) {
383 "a single multi-channel stream."),
385 .p.priv_class = &amerge_class,
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int try_push_frame(AVFilterContext *ctx, int nb_samples)
const FFFilter ff_af_amerge
static int query_formats(AVFilterContext *ctx)
static const AVOption amerge_options[]
static int activate(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
static int config_output(AVFilterLink *outlink)
static const AVFilterPad amerge_outputs[]
static void free_frames(int nb_inputs, AVFrame **input_frames)
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.
static AVFormatContext * ctx
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
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_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,...)
void av_bprintf(AVBPrint *buf, const char *fmt,...)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define AV_BPRINT_SIZE_AUTOMATIC
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
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_retype(AVChannelLayout *channel_layout, enum AVChannelOrder order, int flags)
Change the AVChannelOrder of a channel layout.
int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout, AVBPrint *bp)
bprint variant of av_channel_layout_describe().
#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL
The specified retype target order is ignored and the simplest possible (canonical) order is used for ...
int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels)
Initialize a custom channel layout with the specified number of channels.
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.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
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.
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.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
@ AV_CHANNEL_ORDER_CUSTOM
The channel order does not correspond to any other predefined order and is stored as an explicit map.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
@ AV_CHAN_NONE
Invalid channel index.
@ AV_CHAN_UNKNOWN
Channel contains data, but its position is unknown.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard 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.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S32
signed 32 bits
@ AV_SAMPLE_FMT_U8
unsigned 8 bits
@ AV_SAMPLE_FMT_DBL
double
@ AV_SAMPLE_FMT_S16
signed 16 bits
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
#define FILTER_OUTPUTS(array)
#define FILTER_QUERY_FUNC(func)
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 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
int nb_ch
number of channels for the input
struct AMergeContext::amerge_input * in
int layout_mode
the method for determining the output channel layout
int route[SWR_CH_MAX]
channels routing, see copy_samples
An AVChannelLayout holds information about the channel layout of audio data.
enum AVChannelOrder order
Channel order used in this layout.
union AVChannelLayout::@162063043056170047076125117143030261346263330336 u
Details about which channels are present in this layout.
int nb_channels
Number of channels in this layout.
AVChannelCustom * map
This member must be used when the channel order is AV_CHANNEL_ORDER_CUSTOM.
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.
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.
int64_t duration
Duration of the frame, in the same units as pts.
AVChannelLayout ch_layout
Channel layout of the audio data.