aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fiv-io.c10
-rw-r--r--fiv-io.h2
2 files changed, 11 insertions, 1 deletions
diff --git a/fiv-io.c b/fiv-io.c
index dfea508..26b6e89 100644
--- a/fiv-io.c
+++ b/fiv-io.c
@@ -1718,6 +1718,7 @@ open_libwebp(const gchar *data, gsize len, const gchar *path,
}
// Releasing the demux chunk iterator is actually a no-op.
+ // TODO(p): Avoid copy-pasting the chunk transfer code.
WebPChunkIterator chunk_iter = {};
uint32_t flags = WebPDemuxGetI(demux, WEBP_FF_FORMAT_FLAGS);
if ((flags & EXIF_FLAG) &&
@@ -1741,6 +1742,12 @@ open_libwebp(const gchar *data, gsize len, const gchar *path,
(cairo_destroy_func_t) g_bytes_unref);
WebPDemuxReleaseChunkIterator(&chunk_iter);
}
+ if (WebPDemuxGetChunk(demux, "THUM", 1, &chunk_iter)) {
+ cairo_surface_set_user_data(result, &fiv_io_key_thum,
+ g_bytes_new(chunk_iter.chunk.bytes, chunk_iter.chunk.size),
+ (cairo_destroy_func_t) g_bytes_unref);
+ WebPDemuxReleaseChunkIterator(&chunk_iter);
+ }
if (flags & ANIMATION_FLAG) {
cairo_surface_set_user_data(result, &fiv_io_key_loops,
(void *) (uintptr_t) WebPDemuxGetI(demux, WEBP_FF_LOOP_COUNT),
@@ -2280,6 +2287,7 @@ cairo_user_data_key_t fiv_io_key_exif;
cairo_user_data_key_t fiv_io_key_orientation;
cairo_user_data_key_t fiv_io_key_icc;
cairo_user_data_key_t fiv_io_key_xmp;
+cairo_user_data_key_t fiv_io_key_thum;
cairo_user_data_key_t fiv_io_key_frame_next;
cairo_user_data_key_t fiv_io_key_frame_previous;
@@ -2981,7 +2989,7 @@ static cairo_surface_t *
read_wide_thumbnail(
const gchar *path, const gchar *uri, time_t mtime, GError **error)
{
- // TODO(p): Validate.
+ // TODO(p): Validate fiv_io_key_thum.
(void) uri;
(void) mtime;
return fiv_io_open(path, NULL, FALSE, error);
diff --git a/fiv-io.h b/fiv-io.h
index b561286..52fd691 100644
--- a/fiv-io.h
+++ b/fiv-io.h
@@ -47,6 +47,8 @@ extern cairo_user_data_key_t fiv_io_key_orientation;
extern cairo_user_data_key_t fiv_io_key_icc;
/// GBytes with plain XMP data.
extern cairo_user_data_key_t fiv_io_key_xmp;
+/// GBytes with a WebP's THUM chunk, used for our thumbnails.
+extern cairo_user_data_key_t fiv_io_key_thum;
/// The next frame in a sequence, as a surface, in a chain, pre-composited.
/// There is no wrap-around.