FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
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)
 Calculate the log power-spectral density of the input signal. More...
 
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)
 Calculate the masking curve. More...
 
av_cold void ff_ac3_common_init (void)
 Initialize some tables. More...
 

Variables

const uint8_t ff_ac3_band_start_tab [AC3_CRITICAL_BANDS+1]
 Starting frequency coefficient bin for each critical band. More...
 
uint8_t ff_ac3_bin_to_band_tab [253]
 

Detailed Description

Common code between the AC-3 encoder and decoder.

Definition in file ac3.c.

Function Documentation

static int calc_lowcomp1 ( int  a,
int  b0,
int  b1,
int  c 
)
inlinestatic

Definition at line 76 of file ac3.c.

Referenced by calc_lowcomp(), and ff_ac3_bit_alloc_calc_mask().

static int calc_lowcomp ( int  a,
int  b0,
int  b1,
int  bin 
)
inlinestatic

Definition at line 86 of file ac3.c.

Referenced by ff_ac3_bit_alloc_calc_mask().

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

Calculate 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]expfrequency coefficient exponents
[in]startstarting bin location
[in]endending bin location
[out]psdsignal power for each frequency bin
[out]band_psdsignal power for each critical band

Definition at line 97 of file ac3.c.

Referenced by bit_alloc_masking(), 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 
)

Calculate 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]sadjustable bit allocation parameters
[in]band_psdsignal power for each critical band
[in]startstarting bin location
[in]endending bin location
[in]fast_gainfast gain (estimated signal-to-mask ratio)
[in]is_lfewhether or not the channel being processed is the LFE
[in]dba_modedelta bit allocation mode (none, reuse, or new)
[in]dba_nsegsnumber of delta segments
[in]dba_offsetslocation offsets for each segment
[in]dba_lengthslength of each segment
[in]dba_valuesdelta bit allocation for each segment
[out]maskcalculated masking curve
Returns
returns 0 for success, non-zero for error

Definition at line 123 of file ac3.c.

Referenced by bit_alloc_masking(), and decode_audio_block().

av_cold void ff_ac3_common_init ( void  )

Initialize some tables.

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

Definition at line 223 of file ac3.c.

Referenced by ac3_decode_init(), and ff_ac3_encode_init().

Variable Documentation

const uint8_t ff_ac3_band_start_tab[AC3_CRITICAL_BANDS+1]
Initial value:
= {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 31,
34, 37, 40, 43, 46, 49, 55, 61, 67, 73,
79, 85, 97, 109, 121, 133, 157, 181, 205, 229, 253
}

Starting frequency coefficient bin for each critical band.

Definition at line 34 of file ac3.c.

Referenced by ac3_bit_alloc_calc_bap_c(), ff_ac3_bit_alloc_calc_psd(), and ff_ac3_common_init().

uint8_t ff_ac3_bin_to_band_tab[253]