#include "libavutil/audioconvert.h"
#include "libavutil/audio_fifo.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/samplefmt.h"
#include "audio.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
Go to the source code of this file.
Data Structures | |
struct | FrameInfo |
struct | FrameList |
Linked list used to store timestamps and frame sizes of all frames in the FIFO for the first input. More... | |
struct | MixContext |
Defines | |
#define | INPUT_OFF 0 |
input has reached EOF | |
#define | INPUT_ON 1 |
input is active | |
#define | INPUT_INACTIVE 2 |
input is on, but is currently inactive | |
#define | DURATION_LONGEST 0 |
#define | DURATION_SHORTEST 1 |
#define | DURATION_FIRST 2 |
#define | OFFSET(x) offsetof(MixContext, x) |
#define | A AV_OPT_FLAG_AUDIO_PARAM |
Functions | |
static void | frame_list_clear (FrameList *frame_list) |
static int | frame_list_next_frame_size (FrameList *frame_list) |
static int64_t | frame_list_next_pts (FrameList *frame_list) |
static void | frame_list_remove_samples (FrameList *frame_list, int nb_samples) |
static int | frame_list_add_frame (FrameList *frame_list, int nb_samples, int64_t pts) |
static void | calculate_scales (MixContext *s, int nb_samples) |
Update the scaling factors to apply to each input during mixing. | |
static int | config_output (AVFilterLink *outlink) |
static void | vector_fmac_scalar (float *dst, const float *src, float mul, int len) |
static int | output_frame (AVFilterLink *outlink, int nb_samples) |
Read samples from the input FIFOs, mix, and write to the output link. | |
static int | get_available_samples (MixContext *s) |
Returns the smallest number of samples available in the input FIFOs other than that of the first input. | |
static int | request_samples (AVFilterContext *ctx, int min_samples) |
Requests a frame, if needed, from each input link other than the first. | |
static int | calc_active_inputs (MixContext *s) |
Calculates the number of active inputs and determines EOF based on the duration option. | |
static int | request_frame (AVFilterLink *outlink) |
static void | filter_samples (AVFilterLink *inlink, AVFilterBufferRef *buf) |
static int | init (AVFilterContext *ctx, const char *args, void *opaque) |
static void | uninit (AVFilterContext *ctx) |
static int | query_formats (AVFilterContext *ctx) |
Variables | |
static const AVOption | options [] |
static const AVClass | amix_class |
AVFilter | avfilter_af_amix |
Mixes audio from multiple sources into a single output. The channel layout, sample rate, and sample format will be the same for all inputs and the output.
Definition in file af_amix.c.
#define DURATION_FIRST 2 |
#define DURATION_SHORTEST 1 |
#define INPUT_INACTIVE 2 |
#define INPUT_OFF 0 |
input has reached EOF
Definition at line 44 of file af_amix.c.
Referenced by calc_active_inputs(), get_available_samples(), request_frame(), and request_samples().
#define INPUT_ON 1 |
input is active
Definition at line 45 of file af_amix.c.
Referenced by calculate_scales(), config_output(), and output_frame().
#define OFFSET | ( | x | ) | offsetof(MixContext, x) |
static int calc_active_inputs | ( | MixContext * | s | ) | [static] |
Calculates the number of active inputs and determines EOF based on the duration option.
Definition at line 370 of file af_amix.c.
Referenced by request_frame().
static void calculate_scales | ( | MixContext * | s, | |
int | nb_samples | |||
) | [static] |
Update the scaling factors to apply to each input during mixing.
This balances the full volume range between active inputs and handles volume transitions when EOF is encountered on an input but mixing continues with the remaining inputs.
Definition at line 202 of file af_amix.c.
Referenced by config_output(), and output_frame().
static int config_output | ( | AVFilterLink * | outlink | ) | [static] |
static void filter_samples | ( | AVFilterLink * | inlink, | |
AVFilterBufferRef * | buf | |||
) | [static] |
static int frame_list_add_frame | ( | FrameList * | frame_list, | |
int | nb_samples, | |||
int64_t | pts | |||
) | [static] |
static void frame_list_clear | ( | FrameList * | frame_list | ) | [static] |
static int frame_list_next_frame_size | ( | FrameList * | frame_list | ) | [static] |
static int64_t frame_list_next_pts | ( | FrameList * | frame_list | ) | [static] |
static void frame_list_remove_samples | ( | FrameList * | frame_list, | |
int | nb_samples | |||
) | [static] |
static int get_available_samples | ( | MixContext * | s | ) | [static] |
Returns the smallest number of samples available in the input FIFOs other than that of the first input.
Definition at line 318 of file af_amix.c.
Referenced by request_frame().
static int init | ( | AVFilterContext * | ctx, | |
const char * | args, | |||
void * | opaque | |||
) | [static] |
static int output_frame | ( | AVFilterLink * | outlink, | |
int | nb_samples | |||
) | [static] |
Read samples from the input FIFOs, mix, and write to the output link.
Definition at line 277 of file af_amix.c.
Referenced by request_frame().
static int query_formats | ( | AVFilterContext * | ctx | ) | [static] |
static int request_frame | ( | AVFilterLink * | outlink | ) | [static] |
static int request_samples | ( | AVFilterContext * | ctx, | |
int | min_samples | |||
) | [static] |
Requests a frame, if needed, from each input link other than the first.
Definition at line 340 of file af_amix.c.
Referenced by request_frame().
static void uninit | ( | AVFilterContext * | ctx | ) | [static] |
static void vector_fmac_scalar | ( | float * | dst, | |
const float * | src, | |||
float | mul, | |||
int | len | |||
) | [static] |
const AVClass amix_class [static] |
Initial value:
{ .class_name = "amix filter", .item_name = av_default_item_name, .option = options, .version = LIBAVUTIL_VERSION_INT, }
Initial value:
{ .name = "amix", .description = NULL_IF_CONFIG_SMALL("Audio mixing."), .priv_size = sizeof(MixContext), .init = init, .uninit = uninit, .query_formats = query_formats, .inputs = (const AVFilterPad[]) {{ .name = NULL}}, .outputs = (const AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_AUDIO, .config_props = config_output, .request_frame = request_frame }, { .name = NULL}}, }
Initial value:
{ { "inputs", "Number of inputs.", OFFSET(nb_inputs), AV_OPT_TYPE_INT, { 2 }, 1, 32, A }, { "duration", "How to determine the end-of-stream.", OFFSET(duration_mode), AV_OPT_TYPE_INT, { DURATION_LONGEST }, 0, 2, A, "duration" }, { "longest", "Duration of longest input.", 0, AV_OPT_TYPE_CONST, { DURATION_LONGEST }, INT_MIN, INT_MAX, A, "duration" }, { "shortest", "Duration of shortest input.", 0, AV_OPT_TYPE_CONST, { DURATION_SHORTEST }, INT_MIN, INT_MAX, A, "duration" }, { "first", "Duration of first input.", 0, AV_OPT_TYPE_CONST, { DURATION_FIRST }, INT_MIN, INT_MAX, A, "duration" }, { "dropout_transition", "Transition time, in seconds, for volume " "renormalization when an input stream ends.", OFFSET(dropout_transition), AV_OPT_TYPE_FLOAT, { 2.0 }, 0, INT_MAX, A }, { NULL }, }