libavresample/audio_mix_matrix.c File Reference

#include <stdint.h>
#include "libavutil/common.h"
#include "libavutil/libm.h"
#include "libavutil/samplefmt.h"
#include "avresample.h"
#include "internal.h"
#include "audio_data.h"
#include "audio_mix.h"

Go to the source code of this file.

Defines

#define FRONT_LEFT   0
#define FRONT_RIGHT   1
#define FRONT_CENTER   2
#define LOW_FREQUENCY   3
#define BACK_LEFT   4
#define BACK_RIGHT   5
#define FRONT_LEFT_OF_CENTER   6
#define FRONT_RIGHT_OF_CENTER   7
#define BACK_CENTER   8
#define SIDE_LEFT   9
#define SIDE_RIGHT   10
#define TOP_CENTER   11
#define TOP_FRONT_LEFT   12
#define TOP_FRONT_CENTER   13
#define TOP_FRONT_RIGHT   14
#define TOP_BACK_LEFT   15
#define TOP_BACK_CENTER   16
#define TOP_BACK_RIGHT   17
#define STEREO_LEFT   29
#define STEREO_RIGHT   30
#define WIDE_LEFT   31
#define WIDE_RIGHT   32
#define SURROUND_DIRECT_LEFT   33
#define SURROUND_DIRECT_RIGHT   34
#define LOW_FREQUENCY_2   35
#define SQRT3_2   1.22474487139158904909
#define CONVERT_MATRIX(type, expr)

Functions

static av_always_inline int even (uint64_t layout)
static int sane_layout (uint64_t layout)
int avresample_build_matrix (uint64_t in_layout, uint64_t out_layout, double center_mix_level, double surround_mix_level, double lfe_mix_level, int normalize, double *matrix_out, int stride, enum AVMatrixEncoding matrix_encoding)
 Generate a channel mixing matrix.
int avresample_get_matrix (AVAudioResampleContext *avr, double *matrix, int stride)
 Get the current channel mixing matrix.
int avresample_set_matrix (AVAudioResampleContext *avr, const double *matrix, int stride)
 Set channel mixing matrix.


Define Documentation

#define BACK_CENTER   8

Definition at line 41 of file audio_mix_matrix.c.

Referenced by auto_matrix(), and avresample_build_matrix().

#define BACK_LEFT   4

Definition at line 37 of file audio_mix_matrix.c.

Referenced by auto_matrix(), and avresample_build_matrix().

#define BACK_RIGHT   5

Definition at line 38 of file audio_mix_matrix.c.

Referenced by auto_matrix(), and avresample_build_matrix().

#define CONVERT_MATRIX ( type,
expr   ) 

Value:

avr->am->matrix_## type[0] = av_mallocz(out_channels * in_channels *    \
                                            sizeof(*avr->am->matrix_## type[0])); \
    if (!avr->am->matrix_## type[0])                                        \
        return AVERROR(ENOMEM);                                             \
    for (o = 0; o < out_channels; o++) {                                    \
        if (o > 0)                                                          \
            avr->am->matrix_## type[o] = avr->am->matrix_## type[o - 1] +   \
                                         in_channels;                       \
        for (i = 0; i < in_channels; i++) {                                 \
            double v = matrix[o * stride + i];                              \
            avr->am->matrix_## type[o][i] = expr;                           \
        }                                                                   \
    }                                                                       \
    avr->am->matrix = (void **)avr->am->matrix_## type;

Referenced by avresample_set_matrix().

#define FRONT_CENTER   2

Definition at line 35 of file audio_mix_matrix.c.

Referenced by auto_matrix(), and avresample_build_matrix().

#define FRONT_LEFT   0

Definition at line 33 of file audio_mix_matrix.c.

Referenced by auto_matrix(), and avresample_build_matrix().

#define FRONT_LEFT_OF_CENTER   6

Definition at line 39 of file audio_mix_matrix.c.

Referenced by auto_matrix(), and avresample_build_matrix().

#define FRONT_RIGHT   1

Definition at line 34 of file audio_mix_matrix.c.

Referenced by auto_matrix(), and avresample_build_matrix().

#define FRONT_RIGHT_OF_CENTER   7

Definition at line 40 of file audio_mix_matrix.c.

Referenced by auto_matrix(), and avresample_build_matrix().

#define LOW_FREQUENCY   3

Definition at line 36 of file audio_mix_matrix.c.

Referenced by auto_matrix(), and avresample_build_matrix().

#define LOW_FREQUENCY_2   35

Definition at line 57 of file audio_mix_matrix.c.

#define SIDE_LEFT   9

Definition at line 42 of file audio_mix_matrix.c.

Referenced by auto_matrix(), and avresample_build_matrix().

#define SIDE_RIGHT   10

Definition at line 43 of file audio_mix_matrix.c.

Referenced by auto_matrix(), and avresample_build_matrix().

#define SQRT3_2   1.22474487139158904909

Definition at line 59 of file audio_mix_matrix.c.

Referenced by auto_matrix(), and avresample_build_matrix().

#define STEREO_LEFT   29

Definition at line 51 of file audio_mix_matrix.c.

#define STEREO_RIGHT   30

Definition at line 52 of file audio_mix_matrix.c.

#define SURROUND_DIRECT_LEFT   33

Definition at line 55 of file audio_mix_matrix.c.

#define SURROUND_DIRECT_RIGHT   34

Definition at line 56 of file audio_mix_matrix.c.

#define TOP_BACK_CENTER   16

Definition at line 49 of file audio_mix_matrix.c.

#define TOP_BACK_LEFT   15

Definition at line 48 of file audio_mix_matrix.c.

#define TOP_BACK_RIGHT   17

Definition at line 50 of file audio_mix_matrix.c.

#define TOP_CENTER   11

Definition at line 44 of file audio_mix_matrix.c.

#define TOP_FRONT_CENTER   13

Definition at line 46 of file audio_mix_matrix.c.

#define TOP_FRONT_LEFT   12

Definition at line 45 of file audio_mix_matrix.c.

#define TOP_FRONT_RIGHT   14

Definition at line 47 of file audio_mix_matrix.c.

#define WIDE_LEFT   31

Definition at line 53 of file audio_mix_matrix.c.

#define WIDE_RIGHT   32

Definition at line 54 of file audio_mix_matrix.c.


Function Documentation

int avresample_build_matrix ( uint64_t  in_layout,
uint64_t  out_layout,
double  center_mix_level,
double  surround_mix_level,
double  lfe_mix_level,
int  normalize,
double *  matrix,
int  stride,
enum AVMatrixEncoding  matrix_encoding 
)

Generate a channel mixing matrix.

This function is the one used internally by libavresample for building the default mixing matrix. It is made public just as a utility function for building custom matrices.

Parameters:
in_layout input channel layout
out_layout output channel layout
center_mix_level mix level for the center channel
surround_mix_level mix level for the surround channel(s)
lfe_mix_level mix level for the low-frequency effects channel
normalize if 1, coefficients will be normalized to prevent overflow. if 0, coefficients will not be normalized.
[out] matrix mixing coefficients; matrix[i + stride * o] is the weight of input channel i in output channel o.
stride distance between adjacent input channels in the matrix array
matrix_encoding matrixed stereo downmix mode (e.g. dplii)
Returns:
0 on success, negative AVERROR code on failure

Definition at line 87 of file audio_mix_matrix.c.

Referenced by ff_audio_mix_init().

int avresample_get_matrix ( AVAudioResampleContext avr,
double *  matrix,
int  stride 
)

Get the current channel mixing matrix.

Parameters:
avr audio resample context
matrix mixing coefficients; matrix[i + stride * o] is the weight of input channel i in output channel o.
stride distance between adjacent input channels in the matrix array
Returns:
0 on success, negative AVERROR code on failure

Definition at line 291 of file audio_mix_matrix.c.

Referenced by avresample_set_compensation().

int avresample_set_matrix ( AVAudioResampleContext avr,
const double *  matrix,
int  stride 
)

Set channel mixing matrix.

Allows for setting a custom mixing matrix, overriding the default matrix generated internally during avresample_open(). This function can be called anytime on an allocated context, either before or after calling avresample_open(). avresample_convert() always uses the current matrix. Calling avresample_close() on the context will clear the current matrix.

See also:
avresample_close()
Parameters:
avr audio resample context
matrix mixing coefficients; matrix[i + stride * o] is the weight of input channel i in output channel o.
stride distance between adjacent input channels in the matrix array
Returns:
0 on success, negative AVERROR code on failure

Definition at line 341 of file audio_mix_matrix.c.

Referenced by avresample_set_compensation(), and ff_audio_mix_init().

static av_always_inline int even ( uint64_t  layout  )  [static]

Definition at line 61 of file audio_mix_matrix.c.

Referenced by block_diffs(), and sane_layout().

static int sane_layout ( uint64_t  layout  )  [static]

Definition at line 66 of file audio_mix_matrix.c.

Referenced by auto_matrix(), and avresample_build_matrix().


Generated on Fri Oct 26 02:50:11 2012 for FFmpeg by  doxygen 1.5.8