mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 16:52:18 +01:00
Remove unused base.io_writer arg
This commit is contained in:
1 parent
c5362d6413
commit
5badfef313
6 files changed
+20
-57
No files matched your search
@@ -277,11 +277,7 @@ const char* play() {
|
|||||||
|
|
||||||
bool first_frame = true;
|
bool first_frame = true;
|
||||||
for (;; first_frame = false) {
|
for (;; first_frame = false) {
|
||||||
wuffs_base__io_buffer dst = {.ptr = dst_buffer, .len = dst_len};
|
s = wuffs_gif__decoder__decode_frame(&dec, &ib, src_reader);
|
||||||
wuffs_base__io_writer dst_writer = wuffs_base__io_buffer__writer(&dst);
|
|
||||||
// TODO: provide API and support for when the frame rect is different from
|
|
||||||
// the image rect.
|
|
||||||
s = wuffs_gif__decoder__decode_frame(&dec, &ib, dst_writer, src_reader);
|
|
||||||
if (s) {
|
if (s) {
|
||||||
if (s == WUFFS_GIF__SUSPENSION_END_OF_DATA) {
|
if (s == WUFFS_GIF__SUSPENSION_END_OF_DATA) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
+1
-10
@@ -76,18 +76,9 @@ const char* fuzz(wuffs_base__io_reader src_reader, uint32_t hash) {
|
|||||||
wuffs_base__image_buffer__set_from_slice(
|
wuffs_base__image_buffer__set_from_slice(
|
||||||
&ib, ic, ((wuffs_base__slice_u8){.ptr = pixbuf, .len = pixbuf_size}));
|
&ib, ic, ((wuffs_base__slice_u8){.ptr = pixbuf, .len = pixbuf_size}));
|
||||||
|
|
||||||
wuffs_base__io_buffer dst = {.ptr = (uint8_t*)(pixbuf), .len = pixbuf_size};
|
|
||||||
wuffs_base__io_writer dst_writer = wuffs_base__io_buffer__writer(&dst);
|
|
||||||
|
|
||||||
bool seen_ok = false;
|
bool seen_ok = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
// TODO: handle the frame rect being larger than the image rect. The
|
s = wuffs_gif__decoder__decode_frame(&dec, &ib, src_reader);
|
||||||
// GIF89a spec doesn't disallow this and the Wuffs code tolerates it, in
|
|
||||||
// that it returns a "short write" (because the dst buffer is too small)
|
|
||||||
// and will not e.g. write past the buffer bounds. But the Wuffs GIF API
|
|
||||||
// should somehow pass a subset of pixbuf to decode_frame.
|
|
||||||
dst.wi = 0;
|
|
||||||
s = wuffs_gif__decoder__decode_frame(&dec, &ib, dst_writer, src_reader);
|
|
||||||
if (s) {
|
if (s) {
|
||||||
if ((s == WUFFS_GIF__SUSPENSION_END_OF_DATA) && seen_ok) {
|
if ((s == WUFFS_GIF__SUSPENSION_END_OF_DATA) && seen_ok) {
|
||||||
s = WUFFS_GIF__STATUS_OK;
|
s = WUFFS_GIF__STATUS_OK;
|
||||||
|
|||||||
+1
-5
@@ -1361,7 +1361,6 @@ wuffs_gif__status wuffs_gif__decoder__decode_config(
|
|||||||
wuffs_gif__status wuffs_gif__decoder__decode_frame(
|
wuffs_gif__status wuffs_gif__decoder__decode_frame(
|
||||||
wuffs_gif__decoder* self,
|
wuffs_gif__decoder* self,
|
||||||
wuffs_base__image_buffer* a_ib,
|
wuffs_base__image_buffer* a_ib,
|
||||||
wuffs_base__io_writer a_dst,
|
|
||||||
wuffs_base__io_reader a_src);
|
wuffs_base__io_reader a_src);
|
||||||
|
|
||||||
wuffs_gif__status wuffs_gif__decoder__decode_up_to_id_part1(
|
wuffs_gif__status wuffs_gif__decoder__decode_up_to_id_part1(
|
||||||
@@ -1992,7 +1991,6 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id_part0(
|
|||||||
static wuffs_gif__status wuffs_gif__decoder__decode_id_part1(
|
static wuffs_gif__status wuffs_gif__decoder__decode_id_part1(
|
||||||
wuffs_gif__decoder* self,
|
wuffs_gif__decoder* self,
|
||||||
wuffs_base__image_buffer* a_ib,
|
wuffs_base__image_buffer* a_ib,
|
||||||
wuffs_base__io_writer a_dst,
|
|
||||||
wuffs_base__io_reader a_src);
|
wuffs_base__io_reader a_src);
|
||||||
|
|
||||||
static wuffs_gif__status wuffs_gif__decoder__copy_to_image_buffer(
|
static wuffs_gif__status wuffs_gif__decoder__copy_to_image_buffer(
|
||||||
@@ -2122,7 +2120,6 @@ exit:
|
|||||||
wuffs_gif__status wuffs_gif__decoder__decode_frame(
|
wuffs_gif__status wuffs_gif__decoder__decode_frame(
|
||||||
wuffs_gif__decoder* self,
|
wuffs_gif__decoder* self,
|
||||||
wuffs_base__image_buffer* a_ib,
|
wuffs_base__image_buffer* a_ib,
|
||||||
wuffs_base__io_writer a_dst,
|
|
||||||
wuffs_base__io_reader a_src) {
|
wuffs_base__io_reader a_src) {
|
||||||
if (!self) {
|
if (!self) {
|
||||||
return WUFFS_GIF__ERROR_BAD_RECEIVER;
|
return WUFFS_GIF__ERROR_BAD_RECEIVER;
|
||||||
@@ -2169,7 +2166,7 @@ wuffs_gif__status wuffs_gif__decoder__decode_frame(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||||
status = wuffs_gif__decoder__decode_id_part1(self, a_ib, a_dst, a_src);
|
status = wuffs_gif__decoder__decode_id_part1(self, a_ib, a_src);
|
||||||
if (status) {
|
if (status) {
|
||||||
goto suspend;
|
goto suspend;
|
||||||
}
|
}
|
||||||
@@ -3272,7 +3269,6 @@ short_read_src:
|
|||||||
static wuffs_gif__status wuffs_gif__decoder__decode_id_part1(
|
static wuffs_gif__status wuffs_gif__decoder__decode_id_part1(
|
||||||
wuffs_gif__decoder* self,
|
wuffs_gif__decoder* self,
|
||||||
wuffs_base__image_buffer* a_ib,
|
wuffs_base__image_buffer* a_ib,
|
||||||
wuffs_base__io_writer a_dst,
|
|
||||||
wuffs_base__io_reader a_src) {
|
wuffs_base__io_reader a_src) {
|
||||||
wuffs_gif__status status = WUFFS_GIF__STATUS_OK;
|
wuffs_gif__status status = WUFFS_GIF__STATUS_OK;
|
||||||
|
|
||||||
|
|||||||
@@ -1361,7 +1361,6 @@ wuffs_gif__status wuffs_gif__decoder__decode_config(
|
|||||||
wuffs_gif__status wuffs_gif__decoder__decode_frame(
|
wuffs_gif__status wuffs_gif__decoder__decode_frame(
|
||||||
wuffs_gif__decoder* self,
|
wuffs_gif__decoder* self,
|
||||||
wuffs_base__image_buffer* a_ib,
|
wuffs_base__image_buffer* a_ib,
|
||||||
wuffs_base__io_writer a_dst,
|
|
||||||
wuffs_base__io_reader a_src);
|
wuffs_base__io_reader a_src);
|
||||||
|
|
||||||
wuffs_gif__status wuffs_gif__decoder__decode_up_to_id_part1(
|
wuffs_gif__status wuffs_gif__decoder__decode_up_to_id_part1(
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ pub func decoder.decode_config?(dst ptr base.image_config, src base.io_reader)()
|
|||||||
this.call_sequence = 1
|
this.call_sequence = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
pub func decoder.decode_frame?(ib ptr base.image_buffer, dst base.io_writer, src base.io_reader)() {
|
pub func decoder.decode_frame?(ib ptr base.image_buffer, src base.io_reader)() {
|
||||||
if this.call_sequence == 0 {
|
if this.call_sequence == 0 {
|
||||||
return error "invalid call sequence"
|
return error "invalid call sequence"
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ pub func decoder.decode_frame?(ib ptr base.image_buffer, dst base.io_writer, src
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.decode_id_part1?(ib:in.ib, dst:in.dst, src:in.src)
|
this.decode_id_part1?(ib:in.ib, src:in.src)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub func decoder.decode_up_to_id_part1?(src base.io_reader)() {
|
pub func decoder.decode_up_to_id_part1?(src base.io_reader)() {
|
||||||
@@ -365,8 +365,7 @@ pri func decoder.decode_id_part0?(src base.io_reader)() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: dst should be a ptr base.image_buffer, not a base.io_writer.
|
pri func decoder.decode_id_part1?(ib ptr base.image_buffer, src base.io_reader)() {
|
||||||
pri func decoder.decode_id_part1?(ib ptr base.image_buffer, dst base.io_writer, src base.io_reader)() {
|
|
||||||
// TODO: use this.interlace.
|
// TODO: use this.interlace.
|
||||||
var flags base.u8 = in.src.read_u8?()
|
var flags base.u8 = in.src.read_u8?()
|
||||||
this.interlace = (flags & 0x40) != 0
|
this.interlace = (flags & 0x40) != 0
|
||||||
|
|||||||
+14
-32
@@ -361,7 +361,6 @@ const char* wuffs_gif_decode(wuffs_base__io_buffer* dst,
|
|||||||
wuffs_gif__decoder__initialize(&dec, WUFFS_VERSION, 0);
|
wuffs_gif__decoder__initialize(&dec, WUFFS_VERSION, 0);
|
||||||
wuffs_base__image_buffer ib = ((wuffs_base__image_buffer){});
|
wuffs_base__image_buffer ib = ((wuffs_base__image_buffer){});
|
||||||
wuffs_base__image_config ic = {{0}};
|
wuffs_base__image_config ic = {{0}};
|
||||||
wuffs_base__io_writer dst_writer = wuffs_base__io_buffer__writer(dst);
|
|
||||||
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(src);
|
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(src);
|
||||||
wuffs_gif__status s =
|
wuffs_gif__status s =
|
||||||
wuffs_gif__decoder__decode_config(&dec, &ic, src_reader);
|
wuffs_gif__decoder__decode_config(&dec, &ic, src_reader);
|
||||||
@@ -376,7 +375,7 @@ const char* wuffs_gif_decode(wuffs_base__io_buffer* dst,
|
|||||||
.len = WUFFS_TESTLIB_ARRAY_SIZE(global_pixel_buffer),
|
.len = WUFFS_TESTLIB_ARRAY_SIZE(global_pixel_buffer),
|
||||||
}));
|
}));
|
||||||
while (true) {
|
while (true) {
|
||||||
s = wuffs_gif__decoder__decode_frame(&dec, &ib, dst_writer, src_reader);
|
s = wuffs_gif__decoder__decode_frame(&dec, &ib, src_reader);
|
||||||
if (s == WUFFS_GIF__SUSPENSION_END_OF_DATA) {
|
if (s == WUFFS_GIF__SUSPENSION_END_OF_DATA) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -453,19 +452,19 @@ bool do_test_wuffs_gif_decode(const char* filename,
|
|||||||
int num_iters = 0;
|
int num_iters = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
num_iters++;
|
num_iters++;
|
||||||
wuffs_base__io_writer got_writer = wuffs_base__io_buffer__writer(&got);
|
|
||||||
if (wlimit) {
|
if (wlimit) {
|
||||||
set_writer_limit(&got_writer, wlimit);
|
// TODO: wlimit is unused.
|
||||||
|
// set_writer_limit(&got_writer, wlimit);
|
||||||
}
|
}
|
||||||
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(&src);
|
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(&src);
|
||||||
if (rlimit) {
|
if (rlimit) {
|
||||||
set_reader_limit(&src_reader, rlimit);
|
set_reader_limit(&src_reader, rlimit);
|
||||||
}
|
}
|
||||||
size_t old_wi = got.wi;
|
|
||||||
size_t old_ri = src.ri;
|
size_t old_ri = src.ri;
|
||||||
|
|
||||||
wuffs_gif__status status =
|
wuffs_gif__status status =
|
||||||
wuffs_gif__decoder__decode_frame(&dec, &ib, got_writer, src_reader);
|
wuffs_gif__decoder__decode_frame(&dec, &ib, src_reader);
|
||||||
|
|
||||||
if (status == WUFFS_GIF__STATUS_OK) {
|
if (status == WUFFS_GIF__STATUS_OK) {
|
||||||
const char* msg = copy_to_io_buffer_from_image_buffer(&got, &ib);
|
const char* msg = copy_to_io_buffer_from_image_buffer(&got, &ib);
|
||||||
if (msg) {
|
if (msg) {
|
||||||
@@ -474,27 +473,18 @@ bool do_test_wuffs_gif_decode(const char* filename,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((status != WUFFS_GIF__SUSPENSION_SHORT_READ) &&
|
if (status != WUFFS_GIF__SUSPENSION_SHORT_READ) {
|
||||||
(status != WUFFS_GIF__SUSPENSION_SHORT_WRITE)) {
|
FAIL("decode_frame: got %" PRIi32 " (%s), want %" PRIi32 " (%s)", status,
|
||||||
FAIL("decode_frame: got %" PRIi32 " (%s), want %" PRIi32
|
wuffs_gif__status__string(status), WUFFS_GIF__SUSPENSION_SHORT_READ,
|
||||||
" (%s) or %" PRIi32 " (%s)",
|
wuffs_gif__status__string(WUFFS_GIF__SUSPENSION_SHORT_READ));
|
||||||
status, wuffs_gif__status__string(status),
|
|
||||||
WUFFS_GIF__SUSPENSION_SHORT_READ,
|
|
||||||
wuffs_gif__status__string(WUFFS_GIF__SUSPENSION_SHORT_READ),
|
|
||||||
WUFFS_GIF__SUSPENSION_SHORT_WRITE,
|
|
||||||
wuffs_gif__status__string(WUFFS_GIF__SUSPENSION_SHORT_WRITE));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (got.wi < old_wi) {
|
|
||||||
FAIL("write index got.wi went backwards");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (src.ri < old_ri) {
|
if (src.ri < old_ri) {
|
||||||
FAIL("read index src.ri went backwards");
|
FAIL("read index src.ri went backwards");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((got.wi == old_wi) && (src.ri == old_ri)) {
|
if (src.ri == old_ri) {
|
||||||
FAIL("no progress was made");
|
FAIL("no progress was made");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -539,10 +529,9 @@ bool do_test_wuffs_gif_decode(const char* filename,
|
|||||||
FAIL("decode_frame returned \"ok\" but src was exhausted");
|
FAIL("decode_frame returned \"ok\" but src was exhausted");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
wuffs_base__io_writer got_writer = wuffs_base__io_buffer__writer(&got);
|
|
||||||
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(&src);
|
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(&src);
|
||||||
wuffs_gif__status status =
|
wuffs_gif__status status =
|
||||||
wuffs_gif__decoder__decode_frame(&dec, &ib, got_writer, src_reader);
|
wuffs_gif__decoder__decode_frame(&dec, &ib, src_reader);
|
||||||
if (status != WUFFS_GIF__SUSPENSION_END_OF_DATA) {
|
if (status != WUFFS_GIF__SUSPENSION_END_OF_DATA) {
|
||||||
FAIL("decode_frame: got %" PRIi32 " (%s), want %" PRIi32 " (%s)", status,
|
FAIL("decode_frame: got %" PRIi32 " (%s), want %" PRIi32 " (%s)", status,
|
||||||
wuffs_gif__status__string(status), WUFFS_GIF__SUSPENSION_END_OF_DATA,
|
wuffs_gif__status__string(status), WUFFS_GIF__SUSPENSION_END_OF_DATA,
|
||||||
@@ -561,7 +550,6 @@ bool do_test_wuffs_gif_decode(const char* filename,
|
|||||||
void test_wuffs_gif_call_sequence() {
|
void test_wuffs_gif_call_sequence() {
|
||||||
CHECK_FOCUS(__func__);
|
CHECK_FOCUS(__func__);
|
||||||
|
|
||||||
wuffs_base__io_buffer got = {.ptr = global_got_buffer, .len = BUFFER_SIZE};
|
|
||||||
wuffs_base__io_buffer src = {.ptr = global_src_buffer, .len = BUFFER_SIZE};
|
wuffs_base__io_buffer src = {.ptr = global_src_buffer, .len = BUFFER_SIZE};
|
||||||
|
|
||||||
if (!read_file(&src, "../../data/bricks-dither.gif")) {
|
if (!read_file(&src, "../../data/bricks-dither.gif")) {
|
||||||
@@ -572,11 +560,10 @@ void test_wuffs_gif_call_sequence() {
|
|||||||
wuffs_gif__decoder__initialize(&dec, WUFFS_VERSION, 0);
|
wuffs_gif__decoder__initialize(&dec, WUFFS_VERSION, 0);
|
||||||
|
|
||||||
wuffs_base__image_buffer ib = ((wuffs_base__image_buffer){});
|
wuffs_base__image_buffer ib = ((wuffs_base__image_buffer){});
|
||||||
wuffs_base__io_writer got_writer = wuffs_base__io_buffer__writer(&got);
|
|
||||||
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(&src);
|
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(&src);
|
||||||
|
|
||||||
wuffs_gif__status status =
|
wuffs_gif__status status =
|
||||||
wuffs_gif__decoder__decode_frame(&dec, &ib, got_writer, src_reader);
|
wuffs_gif__decoder__decode_frame(&dec, &ib, src_reader);
|
||||||
if (status != WUFFS_GIF__ERROR_INVALID_CALL_SEQUENCE) {
|
if (status != WUFFS_GIF__ERROR_INVALID_CALL_SEQUENCE) {
|
||||||
FAIL("decode_frame: got %" PRIi32 " (%s), want %" PRIi32 " (%s)", status,
|
FAIL("decode_frame: got %" PRIi32 " (%s), want %" PRIi32 " (%s)", status,
|
||||||
wuffs_gif__status__string(status),
|
wuffs_gif__status__string(status),
|
||||||
@@ -591,7 +578,6 @@ bool do_test_wuffs_gif_decode_animated(
|
|||||||
uint32_t want_num_loops,
|
uint32_t want_num_loops,
|
||||||
uint32_t want_num_frames,
|
uint32_t want_num_frames,
|
||||||
wuffs_base__rect_ie_u32* want_dirty_rects) {
|
wuffs_base__rect_ie_u32* want_dirty_rects) {
|
||||||
wuffs_base__io_buffer got = {.ptr = global_got_buffer, .len = BUFFER_SIZE};
|
|
||||||
wuffs_base__io_buffer src = {.ptr = global_src_buffer, .len = BUFFER_SIZE};
|
wuffs_base__io_buffer src = {.ptr = global_src_buffer, .len = BUFFER_SIZE};
|
||||||
|
|
||||||
if (!read_file(&src, filename)) {
|
if (!read_file(&src, filename)) {
|
||||||
@@ -603,7 +589,6 @@ bool do_test_wuffs_gif_decode_animated(
|
|||||||
|
|
||||||
wuffs_base__image_buffer ib = ((wuffs_base__image_buffer){});
|
wuffs_base__image_buffer ib = ((wuffs_base__image_buffer){});
|
||||||
wuffs_base__image_config ic = {{0}};
|
wuffs_base__image_config ic = {{0}};
|
||||||
wuffs_base__io_writer got_writer = wuffs_base__io_buffer__writer(&got);
|
|
||||||
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(&src);
|
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(&src);
|
||||||
|
|
||||||
wuffs_gif__status status =
|
wuffs_gif__status status =
|
||||||
@@ -629,9 +614,7 @@ bool do_test_wuffs_gif_decode_animated(
|
|||||||
|
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
for (i = 0; i < want_num_frames; i++) {
|
for (i = 0; i < want_num_frames; i++) {
|
||||||
got.wi = 0;
|
status = wuffs_gif__decoder__decode_frame(&dec, &ib, src_reader);
|
||||||
status =
|
|
||||||
wuffs_gif__decoder__decode_frame(&dec, &ib, got_writer, src_reader);
|
|
||||||
if (status != WUFFS_GIF__STATUS_OK) {
|
if (status != WUFFS_GIF__STATUS_OK) {
|
||||||
FAIL("decode_frame #%" PRIu32 ": got %" PRIi32 " (%s)", i, status,
|
FAIL("decode_frame #%" PRIu32 ": got %" PRIi32 " (%s)", i, status,
|
||||||
wuffs_gif__status__string(status));
|
wuffs_gif__status__string(status));
|
||||||
@@ -654,8 +637,7 @@ bool do_test_wuffs_gif_decode_animated(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// There should be no more frames.
|
// There should be no more frames.
|
||||||
got.wi = 0;
|
status = wuffs_gif__decoder__decode_frame(&dec, &ib, src_reader);
|
||||||
status = wuffs_gif__decoder__decode_frame(&dec, &ib, got_writer, src_reader);
|
|
||||||
if (status != WUFFS_GIF__SUSPENSION_END_OF_DATA) {
|
if (status != WUFFS_GIF__SUSPENSION_END_OF_DATA) {
|
||||||
FAIL("decode_frame: got %" PRIi32 " (%s), want %" PRIi32 " (%s)", status,
|
FAIL("decode_frame: got %" PRIi32 " (%s), want %" PRIi32 " (%s)", status,
|
||||||
wuffs_gif__status__string(status), WUFFS_GIF__SUSPENSION_END_OF_DATA,
|
wuffs_gif__status__string(status), WUFFS_GIF__SUSPENSION_END_OF_DATA,
|
||||||
|
|||||||
Reference in new issue
Block a user