mirror of
https://github.com/google/wuffs.git
synced 2026-01-18 17:11:32 +01:00
std/nie: support premultiplied alpha formats
This commit is contained in:
@@ -12813,7 +12813,6 @@ struct wuffs_netpbm__decoder__struct {
|
||||
extern const char wuffs_nie__error__bad_frame[];
|
||||
extern const char wuffs_nie__error__bad_header[];
|
||||
extern const char wuffs_nie__error__truncated_input[];
|
||||
extern const char wuffs_nie__error__unsupported_nie_file[];
|
||||
extern const char wuffs_nie__error__unsupported_restart_frame_index[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
@@ -66756,7 +66755,6 @@ wuffs_netpbm__decoder__workbuf_len(
|
||||
const char wuffs_nie__error__bad_frame[] = "#nie: bad frame";
|
||||
const char wuffs_nie__error__bad_header[] = "#nie: bad header";
|
||||
const char wuffs_nie__error__truncated_input[] = "#nie: truncated input";
|
||||
const char wuffs_nie__error__unsupported_nie_file[] = "#nie: unsupported NIE file";
|
||||
const char wuffs_nie__error__unsupported_restart_frame_index[] = "#nie: unsupported restart frame index";
|
||||
const char wuffs_nie__note__internal_note_short_read[] = "@nie: internal note: short read";
|
||||
|
||||
@@ -67125,11 +67123,9 @@ wuffs_nie__decoder__do_decode_image_config(
|
||||
} else if (v_a == 946758399u) {
|
||||
self->private_impl.f_pixfmt = 2164308923u;
|
||||
} else if (v_a == 879780607u) {
|
||||
status = wuffs_base__make_status(wuffs_nie__error__unsupported_nie_file);
|
||||
goto exit;
|
||||
self->private_impl.f_pixfmt = 2181073032u;
|
||||
} else if (v_a == 946889471u) {
|
||||
status = wuffs_base__make_status(wuffs_nie__error__unsupported_nie_file);
|
||||
goto exit;
|
||||
self->private_impl.f_pixfmt = 2181086139u;
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_nie__error__bad_header);
|
||||
goto exit;
|
||||
@@ -67672,7 +67668,7 @@ wuffs_nie__decoder__skip_frame(
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_pixfmt == 2164308923u) {
|
||||
if ((self->private_impl.f_pixfmt == 2164308923u) || (self->private_impl.f_pixfmt == 2181086139u)) {
|
||||
v_src_bytes_per_pixel = 8u;
|
||||
} else {
|
||||
v_src_bytes_per_pixel = 4u;
|
||||
@@ -67967,7 +67963,7 @@ wuffs_nie__decoder__swizzle(
|
||||
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * ((uint64_t)(v_dst_bytes_per_pixel)));
|
||||
if (v_i >= ((uint64_t)(v_dst.len))) {
|
||||
v_src_bytes_per_pixel = 4u;
|
||||
if (self->private_impl.f_pixfmt == 2164308923u) {
|
||||
if ((self->private_impl.f_pixfmt == 2164308923u) || (self->private_impl.f_pixfmt == 2181086139u)) {
|
||||
v_src_bytes_per_pixel = 8u;
|
||||
}
|
||||
v_n = (((uint64_t)(io2_a_src - iop_a_src)) / ((uint64_t)(v_src_bytes_per_pixel)));
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
pub status "#bad frame"
|
||||
pub status "#bad header"
|
||||
pub status "#truncated input"
|
||||
pub status "#unsupported NIE file"
|
||||
pub status "#unsupported restart frame index"
|
||||
|
||||
pri status "@internal note: short read"
|
||||
@@ -88,9 +87,9 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
|
||||
} else if a == '\xFFbn8'le {
|
||||
this.pixfmt = base.PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE
|
||||
} else if a == '\xFFbp4'le {
|
||||
return "#unsupported NIE file"
|
||||
this.pixfmt = base.PIXEL_FORMAT__BGRA_PREMUL
|
||||
} else if a == '\xFFbp8'le {
|
||||
return "#unsupported NIE file"
|
||||
this.pixfmt = base.PIXEL_FORMAT__BGRA_PREMUL_4X16LE
|
||||
} else {
|
||||
return "#bad header"
|
||||
}
|
||||
@@ -229,7 +228,8 @@ pri func decoder.decode_animation_info?(src: base.io_reader) {
|
||||
pri func decoder.skip_frame?(src: base.io_reader) {
|
||||
var src_bytes_per_pixel : base.u64[..= 8]
|
||||
|
||||
if this.pixfmt == base.PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE {
|
||||
if (this.pixfmt == base.PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE) or
|
||||
(this.pixfmt == base.PIXEL_FORMAT__BGRA_PREMUL_4X16LE) {
|
||||
src_bytes_per_pixel = 8
|
||||
} else {
|
||||
src_bytes_per_pixel = 4
|
||||
@@ -356,7 +356,8 @@ pri func decoder.swizzle!(dst: ptr base.pixel_buffer, src: base.io_reader) base.
|
||||
if i >= dst.length() {
|
||||
src_bytes_per_pixel = 4
|
||||
assert src_bytes_per_pixel > 0
|
||||
if this.pixfmt == base.PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE {
|
||||
if (this.pixfmt == base.PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE) or
|
||||
(this.pixfmt == base.PIXEL_FORMAT__BGRA_PREMUL_4X16LE) {
|
||||
src_bytes_per_pixel = 8
|
||||
assert src_bytes_per_pixel > 0
|
||||
}
|
||||
|
||||
BIN
test/data/49.bn4.nie
Normal file
BIN
test/data/49.bn4.nie
Normal file
Binary file not shown.
BIN
test/data/49.bn8.nie
Normal file
BIN
test/data/49.bn8.nie
Normal file
Binary file not shown.
BIN
test/data/49.bp4.nie
Normal file
BIN
test/data/49.bp4.nie
Normal file
Binary file not shown.
BIN
test/data/49.bp8.nie
Normal file
BIN
test/data/49.bp8.nie
Normal file
Binary file not shown.
@@ -39,7 +39,8 @@ The non-ascii directory holds trivial UTF-8 (but not ASCII) text files.
|
||||
---
|
||||
|
||||
`36.png` and `49.png` are simple, artificially generated images. The generation
|
||||
script is `gen-36-49.go` from https://github.com/nigeltao/etc2
|
||||
script is `gen-36-49.go` from https://github.com/nigeltao/etc2 and the
|
||||
`49.*.nie` variants were generated from a customized version of that script.
|
||||
|
||||
`DCI-P3-D65.icc` comes from
|
||||
[color.org](https://www.color.org/chardata/rgb/DCIP3.xalter).
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# Generated by script/print-nia-checksums.sh
|
||||
OK. 9720c028 test/data/36.png
|
||||
OK. c3528d19 test/data/49.bn4.nie
|
||||
OK. c3528d19 test/data/49.bn8.nie
|
||||
OK. e3bae566 test/data/49.bp4.nie
|
||||
OK. c3528d19 test/data/49.bp8.nie
|
||||
OK. f2a0a3f6 test/data/49.png
|
||||
OK. d3bb0beb test/data/DCI-P3-D65.icc
|
||||
OK. 646e081a test/data/animated-red-blue.000000.nie
|
||||
|
||||
Reference in New Issue
Block a user