mux.h: remove '* const' from function parameters

makes the public interface consistent and more readable

Change-Id: I33f1d1c4ee752e353e4c10636a4df4e44d7cd03f
This commit is contained in:
James Zern 2012-07-17 15:01:30 -07:00
parent 31426ebaec
commit a3ec6225d5
5 changed files with 97 additions and 106 deletions

View File

@ -623,9 +623,8 @@ static void InitDemux(WebPDemuxer* const dmux, const MemBuffer* const mem) {
dmux->mem_ = *mem; dmux->mem_ = *mem;
} }
WebPDemuxer* WebPDemuxInternal( WebPDemuxer* WebPDemuxInternal(const WebPData* data, int allow_partial,
const WebPData* const data, int allow_partial, WebPDemuxState* state, int version) {
WebPDemuxState* const state, int version) {
const ChunkParser* parser; const ChunkParser* parser;
int partial; int partial;
ParseStatus status = PARSE_ERROR; ParseStatus status = PARSE_ERROR;
@ -662,7 +661,7 @@ WebPDemuxer* WebPDemuxInternal(
return dmux; return dmux;
} }
void WebPDemuxDelete(WebPDemuxer* const dmux) { void WebPDemuxDelete(WebPDemuxer* dmux) {
Chunk* c; Chunk* c;
Frame* f; Frame* f;
if (dmux == NULL) return; if (dmux == NULL) return;
@ -682,8 +681,7 @@ void WebPDemuxDelete(WebPDemuxer* const dmux) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
uint32_t WebPDemuxGetI(const WebPDemuxer* const dmux, uint32_t WebPDemuxGetI(const WebPDemuxer* dmux, WebPFormatFeature feature) {
WebPFormatFeature feature) {
if (dmux == NULL) return 0; if (dmux == NULL) return 0;
switch (feature) { switch (feature) {
@ -784,8 +782,7 @@ static int SetFrame(int frame_num, WebPIterator* const iter) {
return SynthesizeFrame(dmux, frame, 1, iter); return SynthesizeFrame(dmux, frame, 1, iter);
} }
int WebPDemuxGetFrame(const WebPDemuxer* const dmux, int WebPDemuxGetFrame(const WebPDemuxer* dmux, int frame, WebPIterator* iter) {
int frame, WebPIterator* const iter) {
if (iter == NULL) return 0; if (iter == NULL) return 0;
memset(iter, 0, sizeof(*iter)); memset(iter, 0, sizeof(*iter));
@ -793,18 +790,18 @@ int WebPDemuxGetFrame(const WebPDemuxer* const dmux,
return SetFrame(frame, iter); return SetFrame(frame, iter);
} }
int WebPDemuxNextFrame(WebPIterator* const iter) { int WebPDemuxNextFrame(WebPIterator* iter) {
if (iter == NULL) return 0; if (iter == NULL) return 0;
return SetFrame(iter->frame_num_ + 1, iter); return SetFrame(iter->frame_num_ + 1, iter);
} }
int WebPDemuxPrevFrame(WebPIterator* const iter) { int WebPDemuxPrevFrame(WebPIterator* iter) {
if (iter == NULL) return 0; if (iter == NULL) return 0;
if (iter->frame_num_ <= 1) return 0; if (iter->frame_num_ <= 1) return 0;
return SetFrame(iter->frame_num_ - 1, iter); return SetFrame(iter->frame_num_ - 1, iter);
} }
int WebPDemuxSelectTile(WebPIterator* const iter, int tile) { int WebPDemuxSelectTile(WebPIterator* iter, int tile) {
if (iter != NULL && iter->private_ != NULL && tile > 0) { if (iter != NULL && iter->private_ != NULL && tile > 0) {
const WebPDemuxer* const dmux = (WebPDemuxer*)iter->private_; const WebPDemuxer* const dmux = (WebPDemuxer*)iter->private_;
const Frame* const frame = GetFrame(dmux, iter->frame_num_); const Frame* const frame = GetFrame(dmux, iter->frame_num_);
@ -815,7 +812,7 @@ int WebPDemuxSelectTile(WebPIterator* const iter, int tile) {
return 0; return 0;
} }
void WebPDemuxReleaseIterator(WebPIterator* const iter) { void WebPDemuxReleaseIterator(WebPIterator* iter) {
(void)iter; (void)iter;
} }
@ -868,9 +865,9 @@ static int SetChunk(const char fourcc[4], int chunk_num,
return 0; return 0;
} }
int WebPDemuxGetChunk(const WebPDemuxer* const dmux, int WebPDemuxGetChunk(const WebPDemuxer* dmux,
const char fourcc[4], int chunk_num, const char fourcc[4], int chunk_num,
WebPChunkIterator* const iter) { WebPChunkIterator* iter) {
if (iter == NULL) return 0; if (iter == NULL) return 0;
memset(iter, 0, sizeof(*iter)); memset(iter, 0, sizeof(*iter));
@ -878,7 +875,7 @@ int WebPDemuxGetChunk(const WebPDemuxer* const dmux,
return SetChunk(fourcc, chunk_num, iter); return SetChunk(fourcc, chunk_num, iter);
} }
int WebPDemuxNextChunk(WebPChunkIterator* const iter) { int WebPDemuxNextChunk(WebPChunkIterator* iter) {
if (iter != NULL) { if (iter != NULL) {
const char* const fourcc = const char* const fourcc =
(const char*)iter->chunk_.bytes_ - CHUNK_HEADER_SIZE; (const char*)iter->chunk_.bytes_ - CHUNK_HEADER_SIZE;
@ -887,7 +884,7 @@ int WebPDemuxNextChunk(WebPChunkIterator* const iter) {
return 0; return 0;
} }
int WebPDemuxPrevChunk(WebPChunkIterator* const iter) { int WebPDemuxPrevChunk(WebPChunkIterator* iter) {
if (iter != NULL && iter->chunk_num_ > 1) { if (iter != NULL && iter->chunk_num_ > 1) {
const char* const fourcc = const char* const fourcc =
(const char*)iter->chunk_.bytes_ - CHUNK_HEADER_SIZE; (const char*)iter->chunk_.bytes_ - CHUNK_HEADER_SIZE;
@ -896,7 +893,7 @@ int WebPDemuxPrevChunk(WebPChunkIterator* const iter) {
return 0; return 0;
} }
void WebPDemuxReleaseChunkIterator(WebPChunkIterator* const iter) { void WebPDemuxReleaseChunkIterator(WebPChunkIterator* iter) {
(void)iter; (void)iter;
} }

View File

@ -58,7 +58,7 @@ static void MuxRelease(WebPMux* const mux) {
DeleteAllChunks(&mux->unknown_); DeleteAllChunks(&mux->unknown_);
} }
void WebPMuxDelete(WebPMux* const mux) { void WebPMuxDelete(WebPMux* mux) {
// If mux is NULL MuxRelease is a noop. // If mux is NULL MuxRelease is a noop.
MuxRelease(mux); MuxRelease(mux);
free(mux); free(mux);
@ -212,8 +212,8 @@ static WebPMuxError DeleteLoopCount(WebPMux* const mux) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Set API(s). // Set API(s).
WebPMuxError WebPMuxSetImage(WebPMux* const mux, WebPMuxError WebPMuxSetImage(WebPMux* mux,
const WebPData* const bitstream, int copy_data) { const WebPData* bitstream, int copy_data) {
WebPMuxError err; WebPMuxError err;
WebPChunk chunk; WebPChunk chunk;
WebPMuxImage wpi; WebPMuxImage wpi;
@ -267,8 +267,7 @@ WebPMuxError WebPMuxSetImage(WebPMux* const mux,
return err; return err;
} }
WebPMuxError WebPMuxSetMetadata(WebPMux* const mux, WebPMuxError WebPMuxSetMetadata(WebPMux* mux, const WebPData* metadata,
const WebPData* const metadata,
int copy_data) { int copy_data) {
WebPMuxError err; WebPMuxError err;
@ -285,8 +284,7 @@ WebPMuxError WebPMuxSetMetadata(WebPMux* const mux,
return MuxSet(mux, IDX_META, 1, metadata, copy_data); return MuxSet(mux, IDX_META, 1, metadata, copy_data);
} }
WebPMuxError WebPMuxSetColorProfile(WebPMux* const mux, WebPMuxError WebPMuxSetColorProfile(WebPMux* mux, const WebPData* color_profile,
const WebPData* const color_profile,
int copy_data) { int copy_data) {
WebPMuxError err; WebPMuxError err;
@ -303,7 +301,7 @@ WebPMuxError WebPMuxSetColorProfile(WebPMux* const mux,
return MuxSet(mux, IDX_ICCP, 1, color_profile, copy_data); return MuxSet(mux, IDX_ICCP, 1, color_profile, copy_data);
} }
WebPMuxError WebPMuxSetLoopCount(WebPMux* const mux, int loop_count) { WebPMuxError WebPMuxSetLoopCount(WebPMux* mux, int loop_count) {
WebPMuxError err; WebPMuxError err;
uint8_t* data = NULL; uint8_t* data = NULL;
@ -406,16 +404,14 @@ static WebPMuxError MuxPushFrameTileInternal(
return err; return err;
} }
WebPMuxError WebPMuxPushFrame(WebPMux* const mux, WebPMuxError WebPMuxPushFrame(WebPMux* mux, const WebPData* bitstream,
const WebPData* const bitstream,
int x_offset, int y_offset, int x_offset, int y_offset,
int duration, int copy_data) { int duration, int copy_data) {
return MuxPushFrameTileInternal(mux, bitstream, x_offset, y_offset, return MuxPushFrameTileInternal(mux, bitstream, x_offset, y_offset,
duration, copy_data, kChunks[IDX_FRAME].tag); duration, copy_data, kChunks[IDX_FRAME].tag);
} }
WebPMuxError WebPMuxPushTile(WebPMux* const mux, WebPMuxError WebPMuxPushTile(WebPMux* mux, const WebPData* bitstream,
const WebPData* const bitstream,
int x_offset, int y_offset, int x_offset, int y_offset,
int copy_data) { int copy_data) {
return MuxPushFrameTileInternal(mux, bitstream, x_offset, y_offset, return MuxPushFrameTileInternal(mux, bitstream, x_offset, y_offset,
@ -426,7 +422,7 @@ WebPMuxError WebPMuxPushTile(WebPMux* const mux,
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Delete API(s). // Delete API(s).
WebPMuxError WebPMuxDeleteImage(WebPMux* const mux) { WebPMuxError WebPMuxDeleteImage(WebPMux* mux) {
WebPMuxError err; WebPMuxError err;
if (mux == NULL) return WEBP_MUX_INVALID_ARGUMENT; if (mux == NULL) return WEBP_MUX_INVALID_ARGUMENT;
@ -439,11 +435,11 @@ WebPMuxError WebPMuxDeleteImage(WebPMux* const mux) {
return WEBP_MUX_OK; return WEBP_MUX_OK;
} }
WebPMuxError WebPMuxDeleteMetadata(WebPMux* const mux) { WebPMuxError WebPMuxDeleteMetadata(WebPMux* mux) {
return MuxDeleteAllNamedData(mux, IDX_META); return MuxDeleteAllNamedData(mux, IDX_META);
} }
WebPMuxError WebPMuxDeleteColorProfile(WebPMux* const mux) { WebPMuxError WebPMuxDeleteColorProfile(WebPMux* mux) {
return MuxDeleteAllNamedData(mux, IDX_ICCP); return MuxDeleteAllNamedData(mux, IDX_ICCP);
} }
@ -456,11 +452,11 @@ static WebPMuxError DeleteFrameTileInternal(WebPMux* const mux, uint32_t nth,
return MuxImageDeleteNth(&mux->images_, nth, id); return MuxImageDeleteNth(&mux->images_, nth, id);
} }
WebPMuxError WebPMuxDeleteFrame(WebPMux* const mux, uint32_t nth) { WebPMuxError WebPMuxDeleteFrame(WebPMux* mux, uint32_t nth) {
return DeleteFrameTileInternal(mux, nth, IDX_FRAME); return DeleteFrameTileInternal(mux, nth, IDX_FRAME);
} }
WebPMuxError WebPMuxDeleteTile(WebPMux* const mux, uint32_t nth) { WebPMuxError WebPMuxDeleteTile(WebPMux* mux, uint32_t nth) {
return DeleteFrameTileInternal(mux, nth, IDX_TILE); return DeleteFrameTileInternal(mux, nth, IDX_TILE);
} }
@ -664,8 +660,7 @@ static WebPMuxError CreateVP8XChunk(WebPMux* const mux) {
return err; return err;
} }
WebPMuxError WebPMuxAssemble(WebPMux* const mux, WebPMuxError WebPMuxAssemble(WebPMux* mux, WebPData* assembled_data) {
WebPData* const assembled_data) {
size_t size = 0; size_t size = 0;
uint8_t* data = NULL; uint8_t* data = NULL;
uint8_t* dst = NULL; uint8_t* dst = NULL;

View File

@ -212,14 +212,14 @@ uint8_t* ChunkListEmit(const WebPChunk* chunk_list, uint8_t* dst) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Manipulation of a WebPData object. // Manipulation of a WebPData object.
void WebPDataClear(WebPData* const webp_data) { void WebPDataClear(WebPData* webp_data) {
if (webp_data != NULL) { if (webp_data != NULL) {
free((void*)webp_data->bytes_); free((void*)webp_data->bytes_);
memset(webp_data, 0, sizeof(*webp_data)); memset(webp_data, 0, sizeof(*webp_data));
} }
} }
int WebPDataCopy(const WebPData* const src, WebPData* const dst) { int WebPDataCopy(const WebPData* src, WebPData* dst) {
if (src == NULL || dst == NULL) return 0; if (src == NULL || dst == NULL) return 0;
memset(dst, 0, sizeof(*dst)); memset(dst, 0, sizeof(*dst));

View File

@ -76,7 +76,7 @@ static WebPMuxError ChunkVerifyAndAssignData(WebPChunk* chunk,
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Create a mux object from WebP-RIFF data. // Create a mux object from WebP-RIFF data.
WebPMux* WebPMuxCreateInternal(const WebPData* const bitstream, int copy_data, WebPMux* WebPMuxCreateInternal(const WebPData* bitstream, int copy_data,
int version) { int version) {
size_t riff_size; size_t riff_size;
uint32_t tag; uint32_t tag;
@ -188,7 +188,7 @@ WebPMux* WebPMuxCreateInternal(const WebPData* const bitstream, int copy_data,
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Get API(s). // Get API(s).
WebPMuxError WebPMuxGetFeatures(const WebPMux* const mux, uint32_t* flags) { WebPMuxError WebPMuxGetFeatures(const WebPMux* mux, uint32_t* flags) {
WebPData data; WebPData data;
WebPMuxError err; WebPMuxError err;
@ -268,8 +268,7 @@ static WebPMuxError SynthesizeBitstream(WebPMuxImage* const wpi,
return WEBP_MUX_OK; return WEBP_MUX_OK;
} }
WebPMuxError WebPMuxGetImage(const WebPMux* const mux, WebPMuxError WebPMuxGetImage(const WebPMux* mux, WebPData* bitstream) {
WebPData* const bitstream) {
WebPMuxError err; WebPMuxError err;
WebPMuxImage* wpi = NULL; WebPMuxImage* wpi = NULL;
@ -288,20 +287,18 @@ WebPMuxError WebPMuxGetImage(const WebPMux* const mux,
return SynthesizeBitstream(wpi, bitstream); return SynthesizeBitstream(wpi, bitstream);
} }
WebPMuxError WebPMuxGetMetadata(const WebPMux* const mux, WebPMuxError WebPMuxGetMetadata(const WebPMux* mux, WebPData* metadata) {
WebPData* const metadata) {
if (mux == NULL || metadata == NULL) return WEBP_MUX_INVALID_ARGUMENT; if (mux == NULL || metadata == NULL) return WEBP_MUX_INVALID_ARGUMENT;
return MuxGet(mux, IDX_META, 1, metadata); return MuxGet(mux, IDX_META, 1, metadata);
} }
WebPMuxError WebPMuxGetColorProfile(const WebPMux* const mux, WebPMuxError WebPMuxGetColorProfile(const WebPMux* mux,
WebPData* const color_profile) { WebPData* color_profile) {
if (mux == NULL || color_profile == NULL) return WEBP_MUX_INVALID_ARGUMENT; if (mux == NULL || color_profile == NULL) return WEBP_MUX_INVALID_ARGUMENT;
return MuxGet(mux, IDX_ICCP, 1, color_profile); return MuxGet(mux, IDX_ICCP, 1, color_profile);
} }
WebPMuxError WebPMuxGetLoopCount(const WebPMux* const mux, WebPMuxError WebPMuxGetLoopCount(const WebPMux* mux, int* loop_count) {
int* const loop_count) {
WebPData image; WebPData image;
WebPMuxError err; WebPMuxError err;
@ -348,16 +345,16 @@ static WebPMuxError MuxGetFrameTileInternal(
return SynthesizeBitstream(wpi, bitstream); return SynthesizeBitstream(wpi, bitstream);
} }
WebPMuxError WebPMuxGetFrame(const WebPMux* const mux, uint32_t nth, WebPMuxError WebPMuxGetFrame(const WebPMux* mux, uint32_t nth,
WebPData* const bitstream, int* const x_offset, WebPData* bitstream,
int* const y_offset, int* const duration) { int* x_offset, int* y_offset, int* duration) {
return MuxGetFrameTileInternal(mux, nth, bitstream, x_offset, y_offset, return MuxGetFrameTileInternal(mux, nth, bitstream, x_offset, y_offset,
duration, kChunks[IDX_FRAME].tag); duration, kChunks[IDX_FRAME].tag);
} }
WebPMuxError WebPMuxGetTile(const WebPMux* const mux, uint32_t nth, WebPMuxError WebPMuxGetTile(const WebPMux* mux, uint32_t nth,
WebPData* const bitstream, WebPData* bitstream,
int* const x_offset, int* const y_offset) { int* x_offset, int* y_offset) {
return MuxGetFrameTileInternal(mux, nth, bitstream, x_offset, y_offset, NULL, return MuxGetFrameTileInternal(mux, nth, bitstream, x_offset, y_offset, NULL,
kChunks[IDX_TILE].tag); kChunks[IDX_TILE].tag);
} }
@ -384,7 +381,7 @@ static int CountChunks(const WebPChunk* const chunk_list, uint32_t tag) {
return count; return count;
} }
WebPMuxError WebPMuxNumChunks(const WebPMux* const mux, WebPMuxError WebPMuxNumChunks(const WebPMux* mux,
WebPChunkId id, int* num_elements) { WebPChunkId id, int* num_elements) {
if (mux == NULL || num_elements == NULL) { if (mux == NULL || num_elements == NULL) {
return WEBP_MUX_INVALID_ARGUMENT; return WEBP_MUX_INVALID_ARGUMENT;

View File

@ -102,11 +102,11 @@ typedef struct {
// Clears the contents of the 'webp_data' object by calling free(). Does not // Clears the contents of the 'webp_data' object by calling free(). Does not
// deallocate the object itself. // deallocate the object itself.
WEBP_EXTERN(void) WebPDataClear(WebPData* const webp_data); WEBP_EXTERN(void) WebPDataClear(WebPData* webp_data);
// Allocates necessary storage for 'dst' and copies the contents of 'src'. // Allocates necessary storage for 'dst' and copies the contents of 'src'.
// Returns true on success. // Returns true on success.
WEBP_EXTERN(int) WebPDataCopy(const WebPData* const src, WebPData* const dst); WEBP_EXTERN(int) WebPDataCopy(const WebPData* src, WebPData* dst);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Life of a Mux object // Life of a Mux object
@ -124,13 +124,13 @@ static WEBP_INLINE WebPMux* WebPMuxNew(void) {
// Deletes the mux object. // Deletes the mux object.
// Parameters: // Parameters:
// mux - (in/out) object to be deleted // mux - (in/out) object to be deleted
WEBP_EXTERN(void) WebPMuxDelete(WebPMux* const mux); WEBP_EXTERN(void) WebPMuxDelete(WebPMux* mux);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Mux creation. // Mux creation.
// Internal, version-checked, entry point // Internal, version-checked, entry point
WEBP_EXTERN(WebPMux*) WebPMuxCreateInternal(const WebPData* const, int, int); WEBP_EXTERN(WebPMux*) WebPMuxCreateInternal(const WebPData*, int, int);
// Creates a mux object from raw data given in WebP RIFF format. // Creates a mux object from raw data given in WebP RIFF format.
// Parameters: // Parameters:
@ -140,7 +140,7 @@ WEBP_EXTERN(WebPMux*) WebPMuxCreateInternal(const WebPData* const, int, int);
// Returns: // Returns:
// A pointer to the mux object created from given data - on success. // A pointer to the mux object created from given data - on success.
// NULL - In case of invalid data or memory error. // NULL - In case of invalid data or memory error.
static WEBP_INLINE WebPMux* WebPMuxCreate(const WebPData* const bitstream, static WEBP_INLINE WebPMux* WebPMuxCreate(const WebPData* bitstream,
int copy_data) { int copy_data) {
return WebPMuxCreateInternal(bitstream, copy_data, WEBP_MUX_ABI_VERSION); return WebPMuxCreateInternal(bitstream, copy_data, WEBP_MUX_ABI_VERSION);
} }
@ -160,8 +160,9 @@ static WEBP_INLINE WebPMux* WebPMuxCreate(const WebPData* const bitstream,
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or bitstream is NULL. // WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or bitstream is NULL.
// WEBP_MUX_MEMORY_ERROR - on memory allocation error. // WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxSetImage( WEBP_EXTERN(WebPMuxError) WebPMuxSetImage(WebPMux* mux,
WebPMux* const mux, const WebPData* const bitstream, int copy_data); const WebPData* bitstream,
int copy_data);
// Gets image data from the mux object. // Gets image data from the mux object.
// The content of 'bitstream' is allocated using malloc(), and NOT // The content of 'bitstream' is allocated using malloc(), and NOT
@ -175,8 +176,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxSetImage(
// OR mux contains animation/tiling. // OR mux contains animation/tiling.
// WEBP_MUX_NOT_FOUND - if image is not present in mux object. // WEBP_MUX_NOT_FOUND - if image is not present in mux object.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxGetImage(const WebPMux* const mux, WEBP_EXTERN(WebPMuxError) WebPMuxGetImage(const WebPMux* mux,
WebPData* const bitstream); WebPData* bitstream);
// Deletes the image in the mux object. // Deletes the image in the mux object.
// Parameters: // Parameters:
@ -186,7 +187,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetImage(const WebPMux* const mux,
// OR if mux contains animation/tiling. // OR if mux contains animation/tiling.
// WEBP_MUX_NOT_FOUND - if image is not present in mux object. // WEBP_MUX_NOT_FOUND - if image is not present in mux object.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteImage(WebPMux* const mux); WEBP_EXTERN(WebPMuxError) WebPMuxDeleteImage(WebPMux* mux);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// XMP Metadata. // XMP Metadata.
@ -202,8 +203,9 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteImage(WebPMux* const mux);
// WEBP_MUX_INVALID_ARGUMENT - if mux or metadata is NULL. // WEBP_MUX_INVALID_ARGUMENT - if mux or metadata is NULL.
// WEBP_MUX_MEMORY_ERROR - on memory allocation error. // WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxSetMetadata( WEBP_EXTERN(WebPMuxError) WebPMuxSetMetadata(WebPMux* mux,
WebPMux* const mux, const WebPData* const metadata, int copy_data); const WebPData* metadata,
int copy_data);
// Gets a reference to the XMP metadata in the mux object. // Gets a reference to the XMP metadata in the mux object.
// The caller should NOT free the returned data. // The caller should NOT free the returned data.
@ -214,8 +216,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxSetMetadata(
// WEBP_MUX_INVALID_ARGUMENT - if either mux or metadata is NULL. // WEBP_MUX_INVALID_ARGUMENT - if either mux or metadata is NULL.
// WEBP_MUX_NOT_FOUND - if metadata is not present in mux object. // WEBP_MUX_NOT_FOUND - if metadata is not present in mux object.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxGetMetadata( WEBP_EXTERN(WebPMuxError) WebPMuxGetMetadata(const WebPMux* mux,
const WebPMux* const mux, WebPData* const metadata); WebPData* metadata);
// Deletes the XMP metadata in the mux object. // Deletes the XMP metadata in the mux object.
// Parameters: // Parameters:
@ -224,7 +226,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetMetadata(
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL // WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
// WEBP_MUX_NOT_FOUND - If mux does not contain metadata. // WEBP_MUX_NOT_FOUND - If mux does not contain metadata.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteMetadata(WebPMux* const mux); WEBP_EXTERN(WebPMuxError) WebPMuxDeleteMetadata(WebPMux* mux);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// ICC Color Profile. // ICC Color Profile.
@ -240,8 +242,9 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteMetadata(WebPMux* const mux);
// WEBP_MUX_INVALID_ARGUMENT - if mux or color_profile is NULL // WEBP_MUX_INVALID_ARGUMENT - if mux or color_profile is NULL
// WEBP_MUX_MEMORY_ERROR - on memory allocation error // WEBP_MUX_MEMORY_ERROR - on memory allocation error
// WEBP_MUX_OK - on success // WEBP_MUX_OK - on success
WEBP_EXTERN(WebPMuxError) WebPMuxSetColorProfile( WEBP_EXTERN(WebPMuxError) WebPMuxSetColorProfile(WebPMux* mux,
WebPMux* const mux, const WebPData* const color_profile, int copy_data); const WebPData* color_profile,
int copy_data);
// Gets a reference to the color profile in the mux object. // Gets a reference to the color profile in the mux object.
// The caller should NOT free the returned data. // The caller should NOT free the returned data.
@ -252,8 +255,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxSetColorProfile(
// WEBP_MUX_INVALID_ARGUMENT - if either mux or color_profile is NULL. // WEBP_MUX_INVALID_ARGUMENT - if either mux or color_profile is NULL.
// WEBP_MUX_NOT_FOUND - if color profile is not present in mux object. // WEBP_MUX_NOT_FOUND - if color profile is not present in mux object.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxGetColorProfile( WEBP_EXTERN(WebPMuxError) WebPMuxGetColorProfile(const WebPMux* mux,
const WebPMux* const mux, WebPData* const color_profile); WebPData* color_profile);
// Deletes the color profile in the mux object. // Deletes the color profile in the mux object.
// Parameters: // Parameters:
@ -262,7 +265,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetColorProfile(
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL // WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
// WEBP_MUX_NOT_FOUND - If mux does not contain color profile. // WEBP_MUX_NOT_FOUND - If mux does not contain color profile.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteColorProfile(WebPMux* const mux); WEBP_EXTERN(WebPMuxError) WebPMuxDeleteColorProfile(WebPMux* mux);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Animation. // Animation.
@ -285,7 +288,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteColorProfile(WebPMux* const mux);
// WEBP_MUX_MEMORY_ERROR - on memory allocation error. // WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxPushFrame( WEBP_EXTERN(WebPMuxError) WebPMuxPushFrame(
WebPMux* const mux, const WebPData* const bitstream, WebPMux* mux, const WebPData* bitstream,
int x_offset, int y_offset, int duration, int copy_data); int x_offset, int y_offset, int duration, int copy_data);
// TODO(urvang): Create a struct as follows to reduce argument list size: // TODO(urvang): Create a struct as follows to reduce argument list size:
@ -314,8 +317,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxPushFrame(
// WEBP_MUX_BAD_DATA - if nth frame chunk in mux is invalid. // WEBP_MUX_BAD_DATA - if nth frame chunk in mux is invalid.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxGetFrame( WEBP_EXTERN(WebPMuxError) WebPMuxGetFrame(
const WebPMux* const mux, uint32_t nth, WebPData* const bitstream, const WebPMux* mux, uint32_t nth, WebPData* bitstream,
int* const x_offset, int* const y_offset, int* const duration); int* x_offset, int* y_offset, int* duration);
// Deletes an animation frame from the mux object. // Deletes an animation frame from the mux object.
// nth=0 has a special meaning - last position. // nth=0 has a special meaning - last position.
@ -327,7 +330,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetFrame(
// WEBP_MUX_NOT_FOUND - If there are less than nth frames in the mux object // WEBP_MUX_NOT_FOUND - If there are less than nth frames in the mux object
// before deletion. // before deletion.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteFrame(WebPMux* const mux, uint32_t nth); WEBP_EXTERN(WebPMuxError) WebPMuxDeleteFrame(WebPMux* mux, uint32_t nth);
// Sets the animation loop count in the mux object. Any existing loop count // Sets the animation loop count in the mux object. Any existing loop count
// value(s) will be removed. // value(s) will be removed.
@ -339,8 +342,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteFrame(WebPMux* const mux, uint32_t nth);
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL // WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
// WEBP_MUX_MEMORY_ERROR - on memory allocation error. // WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxSetLoopCount(WebPMux* const mux, WEBP_EXTERN(WebPMuxError) WebPMuxSetLoopCount(WebPMux* mux, int loop_count);
int loop_count);
// Gets the animation loop count from the mux object. // Gets the animation loop count from the mux object.
// Parameters: // Parameters:
@ -350,8 +352,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxSetLoopCount(WebPMux* const mux,
// WEBP_MUX_INVALID_ARGUMENT - if either of mux or loop_count is NULL // 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_NOT_FOUND - if loop chunk is not present in mux object.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxGetLoopCount(const WebPMux* const mux, WEBP_EXTERN(WebPMuxError) WebPMuxGetLoopCount(const WebPMux* mux,
int* const loop_count); int* loop_count);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Tiling. // Tiling.
@ -373,7 +375,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetLoopCount(const WebPMux* const mux,
// WEBP_MUX_MEMORY_ERROR - on memory allocation error. // WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxPushTile( WEBP_EXTERN(WebPMuxError) WebPMuxPushTile(
WebPMux* const mux, const WebPData* const bitstream, WebPMux* mux, const WebPData* bitstream,
int x_offset, int y_offset, int copy_data); int x_offset, int y_offset, int copy_data);
// Gets the nth tile from the mux object. // Gets the nth tile from the mux object.
@ -394,8 +396,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxPushTile(
// WEBP_MUX_BAD_DATA - if nth tile chunk in mux is invalid. // WEBP_MUX_BAD_DATA - if nth tile chunk in mux is invalid.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxGetTile( WEBP_EXTERN(WebPMuxError) WebPMuxGetTile(
const WebPMux* const mux, uint32_t nth, WebPData* const bitstream, const WebPMux* mux, uint32_t nth, WebPData* bitstream,
int* const x_offset, int* const y_offset); int* x_offset, int* y_offset);
// Deletes a tile from the mux object. // Deletes a tile from the mux object.
// nth=0 has a special meaning - last position // nth=0 has a special meaning - last position
@ -407,7 +409,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetTile(
// WEBP_MUX_NOT_FOUND - If there are less than nth tiles in the mux object // WEBP_MUX_NOT_FOUND - If there are less than nth tiles in the mux object
// before deletion. // before deletion.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxDeleteTile(WebPMux* const mux, uint32_t nth); WEBP_EXTERN(WebPMuxError) WebPMuxDeleteTile(WebPMux* mux, uint32_t nth);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Misc Utilities. // Misc Utilities.
@ -423,7 +425,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteTile(WebPMux* const mux, uint32_t nth);
// WEBP_MUX_NOT_FOUND - if VP8X chunk is not present in mux object. // 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_BAD_DATA - if VP8X chunk in mux is invalid.
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxGetFeatures(const WebPMux* const mux, WEBP_EXTERN(WebPMuxError) WebPMuxGetFeatures(const WebPMux* mux,
uint32_t* flags); uint32_t* flags);
// Gets number of chunks having tag value tag in the mux object. // Gets number of chunks having tag value tag in the mux object.
@ -434,7 +436,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetFeatures(const WebPMux* const mux,
// Returns: // Returns:
// WEBP_MUX_INVALID_ARGUMENT - if either mux, or num_elements is NULL // WEBP_MUX_INVALID_ARGUMENT - if either mux, or num_elements is NULL
// WEBP_MUX_OK - on success. // WEBP_MUX_OK - on success.
WEBP_EXTERN(WebPMuxError) WebPMuxNumChunks(const WebPMux* const mux, WEBP_EXTERN(WebPMuxError) WebPMuxNumChunks(const WebPMux* mux,
WebPChunkId id, int* num_elements); WebPChunkId id, int* num_elements);
// Assembles all chunks in WebP RIFF format and returns in 'assembled_data'. // Assembles all chunks in WebP RIFF format and returns in 'assembled_data'.
@ -452,8 +454,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxNumChunks(const WebPMux* const mux,
// NULL. // NULL.
// WEBP_MUX_MEMORY_ERROR - on memory allocation error. // WEBP_MUX_MEMORY_ERROR - on memory allocation error.
// WEBP_MUX_OK - on success // WEBP_MUX_OK - on success
WEBP_EXTERN(WebPMuxError) WebPMuxAssemble(WebPMux* const mux, WEBP_EXTERN(WebPMuxError) WebPMuxAssemble(WebPMux* mux,
WebPData* const assembled_data); WebPData* assembled_data);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Demux API. // Demux API.
@ -474,12 +476,12 @@ typedef enum {
// Internal, version-checked, entry point // Internal, version-checked, entry point
WEBP_EXTERN(WebPDemuxer*) WebPDemuxInternal( WEBP_EXTERN(WebPDemuxer*) WebPDemuxInternal(
const WebPData* const, int, WebPDemuxState* const, int); const WebPData*, int, WebPDemuxState*, int);
// Parses the WebP file given by 'data'. // Parses the WebP file given by 'data'.
// A complete WebP file must be present in 'data' for the function to succeed. // A complete WebP file must be present in 'data' for the function to succeed.
// Returns a WebPDemuxer object on successful parse, NULL otherwise. // Returns a WebPDemuxer object on successful parse, NULL otherwise.
static WEBP_INLINE WebPDemuxer* WebPDemux(const WebPData* const data) { static WEBP_INLINE WebPDemuxer* WebPDemux(const WebPData* data) {
return WebPDemuxInternal(data, 0, NULL, WEBP_DEMUX_ABI_VERSION); return WebPDemuxInternal(data, 0, NULL, WEBP_DEMUX_ABI_VERSION);
} }
@ -487,12 +489,12 @@ static WEBP_INLINE WebPDemuxer* WebPDemux(const WebPData* const data) {
// If 'state' is non-NULL it will be set to indicate the status of the demuxer. // 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. // Returns a WebPDemuxer object on successful parse, NULL otherwise.
static WEBP_INLINE WebPDemuxer* WebPDemuxPartial( static WEBP_INLINE WebPDemuxer* WebPDemuxPartial(
const WebPData* const data, WebPDemuxState* const state) { const WebPData* data, WebPDemuxState* state) {
return WebPDemuxInternal(data, 1, state, WEBP_DEMUX_ABI_VERSION); return WebPDemuxInternal(data, 1, state, WEBP_DEMUX_ABI_VERSION);
} }
// Frees memory associated with 'dmux'. // Frees memory associated with 'dmux'.
WEBP_EXTERN(void) WebPDemuxDelete(WebPDemuxer* const dmux); WEBP_EXTERN(void) WebPDemuxDelete(WebPDemuxer* dmux);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Data/information extraction. // Data/information extraction.
@ -508,7 +510,7 @@ typedef enum {
// NOTE: values are only valid if WebPDemux() was used or WebPDemuxPartial() // NOTE: values are only valid if WebPDemux() was used or WebPDemuxPartial()
// returned a state > WEBP_DEMUX_PARSING_HEADER. // returned a state > WEBP_DEMUX_PARSING_HEADER.
WEBP_EXTERN(uint32_t) WebPDemuxGetI( WEBP_EXTERN(uint32_t) WebPDemuxGetI(
const WebPDemuxer* const dmux, WebPFormatFeature feature); const WebPDemuxer* dmux, WebPFormatFeature feature);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Frame iteration. // Frame iteration.
@ -536,22 +538,22 @@ typedef struct {
// Call WebPDemuxReleaseIterator() when use of the iterator is complete. // Call WebPDemuxReleaseIterator() when use of the iterator is complete.
// NOTE: 'dmux' must persist for the lifetime of 'iter'. // NOTE: 'dmux' must persist for the lifetime of 'iter'.
WEBP_EXTERN(int) WebPDemuxGetFrame( WEBP_EXTERN(int) WebPDemuxGetFrame(
const WebPDemuxer* const dmux, int frame_number, WebPIterator* const iter); const WebPDemuxer* dmux, int frame_number, WebPIterator* iter);
// Sets 'iter->tile_' to point to the next ('iter->frame_num_' + 1) or previous // Sets 'iter->tile_' to point to the next ('iter->frame_num_' + 1) or previous
// ('iter->frame_num_' - 1) frame. These functions do not loop. // ('iter->frame_num_' - 1) frame. These functions do not loop.
// Returns true on success, false otherwise. // Returns true on success, false otherwise.
WEBP_EXTERN(int) WebPDemuxNextFrame(WebPIterator* const iter); WEBP_EXTERN(int) WebPDemuxNextFrame(WebPIterator* iter);
WEBP_EXTERN(int) WebPDemuxPrevFrame(WebPIterator* const iter); WEBP_EXTERN(int) WebPDemuxPrevFrame(WebPIterator* iter);
// Sets 'iter->tile_' to reflect tile number 'tile_number'. // Sets 'iter->tile_' to reflect tile number 'tile_number'.
// Returns true if tile 'tile_number' is present, false otherwise. // Returns true if tile 'tile_number' is present, false otherwise.
WEBP_EXTERN(int) WebPDemuxSelectTile(WebPIterator* const iter, int tile_number); WEBP_EXTERN(int) WebPDemuxSelectTile(WebPIterator* iter, int tile_number);
// Releases any memory associated with 'iter'. // Releases any memory associated with 'iter'.
// Must be called before destroying the associated WebPDemuxer with // Must be called before destroying the associated WebPDemuxer with
// WebPDemuxDelete(). // WebPDemuxDelete().
WEBP_EXTERN(void) WebPDemuxReleaseIterator(WebPIterator* const iter); WEBP_EXTERN(void) WebPDemuxReleaseIterator(WebPIterator* iter);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Chunk iteration. // Chunk iteration.
@ -576,20 +578,20 @@ typedef struct {
// payloads are accessed through WebPDemuxGetFrame() and related functions. // payloads are accessed through WebPDemuxGetFrame() and related functions.
// Call WebPDemuxReleaseChunkIterator() when use of the iterator is complete. // Call WebPDemuxReleaseChunkIterator() when use of the iterator is complete.
// NOTE: 'dmux' must persist for the lifetime of the iterator. // NOTE: 'dmux' must persist for the lifetime of the iterator.
WEBP_EXTERN(int) WebPDemuxGetChunk(const WebPDemuxer* const dmux, WEBP_EXTERN(int) WebPDemuxGetChunk(const WebPDemuxer* dmux,
const char fourcc[4], int chunk_number, const char fourcc[4], int chunk_number,
WebPChunkIterator* const iter); WebPChunkIterator* iter);
// Sets 'iter->chunk_' to point to the next ('iter->chunk_num_' + 1) or previous // Sets 'iter->chunk_' to point to the next ('iter->chunk_num_' + 1) or previous
// ('iter->chunk_num_' - 1) chunk. These functions do not loop. // ('iter->chunk_num_' - 1) chunk. These functions do not loop.
// Returns true on success, false otherwise. // Returns true on success, false otherwise.
WEBP_EXTERN(int) WebPDemuxNextChunk(WebPChunkIterator* const iter); WEBP_EXTERN(int) WebPDemuxNextChunk(WebPChunkIterator* iter);
WEBP_EXTERN(int) WebPDemuxPrevChunk(WebPChunkIterator* const iter); WEBP_EXTERN(int) WebPDemuxPrevChunk(WebPChunkIterator* iter);
// Releases any memory associated with 'iter'. // Releases any memory associated with 'iter'.
// Must be called before destroying the associated WebPDemuxer with // Must be called before destroying the associated WebPDemuxer with
// WebPDemuxDelete(). // WebPDemuxDelete().
WEBP_EXTERN(void) WebPDemuxReleaseChunkIterator(WebPChunkIterator* const iter); WEBP_EXTERN(void) WebPDemuxReleaseChunkIterator(WebPChunkIterator* iter);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------