From ad9ada3b9f63e8acd09a40edf1d3078ac7d13acf Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 7 Jun 2012 06:56:08 +0000 Subject: [PATCH] libwebp/demux: add WebPDemuxGetI Enables queries for format flag, canvas width/height. Change-Id: I1d97a633712141e42dfc86c95492eb6da5cefa01 --- src/mux/demux.c | 15 +++++++++++++++ src/webp/mux.h | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/mux/demux.c b/src/mux/demux.c index e2a8f042..85a6daec 100644 --- a/src/mux/demux.c +++ b/src/mux/demux.c @@ -650,6 +650,21 @@ void WebPDemuxDelete(WebPDemuxer* const dmux) { free(dmux); } +// ----------------------------------------------------------------------------- + +uint32_t WebPDemuxGetI(const WebPDemuxer* const dmux, + WebPFormatFeature feature) { + if (dmux == NULL) return 0; + + switch (feature) { + case WEBP_FF_FORMAT_FLAGS: return dmux->feature_flags_; + case WEBP_FF_CANVAS_WIDTH: return (uint32_t)dmux->canvas_width_; + case WEBP_FF_CANVAS_HEIGHT: return (uint32_t)dmux->canvas_height_; + case WEBP_FF_LOOP_COUNT: return (uint32_t)dmux->loop_count_; + } + return 0; +} + #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" #endif diff --git a/src/webp/mux.h b/src/webp/mux.h index 106756b0..20321676 100644 --- a/src/webp/mux.h +++ b/src/webp/mux.h @@ -502,6 +502,22 @@ static WEBP_INLINE WebPDemuxer* WebPDemuxPartial( // Frees memory associated with 'dmux'. WEBP_EXTERN(void) WebPDemuxDelete(WebPDemuxer* const dmux); +//------------------------------------------------------------------------------ +// Data/information extraction. + +typedef enum { + WEBP_FF_FORMAT_FLAGS, // Extended format flags present in the 'VP8X' chunk. + WEBP_FF_CANVAS_WIDTH, + WEBP_FF_CANVAS_HEIGHT, + WEBP_FF_LOOP_COUNT +} WebPFormatFeature; + +// Get the 'feature' value from the 'dmux'. +// NOTE: values are only valid if WebPDemux() was used or WebPDemuxPartial() +// returned a state > WEBP_DEMUX_PARSING_HEADER. +WEBP_EXTERN(uint32_t) WebPDemuxGetI( + const WebPDemuxer* const dmux, WebPFormatFeature feature); + //------------------------------------------------------------------------------ #if defined(__cplusplus) || defined(c_plusplus)