mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 06:24:27 +02:00
Move consts to internal header format_constants.h
Change-Id: Ic6180c16d0b4245680738992925e4608c593fbe8
This commit is contained in:
@ -21,7 +21,9 @@ libwebpencode_la_SOURCES += webpenc.c
|
||||
libwebpencodeinclude_HEADERS =
|
||||
libwebpencodeinclude_HEADERS += ../webp/encode.h
|
||||
libwebpencodeinclude_HEADERS += ../webp/types.h
|
||||
noinst_HEADERS = ../webp/mux.h
|
||||
noinst_HEADERS =
|
||||
noinst_HEADERS += ../webp/format_constants.h
|
||||
noinst_HEADERS += ../webp/mux.h
|
||||
|
||||
libwebpencode_la_LDFLAGS = -lm
|
||||
libwebpencode_la_CPPFLAGS = $(USE_EXPERIMENTAL_CODE)
|
||||
|
@ -15,17 +15,12 @@
|
||||
#include "./vp8enci.h"
|
||||
#include "../utils/filters.h"
|
||||
#include "../utils/quant_levels.h"
|
||||
#include "../webp/format_constants.h"
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// TODO(skal): find a common place between enc/ and dec/ for these:
|
||||
#define ALPHA_HEADER_LEN 1
|
||||
#define ALPHA_NO_COMPRESSION 0
|
||||
#define ALPHA_LOSSLESS_COMPRESSION 1
|
||||
#define ALPHA_PREPROCESSED_LEVELS 1
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// int EncodeAlpha(const uint8_t* data, int width, int height, int stride,
|
||||
// int quality, int method, int filter, int effort_level,
|
||||
|
@ -11,22 +11,17 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "../webp/format_constants.h"
|
||||
#include "./vp8enci.h"
|
||||
#include "../dec/webpi.h" // For chunk-size constants.
|
||||
#include "../webp/mux.h" // For 'ALPHA_FLAG' constant.
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define KSIGNATURE 0x9d012a
|
||||
#define MAX_PARTITION0_SIZE (1 << 19) // max size of mode partition
|
||||
#define MAX_PARTITION_SIZE (1 << 24) // max size for token partition
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helper functions
|
||||
|
||||
// TODO(later): Move to webp/format_constants.h?
|
||||
static void PutLE32(uint8_t* const data, uint32_t val) {
|
||||
data[0] = (val >> 0) & 0xff;
|
||||
data[1] = (val >> 8) & 0xff;
|
||||
@ -72,7 +67,7 @@ static WebPEncodingError PutVP8XHeader(const VP8Encoder* const enc) {
|
||||
assert(IsVP8XNeeded(enc));
|
||||
|
||||
if (enc->has_alpha_) {
|
||||
flags |= ALPHA_FLAG;
|
||||
flags |= ALPHA_FLAG_BIT;
|
||||
}
|
||||
|
||||
PutLE32(vp8x + TAG_SIZE, VP8X_CHUNK_SIZE);
|
||||
@ -129,7 +124,7 @@ static WebPEncodingError PutVP8FrameHeader(const WebPPicture* const pic,
|
||||
uint8_t vp8_frm_hdr[VP8_FRAME_HEADER_SIZE];
|
||||
uint32_t bits;
|
||||
|
||||
if (size0 >= MAX_PARTITION0_SIZE) { // partition #0 is too big to fit
|
||||
if (size0 >= VP8_MAX_PARTITION0_SIZE) { // partition #0 is too big to fit
|
||||
return VP8_ENC_ERROR_PARTITION0_OVERFLOW;
|
||||
}
|
||||
|
||||
@ -142,9 +137,9 @@ static WebPEncodingError PutVP8FrameHeader(const WebPPicture* const pic,
|
||||
vp8_frm_hdr[1] = (bits >> 8) & 0xff;
|
||||
vp8_frm_hdr[2] = (bits >> 16) & 0xff;
|
||||
// signature
|
||||
vp8_frm_hdr[3] = (KSIGNATURE >> 16) & 0xff;
|
||||
vp8_frm_hdr[4] = (KSIGNATURE >> 8) & 0xff;
|
||||
vp8_frm_hdr[5] = (KSIGNATURE >> 0) & 0xff;
|
||||
vp8_frm_hdr[3] = (VP8_SIGNATURE >> 16) & 0xff;
|
||||
vp8_frm_hdr[4] = (VP8_SIGNATURE >> 8) & 0xff;
|
||||
vp8_frm_hdr[5] = (VP8_SIGNATURE >> 0) & 0xff;
|
||||
// dimensions
|
||||
vp8_frm_hdr[6] = pic->width & 0xff;
|
||||
vp8_frm_hdr[7] = pic->width >> 8;
|
||||
@ -263,7 +258,7 @@ static int EmitPartitionsSize(const VP8Encoder* const enc,
|
||||
int p;
|
||||
for (p = 0; p < enc->num_parts_ - 1; ++p) {
|
||||
const size_t part_size = VP8BitWriterSize(enc->parts_ + p);
|
||||
if (part_size >= MAX_PARTITION_SIZE) {
|
||||
if (part_size >= VP8_MAX_PARTITION_SIZE) {
|
||||
return WebPEncodingSetError(pic, VP8_ENC_ERROR_PARTITION_OVERFLOW);
|
||||
}
|
||||
buf[3 * p + 0] = (part_size >> 0) & 0xff;
|
||||
|
@ -27,17 +27,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PALETTE_KEY_RIGHT_SHIFT 22 // Key for 1K buffer.
|
||||
#define MAX_HUFF_IMAGE_SIZE (32 * 1024 * 1024)
|
||||
|
||||
// TODO(vikas): find a common place between enc and dec for these:
|
||||
#define PREDICTOR_TRANSFORM 0
|
||||
#define CROSS_COLOR_TRANSFORM 1
|
||||
#define SUBTRACT_GREEN 2
|
||||
#define COLOR_INDEXING_TRANSFORM 3
|
||||
#define TRANSFORM_PRESENT 1
|
||||
|
||||
#define IMAGE_SIZE_BITS 14
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Palette
|
||||
|
||||
@ -640,9 +632,9 @@ static void PutLE32(uint8_t* const data, uint32_t val) {
|
||||
|
||||
static WebPEncodingError WriteRiffHeader(const WebPPicture* const pic,
|
||||
size_t riff_size, size_t vp8l_size) {
|
||||
uint8_t riff[HEADER_SIZE + SIGNATURE_SIZE] = {
|
||||
uint8_t riff[RIFF_HEADER_SIZE + CHUNK_HEADER_SIZE + VP8L_SIGNATURE_SIZE] = {
|
||||
'R', 'I', 'F', 'F', 0, 0, 0, 0, 'W', 'E', 'B', 'P',
|
||||
'V', 'P', '8', 'L', 0, 0, 0, 0, LOSSLESS_MAGIC_BYTE,
|
||||
'V', 'P', '8', 'L', 0, 0, 0, 0, VP8L_MAGIC_BYTE,
|
||||
};
|
||||
PutLE32(riff + TAG_SIZE, (uint32_t)riff_size);
|
||||
PutLE32(riff + RIFF_HEADER_SIZE + TAG_SIZE, (uint32_t)vp8l_size);
|
||||
@ -658,8 +650,8 @@ static int WriteImageSize(const WebPPicture* const pic,
|
||||
const int height = pic->height -1;
|
||||
assert(width < WEBP_MAX_DIMENSION && height < WEBP_MAX_DIMENSION);
|
||||
|
||||
VP8LWriteBits(bw, IMAGE_SIZE_BITS, width);
|
||||
VP8LWriteBits(bw, IMAGE_SIZE_BITS, height);
|
||||
VP8LWriteBits(bw, VP8L_IMAGE_SIZE_BITS, width);
|
||||
VP8LWriteBits(bw, VP8L_IMAGE_SIZE_BITS, height);
|
||||
return !bw->error_;
|
||||
}
|
||||
|
||||
@ -669,7 +661,7 @@ static WebPEncodingError WriteImage(const WebPPicture* const pic,
|
||||
WebPEncodingError err = VP8_ENC_OK;
|
||||
const uint8_t* const webpll_data = VP8LBitWriterFinish(bw);
|
||||
const size_t webpll_size = VP8LBitWriterNumBytes(bw);
|
||||
const size_t vp8l_size = SIGNATURE_SIZE + webpll_size;
|
||||
const size_t vp8l_size = VP8L_SIGNATURE_SIZE + webpll_size;
|
||||
const size_t pad = vp8l_size & 1;
|
||||
const size_t riff_size = TAG_SIZE + CHUNK_HEADER_SIZE + vp8l_size + pad;
|
||||
|
||||
|
@ -15,24 +15,14 @@
|
||||
#ifdef USE_LOSSLESS_ENCODER
|
||||
|
||||
#include "./histogram.h"
|
||||
#include "../webp/encode.h"
|
||||
#include "../utils/bit_writer.h"
|
||||
#include "../webp/encode.h"
|
||||
#include "../webp/format_constants.h"
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// TODO(vikasa): factorize these with ones used in lossless decoder.
|
||||
#define TAG_SIZE 4
|
||||
#define CHUNK_HEADER_SIZE 8
|
||||
#define RIFF_HEADER_SIZE 12
|
||||
#define HEADER_SIZE (RIFF_HEADER_SIZE + CHUNK_HEADER_SIZE)
|
||||
#define SIGNATURE_SIZE 1
|
||||
#define LOSSLESS_MAGIC_BYTE 0x64
|
||||
|
||||
#define MAX_PALETTE_SIZE 256
|
||||
#define PALETTE_KEY_RIGHT_SHIFT 22 // Key for 1K buffer.
|
||||
|
||||
typedef struct {
|
||||
const WebPConfig* config_; // user configuration and parameters
|
||||
const WebPPicture* pic_; // input picture.
|
||||
|
Reference in New Issue
Block a user