std/jpeg: add more EXTEND comments

This commit is contained in:
Nigel Tao committed 2023-06-20 17:33:08 +10:00
1 parent 38205517d4
commit 1acd74482a
1 file changed
+14 -5
+14 -5
View File
@@ -118,6 +118,17 @@ pri const BIAS_AND_CLAMP : roarray[1024] base.u8 = [
// EXTEND is a look-up table that helps implement Figure F.12 "Extending the
// sign bit of a decoded value in V".
//
// If ssss is the low 4 bits of the Huffman table's symbol, then EXTEND[ssss]
// is the selectively applied bias for an ssss-bit number arranged so that:
//
// - when ssss=0, the 0-bit number is -0.
// - when ssss=1, the 1-bit numbers are -1, +1.
// - when ssss=2, the 2-bit numbers are -3, -2, +2, +3.
// - when ssss=3, the 3-bit numbers are -7, -6, -5, -4, +4, +5, +6, +7.
// - etc
//
// EXTEND[0] = -0, EXTEND[1] = -1, EXTEND[2] = -3, EXTEND[3] = -7, etc.
//
// It was generated by this Go code (and then wuffsfmt'ed).
//
// --------
@@ -133,14 +144,12 @@ pri const BIAS_AND_CLAMP : roarray[1024] base.u8 = [
// // "V = (SLL –1 T) + 1" and SLL is "Shift Left Logical".
// v := (uint16(0xFFFF) << t) + 1
// fmt.Printf("0x%04X,", v)
// if (t & 3) == 3 {
// if (t & 7) == 7 {
// fmt.Println()
// }
// }
// }
pri const EXTEND : roarray[16] base.u16 = [
0x0000, 0xFFFF, 0xFFFD, 0xFFF9,
0xFFF1, 0xFFE1, 0xFFC1, 0xFF81,
0xFF01, 0xFE01, 0xFC01, 0xF801,
0xF001, 0xE001, 0xC001, 0x8001,
0x0000, 0xFFFF, 0xFFFD, 0xFFF9, 0xFFF1, 0xFFE1, 0xFFC1, 0xFF81,
0xFF01, 0xFE01, 0xFC01, 0xF801, 0xF001, 0xE001, 0xC001, 0x8001,
]