Commit 17992f7a authored by Nigel Tao's avatar Nigel Tao

image/jpeg: rename some internal variables.

LGTM=dsymonds
R=dsymonds
CC=golang-codereviews
https://golang.org/cl/120980043
parent 5a008ace
...@@ -123,12 +123,11 @@ func (d *decoder) processSOS(n int) error { ...@@ -123,12 +123,11 @@ func (d *decoder) processSOS(n int) error {
// b is the decoded coefficients, in natural (not zig-zag) order. // b is the decoded coefficients, in natural (not zig-zag) order.
b block b block
dc [nColorComponent]int32 dc [nColorComponent]int32
// mx0 and my0 are the location of the current (in terms of 8x8 blocks). // bx and by are the location of the current (in terms of 8x8 blocks).
// For example, with 4:2:0 chroma subsampling, the block whose top left // For example, with 4:2:0 chroma subsampling, the block whose top left
// pixel co-ordinates are (16, 8) is the third block in the first row: // pixel co-ordinates are (16, 8) is the third block in the first row:
// mx0 is 2 and my0 is 0, even though the pixel is in the second MCU. // bx is 2 and by is 0, even though the pixel is in the second MCU.
// TODO(nigeltao): rename mx0 and my0 to bx and by? bx, by int
mx0, my0 int
blockCount int blockCount int
) )
for my := 0; my < myy; my++ { for my := 0; my < myy; my++ {
...@@ -163,26 +162,26 @@ func (d *decoder) processSOS(n int) error { ...@@ -163,26 +162,26 @@ func (d *decoder) processSOS(n int) error {
// 0 1 2 // 0 1 2
// 3 4 5 // 3 4 5
if nComp != 1 { if nComp != 1 {
mx0, my0 = d.comp[compIndex].h*mx, d.comp[compIndex].v*my bx, by = d.comp[compIndex].h*mx, d.comp[compIndex].v*my
if h0 == 1 { if h0 == 1 {
my0 += j by += j
} else { } else {
mx0 += j % 2 bx += j % 2
my0 += j / 2 by += j / 2
} }
} else { } else {
q := mxx * d.comp[compIndex].h q := mxx * d.comp[compIndex].h
mx0 = blockCount % q bx = blockCount % q
my0 = blockCount / q by = blockCount / q
blockCount++ blockCount++
if mx0*8 >= d.width || my0*8 >= d.height { if bx*8 >= d.width || by*8 >= d.height {
continue continue
} }
} }
// Load the previous partially decoded coefficients, if applicable. // Load the previous partially decoded coefficients, if applicable.
if d.progressive { if d.progressive {
b = d.progCoeffs[compIndex][my0*mxx*d.comp[compIndex].h+mx0] b = d.progCoeffs[compIndex][by*mxx*d.comp[compIndex].h+bx]
} else { } else {
b = block{} b = block{}
} }
...@@ -255,7 +254,7 @@ func (d *decoder) processSOS(n int) error { ...@@ -255,7 +254,7 @@ func (d *decoder) processSOS(n int) error {
if d.progressive { if d.progressive {
if zigEnd != blockSize-1 || al != 0 { if zigEnd != blockSize-1 || al != 0 {
// We haven't completely decoded this 8x8 block. Save the coefficients. // We haven't completely decoded this 8x8 block. Save the coefficients.
d.progCoeffs[compIndex][my0*mxx*d.comp[compIndex].h+mx0] = b d.progCoeffs[compIndex][by*mxx*d.comp[compIndex].h+bx] = b
// At this point, we could execute the rest of the loop body to dequantize and // At this point, we could execute the rest of the loop body to dequantize and
// perform the inverse DCT, to save early stages of a progressive image to the // perform the inverse DCT, to save early stages of a progressive image to the
// *image.YCbCr buffers (the whole point of progressive encoding), but in Go, // *image.YCbCr buffers (the whole point of progressive encoding), but in Go,
...@@ -272,15 +271,15 @@ func (d *decoder) processSOS(n int) error { ...@@ -272,15 +271,15 @@ func (d *decoder) processSOS(n int) error {
idct(&b) idct(&b)
dst, stride := []byte(nil), 0 dst, stride := []byte(nil), 0
if d.nComp == nGrayComponent { if d.nComp == nGrayComponent {
dst, stride = d.img1.Pix[8*(my0*d.img1.Stride+mx0):], d.img1.Stride dst, stride = d.img1.Pix[8*(by*d.img1.Stride+bx):], d.img1.Stride
} else { } else {
switch compIndex { switch compIndex {
case 0: case 0:
dst, stride = d.img3.Y[8*(my0*d.img3.YStride+mx0):], d.img3.YStride dst, stride = d.img3.Y[8*(by*d.img3.YStride+bx):], d.img3.YStride
case 1: case 1:
dst, stride = d.img3.Cb[8*(my0*d.img3.CStride+mx0):], d.img3.CStride dst, stride = d.img3.Cb[8*(by*d.img3.CStride+bx):], d.img3.CStride
case 2: case 2:
dst, stride = d.img3.Cr[8*(my0*d.img3.CStride+mx0):], d.img3.CStride dst, stride = d.img3.Cr[8*(by*d.img3.CStride+bx):], d.img3.CStride
default: default:
return UnsupportedError("too many components") return UnsupportedError("too many components")
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment