annotate libass/ass_cache.h @ 30193:faadefe4a66e

Happy new year!
author zuxy
date Thu, 07 Jan 2010 11:12:58 +0000
parents 0f1b5b68af32
children 48d020c5ceca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20008
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19965
diff changeset
1 // -*- c-basic-offset: 8; indent-tabs-mode: t -*-
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19965
diff changeset
2 // vim:ts=8:sw=8:noet:ai:
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19965
diff changeset
3 /*
26723
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
4 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
5 *
26738
588ce97b44f2 Speak of libass instead of MPlayer in the libass license headers.
diego
parents: 26723
diff changeset
6 * This file is part of libass.
26723
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
7 *
26738
588ce97b44f2 Speak of libass instead of MPlayer in the libass license headers.
diego
parents: 26723
diff changeset
8 * libass is free software; you can redistribute it and/or modify
26723
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
9 * it under the terms of the GNU General Public License as published by
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
11 * (at your option) any later version.
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
12 *
26738
588ce97b44f2 Speak of libass instead of MPlayer in the libass license headers.
diego
parents: 26723
diff changeset
13 * libass is distributed in the hope that it will be useful,
26723
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
16 * GNU General Public License for more details.
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
17 *
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
18 * You should have received a copy of the GNU General Public License along
26738
588ce97b44f2 Speak of libass instead of MPlayer in the libass license headers.
diego
parents: 26723
diff changeset
19 * with libass; if not, write to the Free Software Foundation, Inc.,
26723
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
21 */
20008
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19965
diff changeset
22
25897
aaebaf255b23 Consistently give all libass multiple inclusion guards a LIBASS_ prefix.
diego
parents: 25535
diff changeset
23 #ifndef LIBASS_CACHE_H
aaebaf255b23 Consistently give all libass multiple inclusion guards a LIBASS_ prefix.
diego
parents: 25535
diff changeset
24 #define LIBASS_CACHE_H
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
25
26138
74055622161d Add missing header #includes to fix 'make checkheaders'.
diego
parents: 25897
diff changeset
26 #include "ass.h"
74055622161d Add missing header #includes to fix 'make checkheaders'.
diego
parents: 25897
diff changeset
27 #include "ass_font.h"
74055622161d Add missing header #includes to fix 'make checkheaders'.
diego
parents: 25897
diff changeset
28 #include "ass_bitmap.h"
74055622161d Add missing header #includes to fix 'make checkheaders'.
diego
parents: 25897
diff changeset
29
21265
4e7a7dea3e1f Rename:
eugeni
parents: 20008
diff changeset
30 void ass_font_cache_init(void);
21317
dcfd069efd8f Move ass_font_t allocation to ass_font.h.
eugeni
parents: 21277
diff changeset
31 ass_font_t* ass_font_cache_find(ass_font_desc_t* desc);
23211
d9b4bfea1093 Make cache_*_add functions return the pointer to new (copied) value.
eugeni
parents: 23170
diff changeset
32 void* ass_font_cache_add(ass_font_t* font);
21265
4e7a7dea3e1f Rename:
eugeni
parents: 20008
diff changeset
33 void ass_font_cache_done(void);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
34
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
35
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
36 // describes a bitmap; bitmaps with equivalents structs are considered identical
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
37 typedef struct bitmap_hash_key_s {
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
38 char bitmap; // bool : true = bitmap, false = outline
21348
d7920b488fa2 Use (ass_font_t, char code) instead of (FT_Face, glyph index) to identify
eugeni
parents: 21323
diff changeset
39 ass_font_t* font;
23300
04dbd42b3962 Support fractional font sizes.
eugeni
parents: 23211
diff changeset
40 double size; // font size
21348
d7920b488fa2 Use (ass_font_t, char code) instead of (FT_Face, glyph index) to identify
eugeni
parents: 21323
diff changeset
41 uint32_t ch; // character code
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
42 unsigned outline; // border width, 16.16 fixed point value
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
43 int bold, italic;
19848
07be98a5dd5f Add \be (blur edges) support to libass.
eugeni
parents: 19846
diff changeset
44 char be; // blur edges
28436
12e936031c36 Allow \be with arguments other than 0 or 1. Implement \blur.
eugeni
parents: 26738
diff changeset
45 double blur; // gaussian blur
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
46
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
47 unsigned scale_x, scale_y; // 16.16
22215
fb365c2b3d05 Implement \frx and \fry (and reimplement \frz) as 3d rotations.
eugeni
parents: 22214
diff changeset
48 int frx, fry, frz; // signed 16.16
23028
57f56d8e182e Add shift_[xy] (vector that is added to the glyph before transformation) to
eugeni
parents: 23026
diff changeset
49 int shift_x, shift_y; // shift vector that was added to glyph before applying rotation
57f56d8e182e Add shift_[xy] (vector that is added to the glyph before transformation) to
eugeni
parents: 23026
diff changeset
50 // = 0, if frx = fry = frx = 0
57f56d8e182e Add shift_[xy] (vector that is added to the glyph before transformation) to
eugeni
parents: 23026
diff changeset
51 // = (glyph base point) - (rotation origin), otherwise
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28789
diff changeset
52
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
53 FT_Vector advance; // subpixel shift vector
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
54 } bitmap_hash_key_t;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
55
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
56 typedef struct bitmap_hash_val_s {
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
57 bitmap_t* bm; // the actual bitmaps
19846
bcc792bfa431 Store bitmap glyphs in a separate struct, instead of FreeType's internal buffer.
eugeni
parents: 19539
diff changeset
58 bitmap_t* bm_o;
19965
70352570e9ae Shadow support in libass.
eugeni
parents: 19848
diff changeset
59 bitmap_t* bm_s;
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
60 } bitmap_hash_val_t;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
61
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
62 void ass_bitmap_cache_init(void);
23211
d9b4bfea1093 Make cache_*_add functions return the pointer to new (copied) value.
eugeni
parents: 23170
diff changeset
63 void* cache_add_bitmap(bitmap_hash_key_t* key, bitmap_hash_val_t* val);
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
64 bitmap_hash_val_t* cache_find_bitmap(bitmap_hash_key_t* key);
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
65 void ass_bitmap_cache_reset(void);
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
66 void ass_bitmap_cache_done(void);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
67
28789
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
68
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
69 // Cache for composited bitmaps
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
70 typedef struct composite_hash_key_s {
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
71 int aw, ah, bw, bh;
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
72 int ax, ay, bx, by;
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
73 bitmap_hash_key_t a;
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
74 bitmap_hash_key_t b;
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
75 } composite_hash_key_t;
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
76
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
77 typedef struct composite_hash_val_s {
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
78 unsigned char* a;
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
79 unsigned char* b;
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
80 } composite_hash_val_t;
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
81
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
82 void ass_composite_cache_init(void);
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
83 void* cache_add_composite(composite_hash_key_t* key, composite_hash_val_t* val);
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
84 composite_hash_val_t* cache_find_composite(composite_hash_key_t* key);
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
85 void ass_composite_cache_reset(void);
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
86 void ass_composite_cache_done(void);
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
87
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
88
23018
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
89 // describes an outline glyph
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
90 typedef struct glyph_hash_key_s {
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
91 ass_font_t* font;
23300
04dbd42b3962 Support fractional font sizes.
eugeni
parents: 23211
diff changeset
92 double size; // font size
23018
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
93 uint32_t ch; // character code
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
94 int bold, italic;
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
95 unsigned scale_x, scale_y; // 16.16
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
96 FT_Vector advance; // subpixel shift vector
23170
15a05bafc9c7 Bugfix: glyph cache depends on border width, because it contains outline_glyph
eugeni
parents: 23028
diff changeset
97 unsigned outline; // border width, 16.16
23018
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
98 } glyph_hash_key_t;
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
99
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
100 typedef struct glyph_hash_val_s {
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
101 FT_Glyph glyph;
23025
ab0943242d1a Store outline_glyph (glyph border) in glyph cache.
eugeni
parents: 23018
diff changeset
102 FT_Glyph outline_glyph;
23018
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
103 FT_BBox bbox_scaled; // bbox after scaling, but before rotation
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
104 FT_Vector advance; // 26.6, advance distance to the next bitmap in line
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
105 } glyph_hash_val_t;
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
106
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
107 void ass_glyph_cache_init(void);
23211
d9b4bfea1093 Make cache_*_add functions return the pointer to new (copied) value.
eugeni
parents: 23170
diff changeset
108 void* cache_add_glyph(glyph_hash_key_t* key, glyph_hash_val_t* val);
23018
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
109 glyph_hash_val_t* cache_find_glyph(glyph_hash_key_t* key);
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
110 void ass_glyph_cache_reset(void);
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
111 void ass_glyph_cache_done(void);
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
112
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28789
diff changeset
113 typedef struct hashmap_s hashmap_t;
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22215
diff changeset
114 typedef void (*hashmap_item_dtor_t)(void* key, size_t key_size, void* value, size_t value_size);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22215
diff changeset
115 typedef int (*hashmap_key_compare_t)(void* key1, void* key2, size_t key_size);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22215
diff changeset
116 typedef unsigned (*hashmap_hash_t)(void* key, size_t key_size);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22215
diff changeset
117
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22215
diff changeset
118 hashmap_t* hashmap_init(size_t key_size, size_t value_size, int nbuckets,
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22215
diff changeset
119 hashmap_item_dtor_t item_dtor, hashmap_key_compare_t key_compare,
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22215
diff changeset
120 hashmap_hash_t hash);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22215
diff changeset
121 void hashmap_done(hashmap_t* map);
23211
d9b4bfea1093 Make cache_*_add functions return the pointer to new (copied) value.
eugeni
parents: 23170
diff changeset
122 void* hashmap_insert(hashmap_t* map, void* key, void* value);
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22215
diff changeset
123 void* hashmap_find(hashmap_t* map, void* key);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22215
diff changeset
124
25897
aaebaf255b23 Consistently give all libass multiple inclusion guards a LIBASS_ prefix.
diego
parents: 25535
diff changeset
125 #endif /* LIBASS_CACHE_H */