a macro idiom used here triggers the GCC 6.4 ident checker. work around it.
This commit is contained in:
parent
604bbcaa40
commit
d117f9035c
|
@ -430,7 +430,7 @@ extern int stbi_gif_info_from_file (FILE *f, int *x, int
|
|||
#endif
|
||||
#ifdef _KERNEL
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: stb_image.c,v 1.8 2016/01/21 17:17:53 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: stb_image.c,v 1.9 2018/02/04 09:18:44 mrg Exp $");
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
|
@ -1000,18 +1000,30 @@ static unsigned char *convert_format(unsigned char *data, int img_n, int req_com
|
|||
// convert source image with img_n components to one with req_comp components;
|
||||
// avoid switch per pixel, so use switch per scanline and massive macros
|
||||
switch (COMBO(img_n, req_comp)) {
|
||||
CASE(1,2) dest[0]=src[0], dest[1]=255; break;
|
||||
CASE(1,3) dest[0]=dest[1]=dest[2]=src[0]; break;
|
||||
CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255; break;
|
||||
CASE(2,1) dest[0]=src[0]; break;
|
||||
CASE(2,3) dest[0]=dest[1]=dest[2]=src[0]; break;
|
||||
CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; break;
|
||||
CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255; break;
|
||||
CASE(3,1) dest[0]=compute_y(src[0],src[1],src[2]); break;
|
||||
CASE(3,2) dest[0]=compute_y(src[0],src[1],src[2]), dest[1] = 255; break;
|
||||
CASE(4,1) dest[0]=compute_y(src[0],src[1],src[2]); break;
|
||||
CASE(4,2) dest[0]=compute_y(src[0],src[1],src[2]), dest[1] = src[3]; break;
|
||||
CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; break;
|
||||
CASE(1,2) dest[0]=src[0], dest[1]=255;
|
||||
break;
|
||||
CASE(1,3) dest[0]=dest[1]=dest[2]=src[0];
|
||||
break;
|
||||
CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255;
|
||||
break;
|
||||
CASE(2,1) dest[0]=src[0];
|
||||
break;
|
||||
CASE(2,3) dest[0]=dest[1]=dest[2]=src[0];
|
||||
break;
|
||||
CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1];
|
||||
break;
|
||||
CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255;
|
||||
break;
|
||||
CASE(3,1) dest[0]=compute_y(src[0],src[1],src[2]);
|
||||
break;
|
||||
CASE(3,2) dest[0]=compute_y(src[0],src[1],src[2]), dest[1] = 255;
|
||||
break;
|
||||
CASE(4,1) dest[0]=compute_y(src[0],src[1],src[2]);
|
||||
break;
|
||||
CASE(4,2) dest[0]=compute_y(src[0],src[1],src[2]), dest[1] = src[3];
|
||||
break;
|
||||
CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2];
|
||||
break;
|
||||
default: assert(0);
|
||||
}
|
||||
#undef CASE
|
||||
|
@ -1279,7 +1291,7 @@ __forceinline static int extend_receive(jpeg *j, int n)
|
|||
// predict well. I tried to table accelerate it but failed.
|
||||
// maybe it's compiling as a conditional move?
|
||||
if (k < m)
|
||||
return (-1 << n) + k + 1;
|
||||
return (UINT_MAX << n) + k + 1;
|
||||
else
|
||||
return k;
|
||||
}
|
||||
|
@ -2696,13 +2708,20 @@ static int create_png_image_raw(png *a, uint8 *raw, uint32 raw_len, int out_n, u
|
|||
for (i=x-1; i >= 1; --i, raw+=img_n,cur+=img_n,prior+=img_n) \
|
||||
for (k=0; k < img_n; ++k)
|
||||
switch (filter) {
|
||||
CASE(F_none) cur[k] = raw[k]; break;
|
||||
CASE(F_sub) cur[k] = raw[k] + cur[k-img_n]; break;
|
||||
CASE(F_up) cur[k] = raw[k] + prior[k]; break;
|
||||
CASE(F_avg) cur[k] = raw[k] + ((prior[k] + cur[k-img_n])>>1); break;
|
||||
CASE(F_paeth) cur[k] = (uint8) (raw[k] + paeth(cur[k-img_n],prior[k],prior[k-img_n])); break;
|
||||
CASE(F_avg_first) cur[k] = raw[k] + (cur[k-img_n] >> 1); break;
|
||||
CASE(F_paeth_first) cur[k] = (uint8) (raw[k] + paeth(cur[k-img_n],0,0)); break;
|
||||
CASE(F_none) cur[k] = raw[k];
|
||||
break;
|
||||
CASE(F_sub) cur[k] = raw[k] + cur[k-img_n];
|
||||
break;
|
||||
CASE(F_up) cur[k] = raw[k] + prior[k];
|
||||
break;
|
||||
CASE(F_avg) cur[k] = raw[k] + ((prior[k] + cur[k-img_n])>>1);
|
||||
break;
|
||||
CASE(F_paeth) cur[k] = (uint8) (raw[k] + paeth(cur[k-img_n],prior[k],prior[k-img_n]));
|
||||
break;
|
||||
CASE(F_avg_first) cur[k] = raw[k] + (cur[k-img_n] >> 1);
|
||||
break;
|
||||
CASE(F_paeth_first) cur[k] = (uint8) (raw[k] + paeth(cur[k-img_n],0,0));
|
||||
break;
|
||||
}
|
||||
#undef CASE
|
||||
} else {
|
||||
|
@ -2712,13 +2731,20 @@ static int create_png_image_raw(png *a, uint8 *raw, uint32 raw_len, int out_n, u
|
|||
for (i=x-1; i >= 1; --i, cur[img_n]=255,raw+=img_n,cur+=out_n,prior+=out_n) \
|
||||
for (k=0; k < img_n; ++k)
|
||||
switch (filter) {
|
||||
CASE(F_none) cur[k] = raw[k]; break;
|
||||
CASE(F_sub) cur[k] = raw[k] + cur[k-out_n]; break;
|
||||
CASE(F_up) cur[k] = raw[k] + prior[k]; break;
|
||||
CASE(F_avg) cur[k] = raw[k] + ((prior[k] + cur[k-out_n])>>1); break;
|
||||
CASE(F_paeth) cur[k] = (uint8) (raw[k] + paeth(cur[k-out_n],prior[k],prior[k-out_n])); break;
|
||||
CASE(F_avg_first) cur[k] = raw[k] + (cur[k-out_n] >> 1); break;
|
||||
CASE(F_paeth_first) cur[k] = (uint8) (raw[k] + paeth(cur[k-out_n],0,0)); break;
|
||||
CASE(F_none) cur[k] = raw[k];
|
||||
break;
|
||||
CASE(F_sub) cur[k] = raw[k] + cur[k-out_n];
|
||||
break;
|
||||
CASE(F_up) cur[k] = raw[k] + prior[k];
|
||||
break;
|
||||
CASE(F_avg) cur[k] = raw[k] + ((prior[k] + cur[k-out_n])>>1);
|
||||
break;
|
||||
CASE(F_paeth) cur[k] = (uint8) (raw[k] + paeth(cur[k-out_n],prior[k],prior[k-out_n]));
|
||||
break;
|
||||
CASE(F_avg_first) cur[k] = raw[k] + (cur[k-out_n] >> 1);
|
||||
break;
|
||||
CASE(F_paeth_first) cur[k] = (uint8) (raw[k] + paeth(cur[k-out_n],0,0));
|
||||
break;
|
||||
}
|
||||
#undef CASE
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue