FFmpeg
Data Structures | Functions | Variables
aacsbr_template.c File Reference
#include "aac/aacdec.h"
#include "aac/aacdec_tab.h"
#include "avcodec.h"
#include "libavutil/qsort.h"
#include "libavutil/mem.h"

Go to the source code of this file.

Data Structures

struct  ExtChannelElement
 

Functions

static SpectralBandReplicationget_sbr (ChannelElement *ch)
 
av_cold void AAC_RENAME() ff_aac_sbr_init (void)
 Initialize SBR. More...
 
static void sbr_turnoff (SpectralBandReplication *sbr)
 Places SBR in pure upsampling mode. More...
 
av_cold int AAC_RENAME() ff_aac_sbr_ctx_alloc_init (AACDecContext *ac, ChannelElement **che, int id_aac)
 Allocate an ExtChannelElement (if necessary) and initialize the SBR context contained in it. More...
 
av_cold void AAC_RENAME() ff_aac_sbr_ctx_close (ChannelElement *che)
 Close the SBR context implicitly contained in a ChannelElement. More...
 
static int qsort_comparison_function_int16 (const void *a, const void *b)
 
static int in_table_int16 (const int16_t *table, int last_el, int16_t needle)
 
static void sbr_make_f_tablelim (SpectralBandReplication *sbr)
 Limiter Frequency Band Table (14496-3 sp04 p198) More...
 
static unsigned int read_sbr_header (SpectralBandReplication *sbr, GetBitContext *gb, int is_usac)
 
static int array_min_int16 (const int16_t *array, int nel)
 
static int check_n_master (AVCodecContext *avctx, int n_master, int bs_xover_band)
 
static int sbr_make_f_master (AACDecContext *ac, SpectralBandReplication *sbr, SpectrumParameters *spectrum)
 Master Frequency Band Table (14496-3 sp04 p194) More...
 
static int sbr_hf_calc_npatches (AACDecContext *ac, SpectralBandReplication *sbr)
 High Frequency Generation - Patch Construction (14496-3 sp04 p216 fig. 4.46) More...
 
static int sbr_make_f_derived (AACDecContext *ac, SpectralBandReplication *sbr)
 Derived Frequency Band Tables (14496-3 sp04 p197) More...
 
static av_always_inline void get_bits1_vector (GetBitContext *gb, uint8_t *vec, int elements)
 
static int read_sbr_grid (AACDecContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data)
 
static void copy_sbr_grid (SBRData *dst, const SBRData *src)
 
static void read_sbr_dtdf (SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data, int indep_flag)
 Read how the envelope and noise floor data is delta coded. More...
 
static void read_sbr_invf (SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data)
 Read inverse filtering data. More...
 
static int read_sbr_envelope (AACDecContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data, int ch)
 
static int read_sbr_noise (AACDecContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data, int ch)
 
static void read_sbr_extension (AACDecContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int bs_extension_id, int *num_bits_left)
 
static int read_sbr_single_channel_element (AACDecContext *ac, SpectralBandReplication *sbr, GetBitContext *gb)
 
static int read_sbr_channel_pair_element (AACDecContext *ac, SpectralBandReplication *sbr, GetBitContext *gb)
 
static unsigned int read_sbr_data (AACDecContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int id_aac)
 
static void sbr_reset (AACDecContext *ac, SpectralBandReplication *sbr)
 
int AAC_RENAME() ff_aac_sbr_decode_extension (AACDecContext *ac, ChannelElement *che, GetBitContext *gb_host, int crc, int cnt, int id_aac)
 Decode Spectral Band Replication extension data; reference: table 4.55. More...
 
static void copy_usac_default_header (SpectralBandReplication *sbr, AACUsacElemConfig *ue)
 
int ff_aac_sbr_config_usac (AACDecContext *ac, ChannelElement *che, AACUsacElemConfig *ue)
 Due to channel allocation not being known upon SBR parameter transmission, supply the parameters separately. More...
 
int ff_aac_sbr_decode_usac_data (AACDecContext *ac, ChannelElement *che, AACUsacElemConfig *ue, GetBitContext *gb, int sbr_ch, int indep_flag)
 Decode frame SBR data, USAC. More...
 
static void sbr_qmf_analysis (AVFloatDSPContext *dsp, AVTXContext *mdct, av_tx_fn mdct_fn, SBRDSPContext *sbrdsp, const INTFLOAT *in, INTFLOAT *x, INTFLOAT z[320], INTFLOAT W[2][32][32][2], int buf_idx)
 Analysis QMF Bank (14496-3 sp04 p206) More...
 
static void sbr_qmf_synthesis (AVTXContext *mdct, av_tx_fn mdct_fn, SBRDSPContext *sbrdsp, AVFloatDSPContext *dsp, INTFLOAT *out, INTFLOAT X[2][38][64], INTFLOAT mdct_buf[2][64], INTFLOAT *v0, int *v_off, const unsigned int div)
 Synthesis QMF Bank (14496-3 sp04 p206) and Downsampled Synthesis QMF Bank (14496-3 sp04 p206) More...
 
static int sbr_lf_gen (SpectralBandReplication *sbr, INTFLOAT X_low[32][40][2], const INTFLOAT W[2][32][32][2], int buf_idx)
 Generate the subband filtered lowband. More...
 
static int sbr_hf_gen (AACDecContext *ac, SpectralBandReplication *sbr, INTFLOAT X_high[64][40][2], const INTFLOAT X_low[32][40][2], const INTFLOAT(*alpha0)[2], const INTFLOAT(*alpha1)[2], const INTFLOAT bw_array[5], const uint8_t *t_env, int bs_num_env)
 High Frequency Generator (14496-3 sp04 p215) More...
 
static int sbr_x_gen (SpectralBandReplication *sbr, INTFLOAT X[2][38][64], const INTFLOAT Y0[38][64][2], const INTFLOAT Y1[38][64][2], const INTFLOAT X_low[32][40][2], int ch)
 Generate the subband filtered lowband. More...
 
static int sbr_mapping (AACDecContext *ac, SpectralBandReplication *sbr, SBRData *ch_data, int e_a[2])
 High Frequency Adjustment (14496-3 sp04 p217) and Mapping (14496-3 sp04 p217) More...
 
static void sbr_env_estimate (AAC_FLOAT(*e_curr)[48], INTFLOAT X_high[64][40][2], SpectralBandReplication *sbr, SBRData *ch_data)
 Estimation of current envelope (14496-3 sp04 p218) More...
 
void AAC_RENAME() ff_aac_sbr_apply (AACDecContext *ac, ChannelElement *che, int id_aac, void *L_, void *R_)
 Apply one SBR element to one AAC element. More...
 
static void aacsbr_func_ptr_init (AACSBRContext *c)
 

Variables

static const int8_t ceil_log2 []
 ceil(log2(index+1)) More...
 

Detailed Description

AAC Spectral Band Replication decoding functions

Author
Robert Swain ( rob opendot cl )
Stanislav Ocovaj ( stani.nosp@m.slav.nosp@m..ocov.nosp@m.aj@i.nosp@m.mgtec.nosp@m..com )
Zoran Basaric ( zoran.nosp@m..bas.nosp@m.aric@.nosp@m.imgt.nosp@m.ec.co.nosp@m.m )

Definition in file aacsbr_template.c.

Function Documentation

◆ get_sbr()

static SpectralBandReplication* get_sbr ( ChannelElement ch)
inlinestatic

◆ ff_aac_sbr_init()

av_cold void AAC_RENAME() ff_aac_sbr_init ( void  )

Initialize SBR.

Definition at line 52 of file aacsbr_template.c.

Referenced by init_tables_float_fn().

◆ sbr_turnoff()

static void sbr_turnoff ( SpectralBandReplication sbr)
static

◆ ff_aac_sbr_ctx_alloc_init()

av_cold int AAC_RENAME() ff_aac_sbr_ctx_alloc_init ( AACDecContext ac,
ChannelElement **  che,
int  id_aac 
)

Allocate an ExtChannelElement (if necessary) and initialize the SBR context contained in it.

Definition at line 70 of file aacsbr_template.c.

◆ ff_aac_sbr_ctx_close()

av_cold void AAC_RENAME() ff_aac_sbr_ctx_close ( ChannelElement che)

Close the SBR context implicitly contained in a ChannelElement.

Definition at line 115 of file aacsbr_template.c.

◆ qsort_comparison_function_int16()

static int qsort_comparison_function_int16 ( const void *  a,
const void *  b 
)
static

Definition at line 122 of file aacsbr_template.c.

Referenced by sbr_make_f_master(), and sbr_make_f_tablelim().

◆ in_table_int16()

static int in_table_int16 ( const int16_t *  table,
int  last_el,
int16_t  needle 
)
inlinestatic

Definition at line 127 of file aacsbr_template.c.

Referenced by sbr_make_f_tablelim().

◆ sbr_make_f_tablelim()

static void sbr_make_f_tablelim ( SpectralBandReplication sbr)
static

Limiter Frequency Band Table (14496-3 sp04 p198)

Definition at line 137 of file aacsbr_template.c.

Referenced by ff_aac_sbr_decode_usac_data(), read_sbr_header(), and sbr_make_f_derived().

◆ read_sbr_header()

static unsigned int read_sbr_header ( SpectralBandReplication sbr,
GetBitContext gb,
int  is_usac 
)
static

Definition at line 188 of file aacsbr_template.c.

Referenced by ff_aac_sbr_decode_extension(), and ff_aac_sbr_decode_usac_data().

◆ array_min_int16()

static int array_min_int16 ( const int16_t *  array,
int  nel 
)
static

Definition at line 249 of file aacsbr_template.c.

Referenced by sbr_make_f_master().

◆ check_n_master()

static int check_n_master ( AVCodecContext avctx,
int  n_master,
int  bs_xover_band 
)
static

Definition at line 257 of file aacsbr_template.c.

Referenced by sbr_make_f_master().

◆ sbr_make_f_master()

static int sbr_make_f_master ( AACDecContext ac,
SpectralBandReplication sbr,
SpectrumParameters spectrum 
)
static

Master Frequency Band Table (14496-3 sp04 p194)

Definition at line 274 of file aacsbr_template.c.

Referenced by sbr_reset().

◆ sbr_hf_calc_npatches()

static int sbr_hf_calc_npatches ( AACDecContext ac,
SpectralBandReplication sbr 
)
static

High Frequency Generation - Patch Construction (14496-3 sp04 p216 fig. 4.46)

Definition at line 494 of file aacsbr_template.c.

Referenced by sbr_make_f_derived().

◆ sbr_make_f_derived()

static int sbr_make_f_derived ( AACDecContext ac,
SpectralBandReplication sbr 
)
static

Derived Frequency Band Tables (14496-3 sp04 p197)

Definition at line 552 of file aacsbr_template.c.

Referenced by sbr_reset().

◆ get_bits1_vector()

static av_always_inline void get_bits1_vector ( GetBitContext gb,
uint8_t *  vec,
int  elements 
)
static

◆ read_sbr_grid()

static int read_sbr_grid ( AACDecContext ac,
SpectralBandReplication sbr,
GetBitContext gb,
SBRData ch_data 
)
static

◆ copy_sbr_grid()

static void copy_sbr_grid ( SBRData dst,
const SBRData src 
)
static

◆ read_sbr_dtdf()

static void read_sbr_dtdf ( SpectralBandReplication sbr,
GetBitContext gb,
SBRData ch_data,
int  indep_flag 
)
static

Read how the envelope and noise floor data is delta coded.

Definition at line 802 of file aacsbr_template.c.

Referenced by ff_aac_sbr_decode_usac_data(), read_sbr_channel_pair_element(), and read_sbr_single_channel_element().

◆ read_sbr_invf()

static void read_sbr_invf ( SpectralBandReplication sbr,
GetBitContext gb,
SBRData ch_data 
)
static

Read inverse filtering data.

Definition at line 826 of file aacsbr_template.c.

Referenced by ff_aac_sbr_decode_usac_data(), read_sbr_channel_pair_element(), and read_sbr_single_channel_element().

◆ read_sbr_envelope()

static int read_sbr_envelope ( AACDecContext ac,
SpectralBandReplication sbr,
GetBitContext gb,
SBRData ch_data,
int  ch 
)
static

◆ read_sbr_noise()

static int read_sbr_noise ( AACDecContext ac,
SpectralBandReplication sbr,
GetBitContext gb,
SBRData ch_data,
int  ch 
)
static

◆ read_sbr_extension()

static void read_sbr_extension ( AACDecContext ac,
SpectralBandReplication sbr,
GetBitContext gb,
int  bs_extension_id,
int *  num_bits_left 
)
static

Definition at line 965 of file aacsbr_template.c.

Referenced by read_sbr_data().

◆ read_sbr_single_channel_element()

static int read_sbr_single_channel_element ( AACDecContext ac,
SpectralBandReplication sbr,
GetBitContext gb 
)
static

Definition at line 992 of file aacsbr_template.c.

Referenced by read_sbr_data().

◆ read_sbr_channel_pair_element()

static int read_sbr_channel_pair_element ( AACDecContext ac,
SpectralBandReplication sbr,
GetBitContext gb 
)
static

Definition at line 1016 of file aacsbr_template.c.

Referenced by read_sbr_data().

◆ read_sbr_data()

static unsigned int read_sbr_data ( AACDecContext ac,
SpectralBandReplication sbr,
GetBitContext gb,
int  id_aac 
)
static

Definition at line 1068 of file aacsbr_template.c.

Referenced by ff_aac_sbr_decode_extension().

◆ sbr_reset()

static void sbr_reset ( AACDecContext ac,
SpectralBandReplication sbr 
)
static

Definition at line 1112 of file aacsbr_template.c.

Referenced by ff_aac_sbr_decode_extension(), and ff_aac_sbr_decode_usac_data().

◆ ff_aac_sbr_decode_extension()

int AAC_RENAME() ff_aac_sbr_decode_extension ( AACDecContext ac,
ChannelElement che,
GetBitContext gb_host,
int  crc,
int  cnt,
int  id_aac 
)

Decode Spectral Band Replication extension data; reference: table 4.55.

Decode one SBR element.

Parameters
crcflag indicating the presence of CRC checksum
cntlength of TYPE_FIL syntactic element in bytes
Returns
Returns number of bytes consumed from the TYPE_FIL element.

Definition at line 1133 of file aacsbr_template.c.

◆ copy_usac_default_header()

static void copy_usac_default_header ( SpectralBandReplication sbr,
AACUsacElemConfig ue 
)
static

Definition at line 1182 of file aacsbr_template.c.

Referenced by ff_aac_sbr_decode_usac_data().

◆ ff_aac_sbr_config_usac()

int ff_aac_sbr_config_usac ( AACDecContext ac,
ChannelElement che,
AACUsacElemConfig ue 
)

Due to channel allocation not being known upon SBR parameter transmission, supply the parameters separately.

Functionally identical to ff_aac_sbr_decode_extension()

Definition at line 1200 of file aacsbr_template.c.

Referenced by ff_aac_usac_reset_state().

◆ ff_aac_sbr_decode_usac_data()

int ff_aac_sbr_decode_usac_data ( AACDecContext ac,
ChannelElement che,
AACUsacElemConfig ue,
GetBitContext gb,
int  sbr_ch,
int  indep_flag 
)

Decode frame SBR data, USAC.

Definition at line 1208 of file aacsbr_template.c.

Referenced by decode_usac_core_coder().

◆ sbr_qmf_analysis()

static void sbr_qmf_analysis ( AVFloatDSPContext dsp,
AVTXContext mdct,
av_tx_fn  mdct_fn,
SBRDSPContext sbrdsp,
const INTFLOAT in,
INTFLOAT x,
INTFLOAT  z[320],
INTFLOAT  W[2][32][32][2],
int  buf_idx 
)
static

Analysis QMF Bank (14496-3 sp04 p206)

Parameters
xpointer to the beginning of the first sample window
Warray of complex-valued samples split into subbands

Definition at line 1362 of file aacsbr_template.c.

Referenced by ff_aac_sbr_apply().

◆ sbr_qmf_synthesis()

static void sbr_qmf_synthesis ( AVTXContext mdct,
av_tx_fn  mdct_fn,
SBRDSPContext sbrdsp,
AVFloatDSPContext dsp,
INTFLOAT out,
INTFLOAT  X[2][38][64],
INTFLOAT  mdct_buf[2][64],
INTFLOAT v0,
int *  v_off,
const unsigned int  div 
)
static

Synthesis QMF Bank (14496-3 sp04 p206) and Downsampled Synthesis QMF Bank (14496-3 sp04 p206)

Definition at line 1406 of file aacsbr_template.c.

Referenced by ff_aac_sbr_apply().

◆ sbr_lf_gen()

static int sbr_lf_gen ( SpectralBandReplication sbr,
INTFLOAT  X_low[32][40][2],
const INTFLOAT  W[2][32][32][2],
int  buf_idx 
)
static

Generate the subband filtered lowband.

Definition at line 1458 of file aacsbr_template.c.

Referenced by aacsbr_func_ptr_init().

◆ sbr_hf_gen()

static int sbr_hf_gen ( AACDecContext ac,
SpectralBandReplication sbr,
INTFLOAT  X_high[64][40][2],
const INTFLOAT  X_low[32][40][2],
const INTFLOAT(*)  alpha0[2],
const INTFLOAT(*)  alpha1[2],
const INTFLOAT  bw_array[5],
const uint8_t *  t_env,
int  bs_num_env 
)
static

High Frequency Generator (14496-3 sp04 p215)

Definition at line 1483 of file aacsbr_template.c.

Referenced by ff_aac_sbr_apply().

◆ sbr_x_gen()

static int sbr_x_gen ( SpectralBandReplication sbr,
INTFLOAT  X[2][38][64],
const INTFLOAT  Y0[38][64][2],
const INTFLOAT  Y1[38][64][2],
const INTFLOAT  X_low[32][40][2],
int  ch 
)
static

Generate the subband filtered lowband.

Definition at line 1518 of file aacsbr_template.c.

Referenced by aacsbr_func_ptr_init().

◆ sbr_mapping()

static int sbr_mapping ( AACDecContext ac,
SpectralBandReplication sbr,
SBRData ch_data,
int  e_a[2] 
)
static

High Frequency Adjustment (14496-3 sp04 p217) and Mapping (14496-3 sp04 p217)

Definition at line 1557 of file aacsbr_template.c.

Referenced by ff_aac_sbr_apply().

◆ sbr_env_estimate()

static void sbr_env_estimate ( AAC_FLOAT(*)  e_curr[48],
INTFLOAT  X_high[64][40][2],
SpectralBandReplication sbr,
SBRData ch_data 
)
static

Estimation of current envelope (14496-3 sp04 p218)

Definition at line 1612 of file aacsbr_template.c.

Referenced by ff_aac_sbr_apply().

◆ ff_aac_sbr_apply()

void AAC_RENAME() ff_aac_sbr_apply ( AACDecContext ac,
ChannelElement che,
int  id_aac,
void *  L_,
void *  R_ 
)

Apply one SBR element to one AAC element.

Definition at line 1671 of file aacsbr_template.c.

◆ aacsbr_func_ptr_init()

static void aacsbr_func_ptr_init ( AACSBRContext c)
static

Definition at line 1767 of file aacsbr_template.c.

Referenced by ff_aac_sbr_ctx_alloc_init().

Variable Documentation

◆ ceil_log2

const int8_t ceil_log2[]
static
Initial value:
= {
0, 1, 2, 2, 3, 3,
}

ceil(log2(index+1))

Definition at line 633 of file aacsbr_template.c.

Referenced by read_sbr_grid().