Commit Graph

437 Commits

Author SHA1 Message Date
Pascal Massimino
6d0e66c23e prepare experimentation with yuv444 / 422
+ add a simple rescaling function: WebPPictureRescale() for encoding
+ clean-up the memory managment around the alpha plane
+ fix some includes path by using "../webp/xxx.h" instead of "webp/xxx.h"

New flags for 'cwebp':
 -resize <width> <height>
 -444  (no effect)
 -422  (no effect)
 -400

Change-Id: I25a95f901493f939c2dd789e658493b83bd1abfa
2011-05-04 15:41:08 -07:00
Pascal Massimino
79cc49f5eb add a --enable-experimental option to './configure'
This will enable USE_EXPERIMENTAL_FEATURES instead of having a header-level #define

Change-Id: I860b007f64220ddf92d0becd18f7d100c718f8d1
2011-05-04 15:17:54 -07:00
Pascal Massimino
517cec21b9 fix indentation
Change-Id: I868ec38999dc5249e9b93048049dd51422113677
2011-04-28 15:52:06 -07:00
Pascal Massimino
f7d9e261c5 fix merge problems
Change-Id: I6d0763734139d2852896872c80c5e7fa7889945a
2011-04-26 11:02:38 -07:00
Pascal Massimino
2ab4b72f53 EXPERIMENTAL: add support for alpha channel
This is a (minor) bitstream change: if the 'color_space' bit is set to '1'
(which is normally an undefined/invalid behaviour), we add extra data at the
end of partition #0 (so-called 'extensions')

Namely, we add the size of the extension data as 3 bytes (little-endian),
followed by a set of bits telling which extensions we're incorporating.
The data then _preceeds_ this trailing tags.

This is all experimental, and you'll need to have
'#define WEBP_EXPERIMENTAL_FEATURES' in webp/types.h to enable this code
(at your own risk! :))

Still, this hack produces almost-valid WebP file for decoders that don't
check this color_space bit. In particular, previous 'dwebp' (and for instance
Chrome) will recognize this files and decode them, but without the alpha
of course. Other decoder will just see random extra stuff at the end of
partition #0.

To experiment with the alpha-channel, you need to compile on Unix platform
and use PNGs for input/output.

If 'alpha.png' is a source with alpha channel, then you can try (on Unix):

  cwebp alpha.png -o alpha.webp
  dwebp alpha.webp -o test.png

cwebp now has a '-noalpha' flag to ignore any alpha information from the
source, if present.

More hacking and experimenting welcome!

Change-Id: I3c7b1fd8411c9e7a9f77690e898479ad85c52f3e
2011-04-25 23:29:39 -07:00
Pascal Massimino
ca554137d2 fix WebPIDecGetRGB() to accept any RGB(A) mode, not just MODE_RGB
Change-Id: I8780582ecd0868c84e2b1310addebd6c8989e727
2011-04-20 08:42:08 -07:00
Pascal Massimino
276ae82512 Remove files not mean to be in git, and update .gitignore
Makes things lighter at the expense of requiring the user
to be up-to-date for autotools.

patch by Jan Engelhardt (jengelh at medozas dot de)

Change-Id: Icfcab2d899828a213d9fade0dab350dacd0c070a
2011-03-29 09:07:06 -07:00
Pascal Massimino
f8db5d5d1c more C89-fixes
going down to strict -ansi c89 is quite overkill (no 'inline',
and /* */-style comments).
But with these fixes, the code compiles with the stringent flags:
 -Wextra -Wold-style-definition -Wmissing-prototypes
 -Wmissing-declarations and -Wdeclaration-after-statement

Change-Id: I36222f8f505bcba3d9d1309ad98b5ccb04ec17e3
2011-03-25 15:19:37 -07:00
Pascal Massimino
650ffa3bbb add version getters for decoder and encoder
WebPGetDecoderVersion() and WebPGetEncoderVersion()
will not return 0.1.2 encoded as 0x000102

dwebp and cwebp also have a new "-version" flag

Change-Id: I4fb4b5a8fc4e53681a386ff4b74fffb639fa237a
2011-03-24 16:17:10 -07:00
Pascal Massimino
208afb5ea1 add c++ guards
Change-Id: I0d4fa090e88499e2e3f1571b149666bde3304cda
2011-03-23 18:41:18 -07:00
Pascal Massimino
8bf76fe0c8 add incremental decoding
The object WebPIDecoder is available to store the
decoding state. The flow is typically:

   WebPIDecoder* const idec = WebPINew(mode);
   while (has_more_data) {
     // ... (get additional data)
     status = WebPIAppend(idec, new_data, new_data_size);
     if (status != VP8_STATUS_SUSPENDED ||
       break;
     }

     // The above call decodes the current available buffer.
     // Part of the image can now be refreshed by calling to
     // WebPIDecGetRGB()/WebPIDecGetYUV() etc.
   }
   WebPIDelete(idec);

Doing so, one can try and decode new macroblocks everytime fresh
bytes are available.
There's two operating modes: either appending fresh bytes, or
updating the whole buffer with additional data in the end.
The latter requires less memcpy()'s

main patch by Somnath Banerjee (somnath at google.com)

Change-Id: Ie81cbd0b50f175743af06b1f964de838b9a10a4a
2011-03-23 18:33:26 -07:00
Pascal Massimino
b2c3575c8f add a 'last_y' field to WebPDecParams
this allows to keep an exact track of the last displayable pixel row

Change-Id: I590306735a82b9249e7bc9fe64eeb3e5bea3376b
2011-03-23 17:24:31 -07:00
Pascal Massimino
2654c3dadc correctly pass along the exact same status returned from ParsePartitions
Change-Id: I5e4ff98dd548b6dceaf36675faa988efb1f47b77
2011-03-23 17:22:07 -07:00
James Zern
e532b9abb1 Makefile: allow out of tree builds
use top_srcdir rather than top_builddir for AM_CPPFLAGS
add EXTRA_DIST to man Makefile. fixes distcheck target.

Change-Id: I308dc1c98f096de1efe188f63d040ef953598e78
2011-03-15 15:31:25 -07:00
Pascal Massimino
4c0da7aad5 enable sparse dc/ac transforms
non-zero dc-bit was mixed with non-zero ac-bit, preventing
finer optimization during VP8ReconstructBlock.
Depending on sparsity, i see 2-5% gain on average.

Change-Id: I7f34f18d0701c77837de3540b732e5b7d85d7c5d
2011-03-14 12:33:50 -07:00
Pascal Massimino
07dbb8d5af clarify the return logic
Change-Id: I2b5b239496da6545df2deede6d0ca28a2f9d46bf
2011-03-14 10:29:02 -07:00
Pascal Massimino
5c69e1bb4d fix bigger-by-1 array
and use enums for that.
props to Nigel Tao (at google dot com) for the fix

Change-Id: I68194cb510760dd82a2ae83359154bf622502991
2011-03-13 22:43:35 -07:00
Pascal Massimino
7c5267e36e fix a (harmless) typo: non_zero_ -> non_zero_ac_
props to Nigel Tao (at google dot com) for spotting it!

Change-Id: I113d714242e98edf02328a1898eb235899c07601
2011-03-13 20:36:43 -07:00
Pascal Massimino
bc75213572 fix missing free()
Change-Id: Ia09869321e00bb3fb8e92e5d91993ff583dc6cdf
2011-03-13 00:22:57 -08:00
Pascal Massimino
af3e2aaa04 remove trailing spaces
Change-Id: Ic92addd7c152e0216d5c9a35f5661914a5671f03
2011-03-10 15:57:18 -08:00
Pascal Massimino
13e50da6f8 make the bitreader preload at least 8bits, instead of post-load them
(this makes initialization easier and will be helpful for incremental
decoding).
Modify ParsePartitions() to accommodate for truncated input.

Change-Id: I62f52078d6b7a2314a11880a20d9eac5b4714bd0
2011-03-10 15:05:59 -08:00
Pascal Massimino
3db6525574 separate block-parsing into a visible VP8DecodeMB()
This is to prepare for incremental decoding.

Change-Id: Ifc7e2df3e18eb56af3752cba8dfe08d370036d7f
2011-03-09 21:29:36 -08:00
Pascal Massimino
a871de0255 add missing extern "C"
Change-Id: Ie325dbbb1c1f0f55a3f207a32c67139f59c03bf2
2011-03-09 21:25:53 -08:00
Pascal Massimino
b3ce8c522a remove a gcc warning about type pun by using a proper union'd type
Change-Id: Ie2dd4aa696318daa84b90de009218311153c0613
2011-03-09 07:18:51 -08:00
Pascal Massimino
e1863715bf update after addition of webpi.h
Change-Id: I747bb0e6ba89ab6733d85ed688db2c608f7e6973
2011-03-09 07:03:40 -08:00
Pascal Massimino
3e856e2dd6 Extract some useful functions around decoding buffer WebPDecParams.
This is to prepare for incremental decoding.

Change-Id: Ibb1ac6c1f2d10e096c4fbcf0c06bce77b30ca457
2011-03-08 19:23:16 -08:00
Pascal Massimino
d5bc05a47b make the filtering process match libvpx and ffvp8
libvpx (and ffvp8) implementations are completely skipping the deblocking
step if loop_filter_level is 0, which is _not_ equivalent to performing
the loop-filtering with a 0 value for loop_filter_level. In the latter case
(which we followed), few pixels were modified here and there and you could
observe off-by-1 errors on few places.

This patch will reconcile the 3 implementations (since the difference
is minor, skipping the deblocking step will save CPU for virtually
no visible difference).

The spec will be made clearer about the expected behaviour:
* if the global loop_filter_level is 0, turn deblocking off.
* if it's not 0 but the local loop_filter_level ends up being 0 for whatever
reason (lf_delta, mode delta, ref delta, etc.) on a particular
macroblock, skip the deblocking too.

Change-Id: I157f1f8de463b8a76caddb3f347b7fbc7bd527d2
2011-03-08 18:47:08 -08:00
Pascal Massimino
5b70b378bd * add an option to bypass_filtering in VP8Io.
This will make the decoder skip the filtering process if needed,
resulting in speed-up, but also non-compliant (blocky?) output
+ Add a versioning check for VP8InitIo(), since we've adding a field to VP8Io
+ add some more error checks while at it

Change-Id: I4e9899edc24ecf8600cbb27aa4038490b7b2cef3
2011-02-27 10:55:33 -08:00
Pascal Massimino
f61d14aabf a WebP encoder
converts PNG & JPEG to WebP

This is an experimental early version, with lot of room
of later optimizations in both speed and quality.

Compile with the usual `./configure && make`
Command line example is examples/cwebp

Usage:

   cwebp [options] -q quality input.png -o output.webp

where 'quality' is between 0 (poor) to 100 (very good).
Typical value is around 80.

More encoding options with 'cwebp -longhelp'

Change-Id: I577a94f6f622a0c44bdfa9daf1086ace89d45539
2011-02-18 23:54:59 -08:00
Pascal Massimino
87ffa005de typo: fix a missing 'R', was confusing.
Change-Id: I769ded6058f6c7eabc97fc7a772bc44a42cd826e
2011-02-17 09:59:34 -08:00
Pascal Massimino
746a4820b9 * make (*put)() hook return a bool for abort request.
* add an enum for VP8Status() to make things clearer

Change-Id: I458aeabab93f95d28e8ee10be699b677c04b4acb
2011-02-16 14:33:16 -08:00
Pascal Massimino
73c973e6da * strengthen riff/chunk size checks
* don't consider odd-sized chunks being an error

Change-Id: I2901b071232bb996680cf155e1a25a6a9388f222
2011-02-16 13:24:55 -08:00
Pascal Massimino
1dc4611a3a add support for PNG output (default)
regularize include guards

Change-Id: Ia1d0fa49c8c98e2c11f775b839d04a24e5450170
2011-01-31 22:25:44 -08:00
Pascal Massimino
860641df3f fix a typo: sizeof(kYModeProbaInter0) => sizeof(kUVModeProbaInter0)
report by mr dot gnu do jr at gmail dot org.

Change-Id: Iccd701ab1ec613a019f216e5cb37a18e5adfb4cf
2011-01-31 21:12:19 -08:00
Pascal Massimino
504d33937c fix eof_ mis-initialization
For very very short partitions, the initial GetByte() could
set eof_ to 1, whereas some bits were available but unread yet.
So we set eof_ to 0 last.

Change-Id: Ic6b68271bc72efa4de4e64e1f57307d1d8fb613c
2011-01-17 00:25:18 -08:00
Pascal Massimino
2bc0778f85 leftover Makefile.* from previous commit
Change-Id: If89dde15cd3f4a27ad95401a66f27fd5e079c5da
2011-01-08 07:16:20 -08:00
Pascal Massimino
6421a7a4fb move the decoder sourcetree to a sub-location src/dec
to make room for future libs sources

also extract the types declaration into its own types.h file

Change-Id: I8bae8a323a479a29375cf509792228ae6af51c7a
2011-01-06 08:57:14 -08:00