From 95d8170802b7fdcea885776b24ef40bc0f112b49 Mon Sep 17 00:00:00 2001 From: Vertexwahn Date: Fri, 3 Jan 2025 16:25:00 +0100 Subject: [PATCH] libwebp@1.5.0 (#3517) --- modules/libwebp/1.5.0/MODULE.bazel | 9 + modules/libwebp/1.5.0/overlay/BUILD.bazel | 249 +++++++++++++++++++++ modules/libwebp/1.5.0/overlay/MODULE.bazel | 1 + modules/libwebp/1.5.0/presubmit.yml | 18 ++ modules/libwebp/1.5.0/source.json | 9 + modules/libwebp/metadata.json | 3 +- 6 files changed, 288 insertions(+), 1 deletion(-) create mode 100644 modules/libwebp/1.5.0/MODULE.bazel create mode 100644 modules/libwebp/1.5.0/overlay/BUILD.bazel create mode 120000 modules/libwebp/1.5.0/overlay/MODULE.bazel create mode 100644 modules/libwebp/1.5.0/presubmit.yml create mode 100644 modules/libwebp/1.5.0/source.json diff --git a/modules/libwebp/1.5.0/MODULE.bazel b/modules/libwebp/1.5.0/MODULE.bazel new file mode 100644 index 00000000000..9447a15899d --- /dev/null +++ b/modules/libwebp/1.5.0/MODULE.bazel @@ -0,0 +1,9 @@ +module( + name = "libwebp", + version = "1.5.0", + bazel_compatibility = [">=7.2.1"], # need support for "overlay" directory + compatibility_level = 1, +) + +bazel_dep(name = "platforms", version = "0.0.10") +bazel_dep(name = "rules_cc", version = "0.0.17") diff --git a/modules/libwebp/1.5.0/overlay/BUILD.bazel b/modules/libwebp/1.5.0/overlay/BUILD.bazel new file mode 100644 index 00000000000..5c2170352b1 --- /dev/null +++ b/modules/libwebp/1.5.0/overlay/BUILD.bazel @@ -0,0 +1,249 @@ +# Copied from https://skia.googlesource.com/skia/+/refs/heads/main/bazel/external/libwebp/BUILD.bazel +# The copied code is available under the following BSD-style license (see +# https://skia.googlesource.com/skia/+/refs/heads/main/LICENSE): +# +# Copyright (c) 2011 Google Inc. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# This file will be copied into //third_party/externals/libwebp via the new_local_repository +# rule in WORKSPACE.bazel, so all files should be relative to that path. +# We define this here because the emscripten toolchain calls the cpu wasm, whereas the +# bazelbuild/platforms call it wasm32. https://github.com/emscripten-core/emsdk/issues/919 + +load("@rules_cc//cc:cc_library.bzl", "cc_library") + +config_setting( + name = "cpu_wasm", + values = { + "cpu": "wasm", + }, +) + +WEBP_SRCS = [ + "sharpyuv/sharpyuv.c", + "sharpyuv/sharpyuv.h", + "sharpyuv/sharpyuv_cpu.c", + "sharpyuv/sharpyuv_cpu.h", + "sharpyuv/sharpyuv_csp.c", + "sharpyuv/sharpyuv_csp.h", + "sharpyuv/sharpyuv_dsp.c", + "sharpyuv/sharpyuv_dsp.h", + "sharpyuv/sharpyuv_gamma.c", + "sharpyuv/sharpyuv_gamma.h", + "sharpyuv/sharpyuv_neon.c", + "sharpyuv/sharpyuv_sse2.c", + "src/dec/alpha_dec.c", + "src/dec/alphai_dec.h", + "src/dec/buffer_dec.c", + "src/dec/common_dec.h", + "src/dec/frame_dec.c", + "src/dec/idec_dec.c", + "src/dec/io_dec.c", + "src/dec/quant_dec.c", + "src/dec/tree_dec.c", + "src/dec/vp8_dec.c", + "src/dec/vp8_dec.h", + "src/dec/vp8i_dec.h", + "src/dec/vp8l_dec.c", + "src/dec/vp8li_dec.h", + "src/dec/webp_dec.c", + "src/dec/webpi_dec.h", + "src/demux/anim_decode.c", + "src/demux/demux.c", + "src/dsp/alpha_processing.c", + "src/dsp/alpha_processing_mips_dsp_r2.c", + "src/dsp/alpha_processing_neon.c", + "src/dsp/alpha_processing_sse2.c", + "src/dsp/common_sse2.h", + "src/dsp/common_sse41.h", + "src/dsp/cost.c", + "src/dsp/cost_mips32.c", + "src/dsp/cost_mips_dsp_r2.c", + "src/dsp/cost_neon.c", + "src/dsp/cost_sse2.c", + "src/dsp/cpu.c", + "src/dsp/cpu.h", + "src/dsp/dec.c", + "src/dsp/dec_clip_tables.c", + "src/dsp/dec_mips32.c", + "src/dsp/dec_mips_dsp_r2.c", + "src/dsp/dec_msa.c", + "src/dsp/dec_neon.c", + "src/dsp/dec_sse2.c", + "src/dsp/dsp.h", + "src/dsp/enc.c", + "src/dsp/enc_mips32.c", + "src/dsp/enc_mips_dsp_r2.c", + "src/dsp/enc_msa.c", + "src/dsp/enc_neon.c", + "src/dsp/enc_sse2.c", + "src/dsp/filters.c", + "src/dsp/filters_mips_dsp_r2.c", + "src/dsp/filters_msa.c", + "src/dsp/filters_neon.c", + "src/dsp/filters_sse2.c", + "src/dsp/lossless.c", + "src/dsp/lossless.h", + "src/dsp/lossless_common.h", + "src/dsp/lossless_enc.c", + "src/dsp/lossless_enc_mips32.c", + "src/dsp/lossless_enc_mips_dsp_r2.c", + "src/dsp/lossless_enc_msa.c", + "src/dsp/lossless_enc_neon.c", + "src/dsp/lossless_enc_sse2.c", + "src/dsp/lossless_mips_dsp_r2.c", + "src/dsp/lossless_msa.c", + "src/dsp/lossless_neon.c", + "src/dsp/lossless_sse2.c", + "src/dsp/mips_macro.h", + "src/dsp/msa_macro.h", + "src/dsp/neon.h", + "src/dsp/quant.h", + "src/dsp/rescaler.c", + "src/dsp/rescaler_mips32.c", + "src/dsp/rescaler_mips_dsp_r2.c", + "src/dsp/rescaler_msa.c", + "src/dsp/rescaler_neon.c", + "src/dsp/rescaler_sse2.c", + "src/dsp/ssim.c", + "src/dsp/ssim_sse2.c", + "src/dsp/upsampling.c", + "src/dsp/upsampling_mips_dsp_r2.c", + "src/dsp/upsampling_msa.c", + "src/dsp/upsampling_neon.c", + "src/dsp/upsampling_sse2.c", + "src/dsp/yuv.c", + "src/dsp/yuv.h", + "src/dsp/yuv_mips32.c", + "src/dsp/yuv_mips_dsp_r2.c", + "src/dsp/yuv_neon.c", + "src/dsp/yuv_sse2.c", + "src/enc/alpha_enc.c", + "src/enc/analysis_enc.c", + "src/enc/backward_references_cost_enc.c", + "src/enc/backward_references_enc.c", + "src/enc/backward_references_enc.h", + "src/enc/config_enc.c", + "src/enc/cost_enc.c", + "src/enc/cost_enc.h", + "src/enc/filter_enc.c", + "src/enc/frame_enc.c", + "src/enc/histogram_enc.c", + "src/enc/histogram_enc.h", + "src/enc/iterator_enc.c", + "src/enc/near_lossless_enc.c", + "src/enc/picture_csp_enc.c", + "src/enc/picture_enc.c", + "src/enc/picture_psnr_enc.c", + "src/enc/picture_rescale_enc.c", + "src/enc/picture_tools_enc.c", + "src/enc/predictor_enc.c", + "src/enc/quant_enc.c", + "src/enc/syntax_enc.c", + "src/enc/token_enc.c", + "src/enc/tree_enc.c", + "src/enc/vp8i_enc.h", + "src/enc/vp8l_enc.c", + "src/enc/vp8li_enc.h", + "src/enc/webp_enc.c", + "src/mux/anim_encode.c", + "src/mux/animi.h", + "src/mux/muxedit.c", + "src/mux/muxi.h", + "src/mux/muxinternal.c", + "src/mux/muxread.c", + "src/utils/bit_reader_inl_utils.h", + "src/utils/bit_reader_utils.c", + "src/utils/bit_reader_utils.h", + "src/utils/bit_writer_utils.c", + "src/utils/bit_writer_utils.h", + "src/utils/color_cache_utils.c", + "src/utils/color_cache_utils.h", + "src/utils/endian_inl_utils.h", + "src/utils/filters_utils.c", + "src/utils/filters_utils.h", + "src/utils/huffman_encode_utils.c", + "src/utils/huffman_encode_utils.h", + "src/utils/huffman_utils.c", + "src/utils/huffman_utils.h", + "src/utils/palette.c", + "src/utils/palette.h", + "src/utils/quant_levels_dec_utils.c", + "src/utils/quant_levels_dec_utils.h", + "src/utils/quant_levels_utils.c", + "src/utils/quant_levels_utils.h", + "src/utils/random_utils.c", + "src/utils/random_utils.h", + "src/utils/rescaler_utils.c", + "src/utils/rescaler_utils.h", + "src/utils/thread_utils.c", + "src/utils/thread_utils.h", + "src/utils/utils.c", + "src/utils/utils.h", +] + select({ + "@platforms//cpu:x86_64": [ + "src/dsp/alpha_processing_sse41.c", + "src/dsp/dec_sse41.c", + "src/dsp/enc_sse41.c", + "src/dsp/lossless_enc_sse41.c", + "src/dsp/lossless_sse41.c", + "src/dsp/upsampling_sse41.c", + "src/dsp/yuv_sse41.c", + ], + ":cpu_wasm": [], # not sure why wasm doesn't use default + "//conditions:default": [], +}) + +WEBP_COPTS = select({ + "@platforms//os:windows": [], + "//conditions:default": ["-Wno-unused-but-set-variable"], +}) + select({ + "@platforms//cpu:x86_64": ["-msse4.1"], + ":cpu_wasm": [], # not sure why wasm doesn't use default + "//conditions:default": [], +}) + +WEBP_DEFINES = [ + # TODO(scroggo): swizzle ourself in SkWebpCodec instead of requiring this non-standard libwebp. + "WEBP_SWAP_16BIT_CSP", +] + +cc_library( + name = "libwebp", + srcs = WEBP_SRCS, + hdrs = [ + "src/webp/decode.h", + "src/webp/demux.h", + "src/webp/encode.h", + "src/webp/format_constants.h", + "src/webp/mux.h", + "src/webp/mux_types.h", + "src/webp/types.h", + ], + copts = WEBP_COPTS, + includes = ["src"], + local_defines = WEBP_DEFINES, + textual_hdrs = ["src/dsp/cpu.c"], + visibility = ["//visibility:public"], +) diff --git a/modules/libwebp/1.5.0/overlay/MODULE.bazel b/modules/libwebp/1.5.0/overlay/MODULE.bazel new file mode 120000 index 00000000000..9b599e3ad9c --- /dev/null +++ b/modules/libwebp/1.5.0/overlay/MODULE.bazel @@ -0,0 +1 @@ +../MODULE.bazel \ No newline at end of file diff --git a/modules/libwebp/1.5.0/presubmit.yml b/modules/libwebp/1.5.0/presubmit.yml new file mode 100644 index 00000000000..127575623ba --- /dev/null +++ b/modules/libwebp/1.5.0/presubmit.yml @@ -0,0 +1,18 @@ +matrix: + platform: + - debian10 + - debian11 + - macos + - macos_arm64 + - ubuntu2004 + - ubuntu2204 + - ubuntu2404 + - windows + bazel: [7.x, 8.x, rolling] +tasks: + verify_targets: + name: Verify build targets + platform: ${{ platform }} + bazel: ${{ bazel }} + build_targets: + - '@libwebp//:libwebp' diff --git a/modules/libwebp/1.5.0/source.json b/modules/libwebp/1.5.0/source.json new file mode 100644 index 00000000000..b2edee42f25 --- /dev/null +++ b/modules/libwebp/1.5.0/source.json @@ -0,0 +1,9 @@ +{ + "url": "https://github.com/webmproject/libwebp/archive/refs/tags/v1.5.0.tar.gz", + "integrity": "sha256-ZoyaukVWXiTCfhf3qvcGCjmffzHbpsl6BE4f6suTDzc=", + "strip_prefix": "libwebp-1.5.0", + "overlay": { + "BUILD.bazel": "sha256-SuMAYa0uJxIjWTrQHSs/IH0J8skQNEX01uBlRdKPov8=", + "MODULE.bazel": "sha256-hDSISLhO954DHL177asQQ6SkmJfyblEf14eEVZ16/A4=" + } +} diff --git a/modules/libwebp/metadata.json b/modules/libwebp/metadata.json index e1fdd655659..94ada1ecc9a 100644 --- a/modules/libwebp/metadata.json +++ b/modules/libwebp/metadata.json @@ -12,7 +12,8 @@ ], "versions": [ "1.3.2", - "1.4.0" + "1.4.0", + "1.5.0" ], "yanked_versions": {} }