mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
lib/lowleveljpeg: s/ExtractFrom/ExtractYCbCrFrom/
This commit is contained in:
1 parent
979a9d898c
commit
c400a47bb9
6 files changed
+19
-19
No files matched your search
@@ -293,7 +293,7 @@ func Encode(w io.Writer, src image.Image, options *EncodeOptions) error {
|
||||
alphasQuadBlock := lowleveljpeg.QuadBlockU8{}
|
||||
dst := scaleSrc(src, &alphasQuadBlock)
|
||||
dstU8s := lowleveljpeg.Array6BlockU8{}
|
||||
dstU8s.ExtractFrom(dst, 0, 0)
|
||||
dstU8s.ExtractYCbCrFrom(dst, 0, 0)
|
||||
|
||||
// Biasing the Chroma blocks by +8 shifts the neutral (gray) Chroma values
|
||||
// from 0x80 to 0x88. DC coefficient bias-and-quantization can losslessly
|
||||
|
||||
@@ -55,7 +55,7 @@ func Example_basic() {
|
||||
srcI16s := lowleveljpeg.Array6BlockI16{}
|
||||
for y := bounds.Min.Y; y < bounds.Max.Y; y += dy {
|
||||
for x := bounds.Min.X; x < bounds.Max.X; x += dx {
|
||||
srcU8s.ExtractFrom(src, x, y)
|
||||
srcU8s.ExtractYCbCrFrom(src, x, y)
|
||||
srcI16s.ForwardDCTFrom(&srcU8s)
|
||||
if err := enc.Add6(buf, &srcI16s); err != nil {
|
||||
log.Fatalf("enc.Add6: %v", err)
|
||||
|
||||
@@ -172,7 +172,7 @@ func Example_yCbCr444() {
|
||||
srcI16s := lowleveljpeg.Array3BlockI16{}
|
||||
for y := bounds.Min.Y; y < bounds.Max.Y; y += 8 {
|
||||
for x := bounds.Min.X; x < bounds.Max.X; x += 8 {
|
||||
srcU8s.ExtractFrom(src, x, y)
|
||||
srcU8s.ExtractYCbCrFrom(src, x, y)
|
||||
example.transform(&srcI16s, &srcU8s)
|
||||
if err := enc.Add3(buf, &srcI16s); err != nil {
|
||||
log.Fatalf("enc.Add3: %v", err)
|
||||
|
||||
+11
-11
@@ -15,9 +15,9 @@ import (
|
||||
"image/color"
|
||||
)
|
||||
|
||||
// ExtractFrom sets dst to a single channel (Gray) 8×8 MCU (Minimum Coded
|
||||
// ExtractYCbCrFrom sets dst to a single channel (Gray) 8×8 MCU (Minimum Coded
|
||||
// Unit), with the given top-left corner, from the image m.
|
||||
func (dst *Array1BlockU8) ExtractFrom(m image.Image, topLeftX int, topLeftY int) {
|
||||
func (dst *Array1BlockU8) ExtractYCbCrFrom(m image.Image, topLeftX int, topLeftY int) {
|
||||
if dst == nil {
|
||||
return
|
||||
}
|
||||
@@ -57,10 +57,10 @@ func (dst *Array1BlockU8) ExtractFrom(m image.Image, topLeftX int, topLeftY int)
|
||||
fillRightAndDown(&dst[0], topLeftX, topLeftY, bounds.Max.X, bounds.Max.Y)
|
||||
}
|
||||
|
||||
// ExtractFrom sets dst to a three channel (Luma, Chroma-blue, Chroma-red) 8×8
|
||||
// 4:4:4 MCU (Minimum Coded Unit), with the given top-left corner, from the
|
||||
// ExtractYCbCrFrom sets dst to a three channel (Luma, Chroma-blue, Chroma-red)
|
||||
// 8×8 4:4:4 MCU (Minimum Coded Unit), with the given top-left corner, from the
|
||||
// image m.
|
||||
func (dst *Array3BlockU8) ExtractFrom(m image.Image, topLeftX int, topLeftY int) {
|
||||
func (dst *Array3BlockU8) ExtractYCbCrFrom(m image.Image, topLeftX int, topLeftY int) {
|
||||
if dst == nil {
|
||||
return
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func (dst *Array3BlockU8) ExtractFrom(m image.Image, topLeftX int, topLeftY int)
|
||||
fillRightAndDown(&dst[2], topLeftX, topLeftY, bounds.Max.X, bounds.Max.Y)
|
||||
}
|
||||
|
||||
// ExtractFrom sets dst to a three channel (Luma, Chroma-blue, Chroma-red)
|
||||
// ExtractYCbCrFrom sets dst to a three channel (Luma, Chroma-blue, Chroma-red)
|
||||
// 16×16 4:2:0 MCU (Minimum Coded Unit, with the given top-left corner, from
|
||||
// the image m.
|
||||
//
|
||||
@@ -127,7 +127,7 @@ func (dst *Array3BlockU8) ExtractFrom(m image.Image, topLeftX int, topLeftY int)
|
||||
// - Luma bottom right
|
||||
// - Chroma-blue
|
||||
// - Chroma-red
|
||||
func (dst *Array6BlockU8) ExtractFrom(m image.Image, topLeftX int, topLeftY int) {
|
||||
func (dst *Array6BlockU8) ExtractYCbCrFrom(m image.Image, topLeftX int, topLeftY int) {
|
||||
if dst == nil {
|
||||
return
|
||||
}
|
||||
@@ -137,10 +137,10 @@ func (dst *Array6BlockU8) ExtractFrom(m image.Image, topLeftX int, topLeftY int)
|
||||
}
|
||||
|
||||
tmp := [4]Array3BlockU8{}
|
||||
tmp[0].ExtractFrom(m, topLeftX+0, topLeftY+0)
|
||||
tmp[1].ExtractFrom(m, topLeftX+8, topLeftY+0)
|
||||
tmp[2].ExtractFrom(m, topLeftX+0, topLeftY+8)
|
||||
tmp[3].ExtractFrom(m, topLeftX+8, topLeftY+8)
|
||||
tmp[0].ExtractYCbCrFrom(m, topLeftX+0, topLeftY+0)
|
||||
tmp[1].ExtractYCbCrFrom(m, topLeftX+8, topLeftY+0)
|
||||
tmp[2].ExtractYCbCrFrom(m, topLeftX+0, topLeftY+8)
|
||||
tmp[3].ExtractYCbCrFrom(m, topLeftX+8, topLeftY+8)
|
||||
|
||||
dst[0] = tmp[0][0]
|
||||
dst[1] = tmp[1][0]
|
||||
|
||||
@@ -101,9 +101,9 @@ type EncoderOptions struct {
|
||||
// AddN takes ArrayNBlockI16 arguments, which are post-FDCT (when encoding) or
|
||||
// pre-IDCT (when decoding) coefficients.
|
||||
//
|
||||
// To get ArrayNBlockI16 values from pixels, use ExtractFrom on an image.Image
|
||||
// (to get an array of BlockU8 values) and then FowardDCTFrom (to get an array
|
||||
// of BlockI16 values). See Example_basic for an example.
|
||||
// To get ArrayNBlockI16 values from pixels, use ExtractYCbCrFrom on an
|
||||
// image.Image (to get an array of BlockU8 values) and then FowardDCTFrom (to
|
||||
// get an array of BlockI16 values). See Example_basic for an example.
|
||||
//
|
||||
// An Encoder makes no allocations, other than the Encoder struct itself and
|
||||
// any allocations that the passed io.Writer makes.
|
||||
|
||||
@@ -97,7 +97,7 @@ func testLowLevelJpegEncodeJpegDecode(tt *testing.T, src image.RGBA64Image, colo
|
||||
srcI16s := Array1BlockI16{}
|
||||
for y := bounds.Min.Y; y < bounds.Max.Y; y += 8 {
|
||||
for x := bounds.Min.X; x < bounds.Max.X; x += 8 {
|
||||
srcU8s.ExtractFrom(src, x, y)
|
||||
srcU8s.ExtractYCbCrFrom(src, x, y)
|
||||
srcI16s.ForwardDCTFrom(&srcU8s)
|
||||
if err := enc.Add1(buf, &srcI16s); err != nil {
|
||||
tt.Fatalf("enc.Add1: %v", err)
|
||||
@@ -110,7 +110,7 @@ func testLowLevelJpegEncodeJpegDecode(tt *testing.T, src image.RGBA64Image, colo
|
||||
srcI16s := Array3BlockI16{}
|
||||
for y := bounds.Min.Y; y < bounds.Max.Y; y += 8 {
|
||||
for x := bounds.Min.X; x < bounds.Max.X; x += 8 {
|
||||
srcU8s.ExtractFrom(src, x, y)
|
||||
srcU8s.ExtractYCbCrFrom(src, x, y)
|
||||
srcI16s.ForwardDCTFrom(&srcU8s)
|
||||
if err := enc.Add3(buf, &srcI16s); err != nil {
|
||||
tt.Fatalf("enc.Add3: %v", err)
|
||||
|
||||
Reference in new issue
Block a user