Skip to content

Commit 339dcd8

Browse files
committed
libwebp: Sync with upstream 1.2.2
Changes: https://chromium.googlesource.com/webm/libwebp/+/1.2.2/NEWS
1 parent bf12719 commit 339dcd8

28 files changed

+225
-139
lines changed

Diff for: thirdparty/README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -309,18 +309,14 @@ Files extracted from upstream source:
309309
## libwebp
310310

311311
- Upstream: https://chromium.googlesource.com/webm/libwebp/
312-
- Version: 1.2.1 (9ce5843dbabcfd3f7c39ec7ceba9cbeb213cbfdf, 2021)
312+
- Version: 1.2.2 (b0a860891dcd4c0c2d7c6149e5cccb6eb881cc21, 2022)
313313
- License: BSD-3-Clause
314314

315315
Files extracted from upstream source:
316316

317317
- `src/*` except from: `.am`, `.rc` and `.in` files
318318
- `AUTHORS`, `COPYING`, `PATENTS`
319319

320-
Important: The files `utils/bit_reader_utils.{c,h}` have Godot-made
321-
changes to ensure they build for Javascript/HTML5. Those
322-
changes are marked with `// -- GODOT --` comments.
323-
324320

325321
## mbedtls
326322

Diff for: thirdparty/libwebp/AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Contributors:
3232
- Pascal Massimino (pascal dot massimino at gmail dot com)
3333
- Paweł Hajdan, Jr (phajdan dot jr at chromium dot org)
3434
- Pierre Joye (pierre dot php at gmail dot com)
35+
- Roberto Alanis (alanisbaez at google dot com)
3536
- Sam Clegg (sbc at chromium dot org)
3637
- Scott Hancher (seh at google dot com)
3738
- Scott LaVarnway (slavarnway at google dot com)

Diff for: thirdparty/libwebp/src/dec/vp8_dec.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ static const uint8_t kZigzag[16] = {
403403
0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
404404
};
405405

406-
// See section 13-2: http://tools.ietf.org/html/rfc6386#section-13.2
406+
// See section 13-2: https://datatracker.ietf.org/doc/html/rfc6386#section-13.2
407407
static int GetLargeValue(VP8BitReader* const br, const uint8_t* const p) {
408408
int v;
409409
if (!VP8GetBit(br, p[3], "coeffs")) {

Diff for: thirdparty/libwebp/src/dec/vp8i_dec.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extern "C" {
3232
// version numbers
3333
#define DEC_MAJ_VERSION 1
3434
#define DEC_MIN_VERSION 2
35-
#define DEC_REV_VERSION 1
35+
#define DEC_REV_VERSION 2
3636

3737
// YUV-cache parameters. Cache is 32-bytes wide (= one cacheline).
3838
// Constraints are: We need to store one 16x16 block of luma samples (y),

Diff for: thirdparty/libwebp/src/dec/vp8l_dec.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static const uint8_t kCodeToPlane[CODE_TO_PLANE_CODES] = {
8484
// to 256 (green component values) + 24 (length prefix values)
8585
// + color_cache_size (between 0 and 2048).
8686
// All values computed for 8-bit first level lookup with Mark Adler's tool:
87-
// http://www.hdfgroup.org/ftp/lib-external/zlib/zlib-1.2.5/examples/enough.c
87+
// https://github.com/madler/zlib/blob/v1.2.5/examples/enough.c
8888
#define FIXED_TABLE_SIZE (630 * 3 + 410)
8989
static const uint16_t kTableSize[12] = {
9090
FIXED_TABLE_SIZE + 654,

Diff for: thirdparty/libwebp/src/demux/anim_decode.c

+24-16
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323

2424
#define NUM_CHANNELS 4
2525

26+
// Channel extraction from a uint32_t representation of a uint8_t RGBA/BGRA
27+
// buffer.
28+
#ifdef WORDS_BIGENDIAN
29+
#define CHANNEL_SHIFT(i) (24 - (i) * 8)
30+
#else
31+
#define CHANNEL_SHIFT(i) ((i) * 8)
32+
#endif
33+
2634
typedef void (*BlendRowFunc)(uint32_t* const, const uint32_t* const, int);
2735
static void BlendPixelRowNonPremult(uint32_t* const src,
2836
const uint32_t* const dst, int num_pixels);
@@ -209,35 +217,35 @@ static uint8_t BlendChannelNonPremult(uint32_t src, uint8_t src_a,
209217
const uint8_t dst_channel = (dst >> shift) & 0xff;
210218
const uint32_t blend_unscaled = src_channel * src_a + dst_channel * dst_a;
211219
assert(blend_unscaled < (1ULL << 32) / scale);
212-
return (blend_unscaled * scale) >> 24;
220+
return (blend_unscaled * scale) >> CHANNEL_SHIFT(3);
213221
}
214222

215223
// Blend 'src' over 'dst' assuming they are NOT pre-multiplied by alpha.
216224
static uint32_t BlendPixelNonPremult(uint32_t src, uint32_t dst) {
217-
const uint8_t src_a = (src >> 24) & 0xff;
225+
const uint8_t src_a = (src >> CHANNEL_SHIFT(3)) & 0xff;
218226

219227
if (src_a == 0) {
220228
return dst;
221229
} else {
222-
const uint8_t dst_a = (dst >> 24) & 0xff;
230+
const uint8_t dst_a = (dst >> CHANNEL_SHIFT(3)) & 0xff;
223231
// This is the approximate integer arithmetic for the actual formula:
224232
// dst_factor_a = (dst_a * (255 - src_a)) / 255.
225233
const uint8_t dst_factor_a = (dst_a * (256 - src_a)) >> 8;
226234
const uint8_t blend_a = src_a + dst_factor_a;
227235
const uint32_t scale = (1UL << 24) / blend_a;
228236

229-
const uint8_t blend_r =
230-
BlendChannelNonPremult(src, src_a, dst, dst_factor_a, scale, 0);
231-
const uint8_t blend_g =
232-
BlendChannelNonPremult(src, src_a, dst, dst_factor_a, scale, 8);
233-
const uint8_t blend_b =
234-
BlendChannelNonPremult(src, src_a, dst, dst_factor_a, scale, 16);
237+
const uint8_t blend_r = BlendChannelNonPremult(
238+
src, src_a, dst, dst_factor_a, scale, CHANNEL_SHIFT(0));
239+
const uint8_t blend_g = BlendChannelNonPremult(
240+
src, src_a, dst, dst_factor_a, scale, CHANNEL_SHIFT(1));
241+
const uint8_t blend_b = BlendChannelNonPremult(
242+
src, src_a, dst, dst_factor_a, scale, CHANNEL_SHIFT(2));
235243
assert(src_a + dst_factor_a < 256);
236244

237-
return (blend_r << 0) |
238-
(blend_g << 8) |
239-
(blend_b << 16) |
240-
((uint32_t)blend_a << 24);
245+
return ((uint32_t)blend_r << CHANNEL_SHIFT(0)) |
246+
((uint32_t)blend_g << CHANNEL_SHIFT(1)) |
247+
((uint32_t)blend_b << CHANNEL_SHIFT(2)) |
248+
((uint32_t)blend_a << CHANNEL_SHIFT(3));
241249
}
242250
}
243251

@@ -247,7 +255,7 @@ static void BlendPixelRowNonPremult(uint32_t* const src,
247255
const uint32_t* const dst, int num_pixels) {
248256
int i;
249257
for (i = 0; i < num_pixels; ++i) {
250-
const uint8_t src_alpha = (src[i] >> 24) & 0xff;
258+
const uint8_t src_alpha = (src[i] >> CHANNEL_SHIFT(3)) & 0xff;
251259
if (src_alpha != 0xff) {
252260
src[i] = BlendPixelNonPremult(src[i], dst[i]);
253261
}
@@ -264,7 +272,7 @@ static WEBP_INLINE uint32_t ChannelwiseMultiply(uint32_t pix, uint32_t scale) {
264272

265273
// Blend 'src' over 'dst' assuming they are pre-multiplied by alpha.
266274
static uint32_t BlendPixelPremult(uint32_t src, uint32_t dst) {
267-
const uint8_t src_a = (src >> 24) & 0xff;
275+
const uint8_t src_a = (src >> CHANNEL_SHIFT(3)) & 0xff;
268276
return src + ChannelwiseMultiply(dst, 256 - src_a);
269277
}
270278

@@ -274,7 +282,7 @@ static void BlendPixelRowPremult(uint32_t* const src, const uint32_t* const dst,
274282
int num_pixels) {
275283
int i;
276284
for (i = 0; i < num_pixels; ++i) {
277-
const uint8_t src_alpha = (src[i] >> 24) & 0xff;
285+
const uint8_t src_alpha = (src[i] >> CHANNEL_SHIFT(3)) & 0xff;
278286
if (src_alpha != 0xff) {
279287
src[i] = BlendPixelPremult(src[i], dst[i]);
280288
}

Diff for: thirdparty/libwebp/src/demux/demux.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#define DMUX_MAJ_VERSION 1
2727
#define DMUX_MIN_VERSION 2
28-
#define DMUX_REV_VERSION 1
28+
#define DMUX_REV_VERSION 2
2929

3030
typedef struct {
3131
size_t start_; // start location of the data

Diff for: thirdparty/libwebp/src/dsp/dsp.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ extern "C" {
119119
#define WEBP_USE_NEON
120120
#endif
121121

122-
#if defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_M_ARM)
122+
// Note: ARM64 is supported in Visual Studio 2017, but requires the direct
123+
// inclusion of arm64_neon.h; Visual Studio 2019 includes this file in
124+
// arm_neon.h.
125+
#if defined(_MSC_VER) && \
126+
((_MSC_VER >= 1700 && defined(_M_ARM)) || \
127+
(_MSC_VER >= 1920 && defined(_M_ARM64)))
123128
#define WEBP_USE_NEON
124129
#define WEBP_USE_INTRINSICS
125130
#endif

Diff for: thirdparty/libwebp/src/dsp/enc_neon.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//
1010
// ARM NEON version of speed-critical encoding functions.
1111
//
12-
// adapted from libvpx (http://www.webmproject.org/code/)
12+
// adapted from libvpx (https://www.webmproject.org/code/)
1313

1414
#include "src/dsp/dsp.h"
1515

Diff for: thirdparty/libwebp/src/dsp/lossless.c

+36-22
Original file line numberDiff line numberDiff line change
@@ -107,63 +107,77 @@ static WEBP_INLINE uint32_t Select(uint32_t a, uint32_t b, uint32_t c) {
107107
//------------------------------------------------------------------------------
108108
// Predictors
109109

110-
uint32_t VP8LPredictor0_C(uint32_t left, const uint32_t* const top) {
110+
uint32_t VP8LPredictor0_C(const uint32_t* const left,
111+
const uint32_t* const top) {
111112
(void)top;
112113
(void)left;
113114
return ARGB_BLACK;
114115
}
115-
uint32_t VP8LPredictor1_C(uint32_t left, const uint32_t* const top) {
116+
uint32_t VP8LPredictor1_C(const uint32_t* const left,
117+
const uint32_t* const top) {
116118
(void)top;
117-
return left;
119+
return *left;
118120
}
119-
uint32_t VP8LPredictor2_C(uint32_t left, const uint32_t* const top) {
121+
uint32_t VP8LPredictor2_C(const uint32_t* const left,
122+
const uint32_t* const top) {
120123
(void)left;
121124
return top[0];
122125
}
123-
uint32_t VP8LPredictor3_C(uint32_t left, const uint32_t* const top) {
126+
uint32_t VP8LPredictor3_C(const uint32_t* const left,
127+
const uint32_t* const top) {
124128
(void)left;
125129
return top[1];
126130
}
127-
uint32_t VP8LPredictor4_C(uint32_t left, const uint32_t* const top) {
131+
uint32_t VP8LPredictor4_C(const uint32_t* const left,
132+
const uint32_t* const top) {
128133
(void)left;
129134
return top[-1];
130135
}
131-
uint32_t VP8LPredictor5_C(uint32_t left, const uint32_t* const top) {
132-
const uint32_t pred = Average3(left, top[0], top[1]);
136+
uint32_t VP8LPredictor5_C(const uint32_t* const left,
137+
const uint32_t* const top) {
138+
const uint32_t pred = Average3(*left, top[0], top[1]);
133139
return pred;
134140
}
135-
uint32_t VP8LPredictor6_C(uint32_t left, const uint32_t* const top) {
136-
const uint32_t pred = Average2(left, top[-1]);
141+
uint32_t VP8LPredictor6_C(const uint32_t* const left,
142+
const uint32_t* const top) {
143+
const uint32_t pred = Average2(*left, top[-1]);
137144
return pred;
138145
}
139-
uint32_t VP8LPredictor7_C(uint32_t left, const uint32_t* const top) {
140-
const uint32_t pred = Average2(left, top[0]);
146+
uint32_t VP8LPredictor7_C(const uint32_t* const left,
147+
const uint32_t* const top) {
148+
const uint32_t pred = Average2(*left, top[0]);
141149
return pred;
142150
}
143-
uint32_t VP8LPredictor8_C(uint32_t left, const uint32_t* const top) {
151+
uint32_t VP8LPredictor8_C(const uint32_t* const left,
152+
const uint32_t* const top) {
144153
const uint32_t pred = Average2(top[-1], top[0]);
145154
(void)left;
146155
return pred;
147156
}
148-
uint32_t VP8LPredictor9_C(uint32_t left, const uint32_t* const top) {
157+
uint32_t VP8LPredictor9_C(const uint32_t* const left,
158+
const uint32_t* const top) {
149159
const uint32_t pred = Average2(top[0], top[1]);
150160
(void)left;
151161
return pred;
152162
}
153-
uint32_t VP8LPredictor10_C(uint32_t left, const uint32_t* const top) {
154-
const uint32_t pred = Average4(left, top[-1], top[0], top[1]);
163+
uint32_t VP8LPredictor10_C(const uint32_t* const left,
164+
const uint32_t* const top) {
165+
const uint32_t pred = Average4(*left, top[-1], top[0], top[1]);
155166
return pred;
156167
}
157-
uint32_t VP8LPredictor11_C(uint32_t left, const uint32_t* const top) {
158-
const uint32_t pred = Select(top[0], left, top[-1]);
168+
uint32_t VP8LPredictor11_C(const uint32_t* const left,
169+
const uint32_t* const top) {
170+
const uint32_t pred = Select(top[0], *left, top[-1]);
159171
return pred;
160172
}
161-
uint32_t VP8LPredictor12_C(uint32_t left, const uint32_t* const top) {
162-
const uint32_t pred = ClampedAddSubtractFull(left, top[0], top[-1]);
173+
uint32_t VP8LPredictor12_C(const uint32_t* const left,
174+
const uint32_t* const top) {
175+
const uint32_t pred = ClampedAddSubtractFull(*left, top[0], top[-1]);
163176
return pred;
164177
}
165-
uint32_t VP8LPredictor13_C(uint32_t left, const uint32_t* const top) {
166-
const uint32_t pred = ClampedAddSubtractHalf(left, top[0], top[-1]);
178+
uint32_t VP8LPredictor13_C(const uint32_t* const left,
179+
const uint32_t* const top) {
180+
const uint32_t pred = ClampedAddSubtractHalf(*left, top[0], top[-1]);
167181
return pred;
168182
}
169183

Diff for: thirdparty/libwebp/src/dsp/lossless.h

+30-15
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,38 @@ extern "C" {
2828
//------------------------------------------------------------------------------
2929
// Decoding
3030

31-
typedef uint32_t (*VP8LPredictorFunc)(uint32_t left, const uint32_t* const top);
31+
typedef uint32_t (*VP8LPredictorFunc)(const uint32_t* const left,
32+
const uint32_t* const top);
3233
extern VP8LPredictorFunc VP8LPredictors[16];
3334

34-
uint32_t VP8LPredictor0_C(uint32_t left, const uint32_t* const top);
35-
uint32_t VP8LPredictor1_C(uint32_t left, const uint32_t* const top);
36-
uint32_t VP8LPredictor2_C(uint32_t left, const uint32_t* const top);
37-
uint32_t VP8LPredictor3_C(uint32_t left, const uint32_t* const top);
38-
uint32_t VP8LPredictor4_C(uint32_t left, const uint32_t* const top);
39-
uint32_t VP8LPredictor5_C(uint32_t left, const uint32_t* const top);
40-
uint32_t VP8LPredictor6_C(uint32_t left, const uint32_t* const top);
41-
uint32_t VP8LPredictor7_C(uint32_t left, const uint32_t* const top);
42-
uint32_t VP8LPredictor8_C(uint32_t left, const uint32_t* const top);
43-
uint32_t VP8LPredictor9_C(uint32_t left, const uint32_t* const top);
44-
uint32_t VP8LPredictor10_C(uint32_t left, const uint32_t* const top);
45-
uint32_t VP8LPredictor11_C(uint32_t left, const uint32_t* const top);
46-
uint32_t VP8LPredictor12_C(uint32_t left, const uint32_t* const top);
47-
uint32_t VP8LPredictor13_C(uint32_t left, const uint32_t* const top);
35+
uint32_t VP8LPredictor0_C(const uint32_t* const left,
36+
const uint32_t* const top);
37+
uint32_t VP8LPredictor1_C(const uint32_t* const left,
38+
const uint32_t* const top);
39+
uint32_t VP8LPredictor2_C(const uint32_t* const left,
40+
const uint32_t* const top);
41+
uint32_t VP8LPredictor3_C(const uint32_t* const left,
42+
const uint32_t* const top);
43+
uint32_t VP8LPredictor4_C(const uint32_t* const left,
44+
const uint32_t* const top);
45+
uint32_t VP8LPredictor5_C(const uint32_t* const left,
46+
const uint32_t* const top);
47+
uint32_t VP8LPredictor6_C(const uint32_t* const left,
48+
const uint32_t* const top);
49+
uint32_t VP8LPredictor7_C(const uint32_t* const left,
50+
const uint32_t* const top);
51+
uint32_t VP8LPredictor8_C(const uint32_t* const left,
52+
const uint32_t* const top);
53+
uint32_t VP8LPredictor9_C(const uint32_t* const left,
54+
const uint32_t* const top);
55+
uint32_t VP8LPredictor10_C(const uint32_t* const left,
56+
const uint32_t* const top);
57+
uint32_t VP8LPredictor11_C(const uint32_t* const left,
58+
const uint32_t* const top);
59+
uint32_t VP8LPredictor12_C(const uint32_t* const left,
60+
const uint32_t* const top);
61+
uint32_t VP8LPredictor13_C(const uint32_t* const left,
62+
const uint32_t* const top);
4863

4964
// These Add/Sub function expects upper[-1] and out[-1] to be readable.
5065
typedef void (*VP8LPredictorAddSubFunc)(const uint32_t* in,

Diff for: thirdparty/libwebp/src/dsp/lossless_common.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static void PREDICTOR_ADD(const uint32_t* in, const uint32_t* upper, \
179179
int x; \
180180
assert(upper != NULL); \
181181
for (x = 0; x < num_pixels; ++x) { \
182-
const uint32_t pred = (PREDICTOR)(out[x - 1], upper + x); \
182+
const uint32_t pred = (PREDICTOR)(&out[x - 1], upper + x); \
183183
out[x] = VP8LAddPixels(in[x], pred); \
184184
} \
185185
}

Diff for: thirdparty/libwebp/src/dsp/lossless_enc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ static void PredictorSub##PREDICTOR_I##_C(const uint32_t* in, \
745745
assert(upper != NULL); \
746746
for (x = 0; x < num_pixels; ++x) { \
747747
const uint32_t pred = \
748-
VP8LPredictor##PREDICTOR_I##_C(in[x - 1], upper + x); \
748+
VP8LPredictor##PREDICTOR_I##_C(&in[x - 1], upper + x); \
749749
out[x] = VP8LSubPixels(in[x], pred); \
750750
} \
751751
}

0 commit comments

Comments
 (0)