libavcodec/ac3.h File Reference

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

#include "ac3tab.h"

Go to the source code of this file.

Data Structures

struct  AC3BitAllocParameters
struct  AC3HeaderInfo
 Coded AC-3 header values up to the lfeon element, plus derived values. More...

Defines

#define AC3_MAX_CODED_FRAME_SIZE   3840
#define AC3_MAX_CHANNELS   6
#define NB_BLOCKS   6
#define AC3_FRAME_SIZE   (NB_BLOCKS * 256)
#define EXP_REUSE   0
#define EXP_NEW   1
#define EXP_D15   1
#define EXP_D25   2
#define EXP_D45   3

Enumerations

enum  AC3DeltaStrategy { DBA_REUSE = 0, DBA_NEW, DBA_NONE, DBA_RESERVED }
 Delta bit allocation strategy. More...
enum  AC3ChannelMode {
  AC3_CHMODE_DUALMONO = 0, AC3_CHMODE_MONO, AC3_CHMODE_STEREO, AC3_CHMODE_3F,
  AC3_CHMODE_2F1R, AC3_CHMODE_3F1R, AC3_CHMODE_2F2R, AC3_CHMODE_3F2R
}
 Channel mode (audio coding mode). More...
enum  EAC3FrameType { EAC3_FRAME_TYPE_INDEPENDENT = 0, EAC3_FRAME_TYPE_DEPENDENT, EAC3_FRAME_TYPE_AC3_CONVERT, EAC3_FRAME_TYPE_RESERVED }

Functions

void ac3_common_init (void)
 Initializes some tables.
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)


Detailed Description

Common code between the AC-3 encoder and decoder.

Definition in file ac3.h.


Define Documentation

#define AC3_FRAME_SIZE   (NB_BLOCKS * 256)

Definition at line 36 of file ac3.h.

Referenced by AC3_encode_frame(), AC3_encode_init(), and spdif_header_ac3().

#define AC3_MAX_CHANNELS   6

Definition at line 33 of file ac3.h.

Referenced by ac3_decode_frame(), AC3_encode_frame(), decode_audio_block(), and set_channel_info().

#define AC3_MAX_CODED_FRAME_SIZE   3840

Definition at line 32 of file ac3.h.

Referenced by output_frame_header().

#define EXP_D15   1

Definition at line 42 of file ac3.h.

Referenced by compute_exp_strategy(), encode_exp(), and output_audio_block().

#define EXP_D25   2

Definition at line 43 of file ac3.h.

Referenced by compute_exp_strategy(), encode_exp(), and output_audio_block().

#define EXP_D45   3

Definition at line 44 of file ac3.h.

Referenced by compute_exp_strategy(), decode_exponents(), encode_exp(), and output_audio_block().

#define EXP_NEW   1

Definition at line 40 of file ac3.h.

Referenced by compute_exp_strategy().

#define EXP_REUSE   0

#define NB_BLOCKS   6


Enumeration Type Documentation

Channel mode (audio coding mode).

Enumerator:
AC3_CHMODE_DUALMONO 
AC3_CHMODE_MONO 
AC3_CHMODE_STEREO 
AC3_CHMODE_3F 
AC3_CHMODE_2F1R 
AC3_CHMODE_3F1R 
AC3_CHMODE_2F2R 
AC3_CHMODE_3F2R 

Definition at line 55 of file ac3.h.

Delta bit allocation strategy.

Enumerator:
DBA_REUSE 
DBA_NEW 
DBA_NONE 
DBA_RESERVED 

Definition at line 47 of file ac3.h.

Enumerator:
EAC3_FRAME_TYPE_INDEPENDENT 
EAC3_FRAME_TYPE_DEPENDENT 
EAC3_FRAME_TYPE_AC3_CONVERT 
EAC3_FRAME_TYPE_RESERVED 

Definition at line 107 of file ac3.h.


Function Documentation

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.

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().


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