links

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

Commit: 14946c3e843a7a3ae1c1b3bc7f7e5511bb164fa6
Parent: aced39fc30b271f5777a4ccd3b0898d3d7aec2cc
Author: opask
Date:   Thu, 19 Jul 2018 05:54:51 -0600

sed s:my_restrict:restrict:, update TODO

Diffstat:
MTODO | 3+++
Mdip.c | 60++++++++++++++++++++++++++++++------------------------------
Mdither.c | 46+++++++++++++++++++++++-----------------------
Mlinks.h | 40++++++++++++++++++++--------------------
4 files changed, 76 insertions(+), 73 deletions(-)

diff --git a/TODO b/TODO @@ -32,3 +32,6 @@ - get rid of _BSD_SOURCE macro - completely if possible - _POSIX_C_SOURCE or _XOPEN_SOURCE aren't as bad + +- check if restrict is being used correctly + - its likely not even necessary diff --git a/dip.c b/dip.c @@ -116,7 +116,7 @@ typedef double scale_t; * black or 255 is black doesn't matter. */ -static void add_col_gray(unsigned *my_restrict col_buf, unsigned char *my_restrict ptr, int +static void add_col_gray(unsigned *restrict col_buf, unsigned char *restrict ptr, int line_skip, int n, unsigned weight) { for (;n;n--){ @@ -127,7 +127,7 @@ static void add_col_gray(unsigned *my_restrict col_buf, unsigned char *my_restri } /* We assume unsigned short holds at least 16 bits. */ -static void add_row_gray(unsigned *my_restrict row_buf, unsigned char *my_restrict ptr, int n, +static void add_row_gray(unsigned *restrict row_buf, unsigned char *restrict ptr, int n, unsigned weight) { for (;n;n--){ @@ -139,7 +139,7 @@ static void add_row_gray(unsigned *my_restrict row_buf, unsigned char *my_restri /* line_skip is in pixels. The column contains the whole pixels (R G B) * We assume unsigned short holds at least 16 bits. */ -static void add_col_color(scale_t *my_restrict col_buf, unsigned short *my_restrict ptr, +static void add_col_color(scale_t *restrict col_buf, unsigned short *restrict ptr, int line_skip, int n, ulonglong weight) { if (!weight) return; @@ -157,7 +157,7 @@ static void add_col_color(scale_t *my_restrict col_buf, unsigned short *my_restr /* n is in pixels. pixel is 3 unsigned shorts in series */ /* We assume unsigned short holds at least 16 bits. */ -static void add_row_color(scale_t *my_restrict row_buf, unsigned short *my_restrict ptr, +static void add_row_color(scale_t *restrict row_buf, unsigned short *restrict ptr, int n, ulonglong weight) { if (!weight) return; @@ -174,7 +174,7 @@ static void add_row_color(scale_t *my_restrict row_buf, unsigned short *my_restr } /* We assume unsigned holds at least 32 bits */ -static void emit_and_bias_col_gray(unsigned *my_restrict col_buf, unsigned char *my_restrict out, +static void emit_and_bias_col_gray(unsigned *restrict col_buf, unsigned char *restrict out, int line_skip, int n, unsigned weight) { unsigned half=weight>>1; @@ -187,7 +187,7 @@ static void emit_and_bias_col_gray(unsigned *my_restrict col_buf, unsigned char } /* We assume unsigned holds at least 32 bits */ -static void emit_and_bias_row_gray(unsigned *my_restrict row_buf, unsigned char *my_restrict out, +static void emit_and_bias_row_gray(unsigned *restrict row_buf, unsigned char *restrict out, int n, unsigned weight) { unsigned half=weight>>1; @@ -199,13 +199,13 @@ static void emit_and_bias_row_gray(unsigned *my_restrict row_buf, unsigned char } /* We assume unsigned holds at least 32 bits */ -static void bias_buf_gray(unsigned *my_restrict col_buf, int n, unsigned half) +static void bias_buf_gray(unsigned *restrict col_buf, int n, unsigned half) { for (;n;n--) *col_buf++=half; } /* We assume unsigned holds at least 32 bits */ -static void bias_buf_color(scale_t *my_restrict col_buf, int n, scale_t half) +static void bias_buf_color(scale_t *restrict col_buf, int n, scale_t half) { for (;n;n--){ col_buf[0]=half; @@ -221,8 +221,8 @@ static void bias_buf_color(scale_t *my_restrict col_buf, int n, scale_t half) /* line skip is in pixels. Pixel is 3*unsigned short */ /* We assume unsigned holds at least 32 bits */ /* We assume unsigned short holds at least 16 bits. */ -static void emit_and_bias_col_color(scale_t *my_restrict col_buf, - unsigned short *my_restrict out, int line_skip, int n, unsigned weight) +static void emit_and_bias_col_color(scale_t *restrict col_buf, + unsigned short *restrict out, int line_skip, int n, unsigned weight) { scale_t half=(scale_t)weight / 2; scale_t inv_weight = (scale_t)1 / weight; @@ -246,8 +246,8 @@ static void emit_and_bias_col_color(scale_t *my_restrict col_buf, /* n is in pixels. pixel is 3 unsigned shorts in series. */ /* We assume unsigned holds at least 32 bits */ /* We assume unsigned short holds at least 16 bits. */ -static void emit_and_bias_row_color(scale_t *my_restrict row_buf, - unsigned short *my_restrict out, int n, unsigned weight) +static void emit_and_bias_row_color(scale_t *restrict row_buf, + unsigned short *restrict out, int n, unsigned weight) { scale_t half=(scale_t)weight / 2; scale_t inv_weight = (scale_t)1 / weight; @@ -954,7 +954,7 @@ void scale_color(unsigned short *in, int ix, int iy, unsigned short **out, /* Fills a block with given color. length is number of pixels. pixel is a * tribyte. 24 bits per pixel. */ -void mix_one_color_24(unsigned char *my_restrict dest, int length, +void mix_one_color_24(unsigned char *restrict dest, int length, unsigned char r, unsigned char g, unsigned char b) { for (;length;length--){ @@ -969,7 +969,7 @@ void mix_one_color_24(unsigned char *my_restrict dest, int length, * tribyte. 48 bits per pixel. * We assume unsigned short holds at least 16 bits. */ -void mix_one_color_48(unsigned short *my_restrict dest, int length, +void mix_one_color_48(unsigned short *restrict dest, int length, unsigned short r, unsigned short g, unsigned short b) { for (;length;length--){ @@ -987,7 +987,7 @@ void mix_one_color_48(unsigned short *my_restrict dest, int length, * alpha is 8-bit, rgb are all 16-bit * We assume unsigned short holds at least 16 bits. */ -static void mix_two_colors(unsigned short *my_restrict dest, unsigned char *my_restrict alpha, +static void mix_two_colors(unsigned short *restrict dest, unsigned char *restrict alpha, int length ,unsigned short r0, unsigned short g0, unsigned short b0, unsigned short r255, unsigned short g255, unsigned short b255) { @@ -1016,8 +1016,8 @@ static void mix_two_colors(unsigned short *my_restrict dest, unsigned char *my_r } /* We assume unsigned short holds at least 16 bits. */ -void agx_and_uc_32_to_48_table(unsigned short *my_restrict dest, - const unsigned char *my_restrict src, int lenght, unsigned short *my_restrict table, +void agx_and_uc_32_to_48_table(unsigned short *restrict dest, + const unsigned char *restrict src, int lenght, unsigned short *restrict table, unsigned short rb, unsigned short gb, unsigned short bb) { unsigned char alpha, calpha; @@ -1056,8 +1056,8 @@ void agx_and_uc_32_to_48_table(unsigned short *my_restrict dest, * in linear monitor output photon space */ /* We assume unsigned short holds at least 16 bits. */ -void agx_and_uc_32_to_48(unsigned short *my_restrict dest, - const unsigned char *my_restrict src, int lenght, float red_gamma, +void agx_and_uc_32_to_48(unsigned short *restrict dest, + const unsigned char *restrict src, int lenght, float red_gamma, float green_gamma, float blue_gamma, unsigned short rb, unsigned short gb, unsigned short bb) { @@ -1110,8 +1110,8 @@ void agx_and_uc_32_to_48(unsigned short *my_restrict dest, * in linear monitor output photon space. alpha 255 means full image no background. */ /* We assume unsigned short holds at least 16 bits. */ -void agx_and_uc_64_to_48(unsigned short *my_restrict dest, - const unsigned short *my_restrict src, int lenght, float red_gamma, +void agx_and_uc_64_to_48(unsigned short *restrict dest, + const unsigned short *restrict src, int lenght, float red_gamma, float green_gamma, float blue_gamma, unsigned short rb, unsigned short gb, unsigned short bb) { @@ -1164,8 +1164,8 @@ void agx_and_uc_64_to_48(unsigned short *my_restrict dest, * dest. src and dest may be identical and it will work. rb, gb, bb are 0-65535 * in linear monitor output photon space. alpha 255 means full image no background. * We assume unsigned short holds at least 16 bits. */ -void agx_and_uc_64_to_48_table(unsigned short *my_restrict dest, - const unsigned short *my_restrict src, int lenght, unsigned short *my_restrict gamma_table, +void agx_and_uc_64_to_48_table(unsigned short *restrict dest, + const unsigned short *restrict src, int lenght, unsigned short *restrict gamma_table, unsigned short rb, unsigned short gb, unsigned short bb) { unsigned short alpha, calpha; @@ -1202,8 +1202,8 @@ void agx_and_uc_64_to_48_table(unsigned short *my_restrict dest, * number of triplets. output is input powered to the given gamma, passed into * dest. src and dest may be identical and it will work. * We assume unsigned short holds at least 16 bits. */ -void agx_48_to_48(unsigned short *my_restrict dest, - const unsigned short *my_restrict src, int lenght, float red_gamma, +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; @@ -1233,8 +1233,8 @@ void agx_48_to_48(unsigned short *my_restrict dest, * number of triples. output is input powered to the given gamma, passed into * dest. src and dest may be identical and it will work. * We assume unsigned short holds at least 16 bits. */ -void agx_48_to_48_table(unsigned short *my_restrict dest, - const unsigned short *my_restrict src, int lenght, unsigned short *my_restrict table) +void agx_48_to_48_table(unsigned short *restrict dest, + const unsigned short *restrict src, int lenght, unsigned short *restrict table) { for (;lenght;lenght--,src+=3,dest+=3) { @@ -1248,7 +1248,7 @@ void agx_48_to_48_table(unsigned short *my_restrict dest, * number of triples. output is input powered to the given gamma, passed into * dest. src and dest may be identical and it will work. * We assume unsigned short holds at least 16 bits. */ -void agx_24_to_48(unsigned short *my_restrict dest, const unsigned char *my_restrict src, int +void agx_24_to_48(unsigned short *restrict dest, const unsigned char *restrict src, int lenght, float red_gamma, float green_gamma, float blue_gamma) { @@ -1343,8 +1343,8 @@ void make_gamma_table(struct cached_image *cimg) } /* We assume unsigned short holds at least 16 bits. */ -void agx_24_to_48_table(unsigned short *my_restrict dest, const unsigned char *my_restrict src, int - lenght, unsigned short *my_restrict table) +void agx_24_to_48_table(unsigned short *restrict dest, const unsigned char *restrict src, int + lenght, unsigned short *restrict table) { for (;lenght;lenght--,src+=3,dest+=3) { diff --git a/dither.c b/dither.c @@ -86,26 +86,26 @@ static unsigned short round_blue_table[256]; * voltage appropriate to given sRGB coordinate. */ -void (*round_fn)(unsigned short *my_restrict in, struct bitmap *out); +void (*round_fn)(unsigned short *restrict in, struct bitmap *out); /* When you finish the stuff with dither_start, dither_restart, just do "if (dregs) mem_free(dregs);" */ -static void (*dither_fn_internal)(unsigned short *my_restrict in, struct bitmap *out, int *dregs); +static void (*dither_fn_internal)(unsigned short *restrict in, struct bitmap *out, int *dregs); /* prototypes */ -static void dither_1byte(unsigned short *my_restrict, struct bitmap *, int *); /* DITHER_TEMPLATE */ -static void round_1byte(unsigned short *my_restrict, struct bitmap *); /* ROUND_TEMPLATE */ -static void dither_2byte(unsigned short *my_restrict, struct bitmap *, int *); /* DITHER_TEMPLATE */ -static void round_2byte(unsigned short *my_restrict, struct bitmap *); /* ROUND_TEMPLATE */ -static void dither_195(unsigned short *my_restrict, struct bitmap *, int *); /* DITHER_TEMPLATE */ -static void round_195(unsigned short *my_restrict, struct bitmap *); /* ROUND_TEMPLATE */ -static void dither_451(unsigned short *my_restrict, struct bitmap *, int *); /* DITHER_TEMPLATE */ -static void round_451(unsigned short *my_restrict, struct bitmap *); /* ROUND_TEMPLATE */ -static void dither_196(unsigned short *my_restrict, struct bitmap *, int *); /* DITHER_TEMPLATE */ -static void round_196(unsigned short *my_restrict, struct bitmap *); /* ROUND_TEMPLATE */ -static void dither_452(unsigned short *my_restrict, struct bitmap *, int *); /* DITHER_TEMPLATE */ -static void round_452(unsigned short *my_restrict, struct bitmap *); /* ROUND_TEMPLATE */ -static void dither_708(unsigned short *my_restrict, struct bitmap *, int *); /* DITHER_TEMPLATE */ -static void round_708(unsigned short *my_restrict, struct bitmap *); /* ROUND_TEMPLATE */ +static void dither_1byte(unsigned short *restrict, struct bitmap *, int *); /* DITHER_TEMPLATE */ +static void round_1byte(unsigned short *restrict, struct bitmap *); /* ROUND_TEMPLATE */ +static void dither_2byte(unsigned short *restrict, struct bitmap *, int *); /* DITHER_TEMPLATE */ +static void round_2byte(unsigned short *restrict, struct bitmap *); /* ROUND_TEMPLATE */ +static void dither_195(unsigned short *restrict, struct bitmap *, int *); /* DITHER_TEMPLATE */ +static void round_195(unsigned short *restrict, struct bitmap *); /* ROUND_TEMPLATE */ +static void dither_451(unsigned short *restrict, struct bitmap *, int *); /* DITHER_TEMPLATE */ +static void round_451(unsigned short *restrict, struct bitmap *); /* ROUND_TEMPLATE */ +static void dither_196(unsigned short *restrict, struct bitmap *, int *); /* DITHER_TEMPLATE */ +static void round_196(unsigned short *restrict, struct bitmap *); /* ROUND_TEMPLATE */ +static void dither_452(unsigned short *restrict, struct bitmap *, int *); /* DITHER_TEMPLATE */ +static void round_452(unsigned short *restrict, struct bitmap *); /* ROUND_TEMPLATE */ +static void dither_708(unsigned short *restrict, struct bitmap *, int *); /* DITHER_TEMPLATE */ +static void round_708(unsigned short *restrict, struct bitmap *); /* ROUND_TEMPLATE */ static long color_332(int); static long color_121(int); static long color_pass_rgb(int); @@ -224,11 +224,11 @@ int slow_fpu = -1; bptr+=3; #define DITHER_TEMPLATE(template_name) \ - static void template_name(unsigned short *my_restrict in, struct bitmap *out, int *dregs)\ + static void template_name(unsigned short *restrict in, struct bitmap *out, int *dregs)\ {\ int r,g,b,o,rt,gt,bt,y,x;\ - unsigned char *my_restrict outp=out->data;\ - int *my_restrict bptr;\ + unsigned char *restrict outp=out->data;\ + int *restrict bptr;\ int skip=out->skip-SKIP_CODE;\ \ o=0;o=o; /*warning go away */\ @@ -259,10 +259,10 @@ int slow_fpu = -1; } #define ROUND_TEMPLATE(template_name)\ - static void template_name(unsigned short *my_restrict in, struct bitmap *out)\ + static void template_name(unsigned short *restrict in, struct bitmap *out)\ {\ int rt,gt,bt,o,x,y;\ - unsigned char *my_restrict outp=out->data;\ + unsigned char *restrict outp=out->data;\ int skip=out->skip-SKIP_CODE;\ \ o=0;o=o; /*warning go away */\ @@ -985,8 +985,8 @@ pixel memory organisation %d",depth); * Output is linear 48-bit value (in photons) that has corresponding * voltage nearest to the voltage that would be procduced ideally * by the input value. */ -void round_color_sRGB_to_48(unsigned short *my_restrict red, unsigned short *my_restrict green, - unsigned short *my_restrict blue, int rgb) +void round_color_sRGB_to_48(unsigned short *restrict red, unsigned short *restrict green, + unsigned short *restrict blue, int rgb) { *red=round_red_table[(rgb>>16)&255]; *green=round_green_table[(rgb>>8)&255]; diff --git a/links.h b/links.h @@ -1600,34 +1600,34 @@ int g_char_width(struct style *style, unsigned ch); unsigned short ags_8_to_16(unsigned char input, float gamma); unsigned char ags_16_to_8(unsigned short input, float gamma); unsigned short ags_16_to_16(unsigned short input, float gamma); -void agx_24_to_48(unsigned short *my_restrict dest, const unsigned char *my_restrict src, int +void agx_24_to_48(unsigned short *restrict dest, const unsigned char *restrict src, int lenght, float red_gamma, float green_gamma, float blue_gamma); void make_gamma_table(struct cached_image *cimg); -void agx_24_to_48_table(unsigned short *my_restrict dest, const unsigned char *my_restrict src - ,int lenght, unsigned short *my_restrict gamma_table); -void agx_48_to_48_table(unsigned short *my_restrict dest, - const unsigned short *my_restrict src, int lenght, unsigned short *my_restrict table); -void agx_48_to_48(unsigned short *my_restrict dest, - const unsigned short *my_restrict src, int lenght, float red_gamma, +void agx_24_to_48_table(unsigned short *restrict dest, const unsigned char *restrict src + ,int lenght, unsigned short *restrict gamma_table); +void agx_48_to_48_table(unsigned short *restrict dest, + const unsigned short *restrict src, int lenght, unsigned short *restrict table); +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); -void agx_and_uc_32_to_48_table(unsigned short *my_restrict dest, - const unsigned char *my_restrict src, int lenght, unsigned short *my_restrict table, +void agx_and_uc_32_to_48_table(unsigned short *restrict dest, + const unsigned char *restrict src, int lenght, unsigned short *restrict table, unsigned short rb, unsigned short gb, unsigned short bb); -void agx_and_uc_32_to_48(unsigned short *my_restrict dest, - const unsigned char *my_restrict src, int lenght, float red_gamma, +void agx_and_uc_32_to_48(unsigned short *restrict dest, + const unsigned char *restrict src, int lenght, float red_gamma, float green_gamma, float blue_gamma, unsigned short rb, unsigned short gb, unsigned short bb); -void agx_and_uc_64_to_48_table(unsigned short *my_restrict dest, - const unsigned short *my_restrict src, int lenght, unsigned short *my_restrict gamma_table, +void agx_and_uc_64_to_48_table(unsigned short *restrict dest, + const unsigned short *restrict src, int lenght, unsigned short *restrict gamma_table, unsigned short rb, unsigned short gb, unsigned short bb); -void agx_and_uc_64_to_48(unsigned short *my_restrict dest, - const unsigned short *my_restrict src, int lenght, float red_gamma, +void agx_and_uc_64_to_48(unsigned short *restrict dest, + const unsigned short *restrict src, int lenght, float red_gamma, float green_gamma, float blue_gamma, unsigned short rb, unsigned short gb, unsigned short bb); -void mix_one_color_48(unsigned short *my_restrict dest, int length, +void mix_one_color_48(unsigned short *restrict dest, int length, unsigned short r, unsigned short g, unsigned short b); -void mix_one_color_24(unsigned char *my_restrict dest, int length, +void mix_one_color_24(unsigned char *restrict dest, int length, unsigned char r, unsigned char g, unsigned char b); void scale_color(unsigned short *in, int ix, int iy, unsigned short **out, int ox, int oy); @@ -1684,12 +1684,12 @@ extern int slow_fpu; /* -1 --- don't know, 0 --- no, 1 --- yes */ void dither (unsigned short *in, struct bitmap *out); int *dither_start(unsigned short *in, struct bitmap *out); void dither_restart(unsigned short *in, struct bitmap *out, int *dregs); -extern void (*round_fn)(unsigned short *my_restrict in, struct bitmap *out); +extern void (*round_fn)(unsigned short *restrict in, struct bitmap *out); long (*get_color_fn(int depth))(int rgb); void init_dither(int depth); -void round_color_sRGB_to_48(unsigned short *my_restrict red, unsigned short *my_restrict green, - unsigned short *my_restrict blue, int rgb); +void round_color_sRGB_to_48(unsigned short *restrict red, unsigned short *restrict green, + unsigned short *restrict blue, int rgb); void q_palette(unsigned size, unsigned color, unsigned scale, unsigned rgb[3]); double rgb_distance(int r1, int g1, int b1, int r2, int g2, int b2);