Add write_to_ib_instead_of_w transition support

This commit is contained in:
Nigel Tao committed 2018-05-24 09:54:26 +10:00
1 parent a66f8201cf
commit 9d524be60d
3 files changed
+63 -43

No files matched your search

+36 -25
View File
@@ -1258,6 +1258,7 @@ typedef struct {
uint8_t v_lw;
uint64_t v_block_size;
wuffs_gif__status v_z;
bool v_write_to_ib_instead_of_w;
uint64_t v_n_copied;
} c_decode_id_part1[1];
} private_impl;
@@ -3036,6 +3037,7 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id_part1(
WUFFS_BASE__IGNORE_POTENTIALLY_UNUSED_VARIABLE(ioptr_w);
WUFFS_BASE__IGNORE_POTENTIALLY_UNUSED_VARIABLE(iobounds1_w);
wuffs_gif__status v_z;
bool v_write_to_ib_instead_of_w;
wuffs_base__slice_u8 v_pass_through;
uint64_t v_n_copied;
wuffs_base__table_u8 v_tab;
@@ -3085,12 +3087,15 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id_part1(
v_block_size = self->private_impl.c_decode_id_part1[0].v_block_size;
v_w = ((wuffs_base__io_writer){});
v_z = self->private_impl.c_decode_id_part1[0].v_z;
v_write_to_ib_instead_of_w =
self->private_impl.c_decode_id_part1[0].v_write_to_ib_instead_of_w;
v_pass_through = ((wuffs_base__slice_u8){});
v_n_copied = self->private_impl.c_decode_id_part1[0].v_n_copied;
v_tab = ((wuffs_base__table_u8){});
v_pixel_data = ((wuffs_base__slice_u8){});
} else {
v_w = ((wuffs_base__io_writer){});
v_write_to_ib_instead_of_w = false;
v_pass_through = ((wuffs_base__slice_u8){});
v_tab = ((wuffs_base__table_u8){});
v_pixel_data = ((wuffs_base__slice_u8){});
@@ -3219,32 +3224,36 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id_part1(
a_src = o_0_a_src;
}
if ((v_z == 0) || (v_z == WUFFS_GIF__SUSPENSION_SHORT_WRITE)) {
while (self->private_impl.f_uncompressed_ri <
self->private_impl.f_uncompressed_wi) {
v_pass_through = wuffs_base__slice_u8__subslice_ij(
((wuffs_base__slice_u8){
.ptr = self->private_impl.f_uncompressed, .len = 4096}),
self->private_impl.f_uncompressed_ri,
self->private_impl.f_uncompressed_wi);
v_n_copied = wuffs_base__io_writer__copy_from_slice(
&ioptr_dst, iobounds1_dst, v_pass_through);
if (v_n_copied == ((uint64_t)(v_pass_through.len))) {
self->private_impl.f_uncompressed_ri = 0;
self->private_impl.f_uncompressed_wi = 0;
goto label_2_break;
v_write_to_ib_instead_of_w = false;
if (!v_write_to_ib_instead_of_w) {
while (self->private_impl.f_uncompressed_ri <
self->private_impl.f_uncompressed_wi) {
v_pass_through = wuffs_base__slice_u8__subslice_ij(
((wuffs_base__slice_u8){
.ptr = self->private_impl.f_uncompressed, .len = 4096}),
self->private_impl.f_uncompressed_ri,
self->private_impl.f_uncompressed_wi);
v_n_copied = wuffs_base__io_writer__copy_from_slice(
&ioptr_dst, iobounds1_dst, v_pass_through);
if (v_n_copied == ((uint64_t)(v_pass_through.len))) {
self->private_impl.f_uncompressed_ri = 0;
self->private_impl.f_uncompressed_wi = 0;
goto label_2_break;
}
self->private_impl.f_uncompressed_ri =
((self->private_impl.f_uncompressed_ri +
((uint32_t)((v_n_copied & 4095)))) &
4095);
status = WUFFS_GIF__SUSPENSION_SHORT_WRITE;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(7);
}
self->private_impl.f_uncompressed_ri =
((self->private_impl.f_uncompressed_ri +
((uint32_t)((v_n_copied & 4095)))) &
4095);
status = WUFFS_GIF__SUSPENSION_SHORT_WRITE;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(7);
}
label_2_break:;
v_tab = wuffs_base__image_buffer__plane(a_ib, 0);
if (((uint64_t)(v_tab.width)) == ((uint64_t)(v_tab.stride))) {
v_pixel_data = wuffs_base__table_u8__linearize(v_tab);
if (((uint64_t)(v_pixel_data.len)) == 0) {
label_2_break:;
} else {
v_tab = wuffs_base__image_buffer__plane(a_ib, 0);
if (((uint64_t)(v_tab.width)) == ((uint64_t)(v_tab.stride))) {
v_pixel_data = wuffs_base__table_u8__linearize(v_tab);
if (((uint64_t)(v_pixel_data.len)) == 0) {
}
}
}
if (v_z == WUFFS_GIF__SUSPENSION_SHORT_WRITE) {
@@ -3278,6 +3287,8 @@ suspend:
self->private_impl.c_decode_id_part1[0].v_lw = v_lw;
self->private_impl.c_decode_id_part1[0].v_block_size = v_block_size;
self->private_impl.c_decode_id_part1[0].v_z = v_z;
self->private_impl.c_decode_id_part1[0].v_write_to_ib_instead_of_w =
v_write_to_ib_instead_of_w;
self->private_impl.c_decode_id_part1[0].v_n_copied = v_n_copied;
goto exit;
+1
View File
@@ -1258,6 +1258,7 @@ typedef struct {
uint8_t v_lw;
uint64_t v_block_size;
wuffs_gif__status v_z;
bool v_write_to_ib_instead_of_w;
uint64_t v_n_copied;
} c_decode_id_part1[1];
} private_impl;
+26 -18
View File
@@ -385,27 +385,35 @@ pri func decoder.decode_id_part1?(ib ptr base.image_buffer, dst base.io_writer,
//
// TODO: in.dst should be a ptr base.image_buffer and we should
// composite the pixels instead of just copying them.
while this.uncompressed_ri < this.uncompressed_wi {
var pass_through slice base.u8 = this.uncompressed[this.uncompressed_ri:this.uncompressed_wi]
var n_copied base.u64 = in.dst.copy_from_slice!(s:pass_through)
if n_copied == pass_through.length() {
this.uncompressed_ri = 0
this.uncompressed_wi = 0
break
//
// TODO: delete the write_to_ib_instead_of_w hack. It should
// always be true.
var write_to_ib_instead_of_w base.bool = false
if not write_to_ib_instead_of_w {
while this.uncompressed_ri < this.uncompressed_wi {
var pass_through slice base.u8 = this.uncompressed[this.uncompressed_ri:this.uncompressed_wi]
var n_copied base.u64 = in.dst.copy_from_slice!(s:pass_through)
if n_copied == pass_through.length() {
this.uncompressed_ri = 0
this.uncompressed_wi = 0
break
}
this.uncompressed_ri = (this.uncompressed_ri + ((n_copied & 4095) as base.u32)) & 4095
// TODO: "closed for writes" instead?
yield suspension "short write"
}
this.uncompressed_ri = (this.uncompressed_ri + ((n_copied & 4095) as base.u32)) & 4095
// TODO: "closed for writes" instead?
yield suspension "short write"
}
// TODO: don't assume a packed pixel format.
var tab table base.u8 = in.ib.plane(p:0)
if tab.width() == tab.stride() {
var pixel_data slice base.u8 = tab.linearize()
if pixel_data.length() == 0 {
} else {
// TODO: don't assume a packed pixel format.
var tab table base.u8 = in.ib.plane(p:0)
if tab.width() == tab.stride() {
var pixel_data slice base.u8 = tab.linearize()
if pixel_data.length() == 0 {
// TODO.
}
} else {
// TODO.
}
} else {
// TODO.
}
if z == suspension "short write" {