From 48fa7182f41328294149b75b6bd01fc17640a285 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Mon, 19 Jun 2023 13:19:24 +1000 Subject: [PATCH] std/jpeg: tweak UNZIG comments --- std/jpeg/common_consts.wuffs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/std/jpeg/common_consts.wuffs b/std/jpeg/common_consts.wuffs index 10073124..8164a0f3 100644 --- a/std/jpeg/common_consts.wuffs +++ b/std/jpeg/common_consts.wuffs @@ -12,9 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -// UNZIG maps from the zig-zag ordering to the natural ordering. For example, -// UNZIG[3] is the column and row of the fourth element in zig-zag order. The -// value is 16, which means first column (16%8 == 0) and third row (16/8 == 2). +// -------- + +// UNZIG maps from the zig-zag ordering to the natural ordering. Its indices +// start at 1, simplifying while.ac_components loops in decode_mcu_*.wuffs +// +// For example, UNZIG[4] is the column and row of the fourth element in zig-zag +// order. The value is 16, which means first column (16%8 == 0) and third row +// (16/8 == 2). pri const UNZIG : roarray[80] base.u8[..= 63] = [ 0x00, // The 8x8 indexes are below. @@ -27,8 +32,9 @@ pri const UNZIG : roarray[80] base.u8[..= 63] = [ 0x3A, 0x3B, 0x34, 0x2D, 0x26, 0x1F, 0x27, 0x2E, 0x35, 0x3C, 0x3D, 0x36, 0x2F, 0x37, 0x3E, 0x3F, // The 15 extra elements are for invalid JPEGs where "the z in UNZIG[z] - // overflows 63, when saving the AC value". This isn't in the spec but - // matches how libjpeg-turbo treats "above 63". + // overflows 64, when saving the AC value". This isn't in the spec but + // matches how libjpeg-turbo treats "above 64" ("above 63" in the + // equivalent libjpeg-turbo code, since our UNZIG indices start at 1). 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, ] @@ -114,7 +120,7 @@ pri const BIAS_AND_CLAMP : roarray[1024] base.u8 = [ // // It was generated by this Go code (and then wuffsfmt'ed). // -// ---- +// -------- // // package main //