func benchmarkDCT(b *testing.B, f func(*block)) { … } func BenchmarkFDCT(b *testing.B) { … } func BenchmarkIDCT(b *testing.B) { … } func TestDCT(t *testing.T) { … } // differ reports whether any pair-wise elements in b0 and b1 differ by 2 or // more. That tolerance is because there isn't a single definitive decoding of // a given JPEG image, even before the YCbCr to RGB conversion; implementations // can have different IDCT rounding errors. func differ(b0, b1 *block) bool { … } // alpha returns 1 if i is 0 and returns √2 otherwise. func alpha(i int) float64 { … } var cosines … func init() { … } // slowFDCT performs the 8*8 2-dimensional forward discrete cosine transform: // // dst[u,v] = (1/8) * Σ_x Σ_y alpha(u) * alpha(v) * src[x,y] * // cos((π/2) * (2*x + 1) * u / 8) * // cos((π/2) * (2*y + 1) * v / 8) // // x and y are in pixel space, and u and v are in transform space. // // b acts as both dst and src. func slowFDCT(b *block) { … } // slowIDCT performs the 8*8 2-dimensional inverse discrete cosine transform: // // dst[x,y] = (1/8) * Σ_u Σ_v alpha(u) * alpha(v) * src[u,v] * // cos((π/2) * (2*x + 1) * u / 8) * // cos((π/2) * (2*y + 1) * v / 8) // // x and y are in pixel space, and u and v are in transform space. // // b acts as both dst and src. func slowIDCT(b *block) { … } func (b *block) String() string { … } var testBlocks …