code cleanup: double promotions
authorCampbell Barton <ideasman42@gmail.com>
Sun, 4 Nov 2012 10:20:16 +0000 (10:20 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 4 Nov 2012 10:20:16 +0000 (10:20 +0000)
intern/audaspace/FX/AUD_ButterworthFactory.cpp
intern/audaspace/FX/AUD_DelayReader.cpp
intern/audaspace/FX/AUD_HighpassFactory.cpp
intern/bsp/intern/BOP_CarveInterface.cpp
source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
source/blender/editors/space_file/filelist.c
source/blender/imbuf/intern/cineon/logImageCore.c
source/blender/imbuf/intern/radiance_hdr.c
source/blender/render/intern/raytrace/svbvh.h

index 5edca302ece9f825e25baec591505968d46fe893..af1a5af97df17593f530caa3fc11318ccfa79b5e 100644 (file)
@@ -53,11 +53,11 @@ void AUD_ButterworthFactory::recalculateCoefficients(AUD_SampleRate rate,
        float omega = 2 * tan(m_frequency * M_PI / rate);
        float o2 = omega * omega;
        float o4 = o2 * o2;
-       float x1 = o2 + 2 * BWPB41 * omega + 4;
-       float x2 = o2 + 2 * BWPB42 * omega + 4;
-       float y1 = o2 - 2 * BWPB41 * omega + 4;
-       float y2 = o2 - 2 * BWPB42 * omega + 4;
-       float o228 = 2 * o2 - 8;
+       float x1 = o2 + 2.0f * (float)BWPB41 * omega + 4.0f;
+       float x2 = o2 + 2.0f * (float)BWPB42 * omega + 4.0f;
+       float y1 = o2 - 2.0f * (float)BWPB41 * omega + 4.0f;
+       float y2 = o2 - 2.0f * (float)BWPB42 * omega + 4.0f;
+       float o228 = 2.0f * o2 - 8.0f;
        float norm = x1 * x2;
        a.push_back(1);
        a.push_back((x1 + x2) * o228 / norm);
index 903e043af01e6b2c93a4dfd7bb08a5624c74e5a5..0e9833cd07f74f0c05491dc94dd8650ab2c3460e 100644 (file)
@@ -33,8 +33,8 @@
 
 AUD_DelayReader::AUD_DelayReader(AUD_Reference<AUD_IReader> reader, float delay) :
                AUD_EffectReader(reader),
-               m_delay(int(delay * reader->getSpecs().rate)),
-               m_remdelay(int(delay * reader->getSpecs().rate))
+               m_delay(int((AUD_SampleRate)delay * reader->getSpecs().rate)),
+               m_remdelay(int((AUD_SampleRate)delay * reader->getSpecs().rate))
 {
 }
 
index 41070842596639a576ee771efefdefd2ca443d4c..b56be8942ff34565fb067ed374c9e70e23ace2b9 100644 (file)
@@ -48,8 +48,8 @@ void AUD_HighpassFactory::recalculateCoefficients(AUD_SampleRate rate,
                                                                                                  std::vector<float> &b,
                                                                                                  std::vector<float> &a)
 {
-       float w0 = 2 * M_PI * m_frequency / rate;
-       float alpha = sin(w0) / (2 * m_Q);
+       float w0 = 2.0 * M_PI * (AUD_SampleRate)m_frequency / rate;
+       float alpha = (float)(sin(w0) / (2.0 * (double)m_Q));
        float norm = 1 + alpha;
        float c = cos(w0);
        a.push_back(1);
index 93d15e6d5e6a4f4a39991b5ce246890a8d52221b..49c999a1dd4702232385032c27521b0dbb6d90ed 100644 (file)
@@ -60,7 +60,7 @@ static bool isQuadPlanar(carve::geom3d::Vector &v1, carve::geom3d::Vector &v2,
        float production = carve::geom::dot(cross, vec3);
        float magnitude = 1e-5 * cross.length();
 
-       return fabs(production) < magnitude;
+       return fabsf(production) < magnitude;
 }
 
 static bool isFacePlanar(CSG_IFace &face, std::vector<carve::geom3d::Vector> &vertices)
index efdf0134c4b56e70406cac34f3108a396097a1f4..592ad114113df9dcfbab2d6f4b2ef22144ccb104 100644 (file)
@@ -86,8 +86,8 @@ static void FHT(fREAL *data, unsigned int M, unsigned int inverse)
                                fREAL *data_nbd = &data_n[bd];
                                fREAL *data_bd = &data[bd];
                                for (k = bl; k < len; k += istep) {
-                                       t1 = fc * data_n[k] + fs * data_nbd[k];
-                                       t2 = fs * data_n[k] - fc * data_nbd[k];
+                                       t1 = fc * (double)data_n[k] + fs * (double)data_nbd[k];
+                                       t2 = fs * (double)data_n[k] - fc * (double)data_nbd[k];
                                        data_n[k] = data[k] - t1;
                                        data_nbd[k] = data_bd[k] - t2;
                                        data[k] += t1;
@@ -395,7 +395,7 @@ void GlareFogGlowOperation::generateGlare(float *data, MemoryBuffer *inputTile,
                        // linear window good enough here, visual result counts, not scientific analysis
                        //w = (1.f-fabs(u))*(1.f-fabs(v));
                        // actually, Hanning window is ok, cos^2 for some reason is slower
-                       w = (0.5f + 0.5f * cos((double)u * M_PI)) * (0.5f + 0.5f * cos((double)v * M_PI));
+                       w = (0.5f + 0.5f * cosf(u * (float)M_PI)) * (0.5f + 0.5f * cosf(v * (float)M_PI));
                        mul_v3_fl(fcol, w);
                        ckrn->writePixel(x, y, fcol);
                }
index d8e6510a2691822cafa54ee9c857d6b77df0bfd7..8f94086013c027eec50fab00d0f9fea1a38f1d04 100644 (file)
@@ -785,7 +785,7 @@ static int file_extension_type(const char *relname)
        }
        else if (BLI_testextensie(relname, ".txt")  ||
                 BLI_testextensie(relname, ".glsl") ||
-                        BLI_testextensie(relname, ".osl")  ||
+                BLI_testextensie(relname, ".osl")  ||
                 BLI_testextensie(relname, ".data"))
        {
                return TEXTFILE;
index 5c734db323d0ac37dffc2b23ec19d300572d532d..3911e5c2ef37ebbc93e593eb0c65046e91bc39c6 100644 (file)
@@ -947,7 +947,7 @@ static void getLogToLinLut(float *lut, LogImageFile *logImage, LogImageElement l
        softClip = 0;
 
        breakPoint = logImage->referenceWhite - softClip;
-       gain = logElement.maxValue / (1.0 - powf(10, (logImage->referenceBlack - logImage->referenceWhite) * step / negativeFilmGamma * logImage->gamma / 1.7f));
+       gain = logElement.maxValue / (1.0f - powf(10, (logImage->referenceBlack - logImage->referenceWhite) * step / negativeFilmGamma * logImage->gamma / 1.7f));
        offset = gain - logElement.maxValue;
        kneeOffset = powf(10, (breakPoint - logImage->referenceWhite) * step / negativeFilmGamma * logImage->gamma / 1.7f) * gain - offset;
        kneeGain = (logElement.maxValue - kneeOffset) / powf(5 * softClip, softClip / 100);
index 53b00f441c8e2ffe6bbfd75e37b2fdfc248dce96..72cec0e3749e86750841ef31a95703fce2a1e410 100644 (file)
@@ -154,7 +154,7 @@ static void FLOAT2RGBE(fCOLOR fcol, RGBE rgbe)
        if (d <= 1e-32f)
                rgbe[RED] = rgbe[GRN] = rgbe[BLU] = rgbe[EXP] = 0;
        else {
-               d = frexp(d, &e) * 256.f / d;
+               d = (float)frexp(d, &e) * 256.0f / d;
                rgbe[RED] = (unsigned char)(fcol[RED] * d);
                rgbe[GRN] = (unsigned char)(fcol[GRN] * d);
                rgbe[BLU] = (unsigned char)(fcol[BLU] * d);
index 757ebc4c4d3e8e3e4f439849be2591ca1012ba27..6ec75ebb527f2506e2949889cdb41ecd08cc48ef 100644 (file)
@@ -93,7 +93,7 @@ static int svbvh_bb_intersect_test(const Isect *isec, const float *_bb)
        RE_RC_COUNT(isec->raycounter->bb.test);
 
        if (t1x > t2y || t2x < t1y || t1x > t2z || t2x < t1z || t1y > t2z || t2y < t1z) return 0;
-       if (t2x < 0.0 || t2y < 0.0 || t2z < 0.0) return 0;
+       if (t2x < 0.0f || t2y < 0.0f || t2z < 0.0f) return 0;
        if (t1x > isec->dist || t1y > isec->dist || t1z > isec->dist) return 0;
 
        RE_RC_COUNT(isec->raycounter->bb.hit);