Path: blob/master/3rdparty/libwebp/src/webp/format_constants.h
16348 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 MAX_HUFFMAN_BITS 9 // max number of Huffman bits4950#define TRANSFORM_PRESENT 1 // The bit to be written when next data51// to be read is a transform.52#define NUM_TRANSFORMS 4 // Maximum number of allowed transform53// in a bitstream.54typedef enum {55PREDICTOR_TRANSFORM = 0,56CROSS_COLOR_TRANSFORM = 1,57SUBTRACT_GREEN = 2,58COLOR_INDEXING_TRANSFORM = 359} VP8LImageTransformType;6061// Alpha related constants.62#define ALPHA_HEADER_LEN 163#define ALPHA_NO_COMPRESSION 064#define ALPHA_LOSSLESS_COMPRESSION 165#define ALPHA_PREPROCESSED_LEVELS 16667// Mux related constants.68#define TAG_SIZE 4 // Size of a chunk tag (e.g. "VP8L").69#define CHUNK_SIZE_BYTES 4 // Size needed to store chunk's size.70#define CHUNK_HEADER_SIZE 8 // Size of a chunk header.71#define RIFF_HEADER_SIZE 12 // Size of the RIFF header ("RIFFnnnnWEBP").72#define ANMF_CHUNK_SIZE 16 // Size of an ANMF chunk.73#define ANIM_CHUNK_SIZE 6 // Size of an ANIM chunk.74#define VP8X_CHUNK_SIZE 10 // Size of a VP8X chunk.7576#define MAX_CANVAS_SIZE (1 << 24) // 24-bit max for VP8X width/height.77#define MAX_IMAGE_AREA (1ULL << 32) // 32-bit max for width x height.78#define MAX_LOOP_COUNT (1 << 16) // maximum value for loop-count79#define MAX_DURATION (1 << 24) // maximum duration80#define MAX_POSITION_OFFSET (1 << 24) // maximum frame x/y offset8182// Maximum chunk payload is such that adding the header and padding won't83// overflow a uint32_t.84#define MAX_CHUNK_PAYLOAD (~0U - CHUNK_HEADER_SIZE - 1)8586#endif /* WEBP_WEBP_FORMAT_CONSTANTS_H_ */878889