From 543ba11c530d7e0032a32038eb876217afe2c4aa Mon Sep 17 00:00:00 2001 From: drowe67 Date: Tue, 19 Aug 2014 01:52:52 +0000 Subject: [PATCH] reduced Aw[] array size in codec2_decode routines for each mode, sounds OK for each mode git-svn-id: https://svn.code.sf.net/p/freetel/code@1808 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/src/codec2.c | 60 +++++++++++++---------------------------- 1 file changed, 18 insertions(+), 42 deletions(-) diff --git a/codec2-dev/src/codec2.c b/codec2-dev/src/codec2.c index 78679112..60489e1c 100644 --- a/codec2-dev/src/codec2.c +++ b/codec2-dev/src/codec2.c @@ -368,7 +368,7 @@ void codec2_decode_3200(struct CODEC2 *c2, short speech[], const unsigned char * float ak[2][LPC_ORD+1]; int i,j; unsigned int nbit = 0; - COMP Aw[2][FFT_ENC]; + COMP Aw[FFT_ENC]; assert(c2 != NULL); @@ -413,15 +413,11 @@ void codec2_decode_3200(struct CODEC2 *c2, short speech[], const unsigned char * 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[i][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); } - /* synthesise ------------------------------------------------*/ - - for(i=0; i<2; i++) - synthesise_one_frame(c2, &speech[N*i], &model[i], &Aw[i][0]); - /* update memories for next frame ----------------------------*/ c2->prev_model_dec = model[1]; @@ -517,7 +513,7 @@ void codec2_decode_2400(struct CODEC2 *c2, short speech[], const unsigned char * float ak[2][LPC_ORD+1]; int i,j; unsigned int nbit = 0; - COMP Aw[2][FFT_ENC]; + COMP Aw[FFT_ENC]; assert(c2 != NULL); @@ -560,15 +556,11 @@ void codec2_decode_2400(struct CODEC2 *c2, short speech[], const unsigned char * 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[i][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); } - /* synthesise ------------------------------------------------*/ - - for(i=0; i<2; i++) - synthesise_one_frame(c2, &speech[N*i], &model[i], &Aw[i][0]); - /* update memories for next frame ----------------------------*/ c2->prev_model_dec = model[1]; @@ -687,7 +679,7 @@ void codec2_decode_1600(struct CODEC2 *c2, short speech[], const unsigned char * int i,j; unsigned int nbit = 0; float weight; - COMP Aw[4][FFT_ENC]; + COMP Aw[FFT_ENC]; assert(c2 != NULL); @@ -748,15 +740,11 @@ void codec2_decode_1600(struct CODEC2 *c2, short speech[], const unsigned char * for(i=0; i<4; 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[i][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); } - /* synthesise ------------------------------------------------*/ - - for(i=0; i<4; i++) - synthesise_one_frame(c2, &speech[N*i], &model[i], &Aw[i][0]); - /* update memories for next frame ----------------------------*/ c2->prev_model_dec = model[3]; @@ -869,7 +857,7 @@ void codec2_decode_1400(struct CODEC2 *c2, short speech[], const unsigned char * int i,j; unsigned int nbit = 0; float weight; - COMP Aw[4][FFT_ENC]; + COMP Aw[FFT_ENC]; assert(c2 != NULL); @@ -922,15 +910,11 @@ void codec2_decode_1400(struct CODEC2 *c2, short speech[], const unsigned char * for(i=0; i<4; 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[i][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); } - /* synthesise ------------------------------------------------*/ - - for(i=0; i<4; i++) - synthesise_one_frame(c2, &speech[N*i], &model[i], &Aw[i][0]); - /* update memories for next frame ----------------------------*/ c2->prev_model_dec = model[3]; @@ -1050,7 +1034,7 @@ void codec2_decode_1300(struct CODEC2 *c2, short speech[], const unsigned char * int i,j; unsigned int nbit = 0; float weight; - COMP Aw[4][FFT_ENC]; + COMP Aw[FFT_ENC]; PROFILE_VAR(recover_start); assert(c2 != NULL); @@ -1109,8 +1093,9 @@ void codec2_decode_1300(struct CODEC2 *c2, short speech[], const unsigned char * for(i=0; i<4; 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[i][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); } PROFILE_SAMPLE_AND_LOG2(recover_start, " recover"); #ifdef DUMP @@ -1118,11 +1103,6 @@ void codec2_decode_1300(struct CODEC2 *c2, short speech[], const unsigned char * dump_ak_(&ak[3][0], LPC_ORD); #endif - /* synthesise ------------------------------------------------*/ - - for(i=0; i<4; i++) - synthesise_one_frame(c2, &speech[N*i], &model[i], &Aw[i][0]); - /* update memories for next frame ----------------------------*/ c2->prev_model_dec = model[3]; @@ -1240,7 +1220,7 @@ void codec2_decode_1200(struct CODEC2 *c2, short speech[], const unsigned char * int i,j; unsigned int nbit = 0; float weight; - COMP Aw[4][FFT_ENC]; + COMP Aw[FFT_ENC]; assert(c2 != NULL); @@ -1293,15 +1273,11 @@ void codec2_decode_1200(struct CODEC2 *c2, short speech[], const unsigned char * for(i=0; i<4; 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[i][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); } - /* synthesise ------------------------------------------------*/ - - for(i=0; i<4; i++) - synthesise_one_frame(c2, &speech[N*i], &model[i], &Aw[i][0]); - /* update memories for next frame ----------------------------*/ c2->prev_model_dec = model[3]; -- 2.25.1