FFmpeg
Data Structures | Macros | Typedefs | Enumerations | Functions
ac3.h File Reference
#include "libavutil/opt.h"
#include "avcodec.h"
#include "ac3tab.h"

Go to the source code of this file.

Data Structures

struct  AC3BitAllocParameters
 
struct  AC3HeaderInfo
 

Macros

#define AC3_MAX_CODED_FRAME_SIZE   3840 /* in bytes */
 
#define EAC3_MAX_CHANNELS   16
 maximum number of channels in EAC3 More...
 
#define AC3_MAX_CHANNELS   7
 maximum number of channels, including coupling channel More...
 
#define CPL_CH   0
 coupling channel index More...
 
#define AC3_MAX_COEFS   256
 
#define AC3_BLOCK_SIZE   256
 
#define AC3_MAX_BLOCKS   6
 
#define AC3_FRAME_SIZE   (AC3_MAX_BLOCKS * 256)
 
#define AC3_WINDOW_SIZE   (AC3_BLOCK_SIZE * 2)
 
#define AC3_CRITICAL_BANDS   50
 
#define AC3_MAX_CPL_BANDS   18
 
#define EXP_REUSE   0
 
#define EXP_NEW   1
 
#define EXP_D15   1
 
#define EXP_D25   2
 
#define EXP_D45   3
 
#define FIXR(x)   ((float)(x))
 
#define FIXR12(x)   ((float)(x))
 
#define FIXR15(x)   ((float)(x))
 
#define ROUND15(x)   (x)
 
#define AC3_RENAME(x)   x
 
#define AC3_NORM(norm)   (1.0f/(norm))
 
#define AC3_MUL(a, b)   ((a) * (b))
 
#define AC3_RANGE(x)   (dynamic_range_tab[(x)])
 
#define AC3_HEAVY_RANGE(x)   (ff_ac3_heavy_dynamic_range_tab[(x)])
 
#define AC3_DYNAMIC_RANGE(x)   (powf(x, s->drc_scale))
 
#define AC3_SPX_BLEND(x)   (x)* (1.0f/32)
 
#define AC3_DYNAMIC_RANGE1   1.0f
 
#define AC3_LEVEL(x)   ROUND15((x) * FIXR15(M_SQRT1_2))
 
#define LEVEL_PLUS_3DB   M_SQRT2
 
#define LEVEL_PLUS_1POINT5DB   1.1892071150027209
 
#define LEVEL_MINUS_1POINT5DB   0.8408964152537145
 
#define LEVEL_MINUS_3DB   M_SQRT1_2
 
#define LEVEL_MINUS_4POINT5DB   0.5946035575013605
 
#define LEVEL_MINUS_6DB   0.5000000000000000
 
#define LEVEL_MINUS_9DB   0.3535533905932738
 
#define LEVEL_ZERO   0.0000000000000000
 
#define LEVEL_ONE   1.0000000000000000
 

Typedefs

typedef float INTFLOAT
 
typedef float SHORTFLOAT
 

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  AC3DolbySurroundMode { AC3_DSURMOD_NOTINDICATED = 0, AC3_DSURMOD_OFF, AC3_DSURMOD_ON, AC3_DSURMOD_RESERVED }
 Dolby Surround mode. More...
 
enum  AC3DolbySurroundEXMode { AC3_DSUREXMOD_NOTINDICATED = 0, AC3_DSUREXMOD_OFF, AC3_DSUREXMOD_ON, AC3_DSUREXMOD_PLIIZ }
 Dolby Surround EX mode. More...
 
enum  AC3DolbyHeadphoneMode { AC3_DHEADPHONMOD_NOTINDICATED = 0, AC3_DHEADPHONMOD_OFF, AC3_DHEADPHONMOD_ON, AC3_DHEADPHONMOD_RESERVED }
 Dolby Headphone mode. More...
 
enum  AC3PreferredStereoDownmixMode { AC3_DMIXMOD_NOTINDICATED = 0, AC3_DMIXMOD_LTRT, AC3_DMIXMOD_LORO, AC3_DMIXMOD_DPLII }
 Preferred Stereo Downmix mode. More...
 
enum  EAC3FrameType { EAC3_FRAME_TYPE_INDEPENDENT = 0, EAC3_FRAME_TYPE_DEPENDENT, EAC3_FRAME_TYPE_AC3_CONVERT, EAC3_FRAME_TYPE_RESERVED }
 

Functions

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

Detailed Description

Common code between the AC-3 encoder and decoder.

Definition in file ac3.h.

Macro Definition Documentation

◆ AC3_MAX_CODED_FRAME_SIZE

#define AC3_MAX_CODED_FRAME_SIZE   3840 /* in bytes */

Definition at line 30 of file ac3.h.

◆ EAC3_MAX_CHANNELS

#define EAC3_MAX_CHANNELS   16

maximum number of channels in EAC3

Definition at line 31 of file ac3.h.

◆ AC3_MAX_CHANNELS

#define AC3_MAX_CHANNELS   7

maximum number of channels, including coupling channel

Definition at line 32 of file ac3.h.

◆ CPL_CH

#define CPL_CH   0

coupling channel index

Definition at line 33 of file ac3.h.

◆ AC3_MAX_COEFS

#define AC3_MAX_COEFS   256

Definition at line 35 of file ac3.h.

◆ AC3_BLOCK_SIZE

#define AC3_BLOCK_SIZE   256

Definition at line 36 of file ac3.h.

◆ AC3_MAX_BLOCKS

#define AC3_MAX_BLOCKS   6

Definition at line 37 of file ac3.h.

◆ AC3_FRAME_SIZE

#define AC3_FRAME_SIZE   (AC3_MAX_BLOCKS * 256)

Definition at line 38 of file ac3.h.

◆ AC3_WINDOW_SIZE

#define AC3_WINDOW_SIZE   (AC3_BLOCK_SIZE * 2)

Definition at line 39 of file ac3.h.

◆ AC3_CRITICAL_BANDS

#define AC3_CRITICAL_BANDS   50

Definition at line 40 of file ac3.h.

◆ AC3_MAX_CPL_BANDS

#define AC3_MAX_CPL_BANDS   18

Definition at line 41 of file ac3.h.

◆ EXP_REUSE

#define EXP_REUSE   0

Definition at line 48 of file ac3.h.

◆ EXP_NEW

#define EXP_NEW   1

Definition at line 49 of file ac3.h.

◆ EXP_D15

#define EXP_D15   1

Definition at line 51 of file ac3.h.

◆ EXP_D25

#define EXP_D25   2

Definition at line 52 of file ac3.h.

◆ EXP_D45

#define EXP_D45   3

Definition at line 53 of file ac3.h.

◆ FIXR

#define FIXR (   x)    ((float)(x))

Definition at line 82 of file ac3.h.

◆ FIXR12

#define FIXR12 (   x)    ((float)(x))

Definition at line 83 of file ac3.h.

◆ FIXR15

#define FIXR15 (   x)    ((float)(x))

Definition at line 84 of file ac3.h.

◆ ROUND15

#define ROUND15 (   x)    (x)

Definition at line 85 of file ac3.h.

◆ AC3_RENAME

#define AC3_RENAME (   x)    x

Definition at line 87 of file ac3.h.

◆ AC3_NORM

#define AC3_NORM (   norm)    (1.0f/(norm))

Definition at line 88 of file ac3.h.

◆ AC3_MUL

#define AC3_MUL (   a,
  b 
)    ((a) * (b))

Definition at line 89 of file ac3.h.

◆ AC3_RANGE

#define AC3_RANGE (   x)    (dynamic_range_tab[(x)])

Definition at line 90 of file ac3.h.

◆ AC3_HEAVY_RANGE

#define AC3_HEAVY_RANGE (   x)    (ff_ac3_heavy_dynamic_range_tab[(x)])

Definition at line 91 of file ac3.h.

◆ AC3_DYNAMIC_RANGE

#define AC3_DYNAMIC_RANGE (   x)    (powf(x, s->drc_scale))

Definition at line 92 of file ac3.h.

◆ AC3_SPX_BLEND

#define AC3_SPX_BLEND (   x)    (x)* (1.0f/32)

Definition at line 93 of file ac3.h.

◆ AC3_DYNAMIC_RANGE1

#define AC3_DYNAMIC_RANGE1   1.0f

Definition at line 94 of file ac3.h.

◆ AC3_LEVEL

#define AC3_LEVEL (   x)    ROUND15((x) * FIXR15(M_SQRT1_2))

Definition at line 101 of file ac3.h.

◆ LEVEL_PLUS_3DB

#define LEVEL_PLUS_3DB   M_SQRT2

Definition at line 104 of file ac3.h.

◆ LEVEL_PLUS_1POINT5DB

#define LEVEL_PLUS_1POINT5DB   1.1892071150027209

Definition at line 105 of file ac3.h.

◆ LEVEL_MINUS_1POINT5DB

#define LEVEL_MINUS_1POINT5DB   0.8408964152537145

Definition at line 106 of file ac3.h.

◆ LEVEL_MINUS_3DB

#define LEVEL_MINUS_3DB   M_SQRT1_2

Definition at line 107 of file ac3.h.

◆ LEVEL_MINUS_4POINT5DB

#define LEVEL_MINUS_4POINT5DB   0.5946035575013605

Definition at line 108 of file ac3.h.

◆ LEVEL_MINUS_6DB

#define LEVEL_MINUS_6DB   0.5000000000000000

Definition at line 109 of file ac3.h.

◆ LEVEL_MINUS_9DB

#define LEVEL_MINUS_9DB   0.3535533905932738

Definition at line 110 of file ac3.h.

◆ LEVEL_ZERO

#define LEVEL_ZERO   0.0000000000000000

Definition at line 111 of file ac3.h.

◆ LEVEL_ONE

#define LEVEL_ONE   1.0000000000000000

Definition at line 112 of file ac3.h.

Typedef Documentation

◆ INTFLOAT

typedef float INTFLOAT

Definition at line 96 of file ac3.h.

◆ SHORTFLOAT

typedef float SHORTFLOAT

Definition at line 97 of file ac3.h.

Enumeration Type Documentation

◆ AC3DeltaStrategy

Delta bit allocation strategy.

Enumerator
DBA_REUSE 
DBA_NEW 
DBA_NONE 
DBA_RESERVED 

Definition at line 115 of file ac3.h.

◆ AC3ChannelMode

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 123 of file ac3.h.

◆ AC3DolbySurroundMode

Dolby Surround mode.

Enumerator
AC3_DSURMOD_NOTINDICATED 
AC3_DSURMOD_OFF 
AC3_DSURMOD_ON 
AC3_DSURMOD_RESERVED 

Definition at line 135 of file ac3.h.

◆ AC3DolbySurroundEXMode

Dolby Surround EX mode.

Enumerator
AC3_DSUREXMOD_NOTINDICATED 
AC3_DSUREXMOD_OFF 
AC3_DSUREXMOD_ON 
AC3_DSUREXMOD_PLIIZ 

Definition at line 143 of file ac3.h.

◆ AC3DolbyHeadphoneMode

Dolby Headphone mode.

Enumerator
AC3_DHEADPHONMOD_NOTINDICATED 
AC3_DHEADPHONMOD_OFF 
AC3_DHEADPHONMOD_ON 
AC3_DHEADPHONMOD_RESERVED 

Definition at line 151 of file ac3.h.

◆ AC3PreferredStereoDownmixMode

Preferred Stereo Downmix mode.

Enumerator
AC3_DMIXMOD_NOTINDICATED 
AC3_DMIXMOD_LTRT 
AC3_DMIXMOD_LORO 
AC3_DMIXMOD_DPLII 

Definition at line 159 of file ac3.h.

◆ EAC3FrameType

Enumerator
EAC3_FRAME_TYPE_INDEPENDENT 
EAC3_FRAME_TYPE_DEPENDENT 
EAC3_FRAME_TYPE_AC3_CONVERT 
EAC3_FRAME_TYPE_RESERVED 

Definition at line 209 of file ac3.h.

Function Documentation

◆ ff_ac3_common_init()

void ff_ac3_common_init ( void  )

◆ ff_ac3_bit_alloc_calc_psd()

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 92 of file ac3.c.

Referenced by bit_alloc_masking(), and decode_audio_block().

◆ ff_ac3_bit_alloc_calc_mask()

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 118 of file ac3.c.

Referenced by bit_alloc_masking(), and decode_audio_block().