1
0
mirror of https://github.com/golang/go synced 2024-10-03 06:31:22 -06:00
Commit Graph

29 Commits

Author SHA1 Message Date
Nigel Tao
3eb84c8908 image/jpeg: reject bad Tq values in SOF data.
Fixes #10154

Change-Id: Ibb8ea9bcf512e7639c57a6f17afbe4495fa329cd
Reviewed-on: https://go-review.googlesource.com/7494
Reviewed-by: Minux Ma <minux@golang.org>
2015-03-13 05:22:55 +00:00
Nigel Tao
782db7fc88 image/jpeg: support chroma hv values other than 0x11.
The testdata was generated by:
convert video-001.png tmp1.tga
cjpeg -quality 100 -sample 2x2,1x2,1x2 tmp1.tga > video-001.221212.jpeg
djpeg -nosmooth -targa video-001.221212.jpeg > tmp2.tga
convert tmp2.tga video-001.221212.png
rm tmp1.tga tmp2.tga

Change-Id: Ica241dfc19b3eb47ade150bf0432373c6006c38a
Reviewed-on: https://go-review.googlesource.com/7264
Reviewed-by: Rob Pike <r@golang.org>
2015-03-11 00:10:09 +00:00
Nigel Tao
cc009687bc image/jpeg: support RGB JPEG images.
The testdata was generated by:
convert video-001.png tmp1.tga
cjpeg -rgb -sample 2x2,1x1,1x1 tmp1.tga > video-001.rgb.jpeg
djpeg -nosmooth -targa video-001.rgb.jpeg > tmp2.tga
convert tmp2.tga video-001.rgb.png
rm tmp1.tga tmp2.tga

Change-Id: I5da0591b9005c1c75e807311f157d385e0e20a38
Reviewed-on: https://go-review.googlesource.com/6910
Reviewed-by: Rob Pike <r@golang.org>
2015-03-09 23:18:33 +00:00
Nigel Tao
9b73ecc327 image/jpeg: check for component uniqueness and total sampling factors.
Change-Id: I83de9d83708edc8d196bbcfdc7d2ba7ffaff50d2
Reviewed-on: https://go-review.googlesource.com/6586
Reviewed-by: Rob Pike <r@golang.org>
2015-03-04 22:44:28 +00:00
Nigel Tao
848e2feac6 image: make Rectangle implement Image.
Change-Id: I01e328fc3644b679bacf2209c3d7ade9d8bffe53
Reviewed-on: https://go-review.googlesource.com/6551
Reviewed-by: Rob Pike <r@golang.org>
2015-03-04 00:03:46 +00:00
Nigel Tao
0fe6b1293a image/jpeg: when following component selectors, only consider valid
components.

This fixes decoding JPEG images where the component selector is 0. Such
images are rare, but not impossible.

Change-Id: I6d221bce01cce8cc0440e117543233371782ca22
Reviewed-on: https://go-review.googlesource.com/6421
Reviewed-by: Rob Pike <r@golang.org>
2015-03-03 00:01:43 +00:00
Nigel Tao
a773fae808 image/jpeg: distinguish between FormatError and UnsupportedError when
encountering unknown markers.

Change-Id: Ica86013308d69da2f5b486119235ff693135b2f1
Reviewed-on: https://go-review.googlesource.com/6393
Reviewed-by: David Symonds <dsymonds@golang.org>
Run-TryBot: David Symonds <dsymonds@golang.org>
2015-03-02 00:53:23 +00:00
Nigel Tao
c20323d2bb image/draw: add a fast path for Gray src images.
Grayscale PNG and JPEG images are not uncommon. We should have a fast path.

Also add a benchmark for the recently added CMYK fast path.

benchmark                    old ns/op     new ns/op     delta
BenchmarkGray                13960348      324152        -97.68%

Change-Id: I72b5838c8c3d1f2d0a4536a848e020e80b10c0f7
Reviewed-on: https://go-review.googlesource.com/6237
Reviewed-by: Rob Pike <r@golang.org>
2015-02-28 21:43:39 +00:00
Nigel Tao
66c4031ee9 image/draw: optimize drawFillSrc.
benchmark                    old ns/op     new ns/op     delta
BenchmarkFillSrc             46781         46000         -1.67%

Change-Id: I0ab25d42d5763f1a0fe5a67ee00b83f0aa55f1f6
Reviewed-on: https://go-review.googlesource.com/6235
Reviewed-by: Rob Pike <r@golang.org>
2015-02-28 01:26:54 +00:00
Nigel Tao
a32dd83253 image/jpeg: support 4:1:1 and 4:1:0 chroma subsampling.
The test data was generated by:
convert video-001.png tmp.tga
cjpeg -quality 50 -sample 4x2,1x1,1x1 tmp.tga > video-001.q50.410.jpeg
cjpeg -quality 50 -sample 4x1,1x1,1x1 tmp.tga > video-001.q50.411.jpeg
cjpeg -quality 50 -sample 4x2,1x1,1x1 -progressive tmp.tga > video-001.q50.410.progressive.jpeg
cjpeg -quality 50 -sample 4x1,1x1,1x1 -progressive tmp.tga > video-001.q50.411.progressive.jpeg
rm tmp.tga

Change-Id: I5570389c462360f98c3160f3c6963d9466d511de
Reviewed-on: https://go-review.googlesource.com/6041
Reviewed-by: Rob Pike <r@golang.org>
2015-02-26 02:08:45 +00:00
Nigel Tao
7d7351395d image: add YCbCrSubsampleRatio411 and YCbCrSubsampleRatio410.
Some real world JPEG images are in 4:1:1 and 4:1:0 formats.

See also http://en.wikipedia.org/wiki/Chroma_subsampling

Change-Id: I2d51a41944f581cf11f4ab975046b1737271842f
Reviewed-on: https://go-review.googlesource.com/5838
Reviewed-by: Rob Pike <r@golang.org>
2015-02-26 00:14:16 +00:00
Nigel Tao
270f8447d6 image/jpeg: support 16-bit quantization tables and Extended Sequential
frames.

Fixes #9888.

Change-Id: I60f1d843e72e1b7bc77ab984f149c9ddb5258a06
Reviewed-on: https://go-review.googlesource.com/5251
Reviewed-by: Rob Pike <r@golang.org>
2015-02-19 05:00:43 +00:00
Nigel Tao
84c7a6583a image: change Rectangle.Eq to return true for all empty rectangles, even
if their nominal Min and Max points differ.

This is a behavior change, but arguably a bug fix, as Eq wasn't
previously consistent with In, and the concept of a rectangle being a
set of points. This is demonstrated by the new geom_test.go test.

It does mean that r.Eq(s) no longer implies that Inset'ting both r and s
with a negative inset results in two rectangles that are still Eq, but
that seems acceptable to me.

The previous behavior is still available as "r == s".

Also clarify the image.Rect doc comment when the inputs are
non-canonical.

Also simplify the Point and Rectangle Eq implementations dating from
before Go 1.0, when you couldn't compare structs via the == operator.

Change-Id: Ic39e628db31dc5fe5220f4b444e6d5000eeace5b
Reviewed-on: https://go-review.googlesource.com/5006
Reviewed-by: Rob Pike <r@golang.org>
2015-02-18 23:50:09 +00:00
Nigel Tao
391805b14b image/draw: add CMYK fast path.
Change-Id: I9582aff7ca141a8aead5692af74b9c708b1700cc
Reviewed-on: https://go-review.googlesource.com/5020
Reviewed-by: Rob Pike <r@golang.org>
2015-02-17 23:17:12 +00:00
Nigel Tao
5c8f9e38eb image: fix Rectangle.Overlaps and Rectangle.Union for empty rectangles.
Fixes #9895.

Change-Id: I37d78ced9ff8196e32d299504908a1c41ad4592d
Reviewed-on: https://go-review.googlesource.com/4990
Reviewed-by: Rob Pike <r@golang.org>
2015-02-17 03:40:33 +00:00
Nigel Tao
37a61746ee image/draw: add CMYK test.
This just adds test cases. Optimizing CMYK draws will be a follow-up
change.

Change-Id: Ic0d6343d420cd021e21f88623ad7182e93017da9
Reviewed-on: https://go-review.googlesource.com/4941
Reviewed-by: Rob Pike <r@golang.org>
2015-02-17 00:08:47 +00:00
Nigel Tao
10a4696fb8 image/jpeg: remove the (temporary) dependency on image/draw.
Change-Id: Idd66f9c3c9eaa4ff1f950fb90e4800dc625dec08
Reviewed-on: https://go-review.googlesource.com/4916
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-02-16 04:37:15 +00:00
Nigel Tao
f10e03770c image/jpeg: support decoding CMYK and YCbCrK images.
The new testdata was created by:

convert video-001.png -colorspace cmyk video-001.cmyk.jpeg

video-001.cmyk.jpeg was then converted back to video-001.cmyk.png via
the GIMP. ImageMagick (convert) wasn't used for this second conversion
because IM's default color profiles complicates things.

Fixes #4500.

Change-Id: Ibf533f6a6c7e76883acc493ce3a4289d7875df3f
Reviewed-on: https://go-review.googlesource.com/4801
Reviewed-by: Rob Pike <r@golang.org>
2015-02-16 00:25:47 +00:00
Nigel Tao
b5c3a9e572 image: add image.CMYK and color.CMYK types.
Change-Id: Icf212a4b890725c803b16e76e1a88294b8b62cb8
Reviewed-on: https://go-review.googlesource.com/4800
Reviewed-by: Rob Pike <r@golang.org>
2015-02-16 00:08:49 +00:00
Andrew Ekstedt
f5f00be2ec image: fix obsolete reference in PalettedImage doc comment
PalettedColorModel was renamed to color.Palette
over three years ago by https://golang.org/cl/5132048.

Change-Id: I0204ade10eabff45620fda2990fed428c65d871e
Reviewed-on: https://go-review.googlesource.com/3305
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-02-06 04:06:44 +00:00
Andrew Ekstedt
dfc4997ede image: fix typo in Alpha16 doc comment
Change-Id: Ie7031ae37f52ea1f229bfb769daf306d537b3d3e
Reviewed-on: https://go-review.googlesource.com/3300
Reviewed-by: Minux Ma <minux@golang.org>
2015-01-25 22:46:49 +00:00
Nigel Tao
9785a3962d image/draw: fold TestClipWithNilMP into TestClip.
https://go-review.googlesource.com/#/c/1876/ introduced a new
TestClipWithNilMP test, along with a code change that fixed a panic,
but the existing TestClip test already contained almost enough machinery
to cover that bug.

There is a small code change in this CL, but it is a no-op: (*x).y is
equivalent to x.y for a pointer-typed x, but the latter is cleaner.

Change-Id: I79cf6952a4999bc4b91f0a8ec500acb108106e56
Reviewed-on: https://go-review.googlesource.com/2304
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-01-14 06:04:13 +00:00
Nigel Tao
0b52392ef7 image: use three-index slice for NewYCbCr.
This ensures that changing an image.YCbCr's Y values can't change its
chroma values, even after re-slicing up to capacity.

Change-Id: Icb626561522e336a3220e10f456c95330ae7db9e
Reviewed-on: https://go-review.googlesource.com/2209
Reviewed-by: Rob Pike <r@golang.org>
2015-01-05 03:32:15 +00:00
Dave Cheney
64e6fe2d29 image/draw: fix crash in clip
Fixes #9177

Change-Id: I1c7e57f0f0a9b00fb3ddc7fa4844ac53ea6df46f
Reviewed-on: https://go-review.googlesource.com/1876
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-20 06:00:38 +00:00
Russ Cox
04923042bd image/jpeg: handle Read returning n > 0, err != nil in d.fill
Fixes #9127.

LGTM=r
R=bradfitz, r
CC=golang-codereviews, nigeltao
https://golang.org/cl/178120043
2014-11-22 13:55:33 -05:00
Nigel Tao
0be3176a8b image/gif: don't let the per-frame transparent index modify the global
palette.

Fixes #7993.

LGTM=r
R=r
CC=golang-codereviews, james.jdunne
https://golang.org/cl/138600043
2014-09-22 14:29:45 +10:00
Nigel Tao
a2910958a2 image/gif: fix GIF encoding of sub-images.
benchmark                    old ns/op     new ns/op     delta
BenchmarkEncode              8641055       8646829       +0.07%

Fixes #7792.

LGTM=r
R=r
CC=dbathgate, golang-codereviews
https://golang.org/cl/147730043
2014-09-18 12:43:01 +10:00
Nigel Tao
8e77a7ef6b image/jpeg: reject invalid Ta and Td values.
Fixes #8693.

LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/141470043
2014-09-15 08:41:59 +10:00
Russ Cox
c007ce824d build: move package sources from src/pkg to src
Preparation was in CL 134570043.
This CL contains only the effect of 'hg mv src/pkg/* src'.
For more about the move, see golang.org/s/go14nopkg.
2014-09-08 00:08:51 -04:00