variant with edge length = 16
This commit is contained in:
parent
1615b45d78
commit
bf9048443b
15
y16t.c
15
y16t.c
|
@ -7,11 +7,11 @@ static __attribute__((pure))
|
|||
uint8_t y16t_loc2blk_coords(
|
||||
const y16t_location_t loc, const uint32_t offset
|
||||
) {
|
||||
const uint32_t byteoffset = offset / 4;
|
||||
const uint8_t shiftval = 2 * (3 - offset % 4);
|
||||
const uint8_t xres = (loc.x[byteoffset] >> shiftval) & 3;
|
||||
const uint8_t yres = (loc.y[byteoffset] >> shiftval) & 3;
|
||||
return (xres << 2) | yres;
|
||||
const uint32_t byteoffset = offset >> 1;
|
||||
const uint8_t shiftval = 4 * (1 - offset & 1);
|
||||
const uint8_t xres = (loc.x[byteoffset] >> shiftval) & 15;
|
||||
const uint8_t yres = (loc.y[byteoffset] >> shiftval) & 15;
|
||||
return (xres << 4) | yres;
|
||||
}
|
||||
|
||||
void y16t_lookup(
|
||||
|
@ -20,13 +20,12 @@ void y16t_lookup(
|
|||
const size_t datalen,
|
||||
const y16t_location_t * loc
|
||||
) {
|
||||
// data_endblk is set to the first byte which doesn't constitute a full block
|
||||
const size_t datalen_blks = datalen / 16;
|
||||
const size_t datalen_blks = datalen >> 8;
|
||||
const y16t_location_t loc_ = *loc;
|
||||
size_t datoffset = ret->datoffset;
|
||||
|
||||
for ( ; /* bounds checks */ ret->inpoffset < loc_.xylen && datoffset < datalen_blks; ) {
|
||||
datoffset = ntohl(data[16 * datoffset + y16t_loc2blk_coords(loc_, ret->inpoffset)]);
|
||||
datoffset = ntohl(data[(datoffset << 8) | y16t_loc2blk_coords(loc_, ret->inpoffset)]);
|
||||
ret->inpoffset += 1;
|
||||
if(0 == datoffset) {
|
||||
// NULL pointer
|
||||
|
|
Loading…
Reference in a new issue