aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-12-28 19:37:15 +0100
committerPřemysl Eric Janouch <p@janouch.name>2021-12-28 19:59:31 +0100
commitc1af556751e196aba1f66aa06ce36f00d07d7ca7 (patch)
tree447f1ec5f94d0ad0b441b0e57c94152132daac7e
parent2d86ffed342b3533561102fb204faa500ca356f7 (diff)
downloadfiv-c1af556751e196aba1f66aa06ce36f00d07d7ca7.tar.gz
fiv-c1af556751e196aba1f66aa06ce36f00d07d7ca7.tar.xz
fiv-c1af556751e196aba1f66aa06ce36f00d07d7ca7.zip
Load back wide thumbnail metadata
-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.