Skip to content

Commit f8b3ab6

Browse files
authored
Merge pull request #26 from qnighy/feat/libwebp-1.5.0
Support libwebp 1.5.0
2 parents daa4af8 + 29516c8 commit f8b3ab6

File tree

10 files changed

+148
-16
lines changed

10 files changed

+148
-16
lines changed

.github/workflows/test.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
rust: [stable]
12-
webp: [0.4.4, 0.5.2, 1.0.3, 1.1.0, 1.2.0]
12+
webp: [0.4.4, 0.5.2, 1.0.3, 1.1.0, 1.2.0, 1.4.0, 1.5.0]
1313
webp_from: ["build"]
1414
common_features: [""]
1515
include:
@@ -18,23 +18,23 @@ jobs:
1818
webp_from: distr
1919
common_features: ""
2020
- rust: stable
21-
webp: 1.2.0
21+
webp: 1.5.0
2222
webp_from: bundled
2323
common_features: ""
2424
- rust: 1.31.0
25-
webp: 1.2.0
25+
webp: 1.5.0
2626
webp_from: build
2727
common_features: ""
2828
- rust: beta
29-
webp: 1.2.0
29+
webp: 1.5.0
3030
webp_from: build
3131
common_features: ""
3232
- rust: nightly
33-
webp: 1.2.0
33+
webp: 1.5.0
3434
webp_from: build
3535
common_features: ""
3636
- rust: nightly
37-
webp: 1.2.0
37+
webp: 1.5.0
3838
webp_from: build
3939
common_features: extern-types,
4040

@@ -101,12 +101,26 @@ jobs:
101101
cargo test --all --features "${{ matrix.common_features }}1_2,mux"
102102
cargo test --all --features "${{ matrix.common_features }}1_2,demux,mux"
103103
if: matrix.webp >= '1.2'
104+
- name: Test 1.4
105+
run: |
106+
cargo test --all --features "${{ matrix.common_features }}1_4"
107+
cargo test --all --features "${{ matrix.common_features }}1_4,demux"
108+
cargo test --all --features "${{ matrix.common_features }}1_4,mux"
109+
cargo test --all --features "${{ matrix.common_features }}1_4,demux,mux"
110+
if: matrix.webp >= '1.4'
111+
- name: Test 1.5
112+
run: |
113+
cargo test --all --features "${{ matrix.common_features }}1_5"
114+
cargo test --all --features "${{ matrix.common_features }}1_5,demux"
115+
cargo test --all --features "${{ matrix.common_features }}1_5,mux"
116+
cargo test --all --features "${{ matrix.common_features }}1_5,demux,mux"
117+
if: matrix.webp >= '1.5'
104118
- name: Test static builds
105119
run: |
106-
cargo test --all --features "${{ matrix.common_features }}1_2,static"
107-
cargo test --all --features "${{ matrix.common_features }}1_2,static,demux"
108-
cargo test --all --features "${{ matrix.common_features }}1_2,static,mux"
109-
cargo test --all --features "${{ matrix.common_features }}1_2,static,demux,mux"
120+
cargo test --all --features "${{ matrix.common_features }}1_5,static"
121+
cargo test --all --features "${{ matrix.common_features }}1_5,static,demux"
122+
cargo test --all --features "${{ matrix.common_features }}1_5,static,mux"
123+
cargo test --all --features "${{ matrix.common_features }}1_5,static,demux,mux"
110124
if: matrix.webp_from == 'bundled'
111125
- name: Test __doc_cfg
112126
run: |

Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ mux = []
3535
"0_6" = ["0_5"]
3636
"1_1" = ["0_6"]
3737
"1_2" = ["1_1"]
38+
"1_4" = ["1_2"]
39+
"1_5" = ["1_4"]
3840
static = []
3941
extern-types = []
40-
__doc_cfg = ["1_2", "demux", "mux"]
42+
must-use = []
43+
__doc_cfg = ["1_5", "demux", "mux"]
4144

4245
[package.metadata.docs.rs]
43-
features = ["1_2", "demux", "mux", "__doc_cfg", "extern-types"]
46+
features = ["1_5", "demux", "mux", "__doc_cfg", "extern-types", "must-use"]
4447

4548
[build-dependencies]
4649
pkg-config = "0.3.17"

build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ fn build_libwebp() {
209209
.file("c_src/src/utils/color_cache_utils.c")
210210
.file("c_src/src/utils/filters_utils.c")
211211
.file("c_src/src/utils/huffman_utils.c")
212+
.file("c_src/src/utils/palette.c")
212213
.file("c_src/src/utils/quant_levels_dec_utils.c")
213214
.file("c_src/src/utils/rescaler_utils.c")
214215
.file("c_src/src/utils/random_utils.c")

c_src

Submodule c_src updated from ca33220 to a4d7a71

src/decode.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ impl std::fmt::Debug for __WebPDecBufferUnion {
169169

170170
/// Enumeration of the status codes
171171
#[allow(non_camel_case_types)]
172+
// #[cfg_attr(feature = "must-use", must_use)] // meaningless for type aliases
172173
pub type VP8StatusCode = u32;
173174

174175
pub const VP8_STATUS_OK: VP8StatusCode = 0;
@@ -322,6 +323,7 @@ extern "C" {
322323
/// RIFF + VP8X + (optional chunks) + VP8(L)
323324
/// ALPH + VP8 <-- Not a valid WebP format: only allowed for internal purpose.
324325
/// VP8(L) <-- Not a valid WebP format: only allowed for internal purpose.
326+
#[cfg_attr(feature = "must-use", must_use)]
325327
pub fn WebPGetInfo(
326328
data: *const u8,
327329
data_size: usize,
@@ -333,20 +335,23 @@ extern "C" {
333335
/// memory is R, G, B, A, R, G, B, A... in scan order (endian-independent).
334336
/// The returned pointer should be deleted calling WebPFree().
335337
/// Returns NULL in case of error.
338+
#[cfg_attr(feature = "must-use", must_use)]
336339
pub fn WebPDecodeRGBA(
337340
data: *const u8,
338341
data_size: usize,
339342
width: *mut c_int,
340343
height: *mut c_int,
341344
) -> *mut u8;
342345
/// Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data.
346+
#[cfg_attr(feature = "must-use", must_use)]
343347
pub fn WebPDecodeARGB(
344348
data: *const u8,
345349
data_size: usize,
346350
width: *mut c_int,
347351
height: *mut c_int,
348352
) -> *mut u8;
349353
/// Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data.
354+
#[cfg_attr(feature = "must-use", must_use)]
350355
pub fn WebPDecodeBGRA(
351356
data: *const u8,
352357
data_size: usize,
@@ -355,13 +360,15 @@ extern "C" {
355360
) -> *mut u8;
356361
/// Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data.
357362
/// If the bitstream contains transparency, it is ignored.
363+
#[cfg_attr(feature = "must-use", must_use)]
358364
pub fn WebPDecodeRGB(
359365
data: *const u8,
360366
data_size: usize,
361367
width: *mut c_int,
362368
height: *mut c_int,
363369
) -> *mut u8;
364370
/// Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data.
371+
#[cfg_attr(feature = "must-use", must_use)]
365372
pub fn WebPDecodeBGR(
366373
data: *const u8,
367374
data_size: usize,
@@ -378,6 +385,7 @@ extern "C" {
378385
/// 'width' and 'height' may be NULL, the other pointers must not be.
379386
/// Returns NULL in case of error.
380387
/// (*) Also named Y'CbCr. See: https://en.wikipedia.org/wiki/YCbCr
388+
#[cfg_attr(feature = "must-use", must_use)]
381389
pub fn WebPDecodeYUV(
382390
data: *const u8,
383391
data_size: usize,
@@ -396,20 +404,23 @@ extern "C" {
396404
// The parameter 'output_stride' specifies the distance (in bytes)
397405
// between scanlines. Hence, output_buffer_size is expected to be at least
398406
// output_stride x picture-height.
407+
#[cfg_attr(feature = "must-use", must_use)]
399408
pub fn WebPDecodeRGBAInto(
400409
data: *const u8,
401410
data_size: usize,
402411
output_buffer: *mut u8,
403412
output_buffer_size: usize,
404413
output_stride: c_int,
405414
) -> *mut u8;
415+
#[cfg_attr(feature = "must-use", must_use)]
406416
pub fn WebPDecodeARGBInto(
407417
data: *const u8,
408418
data_size: usize,
409419
output_buffer: *mut u8,
410420
output_buffer_size: usize,
411421
output_stride: c_int,
412422
) -> *mut u8;
423+
#[cfg_attr(feature = "must-use", must_use)]
413424
pub fn WebPDecodeBGRAInto(
414425
data: *const u8,
415426
data_size: usize,
@@ -419,13 +430,15 @@ extern "C" {
419430
) -> *mut u8;
420431
// RGB and BGR variants. Here too the transparency information, if present,
421432
// will be dropped and ignored.
433+
#[cfg_attr(feature = "must-use", must_use)]
422434
pub fn WebPDecodeRGBInto(
423435
data: *const u8,
424436
data_size: usize,
425437
output_buffer: *mut u8,
426438
output_buffer_size: usize,
427439
output_stride: c_int,
428440
) -> *mut u8;
441+
#[cfg_attr(feature = "must-use", must_use)]
429442
pub fn WebPDecodeBGRInto(
430443
data: *const u8,
431444
data_size: usize,
@@ -440,6 +453,7 @@ extern "C" {
440453
/// 'u_size' and 'v_size' respectively.
441454
/// Pointer to the luma plane ('*luma') is returned or NULL if an error occurred
442455
/// during decoding (or because some buffers were found to be too small).
456+
#[cfg_attr(feature = "must-use", must_use)]
443457
pub fn WebPDecodeYUVInto(
444458
data: *const u8,
445459
data_size: usize,
@@ -455,6 +469,7 @@ extern "C" {
455469
) -> *mut u8;
456470
/// Internal, version-checked, entry point
457471
#[doc(hidden)]
472+
#[cfg_attr(feature = "must-use", must_use)]
458473
pub fn WebPInitDecBufferInternal(_: *mut WebPDecBuffer, _: c_int) -> c_int;
459474
/// Free any memory associated with the buffer. Must always be called last.
460475
/// Note: doesn't free the 'buffer' structure itself.
@@ -471,6 +486,7 @@ extern "C" {
471486
/// within valid bounds.
472487
/// All other fields of WebPDecBuffer MUST remain constant between calls.
473488
/// Returns NULL if the allocation failed.
489+
#[cfg_attr(feature = "must-use", must_use)]
474490
pub fn WebPINewDecoder(output_buffer: *mut WebPDecBuffer) -> *mut WebPIDecoder;
475491
/// This function allocates and initializes an incremental-decoder object, which
476492
/// will output the RGB/A samples specified by 'csp' into a preallocated
@@ -482,6 +498,7 @@ extern "C" {
482498
/// colorspace 'csp' is taken into account for allocating this buffer. All other
483499
/// parameters are ignored.
484500
/// Returns NULL if the allocation failed, or if some parameters are invalid.
501+
#[cfg_attr(feature = "must-use", must_use)]
485502
pub fn WebPINewRGB(
486503
csp: WEBP_CSP_MODE,
487504
output_buffer: *mut u8,
@@ -499,6 +516,7 @@ extern "C" {
499516
/// In this case, the output buffer will be automatically allocated (using
500517
/// MODE_YUVA) when decoding starts. All parameters are then ignored.
501518
/// Returns NULL if the allocation failed or if a parameter is invalid.
519+
#[cfg_attr(feature = "must-use", must_use)]
502520
pub fn WebPINewYUVA(
503521
luma: *mut u8,
504522
luma_size: usize,
@@ -515,6 +533,7 @@ extern "C" {
515533
) -> *mut WebPIDecoder;
516534
/// Deprecated version of the above, without the alpha plane.
517535
/// Kept for backward compatibility.
536+
#[cfg_attr(feature = "must-use", must_use)]
518537
pub fn WebPINewYUV(
519538
luma: *mut u8,
520539
luma_size: usize,
@@ -548,6 +567,7 @@ extern "C" {
548567
/// (*last_y, *width etc.) can be NULL if corresponding information is not
549568
/// needed. The values in these pointers are only valid on successful (non-NULL)
550569
/// return.
570+
#[cfg_attr(feature = "must-use", must_use)]
551571
pub fn WebPIDecGetRGB(
552572
idec: *const WebPIDecoder,
553573
last_y: *mut c_int,
@@ -558,6 +578,7 @@ extern "C" {
558578
/// Same as above function to get a YUVA image. Returns pointer to the luma
559579
/// plane or NULL in case of error. If there is no alpha information
560580
/// the alpha pointer '*a' will be returned NULL.
581+
#[cfg_attr(feature = "must-use", must_use)]
561582
pub fn WebPIDecGetYUVA(
562583
idec: *const WebPIDecoder,
563584
last_y: *mut c_int,
@@ -576,6 +597,7 @@ extern "C" {
576597
/// Returns NULL in case the incremental decoder object is in an invalid state.
577598
/// Otherwise returns the pointer to the internal representation. This structure
578599
/// is read-only, tied to WebPIDecoder's lifespan and should not be modified.
600+
#[cfg_attr(feature = "must-use", must_use)]
579601
pub fn WebPIDecodedArea(
580602
idec: *const WebPIDecoder,
581603
left: *mut c_int,
@@ -593,6 +615,7 @@ extern "C" {
593615
) -> VP8StatusCode;
594616
/// Internal, version-checked, entry point
595617
#[doc(hidden)]
618+
#[cfg_attr(feature = "must-use", must_use)]
596619
pub fn WebPInitDecoderConfigInternal(_: *mut WebPDecoderConfig, _: c_int) -> c_int;
597620
/// Instantiate a new incremental decoder object with the requested
598621
/// configuration. The bitstream can be passed using 'data' and 'data_size'
@@ -605,6 +628,7 @@ extern "C" {
605628
/// The return WebPIDecoder object must always be deleted calling WebPIDelete().
606629
/// Returns NULL in case of error (and config->status will then reflect
607630
/// the error condition, if available).
631+
#[cfg_attr(feature = "must-use", must_use)]
608632
pub fn WebPIDecode(
609633
data: *const u8,
610634
data_size: usize,
@@ -623,6 +647,7 @@ extern "C" {
623647
/// Initialize the structure as empty. Must be called before any other use.
624648
/// Returns false in case of version mismatch
625649
#[allow(non_snake_case)]
650+
#[cfg_attr(feature = "must-use", must_use)]
626651
#[inline]
627652
pub unsafe extern "C" fn WebPInitDecBuffer(buffer: *mut WebPDecBuffer) -> c_int {
628653
WebPInitDecBufferInternal(buffer, WEBP_DECODER_ABI_VERSION)
@@ -653,6 +678,7 @@ pub unsafe extern "C" fn WebPGetFeatures(
653678
/// called first, unless WebPGetFeatures() is to be called.
654679
/// Returns false in case of mismatched version.
655680
#[allow(non_snake_case)]
681+
#[cfg_attr(feature = "must-use", must_use)]
656682
#[inline]
657683
pub unsafe extern "C" fn WebPInitDecoderConfig(config: *mut WebPDecoderConfig) -> c_int {
658684
WebPInitDecoderConfigInternal(config, WEBP_DECODER_ABI_VERSION)

0 commit comments

Comments
 (0)