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
into consts in the resulting Go source. Previously known as issue 161047,
which I deleted accidentally. Fixes issue 207.
R=rsc
https://golang.org/cl/166059
* better error for lookup of unexported field
* do not assign "ideal string" type to typed string literal
* do not confuse methods and fields during interface check
Fixes#410.
Fixes#411.
Fixes#426.
R=ken2
https://golang.org/cl/179069
parsing and printing to new syntax.
Use -oldparser to parse the old syntax,
use -oldprinter to print the old syntax.
2) Change default gofmt formatting settings
to use tabs for indentation only and to use
spaces for alignment. This will make the code
alignment insensitive to an editor's tabwidth.
Use -spaces=false to use tabs for alignment.
3) Manually changed src/exp/parser/parser_test.go
so that it doesn't try to parse the parser's
source files using the old syntax (they have
new syntax now).
4) gofmt -w src misc test/bench
5th and last set of files.
R=rsc
CC=golang-dev
https://golang.org/cl/180050
parsing and printing to new syntax.
Use -oldparser to parse the old syntax,
use -oldprinter to print the old syntax.
2) Change default gofmt formatting settings
to use tabs for indentation only and to use
spaces for alignment. This will make the code
alignment insensitive to an editor's tabwidth.
Use -spaces=false to use tabs for alignment.
3) Manually changed src/exp/parser/parser_test.go
so that it doesn't try to parse the parser's
source files using the old syntax (they have
new syntax now).
4) gofmt -w src misc test/bench
4th set of files.
R=rsc
CC=golang-dev
https://golang.org/cl/180049
parsing and printing to new syntax.
Use -oldparser to parse the old syntax,
use -oldprinter to print the old syntax.
2) Change default gofmt formatting settings
to use tabs for indentation only and to use
spaces for alignment. This will make the code
alignment insensitive to an editor's tabwidth.
Use -spaces=false to use tabs for alignment.
3) Manually changed src/exp/parser/parser_test.go
so that it doesn't try to parse the parser's
source files using the old syntax (they have
new syntax now).
4) gofmt -w src misc test/bench
3rd set of files.
R=rsc
CC=golang-dev
https://golang.org/cl/180048
parsing and printing to new syntax.
Use -oldparser to parse the old syntax,
use -oldprinter to print the old syntax.
2) Change default gofmt formatting settings
to use tabs for indentation only and to use
spaces for alignment. This will make the code
alignment insensitive to an editor's tabwidth.
Use -spaces=false to use tabs for alignment.
3) Manually changed src/exp/parser/parser_test.go
so that it doesn't try to parse the parser's
source files using the old syntax (they have
new syntax now).
4) gofmt -w src misc test/bench
1st set of files.
R=rsc
CC=agl, golang-dev, iant, ken2, r
https://golang.org/cl/180047
parsing and printing to new syntax.
Use -oldparser to parse the old syntax,
use -oldprinter to print the old syntax.
2) Change default gofmt formatting settings
to use tabs for indentation only and to use
spaces for alignment. This will make the code
alignment insensitive to an editor's tabwidth.
Use -spaces=false to use tabs for alignment.
3) Manually changed src/exp/parser/parser_test.go
so that it doesn't try to parse the parser's
source files using the old syntax (they have
new syntax now).
4) gofmt -w src misc test/bench
2nd set of files.
R=rsc
CC=golang-dev
https://golang.org/cl/179067
Pull the struct into a single line, since 6g reports the error
on the last line of the struct definition and gccgo reports it
on the first line.
6g:
bug215.go:12: invalid recursive type A
gccgo:
bug215.go:12:6: error: invalid recursive type ‘A’
R=rsc
https://golang.org/cl/180044
mustgetc reports unexpected EOF as SyntaxError. using
mustgetc seems to be a better approach than letting the
caller handle unexpected EOF every time.
name: the second if statement should explicitly return
ok==false.
R=rsc
https://golang.org/cl/174083
1. If all data is exhausted using Read then a following Next will
fail as if it saw EOF. (Test case added.)
2. Seeking isn't always possible (i.e. sockets and pipes). Fallback
to read. (Test case added.)
3. Fix to readHeader (cleaner fix pointed out by rsc).
(TestReader modified.)
4. When Read has consumed all the data, don't try to read 0 bytes from reader.
In cases where tr.nb is zero we attempt to read zero bytes and thus
never see an EOF (this is most easily seen when the 'tar source' is
something like bytes.Buffer{} as opposed to os.File).
5. If write is used to the point of ErrWriteTooLong, allow additional file entries.
6. Make close work as expected. That is any further Write or
WriteHeader attempts will result in ErrWriteAfterClose.
Fixes#419.
R=rsc, dsymonds1
https://golang.org/cl/162062
Doing rm -rf /pkg/.. blindly isn't nice. It could have
unintended consequences.
Secondly set bash to abort on (unexpected) errors.
R=dho, rsc
CC=golang-dev
https://golang.org/cl/176056