diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 91cb25cf..3d57d2aa 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -12861,17 +12861,10 @@ wuffs_gif__decoder__copy_to_image_buffer(wuffs_gif__decoder* self, v_pixfmt = wuffs_base__pixel_buffer__pixel_format(a_pb); v_bits_per_pixel = wuffs_base__pixel_format__bits_per_pixel(&v_pixfmt); - if (v_bits_per_pixel == 32) { - v_bytes_per_pixel = 4; - } else if (v_bits_per_pixel == 24) { - v_bytes_per_pixel = 3; - } else if (v_bits_per_pixel == 16) { - v_bytes_per_pixel = 2; - } else if (v_bits_per_pixel == 8) { - v_bytes_per_pixel = 1; - } else { + if ((v_bits_per_pixel > 512) || ((v_bits_per_pixel & 7) != 0)) { return wuffs_base__make_status(wuffs_base__error__unsupported_option); } + v_bytes_per_pixel = (v_bits_per_pixel >> 3); v_width_in_bytes = (((uint64_t)(self->private_impl.f_width)) * ((uint64_t)(v_bytes_per_pixel))); v_tab = wuffs_base__pixel_buffer__plane(a_pb, 0); diff --git a/std/gif/decode_gif.wuffs b/std/gif/decode_gif.wuffs index 358d1225..af78e3f2 100644 --- a/std/gif/decode_gif.wuffs +++ b/std/gif/decode_gif.wuffs @@ -1035,24 +1035,14 @@ pri func decoder.copy_to_image_buffer!(pb: ptr base.pixel_buffer, src: slice bas var replicate_dst : slice base.u8 var replicate_src : slice base.u8 - // TODO: a Wuffs (not just C) name for the WUFFS_BASE__PIXEL_FORMAT__ETC - // magic pixfmt constants. Also, support more formats. - // // TODO: the pixfmt variable shouldn't be necessary. We should be able to // chain the two calls: "args.pb.pixel_format().bits_per_pixel()". pixfmt = args.pb.pixel_format() bits_per_pixel = pixfmt.bits_per_pixel() - if (bits_per_pixel == 32) { - bytes_per_pixel = 4 - } else if (bits_per_pixel == 24) { - bytes_per_pixel = 3 - } else if (bits_per_pixel == 16) { - bytes_per_pixel = 2 - } else if (bits_per_pixel == 8) { - bytes_per_pixel = 1 - } else { + if (bits_per_pixel > 512) or ((bits_per_pixel & 7) <> 0) { return base."#unsupported option" } + bytes_per_pixel = bits_per_pixel >> 3 width_in_bytes = (this.width as base.u64) * (bytes_per_pixel as base.u64) tab = args.pb.plane(p: 0)