// Copyright 2011 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // Internal objects and utils for mux. // // Authors: Urvang ([email protected]) // Vikas ([email protected]) #include <assert.h> #include "src/mux/muxi.h" #include "src/utils/utils.h" #define UNDEFINED_CHUNK_SIZE … const ChunkInfo kChunks[] = …; //------------------------------------------------------------------------------ int WebPGetMuxVersion(void) { … } //------------------------------------------------------------------------------ // Life of a chunk object. void ChunkInit(WebPChunk* const chunk) { … } WebPChunk* ChunkRelease(WebPChunk* const chunk) { … } //------------------------------------------------------------------------------ // Chunk misc methods. CHUNK_INDEX ChunkGetIndexFromTag(uint32_t tag) { … } WebPChunkId ChunkGetIdFromTag(uint32_t tag) { … } uint32_t ChunkGetTagFromFourCC(const char fourcc[4]) { … } CHUNK_INDEX ChunkGetIndexFromFourCC(const char fourcc[4]) { … } //------------------------------------------------------------------------------ // Chunk search methods. // Returns next chunk in the chunk list with the given tag. static WebPChunk* ChunkSearchNextInList(WebPChunk* chunk, uint32_t tag) { … } WebPChunk* ChunkSearchList(WebPChunk* first, uint32_t nth, uint32_t tag) { … } //------------------------------------------------------------------------------ // Chunk writer methods. WebPMuxError ChunkAssignData(WebPChunk* chunk, const WebPData* const data, int copy_data, uint32_t tag) { … } WebPMuxError ChunkSetHead(WebPChunk* const chunk, WebPChunk** const chunk_list) { … } WebPMuxError ChunkAppend(WebPChunk* const chunk, WebPChunk*** const chunk_list) { … } //------------------------------------------------------------------------------ // Chunk deletion method(s). WebPChunk* ChunkDelete(WebPChunk* const chunk) { … } void ChunkListDelete(WebPChunk** const chunk_list) { … } //------------------------------------------------------------------------------ // Chunk serialization methods. static uint8_t* ChunkEmit(const WebPChunk* const chunk, uint8_t* dst) { … } uint8_t* ChunkListEmit(const WebPChunk* chunk_list, uint8_t* dst) { … } size_t ChunkListDiskSize(const WebPChunk* chunk_list) { … } //------------------------------------------------------------------------------ // Life of a MuxImage object. void MuxImageInit(WebPMuxImage* const wpi) { … } WebPMuxImage* MuxImageRelease(WebPMuxImage* const wpi) { … } //------------------------------------------------------------------------------ // MuxImage search methods. // Get a reference to appropriate chunk list within an image given chunk tag. static WebPChunk** GetChunkListFromId(const WebPMuxImage* const wpi, WebPChunkId id) { … } int MuxImageCount(const WebPMuxImage* wpi_list, WebPChunkId id) { … } // Outputs a pointer to 'prev_wpi->next_', // where 'prev_wpi' is the pointer to the image at position (nth - 1). // Returns true if nth image was found. static int SearchImageToGetOrDelete(WebPMuxImage** wpi_list, uint32_t nth, WebPMuxImage*** const location) { … } //------------------------------------------------------------------------------ // MuxImage writer methods. WebPMuxError MuxImagePush(const WebPMuxImage* wpi, WebPMuxImage** wpi_list) { … } //------------------------------------------------------------------------------ // MuxImage deletion methods. WebPMuxImage* MuxImageDelete(WebPMuxImage* const wpi) { … } WebPMuxError MuxImageDeleteNth(WebPMuxImage** wpi_list, uint32_t nth) { … } //------------------------------------------------------------------------------ // MuxImage reader methods. WebPMuxError MuxImageGetNth(const WebPMuxImage** wpi_list, uint32_t nth, WebPMuxImage** wpi) { … } //------------------------------------------------------------------------------ // MuxImage serialization methods. // Size of an image. size_t MuxImageDiskSize(const WebPMuxImage* const wpi) { … } // Special case as ANMF chunk encapsulates other image chunks. static uint8_t* ChunkEmitSpecial(const WebPChunk* const header, size_t total_size, uint8_t* dst) { … } uint8_t* MuxImageEmit(const WebPMuxImage* const wpi, uint8_t* dst) { … } //------------------------------------------------------------------------------ // Helper methods for mux. int MuxHasAlpha(const WebPMuxImage* images) { … } uint8_t* MuxEmitRiffHeader(uint8_t* const data, size_t size) { … } WebPChunk** MuxGetChunkListFromId(const WebPMux* mux, WebPChunkId id) { … } static int IsNotCompatible(int feature, int num_items) { … } #define NO_FLAG … // Test basic constraints: // retrieval, maximum number of chunks by index (use -1 to skip) // and feature incompatibility (use NO_FLAG to skip). // On success returns WEBP_MUX_OK and stores the chunk count in *num. static WebPMuxError ValidateChunk(const WebPMux* const mux, CHUNK_INDEX idx, WebPFeatureFlags feature, uint32_t vp8x_flags, int max, int* num) { … } WebPMuxError MuxValidate(const WebPMux* const mux) { … } #undef NO_FLAG //------------------------------------------------------------------------------