ref: 879084f6f0582ba708841e3445a9e1aa7ed2a84f
parent: 919b7a1f5893fcdb0d0446b57aedcdffd790389f
author: xnorpx <xnorpx@outlook.com>
date: Tue May 23 13:31:51 EDT 2023
Fix some of C4244 double to float warnings
--- a/dnn/common.c
+++ b/dnn/common.c
@@ -40,7 +40,7 @@
float ref[NB_BANDS];
float pred[3*NB_BANDS];
RNN_COPY(ref, x, NB_BANDS);
- for (i=0;i<NB_BANDS;i++) pred[i] = .5*(left[i] + right[i]);
+ for (i=0;i<NB_BANDS;i++) pred[i] = .5f*(left[i] + right[i]);
for (i=0;i<NB_BANDS;i++) pred[NB_BANDS+i] = left[i];
for (i=0;i<NB_BANDS;i++) pred[2*NB_BANDS+i] = right[i];
for (i=0;i<NB_BANDS;i++) {
--- a/dnn/common.h
+++ b/dnn/common.h
@@ -36,8 +36,8 @@
{
float s;
float scale_1 = 32768.f/255.f;
- u = u - 128;
- s = u >= 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);
}
--- a/dnn/lpcnet.c
+++ b/dnn/lpcnet.c
@@ -179,7 +179,7 @@
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));
--- a/dnn/lpcnet_dec.c
+++ b/dnn/lpcnet_dec.c
@@ -121,13 +121,13 @@
}
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;i<NB_BANDS_1;i++) {
features[3][i+1] = ceps_codebook1[vq_end[0]*NB_BANDS_1 + i] + ceps_codebook2[vq_end[1]*NB_BANDS_1 + i] + ceps_codebook3[vq_end[2]*NB_BANDS_1 + i];
}
@@ -141,7 +141,7 @@
features[1][i] = sign*ceps_codebook_diff4[vq_mid*NB_BANDS + i];
}
if ((vq_mid&MULTI_MASK) < 2) {
- for (i=0;i<NB_BANDS;i++) features[1][i] += .5*(vq_mem[i] + features[3][i]);
+ for (i=0;i<NB_BANDS;i++) features[1][i] += .5f*(vq_mem[i] + features[3][i]);
} else if ((vq_mid&MULTI_MASK) == 2) {
for (i=0;i<NB_BANDS;i++) features[1][i] += vq_mem[i];
} else {
--- a/dnn/lpcnet_enc.c
+++ b/dnn/lpcnet_enc.c
@@ -52,7 +52,7 @@
void vq_quantize_mbest(const float *codebook, int nb_entries, const float *x, int ndim, int mbest, float *dist, int *index)
{
int i, j;
- for (i=0;i<mbest;i++) dist[i] = 1e15;
+ for (i=0;i<mbest;i++) dist[i] = 1e15f;
for (i=0;i<nb_entries;i++)
{
@@ -80,7 +80,7 @@
int vq_quantize(const float *codebook, int nb_entries, const float *x, int ndim, float *dist_out)
{
int i, j;
- float min_dist = 1e15;
+ float min_dist = 1e15f;
int nearest = 0;
for (i=0;i<nb_entries;i++)
@@ -242,7 +242,7 @@
static int find_nearest_multi(const float *codebook, int nb_entries, const float *x, int ndim, float *dist_out, int sign)
{
int i, j;
- float min_dist = 1e15;
+ float min_dist = 1e15f;
int nearest = 0;
for (i=0;i<nb_entries;i++)
@@ -290,7 +290,7 @@
float s = 1;
nb_entries = 1<<bits;
RNN_COPY(ref, x, NB_BANDS);
- for (i=0;i<NB_BANDS;i++) pred[i] = pred[NB_BANDS+i] = .5*(left[i] + right[i]);
+ for (i=0;i<NB_BANDS;i++) pred[i] = pred[NB_BANDS+i] = .5f*(left[i] + right[i]);
for (i=0;i<NB_BANDS;i++) pred[2*NB_BANDS+i] = left[i];
for (i=0;i<NB_BANDS;i++) pred[3*NB_BANDS+i] = right[i];
for (i=0;i<4*NB_BANDS;i++) target[i] = x[i%NB_BANDS] - pred[i];
@@ -319,10 +319,10 @@
int interp_search(const float *x, const float *left, const float *right, float *dist_out)
{
int i, k;
- float min_dist = 1e15;
+ float min_dist = 1e15f;
int best_pred = 0;
float pred[4*NB_BANDS];
- for (i=0;i<NB_BANDS;i++) pred[i] = pred[NB_BANDS+i] = .5*(left[i] + right[i]);
+ for (i=0;i<NB_BANDS;i++) pred[i] = pred[NB_BANDS+i] = .5f*(left[i] + right[i]);
for (i=0;i<NB_BANDS;i++) pred[2*NB_BANDS+i] = left[i];
for (i=0;i<NB_BANDS;i++) pred[3*NB_BANDS+i] = right[i];
@@ -342,7 +342,7 @@
void interp_diff(float *x, float *left, float *right, float *codebook, int bits, int sign)
{
int i, k;
- float min_dist = 1e15;
+ float min_dist = 1e15f;
int best_pred = 0;
float ref[NB_BANDS];
float pred[4*NB_BANDS];
@@ -350,7 +350,7 @@
(void)codebook;
(void)bits;
RNN_COPY(ref, x, NB_BANDS);
- for (i=0;i<NB_BANDS;i++) pred[i] = pred[NB_BANDS+i] = .5*(left[i] + right[i]);
+ for (i=0;i<NB_BANDS;i++) pred[i] = pred[NB_BANDS+i] = .5f*(left[i] + right[i]);
for (i=0;i<NB_BANDS;i++) pred[2*NB_BANDS+i] = left[i];
for (i=0;i<NB_BANDS;i++) pred[3*NB_BANDS+i] = right[i];
@@ -378,7 +378,7 @@
int double_interp_search(float features[4][NB_TOTAL_FEATURES], const float *mem) {
int i, j;
int best_id=0;
- float min_dist = 1e15;
+ float min_dist = 1e15f;
float dist[2][3];
interp_search(features[0], mem, features[1], dist[0]);
interp_search(features[2], features[1], features[3], dist[1]);
@@ -410,12 +410,12 @@
id1 = best_id % 3;
count = 1;
if (id0 != 1) {
- float t = (id0==0) ? .5 : 1.;
+ float t = (id0==0) ? .5f : 1.f;
for (i=0;i<NB_BANDS;i++) features[1][i] += t*features[0][i];
count += t;
}
if (id1 != 2) {
- float t = (id1==0) ? .5 : 1.;
+ float t = (id1==0) ? .5f : 1.f;
for (i=0;i<NB_BANDS;i++) features[1][i] += t*features[2][i];
count += t;
}
@@ -548,7 +548,7 @@
/* Upsample correlation by 3x and keep the max. */
float interpolated[PITCH_MAX_PERIOD]={0};
/* interp=sinc([-3:3]+1/3).*(.5+.5*cos(pi*[-3:3]/4.5)); interp=interp/sum(interp); */
- static const float interp[7] = {0.026184, -0.098339, 0.369938, 0.837891, -0.184969, 0.070242, -0.020947};
+ static const float interp[7] = {0.026184f, -0.098339f, 0.369938f, 0.837891f, -0.184969f, 0.070242f, -0.020947f};
for (i=4;i<PITCH_MAX_PERIOD-4;i++) {
float val1=0, val2=0;
int j;
@@ -582,7 +582,7 @@
float sx=0, sxx=0, sxy=0, sy=0, sw=0;
float frame_corr;
int voiced;
- float frame_weight_sum = 1e-15;
+ float frame_weight_sum = 1e-15f;
float center_pitch;
int main_pitch;
int modulation;
@@ -594,11 +594,11 @@
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;i<PITCH_MAX_PERIOD-2*PITCH_MIN_PERIOD;i++) {
float xc_half = MAX16(MAX16(st->xc[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;i<PITCH_MAX_PERIOD-PITCH_MIN_PERIOD;i++) {
int j;
@@ -666,7 +666,7 @@
/*best_b = (sxx*sy - sx*sxy)/(sw*sxx - sx*sx);*/
best_b = (sy - best_a*sx)/sw;
/* Quantizing the pitch as "main" pitch + slope. */
- center_pitch = best_b+5.5*best_a;
+ center_pitch = best_b+5.5f*best_a;
main_pitch = (int)floor(.5 + 21.*log2(center_pitch/PITCH_MIN_PERIOD));
main_pitch = IMAX(0, IMIN(63, main_pitch));
modulation = (int)floor(.5 + 16*7*best_a/center_pitch);
@@ -677,13 +677,13 @@
for (sub=0;sub<4;sub++) {
if (quantize) {
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));
- st->features[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 @@
/*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 @@
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;i<PITCH_MAX_PERIOD-2*PITCH_MIN_PERIOD;i++) {
float xc_half = MAX16(MAX16(st->xc[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;i<PITCH_MAX_PERIOD-PITCH_MIN_PERIOD;i++) {
int j;
@@ -781,8 +781,8 @@
}
frame_corr /= 8;
for (sub=0;sub<4;sub++) {
- 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);*/
}
/*printf("%d %f %f %f\n", best_period, best_a, best_b, best_corr);*/
@@ -804,11 +804,11 @@
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;i<PITCH_MAX_PERIOD-2*PITCH_MIN_PERIOD;i++) {
float xc_half = MAX16(MAX16(st->xc[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]);
--- a/dnn/vec_avx.h
+++ b/dnn/vec_avx.h
@@ -302,7 +302,7 @@
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;
--
⑨