diff --git a/server/go.mod b/server/go.mod index 08947d1a8..3dd2748cc 100644 --- a/server/go.mod +++ b/server/go.mod @@ -70,7 +70,7 @@ require ( go.uber.org/atomic v1.9.0 go.uber.org/zap v1.21.0 golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d - golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 + golang.org/x/image v0.5.0 golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 golang.org/x/text v0.8.0 google.golang.org/grpc v1.46.0 diff --git a/server/go.sum b/server/go.sum index cbb4819ef..90b0f4e4f 100644 --- a/server/go.sum +++ b/server/go.sum @@ -662,8 +662,9 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 h1:hVwzHzIUGRjiF7EcUjqNxk3NCfkPxbDKRdnNE1Rpg0U= golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.5.0 h1:5JMiNunQeQw++mMOz48/ISeNu3Iweh/JaZU8ZLqHRrI= +golang.org/x/image v0.5.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -857,6 +858,7 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/server/vendor/golang.org/x/image/AUTHORS b/server/vendor/golang.org/x/image/AUTHORS deleted file mode 100644 index 15167cd74..000000000 --- a/server/vendor/golang.org/x/image/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code refers to The Go Authors for copyright purposes. -# The master list of authors is in the main Go distribution, -# visible at http://tip.golang.org/AUTHORS. diff --git a/server/vendor/golang.org/x/image/CONTRIBUTORS b/server/vendor/golang.org/x/image/CONTRIBUTORS deleted file mode 100644 index 1c4577e96..000000000 --- a/server/vendor/golang.org/x/image/CONTRIBUTORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code was written by the Go contributors. -# The master list of contributors is in the main Go distribution, -# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/server/vendor/golang.org/x/image/bmp/reader.go b/server/vendor/golang.org/x/image/bmp/reader.go index c10a022f6..e165c2e39 100644 --- a/server/vendor/golang.org/x/image/bmp/reader.go +++ b/server/vendor/golang.org/x/image/bmp/reader.go @@ -85,7 +85,7 @@ func decodeRGB(r io.Reader, c image.Config, topDown bool) (image.Image, error) { // decodeNRGBA reads a 32 bit-per-pixel BMP image from r. // If topDown is false, the image rows will be read bottom-up. -func decodeNRGBA(r io.Reader, c image.Config, topDown bool) (image.Image, error) { +func decodeNRGBA(r io.Reader, c image.Config, topDown, allowAlpha bool) (image.Image, error) { rgba := image.NewNRGBA(image.Rect(0, 0, c.Width, c.Height)) if c.Width == 0 || c.Height == 0 { return rgba, nil @@ -102,6 +102,9 @@ func decodeNRGBA(r io.Reader, c image.Config, topDown bool) (image.Image, error) for i := 0; i < len(p); i += 4 { // BMP images are stored in BGRA order rather than RGBA order. p[i+0], p[i+2] = p[i+2], p[i+0] + if !allowAlpha { + p[i+3] = 0xFF + } } } return rgba, nil @@ -110,7 +113,7 @@ func decodeNRGBA(r io.Reader, c image.Config, topDown bool) (image.Image, error) // Decode reads a BMP image from r and returns it as an image.Image. // Limitation: The file must be 8, 24 or 32 bits per pixel. func Decode(r io.Reader) (image.Image, error) { - c, bpp, topDown, err := decodeConfig(r) + c, bpp, topDown, allowAlpha, err := decodeConfig(r) if err != nil { return nil, err } @@ -120,7 +123,7 @@ func Decode(r io.Reader) (image.Image, error) { case 24: return decodeRGB(r, c, topDown) case 32: - return decodeNRGBA(r, c, topDown) + return decodeNRGBA(r, c, topDown, allowAlpha) } panic("unreachable") } @@ -129,13 +132,15 @@ func Decode(r io.Reader) (image.Image, error) { // decoding the entire image. // Limitation: The file must be 8, 24 or 32 bits per pixel. func DecodeConfig(r io.Reader) (image.Config, error) { - config, _, _, err := decodeConfig(r) + config, _, _, _, err := decodeConfig(r) return config, err } -func decodeConfig(r io.Reader) (config image.Config, bitsPerPixel int, topDown bool, err error) { - // We only support those BMP images that are a BITMAPFILEHEADER - // immediately followed by a BITMAPINFOHEADER. +func decodeConfig(r io.Reader) (config image.Config, bitsPerPixel int, topDown bool, allowAlpha bool, err error) { + // We only support those BMP images with one of the following DIB headers: + // - BITMAPINFOHEADER (40 bytes) + // - BITMAPV4HEADER (108 bytes) + // - BITMAPV5HEADER (124 bytes) const ( fileHeaderLen = 14 infoHeaderLen = 40 @@ -144,18 +149,24 @@ func decodeConfig(r io.Reader) (config image.Config, bitsPerPixel int, topDown b ) var b [1024]byte if _, err := io.ReadFull(r, b[:fileHeaderLen+4]); err != nil { - return image.Config{}, 0, false, err + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + return image.Config{}, 0, false, false, err } if string(b[:2]) != "BM" { - return image.Config{}, 0, false, errors.New("bmp: invalid format") + return image.Config{}, 0, false, false, errors.New("bmp: invalid format") } offset := readUint32(b[10:14]) infoLen := readUint32(b[14:18]) if infoLen != infoHeaderLen && infoLen != v4InfoHeaderLen && infoLen != v5InfoHeaderLen { - return image.Config{}, 0, false, ErrUnsupported + return image.Config{}, 0, false, false, ErrUnsupported } if _, err := io.ReadFull(r, b[fileHeaderLen+4:fileHeaderLen+infoLen]); err != nil { - return image.Config{}, 0, false, err + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + return image.Config{}, 0, false, false, err } width := int(int32(readUint32(b[18:22]))) height := int(int32(readUint32(b[22:26]))) @@ -163,12 +174,12 @@ func decodeConfig(r io.Reader) (config image.Config, bitsPerPixel int, topDown b height, topDown = -height, true } if width < 0 || height < 0 { - return image.Config{}, 0, false, ErrUnsupported + return image.Config{}, 0, false, false, ErrUnsupported } // We only support 1 plane and 8, 24 or 32 bits per pixel and no // compression. planes, bpp, compression := readUint16(b[26:28]), readUint16(b[28:30]), readUint32(b[30:34]) - // if compression is set to BITFIELDS, but the bitmask is set to the default bitmask + // if compression is set to BI_BITFIELDS, but the bitmask is set to the default bitmask // that would be used if compression was set to 0, we can continue as if compression was 0 if compression == 3 && infoLen > infoHeaderLen && readUint32(b[54:58]) == 0xff0000 && readUint32(b[58:62]) == 0xff00 && @@ -176,16 +187,16 @@ func decodeConfig(r io.Reader) (config image.Config, bitsPerPixel int, topDown b compression = 0 } if planes != 1 || compression != 0 { - return image.Config{}, 0, false, ErrUnsupported + return image.Config{}, 0, false, false, ErrUnsupported } switch bpp { case 8: if offset != fileHeaderLen+infoLen+256*4 { - return image.Config{}, 0, false, ErrUnsupported + return image.Config{}, 0, false, false, ErrUnsupported } _, err = io.ReadFull(r, b[:256*4]) if err != nil { - return image.Config{}, 0, false, err + return image.Config{}, 0, false, false, err } pcm := make(color.Palette, 256) for i := range pcm { @@ -193,19 +204,40 @@ func decodeConfig(r io.Reader) (config image.Config, bitsPerPixel int, topDown b // Every 4th byte is padding. pcm[i] = color.RGBA{b[4*i+2], b[4*i+1], b[4*i+0], 0xFF} } - return image.Config{ColorModel: pcm, Width: width, Height: height}, 8, topDown, nil + return image.Config{ColorModel: pcm, Width: width, Height: height}, 8, topDown, false, nil case 24: if offset != fileHeaderLen+infoLen { - return image.Config{}, 0, false, ErrUnsupported + return image.Config{}, 0, false, false, ErrUnsupported } - return image.Config{ColorModel: color.RGBAModel, Width: width, Height: height}, 24, topDown, nil + return image.Config{ColorModel: color.RGBAModel, Width: width, Height: height}, 24, topDown, false, nil case 32: if offset != fileHeaderLen+infoLen { - return image.Config{}, 0, false, ErrUnsupported + return image.Config{}, 0, false, false, ErrUnsupported } - return image.Config{ColorModel: color.RGBAModel, Width: width, Height: height}, 32, topDown, nil + // 32 bits per pixel is possibly RGBX (X is padding) or RGBA (A is + // alpha transparency). However, for BMP images, "Alpha is a + // poorly-documented and inconsistently-used feature" says + // https://source.chromium.org/chromium/chromium/src/+/bc0a792d7ebc587190d1a62ccddba10abeea274b:third_party/blink/renderer/platform/image-decoders/bmp/bmp_image_reader.cc;l=621 + // + // That goes on to say "BITMAPV3HEADER+ have an alpha bitmask in the + // info header... so we respect it at all times... [For earlier + // (smaller) headers we] ignore alpha in Windows V3 BMPs except inside + // ICO files". + // + // "Ignore" means to always set alpha to 0xFF (fully opaque): + // https://source.chromium.org/chromium/chromium/src/+/bc0a792d7ebc587190d1a62ccddba10abeea274b:third_party/blink/renderer/platform/image-decoders/bmp/bmp_image_reader.h;l=272 + // + // Confusingly, "Windows V3" does not correspond to BITMAPV3HEADER, but + // instead corresponds to the earlier (smaller) BITMAPINFOHEADER: + // https://source.chromium.org/chromium/chromium/src/+/bc0a792d7ebc587190d1a62ccddba10abeea274b:third_party/blink/renderer/platform/image-decoders/bmp/bmp_image_reader.cc;l=258 + // + // This Go package does not support ICO files and the (infoLen > + // infoHeaderLen) condition distinguishes BITMAPINFOHEADER (40 bytes) + // vs later (larger) headers. + allowAlpha = infoLen > infoHeaderLen + return image.Config{ColorModel: color.RGBAModel, Width: width, Height: height}, 32, topDown, allowAlpha, nil } - return image.Config{}, 0, false, ErrUnsupported + return image.Config{}, 0, false, false, ErrUnsupported } func init() { diff --git a/server/vendor/golang.org/x/image/ccitt/reader.go b/server/vendor/golang.org/x/image/ccitt/reader.go index 16bd495d5..340de0536 100644 --- a/server/vendor/golang.org/x/image/ccitt/reader.go +++ b/server/vendor/golang.org/x/image/ccitt/reader.go @@ -16,6 +16,7 @@ import ( ) var ( + errIncompleteCode = errors.New("ccitt: incomplete code") errInvalidBounds = errors.New("ccitt: invalid bounds") errInvalidCode = errors.New("ccitt: invalid code") errInvalidMode = errors.New("ccitt: invalid mode") @@ -48,6 +49,10 @@ const ( Group4 ) +// AutoDetectHeight is passed as the height argument to NewReader to indicate +// that the image height (the number of rows) is not known in advance. +const AutoDetectHeight = -1 + // Options are optional parameters. type Options struct { // Align means that some variable-bit-width codes are byte-aligned. @@ -205,10 +210,14 @@ func decode(b *bitReader, decodeTable [][2]int16) (uint32, error) { for { bit, err := b.nextBit() if err != nil { + if err == io.EOF { + err = errIncompleteCode + } return 0, err } bitsRead |= bit << (63 - nBitsRead) nBitsRead++ + // The "&1" is redundant, but can eliminate a bounds check. state = int32(decodeTable[state][bit&1]) if state < 0 { @@ -222,6 +231,35 @@ func decode(b *bitReader, decodeTable [][2]int16) (uint32, error) { } } +// decodeEOL decodes the 12-bit EOL code 0000_0000_0001. +func decodeEOL(b *bitReader) error { + nBitsRead, bitsRead := uint32(0), uint64(0) + for { + bit, err := b.nextBit() + if err != nil { + if err == io.EOF { + err = errMissingEOL + } + return err + } + bitsRead |= bit << (63 - nBitsRead) + nBitsRead++ + + if nBitsRead < 12 { + if bit&1 == 0 { + continue + } + } else if bit&1 != 0 { + return nil + } + + // Unread the bits we've read, then return errMissingEOL. + b.bits = (b.bits >> nBitsRead) | bitsRead + b.nBits += nBitsRead + return errMissingEOL + } +} + type reader struct { br bitReader subFormat SubFormat @@ -231,7 +269,10 @@ type reader struct { // rowsRemaining starts at the image height in pixels, when the reader is // driven through the io.Reader interface, and decrements to zero as rows - // are decoded. When driven through DecodeIntoGray, this field is unused. + // are decoded. Alternatively, it may be negative if the image height is + // not known in advance at the time of the NewReader call. + // + // When driven through DecodeIntoGray, this field is unused. rowsRemaining int // curr and prev hold the current and previous rows. Each element is either @@ -269,6 +310,19 @@ type reader struct { // seenStartOfImage is whether we've called the startDecode method. seenStartOfImage bool + // truncated is whether the input is missing the final 6 consecutive EOL's + // (for Group3) or 2 consecutive EOL's (for Group4). Omitting that trailer + // (but otherwise padding to a byte boundary, with either all 0 bits or all + // 1 bits) is invalid according to the spec, but happens in practice when + // exporting from Adobe Acrobat to TIFF + CCITT. This package silently + // ignores the format error for CCITT input that has been truncated in that + // fashion, returning the full decoded image. + // + // Detecting trailer truncation (just after the final row of pixels) + // requires knowing which row is the final row, and therefore does not + // trigger if the image height is not known in advance. + truncated bool + // readErr is a sticky error for the Read method. readErr error } @@ -294,17 +348,50 @@ func (z *reader) Read(p []byte) (int, error) { // Decode the next row, if necessary. if z.atStartOfRow { - if z.rowsRemaining <= 0 { - if z.readErr = z.finishDecode(); z.readErr != nil { + if z.rowsRemaining < 0 { + // We do not know the image height in advance. See if the next + // code is an EOL. If it is, it is consumed. If it isn't, the + // bitReader shouldn't advance along the bit stream, and we + // simply decode another row of pixel data. + // + // For the Group4 subFormat, we may need to align to a byte + // boundary. For the Group3 subFormat, the previous z.decodeRow + // call (or z.startDecode call) has already consumed one of the + // 6 consecutive EOL's. The next EOL is actually the second of + // 6, in the middle, and we shouldn't align at that point. + if z.align && (z.subFormat == Group4) { + z.br.alignToByteBoundary() + } + + if err := z.decodeEOL(); err == errMissingEOL { + // No-op. It's another row of pixel data. + } else if err != nil { + z.readErr = err + break + } else { + if z.readErr = z.finishDecode(true); z.readErr != nil { + break + } + z.readErr = io.EOF + break + } + + } else if z.rowsRemaining == 0 { + // We do know the image height in advance, and we have already + // decoded exactly that many rows. + if z.readErr = z.finishDecode(false); z.readErr != nil { break } z.readErr = io.EOF break + + } else { + z.rowsRemaining-- } - if z.readErr = z.decodeRow(); z.readErr != nil { + + if z.readErr = z.decodeRow(z.rowsRemaining == 0); z.readErr != nil { break } - z.rowsRemaining-- } // Pack from z.curr (1 byte per pixel) to p (1 bit per pixel). @@ -351,32 +438,44 @@ func (z *reader) startDecode() error { return nil } -func (z *reader) finishDecode() error { +func (z *reader) finishDecode(alreadySeenEOL bool) error { numberOfEOLs := 0 switch z.subFormat { case Group3: + if z.truncated { + return nil + } // The stream ends with a RTC (Return To Control) of 6 consecutive // EOL's, but we should have already just seen an EOL, either in // z.startDecode (for a zero-height image) or in z.decodeRow. numberOfEOLs = 5 case Group4: - // The stream ends with two EOL's, the first of which is possibly - // byte-aligned. - numberOfEOLs = 2 - if err := z.decodeEOL(); err == nil { - numberOfEOLs-- - } else if err == errInvalidCode { - // Try again, this time starting from a byte boundary. + autoDetectHeight := z.rowsRemaining < 0 + if autoDetectHeight { + // Aligning to a byte boundary was already handled by reader.Read. + } else if z.align { z.br.alignToByteBoundary() - } else { + } + // The stream ends with two EOL's. If the first one is missing, and we + // had an explicit image height, we just assume that the trailing two + // EOL's were truncated and return a nil error. + if err := z.decodeEOL(); err != nil { + if (err == errMissingEOL) && !autoDetectHeight { + z.truncated = true + return nil + } return err } + numberOfEOLs = 1 default: return errUnsupportedSubFormat } + if alreadySeenEOL { + numberOfEOLs-- + } for ; numberOfEOLs > 0; numberOfEOLs-- { if err := z.decodeEOL(); err != nil { return err @@ -386,19 +485,10 @@ func (z *reader) finishDecode() error { } func (z *reader) decodeEOL() error { - // TODO: EOL doesn't have to be in the modeDecodeTable. It could be in its - // own table, or we could just hard-code it, especially if we might need to - // cater for optional byte-alignment, or an arbitrary number (potentially - // more than 8) of 0-valued padding bits. - if mode, err := decode(&z.br, modeDecodeTable[:]); err != nil { - return err - } else if mode != modeEOL { - return errMissingEOL - } - return nil + return decodeEOL(&z.br) } -func (z *reader) decodeRow() error { +func (z *reader) decodeRow(finalRow bool) error { z.wi = 0 z.atStartOfRow = true z.penColorIsWhite = true @@ -414,7 +504,12 @@ func (z *reader) decodeRow() error { return err } } - return z.decodeEOL() + err := z.decodeEOL() + if finalRow && (err == errMissingEOL) { + z.truncated = true + return nil + } + return err case Group4: for ; z.wi < len(z.curr); z.atStartOfRow = false { @@ -654,13 +749,13 @@ func DecodeIntoGray(dst *image.Gray, r io.Reader, order Order, sf SubFormat, opt for y := bounds.Min.Y; y < bounds.Max.Y; y++ { p := (y - bounds.Min.Y) * dst.Stride z.curr = dst.Pix[p : p+width] - if err := z.decodeRow(); err != nil { + if err := z.decodeRow(y+1 == bounds.Max.Y); err != nil { return err } z.curr, z.prev = nil, z.curr } - if err := z.finishDecode(); err != nil { + if err := z.finishDecode(false); err != nil { return err } @@ -677,9 +772,12 @@ func DecodeIntoGray(dst *image.Gray, r io.Reader, order Order, sf SubFormat, opt // NewReader returns an io.Reader that decodes the CCITT-formatted data in r. // The resultant byte stream is one bit per pixel (MSB first), with 1 meaning // white and 0 meaning black. Each row in the result is byte-aligned. +// +// A negative height, such as passing AutoDetectHeight, means that the image +// height is not known in advance. A negative width is invalid. func NewReader(r io.Reader, order Order, sf SubFormat, width int, height int, opts *Options) io.Reader { readErr := error(nil) - if (width < 0) || (height < 0) { + if width < 0 { readErr = errInvalidBounds } else if width > maxWidth { readErr = errUnsupportedWidth diff --git a/server/vendor/golang.org/x/image/ccitt/table.go b/server/vendor/golang.org/x/image/ccitt/table.go index f01cc12b5..8b3794bc2 100644 --- a/server/vendor/golang.org/x/image/ccitt/table.go +++ b/server/vendor/golang.org/x/image/ccitt/table.go @@ -31,37 +31,27 @@ package ccitt // modeDecodeTable represents Table 1 and the End-of-Line code. // -// +=XXXXX -// b015 +-+ -// | +=v0010 -// b014 +-+ -// | +=XXXXX -// b013 +-+ -// | +=XXXXX -// b012 +-+ -// | +=XXXXX -// b011 +-+ -// | +=XXXXX -// b009 +-+ -// | +=v0009 -// b007 +-+ -// | | +=v0008 -// b010 | +-+ -// | +=v0005 -// b006 +-+ -// | | +=v0007 -// b008 | +-+ -// | +=v0004 -// b005 +-+ -// | +=v0000 -// b003 +-+ -// | +=v0001 -// b002 +-+ -// | | +=v0006 -// b004 | +-+ -// | +=v0003 -// b001 +-+ -// +=v0002 +// +=XXXXX +// b009 +-+ +// | +=v0009 +// b007 +-+ +// | | +=v0008 +// b010 | +-+ +// | +=v0005 +// b006 +-+ +// | | +=v0007 +// b008 | +-+ +// | +=v0004 +// b005 +-+ +// | +=v0000 +// b003 +-+ +// | +=v0001 +// b002 +-+ +// | | +=v0006 +// b004 | +-+ +// | +=v0003 +// b001 +-+ +// +=v0002 var modeDecodeTable = [...][2]int16{ 0: {0, 0}, 1: {2, ^2}, @@ -72,226 +62,221 @@ var modeDecodeTable = [...][2]int16{ 6: {7, 8}, 7: {9, 10}, 8: {^7, ^4}, - 9: {11, ^9}, + 9: {0, ^9}, 10: {^8, ^5}, - 11: {12, 0}, - 12: {13, 0}, - 13: {14, 0}, - 14: {15, 0}, - 15: {0, ^10}, } // whiteDecodeTable represents Tables 2 and 3 for a white run. // -// +=XXXXX -// b059 +-+ -// | | +=v1792 -// b096 | | +-+ -// | | | | +=v1984 -// b100 | | | +-+ -// | | | +=v2048 -// b094 | | +-+ -// | | | | +=v2112 -// b101 | | | | +-+ -// | | | | | +=v2176 -// b097 | | | +-+ -// | | | | +=v2240 -// b102 | | | +-+ -// | | | +=v2304 -// b085 | +-+ -// | | +=v1856 -// b098 | | +-+ -// | | | +=v1920 -// b095 | +-+ -// | | +=v2368 -// b103 | | +-+ -// | | | +=v2432 -// b099 | +-+ -// | | +=v2496 -// b104 | +-+ -// | +=v2560 -// b040 +-+ -// | | +=v0029 -// b060 | +-+ -// | +=v0030 -// b026 +-+ -// | | +=v0045 -// b061 | | +-+ -// | | | +=v0046 -// b041 | +-+ -// | +=v0022 -// b016 +-+ -// | | +=v0023 -// b042 | | +-+ -// | | | | +=v0047 -// b062 | | | +-+ -// | | | +=v0048 -// b027 | +-+ -// | +=v0013 -// b008 +-+ -// | | +=v0020 -// b043 | | +-+ -// | | | | +=v0033 -// b063 | | | +-+ -// | | | +=v0034 -// b028 | | +-+ -// | | | | +=v0035 -// b064 | | | | +-+ -// | | | | | +=v0036 -// b044 | | | +-+ -// | | | | +=v0037 -// b065 | | | +-+ -// | | | +=v0038 -// b017 | +-+ -// | | +=v0019 -// b045 | | +-+ -// | | | | +=v0031 -// b066 | | | +-+ -// | | | +=v0032 -// b029 | +-+ -// | +=v0001 -// b004 +-+ -// | | +=v0012 -// b030 | | +-+ -// | | | | +=v0053 -// b067 | | | | +-+ -// | | | | | +=v0054 -// b046 | | | +-+ -// | | | +=v0026 -// b018 | | +-+ -// | | | | +=v0039 -// b068 | | | | +-+ -// | | | | | +=v0040 -// b047 | | | | +-+ -// | | | | | | +=v0041 -// b069 | | | | | +-+ -// | | | | | +=v0042 -// b031 | | | +-+ -// | | | | +=v0043 -// b070 | | | | +-+ -// | | | | | +=v0044 -// b048 | | | +-+ -// | | | +=v0021 -// b009 | +-+ -// | | +=v0028 -// b049 | | +-+ -// | | | | +=v0061 -// b071 | | | +-+ -// | | | +=v0062 -// b032 | | +-+ -// | | | | +=v0063 -// b072 | | | | +-+ -// | | | | | +=v0000 -// b050 | | | +-+ -// | | | | +=v0320 -// b073 | | | +-+ -// | | | +=v0384 -// b019 | +-+ -// | +=v0010 -// b002 +-+ -// | | +=v0011 -// b020 | | +-+ -// | | | | +=v0027 -// b051 | | | | +-+ -// | | | | | | +=v0059 -// b074 | | | | | +-+ -// | | | | | +=v0060 -// b033 | | | +-+ -// | | | | +=v1472 -// b086 | | | | +-+ -// | | | | | +=v1536 -// b075 | | | | +-+ -// | | | | | | +=v1600 -// b087 | | | | | +-+ -// | | | | | +=v1728 -// b052 | | | +-+ -// | | | +=v0018 -// b010 | | +-+ -// | | | | +=v0024 -// b053 | | | | +-+ -// | | | | | | +=v0049 -// b076 | | | | | +-+ -// | | | | | +=v0050 -// b034 | | | | +-+ -// | | | | | | +=v0051 -// b077 | | | | | | +-+ -// | | | | | | | +=v0052 -// b054 | | | | | +-+ -// | | | | | +=v0025 -// b021 | | | +-+ -// | | | | +=v0055 -// b078 | | | | +-+ -// | | | | | +=v0056 -// b055 | | | | +-+ -// | | | | | | +=v0057 -// b079 | | | | | +-+ -// | | | | | +=v0058 -// b035 | | | +-+ -// | | | +=v0192 -// b005 | +-+ -// | | +=v1664 -// b036 | | +-+ -// | | | | +=v0448 -// b080 | | | | +-+ -// | | | | | +=v0512 -// b056 | | | +-+ -// | | | | +=v0704 -// b088 | | | | +-+ -// | | | | | +=v0768 -// b081 | | | +-+ -// | | | +=v0640 -// b022 | | +-+ -// | | | | +=v0576 -// b082 | | | | +-+ -// | | | | | | +=v0832 -// b089 | | | | | +-+ -// | | | | | +=v0896 -// b057 | | | | +-+ -// | | | | | | +=v0960 -// b090 | | | | | | +-+ -// | | | | | | | +=v1024 -// b083 | | | | | +-+ -// | | | | | | +=v1088 -// b091 | | | | | +-+ -// | | | | | +=v1152 -// b037 | | | +-+ -// | | | | +=v1216 -// b092 | | | | +-+ -// | | | | | +=v1280 -// b084 | | | | +-+ -// | | | | | | +=v1344 -// b093 | | | | | +-+ -// | | | | | +=v1408 -// b058 | | | +-+ -// | | | +=v0256 -// b011 | +-+ -// | +=v0002 -// b001 +-+ -// | +=v0003 -// b012 | +-+ -// | | | +=v0128 -// b023 | | +-+ -// | | +=v0008 -// b006 | +-+ -// | | | +=v0009 -// b024 | | | +-+ -// | | | | | +=v0016 -// b038 | | | | +-+ -// | | | | +=v0017 -// b013 | | +-+ -// | | +=v0004 -// b003 +-+ -// | +=v0005 -// b014 | +-+ -// | | | +=v0014 -// b039 | | | +-+ -// | | | | +=v0015 -// b025 | | +-+ -// | | +=v0064 -// b007 +-+ -// | +=v0006 -// b015 +-+ -// +=v0007 +// +=XXXXX +// b059 +-+ +// | | +=v1792 +// b096 | | +-+ +// | | | | +=v1984 +// b100 | | | +-+ +// | | | +=v2048 +// b094 | | +-+ +// | | | | +=v2112 +// b101 | | | | +-+ +// | | | | | +=v2176 +// b097 | | | +-+ +// | | | | +=v2240 +// b102 | | | +-+ +// | | | +=v2304 +// b085 | +-+ +// | | +=v1856 +// b098 | | +-+ +// | | | +=v1920 +// b095 | +-+ +// | | +=v2368 +// b103 | | +-+ +// | | | +=v2432 +// b099 | +-+ +// | | +=v2496 +// b104 | +-+ +// | +=v2560 +// b040 +-+ +// | | +=v0029 +// b060 | +-+ +// | +=v0030 +// b026 +-+ +// | | +=v0045 +// b061 | | +-+ +// | | | +=v0046 +// b041 | +-+ +// | +=v0022 +// b016 +-+ +// | | +=v0023 +// b042 | | +-+ +// | | | | +=v0047 +// b062 | | | +-+ +// | | | +=v0048 +// b027 | +-+ +// | +=v0013 +// b008 +-+ +// | | +=v0020 +// b043 | | +-+ +// | | | | +=v0033 +// b063 | | | +-+ +// | | | +=v0034 +// b028 | | +-+ +// | | | | +=v0035 +// b064 | | | | +-+ +// | | | | | +=v0036 +// b044 | | | +-+ +// | | | | +=v0037 +// b065 | | | +-+ +// | | | +=v0038 +// b017 | +-+ +// | | +=v0019 +// b045 | | +-+ +// | | | | +=v0031 +// b066 | | | +-+ +// | | | +=v0032 +// b029 | +-+ +// | +=v0001 +// b004 +-+ +// | | +=v0012 +// b030 | | +-+ +// | | | | +=v0053 +// b067 | | | | +-+ +// | | | | | +=v0054 +// b046 | | | +-+ +// | | | +=v0026 +// b018 | | +-+ +// | | | | +=v0039 +// b068 | | | | +-+ +// | | | | | +=v0040 +// b047 | | | | +-+ +// | | | | | | +=v0041 +// b069 | | | | | +-+ +// | | | | | +=v0042 +// b031 | | | +-+ +// | | | | +=v0043 +// b070 | | | | +-+ +// | | | | | +=v0044 +// b048 | | | +-+ +// | | | +=v0021 +// b009 | +-+ +// | | +=v0028 +// b049 | | +-+ +// | | | | +=v0061 +// b071 | | | +-+ +// | | | +=v0062 +// b032 | | +-+ +// | | | | +=v0063 +// b072 | | | | +-+ +// | | | | | +=v0000 +// b050 | | | +-+ +// | | | | +=v0320 +// b073 | | | +-+ +// | | | +=v0384 +// b019 | +-+ +// | +=v0010 +// b002 +-+ +// | | +=v0011 +// b020 | | +-+ +// | | | | +=v0027 +// b051 | | | | +-+ +// | | | | | | +=v0059 +// b074 | | | | | +-+ +// | | | | | +=v0060 +// b033 | | | +-+ +// | | | | +=v1472 +// b086 | | | | +-+ +// | | | | | +=v1536 +// b075 | | | | +-+ +// | | | | | | +=v1600 +// b087 | | | | | +-+ +// | | | | | +=v1728 +// b052 | | | +-+ +// | | | +=v0018 +// b010 | | +-+ +// | | | | +=v0024 +// b053 | | | | +-+ +// | | | | | | +=v0049 +// b076 | | | | | +-+ +// | | | | | +=v0050 +// b034 | | | | +-+ +// | | | | | | +=v0051 +// b077 | | | | | | +-+ +// | | | | | | | +=v0052 +// b054 | | | | | +-+ +// | | | | | +=v0025 +// b021 | | | +-+ +// | | | | +=v0055 +// b078 | | | | +-+ +// | | | | | +=v0056 +// b055 | | | | +-+ +// | | | | | | +=v0057 +// b079 | | | | | +-+ +// | | | | | +=v0058 +// b035 | | | +-+ +// | | | +=v0192 +// b005 | +-+ +// | | +=v1664 +// b036 | | +-+ +// | | | | +=v0448 +// b080 | | | | +-+ +// | | | | | +=v0512 +// b056 | | | +-+ +// | | | | +=v0704 +// b088 | | | | +-+ +// | | | | | +=v0768 +// b081 | | | +-+ +// | | | +=v0640 +// b022 | | +-+ +// | | | | +=v0576 +// b082 | | | | +-+ +// | | | | | | +=v0832 +// b089 | | | | | +-+ +// | | | | | +=v0896 +// b057 | | | | +-+ +// | | | | | | +=v0960 +// b090 | | | | | | +-+ +// | | | | | | | +=v1024 +// b083 | | | | | +-+ +// | | | | | | +=v1088 +// b091 | | | | | +-+ +// | | | | | +=v1152 +// b037 | | | +-+ +// | | | | +=v1216 +// b092 | | | | +-+ +// | | | | | +=v1280 +// b084 | | | | +-+ +// | | | | | | +=v1344 +// b093 | | | | | +-+ +// | | | | | +=v1408 +// b058 | | | +-+ +// | | | +=v0256 +// b011 | +-+ +// | +=v0002 +// b001 +-+ +// | +=v0003 +// b012 | +-+ +// | | | +=v0128 +// b023 | | +-+ +// | | +=v0008 +// b006 | +-+ +// | | | +=v0009 +// b024 | | | +-+ +// | | | | | +=v0016 +// b038 | | | | +-+ +// | | | | +=v0017 +// b013 | | +-+ +// | | +=v0004 +// b003 +-+ +// | +=v0005 +// b014 | +-+ +// | | | +=v0014 +// b039 | | | +-+ +// | | | | +=v0015 +// b025 | | +-+ +// | | +=v0064 +// b007 +-+ +// | +=v0006 +// b015 +-+ +// +=v0007 var whiteDecodeTable = [...][2]int16{ 0: {0, 0}, 1: {2, 3}, @@ -402,215 +387,215 @@ var whiteDecodeTable = [...][2]int16{ // blackDecodeTable represents Tables 2 and 3 for a black run. // -// +=XXXXX -// b017 +-+ -// | | +=v1792 -// b042 | | +-+ -// | | | | +=v1984 -// b063 | | | +-+ -// | | | +=v2048 -// b029 | | +-+ -// | | | | +=v2112 -// b064 | | | | +-+ -// | | | | | +=v2176 -// b043 | | | +-+ -// | | | | +=v2240 -// b065 | | | +-+ -// | | | +=v2304 -// b022 | +-+ -// | | +=v1856 -// b044 | | +-+ -// | | | +=v1920 -// b030 | +-+ -// | | +=v2368 -// b066 | | +-+ -// | | | +=v2432 -// b045 | +-+ -// | | +=v2496 -// b067 | +-+ -// | +=v2560 -// b013 +-+ -// | | +=v0018 -// b031 | | +-+ -// | | | | +=v0052 -// b068 | | | | +-+ -// | | | | | | +=v0640 -// b095 | | | | | +-+ -// | | | | | +=v0704 -// b046 | | | +-+ -// | | | | +=v0768 -// b096 | | | | +-+ -// | | | | | +=v0832 -// b069 | | | +-+ -// | | | +=v0055 -// b023 | | +-+ -// | | | | +=v0056 -// b070 | | | | +-+ -// | | | | | | +=v1280 -// b097 | | | | | +-+ -// | | | | | +=v1344 -// b047 | | | | +-+ -// | | | | | | +=v1408 -// b098 | | | | | | +-+ -// | | | | | | | +=v1472 -// b071 | | | | | +-+ -// | | | | | +=v0059 -// b032 | | | +-+ -// | | | | +=v0060 -// b072 | | | | +-+ -// | | | | | | +=v1536 -// b099 | | | | | +-+ -// | | | | | +=v1600 -// b048 | | | +-+ -// | | | +=v0024 -// b018 | +-+ -// | | +=v0025 -// b049 | | +-+ -// | | | | +=v1664 -// b100 | | | | +-+ -// | | | | | +=v1728 -// b073 | | | +-+ -// | | | +=v0320 -// b033 | | +-+ -// | | | | +=v0384 -// b074 | | | | +-+ -// | | | | | +=v0448 -// b050 | | | +-+ -// | | | | +=v0512 -// b101 | | | | +-+ -// | | | | | +=v0576 -// b075 | | | +-+ -// | | | +=v0053 -// b024 | +-+ -// | | +=v0054 -// b076 | | +-+ -// | | | | +=v0896 -// b102 | | | +-+ -// | | | +=v0960 -// b051 | | +-+ -// | | | | +=v1024 -// b103 | | | | +-+ -// | | | | | +=v1088 -// b077 | | | +-+ -// | | | | +=v1152 -// b104 | | | +-+ -// | | | +=v1216 -// b034 | +-+ -// | +=v0064 -// b010 +-+ -// | | +=v0013 -// b019 | | +-+ -// | | | | +=v0023 -// b052 | | | | +-+ -// | | | | | | +=v0050 -// b078 | | | | | +-+ -// | | | | | +=v0051 -// b035 | | | | +-+ -// | | | | | | +=v0044 -// b079 | | | | | | +-+ -// | | | | | | | +=v0045 -// b053 | | | | | +-+ -// | | | | | | +=v0046 -// b080 | | | | | +-+ -// | | | | | +=v0047 -// b025 | | | +-+ -// | | | | +=v0057 -// b081 | | | | +-+ -// | | | | | +=v0058 -// b054 | | | | +-+ -// | | | | | | +=v0061 -// b082 | | | | | +-+ -// | | | | | +=v0256 -// b036 | | | +-+ -// | | | +=v0016 -// b014 | +-+ -// | | +=v0017 -// b037 | | +-+ -// | | | | +=v0048 -// b083 | | | | +-+ -// | | | | | +=v0049 -// b055 | | | +-+ -// | | | | +=v0062 -// b084 | | | +-+ -// | | | +=v0063 -// b026 | | +-+ -// | | | | +=v0030 -// b085 | | | | +-+ -// | | | | | +=v0031 -// b056 | | | | +-+ -// | | | | | | +=v0032 -// b086 | | | | | +-+ -// | | | | | +=v0033 -// b038 | | | +-+ -// | | | | +=v0040 -// b087 | | | | +-+ -// | | | | | +=v0041 -// b057 | | | +-+ -// | | | +=v0022 -// b020 | +-+ -// | +=v0014 -// b008 +-+ -// | | +=v0010 -// b015 | | +-+ -// | | | +=v0011 -// b011 | +-+ -// | | +=v0015 -// b027 | | +-+ -// | | | | +=v0128 -// b088 | | | | +-+ -// | | | | | +=v0192 -// b058 | | | | +-+ -// | | | | | | +=v0026 -// b089 | | | | | +-+ -// | | | | | +=v0027 -// b039 | | | +-+ -// | | | | +=v0028 -// b090 | | | | +-+ -// | | | | | +=v0029 -// b059 | | | +-+ -// | | | +=v0019 -// b021 | | +-+ -// | | | | +=v0020 -// b060 | | | | +-+ -// | | | | | | +=v0034 -// b091 | | | | | +-+ -// | | | | | +=v0035 -// b040 | | | | +-+ -// | | | | | | +=v0036 -// b092 | | | | | | +-+ -// | | | | | | | +=v0037 -// b061 | | | | | +-+ -// | | | | | | +=v0038 -// b093 | | | | | +-+ -// | | | | | +=v0039 -// b028 | | | +-+ -// | | | | +=v0021 -// b062 | | | | +-+ -// | | | | | | +=v0042 -// b094 | | | | | +-+ -// | | | | | +=v0043 -// b041 | | | +-+ -// | | | +=v0000 -// b016 | +-+ -// | +=v0012 -// b006 +-+ -// | | +=v0009 -// b012 | | +-+ -// | | | +=v0008 -// b009 | +-+ -// | +=v0007 -// b004 +-+ -// | | +=v0006 -// b007 | +-+ -// | +=v0005 -// b002 +-+ -// | | +=v0001 -// b005 | +-+ -// | +=v0004 -// b001 +-+ -// | +=v0003 -// b003 +-+ -// +=v0002 +// +=XXXXX +// b017 +-+ +// | | +=v1792 +// b042 | | +-+ +// | | | | +=v1984 +// b063 | | | +-+ +// | | | +=v2048 +// b029 | | +-+ +// | | | | +=v2112 +// b064 | | | | +-+ +// | | | | | +=v2176 +// b043 | | | +-+ +// | | | | +=v2240 +// b065 | | | +-+ +// | | | +=v2304 +// b022 | +-+ +// | | +=v1856 +// b044 | | +-+ +// | | | +=v1920 +// b030 | +-+ +// | | +=v2368 +// b066 | | +-+ +// | | | +=v2432 +// b045 | +-+ +// | | +=v2496 +// b067 | +-+ +// | +=v2560 +// b013 +-+ +// | | +=v0018 +// b031 | | +-+ +// | | | | +=v0052 +// b068 | | | | +-+ +// | | | | | | +=v0640 +// b095 | | | | | +-+ +// | | | | | +=v0704 +// b046 | | | +-+ +// | | | | +=v0768 +// b096 | | | | +-+ +// | | | | | +=v0832 +// b069 | | | +-+ +// | | | +=v0055 +// b023 | | +-+ +// | | | | +=v0056 +// b070 | | | | +-+ +// | | | | | | +=v1280 +// b097 | | | | | +-+ +// | | | | | +=v1344 +// b047 | | | | +-+ +// | | | | | | +=v1408 +// b098 | | | | | | +-+ +// | | | | | | | +=v1472 +// b071 | | | | | +-+ +// | | | | | +=v0059 +// b032 | | | +-+ +// | | | | +=v0060 +// b072 | | | | +-+ +// | | | | | | +=v1536 +// b099 | | | | | +-+ +// | | | | | +=v1600 +// b048 | | | +-+ +// | | | +=v0024 +// b018 | +-+ +// | | +=v0025 +// b049 | | +-+ +// | | | | +=v1664 +// b100 | | | | +-+ +// | | | | | +=v1728 +// b073 | | | +-+ +// | | | +=v0320 +// b033 | | +-+ +// | | | | +=v0384 +// b074 | | | | +-+ +// | | | | | +=v0448 +// b050 | | | +-+ +// | | | | +=v0512 +// b101 | | | | +-+ +// | | | | | +=v0576 +// b075 | | | +-+ +// | | | +=v0053 +// b024 | +-+ +// | | +=v0054 +// b076 | | +-+ +// | | | | +=v0896 +// b102 | | | +-+ +// | | | +=v0960 +// b051 | | +-+ +// | | | | +=v1024 +// b103 | | | | +-+ +// | | | | | +=v1088 +// b077 | | | +-+ +// | | | | +=v1152 +// b104 | | | +-+ +// | | | +=v1216 +// b034 | +-+ +// | +=v0064 +// b010 +-+ +// | | +=v0013 +// b019 | | +-+ +// | | | | +=v0023 +// b052 | | | | +-+ +// | | | | | | +=v0050 +// b078 | | | | | +-+ +// | | | | | +=v0051 +// b035 | | | | +-+ +// | | | | | | +=v0044 +// b079 | | | | | | +-+ +// | | | | | | | +=v0045 +// b053 | | | | | +-+ +// | | | | | | +=v0046 +// b080 | | | | | +-+ +// | | | | | +=v0047 +// b025 | | | +-+ +// | | | | +=v0057 +// b081 | | | | +-+ +// | | | | | +=v0058 +// b054 | | | | +-+ +// | | | | | | +=v0061 +// b082 | | | | | +-+ +// | | | | | +=v0256 +// b036 | | | +-+ +// | | | +=v0016 +// b014 | +-+ +// | | +=v0017 +// b037 | | +-+ +// | | | | +=v0048 +// b083 | | | | +-+ +// | | | | | +=v0049 +// b055 | | | +-+ +// | | | | +=v0062 +// b084 | | | +-+ +// | | | +=v0063 +// b026 | | +-+ +// | | | | +=v0030 +// b085 | | | | +-+ +// | | | | | +=v0031 +// b056 | | | | +-+ +// | | | | | | +=v0032 +// b086 | | | | | +-+ +// | | | | | +=v0033 +// b038 | | | +-+ +// | | | | +=v0040 +// b087 | | | | +-+ +// | | | | | +=v0041 +// b057 | | | +-+ +// | | | +=v0022 +// b020 | +-+ +// | +=v0014 +// b008 +-+ +// | | +=v0010 +// b015 | | +-+ +// | | | +=v0011 +// b011 | +-+ +// | | +=v0015 +// b027 | | +-+ +// | | | | +=v0128 +// b088 | | | | +-+ +// | | | | | +=v0192 +// b058 | | | | +-+ +// | | | | | | +=v0026 +// b089 | | | | | +-+ +// | | | | | +=v0027 +// b039 | | | +-+ +// | | | | +=v0028 +// b090 | | | | +-+ +// | | | | | +=v0029 +// b059 | | | +-+ +// | | | +=v0019 +// b021 | | +-+ +// | | | | +=v0020 +// b060 | | | | +-+ +// | | | | | | +=v0034 +// b091 | | | | | +-+ +// | | | | | +=v0035 +// b040 | | | | +-+ +// | | | | | | +=v0036 +// b092 | | | | | | +-+ +// | | | | | | | +=v0037 +// b061 | | | | | +-+ +// | | | | | | +=v0038 +// b093 | | | | | +-+ +// | | | | | +=v0039 +// b028 | | | +-+ +// | | | | +=v0021 +// b062 | | | | +-+ +// | | | | | | +=v0042 +// b094 | | | | | +-+ +// | | | | | +=v0043 +// b041 | | | +-+ +// | | | +=v0000 +// b016 | +-+ +// | +=v0012 +// b006 +-+ +// | | +=v0009 +// b012 | | +-+ +// | | | +=v0008 +// b009 | +-+ +// | +=v0007 +// b004 +-+ +// | | +=v0006 +// b007 | +-+ +// | +=v0005 +// b002 +-+ +// | | +=v0001 +// b005 | +-+ +// | +=v0004 +// b001 +-+ +// | +=v0003 +// b003 +-+ +// +=v0002 var blackDecodeTable = [...][2]int16{ 0: {0, 0}, 1: {2, 3}, @@ -733,17 +718,16 @@ type bitString struct { // modeEncodeTable represents Table 1 and the End-of-Line code. var modeEncodeTable = [...]bitString{ - 0: {0x0001, 4}, // "0001" - 1: {0x0001, 3}, // "001" - 2: {0x0001, 1}, // "1" - 3: {0x0003, 3}, // "011" - 4: {0x0003, 6}, // "000011" - 5: {0x0003, 7}, // "0000011" - 6: {0x0002, 3}, // "010" - 7: {0x0002, 6}, // "000010" - 8: {0x0002, 7}, // "0000010" - 9: {0x0001, 7}, // "0000001" - 10: {0x0001, 12}, // "000000000001" + 0: {0x0001, 4}, // "0001" + 1: {0x0001, 3}, // "001" + 2: {0x0001, 1}, // "1" + 3: {0x0003, 3}, // "011" + 4: {0x0003, 6}, // "000011" + 5: {0x0003, 7}, // "0000011" + 6: {0x0002, 3}, // "010" + 7: {0x0002, 6}, // "000010" + 8: {0x0002, 7}, // "0000010" + 9: {0x0001, 7}, // "0000001" } // whiteEncodeTable2 represents Table 2 for a white run. @@ -983,7 +967,6 @@ const ( modeVL2 // Vertical-Left-2 modeVL3 // Vertical-Left-3 modeExt // Extension - modeEOL // End-of-Line ) // COPY PASTE table.go END diff --git a/server/vendor/golang.org/x/image/draw/draw_go117.go b/server/vendor/golang.org/x/image/draw/draw_go117.go new file mode 100644 index 000000000..fa8364864 --- /dev/null +++ b/server/vendor/golang.org/x/image/draw/draw_go117.go @@ -0,0 +1,27 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build go1.17 +// +build go1.17 + +package draw + +import ( + "image/draw" +) + +// The package documentation, in draw.go, gives the intent of this package: +// +// This package is a superset of and a drop-in replacement for the +// image/draw package in the standard library. +// +// "Drop-in replacement" means that we use type aliases in this file. +// +// TODO: move the type aliases to draw.go once Go 1.16 is no longer supported. + +// RGBA64Image extends both the Image and image.RGBA64Image interfaces with a +// SetRGBA64 method to change a single pixel. SetRGBA64 is equivalent to +// calling Set, but it can avoid allocations from converting concrete color +// types to the color.Color interface type. +type RGBA64Image = draw.RGBA64Image diff --git a/server/vendor/golang.org/x/image/draw/scale.go b/server/vendor/golang.org/x/image/draw/scale.go index 00121a129..ba1bdf3ce 100644 --- a/server/vendor/golang.org/x/image/draw/scale.go +++ b/server/vendor/golang.org/x/image/draw/scale.go @@ -46,8 +46,8 @@ type Scaler interface { // // For example, if m is the matrix // -// m00 m01 m02 -// m10 m11 m12 +// m00 m01 m02 +// m10 m11 m12 // // then the src-space point (sx, sy) maps to the dst-space point // (m00*sx + m01*sy + m02, m10*sx + m11*sy + m12). @@ -98,9 +98,9 @@ type Options struct { // have a 1:1 correspondence. // // Of the interpolators provided by this package: -// - NearestNeighbor is fast but usually looks worst. -// - CatmullRom is slow but usually looks best. -// - ApproxBiLinear has reasonable speed and quality. +// - NearestNeighbor is fast but usually looks worst. +// - CatmullRom is slow but usually looks best. +// - ApproxBiLinear has reasonable speed and quality. // // The time taken depends on the size of dr. For kernel interpolators, the // speed also depends on the size of sr, and so are often slower than diff --git a/server/vendor/golang.org/x/image/font/font.go b/server/vendor/golang.org/x/image/font/font.go index 4d9d63c24..d1a75350d 100644 --- a/server/vendor/golang.org/x/image/font/font.go +++ b/server/vendor/golang.org/x/image/font/font.go @@ -51,9 +51,11 @@ type Face interface { // // It returns !ok if the face does not contain a glyph for r. // - // The glyph's ascent and descent equal -bounds.Min.Y and +bounds.Max.Y. A - // visual depiction of what these metrics are is at - // https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/Art/glyph_metrics_2x.png + // The glyph's ascent and descent are equal to -bounds.Min.Y and + // +bounds.Max.Y. The glyph's left-side and right-side bearings are equal + // to bounds.Min.X and advance-bounds.Max.X. A visual depiction of what + // these metrics are is at + // https://developer.apple.com/library/archive/documentation/TextFonts/Conceptual/CocoaTextArchitecture/Art/glyphterms_2x.png GlyphBounds(r rune) (bounds fixed.Rectangle26_6, advance fixed.Int26_6, ok bool) // GlyphAdvance returns the advance width of r's glyph. diff --git a/server/vendor/golang.org/x/image/tiff/fuzz.go b/server/vendor/golang.org/x/image/tiff/fuzz.go index ec52c7882..b27c54004 100644 --- a/server/vendor/golang.org/x/image/tiff/fuzz.go +++ b/server/vendor/golang.org/x/image/tiff/fuzz.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build gofuzz // +build gofuzz package tiff diff --git a/server/vendor/golang.org/x/image/tiff/lzw/reader.go b/server/vendor/golang.org/x/image/tiff/lzw/reader.go index 78204ba92..1ccf5858a 100644 --- a/server/vendor/golang.org/x/image/tiff/lzw/reader.go +++ b/server/vendor/golang.org/x/image/tiff/lzw/reader.go @@ -3,8 +3,8 @@ // license that can be found in the LICENSE file. // Package lzw implements the Lempel-Ziv-Welch compressed data format, -// described in T. A. Welch, ``A Technique for High-Performance Data -// Compression'', Computer, 17(6) (June 1984), pp 8-19. +// described in T. A. Welch, “A Technique for High-Performance Data +// Compression”, Computer, 17(6) (June 1984), pp 8-19. // // In particular, it implements LZW as used by the TIFF file format, including // an "off by one" algorithmic difference when compared to standard LZW. @@ -30,7 +30,7 @@ Aldus "off by one" algorithm. The Go code doesn't read (invalid) TIFF files written by old versions of libtiff, but the LZW algorithm in this package still differs from the one in -Go's standard package library to accomodate this "off by one" in valid TIFFs. +Go's standard package library to accommodate this "off by one" in valid TIFFs. */ import ( diff --git a/server/vendor/golang.org/x/image/tiff/reader.go b/server/vendor/golang.org/x/image/tiff/reader.go index c26ec36bb..45cc056f4 100644 --- a/server/vendor/golang.org/x/image/tiff/reader.go +++ b/server/vendor/golang.org/x/image/tiff/reader.go @@ -38,6 +38,52 @@ func (e UnsupportedError) Error() string { var errNoPixels = FormatError("not enough pixel data") +const maxChunkSize = 10 << 20 // 10M + +// safeReadtAt is a verbatim copy of internal/saferio.ReadDataAt from the +// standard library, which is used to read data from a reader using a length +// provided by untrusted data, without allocating the entire slice ahead of time +// if it is large (>maxChunkSize). This allows us to avoid allocating giant +// slices before learning that we can't actually read that much data from the +// reader. +func safeReadAt(r io.ReaderAt, n uint64, off int64) ([]byte, error) { + if int64(n) < 0 || n != uint64(int(n)) { + // n is too large to fit in int, so we can't allocate + // a buffer large enough. Treat this as a read failure. + return nil, io.ErrUnexpectedEOF + } + + if n < maxChunkSize { + buf := make([]byte, n) + _, err := r.ReadAt(buf, off) + if err != nil { + // io.SectionReader can return EOF for n == 0, + // but for our purposes that is a success. + if err != io.EOF || n > 0 { + return nil, err + } + } + return buf, nil + } + + var buf []byte + buf1 := make([]byte, maxChunkSize) + for n > 0 { + next := n + if next > maxChunkSize { + next = maxChunkSize + } + _, err := r.ReadAt(buf1[:next], off) + if err != nil { + return nil, err + } + buf = append(buf, buf1[:next]...) + n -= next + off += int64(next) + } + return buf, nil +} + type decoder struct { r io.ReaderAt byteOrder binary.ByteOrder @@ -82,8 +128,7 @@ func (d *decoder) ifdUint(p []byte) (u []uint, err error) { } if datalen := lengths[datatype] * count; datalen > 4 { // The IFD contains a pointer to the real value. - raw = make([]byte, datalen) - _, err = d.r.ReadAt(raw, int64(d.byteOrder.Uint32(p[8:12]))) + raw, err = safeReadAt(d.r, uint64(datalen), int64(d.byteOrder.Uint32(p[8:12]))) } else { raw = p[8 : 8+datalen] } @@ -404,6 +449,9 @@ func newDecoder(r io.Reader) (*decoder, error) { p := make([]byte, 8) if _, err := d.r.ReadAt(p, 0); err != nil { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } return nil, err } switch string(p[0:4]) { @@ -424,8 +472,9 @@ func newDecoder(r io.Reader) (*decoder, error) { numItems := int(d.byteOrder.Uint16(p[0:2])) // All IFD entries are read in one chunk. - p = make([]byte, ifdLen*numItems) - if _, err := d.r.ReadAt(p, ifdOffset+2); err != nil { + var err error + p, err = safeReadAt(d.r, uint64(ifdLen*numItems), ifdOffset+2) + if err != nil { return nil, err } @@ -653,8 +702,7 @@ func Decode(r io.Reader) (img image.Image, err error) { if b, ok := d.r.(*buffer); ok { d.buf, err = b.Slice(int(offset), int(n)) } else { - d.buf = make([]byte, n) - _, err = d.r.ReadAt(d.buf, offset) + d.buf, err = safeReadAt(d.r, uint64(n), offset) } case cG3: inv := d.firstVal(tPhotometricInterpretation) == pWhiteIsZero diff --git a/server/vendor/golang.org/x/image/tiff/writer.go b/server/vendor/golang.org/x/image/tiff/writer.go index c8a01cea7..4272c5aa0 100644 --- a/server/vendor/golang.org/x/image/tiff/writer.go +++ b/server/vendor/golang.org/x/image/tiff/writer.go @@ -8,6 +8,7 @@ import ( "bytes" "compress/zlib" "encoding/binary" + "errors" "image" "io" "sort" @@ -338,6 +339,8 @@ func Encode(w io.Writer, m image.Image, opt *Options) error { } case cDeflate: dst = zlib.NewWriter(&buf) + default: + return errors.New("tiff: unsupported compression") } pr := uint32(prNone) diff --git a/server/vendor/modules.txt b/server/vendor/modules.txt index 75cb109b3..6d291a06a 100644 --- a/server/vendor/modules.txt +++ b/server/vendor/modules.txt @@ -489,7 +489,7 @@ golang.org/x/crypto/pbkdf2 golang.org/x/crypto/ripemd160 golang.org/x/crypto/scrypt golang.org/x/crypto/ssh/terminal -# golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 +# golang.org/x/image v0.5.0 ## explicit; go 1.12 golang.org/x/image/bmp golang.org/x/image/ccitt