Merge commit 'v0.1.99'

* commit 'v0.1.99': (39 commits)
  Update ChangeLog
  add extra precision about default values and behaviour
  header/doc clean up
  Makefile.vc: fix webpmux.exe *-dynamic builds
  remove INAM, ICOP, ... chunks from the test webp file.
  harmonize authors as "Name (mail@address)"
  makefile.unix: provide examples/webpmux target
  update NEWS
  README: cosmetics
  man/cwebp.1: wording, change the date
  add a very crude progress report for lossless
  rename 'use_argb_input' to 'use_argb'
  add some padding bytes areas for later use
  fixing the findings by Frederic Kayser to the bitstream spec
  add missing ABI compatibility checks
  Doc: container spec text tweaks
  add ABI compatibility check
  mux.h: remove '* const' from function parameters
  encode.h: remove '* const' from function parameters
  decode.h: remove '* const' from function parameters
  ...

Conflicts:
	src/mux/muxinternal.c

Change-Id: I635d095c451742e878088464fe6232637a331511
This commit is contained in:
James Zern 2012-07-21 12:20:19 -07:00
commit cbee59eba4
61 changed files with 1617 additions and 942 deletions

View File

@ -1,9 +1,14 @@
Contributors:
- James Zern (jzern at google dot com)
- Jan Engelhardt (jengelh at medozas dot de)
- Johann (johannkoenig at google dot com)
- Lou Quillio (louquillio at google dot com)
- Martin Olsson (mnemo at minimum dot se)
- Mikołaj Zalewski (mikolajz at google dot com)
- Noel Chromium (noel at chromium dot org)
- Pascal Massimino (pascal dot massimino at gmail dot com)
- Pierre Joye (pierre dot php at gmail dot com)
- Scott LaVarnway (slavarnway at google dot com)
- Somnath Banerjee (somnath dot banerjee at gmail dot com)
- Urvang Joshi (urvang at google dot com)
- Vikas Arora (vikasa at google dot com)

View File

@ -24,22 +24,26 @@ LOCAL_SRC_FILES := \
src/dsp/yuv.c \
src/enc/alpha.c \
src/enc/analysis.c \
src/enc/backward_references.c \
src/enc/config.c \
src/enc/cost.c \
src/enc/filter.c \
src/enc/frame.c \
src/enc/histogram.c \
src/enc/iterator.c \
src/enc/layer.c \
src/enc/picture.c \
src/enc/quant.c \
src/enc/syntax.c \
src/enc/tree.c \
src/enc/vp8l.c \
src/enc/webpenc.c \
src/utils/bit_reader.c \
src/utils/bit_writer.c \
src/utils/color_cache.c \
src/utils/filters.c \
src/utils/huffman.c \
src/utils/huffman_encode.c \
src/utils/quant_levels.c \
src/utils/rescaler.c \
src/utils/thread.c \

623
ChangeLog
View File

@ -1,3 +1,626 @@
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
ff9fd1b Makefile.vc: fix webpmux.exe *-dynamic builds
8aacc7b remove INAM, ICOP, ... chunks from the test webp file.
2fc1301 harmonize authors as "Name (mail@address)"
4a9f37b Merge "update NEWS" into 0.2.0
7415ae1 makefile.unix: provide examples/webpmux target
ce82ced update NEWS
641e28e Merge "man/cwebp.1: wording, change the date" into 0.2.0
c37c23e README: cosmetics
3976dcd man/cwebp.1: wording, change the date
3e5bbe1 Merge "rename 'use_argb_input' to 'use_argb'" into 0.2.0
ce90847 Merge "add some padding bytes areas for later use" into 0.2.0
2390dab Merge "fixing the findings by Frederic Kayser to the bitstream spec" into 0.2.0
0275159 add a very crude progress report for lossless
dd10817 rename 'use_argb_input' to 'use_argb'
90516ae add some padding bytes areas for later use
d03b250 fixing the findings by Frederic Kayser to the bitstream spec
ce156af add missing ABI compatibility checks
9d45416 Merge "Doc: container spec text tweaks" into 0.2.0
4e2e0a8 Doc: container spec text tweaks
f7f16a2 add ABI compatibility check
2a77557 Merge "swig: add WebPEncodeLossless* wrappers" into 0.2.0
a3ec622 mux.h: remove '* const' from function parameters
31426eb encode.h: remove '* const' from function parameters
9838e5d decode.h: remove '* const' from function parameters
4972302 swig: add WebPEncodeLossless* wrappers
9ff00ca bump encoder/decoder versions
c2416c9 add lossless quick encoding functions to the public API
4c1f5d6 Merge "NEWS: mention decode_vp8.h is no longer installed" into 0.2.0
6cb2277 NEWS: mention decode_vp8.h is no longer installed
d5e5ad6 move decode_vp8.h from webp/ to dec/
8d3b04a Merge "header clean-up" into 0.2.0
02201c3 Merge "remove one malloc() by making color_cache non dynamic" into 0.2.0
d708ec1 Merge "move MIN/MAX_HISTO_BITS to format_constants.h" into 0.2.0
ab2da3e Merge "add a malloc() check" into 0.2.0
2d571bd add a malloc() check
7f0c178 remove one malloc() by making color_cache non dynamic
6569cd7 Merge "VP8LFillBitWindow: use 64-bit path for msvc x64 builds" into 0.2.0
23d34f3 header clean-up
2a3ab6f move MIN/MAX_HISTO_BITS to format_constants.h
985d3da Merge "shuffle variables in HashChainFindCopy" into 0.2.0
cdf885c shuffle variables in HashChainFindCopy
c3b014d Android.mk: add missing lossless files
8c1cc6b makefile.unix dist: explicitly name installed includes
7f4647e Merge "clarify the colorspace naming and byte ordering of decoded samples" into 0.2.0
cbf6972 clarify the colorspace naming and byte ordering of decoded samples
ff771e7 don't install webp/decode_vp8.h
596dff7 VP8LFillBitWindow: use 64-bit path for msvc x64 builds
3ca7ce9 Merge "doc: remove non-finalized chunk references" into 0.2.0
1efaa5a Merge "bump versions" into 0.2.0
51fa13e Merge "README: update cwebp help output" into 0.2.0
12f9aed README: update cwebp help output
f0b5def bump versions
4c42a61 update AUTHORS
6431a1c doc: remove non-finalized chunk references
8130c4c Merge "build: remove libwebpmux from default targets/config"
23b4443 Merge "configure: broaden test for libpng-config"
85bff2c Merge "doc: correct lossless prefix coding table & code"
05108f6 Merge "More spec/code matching in mux:"
6808e69 More spec/code matching in mux:
bd2b46f Merge "doc/webp-container-spec: light cosmetics"
20ead32 doc/webp-container-spec: light cosmetics (full)
1d40a8b configure: add pthread detection
b5e9067 fix some int <-> size_t mix for buffer sizes
e41a759 build: remove libwebpmux from default targets/config
0fc2baa configure: broaden test for libpng-config
45b8272 Merge "restore authorship to lossless bitstream doc"
06ba059 restore authorship to lossless bitstream doc
44a09a3 add missing description of the alpha filtering methods
63db87d Merge "vwebp: add checkboard background for alpha display"
a73b897 vwebp: add checkboard background for alpha display
939158c Merge "vwebp: fix info display"
b35c07d vwebp: fix info display
48b39eb fix underflow for very short bitstreams
7e62298 cosmetics: param alignment, manpage wording
1bd7dd5 Merge changes I7b0afb0d,I7ecc9708
ac69e63 Merge "Updated cwebp man's help for Alpha & Lossless."
c0e8859 Get rid of image_info_ from WebPChunk struct.
135ca69 WebP Container Spec:
eb6f9b8 Updated cwebp man's help for Alpha & Lossless.
0fa844f cosmetic fixes on assert and 'const' where applicable
7f22bd2 check limit of width * height is 32 bits
16c46e8 autoconf/make: cosmetics: break long lines
ab22a07 configure: add helper macro to define --with-*
c17699b configure: add libtiff test
0e09732 Merge "cwebp: fix crash with yuv input + lossless"
88a510f Merge "fix big-endian VP8LWriteBits"
da99e3b Merge "Makefile.vc: split mux into separate lib"
7bda392 cwebp: fix crash with yuv input + lossless
f56a369 fix big-endian VP8LWriteBits
54169d6 Merge "cwebp: name InputFileFormat members consistently"
e2feefa Makefile.vc: split mux into separate lib
27caa5a Merge "cwebp: add basic TIFF support"
d8921dd cwebp: name InputFileFormat members consistently
6f76d24 cwebp: add basic TIFF support
4691407 Merge changes If39ab7f5,I3658b5ae
cca7c7b Fixed nit: 10 -> 10.f
5d09a24 WebPMuxCreate() error handling:
777341c Fix a memleak in WebPMuxCreate()
61c9d16 doc: correct lossless prefix coding table & code
4c39757 Merge "mark VP8{,L}{GetInfo,CheckSignature} as WEBP_EXTERN"
e4e36cc Merge "Mux: Allow only some frames/tiles to have alpha."
ad2aad3 Merge "WebP Decoding error handling:"
97649c8 Mux: Allow only some frames/tiles to have alpha.
f864be3 Lower the quality settings for Alpha encoding.
3ba81bb WebP Decoding error handling:
fcc6992 add automatic YUVA/ARGB conversion during WebPEncode()
802e012 fix compilation in non-FANCY_UPSAMPLING mode
e012dfd make width/height coding match the spec
228d96a mark VP8{,L}{GetInfo,CheckSignature} as WEBP_EXTERN
637a314 remove the now unused *KeepA variants
d11f6fc webpmux returns error strings rather than numbers
fcec059 makefile.unix: cwebp: fix OSX link
6b811f1 Merge "doc: remove lossless pdf"
c963482 doc: remove lossless pdf
b9ae4f0 cosmetics after mux changes b74ed6e, b494ad5
b494ad5 Mux: only allow adding frame/tiles at the end.
2c341b0 Merge "Added image characteristic hint for the codec."
d373076 Added image characteristic hint for the codec.
2ed2adb Merge "msvc: add intrinsic based BitsLog2Floor"
e595e7c Merge "add demux.c to the makefiles"
da47b5b Merge "demux: add {Next,Prev}Chunk"
e5f4674 add demux.c to the makefiles
4708393 demux: add {Next,Prev}Chunk
e8a0a82 demux: quiet msvc warnings
7f8472a Update the WebP Container Spec.
31b68fe cleanup WebPPicture struct and API
9144a18 add overflow check before calling malloc()
81720c9 consistency cosmetics
2ebe839 Merge "Add kramdown version information to README"
7144308 enc/vp8l.c: fix build
b7ac19f Add kramdown version information to README
efdcb66 Merge "Edit for consistency, usage and grammar."
0822010 Enable alpha in vvwebp
8de9a08 Merge "Mux API change:"
b74ed6e Mux API change:
233a589 take picture->argb_stride into account for lossless coding
04e33f1 Edit for consistency, usage and grammar.
a575b4b Merge "cosmetics: add missing const"
8d99b0f Merge "cosmetics: remove unimplemented function proto"
69d0221 cosmetics: add missing const
5b08318 cosmetics: remove unimplemented function proto
b7fb0ed Log warning for unsupported options for lossless.
e1f769f msvc: add intrinsic based BitsLog2Floor
8a69c7d Bug-fix: Clamp backward dist to 1.
b5b6ac9 Merge "Bring the special writer 'WebPMemoryWriter' to public API"
a6a1909 Merge "Fix floating point exception with cwebp -progress"
f2cee06 Fix floating point exception with cwebp -progress
91b7a8c Bring the special writer 'WebPMemoryWriter' to public API
310e297 support resize and crop for RGBA input
a89835d Merge changes Ice662960,Ie8d7aa90,I2d996d5e,I01c04772
ce614c0 Merge "dec/vp8: avoid setting decoder status twice"
900285d dec/vp8: avoid setting decoder status twice
8227adc Merge changes I6f02b0d0,I5cbc9c0a,I9dd9d4ed,Id684d2a1
dcda59c Merge "demux: rename SetTile to SelectTile"
622ef12 demux: rename SetTile to SelectTile
81ebd37 Merge "demux: add {Next,Prev}Frame"
02dd37a demux: add {Next,Prev}Frame
4b79fa5 Merge "Limit the maximum size of huffman Image to 16MB."
9aa34b3 Manually number "chapters," as chapter numbers are used in the narrative.
2a4c6c2 Re-wrap at <= 72 columns
a45adc1 Apply inline emphasis and monospacing, per gdoc / PDF
9101120 Incorporate gdoc changes through 2012-06-08
7a18248 Removed CodeRay syntax declarations ...
b3ec18c Provide for code-block syntax highlighting.
709d770 Replace high ASCII artifacts (curly quotes, etc.).
930e8ab Lossless WebP doc largely ported to markdown text.
18cae37 msvc: silence some build warnings
b392308 Limit the maximum size of huffman Image to 16MB.
f180df2 Merge "libwebp/demux: add Frame/Chunk iteration"
2bbe1c9 Merge "Enable lossless encoder code"
d0601b0 Merge changes I1d97a633,I81c59093
78f3e34 Enable lossless encoder code
d974a9c Merge "libwebp/demux: add simple format parsing"
26bf223 Merge "libwebp: add WebPDemux stub functions"
2f66668 Merge "modify WebPParseHeaders to allow reuse by GetFeatures"
b402b1f libwebp/demux: add Frame/Chunk iteration
ad9ada3 libwebp/demux: add WebPDemuxGetI
2f2d4d5 libwebp/demux: add extended format parsing
962dcef libwebp/demux: add simple format parsing
f8f9408 libwebp: add WebPDemux stub functions
fb47bb5 Merge "NumNamedElements() should take an enum param."
7c68980 Fix asserts in Palette and BackwardReference code.
fbdcb7e NumNamedElements() should take an enum param.
fb4943b modify WebPParseHeaders to allow reuse by GetFeatures (old-decode-alph-3)
3697b5c write an ad-hoc EncodeImageInternal variant
eaee9e7 Bug-Fix: Decode small (less than 32 bytes) images.
0bceae4 Merge "cwebp: fix alpha reporting in stats output"
0424b1e Rebase default encoding settings.
c71ff9e cwebp: fix alpha reporting in stats output
e2ffe44 Merge "Stop indefinite recursion for Huffman Image."
70eb2bd Stop indefinite recursion for Huffman Image.
f3bab8e Update vwebp
6d5c797 Remove support for partial files in Mux.
f1df558 WebPMuxAssemble() returns WebPData*.
814a063 Rename 'Add' APIs to 'Set'.
bbb0218 Update Mux psuedo-code examples.
4fc4a47 Use WebPData in MUX set APIs
c67bc97 Merge "add WebPPictureImportRGBX() and WebPPictureImportBGRX()"
27519bc add WebPPictureImportRGBX() and WebPPictureImportBGRX()
f80cd27 factorize code in Import()
9b71502 histogram: add log2 wrapper
8c34378 Merge "fix some implicit type conversion warnings"
42f6df9 fix some implicit type conversion warnings
250c16e Merge "doc: update lossless pdf"
9d9daba Merge "add a PDF of the lossless spec"
8fbb918 prefer webp/types.h over stdint.h
0ca170c doc: update lossless pdf
0862ac6 add a PDF of the lossless spec
437999f introduce a generic WebPPictureHasTransparency() function
d2b6c6c cosmetic fixes after Idaba281a
b4e6645 Merge "add colorspace for premultiplied alpha"
48f8275 add colorspace for premultiplied alpha
069f903 Change in lossless bit-stream.
5f7bb3f Merge "WebPReportProgress: use non-encoder specific params"
f18281f WebPReportProgress: use non-encoder specific params
9ef3228 Add support for raw lossless bitstream in decoder.
7cbee29 Fix bug: InitIo reseting fancy_upsampling flag.
880fd98 vwebp: fix exit w/freeglut
1875d92 trap two unchecked error conditions
87b4a90 no need to have mux.h as noinst clause in enc/
88f41ec doc: fix bit alignment in VP8X chunk
52f5a4e Merge "fix bug with lossy-alpha output stride"
3bde22d fix bug with lossy-alpha output stride
42d61b6 update the spec for the lossy-alpha compression methods.
e75dc80 Move some more defines to format_constants.h
c13f663 Move consts to internal header format_constants.h
7f2dfc9 use a bit-set transforms_seen_ instead of looping
18da1f5 modulate alpha-compression effort according to config.method
f5f2fff Merge "Alpha flag fix for lossless."
c975c44 Alpha flag fix for lossless.
4f067fb Merge "Android: only build dec_neon with NEON support"
255c66b Android: only build dec_neon with NEON support
8f9117a cosmetics: signature fixes
39bf5d6 use header-less lossless bitstream for alpha channel
75d7f3b Merge "make input data be 'const' for VP8LInverseTransform()"
9a721c6 make input data be 'const' for VP8LInverseTransform()
9fc64ed Disallow re-use of same transformation.
98ec717 use a function pointer for ProcessRows()
f7ae5e3 cosmetics: join line
140b89a factor out buffer alloc in AllocateARGBBuffers()
a107dfa Rectify WebPParseOptionalChunks().
237eab6 Add two more color-spaces for lossless decoding.
27f417a fix orthographic typo
489ec33 add VP8LEncodeStream() to compress lossless image stream
fa8bc3d make WebPEncodingSetError() take a const picture
638528c bitstream update for lossy alpha compression
d73e63a add DequantizeLevels() placeholder
ec122e0 remove arch-dependent rand()
d40e765 fix alignment
1dd6a8b Merge "remove tcoder, switch alpha-plane compression to lossless"
3e863dd remove tcoder, switch alpha-plane compression to lossless
8d77dc2 Add support for lossless in mux:
831bd13 Make tile size a function of encoding method.
778c522 Merge "remove some variable shadowing"
817c9dc Few more HuffmanTreeToken conversions.
37a77a6 remove some variable shadowing
89c07c9 Merge "normalize example header includes"
4aff411 Merge "add example_util.[hc]"
00b29e2 normalize example header includes
061263a add example_util.[hc]
c6882c4 merge all tree processing into a single VP8LProcessTree()
9c7a3cf fix VP8LHistogramNumCodes to handle the case palette_code_bits == 0
b5551d2 Merge "Added HuffmanTreeCode Struct for tree codes."
8b85d01 Added HuffmanTreeCode Struct for tree codes.
093f76d Merge "Allocate single memory in GetHuffBitLengthsAndCodes."
41d8049 Allocate single memory in GetHuffBitLengthsAndCodes.
1b04f6d Correct size in VP8L header.
2924a5a Makefile.vc: split object lists based on directory
c8f2416 Merge "add assert(tokens)"
4323994 add assert(tokens)
9f54745 Catch an error in DecodeImageData().
ac8e5e4 minor typo and style fix
9f566d1 clean-up around Huffman-encode
c579a71 Introduce CHUNK_SIZE_BYTES in muxi.h.
14757f8 Make sure huffman trees always have valid symbols
4105061 makefile.unix: add support for building vwebp
48b3772 Merge "fixed signed/unsigned comparison warning"
57f696d Merge "EncodeImageInternal: fix potential leak"
d972cdf EncodeImageInternal: fix potential leak
5cd12c3 fixed signed/unsigned comparison warning
cdca30d Merge "cosmetics: shorten long line"
e025fb5 cosmetics: shorten long line
22671ed Merge "enc/vp8l: fix double free on error"
e1b9b05 Merge "cosmetics: VP8LCreateHuffmanTree: fix indent"
a8e725f enc/vp8l: fix double free on error
27541fb cosmetics: VP8LCreateHuffmanTree: fix indent
1d38b25 cwebp/windows: use MAKE_REFGUID where appropriate
817ef6e Merge "cwebp: fix WIC/Microsoft SDK compatibility issue"
902d3e3 cwebp: fix WIC/Microsoft SDK compatibility issue
89d803c Merge "Fix a crash due to wrong pointer-integer arithmetic."
cb1bd74 Merge "Fix a crash in lossless decoder."
de2fe20 Merge "Some cleanup in VP8LCreateHuffmanTree() (and related functions CompareHuffmanTrees() and SetBitDepths()): - Move 'tree_size' initialization and malloc for 'tree + tree_pool' outside the loop. - Some renames/tweaks for readability."
ce69177 Fix a crash due to wrong pointer-integer arithmetic.
e40a368 Fix a crash in lossless decoder.
3927ff3 remove unneeded error condition for WebPMuxNumNamedElements()
2c140e1 Some cleanup in VP8LCreateHuffmanTree() (and related functions CompareHuffmanTrees() and SetBitDepths()): - Move 'tree_size' initialization and malloc for 'tree + tree_pool' outside the loop. - Some renames/tweaks for readability.
861a5b7 add support for animation
eb5c16c Merge "Set correct encode size in encoder's stats."
4abe04a fix the return value and handle missing input file case.
2fafb85 Set correct encode size in encoder's stats.
e7167a2 Provide one entry point for backward references.
c4ccab6 Print relevant lossless encoding stats in cwebp.
e3302cf GetHuffBitLengthsAndCodes: reduce level of indirection
b5f2a9e enc/vp8l: fix uninitialized variable warning
7885f8b makefile.unix: add lossless encoder files
1261a4c Merge "cosmetics"
3926b5b Merge "dsp/cpu.c: Android: fix crash on non-neon arm builds"
834f937 dsp/cpu.c: Android: fix crash on non-neon arm builds
126e160 cosmetics
e38602d Merge branch 'lossless_encoder'
e8d3d6a split StoreHuffmanCode() into smaller functions
d0d8899 more consolidation: introduce VP8LHistogramSet
1a210ef big code clean-up and refactoring and optimization
41b5c8f Some cosmetics in histogram.c
ada6ff7 Approximate FastLog between value range [256, 8192]
ec123ca Forgot to update out_bit_costs to symbol_bit_costs at one instance.
cf33ccd Evaluate output cluster's bit_costs once in HistogramRefine.
781c01f Simple Huffman code changes.
a2849bc Lossless decoder: remove an unneeded param in ReadHuffmanCodeLengths().
b39e748 Reducing emerging palette size from 11 to 9 bits.
bfc73db Move GetHistImageSymbols to histogram.c
889a578 Improve predict vs no-predict heuristic.
01f5066 code-moving and clean-up
31035f3 reduce memory usage by allocating only one histo
fbb501b Restrict histo_bits to ensure histo_image size is under 32MB
8415ddf further simplification for the meta-Huffman coding
e491729 A quick pass of cleanup in backward reference code
83332b3 Make transform bits a function of encode method (-m).
72920ca introduce -lossless option, protected by USE_LOSSLESS_ENCODER
c6ac4df Run TraceBackwards for higher qualities.
412222c Make histo_bits and transform_bits function of quality.
149b509 Update lossless encoder strategy:
0e6fa06 cache_bits passed to EncodeImageInternal()
e38b40a Factorize code for clearing HtreeGroup.
6f4a16e Removing the indirection of meta-huffman tables.
3d33ecd Some renaming/comments related to palette in lossless encoder.
4d02d58 Lossless encoder: correction in Palette storage
4a63623 fix a memleak in EncodeImageInternal()
0993a61 Full and final fix for prediction transform
afd2102 Fix cross-color transform in lossless encoder
b96d874 Need to write a '0' bit at the end of transforms.
54dad7e Color cache size should be counted as 0 when cache bits = 0
4f0c5ca Fix prediction transform in lossless encoder.
36dabda Fix memory leak in method EncodeImageInternal for histogram_image.
352a4f4 Get rid of PackLiteralBitLengths()
d673b6b Change the predictor function to pass left pixel
b2f9946 Fix CopyTileWithPrediction()
84547f5 Add EncodeImageInternal() method.
6b38378 Guard the lossless encoder (in flux) under a flag
09f7532 Fix few nits (const qualifiers)
648be39 Added implementation for various lossless functions
32714ce Add VP8L prefix to backward ref & histogram methods.
fcba7be Fixed header file tag (WEBP_UTILS_HUFFMAN_ENCODE_H_)
bc70374 Add backward_ref, histogram & huffman encode modules from lossless.
fdccaad Fixing nits
227110c libwebp interface changes for lossless encoding.
50679ac minor style fixes
b38dfcc remove unneeded reference to NUM_LITERAL_CODES
8979675 harmonize header description
c04eb7b tcoder.c: define NOT_HAVE_LOG2 for MSVC builds
9a214fa Merge "VP8[L]GetInfo: check input pointers"
5c5be8b VP8[L]GetInfo: check input pointers
0c188fe Merge changes I431acdfe,I713659b7
b3515c6 mux: drop 'chunk' from ChunkInfo member names
aea7923 muxi.h: remove some unused defines
0142249 update NEWS file for next release
29e3f7e Merge "dec: remove deprecated WebPINew()"
4718e44 Merge "muxedit: a few more size_t changes"
82654f9 Merge "muxedit: remove a few redundant NULL checks"
02f27fb dec: remove deprecated WebPINew()
ccddb3f muxedit: remove a few redundant NULL checks
a6cdf71 muxedit: a few more size_t changes
a384689 Merge "mux: remove unused LIST_ID"
11ae46a alpha.c: quiet some size_t -> int conversion warnings
dee4669 mux: remove unused LIST_ID
03f1f49 mux: add version checked entry points
6a0abda Merge "doc: tile/alpha corrections"
c8139fb Merge "few cosmetics"
6833873 Merge "lossless: remove some size_t -> int conversions"
5249e94 doc: tile/alpha corrections
d96e722 huffman: quiet int64 -> int conversion warning
532020f lossless: remove some size_t -> int conversions
23be6ed few cosmetics
1349eda Merge "configure: AC_ARG_* use AS_HELP_STRING"
bfbcc60 configure: AC_ARG_* use AS_HELP_STRING
1427ca8 Merge "Makefile.am: header file maintenance"
087332e Merge "remove unused parameter 'round' from CalcProba()"
9630e16 remove unused parameter 'round' from CalcProba()
92092ea Merge "bit_reader.h: correct include"
a87fc3f Merge "mux: ensure # images = # tiles"
53af99b Merge "mux: use size_t consistently"
39a57da Makefile.am: header file maintenance
1bd0bd0 bit_reader.h: correct include
326a3c6 mux: ensure # images = # tiles
95667b8 mux: use size_t consistently
231ec1f Removing the indirection of meta-huffman tables.
15ebcba check return pointer from MuxImageGetListFromId
b0d6c4a Merge "configure: remove test for zlib.h"
8cccac5 Merge "dsp/lossless: silence some build warnings"
b08819a dsp/lossless: silence some build warnings
7ae2252 Android.mk: SSE2 & NEON updates
0a49e3f Merge "makefile.unix add missing header files"
2e75a9a Merge "decode.h: use size_t consistently"
fa13035 configure: remove test for zlib.h
d3adc81 makefile.unix add missing header files
262fe01 Merge "makefile.unix & Android.mk: cosmetics"
4cce137 Merge "enc_sse2 add missing stdlib.h include"
80256b8 enc_sse2 add missing stdlib.h include
9b3d1f3 decode.h: use size_t consistently
64083d3 Merge "Makefile.am: cosmetics"
dceb8b4 Merge changes If1331d3c,I86fe3847
0e33d7b Merge "webp/decode.h: fix prototypes"
fac0f12 rename BitReader to VP8LBitReader
fbd82b5 types.h: centralize use of stddef.h
2154835 Makefile.am: cosmetics
1c92bd3 vp8io: use size_t for buffer size
90ead71 fix some more uint32_t -> size_t typing
cbe705c webp/decode.h: fix prototypes
3f8ec1c makefile.unix & Android.mk: cosmetics
217ec7f Remove tabs in configure.ac
b3d35fc Merge "Android.mk & Makefile.vc: add new files"
0df04b9 Android.mk & Makefile.vc: add new files
e4f20c5 Merge "automake: replace 'silent-rules' w/AM_SILENT_RULES"
8d254a0 cosmetics
6860c2e fix some uint32_t -> size_t typing
4af1858 Fix a crash due to max symbol in a tree >= alphabet size
6f01b83 split the VP8 and VP8L decoding properly
f2623db enable lossless decoder
b96efd7 add dec/vp8i.h changes from experimental
19f6398 add dec/vp8l{i.h,.c} from experimental
c4ae53c add utils/bit_reader.[hc] changes from experimental
514d008 add dsp/lossless.[hc] from experimental
9c67291 add utils/huffman.[hc] from experimental
337914a add utils/color_cache.[hc] from experimental
b3bf8fe the read-overflow code-path wasn't reporting as an error
1db888b take colorspace into account when cropping
61c2d51 move the rescaling code into its own file and make enc/ and dec/ use it.
efc2016 Make rescaler methods generic
3eacee8 Move rescaler methods out of io.c.
a69b893 automake: replace 'silent-rules' w/AM_SILENT_RULES
6f7bf64 issue 111: fix little-endian problem in bit-reader
ed278e2 Removed unnecessary lookup
cd8c3ba fix some warnings: down-cast and possibly-uninitialized variable
0a7102b ~1% improvement of alpha compression
3bc1b14 Merge "Reformat container doc"
dc17abd mux: cosmetics
cb5810d Merge "WebPMuxGetImage: allow image param to be NULL"
506a4af mux: cosmetics
135e8b1 WebPMuxGetImage: allow image param to be NULL
de556b6 Merge "README.mux: reword some descriptions"
0ee2aeb Makefile.vc: use batch mode rules
d9acddc msvc: move {i,p}db creation to object directory
237c9aa Merge "expose WebPFree function for DLL builds"
b3e4054 silence msvc debug build warning
45feb55 expose WebPFree function for DLL builds
11316d8 README.mux: reword some descriptions
4be52f4 factorize WebPMuxValidate
14f6b9f mux: light cleanup
5e96a5d add more param checks to WebPPictureDistortion()
8abaf82 Merge "silence some type size related warnings"
1601a39 silence some type size related warnings
f3abe52 Merge "idec: simplify buffer size calculation"
a9c5cd4 idec: simplify buffer size calculation
7b06bd7 Merge "configure/automake: add silent-rules option"
e9a7d14 Reformat container doc
d4e5c7f configure/automake: add silent-rules option
5081db7 configure/automake: no -version-info for convenience libs
85b6ff6 Merge "idec: fix WebPIUpdate failure"
7bb6a9c idec: fix internal state corruption
89cd1bb idec: fix WebPIUpdate failure
01b6380 4-5% faster decoding, optimized byte loads in arithmetic decoder.
631117e Merge "cosmetics & warnings"
a0b2736 cosmetics & warnings
f73947f use 32bit for storing dequant coeffs, instead of 16b.
b960030 Merge "store prediction mode array as uint8_t[16], not int[16]."
7b67881 store prediction mode array as uint8_t[16], not int[16].
cab8d4d Merge "NEON TransformOne"
ba503fd NEON TransformOne
9f740e3 Merge "gcc warning fix: remove the 'const' qualifier."
f76d358 gcc warning fix: remove the 'const' qualifier.
e78478d Merge "webpmux: make more use of WebPData"
f85bba3 Merge "manpages: add BUGS section"
48a43bb Merge "makefile.unix: variable cosmetics"
c274dc9 makefile.unix: variable cosmetics
1f7b859 re-organize the error-handling in the main loop a bit
1336fa7 Only recompute level_cost_[] when needed
771ee44 manpages: add BUGS section
0f7820e webpmux: make more use of WebPData
974aaff examples: logging updates
6c14aad Merge "better token buffer code"
f405425 better token buffer code
18d959f Merge "mux: add WebPData type"
eec4b87 mux: add WebPData type
0de3096 use 16bit counters for recording proba counts
7f23678 fix for LevelCost + little speed-up
7107d54 further speed-up/cleanup of RecordCoeffs() and GetResidualCost()
fd22104 Introduce Token buffer (unused for now)
5fa148f Merge "speed-up GetResidualCost()"
28a9d9b speed-up GetResidualCost()
11e7dad Merge "misc cosmetics"
378086b misc cosmetics
d61479f add -print_psnr and -print_ssim options to cwebp.
2e3e8b2 add a WebPCleanupTransparentArea() method
552c121 Merge "mux: plug some memory leaks on error"
a2a81f7 Merge "fix Mach-O shared library build"
b3482c4 Merge "fix gcc-4.0 apple 32-bit build"
e4e3ec1 fix gcc-4.0 apple 32-bit build
b0d2fec mux: plug some memory leaks on error
f0d2c7a pass of cosmetics
b309a6f fix Mach-O shared library build
241ddd3 doc: delete mux container pdf
8b1ba27 doc: update VP8 decode guide link
7e4371c WebPMuxCreate: fix unchecked malloc
eb42558 Merge "have makefile.unix clean up src/webp/*~ too"
a85c363 Merge "correct EncodeAlpha documentation"
a33842f Merge "Update webp container spec with alpha filter options."
8d6490d Incremental support for some of the mux APIs.
b8375ab have makefile.unix clean up src/webp/*~ too
b5855fc correct EncodeAlpha documentation
dba37fe Update webp container spec with alpha filter options.
2e74ec8 fix compile under MINGW
716d1d7 fix suboptimal MAX_LEN cut-off limit
57cab7b Harmonize the alpha-filter predictions at boundary
3a98953 Merge "Fix bug for Alpha in RGBA_4444 color-mode."
8ca2076 Introduce a 'fast' alpha mode
221a06b Fix bug for Alpha in RGBA_4444 color-mode.
ad1e163 cosmetics: normalize copyright headers
c77424d cosmetics: light include cleanup
9d0e17c fix msvc build breakage after 252028a
7c4c177 Some readability fixes for mux library
d8a47e6 Merge "Add predictive filtering option for Alpha."
252028a Add predictive filtering option for Alpha.
9b69be1 Merge "Simplify mux library code"
a056170 Simplify mux library code
992187a improve log2 test
e852f83 update Android.mk file list
a90cb2b reduce number of copies and mallocs in alpha plane enc/dec
b1662b0 fix some more type conversion warnings w/MSVC
223d8c6 fix some uint64_t -> int conversion warnings with MSC
c1a0437 Merge "simplify checks for enabling SSE2 code"
f06817a simplify checks for enabling SSE2 code
948d4fe silence a msvc build warning
9117954 vwebp: msvc build tweaks
7937b40 simple WebP viewer, based on OpenGL
6aac1df add a bunch of missing 'extern "C"'
421eb99 Merge "Remove assigned-but-not-used variable "br""
91e27f4 better fitting names for upsampling functions
a5d7ed5 Remove assigned-but-not-used variable "br"
f62d2c9 remove unused 'has_alpha' from VP8GetInfo() signature
08e8658 trap alpha-decoding error
b361eca add cut-off to arith coder probability update.
8666a93 Some bug-fixes for images with alpha.
273a12a fix off-by-1 diff in case cropping and simple filtering
2f741d1 webpmux: ReadImage: fix ptr free in error case
721f3f4 fix alpha decode
60942c8 fix the has_alpha_ order
30971c9 Implement progress report (and user abort)
eda520a cosmetics after 9523f2a
38bd5bb Merge "Better alpha support in webpmux binary"
ccbaebf Merge "Updated the includes to relative paths."
d71fbdc fix small typo in error message array
cdf97aa Better alpha support in webpmux binary
885f25b Updated the includes to relative paths.
a0ec9aa Update WebP encoder (cwebp) to support Alpha.
667b769 Fixed the include for types.h within mux.h
9523f2a Add Alpha Encode support from WebPEncode.
16612dd Merge "Add Alpha Decode support from WebPDecode."
d117a94 Add Alpha Decode support from WebPDecode.
6722873 cosmetics after e1947a9
e1947a9 Add Alpha encode/decode code.
afc4c5d simplify code by introducing a CopyPlane() helper func
113b312 Merge "MUX API Updates"
c398f59 MUX API Updates
5acf04e remove orphan source file
059f03e Merge "dec: validate colorspace before using as array index"
70a0398 Merge "factorize some code"
9b243b3 factorize some code
372e2b4 Correct a bug in ReadPNG() with GRAY_ALPHA images
469d6eb Merge "Makefile.am: remove redundant noinst_HEADERS"
9fe3372 dec: validate colorspace before using as array index
8962030 remove orphan source file
ced3e3f Makefile.am: remove redundant noinst_HEADERS
964387e use WEBP_INLINE for inline function declarations
90880a1 Merge "manpages: break long lines"
b591089 Merge "manpages: minor formatting updates"
4c451e4 Merge "Rectify the Chunk parsing logic."
04e84cf examples: slight cleanup
099717c manpages: break long lines
1daf39b manpages: minor formatting updates
abd030b fix missing "(void)" in function signature
f6a7d75 remove useless test
f07b213 Rectify the Chunk parsing logic.
b8634f7 webpmux: fix lib link order
42c2e68 Fix missing coma (on uncompiled code)
d8329d4 Android.mk: add missing source files
13a54df Merge "More aggressive copy-edit; add TODO; validate HTML5"
868b96a More aggressive copy-edit; add TODO; validate HTML5
767afea configure: check for a symbol contained in libpng
408b891 Merge "Linewrap at 72 cols. Casual copy-edit."
3ae318c Merge "Restore (most) emphasis; add emphasis to normative RFC 2119 terms (MUST, etc.)"
918eb2d Merge "Basic container doc source clean-up; fix lists and pseudocode blocks."
03bec9e Linewrap at 72 cols. Casual copy-edit.
2678d81 Restore (most) emphasis; add emphasis to normative RFC 2119 terms (MUST, etc.)
428674d Basic container doc source clean-up; fix lists and pseudocode blocks.
6a77d92 Merge "Makefile.vc: cosmetics"
28c38e8 Merge "Makefile.vc: condense directory creation rules"
55be2cf Initial import of container spec document, from pdftotext transform.
a82a788 Makefile.vc: cosmetics
c8f41ce Makefile.vc: condense directory creation rules
2b877cd Some fixes to Makefile.vc to support the src\mux directory.
3eb969b Merge "Add Makefile.vc for Mux library & binary."
e78e971 Add Makefile.vc for Mux library & binary.
6aedde5 Add manual for WebPMux tool.
8a360d0 Merge "Added WebPMux Binary."
a4f32ca Added WebPMux Binary.
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)
dfc9c1e Harmonize the dates
28ad70c Fix PNG decoding bug
846e93c Update AUTHORS & add .mailmap

View File

@ -224,7 +224,7 @@ $(LIBWEBPMUX): $(LIBWEBPMUX_OBJS)
$(LIBWEBP_OBJS) $(LIBWEBPMUX_OBJS): $(OUTPUT_DIRS)
!IF "$(DLLBUILD)" == "TRUE"
$(LIBWEBP_OBJS): $(DIROBJ)\$(DLLINC) $(DIROBJ)\$(DLLC)
$(LIBWEBP_OBJS) $(LIBWEBPMUX_OBJS): $(DIROBJ)\$(DLLINC) $(DIROBJ)\$(DLLC)
{$(DIROBJ)}.c{$(DIROBJ)}.obj:
$(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$@ $<

9
NEWS
View File

@ -1,11 +1,16 @@
- unreleased: version 0.2.0
- 7/19/12: version 0.1.99
* This is a pre-release of 0.2.0, not an rc to allow for further
incompatible changes based on user feedback.
* Alpha channel encode/decode support.
* Lossless decoder.
* Lossless encoder/decoder.
* Add TIFF input support to cwebp.
Incompatible changes:
* The encode ABI has been modified to support alpha encoding.
* Deprecated function WebPINew() has been removed.
* Decode function signatures have changed to consistently use size_t over
int/uint32_t.
* decode_vp8.h is no longer installed system-wide.
* cwebp will encode the alpha channel if present.
- 9/19/11: version 0.1.3
* Advanced decoding APIs.

80
README
View File

@ -4,7 +4,7 @@
\__\__/\____/\_____/__/ ____ ___
/ _/ / \ \ / _ \/ _/
/ \_/ / / \ \ __/ \__
\____/____/\_____/_____/____/v0.1.3
\____/____/\_____/_____/____/v0.1.99
Description:
============
@ -49,11 +49,13 @@ 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).
Please refer the makefile.unix for additional details and customizations.
Please refer to the makefile.unix for additional details and customizations.
Using autoconf tools:
---------------------
./autogen.sh
When building from git sources, you will need to run autogen.sh to generate the
configure script.
./configure
make
make install
@ -61,7 +63,6 @@ make install
should be all you need to have the following files
/usr/local/include/webp/decode.h
/usr/local/include/webp/decode_vp8.h
/usr/local/include/webp/encode.h
/usr/local/include/webp/types.h
/usr/local/lib/libwebp.*
@ -85,17 +86,22 @@ Currently the following functions are mapped:
Decode:
WebPGetDecoderVersion
WebPGetInfo
WebPDecodeRGB
WebPDecodeRGBA
WebPDecodeARGB
WebPDecodeBGR
WebPDecodeBGRA
WebPDecodeBGR
WebPDecodeRGB
Encode:
WebPGetEncoderVersion
WebPEncodeRGB
WebPEncodeRGBA
WebPEncodeBGR
WebPEncodeBGRA
WebPEncodeRGB
WebPEncodeBGR
WebPEncodeLosslessRGBA
WebPEncodeLosslessBGRA
WebPEncodeLosslessRGB
WebPEncodeLosslessBGR
Java bindings:
@ -111,9 +117,13 @@ decoding (dwebp) images.
The easiest use should look like:
cwebp input.png -q 80 -o output.webp
which will convert the input PNG or JPEG 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).
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.
A longer list of options is available using the -longhelp command line flag:
@ -121,8 +131,8 @@ A longer list of options is available using the -longhelp command line flag:
Usage:
cwebp [-preset <...>] [options] in_file [-o out_file]
If input size (-s) for an image is not specified, it is assumed to be a
PNG or JPEG file.
If input size (-s) for an image is not specified, it is assumed to be a PNG,
JPEG or TIFF file.
options:
-h / -help ............ short help
-H / -longhelp ........ long help
@ -156,6 +166,9 @@ options:
One of: none, fast (default) or best.
-alpha_cleanup ......... Clean RGB values in transparent area.
-noalpha ............... discard any transparency information.
-lossless .............. Encode image losslessly.
-hint <string> ......... Specify image characteristics hint.
One of: photo or picture
-short ................. condense printed message
-quiet ................. don't print anything.
@ -189,10 +202,11 @@ Namely:
but with better quality.
Typical value is around '75'.
* 'f' option directly links to the filtering strength used by the codec's
in-loop processing. The higher, the smoother will highly-compressed area
look. This is particularly useful when aiming at very small files.
Typical values are around 20-30. Note that using the option -strong will
change the type of filtering. Use "-f 0" to turn filtering off.
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
option -strong will change the type of filtering. Use "-f 0" to turn
filtering off.
* '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
@ -260,6 +274,20 @@ size_t WebPEncodeBGRA(const uint8_t* bgra, int width, int height, int stride,
They will convert raw RGB samples to a WebP data. The only control supplied
is the quality factor.
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.
Advanced encoding API:
----------------------
@ -325,20 +353,18 @@ This is mainly just one function to call:
#include "webp/decode.h"
uint8_t* WebPDecodeRGB(const uint8_t* data, size_t data_size,
int *width, int *height);
int* width, int* height);
Please have a look at the file src/webp/decode.h for the details.
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.
To detect a WebP file and gather picture's dimensions, the function:
To detect a WebP file and gather the picture's dimensions, the function:
int WebPGetInfo(const uint8_t* data, size_t data_size,
int *width, int *height);
int* width, int* height);
is supplied. No decoding is involved when using it.
A lower-level API is available from the header file <webp/decode_vp8.h>
Incremental decoding API:
=========================
@ -366,15 +392,15 @@ or by just mentioning the new size of the transmitted data:
WebPIUpdate(idec, buffer, size_of_transmitted_buffer);
Note that 'buffer' can be modified between each calls to WebPIUpdate, in
Note that 'buffer' can be modified between each call to WebPIUpdate, in
particular when the buffer is resized to accommodate larger data.
These functions will return the decoding status: either VP8_STATUS_SUSPENDED if
decoding is not finished yet, or VP8_STATUS_OK when decoding is done.
Any other status is an error condition.
decoding is not finished yet or VP8_STATUS_OK when decoding is done. Any other
status is an error condition.
The idec object must always be released (even upon an error condition)
by calling: WebPDelete(idec).
The 'idec' object must always be released (even upon an error condition) by
calling: WebPDelete(idec).
To retrieve partially decoded picture samples, one must use the corresponding
method: WebPIDecGetRGB or WebPIDecGetYUV.

View File

@ -1,4 +1,4 @@
AC_INIT([libwebp], [0.1.3],
AC_INIT([libwebp], [0.1.99],
[http://code.google.com/p/webp/issues],,
[http://code.google.com/speed/webp])
AC_CANONICAL_TARGET

View File

@ -13,7 +13,7 @@ end of this file.
WebP Container Specification
============================
_Working Draft, v0.4, 20120613_
_Working Draft, v0.5, 20120713_
* TOC placeholder
@ -27,9 +27,8 @@ WebP is an image format that uses either (i) the VP8 key frame encoding
to compress image data in a lossy way, or (ii) the WebP lossless encoding
(and possibly other encodings in the future). These encoding schemes should
make it more efficient than currently used formats. It is optimized for fast
image transfer over the network (e.g., for websites). However, it also aims
for feature parity (color profile, metadata, animation, etc.) with other
formats. This document describes the structure of a WebP file.
image transfer over the network (e.g., for websites). This document describes
the structure of a WebP file.
The WebP container (i.e., RIFF container for WebP) allows feature support over
and above the basic use case of WebP (i.e., a file containing a single image
@ -39,25 +38,7 @@ for:
* **Lossless compression.** An image can be losslessly compressed, using the
WebP Lossless Format.
* **Transparency.** An image may have transparency, i.e., an alpha channel
for each frame/tile.
* **Metadata.** An image can have metadata stored in any of the popular
metadata formats.
* **Color profiles.** An image can have an ICC profile characterizing a color
input or output device.
* **Animation.** An image may have pauses between frames, making it
an animation.
* **Tiling.** A single VP8 frame has an inherent limitation for width
or height of 2^14 pixels, and a 512 KiB limit on the size of the first
compressed partition. To support larger images, we support images
that are composed of multiple tiles, each encoded as a separate VP8
frame. All tiles form logically a single image: they have common
metadata, color profile, etc. Tiling may also improve efficiency for
larger images, e.g., grass can be encoded differently than sky.
* **Transparency.** An image may have transparency, i.e., an alpha channel.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
@ -67,16 +48,9 @@ document are to be interpreted as described in [RFC 2119][].
Terminology &amp; Basics
------------------------
A WebP file contains either a still image (i.e., an encoded matrix of
pixels) or an animation (see below), with possibly a color profile,
metadata, etc. In case we need to refer only to the matrix of pixels,
we will call it the _canvas_ of the image.
The canvas of an image is built from one or multiple tiles. Each tile
is a separately encoded VP8 key frame or a WebP lossless bitstream. Building
an image from several tiles allows the format to overcome the size limitations
of a single VP8 frame / WebP lossless bitstream. Tiles are an internal detail
of the file: they are not supposed to be exposed to the user.
A WebP file contains a still image (i.e., an encoded matrix of pixels) and,
optionally, transparency information. In case we need to refer only to the
matrix of pixels, we will call it the _canvas_ of the image.
Below are additional terms used throughout this document:
@ -197,7 +171,7 @@ This layout SHOULD be used if the image requires _lossy_ encoding and does not
require transparency or other advanced features provided by the extended format.
Files with this layout are smaller and supported by older software.
Simple WebP (lossy) file header:
Simple WebP (lossy) file format:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@ -237,7 +211,7 @@ This layout SHOULD be used if the image requires _lossless_ encoding (with an
optional transparency channel) and does not require advanced features provided
by the extended format.
Simple WebP (lossless) file header:
Simple WebP (lossless) file format:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@ -275,45 +249,16 @@ An extended format file consists of:
* A 'VP8X' chunk with information about features used in the file.
* An optional 'ICCP' chunk with color profile.
* An optional 'ALPH' chunk with transparency information.
* Optionally, some other unknown chunk types that may be defined by future
specifications.
* An optional 'LOOP' chunk with animation control data.
* Data for all the frames.
* An optional 'META' chunk with metadata.
A file MUST contain at least one frame. As will be described in the 'VP8X'
chunk description, by checking a flag one can distinguish animated and
non-animated images. A non-animated image has exactly one frame. An animated
one may have multiple frames. Data for each frame consists of:
* An optional 'FRM ' (fourth character is a significant space) chunk
with animation frame metadata. It MUST be present in animated
images at the beginning of data for that frame. It MUST NOT be
present in non-animated images.
* An optional 'TILE' chunk with tile position metadata. It MUST be
present at the beginning of each tile for a frame that is represented as
multiple tile images.
* An optional 'ALPH' chunk with alpha bitstream of the frame/tile.
* A 'VP8 ' or a 'VP8L' chunk containing compressed image data of the
frame/tile.
* An optional unknown chunk type that may be defined by future
specifications.
* The image bitstream contained in either a 'VP8 ' or 'VP8L' chunk.
All chunks SHOULD be placed in the same order as listed above. If a chunk
appears in the wrong place, the file is invalid, but readers MAY parse the
file, ignoring the chunks that come too late.
**Rationale:** Setting the order of chunks should allow quicker file
parsing. For example, if an ICCP chunk does not appear in its required
parsing. For example, if an 'ALPH' chunk does not appear in its required
position, a decoder can choose to stop searching for it. The rule of
ignoring late chunks should make programs that need to do a full search
give the same results as the ones stopping early.
@ -327,61 +272,25 @@ Extended WebP file header:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ChunkHeader('VP8X') |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| R |L|M|I|A|T| Reserved |
| Rsv |L| Rsv | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Canvas Width Minus One | ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... Canvas Height Minus One |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Tiling (T): 1 bit
Reserved (Rsv): 4 bits
: Set if the image is represented by tiles.
Animation (A): 1 bit
: Set if the file is an animation. Data in 'LOOP' and 'FRM ' chunks
should be used to control the animation.
ICC profile (I): 1 bit
: Set if the file contains an 'ICCP' chunk.
Metadata (M): 1 bit
: Set if the file contains a 'META' chunk.
: SHOULD be `0`.
Alpha (L): 1 bit
: Set if the file contains some (or all) images with transparency information
("alpha").
Rotation and Symmetry (R): 3 bits
Reserved (Rsv): 3 bits
: Specify an isometry to be applied to every bitstream chunk decoded.
The table below specifies into what coordinates a point (x,y) in the original
coordinate system has to be transformed into:
| Value | Name | New coordinates |
|:------|:--------------------------:|:--------------------------------------: |
| 0 | Identify | (x,y) |
|-------
| 1 | Horizontal symmetry | (x, CanvasHeight-1-y) |
|-------
| 2 | Vertical symmetry | (CanvasWidth-1-x, y) |
|-------
| 3 | Rotation 180 degrees | (CanvasWidth-1-x, CanvasHeight-1-y) |
|-------
| 4 | Diagonal symmetry 1 | (y, x) |
|-------
| 5 | Rotation clockwise | (CanvasHeight-1-y, x) |
|-------
| 6 | Rotation counter-clockwise | (y, CanvasWidth-1-x) |
|-------
| 7 | Diagonal symmetry 2 | (CanvasHeight-1-y, CanvasWidth-1-x) |
|-------
{: rules="groups"}
: SHOULD be `0`.
Reserved: 24 bits
@ -403,100 +312,6 @@ Future specifications MAY add more fields.
### Chunks
#### Animation
Loop Chunk:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ChunkHeader('LOOP') |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Loop Count |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Loop Count: 16 bits (_uint16_)
: The number of times to loop the animation. `0` means infinitely.
For images that are animations, this chunk contains the global
parameters of the animation.
This chunk MUST appear if the _Animation_ flag in chunk VP8X is set.
If the _Animation_ flag is not set and this chunk is present, it
SHOULD be ignored.
Frame chunk:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ChunkHeader('FRM ') |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Frame X | ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... Frame Y | Frame Width Minus One ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... | Frame Height Minus One |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Frame Duration Minus One |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Frame X: 24 bits (_uint24_)
: The X coordinate of the upper left corner of the frame is `Frame X * 2`
Frame Y: 24 bits (_uint24_)
: The Y coordinate of the upper left corner of the frame is `Frame Y * 2`
Frame Width Minus One: 24 bits (_uint24_)
: The _1-based_ width of the frame.
The frame width is '1 + Frame Width Minus One'
Frame Height Minus One: 24 bits (_uint24_)
: The _1-based_ height of the frame.
The frame height is '1 + Frame Height Minus One'
Frame Duration Minus One: 24 bits (_uint24_)
: The _1-based_ time to wait before displaying the next frame, in 1 millisecond
units. The actual duration is '1 + Frame Duration Minus One' milliseconds.
For images that are animations, this chunk contains information about a single
frame, and describes the optional alpha chunk and the bitstream chunk that
follow it. If the _Animation flag_ is not set and this chunk is present,
it SHOULD be ignored.
#### Tiling
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ChunkHeader('TILE') |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Tile X | ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... Tile Y |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Tile X: 24 bits (_uint24_)
: The X coordinate of the upper left corner of the tile is `Tile X * 2`
Tile Y: 24 bits (_uint24_)
: The Y coordinate of the upper left corner of the tile is `Tile Y * 2`
For images that contain tiling, this chunk contains information about a single
tile and describes the optional alpha chunk and the bitstream chunk that follow
it. If the _Tile flag_ is not set and this chunk is present, it SHOULD be
ignored.
#### Alpha
0 1 2 3
@ -578,11 +393,11 @@ Alpha bitstream: _Chunk Size_ - `1` bytes
: Encoded alpha bitstream.
This optional chunk contains encoded alpha data for a single frame/tile.
For images with transparency, some of the frames/tiles may contain this chunk.
However, a frame/tile containing a 'VP8L' chunk SHOULD NOT contain this chunk.
**Rationale**: the transparency information of a frame/tile is already part of
the 'VP8L' chunk.
This optional chunk contains encoded alpha data for the image. An image
containing a 'VP8L' chunk SHOULD NOT contain this chunk.
**Rationale**: The transparency information of the image is already part
of the 'VP8L' chunk.
The alpha channel data is stored as uncompressed raw data (when
compression method is '0') or compressed using the lossless format
@ -610,198 +425,40 @@ compression method is '0') or compressed using the lossless format
#### Bitstream (VP8/VP8L)
This chunk contains compressed image data. As described earlier, images
with a simple file format (lossy/lossless) have a single bitstream chunk
as the first subchunk of RIFF, while images with extended file format may
contain several of them, one for each frame/tile.
This chunk contains compressed image data.
A bitstream chunk may be either (i) a VP8 chunk, using "VP8 " (note the
significant fourth-character space) as its tag _or_ (ii) a VP8L chunk , using
significant fourth-character space) as its tag _or_ (ii) a VP8L chunk, using
"VP8L" as its tag.
The formats of VP8 and VP8L chunks are as described in sections
[Simple file format (lossy)](#simple-file-format-lossy)
and [Simple file format (lossless)](#simple-file-format-lossless) respectively.
#### Color profile
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ChunkHeader('ICCP') |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Color Profile |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Color Profile: _Chunk Size_ bytes
: ICC profile.
This chunk MUST appear before data for all the frames.
There SHOULD be at most one such chunk. If there are more such chunks, readers
MAY ignore all except the first one.
See <http://www.color.org> for specifications.
If this chunk is not present, sRGB SHOULD be assumed.
#### Metadata
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ChunkHeader('META') |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Metadata |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Metadata: _Chunk Size_ bytes
: image metadata.
This chunk MUST appear after data for all the frames.
There SHOULD be at most one such chunk. If there are more such chunks, readers
MAY ignore all except the first one.
Additional guidance about handling metadata can be found in the
Metadata Working Group's [Guidelines for Handling Metadata][metadata].
#### Unknown Chunks
A file MAY contain other unknown chunks. Readers SHOULD be ignore these chunks.
A file MAY contain other unknown chunks. Readers SHOULD ignore these chunks.
Writers SHOULD preserve them in their original order.
### Assembling the Canvas from Tiles and Animation
Here we provide an overview of how 'TILE' chunks and 'FRM '/'LOOP' chunks are
used to assemble the canvas. The notation _VP8X.field_ means the field in
the 'VP8X' chunk with the same description.
Decoding a _non-animated_ canvas MUST be equivalent to the following
pseudocode:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
assert not VP8X.flags.haveAnimation
canvas ← new black image of size
VP8X.canvasWidth x VP8X.canvasHeight.
tile_params.tileX = tile_params.tileY = 0
for chunk in data_for_all_frames:
if chunk.tag == "TILE":
assert No other TILE chunk after the last Bitstream chunk
assert No ALPH chunk after the last Bitstream chunk
tile_params = chunk
assert VP8X.canvasWidth >=
tile_params.tileX + tile_params.tileWidth
assert VP8X.canvasHeight >=
tile_params.tileY + tile_params.tileHeight
if chunk.tag == "ALPH":
assert No other ALPH chunk after the last Bitstream chunk
tile_params.alpha = alpha_data
if chunk.tag == "VP8 " OR chunk.tag == "VP8L":
render image in chunk on canvas with top-left corner in
(tile_params.tileX, tile_params.tileY).
Ignore unknown chunks
canvas contains the decoded canvas.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Decoding an _animated_ canvas MUST be equivalent to the following
pseudocode:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
assert VP8X.flags.haveAnimation
canvas ← new black image of size
VP8X.canvasWidth x VP8X.canvasHeight.
loop_count ← LOOP.loopCount
if loop_count == 0:
loop_count = ∞
frame_params ← nil
for LOOP.loop = 0, ..., LOOP.loopCount-1
assert First chunk in data_for_all_frames is FRM
for chunk in data_for_all_frames:
if chunk.tag == "FRM ":
assert No other FRM chunk after the last Bitstream chunk
assert No ALPH chunk after the last Bitstream chunk
frame_params = chunk
assert VP8X.canvasWidth >=
frame_params.frameX + frame_params.frameWidth
assert VP8X.canvasHeight >=
frame_params.frameY + frame_params.frameHeight
if chunk.tag == "ALPH":
assert No other ALPH chunk after the last Bitstream chunk
frame_params.alpha = alpha_data
if chunk.tag == "VP8 " OR chunk.tag == "VP8L":
render image in chunk on canvas with top-left corner in
(frame_params.frameX, frame_params.frameY). Show the contents
of the image for frame_params.frameDuration * 1ms.
Ignore unknown chunks
canvas contains the decoded canvas.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As described earlier, if an assert related to chunk ordering fails, the reader
MAY ignore the badly-ordered chunks instead of failing to decode the file.
Example file layouts
--------------------
A tiled image without transparency may look as follows:
A lossy encoded image with alpha may look as follows:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RIFF/WEBP
+- VP8X (descriptions of features used)
+- ICCP (color profile)
+- TILE (First tile parameters)
+- VP8 (bitstream - first tile)
+- TILE (Second tile parameters)
+- VP8 (bitstream - second tile)
+- TILE (third tile parameters)
+- VP8 (bitstream - third tile)
+- TILE (fourth tile parameters)
+- VP8 (bitstream - fourth tile)
+- META (metadata)
+- ALPH (alpha bitstream)
+- VP8 (bitstream)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
An animated image with transparency may look as follows:
A losslessly encoded image may look as follows:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RIFF/WEBP
+- VP8X (descriptions of features used)
+- LOOP (animation control parameters)
+- FRM (first animation frame parameters)
+- ALPH (alpha bitstream - first frame)
+- VP8 (bitstream - first frame)
+- FRM (second animation frame parameters)
+- ALPH (alpha bitstream - second frame)
+- VP8 (bitstream - second frame)
+- META (metadata)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A losslessly encoded non-animated non-tiled image may
look as follows:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RIFF/WEBP
+- VP8X (descriptions of features used)
+- ICCP (color profile)
+- XYZW (unknown chunk)
+- VP8L (lossless bitstream)
+- META (metadata)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
An animated image may have a mix of lossy and lossless
bitstreams as follows:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RIFF/WEBP
+- VP8X (descriptions of features used)
+- FRM (first animation frame parameters)
+- VP8 (lossy bitstream - first frame)
+- FRM (second animation frame parameters)
+- VP8L (lossless bitstream - second frame)
+- ABCD (unknown chunk)
+- FRM (third animation frame parameters)
+- VP8 (lossy bitstream - third frame)
+- EFGH (unknown chunk)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[vp8spec]: http://tools.ietf.org/html/rfc6386

View File

@ -130,7 +130,7 @@ internally.
Broadly, a WebP lossless image contains header data, transform
information and actual image data. Headers contain width and height of
the image. A WebP lossless image can go through five different types of
the image. A WebP lossless image can go through four different types of
transformation before being entropy encoded. The transform information
in the bitstream contains the data required to apply the respective
inverse transforms.
@ -781,7 +781,7 @@ prefixes, and the result of this coding is further Huffman coded.
For every pixel (x, y) in the image, there is a definition of which
entropy code to use. First, there is an integer called 'meta Huffman
code' that can be obtained from a subresolution 2D image. This
code' that can be obtained from the entropy image. This
meta Huffman code identifies a set of five Huffman codes, one for green
(along with length codes and color cache codes), one for each of red,
blue and alpha, and one for distance. The Huffman codes are identified
@ -886,7 +886,7 @@ codes to the number of meta Huffman codes.
There are two ways to code the meta Huffman codes, indicated by one bit
for the ARGB image and is an implicit zero, i.e., not present in the
stream for all predictor images and Huffman image itself.
stream for all transform images and the entropy image itself.
If this bit is zero, there is only one meta Huffman code, using Huffman
codes 0, 1, 2, 3 and 4 for green, alpha, red, blue and distance,
@ -953,8 +953,8 @@ of pixels (xsize * ysize).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<format> ::= <RIFF header><image size><image stream>
<image stream> ::= (<optional-transform><image stream>) |
<entropy-coded image>
<image stream> ::= (<optional-transform><image stream>);
<spatially-coded image>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -964,23 +964,24 @@ of pixels (xsize * ysize).
<optional-transform> ::= 1-bit <transform> <optional-transform> | 0-bit
<transform> ::= <predictor-tx> | <color-tx> | <subtract-green-tx> |
<color-indexing-tx>
<predictor-tx> ::= 2-bit value 0; 4-bit sub-pixel code | <entropy-coded image>
<color-tx> ::= 2-bit value 1; 4-bit sub-pixel code | <entropy-coded image>
<predictor-tx> ::= 2-bit value 0; <predictor image>
<predictor image> ::= 3-bit sub-pixel code | <entropy-coded image>
<color-tx> ::= 2-bit value 1; <color image>
<color image> ::= 3-bit sub-pixel code | <entropy-coded image>
<subtract-green-tx> ::= 2-bit value 2
<color-indexing-tx> ::= 2-bit value 3; 8-bit color count | <entropy-coded image>
<color-indexing-tx> ::= 2-bit value 3; <color-indexing image>
<color-indexing image> ::= 8-bit color count; <entropy-coded image>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#### Structure of the Image Data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<entropy-coded image> ::= <color cache info><optional meta huffman>
<huffman codes><lz77-coded image>
<optional meta huffman> ::= 1-bit value 0 |
(1-bit value 1;
<huffman image><meta Huffman size>)
<huffman image> ::= 4-bit subsample value; <image stream>
<meta huffman size> ::= 4-bit length; meta Huffman size (subtracted by 2).
<spatially-coded image> ::= <meta huffman><entropy-coded image>
<entropy-coded image> ::= <color cache info><huffman codes><lz77-coded image>
<meta huffman> ::= 1-bit value 0 |
(1-bit value 1; <entropy image>)
<entropy image> ::= 3-bit subsample value; <entropy-coded image>
<color cache info> ::= 1 bit value 0 |
(1-bit value 1; 4-bit value for color cache size)
<huffman codes> ::= <huffman code> | <huffman code><huffman codes>
@ -996,7 +997,7 @@ A possible example sequence:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<RIFF header><image size>1-bit value 1<subtract-green-tx>
1-bit value 1<predictor-tx>1-bit value 0<huffman image>
<color cache info><meta huffman code><huffman codes>
1-bit value 1<predictor-tx>1-bit value 0<meta huffman>
<color cache info><huffman codes>
<lz77-coded image>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -64,13 +64,13 @@ extern void* VP8GetCPUInfo; // opaque forward declaration.
static int verbose = 0;
static int ReadYUV(FILE* in_file, WebPPicture* const pic) {
const int use_argb_input = pic->use_argb_input;
const int use_argb = pic->use_argb;
const int uv_width = (pic->width + 1) / 2;
const int uv_height = (pic->height + 1) / 2;
int y;
int ok = 0;
pic->use_argb_input = 0;
pic->use_argb = 0;
if (!WebPPictureAlloc(pic)) return ok;
for (y = 0; y < pic->height; ++y) {
@ -87,7 +87,7 @@ static int ReadYUV(FILE* in_file, WebPPicture* const pic) {
goto End;
}
ok = 1;
if (use_argb_input) ok = WebPPictureYUVAToARGB(pic);
if (use_argb) ok = WebPPictureYUVAToARGB(pic);
End:
return ok;
@ -775,7 +775,7 @@ static void HelpLong(void) {
printf("Usage:\n");
printf(" cwebp [-preset <...>] [options] in_file [-o out_file]\n\n");
printf("If input size (-s) for an image is not specified, "
"it is assumed to be a PNG or JPEG file.\n");
"it is assumed to be a PNG, JPEG or TIFF file.\n");
#ifdef HAVE_WINCODEC_H
printf("Windows builds can take as input any of the files handled by WIC\n");
#endif
@ -943,7 +943,7 @@ int main(int argc, const char *argv[]) {
keep_alpha = 0;
} else if (!strcmp(argv[c], "-lossless")) {
config.lossless = 1;
picture.use_argb_input = 1;
picture.use_argb = 1;
} else if (!strcmp(argv[c], "-hint") && c < argc - 1) {
++c;
if (!strcmp(argv[c], "photo")) {
@ -1049,7 +1049,7 @@ int main(int argc, const char *argv[]) {
// Check for unsupported command line options for lossless mode and log
// warning for such options.
if (config.lossless == 1) {
if (!quiet && config.lossless == 1) {
if (config.target_size > 0 || config.target_PSNR > 0) {
fprintf(stderr, "Encoding for specified size or PSNR is not supported"
" for lossless encoding. Ignoring such option(s)!\n");
@ -1058,10 +1058,6 @@ int main(int argc, const char *argv[]) {
fprintf(stderr, "Partition limit option is not required for lossless"
" encoding. Ignoring this option!\n");
}
if (show_progress) {
fprintf(stderr, "Progress reporting option is not supported for lossless"
" encoding. Ignoring this option!\n");
}
}
if (!WebPValidateConfig(&config)) {
@ -1143,7 +1139,7 @@ int main(int argc, const char *argv[]) {
// Write info
if (dump_file) {
if (picture.use_argb_input) {
if (picture.use_argb) {
fprintf(stderr, "Warning: can't dump file (-d option) in lossless mode.");
} else if (!DumpPicture(&picture, dump_file)) {
fprintf(stderr, "Warning, couldn't dump picture %s\n", dump_file);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -134,7 +134,13 @@ UTILS_OBJS = \
LIBWEBP_OBJS = $(DEC_OBJS) $(DSP_OBJS) $(ENC_OBJS) $(UTILS_OBJS)
LIBWEBPMUX_OBJS = $(MUX_OBJS)
HDRS_INSTALLED = \
src/webp/decode.h \
src/webp/encode.h \
src/webp/types.h \
HDRS = \
src/dec/decode_vp8.h \
src/dec/vp8i.h \
src/dec/vp8li.h \
src/dec/webpi.h \
@ -152,12 +158,9 @@ HDRS = \
src/utils/quant_levels.h \
src/utils/rescaler.h \
src/utils/thread.h \
src/webp/decode.h \
src/webp/decode_vp8.h \
src/webp/encode.h \
src/webp/format_constants.h \
src/webp/mux.h \
src/webp/types.h \
$(HDRS_INSTALLED) \
OUT_LIBS = examples/libexample_util.a src/libwebp.a
OUT_EXAMPLES = examples/cwebp examples/dwebp
@ -192,7 +195,7 @@ examples/vwebp: examples/libexample_util.a src/mux/libwebpmux.a src/libwebp.a
examples/vwebp: EXTRA_LIBS += $(GL_LIBS)
examples/webpmux: examples/libexample_util.a src/mux/libwebpmux.a src/libwebp.a
$(OUT_EXAMPLES) examples/vwebp:
$(OUT_EXAMPLES) examples/vwebp examples/webpmux:
$(CC) -o $@ $^ $(LDFLAGS)
dist: DESTDIR := dist
@ -200,7 +203,7 @@ dist: all
$(INSTALL) -m755 -d $(DESTDIR)/include/webp \
$(DESTDIR)/doc $(DESTDIR)/lib
$(INSTALL) -m755 -s $(OUT_EXAMPLES) $(DESTDIR)
$(INSTALL) -m644 src/webp/*.h $(DESTDIR)/include/webp
$(INSTALL) -m644 $(HDRS_INSTALLED) $(DESTDIR)/include/webp
$(INSTALL) -m644 src/libwebp.a $(DESTDIR)/lib
umask 022; \
for m in man/[cd]webp.1; do \

View File

@ -1,5 +1,5 @@
.\" Hey, EMACS: -*- nroff -*-
.TH CWEBP 1 "January 24, 2012"
.TH CWEBP 1 "July 19, 2012"
.SH NAME
cwebp \- compress an image file to a WebP file
.SH SYNOPSIS
@ -43,7 +43,7 @@ values result in a lossy compression. The default is 100.
Specify the strength of the deblocking filter, between 0 (no filtering)
and 100 (maximum filtering). A value of 0 will turn off any filtering.
Higher value will increase the strength of the filtering process applied
after decoding the picture. The higher the smoother the picture will
after decoding the picture. The higher the value the smoother the picture will
appear. Typical values are usually in the range of 20 to 50.
.TP
.B \-preset string
@ -63,12 +63,12 @@ and where else to better transfer these bits. The possible range goes from
.TP
.B \-m int
Specify the compression method to use. This parameter controls the
tradeoff between encoding speed and the compressed file size and quality.
trade off between encoding speed and the compressed file size and quality.
Possible values range from 0 to 6. Default value is 4.
When higher values are used, the encoder will spend more time inspecting
additional encoding possibilities and decide on the quality gain.
Lower value can result is faster processing time at the expense of
larger filesize and lower compression quality.
larger file size and lower compression quality.
.TP
.B \-af
Turns auto-filter on. This algorithm will spend additional time optimizing

View File

@ -9,9 +9,10 @@ lib_LTLIBRARIES = libwebp.la
libwebp_la_SOURCES =
libwebpinclude_HEADERS =
libwebpinclude_HEADERS += webp/decode.h
libwebpinclude_HEADERS += webp/decode_vp8.h
libwebpinclude_HEADERS += webp/encode.h
libwebpinclude_HEADERS += webp/types.h
noinst_HEADERS =
noinst_HEADERS += webp/format_constants.h
libwebp_la_LIBADD =
libwebp_la_LIBADD += dec/libwebpdecode.la
@ -19,7 +20,7 @@ libwebp_la_LIBADD += dsp/libwebpdsp.la
libwebp_la_LIBADD += enc/libwebpencode.la
libwebp_la_LIBADD += utils/libwebputils.la
libwebp_la_LDFLAGS = -version-info 2:0:0
libwebp_la_LDFLAGS = -version-info 3:0:0
libwebpincludedir = $(includedir)/webp
pkgconfig_DATA = libwebp.pc

View File

@ -4,6 +4,7 @@ noinst_LTLIBRARIES = libwebpdecode.la
libwebpdecode_la_SOURCES =
libwebpdecode_la_SOURCES += alpha.c
libwebpdecode_la_SOURCES += buffer.c
libwebpdecode_la_SOURCES += decode_vp8.h
libwebpdecode_la_SOURCES += frame.c
libwebpdecode_la_SOURCES += idec.c
libwebpdecode_la_SOURCES += io.c
@ -19,9 +20,9 @@ libwebpdecode_la_SOURCES += webpi.h
libwebpdecodeinclude_HEADERS =
libwebpdecodeinclude_HEADERS += ../webp/decode.h
libwebpdecodeinclude_HEADERS += ../webp/decode_vp8.h
libwebpdecodeinclude_HEADERS += ../webp/types.h
noinst_HEADERS = ../webp/format_constants.h
noinst_HEADERS =
noinst_HEADERS += ../webp/format_constants.h
libwebpdecode_la_CPPFLAGS = $(USE_EXPERIMENTAL_CODE)
libwebpdecodeincludedir = $(includedir)/webp

View File

@ -166,14 +166,16 @@ VP8StatusCode WebPAllocateDecBuffer(int w, int h,
//------------------------------------------------------------------------------
// constructors / destructors
int WebPInitDecBufferInternal(WebPDecBuffer* const buffer, int version) {
if (version != WEBP_DECODER_ABI_VERSION) return 0; // version mismatch
int WebPInitDecBufferInternal(WebPDecBuffer* buffer, int version) {
if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DECODER_ABI_VERSION)) {
return 0; // version mismatch
}
if (buffer == NULL) return 0;
memset(buffer, 0, sizeof(*buffer));
return 1;
}
void WebPFreeDecBuffer(WebPDecBuffer* const buffer) {
void WebPFreeDecBuffer(WebPDecBuffer* buffer) {
if (buffer != NULL) {
if (!buffer->is_external_memory)
free(buffer->private_memory);

View File

@ -12,7 +12,7 @@
#ifndef WEBP_WEBP_DECODE_VP8_H_
#define WEBP_WEBP_DECODE_VP8_H_
#include "./decode.h"
#include "../webp/decode.h"
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
@ -106,12 +106,12 @@ struct VP8Io {
};
// Internal, version-checked, entry point
WEBP_EXTERN(int) VP8InitIoInternal(VP8Io* const, int);
int VP8InitIoInternal(VP8Io* const, int);
// Set the custom IO function pointers and user-data. The setter for IO hooks
// should be called before initiating incremental decoding. Returns true if
// WebPIDecoder object is successfully modified, false otherwise.
WEBP_EXTERN(int) WebPISetIOHooks(WebPIDecoder* const idec,
int WebPISetIOHooks(WebPIDecoder* const idec,
VP8IoPutHook put,
VP8IoSetupHook setup,
VP8IoTeardownHook teardown,
@ -121,7 +121,7 @@ WEBP_EXTERN(int) WebPISetIOHooks(WebPIDecoder* const idec,
typedef struct VP8Decoder VP8Decoder;
// Create a new decoder object.
WEBP_EXTERN(VP8Decoder*) VP8New(void);
VP8Decoder* VP8New(void);
// Must be called to make sure 'io' is initialized properly.
// Returns false in case of version mismatch. Upon such failure, no other
@ -131,24 +131,24 @@ static WEBP_INLINE int VP8InitIo(VP8Io* const io) {
}
// Start decoding a new picture. Returns true if ok.
WEBP_EXTERN(int) VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io);
int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io);
// Decode a picture. Will call VP8GetHeaders() if it wasn't done already.
// Returns false in case of error.
WEBP_EXTERN(int) VP8Decode(VP8Decoder* const dec, VP8Io* const io);
int VP8Decode(VP8Decoder* const dec, VP8Io* const io);
// Return current status of the decoder:
WEBP_EXTERN(VP8StatusCode) VP8Status(VP8Decoder* const dec);
VP8StatusCode VP8Status(VP8Decoder* const dec);
// return readable string corresponding to the last status.
WEBP_EXTERN(const char*) VP8StatusMessage(VP8Decoder* const dec);
const char* VP8StatusMessage(VP8Decoder* const dec);
// Resets the decoder in its initial state, reclaiming memory.
// Not a mandatory call between calls to VP8Decode().
WEBP_EXTERN(void) VP8Clear(VP8Decoder* const dec);
void VP8Clear(VP8Decoder* const dec);
// Destroy the decoder object.
WEBP_EXTERN(void) VP8Delete(VP8Decoder* const dec);
void VP8Delete(VP8Decoder* const dec);
//------------------------------------------------------------------------------
// Miscellaneous VP8/VP8L bitstream probing functions.

View File

@ -533,7 +533,7 @@ static VP8StatusCode IDecode(WebPIDecoder* idec) {
//------------------------------------------------------------------------------
// Public functions
WebPIDecoder* WebPINewDecoder(WebPDecBuffer* const output_buffer) {
WebPIDecoder* WebPINewDecoder(WebPDecBuffer* output_buffer) {
WebPIDecoder* idec = (WebPIDecoder*)calloc(1, sizeof(WebPIDecoder));
if (idec == NULL) {
return NULL;
@ -554,7 +554,7 @@ WebPIDecoder* WebPINewDecoder(WebPDecBuffer* const output_buffer) {
}
WebPIDecoder* WebPIDecode(const uint8_t* data, size_t data_size,
WebPDecoderConfig* const config) {
WebPDecoderConfig* config) {
WebPIDecoder* idec;
// Parse the bitstream's features, if requested:
@ -575,7 +575,7 @@ WebPIDecoder* WebPIDecode(const uint8_t* data, size_t data_size,
return idec;
}
void WebPIDelete(WebPIDecoder* const idec) {
void WebPIDelete(WebPIDecoder* idec) {
if (idec == NULL) return;
if (idec->dec_ != NULL) {
if (!idec->is_lossless_) {
@ -638,8 +638,8 @@ static VP8StatusCode IDecCheckStatus(const WebPIDecoder* const idec) {
return VP8_STATUS_SUSPENDED;
}
VP8StatusCode WebPIAppend(WebPIDecoder* const idec,
const uint8_t* const data, size_t data_size) {
VP8StatusCode WebPIAppend(WebPIDecoder* idec,
const uint8_t* data, size_t data_size) {
VP8StatusCode status;
if (idec == NULL || data == NULL) {
return VP8_STATUS_INVALID_PARAM;
@ -659,8 +659,8 @@ VP8StatusCode WebPIAppend(WebPIDecoder* const idec,
return IDecode(idec);
}
VP8StatusCode WebPIUpdate(WebPIDecoder* const idec,
const uint8_t* const data, size_t data_size) {
VP8StatusCode WebPIUpdate(WebPIDecoder* idec,
const uint8_t* data, size_t data_size) {
VP8StatusCode status;
if (idec == NULL || data == NULL) {
return VP8_STATUS_INVALID_PARAM;
@ -692,9 +692,9 @@ static const WebPDecBuffer* GetOutputBuffer(const WebPIDecoder* const idec) {
return idec->params_.output;
}
const WebPDecBuffer* WebPIDecodedArea(const WebPIDecoder* const idec,
int* const left, int* const top,
int* const width, int* const height) {
const WebPDecBuffer* WebPIDecodedArea(const WebPIDecoder* idec,
int* left, int* top,
int* width, int* height) {
const WebPDecBuffer* const src = GetOutputBuffer(idec);
if (left) *left = 0;
if (top) *top = 0;
@ -709,7 +709,7 @@ const WebPDecBuffer* WebPIDecodedArea(const WebPIDecoder* const idec,
return src;
}
uint8_t* WebPIDecGetRGB(const WebPIDecoder* const idec, int* last_y,
uint8_t* WebPIDecGetRGB(const WebPIDecoder* idec, int* last_y,
int* width, int* height, int* stride) {
const WebPDecBuffer* const src = GetOutputBuffer(idec);
if (!src) return NULL;
@ -725,7 +725,7 @@ uint8_t* WebPIDecGetRGB(const WebPIDecoder* const idec, int* last_y,
return src->u.RGBA.rgba;
}
uint8_t* WebPIDecGetYUV(const WebPIDecoder* const idec, int* last_y,
uint8_t* WebPIDecGetYUV(const WebPIDecoder* idec, int* last_y,
uint8_t** u, uint8_t** v,
int* width, int* height, int *stride, int* uv_stride) {
const WebPDecBuffer* const src = GetOutputBuffer(idec);

View File

@ -35,9 +35,10 @@ static void SetOk(VP8Decoder* const dec) {
}
int VP8InitIoInternal(VP8Io* const io, int version) {
if (version != WEBP_DECODER_ABI_VERSION)
if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DECODER_ABI_VERSION)) {
return 0; // mismatch error
if (io) {
}
if (io != NULL) {
memset(io, 0, sizeof(*io));
}
return 1;
@ -45,7 +46,7 @@ int VP8InitIoInternal(VP8Io* const io, int version) {
VP8Decoder* VP8New(void) {
VP8Decoder* const dec = (VP8Decoder*)calloc(1, sizeof(VP8Decoder));
if (dec) {
if (dec != NULL) {
SetOk(dec);
WebPWorkerInit(&dec->worker_);
dec->ready_ = 0;
@ -60,13 +61,13 @@ VP8StatusCode VP8Status(VP8Decoder* const dec) {
}
const char* VP8StatusMessage(VP8Decoder* const dec) {
if (!dec) return "no object";
if (dec == NULL) return "no object";
if (!dec->error_msg_) return "OK";
return dec->error_msg_;
}
void VP8Delete(VP8Decoder* const dec) {
if (dec) {
if (dec != NULL) {
VP8Clear(dec);
free(dec);
}
@ -136,7 +137,7 @@ int VP8GetInfo(const uint8_t* data, size_t data_size, size_t chunk_size,
// Header parsing
static void ResetSegmentHeader(VP8SegmentHeader* const hdr) {
assert(hdr);
assert(hdr != NULL);
hdr->use_segment_ = 0;
hdr->update_map_ = 0;
hdr->absolute_delta_ = 1;
@ -147,8 +148,8 @@ static void ResetSegmentHeader(VP8SegmentHeader* const hdr) {
// Paragraph 9.3
static int ParseSegmentHeader(VP8BitReader* br,
VP8SegmentHeader* hdr, VP8Proba* proba) {
assert(br);
assert(hdr);
assert(br != NULL);
assert(hdr != NULL);
hdr->use_segment_ = VP8Get(br);
if (hdr->use_segment_) {
hdr->update_map_ = VP8Get(br);

View File

@ -28,7 +28,7 @@ extern "C" {
// version numbers
#define DEC_MAJ_VERSION 0
#define DEC_MIN_VERSION 1
#define DEC_REV_VERSION 3
#define DEC_REV_VERSION 99
#define ONLY_KEYFRAME_CODE // to remove any code related to P-Frames

View File

@ -7,8 +7,8 @@
//
// main entry for the decoder
//
// Author: Vikas Arora (vikaas.arora@gmail.com)
// jyrki@google.com (Jyrki Alakuijala)
// Authors: Vikas Arora (vikaas.arora@gmail.com)
// Jyrki Alakuijala (jyrki@google.com)
#include <stdio.h>
#include <stdlib.h>
@ -565,13 +565,14 @@ static int DecodeImageData(VP8LDecoder* const dec,
int col = 0, row = 0;
VP8LBitReader* const br = &dec->br_;
VP8LMetadata* const hdr = &dec->hdr_;
VP8LColorCache* const color_cache = hdr->color_cache_;
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);
@ -784,7 +785,7 @@ static void ClearMetadata(VP8LMetadata* const hdr) {
free(hdr->huffman_image_);
DeleteHtreeGroups(hdr->htree_groups_, hdr->num_htree_groups_);
VP8LColorCacheDelete(hdr->color_cache_);
VP8LColorCacheClear(&hdr->color_cache_);
InitMetadata(hdr);
}
@ -875,13 +876,13 @@ static int DecodeImageStream(int xsize, int ysize,
// Finish setting up the color-cache
if (color_cache_bits > 0) {
hdr->color_cache_size_ = 1 << color_cache_bits;
hdr->color_cache_ = (VP8LColorCache*)malloc(sizeof(*hdr->color_cache_));
if (hdr->color_cache_ == NULL ||
!VP8LColorCacheInit(hdr->color_cache_, color_cache_bits)) {
if (!VP8LColorCacheInit(&hdr->color_cache_, color_cache_bits)) {
dec->status_ = VP8_STATUS_OUT_OF_MEMORY;
ok = 0;
goto End;
}
} else {
hdr->color_cache_size_ = 0;
}
UpdateDecoder(dec, transform_xsize, transform_ysize);
@ -890,12 +891,22 @@ static int DecodeImageStream(int xsize, int ysize,
goto End;
}
data = (uint32_t*)malloc(transform_xsize * transform_ysize * sizeof(*data));
{
const uint64_t total_size =
transform_xsize * transform_ysize * sizeof(*data);
if (total_size != (size_t)total_size) {
// This shouldn't happen, because of transform_bits limit, but...
dec->status_ = VP8_STATUS_BITSTREAM_ERROR;
ok = 0;
goto End;
}
data = (uint32_t*)malloc((size_t)total_size);
if (data == NULL) {
dec->status_ = VP8_STATUS_OUT_OF_MEMORY;
ok = 0;
goto End;
}
}
// Use the Huffman trees to decode the LZ77 encoded data.
ok = DecodeImageData(dec, data, transform_xsize, transform_ysize, NULL);

View File

@ -45,7 +45,7 @@ typedef struct {
typedef struct {
int color_cache_size_;
VP8LColorCache *color_cache_;
VP8LColorCache color_cache_;
int huffman_mask_;
int huffman_subsample_bits_;

View File

@ -649,9 +649,9 @@ int WebPGetInfo(const uint8_t* data, size_t data_size,
//------------------------------------------------------------------------------
// Advance decoding API
int WebPInitDecoderConfigInternal(WebPDecoderConfig* const config,
int WebPInitDecoderConfigInternal(WebPDecoderConfig* config,
int version) {
if (version != WEBP_DECODER_ABI_VERSION) {
if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DECODER_ABI_VERSION)) {
return 0; // version mismatch
}
if (config == NULL) {
@ -664,10 +664,10 @@ int WebPInitDecoderConfigInternal(WebPDecoderConfig* const config,
}
VP8StatusCode WebPGetFeaturesInternal(const uint8_t* data, size_t data_size,
WebPBitstreamFeatures* const features,
WebPBitstreamFeatures* features,
int version) {
VP8StatusCode status;
if (version != WEBP_DECODER_ABI_VERSION) {
if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DECODER_ABI_VERSION)) {
return VP8_STATUS_INVALID_PARAM; // version mismatch
}
if (features == NULL) {
@ -682,7 +682,7 @@ VP8StatusCode WebPGetFeaturesInternal(const uint8_t* data, size_t data_size,
}
VP8StatusCode WebPDecode(const uint8_t* data, size_t data_size,
WebPDecoderConfig* const config) {
WebPDecoderConfig* config) {
WebPDecParams params;
VP8StatusCode status;

View File

@ -17,7 +17,7 @@ extern "C" {
#endif
#include "../utils/rescaler.h"
#include "../webp/decode_vp8.h"
#include "./decode_vp8.h"
//------------------------------------------------------------------------------
// WebPDecParams: Decoding output parameters. Transient internal object.

View File

@ -18,8 +18,8 @@ libwebpdsp_la_SOURCES += yuv.h
libwebpdspinclude_HEADERS = ../webp/types.h
noinst_HEADERS =
noinst_HEADERS += ../dec/decode_vp8.h
noinst_HEADERS += ../webp/decode.h
noinst_HEADERS += ../webp/decode_vp8.h
libwebpdsp_la_LDFLAGS = -lm
libwebpdsp_la_CPPFLAGS = $(USE_EXPERIMENTAL_CODE)

View File

@ -8,7 +8,7 @@
// Image transforms and color space conversion methods for lossless decoder.
//
// Authors: Vikas Arora (vikaas.arora@gmail.com)
// jyrki@google.com (Jyrki Alakuijala)
// Jyrki Alakuijala (jyrki@google.com)
// Urvang Joshi (urvang@google.com)
#if defined(__cplusplus) || defined(c_plusplus)

View File

@ -7,8 +7,8 @@
//
// Image transforms and color space conversion methods for lossless decoder.
//
// Author: Vikas Arora (vikaas.arora@gmail.com)
// jyrki@google.com (Jyrki Alakuijala)
// Authors: Vikas Arora (vikaas.arora@gmail.com)
// Jyrki Alakuijala (jyrki@google.com)
#ifndef WEBP_DSP_LOSSLESS_H_
#define WEBP_DSP_LOSSLESS_H_

View File

@ -12,7 +12,7 @@
#ifndef WEBP_DSP_YUV_H_
#define WEBP_DSP_YUV_H_
#include "../webp/decode_vp8.h"
#include "../dec/decode_vp8.h"
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {

View File

@ -62,7 +62,7 @@ static int EncodeLossless(const uint8_t* data, int width, int height,
WebPPictureInit(&picture);
picture.width = width;
picture.height = height;
picture.use_argb_input = 1;
picture.use_argb = 1;
if (!WebPPictureAlloc(&picture)) return 0;
// Transfer the alpha values to the green channel.

View File

@ -146,18 +146,20 @@ static int HashChainFindCopy(const HashChain* const p,
const uint64_t hash_code = GetPixPairHash64(&argb[index]);
int prev_length = 0;
int64_t best_val = 0;
int best_length = 0;
int best_distance = 0;
const uint32_t* const argb_start = argb + index;
const int iter_min_mult = (quality < 50) ? 2 : (quality < 75) ? 4 : 8;
const int iter_min = -quality * iter_min_mult;
int iter_cnt = 10 + (quality >> 1);
const int min_pos = (index > WINDOW_SIZE) ? index - WINDOW_SIZE : 0;
int32_t pos;
int64_t val;
int best_length = 0;
int best_distance = 0;
int pos;
assert(xsize > 0);
for (pos = p->hash_to_first_index_[hash_code];
pos >= min_pos;
pos = p->chain_[pos]) {
int64_t val;
int curr_length;
if (iter_cnt < 0) {
if (iter_cnt < iter_min || best_val >= 0xff0000) {
@ -166,10 +168,10 @@ static int HashChainFindCopy(const HashChain* const p,
}
--iter_cnt;
if (best_length != 0 &&
argb[pos + best_length - 1] != argb[index + best_length - 1]) {
argb[pos + best_length - 1] != argb_start[best_length - 1]) {
continue;
}
curr_length = FindMatchLength(argb + pos, argb + index, maxlen);
curr_length = FindMatchLength(argb + pos, argb_start, maxlen);
if (curr_length < prev_length) {
continue;
}

View File

@ -19,9 +19,9 @@ extern "C" {
// WebPConfig
//------------------------------------------------------------------------------
int WebPConfigInitInternal(WebPConfig* const config,
int WebPConfigInitInternal(WebPConfig* config,
WebPPreset preset, float quality, int version) {
if (version != WEBP_ENCODER_ABI_VERSION) {
if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_ENCODER_ABI_VERSION)) {
return 0; // caller/system version mismatch!
}
if (config == NULL) return 0;
@ -80,7 +80,7 @@ int WebPConfigInitInternal(WebPConfig* const config,
return WebPValidateConfig(config);
}
int WebPValidateConfig(const WebPConfig* const config) {
int WebPValidateConfig(const WebPConfig* config) {
if (config == NULL) return 0;
if (config->quality < 0 || config->quality > 100)
return 0;

View File

@ -88,8 +88,7 @@ VP8LHistogramSet* VP8LAllocateHistogramSet(int size, int cache_bits) {
// -----------------------------------------------------------------------------
void VP8LConvertPopulationCountTableToBitEstimates(
int num_symbols, const int* const population_counts,
double* const output) {
int num_symbols, const int population_counts[], double output[]) {
int sum = 0;
int nonzeros = 0;
int i;
@ -206,9 +205,6 @@ double VP8LHistogramEstimateBitsBulk(const VP8LHistogram* const p) {
return retval;
}
double VP8LHistogramEstimateBits(const VP8LHistogram* const p) {
return VP8LHistogramEstimateBitsHeader(p) + VP8LHistogramEstimateBitsBulk(p);
}
// Returns the cost encode the rle-encoded entropy code.
// The constants in this function are experimental.
@ -249,7 +245,8 @@ static double HuffmanCost(const int* const population, int length) {
return retval;
}
double VP8LHistogramEstimateBitsHeader(const VP8LHistogram* const p) {
// Estimates the Huffman dictionary + other block overhead size.
static double HistogramEstimateBitsHeader(const VP8LHistogram* const p) {
return HuffmanCost(&p->alpha_[0], 256) +
HuffmanCost(&p->red_[0], 256) +
HuffmanCost(&p->literal_[0], VP8LHistogramNumCodes(p)) +
@ -257,6 +254,10 @@ double VP8LHistogramEstimateBitsHeader(const VP8LHistogram* const p) {
HuffmanCost(&p->distance_[0], NUM_DISTANCE_CODES);
}
double VP8LHistogramEstimateBits(const VP8LHistogram* const p) {
return HistogramEstimateBitsHeader(p) + VP8LHistogramEstimateBitsBulk(p);
}
static void HistogramBuildImage(int xsize, int histo_bits,
const VP8LBackwardRefs* const backward_refs,
VP8LHistogramSet* const image) {

View File

@ -76,10 +76,6 @@ void VP8LHistogramAddSinglePixOrCopy(VP8LHistogram* const histo,
// approximately maps to.
double VP8LHistogramEstimateBits(const VP8LHistogram* const p);
// This function estimates the Huffman dictionary + other block overhead
// size for creating a new deflate block.
double VP8LHistogramEstimateBitsHeader(const VP8LHistogram* const p);
// This function estimates the cost in bits excluding the bits needed to
// represent the entropy code itself.
double VP8LHistogramEstimateBitsBulk(const VP8LHistogram* const p);
@ -100,34 +96,13 @@ static WEBP_INLINE void VP8LHistogramAdd(VP8LHistogram* const p,
}
}
static WEBP_INLINE void VP8LHistogramRemove(VP8LHistogram* const p,
const VP8LHistogram* const a) {
int i;
for (i = 0; i < PIX_OR_COPY_CODES_MAX; ++i) {
p->literal_[i] -= a->literal_[i];
assert(p->literal_[i] >= 0);
}
for (i = 0; i < NUM_DISTANCE_CODES; ++i) {
p->distance_[i] -= a->distance_[i];
assert(p->distance_[i] >= 0);
}
for (i = 0; i < 256; ++i) {
p->red_[i] -= a->red_[i];
p->blue_[i] -= a->blue_[i];
p->alpha_[i] -= a->alpha_[i];
assert(p->red_[i] >= 0);
assert(p->blue_[i] >= 0);
assert(p->alpha_[i] >= 0);
}
}
static WEBP_INLINE int VP8LHistogramNumCodes(const VP8LHistogram* const p) {
return 256 + NUM_LENGTH_CODES +
((p->palette_code_bits_ > 0) ? (1 << p->palette_code_bits_) : 0);
}
void VP8LConvertPopulationCountTableToBitEstimates(
int n, const int* const population_counts, double* const output);
int num_symbols, const int population_counts[], double output[]);
// Builds the histogram image.
int VP8LGetHistoImageSymbols(int xsize, int ysize,

View File

@ -34,14 +34,14 @@ static const union {
// WebPPicture
//------------------------------------------------------------------------------
int WebPPictureAlloc(WebPPicture* const picture) {
int WebPPictureAlloc(WebPPicture* picture) {
if (picture != NULL) {
const WebPEncCSP uv_csp = picture->colorspace & WEBP_CSP_UV_MASK;
const int has_alpha = picture->colorspace & WEBP_CSP_ALPHA_BIT;
const int width = picture->width;
const int height = picture->height;
if (!picture->use_argb_input) {
if (!picture->use_argb) {
const int y_stride = width;
const int uv_width = HALVE(width);
const int uv_height = HALVE(height);
@ -172,7 +172,7 @@ static int PictureAllocARGB(WebPPicture* const picture) {
WebPPicture tmp;
free(picture->memory_argb_);
PictureResetARGB(picture);
picture->use_argb_input = 1;
picture->use_argb = 1;
WebPPictureGrabSpecs(picture, &tmp);
if (!WebPPictureAlloc(&tmp)) {
return WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY);
@ -184,7 +184,7 @@ static int PictureAllocARGB(WebPPicture* const picture) {
}
// Release memory owned by 'picture' (both YUV and ARGB buffers).
void WebPPictureFree(WebPPicture* const picture) {
void WebPPictureFree(WebPPicture* picture) {
if (picture != NULL) {
free(picture->memory_);
free(picture->memory_argb_);
@ -209,7 +209,7 @@ static void CopyPlane(const uint8_t* src, int src_stride,
// Adjust top-left corner to chroma sample position.
static void SnapTopLeftPosition(const WebPPicture* const pic,
int* const left, int* const top) {
if (!pic->use_argb_input) {
if (!pic->use_argb) {
const int is_yuv422 = IS_YUV_CSP(pic->colorspace, WEBP_YUV422);
if (IS_YUV_CSP(pic->colorspace, WEBP_YUV420) || is_yuv422) {
*left &= ~1;
@ -230,14 +230,14 @@ static int AdjustAndCheckRectangle(const WebPPicture* const pic,
return 1;
}
int WebPPictureCopy(const WebPPicture* const src, WebPPicture* const dst) {
int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst) {
if (src == NULL || dst == NULL) return 0;
if (src == dst) return 1;
WebPPictureGrabSpecs(src, dst);
if (!WebPPictureAlloc(dst)) return 0;
if (!src->use_argb_input) {
if (!src->use_argb) {
CopyPlane(src->y, src->y_stride,
dst->y, dst->y_stride, dst->width, dst->height);
CopyPlane(src->u, src->uv_stride,
@ -268,17 +268,17 @@ int WebPPictureCopy(const WebPPicture* const src, WebPPicture* const dst) {
return 1;
}
int WebPPictureIsView(const WebPPicture* const picture) {
int WebPPictureIsView(const WebPPicture* picture) {
if (picture == NULL) return 0;
if (picture->use_argb_input) {
if (picture->use_argb) {
return (picture->memory_argb_ == NULL);
}
return (picture->memory_ == NULL);
}
int WebPPictureView(const WebPPicture* const src,
int WebPPictureView(const WebPPicture* src,
int left, int top, int width, int height,
WebPPicture* const dst) {
WebPPicture* dst) {
if (src == NULL || dst == NULL) return 0;
// verify rectangle position.
@ -289,7 +289,7 @@ int WebPPictureView(const WebPPicture* const src,
}
dst->width = width;
dst->height = height;
if (!src->use_argb_input) {
if (!src->use_argb) {
dst->y = src->y + top * src->y_stride + left;
dst->u = src->u + (top >> 1) * src->uv_stride + (left >> 1);
dst->v = src->v + (top >> 1) * src->uv_stride + (left >> 1);
@ -313,7 +313,7 @@ int WebPPictureView(const WebPPicture* const src,
//------------------------------------------------------------------------------
// Picture cropping
int WebPPictureCrop(WebPPicture* const pic,
int WebPPictureCrop(WebPPicture* pic,
int left, int top, int width, int height) {
WebPPicture tmp;
@ -325,7 +325,7 @@ int WebPPictureCrop(WebPPicture* const pic,
tmp.height = height;
if (!WebPPictureAlloc(&tmp)) return 0;
if (!pic->use_argb_input) {
if (!pic->use_argb) {
const int y_offset = top * pic->y_stride + left;
const int uv_offset = (top / 2) * pic->uv_stride + left / 2;
CopyPlane(pic->y + y_offset, pic->y_stride,
@ -391,7 +391,7 @@ static void RescalePlane(const uint8_t* src,
}
}
int WebPPictureRescale(WebPPicture* const pic, int width, int height) {
int WebPPictureRescale(WebPPicture* pic, int width, int height) {
WebPPicture tmp;
int prev_width, prev_height;
int32_t* work;
@ -415,7 +415,7 @@ int WebPPictureRescale(WebPPicture* const pic, int width, int height) {
tmp.height = height;
if (!WebPPictureAlloc(&tmp)) return 0;
if (!pic->use_argb_input) {
if (!pic->use_argb) {
work = (int32_t*)malloc(2 * width * sizeof(*work));
if (work == NULL) {
WebPPictureFree(&tmp);
@ -471,14 +471,14 @@ int WebPPictureRescale(WebPPicture* const pic, int width, int height) {
//------------------------------------------------------------------------------
// WebPMemoryWriter: Write-to-memory
void WebPMemoryWriterInit(WebPMemoryWriter* const writer) {
void WebPMemoryWriterInit(WebPMemoryWriter* writer) {
writer->mem = NULL;
writer->size = 0;
writer->max_size = 0;
}
int WebPMemoryWrite(const uint8_t* data, size_t data_size,
const WebPPicture* const picture) {
const WebPPicture* picture) {
WebPMemoryWriter* const w = (WebPMemoryWriter*)picture->custom_ptr;
size_t next_size;
if (w == NULL) {
@ -526,9 +526,9 @@ static int CheckNonOpaque(const uint8_t* alpha, int width, int height,
}
// Checking for the presence of non-opaque alpha.
int WebPPictureHasTransparency(const WebPPicture* const picture) {
int WebPPictureHasTransparency(const WebPPicture* picture) {
if (picture == NULL) return 0;
if (!picture->use_argb_input) {
if (!picture->use_argb) {
return CheckNonOpaque(picture->a, picture->width, picture->height,
1, picture->a_stride);
} else {
@ -625,7 +625,7 @@ static int ImportYUVAFromRGBA(const uint8_t* const r_ptr,
const int has_alpha = CheckNonOpaque(a_ptr, width, height, step, rgb_stride);
picture->colorspace = uv_csp;
picture->use_argb_input = 0;
picture->use_argb = 0;
if (has_alpha) {
picture->colorspace |= WEBP_CSP_ALPHA_BIT;
}
@ -704,7 +704,7 @@ static int Import(WebPPicture* const picture,
const int width = picture->width;
const int height = picture->height;
if (!picture->use_argb_input) {
if (!picture->use_argb) {
return ImportYUVAFromRGBA(r_ptr, g_ptr, b_ptr, a_ptr, step, rgb_stride,
picture);
}
@ -750,40 +750,40 @@ static int Import(WebPPicture* const picture,
#undef SUM1
#undef RGB_TO_UV
int WebPPictureImportRGB(WebPPicture* const picture,
const uint8_t* const rgb, int rgb_stride) {
int WebPPictureImportRGB(WebPPicture* picture,
const uint8_t* rgb, int rgb_stride) {
return Import(picture, rgb, rgb_stride, 3, 0, 0);
}
int WebPPictureImportBGR(WebPPicture* const picture,
const uint8_t* const rgb, int rgb_stride) {
int WebPPictureImportBGR(WebPPicture* picture,
const uint8_t* rgb, int rgb_stride) {
return Import(picture, rgb, rgb_stride, 3, 1, 0);
}
int WebPPictureImportRGBA(WebPPicture* const picture,
const uint8_t* const rgba, int rgba_stride) {
int WebPPictureImportRGBA(WebPPicture* picture,
const uint8_t* rgba, int rgba_stride) {
return Import(picture, rgba, rgba_stride, 4, 0, 1);
}
int WebPPictureImportBGRA(WebPPicture* const picture,
const uint8_t* const rgba, int rgba_stride) {
int WebPPictureImportBGRA(WebPPicture* picture,
const uint8_t* rgba, int rgba_stride) {
return Import(picture, rgba, rgba_stride, 4, 1, 1);
}
int WebPPictureImportRGBX(WebPPicture* const picture,
const uint8_t* const rgba, int rgba_stride) {
int WebPPictureImportRGBX(WebPPicture* picture,
const uint8_t* rgba, int rgba_stride) {
return Import(picture, rgba, rgba_stride, 4, 0, 0);
}
int WebPPictureImportBGRX(WebPPicture* const picture,
const uint8_t* const rgba, int rgba_stride) {
int WebPPictureImportBGRX(WebPPicture* picture,
const uint8_t* rgba, int rgba_stride) {
return Import(picture, rgba, rgba_stride, 4, 1, 0);
}
//------------------------------------------------------------------------------
// Automatic YUV <-> ARGB conversions.
int WebPPictureYUVAToARGB(WebPPicture* const picture) {
int WebPPictureYUVAToARGB(WebPPicture* picture) {
if (picture == NULL) return 0;
if (picture->memory_ == NULL || picture->y == NULL ||
picture->u == NULL || picture->v == NULL) {
@ -842,7 +842,7 @@ int WebPPictureYUVAToARGB(WebPPicture* const picture) {
return 1;
}
int WebPPictureARGBToYUVA(WebPPicture* const picture, WebPEncCSP colorspace) {
int WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace) {
if (picture == NULL) return 0;
if (picture->argb == NULL) {
return WebPEncodingSetError(picture, VP8_ENC_ERROR_NULL_PARAMETER);
@ -856,7 +856,7 @@ int WebPPictureARGBToYUVA(WebPPicture* const picture, WebPEncCSP colorspace) {
// would be calling WebPPictureFree(picture) otherwise.
WebPPicture tmp = *picture;
PictureResetARGB(&tmp); // reset ARGB buffer so that it's not free()'d.
tmp.use_argb_input = 0;
tmp.use_argb = 0;
tmp.colorspace = colorspace & WEBP_CSP_UV_MASK;
if (!ImportYUVAFromRGBA(r, g, b, a, 4, 4 * picture->argb_stride, &tmp)) {
return WebPEncodingSetError(picture, VP8_ENC_ERROR_OUT_OF_MEMORY);
@ -896,7 +896,7 @@ static WEBP_INLINE void flatten(uint8_t* ptr, int v, int stride, int size) {
}
}
void WebPCleanupTransparentArea(WebPPicture* const pic) {
void WebPCleanupTransparentArea(WebPPicture* pic) {
int x, y, w, h;
const uint8_t* a_ptr;
int values[3] = { 0 };
@ -942,8 +942,7 @@ void WebPCleanupTransparentArea(WebPPicture* const pic) {
// Max value returned in case of exact similarity.
static const double kMinDistortion_dB = 99.;
int WebPPictureDistortion(const WebPPicture* const pic1,
const WebPPicture* const pic2,
int WebPPictureDistortion(const WebPPicture* pic1, const WebPPicture* pic2,
int type, float result[5]) {
int c;
DistoStats stats[5];
@ -958,8 +957,7 @@ int WebPPictureDistortion(const WebPPicture* const pic1,
return 0;
}
// TODO(skal): provide distortion for ARGB too.
if (pic1->use_argb_input == 1 ||
pic1->use_argb_input != pic2->use_argb_input) {
if (pic1->use_argb == 1 || pic1->use_argb != pic2->use_argb) {
return 0;
}
@ -1008,7 +1006,8 @@ int WebPPictureDistortion(const WebPPicture* const pic1,
typedef int (*Importer)(WebPPicture* const, const uint8_t* const, int);
static size_t Encode(const uint8_t* rgba, int width, int height, int stride,
Importer import, float quality_factor, uint8_t** output) {
Importer import, float quality_factor, int lossless,
uint8_t** output) {
WebPPicture pic;
WebPConfig config;
WebPMemoryWriter wrt;
@ -1019,6 +1018,8 @@ static size_t Encode(const uint8_t* rgba, int width, int height, int stride,
return 0; // shouldn't happen, except if system installation is broken
}
config.lossless = !!lossless;
pic.use_argb = !!lossless;
pic.width = width;
pic.height = height;
pic.writer = WebPMemoryWrite;
@ -1039,7 +1040,7 @@ static size_t Encode(const uint8_t* rgba, int width, int height, int stride,
#define ENCODE_FUNC(NAME, IMPORTER) \
size_t NAME(const uint8_t* in, int w, int h, int bps, float q, \
uint8_t** out) { \
return Encode(in, w, h, bps, IMPORTER, q, out); \
return Encode(in, w, h, bps, IMPORTER, q, 0, out); \
}
ENCODE_FUNC(WebPEncodeRGB, WebPPictureImportRGB);
@ -1049,6 +1050,19 @@ ENCODE_FUNC(WebPEncodeBGRA, WebPPictureImportBGRA);
#undef ENCODE_FUNC
#define LOSSLESS_DEFAULT_QUALITY 70.
#define LOSSLESS_ENCODE_FUNC(NAME, IMPORTER) \
size_t NAME(const uint8_t* in, int w, int h, int bps, uint8_t** out) { \
return Encode(in, w, h, bps, IMPORTER, LOSSLESS_DEFAULT_QUALITY, 1, out); \
}
LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessRGB, WebPPictureImportRGB);
LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessBGR, WebPPictureImportBGR);
LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessRGBA, WebPPictureImportRGBA);
LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessBGRA, WebPPictureImportBGRA);
#undef LOSSLESS_ENCODE_FUNC
//------------------------------------------------------------------------------
#if defined(__cplusplus) || defined(c_plusplus)

View File

@ -27,7 +27,7 @@ extern "C" {
// version numbers
#define ENC_MAJ_VERSION 0
#define ENC_MIN_VERSION 1
#define ENC_REV_VERSION 3
#define ENC_REV_VERSION 99
// size of histogram used by CollectHistogram.
#define MAX_COEFF_THRESH 64

View File

@ -28,8 +28,6 @@ extern "C" {
#define PALETTE_KEY_RIGHT_SHIFT 22 // Key for 1K buffer.
#define MAX_HUFF_IMAGE_SIZE (16 * 1024 * 1024)
#define MIN_HISTO_BITS 2
#define MAX_HISTO_BITS 9
// -----------------------------------------------------------------------------
// Palette
@ -517,7 +515,8 @@ static int EncodeImageInternal(VP8LBitWriter* const bw,
VP8LBackwardRefs refs;
uint16_t* const histogram_symbols =
(uint16_t*)malloc(histogram_image_xysize * sizeof(*histogram_symbols));
assert(histogram_bits >= MIN_HISTO_BITS && histogram_bits <= MAX_HISTO_BITS);
assert(histogram_bits >= MIN_HUFFMAN_BITS);
assert(histogram_bits <= MAX_HUFFMAN_BITS);
if (histogram_image == NULL || histogram_symbols == NULL) goto Error;
// Calculate backward references from ARGB image.
@ -894,8 +893,8 @@ static int GetHistoBits(const WebPConfig* const config,
if (huff_image_size <= MAX_HUFF_IMAGE_SIZE) break;
++histo_bits;
}
return (histo_bits < MIN_HISTO_BITS) ? MIN_HISTO_BITS :
(histo_bits > MAX_HISTO_BITS) ? MAX_HISTO_BITS : histo_bits;
return (histo_bits < MIN_HUFFMAN_BITS) ? MIN_HUFFMAN_BITS :
(histo_bits > MAX_HUFFMAN_BITS) ? MAX_HUFFMAN_BITS : histo_bits;
}
static void InitEncParams(VP8LEncoder* const enc) {
@ -1028,6 +1027,7 @@ int VP8LEncodeImage(const WebPConfig* const config,
int width, height;
int has_alpha;
size_t coded_size;
int percent = 0;
WebPEncodingError err = VP8_ENC_OK;
VP8LBitWriter bw;
@ -1040,6 +1040,11 @@ int VP8LEncodeImage(const WebPConfig* const config,
width = picture->width;
height = picture->height;
if (!WebPReportProgress(picture, 1, &percent)) {
UserAbort:
err = VP8_ENC_ERROR_USER_ABORT;
goto Error;
}
// Write image size.
VP8LBitWriterInit(&bw, (width * height) >> 1);
@ -1055,14 +1060,21 @@ int VP8LEncodeImage(const WebPConfig* const config,
goto Error;
}
if (!WebPReportProgress(picture, 5, &percent)) goto UserAbort;
// Encode main image stream.
err = VP8LEncodeStream(config, picture, &bw);
if (err != VP8_ENC_OK) goto Error;
// TODO(skal): have a fine-grained progress report in VP8LEncodeStream().
if (!WebPReportProgress(picture, 90, &percent)) goto UserAbort;
// Finish the RIFF chunk.
err = WriteImage(picture, &bw, &coded_size);
if (err != VP8_ENC_OK) goto Error;
if (!WebPReportProgress(picture, 100, &percent)) goto UserAbort;
// Collect some stats if needed.
if (picture->stats != NULL) {
WebPAuxStats* const stats = picture->stats;

View File

@ -46,8 +46,8 @@ static int DummyWriter(const uint8_t* data, size_t data_size,
return 1;
}
int WebPPictureInitInternal(WebPPicture* const picture, int version) {
if (version != WEBP_ENCODER_ABI_VERSION) {
int WebPPictureInitInternal(WebPPicture* picture, int version) {
if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_ENCODER_ABI_VERSION)) {
return 0; // caller/system version mismatch!
}
if (picture != NULL) {
@ -328,7 +328,7 @@ int WebPReportProgress(const WebPPicture* const pic,
}
//------------------------------------------------------------------------------
int WebPEncode(const WebPConfig* const config, WebPPicture* const pic) {
int WebPEncode(const WebPConfig* config, WebPPicture* pic) {
int ok;
if (pic == NULL)

View File

@ -623,16 +623,15 @@ static void InitDemux(WebPDemuxer* const dmux, const MemBuffer* const mem) {
dmux->mem_ = *mem;
}
WebPDemuxer* WebPDemuxInternal(
const WebPData* const data, int allow_partial,
WebPDemuxState* const state, int version) {
WebPDemuxer* WebPDemuxInternal(const WebPData* data, int allow_partial,
WebPDemuxState* state, int version) {
const ChunkParser* parser;
int partial;
ParseStatus status = PARSE_ERROR;
MemBuffer mem;
WebPDemuxer* dmux;
if (version != WEBP_DEMUX_ABI_VERSION) return NULL;
if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DEMUX_ABI_VERSION)) return NULL;
if (data == NULL || data->bytes_ == NULL || data->size_ == 0) return NULL;
if (!InitMemBuffer(&mem, data->bytes_, data->size_)) return NULL;
@ -662,7 +661,7 @@ WebPDemuxer* WebPDemuxInternal(
return dmux;
}
void WebPDemuxDelete(WebPDemuxer* const dmux) {
void WebPDemuxDelete(WebPDemuxer* dmux) {
Chunk* c;
Frame* f;
if (dmux == NULL) return;
@ -682,8 +681,7 @@ void WebPDemuxDelete(WebPDemuxer* const dmux) {
// -----------------------------------------------------------------------------
uint32_t WebPDemuxGetI(const WebPDemuxer* const dmux,
WebPFormatFeature feature) {
uint32_t WebPDemuxGetI(const WebPDemuxer* dmux, WebPFormatFeature feature) {
if (dmux == NULL) return 0;
switch (feature) {
@ -784,8 +782,7 @@ static int SetFrame(int frame_num, WebPIterator* const iter) {
return SynthesizeFrame(dmux, frame, 1, iter);
}
int WebPDemuxGetFrame(const WebPDemuxer* const dmux,
int frame, WebPIterator* const iter) {
int WebPDemuxGetFrame(const WebPDemuxer* dmux, int frame, WebPIterator* iter) {
if (iter == NULL) return 0;
memset(iter, 0, sizeof(*iter));
@ -793,18 +790,18 @@ int WebPDemuxGetFrame(const WebPDemuxer* const dmux,
return SetFrame(frame, iter);
}
int WebPDemuxNextFrame(WebPIterator* const iter) {
int WebPDemuxNextFrame(WebPIterator* iter) {
if (iter == NULL) return 0;
return SetFrame(iter->frame_num_ + 1, iter);
}
int WebPDemuxPrevFrame(WebPIterator* const iter) {
int WebPDemuxPrevFrame(WebPIterator* iter) {
if (iter == NULL) return 0;
if (iter->frame_num_ <= 1) return 0;
return SetFrame(iter->frame_num_ - 1, iter);
}
int WebPDemuxSelectTile(WebPIterator* const iter, int tile) {
int WebPDemuxSelectTile(WebPIterator* iter, int tile) {
if (iter != NULL && iter->private_ != NULL && tile > 0) {
const WebPDemuxer* const dmux = (WebPDemuxer*)iter->private_;
const Frame* const frame = GetFrame(dmux, iter->frame_num_);
@ -815,7 +812,7 @@ int WebPDemuxSelectTile(WebPIterator* const iter, int tile) {
return 0;
}
void WebPDemuxReleaseIterator(WebPIterator* const iter) {
void WebPDemuxReleaseIterator(WebPIterator* iter) {
(void)iter;
}
@ -868,9 +865,9 @@ static int SetChunk(const char fourcc[4], int chunk_num,
return 0;
}
int WebPDemuxGetChunk(const WebPDemuxer* const dmux,
int WebPDemuxGetChunk(const WebPDemuxer* dmux,
const char fourcc[4], int chunk_num,
WebPChunkIterator* const iter) {
WebPChunkIterator* iter) {
if (iter == NULL) return 0;
memset(iter, 0, sizeof(*iter));
@ -878,7 +875,7 @@ int WebPDemuxGetChunk(const WebPDemuxer* const dmux,
return SetChunk(fourcc, chunk_num, iter);
}
int WebPDemuxNextChunk(WebPChunkIterator* const iter) {
int WebPDemuxNextChunk(WebPChunkIterator* iter) {
if (iter != NULL) {
const char* const fourcc =
(const char*)iter->chunk_.bytes_ - CHUNK_HEADER_SIZE;
@ -887,7 +884,7 @@ int WebPDemuxNextChunk(WebPChunkIterator* const iter) {
return 0;
}
int WebPDemuxPrevChunk(WebPChunkIterator* const iter) {
int WebPDemuxPrevChunk(WebPChunkIterator* iter) {
if (iter != NULL && iter->chunk_num_ > 1) {
const char* const fourcc =
(const char*)iter->chunk_.bytes_ - CHUNK_HEADER_SIZE;
@ -896,7 +893,7 @@ int WebPDemuxPrevChunk(WebPChunkIterator* const iter) {
return 0;
}
void WebPDemuxReleaseChunkIterator(WebPChunkIterator* const iter) {
void WebPDemuxReleaseChunkIterator(WebPChunkIterator* iter) {
(void)iter;
}

View File

@ -26,11 +26,14 @@ static void MuxInit(WebPMux* const mux) {
}
WebPMux* WebPNewInternal(int version) {
WebPMux* const mux = (version == WEBP_MUX_ABI_VERSION) ?
(WebPMux*)malloc(sizeof(WebPMux)) : NULL;
if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_MUX_ABI_VERSION)) {
return NULL;
} else {
WebPMux* const mux = (WebPMux*)malloc(sizeof(WebPMux));
// If mux is NULL MuxInit is a noop.
MuxInit(mux);
return mux;
}
}
static void DeleteAllChunks(WebPChunk** const chunk_list) {
@ -49,7 +52,7 @@ static void MuxRelease(WebPMux* const mux) {
DeleteAllChunks(&mux->unknown_);
}
void WebPMuxDelete(WebPMux* const mux) {
void WebPMuxDelete(WebPMux* mux) {
// If mux is NULL MuxRelease is a noop.
MuxRelease(mux);
free(mux);
@ -202,8 +205,8 @@ static WebPMuxError DeleteLoopCount(WebPMux* const mux) {
//------------------------------------------------------------------------------
// Set API(s).
WebPMuxError WebPMuxSetImage(WebPMux* const mux,
const WebPData* const bitstream, int copy_data) {
WebPMuxError WebPMuxSetImage(WebPMux* mux,
const WebPData* bitstream, int copy_data) {
WebPMuxError err;
WebPChunk chunk;
WebPMuxImage wpi;
@ -257,8 +260,7 @@ WebPMuxError WebPMuxSetImage(WebPMux* const mux,
return err;
}
WebPMuxError WebPMuxSetMetadata(WebPMux* const mux,
const WebPData* const metadata,
WebPMuxError WebPMuxSetMetadata(WebPMux* mux, const WebPData* metadata,
int copy_data) {
WebPMuxError err;
@ -275,8 +277,7 @@ WebPMuxError WebPMuxSetMetadata(WebPMux* const mux,
return MuxSet(mux, IDX_META, 1, metadata, copy_data);
}
WebPMuxError WebPMuxSetColorProfile(WebPMux* const mux,
const WebPData* const color_profile,
WebPMuxError WebPMuxSetColorProfile(WebPMux* mux, const WebPData* color_profile,
int copy_data) {
WebPMuxError err;
@ -293,7 +294,7 @@ WebPMuxError WebPMuxSetColorProfile(WebPMux* const mux,
return MuxSet(mux, IDX_ICCP, 1, color_profile, copy_data);
}
WebPMuxError WebPMuxSetLoopCount(WebPMux* const mux, int loop_count) {
WebPMuxError WebPMuxSetLoopCount(WebPMux* mux, int loop_count) {
WebPMuxError err;
uint8_t* data = NULL;
@ -396,16 +397,14 @@ static WebPMuxError MuxPushFrameTileInternal(
return err;
}
WebPMuxError WebPMuxPushFrame(WebPMux* const mux,
const WebPData* const bitstream,
WebPMuxError WebPMuxPushFrame(WebPMux* mux, const WebPData* bitstream,
int x_offset, int y_offset,
int duration, int copy_data) {
return MuxPushFrameTileInternal(mux, bitstream, x_offset, y_offset,
duration, copy_data, kChunks[IDX_FRAME].tag);
}
WebPMuxError WebPMuxPushTile(WebPMux* const mux,
const WebPData* const bitstream,
WebPMuxError WebPMuxPushTile(WebPMux* mux, const WebPData* bitstream,
int x_offset, int y_offset,
int copy_data) {
return MuxPushFrameTileInternal(mux, bitstream, x_offset, y_offset,
@ -416,7 +415,7 @@ WebPMuxError WebPMuxPushTile(WebPMux* const mux,
//------------------------------------------------------------------------------
// Delete API(s).
WebPMuxError WebPMuxDeleteImage(WebPMux* const mux) {
WebPMuxError WebPMuxDeleteImage(WebPMux* mux) {
WebPMuxError err;
if (mux == NULL) return WEBP_MUX_INVALID_ARGUMENT;
@ -429,11 +428,11 @@ WebPMuxError WebPMuxDeleteImage(WebPMux* const mux) {
return WEBP_MUX_OK;
}
WebPMuxError WebPMuxDeleteMetadata(WebPMux* const mux) {
WebPMuxError WebPMuxDeleteMetadata(WebPMux* mux) {
return MuxDeleteAllNamedData(mux, IDX_META);
}
WebPMuxError WebPMuxDeleteColorProfile(WebPMux* const mux) {
WebPMuxError WebPMuxDeleteColorProfile(WebPMux* mux) {
return MuxDeleteAllNamedData(mux, IDX_ICCP);
}
@ -446,11 +445,11 @@ static WebPMuxError DeleteFrameTileInternal(WebPMux* const mux, uint32_t nth,
return MuxImageDeleteNth(&mux->images_, nth, id);
}
WebPMuxError WebPMuxDeleteFrame(WebPMux* const mux, uint32_t nth) {
WebPMuxError WebPMuxDeleteFrame(WebPMux* mux, uint32_t nth) {
return DeleteFrameTileInternal(mux, nth, IDX_FRAME);
}
WebPMuxError WebPMuxDeleteTile(WebPMux* const mux, uint32_t nth) {
WebPMuxError WebPMuxDeleteTile(WebPMux* mux, uint32_t nth) {
return DeleteFrameTileInternal(mux, nth, IDX_TILE);
}
@ -644,8 +643,7 @@ static WebPMuxError CreateVP8XChunk(WebPMux* const mux) {
return err;
}
WebPMuxError WebPMuxAssemble(WebPMux* const mux,
WebPData* const assembled_data) {
WebPMuxError WebPMuxAssemble(WebPMux* mux, WebPData* assembled_data) {
size_t size = 0;
uint8_t* data = NULL;
uint8_t* dst = NULL;

View File

@ -212,20 +212,20 @@ uint8_t* ChunkListEmit(const WebPChunk* chunk_list, uint8_t* dst) {
//------------------------------------------------------------------------------
// Manipulation of a WebPData object.
void WebPDataInit(WebPData* const webp_data) {
void WebPDataInit(WebPData* webp_data) {
if (webp_data != NULL) {
memset(webp_data, 0, sizeof(*webp_data));
}
}
void WebPDataClear(WebPData* const webp_data) {
void WebPDataClear(WebPData* webp_data) {
if (webp_data != NULL) {
free((void*)webp_data->bytes_);
WebPDataInit(webp_data);
}
}
int WebPDataCopy(const WebPData* const src, WebPData* const dst) {
int WebPDataCopy(const WebPData* src, WebPData* dst) {
if (src == NULL || dst == NULL) return 0;
WebPDataInit(dst);

View File

@ -76,7 +76,7 @@ static WebPMuxError ChunkVerifyAndAssignData(WebPChunk* chunk,
//------------------------------------------------------------------------------
// Create a mux object from WebP-RIFF data.
WebPMux* WebPMuxCreateInternal(const WebPData* const bitstream, int copy_data,
WebPMux* WebPMuxCreateInternal(const WebPData* bitstream, int copy_data,
int version) {
size_t riff_size;
uint32_t tag;
@ -89,7 +89,9 @@ WebPMux* WebPMuxCreateInternal(const WebPData* const bitstream, int copy_data,
ChunkInit(&chunk);
// Sanity checks.
if (version != WEBP_MUX_ABI_VERSION) return NULL; // version mismatch
if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_MUX_ABI_VERSION)) {
return NULL; // version mismatch
}
if (bitstream == NULL) return NULL;
data = bitstream->bytes_;
@ -188,7 +190,7 @@ WebPMux* WebPMuxCreateInternal(const WebPData* const bitstream, int copy_data,
//------------------------------------------------------------------------------
// Get API(s).
WebPMuxError WebPMuxGetFeatures(const WebPMux* const mux, uint32_t* flags) {
WebPMuxError WebPMuxGetFeatures(const WebPMux* mux, uint32_t* flags) {
WebPData data;
WebPMuxError err;
@ -268,8 +270,7 @@ static WebPMuxError SynthesizeBitstream(WebPMuxImage* const wpi,
return WEBP_MUX_OK;
}
WebPMuxError WebPMuxGetImage(const WebPMux* const mux,
WebPData* const bitstream) {
WebPMuxError WebPMuxGetImage(const WebPMux* mux, WebPData* bitstream) {
WebPMuxError err;
WebPMuxImage* wpi = NULL;
@ -288,20 +289,18 @@ WebPMuxError WebPMuxGetImage(const WebPMux* const mux,
return SynthesizeBitstream(wpi, bitstream);
}
WebPMuxError WebPMuxGetMetadata(const WebPMux* const mux,
WebPData* const metadata) {
WebPMuxError WebPMuxGetMetadata(const WebPMux* mux, WebPData* metadata) {
if (mux == NULL || metadata == NULL) return WEBP_MUX_INVALID_ARGUMENT;
return MuxGet(mux, IDX_META, 1, metadata);
}
WebPMuxError WebPMuxGetColorProfile(const WebPMux* const mux,
WebPData* const color_profile) {
WebPMuxError WebPMuxGetColorProfile(const WebPMux* mux,
WebPData* color_profile) {
if (mux == NULL || color_profile == NULL) return WEBP_MUX_INVALID_ARGUMENT;
return MuxGet(mux, IDX_ICCP, 1, color_profile);
}
WebPMuxError WebPMuxGetLoopCount(const WebPMux* const mux,
int* const loop_count) {
WebPMuxError WebPMuxGetLoopCount(const WebPMux* mux, int* loop_count) {
WebPData image;
WebPMuxError err;
@ -348,16 +347,16 @@ static WebPMuxError MuxGetFrameTileInternal(
return SynthesizeBitstream(wpi, bitstream);
}
WebPMuxError WebPMuxGetFrame(const WebPMux* const mux, uint32_t nth,
WebPData* const bitstream, int* const x_offset,
int* const y_offset, int* const duration) {
WebPMuxError WebPMuxGetFrame(const WebPMux* mux, uint32_t nth,
WebPData* bitstream,
int* x_offset, int* y_offset, int* duration) {
return MuxGetFrameTileInternal(mux, nth, bitstream, x_offset, y_offset,
duration, kChunks[IDX_FRAME].tag);
}
WebPMuxError WebPMuxGetTile(const WebPMux* const mux, uint32_t nth,
WebPData* const bitstream,
int* const x_offset, int* const y_offset) {
WebPMuxError WebPMuxGetTile(const WebPMux* mux, uint32_t nth,
WebPData* bitstream,
int* x_offset, int* y_offset) {
return MuxGetFrameTileInternal(mux, nth, bitstream, x_offset, y_offset, NULL,
kChunks[IDX_TILE].tag);
}
@ -384,7 +383,7 @@ static int CountChunks(const WebPChunk* const chunk_list, uint32_t tag) {
return count;
}
WebPMuxError WebPMuxNumChunks(const WebPMux* const mux,
WebPMuxError WebPMuxNumChunks(const WebPMux* mux,
WebPChunkId id, int* num_elements) {
if (mux == NULL || num_elements == NULL) {
return WEBP_MUX_INVALID_ARGUMENT;

View File

@ -146,7 +146,7 @@ static void ShiftBytes(VP8LBitReader* const br) {
void VP8LFillBitWindow(VP8LBitReader* const br) {
if (br->bit_pos_ >= 32) {
#if defined(__x86_64__)
#if defined(__x86_64__) || defined(_M_X64)
if (br->pos_ + 8 < br->len_) {
br->val_ >>= 32;
// The expression below needs a little-endian arch to work correctly.

View File

@ -7,7 +7,7 @@
//
// Color Cache for WebP Lossless
//
// Author: jyrki@google.com (Jyrki Alakuijala)
// Author: Jyrki Alakuijala (jyrki@google.com)
#include <assert.h>
#include <stdlib.h>
@ -35,14 +35,10 @@ int VP8LColorCacheInit(VP8LColorCache* const cc, int hash_bits) {
void VP8LColorCacheClear(VP8LColorCache* const cc) {
if (cc != NULL) {
free(cc->colors_);
cc->colors_ = NULL;
}
}
void VP8LColorCacheDelete(VP8LColorCache* const cc) {
VP8LColorCacheClear(cc);
free(cc);
}
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif

View File

@ -7,8 +7,8 @@
//
// Color Cache for WebP Lossless
//
// Authors: jyrki@google.com (Jyrki Alakuijala)
// urvang@google.com (Urvang Joshi)
// Authors: Jyrki Alakuijala (jyrki@google.com)
// Urvang Joshi (urvang@google.com)
#ifndef WEBP_UTILS_COLOR_CACHE_H_
#define WEBP_UTILS_COLOR_CACHE_H_
@ -56,12 +56,9 @@ static WEBP_INLINE int VP8LColorCacheContains(const VP8LColorCache* const cc,
// Returns false in case of memory error.
int VP8LColorCacheInit(VP8LColorCache* const color_cache, int hash_bits);
// Delete the color cache.
// Delete the memory associated to color cache.
void VP8LColorCacheClear(VP8LColorCache* const color_cache);
// Delete the color_cache object.
void VP8LColorCacheDelete(VP8LColorCache* const color_cache);
//------------------------------------------------------------------------------
#if defined(__cplusplus) || defined(c_plusplus)

View File

@ -7,7 +7,7 @@
//
// Utilities for building and looking up Huffman trees.
//
// Author: urvang@google.com (Urvang Joshi)
// Author: Urvang Joshi (urvang@google.com)
#include <assert.h>
#include <stdlib.h>

View File

@ -7,7 +7,7 @@
//
// Utilities for building and looking up Huffman trees.
//
// Author: urvang@google.com (Urvang Joshi)
// Author: Urvang Joshi (urvang@google.com)
#ifndef WEBP_UTILS_HUFFMAN_H_
#define WEBP_UTILS_HUFFMAN_H_

View File

@ -5,9 +5,9 @@
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
// -----------------------------------------------------------------------------
//
// Author: jyrki@google.com (Jyrki Alakuijala)
// Author: Jyrki Alakuijala (jyrki@google.com)
//
// Flate-like entropy encoding (Huffman) for webp lossless.
// Entropy encoding (Huffman) for webp lossless.
#include <assert.h>
#include <stdlib.h>

View File

@ -5,9 +5,9 @@
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
// -----------------------------------------------------------------------------
//
// Author: jyrki@google.com (Jyrki Alakuijala)
// Author: Jyrki Alakuijala (jyrki@google.com)
//
// Flate-like entropy encoding (Huffman) for webp lossless
// Entropy encoding (Huffman) for webp lossless
#ifndef WEBP_UTILS_HUFFMAN_ENCODE_H_
#define WEBP_UTILS_HUFFMAN_ENCODE_H_

View File

@ -8,7 +8,7 @@
// Quantize levels for specified number of quantization-levels ([2, 256]).
// Min and max values are preserved (usual 0 and 255 for alpha plane).
//
// Author: skal@google.com (Pascal Massimino)
// Author: Skal (pascal.massimino@gmail.com)
#include <assert.h>
#include <math.h> // for sqrt()

View File

@ -7,7 +7,7 @@
//
// Alpha plane quantization utility
//
// Author: vikasa@google.com (Vikas Arora)
// Author: Vikas Arora (vikasa@google.com)
#ifndef WEBP_UTILS_QUANT_LEVELS_H_
#define WEBP_UTILS_QUANT_LEVELS_H_

View File

@ -7,7 +7,7 @@
//
// Rescaling functions
//
// Author: skal@google.com (Pascal Massimino)
// Author: Skal (pascal.massimino@gmail.com)
#ifndef WEBP_UTILS_RESCALER_H_
#define WEBP_UTILS_RESCALER_H_

View File

@ -7,7 +7,8 @@
//
// Multi-threaded worker
//
// Author: skal@google.com (Pascal Massimino)
// Author: Skal (pascal.massimino@gmail.com)
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@ -7,7 +7,7 @@
//
// Multi-threaded worker
//
// Author: skal@google.com (Pascal Massimino)
// Author: Skal (pascal.massimino@gmail.com)
#ifndef WEBP_UTILS_THREAD_H_
#define WEBP_UTILS_THREAD_H_

View File

@ -5,7 +5,7 @@
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
// -----------------------------------------------------------------------------
//
// Main decoding functions for WEBP images.
// Main decoding functions for WebP images.
//
// Author: Skal (pascal.massimino@gmail.com)
@ -18,7 +18,7 @@
extern "C" {
#endif
#define WEBP_DECODER_ABI_VERSION 0x0003
#define WEBP_DECODER_ABI_VERSION 0x0100 // MAJOR(8b) + MINOR(8b)
// Return the decoder's version number, packed in hexadecimal using 8bits for
// each of major/minor/revision. E.g: v2.5.7 is 0x020507.
@ -27,37 +27,41 @@ WEBP_EXTERN(int) WebPGetDecoderVersion(void);
// Retrieve basic header information: width, height.
// This function will also validate the header and return 0 in
// case of formatting error.
// Pointers *width/*height can be passed NULL if deemed irrelevant.
// Pointers 'width' and 'height' can be passed NULL if deemed irrelevant.
WEBP_EXTERN(int) WebPGetInfo(const uint8_t* data, size_t data_size,
int* width, int* height);
// Decodes WEBP images pointed to by *data and returns RGB samples, along
// with the dimensions in *width and *height.
// Decodes WebP images pointed to by 'data' and returns RGBA samples, along
// with the dimensions in *width and *height. The ordering of samples in
// memory is R, G, B, A, R, G, B, A... in scan order (endian-independent).
// The returned pointer should be deleted calling free().
// Returns NULL in case of error.
WEBP_EXTERN(uint8_t*) WebPDecodeRGB(const uint8_t* data, size_t data_size,
int* width, int* height);
// Same as WebPDecodeRGB, but returning RGBA data.
WEBP_EXTERN(uint8_t*) WebPDecodeRGBA(const uint8_t* data, size_t data_size,
int* width, int* height);
// Same as WebPDecodeRGBA, but returning ARGB data.
// Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data.
WEBP_EXTERN(uint8_t*) WebPDecodeARGB(const uint8_t* data, size_t data_size,
int* width, int* height);
// This variant decode to BGR instead of RGB.
WEBP_EXTERN(uint8_t*) WebPDecodeBGR(const uint8_t* data, size_t data_size,
int* width, int* height);
// This variant decodes to BGRA instead of RGBA.
// Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data.
WEBP_EXTERN(uint8_t*) WebPDecodeBGRA(const uint8_t* data, size_t data_size,
int* width, int* height);
// Decode WEBP images stored in *data in Y'UV format(*). The pointer returned is
// the Y samples buffer. Upon return, *u and *v will point to the U and V
// chroma data. These U and V buffers need NOT be free()'d, unlike the returned
// Y luma one. The dimension of the U and V planes are both (*width + 1) / 2
// and (*height + 1)/ 2.
// Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data.
// If the bitstream contains transparency, it is ignored.
WEBP_EXTERN(uint8_t*) WebPDecodeRGB(const uint8_t* data, size_t data_size,
int* width, int* height);
// Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data.
WEBP_EXTERN(uint8_t*) WebPDecodeBGR(const uint8_t* data, size_t data_size,
int* width, int* height);
// Decode WebP images pointed to by 'data' to Y'UV format(*). The pointer
// returned is the Y samples buffer. Upon return, *u and *v will point to
// the U and V chroma data. These U and V buffers need NOT be free()'d,
// unlike the returned Y luma one. The dimension of the U and V planes
// are both (*width + 1) / 2 and (*height + 1)/ 2.
// Upon return, the Y buffer has a stride returned as '*stride', while U and V
// have a common stride returned as '*uv_stride'.
// Return NULL in case of error.
@ -75,20 +79,22 @@ WEBP_EXTERN(uint8_t*) WebPDecodeYUV(const uint8_t* data, size_t data_size,
// The parameter 'output_stride' specifies the distance (in bytes)
// between scanlines. Hence, output_buffer_size is expected to be at least
// output_stride x picture-height.
WEBP_EXTERN(uint8_t*) WebPDecodeRGBInto(
const uint8_t* data, size_t data_size,
uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
WEBP_EXTERN(uint8_t*) WebPDecodeRGBAInto(
const uint8_t* data, size_t data_size,
uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
WEBP_EXTERN(uint8_t*) WebPDecodeARGBInto(
const uint8_t* data, size_t data_size,
uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
// BGR variants
WEBP_EXTERN(uint8_t*) WebPDecodeBGRInto(
WEBP_EXTERN(uint8_t*) WebPDecodeBGRAInto(
const uint8_t* data, size_t data_size,
uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
WEBP_EXTERN(uint8_t*) WebPDecodeBGRAInto(
// RGB and BGR variants. Here too the transparency information, if present,
// will be dropped and ignored.
WEBP_EXTERN(uint8_t*) WebPDecodeRGBInto(
const uint8_t* data, size_t data_size,
uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
WEBP_EXTERN(uint8_t*) WebPDecodeBGRInto(
const uint8_t* data, size_t data_size,
uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
@ -109,6 +115,10 @@ WEBP_EXTERN(uint8_t*) WebPDecodeYUVInto(
// Output colorspaces and buffer
// Colorspaces
// Note: the naming describes the byte-ordering of packed samples in memory.
// For instance, MODE_BGRA relates to samples ordered as B,G,R,A,B,G,R,A,...
// Non-capital names (e.g.:MODE_Argb) relates to pre-multiplied RGB channels.
// RGB-565 and RGBA-4444 are also endian-agnostic and byte-oriented.
typedef enum { MODE_RGB = 0, MODE_RGBA = 1,
MODE_BGR = 2, MODE_BGRA = 3,
MODE_ARGB = 4, MODE_RGBA_4444 = 5,
@ -140,7 +150,7 @@ static WEBP_INLINE int WebPIsRGBMode(WEBP_CSP_MODE mode) {
}
//------------------------------------------------------------------------------
// WebPDecBuffer: Generic structure for describing the sample buffer.
// WebPDecBuffer: Generic structure for describing the output sample buffer.
typedef struct { // view as RGBA
uint8_t* rgba; // pointer to RGBA samples
@ -167,23 +177,25 @@ typedef struct {
WebPRGBABuffer RGBA;
WebPYUVABuffer YUVA;
} u; // Nameless union of buffer parameters.
uint32_t pad[4]; // padding for later use
uint8_t* private_memory; // Internally allocated memory (only when
// is_external_memory is false). Should not be used
// externally, but accessed via the buffer union.
} WebPDecBuffer;
// Internal, version-checked, entry point
WEBP_EXTERN(int) WebPInitDecBufferInternal(WebPDecBuffer* const, int);
WEBP_EXTERN(int) WebPInitDecBufferInternal(WebPDecBuffer*, int);
// Initialize the structure as empty. Must be called before any other use.
// Returns false in case of version mismatch
static WEBP_INLINE int WebPInitDecBuffer(WebPDecBuffer* const buffer) {
static WEBP_INLINE int WebPInitDecBuffer(WebPDecBuffer* buffer) {
return WebPInitDecBufferInternal(buffer, WEBP_DECODER_ABI_VERSION);
}
// Free any memory associated with the buffer. Must always be called last.
// Note: doesn't free the 'buffer' structure itself.
WEBP_EXTERN(void) WebPFreeDecBuffer(WebPDecBuffer* const buffer);
WEBP_EXTERN(void) WebPFreeDecBuffer(WebPDecBuffer* buffer);
//------------------------------------------------------------------------------
// Enumeration of the status codes
@ -211,7 +223,7 @@ typedef enum {
// WebPInitDecBuffer(&buffer);
// buffer.colorspace = mode;
// ...
// WebPIDecoder* const idec = WebPINewDecoder(&buffer);
// WebPIDecoder* idec = WebPINewDecoder(&buffer);
// while (has_more_data) {
// // ... (get additional data)
// status = WebPIAppend(idec, new_data, new_data_size);
@ -233,15 +245,15 @@ typedef struct WebPIDecoder WebPIDecoder;
// is kept, which means that the lifespan of 'output_buffer' must be larger than
// that of the returned WebPIDecoder object.
// Returns NULL if the allocation failed.
WEBP_EXTERN(WebPIDecoder*) WebPINewDecoder(WebPDecBuffer* const output_buffer);
WEBP_EXTERN(WebPIDecoder*) WebPINewDecoder(WebPDecBuffer* output_buffer);
// This function allocates and initializes an incremental-decoder object, which
// will output the r/g/b(/a) samples specified by 'mode' into a preallocated
// will output the RGB/A samples specified by 'csp' into a preallocated
// buffer 'output_buffer'. The size of this buffer is at least
// 'output_buffer_size' and the stride (distance in bytes between two scanlines)
// is specified by 'output_stride'. Returns NULL if the allocation failed.
WEBP_EXTERN(WebPIDecoder*) WebPINewRGB(
WEBP_CSP_MODE mode,
WEBP_CSP_MODE csp,
uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
// This function allocates and initializes an incremental-decoder object, which
@ -258,13 +270,13 @@ WEBP_EXTERN(WebPIDecoder*) WebPINewYUV(
// Deletes the WebPIDecoder object and associated memory. Must always be called
// if WebPINewDecoder, WebPINewRGB or WebPINewYUV succeeded.
WEBP_EXTERN(void) WebPIDelete(WebPIDecoder* const idec);
WEBP_EXTERN(void) WebPIDelete(WebPIDecoder* idec);
// Copies and decodes the next available data. Returns VP8_STATUS_OK when
// the image is successfully decoded. Returns VP8_STATUS_SUSPENDED when more
// data is expected. Returns error in other cases.
WEBP_EXTERN(VP8StatusCode) WebPIAppend(
WebPIDecoder* const idec, const uint8_t* const data, size_t data_size);
WebPIDecoder* idec, const uint8_t* data, size_t data_size);
// A variant of the above function to be used when data buffer contains
// partial data from the beginning. In this case data buffer is not copied
@ -272,22 +284,22 @@ WEBP_EXTERN(VP8StatusCode) WebPIAppend(
// Note that the value of the 'data' pointer can change between calls to
// WebPIUpdate, for instance when the data buffer is resized to fit larger data.
WEBP_EXTERN(VP8StatusCode) WebPIUpdate(
WebPIDecoder* const idec, const uint8_t* const data, size_t data_size);
WebPIDecoder* idec, const uint8_t* data, size_t data_size);
// Returns the r/g/b/(a) image decoded so far. Returns NULL if output params
// are not initialized yet. The r/g/b/(a) output type corresponds to the mode
// specified in WebPINewDecoder()/WebPINewRGB().
// Returns the RGB/A image decoded so far. Returns NULL if output params
// are not initialized yet. The RGB/A output type corresponds to the colorspace
// specified during call to WebPINewDecoder() or WebPINewRGB().
// *last_y is the index of last decoded row in raster scan order. Some pointers
// (*last_y, *width etc.) can be NULL if corresponding information is not
// needed.
WEBP_EXTERN(uint8_t*) WebPIDecGetRGB(
const WebPIDecoder* const idec, int* last_y,
const WebPIDecoder* idec, int* last_y,
int* width, int* height, int* stride);
// Same as above function to get YUV image. Returns pointer to the luma plane
// or NULL in case of error.
WEBP_EXTERN(uint8_t*) WebPIDecGetYUV(
const WebPIDecoder* const idec, int* last_y,
const WebPIDecoder* idec, int* last_y,
uint8_t** u, uint8_t** v,
int* width, int* height, int* stride, int* uv_stride);
@ -298,9 +310,7 @@ WEBP_EXTERN(uint8_t*) WebPIDecGetYUV(
// Otherwise returns the pointer to the internal representation. This structure
// is read-only, tied to WebPIDecoder's lifespan and should not be modified.
WEBP_EXTERN(const WebPDecBuffer*) WebPIDecodedArea(
const WebPIDecoder* const idec,
int* const left, int* const top,
int* const width, int* const height);
const WebPIDecoder* idec, int* left, int* top, int* width, int* height);
//------------------------------------------------------------------------------
// Advanced decoding parametrization
@ -337,19 +347,22 @@ WEBP_EXTERN(const WebPDecBuffer*) WebPIDecodedArea(
// Features gathered from the bitstream
typedef struct {
int width; // the original width, as read from the bitstream
int height; // the original height, as read from the bitstream
int has_alpha; // true if bitstream contains an alpha channel
int width; // Width in pixels, as read from the bitstream.
int height; // Height in pixels, as read from the bitstream.
int has_alpha; // True if the bitstream contains an alpha channel.
// Unused for now:
int bitstream_version; // should be 0 for now. TODO(later)
int no_incremental_decoding; // if true, using incremental decoding is not
// recommended.
int rotate; // TODO(later)
int uv_sampling; // should be 0 for now. TODO(later)
int bitstream_version; // should be 0 for now. TODO(later)
uint32_t pad[3]; // padding for later use
} WebPBitstreamFeatures;
// Internal, version-checked, entry point
WEBP_EXTERN(VP8StatusCode) WebPGetFeaturesInternal(
const uint8_t*, size_t, WebPBitstreamFeatures* const, int);
const uint8_t*, size_t, WebPBitstreamFeatures*, int);
// Retrieve features from the bitstream. The *features structure is filled
// with information gathered from the bitstream.
@ -357,7 +370,7 @@ WEBP_EXTERN(VP8StatusCode) WebPGetFeaturesInternal(
// In case of error, features->bitstream_status will reflect the error code.
static WEBP_INLINE VP8StatusCode WebPGetFeatures(
const uint8_t* data, size_t data_size,
WebPBitstreamFeatures* const features) {
WebPBitstreamFeatures* features) {
return WebPGetFeaturesInternal(data, data_size, features,
WEBP_DECODER_ABI_VERSION);
}
@ -372,9 +385,12 @@ typedef struct {
int crop_width, crop_height; // dimension of the cropping area
int use_scaling; // if true, scaling is applied _afterward_
int scaled_width, scaled_height; // final resolution
int use_threads; // if true, use multi-threaded decoding
// Unused for now:
int force_rotation; // forced rotation (to be applied _last_)
int no_enhancement; // if true, discard enhancement layer
int use_threads; // if true, use multi-threaded decoding
uint32_t pad[6]; // padding for later use
} WebPDecoderOptions;
// Main object storing the configuration for advanced decoding.
@ -385,32 +401,32 @@ typedef struct {
} WebPDecoderConfig;
// Internal, version-checked, entry point
WEBP_EXTERN(int) WebPInitDecoderConfigInternal(WebPDecoderConfig* const, int);
WEBP_EXTERN(int) WebPInitDecoderConfigInternal(WebPDecoderConfig*, int);
// Initialize the configuration as empty. This function must always be
// called first, unless WebPGetFeatures() is to be called.
// Returns false in case of mismatched version.
static WEBP_INLINE int WebPInitDecoderConfig(WebPDecoderConfig* const config) {
static WEBP_INLINE int WebPInitDecoderConfig(WebPDecoderConfig* config) {
return WebPInitDecoderConfigInternal(config, WEBP_DECODER_ABI_VERSION);
}
// Instantiate a new incremental decoder object with requested configuration.
// The bitstream can be passed using *data and data_size parameter,
// in which case the features will be parsed and stored into config->input.
// Otherwise, 'data' can be NULL and now parsing will occur.
// Note that 'config' can be NULL too, in which case a default configuration is
// used.
// Instantiate a new incremental decoder object with the requested
// configuration. The bitstream can be passed using 'data' and 'data_size'
// parameter, in which case the features will be parsed and stored into
// config->input. Otherwise, 'data' can be NULL and no parsing will occur.
// Note that 'config' can be NULL too, in which case a default configuration
// is used.
// The return WebPIDecoder object must always be deleted calling WebPIDelete().
// Returns NULL in case of error (and config->status will then reflect
// the error condition).
WEBP_EXTERN(WebPIDecoder*) WebPIDecode(const uint8_t* data, size_t data_size,
WebPDecoderConfig* const config);
WebPDecoderConfig* config);
// Non-incremental version. This version decodes the full data at once, taking
// 'config' into account. Return decoding status (VP8_STATUS_OK if decoding
// was successful).
// 'config' into account. Returns decoding status (which should be VP8_STATUS_OK
// if the decoding was successful).
WEBP_EXTERN(VP8StatusCode) WebPDecode(const uint8_t* data, size_t data_size,
WebPDecoderConfig* const config);
WebPDecoderConfig* config);
#if defined(__cplusplus) || defined(c_plusplus)
} // extern "C"

View File

@ -18,7 +18,7 @@
extern "C" {
#endif
#define WEBP_ENCODER_ABI_VERSION 0x0003
#define WEBP_ENCODER_ABI_VERSION 0x0100 // MAJOR(8b) + MINOR(8b)
// Return the encoder's version number, packed in hexadecimal using 8bits for
// each of major/minor/revision. E.g: v2.5.7 is 0x020507.
@ -30,6 +30,9 @@ WEBP_EXTERN(int) WebPGetEncoderVersion(void);
// Returns the size of the compressed data (pointed to by *output), or 0 if
// an error occurred. The compressed data must be released by the caller
// using the call 'free(*output)'.
// These functions compress using the lossy format, and the quality_factor
// can go from 0 (smaller output, lower quality) to 100 (best quality,
// larger output).
WEBP_EXTERN(size_t) WebPEncodeRGB(const uint8_t* rgb,
int width, int height, int stride,
float quality_factor, uint8_t** output);
@ -43,6 +46,22 @@ WEBP_EXTERN(size_t) WebPEncodeBGRA(const uint8_t* bgra,
int width, int height, int stride,
float quality_factor, uint8_t** output);
// These functions are the equivalent of the above, but compressing in a
// lossless manner. Files are usually larger than lossy format, but will
// not suffer any compression loss.
WEBP_EXTERN(size_t) WebPEncodeLosslessRGB(const uint8_t* rgb,
int width, int height, int stride,
uint8_t** output);
WEBP_EXTERN(size_t) WebPEncodeLosslessBGR(const uint8_t* bgr,
int width, int height, int stride,
uint8_t** output);
WEBP_EXTERN(size_t) WebPEncodeLosslessRGBA(const uint8_t* rgba,
int width, int height, int stride,
uint8_t** output);
WEBP_EXTERN(size_t) WebPEncodeLosslessBGRA(const uint8_t* bgra,
int width, int height, int stride,
uint8_t** output);
//------------------------------------------------------------------------------
// Coding parameters
@ -54,37 +73,42 @@ typedef enum {
} WebPImageHint;
typedef struct {
int lossless; // Lossless encoding (0=lossy(default), 1=lossless).
float quality; // between 0 (smallest file) and 100 (biggest)
int method; // quality/speed trade-off (0=fast, 6=slower-better)
WebPImageHint image_hint; // Hint for image type (lossless only for now).
// Parameters related to lossy compression only:
int target_size; // if non-zero, set the desired target size in bytes.
// Takes precedence over the 'compression' parameter.
float target_PSNR; // if non-zero, specifies the minimal distortion to
// try to achieve. Takes precedence over target_size.
int method; // quality/speed trade-off (0=fast, 6=slower-better)
int segments; // maximum number of segments to use, in [1..4]
int sns_strength; // Spatial Noise Shaping. 0=off, 100=maximum.
int filter_strength; // range: [0 = off .. 100 = strongest]
int filter_sharpness; // range: [0 = off .. 7 = least sharp]
int filter_type; // filtering type: 0 = simple, 1 = strong
// (only used if filter_strength > 0 or autofilter > 0)
int filter_type; // filtering type: 0 = simple, 1 = strong (only used
// if filter_strength > 0 or autofilter > 0)
int autofilter; // Auto adjust filter's strength [0 = off, 1 = on]
int alpha_compression; // Algorithm for encoding the alpha plane (0 = none,
// 1 = compressed with WebP lossless). Default is 1.
int alpha_filtering; // Predictive filtering method for alpha plane.
// 0: none, 1: fast, 2: best. Default if 1.
int alpha_quality; // Between 0 (smallest size) and 100 (lossless).
// Default is 100.
int pass; // number of entropy-analysis passes (in [1..10]).
int show_compressed; // if true, export the compressed picture back.
// In-loop filtering is not applied.
int preprocessing; // preprocessing filter (0=none, 1=segment-smooth)
int partitions; // log2(number of token partitions) in [0..3]
// Default is set to 0 for easier progressive decoding.
int partition_limit; // quality degradation allowed to fit the 512k limit on
// prediction modes coding (0=no degradation, 100=full)
int alpha_compression; // Algorithm for encoding the alpha plane (0 = none,
// 1 = backward reference counts encoded with
// arithmetic encoder). Default is 1.
int alpha_filtering; // Predictive filtering method for alpha plane.
// 0: none, 1: fast, 2: best. Default if 1.
int alpha_quality; // Between 0 (smallest size) and 100 (lossless).
// Default is 100.
int lossless; // Lossless encoding (0=lossy(default), 1=lossless).
WebPImageHint image_hint; // Hint for image type.
int partitions; // log2(number of token partitions) in [0..3]. Default
// is set to 0 for easier progressive decoding.
int partition_limit; // quality degradation allowed to fit the 512k limit
// on prediction modes coding (0: no degradation,
// 100: maximum possible degradation).
uint32_t pad[8]; // padding for later use
} WebPConfig;
// Enumerate some predefined settings for WebPConfig, depending on the type
@ -99,13 +123,13 @@ typedef enum {
} WebPPreset;
// Internal, version-checked, entry point
WEBP_EXTERN(int) WebPConfigInitInternal(
WebPConfig* const, WebPPreset, float, int);
WEBP_EXTERN(int) WebPConfigInitInternal(WebPConfig*, WebPPreset, float, int);
// Should always be called, to initialize a fresh WebPConfig structure before
// modification. Returns false in case of version mismatch. WebPConfigInit()
// must have succeeded before using the 'config' object.
static WEBP_INLINE int WebPConfigInit(WebPConfig* const config) {
// Note that the default values are lossless=0 and quality=75.
static WEBP_INLINE int WebPConfigInit(WebPConfig* config) {
return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f,
WEBP_ENCODER_ABI_VERSION);
}
@ -114,7 +138,7 @@ static WEBP_INLINE int WebPConfigInit(WebPConfig* const config) {
// set of parameters (referred to by 'preset') and a given quality factor.
// This function can be called as a replacement to WebPConfigInit(). Will
// return false in case of error.
static WEBP_INLINE int WebPConfigPreset(WebPConfig* const config,
static WEBP_INLINE int WebPConfigPreset(WebPConfig* config,
WebPPreset preset, float quality) {
return WebPConfigInitInternal(config, preset, quality,
WEBP_ENCODER_ABI_VERSION);
@ -122,17 +146,18 @@ static WEBP_INLINE int WebPConfigPreset(WebPConfig* const config,
// Returns true if 'config' is non-NULL and all configuration parameters are
// within their valid ranges.
WEBP_EXTERN(int) WebPValidateConfig(const WebPConfig* const config);
WEBP_EXTERN(int) WebPValidateConfig(const WebPConfig* config);
//------------------------------------------------------------------------------
// Input / Output
typedef struct WebPPicture WebPPicture; // main structure for I/O
// non-essential structure for storing auxiliary statistics
// Structure for storing auxiliary statistics (mostly for lossy encoding).
typedef struct {
float PSNR[4]; // peak-signal-to-noise ratio for Y/U/V/All
int coded_size; // final size
float PSNR[4]; // peak-signal-to-noise ratio for Y/U/V/All
int block_count[3]; // number of intra4/intra16/skipped macroblocks
int header_bytes[2]; // approximate number of bytes spent for header
// and mode-partition #0
@ -147,13 +172,15 @@ typedef struct {
void* user_data; // this field is free to be set to any value and
// used during callbacks (like progress-report e.g.).
uint32_t pad[6]; // padding for later use
} WebPAuxStats;
// Signature for output function. Should return true if writing was successful.
// data/data_size is the segment of data to write, and 'picture' is for
// reference (and so one can make use of picture->custom_ptr).
typedef int (*WebPWriterFunction)(const uint8_t* data, size_t data_size,
const WebPPicture* const picture);
const WebPPicture* picture);
// WebPMemoryWrite: a special WebPWriterFunction that writes to memory using
// the following WebPMemoryWriter object (to be set as a custom_ptr).
@ -161,20 +188,21 @@ typedef struct {
uint8_t* mem; // final buffer (of size 'max_size', larger than 'size').
size_t size; // final size
size_t max_size; // total capacity
uint32_t pad[1]; // padding for later use
} WebPMemoryWriter;
// The following must be called first before any use.
WEBP_EXTERN(void) WebPMemoryWriterInit(WebPMemoryWriter* const writer);
WEBP_EXTERN(void) WebPMemoryWriterInit(WebPMemoryWriter* writer);
// The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon
// completion, writer.mem and writer.size will hold the coded data.
WEBP_EXTERN(int) WebPMemoryWrite(const uint8_t* data, size_t data_size,
const WebPPicture* const picture);
const WebPPicture* picture);
// Progress hook, called from time to time to report progress. It can return
// false to request an abort of the encoding process, or true otherwise if
// everything is OK.
typedef int (*WebPProgressHook)(int percent, const WebPPicture* const picture);
typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture);
typedef enum {
// chroma sampling
@ -210,20 +238,38 @@ typedef enum {
// maximum width/height allowed (inclusive), in pixels
#define WEBP_MAX_DIMENSION 16383
// Main exchange structure (input samples, output bytes, statistics)
struct WebPPicture {
// input
// INPUT
//////////////
// Main flag for encoder selecting between ARGB or YUV input.
// It is recommended to use ARGB input (*argb, argb_stride) for lossless
// compression, and YUV input (*y, *u, *v, etc.) for lossy compression
// since these are the respective native colorspace for these formats.
int use_argb;
// YUV input (mostly used for input to lossy compression)
WebPEncCSP colorspace; // colorspace: should be YUV420 for now (=Y'CbCr).
int width, height; // dimensions (less or equal to WEBP_MAX_DIMENSION)
uint8_t *y, *u, *v; // pointers to luma/chroma planes.
int y_stride, uv_stride; // luma/chroma strides.
uint8_t* a; // pointer to the alpha plane
int a_stride; // stride of the alpha plane
uint32_t pad1[2]; // padding for later use
// output
// ARGB input (mostly used for input to lossless compression)
uint32_t* argb; // Pointer to argb (32 bit) plane.
int argb_stride; // This is stride in pixels units, not bytes.
uint32_t pad2[3]; // padding for later use
// OUTPUT
///////////////
// Byte-emission hook, to store compressed bytes as they are ready.
WebPWriterFunction writer; // can be NULL
void* custom_ptr; // can be used by the writer.
// map for extra information
// map for extra information (only for lossy compression mode)
int extra_info_type; // 1: intra type, 2: segment, 3: quant
// 4: intra-16 prediction mode,
// 5: chroma prediction mode,
@ -233,33 +279,40 @@ struct WebPPicture {
// will be filled with a macroblock map, depending
// on extra_info_type.
// where to store statistics, if not NULL:
// STATS AND REPORTS
///////////////////////////
// Pointer to side statistics (updated only if not NULL)
WebPAuxStats* stats;
// original samples (for non-YUV420 modes)
// Error code for the latest error encountered during encoding
WebPEncodingError error_code;
// If not NULL, report progress during encoding.
WebPProgressHook progress_hook;
uint32_t pad3[3]; // padding for later use
// Unused for now: original samples (for non-YUV420 modes)
uint8_t *u0, *v0;
int uv0_stride;
WebPEncodingError error_code; // error code in case of problem.
uint32_t pad4[7]; // padding for later use
WebPProgressHook progress_hook; // if not NULL, called while encoding.
int use_argb_input; // Flag for encoder to use argb pixels as input.
uint32_t* argb; // Pointer to argb (32 bit) plane.
int argb_stride; // This is stride in pixels units, not bytes.
// private fields:
// PRIVATE FIELDS
////////////////////
void* memory_; // row chunk of memory for yuva planes
void* memory_argb_; // and for argb too.
void* pad5[2]; // padding for later use
};
// Internal, version-checked, entry point
WEBP_EXTERN(int) WebPPictureInitInternal(WebPPicture* const, int);
WEBP_EXTERN(int) WebPPictureInitInternal(WebPPicture*, int);
// Should always be called, to initialize the structure. Returns false in case
// of version mismatch. WebPPictureInit() must have succeeded before using the
// 'picture' object.
static WEBP_INLINE int WebPPictureInit(WebPPicture* const picture) {
// Note that, by default, use_argb is false and colorspace is WEBP_YUV420.
static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) {
return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION);
}
@ -270,25 +323,26 @@ static WEBP_INLINE int WebPPictureInit(WebPPicture* const picture) {
// Allocate y/u/v buffers as per colorspace/width/height specification.
// Note! This function will free the previous buffer if needed.
// Returns false in case of memory error.
WEBP_EXTERN(int) WebPPictureAlloc(WebPPicture* const picture);
WEBP_EXTERN(int) WebPPictureAlloc(WebPPicture* picture);
// Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*().
// Note that this function does _not_ free the memory used by the 'picture'
// object itself.
WEBP_EXTERN(void) WebPPictureFree(WebPPicture* const picture);
// Besides memory (which is reclaimed) all other fields of 'picture' are
// preserved.
WEBP_EXTERN(void) WebPPictureFree(WebPPicture* picture);
// Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return,
// *dst will fully own the copied pixels (this is not a view).
// Returns false in case of memory allocation error.
WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* const src,
WebPPicture* const dst);
WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* src, WebPPicture* dst);
// Compute PSNR or SSIM distortion between two pictures.
// Result is in dB, stores in result[] in the Y/U/V/Alpha/All order.
// Returns false in case of error (pic1 and pic2 don't have same dimension, ...)
// Warning: this function is rather CPU-intensive.
WEBP_EXTERN(int) WebPPictureDistortion(
const WebPPicture* const pic1, const WebPPicture* const pic2,
const WebPPicture* pic1, const WebPPicture* pic2,
int metric_type, // 0 = PSNR, 1 = SSIM
float result[5]);
@ -300,7 +354,7 @@ WEBP_EXTERN(int) WebPPictureDistortion(
// must be fully be comprised inside the 'src' source picture. If the source
// picture uses the YUV420 colorspace, the top and left coordinates will be
// snapped to even values.
WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* const picture,
WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* picture,
int left, int top, int width, int height);
// Extracts a view from 'src' picture into 'dst'. The rectangle for the view
@ -312,68 +366,67 @@ WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* const picture,
// ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so,
// the original dimension will be lost).
// Returns false in case of memory allocation error or invalid parameters.
WEBP_EXTERN(int) WebPPictureView(const WebPPicture* const src,
WEBP_EXTERN(int) WebPPictureView(const WebPPicture* src,
int left, int top, int width, int height,
WebPPicture* const dst);
WebPPicture* dst);
// Returns true if the 'picture' is actually a view and therefore does
// not own the memory for pixels.
WEBP_EXTERN(int) WebPPictureIsView(const WebPPicture* const picture);
WEBP_EXTERN(int) WebPPictureIsView(const WebPPicture* picture);
// Rescale a picture to new dimension width x height.
// Now gamma correction is applied.
// Returns false in case of error (invalid parameter or insufficient memory).
WEBP_EXTERN(int) WebPPictureRescale(WebPPicture* const pic,
int width, int height);
WEBP_EXTERN(int) WebPPictureRescale(WebPPicture* pic, int width, int height);
// Colorspace conversion function to import RGB samples.
// Previous buffer will be free'd, if any.
// *rgb buffer should have a size of at least height * rgb_stride.
// Returns false in case of memory error.
WEBP_EXTERN(int) WebPPictureImportRGB(
WebPPicture* const picture, const uint8_t* const rgb, int rgb_stride);
WebPPicture* picture, const uint8_t* rgb, int rgb_stride);
// Same, but for RGBA buffer.
WEBP_EXTERN(int) WebPPictureImportRGBA(
WebPPicture* const picture, const uint8_t* const rgba, int rgba_stride);
WebPPicture* picture, const uint8_t* rgba, int rgba_stride);
// Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format
// input buffer ignoring the alpha channel. Avoids needing to copy the data
// to a temporary 24-bit RGB buffer to import the RGB only.
WEBP_EXTERN(int) WebPPictureImportRGBX(
WebPPicture* const picture, const uint8_t* const rgbx, int rgbx_stride);
WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride);
// Variants of the above, but taking BGR(A|X) input.
WEBP_EXTERN(int) WebPPictureImportBGR(
WebPPicture* const picture, const uint8_t* const bgr, int bgr_stride);
WebPPicture* picture, const uint8_t* bgr, int bgr_stride);
WEBP_EXTERN(int) WebPPictureImportBGRA(
WebPPicture* const picture, const uint8_t* const bgra, int bgra_stride);
WebPPicture* picture, const uint8_t* bgra, int bgra_stride);
WEBP_EXTERN(int) WebPPictureImportBGRX(
WebPPicture* const picture, const uint8_t* const bgrx, int bgrx_stride);
WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride);
// Converts picture->argb data to the YUVA format specified by 'colorspace'.
// Upon return, picture->use_argb_input is set to false. The presence of
// real non-opaque transparent values is detected, and 'colorspace' will be
// Upon return, picture->use_argb is set to false. The presence of real
// non-opaque transparent values is detected, and 'colorspace' will be
// adjusted accordingly. Note that this method is lossy.
// Returns false in case of error.
WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* const picture,
WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture,
WebPEncCSP colorspace);
// Converts picture->yuv to picture->argb and sets picture->use_argb_input
// to true. The input format must be YUV_420 or YUV_420A.
// Converts picture->yuv to picture->argb and sets picture->use_argb to true.
// The input format must be YUV_420 or YUV_420A.
// Note that the use of this method is discouraged if one has access to the
// raw ARGB samples, since using YUV420 is comparatively lossy. Also, the
// conversion from YUV420 to ARGB incurs a small loss too.
// Returns false in case of error.
WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* const picture);
WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* picture);
// Helper function: given a width x height plane of YUV(A) samples
// (with stride 'stride'), clean-up the YUV samples under fully transparent
// area, to help compressibility (no guarantee, though).
WEBP_EXTERN(void) WebPCleanupTransparentArea(WebPPicture* const picture);
WEBP_EXTERN(void) WebPCleanupTransparentArea(WebPPicture* picture);
// Scan the picture 'picture' for the presence of non fully opaque alpha values.
// Returns true in such case. Otherwise returns false (indicating that the
// alpha plane can be ignored altogether e.g.).
WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* const picture);
WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* picture);
//------------------------------------------------------------------------------
// Main call
@ -384,12 +437,11 @@ WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* const picture);
// Returns false in case of error, true otherwise.
// In case of error, picture->error_code is updated accordingly.
// 'picture' can hold the source samples in both YUV(A) or ARGB input, depending
// on the value of 'picture->use_argb_input'. It is highly recommended to
// use the former for lossy encoding, and the latter for lossless encoding
// on the value of 'picture->use_argb'. It is highly recommended to use
// the former for lossy encoding, and the latter for lossless encoding
// (when config.lossless is true). Automatic conversion from one format to
// another is provided but they both incur some loss.
WEBP_EXTERN(int) WebPEncode(const WebPConfig* const config,
WebPPicture* const picture);
WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture);
//------------------------------------------------------------------------------

View File

@ -40,6 +40,9 @@
#define NUM_DISTANCE_CODES 40
#define CODE_LENGTH_CODES 19
#define MIN_HUFFMAN_BITS 2 // min number of Huffman bits
#define MAX_HUFFMAN_BITS 9 // max number of Huffman bits
#define TRANSFORM_PRESENT 1 // The bit to be written when next data
// to be read is a transform.
#define NUM_TRANSFORMS 4 // Maximum number of allowed transform

View File

@ -51,7 +51,7 @@
extern "C" {
#endif
#define WEBP_MUX_ABI_VERSION 0x0000
#define WEBP_MUX_ABI_VERSION 0x0100 // MAJOR(8b) + MINOR(8b)
// Error codes
typedef enum {
@ -99,15 +99,15 @@ typedef struct {
// Manipulation of a WebPData object.
// Initializes the contents of the 'webp_data' object with default values.
WEBP_EXTERN(void) WebPDataInit(WebPData* const webp_data);
WEBP_EXTERN(void) WebPDataInit(WebPData* webp_data);
// Clears the contents of the 'webp_data' object by calling free(). Does not
// deallocate the object itself.
WEBP_EXTERN(void) WebPDataClear(WebPData* const webp_data);
WEBP_EXTERN(void) WebPDataClear(WebPData* webp_data);
// Allocates necessary storage for 'dst' and copies the contents of 'src'.
// Returns true on success.
WEBP_EXTERN(int) WebPDataCopy(const WebPData* const src, WebPData* const dst);
WEBP_EXTERN(int) WebPDataCopy(const WebPData* src, WebPData* dst);
//------------------------------------------------------------------------------
// Life of a Mux object
@ -125,13 +125,13 @@ static WEBP_INLINE WebPMux* WebPMuxNew(void) {
// Deletes the mux object.
// Parameters:
// mux - (in/out) object to be deleted
WEBP_EXTERN(void) WebPMuxDelete(WebPMux* const mux);
WEBP_EXTERN(void) WebPMuxDelete(WebPMux* mux);
//------------------------------------------------------------------------------
// Mux creation.
// Internal, version-checked, entry point
WEBP_EXTERN(WebPMux*) WebPMuxCreateInternal(const WebPData* const, int, int);
WEBP_EXTERN(WebPMux*) WebPMuxCreateInternal(const WebPData*, int, int);
// Creates a mux object from raw data given in WebP RIFF format.
// Parameters:
@ -141,7 +141,7 @@ WEBP_EXTERN(WebPMux*) WebPMuxCreateInternal(const WebPData* const, int, int);
// Returns:
// A pointer to the mux object created from given data - on success.
// NULL - In case of invalid data or memory error.
static WEBP_INLINE WebPMux* WebPMuxCreate(const WebPData* const bitstream,
static WEBP_INLINE WebPMux* WebPMuxCreate(const WebPData* bitstream,
int copy_data) {
return WebPMuxCreateInternal(bitstream, copy_data, WEBP_MUX_ABI_VERSION);
}
@ -161,8 +161,9 @@ static WEBP_INLINE WebPMux* WebPMuxCreate(const WebPData* const bitstream,
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or bitstream is NULL.
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxSetImage(
WebPMux* const mux, const WebPData* const bitstream, int copy_data);
WEBP_EXTERN(WebPMuxError) WebPMuxSetImage(WebPMux* mux,
const WebPData* bitstream,
int copy_data);
// Gets image data from the mux object.
// The content of 'bitstream' is allocated using malloc(), and NOT
@ -176,8 +177,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxSetImage(
// OR mux contains animation/tiling.
// WEBP_MUX_NOT_FOUND - if image is not present in mux object.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxGetImage(const WebPMux* const mux,
WebPData* const bitstream);
WEBP_EXTERN(WebPMuxError) WebPMuxGetImage(const WebPMux* mux,
WebPData* bitstream);
// Deletes the image in the mux object.
// Parameters:
@ -187,7 +188,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetImage(const WebPMux* const mux,
// OR if mux contains animation/tiling.
// WEBP_MUX_NOT_FOUND - if image is not present in mux object.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteImage(WebPMux* const mux);
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteImage(WebPMux* mux);
//------------------------------------------------------------------------------
// XMP Metadata.
@ -203,8 +204,9 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteImage(WebPMux* const mux);
// WEBP_MUX_INVALID_ARGUMENT - if mux or metadata is NULL.
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxSetMetadata(
WebPMux* const mux, const WebPData* const metadata, int copy_data);
WEBP_EXTERN(WebPMuxError) WebPMuxSetMetadata(WebPMux* mux,
const WebPData* metadata,
int copy_data);
// Gets a reference to the XMP metadata in the mux object.
// The caller should NOT free the returned data.
@ -215,8 +217,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxSetMetadata(
// WEBP_MUX_INVALID_ARGUMENT - if either mux or metadata is NULL.
// WEBP_MUX_NOT_FOUND - if metadata is not present in mux object.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxGetMetadata(
const WebPMux* const mux, WebPData* const metadata);
WEBP_EXTERN(WebPMuxError) WebPMuxGetMetadata(const WebPMux* mux,
WebPData* metadata);
// Deletes the XMP metadata in the mux object.
// Parameters:
@ -225,7 +227,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetMetadata(
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
// WEBP_MUX_NOT_FOUND - If mux does not contain metadata.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteMetadata(WebPMux* const mux);
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteMetadata(WebPMux* mux);
//------------------------------------------------------------------------------
// ICC Color Profile.
@ -241,8 +243,9 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteMetadata(WebPMux* const mux);
// WEBP_MUX_INVALID_ARGUMENT - if mux or color_profile is NULL
// WEBP_MUX_MEMORY_ERROR - on memory allocation error
// WEBP_MUX_OK - on success
WEBP_EXTERN(WebPMuxError) WebPMuxSetColorProfile(
WebPMux* const mux, const WebPData* const color_profile, int copy_data);
WEBP_EXTERN(WebPMuxError) WebPMuxSetColorProfile(WebPMux* mux,
const WebPData* color_profile,
int copy_data);
// Gets a reference to the color profile in the mux object.
// The caller should NOT free the returned data.
@ -253,8 +256,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxSetColorProfile(
// WEBP_MUX_INVALID_ARGUMENT - if either mux or color_profile is NULL.
// WEBP_MUX_NOT_FOUND - if color profile is not present in mux object.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxGetColorProfile(
const WebPMux* const mux, WebPData* const color_profile);
WEBP_EXTERN(WebPMuxError) WebPMuxGetColorProfile(const WebPMux* mux,
WebPData* color_profile);
// Deletes the color profile in the mux object.
// Parameters:
@ -263,7 +266,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetColorProfile(
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
// WEBP_MUX_NOT_FOUND - If mux does not contain color profile.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteColorProfile(WebPMux* const mux);
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteColorProfile(WebPMux* mux);
//------------------------------------------------------------------------------
// Animation.
@ -286,7 +289,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteColorProfile(WebPMux* const mux);
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxPushFrame(
WebPMux* const mux, const WebPData* const bitstream,
WebPMux* mux, const WebPData* bitstream,
int x_offset, int y_offset, int duration, int copy_data);
// TODO(urvang): Create a struct as follows to reduce argument list size:
@ -315,8 +318,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxPushFrame(
// WEBP_MUX_BAD_DATA - if nth frame chunk in mux is invalid.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxGetFrame(
const WebPMux* const mux, uint32_t nth, WebPData* const bitstream,
int* const x_offset, int* const y_offset, int* const duration);
const WebPMux* mux, uint32_t nth, WebPData* bitstream,
int* x_offset, int* y_offset, int* duration);
// Deletes an animation frame from the mux object.
// nth=0 has a special meaning - last position.
@ -328,7 +331,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetFrame(
// WEBP_MUX_NOT_FOUND - If there are less than nth frames in the mux object
// before deletion.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteFrame(WebPMux* const mux, uint32_t nth);
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteFrame(WebPMux* mux, uint32_t nth);
// Sets the animation loop count in the mux object. Any existing loop count
// value(s) will be removed.
@ -340,8 +343,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteFrame(WebPMux* const mux, uint32_t nth);
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxSetLoopCount(WebPMux* const mux,
int loop_count);
WEBP_EXTERN(WebPMuxError) WebPMuxSetLoopCount(WebPMux* mux, int loop_count);
// Gets the animation loop count from the mux object.
// Parameters:
@ -351,8 +353,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxSetLoopCount(WebPMux* const mux,
// WEBP_MUX_INVALID_ARGUMENT - if either of mux or loop_count is NULL
// WEBP_MUX_NOT_FOUND - if loop chunk is not present in mux object.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxGetLoopCount(const WebPMux* const mux,
int* const loop_count);
WEBP_EXTERN(WebPMuxError) WebPMuxGetLoopCount(const WebPMux* mux,
int* loop_count);
//------------------------------------------------------------------------------
// Tiling.
@ -374,7 +376,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetLoopCount(const WebPMux* const mux,
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxPushTile(
WebPMux* const mux, const WebPData* const bitstream,
WebPMux* mux, const WebPData* bitstream,
int x_offset, int y_offset, int copy_data);
// Gets the nth tile from the mux object.
@ -395,8 +397,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxPushTile(
// WEBP_MUX_BAD_DATA - if nth tile chunk in mux is invalid.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxGetTile(
const WebPMux* const mux, uint32_t nth, WebPData* const bitstream,
int* const x_offset, int* const y_offset);
const WebPMux* mux, uint32_t nth, WebPData* bitstream,
int* x_offset, int* y_offset);
// Deletes a tile from the mux object.
// nth=0 has a special meaning - last position
@ -408,7 +410,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetTile(
// WEBP_MUX_NOT_FOUND - If there are less than nth tiles in the mux object
// before deletion.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteTile(WebPMux* const mux, uint32_t nth);
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteTile(WebPMux* mux, uint32_t nth);
//------------------------------------------------------------------------------
// Misc Utilities.
@ -424,7 +426,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteTile(WebPMux* const mux, uint32_t nth);
// WEBP_MUX_NOT_FOUND - if VP8X chunk is not present in mux object.
// WEBP_MUX_BAD_DATA - if VP8X chunk in mux is invalid.
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxGetFeatures(const WebPMux* const mux,
WEBP_EXTERN(WebPMuxError) WebPMuxGetFeatures(const WebPMux* mux,
uint32_t* flags);
// Gets number of chunks having tag value tag in the mux object.
@ -435,7 +437,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetFeatures(const WebPMux* const mux,
// Returns:
// WEBP_MUX_INVALID_ARGUMENT - if either mux, or num_elements is NULL
// WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxNumChunks(const WebPMux* const mux,
WEBP_EXTERN(WebPMuxError) WebPMuxNumChunks(const WebPMux* mux,
WebPChunkId id, int* num_elements);
// Assembles all chunks in WebP RIFF format and returns in 'assembled_data'.
@ -453,14 +455,14 @@ WEBP_EXTERN(WebPMuxError) WebPMuxNumChunks(const WebPMux* const mux,
// NULL.
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success
WEBP_EXTERN(WebPMuxError) WebPMuxAssemble(WebPMux* const mux,
WebPData* const assembled_data);
WEBP_EXTERN(WebPMuxError) WebPMuxAssemble(WebPMux* mux,
WebPData* assembled_data);
//------------------------------------------------------------------------------
// Demux API.
// Enables extraction of image and extended format data from WebP files.
#define WEBP_DEMUX_ABI_VERSION 0x0000
#define WEBP_DEMUX_ABI_VERSION 0x0100 // MAJOR(8b) + MINOR(8b)
typedef struct WebPDemuxer WebPDemuxer;
@ -475,12 +477,12 @@ typedef enum {
// Internal, version-checked, entry point
WEBP_EXTERN(WebPDemuxer*) WebPDemuxInternal(
const WebPData* const, int, WebPDemuxState* const, int);
const WebPData*, int, WebPDemuxState*, int);
// Parses the WebP file given by 'data'.
// A complete WebP file must be present in 'data' for the function to succeed.
// Returns a WebPDemuxer object on successful parse, NULL otherwise.
static WEBP_INLINE WebPDemuxer* WebPDemux(const WebPData* const data) {
static WEBP_INLINE WebPDemuxer* WebPDemux(const WebPData* data) {
return WebPDemuxInternal(data, 0, NULL, WEBP_DEMUX_ABI_VERSION);
}
@ -488,12 +490,12 @@ static WEBP_INLINE WebPDemuxer* WebPDemux(const WebPData* const data) {
// If 'state' is non-NULL it will be set to indicate the status of the demuxer.
// Returns a WebPDemuxer object on successful parse, NULL otherwise.
static WEBP_INLINE WebPDemuxer* WebPDemuxPartial(
const WebPData* const data, WebPDemuxState* const state) {
const WebPData* data, WebPDemuxState* state) {
return WebPDemuxInternal(data, 1, state, WEBP_DEMUX_ABI_VERSION);
}
// Frees memory associated with 'dmux'.
WEBP_EXTERN(void) WebPDemuxDelete(WebPDemuxer* const dmux);
WEBP_EXTERN(void) WebPDemuxDelete(WebPDemuxer* dmux);
//------------------------------------------------------------------------------
// Data/information extraction.
@ -509,7 +511,7 @@ typedef enum {
// NOTE: values are only valid if WebPDemux() was used or WebPDemuxPartial()
// returned a state > WEBP_DEMUX_PARSING_HEADER.
WEBP_EXTERN(uint32_t) WebPDemuxGetI(
const WebPDemuxer* const dmux, WebPFormatFeature feature);
const WebPDemuxer* dmux, WebPFormatFeature feature);
//------------------------------------------------------------------------------
// Frame iteration.
@ -526,6 +528,7 @@ typedef struct {
// still be decoded with the WebP incremental decoder.
WebPData tile_; // The frame or tile given by 'frame_num_' and 'tile_num_'.
uint32_t pad[4]; // padding for later use
void* private_;
} WebPIterator;
@ -537,22 +540,22 @@ typedef struct {
// Call WebPDemuxReleaseIterator() when use of the iterator is complete.
// NOTE: 'dmux' must persist for the lifetime of 'iter'.
WEBP_EXTERN(int) WebPDemuxGetFrame(
const WebPDemuxer* const dmux, int frame_number, WebPIterator* const iter);
const WebPDemuxer* dmux, int frame_number, WebPIterator* iter);
// Sets 'iter->tile_' to point to the next ('iter->frame_num_' + 1) or previous
// ('iter->frame_num_' - 1) frame. These functions do not loop.
// Returns true on success, false otherwise.
WEBP_EXTERN(int) WebPDemuxNextFrame(WebPIterator* const iter);
WEBP_EXTERN(int) WebPDemuxPrevFrame(WebPIterator* const iter);
WEBP_EXTERN(int) WebPDemuxNextFrame(WebPIterator* iter);
WEBP_EXTERN(int) WebPDemuxPrevFrame(WebPIterator* iter);
// Sets 'iter->tile_' to reflect tile number 'tile_number'.
// Returns true if tile 'tile_number' is present, false otherwise.
WEBP_EXTERN(int) WebPDemuxSelectTile(WebPIterator* const iter, int tile_number);
WEBP_EXTERN(int) WebPDemuxSelectTile(WebPIterator* iter, int tile_number);
// Releases any memory associated with 'iter'.
// Must be called before destroying the associated WebPDemuxer with
// WebPDemuxDelete().
WEBP_EXTERN(void) WebPDemuxReleaseIterator(WebPIterator* const iter);
WEBP_EXTERN(void) WebPDemuxReleaseIterator(WebPIterator* iter);
//------------------------------------------------------------------------------
// Chunk iteration.
@ -562,9 +565,9 @@ typedef struct {
// WebPDemuxGetChunk().
int chunk_num_;
int num_chunks_;
// The payload of the chunk.
WebPData chunk_;
WebPData chunk_; // The payload of the chunk.
uint32_t pad[6]; // padding for later use
void* private_;
} WebPChunkIterator;
@ -577,20 +580,20 @@ typedef struct {
// payloads are accessed through WebPDemuxGetFrame() and related functions.
// Call WebPDemuxReleaseChunkIterator() when use of the iterator is complete.
// NOTE: 'dmux' must persist for the lifetime of the iterator.
WEBP_EXTERN(int) WebPDemuxGetChunk(const WebPDemuxer* const dmux,
WEBP_EXTERN(int) WebPDemuxGetChunk(const WebPDemuxer* dmux,
const char fourcc[4], int chunk_number,
WebPChunkIterator* const iter);
WebPChunkIterator* iter);
// Sets 'iter->chunk_' to point to the next ('iter->chunk_num_' + 1) or previous
// ('iter->chunk_num_' - 1) chunk. These functions do not loop.
// Returns true on success, false otherwise.
WEBP_EXTERN(int) WebPDemuxNextChunk(WebPChunkIterator* const iter);
WEBP_EXTERN(int) WebPDemuxPrevChunk(WebPChunkIterator* const iter);
WEBP_EXTERN(int) WebPDemuxNextChunk(WebPChunkIterator* iter);
WEBP_EXTERN(int) WebPDemuxPrevChunk(WebPChunkIterator* iter);
// Releases any memory associated with 'iter'.
// Must be called before destroying the associated WebPDemuxer with
// WebPDemuxDelete().
WEBP_EXTERN(void) WebPDemuxReleaseChunkIterator(WebPChunkIterator* const iter);
WEBP_EXTERN(void) WebPDemuxReleaseChunkIterator(WebPChunkIterator* iter);
//------------------------------------------------------------------------------

View File

@ -39,4 +39,7 @@ typedef long long int int64_t;
#define WEBP_EXTERN(type) extern type
#endif /* WEBP_EXTERN */
// Macro to check ABI compatibility (same major revision number)
#define WEBP_ABI_IS_INCOMPATIBLE(a, b) (((a) >> 8) != ((b) >> 8))
#endif /* WEBP_WEBP_TYPES_H_ */

View File

@ -90,6 +90,10 @@ static jint returned_buffer_size(
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeBGR", 1 },
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeRGBA", 1 },
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeBGRA", 1 },
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessRGB", 1 },
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessBGR", 1 },
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessRGBA", 1 },
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessBGRA", 1 },
{ NULL, 0 }
};
const struct sizemap *p;
@ -108,6 +112,9 @@ static jint returned_buffer_size(
typedef size_t (*WebPEncodeFunction)(const uint8_t* rgb,
int width, int height, int stride,
float quality_factor, uint8_t** output);
typedef size_t (*WebPEncodeLosslessFunction)(const uint8_t* rgb,
int width, int height, int stride,
uint8_t** output);
static uint8_t* encode(const uint8_t* rgb,
int width, int height, int stride,
@ -123,6 +130,19 @@ static uint8_t* encode(const uint8_t* rgb,
*unused = 1;
return image_size ? output : NULL;
}
static uint8_t* encode_lossless(const uint8_t* rgb,
int width, int height, int stride,
WebPEncodeLosslessFunction encfn,
int* output_size, int* unused) {
uint8_t *output = NULL;
const size_t image_size = encfn(rgb, width, height, stride, &output);
// the values of following two will be interpreted by returned_buffer_size()
// as 'width' and 'height' in the size calculation.
*output_size = image_size;
*unused = 1;
return image_size ? output : NULL;
}
%}
//------------------------------------------------------------------------------
@ -137,6 +157,10 @@ static uint8_t* encode(const uint8_t* rgb,
%newobject wrap_WebPEncodeBGR;
%newobject wrap_WebPEncodeRGBA;
%newobject wrap_WebPEncodeBGRA;
%newobject wrap_WebPEncodeLosslessRGB;
%newobject wrap_WebPEncodeLosslessBGR;
%newobject wrap_WebPEncodeLosslessRGBA;
%newobject wrap_WebPEncodeLosslessBGRA;
#ifdef SWIGJAVA
// There's no reason to call these directly
@ -144,6 +168,10 @@ static uint8_t* encode(const uint8_t* rgb,
%javamethodmodifiers wrap_WebPEncodeBGR "private";
%javamethodmodifiers wrap_WebPEncodeRGBA "private";
%javamethodmodifiers wrap_WebPEncodeBGRA "private";
%javamethodmodifiers wrap_WebPEncodeLosslessRGB "private";
%javamethodmodifiers wrap_WebPEncodeLosslessBGR "private";
%javamethodmodifiers wrap_WebPEncodeLosslessRGBA "private";
%javamethodmodifiers wrap_WebPEncodeLosslessBGRA "private";
#endif /* SWIGJAVA */
%inline %{
@ -152,33 +180,36 @@ static uint8_t* encode(const uint8_t* rgb,
// than dealing with the return pointer.
// The additional parameters are to allow reuse of returned_buffer_size(),
// unused2 and output_size will be used in this case.
static uint8_t* wrap_WebPEncodeRGB(
const uint8_t* rgb, int* unused1, int* unused2, int* output_size,
int width, int height, int stride, float quality_factor) {
return encode(rgb, width, height, stride, quality_factor,
WebPEncodeRGB, output_size, unused2);
}
#define LOSSY_WRAPPER(FUNC) \
static uint8_t* wrap_##FUNC( \
const uint8_t* rgb, int* unused1, int* unused2, int* output_size, \
int width, int height, int stride, float quality_factor) { \
return encode(rgb, width, height, stride, quality_factor, \
FUNC, output_size, unused2); \
} \
static uint8_t* wrap_WebPEncodeBGR(
const uint8_t* bgr, int* unused1, int* unused2, int* output_size,
int width, int height, int stride, float quality_factor) {
return encode(bgr, width, height, stride, quality_factor,
WebPEncodeBGR, output_size, unused2);
}
LOSSY_WRAPPER(WebPEncodeRGB)
LOSSY_WRAPPER(WebPEncodeBGR)
LOSSY_WRAPPER(WebPEncodeRGBA)
LOSSY_WRAPPER(WebPEncodeBGRA)
static uint8_t* wrap_WebPEncodeRGBA(
const uint8_t* rgba, int* unused1, int* unused2, int* output_size,
int width, int height, int stride, float quality_factor) {
return encode(rgba, width, height, stride, quality_factor,
WebPEncodeRGBA, output_size, unused2);
}
#undef LOSSY_WRAPPER
#define LOSSLESS_WRAPPER(FUNC) \
static uint8_t* wrap_##FUNC( \
const uint8_t* rgb, int* unused1, int* unused2, int* output_size, \
int width, int height, int stride) { \
return encode_lossless(rgb, width, height, stride, \
FUNC, output_size, unused2); \
} \
LOSSLESS_WRAPPER(WebPEncodeLosslessRGB)
LOSSLESS_WRAPPER(WebPEncodeLosslessBGR)
LOSSLESS_WRAPPER(WebPEncodeLosslessRGBA)
LOSSLESS_WRAPPER(WebPEncodeLosslessBGRA)
#undef LOSSLESS_WRAPPER
static uint8_t* wrap_WebPEncodeBGRA(
const uint8_t* bgra, int* unused1, int* unused2, int* output_size,
int width, int height, int stride, float quality_factor) {
return encode(bgra, width, height, stride, quality_factor,
WebPEncodeBGRA, output_size, unused2);
}
%}
//------------------------------------------------------------------------------
@ -226,5 +257,29 @@ static uint8_t* wrap_WebPEncodeBGRA(
return wrap_WebPEncodeBGRA(
bgra, UNUSED, UNUSED, outputSize, width, height, stride, quality_factor);
}
public static byte[] WebPEncodeLosslessRGB(
byte[] rgb, int width, int height, int stride) {
return wrap_WebPEncodeLosslessRGB(
rgb, UNUSED, UNUSED, outputSize, width, height, stride);
}
public static byte[] WebPEncodeLosslessBGR(
byte[] bgr, int width, int height, int stride) {
return wrap_WebPEncodeLosslessBGR(
bgr, UNUSED, UNUSED, outputSize, width, height, stride);
}
public static byte[] WebPEncodeLosslessRGBA(
byte[] rgba, int width, int height, int stride) {
return wrap_WebPEncodeLosslessRGBA(
rgba, UNUSED, UNUSED, outputSize, width, height, stride);
}
public static byte[] WebPEncodeLosslessBGRA(
byte[] bgra, int width, int height, int stride) {
return wrap_WebPEncodeLosslessBGRA(
bgra, UNUSED, UNUSED, outputSize, width, height, stride);
}
%}
#endif /* SWIGJAVA */

Binary file not shown.

View File

@ -829,6 +829,10 @@ static jint returned_buffer_size(
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeBGR", 1 },
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeRGBA", 1 },
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeBGRA", 1 },
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessRGB", 1 },
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessBGR", 1 },
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessRGBA", 1 },
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessBGRA", 1 },
{ NULL, 0 }
};
const struct sizemap *p;
@ -847,6 +851,9 @@ static jint returned_buffer_size(
typedef size_t (*WebPEncodeFunction)(const uint8_t* rgb,
int width, int height, int stride,
float quality_factor, uint8_t** output);
typedef size_t (*WebPEncodeLosslessFunction)(const uint8_t* rgb,
int width, int height, int stride,
uint8_t** output);
static uint8_t* encode(const uint8_t* rgb,
int width, int height, int stride,
@ -863,39 +870,55 @@ static uint8_t* encode(const uint8_t* rgb,
return image_size ? output : NULL;
}
static uint8_t* encode_lossless(const uint8_t* rgb,
int width, int height, int stride,
WebPEncodeLosslessFunction encfn,
int* output_size, int* unused) {
uint8_t *output = NULL;
const size_t image_size = encfn(rgb, width, height, stride, &output);
// the values of following two will be interpreted by returned_buffer_size()
// as 'width' and 'height' in the size calculation.
*output_size = image_size;
*unused = 1;
return image_size ? output : NULL;
}
// Changes the return type of WebPEncode* to more closely match Decode*.
// This also makes it easier to wrap the output buffer in a native type rather
// than dealing with the return pointer.
// The additional parameters are to allow reuse of returned_buffer_size(),
// unused2 and output_size will be used in this case.
static uint8_t* wrap_WebPEncodeRGB(
const uint8_t* rgb, int* unused1, int* unused2, int* output_size,
int width, int height, int stride, float quality_factor) {
return encode(rgb, width, height, stride, quality_factor,
WebPEncodeRGB, output_size, unused2);
}
#define LOSSY_WRAPPER(FUNC) \
static uint8_t* wrap_##FUNC( \
const uint8_t* rgb, int* unused1, int* unused2, int* output_size, \
int width, int height, int stride, float quality_factor) { \
return encode(rgb, width, height, stride, quality_factor, \
FUNC, output_size, unused2); \
} \
static uint8_t* wrap_WebPEncodeBGR(
const uint8_t* bgr, int* unused1, int* unused2, int* output_size,
int width, int height, int stride, float quality_factor) {
return encode(bgr, width, height, stride, quality_factor,
WebPEncodeBGR, output_size, unused2);
}
LOSSY_WRAPPER(WebPEncodeRGB)
LOSSY_WRAPPER(WebPEncodeBGR)
LOSSY_WRAPPER(WebPEncodeRGBA)
LOSSY_WRAPPER(WebPEncodeBGRA)
static uint8_t* wrap_WebPEncodeRGBA(
const uint8_t* rgba, int* unused1, int* unused2, int* output_size,
int width, int height, int stride, float quality_factor) {
return encode(rgba, width, height, stride, quality_factor,
WebPEncodeRGBA, output_size, unused2);
}
#undef LOSSY_WRAPPER
#define LOSSLESS_WRAPPER(FUNC) \
static uint8_t* wrap_##FUNC( \
const uint8_t* rgb, int* unused1, int* unused2, int* output_size, \
int width, int height, int stride) { \
return encode_lossless(rgb, width, height, stride, \
FUNC, output_size, unused2); \
} \
LOSSLESS_WRAPPER(WebPEncodeLosslessRGB)
LOSSLESS_WRAPPER(WebPEncodeLosslessBGR)
LOSSLESS_WRAPPER(WebPEncodeLosslessRGBA)
LOSSLESS_WRAPPER(WebPEncodeLosslessBGRA)
#undef LOSSLESS_WRAPPER
static uint8_t* wrap_WebPEncodeBGRA(
const uint8_t* bgra, int* unused1, int* unused2, int* output_size,
int width, int height, int stride, float quality_factor) {
return encode(bgra, width, height, stride, quality_factor,
WebPEncodeBGRA, output_size, unused2);
}
/* Work around broken gcj jni.h */
@ -1470,6 +1493,198 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeBG
}
SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessRGB(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jint jarg3, jintArray jarg4, jint jarg5, jint jarg6, jint jarg7) {
jbyteArray jresult = 0 ;
uint8_t *arg1 = (uint8_t *) 0 ;
int *arg2 = (int *) 0 ;
int *arg3 = (int *) 0 ;
int *arg4 = (int *) 0 ;
int arg5 ;
int arg6 ;
int arg7 ;
jbyte *jarr1 ;
int temp4 ;
uint8_t *result = 0 ;
(void)jenv;
(void)jcls;
if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0;
arg2 = (int *)&jarg2;
arg3 = (int *)&jarg3;
{
if (!jarg4) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
return 0;
}
if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) {
SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
return 0;
}
arg4 = &temp4;
}
arg5 = (int)jarg5;
arg6 = (int)jarg6;
arg7 = (int)jarg7;
result = (uint8_t *)wrap_WebPEncodeLosslessRGB((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7);
jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically);
SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1);
{
jint jvalue = (jint)temp4;
(*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue);
}
free(arg1);
free(result);
return jresult;
}
SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessBGR(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jint jarg3, jintArray jarg4, jint jarg5, jint jarg6, jint jarg7) {
jbyteArray jresult = 0 ;
uint8_t *arg1 = (uint8_t *) 0 ;
int *arg2 = (int *) 0 ;
int *arg3 = (int *) 0 ;
int *arg4 = (int *) 0 ;
int arg5 ;
int arg6 ;
int arg7 ;
jbyte *jarr1 ;
int temp4 ;
uint8_t *result = 0 ;
(void)jenv;
(void)jcls;
if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0;
arg2 = (int *)&jarg2;
arg3 = (int *)&jarg3;
{
if (!jarg4) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
return 0;
}
if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) {
SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
return 0;
}
arg4 = &temp4;
}
arg5 = (int)jarg5;
arg6 = (int)jarg6;
arg7 = (int)jarg7;
result = (uint8_t *)wrap_WebPEncodeLosslessBGR((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7);
jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically);
SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1);
{
jint jvalue = (jint)temp4;
(*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue);
}
free(arg1);
free(result);
return jresult;
}
SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessRGBA(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jint jarg3, jintArray jarg4, jint jarg5, jint jarg6, jint jarg7) {
jbyteArray jresult = 0 ;
uint8_t *arg1 = (uint8_t *) 0 ;
int *arg2 = (int *) 0 ;
int *arg3 = (int *) 0 ;
int *arg4 = (int *) 0 ;
int arg5 ;
int arg6 ;
int arg7 ;
jbyte *jarr1 ;
int temp4 ;
uint8_t *result = 0 ;
(void)jenv;
(void)jcls;
if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0;
arg2 = (int *)&jarg2;
arg3 = (int *)&jarg3;
{
if (!jarg4) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
return 0;
}
if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) {
SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
return 0;
}
arg4 = &temp4;
}
arg5 = (int)jarg5;
arg6 = (int)jarg6;
arg7 = (int)jarg7;
result = (uint8_t *)wrap_WebPEncodeLosslessRGBA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7);
jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically);
SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1);
{
jint jvalue = (jint)temp4;
(*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue);
}
free(arg1);
free(result);
return jresult;
}
SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessBGRA(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jint jarg3, jintArray jarg4, jint jarg5, jint jarg6, jint jarg7) {
jbyteArray jresult = 0 ;
uint8_t *arg1 = (uint8_t *) 0 ;
int *arg2 = (int *) 0 ;
int *arg3 = (int *) 0 ;
int *arg4 = (int *) 0 ;
int arg5 ;
int arg6 ;
int arg7 ;
jbyte *jarr1 ;
int temp4 ;
uint8_t *result = 0 ;
(void)jenv;
(void)jcls;
if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0;
arg2 = (int *)&jarg2;
arg3 = (int *)&jarg3;
{
if (!jarg4) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
return 0;
}
if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) {
SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
return 0;
}
arg4 = &temp4;
}
arg5 = (int)jarg5;
arg6 = (int)jarg6;
arg7 = (int)jarg7;
result = (uint8_t *)wrap_WebPEncodeLosslessBGRA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7);
jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically);
SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1);
{
jint jvalue = (jint)temp4;
(*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue);
}
free(arg1);
free(result);
return jresult;
}
#ifdef __cplusplus
}
#endif