From abd6664feece530a44d2822d44fb64ba74a67475 Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 14 Dec 2021 19:52:01 -0800 Subject: [PATCH 01/14] update AUTHORS Bug: webp:541 Change-Id: I270b606a16d72dd5012253d932905375692b8eb7 --- .mailmap | 1 + AUTHORS | 1 + 2 files changed, 2 insertions(+) diff --git a/.mailmap b/.mailmap index f3560c55..6ac2883a 100644 --- a/.mailmap +++ b/.mailmap @@ -12,3 +12,4 @@ Tamar Levy Hui Su James Zern +Roberto Alanis diff --git a/AUTHORS b/AUTHORS index 30abde03..8307c209 100644 --- a/AUTHORS +++ b/AUTHORS @@ -32,6 +32,7 @@ Contributors: - Pascal Massimino (pascal dot massimino at gmail dot com) - Paweł Hajdan, Jr (phajdan dot jr at chromium dot org) - Pierre Joye (pierre dot php at gmail dot com) +- Roberto Alanis (alanisbaez at google dot com) - Sam Clegg (sbc at chromium dot org) - Scott Hancher (seh at google dot com) - Scott LaVarnway (slavarnway at google dot com) From 973390b6189f3c0e8162dd1130fb641044e7cbf1 Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 14 Dec 2021 19:55:12 -0800 Subject: [PATCH 02/14] 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 --- README | 2 +- README.mux | 2 +- configure.ac | 2 +- extras/extras.c | 2 +- src/Makefile.am | 4 ++-- src/dec/vp8i_dec.h | 2 +- src/demux/Makefile.am | 2 +- src/demux/demux.c | 2 +- src/demux/libwebpdemux.rc | 8 ++++---- src/enc/vp8i_enc.h | 2 +- src/libwebp.rc | 8 ++++---- src/libwebpdecoder.rc | 8 ++++---- src/mux/Makefile.am | 2 +- src/mux/libwebpmux.rc | 8 ++++---- src/mux/muxi.h | 2 +- 15 files changed, 28 insertions(+), 28 deletions(-) diff --git a/README b/README index 33012a75..63e1dc2c 100644 --- a/README +++ b/README @@ -4,7 +4,7 @@ \__\__/\____/\_____/__/ ____ ___ / _/ / \ \ / _ \/ _/ / \_/ / / \ \ __/ \__ - \____/____/\_____/_____/____/v1.2.1 + \____/____/\_____/_____/____/v1.2.2 Description: ============ diff --git a/README.mux b/README.mux index 30c7ae86..099d8e06 100644 --- a/README.mux +++ b/README.mux @@ -1,7 +1,7 @@  __ __ ____ ____ ____ __ __ _ __ __ / \\/ \/ _ \/ _ \/ _ \/ \ \/ \___/_ / _\ \ / __/ _ \ __/ / / (_/ /__ - \__\__/\_____/_____/__/ \__//_/\_____/__/___/v1.2.1 + \__\__/\_____/_____/__/ \__//_/\_____/__/___/v1.2.2 Description: diff --git a/configure.ac b/configure.ac index 183842cb..1047ec29 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([libwebp], [1.2.1], +AC_INIT([libwebp], [1.2.2], [https://bugs.chromium.org/p/webp],, [https://developers.google.com/speed/webp]) AC_CANONICAL_HOST diff --git a/extras/extras.c b/extras/extras.c index a66979a4..bdac133e 100644 --- a/extras/extras.c +++ b/extras/extras.c @@ -19,7 +19,7 @@ #define XTRA_MAJ_VERSION 1 #define XTRA_MIN_VERSION 2 -#define XTRA_REV_VERSION 1 +#define XTRA_REV_VERSION 2 //------------------------------------------------------------------------------ diff --git a/src/Makefile.am b/src/Makefile.am index b4a6d3a7..e5b2341d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -36,7 +36,7 @@ libwebp_la_LIBADD += utils/libwebputils.la # other than the ones listed on the command line, i.e., after linking, it will # not have unresolved symbols. Some platforms (Windows among them) require all # symbols in shared libraries to be resolved at library creation. -libwebp_la_LDFLAGS = -no-undefined -version-info 8:2:1 +libwebp_la_LDFLAGS = -no-undefined -version-info 8:3:1 libwebpincludedir = $(includedir)/webp pkgconfig_DATA = libwebp.pc @@ -48,7 +48,7 @@ if BUILD_LIBWEBPDECODER libwebpdecoder_la_LIBADD += dsp/libwebpdspdecode.la libwebpdecoder_la_LIBADD += utils/libwebputilsdecode.la - libwebpdecoder_la_LDFLAGS = -no-undefined -version-info 4:2:1 + libwebpdecoder_la_LDFLAGS = -no-undefined -version-info 4:3:1 pkgconfig_DATA += libwebpdecoder.pc endif diff --git a/src/dec/vp8i_dec.h b/src/dec/vp8i_dec.h index 20526a87..9af22f8c 100644 --- a/src/dec/vp8i_dec.h +++ b/src/dec/vp8i_dec.h @@ -32,7 +32,7 @@ extern "C" { // version numbers #define DEC_MAJ_VERSION 1 #define DEC_MIN_VERSION 2 -#define DEC_REV_VERSION 1 +#define DEC_REV_VERSION 2 // YUV-cache parameters. Cache is 32-bytes wide (= one cacheline). // Constraints are: We need to store one 16x16 block of luma samples (y), diff --git a/src/demux/Makefile.am b/src/demux/Makefile.am index 89d86c1d..750517c7 100644 --- a/src/demux/Makefile.am +++ b/src/demux/Makefile.am @@ -13,6 +13,6 @@ noinst_HEADERS = noinst_HEADERS += ../webp/format_constants.h libwebpdemux_la_LIBADD = ../libwebp.la -libwebpdemux_la_LDFLAGS = -no-undefined -version-info 2:8:0 +libwebpdemux_la_LDFLAGS = -no-undefined -version-info 2:9:0 libwebpdemuxincludedir = $(includedir)/webp pkgconfig_DATA = libwebpdemux.pc diff --git a/src/demux/demux.c b/src/demux/demux.c index 547a7725..f04a2b84 100644 --- a/src/demux/demux.c +++ b/src/demux/demux.c @@ -25,7 +25,7 @@ #define DMUX_MAJ_VERSION 1 #define DMUX_MIN_VERSION 2 -#define DMUX_REV_VERSION 1 +#define DMUX_REV_VERSION 2 typedef struct { size_t start_; // start location of the data diff --git a/src/demux/libwebpdemux.rc b/src/demux/libwebpdemux.rc index 8dce3492..62f7e6eb 100644 --- a/src/demux/libwebpdemux.rc +++ b/src/demux/libwebpdemux.rc @@ -6,8 +6,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,2,1 - PRODUCTVERSION 1,0,2,1 + FILEVERSION 1,0,2,2 + PRODUCTVERSION 1,0,2,2 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -24,12 +24,12 @@ BEGIN BEGIN VALUE "CompanyName", "Google, Inc." VALUE "FileDescription", "libwebpdemux DLL" - VALUE "FileVersion", "1.2.1" + VALUE "FileVersion", "1.2.2" VALUE "InternalName", "libwebpdemux.dll" VALUE "LegalCopyright", "Copyright (C) 2021" VALUE "OriginalFilename", "libwebpdemux.dll" VALUE "ProductName", "WebP Image Demuxer" - VALUE "ProductVersion", "1.2.1" + VALUE "ProductVersion", "1.2.2" END END BLOCK "VarFileInfo" diff --git a/src/enc/vp8i_enc.h b/src/enc/vp8i_enc.h index 67e95093..b4bba08f 100644 --- a/src/enc/vp8i_enc.h +++ b/src/enc/vp8i_enc.h @@ -32,7 +32,7 @@ extern "C" { // version numbers #define ENC_MAJ_VERSION 1 #define ENC_MIN_VERSION 2 -#define ENC_REV_VERSION 1 +#define ENC_REV_VERSION 2 enum { MAX_LF_LEVELS = 64, // Maximum loop filter level MAX_VARIABLE_LEVEL = 67, // last (inclusive) level with variable cost diff --git a/src/libwebp.rc b/src/libwebp.rc index 2deeaca4..629c651a 100644 --- a/src/libwebp.rc +++ b/src/libwebp.rc @@ -6,8 +6,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,2,1 - PRODUCTVERSION 1,0,2,1 + FILEVERSION 1,0,2,2 + PRODUCTVERSION 1,0,2,2 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -24,12 +24,12 @@ BEGIN BEGIN VALUE "CompanyName", "Google, Inc." VALUE "FileDescription", "libwebp DLL" - VALUE "FileVersion", "1.2.1" + VALUE "FileVersion", "1.2.2" VALUE "InternalName", "libwebp.dll" VALUE "LegalCopyright", "Copyright (C) 2021" VALUE "OriginalFilename", "libwebp.dll" VALUE "ProductName", "WebP Image Codec" - VALUE "ProductVersion", "1.2.1" + VALUE "ProductVersion", "1.2.2" END END BLOCK "VarFileInfo" diff --git a/src/libwebpdecoder.rc b/src/libwebpdecoder.rc index 366f242d..3e6e073c 100644 --- a/src/libwebpdecoder.rc +++ b/src/libwebpdecoder.rc @@ -6,8 +6,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,2,1 - PRODUCTVERSION 1,0,2,1 + FILEVERSION 1,0,2,2 + PRODUCTVERSION 1,0,2,2 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -24,12 +24,12 @@ BEGIN BEGIN VALUE "CompanyName", "Google, Inc." VALUE "FileDescription", "libwebpdecoder DLL" - VALUE "FileVersion", "1.2.1" + VALUE "FileVersion", "1.2.2" VALUE "InternalName", "libwebpdecoder.dll" VALUE "LegalCopyright", "Copyright (C) 2021" VALUE "OriginalFilename", "libwebpdecoder.dll" VALUE "ProductName", "WebP Image Decoder" - VALUE "ProductVersion", "1.2.1" + VALUE "ProductVersion", "1.2.2" END END BLOCK "VarFileInfo" diff --git a/src/mux/Makefile.am b/src/mux/Makefile.am index 252219f8..d07d88b1 100644 --- a/src/mux/Makefile.am +++ b/src/mux/Makefile.am @@ -17,6 +17,6 @@ noinst_HEADERS = noinst_HEADERS += ../webp/format_constants.h libwebpmux_la_LIBADD = ../libwebp.la -libwebpmux_la_LDFLAGS = -no-undefined -version-info 3:7:0 -lm +libwebpmux_la_LDFLAGS = -no-undefined -version-info 3:8:0 -lm libwebpmuxincludedir = $(includedir)/webp pkgconfig_DATA = libwebpmux.pc diff --git a/src/mux/libwebpmux.rc b/src/mux/libwebpmux.rc index 9f294d14..cb2453ed 100644 --- a/src/mux/libwebpmux.rc +++ b/src/mux/libwebpmux.rc @@ -6,8 +6,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,2,1 - PRODUCTVERSION 1,0,2,1 + FILEVERSION 1,0,2,2 + PRODUCTVERSION 1,0,2,2 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -24,12 +24,12 @@ BEGIN BEGIN VALUE "CompanyName", "Google, Inc." VALUE "FileDescription", "libwebpmux DLL" - VALUE "FileVersion", "1.2.1" + VALUE "FileVersion", "1.2.2" VALUE "InternalName", "libwebpmux.dll" VALUE "LegalCopyright", "Copyright (C) 2021" VALUE "OriginalFilename", "libwebpmux.dll" VALUE "ProductName", "WebP Image Muxer" - VALUE "ProductVersion", "1.2.1" + VALUE "ProductVersion", "1.2.2" END END BLOCK "VarFileInfo" diff --git a/src/mux/muxi.h b/src/mux/muxi.h index 330da667..d9bf9b37 100644 --- a/src/mux/muxi.h +++ b/src/mux/muxi.h @@ -29,7 +29,7 @@ extern "C" { #define MUX_MAJ_VERSION 1 #define MUX_MIN_VERSION 2 -#define MUX_REV_VERSION 1 +#define MUX_REV_VERSION 2 // Chunk object. typedef struct WebPChunk WebPChunk; From 7031946ad886fee11c62cb921c0b466171d583fc Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 14 Dec 2021 21:59:43 -0800 Subject: [PATCH 03/14] update NEWS Change-Id: Id53e61bfb1551b04fe57fd095aa7ef860f60b248 --- NEWS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS b/NEWS index a6917611..0f534676 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +- 12/15/2021: 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) + - 7/20/2021: version 1.2.1 This is a binary compatible release. * minor lossless encoder improvements and x86 color conversion speed up From f035d2e40d4c314f8c70b868c21bd9d4f8466bb4 Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 15 Dec 2021 15:42:02 -0800 Subject: [PATCH 04/14] update ChangeLog Bug: webp:541 Change-Id: Icd9d0bf1a011263108e899b561f7c8e93dc93e2f --- ChangeLog | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6185fb69..39465093 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,48 @@ +7031946a update NEWS +973390b6 bump version to 1.2.2 +abd6664f update AUTHORS +5b7e7930 Merge "add missing USE_{MSA,NEON} checks in headers" into main +02ca04c3 add missing USE_{MSA,NEON} checks in headers +e94716e2 xcframeworkbuild.sh: place headers in a subdir +c846efd8 patch-check: commit subject length check +b6f756e8 update http links +8f5cb4c1 update rfc links +8ea81561 change VP8LPredictorFunc signature to avoid reading 'left' +6b1d18c3 webpmux: fix the -bgcolor description +3368d876 Merge "webpmux: add "-set bgcolor A,R,G,B"" into main +f213abf6 webpinfo: print the number of warnings +50c97c30 webpmux: add "-set bgcolor A,R,G,B" +2c206aaf Remove CMakeLists.txt check in compile.sh +96e3dfef Merge "infra/common.sh: add shard_should_run()" into main +0e0f74b7 infra/common.sh: add shard_should_run() +35b7436a Jenkins scripts port: update shell function comments +21d24b4c webp-container-spec.txt: remove 'experimental' markers +cdcf8902 Merge "Port Jenkins script: compile" into main +dc683cde Jenkins scripts port: static analysis +0858494e Port Jenkins script: compile +c2cf6a93 Jenkins scripts port: android compilation +df0e808f presubmit: Add pylint-2.7 and .pylintrc +676c57db patch-check: shfmt +7bb7f747 patch-check: Add shellcheck +abcd1797 Reformat docstrings and imports +edaf0895 Port Jenkins scripts: compile js +b9622063 Set CheckPatchFormatted flags to fail on diffs +e23cd548 dsp.h: enable NEON w/VS2019+ ARM64 targets +3875c7de CMakeLists.txt: set minimum version to 3.7 +1a8f0d45 Have a hard-coded value for memset in TrellisQuantizeBlock. +93480160 Speed up TrellisQuantizeBlock +45eaacc9 Convert deprecated uint32 to uint32_t. +42592af8 webp,cmake: Remove unnecessary include dirs +e298e05f Add patch-check steps in PRESUBMIT.py +29148919 Merge tag 'v1.2.1' +9ce5843d update ChangeLog (tag: v1.2.1, origin/1.2.1) d9191588 fuzzer/*: normalize src/ includes +c5bc3624 fuzzer/*: normalize src/ includes 53b6f762 fix indent +d2caaba4 fix indent 731246ba update ChangeLog (tag: v1.2.1-rc2) d250f01d dsp/*: use WEBP_HAVE_* to determine Init availability +1fe31625 dsp/*: use WEBP_HAVE_* to determine Init availability 3a4d3ecd update NEWS b2bc8093 bump version to 1.2.1 e542fc7a update AUTHORS From b217b4fff7196888f7f79663bb35d6d331cb575b Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 22 Dec 2021 13:42:50 -0800 Subject: [PATCH 05/14] webpinfo: fix fourcc comparison w/big-endian store the recognized fourccs in little-endian order to match how the fourcc is being read from the file Bug: webp:548 Change-Id: I9de77db92208709d5e711846908a51e563102fa5 (cherry picked from commit e3cb052ca5172e02641e8211ab1701bfa20d4c7d) --- examples/webpinfo.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/examples/webpinfo.c b/examples/webpinfo.c index 7792629e..356abae5 100644 --- a/examples/webpinfo.c +++ b/examples/webpinfo.c @@ -125,16 +125,16 @@ static void WebPInfoInit(WebPInfo* const webp_info) { memset(webp_info, 0, sizeof(*webp_info)); } -static const char kWebPChunkTags[CHUNK_TYPES][4] = { - { 'V', 'P', '8', ' ' }, - { 'V', 'P', '8', 'L' }, - { 'V', 'P', '8', 'X' }, - { 'A', 'L', 'P', 'H' }, - { 'A', 'N', 'I', 'M' }, - { 'A', 'N', 'M', 'F' }, - { 'I', 'C', 'C', 'P' }, - { 'E', 'X', 'I', 'F' }, - { 'X', 'M', 'P', ' ' }, +static const uint32_t kWebPChunkTags[CHUNK_TYPES] = { + MKFOURCC('V', 'P', '8', ' '), + MKFOURCC('V', 'P', '8', 'L'), + MKFOURCC('V', 'P', '8', 'X'), + MKFOURCC('A', 'L', 'P', 'H'), + MKFOURCC('A', 'N', 'I', 'M'), + MKFOURCC('A', 'N', 'M', 'F'), + MKFOURCC('I', 'C', 'C', 'P'), + MKFOURCC('E', 'X', 'I', 'F'), + MKFOURCC('X', 'M', 'P', ' '), }; // ----------------------------------------------------------------------------- @@ -644,7 +644,7 @@ static WebPInfoStatus ParseChunk(const WebPInfo* const webp_info, return WEBP_INFO_TRUNCATED_DATA; } for (i = 0; i < CHUNK_TYPES; ++i) { - if (!memcmp(kWebPChunkTags[i], &fourcc, TAG_SIZE)) break; + if (kWebPChunkTags[i] == fourcc) break; } chunk_data->offset_ = chunk_start_offset; chunk_data->size_ = chunk_size; @@ -939,7 +939,13 @@ static WebPInfoStatus ProcessChunk(const ChunkData* const chunk_data, LOG_WARN(error_message); } else { if (!webp_info->quiet_) { - const char* tag = kWebPChunkTags[chunk_data->id_]; + char tag[4]; + uint32_t fourcc = kWebPChunkTags[chunk_data->id_]; +#ifdef WORDS_BIGENDIAN + fourcc = (fourcc >> 24) | ((fourcc >> 8) & 0xff00) | + ((fourcc << 8) & 0xff0000) | (fourcc << 24); +#endif + memcpy(tag, &fourcc, sizeof(tag)); printf("Chunk %c%c%c%c at offset %6d, length %6d\n", tag[0], tag[1], tag[2], tag[3], (int)chunk_data->offset_, (int)chunk_data->size_); From f084244d9f8156055521517e60e87036a74634b2 Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 22 Dec 2021 13:46:21 -0800 Subject: [PATCH 06/14] 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 e4886716d3bde3cc67e74ad956e5bd50112cd8f0) --- src/demux/anim_decode.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/demux/anim_decode.c b/src/demux/anim_decode.c index 2bf4dcff..e077ffb5 100644 --- a/src/demux/anim_decode.c +++ b/src/demux/anim_decode.c @@ -23,6 +23,14 @@ #define NUM_CHANNELS 4 +// Channel extraction from a uint32_t representation of a uint8_t RGBA/BGRA +// buffer. +#ifdef WORDS_BIGENDIAN +#define CHANNEL_SHIFT(i) (24 - (i) * 8) +#else +#define CHANNEL_SHIFT(i) ((i) * 8) +#endif + typedef void (*BlendRowFunc)(uint32_t* const, const uint32_t* const, int); static void BlendPixelRowNonPremult(uint32_t* const src, const uint32_t* const dst, int num_pixels); @@ -209,35 +217,35 @@ static uint8_t BlendChannelNonPremult(uint32_t src, uint8_t src_a, const uint8_t dst_channel = (dst >> shift) & 0xff; const uint32_t blend_unscaled = src_channel * src_a + dst_channel * dst_a; assert(blend_unscaled < (1ULL << 32) / scale); - return (blend_unscaled * scale) >> 24; + return (blend_unscaled * scale) >> CHANNEL_SHIFT(3); } // Blend 'src' over 'dst' assuming they are NOT pre-multiplied by alpha. static uint32_t BlendPixelNonPremult(uint32_t src, uint32_t dst) { - const uint8_t src_a = (src >> 24) & 0xff; + const uint8_t src_a = (src >> CHANNEL_SHIFT(3)) & 0xff; if (src_a == 0) { return dst; } else { - const uint8_t dst_a = (dst >> 24) & 0xff; + const uint8_t dst_a = (dst >> CHANNEL_SHIFT(3)) & 0xff; // This is the approximate integer arithmetic for the actual formula: // dst_factor_a = (dst_a * (255 - src_a)) / 255. const uint8_t dst_factor_a = (dst_a * (256 - src_a)) >> 8; const uint8_t blend_a = src_a + dst_factor_a; const uint32_t scale = (1UL << 24) / blend_a; - const uint8_t blend_r = - BlendChannelNonPremult(src, src_a, dst, dst_factor_a, scale, 0); - const uint8_t blend_g = - BlendChannelNonPremult(src, src_a, dst, dst_factor_a, scale, 8); - const uint8_t blend_b = - BlendChannelNonPremult(src, src_a, dst, dst_factor_a, scale, 16); + const uint8_t blend_r = BlendChannelNonPremult( + src, src_a, dst, dst_factor_a, scale, CHANNEL_SHIFT(0)); + const uint8_t blend_g = BlendChannelNonPremult( + src, src_a, dst, dst_factor_a, scale, CHANNEL_SHIFT(1)); + const uint8_t blend_b = BlendChannelNonPremult( + src, src_a, dst, dst_factor_a, scale, CHANNEL_SHIFT(2)); assert(src_a + dst_factor_a < 256); - return (blend_r << 0) | - (blend_g << 8) | - (blend_b << 16) | - ((uint32_t)blend_a << 24); + return ((uint32_t)blend_r << CHANNEL_SHIFT(0)) | + ((uint32_t)blend_g << CHANNEL_SHIFT(1)) | + ((uint32_t)blend_b << CHANNEL_SHIFT(2)) | + ((uint32_t)blend_a << CHANNEL_SHIFT(3)); } } @@ -247,7 +255,7 @@ static void BlendPixelRowNonPremult(uint32_t* const src, const uint32_t* const dst, int num_pixels) { int i; for (i = 0; i < num_pixels; ++i) { - const uint8_t src_alpha = (src[i] >> 24) & 0xff; + const uint8_t src_alpha = (src[i] >> CHANNEL_SHIFT(3)) & 0xff; if (src_alpha != 0xff) { src[i] = BlendPixelNonPremult(src[i], dst[i]); } @@ -264,7 +272,7 @@ static WEBP_INLINE uint32_t ChannelwiseMultiply(uint32_t pix, uint32_t scale) { // Blend 'src' over 'dst' assuming they are pre-multiplied by alpha. static uint32_t BlendPixelPremult(uint32_t src, uint32_t dst) { - const uint8_t src_a = (src >> 24) & 0xff; + const uint8_t src_a = (src >> CHANNEL_SHIFT(3)) & 0xff; return src + ChannelwiseMultiply(dst, 256 - src_a); } @@ -274,7 +282,7 @@ static void BlendPixelRowPremult(uint32_t* const src, const uint32_t* const dst, int num_pixels) { int i; for (i = 0; i < num_pixels; ++i) { - const uint8_t src_alpha = (src[i] >> 24) & 0xff; + const uint8_t src_alpha = (src[i] >> CHANNEL_SHIFT(3)) & 0xff; if (src_alpha != 0xff) { src[i] = BlendPixelPremult(src[i], dst[i]); } From 567e1f442bf169925c79d2668da4c866ce9e4355 Mon Sep 17 00:00:00 2001 From: Yannis Guyon Date: Wed, 5 Jan 2022 10:15:28 +0100 Subject: [PATCH 07/14] Reword img2webp synopsis command line See https://bugs.chromium.org/p/webp/issues/detail?id=549 Change-Id: I75562d2ad021d8ec107eb4ced5b28e0abf373324 (cherry picked from commit a80954a1d98cbb3226f2ddc48d29d590f827740b) --- README | 2 +- examples/img2webp.c | 3 +-- man/img2webp.1 | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README b/README index 63e1dc2c..f6eaf2c0 100644 --- a/README +++ b/README @@ -456,7 +456,7 @@ modes, etc. Usage: - img2webp [file-level options] [image files...] [per-frame options...] + img2webp [file_options] [[frame_options] frame_file]... File-level options (only used at the start of compression): -min_size ............ minimize size diff --git a/examples/img2webp.c b/examples/img2webp.c index 3f1e59b6..94210923 100644 --- a/examples/img2webp.c +++ b/examples/img2webp.c @@ -35,8 +35,7 @@ static void Help(void) { printf("Usage:\n\n"); - printf(" img2webp [file-level options] [image files...] " - "[per-frame options...]\n"); + printf(" img2webp [file_options] [[frame_options] frame_file]...\n"); printf("\n"); printf("File-level options (only used at the start of compression):\n"); diff --git a/man/img2webp.1 b/man/img2webp.1 index 50dc7882..892023c8 100644 --- a/man/img2webp.1 +++ b/man/img2webp.1 @@ -4,7 +4,7 @@ img2webp \- create animated WebP file from a sequence of input images. .SH SYNOPSIS .B img2webp -[file_level_options] [files] [per_frame_options...] +[file_options] [[frame_options] frame_file]... .br .B img2webp argument_file_name .br From 883f06339748b5f18550104f48d89d42c7d91c5b Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 10 Jan 2022 10:57:55 -0800 Subject: [PATCH 08/14] man/img2webp.1: update date after: a80954a1 Reword img2webp synopsis command line Change-Id: I0a5c18f7947d15fcd66dc32fab9b525186f7fcc5 (cherry picked from commit 1b0c15db020945ef8e08a9676897ea58df6a7e82) --- man/img2webp.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/img2webp.1 b/man/img2webp.1 index 892023c8..5b28cede 100644 --- a/man/img2webp.1 +++ b/man/img2webp.1 @@ -1,5 +1,5 @@ .\" Hey, EMACS: -*- nroff -*- -.TH IMG2WEBP 1 "November 17, 2021" +.TH IMG2WEBP 1 "January 5, 2022" .SH NAME img2webp \- create animated WebP file from a sequence of input images. .SH SYNOPSIS From 4acae017bdf402cf45a9cec869ecf1bcef9e56ad Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 11 Jan 2022 18:44:19 -0800 Subject: [PATCH 09/14] update NEWS Bug: webp:541 Change-Id: I529210f8ecaa8f2e9a6fae2518ba71f7fd56a701 --- NEWS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 0f534676..5b36c5cf 100644 --- a/NEWS +++ b/NEWS @@ -1,10 +1,10 @@ -- 12/15/2021: version 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) + * doc updates and bug fixes (#538, #544, #548, #550) - 7/20/2021: version 1.2.1 This is a binary compatible release. From 9195ea0538bac4ac35966efc9451fefc4591998e Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 11 Jan 2022 18:46:37 -0800 Subject: [PATCH 10/14] update ChangeLog Bug: webp:541 Change-Id: I6cfb9da3a3944f66efa681cffec7f3e6a84c8800 --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 39465093..43105518 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +883f0633 man/img2webp.1: update date +567e1f44 Reword img2webp synopsis command line +f084244d anim_decode: fix alpha blending with big-endian +b217b4ff webpinfo: fix fourcc comparison w/big-endian +f035d2e4 update ChangeLog (tag: v1.2.2-rc1) 7031946a update NEWS 973390b6 bump version to 1.2.2 abd6664f update AUTHORS From 286e7fceaa340dd646eb05d8602c098f9657eb4c Mon Sep 17 00:00:00 2001 From: Yannis Guyon Date: Wed, 12 Jan 2022 14:47:49 +0100 Subject: [PATCH 11/14] 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 (cherry picked from commit 6e8a4126f2aab78946a5b85045b241707bbe44d2) --- imageio/jpegdec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/imageio/jpegdec.c b/imageio/jpegdec.c index 1af4a825..74a4c09c 100644 --- a/imageio/jpegdec.c +++ b/imageio/jpegdec.c @@ -336,7 +336,11 @@ int ReadJPEG(const uint8_t* const data, size_t data_size, pic->width = width; pic->height = height; ok = WebPPictureImportRGB(pic, rgb, (int)stride); - if (!ok) goto Error; + if (!ok) { + pic->width = 0; // WebPPictureImportRGB() barely touches 'pic' on failure. + pic->height = 0; // Just reset dimensions but keep any 'custom_ptr' etc. + MetadataFree(metadata); // In case the caller forgets to free it on error. + } End: free(rgb); From 827a307fecdd11b6ff082ad3fb4ada134dcaea1d Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Tue, 11 Jan 2022 16:43:35 +0100 Subject: [PATCH 12/14] 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 (cherry picked from commit 480cd51de6b5ed378b194ef77aa6d1bcdaf63da8) --- imageio/image_enc.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/imageio/image_enc.c b/imageio/image_enc.c index 5a78cbda..e06bcaf5 100644 --- a/imageio/image_enc.c +++ b/imageio/image_enc.c @@ -280,7 +280,7 @@ int WebPWrite16bAsPGM(FILE* fout, const WebPDecBuffer* const buffer) { } //------------------------------------------------------------------------------ -// BMP +// BMP (see https://en.wikipedia.org/wiki/BMP_file_format#Pixel_storage) static void PutLE16(uint8_t* const dst, uint32_t value) { dst[0] = (value >> 0) & 0xff; @@ -293,8 +293,11 @@ static void PutLE32(uint8_t* const dst, uint32_t value) { } #define BMP_HEADER_SIZE 54 +#define BMP_HEADER_ALPHA_EXTRA_SIZE 16 // for alpha info int WebPWriteBMP(FILE* fout, const WebPDecBuffer* const buffer) { const int has_alpha = WebPIsAlphaMode(buffer->colorspace); + const int header_size = + BMP_HEADER_SIZE + (has_alpha ? BMP_HEADER_ALPHA_EXTRA_SIZE : 0); const uint32_t width = buffer->width; const uint32_t height = buffer->height; const uint8_t* rgba = buffer->u.RGBA.rgba; @@ -303,8 +306,9 @@ int WebPWriteBMP(FILE* fout, const WebPDecBuffer* const buffer) { uint32_t y; const uint32_t line_size = bytes_per_px * width; const uint32_t bmp_stride = (line_size + 3) & ~3; // pad to 4 - const uint32_t total_size = bmp_stride * height + BMP_HEADER_SIZE; - uint8_t bmp_header[BMP_HEADER_SIZE] = { 0 }; + const uint32_t image_size = bmp_stride * height; + const uint32_t total_size = image_size + header_size; + uint8_t bmp_header[BMP_HEADER_SIZE + BMP_HEADER_ALPHA_EXTRA_SIZE] = { 0 }; if (fout == NULL || buffer == NULL || rgba == NULL) return 0; @@ -312,30 +316,37 @@ int WebPWriteBMP(FILE* fout, const WebPDecBuffer* const buffer) { PutLE16(bmp_header + 0, 0x4d42); // signature 'BM' PutLE32(bmp_header + 2, total_size); // size including header PutLE32(bmp_header + 6, 0); // reserved - PutLE32(bmp_header + 10, BMP_HEADER_SIZE); // offset to pixel array + PutLE32(bmp_header + 10, header_size); // offset to pixel array // bitmap info header - PutLE32(bmp_header + 14, 40); // DIB header size + PutLE32(bmp_header + 14, header_size - 14); // DIB header size PutLE32(bmp_header + 18, width); // dimensions - PutLE32(bmp_header + 22, -(int)height); // vertical flip! + PutLE32(bmp_header + 22, height); // no vertical flip PutLE16(bmp_header + 26, 1); // number of planes PutLE16(bmp_header + 28, bytes_per_px * 8); // bits per pixel - PutLE32(bmp_header + 30, 0); // no compression (BI_RGB) - PutLE32(bmp_header + 34, 0); // image size (placeholder) + PutLE32(bmp_header + 30, has_alpha ? 3 : 0); // BI_BITFIELDS or BI_RGB + PutLE32(bmp_header + 34, image_size); PutLE32(bmp_header + 38, 2400); // x pixels/meter PutLE32(bmp_header + 42, 2400); // y pixels/meter PutLE32(bmp_header + 46, 0); // number of palette colors PutLE32(bmp_header + 50, 0); // important color count + if (has_alpha) { // BITMAPV3INFOHEADER complement + PutLE32(bmp_header + 54, 0x00ff0000); // red mask + PutLE32(bmp_header + 58, 0x0000ff00); // green mask + PutLE32(bmp_header + 62, 0x000000ff); // blue mask + PutLE32(bmp_header + 66, 0xff000000); // alpha mask + } // TODO(skal): color profile // write header - if (fwrite(bmp_header, sizeof(bmp_header), 1, fout) != 1) { + if (fwrite(bmp_header, header_size, 1, fout) != 1) { return 0; } - // write pixel array + // write pixel array, bottom to top for (y = 0; y < height; ++y) { - if (fwrite(rgba, line_size, 1, fout) != 1) { + const uint8_t* const src = &rgba[(uint64_t)(height - 1 - y) * stride]; + if (fwrite(src, line_size, 1, fout) != 1) { return 0; } // write padding zeroes @@ -345,11 +356,11 @@ int WebPWriteBMP(FILE* fout, const WebPDecBuffer* const buffer) { return 0; } } - rgba += stride; } return 1; } #undef BMP_HEADER_SIZE +#undef BMP_HEADER_ALPHA_EXTRA_SIZE //------------------------------------------------------------------------------ // TIFF From 6db8248c014fca0d9b52b7d09f0e50ef6c63d236 Mon Sep 17 00:00:00 2001 From: Yannis Guyon Date: Tue, 18 Jan 2022 17:28:19 +0100 Subject: [PATCH 13/14] 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 db25f1b4ed2ef519b6a3fd1d7ebfbcdfe2cc9712) --- src/enc/frame_enc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/enc/frame_enc.c b/src/enc/frame_enc.c index af538d83..b93d9e5b 100644 --- a/src/enc/frame_enc.c +++ b/src/enc/frame_enc.c @@ -778,6 +778,7 @@ int VP8EncTokenLoop(VP8Encoder* const enc) { // Roughly refresh the proba eight times per pass int max_count = (enc->mb_w_ * enc->mb_h_) >> 3; int num_pass_left = enc->config_->pass; + int remaining_progress = 40; // percents const int do_search = enc->do_search_; VP8EncIterator it; VP8EncProba* const proba = &enc->proba_; @@ -805,6 +806,9 @@ int VP8EncTokenLoop(VP8Encoder* const enc) { uint64_t size_p0 = 0; uint64_t distortion = 0; int cnt = max_count; + // The final number of passes is not trivial to know in advance. + const int pass_progress = remaining_progress / (2 + num_pass_left); + remaining_progress -= pass_progress; VP8IteratorInit(enc, &it); SetLoopParams(enc, stats.q); if (is_last_pass) { @@ -832,7 +836,7 @@ int VP8EncTokenLoop(VP8Encoder* const enc) { StoreSideInfo(&it); VP8StoreFilterStats(&it); VP8IteratorExport(&it); - ok = VP8IteratorProgress(&it, 20); + ok = VP8IteratorProgress(&it, pass_progress); } VP8IteratorSaveBoundary(&it); } while (ok && VP8IteratorNext(&it)); @@ -878,7 +882,8 @@ int VP8EncTokenLoop(VP8Encoder* const enc) { ok = VP8EmitTokens(&enc->tokens_, enc->parts_ + 0, (const uint8_t*)proba->coeffs_, 1); } - ok = ok && WebPReportProgress(enc->pic_, enc->percent_ + 20, &enc->percent_); + ok = ok && WebPReportProgress(enc->pic_, enc->percent_ + remaining_progress, + &enc->percent_); return PostLoopFinalize(&it, ok); } From b0a860891dcd4c0c2d7c6149e5cccb6eb881cc21 Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 19 Jan 2022 15:35:26 -0800 Subject: [PATCH 14/14] update ChangeLog Change-Id: I8a18162a178f1686cc8359ce48d90c1c7f65ec91 --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 43105518..3411ea61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +6db8248c libwebp: Fix VP8EncTokenLoop() progress +827a307f BMP enc: fix the transparency case +286e7fce libwebp: do not destroy jpeg codec twice on error +9195ea05 update ChangeLog (tag: v1.2.2-rc2) +4acae017 update NEWS 883f0633 man/img2webp.1: update date 567e1f44 Reword img2webp synopsis command line f084244d anim_decode: fix alpha blending with big-endian