mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-20 04:18:26 +01:00
Merge "mux: use size_t consistently"
This commit is contained in:
commit
53af99b18f
@ -215,9 +215,9 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) {
|
|||||||
err = WebPMuxGetFrame(mux, i, &image, &alpha,
|
err = WebPMuxGetFrame(mux, i, &image, &alpha,
|
||||||
&x_offset, &y_offset, &duration);
|
&x_offset, &y_offset, &duration);
|
||||||
RETURN_IF_ERROR2("Failed to retrieve frame#%d\n", i);
|
RETURN_IF_ERROR2("Failed to retrieve frame#%d\n", i);
|
||||||
printf("%3d: %8d %8d %8d %10u",
|
printf("%3d: %8d %8d %8d %10zu",
|
||||||
i, x_offset, y_offset, duration, image.size_);
|
i, x_offset, y_offset, duration, image.size_);
|
||||||
if (flag & ALPHA_FLAG) printf(" %10u", alpha.size_);
|
if (flag & ALPHA_FLAG) printf(" %10zu", alpha.size_);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,9 +239,9 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) {
|
|||||||
WebPData image, alpha;
|
WebPData image, alpha;
|
||||||
err = WebPMuxGetTile(mux, i, &image, &alpha, &x_offset, &y_offset);
|
err = WebPMuxGetTile(mux, i, &image, &alpha, &x_offset, &y_offset);
|
||||||
RETURN_IF_ERROR2("Failed to retrieve tile#%d\n", i);
|
RETURN_IF_ERROR2("Failed to retrieve tile#%d\n", i);
|
||||||
printf("%3d: %8d %8d %10u",
|
printf("%3d: %8d %8d %10zu",
|
||||||
i, x_offset, y_offset, image.size_);
|
i, x_offset, y_offset, image.size_);
|
||||||
if (flag & ALPHA_FLAG) printf(" %10u", alpha.size_);
|
if (flag & ALPHA_FLAG) printf(" %10zu", alpha.size_);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,21 +251,21 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) {
|
|||||||
WebPData icc_profile;
|
WebPData icc_profile;
|
||||||
err = WebPMuxGetColorProfile(mux, &icc_profile);
|
err = WebPMuxGetColorProfile(mux, &icc_profile);
|
||||||
RETURN_IF_ERROR("Failed to retrieve the color profile\n");
|
RETURN_IF_ERROR("Failed to retrieve the color profile\n");
|
||||||
printf("Size of the color profile data: %u\n", icc_profile.size_);
|
printf("Size of the color profile data: %zu\n", icc_profile.size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag & META_FLAG) {
|
if (flag & META_FLAG) {
|
||||||
WebPData metadata;
|
WebPData metadata;
|
||||||
err = WebPMuxGetMetadata(mux, &metadata);
|
err = WebPMuxGetMetadata(mux, &metadata);
|
||||||
RETURN_IF_ERROR("Failed to retrieve the XMP metadata\n");
|
RETURN_IF_ERROR("Failed to retrieve the XMP metadata\n");
|
||||||
printf("Size of the XMP metadata: %u\n", metadata.size_);
|
printf("Size of the XMP metadata: %zu\n", metadata.size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flag & ALPHA_FLAG) && !(flag & (ANIMATION_FLAG | TILE_FLAG))) {
|
if ((flag & ALPHA_FLAG) && !(flag & (ANIMATION_FLAG | TILE_FLAG))) {
|
||||||
WebPData image, alpha;
|
WebPData image, alpha;
|
||||||
err = WebPMuxGetImage(mux, &image, &alpha);
|
err = WebPMuxGetImage(mux, &image, &alpha);
|
||||||
RETURN_IF_ERROR("Failed to retrieve the image\n");
|
RETURN_IF_ERROR("Failed to retrieve the image\n");
|
||||||
printf("Size of the alpha data: %u\n", alpha.size_);
|
printf("Size of the alpha data: %zu\n", alpha.size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
return WEBP_MUX_OK;
|
return WEBP_MUX_OK;
|
||||||
@ -411,8 +411,8 @@ static int ReadImage(const char* filename,
|
|||||||
ok &= WebPDataCopy(&image, image_ptr);
|
ok &= WebPDataCopy(&image, image_ptr);
|
||||||
ok &= WebPDataCopy(&alpha, alpha_ptr);
|
ok &= WebPDataCopy(&alpha, alpha_ptr);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
fprintf(stderr, "Error allocating storage for image (%u bytes) "
|
fprintf(stderr, "Error allocating storage for image (%zu bytes) "
|
||||||
"and alpha (%u bytes) data\n", image.size_, alpha.size_);
|
"and alpha (%zu bytes) data\n", image.size_, alpha.size_);
|
||||||
WebPDataFree(image_ptr);
|
WebPDataFree(image_ptr);
|
||||||
WebPDataFree(alpha_ptr);
|
WebPDataFree(alpha_ptr);
|
||||||
}
|
}
|
||||||
@ -434,7 +434,7 @@ static int WriteData(const char* filename, const WebPData* const webpdata) {
|
|||||||
if (fwrite(webpdata->bytes_, webpdata->size_, 1, fout) != 1) {
|
if (fwrite(webpdata->bytes_, webpdata->size_, 1, fout) != 1) {
|
||||||
fprintf(stderr, "Error writing file %s!\n", filename);
|
fprintf(stderr, "Error writing file %s!\n", filename);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Saved file %s (%d bytes)\n", filename, webpdata->size_);
|
fprintf(stderr, "Saved file %s (%zu bytes)\n", filename, webpdata->size_);
|
||||||
ok = 1;
|
ok = 1;
|
||||||
}
|
}
|
||||||
if (fout != stdout) fclose(fout);
|
if (fout != stdout) fclose(fout);
|
||||||
|
@ -70,7 +70,7 @@ void WebPMuxDelete(WebPMux* const mux) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static WebPMuxError MuxSet(WebPMux* const mux, TAG_ID id, uint32_t nth,
|
static WebPMuxError MuxSet(WebPMux* const mux, TAG_ID id, uint32_t nth,
|
||||||
const uint8_t* data, uint32_t size,
|
const uint8_t* data, size_t size,
|
||||||
WebPImageInfo* image_info, int copy_data) {
|
WebPImageInfo* image_info, int copy_data) {
|
||||||
WebPChunk chunk;
|
WebPChunk chunk;
|
||||||
WebPMuxError err = WEBP_MUX_NOT_FOUND;
|
WebPMuxError err = WEBP_MUX_NOT_FOUND;
|
||||||
@ -114,7 +114,7 @@ static void InitImageInfo(WebPImageInfo* const image_info) {
|
|||||||
// Dimensions calculated from passed VP8 image data.
|
// Dimensions calculated from passed VP8 image data.
|
||||||
static WebPImageInfo* CreateImageInfo(uint32_t x_offset, uint32_t y_offset,
|
static WebPImageInfo* CreateImageInfo(uint32_t x_offset, uint32_t y_offset,
|
||||||
uint32_t duration,
|
uint32_t duration,
|
||||||
const uint8_t* data, uint32_t size) {
|
const uint8_t* data, size_t size) {
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
WebPImageInfo* image_info = NULL;
|
WebPImageInfo* image_info = NULL;
|
||||||
@ -161,7 +161,7 @@ static WebPMuxError CreateDataFromImageInfo(const WebPImageInfo* image_info,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Outputs image data given data from a webp file (including RIFF header).
|
// Outputs image data given data from a webp file (including RIFF header).
|
||||||
static WebPMuxError GetImageData(const uint8_t* data, uint32_t size,
|
static WebPMuxError GetImageData(const uint8_t* data, size_t size,
|
||||||
WebPData* const image, WebPData* const alpha) {
|
WebPData* const image, WebPData* const alpha) {
|
||||||
if (size < TAG_SIZE || memcmp(data, "RIFF", TAG_SIZE)) {
|
if (size < TAG_SIZE || memcmp(data, "RIFF", TAG_SIZE)) {
|
||||||
// It is NOT webp file data. Return input data as is.
|
// It is NOT webp file data. Return input data as is.
|
||||||
@ -220,8 +220,8 @@ static WebPMuxError DeleteLoopCount(WebPMux* const mux) {
|
|||||||
// Set API(s).
|
// Set API(s).
|
||||||
|
|
||||||
WebPMuxError WebPMuxSetImage(WebPMux* const mux,
|
WebPMuxError WebPMuxSetImage(WebPMux* const mux,
|
||||||
const uint8_t* data, uint32_t size,
|
const uint8_t* data, size_t size,
|
||||||
const uint8_t* alpha_data, uint32_t alpha_size,
|
const uint8_t* alpha_data, size_t alpha_size,
|
||||||
int copy_data) {
|
int copy_data) {
|
||||||
WebPMuxError err;
|
WebPMuxError err;
|
||||||
WebPChunk chunk;
|
WebPChunk chunk;
|
||||||
@ -264,7 +264,7 @@ WebPMuxError WebPMuxSetImage(WebPMux* const mux,
|
|||||||
}
|
}
|
||||||
|
|
||||||
WebPMuxError WebPMuxSetMetadata(WebPMux* const mux,
|
WebPMuxError WebPMuxSetMetadata(WebPMux* const mux,
|
||||||
const uint8_t* data, uint32_t size,
|
const uint8_t* data, size_t size,
|
||||||
int copy_data) {
|
int copy_data) {
|
||||||
WebPMuxError err;
|
WebPMuxError err;
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ WebPMuxError WebPMuxSetMetadata(WebPMux* const mux,
|
|||||||
}
|
}
|
||||||
|
|
||||||
WebPMuxError WebPMuxSetColorProfile(WebPMux* const mux,
|
WebPMuxError WebPMuxSetColorProfile(WebPMux* const mux,
|
||||||
const uint8_t* data, uint32_t size,
|
const uint8_t* data, size_t size,
|
||||||
int copy_data) {
|
int copy_data) {
|
||||||
WebPMuxError err;
|
WebPMuxError err;
|
||||||
|
|
||||||
@ -320,8 +320,8 @@ WebPMuxError WebPMuxSetLoopCount(WebPMux* const mux, uint32_t loop_count) {
|
|||||||
|
|
||||||
static WebPMuxError MuxAddFrameTileInternal(
|
static WebPMuxError MuxAddFrameTileInternal(
|
||||||
WebPMux* const mux, uint32_t nth,
|
WebPMux* const mux, uint32_t nth,
|
||||||
const uint8_t* data, uint32_t size,
|
const uint8_t* data, size_t size,
|
||||||
const uint8_t* alpha_data, uint32_t alpha_size,
|
const uint8_t* alpha_data, size_t alpha_size,
|
||||||
uint32_t x_offset, uint32_t y_offset, uint32_t duration,
|
uint32_t x_offset, uint32_t y_offset, uint32_t duration,
|
||||||
int copy_data, uint32_t tag) {
|
int copy_data, uint32_t tag) {
|
||||||
WebPChunk chunk;
|
WebPChunk chunk;
|
||||||
@ -405,8 +405,8 @@ static WebPMuxError MuxAddFrameTileInternal(
|
|||||||
// TODO(urvang): Think about whether we need 'nth' while adding a frame or tile.
|
// TODO(urvang): Think about whether we need 'nth' while adding a frame or tile.
|
||||||
|
|
||||||
WebPMuxError WebPMuxAddFrame(WebPMux* const mux, uint32_t nth,
|
WebPMuxError WebPMuxAddFrame(WebPMux* const mux, uint32_t nth,
|
||||||
const uint8_t* data, uint32_t size,
|
const uint8_t* data, size_t size,
|
||||||
const uint8_t* alpha_data, uint32_t alpha_size,
|
const uint8_t* alpha_data, size_t alpha_size,
|
||||||
uint32_t x_offset, uint32_t y_offset,
|
uint32_t x_offset, uint32_t y_offset,
|
||||||
uint32_t duration, int copy_data) {
|
uint32_t duration, int copy_data) {
|
||||||
return MuxAddFrameTileInternal(mux, nth, data, size, alpha_data, alpha_size,
|
return MuxAddFrameTileInternal(mux, nth, data, size, alpha_data, alpha_size,
|
||||||
@ -415,8 +415,8 @@ WebPMuxError WebPMuxAddFrame(WebPMux* const mux, uint32_t nth,
|
|||||||
}
|
}
|
||||||
|
|
||||||
WebPMuxError WebPMuxAddTile(WebPMux* const mux, uint32_t nth,
|
WebPMuxError WebPMuxAddTile(WebPMux* const mux, uint32_t nth,
|
||||||
const uint8_t* data, uint32_t size,
|
const uint8_t* data, size_t size,
|
||||||
const uint8_t* alpha_data, uint32_t alpha_size,
|
const uint8_t* alpha_data, size_t alpha_size,
|
||||||
uint32_t x_offset, uint32_t y_offset,
|
uint32_t x_offset, uint32_t y_offset,
|
||||||
int copy_data) {
|
int copy_data) {
|
||||||
return MuxAddFrameTileInternal(mux, nth, data, size, alpha_data, alpha_size,
|
return MuxAddFrameTileInternal(mux, nth, data, size, alpha_data, alpha_size,
|
||||||
@ -594,8 +594,8 @@ static WebPMuxError CreateVP8XChunk(WebPMux* const mux) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WebPMuxError WebPMuxAssemble(WebPMux* const mux,
|
WebPMuxError WebPMuxAssemble(WebPMux* const mux,
|
||||||
uint8_t** output_data, uint32_t* output_size) {
|
uint8_t** output_data, size_t* output_size) {
|
||||||
uint32_t size = 0;
|
size_t size = 0;
|
||||||
uint8_t* data = NULL;
|
uint8_t* data = NULL;
|
||||||
uint8_t* dst = NULL;
|
uint8_t* dst = NULL;
|
||||||
int num_frames;
|
int num_frames;
|
||||||
@ -641,7 +641,8 @@ WebPMuxError WebPMuxAssemble(WebPMux* const mux,
|
|||||||
|
|
||||||
// Main RIFF header.
|
// Main RIFF header.
|
||||||
PutLE32(data + 0, mktag('R', 'I', 'F', 'F'));
|
PutLE32(data + 0, mktag('R', 'I', 'F', 'F'));
|
||||||
PutLE32(data + 4, size - CHUNK_HEADER_SIZE);
|
PutLE32(data + 4, (uint32_t)size - CHUNK_HEADER_SIZE);
|
||||||
|
assert(size == (uint32_t)size);
|
||||||
PutLE32(data + 8, mktag('W', 'E', 'B', 'P'));
|
PutLE32(data + 8, mktag('W', 'E', 'B', 'P'));
|
||||||
|
|
||||||
// Chunks.
|
// Chunks.
|
||||||
|
@ -37,7 +37,7 @@ typedef struct {
|
|||||||
typedef struct WebPChunk WebPChunk;
|
typedef struct WebPChunk WebPChunk;
|
||||||
struct WebPChunk {
|
struct WebPChunk {
|
||||||
uint32_t tag_;
|
uint32_t tag_;
|
||||||
uint32_t payload_size_;
|
size_t payload_size_;
|
||||||
WebPImageInfo* image_info_;
|
WebPImageInfo* image_info_;
|
||||||
int owner_; // True if *data_ memory is owned internally.
|
int owner_; // True if *data_ memory is owned internally.
|
||||||
// VP8X, Loop, and other internally created chunks
|
// VP8X, Loop, and other internally created chunks
|
||||||
@ -122,7 +122,7 @@ static WEBP_INLINE void PutLE32(uint8_t* const data, uint32_t val) {
|
|||||||
PutLE16(data + 2, val >> 16);
|
PutLE16(data + 2, val >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
static WEBP_INLINE uint32_t SizeWithPadding(uint32_t chunk_size) {
|
static WEBP_INLINE size_t SizeWithPadding(size_t chunk_size) {
|
||||||
return CHUNK_HEADER_SIZE + ((chunk_size + 1) & ~1U);
|
return CHUNK_HEADER_SIZE + ((chunk_size + 1) & ~1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ WebPChunk* ChunkSearchList(WebPChunk* first, uint32_t nth, uint32_t tag);
|
|||||||
|
|
||||||
// Fill the chunk with the given data & image_info.
|
// Fill the chunk with the given data & image_info.
|
||||||
WebPMuxError ChunkAssignDataImageInfo(WebPChunk* chunk,
|
WebPMuxError ChunkAssignDataImageInfo(WebPChunk* chunk,
|
||||||
const uint8_t* data, uint32_t data_size,
|
const uint8_t* data, size_t data_size,
|
||||||
WebPImageInfo* image_info,
|
WebPImageInfo* image_info,
|
||||||
int copy_data, uint32_t tag);
|
int copy_data, uint32_t tag);
|
||||||
|
|
||||||
@ -160,13 +160,13 @@ WebPChunk* ChunkRelease(WebPChunk* const chunk);
|
|||||||
WebPChunk* ChunkDelete(WebPChunk* const chunk);
|
WebPChunk* ChunkDelete(WebPChunk* const chunk);
|
||||||
|
|
||||||
// Size of a chunk including header and padding.
|
// Size of a chunk including header and padding.
|
||||||
static WEBP_INLINE uint32_t ChunkDiskSize(const WebPChunk* chunk) {
|
static WEBP_INLINE size_t ChunkDiskSize(const WebPChunk* chunk) {
|
||||||
assert(chunk->payload_size_ < MAX_CHUNK_PAYLOAD);
|
assert(chunk->payload_size_ < MAX_CHUNK_PAYLOAD);
|
||||||
return SizeWithPadding(chunk->payload_size_);
|
return SizeWithPadding(chunk->payload_size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Total size of a list of chunks.
|
// Total size of a list of chunks.
|
||||||
uint32_t ChunksListDiskSize(const WebPChunk* chunk_list);
|
size_t ChunksListDiskSize(const WebPChunk* chunk_list);
|
||||||
|
|
||||||
// Write out the given list of chunks into 'dst'.
|
// Write out the given list of chunks into 'dst'.
|
||||||
uint8_t* ChunkListEmit(const WebPChunk* chunk_list, uint8_t* dst);
|
uint8_t* ChunkListEmit(const WebPChunk* chunk_list, uint8_t* dst);
|
||||||
@ -229,7 +229,7 @@ WebPMuxError MuxImageGetNth(const WebPMuxImage** wpi_list, uint32_t nth,
|
|||||||
TAG_ID id, WebPMuxImage** wpi);
|
TAG_ID id, WebPMuxImage** wpi);
|
||||||
|
|
||||||
// Total size of a list of images.
|
// Total size of a list of images.
|
||||||
uint32_t MuxImageListDiskSize(const WebPMuxImage* wpi_list);
|
size_t MuxImageListDiskSize(const WebPMuxImage* wpi_list);
|
||||||
|
|
||||||
// Write out the given list of images into 'dst'.
|
// Write out the given list of images into 'dst'.
|
||||||
uint8_t* MuxImageListEmit(const WebPMuxImage* wpi_list, uint8_t* dst);
|
uint8_t* MuxImageListEmit(const WebPMuxImage* wpi_list, uint8_t* dst);
|
||||||
|
@ -124,7 +124,7 @@ static int ChunkSearchListToSet(WebPChunk** chunk_list, uint32_t nth,
|
|||||||
// Chunk writer methods.
|
// Chunk writer methods.
|
||||||
|
|
||||||
WebPMuxError ChunkAssignDataImageInfo(WebPChunk* chunk,
|
WebPMuxError ChunkAssignDataImageInfo(WebPChunk* chunk,
|
||||||
const uint8_t* data, uint32_t data_size,
|
const uint8_t* data, size_t data_size,
|
||||||
WebPImageInfo* image_info,
|
WebPImageInfo* image_info,
|
||||||
int copy_data, uint32_t tag) {
|
int copy_data, uint32_t tag) {
|
||||||
// For internally allocated chunks, always copy data & make it owner of data.
|
// For internally allocated chunks, always copy data & make it owner of data.
|
||||||
@ -193,8 +193,8 @@ WebPChunk* ChunkDelete(WebPChunk* const chunk) {
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Chunk serialization methods.
|
// Chunk serialization methods.
|
||||||
|
|
||||||
uint32_t ChunksListDiskSize(const WebPChunk* chunk_list) {
|
size_t ChunksListDiskSize(const WebPChunk* chunk_list) {
|
||||||
uint32_t size = 0;
|
size_t size = 0;
|
||||||
while (chunk_list) {
|
while (chunk_list) {
|
||||||
size += ChunkDiskSize(chunk_list);
|
size += ChunkDiskSize(chunk_list);
|
||||||
chunk_list = chunk_list->next_;
|
chunk_list = chunk_list->next_;
|
||||||
@ -206,7 +206,8 @@ static uint8_t* ChunkEmit(const WebPChunk* const chunk, uint8_t* dst) {
|
|||||||
assert(chunk);
|
assert(chunk);
|
||||||
assert(chunk->tag_ != NIL_TAG);
|
assert(chunk->tag_ != NIL_TAG);
|
||||||
PutLE32(dst + 0, chunk->tag_);
|
PutLE32(dst + 0, chunk->tag_);
|
||||||
PutLE32(dst + TAG_SIZE, chunk->payload_size_);
|
PutLE32(dst + TAG_SIZE, (uint32_t)chunk->payload_size_);
|
||||||
|
assert(chunk->payload_size_ == (uint32_t)chunk->payload_size_);
|
||||||
memcpy(dst + CHUNK_HEADER_SIZE, chunk->data_, chunk->payload_size_);
|
memcpy(dst + CHUNK_HEADER_SIZE, chunk->data_, chunk->payload_size_);
|
||||||
if (chunk->payload_size_ & 1)
|
if (chunk->payload_size_ & 1)
|
||||||
dst[CHUNK_HEADER_SIZE + chunk->payload_size_] = 0; // Add padding.
|
dst[CHUNK_HEADER_SIZE + chunk->payload_size_] = 0; // Add padding.
|
||||||
@ -372,16 +373,16 @@ WebPMuxError MuxImageGetNth(const WebPMuxImage** wpi_list, uint32_t nth,
|
|||||||
// MuxImage serialization methods.
|
// MuxImage serialization methods.
|
||||||
|
|
||||||
// Size of an image.
|
// Size of an image.
|
||||||
static uint32_t MuxImageDiskSize(const WebPMuxImage* wpi) {
|
static size_t MuxImageDiskSize(const WebPMuxImage* wpi) {
|
||||||
uint32_t size = 0;
|
size_t size = 0;
|
||||||
if (wpi->header_ != NULL) size += ChunkDiskSize(wpi->header_);
|
if (wpi->header_ != NULL) size += ChunkDiskSize(wpi->header_);
|
||||||
if (wpi->alpha_ != NULL) size += ChunkDiskSize(wpi->alpha_);
|
if (wpi->alpha_ != NULL) size += ChunkDiskSize(wpi->alpha_);
|
||||||
if (wpi->vp8_ != NULL) size += ChunkDiskSize(wpi->vp8_);
|
if (wpi->vp8_ != NULL) size += ChunkDiskSize(wpi->vp8_);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MuxImageListDiskSize(const WebPMuxImage* wpi_list) {
|
size_t MuxImageListDiskSize(const WebPMuxImage* wpi_list) {
|
||||||
uint32_t size = 0;
|
size_t size = 0;
|
||||||
while (wpi_list) {
|
while (wpi_list) {
|
||||||
size += MuxImageDiskSize(wpi_list);
|
size += MuxImageDiskSize(wpi_list);
|
||||||
wpi_list = wpi_list->next_;
|
wpi_list = wpi_list->next_;
|
||||||
|
@ -52,7 +52,7 @@ static WebPMuxError MuxGet(const WebPMux* const mux, TAG_ID id, uint32_t nth,
|
|||||||
// Fill the chunk with the given data, after verifying that the data size
|
// Fill the chunk with the given data, after verifying that the data size
|
||||||
// doesn't exceed 'max_size'.
|
// doesn't exceed 'max_size'.
|
||||||
static WebPMuxError ChunkAssignData(WebPChunk* chunk, const uint8_t* data,
|
static WebPMuxError ChunkAssignData(WebPChunk* chunk, const uint8_t* data,
|
||||||
uint32_t data_size, uint32_t riff_size,
|
size_t data_size, size_t riff_size,
|
||||||
int copy_data) {
|
int copy_data) {
|
||||||
uint32_t chunk_size;
|
uint32_t chunk_size;
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ static WebPMuxError ChunkAssignData(WebPChunk* chunk, const uint8_t* data,
|
|||||||
chunk_size = GetLE32(data + TAG_SIZE);
|
chunk_size = GetLE32(data + TAG_SIZE);
|
||||||
|
|
||||||
{
|
{
|
||||||
const uint32_t chunk_disk_size = SizeWithPadding(chunk_size);
|
const size_t chunk_disk_size = SizeWithPadding(chunk_size);
|
||||||
if (chunk_disk_size > riff_size) return WEBP_MUX_BAD_DATA;
|
if (chunk_disk_size > riff_size) return WEBP_MUX_BAD_DATA;
|
||||||
if (chunk_disk_size > data_size) return WEBP_MUX_NOT_ENOUGH_DATA;
|
if (chunk_disk_size > data_size) return WEBP_MUX_NOT_ENOUGH_DATA;
|
||||||
}
|
}
|
||||||
@ -74,9 +74,9 @@ static WebPMuxError ChunkAssignData(WebPChunk* chunk, const uint8_t* data,
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Create a mux object from WebP-RIFF data.
|
// Create a mux object from WebP-RIFF data.
|
||||||
|
|
||||||
WebPMux* WebPMuxCreate(const uint8_t* data, uint32_t size, int copy_data,
|
WebPMux* WebPMuxCreate(const uint8_t* data, size_t size, int copy_data,
|
||||||
WebPMuxState* const mux_state) {
|
WebPMuxState* const mux_state) {
|
||||||
uint32_t riff_size;
|
size_t riff_size;
|
||||||
uint32_t tag;
|
uint32_t tag;
|
||||||
const uint8_t* end;
|
const uint8_t* end;
|
||||||
WebPMux* mux = NULL;
|
WebPMux* mux = NULL;
|
||||||
@ -170,7 +170,7 @@ WebPMux* WebPMuxCreate(const uint8_t* data, uint32_t size, int copy_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const uint32_t data_size = ChunkDiskSize(&chunk);
|
const size_t data_size = ChunkDiskSize(&chunk);
|
||||||
data += data_size;
|
data += data_size;
|
||||||
size -= data_size;
|
size -= data_size;
|
||||||
}
|
}
|
||||||
@ -292,7 +292,7 @@ static WebPMuxError MuxGetFrameTileInternal(
|
|||||||
WebPData* const image, WebPData* const alpha,
|
WebPData* const image, WebPData* const alpha,
|
||||||
uint32_t* x_offset, uint32_t* y_offset, uint32_t* duration, uint32_t tag) {
|
uint32_t* x_offset, uint32_t* y_offset, uint32_t* duration, uint32_t tag) {
|
||||||
const uint8_t* frame_tile_data;
|
const uint8_t* frame_tile_data;
|
||||||
uint32_t frame_tile_size;
|
size_t frame_tile_size;
|
||||||
WebPMuxError err;
|
WebPMuxError err;
|
||||||
WebPMuxImage* wpi;
|
WebPMuxImage* wpi;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ typedef struct WebPMux WebPMux; // main opaque object.
|
|||||||
// (ICC profile, metadata) and WebP compressed image data.
|
// (ICC profile, metadata) and WebP compressed image data.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const uint8_t* bytes_;
|
const uint8_t* bytes_;
|
||||||
uint32_t size_;
|
size_t size_;
|
||||||
} WebPData;
|
} WebPData;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@ -114,7 +114,7 @@ WEBP_EXTERN(void) WebPMuxDelete(WebPMux* const mux);
|
|||||||
// 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.
|
||||||
WEBP_EXTERN(WebPMux*) WebPMuxCreate(const uint8_t* data, uint32_t size,
|
WEBP_EXTERN(WebPMux*) WebPMuxCreate(const uint8_t* data, size_t size,
|
||||||
int copy_data,
|
int copy_data,
|
||||||
WebPMuxState* const mux_state);
|
WebPMuxState* const mux_state);
|
||||||
|
|
||||||
@ -138,8 +138,8 @@ WEBP_EXTERN(WebPMux*) WebPMuxCreate(const uint8_t* data, uint32_t size,
|
|||||||
// WEBP_MUX_OK - on success.
|
// WEBP_MUX_OK - on success.
|
||||||
WEBP_EXTERN(WebPMuxError) WebPMuxSetImage(
|
WEBP_EXTERN(WebPMuxError) WebPMuxSetImage(
|
||||||
WebPMux* const mux,
|
WebPMux* const mux,
|
||||||
const uint8_t* data, uint32_t size,
|
const uint8_t* data, size_t size,
|
||||||
const uint8_t* alpha_data, uint32_t alpha_size,
|
const uint8_t* alpha_data, size_t alpha_size,
|
||||||
int copy_data);
|
int copy_data);
|
||||||
|
|
||||||
// Gets a reference to the image in the mux object.
|
// Gets a reference to the image in the mux object.
|
||||||
@ -183,7 +183,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteImage(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) WebPMuxSetMetadata(
|
WEBP_EXTERN(WebPMuxError) WebPMuxSetMetadata(
|
||||||
WebPMux* const mux, const uint8_t* data, uint32_t size, int copy_data);
|
WebPMux* const mux, const uint8_t* data, size_t size, 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.
|
||||||
@ -222,7 +222,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteMetadata(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) WebPMuxSetColorProfile(
|
WEBP_EXTERN(WebPMuxError) WebPMuxSetColorProfile(
|
||||||
WebPMux* const mux, const uint8_t* data, uint32_t size, int copy_data);
|
WebPMux* const mux, const uint8_t* data, size_t size, 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.
|
||||||
@ -271,8 +271,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteColorProfile(WebPMux* const mux);
|
|||||||
// WEBP_MUX_OK - on success.
|
// WEBP_MUX_OK - on success.
|
||||||
WEBP_EXTERN(WebPMuxError) WebPMuxAddFrame(
|
WEBP_EXTERN(WebPMuxError) WebPMuxAddFrame(
|
||||||
WebPMux* const mux, uint32_t nth,
|
WebPMux* const mux, uint32_t nth,
|
||||||
const uint8_t* data, uint32_t size,
|
const uint8_t* data, size_t size,
|
||||||
const uint8_t* alpha_data, uint32_t alpha_size,
|
const uint8_t* alpha_data, size_t alpha_size,
|
||||||
uint32_t x_offset, uint32_t y_offset, uint32_t duration,
|
uint32_t x_offset, uint32_t y_offset, uint32_t duration,
|
||||||
int copy_data);
|
int copy_data);
|
||||||
|
|
||||||
@ -370,8 +370,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetLoopCount(const WebPMux* const mux,
|
|||||||
// WEBP_MUX_OK - on success.
|
// WEBP_MUX_OK - on success.
|
||||||
WEBP_EXTERN(WebPMuxError) WebPMuxAddTile(
|
WEBP_EXTERN(WebPMuxError) WebPMuxAddTile(
|
||||||
WebPMux* const mux, uint32_t nth,
|
WebPMux* const mux, uint32_t nth,
|
||||||
const uint8_t* data, uint32_t size,
|
const uint8_t* data, size_t size,
|
||||||
const uint8_t* alpha_data, uint32_t alpha_size,
|
const uint8_t* alpha_data, size_t alpha_size,
|
||||||
uint32_t x_offset, uint32_t y_offset,
|
uint32_t x_offset, uint32_t y_offset,
|
||||||
int copy_data);
|
int copy_data);
|
||||||
|
|
||||||
@ -454,7 +454,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxNumNamedElements(const WebPMux* const mux,
|
|||||||
// WEBP_MUX_OK - on success
|
// WEBP_MUX_OK - on success
|
||||||
WEBP_EXTERN(WebPMuxError) WebPMuxAssemble(WebPMux* const mux,
|
WEBP_EXTERN(WebPMuxError) WebPMuxAssemble(WebPMux* const mux,
|
||||||
uint8_t** output_data,
|
uint8_t** output_data,
|
||||||
uint32_t* output_size);
|
size_t* output_size);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user