Roll back 'dst_palette into the pixel_swizzler'

See the previous commit for the rationale.
This commit is contained in:
Nigel Tao committed 2020-05-26 14:13:28 +10:00
1 parent 2d8ec9ace9
commit 1239280ad8
9 files changed
+310 -236

No files matched your search

+2
View File
@@ -341,6 +341,7 @@ pri func decoder.swizzle!(dst: ptr base.pixel_buffer, src: slice base.u8) base.s
if i < dst.length() {
this.swizzler.swizzle_interleaved!(
dst: dst[i ..],
dst_palette: this.util.empty_slice_u8(),
src: this.stash[.. this.num_stashed])
this.dst_x ~sat+= 1
}
@@ -376,6 +377,7 @@ pri func decoder.swizzle!(dst: ptr base.pixel_buffer, src: slice base.u8) base.s
if i < dst.length() {
n = this.swizzler.swizzle_interleaved!(
dst: dst[i ..],
dst_palette: this.util.empty_slice_u8(),
src: args.src)
this.dst_x ~sat+= (n & 0xFFFF_FFFF) as base.u32
n = (n & 0xFFFF_FFFF) * (src_bytes_per_pixel as base.u64)
+11 -2
View File
@@ -137,6 +137,8 @@ pub struct decoder? implements base.image_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,
lzw : lzw.decoder,
//#WHEN PREPROC101 decode_config.wuffs
@@ -819,6 +821,7 @@ pri func decoder.decode_id_part1?(dst: ptr base.pixel_buffer, src: base.io_reade
var num_palette_entries : base.u32[..= 256]
var i : base.u32
var argb : base.u32
var dst_palette : slice base.u8
var status : base.status
var lw : base.u8
@@ -870,11 +873,16 @@ 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
}
dst_palette = 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_BINARY magic pixfmt constant.
status = this.swizzler.prepare!(
dst_pixfmt: args.dst.pixel_format(),
dst_palette: args.dst.palette(),
dst_palette: dst_palette,
src_pixfmt: this.util.make_pixel_format(repr: 0x8304_0008),
src_palette: this.palettes[which_palette][..],
blend: args.blend)
@@ -1066,7 +1074,8 @@ pri func decoder.copy_to_image_buffer!(pb: ptr base.pixel_buffer, src: slice bas
} else {
dst = dst[i ..]
}
n = this.swizzler.swizzle_interleaved!(dst: dst, src: src)
n = this.swizzler.swizzle_interleaved!(
dst: dst, dst_palette: this.dst_palette[..], src: src)
src_ri ~sat+= n
this.dst_x ~sat+= (n & 0xFFFF_FFFF) as base.u32
+2 -1
View File
@@ -212,7 +212,8 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
// v_c <<= 1;
c = (((c as base.u32) << 1) & 0xFF) as base.u8
this.swizzler.swizzle_interleaved!(dst: dst, src: src[..])
this.swizzler.swizzle_interleaved!(
dst: dst, dst_palette: this.util.empty_slice_u8(), src: src[..])
if dst_bytes_per_pixel <= dst.length() {
dst = dst[dst_bytes_per_pixel ..]