Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-03-27 21:12:59 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-03-27 21:12:59 +0400
commit9c8f1e2ef487483bc374feaed9ff709e07638623 (patch)
tree1157b72533f1b2c2e2082d91562bd9a2da4290fb /source/blender/imbuf
parent4237c0393a9d1f089f01dd7c4b223b1f61b15023 (diff)
imbuf, mathutils & readfile: floats were being implicitly promoted to doubles, adjust to use floats.
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/intern/divers.c6
-rw-r--r--source/blender/imbuf/intern/imageprocess.c16
-rw-r--r--source/blender/imbuf/intern/rectop.c12
-rw-r--r--source/blender/imbuf/intern/scaling.c76
-rw-r--r--source/blender/imbuf/intern/tiff.c2
5 files changed, 56 insertions, 56 deletions
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index ff98ac60166..6b35d7df397 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -109,7 +109,7 @@ void IMB_rect_from_float(struct ImBuf *ibuf)
/* quick method to convert floatbuf to byte */
float *tof = (float *)ibuf->rect_float;
// int do_dither = ibuf->dither != 0.f;
- float dither= ibuf->dither / 255.0;
+ float dither= ibuf->dither / 255.0f;
float srgb[4];
int i, channels= ibuf->channels;
short profile= ibuf->profile;
@@ -141,7 +141,7 @@ void IMB_rect_from_float(struct ImBuf *ibuf)
else if (channels == 4) {
if (dither != 0.f) {
for (i = ibuf->x * ibuf->y; i > 0; i--, to+=4, tof+=4) {
- const float d = (BLI_frand()-0.5)*dither;
+ const float d = (BLI_frand()-0.5f)*dither;
srgb[0]= d + linearrgb_to_srgb(tof[0]);
srgb[1]= d + linearrgb_to_srgb(tof[1]);
@@ -170,7 +170,7 @@ void IMB_rect_from_float(struct ImBuf *ibuf)
else {
if (dither != 0.f) {
for (i = ibuf->x * ibuf->y; i > 0; i--, to+=4, tof+=4) {
- const float d = (BLI_frand()-0.5)*dither;
+ const float d = (BLI_frand()-0.5f)*dither;
float col[4];
col[0]= d + tof[0];
diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c
index ef787e8b799..fa5e951067d 100644
--- a/source/blender/imbuf/intern/imageprocess.c
+++ b/source/blender/imbuf/intern/imageprocess.c
@@ -274,8 +274,8 @@ void bilinear_interpolation_color(struct ImBuf *in, unsigned char *outI, float *
if (x2>in->x-1 || y2>in->y-1) row4= empty;
else row4= (float *)in->rect_float + in->x * y2 * 4 + 4*x2;
- a= u-floor(u);
- b= v-floor(v);
+ a= u-floorf(u);
+ b= v-floorf(v);
a_b= a*b; ma_b= (1.0f-a)*b; a_mb= a*(1.0f-b); ma_mb= (1.0f-a)*(1.0f-b);
outF[0]= ma_mb*row1[0] + a_mb*row3[0] + ma_b*row2[0]+ a_b*row4[0];
@@ -297,8 +297,8 @@ void bilinear_interpolation_color(struct ImBuf *in, unsigned char *outI, float *
if (x2>in->x-1 || y2>in->y-1) row4I= emptyI;
else row4I= (unsigned char *)in->rect + in->x * y2 * 4 + 4*x2;
- a= u-floor(u);
- b= v-floor(v);
+ a= u-floorf(u);
+ b= v-floorf(v);
a_b= a*b; ma_b= (1.0f-a)*b; a_mb= a*(1.0f-b); ma_mb= (1.0f-a)*(1.0f-b);
/* need to add 0.5 to avoid rounding down (causes darken with the smear brush)
@@ -348,8 +348,8 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *outI, fl
row3= (float *)in->rect_float + in->x * y1 * 4 + 4*x2;
row4= (float *)in->rect_float + in->x * y2 * 4 + 4*x2;
- a= u-floor(u);
- b= v-floor(v);
+ a= u-floorf(u);
+ b= v-floorf(v);
a_b= a*b; ma_b= (1.0f-a)*b; a_mb= a*(1.0f-b); ma_mb= (1.0f-a)*(1.0f-b);
outF[0]= ma_mb*row1[0] + a_mb*row3[0] + ma_b*row2[0]+ a_b*row4[0];
@@ -364,8 +364,8 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *outI, fl
row3I= (unsigned char *)in->rect + in->x * y1 * 4 + 4*x2;
row4I= (unsigned char *)in->rect + in->x * y2 * 4 + 4*x2;
- a= u-floor(u);
- b= v-floor(v);
+ a= u-floorf(u);
+ b= v-floorf(v);
a_b= a*b; ma_b= (1.0f-a)*b; a_mb= a*(1.0f-b); ma_mb= (1.0f-a)*(1.0f-b);
/* need to add 0.5 to avoid rounding down (causes darken with the smear brush)
diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c
index a6556cc3a9a..44af7ffdb3f 100644
--- a/source/blender/imbuf/intern/rectop.c
+++ b/source/blender/imbuf/intern/rectop.c
@@ -164,7 +164,7 @@ unsigned int IMB_blend_color(unsigned int src1, unsigned int src2, int fac, IMB_
static void blend_color_mix_float(float *cp, float *cp1, float *cp2, float fac)
{
- float mfac= 1.0-fac;
+ float mfac= 1.0f-fac;
cp[0]= mfac*cp1[0] + fac*cp2[0];
cp[1]= mfac*cp1[1] + fac*cp2[1];
cp[2]= mfac*cp1[2] + fac*cp2[2];
@@ -194,7 +194,7 @@ static void blend_color_sub_float(float *cp, float *cp1, float *cp2, float fac)
static void blend_color_mul_float(float *cp, float *cp1, float *cp2, float fac)
{
- float mfac= 1.0-fac;
+ float mfac= 1.0f-fac;
cp[0]= mfac*cp1[0] + fac*(cp1[0]*cp2[0]);
cp[1]= mfac*cp1[1] + fac*(cp1[1]*cp2[1]);
@@ -488,7 +488,7 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
float a; /* alpha */
float ai; /* alpha inverted */
float aich; /* alpha, inverted, ai/255.0 - Convert char to float at the same time */
- if ((!rect && !rectf) || (!col) || col[3]==0.0)
+ if ((!rect && !rectf) || (!col) || col[3]==0.0f)
return;
/* sanity checks for coords */
@@ -510,7 +510,7 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
unsigned char chr=0, chg=0, chb=0;
float fr=0, fg=0, fb=0;
- if (a == 1.0) {
+ if (a == 1.0f) {
chr = FTOCHAR(col[0]);
chg = FTOCHAR(col[1]);
chb = FTOCHAR(col[2]);
@@ -523,7 +523,7 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
for (i = 0; i < x2-x1; i++) {
pixel = rect + 4 * (((y1 + j) * width) + (x1 + i));
if (pixel >= rect && pixel < rect+ (4 * (width * height))) {
- if (a == 1.0) {
+ if (a == 1.0f) {
pixel[0] = chr;
pixel[1] = chg;
pixel[2] = chb;
@@ -542,7 +542,7 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
for (j = 0; j < y2-y1; j++) {
for (i = 0; i < x2-x1; i++) {
pixel = rectf + 4 * (((y1 + j) * width) + (x1 + i));
- if (a == 1.0) {
+ if (a == 1.0f) {
pixel[0] = col[0];
pixel[1] = col[1];
pixel[2] = col[2];
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index 541f4586afb..9d6748ec1fb 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -594,8 +594,8 @@ static void enlarge_picture_float(
for (y_dst = 0; y_dst < dst_height; y_dst++) {
float* line1 = src + ((int) y_src) * 4 * src_width;
float* line2 = line1 + 4 * src_width;
- float weight1y = 1.0 - (y_src - (int) y_src);
- float weight2y = 1.0 - weight1y;
+ const float weight1y = (float)(1.0 - (y_src - (int) y_src));
+ const float weight2y = 1.0f - weight1y;
if ((int) y_src == src_height - 1) {
line2 = line1;
@@ -603,13 +603,13 @@ static void enlarge_picture_float(
x_src = 0;
for (x_dst = 0; x_dst < dst_width; x_dst++) {
- float weight1x = 1.0 - (x_src - (int) x_src);
- float weight2x = 1.0 - weight1x;
+ const float weight1x = (float)(1.0 - (x_src - (int) x_src));
+ const float weight2x = (float)(1.0f - weight1x);
- float w11 = weight1y * weight1x;
- float w21 = weight2y * weight1x;
- float w12 = weight1y * weight2x;
- float w22 = weight2y * weight2x;
+ const float w11 = weight1y * weight1x;
+ const float w21 = weight2y * weight1x;
+ const float w12 = weight1y * weight2x;
+ const float w22 = weight2y * weight2x;
uintptr_t x = ((int) x_src) * 4;
@@ -678,12 +678,12 @@ static void shrink_picture_float(
y_counter = 1.0;
for (y_src = 0; y_src < src_height; y_src++) {
float* line = src + y_src * 4 * src_width;
- uintptr_t weight1y = 1.0 - (y_dst - (int) y_dst);
- uintptr_t weight2y = 1.0 - weight1y;
+ uintptr_t weight1y = 1.0f - (y_dst - (int) y_dst);
+ uintptr_t weight2y = 1.0f - weight1y;
x_dst = 0;
for (x_src = 0; x_src < src_width; x_src++) {
- uintptr_t weight1x = 1.0 - (x_dst - (int) x_dst);
- uintptr_t weight2x = 1.0 - weight1x;
+ uintptr_t weight1x = 1.0f - (x_dst - (int) x_dst);
+ uintptr_t weight2x = 1.0f - weight1x;
uintptr_t x = (int) x_dst;
@@ -731,10 +731,10 @@ static void shrink_picture_float(
uintptr_t x;
struct scale_outpix_float * temp;
- y_counter += 1.0;
+ y_counter += 1.0f;
for (x=0; x < dst_width; x++) {
- float f = 1.0 / dst_line1[x].weight;
+ float f = 1.0f / dst_line1[x].weight;
*dst++ = dst_line1[x].r * f;
*dst++ = dst_line1[x].g * f;
*dst++ = dst_line1[x].b * f;
@@ -750,7 +750,7 @@ static void shrink_picture_float(
if (dst - dst_begin < dst_width * dst_height * 4) {
uintptr_t x;
for (x = 0; x < dst_width; x++) {
- float f = 1.0 / dst_line1[x].weight;
+ float f = 1.0f / dst_line1[x].weight;
*dst++ = dst_line1[x].r * f;
*dst++ = dst_line1[x].g * f;
*dst++ = dst_line1[x].b * f;
@@ -1026,8 +1026,8 @@ static struct ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
sample += add;
- while (sample >= 1.0) {
- sample -= 1.0;
+ while (sample >= 1.0f) {
+ sample -= 1.0f;
if (do_rect) {
nval[0] += rect[0];
@@ -1069,7 +1069,7 @@ static struct ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
newrectf += skipx;
}
- sample -= 1.0;
+ sample -= 1.0f;
}
}
@@ -1142,22 +1142,22 @@ static struct ImBuf *scaleupx(struct ImBuf *ibuf, int newx)
val_a = rect[0] ;
nval_a = rect[4];
diff_a = nval_a - val_a ;
- val_a += 0.5;
+ val_a += 0.5f;
val_b = rect[1] ;
nval_b = rect[5];
diff_b = nval_b - val_b ;
- val_b += 0.5;
+ val_b += 0.5f;
val_g = rect[2] ;
nval_g = rect[6];
diff_g = nval_g - val_g ;
- val_g += 0.5;
+ val_g += 0.5f;
val_r = rect[3] ;
nval_r = rect[7];
diff_r = nval_r - val_r ;
- val_r += 0.5;
+ val_r += 0.5f;
rect += 8;
}
@@ -1181,29 +1181,29 @@ static struct ImBuf *scaleupx(struct ImBuf *ibuf, int newx)
rectf += 8;
}
for (x = newx ; x>0 ; x--){
- if (sample >= 1.0){
- sample -= 1.0;
+ if (sample >= 1.0f){
+ sample -= 1.0f;
if (do_rect) {
val_a = nval_a ;
nval_a = rect[0] ;
diff_a = nval_a - val_a ;
- val_a += 0.5;
+ val_a += 0.5f;
val_b = nval_b ;
nval_b = rect[1] ;
diff_b = nval_b - val_b ;
- val_b += 0.5;
+ val_b += 0.5f;
val_g = nval_g ;
nval_g = rect[2] ;
diff_g = nval_g - val_g ;
- val_g += 0.5;
+ val_g += 0.5f;
val_r = nval_r ;
nval_r = rect[3] ;
diff_r = nval_r - val_r ;
- val_r += 0.5;
+ val_r += 0.5f;
rect += 4;
}
if (do_float) {
@@ -1312,22 +1312,22 @@ static struct ImBuf *scaleupy(struct ImBuf *ibuf, int newy)
val_a = rect[0] ;
nval_a = rect[skipx];
diff_a = nval_a - val_a ;
- val_a += 0.5;
+ val_a += 0.5f;
val_b = rect[1] ;
nval_b = rect[skipx+1];
diff_b = nval_b - val_b ;
- val_b += 0.5;
+ val_b += 0.5f;
val_g = rect[2] ;
nval_g = rect[skipx+2];
diff_g = nval_g - val_g ;
- val_g += 0.5;
+ val_g += 0.5f;
val_r = rect[3] ;
nval_r = rect[skipx+4];
diff_r = nval_r - val_r ;
- val_r += 0.5;
+ val_r += 0.5f;
rect += 2*skipx;
}
@@ -1355,29 +1355,29 @@ static struct ImBuf *scaleupy(struct ImBuf *ibuf, int newy)
}
for (y = newy ; y>0 ; y--){
- if (sample >= 1.0){
- sample -= 1.0;
+ if (sample >= 1.0f){
+ sample -= 1.0f;
if (do_rect) {
val_a = nval_a ;
nval_a = rect[0] ;
diff_a = nval_a - val_a ;
- val_a += 0.5;
+ val_a += 0.5f;
val_b = nval_b ;
nval_b = rect[1] ;
diff_b = nval_b - val_b ;
- val_b += 0.5;
+ val_b += 0.5f;
val_g = nval_g ;
nval_g = rect[2] ;
diff_g = nval_g - val_g ;
- val_g += 0.5;
+ val_g += 0.5f;
val_r = nval_r ;
nval_r = rect[3] ;
diff_r = nval_r - val_r ;
- val_r += 0.5;
+ val_r += 0.5f;
rect += skipx;
}
if (do_float) {
diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c
index 0c04887e606..155696fb199 100644
--- a/source/blender/imbuf/intern/tiff.c
+++ b/source/blender/imbuf/intern/tiff.c
@@ -336,7 +336,7 @@ static void scanline_contig_32bit(float *rectf, float *fbuf, int scanline_w, int
rectf[i*4 + 0] = fbuf[i*spp + 0];
rectf[i*4 + 1] = fbuf[i*spp + 1];
rectf[i*4 + 2] = fbuf[i*spp + 2];
- rectf[i*4 + 3] = (spp==4)?fbuf[i*spp + 3]:1.0;
+ rectf[i*4 + 3] = (spp==4)?fbuf[i*spp + 3]:1.0f;
}
}