Go to the documentation of this file.
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++) {
225 static 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,
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
A list of supported channel layouts.
#define AV_LOG_WARNING
Something somehow does not look correct.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static int try_push_frame(AVFilterContext *ctx, int nb_samples)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int64_t duration
Duration of the frame, in the same units as pts.
enum MovChannelLayoutTag * layouts
char * av_asprintf(const char *fmt,...)
AVChannelCustom * map
This member must be used when the channel order is AV_CHANNEL_ORDER_CUSTOM.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static const AVFilterPad amerge_outputs[]
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int route[SWR_CH_MAX]
channels routing, see copy_samples
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.
#define AV_LOG_VERBOSE
Detailed information.
enum AVChannelOrder order
Channel order used in this layout.
const char * name
Filter name.
int nb_channels
Number of channels in this layout.
A link between two filters.
const FFFilter ff_af_amerge
int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout, AVBPrint *bp)
bprint variant of av_channel_layout_describe().
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold void uninit(AVFilterContext *ctx)
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
static av_cold int init(AVFilterContext *ctx)
#define AV_BPRINT_SIZE_AUTOMATIC
AVChannelLayout ch_layout
Channel layout of the audio data.
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
static const AVOption amerge_options[]
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
static int query_formats(AVFilterContext *ctx)
@ AV_CHAN_UNKNOWN
Channel contains data, but its position is unknown.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
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.
static int activate(AVFilterContext *ctx)
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define FILTER_OUTPUTS(array)
int nb_ch
number of channels for the input
Describe the class of an AVClass context structure.
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.
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL
The specified retype target order is ignored and the simplest possible (canonical) order is used for ...
int ff_append_inpad_free_name(AVFilterContext *f, AVFilterPad *p)
struct AMergeContext::amerge_input * in
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
An AVChannelLayout holds information about the channel layout of audio data.
int format
agreed upon media format
static AVRational av_make_q(int num, int den)
Create an AVRational.
AVFilterContext * src
source filter
int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrder order, int flags)
Change the AVChannelOrder of a channel layout.
int layout_mode
the method for determining the output channel layout
#define AV_LOG_INFO
Standard information.
int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels)
Initialize a custom channel layout with the specified number of channels.
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
int sample_rate
samples per second
int nb_samples
number of audio samples (per channel) described by this frame
#define i(width, name, range_min, range_max)
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
@ AV_SAMPLE_FMT_U8
unsigned 8 bits
AVFILTER_DEFINE_CLASS(amerge)
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S16
signed 16 bits
const char * name
Pad name.
int ff_inlink_queued_samples(AVFilterLink *link)
void * av_calloc(size_t nmemb, size_t size)
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 void free_frames(int nb_inputs, AVFrame **input_frames)
void av_bprintf(AVBPrint *buf, const char *fmt,...)
@ AV_CHAN_NONE
Invalid channel index.
static int config_output(AVFilterLink *outlink)
@ AV_CHANNEL_ORDER_CUSTOM
The channel order does not correspond to any other predefined order and is stored as an explicit map.
@ AV_OPT_TYPE_INT
Underlying C type is int.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
union AVChannelLayout::@490 u
Details about which channels are present in this layout.
AVFilter p
The public AVFilter.
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
#define ns(max_value, name, subs,...)
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
@ AV_SAMPLE_FMT_DBL
double
@ AV_SAMPLE_FMT_S32
signed 32 bits
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
#define FILTER_QUERY_FUNC(func)