Commit Graph

621 Commits

Author SHA1 Message Date
James Zern
f999d94f4a gif2webp: add -sharp_yuv/-near_lossless
This change is the same as the one that introduced the options to
img2webp:
0825faa4 img2webp: add -sharp_yuv/-near_lossless

Change-Id: Id380d159299c38dd6440f833d487e00c0976afec
2024-11-04 12:29:24 -08:00
James Zern
57883c78ed img2webp: add -exact/-noexact per-frame options
Bug: b:363409354
Change-Id: I4e7282ed2df091dbef6d79743be1c8c868c0d44a
2024-09-03 18:58:13 -07:00
James Zern
1c8eba978b img2webp,cosmetics: add missing '.' spacers to help
Change-Id: I98e853a8caa091c182d41ea9d95499021c8deb3a
2024-09-03 18:27:45 -07:00
Vincent Rabaud
1bf198a22b Allow transform_bits to be different during encoding.
The spec allows it but it is currently forced to the same value for simplicity.

Change-Id: I26197dbf3342f7a72115cc7f7805c154313a2afb
2024-05-13 16:56:19 +02:00
James Zern
a67ff735a2 normalize example exit status
Use EXIT_SUCCESS / EXIT_FAILURE in most cases as more granularity isn't
useful. For anim_diff, use 0 (success), 1 (image difference) and 2
(error) to align it with other diff utilities (diff, etc.).

Bug: webp:637
Change-Id: I52925de8622a5a4d2141883279d69a1d95ef9b12
2024-05-01 10:38:44 -07:00
James Zern
d781646c29 vwebp: fix window title when options are given
Options can precede the file name. This still won't be correct for
Unicode file names, but an approximation will be displayed (with '?'s)
rather than the first character if kParams.file_name were used.
glutCreateWindow() looks like it will prohibit correcting this as it
expects an ASCII string.

Change-Id: I96986a178a0bbce6971d2ac415222d4a456ce1a3
2024-04-01 19:34:17 -07:00
Vincent Rabaud
40e85a0b56 Have the window title reflect the filename.
This is from https://github.com/webmproject/libwebp/pull/3

Change-Id: Ia54f9b6a2ac0d078e931c088694924ed914c18fd
2024-03-20 14:33:54 +01:00
James Zern
1fb9f3dcf1 gifdec: fix ErrorGIFNotAvailable() declaration
A void parameter list should be (void), not (). Fixes a
-Wstrict-prototypes warning.

Change-Id: I180efbf7c58956695359320072cce1171d79e377
2024-02-22 13:58:19 -08:00
James Zern
f4b9bc9ea1 clear -Wextra-semi-stmt warnings
This is available with clang. Clears warnings of the form:
  warning: empty expression statement has no effect; remove unnecessary
    ';' to silence this warning [-Wextra-semi-stmt]

As a side-effect it also clear a few -Wpedantic warnings with gcc:
  warning: ISO C does not allow extra ';' outside of a function
    [-Wpedantic]

Change-Id: I9295c767aad475c68b1fbbdff855b0d6650a25f5
2024-02-15 18:55:22 -08:00
Vincent Rabaud
13d9c30b2b Add a WEBP_NODISCARD
Change-Id: Ice66f2aa6358474d728fb19c571edc86ed139a49
2023-11-10 13:57:07 +01:00
Vincent Rabaud
433c7dca11 Fix static analyzer warnings.
Change-Id: I45f0db2310b1188809963af93240e3d438f807b8
2023-09-14 22:43:45 +02:00
James Zern
2fe27bb96d img2webp: normalize help output
this makes the output from img2webp and the ordering in doc/tools.md and
man/img2webp.1 consistent

Change-Id: Ic389aaa29c20128f2b87f231be383094602f125b
2023-03-17 15:37:55 -07:00
James Zern
24bed3d9fb cwebp: reflow -near_lossless help text
this matches the output from img2webp added in:
0825faa4 img2webp: add -sharp_yuv/-near_lossless

Change-Id: I329ccd796d7e9bee36de1429fceafe83d7dc5532
2023-03-17 15:17:31 -07:00
jzern@google.com
0825faa4c1 img2webp: add -sharp_yuv/-near_lossless
Both are global settings. Modifying them at the frame level is left as a
follow up based on need.

Bug: b/272739498
Change-Id: If15256c052f73fe3df56be5e0095e76d9870cc0f
2023-03-17 09:35:29 -07:00
James Zern
6fc1a9f96e */Android.mk: add a check for NDK_ROOT
This simplifies integration with the Android platform and avoids the
files from being used when a non-NDK build is performed. In that case
Android.bp is preferred.

Change-Id: I6e334cf8b05a19da8452405f5f448f9e4b6e4a40
2022-12-16 12:10:36 -08:00
James Zern
3f73e8f7ac sharpyuv: add SharpYuvGetVersion()
Change-Id: Ic7e93c7c3ec33b8ab0105a6e81b76a7869422b55
2022-10-28 19:15:32 -07:00
James Zern
c626e7d544 cwebp: fix WebPPictureHasTransparency call
when near_lossless is < 100; previously the zeroed 'picture' would be
passed in the check rather than the original picture. this would result
in alpha never been kept in the decode.

Change-Id: I6af3aef7de2d672e044025d975d8180b12d5fa40
2022-08-08 16:42:00 -07:00
James Zern
bcb872c31f vwebp: fix file name display in windows unicode build
glutBitmapCharacter() isn't limited to 8-bit characters; add
PrintStringW() to iterate through the file name. This may not fix all
cases, non-existent characters in the font used have no effect.

https://www.opengl.org/resources/libraries/glut/spec3/node76.html#SECTION000111000000000000000

Change-Id: Idb0379539d556a89ec694127f766eb662f09d597
2022-07-05 12:59:06 -07:00
James Zern
67c44ac5db webpmux: fix -frame option in windows unicode build
-frame takes a file name parameter, use wargv[] like in other paths

Change-Id: Id582e395d3ff9b00bb7fcc0261b475211758f6d4
2022-07-05 11:48:56 -07:00
James Zern
169f867f3c unicode.h: set console mode before using wprintf
This fixes incorrect character display in the file name
in e.g., stats output from cwebp.exe in visual studio builds.

In mingw further changes will be needed as using %s in wfprintf() for
wchar_t pointers is a Microsoft extension that doesn't seem to be
supported with gcc -fms-extensions. %ls works, but will require updating
format strings and wrapping concatenations with TO_W_CHAR() as visual
studio will reject merging string constants of different width.

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setmode

Change-Id: I57d24c3815f7b5aa3971ac315c65c4458258d706
2022-06-29 22:05:26 -07:00
James Zern
bef0d79764 unicode_gif.h: fix -Wdeclaration-after-statement
when building for windows with _UNICODE defined

unicode_gif.h|49 col 3| warning: ISO C90 forbids mixed declarations and
code [-Wdeclaration-after-statement]

Change-Id: Ib9f0cc0eba036d6cd4221a4f70a078770dde01d0
2022-06-20 11:40:09 -07:00
James Zern
2d3293ad76 ExUtilInitCommandLineArguments: fix leak on error
argv_data would leak if the argv_ allocation failed or the MAX_ARGC cap
was hit

Tested:
for i in `seq 1 171`; do
  export MALLOC_FAIL_AT=$i
  ./examples/img2webp jpeg_file -o /dev/null
  ./examples/img2webp -mixed jpeg_file -o /dev/null
done

Change-Id: I39864691e96d5456f324d95a3653bba0f6d6a7be
2022-04-04 11:26:25 -07:00
James Zern
ec34fd7023 anim_util: fix leaks on error
in ReadAnimatedWebP() & ReadAnimatedGIF() when AllocateFrames() fails
due to OOM

Tested:
for i in `seq 1 278`; do
  export MALLOC_FAIL_AT=$i
  ./examples/anim_diff webp1 webp2
  ./examples/anim_diff gif1 gif2
done

Change-Id: I5d486c2c2982ae088e34a25d8e3e0188df1a9b51
2022-04-04 11:26:25 -07:00
James Zern
e471728754 gif2webp: fix segfault on OOM
previously calls to WebPPictureCopy() weren't checked, causing a crash
when the canvas copies were accessed later in the loop

Tested:
for i in `seq 1 1125`; do
  export MALLOC_FAIL_AT=$i
  ./examples/gif2webp gif_file
  ./examples/gif2webp -mixed gif_file
done

Change-Id: I186d13be0ec8f3b72b7d247a8482590c1b1be541
2022-04-04 11:26:12 -07:00
James Zern
617cf03656 image_dec: add WebPGetEnabledInputFileFormats()
and use it to output the types supported in the examples

Change-Id: Ia6b8624a2146cf72c679129065a72f215644e1e9
2022-03-26 15:37:25 -07:00
James Zern
34bb332ca1 man/cwebp.1: add note about crop/resize order
+ normalize help text in [cd]webp

Bug: webp:561
Change-Id: Id92ec4228d4933cd033b2bf68a43192532cef483
2022-03-17 16:08:34 -07:00
James Zern
a30f219016 examples/webpmux.c: fix a couple of typos
in the code and help output; the man page is already correct

Change-Id: Id07d32cde24447cf61e1a2b3d55ab4a33549adde
2022-02-17 17:10:08 -08:00
Pascal Massimino
17bade381a Merge "Reword img2webp synopsis command line" into main 2022-01-05 12:04:26 +00:00
Yannis Guyon
a80954a1d9 Reword img2webp synopsis command line
See https://bugs.chromium.org/p/webp/issues/detail?id=549

Change-Id: I75562d2ad021d8ec107eb4ced5b28e0abf373324
2022-01-05 10:15:28 +01:00
James Zern
e3cb052ca5 webpinfo: fix fourcc comparison w/big-endian
store the recognized fourccs in little-endian order to match how the
fourcc is being read from the file

Bug: webp:548
Change-Id: I9de77db92208709d5e711846908a51e563102fa5
2021-12-22 16:01:54 -08:00
Pascal Massimino
3368d8768a Merge "webpmux: add "-set bgcolor A,R,G,B"" into main 2021-11-04 19:00:36 +00:00
Pascal Massimino
f213abf620 webpinfo: print the number of warnings
otherwise they can go un-noticed (unless you use -diag).

Change-Id: Ic6faaf09e7993002cdae3e998623764fde860351
2021-11-04 17:09:51 +01:00
Pascal Massimino
50c97c301d webpmux: add "-set bgcolor A,R,G,B"
Similarly to "-set loop <>", this is useful to set
the parameter at global level and not just while assembling
the frames separately.

Change-Id: I79bcbe37f8ff50b9904e78d14011ccbac72f17a1
2021-11-04 15:45:44 +00:00
James Zern
1f5791398c cosmetics: remove use of 'sanity' / 'master'
replace with more inclusive terms or remove the comment entirely if the
meaning was already clear.

Bug: webp:507
Change-Id: Ica3bbf751ebf79f6668df6e6209af770248ff4ca
2021-05-21 10:38:40 -07:00
James Zern
5d4ee4c3c0 cosmetics: remove use of the term 'dummy'
this is replaced with more inclusive / informative text

Bug: webp:507
Change-Id: Ib77f0c79dd548601bf2bc3169985af4b5edf0a62
2021-03-15 11:39:06 -07:00
Pascal Massimino
373eb170f1 gif2webp: don't store loop-count if there's only 1 frame
BUG=webp:504

Change-Id: Iacea11a861096ae950379c872d9840bdbec42a21
2021-02-08 22:00:48 +00:00
Pascal Massimino
cccf5e337a webpmux: add an '-set loop <value>' option
This allows to change the loop count option on animated files.

BUG=webp:494

Change-Id: I6849f56d7bff8b33a94f14b409e40f99789009ad
2020-12-12 19:05:11 +00:00
James Zern
ab2d08a842 [cd]webp: document lack of animated webp support
Bug: webp:479
Change-Id: Iee2d7401400a5ff0a11682028194e561b365ab78
2020-11-19 19:17:32 -08:00
Pascal Massimino
906c1fcd61 make ImgIoUtilReadFile use WebPMalloc instead of malloc
This is a minor technical change in API in case a special allocator
was used in WebPMalloc.

Change-Id: Idb78a9150d006f158c1a9538525097749e42e7f7
2020-10-16 15:40:13 +02:00
James Zern
84739717d6 GetBackgroundColorGIF: promote to uint32_t before << 24
quiets a signed integer overflow warning

Change-Id: Ie4dd957e9fa7c6e639c2e887c448ecbba7d50a9e
2020-09-03 15:45:05 -07:00
Yannis Guyon
def64e920f cwebp: Fix -print_psnr for near_lossless
The output was always 99dB because the lossless pipeline is not
modifying the 'picture'. Changing that is not that simple because
near_lossless impacts both VP8ApplyNearLossless() and
ApplyPredictFilter(); the latter cannot be applied as is to the input
and thus the final modified 'picture' cannot be easily retrieved
without decoding the encoded bitstream. Hence ReadWebP() is called in
cwebp.c on the encoded bitstream kept in memory to get the correct
distortion.

However -get_psnr returns a different distortion than get_disto for
lossy encoding configurations because cwebp loads the source as YUV
while get_disto directly reads it as RGB without conversion loss.

Change-Id: I5c32cf8f89eb137973dc7eebda747682d921b8e2
2020-08-17 11:37:37 +02:00
Skal
6a0ff35872 Enc: add a qmin / qmax range for quality factor
This is particularly useful for multi-pass search (but not only),
to prevent the search from going over or below a reasonable threshold.
E.g.: 'cwebp -qrange 50 80 ...' will prevent any unreasonable degradation.

new cwebp option: -qrange min max

Change-Id: I59f394533535fc20b6996bc0895f4301476d5eff
2020-01-29 14:52:02 +01:00
Skal
a4df4aae73 Expose WebPMalloc() in addition to WebPFree()
and use it at various places, including for WebPData.

This is an API change!

Change-Id: Ic041323a1179c465292a4f981a86c4c34635d243
2019-10-15 23:19:50 +02:00
James Zern
fab8f9cfcf cosmetics: normalize '*' association
we associate '*' with types rather than variables

Change-Id: Id93ed65272a8a88e604278693e3850649639e9b6
2019-07-26 01:04:09 -07:00
Pascal Massimino
b9be7e65f8 vwebp: remove the -fit option (and make it default)
BUG=webp:433

Change-Id: I18476ba0ada0184d4d9e94060d601002bfa006da
2019-06-05 21:43:23 +02:00
Pascal Massimino
cbd23dd5b4 vwebp: add a -fit option
This is to make the initial window be rescaled in case the image
dimension is too large to fit the display.

BUG=webp:433

Change-Id: Ib04c12962bc8c26e74c8a6193829214da636ebde
2019-05-29 08:39:47 +02:00
James Zern
2b7214ab99 unicode,INIT_WARGV: add missing cast
CommandLineToArgvW() returns a LPWSTR*, storing to const LPWSTR* is
incorrect without a cast; fixes gcc -Wincompatible-pointer-types
and clang(-cl) -Wincompatible-pointer-types-discads-qualifiers warnings

Change-Id: Iad5b49c4862c7be68251272e50d3c751099559bc
2019-01-24 07:08:55 +00:00
James Zern
b6284d8247 img2webp: add help note about arguments from a file
this was added in:
94a8377b extract the command-line parsing helpers to example_util

and matches the help in webpmux

https://groups.google.com/a/webmproject.org/d/msg/webp-discuss/DJs-w_-Id6o/svFXs2CqBgAJ

BUG=webp:101

Change-Id: I2944d1fb1ed3030c356960be2a6c8de15a79311f
2018-10-26 06:16:56 +00:00
Yannis Guyon
9cf9841b5e libwebp: Unicode command tools on Windows
Define macros in examples/unicode.h to use Unicode argv
on Windows. Keep char everywhere on Unix since it handles
UTF-8 without any change.

Impact:
 - All fopen () and SHCreateStreamOnFile(),
 - All fprintf() printing file paths,
 - All strcmp() used with "-",
 - File path parsing,
 - Gif reading.

Concerned executables from examples/ and extras/:
  anim_diff, anim_dump, vwebp, vwebp_sdl,
  cwebp, dwebp, gif2webp, img2webp,
  webpmux, webpinfo, webp_quality, get_disto

When compiled on Windows with Unicode enabled, webpmux and
img2webp will not work when used with an argument file and
will print "Reading arguments from a file is a feature
unavailable with Unicode binaries."

BUG=webp:398

Change-Id: Ic55d222a3ce1a715f9c4cce57ecbe2705d5ce317
2018-10-17 13:19:40 +02:00
Yannis Guyon
b911fbc980 libwebp: Remove duplicate GIFDisplayError in anim_util
GIFDisplayError() is already defined exactly the same way
in gifdec. Remove it from anim_util.c and add dependency.

Change-Id: Iec01b41c44d0b61b3a279b8cd754d9917d64f804
2018-10-09 17:29:54 +02:00