1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-20 06:45:10 +03:00

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)

This commit is contained in:
Damjan Adamic 2017-02-21 11:02:26 +01:00 committed by Bertrand Songis
parent f36d01d560
commit 2fbd1d8955
5 changed files with 14 additions and 14 deletions

View file

@ -651,7 +651,7 @@ int ToneContext::mixBuffer(AudioBuffer * buffer, int volume, unsigned int fade)
int remainingDuration = fragment.tone.duration - state.duration; int remainingDuration = fragment.tone.duration - state.duration;
if (remainingDuration > 0) { if (remainingDuration > 0) {
int points; int points;
double toneIdx = state.idx; float toneIdx = state.idx;
if (fragment.tone.reset) { if (fragment.tone.reset) {
fragment.tone.reset = 0; fragment.tone.reset = 0;
@ -661,7 +661,7 @@ int ToneContext::mixBuffer(AudioBuffer * buffer, int volume, unsigned int fade)
if (fragment.tone.freq != state.freq) { if (fragment.tone.freq != state.freq) {
state.freq = fragment.tone.freq; state.freq = fragment.tone.freq;
state.step = limit<double>(1, double(DIM(sineValues)*fragment.tone.freq) / AUDIO_SAMPLE_RATE, 512); state.step = limit<float>(1, float(DIM(sineValues)*fragment.tone.freq) / AUDIO_SAMPLE_RATE, 512);
state.volume = evalVolumeRatio(fragment.tone.freq, volume); 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)); end -= (end % DIM(sineValues));
else else
end = DIM(sineValues); end = DIM(sineValues);
points = (double(end) - toneIdx) / state.step; points = (float(end) - toneIdx) / state.step;
} }
for (int i=0; i<points; i++) { for (int i=0; i<points; i++) {

View file

@ -193,8 +193,8 @@ class ToneContext {
AudioFragment fragment; AudioFragment fragment;
struct { struct {
double step; float step;
double idx; float idx;
float volume; float volume;
uint16_t freq; uint16_t freq;
uint16_t duration; uint16_t duration;

View file

@ -812,7 +812,7 @@ int cliDisplay(const char ** argv)
else if (!strcmp(argv[1], "dc")) { else if (!strcmp(argv[1], "dc")) {
DiskCacheStats stats = diskCache.getStats(); DiskCacheStats stats = diskCache.getStats();
uint32_t hitRate = diskCache.getHitRate(); uint32_t hitRate = diskCache.getHitRate();
serialPrint("Disk Cache stats: w:%u r: %u, h: %u(%0.1f%%), m: %u", stats.noWrites, (stats.noHits + stats.noMisses), stats.noHits, hitRate/10.0, stats.noMisses); serialPrint("Disk Cache stats: w:%u r: %u, h: %u(%0.1f%%), m: %u", stats.noWrites, (stats.noHits + stats.noMisses), stats.noHits, hitRate/10.0f, stats.noMisses);
} }
#endif #endif
else if (toLongLongInt(argv, 1, &address) > 0) { else if (toLongLongInt(argv, 1, &address) > 0) {

View file

@ -164,7 +164,7 @@ void BitmapBuffer::drawCircle(int x0, int y0, int radius)
} }
#endif #endif
#define PI 3.14159265 #define PI 3.14159265f
bool evalSlopes(int * slopes, int startAngle, int endAngle) bool evalSlopes(int * slopes, int startAngle, int endAngle)
{ {
@ -176,13 +176,13 @@ bool evalSlopes(int * slopes, int startAngle, int endAngle)
slopes[2] = -100000; slopes[2] = -100000;
} }
else { else {
float angle1 = float(startAngle) * PI / 180; float angle1 = float(startAngle) * PI / 180.0f;
if (startAngle >= 180) { if (startAngle >= 180) {
slopes[1] = -100000; slopes[1] = -100000;
slopes[2] = cos(angle1) * 100 / sin(angle1); slopes[2] = cosf(angle1) * 100 / sinf(angle1);
} }
else { else {
slopes[1] = cos(angle1) * 100 / sin(angle1); slopes[1] = cosf(angle1) * 100 / sinf(angle1);
slopes[2] = -100000; slopes[2] = -100000;
} }
} }
@ -195,10 +195,10 @@ bool evalSlopes(int * slopes, int startAngle, int endAngle)
float angle2 = float(endAngle) * PI / 180; float angle2 = float(endAngle) * PI / 180;
if (endAngle >= 180) { if (endAngle >= 180) {
slopes[0] = -100000; slopes[0] = -100000;
slopes[3] = -cos(angle2) * 100 / sin(angle2); slopes[3] = -cosf(angle2) * 100 / sinf(angle2);
} }
else { else {
slopes[0] = cos(angle2) * 100 / sin(angle2); slopes[0] = cosf(angle2) * 100 / sinf(angle2);
slopes[3] = -100000; slopes[3] = -100000;
} }
} }

View file

@ -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; if (comp & 1) n = comp; else n = comp-1;
for (i=0; i < x*y; ++i) { for (i=0; i < x*y; ++i) {
for (k=0; k < n; ++k) { 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; 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; if (comp & 1) n = comp; else n = comp-1;
for (i=0; i < x*y; ++i) { for (i=0; i < x*y; ++i) {
for (k=0; k < n; ++k) { 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 < 0) z = 0;
if (z > 255) z = 255; if (z > 255) z = 255;
output[i*comp + k] = (stbi_uc) stbi__float2int(z); output[i*comp + k] = (stbi_uc) stbi__float2int(z);