2012-01-06 23:49:06 +01:00
|
|
|
// Copyright 2011 Google Inc. All Rights Reserved.
|
2011-09-22 12:55:23 +02:00
|
|
|
//
|
|
|
|
// 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/
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// RIFF container manipulation for WEBP images.
|
|
|
|
//
|
2011-09-28 05:46:09 +02:00
|
|
|
// Authors: Urvang (urvang@google.com)
|
|
|
|
// Vikas (vikasa@google.com)
|
|
|
|
|
|
|
|
// This API allows manipulation of WebP container images containing features
|
|
|
|
// like Color profile, XMP metadata, Animation & Tiling.
|
|
|
|
//
|
|
|
|
// Code Example#1: Creating a MUX with image data, color profile & XMP metadata.
|
|
|
|
//
|
|
|
|
// int copy_data = 0;
|
|
|
|
// WebPMux* mux = WebPMuxNew();
|
|
|
|
// // ... (Prepare image data).
|
2011-11-22 10:10:41 +01:00
|
|
|
// WebPMuxSetImage(mux, image_data, image_data_size, alpha_data, alpha_size,
|
|
|
|
// copy_data);
|
2011-09-28 05:46:09 +02:00
|
|
|
// // ... (Prepare ICCP color profile data).
|
|
|
|
// WebPMuxSetColorProfile(mux, icc_data, icc_data_size, copy_data);
|
|
|
|
// // ... (Prepare XMP metadata).
|
|
|
|
// WebPMuxSetMetadata(mux, xmp_data, xmp_data_size, copy_data);
|
|
|
|
// // Get data from mux in WebP RIFF format.
|
|
|
|
// WebPMuxAssemble(mux, &output_data, &output_data_size);
|
|
|
|
// WebPMuxDelete(mux);
|
|
|
|
// // ... (Consume output_data; e.g. write output_data to file).
|
|
|
|
// free(output_data);
|
|
|
|
//
|
|
|
|
// Code Example#2: Get image & color profile data from a WebP file.
|
|
|
|
//
|
|
|
|
// int copy_data = 0;
|
|
|
|
// // ... (Read data from file).
|
2012-01-13 10:16:30 +01:00
|
|
|
// WebPMux* mux = WebPMuxCreate(data, data_size, copy_data, NULL);
|
2012-01-07 21:44:01 +01:00
|
|
|
// WebPMuxGetImage(mux, &image, &alpha);
|
|
|
|
// // ... (Consume image; e.g. call WebPDecode() to decode the data).
|
|
|
|
// WebPMuxGetColorProfile(mux, &icc_profile);
|
2011-09-28 05:46:09 +02:00
|
|
|
// // ... (Consume icc_data).
|
|
|
|
// WebPMuxDelete(mux);
|
|
|
|
// free(data);
|
2011-09-22 12:55:23 +02:00
|
|
|
|
|
|
|
#ifndef WEBP_WEBP_MUX_H_
|
|
|
|
#define WEBP_WEBP_MUX_H_
|
|
|
|
|
2011-12-01 09:15:01 +01:00
|
|
|
#include "./types.h"
|
2011-09-22 12:55:23 +02:00
|
|
|
|
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-04-26 02:27:16 +02:00
|
|
|
#define WEBP_MUX_ABI_VERSION 0x0000
|
|
|
|
|
2011-09-22 12:55:23 +02:00
|
|
|
// Error codes
|
|
|
|
typedef enum {
|
|
|
|
WEBP_MUX_OK = 1,
|
|
|
|
WEBP_MUX_ERROR = 0,
|
|
|
|
WEBP_MUX_NOT_FOUND = -1,
|
|
|
|
WEBP_MUX_INVALID_ARGUMENT = -2,
|
|
|
|
WEBP_MUX_INVALID_PARAMETER = -3,
|
|
|
|
WEBP_MUX_BAD_DATA = -4,
|
2012-01-13 10:16:30 +01:00
|
|
|
WEBP_MUX_MEMORY_ERROR = -5,
|
|
|
|
WEBP_MUX_NOT_ENOUGH_DATA = -6
|
2011-09-22 12:55:23 +02:00
|
|
|
} WebPMuxError;
|
|
|
|
|
2012-01-13 10:16:30 +01:00
|
|
|
typedef enum {
|
|
|
|
WEBP_MUX_STATE_PARTIAL = 0,
|
|
|
|
WEBP_MUX_STATE_COMPLETE = 1,
|
|
|
|
WEBP_MUX_STATE_ERROR = -1
|
|
|
|
} WebPMuxState;
|
|
|
|
|
2011-09-22 12:55:23 +02:00
|
|
|
// Flag values for different features used in VP8X chunk.
|
|
|
|
typedef enum {
|
|
|
|
TILE_FLAG = 0x00000001,
|
|
|
|
ANIMATION_FLAG = 0x00000002,
|
|
|
|
ICCP_FLAG = 0x00000004,
|
2011-11-22 10:10:41 +01:00
|
|
|
META_FLAG = 0x00000008,
|
|
|
|
ALPHA_FLAG = 0x00000010
|
2011-09-22 12:55:23 +02:00
|
|
|
} FeatureFlags;
|
|
|
|
|
|
|
|
typedef struct WebPMux WebPMux; // main opaque object.
|
|
|
|
|
2012-01-07 21:44:01 +01:00
|
|
|
// Data type used to describe 'raw' data, e.g., chunk data
|
|
|
|
// (ICC profile, metadata) and WebP compressed image data.
|
|
|
|
typedef struct {
|
|
|
|
const uint8_t* bytes_;
|
2012-04-19 02:13:34 +02:00
|
|
|
size_t size_;
|
2012-01-07 21:44:01 +01:00
|
|
|
} WebPData;
|
|
|
|
|
2011-09-22 12:55:23 +02:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Life of a Mux object
|
|
|
|
|
2012-04-26 02:27:16 +02:00
|
|
|
// Internal, version-checked, entry point
|
|
|
|
WEBP_EXTERN(WebPMux*) WebPNewInternal(int);
|
|
|
|
|
2011-09-22 12:55:23 +02:00
|
|
|
// Creates an empty mux object.
|
|
|
|
// Returns:
|
|
|
|
// A pointer to the newly created empty mux object.
|
2012-04-26 02:27:16 +02:00
|
|
|
static WEBP_INLINE WebPMux* WebPMuxNew(void) {
|
|
|
|
return WebPNewInternal(WEBP_MUX_ABI_VERSION);
|
|
|
|
}
|
2011-09-22 12:55:23 +02:00
|
|
|
|
|
|
|
// Deletes the mux object.
|
2011-09-28 05:46:09 +02:00
|
|
|
// Parameters:
|
|
|
|
// mux - (in/out) object to be deleted
|
2011-09-22 12:55:23 +02:00
|
|
|
WEBP_EXTERN(void) WebPMuxDelete(WebPMux* const mux);
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2011-09-28 05:46:09 +02:00
|
|
|
// Mux creation.
|
2011-09-22 12:55:23 +02:00
|
|
|
|
2012-04-26 02:27:16 +02:00
|
|
|
// Internal, version-checked, entry point
|
|
|
|
WEBP_EXTERN(WebPMux*) WebPMuxCreateInternal(const uint8_t*, size_t,
|
|
|
|
int, WebPMuxState* const, int);
|
|
|
|
|
2011-09-22 12:55:23 +02:00
|
|
|
// Creates a mux object from raw data given in WebP RIFF format.
|
2011-09-28 05:46:09 +02:00
|
|
|
// Parameters:
|
|
|
|
// data - (in) the raw data in WebP RIFF format
|
|
|
|
// size - (in) size of raw data
|
|
|
|
// copy_data - (in) value 1 indicates given data WILL copied to the mux, and
|
|
|
|
// value 0 indicates data will NOT be copied.
|
2012-01-13 10:16:30 +01:00
|
|
|
// mux_state - (out) indicates the state of the mux returned. Can be passed
|
|
|
|
// NULL if not required.
|
2011-09-22 12:55:23 +02:00
|
|
|
// Returns:
|
2011-09-28 05:46:09 +02:00
|
|
|
// A pointer to the mux object created from given data - on success.
|
|
|
|
// NULL - In case of invalid data or memory error.
|
2012-04-26 02:27:16 +02:00
|
|
|
static WEBP_INLINE WebPMux* WebPMuxCreate(const uint8_t* data, size_t size,
|
|
|
|
int copy_data,
|
|
|
|
WebPMuxState* const mux_state) {
|
|
|
|
return WebPMuxCreateInternal(
|
|
|
|
data, size, copy_data, mux_state, WEBP_MUX_ABI_VERSION);
|
|
|
|
}
|
2011-09-28 05:46:09 +02:00
|
|
|
|
2011-11-22 10:10:41 +01:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Single Image.
|
|
|
|
|
|
|
|
// Sets the image in the mux object. Any existing images (including frame/tile)
|
|
|
|
// will be removed.
|
|
|
|
// Parameters:
|
|
|
|
// mux - (in/out) object in which the image is to be set
|
|
|
|
// data - (in) the image data to be set. The data can be either a VP8
|
|
|
|
// bitstream or a single-image WebP file (non-animated & non-tiled)
|
|
|
|
// size - (in) size of the image data
|
|
|
|
// alpha_data - (in) the alpha data corresponding to the image (if present)
|
|
|
|
// alpha_size - (in) size of alpha chunk data
|
|
|
|
// copy_data - (in) value 1 indicates given data WILL copied to the mux, and
|
|
|
|
// value 0 indicates data will NOT be copied.
|
|
|
|
// Returns:
|
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or data is NULL.
|
|
|
|
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
|
|
|
|
// WEBP_MUX_OK - on success.
|
2012-02-18 00:13:09 +01:00
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxSetImage(
|
|
|
|
WebPMux* const mux,
|
2012-04-19 02:13:34 +02:00
|
|
|
const uint8_t* data, size_t size,
|
|
|
|
const uint8_t* alpha_data, size_t alpha_size,
|
2012-02-18 00:13:09 +01:00
|
|
|
int copy_data);
|
2011-11-22 10:10:41 +01:00
|
|
|
|
|
|
|
// Gets a reference to the image in the mux object.
|
|
|
|
// The caller should NOT free the returned data.
|
|
|
|
// Parameters:
|
|
|
|
// mux - (in) object from which the image is to be fetched
|
2012-01-07 21:44:01 +01:00
|
|
|
// image - (out) the image data
|
|
|
|
// alpha - (out) the alpha data of the image (if present)
|
2011-11-22 10:10:41 +01:00
|
|
|
// Returns:
|
2012-02-17 02:41:29 +01:00
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if either mux or both image & alpha are NULL
|
|
|
|
// OR mux contains animation/tiling.
|
2011-11-22 10:10:41 +01:00
|
|
|
// WEBP_MUX_NOT_FOUND - if image is not present in mux object.
|
|
|
|
// WEBP_MUX_OK - on success.
|
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxGetImage(const WebPMux* const mux,
|
2012-01-07 21:44:01 +01:00
|
|
|
WebPData* const image,
|
|
|
|
WebPData* const alpha);
|
2011-11-22 10:10:41 +01:00
|
|
|
|
|
|
|
// Deletes the image in the mux object.
|
|
|
|
// Parameters:
|
|
|
|
// mux - (in/out) object from which the image is to be deleted
|
|
|
|
// Returns:
|
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
|
|
|
|
// OR if mux contains animation/tiling.
|
|
|
|
// WEBP_MUX_NOT_FOUND - if image is not present in mux object.
|
|
|
|
// WEBP_MUX_OK - on success.
|
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteImage(WebPMux* const mux);
|
|
|
|
|
2011-09-28 05:46:09 +02:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// XMP Metadata.
|
2011-09-22 12:55:23 +02:00
|
|
|
|
|
|
|
// Sets the XMP metadata in the mux object. Any existing metadata chunk(s) will
|
|
|
|
// be removed.
|
2011-09-28 05:46:09 +02:00
|
|
|
// Parameters:
|
|
|
|
// mux - (in/out) object to which the XMP metadata is to be added
|
|
|
|
// data - (in) the XMP metadata data to be added
|
|
|
|
// size - (in) size of the XMP metadata data
|
|
|
|
// copy_data - (in) value 1 indicates given data WILL copied to the mux, and
|
|
|
|
// value 0 indicates data will NOT be copied.
|
2011-09-22 12:55:23 +02:00
|
|
|
// Returns:
|
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or data is NULL.
|
|
|
|
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
|
|
|
|
// WEBP_MUX_OK - on success.
|
2012-02-18 00:13:09 +01:00
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxSetMetadata(
|
2012-04-19 02:13:34 +02:00
|
|
|
WebPMux* const mux, const uint8_t* data, size_t size, int copy_data);
|
2011-09-22 12:55:23 +02:00
|
|
|
|
2011-09-28 05:46:09 +02:00
|
|
|
// Gets a reference to the XMP metadata in the mux object.
|
|
|
|
// The caller should NOT free the returned data.
|
|
|
|
// Parameters:
|
|
|
|
// mux - (in) object from which the XMP metadata is to be fetched
|
2012-01-07 21:44:01 +01:00
|
|
|
// metadata - (out) XMP metadata
|
2011-09-28 05:46:09 +02:00
|
|
|
// Returns:
|
2012-01-07 21:44:01 +01:00
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if either mux or metadata is NULL.
|
2011-09-28 05:46:09 +02:00
|
|
|
// WEBP_MUX_NOT_FOUND - if metadata is not present in mux object.
|
|
|
|
// WEBP_MUX_OK - on success.
|
2012-01-07 21:44:01 +01:00
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxGetMetadata(
|
|
|
|
const WebPMux* const mux, WebPData* const metadata);
|
2011-09-28 05:46:09 +02:00
|
|
|
|
|
|
|
// Deletes the XMP metadata in the mux object.
|
|
|
|
// Parameters:
|
|
|
|
// mux - (in/out) object from which XMP metadata is to be deleted
|
|
|
|
// Returns:
|
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
|
|
|
|
// WEBP_MUX_NOT_FOUND - If mux does not contain metadata.
|
|
|
|
// WEBP_MUX_OK - on success.
|
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteMetadata(WebPMux* const mux);
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// ICC Color Profile.
|
|
|
|
|
2011-09-22 12:55:23 +02:00
|
|
|
// Sets the color profile in the mux object. Any existing color profile chunk(s)
|
|
|
|
// will be removed.
|
2011-09-28 05:46:09 +02:00
|
|
|
// Parameters:
|
|
|
|
// mux - (in/out) object to which the color profile is to be added
|
|
|
|
// data - (in) the color profile data to be added
|
|
|
|
// size - (in) size of the color profile data
|
|
|
|
// copy_data - (in) value 1 indicates given data WILL copied to the mux, and
|
|
|
|
// value 0 indicates data will NOT be copied.
|
2011-09-22 12:55:23 +02:00
|
|
|
// Returns:
|
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or data is NULL
|
|
|
|
// WEBP_MUX_MEMORY_ERROR - on memory allocation error
|
|
|
|
// WEBP_MUX_OK - on success
|
2012-02-18 00:13:09 +01:00
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxSetColorProfile(
|
2012-04-19 02:13:34 +02:00
|
|
|
WebPMux* const mux, const uint8_t* data, size_t size, int copy_data);
|
2011-09-22 12:55:23 +02:00
|
|
|
|
2011-09-28 05:46:09 +02:00
|
|
|
// Gets a reference to the color profile in the mux object.
|
|
|
|
// The caller should NOT free the returned data.
|
|
|
|
// Parameters:
|
|
|
|
// mux - (in) object from which the color profile data is to be fetched
|
2012-01-07 21:44:01 +01:00
|
|
|
// color_profile - (out) color profile data
|
2011-09-28 05:46:09 +02:00
|
|
|
// Returns:
|
2012-01-07 21:44:01 +01:00
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if either mux or color_profile is NULL.
|
2011-09-28 05:46:09 +02:00
|
|
|
// WEBP_MUX_NOT_FOUND - if color profile is not present in mux object.
|
|
|
|
// WEBP_MUX_OK - on success.
|
2012-01-07 21:44:01 +01:00
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxGetColorProfile(
|
|
|
|
const WebPMux* const mux, WebPData* const color_profile);
|
2011-09-28 05:46:09 +02:00
|
|
|
|
|
|
|
// Deletes the color profile in the mux object.
|
|
|
|
// Parameters:
|
|
|
|
// mux - (in/out) object from which color profile is to be deleted
|
2011-09-22 12:55:23 +02:00
|
|
|
// Returns:
|
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
|
2011-09-28 05:46:09 +02:00
|
|
|
// WEBP_MUX_NOT_FOUND - If mux does not contain color profile.
|
2011-09-22 12:55:23 +02:00
|
|
|
// WEBP_MUX_OK - on success.
|
2011-09-28 05:46:09 +02:00
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteColorProfile(WebPMux* const mux);
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Animation.
|
2011-09-22 12:55:23 +02:00
|
|
|
|
|
|
|
// Adds an animation frame to the mux object.
|
|
|
|
// nth=0 has a special meaning - last position.
|
2011-09-28 05:46:09 +02:00
|
|
|
// Parameters:
|
|
|
|
// mux - (in/out) object to which an animation frame is to be added
|
|
|
|
// nth - (in) The position at which the frame is to be added.
|
2011-11-22 10:10:41 +01:00
|
|
|
// data - (in) the raw VP8 image data corresponding to frame image. The data
|
|
|
|
// can be either a VP8 bitstream or a single-image WebP file
|
|
|
|
// (non-animated & non-tiled)
|
2011-09-28 05:46:09 +02:00
|
|
|
// size - (in) size of frame chunk data
|
2011-11-22 10:10:41 +01:00
|
|
|
// alpha_data - (in) the alpha data corresponding to frame image (if present)
|
|
|
|
// alpha_size - (in) size of alpha chunk data
|
2011-09-28 05:46:09 +02:00
|
|
|
// x_offset - (in) x-offset of the frame to be added
|
|
|
|
// y_offset - (in) y-offset of the frame to be added
|
|
|
|
// duration - (in) duration of the frame to be added (in milliseconds)
|
|
|
|
// copy_data - (in) value 1 indicates given data WILL copied to the mux, and
|
|
|
|
// value 0 indicates data will NOT be copied.
|
2011-09-22 12:55:23 +02:00
|
|
|
// Returns:
|
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or data is NULL
|
|
|
|
// WEBP_MUX_NOT_FOUND - If we have less than (nth-1) frames before adding.
|
|
|
|
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
|
|
|
|
// WEBP_MUX_OK - on success.
|
2012-02-18 00:13:09 +01:00
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxAddFrame(
|
|
|
|
WebPMux* const mux, uint32_t nth,
|
2012-04-19 02:13:34 +02:00
|
|
|
const uint8_t* data, size_t size,
|
|
|
|
const uint8_t* alpha_data, size_t alpha_size,
|
2012-02-18 00:13:09 +01:00
|
|
|
uint32_t x_offset, uint32_t y_offset, uint32_t duration,
|
|
|
|
int copy_data);
|
2011-09-22 12:55:23 +02:00
|
|
|
|
2011-11-22 10:10:41 +01:00
|
|
|
// TODO(urvang): Create a struct as follows to reduce argument list size:
|
|
|
|
// typedef struct {
|
|
|
|
// int nth;
|
|
|
|
// uint8_t* data;
|
|
|
|
// uint32_t data_size;
|
|
|
|
// uint8_t* alpha;
|
|
|
|
// uint32_t alpha_size;
|
|
|
|
// uint32_t x_offset, y_offset;
|
|
|
|
// uint32_t duration;
|
|
|
|
// } FrameInfo;
|
|
|
|
|
2011-09-28 05:46:09 +02:00
|
|
|
// Gets a reference to the nth animation frame from the mux object.
|
|
|
|
// The caller should NOT free the returned data.
|
2011-09-22 12:55:23 +02:00
|
|
|
// nth=0 has a special meaning - last position.
|
2011-09-28 05:46:09 +02:00
|
|
|
// Parameters:
|
|
|
|
// mux - (in) object from which the info is to be fetched
|
|
|
|
// nth - (in) index of the frame in the mux object
|
2012-01-07 21:44:01 +01:00
|
|
|
// image - (out) the image data
|
|
|
|
// alpha - (out) the alpha data corresponding to frame image (if present)
|
2011-09-28 05:46:09 +02:00
|
|
|
// x_offset - (out) x-offset of the returned frame
|
|
|
|
// y_offset - (out) y-offset of the returned frame
|
|
|
|
// duration - (out) duration of the returned frame (in milliseconds)
|
2011-09-22 12:55:23 +02:00
|
|
|
// Returns:
|
2012-01-07 21:44:01 +01:00
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if either mux, image, x_offset,
|
2011-09-28 05:46:09 +02:00
|
|
|
// y_offset, or duration is NULL
|
|
|
|
// WEBP_MUX_NOT_FOUND - if there are less than nth frames in the mux object.
|
|
|
|
// WEBP_MUX_BAD_DATA - if nth frame chunk in mux is invalid.
|
2011-09-22 12:55:23 +02:00
|
|
|
// WEBP_MUX_OK - on success.
|
2012-02-18 00:13:09 +01:00
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxGetFrame(
|
|
|
|
const WebPMux* const mux, uint32_t nth,
|
|
|
|
WebPData* const image, WebPData* const alpha,
|
|
|
|
uint32_t* x_offset, uint32_t* y_offset, uint32_t* duration);
|
2011-09-22 12:55:23 +02:00
|
|
|
|
|
|
|
// Deletes an animation frame from the mux object.
|
|
|
|
// nth=0 has a special meaning - last position.
|
2011-09-28 05:46:09 +02:00
|
|
|
// Parameters:
|
|
|
|
// mux - (in/out) object from which a frame is to be deleted
|
|
|
|
// nth - (in) The position from which the frame is to be deleted
|
2011-09-22 12:55:23 +02:00
|
|
|
// Returns:
|
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
|
|
|
|
// WEBP_MUX_NOT_FOUND - If there are less than nth frames in the mux object
|
|
|
|
// before deletion.
|
|
|
|
// WEBP_MUX_OK - on success.
|
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteFrame(WebPMux* const mux, uint32_t nth);
|
|
|
|
|
2011-09-28 05:46:09 +02:00
|
|
|
// Sets the animation loop count in the mux object. Any existing loop count
|
|
|
|
// value(s) will be removed.
|
|
|
|
// Parameters:
|
|
|
|
// mux - (in/out) object in which loop chunk is to be set/added
|
|
|
|
// loop_count - (in) animation loop count value.
|
|
|
|
// Note that loop_count of zero denotes infinite loop.
|
2011-09-22 12:55:23 +02:00
|
|
|
// Returns:
|
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
|
|
|
|
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
|
|
|
|
// WEBP_MUX_OK - on success.
|
2011-09-28 05:46:09 +02:00
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxSetLoopCount(WebPMux* const mux,
|
|
|
|
uint32_t loop_count);
|
2011-09-22 12:55:23 +02:00
|
|
|
|
|
|
|
// Gets the animation loop count from the mux object.
|
2011-09-28 05:46:09 +02:00
|
|
|
// Parameters:
|
|
|
|
// mux - (in) object from which the loop count is to be fetched
|
|
|
|
// loop_count - (out) the loop_count value present in the LOOP chunk
|
2011-09-22 12:55:23 +02:00
|
|
|
// Returns:
|
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if either of mux or loop_count is NULL
|
|
|
|
// WEBP_MUX_NOT_FOUND - if loop chunk is not present in mux object.
|
|
|
|
// WEBP_MUX_OK - on success.
|
2011-09-28 05:46:09 +02:00
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxGetLoopCount(const WebPMux* const mux,
|
2011-09-22 12:55:23 +02:00
|
|
|
uint32_t* loop_count);
|
|
|
|
|
2011-09-28 05:46:09 +02:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Tiling.
|
|
|
|
|
|
|
|
// Adds a tile to the mux object.
|
2011-09-22 12:55:23 +02:00
|
|
|
// nth=0 has a special meaning - last position.
|
2011-09-28 05:46:09 +02:00
|
|
|
// Parameters:
|
|
|
|
// mux - (in/out) object to which a tile is to be added
|
|
|
|
// nth - (in) The position at which the tile is to be added.
|
2011-11-22 10:10:41 +01:00
|
|
|
// data - (in) the raw VP8 image data corresponding to tile image. The data
|
|
|
|
// can be either a VP8 bitstream or a single-image WebP file
|
|
|
|
// (non-animated & non-tiled)
|
2011-09-28 05:46:09 +02:00
|
|
|
// size - (in) size of tile chunk data
|
2011-11-22 10:10:41 +01:00
|
|
|
// alpha_data - (in) the alpha data corresponding to tile image (if present)
|
|
|
|
// alpha_size - (in) size of alpha chunk data
|
2011-09-28 05:46:09 +02:00
|
|
|
// x_offset - (in) x-offset of the tile to be added
|
|
|
|
// y_offset - (in) y-offset of the tile to be added
|
|
|
|
// copy_data - (in) value 1 indicates given data WILL copied to the mux, and
|
|
|
|
// value 0 indicates data will NOT be copied.
|
2011-09-22 12:55:23 +02:00
|
|
|
// Returns:
|
2011-09-28 05:46:09 +02:00
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or data is NULL
|
|
|
|
// WEBP_MUX_NOT_FOUND - If we have less than (nth-1) tiles before adding.
|
|
|
|
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
|
2011-09-22 12:55:23 +02:00
|
|
|
// WEBP_MUX_OK - on success.
|
2012-02-18 00:13:09 +01:00
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxAddTile(
|
|
|
|
WebPMux* const mux, uint32_t nth,
|
2012-04-19 02:13:34 +02:00
|
|
|
const uint8_t* data, size_t size,
|
|
|
|
const uint8_t* alpha_data, size_t alpha_size,
|
2012-02-18 00:13:09 +01:00
|
|
|
uint32_t x_offset, uint32_t y_offset,
|
|
|
|
int copy_data);
|
2011-09-22 12:55:23 +02:00
|
|
|
|
|
|
|
// Gets a reference to the nth tile from the mux object.
|
2011-09-28 05:46:09 +02:00
|
|
|
// The caller should NOT free the returned data.
|
2011-09-22 12:55:23 +02:00
|
|
|
// nth=0 has a special meaning - last position.
|
2011-09-28 05:46:09 +02:00
|
|
|
// Parameters:
|
|
|
|
// mux - (in) object from which the info is to be fetched
|
|
|
|
// nth - (in) index of the tile in the mux object
|
2012-01-07 21:44:01 +01:00
|
|
|
// image - (out) the image data
|
|
|
|
// alpha - (out) the alpha data corresponding to tile image (if present)
|
2011-09-28 05:46:09 +02:00
|
|
|
// x_offset - (out) x-offset of the returned tile
|
|
|
|
// y_offset - (out) y-offset of the returned tile
|
2011-09-22 12:55:23 +02:00
|
|
|
// Returns:
|
2012-01-07 21:44:01 +01:00
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if either mux, image, x_offset or
|
2011-09-22 12:55:23 +02:00
|
|
|
// y_offset is NULL
|
|
|
|
// WEBP_MUX_NOT_FOUND - if there are less than nth tiles in the mux object.
|
|
|
|
// WEBP_MUX_BAD_DATA - if nth tile chunk in mux is invalid.
|
|
|
|
// WEBP_MUX_OK - on success.
|
2012-02-18 00:13:09 +01:00
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxGetTile(
|
|
|
|
const WebPMux* const mux, uint32_t nth,
|
|
|
|
WebPData* const image, WebPData* const alpha,
|
|
|
|
uint32_t* x_offset, uint32_t* y_offset);
|
2011-09-22 12:55:23 +02:00
|
|
|
|
2011-09-28 05:46:09 +02:00
|
|
|
// Deletes a tile from the mux object.
|
|
|
|
// nth=0 has a special meaning - last position
|
|
|
|
// Parameters:
|
|
|
|
// mux - (in/out) object from which a tile is to be deleted
|
|
|
|
// nth - (in) The position from which the tile is to be deleted
|
2011-09-22 12:55:23 +02:00
|
|
|
// Returns:
|
2011-09-28 05:46:09 +02:00
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
|
|
|
|
// WEBP_MUX_NOT_FOUND - If there are less than nth tiles in the mux object
|
|
|
|
// before deletion.
|
2011-09-22 12:55:23 +02:00
|
|
|
// WEBP_MUX_OK - on success.
|
2011-09-28 05:46:09 +02:00
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteTile(WebPMux* const mux, uint32_t nth);
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Misc Utilities.
|
|
|
|
|
|
|
|
// Gets the feature flags from the mux object.
|
|
|
|
// Parameters:
|
|
|
|
// mux - (in) object from which the features are to be fetched
|
|
|
|
// flags - (out) the flags specifying which features are present in the
|
|
|
|
// mux object. This will be an OR of various flag values.
|
|
|
|
// Enum 'FeatureFlags' can be used to test for individual flag values.
|
|
|
|
// Returns:
|
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or flags is NULL
|
|
|
|
// WEBP_MUX_NOT_FOUND - if VP8X chunk is not present in mux object.
|
|
|
|
// WEBP_MUX_BAD_DATA - if VP8X chunk in mux is invalid.
|
|
|
|
// WEBP_MUX_OK - on success.
|
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxGetFeatures(const WebPMux* const mux,
|
|
|
|
uint32_t* flags);
|
|
|
|
|
|
|
|
// Gets number of chunks having tag value tag in the mux object.
|
|
|
|
// Parameters:
|
|
|
|
// mux - (in) object from which the info is to be fetched
|
|
|
|
// tag - (in) tag name specifying the type of chunk
|
|
|
|
// num_elements - (out) number of chunks corresponding to the specified tag
|
|
|
|
// Returns:
|
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if either mux, tag or num_elements is NULL
|
|
|
|
// WEBP_MUX_OK - on success.
|
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxNumNamedElements(const WebPMux* const mux,
|
|
|
|
const char* tag,
|
|
|
|
int* num_elements);
|
|
|
|
|
|
|
|
// Assembles all chunks in WebP RIFF format and returns in output_data.
|
|
|
|
// This function also validates the mux object.
|
|
|
|
// The content of '*output_data' is allocated using malloc(), and NOT
|
|
|
|
// owned by the 'mux' object.
|
|
|
|
// It MUST be deallocated by the caller by calling free().
|
|
|
|
// Parameters:
|
|
|
|
// mux - (in/out) object whose chunks are to be assembled
|
|
|
|
// output_data - (out) byte array where assembled WebP data is returned
|
|
|
|
// output_size - (out) size of returned data
|
|
|
|
// Returns:
|
|
|
|
// WEBP_MUX_BAD_DATA - if mux object is invalid.
|
|
|
|
// WEBP_MUX_INVALID_ARGUMENT - if either mux, output_data or output_size is
|
|
|
|
// NULL.
|
|
|
|
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
|
|
|
|
// WEBP_MUX_OK - on success
|
|
|
|
WEBP_EXTERN(WebPMuxError) WebPMuxAssemble(WebPMux* const mux,
|
|
|
|
uint8_t** output_data,
|
2012-04-19 02:13:34 +02:00
|
|
|
size_t* output_size);
|
2011-09-28 05:46:09 +02:00
|
|
|
|
2011-09-22 12:55:23 +02:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* WEBP_WEBP_MUX_H_ */
|