mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-17 14:29:48 +02:00
More spec/code matching in mux:
- Match offsets, duration, width/height for frames/tiles and enforce some constraints. - Note that this also means using 'int's instead of 'uint32_t's for 16-bit and 24-bit fields. Change-Id: If0b229ad9fce296372d961104aa36731a3b1304b
This commit is contained in:
@ -62,9 +62,9 @@ typedef enum {
|
||||
#define CHUNK_SIZE_BYTES 4 // Size needed to store chunk's size.
|
||||
#define CHUNK_HEADER_SIZE 8 // Size of a chunk header.
|
||||
#define RIFF_HEADER_SIZE 12 // Size of the RIFF header ("RIFFnnnnWEBP").
|
||||
#define FRAME_CHUNK_SIZE 20 // Size of a FRM chunk.
|
||||
#define LOOP_CHUNK_SIZE 4 // Size of a LOOP chunk.
|
||||
#define TILE_CHUNK_SIZE 8 // Size of a TILE chunk.
|
||||
#define FRAME_CHUNK_SIZE 15 // Size of a FRM chunk.
|
||||
#define LOOP_CHUNK_SIZE 2 // Size of a LOOP chunk.
|
||||
#define TILE_CHUNK_SIZE 6 // Size of a TILE chunk.
|
||||
#define VP8X_CHUNK_SIZE 10 // Size of a VP8X chunk.
|
||||
|
||||
#define TILING_FLAG_BIT 0x01 // Set if tiles are possibly used.
|
||||
@ -76,9 +76,9 @@ typedef enum {
|
||||
|
||||
#define MAX_CANVAS_SIZE (1 << 24) // 24-bit max for VP8X width/height.
|
||||
#define MAX_IMAGE_AREA (1ULL << 32) // 32-bit max for width x height.
|
||||
#define MAX_LOOP_COUNT (1 << 16) // maximum value for loop-count
|
||||
#define MAX_DURATION (1U << 24) // maximum duration
|
||||
#define MAX_POSITION_OFFSET (1U << 24) // maximum frame/tile x/y offset
|
||||
#define MAX_LOOP_COUNT (1 << 16) // maximum value for loop-count
|
||||
#define MAX_DURATION (1 << 24) // maximum duration
|
||||
#define MAX_POSITION_OFFSET (1 << 24) // maximum frame/tile x/y offset
|
||||
|
||||
// Maximum chunk payload is such that adding the header and padding won't
|
||||
// overflow a uint32_t.
|
||||
|
@ -268,6 +268,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteColorProfile(WebPMux* const mux);
|
||||
// Animation.
|
||||
|
||||
// Adds an animation frame at the end of the mux object.
|
||||
// Note: as WebP only supports even offsets, any odd offset will be snapped to
|
||||
// an even location using: offset &= ~1
|
||||
// Parameters:
|
||||
// mux - (in/out) object to which an animation frame is to be added
|
||||
// bitstream - (in) the image data corresponding to the frame. It can either
|
||||
@ -284,15 +286,13 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteColorProfile(WebPMux* const mux);
|
||||
// WEBP_MUX_OK - on success.
|
||||
WEBP_EXTERN(WebPMuxError) WebPMuxPushFrame(
|
||||
WebPMux* const mux, const WebPData* const bitstream,
|
||||
uint32_t x_offset, uint32_t y_offset, uint32_t 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:
|
||||
// typedef struct {
|
||||
// WebPData image;
|
||||
// WebPData alpha;
|
||||
// uint32_t x_offset, y_offset;
|
||||
// uint32_t duration;
|
||||
// WebPData bitstream;
|
||||
// int x_offset, y_offset;
|
||||
// int duration;
|
||||
// } FrameInfo;
|
||||
|
||||
// Gets the nth animation frame from the mux object.
|
||||
@ -315,7 +315,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxPushFrame(
|
||||
// WEBP_MUX_OK - on success.
|
||||
WEBP_EXTERN(WebPMuxError) WebPMuxGetFrame(
|
||||
const WebPMux* const mux, uint32_t nth, WebPData* const bitstream,
|
||||
uint32_t* x_offset, uint32_t* y_offset, uint32_t* duration);
|
||||
int* const x_offset, int* const y_offset, int* const duration);
|
||||
|
||||
// Deletes an animation frame from the mux object.
|
||||
// nth=0 has a special meaning - last position.
|
||||
@ -340,7 +340,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteFrame(WebPMux* const mux, uint32_t nth);
|
||||
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
|
||||
// WEBP_MUX_OK - on success.
|
||||
WEBP_EXTERN(WebPMuxError) WebPMuxSetLoopCount(WebPMux* const mux,
|
||||
uint32_t loop_count);
|
||||
int loop_count);
|
||||
|
||||
// Gets the animation loop count from the mux object.
|
||||
// Parameters:
|
||||
@ -351,12 +351,14 @@ WEBP_EXTERN(WebPMuxError) WebPMuxSetLoopCount(WebPMux* const mux,
|
||||
// WEBP_MUX_NOT_FOUND - if loop chunk is not present in mux object.
|
||||
// WEBP_MUX_OK - on success.
|
||||
WEBP_EXTERN(WebPMuxError) WebPMuxGetLoopCount(const WebPMux* const mux,
|
||||
uint32_t* loop_count);
|
||||
int* const loop_count);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Tiling.
|
||||
|
||||
// Adds a tile at the end of the mux object.
|
||||
// Note: as WebP only supports even offsets, any odd offset will be snapped to
|
||||
// an even location using: offset &= ~1
|
||||
// Parameters:
|
||||
// mux - (in/out) object to which a tile is to be added.
|
||||
// bitstream - (in) the image data corresponding to the frame. It can either
|
||||
@ -372,7 +374,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxGetLoopCount(const WebPMux* const mux,
|
||||
// WEBP_MUX_OK - on success.
|
||||
WEBP_EXTERN(WebPMuxError) WebPMuxPushTile(
|
||||
WebPMux* const mux, const WebPData* const bitstream,
|
||||
uint32_t x_offset, uint32_t y_offset, int copy_data);
|
||||
int x_offset, int y_offset, int copy_data);
|
||||
|
||||
// Gets the nth tile from the mux object.
|
||||
// The content of 'bitstream' is allocated using malloc(), and NOT
|
||||
@ -393,7 +395,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxPushTile(
|
||||
// WEBP_MUX_OK - on success.
|
||||
WEBP_EXTERN(WebPMuxError) WebPMuxGetTile(
|
||||
const WebPMux* const mux, uint32_t nth, WebPData* const bitstream,
|
||||
uint32_t* x_offset, uint32_t* y_offset);
|
||||
int* const x_offset, int* const y_offset);
|
||||
|
||||
// Deletes a tile from the mux object.
|
||||
// nth=0 has a special meaning - last position
|
||||
|
Reference in New Issue
Block a user