VLC  2.1.0-git
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
common.c File Reference
Include dependency graph for common.c:

Macros

#define REORDER_TYPE(type)
#define INTERLEAVE_TYPE(type)
#define DEINTERLEAVE_TYPE(type)

Functions

unsigned int aout_BitsPerSample (vlc_fourcc_t i_format)
void aout_FormatPrepare (audio_sample_format_t *p_format)
const char * aout_FormatPrintChannels (const audio_sample_format_t *p_format)
void aout_FormatPrint (((vlc_object_t *)(vlc_object_t *obj)), const char *psz_text, const audio_sample_format_t *p_format)
 Prints an audio sample format in a human-readable form.
void aout_FormatsPrint (((vlc_object_t *)(vlc_object_t *obj)), const char *psz_text, const audio_sample_format_t *p_format1, const audio_sample_format_t *p_format2)
 Prints two formats in a human-readable form.
unsigned aout_CheckChannelReorder (const uint32_t *chans_in, const uint32_t *chans_out, uint32_t mask, uint8_t *restrict table)
void aout_ChannelReorder (void *ptr, size_t bytes, unsigned channels, const uint8_t *restrict chans_table, vlc_fourcc_t fourcc)
 Reorders audio samples within a block of linear audio interleaved samples.
void aout_Interleave (void *restrict dst, const void *restrict src, unsigned samples, unsigned chans, vlc_fourcc_t fourcc)
 Interleaves audio samples within a block of samples.
void aout_Deinterleave (void *restrict dst, const void *restrict src, unsigned samples, unsigned chans, vlc_fourcc_t fourcc)
 Deinterleaves audio samples within a block of samples.
static void ExtractChannel (uint8_t *pi_dst, int i_dst_channels, const uint8_t *pi_src, int i_src_channels, int i_sample_count, const int *pi_selection, int i_bytes)
void aout_ChannelExtract (void *p_dst, int i_dst_channels, const void *p_src, int i_src_channels, int i_sample_count, const int *pi_selection, int i_bits_per_sample)
 Do the actual channels extraction using the parameters created by aout_CheckChannelExtraction.
bool aout_CheckChannelExtraction (int *pi_selection, uint32_t *pi_layout, int *pi_channels, const uint32_t pi_order_dst[9], const uint32_t *pi_order_src, int i_channels)
 This fonction will compute the extraction parameter into pi_selection to go from i_channels with their type given by pi_order_src[] into the order describe by pi_order_dst.
static int FilterOrder (const char *psz_name)
bool aout_ChangeFilterString (vlc_object_t *p_obj, vlc_object_t *p_aout, const char *psz_variable, const char *psz_name, bool b_add)

Macro Definition Documentation

#define DEINTERLEAVE_TYPE (   type)
Value:
do { \
type *d = dst; \
const type *s = src; \
for( size_t i = 0; i < chans; i++ ) { \
for( size_t j = 0, k = 0; j < samples; j++, k += chans ) \
*(d++) = s[k]; \
s++; \
} \
} while(0)

Referenced by aout_Deinterleave().

#define INTERLEAVE_TYPE (   type)
Value:
do { \
type *d = dst; \
const type *s = src; \
for( size_t i = 0; i < chans; i++ ) { \
for( size_t j = 0, k = 0; j < samples; j++, k += chans ) \
d[k] = *(s++); \
d++; \
} \
} while(0)

Referenced by aout_Interleave().

#define REORDER_TYPE (   type)
Value:
do { \
const size_t frames = (bytes / sizeof (type)) / channels; \
type *buf = ptr; \
\
for( size_t i = 0; i < frames; i++ ) \
{ \
float tmp[AOUT_CHAN_MAX]; \
\
for( size_t j = 0; j < channels; j++ ) \
tmp[chans_table[j]] = buf[j]; \
memcpy( buf, tmp, sizeof (type) * channels ); \
buf += channels; \
} \
} while(0)

Referenced by aout_ChannelReorder().

Function Documentation

unsigned int aout_BitsPerSample ( vlc_fourcc_t  i_format)
bool aout_ChangeFilterString ( vlc_object_t p_obj,
vlc_object_t p_aout,
const char *  psz_variable,
const char *  psz_name,
bool  b_add 
)
void aout_ChannelExtract ( void *  p_dst,
int  i_dst_channels,
const void *  p_src,
int  i_src_channels,
int  i_sample_count,
const int *  pi_selection,
int  i_bits_per_sample 
)

Do the actual channels extraction using the parameters created by aout_CheckChannelExtraction.

XXX this function does not work in place (p_dst and p_src must not overlap). XXX Only 8, 16, 24, 32, 64 bits per sample are supported.

References ExtractChannel().

void aout_ChannelReorder ( void *  ptr,
size_t  bytes,
unsigned  channels,
const uint8_t *restrict  chans_table,
vlc_fourcc_t  fourcc 
)

Reorders audio samples within a block of linear audio interleaved samples.

Parameters
ptrstart address of the block of samples
bytessize of the block in bytes (must be a multiple of the product of the channels count and the sample size)
channelschannels count (also length of the chans_table table)
chans_tablepermutation table to reorder the channels (usually computed by aout_CheckChannelReorder())
fourccsample format (must be a linear sample format)
Note
The samples must be naturally aligned in memory.

References aout_BitsPerSample(), AOUT_CHAN_MAX, REORDER_TYPE, VLC_CODEC_FL32, VLC_CODEC_FL64, VLC_CODEC_S16N, VLC_CODEC_S32N, and VLC_CODEC_U8.

bool aout_CheckChannelExtraction ( int *  pi_selection,
uint32_t *  pi_layout,
int *  pi_channels,
const uint32_t  pi_order_dst[9],
const uint32_t *  pi_order_src,
int  i_channels 
)

This fonction will compute the extraction parameter into pi_selection to go from i_channels with their type given by pi_order_src[] into the order describe by pi_order_dst.

It will also set :

  • *pi_channels as the number of channels that will be extracted which is lower (in case of non understood channels type) or equal to i_channels.
  • the layout of the channels (*pi_layout).

It will return true if channel extraction is really needed, in which case aout_ChannelExtract must be used

XXX It must be used when the source may have channel type not understood by VLC. In this case the channel type pi_order_src[] must be set to 0. XXX It must also be used if multiple channels have the same type.

References AOUT_CHAN_CENTER, AOUT_CHAN_DUALMONO, AOUT_CHAN_LEFT, AOUT_CHAN_MAX, AOUT_CHAN_RIGHT, and pi_vlc_chan_order_wg4.

unsigned aout_CheckChannelReorder ( const uint32_t *  chans_in,
const uint32_t *  chans_out,
uint32_t  mask,
uint8_t *restrict  table 
)

References pi_vlc_chan_order_wg4.

void aout_Deinterleave ( void *restrict  dst,
const void *restrict  src,
unsigned  samples,
unsigned  chans,
vlc_fourcc_t  fourcc 
)

Deinterleaves audio samples within a block of samples.

Parameters
dstdestination buffer for planar samples
srcsource buffer with interleaved samples
samplesnumber of samples (per channel/per plane)
chanschannels/planes count
fourccsample format (must be a linear sample format)
Note
The samples must be naturally aligned in memory.
Warning
Destination and source buffers MUST NOT overlap.

References DEINTERLEAVE_TYPE, VLC_CODEC_FL32, VLC_CODEC_FL64, VLC_CODEC_S16N, VLC_CODEC_S32N, and VLC_CODEC_U8.

void aout_FormatPrepare ( audio_sample_format_t p_format)
void aout_FormatPrint ( ((vlc_object_t *)(vlc_object_t *obj))  ,
const char *  psz_text,
const audio_sample_format_t p_format 
)
const char* aout_FormatPrintChannels ( const audio_sample_format_t p_format)
void aout_FormatsPrint ( ((vlc_object_t *)(vlc_object_t *obj))  ,
const char *  psz_text,
const audio_sample_format_t p_format1,
const audio_sample_format_t p_format2 
)

Prints two formats in a human-readable form.

References aout_FormatPrintChannels(), audio_format_t::i_format, audio_format_t::i_rate, and msg_Dbg.

void aout_Interleave ( void *restrict  dst,
const void *restrict  src,
unsigned  samples,
unsigned  chans,
vlc_fourcc_t  fourcc 
)

Interleaves audio samples within a block of samples.

Parameters
dstdestination buffer for interleaved samples
srcsource buffer with consecutive planes of samples
samplesnumber of samples (per channel/per plane)
chanschannels/planes count
fourccsample format (must be a linear sample format)
Note
The samples must be naturally aligned in memory.
Warning
Destination and source buffers MUST NOT overlap.

References INTERLEAVE_TYPE, VLC_CODEC_FL32, VLC_CODEC_FL64, VLC_CODEC_S16N, VLC_CODEC_S32N, and VLC_CODEC_U8.

static void ExtractChannel ( uint8_t *  pi_dst,
int  i_dst_channels,
const uint8_t *  pi_src,
int  i_src_channels,
int  i_sample_count,
const int *  pi_selection,
int  i_bytes 
)
inlinestatic

Referenced by aout_ChannelExtract().

static int FilterOrder ( const char *  psz_name)
static

References ARRAY_SIZE.

Referenced by aout_ChangeFilterString().