From 419ac1ac45095fd89300bc6f62026bce78a6a54a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 27 Nov 2023 19:49:59 +0100 Subject: [PATCH 1/2] Squashed 'libwebp_src/' changes from 0d1f12546..ca332209c ca332209c update ChangeLog 1ace578c9 update NEWS 63234c429 bump version to 1.3.2 2af26267c Fix OOB write in BuildHuffmanTable. fd7bb21c0 update ChangeLog e1adea50e update NEWS 433933203 enc/*: normalize WebPEncodingSetError() calls 287fdefe9 enc/*: add missing WebPEncodingSetError() calls c3bd7cff2 EncodeAlphaInternal: add missing error check d49cfbb34 vp8l_enc,WriteImage: add missing error check 2e5a9ec3b muxread,MuxImageParse: add missing error checks ebb6f949f cmake,emscripten: explicitly set stack size 59a2b1f9e WebPDecodeYUV: check u/v/stride/uv_stride ptrs 8e965ccb0 Call png_get_channels() to see if image has alpha 7f0a34194 update ChangeLog bab7efbe7 update NEWS 7138bf8fc bump version to 1.3.1 435b4ded4 update AUTHORS 473512298 update .mailmap ff6c7f4e7 CONTRIBUTING.md: add C style / cmake-format notes dd530437f add .cmake-format.py adbe2cb17 cmake,cosmetics: apply cmake-format 15b365083 doc/webp-container-spec: rm future codec comment c369c4bf0 doc/webp-lossless-bitstream-spec: improve link text 1de35f476 doc/webp-container-spec: don't use 'currently' bb06a16ed doc/webp-container-spec: prefer present tense 9f38b71e0 doc/webp-lossless-bitstream-spec: prefer present tense 7acb6b829 doc/webp-container-spec: avoid i.e. & e.g. 4967e7cd7 doc/webp-lossless-bitstream-spec: avoid i.e. & e.g. e3366659a Merge "Do not find_package image libraries if not needed." into main 428588ef9 clarify single leaf node trees and use of canonical prefix coding 709ec152d Do not find_package image libraries if not needed. 8dd80ef81 fuzz_utils.h: lower kFuzzPxLimit w/ASan 8f187b9f7 Clean message calls in CMake cba300781 WebPConfig.cmake.in: use calculated include path 6cf9a76ae Merge "webp-lossless-bitstream-spec: remove use of 'dynamics'" into main 740943b27 Merge "Specialize and optimize ITransform_SSE2 using do_two" into main 2d547e24d Compare kFuzzPxLimit to max_num_operations ac42dde1c Specialize and optimize ITransform_SSE2 using do_two 17e0ef1da webp-lossless-bitstream-spec: remove use of 'dynamics' ed2743716 neon.h,cosmetics: clear a couple lint warnings 3fb829476 cpu.h,cosmetics: segment defines 0c496a4ff cpu.h: add WEBP_AARCH64 8151f388e move VP8GetCPUInfo declaration to cpu.c 916548c28 Make kFuzzPxLimit sanitizer dependent 4070b271a advanced_api_fuzzer: reduce scaling limit 761f49c3a Merge "webp-lossless-bitstream-spec: add missing bits to ABNF" into main 84d04c484 webp-lossless-bitstream-spec: add missing bits to ABNF 0696e1a7f advanced_api_fuzzer: reduce scaling limit 93d88aa25 Merge "deps.cmake: remove unneeded header checks" into main 118e0035d deps.cmake: remove unneeded header checks 4c3d7018c webp-lossless-bitstream-spec: condense normal-prefix-code a6a09b329 webp-lossless-bitstream-spec: fix 2 code typos 50ac4f7c9 Merge "cpu.h: enable NEON w/_M_ARM64EC" into main 4b7d7b4f2 Add contribution instructions 0afbd97b4 cpu.h: enable NEON w/_M_ARM64EC 349f4353d Merge changes Ibd89e56b,Ic57e7f84,I89096614 into main 8f7513b7c upsampling_neon.c: fix WEBP_SWAP_16BIT_CSP check cbf624b56 advanced_api_fuzzer: reduce scaling limit 89edfdd1e Skip slow scaling in libwebp advanced_api_fuzzer 859f19f74 Reduce libwebp advanced_api_fuzzer threshold a4f048357 Merge changes Ic389aaa2,I329ccd79 into main 1275fac82 Makefile.vc: fix img2webp link w/dynamic cfg 2fe27bb96 img2webp: normalize help output 24bed3d9f cwebp: reflow -near_lossless help text 0825faa4c img2webp: add -sharp_yuv/-near_lossless d64e6d7d9 Merge "PaletteSortModifiedZeng: fix leak on error" into main 0e12a22d8 Merge "EncodeAlphaInternal: clear result->bw on error" into main 0edbb6ea7 PaletteSortModifiedZeng: fix leak on error 41ffe04e1 Merge "Update yapf style from "chromium" to "yapf"" into main 2d9d9265f Update yapf style from "chromium" to "yapf" a486d800b EncodeAlphaInternal: clear result->bw on error 1347a32d8 Skip big scaled advanced_api_fuzzer 52b6f0670 Fix scaling limit in advanced_api_fuzzer.c 736184283 Limit scaling in libwebp advanced_api_fuzzer.c b54d21a01 Merge "CMakeLists.txt: allow CMAKE_INSTALL_RPATH to be set empty" into main 31c28db53 libwebp{,demux,mux}.pc.in: Requires -> Requires.private d9a505ffb CMakeLists.txt: allow CMAKE_INSTALL_RPATH to be set empty bdf33d03b Merge tag 'v1.3.0' b55777696 update ChangeLog 0ba772442 update NEWS e763eb1ea bump version to 1.3.0 2a8686fca update AUTHORS 106a57c1d Merge "*/Android.mk: add a check for NDK_ROOT" into main c5e841c41 Merge "extras: WebpToSDL -> WebPToSDL" into main dbc307151 Merge "xcframeworkbuild.sh: bump MACOSX_CATALYST_MIN_VERSION" into main 6fc1a9f96 */Android.mk: add a check for NDK_ROOT d3e151fc0 doc/api.md,webp_js/README.md: Webp -> WebP ed92a6264 extras: WebpToSDL -> WebPToSDL 6eb0189b2 xcframeworkbuild.sh: bump MACOSX_CATALYST_MIN_VERSION 1d58575b1 CMake: align .pc variables with autoconf e5fe2cfc1 webp-lossless-bitstream-spec,cosmetics: reflow paragraphs 0ceeeab98 webp-lossless-bitstream-spec: add amendment note 607611cd8 Merge "webp-container-spec: normalize section title case" into main f853685e1 lossless: SUBTRACT_GREEN -> SUBTRACT_GREEN_TRANSFORM 786497e48 webp-lossless-bitstream-spec: fix inv color txfm description c6ac672db webp-lossless-bitstream-spec: fix num_code_lengths check b5700efb7 webp-lossless-bitstream-spec,cosmetics: grammar/capitalization d8ed8c117 webp-container-spec: normalize section title case 52ec0b8f6 Merge changes Ie975dbb5,Ifc8c93af,I6ca7c5d6,I2e8d66f5,I152477b8 into main 5097ef625 webp-container-spec,cosmetics: grammar/capitalization e3ba2b1f5 webp-lossless-bitstream-spec,cosmetics: reflow abstract 1e8e3ded2 webp-lossless-bitstream-spec: reword abstract re alpha 017cb6fa9 webp-container-spec,cosmetics: normalize range syntax f6a4684ba webp-lossless-bitstream-spec,cosmetics: normalize range syntax 54ebd5a37 webp-lossless-bitstream-spec: limit dist map lut to 69 cols 44741f9c5 webp-lossless-bitstream-spec: fix dist mapping example fad0ece7e pnmdec.c: use snprintf instead of sprintf 3f73e8f7a sharpyuv: add SharpYuvGetVersion() ce2f2d668 SharpYuvConvert: fix a race on SharpYuvGetCPUInfo a458e3086 sharpyuv_dsp.h: restore sharpyuv_cpu.h include 9ba800a74 Merge changes Id72fbf3b,Ic59d23a2 into main 979c0ebbc sharpyuv: add SharpYuvGetCPUInfo 8bab09a4a Merge "*.pc.in: rename lib_prefix to webp_libname_prefix" into main 769387c54 cpu.c,cosmetics: fix a typo a02978c25 sharpyuv/Makefile.am+cmake: add missing -lm 28aedcb9b *.pc.in: rename lib_prefix to webp_libname_prefix c42e6d5a8 configure.ac: export an empty lib_prefix variable dfc843aa6 Merge "*.pc.in: add lib prefix to lib names w/MSVC" into main 2498209ba *.pc.in: add lib prefix to lib names w/MSVC ac252b611 Merge "analysis_enc.c: fix a dead store warning" into main 569447624 analysis_enc.c: fix a dead store warning d34f9b99b Merge "webp-lossless-bitstream-spec: convert BNF to ABNF" into main dc05b4db2 Merge changes I96bc063c,I45880467,If9e18e5a,I6ee938e4,I0a410b28, ... into main 83270c7f8 webp-container-spec: add prose for rendering process 73b19b64f webp-container-spec: note reserved fields MUST be ignored 57101d3fc webp-lossless-bitstream-spec: improve 'small' color table stmt dfd32e459 webp-container-spec: remove redundant sentence 8a6185dd2 doc/webp-*: fix some punctuation, grammar 72776530d webp-lossless-bitstream-spec: convert BNF to ABNF d992bb08b cmake: rename cpufeatures target to cpufeatures-webp 3ed2b2751 webp-container-spec: clarify background color note 951c292d1 webp-container-spec: come too late -> out of order 902dd7876 webp-container-spec: prefer hex literals a8f6b5ee9 webp-container-spec: change SHOULD to MUST w/ANIM chunk 1dc594352 webp-container-spec: add unknown fields MUST be ignored 280a810f2 webp-container-spec: make padding byte=0 a MUST 41f0bf680 webp-container-spec: update note on trailing data 6bdd36dbe webp-container-spec: clarify Chunk Size is in bytes 87e36c485 Merge "webp_js/README.md,cosmetics: reflow some lines" into main 5b01f3216 Merge "Update Windows makefile to build libsharpyuv library." into main 19b1a71c4 webp_js/README.md,cosmetics: reflow some lines 780db7561 Update Windows makefile to build libsharpyuv library. e407d4b37 CMakeLists.txt: replace GLUT_glut_LIBRARY w/GLUT::GLUT abf73d628 Merge "WebPConfig.cmake.in: add find_dependency(Threads)" into main 25807fb4c Merge "cmake: restore compatibility with cmake < 3.12" into main 5dbc4bfa1 WebPConfig.cmake.in: add find_dependency(Threads) b2a175dd0 Merge "Update wasm instructions." into main cb90f76b6 Update wasm instructions. 02d152586 cmake: restore compatibility with cmake < 3.12 5ba046e25 CMake: add_definitions -> add_compile_options e68765af4 dsp,neon: use vaddv in a few more places e8f83de28 Set libsharpyuv include dir to 'webp' subdirectory. 15a91ab17 cmake,cosmetics: apply cmake-format 0dd49d1a3 CMakeLists.txt: set @ONLY in configure_file() calls 62b1bfe8b Merge changes I2877e7bb,I777cad70,I15af7d1a,I686e6740,If10538a9, ... into main 95c8fe5f3 Merge changes Iecea3603,I9dc228ab into main e7c805cfa picture_csp_enc.c: remove SafeInitSharpYuv 6af8845a8 sharpyuv: prefer webp/types.h 639619ce7 cmake: fix dll exports 782ed48cd sharpyuv,SharpYuvInit: add mutex protection when available cad0d5adb sharyuv_{neon,sse2}.c: merge WEBP_USE_* sections ef70ee06f add a few missing includes for NULL f0f9eda40 sharpyuv.h: remove 9b902cbac Merge "picture_csp_enc.c,CheckNonOpaque: rm unneeded local" into main 9c1d457c0 cmake/cpu.cmake: remove unused variable 9ac25bcb3 CMakeLists.txt,win32: match naming convention used by nmake 76c353bab picture_csp_enc.c,CheckNonOpaque: rm unneeded local 5000de543 Merge "cwebp: fix WebPPictureHasTransparency call" into main e17293095 Merge "WebPPictureHasTransparency: add missing pointer check" into main 00ff988a5 vp8l_enc,AddSingleSubGreen: clear int sanitizer warnings e2fecc22e dsp/lossless_enc.c: clear int sanitizer warnings 129cf9e97 dsp/lossless.c: clear int sanitizer warnings ad7d1753c dsp/lossless_enc.c: clear int sanitizer warnings 5037220e5 VP8LSubtractGreenFromBlueAndRed_C: clear int sanitizer warnings 2ee786c74 upsampling_sse2.c: clear int sanitizer warnings 4cc157d48 ParseOptionalChunks: clear int sanitizer warning 892cf033b BuildHuffmanTable: clear int sanitizer warning 3a9a4d458 VP8GetSigned: clear int sanitizer warnings 704a3d0a1 dsp/lossless.c: quiet int sanitizer warnings 1a6c109c9 WebPPictureHasTransparency: add missing pointer check c626e7d54 cwebp: fix WebPPictureHasTransparency call 866e349ce Merge tag 'v1.2.4' c170df383 Merge "Create libsharpyuv.a in makefile.unix." into main 9d7ff74a5 Create libsharpyuv.a in makefile.unix. fcbc2d78a Merge "doc/*.txt: restrict code to 69 columns" into main 4ad0e1895 Merge "webp-container-spec.txt: normalize fourcc spelling" into main 7a0a9935e doc/*.txt: restrict code to 69 columns c040a615b webp-container-spec.txt: normalize fourcc spelling aff1c546e dsp,x86: normalize types w/_mm_cvtsi128_si32 calls ab540ae0c dsp,x86: normalize types w/_mm_cvtsi32_si128 calls 8980362ee dsp,x86: normalize types w/_mm_set* calls (2) 835392393 dsp,x86: normalize types w/_mm_set* calls 8a4576ce2 webp-container-spec.txt: replace & with & db8708816 Merge "webp-container-spec.txt: make reserved 0 values a MUST" into main 01d7d378d webp-lossless-bitstream-spec: number all sections 337cf69f5 webp-lossless-bitstream-spec: mv Nomenclature after Intro 79be856e6 Merge changes I7111d1f7,I872cd62c into main 5b87983ad webp-container-spec.txt: make reserved 0 values a MUST bd9391232 Merge changes I7a25b1a6,I51b2c2a0,I87d0cbcf,I6ec60af6,I0a3fe9dc into main 04764b56a libwebp.pc: add libsharpyuv to requires 7deee8103 libsharpyuv: add pkg-config file 1a64a7e64 webp-container-spec.txt: clarify some SHOULDs bec2c88a1 webp-container-spec.txt: move ChunkHeader to terminology c9359332a webp-container-spec.txt: clarify 'VP8 '/'XMP ' fourccs 70fe3063a webp-container-spec.txt: rightsize table entries ddbf3f3f2 webp-container-spec.txt: update 'key words' text c151e95bd utils.h,WEBP_ALIGN: make bitmask unsigned 748e92bbb add WebPInt32ToMem 3fe15b677 Merge "Build libsharpyuv as a full installable library." into main 4f402f34a add WebPMemToInt32 a3b68c195 Build libsharpyuv as a full installable library. b4994eaa6 CMake: set rpath for shared objects 94cd71177 Merge "CMake: fix dylib versioning" into main e91451b69 Fix the lossless specs a bit more. 231bdfb76 CMake: fix dylib versioning 7366f7f39 Merge "lossless: fix crunch mode w/WEBP_REDUCE_SIZE" into main 84163d9d0 lossless: fix crunch mode w/WEBP_REDUCE_SIZE d01c1eb30 webp-lossless-bitstream-spec,cosmetics: normalize capitalization 8813ca8e6 Merge tag 'v1.2.3' git-subtree-dir: libwebp_src git-subtree-split: ca332209cb5567c9b249c86788cb2dbf8847e760 --- .cmake-format.py | 240 ++++++++ .mailmap | 1 + .style.yapf | 2 +- AUTHORS | 4 + Android.mk | 6 +- CMakeLists.txt | 543 +++++++++--------- CONTRIBUTING.md | 51 +- ChangeLog | 220 +++++++ Makefile.vc | 46 +- NEWS | 27 + README.md | 2 +- build.gradle | 1 + cmake/WebPConfig.cmake.in | 11 +- cmake/config.h.in | 33 -- cmake/cpu.cmake | 27 +- cmake/deps.cmake | 137 ++--- configure.ac | 6 +- doc/api.md | 2 +- doc/tools.md | 12 +- doc/webp-container-spec.txt | 259 +++++---- doc/webp-lossless-bitstream-spec.txt | 826 +++++++++++++-------------- examples/Android.mk | 3 + examples/Makefile.am | 4 +- examples/cwebp.c | 17 +- examples/img2webp.c | 20 +- extras/extras.c | 4 +- extras/vwebp_sdl.c | 2 +- extras/webp_to_sdl.c | 2 +- extras/webp_to_sdl.h | 4 +- imageio/Android.mk | 3 + imageio/pngdec.c | 16 +- imageio/pnmdec.c | 7 +- makefile.unix | 33 +- man/img2webp.1 | 16 +- sharpyuv/Makefile.am | 17 +- sharpyuv/libsharpyuv.pc.in | 11 + sharpyuv/libsharpyuv.rc | 41 ++ sharpyuv/sharpyuv.c | 59 +- sharpyuv/sharpyuv.h | 40 +- sharpyuv/sharpyuv_cpu.c | 14 + sharpyuv/sharpyuv_cpu.h | 22 + sharpyuv/sharpyuv_csp.c | 2 +- sharpyuv/sharpyuv_csp.h | 7 +- sharpyuv/sharpyuv_dsp.c | 18 +- sharpyuv/sharpyuv_dsp.h | 7 +- sharpyuv/sharpyuv_gamma.c | 1 - sharpyuv/sharpyuv_gamma.h | 2 +- sharpyuv/sharpyuv_neon.c | 9 +- sharpyuv/sharpyuv_sse2.c | 7 +- src/Makefile.am | 4 +- src/dec/tree_dec.c | 3 +- src/dec/vp8_dec.c | 2 + src/dec/vp8i_dec.h | 4 +- src/dec/vp8l_dec.c | 48 +- src/dec/vp8li_dec.h | 2 +- src/dec/webp_dec.c | 35 +- src/demux/Makefile.am | 2 +- src/demux/demux.c | 4 +- src/demux/libwebpdemux.pc.in | 4 +- src/demux/libwebpdemux.rc | 10 +- src/dsp/alpha_processing.c | 1 + src/dsp/alpha_processing_sse2.c | 12 +- src/dsp/alpha_processing_sse41.c | 2 +- src/dsp/cost.c | 1 + src/dsp/cost_neon.c | 4 +- src/dsp/cpu.c | 8 +- src/dsp/cpu.h | 38 +- src/dsp/dec.c | 1 + src/dsp/dec_neon.c | 4 +- src/dsp/dec_sse2.c | 93 +-- src/dsp/dec_sse41.c | 2 +- src/dsp/enc.c | 1 + src/dsp/enc_neon.c | 11 +- src/dsp/enc_sse2.c | 293 +++++++--- src/dsp/filters.c | 1 + src/dsp/lossless.c | 13 +- src/dsp/lossless_enc.c | 19 +- src/dsp/lossless_enc_neon.c | 2 +- src/dsp/lossless_enc_sse2.c | 8 +- src/dsp/lossless_neon.c | 2 +- src/dsp/lossless_sse2.c | 88 ++- src/dsp/lossless_sse41.c | 7 +- src/dsp/neon.h | 4 +- src/dsp/quant.h | 13 +- src/dsp/rescaler.c | 1 + src/dsp/rescaler_sse2.c | 6 +- src/dsp/ssim.c | 1 + src/dsp/upsampling.c | 1 + src/dsp/upsampling_neon.c | 2 +- src/dsp/upsampling_sse2.c | 2 +- src/dsp/yuv.c | 1 + src/dsp/yuv_sse2.c | 13 +- src/dsp/yuv_sse41.c | 6 +- src/enc/alpha_enc.c | 20 +- src/enc/analysis_enc.c | 12 +- src/enc/backward_references_enc.c | 9 +- src/enc/frame_enc.c | 8 +- src/enc/picture_csp_enc.c | 34 +- src/enc/picture_rescale_enc.c | 20 +- src/enc/syntax_enc.c | 6 +- src/enc/vp8i_enc.h | 4 +- src/enc/vp8l_enc.c | 49 +- src/enc/webp_enc.c | 10 +- src/libwebp.pc.in | 3 +- src/libwebp.rc | 10 +- src/libwebpdecoder.pc.in | 2 +- src/libwebpdecoder.rc | 10 +- src/mux/Makefile.am | 2 +- src/mux/libwebpmux.pc.in | 4 +- src/mux/libwebpmux.rc | 10 +- src/mux/muxi.h | 4 +- src/mux/muxread.c | 7 +- src/utils/bit_reader_inl_utils.h | 4 +- src/utils/bit_reader_utils.c | 3 +- src/utils/bit_reader_utils.h | 3 +- src/utils/huffman_utils.c | 99 +++- src/utils/huffman_utils.h | 27 +- src/utils/utils.h | 12 +- src/webp/decode.h | 5 +- src/webp/format_constants.h | 2 +- src/webp/types.h | 6 +- tests/fuzzer/advanced_api_fuzzer.c | 37 +- tests/fuzzer/fuzz_utils.h | 18 +- tests/fuzzer/makefile.unix | 1 + webp_js/README.md | 19 +- webp_js/index.html | 2 +- webp_js/index_wasm.html | 2 +- xcframeworkbuild.sh | 2 +- 128 files changed, 2615 insertions(+), 1474 deletions(-) create mode 100644 .cmake-format.py create mode 100644 sharpyuv/libsharpyuv.pc.in create mode 100644 sharpyuv/libsharpyuv.rc create mode 100644 sharpyuv/sharpyuv_cpu.c create mode 100644 sharpyuv/sharpyuv_cpu.h diff --git a/.cmake-format.py b/.cmake-format.py new file mode 100644 index 0000000..71043af --- /dev/null +++ b/.cmake-format.py @@ -0,0 +1,240 @@ +# ---------------------------------- +# Options affecting listfile parsing +# ---------------------------------- +with section("parse"): + + # Specify structure for custom cmake functions + additional_commands = { 'foo': { 'flags': ['BAR', 'BAZ'], + 'kwargs': {'DEPENDS': '*', 'HEADERS': '*', 'SOURCES': '*'}}} + + # Override configurations per-command where available + override_spec = {} + + # Specify variable tags. + vartags = [] + + # Specify property tags. + proptags = [] + +# ----------------------------- +# Options affecting formatting. +# ----------------------------- +with section("format"): + + # Disable formatting entirely, making cmake-format a no-op + disable = False + + # How wide to allow formatted cmake files + line_width = 80 + + # How many spaces to tab for indent + tab_size = 2 + + # If true, lines are indented using tab characters (utf-8 0x09) instead of + # space characters (utf-8 0x20). In cases where the layout would + # require a fractional tab character, the behavior of the fractional + # indentation is governed by + use_tabchars = False + + # If is True, then the value of this variable indicates how + # fractional indentions are handled during whitespace replacement. If set to + # 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set + # to `round-up` fractional indentation is replaced with a single tab character + # (utf-8 0x09) effectively shifting the column to the next tabstop + fractional_tab_policy = 'use-space' + + # If an argument group contains more than this many sub-groups (parg or kwarg + # groups) then force it to a vertical layout. + max_subgroups_hwrap = 3 + + # If a positional argument group contains more than this many arguments, then + # force it to a vertical layout. + max_pargs_hwrap = 6 + + # If a cmdline positional group consumes more than this many lines without + # nesting, then invalidate the layout (and nest) + max_rows_cmdline = 2 + + # If true, separate flow control names from their parentheses with a space + separate_ctrl_name_with_space = False + + # If true, separate function names from parentheses with a space + separate_fn_name_with_space = False + + # If a statement is wrapped to more than one line, than dangle the closing + # parenthesis on its own line. + dangle_parens = False + + # If the trailing parenthesis must be 'dangled' on its on line, then align it + # to this reference: `prefix`: the start of the statement, `prefix-indent`: + # the start of the statement, plus one indentation level, `child`: align to + # the column of the arguments + dangle_align = 'prefix' + + # If the statement spelling length (including space and parenthesis) is + # smaller than this amount, then force reject nested layouts. + min_prefix_chars = 4 + + # If the statement spelling length (including space and parenthesis) is larger + # than the tab width by more than this amount, then force reject un-nested + # layouts. + max_prefix_chars = 10 + + # If a candidate layout is wrapped horizontally but it exceeds this many + # lines, then reject the layout. + max_lines_hwrap = 2 + + # What style line endings to use in the output. + line_ending = 'unix' + + # Format command names consistently as 'lower' or 'upper' case + command_case = 'canonical' + + # Format keywords consistently as 'lower' or 'upper' case + keyword_case = 'unchanged' + + # A list of command names which should always be wrapped + always_wrap = [] + + # If true, the argument lists which are known to be sortable will be sorted + # lexicographicall + enable_sort = True + + # If true, the parsers may infer whether or not an argument list is sortable + # (without annotation). + autosort = False + + # By default, if cmake-format cannot successfully fit everything into the + # desired linewidth it will apply the last, most agressive attempt that it + # made. If this flag is True, however, cmake-format will print error, exit + # with non-zero status code, and write-out nothing + require_valid_layout = False + + # A dictionary mapping layout nodes to a list of wrap decisions. See the + # documentation for more information. + layout_passes = {} + +# ------------------------------------------------ +# Options affecting comment reflow and formatting. +# ------------------------------------------------ +with section("markup"): + + # What character to use for bulleted lists + bullet_char = '*' + + # What character to use as punctuation after numerals in an enumerated list + enum_char = '.' + + # If comment markup is enabled, don't reflow the first comment block in each + # listfile. Use this to preserve formatting of your copyright/license + # statements. + first_comment_is_literal = True + + # If comment markup is enabled, don't reflow any comment block which matches + # this (regex) pattern. Default is `None` (disabled). + literal_comment_pattern = None + + # Regular expression to match preformat fences in comments default= + # ``r'^\s*([`~]{3}[`~]*)(.*)$'`` + fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$' + + # Regular expression to match rulers in comments default= + # ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'`` + ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$' + + # If a comment line matches starts with this pattern then it is explicitly a + # trailing comment for the preceeding argument. Default is '#<' + explicit_trailing_pattern = '#<' + + # If a comment line starts with at least this many consecutive hash + # characters, then don't lstrip() them off. This allows for lazy hash rulers + # where the first hash char is not separated by space + hashruler_min_length = 10 + + # If true, then insert a space between the first hash char and remaining hash + # chars in a hash ruler, and normalize its length to fill the column + canonicalize_hashrulers = True + + # enable comment markup parsing and reflow + enable_markup = True + +# ---------------------------- +# Options affecting the linter +# ---------------------------- +with section("lint"): + + # a list of lint codes to disable + disabled_codes = [] + + # regular expression pattern describing valid function names + function_pattern = '[0-9a-z_]+' + + # regular expression pattern describing valid macro names + macro_pattern = '[0-9A-Z_]+' + + # regular expression pattern describing valid names for variables with global + # (cache) scope + global_var_pattern = '[A-Z][0-9A-Z_]+' + + # regular expression pattern describing valid names for variables with global + # scope (but internal semantic) + internal_var_pattern = '_[A-Z][0-9A-Z_]+' + + # regular expression pattern describing valid names for variables with local + # scope + local_var_pattern = '[a-z][a-z0-9_]+' + + # regular expression pattern describing valid names for privatedirectory + # variables + private_var_pattern = '_[0-9a-z_]+' + + # regular expression pattern describing valid names for public directory + # variables + public_var_pattern = '[A-Z][0-9A-Z_]+' + + # regular expression pattern describing valid names for function/macro + # arguments and loop variables. + argument_var_pattern = '[a-z][a-z0-9_]+' + + # regular expression pattern describing valid names for keywords used in + # functions or macros + keyword_pattern = '[A-Z][0-9A-Z_]+' + + # In the heuristic for C0201, how many conditionals to match within a loop in + # before considering the loop a parser. + max_conditionals_custom_parser = 2 + + # Require at least this many newlines between statements + min_statement_spacing = 1 + + # Require no more than this many newlines between statements + max_statement_spacing = 2 + max_returns = 6 + max_branches = 12 + max_arguments = 5 + max_localvars = 15 + max_statements = 50 + +# ------------------------------- +# Options affecting file encoding +# ------------------------------- +with section("encode"): + + # If true, emit the unicode byte-order mark (BOM) at the start of the file + emit_byteorder_mark = False + + # Specify the encoding of the input file. Defaults to utf-8 + input_encoding = 'utf-8' + + # Specify the encoding of the output file. Defaults to utf-8. Note that cmake + # only claims to support utf-8 so be careful when using anything else + output_encoding = 'utf-8' + +# ------------------------------------- +# Miscellaneous configurations options. +# ------------------------------------- +with section("misc"): + + # A dictionary containing any per-command configuration overrides. Currently + # only `command_case` is supported. + per_command = {} diff --git a/.mailmap b/.mailmap index ddcf1a7..cf26f1d 100644 --- a/.mailmap +++ b/.mailmap @@ -16,3 +16,4 @@ James Zern Roberto Alanis Brian Ledger Maryla Ustarroz-Calonge +Yannis Guyon diff --git a/.style.yapf b/.style.yapf index 47ca4cc..0be981a 100644 --- a/.style.yapf +++ b/.style.yapf @@ -1,2 +1,2 @@ [style] -based_on_style = chromium \ No newline at end of file +based_on_style = yapf \ No newline at end of file diff --git a/AUTHORS b/AUTHORS index 3efcbe2..8359b20 100644 --- a/AUTHORS +++ b/AUTHORS @@ -11,11 +11,13 @@ Contributors: - Djordje Pesut (djordje dot pesut at imgtec dot com) - Frank Barchard (fbarchard at google dot com) - Hui Su (huisu at google dot com) +- H. Vetinari (h dot vetinari at gmx dot com) - Ilya Kurdyukov (jpegqs at gmail dot com) - Ingvar Stepanyan (rreverser at google dot com) - James Zern (jzern at google dot com) - Jan Engelhardt (jengelh at medozas dot de) - Jehan (jehan at girinstud dot io) +- Jeremy Maitin-Shepard (jbms at google dot com) - Johann Koenig (johann dot koenig at duck dot com) - Jovan Zelincevic (jovan dot zelincevic at imgtec dot com) - Jyrki Alakuijala (jyrki at google dot com) @@ -30,6 +32,7 @@ Contributors: - Mislav Bradac (mislavm at google dot com) - Nico Weber (thakis at chromium dot org) - Noel Chromium (noel at chromium dot org) +- Nozomi Isozaki (nontan at pixiv dot co dot jp) - Oliver Wolff (oliver dot wolff at qt dot io) - Owen Rodley (orodley at google dot com) - Parag Salasakar (img dot mips1 at gmail dot com) @@ -45,6 +48,7 @@ Contributors: - Somnath Banerjee (somnath dot banerjee at gmail dot com) - Sriraman Tallam (tmsriram at google dot com) - Tamar Levy (tamar dot levy at intel dot com) +- Thiago Perrotta (tperrotta at google dot com) - Timothy Gu (timothygu99 at gmail dot com) - Urvang Joshi (urvang at google dot com) - Vikas Arora (vikasa at google dot com) diff --git a/Android.mk b/Android.mk index 85ba5c6..9d16f08 100644 --- a/Android.mk +++ b/Android.mk @@ -1,3 +1,5 @@ +# Ignore this file during non-NDK builds. +ifdef NDK_ROOT LOCAL_PATH := $(call my-dir) WEBP_CFLAGS := -Wall -DANDROID -DHAVE_MALLOC_H -DHAVE_PTHREAD -DWEBP_USE_THREAD @@ -35,6 +37,7 @@ endif sharpyuv_srcs := \ sharpyuv/sharpyuv.c \ + sharpyuv/sharpyuv_cpu.c \ sharpyuv/sharpyuv_csp.c \ sharpyuv/sharpyuv_dsp.c \ sharpyuv/sharpyuv_gamma.c \ @@ -218,7 +221,7 @@ LOCAL_SRC_FILES := \ $(utils_enc_srcs) \ LOCAL_CFLAGS := $(WEBP_CFLAGS) -LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/src +LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/src $(LOCAL_PATH) # prefer arm over thumb mode for performance gains LOCAL_ARM_MODE := arm @@ -288,3 +291,4 @@ include $(WEBP_SRC_PATH)/examples/Android.mk ifeq ($(USE_CPUFEATURES),yes) $(call import-module,android/cpufeatures) endif +endif # NDK_ROOT diff --git a/CMakeLists.txt b/CMakeLists.txt index 2501012..ad5e14c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,11 @@ # in the file PATENTS. All contributing project authors may # be found in the AUTHORS file in the root of the source tree. -cmake_minimum_required(VERSION 3.7) +if(APPLE) + cmake_minimum_required(VERSION 3.17) +else() + cmake_minimum_required(VERSION 3.7) +endif() if(POLICY CMP0072) cmake_policy(SET CMP0072 NEW) @@ -50,9 +54,9 @@ set_property(CACHE WEBP_BITTRACE PROPERTY STRINGS 0 1 2) if(WEBP_LINK_STATIC) if(WIN32) - SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) else() - SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) endif() set(CMAKE_POSITION_INDEPENDENT_CODE ON) # vwebp does not compile on Ubuntu with static libraries so disabling it for @@ -78,23 +82,42 @@ if(WEBP_BUILD_WEBP_JS) set(WEBP_USE_THREAD OFF) if(WEBP_ENABLE_SIMD) - message("wasm2js does not support SIMD, disabling webp.js generation.") + message(NOTICE + "wasm2js does not support SIMD, disabling webp.js generation.") endif() endif() +set(SHARPYUV_DEP_LIBRARIES) +set(SHARPYUV_DEP_INCLUDE_DIRS) set(WEBP_DEP_LIBRARIES) set(WEBP_DEP_INCLUDE_DIRS) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type: Release, Debug, MinSizeRel or RelWithDebInfo" - FORCE) + FORCE) endif() # Include dependencies. +if(WEBP_BUILD_ANIM_UTILS + OR WEBP_BUILD_CWEBP + OR WEBP_BUILD_DWEBP + OR WEBP_BUILD_EXTRAS + OR WEBP_BUILD_GIF2WEBP + OR WEBP_BUILD_IMG2WEBP) + set(WEBP_FIND_IMG_LIBS TRUE) +else() + set(WEBP_FIND_IMG_LIBS FALSE) +endif() include(cmake/deps.cmake) include(GNUInstallDirs) +if(BUILD_SHARED_LIBS AND NOT DEFINED CMAKE_INSTALL_RPATH) + # Set the rpath to match autoconf/libtool behavior. Note this must be set + # before target creation. + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") +endif() + # ############################################################################## # Options. if(WEBP_ENABLE_SWAP_16BIT_CSP) @@ -110,26 +133,50 @@ if(WEBP_UNICODE) add_definitions(-DUNICODE -D_UNICODE) endif() +if(MSVC AND BUILD_SHARED_LIBS) + add_definitions(-DWEBP_DLL) +endif() + +# pkg-config variables used by *.pc.in. set(prefix ${CMAKE_INSTALL_PREFIX}) -set(exec_prefix "\$\{prefix\}") -set(libdir "\$\{prefix\}/lib") -set(includedir "\$\{prefix\}/include") +set(exec_prefix "\${prefix}") +if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") + set(libdir "${CMAKE_INSTALL_LIBDIR}") +else() + set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") +endif() +if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") + set(includedir "${CMAKE_INSTALL_INCLUDEDIR}") +else() + set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") +endif() set(PTHREAD_LIBS ${CMAKE_THREAD_LIBS_INIT}) set(INSTALLED_LIBRARIES) +if(MSVC) + # match the naming convention used by nmake + set(webp_libname_prefix "lib") + set(CMAKE_SHARED_LIBRARY_PREFIX "${webp_libname_prefix}") + set(CMAKE_IMPORT_LIBRARY_PREFIX "${webp_libname_prefix}") + set(CMAKE_STATIC_LIBRARY_PREFIX "${webp_libname_prefix}") +endif() + set(CMAKE_C_VISIBILITY_PRESET hidden) # ############################################################################## # Android only. if(ANDROID) include_directories(${ANDROID_NDK}/sources/android/cpufeatures) - add_library(cpufeatures STATIC + add_library(cpufeatures-webp STATIC ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c) - list(APPEND INSTALLED_LIBRARIES cpufeatures) - target_link_libraries(cpufeatures dl) - set(WEBP_DEP_LIBRARIES ${WEBP_DEP_LIBRARIES} cpufeatures) - set(WEBP_DEP_INCLUDE_DIRS ${WEBP_DEP_INCLUDE_DIRS} - ${ANDROID_NDK}/sources/android/cpufeatures) + list(APPEND INSTALLED_LIBRARIES cpufeatures-webp) + target_link_libraries(cpufeatures-webp dl) + set(SHARPYUV_DEP_LIBRARIES ${SHARPYUV_DEP_LIBRARIES} cpufeatures-webp) + set(WEBP_DEP_LIBRARIES ${WEBP_DEP_LIBRARIES} cpufeatures-webp) + set(cpufeatures_include_dir ${ANDROID_NDK}/sources/android/cpufeatures) + set(SHARPYUV_DEP_INCLUDE_DIRS ${SHARPYUV_DEP_INCLUDE_DIRS} + ${cpufeatures_include_dir}) + set(WEBP_DEP_INCLUDE_DIRS ${WEBP_DEP_INCLUDE_DIRS} ${cpufeatures_include_dir}) add_definitions(-DHAVE_CPU_FEATURES_H=1) set(HAVE_CPU_FEATURES_H 1) else() @@ -138,7 +185,7 @@ endif() function(configure_pkg_config FILE) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.in" - "${CMAKE_CURRENT_BINARY_DIR}/${FILE}") + "${CMAKE_CURRENT_BINARY_DIR}/${FILE}" @ONLY) if(HAVE_MATH_LIBRARY) # MSVC doesn't have libm @@ -147,10 +194,8 @@ function(configure_pkg_config FILE) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${FILE} ${data}) endif() - install( - FILES "${CMAKE_CURRENT_BINARY_DIR}/${FILE}" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig - ) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${FILE}" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) endfunction() # ############################################################################## @@ -160,23 +205,15 @@ endfunction() # E.g.: libimagedec_la_SOURCES = image_dec.c image_dec.h function(parse_Makefile_am FOLDER VAR SRC_REGEX) file(READ ${FOLDER}/Makefile.am MAKEFILE_AM) - string(REGEX MATCHALL - "${SRC_REGEX}_SOURCES[ ]*\\+?=[ ]+[0-9a-z\\._ ]*" - FILES_PER_LINE - ${MAKEFILE_AM}) + string(REGEX MATCHALL "${SRC_REGEX}_SOURCES[ ]*\\+?=[ ]+[0-9a-z\\._ ]*" + FILES_PER_LINE ${MAKEFILE_AM}) set(SRCS ${${VAR}}) foreach(FILES ${FILES_PER_LINE}) string(FIND ${FILES} "=" OFFSET) math(EXPR OFFSET "${OFFSET} + 2") - string(SUBSTRING ${FILES} - ${OFFSET} - -1 - FILES) + string(SUBSTRING ${FILES} ${OFFSET} -1 FILES) if(FILES) - string(REGEX MATCHALL - "[0-9a-z\\._]+" - FILES - ${FILES}) + string(REGEX MATCHALL "[0-9a-z\\._]+" FILES ${FILES}) foreach(FILE ${FILES}) list(APPEND SRCS ${FOLDER}/${FILE}) endforeach() @@ -205,9 +242,52 @@ endforeach() # Generate the config.h file. configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/config.h.in - ${CMAKE_CURRENT_BINARY_DIR}/src/webp/config.h) + ${CMAKE_CURRENT_BINARY_DIR}/src/webp/config.h @ONLY) add_definitions(-DHAVE_CONFIG_H) +# Set the version numbers. +macro(set_version FILE TARGET_NAME NAME_IN_MAKEFILE) + file(READ ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} SOURCE_FILE) + string(REGEX MATCH + "${NAME_IN_MAKEFILE}_la_LDFLAGS[^\n]* -version-info [0-9:]+" TMP + ${SOURCE_FILE}) + string(REGEX MATCH "[0-9:]+" TMP ${TMP}) + string(REGEX REPLACE ":" " " LT_VERSION ${TMP}) + + # See the libtool docs for more information: + # https://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info + # + # c=, a=, r= + # + # libtool generates a .so file as .so.[c-a].a.r, while -version-info c:r:a is + # passed to libtool. + # + # We set FULL = [c-a].a.r and MAJOR = [c-a]. + separate_arguments(LT_VERSION) + list(GET LT_VERSION 0 LT_CURRENT) + list(GET LT_VERSION 1 LT_REVISION) + list(GET LT_VERSION 2 LT_AGE) + math(EXPR LT_CURRENT_MINUS_AGE "${LT_CURRENT} - ${LT_AGE}") + + set_target_properties( + ${TARGET_NAME} + PROPERTIES VERSION ${LT_CURRENT_MINUS_AGE}.${LT_AGE}.${LT_REVISION} + SOVERSION ${LT_CURRENT_MINUS_AGE}) + if(APPLE) + # For compatibility, set MACHO_COMPATIBILITY_VERSION and + # MACHO_CURRENT_VERSION to match libtool. These properties were introduced + # in 3.17: + # https://cmake.org/cmake/help/latest/prop_tgt/MACHO_COMPATIBILITY_VERSION.html + math(EXPR LIBWEBP_MACHO_COMPATIBILITY_VERSION "${LT_CURRENT} + 1") + set_target_properties( + ${TARGET_NAME} + PROPERTIES MACHO_COMPATIBILITY_VERSION + ${LIBWEBP_MACHO_COMPATIBILITY_VERSION} + MACHO_CURRENT_VERSION + ${LIBWEBP_MACHO_COMPATIBILITY_VERSION}.${LT_REVISION}) + endif() +endmacro() + # ############################################################################## # Build the webpdecoder library. @@ -216,13 +296,12 @@ add_definitions(-DHAVE_CONFIG_H) # # See also: # https://cmake.org/cmake/help/v3.18/command/add_library.html#object-libraries -# "Some native build systems (such as Xcode) may not like targets that have -# only object files, so consider adding at least one real source file to any -# target that references $." +# "Some native build systems (such as Xcode) may not like targets that have only +# object files, so consider adding at least one real source file to any target +# that references $." function(libwebp_add_stub_file TARGET) set(stub_source_dir "${CMAKE_BINARY_DIR}") - set(stub_source_file - "${stub_source_dir}/libwebp_${TARGET}_stub.c") + set(stub_source_file "${stub_source_dir}/libwebp_${TARGET}_stub.c") set(stub_source_code "// Generated file. DO NOT EDIT!\n" "// C source file created for target ${TARGET}.\n" @@ -233,51 +312,55 @@ function(libwebp_add_stub_file TARGET) target_sources(${TARGET} PRIVATE ${stub_source_file}) endfunction() -parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/sharpyuv "WEBP_SHARPYUV_SRCS" - "") -add_library(sharpyuv OBJECT ${WEBP_SHARPYUV_SRCS}) -target_include_directories(sharpyuv - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}) +parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/sharpyuv "WEBP_SHARPYUV_SRCS" "") +add_library(sharpyuv ${WEBP_SHARPYUV_SRCS}) +target_link_libraries(sharpyuv ${SHARPYUV_DEP_LIBRARIES}) +set_version(sharpyuv/Makefile.am sharpyuv sharpyuv) +target_include_directories( + sharpyuv PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src) set_target_properties( sharpyuv PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/sharpyuv/sharpyuv.h;\ -${CMAKE_CURRENT_SOURCE_DIR}/sharpyuv/sharpyuv_csp.h;\ -${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h") +${CMAKE_CURRENT_SOURCE_DIR}/sharpyuv/sharpyuv_csp.h") +configure_pkg_config("sharpyuv/libsharpyuv.pc") +install( + TARGETS sharpyuv + EXPORT ${PROJECT_NAME}Targets + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webp/sharpyuv + INCLUDES + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ${CMAKE_INSTALL_INCLUDEDIR}/webp + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) if(MSVC) # avoid security warnings for e.g., fopen() used in the examples. add_definitions(-D_CRT_SECURE_NO_WARNINGS) else() - add_definitions(-Wall) + add_compile_options(-Wall) endif() 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}) +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}) -add_library(webpdecoder - $ - $ - $) +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}) +add_library( + webpdecoder $ $ + $) if(XCODE) libwebp_add_stub_file(webpdecoder) endif() target_link_libraries(webpdecoder ${WEBP_DEP_LIBRARIES}) target_include_directories( - webpdecoder - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} + webpdecoder PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} INTERFACE $ $) set_target_properties( @@ -289,39 +372,26 @@ configure_pkg_config("src/libwebpdecoder.pc") # 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_include_directories( + webpencode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src) +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 sharpyuv) if(XCODE) libwebp_add_stub_file(webp) endif() target_link_libraries(webp ${WEBP_DEP_LIBRARIES}) target_include_directories( - webp - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} + webp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} PUBLIC $ $) set_target_properties( @@ -332,83 +402,33 @@ ${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). -set_target_properties(sharpyuv - webpdecode - webpdspdecode - webputilsdecode - webpencode - webpdsp - webputils - PROPERTIES POSITION_INDEPENDENT_CODE ON) +set_target_properties(webpdecode webpdspdecode webputilsdecode webpencode + webpdsp webputils PROPERTIES POSITION_INDEPENDENT_CODE ON) configure_pkg_config("src/libwebp.pc") # 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 $) +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;\ + 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") configure_pkg_config("src/demux/libwebpdemux.pc") -# Set the version numbers. -macro(set_version FILE TARGET_NAME NAME_IN_MAKEFILE) - file(READ ${CMAKE_CURRENT_SOURCE_DIR}/src/${FILE} SOURCE_FILE) - string(REGEX MATCH - "${NAME_IN_MAKEFILE}_la_LDFLAGS[^\n]* -version-info [0-9:]+" - TMP - ${SOURCE_FILE}) - string(REGEX MATCH - "[0-9:]+" - TMP - ${TMP}) - string(REGEX - REPLACE ":" - " " - LT_VERSION - ${TMP}) - - # See the libtool docs for more information: - # https://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info - # - # c=, a=, r= - # - # libtool generates a .so file as .so.[c-a].a.r, while -version-info c:r:a is - # passed to libtool. - # - # We set FULL = [c-a].a.r and MAJOR = [c-a]. - separate_arguments(LT_VERSION) - list(GET LT_VERSION 0 LT_CURRENT) - list(GET LT_VERSION 1 LT_REVISION) - list(GET LT_VERSION 2 LT_AGE) - math(EXPR LT_CURRENT_MINUS_AGE "${LT_CURRENT} - ${LT_AGE}") - - set_target_properties( - ${TARGET_NAME} - PROPERTIES VERSION - ${LT_CURRENT_MINUS_AGE}.${LT_AGE}.${LT_REVISION} - SOVERSION - ${LT_CURRENT_MINUS_AGE}) -endmacro() -set_version(Makefile.am webp webp) -set_version(Makefile.am webpdecoder webpdecoder) -set_version(demux/Makefile.am webpdemux webpdemux) +set_version(src/Makefile.am webp webp) +set_version(src/Makefile.am webpdecoder webpdecoder) +set_version(src/demux/Makefile.am webpdemux webpdemux) file(READ ${CMAKE_CURRENT_SOURCE_DIR}/configure.ac CONFIGURE_FILE) -string(REGEX MATCH - "AC_INIT\\([^\n]*\\[[0-9\\.]+\\]" - TMP - ${CONFIGURE_FILE}) -string(REGEX MATCH - "[0-9\\.]+" - PROJECT_VERSION - ${TMP}) +string(REGEX MATCH "AC_INIT\\([^\n]*\\[[0-9\\.]+\\]" TMP ${CONFIGURE_FILE}) +string(REGEX MATCH "[0-9\\.]+" PROJECT_VERSION ${TMP}) # Define the libraries to install. list(APPEND INSTALLED_LIBRARIES webpdecoder webp webpdemux) @@ -421,10 +441,8 @@ math(EXPR WEBP_SIMD_FILES_TO_INCLUDE_RANGE foreach(I_FILE RANGE ${WEBP_SIMD_FILES_TO_INCLUDE_RANGE}) list(GET WEBP_SIMD_FILES_TO_INCLUDE ${I_FILE} FILE) list(GET WEBP_SIMD_FLAGS_TO_INCLUDE ${I_FILE} SIMD_COMPILE_FLAG) - set_source_files_properties(${FILE} - PROPERTIES - COMPILE_FLAGS - ${SIMD_COMPILE_FLAG}) + set_source_files_properties(${FILE} PROPERTIES COMPILE_FLAGS + ${SIMD_COMPILE_FLAG}) endforeach() if(NOT WEBP_BUILD_LIBWEBPMUX) @@ -456,8 +474,7 @@ if(WEBP_BUILD_ANIM_UTILS list(APPEND EXAMPLEUTIL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/examples/stopwatch.h) add_library(exampleutil STATIC ${EXAMPLEUTIL_SRCS}) target_include_directories( - exampleutil - PUBLIC $) + exampleutil PUBLIC $) parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/imageio "IMAGEIOUTILS_SRCS" "imageio_util_[^ ]*") @@ -469,10 +486,7 @@ if(WEBP_BUILD_ANIM_UTILS parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/imageio "IMAGEDEC_SRCS" "imagedec_[^ ]*") add_library(imagedec STATIC ${IMAGEDEC_SRCS}) - target_link_libraries(imagedec - imageioutil - webpdemux - webp + target_link_libraries(imagedec imageioutil webpdemux webp ${WEBP_DEP_IMG_LIBRARIES}) # Image-encoding utility library. @@ -481,12 +495,10 @@ if(WEBP_BUILD_ANIM_UTILS add_library(imageenc STATIC ${IMAGEENC_SRCS}) target_link_libraries(imageenc imageioutil webp) - set_property(TARGET exampleutil - imageioutil - imagedec - imageenc - PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src - ${CMAKE_CURRENT_BINARY_DIR}/src) + set_property( + TARGET exampleutil imageioutil imagedec imageenc + PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_BINARY_DIR}/src) endif() if(WEBP_BUILD_DWEBP) @@ -503,7 +515,8 @@ if(WEBP_BUILD_CWEBP) parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "CWEBP_SRCS" "cwebp") add_executable(cwebp ${CWEBP_SRCS}) target_link_libraries(cwebp exampleutil imagedec webp) - target_include_directories(cwebp PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src) + target_include_directories(cwebp PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR}) install(TARGETS cwebp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() @@ -511,13 +524,12 @@ if(WEBP_BUILD_LIBWEBPMUX) parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/src/mux "WEBP_MUX_SRCS" "") add_library(libwebpmux ${WEBP_MUX_SRCS}) target_link_libraries(libwebpmux webp) - target_include_directories(libwebpmux - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}) - set_version(mux/Makefile.am libwebpmux webpmux) - set_target_properties(libwebpmux - PROPERTIES PUBLIC_HEADER - "${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux.h;\ + target_include_directories(libwebpmux PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}) + set_version(src/mux/Makefile.am libwebpmux webpmux) + set_target_properties( + libwebpmux + 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;") set_target_properties(libwebpmux PROPERTIES OUTPUT_NAME webpmux) @@ -531,11 +543,7 @@ if(WEBP_BUILD_GIF2WEBP) parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "GIF2WEBP_SRCS" "gif2webp") add_executable(gif2webp ${GIF2WEBP_SRCS}) - target_link_libraries(gif2webp - exampleutil - imageioutil - webp - libwebpmux + target_link_libraries(gif2webp exampleutil imageioutil webp libwebpmux ${WEBP_DEP_GIF_LIBRARIES}) target_include_directories(gif2webp PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src) install(TARGETS gif2webp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) @@ -547,13 +555,10 @@ if(WEBP_BUILD_IMG2WEBP) parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "IMG2WEBP_SRCS" "img2webp") add_executable(img2webp ${IMG2WEBP_SRCS}) - target_link_libraries(img2webp - exampleutil - imagedec - imageioutil - webp + target_link_libraries(img2webp exampleutil imagedec imageioutil webp libwebpmux) - target_include_directories(img2webp PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src) + target_include_directories(img2webp PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR}) install(TARGETS img2webp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() @@ -564,17 +569,17 @@ if(WEBP_BUILD_VWEBP) include_directories(${WEBP_DEP_IMG_INCLUDE_DIRS}) parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "VWEBP_SRCS" "vwebp") add_executable(vwebp ${VWEBP_SRCS}) - target_link_libraries(vwebp - ${OPENGL_LIBRARIES} - exampleutil - ${GLUT_glut_LIBRARY} - imageioutil - webp - webpdemux) - target_include_directories(vwebp - PRIVATE ${GLUT_INCLUDE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/src - ${OPENGL_INCLUDE_DIR}) + target_link_libraries( + vwebp + ${OPENGL_LIBRARIES} + exampleutil + GLUT::GLUT + imageioutil + webp + webpdemux) + target_include_directories( + vwebp PRIVATE ${GLUT_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/src + ${OPENGL_INCLUDE_DIR}) install(TARGETS vwebp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") check_c_compiler_flag("-Wno-deprecated-declarations" HAS_NO_DEPRECATED) @@ -592,9 +597,8 @@ if(WEBP_BUILD_WEBPINFO) "webpinfo") add_executable(webpinfo ${WEBPINFO_SRCS}) target_link_libraries(webpinfo exampleutil imageioutil) - target_include_directories(webpinfo - PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src - ${CMAKE_CURRENT_SOURCE_DIR}/src) + target_include_directories(webpinfo PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR}/src) install(TARGETS webpinfo RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() @@ -617,41 +621,46 @@ if(WEBP_BUILD_EXTRAS) # libextras add_library(extras STATIC ${WEBP_EXTRAS_SRCS}) - target_include_directories(extras - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/src) + target_include_directories( + extras PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src) # get_disto add_executable(get_disto ${GET_DISTO_SRCS}) target_link_libraries(get_disto imagedec) - target_include_directories(get_disto - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/src) + target_include_directories(get_disto PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/src) # webp_quality add_executable(webp_quality ${WEBP_QUALITY_SRCS}) target_link_libraries(webp_quality exampleutil imagedec extras) - target_include_directories(webp_quality - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}) + target_include_directories(webp_quality PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}) # vwebp_sdl find_package(SDL) if(WEBP_BUILD_VWEBP AND SDL_FOUND) add_executable(vwebp_sdl ${VWEBP_SDL_SRCS}) target_link_libraries(vwebp_sdl ${SDL_LIBRARY} imageioutil webp) - target_include_directories(vwebp_sdl - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/src - ${SDL_INCLUDE_DIR}) + target_include_directories( + vwebp_sdl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/src ${SDL_INCLUDE_DIR}) set(WEBP_HAVE_SDL 1) target_compile_definitions(vwebp_sdl PUBLIC WEBP_HAVE_SDL) endif() endif() if(WEBP_BUILD_WEBP_JS) + # The default stack size changed from 5MB to 64KB in 3.1.27. See + # https://crbug.com/webp/614. + if(EMSCRIPTEN_VERSION VERSION_GREATER_EQUAL "3.1.27") + # TOTAL_STACK size was renamed to STACK_SIZE in 3.1.27. The old name was + # kept for compatibility, but prefer the new one in case it is removed in + # the future. + set(emscripten_stack_size "-sSTACK_SIZE=5MB") + else() + set(emscripten_stack_size "-sTOTAL_STACK=5MB") + endif() # wasm2js does not support SIMD. if(NOT WEBP_ENABLE_SIMD) # JavaScript version @@ -661,9 +670,9 @@ if(WEBP_BUILD_WEBP_JS) set(WEBP_HAVE_SDL 1) set_target_properties( webp_js - PROPERTIES LINK_FLAGS "-s WASM=0 \ - -s EXPORTED_FUNCTIONS='[\"_WebpToSDL\"]' -s INVOKE_RUN=0 \ - -s EXPORTED_RUNTIME_METHODS='[\"cwrap\"]'") + PROPERTIES LINK_FLAGS "-sWASM=0 ${emscripten_stack_size} \ + -sEXPORTED_FUNCTIONS=_WebPToSDL -sINVOKE_RUN=0 \ + -sEXPORTED_RUNTIME_METHODS=cwrap") set_target_properties(webp_js PROPERTIES OUTPUT_NAME webp) target_compile_definitions(webp_js PUBLIC EMSCRIPTEN WEBP_HAVE_SDL) endif() @@ -674,9 +683,9 @@ if(WEBP_BUILD_WEBP_JS) target_include_directories(webp_wasm PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) set_target_properties( webp_wasm - PROPERTIES LINK_FLAGS "-s WASM=1 \ - -s EXPORTED_FUNCTIONS='[\"_WebpToSDL\"]' -s INVOKE_RUN=0 \ - -s EXPORTED_RUNTIME_METHODS='[\"cwrap\"]'") + PROPERTIES LINK_FLAGS "-sWASM=1 ${emscripten_stack_size} \ + -sEXPORTED_FUNCTIONS=_WebPToSDL -sINVOKE_RUN=0 \ + -sEXPORTED_RUNTIME_METHODS=cwrap") target_compile_definitions(webp_wasm PUBLIC EMSCRIPTEN WEBP_HAVE_SDL) target_compile_definitions(webpdspdecode PUBLIC EMSCRIPTEN) @@ -688,14 +697,15 @@ if(WEBP_BUILD_ANIM_UTILS) parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "ANIM_DIFF_SRCS" "anim_diff") add_executable(anim_diff ${ANIM_DIFF_SRCS}) - target_link_libraries(anim_diff - exampleutil - imagedec - imageenc - imageioutil - webp - webpdemux - ${WEBP_DEP_GIF_LIBRARIES}) + target_link_libraries( + anim_diff + exampleutil + imagedec + imageenc + imageioutil + webp + webpdemux + ${WEBP_DEP_GIF_LIBRARIES}) target_include_directories(anim_diff PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src) # anim_dump @@ -703,49 +713,59 @@ if(WEBP_BUILD_ANIM_UTILS) parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "ANIM_DUMP_SRCS" "anim_dump") add_executable(anim_dump ${ANIM_DUMP_SRCS}) - target_link_libraries(anim_dump - exampleutil - imagedec - imageenc - imageioutil - webp - webpdemux - ${WEBP_DEP_GIF_LIBRARIES}) + target_link_libraries( + anim_dump + exampleutil + imagedec + imageenc + imageioutil + webp + webpdemux + ${WEBP_DEP_GIF_LIBRARIES}) target_include_directories(anim_dump PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src) endif() # Install the different headers and libraries. -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}) +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}:: +install(EXPORT ${PROJECT_NAME}Targets NAMESPACE ${PROJECT_NAME}:: DESTINATION ${ConfigPackageLocation}) # Create the CMake version file. include(CMakePackageConfigHelpers) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/WebPConfigVersion.cmake" - VERSION ${PACKAGE_VERSION} - COMPATIBILITY AnyNewerVersion) + VERSION ${PACKAGE_VERSION} COMPATIBILITY AnyNewerVersion) # Create the Config file. include(CMakePackageConfigHelpers) -# Fix libwebpmux reference. The target name libwebpmux is used for -# compatibility purposes, but the library mentioned in WebPConfig.cmake should -# be the unprefixed version. -list(TRANSFORM INSTALLED_LIBRARIES REPLACE "libwebpmux" "webpmux") +# Fix libwebpmux reference. The target name libwebpmux is used for compatibility +# purposes, but the library mentioned in WebPConfig.cmake should be the +# unprefixed version. Note string(...) can be replaced with list(TRANSFORM ...) +# if cmake_minimum_required is >= 3.12. +string(REGEX REPLACE "libwebpmux" "webpmux" INSTALLED_LIBRARIES + "${INSTALLED_LIBRARIES}") + +if(MSVC) + # For compatibility with nmake, MSVC builds use a custom prefix (lib) that + # needs to be included in the library name. + string(REGEX REPLACE "[A-Za-z0-9_]+" "${CMAKE_STATIC_LIBRARY_PREFIX}\\0" + INSTALLED_LIBRARIES "${INSTALLED_LIBRARIES}") +endif() + configure_package_config_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/WebPConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/WebPConfig.cmake - INSTALL_DESTINATION - ${ConfigPackageLocation}) + INSTALL_DESTINATION ${ConfigPackageLocation} + PATH_VARS CMAKE_INSTALL_INCLUDEDIR) # Install the generated CMake files. install(FILES "${CMAKE_CURRENT_BINARY_DIR}/WebPConfigVersion.cmake" @@ -777,7 +797,6 @@ 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 - COMPONENT doc) + DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) endif() endforeach() diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7a73a30..9540f34 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,10 +19,59 @@ again. All submissions, including submissions by project members, require review. We use a [Gerrit](https://www.gerritcodereview.com) instance hosted at -https://chromium-review.googlesource.com for this purpose. See the +https://chromium-review.googlesource.com for this purpose. + +## Sending patches + +The basic git workflow for modifying libwebp code and sending for review is: + +1. Get the latest version of the repository locally: + + ```sh + git clone https://chromium.googlesource.com/webm/libwebp && cd libwebp + ``` + +2. Copy the commit-msg script into ./git/hooks (this will add an ID to all of + your commits): + + ```sh + curl -Lo .git/hooks/commit-msg https://chromium-review.googlesource.com/tools/hooks/commit-msg && chmod u+x .git/hooks/commit-msg + ``` + +3. Modify the local copy of libwebp. Make sure the code + [builds successfully](https://chromium.googlesource.com/webm/libwebp/+/HEAD/doc/building.md#cmake). + +4. Choose a short and representative commit message: + + ```sh + git commit -a -m "Set commit message here" + ``` + +5. Send the patch for review: + + ```sh + git push https://chromium-review.googlesource.com/webm/libwebp HEAD:refs/for/main + ``` + + Go to https://chromium-review.googlesource.com to view your patch and + request a review from the maintainers. + +See the [WebM Project page](https://www.webmproject.org/code/contribute/submitting-patches/) for additional details. +## Code Style + +The C code style is based on the +[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html) and +`clang-format --style=Google`, though this project doesn't use the tool to +enforce the formatting. + +CMake files are formatted with +[cmake-format](https://cmake-format.readthedocs.io/en/latest/). `cmake-format +-i` can be used to format individual files, it will use the settings from +`.cmake-format.py`. + ## Community Guidelines This project follows diff --git a/ChangeLog b/ChangeLog index c7655f2..33ec486 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,228 @@ +1ace578c update NEWS +63234c42 bump version to 1.3.2 +2af26267 Fix OOB write in BuildHuffmanTable. +fd7bb21c update ChangeLog (tag: v1.3.1-rc2, tag: v1.3.1) +e1adea50 update NEWS +43393320 enc/*: normalize WebPEncodingSetError() calls +287fdefe enc/*: add missing WebPEncodingSetError() calls +c3bd7cff EncodeAlphaInternal: add missing error check +d49cfbb3 vp8l_enc,WriteImage: add missing error check +2e5a9ec3 muxread,MuxImageParse: add missing error checks +ebb6f949 cmake,emscripten: explicitly set stack size +59a2b1f9 WebPDecodeYUV: check u/v/stride/uv_stride ptrs +8e965ccb Call png_get_channels() to see if image has alpha +7f0a3419 update ChangeLog (tag: v1.3.1-rc1) +bab7efbe update NEWS +7138bf8f bump version to 1.3.1 +435b4ded update AUTHORS +47351229 update .mailmap +ff6c7f4e CONTRIBUTING.md: add C style / cmake-format notes +dd530437 add .cmake-format.py +adbe2cb1 cmake,cosmetics: apply cmake-format +15b36508 doc/webp-container-spec: rm future codec comment +c369c4bf doc/webp-lossless-bitstream-spec: improve link text +1de35f47 doc/webp-container-spec: don't use 'currently' +bb06a16e doc/webp-container-spec: prefer present tense +9f38b71e doc/webp-lossless-bitstream-spec: prefer present tense +7acb6b82 doc/webp-container-spec: avoid i.e. & e.g. +4967e7cd doc/webp-lossless-bitstream-spec: avoid i.e. & e.g. +e3366659 Merge "Do not find_package image libraries if not needed." into main +428588ef clarify single leaf node trees and use of canonical prefix coding +709ec152 Do not find_package image libraries if not needed. +8dd80ef8 fuzz_utils.h: lower kFuzzPxLimit w/ASan +8f187b9f Clean message calls in CMake +cba30078 WebPConfig.cmake.in: use calculated include path +6cf9a76a Merge "webp-lossless-bitstream-spec: remove use of 'dynamics'" into main +740943b2 Merge "Specialize and optimize ITransform_SSE2 using do_two" into main +2d547e24 Compare kFuzzPxLimit to max_num_operations +ac42dde1 Specialize and optimize ITransform_SSE2 using do_two +17e0ef1d webp-lossless-bitstream-spec: remove use of 'dynamics' +ed274371 neon.h,cosmetics: clear a couple lint warnings +3fb82947 cpu.h,cosmetics: segment defines +0c496a4f cpu.h: add WEBP_AARCH64 +8151f388 move VP8GetCPUInfo declaration to cpu.c +916548c2 Make kFuzzPxLimit sanitizer dependent +4070b271 advanced_api_fuzzer: reduce scaling limit +761f49c3 Merge "webp-lossless-bitstream-spec: add missing bits to ABNF" into main +84d04c48 webp-lossless-bitstream-spec: add missing bits to ABNF +0696e1a7 advanced_api_fuzzer: reduce scaling limit +93d88aa2 Merge "deps.cmake: remove unneeded header checks" into main +118e0035 deps.cmake: remove unneeded header checks +4c3d7018 webp-lossless-bitstream-spec: condense normal-prefix-code +a6a09b32 webp-lossless-bitstream-spec: fix 2 code typos +50ac4f7c Merge "cpu.h: enable NEON w/_M_ARM64EC" into main +4b7d7b4f Add contribution instructions +0afbd97b cpu.h: enable NEON w/_M_ARM64EC +349f4353 Merge changes Ibd89e56b,Ic57e7f84,I89096614 into main +8f7513b7 upsampling_neon.c: fix WEBP_SWAP_16BIT_CSP check +cbf624b5 advanced_api_fuzzer: reduce scaling limit +89edfdd1 Skip slow scaling in libwebp advanced_api_fuzzer +859f19f7 Reduce libwebp advanced_api_fuzzer threshold +a4f04835 Merge changes Ic389aaa2,I329ccd79 into main +1275fac8 Makefile.vc: fix img2webp link w/dynamic cfg +2fe27bb9 img2webp: normalize help output +24bed3d9 cwebp: reflow -near_lossless help text +0825faa4 img2webp: add -sharp_yuv/-near_lossless +d64e6d7d Merge "PaletteSortModifiedZeng: fix leak on error" into main +0e12a22d Merge "EncodeAlphaInternal: clear result->bw on error" into main +0edbb6ea PaletteSortModifiedZeng: fix leak on error +41ffe04e Merge "Update yapf style from "chromium" to "yapf"" into main +2d9d9265 Update yapf style from "chromium" to "yapf" +a486d800 EncodeAlphaInternal: clear result->bw on error +1347a32d Skip big scaled advanced_api_fuzzer +52b6f067 Fix scaling limit in advanced_api_fuzzer.c +73618428 Limit scaling in libwebp advanced_api_fuzzer.c +b54d21a0 Merge "CMakeLists.txt: allow CMAKE_INSTALL_RPATH to be set empty" into main +31c28db5 libwebp{,demux,mux}.pc.in: Requires -> Requires.private +d9a505ff CMakeLists.txt: allow CMAKE_INSTALL_RPATH to be set empty +bdf33d03 Merge tag 'v1.3.0' +b5577769 update ChangeLog (tag: v1.3.0-rc1, tag: v1.3.0) +0ba77244 update NEWS +e763eb1e bump version to 1.3.0 +2a8686fc update AUTHORS +106a57c1 Merge "*/Android.mk: add a check for NDK_ROOT" into main +c5e841c4 Merge "extras: WebpToSDL -> WebPToSDL" into main +dbc30715 Merge "xcframeworkbuild.sh: bump MACOSX_CATALYST_MIN_VERSION" into main +6fc1a9f9 */Android.mk: add a check for NDK_ROOT +d3e151fc doc/api.md,webp_js/README.md: Webp -> WebP +ed92a626 extras: WebpToSDL -> WebPToSDL +6eb0189b xcframeworkbuild.sh: bump MACOSX_CATALYST_MIN_VERSION +1d58575b CMake: align .pc variables with autoconf +e5fe2cfc webp-lossless-bitstream-spec,cosmetics: reflow paragraphs +0ceeeab9 webp-lossless-bitstream-spec: add amendment note +607611cd Merge "webp-container-spec: normalize section title case" into main +f853685e lossless: SUBTRACT_GREEN -> SUBTRACT_GREEN_TRANSFORM +786497e4 webp-lossless-bitstream-spec: fix inv color txfm description +c6ac672d webp-lossless-bitstream-spec: fix num_code_lengths check +b5700efb webp-lossless-bitstream-spec,cosmetics: grammar/capitalization +d8ed8c11 webp-container-spec: normalize section title case +52ec0b8f Merge changes Ie975dbb5,Ifc8c93af,I6ca7c5d6,I2e8d66f5,I152477b8 into main +5097ef62 webp-container-spec,cosmetics: grammar/capitalization +e3ba2b1f webp-lossless-bitstream-spec,cosmetics: reflow abstract +1e8e3ded webp-lossless-bitstream-spec: reword abstract re alpha +017cb6fa webp-container-spec,cosmetics: normalize range syntax +f6a4684b webp-lossless-bitstream-spec,cosmetics: normalize range syntax +54ebd5a3 webp-lossless-bitstream-spec: limit dist map lut to 69 cols +44741f9c webp-lossless-bitstream-spec: fix dist mapping example +fad0ece7 pnmdec.c: use snprintf instead of sprintf +3f73e8f7 sharpyuv: add SharpYuvGetVersion() +ce2f2d66 SharpYuvConvert: fix a race on SharpYuvGetCPUInfo +a458e308 sharpyuv_dsp.h: restore sharpyuv_cpu.h include +9ba800a7 Merge changes Id72fbf3b,Ic59d23a2 into main +979c0ebb sharpyuv: add SharpYuvGetCPUInfo +8bab09a4 Merge "*.pc.in: rename lib_prefix to webp_libname_prefix" into main +769387c5 cpu.c,cosmetics: fix a typo +a02978c2 sharpyuv/Makefile.am+cmake: add missing -lm +28aedcb9 *.pc.in: rename lib_prefix to webp_libname_prefix +c42e6d5a configure.ac: export an empty lib_prefix variable +dfc843aa Merge "*.pc.in: add lib prefix to lib names w/MSVC" into main +2498209b *.pc.in: add lib prefix to lib names w/MSVC +ac252b61 Merge "analysis_enc.c: fix a dead store warning" into main +56944762 analysis_enc.c: fix a dead store warning +d34f9b99 Merge "webp-lossless-bitstream-spec: convert BNF to ABNF" into main +dc05b4db Merge changes I96bc063c,I45880467,If9e18e5a,I6ee938e4,I0a410b28, ... into main +83270c7f webp-container-spec: add prose for rendering process +73b19b64 webp-container-spec: note reserved fields MUST be ignored +57101d3f webp-lossless-bitstream-spec: improve 'small' color table stmt +dfd32e45 webp-container-spec: remove redundant sentence +8a6185dd doc/webp-*: fix some punctuation, grammar +72776530 webp-lossless-bitstream-spec: convert BNF to ABNF +d992bb08 cmake: rename cpufeatures target to cpufeatures-webp +3ed2b275 webp-container-spec: clarify background color note +951c292d webp-container-spec: come too late -> out of order +902dd787 webp-container-spec: prefer hex literals +a8f6b5ee webp-container-spec: change SHOULD to MUST w/ANIM chunk +1dc59435 webp-container-spec: add unknown fields MUST be ignored +280a810f webp-container-spec: make padding byte=0 a MUST +41f0bf68 webp-container-spec: update note on trailing data +6bdd36db webp-container-spec: clarify Chunk Size is in bytes +87e36c48 Merge "webp_js/README.md,cosmetics: reflow some lines" into main +5b01f321 Merge "Update Windows makefile to build libsharpyuv library." into main +19b1a71c webp_js/README.md,cosmetics: reflow some lines +780db756 Update Windows makefile to build libsharpyuv library. +e407d4b3 CMakeLists.txt: replace GLUT_glut_LIBRARY w/GLUT::GLUT +abf73d62 Merge "WebPConfig.cmake.in: add find_dependency(Threads)" into main +25807fb4 Merge "cmake: restore compatibility with cmake < 3.12" into main +5dbc4bfa WebPConfig.cmake.in: add find_dependency(Threads) +b2a175dd Merge "Update wasm instructions." into main +cb90f76b Update wasm instructions. +02d15258 cmake: restore compatibility with cmake < 3.12 +5ba046e2 CMake: add_definitions -> add_compile_options +e68765af dsp,neon: use vaddv in a few more places +e8f83de2 Set libsharpyuv include dir to 'webp' subdirectory. +15a91ab1 cmake,cosmetics: apply cmake-format +0dd49d1a CMakeLists.txt: set @ONLY in configure_file() calls +62b1bfe8 Merge changes I2877e7bb,I777cad70,I15af7d1a,I686e6740,If10538a9, ... into main +95c8fe5f Merge changes Iecea3603,I9dc228ab into main +e7c805cf picture_csp_enc.c: remove SafeInitSharpYuv +6af8845a sharpyuv: prefer webp/types.h +639619ce cmake: fix dll exports +782ed48c sharpyuv,SharpYuvInit: add mutex protection when available +cad0d5ad sharyuv_{neon,sse2}.c: merge WEBP_USE_* sections +ef70ee06 add a few missing includes for NULL +f0f9eda4 sharpyuv.h: remove +9b902cba Merge "picture_csp_enc.c,CheckNonOpaque: rm unneeded local" into main +9c1d457c cmake/cpu.cmake: remove unused variable +9ac25bcb CMakeLists.txt,win32: match naming convention used by nmake +76c353ba picture_csp_enc.c,CheckNonOpaque: rm unneeded local +5000de54 Merge "cwebp: fix WebPPictureHasTransparency call" into main +e1729309 Merge "WebPPictureHasTransparency: add missing pointer check" into main +00ff988a vp8l_enc,AddSingleSubGreen: clear int sanitizer warnings +e2fecc22 dsp/lossless_enc.c: clear int sanitizer warnings +129cf9e9 dsp/lossless.c: clear int sanitizer warnings +ad7d1753 dsp/lossless_enc.c: clear int sanitizer warnings +5037220e VP8LSubtractGreenFromBlueAndRed_C: clear int sanitizer warnings +2ee786c7 upsampling_sse2.c: clear int sanitizer warnings +4cc157d4 ParseOptionalChunks: clear int sanitizer warning +892cf033 BuildHuffmanTable: clear int sanitizer warning +3a9a4d45 VP8GetSigned: clear int sanitizer warnings +704a3d0a dsp/lossless.c: quiet int sanitizer warnings +1a6c109c WebPPictureHasTransparency: add missing pointer check +c626e7d5 cwebp: fix WebPPictureHasTransparency call +866e349c Merge tag 'v1.2.4' +c170df38 Merge "Create libsharpyuv.a in makefile.unix." into main +9d7ff74a Create libsharpyuv.a in makefile.unix. +0d1f1254 update ChangeLog (tag: v1.2.4) +fcbc2d78 Merge "doc/*.txt: restrict code to 69 columns" into main +4ad0e189 Merge "webp-container-spec.txt: normalize fourcc spelling" into main 980d2488 update NEWS 9fde8127 bump version to 1.2.4 +7a0a9935 doc/*.txt: restrict code to 69 columns +c040a615 webp-container-spec.txt: normalize fourcc spelling +aff1c546 dsp,x86: normalize types w/_mm_cvtsi128_si32 calls +ab540ae0 dsp,x86: normalize types w/_mm_cvtsi32_si128 calls +8980362e dsp,x86: normalize types w/_mm_set* calls (2) e626925c lossless: fix crunch mode w/WEBP_REDUCE_SIZE +83539239 dsp,x86: normalize types w/_mm_set* calls +8a4576ce webp-container-spec.txt: replace & with & +db870881 Merge "webp-container-spec.txt: make reserved 0 values a MUST" into main +01d7d378 webp-lossless-bitstream-spec: number all sections +337cf69f webp-lossless-bitstream-spec: mv Nomenclature after Intro +79be856e Merge changes I7111d1f7,I872cd62c into main +5b87983a webp-container-spec.txt: make reserved 0 values a MUST +bd939123 Merge changes I7a25b1a6,I51b2c2a0,I87d0cbcf,I6ec60af6,I0a3fe9dc into main +04764b56 libwebp.pc: add libsharpyuv to requires +7deee810 libsharpyuv: add pkg-config file +1a64a7e6 webp-container-spec.txt: clarify some SHOULDs +bec2c88a webp-container-spec.txt: move ChunkHeader to terminology +c9359332 webp-container-spec.txt: clarify 'VP8 '/'XMP ' fourccs +70fe3063 webp-container-spec.txt: rightsize table entries +ddbf3f3f webp-container-spec.txt: update 'key words' text +c151e95b utils.h,WEBP_ALIGN: make bitmask unsigned +748e92bb add WebPInt32ToMem +3fe15b67 Merge "Build libsharpyuv as a full installable library." into main +4f402f34 add WebPMemToInt32 +a3b68c19 Build libsharpyuv as a full installable library. +b4994eaa CMake: set rpath for shared objects +94cd7117 Merge "CMake: fix dylib versioning" into main +e91451b6 Fix the lossless specs a bit more. +231bdfb7 CMake: fix dylib versioning bfad7ab5 CMakeLists.txt: correct libwebpmux name in WebPConfig.cmake c2e3fd30 Revert "cmake: fix webpmux lib name for cmake linking" +7366f7f3 Merge "lossless: fix crunch mode w/WEBP_REDUCE_SIZE" into main +84163d9d lossless: fix crunch mode w/WEBP_REDUCE_SIZE +d01c1eb3 webp-lossless-bitstream-spec,cosmetics: normalize capitalization +8813ca8e Merge tag 'v1.2.3' 3c4a0fbf update ChangeLog (tag: v1.2.3) 56a480e8 dsp/cpu.h: add missing extern "C" 62b45bdd update ChangeLog (tag: v1.2.3-rc1) diff --git a/Makefile.vc b/Makefile.vc index f254109..cb6b7a9 100644 --- a/Makefile.vc +++ b/Makefile.vc @@ -5,6 +5,7 @@ LIBWEBPDECODER_BASENAME = libwebpdecoder LIBWEBP_BASENAME = libwebp LIBWEBPMUX_BASENAME = libwebpmux LIBWEBPDEMUX_BASENAME = libwebpdemux +LIBSHARPYUV_BASENAME = libsharpyuv !IFNDEF ARCH !IF ! [ cl 2>&1 | find "x86" > NUL ] @@ -96,6 +97,7 @@ LIBWEBPDECODER_BASENAME = $(LIBWEBPDECODER_BASENAME)_debug LIBWEBP_BASENAME = $(LIBWEBP_BASENAME)_debug LIBWEBPMUX_BASENAME = $(LIBWEBPMUX_BASENAME)_debug LIBWEBPDEMUX_BASENAME = $(LIBWEBPDEMUX_BASENAME)_debug +LIBSHARPYUV_BASENAME = $(LIBSHARPYUV_BASENAME)_debug !ELSE IF "$(CFG)" == "release-dynamic" CC = $(CCNODBG) RC = $(RCNODBG) @@ -109,6 +111,7 @@ LIBWEBPDECODER_BASENAME = $(LIBWEBPDECODER_BASENAME)_debug LIBWEBP_BASENAME = $(LIBWEBP_BASENAME)_debug LIBWEBPMUX_BASENAME = $(LIBWEBPMUX_BASENAME)_debug LIBWEBPDEMUX_BASENAME = $(LIBWEBPDEMUX_BASENAME)_debug +LIBSHARPYUV_BASENAME = $(LIBSHARPYUV_BASENAME)_debug !ENDIF !IF "$(STATICLIBBUILD)" == "TRUE" @@ -118,13 +121,14 @@ LIBWEBPDECODER = $(DIRLIB)\$(LIBWEBPDECODER_BASENAME).lib LIBWEBP = $(DIRLIB)\$(LIBWEBP_BASENAME).lib LIBWEBPMUX = $(DIRLIB)\$(LIBWEBPMUX_BASENAME).lib LIBWEBPDEMUX = $(DIRLIB)\$(LIBWEBPDEMUX_BASENAME).lib +LIBSHARPYUV = $(DIRLIB)\$(LIBSHARPYUV_BASENAME).lib !ELSE IF "$(DLLBUILD)" == "TRUE" -DLLINC = webp_dll.h -CC = $(CC) /I$(DIROBJ) /FI$(DLLINC) $(RTLIB) /DWEBP_DLL +CC = $(CC) /I$(DIROBJ) $(RTLIB) /DWEBP_DLL LIBWEBPDECODER = $(DIRLIB)\$(LIBWEBPDECODER_BASENAME)_dll.lib LIBWEBP = $(DIRLIB)\$(LIBWEBP_BASENAME)_dll.lib LIBWEBPMUX = $(DIRLIB)\$(LIBWEBPMUX_BASENAME)_dll.lib LIBWEBPDEMUX = $(DIRLIB)\$(LIBWEBPDEMUX_BASENAME)_dll.lib +LIBSHARPYUV = $(DIRLIB)\$(LIBSHARPYUV_BASENAME)_dll.lib LIBWEBP_PDBNAME = $(DIROBJ)\$(LIBWEBP_BASENAME)_dll.pdb CFGSET = TRUE !ENDIF @@ -176,6 +180,7 @@ CFLAGS = $(CFLAGS) /D_UNICODE /DUNICODE SHARPYUV_OBJS = \ $(DIROBJ)\sharpyuv\sharpyuv.obj \ + $(DIROBJ)\sharpyuv\sharpyuv_cpu.obj \ $(DIROBJ)\sharpyuv\sharpyuv_csp.obj \ $(DIROBJ)\sharpyuv\sharpyuv_dsp.obj \ $(DIROBJ)\sharpyuv\sharpyuv_gamma.obj \ @@ -343,12 +348,13 @@ UTILS_ENC_OBJS = \ $(DIROBJ)\utils\quant_levels_utils.obj \ LIBWEBPDECODER_OBJS = $(DEC_OBJS) $(DSP_DEC_OBJS) $(UTILS_DEC_OBJS) -LIBWEBP_OBJS = $(LIBWEBPDECODER_OBJS) $(SHARPYUV_OBJS) $(ENC_OBJS) \ +LIBWEBP_OBJS = $(LIBWEBPDECODER_OBJS) $(ENC_OBJS) \ $(DSP_ENC_OBJS) $(UTILS_ENC_OBJS) $(DLL_OBJS) LIBWEBPMUX_OBJS = $(MUX_OBJS) $(LIBWEBPMUX_OBJS) LIBWEBPDEMUX_OBJS = $(DEMUX_OBJS) $(LIBWEBPDEMUX_OBJS) +LIBSHARPYUV_OBJS = $(SHARPYUV_OBJS) -OUT_LIBS = $(LIBWEBPDECODER) $(LIBWEBP) +OUT_LIBS = $(LIBWEBPDECODER) $(LIBWEBP) $(LIBSHARPYUV) !IF "$(ARCH)" == "ARM" ex: $(OUT_LIBS) all: ex @@ -376,7 +382,7 @@ $(DIRBIN)\anim_dump.exe: $(EX_GIF_DEC_OBJS) $(LIBWEBPDEMUX) $(LIBWEBP) $(DIRBIN)\anim_dump.exe: $(IMAGEIO_ENC_OBJS) $(DIRBIN)\cwebp.exe: $(DIROBJ)\examples\cwebp.obj $(IMAGEIO_DEC_OBJS) $(DIRBIN)\cwebp.exe: $(IMAGEIO_UTIL_OBJS) -$(DIRBIN)\cwebp.exe: $(LIBWEBPDEMUX) +$(DIRBIN)\cwebp.exe: $(LIBWEBPDEMUX) $(LIBSHARPYUV) $(DIRBIN)\dwebp.exe: $(DIROBJ)\examples\dwebp.obj $(IMAGEIO_DEC_OBJS) $(DIRBIN)\dwebp.exe: $(IMAGEIO_ENC_OBJS) $(DIRBIN)\dwebp.exe: $(IMAGEIO_UTIL_OBJS) @@ -394,7 +400,7 @@ $(DIRBIN)\webpmux.exe: $(EX_UTIL_OBJS) $(IMAGEIO_UTIL_OBJS) $(LIBWEBP) $(DIRBIN)\img2webp.exe: $(DIROBJ)\examples\img2webp.obj $(LIBWEBPMUX) $(DIRBIN)\img2webp.exe: $(IMAGEIO_DEC_OBJS) $(DIRBIN)\img2webp.exe: $(EX_UTIL_OBJS) $(IMAGEIO_UTIL_OBJS) -$(DIRBIN)\img2webp.exe: $(LIBWEBPDEMUX) $(LIBWEBP) +$(DIRBIN)\img2webp.exe: $(LIBWEBPDEMUX) $(LIBWEBP) $(LIBSHARPYUV) $(DIRBIN)\get_disto.exe: $(DIROBJ)\extras\get_disto.obj $(DIRBIN)\get_disto.exe: $(IMAGEIO_DEC_OBJS) $(IMAGEIO_UTIL_OBJS) $(DIRBIN)\get_disto.exe: $(LIBWEBPDEMUX) $(LIBWEBP) @@ -417,17 +423,16 @@ $(EX_UTIL_OBJS) $(IMAGEIO_UTIL_OBJS): $(OUTPUT_DIRS) $(IMAGEIO_DEC_OBJS) $(IMAGEIO_ENC_OBJS) $(EXTRAS_OBJS): $(OUTPUT_DIRS) !ENDIF # ARCH == ARM +$(LIBSHARPYUV): $(LIBSHARPYUV_OBJS) $(LIBWEBPDECODER): $(LIBWEBPDECODER_OBJS) -$(LIBWEBP): $(LIBWEBP_OBJS) +$(LIBWEBP): $(LIBWEBP_OBJS) $(LIBSHARPYUV) $(LIBWEBPMUX): $(LIBWEBPMUX_OBJS) $(LIBWEBPDEMUX): $(LIBWEBPDEMUX_OBJS) -$(LIBWEBP_OBJS) $(LIBWEBPMUX_OBJS) $(LIBWEBPDEMUX_OBJS): $(OUTPUT_DIRS) +$(LIBWEBP_OBJS) $(LIBWEBPMUX_OBJS) $(LIBWEBPDEMUX_OBJS) $(LIBSHARPYUV_OBJS): \ + $(OUTPUT_DIRS) !IF "$(DLLBUILD)" == "TRUE" -$(LIBWEBP_OBJS) $(LIBWEBPMUX_OBJS) $(LIBWEBPDEMUX_OBJS): \ - $(DIROBJ)\$(DLLINC) - {$(DIROBJ)}.c{$(DIROBJ)}.obj: $(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$@ $< @@ -437,20 +442,20 @@ $(LIBWEBP_OBJS) $(LIBWEBPMUX_OBJS) $(LIBWEBPDEMUX_OBJS): \ $(RC) /fo$@ $< {src\mux}.rc{$(DIROBJ)\mux}.res: $(RC) /fo$@ $< +{sharpyuv}.rc{$(DIROBJ)\sharpyuv}.res: + $(RC) /fo$@ $< -$(LIBWEBP): $(DIROBJ)\$(LIBWEBP_BASENAME:_debug=).res +$(LIBSHARPYUV): $(DIROBJ)\sharpyuv\$(LIBSHARPYUV_BASENAME:_debug=).res +$(LIBWEBP): $(LIBSHARPYUV) $(DIROBJ)\$(LIBWEBP_BASENAME:_debug=).res $(LIBWEBPDECODER): $(DIROBJ)\$(LIBWEBPDECODER_BASENAME:_debug=).res $(LIBWEBPMUX): $(LIBWEBP) $(DIROBJ)\mux\$(LIBWEBPMUX_BASENAME:_debug=).res $(LIBWEBPDEMUX): $(LIBWEBP) $(DIROBJ)\demux\$(LIBWEBPDEMUX_BASENAME:_debug=).res -$(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX): +$(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX) $(LIBSHARPYUV): $(LNKDLL) /out:$(DIRBIN)\$(@B:_dll=.dll) /implib:$@ $(LFLAGS) $** -xcopy $(DIROBJ)\*.pdb $(DIRLIB) /y - -clean:: - @-erase /s $(DIROBJ)\$(DLLINC) 2> NUL !ELSE -$(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX): +$(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX) $(LIBSHARPYUV): $(LNKLIB) /out:$@ $** -xcopy $(DIROBJ)\*.pdb $(DIRLIB) /y !ENDIF @@ -458,13 +463,6 @@ $(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX): $(OUTPUT_DIRS): @if not exist "$(@)" mkdir "$(@)" -# generate a helper include to define WEBP_EXTERN suitable for the DLL build -$(DIROBJ)\$(DLLINC): - @echo #ifndef WEBP_DLL_H_ > $@ - @echo #define WEBP_DLL_H_ >> $@ - @echo #define WEBP_EXTERN __declspec(dllexport) >> $@ - @echo #endif /* WEBP_DLL_H_ */ >> $@ - .SUFFIXES: .c .obj .res .exe # File-specific flag builds. Note batch rules take precedence over wildcards, # so for now name each file individually. diff --git a/NEWS b/NEWS index c2bf389..47f8451 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,30 @@ +- 9/13/2023: version 1.3.2 + This is a binary compatible release. + * security fix for lossless decoder (chromium: #1479274, CVE-2023-4863) + +- 6/23/2023: version 1.3.1 + This is a binary compatible release. + * security fixes for lossless encoder (#603, chromium: #1420107, #1455619, + CVE-2023-1999) + * improve error reporting through WebPPicture error codes + * fix upsampling for RGB565 and RGBA4444 in NEON builds + * img2webp: add -sharp_yuv & -near_lossless + * Windows builds: + - fix compatibility with clang-cl (#607) + - improve Arm64 performance with cl.exe + - add Arm64EC support + * fix webp_js with emcc >= 3.1.27 (stack size change, #614) + * CMake fixes (#592, #610, #612) + * further updates to the container and lossless bitstream docs (#581, #611) + +- 12/16/2022: version 1.3.0 + This is a binary compatible release. + * add libsharpyuv, which exposes -sharp_yuv/config.use_sharp_yuv + functionality to other libraries; libwebp now depends on this library + * major updates to the container and lossless bitstream docs (#448, #546, + #551) + * miscellaneous warning, bug & build fixes (#576, #583, #584) + - 8/4/2022: version 1.2.4 This is a binary compatible release. * restore CMake libwebpmux target name for compatibility with 1.2.2 (#575) diff --git a/README.md b/README.md index 396a741..a9f2c0e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ \__\__/\____/\_____/__/ ____ ___ / _/ / \ \ / _ \/ _/ / \_/ / / \ \ __/ \__ - \____/____/\_____/_____/____/v1.2.4 + \____/____/\_____/_____/____/v1.3.2 ``` WebP codec is a library to encode and decode images in WebP format. This package diff --git a/build.gradle b/build.gradle index 13202a8..c25314c 100644 --- a/build.gradle +++ b/build.gradle @@ -107,6 +107,7 @@ model { source { srcDir "sharpyuv" include "sharpyuv.c" + include "sharpyuv_cpu.c" include "sharpyuv_csp.c" include "sharpyuv_dsp.c" include "sharpyuv_gamma.c" diff --git a/cmake/WebPConfig.cmake.in b/cmake/WebPConfig.cmake.in index 822fc59..8c883fe 100644 --- a/cmake/WebPConfig.cmake.in +++ b/cmake/WebPConfig.cmake.in @@ -3,9 +3,16 @@ set(WEBP_VERSION ${WebP_VERSION}) @PACKAGE_INIT@ -include ("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +if(@WEBP_USE_THREAD@) + include(CMakeFindDependencyMacro) + find_dependency(Threads REQUIRED) +endif() -set(WebP_INCLUDE_DIRS "@CMAKE_INSTALL_FULL_INCLUDEDIR@") +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") + +set_and_check(WebP_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") set(WEBP_INCLUDE_DIRS ${WebP_INCLUDE_DIRS}) set(WebP_LIBRARIES "@INSTALLED_LIBRARIES@") set(WEBP_LIBRARIES "${WebP_LIBRARIES}") + +check_required_components(WebP) diff --git a/cmake/config.h.in b/cmake/config.h.in index 3770935..fe1c53a 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -16,48 +16,18 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_CPU_FEATURES_H 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_DLFCN_H 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_GLUT_GLUT_H 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_GL_GLUT_H 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_MEMORY_H 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_OPENGL_GLUT_H 1 -/* Have PTHREAD_PRIO_INHERIT. */ -#cmakedefine HAVE_PTHREAD_PRIO_INHERIT @HAVE_PTHREAD_PRIO_INHERIT@ - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SHLWAPI_H 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_TYPES_H 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UNISTD_H 1 @@ -93,9 +63,6 @@ /* Define to the version of this package. */ #cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" -/* Define to 1 if you have the ANSI C header files. */ -#cmakedefine STDC_HEADERS 1 - /* Version number of package */ #cmakedefine VERSION "@VERSION@" diff --git a/cmake/cpu.cmake b/cmake/cpu.cmake index bc0dbc9..7513ca8 100644 --- a/cmake/cpu.cmake +++ b/cmake/cpu.cmake @@ -18,7 +18,8 @@ function(webp_check_compiler_flag WEBP_SIMD_FLAG ENABLE_SIMD) unset(WEBP_HAVE_FLAG_${WEBP_SIMD_FLAG} CACHE) cmake_push_check_state() set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}) - check_c_source_compiles(" + check_c_source_compiles( + " #include \"${CMAKE_CURRENT_LIST_DIR}/../src/dsp/dsp.h\" int main(void) { #if !defined(WEBP_USE_${WEBP_SIMD_FLAG}) @@ -26,7 +27,8 @@ function(webp_check_compiler_flag WEBP_SIMD_FLAG ENABLE_SIMD) #endif return 0; } - " WEBP_HAVE_FLAG_${WEBP_SIMD_FLAG}) + " + WEBP_HAVE_FLAG_${WEBP_SIMD_FLAG}) cmake_pop_check_state() if(WEBP_HAVE_FLAG_${WEBP_SIMD_FLAG}) set(WEBP_HAVE_${WEBP_SIMD_FLAG} 1 PARENT_SCOPE) @@ -52,13 +54,10 @@ if(MSVC AND CMAKE_C_COMPILER_ID STREQUAL "MSVC") endif() set(SIMD_DISABLE_FLAGS) else() - set(SIMD_ENABLE_FLAGS - "-msse4.1;-msse2;-mips32;-mdspr2;-mfpu=neon;-mmsa") - set(SIMD_DISABLE_FLAGS - "-mno-sse4.1;-mno-sse2;;-mno-dspr2;;-mno-msa") + set(SIMD_ENABLE_FLAGS "-msse4.1;-msse2;-mips32;-mdspr2;-mfpu=neon;-mmsa") + set(SIMD_DISABLE_FLAGS "-mno-sse4.1;-mno-sse2;;-mno-dspr2;;-mno-msa") endif() -set(WEBP_SIMD_FILES_TO_NOT_INCLUDE) set(WEBP_SIMD_FILES_TO_INCLUDE) set(WEBP_SIMD_FLAGS_TO_INCLUDE) @@ -75,8 +74,8 @@ list(LENGTH WEBP_SIMD_FLAGS WEBP_SIMD_FLAGS_LENGTH) math(EXPR WEBP_SIMD_FLAGS_RANGE "${WEBP_SIMD_FLAGS_LENGTH} - 1") foreach(I_SIMD RANGE ${WEBP_SIMD_FLAGS_RANGE}) - # With Emscripten 2.0.9 -msimd128 -mfpu=neon will enable NEON, but the - # source will fail to compile. + # With Emscripten 2.0.9 -msimd128 -mfpu=neon will enable NEON, but the source + # will fail to compile. if(EMSCRIPTEN AND ${I_SIMD} GREATER_EQUAL 2) break() endif() @@ -108,7 +107,7 @@ foreach(I_SIMD RANGE ${WEBP_SIMD_FLAGS_RANGE}) # Check which files we should include or not. list(GET WEBP_SIMD_FILE_EXTENSIONS ${I_SIMD} WEBP_SIMD_FILE_EXTENSION) file(GLOB SIMD_FILES "${CMAKE_CURRENT_LIST_DIR}/../" - "src/dsp/*${WEBP_SIMD_FILE_EXTENSION}") + "src/dsp/*${WEBP_SIMD_FILE_EXTENSION}") if(WEBP_HAVE_${WEBP_SIMD_FLAG}) # Memorize the file and flags. foreach(FILE ${SIMD_FILES}) @@ -142,11 +141,9 @@ foreach(I_SIMD RANGE ${WEBP_SIMD_FLAGS_RANGE}) set(COMMON_PATTERNS) endif() set(CMAKE_REQUIRED_DEFINITIONS ${SIMD_COMPILE_FLAG}) - check_c_source_compiles("int main(void) {return 0;}" - FLAG_${SIMD_COMPILE_FLAG} - FAIL_REGEX - "warning: argument unused during compilation:" - ${COMMON_PATTERNS}) + check_c_source_compiles( + "int main(void) {return 0;}" FLAG_${SIMD_COMPILE_FLAG} FAIL_REGEX + "warning: argument unused during compilation:" ${COMMON_PATTERNS}) if(NOT FLAG_${SIMD_COMPILE_FLAG}) unset(HAS_COMPILE_FLAG) unset(HAS_COMPILE_FLAG CACHE) diff --git a/cmake/deps.cmake b/cmake/deps.cmake index f79cdbb..0760ba9 100644 --- a/cmake/deps.cmake +++ b/cmake/deps.cmake @@ -10,24 +10,30 @@ # Check for compiler options. include(CheckCSourceCompiles) -check_c_source_compiles(" +check_c_source_compiles( + " int main(void) { (void)__builtin_bswap16(0); return 0; } - " HAVE_BUILTIN_BSWAP16) -check_c_source_compiles(" + " + HAVE_BUILTIN_BSWAP16) +check_c_source_compiles( + " int main(void) { (void)__builtin_bswap32(0); return 0; } - " HAVE_BUILTIN_BSWAP32) -check_c_source_compiles(" + " + HAVE_BUILTIN_BSWAP32) +check_c_source_compiles( + " int main(void) { (void)__builtin_bswap64(0); return 0; } - " HAVE_BUILTIN_BSWAP64) + " + HAVE_BUILTIN_BSWAP64) # Check for libraries. if(WEBP_USE_THREAD) @@ -37,14 +43,6 @@ if(WEBP_USE_THREAD) if(CMAKE_USE_PTHREADS_INIT AND NOT CMAKE_SYSTEM_NAME STREQUAL "QNX") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") endif() - check_c_source_compiles(" - #include - int main (void) { - int attr = PTHREAD_PRIO_INHERIT; - return attr; - } - " FLAG_HAVE_PTHREAD_PRIO_INHERIT) - set(HAVE_PTHREAD_PRIO_INHERIT ${FLAG_HAVE_PTHREAD_PRIO_INHERIT}) list(APPEND WEBP_DEP_LIBRARIES Threads::Threads) endif() set(WEBP_USE_THREAD ${Threads_FOUND}) @@ -59,94 +57,88 @@ set(WEBP_HAVE_GL ${OPENGL_FOUND}) # Check if we need to link to the C math library. We do not look for it as it is # not found when cross-compiling, while it is here. -check_c_source_compiles(" +check_c_source_compiles( + " #include int main(int argc, char** argv) { return (int)pow(argc, 2.5); } - " HAVE_MATH_LIBRARY) + " + HAVE_MATH_LIBRARY) if(NOT HAVE_MATH_LIBRARY) message(STATUS "Adding -lm flag.") + list(APPEND SHARPYUV_DEP_LIBRARIES m) list(APPEND WEBP_DEP_LIBRARIES m) endif() # Find the standard image libraries. set(WEBP_DEP_IMG_LIBRARIES) set(WEBP_DEP_IMG_INCLUDE_DIRS) -foreach(I_LIB PNG JPEG TIFF) - # Disable tiff when compiling in static mode as it is failing on Ubuntu. - if(WEBP_LINK_STATIC AND ${I_LIB} STREQUAL "TIFF") - message("TIFF is disabled when statically linking.") - continue() - endif() - find_package(${I_LIB}) - set(WEBP_HAVE_${I_LIB} ${${I_LIB}_FOUND}) - if(${I_LIB}_FOUND) - list(APPEND WEBP_DEP_IMG_LIBRARIES ${${I_LIB}_LIBRARIES}) - list(APPEND WEBP_DEP_IMG_INCLUDE_DIRS ${${I_LIB}_INCLUDE_DIR} - ${${I_LIB}_INCLUDE_DIRS}) +if(WEBP_FIND_IMG_LIBS) + foreach(I_LIB PNG JPEG TIFF) + # Disable tiff when compiling in static mode as it is failing on Ubuntu. + if(WEBP_LINK_STATIC AND ${I_LIB} STREQUAL "TIFF") + message(STATUS "TIFF is disabled when statically linking.") + continue() + endif() + find_package(${I_LIB}) + set(WEBP_HAVE_${I_LIB} ${${I_LIB}_FOUND}) + if(${I_LIB}_FOUND) + list(APPEND WEBP_DEP_IMG_LIBRARIES ${${I_LIB}_LIBRARIES}) + list(APPEND WEBP_DEP_IMG_INCLUDE_DIRS ${${I_LIB}_INCLUDE_DIR} + ${${I_LIB}_INCLUDE_DIRS}) + endif() + endforeach() + if(WEBP_DEP_IMG_INCLUDE_DIRS) + list(REMOVE_DUPLICATES WEBP_DEP_IMG_INCLUDE_DIRS) endif() -endforeach() -if(WEBP_DEP_IMG_INCLUDE_DIRS) - list(REMOVE_DUPLICATES WEBP_DEP_IMG_INCLUDE_DIRS) -endif() -# GIF detection, gifdec isn't part of the imageio lib. -include(CMakePushCheckState) -set(WEBP_DEP_GIF_LIBRARIES) -set(WEBP_DEP_GIF_INCLUDE_DIRS) -find_package(GIF) -set(WEBP_HAVE_GIF ${GIF_FOUND}) -if(GIF_FOUND) - # GIF find_package only locates the header and library, it doesn't fail - # compile tests when detecting the version, but falls back to 3 (as of at - # least cmake 3.7.2). Make sure the library links to avoid incorrect detection - # when cross compiling. - cmake_push_check_state() - set(CMAKE_REQUIRED_LIBRARIES ${GIF_LIBRARIES}) - set(CMAKE_REQUIRED_INCLUDES ${GIF_INCLUDE_DIR}) - check_c_source_compiles(" + # GIF detection, gifdec isn't part of the imageio lib. + include(CMakePushCheckState) + set(WEBP_DEP_GIF_LIBRARIES) + set(WEBP_DEP_GIF_INCLUDE_DIRS) + find_package(GIF) + set(WEBP_HAVE_GIF ${GIF_FOUND}) + if(GIF_FOUND) + # GIF find_package only locates the header and library, it doesn't fail + # compile tests when detecting the version, but falls back to 3 (as of at + # least cmake 3.7.2). Make sure the library links to avoid incorrect + # detection when cross compiling. + cmake_push_check_state() + set(CMAKE_REQUIRED_LIBRARIES ${GIF_LIBRARIES}) + set(CMAKE_REQUIRED_INCLUDES ${GIF_INCLUDE_DIR}) + check_c_source_compiles( + " #include int main(void) { (void)DGifOpenFileHandle; return 0; } - " GIF_COMPILES) - cmake_pop_check_state() - if(GIF_COMPILES) - list(APPEND WEBP_DEP_GIF_LIBRARIES ${GIF_LIBRARIES}) - list(APPEND WEBP_DEP_GIF_INCLUDE_DIRS ${GIF_INCLUDE_DIR}) - else() - unset(GIF_FOUND) + " + GIF_COMPILES) + cmake_pop_check_state() + if(GIF_COMPILES) + list(APPEND WEBP_DEP_GIF_LIBRARIES ${GIF_LIBRARIES}) + list(APPEND WEBP_DEP_GIF_INCLUDE_DIRS ${GIF_INCLUDE_DIR}) + else() + unset(GIF_FOUND) + endif() endif() endif() # Check for specific headers. include(CheckIncludeFiles) -check_include_files("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS) -check_include_files(dlfcn.h HAVE_DLFCN_H) check_include_files(GLUT/glut.h HAVE_GLUT_GLUT_H) check_include_files(GL/glut.h HAVE_GL_GLUT_H) -check_include_files(inttypes.h HAVE_INTTYPES_H) -check_include_files(memory.h HAVE_MEMORY_H) check_include_files(OpenGL/glut.h HAVE_OPENGL_GLUT_H) check_include_files(shlwapi.h HAVE_SHLWAPI_H) -check_include_files(stdint.h HAVE_STDINT_H) -check_include_files(stdlib.h HAVE_STDLIB_H) -check_include_files(strings.h HAVE_STRINGS_H) -check_include_files(string.h HAVE_STRING_H) -check_include_files(sys/stat.h HAVE_SYS_STAT_H) -check_include_files(sys/types.h HAVE_SYS_TYPES_H) check_include_files(unistd.h HAVE_UNISTD_H) check_include_files(wincodec.h HAVE_WINCODEC_H) check_include_files(windows.h HAVE_WINDOWS_H) # Windows specifics if(HAVE_WINCODEC_H) - list(APPEND WEBP_DEP_LIBRARIES - shlwapi - ole32 - windowscodecs) + list(APPEND WEBP_DEP_LIBRARIES shlwapi ole32 windowscodecs) endif() # Check for SIMD extensions. @@ -158,17 +150,12 @@ set(PACKAGE_NAME ${PROJECT_NAME}) # Read from configure.ac. file(READ ${CMAKE_CURRENT_SOURCE_DIR}/configure.ac CONFIGURE_AC) -string(REGEX MATCHALL - "\\[([0-9a-z\\.:/]*)\\]" - CONFIGURE_AC_PACKAGE_INFO +string(REGEX MATCHALL "\\[([0-9a-z\\.:/]*)\\]" CONFIGURE_AC_PACKAGE_INFO ${CONFIGURE_AC}) function(strip_bracket VAR) string(LENGTH ${${VAR}} TMP_LEN) math(EXPR TMP_LEN ${TMP_LEN}-2) - string(SUBSTRING ${${VAR}} - 1 - ${TMP_LEN} - TMP_SUB) + string(SUBSTRING ${${VAR}} 1 ${TMP_LEN} TMP_SUB) set(${VAR} ${TMP_SUB} PARENT_SCOPE) endfunction() diff --git a/configure.ac b/configure.ac index dc6cd6c..2216e4a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([libwebp], [1.2.4], +AC_INIT([libwebp], [1.3.2], [https://bugs.chromium.org/p/webp],, [https://developers.google.com/speed/webp]) AC_CANONICAL_HOST @@ -749,11 +749,13 @@ fi dnl ========================= +dnl Add an empty webp_libname_prefix variable for use in *.pc.in. +AC_SUBST([webp_libname_prefix]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([src/webp/config.h]) AC_CONFIG_FILES([Makefile src/Makefile man/Makefile \ examples/Makefile extras/Makefile imageio/Makefile \ - sharpyuv/Makefile \ + sharpyuv/Makefile sharpyuv/libsharpyuv.pc \ src/dec/Makefile src/enc/Makefile src/dsp/Makefile \ src/demux/Makefile src/mux/Makefile \ src/utils/Makefile \ diff --git a/doc/api.md b/doc/api.md index d0adafb..c613ed3 100644 --- a/doc/api.md +++ b/doc/api.md @@ -233,7 +233,7 @@ WebPIDelete(idec); WebPFreeDecBuffer(&config.output); ``` -## Webp Mux +## WebP Mux WebPMux is a set of two libraries 'Mux' and 'Demux' for creation, extraction and manipulation of an extended format WebP file, which can have features like color diff --git a/doc/tools.md b/doc/tools.md index 853af81..bf49274 100644 --- a/doc/tools.md +++ b/doc/tools.md @@ -82,8 +82,8 @@ Options: green=0xe0 and blue=0xd0 -noalpha ............... discard any transparency information -lossless .............. encode image losslessly, default=off --near_lossless ... use near-lossless image - preprocessing (0..100=off), default=100 +-near_lossless ... use near-lossless image preprocessing + (0..100=off), default=100 -hint ......... specify image characteristics hint, one of: photo, picture or graph @@ -295,19 +295,23 @@ etc. Usage: ```shell -img2webp [file_options] [[frame_options] frame_file]... +img2webp [file_options] [[frame_options] frame_file]... [-o webp_file] ``` File-level options (only used at the start of compression): ``` -min_size ............ minimize size --loop .......... loop count (default: 0, = infinite loop) -kmax .......... maximum number of frame between key-frames (0=only keyframes) -kmin .......... minimum number of frame between key-frames (0=disable key-frames altogether) -mixed ............... use mixed lossy/lossless automatic mode +-near_lossless . use near-lossless image preprocessing + (0..100=off), default=100 +-sharp_yuv ........... use sharper (and slower) RGB->YUV conversion + (lossy only) +-loop .......... loop count (default: 0, = infinite loop) -v ................... verbose mode -h ................... this help -version ............. print version number and exit diff --git a/doc/webp-container-spec.txt b/doc/webp-container-spec.txt index e421dc6..3e66526 100644 --- a/doc/webp-container-spec.txt +++ b/doc/webp-container-spec.txt @@ -20,25 +20,25 @@ WebP Container Specification Introduction ------------ -WebP is an image format that uses either (i) the VP8 key frame encoding -to compress image data in a lossy way, or (ii) the WebP lossless encoding -(and possibly other encodings in the future). These encoding schemes should -make it more efficient than currently used formats. It is optimized for fast -image transfer over the network (e.g., for websites). The WebP format has -feature parity (color profile, metadata, animation etc) with other formats as -well. This document describes the structure of a WebP file. - -The WebP container (i.e., RIFF container for WebP) allows feature support over -and above the basic use case of WebP (i.e., a file containing a single image -encoded as a VP8 key frame). The WebP container provides additional support -for: +WebP is an image format that uses either (i) the VP8 key frame encoding to +compress image data in a lossy way, or (ii) the WebP lossless encoding. These +encoding schemes should make it more efficient than older formats such as JPEG, +GIF and PNG. It is optimized for fast image transfer over the network (for +example, for websites). The WebP format has feature parity (color profile, +metadata, animation, etc.) with other formats as well. This document describes +the structure of a WebP file. + +The WebP container (that is, the RIFF container for WebP) allows feature support +over and above the basic use case of WebP (that is, a file containing a single +image encoded as a VP8 key frame). The WebP container provides additional +support for: * **Lossless compression.** An image can be losslessly compressed, using the WebP Lossless Format. * **Metadata.** An image may have metadata stored in Exif or XMP formats. - * **Transparency.** An image may have transparency, i.e., an alpha channel. + * **Transparency.** An image may have transparency, that is, an alpha channel. * **Color Profile.** An image may have an embedded ICC profile as described by the [International Color Consortium][iccspec]. @@ -46,20 +46,21 @@ for: * **Animation.** An image may have multiple frames with pauses between them, making it an animation. -The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", -"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this -document are to be interpreted as described in [RFC 2119][]. +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", +"SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this +document are to be interpreted as described in BCP 14 [RFC 2119][] [RFC 8174][] +when, and only when, they appear in all capitals, as shown here. Bit numbering in chunk diagrams starts at `0` for the most significant bit ('MSB 0') as described in [RFC 1166][]. -Terminology & Basics ------------------------- +Terminology & Basics +-------------------- -A WebP file contains either a still image (i.e., an encoded matrix of pixels) +A WebP file contains either a still image (that is, an encoded matrix of pixels) or an [animation](#animation). Optionally, it can also contain transparency -information, color profile and metadata. In case we need to refer only to the -matrix of pixels, we will call it the _canvas_ of the image. +information, color profile and metadata. We refer to the matrix of pixels as the +_canvas_ of the image. Below are additional terms used throughout this document: @@ -83,12 +84,19 @@ _uint32_ _FourCC_ : A _FourCC_ (four-character code) is a _uint32_ created by concatenating four - ASCII characters in little-endian order. + ASCII characters in little-endian order. This means 'aaaa' (0x61616161) and + 'AAAA' (0x41414141) are treated as different _FourCCs_. _1-based_ -: An unsigned integer field storing values offset by `-1`. e.g., Such a field - would store value _25_ as _24_. +: An unsigned integer field storing values offset by `-1`, for example, such a + field would store value _25_ as _24_. + +_ChunkHeader('ABCD')_ + +: This is used to describe the _FourCC_ and _Chunk Size_ header of individual + chunks, where 'ABCD' is the FourCC for the chunk. This element's size is 8 + bytes. RIFF File Format @@ -106,7 +114,7 @@ The basic element of a RIFF file is a _chunk_. It consists of: +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Chunk Size | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Chunk Payload | + : Chunk Payload : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Chunk FourCC: 32 bits @@ -115,19 +123,13 @@ Chunk FourCC: 32 bits Chunk Size: 32 bits (_uint32_) -: The size of the chunk not including this field, the chunk identifier or - padding. +: The size of the chunk in bytes, not including this field, the chunk + identifier or padding. Chunk Payload: _Chunk Size_ bytes -: The data payload. If _Chunk Size_ is odd, a single padding byte -- that - SHOULD be `0` -- is added. - -_ChunkHeader('ABCD')_ - -: This is used to describe the _FourCC_ and _Chunk Size_ header of individual - chunks, where 'ABCD' is the FourCC for the chunk. This element's - size is 8 bytes. +: The data payload. If _Chunk Size_ is odd, a single padding byte -- that MUST + be `0` to conform with RIFF -- is added. **Note:** RIFF has a convention that all-uppercase chunk FourCCs are standard chunks that apply to any RIFF file format, while FourCCs specific to a file @@ -163,9 +165,11 @@ File Size: 32 bits (_uint32_) A WebP file MUST begin with a RIFF header with the FourCC 'WEBP'. The file size in the header is the total size of the chunks that follow plus `4` bytes for -the 'WEBP' FourCC. The file SHOULD NOT contain anything after it. As the size -of any chunk is even, the size given by the RIFF header is also even. The -contents of individual chunks will be described in the following sections. +the 'WEBP' FourCC. The file SHOULD NOT contain any data after the data +specified by _File Size_. Readers MAY parse such files, ignoring the trailing +data. As the size of any chunk is even, the size given by the RIFF header is +also even. The contents of individual chunks are described in the following +sections. Simple File Format (Lossy) @@ -180,9 +184,11 @@ Simple WebP (lossy) file format: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | | WebP file header (12 bytes) | + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | VP8 chunk | + : VP8 chunk : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ VP8 chunk: @@ -191,20 +197,24 @@ VP8 chunk: 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ChunkHeader('VP8 ') | + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | VP8 data | + : VP8 data : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ VP8 data: _Chunk Size_ bytes : VP8 bitstream data. +Note the fourth character in the 'VP8 ' FourCC is an ASCII space (0x20). + The VP8 bitstream format specification can be found at [VP8 Data Format and Decoding Guide][vp8spec]. Note that the VP8 frame header contains the VP8 frame width and height. That is assumed to be the width and height of the canvas. -The VP8 specification describes how to decode the image into Y'CbCr -format. To convert to RGB, Rec. 601 SHOULD be used. +The VP8 specification describes how to decode the image into Y'CbCr format. To +convert to RGB, Rec. 601 SHOULD be used. Applications MAY use another +conversion method, but visual results may differ among decoders. Simple File Format (Lossless) @@ -221,9 +231,11 @@ Simple WebP (lossless) file format: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | | WebP file header (12 bytes) | + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | VP8L chunk | + : VP8L chunk : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ VP8L chunk: @@ -232,8 +244,9 @@ VP8L chunk: 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ChunkHeader('VP8L') | + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | VP8L data | + : VP8L data : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ VP8L data: _Chunk Size_ bytes @@ -279,7 +292,7 @@ details about frames can be found in the [Animation](#animation) section. All chunks SHOULD be placed in the same order as listed above. If a chunk appears in the wrong place, the file is invalid, but readers MAY parse the -file, ignoring the chunks that come too late. +file, ignoring the chunks that are out of order. **Rationale:** Setting the order of chunks should allow quicker file parsing. For example, if an 'ALPH' chunk does not appear in its required @@ -293,9 +306,12 @@ Extended WebP file header: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | | WebP file header (12 bytes) | + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ChunkHeader('VP8X') | + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Rsv|I|L|E|X|A|R| Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ @@ -306,7 +322,7 @@ Extended WebP file header: Reserved (Rsv): 2 bits -: SHOULD be `0`. +: MUST be `0`. Readers MUST ignore this field. ICC profile (I): 1 bit @@ -332,11 +348,11 @@ Animation (A): 1 bit Reserved (R): 1 bit -: SHOULD be `0`. +: MUST be `0`. Readers MUST ignore this field. Reserved: 24 bits -: SHOULD be `0`. +: MUST be `0`. Readers MUST ignore this field. Canvas Width Minus One: 24 bits @@ -350,7 +366,7 @@ Canvas Height Minus One: 24 bits The product of _Canvas Width_ and _Canvas Height_ MUST be at most `2^32 - 1`. -Future specifications MAY add more fields. +Future specifications may add more fields. Unknown fields MUST be ignored. ### Chunks @@ -368,6 +384,7 @@ animation. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ChunkHeader('ANIM') | + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Background Color | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ @@ -383,8 +400,8 @@ Background Color: 32 bits (_uint32_) **Note**: - * Background color MAY contain a transparency value (alpha), even if the - _Alpha_ flag in [VP8X chunk](#extended_header) is unset. + * Background color MAY contain a non-opaque alpha value, even if the _Alpha_ + flag in [VP8X chunk](#extended_header) is unset. * Viewer applications SHOULD treat the background color value as a hint, and are not required to use it. @@ -397,8 +414,8 @@ Loop Count: 16 bits (_uint16_) : The number of times to loop the animation. `0` means infinitely. This chunk MUST appear if the _Animation_ flag in the VP8X chunk is set. -If the _Animation_ flag is not set and this chunk is present, it -SHOULD be ignored. +If the _Animation_ flag is not set and this chunk is present, it MUST be +ignored. ANMF chunk: @@ -409,6 +426,7 @@ If the _Animation flag_ is not set, then this chunk SHOULD NOT be present. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ChunkHeader('ANMF') | + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Frame X | ... +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ @@ -418,7 +436,7 @@ If the _Animation flag_ is not set, then this chunk SHOULD NOT be present. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Frame Duration | Reserved |B|D| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Frame Data | + : Frame Data : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Frame X: 24 bits (_uint24_) @@ -448,7 +466,7 @@ Frame Duration: 24 bits (_uint24_) Reserved: 6 bits -: SHOULD be 0. +: MUST be `0`. Readers MUST ignore this field. Blending method (B): 1 bit @@ -493,8 +511,9 @@ Disposal method (D): 1 bit if blend.A = 0 then blend.RGB = 0 else - blend.RGB = (src.RGB * src.A + - dst.RGB * dst.A * (1 - src.A / 255)) / blend.A + blend.RGB = + (src.RGB * src.A + + dst.RGB * dst.A * (1 - src.A / 255)) / blend.A ~~~~~ * Alpha-blending SHOULD be done in linear color space, by taking into account @@ -521,22 +540,23 @@ _padded_ chunks as described by the [RIFF file format](#riff-file-format). 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ChunkHeader('ALPH') | + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Rsv| P | F | C | Alpha Bitstream... | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Reserved (Rsv): 2 bits -: SHOULD be `0`. +: MUST be `0`. Readers MUST ignore this field. Pre-processing (P): 2 bits -: These INFORMATIVE bits are used to signal the pre-processing that has +: These _informative_ bits are used to signal the pre-processing that has been performed during compression. The decoder can use this information to - e.g. dither the values or smooth the gradients prior to display. + for example, dither the values or smooth the gradients prior to display. - * `0`: no pre-processing - * `1`: level reduction + * `0`: No pre-processing. + * `1`: Level reduction. Filtering method (F): 2 bits @@ -569,14 +589,14 @@ where `clip(v)` is equal to: * v otherwise The final value is derived by adding the decompressed value `X` to the -predictor and using modulo-256 arithmetic to wrap the \[256-511\] range -into the \[0-255\] one: +predictor and using modulo-256 arithmetic to wrap the \[256..511\] range +into the \[0..255\] one: `alpha = (predictor + X) % 256` -There are special cases for left-most and top-most pixel positions: +There are special cases for the left-most and top-most pixel positions: - * Top-left value at location (0,0) uses 0 as predictor value. Otherwise, + * The top-left value at location (0, 0) uses 0 as predictor value. Otherwise, * For horizontal or gradient filtering methods, the left-most pixels at location (0, y) are predicted using the location (0, y-1) just above. * For vertical or gradient filtering methods, the top-most pixels at @@ -638,14 +658,15 @@ The formats of VP8 and VP8L chunks are as described in sections [Simple File Format (Lossy)](#simple-file-format-lossy) and [Simple File Format (Lossless)](#simple-file-format-lossless) respectively. -#### Color profile +#### Color Profile 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ChunkHeader('ICCP') | + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Color Profile | + : Color Profile : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Color Profile: _Chunk Size_ bytes @@ -665,8 +686,7 @@ If this chunk is not present, sRGB SHOULD be assumed. Metadata can be stored in 'EXIF' or 'XMP ' chunks. There SHOULD be at most one chunk of each type ('EXIF' and 'XMP '). If there -are more such chunks, readers MAY ignore all except the first one. Also, a file -may possibly contain both 'EXIF' and 'XMP ' chunks. +are more such chunks, readers MAY ignore all except the first one. The chunks are defined as follows: @@ -676,13 +696,14 @@ EXIF chunk: 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ChunkHeader('EXIF') | + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Exif Metadata | + : Exif Metadata : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Exif Metadata: _Chunk Size_ bytes -: image metadata in Exif format. +: Image metadata in Exif format. XMP chunk: @@ -690,13 +711,16 @@ XMP chunk: 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ChunkHeader('XMP ') | + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | XMP Metadata | + : XMP Metadata : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ XMP Metadata: _Chunk Size_ bytes -: image metadata in XMP format. +: Image metadata in XMP format. + +Note the fourth character in the 'XMP ' FourCC is an ASCII space (0x20). Additional guidance about handling metadata can be found in the Metadata Working Group's [Guidelines for Handling Metadata][metadata]. @@ -720,49 +744,73 @@ A file MAY contain unknown chunks: Readers SHOULD ignore these chunks. Writers SHOULD preserve them in their original order (unless they specifically intend to modify these chunks). -### Assembling the Canvas from frames +### Assembling the Canvas From Frames + +Here we provide an overview of how a reader MUST assemble a canvas in the case +of an animated image. + +The process begins with creating a canvas using the dimensions given in the +'VP8X' chunk, `Canvas Width Minus One + 1` pixels wide by `Canvas Height Minus +One + 1` pixels high. The `Loop Count` field from the 'ANIM' chunk controls how +many times the animation process is repeated. This is `Loop Count - 1` for +non-zero `Loop Count` values or infinitely if `Loop Count` is zero. + +At the beginning of each loop iteration the canvas is filled using the +background color from the 'ANIM' chunk or an application defined color. + +'ANMF' chunks contain individual frames given in display order. Before rendering +each frame, the previous frame's `Disposal method` is applied. + +The rendering of the decoded frame begins at the Cartesian coordinates (`2 * +Frame X`, `2 * Frame Y`) using the top-left corner of the canvas as the origin. +`Frame Width Minus One + 1` pixels wide by `Frame Height Minus One + 1` pixels +high are rendered onto the canvas using the `Blending method`. -Here we provide an overview of how a reader should assemble a canvas in the -case of an animated image. The notation _VP8X.field_ means the field in the -'VP8X' chunk with the same description. +The canvas is displayed for `Frame Duration` milliseconds. This continues until +all frames given by 'ANMF' chunks have been displayed. A new loop iteration is +then begun or the canvas is left in its final state if all iterations have been +completed. -Displaying an _animated image_ canvas MUST be equivalent to the following -pseudocode: +The following pseudocode illustrates the rendering process. The notation +_VP8X.field_ means the field in the 'VP8X' chunk with the same description. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ assert VP8X.flags.hasAnimation canvas ← new image of size VP8X.canvasWidth x VP8X.canvasHeight with background color ANIM.background_color. loop_count ← ANIM.loopCount -dispose_method ← ANIM.disposeMethod +dispose_method ← Dispose to background color if loop_count == 0: - loop_count = ∞ + loop_count = ∞ frame_params ← nil assert next chunk in image_data is ANMF for loop = 0..loop_count - 1 - clear canvas to ANIM.background_color or application defined color - until eof or non-ANMF chunk - frame_params.frameX = Frame X - frame_params.frameY = Frame Y - frame_params.frameWidth = Frame Width Minus One + 1 - frame_params.frameHeight = Frame Height Minus One + 1 - frame_params.frameDuration = Frame Duration - frame_right = frame_params.frameX + frame_params.frameWidth - frame_bottom = frame_params.frameY + frame_params.frameHeight - assert VP8X.canvasWidth >= frame_right - assert VP8X.canvasHeight >= frame_bottom - for subchunk in 'Frame Data': - if subchunk.tag == "ALPH": - assert alpha subchunks not found in 'Frame Data' earlier - frame_params.alpha = alpha_data - else if subchunk.tag == "VP8 " OR subchunk.tag == "VP8L": - assert bitstream subchunks not found in 'Frame Data' earlier - frame_params.bitstream = bitstream_data - render frame with frame_params.alpha and frame_params.bitstream on - canvas with top-left corner at (frame_params.frameX, - frame_params.frameY), using dispose method dispose_method. - canvas contains the decoded image. - Show the contents of the canvas for frame_params.frameDuration * 1ms. + clear canvas to ANIM.background_color or application defined color + until eof or non-ANMF chunk + frame_params.frameX = Frame X + frame_params.frameY = Frame Y + frame_params.frameWidth = Frame Width Minus One + 1 + frame_params.frameHeight = Frame Height Minus One + 1 + frame_params.frameDuration = Frame Duration + frame_right = frame_params.frameX + frame_params.frameWidth + frame_bottom = frame_params.frameY + frame_params.frameHeight + assert VP8X.canvasWidth >= frame_right + assert VP8X.canvasHeight >= frame_bottom + for subchunk in 'Frame Data': + if subchunk.tag == "ALPH": + assert alpha subchunks not found in 'Frame Data' earlier + frame_params.alpha = alpha_data + else if subchunk.tag == "VP8 " OR subchunk.tag == "VP8L": + assert bitstream subchunks not found in 'Frame Data' earlier + frame_params.bitstream = bitstream_data + render frame with frame_params.alpha and frame_params.bitstream + on canvas with top-left corner at (frame_params.frameX, + frame_params.frameY), using blending method + frame_params.blendingMethod. + canvas contains the decoded image. + Show the contents of the canvas for + frame_params.frameDuration * 1ms. + dispose_method = frame_params.disposeMethod ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -817,3 +865,4 @@ RIFF/WEBP [metadata]: https://web.archive.org/web/20180919181934/http://www.metadataworkinggroup.org/pdf/mwg_guidance.pdf [rfc 1166]: https://datatracker.ietf.org/doc/html/rfc1166 [rfc 2119]: https://datatracker.ietf.org/doc/html/rfc2119 +[rfc 8174]: https://datatracker.ietf.org/doc/html/rfc8174 diff --git a/doc/webp-lossless-bitstream-spec.txt b/doc/webp-lossless-bitstream-spec.txt index d38481e..ebaf655 100644 --- a/doc/webp-lossless-bitstream-spec.txt +++ b/doc/webp-lossless-bitstream-spec.txt @@ -1,8 +1,8 @@