mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Prepare to call decode_huffman_fast more often
This commit is contained in:
1 parent
1af543866c
commit
2fd03f42b5
2 files changed
+51
-46
No files matched your search
@@ -5552,42 +5552,45 @@ wuffs_deflate__decoder__decode_blocks(wuffs_deflate__decoder* self,
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_end_of_block = false;
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
}
|
||||
v_status =
|
||||
wuffs_deflate__decoder__decode_huffman_fast(self, a_dst, a_src);
|
||||
if (a_src.private_impl.buf) {
|
||||
iop_a_src =
|
||||
a_src.private_impl.buf->data.ptr + a_src.private_impl.buf->meta.ri;
|
||||
}
|
||||
if (wuffs_base__status__is_error(v_status)) {
|
||||
status = v_status;
|
||||
while (true) {
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
}
|
||||
v_status =
|
||||
wuffs_deflate__decoder__decode_huffman_fast(self, a_dst, a_src);
|
||||
if (a_src.private_impl.buf) {
|
||||
iop_a_src = a_src.private_impl.buf->data.ptr +
|
||||
a_src.private_impl.buf->meta.ri;
|
||||
}
|
||||
if (wuffs_base__status__is_error(v_status)) {
|
||||
status = v_status;
|
||||
goto exit;
|
||||
}
|
||||
if (self->private_impl.f_end_of_block) {
|
||||
goto label_0_continue;
|
||||
}
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
status =
|
||||
wuffs_deflate__decoder__decode_huffman_slow(self, a_dst, a_src);
|
||||
if (a_src.private_impl.buf) {
|
||||
iop_a_src = a_src.private_impl.buf->data.ptr +
|
||||
a_src.private_impl.buf->meta.ri;
|
||||
}
|
||||
if (status) {
|
||||
goto suspend;
|
||||
}
|
||||
if (self->private_impl.f_end_of_block) {
|
||||
goto label_0_continue;
|
||||
}
|
||||
status =
|
||||
wuffs_deflate__error__internal_error_inconsistent_huffman_end_of_block;
|
||||
goto exit;
|
||||
}
|
||||
if (self->private_impl.f_end_of_block) {
|
||||
goto label_0_continue;
|
||||
}
|
||||
if (a_src.private_impl.buf) {
|
||||
a_src.private_impl.buf->meta.ri =
|
||||
iop_a_src - a_src.private_impl.buf->data.ptr;
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
status = wuffs_deflate__decoder__decode_huffman_slow(self, a_dst, a_src);
|
||||
if (a_src.private_impl.buf) {
|
||||
iop_a_src =
|
||||
a_src.private_impl.buf->data.ptr + a_src.private_impl.buf->meta.ri;
|
||||
}
|
||||
if (status) {
|
||||
goto suspend;
|
||||
}
|
||||
if (self->private_impl.f_end_of_block) {
|
||||
goto label_0_continue;
|
||||
}
|
||||
status =
|
||||
wuffs_deflate__error__internal_error_inconsistent_huffman_end_of_block;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto ok;
|
||||
|
||||
@@ -184,7 +184,7 @@ pri func decoder.decode_blocks?(dst base.io_writer, src base.io_reader) {
|
||||
var type base.u32
|
||||
var status base.status
|
||||
|
||||
while final == 0 {
|
||||
while:outer final == 0 {
|
||||
while this.n_bits < 3,
|
||||
post this.n_bits >= 3,
|
||||
{
|
||||
@@ -218,18 +218,20 @@ pri func decoder.decode_blocks?(dst base.io_writer, src base.io_reader) {
|
||||
}
|
||||
|
||||
this.end_of_block = false
|
||||
status = this.decode_huffman_fast!(dst:args.dst, src:args.src)
|
||||
if status.is_error() {
|
||||
return status
|
||||
while true {
|
||||
status = this.decode_huffman_fast!(dst:args.dst, src:args.src)
|
||||
if status.is_error() {
|
||||
return status
|
||||
}
|
||||
if this.end_of_block {
|
||||
continue:outer
|
||||
}
|
||||
this.decode_huffman_slow?(dst:args.dst, src:args.src)
|
||||
if this.end_of_block {
|
||||
continue:outer
|
||||
}
|
||||
return "?internal error: inconsistent Huffman end_of_block"
|
||||
}
|
||||
if this.end_of_block {
|
||||
continue
|
||||
}
|
||||
this.decode_huffman_slow?(dst:args.dst, src:args.src)
|
||||
if this.end_of_block {
|
||||
continue
|
||||
}
|
||||
return "?internal error: inconsistent Huffman end_of_block"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user