Compare commits

..

57 Commits

Author SHA1 Message Date
2a04b034f7 update ChangeLog
Change-Id: Idea3464bbcb28896179c99488e7b96a4341b508a
2013-06-17 16:53:22 -07:00
7288950b88 Regression fix for alpha channels using color cache:
Considering the fact that insert to/lookup from the color cache is always 32
bit, use DecodeImageData() variant in that case.

Conflicts:
	src/dec/vp8l.c

Change-Id: I6c665a6cfbd9bd10651c1e82fa54e687cbd54a2b
(cherry picked from commit a37eff47d6)
2013-06-17 16:29:09 -07:00
2e377b53b0 wicdec: silence a format warning
from x86_64-w64-mingw32-gcc

examples/wicdec.c: In function ‘ExtractICCP’:
examples/wicdec.c:131:21: warning: format ‘%u’ expects argument of type
‘unsigned int’, but argument 4 has type ‘size_t’ [-Wformat]

Change-Id: I6642dae62265a2276ae9ac96dd8ce6f1e2d37ca5
(cherry picked from commit ffae9f31e8)
2013-06-17 15:43:33 -07:00
ad9e42a6fe muxedit: silence some uninitialized warnings
src/mux/muxedit.c:490: warning: 'x_offset' may be used uninitialized in this function
src/mux/muxedit.c:490: warning: 'y_offset' may be used uninitialized in this function

Change-Id: I4fd27f717e59a556354d0560b633d0edafe7a4d8
(cherry picked from commit 14cd5c6c40)
2013-06-17 15:43:33 -07:00
825e73b1a6 update ChangeLog
Change-Id: I2e67e5d80cb8f8e4453cee45144bcc01e9a3efeb
2013-06-12 23:32:59 -07:00
abf6f6915f update NEWS
Change-Id: Ie831ecc6995679acaf238686e2f287bfaa0221a7
2013-06-12 23:25:09 -07:00
5a92c1a5e9 bump version to 0.3.1
libwebp{,decoder} - 0.3.1
libwebp libtool - 4.3.0 (compatible release)
libwebpdecoder libtool - 0.1.0 (compatible release)

mux/demux - 0.1.1
libtool - 0.1.0 (compatible release)

Change-Id: Icc8329a6bcd9eea5a715ea83f1535a66d6ba4b58
2013-06-12 23:19:13 -07:00
67bc353e6d Revert "add WebPBlendAlpha() function to blend colors against background"
This reverts commit dcbb1ca54a.

Dropping this for now to maintain compatibility for 0.3.1.

Change-Id: I44e032a072d317bb67e1439c42cff923e603038f
2013-06-12 15:02:09 -07:00
38cc011408 Simplify forward-WHT + SSE2 version
no precision loss observed
speed is not really faster (0.5% at max), as forward-WHT isn't called often.

also: replaced a "int << 3" (undefined by C-spec) by a "int * 8"
( supersedes https://gerrit.chromium.org/gerrit/#/c/48739/ )

Change-Id: I2d980ec2f20f4ff6be5636105ff4f1c70ffde401
(cherry picked from commit 9c4ce971a8)
2013-06-12 13:48:11 -07:00
f32097e0df probe input file and quick-check for WebP format.
Error message is clearer that 'can't create demux object'.

Change-Id: Iec008601892f7cd8399e1948751747ac23305eef
(cherry picked from commit 830f72b7e9)
2013-06-11 15:03:23 -07:00
a2aed1d08c configure: improve gl/glut library test
add a check for a libGL function (glOrtho) in addition to glutMainLoop
when establishing the need for libGL at link time.

fixes vwebp link failure on ubuntu 13.04+

Change-Id: I537e9a5cab5cf4cd8875e06268d2107f377e625e
(cherry picked from commit 2ccf58d648)
2013-06-11 15:03:23 -07:00
c7e89cbb02 update copyright text
rather than symlink the webm/vpx terms, use the same header as libvpx to
reference in-tree files

based on the discussion in:
https://codereview.chromium.org/12771026/

Change-Id: Ia3067ecddefaa7ee01550136e00f7b3f086d4af4
(cherry picked from commit d640614d54)
2013-06-11 15:03:22 -07:00
a00380d2ed configure: remove use of AS_VAR_APPEND
This wasn't used often and benefits were likely minimal. Dropping it
outright is a bit simpler than adding a compatibility ifdef.

provides some compatibility with older versions of autoconf.
tested with autoconf 2.59/automake 1.7/aclocal 1.7

Change-Id: Ifed892346cf2329597985704830a96fc58d65607
(cherry picked from commit 9326a56f8d)
2013-06-11 15:03:22 -07:00
a94a88dd62 fix EXIF parsing in PNG
'exiftool' puts an 'APP1' chunk for exif, e.g.:
https://metacpan.org/source/EXIFTOOL/Image-ExifTool-5.87/lib/Image/ExifTool/PNG.pm#L305

Change-Id: I313d3e6945898526b8a4baf3d9016a2591a1a817
(cherry picked from commit bec11092ca)
2013-06-11 15:03:22 -07:00
a71e5d84e9 add doc precision for WebPPictureCopy() and WebPPictureView()
output picture object is overwritten, not free'd or destroyed.

Change-Id: Ibb47ab444063e7ad90ff3d296260807ffe7ddbf9
(cherry picked from commit 23d28e216d)
2013-06-11 15:03:21 -07:00
8287012ec7 remove datatype qualifier for vmnv
this fix is for clang (LLVM v4.2). gcc was fine.

Change-Id: Id4076cda84813f6f9548a01775b094cff22b4be9
(cherry picked from commit 3fe91635df)
2013-06-11 15:03:21 -07:00
e190843029 fix a memory leak in gif2webp
(rgba->yuv allocates memory)
Also fixed few warning and cleaned the code up.

Change-Id: Id904ad3ad8802ea9fc3d34247d27193dfa7b0b99
(cherry picked from commit 764fdffaac)
2013-06-11 15:03:21 -07:00
0b18b9eef6 fix two minor memory leaks in webpmux
(only occur in case of error)

Change-Id: Icab69bb364b77f8eae6cae91047354c27e610602
(cherry picked from commit 3e59a74d72)
2013-06-11 15:03:21 -07:00
db5095d5b6 remove some cruft from swig/libwebp.jar
picked up a few unnecessary classes from a dirty tree in the last commit

Change-Id: I98be16a0bc8716476ce440da542d113f254aee78
(cherry picked from commit 325d15ff30)
2013-06-11 15:03:21 -07:00
850e956f9b README: update swig notes
add python, required version notes

Change-Id: Iec2e94075f6cf54455ce5a658f9b7258109f4d01
(cherry picked from commit 4a7627c215)
2013-06-11 15:03:21 -07:00
bddd9b0a93 swig/python: add minimal documentation
uses autodoc to display the function arguments rather than the
inscrutable va_args (*args).

Change-Id: Iec2ff8276c1533b14c3032836d822fbdae632521
(cherry picked from commit 825b64db53)
2013-06-11 15:00:48 -07:00
d573a8d53f swig: add python encode support
wraps the simple interface similar to java.

Change-Id: Ib922bbcae322b2345b6dce5dee08faad705a77fd
(cherry picked from commit 14677e11d4)
2013-06-11 15:00:47 -07:00
6b931875ac swig/java: reduce wrapper function code duplication
define a macro to emit the wrapper code

Change-Id: I672416016162d6d9ce6f455d224044e0837e3ace
(cherry picked from commit a5c297c842)
2013-06-11 15:00:47 -07:00
6fe536f4ba swig/java: rework uint8_t typemap
reuse the declarations from arrays_java.i for signed char to make an
explicit uint8_t mapping. this avoids sign conversion build warnings.

Change-Id: Icfb5b865cf1fd404e89f2cd889111f0a94e3c604
(cherry picked from commit ad4a367dba)
2013-06-11 15:00:47 -07:00
a2ea46439e Fix the bug in ApplyPalette.
The auto-infer logic of detecting the 'Alpha' use case
(via check '(palette[i] & 0x00ff00ffu) != 0' is failing
for this corner case image with all black pixels (rgb = 0)
and different Alpha values.

-> switch generic use-LUT detection

Change-Id: I982a8b28c8bcc43e3dc68ac358f978a4bcc14c36
(cherry picked from commit afa3450c11)
2013-06-11 15:00:47 -07:00
7bb28d2a55 webp/lossless: fix big endian BGRA output
Change-Id: I3d4b3d21f561cb526dbe7697a31ea847d3e8b2c1
(cherry picked from commit 2ca83968ae)
2013-06-11 15:00:47 -07:00
f036d4bfa6 Speed up ApplyPalette for ARGB pixels.
Added 1 pixel cache for palette colors for faster lookup.
This will speedup images that require ApplyPalette by 6.5% for lossless
compression.

Change-Id: Id0c5174d797ffabdb09905c2ba76e60601b686f8
(cherry picked from commit 742110ccce)
2013-06-11 15:00:46 -07:00
8112c8cf54 remove some warnings:
* "declaration of ‘index’ shadows a global declaration [-Wshadow]"
* "signed and unsigned type in conditional expression [-Wsign-compare]"

Change-Id: I891182d919b18b6c84048486e0385027bd93b57d
(cherry picked from commit 87a4fca25f)
2013-06-11 15:00:46 -07:00
cc128e0bfc Further reduce memory to decode lossy+alpha images
Earlier such images were using roughly 9 * width * height bytes for
decoding. Now, they take 6 * width * height memory.

Change-Id: Ie4a681ca5074d96d64f30b2597fafdca648dd8f7
(cherry picked from commit 64c844863a)
2013-06-11 15:00:46 -07:00
07db70d20f fix for big-endian
(Issue #150: https://code.google.com/p/webp/issues/detail?id=150)

Change-Id: Iad46d375a8c5eabae37cde8f55b3e7448601f264
(cherry picked from commit 4437061735)
2013-06-11 15:00:46 -07:00
eda8a7dec5 gif2webp: Fix signed/unsigned comparison mismatch
Change-Id: I355f0614424276550db71b24e5bb1948e5c6894c
(cherry picked from commit 043e1ae4bd)
2013-06-11 15:00:46 -07:00
31f346fe0c Makefile.vc: fix libwebpdemux dll variable typo
Fixes issue #149

Patch by: Jason Stevens  (cypher497 at gmail dot com)

Change-Id: I65cceaad37d22b96e5e92cb78f859fc0b7c38b67
(cherry picked from commit 3eeedae1bc)
2013-06-11 15:00:45 -07:00
6c76d28e4b swig: add python (decode) support
similar to Java, simple interface only

Change-Id: I8a3d344e5d89f73627e4e0cb2067512260d46fdd
(cherry picked from commit f980faf417)
2013-06-11 15:00:45 -07:00
b4f5bb6ca3 swig: cosmetics
normalize formatting
- update decode prototypes
- match project function name style

Change-Id: Ib481b5602171b72dbb1a5d462e6d5166e9b8566e
(cherry picked from commit 7f5f42bb36)
2013-06-11 15:00:45 -07:00
498d4dd634 WebP-Lossless encoding improvements.
Lossy (with Alpha) image compression gets 2.3X speedup.
Compressing lossless images is 20%-40% faster now.

Change-Id: I41f0225838b48ae5c60b1effd1b0de72fecb3ae6
(cherry picked from commit 8eae188a62)
2013-06-11 15:00:45 -07:00
26e7244221 swig: ifdef some Java specific code
no implementation change

Change-Id: I077c707e1f6293188e6fa11ba24757009a709f77
(cherry picked from commit c7247c4c68)
2013-06-11 15:00:45 -07:00
8ecec68652 configure: add warning related flags
adds TEST_AND_ADD_CFLAGS function
uses AM_CFLAGS to allow CFLAGS override

Change-Id: I9352aec6e5d905a41d832bf5ad0c8dcd154f7e97
(cherry picked from commit bba4c2b2a6)
2013-06-11 15:00:44 -07:00
e676b04309 configure: add GLUT detection; build vwebp
Change-Id: I7f0964db2d04c22ff9ec274e8cd1cbed7379a165
(cherry picked from commit 0e513f7ae3)
2013-06-11 15:00:44 -07:00
b0ffc43700 Alpha decoding: significantly reduce memory usage
Simply get rid of an intermediate buffer of size width x height, by
using the fact that stride == width in this case.

Change-Id: I92376a2561a3beb6e723e8bcf7340c7f348e02c2
(cherry picked from commit edccd19436)
2013-06-11 15:00:44 -07:00
20aa7a8dd5 configure: add --enable-everything
Change-Id: Ie1b3abd42459de7f789fe985759c465c2a196727
(cherry picked from commit 3cafcc9a8d)
2013-06-11 15:00:44 -07:00
b8307cc08b configure.ac: add some helper macros
library check related variable maintenance -> *_INCLUDES / *_LIBS

CLEAR_LIBVARS / LIBCHECK_PROLOGUE / LIBCHECK_EPILOGUE

Change-Id: I72e292dc1f69b02f69a26639308f247db0471e2b
(cherry picked from commit 4ef1447792)
2013-06-11 15:00:44 -07:00
980e7ae951 Remove the gcc compilation comments
They went out of sync some time ago, and are
no longer really required since we have them
buildable from makefile.unix

Change-Id: Ica2dcf5c55f44365598f832f55204d123d7aa601
(cherry picked from commit a4e1cdbbe8)
2013-06-11 15:00:44 -07:00
7f25ff99fd gif2webp: Fix ICC and XMP support
Change-Id: Ib5aafef388bd191610e4cc2f8180f35cd454f1d3
(cherry picked from commit b26e5ad540)
2013-06-11 15:00:43 -07:00
d8e5321144 Add missing name to AUTHORS
Change-Id: I00092e5bb676b48abc05b94080b589b48c911c82
(cherry picked from commit 46089b207d)
2013-06-11 15:00:43 -07:00
11edf5e24b Demux: Fix a potential memleak
Change-Id: Ic0dcac010da088b791c130be4abacdd8c31e92cf
(cherry picked from commit 94328d6457)
2013-06-11 15:00:43 -07:00
c7b92184df don't forward declare enums
doing so is not part of ISO C; removes some pedantic warnings

Change-Id: I739ad8c5cacc133e2546e9f45c0db9d92fb93d7e
(cherry picked from commit 96e948d7b0)
2013-06-11 15:00:43 -07:00
7a650c6ad6 prevent signed int overflow in left shift ops
force unsigned when shifting by 24.

Change-Id: Ie229d252e2e4078107cd705b09397e686a321ffd
(cherry picked from commit f4f90880a8)
2013-06-11 15:00:43 -07:00
31bea32408 add precision about dynamic output reallocation with IDecoder
The output surface CAN be changed inbetween calls to
WebPIUpdate() or WebPIAppend(), but with precautions.

Change-Id: I899afbd95738a6a8e0e7000f8daef3e74c99ddd8
(cherry picked from commit ff885bfe1f)
2013-06-11 15:00:43 -07:00
c22877f70f Add incremental support for extended format files
This applies to images with optional chunks (e.g. images with ALPH
chunk,
ICCP chunk etc). Before this, the incremental decoding used to work like
non-incremental decoding for such files, that is, no rows were decoded
until
all data was available.

The change is in 2 parts:
- During optional chunk parsing, don't wait for the full VP8/VP8L chunk.
- Remap 'alpha_data' pointer whenever a new buffer is allocated/used in
WebPIAppend() and WebPIUpdate().

Change-Id: I6cfd6ca1f334b9c6610fcbf662cd85fa494f2a91
(cherry picked from commit ead4d47859)
2013-06-11 15:00:42 -07:00
5051245f3a Makefile.vc: have 'all' target build everything
default is still the core examples as makefile.unix

Change-Id: Ica3fe6123f4359aefa130b39d2b0739b65e34c0b
(cherry picked from commit 69d0f92658)
2013-06-11 15:00:42 -07:00
8191decae9 Makefile.vc: flags cleanup
- drop some unnecessary link flags
- use lib.exe directly for creating libraries
- factorize /nologo and use it consistently

Change-Id: Ie76119bc051e9bc53e4d6bba1a0a3f124f9062fc
(cherry picked from commit 52967498b3)
2013-06-11 15:00:42 -07:00
b9d747351a Makefile.vc: drop /FD flag
breaks under wine; from MSDN:
/FD is only used by the development environment, and it should not be
used from the command line or a build script.

Change-Id: I180c9813e721b163cc645b9b7f14fe36556019d3
(cherry picked from commit c61baf0c10)
2013-06-11 15:00:42 -07:00
5568dbcfe6 update gitignore
*.a, new examples and new automake-1.12 file (ar-lib)

Change-Id: I28d7bc59a2977a7c5959940936e3d13a71dd149c
(cherry picked from commit 3a15125d2f)
2013-06-11 15:00:42 -07:00
f4c7b6547b WebPEncode: An additional check.
Start VP8EncLoop/VP8EncTokenLoop only if VP8EncStartAlpha succeeded.

Change-Id: Id1faca3e6def88102329ae2b4974bd4d6d4c4a7a
(cherry picked from commit 67708d6701)
2013-06-11 15:00:42 -07:00
1fb04bec99 pngdec: Avoid a double-free.
Earlier, at line#275, if ok == 0, it would have triggered a double free
of 'rgb'.

Change-Id: Iaee1f35824a66f6e4b488e523416f73b87c5ec30
(cherry picked from commit b68912af2c)
2013-06-11 15:00:42 -07:00
dcbb1ca54a add WebPBlendAlpha() function to blend colors against background
new option: -blend_alpha 0xrrggbb
also: don't force picture.use_argb value for lossless. Instead,
delay the YUVA<->ARGB conversion till WebPEncode() is called.
This make the blending more accurate when source is ARGB
and lossy compression is used (YUVA).
This has an effect on cropping/rescaling. E.g. for PNG, these
are now done in ARGB colorspace instead of YUV when lossy compression
is used.

Change-Id: I18571f1b1179881737a8dbd23ad0aa8cddae3c6b
(cherry picked from commit e7d9548c9b)
2013-06-11 15:00:41 -07:00
bc9f5fbe0f configure.ac: add AM_PROG_AR for automake >= 1.12
fixes:
automake-1.12/am/ltlibrary.am: warning: 'libwebp.la': linking libtool libraries using a non-POSIX
automake-1.12/am/ltlibrary.am: archiver requires 'AM_PROG_AR' in 'configure.ac'

Change-Id: I223f93e5f075aaf23cfefceef55e2ab8eeb34ccd
(cherry picked from commit ed4dc71769)
2013-06-11 15:00:41 -07:00
124 changed files with 7583 additions and 1061 deletions

7
.gitignore vendored
View File

@ -1,8 +1,9 @@
*.l[ao] *.l[ao]
*.o *.[ao]
.deps .deps
.libs .libs
/aclocal.m4 /aclocal.m4
/ar-lib
/autom4te.cache /autom4te.cache
/compile /compile
/config.* /config.*
@ -16,7 +17,9 @@
/stamp-h1 /stamp-h1
Makefile Makefile
Makefile.in Makefile.in
examples/[cd]webp examples/[cdv]webp
examples/gif2webp
examples/webpmux
/output /output
/doc/output /doc/output
*.idb *.idb

View File

@ -1,4 +1,5 @@
Contributors: Contributors:
- Christian Duvivier (cduvivier at google dot com)
- James Zern (jzern at google dot com) - James Zern (jzern at google dot com)
- Jan Engelhardt (jengelh at medozas dot de) - Jan Engelhardt (jengelh at medozas dot de)
- Johann (johann dot koenig at duck dot com) - Johann (johann dot koenig at duck dot com)

View File

@ -1,3 +1,60 @@
7288950 Regression fix for alpha channels using color cache:
2e377b5 wicdec: silence a format warning
ad9e42a muxedit: silence some uninitialized warnings
825e73b update ChangeLog
abf6f69 update NEWS
5a92c1a bump version to 0.3.1
67bc353 Revert "add WebPBlendAlpha() function to blend colors against background"
38cc011 Simplify forward-WHT + SSE2 version
f32097e probe input file and quick-check for WebP format.
a2aed1d configure: improve gl/glut library test
c7e89cb update copyright text
a00380d configure: remove use of AS_VAR_APPEND
a94a88d fix EXIF parsing in PNG
a71e5d8 add doc precision for WebPPictureCopy() and WebPPictureView()
8287012 remove datatype qualifier for vmnv
e190843 fix a memory leak in gif2webp
0b18b9e fix two minor memory leaks in webpmux
db5095d remove some cruft from swig/libwebp.jar
850e956 README: update swig notes
bddd9b0 swig/python: add minimal documentation
d573a8d swig: add python encode support
6b93187 swig/java: reduce wrapper function code duplication
6fe536f swig/java: rework uint8_t typemap
a2ea464 Fix the bug in ApplyPalette.
7bb28d2 webp/lossless: fix big endian BGRA output
f036d4b Speed up ApplyPalette for ARGB pixels.
8112c8c remove some warnings:
cc128e0 Further reduce memory to decode lossy+alpha images
07db70d fix for big-endian
eda8a7d gif2webp: Fix signed/unsigned comparison mismatch
31f346f Makefile.vc: fix libwebpdemux dll variable typo
6c76d28 swig: add python (decode) support
b4f5bb6 swig: cosmetics
498d4dd WebP-Lossless encoding improvements.
26e7244 swig: ifdef some Java specific code
8ecec68 configure: add warning related flags
e676b04 configure: add GLUT detection; build vwebp
b0ffc43 Alpha decoding: significantly reduce memory usage
20aa7a8 configure: add --enable-everything
b8307cc configure.ac: add some helper macros
980e7ae Remove the gcc compilation comments
7f25ff9 gif2webp: Fix ICC and XMP support
d8e5321 Add missing name to AUTHORS
11edf5e Demux: Fix a potential memleak
c7b9218 don't forward declare enums
7a650c6 prevent signed int overflow in left shift ops
31bea32 add precision about dynamic output reallocation with IDecoder
c22877f Add incremental support for extended format files
5051245 Makefile.vc: have 'all' target build everything
8191dec Makefile.vc: flags cleanup
b9d7473 Makefile.vc: drop /FD flag
5568dbc update gitignore
f4c7b65 WebPEncode: An additional check. Start VP8EncLoop/VP8EncTokenLoop only if VP8EncStartAlpha succeeded.
1fb04be pngdec: Avoid a double-free.
dcbb1ca add WebPBlendAlpha() function to blend colors against background
bc9f5fb configure.ac: add AM_PROG_AR for automake >= 1.12
1e0d4b8 Update ChangeLog (tag: v0.3.0-rc7, tag: v0.3.0)
d52b405 Cosmetic fixes d52b405 Cosmetic fixes
6cb4a61 misc style fix 6cb4a61 misc style fix
68111ab add missing YUVA->ARGB automatic conversion in WebPEncode() 68111ab add missing YUVA->ARGB automatic conversion in WebPEncode()
@ -18,7 +75,7 @@ a5ebd14 gif2webp: Bgcolor fix for a special case
3c8eb9a fix bad saturation order in QuantizeBlock 3c8eb9a fix bad saturation order in QuantizeBlock
04c7a2e vwebp/animation: fix background dispose 04c7a2e vwebp/animation: fix background dispose
81a5069 Makefile.vc: fix dynamic builds 81a5069 Makefile.vc: fix dynamic builds
5f25c39 update ChangeLog 5f25c39 update ChangeLog (tag: v0.3.0-rc6)
14d42af examples: don't use C99 %zu 14d42af examples: don't use C99 %zu
5ccf1fe update ChangeLog 5ccf1fe update ChangeLog
2560c24 update NEWS 2560c24 update NEWS
@ -324,7 +381,7 @@ a61a824 Merge "Add NULL check in chunk APIs"
a077072 mux struct naming a077072 mux struct naming
6c66dde Merge "Tune Lossless encoder" 6c66dde Merge "Tune Lossless encoder"
ab5ea21 Tune Lossless encoder ab5ea21 Tune Lossless encoder
74fefc8 Update ChangeLog (v0.2.1, origin/0.2.0) 74fefc8 Update ChangeLog (tag: v0.2.1, origin/0.2.0)
92f8059 Rename some chunks: 92f8059 Rename some chunks:
3bb4bbe Merge "Mux API change:" 3bb4bbe Merge "Mux API change:"
d0c79f0 Mux API change: d0c79f0 Mux API change:
@ -394,7 +451,7 @@ c7eb457 make VP8DspInitNEON() public
ab3234a Create WebPMuxFrameInfo struct for Mux APIs ab3234a Create WebPMuxFrameInfo struct for Mux APIs
e3990fd Alignment fixes e3990fd Alignment fixes
e55fbd6 Merge branch '0.2.0' e55fbd6 Merge branch '0.2.0'
4238bc0 Update ChangeLog (v0.2.0) 4238bc0 Update ChangeLog (tag: v0.2.0)
c655380 dec/io.c: cosmetics c655380 dec/io.c: cosmetics
fe1958f RGBA4444: harmonize lossless/lossy alpha values fe1958f RGBA4444: harmonize lossless/lossy alpha values
681cb30 fix RGBA4444 output w/fancy upsampling 681cb30 fix RGBA4444 output w/fancy upsampling
@ -405,7 +462,7 @@ f56e98f Alignment fix
a0a4885 Lossless decoder fix for a special transform order a0a4885 Lossless decoder fix for a special transform order
62dd9bb Update encoding heuristic w.r.t palette colors. 62dd9bb Update encoding heuristic w.r.t palette colors.
6f4272b remove unused ApplyInverseTransform() 6f4272b remove unused ApplyInverseTransform()
93bf0fa Update ChangeLog (v0.2.0-rc1) 93bf0fa Update ChangeLog (tag: v0.2.0-rc1)
5934fc5 update AUTHORS 5934fc5 update AUTHORS
014a711 update NEWS 014a711 update NEWS
43b0d61 add support for ARGB -> YUVA conversion for lossless decoder 43b0d61 add support for ARGB -> YUVA conversion for lossless decoder
@ -448,7 +505,7 @@ cbee59e Merge commit 'v0.1.99'
3bc3f7c Merge "dwebp: add PAM output support" into 0.2.0 3bc3f7c Merge "dwebp: add PAM output support" into 0.2.0
d919ed0 dwebp: add PAM output support d919ed0 dwebp: add PAM output support
85e215d README/manpages/configure: update website link 85e215d README/manpages/configure: update website link
c3a207b Update ChangeLog (v0.1.99) c3a207b Update ChangeLog (tag: v0.1.99)
d1fd782 Merge "add extra precision about default values and behaviour" into 0.2.0 d1fd782 Merge "add extra precision about default values and behaviour" into 0.2.0
efc826e add extra precision about default values and behaviour efc826e add extra precision about default values and behaviour
9f29635 header/doc clean up 9f29635 header/doc clean up
@ -1073,7 +1130,7 @@ f3bf4c7 Added Mux Container Spec & README for MUX-API.
9f761cf Changed function signature for WebPMuxCreate 9f761cf Changed function signature for WebPMuxCreate
5f31b5e Merge "Add Mux library for manipulating WebP container." 5f31b5e Merge "Add Mux library for manipulating WebP container."
2315785 Add Mux library for manipulating WebP container. 2315785 Add Mux library for manipulating WebP container.
7e198ab update ChangeLog (v0.1.3) 7e198ab update ChangeLog (tag: v0.1.3)
dfc9c1e Harmonize the dates dfc9c1e Harmonize the dates
28ad70c Fix PNG decoding bug 28ad70c Fix PNG decoding bug
846e93c Update AUTHORS & add .mailmap 846e93c Update AUTHORS & add .mailmap
@ -1214,7 +1271,7 @@ cfbf88a add SSE2 functions. ~2x faster encoding on average.
e7ff3f9 merge two ITransforms together when applicable and change the TTransform to return the sum directly. e7ff3f9 merge two ITransforms together when applicable and change the TTransform to return the sum directly.
ca55413 fix WebPIDecGetRGB() to accept any RGB(A) mode, not just MODE_RGB ca55413 fix WebPIDecGetRGB() to accept any RGB(A) mode, not just MODE_RGB
8aa50ef fix some 'man' typos 8aa50ef fix some 'man' typos
d3f3bdd update ChangeLog (v0.1.2) d3f3bdd update ChangeLog (tag: v0.1.2)
d7e9a69 update contributor list d7e9a69 update contributor list
261abb8 add a 'superclean' section 261abb8 add a 'superclean' section
276ae82 Remove files not mean to be in git, and update .gitignore 276ae82 Remove files not mean to be in git, and update .gitignore

View File

@ -24,18 +24,18 @@ PLATFORM_LDFLAGS = /SAFESEH
############################################################# #############################################################
## Nothing more to do below this line! ## Nothing more to do below this line!
MT = mt.exe NOLOGO = /nologo
CCNODBG = cl.exe /nologo /O2 /DNDEBUG CCNODBG = cl.exe $(NOLOGO) /O2 /DNDEBUG
CCDEBUG = cl.exe /nologo /Od /Gm /Zi /D_DEBUG /RTC1 CCDEBUG = cl.exe $(NOLOGO) /Od /Gm /Zi /D_DEBUG /RTC1
CFLAGS = /Isrc /nologo /W3 /EHsc /FD /c /GS CFLAGS = /Isrc $(NOLOGO) /W3 /EHsc /c /GS
CFLAGS = $(CFLAGS) /DWIN32 /D_CRT_SECURE_NO_WARNINGS /DWIN32_LEAN_AND_MEAN CFLAGS = $(CFLAGS) /DWIN32 /D_CRT_SECURE_NO_WARNINGS /DWIN32_LEAN_AND_MEAN
CFLAGS = $(CFLAGS) /DHAVE_WINCODEC_H /DWEBP_USE_THREAD CFLAGS = $(CFLAGS) /DHAVE_WINCODEC_H /DWEBP_USE_THREAD
LDFLAGS = /LARGEADDRESSAWARE /MANIFEST /NXCOMPAT /DYNAMICBASE LDFLAGS = /LARGEADDRESSAWARE /MANIFEST /NXCOMPAT /DYNAMICBASE
LDFLAGS = $(LDFLAGS) $(PLATFORM_LDFLAGS) LDFLAGS = $(LDFLAGS) $(PLATFORM_LDFLAGS)
LNKDLL = link.exe /DLL LNKDLL = link.exe /DLL $(NOLOGO)
LNKLIB = link.exe /lib LNKEXE = link.exe $(NOLOGO)
LNKEXE = link.exe LNKLIB = lib.exe $(NOLOGO)
LFLAGS = /nologo /machine:$(ARCH) MT = mt.exe $(NOLOGO)
CFGSET = FALSE CFGSET = FALSE
!IF "$(OBJDIR)" == "" !IF "$(OBJDIR)" == ""
@ -108,7 +108,7 @@ CC = $(CC) /I$(DIROBJ) /FI$(DLLINC) $(RTLIB) /DWEBP_DLL
LIBWEBPDECODER = $(DIRLIB)\$(LIBWEBPDECODER_BASENAME)_dll.lib LIBWEBPDECODER = $(DIRLIB)\$(LIBWEBPDECODER_BASENAME)_dll.lib
LIBWEBP = $(DIRLIB)\$(LIBWEBP_BASENAME)_dll.lib LIBWEBP = $(DIRLIB)\$(LIBWEBP_BASENAME)_dll.lib
LIBWEBPMUX = $(DIRLIB)\$(LIBWEBPMUX_BASENAME)_dll.lib LIBWEBPMUX = $(DIRLIB)\$(LIBWEBPMUX_BASENAME)_dll.lib
LIBWEBPDEMUX = $(DIRLIB)\$(LIBWEBPMDEMUX_BASENAME)_dll.lib LIBWEBPDEMUX = $(DIRLIB)\$(LIBWEBPDEMUX_BASENAME)_dll.lib
LIBWEBP_PDBNAME = $(DIROBJ)\$(LIBWEBP_BASENAME)_dll.pdb LIBWEBP_PDBNAME = $(DIROBJ)\$(LIBWEBP_BASENAME)_dll.pdb
CFGSET = TRUE CFGSET = TRUE
!ENDIF !ENDIF
@ -130,7 +130,8 @@ CFGSET = TRUE
!MESSAGE - clean - perform a clean for CFG !MESSAGE - clean - perform a clean for CFG
!MESSAGE - experimental - build CFG with experimental !MESSAGE - experimental - build CFG with experimental
!MESSAGE . features enabled. !MESSAGE . features enabled.
!MESSAGE - (empty) or all - build all targets for CFG !MESSAGE - (empty) - build libwebp-based targets for CFG
!MESSAGE - all - build (de)mux-based targets for CFG
!MESSAGE !MESSAGE
!MESSAGE RTLIBCFG controls the runtime library linkage - 'static' or 'dynamic'. !MESSAGE RTLIBCFG controls the runtime library linkage - 'static' or 'dynamic'.
!MESSAGE OBJDIR is the path where you like to build (obj, bins, etc.), !MESSAGE OBJDIR is the path where you like to build (obj, bins, etc.),
@ -238,8 +239,10 @@ LIBWEBPDEMUX_OBJS = $(DEMUX_OBJS) $(LIBWEBPDEMUX_OBJS)
OUT_LIBS = $(LIBWEBPDECODER) $(LIBWEBP) OUT_LIBS = $(LIBWEBPDECODER) $(LIBWEBP)
OUT_EXAMPLES = $(DIRBIN)\cwebp.exe $(DIRBIN)\dwebp.exe OUT_EXAMPLES = $(DIRBIN)\cwebp.exe $(DIRBIN)\dwebp.exe
EXTRA_EXAMPLES = $(DIRBIN)\vwebp.exe $(DIRBIN)\webpmux.exe
all: $(OUT_LIBS) $(OUT_EXAMPLES) ex: $(OUT_LIBS) $(OUT_EXAMPLES)
all: ex $(EXTRA_EXAMPLES)
$(DIRBIN)\cwebp.exe: $(DIROBJ)\examples\cwebp.obj $(EX_FORMAT_DEC_OBJS) $(DIRBIN)\cwebp.exe: $(DIROBJ)\examples\cwebp.obj $(EX_FORMAT_DEC_OBJS)
$(DIRBIN)\dwebp.exe: $(DIROBJ)\examples\dwebp.obj $(DIRBIN)\dwebp.exe: $(DIROBJ)\examples\dwebp.obj
$(DIRBIN)\vwebp.exe: $(DIROBJ)\examples\vwebp.obj $(DIRBIN)\vwebp.exe: $(DIROBJ)\examples\vwebp.obj
@ -247,6 +250,7 @@ $(DIRBIN)\vwebp.exe: $(EX_UTIL_OBJS) $(LIBWEBPDEMUX) $(LIBWEBP)
$(DIRBIN)\webpmux.exe: $(DIROBJ)\examples\webpmux.obj $(LIBWEBPMUX) $(DIRBIN)\webpmux.exe: $(DIROBJ)\examples\webpmux.obj $(LIBWEBPMUX)
$(DIRBIN)\webpmux.exe: $(EX_UTIL_OBJS) $(LIBWEBP) $(DIRBIN)\webpmux.exe: $(EX_UTIL_OBJS) $(LIBWEBP)
$(OUT_EXAMPLES): $(EX_UTIL_OBJS) $(LIBWEBP) $(OUT_EXAMPLES): $(EX_UTIL_OBJS) $(LIBWEBP)
$(EX_UTIL_OBJS) $(EX_FORMAT_DEC_OBJS): $(OUTPUT_DIRS)
experimental: experimental:
$(MAKE) /f Makefile.vc \ $(MAKE) /f Makefile.vc \
@ -278,7 +282,7 @@ clean::
@-erase /s $(DIROBJ)\$(DLLC) $(DIROBJ)\$(DLLINC) 2> NUL @-erase /s $(DIROBJ)\$(DLLC) $(DIROBJ)\$(DLLINC) 2> NUL
!ELSE !ELSE
$(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX): $(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX):
$(LNKLIB) /out:$@ $(LFLAGS) $** $(LNKLIB) /out:$@ $**
-xcopy $(DIROBJ)\*.pdb $(DIRLIB) /y -xcopy $(DIROBJ)\*.pdb $(DIRLIB) /y
!ENDIF !ENDIF

6
NEWS
View File

@ -1,3 +1,9 @@
- 6/13/13: version 0.3.1
This is a binary compatible release.
* Add incremental decoding support for images containing ALPH and ICCP chunks.
* Python bindings via swig for the simple encode/decode interfaces similar to
Java.
- 3/20/13: version 0.3.0 - 3/20/13: version 0.3.0
This is a binary compatible release. This is a binary compatible release.
* WebPINewRGB/WebPINewYUVA accept being passed a NULL output buffer * WebPINewRGB/WebPINewYUVA accept being passed a NULL output buffer

14
README
View File

@ -4,7 +4,7 @@
\__\__/\____/\_____/__/ ____ ___ \__\__/\____/\_____/__/ ____ ___
/ _/ / \ \ / _ \/ _/ / _/ / \ \ / _ \/ _/
/ \_/ / / \ \ __/ \__ / \_/ / / \ \ __/ \__
\____/____/\_____/_____/____/v0.3.0 \____/____/\_____/_____/____/v0.3.1
Description: Description:
============ ============
@ -80,8 +80,8 @@ more options.
SWIG bindings: SWIG bindings:
-------------- --------------
To generate language bindings from swig/libwebp.i swig-1.3 To generate language bindings from swig/libwebp.i at least swig-1.3
(http://www.swig.org) is required. 2.0 may work, but has not been tested. (http://www.swig.org) is required.
Currently the following functions are mapped: Currently the following functions are mapped:
Decode: Decode:
@ -104,12 +104,20 @@ Encode:
WebPEncodeLosslessRGB WebPEncodeLosslessRGB
WebPEncodeLosslessBGR WebPEncodeLosslessBGR
See swig/README for more detailed build instructions.
Java bindings: Java bindings:
To build the swig-generated JNI wrapper code at least JDK-1.5 (or equivalent) To build the swig-generated JNI wrapper code at least JDK-1.5 (or equivalent)
is necessary for enum support. The output is intended to be a shared object / is necessary for enum support. The output is intended to be a shared object /
DLL that can be loaded via System.loadLibrary("webp_jni"). DLL that can be loaded via System.loadLibrary("webp_jni").
Python bindings:
To build the swig-generated Python extension code at least Python 2.6 is
required. Python < 2.6 may build with some minor changes to libwebp.i or the
generated code, but is untested.
Encoding tool: Encoding tool:
============== ==============

View File

@ -1,7 +1,7 @@
 __ __ ____ ____ ____ __ __ _ __ __  __ __ ____ ____ ____ __ __ _ __ __
/ \\/ \/ _ \/ _ \/ _ \/ \ \/ \___/_ / _\ / \\/ \/ _ \/ _ \/ _ \/ \ \/ \___/_ / _\
\ / __/ _ \ __/ / / (_/ /__ \ / __/ _ \ __/ / / (_/ /__
\__\__/\_____/_____/__/ \__//_/\_____/__/___/v0.1.0 \__\__/\_____/_____/__/ \__//_/\_____/__/___/v0.1.1
Description: Description:

View File

@ -1,19 +1,67 @@
AC_INIT([libwebp], [0.3.0], AC_INIT([libwebp], [0.3.1],
[http://code.google.com/p/webp/issues],, [http://code.google.com/p/webp/issues],,
[http://developers.google.com/speed/webp]) [http://developers.google.com/speed/webp])
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
dnl === automake >= 1.12 requires this for 'unusual archivers' support.
dnl === it must occur before LT_INIT (AC_PROG_LIBTOOL).
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
AM_PROG_CC_C_O AM_PROG_CC_C_O
dnl === Enable less verbose output when building. dnl === Enable less verbose output when building.
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
dnl === SET_IF_UNSET(shell_var, value)
dnl === Set the shell variable 'shell_var' to 'value' if it is unset.
AC_DEFUN([SET_IF_UNSET], [test "${$1+set}" = "set" || $1=$2])
AC_ARG_ENABLE([everything],
AS_HELP_STRING([--enable-everything],
[Enable all optional targets. These can still be
disabled with --disable-target]),
[SET_IF_UNSET([enable_libwebpdecoder], [$enableval])
SET_IF_UNSET([enable_libwebpdemux], [$enableval])
SET_IF_UNSET([enable_libwebpmux], [$enableval])])
AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=DIR], AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=DIR],
[Path to the pkgconfig directory @<:@LIBDIR/pkgconfig@:>@]), [Path to the pkgconfig directory @<:@LIBDIR/pkgconfig@:>@]),
[pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig']) [pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig'])
AC_SUBST([pkgconfigdir]) AC_SUBST([pkgconfigdir])
dnl === TEST_AND_ADD_CFLAGS(flag)
dnl === Checks whether $CC supports 'flag' and adds it to AM_CFLAGS on success.
AC_DEFUN([TEST_AND_ADD_CFLAGS],
[SAVED_CFLAGS="$CFLAGS"
CFLAGS="-Werror $1"
AC_MSG_CHECKING([whether $CC supports $1])
dnl Note AC_LANG_PROGRAM([]) uses an old-style main definition.
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])],
[AC_MSG_RESULT([yes])]
dnl Simply append the variable avoiding a
dnl compatibility ifdef for AS_VAR_APPEND as this
dnl variable shouldn't grow all that large.
[AM_CFLAGS="$AM_CFLAGS $1"],
[AC_MSG_RESULT([no])])
CFLAGS="$SAVED_CFLAGS"])
TEST_AND_ADD_CFLAGS([-Wall])
TEST_AND_ADD_CFLAGS([-Wdeclaration-after-statement])
TEST_AND_ADD_CFLAGS([-Wextra])
TEST_AND_ADD_CFLAGS([-Wmissing-declarations])
TEST_AND_ADD_CFLAGS([-Wmissing-prototypes])
TEST_AND_ADD_CFLAGS([-Wold-style-definition])
TEST_AND_ADD_CFLAGS([-Wshadow])
TEST_AND_ADD_CFLAGS([-Wunused-but-set-variable])
TEST_AND_ADD_CFLAGS([-Wunused])
TEST_AND_ADD_CFLAGS([-Wvla])
AC_SUBST([AM_CFLAGS])
dnl === CLEAR_LIBVARS([var_pfx])
dnl === Clears <var_pfx>_{INCLUDES,LIBS}.
AC_DEFUN([CLEAR_LIBVARS], [$1_INCLUDES=""; $1_LIBS=""])
dnl === WITHLIB_OPTION([opt_pfx], [outvar_pfx]) dnl === WITHLIB_OPTION([opt_pfx], [outvar_pfx])
dnl === Defines --with-<opt_pfx>{include,lib}dir options which set dnl === Defines --with-<opt_pfx>{include,lib}dir options which set
dnl === the variables <outvar_pfx>_{INCLUDES,LIBS}. dnl === the variables <outvar_pfx>_{INCLUDES,LIBS}.
@ -27,6 +75,24 @@ AC_DEFUN([WITHLIB_OPTION],
[use $2 libraries from DIR]), [use $2 libraries from DIR]),
[$2_LIBS="-L$withval"])]) [$2_LIBS="-L$withval"])])
dnl === LIBCHECK_PROLOGUE([var_pfx])
dnl === Caches the current values of CPPFLAGS/LIBS in SAVED_* then
dnl === prepends the current values with <var_pfx>_{INCLUDES,LIBS}.
AC_DEFUN([LIBCHECK_PROLOGUE],
[SAVED_CPPFLAGS=$CPPFLAGS
SAVED_LIBS=$LIBS
CPPFLAGS="$$1_INCLUDES $CPPFLAGS"
LIBS="$$1_LIBS $LIBS"])
dnl === LIBCHECK_EPILOGUE([var_pfx])
dnl === Restores the values of CPPFLAGS/LIBS from SAVED_* and exports
dnl === <var_pfx>_{INCLUDES,LIBS} with AC_SUBST.
AC_DEFUN([LIBCHECK_EPILOGUE],
[AC_SUBST($1_LIBS)
AC_SUBST($1_INCLUDES)
CPPFLAGS=$SAVED_CPPFLAGS
LIBS=$SAVED_LIBS])
dnl === Check for pthread support dnl === Check for pthread support
AC_ARG_ENABLE([threading], AC_ARG_ENABLE([threading],
AS_HELP_STRING([--disable-threading], AS_HELP_STRING([--disable-threading],
@ -44,10 +110,108 @@ if test "$enable_threading" = "yes"; then
fi fi
AC_MSG_NOTICE([checking if threading is enabled... ${enable_threading-no}]) AC_MSG_NOTICE([checking if threading is enabled... ${enable_threading-no}])
dnl === check for OpenGL/GLUT support ===
CLEAR_LIBVARS([GL])
WITHLIB_OPTION([gl], [GL])
LIBCHECK_PROLOGUE([GL])
glut_cflags="none"
glut_ldflags="none"
case $host_os in
darwin*)
# Special case for OSX builds. Append these to give the user a chance to
# override with --with-gl*
glut_cflags="$glut_cflags|-framework GLUT -framework OpenGL"
glut_ldflags="$glut_ldflags|-framework GLUT -framework OpenGL"
;;
esac
GLUT_SAVED_CPPFLAGS="$CPPFLAGS"
SAVED_IFS="$IFS"
IFS="|"
for flag in $glut_cflags; do
# restore IFS immediately as the autoconf macros may need the default.
IFS="$SAVED_IFS"
unset ac_cv_header_GL_glut_h
unset ac_cv_header_OpenGL_glut_h
case $flag in
none) ;;
*) CPPFLAGS="$flag $CPPFLAGS";;
esac
AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h OpenGL/glut.h],
[glut_headers=yes;
test "$flag" = "none" || GL_INCLUDES="$CPPFLAGS";
break])
CPPFLAGS="$GLUT_SAVED_CPPFLAGS"
test "$glut_headers" = "yes" && break
done
IFS="$SAVED_IFS"
if test "$glut_headers" = "yes"; then
AC_LANG_PUSH([C])
GLUT_SAVED_LDFLAGS="$LDFLAGS"
SAVED_IFS="$IFS"
IFS="|"
for flag in $glut_ldflags; do
# restore IFS immediately as the autoconf macros may need the default.
IFS="$SAVED_IFS"
unset ac_cv_search_glBegin
case $flag in
none) ;;
*) LDFLAGS="$flag $LDFLAGS";;
esac
# find libGL
GL_SAVED_LIBS="$LIBS"
AC_SEARCH_LIBS([glBegin], [GL OpenGL])
LIBS="$GL_SAVED_LIBS"
# A direct link to libGL may not be necessary on e.g., linux.
GLUT_SAVED_LIBS="$LIBS"
for lib in "" "-lglut" "-lglut $ac_cv_search_glBegin"; do
LIBS="$lib"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([
#ifdef __cplusplus
# define EXTERN_C extern "C"
#else
# define EXTERN_C
#endif
EXTERN_C char glOrtho();
EXTERN_C char glutMainLoop();
],[
glOrtho();
glutMainLoop();
])
],
[glut_support=yes], []
)
if test "$glut_support" = "yes"; then
GL_LIBS="$LDFLAGS $lib"
break
fi
done
LIBS="$GLUT_SAVED_LIBS"
LDFLAGS="$GLUT_SAVED_LDFLAGS"
test "$glut_support" = "yes" && break
done
IFS="$SAVED_IFS"
AC_LANG_POP
fi
LIBCHECK_EPILOGUE([GL])
if test "$glut_support" = "yes" -a "$enable_libwebpdemux" = "yes"; then
build_vwebp=yes
fi
AM_CONDITIONAL([BUILD_VWEBP], [test "$build_vwebp" = "yes"])
dnl === check for PNG support === dnl === check for PNG support ===
PNG_INCLUDES="" CLEAR_LIBVARS([PNG])
PNG_LIBS=""
AC_PATH_PROGS(LIBPNG_CONFIG, AC_PATH_PROGS(LIBPNG_CONFIG,
[libpng-config libpng15-config libpng14-config libpng12-config]) [libpng-config libpng15-config libpng14-config libpng12-config])
if test -n "$LIBPNG_CONFIG"; then if test -n "$LIBPNG_CONFIG"; then
@ -61,11 +225,7 @@ fi
WITHLIB_OPTION([png], [PNG]) WITHLIB_OPTION([png], [PNG])
SAVED_CPPFLAGS=$CPPFLAGS LIBCHECK_PROLOGUE([PNG])
SAVED_LIBS=$LIBS
CPPFLAGS="$PNG_INCLUDES $CPPFLAGS"
LIBS="$PNG_LIBS $LIBS"
AC_CHECK_HEADER(png.h, AC_CHECK_HEADER(png.h,
AC_SEARCH_LIBS(png_get_libpng_ver, [png], AC_SEARCH_LIBS(png_get_libpng_ver, [png],
[test "$ac_cv_search_png_get_libpng_ver" = "none required" \ [test "$ac_cv_search_png_get_libpng_ver" = "none required" \
@ -85,23 +245,14 @@ AC_CHECK_HEADER(png.h,
PNG_INCLUDES="" PNG_INCLUDES=""
], ],
) )
AC_SUBST(PNG_LIBS) LIBCHECK_EPILOGUE([PNG])
AC_SUBST(PNG_INCLUDES)
CPPFLAGS=$SAVED_CPPFLAGS
LIBS=$SAVED_LIBS
dnl === check for JPEG support === dnl === check for JPEG support ===
JPEG_INCLUDES="" CLEAR_LIBVARS([JPEG])
JPEG_LIBS=""
WITHLIB_OPTION([jpeg], [JPEG]) WITHLIB_OPTION([jpeg], [JPEG])
SAVED_CPPFLAGS=$CPPFLAGS LIBCHECK_PROLOGUE([JPEG])
SAVED_LIBS=$LIBS
CPPFLAGS="$JPEG_INCLUDES $CPPFLAGS"
LIBS="$JPEG_LIBS $LIBS"
AC_CHECK_HEADER(jpeglib.h, AC_CHECK_HEADER(jpeglib.h,
AC_CHECK_LIB(jpeg, jpeg_set_defaults, AC_CHECK_LIB(jpeg, jpeg_set_defaults,
[JPEG_LIBS="$JPEG_LIBS -ljpeg" [JPEG_LIBS="$JPEG_LIBS -ljpeg"
@ -114,23 +265,14 @@ AC_CHECK_HEADER(jpeglib.h,
[$MATH_LIBS]), [$MATH_LIBS]),
AC_MSG_WARN(jpeg library not available - no jpeglib.h) AC_MSG_WARN(jpeg library not available - no jpeglib.h)
) )
AC_SUBST(JPEG_LIBS) LIBCHECK_EPILOGUE([JPEG])
AC_SUBST(JPEG_INCLUDES)
CPPFLAGS=$SAVED_CPPFLAGS
LIBS=$SAVED_LIBS
dnl === check for TIFF support === dnl === check for TIFF support ===
TIFF_INCLUDES="" CLEAR_LIBVARS([TIFF])
TIFF_LIBS=""
WITHLIB_OPTION([tiff], [TIFF]) WITHLIB_OPTION([tiff], [TIFF])
SAVED_CPPFLAGS=$CPPFLAGS LIBCHECK_PROLOGUE([TIFF])
SAVED_LIBS=$LIBS
CPPFLAGS="$TIFF_INCLUDES $CPPFLAGS"
LIBS="$TIFF_LIBS $LIBS"
AC_CHECK_HEADER(tiffio.h, AC_CHECK_HEADER(tiffio.h,
AC_CHECK_LIB(tiff, TIFFGetVersion, AC_CHECK_LIB(tiff, TIFFGetVersion,
[TIFF_LIBS="$TIFF_LIBS -ltiff" [TIFF_LIBS="$TIFF_LIBS -ltiff"
@ -143,23 +285,14 @@ AC_CHECK_HEADER(tiffio.h,
[$MATH_LIBS]), [$MATH_LIBS]),
AC_MSG_WARN(tiff library not available - no tiffio.h) AC_MSG_WARN(tiff library not available - no tiffio.h)
) )
AC_SUBST(TIFF_LIBS) LIBCHECK_EPILOGUE([TIFF])
AC_SUBST(TIFF_INCLUDES)
CPPFLAGS=$SAVED_CPPFLAGS
LIBS=$SAVED_LIBS
dnl === check for GIF support === dnl === check for GIF support ===
GIF_INCLUDES="" CLEAR_LIBVARS([GIF])
GIF_LIBS=""
WITHLIB_OPTION([gif], [GIF]) WITHLIB_OPTION([gif], [GIF])
SAVED_CPPFLAGS=$CPPFLAGS LIBCHECK_PROLOGUE([GIF])
SAVED_LIBS=$LIBS
CPPFLAGS="$GIF_INCLUDES $CPPFLAGS"
LIBS="$GIF_LIBS $LIBS"
AC_CHECK_HEADER(gif_lib.h, AC_CHECK_HEADER(gif_lib.h,
AC_CHECK_LIB([gif], [DGifOpenFileHandle], AC_CHECK_LIB([gif], [DGifOpenFileHandle],
[GIF_LIBS="$GIF_LIBS -lgif" [GIF_LIBS="$GIF_LIBS -lgif"
@ -169,11 +302,7 @@ AC_CHECK_HEADER(gif_lib.h,
[$MATH_LIBS]), [$MATH_LIBS]),
AC_MSG_WARN(gif library not available - no gif_lib.h) AC_MSG_WARN(gif library not available - no gif_lib.h)
) )
AC_SUBST(GIF_LIBS) LIBCHECK_EPILOGUE([GIF])
AC_SUBST(GIF_INCLUDES)
CPPFLAGS=$SAVED_CPPFLAGS
LIBS=$SAVED_LIBS
if test "$gif_support" = "yes" -a \ if test "$gif_support" = "yes" -a \
"$enable_libwebpmux" = "yes"; then "$enable_libwebpmux" = "yes"; then
@ -302,18 +431,19 @@ libwebpdemux: ${enable_libwebpdemux-no}
libwebpmux: ${enable_libwebpmux-no} libwebpmux: ${enable_libwebpmux-no}
Tools: Tools:
cwebp: yes cwebp : yes
Input format support Input format support
==================== ====================
JPEG : ${jpeg_support-no} JPEG : ${jpeg_support-no}
PNG : ${png_support-no} PNG : ${png_support-no}
TIFF : ${tiff_support-no} TIFF : ${tiff_support-no}
WIC : ${wic_support-no} WIC : ${wic_support-no}
dwebp: yes dwebp : yes
Output format support Output format support
===================== =====================
PNG : ${png_support-no} PNG : ${png_support-no}
WIC : ${wic_support-no} WIC : ${wic_support-no}
gif2webp: ${build_gif2webp-no} gif2webp : ${build_gif2webp-no}
webpmux: ${enable_libwebpmux-no} webpmux : ${enable_libwebpmux-no}
vwebp : ${build_vwebp-no}
]) ])

View File

@ -1,6 +1,9 @@
AM_CPPFLAGS = -I$(top_srcdir)/src AM_CPPFLAGS = -I$(top_srcdir)/src
bin_PROGRAMS = dwebp cwebp bin_PROGRAMS = dwebp cwebp
if BUILD_VWEBP
bin_PROGRAMS += vwebp
endif
if WANT_MUX if WANT_MUX
bin_PROGRAMS += webpmux bin_PROGRAMS += webpmux
endif endif
@ -18,12 +21,6 @@ dwebp_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE)
dwebp_CPPFLAGS += $(JPEG_INCLUDES) $(PNG_INCLUDES) dwebp_CPPFLAGS += $(JPEG_INCLUDES) $(PNG_INCLUDES)
dwebp_LDADD = libexampleutil.la $(PNG_LIBS) $(JPEG_LIBS) dwebp_LDADD = libexampleutil.la $(PNG_LIBS) $(JPEG_LIBS)
if BUILD_LIBWEBPDECODER
dwebp_LDADD += ../src/libwebpdecoder.la
else
dwebp_LDADD += ../src/libwebp.la
endif
cwebp_SOURCES = cwebp.c metadata.c metadata.h stopwatch.h cwebp_SOURCES = cwebp.c metadata.c metadata.h stopwatch.h
cwebp_SOURCES += jpegdec.c jpegdec.h cwebp_SOURCES += jpegdec.c jpegdec.h
cwebp_SOURCES += pngdec.c pngdec.h cwebp_SOURCES += pngdec.c pngdec.h
@ -41,3 +38,15 @@ gif2webp_LDADD += $(GIF_LIBS)
webpmux_SOURCES = webpmux.c webpmux_SOURCES = webpmux.c
webpmux_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE) webpmux_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE)
webpmux_LDADD = libexampleutil.la ../src/mux/libwebpmux.la ../src/libwebp.la webpmux_LDADD = libexampleutil.la ../src/mux/libwebpmux.la ../src/libwebp.la
vwebp_SOURCES = vwebp.c
vwebp_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE) $(GL_INCLUDES)
vwebp_LDADD = libexampleutil.la ../src/demux/libwebpdemux.la $(GL_LIBS)
if BUILD_LIBWEBPDECODER
dwebp_LDADD += ../src/libwebpdecoder.la
vwebp_LDADD += ../src/libwebpdecoder.la
else
dwebp_LDADD += ../src/libwebp.la
vwebp_LDADD += ../src/libwebp.la
endif

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// simple command line calling the WebPEncode function. // simple command line calling the WebPEncode function.
@ -109,15 +111,15 @@ typedef enum {
static InputFileFormat GetImageType(FILE* in_file) { static InputFileFormat GetImageType(FILE* in_file) {
InputFileFormat format = UNSUPPORTED; InputFileFormat format = UNSUPPORTED;
unsigned int magic; uint32_t magic;
unsigned char buf[4]; uint8_t buf[4];
if ((fread(&buf[0], 4, 1, in_file) != 1) || if ((fread(&buf[0], 4, 1, in_file) != 1) ||
(fseek(in_file, 0, SEEK_SET) != 0)) { (fseek(in_file, 0, SEEK_SET) != 0)) {
return format; return format;
} }
magic = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; magic = ((uint32_t)buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
if (magic == 0x89504E47U) { if (magic == 0x89504E47U) {
format = PNG_; format = PNG_;
} else if (magic >= 0xFFD8FF00U && magic <= 0xFFD8FFFFU) { } else if (magic >= 0xFFD8FF00U && magic <= 0xFFD8FFFFU) {

View File

@ -1,13 +1,13 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Command-line tool for decoding a WebP image // Command-line tool for decoding a WebP image.
//
// Compile with: gcc -o dwebp dwebp.c -lwebpdecode
// //
// Author: Skal (pascal.massimino@gmail.com) // Author: Skal (pascal.massimino@gmail.com)

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Utility functions used by the example programs. // Utility functions used by the example programs.

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Utility functions used by the example programs. // Utility functions used by the example programs.

View File

@ -1,21 +1,14 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// simple tool to convert animated GIFs to WebP // simple tool to convert animated GIFs to WebP
// //
// Getting the prerequisites:
// Debian-like linux:
// sudo apt-get install libgif-dev
// MacPorts
// sudo port install giflib
//
// Compiling:
// gcc -o gif2webp gif2webp.c -O3 -lwebpmux -lwebp -lgif -lpthread -lm
//
// Authors: Skal (pascal.massimino@gmail.com) // Authors: Skal (pascal.massimino@gmail.com)
// Urvang (urvang@google.com) // Urvang (urvang@google.com)
@ -197,8 +190,6 @@ int main(int argc, const char *argv[]) {
FILE* out = NULL; FILE* out = NULL;
GifFileType* gif = NULL; GifFileType* gif = NULL;
WebPPicture picture; WebPPicture picture;
WebPPicture view;
WebPMemoryWriter memory;
WebPMuxFrameInfo frame; WebPMuxFrameInfo frame;
WebPMuxAnimParams anim = { WHITE_COLOR, 0 }; WebPMuxAnimParams anim = { WHITE_COLOR, 0 };
@ -209,6 +200,8 @@ int main(int argc, const char *argv[]) {
WebPConfig config; WebPConfig config;
WebPMux* mux = NULL; WebPMux* mux = NULL;
WebPData webp_data = { NULL, 0 }; WebPData webp_data = { NULL, 0 };
int stored_icc = 0; // Whether we have already stored an ICC profile.
int stored_xmp = 0;
memset(&frame, 0, sizeof(frame)); memset(&frame, 0, sizeof(frame));
frame.id = WEBP_CHUNK_ANMF; frame.id = WEBP_CHUNK_ANMF;
@ -283,9 +276,7 @@ int main(int argc, const char *argv[]) {
picture.width = gif->SWidth; picture.width = gif->SWidth;
picture.height = gif->SHeight; picture.height = gif->SHeight;
picture.use_argb = 1; picture.use_argb = 1;
picture.writer = WebPMemoryWrite; if (!WebPPictureAlloc(&picture)) goto End;
picture.custom_ptr = &memory;
if (!WebPPictureAlloc(&picture)) goto End;
mux = WebPMuxNew(); mux = WebPMuxNew();
if (mux == NULL) { if (mux == NULL) {
@ -301,27 +292,33 @@ int main(int argc, const char *argv[]) {
switch (type) { switch (type) {
case IMAGE_DESC_RECORD_TYPE: { case IMAGE_DESC_RECORD_TYPE: {
WebPPicture sub_image;
WebPMemoryWriter memory;
if (frame.dispose_method == WEBP_MUX_DISPOSE_BACKGROUND) { if (frame.dispose_method == WEBP_MUX_DISPOSE_BACKGROUND) {
ClearPicture(&picture, anim.bgcolor); ClearPicture(&picture, anim.bgcolor);
} }
if (!DGifGetImageDesc(gif)) goto End; if (!DGifGetImageDesc(gif)) goto End;
if (!ReadSubImage(gif, &picture, &view)) goto End; if (!ReadSubImage(gif, &picture, &sub_image)) goto End;
WebPMemoryWriterInit(&memory);
if (!config.lossless) { if (!config.lossless) {
// We need to call BGRA variant because of the way we do Remap(). // We need to call BGRA variant because of the way we do Remap(). Note
// TODO(later): This works for little-endian only due to uint32_t to // that 'sub_image' will no longer be a view and own some memory.
// uint8_t conversion. Make it work for big-endian too. WebPPictureImportBGRA(
WebPPictureImportBGRA(&view, (uint8_t*)view.argb, &sub_image, (uint8_t*)sub_image.argb,
view.argb_stride * sizeof(*view.argb)); sub_image.argb_stride * sizeof(*sub_image.argb));
view.use_argb = 0; sub_image.use_argb = 0;
} else { } else {
view.use_argb = 1; sub_image.use_argb = 1;
} }
if (!WebPEncode(&config, &view)) {
sub_image.writer = WebPMemoryWrite;
sub_image.custom_ptr = &memory;
WebPMemoryWriterInit(&memory);
if (!WebPEncode(&config, &sub_image)) {
fprintf(stderr, "Error! Cannot encode picture as WebP\n"); fprintf(stderr, "Error! Cannot encode picture as WebP\n");
fprintf(stderr, "Error code: %d\n", view.error_code); fprintf(stderr, "Error code: %d\n", sub_image.error_code);
goto End; goto End;
} }
@ -340,12 +337,14 @@ int main(int argc, const char *argv[]) {
} }
if (verbose) { if (verbose) {
printf("Added frame %dx%d (offset:%d,%d duration:%d) ", printf("Added frame %dx%d (offset:%d,%d duration:%d) ",
view.width, view.height, frame.x_offset, frame.y_offset, sub_image.width, sub_image.height,
frame.x_offset, frame.y_offset,
frame.duration); frame.duration);
printf("dispose:%d transparent index:%d\n", printf("dispose:%d transparent index:%d\n",
frame.dispose_method, transparent_index); frame.dispose_method, transparent_index);
} }
WebPDataClear(&frame.bitstream); WebPDataClear(&frame.bitstream);
WebPPictureFree(&sub_image);
break; break;
} }
case EXTENSION_RECORD_TYPE: { case EXTENSION_RECORD_TYPE: {
@ -398,24 +397,70 @@ int main(int argc, const char *argv[]) {
if (data[0] != 3 && data[1] != 1) break; // wrong size/marker if (data[0] != 3 && data[1] != 1) break; // wrong size/marker
anim.loop_count = data[2] | (data[3] << 8); anim.loop_count = data[2] | (data[3] << 8);
if (verbose) printf("Loop count: %d\n", anim.loop_count); if (verbose) printf("Loop count: %d\n", anim.loop_count);
} else if (!memcmp(data + 1, "XMP dataXMP", 11)) { } else { // An extension containing metadata.
// Read XMP metadata. // We only store the first encountered chunk of each type.
WebPData xmp; const int is_xmp =
if (DGifGetExtensionNext(gif, &data) == GIF_ERROR) goto End; !stored_xmp && !memcmp(data + 1, "XMP DataXMP", 11);
if (data == NULL) goto End; const int is_icc =
xmp.bytes = (uint8_t*)data; !stored_icc && !memcmp(data + 1, "ICCRGBG1012", 11);
xmp.size = data[0] + 1; if (is_xmp || is_icc) {
WebPMuxSetChunk(mux, "XMP ", &xmp, 1); const char* const fourccs[2] = { "XMP " , "ICCP" };
if (verbose) printf("XMP size: %d\n", (int)xmp.size); const char* const features[2] = { "XMP" , "ICC" };
} else if (!memcmp(data + 1, "ICCRGBG1012", 11)) { WebPData metadata = { NULL, 0 };
// Read ICC profile. // Construct metadata from sub-blocks.
WebPData icc; // Usual case (including ICC profile): In each sub-block, the
if (DGifGetExtensionNext(gif, &data) == GIF_ERROR) goto End; // first byte specifies its size in bytes (0 to 255) and the
if (data == NULL) goto End; // rest of the bytes contain the data.
icc.bytes = (uint8_t*)data; // Special case for XMP data: In each sub-block, the first byte
icc.size = data[0] + 1; // is also part of the XMP payload. XMP in GIF also has a 257
WebPMuxSetChunk(mux, "ICCP", &icc, 1); // byte padding data. See the XMP specification for details.
if (verbose) printf("ICC size: %d\n", (int)icc.size); while (1) {
WebPData prev_metadata = metadata;
WebPData subblock;
if (DGifGetExtensionNext(gif, &data) == GIF_ERROR) {
WebPDataClear(&metadata);
goto End;
}
if (data == NULL) break; // Finished.
subblock.size = is_xmp ? data[0] + 1 : data[0];
assert(subblock.size > 0);
subblock.bytes = is_xmp ? data : data + 1;
metadata.bytes =
(uint8_t*)realloc((void*)metadata.bytes,
prev_metadata.size + subblock.size);
if (metadata.bytes == NULL) {
WebPDataClear(&prev_metadata);
goto End;
}
metadata.size += subblock.size;
memcpy((void*)(metadata.bytes + prev_metadata.size),
subblock.bytes, subblock.size);
}
if (is_xmp) {
// XMP padding data is 0x01, 0xff, 0xfe ... 0x01, 0x00.
const size_t xmp_pading_size = 257;
if (metadata.size > xmp_pading_size) {
metadata.size -= xmp_pading_size;
}
}
// Add metadata chunk.
err = WebPMuxSetChunk(mux, fourccs[is_icc], &metadata, 1);
if (verbose) {
printf("%s size: %d\n", features[is_icc], (int)metadata.size);
}
WebPDataClear(&metadata);
if (err != WEBP_MUX_OK) {
fprintf(stderr, "ERROR (%s): Could not set %s chunk.\n",
ErrorString(err), features[is_icc]);
goto End;
}
if (is_icc) {
stored_icc = 1;
} else if (is_xmp) {
stored_xmp = 1;
}
}
} }
break; break;
} }
@ -423,9 +468,9 @@ int main(int argc, const char *argv[]) {
break; // skip break; // skip
} }
} }
do { while (data != NULL) {
if (DGifGetExtensionNext(gif, &data) == GIF_ERROR) goto End; if (DGifGetExtensionNext(gif, &data) == GIF_ERROR) goto End;
} while (data != NULL); }
break; break;
} }
case TERMINATE_RECORD_TYPE: { case TERMINATE_RECORD_TYPE: {

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// JPEG decode. // JPEG decode.

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// JPEG decode. // JPEG decode.

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Metadata types and functions. // Metadata types and functions.

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Metadata types and functions. // Metadata types and functions.

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// PNG decode. // PNG decode.
@ -108,6 +110,8 @@ static const struct {
// See also: ExifTool on CPAN. // See also: ExifTool on CPAN.
{ "Raw profile type exif", ProcessRawProfile, METADATA_OFFSET(exif) }, { "Raw profile type exif", ProcessRawProfile, METADATA_OFFSET(exif) },
{ "Raw profile type xmp", ProcessRawProfile, METADATA_OFFSET(xmp) }, { "Raw profile type xmp", ProcessRawProfile, METADATA_OFFSET(xmp) },
// Exiftool puts exif data in APP1 chunk, too.
{ "Raw profile type APP1", ProcessRawProfile, METADATA_OFFSET(exif) },
// XMP Specification Part 3, Section 3 #PNG // XMP Specification Part 3, Section 3 #PNG
{ "XML:com.adobe.xmp", MetadataCopy, METADATA_OFFSET(xmp) }, { "XML:com.adobe.xmp", MetadataCopy, METADATA_OFFSET(xmp) },
{ NULL, NULL, 0 }, { NULL, NULL, 0 },
@ -207,7 +211,6 @@ int ReadPNG(FILE* in_file, WebPPicture* const pic, int keep_alpha,
Error: Error:
MetadataFree(metadata); MetadataFree(metadata);
png_destroy_read_struct(&png, &info, &end_info); png_destroy_read_struct(&png, &info, &end_info);
free(rgb);
goto End; goto End;
} }
@ -269,13 +272,13 @@ int ReadPNG(FILE* in_file, WebPPicture* const pic, int keep_alpha,
pic->height = height; pic->height = height;
ok = has_alpha ? WebPPictureImportRGBA(pic, rgb, stride) ok = has_alpha ? WebPPictureImportRGBA(pic, rgb, stride)
: WebPPictureImportRGB(pic, rgb, stride); : WebPPictureImportRGB(pic, rgb, stride);
free(rgb);
if (!ok) { if (!ok) {
goto Error; goto Error;
} }
End: End:
free(rgb);
return ok; return ok;
} }
#else // !WEBP_HAVE_PNG #else // !WEBP_HAVE_PNG

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// PNG decode. // PNG decode.

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Helper functions to measure elapsed time. // Helper functions to measure elapsed time.

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// TIFF decode. // TIFF decode.

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// TIFF decode. // TIFF decode.

View File

@ -1,25 +1,24 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Simple WebP file viewer. // Simple OpenGL-based WebP file viewer.
//
// Compiling on linux:
// sudo apt-get install freeglut3-dev mesa-common-dev
// gcc -o vwebp vwebp.c -O3 -lwebp -lwebpmux -lglut -lGL -lpthread -lm
// Compiling on Mac + XCode:
// gcc -o vwebp vwebp.c -lwebp -lwebpmux -framework GLUT -framework OpenGL
// //
// Author: Skal (pascal.massimino@gmail.com) // Author: Skal (pascal.massimino@gmail.com)
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef __APPLE__ #if defined(HAVE_GLUT_GLUT_H)
#include <GLUT/glut.h> #include <GLUT/glut.h>
#else #else
#include <GL/glut.h> #include <GL/glut.h>
@ -437,6 +436,11 @@ int main(int argc, char *argv[]) {
goto Error; goto Error;
} }
if (!WebPGetInfo(kParams.data.bytes, kParams.data.size, NULL, NULL)) {
fprintf(stderr, "Input file doesn't appear to be WebP format.\n");
goto Error;
}
kParams.dmux = WebPDemux(&kParams.data); kParams.dmux = WebPDemux(&kParams.data);
if (kParams.dmux == NULL) { if (kParams.dmux == NULL) {
fprintf(stderr, "Could not create demuxing object!\n"); fprintf(stderr, "Could not create demuxing object!\n");

View File

@ -1,16 +1,15 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Simple command-line to create a WebP container file and to extract or strip // Simple command-line to create a WebP container file and to extract or strip
// relevant data from the container file. // relevant data from the container file.
// //
// Compile with: gcc -o webpmux webpmux.c -lwebpmux -lwebp
//
//
// Authors: Vikas (vikaas.arora@gmail.com), // Authors: Vikas (vikaas.arora@gmail.com),
// Urvang (urvang@google.com) // Urvang (urvang@google.com)
@ -229,11 +228,13 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) {
for (i = 1; i <= nFrames; i++) { for (i = 1; i <= nFrames; i++) {
WebPMuxFrameInfo frame; WebPMuxFrameInfo frame;
err = WebPMuxGetFrame(mux, i, &frame); err = WebPMuxGetFrame(mux, i, &frame);
RETURN_IF_ERROR3("Failed to retrieve %s#%d\n", type_str, i); if (err == WEBP_MUX_OK) {
printf("%3d: %8d %8d ", i, frame.x_offset, frame.y_offset); printf("%3d: %8d %8d ", i, frame.x_offset, frame.y_offset);
if (is_anim) printf("%8d %7d ", frame.duration, frame.dispose_method); if (is_anim) printf("%8d %7d ", frame.duration, frame.dispose_method);
printf("%10d\n", (int)frame.bitstream.size); printf("%10d\n", (int)frame.bitstream.size);
}
WebPDataClear(&frame.bitstream); WebPDataClear(&frame.bitstream);
RETURN_IF_ERROR3("Failed to retrieve %s#%d\n", type_str, i);
} }
} }
} }
@ -262,8 +263,11 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) {
if ((flag & ALPHA_FLAG) && !(flag & (ANIMATION_FLAG | FRAGMENTS_FLAG))) { if ((flag & ALPHA_FLAG) && !(flag & (ANIMATION_FLAG | FRAGMENTS_FLAG))) {
WebPMuxFrameInfo image; WebPMuxFrameInfo image;
err = WebPMuxGetFrame(mux, 1, &image); err = WebPMuxGetFrame(mux, 1, &image);
if (err == WEBP_MUX_OK) {
printf("Size of the image (with alpha): %d\n", (int)image.bitstream.size);
}
WebPDataClear(&image.bitstream);
RETURN_IF_ERROR("Failed to retrieve the image\n"); RETURN_IF_ERROR("Failed to retrieve the image\n");
printf("Size of the image (with alpha): %d\n", (int)image.bitstream.size);
} }
return WEBP_MUX_OK; return WEBP_MUX_OK;

View File

@ -1,8 +1,10 @@
// Copyright 2013 Google Inc. All Rights Reserved. // Copyright 2013 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Windows Imaging Component (WIC) decode. // Windows Imaging Component (WIC) decode.
@ -126,7 +128,7 @@ static HRESULT ExtractICCP(IWICImagingFactory* const factory,
&size)); &size));
if (SUCCEEDED(hr) && size != iccp->size) { if (SUCCEEDED(hr) && size != iccp->size) {
fprintf(stderr, "Warning! ICC profile size (%u) != expected (%u)\n", fprintf(stderr, "Warning! ICC profile size (%u) != expected (%u)\n",
size, iccp->size); size, (uint32_t)iccp->size);
iccp->size = size; iccp->size = size;
} }
break; break;

View File

@ -1,8 +1,10 @@
// Copyright 2013 Google Inc. All Rights Reserved. // Copyright 2013 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Windows Imaging Component (WIC) decode. // Windows Imaging Component (WIC) decode.

View File

@ -24,6 +24,7 @@ ifeq ($(strip $(shell uname)), Darwin)
# cf., src/enc/yuv.[hc] # cf., src/enc/yuv.[hc]
# Failure observed with: gcc 4.2.1 and 4.0.1. # Failure observed with: gcc 4.2.1 and 4.0.1.
EXTRA_FLAGS += -fno-common EXTRA_FLAGS += -fno-common
EXTRA_FLAGS += -DHAVE_GLUT_GLUT_H
EXTRA_FLAGS += -I/opt/local/include EXTRA_FLAGS += -I/opt/local/include
EXTRA_LIBS += -L/opt/local/lib EXTRA_LIBS += -L/opt/local/lib
GL_LIBS = -framework GLUT -framework OpenGL GL_LIBS = -framework GLUT -framework OpenGL

View File

@ -36,7 +36,7 @@ libwebp_la_LIBADD += utils/libwebputils.la
# other than the ones listed on the command line, i.e., after linking, it will # other than the ones listed on the command line, i.e., after linking, it will
# not have unresolved symbols. Some platforms (Windows among them) require all # not have unresolved symbols. Some platforms (Windows among them) require all
# symbols in shared libraries to be resolved at library creation. # symbols in shared libraries to be resolved at library creation.
libwebp_la_LDFLAGS = -no-undefined -version-info 4:2:0 libwebp_la_LDFLAGS = -no-undefined -version-info 4:3:0
libwebpincludedir = $(includedir)/webp libwebpincludedir = $(includedir)/webp
pkgconfig_DATA = libwebp.pc pkgconfig_DATA = libwebp.pc
@ -48,7 +48,7 @@ if BUILD_LIBWEBPDECODER
libwebpdecoder_la_LIBADD += dsp/libwebpdspdecode.la libwebpdecoder_la_LIBADD += dsp/libwebpdspdecode.la
libwebpdecoder_la_LIBADD += utils/libwebputilsdecode.la libwebpdecoder_la_LIBADD += utils/libwebputilsdecode.la
libwebpdecoder_la_LDFLAGS = -no-undefined -version-info 0:0:0 libwebpdecoder_la_LDFLAGS = -no-undefined -version-info 0:1:0
pkgconfig_DATA += libwebpdecoder.pc pkgconfig_DATA += libwebpdecoder.pc
endif endif

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Alpha-plane decompression. // Alpha-plane decompression.
@ -20,20 +22,10 @@
extern "C" { extern "C" {
#endif #endif
// TODO(skal): move to dsp/ ?
static void CopyPlane(const uint8_t* src, int src_stride,
uint8_t* dst, int dst_stride, int width, int height) {
while (height-- > 0) {
memcpy(dst, src, width);
src += src_stride;
dst += dst_stride;
}
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Decodes the compressed data 'data' of size 'data_size' into the 'output'. // Decodes the compressed data 'data' of size 'data_size' into the 'output'.
// The 'output' buffer should be pre-allocated and must be of the same // The 'output' buffer should be pre-allocated and must be of the same
// dimension 'height'x'stride', as that of the image. // dimension 'height'x'width', as that of the image.
// //
// Returns 1 on successfully decoding the compressed alpha and // Returns 1 on successfully decoding the compressed alpha and
// 0 if either: // 0 if either:
@ -41,16 +33,16 @@ static void CopyPlane(const uint8_t* src, int src_stride,
// error returned by appropriate compression method. // error returned by appropriate compression method.
static int DecodeAlpha(const uint8_t* data, size_t data_size, static int DecodeAlpha(const uint8_t* data, size_t data_size,
int width, int height, int stride, uint8_t* output) { int width, int height, uint8_t* output) {
uint8_t* decoded_data = NULL;
const size_t decoded_size = height * width;
WEBP_FILTER_TYPE filter; WEBP_FILTER_TYPE filter;
int pre_processing; int pre_processing;
int rsrv; int rsrv;
int ok = 0; int ok = 0;
int method; int method;
const uint8_t* const alpha_data = data + ALPHA_HEADER_LEN;
const size_t alpha_data_size = data_size - ALPHA_HEADER_LEN;
assert(width > 0 && height > 0 && stride >= width); assert(width > 0 && height > 0);
assert(data != NULL && output != NULL); assert(data != NULL && output != NULL);
if (data_size <= ALPHA_HEADER_LEN) { if (data_size <= ALPHA_HEADER_LEN) {
@ -70,15 +62,12 @@ static int DecodeAlpha(const uint8_t* data, size_t data_size,
} }
if (method == ALPHA_NO_COMPRESSION) { if (method == ALPHA_NO_COMPRESSION) {
ok = (data_size >= decoded_size); const size_t alpha_decoded_size = height * width;
decoded_data = (uint8_t*)data + ALPHA_HEADER_LEN; ok = (alpha_data_size >= alpha_decoded_size);
if (ok) memcpy(output, alpha_data, alpha_decoded_size);
} else { } else {
decoded_data = (uint8_t*)malloc(decoded_size); ok = VP8LDecodeAlphaImageStream(width, height, alpha_data, alpha_data_size,
if (decoded_data == NULL) return 0; output);
ok = VP8LDecodeAlphaImageStream(width, height,
data + ALPHA_HEADER_LEN,
data_size - ALPHA_HEADER_LEN,
decoded_data);
} }
if (ok) { if (ok) {
@ -86,18 +75,13 @@ static int DecodeAlpha(const uint8_t* data, size_t data_size,
if (unfilter_func != NULL) { if (unfilter_func != NULL) {
// TODO(vikas): Implement on-the-fly decoding & filter mechanism to decode // TODO(vikas): Implement on-the-fly decoding & filter mechanism to decode
// and apply filter per image-row. // and apply filter per image-row.
unfilter_func(width, height, width, decoded_data); unfilter_func(width, height, width, output);
} }
// Construct raw_data (height x stride) from alpha data (height x width).
CopyPlane(decoded_data, width, output, stride, width, height);
if (pre_processing == ALPHA_PREPROCESSED_LEVELS) { if (pre_processing == ALPHA_PREPROCESSED_LEVELS) {
ok = DequantizeLevels(decoded_data, width, height); ok = DequantizeLevels(output, width, height);
} }
} }
if (method != ALPHA_NO_COMPRESSION) {
free(decoded_data);
}
return ok; return ok;
} }
@ -105,23 +89,25 @@ static int DecodeAlpha(const uint8_t* data, size_t data_size,
const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec, const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec,
int row, int num_rows) { int row, int num_rows) {
const int stride = dec->pic_hdr_.width_; const int width = dec->pic_hdr_.width_;
const int height = dec->pic_hdr_.height_;
if (row < 0 || num_rows < 0 || row + num_rows > dec->pic_hdr_.height_) { if (row < 0 || num_rows < 0 || row + num_rows > height) {
return NULL; // sanity check. return NULL; // sanity check.
} }
if (row == 0) { if (row == 0) {
// Decode everything during the first call. // Decode everything during the first call.
assert(!dec->is_alpha_decoded_);
if (!DecodeAlpha(dec->alpha_data_, (size_t)dec->alpha_data_size_, if (!DecodeAlpha(dec->alpha_data_, (size_t)dec->alpha_data_size_,
dec->pic_hdr_.width_, dec->pic_hdr_.height_, stride, width, height, dec->alpha_plane_)) {
dec->alpha_plane_)) {
return NULL; // Error. return NULL; // Error.
} }
dec->is_alpha_decoded_ = 1;
} }
// Return a pointer to the current decoded row. // Return a pointer to the current decoded row.
return dec->alpha_plane_ + row * stride; return dec->alpha_plane_ + row * width;
} }
#if defined(__cplusplus) || defined(c_plusplus) #if defined(__cplusplus) || defined(c_plusplus)

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Everything about WebPDecBuffer // Everything about WebPDecBuffer

View File

@ -1,8 +1,10 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Low-level API for VP8 decoder // Low-level API for VP8 decoder

View File

@ -1,8 +1,10 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Frame-reconstruction function. Memory allocation. // Frame-reconstruction function. Memory allocation.

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Incremental decoding // Incremental decoding
@ -97,6 +99,23 @@ static WEBP_INLINE size_t MemDataSize(const MemBuffer* mem) {
return (mem->end_ - mem->start_); return (mem->end_ - mem->start_);
} }
// Check if we need to preserve the compressed alpha data, as it may not have
// been decoded yet.
static int NeedCompressedAlpha(const WebPIDecoder* const idec) {
if (idec->state_ == STATE_PRE_VP8) {
// We haven't parsed the headers yet, so we don't know whether the image is
// lossy or lossless. This also means that we haven't parsed the ALPH chunk.
return 0;
}
if (idec->is_lossless_) {
return 0; // ALPH chunk is not present for lossless images.
} else {
const VP8Decoder* const dec = (VP8Decoder*)idec->dec_;
assert(dec != NULL); // Must be true as idec->state_ != STATE_PRE_VP8.
return (dec->alpha_data_ != NULL) && !dec->is_alpha_decoded_;
}
}
static void DoRemap(WebPIDecoder* const idec, ptrdiff_t offset) { static void DoRemap(WebPIDecoder* const idec, ptrdiff_t offset) {
MemBuffer* const mem = &idec->mem_; MemBuffer* const mem = &idec->mem_;
const uint8_t* const new_base = mem->buf_ + mem->start_; const uint8_t* const new_base = mem->buf_ + mem->start_;
@ -122,6 +141,7 @@ static void DoRemap(WebPIDecoder* const idec, ptrdiff_t offset) {
} }
assert(last_part >= 0); assert(last_part >= 0);
dec->parts_[last_part].buf_end_ = mem->buf_ + mem->end_; dec->parts_[last_part].buf_end_ = mem->buf_ + mem->end_;
if (NeedCompressedAlpha(idec)) dec->alpha_data_ += offset;
} else { // Resize lossless bitreader } else { // Resize lossless bitreader
VP8LDecoder* const dec = (VP8LDecoder*)idec->dec_; VP8LDecoder* const dec = (VP8LDecoder*)idec->dec_;
VP8LBitReaderSetBuffer(&dec->br_, new_base, MemDataSize(mem)); VP8LBitReaderSetBuffer(&dec->br_, new_base, MemDataSize(mem));
@ -133,8 +153,12 @@ static void DoRemap(WebPIDecoder* const idec, ptrdiff_t offset) {
// size if required and also updates VP8BitReader's if new memory is allocated. // size if required and also updates VP8BitReader's if new memory is allocated.
static int AppendToMemBuffer(WebPIDecoder* const idec, static int AppendToMemBuffer(WebPIDecoder* const idec,
const uint8_t* const data, size_t data_size) { const uint8_t* const data, size_t data_size) {
VP8Decoder* const dec = (VP8Decoder*)idec->dec_;
MemBuffer* const mem = &idec->mem_; MemBuffer* const mem = &idec->mem_;
const uint8_t* const old_base = mem->buf_ + mem->start_; const int need_compressed_alpha = NeedCompressedAlpha(idec);
const uint8_t* const old_start = mem->buf_ + mem->start_;
const uint8_t* const old_base =
need_compressed_alpha ? dec->alpha_data_ : old_start;
assert(mem->mode_ == MEM_MODE_APPEND); assert(mem->mode_ == MEM_MODE_APPEND);
if (data_size > MAX_CHUNK_PAYLOAD) { if (data_size > MAX_CHUNK_PAYLOAD) {
// security safeguard: trying to allocate more than what the format // security safeguard: trying to allocate more than what the format
@ -143,7 +167,8 @@ static int AppendToMemBuffer(WebPIDecoder* const idec,
} }
if (mem->end_ + data_size > mem->buf_size_) { // Need some free memory if (mem->end_ + data_size > mem->buf_size_) { // Need some free memory
const size_t current_size = MemDataSize(mem); const size_t new_mem_start = old_start - old_base;
const size_t current_size = MemDataSize(mem) + new_mem_start;
const uint64_t new_size = (uint64_t)current_size + data_size; const uint64_t new_size = (uint64_t)current_size + data_size;
const uint64_t extra_size = (new_size + CHUNK_SIZE - 1) & ~(CHUNK_SIZE - 1); const uint64_t extra_size = (new_size + CHUNK_SIZE - 1) & ~(CHUNK_SIZE - 1);
uint8_t* const new_buf = uint8_t* const new_buf =
@ -153,7 +178,7 @@ static int AppendToMemBuffer(WebPIDecoder* const idec,
free(mem->buf_); free(mem->buf_);
mem->buf_ = new_buf; mem->buf_ = new_buf;
mem->buf_size_ = (size_t)extra_size; mem->buf_size_ = (size_t)extra_size;
mem->start_ = 0; mem->start_ = new_mem_start;
mem->end_ = current_size; mem->end_ = current_size;
} }
@ -161,14 +186,15 @@ static int AppendToMemBuffer(WebPIDecoder* const idec,
mem->end_ += data_size; mem->end_ += data_size;
assert(mem->end_ <= mem->buf_size_); assert(mem->end_ <= mem->buf_size_);
DoRemap(idec, mem->buf_ + mem->start_ - old_base); DoRemap(idec, mem->buf_ + mem->start_ - old_start);
return 1; return 1;
} }
static int RemapMemBuffer(WebPIDecoder* const idec, static int RemapMemBuffer(WebPIDecoder* const idec,
const uint8_t* const data, size_t data_size) { const uint8_t* const data, size_t data_size) {
MemBuffer* const mem = &idec->mem_; MemBuffer* const mem = &idec->mem_;
const uint8_t* const old_base = mem->buf_ + mem->start_; const uint8_t* const old_buf = mem->buf_;
const uint8_t* const old_start = old_buf + mem->start_;
assert(mem->mode_ == MEM_MODE_MAP); assert(mem->mode_ == MEM_MODE_MAP);
if (data_size < mem->buf_size_) return 0; // can't remap to a shorter buffer! if (data_size < mem->buf_size_) return 0; // can't remap to a shorter buffer!
@ -176,7 +202,7 @@ static int RemapMemBuffer(WebPIDecoder* const idec,
mem->buf_ = (uint8_t*)data; mem->buf_ = (uint8_t*)data;
mem->end_ = mem->buf_size_ = data_size; mem->end_ = mem->buf_size_ = data_size;
DoRemap(idec, mem->buf_ + mem->start_ - old_base); DoRemap(idec, mem->buf_ + mem->start_ - old_start);
return 1; return 1;
} }

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// functions for sample output. // functions for sample output.

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Enhancement layer (for YUV444/422) // Enhancement layer (for YUV444/422)

View File

@ -1,8 +1,10 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Quantizer initialization // Quantizer initialization

View File

@ -1,8 +1,10 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Coding trees and probas // Coding trees and probas

View File

@ -1,8 +1,10 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// main entry for the decoder // main entry for the decoder

View File

@ -1,8 +1,10 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// VP8 decoder: internal header. // VP8 decoder: internal header.
@ -28,7 +30,7 @@ extern "C" {
// version numbers // version numbers
#define DEC_MAJ_VERSION 0 #define DEC_MAJ_VERSION 0
#define DEC_MIN_VERSION 3 #define DEC_MIN_VERSION 3
#define DEC_REV_VERSION 0 #define DEC_REV_VERSION 1
#define ONLY_KEYFRAME_CODE // to remove any code related to P-Frames #define ONLY_KEYFRAME_CODE // to remove any code related to P-Frames
@ -276,6 +278,7 @@ struct VP8Decoder {
// extensions // extensions
const uint8_t* alpha_data_; // compressed alpha data (if present) const uint8_t* alpha_data_; // compressed alpha data (if present)
size_t alpha_data_size_; size_t alpha_data_size_;
int is_alpha_decoded_; // true if alpha_data_ is decoded in alpha_plane_
uint8_t* alpha_plane_; // output. Persistent, contains the whole data. uint8_t* alpha_plane_; // output. Persistent, contains the whole data.
int layer_colorspace_; int layer_colorspace_;

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// main entry for the decoder // main entry for the decoder
@ -625,10 +627,24 @@ static void ApplyInverseTransforms(VP8LDecoder* const dec, int num_rows,
} }
} }
// Special method for paletted alpha data.
static void ApplyInverseTransformsAlpha(VP8LDecoder* const dec, int num_rows,
const uint8_t* const rows) {
const int start_row = dec->last_row_;
const int end_row = start_row + num_rows;
const uint8_t* rows_in = rows;
uint8_t* rows_out = (uint8_t*)dec->io_->opaque + dec->io_->width * start_row;
VP8LTransform* const transform = &dec->transforms_[0];
assert(dec->next_transform_ == 1);
assert(transform->type_ == COLOR_INDEXING_TRANSFORM);
VP8LColorIndexInverseTransformAlpha(transform, start_row, end_row, rows_in,
rows_out);
}
// Processes (transforms, scales & color-converts) the rows decoded after the // Processes (transforms, scales & color-converts) the rows decoded after the
// last call. // last call.
static void ProcessRows(VP8LDecoder* const dec, int row) { static void ProcessRows(VP8LDecoder* const dec, int row) {
const uint32_t* const rows = dec->argb_ + dec->width_ * dec->last_row_; const uint32_t* const rows = dec->pixels_ + dec->width_ * dec->last_row_;
const int num_rows = row - dec->last_row_; const int num_rows = row - dec->last_row_;
if (num_rows <= 0) return; // Nothing to be done. if (num_rows <= 0) return; // Nothing to be done.
@ -667,121 +683,135 @@ static void ProcessRows(VP8LDecoder* const dec, int row) {
assert(dec->last_row_ <= dec->height_); assert(dec->last_row_ <= dec->height_);
} }
static int DecodeImageData(VP8LDecoder* const dec, #define DECODE_DATA_FUNC(FUNC_NAME, TYPE, STORE_PIXEL) \
uint32_t* const data, int width, int height, static int FUNC_NAME(VP8LDecoder* const dec, TYPE* const data, int width, \
ProcessRowsFunc process_func) { int height, ProcessRowsFunc process_func) { \
int ok = 1; int ok = 1; \
int col = 0, row = 0; int col = 0, row = 0; \
VP8LBitReader* const br = &dec->br_; VP8LBitReader* const br = &dec->br_; \
VP8LMetadata* const hdr = &dec->hdr_; VP8LMetadata* const hdr = &dec->hdr_; \
HTreeGroup* htree_group = hdr->htree_groups_; HTreeGroup* htree_group = hdr->htree_groups_; \
uint32_t* src = data; TYPE* src = data; \
uint32_t* last_cached = data; TYPE* last_cached = data; \
uint32_t* const src_end = data + width * height; TYPE* const src_end = data + width * height; \
const int len_code_limit = NUM_LITERAL_CODES + NUM_LENGTH_CODES; const int len_code_limit = NUM_LITERAL_CODES + NUM_LENGTH_CODES; \
const int color_cache_limit = len_code_limit + hdr->color_cache_size_; const int color_cache_limit = len_code_limit + hdr->color_cache_size_; \
VP8LColorCache* const color_cache = VP8LColorCache* const color_cache = \
(hdr->color_cache_size_ > 0) ? &hdr->color_cache_ : NULL; (hdr->color_cache_size_ > 0) ? &hdr->color_cache_ : NULL; \
const int mask = hdr->huffman_mask_; const int mask = hdr->huffman_mask_; \
assert(htree_group != NULL); \
assert(htree_group != NULL); while (!br->eos_ && src < src_end) { \
int code; \
while (!br->eos_ && src < src_end) { /* Only update when changing tile. Note we could use this test: */ \
int code; /* if "((((prev_col ^ col) | prev_row ^ row)) > mask)" -> tile changed */ \
// Only update when changing tile. Note we could use the following test: /* but that's actually slower and needs storing the previous col/row. */ \
// if "((((prev_col ^ col) | prev_row ^ row)) > mask)" -> tile changed if ((col & mask) == 0) { \
// but that's actually slower and requires storing the previous col/row htree_group = GetHtreeGroupForPos(hdr, col, row); \
if ((col & mask) == 0) { } \
htree_group = GetHtreeGroupForPos(hdr, col, row); VP8LFillBitWindow(br); \
} code = ReadSymbol(&htree_group->htrees_[GREEN], br); \
VP8LFillBitWindow(br); if (code < NUM_LITERAL_CODES) { /* Literal*/ \
code = ReadSymbol(&htree_group->htrees_[GREEN], br); int red, green, blue, alpha; \
if (code < NUM_LITERAL_CODES) { // Literal. red = ReadSymbol(&htree_group->htrees_[RED], br); \
int red, green, blue, alpha; green = code; \
red = ReadSymbol(&htree_group->htrees_[RED], br); VP8LFillBitWindow(br); \
green = code; blue = ReadSymbol(&htree_group->htrees_[BLUE], br); \
VP8LFillBitWindow(br); alpha = ReadSymbol(&htree_group->htrees_[ALPHA], br); \
blue = ReadSymbol(&htree_group->htrees_[BLUE], br); *src = STORE_PIXEL(alpha, red, green, blue); \
alpha = ReadSymbol(&htree_group->htrees_[ALPHA], br); AdvanceByOne: \
*src = (alpha << 24) + (red << 16) + (green << 8) + blue; ++src; \
AdvanceByOne: ++col; \
++src; if (col >= width) { \
++col; col = 0; \
if (col >= width) { ++row; \
col = 0; if ((process_func != NULL) && (row % NUM_ARGB_CACHE_ROWS == 0)) { \
++row; process_func(dec, row); \
if ((process_func != NULL) && (row % NUM_ARGB_CACHE_ROWS == 0)) { } \
process_func(dec, row); if (color_cache != NULL) { \
} while (last_cached < src) { \
if (color_cache != NULL) { VP8LColorCacheInsert(color_cache, *last_cached++); \
while (last_cached < src) { } \
VP8LColorCacheInsert(color_cache, *last_cached++); } \
} } \
} } else if (code < len_code_limit) { /* Backward reference */ \
} int dist_code, dist; \
} else if (code < len_code_limit) { // Backward reference const int length_sym = code - NUM_LITERAL_CODES; \
int dist_code, dist; const int length = GetCopyLength(length_sym, br); \
const int length_sym = code - NUM_LITERAL_CODES; const int dist_symbol = ReadSymbol(&htree_group->htrees_[DIST], br); \
const int length = GetCopyLength(length_sym, br); VP8LFillBitWindow(br); \
const int dist_symbol = ReadSymbol(&htree_group->htrees_[DIST], br); dist_code = GetCopyDistance(dist_symbol, br); \
VP8LFillBitWindow(br); dist = PlaneCodeToDistance(width, dist_code); \
dist_code = GetCopyDistance(dist_symbol, br); if (src - data < dist || src_end - src < length) { \
dist = PlaneCodeToDistance(width, dist_code); ok = 0; \
if (src - data < dist || src_end - src < length) { goto End; \
ok = 0; } \
goto End; { \
} int i; \
{ for (i = 0; i < length; ++i) src[i] = src[i - dist]; \
int i; src += length; \
for (i = 0; i < length; ++i) src[i] = src[i - dist]; } \
src += length; col += length; \
} while (col >= width) { \
col += length; col -= width; \
while (col >= width) { ++row; \
col -= width; if ((process_func != NULL) && (row % NUM_ARGB_CACHE_ROWS == 0)) { \
++row; process_func(dec, row); \
if ((process_func != NULL) && (row % NUM_ARGB_CACHE_ROWS == 0)) { } \
process_func(dec, row); } \
} if (src < src_end) { \
} htree_group = GetHtreeGroupForPos(hdr, col, row); \
if (src < src_end) { if (color_cache != NULL) { \
htree_group = GetHtreeGroupForPos(hdr, col, row); while (last_cached < src) { \
if (color_cache != NULL) { VP8LColorCacheInsert(color_cache, *last_cached++); \
while (last_cached < src) { } \
VP8LColorCacheInsert(color_cache, *last_cached++); } \
} } \
} } else if (code < color_cache_limit) { /* Color cache */ \
} const int key = code - len_code_limit; \
} else if (code < color_cache_limit) { // Color cache. assert(color_cache != NULL); \
const int key = code - len_code_limit; while (last_cached < src) { \
assert(color_cache != NULL); VP8LColorCacheInsert(color_cache, *last_cached++); \
while (last_cached < src) { } \
VP8LColorCacheInsert(color_cache, *last_cached++); *src = VP8LColorCacheLookup(color_cache, key); \
} goto AdvanceByOne; \
*src = VP8LColorCacheLookup(color_cache, key); } else { /* Not reached */ \
goto AdvanceByOne; ok = 0; \
} else { // Not reached. goto End; \
ok = 0; } \
goto End; ok = !br->error_; \
} if (!ok) goto End; \
ok = !br->error_; } \
if (!ok) goto End; /* Process the remaining rows corresponding to last row-block. */ \
} if (process_func != NULL) process_func(dec, row); \
// Process the remaining rows corresponding to last row-block. End: \
if (process_func != NULL) process_func(dec, row); if (br->error_ || !ok || (br->eos_ && src < src_end)) { \
ok = 0; \
End: dec->status_ = \
if (br->error_ || !ok || (br->eos_ && src < src_end)) { (!br->eos_) ? VP8_STATUS_BITSTREAM_ERROR : VP8_STATUS_SUSPENDED; \
ok = 0; } else if (src == src_end) { \
dec->status_ = (!br->eos_) ? dec->state_ = READ_DATA; \
VP8_STATUS_BITSTREAM_ERROR : VP8_STATUS_SUSPENDED; } \
} else if (src == src_end) { return ok; \
dec->state_ = READ_DATA;
}
return ok;
} }
static WEBP_INLINE uint32_t GetARGBPixel(int alpha, int red, int green,
int blue) {
return (alpha << 24) | (red << 16) | (green << 8) | blue;
}
static WEBP_INLINE uint8_t GetAlphaPixel(int alpha, int red, int green,
int blue) {
(void)alpha;
(void)red;
(void)blue;
return green; // Alpha value is stored in green channel.
}
DECODE_DATA_FUNC(DecodeImageData, uint32_t, GetARGBPixel)
DECODE_DATA_FUNC(DecodeAlphaData, uint8_t, GetAlphaPixel)
#undef DECODE_DATA_FUNC
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// VP8LTransform // VP8LTransform
@ -903,8 +933,8 @@ void VP8LClear(VP8LDecoder* const dec) {
if (dec == NULL) return; if (dec == NULL) return;
ClearMetadata(&dec->hdr_); ClearMetadata(&dec->hdr_);
free(dec->argb_); free(dec->pixels_);
dec->argb_ = NULL; dec->pixels_ = NULL;
for (i = 0; i < dec->next_transform_; ++i) { for (i = 0; i < dec->next_transform_; ++i) {
ClearTransform(&dec->transforms_[i]); ClearTransform(&dec->transforms_[i]);
} }
@ -1028,35 +1058,39 @@ static int DecodeImageStream(int xsize, int ysize,
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Allocate dec->argb_ and dec->argb_cache_ using dec->width_ and dec->height_ // Allocate internal buffers dec->pixels_ and dec->argb_cache_.
static int AllocateInternalBuffers(VP8LDecoder* const dec, int final_width,
static int AllocateARGBBuffers(VP8LDecoder* const dec, int final_width) { size_t bytes_per_pixel) {
const int argb_cache_needed = (bytes_per_pixel == sizeof(uint32_t));
const uint64_t num_pixels = (uint64_t)dec->width_ * dec->height_; const uint64_t num_pixels = (uint64_t)dec->width_ * dec->height_;
// Scratch buffer corresponding to top-prediction row for transforming the // Scratch buffer corresponding to top-prediction row for transforming the
// first row in the row-blocks. // first row in the row-blocks. Not needed for paletted alpha.
const uint64_t cache_top_pixels = final_width; const uint64_t cache_top_pixels =
// Scratch buffer for temporary BGRA storage. argb_cache_needed ? (uint16_t)final_width : 0ULL;
const uint64_t cache_pixels = (uint64_t)final_width * NUM_ARGB_CACHE_ROWS; // Scratch buffer for temporary BGRA storage. Not needed for paletted alpha.
const uint64_t cache_pixels =
argb_cache_needed ? (uint64_t)final_width * NUM_ARGB_CACHE_ROWS : 0ULL;
const uint64_t total_num_pixels = const uint64_t total_num_pixels =
num_pixels + cache_top_pixels + cache_pixels; num_pixels + cache_top_pixels + cache_pixels;
assert(dec->width_ <= final_width); assert(dec->width_ <= final_width);
dec->argb_ = (uint32_t*)WebPSafeMalloc(total_num_pixels, sizeof(*dec->argb_)); dec->pixels_ = (uint32_t*)WebPSafeMalloc(total_num_pixels, bytes_per_pixel);
if (dec->argb_ == NULL) { if (dec->pixels_ == NULL) {
dec->argb_cache_ = NULL; // for sanity check dec->argb_cache_ = NULL; // for sanity check
dec->status_ = VP8_STATUS_OUT_OF_MEMORY; dec->status_ = VP8_STATUS_OUT_OF_MEMORY;
return 0; return 0;
} }
dec->argb_cache_ = dec->argb_ + num_pixels + cache_top_pixels; dec->argb_cache_ =
argb_cache_needed ? dec->pixels_ + num_pixels + cache_top_pixels : NULL;
return 1; return 1;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Special row-processing that only stores the alpha data.
// Special row-processing that only stores the alpha data.
static void ExtractAlphaRows(VP8LDecoder* const dec, int row) { static void ExtractAlphaRows(VP8LDecoder* const dec, int row) {
const int num_rows = row - dec->last_row_; const int num_rows = row - dec->last_row_;
const uint32_t* const in = dec->argb_ + dec->width_ * dec->last_row_; const uint32_t* const in = dec->pixels_ + dec->width_ * dec->last_row_;
if (num_rows <= 0) return; // Nothing to be done. if (num_rows <= 0) return; // Nothing to be done.
ApplyInverseTransforms(dec, num_rows, in); ApplyInverseTransforms(dec, num_rows, in);
@ -1070,7 +1104,17 @@ static void ExtractAlphaRows(VP8LDecoder* const dec, int row) {
int i; int i;
for (i = 0; i < cache_pixs; ++i) dst[i] = (src[i] >> 8) & 0xff; for (i = 0; i < cache_pixs; ++i) dst[i] = (src[i] >> 8) & 0xff;
} }
dec->last_row_ = dec->last_out_row_ = row;
}
// Row-processing for the special case when alpha data contains only one
// transform: color indexing.
static void ExtractPalettedAlphaRows(VP8LDecoder* const dec, int row) {
const int num_rows = row - dec->last_row_;
const uint8_t* const in =
(uint8_t*)dec->pixels_ + dec->width_ * dec->last_row_;
if (num_rows <= 0) return; // Nothing to be done.
ApplyInverseTransformsAlpha(dec, num_rows, in);
dec->last_row_ = dec->last_out_row_ = row; dec->last_row_ = dec->last_out_row_ = row;
} }
@ -1079,6 +1123,7 @@ int VP8LDecodeAlphaImageStream(int width, int height, const uint8_t* const data,
VP8Io io; VP8Io io;
int ok = 0; int ok = 0;
VP8LDecoder* const dec = VP8LNew(); VP8LDecoder* const dec = VP8LNew();
size_t bytes_per_pixel = sizeof(uint32_t); // Default: BGRA mode.
if (dec == NULL) return 0; if (dec == NULL) return 0;
dec->width_ = width; dec->width_ = width;
@ -1097,13 +1142,25 @@ int VP8LDecodeAlphaImageStream(int width, int height, const uint8_t* const data,
dec->action_ = READ_HDR; dec->action_ = READ_HDR;
if (!DecodeImageStream(width, height, 1, dec, NULL)) goto Err; if (!DecodeImageStream(width, height, 1, dec, NULL)) goto Err;
// Allocate output (note that dec->width_ may have changed here). // Special case: if alpha data uses only the color indexing transform and
if (!AllocateARGBBuffers(dec, width)) goto Err; // doesn't use color cache (a frequent case), we will use DecodeAlphaData()
// method that only needs allocation of 1 byte per pixel (alpha channel).
if (dec->next_transform_ == 1 &&
dec->transforms_[0].type_ == COLOR_INDEXING_TRANSFORM &&
dec->hdr_.color_cache_size_ == 0) {
bytes_per_pixel = sizeof(uint8_t);
}
// Allocate internal buffers (note that dec->width_ may have changed here).
if (!AllocateInternalBuffers(dec, width, bytes_per_pixel)) goto Err;
// Decode (with special row processing). // Decode (with special row processing).
dec->action_ = READ_DATA; dec->action_ = READ_DATA;
ok = DecodeImageData(dec, dec->argb_, dec->width_, dec->height_, ok = (bytes_per_pixel == sizeof(uint8_t)) ?
ExtractAlphaRows); DecodeAlphaData(dec, (uint8_t*)dec->pixels_, dec->width_, dec->height_,
ExtractPalettedAlphaRows) :
DecodeImageData(dec, dec->pixels_, dec->width_, dec->height_,
ExtractAlphaRows);
Err: Err:
VP8LDelete(dec); VP8LDelete(dec);
@ -1143,6 +1200,7 @@ int VP8LDecodeHeader(VP8LDecoder* const dec, VP8Io* const io) {
} }
int VP8LDecodeImage(VP8LDecoder* const dec) { int VP8LDecodeImage(VP8LDecoder* const dec) {
const size_t bytes_per_pixel = sizeof(uint32_t);
VP8Io* io = NULL; VP8Io* io = NULL;
WebPDecParams* params = NULL; WebPDecParams* params = NULL;
@ -1162,13 +1220,13 @@ int VP8LDecodeImage(VP8LDecoder* const dec) {
goto Err; goto Err;
} }
if (!AllocateARGBBuffers(dec, io->width)) goto Err; if (!AllocateInternalBuffers(dec, io->width, bytes_per_pixel)) goto Err;
if (io->use_scaling && !AllocateAndInitRescaler(dec, io)) goto Err; if (io->use_scaling && !AllocateAndInitRescaler(dec, io)) goto Err;
// Decode. // Decode.
dec->action_ = READ_DATA; dec->action_ = READ_DATA;
if (!DecodeImageData(dec, dec->argb_, dec->width_, dec->height_, if (!DecodeImageData(dec, dec->pixels_, dec->width_, dec->height_,
ProcessRows)) { ProcessRows)) {
goto Err; goto Err;
} }

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Lossless decoder: internal header. // Lossless decoder: internal header.
@ -63,7 +65,8 @@ typedef struct {
const WebPDecBuffer *output_; // shortcut to io->opaque->output const WebPDecBuffer *output_; // shortcut to io->opaque->output
uint32_t *argb_; // Internal data: always in BGRA color mode. uint32_t *pixels_; // Internal data: either uint8_t* for alpha
// or uint32_t* for BGRA.
uint32_t *argb_cache_; // Scratch buffer for temporary BGRA storage. uint32_t *argb_cache_; // Scratch buffer for temporary BGRA storage.
VP8LBitReader br_; VP8LBitReader br_;

View File

@ -1,8 +1,10 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Main decoding functions for WEBP images. // Main decoding functions for WEBP images.
@ -192,6 +194,15 @@ static VP8StatusCode ParseOptionalChunks(const uint8_t** const data,
return VP8_STATUS_BITSTREAM_ERROR; // Not a valid chunk size. return VP8_STATUS_BITSTREAM_ERROR; // Not a valid chunk size.
} }
// Start of a (possibly incomplete) VP8/VP8L chunk implies that we have
// parsed all the optional chunks.
// Note: This check must occur before the check 'buf_size < disk_chunk_size'
// below to allow incomplete VP8/VP8L chunks.
if (!memcmp(buf, "VP8 ", TAG_SIZE) ||
!memcmp(buf, "VP8L", TAG_SIZE)) {
return VP8_STATUS_OK;
}
if (buf_size < disk_chunk_size) { // Insufficient data. if (buf_size < disk_chunk_size) { // Insufficient data.
return VP8_STATUS_NOT_ENOUGH_DATA; return VP8_STATUS_NOT_ENOUGH_DATA;
} }
@ -199,9 +210,6 @@ static VP8StatusCode ParseOptionalChunks(const uint8_t** const data,
if (!memcmp(buf, "ALPH", TAG_SIZE)) { // A valid ALPH header. if (!memcmp(buf, "ALPH", TAG_SIZE)) { // A valid ALPH header.
*alpha_data = buf + CHUNK_HEADER_SIZE; *alpha_data = buf + CHUNK_HEADER_SIZE;
*alpha_size = chunk_size; *alpha_size = chunk_size;
} else if (!memcmp(buf, "VP8 ", TAG_SIZE) ||
!memcmp(buf, "VP8L", TAG_SIZE)) { // A valid VP8/VP8L header.
return VP8_STATUS_OK; // Found.
} }
// We have a full and valid chunk; skip it. // We have a full and valid chunk; skip it.

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Internal header: WebP decoding parameters and custom IO on buffer // Internal header: WebP decoding parameters and custom IO on buffer

View File

@ -10,6 +10,6 @@ libwebpdemuxinclude_HEADERS += ../webp/mux_types.h
libwebpdemuxinclude_HEADERS += ../webp/types.h libwebpdemuxinclude_HEADERS += ../webp/types.h
libwebpdemux_la_LIBADD = ../libwebp.la libwebpdemux_la_LIBADD = ../libwebp.la
libwebpdemux_la_LDFLAGS = -no-undefined -version-info 0:0:0 libwebpdemux_la_LDFLAGS = -no-undefined -version-info 0:1:0
libwebpdemuxincludedir = $(includedir)/webp libwebpdemuxincludedir = $(includedir)/webp
pkgconfig_DATA = libwebpdemux.pc pkgconfig_DATA = libwebpdemux.pc

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// WebP container demux. // WebP container demux.
@ -27,7 +29,7 @@ extern "C" {
#define DMUX_MAJ_VERSION 0 #define DMUX_MAJ_VERSION 0
#define DMUX_MIN_VERSION 1 #define DMUX_MIN_VERSION 1
#define DMUX_REV_VERSION 0 #define DMUX_REV_VERSION 1
typedef struct { typedef struct {
size_t start_; // start location of the data size_t start_; // start location of the data
@ -317,6 +319,7 @@ static ParseStatus ParseAnimationFrame(
frame->duration_ = ReadLE24s(mem); frame->duration_ = ReadLE24s(mem);
frame->dispose_method_ = (WebPMuxAnimDispose)(ReadByte(mem) & 1); frame->dispose_method_ = (WebPMuxAnimDispose)(ReadByte(mem) & 1);
if (frame->width_ * (uint64_t)frame->height_ >= MAX_IMAGE_AREA) { if (frame->width_ * (uint64_t)frame->height_ >= MAX_IMAGE_AREA) {
free(frame);
return PARSE_ERROR; return PARSE_ERROR;
} }

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// CPU detection // CPU detection

View File

@ -1,8 +1,10 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Speed-critical decoding functions. // Speed-critical decoding functions.

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// ARM NEON version of dsp functions and loop filtering. // ARM NEON version of dsp functions and loop filtering.

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// SSE2 version of some decoding functions (idct, loop filtering). // SSE2 version of some decoding functions (idct, loop filtering).

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Speed-critical functions. // Speed-critical functions.

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Speed-critical encoding functions. // Speed-critical encoding functions.
@ -142,9 +144,9 @@ static void FTransform(const uint8_t* src, const uint8_t* ref, int16_t* out) {
const int a1 = (d1 + d2); const int a1 = (d1 + d2);
const int a2 = (d1 - d2); const int a2 = (d1 - d2);
const int a3 = (d0 - d3); const int a3 = (d0 - d3);
tmp[0 + i * 4] = (a0 + a1) << 3; // 14b [-8160,8160] tmp[0 + i * 4] = (a0 + a1) * 8; // 14b [-8160,8160]
tmp[1 + i * 4] = (a2 * 2217 + a3 * 5352 + 1812) >> 9; // [-7536,7542] tmp[1 + i * 4] = (a2 * 2217 + a3 * 5352 + 1812) >> 9; // [-7536,7542]
tmp[2 + i * 4] = (a0 - a1) << 3; tmp[2 + i * 4] = (a0 - a1) * 8;
tmp[3 + i * 4] = (a3 * 2217 - a2 * 5352 + 937) >> 9; tmp[3 + i * 4] = (a3 * 2217 - a2 * 5352 + 937) >> 9;
} }
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
@ -187,31 +189,32 @@ static void ITransformWHT(const int16_t* in, int16_t* out) {
} }
static void FTransformWHT(const int16_t* in, int16_t* out) { static void FTransformWHT(const int16_t* in, int16_t* out) {
int tmp[16]; // input is 12b signed
int16_t tmp[16];
int i; int i;
for (i = 0; i < 4; ++i, in += 64) { for (i = 0; i < 4; ++i, in += 64) {
const int a0 = (in[0 * 16] + in[2 * 16]) << 2; const int a0 = (in[0 * 16] + in[2 * 16]); // 13b
const int a1 = (in[1 * 16] + in[3 * 16]) << 2; const int a1 = (in[1 * 16] + in[3 * 16]);
const int a2 = (in[1 * 16] - in[3 * 16]) << 2; const int a2 = (in[1 * 16] - in[3 * 16]);
const int a3 = (in[0 * 16] - in[2 * 16]) << 2; const int a3 = (in[0 * 16] - in[2 * 16]);
tmp[0 + i * 4] = (a0 + a1) + (a0 != 0); tmp[0 + i * 4] = a0 + a1; // 14b
tmp[1 + i * 4] = a3 + a2; tmp[1 + i * 4] = a3 + a2;
tmp[2 + i * 4] = a3 - a2; tmp[2 + i * 4] = a3 - a2;
tmp[3 + i * 4] = a0 - a1; tmp[3 + i * 4] = a0 - a1;
} }
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
const int a0 = (tmp[0 + i] + tmp[8 + i]); const int a0 = (tmp[0 + i] + tmp[8 + i]); // 15b
const int a1 = (tmp[4 + i] + tmp[12+ i]); const int a1 = (tmp[4 + i] + tmp[12+ i]);
const int a2 = (tmp[4 + i] - tmp[12+ i]); const int a2 = (tmp[4 + i] - tmp[12+ i]);
const int a3 = (tmp[0 + i] - tmp[8 + i]); const int a3 = (tmp[0 + i] - tmp[8 + i]);
const int b0 = a0 + a1; const int b0 = a0 + a1; // 16b
const int b1 = a3 + a2; const int b1 = a3 + a2;
const int b2 = a3 - a2; const int b2 = a3 - a2;
const int b3 = a0 - a1; const int b3 = a0 - a1;
out[ 0 + i] = (b0 + (b0 > 0) + 3) >> 3; out[ 0 + i] = b0 >> 1; // 15b
out[ 4 + i] = (b1 + (b1 > 0) + 3) >> 3; out[ 4 + i] = b1 >> 1;
out[ 8 + i] = (b2 + (b2 > 0) + 3) >> 3; out[ 8 + i] = b2 >> 1;
out[12 + i] = (b3 + (b3 > 0) + 3) >> 3; out[12 + i] = b3 >> 1;
} }
} }

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// ARM NEON version of speed-critical encoding functions. // ARM NEON version of speed-critical encoding functions.
@ -322,7 +324,7 @@ static void FTransform(const uint8_t* src, const uint8_t* ref,
"vmlal.s16 q11, d6, d17 \n" // c1*2217 + d1*5352 + 12000 "vmlal.s16 q11, d6, d17 \n" // c1*2217 + d1*5352 + 12000
"vmlsl.s16 q12, d6, d16 \n" // d1*2217 - c1*5352 + 51000 "vmlsl.s16 q12, d6, d16 \n" // d1*2217 - c1*5352 + 51000
"vmvn.s16 d4, d4 \n" "vmvn d4, d4 \n" // !(d1 == 0)
// op[4] = (c1*2217 + d1*5352 + 12000)>>16 // op[4] = (c1*2217 + d1*5352 + 12000)>>16
"vshrn.s32 d1, q11, #16 \n" "vshrn.s32 d1, q11, #16 \n"
// op[4] += (d1!=0) // op[4] += (d1!=0)
@ -363,19 +365,12 @@ static void FTransformWHT(const int16_t* in, int16_t* out) {
"vld1.16 d2[3], [%[in]], %[kStep] \n" "vld1.16 d2[3], [%[in]], %[kStep] \n"
"vld1.16 d3[3], [%[in]], %[kStep] \n" "vld1.16 d3[3], [%[in]], %[kStep] \n"
"vaddl.s16 q2, d0, d2 \n" "vaddl.s16 q2, d0, d2 \n" // a0=(in[0*16]+in[2*16])
"vshl.s32 q2, q2, #2 \n" // a0=(in[0*16]+in[2*16])<<2 "vaddl.s16 q3, d1, d3 \n" // a1=(in[1*16]+in[3*16])
"vaddl.s16 q3, d1, d3 \n" "vsubl.s16 q4, d1, d3 \n" // a2=(in[1*16]-in[3*16])
"vshl.s32 q3, q3, #2 \n" // a1=(in[1*16]+in[3*16])<<2 "vsubl.s16 q5, d0, d2 \n" // a3=(in[0*16]-in[2*16])
"vsubl.s16 q4, d1, d3 \n"
"vshl.s32 q4, q4, #2 \n" // a2=(in[1*16]-in[3*16])<<2
"vsubl.s16 q5, d0, d2 \n"
"vshl.s32 q5, q5, #2 \n" // a3=(in[0*16]-in[2*16])<<2
"vceq.s32 q10, q2, #0 \n" "vqadd.s32 q6, q2, q3 \n" // a0 + a1
"vmvn.s32 q10, q10 \n" // (a0 != 0)
"vqadd.s32 q6, q2, q3 \n" // (a0 + a1)
"vqsub.s32 q6, q6, q10 \n" // (a0 + a1) + (a0 != 0)
"vqadd.s32 q7, q5, q4 \n" // a3 + a2 "vqadd.s32 q7, q5, q4 \n" // a3 + a2
"vqsub.s32 q8, q5, q4 \n" // a3 - a2 "vqsub.s32 q8, q5, q4 \n" // a3 - a2
"vqsub.s32 q9, q2, q3 \n" // a0 - a1 "vqsub.s32 q9, q2, q3 \n" // a0 - a1
@ -398,27 +393,10 @@ static void FTransformWHT(const int16_t* in, int16_t* out) {
"vqsub.s32 q6, q3, q2 \n" // b2 = a3 - a2 "vqsub.s32 q6, q3, q2 \n" // b2 = a3 - a2
"vqsub.s32 q7, q0, q1 \n" // b3 = a0 - a1 "vqsub.s32 q7, q0, q1 \n" // b3 = a0 - a1
"vmov.s32 q0, #3 \n" // q0 = 3 "vshrn.s32 d18, q4, #1 \n" // b0 >> 1
"vshrn.s32 d19, q5, #1 \n" // b1 >> 1
"vcgt.s32 q1, q4, #0 \n" // (b0>0) "vshrn.s32 d20, q6, #1 \n" // b2 >> 1
"vqsub.s32 q2, q4, q1 \n" // (b0+(b0>0)) "vshrn.s32 d21, q7, #1 \n" // b3 >> 1
"vqadd.s32 q3, q2, q0 \n" // (b0+(b0>0)+3)
"vshrn.s32 d18, q3, #3 \n" // (b0+(b0>0)+3) >> 3
"vcgt.s32 q1, q5, #0 \n" // (b1>0)
"vqsub.s32 q2, q5, q1 \n" // (b1+(b1>0))
"vqadd.s32 q3, q2, q0 \n" // (b1+(b1>0)+3)
"vshrn.s32 d19, q3, #3 \n" // (b1+(b1>0)+3) >> 3
"vcgt.s32 q1, q6, #0 \n" // (b2>0)
"vqsub.s32 q2, q6, q1 \n" // (b2+(b2>0))
"vqadd.s32 q3, q2, q0 \n" // (b2+(b2>0)+3)
"vshrn.s32 d20, q3, #3 \n" // (b2+(b2>0)+3) >> 3
"vcgt.s32 q1, q7, #0 \n" // (b3>0)
"vqsub.s32 q2, q7, q1 \n" // (b3+(b3>0))
"vqadd.s32 q3, q2, q0 \n" // (b3+(b3>0)+3)
"vshrn.s32 d21, q3, #3 \n" // (b3+(b3>0)+3) >> 3
"vst1.16 {q9, q10}, [%[out]] \n" "vst1.16 {q9, q10}, [%[out]] \n"

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// SSE2 version of speed-critical encoding functions. // SSE2 version of speed-critical encoding functions.
@ -453,6 +455,39 @@ static void FTransformSSE2(const uint8_t* src, const uint8_t* ref,
} }
} }
static void FTransformWHTSSE2(const int16_t* in, int16_t* out) {
int16_t tmp[16];
int i;
for (i = 0; i < 4; ++i, in += 64) {
const int a0 = (in[0 * 16] + in[2 * 16]);
const int a1 = (in[1 * 16] + in[3 * 16]);
const int a2 = (in[1 * 16] - in[3 * 16]);
const int a3 = (in[0 * 16] - in[2 * 16]);
tmp[0 + i * 4] = a0 + a1;
tmp[1 + i * 4] = a3 + a2;
tmp[2 + i * 4] = a3 - a2;
tmp[3 + i * 4] = a0 - a1;
}
{
const __m128i src0 = _mm_loadl_epi64((__m128i*)&tmp[0]);
const __m128i src1 = _mm_loadl_epi64((__m128i*)&tmp[4]);
const __m128i src2 = _mm_loadl_epi64((__m128i*)&tmp[8]);
const __m128i src3 = _mm_loadl_epi64((__m128i*)&tmp[12]);
const __m128i a0 = _mm_add_epi16(src0, src2);
const __m128i a1 = _mm_add_epi16(src1, src3);
const __m128i a2 = _mm_sub_epi16(src1, src3);
const __m128i a3 = _mm_sub_epi16(src0, src2);
const __m128i b0 = _mm_srai_epi16(_mm_adds_epi16(a0, a1), 1);
const __m128i b1 = _mm_srai_epi16(_mm_adds_epi16(a3, a2), 1);
const __m128i b2 = _mm_srai_epi16(_mm_subs_epi16(a3, a2), 1);
const __m128i b3 = _mm_srai_epi16(_mm_subs_epi16(a0, a1), 1);
_mm_storel_epi64((__m128i*)&out[ 0], b0);
_mm_storel_epi64((__m128i*)&out[ 4], b1);
_mm_storel_epi64((__m128i*)&out[ 8], b2);
_mm_storel_epi64((__m128i*)&out[12], b3);
}
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Metric // Metric
@ -919,6 +954,7 @@ void VP8EncDspInitSSE2(void) {
VP8EncQuantizeBlock = QuantizeBlockSSE2; VP8EncQuantizeBlock = QuantizeBlockSSE2;
VP8ITransform = ITransformSSE2; VP8ITransform = ITransformSSE2;
VP8FTransform = FTransformSSE2; VP8FTransform = FTransformSSE2;
VP8FTransformWHT = FTransformWHTSSE2;
VP8SSE16x16 = SSE16x16SSE2; VP8SSE16x16 = SSE16x16SSE2;
VP8SSE16x8 = SSE16x8SSE2; VP8SSE16x8 = SSE16x8SSE2;
VP8SSE8x8 = SSE8x8SSE2; VP8SSE8x8 = SSE8x8SSE2;

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Image transforms and color space conversion methods for lossless decoder. // Image transforms and color space conversion methods for lossless decoder.
@ -1093,39 +1095,64 @@ static void ColorSpaceInverseTransform(const VP8LTransform* const transform,
} }
// Separate out pixels packed together using pixel-bundling. // Separate out pixels packed together using pixel-bundling.
static void ColorIndexInverseTransform( // We define two methods for ARGB data (uint32_t) and alpha-only data (uint8_t).
const VP8LTransform* const transform, #define COLOR_INDEX_INVERSE(FUNC_NAME, TYPE, GET_INDEX, GET_VALUE) \
int y_start, int y_end, const uint32_t* src, uint32_t* dst) { void FUNC_NAME(const VP8LTransform* const transform, \
int y; int y_start, int y_end, const TYPE* src, TYPE* dst) { \
const int bits_per_pixel = 8 >> transform->bits_; int y; \
const int width = transform->xsize_; const int bits_per_pixel = 8 >> transform->bits_; \
const uint32_t* const color_map = transform->data_; const int width = transform->xsize_; \
if (bits_per_pixel < 8) { const uint32_t* const color_map = transform->data_; \
const int pixels_per_byte = 1 << transform->bits_; if (bits_per_pixel < 8) { \
const int count_mask = pixels_per_byte - 1; const int pixels_per_byte = 1 << transform->bits_; \
const uint32_t bit_mask = (1 << bits_per_pixel) - 1; const int count_mask = pixels_per_byte - 1; \
for (y = y_start; y < y_end; ++y) { const uint32_t bit_mask = (1 << bits_per_pixel) - 1; \
uint32_t packed_pixels = 0; for (y = y_start; y < y_end; ++y) { \
int x; uint32_t packed_pixels = 0; \
for (x = 0; x < width; ++x) { int x; \
// We need to load fresh 'packed_pixels' once every 'pixels_per_byte' for (x = 0; x < width; ++x) { \
// increments of x. Fortunately, pixels_per_byte is a power of 2, so /* We need to load fresh 'packed_pixels' once every */ \
// can just use a mask for that, instead of decrementing a counter. /* 'pixels_per_byte' increments of x. Fortunately, pixels_per_byte */ \
if ((x & count_mask) == 0) packed_pixels = ((*src++) >> 8) & 0xff; /* is a power of 2, so can just use a mask for that, instead of */ \
*dst++ = color_map[packed_pixels & bit_mask]; /* decrementing a counter. */ \
packed_pixels >>= bits_per_pixel; if ((x & count_mask) == 0) packed_pixels = GET_INDEX(*src++); \
} *dst++ = GET_VALUE(color_map[packed_pixels & bit_mask]); \
} packed_pixels >>= bits_per_pixel; \
} else { } \
for (y = y_start; y < y_end; ++y) { } \
int x; } else { \
for (x = 0; x < width; ++x) { for (y = y_start; y < y_end; ++y) { \
*dst++ = color_map[((*src++) >> 8) & 0xff]; int x; \
} for (x = 0; x < width; ++x) { \
} *dst++ = GET_VALUE(color_map[GET_INDEX(*src++)]); \
} } \
} \
} \
} }
static WEBP_INLINE uint32_t GetARGBIndex(uint32_t idx) {
return (idx >> 8) & 0xff;
}
static WEBP_INLINE uint8_t GetAlphaIndex(uint8_t idx) {
return idx;
}
static WEBP_INLINE uint32_t GetARGBValue(uint32_t val) {
return val;
}
static WEBP_INLINE uint8_t GetAlphaValue(uint32_t val) {
return (val >> 8) & 0xff;
}
static COLOR_INDEX_INVERSE(ColorIndexInverseTransform, uint32_t, GetARGBIndex,
GetARGBValue)
COLOR_INDEX_INVERSE(VP8LColorIndexInverseTransformAlpha, uint8_t, GetAlphaIndex,
GetAlphaValue)
#undef COLOR_INDEX_INVERSE
void VP8LInverseTransform(const VP8LTransform* const transform, void VP8LInverseTransform(const VP8LTransform* const transform,
int row_start, int row_end, int row_start, int row_end,
const uint32_t* const in, uint32_t* const out) { const uint32_t* const in, uint32_t* const out) {
@ -1254,11 +1281,12 @@ static void CopyOrSwap(const uint32_t* src, int num_pixels, uint8_t* dst,
while (src < src_end) { while (src < src_end) {
uint32_t argb = *src++; uint32_t argb = *src++;
#if !defined(__BIG_ENDIAN__)
#if !defined(WEBP_REFERENCE_IMPLEMENTATION) #if !defined(WEBP_REFERENCE_IMPLEMENTATION)
#if !defined(__BIG_ENDIAN__) && (defined(__i386__) || defined(__x86_64__)) #if defined(__i386__) || defined(__x86_64__)
__asm__ volatile("bswap %0" : "=r"(argb) : "0"(argb)); __asm__ volatile("bswap %0" : "=r"(argb) : "0"(argb));
*(uint32_t*)dst = argb; *(uint32_t*)dst = argb;
#elif !defined(__BIG_ENDIAN__) && defined(_MSC_VER) #elif defined(_MSC_VER)
argb = _byteswap_ulong(argb); argb = _byteswap_ulong(argb);
*(uint32_t*)dst = argb; *(uint32_t*)dst = argb;
#else #else
@ -1267,11 +1295,17 @@ static void CopyOrSwap(const uint32_t* src, int num_pixels, uint8_t* dst,
dst[2] = (argb >> 8) & 0xff; dst[2] = (argb >> 8) & 0xff;
dst[3] = (argb >> 0) & 0xff; dst[3] = (argb >> 0) & 0xff;
#endif #endif
#else // WEBP_REFERENCE_IMPLEMENTATION #else // WEBP_REFERENCE_IMPLEMENTATION
dst[0] = (argb >> 24) & 0xff; dst[0] = (argb >> 24) & 0xff;
dst[1] = (argb >> 16) & 0xff; dst[1] = (argb >> 16) & 0xff;
dst[2] = (argb >> 8) & 0xff; dst[2] = (argb >> 8) & 0xff;
dst[3] = (argb >> 0) & 0xff; dst[3] = (argb >> 0) & 0xff;
#endif
#else // __BIG_ENDIAN__
dst[0] = (argb >> 0) & 0xff;
dst[1] = (argb >> 8) & 0xff;
dst[2] = (argb >> 16) & 0xff;
dst[3] = (argb >> 24) & 0xff;
#endif #endif
dst += sizeof(argb); dst += sizeof(argb);
} }
@ -1325,6 +1359,27 @@ void VP8LConvertFromBGRA(const uint32_t* const in_data, int num_pixels,
} }
} }
// Bundles multiple (1, 2, 4 or 8) pixels into a single pixel.
void VP8LBundleColorMap(const uint8_t* const row, int width,
int xbits, uint32_t* const dst) {
int x;
if (xbits > 0) {
const int bit_depth = 1 << (3 - xbits);
const int mask = (1 << xbits) - 1;
uint32_t code = 0xff000000;
for (x = 0; x < width; ++x) {
const int xsub = x & mask;
if (xsub == 0) {
code = 0xff000000;
}
code |= row[x] << (8 + bit_depth * xsub);
dst[x >> xbits] = code;
}
} else {
for (x = 0; x < width; ++x) dst[x] = 0xff000000 | (row[x] << 8);
}
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#if defined(__cplusplus) || defined(c_plusplus) #if defined(__cplusplus) || defined(c_plusplus)

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Image transforms and color space conversion methods for lossless decoder. // Image transforms and color space conversion methods for lossless decoder.
@ -33,6 +35,13 @@ void VP8LInverseTransform(const struct VP8LTransform* const transform,
int row_start, int row_end, int row_start, int row_end,
const uint32_t* const in, uint32_t* const out); const uint32_t* const in, uint32_t* const out);
// Similar to the static method ColorIndexInverseTransform() that is part of
// lossless.c, but used only for alpha decoding. It takes uint8_t (rather than
// uint32_t) arguments for 'src' and 'dst'.
void VP8LColorIndexInverseTransformAlpha(
const struct VP8LTransform* const transform, int y_start, int y_end,
const uint8_t* src, uint8_t* dst);
// Subtracts green from blue and red channels. // Subtracts green from blue and red channels.
void VP8LSubtractGreenFromBlueAndRed(uint32_t* argb_data, int num_pixs); void VP8LSubtractGreenFromBlueAndRed(uint32_t* argb_data, int num_pixs);
@ -83,6 +92,9 @@ static WEBP_INLINE uint32_t VP8LSubPixels(uint32_t a, uint32_t b) {
return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu); return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu);
} }
void VP8LBundleColorMap(const uint8_t* const row, int width,
int xbits, uint32_t* const dst);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#if defined(__cplusplus) || defined(c_plusplus) #if defined(__cplusplus) || defined(c_plusplus)

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// YUV to RGB upsampling functions. // YUV to RGB upsampling functions.

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// NEON version of YUV to RGB upsampling functions. // NEON version of YUV to RGB upsampling functions.

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// SSE2 version of YUV to RGB upsampling functions. // SSE2 version of YUV to RGB upsampling functions.

View File

@ -1,8 +1,10 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// YUV->RGB conversion function // YUV->RGB conversion function

View File

@ -1,8 +1,10 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// inline YUV<->RGB conversion function // inline YUV<->RGB conversion function

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Alpha-plane compression. // Alpha-plane compression.
@ -80,7 +82,7 @@ static int EncodeLossless(const uint8_t* const data, int width, int height,
config.lossless = 1; config.lossless = 1;
config.method = effort_level; // impact is very small config.method = effort_level; // impact is very small
// Set a moderate default quality setting for alpha. // Set a moderate default quality setting for alpha.
config.quality = 5.f * effort_level; config.quality = 10.f * effort_level;
assert(config.quality >= 0 && config.quality <= 100.f); assert(config.quality >= 0 && config.quality <= 100.f);
ok = VP8LBitWriterInit(&tmp_bw, (width * height) >> 3); ok = VP8LBitWriterInit(&tmp_bw, (width * height) >> 3);
@ -156,6 +158,25 @@ static void CopyPlane(const uint8_t* src, int src_stride,
} }
} }
static int GetNumColors(const uint8_t* data, int width, int height,
int stride) {
int j;
int colors = 0;
uint8_t color[256] = { 0 };
for (j = 0; j < height; ++j) {
int i;
const uint8_t* const p = data + j * stride;
for (i = 0; i < width; ++i) {
color[p[i]] = 1;
}
}
for (j = 0; j < 256; ++j) {
if (color[j] > 0) ++colors;
}
return colors;
}
static int EncodeAlpha(VP8Encoder* const enc, static int EncodeAlpha(VP8Encoder* const enc,
int quality, int method, int filter, int quality, int method, int filter,
int effort_level, int effort_level,
@ -207,18 +228,32 @@ static int EncodeAlpha(VP8Encoder* const enc,
VP8BitWriter bw; VP8BitWriter bw;
int test_filter; int test_filter;
uint8_t* filtered_alpha = NULL; uint8_t* filtered_alpha = NULL;
int try_filter_none = (effort_level > 3);
// We always test WEBP_FILTER_NONE first. if (filter == WEBP_FILTER_FAST) { // Quick estimate of the best candidate.
ok = EncodeAlphaInternal(quant_alpha, width, height, const int kMinColorsForFilterNone = 16;
method, WEBP_FILTER_NONE, reduce_levels, const int kMaxColorsForFilterNone = 192;
effort_level, NULL, &bw, pic->stats); const int num_colors = GetNumColors(quant_alpha, width, height, width);
if (!ok) { // For low number of colors, NONE yeilds better compression.
VP8BitWriterWipeOut(&bw); filter = (num_colors <= kMinColorsForFilterNone) ? WEBP_FILTER_NONE :
goto End; EstimateBestFilter(quant_alpha, width, height, width);
// For large number of colors, try FILTER_NONE in addition to the best
// filter as well.
if (num_colors > kMaxColorsForFilterNone) {
try_filter_none = 1;
}
} }
if (filter == WEBP_FILTER_FAST) { // Quick estimate of a second candidate? // Test for WEBP_FILTER_NONE for higher effort levels.
filter = EstimateBestFilter(quant_alpha, width, height, width); if (try_filter_none || filter == WEBP_FILTER_NONE) {
ok = EncodeAlphaInternal(quant_alpha, width, height,
method, WEBP_FILTER_NONE, reduce_levels,
effort_level, NULL, &bw, pic->stats);
if (!ok) {
VP8BitWriterWipeOut(&bw);
goto End;
}
} }
// Stop? // Stop?
if (filter == WEBP_FILTER_NONE) { if (filter == WEBP_FILTER_NONE) {
@ -234,11 +269,14 @@ static int EncodeAlpha(VP8Encoder* const enc,
// Try the other mode(s). // Try the other mode(s).
{ {
WebPAuxStats best_stats; WebPAuxStats best_stats;
size_t best_score = VP8BitWriterSize(&bw); size_t best_score = try_filter_none ?
VP8BitWriterSize(&bw) : (size_t)~0U;
int wipe_tmp_bw = try_filter_none;
memset(&best_stats, 0, sizeof(best_stats)); // prevent spurious warning memset(&best_stats, 0, sizeof(best_stats)); // prevent spurious warning
if (pic->stats != NULL) best_stats = *pic->stats; if (pic->stats != NULL) best_stats = *pic->stats;
for (test_filter = WEBP_FILTER_HORIZONTAL; for (test_filter =
try_filter_none ? WEBP_FILTER_HORIZONTAL : WEBP_FILTER_NONE;
ok && (test_filter <= WEBP_FILTER_GRADIENT); ok && (test_filter <= WEBP_FILTER_GRADIENT);
++test_filter) { ++test_filter) {
VP8BitWriter tmp_bw; VP8BitWriter tmp_bw;
@ -262,7 +300,10 @@ static int EncodeAlpha(VP8Encoder* const enc,
} else { } else {
VP8BitWriterWipeOut(&bw); VP8BitWriterWipeOut(&bw);
} }
VP8BitWriterWipeOut(&tmp_bw); if (wipe_tmp_bw) {
VP8BitWriterWipeOut(&tmp_bw);
}
wipe_tmp_bw = 1; // For next filter trial for WEBP_FILTER_BEST.
} }
if (pic->stats != NULL) *pic->stats = best_stats; if (pic->stats != NULL) *pic->stats = best_stats;
} }

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Macroblock analysis // Macroblock analysis

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Author: Jyrki Alakuijala (jyrki@google.com) // Author: Jyrki Alakuijala (jyrki@google.com)
@ -142,9 +144,10 @@ static void HashChainInsert(HashChain* const p,
} }
static void GetParamsForHashChainFindCopy(int quality, int xsize, static void GetParamsForHashChainFindCopy(int quality, int xsize,
int* window_size, int* iter_pos, int cache_bits, int* window_size,
int* iter_limit) { int* iter_pos, int* iter_limit) {
const int iter_mult = (quality < 27) ? 1 : 1 + ((quality - 27) >> 4); const int iter_mult = (quality < 27) ? 1 : 1 + ((quality - 27) >> 4);
const int iter_neg = -iter_mult * (quality >> 1);
// Limit the backward-ref window size for lower qualities. // Limit the backward-ref window size for lower qualities.
const int max_window_size = (quality > 50) ? WINDOW_SIZE const int max_window_size = (quality > 50) ? WINDOW_SIZE
: (quality > 25) ? (xsize << 8) : (quality > 25) ? (xsize << 8)
@ -152,77 +155,74 @@ static void GetParamsForHashChainFindCopy(int quality, int xsize,
assert(xsize > 0); assert(xsize > 0);
*window_size = (max_window_size > WINDOW_SIZE) ? WINDOW_SIZE *window_size = (max_window_size > WINDOW_SIZE) ? WINDOW_SIZE
: max_window_size; : max_window_size;
*iter_pos = 5 + (quality >> 3); *iter_pos = 8 + (quality >> 3);
*iter_limit = -quality * iter_mult; // For lower entropy images, the rigourous search loop in HashChainFindCopy
// can be relaxed.
*iter_limit = (cache_bits > 0) ? iter_neg : iter_neg / 2;
} }
static int HashChainFindCopy(const HashChain* const p, static int HashChainFindCopy(const HashChain* const p,
int base_position, int xsize, int base_position, int xsize_signed,
const uint32_t* const argb, int maxlen, const uint32_t* const argb, int maxlen,
int window_size, int iter_pos, int iter_limit, int window_size, int iter_pos, int iter_limit,
int* const distance_ptr, int* const distance_ptr,
int* const length_ptr) { int* const length_ptr) {
const uint64_t hash_code = GetPixPairHash64(&argb[base_position]);
int prev_length = 0;
int64_t best_val = 0;
int best_length = 0;
int best_distance = 0;
const uint32_t* const argb_start = argb + base_position; const uint32_t* const argb_start = argb + base_position;
uint64_t best_val = 0;
uint32_t best_length = 1;
uint32_t best_distance = 0;
const uint32_t xsize = (uint32_t)xsize_signed;
const int min_pos = const int min_pos =
(base_position > window_size) ? base_position - window_size : 0; (base_position > window_size) ? base_position - window_size : 0;
int pos; int pos;
assert(xsize > 0); assert(xsize > 0);
for (pos = p->hash_to_first_index_[hash_code]; for (pos = p->hash_to_first_index_[GetPixPairHash64(argb_start)];
pos >= min_pos; pos >= min_pos;
pos = p->chain_[pos]) { pos = p->chain_[pos]) {
int64_t val; uint64_t val;
int curr_length; uint32_t curr_length;
uint32_t distance;
if (iter_pos < 0) { if (iter_pos < 0) {
if (iter_pos < iter_limit || best_val >= 0xff0000) { if (iter_pos < iter_limit || best_val >= 0xff0000) {
break; break;
} }
} }
--iter_pos; --iter_pos;
if (best_length != 0 && if (argb[pos + best_length - 1] != argb_start[best_length - 1]) {
argb[pos + best_length - 1] != argb_start[best_length - 1]) {
continue; continue;
} }
curr_length = FindMatchLength(argb + pos, argb_start, maxlen); curr_length = FindMatchLength(argb + pos, argb_start, maxlen);
if (curr_length < prev_length) { if (curr_length < best_length) {
continue; continue;
} }
val = 65536 * curr_length; distance = (uint32_t)(base_position - pos);
val = curr_length << 16;
// Favoring 2d locality here gives savings for certain images. // Favoring 2d locality here gives savings for certain images.
if (base_position - pos < 9 * xsize) { if (distance < 9 * xsize) {
const int y = (base_position - pos) / xsize; const uint32_t y = distance / xsize;
int x = (base_position - pos) % xsize; uint32_t x = distance % xsize;
if (x > xsize / 2) { if (x > (xsize >> 1)) {
x = xsize - x; x = xsize - x;
} }
if (x <= 7 && x >= -8) { if (x <= 7) {
val += 9 * 9 + 9 * 9;
val -= y * y + x * x; val -= y * y + x * x;
} else {
val -= 9 * 9 + 9 * 9;
} }
} else {
val -= 9 * 9 + 9 * 9;
} }
if (best_val < val) { if (best_val < val) {
prev_length = curr_length;
best_val = val; best_val = val;
best_length = curr_length; best_length = curr_length;
best_distance = base_position - pos; best_distance = distance;
if (curr_length >= MAX_LENGTH) { if (curr_length >= MAX_LENGTH) {
break; break;
} }
if ((best_distance == 1 || best_distance == xsize) && if ((best_distance == 1 || distance == xsize) &&
best_length >= 128) { best_length >= 128) {
break; break;
} }
} }
} }
*distance_ptr = best_distance; *distance_ptr = (int)best_distance;
*length_ptr = best_length; *length_ptr = best_length;
return (best_length >= MIN_LENGTH); return (best_length >= MIN_LENGTH);
} }
@ -284,8 +284,8 @@ static int BackwardReferencesHashChain(int xsize, int ysize,
if (!HashChainInit(hash_chain, pix_count)) goto Error; if (!HashChainInit(hash_chain, pix_count)) goto Error;
refs->size = 0; refs->size = 0;
GetParamsForHashChainFindCopy(quality, xsize, &window_size, &iter_pos, GetParamsForHashChainFindCopy(quality, xsize, cache_bits,
&iter_limit); &window_size, &iter_pos, &iter_limit);
for (i = 0; i < pix_count; ) { for (i = 0; i < pix_count; ) {
// Alternative#1: Code the pixels starting at 'i' using backward reference. // Alternative#1: Code the pixels starting at 'i' using backward reference.
int offset = 0; int offset = 0;
@ -510,8 +510,8 @@ static int BackwardReferencesHashChainDistanceOnly(
// We loop one pixel at a time, but store all currently best points to // We loop one pixel at a time, but store all currently best points to
// non-processed locations from this point. // non-processed locations from this point.
dist_array[0] = 0; dist_array[0] = 0;
GetParamsForHashChainFindCopy(quality, xsize, &window_size, &iter_pos, GetParamsForHashChainFindCopy(quality, xsize, cache_bits,
&iter_limit); &window_size, &iter_pos, &iter_limit);
for (i = 0; i < pix_count; ++i) { for (i = 0; i < pix_count; ++i) {
double prev_cost = 0.0; double prev_cost = 0.0;
int shortmax; int shortmax;
@ -645,8 +645,8 @@ static int BackwardReferencesHashChainFollowChosenPath(
} }
refs->size = 0; refs->size = 0;
GetParamsForHashChainFindCopy(quality, xsize, &window_size, &iter_pos, GetParamsForHashChainFindCopy(quality, xsize, cache_bits,
&iter_limit); &window_size, &iter_pos, &iter_limit);
for (ix = 0; ix < chosen_path_size; ++ix, ++size) { for (ix = 0; ix < chosen_path_size; ++ix, ++size) {
int offset = 0; int offset = 0;
int len = 0; int len = 0;
@ -785,7 +785,9 @@ int VP8LGetBackwardReferences(int width, int height,
*best = refs_lz77; // default guess: lz77 is better *best = refs_lz77; // default guess: lz77 is better
VP8LClearBackwardRefs(&refs_rle); VP8LClearBackwardRefs(&refs_rle);
if (try_lz77_trace_backwards) { if (try_lz77_trace_backwards) {
const int recursion_level = (num_pix < 320 * 200) ? 1 : 0; // Set recursion level for large images using a color cache.
const int recursion_level =
(num_pix < 320 * 200) && (cache_bits > 0) ? 1 : 0;
VP8LBackwardRefs refs_trace; VP8LBackwardRefs refs_trace;
if (!VP8LBackwardRefsAlloc(&refs_trace, num_pix)) { if (!VP8LBackwardRefsAlloc(&refs_trace, num_pix)) {
goto End; goto End;

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Author: Jyrki Alakuijala (jyrki@google.com) // Author: Jyrki Alakuijala (jyrki@google.com)

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Coding tools configuration // Coding tools configuration

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Cost tables for level and modes // Cost tables for level and modes

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Cost tables for level and modes. // Cost tables for level and modes.

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Selecting filter level // Selecting filter level

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// frame coding and analysis // frame coding and analysis

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Author: Jyrki Alakuijala (jyrki@google.com) // Author: Jyrki Alakuijala (jyrki@google.com)

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Author: Jyrki Alakuijala (jyrki@google.com) // Author: Jyrki Alakuijala (jyrki@google.com)

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// VP8Iterator: block iterator // VP8Iterator: block iterator

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Enhancement layer (for YUV444/422) // Enhancement layer (for YUV444/422)

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// WebPPicture utils: colorspace conversion, crop, ... // WebPPicture utils: colorspace conversion, crop, ...
@ -709,7 +711,7 @@ static int Import(WebPPicture* const picture,
for (y = 0; y < height; ++y) { for (y = 0; y < height; ++y) {
for (x = 0; x < width; ++x) { for (x = 0; x < width; ++x) {
const int offset = step * x + y * rgb_stride; const int offset = step * x + y * rgb_stride;
const uint32_t argb = (a_ptr[offset] << 24) | const uint32_t argb = ((uint32_t)a_ptr[offset] << 24) |
(r_ptr[offset] << 16) | (r_ptr[offset] << 16) |
(g_ptr[offset] << 8) | (g_ptr[offset] << 8) |
(b_ptr[offset]); (b_ptr[offset]);
@ -809,7 +811,7 @@ int WebPPictureYUVAToARGB(WebPPicture* picture) {
const uint8_t* const src = picture->a + y * picture->a_stride; const uint8_t* const src = picture->a + y * picture->a_stride;
int x; int x;
for (x = 0; x < width; ++x) { for (x = 0; x < width; ++x) {
argb_dst[x] = (argb_dst[x] & 0x00ffffffu) | (src[x] << 24); argb_dst[x] = (argb_dst[x] & 0x00ffffffu) | ((uint32_t)src[x] << 24);
} }
} }
} }

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Quantization // Quantization

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Header syntax writing // Header syntax writing

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Paginated token buffer // Paginated token buffer

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Token probabilities // Token probabilities

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// WebP encoder: internal header. // WebP encoder: internal header.
@ -28,7 +30,7 @@ extern "C" {
// version numbers // version numbers
#define ENC_MAJ_VERSION 0 #define ENC_MAJ_VERSION 0
#define ENC_MIN_VERSION 3 #define ENC_MIN_VERSION 3
#define ENC_REV_VERSION 0 #define ENC_REV_VERSION 1
// intra prediction modes // intra prediction modes
enum { B_DC_PRED = 0, // 4x4 modes enum { B_DC_PRED = 0, // 4x4 modes

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// main entry for the lossless encoder. // main entry for the lossless encoder.
@ -86,7 +88,7 @@ static int AnalyzeAndCreatePalette(const WebPPicture* const pic,
argb += pic->argb_stride; argb += pic->argb_stride;
} }
// TODO(skal): could we reuse in_use[] to speed up ApplyPalette()? // TODO(skal): could we reuse in_use[] to speed up EncodePalette()?
num_colors = 0; num_colors = 0;
for (i = 0; i < (int)(sizeof(in_use) / sizeof(in_use[0])); ++i) { for (i = 0; i < (int)(sizeof(in_use) / sizeof(in_use[0])); ++i) {
if (in_use[i]) { if (in_use[i]) {
@ -811,34 +813,66 @@ static WebPEncodingError AllocateTransformBuffer(VP8LEncoder* const enc,
return err; return err;
} }
// Bundles multiple (1, 2, 4 or 8) pixels into a single pixel. static void ApplyPalette(uint32_t* src, uint32_t* dst,
static void BundleColorMap(const uint8_t* const row, int width, uint32_t src_stride, uint32_t dst_stride,
int xbits, uint32_t* const dst) { const uint32_t* palette, int palette_size,
int x; int width, int height, int xbits, uint8_t* row) {
if (xbits > 0) { int i, x, y;
const int bit_depth = 1 << (3 - xbits); int use_LUT = 1;
const int mask = (1 << xbits) - 1; for (i = 0; i < palette_size; ++i) {
uint32_t code = 0xff000000; if ((palette[i] & 0xffff00ffu) != 0) {
for (x = 0; x < width; ++x) { use_LUT = 0;
const int xsub = x & mask; break;
if (xsub == 0) { }
code = 0xff000000; }
if (use_LUT) {
int inv_palette[MAX_PALETTE_SIZE] = { 0 };
for (i = 0; i < palette_size; ++i) {
const int color = (palette[i] >> 8) & 0xff;
inv_palette[color] = i;
}
for (y = 0; y < height; ++y) {
for (x = 0; x < width; ++x) {
const int color = (src[x] >> 8) & 0xff;
row[x] = inv_palette[color];
} }
code |= row[x] << (8 + bit_depth * xsub); VP8LBundleColorMap(row, width, xbits, dst);
dst[x >> xbits] = code; src += src_stride;
dst += dst_stride;
} }
} else { } else {
for (x = 0; x < width; ++x) dst[x] = 0xff000000 | (row[x] << 8); // Use 1 pixel cache for ARGB pixels.
uint32_t last_pix = palette[0];
int last_idx = 0;
for (y = 0; y < height; ++y) {
for (x = 0; x < width; ++x) {
const uint32_t pix = src[x];
if (pix != last_pix) {
for (i = 0; i < palette_size; ++i) {
if (pix == palette[i]) {
last_idx = i;
last_pix = pix;
break;
}
}
}
row[x] = last_idx;
}
VP8LBundleColorMap(row, width, xbits, dst);
src += src_stride;
dst += dst_stride;
}
} }
} }
// Note: Expects "enc->palette_" to be set properly. // Note: Expects "enc->palette_" to be set properly.
// Also, "enc->palette_" will be modified after this call and should not be used // Also, "enc->palette_" will be modified after this call and should not be used
// later. // later.
static WebPEncodingError ApplyPalette(VP8LBitWriter* const bw, static WebPEncodingError EncodePalette(VP8LBitWriter* const bw,
VP8LEncoder* const enc, int quality) { VP8LEncoder* const enc, int quality) {
WebPEncodingError err = VP8_ENC_OK; WebPEncodingError err = VP8_ENC_OK;
int i, x, y; int i;
const WebPPicture* const pic = enc->pic_; const WebPPicture* const pic = enc->pic_;
uint32_t* src = pic->argb; uint32_t* src = pic->argb;
uint32_t* dst; uint32_t* dst;
@ -864,20 +898,8 @@ static WebPEncodingError ApplyPalette(VP8LBitWriter* const bw,
row = WebPSafeMalloc((uint64_t)width, sizeof(*row)); row = WebPSafeMalloc((uint64_t)width, sizeof(*row));
if (row == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY; if (row == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY;
for (y = 0; y < height; ++y) { ApplyPalette(src, dst, pic->argb_stride, enc->current_width_,
for (x = 0; x < width; ++x) { palette, palette_size, width, height, xbits, row);
const uint32_t pix = src[x];
for (i = 0; i < palette_size; ++i) {
if (pix == palette[i]) {
row[x] = i;
break;
}
}
}
BundleColorMap(row, width, xbits, dst);
src += pic->argb_stride;
dst += enc->current_width_;
}
// Save palette to bitstream. // Save palette to bitstream.
VP8LWriteBits(bw, 1, TRANSFORM_PRESENT); VP8LWriteBits(bw, 1, TRANSFORM_PRESENT);
@ -899,13 +921,10 @@ static WebPEncodingError ApplyPalette(VP8LBitWriter* const bw,
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
static int GetHistoBits(const WebPConfig* const config, static int GetHistoBits(int method, int use_palette, int width, int height) {
const WebPPicture* const pic) {
const int width = pic->width;
const int height = pic->height;
const uint64_t hist_size = sizeof(VP8LHistogram); const uint64_t hist_size = sizeof(VP8LHistogram);
// Make tile size a function of encoding method (Range: 0 to 6). // Make tile size a function of encoding method (Range: 0 to 6).
int histo_bits = 7 - config->method; int histo_bits = (use_palette ? 9 : 7) - method;
while (1) { while (1) {
const uint64_t huff_image_size = VP8LSubSampleSize(width, histo_bits) * const uint64_t huff_image_size = VP8LSubSampleSize(width, histo_bits) *
VP8LSubSampleSize(height, histo_bits) * VP8LSubSampleSize(height, histo_bits) *
@ -917,13 +936,14 @@ static int GetHistoBits(const WebPConfig* const config,
(histo_bits > MAX_HUFFMAN_BITS) ? MAX_HUFFMAN_BITS : histo_bits; (histo_bits > MAX_HUFFMAN_BITS) ? MAX_HUFFMAN_BITS : histo_bits;
} }
static void InitEncParams(VP8LEncoder* const enc) { static void FinishEncParams(VP8LEncoder* const enc) {
const WebPConfig* const config = enc->config_; const WebPConfig* const config = enc->config_;
const WebPPicture* const picture = enc->pic_; const WebPPicture* const pic = enc->pic_;
const int method = config->method; const int method = config->method;
const float quality = config->quality; const float quality = config->quality;
const int use_palette = enc->use_palette_;
enc->transform_bits_ = (method < 4) ? 5 : (method > 4) ? 3 : 4; enc->transform_bits_ = (method < 4) ? 5 : (method > 4) ? 3 : 4;
enc->histo_bits_ = GetHistoBits(config, picture); enc->histo_bits_ = GetHistoBits(method, use_palette, pic->width, pic->height);
enc->cache_bits_ = (quality <= 25.f) ? 0 : 7; enc->cache_bits_ = (quality <= 25.f) ? 0 : 7;
} }
@ -965,8 +985,6 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
goto Error; goto Error;
} }
InitEncParams(enc);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Analyze image (entropy, num_palettes etc) // Analyze image (entropy, num_palettes etc)
@ -975,8 +993,10 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
goto Error; goto Error;
} }
FinishEncParams(enc);
if (enc->use_palette_) { if (enc->use_palette_) {
err = ApplyPalette(bw, enc, quality); err = EncodePalette(bw, enc, quality);
if (err != VP8_ENC_OK) goto Error; if (err != VP8_ENC_OK) goto Error;
// Color cache is disabled for palette. // Color cache is disabled for palette.
enc->cache_bits_ = 0; enc->cache_bits_ = 0;

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Lossless encoder: internal header. // Lossless encoder: internal header.

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// WebP encoder: main entry point // WebP encoder: main entry point
@ -386,9 +388,9 @@ int WebPEncode(const WebPConfig* config, WebPPicture* pic) {
// Analysis is done, proceed to actual coding. // Analysis is done, proceed to actual coding.
ok = ok && VP8EncStartAlpha(enc); // possibly done in parallel ok = ok && VP8EncStartAlpha(enc); // possibly done in parallel
if (!enc->use_tokens_) { if (!enc->use_tokens_) {
ok = VP8EncLoop(enc); ok = ok && VP8EncLoop(enc);
} else { } else {
ok = VP8EncTokenLoop(enc); ok = ok && VP8EncTokenLoop(enc);
} }
ok = ok && VP8EncFinishAlpha(enc); ok = ok && VP8EncFinishAlpha(enc);
#ifdef WEBP_EXPERIMENTAL_FEATURES #ifdef WEBP_EXPERIMENTAL_FEATURES

View File

@ -13,6 +13,6 @@ libwebpmuxinclude_HEADERS += ../webp/mux_types.h
libwebpmuxinclude_HEADERS += ../webp/types.h libwebpmuxinclude_HEADERS += ../webp/types.h
libwebpmux_la_LIBADD = ../libwebp.la libwebpmux_la_LIBADD = ../libwebp.la
libwebpmux_la_LDFLAGS = -no-undefined -version-info 0:0:0 libwebpmux_la_LDFLAGS = -no-undefined -version-info 0:1:0
libwebpmuxincludedir = $(includedir)/webp libwebpmuxincludedir = $(includedir)/webp
pkgconfig_DATA = libwebpmux.pc pkgconfig_DATA = libwebpmux.pc

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Set and delete APIs for mux. // Set and delete APIs for mux.
@ -475,7 +477,7 @@ static WebPMuxError GetImageCanvasWidthHeight(
int64_t image_area = 0; int64_t image_area = 0;
// Aggregate the bounding box for animation frames & fragmented images. // Aggregate the bounding box for animation frames & fragmented images.
for (; wpi != NULL; wpi = wpi->next_) { for (; wpi != NULL; wpi = wpi->next_) {
int x_offset, y_offset, duration, w, h; int x_offset = 0, y_offset = 0, duration = 0, w = 0, h = 0;
const WebPMuxError err = GetImageInfo(wpi, &x_offset, &y_offset, const WebPMuxError err = GetImageInfo(wpi, &x_offset, &y_offset,
&duration, &w, &h); &duration, &w, &h);
const int max_x_pos = x_offset + w; const int max_x_pos = x_offset + w;

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Internal header for mux library. // Internal header for mux library.
@ -26,7 +28,7 @@ extern "C" {
#define MUX_MAJ_VERSION 0 #define MUX_MAJ_VERSION 0
#define MUX_MIN_VERSION 1 #define MUX_MIN_VERSION 1
#define MUX_REV_VERSION 0 #define MUX_REV_VERSION 1
// Chunk object. // Chunk object.
typedef struct WebPChunk WebPChunk; typedef struct WebPChunk WebPChunk;

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Internal objects and utils for mux. // Internal objects and utils for mux.

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Read APIs for mux. // Read APIs for mux.

View File

@ -1,8 +1,10 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Boolean decoder // Boolean decoder

View File

@ -1,8 +1,10 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Boolean decoder // Boolean decoder
@ -194,6 +196,7 @@ static WEBP_INLINE void VP8LoadNewBytes(VP8BitReader* const br) {
#endif #endif
#else // BIG_ENDIAN #else // BIG_ENDIAN
bits = (bit_t)in_bits; bits = (bit_t)in_bits;
if (BITS != 8 * sizeof(bit_t)) bits >>= (8 * sizeof(bit_t) - BITS);
#endif #endif
#ifndef USE_RIGHT_JUSTIFY #ifndef USE_RIGHT_JUSTIFY
br->value_ |= bits << (-br->bits_); br->value_ |= bits << (-br->bits_);

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Bit writing and boolean coder // Bit writing and boolean coder

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Bit writing and boolean coder // Bit writing and boolean coder

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Color Cache for WebP Lossless // Color Cache for WebP Lossless

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Color Cache for WebP Lossless // Color Cache for WebP Lossless

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Spatial prediction using various filters // Spatial prediction using various filters
@ -154,8 +156,7 @@ static void GradientUnfilter(int width, int height, int stride, uint8_t* data) {
#undef SANITY_CHECK #undef SANITY_CHECK
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Quick estimate of a potentially interesting filter mode to try, in addition // Quick estimate of a potentially interesting filter mode to try.
// to the default NONE.
#define SMAX 16 #define SMAX 16
#define SDIFF(a, b) (abs((a) - (b)) >> 4) // Scoring diff, in [0..SMAX) #define SDIFF(a, b) (abs((a) - (b)) >> 4) // Scoring diff, in [0..SMAX)
@ -165,6 +166,7 @@ WEBP_FILTER_TYPE EstimateBestFilter(const uint8_t* data,
int i, j; int i, j;
int bins[WEBP_FILTER_LAST][SMAX]; int bins[WEBP_FILTER_LAST][SMAX];
memset(bins, 0, sizeof(bins)); memset(bins, 0, sizeof(bins));
// We only sample every other pixels. That's enough. // We only sample every other pixels. That's enough.
for (j = 2; j < height - 1; j += 2) { for (j = 2; j < height - 1; j += 2) {
const uint8_t* const p = data + j * stride; const uint8_t* const p = data + j * stride;

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Spatial prediction using various filters // Spatial prediction using various filters

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Utilities for building and looking up Huffman trees. // Utilities for building and looking up Huffman trees.

View File

@ -1,8 +1,10 @@
// Copyright 2012 Google Inc. All Rights Reserved. // Copyright 2012 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Utilities for building and looking up Huffman trees. // Utilities for building and looking up Huffman trees.

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Author: Jyrki Alakuijala (jyrki@google.com) // Author: Jyrki Alakuijala (jyrki@google.com)

View File

@ -1,8 +1,10 @@
// Copyright 2011 Google Inc. All Rights Reserved. // Copyright 2011 Google Inc. All Rights Reserved.
// //
// This code is licensed under the same terms as WebM: // Use of this source code is governed by a BSD-style license
// Software License Agreement: http://www.webmproject.org/license/software/ // that can be found in the COPYING file in the root of the source
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// //
// Author: Jyrki Alakuijala (jyrki@google.com) // Author: Jyrki Alakuijala (jyrki@google.com)

Some files were not shown because too many files have changed in this diff Show More