Go to the documentation of this file.
48 #define OFFSET(x) offsetof(AMergeContext, x)
49 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
52 {
"inputs",
"specify the number of inputs",
OFFSET(nb_inputs),
80 int i,
ret, overlap = 0, nb_ch = 0;
82 for (
i = 0;
i <
s->nb_inputs;
i++) {
83 if (!
ctx->inputs[
i]->incfg.channel_layouts ||
84 !
ctx->inputs[
i]->incfg.channel_layouts->nb_channel_layouts) {
86 "No channel layout for input %d\n",
i + 1);
89 inlayout[
i] = &
ctx->inputs[
i]->incfg.channel_layouts->channel_layouts[0];
90 if (
ctx->inputs[
i]->incfg.channel_layouts->nb_channel_layouts > 1) {
105 nb_ch +=
s->in[
i].nb_ch;
113 "Input channel layouts overlap: "
114 "output layout will be determined by the number of distinct input channels\n");
115 for (
i = 0;
i < nb_ch;
i++)
118 if (!
KNOWN(&outlayout) && nb_ch)
122 int c, out_ch_number = 0;
126 for (
i = 1;
i <
s->nb_inputs;
i++)
127 route[
i] = route[
i - 1] +
s->in[
i - 1].nb_ch;
129 for (
i = 0;
i <
s->nb_inputs;
i++)
131 *(route[
i]++) = out_ch_number++;
135 for (
i = 0;
i <
s->nb_inputs;
i++) {
162 for (
i = 0;
i <
s->nb_inputs;
i++) {
189 static inline void copy_samples(
int nb_inputs,
struct amerge_input in[],
190 int *route, uint8_t *ins[],
191 uint8_t **outs,
int ns,
int bps)
196 for (
i = 0;
i < nb_inputs;
i++)
197 nb_ch += in[
i].nb_ch;
200 for (
i = 0;
i < nb_inputs;
i++) {
201 for (
c = 0;
c < in[
i].nb_ch;
c++) {
202 memcpy((*outs) +
bps * *(route_cur++), ins[
i],
bps);
206 *outs += nb_ch *
bps;
213 for (
i = 0;
i < nb_inputs;
i++)
225 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
231 ins[
i] = inbuf[
i]->
data[0];
240 outs = outbuf->
data[0];
241 outbuf->
pts = inbuf[0]->
pts;
259 copy_samples(
s->nb_inputs,
s->in,
s->route, ins, &outs, nb_samples, 1);
262 copy_samples(
s->nb_inputs,
s->in,
s->route, ins, &outs, nb_samples, 2);
265 copy_samples(
s->nb_inputs,
s->in,
s->route, ins, &outs, nb_samples, 4);
268 copy_samples(
s->nb_inputs,
s->in,
s->route, ins, &outs, nb_samples,
s->bps);
288 for (
i = 1;
i <
ctx->nb_inputs && nb_samples > 0;
i++) {
298 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
322 for (
i = 0;
i <
s->nb_inputs;
i++) {
347 "a single multi-channel stream."),
355 .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
const AVFilter ff_af_amerge
char * av_asprintf(const char *fmt,...)
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
#define AV_LOG_VERBOSE
Detailed information.
enum AVChannelOrder order
Channel order used in this layout.
const char * name
Filter name.
uint64_t mask
This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC ...
int nb_channels
Number of channels in this layout.
A link between two filters.
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)
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.
int ff_append_inpad_free_name(AVFilterContext *f, AVFilterPad *p)
struct AMergeContext::amerge_input * in
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
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
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
#define ns(max_value, name, subs,...)
#define AV_LOG_INFO
Standard information.
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,...)
static int config_output(AVFilterLink *outlink)
uint64_t av_channel_layout_subset(const AVChannelLayout *channel_layout, uint64_t mask)
Find out what channels from a given set are present in a channel layout, without regard for their pos...
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.
@ AV_OPT_TYPE_INT
Underlying C type is int.
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::@410 u
Details about which channels are present in this layout.
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
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
#define FILTER_QUERY_FUNC(func)