Fix for divide-by-zero in ixheaacd_sbr_env_calc
These changes handle the divide-by-zero runtime error reported while calculating energy gain. Bug: ossFuzz:62903 Test: poc in bug
This commit is contained in:
parent
0c86a5d8fa
commit
2d79f3ac59
1 changed files with 11 additions and 11 deletions
|
|
@ -150,6 +150,7 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, FLOAT32
|
|||
WORD32 band_loop_end;
|
||||
|
||||
WORD32 rate = upsamp_4_flag ? 4 : 2;
|
||||
FLOAT64 guard = 1e-17;
|
||||
|
||||
if (ldmps_present == 1) rate = 1;
|
||||
|
||||
|
|
@ -349,7 +350,7 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, FLOAT32
|
|||
nrg_tone_pvc[c][t] = 0.0f;
|
||||
|
||||
tmp = frame_data->qmapped_pvc[c][t] /
|
||||
(1 + frame_data->qmapped_pvc[c][t]);
|
||||
(1 + frame_data->qmapped_pvc[c][t] + guard);
|
||||
|
||||
if (flag) {
|
||||
nrg_gain_pvc[c][t] = (FLOAT32)sqrt(nrg_ref_pvc[c][t] * tmp /
|
||||
|
|
@ -359,7 +360,7 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, FLOAT32
|
|||
(harmonics[c] && (t >= frame_data->sine_position ||
|
||||
(*harm_flag_prev)[c + sub_band_start]))
|
||||
? sqrt(nrg_ref_pvc[c][t] * tmp /
|
||||
frame_data->qmapped_pvc[c][t])
|
||||
(frame_data->qmapped_pvc[c][t] + guard))
|
||||
: nrg_tone_pvc[c][t]);
|
||||
|
||||
nrg_tone_pvc[c][t] = (FLOAT32)(
|
||||
|
|
@ -376,7 +377,7 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, FLOAT32
|
|||
} else {
|
||||
nrg_gain_pvc[c][t] = (FLOAT32)sqrt(
|
||||
nrg_ref_pvc[c][t] * tmp /
|
||||
((nrg_est_pvc[c][t] + 1) * frame_data->qmapped_pvc[c][t]));
|
||||
((nrg_est_pvc[c][t] + 1) * (frame_data->qmapped_pvc[c][t] + guard)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -400,7 +401,7 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, FLOAT32
|
|||
k < (*lim_table)[limiter_band][c + 1]; k++) {
|
||||
if (g_max <= nrg_gain_pvc[k][t]) {
|
||||
noise_level_pvc[k][t] =
|
||||
noise_level_pvc[k][t] * (g_max / nrg_gain_pvc[k][t]);
|
||||
(FLOAT32)(noise_level_pvc[k][t] * (g_max / (nrg_gain_pvc[k][t] + guard)));
|
||||
nrg_gain_pvc[k][t] = g_max;
|
||||
}
|
||||
|
||||
|
|
@ -473,7 +474,7 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, FLOAT32
|
|||
nrg_tone_pvc[c][t] = 0.0f;
|
||||
|
||||
tmp = frame_data->qmapped_pvc[c][t] /
|
||||
(1 + frame_data->qmapped_pvc[c][t]);
|
||||
(1 + frame_data->qmapped_pvc[c][t] + guard);
|
||||
|
||||
if (flag) {
|
||||
nrg_gain_pvc[c][t] = (FLOAT32)sqrt(nrg_ref_pvc[c][t] * tmp /
|
||||
|
|
@ -483,7 +484,7 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, FLOAT32
|
|||
(harmonics[c] && (t >= frame_data->sine_position ||
|
||||
(*harm_flag_prev)[c + sub_band_start]))
|
||||
? sqrt(nrg_ref_pvc[c][t] * tmp /
|
||||
frame_data->qmapped_pvc[c][t])
|
||||
(frame_data->qmapped_pvc[c][t] + guard))
|
||||
: nrg_tone_pvc[c][t]);
|
||||
} else {
|
||||
if (noise_absc_flag) {
|
||||
|
|
@ -492,7 +493,7 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, FLOAT32
|
|||
} else {
|
||||
nrg_gain_pvc[c][t] = (FLOAT32)sqrt(
|
||||
nrg_ref_pvc[c][t] * tmp /
|
||||
((nrg_est_pvc[c][t] + 1) * frame_data->qmapped_pvc[c][t]));
|
||||
((nrg_est_pvc[c][t] + 1) * (frame_data->qmapped_pvc[c][t] + guard)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -645,7 +646,7 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, FLOAT32
|
|||
ui2 = frame_data->pstr_sbr_header->pstr_freq_band_data
|
||||
->freq_band_tbl_noise[o + 1];
|
||||
|
||||
if (p_frame_info->border_vec[i] == p_frame_info->border_vec[i + 1]) {
|
||||
if (p_frame_info->border_vec[i] >= p_frame_info->border_vec[i + 1]) {
|
||||
for (flag = 0, k = li; k < ui; k++) {
|
||||
flag = (harmonics[c] &&
|
||||
(i >= trans_env || (*harm_flag_prev)[c + sub_band_start]))
|
||||
|
|
@ -677,7 +678,6 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, FLOAT32
|
|||
c -= (ui - li);
|
||||
|
||||
for (k = 0; k < ui - li; k++) {
|
||||
FLOAT64 guard = 1e-17;
|
||||
o = (k + li >= ui2) ? o + 1 : o;
|
||||
if (o >= MAX_NOISE_COEFFS) {
|
||||
if (ec_flag)
|
||||
|
|
@ -691,7 +691,7 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, FLOAT32
|
|||
nrg_est[c] = (!int_mode) ? nrg : nrg_est[c];
|
||||
nrg_tone[c] = 0;
|
||||
tmp = noise_floor[next * num_nf_bands + o] /
|
||||
(1 + noise_floor[next * num_nf_bands + o]);
|
||||
(1 + noise_floor[next * num_nf_bands + o] + guard);
|
||||
if (flag) {
|
||||
nrg_gain[c] = (FLOAT32)sqrt(nrg_ref[c] * tmp / (nrg_est[c] + 1));
|
||||
nrg_tone[c] = (FLOAT32)(
|
||||
|
|
@ -728,7 +728,7 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, FLOAT32
|
|||
for (k = (*lim_table)[limiter_band][c];
|
||||
k < (*lim_table)[limiter_band][c + 1]; k++) {
|
||||
if (g_max <= nrg_gain[k]) {
|
||||
noise_level[k] = noise_level[k] * (g_max / nrg_gain[k]);
|
||||
noise_level[k] = (FLOAT32)(noise_level[k] * (g_max / (nrg_gain[k] + guard)));
|
||||
nrg_gain[k] = g_max;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue