Commit Graph

2769 Commits

Author SHA1 Message Date
Maryla
93c5437115 sharpyuv: add support for 10/12/16 bit rgb and 10/12 bit yuv.
10bit+ input is truncated to 10bits for now.

Change-Id: I7ac00ca54c623d94c76ccd8954418e11095997d2
2022-05-23 20:48:44 +02:00
Vincent Rabaud
30453ea4e6 Add an internal WebPValidatePicture.
Change-Id: Ia01bd3975f7bd0d47eb0a1764807baed16f0d268
2022-05-16 17:37:20 +02:00
Vincent Rabaud
6c43219a5f Some renamings for consistency.
- pic->picture in public header
- match implementation to declaration in PictureImport, WebPPictureRescale, WebpBlendAlpha

Change-Id: Ibf3771af22d671bba6fd657684add618c6f32978
2022-05-16 17:33:49 +02:00
Vincent Rabaud
6c45cef7ff Make sure the stride has a minimum value in the importer.
Bug: webp:569
Change-Id: Ia48d064dbb10e7179ae3da04ca8d769d1c447276
2022-05-10 10:18:46 +02:00
Maryla
0c8b0e67a4 sharpyuv: cleanup/cosmetic changes
Remove unused constants.
Use ALL_CAPS for defines and kCamelCase for static const values.
Change some defines into static constants if they are not used in array sizes.

Change-Id: I036b0f99215fd0414a33f099bd6b809ff8ee4541
2022-05-09 15:10:14 +02:00
James Zern
dc3841e077 {histogram,predictor}_enc: quiet int -> float warnings
after:
a19a25bb Replace doubles by floats in lossless misc cost estimations.

Change-Id: Idc5888b40ce5b591b72c6e51a188a9ab8c5d9823
2022-04-20 10:10:27 -07:00
Vincent Rabaud
a19a25bb03 Replace doubles by floats in lossless misc cost estimations.
Doubles are slower and use more RAM for no benefit.

Change-Id: I05b313576f9b33388c7c39d7fed8de84170c3753
2022-04-17 21:07:54 +02:00
brianpl@google.com
779597d443 demux,IsValidExtendedFormat: remove unused variable
quiets -Wunused-but-set-variable

frame_count has been unused in this function since:
ab714b8a demux, Frame: remove is_fragment_ field

Change-Id: Ie6afda915c6b82736e05e7490eba0165c3dd37e4
2022-04-08 15:28:05 -07:00
Maryla Ustarroz-Calonge
40e8aa57f8 Merge "libsharpyuv: add colorspace utilities" into main 2022-04-08 09:06:23 +00:00
Maryla
01a05de1a7 libsharpyuv: add colorspace utilities
Change-Id: I620c8593dc81f39e747de5ed354332adb7278bed
2022-04-08 10:07:22 +02:00
James Zern
2de4b05a56 Merge changes Id9890a60,I376d81e6,I1c958838 into main
* changes:
  GetBackwardReferences: fail on alloc error
  BackwardReferencesHashChainDistanceOnly: fix segfault on OOM
  VP8LEncodeStream: fix segfault on OOM
2022-04-06 20:04:25 +00:00
Pascal Massimino
e8e77b9c47 Merge changes I479bc487,I39864691,I5d486c2c,I186d13be into main
* changes:
  mux{edit,internal}: fix leaks on error
  ExUtilInitCommandLineArguments: fix leak on error
  anim_util: fix leaks on error
  gif2webp: fix segfault on OOM
2022-04-05 05:51:53 +00:00
James Zern
10c5084842 normalize label indent
1 space is most common in the source; this fixes some mixed cases within
lossless files, likely from clang-format

Change-Id: I504206d5bf418781d4131ee73570ecee4e0a69a1
2022-04-04 12:47:41 -07:00
James Zern
89f774e61d mux{edit,internal}: fix leaks on error
several calls to ChunkSetHead() were unchecked, causing the chunk to
leak should the call fail due to OOM

Tested:
for i in `seq 1 1125`; do
  export MALLOC_FAIL_AT=$i
  ./examples/gif2webp gif_file
  ./examples/gif2webp -mixed gif_file
done
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: I479bc487f61b493e5ce033872d353007055c172a
2022-04-04 11:26:25 -07:00
James Zern
e3cfafaf71 GetBackwardReferences: fail on alloc error
previously failures in the call to
VP8LBackwardReferencesTraceBackwards() would be ignored which, though it
wouldn't result in a crash, would produce non-deterministic output

Change-Id: Id9890a60883c3270ec75e968506d46eea32b76d4
2022-04-04 11:24:06 -07:00
James Zern
a828a59b49 BackwardReferencesHashChainDistanceOnly: fix segfault on OOM
change CostManager to calloc to avoid frees on undefined pointer
values in CostManagerClear() should the cost_model allocation succeed,
but the cost_manager allocation fail

since:
v0.5.0-93-g3e023c17 Speed-up BackwardReferencesHashChainDistanceOnly.

Tested:
for i in `seq 1 639`; do
  export MALLOC_FAIL_AT=$i
  ./examples/cwebp -m 6 -q 100 -lossless jpeg_file
done

Bug: webp:565
Change-Id: I376d81e6f41eb73529053e9e30c142b4b4f6b45b
2022-04-04 11:23:39 -07:00
James Zern
fe153fae98 VP8LEncodeStream: fix segfault on OOM
initialize bw_side before calling EncoderAnalyze() & EncoderInit() which
may fail; previously this would cause a free of an invalid pointer in
VP8LBitWriterWipeOut().

since at least:
v0.6.0-120-gf8c2ac15 Multi-thread the lossless cruncher.

Tested:
for i in `seq 1 639`; do
  export MALLOC_FAIL_AT=$i
  ./examples/cwebp -m 6 -q 100 -lossless jpeg_file
done

Bug: webp:565
Change-Id: I1c95883834b6e4b13aee890568ce3bad0f4266f0
2022-04-04 11:21:30 -07:00
Maryla
841960b670 Make libsharpyuv self-contained by removing dependency on cpu.c
Change-Id: I2edac1afa38bfddf2a91e7829e38425bd3519feb
2022-03-30 15:04:35 +02:00
Maryla
7a68afaac5 Let SharpArgbToYuv caller pass in an RGB>YUV conversion matrix.
Change-Id: I4ed2dfc00ce63361abd49c693f31f307e0b0262f
2022-03-24 16:37:47 +01:00
James Zern
5ccbd6ed8c vp8l_dec.c,cosmetics: fix a few typos
Change-Id: Ia2906883e7d19bd96f355b4ade98d29ac2efe8cc
2022-03-14 10:15:31 -07:00
Maryla Ustarroz-Calonge
d0d2292e1a Merge "Make libwebp depend on libsharpyuv." into main 2022-03-07 09:34:37 +00:00
James Zern
03d1219055 alpha_processing_neon.c: fix 0x01... typo
one instance was overlong leading to a int64->uint32 conversion warning

Change-Id: I56d5ab75d89960c79293f62cd489d7ab519bbc34
2022-03-04 15:26:21 -08:00
Maryla
d55d447c9a Make libwebp depend on libsharpyuv.
Change-Id: I6d8ebfe1f855024fc0694b1aa584f71fa27b83ae
2022-03-04 11:35:03 +01:00
Vincent Rabaud
e4cbcdd2b5 Fix lossless encoding for MIPS.
Bug: webp:558
Change-Id: I3d3ddb64ed26a8d8ff5664664c5f20f6eadfeb4f
2022-03-01 14:01:49 +01:00
James Zern
924e7ca654 alpha_processing_neon.c: fix Dispatch/ExtractAlpha_NEON
the trailing width % 8 bytes would clear the upper bytes of
alpha_mask as they're done one at a time

since:
49d0280d NEON: implement several alpha-processing functions

Change-Id: Iff76c0af3094597285a6aa6ed032b345f9856aae
2022-02-28 13:57:23 -08:00
Maryla
29cc95ce4c Basic version of libsharpyuv in libwebp, in C.
It's self contained apart from a dependency on src/webp/types.h and src/dsp/cpu.h
For now it's only set up as an internal library, not an installable one.
Webp doesn't depend on it yet, the code is only duplicated.

Change-Id: I752799894f9d4105d0d296ddebd9f9641181a1ec
2022-02-18 14:52:44 +00:00
James Zern
b9d2f9cd3b quant_enc.c: use WEBP_RESTRICT qualifier
results in code layout changes, a couple fewer instructions; some of the
smaller functions were unaffected as they were inlined, but are updated
for consistency. this mostly affects VP8Decimate(), ReconstructIntra16()
and ReconstructUV().

Change-Id: Icc2582278987a66ad1110bab683d1e0c21e6591a
2022-02-10 11:07:18 -08:00
Yannis Guyon
ec178f2c7f Add progress hook granularity in lossless
A WebPPicture instance is necessary to call WebPReportProgress() which
sets WebPPicture::error_code so as well use WebPEncodingSetError() to
record errors too, instead of functions returning a WebPEncodingError.
However there must be one WebPPicture instance per thread, with error
codes merged at sync time. A mutex could simplify that but it is not
the objective of this change.

https://groups.google.com/a/webmproject.org/g/webp-discuss/c/yOiP8APubgc/m/vCTvxl6ODgAJ

Change-Id: Ia1a8f9d1199202e1c88484ce719b0180a80447ce
2022-02-07 11:00:09 +01:00
Yannis Guyon
26139c7398 Rename MAX_COST to MAX_BIT_COST in histogram_enc.c
To differentiate it with the one in vp8i_enc.h

Change-Id: If4ecc40246cb1c6e42a2ae77328966c4069d441c
2022-02-03 09:57:30 +01:00
James Zern
6f49654024 libwebp-1.2.2
- 1/11/2022: version 1.2.2
   This is a binary compatible release.
   * webpmux: add "-set bgcolor A,R,G,B"
   * add ARM64 NEON support for MSVC builds (#539)
   * fix duplicate include error in Xcode when using multiple XCFrameworks in a
     project (#542)
   * doc updates and bug fixes (#538, #544, #548, #550)
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEaw5rcJdt4wPt8vYB+cPWvbgjK10FAmHoy90ACgkQ+cPWvbgj
 K10DLg/7BS8mjKMJGkH1HD3PT12K54H9a9BReD2lPMfUTmclLbLktwG9/cn8pHG1
 xTTJp7HQWr5d0VEkv2X2XZYIAdAb+6FICdFDp+J26jqErZU62LLK2Gq0gWs+bRNE
 36u8Q0qyJdt2BAdDgfUEBHZeAz+uevp1u5YVCg05u3FcBejLEGx6Bc+fvIrk5Al9
 C1zjbP7kFRVE/6OEGFc/jLHGfzTHhfgIW0GDUIKav/x9/cjkqjcC34Uwgz6/y4+K
 C6HAzfHfgiKUzDpwTYC9HkpulKhuIfMF4wTytaIfyoYXMScbKRWq989NW6a7ctGv
 1+nOh//37RRf2gXnGFW2eXGD1vFdXwLSm04AXzpXIE1o9jQzII3akw6vQX4gGE0d
 n3X0GUjpvAkgPH1P1/qF5qZSKuBSLlfYYAbdZNNoUvKCviF/zOj2A0T19727OdnV
 EtXvL6Yd9B7E+Uu15FyoCeJYiGwFFEJSTC1fhMnGPgiLa0JN/7QD4Q9RFg/O45Q3
 e3DvYv7x6sg83MJipWNh7BTXhcX9Q0zNXmySAwuM53g+hhtkVliojZV4+7vzdO/0
 /aVfNAErAtPNUPofDUOIj9qrbx+PvLCeiI5lhFWs1sBWtSdU7XNnewzzYJKJAexp
 HMbwpVM0KnMbX7D3VzT8mo11M5KYQGbzIjaM1DzqiaobLSVmVs8=
 =HlsB
 -----END PGP SIGNATURE-----

Merge tag 'v1.2.2'

libwebp-1.2.2

- 1/11/2022: version 1.2.2
  This is a binary compatible release.
  * webpmux: add "-set bgcolor A,R,G,B"
  * add ARM64 NEON support for MSVC builds (#539)
  * fix duplicate include error in Xcode when using multiple XCFrameworks in a
    project (#542)
  * doc updates and bug fixes (#538, #544, #548, #550)

* tag 'v1.2.2':
  update ChangeLog
  libwebp: Fix VP8EncTokenLoop() progress
  BMP enc: fix the transparency case
  libwebp: do not destroy jpeg codec twice on error
  update ChangeLog
  update NEWS
  man/img2webp.1: update date
  Reword img2webp synopsis command line
  anim_decode: fix alpha blending with big-endian
  webpinfo: fix fourcc comparison w/big-endian
  update ChangeLog
  update NEWS
  bump version to 1.2.2
  update AUTHORS

Bug: webp:541, b/202302177
Change-Id: Iae875b6ec3084157837cc774c94088ca72e8dd91
2022-01-20 10:17:37 -08:00
James Zern
4074acf873 dsp.h: bump msvc arm64 version requirement to 16.6
there was a bug in 16.4 causing compile failures with vtbl4_u8():

src\dsp\lossless_neon.c(105): error C2143: syntax error: missing ')'
before '{'
src\dsp\lossless_neon.c(105): error C2168: 'neon_tbl2_q8': too few
actual parameters for intrinsic function

https://developercommunity.visualstudio.com/t/cannot-compile-arm64-neon-vtbl4-u8-function-in-c-f/859331

Change-Id: I87c21850b3c597aa5cb41a8105b81e2135a9f890
2022-01-19 21:49:59 -08:00
Yannis Guyon
6db8248c01 libwebp: Fix VP8EncTokenLoop() progress
Encoding the image found in the user bug report below would result in
a progress rising up to 173% because of the extra 20% caused by each
of the 4 extra lossy passes. It happened at methods 3 to 6.

https://groups.google.com/a/webmproject.org/g/webp-discuss/c/yOiP8APubgc/m/FP3r5X2rDAAJ

Change-Id: I95318d0dc4df546044eb926c786c04bb7f915cbe
(cherry picked from commit db25f1b4ed)
2022-01-19 18:07:42 +00:00
Yannis Guyon
db25f1b4ed libwebp: Fix VP8EncTokenLoop() progress
Encoding the image found in the user bug report below would result in
a progress rising up to 173% because of the extra 20% caused by each
of the 4 extra lossy passes. It happened at methods 3 to 6.

https://groups.google.com/a/webmproject.org/g/webp-discuss/c/yOiP8APubgc/m/FP3r5X2rDAAJ

Change-Id: I95318d0dc4df546044eb926c786c04bb7f915cbe
2022-01-18 21:12:11 +00:00
James Zern
f084244d9f anim_decode: fix alpha blending with big-endian
images are decoded in RGBA/BGRA, but represented as uint32_t during the
blend process; this fixes the channel extraction

Bug: webp:548
Change-Id: Ie74aa43d8f87d3552d5afc0abba466335f5d1617
(cherry picked from commit e4886716d3)
2021-12-23 14:49:14 +00:00
James Zern
e4886716d3 anim_decode: fix alpha blending with big-endian
images are decoded in RGBA/BGRA, but represented as uint32_t during the
blend process; this fixes the channel extraction

Bug: webp:548
Change-Id: Ie74aa43d8f87d3552d5afc0abba466335f5d1617
2021-12-22 17:03:58 -08:00
James Zern
973390b618 bump version to 1.2.2
libwebp{,decoder} - 1.2.2
libwebp libtool - 8.3.1
libwebpdecoder libtool - 4.3.1

mux - 1.2.2
libtool - 3.8.0

demux - 1.2.2
libtool - 2.9.0

Bug: webp:541
Change-Id: Ia9adda28f0320714335156552d0f5b563e1babb6
2021-12-14 19:58:29 -08:00
jzern@google.com
02ca04c348 add missing USE_{MSA,NEON} checks in headers
msa_macro.h
neon.h

allows the headers to be built / analyzed under different target
configurations

Change-Id: Ibbcfada210b54988aa5279674d53af8e21fd4a97
2021-12-14 22:21:57 +00: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
James Zern
8f5cb4c18e update rfc links
to https://datatracker.ietf.org/doc/html/... the http tools.ietf.org
links redirect here sometimes, in other cases they 404.

Bug: webp:544
Change-Id: I900972070d6c5659c45a86a89e78b870f42fe5bc
2021-11-17 11:03:35 -08:00
Pascal Massimino
8ea81561d2 change VP8LPredictorFunc signature to avoid reading 'left'
... when it's not available. Even if the value was discarded and
never used, some msan config were complaining about reading it
and passing it around.

Change-Id: Iab8d24676c5bb58e607a829121e36c2862da397c
2021-11-05 16:22:31 +01:00
James Zern
e23cd5481c dsp.h: enable NEON w/VS2019+ ARM64 targets
Visual Studio added ARM64 support, but requires arm64_neon.h to be
included rather than arm_neon.h. Visual Studio 2019 addressed this so
we'll start with that version and leave a local adapter include for a
follow up.

Bug: webp:539
Change-Id: If975c029dafffba99210b3bb2d670035a83e8105
2021-09-13 19:56:19 -07:00
Vincent Rabaud
1a8f0d45d3 Have a hard-coded value for memset in TrellisQuantizeBlock.
Change-Id: I1b842bb0cfec9e8559d0f11b3db8fa1bc1c9692f
2021-08-30 18:50:11 +02:00
Vincent Rabaud
934801604e Speed up TrellisQuantizeBlock
- only initialize variable when needed
- perform first loop outside the for loop
- perform computation only if know we are not already worse
- not adding base_score every time

Change-Id: I2cb8231fcaec1113b5902ed61b685f0ae3c78823
2021-08-30 17:07:42 +02:00
James Zern
53b6f76209 fix indent
after:
277d3074 Fix size_t overflow in  WebPRescalerInit

Change-Id: I9adf7f01f28ddd54305512762e2ed28713282966
(cherry picked from commit d2caaba435)
2021-07-28 20:22:18 +00:00
James Zern
d250f01d95 dsp/*: use WEBP_HAVE_* to determine Init availability
after:
  ece18e55 dsp.h: respect --disable-sse2/sse4.1/neon
WEBP_USE_* will be set when a module is targeting a particular
instruction set, e.g., sse4.1, and not overridden if WEBP_HAVE_SSE41 is
set, as previously this would ignore the case where the instruction set
was disabled via config.h and the HAVE macro was unset.

dsp.h not ensures WEBP_HAVE_* are set when WEBP_USE_* to cover cases
where the files are built without config.h.

Change-Id: Ia1c2dcf4100cc1081d968acb6e085e2a1768ece6
(cherry picked from commit 1fe3162541)
2021-07-26 20:44:58 +00:00
James Zern
b2bc809346 bump version to 1.2.1
libwebp{,decoder} - 1.2.1
libwebp libtool - 8.2.1
libwebpdecoder libtool - 4.2.1

mux - 1.2.1
libtool - 3.7.0

demux - 1.2.1
libtool - 2.8.0

Bug: webp:521
Change-Id: I098e3e9df698baa275dea85315b9136e565e9971
2021-07-20 18:12:24 -07:00
James Zern
ece18e5520 dsp.h: respect --disable-sse2/sse4.1/neon
previously this would be overridden if the instruction set was enabled
via -msse4.1, __aarch64__, etc.

Change-Id: I51e87a7da7589c6093d260b848ab41d89ec7b990
2021-07-17 12:14:38 -07:00
James Zern
8f5946634e alpha_processing: fix visual studio warnings
similar to '* const', __restrict needs to be included in the
declaration to avoid warnings like:
src\dsp\alpha_processing.c(429): warning C4028: formal parameter 1
different from declaration

this change also moves WEBP_RESTRICT to dsp.h to avoid a circular
dependency between it and utils.h which already includes dsp.h

Change-Id: Ib070d358a372e76fae4be5445ab288940b9baac0
2021-07-13 23:41:45 +00:00
James Zern
a1e5dae0f0 alpha_processing*: use WEBP_RESTRICT qualifier
this helps both auto-vectorization in the C code and the optimized code
generation

Change-Id: Ide570d6be45125ffef7248bdc40e9eb08f00e832
2021-07-07 15:39:21 -07:00
Pascal Massimino
e1a8d4f3fe Merge "bit_reader_inl_utils: uniformly apply WEBP_RESTRICT" into main 2021-06-28 23:19:21 +00:00