📄 phi_axit.c
字号:
float *h; /* Array for the impulse response of 1/A(z) */ float *t; /* Array for the cbk-search target signal */ float *e; float *vtmp; /* Temporary Array (Used duing Backward Filt */ float *scratch; /* Temporary Array (Used duing Backward Filt */ long **fixed_cbk; /* 2-d Array for generating the fixed codebook */ float cba_gain; /* Adaptive Codebook Gain */ float cbf_gain; /* Fixed Codebook Gain */ long cbf_pi[FCBK_PRESELECT_VECS]; /* Array for pre-selected fixed cbk candidates */ long phase; /* Phase of the RPE codebook */ int i; /* Local indices */ /*==================================================================*/ /* Memory allocation for temporary arrays */ /*==================================================================*/ if ( (( h = (float *)malloc((unsigned int)sbfrm_size * sizeof(float))) == NULL ) || (( t = (float *)malloc((unsigned int)sbfrm_size * sizeof(float))) == NULL ) || (( e = (float *)malloc((unsigned int)sbfrm_size * sizeof(float))) == NULL ) || (( amp = (long *)malloc((unsigned int)PHI_Np * sizeof(long))) == NULL ) || (( pos = (long *)malloc((unsigned int)PHI_Np * sizeof(long))) == NULL ) || (( scratch = (float *)malloc((unsigned int)sbfrm_size * sizeof(float)))== NULL ) || (( vtmp = (float *)malloc((unsigned int)sbfrm_size * sizeof(float))) == NULL ) ) { printf("ERROR: Malloc Failure in Block: Excitation Anlaysis \n"); exit(1); } if ((fixed_cbk = (long **) malloc((unsigned int)PHI_Nf * sizeof(long *))) == NULL) { printf("Malloc failure in Block:Excitation Anlysis\n"); exit(1); } for (i = 0; i < (int)PHI_Nf; i++) { fixed_cbk[i] = (long *) malloc ((unsigned int)sbfrm_size * sizeof (long)); if (fixed_cbk[i] == NULL) { printf("ERROR: Malloc Failure in Block: Excitation Anlaysis \n"); exit (1); } } /*==================================================================*/ /* Make sure the number of shape and gain codebooks is correct */ /*==================================================================*/ if (num_shape_cbks != 2) { fprintf(stderr, "Wrong number of shape codebooks in Block: Excitation Anlysis\n"); exit(1); } if (num_gain_cbks != 2) { fprintf(stderr, "Wrong number of gain codebooks in Block: Excitation Anlysis\n"); exit(1); } /*==================================================================*/ /* We need to know which subframe we are in */ /*==================================================================*/ if (PHI_sbfrm_ctr % n_subframes == 0) { PHI_sbfrm_ctr = 0; } /*==================================================================*/ /* 2.7 perceptual weighting filter */ /*==================================================================*/ PHI_perceptual_weighting(sbfrm_size, lpc_residual, scratch, lpc_order, int_Qlpc_coefficients, PHI_Wden_states); /*==================================================================*/ /* 2.9 zero-input response, weighted target signal and impulse */ /* response calculator */ /*==================================================================*/ PHI_calc_impulse_response(sbfrm_size, h, lpc_order, int_Qlpc_coefficients); PHI_calc_zero_input_response(sbfrm_size, vtmp, lpc_order, int_Qlpc_coefficients, PHI_s_state); PHI_calc_weighted_target(sbfrm_size, scratch, vtmp, t); if (PHI_sbfrm_ctr == n_subframes/2) { PHI_afp = first_order_lpc_par; } PHI_afp = first_order_lpc_par; /*==============================================================*/ /* 2.10 adaptive codebook search - preselection */ /*==============================================================*/ PHI_backward_filtering(sbfrm_size, t, vtmp, h); PHI_cba_preselection(sbfrm_size, Lmax, Lmin, n_subframes, n_lag_candidates, PHI_cba_codebook, vtmp, PHI_afp, lag_candidates, PHI_sbfrm_ctr); /*==================================================================*/ /* 2.11 adaptive codebook search */ /*==================================================================*/ PHI_cba_search(sbfrm_size, (long)Lmax, (long)Lmin, PHI_cba_codebook, lag_candidates, n_lag_candidates, h, t, &cba_gain, &shape_indices[0], &gain_indices[0]); PHI_calc_cba_excitation(sbfrm_size, Lmax, Lmin, PHI_cba_codebook, *shape_indices, scratch); PHI_calc_cba_residual(sbfrm_size, scratch, cba_gain, h, t, e); /*==================================================================*/ /* 2.12 fixed codebook search - preselection */ /* REDUCED COMPLEXITY FIXED CODEBOOK PRESELECTION */ /*==================================================================*/ PHI_backward_filtering(sbfrm_size, e, vtmp, h); PHI_calc_cbf_phase(PHI_D, sbfrm_size, vtmp, &phase); PHI_CompAmpArray(PHI_Np, PHI_D, vtmp, phase, amp); PHI_CompPosArray(PHI_Np, PHI_D, PHI_Nz, vtmp, phase, pos); PHI_generate_cbf(PHI_Np, PHI_D, PHI_Nf, sbfrm_size, fixed_cbk, phase, amp, pos); PHI_cbf_preselection((long)PHI_D, (long)FCBK_PRESELECT_VECS, PHI_Nf, sbfrm_size, fixed_cbk, phase, vtmp, PHI_afp, cbf_pi); /*==================================================================*/ /* 2.13 fixed codebook search */ /*==================================================================*/ PHI_cbf_search(PHI_Np, (long)PHI_D, (long)FCBK_PRESELECT_VECS, sbfrm_size, fixed_cbk, phase, cbf_pi, h, e, &cbf_gain, &gain_indices[1], amp, PHI_sbfrm_ctr); /*==================================================================*/ /* 2.13 Code RPE index and phase into fixed_cbk_index */ /*==================================================================*/ PHI_code_cbf_amplitude_phase(PHI_Np, (long)PHI_D, amp, phase, &shape_indices[1]); /*==================================================================*/ /* 2.14 simulation of decoder */ /*==================================================================*/ PHI_calc_cbf_excitation(sbfrm_size, PHI_Np, (long)PHI_D, amp, phase, vtmp); PHI_sum_excitations(sbfrm_size, cba_gain, scratch, cbf_gain, vtmp, decoded_excitation); PHI_update_cba_memory(sbfrm_size, Lmax, PHI_cba_codebook, decoded_excitation); PHI_update_filter_states(sbfrm_size, lpc_order, decoded_excitation, PHI_s_state, int_Qlpc_coefficients); /*==================================================================*/ /* Update the subframe counter */ /*==================================================================*/ PHI_sbfrm_ctr++; /*==================================================================*/ /* Free temp states */ /*==================================================================*/ free(h); free(t); free(e); free(amp); free(pos); free(vtmp); free(scratch); for (i = 0; i < (int)PHI_Nf; i++) { free(fixed_cbk[i]); } free(fixed_cbk);}/*======================================================================*//* Function Definition: PHI_close_excitation_analysis *//*======================================================================*/void PHI_close_excitation_analysis(void){ free (PHI_Wden_states); free (PHI_s_state); free (PHI_cba_codebook);} /*======================================================================*//* H I S T O R Y *//*======================================================================*//* 17-04-96 R. Taori Initial Version *//* 30-06-96 R. Taori Modified interface to meet the MPEG-4 requirement*//* 20-08-96 R. Taori Modified interface to accomodate Tampere results */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -