Commit Graph

688 Commits

Author SHA1 Message Date
James Zern
2924a5aee6 Makefile.vc: split object lists based on directory
Change-Id: I4e189193817f26117e6459da078e2a72c9f3ef5f
2012-05-11 18:29:33 -07:00
Pascal Massimino
c8f24165b7 Merge "add assert(tokens)" 2012-05-11 01:46:45 -07:00
Pascal Massimino
432399472f add assert(tokens)
Change-Id: I952a5cd15ff0a80cff349293e6403357cbc7bd8d
2012-05-11 01:45:06 -07:00
Urvang Joshi
9f547450e0 Catch an error in DecodeImageData().
When we are at end-of-stream, but haven't decoded all pixels, we should
return an error.
Also remove an obsolete TODO.

Change-Id: I3fb1646136e706da536d537a54d1fa487a890630
2012-05-11 14:10:01 +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
Urvang Joshi
c579a71012 Introduce CHUNK_SIZE_BYTES in muxi.h.
Plus a style fix.

Change-Id: Id94df6c91a96598cb022c813e0981f542aebe982
2012-05-10 13:16:18 +05:30
Urvang Joshi
14757f8ae2 Make sure huffman trees always have valid symbols
- Symbols added to the tree are valid inside HuffmanTreeBuildExplicit().
- In HuffmanTreeBuildImplicit(), make sure 'root_symbol' is
valid in case of a single symbol tree.

Change-Id: I7de5de71ff28f41e2d6228b29ed8dd4a20813e99
2012-05-10 11:40:18 +05:30
James Zern
4105061840 makefile.unix: add support for building vwebp
standalone from the normal examples due to the additional OpenGL
dependencies.
$ make -f makefile.unix examples/vwebp

Change-Id: I7e3f0b5e0328230cb32acdd1e2a011cbbb80e55d
2012-05-09 15:47:00 -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
pascal massimino
22671ed6a3 Merge "enc/vp8l: fix double free on error" 2012-05-09 13:36:38 -07:00
pascal massimino
e1b9b05258 Merge "cosmetics: VP8LCreateHuffmanTree: fix indent" 2012-05-09 13:23:24 -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
James Zern
27541fbdc0 cosmetics: VP8LCreateHuffmanTree: fix indent
Change-Id: I025fada400366f8937208e1f9b8df483cd53a942
2012-05-09 12:11:22 -07:00
James Zern
1d38b258b8 cwebp/windows: use MAKE_REFGUID where appropriate
Change-Id: If595c75a833d37df86c16bf926da5f032015c68e
2012-05-09 11:52:01 -07:00
James Zern
817ef6e9af Merge "cwebp: fix WIC/Microsoft SDK compatibility issue" 2012-05-09 11:50:05 -07:00
James Zern
902d3e3b5f cwebp: fix WIC/Microsoft SDK compatibility issue
Fixes issue #115.
Define local copies of GUID_WICPixelFormat24bppRGB &
GUID_WICPixelFormat32bppRGBA (and GUID_WICPixelFormat32bppBGRA for
symmetry) to avoid link issues when building against older versions of
the SDK.

Change-Id: I2a26be1b7fe6d970feb3211cf0059e5898e3028d
2012-05-09 11:47:15 -07:00
pascal massimino
89d803c423 Merge "Fix a crash due to wrong pointer-integer arithmetic." 2012-05-09 02:22:01 -07:00
pascal massimino
cb1bd741f9 Merge "Fix a crash in lossless decoder." 2012-05-09 02:21:13 -07:00
pascal massimino
de2fe20290 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." 2012-05-09 02:15:42 -07:00
Urvang Joshi
ce69177a41 Fix a crash due to wrong pointer-integer arithmetic.
[Basically, the condition "src - dist < data" can be wrongly evaluated
to be false if "src < dist" due to underflow. Instead, "src - data <
dist" is the correct condition, as "src > data" is always true and so
there would never be an underflow].

Change-Id: Ic9f64bfe76a9acae97abc1fb7c1f4868e81f1eb8
2012-05-09 14:40:06 +05:30
Urvang Joshi
e40a3684f5 Fix a crash in lossless decoder.
This was due to incorrect update of 'ok'.

Change-Id: I91edfb5682527e8bc7eaa10e635c0261edb016b6
2012-05-09 14:35:11 +05:30
Pascal Massimino
3927ff3abc remove unneeded error condition for WebPMuxNumNamedElements()
+ fix error message

Change-Id: If283ff6609ee0c5dff81a9c1c3f194faa729161c
2012-05-09 01:57:15 -07:00
Urvang Joshi
2c140e113c 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.

Change-Id: I5cb3cc942afac6e9f51a0b97c57ee897677a48a2
2012-05-09 14:26:01 +05:30
Pascal Massimino
861a5b7bc9 add support for animation
it's using glutTimerFunc() for trigger next frame's decoding

Reminder: how to build and use manually (integration in makefile.unix coming soon)

Unix:
cd libwebp
make -f makefile.unix
cd examples
cc -o vwebp vwebp.c -framework GLUT -framework OpenGL -I../src/ ../src/libwebp.a ../src/mux/libwebpmux.a

Mac + xcode:
cd libwebp
make -f makefile.unix
cd examples
cc -o vwebp vwebp.c -lglut -lGL -lpthread -lm -I../src/ ../src/libwebp.a ../src/mux/libwebpmux.a

Change-Id: Id49e87c26628c2b58ec221f6030cbd2e46a807b4
2012-05-09 01:23:39 -07:00
pascal massimino
eb5c16cc18 Merge "Set correct encode size in encoder's stats." 2012-05-09 00:37:25 -07:00
Pascal Massimino
4abe04a204 fix the return value and handle missing input file case.
Change-Id: I42a64fcf7587ff3a487115808e2cfa51cec0031d
2012-05-09 00:34:30 -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
Vikas Arora
c4ccab6463 Print relevant lossless encoding stats in cwebp.
Change-Id: Ib8dfab498b1a05e49734bba2d3e72810343e8b0a
2012-05-09 11:31:41 +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
7885f8b25d makefile.unix: add lossless encoder files
comment out 'EXTRA_FLAGS += -DUSE_LOSSLESS_ENCODER' to disable

Change-Id: I75ead699c95644e319e7cbbf2a167d98e826fb7c
2012-05-08 11:25:28 -07:00
James Zern
1261a4c888 Merge "cosmetics" 2012-05-07 17:54:43 -07:00
James Zern
3926b5be3b Merge "dsp/cpu.c: Android: fix crash on non-neon arm builds" 2012-05-07 17:53:03 -07:00
James Zern
834f937f3c dsp/cpu.c: Android: fix crash on non-neon arm builds
add proper cpu-detection for Android targets

Fixes issue #118 (and is a better solution for #117).

based on patch by pepijn vaneeckhoudt

Change-Id: I6b00ea6d51ca658ccf6a3d55b87b99c01c6805be
2012-05-07 17:52:15 -07:00
James Zern
126e160672 cosmetics
vp8.[hc]:fix '*' placement in pointer types
vp8l.c: remove trailing ',' from enum
decode.h: fix stray WebPINew()

Change-Id: Id6749a14a12ed0a090649f28ef4267fda45a37a8
2012-05-07 17:47:51 -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
ada6ff77df Approximate FastLog between value range [256, 8192]
Profiled data: Profiled few images and found that in the function VP8LFastLog,
90% of time table lookup is performed, while rest of time (10%) call to log
function is made. Typical lookup accounts for 10 CPU instructions and call to
log 200 instruction counts. The weighted average comes out to be 30
instructions per call. For mid qualities (25-75), this function (VP8LFastLog)
accounts for 30-50% of total CPU cycles (via call path: VP8LCOlorSpaceTransform
-> PredictionCostCrossColor -> ShannonEntropy). After this change, the log is
called less that 1% of time, with average instructions being 15 per call.
Measured the performance over 1000 files for various qualities and found
overall compression speedup between 10-15% (in quality range [0, 75]). The
compression density loss is around 0.5% (though at some qualities, compression
is little better as well).

Change-Id: I247bc6a8d4351819c871f19d65455dc23aea8650
2012-05-07 14:25:26 -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