std/jpeg: grow quant_tables' elements, s/u8/u16/

This commit is contained in:
Nigel Tao committed 2023-07-17 10:27:49 +10:00
1 parent e5b6f2563e
commit 0af626b850
6 files changed
+28 -20

No files matched your search

+7 -5
View File
@@ -1190,7 +1190,7 @@ func (g *gen) writeBuiltinQuestionCall(b *buffer, n *a.Expr, depth uint32) error
switch recvTyp.QID()[1] {
case t.IDIOReader:
switch method.Ident() {
case t.IDReadU8, t.IDReadU8AsU32, t.IDReadU8AsU64:
case t.IDReadU8, t.IDReadU8AsU16, t.IDReadU8AsU32, t.IDReadU8AsU64:
if err := g.writeCoroSuspPoint(b, false); err != nil {
return err
}
@@ -1389,8 +1389,9 @@ var readMethods = [...]struct {
}{
t.IDReadU8 - readMethodsBase: {8, 8, 'b'},
t.IDReadU16BE - readMethodsBase: {16, 16, 'b'},
t.IDReadU16LE - readMethodsBase: {16, 16, 'l'},
t.IDReadU8AsU16 - readMethodsBase: {16, 8, 'b'},
t.IDReadU16BE - readMethodsBase: {16, 16, 'b'},
t.IDReadU16LE - readMethodsBase: {16, 16, 'l'},
t.IDReadU8AsU32 - readMethodsBase: {32, 8, 'b'},
t.IDReadU16BEAsU32 - readMethodsBase: {32, 16, 'b'},
@@ -1426,8 +1427,9 @@ var peekMethods = [...]struct {
}{
t.IDPeekU8 - peekMethodsBase: {8, 8, 'b'},
t.IDPeekU16BE - peekMethodsBase: {16, 16, 'b'},
t.IDPeekU16LE - peekMethodsBase: {16, 16, 'l'},
t.IDPeekU8AsU16 - peekMethodsBase: {16, 8, 'b'},
t.IDPeekU16BE - peekMethodsBase: {16, 16, 'b'},
t.IDPeekU16LE - peekMethodsBase: {16, 16, 'l'},
t.IDPeekU8AsU32 - peekMethodsBase: {32, 8, 'b'},
t.IDPeekU16BEAsU32 - peekMethodsBase: {32, 16, 'b'},
+2
View File
@@ -431,6 +431,7 @@ var funcsOther = [...]string{
"io_reader.read_u8?() u8",
"io_reader.read_u8_as_u16?() u16[..= 0xFF]",
"io_reader.read_u16be?() u16",
"io_reader.read_u16le?() u16",
@@ -467,6 +468,7 @@ var funcsOther = [...]string{
"io_reader.peek_u8() u8",
"io_reader.peek_u8_as_u16() u16[..= 0xFF]",
"io_reader.peek_u16be() u16",
"io_reader.peek_u16le() u16",
+12 -8
View File
@@ -524,8 +524,9 @@ const (
IDUndoByte = ID(0x180)
IDReadU8 = ID(0x181)
IDReadU16BE = ID(0x182)
IDReadU16LE = ID(0x183)
IDReadU8AsU16 = ID(0x185)
IDReadU16BE = ID(0x186)
IDReadU16LE = ID(0x187)
IDReadU8AsU32 = ID(0x189)
IDReadU16BEAsU32 = ID(0x18A)
@@ -557,8 +558,9 @@ const (
IDPeekU8 = ID(0x1A1)
IDPeekU16BE = ID(0x1A2)
IDPeekU16LE = ID(0x1A3)
IDPeekU8AsU16 = ID(0x1A5)
IDPeekU16BE = ID(0x1A6)
IDPeekU16LE = ID(0x1A7)
IDPeekU8AsU32 = ID(0x1A9)
IDPeekU16BEAsU32 = ID(0x1AA)
@@ -965,8 +967,9 @@ var builtInsByID = [nBuiltInIDs]string{
IDUndoByte: "undo_byte",
IDReadU8: "read_u8",
IDReadU16BE: "read_u16be",
IDReadU16LE: "read_u16le",
IDReadU8AsU16: "read_u8_as_u16",
IDReadU16BE: "read_u16be",
IDReadU16LE: "read_u16le",
IDReadU8AsU32: "read_u8_as_u32",
IDReadU16BEAsU32: "read_u16be_as_u32",
@@ -998,8 +1001,9 @@ var builtInsByID = [nBuiltInIDs]string{
IDPeekU8: "peek_u8",
IDPeekU16BE: "peek_u16be",
IDPeekU16LE: "peek_u16le",
IDPeekU8AsU16: "peek_u8_as_u16",
IDPeekU16BE: "peek_u16be",
IDPeekU16LE: "peek_u16le",
IDPeekU8AsU32: "peek_u8_as_u32",
IDPeekU16BEAsU32: "peek_u16be_as_u32",
+3 -3
View File
@@ -9152,8 +9152,8 @@ struct wuffs_jpeg__decoder__struct {
uint32_t f_bitstream_ri;
uint32_t f_bitstream_wi;
uint32_t f_bitstream_padding;
uint8_t f_quant_tables[4][64];
uint8_t f_saved_quant_tables[4][64];
uint16_t f_quant_tables[4][64];
uint16_t f_saved_quant_tables[4][64];
uint8_t f_huff_tables_symbols[8][256];
uint32_t f_huff_tables_slow[8][16];
uint16_t f_huff_tables_fast[8][256];
@@ -40494,7 +40494,7 @@ wuffs_jpeg__decoder__decode_dqt(
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend;
}
uint8_t t_1 = *iop_a_src++;
uint16_t t_1 = *iop_a_src++;
self->private_impl.f_quant_tables[v_q][WUFFS_JPEG__UNZIG[v_i]] = t_1;
}
}
+3 -3
View File
@@ -276,8 +276,8 @@ pub struct decoder? implements base.image_decoder(
// arbitrary.
bitstream_padding : base.u32[..= 12345],
quant_tables : array[4] array[64] base.u8,
saved_quant_tables : array[4] array[64] base.u8,
quant_tables : array[4] array[64] base.u16[..= 0xFF],
saved_quant_tables : array[4] array[64] base.u16[..= 0xFF],
// huff_tables_symbols[(tc*4)|th][i] is the i'th Huffman code's symbol.
huff_tables_symbols : array[8] array[256] base.u8,
@@ -509,7 +509,7 @@ pri func decoder.decode_dqt?(src: base.io_reader) {
i = 0
while i < 64 {
i += 1
this.quant_tables[q][UNZIG[i]] = args.src.read_u8?()
this.quant_tables[q][UNZIG[i]] = args.src.read_u8_as_u16?()
} endwhile
this.seen_dqt[q] = true
+1 -1
View File
@@ -550,7 +550,7 @@ test_wuffs_jpeg_decode_idct() {
// This is "test/data/bricks-color.jpeg"'s first quantization table, in
// natural (not zig-zag) order.
const uint8_t quant_table[64] = {
const uint16_t quant_table[64] = {
0x03, 0x02, 0x02, 0x03, 0x04, 0x06, 0x08, 0x0A, //
0x02, 0x02, 0x02, 0x03, 0x04, 0x09, 0x0A, 0x09, //
0x02, 0x02, 0x03, 0x04, 0x06, 0x09, 0x0B, 0x09, //