libavcodec/aacsbr.c File Reference

AAC Spectral Band Replication decoding functions. More...

#include "aac.h"
#include "sbr.h"
#include "aacsbr.h"
#include "aacsbrdata.h"
#include "fft.h"
#include "aacps.h"
#include "libavutil/libm.h"
#include "libavutil/avassert.h"
#include <stdint.h>
#include <float.h>
#include <math.h>

Go to the source code of this file.

Defines

#define ENVELOPE_ADJUSTMENT_OFFSET   2
#define NOISE_FLOOR_OFFSET   6.0f
#define SBR_INIT_VLC_STATIC(num, size)
#define SBR_VLC_ROW(name)   { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) }

Enumerations

enum  {
  T_HUFFMAN_ENV_1_5DB, F_HUFFMAN_ENV_1_5DB, T_HUFFMAN_ENV_BAL_1_5DB, F_HUFFMAN_ENV_BAL_1_5DB,
  T_HUFFMAN_ENV_3_0DB, F_HUFFMAN_ENV_3_0DB, T_HUFFMAN_ENV_BAL_3_0DB, F_HUFFMAN_ENV_BAL_3_0DB,
  T_HUFFMAN_NOISE_3_0DB, T_HUFFMAN_NOISE_BAL_3_0DB
}
 SBR VLC tables. More...
enum  { FIXFIX, FIXVAR, VARFIX, VARVAR }
 bs_frame_class - frame class of current SBR frame (14496-3 sp04 p98) More...
enum  { EXTENSION_ID_PS = 2 }

Functions

av_cold void ff_aac_sbr_init (void)
 Initialize SBR.
av_cold void ff_aac_sbr_ctx_init (AACContext *ac, SpectralBandReplication *sbr)
 Initialize one SBR context.
av_cold void ff_aac_sbr_ctx_close (SpectralBandReplication *sbr)
 Close one SBR context.
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).
static unsigned int read_sbr_header (SpectralBandReplication *sbr, GetBitContext *gb)
static int array_min_int16 (const int16_t *array, int nel)
static void make_bands (int16_t *bands, int start, int stop, int num_bands)
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).
static int sbr_hf_calc_npatches (AACContext *ac, SpectralBandReplication *sbr)
 High Frequency Generation - Patch Construction (14496-3 sp04 p216 fig. 4.46).
static int sbr_make_f_derived (AACContext *ac, SpectralBandReplication *sbr)
 Derived Frequency Band Tables (14496-3 sp04 p197).
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.
static void read_sbr_invf (SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data)
 Read inverse filtering data.
static void read_sbr_envelope (SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data, int ch)
static void read_sbr_noise (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 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.
static void sbr_dequant (SpectralBandReplication *sbr, int id_aac)
 Dequantization and stereo decoding (14496-3 sp04 p203).
static void sbr_qmf_analysis (DSPContext *dsp, FFTContext *mdct, const float *in, float *x, float z[320], float W[2][32][32][2])
 Analysis QMF Bank (14496-3 sp04 p206).
static void sbr_qmf_synthesis (DSPContext *dsp, FFTContext *mdct, float *out, float X[2][38][64], float mdct_buf[2][64], float *v0, int *v_off, const unsigned int div)
 Synthesis QMF Bank (14496-3 sp04 p206) and Downsampled Synthesis QMF Bank (14496-3 sp04 p206).
static void autocorrelate (const float x[40][2], float phi[3][2][2], int lag)
static void sbr_hf_inverse_filter (float(*alpha0)[2], float(*alpha1)[2], const float X_low[32][40][2], int k0)
 High Frequency Generation (14496-3 sp04 p214+) and Inverse Filtering (14496-3 sp04 p214) Warning: This routine does not seem numerically stable.
static void sbr_chirp (SpectralBandReplication *sbr, SBRData *ch_data)
 Chirp Factors (14496-3 sp04 p214).
static int sbr_lf_gen (AACContext *ac, SpectralBandReplication *sbr, float X_low[32][40][2], const float W[2][32][32][2])
 Generate the subband filtered lowband.
static int sbr_hf_gen (AACContext *ac, SpectralBandReplication *sbr, float X_high[64][40][2], const float X_low[32][40][2], const float(*alpha0)[2], const float(*alpha1)[2], const float bw_array[5], const uint8_t *t_env, int bs_num_env)
 High Frequency Generator (14496-3 sp04 p215).
static int sbr_x_gen (SpectralBandReplication *sbr, float X[2][38][64], const float X_low[32][40][2], const float Y[2][38][64][2], int ch)
 Generate the subband filtered lowband.
static void 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).
static void sbr_env_estimate (float(*e_curr)[48], float X_high[64][40][2], SpectralBandReplication *sbr, SBRData *ch_data)
 Estimation of current envelope (14496-3 sp04 p218).
static void sbr_gain_calc (AACContext *ac, SpectralBandReplication *sbr, SBRData *ch_data, const int e_a[2])
 Calculation of levels of additional HF signal components (14496-3 sp04 p219) and Calculation of gain (14496-3 sp04 p219).
static void sbr_hf_assemble (float Y[2][38][64][2], const float X_high[64][40][2], SpectralBandReplication *sbr, SBRData *ch_data, const int e_a[2])
 Assembling HF Signals (14496-3 sp04 p220).
void ff_sbr_apply (AACContext *ac, SpectralBandReplication *sbr, int id_aac, float *L, float *R)
 Apply one SBR element to one AAC element.

Variables

static VLC vlc_sbr [10]
static const int8_t vlc_sbr_lav [10]
static const float zero64 [64]
static const int8_t ceil_log2 []
 ceil(log2(index+1))


Detailed Description

AAC Spectral Band Replication decoding functions.

Author:
Robert Swain ( rob opendot cl )

Definition in file aacsbr.c.


Define Documentation

#define ENVELOPE_ADJUSTMENT_OFFSET   2

Definition at line 42 of file aacsbr.c.

Referenced by sbr_env_estimate(), sbr_hf_assemble(), sbr_hf_gen(), and sbr_x_gen().

#define NOISE_FLOOR_OFFSET   6.0f

Definition at line 43 of file aacsbr.c.

Referenced by sbr_dequant().

#define SBR_INIT_VLC_STATIC ( num,
size   ) 

Value:

INIT_VLC_STATIC(&vlc_sbr[num], 9, sbr_tmp[num].table_size / sbr_tmp[num].elem_size,     \
                    sbr_tmp[num].sbr_bits ,                      1,                      1, \
                    sbr_tmp[num].sbr_codes, sbr_tmp[num].elem_size, sbr_tmp[num].elem_size, \
                    size)

Definition at line 80 of file aacsbr.c.

Referenced by ff_aac_sbr_init().

#define SBR_VLC_ROW ( name   )     { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) }

Definition at line 86 of file aacsbr.c.

Referenced by ff_aac_sbr_init().


Enumeration Type Documentation

anonymous enum

SBR VLC tables.

Enumerator:
T_HUFFMAN_ENV_1_5DB 
F_HUFFMAN_ENV_1_5DB 
T_HUFFMAN_ENV_BAL_1_5DB 
F_HUFFMAN_ENV_BAL_1_5DB 
T_HUFFMAN_ENV_3_0DB 
F_HUFFMAN_ENV_3_0DB 
T_HUFFMAN_ENV_BAL_3_0DB 
F_HUFFMAN_ENV_BAL_3_0DB 
T_HUFFMAN_NOISE_3_0DB 
T_HUFFMAN_NOISE_BAL_3_0DB 

Definition at line 48 of file aacsbr.c.

anonymous enum

bs_frame_class - frame class of current SBR frame (14496-3 sp04 p98)

Enumerator:
FIXFIX 
FIXVAR 
VARFIX 
VARVAR 

Definition at line 64 of file aacsbr.c.

anonymous enum

Enumerator:
EXTENSION_ID_PS 

Definition at line 71 of file aacsbr.c.


Function Documentation

static int array_min_int16 ( const int16_t array,
int  nel 
) [static]

Definition at line 271 of file aacsbr.c.

Referenced by sbr_make_f_master().

static void autocorrelate ( const float  x[40][2],
float  phi[3][2][2],
int  lag 
) [static]

Definition at line 1233 of file aacsbr.c.

Referenced by sbr_hf_inverse_filter().

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

Definition at line 297 of file aacsbr.c.

Referenced by sbr_make_f_master().

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

Definition at line 761 of file aacsbr.c.

Referenced by read_sbr_channel_pair_element().

av_cold void ff_aac_sbr_ctx_close ( SpectralBandReplication sbr  ) 

Close one SBR context.

Definition at line 149 of file aacsbr.c.

Referenced by aac_decode_close(), and che_configure().

av_cold void ff_aac_sbr_ctx_init ( AACContext ac,
SpectralBandReplication sbr 
)

Initialize one SBR context.

Definition at line 131 of file aacsbr.c.

Referenced by che_configure().

av_cold void ff_aac_sbr_init ( void   ) 

Initialize SBR.

Definition at line 89 of file aacsbr.c.

Referenced by aac_decode_init().

int 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:
crc flag indicating the presence of CRC checksum
cnt length of TYPE_FIL syntactic element in bytes
Returns:
Returns number of bytes consumed from the TYPE_FIL element.

Definition at line 1054 of file aacsbr.c.

Referenced by decode_extension_payload().

void ff_sbr_apply ( AACContext ac,
SpectralBandReplication sbr,
int  id_aac,
float *  L,
float *  R 
)

Apply one SBR element to one AAC element.

Definition at line 1718 of file aacsbr.c.

Referenced by spectral_to_sample().

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

static int in_table_int16 ( const int16_t table,
int  last_el,
int16_t  needle 
) [inline, static]

Definition at line 160 of file aacsbr.c.

Referenced by sbr_make_f_tablelim().

static void make_bands ( int16_t bands,
int  start,
int  stop,
int  num_bands 
) [static]

Definition at line 279 of file aacsbr.c.

Referenced by sbr_make_f_master().

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

Definition at line 155 of file aacsbr.c.

Referenced by sbr_make_f_master(), and sbr_make_f_tablelim().

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

Definition at line 950 of file aacsbr.c.

Referenced by read_sbr_data().

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

Definition at line 992 of file aacsbr.c.

Referenced by ff_decode_sbr_extension().

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 779 of file aacsbr.c.

Referenced by read_sbr_channel_pair_element(), and read_sbr_single_channel_element().

static void read_sbr_envelope ( SpectralBandReplication sbr,
GetBitContext gb,
SBRData ch_data,
int  ch 
) [static]

Definition at line 797 of file aacsbr.c.

Referenced by read_sbr_channel_pair_element(), and read_sbr_single_channel_element().

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

Definition at line 902 of file aacsbr.c.

Referenced by read_sbr_data().

static int read_sbr_grid ( AACContext ac,
SpectralBandReplication sbr,
GetBitContext gb,
SBRData ch_data 
) [static]

Definition at line 619 of file aacsbr.c.

Referenced by read_sbr_channel_pair_element(), and read_sbr_single_channel_element().

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

Definition at line 217 of file aacsbr.c.

Referenced by ff_decode_sbr_extension().

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

Read inverse filtering data.

Definition at line 787 of file aacsbr.c.

Referenced by read_sbr_channel_pair_element(), and read_sbr_single_channel_element().

static void read_sbr_noise ( SpectralBandReplication sbr,
GetBitContext gb,
SBRData ch_data,
int  ch 
) [static]

Definition at line 866 of file aacsbr.c.

Referenced by read_sbr_channel_pair_element(), and read_sbr_single_channel_element().

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

Definition at line 930 of file aacsbr.c.

Referenced by read_sbr_data().

static void sbr_chirp ( SpectralBandReplication sbr,
SBRData ch_data 
) [static]

Chirp Factors (14496-3 sp04 p214).

Definition at line 1317 of file aacsbr.c.

Referenced by ff_sbr_apply().

static void sbr_dequant ( SpectralBandReplication sbr,
int  id_aac 
) [static]

Dequantization and stereo decoding (14496-3 sp04 p203).

Definition at line 1099 of file aacsbr.c.

Referenced by ff_sbr_apply().

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

Estimation of current envelope (14496-3 sp04 p218).

Definition at line 1501 of file aacsbr.c.

Referenced by ff_sbr_apply().

static void sbr_gain_calc ( AACContext ac,
SpectralBandReplication sbr,
SBRData ch_data,
const int  e_a[2] 
) [static]

Calculation of levels of additional HF signal components (14496-3 sp04 p219) and Calculation of gain (14496-3 sp04 p219).

Definition at line 1554 of file aacsbr.c.

Referenced by ff_sbr_apply().

static void sbr_hf_assemble ( float  Y[2][38][64][2],
const float  X_high[64][40][2],
SpectralBandReplication sbr,
SBRData ch_data,
const int  e_a[2] 
) [static]

Assembling HF Signals (14496-3 sp04 p220).

Definition at line 1610 of file aacsbr.c.

Referenced by ff_sbr_apply().

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 501 of file aacsbr.c.

Referenced by sbr_make_f_derived().

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

High Frequency Generator (14496-3 sp04 p215).

Definition at line 1361 of file aacsbr.c.

Referenced by ff_sbr_apply().

static void sbr_hf_inverse_filter ( float(*)  alpha0[2],
float(*)  alpha1[2],
const float  X_low[32][40][2],
int  k0 
) [static]

High Frequency Generation (14496-3 sp04 p214+) and Inverse Filtering (14496-3 sp04 p214) Warning: This routine does not seem numerically stable.

Definition at line 1262 of file aacsbr.c.

Referenced by ff_sbr_apply().

static int sbr_lf_gen ( AACContext ac,
SpectralBandReplication sbr,
float  X_low[32][40][2],
const float  W[2][32][32][2] 
) [static]

Generate the subband filtered lowband.

Definition at line 1338 of file aacsbr.c.

Referenced by ff_sbr_apply().

static int sbr_make_f_derived ( AACContext ac,
SpectralBandReplication sbr 
) [static]

Derived Frequency Band Tables (14496-3 sp04 p197).

Definition at line 552 of file aacsbr.c.

Referenced by sbr_reset().

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

Master Frequency Band Table (14496-3 sp04 p194).

Definition at line 314 of file aacsbr.c.

Referenced by sbr_reset().

static void sbr_make_f_tablelim ( SpectralBandReplication sbr  )  [static]

Limiter Frequency Band Table (14496-3 sp04 p198).

Definition at line 170 of file aacsbr.c.

Referenced by read_sbr_header(), and sbr_make_f_derived().

static void 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 1452 of file aacsbr.c.

Referenced by ff_sbr_apply().

static void sbr_qmf_analysis ( DSPContext dsp,
FFTContext mdct,
const float *  in,
float *  x,
float  z[320],
float  W[2][32][32][2] 
) [static]

Analysis QMF Bank (14496-3 sp04 p206).

Parameters:
x pointer to the beginning of the first sample window
W array of complex-valued samples split into subbands

Definition at line 1146 of file aacsbr.c.

Referenced by ff_sbr_apply().

static void sbr_qmf_synthesis ( DSPContext dsp,
FFTContext mdct,
float *  out,
float  X[2][38][64],
float  mdct_buf[2][64],
float *  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 1181 of file aacsbr.c.

Referenced by ff_sbr_apply().

static void sbr_reset ( AACContext ac,
SpectralBandReplication sbr 
) [static]

Definition at line 1033 of file aacsbr.c.

Referenced by ff_decode_sbr_extension().

static int sbr_x_gen ( SpectralBandReplication sbr,
float  X[2][38][64],
const float  X_low[32][40][2],
const float  Y[2][38][64][2],
int  ch 
) [static]

Generate the subband filtered lowband.

Definition at line 1413 of file aacsbr.c.

Referenced by ff_sbr_apply().


Variable Documentation

const int8_t ceil_log2[] [static]

Initial value:

 {
    0, 1, 2, 2, 3, 3,
}
ceil(log2(index+1))

Definition at line 615 of file aacsbr.c.

Referenced by read_sbr_grid().

VLC vlc_sbr[10] [static]

Definition at line 75 of file aacsbr.c.

const int8_t vlc_sbr_lav[10] [static]

Initial value:

    { 60, 60, 24, 24, 31, 31, 12, 12, 31, 12 }

Definition at line 76 of file aacsbr.c.

Referenced by read_sbr_envelope(), and read_sbr_noise().

const float zero64[64] [static]

Definition at line 78 of file aacsbr.c.

Referenced by sbr_qmf_synthesis().


Generated on Fri Oct 26 02:43:45 2012 for FFmpeg by  doxygen 1.5.8