From 5c6321d3bed7f2025a64657cd76013cec52a3547 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Tue, 25 Oct 2016 06:00:48 +0000 Subject: [PATCH] bunch of warnings removed - thanks Danilo! git-svn-id: https://svn.code.sf.net/p/freetel/code@2896 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/CMakeLists.txt | 4 +- codec2-dev/src/ampexp.c | 72 +++++++------- codec2-dev/src/c2dec.c | 10 +- codec2-dev/src/c2sim.c | 8 +- codec2-dev/src/codec2_fft.c | 4 + codec2-dev/src/fdmdv_mod.c | 4 + codec2-dev/src/fm_demod.c | 2 + codec2-dev/src/freedv_vhf_framing.c | 8 +- codec2-dev/src/genlspdtcb.c | 1 + codec2-dev/src/phaseexp.c | 145 ++++++++++++++-------------- codec2-dev/src/quantise.c | 15 ++- codec2-dev/unittest/genampdata.c | 4 +- codec2-dev/unittest/genphdata.c | 2 +- codec2-dev/unittest/raw2h.c | 6 +- codec2-dev/unittest/scalarlsptest.c | 13 ++- codec2-dev/unittest/vq_train_jvm.c | 5 +- codec2-dev/unittest/vqtrain.c | 5 +- codec2-dev/unittest/vqtrainph.c | 18 ++-- 18 files changed, 179 insertions(+), 147 deletions(-) diff --git a/codec2-dev/CMakeLists.txt b/codec2-dev/CMakeLists.txt index 36bb52da..dd39b448 100644 --- a/codec2-dev/CMakeLists.txt +++ b/codec2-dev/CMakeLists.txt @@ -53,7 +53,9 @@ endif() # Set default C++ flags. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -O2 -std=gnu11") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -O3 -std=gnu11") +# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS}") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS}") diff --git a/codec2-dev/src/ampexp.c b/codec2-dev/src/ampexp.c index c0db2140..cb191164 100644 --- a/codec2-dev/src/ampexp.c +++ b/codec2-dev/src/ampexp.c @@ -299,41 +299,6 @@ static void add_quant_noise(struct AEXP *aexp, MODEL *model, int start, int end, */ -static void print_sparse_pred_error(struct AEXP *aexp, MODEL *model, float mag_thresh) -{ - int m, index; - float mag, error; - float sparse_pe[MAX_AMP]; - - mag = 0.0; - for(m=1; m<=model->L; m++) - mag += model->A[m]*model->A[m]; - mag = 10*log10(mag/model->L); - - if (mag > mag_thresh) { - for(m=0; mL; m++) { - assert(model->A[m] > 0.0); - error = PRED_COEFF*20.0*log10(aexp->A_prev[m]) - 20.0*log10(model->A[m]); - //error = 20.0*log10(model->A[m]) - mag; - - index = MAX_AMP*m*model->Wo/PI; - assert(index < MAX_AMP); - sparse_pe[index] = error; - } - - /* dump sparse amp vector */ - - for(m=0; mL; m++) + mag += model->A[m]*model->A[m]; + mag = 10*log10(mag/model->L); + + if (mag > mag_thresh) { + for(m=0; mL; m++) { + assert(model->A[m] > 0.0); + error = PRED_COEFF*20.0*log10(aexp->A_prev[m]) - 20.0*log10(model->A[m]); + //error = 20.0*log10(model->A[m]) - mag; + + index = MAX_AMP*m*model->Wo/PI; + assert(index < MAX_AMP); + sparse_pe[index] = error; + } + + /* dump sparse amp vector */ + + for(m=0; m 0; i--) - { - for (j = 1; j <= i; j++) - { - //printf("i %d j %d %f %f \n", i, j, numbers[j-1].amp, numbers[j].amp); - if (numbers[j-1].amp < numbers[j].amp) - { - temp = numbers[j-1]; - numbers[j-1] = numbers[j]; - numbers[j] = temp; - } - } - } -} - - -static void print_pred_error(struct PEXP *pexp, MODEL *model, int start, int end, float mag_thresh) { - int i; - float mag; - - mag = 0.0; - for(i=start; i<=end; i++) - mag += model->A[i]*model->A[i]; - mag = 10*log10(mag/(end-start)); - - if (mag > mag_thresh) { - for(i=start; i<=end; i++) { - float pred = pexp->phi_prev[i] + N_SAMP*i*(model->Wo + pexp->Wo_prev)/2.0; - float err = pred - model->phi[i]; - err = atan2(sin(err),cos(err)); - printf("%f\n",err); - } - //printf("\n"); - } - -} - static void predict_phases(struct PEXP *pexp, MODEL *model, int start, int end) { int i; @@ -343,14 +294,6 @@ static void predict_phases2(struct PEXP *pexp, MODEL *model, int start, int end) } -static void rand_phases(MODEL *model, int start, int end) { - int i; - - for(i=start; i<=end; i++) - model->phi[i] = PI*(1.0 - 2.0*(float)rand()/RAND_MAX); - -} - static void quant_phase(float *phase, float min, float max, int bits) { int levels = 1 << bits; int index; @@ -376,6 +319,64 @@ static void quant_phases(MODEL *model, int start, int end, int bits) { } } +#if 0 +/* Bubblesort to find highest amplitude harmonics */ + +struct AMPINDEX { + float amp; + int index; +}; + +static void bubbleSort(struct AMPINDEX numbers[], int array_size) +{ + int i, j; + struct AMPINDEX temp; + + for (i = (array_size - 1); i > 0; i--) + { + for (j = 1; j <= i; j++) + { + //printf("i %d j %d %f %f \n", i, j, numbers[j-1].amp, numbers[j].amp); + if (numbers[j-1].amp < numbers[j].amp) + { + temp = numbers[j-1]; + numbers[j-1] = numbers[j]; + numbers[j] = temp; + } + } + } +} + +static void print_pred_error(struct PEXP *pexp, MODEL *model, int start, int end, float mag_thresh) { + int i; + float mag; + + mag = 0.0; + for(i=start; i<=end; i++) + mag += model->A[i]*model->A[i]; + mag = 10*log10(mag/(end-start)); + + if (mag > mag_thresh) { + for(i=start; i<=end; i++) { + float pred = pexp->phi_prev[i] + N_SAMP*i*(model->Wo + pexp->Wo_prev)/2.0; + float err = pred - model->phi[i]; + err = atan2(sin(err),cos(err)); + printf("%f\n",err); + } + //printf("\n"); + } + +} + + +static void rand_phases(MODEL *model, int start, int end) { + int i; + + for(i=start; i<=end; i++) + model->phi[i] = PI*(1.0 - 2.0*(float)rand()/RAND_MAX); + +} + static void fixed_bits_per_frame(struct PEXP *pexp, MODEL *model, int m, int budget) { int res, finished; @@ -586,7 +587,6 @@ static void quant_prediction_error(struct PEXP *pexp, MODEL *model, int start, i } } - static void print_sparse_pred_error(struct PEXP *pexp, MODEL *model, int start, int end, float mag_thresh) { int i, index; @@ -621,6 +621,19 @@ static void print_sparse_pred_error(struct PEXP *pexp, MODEL *model, int start, } } +static void predict_phases1(struct PEXP *pexp, MODEL *model, int start, int end) { + int i; + float best_Wo; + + best_Wo = refine_Wo(pexp, model, 1, model->L); + + for(i=start; i<=end; i++) { + model->phi[i] = pexp->phi_prev[i] + N_SAMP*i*best_Wo; + } +} + + +#endif static void update_snr_calc(struct PEXP *pexp, MODEL *model, float before[]) { @@ -852,18 +865,6 @@ static void sparse_vq_pred_error(struct PEXP *pexp, } -static void predict_phases1(struct PEXP *pexp, MODEL *model, int start, int end) { - int i; - float best_Wo; - - best_Wo = refine_Wo(pexp, model, 1, model->L); - - for(i=start; i<=end; i++) { - model->phi[i] = pexp->phi_prev[i] + N_SAMP*i*best_Wo; - } -} - - /* This functions tests theory that some bands can be combined together due to less frequency resolution at higher frequencies. This will @@ -1161,7 +1162,7 @@ void cb_phase1(struct PEXP *pexp, MODEL *model) { void cb_phase2(struct PEXP *pexp, MODEL *model) { int st, m, i, a, b, step; - float diff,w,c,s,phi1_; + float diff,w,c,s; float A[MAX_AMP]; for(m=1; m<=model->L; m++) { @@ -1187,7 +1188,7 @@ void cb_phase2(struct PEXP *pexp, MODEL *model) { w = 1.0; c += w*cos(diff); s += w*sin(diff); } - phi1_ = atan2(s,c); + // float phi1_ = atan2(s,c); printf("replacing: "); for(i=a; iphi[i] = i*phi1_; diff --git a/codec2-dev/src/quantise.c b/codec2-dev/src/quantise.c index e57ffa30..65afbf99 100644 --- a/codec2-dev/src/quantise.c +++ b/codec2-dev/src/quantise.c @@ -41,6 +41,12 @@ #include "machdep.h" #define LSP_DELTA1 0.01 /* grid spacing for LSP root searches */ +// #define MBEST_PRINT_OUT +#ifdef MBEST_PRINT_OUT + #define MBEST_PRINT(a,b) mbest_print((a),(b)) +#else + #define MBEST_PRINT(a,b) +#endif /*---------------------------------------------------------------------------*\ @@ -656,6 +662,7 @@ static void mbest_insert(struct MBEST *mbest, int index[], float error) { } +#ifdef MBEST_PRINT_OUT static void mbest_print(char title[], struct MBEST *mbest) { int i,j; @@ -666,6 +673,7 @@ static void mbest_print(char title[], struct MBEST *mbest) { fprintf(stderr, " %f\n", mbest->list[i].error); } } +#endif /*---------------------------------------------------------------------------*\ @@ -729,7 +737,8 @@ float lspmelvq_mbest_encode(int *indexes, float *x, float *xq, int ndim, int mbe /* Stage 1 */ mbest_search(codebook1, x, w, ndim, lspmelvq_cb[0].m, mbest_stage1, index); - //mbest_print("Stage 1:", mbest_stage1); + MBEST_PRINT("Stage 1:", mbest_stage1); + /* Stage 2 */ @@ -739,7 +748,7 @@ float lspmelvq_mbest_encode(int *indexes, float *x, float *xq, int ndim, int mbe target[i] = x[i] - codebook1[ndim*n1+i]; mbest_search(codebook2, target, w, ndim, lspmelvq_cb[1].m, mbest_stage2, index); } - //mbest_print("Stage 2:", mbest_stage2); + MBEST_PRINT("Stage 2:", mbest_stage2); /* Stage 3 */ @@ -750,7 +759,7 @@ float lspmelvq_mbest_encode(int *indexes, float *x, float *xq, int ndim, int mbe target[i] = x[i] - codebook1[ndim*n1+i] - codebook2[ndim*n2+i]; mbest_search(codebook3, target, w, ndim, lspmelvq_cb[2].m, mbest_stage3, index); } - //mbest_print("Stage 3:", mbest_stage3); + MBEST_PRINT("Stage 3:", mbest_stage3); n1 = mbest_stage3->list[0].index[2]; n2 = mbest_stage3->list[0].index[1]; diff --git a/codec2-dev/unittest/genampdata.c b/codec2-dev/unittest/genampdata.c index dfd46953..3fa2d2ed 100644 --- a/codec2-dev/unittest/genampdata.c +++ b/codec2-dev/unittest/genampdata.c @@ -23,7 +23,7 @@ typedef struct { int main(void) { FILE *f=fopen("testamp.flt", "wb"); - int i, j, m, L, index; + int i, m, L, index; float amp, noisey_amp, pitch, Wo; float sparse_pe[MAX_AMP]; @@ -37,7 +37,7 @@ int main(void) { */ for(i=0; i