中级会员
 
- 积分
- 201
- 金钱
- 201
- 注册时间
- 2019-2-9
- 在线时间
- 42 小时
|
发表于 2022-8-23 12:07:23
|
显示全部楼层
void codec2_decode_2400(struct CODEC2 *c2, short speech[], const unsigned char * bits) { MODEL model[2]; int lsp_indexes[LPC_ORD]; float lsps[2][LPC_ORD]; int WoE_index; float e[2]; float snr; float ak[2][LPC_ORD+1]; int i,j; unsigned int nbit = 0; COMP Aw[FFT_ENC]; assert(c2 != NULL); /* only need to zero these out due to (unused) snr calculation */ for(i=0; i<2; i++) for(j=1; j<=MAX_AMP; j++) model[i].A[j] = 0.0; /* unpack bits from channel ------------------------------------*/ /* this will partially fill the model params for the 2 x 10ms frames */ model[0].voiced = unpack(bits, &nbit, 1); model[1].voiced = unpack(bits, &nbit, 1); WoE_index = unpack(bits, &nbit, WO_E_BITS); decode_WoE(&model[1], &e[1], c2->xq_dec, WoE_index); for(i=0; i<LSP_SCALAR_INDEXES; i++) { lsp_indexes[i] = unpack(bits, &nbit, lsp_bits(i)); } decode_lsps_scalar(&lsps[1][0], lsp_indexes, LPC_ORD); check_lsp_order(&lsps[1][0], LPC_ORD); bw_expand_lsps(&lsps[1][0], LPC_ORD, 50.0, 100.0); /* interpolate ------------------------------------------------*/ /* Wo and energy are sampled every 20ms, so we interpolate just 1 10ms frame between 20ms samples */ interp_Wo(&model[0], &c2->prev_model_dec, &model[1]); e[0] = interp_energy(c2->prev_e_dec, e[1]); /* LSPs are sampled every 20ms so we interpolate the frame in between, then recover spectral amplitudes */ interpolate_lsp_ver2(&lsps[0][0], c2->prev_lsps_dec, &lsps[1][0], 0.5, LPC_ORD); for(i=0; i<2; i++) { lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD); aks_to_M2(c2->fft_fwd_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 0, 0, c2->lpc_pf, c2->bass_boost, c2->beta, c2->gamma, Aw); apply_lpc_correction(&model[i]); synthesise_one_frame(c2, &speech[N*i], &model[i], Aw); } /* update memories for next frame ----------------------------*/ c2->prev_model_dec = model[1]; c2->prev_e_dec = e[1]; for(i=0; i<LPC_ORD; i++) c2->prev_lsps_dec[i] = lsps[1][i]; } |
|