mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-15 13:29:54 +02:00
Compare commits
57 Commits
v0.3.0
...
v0.3.1-rc2
Author | SHA1 | Date | |
---|---|---|---|
2a04b034f7 | |||
7288950b88 | |||
2e377b53b0 | |||
ad9e42a6fe | |||
825e73b1a6 | |||
abf6f6915f | |||
5a92c1a5e9 | |||
67bc353e6d | |||
38cc011408 | |||
f32097e0df | |||
a2aed1d08c | |||
c7e89cbb02 | |||
a00380d2ed | |||
a94a88dd62 | |||
a71e5d84e9 | |||
8287012ec7 | |||
e190843029 | |||
0b18b9eef6 | |||
db5095d5b6 | |||
850e956f9b | |||
bddd9b0a93 | |||
d573a8d53f | |||
6b931875ac | |||
6fe536f4ba | |||
a2ea46439e | |||
7bb28d2a55 | |||
f036d4bfa6 | |||
8112c8cf54 | |||
cc128e0bfc | |||
07db70d20f | |||
eda8a7dec5 | |||
31f346fe0c | |||
6c76d28e4b | |||
b4f5bb6ca3 | |||
498d4dd634 | |||
26e7244221 | |||
8ecec68652 | |||
e676b04309 | |||
b0ffc43700 | |||
20aa7a8dd5 | |||
b8307cc08b | |||
980e7ae951 | |||
7f25ff99fd | |||
d8e5321144 | |||
11edf5e24b | |||
c7b92184df | |||
7a650c6ad6 | |||
31bea32408 | |||
c22877f70f | |||
5051245f3a | |||
8191decae9 | |||
b9d747351a | |||
5568dbcfe6 | |||
f4c7b6547b | |||
1fb04bec99 | |||
dcbb1ca54a | |||
bc9f5fbe0f |
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,8 +1,9 @@
|
||||
*.l[ao]
|
||||
*.o
|
||||
*.[ao]
|
||||
.deps
|
||||
.libs
|
||||
/aclocal.m4
|
||||
/ar-lib
|
||||
/autom4te.cache
|
||||
/compile
|
||||
/config.*
|
||||
@ -16,7 +17,9 @@
|
||||
/stamp-h1
|
||||
Makefile
|
||||
Makefile.in
|
||||
examples/[cd]webp
|
||||
examples/[cdv]webp
|
||||
examples/gif2webp
|
||||
examples/webpmux
|
||||
/output
|
||||
/doc/output
|
||||
*.idb
|
||||
|
1
AUTHORS
1
AUTHORS
@ -1,4 +1,5 @@
|
||||
Contributors:
|
||||
- Christian Duvivier (cduvivier at google dot com)
|
||||
- James Zern (jzern at google dot com)
|
||||
- Jan Engelhardt (jengelh at medozas dot de)
|
||||
- Johann (johann dot koenig at duck dot com)
|
||||
|
71
ChangeLog
71
ChangeLog
@ -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
|
||||
6cb4a61 misc style fix
|
||||
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
|
||||
04c7a2e vwebp/animation: fix background dispose
|
||||
81a5069 Makefile.vc: fix dynamic builds
|
||||
5f25c39 update ChangeLog
|
||||
5f25c39 update ChangeLog (tag: v0.3.0-rc6)
|
||||
14d42af examples: don't use C99 %zu
|
||||
5ccf1fe update ChangeLog
|
||||
2560c24 update NEWS
|
||||
@ -324,7 +381,7 @@ a61a824 Merge "Add NULL check in chunk APIs"
|
||||
a077072 mux struct naming
|
||||
6c66dde Merge "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:
|
||||
3bb4bbe Merge "Mux API change:"
|
||||
d0c79f0 Mux API change:
|
||||
@ -394,7 +451,7 @@ c7eb457 make VP8DspInitNEON() public
|
||||
ab3234a Create WebPMuxFrameInfo struct for Mux APIs
|
||||
e3990fd Alignment fixes
|
||||
e55fbd6 Merge branch '0.2.0'
|
||||
4238bc0 Update ChangeLog (v0.2.0)
|
||||
4238bc0 Update ChangeLog (tag: v0.2.0)
|
||||
c655380 dec/io.c: cosmetics
|
||||
fe1958f RGBA4444: harmonize lossless/lossy alpha values
|
||||
681cb30 fix RGBA4444 output w/fancy upsampling
|
||||
@ -405,7 +462,7 @@ f56e98f Alignment fix
|
||||
a0a4885 Lossless decoder fix for a special transform order
|
||||
62dd9bb Update encoding heuristic w.r.t palette colors.
|
||||
6f4272b remove unused ApplyInverseTransform()
|
||||
93bf0fa Update ChangeLog (v0.2.0-rc1)
|
||||
93bf0fa Update ChangeLog (tag: v0.2.0-rc1)
|
||||
5934fc5 update AUTHORS
|
||||
014a711 update NEWS
|
||||
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
|
||||
d919ed0 dwebp: add PAM output support
|
||||
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
|
||||
efc826e add extra precision about default values and behaviour
|
||||
9f29635 header/doc clean up
|
||||
@ -1073,7 +1130,7 @@ f3bf4c7 Added Mux Container Spec & README for MUX-API.
|
||||
9f761cf Changed function signature for WebPMuxCreate
|
||||
5f31b5e Merge "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
|
||||
28ad70c Fix PNG decoding bug
|
||||
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.
|
||||
ca55413 fix WebPIDecGetRGB() to accept any RGB(A) mode, not just MODE_RGB
|
||||
8aa50ef fix some 'man' typos
|
||||
d3f3bdd update ChangeLog (v0.1.2)
|
||||
d3f3bdd update ChangeLog (tag: v0.1.2)
|
||||
d7e9a69 update contributor list
|
||||
261abb8 add a 'superclean' section
|
||||
276ae82 Remove files not mean to be in git, and update .gitignore
|
||||
|
28
Makefile.vc
28
Makefile.vc
@ -24,18 +24,18 @@ PLATFORM_LDFLAGS = /SAFESEH
|
||||
#############################################################
|
||||
## Nothing more to do below this line!
|
||||
|
||||
MT = mt.exe
|
||||
CCNODBG = cl.exe /nologo /O2 /DNDEBUG
|
||||
CCDEBUG = cl.exe /nologo /Od /Gm /Zi /D_DEBUG /RTC1
|
||||
CFLAGS = /Isrc /nologo /W3 /EHsc /FD /c /GS
|
||||
NOLOGO = /nologo
|
||||
CCNODBG = cl.exe $(NOLOGO) /O2 /DNDEBUG
|
||||
CCDEBUG = cl.exe $(NOLOGO) /Od /Gm /Zi /D_DEBUG /RTC1
|
||||
CFLAGS = /Isrc $(NOLOGO) /W3 /EHsc /c /GS
|
||||
CFLAGS = $(CFLAGS) /DWIN32 /D_CRT_SECURE_NO_WARNINGS /DWIN32_LEAN_AND_MEAN
|
||||
CFLAGS = $(CFLAGS) /DHAVE_WINCODEC_H /DWEBP_USE_THREAD
|
||||
LDFLAGS = /LARGEADDRESSAWARE /MANIFEST /NXCOMPAT /DYNAMICBASE
|
||||
LDFLAGS = $(LDFLAGS) $(PLATFORM_LDFLAGS)
|
||||
LNKDLL = link.exe /DLL
|
||||
LNKLIB = link.exe /lib
|
||||
LNKEXE = link.exe
|
||||
LFLAGS = /nologo /machine:$(ARCH)
|
||||
LNKDLL = link.exe /DLL $(NOLOGO)
|
||||
LNKEXE = link.exe $(NOLOGO)
|
||||
LNKLIB = lib.exe $(NOLOGO)
|
||||
MT = mt.exe $(NOLOGO)
|
||||
|
||||
CFGSET = FALSE
|
||||
!IF "$(OBJDIR)" == ""
|
||||
@ -108,7 +108,7 @@ CC = $(CC) /I$(DIROBJ) /FI$(DLLINC) $(RTLIB) /DWEBP_DLL
|
||||
LIBWEBPDECODER = $(DIRLIB)\$(LIBWEBPDECODER_BASENAME)_dll.lib
|
||||
LIBWEBP = $(DIRLIB)\$(LIBWEBP_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
|
||||
CFGSET = TRUE
|
||||
!ENDIF
|
||||
@ -130,7 +130,8 @@ CFGSET = TRUE
|
||||
!MESSAGE - clean - perform a clean for CFG
|
||||
!MESSAGE - experimental - build CFG with experimental
|
||||
!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 RTLIBCFG controls the runtime library linkage - 'static' or 'dynamic'.
|
||||
!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_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)\dwebp.exe: $(DIROBJ)\examples\dwebp.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: $(EX_UTIL_OBJS) $(LIBWEBP)
|
||||
$(OUT_EXAMPLES): $(EX_UTIL_OBJS) $(LIBWEBP)
|
||||
$(EX_UTIL_OBJS) $(EX_FORMAT_DEC_OBJS): $(OUTPUT_DIRS)
|
||||
|
||||
experimental:
|
||||
$(MAKE) /f Makefile.vc \
|
||||
@ -278,7 +282,7 @@ clean::
|
||||
@-erase /s $(DIROBJ)\$(DLLC) $(DIROBJ)\$(DLLINC) 2> NUL
|
||||
!ELSE
|
||||
$(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX):
|
||||
$(LNKLIB) /out:$@ $(LFLAGS) $**
|
||||
$(LNKLIB) /out:$@ $**
|
||||
-xcopy $(DIROBJ)\*.pdb $(DIRLIB) /y
|
||||
!ENDIF
|
||||
|
||||
|
6
NEWS
6
NEWS
@ -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
|
||||
This is a binary compatible release.
|
||||
* WebPINewRGB/WebPINewYUVA accept being passed a NULL output buffer
|
||||
|
14
README
14
README
@ -4,7 +4,7 @@
|
||||
\__\__/\____/\_____/__/ ____ ___
|
||||
/ _/ / \ \ / _ \/ _/
|
||||
/ \_/ / / \ \ __/ \__
|
||||
\____/____/\_____/_____/____/v0.3.0
|
||||
\____/____/\_____/_____/____/v0.3.1
|
||||
|
||||
Description:
|
||||
============
|
||||
@ -80,8 +80,8 @@ more options.
|
||||
SWIG bindings:
|
||||
--------------
|
||||
|
||||
To generate language bindings from swig/libwebp.i swig-1.3
|
||||
(http://www.swig.org) is required. 2.0 may work, but has not been tested.
|
||||
To generate language bindings from swig/libwebp.i at least swig-1.3
|
||||
(http://www.swig.org) is required.
|
||||
|
||||
Currently the following functions are mapped:
|
||||
Decode:
|
||||
@ -104,12 +104,20 @@ Encode:
|
||||
WebPEncodeLosslessRGB
|
||||
WebPEncodeLosslessBGR
|
||||
|
||||
See swig/README for more detailed build instructions.
|
||||
|
||||
Java bindings:
|
||||
|
||||
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 /
|
||||
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:
|
||||
==============
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
__ __ ____ ____ ____ __ __ _ __ __
|
||||
/ \\/ \/ _ \/ _ \/ _ \/ \ \/ \___/_ / _\
|
||||
\ / __/ _ \ __/ / / (_/ /__
|
||||
\__\__/\_____/_____/__/ \__//_/\_____/__/___/v0.1.0
|
||||
\__\__/\_____/_____/__/ \__//_/\_____/__/___/v0.1.1
|
||||
|
||||
|
||||
Description:
|
||||
|
236
configure.ac
236
configure.ac
@ -1,19 +1,67 @@
|
||||
AC_INIT([libwebp], [0.3.0],
|
||||
AC_INIT([libwebp], [0.3.1],
|
||||
[http://code.google.com/p/webp/issues],,
|
||||
[http://developers.google.com/speed/webp])
|
||||
AC_CANONICAL_TARGET
|
||||
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
|
||||
AM_PROG_CC_C_O
|
||||
|
||||
dnl === Enable less verbose output when building.
|
||||
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],
|
||||
[Path to the pkgconfig directory @<:@LIBDIR/pkgconfig@:>@]),
|
||||
[pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig'])
|
||||
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 === Defines --with-<opt_pfx>{include,lib}dir options which set
|
||||
dnl === the variables <outvar_pfx>_{INCLUDES,LIBS}.
|
||||
@ -27,6 +75,24 @@ AC_DEFUN([WITHLIB_OPTION],
|
||||
[use $2 libraries from DIR]),
|
||||
[$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
|
||||
AC_ARG_ENABLE([threading],
|
||||
AS_HELP_STRING([--disable-threading],
|
||||
@ -44,10 +110,108 @@ if test "$enable_threading" = "yes"; then
|
||||
fi
|
||||
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 ===
|
||||
|
||||
PNG_INCLUDES=""
|
||||
PNG_LIBS=""
|
||||
CLEAR_LIBVARS([PNG])
|
||||
AC_PATH_PROGS(LIBPNG_CONFIG,
|
||||
[libpng-config libpng15-config libpng14-config libpng12-config])
|
||||
if test -n "$LIBPNG_CONFIG"; then
|
||||
@ -61,11 +225,7 @@ fi
|
||||
|
||||
WITHLIB_OPTION([png], [PNG])
|
||||
|
||||
SAVED_CPPFLAGS=$CPPFLAGS
|
||||
SAVED_LIBS=$LIBS
|
||||
CPPFLAGS="$PNG_INCLUDES $CPPFLAGS"
|
||||
LIBS="$PNG_LIBS $LIBS"
|
||||
|
||||
LIBCHECK_PROLOGUE([PNG])
|
||||
AC_CHECK_HEADER(png.h,
|
||||
AC_SEARCH_LIBS(png_get_libpng_ver, [png],
|
||||
[test "$ac_cv_search_png_get_libpng_ver" = "none required" \
|
||||
@ -85,23 +245,14 @@ AC_CHECK_HEADER(png.h,
|
||||
PNG_INCLUDES=""
|
||||
],
|
||||
)
|
||||
AC_SUBST(PNG_LIBS)
|
||||
AC_SUBST(PNG_INCLUDES)
|
||||
|
||||
CPPFLAGS=$SAVED_CPPFLAGS
|
||||
LIBS=$SAVED_LIBS
|
||||
LIBCHECK_EPILOGUE([PNG])
|
||||
|
||||
dnl === check for JPEG support ===
|
||||
|
||||
JPEG_INCLUDES=""
|
||||
JPEG_LIBS=""
|
||||
CLEAR_LIBVARS([JPEG])
|
||||
WITHLIB_OPTION([jpeg], [JPEG])
|
||||
|
||||
SAVED_CPPFLAGS=$CPPFLAGS
|
||||
SAVED_LIBS=$LIBS
|
||||
CPPFLAGS="$JPEG_INCLUDES $CPPFLAGS"
|
||||
LIBS="$JPEG_LIBS $LIBS"
|
||||
|
||||
LIBCHECK_PROLOGUE([JPEG])
|
||||
AC_CHECK_HEADER(jpeglib.h,
|
||||
AC_CHECK_LIB(jpeg, jpeg_set_defaults,
|
||||
[JPEG_LIBS="$JPEG_LIBS -ljpeg"
|
||||
@ -114,23 +265,14 @@ AC_CHECK_HEADER(jpeglib.h,
|
||||
[$MATH_LIBS]),
|
||||
AC_MSG_WARN(jpeg library not available - no jpeglib.h)
|
||||
)
|
||||
AC_SUBST(JPEG_LIBS)
|
||||
AC_SUBST(JPEG_INCLUDES)
|
||||
|
||||
CPPFLAGS=$SAVED_CPPFLAGS
|
||||
LIBS=$SAVED_LIBS
|
||||
LIBCHECK_EPILOGUE([JPEG])
|
||||
|
||||
dnl === check for TIFF support ===
|
||||
|
||||
TIFF_INCLUDES=""
|
||||
TIFF_LIBS=""
|
||||
CLEAR_LIBVARS([TIFF])
|
||||
WITHLIB_OPTION([tiff], [TIFF])
|
||||
|
||||
SAVED_CPPFLAGS=$CPPFLAGS
|
||||
SAVED_LIBS=$LIBS
|
||||
CPPFLAGS="$TIFF_INCLUDES $CPPFLAGS"
|
||||
LIBS="$TIFF_LIBS $LIBS"
|
||||
|
||||
LIBCHECK_PROLOGUE([TIFF])
|
||||
AC_CHECK_HEADER(tiffio.h,
|
||||
AC_CHECK_LIB(tiff, TIFFGetVersion,
|
||||
[TIFF_LIBS="$TIFF_LIBS -ltiff"
|
||||
@ -143,23 +285,14 @@ AC_CHECK_HEADER(tiffio.h,
|
||||
[$MATH_LIBS]),
|
||||
AC_MSG_WARN(tiff library not available - no tiffio.h)
|
||||
)
|
||||
AC_SUBST(TIFF_LIBS)
|
||||
AC_SUBST(TIFF_INCLUDES)
|
||||
|
||||
CPPFLAGS=$SAVED_CPPFLAGS
|
||||
LIBS=$SAVED_LIBS
|
||||
LIBCHECK_EPILOGUE([TIFF])
|
||||
|
||||
dnl === check for GIF support ===
|
||||
|
||||
GIF_INCLUDES=""
|
||||
GIF_LIBS=""
|
||||
CLEAR_LIBVARS([GIF])
|
||||
WITHLIB_OPTION([gif], [GIF])
|
||||
|
||||
SAVED_CPPFLAGS=$CPPFLAGS
|
||||
SAVED_LIBS=$LIBS
|
||||
CPPFLAGS="$GIF_INCLUDES $CPPFLAGS"
|
||||
LIBS="$GIF_LIBS $LIBS"
|
||||
|
||||
LIBCHECK_PROLOGUE([GIF])
|
||||
AC_CHECK_HEADER(gif_lib.h,
|
||||
AC_CHECK_LIB([gif], [DGifOpenFileHandle],
|
||||
[GIF_LIBS="$GIF_LIBS -lgif"
|
||||
@ -169,11 +302,7 @@ AC_CHECK_HEADER(gif_lib.h,
|
||||
[$MATH_LIBS]),
|
||||
AC_MSG_WARN(gif library not available - no gif_lib.h)
|
||||
)
|
||||
AC_SUBST(GIF_LIBS)
|
||||
AC_SUBST(GIF_INCLUDES)
|
||||
|
||||
CPPFLAGS=$SAVED_CPPFLAGS
|
||||
LIBS=$SAVED_LIBS
|
||||
LIBCHECK_EPILOGUE([GIF])
|
||||
|
||||
if test "$gif_support" = "yes" -a \
|
||||
"$enable_libwebpmux" = "yes"; then
|
||||
@ -302,18 +431,19 @@ libwebpdemux: ${enable_libwebpdemux-no}
|
||||
libwebpmux: ${enable_libwebpmux-no}
|
||||
|
||||
Tools:
|
||||
cwebp: yes
|
||||
cwebp : yes
|
||||
Input format support
|
||||
====================
|
||||
JPEG : ${jpeg_support-no}
|
||||
PNG : ${png_support-no}
|
||||
TIFF : ${tiff_support-no}
|
||||
WIC : ${wic_support-no}
|
||||
dwebp: yes
|
||||
dwebp : yes
|
||||
Output format support
|
||||
=====================
|
||||
PNG : ${png_support-no}
|
||||
WIC : ${wic_support-no}
|
||||
gif2webp: ${build_gif2webp-no}
|
||||
webpmux: ${enable_libwebpmux-no}
|
||||
gif2webp : ${build_gif2webp-no}
|
||||
webpmux : ${enable_libwebpmux-no}
|
||||
vwebp : ${build_vwebp-no}
|
||||
])
|
||||
|
@ -1,6 +1,9 @@
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src
|
||||
|
||||
bin_PROGRAMS = dwebp cwebp
|
||||
if BUILD_VWEBP
|
||||
bin_PROGRAMS += vwebp
|
||||
endif
|
||||
if WANT_MUX
|
||||
bin_PROGRAMS += webpmux
|
||||
endif
|
||||
@ -18,12 +21,6 @@ dwebp_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE)
|
||||
dwebp_CPPFLAGS += $(JPEG_INCLUDES) $(PNG_INCLUDES)
|
||||
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 += jpegdec.c jpegdec.h
|
||||
cwebp_SOURCES += pngdec.c pngdec.h
|
||||
@ -41,3 +38,15 @@ gif2webp_LDADD += $(GIF_LIBS)
|
||||
webpmux_SOURCES = webpmux.c
|
||||
webpmux_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE)
|
||||
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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -109,15 +111,15 @@ typedef enum {
|
||||
|
||||
static InputFileFormat GetImageType(FILE* in_file) {
|
||||
InputFileFormat format = UNSUPPORTED;
|
||||
unsigned int magic;
|
||||
unsigned char buf[4];
|
||||
uint32_t magic;
|
||||
uint8_t buf[4];
|
||||
|
||||
if ((fread(&buf[0], 4, 1, in_file) != 1) ||
|
||||
(fseek(in_file, 0, SEEK_SET) != 0)) {
|
||||
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) {
|
||||
format = PNG_;
|
||||
} else if (magic >= 0xFFD8FF00U && magic <= 0xFFD8FFFFU) {
|
||||
|
@ -1,13 +1,13 @@
|
||||
// Copyright 2010 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
//
|
||||
// Compile with: gcc -o dwebp dwebp.c -lwebpdecode
|
||||
// Command-line tool for decoding a WebP image.
|
||||
//
|
||||
// Author: Skal (pascal.massimino@gmail.com)
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,21 +1,14 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
//
|
||||
// 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)
|
||||
// Urvang (urvang@google.com)
|
||||
|
||||
@ -197,8 +190,6 @@ int main(int argc, const char *argv[]) {
|
||||
FILE* out = NULL;
|
||||
GifFileType* gif = NULL;
|
||||
WebPPicture picture;
|
||||
WebPPicture view;
|
||||
WebPMemoryWriter memory;
|
||||
WebPMuxFrameInfo frame;
|
||||
WebPMuxAnimParams anim = { WHITE_COLOR, 0 };
|
||||
|
||||
@ -209,6 +200,8 @@ int main(int argc, const char *argv[]) {
|
||||
WebPConfig config;
|
||||
WebPMux* mux = NULL;
|
||||
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));
|
||||
frame.id = WEBP_CHUNK_ANMF;
|
||||
@ -283,9 +276,7 @@ int main(int argc, const char *argv[]) {
|
||||
picture.width = gif->SWidth;
|
||||
picture.height = gif->SHeight;
|
||||
picture.use_argb = 1;
|
||||
picture.writer = WebPMemoryWrite;
|
||||
picture.custom_ptr = &memory;
|
||||
if (!WebPPictureAlloc(&picture)) goto End;
|
||||
if (!WebPPictureAlloc(&picture)) goto End;
|
||||
|
||||
mux = WebPMuxNew();
|
||||
if (mux == NULL) {
|
||||
@ -301,27 +292,33 @@ int main(int argc, const char *argv[]) {
|
||||
|
||||
switch (type) {
|
||||
case IMAGE_DESC_RECORD_TYPE: {
|
||||
WebPPicture sub_image;
|
||||
WebPMemoryWriter memory;
|
||||
|
||||
if (frame.dispose_method == WEBP_MUX_DISPOSE_BACKGROUND) {
|
||||
ClearPicture(&picture, anim.bgcolor);
|
||||
}
|
||||
|
||||
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) {
|
||||
// We need to call BGRA variant because of the way we do Remap().
|
||||
// TODO(later): This works for little-endian only due to uint32_t to
|
||||
// uint8_t conversion. Make it work for big-endian too.
|
||||
WebPPictureImportBGRA(&view, (uint8_t*)view.argb,
|
||||
view.argb_stride * sizeof(*view.argb));
|
||||
view.use_argb = 0;
|
||||
// We need to call BGRA variant because of the way we do Remap(). Note
|
||||
// that 'sub_image' will no longer be a view and own some memory.
|
||||
WebPPictureImportBGRA(
|
||||
&sub_image, (uint8_t*)sub_image.argb,
|
||||
sub_image.argb_stride * sizeof(*sub_image.argb));
|
||||
sub_image.use_argb = 0;
|
||||
} 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 code: %d\n", view.error_code);
|
||||
fprintf(stderr, "Error code: %d\n", sub_image.error_code);
|
||||
goto End;
|
||||
}
|
||||
|
||||
@ -340,12 +337,14 @@ int main(int argc, const char *argv[]) {
|
||||
}
|
||||
if (verbose) {
|
||||
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);
|
||||
printf("dispose:%d transparent index:%d\n",
|
||||
frame.dispose_method, transparent_index);
|
||||
}
|
||||
WebPDataClear(&frame.bitstream);
|
||||
WebPPictureFree(&sub_image);
|
||||
break;
|
||||
}
|
||||
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
|
||||
anim.loop_count = data[2] | (data[3] << 8);
|
||||
if (verbose) printf("Loop count: %d\n", anim.loop_count);
|
||||
} else if (!memcmp(data + 1, "XMP dataXMP", 11)) {
|
||||
// Read XMP metadata.
|
||||
WebPData xmp;
|
||||
if (DGifGetExtensionNext(gif, &data) == GIF_ERROR) goto End;
|
||||
if (data == NULL) goto End;
|
||||
xmp.bytes = (uint8_t*)data;
|
||||
xmp.size = data[0] + 1;
|
||||
WebPMuxSetChunk(mux, "XMP ", &xmp, 1);
|
||||
if (verbose) printf("XMP size: %d\n", (int)xmp.size);
|
||||
} else if (!memcmp(data + 1, "ICCRGBG1012", 11)) {
|
||||
// Read ICC profile.
|
||||
WebPData icc;
|
||||
if (DGifGetExtensionNext(gif, &data) == GIF_ERROR) goto End;
|
||||
if (data == NULL) goto End;
|
||||
icc.bytes = (uint8_t*)data;
|
||||
icc.size = data[0] + 1;
|
||||
WebPMuxSetChunk(mux, "ICCP", &icc, 1);
|
||||
if (verbose) printf("ICC size: %d\n", (int)icc.size);
|
||||
} else { // An extension containing metadata.
|
||||
// We only store the first encountered chunk of each type.
|
||||
const int is_xmp =
|
||||
!stored_xmp && !memcmp(data + 1, "XMP DataXMP", 11);
|
||||
const int is_icc =
|
||||
!stored_icc && !memcmp(data + 1, "ICCRGBG1012", 11);
|
||||
if (is_xmp || is_icc) {
|
||||
const char* const fourccs[2] = { "XMP " , "ICCP" };
|
||||
const char* const features[2] = { "XMP" , "ICC" };
|
||||
WebPData metadata = { NULL, 0 };
|
||||
// Construct metadata from sub-blocks.
|
||||
// Usual case (including ICC profile): In each sub-block, the
|
||||
// first byte specifies its size in bytes (0 to 255) and the
|
||||
// rest of the bytes contain the data.
|
||||
// Special case for XMP data: In each sub-block, the first byte
|
||||
// is also part of the XMP payload. XMP in GIF also has a 257
|
||||
// byte padding data. See the XMP specification for details.
|
||||
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;
|
||||
}
|
||||
@ -423,9 +468,9 @@ int main(int argc, const char *argv[]) {
|
||||
break; // skip
|
||||
}
|
||||
}
|
||||
do {
|
||||
while (data != NULL) {
|
||||
if (DGifGetExtensionNext(gif, &data) == GIF_ERROR) goto End;
|
||||
} while (data != NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TERMINATE_RECORD_TYPE: {
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -108,6 +110,8 @@ static const struct {
|
||||
// See also: ExifTool on CPAN.
|
||||
{ "Raw profile type exif", ProcessRawProfile, METADATA_OFFSET(exif) },
|
||||
{ "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
|
||||
{ "XML:com.adobe.xmp", MetadataCopy, METADATA_OFFSET(xmp) },
|
||||
{ NULL, NULL, 0 },
|
||||
@ -207,7 +211,6 @@ int ReadPNG(FILE* in_file, WebPPicture* const pic, int keep_alpha,
|
||||
Error:
|
||||
MetadataFree(metadata);
|
||||
png_destroy_read_struct(&png, &info, &end_info);
|
||||
free(rgb);
|
||||
goto End;
|
||||
}
|
||||
|
||||
@ -269,13 +272,13 @@ int ReadPNG(FILE* in_file, WebPPicture* const pic, int keep_alpha,
|
||||
pic->height = height;
|
||||
ok = has_alpha ? WebPPictureImportRGBA(pic, rgb, stride)
|
||||
: WebPPictureImportRGB(pic, rgb, stride);
|
||||
free(rgb);
|
||||
|
||||
if (!ok) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
End:
|
||||
free(rgb);
|
||||
return ok;
|
||||
}
|
||||
#else // !WEBP_HAVE_PNG
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,25 +1,24 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
//
|
||||
// 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
|
||||
// Simple OpenGL-based WebP file viewer.
|
||||
//
|
||||
// Author: Skal (pascal.massimino@gmail.com)
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined(HAVE_GLUT_GLUT_H)
|
||||
#include <GLUT/glut.h>
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
@ -437,6 +436,11 @@ int main(int argc, char *argv[]) {
|
||||
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);
|
||||
if (kParams.dmux == NULL) {
|
||||
fprintf(stderr, "Could not create demuxing object!\n");
|
||||
|
@ -1,16 +1,15 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
// relevant data from the container file.
|
||||
//
|
||||
// Compile with: gcc -o webpmux webpmux.c -lwebpmux -lwebp
|
||||
//
|
||||
//
|
||||
// Authors: Vikas (vikaas.arora@gmail.com),
|
||||
// Urvang (urvang@google.com)
|
||||
|
||||
@ -229,11 +228,13 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) {
|
||||
for (i = 1; i <= nFrames; i++) {
|
||||
WebPMuxFrameInfo frame;
|
||||
err = WebPMuxGetFrame(mux, i, &frame);
|
||||
RETURN_IF_ERROR3("Failed to retrieve %s#%d\n", type_str, i);
|
||||
printf("%3d: %8d %8d ", i, frame.x_offset, frame.y_offset);
|
||||
if (is_anim) printf("%8d %7d ", frame.duration, frame.dispose_method);
|
||||
printf("%10d\n", (int)frame.bitstream.size);
|
||||
if (err == WEBP_MUX_OK) {
|
||||
printf("%3d: %8d %8d ", i, frame.x_offset, frame.y_offset);
|
||||
if (is_anim) printf("%8d %7d ", frame.duration, frame.dispose_method);
|
||||
printf("%10d\n", (int)frame.bitstream.size);
|
||||
}
|
||||
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))) {
|
||||
WebPMuxFrameInfo 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");
|
||||
printf("Size of the image (with alpha): %d\n", (int)image.bitstream.size);
|
||||
}
|
||||
|
||||
return WEBP_MUX_OK;
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -126,7 +128,7 @@ static HRESULT ExtractICCP(IWICImagingFactory* const factory,
|
||||
&size));
|
||||
if (SUCCEEDED(hr) && size != iccp->size) {
|
||||
fprintf(stderr, "Warning! ICC profile size (%u) != expected (%u)\n",
|
||||
size, iccp->size);
|
||||
size, (uint32_t)iccp->size);
|
||||
iccp->size = size;
|
||||
}
|
||||
break;
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -24,6 +24,7 @@ ifeq ($(strip $(shell uname)), Darwin)
|
||||
# cf., src/enc/yuv.[hc]
|
||||
# Failure observed with: gcc 4.2.1 and 4.0.1.
|
||||
EXTRA_FLAGS += -fno-common
|
||||
EXTRA_FLAGS += -DHAVE_GLUT_GLUT_H
|
||||
EXTRA_FLAGS += -I/opt/local/include
|
||||
EXTRA_LIBS += -L/opt/local/lib
|
||||
GL_LIBS = -framework GLUT -framework OpenGL
|
||||
|
@ -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
|
||||
# not have unresolved symbols. Some platforms (Windows among them) require all
|
||||
# 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
|
||||
pkgconfig_DATA = libwebp.pc
|
||||
|
||||
@ -48,7 +48,7 @@ if BUILD_LIBWEBPDECODER
|
||||
libwebpdecoder_la_LIBADD += dsp/libwebpdspdecode.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
|
||||
endif
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -20,20 +22,10 @@
|
||||
extern "C" {
|
||||
#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'.
|
||||
// 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
|
||||
// 0 if either:
|
||||
@ -41,16 +33,16 @@ static void CopyPlane(const uint8_t* src, int src_stride,
|
||||
// error returned by appropriate compression method.
|
||||
|
||||
static int DecodeAlpha(const uint8_t* data, size_t data_size,
|
||||
int width, int height, int stride, uint8_t* output) {
|
||||
uint8_t* decoded_data = NULL;
|
||||
const size_t decoded_size = height * width;
|
||||
int width, int height, uint8_t* output) {
|
||||
WEBP_FILTER_TYPE filter;
|
||||
int pre_processing;
|
||||
int rsrv;
|
||||
int ok = 0;
|
||||
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);
|
||||
|
||||
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) {
|
||||
ok = (data_size >= decoded_size);
|
||||
decoded_data = (uint8_t*)data + ALPHA_HEADER_LEN;
|
||||
const size_t alpha_decoded_size = height * width;
|
||||
ok = (alpha_data_size >= alpha_decoded_size);
|
||||
if (ok) memcpy(output, alpha_data, alpha_decoded_size);
|
||||
} else {
|
||||
decoded_data = (uint8_t*)malloc(decoded_size);
|
||||
if (decoded_data == NULL) return 0;
|
||||
ok = VP8LDecodeAlphaImageStream(width, height,
|
||||
data + ALPHA_HEADER_LEN,
|
||||
data_size - ALPHA_HEADER_LEN,
|
||||
decoded_data);
|
||||
ok = VP8LDecodeAlphaImageStream(width, height, alpha_data, alpha_data_size,
|
||||
output);
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
@ -86,18 +75,13 @@ static int DecodeAlpha(const uint8_t* data, size_t data_size,
|
||||
if (unfilter_func != NULL) {
|
||||
// TODO(vikas): Implement on-the-fly decoding & filter mechanism to decode
|
||||
// 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) {
|
||||
ok = DequantizeLevels(decoded_data, width, height);
|
||||
ok = DequantizeLevels(output, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
if (method != ALPHA_NO_COMPRESSION) {
|
||||
free(decoded_data);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
@ -105,23 +89,25 @@ static int DecodeAlpha(const uint8_t* data, size_t data_size,
|
||||
|
||||
const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec,
|
||||
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.
|
||||
}
|
||||
|
||||
if (row == 0) {
|
||||
// Decode everything during the first call.
|
||||
assert(!dec->is_alpha_decoded_);
|
||||
if (!DecodeAlpha(dec->alpha_data_, (size_t)dec->alpha_data_size_,
|
||||
dec->pic_hdr_.width_, dec->pic_hdr_.height_, stride,
|
||||
dec->alpha_plane_)) {
|
||||
width, height, dec->alpha_plane_)) {
|
||||
return NULL; // Error.
|
||||
}
|
||||
dec->is_alpha_decoded_ = 1;
|
||||
}
|
||||
|
||||
// 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)
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2010 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2010 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
@ -97,6 +99,23 @@ static WEBP_INLINE size_t MemDataSize(const MemBuffer* mem) {
|
||||
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) {
|
||||
MemBuffer* const mem = &idec->mem_;
|
||||
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);
|
||||
dec->parts_[last_part].buf_end_ = mem->buf_ + mem->end_;
|
||||
if (NeedCompressedAlpha(idec)) dec->alpha_data_ += offset;
|
||||
} else { // Resize lossless bitreader
|
||||
VP8LDecoder* const dec = (VP8LDecoder*)idec->dec_;
|
||||
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.
|
||||
static int AppendToMemBuffer(WebPIDecoder* const idec,
|
||||
const uint8_t* const data, size_t data_size) {
|
||||
VP8Decoder* const dec = (VP8Decoder*)idec->dec_;
|
||||
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);
|
||||
if (data_size > MAX_CHUNK_PAYLOAD) {
|
||||
// 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
|
||||
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 extra_size = (new_size + CHUNK_SIZE - 1) & ~(CHUNK_SIZE - 1);
|
||||
uint8_t* const new_buf =
|
||||
@ -153,7 +178,7 @@ static int AppendToMemBuffer(WebPIDecoder* const idec,
|
||||
free(mem->buf_);
|
||||
mem->buf_ = new_buf;
|
||||
mem->buf_size_ = (size_t)extra_size;
|
||||
mem->start_ = 0;
|
||||
mem->start_ = new_mem_start;
|
||||
mem->end_ = current_size;
|
||||
}
|
||||
|
||||
@ -161,14 +186,15 @@ static int AppendToMemBuffer(WebPIDecoder* const idec,
|
||||
mem->end_ += data_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;
|
||||
}
|
||||
|
||||
static int RemapMemBuffer(WebPIDecoder* const idec,
|
||||
const uint8_t* const data, size_t data_size) {
|
||||
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);
|
||||
|
||||
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->end_ = mem->buf_size_ = data_size;
|
||||
|
||||
DoRemap(idec, mem->buf_ + mem->start_ - old_base);
|
||||
DoRemap(idec, mem->buf_ + mem->start_ - old_start);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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)
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2010 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2010 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2010 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2010 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -28,7 +30,7 @@ extern "C" {
|
||||
// version numbers
|
||||
#define DEC_MAJ_VERSION 0
|
||||
#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
|
||||
|
||||
@ -276,6 +278,7 @@ struct VP8Decoder {
|
||||
// extensions
|
||||
const uint8_t* alpha_data_; // compressed alpha data (if present)
|
||||
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.
|
||||
|
||||
int layer_colorspace_;
|
||||
|
332
src/dec/vp8l.c
332
src/dec/vp8l.c
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
@ -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
|
||||
// last call.
|
||||
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_;
|
||||
|
||||
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_);
|
||||
}
|
||||
|
||||
static int DecodeImageData(VP8LDecoder* const dec,
|
||||
uint32_t* const data, int width, int height,
|
||||
ProcessRowsFunc process_func) {
|
||||
int ok = 1;
|
||||
int col = 0, row = 0;
|
||||
VP8LBitReader* const br = &dec->br_;
|
||||
VP8LMetadata* const hdr = &dec->hdr_;
|
||||
HTreeGroup* htree_group = hdr->htree_groups_;
|
||||
uint32_t* src = data;
|
||||
uint32_t* last_cached = data;
|
||||
uint32_t* const src_end = data + width * height;
|
||||
const int len_code_limit = NUM_LITERAL_CODES + NUM_LENGTH_CODES;
|
||||
const int color_cache_limit = len_code_limit + hdr->color_cache_size_;
|
||||
VP8LColorCache* const color_cache =
|
||||
(hdr->color_cache_size_ > 0) ? &hdr->color_cache_ : NULL;
|
||||
const int mask = hdr->huffman_mask_;
|
||||
|
||||
assert(htree_group != NULL);
|
||||
|
||||
while (!br->eos_ && src < src_end) {
|
||||
int code;
|
||||
// Only update when changing tile. Note we could use the following test:
|
||||
// if "((((prev_col ^ col) | prev_row ^ row)) > mask)" -> tile changed
|
||||
// but that's actually slower and requires storing the previous col/row
|
||||
if ((col & mask) == 0) {
|
||||
htree_group = GetHtreeGroupForPos(hdr, col, row);
|
||||
}
|
||||
VP8LFillBitWindow(br);
|
||||
code = ReadSymbol(&htree_group->htrees_[GREEN], br);
|
||||
if (code < NUM_LITERAL_CODES) { // Literal.
|
||||
int red, green, blue, alpha;
|
||||
red = ReadSymbol(&htree_group->htrees_[RED], br);
|
||||
green = code;
|
||||
VP8LFillBitWindow(br);
|
||||
blue = ReadSymbol(&htree_group->htrees_[BLUE], br);
|
||||
alpha = ReadSymbol(&htree_group->htrees_[ALPHA], br);
|
||||
*src = (alpha << 24) + (red << 16) + (green << 8) + blue;
|
||||
AdvanceByOne:
|
||||
++src;
|
||||
++col;
|
||||
if (col >= width) {
|
||||
col = 0;
|
||||
++row;
|
||||
if ((process_func != NULL) && (row % NUM_ARGB_CACHE_ROWS == 0)) {
|
||||
process_func(dec, row);
|
||||
}
|
||||
if (color_cache != NULL) {
|
||||
while (last_cached < src) {
|
||||
VP8LColorCacheInsert(color_cache, *last_cached++);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (code < len_code_limit) { // Backward reference
|
||||
int dist_code, dist;
|
||||
const int length_sym = code - NUM_LITERAL_CODES;
|
||||
const int length = GetCopyLength(length_sym, br);
|
||||
const int dist_symbol = ReadSymbol(&htree_group->htrees_[DIST], br);
|
||||
VP8LFillBitWindow(br);
|
||||
dist_code = GetCopyDistance(dist_symbol, br);
|
||||
dist = PlaneCodeToDistance(width, dist_code);
|
||||
if (src - data < dist || src_end - src < length) {
|
||||
ok = 0;
|
||||
goto End;
|
||||
}
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < length; ++i) src[i] = src[i - dist];
|
||||
src += length;
|
||||
}
|
||||
col += length;
|
||||
while (col >= width) {
|
||||
col -= width;
|
||||
++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 (color_cache != NULL) {
|
||||
while (last_cached < src) {
|
||||
VP8LColorCacheInsert(color_cache, *last_cached++);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (code < color_cache_limit) { // Color cache.
|
||||
const int key = code - len_code_limit;
|
||||
assert(color_cache != NULL);
|
||||
while (last_cached < src) {
|
||||
VP8LColorCacheInsert(color_cache, *last_cached++);
|
||||
}
|
||||
*src = VP8LColorCacheLookup(color_cache, key);
|
||||
goto AdvanceByOne;
|
||||
} else { // Not reached.
|
||||
ok = 0;
|
||||
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);
|
||||
|
||||
End:
|
||||
if (br->error_ || !ok || (br->eos_ && src < src_end)) {
|
||||
ok = 0;
|
||||
dec->status_ = (!br->eos_) ?
|
||||
VP8_STATUS_BITSTREAM_ERROR : VP8_STATUS_SUSPENDED;
|
||||
} else if (src == src_end) {
|
||||
dec->state_ = READ_DATA;
|
||||
}
|
||||
|
||||
return ok;
|
||||
#define DECODE_DATA_FUNC(FUNC_NAME, TYPE, STORE_PIXEL) \
|
||||
static int FUNC_NAME(VP8LDecoder* const dec, TYPE* const data, int width, \
|
||||
int height, ProcessRowsFunc process_func) { \
|
||||
int ok = 1; \
|
||||
int col = 0, row = 0; \
|
||||
VP8LBitReader* const br = &dec->br_; \
|
||||
VP8LMetadata* const hdr = &dec->hdr_; \
|
||||
HTreeGroup* htree_group = hdr->htree_groups_; \
|
||||
TYPE* src = data; \
|
||||
TYPE* last_cached = data; \
|
||||
TYPE* const src_end = data + width * height; \
|
||||
const int len_code_limit = NUM_LITERAL_CODES + NUM_LENGTH_CODES; \
|
||||
const int color_cache_limit = len_code_limit + hdr->color_cache_size_; \
|
||||
VP8LColorCache* const color_cache = \
|
||||
(hdr->color_cache_size_ > 0) ? &hdr->color_cache_ : NULL; \
|
||||
const int mask = hdr->huffman_mask_; \
|
||||
assert(htree_group != NULL); \
|
||||
while (!br->eos_ && src < src_end) { \
|
||||
int code; \
|
||||
/* Only update when changing tile. Note we could use this test: */ \
|
||||
/* if "((((prev_col ^ col) | prev_row ^ row)) > mask)" -> tile changed */ \
|
||||
/* but that's actually slower and needs storing the previous col/row. */ \
|
||||
if ((col & mask) == 0) { \
|
||||
htree_group = GetHtreeGroupForPos(hdr, col, row); \
|
||||
} \
|
||||
VP8LFillBitWindow(br); \
|
||||
code = ReadSymbol(&htree_group->htrees_[GREEN], br); \
|
||||
if (code < NUM_LITERAL_CODES) { /* Literal*/ \
|
||||
int red, green, blue, alpha; \
|
||||
red = ReadSymbol(&htree_group->htrees_[RED], br); \
|
||||
green = code; \
|
||||
VP8LFillBitWindow(br); \
|
||||
blue = ReadSymbol(&htree_group->htrees_[BLUE], br); \
|
||||
alpha = ReadSymbol(&htree_group->htrees_[ALPHA], br); \
|
||||
*src = STORE_PIXEL(alpha, red, green, blue); \
|
||||
AdvanceByOne: \
|
||||
++src; \
|
||||
++col; \
|
||||
if (col >= width) { \
|
||||
col = 0; \
|
||||
++row; \
|
||||
if ((process_func != NULL) && (row % NUM_ARGB_CACHE_ROWS == 0)) { \
|
||||
process_func(dec, row); \
|
||||
} \
|
||||
if (color_cache != NULL) { \
|
||||
while (last_cached < src) { \
|
||||
VP8LColorCacheInsert(color_cache, *last_cached++); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} else if (code < len_code_limit) { /* Backward reference */ \
|
||||
int dist_code, dist; \
|
||||
const int length_sym = code - NUM_LITERAL_CODES; \
|
||||
const int length = GetCopyLength(length_sym, br); \
|
||||
const int dist_symbol = ReadSymbol(&htree_group->htrees_[DIST], br); \
|
||||
VP8LFillBitWindow(br); \
|
||||
dist_code = GetCopyDistance(dist_symbol, br); \
|
||||
dist = PlaneCodeToDistance(width, dist_code); \
|
||||
if (src - data < dist || src_end - src < length) { \
|
||||
ok = 0; \
|
||||
goto End; \
|
||||
} \
|
||||
{ \
|
||||
int i; \
|
||||
for (i = 0; i < length; ++i) src[i] = src[i - dist]; \
|
||||
src += length; \
|
||||
} \
|
||||
col += length; \
|
||||
while (col >= width) { \
|
||||
col -= width; \
|
||||
++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 (color_cache != NULL) { \
|
||||
while (last_cached < src) { \
|
||||
VP8LColorCacheInsert(color_cache, *last_cached++); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} else if (code < color_cache_limit) { /* Color cache */ \
|
||||
const int key = code - len_code_limit; \
|
||||
assert(color_cache != NULL); \
|
||||
while (last_cached < src) { \
|
||||
VP8LColorCacheInsert(color_cache, *last_cached++); \
|
||||
} \
|
||||
*src = VP8LColorCacheLookup(color_cache, key); \
|
||||
goto AdvanceByOne; \
|
||||
} else { /* Not reached */ \
|
||||
ok = 0; \
|
||||
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); \
|
||||
End: \
|
||||
if (br->error_ || !ok || (br->eos_ && src < src_end)) { \
|
||||
ok = 0; \
|
||||
dec->status_ = \
|
||||
(!br->eos_) ? VP8_STATUS_BITSTREAM_ERROR : VP8_STATUS_SUSPENDED; \
|
||||
} else if (src == src_end) { \
|
||||
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
|
||||
|
||||
@ -903,8 +933,8 @@ void VP8LClear(VP8LDecoder* const dec) {
|
||||
if (dec == NULL) return;
|
||||
ClearMetadata(&dec->hdr_);
|
||||
|
||||
free(dec->argb_);
|
||||
dec->argb_ = NULL;
|
||||
free(dec->pixels_);
|
||||
dec->pixels_ = NULL;
|
||||
for (i = 0; i < dec->next_transform_; ++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_
|
||||
|
||||
static int AllocateARGBBuffers(VP8LDecoder* const dec, int final_width) {
|
||||
// Allocate internal buffers dec->pixels_ and dec->argb_cache_.
|
||||
static int AllocateInternalBuffers(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_;
|
||||
// Scratch buffer corresponding to top-prediction row for transforming the
|
||||
// first row in the row-blocks.
|
||||
const uint64_t cache_top_pixels = final_width;
|
||||
// Scratch buffer for temporary BGRA storage.
|
||||
const uint64_t cache_pixels = (uint64_t)final_width * NUM_ARGB_CACHE_ROWS;
|
||||
// first row in the row-blocks. Not needed for paletted alpha.
|
||||
const uint64_t cache_top_pixels =
|
||||
argb_cache_needed ? (uint16_t)final_width : 0ULL;
|
||||
// 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 =
|
||||
num_pixels + cache_top_pixels + cache_pixels;
|
||||
|
||||
assert(dec->width_ <= final_width);
|
||||
dec->argb_ = (uint32_t*)WebPSafeMalloc(total_num_pixels, sizeof(*dec->argb_));
|
||||
if (dec->argb_ == NULL) {
|
||||
dec->pixels_ = (uint32_t*)WebPSafeMalloc(total_num_pixels, bytes_per_pixel);
|
||||
if (dec->pixels_ == NULL) {
|
||||
dec->argb_cache_ = NULL; // for sanity check
|
||||
dec->status_ = VP8_STATUS_OUT_OF_MEMORY;
|
||||
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;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// 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) {
|
||||
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.
|
||||
ApplyInverseTransforms(dec, num_rows, in);
|
||||
@ -1070,7 +1104,17 @@ static void ExtractAlphaRows(VP8LDecoder* const dec, int row) {
|
||||
int i;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1079,6 +1123,7 @@ int VP8LDecodeAlphaImageStream(int width, int height, const uint8_t* const data,
|
||||
VP8Io io;
|
||||
int ok = 0;
|
||||
VP8LDecoder* const dec = VP8LNew();
|
||||
size_t bytes_per_pixel = sizeof(uint32_t); // Default: BGRA mode.
|
||||
if (dec == NULL) return 0;
|
||||
|
||||
dec->width_ = width;
|
||||
@ -1097,13 +1142,25 @@ int VP8LDecodeAlphaImageStream(int width, int height, const uint8_t* const data,
|
||||
dec->action_ = READ_HDR;
|
||||
if (!DecodeImageStream(width, height, 1, dec, NULL)) goto Err;
|
||||
|
||||
// Allocate output (note that dec->width_ may have changed here).
|
||||
if (!AllocateARGBBuffers(dec, width)) goto Err;
|
||||
// Special case: if alpha data uses only the color indexing transform and
|
||||
// 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).
|
||||
dec->action_ = READ_DATA;
|
||||
ok = DecodeImageData(dec, dec->argb_, dec->width_, dec->height_,
|
||||
ExtractAlphaRows);
|
||||
ok = (bytes_per_pixel == sizeof(uint8_t)) ?
|
||||
DecodeAlphaData(dec, (uint8_t*)dec->pixels_, dec->width_, dec->height_,
|
||||
ExtractPalettedAlphaRows) :
|
||||
DecodeImageData(dec, dec->pixels_, dec->width_, dec->height_,
|
||||
ExtractAlphaRows);
|
||||
|
||||
Err:
|
||||
VP8LDelete(dec);
|
||||
@ -1143,6 +1200,7 @@ int VP8LDecodeHeader(VP8LDecoder* const dec, VP8Io* const io) {
|
||||
}
|
||||
|
||||
int VP8LDecodeImage(VP8LDecoder* const dec) {
|
||||
const size_t bytes_per_pixel = sizeof(uint32_t);
|
||||
VP8Io* io = NULL;
|
||||
WebPDecParams* params = NULL;
|
||||
|
||||
@ -1162,13 +1220,13 @@ int VP8LDecodeImage(VP8LDecoder* const dec) {
|
||||
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;
|
||||
|
||||
// Decode.
|
||||
dec->action_ = READ_DATA;
|
||||
if (!DecodeImageData(dec, dec->argb_, dec->width_, dec->height_,
|
||||
if (!DecodeImageData(dec, dec->pixels_, dec->width_, dec->height_,
|
||||
ProcessRows)) {
|
||||
goto Err;
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -63,7 +65,8 @@ typedef struct {
|
||||
|
||||
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.
|
||||
|
||||
VP8LBitReader br_;
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2010 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -192,6 +194,15 @@ static VP8StatusCode ParseOptionalChunks(const uint8_t** const data,
|
||||
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.
|
||||
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.
|
||||
*alpha_data = buf + CHUNK_HEADER_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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -10,6 +10,6 @@ libwebpdemuxinclude_HEADERS += ../webp/mux_types.h
|
||||
libwebpdemuxinclude_HEADERS += ../webp/types.h
|
||||
|
||||
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
|
||||
pkgconfig_DATA = libwebpdemux.pc
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -27,7 +29,7 @@ extern "C" {
|
||||
|
||||
#define DMUX_MAJ_VERSION 0
|
||||
#define DMUX_MIN_VERSION 1
|
||||
#define DMUX_REV_VERSION 0
|
||||
#define DMUX_REV_VERSION 1
|
||||
|
||||
typedef struct {
|
||||
size_t start_; // start location of the data
|
||||
@ -317,6 +319,7 @@ static ParseStatus ParseAnimationFrame(
|
||||
frame->duration_ = ReadLE24s(mem);
|
||||
frame->dispose_method_ = (WebPMuxAnimDispose)(ReadByte(mem) & 1);
|
||||
if (frame->width_ * (uint64_t)frame->height_ >= MAX_IMAGE_AREA) {
|
||||
free(frame);
|
||||
return PARSE_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2010 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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).
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -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 a2 = (d1 - d2);
|
||||
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[2 + i * 4] = (a0 - a1) << 3;
|
||||
tmp[2 + i * 4] = (a0 - a1) * 8;
|
||||
tmp[3 + i * 4] = (a3 * 2217 - a2 * 5352 + 937) >> 9;
|
||||
}
|
||||
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) {
|
||||
int tmp[16];
|
||||
// input is 12b signed
|
||||
int16_t tmp[16];
|
||||
int i;
|
||||
for (i = 0; i < 4; ++i, in += 64) {
|
||||
const int a0 = (in[0 * 16] + in[2 * 16]) << 2;
|
||||
const int a1 = (in[1 * 16] + in[3 * 16]) << 2;
|
||||
const int a2 = (in[1 * 16] - in[3 * 16]) << 2;
|
||||
const int a3 = (in[0 * 16] - in[2 * 16]) << 2;
|
||||
tmp[0 + i * 4] = (a0 + a1) + (a0 != 0);
|
||||
const int a0 = (in[0 * 16] + in[2 * 16]); // 13b
|
||||
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; // 14b
|
||||
tmp[1 + i * 4] = a3 + a2;
|
||||
tmp[2 + i * 4] = a3 - a2;
|
||||
tmp[3 + i * 4] = a0 - a1;
|
||||
}
|
||||
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 a2 = (tmp[4 + i] - tmp[12+ 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 b2 = a3 - a2;
|
||||
const int b3 = a0 - a1;
|
||||
out[ 0 + i] = (b0 + (b0 > 0) + 3) >> 3;
|
||||
out[ 4 + i] = (b1 + (b1 > 0) + 3) >> 3;
|
||||
out[ 8 + i] = (b2 + (b2 > 0) + 3) >> 3;
|
||||
out[12 + i] = (b3 + (b3 > 0) + 3) >> 3;
|
||||
out[ 0 + i] = b0 >> 1; // 15b
|
||||
out[ 4 + i] = b1 >> 1;
|
||||
out[ 8 + i] = b2 >> 1;
|
||||
out[12 + i] = b3 >> 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -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
|
||||
"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
|
||||
"vshrn.s32 d1, q11, #16 \n"
|
||||
// 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 d3[3], [%[in]], %[kStep] \n"
|
||||
|
||||
"vaddl.s16 q2, d0, d2 \n"
|
||||
"vshl.s32 q2, q2, #2 \n" // a0=(in[0*16]+in[2*16])<<2
|
||||
"vaddl.s16 q3, d1, d3 \n"
|
||||
"vshl.s32 q3, q3, #2 \n" // a1=(in[1*16]+in[3*16])<<2
|
||||
"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
|
||||
"vaddl.s16 q2, d0, d2 \n" // a0=(in[0*16]+in[2*16])
|
||||
"vaddl.s16 q3, d1, d3 \n" // a1=(in[1*16]+in[3*16])
|
||||
"vsubl.s16 q4, d1, d3 \n" // a2=(in[1*16]-in[3*16])
|
||||
"vsubl.s16 q5, d0, d2 \n" // a3=(in[0*16]-in[2*16])
|
||||
|
||||
"vceq.s32 q10, q2, #0 \n"
|
||||
"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 q6, q2, q3 \n" // a0 + a1
|
||||
"vqadd.s32 q7, q5, q4 \n" // a3 + a2
|
||||
"vqsub.s32 q8, q5, q4 \n" // a3 - a2
|
||||
"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 q7, q0, q1 \n" // b3 = a0 - a1
|
||||
|
||||
"vmov.s32 q0, #3 \n" // q0 = 3
|
||||
|
||||
"vcgt.s32 q1, q4, #0 \n" // (b0>0)
|
||||
"vqsub.s32 q2, q4, q1 \n" // (b0+(b0>0))
|
||||
"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
|
||||
"vshrn.s32 d18, q4, #1 \n" // b0 >> 1
|
||||
"vshrn.s32 d19, q5, #1 \n" // b1 >> 1
|
||||
"vshrn.s32 d20, q6, #1 \n" // b2 >> 1
|
||||
"vshrn.s32 d21, q7, #1 \n" // b3 >> 1
|
||||
|
||||
"vst1.16 {q9, q10}, [%[out]] \n"
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -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
|
||||
|
||||
@ -919,6 +954,7 @@ void VP8EncDspInitSSE2(void) {
|
||||
VP8EncQuantizeBlock = QuantizeBlockSSE2;
|
||||
VP8ITransform = ITransformSSE2;
|
||||
VP8FTransform = FTransformSSE2;
|
||||
VP8FTransformWHT = FTransformWHTSSE2;
|
||||
VP8SSE16x16 = SSE16x16SSE2;
|
||||
VP8SSE16x8 = SSE16x8SSE2;
|
||||
VP8SSE8x8 = SSE8x8SSE2;
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -1093,39 +1095,64 @@ static void ColorSpaceInverseTransform(const VP8LTransform* const transform,
|
||||
}
|
||||
|
||||
// Separate out pixels packed together using pixel-bundling.
|
||||
static void ColorIndexInverseTransform(
|
||||
const VP8LTransform* const transform,
|
||||
int y_start, int y_end, const uint32_t* src, uint32_t* dst) {
|
||||
int y;
|
||||
const int bits_per_pixel = 8 >> transform->bits_;
|
||||
const int width = transform->xsize_;
|
||||
const uint32_t* const color_map = transform->data_;
|
||||
if (bits_per_pixel < 8) {
|
||||
const int pixels_per_byte = 1 << transform->bits_;
|
||||
const int count_mask = pixels_per_byte - 1;
|
||||
const uint32_t bit_mask = (1 << bits_per_pixel) - 1;
|
||||
for (y = y_start; y < y_end; ++y) {
|
||||
uint32_t packed_pixels = 0;
|
||||
int x;
|
||||
for (x = 0; x < width; ++x) {
|
||||
// We need to load fresh 'packed_pixels' once every 'pixels_per_byte'
|
||||
// increments of x. Fortunately, pixels_per_byte is a power of 2, so
|
||||
// can just use a mask for that, instead of decrementing a counter.
|
||||
if ((x & count_mask) == 0) packed_pixels = ((*src++) >> 8) & 0xff;
|
||||
*dst++ = color_map[packed_pixels & bit_mask];
|
||||
packed_pixels >>= bits_per_pixel;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (y = y_start; y < y_end; ++y) {
|
||||
int x;
|
||||
for (x = 0; x < width; ++x) {
|
||||
*dst++ = color_map[((*src++) >> 8) & 0xff];
|
||||
}
|
||||
}
|
||||
}
|
||||
// We define two methods for ARGB data (uint32_t) and alpha-only data (uint8_t).
|
||||
#define COLOR_INDEX_INVERSE(FUNC_NAME, TYPE, GET_INDEX, GET_VALUE) \
|
||||
void FUNC_NAME(const VP8LTransform* const transform, \
|
||||
int y_start, int y_end, const TYPE* src, TYPE* dst) { \
|
||||
int y; \
|
||||
const int bits_per_pixel = 8 >> transform->bits_; \
|
||||
const int width = transform->xsize_; \
|
||||
const uint32_t* const color_map = transform->data_; \
|
||||
if (bits_per_pixel < 8) { \
|
||||
const int pixels_per_byte = 1 << transform->bits_; \
|
||||
const int count_mask = pixels_per_byte - 1; \
|
||||
const uint32_t bit_mask = (1 << bits_per_pixel) - 1; \
|
||||
for (y = y_start; y < y_end; ++y) { \
|
||||
uint32_t packed_pixels = 0; \
|
||||
int x; \
|
||||
for (x = 0; x < width; ++x) { \
|
||||
/* We need to load fresh 'packed_pixels' once every */ \
|
||||
/* 'pixels_per_byte' increments of x. Fortunately, pixels_per_byte */ \
|
||||
/* is a power of 2, so can just use a mask for that, instead of */ \
|
||||
/* decrementing a counter. */ \
|
||||
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; \
|
||||
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,
|
||||
int row_start, int row_end,
|
||||
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) {
|
||||
uint32_t argb = *src++;
|
||||
|
||||
#if !defined(__BIG_ENDIAN__)
|
||||
#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));
|
||||
*(uint32_t*)dst = argb;
|
||||
#elif !defined(__BIG_ENDIAN__) && defined(_MSC_VER)
|
||||
#elif defined(_MSC_VER)
|
||||
argb = _byteswap_ulong(argb);
|
||||
*(uint32_t*)dst = argb;
|
||||
#else
|
||||
@ -1267,11 +1295,17 @@ static void CopyOrSwap(const uint32_t* src, int num_pixels, uint8_t* dst,
|
||||
dst[2] = (argb >> 8) & 0xff;
|
||||
dst[3] = (argb >> 0) & 0xff;
|
||||
#endif
|
||||
#else // WEBP_REFERENCE_IMPLEMENTATION
|
||||
#else // WEBP_REFERENCE_IMPLEMENTATION
|
||||
dst[0] = (argb >> 24) & 0xff;
|
||||
dst[1] = (argb >> 16) & 0xff;
|
||||
dst[2] = (argb >> 8) & 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
|
||||
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)
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -33,6 +35,13 @@ void VP8LInverseTransform(const struct VP8LTransform* const transform,
|
||||
int row_start, int row_end,
|
||||
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.
|
||||
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);
|
||||
}
|
||||
|
||||
void VP8LBundleColorMap(const uint8_t* const row, int width,
|
||||
int xbits, uint32_t* const dst);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2010 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2010 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -80,7 +82,7 @@ static int EncodeLossless(const uint8_t* const data, int width, int height,
|
||||
config.lossless = 1;
|
||||
config.method = effort_level; // impact is very small
|
||||
// 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);
|
||||
|
||||
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,
|
||||
int quality, int method, int filter,
|
||||
int effort_level,
|
||||
@ -207,18 +228,32 @@ static int EncodeAlpha(VP8Encoder* const enc,
|
||||
VP8BitWriter bw;
|
||||
int test_filter;
|
||||
uint8_t* filtered_alpha = NULL;
|
||||
int try_filter_none = (effort_level > 3);
|
||||
|
||||
// We always test WEBP_FILTER_NONE first.
|
||||
ok = EncodeAlphaInternal(quant_alpha, width, height,
|
||||
method, WEBP_FILTER_NONE, reduce_levels,
|
||||
effort_level, NULL, &bw, pic->stats);
|
||||
if (!ok) {
|
||||
VP8BitWriterWipeOut(&bw);
|
||||
goto End;
|
||||
if (filter == WEBP_FILTER_FAST) { // Quick estimate of the best candidate.
|
||||
const int kMinColorsForFilterNone = 16;
|
||||
const int kMaxColorsForFilterNone = 192;
|
||||
const int num_colors = GetNumColors(quant_alpha, width, height, width);
|
||||
// For low number of colors, NONE yeilds better compression.
|
||||
filter = (num_colors <= kMinColorsForFilterNone) ? WEBP_FILTER_NONE :
|
||||
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?
|
||||
filter = EstimateBestFilter(quant_alpha, width, height, width);
|
||||
// Test for WEBP_FILTER_NONE for higher effort levels.
|
||||
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?
|
||||
if (filter == WEBP_FILTER_NONE) {
|
||||
@ -234,11 +269,14 @@ static int EncodeAlpha(VP8Encoder* const enc,
|
||||
// Try the other mode(s).
|
||||
{
|
||||
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
|
||||
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);
|
||||
++test_filter) {
|
||||
VP8BitWriter tmp_bw;
|
||||
@ -262,7 +300,10 @@ static int EncodeAlpha(VP8Encoder* const enc,
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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)
|
||||
@ -142,9 +144,10 @@ static void HashChainInsert(HashChain* const p,
|
||||
}
|
||||
|
||||
static void GetParamsForHashChainFindCopy(int quality, int xsize,
|
||||
int* window_size, int* iter_pos,
|
||||
int* iter_limit) {
|
||||
int cache_bits, int* window_size,
|
||||
int* iter_pos, int* iter_limit) {
|
||||
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.
|
||||
const int max_window_size = (quality > 50) ? WINDOW_SIZE
|
||||
: (quality > 25) ? (xsize << 8)
|
||||
@ -152,77 +155,74 @@ static void GetParamsForHashChainFindCopy(int quality, int xsize,
|
||||
assert(xsize > 0);
|
||||
*window_size = (max_window_size > WINDOW_SIZE) ? WINDOW_SIZE
|
||||
: max_window_size;
|
||||
*iter_pos = 5 + (quality >> 3);
|
||||
*iter_limit = -quality * iter_mult;
|
||||
*iter_pos = 8 + (quality >> 3);
|
||||
// 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,
|
||||
int base_position, int xsize,
|
||||
int base_position, int xsize_signed,
|
||||
const uint32_t* const argb, int maxlen,
|
||||
int window_size, int iter_pos, int iter_limit,
|
||||
int* const distance_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;
|
||||
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 =
|
||||
(base_position > window_size) ? base_position - window_size : 0;
|
||||
int pos;
|
||||
|
||||
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 = p->chain_[pos]) {
|
||||
int64_t val;
|
||||
int curr_length;
|
||||
uint64_t val;
|
||||
uint32_t curr_length;
|
||||
uint32_t distance;
|
||||
if (iter_pos < 0) {
|
||||
if (iter_pos < iter_limit || best_val >= 0xff0000) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
--iter_pos;
|
||||
if (best_length != 0 &&
|
||||
argb[pos + best_length - 1] != argb_start[best_length - 1]) {
|
||||
if (argb[pos + best_length - 1] != argb_start[best_length - 1]) {
|
||||
continue;
|
||||
}
|
||||
curr_length = FindMatchLength(argb + pos, argb_start, maxlen);
|
||||
if (curr_length < prev_length) {
|
||||
if (curr_length < best_length) {
|
||||
continue;
|
||||
}
|
||||
val = 65536 * curr_length;
|
||||
distance = (uint32_t)(base_position - pos);
|
||||
val = curr_length << 16;
|
||||
// Favoring 2d locality here gives savings for certain images.
|
||||
if (base_position - pos < 9 * xsize) {
|
||||
const int y = (base_position - pos) / xsize;
|
||||
int x = (base_position - pos) % xsize;
|
||||
if (x > xsize / 2) {
|
||||
if (distance < 9 * xsize) {
|
||||
const uint32_t y = distance / xsize;
|
||||
uint32_t x = distance % xsize;
|
||||
if (x > (xsize >> 1)) {
|
||||
x = xsize - x;
|
||||
}
|
||||
if (x <= 7 && x >= -8) {
|
||||
if (x <= 7) {
|
||||
val += 9 * 9 + 9 * 9;
|
||||
val -= y * y + x * x;
|
||||
} else {
|
||||
val -= 9 * 9 + 9 * 9;
|
||||
}
|
||||
} else {
|
||||
val -= 9 * 9 + 9 * 9;
|
||||
}
|
||||
if (best_val < val) {
|
||||
prev_length = curr_length;
|
||||
best_val = val;
|
||||
best_length = curr_length;
|
||||
best_distance = base_position - pos;
|
||||
best_distance = distance;
|
||||
if (curr_length >= MAX_LENGTH) {
|
||||
break;
|
||||
}
|
||||
if ((best_distance == 1 || best_distance == xsize) &&
|
||||
if ((best_distance == 1 || distance == xsize) &&
|
||||
best_length >= 128) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
*distance_ptr = best_distance;
|
||||
*distance_ptr = (int)best_distance;
|
||||
*length_ptr = best_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;
|
||||
|
||||
refs->size = 0;
|
||||
GetParamsForHashChainFindCopy(quality, xsize, &window_size, &iter_pos,
|
||||
&iter_limit);
|
||||
GetParamsForHashChainFindCopy(quality, xsize, cache_bits,
|
||||
&window_size, &iter_pos, &iter_limit);
|
||||
for (i = 0; i < pix_count; ) {
|
||||
// Alternative#1: Code the pixels starting at 'i' using backward reference.
|
||||
int offset = 0;
|
||||
@ -510,8 +510,8 @@ static int BackwardReferencesHashChainDistanceOnly(
|
||||
// We loop one pixel at a time, but store all currently best points to
|
||||
// non-processed locations from this point.
|
||||
dist_array[0] = 0;
|
||||
GetParamsForHashChainFindCopy(quality, xsize, &window_size, &iter_pos,
|
||||
&iter_limit);
|
||||
GetParamsForHashChainFindCopy(quality, xsize, cache_bits,
|
||||
&window_size, &iter_pos, &iter_limit);
|
||||
for (i = 0; i < pix_count; ++i) {
|
||||
double prev_cost = 0.0;
|
||||
int shortmax;
|
||||
@ -645,8 +645,8 @@ static int BackwardReferencesHashChainFollowChosenPath(
|
||||
}
|
||||
|
||||
refs->size = 0;
|
||||
GetParamsForHashChainFindCopy(quality, xsize, &window_size, &iter_pos,
|
||||
&iter_limit);
|
||||
GetParamsForHashChainFindCopy(quality, xsize, cache_bits,
|
||||
&window_size, &iter_pos, &iter_limit);
|
||||
for (ix = 0; ix < chosen_path_size; ++ix, ++size) {
|
||||
int offset = 0;
|
||||
int len = 0;
|
||||
@ -785,7 +785,9 @@ int VP8LGetBackwardReferences(int width, int height,
|
||||
*best = refs_lz77; // default guess: lz77 is better
|
||||
VP8LClearBackwardRefs(&refs_rle);
|
||||
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;
|
||||
if (!VP8LBackwardRefsAlloc(&refs_trace, num_pix)) {
|
||||
goto End;
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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)
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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)
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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)
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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)
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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, ...
|
||||
@ -709,7 +711,7 @@ static int Import(WebPPicture* const picture,
|
||||
for (y = 0; y < height; ++y) {
|
||||
for (x = 0; x < width; ++x) {
|
||||
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) |
|
||||
(g_ptr[offset] << 8) |
|
||||
(b_ptr[offset]);
|
||||
@ -809,7 +811,7 @@ int WebPPictureYUVAToARGB(WebPPicture* picture) {
|
||||
const uint8_t* const src = picture->a + y * picture->a_stride;
|
||||
int 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -28,7 +30,7 @@ extern "C" {
|
||||
// version numbers
|
||||
#define ENC_MAJ_VERSION 0
|
||||
#define ENC_MIN_VERSION 3
|
||||
#define ENC_REV_VERSION 0
|
||||
#define ENC_REV_VERSION 1
|
||||
|
||||
// intra prediction modes
|
||||
enum { B_DC_PRED = 0, // 4x4 modes
|
||||
|
114
src/enc/vp8l.c
114
src/enc/vp8l.c
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -86,7 +88,7 @@ static int AnalyzeAndCreatePalette(const WebPPicture* const pic,
|
||||
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;
|
||||
for (i = 0; i < (int)(sizeof(in_use) / sizeof(in_use[0])); ++i) {
|
||||
if (in_use[i]) {
|
||||
@ -811,34 +813,66 @@ static WebPEncodingError AllocateTransformBuffer(VP8LEncoder* const enc,
|
||||
return err;
|
||||
}
|
||||
|
||||
// Bundles multiple (1, 2, 4 or 8) pixels into a single pixel.
|
||||
static void BundleColorMap(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;
|
||||
static void ApplyPalette(uint32_t* src, uint32_t* dst,
|
||||
uint32_t src_stride, uint32_t dst_stride,
|
||||
const uint32_t* palette, int palette_size,
|
||||
int width, int height, int xbits, uint8_t* row) {
|
||||
int i, x, y;
|
||||
int use_LUT = 1;
|
||||
for (i = 0; i < palette_size; ++i) {
|
||||
if ((palette[i] & 0xffff00ffu) != 0) {
|
||||
use_LUT = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
dst[x >> xbits] = code;
|
||||
VP8LBundleColorMap(row, width, xbits, dst);
|
||||
src += src_stride;
|
||||
dst += dst_stride;
|
||||
}
|
||||
} 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.
|
||||
// Also, "enc->palette_" will be modified after this call and should not be used
|
||||
// later.
|
||||
static WebPEncodingError ApplyPalette(VP8LBitWriter* const bw,
|
||||
VP8LEncoder* const enc, int quality) {
|
||||
static WebPEncodingError EncodePalette(VP8LBitWriter* const bw,
|
||||
VP8LEncoder* const enc, int quality) {
|
||||
WebPEncodingError err = VP8_ENC_OK;
|
||||
int i, x, y;
|
||||
int i;
|
||||
const WebPPicture* const pic = enc->pic_;
|
||||
uint32_t* src = pic->argb;
|
||||
uint32_t* dst;
|
||||
@ -864,20 +898,8 @@ static WebPEncodingError ApplyPalette(VP8LBitWriter* const bw,
|
||||
row = WebPSafeMalloc((uint64_t)width, sizeof(*row));
|
||||
if (row == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
for (y = 0; y < height; ++y) {
|
||||
for (x = 0; x < width; ++x) {
|
||||
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_;
|
||||
}
|
||||
ApplyPalette(src, dst, pic->argb_stride, enc->current_width_,
|
||||
palette, palette_size, width, height, xbits, row);
|
||||
|
||||
// Save palette to bitstream.
|
||||
VP8LWriteBits(bw, 1, TRANSFORM_PRESENT);
|
||||
@ -899,13 +921,10 @@ static WebPEncodingError ApplyPalette(VP8LBitWriter* const bw,
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static int GetHistoBits(const WebPConfig* const config,
|
||||
const WebPPicture* const pic) {
|
||||
const int width = pic->width;
|
||||
const int height = pic->height;
|
||||
static int GetHistoBits(int method, int use_palette, int width, int height) {
|
||||
const uint64_t hist_size = sizeof(VP8LHistogram);
|
||||
// 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) {
|
||||
const uint64_t huff_image_size = VP8LSubSampleSize(width, 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;
|
||||
}
|
||||
|
||||
static void InitEncParams(VP8LEncoder* const enc) {
|
||||
static void FinishEncParams(VP8LEncoder* const enc) {
|
||||
const WebPConfig* const config = enc->config_;
|
||||
const WebPPicture* const picture = enc->pic_;
|
||||
const WebPPicture* const pic = enc->pic_;
|
||||
const int method = config->method;
|
||||
const float quality = config->quality;
|
||||
const int use_palette = enc->use_palette_;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -965,8 +985,6 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
|
||||
goto Error;
|
||||
}
|
||||
|
||||
InitEncParams(enc);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Analyze image (entropy, num_palettes etc)
|
||||
|
||||
@ -975,8 +993,10 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
|
||||
goto Error;
|
||||
}
|
||||
|
||||
FinishEncParams(enc);
|
||||
|
||||
if (enc->use_palette_) {
|
||||
err = ApplyPalette(bw, enc, quality);
|
||||
err = EncodePalette(bw, enc, quality);
|
||||
if (err != VP8_ENC_OK) goto Error;
|
||||
// Color cache is disabled for palette.
|
||||
enc->cache_bits_ = 0;
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
@ -386,9 +388,9 @@ int WebPEncode(const WebPConfig* config, WebPPicture* pic) {
|
||||
// Analysis is done, proceed to actual coding.
|
||||
ok = ok && VP8EncStartAlpha(enc); // possibly done in parallel
|
||||
if (!enc->use_tokens_) {
|
||||
ok = VP8EncLoop(enc);
|
||||
ok = ok && VP8EncLoop(enc);
|
||||
} else {
|
||||
ok = VP8EncTokenLoop(enc);
|
||||
ok = ok && VP8EncTokenLoop(enc);
|
||||
}
|
||||
ok = ok && VP8EncFinishAlpha(enc);
|
||||
#ifdef WEBP_EXPERIMENTAL_FEATURES
|
||||
|
@ -13,6 +13,6 @@ libwebpmuxinclude_HEADERS += ../webp/mux_types.h
|
||||
libwebpmuxinclude_HEADERS += ../webp/types.h
|
||||
|
||||
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
|
||||
pkgconfig_DATA = libwebpmux.pc
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -475,7 +477,7 @@ static WebPMuxError GetImageCanvasWidthHeight(
|
||||
int64_t image_area = 0;
|
||||
// Aggregate the bounding box for animation frames & fragmented images.
|
||||
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,
|
||||
&duration, &w, &h);
|
||||
const int max_x_pos = x_offset + w;
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
@ -26,7 +28,7 @@ extern "C" {
|
||||
|
||||
#define MUX_MAJ_VERSION 0
|
||||
#define MUX_MIN_VERSION 1
|
||||
#define MUX_REV_VERSION 0
|
||||
#define MUX_REV_VERSION 1
|
||||
|
||||
// Chunk object.
|
||||
typedef struct WebPChunk WebPChunk;
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2010 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2010 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
@ -194,6 +196,7 @@ static WEBP_INLINE void VP8LoadNewBytes(VP8BitReader* const br) {
|
||||
#endif
|
||||
#else // BIG_ENDIAN
|
||||
bits = (bit_t)in_bits;
|
||||
if (BITS != 8 * sizeof(bit_t)) bits >>= (8 * sizeof(bit_t) - BITS);
|
||||
#endif
|
||||
#ifndef USE_RIGHT_JUSTIFY
|
||||
br->value_ |= bits << (-br->bits_);
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
@ -154,8 +156,7 @@ static void GradientUnfilter(int width, int height, int stride, uint8_t* data) {
|
||||
#undef SANITY_CHECK
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Quick estimate of a potentially interesting filter mode to try, in addition
|
||||
// to the default NONE.
|
||||
// Quick estimate of a potentially interesting filter mode to try.
|
||||
|
||||
#define SMAX 16
|
||||
#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 bins[WEBP_FILTER_LAST][SMAX];
|
||||
memset(bins, 0, sizeof(bins));
|
||||
|
||||
// We only sample every other pixels. That's enough.
|
||||
for (j = 2; j < height - 1; j += 2) {
|
||||
const uint8_t* const p = data + j * stride;
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2012 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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.
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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)
|
||||
|
@ -1,8 +1,10 @@
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// This code is licensed under the same terms as WebM:
|
||||
// Software License Agreement: http://www.webmproject.org/license/software/
|
||||
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// 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)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user