Path: blob/master/thirdparty/libwebp/src/webp/format_constants.h
9913 views
// Copyright 2012 Google Inc. All Rights Reserved.1//2// Use of this source code is governed by a BSD-style license3// that can be found in the COPYING file in the root of the source4// tree. An additional intellectual property rights grant can be found5// in the file PATENTS. All contributing project authors may6// be found in the AUTHORS file in the root of the source tree.7// -----------------------------------------------------------------------------8//9// Internal header for constants related to WebP file format.10//11// Author: Urvang ([email protected])1213#ifndef WEBP_WEBP_FORMAT_CONSTANTS_H_14#define WEBP_WEBP_FORMAT_CONSTANTS_H_1516// Create fourcc of the chunk from the chunk tag characters.17#define MKFOURCC(a, b, c, d) ((a) | (b) << 8 | (c) << 16 | (uint32_t)(d) << 24)1819// VP8 related constants.20#define VP8_SIGNATURE 0x9d012a // Signature in VP8 data.21#define VP8_MAX_PARTITION0_SIZE (1 << 19) // max size of mode partition22#define VP8_MAX_PARTITION_SIZE (1 << 24) // max size for token partition23#define VP8_FRAME_HEADER_SIZE 10 // Size of the frame header within VP8 data.2425// VP8L related constants.26#define VP8L_SIGNATURE_SIZE 1 // VP8L signature size.27#define VP8L_MAGIC_BYTE 0x2f // VP8L signature byte.28#define VP8L_IMAGE_SIZE_BITS 14 // Number of bits used to store29// width and height.30#define VP8L_VERSION_BITS 3 // 3 bits reserved for version.31#define VP8L_VERSION 0 // version 032#define VP8L_FRAME_HEADER_SIZE 5 // Size of the VP8L frame header.3334#define MAX_PALETTE_SIZE 25635#define MAX_CACHE_BITS 1136#define HUFFMAN_CODES_PER_META_CODE 537#define ARGB_BLACK 0xff0000003839#define DEFAULT_CODE_LENGTH 840#define MAX_ALLOWED_CODE_LENGTH 154142#define NUM_LITERAL_CODES 25643#define NUM_LENGTH_CODES 2444#define NUM_DISTANCE_CODES 4045#define CODE_LENGTH_CODES 194647#define MIN_HUFFMAN_BITS 2 // min number of Huffman bits48#define NUM_HUFFMAN_BITS 34950// the maximum number of bits defining a transform is51// MIN_TRANSFORM_BITS + (1 << NUM_TRANSFORM_BITS) - 152#define MIN_TRANSFORM_BITS 253#define NUM_TRANSFORM_BITS 35455#define TRANSFORM_PRESENT 1 // The bit to be written when next data56// to be read is a transform.57#define NUM_TRANSFORMS 4 // Maximum number of allowed transform58// in a bitstream.59typedef enum {60PREDICTOR_TRANSFORM = 0,61CROSS_COLOR_TRANSFORM = 1,62SUBTRACT_GREEN_TRANSFORM = 2,63COLOR_INDEXING_TRANSFORM = 364} VP8LImageTransformType;6566// Alpha related constants.67#define ALPHA_HEADER_LEN 168#define ALPHA_NO_COMPRESSION 069#define ALPHA_LOSSLESS_COMPRESSION 170#define ALPHA_PREPROCESSED_LEVELS 17172// Mux related constants.73#define TAG_SIZE 4 // Size of a chunk tag (e.g. "VP8L").74#define CHUNK_SIZE_BYTES 4 // Size needed to store chunk's size.75#define CHUNK_HEADER_SIZE 8 // Size of a chunk header.76#define RIFF_HEADER_SIZE 12 // Size of the RIFF header ("RIFFnnnnWEBP").77#define ANMF_CHUNK_SIZE 16 // Size of an ANMF chunk.78#define ANIM_CHUNK_SIZE 6 // Size of an ANIM chunk.79#define VP8X_CHUNK_SIZE 10 // Size of a VP8X chunk.8081#define MAX_CANVAS_SIZE (1 << 24) // 24-bit max for VP8X width/height.82#define MAX_IMAGE_AREA (1ULL << 32) // 32-bit max for width x height.83#define MAX_LOOP_COUNT (1 << 16) // maximum value for loop-count84#define MAX_DURATION (1 << 24) // maximum duration85#define MAX_POSITION_OFFSET (1 << 24) // maximum frame x/y offset8687// Maximum chunk payload is such that adding the header and padding won't88// overflow a uint32_t.89#define MAX_CHUNK_PAYLOAD (~0U - CHUNK_HEADER_SIZE - 1)9091#endif // WEBP_WEBP_FORMAT_CONSTANTS_H_929394