From a6c89da981b684d6e515247ab54d1bd05567be56 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Wed, 8 Apr 2026 21:08:43 +1000 Subject: [PATCH] std/handsum: change version bits from 0x00 to 0x40 --- example/stb-imagedumper/stb-imagedumper.c | 2 +- lib/handsum/handsum.go | 6 +++--- release/c/wuffs-unsupported-snapshot.c | 2 +- std/handsum/decode_handsum.wuffs | 2 +- test/data/bricks-color.handsum | Bin 48 -> 48 bytes test/data/mona-lisa.21x32.handsum | Bin 48 -> 48 bytes 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/example/stb-imagedumper/stb-imagedumper.c b/example/stb-imagedumper/stb-imagedumper.c index b5db386b..cc2baefe 100644 --- a/example/stb-imagedumper/stb-imagedumper.c +++ b/example/stb-imagedumper/stb-imagedumper.c @@ -226,7 +226,7 @@ const uint8_t g_src_ptr__mona_lisa_21_32_th[] = { const size_t g_src_len__mona_lisa_21_32_th = 24; const uint8_t g_src_ptr__mona_lisa_21_32_handsum[] = { - 0xfe, 0xd7, 0x34, 0x17, 0x6f, 0xef, 0x00, 0x08, 0xa9, 0xfb, 0x6a, 0xf0, + 0xfe, 0xd7, 0x74, 0x17, 0x6f, 0xef, 0x00, 0x08, 0xa9, 0xfb, 0x6a, 0xf0, 0x1d, 0xff, 0xf0, 0xa0, 0xcb, 0xe2, 0x04, 0x4f, 0xad, 0xfa, 0xfb, 0x0c, 0x2e, 0x26, 0xf9, 0x8a, 0x6f, 0xac, 0x9f, 0xbf, 0xc8, 0x67, 0x90, 0xc9, 0x7b, 0x89, 0x77, 0x88, 0x96, 0x6a, 0x75, 0x75, 0x87, 0x87, 0x88, 0xa9, diff --git a/lib/handsum/handsum.go b/lib/handsum/handsum.go index a234d139..a52153a4 100644 --- a/lib/handsum/handsum.go +++ b/lib/handsum/handsum.go @@ -111,7 +111,7 @@ func Encode(w io.Writer, src image.Image, options *EncodeOptions) error { buf := [FileSize]byte{} buf[0] = Magic[0] buf[1] = Magic[1] - buf[2] = aspectRatio + buf[2] = aspectRatio | 0x40 bitOffset := 3 * 8 for i := range dstI16s { @@ -192,7 +192,7 @@ func DecodeConfig(r io.Reader) (image.Config, error) { return image.Config{}, err } else if (buf[0] != Magic[0]) || (buf[1] != Magic[1]) { return image.Config{}, ErrNotAHandsumFile - } else if (buf[2] & 0xC0) != 0 { + } else if (buf[2] & 0xC0) != 0x40 { return image.Config{}, ErrUnsupportedFileVersion } @@ -211,7 +211,7 @@ func Decode(r io.Reader) (image.Image, error) { return nil, err } else if (buf[0] != Magic[0]) || (buf[1] != Magic[1]) { return nil, ErrNotAHandsumFile - } else if (buf[2] & 0xC0) != 0 { + } else if (buf[2] & 0xC0) != 0x40 { return nil, ErrUnsupportedFileVersion } diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index fbc324e6..001e7c33 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -50863,7 +50863,7 @@ wuffs_handsum__decoder__do_decode_image_config( uint32_t t_1 = *iop_a_src++; v_c32 = t_1; } - if ((v_c32 & 192u) != 0u) { + if ((v_c32 & 192u) != 64u) { status = wuffs_base__make_status(wuffs_handsum__error__unsupported_handsum_file); goto exit; } diff --git a/std/handsum/decode_handsum.wuffs b/std/handsum/decode_handsum.wuffs index ba735985..beaabc29 100644 --- a/std/handsum/decode_handsum.wuffs +++ b/std/handsum/decode_handsum.wuffs @@ -82,7 +82,7 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base. return "#bad header" } c32 = args.src.read_u8_as_u32?() - if (c32 & 0xC0) <> 0x00 { + if (c32 & 0xC0) <> 0x40 { return "#unsupported Handsum file" } diff --git a/test/data/bricks-color.handsum b/test/data/bricks-color.handsum index 102e13611ce4380cc6b7d21cbbf8b7ccc196b447..8f062df5668b4836975a9963ff819e1eb8ab7c39 100644 GIT binary patch delta 9 QcmXpoVE%VKd?K?h01&qWQ2+n{ delta 9 QcmXpoVE%Vqd?K?h01vkV5dZ)H diff --git a/test/data/mona-lisa.21x32.handsum b/test/data/mona-lisa.21x32.handsum index 6897aefbc9a06956775856c0f52d18c0316f7627..9a143d220f38f34d061651ba059de4ad833ad1cf 100644 GIT binary patch delta 9 QcmXpoVE%W#WFoUJ01+z#ZU6uP delta 9 QcmXpoVE%XAWFoUJ01zt!E&u=k