Slightly optimize thumbnail loading
Now it translates to just x86 bswap and ror.
This commit is contained in:
parent
37adaac965
commit
6f86911df6
10
fastiv-io.c
10
fastiv-io.c
@ -710,7 +710,7 @@ read_spng_thumbnail(
|
||||
ihdr.color_type == SPNG_COLOR_TYPE_TRUECOLOR_ALPHA ||
|
||||
!spng_get_trns(ctx, &trns)) {
|
||||
for (size_t i = size / sizeof *output; i--; ) {
|
||||
uint8_t *unit = (uint8_t *) &data[i],
|
||||
const uint8_t *unit = (const uint8_t *) &data[i],
|
||||
a = unit[3],
|
||||
b = unit[2] * a / 255,
|
||||
g = unit[1] * a / 255,
|
||||
@ -719,12 +719,8 @@ read_spng_thumbnail(
|
||||
}
|
||||
} else {
|
||||
for (size_t i = size / sizeof *output; i--; ) {
|
||||
uint8_t *unit = (uint8_t *) &data[i],
|
||||
a = unit[3],
|
||||
b = unit[2],
|
||||
g = unit[1],
|
||||
r = unit[0];
|
||||
output[i] = a << 24 | r << 16 | g << 8 | b;
|
||||
uint32_t x = g_ntohl(data[i]);
|
||||
output[i] = x << 24 | x >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user