mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 16:47:28 +01:00
30 lines
770 B
Plaintext
30 lines
770 B
Plaintext
// Use of this source code is governed by a BSD-style license that can be found
|
|
// in the LICENSE file.
|
|
|
|
// The GIF spec is https://www.w3.org/Graphics/GIF/spec-gif89a.txt
|
|
|
|
pub error "bad GIF header"
|
|
|
|
pub struct decoder?(
|
|
lzw lzw_decoder,
|
|
)
|
|
|
|
pub func decoder.decode?(dst ptr buf1, src ptr buf1)() {
|
|
this.decode_header?(src:in.src)
|
|
}
|
|
|
|
// decode_header reads either "GIF87a" or "GIF89a".
|
|
pri func decoder.decode_header?(src ptr buf1)() {
|
|
if (in.src.read_u8?() != 0x47) or (in.src.read_u8?() != 0x49) or
|
|
(in.src.read_u8?() != 0x46) or (in.src.read_u8?() != 0x38) {
|
|
return error "bad GIF header"
|
|
}
|
|
var c u8 = in.src.read_u8?()
|
|
if (c != 0x37) and (c != 0x39) {
|
|
return error "bad GIF header"
|
|
}
|
|
if in.src.read_u8?() != 0x61 {
|
|
return error "bad GIF header"
|
|
}
|
|
}
|