summaryrefslogtreecommitdiff
path: root/libgo/go/image
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2013-01-29 20:52:43 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2013-01-29 20:52:43 +0000
commitd6f2922e91928b5191a5c5f1b3a6b320712b5ce3 (patch)
tree4f2fad1f4b778519bdd5941185c7e1d032af055b /libgo/go/image
parent91bfca59095b1cca9d4364996866848eaaf76c26 (diff)
libgo: Update Go library to master revision 15489/921e53d4863c.
From-SVN: r195560
Diffstat (limited to 'libgo/go/image')
-rw-r--r--libgo/go/image/format.go2
-rw-r--r--libgo/go/image/jpeg/reader.go19
-rw-r--r--libgo/go/image/jpeg/reader_test.go1
-rw-r--r--libgo/go/image/jpeg/writer.go4
-rw-r--r--libgo/go/image/testdata/video-005.gray.q50.2x2.jpegbin0 -> 2782 bytes
-rw-r--r--libgo/go/image/testdata/video-005.gray.q50.2x2.progressive.jpegbin0 -> 2699 bytes
6 files changed, 20 insertions, 6 deletions
diff --git a/libgo/go/image/format.go b/libgo/go/image/format.go
index f93d356b041..36635bcc538 100644
--- a/libgo/go/image/format.go
+++ b/libgo/go/image/format.go
@@ -39,7 +39,7 @@ type reader interface {
Peek(int) ([]byte, error)
}
-// AsReader converts an io.Reader to a reader.
+// asReader converts an io.Reader to a reader.
func asReader(r io.Reader) reader {
if rr, ok := r.(reader); ok {
return rr
diff --git a/libgo/go/image/jpeg/reader.go b/libgo/go/image/jpeg/reader.go
index 24dd65defcc..1ee6bbcd1ac 100644
--- a/libgo/go/image/jpeg/reader.go
+++ b/libgo/go/image/jpeg/reader.go
@@ -147,14 +147,27 @@ func (d *decoder) processSOF(n int) error {
return UnsupportedError("SOF has wrong number of image components")
}
for i := 0; i < d.nComp; i++ {
- hv := d.tmp[7+3*i]
- d.comp[i].h = int(hv >> 4)
- d.comp[i].v = int(hv & 0x0f)
d.comp[i].c = d.tmp[6+3*i]
d.comp[i].tq = d.tmp[8+3*i]
if d.nComp == nGrayComponent {
+ // If a JPEG image has only one component, section A.2 says "this data
+ // is non-interleaved by definition" and section A.2.2 says "[in this
+ // case...] the order of data units within a scan shall be left-to-right
+ // and top-to-bottom... regardless of the values of H_1 and V_1". Section
+ // 4.8.2 also says "[for non-interleaved data], the MCU is defined to be
+ // one data unit". Similarly, section A.1.1 explains that it is the ratio
+ // of H_i to max_j(H_j) that matters, and similarly for V. For grayscale
+ // images, H_1 is the maximum H_j for all components j, so that ratio is
+ // always 1. The component's (h, v) is effectively always (1, 1): even if
+ // the nominal (h, v) is (2, 1), a 20x5 image is encoded in three 8x8
+ // MCUs, not two 16x8 MCUs.
+ d.comp[i].h = 1
+ d.comp[i].v = 1
continue
}
+ hv := d.tmp[7+3*i]
+ d.comp[i].h = int(hv >> 4)
+ d.comp[i].v = int(hv & 0x0f)
// For color images, we only support 4:4:4, 4:4:0, 4:2:2 or 4:2:0 chroma
// downsampling ratios. This implies that the (h, v) values for the Y
// component are either (1, 1), (1, 2), (2, 1) or (2, 2), and the (h, v)
diff --git a/libgo/go/image/jpeg/reader_test.go b/libgo/go/image/jpeg/reader_test.go
index f7fbd9a8a5e..b520a8ab18c 100644
--- a/libgo/go/image/jpeg/reader_test.go
+++ b/libgo/go/image/jpeg/reader_test.go
@@ -24,6 +24,7 @@ func TestDecodeProgressive(t *testing.T) {
"../testdata/video-001.q50.440",
"../testdata/video-001.q50.444",
"../testdata/video-005.gray.q50",
+ "../testdata/video-005.gray.q50.2x2",
}
for _, tc := range testCases {
m0, err := decodeFile(tc + ".jpeg")
diff --git a/libgo/go/image/jpeg/writer.go b/libgo/go/image/jpeg/writer.go
index 375d8a66d5a..c58fbf30555 100644
--- a/libgo/go/image/jpeg/writer.go
+++ b/libgo/go/image/jpeg/writer.go
@@ -210,8 +210,8 @@ func init() {
// writer is a buffered writer.
type writer interface {
Flush() error
- Write([]byte) (int, error)
- WriteByte(byte) error
+ io.Writer
+ io.ByteWriter
}
// encoder encodes an image to the JPEG format.
diff --git a/libgo/go/image/testdata/video-005.gray.q50.2x2.jpeg b/libgo/go/image/testdata/video-005.gray.q50.2x2.jpeg
new file mode 100644
index 00000000000..630b615f73a
--- /dev/null
+++ b/libgo/go/image/testdata/video-005.gray.q50.2x2.jpeg
Binary files differ
diff --git a/libgo/go/image/testdata/video-005.gray.q50.2x2.progressive.jpeg b/libgo/go/image/testdata/video-005.gray.q50.2x2.progressive.jpeg
new file mode 100644
index 00000000000..c6b93608cb7
--- /dev/null
+++ b/libgo/go/image/testdata/video-005.gray.q50.2x2.progressive.jpeg
Binary files differ