Commit Graph

4675 Commits

Author SHA1 Message Date
James Zern
67a7cc2b07 webp-lossless-bitstream-spec: fix code blocks
+ change "> 19" to "greater than 19" as it's referred to in prose

Bug: webp:611
Change-Id: I644d7d39f9c4a19050ff0256114873057aee95ef
2023-07-26 09:42:00 -07:00
James Zern
cd436142f6 webp-lossless-bitstream-spec: block -> chunk
when referring to the RIFF chunk size; this is more consistent with
other documentation.

Bug: webp:611
Change-Id: Icf05491ee79f5c48fab0b4935da397b4e4e45a71
2023-07-25 22:10:06 -07:00
James Zern
3cb66f64b0 webp-lossless-bitstream-spec: add some missing commas
The serial comma change is based on the Chicago Manual of Style
(CMOS), 17th edition.

Bug: webp:611
Change-Id: Ic02e6652662608414c16e0fead2912781a47633d
2023-07-25 22:09:59 -07:00
James Zern
56471a53cf webp-lossless-bitstream-spec: normalize item text in 5.1
Makes references to earlier sections consistent. Based on RFC editor
update.

Bug: webp:611
Change-Id: I63b1125810a3d8afa957d392e98c68a632749d76
2023-07-25 22:08:51 -07:00
James Zern
af7fbfd2d9 vp8l_dec,ReadTransform: improve error status reporting
ExpandColorMap() can fail due to a memory allocation failure.

Found by Nallocfuzz (https://github.com/catenacyber/nallocfuzz).

Change-Id: I868c5db2fee18e876f4aa3b63e744d7297d1a91b
2023-07-21 16:30:50 -07:00
James Zern
7d8e0896e9 vp8l_dec: add VP8LSetError()
similar to VP8SetError(); the first error set takes precedence

Change-Id: Id00eb134cac328f72142a2ec0909e72768a6be0e
2023-07-21 16:30:49 -07:00
James Zern
a71ce1cf74 animencoder_fuzzer: fix error check w/Nallocfuzz
WebPAnimEncoderAdd() may fail due to muxer errors that are reported as
booleans. When running under the nallocfuzz engine, ignore all failures.

Found by Nallocfuzz (https://github.com/catenacyber/nallocfuzz).

Change-Id: I36589545d20ac30a67f7e09264146db085dee6ca
2023-07-21 16:30:48 -07:00
James Zern
e94b36d66d webp-lossless-bitstream-spec: relocate details from 5.1
Move the details given for meta prefix codes and the transforms from
"5.1. Roles of Image Data" to their corresponding sections.

Bug: webp:611
Change-Id: I750a3f45956d0a3928a22113180a2590ac1a36db
2023-07-21 15:50:38 -07:00
James Zern
84628e5611 webp-lossless-bitstream-spec: clarify image width changes
After processing the Color Indexing Transform the image width is
subsampled by the transform's width_bits.

Bug: webp:611
Change-Id: If8d2d47dbe05e5c8085fb3fb4c1b63552be9028b
2023-07-20 17:54:20 -07:00
James Zern
ee72299796 alpha_dec: add missing VP8SetError()
in AllocateAlphaPlane() and VP8DecompressAlphaRows().

Found by Nallocfuzz (https://github.com/catenacyber/nallocfuzz).

Change-Id: I39eb305abfe9f4d7915cce5d91e72917f482bc20
2023-07-18 16:25:29 -07:00
James Zern
0081693d61 enc_dec_fuzzer: use WebPDecode()
rather than WebPDecodeRGBA(). This allows finer grained error detection
and avoids an abort() when running under the nallocfuzz engine.

Change-Id: I8ff37f2fe7e1c8b39bd4a8bfe7b26ac41149ba42
2023-07-18 16:24:11 -07:00
James Zern
0fcb311cfc enc_dec_fuzzer: fix WebPEncode/pic.error_code check
pic.error_code may be set to VP8_ENC_ERROR_BAD_WRITE if the writer fails
due to a memory allocation failure.

Found by Nallocfuzz (https://github.com/catenacyber/nallocfuzz).

Change-Id: I912c9e5f9a37b78832c52d9ab6f0710967fbadac
2023-07-18 16:24:09 -07:00
James Zern
982c177c8a webp-lossless-bitstream-spec: fix struct member refs
remove trailing '_' to match the definition of ColorTransformElement

Bug: webp:611
Change-Id: I741213b389fc88473c72c64090a4733f51d87925
2023-07-14 15:13:27 -07:00
James Zern
56cf562570 webp-lossless-bitstream-spec: use RFC 7405 for ABNF
This allows for case sensitive literals.

Bug: webp:611
Change-Id: I5258c67ab12c48593d433449328fd85d461a05d2
2023-07-14 15:13:27 -07:00
James Zern
6c6b3fd317 webp-lossless-bitstream-spec,cosmetics: delete blank lines
This normalizes the spacing between sections and quiets some lint
warnings.

Bug: webp:611
Change-Id: Ic36eb08d55a566def74f746e2ec225c67ff8aecf
2023-07-14 15:12:35 -07:00
James Zern
29b9eb1517 Merge changes Id56ca4fd,I662bd1d7 into main
* changes:
  webp-lossless-bitstream-spec: add validity note for max_symbol
  webp-lossless-bitstream-spec: fix max_symbol definition
2023-07-13 20:43:51 +00:00
James Zern
47c0af8daf ReadHuffmanCodes: rm max_alphabet_size calc
This is unnecessary as green will have the largest value; the sizes are
currently: 256 + 24 + color_cache_size, 256, 40, in that order.

Change-Id: Ib9ce3292285a7b9c6089557b68a87184b68d17a5
2023-07-12 12:04:57 -07:00
James Zern
b92deba353 animencoder_fuzzer: no WebPAnimEncoderAssemble check w/nallocfuzz
This function may fail due to allocation failures. Use the
NALLOC_FUZZ_VERSION environment variable to detect the engine. This was
added in:
9c9a9883cc

Change-Id: Ia5b6fd9458ffa1f810152a10ab49a48c75d17687
2023-07-10 15:10:00 -07:00
James Zern
6be9bf8bae animencoder_fuzzer: fix leak on alloc failure
Change-Id: Id626145a336fc33c4a4158719957f3c96db156c8
2023-07-10 15:09:17 -07:00
James Zern
5c965e55dd vp8l_dec,cosmetics: add some /*param=*/ comments
Change-Id: I8912a5d8a8f550517e644e1af6b468b49505247f
2023-07-07 19:57:47 -07:00
James Zern
e4fc2f78c7 webp-lossless-bitstream-spec: add validity note for max_symbol
Bug: webp:611
Change-Id: Id56ca4fd0ad3cfc17c9c971281ccfb8ce7eaa2f4
2023-07-07 15:54:34 -07:00
James Zern
71916726b6 webp-lossless-bitstream-spec: fix max_symbol definition
If ReadBits(0) == 0, the value of max_symbol is set to the alphabet size
for each symbol type.

See vp8l_dec.c, ReadHuffmanCode(), which passes alphabet_size to
ReadHuffmanCodeLengths() as num_symbols, and ReadHuffmanCodeLengths()
then sets max_symbol to that.

Bug: webp:611
Change-Id: I662bd1d7f372e7f2e9c71cc86f87aefd02f36647
2023-07-07 15:54:34 -07:00
Vincent Rabaud
eac3bd5c53 Have the palette code be in its own file.
Change-Id: I099a342effedd9f451c94d00a14aead27079e6cc
2023-07-06 22:09:24 +02:00
Vincent Rabaud
e2c85878f6 Add an initializer for the SharpYuvOptions struct.
Change-Id: I36510bc361b040d3d3e7d261ab67b24ffc3013a6
2023-07-01 21:15:37 +02:00
James Zern
4222b00679 libwebp-1.3.1
- 6/23/2023: version 1.3.1
   This is a binary compatible release.
   * security fixes for lossless encoder (#603, chromium: #1420107, #1455619,
     CVE-2023-1999)
   * improve error reporting through WebPPicture error codes
   * fix upsampling for RGB565 and RGBA4444 in NEON builds
   * img2webp: add -sharp_yuv & -near_lossless
   * Windows builds:
     - fix compatibility with clang-cl (#607)
     - improve Arm64 performance with cl.exe
     - add Arm64EC support
   * fix webp_js with emcc >= 3.1.27 (stack size change, #614)
   * CMake fixes (#592, #610, #612)
   * further updates to the container and lossless bitstream docs (#581, #611)
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEaw5rcJdt4wPt8vYB+cPWvbgjK10FAmSc53oACgkQ+cPWvbgj
 K120Fg//f0JkK3oKnO8P4B5XSAK26/5845xBPU8D06UuUqhct+mjfF5kM1CFxxex
 49W4rT7RJCpgGlwmRFFgRB3a9j7cW4C+Kt5MAfM++vudVrxnpnX6o3rdVDQ60PEZ
 C4T5u2jio/HuZAkPWYwwmIAz1vfqTjYpi0D12hn7yoBoketGcISlMuTgmwfjyQKg
 bn3JcjcjKtERfXSH36aCtnGAXJdf0Ok2WJtwS4kAcZiMByi5wf0AdEK0pnhmE3Y6
 YFPc0/RM50RXITnsDxmLZVRqpsAYr4l3RZvHwDDWVFMELWBsGWNF/kgzWlZ3/KjO
 4CUPE+810P4oVGJuRZ8++0hMSD0L1qh17awElpqLoBlDXfS1fEIw5QodbmoJzi0H
 mhiLH7fIZlpjoZyWuwNCzlkhykRLO4cEIaxxq28p5eoC70LXsv77rWqomfAja/6/
 88BQz6wrxHr0k4MmdOa+G8B5sMOBRVXXeW4bP1XCVGUfk8FN2rz0vlhbHk8sx/6/
 jqW19Bk3t2QnUZschBi1GKHKa0KkefFhTezTm/CV4fPmT50Z4k/+TTjJ6snSxAAX
 oYabJDtVARLgPxOcN64Hbsy1t5L9pWGLTfwbYBTVipX4lmofL9SHhgyg6oYVnZd5
 qbCVdqpYOOrbXXT/AByOuzo3tuaLMd8Ytas0I5/HHnI6QCTthg0=
 =/atT
 -----END PGP SIGNATURE-----

Merge tag 'v1.3.1'

libwebp-1.3.1

- 6/23/2023: version 1.3.1
  This is a binary compatible release.
  * security fixes for lossless encoder (#603, chromium: #1420107, #1455619,
    CVE-2023-1999)
  * improve error reporting through WebPPicture error codes
  * fix upsampling for RGB565 and RGBA4444 in NEON builds
  * img2webp: add -sharp_yuv & -near_lossless
  * Windows builds:
    - fix compatibility with clang-cl (#607)
    - improve Arm64 performance with cl.exe
    - add Arm64EC support
  * fix webp_js with emcc >= 3.1.27 (stack size change, #614)
  * CMake fixes (#592, #610, #612)
  * further updates to the container and lossless bitstream docs (#581, #611)

* tag 'v1.3.1':
  update ChangeLog
  update NEWS
  enc/*: normalize WebPEncodingSetError() calls
  enc/*: add missing WebPEncodingSetError() calls
  EncodeAlphaInternal: add missing error check
  vp8l_enc,WriteImage: add missing error check
  muxread,MuxImageParse: add missing error checks
  cmake,emscripten: explicitly set stack size
  WebPDecodeYUV: check u/v/stride/uv_stride ptrs
  Call png_get_channels() to see if image has alpha
  update ChangeLog
  update NEWS
  bump version to 1.3.1
  update AUTHORS
  update .mailmap

Bug: webp:608
Bug: b/281615350
Change-Id: Ic3e1956c92fef0ae22040bbc3e81b297c65008af
2023-06-28 19:34:13 -07:00
Vincent Rabaud
25d94f473b Implement more transfer functions in libsharpyuv
This is inspired by https://github.com/AOMediaCodec/libavif/pull/444/files

Change-Id: I98fae61696b3b8bbc1b5941e7950810d3ac3d588
2023-06-28 11:43:37 +02:00
James Zern
2153a6797c Merge changes Id0300937,I5dba5ccf,I57bb68e0,I2dba7b4e,I172aca36, ... into main
* changes:
  webp-lossless-bitstream-spec: add PredictorTransformOutput
  webp-lossless-bitstream-spec: fix RIFF-header ABNF
  webp-lossless-bitstream-spec: split LZ77 Backward Ref section
  webp-lossless-bitstream-spec: split Meta Prefix Codes section
  webp-lossless-bitstream-spec: note transform order
  webp-lossless-bitstream-spec: update transformations text
2023-06-27 21:56:43 +00:00
James Zern
4298e9765c webp-lossless-bitstream-spec: add PredictorTransformOutput
Describe the addition of the residual value to the predicted value.

Bug: webp:611
Change-Id: Id0300937eeebbafec3b2cd15376c56418c98a3bf
2023-06-26 12:51:36 -07:00
James Zern
cd7e02bece webp-lossless-bitstream-spec: fix RIFF-header ABNF
0x2f is a part of the image header, not RIFF header

Bug: webp:611
Change-Id: I5dba5ccfebeb25586723a1f3e00eebc317806928
2023-06-26 12:51:36 -07:00
James Zern
6c3845f9e0 webp-lossless-bitstream-spec: split LZ77 Backward Ref section
Make Distance Mapping its section for ease of reference.

Bug: webp:611
Change-Id: I57bb68e0fcf4d23ce0013f327adce93c6377be3a
2023-06-26 12:51:36 -07:00
James Zern
7f1b6799db webp-lossless-bitstream-spec: split Meta Prefix Codes section
Make Entropy Image and Interpretation of Meta Prefix Codes their own
section for ease of reference.

Bug: webp:611
Change-Id: I2dba7b4efd02d8bb250810ebff42ac1687262804
2023-06-26 12:51:36 -07:00
James Zern
7b634d8f0c webp-lossless-bitstream-spec: note transform order
transforms are applied in reverse bitstream order.

Bug: webp:611
Change-Id: I172aca36bbd5c3358a71b0acb49c5704ceee63d7
2023-06-26 12:51:36 -07:00
James Zern
6d6d4915ce webp-lossless-bitstream-spec: update transformations text
follow up to:
29c9f2d4 webp-lossless-bitstream-spec: minor wording updates

Universally use 'transform' over 'transformation'. The doc generally
uses 'transform' to talk about the individual transforms themselves as
well as their related data.

Bug: webp:611
Change-Id: I097701873bbc440bd399ab5440a914a14f7c62f6
2023-06-26 12:50:39 -07:00
James Zern
fd7bb21c0c update ChangeLog
Bug: webp:608
Change-Id: Id619a5e39a71d1372fd2209774f4f57d87712aa7
2023-06-23 11:52:38 -07:00
James Zern
e1adea50ed update NEWS
Bug: webp:608
Change-Id: I8c09742daa8502e7a1fdc626afa3b747e03569bf
2023-06-23 10:16:35 -07:00
James Zern
6b1c722a5b lossless_common.h,cosmetics: fix a typo
Change-Id: I22d2f96fa1fd2e3c9f059c26996fb11d998159a9
2023-06-22 18:31:36 -07:00
James Zern
08d60d6006 webp-lossless-bitstream-spec: split code length section
Make Simple / Normal Code Length Code their own section for ease of
reference.

Bug: webp:611
Change-Id: I1e6ed50d98f9258cacb163d2059716b5356e8b6f
2023-06-21 19:20:12 -07:00
James Zern
7a12afcc54 webp-lossless-bitstream-spec: rm unused anchor
The last use of #decoding-the-code-lengths was removed in:
86f94ee0 Update lossless spec with Huffman codes.

Also remove the redundant section header associated with it.

Bug: webp:611
Change-Id: I7f6bb1a1b75255324f185f4591313d9e6d49d1e9
2023-06-21 19:16:39 -07:00
James Zern
4339332038 enc/*: normalize WebPEncodingSetError() calls
return WebPEncodingSetError() directly where possible (it returns 0 /
failure for convenience).

Change-Id: I89a937778886c15ecbbe078af5b4c8c89ef0f9af
2023-06-21 16:43:00 -07:00
James Zern
287fdefe95 enc/*: add missing WebPEncodingSetError() calls
Users of the encoder (including anim_encode.c) and areas of the encoder
itself rely on the status returned via WebPPicture.

Change-Id: Id786176b8ac3b2329d1e41b9dacbb8dcc5d822e4
2023-06-21 16:43:00 -07:00
James Zern
c3bd7cff2e EncodeAlphaInternal: add missing error check
VP8LBitWriterFinish() may cause the VP8LBitWriter's buffer to be grown.
If that allocation fails, VP8LBitWriterNumBytes() will return a size
larger than the current allocation resulting in a heap overwrite of the
missing bytes.

==13==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x61900005b880 at pc 0x00000049ffc1 bp 0x7fff144f5b40 sp 0x7fff144f5310
READ of size 1028 at 0x61900005b880 thread T0
    #0 0x49ffc0 in __asan_memcpy
    #1 0x695861 in VP8BitWriterAppend src/utils/bit_writer_utils.c:186:3
    #2 0x65acf9 in EncodeAlphaInternal src/enc/alpha_enc.c:169:14

Found by Nallocfuzz (https://github.com/catenacyber/nallocfuzz).

This is the same issue that was fixed in the non-alpha lossless path in:
d49cfbb3 vp8l_enc,WriteImage: add missing error check

Bug: chromium:1455619
Change-Id: I6bd10de213707d3d6b7ce3d0d2b3942af45d317f
2023-06-21 16:43:00 -07:00
James Zern
14a9dbfba0 webp-lossless-bitstream-spec: refine single node text
Remove the ambiguous 'should' which in other contexts might result in
questions as to whether it is a SHOULD or a MUST.

Change-Id: I9b396187ebde5ea5a0dbaf42daee6acf541258cd
2023-06-20 19:30:20 -07:00
Vincent Rabaud
64819c7cf3 Implement ExtractGreen_SSE2
Change-Id: I74f50e0c01603a640aa8cf7c9658d477e696ea8a
2023-06-19 13:31:46 +02:00
James Zern
d49cfbb348 vp8l_enc,WriteImage: add missing error check
VP8LBitWriterFinish() may cause the VP8LBitWriter's buffer to be grown.
If that allocation fails, VP8LBitWriterNumBytes() will return a size
larger than the current allocation resulting in a heap overwrite of the
missing bytes.

==3531848==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x61d000000880 at pc 0x556eddfa1007 bp 0x7ffe434c7a90 sp 0x7ffe434c7260
READ of size 2052 at 0x61d000000880 thread T0
    #0 0x556eddfa1006 in __asan_memcpy
    #1 0x556eddfeeccf in WebPMemoryWrite src/enc/picture_enc.c:220:5
    #2 0x556ede0f9f87 in WriteImage src/enc/vp8l_enc.c:1454:8

Found by Nallocfuzz (https://github.com/catenacyber/nallocfuzz).

Change-Id: Ib1c9454c2c51849b0ba58c5347e6bd5b02a12fbe
2023-06-15 15:09:10 -07:00
James Zern
2e5a9ec3b6 muxread,MuxImageParse: add missing error checks
This prevents leaks should an allocation fail.

Spotted by Philippe Antoine (p dot antoine at catenacyber dot fr)
and https://github.com/catenacyber/nallocfuzz.

Change-Id: I07a8a475a282b18bf2f9015cc5b1120772babd48
2023-06-14 13:53:59 -07:00
James Zern
ebb6f949f4 cmake,emscripten: explicitly set stack size
The default was changed from 5MB to 64KB in 3.1.27 [1] causing image
decodes to fail. This restores the old default. In testing, 1536KB was
enough for the sample image, 1024KB was not.

[1]: https://github.com/emscripten-core/emscripten/blob/main/ChangeLog.md#3127---112922

Bug: webp:614
Change-Id: I1ff7afc72fa49d88d2efe88d2a04dfadbea3b1a5
Fixed: webp:614
Test: emcc 3.1.18 & 3.1.41
2023-06-13 21:47:52 -07:00
James Zern
59a2b1f9e3 WebPDecodeYUV: check u/v/stride/uv_stride ptrs
The buffers are made mandatory to match WebPDecodeYUVInto(), though this
conflicts with WebPIDecGetYUVA().

spotted by Oliver Kunz (okunz at google dot com)

Change-Id: Ic4740c53b75da6b93d4f3462303fb9be0ebfbd48
2023-06-13 17:39:45 -07: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
fe80fbbd6b webp-container-spec: add some missing commas
The serial comma change is based on the Chicago Manual of Style
(CMOS), 17th edition.

Change-Id: I642d6eb87492bb671869b25415c59b96b749c798
2023-06-12 22:03:01 -07:00
Pascal Massimino
e8ed317609 Merge "treat FILTER_NONE as a regular Unfilter[] call" into main 2023-06-12 14:19:04 +00:00