Skip to content

Commit ea5548f

Browse files
committed
Merge pull request godotengine#101348 from akien-mga/libwebp-1.5.0
libwebp: Update to 1.5.0
2 parents ffdffe0 + 01f88ff commit ea5548f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+3136
-2148
lines changed

thirdparty/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ Files extracted from upstream source:
581581
## libwebp
582582

583583
- Upstream: https://chromium.googlesource.com/webm/libwebp/
584-
- Version: 1.4.0 (845d5476a866141ba35ac133f856fa62f0b7445f, 2024)
584+
- Version: 1.5.0 (a4d7a715337ded4451fec90ff8ce79728e04126c, 2024)
585585
- License: BSD-3-Clause
586586

587587
Files extracted from upstream source:

thirdparty/libwebp/AUTHORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ Contributors:
1111
- Christopher Degawa (ccom at randomderp dot com)
1212
- Clement Courbet (courbet at google dot com)
1313
- Djordje Pesut (djordje dot pesut at imgtec dot com)
14+
- Frank (1433351828 at qq dot com)
1415
- Frank Barchard (fbarchard at google dot com)
1516
- Hui Su (huisu at google dot com)
1617
- H. Vetinari (h dot vetinari at gmx dot com)
1718
- Ilya Kurdyukov (jpegqs at gmail dot com)
1819
- Ingvar Stepanyan (rreverser at google dot com)
20+
- Istvan Stefan (Istvan dot Stefan at arm dot com)
1921
- James Zern (jzern at google dot com)
2022
- Jan Engelhardt (jengelh at medozas dot de)
2123
- Jehan (jehan at girinstud dot io)
@@ -62,6 +64,7 @@ Contributors:
6264
- Vincent Rabaud (vrabaud at google dot com)
6365
- Vlad Tsyrklevich (vtsyrklevich at chromium dot org)
6466
- Wan-Teh Chang (wtc at google dot com)
67+
- wrv (wrv at utexas dot edu)
6568
- Yang Zhang (yang dot zhang at arm dot com)
6669
- Yannis Guyon (yguyon at google dot com)
6770
- Zhi An Ng (zhin at chromium dot org)

thirdparty/libwebp/sharpyuv/sharpyuv.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,10 +565,11 @@ int SharpYuvConvertWithOptions(const void* r_ptr, const void* g_ptr,
565565
scaled_matrix.rgb_to_u[3] = Shift(yuv_matrix->rgb_to_u[3], sfix);
566566
scaled_matrix.rgb_to_v[3] = Shift(yuv_matrix->rgb_to_v[3], sfix);
567567

568-
return DoSharpArgbToYuv(r_ptr, g_ptr, b_ptr, rgb_step, rgb_stride,
569-
rgb_bit_depth, y_ptr, y_stride, u_ptr, u_stride,
570-
v_ptr, v_stride, yuv_bit_depth, width, height,
571-
&scaled_matrix, transfer_type);
568+
return DoSharpArgbToYuv(
569+
(const uint8_t*)r_ptr, (const uint8_t*)g_ptr, (const uint8_t*)b_ptr,
570+
rgb_step, rgb_stride, rgb_bit_depth, (uint8_t*)y_ptr, y_stride,
571+
(uint8_t*)u_ptr, u_stride, (uint8_t*)v_ptr, v_stride, yuv_bit_depth,
572+
width, height, &scaled_matrix, transfer_type);
572573
}
573574

574575
//------------------------------------------------------------------------------

thirdparty/libwebp/sharpyuv/sharpyuv.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extern "C" {
5252
// SharpYUV API version following the convention from semver.org
5353
#define SHARPYUV_VERSION_MAJOR 0
5454
#define SHARPYUV_VERSION_MINOR 4
55-
#define SHARPYUV_VERSION_PATCH 0
55+
#define SHARPYUV_VERSION_PATCH 1
5656
// Version as a uint32_t. The major number is the high 8 bits.
5757
// The minor number is the middle 8 bits. The patch number is the low 16 bits.
5858
#define SHARPYUV_MAKE_VERSION(MAJOR, MINOR, PATCH) \
@@ -66,10 +66,17 @@ extern "C" {
6666
SHARPYUV_EXTERN int SharpYuvGetVersion(void);
6767

6868
// RGB to YUV conversion matrix, in 16 bit fixed point.
69-
// y = rgb_to_y[0] * r + rgb_to_y[1] * g + rgb_to_y[2] * b + rgb_to_y[3]
70-
// u = rgb_to_u[0] * r + rgb_to_u[1] * g + rgb_to_u[2] * b + rgb_to_u[3]
71-
// v = rgb_to_v[0] * r + rgb_to_v[1] * g + rgb_to_v[2] * b + rgb_to_v[3]
72-
// Then y, u and v values are divided by 1<<16 and rounded.
69+
// y_ = rgb_to_y[0] * r + rgb_to_y[1] * g + rgb_to_y[2] * b + rgb_to_y[3]
70+
// u_ = rgb_to_u[0] * r + rgb_to_u[1] * g + rgb_to_u[2] * b + rgb_to_u[3]
71+
// v_ = rgb_to_v[0] * r + rgb_to_v[1] * g + rgb_to_v[2] * b + rgb_to_v[3]
72+
// Then the values are divided by 1<<16 and rounded.
73+
// y = (y_ + (1 << 15)) >> 16
74+
// u = (u_ + (1 << 15)) >> 16
75+
// v = (v_ + (1 << 15)) >> 16
76+
//
77+
// Typically, the offset values rgb_to_y[3], rgb_to_u[3] and rgb_to_v[3] depend
78+
// on the input's bit depth, e.g., rgb_to_u[3] = 1 << (rgb_bit_depth - 1 + 16).
79+
// See also sharpyuv_csp.h to get a predefined matrix or generate a matrix.
7380
typedef struct {
7481
int rgb_to_y[4];
7582
int rgb_to_u[4];
@@ -127,6 +134,8 @@ typedef enum SharpYuvTransferFunctionType {
127134
// adjacent pixels on the y, u and v channels. If yuv_bit_depth > 8, they
128135
// should be multiples of 2.
129136
// width, height: width and height of the image in pixels
137+
// yuv_matrix: RGB to YUV conversion matrix. The matrix values typically
138+
// depend on the input's rgb_bit_depth.
130139
// This function calls SharpYuvConvertWithOptions with a default transfer
131140
// function of kSharpYuvTransferFunctionSrgb.
132141
SHARPYUV_EXTERN int SharpYuvConvert(const void* r_ptr, const void* g_ptr,

thirdparty/libwebp/sharpyuv/sharpyuv_csp.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ void SharpYuvComputeConversionMatrix(const SharpYuvColorSpace* yuv_color_space,
2222
const float kr = yuv_color_space->kr;
2323
const float kb = yuv_color_space->kb;
2424
const float kg = 1.0f - kr - kb;
25-
const float cr = 0.5f / (1.0f - kb);
26-
const float cb = 0.5f / (1.0f - kr);
25+
const float cb = 0.5f / (1.0f - kb);
26+
const float cr = 0.5f / (1.0f - kr);
2727

2828
const int shift = yuv_color_space->bit_depth - 8;
2929

3030
const float denom = (float)((1 << yuv_color_space->bit_depth) - 1);
3131
float scale_y = 1.0f;
3232
float add_y = 0.0f;
33-
float scale_u = cr;
34-
float scale_v = cb;
33+
float scale_u = cb;
34+
float scale_v = cr;
3535
float add_uv = (float)(128 << shift);
3636
assert(yuv_color_space->bit_depth >= 8);
3737

@@ -59,31 +59,35 @@ void SharpYuvComputeConversionMatrix(const SharpYuvColorSpace* yuv_color_space,
5959
}
6060

6161
// Matrices are in YUV_FIX fixed point precision.
62-
// WebP's matrix, similar but not identical to kRec601LimitedMatrix.
62+
// WebP's matrix, similar but not identical to kRec601LimitedMatrix
63+
// Derived using the following formulas:
64+
// Y = 0.2569 * R + 0.5044 * G + 0.0979 * B + 16
65+
// U = -0.1483 * R - 0.2911 * G + 0.4394 * B + 128
66+
// V = 0.4394 * R - 0.3679 * G - 0.0715 * B + 128
6367
static const SharpYuvConversionMatrix kWebpMatrix = {
6468
{16839, 33059, 6420, 16 << 16},
6569
{-9719, -19081, 28800, 128 << 16},
6670
{28800, -24116, -4684, 128 << 16},
6771
};
68-
// Kr=0.2990f Kb=0.1140f bits=8 range=kSharpYuvRangeLimited
72+
// Kr=0.2990f Kb=0.1140f bit_depth=8 range=kSharpYuvRangeLimited
6973
static const SharpYuvConversionMatrix kRec601LimitedMatrix = {
7074
{16829, 33039, 6416, 16 << 16},
7175
{-9714, -19071, 28784, 128 << 16},
7276
{28784, -24103, -4681, 128 << 16},
7377
};
74-
// Kr=0.2990f Kb=0.1140f bits=8 range=kSharpYuvRangeFull
78+
// Kr=0.2990f Kb=0.1140f bit_depth=8 range=kSharpYuvRangeFull
7579
static const SharpYuvConversionMatrix kRec601FullMatrix = {
7680
{19595, 38470, 7471, 0},
7781
{-11058, -21710, 32768, 128 << 16},
7882
{32768, -27439, -5329, 128 << 16},
7983
};
80-
// Kr=0.2126f Kb=0.0722f bits=8 range=kSharpYuvRangeLimited
84+
// Kr=0.2126f Kb=0.0722f bit_depth=8 range=kSharpYuvRangeLimited
8185
static const SharpYuvConversionMatrix kRec709LimitedMatrix = {
8286
{11966, 40254, 4064, 16 << 16},
8387
{-6596, -22189, 28784, 128 << 16},
8488
{28784, -26145, -2639, 128 << 16},
8589
};
86-
// Kr=0.2126f Kb=0.0722f bits=8 range=kSharpYuvRangeFull
90+
// Kr=0.2126f Kb=0.0722f bit_depth=8 range=kSharpYuvRangeFull
8791
static const SharpYuvConversionMatrix kRec709FullMatrix = {
8892
{13933, 46871, 4732, 0},
8993
{-7509, -25259, 32768, 128 << 16},

thirdparty/libwebp/sharpyuv/sharpyuv_csp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,15 @@ SHARPYUV_EXTERN void SharpYuvComputeConversionMatrix(
4141

4242
// Enums for precomputed conversion matrices.
4343
typedef enum {
44+
// WebP's matrix, similar but not identical to kSharpYuvMatrixRec601Limited
4445
kSharpYuvMatrixWebp = 0,
46+
// Kr=0.2990f Kb=0.1140f bit_depth=8 range=kSharpYuvRangeLimited
4547
kSharpYuvMatrixRec601Limited,
48+
// Kr=0.2990f Kb=0.1140f bit_depth=8 range=kSharpYuvRangeFull
4649
kSharpYuvMatrixRec601Full,
50+
// Kr=0.2126f Kb=0.0722f bit_depth=8 range=kSharpYuvRangeLimited
4751
kSharpYuvMatrixRec709Limited,
52+
// Kr=0.2126f Kb=0.0722f bit_depth=8 range=kSharpYuvRangeFull
4853
kSharpYuvMatrixRec709Full,
4954
kSharpYuvMatrixNum
5055
} SharpYuvMatrixType;

thirdparty/libwebp/src/dec/tree_dec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
#include "src/utils/bit_reader_inl_utils.h"
1717

1818
#if !defined(USE_GENERIC_TREE)
19-
#if !defined(__arm__) && !defined(_M_ARM) && !WEBP_AARCH64
19+
#if !defined(__arm__) && !defined(_M_ARM) && !WEBP_AARCH64 && \
20+
!defined(__wasm__)
2021
// using a table is ~1-2% slower on ARM. Prefer the coded-tree approach then.
2122
#define USE_GENERIC_TREE 1 // ALTERNATE_CODE
2223
#else

thirdparty/libwebp/src/dec/vp8i_dec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extern "C" {
3232

3333
// version numbers
3434
#define DEC_MAJ_VERSION 1
35-
#define DEC_MIN_VERSION 4
35+
#define DEC_MIN_VERSION 5
3636
#define DEC_REV_VERSION 0
3737

3838
// YUV-cache parameters. Cache is 32-bytes wide (= one cacheline).

thirdparty/libwebp/src/dec/vp8l_dec.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
#include "src/dsp/dsp.h"
2121
#include "src/dsp/lossless.h"
2222
#include "src/dsp/lossless_common.h"
23-
#include "src/dsp/yuv.h"
24-
#include "src/utils/endian_inl_utils.h"
2523
#include "src/utils/huffman_utils.h"
2624
#include "src/utils/utils.h"
25+
#include "src/webp/format_constants.h"
2726

2827
#define NUM_ARGB_CACHE_ROWS 16
2928

@@ -381,7 +380,8 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize,
381380

382381
if (allow_recursion && VP8LReadBits(br, 1)) {
383382
// use meta Huffman codes.
384-
const int huffman_precision = VP8LReadBits(br, 3) + 2;
383+
const int huffman_precision =
384+
MIN_HUFFMAN_BITS + VP8LReadBits(br, NUM_HUFFMAN_BITS);
385385
const int huffman_xsize = VP8LSubSampleSize(xsize, huffman_precision);
386386
const int huffman_ysize = VP8LSubSampleSize(ysize, huffman_precision);
387387
const int huffman_pixs = huffman_xsize * huffman_ysize;
@@ -1351,7 +1351,8 @@ static int ReadTransform(int* const xsize, int const* ysize,
13511351
switch (type) {
13521352
case PREDICTOR_TRANSFORM:
13531353
case CROSS_COLOR_TRANSFORM:
1354-
transform->bits_ = VP8LReadBits(br, 3) + 2;
1354+
transform->bits_ =
1355+
MIN_TRANSFORM_BITS + VP8LReadBits(br, NUM_TRANSFORM_BITS);
13551356
ok = DecodeImageStream(VP8LSubSampleSize(transform->xsize_,
13561357
transform->bits_),
13571358
VP8LSubSampleSize(transform->ysize_,
@@ -1416,7 +1417,9 @@ VP8LDecoder* VP8LNew(void) {
14161417
return dec;
14171418
}
14181419

1419-
void VP8LClear(VP8LDecoder* const dec) {
1420+
// Resets the decoder in its initial state, reclaiming memory.
1421+
// Preserves the dec->status_ value.
1422+
static void VP8LClear(VP8LDecoder* const dec) {
14201423
int i;
14211424
if (dec == NULL) return;
14221425
ClearMetadata(&dec->hdr_);

thirdparty/libwebp/src/dec/vp8li_dec.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ WEBP_NODISCARD int VP8LDecodeHeader(VP8LDecoder* const dec, VP8Io* const io);
121121
// this function. Returns false in case of error, with updated dec->status_.
122122
WEBP_NODISCARD int VP8LDecodeImage(VP8LDecoder* const dec);
123123

124-
// Resets the decoder in its initial state, reclaiming memory.
125-
// Preserves the dec->status_ value.
126-
void VP8LClear(VP8LDecoder* const dec);
127-
128124
// Clears and deallocate a lossless decoder instance.
129125
void VP8LDelete(VP8LDecoder* const dec);
130126

0 commit comments

Comments
 (0)