1a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora// Copyright 2012 Google Inc. All Rights Reserved. 2a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora// 30406ce1417f76f2034833414dcecc9f56253640cVikas Arora// Use of this source code is governed by a BSD-style license 40406ce1417f76f2034833414dcecc9f56253640cVikas Arora// that can be found in the COPYING file in the root of the source 50406ce1417f76f2034833414dcecc9f56253640cVikas Arora// tree. An additional intellectual property rights grant can be found 60406ce1417f76f2034833414dcecc9f56253640cVikas Arora// in the file PATENTS. All contributing project authors may 70406ce1417f76f2034833414dcecc9f56253640cVikas Arora// be found in the AUTHORS file in the root of the source tree. 8a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora// ----------------------------------------------------------------------------- 9a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora// 10a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora// Internal header for constants related to WebP file format. 11a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora// 12a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora// Author: Urvang (urvang@google.com) 13a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora 14a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#ifndef WEBP_WEBP_FORMAT_CONSTANTS_H_ 15a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define WEBP_WEBP_FORMAT_CONSTANTS_H_ 16a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora 170406ce1417f76f2034833414dcecc9f56253640cVikas Arora// Create fourcc of the chunk from the chunk tag characters. 180406ce1417f76f2034833414dcecc9f56253640cVikas Arora#define MKFOURCC(a, b, c, d) ((uint32_t)(a) | (b) << 8 | (c) << 16 | (d) << 24) 190406ce1417f76f2034833414dcecc9f56253640cVikas Arora 20a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora// VP8 related constants. 21a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define VP8_SIGNATURE 0x9d012a // Signature in VP8 data. 22a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define VP8_MAX_PARTITION0_SIZE (1 << 19) // max size of mode partition 23a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define VP8_MAX_PARTITION_SIZE (1 << 24) // max size for token partition 24a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define VP8_FRAME_HEADER_SIZE 10 // Size of the frame header within VP8 data. 25a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora 26a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora// VP8L related constants. 27a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define VP8L_SIGNATURE_SIZE 1 // VP8L signature size. 28a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define VP8L_MAGIC_BYTE 0x2f // VP8L signature byte. 29a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define VP8L_IMAGE_SIZE_BITS 14 // Number of bits used to store 30a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora // width and height. 31a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define VP8L_VERSION_BITS 3 // 3 bits reserved for version. 32a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define VP8L_VERSION 0 // version 0 33a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define VP8L_FRAME_HEADER_SIZE 5 // Size of the VP8L frame header. 34a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora 35a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define MAX_PALETTE_SIZE 256 36a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define MAX_CACHE_BITS 11 37a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define HUFFMAN_CODES_PER_META_CODE 5 38a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define ARGB_BLACK 0xff000000 39a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora 40a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define DEFAULT_CODE_LENGTH 8 41a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define MAX_ALLOWED_CODE_LENGTH 15 42a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora 43a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define NUM_LITERAL_CODES 256 44a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define NUM_LENGTH_CODES 24 45a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define NUM_DISTANCE_CODES 40 46a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define CODE_LENGTH_CODES 19 47a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora 48a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define MIN_HUFFMAN_BITS 2 // min number of Huffman bits 49a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define MAX_HUFFMAN_BITS 9 // max number of Huffman bits 50a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora 51a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define TRANSFORM_PRESENT 1 // The bit to be written when next data 52a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora // to be read is a transform. 53a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define NUM_TRANSFORMS 4 // Maximum number of allowed transform 54a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora // in a bitstream. 55a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Aroratypedef enum { 56a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora PREDICTOR_TRANSFORM = 0, 57a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora CROSS_COLOR_TRANSFORM = 1, 58a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora SUBTRACT_GREEN = 2, 59a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora COLOR_INDEXING_TRANSFORM = 3 60a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora} VP8LImageTransformType; 61a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora 62a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora// Alpha related constants. 63a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define ALPHA_HEADER_LEN 1 64a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define ALPHA_NO_COMPRESSION 0 65a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define ALPHA_LOSSLESS_COMPRESSION 1 66a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define ALPHA_PREPROCESSED_LEVELS 1 67a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora 68a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora// Mux related constants. 69a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define TAG_SIZE 4 // Size of a chunk tag (e.g. "VP8L"). 70a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define CHUNK_SIZE_BYTES 4 // Size needed to store chunk's size. 71a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define CHUNK_HEADER_SIZE 8 // Size of a chunk header. 72a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define RIFF_HEADER_SIZE 12 // Size of the RIFF header ("RIFFnnnnWEBP"). 731e7bf8805bd030c19924a5306837ecd72c295751Vikas Arora#define ANMF_CHUNK_SIZE 16 // Size of an ANMF chunk. 741e7bf8805bd030c19924a5306837ecd72c295751Vikas Arora#define ANIM_CHUNK_SIZE 6 // Size of an ANIM chunk. 751e7bf8805bd030c19924a5306837ecd72c295751Vikas Arora#define FRGM_CHUNK_SIZE 6 // Size of a FRGM chunk. 76a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define VP8X_CHUNK_SIZE 10 // Size of a VP8X chunk. 77a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora 780406ce1417f76f2034833414dcecc9f56253640cVikas Arora#define MAX_CANVAS_SIZE (1 << 24) // 24-bit max for VP8X width/height. 790406ce1417f76f2034833414dcecc9f56253640cVikas Arora#define MAX_IMAGE_AREA (1ULL << 32) // 32-bit max for width x height. 800406ce1417f76f2034833414dcecc9f56253640cVikas Arora#define MAX_LOOP_COUNT (1 << 16) // maximum value for loop-count 810406ce1417f76f2034833414dcecc9f56253640cVikas Arora#define MAX_DURATION (1 << 24) // maximum duration 820406ce1417f76f2034833414dcecc9f56253640cVikas Arora#define MAX_POSITION_OFFSET (1 << 24) // maximum frame/fragment x/y offset 83a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora 84a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora// Maximum chunk payload is such that adding the header and padding won't 85a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora// overflow a uint32_t. 86a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#define MAX_CHUNK_PAYLOAD (~0U - CHUNK_HEADER_SIZE - 1) 87a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora 88a2415724fb3466168b2af5b08bd94ba732c0e753Vikas Arora#endif /* WEBP_WEBP_FORMAT_CONSTANTS_H_ */ 89