mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
std/webp: re-implement 8-bit color indexing
This commit is contained in:
1 parent
8fe987e0b2
commit
c6aebf819f
2 files changed
+32
-2
No files matched your search
@@ -71438,6 +71438,26 @@ wuffs_webp__decoder__apply_transform_color_indexing(
|
||||
|
||||
v_tile_size_log2 = ((uint32_t)(self->private_impl.f_transform_tile_size_log2[3u]));
|
||||
if (v_tile_size_log2 == 0u) {
|
||||
{
|
||||
wuffs_base__slice_u8 i_slice_dst = a_pix;
|
||||
v_dst.ptr = i_slice_dst.ptr;
|
||||
v_dst.len = 4;
|
||||
const uint8_t* i_end0_dst = wuffs_private_impl__ptr_u8_plus_len(v_dst.ptr, (((i_slice_dst.len - (size_t)(v_dst.ptr - i_slice_dst.ptr)) / 4) * 4));
|
||||
while (v_dst.ptr < i_end0_dst) {
|
||||
v_p = (((uint32_t)(v_dst.ptr[1u])) * 4u);
|
||||
v_p0 = self->private_data.f_palette[(v_p + 0u)];
|
||||
v_p1 = self->private_data.f_palette[(v_p + 1u)];
|
||||
v_p2 = self->private_data.f_palette[(v_p + 2u)];
|
||||
v_p3 = self->private_data.f_palette[(v_p + 3u)];
|
||||
v_dst.ptr[0u] = v_p0;
|
||||
v_dst.ptr[1u] = v_p1;
|
||||
v_dst.ptr[2u] = v_p2;
|
||||
v_dst.ptr[3u] = v_p3;
|
||||
v_dst.ptr += 4;
|
||||
}
|
||||
v_dst.len = 0;
|
||||
}
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
v_bits_per_pixel = (((uint32_t)(8u)) >> v_tile_size_log2);
|
||||
v_x_mask = ((((uint32_t)(1u)) << v_tile_size_log2) - 1u);
|
||||
|
||||
@@ -379,8 +379,18 @@ pri func decoder.apply_transform_color_indexing!(pix: slice base.u8) {
|
||||
|
||||
tile_size_log2 = this.transform_tile_size_log2[3] as base.u32
|
||||
if tile_size_log2 == 0 {
|
||||
// TODO: the code below is correct, but we could possibly simplify the
|
||||
// case where the src and dst pixel counts are 1:1.
|
||||
iterate (dst = args.pix)(length: 4, advance: 4, unroll: 1) {
|
||||
p = (dst[1] as base.u32) * 4
|
||||
p0 = this.palette[p + 0]
|
||||
p1 = this.palette[p + 1]
|
||||
p2 = this.palette[p + 2]
|
||||
p3 = this.palette[p + 3]
|
||||
dst[0] = p0
|
||||
dst[1] = p1
|
||||
dst[2] = p2
|
||||
dst[3] = p3
|
||||
}
|
||||
return nothing
|
||||
}
|
||||
|
||||
bits_per_pixel = (8 as base.u32) >> tile_size_log2
|
||||
|
||||
Reference in new issue
Block a user