image-rs / image-gif

GIF en- and decoder
Apache License 2.0
148 stars 42 forks source link

Unify Decoded events for pixels and LZW copy, check lifetimes #158

Closed kornelski closed 8 months ago

kornelski commented 8 months ago

Instead of separate decode_bytes_into for pixels, and a different event for LZW, it uses an OutputBuffer that handles both slices and Vec (for appending LZW, and only LZW, because Weezl decoder doesn't support writing to a MaybeUninit, so I did not add Vec-append-based optimization for pixel decoding).

I've also added an if false { return … } block for checking that the lifetimes of the events and buffers are correct, because the other return mem::transmute didn't check them, and was dangerous.