Commit bfd0e02d authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/aacsbr: Split pre dequantization noise factors table

This allows removing a special case for the fixed point decoder and will
make error checks simpler
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 50ce510a
......@@ -93,8 +93,8 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
}
for (e = 1; e <= sbr->data[0].bs_num_noise; e++) {
for (k = 0; k < sbr->n_q; k++) {
float temp1 = exp2f(NOISE_FLOOR_OFFSET - sbr->data[0].noise_facs[e][k] + 1);
float temp2 = exp2f(12 - sbr->data[1].noise_facs[e][k]);
float temp1 = exp2f(NOISE_FLOOR_OFFSET - sbr->data[0].noise_facs_q[e][k] + 1);
float temp2 = exp2f(12 - sbr->data[1].noise_facs_q[e][k]);
float fac;
if (temp1 > 1E20) {
av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n");
......@@ -121,7 +121,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
for (e = 1; e <= sbr->data[ch].bs_num_noise; e++)
for (k = 0; k < sbr->n_q; k++)
sbr->data[ch].noise_facs[e][k] =
exp2f(NOISE_FLOOR_OFFSET - sbr->data[ch].noise_facs[e][k]);
exp2f(NOISE_FLOOR_OFFSET - sbr->data[ch].noise_facs_q[e][k]);
}
}
}
......
......@@ -190,13 +190,13 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
SoftFloat temp1, temp2, fac;
temp1.exp = NOISE_FLOOR_OFFSET - \
sbr->data[0].noise_facs[e][k].mant + 2;
sbr->data[0].noise_facs_q[e][k] + 2;
temp1.mant = 0x20000000;
if (temp1.exp > 66) { // temp1 > 1E20
av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n");
temp1 = FLOAT_1;
}
temp2.exp = 12 - sbr->data[1].noise_facs[e][k].mant + 1;
temp2.exp = 12 - sbr->data[1].noise_facs_q[e][k] + 1;
temp2.mant = 0x20000000;
fac = av_div_sf(temp1, av_add_sf(FLOAT_1, temp2));
sbr->data[0].noise_facs[e][k] = fac;
......@@ -225,7 +225,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
for (e = 1; e <= sbr->data[ch].bs_num_noise; e++)
for (k = 0; k < sbr->n_q; k++){
sbr->data[ch].noise_facs[e][k].exp = NOISE_FLOOR_OFFSET - \
sbr->data[ch].noise_facs[e][k].mant + 1;
sbr->data[ch].noise_facs_q[e][k] + 1;
sbr->data[ch].noise_facs[e][k].mant = 0x20000000;
}
}
......
......@@ -906,33 +906,20 @@ static void read_sbr_noise(SpectralBandReplication *sbr, GetBitContext *gb,
f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_3_0DB];
}
#if USE_FIXED
for (i = 0; i < ch_data->bs_num_noise; i++) {
if (ch_data->bs_df_noise[i]) {
for (j = 0; j < sbr->n_q; j++)
ch_data->noise_facs[i + 1][j].mant = ch_data->noise_facs[i][j].mant + delta * (get_vlc2(gb, t_huff, 9, 2) - t_lav);
} else {
ch_data->noise_facs[i + 1][0].mant = delta * get_bits(gb, 5); // bs_noise_start_value_balance or bs_noise_start_value_level
for (j = 1; j < sbr->n_q; j++)
ch_data->noise_facs[i + 1][j].mant = ch_data->noise_facs[i + 1][j - 1].mant + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav);
}
}
#else
for (i = 0; i < ch_data->bs_num_noise; i++) {
if (ch_data->bs_df_noise[i]) {
for (j = 0; j < sbr->n_q; j++)
ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i][j] + delta * (get_vlc2(gb, t_huff, 9, 2) - t_lav);
ch_data->noise_facs_q[i + 1][j] = ch_data->noise_facs_q[i][j] + delta * (get_vlc2(gb, t_huff, 9, 2) - t_lav);
} else {
ch_data->noise_facs[i + 1][0] = delta * get_bits(gb, 5); // bs_noise_start_value_balance or bs_noise_start_value_level
ch_data->noise_facs_q[i + 1][0] = delta * get_bits(gb, 5); // bs_noise_start_value_balance or bs_noise_start_value_level
for (j = 1; j < sbr->n_q; j++)
ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav);
ch_data->noise_facs_q[i + 1][j] = ch_data->noise_facs_q[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav);
}
}
#endif /* USE_FIXED */
//assign 0th elements of noise_facs from last elements
memcpy(ch_data->noise_facs[0], ch_data->noise_facs[ch_data->bs_num_noise],
sizeof(ch_data->noise_facs[0]));
//assign 0th elements of noise_facs_q from last elements
memcpy(ch_data->noise_facs_q[0], ch_data->noise_facs_q[ch_data->bs_num_noise],
sizeof(ch_data->noise_facs_q[0]));
}
static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr,
......
......@@ -96,8 +96,10 @@ typedef struct SBRData {
AAC_FLOAT q_temp[42][48];
uint8_t s_indexmapped[8][48];
///Envelope scalefactors
uint8_t env_facs_q[6][48];
AAC_FLOAT env_facs[6][48];
///Noise scalefactors
uint8_t noise_facs_q[6][48];
AAC_FLOAT noise_facs[3][5];
///Envelope time borders
uint8_t t_env[8];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment