FFmpeg  4.0
Functions | Variables
aacsbr_template.c File Reference

AAC Spectral Band Replication decoding functions. More...

#include "libavutil/qsort.h"

Go to the source code of this file.

Functions

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 void AAC_RENAME() ff_aac_sbr_ctx_init (AACContext *ac, SpectralBandReplication *sbr, int id_aac)
 Initialize one SBR context. More...
 
av_cold void AAC_RENAME() ff_aac_sbr_ctx_close (SpectralBandReplication *sbr)
 Close one SBR context. 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)
 
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 (AACContext *ac, SpectralBandReplication *sbr, SpectrumParameters *spectrum)
 Master Frequency Band Table (14496-3 sp04 p194) More...
 
static int sbr_hf_calc_npatches (AACContext *ac, SpectralBandReplication *sbr)
 High Frequency Generation - Patch Construction (14496-3 sp04 p216 fig. 4.46) More...
 
static int sbr_make_f_derived (AACContext *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 (AACContext *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)
 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 (AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data, int ch)
 
static int read_sbr_noise (AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data, int ch)
 
static void read_sbr_extension (AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int bs_extension_id, int *num_bits_left)
 
static int read_sbr_single_channel_element (AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb)
 
static int read_sbr_channel_pair_element (AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb)
 
static unsigned int read_sbr_data (AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int id_aac)
 
static void sbr_reset (AACContext *ac, SpectralBandReplication *sbr)
 
int AAC_RENAME() ff_decode_sbr_extension (AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb_host, int crc, int cnt, int id_aac)
 Decode Spectral Band Replication extension data; reference: table 4.55. More...
 
static void sbr_qmf_analysis (AVFloatDSPContext *dsp, FFTContext *mdct, 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 (FFTContext *mdct, 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 (AACContext *ac, 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 (AACContext *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 (AACContext *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_sbr_apply (AACContext *ac, SpectralBandReplication *sbr, int id_aac, INTFLOAT *L, INTFLOAT *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

◆ ff_aac_sbr_init()

av_cold void AAC_RENAME() ff_aac_sbr_init ( void  )

Initialize SBR.

Definition at line 37 of file aacsbr_template.c.

Referenced by aac_static_table_init().

◆ sbr_turnoff()

static void sbr_turnoff ( SpectralBandReplication sbr)
static

Places SBR in pure upsampling mode.

Definition at line 73 of file aacsbr_template.c.

Referenced by ff_aac_sbr_ctx_init(), ff_decode_sbr_extension(), ff_sbr_apply(), read_sbr_data(), sbr_mapping(), and sbr_reset().

◆ ff_aac_sbr_ctx_init()

av_cold void AAC_RENAME() ff_aac_sbr_ctx_init ( AACContext ac,
SpectralBandReplication sbr,
int  id_aac 
)

Initialize one SBR context.

Definition at line 84 of file aacsbr_template.c.

Referenced by che_configure().

◆ ff_aac_sbr_ctx_close()

av_cold void AAC_RENAME() ff_aac_sbr_ctx_close ( SpectralBandReplication sbr)

Close one SBR context.

Definition at line 103 of file aacsbr_template.c.

Referenced by aac_decode_close(), and che_configure().

◆ qsort_comparison_function_int16()

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

Definition at line 109 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 114 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 124 of file aacsbr_template.c.

Referenced by read_sbr_header(), and sbr_make_f_derived().

◆ read_sbr_header()

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

Definition at line 175 of file aacsbr_template.c.

Referenced by ff_decode_sbr_extension().

◆ array_min_int16()

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

Definition at line 230 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 238 of file aacsbr_template.c.

Referenced by sbr_make_f_master().

◆ sbr_make_f_master()

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

Master Frequency Band Table (14496-3 sp04 p194)

Definition at line 255 of file aacsbr_template.c.

Referenced by sbr_reset().

◆ sbr_hf_calc_npatches()

static int sbr_hf_calc_npatches ( AACContext ac,
SpectralBandReplication sbr 
)
static

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

Definition at line 475 of file aacsbr_template.c.

Referenced by sbr_make_f_derived().

◆ sbr_make_f_derived()

static int sbr_make_f_derived ( AACContext ac,
SpectralBandReplication sbr 
)
static

Derived Frequency Band Tables (14496-3 sp04 p197)

Definition at line 533 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 ( AACContext ac,
SpectralBandReplication sbr,
GetBitContext gb,
SBRData ch_data 
)
static

◆ copy_sbr_grid()

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

Definition at line 765 of file aacsbr_template.c.

Referenced by read_sbr_channel_pair_element().

◆ read_sbr_dtdf()

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

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

Definition at line 783 of file aacsbr_template.c.

Referenced by 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 791 of file aacsbr_template.c.

Referenced by read_sbr_channel_pair_element(), and read_sbr_single_channel_element().

◆ read_sbr_envelope()

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

◆ read_sbr_noise()

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

◆ read_sbr_extension()

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

Definition at line 937 of file aacsbr_template.c.

Referenced by read_sbr_data().

◆ read_sbr_single_channel_element()

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

Definition at line 962 of file aacsbr_template.c.

Referenced by read_sbr_data().

◆ read_sbr_channel_pair_element()

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

Definition at line 986 of file aacsbr_template.c.

Referenced by read_sbr_data().

◆ read_sbr_data()

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

Definition at line 1038 of file aacsbr_template.c.

Referenced by ff_decode_sbr_extension().

◆ sbr_reset()

static void sbr_reset ( AACContext ac,
SpectralBandReplication sbr 
)
static

Definition at line 1082 of file aacsbr_template.c.

Referenced by ff_decode_sbr_extension().

◆ ff_decode_sbr_extension()

int AAC_RENAME() ff_decode_sbr_extension ( AACContext ac,
SpectralBandReplication sbr,
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 1103 of file aacsbr_template.c.

Referenced by decode_extension_payload().

◆ sbr_qmf_analysis()

static void sbr_qmf_analysis ( AVFloatDSPContext dsp,
FFTContext mdct,
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 1159 of file aacsbr_template.c.

Referenced by ff_decode_sbr_extension(), and ff_sbr_apply().

◆ sbr_qmf_synthesis()

static void sbr_qmf_synthesis ( FFTContext mdct,
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 1202 of file aacsbr_template.c.

Referenced by ff_sbr_apply().

◆ sbr_lf_gen()

static int sbr_lf_gen ( AACContext ac,
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 1254 of file aacsbr_template.c.

Referenced by aacsbr_func_ptr_init().

◆ sbr_hf_gen()

static int sbr_hf_gen ( AACContext 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 1279 of file aacsbr_template.c.

Referenced by ff_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 1314 of file aacsbr_template.c.

Referenced by aacsbr_func_ptr_init().

◆ sbr_mapping()

static int sbr_mapping ( AACContext 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 1353 of file aacsbr_template.c.

Referenced by ff_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 1408 of file aacsbr_template.c.

Referenced by ff_sbr_apply().

◆ ff_sbr_apply()

void AAC_RENAME() ff_sbr_apply ( AACContext ac,
SpectralBandReplication sbr,
int  id_aac,
INTFLOAT L,
INTFLOAT R 
)

Apply one SBR element to one AAC element.

Definition at line 1467 of file aacsbr_template.c.

Referenced by spectral_to_sample().

◆ aacsbr_func_ptr_init()

static void aacsbr_func_ptr_init ( AACSBRContext c)
static

Definition at line 1560 of file aacsbr_template.c.

Referenced by ff_aac_sbr_ctx_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 614 of file aacsbr_template.c.