libavcodec/ac3.c File Reference

Common code between the AC-3 encoder and decoder. More...

#include "avcodec.h"
#include "ac3.h"
#include "get_bits.h"

Go to the source code of this file.

Functions

static int calc_lowcomp1 (int a, int b0, int b1, int c)
static int calc_lowcomp (int a, int b0, int b1, int bin)
void ff_ac3_bit_alloc_calc_psd (int8_t *exp, int start, int end, int16_t *psd, int16_t *band_psd)
 Calculates the log power-spectral density of the input signal.
int ff_ac3_bit_alloc_calc_mask (AC3BitAllocParameters *s, int16_t *band_psd, int start, int end, int fast_gain, int is_lfe, int dba_mode, int dba_nsegs, uint8_t *dba_offsets, uint8_t *dba_lengths, uint8_t *dba_values, int16_t *mask)
 Calculates the masking curve.
void ff_ac3_bit_alloc_calc_bap (int16_t *mask, int16_t *psd, int start, int end, int snr_offset, int floor, const uint8_t *bap_tab, uint8_t *bap)
 Calculates bit allocation pointers.
void ac3_parametric_bit_allocation (AC3BitAllocParameters *s, uint8_t *bap, int8_t *exp, int start, int end, int snr_offset, int fast_gain, int is_lfe, int dba_mode, int dba_nsegs, uint8_t *dba_offsets, uint8_t *dba_lengths, uint8_t *dba_values)
av_cold void ac3_common_init (void)
 Initializes some tables.

Variables

static uint8_t band_start_tab [51]
static uint8_t bin_to_band_tab [253]


Detailed Description

Common code between the AC-3 encoder and decoder.

Definition in file ac3.c.


Function Documentation

av_cold void ac3_common_init ( void   ) 

Initializes some tables.

note: This function must remain thread safe because it is called by the AVParser init code.

Definition at line 268 of file ac3.c.

Referenced by ac3_decode_init(), and AC3_encode_init().

void ac3_parametric_bit_allocation ( AC3BitAllocParameters s,
uint8_t *  bap,
int8_t *  exp,
int  start,
int  end,
int  snr_offset,
int  fast_gain,
int  is_lfe,
int  dba_mode,
int  dba_nsegs,
uint8_t *  dba_offsets,
uint8_t *  dba_lengths,
uint8_t *  dba_values 
)

Definition at line 242 of file ac3.c.

static int calc_lowcomp ( int  a,
int  b0,
int  b1,
int  bin 
) [inline, static]

Definition at line 87 of file ac3.c.

Referenced by ff_ac3_bit_alloc_calc_mask().

static int calc_lowcomp1 ( int  a,
int  b0,
int  b1,
int  c 
) [inline, static]

Definition at line 77 of file ac3.c.

Referenced by calc_lowcomp(), and ff_ac3_bit_alloc_calc_mask().

void ff_ac3_bit_alloc_calc_bap ( int16_t *  mask,
int16_t *  psd,
int  start,
int  end,
int  snr_offset,
int  floor,
const uint8_t *  bap_tab,
uint8_t *  bap 
)

Calculates bit allocation pointers.

The SNR is the difference between the masking curve and the signal. AC-3 uses this value for each frequency bin to allocate bits. The snroffset parameter is a global adjustment to the SNR for all bins.

Parameters:
[in] mask masking curve
[in] psd signal power for each frequency bin
[in] start starting bin location
[in] end ending bin location
[in] snr_offset SNR adjustment
[in] floor noise floor
[in] bap_tab look-up table for bit allocation pointers
[out] bap bit allocation pointers

Definition at line 216 of file ac3.c.

Referenced by ac3_parametric_bit_allocation(), bit_alloc(), and decode_audio_block().

int ff_ac3_bit_alloc_calc_mask ( AC3BitAllocParameters s,
int16_t *  band_psd,
int  start,
int  end,
int  fast_gain,
int  is_lfe,
int  dba_mode,
int  dba_nsegs,
uint8_t *  dba_offsets,
uint8_t *  dba_lengths,
uint8_t *  dba_values,
int16_t *  mask 
)

Calculates the masking curve.

First, the excitation is calculated using parameters in s and the signal power in each critical band. The excitation is compared with a predefined hearing threshold table to produce the masking curve. If delta bit allocation information is provided, it is used for adjusting the masking curve, usually to give a closer match to a better psychoacoustic model.

Parameters:
[in] s adjustable bit allocation parameters
[in] band_psd signal power for each critical band
[in] start starting bin location
[in] end ending bin location
[in] fast_gain fast gain (estimated signal-to-mask ratio)
[in] is_lfe whether or not the channel being processed is the LFE
[in] dba_mode delta bit allocation mode (none, reuse, or new)
[in] dba_nsegs number of delta segments
[in] dba_offsets location offsets for each segment
[in] dba_lengths length of each segment
[in] dba_values delta bit allocation for each segment
[out] mask calculated masking curve
Returns:
returns 0 for success, non-zero for error

Definition at line 124 of file ac3.c.

Referenced by ac3_parametric_bit_allocation(), bit_alloc_masking(), and decode_audio_block().

void ff_ac3_bit_alloc_calc_psd ( int8_t *  exp,
int  start,
int  end,
int16_t *  psd,
int16_t *  band_psd 
)

Calculates the log power-spectral density of the input signal.

This gives a rough estimate of signal power in the frequency domain by using the spectral envelope (exponents). The psd is also separately grouped into critical bands for use in the calculating the masking curve. 128 units in psd = -6 dB. The dbknee parameter in AC3BitAllocParameters determines the reference level.

Parameters:
[in] exp frequency coefficient exponents
[in] start starting bin location
[in] end ending bin location
[out] psd signal power for each frequency bin
[out] band_psd signal power for each critical band

Definition at line 98 of file ac3.c.

Referenced by ac3_parametric_bit_allocation(), bit_alloc_masking(), and decode_audio_block().


Variable Documentation

uint8_t band_start_tab[51] [static]

Definition at line 73 of file ac3.c.

Referenced by ac3_common_init(), ff_ac3_bit_alloc_calc_bap(), and ff_ac3_bit_alloc_calc_psd().

uint8_t bin_to_band_tab[253] [static]


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