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),
78 int i,
ret, overlap = 0, nb_ch = 0;
80 for (
i = 0;
i <
s->nb_inputs;
i++) {
81 if (!
ctx->inputs[
i]->incfg.channel_layouts ||
82 !
ctx->inputs[
i]->incfg.channel_layouts->nb_channel_layouts) {
84 "No channel layout for input %d\n",
i + 1);
87 inlayout[
i] =
ctx->inputs[
i]->incfg.channel_layouts->channel_layouts[0];
88 if (
ctx->inputs[
i]->incfg.channel_layouts->nb_channel_layouts > 1) {
98 if (outlayout & inlayout[
i])
100 outlayout |= inlayout[
i];
102 nb_ch +=
s->in[
i].nb_ch;
110 "Input channel layouts overlap: "
111 "output layout will be determined by the number of distinct input channels\n");
112 for (
i = 0;
i < nb_ch;
i++)
115 if (!outlayout && nb_ch)
116 outlayout = 0xFFFFFFFFFFFFFFFFULL >> (64 - nb_ch);
119 int c, out_ch_number = 0;
122 for (
i = 1;
i <
s->nb_inputs;
i++)
123 route[
i] = route[
i - 1] +
s->in[
i - 1].nb_ch;
125 for (
i = 0;
i <
s->nb_inputs;
i++)
126 if ((inlayout[
i] >>
c) & 1)
127 *(route[
i]++) = out_ch_number++;
131 for (
i = 0;
i <
s->nb_inputs;
i++) {
158 for (
i = 0;
i <
s->nb_inputs;
i++) {
185 static inline void copy_samples(
int nb_inputs,
struct amerge_input in[],
186 int *route, uint8_t *ins[],
187 uint8_t **outs,
int ns,
int bps)
192 for (
i = 0;
i < nb_inputs;
i++)
193 nb_ch += in[
i].nb_ch;
196 for (
i = 0;
i < nb_inputs;
i++) {
197 for (
c = 0;
c < in[
i].nb_ch;
c++) {
198 memcpy((*outs) +
bps * *(route_cur++), ins[
i],
bps);
202 *outs += nb_ch *
bps;
209 for (
i = 0;
i < nb_inputs;
i++)
221 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
227 ins[
i] = inbuf[
i]->
data[0];
236 outs = outbuf->
data[0];
237 outbuf->
pts = inbuf[0]->
pts;
248 copy_samples(
s->nb_inputs,
s->in,
s->route, ins, &outs, nb_samples, 1);
251 copy_samples(
s->nb_inputs,
s->in,
s->route, ins, &outs, nb_samples, 2);
254 copy_samples(
s->nb_inputs,
s->in,
s->route, ins, &outs, nb_samples, 4);
257 copy_samples(
s->nb_inputs,
s->in,
s->route, ins, &outs, nb_samples,
s->bps);
277 for (
i = 1;
i <
ctx->nb_inputs && nb_samples > 0;
i++) {
287 for (
i = 0;
i <
ctx->nb_inputs;
i++) {
311 for (
i = 0;
i <
s->nb_inputs;
i++) {
336 "a single multi-channel stream."),
344 .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
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[]
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.
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.
const char * name
Filter name.
A link between two filters.
int channels
Number of channels.
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
#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.
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 channels
number of audio channels, only used for audio.
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.
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)
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
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
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
AVFilterContext * src
source filter
uint64_t channel_layout
Channel layout of the audio data.
#define ns(max_value, name, subs,...)
#define AV_LOG_INFO
Standard information.
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)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
int64_t av_get_default_channel_layout(int nb_channels)
Return default channel layout for a given number of channels.
#define FILTER_OUTPUTS(array)
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