mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-16 05:49:51 +02:00
Separate out mux and demux code and libraries:
- Separate out mux.h and demux.h - muxtypes.h: new header for data types common to mux/demux - Move some misc read/write utilities to utils/utils.h - Remove some duplicate methods. - Separate out mux/demux libraries Change-Id: If9b9569b10d55d922ad9317ef51710544315d6de
This commit is contained in:
@ -15,7 +15,6 @@
|
||||
#include <stdlib.h>
|
||||
#include "../dec/vp8i.h"
|
||||
#include "../dec/vp8li.h"
|
||||
#include "../webp/format_constants.h"
|
||||
#include "../webp/mux.h"
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
@ -82,8 +81,6 @@ typedef enum {
|
||||
|
||||
#define NIL_TAG 0x00000000u // To signal void chunk.
|
||||
|
||||
#define MKFOURCC(a, b, c, d) ((uint32_t)(a) | (b) << 8 | (c) << 16 | (d) << 24)
|
||||
|
||||
typedef struct {
|
||||
uint32_t tag;
|
||||
WebPChunkId id;
|
||||
@ -92,44 +89,6 @@ typedef struct {
|
||||
|
||||
extern const ChunkInfo kChunks[IDX_LAST_CHUNK];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helper functions.
|
||||
|
||||
// Read 16, 24 or 32 bits stored in little-endian order.
|
||||
static WEBP_INLINE int GetLE16(const uint8_t* const data) {
|
||||
return (int)(data[0] << 0) | (data[1] << 8);
|
||||
}
|
||||
|
||||
static WEBP_INLINE int GetLE24(const uint8_t* const data) {
|
||||
return GetLE16(data) | (data[2] << 16);
|
||||
}
|
||||
|
||||
static WEBP_INLINE uint32_t GetLE32(const uint8_t* const data) {
|
||||
return (uint32_t)GetLE16(data) | (GetLE16(data + 2) << 16);
|
||||
}
|
||||
|
||||
// Store 16, 24 or 32 bits in little-endian order.
|
||||
static WEBP_INLINE void PutLE16(uint8_t* const data, int val) {
|
||||
assert(val < (1 << 16));
|
||||
data[0] = (val >> 0);
|
||||
data[1] = (val >> 8);
|
||||
}
|
||||
|
||||
static WEBP_INLINE void PutLE24(uint8_t* const data, int val) {
|
||||
assert(val < (1 << 24));
|
||||
PutLE16(data, val & 0xffff);
|
||||
data[2] = (val >> 16);
|
||||
}
|
||||
|
||||
static WEBP_INLINE void PutLE32(uint8_t* const data, uint32_t val) {
|
||||
PutLE16(data, (int)(val & 0xffff));
|
||||
PutLE16(data + 2, (int)(val >> 16));
|
||||
}
|
||||
|
||||
static WEBP_INLINE size_t SizeWithPadding(size_t chunk_size) {
|
||||
return CHUNK_HEADER_SIZE + ((chunk_size + 1) & ~1U);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Chunk object management.
|
||||
|
||||
@ -167,6 +126,11 @@ WebPChunk* ChunkRelease(WebPChunk* const chunk);
|
||||
// Deletes given chunk & returns chunk->next_.
|
||||
WebPChunk* ChunkDelete(WebPChunk* const chunk);
|
||||
|
||||
// Returns size of the chunk including chunk header and padding byte (if any).
|
||||
static WEBP_INLINE size_t SizeWithPadding(size_t chunk_size) {
|
||||
return CHUNK_HEADER_SIZE + ((chunk_size + 1) & ~1U);
|
||||
}
|
||||
|
||||
// Size of a chunk including header and padding.
|
||||
static WEBP_INLINE size_t ChunkDiskSize(const WebPChunk* chunk) {
|
||||
const size_t data_size = chunk->data_.size;
|
||||
|
Reference in New Issue
Block a user