mirror of https://github.com/golang/go.git
image/color: order color computation to match rgb
The order of computation was switched unintentionally in https://go-review.googlesource.com/21910. Revert the order to first compute g then b. Change-Id: I8cedb5e45fbad2679246839f609bcac4f9052403 Reviewed-on: https://go-review.googlesource.com/22016 Reviewed-by: Nigel Tao <nigeltao@golang.org>
This commit is contained in:
parent
0da4dbe232
commit
8955745bfb
|
|
@ -60,7 +60,7 @@ func YCbCrToRGB(y, cb, cr uint8) (uint8, uint8, uint8) {
|
|||
// but uses fewer branches and is faster.
|
||||
// Note that the uint8 type conversion in the return
|
||||
// statement will convert ^int32(0) to 0xff.
|
||||
// The code below to compute b and g uses a similar pattern.
|
||||
// The code below to compute g and b uses a similar pattern.
|
||||
r := yy1 + 91881*cr1
|
||||
if uint32(r)&0xff000000 == 0 {
|
||||
r >>= 16
|
||||
|
|
@ -68,13 +68,6 @@ func YCbCrToRGB(y, cb, cr uint8) (uint8, uint8, uint8) {
|
|||
r = ^(r >> 31)
|
||||
}
|
||||
|
||||
b := yy1 + 116130*cb1
|
||||
if uint32(b)&0xff000000 == 0 {
|
||||
b >>= 16
|
||||
} else {
|
||||
b = ^(b >> 31)
|
||||
}
|
||||
|
||||
g := yy1 - 22554*cb1 - 46802*cr1
|
||||
if uint32(g)&0xff000000 == 0 {
|
||||
g >>= 16
|
||||
|
|
@ -82,6 +75,13 @@ func YCbCrToRGB(y, cb, cr uint8) (uint8, uint8, uint8) {
|
|||
g = ^(g >> 31)
|
||||
}
|
||||
|
||||
b := yy1 + 116130*cb1
|
||||
if uint32(b)&0xff000000 == 0 {
|
||||
b >>= 16
|
||||
} else {
|
||||
b = ^(b >> 31)
|
||||
}
|
||||
|
||||
return uint8(r), uint8(g), uint8(b)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ const sratioCase = `
|
|||
// but uses fewer branches and is faster.
|
||||
// Note that the uint8 type conversion in the return
|
||||
// statement will convert ^int32(0) to 0xff.
|
||||
// The code below to compute b and g uses a similar pattern.
|
||||
// The code below to compute g and b uses a similar pattern.
|
||||
r := yy1 + 91881*cr1
|
||||
if uint32(r)&0xff000000 == 0 {
|
||||
r >>= 16
|
||||
|
|
@ -119,13 +119,6 @@ const sratioCase = `
|
|||
r = ^(r >> 31)
|
||||
}
|
||||
|
||||
b := yy1 + 116130*cb1
|
||||
if uint32(b)&0xff000000 == 0 {
|
||||
b >>= 16
|
||||
} else {
|
||||
b = ^(b >> 31)
|
||||
}
|
||||
|
||||
g := yy1 - 22554*cb1 - 46802*cr1
|
||||
if uint32(g)&0xff000000 == 0 {
|
||||
g >>= 16
|
||||
|
|
@ -133,6 +126,13 @@ const sratioCase = `
|
|||
g = ^(g >> 31)
|
||||
}
|
||||
|
||||
b := yy1 + 116130*cb1
|
||||
if uint32(b)&0xff000000 == 0 {
|
||||
b >>= 16
|
||||
} else {
|
||||
b = ^(b >> 31)
|
||||
}
|
||||
|
||||
dpix[x+0] = uint8(r)
|
||||
dpix[x+1] = uint8(g)
|
||||
dpix[x+2] = uint8(b)
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func DrawYCbCr(dst *image.RGBA, r image.Rectangle, src *image.YCbCr, sp image.Po
|
|||
// but uses fewer branches and is faster.
|
||||
// Note that the uint8 type conversion in the return
|
||||
// statement will convert ^int32(0) to 0xff.
|
||||
// The code below to compute b and g uses a similar pattern.
|
||||
// The code below to compute g and b uses a similar pattern.
|
||||
r := yy1 + 91881*cr1
|
||||
if uint32(r)&0xff000000 == 0 {
|
||||
r >>= 16
|
||||
|
|
@ -68,13 +68,6 @@ func DrawYCbCr(dst *image.RGBA, r image.Rectangle, src *image.YCbCr, sp image.Po
|
|||
r = ^(r >> 31)
|
||||
}
|
||||
|
||||
b := yy1 + 116130*cb1
|
||||
if uint32(b)&0xff000000 == 0 {
|
||||
b >>= 16
|
||||
} else {
|
||||
b = ^(b >> 31)
|
||||
}
|
||||
|
||||
g := yy1 - 22554*cb1 - 46802*cr1
|
||||
if uint32(g)&0xff000000 == 0 {
|
||||
g >>= 16
|
||||
|
|
@ -82,6 +75,13 @@ func DrawYCbCr(dst *image.RGBA, r image.Rectangle, src *image.YCbCr, sp image.Po
|
|||
g = ^(g >> 31)
|
||||
}
|
||||
|
||||
b := yy1 + 116130*cb1
|
||||
if uint32(b)&0xff000000 == 0 {
|
||||
b >>= 16
|
||||
} else {
|
||||
b = ^(b >> 31)
|
||||
}
|
||||
|
||||
dpix[x+0] = uint8(r)
|
||||
dpix[x+1] = uint8(g)
|
||||
dpix[x+2] = uint8(b)
|
||||
|
|
@ -115,7 +115,7 @@ func DrawYCbCr(dst *image.RGBA, r image.Rectangle, src *image.YCbCr, sp image.Po
|
|||
// but uses fewer branches and is faster.
|
||||
// Note that the uint8 type conversion in the return
|
||||
// statement will convert ^int32(0) to 0xff.
|
||||
// The code below to compute b and g uses a similar pattern.
|
||||
// The code below to compute g and b uses a similar pattern.
|
||||
r := yy1 + 91881*cr1
|
||||
if uint32(r)&0xff000000 == 0 {
|
||||
r >>= 16
|
||||
|
|
@ -123,13 +123,6 @@ func DrawYCbCr(dst *image.RGBA, r image.Rectangle, src *image.YCbCr, sp image.Po
|
|||
r = ^(r >> 31)
|
||||
}
|
||||
|
||||
b := yy1 + 116130*cb1
|
||||
if uint32(b)&0xff000000 == 0 {
|
||||
b >>= 16
|
||||
} else {
|
||||
b = ^(b >> 31)
|
||||
}
|
||||
|
||||
g := yy1 - 22554*cb1 - 46802*cr1
|
||||
if uint32(g)&0xff000000 == 0 {
|
||||
g >>= 16
|
||||
|
|
@ -137,6 +130,13 @@ func DrawYCbCr(dst *image.RGBA, r image.Rectangle, src *image.YCbCr, sp image.Po
|
|||
g = ^(g >> 31)
|
||||
}
|
||||
|
||||
b := yy1 + 116130*cb1
|
||||
if uint32(b)&0xff000000 == 0 {
|
||||
b >>= 16
|
||||
} else {
|
||||
b = ^(b >> 31)
|
||||
}
|
||||
|
||||
dpix[x+0] = uint8(r)
|
||||
dpix[x+1] = uint8(g)
|
||||
dpix[x+2] = uint8(b)
|
||||
|
|
@ -170,7 +170,7 @@ func DrawYCbCr(dst *image.RGBA, r image.Rectangle, src *image.YCbCr, sp image.Po
|
|||
// but uses fewer branches and is faster.
|
||||
// Note that the uint8 type conversion in the return
|
||||
// statement will convert ^int32(0) to 0xff.
|
||||
// The code below to compute b and g uses a similar pattern.
|
||||
// The code below to compute g and b uses a similar pattern.
|
||||
r := yy1 + 91881*cr1
|
||||
if uint32(r)&0xff000000 == 0 {
|
||||
r >>= 16
|
||||
|
|
@ -178,13 +178,6 @@ func DrawYCbCr(dst *image.RGBA, r image.Rectangle, src *image.YCbCr, sp image.Po
|
|||
r = ^(r >> 31)
|
||||
}
|
||||
|
||||
b := yy1 + 116130*cb1
|
||||
if uint32(b)&0xff000000 == 0 {
|
||||
b >>= 16
|
||||
} else {
|
||||
b = ^(b >> 31)
|
||||
}
|
||||
|
||||
g := yy1 - 22554*cb1 - 46802*cr1
|
||||
if uint32(g)&0xff000000 == 0 {
|
||||
g >>= 16
|
||||
|
|
@ -192,6 +185,13 @@ func DrawYCbCr(dst *image.RGBA, r image.Rectangle, src *image.YCbCr, sp image.Po
|
|||
g = ^(g >> 31)
|
||||
}
|
||||
|
||||
b := yy1 + 116130*cb1
|
||||
if uint32(b)&0xff000000 == 0 {
|
||||
b >>= 16
|
||||
} else {
|
||||
b = ^(b >> 31)
|
||||
}
|
||||
|
||||
dpix[x+0] = uint8(r)
|
||||
dpix[x+1] = uint8(g)
|
||||
dpix[x+2] = uint8(b)
|
||||
|
|
@ -224,7 +224,7 @@ func DrawYCbCr(dst *image.RGBA, r image.Rectangle, src *image.YCbCr, sp image.Po
|
|||
// but uses fewer branches and is faster.
|
||||
// Note that the uint8 type conversion in the return
|
||||
// statement will convert ^int32(0) to 0xff.
|
||||
// The code below to compute b and g uses a similar pattern.
|
||||
// The code below to compute g and b uses a similar pattern.
|
||||
r := yy1 + 91881*cr1
|
||||
if uint32(r)&0xff000000 == 0 {
|
||||
r >>= 16
|
||||
|
|
@ -232,13 +232,6 @@ func DrawYCbCr(dst *image.RGBA, r image.Rectangle, src *image.YCbCr, sp image.Po
|
|||
r = ^(r >> 31)
|
||||
}
|
||||
|
||||
b := yy1 + 116130*cb1
|
||||
if uint32(b)&0xff000000 == 0 {
|
||||
b >>= 16
|
||||
} else {
|
||||
b = ^(b >> 31)
|
||||
}
|
||||
|
||||
g := yy1 - 22554*cb1 - 46802*cr1
|
||||
if uint32(g)&0xff000000 == 0 {
|
||||
g >>= 16
|
||||
|
|
@ -246,6 +239,13 @@ func DrawYCbCr(dst *image.RGBA, r image.Rectangle, src *image.YCbCr, sp image.Po
|
|||
g = ^(g >> 31)
|
||||
}
|
||||
|
||||
b := yy1 + 116130*cb1
|
||||
if uint32(b)&0xff000000 == 0 {
|
||||
b >>= 16
|
||||
} else {
|
||||
b = ^(b >> 31)
|
||||
}
|
||||
|
||||
dpix[x+0] = uint8(r)
|
||||
dpix[x+1] = uint8(g)
|
||||
dpix[x+2] = uint8(b)
|
||||
|
|
|
|||
Loading…
Reference in New Issue