#include "aac.h"
#include "sbr.h"
#include "aacsbr.h"
#include "aacsbrdata.h"
#include "fft.h"
#include "aacps.h"
#include "sbrdsp.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. | |
static void | sbr_turnoff (SpectralBandReplication *sbr) |
Places SBR in pure upsampling mode. | |
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, SBRDSPContext *sbrdsp, 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, SBRDSPContext *sbrdsp, 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 | sbr_hf_inverse_filter (SBRDSPContext *dsp, 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 Y0[38][64][2], const float Y1[38][64][2], const float X_low[32][40][2], int ch) |
Generate the subband filtered lowband. | |
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). | |
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 Y1[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)) |
Definition in file aacsbr.c.
#define ENVELOPE_ADJUSTMENT_OFFSET 2 |
Definition at line 43 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 |
#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 81 of file aacsbr.c.
Referenced by ff_aac_sbr_init().
anonymous enum |
anonymous enum |
static int check_n_master | ( | AVCodecContext * | avctx, | |
int | n_master, | |||
int | bs_xover_band | |||
) | [static] |
av_cold void ff_aac_sbr_ctx_close | ( | SpectralBandReplication * | sbr | ) |
Close one SBR context.
Definition at line 162 of file aacsbr.c.
Referenced by aac_decode_close(), and che_configure().
av_cold void ff_aac_sbr_ctx_init | ( | AACContext * | ac, | |
SpectralBandReplication * | sbr | |||
) |
av_cold void ff_aac_sbr_init | ( | void | ) |
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.
crc | flag indicating the presence of CRC checksum | |
cnt | length of TYPE_FIL syntactic element in bytes |
Definition at line 1069 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 1653 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] |
Definition at line 618 of file aacsbr.c.
Referenced by read_sbr_channel_pair_element(), read_sbr_dtdf(), read_sbr_grid(), and read_sbr_single_channel_element().
static int qsort_comparison_function_int16 | ( | const void * | a, | |
const void * | b | |||
) | [static] |
Definition at line 168 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] |
static unsigned int read_sbr_data | ( | AACContext * | ac, | |
SpectralBandReplication * | sbr, | |||
GetBitContext * | gb, | |||
int | id_aac | |||
) | [static] |
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 792 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 810 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] |
static int read_sbr_grid | ( | AACContext * | ac, | |
SpectralBandReplication * | sbr, | |||
GetBitContext * | gb, | |||
SBRData * | ch_data | |||
) | [static] |
Definition at line 632 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] |
static void read_sbr_invf | ( | SpectralBandReplication * | sbr, | |
GetBitContext * | gb, | |||
SBRData * | ch_data | |||
) | [static] |
Read inverse filtering data.
Definition at line 800 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 879 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] |
static void sbr_chirp | ( | SpectralBandReplication * | sbr, | |
SBRData * | ch_data | |||
) | [static] |
Chirp Factors (14496-3 sp04 p214).
Definition at line 1290 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 1115 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 1463 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 1509 of file aacsbr.c.
Referenced by ff_sbr_apply().
static void sbr_hf_assemble | ( | float | Y1[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 1565 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 514 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 1334 of file aacsbr.c.
Referenced by ff_sbr_apply().
static void sbr_hf_inverse_filter | ( | SBRDSPContext * | dsp, | |
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 1235 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 1311 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 565 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 327 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 183 of file aacsbr.c.
Referenced by read_sbr_header(), and sbr_make_f_derived().
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 1408 of file aacsbr.c.
Referenced by ff_sbr_apply().
static void sbr_qmf_analysis | ( | DSPContext * | dsp, | |
FFTContext * | mdct, | |||
SBRDSPContext * | sbrdsp, | |||
const float * | in, | |||
float * | x, | |||
float | z[320], | |||
float | W[2][32][32][2] | |||
) | [static] |
Analysis QMF Bank (14496-3 sp04 p206).
x | pointer to the beginning of the first sample window | |
W | array of complex-valued samples split into subbands |
Definition at line 1162 of file aacsbr.c.
Referenced by ff_sbr_apply().
static void sbr_qmf_synthesis | ( | DSPContext * | dsp, | |
FFTContext * | mdct, | |||
SBRDSPContext * | sbrdsp, | |||
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 1185 of file aacsbr.c.
Referenced by ff_sbr_apply().
static void sbr_reset | ( | AACContext * | ac, | |
SpectralBandReplication * | sbr | |||
) | [static] |
static void sbr_turnoff | ( | SpectralBandReplication * | sbr | ) | [static] |
Places SBR in pure upsampling mode.
Definition at line 133 of file aacsbr.c.
Referenced by ff_aac_sbr_ctx_init(), read_sbr_data(), sbr_mapping(), and sbr_reset().
static int sbr_x_gen | ( | SpectralBandReplication * | sbr, | |
float | X[2][38][64], | |||
const float | Y0[38][64][2], | |||
const float | Y1[38][64][2], | |||
const float | X_low[32][40][2], | |||
int | ch | |||
) | [static] |
Generate the subband filtered lowband.
Definition at line 1369 of file aacsbr.c.
Referenced by ff_sbr_apply().
const int8_t ceil_log2[] [static] |
Initial value:
{ 0, 1, 2, 2, 3, 3, }
Definition at line 628 of file aacsbr.c.
Referenced by read_sbr_grid().
const int8_t vlc_sbr_lav[10] [static] |
Initial value:
{ 60, 60, 24, 24, 31, 31, 12, 12, 31, 12 }
Definition at line 77 of file aacsbr.c.
Referenced by read_sbr_envelope(), and read_sbr_noise().
const float zero64[64] [static] |