std/webp: ignore alpha_is_used bit per the spec

This commit is contained in:
Nigel Tao committed 2026-07-16 21:49:31 +10:00
1 parent 8515165bee
commit e3bda4efc9
3 files changed
+12 -22

No files matched your search

+3 -11
View File
@@ -16393,7 +16393,6 @@ struct wuffs_webp__decoder__struct {
wuffs_base__vtable vtable_for__wuffs_base__image_decoder;
wuffs_base__vtable null_vtable;
uint32_t f_pixfmt;
uint32_t f_width;
uint32_t f_height;
uint8_t f_call_sequence;
@@ -89292,7 +89291,7 @@ wuffs_webp__decoder__do_decode_image_config(
if ( ! self->private_impl.f_is_vp8_lossy && (a_dst != NULL)) {
wuffs_base__image_config__set(
a_dst,
self->private_impl.f_pixfmt,
2164295816u,
0u,
self->private_impl.f_width,
self->private_impl.f_height,
@@ -89609,10 +89608,6 @@ wuffs_webp__decoder__do_decode_image_config_limited_vp8l(
v_c32 >>= 14u;
self->private_impl.f_height = ((v_c32 & 16383u) + 1u);
v_c32 >>= 14u;
self->private_impl.f_pixfmt = 2415954056u;
if ((v_c32 & 1u) != 0u) {
self->private_impl.f_pixfmt = 2164295816u;
}
v_c32 >>= 1u;
if (v_c32 != 0u) {
status = wuffs_base__make_status(wuffs_webp__error__bad_header);
@@ -89726,8 +89721,6 @@ wuffs_webp__decoder__do_decode_frame_config(
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__pixel_format v_pixfmt = {0};
const uint8_t* iop_a_src = NULL;
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
@@ -89770,7 +89763,6 @@ wuffs_webp__decoder__do_decode_frame_config(
goto ok;
}
if (a_dst != NULL) {
v_pixfmt = wuffs_base__utility__make_pixel_format(self->private_impl.f_pixfmt);
wuffs_base__frame_config__set(
a_dst,
wuffs_base__utility__make_rect_ie_u32(
@@ -89784,7 +89776,7 @@ wuffs_webp__decoder__do_decode_frame_config(
0u,
false,
false,
wuffs_base__pixel_format__default_background_color(&v_pixfmt));
0u);
}
self->private_impl.f_call_sequence = 64u;
@@ -90741,7 +90733,7 @@ wuffs_webp__decoder__swizzle(
v_status = wuffs_base__pixel_swizzler__prepare(&self->private_impl.f_swizzler,
wuffs_base__pixel_buffer__pixel_format(a_dst),
wuffs_base__pixel_buffer__palette_or_else(a_dst, wuffs_base__make_slice_u8(self->private_data.f_palette, 1024)),
wuffs_base__utility__make_pixel_format(self->private_impl.f_pixfmt),
wuffs_base__utility__make_pixel_format(2164295816u),
wuffs_base__utility__empty_slice_u8(),
a_blend);
if ( ! wuffs_base__status__is_ok(&v_status)) {
+2
View File
@@ -2,6 +2,8 @@
WebP is a still image format, described in the [WebP Container
Specification](https://developers.google.com/speed/webp/docs/riff_container).
It is a container for [VP8 Lossy](https://www.ietf.org/rfc/rfc6386.txt) or [VP8
Lossless](https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification).
The ["Making Software - Image
Compression"](https://www.makingsoftware.com/chapters/image-compression) book
+7 -11
View File
@@ -31,7 +31,6 @@ pri status "#internal error: inconsistent n_bits"
pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 0x4C00_0000
pub struct decoder? implements base.image_decoder(
pixfmt : base.u32,
width : base.u32[..= 0x4000],
height : base.u32[..= 0x4000],
@@ -202,7 +201,7 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
if (not this.is_vp8_lossy) and (args.dst <> nullptr) {
args.dst.set!(
pixfmt: this.pixfmt,
pixfmt: base.PIXEL_FORMAT__BGRA_NONPREMUL,
pixsub: 0,
width: this.width,
height: this.height,
@@ -283,10 +282,10 @@ pri func decoder.do_decode_image_config_limited_vp8l?(src: base.io_reader) {
c32 >>= 14
this.height = (c32 & 0x3FFF) + 1
c32 >>= 14
this.pixfmt = base.PIXEL_FORMAT__BGRX
if (c32 & 1) <> 0 {
this.pixfmt = base.PIXEL_FORMAT__BGRA_NONPREMUL
}
// In theory, (c32 & 1) would let us discriminate between
// base.PIXEL_FORMAT__BGRX and base.PIXEL_FORMAT__BGRA_NONPREMUL, but the
// VP8 Lossless spec says that this bit "is a hint only, and *should not
// impact decoding* [emphasis added]".
c32 >>= 1
if c32 <> 0 {
return "#bad header"
@@ -316,8 +315,6 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_
}
pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
var pixfmt : base.pixel_format
if this.call_sequence == 0x20 {
// No-op.
} else if this.call_sequence < 0x20 {
@@ -334,7 +331,6 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.
}
if args.dst <> nullptr {
pixfmt = this.util.make_pixel_format(repr: this.pixfmt)
args.dst.set!(bounds: this.util.make_rect_ie_u32(
min_incl_x: 0,
min_incl_y: 0,
@@ -346,7 +342,7 @@ pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.
disposal: 0,
opaque_within_bounds: false,
overwrite_instead_of_blend: false,
background_color: pixfmt.default_background_color())
background_color: 0x0000_0000)
}
this.call_sequence = 0x40
@@ -809,7 +805,7 @@ pri func decoder.swizzle!(dst: ptr base.pixel_buffer, src: roslice base.u8, blen
status = this.swizzler.prepare!(
dst_pixfmt: args.dst.pixel_format(),
dst_palette: args.dst.palette_or_else(fallback: this.palette[..]),
src_pixfmt: this.util.make_pixel_format(repr: this.pixfmt),
src_pixfmt: this.util.make_pixel_format(repr: base.PIXEL_FORMAT__BGRA_NONPREMUL),
src_palette: this.util.empty_slice_u8(),
blend: args.blend)
if not status.is_ok() {