Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(84)

Issue 6684046: code review 6684046: image/jpeg: decode progressive JPEGs. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 9 months ago by nigeltao
Modified:
12 years, 9 months ago
Reviewers:
CC:
r, golang-dev
Visibility:
Public.

Description

image/jpeg: decode progressive JPEGs. To be clear, this supports decoding the bytes on the wire into an in-memory image. There is no API change: jpeg.Decode will still not return until the entire image is decoded. The code is obviously more complicated, and costs around 10% in performance on baseline JPEGs. The processSOS code could be cleaned up a bit, and maybe some of that loss can be reclaimed, but I'll leave that for follow-up CLs, to keep the diff for this one as small as possible. Before: BenchmarkDecode 1000 2855637 ns/op 21.64 MB/s After: BenchmarkDecodeBaseline 500 3178960 ns/op 19.44 MB/s BenchmarkDecodeProgressive 500 4082640 ns/op 15.14 MB/s Fixes issue 3976. The test data was generated by: # Create intermediate files; cjpeg on Ubuntu 10.04 can't read PNG. convert video-001.png video-001.bmp convert video-005.gray.png video-005.gray.pgm # Create new test files. cjpeg -quality 100 -sample 1x1,1x1,1x1 -progressive video-001.bmp > video-001.progressive.jpeg cjpeg -quality 50 -sample 2x2,1x1,1x1 video-001.bmp > video-001.q50.420.jpeg cjpeg -quality 50 -sample 2x1,1x1,1x1 video-001.bmp > video-001.q50.422.jpeg cjpeg -quality 50 -sample 1x1,1x1,1x1 video-001.bmp > video-001.q50.444.jpeg cjpeg -quality 50 -sample 2x2,1x1,1x1 -progressive video-001.bmp > video-001.q50.420.progressive.jpeg cjpeg -quality 50 -sample 2x1,1x1,1x1 -progressive video-001.bmp > video-001.q50.422.progressive.jpeg cjpeg -quality 50 -sample 1x1,1x1,1x1 -progressive video-001.bmp > video-001.q50.444.progressive.jpeg cjpeg -quality 50 video-005.gray.pgm > video-005.gray.q50.jpeg cjpeg -quality 50 -progressive video-005.gray.pgm > video-005.gray.q50.progressive.jpeg # Delete intermediate files. rm video-001.bmp video-005.gray.pgm

Patch Set 1 #

Patch Set 2 : diff -r 1baa80f7f4a4 https://code.google.com/p/go #

Patch Set 3 : diff -r 1baa80f7f4a4 https://code.google.com/p/go #

Patch Set 4 : diff -r 1baa80f7f4a4 https://code.google.com/p/go #

Patch Set 5 : diff -r 1baa80f7f4a4 https://code.google.com/p/go #

Patch Set 6 : diff -r 1baa80f7f4a4 https://code.google.com/p/go #

Patch Set 7 : diff -r 1baa80f7f4a4 https://code.google.com/p/go #

Total comments: 5

Patch Set 8 : diff -r 79795b342a76 https://code.google.com/p/go #

Unified diffs Side-by-side diffs Delta from patch set Stats (+498 lines, -85 lines) Patch
M src/pkg/image/decode_test.go View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/pkg/image/jpeg/huffman.go View 1 5 chunks +31 lines, -7 lines 0 comments Download
M src/pkg/image/jpeg/reader.go View 1 2 3 4 5 6 7 4 chunks +200 lines, -61 lines 0 comments Download
A src/pkg/image/jpeg/reader_test.go View 1 2 3 4 5 6 7 1 chunk +155 lines, -0 lines 0 comments Download
A src/pkg/image/jpeg/scan.go View 1 1 chunk +111 lines, -0 lines 0 comments Download
M src/pkg/image/jpeg/writer_test.go View 1 1 chunk +0 lines, -17 lines 0 comments Download
A src/pkg/image/testdata/video-001.progressive.jpeg View 1 Binary file 0 comments Download
A src/pkg/image/testdata/video-001.q50.420.jpeg View 1 Binary file 0 comments Download
A src/pkg/image/testdata/video-001.q50.420.progressive.jpeg View 1 Binary file 0 comments Download
A src/pkg/image/testdata/video-001.q50.422.jpeg View 1 Binary file 0 comments Download
A src/pkg/image/testdata/video-001.q50.422.progressive.jpeg View 1 Binary file 0 comments Download
A src/pkg/image/testdata/video-001.q50.444.jpeg View 1 Binary file 0 comments Download
A src/pkg/image/testdata/video-001.q50.444.progressive.jpeg View 1 Binary file 0 comments Download
A src/pkg/image/testdata/video-005.gray.q50.jpeg View 1 Binary file 0 comments Download
A src/pkg/image/testdata/video-005.gray.q50.progressive.jpeg View 1 Binary file 0 comments Download

Messages

Total messages: 4
nigeltao
Hello r@golang.org (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go
12 years, 9 months ago (2012-10-14 07:25:52 UTC) #1
r
LGTM http://codereview.appspot.com/6684046/diff/6017/src/pkg/image/jpeg/reader.go File src/pkg/image/jpeg/reader.go (right): http://codereview.appspot.com/6684046/diff/6017/src/pkg/image/jpeg/reader.go#newcode317 src/pkg/image/jpeg/reader.go:317: // pixel co-ordinates is (16, 8) is the ...
12 years, 9 months ago (2012-10-14 21:33:26 UTC) #2
nigeltao
https://codereview.appspot.com/6684046/diff/6017/src/pkg/image/jpeg/reader.go File src/pkg/image/jpeg/reader.go (right): https://codereview.appspot.com/6684046/diff/6017/src/pkg/image/jpeg/reader.go#newcode348 src/pkg/image/jpeg/reader.go:348: // 3 4 5 On 2012/10/14 21:33:26, r wrote: ...
12 years, 9 months ago (2012-10-15 00:12:56 UTC) #3
nigeltao
12 years, 9 months ago (2012-10-15 00:21:38 UTC) #4
*** Submitted as http://code.google.com/p/go/source/detail?r=51f26e36ba98 ***

image/jpeg: decode progressive JPEGs.

To be clear, this supports decoding the bytes on the wire into an
in-memory image. There is no API change: jpeg.Decode will still not
return until the entire image is decoded.

The code is obviously more complicated, and costs around 10% in
performance on baseline JPEGs. The processSOS code could be cleaned up a
bit, and maybe some of that loss can be reclaimed, but I'll leave that
for follow-up CLs, to keep the diff for this one as small as possible.

Before:
BenchmarkDecode	    1000	   2855637 ns/op	  21.64 MB/s
After:
BenchmarkDecodeBaseline	     500	   3178960 ns/op	  19.44 MB/s
BenchmarkDecodeProgressive	     500	   4082640 ns/op	  15.14 MB/s

Fixes issue 3976.

The test data was generated by:
# Create intermediate files; cjpeg on Ubuntu 10.04 can't read PNG.
convert video-001.png video-001.bmp
convert video-005.gray.png video-005.gray.pgm
# Create new test files.
cjpeg -quality 100 -sample 1x1,1x1,1x1 -progressive video-001.bmp >
video-001.progressive.jpeg
cjpeg -quality 50 -sample 2x2,1x1,1x1 video-001.bmp > video-001.q50.420.jpeg
cjpeg -quality 50 -sample 2x1,1x1,1x1 video-001.bmp > video-001.q50.422.jpeg
cjpeg -quality 50 -sample 1x1,1x1,1x1 video-001.bmp > video-001.q50.444.jpeg
cjpeg -quality 50 -sample 2x2,1x1,1x1 -progressive video-001.bmp >
video-001.q50.420.progressive.jpeg
cjpeg -quality 50 -sample 2x1,1x1,1x1 -progressive video-001.bmp >
video-001.q50.422.progressive.jpeg
cjpeg -quality 50 -sample 1x1,1x1,1x1 -progressive video-001.bmp >
video-001.q50.444.progressive.jpeg
cjpeg -quality 50 video-005.gray.pgm > video-005.gray.q50.jpeg
cjpeg -quality 50 -progressive video-005.gray.pgm >
video-005.gray.q50.progressive.jpeg
# Delete intermediate files.
rm video-001.bmp video-005.gray.pgm

R=r
CC=golang-dev
http://codereview.appspot.com/6684046
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b