links

lynx-like text mode web browser
git clone anongit@rnpnr.xyz:links.git
Log | Files | Refs | Feed | README | LICENSE

Commit: ea44ac4cd6c824fd920ebbb2e953abc4f071f719
Parent: 1d3daaf16f610bb82d98ddf2cfe2e04cd5bac999
Author: opask
Date:   Tue, 14 Aug 2018 18:03:49 -0600

sed s:float_double:float:g

Diffstat:
Mdip.c | 80++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mdither.c | 28++++++++++++++--------------
2 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/dip.c b/dip.c @@ -1036,10 +1036,10 @@ void agx_and_uc_32_to_48(unsigned short *restrict dest, float green_gamma, float blue_gamma, unsigned short rb, unsigned short gb, unsigned short bb) { - float_double r,g,b; + float r,g,b; unsigned char alpha, calpha; unsigned short ri,gi,bi; - const float_double inv_255=(float_double)(1/255.); + const float inv_255=(float)(1/255.); for (;lenght;lenght--) { @@ -1054,9 +1054,9 @@ void agx_and_uc_32_to_48(unsigned short *restrict dest, r=fd_pow(r,red_gamma); g=fd_pow(g,green_gamma); b=fd_pow(b,blue_gamma); - ri=(unsigned)((r*65535)+(float_double)0.5); - gi=(unsigned)((g*65535)+(float_double)0.5); - bi=(unsigned)((b*65535)+(float_double)0.5); + ri=(unsigned)((r*65535)+(float)0.5); + gi=(unsigned)((g*65535)+(float)0.5); + bi=(unsigned)((b*65535)+(float)0.5); if (((alpha + 1) & 255) >= 2) { calpha=255-alpha; dest[0]=(unsigned short)((ri*alpha+calpha*rb+127U)/255U); @@ -1087,10 +1087,10 @@ void agx_and_uc_64_to_48(unsigned short *restrict dest, float green_gamma, float blue_gamma, unsigned short rb, unsigned short gb, unsigned short bb) { - float_double r,g,b; + float r,g,b; unsigned short alpha, calpha; unsigned short ri,gi,bi; - const float_double inv_65535=(float_double)(1/65535.); + const float inv_65535=(float)(1/65535.); for (;lenght;lenght--) { @@ -1105,9 +1105,9 @@ void agx_and_uc_64_to_48(unsigned short *restrict dest, r=fd_pow(r,red_gamma); g=fd_pow(g,green_gamma); b=fd_pow(b,blue_gamma); - ri=(unsigned short)(r*65535+(float_double)0.5); - gi=(unsigned short)(g*65535+(float_double)0.5); - bi=(unsigned short)(b*65535+(float_double)0.5); + ri=(unsigned short)(r*65535+(float)0.5); + gi=(unsigned short)(g*65535+(float)0.5); + bi=(unsigned short)(b*65535+(float)0.5); if (((alpha + 1) & 65535) >= 2) { calpha=65535-alpha; dest[0]=(unsigned short)((ri*alpha+calpha*rb+32767U)/65535U); @@ -1175,23 +1175,23 @@ void agx_48_to_48(unsigned short *restrict dest, const unsigned short *restrict src, int lenght, float red_gamma, float green_gamma, float blue_gamma) { - float_double a; - const float_double inv_65535=(float_double)(1/65535.); + float a; + const float inv_65535=(float)(1/65535.); for (;lenght;lenght--,src+=3,dest+=3) { a=*src; a*=inv_65535; a=fd_pow(a,red_gamma); - dest[0]=(unsigned short)((a*65535)+(float_double)0.5); + dest[0]=(unsigned short)((a*65535)+(float)0.5); a=src[1]; a*=inv_65535; a=fd_pow(a,green_gamma); - dest[1]=(unsigned short)((a*65535)+(float_double)0.5); + dest[1]=(unsigned short)((a*65535)+(float)0.5); a=src[2]; a*=inv_65535; a=fd_pow(a,blue_gamma); - dest[2]=(unsigned short)((a*65535)+(float_double)0.5); + dest[2]=(unsigned short)((a*65535)+(float)0.5); } } @@ -1218,23 +1218,23 @@ void agx_24_to_48(unsigned short *restrict dest, const unsigned char *restrict s lenght, float red_gamma, float green_gamma, float blue_gamma) { - float_double a; - const float_double inv_255=(float_double)(1/255.); + float a; + const float inv_255=(float)(1/255.); for (;lenght;lenght--,src+=3,dest+=3) { a=*src; a*=inv_255; a=fd_pow(a,red_gamma); - dest[0]=(unsigned short)((a*65535)+(float_double)0.5); + dest[0]=(unsigned short)((a*65535)+(float)0.5); a=src[1]; a*=inv_255; a=fd_pow(a,green_gamma); - dest[1]=(unsigned short)((a*65535)+(float_double)0.5); + dest[1]=(unsigned short)((a*65535)+(float)0.5); a=src[2]; a*=inv_255; a=fd_pow(a,blue_gamma); - dest[2]=(unsigned short)((a*65535)+(float_double)0.5); + dest[2]=(unsigned short)((a*65535)+(float)0.5); } } @@ -1243,29 +1243,29 @@ void agx_24_to_48(unsigned short *restrict dest, const unsigned char *restrict s * We assume unsigned short holds at least 16 bits. */ void make_gamma_table(struct cached_image *cimg) { - float_double rg=(float_double)((float_double)user_gamma/cimg->red_gamma); - float_double gg=(float_double)((float_double)user_gamma/cimg->green_gamma); - float_double bg=(float_double)((float_double)user_gamma/cimg->blue_gamma); + float rg=(float)((float)user_gamma/cimg->red_gamma); + float gg=(float)((float)user_gamma/cimg->green_gamma); + float bg=(float)((float)user_gamma/cimg->blue_gamma); int a; unsigned short *ptr_16; unsigned short last_val; - const float_double inv_255=(float_double)(1/255.); - const float_double inv_65535=(float_double)(1/65535.); + const float inv_255=(float)(1/255.); + const float inv_65535=(float)(1/65535.); if (cimg->buffer_bytes_per_pixel<=4){ /* 8-bit */ ptr_16 = xmalloc(768 * sizeof(*(cimg->gamma_table))); cimg->gamma_table=ptr_16; for (a=0;a<256;a++,ptr_16++){ - last_val = (unsigned short)(65535*fd_pow((float_double)a*inv_255,rg)+(float_double)0.5); + last_val = (unsigned short)(65535*fd_pow((float)a*inv_255,rg)+(float)0.5); *ptr_16 = last_val; } for (a=0;a<256;a++,ptr_16++){ - last_val = (unsigned short)(65535*fd_pow((float_double)a*inv_255,gg)+(float_double)0.5); + last_val = (unsigned short)(65535*fd_pow((float)a*inv_255,gg)+(float)0.5); *ptr_16 = last_val; } for (a=0;a<256;a++,ptr_16++){ - last_val = (unsigned short)(65535*fd_pow((float_double)a*inv_255,bg)+(float_double)0.5); + last_val = (unsigned short)(65535*fd_pow((float)a*inv_255,bg)+(float)0.5); *ptr_16 = last_val; } }else{ @@ -1280,17 +1280,17 @@ void make_gamma_table(struct cached_image *cimg) cimg->gamma_table=ptr_16; for (a=0;a<0x10000;a++,ptr_16++){ if (!x_slow_fpu || !(a & 0xff)) - last_val = (unsigned short)(65535*fd_pow((float_double)a*inv_65535,rg)+(float_double)0.5); + last_val = (unsigned short)(65535*fd_pow((float)a*inv_65535,rg)+(float)0.5); *ptr_16 = last_val; } for (a=0;a<0x10000;a++,ptr_16++){ if (!x_slow_fpu || !(a & 0xff)) - last_val = (unsigned short)(65535*fd_pow((float_double)a*inv_65535,gg)+(float_double)0.5); + last_val = (unsigned short)(65535*fd_pow((float)a*inv_65535,gg)+(float)0.5); *ptr_16 = last_val; } for (a=0;a<0x10000;a++,ptr_16++){ if (!x_slow_fpu || !(a & 0xff)) - last_val = (unsigned short)(65535*fd_pow((float_double)a*inv_65535,bg)+(float_double)0.5); + last_val = (unsigned short)(65535*fd_pow((float)a*inv_65535,bg)+(float)0.5); *ptr_16 = last_val; } } @@ -1312,8 +1312,8 @@ void agx_24_to_48_table(unsigned short *restrict dest, const unsigned char *rest /* Input is 0-255 (8-bit). Output is 0-255 (8-bit)*/ unsigned char ags_8_to_8(unsigned char input, float gamma) { - const float_double inv_255=1/255.; - return 255*fd_pow((float_double)input*inv_255,gamma)+(float_double)0.5; + const float inv_255=1/255.; + return 255*fd_pow((float)input*inv_255,gamma)+(float)0.5; } #endif @@ -1321,14 +1321,14 @@ unsigned char ags_8_to_8(unsigned char input, float gamma) /* We assume unsigned short holds at least 16 bits. */ unsigned short ags_8_to_16(unsigned char input, float gamma) { - float_double a=input; + float a=input; unsigned short retval; - const float_double inv_255=(float_double)(1/255.); + const float inv_255=(float)(1/255.); a*=inv_255; a=fd_pow(a,gamma); a*=65535; - retval = (unsigned short)(a+(float_double)0.5); + retval = (unsigned short)(a+(float)0.5); return retval; } @@ -1336,17 +1336,17 @@ unsigned short ags_8_to_16(unsigned char input, float gamma) /* We assume unsigned short holds at least 16 bits. */ unsigned char ags_16_to_8(unsigned short input, float gamma) { - const float_double inv_65535=(float_double)(1/65535.); - return (unsigned char)(fd_pow((float_double)input*inv_65535,gamma)*255+(float_double)0.5); + const float inv_65535=(float)(1/65535.); + return (unsigned char)(fd_pow((float)input*inv_65535,gamma)*255+(float)0.5); } /* Input is 0-65535 (16-bit). Output is 0-255 (8-bit)*/ unsigned short ags_16_to_16(unsigned short input, float gamma) { unsigned short retval; - const float_double inv_65535=(float_double)(1/65535.); + const float inv_65535=(float)(1/65535.); - retval = (unsigned short)(65535*fd_pow((float_double)input*inv_65535,gamma)+(float_double)0.5); + retval = (unsigned short)(65535*fd_pow((float)input*inv_65535,gamma)+(float)0.5); return retval; } diff --git a/dither.c b/dither.c @@ -118,7 +118,7 @@ static long color_555(int); static long color_565be(int); static long color_565(int); /*static void make_8_table(int *, double);*/ -static void make_16_table(int *, int, int, float_double, int, int); +static void make_16_table(int *, int, int, float, int, int); static void make_red_table(int, int, int, int); static void make_green_table(int, int, int, int); static void make_blue_table(int, int, int, int); @@ -658,11 +658,11 @@ long (*get_color_fn(int depth))(int rgb) static void make_8_table(int *table, double gamma) { int i,light0; - float_double light; - const float_double inv_255=1/255.; + float light; + const float inv_255=1/255.; for (i=0;i<256;i++){ - light=fd_pow((float_double)i*inv_255,gamma); + light=fd_pow((float)i*inv_255,gamma); /* Long live the Nipkow Disk */ light0=65535*light; if (light0<0) light0=0; @@ -676,13 +676,13 @@ static void make_8_table(int *table, double gamma) /* dump_t2c means memory organization defined in comment for * red_table on the top of dither.c */ /* dump_t2c is taken into account only if t2c is defined. */ -static void make_16_table(int *table, int bits, int pos, float_double gamma, int dump_t2c, +static void make_16_table(int *table, int bits, int pos, float gamma, int dump_t2c, int bigendian) { int j,light_val,grades=(1<<bits)-1,grade; - float_double voltage; - float_double rev_gamma=1/gamma; - const float_double inv_65535=(float_double)(1/65535.); + float voltage; + float rev_gamma=1/gamma; + const float inv_65535=(float)(1/65535.); int last_grade, last_content; uttime start_time = get_time(); int sample_state = 0; @@ -722,13 +722,13 @@ static void make_16_table(int *table, int bits, int pos, float_double gamma, int * to said photon flux level */ - grade=(int)(voltage*grades+(float_double)0.5); + grade=(int)(voltage*grades+(float)0.5); if (grade==last_grade){ table[j]=last_content; continue; } last_grade=grade; - voltage=(float_double)grade/grades; + voltage=(float)grade/grades; /* Find nearest voltage to this voltage. Finding nearest voltage, not * nearest photon flux ensures the dithered pixels will be perceived to be * near. The voltage input into the monitor was intentionally chosen by @@ -738,7 +738,7 @@ static void make_16_table(int *table, int bits, int pos, float_double gamma, int * kool ;-) (and is kool) */ - light_val=(int)(fd_pow(voltage,gamma)*65535+(float_double)0.5); + light_val=(int)(fd_pow(voltage,gamma)*65535+(float)0.5); /* Find out what photon flux this index represents */ if (light_val<0) light_val=0; @@ -765,19 +765,19 @@ static void make_16_table(int *table, int bits, int pos, float_double gamma, int static void make_red_table(int bits, int pos, int dump_t2c, int be) { red_table = xrealloc(red_table, 65536 * sizeof(*red_table)); - make_16_table(red_table,bits,pos,(float_double)display_red_gamma,dump_t2c, be); + make_16_table(red_table,bits,pos,(float)display_red_gamma,dump_t2c, be); } static void make_green_table(int bits, int pos, int dump_t2c, int be) { green_table = xrealloc(green_table, 65536 * sizeof(*green_table)); - make_16_table(green_table,bits,pos,(float_double)display_green_gamma,dump_t2c, be); + make_16_table(green_table,bits,pos,(float)display_green_gamma,dump_t2c, be); } static void make_blue_table(int bits, int pos,int dump_t2c, int be) { blue_table = xrealloc(blue_table, 65536 * sizeof(*blue_table)); - make_16_table(blue_table,bits,pos,(float_double)display_blue_gamma, dump_t2c, be); + make_16_table(blue_table,bits,pos,(float)display_blue_gamma, dump_t2c, be); } void dither(unsigned short *in, struct bitmap *out)