From f8f94081be75d4ee3724d59071c4e40362ea5b4c Mon Sep 17 00:00:00 2001 From: James Zern Date: Sat, 2 Jun 2012 19:49:53 +0000 Subject: [PATCH] libwebp: add WebPDemux stub functions beginning of a separate interface to demux webp files. Change-Id: If8bf9c43defe5f6c8678afd03541f7cd8261c99a --- src/mux/demux.c | 33 +++++++++++++++++++++++++++++++++ src/webp/mux.h | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 src/mux/demux.c diff --git a/src/mux/demux.c b/src/mux/demux.c new file mode 100644 index 00000000..3a644f8a --- /dev/null +++ b/src/mux/demux.c @@ -0,0 +1,33 @@ +// Copyright 2012 Google Inc. All Rights Reserved. +// +// This code is licensed under the same terms as WebM: +// Software License Agreement: http://www.webmproject.org/license/software/ +// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// ----------------------------------------------------------------------------- +// +// WebP container demux. +// + +#include "../webp/mux.h" + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + +WebPDemuxer* WebPDemuxInternal( + const WebPData* const data, int allow_partial, + WebPDemuxState* const state, int version) { + (void)data; + (void)allow_partial; + (void)state; + (void)version; + return NULL; +} + +void WebPDemuxDelete(WebPDemuxer* const dmux) { + (void)dmux; +} + +#if defined(__cplusplus) || defined(c_plusplus) +} // extern "C" +#endif diff --git a/src/webp/mux.h b/src/webp/mux.h index a8bd4f54..106756b0 100644 --- a/src/webp/mux.h +++ b/src/webp/mux.h @@ -463,6 +463,45 @@ WEBP_EXTERN(WebPMuxError) WebPMuxNumChunks(const WebPMux* const mux, WEBP_EXTERN(WebPMuxError) WebPMuxAssemble(WebPMux* const mux, WebPData* const assembled_data); +//------------------------------------------------------------------------------ +// Demux API. +// Enables extraction of image and extended format data from WebP files. + +#define WEBP_DEMUX_ABI_VERSION 0x0000 + +typedef struct WebPDemuxer WebPDemuxer; + +typedef enum { + WEBP_DEMUX_PARSING_HEADER, // Not enough data to parse full header. + WEBP_DEMUX_PARSED_HEADER, // Header parsing complete, data may be available. + WEBP_DEMUX_DONE // Entire file has been parsed. +} WebPDemuxState; + +//------------------------------------------------------------------------------ +// Life of a Demux object + +// Internal, version-checked, entry point +WEBP_EXTERN(WebPDemuxer*) WebPDemuxInternal( + const WebPData* const, int, WebPDemuxState* const, int); + +// Parses the WebP file given by 'data'. +// A complete WebP file must be present in 'data' for the function to succeed. +// Returns a WebPDemuxer object on successful parse, NULL otherwise. +static WEBP_INLINE WebPDemuxer* WebPDemux(const WebPData* const data) { + return WebPDemuxInternal(data, 0, NULL, WEBP_DEMUX_ABI_VERSION); +} + +// Parses the WebP file given by 'data'. +// If 'state' is non-NULL it will be set to indicate the status of the demuxer. +// Returns a WebPDemuxer object on successful parse, NULL otherwise. +static WEBP_INLINE WebPDemuxer* WebPDemuxPartial( + const WebPData* const data, WebPDemuxState* const state) { + return WebPDemuxInternal(data, 1, state, WEBP_DEMUX_ABI_VERSION); +} + +// Frees memory associated with 'dmux'. +WEBP_EXTERN(void) WebPDemuxDelete(WebPDemuxer* const dmux); + //------------------------------------------------------------------------------ #if defined(__cplusplus) || defined(c_plusplus)