48 #define INPUT_INACTIVE 2
50 #define DURATION_LONGEST 0
51 #define DURATION_SHORTEST 1
52 #define DURATION_FIRST 2
79 while (frame_list->
list) {
92 if (!frame_list->
list)
99 if (!frame_list->
list)
110 while (samples > 0) {
116 if (!frame_list->
list)
140 if (!frame_list->
list) {
141 frame_list->
list = info;
142 frame_list->
end = info;
146 frame_list->
end = info;
175 #define OFFSET(x) offsetof(MixContext, x)
176 #define A AV_OPT_FLAG_AUDIO_PARAM
178 {
"inputs",
"Number of inputs.",
180 {
"duration",
"How to determine the end-of-stream.",
185 {
"dropout_transition",
"Transition time, in seconds, for volume "
186 "renormalization when an input stream ends.",
265 "inputs:%d fmt:%s srate:%d cl:%s\n", s->
nb_inputs,
295 int planes, plane_size, p;
302 plane_size =
FFALIGN(plane_size, 16);
304 for (p = 0; p < planes; p++) {
327 int available_samples = INT_MAX;
336 available_samples =
FFMIN(available_samples, nb_samples);
338 if (available_samples == INT_MAX)
340 return available_samples;
379 int active_inputs = 0;
384 if (!active_inputs ||
396 int wanted_samples, available_samples;
412 if (!available_samples)
445 if (!available_samples)
447 available_samples =
FFMIN(available_samples, wanted_samples);
449 available_samples = wanted_samples;
466 if (ctx->
inputs[i] == inlink)
509 snprintf(name,
sizeof(name),
"input%d", i);
572 .
outputs = avfilter_af_amix_outputs,
uint8_t ** extended_data
pointers to the data planes/channels.
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples)
Write data to an AVAudioFifo.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static void uninit(AVFilterContext *ctx)
struct FrameInfo FrameInfo
AVFilterBufferRef * ff_get_audio_buffer(AVFilterLink *link, int perms, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
int nb_samples
number of audio samples
static int get_available_samples(MixContext *s)
Returns the smallest number of samples available in the input FIFOs other than that of the first inpu...
AVFilterBufferRefAudioProps * audio
audio buffer specific properties
static const AVFilterPad outputs[]
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
int ff_filter_frame(AVFilterLink *link, AVFilterBufferRef *frame)
Send a frame of data to the next filter.
int av_set_options_string(void *ctx, const char *opts, const char *key_val_sep, const char *pairs_sep)
Parse the key/value pairs list in opts.
int(* filter_frame)(AVFilterLink *link, AVFilterBufferRef *frame)
Filtering callback.
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)
struct FrameList FrameList
Linked list used to store timestamps and frame sizes of all frames in the FIFO for the first input...
struct MixContext MixContext
enum AVMediaType type
AVFilterPad type.
static enum AVSampleFormat formats[]
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
static const AVClass amix_class
static int frame_list_next_frame_size(FrameList *frame_list)
static const AVOption options[]
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Remove a reference to a buffer.
Linked list used to store timestamps and frame sizes of all frames in the FIFO for the first input...
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
void(* vector_fmac_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float and add to destination vector.
const char * name
Pad name.
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples)
Read data from an AVAudioFifo.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVFilterLink ** inputs
array of pointers to input links
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int64_t frame_list_next_pts(FrameList *frame_list)
static int request_samples(AVFilterContext *ctx, int min_samples)
Requests a frame, if needed, from each input link other than the first.
static const AVFilterPad avfilter_af_amix_outputs[]
static int calc_active_inputs(MixContext *s)
Calculates the number of active inputs and determines EOF based on the duration option.
int sample_rate
sample rate
static int query_formats(AVFilterContext *ctx)
#define INPUT_OFF
input has reached EOF
float dropout_transition
transition time when an input drops out
FrameList * frame_list
list of frame info for the first input
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
float * input_scale
mixing scale factor for each input
int64_t pts
presentation timestamp.
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
A link between two filters.
AVAudioFifo ** fifos
audio fifo for each input
AVFilterPad * input_pads
array of input pads
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
float scale_norm
normalization factor for all inputs
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
int sample_rate
samples per second
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
const AVClass * class
class for AVOptions
simple assert() macros that are a bit more flexible than ISO C assert().
void av_log(void *avcl, int level, const char *fmt,...)
AVFilter avfilter_af_amix
static int output_frame(AVFilterLink *outlink, int nb_samples)
Read samples from the input FIFOs, mix, and write to the output link.
int active_inputs
number of input currently active
struct AVRational AVRational
rational number numerator/denominator
audio channel layout utility functions
unsigned nb_inputs
number of input pads
static void frame_list_remove_samples(FrameList *frame_list, int nb_samples)
int duration_mode
mode for determining duration
AVFilterContext * src
source filter
int nb_channels
number of channels
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
int format
agreed upon media format
static int frame_list_add_frame(FrameList *frame_list, int nb_samples, int64_t pts)
A reference to an AVFilterBuffer.
static int init(AVFilterContext *ctx, const char *args)
char * av_strdup(const char *s)
Duplicate the string s.
uint8_t * input_state
current state of each input
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
const char * name
filter name
#define INPUT_ON
input is active
AVFilterLink ** outputs
array of pointers to output links
int64_t next_pts
calculated pts for next output frame
#define DURATION_SHORTEST
static void calculate_scales(MixContext *s, int nb_samples)
Update the scaling factors to apply to each input during mixing.
void av_opt_free(void *obj)
Free all string and binary options in obj.
common internal and external API header
static int request_frame(AVFilterLink *outlink)
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
#define AV_PERM_WRITE
can write to the buffer
AVFilterContext * dst
dest filter
static void ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.
int nb_inputs
number of inputs
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
static int config_output(AVFilterLink *outlink)
void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
Initialize a float DSP context.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static void frame_list_clear(FrameList *frame_list)
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.