~shabbyrobe/grugdct

2eb151997f5fc678e42a9b575dbcfa8ddfa55044 — Blake Williams 1 year, 8 months ago 6c0c1c5
Bit more consistency
4 files changed, 24 insertions(+), 14 deletions(-)

M basic_8x8.go
M basic_std.go
M cachedcos_8x8.go
M cachedcos_std.go
M basic_8x8.go => basic_8x8.go +7 -4
@@ 28,7 28,7 @@ func (bas Basic8x8) DCT8x8Into(img Image, xpos int, ypos int, mat *Matrix8x8F32)
	const scale = 0.25                           // 1 / (sqrt(8*8) / 2)
	const piDivByDoubleDim = 0.19634954084936207 // pi / 8*2

	for v, voff := 0, 0; v < 8; v, voff = v+1, voff+8 {
	for v, mi := 0, 0; v < 8; v++ {
		for u := 0; u < 8; u++ {
			var z float32



@@ 53,7 53,8 @@ func (bas Basic8x8) DCT8x8Into(img Image, xpos int, ypos int, mat *Matrix8x8F32)
			if v == 0 {
				q *= oneOverSqrt2
			}
			mat[voff+u] = q
			mat[mi] = q
			mi++
		}
	}
}


@@ 67,9 68,11 @@ func (bas Basic8x8) IDCT8x8Into(mat *Matrix8x8F32, xpos int, ypos int, into Imag
		for x := 0; x < 8; x++ {
			var z float32

			for v, voff := 0, 0; v < 8; v, voff = v+1, voff+8 {
			for v, mi := 0, 0; v < 8; v++ {
				for u := 0; u < 8; u++ {
					s := mat[voff+u]
					s := mat[mi]
					mi++

					q := s *
						float32(math.Cos(float64(2*x+1)*float64(u)*piDivByDoubleDim)) *
						float32(math.Cos(float64(2*y+1)*float64(v)*piDivByDoubleDim))

M basic_std.go => basic_std.go +7 -4
@@ 40,7 40,7 @@ func (bas Basic) DCTInto(img Image, xpos int, ypos int, mat MatrixF64) {

	w, h := bas.W, bas.H

	for v, voff := 0, 0; v < h; v, voff = v+1, voff+bas.W {
	for v, mi := 0, 0; v < h; v++ {
		for u := 0; u < w; u++ {
			var z float64



@@ 65,7 65,8 @@ func (bas Basic) DCTInto(img Image, xpos int, ypos int, mat MatrixF64) {
			if v == 0 {
				q *= oneOverSqrt2
			}
			mat.V[voff+u] = q
			mat.V[mi] = q
			mi++
		}
	}
}


@@ 79,9 80,11 @@ func (bas Basic) IDCTInto(mat MatrixF64, xpos int, ypos int, into Image) {
		for x := 0; x < w; x++ {
			var z float64

			for v, voff := 0, 0; v < h; v, voff = v+1, voff+bas.W {
			for v, mi := 0, 0; v < h; v++ {
				for u := 0; u < w; u++ {
					s := mat.V[voff+u]
					s := mat.V[mi]
					mi++

					q := s *
						math.Cos(float64(2*x+1)*float64(u)*bas.piDivByDoubleWidth) *
						math.Cos(float64(2*y+1)*float64(v)*bas.piDivByDoubleHeight)

M cachedcos_8x8.go => cachedcos_8x8.go +3 -2
@@ 69,9 69,10 @@ func (cos CachedCosines8x8) IDCT8x8Into(mat *Matrix8x8F32, xpos int, ypos int, i
		for x := 0; x < 8; x++ {
			var z float32

			for v, voff := 0, 0; v < 8; v, voff = v+1, voff+8 {
			for v, mi := 0, 0; v < 8; v++ {
				for u := 0; u < 8; u++ {
					s := mat[voff+u]
					s := mat[mi]
					mi++
					q := s * cosines8x8LUT32[x][u] * cosines8x8LUT32[y][v]
					if u == 0 {
						q *= oneOverSqrt2

M cachedcos_std.go => cachedcos_std.go +7 -4
@@ 73,7 73,7 @@ func (cos CachedCosines) DCTInto(img Image, xpos int, ypos int, mat MatrixF64) {

	w, h := cos.W, cos.H

	for v, voff := 0, 0; v < h; v, voff = v+1, voff+w {
	for v, mi := 0, 0; v < h; v++ {
		for u := 0; u < w; u++ {
			var z float64
			for y := 0; y < h; y++ {


@@ 93,7 93,8 @@ func (cos CachedCosines) DCTInto(img Image, xpos int, ypos int, mat MatrixF64) {
			if v == 0 {
				q *= oneOverSqrt2
			}
			mat.V[voff+u] = q
			mat.V[mi] = q
			mi++
		}
	}
}


@@ 107,9 108,11 @@ func (dct CachedCosines) IDCTInto(mat MatrixF64, xpos int, ypos int, into Image)
		for x := 0; x < w; x++ {
			var z float64

			for v, voff := 0, 0; v < h; v, voff = v+1, voff+dct.W {
			for v, mi := 0, 0; v < h; v++ {
				for u := 0; u < w; u++ {
					s := mat.V[voff+u]
					s := mat.V[mi]
					mi++

					q := s * dct.wcos[u*w+x] * dct.hcos[v*h+y]
					if u == 0 {
						q *= oneOverSqrt2