FFmpeg
Loading...
Searching...
No Matches
ac3.h File Reference

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

#include <math.h>
#include <stdint.h>
#include "ac3tab.h"
#include "libavutil/libm.h"

Go to the source code of this file.

Data Structures

struct  AC3BitAllocParameters
 

Macros

#define USE_FIXED   0
 
#define FIXR(x)
 
#define FIXR12(x)
 
#define FIXR15(x)
 
#define ROUND15(x)
 
#define AC3_RENAME(x)
 
#define AC3_NORM(norm)
 
#define AC3_MUL(a, b)
 
#define AC3_RANGE(x)
 
#define AC3_HEAVY_RANGE(x)
 
#define AC3_DYNAMIC_RANGE(x)
 
#define AC3_SPX_BLEND(x)
 
#define AC3_DYNAMIC_RANGE1   1.0f
 
#define AC3_LEVEL(x)
 

Functions

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

Detailed Description

Common code between the AC-3 encoder and decoder.

Definition in file ac3.h.

Macro Definition Documentation

◆ USE_FIXED

#define USE_FIXED   0

Definition at line 36 of file ac3.h.

◆ FIXR

#define FIXR ( x)
Value:
((float)(x))

Definition at line 62 of file ac3.h.

◆ FIXR12

#define FIXR12 ( x)
Value:
((float)(x))

Definition at line 63 of file ac3.h.

Referenced by set_downmix_coeffs().

◆ FIXR15

#define FIXR15 ( x)
Value:
((float)(x))

Definition at line 64 of file ac3.h.

◆ ROUND15

#define ROUND15 ( x)
Value:
(x)

Definition at line 65 of file ac3.h.

◆ AC3_RENAME

#define AC3_RENAME ( x)
Value:
x

Definition at line 67 of file ac3.h.

Referenced by ac3_decode_flush(), ac3_decode_init(), and decode_audio_block().

◆ AC3_NORM

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

Definition at line 68 of file ac3.h.

◆ AC3_MUL

#define AC3_MUL ( a,
b )
Value:
((a) * (b))
int a
#define b
Definition input.c:43

Definition at line 69 of file ac3.h.

◆ AC3_RANGE

#define AC3_RANGE ( x)
Value:
static float dynamic_range_tab[256]
dynamic range table.
Definition ac3dec.c:52

Definition at line 70 of file ac3.h.

Referenced by decode_audio_block().

◆ AC3_HEAVY_RANGE

#define AC3_HEAVY_RANGE ( x)
Value:
float ff_ac3_heavy_dynamic_range_tab[256]
Definition ac3dec.c:53

Definition at line 71 of file ac3.h.

Referenced by ff_eac3_parse_header(), and parse_frame_header().

◆ AC3_DYNAMIC_RANGE

#define AC3_DYNAMIC_RANGE ( x)
Value:
(powf(x, s->drc_scale))
#define s(width, name)
Definition cbs_vp9.c:198
#define powf(x, y)
Definition libm.h:52

Definition at line 72 of file ac3.h.

Referenced by decode_audio_block().

◆ AC3_SPX_BLEND

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

Definition at line 73 of file ac3.h.

Referenced by spx_coordinates().

◆ AC3_DYNAMIC_RANGE1

#define AC3_DYNAMIC_RANGE1   1.0f

Definition at line 74 of file ac3.h.

Referenced by decode_audio_block().

◆ AC3_LEVEL

#define AC3_LEVEL ( x)
Value:
#define ROUND15(x)
Definition ac3.h:65
#define FIXR15(x)
Definition ac3.h:64
#define M_SQRT1_2

Definition at line 82 of file ac3.h.

Function Documentation

◆ 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 175 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 201 of file ac3.c.

Referenced by bit_alloc_masking(), and decode_audio_block().