Commit Graph

4736 Commits

Author SHA1 Message Date
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
James Zern
03a7a04892 webp-lossless-bitstream-spec: rm redundant statement
Within the 'Entropy image' subsection, its clear this is what is being
described in the following paragraphs. Remove 'as described below' from
the first sentence.

Bug: webp:611
Change-Id: I365d69c8f6963cd826849ebdd96e46206d38b55d
2023-06-08 11:22:10 -07:00
James Zern
c437c7aace webp-lossless-bitstream-spec: mv up prefix code group def
Move this to the top-level of the "Details" section as prefix codes are
discussed in both "Decoding and Building the Prefix Codes" and "Decoding
of Meta Prefix Codes"

Bug: webp:611
Change-Id: Ide2dfedf081d6c94122ac16ecded968ed760f90c
2023-06-08 11:22:10 -07:00
James Zern
e4f17a31a7 webp-lossless-bitstream-spec: fix section reference
in the Transformations section describing decoding of the transform
data followed by the image data. The section numbers were adjusted by 1
in:
337cf69f webp-lossless-bitstream-spec: mv Nomenclature after Intro

Bug: webp:611
Change-Id: I4eede0d068fabdef51a140a0268436ab6629e8bb
2023-06-08 11:22:10 -07:00
James Zern
e2ecd5e937 webp-lossless-bitstream-spec: clarify ABNF syntax
Give some examples of repetition and binary value notation to limit the
need to follow the ABNF reference.

Bug: webp:611
Change-Id: I5b5a7632f011e1523b4a528653fe3630afba3e3e
2023-06-08 11:22:10 -07:00
James Zern
8b55425a56 webp-lossless-bitstream-spec: refine pixel copy text
in 6.2.3 Decoding Entropy-Coded Image Data.

The copying of distance code pixels cause some confusion during the
AUTH48 portion of the RFC review process.

Bug: webp:611
Change-Id: I78f547ae10c95f180355a4c93ec6d48acdc09141
2023-06-08 11:22:10 -07:00
James Zern
29c9f2d410 webp-lossless-bitstream-spec: minor wording updates
Mostly grammatical and addition/subtraction of commas from the AUTH48
portion of the RFC review process.

The serial comma changes are based on the Chicago Manual of Style
(CMOS), 17th edition.

Bug: webp:611
Change-Id: I5ae2d1cc0196009dbf3a4c2195cc73c2ef809b49
2023-06-08 11:21:55 -07:00
skal
6b02f66015 treat FILTER_NONE as a regular Unfilter[] call
Removes the hard-coded memcpy() in alpha-decoding.

Change-Id: I1dfd98db206893d7715a79d05a1bd9272690471a
2023-06-07 15:42:16 +02:00
James Zern
7f75c91ced webp-container-spec: fix location of informative msg
preprocessing bits are informative, not the filtering bits.

since:
391f9db9 Ordering of description of bits in container spec

Change-Id: I1c0da963074ce9cf4d33a13b4b36c9421b3e3b9d
2023-06-06 22:09:41 -07:00
James Zern
f6499943c4 webp-container-spec: consistently quote FourCCs
from the AUTH48 portion of the RFC review process

Change-Id: I3aad4b32c95517735e98ffa0120228ee24be6a4d
2023-06-06 18:47:20 -07:00
James Zern
49918af32b webp-container-spec: minor wording updates
Mostly grammatical and addition/subtraction of commas from the AUTH48
portion of the RFC review process.

The serial comma changes are based on the Chicago Manual of Style
(CMOS), 17th edition.

Change-Id: Ic75abf2e53e09c8a849e28e9c40e16c127515287
2023-06-05 18:26:34 -07:00
James Zern
7f0a341943 update ChangeLog
Bug: webp:608
Change-Id: Ic2188807076eee4c311ea20b999ba66265df9003
2023-06-02 09:37:51 -07:00
James Zern
bab7efbe73 update NEWS
Bug: webp:608
Change-Id: I96245759d1f0d7ccb42de47e10e18677a509feaa
2023-06-02 09:31:46 -07:00
James Zern
7138bf8fc3 bump version to 1.3.1
libwebp{,decoder} - 1.3.1
libwebp libtool - 8.7.1
libwebpdecoder libtool - 4.7.1

mux - 1.3.1
libtool - 3.12.0

demux - 1.3.1
libtool - 2.13.0

sharpyuv - 0.2.1
libtool - 0.1.0

Bug: webp:608
Change-Id: Ia80c54651a45caa1baa595f66820a3c1091d05c4
2023-06-01 18:56:12 -07:00
James Zern
435b4ded42 update AUTHORS
Bug: webp:608
Change-Id: I84f5ea6a9de352cfb216198aee9f6fd204cd1c46
2023-06-01 17:13:22 -07:00
James Zern
473512298a update .mailmap
Bug: webp:608
Change-Id: Ib7d6fd5d9537770f7e4c6a3290a5071f617f9b91
2023-06-01 17:13:21 -07:00
Vincent Rabaud
46bc4fc9d9 Merge "Switch ExtraCost to ints and implement it in SSE." into main 2023-06-01 11:05:12 +00:00
Vincent Rabaud
828b4ce062 Switch ExtraCost to ints and implement it in SSE.
The histograms count the occurrences of len/dist in entropy images.
Those (at most (1<<14) by (1<<14)) are sub-sampled by at least
MIN_HUFFMAN_BITS == 2, hence at most 24 bits in a histogram value.
At most, we multiply by 19 (because the longest histogram is of
size 40 and we do 40>>1, cf code) for the bit cost. So it all fits
in 32 bits.

Change-Id: Ife24b035f54794851ff31f2fac07901f724c6d7f
2023-06-01 10:17:13 +02:00
James Zern
ff6c7f4e71 CONTRIBUTING.md: add C style / cmake-format notes
Change-Id: I54ad0e27341025a6385a736d5a79ab8b6556a6ec
2023-05-30 13:54:12 -07:00
James Zern
dd530437f6 add .cmake-format.py
Created with cmake-format 0.6.13 using:
--dump-config --max-subgroups-hwrap 3 --first-comment-is-literal true

Change-Id: Ica8ca81086dcf466d4ea9693ffcb4e31aa0af002
2023-05-30 13:54:06 -07:00
James Zern
adbe2cb17e cmake,cosmetics: apply cmake-format
using the defaults present in 0.6.13 and setting
--first-comment-is-literal to avoid reflowing the copyright block and
--max-subgroups-hwrap 3 (default is 2) to avoid making some short set()
statements multi-line.

Change-Id: I3d90c025b5b2bb353046f4da19b8e442a044b902
2023-05-30 12:14:28 -07:00
James Zern
15b365083d doc/webp-container-spec: rm future codec comment
From the compression standpoint the file format is fixed at this point.

Change-Id: I788fcf7106e4840bf2f9950dfb099a7bab88b3bf
2023-05-26 15:48:31 -07:00
James Zern
c369c4bf0b doc/webp-lossless-bitstream-spec: improve link text
Reference the section by number, rather than 'this section'. Fixes a
lint warning:

Style notice: Write unique, descriptive link text that makes sense
without the surrounding text. Don't use phrases such as this document,
this article, or click here.
https://developers.google.com/style/link-text?hl=en#write-link-text

Change-Id: Iab33e4980528dddb5eed4404d25a4a746705131a
2023-05-26 15:48:28 -07:00
James Zern
1de35f476b doc/webp-container-spec: don't use 'currently'
Provide examples of formats that WebP performs better than.

https://developers.google.com/style/timeless-documentation

Change-Id: I4ead60be349d8650478788484989bde9ff18f6b6
2023-05-26 15:48:26 -07:00
James Zern
bb06a16ed1 doc/webp-container-spec: prefer present tense
https://developers.google.com/style/tense

Change-Id: I0cd4e1431cddc340adf5634c07f0c60635b3d4f2
2023-05-26 15:48:23 -07:00
James Zern
9f38b71e01 doc/webp-lossless-bitstream-spec: prefer present tense
https://developers.google.com/style/tense

Change-Id: I1151ad0f585afd388920e6910a30aca4c2d0cc32
2023-05-26 15:48:17 -07:00
James Zern
7acb6b829a doc/webp-container-spec: avoid i.e. & e.g.
Using 'that is' or 'for example' is recommended:
https://developers.google.com/style/abbreviations#dont-use

Change-Id: I25b45f5b41687dfbd25a0fbea4978d6bc8e44ad2
2023-05-26 15:48:12 -07:00
James Zern
4967e7cd78 doc/webp-lossless-bitstream-spec: avoid i.e. & e.g.
Using 'that is' or 'for example' is recommended:
https://developers.google.com/style/abbreviations#dont-use

Change-Id: I5d0dad2ee7ae5ebaf73661d5d79a4a2f1dc1802a
2023-05-26 15:48:09 -07:00
Vincent Rabaud
e3366659a0 Merge "Do not find_package image libraries if not needed." into main 2023-05-26 20:55:09 +00:00
Jyrki Alakuijala
428588ef90 clarify single leaf node trees and use of canonical prefix coding
remove AMENDED-notes (the last functional spec change to match with the
implementation is from 2014, other amendments are clarifications)

Bug: webp:581
Change-Id: Ic47739be0fd5a975fd734d6813567ca615304f1d
2023-05-25 17:25:48 -07:00
Vincent Rabaud
709ec152df Do not find_package image libraries if not needed.
This can be tested by running:
cmake ../ -DWEBP_BUILD_ANIM_UTILS=OFF -DWEBP_BUILD_CWEBP=OFF -DWEBP_BUILD_DWEBP=OFF -DWEBP_BUILD_GIF2WEBP=OFF -DWEBP_BUILD_IMG2WEBP=OFF -DWEBP_BUILD_EXTRAS=OFF

Bug: webp:612

Change-Id: Ie06d8f0535676d6d31ff0047ff7a6c026e16118e
2023-05-26 00:14:05 +02:00
James Zern
8dd80ef814 fuzz_utils.h: lower kFuzzPxLimit w/ASan
prevents some timeouts when decoding large jpeg source images.

Change-Id: I5cb6a10cbf0658a71fa9f49fc7da4c8d3e70fa00
2023-05-24 19:39:38 -07:00
Vincent Rabaud
8f187b9f7f Clean message calls in CMake
Change-Id: If1a959d9b8d544c9f4671c84880b1d0d11d3d285
2023-05-24 19:39:26 -07:00
James Zern
cba300781f WebPConfig.cmake.in: use calculated include path
when setting WebP_INCLUDE_DIRS; this value is relative to the
WebPConfig.cmake install location (${PACKAGE_PREFIX_DIR}/include) and
allows the install to be relocated after creation.

See also:
https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html#example-generating-package-files

Bug: webp:610
Change-Id: If877625e96584a9808b0bba902e3f0b2a744aa60
Fixed: webp:610
2023-05-16 17:39:50 -07:00
James Zern
6cf9a76ae2 Merge "webp-lossless-bitstream-spec: remove use of 'dynamics'" into main 2023-05-16 22:00:51 +00:00
James Zern
740943b276 Merge "Specialize and optimize ITransform_SSE2 using do_two" into main 2023-05-16 19:57:48 +00:00
Yannis Guyon
2d547e24dc Compare kFuzzPxLimit to max_num_operations
To avoid timeouts caused by extreme rescaling such as
1x14339 -> 51712x1

Change-Id: I291d8e3b24155c190256411a506b7312abde8c45
2023-05-16 13:20:14 +02:00
Nozomi Isozaki
ac42dde1c5 Specialize and optimize ITransform_SSE2 using do_two
Change-Id: I976eb4a0cc4e669a02b55012d4aba1536f193781
2023-05-16 12:07:58 +09:00
James Zern
17e0ef1da5 webp-lossless-bitstream-spec: remove use of 'dynamics'
when bit width or precision are meant.

Change-Id: I89c2279e99b02c3e8a3bf39860364d2ce6d909c8
2023-05-12 15:10:30 -07:00
James Zern
ed27437160 neon.h,cosmetics: clear a couple lint warnings
Missing space after ,  [whitespace/comma] [3]

Change-Id: Ib8fc05c31cbef5318a752e98ab5106dad55d69e9
2023-05-02 17:32:14 -07:00