annotate libass/ass_render.h @ 32041:d03d69f64929

Move mplPBFade extern declaration to gmplayer.h, which is better suited.
author diego
date Thu, 09 Sep 2010 17:15:16 +0000
parents e64df5862cea
children 88eebbbbd6a0
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 /*
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
2 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
3 * Copyright (C) 2009 Grigori Goronzy <greg@geekmind.org>
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
4 *
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
5 * This file is part of libass.
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
6 *
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
7 * libass is free software; you can redistribute it and/or modify
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
10 * (at your option) any later version.
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
11 *
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
12 * libass is distributed in the hope that it will be useful,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
15 * GNU General Public License for more details.
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
16 *
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License along
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
18 * with libass; if not, write to the Free Software Foundation, Inc.,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
22 #ifndef LIBASS_RENDER_H
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
23 #define LIBASS_RENDER_H
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
24
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
25 #include <inttypes.h>
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
26 #include <ft2build.h>
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
27 #include FT_FREETYPE_H
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
28 #include FT_STROKER_H
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
29 #include FT_GLYPH_H
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
30 #include FT_SYNTHESIS_H
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
31
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
32 #include "ass.h"
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
33 #include "ass_font.h"
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
34 #include "ass_bitmap.h"
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
35 #include "ass_cache.h"
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
36 #include "ass_utils.h"
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
37 #include "ass_fontconfig.h"
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
38 #include "ass_library.h"
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
39 #include "ass_drawing.h"
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
40
31853
e64df5862cea Import libass 0.9.10
greg
parents: 30200
diff changeset
41 #define GLYPH_CACHE_MAX 1000
e64df5862cea Import libass 0.9.10
greg
parents: 30200
diff changeset
42 #define BITMAP_CACHE_MAX_SIZE 30 * 1048576
e64df5862cea Import libass 0.9.10
greg
parents: 30200
diff changeset
43
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
44 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
45 double xMin;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
46 double xMax;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
47 double yMin;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
48 double yMax;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
49 } DBBox;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
50
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
51 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
52 double x;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
53 double y;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
54 } DVector;
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 typedef struct free_list {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
57 void *object;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
58 struct free_list *next;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
59 } FreeList;
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 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
62 int frame_width;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
63 int frame_height;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
64 double font_size_coeff; // font size multiplier
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
65 double line_spacing; // additional line spacing (in frame pixels)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
66 int top_margin; // height of top margin. Everything except toptitles is shifted down by top_margin.
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
67 int bottom_margin; // height of bottom margin. (frame_height - top_margin - bottom_margin) is original video height.
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
68 int left_margin;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
69 int right_margin;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
70 int use_margins; // 0 - place all subtitles inside original frame
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
71 // 1 - use margins for placing toptitles and subtitles
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
72 double aspect; // frame aspect ratio, d_width / d_height.
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
73 double storage_aspect; // pixel ratio of the source image
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
74 ASS_Hinting hinting;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
75
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
76 char *default_font;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
77 char *default_family;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
78 } ASS_Settings;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
79
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
80 // a rendered event
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
81 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
82 ASS_Image *imgs;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
83 int top, height, left, width;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
84 int detect_collisions;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
85 int shift_direction;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
86 ASS_Event *event;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
87 } EventImages;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
88
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
89 typedef enum {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
90 EF_NONE = 0,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
91 EF_KARAOKE,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
92 EF_KARAOKE_KF,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
93 EF_KARAOKE_KO
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
94 } Effect;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
95
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
96 // describes a glyph
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
97 // GlyphInfo and TextInfo are used for text centering and word-wrapping operations
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
98 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
99 unsigned symbol;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
100 unsigned skip; // skip glyph when layouting text
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
101 FT_Glyph glyph;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
102 FT_Glyph outline_glyph;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
103 Bitmap *bm; // glyph bitmap
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
104 Bitmap *bm_o; // outline bitmap
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
105 Bitmap *bm_s; // shadow bitmap
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
106 FT_BBox bbox;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
107 FT_Vector pos;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
108 char linebreak; // the first (leading) glyph of some line ?
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
109 uint32_t c[4]; // colors
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
110 FT_Vector advance; // 26.6
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
111 Effect effect_type;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
112 int effect_timing; // time duration of current karaoke word
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
113 // after process_karaoke_effects: distance in pixels from the glyph origin.
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
114 // part of the glyph to the left of it is displayed in a different color.
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
115 int effect_skip_timing; // delay after the end of last karaoke word
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
116 int asc, desc; // font max ascender and descender
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
117 int be; // blur edges
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
118 double blur; // gaussian blur
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
119 double shadow_x;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
120 double shadow_y;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
121 double frx, fry, frz; // rotation
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
122 double fax, fay; // text shearing
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
123
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
124 BitmapHashKey hash_key;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
125 } GlyphInfo;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
126
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
127 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
128 double asc, desc;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
129 } LineInfo;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
130
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
131 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
132 GlyphInfo *glyphs;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
133 int length;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
134 LineInfo *lines;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
135 int n_lines;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
136 double height;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
137 int max_glyphs;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
138 int max_lines;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
139 } TextInfo;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
140
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
141 // Renderer state.
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
142 // Values like current font face, color, screen position, clipping and so on are stored here.
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
143 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
144 ASS_Event *event;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
145 ASS_Style *style;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
146
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
147 ASS_Font *font;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
148 char *font_path;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
149 double font_size;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
150 int flags; // decoration flags (underline/strike-through)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
151
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
152 FT_Stroker stroker;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
153 int alignment; // alignment overrides go here; if zero, style value will be used
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
154 double frx, fry, frz;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
155 double fax, fay; // text shearing
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
156 enum {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
157 EVENT_NORMAL, // "normal" top-, sub- or mid- title
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
158 EVENT_POSITIONED, // happens after pos(,), margins are ignored
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
159 EVENT_HSCROLL, // "Banner" transition effect, text_width is unlimited
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
160 EVENT_VSCROLL // "Scroll up", "Scroll down" transition effects
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
161 } evt_type;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
162 double pos_x, pos_y; // position
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
163 double org_x, org_y; // origin
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
164 char have_origin; // origin is explicitly defined; if 0, get_base_point() is used
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
165 double scale_x, scale_y;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
166 double hspacing; // distance between letters, in pixels
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
167 double border_x; // outline width
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
168 double border_y;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
169 uint32_t c[4]; // colors(Primary, Secondary, so on) in RGBA
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
170 int clip_x0, clip_y0, clip_x1, clip_y1;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
171 char clip_mode; // 1 = iclip
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
172 char detect_collisions;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
173 uint32_t fade; // alpha from \fad
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
174 char be; // blur edges
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
175 double blur; // gaussian blur
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
176 double shadow_x;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
177 double shadow_y;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
178 int drawing_mode; // not implemented; when != 0 text is discarded, except for style override tags
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
179 ASS_Drawing *drawing; // current drawing
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
180 ASS_Drawing *clip_drawing; // clip vector
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
181 int clip_drawing_mode; // 0 = regular clip, 1 = inverse clip
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
182
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
183 Effect effect_type;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
184 int effect_timing;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
185 int effect_skip_timing;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
186
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
187 enum {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
188 SCROLL_LR, // left-to-right
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
189 SCROLL_RL,
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
190 SCROLL_TB, // top-to-bottom
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
191 SCROLL_BT
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
192 } scroll_direction; // for EVENT_HSCROLL, EVENT_VSCROLL
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
193 int scroll_shift;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
194
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
195 // face properties
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
196 char *family;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
197 unsigned bold;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
198 unsigned italic;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
199 int treat_family_as_pattern;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
200 int wrap_style;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
201 } RenderContext;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
202
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
203 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
204 Hashmap *font_cache;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
205 Hashmap *glyph_cache;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
206 Hashmap *bitmap_cache;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
207 Hashmap *composite_cache;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
208 size_t glyph_max;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
209 size_t bitmap_max_size;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
210 } CacheStore;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
211
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
212 struct ass_renderer {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
213 ASS_Library *library;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
214 FT_Library ftlibrary;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
215 FCInstance *fontconfig_priv;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
216 ASS_Settings settings;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
217 int render_id;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
218 ASS_SynthPriv *synth_priv;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
219
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
220 ASS_Image *images_root; // rendering result is stored here
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
221 ASS_Image *prev_images_root;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
222
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
223 EventImages *eimg; // temporary buffer for sorting rendered events
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
224 int eimg_size; // allocated buffer size
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
225
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
226 // frame-global data
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
227 int width, height; // screen dimensions
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
228 int orig_height; // frame height ( = screen height - margins )
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
229 int orig_width; // frame width ( = screen width - margins )
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
230 int orig_height_nocrop; // frame height ( = screen height - margins + cropheight)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
231 int orig_width_nocrop; // frame width ( = screen width - margins + cropwidth)
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
232 ASS_Track *track;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
233 long long time; // frame's timestamp, ms
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
234 double font_scale;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
235 double font_scale_x; // x scale applied to all glyphs to preserve text aspect ratio
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
236 double border_scale;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
237
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
238 RenderContext state;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
239 TextInfo text_info;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
240 CacheStore cache;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
241
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
242 FreeList *free_head;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
243 FreeList *free_tail;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
244 };
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
245
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
246 typedef struct render_priv {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
247 int top, height, left, width;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
248 int render_id;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
249 } RenderPriv;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
250
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
251 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
252 int x0;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
253 int y0;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
254 int x1;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
255 int y1;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
256 } Rect;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
257
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
258 typedef struct {
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
259 int a, b; // top and height
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
260 int ha, hb; // left and width
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
261 } Segment;
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
262
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
263 void reset_render_context(ASS_Renderer *render_priv);
31853
e64df5862cea Import libass 0.9.10
greg
parents: 30200
diff changeset
264 void ass_free_images(ASS_Image *img);
30200
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
265
48d020c5ceca Update internal libass copy to commit 8db4a5
greg
parents:
diff changeset
266 #endif /* LIBASS_RENDER_H */