mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 00:55:11 +01:00
Rename some variables for clarity.
This commit is contained in:
1 parent
b402429eee
commit
c1789e0065
6 files changed
+71
-72
No files matched your search
+34
-34
@@ -182,7 +182,7 @@ typedef struct {
|
|||||||
struct {
|
struct {
|
||||||
uint32_t coro_susp_point;
|
uint32_t coro_susp_point;
|
||||||
puffs_flate_status v_z;
|
puffs_flate_status v_z;
|
||||||
uint64_t v_n;
|
uint64_t v_n_copied;
|
||||||
uint32_t v_already_full;
|
uint32_t v_already_full;
|
||||||
} c_decode[1];
|
} c_decode[1];
|
||||||
struct {
|
struct {
|
||||||
@@ -193,7 +193,7 @@ typedef struct {
|
|||||||
struct {
|
struct {
|
||||||
uint32_t coro_susp_point;
|
uint32_t coro_susp_point;
|
||||||
uint32_t v_length;
|
uint32_t v_length;
|
||||||
uint32_t v_n;
|
uint32_t v_n_copied;
|
||||||
uint64_t scratch;
|
uint64_t scratch;
|
||||||
} c_decode_uncompressed[1];
|
} c_decode_uncompressed[1];
|
||||||
struct {
|
struct {
|
||||||
@@ -208,7 +208,7 @@ typedef struct {
|
|||||||
uint32_t v_redir_mask;
|
uint32_t v_redir_mask;
|
||||||
uint32_t v_length;
|
uint32_t v_length;
|
||||||
uint32_t v_distance;
|
uint32_t v_distance;
|
||||||
uint32_t v_n;
|
uint32_t v_n_copied;
|
||||||
uint32_t v_hlen;
|
uint32_t v_hlen;
|
||||||
uint32_t v_hdist;
|
uint32_t v_hdist;
|
||||||
} c_decode_huffman[1];
|
} c_decode_huffman[1];
|
||||||
@@ -743,7 +743,7 @@ puffs_flate_status puffs_flate_decoder_decode(puffs_flate_decoder* self,
|
|||||||
|
|
||||||
puffs_flate_status v_z;
|
puffs_flate_status v_z;
|
||||||
puffs_base_slice_u8 v_written;
|
puffs_base_slice_u8 v_written;
|
||||||
uint64_t v_n;
|
uint64_t v_n_copied;
|
||||||
uint32_t v_already_full;
|
uint32_t v_already_full;
|
||||||
|
|
||||||
uint8_t* b_wptr_dst = NULL;
|
uint8_t* b_wptr_dst = NULL;
|
||||||
@@ -769,7 +769,7 @@ puffs_flate_status puffs_flate_decoder_decode(puffs_flate_decoder* self,
|
|||||||
if (coro_susp_point) {
|
if (coro_susp_point) {
|
||||||
v_z = self->private_impl.c_decode[0].v_z;
|
v_z = self->private_impl.c_decode[0].v_z;
|
||||||
v_written = ((puffs_base_slice_u8){});
|
v_written = ((puffs_base_slice_u8){});
|
||||||
v_n = self->private_impl.c_decode[0].v_n;
|
v_n_copied = self->private_impl.c_decode[0].v_n_copied;
|
||||||
v_already_full = self->private_impl.c_decode[0].v_already_full;
|
v_already_full = self->private_impl.c_decode[0].v_already_full;
|
||||||
}
|
}
|
||||||
switch (coro_susp_point) {
|
switch (coro_susp_point) {
|
||||||
@@ -820,20 +820,20 @@ puffs_flate_status puffs_flate_decoder_decode(puffs_flate_decoder* self,
|
|||||||
v_written);
|
v_written);
|
||||||
self->private_impl.f_history_index = 32768;
|
self->private_impl.f_history_index = 32768;
|
||||||
} else {
|
} else {
|
||||||
v_n = puffs_base_slice_u8_copy_from_slice(
|
v_n_copied = puffs_base_slice_u8_copy_from_slice(
|
||||||
puffs_base_slice_u8_subslice_i(
|
puffs_base_slice_u8_subslice_i(
|
||||||
((puffs_base_slice_u8){.ptr = self->private_impl.f_history,
|
((puffs_base_slice_u8){.ptr = self->private_impl.f_history,
|
||||||
.len = 32768}),
|
.len = 32768}),
|
||||||
self->private_impl.f_history_index & 32767),
|
self->private_impl.f_history_index & 32767),
|
||||||
v_written);
|
v_written);
|
||||||
if (v_n < ((uint64_t)(v_written.len))) {
|
if (v_n_copied < ((uint64_t)(v_written.len))) {
|
||||||
v_written = puffs_base_slice_u8_subslice_i(v_written, v_n);
|
v_written = puffs_base_slice_u8_subslice_i(v_written, v_n_copied);
|
||||||
v_n = puffs_base_slice_u8_copy_from_slice(
|
v_n_copied = puffs_base_slice_u8_copy_from_slice(
|
||||||
((puffs_base_slice_u8){.ptr = self->private_impl.f_history,
|
((puffs_base_slice_u8){.ptr = self->private_impl.f_history,
|
||||||
.len = 32768}),
|
.len = 32768}),
|
||||||
v_written);
|
v_written);
|
||||||
self->private_impl.f_history_index =
|
self->private_impl.f_history_index =
|
||||||
(((uint32_t)((v_n & 32767))) + 32768);
|
(((uint32_t)((v_n_copied & 32767))) + 32768);
|
||||||
} else {
|
} else {
|
||||||
v_already_full = 0;
|
v_already_full = 0;
|
||||||
if (self->private_impl.f_history_index >= 32768) {
|
if (self->private_impl.f_history_index >= 32768) {
|
||||||
@@ -841,7 +841,7 @@ puffs_flate_status puffs_flate_decoder_decode(puffs_flate_decoder* self,
|
|||||||
}
|
}
|
||||||
self->private_impl.f_history_index =
|
self->private_impl.f_history_index =
|
||||||
((self->private_impl.f_history_index & 32767) +
|
((self->private_impl.f_history_index & 32767) +
|
||||||
((uint32_t)((v_n & 32767))) + v_already_full);
|
((uint32_t)((v_n_copied & 32767))) + v_already_full);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
status = v_z;
|
status = v_z;
|
||||||
@@ -858,7 +858,7 @@ puffs_flate_status puffs_flate_decoder_decode(puffs_flate_decoder* self,
|
|||||||
suspend:
|
suspend:
|
||||||
self->private_impl.c_decode[0].coro_susp_point = coro_susp_point;
|
self->private_impl.c_decode[0].coro_susp_point = coro_susp_point;
|
||||||
self->private_impl.c_decode[0].v_z = v_z;
|
self->private_impl.c_decode[0].v_z = v_z;
|
||||||
self->private_impl.c_decode[0].v_n = v_n;
|
self->private_impl.c_decode[0].v_n_copied = v_n_copied;
|
||||||
self->private_impl.c_decode[0].v_already_full = v_already_full;
|
self->private_impl.c_decode[0].v_already_full = v_already_full;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
@@ -1066,7 +1066,7 @@ puffs_flate_status puffs_flate_decoder_decode_uncompressed(
|
|||||||
puffs_flate_status status = PUFFS_FLATE_STATUS_OK;
|
puffs_flate_status status = PUFFS_FLATE_STATUS_OK;
|
||||||
|
|
||||||
uint32_t v_length;
|
uint32_t v_length;
|
||||||
uint32_t v_n;
|
uint32_t v_n_copied;
|
||||||
|
|
||||||
uint8_t* b_wptr_dst = NULL;
|
uint8_t* b_wptr_dst = NULL;
|
||||||
uint8_t* b_wstart_dst = NULL;
|
uint8_t* b_wstart_dst = NULL;
|
||||||
@@ -1106,7 +1106,7 @@ puffs_flate_status puffs_flate_decoder_decode_uncompressed(
|
|||||||
self->private_impl.c_decode_uncompressed[0].coro_susp_point;
|
self->private_impl.c_decode_uncompressed[0].coro_susp_point;
|
||||||
if (coro_susp_point) {
|
if (coro_susp_point) {
|
||||||
v_length = self->private_impl.c_decode_uncompressed[0].v_length;
|
v_length = self->private_impl.c_decode_uncompressed[0].v_length;
|
||||||
v_n = self->private_impl.c_decode_uncompressed[0].v_n;
|
v_n_copied = self->private_impl.c_decode_uncompressed[0].v_n_copied;
|
||||||
}
|
}
|
||||||
switch (coro_susp_point) {
|
switch (coro_susp_point) {
|
||||||
PUFFS_COROUTINE_SUSPENSION_POINT(0);
|
PUFFS_COROUTINE_SUSPENSION_POINT(0);
|
||||||
@@ -1151,13 +1151,13 @@ puffs_flate_status puffs_flate_decoder_decode_uncompressed(
|
|||||||
}
|
}
|
||||||
v_length = ((v_length) & ((1 << (16)) - 1));
|
v_length = ((v_length) & ((1 << (16)) - 1));
|
||||||
while (true) {
|
while (true) {
|
||||||
v_n = puffs_base_writer1_copy_from_reader32(
|
v_n_copied = puffs_base_writer1_copy_from_reader32(
|
||||||
&b_wptr_dst, b_wend_dst, &b_rptr_src, b_rend_src, v_length);
|
&b_wptr_dst, b_wend_dst, &b_rptr_src, b_rend_src, v_length);
|
||||||
if (v_length <= v_n) {
|
if (v_length <= v_n_copied) {
|
||||||
v_length = 0;
|
v_length = 0;
|
||||||
goto label_0_break;
|
goto label_0_break;
|
||||||
}
|
}
|
||||||
v_length -= v_n;
|
v_length -= v_n_copied;
|
||||||
if (((uint64_t)(b_wend_dst - b_wptr_dst)) == 0) {
|
if (((uint64_t)(b_wend_dst - b_wptr_dst)) == 0) {
|
||||||
status = PUFFS_FLATE_SUSPENSION_SHORT_WRITE;
|
status = PUFFS_FLATE_SUSPENSION_SHORT_WRITE;
|
||||||
PUFFS_COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
PUFFS_COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
||||||
@@ -1178,7 +1178,7 @@ puffs_flate_status puffs_flate_decoder_decode_uncompressed(
|
|||||||
suspend:
|
suspend:
|
||||||
self->private_impl.c_decode_uncompressed[0].coro_susp_point = coro_susp_point;
|
self->private_impl.c_decode_uncompressed[0].coro_susp_point = coro_susp_point;
|
||||||
self->private_impl.c_decode_uncompressed[0].v_length = v_length;
|
self->private_impl.c_decode_uncompressed[0].v_length = v_length;
|
||||||
self->private_impl.c_decode_uncompressed[0].v_n = v_n;
|
self->private_impl.c_decode_uncompressed[0].v_n_copied = v_n_copied;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
if (a_dst.buf) {
|
if (a_dst.buf) {
|
||||||
@@ -1233,7 +1233,7 @@ puffs_flate_status puffs_flate_decoder_decode_huffman(
|
|||||||
uint32_t v_redir_mask;
|
uint32_t v_redir_mask;
|
||||||
uint32_t v_length;
|
uint32_t v_length;
|
||||||
uint32_t v_distance;
|
uint32_t v_distance;
|
||||||
uint32_t v_n;
|
uint32_t v_n_copied;
|
||||||
uint32_t v_hlen;
|
uint32_t v_hlen;
|
||||||
uint32_t v_hdist;
|
uint32_t v_hdist;
|
||||||
|
|
||||||
@@ -1285,7 +1285,7 @@ puffs_flate_status puffs_flate_decoder_decode_huffman(
|
|||||||
v_redir_mask = self->private_impl.c_decode_huffman[0].v_redir_mask;
|
v_redir_mask = self->private_impl.c_decode_huffman[0].v_redir_mask;
|
||||||
v_length = self->private_impl.c_decode_huffman[0].v_length;
|
v_length = self->private_impl.c_decode_huffman[0].v_length;
|
||||||
v_distance = self->private_impl.c_decode_huffman[0].v_distance;
|
v_distance = self->private_impl.c_decode_huffman[0].v_distance;
|
||||||
v_n = self->private_impl.c_decode_huffman[0].v_n;
|
v_n_copied = self->private_impl.c_decode_huffman[0].v_n_copied;
|
||||||
v_hlen = self->private_impl.c_decode_huffman[0].v_hlen;
|
v_hlen = self->private_impl.c_decode_huffman[0].v_hlen;
|
||||||
v_hdist = self->private_impl.c_decode_huffman[0].v_hdist;
|
v_hdist = self->private_impl.c_decode_huffman[0].v_hdist;
|
||||||
}
|
}
|
||||||
@@ -1460,9 +1460,9 @@ puffs_flate_status puffs_flate_decoder_decode_huffman(
|
|||||||
32767);
|
32767);
|
||||||
v_bits >>= v_table_entry_n_bits;
|
v_bits >>= v_table_entry_n_bits;
|
||||||
v_n_bits -= v_table_entry_n_bits;
|
v_n_bits -= v_table_entry_n_bits;
|
||||||
|
v_n_copied = 0;
|
||||||
label_5_continue:;
|
label_5_continue:;
|
||||||
while (true) {
|
while (true) {
|
||||||
v_n = 0;
|
|
||||||
if (((uint64_t)(v_distance)) >
|
if (((uint64_t)(v_distance)) >
|
||||||
((uint64_t)(b_wptr_dst - b_wstart_dst))) {
|
((uint64_t)(b_wptr_dst - b_wstart_dst))) {
|
||||||
v_hlen = 0;
|
v_hlen = 0;
|
||||||
@@ -1481,20 +1481,20 @@ puffs_flate_status puffs_flate_decoder_decode_huffman(
|
|||||||
}
|
}
|
||||||
v_hdist = ((self->private_impl.f_history_index - v_hdist) & 32767);
|
v_hdist = ((self->private_impl.f_history_index - v_hdist) & 32767);
|
||||||
while (true) {
|
while (true) {
|
||||||
v_n = puffs_base_writer1_copy_from_slice32(
|
v_n_copied = puffs_base_writer1_copy_from_slice32(
|
||||||
&b_wptr_dst, b_wend_dst,
|
&b_wptr_dst, b_wend_dst,
|
||||||
puffs_base_slice_u8_subslice_i(
|
puffs_base_slice_u8_subslice_i(
|
||||||
((puffs_base_slice_u8){.ptr = self->private_impl.f_history,
|
((puffs_base_slice_u8){.ptr = self->private_impl.f_history,
|
||||||
.len = 32768}),
|
.len = 32768}),
|
||||||
v_hdist),
|
v_hdist),
|
||||||
v_hlen);
|
v_hlen);
|
||||||
if (v_hlen <= v_n) {
|
if (v_hlen <= v_n_copied) {
|
||||||
v_hlen = 0;
|
v_hlen = 0;
|
||||||
goto label_6_break;
|
goto label_6_break;
|
||||||
}
|
}
|
||||||
if (v_n > 0) {
|
if (v_n_copied > 0) {
|
||||||
v_hlen -= v_n;
|
v_hlen -= v_n_copied;
|
||||||
v_hdist = ((v_hdist + (v_n & 32767)) & 32767);
|
v_hdist = ((v_hdist + (v_n_copied & 32767)) & 32767);
|
||||||
if (v_hdist == 0) {
|
if (v_hdist == 0) {
|
||||||
goto label_6_break;
|
goto label_6_break;
|
||||||
}
|
}
|
||||||
@@ -1505,19 +1505,19 @@ puffs_flate_status puffs_flate_decoder_decode_huffman(
|
|||||||
label_6_break:;
|
label_6_break:;
|
||||||
if (v_hlen > 0) {
|
if (v_hlen > 0) {
|
||||||
while (true) {
|
while (true) {
|
||||||
v_n = puffs_base_writer1_copy_from_slice32(
|
v_n_copied = puffs_base_writer1_copy_from_slice32(
|
||||||
&b_wptr_dst, b_wend_dst,
|
&b_wptr_dst, b_wend_dst,
|
||||||
puffs_base_slice_u8_subslice_i(
|
puffs_base_slice_u8_subslice_i(
|
||||||
((puffs_base_slice_u8){
|
((puffs_base_slice_u8){
|
||||||
.ptr = self->private_impl.f_history, .len = 32768}),
|
.ptr = self->private_impl.f_history, .len = 32768}),
|
||||||
v_hdist),
|
v_hdist),
|
||||||
v_hlen);
|
v_hlen);
|
||||||
if (v_hlen <= v_n) {
|
if (v_hlen <= v_n_copied) {
|
||||||
v_hlen = 0;
|
v_hlen = 0;
|
||||||
goto label_7_break;
|
goto label_7_break;
|
||||||
}
|
}
|
||||||
v_hlen -= v_n;
|
v_hlen -= v_n_copied;
|
||||||
v_hdist = ((v_hdist + (v_n & 32767)) & 32767);
|
v_hdist = ((v_hdist + (v_n_copied & 32767)) & 32767);
|
||||||
status = PUFFS_FLATE_SUSPENSION_SHORT_WRITE;
|
status = PUFFS_FLATE_SUSPENSION_SHORT_WRITE;
|
||||||
PUFFS_COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(9);
|
PUFFS_COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(9);
|
||||||
}
|
}
|
||||||
@@ -1527,13 +1527,13 @@ puffs_flate_status puffs_flate_decoder_decode_huffman(
|
|||||||
goto label_5_continue;
|
goto label_5_continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
v_n = puffs_base_writer1_copy_from_history32(
|
v_n_copied = puffs_base_writer1_copy_from_history32(
|
||||||
&b_wptr_dst, b_wstart_dst, b_wend_dst, v_distance, v_length);
|
&b_wptr_dst, b_wstart_dst, b_wend_dst, v_distance, v_length);
|
||||||
if (v_length <= v_n) {
|
if (v_length <= v_n_copied) {
|
||||||
v_length = 0;
|
v_length = 0;
|
||||||
goto label_5_break;
|
goto label_5_break;
|
||||||
}
|
}
|
||||||
v_length -= v_n;
|
v_length -= v_n_copied;
|
||||||
status = PUFFS_FLATE_SUSPENSION_SHORT_WRITE;
|
status = PUFFS_FLATE_SUSPENSION_SHORT_WRITE;
|
||||||
PUFFS_COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(10);
|
PUFFS_COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(10);
|
||||||
}
|
}
|
||||||
@@ -1563,7 +1563,7 @@ suspend:
|
|||||||
self->private_impl.c_decode_huffman[0].v_redir_mask = v_redir_mask;
|
self->private_impl.c_decode_huffman[0].v_redir_mask = v_redir_mask;
|
||||||
self->private_impl.c_decode_huffman[0].v_length = v_length;
|
self->private_impl.c_decode_huffman[0].v_length = v_length;
|
||||||
self->private_impl.c_decode_huffman[0].v_distance = v_distance;
|
self->private_impl.c_decode_huffman[0].v_distance = v_distance;
|
||||||
self->private_impl.c_decode_huffman[0].v_n = v_n;
|
self->private_impl.c_decode_huffman[0].v_n_copied = v_n_copied;
|
||||||
self->private_impl.c_decode_huffman[0].v_hlen = v_hlen;
|
self->private_impl.c_decode_huffman[0].v_hlen = v_hlen;
|
||||||
self->private_impl.c_decode_huffman[0].v_hdist = v_hdist;
|
self->private_impl.c_decode_huffman[0].v_hdist = v_hdist;
|
||||||
|
|
||||||
|
|||||||
+8
-8
@@ -165,7 +165,7 @@ typedef struct {
|
|||||||
uint32_t v_code;
|
uint32_t v_code;
|
||||||
uint32_t v_s;
|
uint32_t v_s;
|
||||||
uint32_t v_c;
|
uint32_t v_c;
|
||||||
uint64_t v_n;
|
uint64_t v_n_copied;
|
||||||
} c_decode[1];
|
} c_decode[1];
|
||||||
} private_impl;
|
} private_impl;
|
||||||
} puffs_gif_lzw_decoder;
|
} puffs_gif_lzw_decoder;
|
||||||
@@ -1338,7 +1338,7 @@ puffs_gif_status puffs_gif_lzw_decoder_decode(puffs_gif_lzw_decoder* self,
|
|||||||
uint32_t v_s;
|
uint32_t v_s;
|
||||||
uint32_t v_c;
|
uint32_t v_c;
|
||||||
puffs_base_slice_u8 v_expansion;
|
puffs_base_slice_u8 v_expansion;
|
||||||
uint64_t v_n;
|
uint64_t v_n_copied;
|
||||||
|
|
||||||
uint8_t* b_wptr_dst = NULL;
|
uint8_t* b_wptr_dst = NULL;
|
||||||
uint8_t* b_wstart_dst = NULL;
|
uint8_t* b_wstart_dst = NULL;
|
||||||
@@ -1387,7 +1387,7 @@ puffs_gif_status puffs_gif_lzw_decoder_decode(puffs_gif_lzw_decoder* self,
|
|||||||
v_s = self->private_impl.c_decode[0].v_s;
|
v_s = self->private_impl.c_decode[0].v_s;
|
||||||
v_c = self->private_impl.c_decode[0].v_c;
|
v_c = self->private_impl.c_decode[0].v_c;
|
||||||
v_expansion = ((puffs_base_slice_u8){});
|
v_expansion = ((puffs_base_slice_u8){});
|
||||||
v_n = self->private_impl.c_decode[0].v_n;
|
v_n_copied = self->private_impl.c_decode[0].v_n_copied;
|
||||||
}
|
}
|
||||||
switch (coro_susp_point) {
|
switch (coro_susp_point) {
|
||||||
PUFFS_COROUTINE_SUSPENSION_POINT(0);
|
PUFFS_COROUTINE_SUSPENSION_POINT(0);
|
||||||
@@ -1458,12 +1458,12 @@ puffs_gif_status puffs_gif_lzw_decoder_decode(puffs_gif_lzw_decoder* self,
|
|||||||
((puffs_base_slice_u8){.ptr = self->private_impl.f_stack,
|
((puffs_base_slice_u8){.ptr = self->private_impl.f_stack,
|
||||||
.len = 4096}),
|
.len = 4096}),
|
||||||
v_s);
|
v_s);
|
||||||
v_n = puffs_base_writer1_copy_from_slice(&b_wptr_dst, b_wend_dst,
|
v_n_copied = puffs_base_writer1_copy_from_slice(
|
||||||
v_expansion);
|
&b_wptr_dst, b_wend_dst, v_expansion);
|
||||||
if (v_n == ((uint64_t)(v_expansion.len))) {
|
if (v_n_copied == ((uint64_t)(v_expansion.len))) {
|
||||||
goto label_1_break;
|
goto label_1_break;
|
||||||
}
|
}
|
||||||
v_s = ((v_s + ((uint32_t)((v_n & 4095)))) & 4095);
|
v_s = ((v_s + ((uint32_t)((v_n_copied & 4095)))) & 4095);
|
||||||
status = PUFFS_GIF_SUSPENSION_SHORT_WRITE;
|
status = PUFFS_GIF_SUSPENSION_SHORT_WRITE;
|
||||||
PUFFS_COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
PUFFS_COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
||||||
}
|
}
|
||||||
@@ -1505,7 +1505,7 @@ suspend:
|
|||||||
self->private_impl.c_decode[0].v_code = v_code;
|
self->private_impl.c_decode[0].v_code = v_code;
|
||||||
self->private_impl.c_decode[0].v_s = v_s;
|
self->private_impl.c_decode[0].v_s = v_s;
|
||||||
self->private_impl.c_decode[0].v_c = v_c;
|
self->private_impl.c_decode[0].v_c = v_c;
|
||||||
self->private_impl.c_decode[0].v_n = v_n;
|
self->private_impl.c_decode[0].v_n_copied = v_n_copied;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
if (a_dst.buf) {
|
if (a_dst.buf) {
|
||||||
|
|||||||
+3
-3
@@ -182,7 +182,7 @@ typedef struct {
|
|||||||
struct {
|
struct {
|
||||||
uint32_t coro_susp_point;
|
uint32_t coro_susp_point;
|
||||||
puffs_flate_status v_z;
|
puffs_flate_status v_z;
|
||||||
uint64_t v_n;
|
uint64_t v_n_copied;
|
||||||
uint32_t v_already_full;
|
uint32_t v_already_full;
|
||||||
} c_decode[1];
|
} c_decode[1];
|
||||||
struct {
|
struct {
|
||||||
@@ -193,7 +193,7 @@ typedef struct {
|
|||||||
struct {
|
struct {
|
||||||
uint32_t coro_susp_point;
|
uint32_t coro_susp_point;
|
||||||
uint32_t v_length;
|
uint32_t v_length;
|
||||||
uint32_t v_n;
|
uint32_t v_n_copied;
|
||||||
uint64_t scratch;
|
uint64_t scratch;
|
||||||
} c_decode_uncompressed[1];
|
} c_decode_uncompressed[1];
|
||||||
struct {
|
struct {
|
||||||
@@ -208,7 +208,7 @@ typedef struct {
|
|||||||
uint32_t v_redir_mask;
|
uint32_t v_redir_mask;
|
||||||
uint32_t v_length;
|
uint32_t v_length;
|
||||||
uint32_t v_distance;
|
uint32_t v_distance;
|
||||||
uint32_t v_n;
|
uint32_t v_n_copied;
|
||||||
uint32_t v_hlen;
|
uint32_t v_hlen;
|
||||||
uint32_t v_hdist;
|
uint32_t v_hdist;
|
||||||
} c_decode_huffman[1];
|
} c_decode_huffman[1];
|
||||||
|
|||||||
+1
-1
@@ -165,7 +165,7 @@ typedef struct {
|
|||||||
uint32_t v_code;
|
uint32_t v_code;
|
||||||
uint32_t v_s;
|
uint32_t v_s;
|
||||||
uint32_t v_c;
|
uint32_t v_c;
|
||||||
uint64_t v_n;
|
uint64_t v_n_copied;
|
||||||
} c_decode[1];
|
} c_decode[1];
|
||||||
} private_impl;
|
} private_impl;
|
||||||
} puffs_gif_lzw_decoder;
|
} puffs_gif_lzw_decoder;
|
||||||
|
|||||||
@@ -137,8 +137,8 @@ pub func decoder.decode?(dst writer1, src reader1)() {
|
|||||||
} else {
|
} else {
|
||||||
// Otherwise, append written to the history ringbuffer starting at
|
// Otherwise, append written to the history ringbuffer starting at
|
||||||
// the previous history_index (modulo 0x8000).
|
// the previous history_index (modulo 0x8000).
|
||||||
var n u64 = this.history[this.history_index & 0x7FFF:].copy_from_slice(s:written)
|
var n_copied u64 = this.history[this.history_index & 0x7FFF:].copy_from_slice(s:written)
|
||||||
if n < written.length() {
|
if n_copied < written.length() {
|
||||||
// a_slice.copy_from(s:b_slice) returns the minimum of the two
|
// a_slice.copy_from(s:b_slice) returns the minimum of the two
|
||||||
// slice lengths. If that value is less than b_slice.length(),
|
// slice lengths. If that value is less than b_slice.length(),
|
||||||
// then not all of b_slice was copied.
|
// then not all of b_slice was copied.
|
||||||
@@ -146,21 +146,21 @@ pub func decoder.decode?(dst writer1, src reader1)() {
|
|||||||
// In terms of the history ringbuffer, that means that we have
|
// In terms of the history ringbuffer, that means that we have
|
||||||
// to wrap around and copy the remainder of written over the
|
// to wrap around and copy the remainder of written over the
|
||||||
// start of the history ringbuffer.
|
// start of the history ringbuffer.
|
||||||
written = written[n:]
|
written = written[n_copied:]
|
||||||
n = this.history[:].copy_from_slice(s:written)
|
n_copied = this.history[:].copy_from_slice(s:written)
|
||||||
// Set history_index (modulo 0x8000) to the length of this
|
// Set history_index (modulo 0x8000) to the length of this
|
||||||
// remainder. The &0x7FFF is redundant, but proves to the
|
// remainder. The &0x7FFF is redundant, but proves to the
|
||||||
// compiler that the conversion to u32 will not overflow. The
|
// compiler that the conversion to u32 will not overflow. The
|
||||||
// +0x8000 is to maintain that the history ringbuffer is full
|
// +0x8000 is to maintain that the history ringbuffer is full
|
||||||
// if and only if history_index >= 0x8000.
|
// if and only if history_index >= 0x8000.
|
||||||
this.history_index = ((n & 0x7FFF) as u32) + 0x8000
|
this.history_index = ((n_copied & 0x7FFF) as u32) + 0x8000
|
||||||
} else {
|
} else {
|
||||||
// We didn't need to wrap around.
|
// We didn't need to wrap around.
|
||||||
var already_full u32[..0x8000]
|
var already_full u32[..0x8000]
|
||||||
if this.history_index >= 0x8000 {
|
if this.history_index >= 0x8000 {
|
||||||
already_full = 0x8000
|
already_full = 0x8000
|
||||||
}
|
}
|
||||||
this.history_index = (this.history_index & 0x7FFF) + ((n & 0x7FFF) as u32) + already_full
|
this.history_index = (this.history_index & 0x7FFF) + ((n_copied & 0x7FFF) as u32) + already_full
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return z
|
return z
|
||||||
@@ -209,12 +209,12 @@ pri func decoder.decode_uncompressed?(dst writer1, src reader1)() {
|
|||||||
}
|
}
|
||||||
length = length.low_bits(n:16)
|
length = length.low_bits(n:16)
|
||||||
while true {
|
while true {
|
||||||
var n u32 = in.dst.copy_from_reader32(r:in.src, length:length)
|
var n_copied u32 = in.dst.copy_from_reader32(r:in.src, length:length)
|
||||||
if length <= n {
|
if length <= n_copied {
|
||||||
length = 0
|
length = 0
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
length -= n
|
length -= n_copied
|
||||||
if in.dst.available() == 0 {
|
if in.dst.available() == 0 {
|
||||||
// TODO: "closed for writes" instead?
|
// TODO: "closed for writes" instead?
|
||||||
return suspension "short write"
|
return suspension "short write"
|
||||||
@@ -358,9 +358,8 @@ pri func decoder.decode_huffman?(dst writer1, src reader1)() {
|
|||||||
bits >>= table_entry_n_bits
|
bits >>= table_entry_n_bits
|
||||||
n_bits -= table_entry_n_bits
|
n_bits -= table_entry_n_bits
|
||||||
|
|
||||||
|
var n_copied u32
|
||||||
while true {
|
while true {
|
||||||
var n u32
|
|
||||||
|
|
||||||
// Copy from this.history.
|
// Copy from this.history.
|
||||||
if (distance as u64) > in.dst.length() {
|
if (distance as u64) > in.dst.length() {
|
||||||
// Set (hlen, hdist) to be the length-distance pair to copy
|
// Set (hlen, hdist) to be the length-distance pair to copy
|
||||||
@@ -384,15 +383,15 @@ pri func decoder.decode_huffman?(dst writer1, src reader1)() {
|
|||||||
|
|
||||||
// Copy from hdist to the end of this.history.
|
// Copy from hdist to the end of this.history.
|
||||||
while true {
|
while true {
|
||||||
n = in.dst.copy_from_slice32(s:this.history[hdist:], length:hlen)
|
n_copied = in.dst.copy_from_slice32(s:this.history[hdist:], length:hlen)
|
||||||
if hlen <= n {
|
if hlen <= n_copied {
|
||||||
hlen = 0
|
hlen = 0
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if n > 0 {
|
if n_copied > 0 {
|
||||||
hlen -= n
|
hlen -= n_copied
|
||||||
// TODO: a "~+" tilde-operator that ignores overflow.
|
// TODO: a "~+" tilde-operator that ignores overflow.
|
||||||
hdist = (hdist + (n & 0x7FFF)) & 0x7FFF
|
hdist = (hdist + (n_copied & 0x7FFF)) & 0x7FFF
|
||||||
if hdist == 0 {
|
if hdist == 0 {
|
||||||
// Wrap around the this.history ringbuffer.
|
// Wrap around the this.history ringbuffer.
|
||||||
break
|
break
|
||||||
@@ -410,13 +409,13 @@ pri func decoder.decode_huffman?(dst writer1, src reader1)() {
|
|||||||
// Copy from the start of this.history, if we wrapped around.
|
// Copy from the start of this.history, if we wrapped around.
|
||||||
if hlen > 0 {
|
if hlen > 0 {
|
||||||
while true {
|
while true {
|
||||||
n = in.dst.copy_from_slice32(s:this.history[hdist:], length:hlen)
|
n_copied = in.dst.copy_from_slice32(s:this.history[hdist:], length:hlen)
|
||||||
if hlen <= n {
|
if hlen <= n_copied {
|
||||||
hlen = 0
|
hlen = 0
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
hlen -= n
|
hlen -= n_copied
|
||||||
hdist = (hdist + (n & 0x7FFF)) & 0x7FFF
|
hdist = (hdist + (n_copied & 0x7FFF)) & 0x7FFF
|
||||||
// TODO: "closed for writes" instead?
|
// TODO: "closed for writes" instead?
|
||||||
return suspension "short write"
|
return suspension "short write"
|
||||||
}
|
}
|
||||||
@@ -429,12 +428,12 @@ pri func decoder.decode_huffman?(dst writer1, src reader1)() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy from in.dst.
|
// Copy from in.dst.
|
||||||
n = in.dst.copy_from_history32(distance:distance, length:length)
|
n_copied = in.dst.copy_from_history32(distance:distance, length:length)
|
||||||
if length <= n {
|
if length <= n_copied {
|
||||||
length = 0
|
length = 0
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
length -= n
|
length -= n_copied
|
||||||
// TODO: "closed for writes" instead?
|
// TODO: "closed for writes" instead?
|
||||||
return suspension "short write"
|
return suspension "short write"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,11 +111,11 @@ pub func lzw_decoder.decode?(dst writer1, src reader1)() {
|
|||||||
{
|
{
|
||||||
var expansion[] u8 = this.stack[s:]
|
var expansion[] u8 = this.stack[s:]
|
||||||
// TODO: "x:" instead of "s:" should be a compiler error.
|
// TODO: "x:" instead of "s:" should be a compiler error.
|
||||||
var n u64 = in.dst.copy_from_slice(x:expansion)
|
var n_copied u64 = in.dst.copy_from_slice(x:expansion)
|
||||||
if n == expansion.length() {
|
if n_copied == expansion.length() {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
s = (s + ((n & 4095) as u32)) & 4095
|
s = (s + ((n_copied & 4095) as u32)) & 4095
|
||||||
// TODO: "closed for writes" instead?
|
// TODO: "closed for writes" instead?
|
||||||
return suspension "short write"
|
return suspension "short write"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user