1
0
mirror of https://github.com/golang/go synced 2024-11-21 21:54:40 -07:00
The Go programming language
Go to file
Nigel Tao 8bf58725b2 Basic image/jpeg decoder.
This is not a complete JPEG implementation (e.g. it does not handle
progressive JPEGs or restart markers), but I was able to take a photo
with my phone, and view the resultant JPEG in pure Go.

The decoder is simple, but slow. The Huffman decoder in particular
should be easily improvable, but optimization is left to future
changelists. Being able to inline functions in the inner loop should
also help performance.

The output is not pixel-for-pixel identical to libjpeg, although
identical behavior isn't necessarily a goal, since JPEG is a lossy
codec. There are at least two reasons for the discrepancy.

First, the inverse DCT algorithm used is the same as Plan9's
src/cmd/jpg, which has different rounding errors from libjpeg's
default IDCT implementation. Note that libjpeg actually has three
different IDCT implementations: one floating point, and two fixed
point. Out of those four, Plan9's seemed the simplest to understand,
partly because it has no #ifdef's or C macros.

Second, for 4:2:2 or 4:2:0 chroma sampling, this implementation does
nearest neighbor upsampling, compared to libjpeg's triangle filter
(e.g. see h2v1_fancy_upsample in jdsample.c).

The difference from the first reason is typically zero, but sometimes
1 (out of 256) in YCbCr space, or double that in RGB space. The
difference from the second reason can be as large as 8/256 in YCbCr
space, in regions of steep chroma gradients. Informal eyeballing
suggests that the net difference is typically imperceptible, though.

R=r
CC=golang-dev, rsc
https://golang.org/cl/164056
2009-12-17 10:32:17 +11:00
doc Add roadmap document. 2009-12-16 15:30:39 -08:00
include Ports of lib9, libbio and libmach to Windows. 2009-11-30 11:53:11 -08:00
lib codereview: add golang-dev@googlegroups.com 2009-12-15 13:36:05 -08:00
misc 1) Change default gofmt default settings for 2009-12-15 15:33:31 -08:00
pkg more description 2009-10-15 23:08:46 -07:00
src Basic image/jpeg decoder. 2009-12-17 10:32:17 +11:00
test runtime: return zero value in x, ok = <-c when ok == false 2009-12-15 16:59:23 -08:00
.hgignore build Make.deps during make.bash instead 2009-11-19 16:27:13 -08:00
.hgtags hgtags: add release tag, again. 2009-12-09 14:55:31 -08:00
AUTHORS This patch enables cgo utility to correctly convert enums in the C source 2009-12-15 21:24:17 -08:00
CONTRIBUTORS This patch enables cgo utility to correctly convert enums in the C source 2009-12-15 21:24:17 -08:00
favicon.ico add a favicon plus a couple of hi-res versions of gordon 2009-10-26 10:13:07 -07:00
LICENSE Add AUTHORS and LICENSE files. 2009-08-13 09:21:28 -07:00
README add a README file, so that if someone finds a 2009-11-08 09:57:37 -08:00

This is the source code repository for the Go programming language.  

For documentation about how to install and use Go,
visit http://golang.org/ or load doc/install.html in your web browser.

After installing Go, you can view a nicely formatted
doc/install.html by running godoc --http=:6060
and then visiting http://localhost:6060/doc/install.html.

Unless otherwise noted, the Go source files are distributed
under the BSD-style license found in the LICENSE file.