Commit Graph

52 Commits

Author SHA1 Message Date
Nigel Tao
2a1231edb8 draw: factor out the Scale implementations.
This is just a copy/paste/rename in anticipation of automatically
generating fast-path code for specific dst-image types and src-image
types, a la the standard library's image/draw package.

Change-Id: If6385b347cb5e1d134b0ce841ef38ed4450a6fef
Reviewed-on: https://go-review.googlesource.com/5252
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-02-20 07:27:42 +00:00
Andrew Gerrand
5869597f23 doc: add CONTRIBUTING.md
Change-Id: Ica8168a510824e9519902a3b660025bcf913f762
Reviewed-on: https://go-review.googlesource.com/5413
Reviewed-by: Minux Ma <minux@golang.org>
2015-02-20 05:00:47 +00:00
Nigel Tao
96b77d5c7a draw: new package, a superset of the standard library's image/draw
package, including the ability to scale an image.

Design discussion:
https://groups.google.com/forum/#!topic/golang-dev/B7-OrWdheic

Previous code review (when Go used hg instead of git):
https://codereview.appspot.com/101670045

New benchmarks:
BenchmarkScaleLargeDownNN	     300	   5935174 ns/op
BenchmarkScaleLargeDownAB	     100	  14482372 ns/op
BenchmarkScaleLargeDownBL	       1	1383805986 ns/op
BenchmarkScaleLargeDownCR	       1	2724631789 ns/op
BenchmarkScaleDownNN     	    1000	   1850500 ns/op
BenchmarkScaleDownAB     	     300	   4413499 ns/op
BenchmarkScaleDownBL     	      50	  30498748 ns/op
BenchmarkScaleDownCR     	      20	  58349653 ns/op
BenchmarkScaleUpNN       	      20	  92306475 ns/op
BenchmarkScaleUpAB       	       5	 220103753 ns/op
BenchmarkScaleUpBL       	      10	 122635195 ns/op
BenchmarkScaleUpCR       	      10	 183275927 ns/op

Change-Id: I69d397e68897bae024c7b330a9375fa3e7688591
Reviewed-on: https://go-review.googlesource.com/4210
Reviewed-by: Rob Pike <r@golang.org>
2015-02-17 23:20:02 +00:00
Alex Brainman
7f6859d385 image: copying .gitattributes to all subrepositories
Fixes #9281

Change-Id: I9e807f826e8c48fef35cb1de08c89d37845e8721
Reviewed-on: https://go-review.googlesource.com/2075
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-23 11:05:35 +00:00
David Symonds
0351284b2d image: add import comments.
Change-Id: I2d3a1d002ad43af24cd8b451a2cae4c217482675
Reviewed-on: https://go-review.googlesource.com/1237
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-09 22:43:18 +00:00
David Symonds
b0cc87690b remove codereview.cfg. 2014-12-08 10:59:03 +11:00
David Symonds
95b61cf7c4 convert .hgignore to .gitignore. 2014-12-08 10:42:30 +11:00
Andrew Gerrand
2e99ef522d go.image: use golang.org/x/... import paths
LGTM=bradfitz, rsc
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/169090043
2014-11-10 08:52:14 +11:00
Nigel Tao
c087821dc6 go.image/webp: implement alpha filtering and uncompressed alpha.
This passes the four new alpha_*.webp conformance tests referred to in
https://golang.org/cl/162850043/#msg7

LGTM=pascal.massimino, r
R=r, pascal.massimino
CC=golang-codereviews
https://golang.org/cl/163630043
2014-10-31 17:06:42 +11:00
Nigel Tao
013424077b go.image/riff: new package.
Also update package webp to use package riff.

LGTM=r
R=r
CC=golang-codereviews, pascal.massimino
https://golang.org/cl/162850043
2014-10-23 08:59:14 +11:00
Nigel Tao
ef5e0288ce go.image/webp: implement lossy-with-alpha.
This fixes all three lossy_alpha*.webp conformance tests.

The test data was generated by cwebp/dwebp version 0.4.1:
cwebp yellow_rose.png -o yellow_rose.lossy-with-alpha.webp
dwebp yellow_rose.lossy-with-alpha.webp -pgm -o tmp.pgm
convert tmp.pgm yellow_rose.lossy-with-alpha.webp.nycbcra.png

LGTM=pascal.massimino, r
R=r, pascal.massimino
CC=golang-codereviews
https://golang.org/cl/154350043
2014-10-20 10:46:12 +11:00
Nigel Tao
d354b8dda9 go.image/webp/nycbcra: new package.
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/147500043
2014-10-08 14:30:35 +11:00
Nigel Tao
8d4fc1653b go.image/bmp: add a test image for top-down BMPs.
LGTM=ruiu
R=ruiu
CC=bsiegert, golang-codereviews
https://golang.org/cl/149090043
2014-10-01 09:41:12 +10:00
Nigel Tao
8a2d4aba20 go.image/vp8: clamp the UV DC quantization factor to 132.
This fixes the lossy_extreme_probabilities.webp conformance test.

LGTM=pascal.massimino, r
R=r, pascal.massimino
CC=golang-codereviews
https://golang.org/cl/145600043
2014-10-01 09:39:28 +10:00
Nigel Tao
3bcf25db01 go.image/bmp: support decoding 32-bit BMPs, as well as top-down BMPs.
Tested manually, from "dwebp -bmp" output. dwebp comes from
https://developers.google.com/speed/webp/download

LGTM=bsiegert
R=bsiegert
CC=golang-codereviews
https://golang.org/cl/148020043
2014-09-26 11:11:55 +10:00
Nigel Tao
a704c116ac go.image/vp8l: use the default code length for repeated codes.
This fixes the lossless_vec_2_13.webp conformance test.

LGTM=r
R=r, pascal.massimino
CC=golang-codereviews
https://golang.org/cl/143610043
2014-09-26 11:09:06 +10:00
Nigel Tao
96df300f7f go.image/cmd/webp-manual-test: new program to test Go's WEBP
compatibility with the C libwebp implementation.

Current status:
104 PASS, 5 FAIL, 109 TOTAL
Of those 5 failures, 3 are because Go doesn't support lossy-with-alpha
yet, and the other 2 (lossless_vec_2_13.webp,
lossy_extreme_probabilities.webp) look like genuine bugs.

LGTM=r
R=r, pascal.massimino
CC=golang-codereviews
https://golang.org/cl/150000043
2014-09-25 09:44:20 +10:00
Nigel Tao
95764ac466 vp8l: update comments to match latest spec.
The spec change is at
https://gerrit.chromium.org/gerrit/#/c/71605/

LGTM=robsc
R=robsc
CC=golang-codereviews
https://golang.org/cl/146910043
2014-09-22 12:52:41 +10:00
Nigel Tao
34eb6b7c8b go.image/tiff: remove unreachable code.
This makes "go vet code.google.com/p/go.image/..." happy.

LGTM=dsymonds
R=dsymonds
CC=golang-codereviews
https://golang.org/cl/103630047
2014-06-30 11:43:54 +10:00
Nigel Tao
07fcf9c2fe vp8: skip filtering for all-zero-DC macroblock residuals.
This makes the Go code match the libwebp C code's output on
blue-purple-pink-large.*-filter.lossy.webp

Also make the various WEBP benchmarks all decode a similar image,
the image at http://blog.golang.org/gophercon/image01.jpg, to make
it more meaningful to e.g. compare the simple filter's numbers with
the normal filter's numbers.

Also fix a "go vet" warning in webp/decode.go.

The test data was generated by:
wget http://blog.golang.org/gophercon/image01.jpg -O blue-purple-pink-large.jpeg
convert blue-purple-pink-large.jpeg blue-purple-pink-large.png
cwebp -lossless blue-purple-pink-large.png -o blue-purple-pink-large.lossless.webp
cwebp -q 80 -f 0 blue-purple-pink-large.png -o blue-purple-pink-large.no-filter.lossy.webp
cwebp -q 80 -strong blue-purple-pink-large.png -o blue-purple-pink-large.normal-filter.lossy.webp
cwebp -q 80 -nostrong blue-purple-pink-large.png -o blue-purple-pink-large.simple-filter.lossy.webp
dwebp -pgm blue-purple-pink-large.no-filter.lossy.webp -o tmp.pgm && convert tmp.pgm blue-purple-pink-large.no-filter.lossy.webp.ycbcr.png && rm tmp.pgm
dwebp -pgm blue-purple-pink-large.normal-filter.lossy.webp -o tmp.pgm && convert tmp.pgm blue-purple-pink-large.normal-filter.lossy.webp.ycbcr.png && rm tmp.pgm
dwebp -pgm blue-purple-pink-large.simple-filter.lossy.webp -o tmp.pgm && convert tmp.pgm blue-purple-pink-large.simple-filter.lossy.webp.ycbcr.png && rm tmp.pgm

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/106230044
2014-06-30 10:36:25 +10:00
Rui Ueyama
dc115882f1 go.image/vp8: use branch-free abs
This change seems to restore performance to
the level before CL 108140045.

benchmark                         old ns/op    new ns/op    delta
BenchmarkDecodeVP8SimpleFilter       796416       784394   -1.51%
BenchmarkDecodeVP8NormalFilter      4931138      4693078   -4.83%
BenchmarkDecodeVP8L                 7820030      7821796   +0.02%

LGTM=nigeltao, r
R=nigeltao, r
CC=golang-codereviews
https://golang.org/cl/107340047
2014-06-30 10:33:37 +10:00
Nigel Tao
f8a86727c2 go.image/vp8: remove the filter look-up tables.
The benchmarks are a little slower, but the code is shorter.

benchmark                          old ns/op     new ns/op     delta
BenchmarkDecodeVP8SimpleFilter     621950        644184        +3.57%
BenchmarkDecodeVP8NormalFilter     4045745       4269431       +5.53%

LGTM=r
R=r, minux, ruiu
CC=golang-codereviews
https://golang.org/cl/108140045
2014-06-27 09:14:15 +10:00
Nigel Tao
0424e74a0e go.image/vp8: implement the normal filter.
The testdata was generated via:
cwebp foo.png -o foo.lossy.webp
dwebp -pgm foo.lossy.webp -o tmp.pgm
convert tmp.pgm foo.lossy.webp.ycbcr.png
rm tmp.pgm

TBR=r
R=r
CC=golang-codereviews
https://golang.org/cl/107330043
2014-06-26 13:29:30 +10:00
Nigel Tao
94ba43c478 go.image/vp8l: new package.
The blue-purple-pink image comes from
http://blog.golang.org/gophercon

The tux and yellow_rose images come from
https://developers.google.com/speed/webp/gallery2 and according to
that page, those images are in the public domain.

The gopher-doc images are http://golang.org/doc/gopher/doc.png
after quantizing its palette to 2/4/16/256 colors.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/109010043
2014-06-17 21:51:57 +10:00
Nigel Tao
a1da419f1a go.image/tiff: fix (TIFF-specific) LZW decompression.
The blue-purple-pink.lzwcompressed.tiff image was created by
"bmp2tiff -c lzw".

LGTM=djd
R=djd
CC=bsiegert, golang-codereviews
https://golang.org/cl/105750045
2014-06-02 14:51:51 +10:00
Nigel Tao
2bda575717 go.image/tiff/lzw: fork the standard library's compress/lzw package.
This CL has no code changes. Future CLs will modify the code to
implement TIFF's LZW instead of the standard LZW.

LGTM=bradfitz
R=djd, bradfitz
CC=golang-codereviews
https://golang.org/cl/105750044
2014-06-02 13:56:21 +10:00
Nigel Tao
72be9c51b1 go.image/vp8: implement the loop filter.
The testdata files were created by:
cwebp video-001.png -o video-001.webp
dwebp -pgm video-001.webp -o tmp.pgm
convert tmp.pgm video-001.webp.ycbcr.png
rm tmp.pgm

LGTM=r
R=r
CC=chaishushan, golang-codereviews
https://golang.org/cl/91700044
2014-05-27 10:52:02 +10:00
Patrick Riley
38c1f4ffe8 go.image/tiff: Support missing Compression tag
no_compress.tiff is no_rps.tiff that was read in by go.image/tiff and written out again (with a hack to avoid creating the Compression tag on the way out).

$ tiffdump no_compress.tiff
no_compress.tiff:
Magic: 0x4949 <little-endian> Version: 0x2a
Directory 0: offset 968 (0x3c8) next 0 (0)
ImageWidth (256) SHORT (3) 1<16>
ImageLength (257) SHORT (3) 1<15>
BitsPerSample (258) SHORT (3) 4<8 8 8 8>
Photometric (262) SHORT (3) 1<2>
StripOffsets (273) LONG (4) 1<8>
SamplesPerPixel (277) SHORT (3) 1<4>
RowsPerStrip (278) SHORT (3) 1<15>
StripByteCounts (279) LONG (4) 1<960>
XResolution (282) RATIONAL (5) 1<72>
YResolution (283) RATIONAL (5) 1<72>
ResolutionUnit (296) SHORT (3) 1<2>
ExtraSamples (338) SHORT (3) 1<2>

LGTM=bsiegert, nigeltao
R=bsiegert, nigeltao
CC=golang-codereviews
https://golang.org/cl/95930044
2014-05-12 16:41:44 +10:00
Nigel Tao
f93749e6f2 go.image/vp8, go.image/webp: new packages, copied from
code.google.com/p/vp8-go

This is a straight copy, followed by import path updates.

LGTM=r
R=r, mirtchovski, oleku.konko
CC=golang-codereviews
https://golang.org/cl/79320043
2014-03-25 13:29:48 +11:00
Rob Pike
756628658b .hgignore: add comment setting policy
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/44850043
2013-12-20 16:30:01 -08:00
Rob Pike
35529c2b86 codereview.cfg: change defaultcc to golang-codereviews@
R=rsc
CC=golang-codereviews
https://golang.org/cl/44870043
2013-12-20 16:26:52 -08:00
ChaiShushan
420d421738 go.image/tiff: encoder fix non LZW Predictor and Paletted SamplesPerPixel and non RGB ExtraSamples.
TIFF6.0 Spec:
Page 31: ExtraSamples can only included in RGB mode image.
Page 39, SamplesPerPixel is usually 1 for bilevel, grayscale, and palette-color images.
Page 64, Currently Predictor field is used only with LZW.

Fixes golang/go#6421.

R=bsiegert, nigeltao, gbulmer
CC=golang-dev
https://golang.org/cl/13779043
2013-09-22 11:21:53 +10:00
ChaiShushan
b2d744f611 go.image/tiff: support 16bit RGB
R=nigeltao, bsiegert
CC=golang-dev
https://golang.org/cl/13736044
2013-09-18 17:16:05 +10:00
ChaiShushan
e39b2394e5 go.image/tiff: encoder support Gray/Gray16/Paletted format
Use these commands to generate testdata:

# TIFF Tools
tiff2bw    video-001.tiff video-001-gray.tiff
tiffmedian video-001.tiff video-001-paletted.tiff

# ImageMagick
convert -depth 16 video-001.tiff      video-001-16bit.tiff
convert -depth 16 video-001-gray.tiff video-001-gray-16bit.tiff

R=nigeltao, bsiegert
CC=golang-dev
https://golang.org/cl/13243047
2013-09-13 17:42:53 +10:00
ChaiShushan
864256f267 go.image/bmp: add Encode
R=nigeltao
CC=golang-dev
https://golang.org/cl/13407045
2013-09-10 17:19:36 +10:00
ChaiShushan
de306d5329 go.image/tiff: decoder support tiled tiff format
Use these commands to generate testdata:
tiffcp -s -r 64 video-001.tiff video-001-strip-64.tiff
tiffcp -t -l 64 -w 64 video-001.tiff video-001-tile-64x64.tiff

R=golang-dev, nigeltao, bsiegert
CC=golang-dev
https://golang.org/cl/13453043
2013-09-06 20:07:58 +10:00
ChaiShushan
822abc7ef1 go.image/tiff: add missing encoder to pkg doc
R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/13302045
2013-09-02 13:29:55 +10:00
Benny Siegert
26936f5590 go.image/tiff: Support reading 16-bit gray images.
Fixes golang/go#5866.

R=nigeltao
CC=golang-dev
https://golang.org/cl/11920043
2013-07-30 15:02:33 +10:00
Benny Siegert
d165204442 go.image/tiff: support for writing compressed images.
Only Deflate compression is supported for now.

R=nigeltao, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6866051
2012-12-12 13:24:12 +11:00
Benny Siegert
41cf08abcf tiff: support writing files with differencing predictor.
This will make more sense after implementing compression.

R=nigeltao
CC=golang-dev
https://golang.org/cl/6567077
2012-10-03 10:11:21 +10:00
Benny Siegert
5198c64fc9 tiff: new Options parameter for Encode.
No functional change at the moment but it will allow choosing
the compression type.

This is an incompatible, user-visible change. To get the old
behavior, callers of tiff.Encode need to add ", nil" as the
last parameter.

R=nigeltao
CC=golang-dev
https://golang.org/cl/6479044
2012-08-23 20:16:03 +10:00
Benny Siegert
c35a1ecb6c go.image/tiff: use optimized routines for RGBA and NRGBA
Performance for an RGBA image:

benchmark          old ns/op    new ns/op    delta
BenchmarkEncode      1633495         7897  -99.52%

benchmark           old MB/s     new MB/s  speedup
BenchmarkEncode        37.83      7824.96  206.85x

NRGBA images are now encoded as such, the spec calls it
"unassociated alpha".

R=nigeltao, rsc
CC=golang-dev
https://golang.org/cl/6308049
2012-06-13 10:40:38 +10:00
Benny Siegert
de792da79c go.image/tiff: add a benchmark for the encoder
The idea is to see whether it is worthwhile to implement special cases.

On my Mac Book Pro:

BenchmarkEncode	    1000	   1689656 ns/op	  36.69 MB/s

R=nigeltao, minux.ma
CC=golang-dev
https://golang.org/cl/6278050
2012-06-07 09:41:24 +10:00
Nigel Tao
2b631034c7 go.image: add PATENTS file to the subrepo.
R=r
CC=golang-dev
https://golang.org/cl/6024044
2012-04-16 11:25:02 +10:00
Rob Pike
2393f5daa3 LICENSE: add
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5847054
2012-03-17 15:20:31 +11:00
Benny Siegert
27e7e9451c go.image/bmp: fix warnings from go vet
reader.go:138:10: image.Config struct literal uses untagged fields
reader.go:144:10: image.Config struct literal uses untagged fields

R=nigeltao
CC=golang-dev
https://golang.org/cl/5825047
2012-03-15 09:44:37 +11:00
Nigel Tao
20e9620e99 go.image/tiff: simplify encoding.
R=bsiegert
CC=golang-dev
https://golang.org/cl/5738044
2012-03-07 10:32:33 +11:00
Benny Siegert
f594c3aad5 go.image/tiff: initial support for writing TIFF images
The basic functionality works. Features to add in future CLs:

- compression
- fast paths for image formats that can be directly expressed in TIFF,
  such as RGBA, NRGBA and maybe Gray and Paletted.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5694051
2012-03-05 11:45:47 +11:00
Benny Siegert
324e6dabf0 go.image/tiff: optimize reading uncompressed files from a tiff.buffer.
In case the image is read via a tiff.buffer, avoid copying the
data strip before decoding it. Remove corresponding TODO.
Speeds up reading uncompressed images (which is the common case)
and uses much less memory.

benchmark                      old ns/op    new ns/op    delta
BenchmarkDecodeCompressed        4619438      4630774   +0.25%
BenchmarkDecodeUncompressed       260809       219875  -15.70%

R=nigeltao
CC=golang-dev
https://golang.org/cl/5683050
2012-02-21 11:25:19 +11:00
Nigel Tao
996c335c4a go.image/{bmp,tiff}: move tiff/testdata to testdata.
Add a "compare to golden PNG" test for BMP and TIFF.

R=rsc
CC=golang-dev
https://golang.org/cl/5601054
2012-01-31 14:02:27 +11:00