annotate libass/ass_cache_template.h @ 35282:38a5d56c389c

Fix allocation that could in theory be too small for the terminating NULL. It should only have been possible to actually trigger when chapter name and start string were both empty.
author reimar
date Sat, 10 Nov 2012 11:49:37 +0000
parents 6e7f60f6f9d4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
1 #ifdef CREATE_STRUCT_DEFINITIONS
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
2 #undef CREATE_STRUCT_DEFINITIONS
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
3 #define START(funcname, structname) \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
4 typedef struct structname {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
5 #define GENERIC(type, member) \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
6 type member;
34295
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
7 #define STRING(member) \
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
8 char *member;
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
9 #define FTVECTOR(member) \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
10 FT_Vector member;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
11 #define BITMAPHASHKEY(member) \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
12 BitmapHashKey member;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
13 #define END(typedefnamename) \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
14 } typedefnamename;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
15
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
16 #elif defined(CREATE_COMPARISON_FUNCTIONS)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
17 #undef CREATE_COMPARISON_FUNCTIONS
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
18 #define START(funcname, structname) \
34295
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
19 static unsigned funcname##_compare(void *key1, void *key2, size_t key_size) \
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
20 { \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
21 struct structname *a = key1; \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
22 struct structname *b = key2; \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
23 return // conditions follow
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
24 #define GENERIC(type, member) \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
25 a->member == b->member &&
34295
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
26 #define STRING(member) \
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
27 strcmp(a->member, b->member) == 0 &&
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
28 #define FTVECTOR(member) \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
29 a->member.x == b->member.x && a->member.y == b->member.y &&
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
30 #define BITMAPHASHKEY(member) \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
31 bitmap_compare(&a->member, &b->member, sizeof(a->member)) &&
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
32 #define END(typedefname) \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
33 1; \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
34 }
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
35
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
36 #elif defined(CREATE_HASH_FUNCTIONS)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
37 #undef CREATE_HASH_FUNCTIONS
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
38 #define START(funcname, structname) \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
39 static unsigned funcname##_hash(void *buf, size_t len) \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
40 { \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
41 struct structname *p = buf; \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
42 unsigned hval = FNV1_32A_INIT;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
43 #define GENERIC(type, member) \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
44 hval = fnv_32a_buf(&p->member, sizeof(p->member), hval);
34295
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
45 #define STRING(member) \
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
46 hval = fnv_32a_str(p->member, hval);
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
47 #define FTVECTOR(member) GENERIC(, member.x); GENERIC(, member.y);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
48 #define BITMAPHASHKEY(member) { \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
49 unsigned temp = bitmap_hash(&p->member, sizeof(p->member)); \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
50 hval = fnv_32a_buf(&temp, sizeof(temp), hval); \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
51 }
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
52 #define END(typedefname) \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
53 return hval; \
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
54 }
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
55
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
56 #else
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
57 #error missing defines
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
58 #endif
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
59
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
60
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
61
34295
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
62 // describes an outline bitmap
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
63 START(outline_bitmap, outline_bitmap_hash_key)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
64 GENERIC(OutlineHashValue *, outline)
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
65 GENERIC(char, be) // blur edges
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
66 GENERIC(double, blur) // gaussian blur
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
67 GENERIC(int, frx) // signed 16.16
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
68 GENERIC(int, fry) // signed 16.16
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
69 GENERIC(int, frz) // signed 16.16
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
70 GENERIC(int, fax) // signed 16.16
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
71 GENERIC(int, fay) // signed 16.16
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
72 // shift vector that was added to glyph before applying rotation
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
73 // = 0, if frx = fry = frx = 0
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
74 // = (glyph base point) - (rotation origin), otherwise
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
75 GENERIC(int, shift_x)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
76 GENERIC(int, shift_y)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
77 FTVECTOR(advance) // subpixel shift vector
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
78 FTVECTOR(shadow_offset) // shadow subpixel shift
34295
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
79 END(OutlineBitmapHashKey)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
80
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
81 // describe a clip mask bitmap
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
82 START(clip_bitmap, clip_bitmap_hash_key)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
83 STRING(text)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
84 END(ClipMaskHashKey)
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
85
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
86 // describes an outline glyph
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
87 START(glyph, glyph_hash_key)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
88 GENERIC(ASS_Font *, font)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
89 GENERIC(double, size) // font size
34295
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
90 GENERIC(int, face_index)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
91 GENERIC(int, glyph_index)
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
92 GENERIC(int, bold)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
93 GENERIC(int, italic)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
94 GENERIC(unsigned, scale_x) // 16.16
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
95 GENERIC(unsigned, scale_y) // 16.16
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
96 FTVECTOR(outline) // border width, 16.16
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
97 GENERIC(unsigned, flags) // glyph decoration flags
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
98 GENERIC(unsigned, border_style)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
99 END(GlyphHashKey)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
100
34295
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
101 START(glyph_metrics, glyph_metrics_hash_key)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
102 GENERIC(ASS_Font *, font)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
103 GENERIC(double, size)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
104 GENERIC(int, face_index)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
105 GENERIC(int, glyph_index)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
106 GENERIC(unsigned, scale_x)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
107 GENERIC(unsigned, scale_y)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
108 END(GlyphMetricsHashKey)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
109
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
110 // describes an outline drawing
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
111 START(drawing, drawing_hash_key)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
112 GENERIC(unsigned, scale_x)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
113 GENERIC(unsigned, scale_y)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
114 GENERIC(int, pbo)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
115 FTVECTOR(outline)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
116 GENERIC(unsigned, border_style)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
117 GENERIC(int, scale)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
118 GENERIC(unsigned, hash)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
119 STRING(text)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
120 END(DrawingHashKey)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
121
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
122 // Cache for composited bitmaps
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
123 START(composite, composite_hash_key)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
124 GENERIC(int, aw)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
125 GENERIC(int, ah)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
126 GENERIC(int, bw)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
127 GENERIC(int, bh)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
128 GENERIC(int, ax)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
129 GENERIC(int, ay)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
130 GENERIC(int, bx)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
131 GENERIC(int, by)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
132 GENERIC(int, as)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
133 GENERIC(int, bs)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
134 GENERIC(unsigned char *, a)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
135 GENERIC(unsigned char *, b)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
136 END(CompositeHashKey)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
137
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
138
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
139 #undef START
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
140 #undef GENERIC
34295
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 30200
diff changeset
141 #undef STRING
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
142 #undef FTVECTOR
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
143 #undef BITMAPHASHKEY
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
144 #undef END