📄 g729ev_fec_decbfi.c
字号:
IF((sub(prev_bfi, G729EV_FEC_GOOD_FRAME) != 0)) { /*------------------------------------------------------------* * Speech synthesis at 8 kHz sampling rate * *------------------------------------------------------------*/ G729EV_G729_Copy(mem_tmp, mem_syn, G729EV_G729_M);#if(WMOPS) move16();#endif p_Az = Aq; FOR(i_subfr = 0; i_subfr < G729EV_MAIN_L_FRAME2; i_subfr += G729EV_G729_L_SUBFR) { G729EV_G729_Syn_filt2(p_Az, &exc_tmp[i_subfr], &synth[i_subfr], G729EV_G729_L_SUBFR, mem_syn, 1);#if(WMOPS) move16();#endif p_Az += (G729EV_G729_M + 1); } } return;}/******************************************************************************//* G729EV_FEC_enr_1_Az : To find impulse response energy *//******************************************************************************/static Word16 G729EV_FEC_enr_1_Az( /* o: impulse response energy */ Word16 Aq[], /* i: LP filter coefs */ Word16 len /* i: impulse response length */ ){ Word16 i, enr_LP, h1[2 * G729EV_G729_L_SUBFR], mem[G729EV_G729_M]; Word32 L_tmp; /* Find the impulse response */ G729EV_G729_Set_zero(h1, len); G729EV_G729_Set_zero(mem, G729EV_G729_M); h1[0] = 1024; /* h1_in Q10, h1_out Q10 */ G729EV_G729_Syn_filt(Aq, h1, h1, len, mem, 0);#if(WMOPS) move16(); move32();#endif /* Find the impulse response energy */ L_tmp = (Word32) 0; FOR(i = 0; i < len; i++) { L_tmp = L_mac0(L_tmp, h1[i], h1[i]); } enr_LP = round(L_tmp); /* Q21 to Q5 */ return enr_LP;}/******************************************************************************//* G729EV_FEC_synchro_exc : To resynchronize concealed *//* - Find number of minimum energy region *//* - Find location of minimum energy region *//* - Find number of sample to add/remove by minimum energy region *//* - Synchronisation (sample deletion/addition) *//******************************************************************************/static void G729EV_FEC_synchro_exc(Word16 * exc, /* i/o : exc vector to modify */ Word16 desire_puls_pos, /* Pulse position send by the encoder */ Word16 true_puls_pos, /* Present pulse location */ Word16 Old_pitch /* Pitch use to create temporary adaptive codebook */ ){ Word16 exc_tmp[G729EV_MAIN_L_FRAME2 + G729EV_G729_L_SUBFR], *pt_exc, *pt_exc1, tmp16, fact; Word32 L_tmp, L_tmp1; Word16 remaining_len; Word16 i, j, k, point_to_remove, point_to_add, nb_min, points_by_pos[10], total_point; Word16 *pt_pos, pos, start_search, tmp_len; Word16 min_pos[10]; point_to_add = -1;#if(WMOPS) move16();#endif FOR(i = 0; i < 10; i++) { min_pos[i] = (Word16) - 10000; points_by_pos[i] = (Word16) 0;#if(WMOPS) move16(); move16();#endif } /* Find number of point to remove and number of minimum */ point_to_remove = sub(true_puls_pos, desire_puls_pos); /* if it is negative it means remove point else it means add point */ /* Find number of minimum energy region */ tmp16 = shl(Old_pitch, 7); tmp_len = sub(G729EV_MAIN_L_FRAME2, true_puls_pos); tmp16 = div_s(shl(tmp_len, 3), tmp16); nb_min = shr(tmp16, 11); /* if Old pitch < 80, must have at least 2 min */#if (WMOPS) test();#endif if (sub(Old_pitch, 80) <= 0 && sub(nb_min, 2) < 0) { nb_min = (Word16) 2;#if(WMOPS) move16();#endif } /* Must have at least 1 min */ if (nb_min == 0) { nb_min = (Word16) 1;#if(WMOPS) move16();#endif }#if(WMOPS) move16(); move16();#endif pos = tmp_len; pt_exc = exc + pos; /* Find starting point for minimum energy search */ start_search = shr_r(i_mult(-3, Old_pitch), 2); IF(add(start_search, pos) < 0) { start_search = negate(pos); if (sub(abs_s(start_search), shr(Old_pitch, 3)) < 0) { /* it's not safe to remove/add point inside 1/8 of the pulse position */ return; } } /* Find min energy in the first pitch section */#if(WMOPS) move32();#endif /* -------------------------------------------------------------------- * The minimum energy regions are determined by the computing the energy * using a sliding 5-sample window. The minimum energy position is set * at the middle of the window at which the energy is at minimum * --------------------------------------------------------------------*/ L_tmp = MAX_32; L_tmp1 = L_mult(pt_exc[start_search], pt_exc[start_search]); L_tmp1 = L_mac(L_tmp1, pt_exc[start_search + 1], pt_exc[start_search + 1]); L_tmp1 = L_mac(L_tmp1, pt_exc[start_search + 2], pt_exc[start_search + 2]); L_tmp1 = L_mac(L_tmp1, pt_exc[start_search + 3], pt_exc[start_search + 3]); L_tmp1 = L_mac(L_tmp1, pt_exc[start_search + 4], pt_exc[start_search + 4]); IF(L_sub(L_tmp1, L_tmp) < 0) { L_tmp = L_tmp1; min_pos[0] = add(add(pos, start_search), 2);#if(WMOPS) move32(); move16();#endif } FOR(i = start_search; i < -5; i++) { L_tmp1 = L_msu(L_tmp1, pt_exc[i], pt_exc[i]); L_tmp1 = L_mac(L_tmp1, pt_exc[i + 5], pt_exc[i + 5]); IF(L_sub(L_tmp1, L_tmp) < 0) { L_tmp = L_tmp1; min_pos[0] = add(add(pos, i), 2);#if(WMOPS) move32(); move16();#endif } } FOR(j = 1; j < nb_min; j++) {#if(WMOPS) move16();#endif min_pos[j] = sub(min_pos[j - 1], Old_pitch); /* If the first minimum is in the past, forget this minimum */ if (min_pos[j] < 0) { min_pos[j] = -10000; nb_min = sub(nb_min, 1);#if(WMOPS) move16();#endif } } /* -------------------------------------------------------------------- * Determine the number of samples to be added or removed at each pitch * cycle whereby less samples are added/removed at the beginning and * more towards the end of the frame * --------------------------------------------------------------------*/#if(WMOPS) test();#endif IF(sub(nb_min, 1) == 0 || sub(abs_s(point_to_remove), 1) == 0) { nb_min = 1; points_by_pos[0] = abs_s(point_to_remove); total_point = points_by_pos[0];#if(WMOPS) move16(); move16(); move16();#endif } ELSE { /* First position */ /*fact = (float)fabs(point_to_remove) / sqi[nb_min-2]; (nb_min*nb_min); */ fact = mult_r(shl(abs_s(point_to_remove), 7), inv_sqi[nb_min - 2]); /*Q7 */ points_by_pos[0] = shr(add(fact, 64), 7); /*Q7 */ total_point = points_by_pos[0];#if(WMOPS) move16(); move16();#endif FOR(i = 2; i <= nb_min; i++) { /*points_by_pos[i-1] = (Word16)(fact*(sqi[i-2]) - total_point+0.5) ; */#if(WMOPS) move16();#endif points_by_pos[i - 1] = sub(shr(add(i_mult(fact, sqi[i - 2]), 64), 7), total_point); total_point = add(total_point, points_by_pos[i - 1]); /* ensure a constant increase */ IF(sub(points_by_pos[i - 1], points_by_pos[i - 2]) < 0) {#if(WMOPS) move16(); move16(); move16();#endif tmp16 = points_by_pos[i - 2]; points_by_pos[i - 2] = points_by_pos[i - 1]; points_by_pos[i - 1] = tmp16; } } } /* -------------------------------------------------------------------- * Sample deletion or insertion is performed in minimum energy regions. * At the end of this section the last maximum pulse in the concealed * excitation is forced to align to the actual maximum pulse position * at the end of the frame which is transmitted in the future frame. * --------------------------------------------------------------------*/ if (point_to_remove > 0) { point_to_add = point_to_remove;#if(WMOPS) move16();#endif } pt_exc = exc_tmp; pt_exc1 = exc; pt_pos = min_pos + sub(nb_min, 1);#if(WMOPS) move16(); move16();#endif i = 0; k = 0; pt_pos = min_pos + sub(nb_min, 1); IF(point_to_add > 0) /* Samples insertion */ { remaining_len = G729EV_MAIN_L_FRAME2;#if(WMOPS) move16();#endif FOR(i = 0; i < nb_min; i++) { if (i == 0) { /*Compute len to copy */ tmp_len = *pt_pos;#if(WMOPS) move16();#endif } IF(i > 0) { /*Compute len to copy */ tmp_len = sub(sub(*pt_pos, *(pt_pos + 1)), points_by_pos[i - 1]); } /*Copy section */ G729EV_G729_Copy(pt_exc1, pt_exc, tmp_len); remaining_len = sub(remaining_len, tmp_len);#if(WMOPS) move16(); move16();#endif pt_exc1 += tmp_len; pt_exc += tmp_len; /*Find point to add and Add points */ tmp16 = mult_r(*pt_exc1, -1638); FOR(j = 0; j < points_by_pos[i]; j++) { *pt_exc++ = tmp16; /* repeat last point */ tmp16 = negate(tmp16);#if(WMOPS) move16();#endif } remaining_len = sub(remaining_len, points_by_pos[i]); pt_pos--; } /* Copy remaining data */ G729EV_G729_Copy(pt_exc1, pt_exc, remaining_len); /* Update excitation vector */ G729EV_G729_Copy(exc_tmp, exc, G729EV_MAIN_L_FRAME2); } ELSE /* Samples deletion */ { remaining_len = G729EV_MAIN_L_FRAME2;#if(WMOPS) move16();#endif FOR(i = 0; i < nb_min; i++) { if (i == 0) { /*Compute len to copy */ tmp_len = *pt_pos;#if(WMOPS) move16();#endif } IF(i > 0) { /*Compute len to copy */ tmp_len = sub(sub(*pt_pos, *(pt_pos + 1)), points_by_pos[i - 1]); } G729EV_G729_Copy(pt_exc1, pt_exc, tmp_len); remaining_len = sub(remaining_len, tmp_len); pt_exc1 += tmp_len; pt_exc += tmp_len;#if(WMOPS) move16(); move16();#endif /* Remove points */ FOR(j = 0; j < points_by_pos[i]; j++) { pt_exc1++; } pt_pos--; } /* Copy remaining data */ G729EV_G729_Copy(pt_exc1, pt_exc, remaining_len); /* Update excitation vector */ G729EV_G729_Copy(exc_tmp, exc, G729EV_MAIN_L_FRAME2); } return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -