Add palette arguments to the pixel swizzler

This commit is contained in:
Nigel Tao committed 2018-12-08 13:58:52 +11:00
1 parent 6c9dca47ee
commit 90193cb6e2
6 files changed
+167 -33

No files matched your search

+12 -3
View File
@@ -113,6 +113,8 @@ pub struct decoder?(
// palettes[0] and palettes[1] are the Global and Local Color Table.
palettes array[2] array[4 * 256] base.u8,
// dst_palette is the swizzled color table.
dst_palette array[4 * 256] base.u8,
swizzler base.pixel_swizzler,
util base.utility,
@@ -583,11 +585,18 @@ pri func decoder.decode_id_part1!??(dst ptr base.pixel_buffer, src base.io_reade
this.palettes[1][(4 * (this.gc_transparent_index as base.u32)) + 3] = 0x00
}
args.dst.palette().copy_from_slice!(s:this.palettes[this.which_palette][:])
var dst_palette slice base.u8 = args.dst.palette()
if dst_palette.length() == 0 {
dst_palette = this.dst_palette[:]
}
// TODO: a Wuffs (not just C) name for the
// WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_NONPREMUL magic pixfmt constant.
this.swizzler.initialize!(dst_pixfmt:args.dst.pixel_format(), src_pixfmt:0x42040008)
this.swizzler.initialize!(
dst_pixfmt:args.dst.pixel_format(),
dst_palette:dst_palette,
src_pixfmt:0x42040008,
src_palette:this.palettes[this.which_palette][:])
// Other GIF implementations accept GIF files that aren't completely spec
// compliant. For example, the test/data/gifplayer-muybridge.gif file
@@ -701,7 +710,7 @@ pri func decoder.copy_to_image_buffer!?(pb ptr base.pixel_buffer) {
} else {
dst = dst[this.dst_x as base.u64:]
}
var n64 base.u64 = this.swizzler.swizzle_packed!(dst:dst, src:src)
var n64 base.u64 = this.swizzler.swizzle_packed!(dst:dst, dst_palette:this.dst_palette[:], src:src)
n = (n64 & 0xFFFFFFFF) as base.u32
new_ri = this.uncompressed_ri ~sat+ n