annotate libass/ass_cache.h @ 33263:5f527a9a9521

Add an exit function. This function will allow performing clean-up operations. (MPlayer calls guiDone() before exiting, but only if the GUI has been initialized, i.e. if guiInit() has been called successfully. Any exit_player()/exit_player_with_rc() after GUI's cfg_read() until guiInit(), or any exit_player() during guiInit() itself will end the GUI without calling guiDone(). This exit function will at least handle abortions during guiInit() itself. It will be called twice in case of an guiExit() after GUI initialization - first directly, next by guiDone() via MPlayer's exit_player_with_rc().)
author ib
date Tue, 03 May 2011 12:19:22 +0000
parents 48d020c5ceca
children 88eebbbbd6a0
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 *
26738
588ce97b44f2 Speak of libass instead of MPlayer in the libass license headers.
diego
parents: 26723
diff changeset
6 * libass is free software; you can redistribute it and/or modify
26723
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
7 * it under the terms of the GNU General Public License as published by
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
9 * (at your option) any later version.
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
10 *
26738
588ce97b44f2 Speak of libass instead of MPlayer in the libass license headers.
diego
parents: 26723
diff changeset
11 * libass is distributed in the hope that it will be useful,
26723
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
14 * GNU General Public License for more details.
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
15 *
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
16 * 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
17 * with libass; if not, write to the Free Software Foundation, Inc.,
26723
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
0f892cd714b2 Use standard license header.
diego
parents: 26138
diff changeset
19 */
20008
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19965
diff changeset
20
25897
aaebaf255b23 Consistently give all libass multiple inclusion guards a LIBASS_ prefix.
diego
parents: 25535
diff changeset
21 #ifndef LIBASS_CACHE_H
aaebaf255b23 Consistently give all libass multiple inclusion guards a LIBASS_ prefix.
diego
parents: 25535
diff changeset
22 #define LIBASS_CACHE_H
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
23
26138
74055622161d Add missing header #includes to fix 'make checkheaders'.
diego
parents: 25897
diff changeset
24 #include "ass.h"
74055622161d Add missing header #includes to fix 'make checkheaders'.
diego
parents: 25897
diff changeset
25 #include "ass_font.h"
74055622161d Add missing header #includes to fix 'make checkheaders'.
diego
parents: 25897
diff changeset
26 #include "ass_bitmap.h"
74055622161d Add missing header #includes to fix 'make checkheaders'.
diego
parents: 25897
diff changeset
27
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
28 typedef void (*HashmapItemDtor) (void *key, size_t key_size,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
29 void *value, size_t value_size);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
30 typedef int (*HashmapKeyCompare) (void *key1, void *key2,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
31 size_t key_size);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
32 typedef unsigned (*HashmapHash) (void *key, size_t key_size);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
33
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
34 typedef struct hashmap_item {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
35 void *key;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
36 void *value;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
37 struct hashmap_item *next;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
38 } HashmapItem;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
39 typedef HashmapItem *hashmap_item_p;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
40
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
41 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
42 int nbuckets;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
43 size_t key_size, value_size;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
44 hashmap_item_p *root;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
45 HashmapItemDtor item_dtor; // a destructor for hashmap key/value pairs
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
46 HashmapKeyCompare key_compare;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
47 HashmapHash hash;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
48 size_t cache_size;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
49 // stats
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
50 int hit_count;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
51 int miss_count;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
52 int count;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
53 ASS_Library *library;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
54 } Hashmap;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
55
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
56 Hashmap *hashmap_init(ASS_Library *library, size_t key_size,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
57 size_t value_size, int nbuckets,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
58 HashmapItemDtor item_dtor,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
59 HashmapKeyCompare key_compare,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
60 HashmapHash hash);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
61 void hashmap_done(Hashmap *map);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
62 void *hashmap_insert(Hashmap *map, void *key, void *value);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
63 void *hashmap_find(Hashmap *map, void *key);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28789
diff changeset
64
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
65 Hashmap *ass_font_cache_init(ASS_Library *library);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
66 ASS_Font *ass_font_cache_find(Hashmap *, ASS_FontDesc *desc);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
67 void *ass_font_cache_add(Hashmap *, ASS_Font *font);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
68 void ass_font_cache_done(Hashmap *);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
69
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
70 // Create definitions for bitmap_hash_key and glyph_hash_key
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
71 #define CREATE_STRUCT_DEFINITIONS
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
72 #include "ass_cache_template.h"
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
73
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
74 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
75 Bitmap *bm; // the actual bitmaps
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
76 Bitmap *bm_o;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
77 Bitmap *bm_s;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
78 } BitmapHashValue;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
79
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
80 Hashmap *ass_bitmap_cache_init(ASS_Library *library);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
81 void *cache_add_bitmap(Hashmap *, BitmapHashKey *key,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
82 BitmapHashValue *val);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
83 BitmapHashValue *cache_find_bitmap(Hashmap *bitmap_cache,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
84 BitmapHashKey *key);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
85 Hashmap *ass_bitmap_cache_reset(Hashmap *bitmap_cache);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
86 void ass_bitmap_cache_done(Hashmap *bitmap_cache);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
87
28789
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
88
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
89 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
90 unsigned char *a;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
91 unsigned char *b;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
92 } CompositeHashValue;
28789
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
93
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
94 Hashmap *ass_composite_cache_init(ASS_Library *library);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
95 void *cache_add_composite(Hashmap *, CompositeHashKey *key,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
96 CompositeHashValue *val);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
97 CompositeHashValue *cache_find_composite(Hashmap *composite_cache,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
98 CompositeHashKey *key);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
99 Hashmap *ass_composite_cache_reset(Hashmap *composite_cache);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
100 void ass_composite_cache_done(Hashmap *composite_cache);
28789
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
101
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 28436
diff changeset
102
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
103 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
104 FT_Glyph glyph;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
105 FT_Glyph outline_glyph;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
106 FT_BBox bbox_scaled; // bbox after scaling, but before rotation
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
107 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
108 int asc, desc; // ascender/descender of a drawing
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
109 } GlyphHashValue;
23018
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
110
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
111 Hashmap *ass_glyph_cache_init(ASS_Library *library);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
112 void *cache_add_glyph(Hashmap *, GlyphHashKey *key,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
113 GlyphHashValue *val);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
114 GlyphHashValue *cache_find_glyph(Hashmap *glyph_cache,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
115 GlyphHashKey *key);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
116 Hashmap *ass_glyph_cache_reset(Hashmap *glyph_cache);
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
117 void ass_glyph_cache_done(Hashmap *glyph_cache);
23018
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
118
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents: 29263
diff changeset
119 #endif /* LIBASS_CACHE_H */