Commit Graph

517 Commits

Author SHA1 Message Date
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
James Zern
806f6279ae gif2webp: fix crash with NULL extension data
DGifGetExtension() may successfully return, but the data pointer should
still be validated

BUG=webp:310

Change-Id: I6cfe617871fef2fe07887e5f48bb20f7ab7cfb35
2016-10-07 11:21:18 -07:00
James Zern
bfab894739 vwebp: ensure setenv() is available in stdlib.h
quiets a -Wimplicit-function-declaration with some configurations of gcc
(-std=c99).
_POSIX_C_SOURCE is preferred over _BSD_SOURCE with newer versions of
glibc

Change-Id: I378bffb13ba52ff5c4bad1433090dcc387e5d507
2016-09-30 00:27:06 -07:00
Pascal Massimino
9310d19258 vwebp: handle window resizing properly
The image is scaled to fit the whole viewport.
Avoid some oddities with offsets, etc.

removes some TODO.

Change-Id: I52fae9ca80a2feed234f32261c7f6358d7594e21
2016-09-29 07:30:03 +02:00
Pascal Massimino
1c36440094 prevent 32b overflow for very large canvas_width / height
some multiplies here and there needed some extra checks
and error reporting. Even if width * height is guaranteed
to be < 2**32, we were multiplying by num_channels and
triggering a 32b overflow.
Some multiplies were not using size_t or uint64_t, additionally.

Change-Id: If2a35b94c8af204135f4b88a7fd63850aa381bbf
2016-09-23 05:19:32 +00:00
Pascal Massimino
1effde7bcd fix anim_util.c compilation when HAVE_GIF is not defined.
Change-Id: I1a4f13a5799c020fb4b3ade3c7336f049443ab62
2016-09-22 13:43:36 +02:00
James Zern
41cab7fe0f imageio/Android.mk: correct imagedec dependencies
this relies on imageio_util; remove the reference for dwebp as this does
not directly rely on it.

Change-Id: I09b863ae0dfe2e9c4929ff6b77e9310bb870ce35
2016-09-08 20:03:07 -07:00
James Zern
82c91c708e Merge "libimageenc.a: extract image-saving code from dwebp" 2016-09-09 03:00:20 +00:00
Pascal Massimino
af1ad3e2dd libimageenc.a: extract image-saving code from dwebp
BUG=webp:277
Change-Id: I2c0e1df7b13b1f77474b5478048fef022e90f77a
2016-09-08 19:11:26 -07:00
Pascal Massimino
545c147fd8 remove mention of fragment, frgm, FRGM, etc.
demux.h still has a 'fragment' field, for historical reasons.

bumped the ABI number in mux.h

Change-Id: I73299aa2e96b1f2e44f5cebfd84c597d1db12bff
2016-09-02 14:43:12 +02:00
hui su
43bd895879 Make gif transparent color to be transparent black
Change it from transparent white to transparent black, which matches
the transparent color assumed in Webp dispose-to-background method.

Also pre-multiply background colors before comparison in anim_diff,
just as what is done with regular pixel values.

Change-Id: I5a790522df21619c666ce499f73e42294ed276f2
2016-09-01 16:50:14 -07:00
Pascal Massimino
c0a27fd2af vwebp: Clear previous frame when a key triggers a redraw
otherwise, transparent areas were accumulating.

Change-Id: I066a96a2bcf0cac750b3df0c02229542b1ed3473
2016-08-24 11:04:17 +02:00
Hui Su
74f6f9e793 Add descriptions of default configuration in help info.
Change-Id: I43188fab5f57bd45aa3e564df52e36cc37b1bb2f
2016-08-16 14:32:46 -07:00
James Zern
b551e587b3 cosmetics: add {}s on continued control statements
for consistency within the codebase. in some cases simply join the
lines.

Change-Id: I071f061052e274c8a69f651ed4305befb4414a40
2016-08-03 19:08:59 -07:00
James Zern
d7ce4a2e3e examples/Makefile.am,cosmetics: sort binary targets
Change-Id: I1a592bfcdf55b41814eaf971b43a773c26fbb651
2016-07-25 22:39:54 -07:00
James Zern
ebee57f4d1 move imageio/example_util.[hc] (back to) examples/
decoding and file i/o have been split to imageio, all that remains is
some string routines used for parameter parsing in the examples

Change-Id: I77386cd8aa39124b9e14c95fdbaa17ea4ab5bb24
2016-07-21 20:41:03 -07:00
James Zern
99542bbf3e webpdec: s/ExUtil//
PrintWebPError, LoadWebP, DecodeWebP, DecodeWebPIncremental

Change-Id: Ie17578b91c7efdf6e5fe63568a95f79788b7f8ee
2016-07-21 20:40:11 -07:00
James Zern
da573cf490 imageio_util: s/ExUtil/ImgIoUtil/
ExUtil(SetBinaryMode|ReadFile|ReadFromStdin|WriteFile|CopyPlane) ->
ImgIoUtil(SetBinaryMode|ReadFile|ReadFromStdin|WriteFile|CopyPlane)

Change-Id: I5497f8fe514347efeb83b8b8866ef334390fc18e
2016-07-21 20:40:11 -07:00
James Zern
bdda5bd4bf split example_util.h
move ExUtil*File to imageio_util.h
ExUtil*WebP* to webpdec.h

string parsing routines remain

Change-Id: I0560c4a74e86710d83bc4b5b234f1b5ef9a86f9d
2016-07-21 19:14:58 -07:00
James Zern
c379b55a93 move examples/{example_util,image_dec} to imageio/
Change-Id: I2508c786a095a2a75bebf766210c64e2af88f9b6
2016-07-19 19:06:29 -07:00
Urvang Joshi
479d19085d webpmux: Also print compression info per frame.
As per the user request:
https://groups.google.com/a/webmproject.org/forum/#!topic/webp-discuss/dk9M-q1MFnw

Change-Id: Id2540413a89e1f043e50abb0cec7c69367ee8325
2016-07-08 15:44:38 -07:00
James Zern
ab7937a5c7 gif2webp: normalize the number of .'s in the help message
Change-Id: I3a2412f391b3244c172ee28819e8e606a9674aa9
2016-06-24 19:29:43 -07:00
James Zern
3cdec847a5 vwebp: normalize the number of .'s in the help message
Change-Id: Iadaa5a8f64cd8093eeeaf829ba609bef034d63b5
2016-06-24 19:29:43 -07:00
James Zern
bdf6241e70 cwebp: normalize the number of .'s in the help message
Change-Id: I0208c01a671bd822ee707c6d8ead3d5348b3e2c6
2016-06-24 19:29:43 -07:00
Pascal Massimino
97b9e64459 normalize the number of .'s in the help message
Change-Id: I2dbb36cbdc3cb93364d9e1dd6da10d3a5f9470af
2016-06-23 16:06:09 -07:00