Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/libwebp/src/webp/format_constants.h
9913 views
1
// Copyright 2012 Google Inc. All Rights Reserved.
2
//
3
// Use of this source code is governed by a BSD-style license
4
// that can be found in the COPYING file in the root of the source
5
// tree. An additional intellectual property rights grant can be found
6
// in the file PATENTS. All contributing project authors may
7
// be found in the AUTHORS file in the root of the source tree.
8
// -----------------------------------------------------------------------------
9
//
10
// Internal header for constants related to WebP file format.
11
//
12
// Author: Urvang ([email protected])
13
14
#ifndef WEBP_WEBP_FORMAT_CONSTANTS_H_
15
#define WEBP_WEBP_FORMAT_CONSTANTS_H_
16
17
// Create fourcc of the chunk from the chunk tag characters.
18
#define MKFOURCC(a, b, c, d) ((a) | (b) << 8 | (c) << 16 | (uint32_t)(d) << 24)
19
20
// VP8 related constants.
21
#define VP8_SIGNATURE 0x9d012a // Signature in VP8 data.
22
#define VP8_MAX_PARTITION0_SIZE (1 << 19) // max size of mode partition
23
#define VP8_MAX_PARTITION_SIZE (1 << 24) // max size for token partition
24
#define VP8_FRAME_HEADER_SIZE 10 // Size of the frame header within VP8 data.
25
26
// VP8L related constants.
27
#define VP8L_SIGNATURE_SIZE 1 // VP8L signature size.
28
#define VP8L_MAGIC_BYTE 0x2f // VP8L signature byte.
29
#define VP8L_IMAGE_SIZE_BITS 14 // Number of bits used to store
30
// width and height.
31
#define VP8L_VERSION_BITS 3 // 3 bits reserved for version.
32
#define VP8L_VERSION 0 // version 0
33
#define VP8L_FRAME_HEADER_SIZE 5 // Size of the VP8L frame header.
34
35
#define MAX_PALETTE_SIZE 256
36
#define MAX_CACHE_BITS 11
37
#define HUFFMAN_CODES_PER_META_CODE 5
38
#define ARGB_BLACK 0xff000000
39
40
#define DEFAULT_CODE_LENGTH 8
41
#define MAX_ALLOWED_CODE_LENGTH 15
42
43
#define NUM_LITERAL_CODES 256
44
#define NUM_LENGTH_CODES 24
45
#define NUM_DISTANCE_CODES 40
46
#define CODE_LENGTH_CODES 19
47
48
#define MIN_HUFFMAN_BITS 2 // min number of Huffman bits
49
#define NUM_HUFFMAN_BITS 3
50
51
// the maximum number of bits defining a transform is
52
// MIN_TRANSFORM_BITS + (1 << NUM_TRANSFORM_BITS) - 1
53
#define MIN_TRANSFORM_BITS 2
54
#define NUM_TRANSFORM_BITS 3
55
56
#define TRANSFORM_PRESENT 1 // The bit to be written when next data
57
// to be read is a transform.
58
#define NUM_TRANSFORMS 4 // Maximum number of allowed transform
59
// in a bitstream.
60
typedef enum {
61
PREDICTOR_TRANSFORM = 0,
62
CROSS_COLOR_TRANSFORM = 1,
63
SUBTRACT_GREEN_TRANSFORM = 2,
64
COLOR_INDEXING_TRANSFORM = 3
65
} VP8LImageTransformType;
66
67
// Alpha related constants.
68
#define ALPHA_HEADER_LEN 1
69
#define ALPHA_NO_COMPRESSION 0
70
#define ALPHA_LOSSLESS_COMPRESSION 1
71
#define ALPHA_PREPROCESSED_LEVELS 1
72
73
// Mux related constants.
74
#define TAG_SIZE 4 // Size of a chunk tag (e.g. "VP8L").
75
#define CHUNK_SIZE_BYTES 4 // Size needed to store chunk's size.
76
#define CHUNK_HEADER_SIZE 8 // Size of a chunk header.
77
#define RIFF_HEADER_SIZE 12 // Size of the RIFF header ("RIFFnnnnWEBP").
78
#define ANMF_CHUNK_SIZE 16 // Size of an ANMF chunk.
79
#define ANIM_CHUNK_SIZE 6 // Size of an ANIM chunk.
80
#define VP8X_CHUNK_SIZE 10 // Size of a VP8X chunk.
81
82
#define MAX_CANVAS_SIZE (1 << 24) // 24-bit max for VP8X width/height.
83
#define MAX_IMAGE_AREA (1ULL << 32) // 32-bit max for width x height.
84
#define MAX_LOOP_COUNT (1 << 16) // maximum value for loop-count
85
#define MAX_DURATION (1 << 24) // maximum duration
86
#define MAX_POSITION_OFFSET (1 << 24) // maximum frame x/y offset
87
88
// Maximum chunk payload is such that adding the header and padding won't
89
// overflow a uint32_t.
90
#define MAX_CHUNK_PAYLOAD (~0U - CHUNK_HEADER_SIZE - 1)
91
92
#endif // WEBP_WEBP_FORMAT_CONSTANTS_H_
93
94