Update to go1.24.0
This commit is contained in:
@@ -80,7 +80,7 @@ func printPlan9(w io.Writer) {
|
||||
}
|
||||
fmt.Fprintln(w, "// Plan9 is a 256-color palette that partitions the 24-bit RGB space")
|
||||
fmt.Fprintln(w, "// into 4×4×4 subdivision, with 4 shades in each subcube. Compared to the")
|
||||
fmt.Fprintln(w, "// WebSafe, the idea is to reduce the color resolution by dicing the")
|
||||
fmt.Fprintln(w, "// [WebSafe], the idea is to reduce the color resolution by dicing the")
|
||||
fmt.Fprintln(w, "// color cube into fewer cells, and to use the extra space to increase the")
|
||||
fmt.Fprintln(w, "// intensity resolution. This results in 16 gray shades (4 gray subcubes with")
|
||||
fmt.Fprintln(w, "// 4 samples in each), 13 shades of each primary and secondary color (3")
|
||||
|
||||
@@ -169,7 +169,7 @@ func (r Rectangle) Intersect(s Rectangle) Rectangle {
|
||||
//
|
||||
// if max(r0.Min.X, s0.Min.X) >= min(r0.Max.X, s0.Max.X) || likewiseForY { etc }
|
||||
if r.Empty() {
|
||||
return ZR
|
||||
return Rectangle{}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -146,8 +146,8 @@ func (e *encoder) writeHeader() {
|
||||
}
|
||||
|
||||
// Logical screen width and height.
|
||||
byteorder.LePutUint16(e.buf[0:2], uint16(e.g.Config.Width))
|
||||
byteorder.LePutUint16(e.buf[2:4], uint16(e.g.Config.Height))
|
||||
byteorder.LEPutUint16(e.buf[0:2], uint16(e.g.Config.Width))
|
||||
byteorder.LEPutUint16(e.buf[2:4], uint16(e.g.Config.Height))
|
||||
e.write(e.buf[:4])
|
||||
|
||||
if p, ok := e.g.Config.ColorModel.(color.Palette); ok && len(p) > 0 {
|
||||
@@ -185,7 +185,7 @@ func (e *encoder) writeHeader() {
|
||||
}
|
||||
e.buf[0] = 0x03 // Block Size.
|
||||
e.buf[1] = 0x01 // Sub-block Index.
|
||||
byteorder.LePutUint16(e.buf[2:4], uint16(e.g.LoopCount))
|
||||
byteorder.LEPutUint16(e.buf[2:4], uint16(e.g.LoopCount))
|
||||
e.buf[4] = 0x00 // Block Terminator.
|
||||
e.write(e.buf[:5])
|
||||
}
|
||||
@@ -271,7 +271,7 @@ func (e *encoder) writeImageBlock(pm *image.Paletted, delay int, disposal byte)
|
||||
} else {
|
||||
e.buf[3] = 0x00 | disposal<<2
|
||||
}
|
||||
byteorder.LePutUint16(e.buf[4:6], uint16(delay)) // Delay Time (1/100ths of a second)
|
||||
byteorder.LEPutUint16(e.buf[4:6], uint16(delay)) // Delay Time (1/100ths of a second)
|
||||
|
||||
// Transparent color index.
|
||||
if transparentIndex != -1 {
|
||||
@@ -283,10 +283,10 @@ func (e *encoder) writeImageBlock(pm *image.Paletted, delay int, disposal byte)
|
||||
e.write(e.buf[:8])
|
||||
}
|
||||
e.buf[0] = sImageDescriptor
|
||||
byteorder.LePutUint16(e.buf[1:3], uint16(b.Min.X))
|
||||
byteorder.LePutUint16(e.buf[3:5], uint16(b.Min.Y))
|
||||
byteorder.LePutUint16(e.buf[5:7], uint16(b.Dx()))
|
||||
byteorder.LePutUint16(e.buf[7:9], uint16(b.Dy()))
|
||||
byteorder.LEPutUint16(e.buf[1:3], uint16(b.Min.X))
|
||||
byteorder.LEPutUint16(e.buf[3:5], uint16(b.Min.Y))
|
||||
byteorder.LEPutUint16(e.buf[5:7], uint16(b.Dx()))
|
||||
byteorder.LEPutUint16(e.buf[7:9], uint16(b.Dy()))
|
||||
e.write(e.buf[:9])
|
||||
|
||||
// To determine whether or not this frame's palette is the same as the
|
||||
|
||||
@@ -112,12 +112,42 @@ func alpha(i int) float64 {
|
||||
return math.Sqrt2
|
||||
}
|
||||
|
||||
var cosines [32]float64 // cosines[k] = cos(π/2 * k/8)
|
||||
var cosines = [32]float64{
|
||||
+1.0000000000000000000000000000000000000000000000000000000000000000, // cos(π/16 * 0)
|
||||
+0.9807852804032304491261822361342390369739337308933360950029160885, // cos(π/16 * 1)
|
||||
+0.9238795325112867561281831893967882868224166258636424861150977312, // cos(π/16 * 2)
|
||||
+0.8314696123025452370787883776179057567385608119872499634461245902, // cos(π/16 * 3)
|
||||
+0.7071067811865475244008443621048490392848359376884740365883398689, // cos(π/16 * 4)
|
||||
+0.5555702330196022247428308139485328743749371907548040459241535282, // cos(π/16 * 5)
|
||||
+0.3826834323650897717284599840303988667613445624856270414338006356, // cos(π/16 * 6)
|
||||
+0.1950903220161282678482848684770222409276916177519548077545020894, // cos(π/16 * 7)
|
||||
|
||||
func init() {
|
||||
for k := range cosines {
|
||||
cosines[k] = math.Cos(math.Pi * float64(k) / 16)
|
||||
}
|
||||
-0.0000000000000000000000000000000000000000000000000000000000000000, // cos(π/16 * 8)
|
||||
-0.1950903220161282678482848684770222409276916177519548077545020894, // cos(π/16 * 9)
|
||||
-0.3826834323650897717284599840303988667613445624856270414338006356, // cos(π/16 * 10)
|
||||
-0.5555702330196022247428308139485328743749371907548040459241535282, // cos(π/16 * 11)
|
||||
-0.7071067811865475244008443621048490392848359376884740365883398689, // cos(π/16 * 12)
|
||||
-0.8314696123025452370787883776179057567385608119872499634461245902, // cos(π/16 * 13)
|
||||
-0.9238795325112867561281831893967882868224166258636424861150977312, // cos(π/16 * 14)
|
||||
-0.9807852804032304491261822361342390369739337308933360950029160885, // cos(π/16 * 15)
|
||||
|
||||
-1.0000000000000000000000000000000000000000000000000000000000000000, // cos(π/16 * 16)
|
||||
-0.9807852804032304491261822361342390369739337308933360950029160885, // cos(π/16 * 17)
|
||||
-0.9238795325112867561281831893967882868224166258636424861150977312, // cos(π/16 * 18)
|
||||
-0.8314696123025452370787883776179057567385608119872499634461245902, // cos(π/16 * 19)
|
||||
-0.7071067811865475244008443621048490392848359376884740365883398689, // cos(π/16 * 20)
|
||||
-0.5555702330196022247428308139485328743749371907548040459241535282, // cos(π/16 * 21)
|
||||
-0.3826834323650897717284599840303988667613445624856270414338006356, // cos(π/16 * 22)
|
||||
-0.1950903220161282678482848684770222409276916177519548077545020894, // cos(π/16 * 23)
|
||||
|
||||
+0.0000000000000000000000000000000000000000000000000000000000000000, // cos(π/16 * 24)
|
||||
+0.1950903220161282678482848684770222409276916177519548077545020894, // cos(π/16 * 25)
|
||||
+0.3826834323650897717284599840303988667613445624856270414338006356, // cos(π/16 * 26)
|
||||
+0.5555702330196022247428308139485328743749371907548040459241535282, // cos(π/16 * 27)
|
||||
+0.7071067811865475244008443621048490392848359376884740365883398689, // cos(π/16 * 28)
|
||||
+0.8314696123025452370787883776179057567385608119872499634461245902, // cos(π/16 * 29)
|
||||
+0.9238795325112867561281831893967882868224166258636424861150977312, // cos(π/16 * 30)
|
||||
+0.9807852804032304491261822361342390369739337308933360950029160885, // cos(π/16 * 31)
|
||||
}
|
||||
|
||||
// slowFDCT performs the 8*8 2-dimensional forward discrete cosine transform:
|
||||
|
||||
@@ -50,8 +50,8 @@ const (
|
||||
|
||||
// unscaledQuant are the unscaled quantization tables in zig-zag order. Each
|
||||
// encoder copies and scales the tables according to its quality parameter.
|
||||
// The values are derived from section K.1 after converting from natural to
|
||||
// zig-zag order.
|
||||
// The values are derived from section K.1 of the spec, after converting from
|
||||
// natural to zig-zag order.
|
||||
var unscaledQuant = [nQuantIndex][blockSize]byte{
|
||||
// Luminance.
|
||||
{
|
||||
@@ -89,14 +89,22 @@ const (
|
||||
|
||||
// huffmanSpec specifies a Huffman encoding.
|
||||
type huffmanSpec struct {
|
||||
// count[i] is the number of codes of length i bits.
|
||||
// count[i] is the number of codes of length i+1 bits.
|
||||
count [16]byte
|
||||
// value[i] is the decoded value of the i'th codeword.
|
||||
value []byte
|
||||
}
|
||||
|
||||
// theHuffmanSpec is the Huffman encoding specifications.
|
||||
// This encoder uses the same Huffman encoding for all images.
|
||||
//
|
||||
// This encoder uses the same Huffman encoding for all images. It is also the
|
||||
// same Huffman encoding used by section K.3 of the spec.
|
||||
//
|
||||
// The DC tables have 12 decoded values, called categories.
|
||||
//
|
||||
// The AC tables have 162 decoded values: bytes that pack a 4-bit Run and a
|
||||
// 4-bit Size. There are 16 valid Runs and 10 valid Sizes, plus two special R|S
|
||||
// cases: 0|0 (meaning EOB) and F|0 (meaning ZRL).
|
||||
var theHuffmanSpec = [nHuffIndex]huffmanSpec{
|
||||
// Luminance DC.
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user