mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
Drop the "flate_" in "deflate.flate_decoder"
This commit is contained in:
1 parent
2755a61ae9
commit
8e2255916e
11 files changed
+126
-142
No files matched your search
@@ -647,7 +647,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
|||||||
// package.
|
// package.
|
||||||
//
|
//
|
||||||
// TODO: don't hard-code a_dst or a_src.
|
// TODO: don't hard-code a_dst or a_src.
|
||||||
b.printf("%sstatus %s%d = wuffs_deflate__flate_decoder__decode("+
|
b.printf("%sstatus %s%d = wuffs_deflate__decoder__decode("+
|
||||||
"&self->private_impl.f_flate, %sdst, %ssrc);\n",
|
"&self->private_impl.f_flate, %sdst, %ssrc);\n",
|
||||||
g.pkgPrefix, tPrefix, temp,
|
g.pkgPrefix, tPrefix, temp,
|
||||||
aPrefix, aPrefix)
|
aPrefix, aPrefix)
|
||||||
|
|||||||
+55
-61
@@ -181,7 +181,7 @@ const char* wuffs_deflate__status__string(wuffs_deflate__status s);
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||||
// compatibility or safety guarantee if you do so. Instead, use the
|
// compatibility or safety guarantee if you do so. Instead, use the
|
||||||
// wuffs_deflate__flate_decoder__etc functions.
|
// wuffs_deflate__decoder__etc functions.
|
||||||
//
|
//
|
||||||
// In C++, these fields would be "private", but C does not support that.
|
// In C++, these fields would be "private", but C does not support that.
|
||||||
//
|
//
|
||||||
@@ -252,25 +252,23 @@ typedef struct {
|
|||||||
uint32_t v_hdist;
|
uint32_t v_hdist;
|
||||||
} c_decode_huffman_slow[1];
|
} c_decode_huffman_slow[1];
|
||||||
} private_impl;
|
} private_impl;
|
||||||
} wuffs_deflate__flate_decoder;
|
} wuffs_deflate__decoder;
|
||||||
|
|
||||||
// ---------------- Public Initializer Prototypes
|
// ---------------- Public Initializer Prototypes
|
||||||
|
|
||||||
// wuffs_deflate__flate_decoder__initialize is an initializer function.
|
// wuffs_deflate__decoder__initialize is an initializer function.
|
||||||
//
|
//
|
||||||
// It should be called before any other wuffs_deflate__flate_decoder__*
|
// It should be called before any other wuffs_deflate__decoder__* function.
|
||||||
// function.
|
|
||||||
//
|
//
|
||||||
// Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only.
|
// Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only.
|
||||||
void wuffs_deflate__flate_decoder__initialize(
|
void wuffs_deflate__decoder__initialize(wuffs_deflate__decoder* self,
|
||||||
wuffs_deflate__flate_decoder* self,
|
uint32_t wuffs_version,
|
||||||
uint32_t wuffs_version,
|
uint32_t for_internal_use_only);
|
||||||
uint32_t for_internal_use_only);
|
|
||||||
|
|
||||||
// ---------------- Public Function Prototypes
|
// ---------------- Public Function Prototypes
|
||||||
|
|
||||||
wuffs_deflate__status wuffs_deflate__flate_decoder__decode(
|
wuffs_deflate__status wuffs_deflate__decoder__decode(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
wuffs_base__writer1 a_dst,
|
wuffs_base__writer1 a_dst,
|
||||||
wuffs_base__reader1 a_src);
|
wuffs_base__reader1 a_src);
|
||||||
|
|
||||||
@@ -731,46 +729,45 @@ static const uint32_t wuffs_deflate__dcode_magic_numbers[32] = {
|
|||||||
|
|
||||||
// ---------------- Private Function Prototypes
|
// ---------------- Private Function Prototypes
|
||||||
|
|
||||||
static wuffs_deflate__status wuffs_deflate__flate_decoder__decode_blocks(
|
static wuffs_deflate__status wuffs_deflate__decoder__decode_blocks(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
wuffs_base__writer1 a_dst,
|
wuffs_base__writer1 a_dst,
|
||||||
wuffs_base__reader1 a_src);
|
wuffs_base__reader1 a_src);
|
||||||
|
|
||||||
static wuffs_deflate__status wuffs_deflate__flate_decoder__decode_uncompressed(
|
static wuffs_deflate__status wuffs_deflate__decoder__decode_uncompressed(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
wuffs_base__writer1 a_dst,
|
wuffs_base__writer1 a_dst,
|
||||||
wuffs_base__reader1 a_src);
|
wuffs_base__reader1 a_src);
|
||||||
|
|
||||||
static wuffs_deflate__status wuffs_deflate__flate_decoder__init_fixed_huffman(
|
static wuffs_deflate__status wuffs_deflate__decoder__init_fixed_huffman(
|
||||||
wuffs_deflate__flate_decoder* self);
|
wuffs_deflate__decoder* self);
|
||||||
|
|
||||||
static wuffs_deflate__status wuffs_deflate__flate_decoder__init_dynamic_huffman(
|
static wuffs_deflate__status wuffs_deflate__decoder__init_dynamic_huffman(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
wuffs_base__reader1 a_src);
|
wuffs_base__reader1 a_src);
|
||||||
|
|
||||||
static wuffs_deflate__status wuffs_deflate__flate_decoder__init_huff(
|
static wuffs_deflate__status wuffs_deflate__decoder__init_huff(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
uint32_t a_which,
|
uint32_t a_which,
|
||||||
uint32_t a_n_codes0,
|
uint32_t a_n_codes0,
|
||||||
uint32_t a_n_codes1,
|
uint32_t a_n_codes1,
|
||||||
uint32_t a_base_symbol);
|
uint32_t a_base_symbol);
|
||||||
|
|
||||||
static wuffs_deflate__status wuffs_deflate__flate_decoder__decode_huffman_fast(
|
static wuffs_deflate__status wuffs_deflate__decoder__decode_huffman_fast(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
wuffs_base__writer1 a_dst,
|
wuffs_base__writer1 a_dst,
|
||||||
wuffs_base__reader1 a_src);
|
wuffs_base__reader1 a_src);
|
||||||
|
|
||||||
static wuffs_deflate__status wuffs_deflate__flate_decoder__decode_huffman_slow(
|
static wuffs_deflate__status wuffs_deflate__decoder__decode_huffman_slow(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
wuffs_base__writer1 a_dst,
|
wuffs_base__writer1 a_dst,
|
||||||
wuffs_base__reader1 a_src);
|
wuffs_base__reader1 a_src);
|
||||||
|
|
||||||
// ---------------- Initializer Implementations
|
// ---------------- Initializer Implementations
|
||||||
|
|
||||||
void wuffs_deflate__flate_decoder__initialize(
|
void wuffs_deflate__decoder__initialize(wuffs_deflate__decoder* self,
|
||||||
wuffs_deflate__flate_decoder* self,
|
uint32_t wuffs_version,
|
||||||
uint32_t wuffs_version,
|
uint32_t for_internal_use_only) {
|
||||||
uint32_t for_internal_use_only) {
|
|
||||||
if (!self) {
|
if (!self) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -786,8 +783,8 @@ void wuffs_deflate__flate_decoder__initialize(
|
|||||||
|
|
||||||
// ---------------- Function Implementations
|
// ---------------- Function Implementations
|
||||||
|
|
||||||
wuffs_deflate__status wuffs_deflate__flate_decoder__decode(
|
wuffs_deflate__status wuffs_deflate__decoder__decode(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
wuffs_base__writer1 a_dst,
|
wuffs_base__writer1 a_dst,
|
||||||
wuffs_base__reader1 a_src) {
|
wuffs_base__reader1 a_src) {
|
||||||
if (!self) {
|
if (!self) {
|
||||||
@@ -850,7 +847,7 @@ wuffs_deflate__status wuffs_deflate__flate_decoder__decode(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
wuffs_deflate__status t_0 =
|
wuffs_deflate__status t_0 =
|
||||||
wuffs_deflate__flate_decoder__decode_blocks(self, a_dst, a_src);
|
wuffs_deflate__decoder__decode_blocks(self, a_dst, a_src);
|
||||||
if (a_dst.buf) {
|
if (a_dst.buf) {
|
||||||
b_wptr_dst = a_dst.buf->ptr + a_dst.buf->wi;
|
b_wptr_dst = a_dst.buf->ptr + a_dst.buf->wi;
|
||||||
}
|
}
|
||||||
@@ -938,8 +935,8 @@ exit:
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static wuffs_deflate__status wuffs_deflate__flate_decoder__decode_blocks(
|
static wuffs_deflate__status wuffs_deflate__decoder__decode_blocks(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
wuffs_base__writer1 a_dst,
|
wuffs_base__writer1 a_dst,
|
||||||
wuffs_base__reader1 a_src) {
|
wuffs_base__reader1 a_src) {
|
||||||
wuffs_deflate__status status = WUFFS_DEFLATE__STATUS_OK;
|
wuffs_deflate__status status = WUFFS_DEFLATE__STATUS_OK;
|
||||||
@@ -1003,8 +1000,8 @@ static wuffs_deflate__status wuffs_deflate__flate_decoder__decode_blocks(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
status = wuffs_deflate__flate_decoder__decode_uncompressed(self, a_dst,
|
status =
|
||||||
a_src);
|
wuffs_deflate__decoder__decode_uncompressed(self, a_dst, a_src);
|
||||||
if (a_src.buf) {
|
if (a_src.buf) {
|
||||||
b_rptr_src = a_src.buf->ptr + a_src.buf->ri;
|
b_rptr_src = a_src.buf->ptr + a_src.buf->ri;
|
||||||
}
|
}
|
||||||
@@ -1014,7 +1011,7 @@ static wuffs_deflate__status wuffs_deflate__flate_decoder__decode_blocks(
|
|||||||
goto label_0_continue;
|
goto label_0_continue;
|
||||||
} else if (v_type == 1) {
|
} else if (v_type == 1) {
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||||
status = wuffs_deflate__flate_decoder__init_fixed_huffman(self);
|
status = wuffs_deflate__decoder__init_fixed_huffman(self);
|
||||||
if (status) {
|
if (status) {
|
||||||
goto suspend;
|
goto suspend;
|
||||||
}
|
}
|
||||||
@@ -1030,8 +1027,7 @@ static wuffs_deflate__status wuffs_deflate__flate_decoder__decode_blocks(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
status =
|
status = wuffs_deflate__decoder__init_dynamic_huffman(self, a_src);
|
||||||
wuffs_deflate__flate_decoder__init_dynamic_huffman(self, a_src);
|
|
||||||
if (a_src.buf) {
|
if (a_src.buf) {
|
||||||
b_rptr_src = a_src.buf->ptr + a_src.buf->ri;
|
b_rptr_src = a_src.buf->ptr + a_src.buf->ri;
|
||||||
}
|
}
|
||||||
@@ -1054,8 +1050,7 @@ static wuffs_deflate__status wuffs_deflate__flate_decoder__decode_blocks(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
status =
|
status = wuffs_deflate__decoder__decode_huffman_fast(self, a_dst, a_src);
|
||||||
wuffs_deflate__flate_decoder__decode_huffman_fast(self, a_dst, a_src);
|
|
||||||
if (a_src.buf) {
|
if (a_src.buf) {
|
||||||
b_rptr_src = a_src.buf->ptr + a_src.buf->ri;
|
b_rptr_src = a_src.buf->ptr + a_src.buf->ri;
|
||||||
}
|
}
|
||||||
@@ -1076,8 +1071,7 @@ static wuffs_deflate__status wuffs_deflate__flate_decoder__decode_blocks(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
status =
|
status = wuffs_deflate__decoder__decode_huffman_slow(self, a_dst, a_src);
|
||||||
wuffs_deflate__flate_decoder__decode_huffman_slow(self, a_dst, a_src);
|
|
||||||
if (a_src.buf) {
|
if (a_src.buf) {
|
||||||
b_rptr_src = a_src.buf->ptr + a_src.buf->ri;
|
b_rptr_src = a_src.buf->ptr + a_src.buf->ri;
|
||||||
}
|
}
|
||||||
@@ -1129,8 +1123,8 @@ short_read_src:
|
|||||||
goto suspend;
|
goto suspend;
|
||||||
}
|
}
|
||||||
|
|
||||||
static wuffs_deflate__status wuffs_deflate__flate_decoder__decode_uncompressed(
|
static wuffs_deflate__status wuffs_deflate__decoder__decode_uncompressed(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
wuffs_base__writer1 a_dst,
|
wuffs_base__writer1 a_dst,
|
||||||
wuffs_base__reader1 a_src) {
|
wuffs_base__reader1 a_src) {
|
||||||
wuffs_deflate__status status = WUFFS_DEFLATE__STATUS_OK;
|
wuffs_deflate__status status = WUFFS_DEFLATE__STATUS_OK;
|
||||||
@@ -1291,8 +1285,8 @@ short_read_src:
|
|||||||
goto suspend;
|
goto suspend;
|
||||||
}
|
}
|
||||||
|
|
||||||
static wuffs_deflate__status wuffs_deflate__flate_decoder__init_fixed_huffman(
|
static wuffs_deflate__status wuffs_deflate__decoder__init_fixed_huffman(
|
||||||
wuffs_deflate__flate_decoder* self) {
|
wuffs_deflate__decoder* self) {
|
||||||
wuffs_deflate__status status = WUFFS_DEFLATE__STATUS_OK;
|
wuffs_deflate__status status = WUFFS_DEFLATE__STATUS_OK;
|
||||||
|
|
||||||
uint32_t v_i;
|
uint32_t v_i;
|
||||||
@@ -1327,12 +1321,12 @@ static wuffs_deflate__status wuffs_deflate__flate_decoder__init_fixed_huffman(
|
|||||||
v_i += 1;
|
v_i += 1;
|
||||||
}
|
}
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||||
status = wuffs_deflate__flate_decoder__init_huff(self, 0, 0, 288, 257);
|
status = wuffs_deflate__decoder__init_huff(self, 0, 0, 288, 257);
|
||||||
if (status) {
|
if (status) {
|
||||||
goto suspend;
|
goto suspend;
|
||||||
}
|
}
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||||
status = wuffs_deflate__flate_decoder__init_huff(self, 1, 288, 320, 0);
|
status = wuffs_deflate__decoder__init_huff(self, 1, 288, 320, 0);
|
||||||
if (status) {
|
if (status) {
|
||||||
goto suspend;
|
goto suspend;
|
||||||
}
|
}
|
||||||
@@ -1352,8 +1346,8 @@ exit:
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static wuffs_deflate__status wuffs_deflate__flate_decoder__init_dynamic_huffman(
|
static wuffs_deflate__status wuffs_deflate__decoder__init_dynamic_huffman(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
wuffs_base__reader1 a_src) {
|
wuffs_base__reader1 a_src) {
|
||||||
wuffs_deflate__status status = WUFFS_DEFLATE__STATUS_OK;
|
wuffs_deflate__status status = WUFFS_DEFLATE__STATUS_OK;
|
||||||
|
|
||||||
@@ -1459,7 +1453,7 @@ static wuffs_deflate__status wuffs_deflate__flate_decoder__init_dynamic_huffman(
|
|||||||
v_i += 1;
|
v_i += 1;
|
||||||
}
|
}
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||||
status = wuffs_deflate__flate_decoder__init_huff(self, 0, 0, 19, 4095);
|
status = wuffs_deflate__decoder__init_huff(self, 0, 0, 19, 4095);
|
||||||
if (status) {
|
if (status) {
|
||||||
goto suspend;
|
goto suspend;
|
||||||
}
|
}
|
||||||
@@ -1555,13 +1549,13 @@ static wuffs_deflate__status wuffs_deflate__flate_decoder__init_dynamic_huffman(
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||||
status = wuffs_deflate__flate_decoder__init_huff(self, 0, 0, v_n_lit, 257);
|
status = wuffs_deflate__decoder__init_huff(self, 0, 0, v_n_lit, 257);
|
||||||
if (status) {
|
if (status) {
|
||||||
goto suspend;
|
goto suspend;
|
||||||
}
|
}
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||||
status = wuffs_deflate__flate_decoder__init_huff(self, 1, v_n_lit,
|
status = wuffs_deflate__decoder__init_huff(self, 1, v_n_lit,
|
||||||
(v_n_lit + v_n_dist), 0);
|
(v_n_lit + v_n_dist), 0);
|
||||||
if (status) {
|
if (status) {
|
||||||
goto suspend;
|
goto suspend;
|
||||||
}
|
}
|
||||||
@@ -1617,8 +1611,8 @@ short_read_src:
|
|||||||
goto suspend;
|
goto suspend;
|
||||||
}
|
}
|
||||||
|
|
||||||
static wuffs_deflate__status wuffs_deflate__flate_decoder__init_huff(
|
static wuffs_deflate__status wuffs_deflate__decoder__init_huff(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
uint32_t a_which,
|
uint32_t a_which,
|
||||||
uint32_t a_n_codes0,
|
uint32_t a_n_codes0,
|
||||||
uint32_t a_n_codes1,
|
uint32_t a_n_codes1,
|
||||||
@@ -1897,8 +1891,8 @@ exit:
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static wuffs_deflate__status wuffs_deflate__flate_decoder__decode_huffman_fast(
|
static wuffs_deflate__status wuffs_deflate__decoder__decode_huffman_fast(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
wuffs_base__writer1 a_dst,
|
wuffs_base__writer1 a_dst,
|
||||||
wuffs_base__reader1 a_src) {
|
wuffs_base__reader1 a_src) {
|
||||||
wuffs_deflate__status status = WUFFS_DEFLATE__STATUS_OK;
|
wuffs_deflate__status status = WUFFS_DEFLATE__STATUS_OK;
|
||||||
@@ -2281,8 +2275,8 @@ exit:
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static wuffs_deflate__status wuffs_deflate__flate_decoder__decode_huffman_slow(
|
static wuffs_deflate__status wuffs_deflate__decoder__decode_huffman_slow(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
wuffs_base__writer1 a_dst,
|
wuffs_base__writer1 a_dst,
|
||||||
wuffs_base__reader1 a_src) {
|
wuffs_base__reader1 a_src) {
|
||||||
wuffs_deflate__status status = WUFFS_DEFLATE__STATUS_OK;
|
wuffs_deflate__status status = WUFFS_DEFLATE__STATUS_OK;
|
||||||
|
|||||||
+13
-15
@@ -190,7 +190,7 @@ const char* wuffs_deflate__status__string(wuffs_deflate__status s);
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||||
// compatibility or safety guarantee if you do so. Instead, use the
|
// compatibility or safety guarantee if you do so. Instead, use the
|
||||||
// wuffs_deflate__flate_decoder__etc functions.
|
// wuffs_deflate__decoder__etc functions.
|
||||||
//
|
//
|
||||||
// In C++, these fields would be "private", but C does not support that.
|
// In C++, these fields would be "private", but C does not support that.
|
||||||
//
|
//
|
||||||
@@ -261,25 +261,23 @@ typedef struct {
|
|||||||
uint32_t v_hdist;
|
uint32_t v_hdist;
|
||||||
} c_decode_huffman_slow[1];
|
} c_decode_huffman_slow[1];
|
||||||
} private_impl;
|
} private_impl;
|
||||||
} wuffs_deflate__flate_decoder;
|
} wuffs_deflate__decoder;
|
||||||
|
|
||||||
// ---------------- Public Initializer Prototypes
|
// ---------------- Public Initializer Prototypes
|
||||||
|
|
||||||
// wuffs_deflate__flate_decoder__initialize is an initializer function.
|
// wuffs_deflate__decoder__initialize is an initializer function.
|
||||||
//
|
//
|
||||||
// It should be called before any other wuffs_deflate__flate_decoder__*
|
// It should be called before any other wuffs_deflate__decoder__* function.
|
||||||
// function.
|
|
||||||
//
|
//
|
||||||
// Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only.
|
// Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only.
|
||||||
void wuffs_deflate__flate_decoder__initialize(
|
void wuffs_deflate__decoder__initialize(wuffs_deflate__decoder* self,
|
||||||
wuffs_deflate__flate_decoder* self,
|
uint32_t wuffs_version,
|
||||||
uint32_t wuffs_version,
|
uint32_t for_internal_use_only);
|
||||||
uint32_t for_internal_use_only);
|
|
||||||
|
|
||||||
// ---------------- Public Function Prototypes
|
// ---------------- Public Function Prototypes
|
||||||
|
|
||||||
wuffs_deflate__status wuffs_deflate__flate_decoder__decode(
|
wuffs_deflate__status wuffs_deflate__decoder__decode(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
wuffs_base__writer1 a_dst,
|
wuffs_base__writer1 a_dst,
|
||||||
wuffs_base__reader1 a_src);
|
wuffs_base__reader1 a_src);
|
||||||
|
|
||||||
@@ -367,7 +365,7 @@ typedef struct {
|
|||||||
wuffs_zlib__status status;
|
wuffs_zlib__status status;
|
||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
|
|
||||||
wuffs_deflate__flate_decoder f_flate;
|
wuffs_deflate__decoder f_flate;
|
||||||
wuffs_zlib__adler32 f_adler;
|
wuffs_zlib__adler32 f_adler;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
@@ -841,8 +839,8 @@ void wuffs_zlib__decoder__initialize(wuffs_zlib__decoder* self,
|
|||||||
memset(self, 0, sizeof(*self));
|
memset(self, 0, sizeof(*self));
|
||||||
}
|
}
|
||||||
self->private_impl.magic = WUFFS_BASE__MAGIC;
|
self->private_impl.magic = WUFFS_BASE__MAGIC;
|
||||||
wuffs_deflate__flate_decoder__initialize(
|
wuffs_deflate__decoder__initialize(&self->private_impl.f_flate, WUFFS_VERSION,
|
||||||
&self->private_impl.f_flate, WUFFS_VERSION, WUFFS_BASE__ALREADY_ZEROED);
|
WUFFS_BASE__ALREADY_ZEROED);
|
||||||
wuffs_zlib__adler32__initialize(&self->private_impl.f_adler, WUFFS_VERSION,
|
wuffs_zlib__adler32__initialize(&self->private_impl.f_adler, WUFFS_VERSION,
|
||||||
WUFFS_BASE__ALREADY_ZEROED);
|
WUFFS_BASE__ALREADY_ZEROED);
|
||||||
}
|
}
|
||||||
@@ -979,7 +977,7 @@ wuffs_zlib__status wuffs_zlib__decoder__decode(wuffs_zlib__decoder* self,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wuffs_zlib__status t_2 = wuffs_deflate__flate_decoder__decode(
|
wuffs_zlib__status t_2 = wuffs_deflate__decoder__decode(
|
||||||
&self->private_impl.f_flate, a_dst, a_src);
|
&self->private_impl.f_flate, a_dst, a_src);
|
||||||
if (a_dst.buf) {
|
if (a_dst.buf) {
|
||||||
b_wptr_dst = a_dst.buf->ptr + a_dst.buf->wi;
|
b_wptr_dst = a_dst.buf->ptr + a_dst.buf->wi;
|
||||||
|
|||||||
+9
-11
@@ -181,7 +181,7 @@ const char* wuffs_deflate__status__string(wuffs_deflate__status s);
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||||
// compatibility or safety guarantee if you do so. Instead, use the
|
// compatibility or safety guarantee if you do so. Instead, use the
|
||||||
// wuffs_deflate__flate_decoder__etc functions.
|
// wuffs_deflate__decoder__etc functions.
|
||||||
//
|
//
|
||||||
// In C++, these fields would be "private", but C does not support that.
|
// In C++, these fields would be "private", but C does not support that.
|
||||||
//
|
//
|
||||||
@@ -252,25 +252,23 @@ typedef struct {
|
|||||||
uint32_t v_hdist;
|
uint32_t v_hdist;
|
||||||
} c_decode_huffman_slow[1];
|
} c_decode_huffman_slow[1];
|
||||||
} private_impl;
|
} private_impl;
|
||||||
} wuffs_deflate__flate_decoder;
|
} wuffs_deflate__decoder;
|
||||||
|
|
||||||
// ---------------- Public Initializer Prototypes
|
// ---------------- Public Initializer Prototypes
|
||||||
|
|
||||||
// wuffs_deflate__flate_decoder__initialize is an initializer function.
|
// wuffs_deflate__decoder__initialize is an initializer function.
|
||||||
//
|
//
|
||||||
// It should be called before any other wuffs_deflate__flate_decoder__*
|
// It should be called before any other wuffs_deflate__decoder__* function.
|
||||||
// function.
|
|
||||||
//
|
//
|
||||||
// Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only.
|
// Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only.
|
||||||
void wuffs_deflate__flate_decoder__initialize(
|
void wuffs_deflate__decoder__initialize(wuffs_deflate__decoder* self,
|
||||||
wuffs_deflate__flate_decoder* self,
|
uint32_t wuffs_version,
|
||||||
uint32_t wuffs_version,
|
uint32_t for_internal_use_only);
|
||||||
uint32_t for_internal_use_only);
|
|
||||||
|
|
||||||
// ---------------- Public Function Prototypes
|
// ---------------- Public Function Prototypes
|
||||||
|
|
||||||
wuffs_deflate__status wuffs_deflate__flate_decoder__decode(
|
wuffs_deflate__status wuffs_deflate__decoder__decode(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
wuffs_base__writer1 a_dst,
|
wuffs_base__writer1 a_dst,
|
||||||
wuffs_base__reader1 a_src);
|
wuffs_base__reader1 a_src);
|
||||||
|
|
||||||
|
|||||||
+10
-12
@@ -190,7 +190,7 @@ const char* wuffs_deflate__status__string(wuffs_deflate__status s);
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||||
// compatibility or safety guarantee if you do so. Instead, use the
|
// compatibility or safety guarantee if you do so. Instead, use the
|
||||||
// wuffs_deflate__flate_decoder__etc functions.
|
// wuffs_deflate__decoder__etc functions.
|
||||||
//
|
//
|
||||||
// In C++, these fields would be "private", but C does not support that.
|
// In C++, these fields would be "private", but C does not support that.
|
||||||
//
|
//
|
||||||
@@ -261,25 +261,23 @@ typedef struct {
|
|||||||
uint32_t v_hdist;
|
uint32_t v_hdist;
|
||||||
} c_decode_huffman_slow[1];
|
} c_decode_huffman_slow[1];
|
||||||
} private_impl;
|
} private_impl;
|
||||||
} wuffs_deflate__flate_decoder;
|
} wuffs_deflate__decoder;
|
||||||
|
|
||||||
// ---------------- Public Initializer Prototypes
|
// ---------------- Public Initializer Prototypes
|
||||||
|
|
||||||
// wuffs_deflate__flate_decoder__initialize is an initializer function.
|
// wuffs_deflate__decoder__initialize is an initializer function.
|
||||||
//
|
//
|
||||||
// It should be called before any other wuffs_deflate__flate_decoder__*
|
// It should be called before any other wuffs_deflate__decoder__* function.
|
||||||
// function.
|
|
||||||
//
|
//
|
||||||
// Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only.
|
// Pass WUFFS_VERSION and 0 for wuffs_version and for_internal_use_only.
|
||||||
void wuffs_deflate__flate_decoder__initialize(
|
void wuffs_deflate__decoder__initialize(wuffs_deflate__decoder* self,
|
||||||
wuffs_deflate__flate_decoder* self,
|
uint32_t wuffs_version,
|
||||||
uint32_t wuffs_version,
|
uint32_t for_internal_use_only);
|
||||||
uint32_t for_internal_use_only);
|
|
||||||
|
|
||||||
// ---------------- Public Function Prototypes
|
// ---------------- Public Function Prototypes
|
||||||
|
|
||||||
wuffs_deflate__status wuffs_deflate__flate_decoder__decode(
|
wuffs_deflate__status wuffs_deflate__decoder__decode(
|
||||||
wuffs_deflate__flate_decoder* self,
|
wuffs_deflate__decoder* self,
|
||||||
wuffs_base__writer1 a_dst,
|
wuffs_base__writer1 a_dst,
|
||||||
wuffs_base__reader1 a_src);
|
wuffs_base__reader1 a_src);
|
||||||
|
|
||||||
@@ -367,7 +365,7 @@ typedef struct {
|
|||||||
wuffs_zlib__status status;
|
wuffs_zlib__status status;
|
||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
|
|
||||||
wuffs_deflate__flate_decoder f_flate;
|
wuffs_deflate__decoder f_flate;
|
||||||
wuffs_zlib__adler32 f_adler;
|
wuffs_zlib__adler32 f_adler;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|||||||
+2
-2
@@ -1115,8 +1115,8 @@ swtch:
|
|||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// TODO: don't hard-code deflate.flate_decoder as an acceptable type.
|
// TODO: don't hard-code deflate.decoder as an acceptable type.
|
||||||
if q.tm.ByID(n.Decorator()) == "deflate" && q.tm.ByID(n.Name()) == "flate_decoder" {
|
if q.tm.ByID(n.Decorator()) == "deflate" && q.tm.ByID(n.Name()) == "decoder" {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
return fmt.Errorf("check: unrecognized node for tcheckTypeExpr")
|
return fmt.Errorf("check: unrecognized node for tcheckTypeExpr")
|
||||||
|
|||||||
@@ -14,9 +14,6 @@
|
|||||||
|
|
||||||
packageid "dflt"
|
packageid "dflt"
|
||||||
|
|
||||||
// TODO: rename "struct flate_decoder" to just "struct decoder", to avoid
|
|
||||||
// stutter in the fully qualified C name such as "wuffs_flate__flate_decoder".
|
|
||||||
|
|
||||||
pub error "bad Huffman code (over-subscribed)"
|
pub error "bad Huffman code (over-subscribed)"
|
||||||
pub error "bad Huffman code (under-subscribed)"
|
pub error "bad Huffman code (under-subscribed)"
|
||||||
pub error "bad Huffman code length count"
|
pub error "bad Huffman code length count"
|
||||||
@@ -37,9 +34,9 @@ pub error "no Huffman codes"
|
|||||||
|
|
||||||
// The next two tables were created by script/print-flate-magic-numbers.go.
|
// The next two tables were created by script/print-flate-magic-numbers.go.
|
||||||
//
|
//
|
||||||
// The u32 values' meanings are the same as the flate_decoder.huffs u32 values.
|
// The u32 values' meanings are the same as the decoder.huffs u32 values. In
|
||||||
// In particular, bit 30 indicates a base number + extra bits, bits 23-8 are
|
// particular, bit 30 indicates a base number + extra bits, bits 23-8 are the
|
||||||
// the base number and bits 7-4 are the number of those extra bits.
|
// base number and bits 7-4 are the number of those extra bits.
|
||||||
//
|
//
|
||||||
// Some trailing elements are 0x08000000. Bit 27 indicates an invalid value.
|
// Some trailing elements are 0x08000000. Bit 27 indicates an invalid value.
|
||||||
|
|
||||||
@@ -57,7 +54,7 @@ pri const dcode_magic_numbers[32] u32 = $(
|
|||||||
0x401001B0, 0x401801B0, 0x402001C0, 0x403001C0, 0x404001D0, 0x406001D0, 0x08000000, 0x08000000,
|
0x401001B0, 0x401801B0, 0x402001C0, 0x403001C0, 0x404001D0, 0x406001D0, 0x08000000, 0x08000000,
|
||||||
)
|
)
|
||||||
|
|
||||||
pub struct flate_decoder?(
|
pub struct decoder?(
|
||||||
// These fields yield src's bits in Least Significant Bits order.
|
// These fields yield src's bits in Least Significant Bits order.
|
||||||
bits u32,
|
bits u32,
|
||||||
n_bits u32,
|
n_bits u32,
|
||||||
@@ -69,17 +66,16 @@ pub struct flate_decoder?(
|
|||||||
// - huffs[0] is used for clcode and lcode.
|
// - huffs[0] is used for clcode and lcode.
|
||||||
// - huffs[1] is used for dcode.
|
// - huffs[1] is used for dcode.
|
||||||
//
|
//
|
||||||
// The initial table key is the low n_huffs_bits of the flate_decoder.bits
|
// The initial table key is the low n_huffs_bits of the decoder.bits field.
|
||||||
// field. Keys longer than 9 bits require a two step lookup, the first step
|
// Keys longer than 9 bits require a two step lookup, the first step
|
||||||
// examines the low 9 bits, the second step examines the remaining bits.
|
// examines the low 9 bits, the second step examines the remaining bits.
|
||||||
// Two steps are required at most, as keys are at most 15 bits long.
|
// Two steps are required at most, as keys are at most 15 bits long.
|
||||||
//
|
//
|
||||||
// Using flate_decoder.bits's low n_huffs_bits as a table key is valid even
|
// Using decoder.bits's low n_huffs_bits as a table key is valid even if
|
||||||
// if flate_decoder.n_bits is less than n_huffs_bits, because the immediate
|
// decoder.n_bits is less than n_huffs_bits, because the immediate next
|
||||||
// next step after indexing the table by the key is to compare
|
// step after indexing the table by the key is to compare decoder.n_bits to
|
||||||
// flate_decoder.n_bits to the table value's number of flate_decoder.bits
|
// the table value's number of decoder.bits to consume. If it compares
|
||||||
// to consume. If it compares less, then more source bytes are read and the
|
// less, then more source bytes are read and the table lookup re-tried.
|
||||||
// table lookup re-tried.
|
|
||||||
//
|
//
|
||||||
// The table value is:
|
// The table value is:
|
||||||
// - bit 31 indicates the symbol is a literal.
|
// - bit 31 indicates the symbol is a literal.
|
||||||
@@ -90,7 +86,7 @@ pub struct flate_decoder?(
|
|||||||
// - bits 26-24 are zero.
|
// - bits 26-24 are zero.
|
||||||
// - bits 23- 8 is the redirect offset, literal (in bits 15-8) or base number.
|
// - bits 23- 8 is the redirect offset, literal (in bits 15-8) or base number.
|
||||||
// - bits 7- 4 is the redirected table's bits or number of extra bits.
|
// - bits 7- 4 is the redirected table's bits or number of extra bits.
|
||||||
// - bits 3- 0 are the number of flate_decoder.bits to consume.
|
// - bits 3- 0 are the number of decoder.bits to consume.
|
||||||
//
|
//
|
||||||
// Exactly one of the eight bits 31-24 should be set.
|
// Exactly one of the eight bits 31-24 should be set.
|
||||||
//
|
//
|
||||||
@@ -124,7 +120,7 @@ pub struct flate_decoder?(
|
|||||||
end_of_block bool,
|
end_of_block bool,
|
||||||
)
|
)
|
||||||
|
|
||||||
pub func flate_decoder.decode?(dst writer1, src reader1)() {
|
pub func decoder.decode?(dst writer1, src reader1)() {
|
||||||
while true {
|
while true {
|
||||||
in.dst.mark()
|
in.dst.mark()
|
||||||
var z status = try this.decode_blocks?(dst:in.dst, src:in.src)
|
var z status = try this.decode_blocks?(dst:in.dst, src:in.src)
|
||||||
@@ -176,7 +172,7 @@ pub func flate_decoder.decode?(dst writer1, src reader1)() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pri func flate_decoder.decode_blocks?(dst writer1, src reader1)() {
|
pri func decoder.decode_blocks?(dst writer1, src reader1)() {
|
||||||
var final u32
|
var final u32
|
||||||
while final == 0 {
|
while final == 0 {
|
||||||
while this.n_bits < 3,
|
while this.n_bits < 3,
|
||||||
@@ -216,7 +212,7 @@ pri func flate_decoder.decode_blocks?(dst writer1, src reader1)() {
|
|||||||
|
|
||||||
// decode_uncompressed decodes an uncompresed block as per the RFC section
|
// decode_uncompressed decodes an uncompresed block as per the RFC section
|
||||||
// 3.2.4.
|
// 3.2.4.
|
||||||
pri func flate_decoder.decode_uncompressed?(dst writer1, src reader1)() {
|
pri func decoder.decode_uncompressed?(dst writer1, src reader1)() {
|
||||||
// TODO: make this "if" into a function invariant?
|
// TODO: make this "if" into a function invariant?
|
||||||
//
|
//
|
||||||
// Ditto for decode_huffman_slow and decode_huffman_fast.
|
// Ditto for decode_huffman_slow and decode_huffman_fast.
|
||||||
@@ -248,7 +244,7 @@ pri func flate_decoder.decode_uncompressed?(dst writer1, src reader1)() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// init_fixed_huffman initializes this.huffs as per the RFC section 3.2.6.
|
// init_fixed_huffman initializes this.huffs as per the RFC section 3.2.6.
|
||||||
pri func flate_decoder.init_fixed_huffman?()() {
|
pri func decoder.init_fixed_huffman?()() {
|
||||||
var i u32
|
var i u32
|
||||||
while i < 144 {
|
while i < 144 {
|
||||||
this.code_lengths[i] = 8
|
this.code_lengths[i] = 8
|
||||||
@@ -275,7 +271,7 @@ pri func flate_decoder.init_fixed_huffman?()() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// init_dynamic_huffman initializes this.huffs as per the RFC section 3.2.7.
|
// init_dynamic_huffman initializes this.huffs as per the RFC section 3.2.7.
|
||||||
pri func flate_decoder.init_dynamic_huffman?(src reader1)() {
|
pri func decoder.init_dynamic_huffman?(src reader1)() {
|
||||||
var bits u32 = this.bits
|
var bits u32 = this.bits
|
||||||
var n_bits u32 = this.n_bits
|
var n_bits u32 = this.n_bits
|
||||||
while n_bits < 14,
|
while n_bits < 14,
|
||||||
@@ -425,7 +421,7 @@ pri func flate_decoder.init_dynamic_huffman?(src reader1)() {
|
|||||||
// TODO: skip generating WUFFS_COROUTINE_SUSPENSION_POINTs for *callers* of
|
// TODO: skip generating WUFFS_COROUTINE_SUSPENSION_POINTs for *callers* of
|
||||||
// this function, as it can only return errors, not suspensions.
|
// this function, as it can only return errors, not suspensions.
|
||||||
|
|
||||||
pri func flate_decoder.init_huff?(which u32[..1], n_codes0 u32[..320], n_codes1 u32[..320], base_symbol u32)() {
|
pri func decoder.init_huff?(which u32[..1], n_codes0 u32[..320], n_codes1 u32[..320], base_symbol u32)() {
|
||||||
// For the clcode example in this package's README.md:
|
// For the clcode example in this package's README.md:
|
||||||
// - n_codes0 = 0
|
// - n_codes0 = 0
|
||||||
// - n_codes1 = 19
|
// - n_codes1 = 19
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
// TODO: describe how the xxx_fast version differs from the xxx_slow one, the
|
// TODO: describe how the xxx_fast version differs from the xxx_slow one, the
|
||||||
// assumptions that xxx_fast makes, and how that makes it fast.
|
// assumptions that xxx_fast makes, and how that makes it fast.
|
||||||
pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
|
pri func decoder.decode_huffman_fast?(dst writer1, src reader1)() {
|
||||||
// When editing this function, consider making the equivalent change to the
|
// When editing this function, consider making the equivalent change to the
|
||||||
// decode_huffman_slow function. Keep the diff between the two
|
// decode_huffman_slow function. Keep the diff between the two
|
||||||
// decode_huffman_*.wuffs files as small as possible, while retaining both
|
// decode_huffman_*.wuffs files as small as possible, while retaining both
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
pri func flate_decoder.decode_huffman_slow?(dst writer1, src reader1)() {
|
pri func decoder.decode_huffman_slow?(dst writer1, src reader1)() {
|
||||||
// When editing this function, consider making the equivalent change to the
|
// When editing this function, consider making the equivalent change to the
|
||||||
// decode_huffman_fast function. Keep the diff between the two
|
// decode_huffman_fast function. Keep the diff between the two
|
||||||
// decode_huffman_*.wuffs files as small as possible, while retaining both
|
// decode_huffman_*.wuffs files as small as possible, while retaining both
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ pub error "invalid zlib parity check"
|
|||||||
pub error "TODO: unsupported zlib preset dictionary"
|
pub error "TODO: unsupported zlib preset dictionary"
|
||||||
|
|
||||||
pub struct decoder?(
|
pub struct decoder?(
|
||||||
flate deflate.flate_decoder,
|
flate deflate.decoder,
|
||||||
adler adler32,
|
adler adler32,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+15
-15
@@ -120,8 +120,8 @@ const char* wuffs_deflate_decode(wuffs_base__buf1* dst,
|
|||||||
wuffs_base__buf1* src,
|
wuffs_base__buf1* src,
|
||||||
uint64_t wlimit,
|
uint64_t wlimit,
|
||||||
uint64_t rlimit) {
|
uint64_t rlimit) {
|
||||||
wuffs_deflate__flate_decoder dec;
|
wuffs_deflate__decoder dec;
|
||||||
wuffs_deflate__flate_decoder__initialize(&dec, WUFFS_VERSION, 0);
|
wuffs_deflate__decoder__initialize(&dec, WUFFS_VERSION, 0);
|
||||||
uint64_t wlim = 0;
|
uint64_t wlim = 0;
|
||||||
uint64_t rlim = 0;
|
uint64_t rlim = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -137,7 +137,7 @@ const char* wuffs_deflate_decode(wuffs_base__buf1* dst,
|
|||||||
}
|
}
|
||||||
|
|
||||||
wuffs_deflate__status s =
|
wuffs_deflate__status s =
|
||||||
wuffs_deflate__flate_decoder__decode(&dec, dst_writer, src_reader);
|
wuffs_deflate__decoder__decode(&dec, dst_writer, src_reader);
|
||||||
|
|
||||||
if (s == WUFFS_DEFLATE__STATUS_OK) {
|
if (s == WUFFS_DEFLATE__STATUS_OK) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -211,7 +211,7 @@ void test_wuffs_deflate_decode_split_src() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wuffs_deflate__flate_decoder dec;
|
wuffs_deflate__decoder dec;
|
||||||
wuffs_base__writer1 dst_writer = {.buf = &got};
|
wuffs_base__writer1 dst_writer = {.buf = &got};
|
||||||
wuffs_base__reader1 src_reader = {.buf = &src};
|
wuffs_base__reader1 src_reader = {.buf = &src};
|
||||||
|
|
||||||
@@ -224,19 +224,19 @@ void test_wuffs_deflate_decode_split_src() {
|
|||||||
}
|
}
|
||||||
got.wi = 0;
|
got.wi = 0;
|
||||||
|
|
||||||
wuffs_deflate__flate_decoder__initialize(&dec, WUFFS_VERSION, 0);
|
wuffs_deflate__decoder__initialize(&dec, WUFFS_VERSION, 0);
|
||||||
|
|
||||||
src.closed = false;
|
src.closed = false;
|
||||||
src.ri = gt->src_offset0;
|
src.ri = gt->src_offset0;
|
||||||
src.wi = split;
|
src.wi = split;
|
||||||
wuffs_deflate__status s0 =
|
wuffs_deflate__status s0 =
|
||||||
wuffs_deflate__flate_decoder__decode(&dec, dst_writer, src_reader);
|
wuffs_deflate__decoder__decode(&dec, dst_writer, src_reader);
|
||||||
|
|
||||||
src.closed = true;
|
src.closed = true;
|
||||||
src.ri = split;
|
src.ri = split;
|
||||||
src.wi = gt->src_offset1;
|
src.wi = gt->src_offset1;
|
||||||
wuffs_deflate__status s1 =
|
wuffs_deflate__status s1 =
|
||||||
wuffs_deflate__flate_decoder__decode(&dec, dst_writer, src_reader);
|
wuffs_deflate__decoder__decode(&dec, dst_writer, src_reader);
|
||||||
|
|
||||||
if (s0 != WUFFS_DEFLATE__SUSPENSION_SHORT_READ) {
|
if (s0 != WUFFS_DEFLATE__SUSPENSION_SHORT_READ) {
|
||||||
FAIL("i=%d: s0: got %" PRIi32 " (%s), want %" PRIi32 " (%s)", i, s0,
|
FAIL("i=%d: s0: got %" PRIi32 " (%s), want %" PRIi32 " (%s)", i, s0,
|
||||||
@@ -265,7 +265,7 @@ bool do_test_wuffs_deflate_history(int i,
|
|||||||
golden_test* gt,
|
golden_test* gt,
|
||||||
wuffs_base__buf1* src,
|
wuffs_base__buf1* src,
|
||||||
wuffs_base__buf1* got,
|
wuffs_base__buf1* got,
|
||||||
wuffs_deflate__flate_decoder* dec,
|
wuffs_deflate__decoder* dec,
|
||||||
uint32_t starting_history_index,
|
uint32_t starting_history_index,
|
||||||
uint64_t limit,
|
uint64_t limit,
|
||||||
wuffs_deflate__status want_s) {
|
wuffs_deflate__status want_s) {
|
||||||
@@ -274,7 +274,7 @@ bool do_test_wuffs_deflate_history(int i,
|
|||||||
got->ri = 0;
|
got->ri = 0;
|
||||||
got->wi = 0;
|
got->wi = 0;
|
||||||
|
|
||||||
wuffs_deflate__flate_decoder__initialize(dec, WUFFS_VERSION, 0);
|
wuffs_deflate__decoder__initialize(dec, WUFFS_VERSION, 0);
|
||||||
wuffs_base__writer1 dst_writer = {.buf = got};
|
wuffs_base__writer1 dst_writer = {.buf = got};
|
||||||
wuffs_base__reader1 src_reader = {.buf = src};
|
wuffs_base__reader1 src_reader = {.buf = src};
|
||||||
|
|
||||||
@@ -283,7 +283,7 @@ bool do_test_wuffs_deflate_history(int i,
|
|||||||
dst_writer.private_impl.limit.ptr_to_len = &limit;
|
dst_writer.private_impl.limit.ptr_to_len = &limit;
|
||||||
|
|
||||||
wuffs_deflate__status got_s =
|
wuffs_deflate__status got_s =
|
||||||
wuffs_deflate__flate_decoder__decode(dec, dst_writer, src_reader);
|
wuffs_deflate__decoder__decode(dec, dst_writer, src_reader);
|
||||||
if (got_s != want_s) {
|
if (got_s != want_s) {
|
||||||
FAIL("i=%d: starting_history_index=0x%04" PRIX32
|
FAIL("i=%d: starting_history_index=0x%04" PRIX32
|
||||||
": decode status: got %" PRIi32 " (%s), want %" PRIi32 " (%s)",
|
": decode status: got %" PRIi32 " (%s), want %" PRIi32 " (%s)",
|
||||||
@@ -312,7 +312,7 @@ void test_wuffs_deflate_history_full() {
|
|||||||
const int full_history_size = 0x8000;
|
const int full_history_size = 0x8000;
|
||||||
int i;
|
int i;
|
||||||
for (i = -2; i <= +2; i++) {
|
for (i = -2; i <= +2; i++) {
|
||||||
wuffs_deflate__flate_decoder dec;
|
wuffs_deflate__decoder dec;
|
||||||
if (!do_test_wuffs_deflate_history(
|
if (!do_test_wuffs_deflate_history(
|
||||||
i, gt, &src, &got, &dec, 0, want.wi + i,
|
i, gt, &src, &got, &dec, 0, want.wi + i,
|
||||||
i >= 0 ? WUFFS_DEFLATE__STATUS_OK
|
i >= 0 ? WUFFS_DEFLATE__STATUS_OK
|
||||||
@@ -374,7 +374,7 @@ void test_wuffs_deflate_history_partial() {
|
|||||||
const char* fragment = "3.14";
|
const char* fragment = "3.14";
|
||||||
const uint32_t fragment_length = 4;
|
const uint32_t fragment_length = 4;
|
||||||
|
|
||||||
wuffs_deflate__flate_decoder dec;
|
wuffs_deflate__decoder dec;
|
||||||
if (!do_test_wuffs_deflate_history(i, gt, &src, &got, &dec,
|
if (!do_test_wuffs_deflate_history(i, gt, &src, &got, &dec,
|
||||||
starting_history_index, fragment_length,
|
starting_history_index, fragment_length,
|
||||||
WUFFS_DEFLATE__SUSPENSION_SHORT_WRITE)) {
|
WUFFS_DEFLATE__SUSPENSION_SHORT_WRITE)) {
|
||||||
@@ -455,8 +455,8 @@ void test_wuffs_deflate_table_redirect() {
|
|||||||
// 1st is the key in the first level table (9 bits).
|
// 1st is the key in the first level table (9 bits).
|
||||||
// 2nd is the key in the second level table (variable bits).
|
// 2nd is the key in the second level table (variable bits).
|
||||||
|
|
||||||
wuffs_deflate__flate_decoder dec;
|
wuffs_deflate__decoder dec;
|
||||||
wuffs_deflate__flate_decoder__initialize(&dec, WUFFS_VERSION, 0);
|
wuffs_deflate__decoder__initialize(&dec, WUFFS_VERSION, 0);
|
||||||
|
|
||||||
// The initializer should zero out dec's fields, but to be paranoid, we zero
|
// The initializer should zero out dec's fields, but to be paranoid, we zero
|
||||||
// it out explicitly.
|
// it out explicitly.
|
||||||
@@ -480,7 +480,7 @@ void test_wuffs_deflate_table_redirect() {
|
|||||||
dec.private_impl.f_code_lengths[n++] = 13;
|
dec.private_impl.f_code_lengths[n++] = 13;
|
||||||
|
|
||||||
wuffs_deflate__status s =
|
wuffs_deflate__status s =
|
||||||
wuffs_deflate__flate_decoder__init_huff(&dec, 0, 0, n, 257);
|
wuffs_deflate__decoder__init_huff(&dec, 0, 0, n, 257);
|
||||||
if (s) {
|
if (s) {
|
||||||
FAIL("%s", wuffs_deflate__status__string(s));
|
FAIL("%s", wuffs_deflate__status__string(s));
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in new issue
Block a user