This source file includes following definitions.
- SizeWithPadding
- ChunkDiskSize
- IsWPI
- MuxImageGetListFromId
#ifndef WEBP_MUX_MUXI_H_
#define WEBP_MUX_MUXI_H_
#include <stdlib.h>
#include "../dec/vp8i.h"
#include "../dec/vp8li.h"
#include "../webp/mux.h"
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
#define MUX_MAJ_VERSION 0
#define MUX_MIN_VERSION 1
#define MUX_REV_VERSION 1
typedef struct WebPChunk WebPChunk;
struct WebPChunk {
uint32_t tag_;
int owner_;
WebPData data_;
WebPChunk* next_;
};
typedef struct WebPMuxImage WebPMuxImage;
struct WebPMuxImage {
WebPChunk* header_;
WebPChunk* alpha_;
WebPChunk* img_;
int is_partial_;
WebPMuxImage* next_;
};
struct WebPMux {
WebPMuxImage* images_;
WebPChunk* iccp_;
WebPChunk* exif_;
WebPChunk* xmp_;
WebPChunk* anim_;
WebPChunk* vp8x_;
WebPChunk* unknown_;
};
typedef enum {
IDX_VP8X = 0,
IDX_ICCP,
IDX_ANIM,
IDX_ANMF,
IDX_FRGM,
IDX_ALPHA,
IDX_VP8,
IDX_VP8L,
IDX_EXIF,
IDX_XMP,
IDX_UNKNOWN,
IDX_NIL,
IDX_LAST_CHUNK
} CHUNK_INDEX;
#define NIL_TAG 0x00000000u
typedef struct {
uint32_t tag;
WebPChunkId id;
uint32_t size;
} ChunkInfo;
extern const ChunkInfo kChunks[IDX_LAST_CHUNK];
void ChunkInit(WebPChunk* const chunk);
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]);
WebPChunk* ChunkSearchList(WebPChunk* first, uint32_t nth, uint32_t tag);
WebPMuxError ChunkAssignData(WebPChunk* chunk, const WebPData* const data,
int copy_data, uint32_t tag);
WebPMuxError ChunkSetNth(WebPChunk* chunk, WebPChunk** chunk_list,
uint32_t nth);
WebPChunk* ChunkRelease(WebPChunk* const chunk);
WebPChunk* ChunkDelete(WebPChunk* const chunk);
static WEBP_INLINE size_t SizeWithPadding(size_t chunk_size) {
return CHUNK_HEADER_SIZE + ((chunk_size + 1) & ~1U);
}
static WEBP_INLINE size_t ChunkDiskSize(const WebPChunk* chunk) {
const size_t data_size = chunk->data_.size;
assert(data_size < MAX_CHUNK_PAYLOAD);
return SizeWithPadding(data_size);
}
size_t ChunksListDiskSize(const WebPChunk* chunk_list);
uint8_t* ChunkListEmit(const WebPChunk* chunk_list, uint8_t* dst);
WebPMuxError MuxGetImageWidthHeight(const WebPChunk* const image_chunk,
int* const width, int* const height);
void MuxImageInit(WebPMuxImage* const wpi);
WebPMuxImage* MuxImageRelease(WebPMuxImage* const wpi);
WebPMuxImage* MuxImageDelete(WebPMuxImage* const wpi);
void MuxImageDeleteAll(WebPMuxImage** const wpi_list);
int MuxImageCount(const WebPMuxImage* wpi_list, WebPChunkId id);
static WEBP_INLINE int IsWPI(WebPChunkId id) {
switch (id) {
case WEBP_CHUNK_ANMF:
case WEBP_CHUNK_FRGM:
case WEBP_CHUNK_ALPHA:
case WEBP_CHUNK_IMAGE: return 1;
default: return 0;
}
}
static WEBP_INLINE WebPChunk** MuxImageGetListFromId(
const WebPMuxImage* const wpi, WebPChunkId id) {
assert(wpi != NULL);
switch (id) {
case WEBP_CHUNK_ANMF:
case WEBP_CHUNK_FRGM: return (WebPChunk**)&wpi->header_;
case WEBP_CHUNK_ALPHA: return (WebPChunk**)&wpi->alpha_;
case WEBP_CHUNK_IMAGE: return (WebPChunk**)&wpi->img_;
default: return NULL;
}
}
WebPMuxError MuxImagePush(const WebPMuxImage* wpi, WebPMuxImage** wpi_list);
WebPMuxError MuxImageDeleteNth(WebPMuxImage** wpi_list, uint32_t nth);
WebPMuxError MuxImageGetNth(const WebPMuxImage** wpi_list, uint32_t nth,
WebPMuxImage** wpi);
size_t MuxImageDiskSize(const WebPMuxImage* const wpi);
size_t MuxImageListDiskSize(const WebPMuxImage* wpi_list);
uint8_t* MuxImageEmit(const WebPMuxImage* const wpi, uint8_t* dst);
uint8_t* MuxImageListEmit(const WebPMuxImage* wpi_list, uint8_t* dst);
int MuxHasLosslessImages(const WebPMuxImage* images);
uint8_t* MuxEmitRiffHeader(uint8_t* const data, size_t size);
WebPChunk** MuxGetChunkListFromId(const WebPMux* mux, WebPChunkId id);
WebPMuxError MuxValidateForImage(const WebPMux* const mux);
WebPMuxError MuxValidate(const WebPMux* const mux);
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
#endif