mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 06:08:21 +01:00
mux: cosmetics
group like parameters together in prototypes, comments, move variable declarations closer to first use. Change-Id: Idd6bd87d0366d783fed83f4dd21bd7968cbe6948
This commit is contained in:
parent
de556b6866
commit
506a4af2fa
@ -263,8 +263,9 @@ WebPMuxError WebPMuxSetImage(WebPMux* const mux,
|
||||
return MuxImageSetNth(&wpi, &mux->images_, 1);
|
||||
}
|
||||
|
||||
WebPMuxError WebPMuxSetMetadata(WebPMux* const mux, const uint8_t* data,
|
||||
uint32_t size, int copy_data) {
|
||||
WebPMuxError WebPMuxSetMetadata(WebPMux* const mux,
|
||||
const uint8_t* data, uint32_t size,
|
||||
int copy_data) {
|
||||
WebPMuxError err;
|
||||
|
||||
if (mux == NULL || data == NULL || size > MAX_CHUNK_PAYLOAD) {
|
||||
@ -279,8 +280,9 @@ WebPMuxError WebPMuxSetMetadata(WebPMux* const mux, const uint8_t* data,
|
||||
return MuxSet(mux, META_ID, 1, data, size, NULL, copy_data);
|
||||
}
|
||||
|
||||
WebPMuxError WebPMuxSetColorProfile(WebPMux* const mux, const uint8_t* data,
|
||||
uint32_t size, int copy_data) {
|
||||
WebPMuxError WebPMuxSetColorProfile(WebPMux* const mux,
|
||||
const uint8_t* data, uint32_t size,
|
||||
int copy_data) {
|
||||
WebPMuxError err;
|
||||
|
||||
if (mux == NULL || data == NULL || size > MAX_CHUNK_PAYLOAD) {
|
||||
@ -316,14 +318,12 @@ WebPMuxError WebPMuxSetLoopCount(WebPMux* const mux, uint32_t loop_count) {
|
||||
return err;
|
||||
}
|
||||
|
||||
static WebPMuxError MuxAddFrameTileInternal(WebPMux* const mux, uint32_t nth,
|
||||
const uint8_t* data, uint32_t size,
|
||||
const uint8_t* alpha_data,
|
||||
uint32_t alpha_size,
|
||||
uint32_t x_offset,
|
||||
uint32_t y_offset,
|
||||
uint32_t duration,
|
||||
int copy_data, uint32_t tag) {
|
||||
static WebPMuxError MuxAddFrameTileInternal(
|
||||
WebPMux* const mux, uint32_t nth,
|
||||
const uint8_t* data, uint32_t size,
|
||||
const uint8_t* alpha_data, uint32_t alpha_size,
|
||||
uint32_t x_offset, uint32_t y_offset, uint32_t duration,
|
||||
int copy_data, uint32_t tag) {
|
||||
WebPChunk chunk;
|
||||
WebPData image;
|
||||
WebPMuxImage wpi;
|
||||
@ -435,7 +435,7 @@ WebPMuxError WebPMuxDeleteImage(WebPMux* const mux) {
|
||||
err = ValidateForImage(mux);
|
||||
if (err != WEBP_MUX_OK) return err;
|
||||
|
||||
// All Well, delete Image.
|
||||
// All well, delete image.
|
||||
MuxImageDeleteAll(&mux->images_);
|
||||
return WEBP_MUX_OK;
|
||||
}
|
||||
@ -469,10 +469,9 @@ WebPMuxError WebPMuxDeleteTile(WebPMux* const mux, uint32_t nth) {
|
||||
//------------------------------------------------------------------------------
|
||||
// Assembly of the WebP RIFF file.
|
||||
|
||||
static WebPMuxError GetImageCanvasHeightWidth(const WebPMux* const mux,
|
||||
uint32_t flags,
|
||||
uint32_t* width,
|
||||
uint32_t* height) {
|
||||
static WebPMuxError GetImageCanvasHeightWidth(
|
||||
const WebPMux* const mux,
|
||||
uint32_t flags, uint32_t* width, uint32_t* height) {
|
||||
WebPMuxImage* wpi = NULL;
|
||||
assert(mux != NULL);
|
||||
assert(width && height);
|
||||
@ -585,9 +584,9 @@ static WebPMuxError CreateVP8XChunk(WebPMux* const mux) {
|
||||
err = GetImageCanvasHeightWidth(mux, flags, &width, &height);
|
||||
if (err != WEBP_MUX_OK) return err;
|
||||
|
||||
PutLE32(data + 0, flags); // Put VP8X Chunk Flags.
|
||||
PutLE32(data + 4, width); // Put canvasWidth.
|
||||
PutLE32(data + 8, height); // Put canvasHeight.
|
||||
PutLE32(data + 0, flags); // VP8X chunk flags.
|
||||
PutLE32(data + 4, width); // canvas width.
|
||||
PutLE32(data + 8, height); // canvas height.
|
||||
|
||||
err = MuxAddChunk(mux, 1, kChunks[VP8X_ID].chunkTag, data, data_size,
|
||||
NULL, 1);
|
||||
|
@ -39,12 +39,8 @@ const ChunkInfo kChunks[] = {
|
||||
|
||||
void ChunkInit(WebPChunk* const chunk) {
|
||||
assert(chunk);
|
||||
memset(chunk, 0, sizeof(*chunk));
|
||||
chunk->tag_ = NIL_TAG;
|
||||
chunk->data_ = NULL;
|
||||
chunk->payload_size_ = 0;
|
||||
chunk->owner_ = 0;
|
||||
chunk->image_info_ = NULL;
|
||||
chunk->next_ = NULL;
|
||||
}
|
||||
|
||||
WebPChunk* ChunkRelease(WebPChunk* const chunk) {
|
||||
|
@ -284,13 +284,10 @@ WebPMuxError WebPMuxGetLoopCount(const WebPMux* const mux,
|
||||
return WEBP_MUX_OK;
|
||||
}
|
||||
|
||||
static WebPMuxError MuxGetFrameTileInternal(const WebPMux* const mux,
|
||||
uint32_t nth,
|
||||
WebPData* const image,
|
||||
WebPData* const alpha,
|
||||
uint32_t* x_offset,
|
||||
uint32_t* y_offset,
|
||||
uint32_t* duration, uint32_t tag) {
|
||||
static WebPMuxError MuxGetFrameTileInternal(
|
||||
const WebPMux* const mux, uint32_t nth,
|
||||
WebPData* const image, WebPData* const alpha,
|
||||
uint32_t* x_offset, uint32_t* y_offset, uint32_t* duration, uint32_t tag) {
|
||||
const uint8_t* frame_tile_data;
|
||||
uint32_t frame_tile_size;
|
||||
WebPMuxError err;
|
||||
@ -370,7 +367,6 @@ static int CountChunks(WebPChunk* const chunk_list, uint32_t tag) {
|
||||
WebPMuxError WebPMuxNumNamedElements(const WebPMux* const mux, const char* tag,
|
||||
int* num_elements) {
|
||||
const TAG_ID id = ChunkGetIdFromName(tag);
|
||||
WebPChunk** chunk_list;
|
||||
|
||||
if (mux == NULL || tag == NULL || num_elements == NULL) {
|
||||
return WEBP_MUX_INVALID_ARGUMENT;
|
||||
@ -379,7 +375,7 @@ WebPMuxError WebPMuxNumNamedElements(const WebPMux* const mux, const char* tag,
|
||||
if (IsWPI(id)) {
|
||||
*num_elements = MuxImageCount(mux->images_, id);
|
||||
} else {
|
||||
chunk_list = GetChunkListFromId(mux, id);
|
||||
WebPChunk** chunk_list = GetChunkListFromId(mux, id);
|
||||
if (chunk_list == NULL) {
|
||||
*num_elements = 0;
|
||||
} else {
|
||||
|
@ -136,10 +136,11 @@ WEBP_EXTERN(WebPMux*) WebPMuxCreate(const uint8_t* data, uint32_t size,
|
||||
// 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.
|
||||
WEBP_EXTERN(WebPMuxError) WebPMuxSetImage(WebPMux* const mux,
|
||||
const uint8_t* data, uint32_t size,
|
||||
const uint8_t* alpha_data,
|
||||
uint32_t alpha_size, int copy_data);
|
||||
WEBP_EXTERN(WebPMuxError) WebPMuxSetImage(
|
||||
WebPMux* const mux,
|
||||
const uint8_t* data, uint32_t size,
|
||||
const uint8_t* alpha_data, uint32_t alpha_size,
|
||||
int copy_data);
|
||||
|
||||
// Gets a reference to the image in the mux object.
|
||||
// The caller should NOT free the returned data.
|
||||
@ -181,9 +182,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteImage(WebPMux* const mux);
|
||||
// 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.
|
||||
WEBP_EXTERN(WebPMuxError) WebPMuxSetMetadata(WebPMux* const mux,
|
||||
const uint8_t* data,
|
||||
uint32_t size, int copy_data);
|
||||
WEBP_EXTERN(WebPMuxError) WebPMuxSetMetadata(
|
||||
WebPMux* const mux, const uint8_t* data, uint32_t size, int copy_data);
|
||||
|
||||
// Gets a reference to the XMP metadata in the mux object.
|
||||
// The caller should NOT free the returned data.
|
||||
@ -221,9 +221,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteMetadata(WebPMux* const mux);
|
||||
// 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
|
||||
WEBP_EXTERN(WebPMuxError) WebPMuxSetColorProfile(WebPMux* const mux,
|
||||
const uint8_t* data,
|
||||
uint32_t size, int copy_data);
|
||||
WEBP_EXTERN(WebPMuxError) WebPMuxSetColorProfile(
|
||||
WebPMux* const mux, const uint8_t* data, uint32_t size, int copy_data);
|
||||
|
||||
// Gets a reference to the color profile in the mux object.
|
||||
// The caller should NOT free the returned data.
|
||||
@ -270,12 +269,12 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteColorProfile(WebPMux* const mux);
|
||||
// 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.
|
||||
WEBP_EXTERN(WebPMuxError) WebPMuxAddFrame(WebPMux* const mux, uint32_t nth,
|
||||
const uint8_t* data, uint32_t size,
|
||||
const uint8_t* alpha_data,
|
||||
uint32_t alpha_size,
|
||||
uint32_t x_offset, uint32_t y_offset,
|
||||
uint32_t duration, int copy_data);
|
||||
WEBP_EXTERN(WebPMuxError) WebPMuxAddFrame(
|
||||
WebPMux* const mux, uint32_t nth,
|
||||
const uint8_t* data, uint32_t size,
|
||||
const uint8_t* alpha_data, uint32_t alpha_size,
|
||||
uint32_t x_offset, uint32_t y_offset, uint32_t duration,
|
||||
int copy_data);
|
||||
|
||||
// TODO(urvang): Create a struct as follows to reduce argument list size:
|
||||
// typedef struct {
|
||||
@ -305,13 +304,10 @@ WEBP_EXTERN(WebPMuxError) WebPMuxAddFrame(WebPMux* const mux, uint32_t nth,
|
||||
// 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.
|
||||
// WEBP_MUX_OK - on success.
|
||||
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);
|
||||
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);
|
||||
|
||||
// Deletes an animation frame from the mux object.
|
||||
// nth=0 has a special meaning - last position.
|
||||
@ -372,12 +368,12 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetLoopCount(const WebPMux* const mux,
|
||||
// WEBP_MUX_NOT_FOUND - If we have less than (nth-1) tiles before adding.
|
||||
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
|
||||
// WEBP_MUX_OK - on success.
|
||||
WEBP_EXTERN(WebPMuxError) WebPMuxAddTile(WebPMux* const mux, uint32_t nth,
|
||||
const uint8_t* data, uint32_t size,
|
||||
const uint8_t* alpha_data,
|
||||
uint32_t alpha_size,
|
||||
uint32_t x_offset, uint32_t y_offset,
|
||||
int copy_data);
|
||||
WEBP_EXTERN(WebPMuxError) WebPMuxAddTile(
|
||||
WebPMux* const mux, uint32_t nth,
|
||||
const uint8_t* data, uint32_t size,
|
||||
const uint8_t* alpha_data, uint32_t alpha_size,
|
||||
uint32_t x_offset, uint32_t y_offset,
|
||||
int copy_data);
|
||||
|
||||
// Gets a reference to the nth tile from the mux object.
|
||||
// The caller should NOT free the returned data.
|
||||
@ -395,11 +391,10 @@ WEBP_EXTERN(WebPMuxError) WebPMuxAddTile(WebPMux* const mux, uint32_t nth,
|
||||
// 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.
|
||||
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);
|
||||
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);
|
||||
|
||||
// Deletes a tile from the mux object.
|
||||
// nth=0 has a special meaning - last position
|
||||
|
Loading…
Reference in New Issue
Block a user