From 826b3e6c48f6e77722fc94248f2e2974897b5359 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sun, 26 Aug 2018 17:25:34 +1000 Subject: [PATCH] Remove gif's previous_use_global_palette --- release/c/wuffs-unsupported-snapshot.h | 16 +++++----------- std/gif/decode_gif.wuffs | 14 +++----------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/release/c/wuffs-unsupported-snapshot.h b/release/c/wuffs-unsupported-snapshot.h index 7546fbf1..d56987f3 100644 --- a/release/c/wuffs-unsupported-snapshot.h +++ b/release/c/wuffs-unsupported-snapshot.h @@ -2403,7 +2403,6 @@ typedef struct { uint8_t f_call_sequence; bool f_end_of_data; bool f_previous_lzw_decode_ended_abruptly; - bool f_previous_use_global_palette; uint8_t f_local_palette_log2_size; uint8_t f_which_palette; uint8_t f_interlace; @@ -6539,14 +6538,9 @@ wuffs_gif__decoder__decode_frame_config(wuffs_gif__decoder* self, if ((self->private_impl.f_local_palette_log2_size != 0) || self->private_impl.f_gc_has_transparent_index) { self->private_impl.f_which_palette = 1; - } else if (!self->private_impl.f_previous_use_global_palette) { - self->private_impl.f_which_palette = 0; } else { - self->private_impl.f_which_palette = 2; + self->private_impl.f_which_palette = 0; } - self->private_impl.f_previous_use_global_palette = - ((self->private_impl.f_local_palette_log2_size == 0) && - !self->private_impl.f_gc_has_transparent_index); v_blend = 0; if (!self->private_impl.f_gc_has_transparent_index) { v_blend = 2; @@ -7999,10 +7993,10 @@ wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self, 0; } wuffs_base__pixel_buffer__set_palette( - a_dst, - ((wuffs_base__slice_u8){.ptr = self->private_impl.f_palettes[( - self->private_impl.f_which_palette & 1)], - .len = 1024})); + a_dst, ((wuffs_base__slice_u8){ + .ptr = self->private_impl + .f_palettes[self->private_impl.f_which_palette], + .len = 1024})); if (self->private_impl.f_previous_lzw_decode_ended_abruptly) { (memset(&self->private_impl.f_lzw, 0, sizeof((wuffs_lzw__decoder){})), wuffs_base__ignore_check_wuffs_version_status( diff --git a/std/gif/decode_gif.wuffs b/std/gif/decode_gif.wuffs index 1d73af14..34d4d174 100644 --- a/std/gif/decode_gif.wuffs +++ b/std/gif/decode_gif.wuffs @@ -74,11 +74,10 @@ pub struct decoder?( end_of_data base.bool, previous_lzw_decode_ended_abruptly base.bool, - previous_use_global_palette base.bool, local_palette_log2_size base.u8[..8], // 0 means no local palette. - which_palette base.u8[..2], + which_palette base.u8[..1], // interlace indexes the interlace_start and interlace_delta arrays. interlace base.u8[..4], @@ -190,16 +189,9 @@ pub func decoder.decode_frame_config!??(dst nptr base.frame_config, src base.io_ if (this.local_palette_log2_size != 0) or this.gc_has_transparent_index { this.which_palette = 1 - } else if not this.previous_use_global_palette { - // This frame uses the global palette but the previous one didn't. - this.which_palette = 0 } else { - // Both this frame and the previous one used the global palette. No - // palette update is necessary. - this.which_palette = 2 + this.which_palette = 0 } - this.previous_use_global_palette = - (this.local_palette_log2_size == 0) and not this.gc_has_transparent_index var blend base.u8 = 0 if not this.gc_has_transparent_index { @@ -559,7 +551,7 @@ 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)) + 2] = 0x00 this.palettes[1][(4 * (this.gc_transparent_index as base.u32)) + 3] = 0x00 } - args.dst.set_palette!(palette:this.palettes[this.which_palette & 1][:]) + args.dst.set_palette!(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