Go to the documentation of this file.
41 for (n = 0; n < 320; n++)
48 const void *sbr_codes, *sbr_bits;
49 const unsigned int table_size, elem_size;
100 sbr->kx[0] = sbr->kx[1];
101 sbr->id_aac = id_aac;
138 return *(
const int16_t *)
a - *(
const int16_t *)
b;
144 for (
i = 0;
i <= last_el;
i++)
155 static const INTFLOAT bands_warped[3] = {
Q23(1.32715174233856803909
f),
156 Q23(1.18509277094158210129
f),
157 Q23(1.11987160404675912501
f) };
159 int16_t patch_borders[7];
162 patch_borders[0] = sbr->
kx[1];
169 memcpy(sbr->
f_tablelim + sbr->
n[0] + 1, patch_borders + 1,
170 (sbr->
num_patches - 1) *
sizeof(patch_borders[0]));
177 while (out < sbr->f_tablelim + sbr->
n_lim) {
179 if ((*in << 23) >= *
out * lim_bands_per_octave_warped) {
181 if (*in >= *
out * lim_bands_per_octave_warped) {
184 }
else if (*in == *
out ||
205 uint8_t bs_header_extra_1;
206 uint8_t bs_header_extra_2;
225 if (bs_header_extra_1) {
239 if (bs_header_extra_2) {
260 for (
i = 1;
i < nel;
i++)
272 if (bs_xover_band >= n_master) {
274 "Invalid bitstream, crossover band index beyond array bounds: %d\n",
285 unsigned int temp, max_qmf_subbands = 0;
286 unsigned int start_min, stop_min;
288 const int8_t *sbr_offset_ptr;
304 case 44100:
case 48000:
case 64000:
307 case 88200:
case 96000:
case 128000:
case 176400:
case 192000:
312 "Unsupported sample rate for SBR: %d\n", sbr->
sample_rate);
329 sbr->
k[2] = stop_min;
333 sbr->
k[2] += stop_dk[k];
335 sbr->
k[2] = 2*sbr->
k[0];
337 sbr->
k[2] = 3*sbr->
k[0];
343 sbr->
k[2] =
FFMIN(64, sbr->
k[2]);
347 max_qmf_subbands = 48;
349 max_qmf_subbands = 35;
351 max_qmf_subbands = 32;
355 if (sbr->
k[2] - sbr->
k[0] > max_qmf_subbands) {
357 "Invalid bitstream, too many QMF subbands: %d\n", sbr->
k[2] - sbr->
k[0]);
365 sbr->
n_master = ((sbr->
k[2] - sbr->
k[0] + (dk&2)) >> dk) << 1;
369 for (k = 1; k <= sbr->
n_master; k++)
372 k2diff = sbr->
k[2] - sbr->
k[0] - sbr->
n_master * dk;
381 for (k = 1; k <= sbr->
n_master; k++)
386 int two_regions, num_bands_0;
387 int vdk0_max, vdk1_min;
393 if (49 * sbr->
k[2] > 110 * sbr->
k[0]) {
395 sbr->
k[1] = 2 * sbr->
k[0];
398 sbr->
k[1] = sbr->
k[2];
402 tmp = (sbr->
k[1] << 23) / sbr->
k[0];
403 while (
tmp < 0x40000000) {
409 tmp = (((
tmp + 0x80) >> 8) + ((8 - nz) << 23)) * half_bands;
410 num_bands_0 = ((
tmp + 0x400000) >> 23) * 2;
412 num_bands_0 =
lrintf(half_bands *
log2f(sbr->
k[1] / (
float)sbr->
k[0])) * 2;
415 if (num_bands_0 <= 0) {
425 vdk0_max = vk0[num_bands_0];
428 for (k = 1; k <= num_bands_0; k++) {
441 tmp = (sbr->
k[2] << 23) / sbr->
k[1];
443 while (
tmp < 0x40000000) {
449 tmp = (((
tmp + 0x80) >> 8) + ((8 - nz) << 23)) * half_bands;
452 num_bands_1 = ((
tmp + 0x400000) >> 23) * 2;
454 float invwarp = spectrum->
bs_alter_scale ? 0.76923076923076923077f
456 int num_bands_1 =
lrintf(half_bands * invwarp *
457 log2f(sbr->
k[2] / (
float)sbr->
k[1])) * 2;
463 if (vdk1_min < vdk0_max) {
466 change =
FFMIN(vdk0_max - vk1[1], (vk1[num_bands_1] - vk1[1]) >> 1);
468 vk1[num_bands_1] -= change;
474 for (k = 1; k <= num_bands_1; k++) {
482 sbr->
n_master = num_bands_0 + num_bands_1;
486 (num_bands_0 + 1) *
sizeof(sbr->
f_master[0]));
487 memcpy(&sbr->
f_master[num_bands_0 + 1], vk1 + 1,
488 num_bands_1 *
sizeof(sbr->
f_master[0]));
504 int i, k, last_k = -1, last_msb = -1, sb = 0;
506 int usb = sbr->
kx[1];
511 if (goal_sb < sbr->kx[1] + sbr->
m[1]) {
512 for (k = 0; sbr->
f_master[k] < goal_sb; k++) ;
518 if (k == last_k && msb == last_msb) {
524 for (
i = k;
i == k || sb > (sbr->
k[0] - 1 + msb - odd);
i--) {
526 odd = (sb + sbr->
k[0]) & 1;
550 }
while (sb != sbr->
kx[1] + sbr->
m[1]);
568 sbr->
n[0] = (sbr->
n[1] + 1) >> 1;
571 (sbr->
n[1] + 1) *
sizeof(sbr->
f_master[0]));
576 if (sbr->
kx[1] + sbr->
m[1] > 64) {
578 "Stop frequency border too high: %d\n", sbr->
kx[1] + sbr->
m[1]);
581 if (sbr->
kx[1] > 32) {
587 temp = sbr->
n[1] & 1;
588 for (k = 1; k <= sbr->
n[0]; k++)
591 temp = (sbr->
k[2] << 23) / sbr->
kx[1];
592 while (
temp < 0x40000000) {
600 sbr->
n_q = (
temp + 0x400000) >> 23;
605 log2f(sbr->
k[2] / (
float)sbr->
kx[1])));
615 for (k = 1; k <= sbr->
n_q; k++) {
651 int abs_bord_trail = 16;
652 int num_rel_lead, num_rel_trail;
653 unsigned bs_num_env_old = ch_data->
bs_num_env;
654 int bs_frame_class, bs_num_env;
660 switch (bs_frame_class =
get_bits(gb, 2)) {
663 if (bs_num_env > 4) {
665 "Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n",
675 ch_data->
t_env[0] = 0;
678 abs_bord_trail = (abs_bord_trail + (ch_data->
bs_num_env >> 1)) /
680 for (
i = 0;
i < num_rel_lead;
i++)
681 ch_data->
t_env[
i + 1] = ch_data->
t_env[
i] + abs_bord_trail;
691 ch_data->
t_env[0] = 0;
694 for (
i = 0;
i < num_rel_trail;
i++)
709 for (
i = 0;
i < num_rel_lead;
i++)
721 bs_num_env = num_rel_lead + num_rel_trail + 1;
723 if (bs_num_env > 5) {
725 "Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n",
733 for (
i = 0;
i < num_rel_lead;
i++)
735 for (
i = 0;
i < num_rel_trail;
i++)
749 "Invalid bitstream, bs_pointer points to a middle noise border outside the time borders table: %d\n",
763 ch_data->
t_q[0] = ch_data->
t_env[0];
774 else if (bs_pointer == 1)
777 idx = bs_pointer - 1;
779 ch_data->
t_q[1] = ch_data->
t_env[idx];
782 ch_data->
e_a[0] = -(ch_data->
e_a[1] != bs_num_env_old);
783 ch_data->
e_a[1] = -1;
787 ch_data->
e_a[1] = bs_pointer - 1;
801 memcpy(dst->
t_q,
src->t_q,
sizeof(dst->
t_q));
806 dst->
e_a[1] =
src->e_a[1];
824 for (
i = 0;
i < sbr->
n_q;
i++)
833 const VLCElem *t_huff, *f_huff;
836 const int odd = sbr->
n[1] & 1;
890 k = j ? 2*j - odd : 0;
921 const VLCElem *t_huff, *f_huff;
939 for (j = 0; j < sbr->
n_q; j++) {
948 for (j = 1; j < sbr->
n_q; j++) {
966 int bs_extension_id,
int *num_bits_left)
968 switch (bs_extension_id) {
971 av_log(ac->
avctx,
AV_LOG_ERROR,
"Parametric Stereo signaled to be not-present but was found in the bitstream.\n");
983 if (bs_extension_id || *num_bits_left > 16 ||
show_bits(gb, *num_bits_left))
1087 "Invalid bitstream - cannot apply SBR to element type %d\n", id_aac);
1092 int num_bits_left =
get_bits(gb, 4);
1093 if (num_bits_left == 15)
1096 num_bits_left <<= 3;
1097 while (num_bits_left > 7) {
1101 if (num_bits_left < 0) {
1104 if (num_bits_left > 0)
1119 "SBR reset failed. Switching SBR to pure upsampling mode.\n");
1135 unsigned int num_sbr_bits = 0, num_align_bits;
1136 unsigned bytes_read;
1142 if (!sbr->sample_rate)
1143 sbr->sample_rate = 2 * ac->oc[1].m4ac.sample_rate;
1144 if (!ac->oc[1].m4ac.ext_sample_rate)
1145 ac->oc[1].m4ac.ext_sample_rate = 2 * ac->oc[1].m4ac.sample_rate;
1153 sbr->kx[0] = sbr->kx[1];
1154 sbr->m[0] = sbr->m[1];
1155 sbr->kx_and_m_pushed = 1;
1167 num_align_bits = ((cnt << 3) - 4 - num_sbr_bits) & 7;
1168 bytes_read = ((num_sbr_bits + num_align_bits + 4) >> 3);
1170 if (bytes_read > cnt) {
1172 "Expected to read %d SBR bytes actually read %d.\n", cnt, bytes_read);
1184 #ifndef sbr_qmf_analysis
1199 memcpy(x , x+1024, (320-32)*
sizeof(x[0]));
1200 memcpy(x+288, in, 1024*
sizeof(x[0]));
1201 for (
i = 0;
i < 32;
i++) {
1205 sbrdsp->qmf_pre_shuffle(z);
1207 for (j = 64; j < 128; j++) {
1210 "sbr_qmf_analysis: value %09d too large, setting to %09d\n",
1213 }
else if (z[j] < -(1<<24)) {
1215 "sbr_qmf_analysis: value %09d too small, setting to %09d\n",
1221 mdct_fn(mdct, z, z + 64,
sizeof(
INTFLOAT));
1222 sbrdsp->qmf_post_shuffle(
W[buf_idx][
i], z);
1232 #ifndef sbr_qmf_synthesis
1241 INTFLOAT *
v0,
int *v_off,
const unsigned int div)
1245 const int step = 128 >> div;
1247 for (
i = 0;
i < 32;
i++) {
1248 if (*v_off <
step) {
1249 int saved_samples = (1280 - 128) >> div;
1257 for (n = 0; n < 32; n++) {
1258 X[0][
i][ n] = -
X[0][
i][n];
1259 X[0][
i][32+n] =
X[1][
i][31-n];
1261 mdct_fn(mdct, mdct_buf[0],
X[0][
i],
sizeof(
INTFLOAT));
1262 sbrdsp->qmf_deint_neg(v, mdct_buf[0]);
1264 sbrdsp->neg_odd_64(
X[1][
i]);
1265 mdct_fn(mdct, mdct_buf[0],
X[0][
i],
sizeof(
INTFLOAT));
1266 mdct_fn(mdct, mdct_buf[1],
X[1][
i],
sizeof(
INTFLOAT));
1267 sbrdsp->qmf_deint_bfly(v, mdct_buf[1], mdct_buf[0]);
1290 const int t_HFGen = 8;
1292 memset(X_low, 0, 32*
sizeof(*X_low));
1293 for (k = 0; k < sbr->
kx[1]; k++) {
1294 for (
i = t_HFGen;
i < i_f + t_HFGen;
i++) {
1295 X_low[k][
i][0] =
W[buf_idx][
i - t_HFGen][k][0];
1296 X_low[k][
i][1] =
W[buf_idx][
i - t_HFGen][k][1];
1299 buf_idx = 1-buf_idx;
1300 for (k = 0; k < sbr->
kx[0]; k++) {
1301 for (
i = 0;
i < t_HFGen;
i++) {
1302 X_low[k][
i][0] =
W[buf_idx][
i + i_f - t_HFGen][k][0];
1303 X_low[k][
i][1] =
W[buf_idx][
i + i_f - t_HFGen][k][1];
1313 const INTFLOAT bw_array[5],
const uint8_t *t_env,
1328 "ERROR : no subband found for frequency %d\n", k);
1334 alpha0[p], alpha1[p], bw_array[
g],
1335 2 * t_env[0], 2 * t_env[bs_num_env]);
1338 if (k < sbr->m[1] + sbr->
kx[1])
1339 memset(X_high + k, 0, (sbr->
m[1] + sbr->
kx[1] - k) *
sizeof(*X_high));
1347 const INTFLOAT X_low[32][40][2],
int ch)
1352 memset(
X, 0, 2*
sizeof(*
X));
1353 for (k = 0; k < sbr->
kx[0]; k++) {
1354 for (
i = 0;
i < i_Temp;
i++) {
1359 for (; k < sbr->
kx[0] + sbr->
m[0]; k++) {
1360 for (
i = 0;
i < i_Temp;
i++) {
1361 X[0][
i][k] = Y0[
i + i_f][k][0];
1362 X[1][
i][k] = Y0[
i + i_f][k][1];
1366 for (k = 0; k < sbr->
kx[1]; k++) {
1367 for (
i = i_Temp;
i < 38;
i++) {
1372 for (; k < sbr->
kx[1] + sbr->
m[1]; k++) {
1373 for (
i = i_Temp;
i < i_f;
i++) {
1374 X[0][
i][k] = Y1[
i][k][0];
1375 X[1][
i][k] = Y1[
i][k][1];
1391 const unsigned int ilim = sbr->
n[ch_data->
bs_freq_res[e + 1]];
1397 "Derived frequency tables were not regenerated.\n");
1401 for (
i = 0;
i < ilim;
i++)
1407 for (
i = 0;
i < sbr->
n_q;
i++)
1408 for (m = sbr->
f_tablenoise[
i]; m < sbr->f_tablenoise[
i + 1]; m++)
1411 for (
i = 0;
i < sbr->
n[1];
i++) {
1413 const unsigned int m_midpoint =
1417 (e >= e_a[1] || (ch_data->
s_indexmapped[0][m_midpoint - sbr->
kx[1]] == 1));
1421 for (
i = 0;
i < ilim;
i++) {
1422 int additional_sinusoid_present = 0;
1425 additional_sinusoid_present = 1;
1429 memset(&sbr->
s_mapped[e][
table[
i] - sbr->
kx[1]], additional_sinusoid_present,
1443 int kx1 = sbr->
kx[1];
1450 const float recip_env_size = 0.5f / (ch_data->
t_env[e + 1] - ch_data->
t_env[e]);
1455 for (m = 0; m < sbr->
m[1]; m++) {
1458 e_curr[e][m] =
av_mul_sf(sum, recip_env_size);
1460 e_curr[e][m] = sum * recip_env_size;
1468 const int env_size = 2 * (ch_data->
t_env[e + 1] - ch_data->
t_env[e]);
1473 for (p = 0; p < sbr->
n[ch_data->
bs_freq_res[e + 1]]; p++) {
1483 const int den = env_size * (
table[p + 1] -
table[p]);
1491 e_curr[e][k - kx1] = sum;
1501 int downsampled = ac->oc[1].m4ac.ext_sample_rate < sbr->sample_rate;
1503 int nch = (id_aac ==
TYPE_CPE) ? 2 : 1;
1506 if (id_aac != sbr->id_aac) {
1508 "element type mismatch %d != %d\n", id_aac, sbr->id_aac);
1512 if (sbr->start && !sbr->ready_for_dequant) {
1514 "No quantized data read for sbr_dequant.\n");
1518 if (!sbr->kx_and_m_pushed) {
1519 sbr->kx[0] = sbr->kx[1];
1520 sbr->m[0] = sbr->m[1];
1522 sbr->kx_and_m_pushed = 0;
1527 sbr->ready_for_dequant = 0;
1529 for (ch = 0; ch < nch; ch++) {
1532 ch ?
R :
L, sbr->data[ch].analysis_filterbank_samples,
1533 (
INTFLOAT*)sbr->qmf_filter_scratch,
1534 sbr->data[ch].W, sbr->data[ch].Ypos);
1535 sbr->c.sbr_lf_gen(ac, sbr, sbr->X_low,
1536 (
const INTFLOAT (*)[32][32][2]) sbr->data[ch].W,
1537 sbr->data[ch].Ypos);
1538 sbr->data[ch].Ypos ^= 1;
1540 sbr->c.sbr_hf_inverse_filter(&sbr->dsp, sbr->alpha0, sbr->alpha1,
1541 (
const INTFLOAT (*)[40][2]) sbr->X_low, sbr->k[0]);
1545 (
const INTFLOAT (*)[40][2]) sbr->X_low,
1546 (
const INTFLOAT (*)[2]) sbr->alpha0,
1547 (
const INTFLOAT (*)[2]) sbr->alpha1,
1548 sbr->data[ch].bw_array, sbr->data[ch].t_env,
1549 sbr->data[ch].bs_num_env);
1552 err =
sbr_mapping(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a);
1556 sbr->c.sbr_hf_assemble(sbr->data[ch].Y[sbr->data[ch].Ypos],
1557 (
const INTFLOAT (*)[40][2]) sbr->X_high,
1558 sbr, &sbr->data[ch],
1564 sbr->c.sbr_x_gen(sbr, sbr->X[ch],
1565 (
const INTFLOAT (*)[64][2]) sbr->data[ch].Y[1-sbr->data[ch].Ypos],
1566 (
const INTFLOAT (*)[64][2]) sbr->data[ch].Y[ sbr->data[ch].Ypos],
1567 (
const INTFLOAT (*)[40][2]) sbr->X_low, ch);
1570 if (ac->oc[1].m4ac.ps == 1) {
1571 if (sbr->ps.common.start) {
1574 memcpy(sbr->X[1], sbr->X[0],
sizeof(sbr->X[0]));
1580 L, sbr->X[0], sbr->qmf_filter_scratch,
1581 sbr->data[0].synthesis_filterbank_samples,
1582 &sbr->data[0].synthesis_filterbank_samples_offset,
1586 R, sbr->X[1], sbr->qmf_filter_scratch,
1587 sbr->data[1].synthesis_filterbank_samples,
1588 &sbr->data[1].synthesis_filterbank_samples_offset,
void(* hf_gen)(INTFLOAT(*X_high)[2], const INTFLOAT(*X_low)[2], const INTFLOAT alpha0[2], const INTFLOAT alpha1[2], INTFLOAT bw, int start, int end)
static void sbr_reset(AACContext *ac, SpectralBandReplication *sbr)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
@ T_HUFFMAN_ENV_BAL_1_5DB
av_cold void AAC_RENAME() ff_aac_sbr_init(void)
Initialize SBR.
unsigned bs_limiter_gains
static const ElemCat * elements[ELEMENT_COUNT]
AAC_FLOAT e_origmapped[7][48]
Dequantized envelope scalefactors, remapped.
AAC_FLOAT env_facs[6][48]
static void sbr_chirp(SpectralBandReplication *sbr, SBRData *ch_data)
Chirp Factors (14496-3 sp04 p214)
static int sbr_hf_calc_npatches(AACContext *ac, SpectralBandReplication *sbr)
High Frequency Generation - Patch Construction (14496-3 sp04 p216 fig. 4.46)
av_cold void AAC_RENAME() ff_aac_sbr_ctx_close(SpectralBandReplication *sbr)
Close one SBR context.
void(* vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len)
Calculate the entry wise product of two vectors of floats, and store the result in a vector of floats...
static int get_bits_count(const GetBitContext *s)
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: Thi...
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
AAC_SIGNE m[2]
M' and M respectively, M is the number of QMF subbands that use SBR.
static const uint16_t table[]
uint8_t t_env_num_env_old
Envelope time border of the last envelope of the previous frame.
static void copy_sbr_grid(SBRData *dst, const SBRData *src)
#define AV_LOG_VERBOSE
Detailed information.
av_cold void AAC_RENAME() ff_ps_init(void)
uint8_t t_env[8]
Envelope time borders.
static int qsort_comparison_function_int16(const void *a, const void *b)
static int read_sbr_envelope(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data, int ch)
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
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)
static void skip_bits(GetBitContext *s, int n)
#define SBR_VLC_ROW(name)
int e_a[2]
l_APrev and l_A
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
unsigned bs_interpol_freq
AAC_SIGNE n_master
The number of frequency bands in f_master.
unsigned bs_add_harmonic_flag
static int read_sbr_channel_pair_element(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb)
static av_always_inline float scale(float x, float s)
AAC_FLOAT noise_facs[3][5]
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)
static INTFLOAT sbr_qmf_window_ds[320]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
@ AV_TX_FLOAT_MDCT
Standard MDCT with a sample data type of float, double or int32_t, respecively.
static unsigned int read_sbr_header(SpectralBandReplication *sbr, GetBitContext *gb)
static int sbr_make_f_derived(AACContext *ac, SpectralBandReplication *sbr)
Derived Frequency Band Tables (14496-3 sp04 p197)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static const int8_t sbr_offset[6][16]
window coefficients for analysis/synthesis QMF banks
uint16_t f_tablenoise[6]
Frequency borders for noise floors.
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.
AAC_SIGNE n_lim
Number of limiter bands.
uint8_t env_facs_q[6][48]
Envelope scalefactors.
uint16_t f_tablelow[25]
Frequency borders for low resolution SBR.
static const SoftFloat FLOAT_0
0.0
static int read_sbr_single_channel_element(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb)
static int check_n_master(AVCodecContext *avctx, int n_master, int bs_xover_band)
uint16_t f_tablelim[30]
Frequency borders for the limiter.
static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, SpectrumParameters *spectrum)
Master Frequency Band Table (14496-3 sp04 p194)
uint8_t bs_add_harmonic[48]
static unsigned int get_bits1(GetBitContext *s)
aacsbr functions pointers
static int fixed_log(int x)
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)
#define SBR_SYNTHESIS_BUF_SIZE
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.
av_cold int AAC_RENAME() ff_aac_sbr_ctx_init(AACContext *ac, SpectralBandReplication *sbr, int id_aac)
Initialize one SBR context.
static void make_bands(int16_t *bands, int start, int stop, int num_bands)
AAC_SIGNE n[2]
N_Low and N_High respectively, the number of frequency bands for low and high resolution.
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
uint8_t s_indexmapped[8][48]
static void read_sbr_dtdf(SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data)
Read how the envelope and noise floor data is delta coded.
unsigned bs_smoothing_mode
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.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the pr...
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)
uint16_t f_master[49]
The master QMF frequency grouping.
void(* vector_fmul)(float *dst, const float *src0, const float *src1, int len)
Calculate the entry wise product of two vectors of floats and store the result in a vector of floats.
#define SBR_INIT_VLC_STATIC(num, size)
static void sbr_turnoff(SpectralBandReplication *sbr)
Places SBR in pure upsampling mode.
Spectral Band Replication.
uint8_t bs_invf_mode[2][5]
av_cold void AAC_RENAME() ff_ps_ctx_init(PSContext *ps)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
void ff_aacsbr_func_ptr_init_mips(AACSBRContext *c)
AAC_SIGNE n_q
Number of noise floor bands.
uint8_t patch_start_subband[6]
static const int CONST_076923
static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int bs_extension_id, int *num_bits_left)
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
void AAC_RENAME() ff_sbrdsp_init(SBRDSPContext *s)
static void aacsbr_func_ptr_init(AACSBRContext *c)
static const int CONST_RECIP_LN2
#define i(width, name, range_min, range_max)
static const int8_t ceil_log2[]
ceil(log2(index+1))
#define AV_QSORT(p, num, type, cmp)
Quicksort This sort is fast, and fully inplace but not stable and it is possible to construct input t...
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
Spectral Band Replication per channel data.
static int read_sbr_noise(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data, int ch)
void(* vector_fmul_add)(float *dst, const float *src0, const float *src1, const float *src2, int len)
Calculate the entry wise product of two vectors of floats, add a third vector of floats and store the...
static int in_table_int16(const int16_t *table, int last_el, int16_t needle)
static av_const SoftFloat av_int2sf(int v, int frac_bits)
Converts a mantisse and exponent to a SoftFloat.
@ T_HUFFMAN_NOISE_BAL_3_0DB
static void sbr_make_f_tablelim(SpectralBandReplication *sbr)
Limiter Frequency Band Table (14496-3 sp04 p198)
@ T_HUFFMAN_ENV_BAL_3_0DB
OutputConfiguration oc[2]
@ F_HUFFMAN_ENV_BAL_3_0DB
static void read_sbr_invf(SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data)
Read inverse filtering data.
static int array[MAX_W *MAX_W]
static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
Dequantization and stereo decoding (14496-3 sp04 p203)
static const int8_t vlc_sbr_lav[10]
static int array_min_int16(const int16_t *array, int nel)
static av_cold void aacsbr_tableinit(void)
main external API structure.
#define AV_PROFILE_AAC_HE_V2
static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int id_aac)
int ps
-1 implicit, 1 presence
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)
uint8_t t_q[3]
Noise time borders.
SpectrumParameters spectrum_params
static av_const SoftFloat av_add_sf(SoftFloat a, SoftFloat b)
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.
static const INTFLOAT sbr_qmf_window_us[640]
uint16_t f_tablehigh[49]
Frequency borders for high resolution SBR.
uint8_t noise_facs_q[3][5]
Noise scalefactors.
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)
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 ...
unsigned bs_limiter_bands
uint8_t patch_num_subbands[6]
#define avpriv_request_sample(...)
AAC_FLOAT(* sum_square)(INTFLOAT(*x)[2], int n)
#define ENVELOPE_ADJUSTMENT_OFFSET
int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb, PSCommonContext *ps, int bits_left)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int AAC_RENAME() ff_ps_apply(AVCodecContext *avctx, PSContext *ps, INTFLOAT L[2][38][64], INTFLOAT R[2][38][64], int top)
@ F_HUFFMAN_ENV_BAL_1_5DB
AAC_FLOAT q_mapped[7][48]
Dequantized noise scalefactors, remapped.
static av_always_inline void get_bits1_vector(GetBitContext *gb, uint8_t *vec, int elements)
AAC_SIGNE kx[2]
kx', and kx respectively, kx is the first QMF subband where SBR is used.
static av_const SoftFloat av_mul_sf(SoftFloat a, SoftFloat b)
uint8_t s_mapped[7][48]
Sinusoidal presence, remapped.
static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, SBRData *ch_data)