Commit Graph

541 Commits

Author SHA1 Message Date
James Zern
1f14632a18 gif2webp: fix transcode of loop count=65535
with loop_compatibility disabled (the default), non-zero loop counts
will be incremented by 1 for browser rendering compatibility. the max,
65535, is a special case as the muxer will fail if it is exceeded; avoid
increasing the limit in this case. this isn't 100% correct, but should
be close enough given the high number of iterations.

BUG=webp:382,webp:512

Change-Id: Icde3e98a58e9ee89604a72fafda30ab71060dec5
(cherry picked from commit af0e4fbb06)
(cherry picked from commit 4b282e13ad)
2021-03-23 17:08:16 -07:00
James Zern
c10a493caf vwebp: disable double buffering on windows & mac
this results in flickering with animated webp + alpha. disabling the
option is a workaround to restore the behavior to the previous release.

BUG=webp:365

Change-Id: Iac7fcc0d483837e76cc54ad3f26c4e0e5511e31d
2017-11-25 18:22:39 -08:00
James Zern
126be10950 webpinfo: add -version option
Change-Id: I5861d5ccd2119dd6749dc70b65fd145b5a732f98
2017-11-24 14:21:05 -08:00
Pascal Massimino
2e5785b233 anim_utils.c: remove warning when !defined(WEBP_HAVE_GIF)
BUG=webp:355
Change-Id: I57d77672260771bb0c2ab3c802388f2d62b1f187
2017-11-23 00:22:33 -08:00
Pascal Massimino
8052c585b3 remove some petty TODOs from vwebp.
they're rather low-prio anyway.

Change-Id: I76dd74fcfb1c974c6f8a074472455d3f0b202e01
2017-11-22 19:22:52 +00:00
James Zern
68b2eab7df cwebp: fix alpha reporting w/lossless & metadata
the incorrect bit was being extracted from the lossless bitstream header
causing the alpha flag in VP8X to be misreported. previously the
signature byte was ignored in the calculation of the offset.

since:
8ba1bf61 Stricter check for presence of alpha when writing lossless
images

BUG=webp:361

Change-Id: I7c618b5f01a37f5e4b799dee11a7949efaf88046
2017-10-18 12:35:56 -07:00
Pascal Massimino
3c74c645ca gif2webp: handle 1-frame case properly + fix anim_diff
follow-up to commit b4e046778

Change-Id: I3c7617d09682262ca7929e6a3e56777b163cce45
2017-09-20 22:21:15 +00:00
Pascal Massimino
b4e046778d gif2webp: introduce -loop_compatibility option
This patch fixes the compatibility for loop-count handling.
This aims at addressing the change in Chrome handling of loop-count
prior to M63.

Before M63: loop-count interpretation was aligned to GIF's behaviour in
Chrome, but incompatible with WebP's spec. In particular, you couldn't
loop exactly once.

Post-M63: loop-count in WebP is really the total number of loops. Gif2webp
will convert correctly from a GIF source by adjusting the loop count.

Note: The Chrome version can be retrieved from the User-Agent
string (chrome://version).
An M63 version will contain the pattern:
   Chrome/63.x.xxxx.xx
for instance.

Change-Id: Ie6dc13227e6498f4d7af2f09247913648997648a
2017-09-20 07:37:49 +00:00
Pascal Massimino
f66f94ef36 anim_dump: small tool to dump frames from animated WebP
dumps frames to PNG, PAM or TIFF files.


Change-Id: I86a4d7e235cb7040cf5bbcae28270cb5a84be087
2017-08-30 06:12:03 +00:00
Pascal Massimino
3822762a6c rationalize the Makefile.am
one library addition per line, etc...

BUG=webp:355

Change-Id: I95761dea598a382db5632c5187210937e129ff75
2017-08-29 00:00:14 -07:00
Pascal Massimino
f8bdc26821 Merge "protect against NULL dump_folder[] value in ReadAnimatedImage()" 2017-08-29 05:41:16 +00:00
Pascal Massimino
23bfc652fe protect against NULL dump_folder[] value in ReadAnimatedImage()
BUG=webp:355

Change-Id: If449ed4b0bd7a11ce7c646eabe2a7b58a1abf009
2017-08-28 20:57:22 +00:00
James Zern
8dc3d71ba0 cosmetics,ReadAnimatedWebP: correct function comment
BUG=webp:355

Change-Id: If671b67067ee6ebaa63e9710ddbb7d59b33dbc3b
2017-08-28 11:43:26 -07:00
James Zern
7945575c92 cosmetics,webpinfo: remove an else after a return
this is redundant with an if block that returns

BUG=webp:355

Change-Id: I66a64a0a4932c5f419f6171684b72088c43e7136
2017-08-26 14:22:39 -07:00
James Zern
8729fa1102 cosmetics,cwebp: remove an else after a return
this is redundant with an if block that returns

BUG=webp:355

Change-Id: I4d2e520f89a8e144ab13aa3696f305365e584a0e
2017-08-26 14:22:32 -07:00
James Zern
7beed2807b add missing ()s to macro parameters
BUG=webp:355

Change-Id: I616c6d3540d6551edd1b1cfdb5bffcf0a044c90f
2017-08-04 17:02:53 -07:00
Vincent Rabaud
5d7a50efee Get code to compile in C++.
Change-Id: I2f56e6b71e33ffecdba9e4fa9ef8f891c88f850f
2017-06-19 17:12:29 +02:00
hui su
af6deaffa0 webpinfo: handle alpha flag mismatch
Throw a warning for false positive vp8x alpha flag;
throw an error for false negative vp8x alpha flag.

BUG=webp:330

Change-Id: I3933588c9d6d76ecaf515517f7506dea299af638
2017-05-23 10:28:25 -07:00
hui su
0d20abb36f webpinfo: tolerate ALPH+VP8L
Change-Id: I63cec2d021c0bfaa188017813813bddaadfbeacb
2017-05-19 14:58:44 -07:00
hui su
dabda70733 webpinfo: add support to parse Alpha bitstream
BUG=webp:330

Change-Id: I9ed0923d19558052d63bdbe93a542c51595fdce7
2017-05-17 09:35:58 -07:00
James Zern
4c1176432a webpinfo: correct background color output, BGRA->ARGB
bgcolor is stored little-endian, byte order is BGRA, with A being the
high byte

Change-Id: I8327380c039634120ee2313044781a5651513dcb
2017-05-16 11:51:44 -07:00
Pascal Massimino
818d795b09 vwebp: activate GLUT double-buffering
This prevents the flickering of animated webp + alpha.

Change-Id: I335a434ccc6c90e32528c9832555a38cc0f71cc4
2017-05-10 05:16:47 +00:00
Hui Su
cbc1b92117 webpinfo: add features to parse bitstream header
BUG=webp:330

Change-Id: If2a6ff010219fa25a2b5843725c616ee4dce65a7
2017-05-04 09:18:11 -07:00
James Zern
2cb58ab2d7 webpinfo: output format as a human readable string
Change-Id: I3a3d95bae049ee1053c9d92a364cf1b75f277f81
2017-03-17 00:23:11 -07:00
Pascal Massimino
274daf5415 Add webpinfo tool.
A command line tool to print out the chunk level structure of
WebP files along with basic integrity checks.

BUG=webp:330

Change-Id: Ic69f646f649abb655b1854621d99afedeed158d7
2017-03-14 11:41:17 +01:00
Pascal Massimino
9273e441da fix TIFF encoder regarding rgbA/RGBA
Encoder:
We were always using ExtraSamples=1, which means associated-alpha.
But we don't need the (lossy) excursion to rgbA format. We can save
the samples as RGBA directly, by changing ExtraSamples to '2'.
The TIFF encoder now checks the colorspace properly, to handle
premultiplied format as well as non-premultiplied.

Decoder:
The result of TIFFReadRGBAImageOriented() is always pre-multiply.
So, in case an alpha channel is present, we need to unmultiply it before
calling WebPPictureImportRGBA().

See:
https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf (page 31)
and also http://www.asmail.be/msg0055469184.html

Change-Id: I3258bfdb0eb2e1a53d6c04414f55edb2926c938c
2017-03-03 10:36:29 -08:00
James Zern
0d8e05880c img2webp: treat -loop as a no-op w/single images
or in cases where duplicates have been reduced to one

Change-Id: I145cd61b6792b021617f1234f0ba36e2a3128d84
2017-01-25 08:17:39 +00:00
James Zern
6451709e72 img2webp,get_disto: fix image decode w/WIC builds
similar to cwebp, attempt ReadPictureWithWIC() first

Change-Id: Ifb83aaa457be59c95b201bf8bd6b0877a6a253ed
2017-01-24 15:12:08 -08:00
Pascal Massimino
4689ce1635 cwebp: add a -sharp_yuv option for 'sharp' RGB->YUV conversion
Change-Id: I6edd5b44d693da50f702fa8218f14872874d91ba
2017-01-20 16:54:54 +01:00
Pascal Massimino
eb1dc89a5f silently expose use_delta_palette in the WebPConfig API
is just a placeholder for now, unless WEBP_USE_EXPERIMENTAL_FEATURES
is defined.

Change-Id: I087cb49781560bc1a7fbb01b136d36115c97ef72
2017-01-20 10:25:19 +01:00
Pascal Massimino
259e98286a replace 'ptr + y * stride' by 'ptr += stride'
This is to prevent potential overflow.

Change-Id: I9d21cfe790ba975bd5e117b025ea4d9deaeae4ab
2017-01-04 00:54:23 -08:00
James Zern
67c25ad5b4 vwebp: clear canvas during resize w/o animation
this corrects the checkboard pattern displayed with transparent images

Change-Id: I5f46dbc9fa3893d61f5f1d4fda643ac030238f94
2016-12-13 23:21:33 -08:00
Pascal Massimino
cb9ec84b54 Merge "remove the dependency to stop_watch.[ch] in imageio" 2016-12-13 06:48:07 +00:00
James Zern
1e2e25b0d4 anim_util: quiet implicit conv warnings in 32-bit
the sizes are already validated by CheckSizeForOverflow(), add casts to
size_t to avoid -Wshorten-64-to-32

Change-Id: Ida9102c2104f4a334a0ad16d6e01a12bedfd4eec
2016-12-12 19:06:14 -08:00
Pascal Massimino
cb215aed5c remove the dependency to stop_watch.[ch] in imageio
Passing the 'verbose' flag to DecodeWebP() wasn't mandated,
and was creating a forced dependency between imageio/ and examples/

Change-Id: Ib3d3f381a7b699df369a97cfb44360580422df11
2016-12-12 22:01:36 +01:00
Pascal Massimino
bded7848ea img2webp: fix default -lossless value and use pic.argb=1
Change-Id: I0e5350928c1e58e0901303ee979fb4587f25d6bc
2016-12-02 13:19:02 +01:00
Pascal Massimino
03f40955a3 img2webp: convert a sequence of images to an animated webp
Usage:

  img2webp [file-level options] [image files...] [per-frame options...]

File-level options (only used at the start of compression):
 -min_size ............ minimize size
 -loop <int> .......... loop count (default: 0, = infinite loop)
 -kmax <int> .......... maximum number of frame between key-frames
                        (0=only keyframes)
 -kmin <int> .......... minimum number of frame between key-frames
                        (0=disable key-frames altogether)
 -mixed ............... use mixed lossy/lossless automatic mode
 -v ................... verbose mode
 -h ................... this help

Per-frame options (only used for subsequent images input):
 -d <int> ............. frame duration in ms (default: 100)
 -lossless  ........... use lossless mode (default)
 -lossy ... ........... use lossy mode
 -q <float> ........... quality
 -m <int> ............. method to use

example: img2webp -loop 2 in0.png -lossy in1.jpg
                  -d 80 in2.tiff -o out.webp

Change-Id: I23771b90eaf0660f420d7ffd304e704155386286
2016-12-02 11:44:17 +01:00
Pascal Massimino
c85adb33d2 vwebp: make 'd' key toggle the debugging of fragments
it actually disables the disposal / blending method
and just displays the raw delta values.
Useful for debugging.
TODO: Outline the refreshed area with a drawn rectangle?

Change-Id: I6f8cddd0aad8b953cff78a693ae7e8c31def010c
2016-11-28 19:47:23 +00:00
Pascal Massimino
c0699515af webpmux -duration: set default 'end' value equal to 'start'
The options are now:
  -duration d     -> set the whole animation to duration 'd'
  -duration d,s   -> set only frame 's' to duration 'd'
  -duration d,s,e -> set only interval [s,d] to duration 'd'

+ style fix

Change-Id: I72e95282d520146f76696666f44280ad9506affa
2016-11-11 17:57:56 +00:00
Urvang Joshi
f90c60d129 Merge "add a "-duration duration,start,end" option to webpmux" 2016-11-09 19:05:12 +00:00
Pascal Massimino
3f182d36f4 add a "-duration duration,start,end" option to webpmux
this will force a constant duration for an interval of frames
in an animation.
Notes:
 a) '-duration [...]' can be repeated as many times as needed.
 b) intervals are taken into account in option order. If they overlap, values will be overwritten.
 c) 'start' and 'end' can be omitted, but not the duration value.
 d) 'end' can be equal to '0', in which case it means 'last frame'
 e) single-image files are untouched (ie. not turned into an animation file).

Some example usage:
    webpmux -duration 150 in.webp -o out.webp
    webpmux -duration 33,10,0 in.webp -o out.webp
    webpmux -duration 200,2 -duration 150,0,50 in.webp -o out.webp

Change-Id: I9b595dafa77f9221bacd080be7858b1457f54636
2016-11-09 15:44:09 +01:00
James Zern
cac9a36a23 gifdec,Remap: avoid out of bounds colormap read
make this function return success/failure.
an empty map or out of bounds read is treated as an error.

BUG=webp:316

Change-Id: Ic8651836915ea4dd8e0dc81ca8d5d3f247be1ff8
2016-11-02 15:01:10 -07:00
James Zern
4595e01fd0 Revert "gifdec,Remap: avoid out of bounds colormap read"
This reverts commit f048d38d38.

the 'len' in Remap refers to the src[] not the colormap; this change
breaks valid files

BUG=webp:316

Change-Id: I1ed40075c2194df91d345cb6f29619b1f5cc96fc
2016-11-01 21:03:56 -07:00
James Zern
fb52d4432a gifdec: make some constants unsigned
fixes implicit type conversion when dealing with color types

Change-Id: Ie4f25e14d8bb2748050db4fca25147164fc6adb4
2016-10-31 17:51:27 -07:00
James Zern
f048d38d38 gifdec,Remap: avoid out of bounds colormap read
sanitize the requested length to be read against the reported size of
the table

BUG=webp:316

Change-Id: I1c471e93ab696a9d21a0142cf1987ffcf8f55dd2
2016-10-31 12:56:04 -07:00
Pascal Massimino
2f51b614b0 introduce WebPPlaneDistortion to compute plane distortion
Make WebPPictureDistortion() only compute distortion on A/R/G/B planes, not Y/U/V(A).
(not just for SSIM, but PSNR too).

This is to avoid problems with using SSIM on U/V channels.
If Y/U/V distortion is needed, one can always use WebPPlaneDistortion() individually.

Change-Id: If8bc9c3ac12a8d2220f03224694fc389b16b7da9
2016-10-19 09:12:13 +02:00
Pascal Massimino
265abbe9b2 Merge "additional fix for stride type as size_t" 2016-10-13 20:38:07 +00:00
Pascal Massimino
ce8733209d Introduce a generic WebPGetImageReader(type) function
Also introduce an always-failing 'reader' for unknown formats.
So we don't have to check reader==NULL, code is more regular.

-> We can get read of specific ReadPNG(), ReadJPEG(), ... declaration and use.

Change-Id: I290759705420878f00c7223c726d4ad404afd9c4
2016-10-12 21:00:27 -07:00
Pascal Massimino
9f5c8eca79 additional fix for stride type as size_t
- remove the inclusion of format_constants.h
 - use incremental update of pointer, instead of arithmetic

(follow-up to e2affacc35)

Change-Id: I48420c8defc8d47339f54bc00e9da9617f08ab32
2016-10-12 18:23:04 +00:00
Pascal Massimino
e2affacc35 fix potential overflow when width * height * 4 >= (1<<32)
Mostly: avoid doing calculation like: ptr + j * stride
when stride is 'int'. Rather use size_t, or pointer increments (ptr += stride)
when possible.

BUG=webp:314

Change-Id: I81c684b515dd1ec4f601f32d50a6e821c4e46e20
2016-10-10 13:55:46 +02:00