Commit Graph

278 Commits

Author SHA1 Message Date
Vikas Arora
dd1c3873fe Add image-hint for low-color images.
For low-color images, it may be better to not use color-palettes.
Users should treat this as one another hint (as with Photo &
Picture) and another parameter for tuning the compression density.
The optimum compression can still be obtained by running (outer loop)
compression with all possible tunable parameters.

Change-Id: Icb1a4face2a84774e16e801aee4a8ae97e232e8a
2012-07-31 23:11:19 -07:00
James Zern
183cba83a7 check VP8LBitWriterInit return
Change-Id: I460906281598f5792bd75a25b14b449c8daaff8c
2012-07-31 12:11:40 -07:00
James Zern
cbfa9eecf4 lossless: fix crash on user abort
avoid free on uninitialized bit writer buffer

Change-Id: I1a41b2cea421bf5a2ea0af33c6e84018cb997caf
2012-07-31 11:59:54 -07:00
James Zern
475d87d767 WebPEncode: clear stats at the start of encode
also relocate user_data from WebPAuxStats to the WebPPicture struct to
make clearing easier while placing it closer to the progress hook with
which it's used.
prior to this change some spurious lossless data could be reported in
the lossy (sans alpha) encoding case. additionally user_data could be
lost during lossless encoding.

Change-Id: I929fae3dfde4d445ff81bbaad51445ea586dd80b
2012-07-27 19:57:18 -07:00
Pascal Massimino
a7cc729126 fix type and conversion warnings
avoids warning messages on MSVC mainly

Change-Id: I80f281d5263a54c6a224bb095175497cf2f4ce1e
2012-07-25 14:18:21 -07:00
Pascal Massimino
7d853d79dc add stats for lossless
* Extend AuxStats with new fields
  it's slightly ABI-incompatible, but i guess it's ok for 0.1.99+
  I expect to add more stats later, possibly (predictor stats, etc.)
* Have cwebp report the features used by lossless
  compression (either for alpha or full lossless coding)
* Print the PSNR for alpha (useful in case of -alpha_q)
* clean-up alpha.c signatures
+ misc cleanup (added const '* const ptr', etc.)

Change-Id: I157a21581f1793cb0c6cc0882e7b0a2dde68a970
2012-07-24 16:17:13 -07:00
Urvang Joshi
159b75d31a cwebp output size consistency:
In case of lossless too, it should report full file size.
Fixes this issue: http://code.google.com/p/webp/issues/detail?id=126

Change-Id: I96e2bf09e6c9470a0267f5eea911d9b40d1addb3
2012-07-23 12:47:24 +05:30
James Zern
3e5bbe1c2e Merge "rename 'use_argb_input' to 'use_argb'" into 0.2.0 2012-07-18 23:26:42 -07:00
Pascal Massimino
0275159143 add a very crude progress report for lossless
better than nothing. Removed the warning in cwebp.c
(and silenced the warning in quiet mode too)

Change-Id: I85bbeaf77e0f60ead798886043dc053e6b44def5
2012-07-18 22:54:50 -07:00
Pascal Massimino
dd1081763c rename 'use_argb_input' to 'use_argb'
long name, and there's not really an 'output' equivalent

Change-Id: I9133ff734ae8d6572cb2f607211361f011fc0bc1
2012-07-18 22:47:16 -07:00
James Zern
ce156afccf add missing ABI compatibility checks
original change:
f7f16a2 add ABI compatibility check

Change-Id: I7cd6508f8d8e0d957a3d62ad52a117876fa5ec29
2012-07-18 22:24:33 -07:00
James Zern
31426ebaec encode.h: remove '* const' from function parameters
makes the public interface consistent and more readable

Change-Id: Ib93614e901e0af44bb64782357cfd9e724e050be
2012-07-17 16:26:54 -07:00
James Zern
9ff00cae72 bump encoder/decoder versions
those returned by WebPGet(Encoder|Decoder)Version()

Change-Id: I7584d04060ae7ca552f8f3aaf9df294d310a5be6
2012-07-17 13:43:39 -07:00
Pascal Massimino
c2416c9b61 add lossless quick encoding functions to the public API
New functions:
   WebPEncodeLosslessRGB()
   WebPEncodeLosslessBGR()
   WebPEncodeLosslessRGBA()
   WebPEncodeLosslessBGRA()

Change-Id: Id56da7569eee80c57de8f1f053fb87b217d33a4b
2012-07-17 12:02:53 -07:00
James Zern
8d3b04a25d Merge "header clean-up" into 0.2.0 2012-07-16 19:21:49 -07:00
James Zern
d708ec1452 Merge "move MIN/MAX_HISTO_BITS to format_constants.h" into 0.2.0 2012-07-16 19:19:32 -07:00
Pascal Massimino
23d34f3142 header clean-up
remove unused VP8LHistogramRemove function
make HistogramEstimateBitsHeader static

Change-Id: I0dc6a6f4c41d3c5f55a8153cd7d710c9f84582a7
2012-07-16 19:13:01 -07:00
Pascal Massimino
2a3ab6f925 move MIN/MAX_HISTO_BITS to format_constants.h
(under the name MAX_HUFFMAN_BITS, since the specs read:
	int huffman_bits = ReadBits(3) + 2;
)

Change-Id: Ifc66576bbd8e48518d3d78a3f515f851cf1883dc
2012-07-16 19:11:54 -07:00
Pascal Massimino
cdf885c67c shuffle variables in HashChainFindCopy
might lead to observable speed-up on some compiler/arch

Change-Id: I6c89ec9cd4f490e7e22b790785f80097a47d27b5
2012-07-16 19:08:59 -07:00
Vikas Arora
cca7c7b81b Fixed nit: 10 -> 10.f
Change-Id: I0cdb096525460b27f3adcb9f802f6dc193d5f590
2012-07-02 11:29:01 +05:30
Vikas Arora
f864be3b2c Lower the quality settings for Alpha encoding.
Evaluated the impact of this change over 1000 image corpus.
The compression density is up (on average) by 1.2% and encoding time has
gone down considerably from 716 ms (per file) to 146 ms (per file)
(4.9X improvement in encoding time).

Change-Id: Ida562cc0bfe18c9d6f5f00873c95f8396b480eab
2012-06-29 16:19:42 +05:30
Pascal Massimino
fcc69923b9 add automatic YUVA/ARGB conversion during WebPEncode()
Adds new methods WebPPictureARGBToYUVA() and WebPPictureYUVAToARGB()
Depending on the value of picture->use_argb_input,
the main call WebPEncode() will convert appropriately.
Note that both conversions are lossy, so it's recommended to:
* use YUVA input for lossy compression (picture->use_argb_input=0)
* use ARGB input for lossless compression (picture->use_argb_input=1)

Change-Id: I8269d607723ee8a1136b9f4999f7ff4e657bbb04
2012-06-28 00:34:23 -07:00
Pascal Massimino
e012dfd90f make width/height coding match the spec
* width/height in VP8X chunk is 24bit now
* Added some more constants #defines

Change-Id: I2f8ca7f965a247bccd341dd079ed2abf549c39d7
2012-06-28 00:20:28 -07:00
pascal massimino
2c341b0eed Merge "Added image characteristic hint for the codec." 2012-06-22 02:54:51 -07:00
Vikas Arora
d373076a53 Added image characteristic hint for the codec.
This image type hint is used by codec to apply appropriate set of
transform filters to the image.

Change-Id: Ibb24e47ba14c40fa7f9f2c50ae86e03f2b29e9a6
2012-06-22 14:03:46 +05:30
pascal massimino
2ed2adb5ba Merge "msvc: add intrinsic based BitsLog2Floor" 2012-06-22 00:13:47 -07:00
Pascal Massimino
31b68fe639 cleanup WebPPicture struct and API
* add a real proper pointer for holding memory chunk pointer
  (instead of using y and argb fields)
* polish the doc with details
* add a WebPPictureView() that extract a view from a picture
  without any copy (kind of a fast-crop).
* properly snap the top-left corner for Crop/View. Previously,
  the luma position was not snapped, and was off compared to the chroma.

Change-Id: I8a3620c7f5fc6f7d1f8dd89d9da167c91e237439
2012-06-21 00:30:43 -07:00
Pascal Massimino
81720c9139 consistency cosmetics
Change-Id: Ie8e372ddcdd6e48527478f70bf716953ed18292a
2012-06-20 23:56:11 -07:00
James Zern
7144308402 enc/vp8l.c: fix build
broken since:
233a589 take picture->argb_stride into account for lossless coding

Change-Id: I9ecbbf65f3048be3077d28c3a20dfc0e1afa10be
2012-06-20 14:44:39 -07:00
Pascal Massimino
233a589ea9 take picture->argb_stride into account for lossless coding
analysis phase was assuming flat layout...

Change-Id: I96681f6d76aa3faabc51dd2ee3dffbe77ff90d36
2012-06-20 10:13:04 -07:00
James Zern
5b08318b57 cosmetics: remove unimplemented function proto
Change-Id: I580fcc756d161cebbabf753ee68c09d189628d7f
2012-06-19 22:27:56 -07:00
James Zern
e1f769fe1c msvc: add intrinsic based BitsLog2Floor
Change-Id: Ic0c7d2f03e300c6699e130916a759403e672f9d8
2012-06-19 16:14:54 -07:00
James Zern
b5b6ac979f Merge "Bring the special writer 'WebPMemoryWriter' to public API" 2012-06-18 16:22:17 -07:00
pascal massimino
a6a1909fff Merge "Fix floating point exception with cwebp -progress" 2012-06-18 16:11:53 -07:00
James Zern
f2cee06708 Fix floating point exception with cwebp -progress
Adds a test of enc->mb_h_ to VP8IteratorProgress() to avoid a division
by zero. Fixes issue #121.

Original patch from even rouault (even dot rouault at gmail dot com).

Change-Id: Ie5fcc1821860c0a9366d5aa11f3aded4f5b98ed7
2012-06-18 15:43:28 -07:00
Pascal Massimino
91b7a8c754 Bring the special writer 'WebPMemoryWriter' to public API
=> WebPMemoryWriter, WebPMemoryWriterInit(), WebPMemoryWrite()

Change-Id: I142fb22b0290ece7a6f6d74f00964a2e9e58ec9b
2012-06-18 15:42:56 -07:00
Pascal Massimino
310e297205 support resize and crop for RGBA input
Change-Id: I19eac3fb4f8ecb973ff5872ac3a921f8947054bf
2012-06-18 15:20:46 -07:00
pascal massimino
4b79fa5923 Merge "Limit the maximum size of huffman Image to 16MB." 2012-06-17 00:20:26 -07:00
James Zern
18cae37b91 msvc: silence some build warnings
these are related to the removal of USE_LOSSLESS_ENCODER

Change-Id: Ib0ca5bc2766c351130507bc2e657a034c8455b34
2012-06-13 13:51:50 -07:00
Vikas Arora
b3923084b9 Limit the maximum size of huffman Image to 16MB.
This limit corresponds to default histo_bits=3 for images upto sizes 400x400.
Any image higher than this dimension will bump up the histo_bits to 4 internally.

Change-Id: Ic8ba3dcd50e9c588cbbc4a0457289086498ff4ee
2012-06-13 13:27:43 +05:30
Pascal Massimino
78f3e34504 Enable lossless encoder code
Remove USE_LOSSLESS_ENCODER compile flag
Update Makefile.am and makefile.unix

Change-Id: If7080c4d8f37994c7c784730c5e547bb0a851455
2012-06-13 00:26:58 -07:00
Vikas Arora
7c6898051e Fix asserts in Palette and BackwardReference code.
Fix inequality assertion on number of palette colors.
Fix inequality assertion test in BackwardReferencesHashChainFollowChosenPath.

Change-Id: Ie3242f1bbeaf96db91b839b6732ccce2634cebf3
2012-06-11 12:27:59 +05:30
Pascal Massimino
3697b5ceb2 write an ad-hoc EncodeImageInternal variant
Used when we don't code a Huffman Image.
-> Simplify the code quite some because we don't have to
deal with special cases of histo bits

Change-Id: I0c3f46cbf3b501e021c093e07253e7404c01ff4f
2012-06-08 11:52:31 -07:00
Vikas Arora
0424b1ef3b Rebase default encoding settings.
Updated histo_bits to 3 from 4 and changed the quality threshold for inner loop for HashChainFindCopy.
Impact: 0.5%-0.8% better bpp with 15%-20% hit on encoding throughput
at default encoding settings.

Change-Id: I316ef88403148b1e19036fa0817d944eb0301255
2012-06-08 09:18:15 +05:30
Vikas Arora
70eb2bd687 Stop indefinite recursion for Huffman Image.
Ensure that the lossless bit-stream doesn't allow for such cases and
safe-gaurd decoder against indefinite recursion.

Change-Id: Ia6d7f519291de8739f79a977a5800982872aae71
2012-06-07 17:27:19 +05:30
pascal massimino
c67bc979dd Merge "add WebPPictureImportRGBX() and WebPPictureImportBGRX()" 2012-06-05 00:28:04 -07:00
Noel Chromium
27519bc2b6 add WebPPictureImportRGBX() and WebPPictureImportBGRX()
When importing BGRA or RGBA data for encoding, provide variants of
the WEBPImportPicture API for RGBX and BRGX data meaning the alpha
channel should be ignored.

Author: noel@chromium.org
from Chromium patch: https://chromiumcodereview.appspot.com/10496016/

Change-Id: I15fcaa4160c69a2b5549394204b6e6d7a1c5d333
2012-06-05 00:26:17 -07:00
Pascal Massimino
f80cd27e28 factorize code in Import()
Change-Id: I6a4e77715c3a5be5238c81e029bfb6479d36de05
2012-06-04 23:27:01 -07:00
James Zern
9b71502669 histogram: add log2 wrapper
Change-Id: I5e68efaf5f763a42ace1af83f4b7887e0ddfd099
2012-06-04 23:14:41 -07:00
James Zern
42f6df9da3 fix some implicit type conversion warnings
Change-Id: I0653d10410c0d46f91fedad4c4dffa9c1de402cb
2012-06-04 22:33:32 -07:00
James Zern
8fbb91884e prefer webp/types.h over stdint.h
stdint.h is part of C99 and is notably lacking under MSVC

Change-Id: Iff60dcb8bdcc7f948dc35fb0b5d47478520b570f
2012-06-04 18:34:24 -07:00
Pascal Massimino
437999fb77 introduce a generic WebPPictureHasTransparency() function
VP8-lossy will now avoid writing an ALPH chunk if the
alpha values are trivial.

+ changed DumpPicture() accordingly in cwebp
+ prevented the -d option to be active with lossless
 (DumpPicture wouldn't work).

Change-Id: I34fdb108a2b6207e93fa6cd00b1d2509a8e1dc4b
2012-06-04 16:17:55 -07:00
Vikas Arora
069f903a08 Change in lossless bit-stream.
Change the lossless signature to 0x2f
Add 1 bit indicator for 'droppable (or trivial) alpha)'.
Add 3 bit lossless version (for future extension like yuv support).
Change the sub-resolution information to 3 bits implying range [2 .. 9]

Change-Id: Ic7b8c069240bbcd326cf5d5d4cd2dde8667851e2
2012-06-04 12:47:01 +05:30
James Zern
f18281ffa0 WebPReportProgress: use non-encoder specific params
Take picture and percent value storage location instead of VP8Encoder.
This will allow reuse by the lossless encoder.

Change-Id: Ic49dbc800cc3e2df60d20f4ebac277f68ed6031b
2012-05-31 11:28:48 -07:00
Pascal Massimino
1875d926e7 trap two unchecked error conditions
CostModelBuild() and TrackBackwards() returns weren't checked

+ code clean-up
+ de-inline VP8LBackwardRefs non-critical methods
+ shuffle the .h around to group things together
+ extract some constants as #define's
+ fixed the "if (!(cc_init = ...)) {...}" constructs
+ removed some unneeded VP8L prefixes

Change-Id: Ic634cb87bc6b2033242d3e8e8731fab4c134f327
2012-05-25 02:52:44 -07:00
Pascal Massimino
87b4a908a5 no need to have mux.h as noinst clause in enc/
Change-Id: I93c65838f33d01170fc63340650edeeee753786f
2012-05-24 15:05:19 -07:00
Urvang Joshi
e75dc80516 Move some more defines to format_constants.h
Also remove some duplicate const/defines.

Change-Id: I0ec48866b874f546022d72e938fb65669b0b3211
2012-05-24 17:46:01 +05:30
Urvang Joshi
c13f663261 Move consts to internal header format_constants.h
Change-Id: Ic6180c16d0b4245680738992925e4608c593fbe8
2012-05-24 15:02:02 +05:30
Pascal Massimino
18da1f53fc modulate alpha-compression effort according to config.method
we vary linearly lossless-method between 0 and 6,
and lossless-quality between 50 and 100, so that encoding
speed can go from 'quite fast' to 'rather slow'.
Impact on size is moderate, but visible.

Change-Id: I0b7917e7170eb50258afb1a4e248028cd9e9207d
2012-05-24 01:54:12 -07:00
Pascal Massimino
39bf5d6497 use header-less lossless bitstream for alpha channel
This saves ~26 bytes of headers.
* introduce new VP8LDecodeAlphaImageStream() for decoding
* use VP8LEncodeStream() for encoding
* refactor code a bit

still TODO: make the alpha-quality/enc-method user-configurable

Change-Id: I23e599bebe335cfb5868e746e076c3358ef12e71
2012-05-23 08:01:44 -07:00
Pascal Massimino
489ec335a1 add VP8LEncodeStream() to compress lossless image stream
* RIFF header is omitted
* rename NewVP8LEncoder and DeleteVP8Encoder
* change the signature to take a "const WebPPicture*"
  (it was non-const just because we were setting some error potentially)
* made the pic_ field const in VP8LEncoder too.
* trap the bitwriter::error_ too
* simplify some signatures to take WebPPicture* instead
  of unneeded VP8LEncoder*

VP8LEncodeStream() will be called directly to compress alpha channel
header-less.

Change-Id: Ibceef63d2b3fbc412f0dffc38dc05c2dee6b6bbf
2012-05-22 03:15:58 -07:00
Pascal Massimino
fa8bc3dbca make WebPEncodingSetError() take a const picture
This is a border-case situation: the picture is not const, because
we're change its error status. But taking it non-const forces
the caller to carry a non-const picture all around the code just
in case (0.00001% of the time?) something bad happen.
This pretty much the same as making all objects non-const because
we'll eventually call delete or free() on them, which is quite a
non-const operation. Well... Better allow constness enforcement for
the remaining 99.9999% of the code.

Change-Id: I9b93892a189a50feaec1a3a518ebf488eb6ff22f
2012-05-22 02:51:38 -07:00
Pascal Massimino
638528cd1e bitstream update for lossy alpha compression
now, we only use 2 bits for the filtering method, and 2 bits
for the compression method.
There's two additional bits which are INFORMATIVE, to specify
whether the source has been pre-processed (level reduction)
during compression. This can be used at decompression time
for some post-processing (see DequantizeLevels()).

New relevant spec excerpt:

     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('ALPH')                      |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |Rsv| P | F | C |     Alpha Bitstream...                        |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Compression method (C): 2 bits

: The compression method used:

  * `0`: No compression.
  * `1`: Backward reference counts encoded with arithmetic encoder.

Filtering method (F): 2 bits

: The filtering method used:

  * `0`: None.
  * `1`: Horizontal filter.
  * `2`: Vertical filter.
  * `3`: Gradient filter.

Pre-processing (P): 2 bits

: These INFORMATIVE bits are used to signal the pre-processing that has
been performed during compression. The decoder can use this information to
e.g. dither the values or smooth the gradients prior to display.

  * `0`: no pre-processing
  * `1`: level reduction

Decoders are not required to use this information in any specified way.

Reserved (Rsv): 2 bits

: SHOULD be `0`.

Alpha bitstream: _Chunk Size_ - `1` bytes

: Encoded alpha bitstream.

This optional chunk contains encoded alpha data for a single tile.
Either **ALL or NONE** of the tiles must contain this chunk.

The alpha channel data is losslessly stored as raw data (when
compression method is '0') or compressed using the lossless format
(when the compression method is '1').

Change-Id: Ied8f5fb922707a953e6a2b601c69c73e552dda6b
2012-05-22 02:36:22 -07:00
Pascal Massimino
ec122e0986 remove arch-dependent rand()
let's use our own simple pseudo-random number generator

Change-Id: I7b4a190cdf4d338b1fae5ef3622ebd82c6e19274
2012-05-22 00:17:04 -07:00
Pascal Massimino
d40e7653db fix alignment
Change-Id: Ieb36de1bcf8c624024f8a3d5a238a2b508d4bb51
2012-05-21 14:31:16 -07:00
Pascal Massimino
3e863dda61 remove tcoder, switch alpha-plane compression to lossless
* Method #1 is now calling the lossless encoder on the alpha plane.
Format is not final, it's just a first draft. We need ad-hoc functions.
* removed now useless utils/alpha.*
* added utils/quant_levels.h instead
* removed the TCoder code altogether

Change-Id: I636840b6129a43171b74860e0a0fc5bb1bcffc6a
2012-05-21 06:24:48 -07:00
Vikas Arora
831bd13168 Make tile size a function of encoding method.
Higher method implies more encoding effort (CPU) achieved with
smaller tile sizes (lower histo_bits).

Change-Id: Ic39c8d882c87835f74fde41172afb002ac3fd1c3
2012-05-18 12:16:39 +05:30
James Zern
778c52284b Merge "remove some variable shadowing" 2012-05-17 14:03:10 -07:00
Vikas Arora
817c9dce61 Few more HuffmanTreeToken conversions.
Change-Id: I932b5368d279f83c462c7d916978dab3e81d7709
2012-05-16 12:15:52 +05:30
James Zern
37a77a6bf4 remove some variable shadowing
Change-Id: I4348253ec6b50639095b22c4745dc26da0904466
2012-05-15 14:04:24 -07:00
Pascal Massimino
c6882c49e3 merge all tree processing into a single VP8LProcessTree()
-> 0.1% size improvement because we're calling OptimizeForRLE()
systematically now.

Change-Id: I03bd712175728e0d46323f375134cae5a241db4b
2012-05-14 05:49:02 -07:00
Pascal Massimino
9c7a3cf5e7 fix VP8LHistogramNumCodes to handle the case palette_code_bits == 0
-> lot of simplifications ensue and we should be able to get rid of
 ClearHuffmanTreeIfOnlyOneSymbol() too, in a subsequent patch.

Change-Id: Ic4c51d05e4b1970e37f94ffd85fae6a02e4a6422
2012-05-14 01:23:58 -07:00
pascal massimino
b5551d2e1d Merge "Added HuffmanTreeCode Struct for tree codes." 2012-05-14 01:23:08 -07:00
Vikas Arora
8b85d01c45 Added HuffmanTreeCode Struct for tree codes.
To represent tree codes (depth and bits array).

Change-Id: I87650886384dd10d95b16ab808dfd3bb573172bc
2012-05-14 13:50:35 +05:30
pascal massimino
093f76d831 Merge "Allocate single memory in GetHuffBitLengthsAndCodes." 2012-05-14 01:15:46 -07:00
Vikas Arora
41d8049451 Allocate single memory in GetHuffBitLengthsAndCodes.
Allocate big chunk of memory in GetHuffBitLengthsAndCodes, instead of allocating in a loop.
Also fixed the potential memleak.

Change-Id: Idc23ffa306f76100217304444191a8d2fef9c44a
2012-05-14 13:41:59 +05:30
Urvang Joshi
1b04f6d234 Correct size in VP8L header.
The size written in VP8L header should be without padding.
(Also clarified this code using consts).

Change-Id: Ic6583d760c0f52ef61924ab0330c65c668a12fdc
2012-05-14 12:49:16 +05:30
Pascal Massimino
ac8e5e42d1 minor typo and style fix
Change-Id: If4927beb7a8f3c96379eee1fedc687a5046a6951
2012-05-11 01:17:31 -07:00
Pascal Massimino
9f566d1d36 clean-up around Huffman-encode
* refine doc
* use LUT for bit-reversal
* added assert
* Introduce HuffmanTreeToken instead of separate code/extra_bits arrays

Change-Id: I0fe0b50b55eb43a4be9f730b1abe40632a6fa7f0
2012-05-10 09:11:47 -07:00
James Zern
48b37721fc Merge "fixed signed/unsigned comparison warning" 2012-05-09 14:10:32 -07:00
pascal massimino
57f696daef Merge "EncodeImageInternal: fix potential leak" 2012-05-09 13:58:55 -07:00
James Zern
d972cdf2dd EncodeImageInternal: fix potential leak
if histogram_image_size is reduced in when writing the histogram_image
the bit arrays would leak any remaining elements. store their element
count separately.

Change-Id: I710142a11ebd4325faec7bd65c2d2572aae19307
2012-05-09 13:49:10 -07:00
James Zern
5cd12c3df2 fixed signed/unsigned comparison warning
present in an assert in backward_references.h

Change-Id: Id9a528896689e51d784ad64fdc1ca052e97fe7a2
2012-05-09 13:45:26 -07:00
pascal massimino
cdca30d0b5 Merge "cosmetics: shorten long line" 2012-05-09 13:45:12 -07:00
James Zern
e025fb5546 cosmetics: shorten long line
Change-Id: I78bb19cf593730e74734e08d3d6de08a29bd9cbc
2012-05-09 13:42:31 -07:00
James Zern
a8e725f800 enc/vp8l: fix double free on error
GetHuffBitLengthsAndCodes and the caller would both free
bit_lengths/bit_codes

Change-Id: I1b62ff727c82567f11c39a847f74fe765b5f527c
2012-05-09 12:56:07 -07:00
Vikas Arora
2fafb85579 Set correct encode size in encoder's stats.
The current implementation doesn't take care one byte
signature and associated one byte padding (for odd sized chunk).

Change-Id: I35b81d0644818cdba38189aa48c75db5f92e68f4
2012-05-09 12:33:58 +05:30
Vikas Arora
e7167a2b95 Provide one entry point for backward references.
The new method VP8LGetBackwardReferences hides internal
heuristics used for choosing RLE or LZ77 based refs.
- Tuned VP8LHashChainFindCopy for better compression at higher Q.
- Refactored code.
- Removed the unused method VP8LVerifyBackwardReferences.

Change-Id: Ibb7bb072bab5a49a001577a20d88226f52e6c663
2012-05-09 12:13:06 +05:30
James Zern
e3302cfd73 GetHuffBitLengthsAndCodes: reduce level of indirection
arrays can be passed directly as only their members are being modified.
this also reduces the allocation for bit_codes[] by taking the
sizeof(type)=2 rather than sizeof(ptr)=4/8 in one case.

Change-Id: Idad20cead58c218b58d90b71699374fefd01cad9
2012-05-08 11:48:55 -07:00
James Zern
b5f2a9ed49 enc/vp8l: fix uninitialized variable warning
histogram_image_size could be unset if the code branches to the 'Error'
label.

Change-Id: I690b20f86372f19a47d159c2bec8fbf49553f0d5
2012-05-08 11:45:04 -07:00
James Zern
e38602d2ad Merge branch 'lossless_encoder'
* lossless_encoder: (46 commits)
  split StoreHuffmanCode() into smaller functions
  more consolidation: introduce VP8LHistogramSet
  big code clean-up and refactoring and optimization
  Some cosmetics in histogram.c
  Approximate FastLog between value range [256, 8192]
  Forgot to update out_bit_costs to symbol_bit_costs at one instance.
  Evaluate output cluster's bit_costs once in HistogramRefine.
  Simple Huffman code changes.
  Lossless decoder: remove an unneeded param in ReadHuffmanCodeLengths().
  Reducing emerging palette size from 11 to 9 bits.
  Move GetHistImageSymbols to histogram.c
  Improve predict vs no-predict heuristic.
  code-moving and clean-up
  reduce memory usage by allocating only one histo
  Restrict histo_bits to ensure histo_image size is under 32MB
  further simplification for the meta-Huffman coding
  A quick pass of cleanup in backward reference code
  Make transform bits a function of encode method (-m).
  introduce -lossless option, protected by USE_LOSSLESS_ENCODER
  Run TraceBackwards for higher qualities.
  ...

Conflicts:
	src/enc/webpenc.c

Change-Id: I9a5d98cba0889ea91d10699466939cc283da345a
2012-05-07 14:27:17 -07:00
Pascal Massimino
e8d3d6a018 split StoreHuffmanCode() into smaller functions
Change-Id: Iaa715f4997505eebabee1e92e964a5d7ee6f3e7d
2012-05-07 14:25:32 -07:00
Pascal Massimino
d0d88990d8 more consolidation: introduce VP8LHistogramSet
VP8LHistogramSet is container for pointers to histograms that
we can shuffle around. Allocation is one big chunk of memory.
Downside is that we don't de-allocate memory on-the-go during
HistogramRefine().

+ renamed HistogramRefine() into HistogramRemap(), so we don't
confuse with "HistogramCombine"
+ made VP8LHistogramClear() static.

Change-Id: Idf1a748a871c3b942cca5c8050072ccd82c7511d
2012-05-07 14:25:30 -07:00
Pascal Massimino
1a210ef1a9 big code clean-up and refactoring and optimization
* de-inline some function
* make VP8LBackwardRefs be more like a vectorwith max capacity
* add bit_cost_ field to VP8LHistogram
* general code simplifications
* remove some memmov() from HistogramRefine
* simplify HistogramDistance()
...

Change-Id: I16904d9fa2380e1cf4a3fdddf56ed1fcadfa25dc
2012-05-07 14:25:29 -07:00
Urvang Joshi
41b5c8ff71 Some cosmetics in histogram.c
Change-Id: I5d5872a793759fad593dba88c3f593f72b328b0c
2012-05-07 14:25:28 -07:00
Vikas Arora
ec123ca3f6 Forgot to update out_bit_costs to symbol_bit_costs at one instance.
Change-Id: Iaf952c0cb6e3fe35257d2503a16a437c6f2eb3aa
2012-05-07 14:25:25 -07:00
Vikas Arora
cf33ccd160 Evaluate output cluster's bit_costs once in HistogramRefine.
Avoid bit_costs evaluated every time in function HistogramDistance. Also moved
VP8LInitBackwardRefs and VP8LClearBackwardRefs to backward_references.h

Change-Id: Id507f164d0fc64480aebc4a3ea3e6950ed377a60
2012-05-07 14:25:23 -07:00
Vikas Arora
781c01f421 Simple Huffman code changes.
No empty trees are codified with the simple Huffman code. The simple Huffman
code is simplified to be either a 1-bit code or 8-bit code for symbols.

Change-Id: I3e2813027b5a643862729339303d80197c497aff
2012-05-07 14:25:21 -07:00
Vikas Arora
b39e7487a7 Reducing emerging palette size from 11 to 9 bits.
This is required to reduce memory used to construct histo_image.

Change-Id: I491a06e10a3e3f3d8a00ecec286394378283ffea
2012-05-07 14:25:19 -07:00
Vikas Arora
bfc73db4a8 Move GetHistImageSymbols to histogram.c
Planning to revisit memory allocation scheme at several instanaces (next CL).

Change-Id: Id7b9f4854e9577e10b53d5b1d8595b7d862e6e01
2012-05-07 14:25:18 -07:00