Rename std/bmp mask_x fields

This commit is contained in:
Nigel Tao committed 2020-11-23 22:40:11 +11:00
1 parent 3811a2b839
commit cda0db2f0c
2 files changed
+26 -28

No files matched your search

+8 -11
View File
@@ -5568,10 +5568,7 @@ struct wuffs_bmp__decoder__struct {
uint64_t f_io_redirect_pos;
uint64_t f_frame_config_io_position;
uint32_t f_padding;
uint32_t f_mask_r;
uint32_t f_mask_g;
uint32_t f_mask_b;
uint32_t f_mask_a;
uint32_t f_channel_masks[4];
uint32_t f_dst_x;
uint32_t f_dst_y;
uint32_t f_dst_y_end;
@@ -16495,7 +16492,7 @@ wuffs_bmp__decoder__decode_image_config(
*scratch |= ((uint64_t)(num_bits_8)) << 56;
}
}
self->private_impl.f_mask_r = t_8;
self->private_impl.f_channel_masks[2] = t_8;
}
{
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(21);
@@ -16524,7 +16521,7 @@ wuffs_bmp__decoder__decode_image_config(
*scratch |= ((uint64_t)(num_bits_9)) << 56;
}
}
self->private_impl.f_mask_g = t_9;
self->private_impl.f_channel_masks[1] = t_9;
}
{
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(23);
@@ -16553,7 +16550,7 @@ wuffs_bmp__decoder__decode_image_config(
*scratch |= ((uint64_t)(num_bits_10)) << 56;
}
}
self->private_impl.f_mask_b = t_10;
self->private_impl.f_channel_masks[0] = t_10;
}
if (v_bitmap_info_len >= 56) {
{
@@ -16583,7 +16580,7 @@ wuffs_bmp__decoder__decode_image_config(
*scratch |= ((uint64_t)(num_bits_11)) << 56;
}
}
self->private_impl.f_mask_a = t_11;
self->private_impl.f_channel_masks[3] = t_11;
}
self->private_data.s_decode_image_config[0].scratch = (v_bitmap_info_len - 56);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(27);
@@ -16595,11 +16592,11 @@ wuffs_bmp__decoder__decode_image_config(
}
iop_a_src += self->private_data.s_decode_image_config[0].scratch;
}
if ((self->private_impl.f_mask_r == 16711680) && (self->private_impl.f_mask_g == 65280) && (self->private_impl.f_mask_b == 255)) {
if ((self->private_impl.f_channel_masks[0] == 255) && (self->private_impl.f_channel_masks[1] == 65280) && (self->private_impl.f_channel_masks[2] == 16711680)) {
if (v_bits_per_pixel == 24) {
v_compression = 0;
} else if (v_bits_per_pixel == 32) {
if ((self->private_impl.f_mask_a == 0) || (self->private_impl.f_mask_a == 4278190080)) {
if ((self->private_impl.f_channel_masks[3] == 0) || (self->private_impl.f_channel_masks[3] == 4278190080)) {
v_compression = 0;
}
}
@@ -16626,7 +16623,7 @@ wuffs_bmp__decoder__decode_image_config(
} else if (v_bits_per_pixel == 32) {
self->private_impl.f_bytes_per_row = (((uint64_t)(self->private_impl.f_width)) * 4);
self->private_impl.f_pad_per_row = 0;
if (self->private_impl.f_mask_a == 0) {
if (self->private_impl.f_channel_masks[3] == 0) {
self->private_impl.f_pixfmt = wuffs_base__utility__make_pixel_format(2415954056);
} else {
self->private_impl.f_pixfmt = wuffs_base__utility__make_pixel_format(2164295816);
+18 -17
View File
@@ -37,10 +37,9 @@ pub struct decoder? implements base.image_decoder(
padding : base.u32,
mask_r : base.u32,
mask_g : base.u32,
mask_b : base.u32,
mask_a : base.u32,
// channel_etc's indexes are: B, G, R, A. This is in Wuffs' default order,
// which isn't the RGBA order they're listed in the wire format.
channel_masks : array[4] base.u32,
dst_x : base.u32,
dst_y : base.u32,
@@ -97,7 +96,7 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
if bitmap_info_len == 40 {
// It's poorly documented, but some "length 40" data can be silently
// augmented with RGB masks (12 bytes) or RGBA masks (16 bytes).
// augmented with RGB or RGBA channel_masks (12 or 16 bytes).
if this.padding >= 16 {
bitmap_info_len = 56
this.padding -= 16
@@ -151,26 +150,28 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
// the version 3 BITMAPINFOHEADER (whose total size is 40).
args.src.skip_u32?(n: 40 - 20)
// Read the masks when compression is 3 (BITFIELDS) or 6 (ALPHABITFIELDS).
// Read the channel_masks when compression is 3 (BITFIELDS) or 6
// (ALPHABITFIELDS).
if (compression == 3) or (compression == 6) {
if bitmap_info_len >= 52 {
this.mask_r = args.src.read_u32le?()
this.mask_g = args.src.read_u32le?()
this.mask_b = args.src.read_u32le?()
this.channel_masks[2] = args.src.read_u32le?()
this.channel_masks[1] = args.src.read_u32le?()
this.channel_masks[0] = args.src.read_u32le?()
if bitmap_info_len >= 56 {
this.mask_a = args.src.read_u32le?()
this.channel_masks[3] = args.src.read_u32le?()
// Skip the rest of the BITMAPINFOHEADER.
args.src.skip_u32?(n: bitmap_info_len - 56)
}
// If the explicit masks are what the implicit masks would be for
// no compression, treat it as no compression.
if (this.mask_r == 0x00FF_0000) and
(this.mask_g == 0x0000_FF00) and
(this.mask_b == 0x0000_00FF) {
// If the explicit channel_masks are what the implicit ones would
// be for no compression, treat it as no compression.
if (this.channel_masks[0] == 0x0000_00FF) and
(this.channel_masks[1] == 0x0000_FF00) and
(this.channel_masks[2] == 0x00FF_0000) {
if bits_per_pixel == 24 {
compression = 0
} else if bits_per_pixel == 32 {
if (this.mask_a == 0) or (this.mask_a == 0xFF00_0000) {
if (this.channel_masks[3] == 0) or
(this.channel_masks[3] == 0xFF00_0000) {
compression = 0
}
}
@@ -192,7 +193,7 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
} else if bits_per_pixel == 32 {
this.bytes_per_row = (this.width as base.u64) * 4
this.pad_per_row = 0
if this.mask_a == 0 {
if this.channel_masks[3] == 0 {
this.pixfmt = this.util.make_pixel_format(repr: base.PIXEL_FORMAT__BGRX)
} else {
this.pixfmt = this.util.make_pixel_format(repr: base.PIXEL_FORMAT__BGRA_NONPREMUL)