From 2fbd1d89559ce6074553db0b2c9592a7e7c2eabf Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Tue, 21 Feb 2017 11:02:26 +0100 Subject: [PATCH] Re #4477: All usage (except Lua) of double converted to float. printf("%f") still uses promotion to double, (floating point va_args are always promoted to double) (#4483) --- radio/src/audio_arm.cpp | 6 +++--- radio/src/audio_arm.h | 4 ++-- radio/src/cli.cpp | 2 +- radio/src/gui/480x272/bitmapbuffer.cpp | 12 ++++++------ radio/src/thirdparty/Stb/stb_image.h | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/radio/src/audio_arm.cpp b/radio/src/audio_arm.cpp index 6aff1a3f5..b849f5605 100644 --- a/radio/src/audio_arm.cpp +++ b/radio/src/audio_arm.cpp @@ -651,7 +651,7 @@ int ToneContext::mixBuffer(AudioBuffer * buffer, int volume, unsigned int fade) int remainingDuration = fragment.tone.duration - state.duration; if (remainingDuration > 0) { int points; - double toneIdx = state.idx; + float toneIdx = state.idx; if (fragment.tone.reset) { fragment.tone.reset = 0; @@ -661,7 +661,7 @@ int ToneContext::mixBuffer(AudioBuffer * buffer, int volume, unsigned int fade) if (fragment.tone.freq != state.freq) { state.freq = fragment.tone.freq; - state.step = limit(1, double(DIM(sineValues)*fragment.tone.freq) / AUDIO_SAMPLE_RATE, 512); + state.step = limit(1, float(DIM(sineValues)*fragment.tone.freq) / AUDIO_SAMPLE_RATE, 512); state.volume = evalVolumeRatio(fragment.tone.freq, volume); } @@ -695,7 +695,7 @@ int ToneContext::mixBuffer(AudioBuffer * buffer, int volume, unsigned int fade) end -= (end % DIM(sineValues)); else end = DIM(sineValues); - points = (double(end) - toneIdx) / state.step; + points = (float(end) - toneIdx) / state.step; } for (int i=0; i 0) { diff --git a/radio/src/gui/480x272/bitmapbuffer.cpp b/radio/src/gui/480x272/bitmapbuffer.cpp index 6e21fed82..1581022e5 100644 --- a/radio/src/gui/480x272/bitmapbuffer.cpp +++ b/radio/src/gui/480x272/bitmapbuffer.cpp @@ -164,7 +164,7 @@ void BitmapBuffer::drawCircle(int x0, int y0, int radius) } #endif -#define PI 3.14159265 +#define PI 3.14159265f bool evalSlopes(int * slopes, int startAngle, int endAngle) { @@ -176,13 +176,13 @@ bool evalSlopes(int * slopes, int startAngle, int endAngle) slopes[2] = -100000; } else { - float angle1 = float(startAngle) * PI / 180; + float angle1 = float(startAngle) * PI / 180.0f; if (startAngle >= 180) { slopes[1] = -100000; - slopes[2] = cos(angle1) * 100 / sin(angle1); + slopes[2] = cosf(angle1) * 100 / sinf(angle1); } else { - slopes[1] = cos(angle1) * 100 / sin(angle1); + slopes[1] = cosf(angle1) * 100 / sinf(angle1); slopes[2] = -100000; } } @@ -195,10 +195,10 @@ bool evalSlopes(int * slopes, int startAngle, int endAngle) float angle2 = float(endAngle) * PI / 180; if (endAngle >= 180) { slopes[0] = -100000; - slopes[3] = -cos(angle2) * 100 / sin(angle2); + slopes[3] = -cosf(angle2) * 100 / sinf(angle2); } else { - slopes[0] = cos(angle2) * 100 / sin(angle2); + slopes[0] = cosf(angle2) * 100 / sinf(angle2); slopes[3] = -100000; } } diff --git a/radio/src/thirdparty/Stb/stb_image.h b/radio/src/thirdparty/Stb/stb_image.h index f7723dfd7..d13589374 100644 --- a/radio/src/thirdparty/Stb/stb_image.h +++ b/radio/src/thirdparty/Stb/stb_image.h @@ -1404,7 +1404,7 @@ static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) if (comp & 1) n = comp; else n = comp-1; for (i=0; i < x*y; ++i) { for (k=0; k < n; ++k) { - output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale); + output[i*comp + k] = (float) (powf(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale); } if (k < comp) output[i*comp + k] = data[i*comp+k]/255.0f; } @@ -1424,7 +1424,7 @@ static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) if (comp & 1) n = comp; else n = comp-1; for (i=0; i < x*y; ++i) { for (k=0; k < n; ++k) { - float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; + float z = (float) powf(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; if (z < 0) z = 0; if (z > 255) z = 255; output[i*comp + k] = (stbi_uc) stbi__float2int(z);