From 879084f6f0582ba708841e3445a9e1aa7ed2a84f Mon Sep 17 00:00:00 2001 From: xnorpx Date: Tue, 23 May 2023 17:31:51 -0700 Subject: [PATCH] Fix some of C4244 double to float warnings --- dnn/common.c | 2 +- dnn/common.h | 4 ++-- dnn/lpcnet.c | 2 +- dnn/lpcnet_dec.c | 10 ++++----- dnn/lpcnet_enc.c | 58 ++++++++++++++++++++++++------------------------ dnn/vec_avx.h | 2 +- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/dnn/common.c b/dnn/common.c index d5a4580a..9fae8b3b 100644 --- a/dnn/common.c +++ b/dnn/common.c @@ -40,7 +40,7 @@ static void single_interp(float *x, const float *left, const float *right, int i float ref[NB_BANDS]; float pred[3*NB_BANDS]; RNN_COPY(ref, x, NB_BANDS); - for (i=0;i= 0 ? 1 : -1; + u = u - 128.f; + s = u >= 0.f ? 1.f : -1.f; u = fabs(u); return s*scale_1*(exp(u/128.*LOG256)-1); } diff --git a/dnn/lpcnet.c b/dnn/lpcnet.c index f9ca127f..914f4476 100644 --- a/dnn/lpcnet.c +++ b/dnn/lpcnet.c @@ -179,7 +179,7 @@ LPCNET_EXPORT int lpcnet_init(LPCNetState *lpcnet) memset(lpcnet, 0, lpcnet_get_size()); lpcnet->last_exc = lin2ulaw(0.f); for (i=0;i<256;i++) { - float prob = .025+.95*i/255.; + float prob = .025f+.95f*i/255.f; lpcnet->sampling_logit_table[i] = -log((1-prob)/prob); } kiss99_srand(&lpcnet->rng, (const unsigned char *)rng_string, strlen(rng_string)); diff --git a/dnn/lpcnet_dec.c b/dnn/lpcnet_dec.c index bea0d5f2..8ae70c15 100644 --- a/dnn/lpcnet_dec.c +++ b/dnn/lpcnet_dec.c @@ -121,13 +121,13 @@ void decode_packet(float features[4][NB_TOTAL_FEATURES], float *vq_mem, const un } for (sub=0;sub<4;sub++) { float p = pow(2.f, main_pitch/21.)*PITCH_MIN_PERIOD; - p *= 1 + modulation/16./7.*(2*sub-3); + p *= 1.f + modulation/16.f/7.f*(2*sub-3); p = MIN16(255, MAX16(33, p)); - features[sub][NB_BANDS] = .02*(p-100); - features[sub][NB_BANDS + 1] = frame_corr-.5; + features[sub][NB_BANDS] = .02f*(p-100.f); + features[sub][NB_BANDS + 1] = frame_corr-.5f; } - features[3][0] = (c0_id-64)/4.; + features[3][0] = (c0_id-64)/4.f; for (i=0;iframe_weight[2+sub]; for(sub=0;sub<8;sub++) st->frame_weight[2+sub] *= (8.f/frame_weight_sum); for(sub=0;sub<8;sub++) { - float max_path_all = -1e15; + float max_path_all = -1e15f; best_i = 0; for (i=0;ixc[2+sub][(PITCH_MAX_PERIOD+i)/2], st->xc[2+sub][(PITCH_MAX_PERIOD+i+2)/2]), st->xc[2+sub][(PITCH_MAX_PERIOD+i-1)/2]); - if (st->xc[2+sub][i] < xc_half*1.1) st->xc[2+sub][i] *= .8; + if (st->xc[2+sub][i] < xc_half*1.1f) st->xc[2+sub][i] *= .8f; } for (i=0;ifeatures[sub][NB_BANDS] = .02*(p-100); - st->features[sub][NB_BANDS + 1] = frame_corr-.5; + st->features[sub][NB_BANDS] = .02f*(p-100); + st->features[sub][NB_BANDS + 1] = frame_corr-.5f; } else { - st->features[sub][NB_BANDS] = .01*(IMAX(66, IMIN(510, best[2+2*sub]+best[2+2*sub+1]))-200); - st->features[sub][NB_BANDS + 1] = frame_corr-.5; + st->features[sub][NB_BANDS] = .01f*(IMAX(66, IMIN(510, best[2+2*sub]+best[2+2*sub+1]))-200); + st->features[sub][NB_BANDS + 1] = frame_corr-.5f; } /*printf("%f %d %f\n", st->features[sub][NB_BANDS], best[2+2*sub], frame_corr);*/ } @@ -694,7 +694,7 @@ void process_superframe(LPCNetEncState *st, unsigned char *buf, FILE *ffeat, int /*printf("%f\n", st->features[3][0]);*/ c0_id = (int)floor(.5 + st->features[3][0]*4); c0_id = IMAX(-64, IMIN(63, c0_id)); - st->features[3][0] = c0_id/4.; + st->features[3][0] = c0_id/4.f; quantize_3stage_mbest(&st->features[3][1], vq_end); /*perform_interp_relaxation(st->features, st->vq_mem);*/ quantize_diff(&st->features[1][0], st->vq_mem, &st->features[3][0], ceps_codebook_diff4, 12, 1, &vq_mid); @@ -736,15 +736,15 @@ void process_multi_frame(LPCNetEncState *st, FILE *ffeat) { int best[10]; int pitch_prev[8][PITCH_MAX_PERIOD]; float frame_corr; - float frame_weight_sum = 1e-15; + float frame_weight_sum = 1e-15f; for(sub=0;sub<8;sub++) frame_weight_sum += st->frame_weight[2+sub]; for(sub=0;sub<8;sub++) st->frame_weight[2+sub] *= (8.f/frame_weight_sum); for(sub=0;sub<8;sub++) { - float max_path_all = -1e15; + float max_path_all = -1e15f; best_i = 0; for (i=0;ixc[2+sub][(PITCH_MAX_PERIOD+i)/2], st->xc[2+sub][(PITCH_MAX_PERIOD+i+2)/2]), st->xc[2+sub][(PITCH_MAX_PERIOD+i-1)/2]); - if (st->xc[2+sub][i] < xc_half*1.1) st->xc[2+sub][i] *= .8; + if (st->xc[2+sub][i] < xc_half*1.1) st->xc[2+sub][i] *= .8f; } for (i=0;ifeatures[sub][NB_BANDS] = .01*(IMAX(66, IMIN(510, best[2+2*sub]+best[2+2*sub+1]))-200); - st->features[sub][NB_BANDS + 1] = frame_corr-.5; + st->features[sub][NB_BANDS] = .01f*(IMAX(66, IMIN(510, best[2+2*sub]+best[2+2*sub+1]))-200); + st->features[sub][NB_BANDS + 1] = frame_corr-.5f; /*printf("%f %d %f\n", st->features[sub][NB_BANDS], best[2+2*sub], frame_corr);*/ } /*printf("%d %f %f %f\n", best_period, best_a, best_b, best_corr);*/ @@ -804,11 +804,11 @@ void process_single_frame(LPCNetEncState *st, FILE *ffeat) { int best[4]; int pitch_prev[2][PITCH_MAX_PERIOD]; float frame_corr; - float frame_weight_sum = 1e-15; + float frame_weight_sum = 1e-15f; for(sub=0;sub<2;sub++) frame_weight_sum += st->frame_weight[2+2*st->pcount+sub]; for(sub=0;sub<2;sub++) st->frame_weight[2+2*st->pcount+sub] *= (2.f/frame_weight_sum); for(sub=0;sub<2;sub++) { - float max_path_all = -1e15; + float max_path_all = -1e15f; best_i = 0; for (i=0;ixc[2+2*st->pcount+sub][(PITCH_MAX_PERIOD+i)/2], st->xc[2+2*st->pcount+sub][(PITCH_MAX_PERIOD+i+2)/2]), st->xc[2+2*st->pcount+sub][(PITCH_MAX_PERIOD+i-1)/2]); diff --git a/dnn/vec_avx.h b/dnn/vec_avx.h index 9962284b..0c6874a5 100644 --- a/dnn/vec_avx.h +++ b/dnn/vec_avx.h @@ -302,7 +302,7 @@ static inline __m256 exp8_approx(__m256 X) const __m256 K1 = _mm256_set1_ps(0.69583354f); const __m256 K2 = _mm256_set1_ps(0.22606716f); const __m256 K3 = _mm256_set1_ps(0.078024523f); - const __m256 log2_E = _mm256_set1_ps(1.44269504); + const __m256 log2_E = _mm256_set1_ps(1.44269504f); const __m256 max_in = _mm256_set1_ps(50.f); const __m256 min_in = _mm256_set1_ps(-50.f); __m256 XF, Y;