2010-09-30 15:34:38 +02:00
|
|
|
__ __ ____ ____ ____
|
|
|
|
/ \\/ \/ _ \/ _ )/ _ \
|
|
|
|
\ / __/ _ \ __/
|
2011-02-19 08:33:46 +01:00
|
|
|
\__\__/\____/\_____/__/ ____ ___
|
|
|
|
/ _/ / \ \ / _ \/ _/
|
|
|
|
/ \_/ / / \ \ __/ \__
|
2018-11-03 04:36:14 +01:00
|
|
|
\____/____/\_____/_____/____/v1.0.1
|
2011-02-19 08:33:46 +01:00
|
|
|
|
2010-09-30 15:34:38 +02:00
|
|
|
Description:
|
|
|
|
============
|
|
|
|
|
2011-08-31 02:21:53 +02:00
|
|
|
WebP codec: library to encode and decode images in WebP format. This package
|
2011-02-19 08:33:46 +01:00
|
|
|
contains the library that can be used in other programs to add WebP support,
|
|
|
|
as well as the command line tools 'cwebp' and 'dwebp'.
|
2010-09-30 15:34:38 +02:00
|
|
|
|
2012-07-21 01:19:12 +02:00
|
|
|
See http://developers.google.com/speed/webp
|
2010-09-30 15:34:38 +02:00
|
|
|
|
2015-12-17 03:13:02 +01:00
|
|
|
The latest source tree is available at
|
|
|
|
https://chromium.googlesource.com/webm/libwebp
|
2010-09-30 15:34:38 +02:00
|
|
|
|
|
|
|
It is released under the same license as the WebM project.
|
|
|
|
See http://www.webmproject.org/license/software/ or the
|
2016-06-14 07:48:04 +02:00
|
|
|
"COPYING" file for details. An additional intellectual
|
2010-09-30 15:34:38 +02:00
|
|
|
property rights grant can be found in the file PATENTS.
|
|
|
|
|
2011-02-19 08:33:46 +01:00
|
|
|
Building:
|
|
|
|
=========
|
2010-09-30 15:34:38 +02:00
|
|
|
|
2011-02-19 08:33:46 +01:00
|
|
|
Windows build:
|
|
|
|
--------------
|
2010-09-30 15:34:38 +02:00
|
|
|
|
2011-02-19 08:33:46 +01:00
|
|
|
By running:
|
2010-09-30 15:34:38 +02:00
|
|
|
|
2011-02-19 08:33:46 +01:00
|
|
|
nmake /f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output
|
2010-09-30 15:34:38 +02:00
|
|
|
|
2011-07-16 03:58:56 +02:00
|
|
|
the directory output\release-static\(x64|x86)\bin will contain the tools
|
|
|
|
cwebp.exe and dwebp.exe. The directory output\release-static\(x64|x86)\lib will
|
|
|
|
contain the libwebp static library.
|
2011-08-31 02:21:53 +02:00
|
|
|
The target architecture (x86/x64) is detected by Makefile.vc from the Visual
|
|
|
|
Studio compiler (cl.exe) available in the system path.
|
2010-09-30 15:34:38 +02:00
|
|
|
|
2011-02-20 20:11:55 +01:00
|
|
|
Unix build using makefile.unix:
|
|
|
|
-------------------------------
|
|
|
|
|
|
|
|
On platforms with GNU tools installed (gcc and make), running
|
|
|
|
|
|
|
|
make -f makefile.unix
|
|
|
|
|
|
|
|
will build the binaries examples/cwebp and examples/dwebp, along
|
|
|
|
with the static library src/libwebp.a. No system-wide installation
|
|
|
|
is supplied, as this is a simple alternative to the full installation
|
|
|
|
system based on the autoconf tools (see below).
|
2013-03-16 20:35:49 +01:00
|
|
|
Please refer to makefile.unix for additional details and customizations.
|
2011-02-20 20:11:55 +01:00
|
|
|
|
2011-02-19 08:33:46 +01:00
|
|
|
Using autoconf tools:
|
|
|
|
---------------------
|
2015-12-04 04:29:53 +01:00
|
|
|
Prerequisites:
|
|
|
|
A compiler (e.g., gcc), make, autoconf, automake, libtool.
|
|
|
|
On a Debian-like system the following should install everything you need for a
|
|
|
|
minimal build:
|
|
|
|
$ sudo apt-get install gcc make autoconf automake libtool
|
|
|
|
|
2012-07-19 20:40:42 +02:00
|
|
|
When building from git sources, you will need to run autogen.sh to generate the
|
|
|
|
configure script.
|
|
|
|
|
2010-09-30 15:34:38 +02:00
|
|
|
./configure
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
|
|
|
|
should be all you need to have the following files
|
|
|
|
|
|
|
|
/usr/local/include/webp/decode.h
|
2011-02-19 08:33:46 +01:00
|
|
|
/usr/local/include/webp/encode.h
|
|
|
|
/usr/local/include/webp/types.h
|
|
|
|
/usr/local/lib/libwebp.*
|
|
|
|
/usr/local/bin/cwebp
|
|
|
|
/usr/local/bin/dwebp
|
2010-09-30 15:34:38 +02:00
|
|
|
|
|
|
|
installed.
|
|
|
|
|
2013-03-16 20:35:49 +01:00
|
|
|
Note: A decode-only library, libwebpdecoder, is available using the
|
|
|
|
'--enable-libwebpdecoder' flag. The encode library is built separately and can
|
|
|
|
be installed independently using a minor modification in the corresponding
|
|
|
|
Makefile.am configure files (see comments there). See './configure --help' for
|
|
|
|
more options.
|
2011-02-19 08:33:46 +01:00
|
|
|
|
2016-05-27 12:09:27 +02:00
|
|
|
Building for MIPS Linux:
|
|
|
|
------------------------
|
|
|
|
MIPS Linux toolchain stable available releases can be found at:
|
|
|
|
https://community.imgtec.com/developers/mips/tools/codescape-mips-sdk/available-releases/
|
|
|
|
|
|
|
|
# Add toolchain to PATH
|
|
|
|
export PATH=$PATH:/path/to/toolchain/bin
|
|
|
|
|
|
|
|
# 32-bit build for mips32r5 (p5600)
|
|
|
|
HOST=mips-mti-linux-gnu
|
|
|
|
MIPS_CFLAGS="-O3 -mips32r5 -mabi=32 -mtune=p5600 -mmsa -mfp64 \
|
|
|
|
-msched-weight -mload-store-pairs -fPIE"
|
|
|
|
MIPS_LDFLAGS="-mips32r5 -mabi=32 -mmsa -mfp64 -pie"
|
|
|
|
|
|
|
|
# 64-bit build for mips64r6 (i6400)
|
|
|
|
HOST=mips-img-linux-gnu
|
|
|
|
MIPS_CFLAGS="-O3 -mips64r6 -mabi=64 -mtune=i6400 -mmsa -mfp64 \
|
|
|
|
-msched-weight -mload-store-pairs -fPIE"
|
|
|
|
MIPS_LDFLAGS="-mips64r6 -mabi=64 -mmsa -mfp64 -pie"
|
|
|
|
|
|
|
|
./configure --host=${HOST} --build=`config.guess` \
|
|
|
|
CC="${HOST}-gcc -EL" \
|
|
|
|
CFLAGS="$MIPS_CFLAGS" \
|
|
|
|
LDFLAGS="$MIPS_LDFLAGS"
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
|
2015-12-21 15:35:13 +01:00
|
|
|
CMake:
|
|
|
|
------
|
2017-11-24 08:58:22 +01:00
|
|
|
With CMake, you can compile libwebp, cwebp, dwebp, gif2web, img2webp, webpinfo
|
|
|
|
and the JS bindings.
|
2015-12-21 15:35:13 +01:00
|
|
|
|
|
|
|
Prerequisites:
|
|
|
|
A compiler (e.g., gcc with autotools) and CMake.
|
|
|
|
On a Debian-like system the following should install everything you need for a
|
|
|
|
minimal build:
|
|
|
|
$ sudo apt-get install build-essential cmake
|
|
|
|
|
|
|
|
When building from git sources, you will need to run cmake to generate the
|
2017-06-22 01:36:09 +02:00
|
|
|
makefiles.
|
2015-12-21 15:35:13 +01:00
|
|
|
|
|
|
|
mkdir build && cd build && cmake ../
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
|
2017-02-22 15:57:06 +01:00
|
|
|
If you also want any of the executables, you will need to enable them through
|
|
|
|
CMake, e.g.:
|
2015-12-21 15:35:13 +01:00
|
|
|
|
|
|
|
cmake -DWEBP_BUILD_CWEBP=ON -DWEBP_BUILD_DWEBP=ON ../
|
|
|
|
|
|
|
|
or through your favorite interface (like ccmake or cmake-qt-gui).
|
|
|
|
|
libwebp: Unicode command tools on Windows
Define macros in examples/unicode.h to use Unicode argv
on Windows. Keep char everywhere on Unix since it handles
UTF-8 without any change.
Impact:
- All fopen () and SHCreateStreamOnFile(),
- All fprintf() printing file paths,
- All strcmp() used with "-",
- File path parsing,
- Gif reading.
Concerned executables from examples/ and extras/:
anim_diff, anim_dump, vwebp, vwebp_sdl,
cwebp, dwebp, gif2webp, img2webp,
webpmux, webpinfo, webp_quality, get_disto
When compiled on Windows with Unicode enabled, webpmux and
img2webp will not work when used with an argument file and
will print "Reading arguments from a file is a feature
unavailable with Unicode binaries."
BUG=webp:398
Change-Id: Ic55d222a3ce1a715f9c4cce57ecbe2705d5ce317
2018-10-16 11:03:18 +02:00
|
|
|
Use option -DWEBP_UNICODE=ON for Unicode support on Windows (with chcp 65001).
|
|
|
|
|
2017-02-22 15:57:06 +01:00
|
|
|
Finally, once installed, you can also use WebP in your CMake project by doing:
|
|
|
|
|
|
|
|
find_package(WebP)
|
|
|
|
|
|
|
|
which will define the CMake variables WebP_INCLUDE_DIRS and WebP_LIBRARIES.
|
|
|
|
|
2016-05-24 15:35:20 +02:00
|
|
|
Gradle:
|
|
|
|
-------
|
|
|
|
The support for Gradle is minimal: it only helps you compile libwebp, cwebp and
|
|
|
|
dwebp and webpmux_example.
|
|
|
|
|
|
|
|
Prerequisites:
|
|
|
|
A compiler (e.g., gcc with autotools) and gradle.
|
|
|
|
On a Debian-like system the following should install everything you need for a
|
|
|
|
minimal build:
|
|
|
|
$ sudo apt-get install build-essential gradle
|
|
|
|
|
|
|
|
When building from git sources, you will need to run the Gradle wrapper with the
|
|
|
|
appropriate target, e.g. :
|
|
|
|
|
|
|
|
./gradlew buildAllExecutables
|
|
|
|
|
2011-05-06 22:09:56 +02:00
|
|
|
SWIG bindings:
|
|
|
|
--------------
|
|
|
|
|
2013-10-29 19:49:11 +01:00
|
|
|
To generate language bindings from swig/libwebp.swig at least swig-1.3
|
2013-05-21 23:58:32 +02:00
|
|
|
(http://www.swig.org) is required.
|
2011-05-06 22:09:56 +02:00
|
|
|
|
2011-07-15 02:35:40 +02:00
|
|
|
Currently the following functions are mapped:
|
2011-06-10 20:48:48 +02:00
|
|
|
Decode:
|
2011-05-06 22:09:56 +02:00
|
|
|
WebPGetDecoderVersion
|
|
|
|
WebPGetInfo
|
|
|
|
WebPDecodeRGBA
|
2011-07-15 02:35:40 +02:00
|
|
|
WebPDecodeARGB
|
2011-05-06 22:09:56 +02:00
|
|
|
WebPDecodeBGRA
|
2012-07-19 20:40:42 +02:00
|
|
|
WebPDecodeBGR
|
|
|
|
WebPDecodeRGB
|
|
|
|
|
2011-06-10 20:48:48 +02:00
|
|
|
Encode:
|
|
|
|
WebPGetEncoderVersion
|
|
|
|
WebPEncodeRGBA
|
|
|
|
WebPEncodeBGRA
|
2012-07-19 20:40:42 +02:00
|
|
|
WebPEncodeRGB
|
|
|
|
WebPEncodeBGR
|
|
|
|
WebPEncodeLosslessRGBA
|
|
|
|
WebPEncodeLosslessBGRA
|
|
|
|
WebPEncodeLosslessRGB
|
|
|
|
WebPEncodeLosslessBGR
|
2011-05-06 22:09:56 +02:00
|
|
|
|
2013-05-21 23:58:32 +02:00
|
|
|
See swig/README for more detailed build instructions.
|
|
|
|
|
2011-05-06 22:09:56 +02:00
|
|
|
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").
|
|
|
|
|
2013-05-21 23:58:32 +02:00
|
|
|
Python bindings:
|
|
|
|
|
|
|
|
To build the swig-generated Python extension code at least Python 2.6 is
|
2013-10-29 19:49:11 +01:00
|
|
|
required. Python < 2.6 may build with some minor changes to libwebp.swig or the
|
2013-05-21 23:58:32 +02:00
|
|
|
generated code, but is untested.
|
|
|
|
|
2011-02-19 08:33:46 +01:00
|
|
|
Encoding tool:
|
|
|
|
==============
|
|
|
|
|
|
|
|
The examples/ directory contains tools for encoding (cwebp) and
|
|
|
|
decoding (dwebp) images.
|
|
|
|
|
|
|
|
The easiest use should look like:
|
|
|
|
cwebp input.png -q 80 -o output.webp
|
2012-07-19 20:40:42 +02:00
|
|
|
which will convert the input file to a WebP file using a quality factor of 80
|
|
|
|
on a 0->100 scale (0 being the lowest quality, 100 being the best. Default
|
|
|
|
value is 75).
|
|
|
|
You might want to try the -lossless flag too, which will compress the source
|
|
|
|
(in RGBA format) without any loss. The -q quality parameter will in this case
|
|
|
|
control the amount of processing time spent trying to make the output file as
|
|
|
|
small as possible.
|
2011-02-19 08:33:46 +01:00
|
|
|
|
|
|
|
A longer list of options is available using the -longhelp command line flag:
|
|
|
|
|
|
|
|
> cwebp -longhelp
|
|
|
|
Usage:
|
|
|
|
cwebp [-preset <...>] [options] in_file [-o out_file]
|
|
|
|
|
2014-06-18 16:45:34 +02:00
|
|
|
If input size (-s) for an image is not specified, it is
|
|
|
|
assumed to be a PNG, JPEG, TIFF or WebP file.
|
|
|
|
|
|
|
|
Options:
|
2016-06-25 04:25:11 +02:00
|
|
|
-h / -help ............. short help
|
|
|
|
-H / -longhelp ......... long help
|
2016-08-09 19:03:55 +02:00
|
|
|
-q <float> ............. quality factor (0:small..100:big), default=75
|
|
|
|
-alpha_q <int> ......... transparency-compression quality (0..100),
|
|
|
|
default=100
|
2014-06-18 16:45:34 +02:00
|
|
|
-preset <string> ....... preset setting, one of:
|
2011-02-19 08:33:46 +01:00
|
|
|
default, photo, picture,
|
|
|
|
drawing, icon, text
|
2014-06-18 16:45:34 +02:00
|
|
|
-preset must come first, as it overwrites other parameters
|
|
|
|
-z <int> ............... activates lossless preset with given
|
2014-05-26 22:36:16 +02:00
|
|
|
level in [0:fast, ..., 9:slowest]
|
|
|
|
|
2016-08-09 19:03:55 +02:00
|
|
|
-m <int> ............... compression method (0=fast, 6=slowest), default=4
|
|
|
|
-segments <int> ........ number of segments to use (1..4), default=4
|
2014-06-18 16:45:34 +02:00
|
|
|
-size <int> ............ target size (in bytes)
|
|
|
|
-psnr <float> .......... target PSNR (in dB. typically: 42)
|
2011-02-19 08:33:46 +01:00
|
|
|
|
2014-06-18 16:45:34 +02:00
|
|
|
-s <int> <int> ......... input size (width x height) for YUV
|
2016-08-09 19:03:55 +02:00
|
|
|
-sns <int> ............. spatial noise shaping (0:off, 100:max), default=50
|
|
|
|
-f <int> ............... filter strength (0=off..100), default=60
|
|
|
|
-sharpness <int> ....... filter sharpness (0:most .. 7:least sharp), default=0
|
2014-06-18 16:45:34 +02:00
|
|
|
-strong ................ use strong filter instead of simple (default)
|
|
|
|
-nostrong .............. use simple filter instead of strong
|
2017-01-20 16:53:58 +01:00
|
|
|
-sharp_yuv ............. use sharper (and slower) RGB->YUV conversion
|
2011-08-24 00:58:22 +02:00
|
|
|
-partition_limit <int> . limit quality to fit the 512k limit on
|
|
|
|
the first partition (0=no degradation ... 100=full)
|
2011-02-19 08:33:46 +01:00
|
|
|
-pass <int> ............ analysis pass number (1..10)
|
|
|
|
-crop <x> <y> <w> <h> .. crop picture with the given rectangle
|
2011-06-20 09:45:15 +02:00
|
|
|
-resize <w> <h> ........ resize picture (after any cropping)
|
2013-03-01 01:21:34 +01:00
|
|
|
-mt .................... use multi-threading if available
|
2013-03-12 00:37:42 +01:00
|
|
|
-low_memory ............ reduce memory usage (slower encoding)
|
2014-06-18 16:45:34 +02:00
|
|
|
-map <int> ............. print map of extra info
|
|
|
|
-print_psnr ............ prints averaged PSNR distortion
|
|
|
|
-print_ssim ............ prints averaged SSIM distortion
|
|
|
|
-print_lsim ............ prints local-similarity distortion
|
|
|
|
-d <file.pgm> .......... dump the compressed output (PGM file)
|
2016-08-09 19:03:55 +02:00
|
|
|
-alpha_method <int> .... transparency-compression method (0..1), default=1
|
2014-06-18 16:45:34 +02:00
|
|
|
-alpha_filter <string> . predictive filtering for alpha plane,
|
|
|
|
one of: none, fast (default) or best
|
2016-08-09 19:03:55 +02:00
|
|
|
-exact ................. preserve RGB values in transparent area, default=off
|
2014-06-18 16:45:34 +02:00
|
|
|
-blend_alpha <hex> ..... blend colors against background color
|
2013-04-03 04:14:14 +02:00
|
|
|
expressed as RGB values written in
|
|
|
|
hexadecimal, e.g. 0xc0e0d0 for red=0xc0
|
2014-06-18 16:45:34 +02:00
|
|
|
green=0xe0 and blue=0xd0
|
|
|
|
-noalpha ............... discard any transparency information
|
2016-08-09 19:03:55 +02:00
|
|
|
-lossless .............. encode image losslessly, default=off
|
2015-12-17 03:13:02 +01:00
|
|
|
-near_lossless <int> ... use near-lossless image
|
2016-08-09 19:03:55 +02:00
|
|
|
preprocessing (0..100=off), default=100
|
2014-06-18 16:45:34 +02:00
|
|
|
-hint <string> ......... specify image characteristics hint,
|
|
|
|
one of: photo, picture or graph
|
2011-02-19 08:33:46 +01:00
|
|
|
|
2013-01-11 21:25:36 +01:00
|
|
|
-metadata <string> ..... comma separated list of metadata to
|
|
|
|
copy from the input to the output if present.
|
2013-03-13 22:04:20 +01:00
|
|
|
Valid values: all, none (default), exif, icc, xmp
|
2013-01-11 21:25:36 +01:00
|
|
|
|
2011-02-19 08:33:46 +01:00
|
|
|
-short ................. condense printed message
|
2014-06-18 16:45:34 +02:00
|
|
|
-quiet ................. don't print anything
|
|
|
|
-version ............... print version number and exit
|
|
|
|
-noasm ................. disable all assembly optimizations
|
2011-02-19 08:33:46 +01:00
|
|
|
-v ..................... verbose, e.g. print encoding/decoding times
|
2011-12-01 11:24:50 +01:00
|
|
|
-progress .............. report encoding progress
|
|
|
|
|
2011-02-19 08:33:46 +01:00
|
|
|
Experimental Options:
|
2014-06-18 16:45:34 +02:00
|
|
|
-jpeg_like ............. roughly match expected JPEG size
|
|
|
|
-af .................... auto-adjust filter strength
|
2011-02-19 08:33:46 +01:00
|
|
|
-pre <int> ............. pre-processing filter
|
|
|
|
|
|
|
|
The main options you might want to try in order to further tune the
|
|
|
|
visual quality are:
|
|
|
|
-preset
|
|
|
|
-sns
|
|
|
|
-f
|
|
|
|
-m
|
|
|
|
|
|
|
|
Namely:
|
2011-07-16 03:58:56 +02:00
|
|
|
* 'preset' will set up a default encoding configuration targeting a
|
2011-02-19 08:33:46 +01:00
|
|
|
particular type of input. It should appear first in the list of options,
|
|
|
|
so that subsequent options can take effect on top of this preset.
|
|
|
|
Default value is 'default'.
|
|
|
|
* 'sns' will progressively turn on (when going from 0 to 100) some additional
|
|
|
|
visual optimizations (like: segmentation map re-enforcement). This option
|
|
|
|
will balance the bit allocation differently. It tries to take bits from the
|
|
|
|
"easy" parts of the picture and use them in the "difficult" ones instead.
|
|
|
|
Usually, raising the sns value (at fixed -q value) leads to larger files,
|
|
|
|
but with better quality.
|
|
|
|
Typical value is around '75'.
|
|
|
|
* 'f' option directly links to the filtering strength used by the codec's
|
2012-07-19 20:40:42 +02:00
|
|
|
in-loop processing. The higher the value, the smoother the
|
|
|
|
highly-compressed area will look. This is particularly useful when aiming
|
|
|
|
at very small files. Typical values are around 20-30. Note that using the
|
2013-02-15 10:08:52 +01:00
|
|
|
option -strong/-nostrong will change the type of filtering. Use "-f 0" to
|
|
|
|
turn filtering off.
|
2011-02-19 08:33:46 +01:00
|
|
|
* 'm' controls the trade-off between encoding speed and quality. Default is 4.
|
|
|
|
You can try -m 5 or -m 6 to explore more (time-consuming) encoding
|
|
|
|
possibilities. A lower value will result in faster encoding at the expense
|
|
|
|
of quality.
|
|
|
|
|
|
|
|
Decoding tool:
|
|
|
|
==============
|
|
|
|
|
2011-08-31 02:21:53 +02:00
|
|
|
There is a decoding sample in examples/dwebp.c which will take
|
2011-02-19 08:33:46 +01:00
|
|
|
a .webp file and decode it to a PNG image file (amongst other formats).
|
|
|
|
This is simply to demonstrate the use of the API. You can verify the
|
|
|
|
file test.webp decodes to exactly the same as test_ref.ppm by using:
|
2010-09-30 15:34:38 +02:00
|
|
|
|
2011-02-19 08:33:46 +01:00
|
|
|
cd examples
|
|
|
|
./dwebp test.webp -ppm -o test.ppm
|
|
|
|
diff test.ppm test_ref.ppm
|
2010-09-30 15:34:38 +02:00
|
|
|
|
2011-06-20 09:45:15 +02:00
|
|
|
The full list of options is available using -h:
|
|
|
|
|
|
|
|
> dwebp -h
|
|
|
|
Usage: dwebp in_file [options] [-o out_file]
|
|
|
|
|
|
|
|
Decodes the WebP image file to PNG format [Default]
|
|
|
|
Use following options to convert into alternate image formats:
|
2012-08-03 01:11:02 +02:00
|
|
|
-pam ......... save the raw RGBA samples as a color PAM
|
|
|
|
-ppm ......... save the raw RGB samples as a color PPM
|
2013-04-10 03:51:59 +02:00
|
|
|
-bmp ......... save as uncompressed BMP format
|
2013-05-09 12:57:50 +02:00
|
|
|
-tiff ........ save as uncompressed TIFF format
|
2011-06-20 09:45:15 +02:00
|
|
|
-pgm ......... save the raw YUV samples as a grayscale PGM
|
2013-04-10 03:51:59 +02:00
|
|
|
file with IMC4 layout
|
|
|
|
-yuv ......... save the raw YUV samples in flat layout
|
2013-01-28 23:22:14 +01:00
|
|
|
|
2011-06-20 09:45:15 +02:00
|
|
|
Other options are:
|
2016-06-23 16:11:47 +02:00
|
|
|
-version ..... print version number and exit
|
2014-01-16 15:48:43 +01:00
|
|
|
-nofancy ..... don't use the fancy YUV420 upscaler
|
|
|
|
-nofilter .... disable in-loop filtering
|
|
|
|
-nodither .... disable dithering
|
2013-12-18 06:51:41 +01:00
|
|
|
-dither <d> .. dithering strength (in 0..100)
|
2014-06-18 16:45:34 +02:00
|
|
|
-alpha_dither use alpha-plane dithering if needed
|
2011-07-22 22:09:10 +02:00
|
|
|
-mt .......... use multi-threading
|
2011-06-20 09:45:15 +02:00
|
|
|
-crop <x> <y> <w> <h> ... crop output with the given rectangle
|
2015-08-18 04:31:10 +02:00
|
|
|
-resize <w> <h> ......... scale the output (*after* any cropping)
|
2014-01-16 15:48:43 +01:00
|
|
|
-flip ........ flip the output vertically
|
|
|
|
-alpha ....... only save the alpha plane
|
2013-12-18 06:51:41 +01:00
|
|
|
-incremental . use incremental decoding (useful for tests)
|
2016-06-23 16:11:47 +02:00
|
|
|
-h ........... this help message
|
|
|
|
-v ........... verbose (e.g. print encoding/decoding times)
|
2015-08-18 05:07:46 +02:00
|
|
|
-quiet ....... quiet mode, don't print anything
|
2014-01-16 15:48:43 +01:00
|
|
|
-noasm ....... disable all assembly optimizations
|
2011-02-19 08:33:46 +01:00
|
|
|
|
2017-11-24 08:58:22 +01:00
|
|
|
WebP file analysis tool:
|
|
|
|
========================
|
|
|
|
|
|
|
|
'webpinfo' can be used to print out the chunk level structure and bitstream
|
|
|
|
header information of WebP files. It can also check if the files are of valid
|
|
|
|
WebP format.
|
|
|
|
|
|
|
|
Usage: webpinfo [options] in_files
|
|
|
|
Note: there could be multiple input files;
|
|
|
|
options must come before input files.
|
|
|
|
Options:
|
2017-11-24 23:17:51 +01:00
|
|
|
-version ........... Print version number and exit.
|
2017-11-24 08:58:22 +01:00
|
|
|
-quiet ............. Do not show chunk parsing information.
|
|
|
|
-diag .............. Show parsing error diagnosis.
|
|
|
|
-summary ........... Show chunk stats summary.
|
|
|
|
-bitstream_info .... Parse bitstream header.
|
|
|
|
|
2011-12-13 23:02:04 +01:00
|
|
|
Visualization tool:
|
|
|
|
===================
|
|
|
|
|
|
|
|
There's a little self-serve visualization tool called 'vwebp' under the
|
|
|
|
examples/ directory. It uses OpenGL to open a simple drawing window and show
|
2013-03-16 20:35:49 +01:00
|
|
|
a decoded WebP file. It's not yet integrated in the automake build system, but
|
|
|
|
you can try to manually compile it using the recommendations below.
|
2011-12-13 23:02:04 +01:00
|
|
|
|
2013-03-08 04:31:27 +01:00
|
|
|
Usage: vwebp in_file [options]
|
2011-12-13 23:02:04 +01:00
|
|
|
|
2013-03-08 04:31:27 +01:00
|
|
|
Decodes the WebP image file and visualize it using OpenGL
|
|
|
|
Options are:
|
2016-06-25 04:25:52 +02:00
|
|
|
-version ..... print version number and exit
|
2014-06-18 16:45:34 +02:00
|
|
|
-noicc ....... don't use the icc profile if present
|
|
|
|
-nofancy ..... don't use the fancy YUV420 upscaler
|
|
|
|
-nofilter .... disable in-loop filtering
|
|
|
|
-dither <int> dithering strength (0..100), default=50
|
|
|
|
-noalphadither disable alpha plane dithering
|
2018-07-20 12:54:30 +02:00
|
|
|
-usebgcolor .. display background color
|
2014-06-18 16:45:34 +02:00
|
|
|
-mt .......... use multi-threading
|
|
|
|
-info ........ print info
|
2016-06-25 04:25:52 +02:00
|
|
|
-h ........... this help message
|
2013-03-08 04:31:27 +01:00
|
|
|
|
|
|
|
Keyboard shortcuts:
|
2014-06-18 16:45:34 +02:00
|
|
|
'c' ................ toggle use of color profile
|
2018-07-20 12:54:30 +02:00
|
|
|
'b' ................ toggle background color display
|
2014-06-18 16:45:34 +02:00
|
|
|
'i' ................ overlay file information
|
2016-11-25 15:31:54 +01:00
|
|
|
'd' ................ disable blending & disposal (debug)
|
2014-06-18 16:45:34 +02:00
|
|
|
'q' / 'Q' / ESC .... quit
|
2013-03-08 04:31:27 +01:00
|
|
|
|
|
|
|
Building:
|
|
|
|
---------
|
|
|
|
|
|
|
|
Prerequisites:
|
|
|
|
1) OpenGL & OpenGL Utility Toolkit (GLUT)
|
|
|
|
Linux:
|
|
|
|
$ sudo apt-get install freeglut3-dev mesa-common-dev
|
|
|
|
Mac + XCode:
|
|
|
|
- These libraries should be available in the OpenGL / GLUT frameworks.
|
|
|
|
Windows:
|
|
|
|
http://freeglut.sourceforge.net/index.php#download
|
|
|
|
|
|
|
|
2) (Optional) qcms (Quick Color Management System)
|
|
|
|
i. Download qcms from Mozilla / Chromium:
|
|
|
|
http://hg.mozilla.org/mozilla-central/file/0e7639e3bdfb/gfx/qcms
|
|
|
|
http://src.chromium.org/viewvc/chrome/trunk/src/third_party/qcms
|
|
|
|
ii. Build and archive the source files as libqcms.a / qcms.lib
|
|
|
|
iii. Update makefile.unix / Makefile.vc
|
|
|
|
a) Define WEBP_HAVE_QCMS
|
|
|
|
b) Update include / library paths to reference the qcms directory.
|
|
|
|
|
|
|
|
Build using makefile.unix / Makefile.vc:
|
|
|
|
$ make -f makefile.unix examples/vwebp
|
|
|
|
> nmake /f Makefile.vc CFG=release-static \
|
|
|
|
../obj/x64/release-static/bin/vwebp.exe
|
2011-12-13 23:02:04 +01:00
|
|
|
|
2016-12-02 11:44:17 +01:00
|
|
|
Animation creation tool:
|
|
|
|
========================
|
|
|
|
The utility 'img2webp' can turn a sequence of input images (PNG, JPEG, ...)
|
|
|
|
into an animated WebP file. It offers fine control over duration, encoding
|
|
|
|
modes, etc.
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
img2webp [file-level options] [image files...] [per-frame options...]
|
|
|
|
|
|
|
|
File-level options (only used at the start of compression):
|
|
|
|
-min_size ............ minimize size
|
|
|
|
-loop <int> .......... loop count (default: 0, = infinite loop)
|
|
|
|
-kmax <int> .......... maximum number of frame between key-frames
|
|
|
|
(0=only keyframes)
|
|
|
|
-kmin <int> .......... minimum number of frame between key-frames
|
|
|
|
(0=disable key-frames altogether)
|
|
|
|
-mixed ............... use mixed lossy/lossless automatic mode
|
|
|
|
-v ................... verbose mode
|
|
|
|
-h ................... this help
|
2018-04-03 14:50:58 +02:00
|
|
|
-version ............. print version number and exit
|
2016-12-02 11:44:17 +01:00
|
|
|
|
|
|
|
Per-frame options (only used for subsequent images input):
|
|
|
|
-d <int> ............. frame duration in ms (default: 100)
|
|
|
|
-lossless ........... use lossless mode (default)
|
|
|
|
-lossy ... ........... use lossy mode
|
|
|
|
-q <float> ........... quality
|
|
|
|
-m <int> ............. method to use
|
|
|
|
|
|
|
|
example: img2webp -loop 2 in0.png -lossy in1.jpg
|
|
|
|
-d 80 in2.tiff -o out.webp
|
|
|
|
|
2018-11-03 04:36:14 +01:00
|
|
|
Note: if a single file name is passed as the argument, the arguments will be
|
|
|
|
tokenized from this file. The file name must not start with the character '-'.
|
|
|
|
|
2013-12-18 06:56:14 +01:00
|
|
|
Animated GIF conversion:
|
|
|
|
========================
|
|
|
|
Animated GIF files can be converted to WebP files with animation using the
|
|
|
|
gif2webp utility available under examples/. The files can then be viewed using
|
|
|
|
vwebp.
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
gif2webp [options] gif_file -o webp_file
|
2014-07-24 05:02:43 +02:00
|
|
|
Options:
|
2016-06-25 04:26:07 +02:00
|
|
|
-h / -help ............. this help
|
2014-07-24 05:02:43 +02:00
|
|
|
-lossy ................. encode image using lossy compression
|
|
|
|
-mixed ................. for each frame in the image, pick lossy
|
|
|
|
or lossless compression heuristically
|
2013-12-18 06:56:14 +01:00
|
|
|
-q <float> ............. quality factor (0:small..100:big)
|
|
|
|
-m <int> ............... compression method (0=fast, 6=slowest)
|
2015-12-17 03:13:02 +01:00
|
|
|
-min_size .............. minimize output size (default:off)
|
|
|
|
lossless compression by default; can be
|
|
|
|
combined with -q, -m, -lossy or -mixed
|
|
|
|
options
|
2014-07-24 05:02:43 +02:00
|
|
|
-kmin <int> ............ min distance between key frames
|
|
|
|
-kmax <int> ............ max distance between key frames
|
2013-12-18 06:56:14 +01:00
|
|
|
-f <int> ............... filter strength (0=off..100)
|
|
|
|
-metadata <string> ..... comma separated list of metadata to
|
2014-07-24 05:02:43 +02:00
|
|
|
copy from the input to the output if present
|
2013-12-18 06:56:14 +01:00
|
|
|
Valid values: all, none, icc, xmp (default)
|
2017-09-19 08:38:09 +02:00
|
|
|
-loop_compatibility .... use compatibility mode for Chrome
|
|
|
|
version prior to M62 (inclusive)
|
2013-12-18 06:56:14 +01:00
|
|
|
-mt .................... use multi-threading if available
|
|
|
|
|
2014-07-24 05:02:43 +02:00
|
|
|
-version ............... print version number and exit
|
|
|
|
-v ..................... verbose
|
|
|
|
-quiet ................. don't print anything
|
2013-12-18 06:56:14 +01:00
|
|
|
|
|
|
|
Building:
|
|
|
|
---------
|
|
|
|
With the libgif development files installed, gif2webp can be built using
|
|
|
|
makefile.unix:
|
|
|
|
$ make -f makefile.unix examples/gif2webp
|
|
|
|
|
|
|
|
or using autoconf:
|
|
|
|
$ ./configure --enable-everything
|
|
|
|
$ make
|
|
|
|
|
2015-05-02 01:11:49 +02:00
|
|
|
Comparison of animated images:
|
|
|
|
==============================
|
|
|
|
Test utility anim_diff under examples/ can be used to compare two animated
|
|
|
|
images (each can be GIF or WebP).
|
|
|
|
|
2015-12-17 03:13:02 +01:00
|
|
|
Usage: anim_diff <image1> <image2> [options]
|
|
|
|
|
|
|
|
Options:
|
|
|
|
-dump_frames <folder> dump decoded frames in PAM format
|
|
|
|
-min_psnr <float> ... minimum per-frame PSNR
|
|
|
|
-raw_comparison ..... if this flag is not used, RGB is
|
|
|
|
premultiplied before comparison
|
2018-04-03 00:16:11 +02:00
|
|
|
-max_diff <int> ..... maximum allowed difference per channel
|
|
|
|
between corresponding pixels in subsequent
|
|
|
|
frames
|
2018-04-03 14:50:58 +02:00
|
|
|
-h .................. this help
|
|
|
|
-version ............ print version number and exit
|
2015-05-02 01:11:49 +02:00
|
|
|
|
|
|
|
Building:
|
|
|
|
---------
|
|
|
|
With the libgif development files and a C++ compiler installed, anim_diff can
|
|
|
|
be built using makefile.unix:
|
|
|
|
$ make -f makefile.unix examples/anim_diff
|
|
|
|
|
|
|
|
or using autoconf:
|
|
|
|
$ ./configure --enable-everything
|
|
|
|
$ make
|
|
|
|
|
2011-02-19 08:33:46 +01:00
|
|
|
Encoding API:
|
2011-08-31 02:21:53 +02:00
|
|
|
=============
|
2011-02-19 08:33:46 +01:00
|
|
|
|
|
|
|
The main encoding functions are available in the header src/webp/encode.h
|
|
|
|
The ready-to-use ones are:
|
|
|
|
size_t WebPEncodeRGB(const uint8_t* rgb, int width, int height, int stride,
|
|
|
|
float quality_factor, uint8_t** output);
|
|
|
|
size_t WebPEncodeBGR(const uint8_t* bgr, int width, int height, int stride,
|
|
|
|
float quality_factor, uint8_t** output);
|
|
|
|
size_t WebPEncodeRGBA(const uint8_t* rgba, int width, int height, int stride,
|
|
|
|
float quality_factor, uint8_t** output);
|
|
|
|
size_t WebPEncodeBGRA(const uint8_t* bgra, int width, int height, int stride,
|
|
|
|
float quality_factor, uint8_t** output);
|
|
|
|
|
|
|
|
They will convert raw RGB samples to a WebP data. The only control supplied
|
|
|
|
is the quality factor.
|
|
|
|
|
2012-07-17 20:56:24 +02:00
|
|
|
There are some variants for using the lossless format:
|
|
|
|
|
|
|
|
size_t WebPEncodeLosslessRGB(const uint8_t* rgb, int width, int height,
|
|
|
|
int stride, uint8_t** output);
|
|
|
|
size_t WebPEncodeLosslessBGR(const uint8_t* bgr, int width, int height,
|
|
|
|
int stride, uint8_t** output);
|
|
|
|
size_t WebPEncodeLosslessRGBA(const uint8_t* rgba, int width, int height,
|
|
|
|
int stride, uint8_t** output);
|
|
|
|
size_t WebPEncodeLosslessBGRA(const uint8_t* bgra, int width, int height,
|
|
|
|
int stride, uint8_t** output);
|
|
|
|
|
|
|
|
Of course in this case, no quality factor is needed since the compression
|
|
|
|
occurs without loss of the input values, at the expense of larger output sizes.
|
|
|
|
|
2011-08-31 02:21:53 +02:00
|
|
|
Advanced encoding API:
|
|
|
|
----------------------
|
2011-02-19 08:33:46 +01:00
|
|
|
|
|
|
|
A more advanced API is based on the WebPConfig and WebPPicture structures.
|
|
|
|
|
2011-08-31 02:21:53 +02:00
|
|
|
WebPConfig contains the encoding settings and is not tied to a particular
|
2011-02-19 08:33:46 +01:00
|
|
|
picture.
|
|
|
|
WebPPicture contains input data, on which some WebPConfig will be used for
|
|
|
|
compression.
|
|
|
|
The encoding flow looks like:
|
|
|
|
|
|
|
|
-------------------------------------- BEGIN PSEUDO EXAMPLE
|
|
|
|
|
|
|
|
#include <webp/encode.h>
|
|
|
|
|
|
|
|
// Setup a config, starting form a preset and tuning some additional
|
|
|
|
// parameters
|
|
|
|
WebPConfig config;
|
|
|
|
if (!WebPConfigPreset(&config, WEBP_PRESET_PHOTO, quality_factor))
|
|
|
|
return 0; // version error
|
|
|
|
}
|
|
|
|
// ... additional tuning
|
|
|
|
config.sns_strength = 90;
|
|
|
|
config.filter_sharpness = 6;
|
2011-07-16 03:58:56 +02:00
|
|
|
config_error = WebPValidateConfig(&config); // not mandatory, but useful
|
2011-02-19 08:33:46 +01:00
|
|
|
|
|
|
|
// Setup the input data
|
|
|
|
WebPPicture pic;
|
|
|
|
if (!WebPPictureInit(&pic)) {
|
|
|
|
return 0; // version error
|
|
|
|
}
|
|
|
|
pic.width = width;
|
|
|
|
pic.height = height;
|
|
|
|
// allocated picture of dimension width x height
|
|
|
|
if (!WebPPictureAllocate(&pic)) {
|
|
|
|
return 0; // memory error
|
|
|
|
}
|
2011-08-31 02:21:53 +02:00
|
|
|
// at this point, 'pic' has been initialized as a container,
|
2011-02-19 08:33:46 +01:00
|
|
|
// and can receive the Y/U/V samples.
|
|
|
|
// Alternatively, one could use ready-made import functions like
|
|
|
|
// WebPPictureImportRGB(), which will take care of memory allocation.
|
|
|
|
// In any case, past this point, one will have to call
|
|
|
|
// WebPPictureFree(&pic) to reclaim memory.
|
|
|
|
|
|
|
|
// Set up a byte-output write method. WebPMemoryWriter, for instance.
|
|
|
|
WebPMemoryWriter wrt;
|
2014-03-27 23:27:32 +01:00
|
|
|
WebPMemoryWriterInit(&wrt); // initialize 'wrt'
|
|
|
|
|
2011-02-19 08:33:46 +01:00
|
|
|
pic.writer = MyFileWriter;
|
|
|
|
pic.custom_ptr = my_opaque_structure_to_make_MyFileWriter_work;
|
|
|
|
|
|
|
|
// Compress!
|
2011-07-16 03:58:56 +02:00
|
|
|
int ok = WebPEncode(&config, &pic); // ok = 0 => error occurred!
|
2011-02-19 08:33:46 +01:00
|
|
|
WebPPictureFree(&pic); // must be called independently of the 'ok' result.
|
|
|
|
|
|
|
|
// output data should have been handled by the writer at that point.
|
2014-03-27 23:27:32 +01:00
|
|
|
// -> compressed data is the memory buffer described by wrt.mem / wrt.size
|
|
|
|
|
|
|
|
// deallocate the memory used by compressed data
|
|
|
|
WebPMemoryWriterClear(&wrt);
|
2011-02-19 08:33:46 +01:00
|
|
|
|
|
|
|
-------------------------------------- END PSEUDO EXAMPLE
|
|
|
|
|
|
|
|
Decoding API:
|
|
|
|
=============
|
|
|
|
|
|
|
|
This is mainly just one function to call:
|
|
|
|
|
|
|
|
#include "webp/decode.h"
|
2012-04-18 01:01:33 +02:00
|
|
|
uint8_t* WebPDecodeRGB(const uint8_t* data, size_t data_size,
|
2012-07-19 20:40:42 +02:00
|
|
|
int* width, int* height);
|
2011-02-19 08:33:46 +01:00
|
|
|
|
|
|
|
Please have a look at the file src/webp/decode.h for the details.
|
2011-07-16 03:58:56 +02:00
|
|
|
There are variants for decoding in BGR/RGBA/ARGB/BGRA order, along with
|
|
|
|
decoding to raw Y'CbCr samples. One can also decode the image directly into a
|
|
|
|
pre-allocated buffer.
|
2011-02-19 08:33:46 +01:00
|
|
|
|
2012-07-19 20:40:42 +02:00
|
|
|
To detect a WebP file and gather the picture's dimensions, the function:
|
2012-04-18 01:01:33 +02:00
|
|
|
int WebPGetInfo(const uint8_t* data, size_t data_size,
|
2012-07-19 20:40:42 +02:00
|
|
|
int* width, int* height);
|
2011-02-19 08:33:46 +01:00
|
|
|
is supplied. No decoding is involved when using it.
|
|
|
|
|
2011-03-24 23:50:02 +01:00
|
|
|
Incremental decoding API:
|
|
|
|
=========================
|
|
|
|
|
|
|
|
In the case when data is being progressively transmitted, pictures can still
|
|
|
|
be incrementally decoded using a slightly more complicated API. Decoder state
|
|
|
|
is stored into an instance of the WebPIDecoder object. This object can be
|
|
|
|
created with the purpose of decoding either RGB or Y'CbCr samples.
|
|
|
|
For instance:
|
|
|
|
|
2012-04-28 04:20:13 +02:00
|
|
|
WebPDecBuffer buffer;
|
|
|
|
WebPInitDecBuffer(&buffer);
|
|
|
|
buffer.colorspace = MODE_BGR;
|
|
|
|
...
|
|
|
|
WebPIDecoder* idec = WebPINewDecoder(&buffer);
|
2011-03-24 23:50:02 +01:00
|
|
|
|
|
|
|
As data is made progressively available, this incremental-decoder object
|
2011-03-25 00:32:29 +01:00
|
|
|
can be used to decode the picture further. There are two (mutually exclusive)
|
2011-03-24 23:50:02 +01:00
|
|
|
ways to pass freshly arrived data:
|
|
|
|
|
|
|
|
either by appending the fresh bytes:
|
|
|
|
|
2011-03-25 00:32:29 +01:00
|
|
|
WebPIAppend(idec, fresh_data, size_of_fresh_data);
|
2011-03-24 23:50:02 +01:00
|
|
|
|
|
|
|
or by just mentioning the new size of the transmitted data:
|
|
|
|
|
|
|
|
WebPIUpdate(idec, buffer, size_of_transmitted_buffer);
|
|
|
|
|
2012-07-19 20:40:42 +02:00
|
|
|
Note that 'buffer' can be modified between each call to WebPIUpdate, in
|
2011-07-16 03:58:56 +02:00
|
|
|
particular when the buffer is resized to accommodate larger data.
|
2011-03-24 23:50:02 +01:00
|
|
|
|
|
|
|
These functions will return the decoding status: either VP8_STATUS_SUSPENDED if
|
2012-07-19 20:40:42 +02:00
|
|
|
decoding is not finished yet or VP8_STATUS_OK when decoding is done. Any other
|
|
|
|
status is an error condition.
|
2011-03-24 23:50:02 +01:00
|
|
|
|
2012-07-19 20:40:42 +02:00
|
|
|
The 'idec' object must always be released (even upon an error condition) by
|
|
|
|
calling: WebPDelete(idec).
|
2011-03-24 23:50:02 +01:00
|
|
|
|
|
|
|
To retrieve partially decoded picture samples, one must use the corresponding
|
2012-08-04 00:15:34 +02:00
|
|
|
method: WebPIDecGetRGB or WebPIDecGetYUVA.
|
2011-03-24 23:50:02 +01:00
|
|
|
It will return the last displayable pixel row.
|
|
|
|
|
|
|
|
Lastly, note that decoding can also be performed into a pre-allocated pixel
|
|
|
|
buffer. This buffer must be passed when creating a WebPIDecoder, calling
|
2012-08-04 00:15:34 +02:00
|
|
|
WebPINewRGB() or WebPINewYUVA().
|
2011-03-24 23:50:02 +01:00
|
|
|
|
|
|
|
Please have a look at the src/webp/decode.h header for further details.
|
|
|
|
|
2011-08-25 05:41:08 +02:00
|
|
|
Advanced Decoding API:
|
2011-08-31 02:21:53 +02:00
|
|
|
======================
|
2011-08-25 05:41:08 +02:00
|
|
|
|
2011-08-31 02:21:53 +02:00
|
|
|
WebP decoding supports an advanced API which provides on-the-fly cropping and
|
|
|
|
rescaling, something of great usefulness on memory-constrained environments like
|
|
|
|
mobile phones. Basically, the memory usage will scale with the output's size,
|
|
|
|
not the input's, when one only needs a quick preview or a zoomed in portion of
|
|
|
|
an otherwise too-large picture. Some CPU can be saved too, incidentally.
|
2011-08-25 05:41:08 +02:00
|
|
|
|
|
|
|
-------------------------------------- BEGIN PSEUDO EXAMPLE
|
|
|
|
// A) Init a configuration object
|
|
|
|
WebPDecoderConfig config;
|
|
|
|
CHECK(WebPInitDecoderConfig(&config));
|
|
|
|
|
|
|
|
// B) optional: retrieve the bitstream's features.
|
|
|
|
CHECK(WebPGetFeatures(data, data_size, &config.input) == VP8_STATUS_OK);
|
|
|
|
|
|
|
|
// C) Adjust 'config' options, if needed
|
2011-09-09 07:50:27 +02:00
|
|
|
config.options.no_fancy_upsampling = 1;
|
2011-08-25 05:41:08 +02:00
|
|
|
config.options.use_scaling = 1;
|
|
|
|
config.options.scaled_width = scaledWidth();
|
|
|
|
config.options.scaled_height = scaledHeight();
|
|
|
|
// etc.
|
|
|
|
|
|
|
|
// D) Specify 'config' output options for specifying output colorspace.
|
|
|
|
// Optionally the external image decode buffer can also be specified.
|
|
|
|
config.output.colorspace = MODE_BGRA;
|
|
|
|
// Optionally, the config.output can be pointed to an external buffer as
|
|
|
|
// well for decoding the image. This externally supplied memory buffer
|
|
|
|
// should be big enough to store the decoded picture.
|
2011-09-09 07:50:27 +02:00
|
|
|
config.output.u.RGBA.rgba = (uint8_t*) memory_buffer;
|
2011-08-25 05:41:08 +02:00
|
|
|
config.output.u.RGBA.stride = scanline_stride;
|
|
|
|
config.output.u.RGBA.size = total_size_of_the_memory_buffer;
|
|
|
|
config.output.is_external_memory = 1;
|
|
|
|
|
|
|
|
// E) Decode the WebP image. There are two variants w.r.t decoding image.
|
|
|
|
// The first one (E.1) decodes the full image and the second one (E.2) is
|
|
|
|
// used to incrementally decode the image using small input buffers.
|
|
|
|
// Any one of these steps can be used to decode the WebP image.
|
|
|
|
|
|
|
|
// E.1) Decode full image.
|
|
|
|
CHECK(WebPDecode(data, data_size, &config) == VP8_STATUS_OK);
|
|
|
|
|
|
|
|
// E.2) Decode image incrementally.
|
|
|
|
WebPIDecoder* const idec = WebPIDecode(NULL, NULL, &config);
|
|
|
|
CHECK(idec != NULL);
|
|
|
|
while (bytes_remaining > 0) {
|
|
|
|
VP8StatusCode status = WebPIAppend(idec, input, bytes_read);
|
|
|
|
if (status == VP8_STATUS_OK || status == VP8_STATUS_SUSPENDED) {
|
|
|
|
bytes_remaining -= bytes_read;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WebPIDelete(idec);
|
|
|
|
|
|
|
|
// F) Decoded image is now in config.output (and config.output.u.RGBA).
|
|
|
|
// It can be saved, displayed or otherwise processed.
|
|
|
|
|
|
|
|
// G) Reclaim memory allocated in config's object. It's safe to call
|
|
|
|
// this function even if the memory is external and wasn't allocated
|
|
|
|
// by WebPDecode().
|
|
|
|
WebPFreeDecBuffer(&config.output);
|
|
|
|
|
|
|
|
-------------------------------------- END PSEUDO EXAMPLE
|
|
|
|
|
2010-09-30 15:34:38 +02:00
|
|
|
Bugs:
|
|
|
|
=====
|
|
|
|
|
2016-06-23 22:53:15 +02:00
|
|
|
Please report all bugs to the issue tracker:
|
2015-10-20 05:06:50 +02:00
|
|
|
https://bugs.chromium.org/p/webp
|
2010-09-30 15:34:38 +02:00
|
|
|
Patches welcome! See this page to get started:
|
|
|
|
http://www.webmproject.org/code/contribute/submitting-patches/
|
|
|
|
|
|
|
|
Discuss:
|
|
|
|
========
|
|
|
|
|
|
|
|
Email: webp-discuss@webmproject.org
|
2011-07-16 03:58:56 +02:00
|
|
|
Web: http://groups.google.com/a/webmproject.org/group/webp-discuss
|