51 #define DURATION_LONGEST 0 52 #define DURATION_SHORTEST 1 53 #define DURATION_FIRST 2 80 while (frame_list->
list) {
93 if (!frame_list->
list)
100 if (!frame_list->
list)
111 while (samples > 0) {
117 if (!frame_list->
list)
124 info->
pts += samples;
141 if (!frame_list->
list) {
142 frame_list->
list = info;
143 frame_list->
end = info;
147 frame_list->
end = info;
180 #define OFFSET(x) offsetof(MixContext, x) 181 #define A AV_OPT_FLAG_AUDIO_PARAM 182 #define F AV_OPT_FLAG_FILTERING_PARAM 184 {
"inputs",
"Number of inputs.",
186 {
"duration",
"How to determine the end-of-stream.",
191 {
"dropout_transition",
"Transition time, in seconds, for volume " 192 "renormalization when an input stream ends.",
194 {
"weights",
"Set weight for each input.",
210 float weight_sum = 0.f;
279 "inputs:%d fmt:%s srate:%d cl:%s\n", s->
nb_inputs,
301 if (ns < nb_samples) {
312 nb_samples = INT_MAX;
316 nb_samples =
FFMIN(nb_samples, ns);
319 if (nb_samples == INT_MAX) {
345 int planes, plane_size, p;
352 plane_size =
FFALIGN(plane_size, 16);
356 for (p = 0; p <
planes; p++) {
362 for (p = 0; p <
planes; p++) {
409 int active_inputs = 0;
414 if (!active_inputs ||
507 char *p, *
arg, *saveptr =
NULL;
508 float last_weight = 1.f;
535 if (!(arg =
av_strtok(p,
" ", &saveptr)))
539 sscanf(arg,
"%f", &last_weight);
615 .priv_class = &amix_class,
621 .
outputs = avfilter_af_amix_outputs,
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples)
Read data from an AVAudioFifo.
This structure describes decoded (raw) audio or video data.
Main libavfilter public API header.
static av_cold void uninit(AVFilterContext *ctx)
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
enum AVMediaType type
AVFilterPad type.
static int frame_list_next_frame_size(FrameList *frame_list)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
static int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
Macro definitions for various function/variable attributes.
Linked list used to store timestamps and frame sizes of all frames in the FIFO for the first input...
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
#define av_assert0(cond)
assert() equivalent, that is always enabled.
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.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static int activate(AVFilterContext *ctx)
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.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
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 AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
float dropout_transition
transition time when an input drops out
FrameList * frame_list
list of frame info for the first input
float * input_scale
mixing scale factor for each input
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
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.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
AVAudioFifo ** fifos
audio fifo for each input
void(* vector_dmac_scalar)(double *dst, const double *src, double mul, int len)
Multiply a vector of doubles by a scalar double and add to destination vector.
AVFilterPad * input_pads
array of input pads
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
int sample_rate
samples per second
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#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
uint64_t * channel_layouts
list of channel layouts
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
simple assert() macros that are a bit more flexible than ISO C assert().
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
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.
Context for an Audio FIFO Buffer.
char * av_asprintf(const char *fmt,...)
int active_inputs
number of input currently active
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
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
float weight_sum
sum of custom weights for every input
int nb_channels
number of channels
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
int format
agreed upon media format
static int frame_list_add_frame(FrameList *frame_list, int nb_samples, int64_t pts)
A list of supported channel layouts.
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.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
uint8_t * input_state
current state of each input
float * scale_norm
normalization factor for every input
char * weights_str
string for custom weights for every input
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
const char * name
Filter name.
static int output_frame(AVFilterLink *outlink)
Read samples from the input FIFOs, mix, and write to the output link.
#define INPUT_ON
input is active
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
int64_t next_pts
calculated pts for next output frame
#define DURATION_SHORTEST
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples)
Write data to an AVAudioFifo.
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok()...
#define INPUT_EOF
input has reached EOF (may still be active)
static void calculate_scales(MixContext *s, int nb_samples)
Update the scaling factors to apply to each input during mixing.
common internal and external API header
AVFILTER_DEFINE_CLASS(amix)
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
int channels
Number of channels.
static const struct @272 planes[]
static const AVOption amix_options[]
float * weights
custom weights for every input
int nb_inputs
number of inputs
static av_cold int init(AVFilterContext *ctx)
static int config_output(AVFilterLink *outlink)
uint8_t ** extended_data
pointers to the data planes/channels.
int nb_samples
number of audio samples (per channel) described by this frame
static void frame_list_clear(FrameList *frame_list)
#define AV_NOPTS_VALUE
Undefined timestamp value.
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
static int ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.