Use some more animated GIF test data

This commit is contained in:
Nigel Tao committed 2018-05-10 10:14:07 +10:00
1 parent 282b9c4b20
commit 76c6af4ff4
2 files changed
+92 -55

No files matched your search

+22 -25
View File
@@ -55,33 +55,30 @@ const char* mimic_gif_decode(wuffs_base__io_buffer* dst,
goto cleanup1;
}
// TODO: have Wuffs accept multi-frame (animated) GIFs.
if (f->ImageCount != 1) {
ret = "GIF image has more than one frame";
goto cleanup1;
int i;
for (i = 0; i < f->ImageCount; i++) {
// Copy the pixel data from the GifFileType* f to the dst buffer, since the
// former is free'd at the end of this function.
//
// In theory, this mimic_gif_decode function might be faster overall if the
// DGifSlurp call above decoded the pixel data directly into dst instead of
// into an intermediate buffer that needed to be malloc'ed and then free'd.
// In practice, doing so did not seem to show a huge difference. (See
// commit ab7e0ae "Add a custom gif_mimic_DGifSlurp function.") It also
// further complicates supporting both versions 4 and 5 of giflib. That
// commit was therefore rolled back.
struct SavedImage* si = &f->SavedImages[i];
size_t num_src =
(size_t)(si->ImageDesc.Width) * (size_t)(si->ImageDesc.Height);
size_t num_dst = dst->len - dst->wi;
if (num_dst < num_src) {
ret = "GIF image's pixel data won't fit in the dst buffer";
goto cleanup1;
}
memmove(dst->ptr + dst->wi, si->RasterBits, num_src);
dst->wi += num_src;
}
// Copy the pixel data from the GifFileType* f to the dst buffer, since the
// former is free'd at the end of this function.
//
// In theory, this mimic_gif_decode function might be faster overall if the
// DGifSlurp call above decoded the pixel data directly into dst instead of
// into an intermediate buffer that needed to be malloc'ed and then free'd.
// In practice, doing so did not seem to show a huge difference. (See commit
// ab7e0ae "Add a custom gif_mimic_DGifSlurp function.") It also further
// complicates supporting both versions 4 and 5 of giflib. That commit was
// therefore rolled back.
struct SavedImage* si = &f->SavedImages[0];
size_t num_src =
(size_t)(si->ImageDesc.Width) * (size_t)(si->ImageDesc.Height);
size_t num_dst = dst->len - dst->wi;
if (num_dst < num_src) {
ret = "GIF image's pixel data won't fit in the dst buffer";
goto cleanup1;
}
memmove(dst->ptr + dst->wi, si->RasterBits, num_src);
dst->wi += num_src;
cleanup1:;
#if defined(GIFLIB_MAJOR) && (GIFLIB_MAJOR >= 5)
int close_status = DGifCloseFile(f, NULL);