Go to the documentation of this file.
47 #define OFFSET(x) offsetof(AMergeContext, x)
48 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
51 {
"inputs",
"specify the number of inputs",
OFFSET(nb_inputs),
79 int i,
ret, overlap = 0, nb_ch = 0;
81 for (
i = 0;
i <
s->nb_inputs;
i++) {
82 if (!
ctx->inputs[
i]->incfg.channel_layouts ||
83 !
ctx->inputs[
i]->incfg.channel_layouts->nb_channel_layouts) {
85 "No channel layout for input %d\n",
i + 1);
88 inlayout[
i] = &
ctx->inputs[
i]->incfg.channel_layouts->channel_layouts[0];
89 if (
ctx->inputs[
i]->incfg.channel_layouts->nb_channel_layouts > 1) {
104 nb_ch +=
s->in[
i].nb_ch;
112 "Input channel layouts overlap: "
113 "output layout will be determined by the number of distinct input channels\n");
114 for (
i = 0;
i < nb_ch;
i++)
117 if (!
KNOWN(&outlayout) && nb_ch)
121 int c, out_ch_number = 0;
125 for (
i = 1;
i <
s->nb_inputs;
i++)
126 route[
i] = route[
i - 1] +
s->in[
i - 1].nb_ch;
128 for (
i = 0;
i <
s->nb_inputs;
i++)
130 *(route[
i]++) = out_ch_number++;
134 for (
i = 0;
i <
s->nb_inputs;
i++) {
162 for (
i = 0;
i <
s->nb_inputs;
i++) {
191 static inline void copy_samples(
int nb_inputs,
struct amerge_input in[],
192 int *route, uint8_t *ins[],
193 uint8_t **outs,
int ns,
int bps)
198 for (
i = 0;
i < nb_inputs;
i++)
199 nb_ch += in[
i].nb_ch;
202 for (
i = 0;
i < nb_inputs;
i++) {
203 for (
c = 0;
c < in[
i].nb_ch;
c++) {
204 memcpy((*outs) +
bps * *(route_cur++), ins[
i],
bps);
208 *outs += nb_ch *
bps;
215 for (
i = 0;
i < nb_inputs;
i++)
227 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
233 ins[
i] = inbuf[
i]->
data[0];
242 outs = outbuf->
data[0];
243 outbuf->
pts = inbuf[0]->
pts;
248 #if FF_API_OLD_CHANNEL_LAYOUT
260 copy_samples(
s->nb_inputs,
s->in,
s->route, ins, &outs, nb_samples, 1);
263 copy_samples(
s->nb_inputs,
s->in,
s->route, ins, &outs, nb_samples, 2);
266 copy_samples(
s->nb_inputs,
s->in,
s->route, ins, &outs, nb_samples, 4);
269 copy_samples(
s->nb_inputs,
s->in,
s->route, ins, &outs, nb_samples,
s->bps);
289 for (
i = 1;
i <
ctx->nb_inputs && nb_samples > 0;
i++) {
299 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
323 for (
i = 0;
i <
s->nb_inputs;
i++) {
348 "a single multi-channel stream."),
356 .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.
#define FF_ENABLE_DEPRECATION_WARNINGS
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
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
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.
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 FILTER_QUERY_FUNC(func)
#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.
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.
attribute_deprecated int channels
number of audio channels, only used for audio.
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
attribute_deprecated uint64_t channel_layout
Channel layout of the audio data.
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)
FF_ENABLE_DEPRECATION_WARNINGS 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)
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.
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 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.
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.
#define FF_DISABLE_DEPRECATION_WARNINGS
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
#define FILTER_OUTPUTS(array)
union AVChannelLayout::@314 u
Details about which channels are present in this layout.
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