From cba2885375012054cf9e417660c96d37192f16f1 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 2 Apr 2018 15:32:46 -0700 Subject: [PATCH 01/23] update NEWS Change-Id: I3470bf02d20f87e17bbabcb3e415a7c2dd5804ed --- NEWS | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/NEWS b/NEWS index 85d273e0..480cb7d3 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,13 @@ +- 4/2/2018: version 1.0.0 + This is a binary compatible release. + * lossy encoder improvements to avoid chroma shifts in various circumstances + (issues #308, #340) + * big-endian fixes for decode, RGBA import and WebPPictureDistortion + Tool updates: + gifwebp, anim_diff - default duration behavior (<= 10ms) changed to match + web browsers, transcoding tools (issue #379) + img2webp, webpmux - allow options to be passed in via a file (issue #355) + - 11/24/2017: version 0.6.1 This is a binary compatible release. * lossless performance and compression improvements + a new 'cruncher' mode From c57b273698f90f33bafb738b7124db1c545f048b Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 2 Apr 2018 15:16:11 -0700 Subject: [PATCH 02/23] bump version to 1.0.0 libwebp{,decoder} - 1.0.0 libwebp libtool - 7.2.0 libwebpdecoder libtool - 3.2.0 mux - 1.0.0 libtool - 3.2.0 demux - 1.0.0 libtool - 2.4.0 Change-Id: I4310caed27d1e53cc8c1b534571e3d653ad434c8 --- README | 5 ++++- README.mux | 2 +- configure.ac | 2 +- extras/extras.c | 6 +++--- src/Makefile.am | 4 ++-- src/dec/vp8i_dec.h | 6 +++--- src/demux/Makefile.am | 2 +- src/demux/demux.c | 6 +++--- src/demux/libwebpdemux.rc | 10 +++++----- src/enc/vp8i_enc.h | 6 +++--- src/libwebp.rc | 10 +++++----- src/libwebpdecoder.rc | 10 +++++----- src/mux/Makefile.am | 2 +- src/mux/libwebpmux.rc | 10 +++++----- src/mux/muxi.h | 6 +++--- 15 files changed, 45 insertions(+), 42 deletions(-) diff --git a/README b/README index e9817bfc..5ddbfc9b 100644 --- a/README +++ b/README @@ -4,7 +4,7 @@ \__\__/\____/\_____/__/ ____ ___ / _/ / \ \ / _ \/ _/ / \_/ / / \ \ __/ \__ - \____/____/\_____/_____/____/v0.6.1 + \____/____/\_____/_____/____/v1.0.0 Description: ============ @@ -524,6 +524,9 @@ Options: -min_psnr ... minimum per-frame PSNR -raw_comparison ..... if this flag is not used, RGB is premultiplied before comparison + -max_diff ..... maximum allowed difference per channel + between corresponding pixels in subsequent + frames Building: --------- diff --git a/README.mux b/README.mux index d09ac179..bd4f92fa 100644 --- a/README.mux +++ b/README.mux @@ -1,7 +1,7 @@  __ __ ____ ____ ____ __ __ _ __ __ / \\/ \/ _ \/ _ \/ _ \/ \ \/ \___/_ / _\ \ / __/ _ \ __/ / / (_/ /__ - \__\__/\_____/_____/__/ \__//_/\_____/__/___/v0.4.1 + \__\__/\_____/_____/__/ \__//_/\_____/__/___/v1.0.0 Description: diff --git a/configure.ac b/configure.ac index dff7d077..896e5ff7 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([libwebp], [0.6.1], +AC_INIT([libwebp], [1.0.0], [https://bugs.chromium.org/p/webp],, [http://developers.google.com/speed/webp]) AC_CANONICAL_HOST diff --git a/extras/extras.c b/extras/extras.c index d01aadbd..dcb30395 100644 --- a/extras/extras.c +++ b/extras/extras.c @@ -16,9 +16,9 @@ #include #include -#define XTRA_MAJ_VERSION 0 -#define XTRA_MIN_VERSION 1 -#define XTRA_REV_VERSION 1 +#define XTRA_MAJ_VERSION 1 +#define XTRA_MIN_VERSION 0 +#define XTRA_REV_VERSION 0 //------------------------------------------------------------------------------ diff --git a/src/Makefile.am b/src/Makefile.am index 7b5f26da..32cfa38e 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 7:1:0 +libwebp_la_LDFLAGS = -no-undefined -version-info 7:2:0 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 3:1:0 + libwebpdecoder_la_LDFLAGS = -no-undefined -version-info 3:2:0 pkgconfig_DATA += libwebpdecoder.pc endif diff --git a/src/dec/vp8i_dec.h b/src/dec/vp8i_dec.h index 28244d9d..c929933e 100644 --- a/src/dec/vp8i_dec.h +++ b/src/dec/vp8i_dec.h @@ -30,9 +30,9 @@ extern "C" { // Various defines and enums // version numbers -#define DEC_MAJ_VERSION 0 -#define DEC_MIN_VERSION 6 -#define DEC_REV_VERSION 1 +#define DEC_MAJ_VERSION 1 +#define DEC_MIN_VERSION 0 +#define DEC_REV_VERSION 0 // 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 362c2afe..ba9d9474 100644 --- a/src/demux/Makefile.am +++ b/src/demux/Makefile.am @@ -10,6 +10,6 @@ libwebpdemuxinclude_HEADERS += ../webp/mux_types.h libwebpdemuxinclude_HEADERS += ../webp/types.h libwebpdemux_la_LIBADD = ../libwebp.la -libwebpdemux_la_LDFLAGS = -no-undefined -version-info 2:3:0 +libwebpdemux_la_LDFLAGS = -no-undefined -version-info 2:4:0 libwebpdemuxincludedir = $(includedir)/webp pkgconfig_DATA = libwebpdemux.pc diff --git a/src/demux/demux.c b/src/demux/demux.c index 79c24a5a..684215e3 100644 --- a/src/demux/demux.c +++ b/src/demux/demux.c @@ -23,9 +23,9 @@ #include "src/webp/demux.h" #include "src/webp/format_constants.h" -#define DMUX_MAJ_VERSION 0 -#define DMUX_MIN_VERSION 3 -#define DMUX_REV_VERSION 3 +#define DMUX_MAJ_VERSION 1 +#define DMUX_MIN_VERSION 0 +#define DMUX_REV_VERSION 0 typedef struct { size_t start_; // start location of the data diff --git a/src/demux/libwebpdemux.rc b/src/demux/libwebpdemux.rc index 5a6994d2..544a8b2f 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 0,3,0,3 - PRODUCTVERSION 0,3,0,3 + FILEVERSION 1,0,0,0 + PRODUCTVERSION 1,0,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -24,12 +24,12 @@ BEGIN BEGIN VALUE "CompanyName", "Google, Inc." VALUE "FileDescription", "libwebpdemux DLL" - VALUE "FileVersion", "0.3.3" + VALUE "FileVersion", "1.0.0" VALUE "InternalName", "libwebpdemux.dll" - VALUE "LegalCopyright", "Copyright (C) 2017" + VALUE "LegalCopyright", "Copyright (C) 2018" VALUE "OriginalFilename", "libwebpdemux.dll" VALUE "ProductName", "WebP Image Demuxer" - VALUE "ProductVersion", "0.3.3" + VALUE "ProductVersion", "1.0.0" END END BLOCK "VarFileInfo" diff --git a/src/enc/vp8i_enc.h b/src/enc/vp8i_enc.h index 11ff3f1d..624e8f8e 100644 --- a/src/enc/vp8i_enc.h +++ b/src/enc/vp8i_enc.h @@ -30,9 +30,9 @@ extern "C" { // Various defines and enums // version numbers -#define ENC_MAJ_VERSION 0 -#define ENC_MIN_VERSION 6 -#define ENC_REV_VERSION 1 +#define ENC_MAJ_VERSION 1 +#define ENC_MIN_VERSION 0 +#define ENC_REV_VERSION 0 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 3a47fce2..d554124f 100644 --- a/src/libwebp.rc +++ b/src/libwebp.rc @@ -6,8 +6,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,6,0,1 - PRODUCTVERSION 0,6,0,1 + FILEVERSION 1,0,0,0 + PRODUCTVERSION 1,0,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -24,12 +24,12 @@ BEGIN BEGIN VALUE "CompanyName", "Google, Inc." VALUE "FileDescription", "libwebp DLL" - VALUE "FileVersion", "0.6.1" + VALUE "FileVersion", "1.0.0" VALUE "InternalName", "libwebp.dll" - VALUE "LegalCopyright", "Copyright (C) 2017" + VALUE "LegalCopyright", "Copyright (C) 2018" VALUE "OriginalFilename", "libwebp.dll" VALUE "ProductName", "WebP Image Codec" - VALUE "ProductVersion", "0.6.1" + VALUE "ProductVersion", "1.0.0" END END BLOCK "VarFileInfo" diff --git a/src/libwebpdecoder.rc b/src/libwebpdecoder.rc index 9fb0b447..8a2def48 100644 --- a/src/libwebpdecoder.rc +++ b/src/libwebpdecoder.rc @@ -6,8 +6,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,6,0,1 - PRODUCTVERSION 0,6,0,1 + FILEVERSION 1,0,0,0 + PRODUCTVERSION 1,0,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -24,12 +24,12 @@ BEGIN BEGIN VALUE "CompanyName", "Google, Inc." VALUE "FileDescription", "libwebpdecoder DLL" - VALUE "FileVersion", "0.6.1" + VALUE "FileVersion", "1.0.0" VALUE "InternalName", "libwebpdecoder.dll" - VALUE "LegalCopyright", "Copyright (C) 2017" + VALUE "LegalCopyright", "Copyright (C) 2018" VALUE "OriginalFilename", "libwebpdecoder.dll" VALUE "ProductName", "WebP Image Decoder" - VALUE "ProductVersion", "0.6.1" + VALUE "ProductVersion", "1.0.0" END END BLOCK "VarFileInfo" diff --git a/src/mux/Makefile.am b/src/mux/Makefile.am index 374c1e7b..771ff339 100644 --- a/src/mux/Makefile.am +++ b/src/mux/Makefile.am @@ -15,6 +15,6 @@ libwebpmuxinclude_HEADERS += ../webp/mux_types.h libwebpmuxinclude_HEADERS += ../webp/types.h libwebpmux_la_LIBADD = ../libwebp.la -libwebpmux_la_LDFLAGS = -no-undefined -version-info 3:1:0 -lm +libwebpmux_la_LDFLAGS = -no-undefined -version-info 3:2:0 -lm libwebpmuxincludedir = $(includedir)/webp pkgconfig_DATA = libwebpmux.pc diff --git a/src/mux/libwebpmux.rc b/src/mux/libwebpmux.rc index a9d07e47..8c7d5f67 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 0,4,0,1 - PRODUCTVERSION 0,4,0,1 + FILEVERSION 1,0,0,0 + PRODUCTVERSION 1,0,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -24,12 +24,12 @@ BEGIN BEGIN VALUE "CompanyName", "Google, Inc." VALUE "FileDescription", "libwebpmux DLL" - VALUE "FileVersion", "0.4.1" + VALUE "FileVersion", "1.0.0" VALUE "InternalName", "libwebpmux.dll" - VALUE "LegalCopyright", "Copyright (C) 2017" + VALUE "LegalCopyright", "Copyright (C) 2018" VALUE "OriginalFilename", "libwebpmux.dll" VALUE "ProductName", "WebP Image Muxer" - VALUE "ProductVersion", "0.4.1" + VALUE "ProductVersion", "1.0.0" END END BLOCK "VarFileInfo" diff --git a/src/mux/muxi.h b/src/mux/muxi.h index b73e3fbd..6b57eea3 100644 --- a/src/mux/muxi.h +++ b/src/mux/muxi.h @@ -26,9 +26,9 @@ extern "C" { //------------------------------------------------------------------------------ // Defines and constants. -#define MUX_MAJ_VERSION 0 -#define MUX_MIN_VERSION 4 -#define MUX_REV_VERSION 1 +#define MUX_MAJ_VERSION 1 +#define MUX_MIN_VERSION 0 +#define MUX_REV_VERSION 0 // Chunk object. typedef struct WebPChunk WebPChunk; From 38410c082fe2879f02cb60840b5fe8347c78e46b Mon Sep 17 00:00:00 2001 From: Vlad Tsyrklevich Date: Mon, 2 Apr 2018 15:52:19 -0700 Subject: [PATCH 03/23] [CFI] Remove function pointer casts Control Flow Integrity [1] indirect call checking verifies that function pointers only call valid functions with a matching type signature. This change eliminates function pointer casts that were causing cfi-icall failures. [1] https://www.chromium.org/developers/testing/control-flow-integrity BUG=chromium:827826 Change-Id: I5db021d06390a6cefd670fdd2f0d34c9e530465e (cherry picked from commit 978eec2507e3b5110bd1d2a408fa27a8f7e702cf) --- src/dec/frame_dec.c | 6 ++++-- src/enc/alpha_enc.c | 5 +++-- src/enc/analysis_enc.c | 6 ++++-- src/enc/vp8l_enc.c | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/dec/frame_dec.c b/src/dec/frame_dec.c index 514e85b5..a9d5430d 100644 --- a/src/dec/frame_dec.c +++ b/src/dec/frame_dec.c @@ -400,7 +400,9 @@ static void DitherRow(VP8Decoder* const dec) { #define MACROBLOCK_VPOS(mb_y) ((mb_y) * 16) // vertical position of a MB // Finalize and transmit a complete row. Return false in case of user-abort. -static int FinishRow(VP8Decoder* const dec, VP8Io* const io) { +static int FinishRow(void* arg1, void* arg2) { + VP8Decoder* const dec = (VP8Decoder*)arg1; + VP8Io* const io = (VP8Io*)arg2; int ok = 1; const VP8ThreadContext* const ctx = &dec->thread_ctx_; const int cache_id = ctx->id_; @@ -647,7 +649,7 @@ static int InitThreadContext(VP8Decoder* const dec) { } worker->data1 = dec; worker->data2 = (void*)&dec->thread_ctx_.io_; - worker->hook = (WebPWorkerHook)FinishRow; + worker->hook = FinishRow; dec->num_caches_ = (dec->filter_type_ > 0) ? MT_CACHE_LINES : MT_CACHE_LINES - 1; } else { diff --git a/src/enc/alpha_enc.c b/src/enc/alpha_enc.c index 7e8d87f2..dce9ca95 100644 --- a/src/enc/alpha_enc.c +++ b/src/enc/alpha_enc.c @@ -361,7 +361,8 @@ static int EncodeAlpha(VP8Encoder* const enc, //------------------------------------------------------------------------------ // Main calls -static int CompressAlphaJob(VP8Encoder* const enc, void* dummy) { +static int CompressAlphaJob(void* arg1, void* dummy) { + VP8Encoder* const enc = (VP8Encoder*)arg1; const WebPConfig* config = enc->config_; uint8_t* alpha_data = NULL; size_t alpha_size = 0; @@ -394,7 +395,7 @@ void VP8EncInitAlpha(VP8Encoder* const enc) { WebPGetWorkerInterface()->Init(worker); worker->data1 = enc; worker->data2 = NULL; - worker->hook = (WebPWorkerHook)CompressAlphaJob; + worker->hook = CompressAlphaJob; } } diff --git a/src/enc/analysis_enc.c b/src/enc/analysis_enc.c index 08f471f5..a47ff7d4 100644 --- a/src/enc/analysis_enc.c +++ b/src/enc/analysis_enc.c @@ -434,7 +434,9 @@ typedef struct { } SegmentJob; // main work call -static int DoSegmentsJob(SegmentJob* const job, VP8EncIterator* const it) { +static int DoSegmentsJob(void* arg1, void* arg2) { + SegmentJob* const job = (SegmentJob*)arg1; + VP8EncIterator* const it = (VP8EncIterator*)arg2; int ok = 1; if (!VP8IteratorIsDone(it)) { uint8_t tmp[32 + WEBP_ALIGN_CST]; @@ -462,7 +464,7 @@ static void InitSegmentJob(VP8Encoder* const enc, SegmentJob* const job, WebPGetWorkerInterface()->Init(&job->worker); job->worker.data1 = job; job->worker.data2 = &job->it; - job->worker.hook = (WebPWorkerHook)DoSegmentsJob; + job->worker.hook = DoSegmentsJob; VP8IteratorInit(enc, &job->it); VP8IteratorSetRow(&job->it, start_row); VP8IteratorSetCountDown(&job->it, (end_row - start_row) * enc->mb_w_); diff --git a/src/enc/vp8l_enc.c b/src/enc/vp8l_enc.c index aeb52f38..2b3f3486 100644 --- a/src/enc/vp8l_enc.c +++ b/src/enc/vp8l_enc.c @@ -1754,7 +1754,7 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config, worker_interface->Init(worker); worker->data1 = param; worker->data2 = NULL; - worker->hook = (WebPWorkerHook)EncodeStreamHook; + worker->hook = EncodeStreamHook; } } From e607dabcf20cbaa5e5887b9c580e075d925111b7 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 2 Apr 2018 16:57:46 -0700 Subject: [PATCH 04/23] update AUTHORS Change-Id: I51c52f4f9b37dee36a9201893d7acf1fde46a78e --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index b6e9cfb8..83c7b9c5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -35,4 +35,5 @@ Contributors: - Urvang Joshi (urvang at google dot com) - Vikas Arora (vikasa at google dot com) - Vincent Rabaud (vrabaud at google dot com) +- Vlad Tsyrklevich (vtsyrklevich at chromium dot org) - Yang Zhang (yang dot zhang at arm dot com) From 15aa48d905a7a00f13d018ed9574c3c9b70d96af Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 2 Apr 2018 17:38:41 -0700 Subject: [PATCH 05/23] update ChangeLog Change-Id: I4a34bfa69c203bec92b42f91d6e7d79a46780584 --- ChangeLog | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/ChangeLog b/ChangeLog index b17feb20..846fd0cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,74 @@ +e607dabc update AUTHORS +38410c08 [CFI] Remove function pointer casts +c57b2736 bump version to 1.0.0 +cba28853 update NEWS +c909d531 Merge "remove some deprecation warning on MacOSX" +217443c7 remove some deprecation warning on MacOSX +b672bdfa configure: quiet glut deprecation warnings on OS X +daa9fcaf configure: use sdl-config if available +dd174cae Merge "imagedec: support metadata reading for WebP image decoding" +641cedcc imagedec: support metadata reading for WebP image decoding +065b2ce1 anim_diff: add a couple missing newlines in Help() +c4cc1147 Merge "gif2webp: force low duration frames to 100ms" +09333097 gif2webp: force low duration frames to 100ms +e03f0ec3 sharp_yuv: use 14b fixed-point precision for gamma +b2db361c image_enc,WebPWritePNG: move locals after setjmp +74e82ec6 Merge "WebPPictureDistortion: fix big-endian results order" +645d04ca Merge "cwebp,get_disto: report bpp" +120f58c3 Merge "lossless*sse2: improve non-const 16-bit vector creation" +a7fe9412 WebPPictureDistortion: fix big-endian results order +e26fe066 cwebp,get_disto: report bpp +9df64e28 Merge changes Id5b4a1a4,Ia20ce844 +8043504f lossless*sse2: improve non-const 16-bit vector creation +1e3dfc48 Import: extract condition from loop +3b07d327 Import,RGBA: fix for BigEndian import +551948e4 Remove unused argument in VP8LBitsEntropy. +3005237a ReadWebP: fix for big-endian +499c395a Merge "anim_diff: expose the -max_diff option" +f69dcd69 Merge "remove WEBP_EXPERIMENTAL_FEATURES" +07d884d5 anim_diff: expose the -max_diff option +f4dd9256 remove WEBP_EXPERIMENTAL_FEATURES +94a8377b extract the command-line parsing helpers to example_util +fc09e6e2 PNM decoder: prevent unsupported depth=2 PAM case. +6de58603 MIPS64: Fix defined-but-not-used errors with WEBP_REDUCE_CSP +cbde5728 gif2webp: add support for reading from stdin +cf1c5054 Add an SSE4 version of some lossless color transforms. +45a8b5eb Fix lint error with man page. +cff38e8f Merge "PNG decoder: handle gAMA chunk" +59cb1a48 Merge "enable dc error-diffusion always" +78318b30 PNG decoder: handle gAMA chunk +664c21dd Merge "remove some TODOs" +815652de enable dc error-diffusion always +aec45cec remove some TODOs +5715dfce fix block-count[] increment in case of large image +c2d04f3e enable DC error-diffusion always for multi-pass +96bf07c5 use DC error diffusion for U/V at low-quality +1c59020b fix missing sse41 targets in makefile.unix +7a8e814b cosmetics: s/color_space/colorspace/ +05f6fe24 upsampling: rm asserts w/REDUCE_CSP+OMIT_C_CODE +b4cf5597 Merge "Upsampling SSE2/SSE4 speedup." +ccbeb32c Makefile.vc: add missing sse41 files +55403a9a Upsampling SSE2/SSE4 speedup. +807b53c4 Implement the upsampling/yuv functions in SSE41 +84101a81 Fix wasm WebP compilation +8bebd2a3 fix warning on MSVC +a7f93fe3 webpmux: allow reading argument from a file +b69f18a7 gif2webp.1: fix -loop_compatibility layout +72d530c0 Merge "fix lossless decoding w/WEBP_REDUCE_SIZE" +296c7dc4 fix lossless decoding w/WEBP_REDUCE_SIZE +0d5d029c Merge "ImgIoUtilReadFile: fix file leak upon error" +ae568ce7 ImgIoUtilReadFile: fix file leak upon error +796b5a8a Merge tag 'v0.6.1' +6b7a95fd update ChangeLog (tag: v0.6.1) f66955de WEBP_REDUCE_CSP: restrict colorspace support +1af0df76 Merge "WEBP_REDUCE_CSP: restrict colorspace support" +6de20df0 WEBP_REDUCE_CSP: restrict colorspace support a289d8e7 update ChangeLog (tag: v0.6.1-rc2) c10a493c vwebp: disable double buffering on windows & mac 0d4466c2 webp_to_sdl.c: fix file mode 1b27bf8b WEBP_REDUCE_SIZE: disable all rescaler code 126be109 webpinfo: add -version option +0df22b9e WEBP_REDUCE_SIZE: disable all rescaler code 9add62b5 bump version to 0.6.1 d3e26144 update NEWS 2edda639 README: add webpinfo section From fc1b8e3a8bd5fc7bac79cfe7f46daf6441f4ef7c Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Tue, 3 Apr 2018 13:55:33 +0200 Subject: [PATCH 06/23] webp_js: fix webp_js demo html We need to export 'Module.cwrap' method. Change-Id: I2986c5a4c06630ae3f95086a114e727a86c99a2b --- CMakeLists.txt | 6 ++++-- README.webp_js | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 79477a45..a3b7a436 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -289,7 +289,8 @@ if(WEBP_BUILD_WEBP_JS) target_link_libraries(webp_js webpdecoder SDL) set(WEBP_HAVE_SDL 1) set_target_properties(webp_js PROPERTIES LINK_FLAGS - "-s EXPORTED_FUNCTIONS='[\"_WebpToSDL\"]' -s INVOKE_RUN=0") + "-s EXPORTED_FUNCTIONS='[\"_WebpToSDL\"]' -s INVOKE_RUN=0 \ + -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"cwrap\"]'") set_target_properties(webp_js PROPERTIES OUTPUT_NAME webp) target_compile_definitions(webp_js PUBLIC EMSCRIPTEN WEBP_HAVE_SDL) @@ -299,7 +300,8 @@ if(WEBP_BUILD_WEBP_JS) target_link_libraries(webp_wasm webpdecoder SDL) set_target_properties(webp_wasm PROPERTIES LINK_FLAGS "-s WASM=1 -s 'BINARYEN_METHOD=\"native-wasm\"' \ - -s EXPORTED_FUNCTIONS='[\"_WebpToSDL\"]' -s INVOKE_RUN=0") + -s EXPORTED_FUNCTIONS='[\"_WebpToSDL\"]' -s INVOKE_RUN=0 \ + -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"cwrap\"]'") target_compile_definitions(webp_wasm PUBLIC EMSCRIPTEN WEBP_HAVE_SDL) target_compile_definitions(webpdecoder PUBLIC EMSCRIPTEN) diff --git a/README.webp_js b/README.webp_js index 04f4970b..2805354d 100644 --- a/README.webp_js +++ b/README.webp_js @@ -32,7 +32,8 @@ using Emscripten and CMake. webp.js.mem files generated. The callable JavaScript function is WebPToSDL(), which decodes a raw WebP -bitstream into a canvas. See webp_js/index.html for a simple usage sample. +bitstream into a canvas. See webp_js/index.html for a simple usage sample +(see below for instructions). Demo HTML page: =============== From 64a57d0587a2fd1c26015a42ed422b1fde22d608 Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Tue, 3 Apr 2018 14:50:58 +0200 Subject: [PATCH 07/23] add -version option to anim_dump,anim_diff and img2webp This is to harmonize the -h/-version options on all our examples. + added GetAnimatedImageVersions() method to anim_util.* Change-Id: I2304a1c29e310682e97f236d3867274a192a7a09 --- README | 3 +++ examples/anim_diff.c | 25 ++++++++++++++++++++----- examples/anim_dump.c | 14 ++++++++++++++ examples/anim_util.c | 6 ++++++ examples/anim_util.h | 4 ++++ examples/img2webp.c | 9 +++++++++ man/img2webp.1 | 5 ++++- 7 files changed, 60 insertions(+), 6 deletions(-) diff --git a/README b/README index 5ddbfc9b..a76b3787 100644 --- a/README +++ b/README @@ -458,6 +458,7 @@ File-level options (only used at the start of compression): -mixed ............... use mixed lossy/lossless automatic mode -v ................... verbose mode -h ................... this help + -version ............. print version number and exit Per-frame options (only used for subsequent images input): -d ............. frame duration in ms (default: 100) @@ -527,6 +528,8 @@ Options: -max_diff ..... maximum allowed difference per channel between corresponding pixels in subsequent frames + -h .................. this help + -version ............ print version number and exit Building: --------- diff --git a/examples/anim_diff.c b/examples/anim_diff.c index 7ac56899..e74a915f 100644 --- a/examples/anim_diff.c +++ b/examples/anim_diff.c @@ -190,6 +190,8 @@ static void Help(void) { printf(" -max_diff ..... maximum allowed difference per channel\n" " between corresponding pixels in subsequent\n" " frames\n"); + printf(" -h .................. this help\n"); + printf(" -version ............ print version number and exit\n"); } int main(int argc, const char* argv[]) { @@ -205,11 +207,6 @@ int main(int argc, const char* argv[]) { const char* files[2] = { NULL, NULL }; AnimatedImage images[2]; - if (argc < 3) { - Help(); - return -1; - } - for (c = 1; c < argc; ++c) { int parse_error = 0; if (!strcmp(argv[c], "-dump_frames")) { @@ -247,6 +244,18 @@ int main(int argc, const char* argv[]) { } else { parse_error = 1; } + } else if (!strcmp(argv[c], "-h") || !strcmp(argv[c], "-help")) { + Help(); + return 0; + } else if (!strcmp(argv[c], "-version")) { + int dec_version, demux_version; + GetAnimatedImageVersions(&dec_version, &demux_version); + printf("WebP Decoder version: %d.%d.%d\nWebP Demux version: %d.%d.%d\n", + (dec_version >> 16) & 0xff, (dec_version >> 8) & 0xff, + (dec_version >> 0) & 0xff, + (demux_version >> 16) & 0xff, (demux_version >> 8) & 0xff, + (demux_version >> 0) & 0xff); + return 0; } else { if (!got_input1) { files[0] = argv[c]; @@ -263,6 +272,12 @@ int main(int argc, const char* argv[]) { return -1; } } + if (argc < 3) { + Help(); + return -1; + } + + if (!got_input2) { Help(); return -1; diff --git a/examples/anim_dump.c b/examples/anim_dump.c index b955b54a..7b96cfec 100644 --- a/examples/anim_dump.c +++ b/examples/anim_dump.c @@ -30,6 +30,8 @@ static void Help(void) { "(default: 'dump_')\n"); printf(" -tiff ............... save frames as TIFF\n"); printf(" -pam ................ save frames as PAM\n"); + printf(" -h .................. this help\n"); + printf(" -version ............ print version number and exit\n"); } int main(int argc, const char* argv[]) { @@ -66,6 +68,18 @@ int main(int argc, const char* argv[]) { } else if (!strcmp(argv[c], "-pam")) { format = PAM; suffix = "pam"; + } else if (!strcmp(argv[c], "-h") || !strcmp(argv[c], "-help")) { + Help(); + return 0; + } else if (!strcmp(argv[c], "-version")) { + int dec_version, demux_version; + GetAnimatedImageVersions(&dec_version, &demux_version); + printf("WebP Decoder version: %d.%d.%d\nWebP Demux version: %d.%d.%d\n", + (dec_version >> 16) & 0xff, (dec_version >> 8) & 0xff, + (dec_version >> 0) & 0xff, + (demux_version >> 16) & 0xff, (demux_version >> 8) & 0xff, + (demux_version >> 0) & 0xff); + return 0; } else { uint32_t i; AnimatedImage image; diff --git a/examples/anim_util.c b/examples/anim_util.c index 800ea763..c7a05c7c 100644 --- a/examples/anim_util.c +++ b/examples/anim_util.c @@ -786,3 +786,9 @@ void GetDiffAndPSNR(const uint8_t rgba1[], const uint8_t rgba2[], *psnr = 4.3429448 * log(255. * 255. / sse); } } + +void GetAnimatedImageVersions(int* const decoder_version, + int* const demux_version) { + *decoder_version = WebPGetDecoderVersion(); + *demux_version = WebPGetDemuxVersion(); +} diff --git a/examples/anim_util.h b/examples/anim_util.h index dbc9792c..8063121f 100644 --- a/examples/anim_util.h +++ b/examples/anim_util.h @@ -56,6 +56,10 @@ void GetDiffAndPSNR(const uint8_t rgba1[], const uint8_t rgba2[], uint32_t width, uint32_t height, int premultiply, int* const max_diff, double* const psnr); +// Return library versions used by anim_util. +void GetAnimatedImageVersions(int* const decoder_version, + int* const demux_version); + #ifdef __cplusplus } // extern "C" #endif diff --git a/examples/img2webp.c b/examples/img2webp.c index 052aa87a..2f750c59 100644 --- a/examples/img2webp.c +++ b/examples/img2webp.c @@ -48,6 +48,7 @@ static void Help(void) { printf(" -mixed ............... use mixed lossy/lossless automatic mode\n"); printf(" -v ................... verbose mode\n"); printf(" -h ................... this help\n"); + printf(" -version ............. print version number and exit\n"); printf("\n"); printf("Per-frame options (only used for subsequent images input):\n"); @@ -177,6 +178,14 @@ int main(int argc, const char* argv[]) { } else if (!strcmp(argv[c], "-h") || !strcmp(argv[c], "-help")) { Help(); goto End; + } else if (!strcmp(argv[c], "-version")) { + const int enc_version = WebPGetEncoderVersion(); + const int mux_version = WebPGetMuxVersion(); + printf("WebP Encoder version: %d.%d.%d\nWebP Mux version: %d.%d.%d\n", + (enc_version >> 16) & 0xff, (enc_version >> 8) & 0xff, + enc_version & 0xff, (mux_version >> 16) & 0xff, + (mux_version >> 8) & 0xff, mux_version & 0xff); + goto End; } else { continue; } diff --git a/man/img2webp.1 b/man/img2webp.1 index 910c7942..da1d91dc 100644 --- a/man/img2webp.1 +++ b/man/img2webp.1 @@ -1,5 +1,5 @@ .\" Hey, EMACS: -*- nroff -*- -.TH IMG2WEBP 1 "February 7, 2018" +.TH IMG2WEBP 1 "April 3, 2018" .SH NAME img2webp \- create animated WebP file from a sequence of input images. .SH SYNOPSIS @@ -53,6 +53,9 @@ Be more verbose. .TP .B \-h, \-help A short usage summary. +.TP +.B \-version +Print the version numbers of the relevant libraries used. .SH PER-FRAME OPTIONS The per-frame options are applied for the images following as arguments in the From b892b8ba8b31c060971d15da465cde7983d0312b Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 3 Apr 2018 12:55:01 -0700 Subject: [PATCH 08/23] makefile.unix,dist: use ascii for text output this prevents unknown escapes containing '-'s getting stripped on OS X when a tty targeted font is used Change-Id: I11d77f2984d9fd67a8b22948fb21e4c11396aec4 --- makefile.unix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile.unix b/makefile.unix index 826b956e..7881485a 100644 --- a/makefile.unix +++ b/makefile.unix @@ -474,7 +474,7 @@ dist: all for m in man/[cdv]webp.1 man/gif2webp.1 man/webpmux.1 \ man/img2webp.1 man/webpinfo.1; do \ basenam=$$(basename $$m .1); \ - $(GROFF) -t -e -man -T utf8 $$m \ + $(GROFF) -t -e -man -T ascii $$m \ | $(COL) -bx >$(DESTDIR)/doc/$${basenam}.txt; \ $(GROFF) -t -e -man -T html $$m \ | $(COL) -bx >$(DESTDIR)/doc/$${basenam}.html; \ From cd758a17454872ae73996dcfa3bcfb235f067895 Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 3 Apr 2018 18:02:27 -0700 Subject: [PATCH 09/23] {de,}mux/Makefile.am: add missing headers demux + mux: format_constants.h demux: decode.h (included by demux.h for anim_decode) Change-Id: I290a3416d4e47b4b6ebc14e99775d9db1ce5aec2 --- src/demux/Makefile.am | 3 +++ src/mux/Makefile.am | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/demux/Makefile.am b/src/demux/Makefile.am index ba9d9474..7e80bdc2 100644 --- a/src/demux/Makefile.am +++ b/src/demux/Makefile.am @@ -5,9 +5,12 @@ libwebpdemux_la_SOURCES = libwebpdemux_la_SOURCES += anim_decode.c demux.c libwebpdemuxinclude_HEADERS = +libwebpdemuxinclude_HEADERS += ../webp/decode.h libwebpdemuxinclude_HEADERS += ../webp/demux.h libwebpdemuxinclude_HEADERS += ../webp/mux_types.h libwebpdemuxinclude_HEADERS += ../webp/types.h +noinst_HEADERS = +noinst_HEADERS += ../webp/format_constants.h libwebpdemux_la_LIBADD = ../libwebp.la libwebpdemux_la_LDFLAGS = -no-undefined -version-info 2:4:0 diff --git a/src/mux/Makefile.am b/src/mux/Makefile.am index 771ff339..447bcce4 100644 --- a/src/mux/Makefile.am +++ b/src/mux/Makefile.am @@ -13,6 +13,8 @@ libwebpmuxinclude_HEADERS = libwebpmuxinclude_HEADERS += ../webp/mux.h libwebpmuxinclude_HEADERS += ../webp/mux_types.h libwebpmuxinclude_HEADERS += ../webp/types.h +noinst_HEADERS = +noinst_HEADERS += ../webp/format_constants.h libwebpmux_la_LIBADD = ../libwebp.la libwebpmux_la_LDFLAGS = -no-undefined -version-info 3:2:0 -lm From 3f157dd5e7693fbd7d0163213abc07e5f2f1e612 Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Tue, 3 Apr 2018 15:17:21 +0200 Subject: [PATCH 10/23] Remove some very hard TODOs. Change-Id: I3d1b0072e0ac9125840fbbd76e91d151c82489ec (cherry picked from commit 4033e1d70d8f25904b3a422bf60d7a8973bf688f) --- src/enc/histogram_enc.c | 2 +- src/enc/vp8l_enc.c | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/enc/histogram_enc.c b/src/enc/histogram_enc.c index aa840783..9fdbc627 100644 --- a/src/enc/histogram_enc.c +++ b/src/enc/histogram_enc.c @@ -1026,7 +1026,7 @@ int VP8LGetHistoImageSymbols(int xsize, int ysize, } } - // TODO(vikasa): Optimize HistogramRemap for low-effort compression mode also. + // TODO(vrabaud): Optimize HistogramRemap for low-effort compression mode. // Find the optimal map from original histograms to the final ones. HistogramRemap(orig_histo, image_histo, histogram_symbols); diff --git a/src/enc/vp8l_enc.c b/src/enc/vp8l_enc.c index 2b3f3486..a89184eb 100644 --- a/src/enc/vp8l_enc.c +++ b/src/enc/vp8l_enc.c @@ -382,8 +382,7 @@ static int EncoderAnalyze(VP8LEncoder* const enc, AnalyzeAndCreatePalette(pic, low_effort, enc->palette_, &enc->palette_size_); - // TODO(jyrki): replace the decision to be based on an actual estimate - // of entropy, or even spatial variance of entropy. + // Empirical bit sizes. enc->histo_bits_ = GetHistoBits(method, use_palette, pic->width, pic->height); enc->transform_bits_ = GetTransformBits(method, enc->histo_bits_); @@ -754,7 +753,6 @@ static WebPEncodingError StoreImageToBitMask( // Don't write the distance with the extra bits code since // the distance can be up to 18 bits of extra bits, and the prefix // 15 bits, totaling to 33, and our PutBits only supports up to 32 bits. - // TODO(jyrki): optimize this further. VP8LPrefixEncode(distance, &code, &n_bits, &bits); WriteHuffmanCode(bw, codes + 4, code); VP8LPutBits(bw, bits, n_bits); @@ -1876,7 +1874,6 @@ int VP8LEncodeImage(const WebPConfig* const config, err = VP8LEncodeStream(config, picture, &bw, 1 /*use_cache*/); if (err != VP8_ENC_OK) goto Error; - // TODO(skal): have a fine-grained progress report in VP8LEncodeStream(). if (!WebPReportProgress(picture, 90, &percent)) goto UserAbort; // Finish the RIFF chunk. From 8165e8fb3b15d5df8fb9c64256756e4a8c7875a8 Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Fri, 30 Mar 2018 10:58:33 +0200 Subject: [PATCH 11/23] Use proper targets for CMake. Also fix the bug where near lossless was not used and allow examples to be built by default. Change-Id: Ieb5ef77fafe83f3776ff4fd27a6d26534c7a51f3 (cherry picked from commit e155dda0cc110bcf36f9157d15cb355f7d102732) --- CMakeLists.txt | 141 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 101 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3b7a436..235c3f79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,16 +1,16 @@ -cmake_minimum_required(VERSION 2.8.7) +cmake_minimum_required(VERSION 3.5) -project(libwebp C) +project(WebP C) # Options for coder / decoder executables. option(WEBP_ENABLE_SIMD "Enable any SIMD optimization." ON) -option(WEBP_BUILD_CWEBP "Build the cwebp command line tool." OFF) -option(WEBP_BUILD_DWEBP "Build the dwebp command line tool." OFF) -option(WEBP_BUILD_GIF2WEBP "Build the gif2webp conversion tool." OFF) -option(WEBP_BUILD_IMG2WEBP "Build the img2webp animation tool." OFF) -option(WEBP_BUILD_WEBPINFO "Build the webpinfo command line tool." OFF) +option(WEBP_BUILD_CWEBP "Build the cwebp command line tool." ON) +option(WEBP_BUILD_DWEBP "Build the dwebp command line tool." ON) +option(WEBP_BUILD_GIF2WEBP "Build the gif2webp conversion tool." ON) +option(WEBP_BUILD_IMG2WEBP "Build the img2webp animation tool." ON) +option(WEBP_BUILD_WEBPINFO "Build the webpinfo command line tool." ON) option(WEBP_BUILD_WEBP_JS "Emscripten build of webp.js." OFF) -option(WEBP_ENABLE_NEAR_LOSSLESS "Enable near-lossless encoding" ON) +option(WEBP_NEAR_LOSSLESS "Enable near-lossless encoding" ON) option(WEBP_ENABLE_SWAP_16BIT_CSP "Enable byte swap for 16 bit colorspaces." OFF) if(WEBP_BUILD_WEBP_JS) @@ -22,12 +22,13 @@ set(WEBP_DEP_INCLUDE_DIRS) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE - "Build type: Release, Debug or RelWithDebInfo" STRING FORCE + "Build type: Release, Debug, MinSizeRel or RelWithDebInfo" STRING FORCE ) endif() # Include dependencies. include(cmake/deps.cmake) +include(GNUInstallDirs) ################################################################################ # Options. @@ -100,6 +101,11 @@ foreach(FILE ${WEBP_SIMD_FILES_NOT_TO_INCLUDE}) list(REMOVE_ITEM WEBP_DSP_DEC_SRCS ${FILE}) endforeach() +# Generate the config.h file. +configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/config.h.in + ${CMAKE_CURRENT_BINARY_DIR}/src/webp/config.h) +add_definitions(-DHAVE_CONFIG_H) + ### Define the mandatory libraries. # Build the webpdecoder library. if(MSVC) @@ -108,24 +114,62 @@ if(MSVC) else() add_definitions(-Wall) endif() -include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${WEBP_DEP_INCLUDE_DIRS}) +include_directories(${WEBP_DEP_INCLUDE_DIRS}) add_library(webpdecode OBJECT ${WEBP_DEC_SRCS}) +target_include_directories(webpdecode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) add_library(webpdspdecode OBJECT ${WEBP_DSP_COMMON_SRCS} ${WEBP_DSP_DEC_SRCS}) +target_include_directories(webpdspdecode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) add_library(webputilsdecode OBJECT ${WEBP_UTILS_COMMON_SRCS} - ${WEBP_UTILS_DEC_SRCS}) + ${WEBP_UTILS_DEC_SRCS} +) +target_include_directories(webputilsdecode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) add_library(webpdecoder $ $ $) target_link_libraries(webpdecoder ${WEBP_DEP_LIBRARIES}) +target_include_directories(webpdecoder + PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + INTERFACE $ +) +set_target_properties(webpdecoder PROPERTIES PUBLIC_HEADER +"${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h;\ +${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h" +) # Build the webp library. add_library(webpencode OBJECT ${WEBP_ENC_SRCS}) +target_include_directories(webpencode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) add_library(webpdsp OBJECT ${WEBP_DSP_COMMON_SRCS} ${WEBP_DSP_DEC_SRCS} ${WEBP_DSP_ENC_SRCS}) +target_include_directories(webpdsp PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) add_library(webputils OBJECT ${WEBP_UTILS_COMMON_SRCS} ${WEBP_UTILS_DEC_SRCS} ${WEBP_UTILS_ENC_SRCS}) +target_include_directories(webputils PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} +) add_library(webp $ $ $ $) target_link_libraries(webp ${WEBP_DEP_LIBRARIES}) +target_include_directories(webp + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + PUBLIC $ +) +set_target_properties(webp PROPERTIES PUBLIC_HEADER +"${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h;\ +${CMAKE_CURRENT_SOURCE_DIR}/src/webp/encode.h;\ +${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h" +) # Make sure the OBJECT libraries are built with position independent code # (it is not ON by default). @@ -135,6 +179,17 @@ set_target_properties(webpdecode webpdspdecode webputilsdecode # Build the webp demux library. add_library(webpdemux ${WEBP_DEMUX_SRCS}) target_link_libraries(webpdemux webp) +target_include_directories(webpdemux + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + PUBLIC $ +) +set_target_properties(webpdemux PROPERTIES PUBLIC_HEADER +"${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h;\ +${CMAKE_CURRENT_SOURCE_DIR}/src/webp/demux.h;\ +${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux_types.h;\ +${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h" +) # Set the version numbers. function(parse_version FILE NAME VAR) @@ -182,6 +237,8 @@ if(WEBP_BUILD_CWEBP OR WEBP_BUILD_DWEBP OR list(APPEND EXAMPLEUTIL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/examples/stopwatch.h) add_library(exampleutil ${EXAMPLEUTIL_SRCS}) + target_include_directories(exampleutil + PUBLIC $) parse_Makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/imageio "IMAGEIOUTILS_SRCS" "imageio_util_[^ ]*") @@ -213,9 +270,9 @@ if(WEBP_BUILD_DWEBP) "dwebp") add_executable(dwebp ${DWEBP_SRCS}) target_link_libraries(dwebp exampleutil imagedec imageenc webpdecoder) - install(TARGETS dwebp RUNTIME DESTINATION bin) + install(TARGETS dwebp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) set_property(TARGET dwebp PROPERTY INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src) + ${CMAKE_CURRENT_BINARY_DIR}/src) endif() if(WEBP_BUILD_CWEBP) @@ -225,9 +282,9 @@ if(WEBP_BUILD_CWEBP) "cwebp") add_executable(cwebp ${CWEBP_SRCS}) target_link_libraries(cwebp exampleutil imagedec webp) - install(TARGETS cwebp RUNTIME DESTINATION bin) + install(TARGETS cwebp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) set_property(TARGET cwebp PROPERTY INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src) + ${CMAKE_CURRENT_BINARY_DIR}/src) endif() if(WEBP_BUILD_GIF2WEBP AND NOT GIF_FOUND) @@ -239,9 +296,17 @@ if(WEBP_BUILD_GIF2WEBP OR WEBP_BUILD_IMG2WEBP) "") add_library(webpmux ${WEBP_MUX_SRCS}) target_link_libraries(webpmux webp) + target_include_directories(webpmux + PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}) parse_version(mux/Makefile.am webpmux WEBP_MUX_SOVERSION) set_target_properties(webpmux PROPERTIES VERSION ${PACKAGE_VERSION} SOVERSION ${WEBP_MUX_SOVERSION}) + set_target_properties(webpmux PROPERTIES PUBLIC_HEADER +"${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux.h;\ +${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux_types.h;\ +${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h;" + ) list(APPEND INSTALLED_LIBRARIES webpmux) endif() @@ -253,9 +318,9 @@ if(WEBP_BUILD_GIF2WEBP) add_executable(gif2webp ${GIF2WEBP_SRCS}) target_link_libraries(gif2webp exampleutil imageioutil webp webpmux ${WEBP_DEP_GIF_LIBRARIES}) - install(TARGETS gif2webp RUNTIME DESTINATION bin) + install(TARGETS gif2webp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) set_property(TARGET gif2webp PROPERTY INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src) + ${CMAKE_CURRENT_BINARY_DIR}/src) endif() if(WEBP_BUILD_IMG2WEBP) @@ -265,9 +330,9 @@ if(WEBP_BUILD_IMG2WEBP) "img2webp") add_executable(img2webp ${IMG2WEBP_SRCS}) target_link_libraries(img2webp exampleutil imagedec imageioutil webp webpmux) - install(TARGETS img2webp RUNTIME DESTINATION bin) + install(TARGETS img2webp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) set_property(TARGET img2webp PROPERTY INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src) + ${CMAKE_CURRENT_BINARY_DIR}/src) endif() if (WEBP_BUILD_WEBPINFO) @@ -277,7 +342,7 @@ if (WEBP_BUILD_WEBPINFO) "webpinfo") add_executable(webpinfo ${WEBPINFO_SRCS}) target_link_libraries(webpinfo exampleutil imageioutil) - install(TARGETS webpinfo RUNTIME DESTINATION bin) + install(TARGETS webpinfo RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) set_property(TARGET webpinfo PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src) endif() @@ -307,25 +372,22 @@ if(WEBP_BUILD_WEBP_JS) target_compile_definitions(webpdecoder PUBLIC EMSCRIPTEN) endif() -# Generate the config.h file. -configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/config.h.in - ${CMAKE_CURRENT_BINARY_DIR}/src/webp/config.h) -add_definitions(-DHAVE_CONFIG_H) -# The webp folder is included as we reference config.h as -# ../webp/config.h or webp/config.h -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - # Install the different headers and libraries. -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/demux.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/encode.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux_types.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h - DESTINATION include/webp) -install(TARGETS ${INSTALLED_LIBRARIES} - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) +include(GNUInstallDirs) +install( + TARGETS ${INSTALLED_LIBRARIES} + EXPORT ${PROJECT_NAME}Targets + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webp + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) +set(ConfigPackageLocation ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake/) +install(EXPORT ${PROJECT_NAME}Targets + NAMESPACE ${PROJECT_NAME}:: + DESTINATION ${ConfigPackageLocation} +) # Create the CMake version file. include(CMakePackageConfigHelpers) @@ -337,7 +399,6 @@ write_basic_package_version_file( # Create the Config file. include(CMakePackageConfigHelpers) -set(ConfigPackageLocation share/WebP/cmake/) configure_package_config_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/WebPConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/WebPConfig.cmake @@ -364,7 +425,7 @@ foreach(I_MAN RANGE ${MAN_PAGES_RANGE}) if(WEBP_BUILD_${EXEC_BUILD}) list(GET MAN_PAGES ${I_MAN} MAN_PAGE) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/man/${MAN_PAGE} - DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1 + DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc ) endif() From 2f930e0872c8ce1f59b17f9a48257cf4e58b0e2c Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 3 Apr 2018 19:52:18 -0700 Subject: [PATCH 12/23] Revert "Use proper targets for CMake." This reverts commit 8165e8fb3b15d5df8fb9c64256756e4a8c7875a8. breaks webp_js builds: missing includes, multiply defined symbols Change-Id: I8df7eda3974e708c2a96b98600ec69981ec7aacb --- CMakeLists.txt | 141 ++++++++++++++----------------------------------- 1 file changed, 40 insertions(+), 101 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 235c3f79..a3b7a436 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,16 +1,16 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 2.8.7) -project(WebP C) +project(libwebp C) # Options for coder / decoder executables. option(WEBP_ENABLE_SIMD "Enable any SIMD optimization." ON) -option(WEBP_BUILD_CWEBP "Build the cwebp command line tool." ON) -option(WEBP_BUILD_DWEBP "Build the dwebp command line tool." ON) -option(WEBP_BUILD_GIF2WEBP "Build the gif2webp conversion tool." ON) -option(WEBP_BUILD_IMG2WEBP "Build the img2webp animation tool." ON) -option(WEBP_BUILD_WEBPINFO "Build the webpinfo command line tool." ON) +option(WEBP_BUILD_CWEBP "Build the cwebp command line tool." OFF) +option(WEBP_BUILD_DWEBP "Build the dwebp command line tool." OFF) +option(WEBP_BUILD_GIF2WEBP "Build the gif2webp conversion tool." OFF) +option(WEBP_BUILD_IMG2WEBP "Build the img2webp animation tool." OFF) +option(WEBP_BUILD_WEBPINFO "Build the webpinfo command line tool." OFF) option(WEBP_BUILD_WEBP_JS "Emscripten build of webp.js." OFF) -option(WEBP_NEAR_LOSSLESS "Enable near-lossless encoding" ON) +option(WEBP_ENABLE_NEAR_LOSSLESS "Enable near-lossless encoding" ON) option(WEBP_ENABLE_SWAP_16BIT_CSP "Enable byte swap for 16 bit colorspaces." OFF) if(WEBP_BUILD_WEBP_JS) @@ -22,13 +22,12 @@ set(WEBP_DEP_INCLUDE_DIRS) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE - "Build type: Release, Debug, MinSizeRel or RelWithDebInfo" STRING FORCE + "Build type: Release, Debug or RelWithDebInfo" STRING FORCE ) endif() # Include dependencies. include(cmake/deps.cmake) -include(GNUInstallDirs) ################################################################################ # Options. @@ -101,11 +100,6 @@ foreach(FILE ${WEBP_SIMD_FILES_NOT_TO_INCLUDE}) list(REMOVE_ITEM WEBP_DSP_DEC_SRCS ${FILE}) endforeach() -# Generate the config.h file. -configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/config.h.in - ${CMAKE_CURRENT_BINARY_DIR}/src/webp/config.h) -add_definitions(-DHAVE_CONFIG_H) - ### Define the mandatory libraries. # Build the webpdecoder library. if(MSVC) @@ -114,62 +108,24 @@ if(MSVC) else() add_definitions(-Wall) endif() -include_directories(${WEBP_DEP_INCLUDE_DIRS}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${WEBP_DEP_INCLUDE_DIRS}) add_library(webpdecode OBJECT ${WEBP_DEC_SRCS}) -target_include_directories(webpdecode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} -) add_library(webpdspdecode OBJECT ${WEBP_DSP_COMMON_SRCS} ${WEBP_DSP_DEC_SRCS}) -target_include_directories(webpdspdecode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} -) add_library(webputilsdecode OBJECT ${WEBP_UTILS_COMMON_SRCS} - ${WEBP_UTILS_DEC_SRCS} -) -target_include_directories(webputilsdecode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} -) + ${WEBP_UTILS_DEC_SRCS}) add_library(webpdecoder $ $ $) target_link_libraries(webpdecoder ${WEBP_DEP_LIBRARIES}) -target_include_directories(webpdecoder - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - INTERFACE $ -) -set_target_properties(webpdecoder PROPERTIES PUBLIC_HEADER -"${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h;\ -${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h" -) # Build the webp library. add_library(webpencode OBJECT ${WEBP_ENC_SRCS}) -target_include_directories(webpencode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} -) add_library(webpdsp OBJECT ${WEBP_DSP_COMMON_SRCS} ${WEBP_DSP_DEC_SRCS} ${WEBP_DSP_ENC_SRCS}) -target_include_directories(webpdsp PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} -) add_library(webputils OBJECT ${WEBP_UTILS_COMMON_SRCS} ${WEBP_UTILS_DEC_SRCS} ${WEBP_UTILS_ENC_SRCS}) -target_include_directories(webputils PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} -) add_library(webp $ $ $ $) target_link_libraries(webp ${WEBP_DEP_LIBRARIES}) -target_include_directories(webp - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - PUBLIC $ -) -set_target_properties(webp PROPERTIES PUBLIC_HEADER -"${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h;\ -${CMAKE_CURRENT_SOURCE_DIR}/src/webp/encode.h;\ -${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h" -) # Make sure the OBJECT libraries are built with position independent code # (it is not ON by default). @@ -179,17 +135,6 @@ set_target_properties(webpdecode webpdspdecode webputilsdecode # Build the webp demux library. add_library(webpdemux ${WEBP_DEMUX_SRCS}) target_link_libraries(webpdemux webp) -target_include_directories(webpdemux - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - PUBLIC $ -) -set_target_properties(webpdemux PROPERTIES PUBLIC_HEADER -"${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h;\ -${CMAKE_CURRENT_SOURCE_DIR}/src/webp/demux.h;\ -${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux_types.h;\ -${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h" -) # Set the version numbers. function(parse_version FILE NAME VAR) @@ -237,8 +182,6 @@ if(WEBP_BUILD_CWEBP OR WEBP_BUILD_DWEBP OR list(APPEND EXAMPLEUTIL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/examples/stopwatch.h) add_library(exampleutil ${EXAMPLEUTIL_SRCS}) - target_include_directories(exampleutil - PUBLIC $) parse_Makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/imageio "IMAGEIOUTILS_SRCS" "imageio_util_[^ ]*") @@ -270,9 +213,9 @@ if(WEBP_BUILD_DWEBP) "dwebp") add_executable(dwebp ${DWEBP_SRCS}) target_link_libraries(dwebp exampleutil imagedec imageenc webpdecoder) - install(TARGETS dwebp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(TARGETS dwebp RUNTIME DESTINATION bin) set_property(TARGET dwebp PROPERTY INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_BINARY_DIR}/src) + ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src) endif() if(WEBP_BUILD_CWEBP) @@ -282,9 +225,9 @@ if(WEBP_BUILD_CWEBP) "cwebp") add_executable(cwebp ${CWEBP_SRCS}) target_link_libraries(cwebp exampleutil imagedec webp) - install(TARGETS cwebp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(TARGETS cwebp RUNTIME DESTINATION bin) set_property(TARGET cwebp PROPERTY INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_BINARY_DIR}/src) + ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src) endif() if(WEBP_BUILD_GIF2WEBP AND NOT GIF_FOUND) @@ -296,17 +239,9 @@ if(WEBP_BUILD_GIF2WEBP OR WEBP_BUILD_IMG2WEBP) "") add_library(webpmux ${WEBP_MUX_SRCS}) target_link_libraries(webpmux webp) - target_include_directories(webpmux - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}) parse_version(mux/Makefile.am webpmux WEBP_MUX_SOVERSION) set_target_properties(webpmux PROPERTIES VERSION ${PACKAGE_VERSION} SOVERSION ${WEBP_MUX_SOVERSION}) - set_target_properties(webpmux PROPERTIES PUBLIC_HEADER -"${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux.h;\ -${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux_types.h;\ -${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h;" - ) list(APPEND INSTALLED_LIBRARIES webpmux) endif() @@ -318,9 +253,9 @@ if(WEBP_BUILD_GIF2WEBP) add_executable(gif2webp ${GIF2WEBP_SRCS}) target_link_libraries(gif2webp exampleutil imageioutil webp webpmux ${WEBP_DEP_GIF_LIBRARIES}) - install(TARGETS gif2webp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(TARGETS gif2webp RUNTIME DESTINATION bin) set_property(TARGET gif2webp PROPERTY INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_BINARY_DIR}/src) + ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src) endif() if(WEBP_BUILD_IMG2WEBP) @@ -330,9 +265,9 @@ if(WEBP_BUILD_IMG2WEBP) "img2webp") add_executable(img2webp ${IMG2WEBP_SRCS}) target_link_libraries(img2webp exampleutil imagedec imageioutil webp webpmux) - install(TARGETS img2webp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(TARGETS img2webp RUNTIME DESTINATION bin) set_property(TARGET img2webp PROPERTY INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_BINARY_DIR}/src) + ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src) endif() if (WEBP_BUILD_WEBPINFO) @@ -342,7 +277,7 @@ if (WEBP_BUILD_WEBPINFO) "webpinfo") add_executable(webpinfo ${WEBPINFO_SRCS}) target_link_libraries(webpinfo exampleutil imageioutil) - install(TARGETS webpinfo RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(TARGETS webpinfo RUNTIME DESTINATION bin) set_property(TARGET webpinfo PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src) endif() @@ -372,22 +307,25 @@ if(WEBP_BUILD_WEBP_JS) target_compile_definitions(webpdecoder PUBLIC EMSCRIPTEN) endif() +# Generate the config.h file. +configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/config.h.in + ${CMAKE_CURRENT_BINARY_DIR}/src/webp/config.h) +add_definitions(-DHAVE_CONFIG_H) +# The webp folder is included as we reference config.h as +# ../webp/config.h or webp/config.h +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + # Install the different headers and libraries. -include(GNUInstallDirs) -install( - TARGETS ${INSTALLED_LIBRARIES} - EXPORT ${PROJECT_NAME}Targets - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webp - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) -set(ConfigPackageLocation ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake/) -install(EXPORT ${PROJECT_NAME}Targets - NAMESPACE ${PROJECT_NAME}:: - DESTINATION ${ConfigPackageLocation} -) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/demux.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/encode.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h + DESTINATION include/webp) +install(TARGETS ${INSTALLED_LIBRARIES} + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) # Create the CMake version file. include(CMakePackageConfigHelpers) @@ -399,6 +337,7 @@ write_basic_package_version_file( # Create the Config file. include(CMakePackageConfigHelpers) +set(ConfigPackageLocation share/WebP/cmake/) configure_package_config_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/WebPConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/WebPConfig.cmake @@ -425,7 +364,7 @@ foreach(I_MAN RANGE ${MAN_PAGES_RANGE}) if(WEBP_BUILD_${EXEC_BUILD}) list(GET MAN_PAGES ${I_MAN} MAN_PAGE) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/man/${MAN_PAGE} - DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1 COMPONENT doc ) endif() From 882784b03d9e6a3f2847d7322c7b32076a6a6d87 Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 3 Apr 2018 19:09:18 -0700 Subject: [PATCH 13/23] update ChangeLog Change-Id: I7e38d9beb2d733b85f56a44add8481cb45faf698 --- ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 846fd0cf..00941d12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2f930e08 Revert "Use proper targets for CMake." +8165e8fb Use proper targets for CMake. +3f157dd5 Remove some very hard TODOs. +cd758a17 {de,}mux/Makefile.am: add missing headers +b892b8ba makefile.unix,dist: use ascii for text output +64a57d05 add -version option to anim_dump,anim_diff and img2webp +fc1b8e3a webp_js: fix webp_js demo html +15aa48d9 update ChangeLog e607dabc update AUTHORS 38410c08 [CFI] Remove function pointer casts c57b2736 bump version to 1.0.0 From d898dc14a5af750d07db3c3daf932478bc9581ba Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Mon, 9 Apr 2018 18:14:57 +0200 Subject: [PATCH 14/23] fix bug in WebPImport565: alpha value was not set Change-Id: I2af4efb3c6ed49800bc16dbd4a997f7a95931918 --- extras/extras.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/extras/extras.c b/extras/extras.c index dcb30395..2feb595c 100644 --- a/extras/extras.c +++ b/extras/extras.c @@ -48,13 +48,14 @@ int WebPImportGray(const uint8_t* gray_data, WebPPicture* pic) { int WebPImportRGB565(const uint8_t* rgb565, WebPPicture* pic) { int x, y; + uint32_t* dst; if (pic == NULL || rgb565 == NULL) return 0; pic->colorspace = WEBP_YUV420; pic->use_argb = 1; if (!WebPPictureAlloc(pic)) return 0; + dst = pic->argb; for (y = 0; y < pic->height; ++y) { const int width = pic->width; - uint32_t* dst = pic->argb + y * pic->argb_stride; for (x = 0; x < width; ++x) { #ifdef WEBP_SWAP_16BIT_CSP const uint32_t rg = rgb565[2 * x + 1]; @@ -70,22 +71,24 @@ int WebPImportRGB565(const uint8_t* rgb565, WebPPicture* pic) { r = r | (r >> 5); g = g | (g >> 6); b = b | (b >> 5); - dst[x] = (r << 16) | (g << 8) | b; + dst[x] = (0xffu << 24) | (r << 16) | (g << 8) | b; } rgb565 += 2 * width; + dst += pic->argb_stride; } return 1; } int WebPImportRGB4444(const uint8_t* rgb4444, WebPPicture* pic) { int x, y; + uint32_t* dst; if (pic == NULL || rgb4444 == NULL) return 0; pic->colorspace = WEBP_YUV420; pic->use_argb = 1; if (!WebPPictureAlloc(pic)) return 0; + dst = pic->argb; for (y = 0; y < pic->height; ++y) { const int width = pic->width; - uint32_t* dst = pic->argb + y * pic->argb_stride; for (x = 0; x < width; ++x) { #ifdef WEBP_SWAP_16BIT_CSP const uint32_t rg = rgb4444[2 * x + 1]; @@ -106,6 +109,7 @@ int WebPImportRGB4444(const uint8_t* rgb4444, WebPPicture* pic) { dst[x] = (a << 24) | (r << 16) | (g << 8) | b; } rgb4444 += 2 * width; + dst += pic->argb_stride; } return 1; } From f5565ca84afc956232f8dcc635a9d133e210f88e Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Tue, 10 Apr 2018 20:32:00 +0200 Subject: [PATCH 15/23] cmake: Make sure we use near-lossless by default. The name of the CMake variable needs to be the same as the C define used in cmake/config.h.in. Change-Id: Id56d338617f6e4ed5f1da7ce01006d324ef4989f --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3b7a436..ea263b3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ option(WEBP_BUILD_GIF2WEBP "Build the gif2webp conversion tool." OFF) option(WEBP_BUILD_IMG2WEBP "Build the img2webp animation tool." OFF) option(WEBP_BUILD_WEBPINFO "Build the webpinfo command line tool." OFF) option(WEBP_BUILD_WEBP_JS "Emscripten build of webp.js." OFF) -option(WEBP_ENABLE_NEAR_LOSSLESS "Enable near-lossless encoding" ON) +option(WEBP_NEAR_LOSSLESS "Enable near-lossless encoding" ON) option(WEBP_ENABLE_SWAP_16BIT_CSP "Enable byte swap for 16 bit colorspaces." OFF) if(WEBP_BUILD_WEBP_JS) From 99be34b3a89b3f24b6773a9d6a69d54dfdd9e19f Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 10 Apr 2018 15:51:23 -0700 Subject: [PATCH 16/23] cwebp,get_disto: fix bpp output bits-per-pixel were intended, not bytes-per-pixel Change-Id: I023349013ac5956154ab4526bd1e195dfe95b8ab (cherry picked from commit e122e511cf091bb31d7f42503497029abc60256c) --- examples/cwebp.c | 4 ++-- extras/get_disto.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/cwebp.c b/examples/cwebp.c index 164b57fe..de7190bd 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -188,7 +188,7 @@ static void PrintExtraInfoLossless(const WebPPicture* const pic, fprintf(stderr, "File: %s\n", file_name); fprintf(stderr, "Dimension: %d x %d\n", pic->width, pic->height); fprintf(stderr, "Output: %d bytes (%.2f bpp)\n", stats->coded_size, - 1.f * stats->coded_size / pic->width / pic->height); + 8.f * stats->coded_size / pic->width / pic->height); PrintFullLosslessInfo(stats, "ARGB"); } } @@ -213,7 +213,7 @@ static void PrintExtraInfoLossy(const WebPPicture* const pic, int short_output, " (%.2f bpp)\n", stats->coded_size, stats->PSNR[0], stats->PSNR[1], stats->PSNR[2], stats->PSNR[3], - 1.f * stats->coded_size / pic->width / pic->height); + 8.f * stats->coded_size / pic->width / pic->height); if (total > 0) { int totals[4] = { 0, 0, 0, 0 }; fprintf(stderr, "block count: intra4: %6d (%.2f%%)\n" diff --git a/extras/get_disto.c b/extras/get_disto.c index 23914f2b..b4061477 100644 --- a/extras/get_disto.c +++ b/extras/get_disto.c @@ -293,7 +293,7 @@ int main(int argc, const char *argv[]) { printf("%u %.2f %.2f %.2f %.2f %.2f [ %.2f bpp ]\n", (unsigned int)size1, disto[4], disto[0], disto[1], disto[2], disto[3], - 1.f * size1 / pic1.width / pic1.height); + 8.f * size1 / pic1.width / pic1.height); if (output != NULL) { uint8_t* data = NULL; From e577feb7c2108e0ac2ef115bf14a2f719d6e0889 Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Wed, 11 Apr 2018 13:45:53 +0200 Subject: [PATCH 17/23] makefile.unix: add DEBUG flag for compiling w/ debug-symbol usage example: make -f makefile.unix DEBUG= Change-Id: I5aefe026a3364e5db5e0220b9fa506687cb98a8d --- makefile.unix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/makefile.unix b/makefile.unix index 7881485a..cc0035df 100644 --- a/makefile.unix +++ b/makefile.unix @@ -112,7 +112,12 @@ endif AR = ar ARFLAGS = r CPPFLAGS = -I. -Isrc/ -Wall -CFLAGS = -O3 -DNDEBUG $(EXTRA_FLAGS) +ifeq ($(DEBUG), 1) + CFLAGS = -g +else + CFLAGS = -O3 -DNDEBUG +endif +CFLAGS += $(EXTRA_FLAGS) CC = gcc INSTALL = install GROFF = /usr/bin/groff From c1cb86af5f9cdea7afe2fff54d0e04b085d1e186 Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Wed, 11 Apr 2018 15:17:14 +0200 Subject: [PATCH 18/23] fix 16b overflow in SSE2 the 'accum' variable can be larger than 15b for large rescale values. Assert triggered: src/dsp/rescaler_sse2.c:249: RescalerExportRowExpand_SSE2: Assertion `v >= 0 && v <= 255' failed. src/dsp/rescaler_sse2.c:350: RescalerExportRowShrink_SSE2: Assertion `v >= 0 && v <= 255' failed. -> fall back to C implementation in this case for now Change-Id: I7ea1cb72301cafc1459be403f6a6f4e3cbc89bb1 --- src/dsp/rescaler_sse2.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/dsp/rescaler_sse2.c b/src/dsp/rescaler_sse2.c index f93b204f..64c50dea 100644 --- a/src/dsp/rescaler_sse2.c +++ b/src/dsp/rescaler_sse2.c @@ -36,7 +36,7 @@ static void LoadTwoPixels_SSE2(const uint8_t* const src, __m128i* out) { } // input: 8 bytes ABCDEFGH -> output: A0B0C0D0E0F0G0H0 -static void LoadHeightPixels_SSE2(const uint8_t* const src, __m128i* out) { +static void LoadEightPixels_SSE2(const uint8_t* const src, __m128i* out) { const __m128i zero = _mm_setzero_si128(); const __m128i A = _mm_loadl_epi64((const __m128i*)(src)); // ABCDEFGH *out = _mm_unpacklo_epi8(A, zero); @@ -50,13 +50,15 @@ static void RescalerImportRowExpand_SSE2(WebPRescaler* const wrk, int accum = x_add; __m128i cur_pixels; + // SSE2 implementation only works with 16b signed arithmetic at max. + if (wrk->src_width < 8 || accum >= (1 << 15)) { + WebPRescalerImportRowExpand_C(wrk, src); + return; + } + assert(!WebPRescalerInputDone(wrk)); assert(wrk->x_expand); if (wrk->num_channels == 4) { - if (wrk->src_width < 2) { - WebPRescalerImportRowExpand_C(wrk, src); - return; - } LoadTwoPixels_SSE2(src, &cur_pixels); src += 4; while (1) { @@ -75,11 +77,7 @@ static void RescalerImportRowExpand_SSE2(WebPRescaler* const wrk, } else { int left; const uint8_t* const src_limit = src + wrk->src_width - 8; - if (wrk->src_width < 8) { - WebPRescalerImportRowExpand_C(wrk, src); - return; - } - LoadHeightPixels_SSE2(src, &cur_pixels); + LoadEightPixels_SSE2(src, &cur_pixels); src += 7; left = 7; while (1) { @@ -94,7 +92,7 @@ static void RescalerImportRowExpand_SSE2(WebPRescaler* const wrk, if (--left) { cur_pixels = _mm_srli_si128(cur_pixels, 2); } else if (src <= src_limit) { - LoadHeightPixels_SSE2(src, &cur_pixels); + LoadEightPixels_SSE2(src, &cur_pixels); src += 7; left = 7; } else { // tail From 0d5fad46cf5e78906dee006614587656d07648f4 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 16 Apr 2018 20:19:54 -0700 Subject: [PATCH 19/23] add WEBP_DSP_INIT / WEBP_DSP_INIT_FUNC this internalizes the init checks and provides stronger synchronization with pthreads when available while still allowing VP8GetCPUInfo to be modified (mostly for testing purposes). windows is left as is since a critical section or mutex would cause a leak. Change-Id: Ieb997e014f2805c0ae39c16f13337663521356f4 (cherry picked from commit d77bf512bd0c4ff53019e357a2d24f6c4e3fbefc) --- src/dec/vp8_dec.c | 2 +- src/dsp/alpha_processing.c | 9 +-------- src/dsp/cost.c | 9 +-------- src/dsp/dec.c | 9 +-------- src/dsp/dsp.h | 38 ++++++++++++++++++++++++++++++++++++- src/dsp/enc.c | 9 +-------- src/dsp/filters.c | 9 +-------- src/dsp/lossless.c | 9 +-------- src/dsp/lossless_enc.c | 9 +-------- src/dsp/rescaler.c | 7 +------ src/dsp/ssim.c | 9 +-------- src/dsp/upsampling.c | 16 ++-------------- src/dsp/yuv.c | 17 ++--------------- src/enc/near_lossless_enc.c | 2 +- src/enc/picture_csp_enc.c | 4 ++-- 15 files changed, 54 insertions(+), 104 deletions(-) diff --git a/src/dec/vp8_dec.c b/src/dec/vp8_dec.c index 6212efd1..c904b529 100644 --- a/src/dec/vp8_dec.c +++ b/src/dec/vp8_dec.c @@ -491,7 +491,7 @@ static int GetCoeffsAlt(VP8BitReader* const br, return 16; } -WEBP_TSAN_IGNORE_FUNCTION static void InitGetCoeffs(void) { +static WEBP_TSAN_IGNORE_FUNCTION void InitGetCoeffs(void) { if (GetCoeffs == NULL) { if (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kSlowSSSE3)) { GetCoeffs = GetCoeffsAlt; diff --git a/src/dsp/alpha_processing.c b/src/dsp/alpha_processing.c index 995b4345..819d1391 100644 --- a/src/dsp/alpha_processing.c +++ b/src/dsp/alpha_processing.c @@ -409,12 +409,7 @@ extern void WebPInitAlphaProcessingSSE2(void); extern void WebPInitAlphaProcessingSSE41(void); extern void WebPInitAlphaProcessingNEON(void); -static volatile VP8CPUInfo alpha_processing_last_cpuinfo_used = - (VP8CPUInfo)&alpha_processing_last_cpuinfo_used; - -WEBP_TSAN_IGNORE_FUNCTION void WebPInitAlphaProcessing(void) { - if (alpha_processing_last_cpuinfo_used == VP8GetCPUInfo) return; - +WEBP_DSP_INIT_FUNC(WebPInitAlphaProcessing) { WebPMultARGBRow = WebPMultARGBRow_C; WebPMultRow = WebPMultRow_C; WebPApplyAlphaMultiply4444 = ApplyAlphaMultiply_16b_C; @@ -474,6 +469,4 @@ WEBP_TSAN_IGNORE_FUNCTION void WebPInitAlphaProcessing(void) { assert(WebPPackRGB != NULL); assert(WebPHasAlpha8b != NULL); assert(WebPHasAlpha32b != NULL); - - alpha_processing_last_cpuinfo_used = VP8GetCPUInfo; } diff --git a/src/dsp/cost.c b/src/dsp/cost.c index a732389d..634ccc20 100644 --- a/src/dsp/cost.c +++ b/src/dsp/cost.c @@ -378,12 +378,7 @@ extern void VP8EncDspCostInitMIPS32(void); extern void VP8EncDspCostInitMIPSdspR2(void); extern void VP8EncDspCostInitSSE2(void); -static volatile VP8CPUInfo cost_last_cpuinfo_used = - (VP8CPUInfo)&cost_last_cpuinfo_used; - -WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspCostInit(void) { - if (cost_last_cpuinfo_used == VP8GetCPUInfo) return; - +WEBP_DSP_INIT_FUNC(VP8EncDspCostInit) { VP8GetResidualCost = GetResidualCost_C; VP8SetResidualCoeffs = SetResidualCoeffs_C; @@ -405,8 +400,6 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspCostInit(void) { } #endif } - - cost_last_cpuinfo_used = VP8GetCPUInfo; } //------------------------------------------------------------------------------ diff --git a/src/dsp/dec.c b/src/dsp/dec.c index 7e824075..1119842d 100644 --- a/src/dsp/dec.c +++ b/src/dsp/dec.c @@ -741,12 +741,7 @@ extern void VP8DspInitMIPS32(void); extern void VP8DspInitMIPSdspR2(void); extern void VP8DspInitMSA(void); -static volatile VP8CPUInfo dec_last_cpuinfo_used = - (VP8CPUInfo)&dec_last_cpuinfo_used; - -WEBP_TSAN_IGNORE_FUNCTION void VP8DspInit(void) { - if (dec_last_cpuinfo_used == VP8GetCPUInfo) return; - +WEBP_DSP_INIT_FUNC(VP8DspInit) { VP8InitClipTables(); #if !WEBP_NEON_OMIT_C_CODE @@ -889,6 +884,4 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8DspInit(void) { assert(VP8PredChroma8[5] != NULL); assert(VP8PredChroma8[6] != NULL); assert(VP8DitherCombine8x8 != NULL); - - dec_last_cpuinfo_used = VP8GetCPUInfo; } diff --git a/src/dsp/dsp.h b/src/dsp/dsp.h index 5146949e..4ab77a51 100644 --- a/src/dsp/dsp.h +++ b/src/dsp/dsp.h @@ -141,6 +141,42 @@ extern "C" { #endif #endif +#if defined(WEBP_USE_THREAD) && !defined(_WIN32) +#include // NOLINT + +#define WEBP_DSP_INIT(func) do { \ + static volatile VP8CPUInfo func ## _last_cpuinfo_used = \ + (VP8CPUInfo)&func ## _last_cpuinfo_used; \ + static pthread_mutex_t func ## _lock = PTHREAD_MUTEX_INITIALIZER; \ + if (pthread_mutex_lock(&func ## _lock)) break; \ + if (func ## _last_cpuinfo_used != VP8GetCPUInfo) func(); \ + func ## _last_cpuinfo_used = VP8GetCPUInfo; \ + (void)pthread_mutex_unlock(&func ## _lock); \ +} while (0) +#else // !(defined(WEBP_USE_THREAD) && !defined(_WIN32)) +#define WEBP_DSP_INIT(func) do { \ + static volatile VP8CPUInfo func ## _last_cpuinfo_used = \ + (VP8CPUInfo)&func ## _last_cpuinfo_used; \ + if (func ## _last_cpuinfo_used == VP8GetCPUInfo) break; \ + func(); \ + func ## _last_cpuinfo_used = VP8GetCPUInfo; \ +} while (0) +#endif // defined(WEBP_USE_THREAD) && !defined(_WIN32) + +// Defines an Init + helper function that control multiple initialization of +// function pointers / tables. +/* Usage: + WEBP_DSP_INIT_FUNC(InitFunc) { + ...function body + } +*/ +#define WEBP_DSP_INIT_FUNC(name) \ + static WEBP_TSAN_IGNORE_FUNCTION void name ## _body(void); \ + WEBP_TSAN_IGNORE_FUNCTION void name(void) { \ + WEBP_DSP_INIT(name ## _body); \ + } \ + static WEBP_TSAN_IGNORE_FUNCTION void name ## _body(void) + #define WEBP_UBSAN_IGNORE_UNDEF #define WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW #if defined(__clang__) && defined(__has_attribute) @@ -196,7 +232,7 @@ WEBP_EXTERN VP8CPUInfo VP8GetCPUInfo; // avoiding a compiler warning. #define WEBP_DSP_INIT_STUB(func) \ extern void func(void); \ - WEBP_TSAN_IGNORE_FUNCTION void func(void) {} + void func(void) {} //------------------------------------------------------------------------------ // Encoding diff --git a/src/dsp/enc.c b/src/dsp/enc.c index 1c807f1d..fa23b40a 100644 --- a/src/dsp/enc.c +++ b/src/dsp/enc.c @@ -740,12 +740,7 @@ extern void VP8EncDspInitMIPS32(void); extern void VP8EncDspInitMIPSdspR2(void); extern void VP8EncDspInitMSA(void); -static volatile VP8CPUInfo enc_last_cpuinfo_used = - (VP8CPUInfo)&enc_last_cpuinfo_used; - -WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspInit(void) { - if (enc_last_cpuinfo_used == VP8GetCPUInfo) return; - +WEBP_DSP_INIT_FUNC(VP8EncDspInit) { VP8DspInit(); // common inverse transforms InitTables(); @@ -838,6 +833,4 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspInit(void) { assert(VP8EncQuantizeBlockWHT != NULL); assert(VP8Copy4x4 != NULL); assert(VP8Copy16x8 != NULL); - - enc_last_cpuinfo_used = VP8GetCPUInfo; } diff --git a/src/dsp/filters.c b/src/dsp/filters.c index ca5f877d..069a22ea 100644 --- a/src/dsp/filters.c +++ b/src/dsp/filters.c @@ -238,12 +238,7 @@ extern void VP8FiltersInitMSA(void); extern void VP8FiltersInitNEON(void); extern void VP8FiltersInitSSE2(void); -static volatile VP8CPUInfo filters_last_cpuinfo_used = - (VP8CPUInfo)&filters_last_cpuinfo_used; - -WEBP_TSAN_IGNORE_FUNCTION void VP8FiltersInit(void) { - if (filters_last_cpuinfo_used == VP8GetCPUInfo) return; - +WEBP_DSP_INIT_FUNC(VP8FiltersInit) { WebPUnfilters[WEBP_FILTER_NONE] = NULL; #if !WEBP_NEON_OMIT_C_CODE WebPUnfilters[WEBP_FILTER_HORIZONTAL] = HorizontalUnfilter_C; @@ -289,6 +284,4 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8FiltersInit(void) { assert(WebPFilters[WEBP_FILTER_HORIZONTAL] != NULL); assert(WebPFilters[WEBP_FILTER_VERTICAL] != NULL); assert(WebPFilters[WEBP_FILTER_GRADIENT] != NULL); - - filters_last_cpuinfo_used = VP8GetCPUInfo; } diff --git a/src/dsp/lossless.c b/src/dsp/lossless.c index 83f553d9..f9b3c182 100644 --- a/src/dsp/lossless.c +++ b/src/dsp/lossless.c @@ -577,9 +577,6 @@ extern void VP8LDspInitNEON(void); extern void VP8LDspInitMIPSdspR2(void); extern void VP8LDspInitMSA(void); -static volatile VP8CPUInfo lossless_last_cpuinfo_used = - (VP8CPUInfo)&lossless_last_cpuinfo_used; - #define COPY_PREDICTOR_ARRAY(IN, OUT) do { \ (OUT)[0] = IN##0_C; \ (OUT)[1] = IN##1_C; \ @@ -599,9 +596,7 @@ static volatile VP8CPUInfo lossless_last_cpuinfo_used = (OUT)[15] = IN##0_C; \ } while (0); -WEBP_TSAN_IGNORE_FUNCTION void VP8LDspInit(void) { - if (lossless_last_cpuinfo_used == VP8GetCPUInfo) return; - +WEBP_DSP_INIT_FUNC(VP8LDspInit) { COPY_PREDICTOR_ARRAY(Predictor, VP8LPredictors) COPY_PREDICTOR_ARRAY(Predictor, VP8LPredictors_C) COPY_PREDICTOR_ARRAY(PredictorAdd, VP8LPredictorsAdd) @@ -658,8 +653,6 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8LDspInit(void) { assert(VP8LConvertBGRAToRGB565 != NULL); assert(VP8LMapColor32b != NULL); assert(VP8LMapColor8b != NULL); - - lossless_last_cpuinfo_used = VP8GetCPUInfo; } #undef COPY_PREDICTOR_ARRAY diff --git a/src/dsp/lossless_enc.c b/src/dsp/lossless_enc.c index 92ca3c05..d608326f 100644 --- a/src/dsp/lossless_enc.c +++ b/src/dsp/lossless_enc.c @@ -863,12 +863,7 @@ extern void VP8LEncDspInitMIPS32(void); extern void VP8LEncDspInitMIPSdspR2(void); extern void VP8LEncDspInitMSA(void); -static volatile VP8CPUInfo lossless_enc_last_cpuinfo_used = - (VP8CPUInfo)&lossless_enc_last_cpuinfo_used; - -WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInit(void) { - if (lossless_enc_last_cpuinfo_used == VP8GetCPUInfo) return; - +WEBP_DSP_INIT_FUNC(VP8LEncDspInit) { VP8LDspInit(); #if !WEBP_NEON_OMIT_C_CODE @@ -1011,8 +1006,6 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInit(void) { assert(VP8LPredictorsSub_C[13] != NULL); assert(VP8LPredictorsSub_C[14] != NULL); assert(VP8LPredictorsSub_C[15] != NULL); - - lossless_enc_last_cpuinfo_used = VP8GetCPUInfo; } //------------------------------------------------------------------------------ diff --git a/src/dsp/rescaler.c b/src/dsp/rescaler.c index 4b6b7834..f307d350 100644 --- a/src/dsp/rescaler.c +++ b/src/dsp/rescaler.c @@ -204,11 +204,7 @@ extern void WebPRescalerDspInitMIPSdspR2(void); extern void WebPRescalerDspInitMSA(void); extern void WebPRescalerDspInitNEON(void); -static volatile VP8CPUInfo rescaler_last_cpuinfo_used = - (VP8CPUInfo)&rescaler_last_cpuinfo_used; - -WEBP_TSAN_IGNORE_FUNCTION void WebPRescalerDspInit(void) { - if (rescaler_last_cpuinfo_used == VP8GetCPUInfo) return; +WEBP_DSP_INIT_FUNC(WebPRescalerDspInit) { #if !defined(WEBP_REDUCE_SIZE) #if !WEBP_NEON_OMIT_C_CODE WebPRescalerExportRowExpand = WebPRescalerExportRowExpand_C; @@ -253,5 +249,4 @@ WEBP_TSAN_IGNORE_FUNCTION void WebPRescalerDspInit(void) { assert(WebPRescalerImportRowExpand != NULL); assert(WebPRescalerImportRowShrink != NULL); #endif // WEBP_REDUCE_SIZE - rescaler_last_cpuinfo_used = VP8GetCPUInfo; } diff --git a/src/dsp/ssim.c b/src/dsp/ssim.c index dc1b518a..989ce825 100644 --- a/src/dsp/ssim.c +++ b/src/dsp/ssim.c @@ -139,12 +139,7 @@ VP8AccumulateSSEFunc VP8AccumulateSSE; extern void VP8SSIMDspInitSSE2(void); -static volatile VP8CPUInfo ssim_last_cpuinfo_used = - (VP8CPUInfo)&ssim_last_cpuinfo_used; - -WEBP_TSAN_IGNORE_FUNCTION void VP8SSIMDspInit(void) { - if (ssim_last_cpuinfo_used == VP8GetCPUInfo) return; - +WEBP_DSP_INIT_FUNC(VP8SSIMDspInit) { #if !defined(WEBP_REDUCE_SIZE) VP8SSIMGetClipped = SSIMGetClipped_C; VP8SSIMGet = SSIMGet_C; @@ -161,6 +156,4 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8SSIMDspInit(void) { } #endif } - - ssim_last_cpuinfo_used = VP8GetCPUInfo; } diff --git a/src/dsp/upsampling.c b/src/dsp/upsampling.c index ddfd1925..9b60da5b 100644 --- a/src/dsp/upsampling.c +++ b/src/dsp/upsampling.c @@ -219,12 +219,7 @@ extern void WebPInitYUV444ConvertersMIPSdspR2(void); extern void WebPInitYUV444ConvertersSSE2(void); extern void WebPInitYUV444ConvertersSSE41(void); -static volatile VP8CPUInfo upsampling_last_cpuinfo_used1 = - (VP8CPUInfo)&upsampling_last_cpuinfo_used1; - -WEBP_TSAN_IGNORE_FUNCTION void WebPInitYUV444Converters(void) { - if (upsampling_last_cpuinfo_used1 == VP8GetCPUInfo) return; - +WEBP_DSP_INIT_FUNC(WebPInitYUV444Converters) { WebPYUV444Converters[MODE_RGBA] = WebPYuv444ToRgba_C; WebPYUV444Converters[MODE_BGRA] = WebPYuv444ToBgra_C; WebPYUV444Converters[MODE_RGB] = WebPYuv444ToRgb_C; @@ -254,7 +249,6 @@ WEBP_TSAN_IGNORE_FUNCTION void WebPInitYUV444Converters(void) { } #endif } - upsampling_last_cpuinfo_used1 = VP8GetCPUInfo; } //------------------------------------------------------------------------------ @@ -266,12 +260,7 @@ extern void WebPInitUpsamplersNEON(void); extern void WebPInitUpsamplersMIPSdspR2(void); extern void WebPInitUpsamplersMSA(void); -static volatile VP8CPUInfo upsampling_last_cpuinfo_used2 = - (VP8CPUInfo)&upsampling_last_cpuinfo_used2; - -WEBP_TSAN_IGNORE_FUNCTION void WebPInitUpsamplers(void) { - if (upsampling_last_cpuinfo_used2 == VP8GetCPUInfo) return; - +WEBP_DSP_INIT_FUNC(WebPInitUpsamplers) { #ifdef FANCY_UPSAMPLING #if !WEBP_NEON_OMIT_C_CODE WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair_C; @@ -333,7 +322,6 @@ WEBP_TSAN_IGNORE_FUNCTION void WebPInitUpsamplers(void) { #endif #endif // FANCY_UPSAMPLING - upsampling_last_cpuinfo_used2 = VP8GetCPUInfo; } //------------------------------------------------------------------------------ diff --git a/src/dsp/yuv.c b/src/dsp/yuv.c index 957d1d66..14e67fc2 100644 --- a/src/dsp/yuv.c +++ b/src/dsp/yuv.c @@ -75,12 +75,7 @@ extern void WebPInitSamplersSSE41(void); extern void WebPInitSamplersMIPS32(void); extern void WebPInitSamplersMIPSdspR2(void); -static volatile VP8CPUInfo yuv_last_cpuinfo_used = - (VP8CPUInfo)&yuv_last_cpuinfo_used; - -WEBP_TSAN_IGNORE_FUNCTION void WebPInitSamplers(void) { - if (yuv_last_cpuinfo_used == VP8GetCPUInfo) return; - +WEBP_DSP_INIT_FUNC(WebPInitSamplers) { WebPSamplers[MODE_RGB] = YuvToRgbRow; WebPSamplers[MODE_RGBA] = YuvToRgbaRow; WebPSamplers[MODE_BGR] = YuvToBgrRow; @@ -116,7 +111,6 @@ WEBP_TSAN_IGNORE_FUNCTION void WebPInitSamplers(void) { } #endif // WEBP_USE_MIPS_DSP_R2 } - yuv_last_cpuinfo_used = VP8GetCPUInfo; } //----------------------------------------------------------------------------- @@ -260,18 +254,13 @@ void (*WebPSharpYUVUpdateRGB)(const int16_t* ref, const int16_t* src, void (*WebPSharpYUVFilterRow)(const int16_t* A, const int16_t* B, int len, const uint16_t* best_y, uint16_t* out); -static volatile VP8CPUInfo rgba_to_yuv_last_cpuinfo_used = - (VP8CPUInfo)&rgba_to_yuv_last_cpuinfo_used; - extern void WebPInitConvertARGBToYUVSSE2(void); extern void WebPInitConvertARGBToYUVSSE41(void); extern void WebPInitConvertARGBToYUVNEON(void); extern void WebPInitSharpYUVSSE2(void); extern void WebPInitSharpYUVNEON(void); -WEBP_TSAN_IGNORE_FUNCTION void WebPInitConvertARGBToYUV(void) { - if (rgba_to_yuv_last_cpuinfo_used == VP8GetCPUInfo) return; - +WEBP_DSP_INIT_FUNC(WebPInitConvertARGBToYUV) { WebPConvertARGBToY = ConvertARGBToY_C; WebPConvertARGBToUV = WebPConvertARGBToUV_C; @@ -316,6 +305,4 @@ WEBP_TSAN_IGNORE_FUNCTION void WebPInitConvertARGBToYUV(void) { assert(WebPSharpYUVUpdateY != NULL); assert(WebPSharpYUVUpdateRGB != NULL); assert(WebPSharpYUVFilterRow != NULL); - - rgba_to_yuv_last_cpuinfo_used = VP8GetCPUInfo; } diff --git a/src/enc/near_lossless_enc.c b/src/enc/near_lossless_enc.c index cadd14c6..5517a7e2 100644 --- a/src/enc/near_lossless_enc.c +++ b/src/enc/near_lossless_enc.c @@ -146,6 +146,6 @@ int VP8ApplyNearLossless(const WebPPicture* const picture, int quality, // Define a stub to suppress compiler warnings. extern void VP8LNearLosslessStub(void); -WEBP_TSAN_IGNORE_FUNCTION void VP8LNearLosslessStub(void) {} +void VP8LNearLosslessStub(void) {} #endif // (WEBP_NEAR_LOSSLESS == 1) diff --git a/src/enc/picture_csp_enc.c b/src/enc/picture_csp_enc.c index d6dbae62..02d9df76 100644 --- a/src/enc/picture_csp_enc.c +++ b/src/enc/picture_csp_enc.c @@ -126,7 +126,7 @@ static WEBP_INLINE int LinearToGamma(uint32_t base_value, int shift) { #else -static WEBP_TSAN_IGNORE_FUNCTION void InitGammaTables(void) {} +static void InitGammaTables(void) {} static WEBP_INLINE uint32_t GammaToLinear(uint8_t v) { return v; } static WEBP_INLINE int LinearToGamma(uint32_t base_value, int shift) { return (int)(base_value << shift); @@ -238,7 +238,7 @@ static WEBP_INLINE uint32_t LinearToGammaS(uint32_t value) { #else -static WEBP_TSAN_IGNORE_FUNCTION void InitGammaTablesS(void) {} +static void InitGammaTablesS(void) {} static WEBP_INLINE uint32_t GammaToLinearS(int v) { return (v << GAMMA_TO_LINEAR_BITS) / MAX_Y_T; } From d20b7707137f3848930a8f851bebdbda2af0f2c0 Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 17 Apr 2018 18:37:49 -0700 Subject: [PATCH 20/23] update ChangeLog Change-Id: I809f4b9581802d43503cba85f03c90e3a98627a4 --- ChangeLog | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 00941d12..1e5f8878 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +0d5fad46 add WEBP_DSP_INIT / WEBP_DSP_INIT_FUNC +c1cb86af fix 16b overflow in SSE2 +e577feb7 makefile.unix: add DEBUG flag for compiling w/ debug-symbol +99be34b3 cwebp,get_disto: fix bpp output +f5565ca8 cmake: Make sure we use near-lossless by default. +d898dc14 fix bug in WebPImport565: alpha value was not set +882784b0 update ChangeLog (tag: v1.0.0-rc2) 2f930e08 Revert "Use proper targets for CMake." 8165e8fb Use proper targets for CMake. 3f157dd5 Remove some very hard TODOs. @@ -5,7 +12,7 @@ cd758a17 {de,}mux/Makefile.am: add missing headers b892b8ba makefile.unix,dist: use ascii for text output 64a57d05 add -version option to anim_dump,anim_diff and img2webp fc1b8e3a webp_js: fix webp_js demo html -15aa48d9 update ChangeLog +15aa48d9 update ChangeLog (tag: v1.0.0-rc1) e607dabc update AUTHORS 38410c08 [CFI] Remove function pointer casts c57b2736 bump version to 1.0.0 From e6b2164e3a3677f38c903cea57ecce879b05f133 Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Fri, 20 Apr 2018 10:55:42 +0200 Subject: [PATCH 21/23] vwebp: Copy Chrome's behavior w/frame duration == 0 BUG=webp:380 Change-Id: Ia0b108d7da755ff91cf6c84581412e47a3a6e5d9 (cherry picked from commit fd3d5756cb7c63ba78c73297f755f072751d4aed) --- examples/vwebp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/vwebp.c b/examples/vwebp.c index b19465cd..a79c72cb 100644 --- a/examples/vwebp.c +++ b/examples/vwebp.c @@ -205,6 +205,11 @@ static void decode_callback(int what) { } } duration = curr->duration; + // Behavior copied from Chrome, cf: + // https://cs.chromium.org/chromium/src/third_party/WebKit/Source/ + // platform/graphics/DeferredImageDecoder.cpp? + // rcl=b4c33049f096cd283f32be9a58b9a9e768227c26&l=246 + if (duration <= 10) duration = 100; } if (!Decode()) { kParams.decoding_error = 1; From 8d510751dadc6a470768e2874842a466b1e80d60 Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 20 Apr 2018 12:59:50 -0700 Subject: [PATCH 22/23] webp-container-spec: correct frame duration=0 note the interpretation of a 0 duration depends on the implementation; merging of multiple frames isn't guaranteed, some may enforce a minimum duration. BUG=webp:380 Change-Id: Idf592049d2092e4cc5cfb2e4c59ddbc91bd52f9c (cherry picked from commit 71c39a06c83b7bfbee136fd40ac710bdda3a237c) --- doc/webp-container-spec.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/webp-container-spec.txt b/doc/webp-container-spec.txt index dbb49f14..94a7ca29 100644 --- a/doc/webp-container-spec.txt +++ b/doc/webp-container-spec.txt @@ -446,8 +446,9 @@ Frame Height Minus One: 24 bits (_uint24_) Frame Duration: 24 bits (_uint24_) : The time to wait before displaying the next frame, in 1 millisecond units. - In particular, frame duration of 0 is useful when one wants to update - multiple areas of the canvas at once during the animation. + Note the interpretation of frame duration of 0 (and often <= 10) is + implementation defined. Many tools and browsers assign a minimum duration + similar to GIF. Reserved: 6 bits From 698b8844e38a0c5ca50bb20f866e71291bfc3b36 Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 20 Apr 2018 20:04:55 -0700 Subject: [PATCH 23/23] update ChangeLog Change-Id: Ica00314a3dfacad89ec62a3dc2df0d476e6397af --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1e5f8878..9fd9acfe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +8d510751 webp-container-spec: correct frame duration=0 note +e6b2164e vwebp: Copy Chrome's behavior w/frame duration == 0 +d20b7707 update ChangeLog (tag: v1.0.0-rc3) 0d5fad46 add WEBP_DSP_INIT / WEBP_DSP_INIT_FUNC c1cb86af fix 16b overflow in SSE2 e577feb7 makefile.unix: add DEBUG flag for compiling w/ debug-symbol