annotate libass/ass_cache.h @ 34094:c366199552d1

Cosmetic: Adjust indent.
author ib
date Thu, 06 Oct 2011 12:22:57 +0000
parents 88eebbbbd6a0
children 6e7f60f6f9d4
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 /*
26723
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
2 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
3 *
26738
588ce97b44f2 Speak of libass instead of MPlayer in the libass license headers.
diego
parents: 26723
diff changeset
4 * This file is part of libass.
26723
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
5 *
34011
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 30200
diff changeset
6 * Permission to use, copy, modify, and distribute this software for any
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 30200
diff changeset
7 * purpose with or without fee is hereby granted, provided that the above
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 30200
diff changeset
8 * copyright notice and this permission notice appear in all copies.
26723
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
9 *
34011
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 30200
diff changeset
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 30200
diff changeset
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 30200
diff changeset
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 30200
diff changeset
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 30200
diff changeset
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 30200
diff changeset
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 30200
diff changeset
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26723
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
17 */
20008
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19965
diff changeset
18
25897
aaebaf255b23 Consistently give all libass multiple inclusion guards a LIBASS_ prefix.
diego
parents: 25535
diff changeset
19 #ifndef LIBASS_CACHE_H
aaebaf255b23 Consistently give all libass multiple inclusion guards a LIBASS_ prefix.
diego
parents: 25535
diff changeset
20 #define LIBASS_CACHE_H
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
21
26138
74055622161d Add missing header #includes to fix 'make checkheaders'.
diego
parents: 25897
diff changeset
22 #include "ass.h"
74055622161d Add missing header #includes to fix 'make checkheaders'.
diego
parents: 25897
diff changeset
23 #include "ass_font.h"
74055622161d Add missing header #includes to fix 'make checkheaders'.
diego
parents: 25897
diff changeset
24 #include "ass_bitmap.h"
74055622161d Add missing header #includes to fix 'make checkheaders'.
diego
parents: 25897
diff changeset
25
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
26 typedef void (*HashmapItemDtor) (void *key, size_t key_size,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
27 void *value, size_t value_size);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
28 typedef int (*HashmapKeyCompare) (void *key1, void *key2,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
29 size_t key_size);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
30 typedef unsigned (*HashmapHash) (void *key, size_t key_size);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
31
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
32 typedef struct hashmap_item {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
33 void *key;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
34 void *value;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
35 struct hashmap_item *next;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
36 } HashmapItem;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
37 typedef HashmapItem *hashmap_item_p;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
38
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
39 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
40 int nbuckets;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
41 size_t key_size, value_size;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
42 hashmap_item_p *root;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
43 HashmapItemDtor item_dtor; // a destructor for hashmap key/value pairs
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
44 HashmapKeyCompare key_compare;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
45 HashmapHash hash;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
46 size_t cache_size;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
47 // stats
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
48 int hit_count;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
49 int miss_count;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
50 int count;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
51 ASS_Library *library;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
52 } Hashmap;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
53
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
54 Hashmap *hashmap_init(ASS_Library *library, size_t key_size,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
55 size_t value_size, int nbuckets,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
56 HashmapItemDtor item_dtor,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
57 HashmapKeyCompare key_compare,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
58 HashmapHash hash);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
59 void hashmap_done(Hashmap *map);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
60 void *hashmap_insert(Hashmap *map, void *key, void *value);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
61 void *hashmap_find(Hashmap *map, void *key);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28789
diff changeset
62
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
63 Hashmap *ass_font_cache_init(ASS_Library *library);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
64 ASS_Font *ass_font_cache_find(Hashmap *, ASS_FontDesc *desc);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
65 void *ass_font_cache_add(Hashmap *, ASS_Font *font);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
66 void ass_font_cache_done(Hashmap *);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
67
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
68 // Create definitions for bitmap_hash_key and glyph_hash_key
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
69 #define CREATE_STRUCT_DEFINITIONS
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
70 #include "ass_cache_template.h"
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
71
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
72 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
73 Bitmap *bm; // the actual bitmaps
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
74 Bitmap *bm_o;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
75 Bitmap *bm_s;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
76 } BitmapHashValue;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
77
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
78 Hashmap *ass_bitmap_cache_init(ASS_Library *library);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
79 void *cache_add_bitmap(Hashmap *, BitmapHashKey *key,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
80 BitmapHashValue *val);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
81 BitmapHashValue *cache_find_bitmap(Hashmap *bitmap_cache,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
82 BitmapHashKey *key);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
83 Hashmap *ass_bitmap_cache_reset(Hashmap *bitmap_cache);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
84 void ass_bitmap_cache_done(Hashmap *bitmap_cache);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
85
28789
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
86
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
87 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
88 unsigned char *a;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
89 unsigned char *b;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
90 } CompositeHashValue;
28789
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
91
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
92 Hashmap *ass_composite_cache_init(ASS_Library *library);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
93 void *cache_add_composite(Hashmap *, CompositeHashKey *key,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
94 CompositeHashValue *val);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
95 CompositeHashValue *cache_find_composite(Hashmap *composite_cache,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
96 CompositeHashKey *key);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
97 Hashmap *ass_composite_cache_reset(Hashmap *composite_cache);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
98 void ass_composite_cache_done(Hashmap *composite_cache);
28789
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
99
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
100
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
101 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
102 FT_Glyph glyph;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
103 FT_Glyph outline_glyph;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
104 FT_BBox bbox_scaled; // bbox after scaling, but before rotation
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
105 FT_Vector advance; // 26.6, advance distance to the next bitmap in line
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
106 int asc, desc; // ascender/descender of a drawing
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
107 } GlyphHashValue;
23018
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
108
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
109 Hashmap *ass_glyph_cache_init(ASS_Library *library);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
110 void *cache_add_glyph(Hashmap *, GlyphHashKey *key,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
111 GlyphHashValue *val);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
112 GlyphHashValue *cache_find_glyph(Hashmap *glyph_cache,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
113 GlyphHashKey *key);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
114 Hashmap *ass_glyph_cache_reset(Hashmap *glyph_cache);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
115 void ass_glyph_cache_done(Hashmap *glyph_cache);
23018
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
116
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
117 #endif /* LIBASS_CACHE_H */