Commit Graph

2677 Commits

Author SHA1 Message Date
Vincent Rabaud
e79974cd6a Fix undefined signed shift.
Using the fix from SSE2.

Change-Id: Ie53d0163d97322da5a722c3e49f9d5f057ee1d91
2021-02-18 16:56:22 +01:00
Ilya Kurdyukov
a09a647241 SSE4.1 version of TransformColorInverse
Change-Id: I6ba5cb35917eef7a52152c4924eca205b4af7220
2021-02-18 12:42:39 +01:00
Skal
06c1e72e71 Code cleanup
* match param names

Change-Id: Ib75197a3c6bcc735049c6724dce6c240684108ae
2021-02-10 22:14:45 +01:00
James Zern
9c367bc602 WebPAnimDecoderNewInternal: validate bitstream before alloc
this avoids large allocations with corrupt files due to the canvas size

BUG=oss-fuzz:28658

Change-Id: Idd1957e5447a2dadaef1fadaf68820fcb29f045a
2021-02-05 13:01:27 -08:00
James Zern
47f64f6edd filters_sse2: import Chromium change
VerticalUnfilter_SSE2 has long been disabled due to a crash in an
Android emulator that hasn't reproduced elsewhere (crbug.com/654974).
this synchronizes the code for now to avoid needing to locally edit the
file on import.

Bug: 1141126
Change-Id: Ib61aeab93caaff1759606566b9e499eaac1576cf
2021-01-30 11:44:07 -08:00
James Zern
8599571935 disable CombinedShannonEntropy_SSE2 on x86
this function produces different results from the C code due to
use of double/float resulting in output differences when compared to
-noasm.

Bug: webp:499
Change-Id: Ia039b168c0a66da723fb434656657ba1948db8ae
2021-01-18 16:41:44 -08:00
James Zern
28c4982064 bump version to 1.2.0
libwebp{,decoder} - 1.2.0
libwebp libtool - 8.1.1
libwebpdecoder libtool - 4.1.1

mux - 1.2.0
libtool - 3.6.0

demux - 1.1.0
libtool - 2.7.0

Bug: webp:484
Change-Id: I458940f407515e0d95d20bbfd670ee29255c12eb
2020-12-23 19:54:29 -08:00
James Zern
7363dff25c webp/encode.h: restore WEBP_ENCODER_ABI_VERSION to v1.1.0
this was missed in:
f9b30586 fix ABI breakage introduced by 6a0ff358

Bug: webp:484
Change-Id: I64c9e5d1113209727f1ede467316549b4f2ad116
2020-12-23 19:50:03 -08:00
Pascal Massimino
2e7bed7925 WebPPicture: clarify the ownership of user-owned data.
It's explicitly safe (and recommended!) to plug external data into
the pic->y/u/v/argb fields. They are guaranteed to be preserved
by the encoding process if no conversion is needed.

Change-Id: I325ca41a6a834f7f028431c605dddef67e9542cc
2020-12-14 12:28:52 +01:00
James Zern
ae54553461 dsp.h: allow config.h to override MSVC SIMD autodetection
this fixes builds with cmake targeting visual studio that set
-DWEBP_ENABLE_SIMD=0

BUG=webp:478

Change-Id: I21b61b112c79ff9cbab9e4502a25d3f1fa096c8b
2020-12-03 10:22:04 -08:00
Vincent Rabaud
fc14fc038b Have C encoding predictors use decoding predictors.
libwebp.a in Release mode with no symbols size in bytes:
986430 -> 975114  (-1.1%)

Change-Id: Ia96192a6be2911779e359b72132bdba60b60a13d
2020-12-02 11:54:59 +01:00
Pascal Massimino
988b02abfd Merge "Couple of fixes to allow SIMD on Emscripten" 2020-11-20 08:18:41 +00:00
Ingvar Stepanyan
52273943c6 Couple of fixes to allow SIMD on Emscripten
- Add `-msimd128` to flags to actually enable WebAssembly SIMD
   when performing SIMD detection. It's currently required in
   addition to `-msse*` / `-mfpu=neon` flags which only perform
   translation of corresponding intrinsics to Wasm SIMD ones.
   See a discussion at emscripten-core/emscripten#12714 for
   automating this and making easier in the future.
 - Remove compilation branch that prevented definitions of
   `WEBP_USE_SSE` and `WEBP_USE_NEON` on Emscripten even when
   SIMD support was detected at compile-time.
 - Add an implementation of `VP8GetCPUInfo` for Emscripten which
   uses static `WEBP_USE_*` flags to determine if a corresponding
   SIMD instruction is supported. This is because Wasm doesn't
   have proper feature detection (yet) and requires making separate
   build for SIMD version anyway.

Change-Id: I77592081b91fd0e4cbc9242f5600ce905184f506
2020-11-18 21:51:41 +00:00
Pascal Massimino
8870ba7f06 Fix skia bug #10952
The offset *can* be negative, but the sanitizer reports strange
address behaviour when row_offset is unsigned size_t.

For safety, use int64_t instead (probably overkill. int32_t is probably ok).

Change-Id: I1bd424bfdb5447b3839f40679581d6bdea075320
2020-11-18 14:59:34 +01:00
Wan-Teh Chang
4b3c6953ef Detect if StoreFrame read more than anmf_payload_size bytes
After ParseAnimationFrame() calls StoreFrame(), check if StoreFrame() reads
more than anmf_payload_size bytes from dmux->mem_. Treat that as PARSE_ERROR.

Change-Id: I0d03885c19d32792af78de7bed1a944ca01f1dc6
2020-11-17 07:57:24 +01:00
James Zern
17fd4ba820 webp/decode.h,cosmetics: normalize 'flip' comment
have it match the other boolean options with 'if true...'

Change-Id: I5a3e7c17b35a21fc5146ecaf10e226486a2dc740
2020-10-29 16:00:44 -07:00
James Zern
411d3677ca remove some unreachable break statements
following a goto.
+ enable -Wunreachable-code-aggressive if available

Change-Id: I0312800d84d8984dbc51925600ed5d7d438413fd
2020-10-26 18:45:24 -07:00
James Zern
3700ffd7e1 WebPPictureHasTransparency: remove unreachable return
Change-Id: Ia8077918b5110fb7fc74f326d4d16b38d9ed1b38
2020-10-26 15:52:20 -07:00
James Zern
64425a0884 picture_tools_enc: fix windows build warning
with WebPReplaceTransparentPixels() function signature:

src\enc\picture_tools_enc.c(86): warning C4028: formal parameter 1
different from declaration

Change-Id: I0140d61b0dfebcbb4189707e8f2f4b1af802a4d7
2020-10-14 13:13:53 -07:00
James Zern
cf847cba58 use WEBP_DSP_INIT_FUNC for Init{GammaTables*,GetCoeffs}
this provides stronger synchronization when pthreads are available as
was done in 'd77bf512 add WEBP_DSP_INIT / WEBP_DSP_INIT_FUNC' for the
other init functions.

Change-Id: I2ffe4e24454d276c2411ece34dca38d23d4756d5
2020-09-11 11:57:51 -07:00
Skal
55a080e50a Add WebPReplaceTransparentPixels() in dsp
with SSE2 implementation.

(Extracted from side experiment)

Change-Id: I62d457fb6643645291cffd6d2d205d4a5ffa4517
2020-09-09 08:15:22 +02:00
Vincent Rabaud
cf2f88b38f Add palette and spatial for q >= 75 and -m 5
Change-Id: I12198b7eb82a4247e606bc60342595abf4d6eee0
2020-06-17 12:51:40 +02:00
Vincent Rabaud
f0110baec0 Add no-color cache configuration to the cruncher
Fix another pessimization found by the pingo image compressor.

Refactoring is necessary to make LZ77 computation
common to cache or no-cache analysis.
Slower by 1.7x instead of 2x

Change-Id: I396701ea6e88543dbfe9471eb552877f6c8ce1e3
2020-06-09 19:04:44 +02:00
Vincent Rabaud
749a8b99f7 Better estimate of the cache cost.
Change-Id: I171a8f80f1597bbdeb724957e789b947df3c2885
2020-06-05 16:07:58 +02:00
Vincent Rabaud
4f9f00ccf4 Use spatial predictors on top of palette no matter what.
This is fixing another inefficiency found by the pingo image optimizer.

Change-Id: Icecb0d39fcbd17b403667e8e2095c7705b1dd493
2020-06-04 18:03:57 +02:00
Vincent Rabaud
7658c68613 Add spatial prediction on top of palette in cruncher.
Change-Id: I3765ab628ef915eedf2e541a80c65ce9880dff36
2020-06-04 14:38:08 +02:00
Vincent Rabaud
e3c259a278 Fix integer overflow in EmitFancyRGB.
+ enhance the assert in WebPCopyPlane()

Change-Id: Id9b01d00a8dce6caf0d4721a6fbe8def40b8bb85
2020-05-05 14:57:19 +02:00
Pascal Massimino
f9b30586eb fix ABI breakage introduced by 6a0ff358
qmin / qmax are now using the pad[] spot at the end of the struct,
 and we don't need to bump the ABI major number.

Change-Id: I41adcaf1600b29a5a05c9fe380bfd977cf425124
2020-04-21 19:17:56 +00:00
Yannis Guyon
47309ef52d webp: WEBP_OFFSET_PTR()
Removes undefined behavior of offsetting NULL.

Change-Id: I7c83d0c913c631c091a5fb128f6d6b46b1d116db
2020-03-20 11:39:06 +01:00
James Zern
687ab00e6e DC{4,8,16}_NEON: replace vmovl w/vaddl
4/8/16 fewer instructions

Change-Id: I38fe08722e7b839e3f3e0bf4df7e0fa8e7a0138f
2020-03-05 09:41:14 -08:00
James Zern
1b92fe75a1 DC16_NEON,aarch64: use vaddlv
saves 3 instructions, neutral to mildly faster on a pixel 3a

Change-Id: I6ae57e8e38d4149167ea14e27cd2b32113b4f8e7
2020-03-04 23:12:20 -08:00
James Zern
53f3d8cf7e dec_neon,DC8_NEON: use vaddlv instead of movl+vaddv
one fewer instruction

Change-Id: I2f599fd6f9eebbb0cab81ae9855244fc401d4323
2020-03-04 15:46:38 -08:00
Yannis Guyon
27d082403c Fix integer overflow in WebPAnimDecoderGetNext()
Change-Id: Ic53263b6125ca125d5fb3791474eab78043fec18
2020-02-27 20:23:37 +01:00
Skal
a99078c1cf remove call to MBAnalyzeBestIntra4Mode for method >= 5
this was not giving a good alpha value, making the method 5/6 a little
blurrier than method 4 (!).

Change-Id: I69b9890dea21499c1af1753e87d9f7adf8b433de
2020-02-07 14:38:13 +01:00
Skal
71690b524e fix MSVC warning
"warning C4244: '=': conversion from 'const int' to 'float', possible loss of data"

Change-Id: Ie0769e50c19efd48332ffeadb026d4538fec9919
2020-01-30 09:25:26 +01: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
James Zern
30f0955160 bump version to 1.1.0
libwebp{,decoder} - 1.1.0
libwebp libtool - 8.0.1
libwebpdecoder libtool - 4.0.1

mux - 1.1.0
libtool - 3.5.0

demux - 1.1.0
libtool - 2.6.0 (no code change)

BUG=webp:441

Change-Id: I458940f407515e0d95d20bbfd670ee29255c12eb
2019-12-18 00:06:50 -08:00
James Zern
22cbae33e5 idec_dec: fix 0 offset of NULL pointer
in RemapMemBuffer() and AppendToMemBuffer()

BUG=chromium:1028716,chromium:1027136

Change-Id: Ibc321d233b6207be3cb5cef4d9e8a60498e32457
2019-12-14 17:14:30 -08:00
James Zern
290dd0b426 muxread: fix 0 offset of NULL pointer
BUG=chromium:1028620,chromium:1027409

Change-Id: I2b5527a223a03161afbf39c297c4646954a91fbc
2019-12-14 12:57:39 -08:00
James Zern
0df474ac9e Merge "lossless_(enc_|)sse2: avoid offsetting a NULL pointer" 2019-12-13 22:04:44 +00:00
James Zern
c6b75a1966 lossless_(enc_|)sse2: avoid offsetting a NULL pointer
PredictorSub0_SSE2 doesn't use 'upper' (neither does
VP8LPredictorsSub_C[0]); just pass NULL when dealing with trailing
pixels to avoid undefined behavior when offsetting a NULL pointer

BUG=chromium:1026858,oss-fuzz:19430

Change-Id: I08be8899ed2e34f26aaee34defe68dbd0fe216d3
2019-12-13 18:33:10 +00:00
Skal
295e5e3801 fix UBSAN warning
"applying non-zero offset 2044 to null pointer"

  Fixes chromium bug #19447

Change-Id: I530ae27dc64e92ed0018f36469264c448329e042
2019-12-13 13:26:16 +00:00
James Zern
e2575e05cb DC8_NEON,aarch64: use vaddv
results in one fewer instruction for both DC8uv_NEON and
DC8uvNoLeft_NEON

Change-Id: Ia4e6f4dbc070079cdc2496a698bd4b34198ea164
2019-12-06 09:38:48 -08:00
Cheng Yi
b0e09e346f dec_neon: Fix build failure under some toolchains
some toolchains may implement vcreate_u64 as an assignment to a vector
causing a type mismatch:
 invalid conversion between vector type 'uint64x1_t' (vector of 1
'uint64_t' value) and integer type 'unsigned int' of different size
  const uint64x1_t LKJI____ = vcreate_u64(L | (K << 8) | (J << 16) | (I << 24));
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change-Id: I5c7b0076ad66d4b3fcdcb7ee9f59bbaa6f19b783
2019-12-06 00:06:44 -08:00
Oliver Wolff
cf0e903c89 dsp/lossless: Fix non gcc ARM builds
The workaround for GCC ARM must not be applied when another toolchain
(like MSVC) is used for the build.

Change-Id: I11ec4558902063ccb085d3f435e24b3a60739dd5
2019-11-27 15:05:08 +01:00
Vincent Rabaud
bb7bc40b6d Remove ubsan errors.
'upper' could be NULL and it would be increased.
But that is for predictor zero that does not use 'upper'.

Change-Id: Icd4ae6792cc55ea021b4f828c3dbdb5f03e120d8
2019-11-06 14:08:14 +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
Nico Weber
af650c0bd2 Fix a Wxor-used-as-pow false positive
Since people seem to write "2 ^ X" hoping that it means "1 << X", clang
recently added a warning for this pattern.

It incorrectly fires on this file. To suppress it, restructure the code
to be less clever. (Alternatively we could use "xor" instead of "^" or
write "0x2" instead of "2" but both seem worse.)

No intended behavior change.

Bug: chromium:995200
Change-Id: I64744345be5f5a8cd1f4aaeaf0982da239b378a7
2019-09-04 23:35:46 -07:00
Skal
0e48d889eb bugfix: last alpha rows were incorrectly decoded
sometimes, the last rows of the alpha plane contain more than NUM_ARGB_CACHE_ROWS
rows to process. But ExtractAlphaRows() was repeatedly calling ApplyInverseTransforms()
without updating the dec->last_row_ field, which is the starting row used as starting
point.

Fix would consist of either updating correctly dec->last_row_ before calling
ApplyInverseTransforms(). Or pass the starting row explicitly, which is simpler.

BUG=webp:439

Change-Id: Id99f2c28662d02b2b866cb79e666050be9d59e04
2019-08-30 14:13:28 +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