Update libwebp to 1.1.0
This commit is contained in:
parent
6b64c60b0e
commit
65f2ab1b61
|
@ -237,7 +237,7 @@ from the Android NDK r18.
|
||||||
## libwebp
|
## libwebp
|
||||||
|
|
||||||
- Upstream: https://chromium.googlesource.com/webm/libwebp/
|
- Upstream: https://chromium.googlesource.com/webm/libwebp/
|
||||||
- Version: 1.0.3
|
- Version: 1.1.0
|
||||||
- License: BSD-3-Clause
|
- License: BSD-3-Clause
|
||||||
|
|
||||||
Files extracted from upstream source:
|
Files extracted from upstream source:
|
||||||
|
|
|
@ -732,7 +732,7 @@ static int AllocateMemory(VP8Decoder* const dec) {
|
||||||
mem += f_info_size;
|
mem += f_info_size;
|
||||||
dec->thread_ctx_.id_ = 0;
|
dec->thread_ctx_.id_ = 0;
|
||||||
dec->thread_ctx_.f_info_ = dec->f_info_;
|
dec->thread_ctx_.f_info_ = dec->f_info_;
|
||||||
if (dec->mt_method_ > 0) {
|
if (dec->filter_type_ > 0 && dec->mt_method_ > 0) {
|
||||||
// secondary cache line. The deblocking process need to make use of the
|
// secondary cache line. The deblocking process need to make use of the
|
||||||
// filtering strength from previous macroblock row, while the new ones
|
// filtering strength from previous macroblock row, while the new ones
|
||||||
// are being decoded in parallel. We'll just swap the pointers.
|
// are being decoded in parallel. We'll just swap the pointers.
|
||||||
|
|
|
@ -166,9 +166,11 @@ static int AppendToMemBuffer(WebPIDecoder* const idec,
|
||||||
VP8Decoder* const dec = (VP8Decoder*)idec->dec_;
|
VP8Decoder* const dec = (VP8Decoder*)idec->dec_;
|
||||||
MemBuffer* const mem = &idec->mem_;
|
MemBuffer* const mem = &idec->mem_;
|
||||||
const int need_compressed_alpha = NeedCompressedAlpha(idec);
|
const int need_compressed_alpha = NeedCompressedAlpha(idec);
|
||||||
const uint8_t* const old_start = mem->buf_ + mem->start_;
|
const uint8_t* const old_start =
|
||||||
|
(mem->buf_ == NULL) ? NULL : mem->buf_ + mem->start_;
|
||||||
const uint8_t* const old_base =
|
const uint8_t* const old_base =
|
||||||
need_compressed_alpha ? dec->alpha_data_ : old_start;
|
need_compressed_alpha ? dec->alpha_data_ : old_start;
|
||||||
|
assert(mem->buf_ != NULL || mem->start_ == 0);
|
||||||
assert(mem->mode_ == MEM_MODE_APPEND);
|
assert(mem->mode_ == MEM_MODE_APPEND);
|
||||||
if (data_size > MAX_CHUNK_PAYLOAD) {
|
if (data_size > MAX_CHUNK_PAYLOAD) {
|
||||||
// security safeguard: trying to allocate more than what the format
|
// security safeguard: trying to allocate more than what the format
|
||||||
|
@ -184,7 +186,7 @@ static int AppendToMemBuffer(WebPIDecoder* const idec,
|
||||||
uint8_t* const new_buf =
|
uint8_t* const new_buf =
|
||||||
(uint8_t*)WebPSafeMalloc(extra_size, sizeof(*new_buf));
|
(uint8_t*)WebPSafeMalloc(extra_size, sizeof(*new_buf));
|
||||||
if (new_buf == NULL) return 0;
|
if (new_buf == NULL) return 0;
|
||||||
memcpy(new_buf, old_base, current_size);
|
if (old_base != NULL) memcpy(new_buf, old_base, current_size);
|
||||||
WebPSafeFree(mem->buf_);
|
WebPSafeFree(mem->buf_);
|
||||||
mem->buf_ = new_buf;
|
mem->buf_ = new_buf;
|
||||||
mem->buf_size_ = (size_t)extra_size;
|
mem->buf_size_ = (size_t)extra_size;
|
||||||
|
@ -192,6 +194,7 @@ static int AppendToMemBuffer(WebPIDecoder* const idec,
|
||||||
mem->end_ = current_size;
|
mem->end_ = current_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(mem->buf_ != NULL);
|
||||||
memcpy(mem->buf_ + mem->end_, data, data_size);
|
memcpy(mem->buf_ + mem->end_, data, data_size);
|
||||||
mem->end_ += data_size;
|
mem->end_ += data_size;
|
||||||
assert(mem->end_ <= mem->buf_size_);
|
assert(mem->end_ <= mem->buf_size_);
|
||||||
|
@ -204,7 +207,9 @@ static int RemapMemBuffer(WebPIDecoder* const idec,
|
||||||
const uint8_t* const data, size_t data_size) {
|
const uint8_t* const data, size_t data_size) {
|
||||||
MemBuffer* const mem = &idec->mem_;
|
MemBuffer* const mem = &idec->mem_;
|
||||||
const uint8_t* const old_buf = mem->buf_;
|
const uint8_t* const old_buf = mem->buf_;
|
||||||
const uint8_t* const old_start = old_buf + mem->start_;
|
const uint8_t* const old_start =
|
||||||
|
(old_buf == NULL) ? NULL : old_buf + mem->start_;
|
||||||
|
assert(old_buf != NULL || mem->start_ == 0);
|
||||||
assert(mem->mode_ == MEM_MODE_MAP);
|
assert(mem->mode_ == MEM_MODE_MAP);
|
||||||
|
|
||||||
if (data_size < mem->buf_size_) return 0; // can't remap to a shorter buffer!
|
if (data_size < mem->buf_size_) return 0; // can't remap to a shorter buffer!
|
||||||
|
|
|
@ -31,8 +31,8 @@ extern "C" {
|
||||||
|
|
||||||
// version numbers
|
// version numbers
|
||||||
#define DEC_MAJ_VERSION 1
|
#define DEC_MAJ_VERSION 1
|
||||||
#define DEC_MIN_VERSION 0
|
#define DEC_MIN_VERSION 1
|
||||||
#define DEC_REV_VERSION 3
|
#define DEC_REV_VERSION 0
|
||||||
|
|
||||||
// YUV-cache parameters. Cache is 32-bytes wide (= one cacheline).
|
// YUV-cache parameters. Cache is 32-bytes wide (= one cacheline).
|
||||||
// Constraints are: We need to store one 16x16 block of luma samples (y),
|
// Constraints are: We need to store one 16x16 block of luma samples (y),
|
||||||
|
|
|
@ -754,11 +754,11 @@ static WEBP_INLINE HTreeGroup* GetHtreeGroupForPos(VP8LMetadata* const hdr,
|
||||||
|
|
||||||
typedef void (*ProcessRowsFunc)(VP8LDecoder* const dec, int row);
|
typedef void (*ProcessRowsFunc)(VP8LDecoder* const dec, int row);
|
||||||
|
|
||||||
static void ApplyInverseTransforms(VP8LDecoder* const dec, int num_rows,
|
static void ApplyInverseTransforms(VP8LDecoder* const dec,
|
||||||
|
int start_row, int num_rows,
|
||||||
const uint32_t* const rows) {
|
const uint32_t* const rows) {
|
||||||
int n = dec->next_transform_;
|
int n = dec->next_transform_;
|
||||||
const int cache_pixs = dec->width_ * num_rows;
|
const int cache_pixs = dec->width_ * num_rows;
|
||||||
const int start_row = dec->last_row_;
|
|
||||||
const int end_row = start_row + num_rows;
|
const int end_row = start_row + num_rows;
|
||||||
const uint32_t* rows_in = rows;
|
const uint32_t* rows_in = rows;
|
||||||
uint32_t* const rows_out = dec->argb_cache_;
|
uint32_t* const rows_out = dec->argb_cache_;
|
||||||
|
@ -789,8 +789,7 @@ static void ProcessRows(VP8LDecoder* const dec, int row) {
|
||||||
VP8Io* const io = dec->io_;
|
VP8Io* const io = dec->io_;
|
||||||
uint8_t* rows_data = (uint8_t*)dec->argb_cache_;
|
uint8_t* rows_data = (uint8_t*)dec->argb_cache_;
|
||||||
const int in_stride = io->width * sizeof(uint32_t); // in unit of RGBA
|
const int in_stride = io->width * sizeof(uint32_t); // in unit of RGBA
|
||||||
|
ApplyInverseTransforms(dec, dec->last_row_, num_rows, rows);
|
||||||
ApplyInverseTransforms(dec, num_rows, rows);
|
|
||||||
if (!SetCropWindow(io, dec->last_row_, row, &rows_data, in_stride)) {
|
if (!SetCropWindow(io, dec->last_row_, row, &rows_data, in_stride)) {
|
||||||
// Nothing to output (this time).
|
// Nothing to output (this time).
|
||||||
} else {
|
} else {
|
||||||
|
@ -1193,6 +1192,7 @@ static int DecodeImageData(VP8LDecoder* const dec, uint32_t* const data,
|
||||||
VP8LFillBitWindow(br);
|
VP8LFillBitWindow(br);
|
||||||
dist_code = GetCopyDistance(dist_symbol, br);
|
dist_code = GetCopyDistance(dist_symbol, br);
|
||||||
dist = PlaneCodeToDistance(width, dist_code);
|
dist = PlaneCodeToDistance(width, dist_code);
|
||||||
|
|
||||||
if (VP8LIsEndOfStream(br)) break;
|
if (VP8LIsEndOfStream(br)) break;
|
||||||
if (src - data < (ptrdiff_t)dist || src_end - src < (ptrdiff_t)length) {
|
if (src - data < (ptrdiff_t)dist || src_end - src < (ptrdiff_t)length) {
|
||||||
goto Error;
|
goto Error;
|
||||||
|
@ -1553,7 +1553,7 @@ static void ExtractAlphaRows(VP8LDecoder* const dec, int last_row) {
|
||||||
const int cache_pixs = width * num_rows_to_process;
|
const int cache_pixs = width * num_rows_to_process;
|
||||||
uint8_t* const dst = output + width * cur_row;
|
uint8_t* const dst = output + width * cur_row;
|
||||||
const uint32_t* const src = dec->argb_cache_;
|
const uint32_t* const src = dec->argb_cache_;
|
||||||
ApplyInverseTransforms(dec, num_rows_to_process, in);
|
ApplyInverseTransforms(dec, cur_row, num_rows_to_process, in);
|
||||||
WebPExtractGreen(src, dst, cache_pixs);
|
WebPExtractGreen(src, dst, cache_pixs);
|
||||||
AlphaApplyFilter(alph_dec,
|
AlphaApplyFilter(alph_dec,
|
||||||
cur_row, cur_row + num_rows_to_process, dst, width);
|
cur_row, cur_row + num_rows_to_process, dst, width);
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
#include "src/webp/format_constants.h"
|
#include "src/webp/format_constants.h"
|
||||||
|
|
||||||
#define DMUX_MAJ_VERSION 1
|
#define DMUX_MAJ_VERSION 1
|
||||||
#define DMUX_MIN_VERSION 0
|
#define DMUX_MIN_VERSION 1
|
||||||
#define DMUX_REV_VERSION 3
|
#define DMUX_REV_VERSION 0
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
size_t start_; // start location of the data
|
size_t start_; // start location of the data
|
||||||
|
|
|
@ -1361,7 +1361,8 @@ static void RD4_NEON(uint8_t* dst) { // Down-right
|
||||||
const uint32_t J = dst[-1 + 1 * BPS];
|
const uint32_t J = dst[-1 + 1 * BPS];
|
||||||
const uint32_t K = dst[-1 + 2 * BPS];
|
const uint32_t K = dst[-1 + 2 * BPS];
|
||||||
const uint32_t L = dst[-1 + 3 * BPS];
|
const uint32_t L = dst[-1 + 3 * BPS];
|
||||||
const uint64x1_t LKJI____ = vcreate_u64(L | (K << 8) | (J << 16) | (I << 24));
|
const uint64x1_t LKJI____ =
|
||||||
|
vcreate_u64((uint64_t)L | (K << 8) | (J << 16) | (I << 24));
|
||||||
const uint64x1_t LKJIXABC = vorr_u64(LKJI____, ____XABC);
|
const uint64x1_t LKJIXABC = vorr_u64(LKJI____, ____XABC);
|
||||||
const uint8x8_t KJIXABC_ = vreinterpret_u8_u64(vshr_n_u64(LKJIXABC, 8));
|
const uint8x8_t KJIXABC_ = vreinterpret_u8_u64(vshr_n_u64(LKJIXABC, 8));
|
||||||
const uint8x8_t JIXABC__ = vreinterpret_u8_u64(vshr_n_u64(LKJIXABC, 16));
|
const uint8x8_t JIXABC__ = vreinterpret_u8_u64(vshr_n_u64(LKJIXABC, 16));
|
||||||
|
@ -1427,10 +1428,16 @@ static WEBP_INLINE void DC8_NEON(uint8_t* dst, int do_top, int do_left) {
|
||||||
|
|
||||||
if (do_top) {
|
if (do_top) {
|
||||||
const uint8x8_t A = vld1_u8(dst - BPS); // top row
|
const uint8x8_t A = vld1_u8(dst - BPS); // top row
|
||||||
|
#if defined(__aarch64__)
|
||||||
|
const uint16x8_t B = vmovl_u8(A);
|
||||||
|
const uint16_t p2 = vaddvq_u16(B);
|
||||||
|
sum_top = vdupq_n_u16(p2);
|
||||||
|
#else
|
||||||
const uint16x4_t p0 = vpaddl_u8(A); // cascading summation of the top
|
const uint16x4_t p0 = vpaddl_u8(A); // cascading summation of the top
|
||||||
const uint16x4_t p1 = vpadd_u16(p0, p0);
|
const uint16x4_t p1 = vpadd_u16(p0, p0);
|
||||||
const uint16x4_t p2 = vpadd_u16(p1, p1);
|
const uint16x4_t p2 = vpadd_u16(p1, p1);
|
||||||
sum_top = vcombine_u16(p2, p2);
|
sum_top = vcombine_u16(p2, p2);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_left) {
|
if (do_left) {
|
||||||
|
|
|
@ -81,7 +81,7 @@ static WEBP_INLINE uint32_t ClampedAddSubtractHalf(uint32_t c0, uint32_t c1,
|
||||||
|
|
||||||
// gcc <= 4.9 on ARM generates incorrect code in Select() when Sub3() is
|
// gcc <= 4.9 on ARM generates incorrect code in Select() when Sub3() is
|
||||||
// inlined.
|
// inlined.
|
||||||
#if defined(__arm__) && LOCAL_GCC_VERSION <= 0x409
|
#if defined(__arm__) && defined(__GNUC__) && LOCAL_GCC_VERSION <= 0x409
|
||||||
# define LOCAL_INLINE __attribute__ ((noinline))
|
# define LOCAL_INLINE __attribute__ ((noinline))
|
||||||
#else
|
#else
|
||||||
# define LOCAL_INLINE WEBP_INLINE
|
# define LOCAL_INLINE WEBP_INLINE
|
||||||
|
@ -167,15 +167,20 @@ static uint32_t Predictor13_C(uint32_t left, const uint32_t* const top) {
|
||||||
return pred;
|
return pred;
|
||||||
}
|
}
|
||||||
|
|
||||||
GENERATE_PREDICTOR_ADD(Predictor0_C, PredictorAdd0_C)
|
static void PredictorAdd0_C(const uint32_t* in, const uint32_t* upper,
|
||||||
|
int num_pixels, uint32_t* out) {
|
||||||
|
int x;
|
||||||
|
(void)upper;
|
||||||
|
for (x = 0; x < num_pixels; ++x) out[x] = VP8LAddPixels(in[x], ARGB_BLACK);
|
||||||
|
}
|
||||||
static void PredictorAdd1_C(const uint32_t* in, const uint32_t* upper,
|
static void PredictorAdd1_C(const uint32_t* in, const uint32_t* upper,
|
||||||
int num_pixels, uint32_t* out) {
|
int num_pixels, uint32_t* out) {
|
||||||
int i;
|
int i;
|
||||||
uint32_t left = out[-1];
|
uint32_t left = out[-1];
|
||||||
|
(void)upper;
|
||||||
for (i = 0; i < num_pixels; ++i) {
|
for (i = 0; i < num_pixels; ++i) {
|
||||||
out[i] = left = VP8LAddPixels(in[i], left);
|
out[i] = left = VP8LAddPixels(in[i], left);
|
||||||
}
|
}
|
||||||
(void)upper;
|
|
||||||
}
|
}
|
||||||
GENERATE_PREDICTOR_ADD(Predictor2_C, PredictorAdd2_C)
|
GENERATE_PREDICTOR_ADD(Predictor2_C, PredictorAdd2_C)
|
||||||
GENERATE_PREDICTOR_ADD(Predictor3_C, PredictorAdd3_C)
|
GENERATE_PREDICTOR_ADD(Predictor3_C, PredictorAdd3_C)
|
||||||
|
|
|
@ -177,6 +177,7 @@ uint32_t VP8LSubPixels(uint32_t a, uint32_t b) {
|
||||||
static void PREDICTOR_ADD(const uint32_t* in, const uint32_t* upper, \
|
static void PREDICTOR_ADD(const uint32_t* in, const uint32_t* upper, \
|
||||||
int num_pixels, uint32_t* out) { \
|
int num_pixels, uint32_t* out) { \
|
||||||
int x; \
|
int x; \
|
||||||
|
assert(upper != NULL); \
|
||||||
for (x = 0; x < num_pixels; ++x) { \
|
for (x = 0; x < num_pixels; ++x) { \
|
||||||
const uint32_t pred = (PREDICTOR)(out[x - 1], upper + x); \
|
const uint32_t pred = (PREDICTOR)(out[x - 1], upper + x); \
|
||||||
out[x] = VP8LAddPixels(in[x], pred); \
|
out[x] = VP8LAddPixels(in[x], pred); \
|
||||||
|
@ -189,6 +190,7 @@ static void PREDICTOR_ADD(const uint32_t* in, const uint32_t* upper, \
|
||||||
static void PREDICTOR_SUB(const uint32_t* in, const uint32_t* upper, \
|
static void PREDICTOR_SUB(const uint32_t* in, const uint32_t* upper, \
|
||||||
int num_pixels, uint32_t* out) { \
|
int num_pixels, uint32_t* out) { \
|
||||||
int x; \
|
int x; \
|
||||||
|
assert(upper != NULL); \
|
||||||
for (x = 0; x < num_pixels; ++x) { \
|
for (x = 0; x < num_pixels; ++x) { \
|
||||||
const uint32_t pred = (PREDICTOR)(in[x - 1], upper + x); \
|
const uint32_t pred = (PREDICTOR)(in[x - 1], upper + x); \
|
||||||
out[x] = VP8LSubPixels(in[x], pred); \
|
out[x] = VP8LSubPixels(in[x], pred); \
|
||||||
|
|
|
@ -455,8 +455,9 @@ static void PredictorSub0_SSE2(const uint32_t* in, const uint32_t* upper,
|
||||||
_mm_storeu_si128((__m128i*)&out[i], res);
|
_mm_storeu_si128((__m128i*)&out[i], res);
|
||||||
}
|
}
|
||||||
if (i != num_pixels) {
|
if (i != num_pixels) {
|
||||||
VP8LPredictorsSub_C[0](in + i, upper + i, num_pixels - i, out + i);
|
VP8LPredictorsSub_C[0](in + i, NULL, num_pixels - i, out + i);
|
||||||
}
|
}
|
||||||
|
(void)upper;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GENERATE_PREDICTOR_1(X, IN) \
|
#define GENERATE_PREDICTOR_1(X, IN) \
|
||||||
|
|
|
@ -191,8 +191,9 @@ static void PredictorAdd0_SSE2(const uint32_t* in, const uint32_t* upper,
|
||||||
_mm_storeu_si128((__m128i*)&out[i], res);
|
_mm_storeu_si128((__m128i*)&out[i], res);
|
||||||
}
|
}
|
||||||
if (i != num_pixels) {
|
if (i != num_pixels) {
|
||||||
VP8LPredictorsAdd_C[0](in + i, upper + i, num_pixels - i, out + i);
|
VP8LPredictorsAdd_C[0](in + i, NULL, num_pixels - i, out + i);
|
||||||
}
|
}
|
||||||
|
(void)upper;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Predictor1: left.
|
// Predictor1: left.
|
||||||
|
|
|
@ -29,11 +29,15 @@
|
||||||
#define USE_INVERSE_ALPHA_TABLE
|
#define USE_INVERSE_ALPHA_TABLE
|
||||||
|
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
#define ALPHA_OFFSET 0 // uint32_t 0xff000000 is 0xff,00,00,00 in memory
|
// uint32_t 0xff000000 is 0xff,00,00,00 in memory
|
||||||
|
#define CHANNEL_OFFSET(i) (i)
|
||||||
#else
|
#else
|
||||||
#define ALPHA_OFFSET 3 // uint32_t 0xff000000 is 0x00,00,00,ff in memory
|
// uint32_t 0xff000000 is 0x00,00,00,ff in memory
|
||||||
|
#define CHANNEL_OFFSET(i) (3-(i))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define ALPHA_OFFSET CHANNEL_OFFSET(0)
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Detection of non-trivial transparency
|
// Detection of non-trivial transparency
|
||||||
|
|
||||||
|
@ -997,10 +1001,10 @@ static int PictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace,
|
||||||
return WebPEncodingSetError(picture, VP8_ENC_ERROR_INVALID_CONFIGURATION);
|
return WebPEncodingSetError(picture, VP8_ENC_ERROR_INVALID_CONFIGURATION);
|
||||||
} else {
|
} else {
|
||||||
const uint8_t* const argb = (const uint8_t*)picture->argb;
|
const uint8_t* const argb = (const uint8_t*)picture->argb;
|
||||||
const uint8_t* const a = argb + (0 ^ ALPHA_OFFSET);
|
const uint8_t* const a = argb + CHANNEL_OFFSET(0);
|
||||||
const uint8_t* const r = argb + (1 ^ ALPHA_OFFSET);
|
const uint8_t* const r = argb + CHANNEL_OFFSET(1);
|
||||||
const uint8_t* const g = argb + (2 ^ ALPHA_OFFSET);
|
const uint8_t* const g = argb + CHANNEL_OFFSET(2);
|
||||||
const uint8_t* const b = argb + (3 ^ ALPHA_OFFSET);
|
const uint8_t* const b = argb + CHANNEL_OFFSET(3);
|
||||||
|
|
||||||
picture->colorspace = WEBP_YUV420;
|
picture->colorspace = WEBP_YUV420;
|
||||||
return ImportYUVAFromRGBA(r, g, b, a, 4, 4 * picture->argb_stride,
|
return ImportYUVAFromRGBA(r, g, b, a, 4, 4 * picture->argb_stride,
|
||||||
|
|
|
@ -31,8 +31,8 @@ extern "C" {
|
||||||
|
|
||||||
// version numbers
|
// version numbers
|
||||||
#define ENC_MAJ_VERSION 1
|
#define ENC_MAJ_VERSION 1
|
||||||
#define ENC_MIN_VERSION 0
|
#define ENC_MIN_VERSION 1
|
||||||
#define ENC_REV_VERSION 3
|
#define ENC_REV_VERSION 0
|
||||||
|
|
||||||
enum { MAX_LF_LEVELS = 64, // Maximum loop filter level
|
enum { MAX_LF_LEVELS = 64, // Maximum loop filter level
|
||||||
MAX_VARIABLE_LEVEL = 67, // last (inclusive) level with variable cost
|
MAX_VARIABLE_LEVEL = 67, // last (inclusive) level with variable cost
|
||||||
|
|
|
@ -28,8 +28,8 @@ extern "C" {
|
||||||
// Defines and constants.
|
// Defines and constants.
|
||||||
|
|
||||||
#define MUX_MAJ_VERSION 1
|
#define MUX_MAJ_VERSION 1
|
||||||
#define MUX_MIN_VERSION 0
|
#define MUX_MIN_VERSION 1
|
||||||
#define MUX_REV_VERSION 3
|
#define MUX_REV_VERSION 0
|
||||||
|
|
||||||
// Chunk object.
|
// Chunk object.
|
||||||
typedef struct WebPChunk WebPChunk;
|
typedef struct WebPChunk WebPChunk;
|
||||||
|
|
|
@ -100,7 +100,7 @@ static int MuxImageParse(const WebPChunk* const chunk, int copy_data,
|
||||||
WebPMuxImage* const wpi) {
|
WebPMuxImage* const wpi) {
|
||||||
const uint8_t* bytes = chunk->data_.bytes;
|
const uint8_t* bytes = chunk->data_.bytes;
|
||||||
size_t size = chunk->data_.size;
|
size_t size = chunk->data_.size;
|
||||||
const uint8_t* const last = bytes + size;
|
const uint8_t* const last = (bytes == NULL) ? NULL : bytes + size;
|
||||||
WebPChunk subchunk;
|
WebPChunk subchunk;
|
||||||
size_t subchunk_size;
|
size_t subchunk_size;
|
||||||
WebPChunk** unknown_chunk_list = &wpi->unknown_;
|
WebPChunk** unknown_chunk_list = &wpi->unknown_;
|
||||||
|
|
|
@ -216,9 +216,14 @@ void WebPSafeFree(void* const ptr) {
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Public API function.
|
// Public API functions.
|
||||||
|
|
||||||
|
void* WebPMalloc(size_t size) {
|
||||||
|
return WebPSafeMalloc(1, size);
|
||||||
|
}
|
||||||
|
|
||||||
void WebPFree(void* ptr) {
|
void WebPFree(void* ptr) {
|
||||||
free(ptr);
|
WebPSafeFree(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define WEBP_DECODER_ABI_VERSION 0x0208 // MAJOR(8b) + MINOR(8b)
|
#define WEBP_DECODER_ABI_VERSION 0x0209 // MAJOR(8b) + MINOR(8b)
|
||||||
|
|
||||||
// Note: forward declaring enumerations is not allowed in (strict) C and C++,
|
// Note: forward declaring enumerations is not allowed in (strict) C and C++,
|
||||||
// the types are left here for reference.
|
// the types are left here for reference.
|
||||||
|
@ -91,9 +91,6 @@ WEBP_EXTERN uint8_t* WebPDecodeYUV(const uint8_t* data, size_t data_size,
|
||||||
uint8_t** u, uint8_t** v,
|
uint8_t** u, uint8_t** v,
|
||||||
int* stride, int* uv_stride);
|
int* stride, int* uv_stride);
|
||||||
|
|
||||||
// Releases memory returned by the WebPDecode*() functions above.
|
|
||||||
WEBP_EXTERN void WebPFree(void* ptr);
|
|
||||||
|
|
||||||
// These five functions are variants of the above ones, that decode the image
|
// These five functions are variants of the above ones, that decode the image
|
||||||
// directly into a pre-allocated buffer 'output_buffer'. The maximum storage
|
// directly into a pre-allocated buffer 'output_buffer'. The maximum storage
|
||||||
// available in this buffer is indicated by 'output_buffer_size'. If this
|
// available in this buffer is indicated by 'output_buffer_size'. If this
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define WEBP_ENCODER_ABI_VERSION 0x020e // MAJOR(8b) + MINOR(8b)
|
#define WEBP_ENCODER_ABI_VERSION 0x020f // MAJOR(8b) + MINOR(8b)
|
||||||
|
|
||||||
// Note: forward declaring enumerations is not allowed in (strict) C and C++,
|
// Note: forward declaring enumerations is not allowed in (strict) C and C++,
|
||||||
// the types are left here for reference.
|
// the types are left here for reference.
|
||||||
|
@ -79,9 +79,6 @@ WEBP_EXTERN size_t WebPEncodeLosslessBGRA(const uint8_t* bgra,
|
||||||
int width, int height, int stride,
|
int width, int height, int stride,
|
||||||
uint8_t** output);
|
uint8_t** output);
|
||||||
|
|
||||||
// Releases memory returned by the WebPEncode*() functions above.
|
|
||||||
WEBP_EXTERN void WebPFree(void* ptr);
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Coding parameters
|
// Coding parameters
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ extern "C" {
|
||||||
WebPMuxGetChunk(mux, "ICCP", &icc_profile);
|
WebPMuxGetChunk(mux, "ICCP", &icc_profile);
|
||||||
// ... (Consume icc_data).
|
// ... (Consume icc_data).
|
||||||
WebPMuxDelete(mux);
|
WebPMuxDelete(mux);
|
||||||
free(data);
|
WebPFree(data);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Note: forward declaring enumerations is not allowed in (strict) C and C++,
|
// Note: forward declaring enumerations is not allowed in (strict) C and C++,
|
||||||
|
@ -245,7 +245,7 @@ WEBP_EXTERN WebPMuxError WebPMuxPushFrame(
|
||||||
WebPMux* mux, const WebPMuxFrameInfo* frame, int copy_data);
|
WebPMux* mux, const WebPMuxFrameInfo* frame, int copy_data);
|
||||||
|
|
||||||
// Gets the nth frame from the mux object.
|
// Gets the nth frame from the mux object.
|
||||||
// The content of 'frame->bitstream' is allocated using malloc(), and NOT
|
// The content of 'frame->bitstream' is allocated using WebPMalloc(), and NOT
|
||||||
// owned by the 'mux' object. It MUST be deallocated by the caller by calling
|
// owned by the 'mux' object. It MUST be deallocated by the caller by calling
|
||||||
// WebPDataClear().
|
// WebPDataClear().
|
||||||
// nth=0 has a special meaning - last position.
|
// nth=0 has a special meaning - last position.
|
||||||
|
@ -376,10 +376,10 @@ WEBP_EXTERN WebPMuxError WebPMuxNumChunks(const WebPMux* mux,
|
||||||
// Assembles all chunks in WebP RIFF format and returns in 'assembled_data'.
|
// Assembles all chunks in WebP RIFF format and returns in 'assembled_data'.
|
||||||
// This function also validates the mux object.
|
// This function also validates the mux object.
|
||||||
// Note: The content of 'assembled_data' will be ignored and overwritten.
|
// Note: The content of 'assembled_data' will be ignored and overwritten.
|
||||||
// Also, the content of 'assembled_data' is allocated using malloc(), and NOT
|
// Also, the content of 'assembled_data' is allocated using WebPMalloc(), and
|
||||||
// owned by the 'mux' object. It MUST be deallocated by the caller by calling
|
// NOT owned by the 'mux' object. It MUST be deallocated by the caller by
|
||||||
// WebPDataClear(). It's always safe to call WebPDataClear() upon return,
|
// calling WebPDataClear(). It's always safe to call WebPDataClear() upon
|
||||||
// even in case of error.
|
// return, even in case of error.
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// mux - (in/out) object whose chunks are to be assembled
|
// mux - (in/out) object whose chunks are to be assembled
|
||||||
// assembled_data - (out) assembled WebP data
|
// assembled_data - (out) assembled WebP data
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#ifndef WEBP_WEBP_MUX_TYPES_H_
|
#ifndef WEBP_WEBP_MUX_TYPES_H_
|
||||||
#define WEBP_WEBP_MUX_TYPES_H_
|
#define WEBP_WEBP_MUX_TYPES_H_
|
||||||
|
|
||||||
#include <stdlib.h> // free()
|
|
||||||
#include <string.h> // memset()
|
#include <string.h> // memset()
|
||||||
#include "./types.h"
|
#include "./types.h"
|
||||||
|
|
||||||
|
@ -56,6 +55,7 @@ typedef enum WebPMuxAnimBlend {
|
||||||
|
|
||||||
// Data type used to describe 'raw' data, e.g., chunk data
|
// Data type used to describe 'raw' data, e.g., chunk data
|
||||||
// (ICC profile, metadata) and WebP compressed image data.
|
// (ICC profile, metadata) and WebP compressed image data.
|
||||||
|
// 'bytes' memory must be allocated using WebPMalloc() and such.
|
||||||
struct WebPData {
|
struct WebPData {
|
||||||
const uint8_t* bytes;
|
const uint8_t* bytes;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
@ -68,11 +68,11 @@ static WEBP_INLINE void WebPDataInit(WebPData* webp_data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clears the contents of the 'webp_data' object by calling free(). Does not
|
// Clears the contents of the 'webp_data' object by calling WebPFree().
|
||||||
// deallocate the object itself.
|
// Does not deallocate the object itself.
|
||||||
static WEBP_INLINE void WebPDataClear(WebPData* webp_data) {
|
static WEBP_INLINE void WebPDataClear(WebPData* webp_data) {
|
||||||
if (webp_data != NULL) {
|
if (webp_data != NULL) {
|
||||||
free((void*)webp_data->bytes);
|
WebPFree((void*)webp_data->bytes);
|
||||||
WebPDataInit(webp_data);
|
WebPDataInit(webp_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ static WEBP_INLINE int WebPDataCopy(const WebPData* src, WebPData* dst) {
|
||||||
if (src == NULL || dst == NULL) return 0;
|
if (src == NULL || dst == NULL) return 0;
|
||||||
WebPDataInit(dst);
|
WebPDataInit(dst);
|
||||||
if (src->bytes != NULL && src->size != 0) {
|
if (src->bytes != NULL && src->size != 0) {
|
||||||
dst->bytes = (uint8_t*)malloc(src->size);
|
dst->bytes = (uint8_t*)WebPMalloc(src->size);
|
||||||
if (dst->bytes == NULL) return 0;
|
if (dst->bytes == NULL) return 0;
|
||||||
memcpy((void*)dst->bytes, src->bytes, src->size);
|
memcpy((void*)dst->bytes, src->bytes, src->size);
|
||||||
dst->size = src->size;
|
dst->size = src->size;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
// be found in the AUTHORS file in the root of the source tree.
|
// be found in the AUTHORS file in the root of the source tree.
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Common types
|
// Common types + memory wrappers
|
||||||
//
|
//
|
||||||
// Author: Skal (pascal.massimino@gmail.com)
|
// Author: Skal (pascal.massimino@gmail.com)
|
||||||
|
|
||||||
|
@ -49,4 +49,20 @@ typedef long long int int64_t;
|
||||||
// Macro to check ABI compatibility (same major revision number)
|
// Macro to check ABI compatibility (same major revision number)
|
||||||
#define WEBP_ABI_IS_INCOMPATIBLE(a, b) (((a) >> 8) != ((b) >> 8))
|
#define WEBP_ABI_IS_INCOMPATIBLE(a, b) (((a) >> 8) != ((b) >> 8))
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Allocates 'size' bytes of memory. Returns NULL upon error. Memory
|
||||||
|
// must be deallocated by calling WebPFree(). This function is made available
|
||||||
|
// by the core 'libwebp' library.
|
||||||
|
WEBP_EXTERN void* WebPMalloc(size_t size);
|
||||||
|
|
||||||
|
// Releases memory returned by the WebPDecode*() functions (from decode.h).
|
||||||
|
WEBP_EXTERN void WebPFree(void* ptr);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // WEBP_WEBP_TYPES_H_
|
#endif // WEBP_WEBP_TYPES_H_
|
||||||
|
|
Loading…
Reference in New Issue