New comit of SDL2
[supertux.git] / src / SDL2 / external / libwebp-0.3.0 / src / webp / format_constants.h
1 // Copyright 2012 Google Inc. All Rights Reserved.
2 //
3 // This code is licensed under the same terms as WebM:
4 //  Software License Agreement:  http://www.webmproject.org/license/software/
5 //  Additional IP Rights Grant:  http://www.webmproject.org/license/additional/
6 // -----------------------------------------------------------------------------
7 //
8 //  Internal header for constants related to WebP file format.
9 //
10 // Author: Urvang (urvang@google.com)
11
12 #ifndef WEBP_WEBP_FORMAT_CONSTANTS_H_
13 #define WEBP_WEBP_FORMAT_CONSTANTS_H_
14
15 // Create fourcc of the chunk from the chunk tag characters.
16 #define MKFOURCC(a, b, c, d) ((uint32_t)(a) | (b) << 8 | (c) << 16 | (d) << 24)
17
18 // VP8 related constants.
19 #define VP8_SIGNATURE 0x9d012a              // Signature in VP8 data.
20 #define VP8_MAX_PARTITION0_SIZE (1 << 19)   // max size of mode partition
21 #define VP8_MAX_PARTITION_SIZE  (1 << 24)   // max size for token partition
22 #define VP8_FRAME_HEADER_SIZE 10  // Size of the frame header within VP8 data.
23
24 // VP8L related constants.
25 #define VP8L_SIGNATURE_SIZE          1      // VP8L signature size.
26 #define VP8L_MAGIC_BYTE              0x2f   // VP8L signature byte.
27 #define VP8L_IMAGE_SIZE_BITS         14     // Number of bits used to store
28                                             // width and height.
29 #define VP8L_VERSION_BITS            3      // 3 bits reserved for version.
30 #define VP8L_VERSION                 0      // version 0
31 #define VP8L_FRAME_HEADER_SIZE       5      // Size of the VP8L frame header.
32
33 #define MAX_PALETTE_SIZE             256
34 #define MAX_CACHE_BITS               11
35 #define HUFFMAN_CODES_PER_META_CODE  5
36 #define ARGB_BLACK                   0xff000000
37
38 #define DEFAULT_CODE_LENGTH          8
39 #define MAX_ALLOWED_CODE_LENGTH      15
40
41 #define NUM_LITERAL_CODES            256
42 #define NUM_LENGTH_CODES             24
43 #define NUM_DISTANCE_CODES           40
44 #define CODE_LENGTH_CODES            19
45
46 #define MIN_HUFFMAN_BITS             2  // min number of Huffman bits
47 #define MAX_HUFFMAN_BITS             9  // max number of Huffman bits
48
49 #define TRANSFORM_PRESENT            1  // The bit to be written when next data
50                                         // to be read is a transform.
51 #define NUM_TRANSFORMS               4  // Maximum number of allowed transform
52                                         // in a bitstream.
53 typedef enum {
54   PREDICTOR_TRANSFORM      = 0,
55   CROSS_COLOR_TRANSFORM    = 1,
56   SUBTRACT_GREEN           = 2,
57   COLOR_INDEXING_TRANSFORM = 3
58 } VP8LImageTransformType;
59
60 // Alpha related constants.
61 #define ALPHA_HEADER_LEN            1
62 #define ALPHA_NO_COMPRESSION        0
63 #define ALPHA_LOSSLESS_COMPRESSION  1
64 #define ALPHA_PREPROCESSED_LEVELS   1
65
66 // Mux related constants.
67 #define TAG_SIZE           4     // Size of a chunk tag (e.g. "VP8L").
68 #define CHUNK_SIZE_BYTES   4     // Size needed to store chunk's size.
69 #define CHUNK_HEADER_SIZE  8     // Size of a chunk header.
70 #define RIFF_HEADER_SIZE   12    // Size of the RIFF header ("RIFFnnnnWEBP").
71 #define ANMF_CHUNK_SIZE    16    // Size of an ANMF chunk.
72 #define ANIM_CHUNK_SIZE    6     // Size of an ANIM chunk.
73 #define FRGM_CHUNK_SIZE    6     // Size of a FRGM chunk.
74 #define VP8X_CHUNK_SIZE    10    // Size of a VP8X chunk.
75
76 #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-count
79 #define MAX_DURATION        (1 << 24)     // maximum duration
80 #define MAX_POSITION_OFFSET (1 << 24)     // maximum frame/fragment x/y offset
81
82 // Maximum chunk payload is such that adding the header and padding won't
83 // overflow a uint32_t.
84 #define MAX_CHUNK_PAYLOAD (~0U - CHUNK_HEADER_SIZE - 1)
85
86 #endif  /* WEBP_WEBP_FORMAT_CONSTANTS_H_ */