Commit Graph

85 Commits

Author SHA1 Message Date
Vincent Rabaud
a1ca153d51 Fix hidden myerr in my_error_exit
Change-Id: I0e3660eff2f6a20446b6fcd2925312757fda424c
2024-07-11 15:59:57 +02:00
Vincent Rabaud
4838611f91 Disable msg_code use in fuzzing mode
bug:oss-fuzz:70102
bug:oss-fuzz:70112
Change-Id: I519c991c784bccb4bbaec622281f81015ab479a4
2024-07-10 22:55:21 +02:00
James Zern
79e7968ad0 jpegdec: add a hint for EOF/READ errors
`jpegtran -copy all` may be able to process the file into something
libjpeg can read.

Bug: webp:562
Change-Id: I27a8a7a841c1d8d54f47c7c52e289d9d8c549220
2024-05-01 12:32:47 -07:00
James Zern
3cada4cef4 ImgIoUtilReadFile: check ftell() return
This avoids attempting to allocate 0 bytes if the call fails. (An
additional byte is added to the result to allow a '\0' to be appended.)

Bug: chromium:334120888
Change-Id: Ifcb8ff7744c567cbd08051aa04cc66acf936078d
2024-04-19 12:50:01 -07:00
Vincent Rabaud
433c7dca11 Fix static analyzer warnings.
Change-Id: I45f0db2310b1188809963af93240e3d438f807b8
2023-09-14 22:43:45 +02:00
Wan-Teh Chang
8e965ccb0f Call png_get_channels() to see if image has alpha
After the png_read_update_info() call, call png_get_channels() to find
out if the image has alpha.

Change-Id: I6fa709418744b4de90d10ff96eaeefe454ffa290
2023-06-13 17:35:31 -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
fad0ece7ed pnmdec.c: use snprintf instead of sprintf
this is consistent with the rest of the example code

Change-Id: Id4c02e16be84fbe21ddc74c9049d8cbda2d875a8
2022-11-15 17:10:26 -08:00
James Zern
0957fd69ee tiffdec: add grayscale support
the file is always decoded to RGBA, so just the samples_per_px needed an
update

Bug: webp:563
Change-Id: I95d95c3b9e45dc8ecb2223f89f4ba791f0b21e8b
2022-03-31 21:43:29 -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
Yannis Guyon
66b3ce239e Fix bad overflow check in ReadTIFF()
See ImgIoUtilCheckSizeArgumentsOverflow() usage at line 199.

Change-Id: Iecad9278446a2f189e287e08512d26a794270a5a
2022-02-15 17:51:14 +01:00
Yannis Guyon
6e8a4126f2 libwebp: do not destroy jpeg codec twice on error
WebPPictureImportRGB() can fail on memory allocation. In this case,
jpeg_destroy_decompress() was already called, so do not go to Error.
Free metadata as an error is returned.

Change-Id: I045b072090e9063d3ad10369ad18b0f08bdffe9f
2022-01-13 14:10:43 +00:00
James Zern
faf219684c Merge "BMP enc: fix the transparency case" into main 2022-01-12 23:24:23 +00:00
Pascal Massimino
480cd51de6 BMP enc: fix the transparency case
When transparency is present, it's not enough to just write 32bpp samples.
One need to use the full BITMAPV3INFOHEADER syntax and specify the
masks for BGRA.

 see https://en.wikipedia.org/wiki/BMP_file_format#Pixel_storage

Also remove the height-flip trick and write samples bottom-to-top instead.

Change-Id: If5d92c11453b96764b5bfbf19e9678e632bc911f
2022-01-12 07:48:01 +01:00
James Zern
b6f756e82b update http links
- prefer https

- metadataworkinggroup.org/com seem to be offline; the web archive link
  was obtained from exiftool: https://exiftool.org/TagNames/MWG.html

- fix kramdown link, rubyforge has been gone a long time

- fix png/zlib links

Bug: webp:544
Bug: b/202302177
Change-Id: Id69de4553e7baf00393f12a2c1acb262443a1a93
2021-11-23 10:13:40 -08:00
Vincent Rabaud
45eaacc939 Convert deprecated uint32 to uint32_t.
Change-Id: I057296a7ea90c3eeb9eaf251e08352a8491a591b
2021-08-30 16:06:53 +02:00
James Zern
a89a3230c9 wicdec: support alpha from WebP WIC decoder
the container check may not be strictly necessary now that the alpha
check has matured and the library will detect usable alpha, but it's
safer to fix this case first before making larger changes.

Bug: webp:533
Change-Id: I2e1ba42156970d579a52bd183707a037e65fd900
2021-07-16 12:19:33 -07: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
7d416ff085 webpdec,cosmetics: match error text to function call
WebPINewDecoder -> WebPIDecode

Change-Id: I5c17486ce2598a5dda687d7bc579daf7630c2133
2021-04-17 15:13:43 -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
James Zern
b27ea8525a wicdec,icc: treat unsupported op as non-fatal
ICC extraction via GetColorContexts may fail due to the operation not
being supported with e.g., bitmaps.

Bug: webp:506
Change-Id: I587220e688ac90d77c84af21c9e7bc8bf178f3aa
2021-02-18 10:36:13 -08:00
James Zern
2690782292 pngdec: check version before using png_get_chunk_malloc_max
png_get_chunk_malloc_max / png_set_chunk_malloc_max were added in 1.4.1.

Bug: webp:505, webp:497
Change-Id: Id4e0643a7734563fec7779f7943ec760da8d276d
2021-02-10 13:41:54 -08:00
Skal
289757fe1e TiffDec: enforce stricter mem/dimension limit on tiles
Tile can be even larger than image dimensions.

Change-Id: I80518e815bb11d7a07c8189d0493b3cc60e29815
2021-01-12 10:57:27 +01:00
Pascal Massimino
8696147da4 pngdec: raise memory limit if needed
Some PNG input contain chunks larger than libpng's default
memory-alloc limit (8M).
Raise this limit reasonably if it looks like the input bitstream
is larger than libpng's default limit.

BUG=webp:497

Change-Id: I2c9fbed727424042444b82cbf15e0781cefb38dc
2021-01-08 08:48:39 +01:00
James Zern
26faf7706b wicdec: fail with animated images
this matches the behavior of other decoders (WebP) in imageio.

Bug: webp:479
Change-Id: Ifcae0f38d7eebde31cd294070a6dd1f80cb30043
2020-11-19 19:49:11 -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
Pascal Massimino
6cf504d018 PNM decoding: handle max_value != 255
also add support for PAM's GRAYSCALE_ALPHA tuple (with depth = 2)

BUG=webp:449

Change-Id: I0fe4825cd1d5487b9f7af332c7d3d56c1b35c3fb
2020-01-06 23:48:40 +01:00
Yannis Guyon
17850e74ce libwebp: Remove char-subscripts warning in pnmdec.c
Change-Id: I7a771e17fca0ba8a49a816b48cc477ad7a03a435
2019-10-16 17:58:30 +02:00
Yannis Guyon
853ea3d846 imageio/tiff: Return error before allocating bad tile size
Change-Id: I5820b808e25beeda0fd4e755b62da0caabe48d8d
2019-10-15 10:44:17 +02:00
Yannis Guyon
24d2ccb4e0 webp: Fix imageio ReadPNM() TUPLTYPE
It was colliding with "DEPTH" header value so ignoring "TUPLTYPE"
except for unhandled types.

Change-Id: I3c69cb6a81c5369e64b59d50567cd7fbc1756d57
2019-07-30 09:22:29 +02:00
Yannis Guyon
01ac46bae6 libwebp: Display "libjpeg error:" in imageio/jpegdec
For clearer error message in cwebp.

BUG=webp:420

Change-Id: Ie60b53c4c6b77a96f81f3b5cd285b7c7003a1308
2019-03-08 19:09:41 +01: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
Pascal Massimino
123d330699 TIFF decoder: remove unused KINV definition
+ some #undef

Change-Id: Ib8b8357ad3a6458ca421a59d9ad625656dd54afe
2018-10-14 08:24:43 +02:00
James Zern
637141bc7c pngdec: fix build w/libpng < 1.4.x
after:
bc5092b1 pngdec: set memory functions

png_alloc_size_t was added in 1.4 use png_size_t in earlier versions

Change-Id: If65ac1c501e2d497b1be480095bf21f06ea7026a
2018-09-28 17:42:27 -07:00
James Zern
bc5092b162 pngdec: set memory functions
use png_create_read_struct_2 to set a malloc function allowing the code
to fail on large allocations while fuzzing

Change-Id: Iaca1b93ecc6570067708f3ae2db07fbca74386ee
2018-09-28 00:35:47 -07:00
James Zern
5d8985de47 configure,*am,cosmetics: s/WANT_/BUILD_/
'BUILD_' is more common across the build files

Change-Id: Id302dba2e9e567c186a9da1da0fba44517e85d07
2018-06-02 10:41:49 -07:00
Pascal Massimino
641cedccd3 imagedec: support metadata reading for WebP image decoding
Needs to link imagedec.a to demux/libwebpdemux.a

Change-Id: Id8f4068718b0e4a1e84607bccd5af5419120c231
2018-03-28 16:36:37 -07:00
James Zern
b2db361ca6 image_enc,WebPWritePNG: move locals after setjmp
this quiets a -Wclobbered warning on const has_alpha under gcc-7 and
brings the variables closer to their first use.

Change-Id: I8a24f275b7ff34a94d47b576bcf276dbedac2121
2018-03-08 22:58:11 -08:00
Pascal Massimino
3005237a5d ReadWebP: fix for big-endian
Change-Id: I36b3c12ccf02eb5dad350c460387c0528fff8df3
2018-02-14 23:39:26 -08:00
James Zern
f4dd92565e remove WEBP_EXPERIMENTAL_FEATURES
the webp bitstream is considered stable at this point

Change-Id: I4b13f9ed4c45f63785474b097e96cb7bf651be7b
2018-02-09 10:25:11 -08:00
skal
fc09e6e252 PNM decoder: prevent unsupported depth=2 PAM case.
Change-Id: I8476818908d71498dd80b07dc255aa008ffd16f5
2018-02-07 18:24:01 -08:00
Pascal Massimino
78318b30e5 PNG decoder: handle gAMA chunk
Apply gamma correction to the decoded RGB values.

This handles corner cases where the PNG file doesn't have
a standard 1/2.2 gamma value.

BUG=webp:369

Change-Id: I9907b6e2c458002de7c26d0b9e416278cca33990
2018-01-05 10:56:52 -08:00
Pascal Massimino
a7f93fe32d webpmux: allow reading argument from a file
if a single text file name is supplied as argument
(e.g.: 'webpmux my_long_list_of_frames.txt'), the command
line arguments are actually parsed from this file.
Tokenizer will remove space, tabs, LF, CR, returns, etc.

+ changed ImgIoUtilReadFile() to return a null-terminated
data, for convenience.

+ misc clean-up in the code

BUG=webp:355

Change-Id: I76796305641d660933de5881763d723006712fa9
---
2017-12-01 01:42:22 -08:00
Pascal Massimino
ae568ce7c4 ImgIoUtilReadFile: fix file leak upon error
the file was not closed in case of malloc error.

Change-Id: I5f8b22d7d0da6d2c8c2dd245cdd57994e3ddea3a
2017-11-29 21:30:22 +01:00
James Zern
6ba98764e8 webpdec: correct alloc size check w/use_argb
the allocation is always 4 x width regardless of the presence of alpha

Change-Id: I154bd7e5c0190d37abd669e17e18911ebb7e066c
2017-10-26 23:17:11 -07: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
James Zern
f324b7f9ba cosmetics: normalize fn proto & decl param names
BUG=webp:355

Change-Id: If020eb3b064cdb11853d1fa47058acae34752ce3
2017-08-26 14:17:31 -07:00
James Zern
20a94186ce pnmdec,PAM: validate depth before calculating bytes_per_px
fixes potential integer overflow with corrupt files.

Change-Id: I03e27fb14ad559dcd47e2704afdb6be9a163e02e
2017-08-19 13:56:06 -07:00
James Zern
86fc4dd9f4 webpdec: use ImgIoUtilCheckSizeArgumentsOverflow
...prior to allocating a Picture. this is consistent with the other
readers and allows the allocation size to be limited at compile time

BUG=webp:355

Change-Id: Ib8e027ef863489b1e0f9e2a1403c3836da3ef48d
2017-08-08 07:02:02 -07:00
James Zern
08ea9ecde3 imageio: add ability restrict max image size
WEBP_MAX_IMAGE_SIZE can be defined to control this limit.
Set it to 1.5GiB w/--config=asan-fuzzer to avoid OOM with large resolution
images. This limit leaves some headroom over the single image max of 2^14 *
2^14 * 4

BUG=webp:355

Change-Id: I4d48eb0a063638297a842582e0229dfd5a54df5f
2017-08-08 07:02:02 -07:00