diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c index 81f19028224b833b3f12d0b0bbe49faa5e331c9f..7fb21cc3fb3b322722873c5fcef4cde37df827b3 100644 --- a/libavcodec/aacsbr.c +++ b/libavcodec/aacsbr.c @@ -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]); } } } diff --git a/libavcodec/aacsbr_fixed.c b/libavcodec/aacsbr_fixed.c index b4e3ac7f76395b1b1c96162fa51c834a121e1df9..6ec39c14e457c633a3c18b8f636e10ada07cfa0f 100644 --- a/libavcodec/aacsbr_fixed.c +++ b/libavcodec/aacsbr_fixed.c @@ -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; } } diff --git a/libavcodec/aacsbr_template.c b/libavcodec/aacsbr_template.c index 66f415912ccfa9b6c9d350a3932c4c8e9dbfe3db..906823ab72a1a3999a63aca3efe28063f24c7521 100644 --- a/libavcodec/aacsbr_template.c +++ b/libavcodec/aacsbr_template.c @@ -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, diff --git a/libavcodec/sbr.h b/libavcodec/sbr.h index 66a88a28988c9214a3ce949599f59bb395e191a6..f22c47501bb554314582dff56b949cbfa7931f62 100644 --- a/libavcodec/sbr.h +++ b/libavcodec/sbr.h @@ -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];