Mercurial > mplayer.hg
annotate libass/ass.h @ 26577:d1e4656332cf
cosmetics: Move some variable declarations to better places.
author | diego |
---|---|
date | Wed, 30 Apr 2008 13:58:26 +0000 |
parents | 74055622161d |
children | 62ac4f8062ee |
rev | line source |
---|---|
20008
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
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:
19652
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:
19652
diff
changeset
|
3 /* |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
4 Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com> |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
5 |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
6 This program is free software; you can redistribute it and/or modify |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
8 the Free Software Foundation; either version 2 of the License, or |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
9 (at your option) any later version. |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
10 |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
11 This program is distributed in the hope that it will be useful, |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
14 GNU General Public License for more details. |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
15 |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
17 along with this program; if not, write to the Free Software |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
19 */ |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19652
diff
changeset
|
20 |
25897
aaebaf255b23
Consistently give all libass multiple inclusion guards a LIBASS_ prefix.
diego
parents:
25613
diff
changeset
|
21 #ifndef LIBASS_ASS_H |
aaebaf255b23
Consistently give all libass multiple inclusion guards a LIBASS_ prefix.
diego
parents:
25613
diff
changeset
|
22 #define LIBASS_ASS_H |
18937 | 23 |
26138
74055622161d
Add missing header #includes to fix 'make checkheaders'.
diego
parents:
25897
diff
changeset
|
24 #include <stdio.h> |
18937 | 25 #include "ass_types.h" |
26 | |
20477 | 27 /// Libass renderer object. Contents are private. |
28 typedef struct ass_renderer_s ass_renderer_t; | |
18937 | 29 |
30 /// a linked list of images produced by ass renderer | |
31 typedef struct ass_image_s { | |
32 int w, h; // bitmap width/height | |
33 int stride; // bitmap stride | |
34 unsigned char* bitmap; // 1bpp stride*h alpha buffer | |
35 uint32_t color; // RGBA | |
36 int dst_x, dst_y; // bitmap placement inside the video frame | |
37 | |
38 struct ass_image_s* next; // linked list | |
39 } ass_image_t; | |
40 | |
23134
1de2a46a0987
Add -ass-hinting option for setting font hinting method.
eugeni
parents:
21506
diff
changeset
|
41 /// Hinting type |
1de2a46a0987
Add -ass-hinting option for setting font hinting method.
eugeni
parents:
21506
diff
changeset
|
42 typedef enum {ASS_HINTING_NONE = 0, |
1de2a46a0987
Add -ass-hinting option for setting font hinting method.
eugeni
parents:
21506
diff
changeset
|
43 ASS_HINTING_LIGHT, |
1de2a46a0987
Add -ass-hinting option for setting font hinting method.
eugeni
parents:
21506
diff
changeset
|
44 ASS_HINTING_NORMAL, |
1de2a46a0987
Add -ass-hinting option for setting font hinting method.
eugeni
parents:
21506
diff
changeset
|
45 ASS_HINTING_NATIVE |
1de2a46a0987
Add -ass-hinting option for setting font hinting method.
eugeni
parents:
21506
diff
changeset
|
46 } ass_hinting_t; |
1de2a46a0987
Add -ass-hinting option for setting font hinting method.
eugeni
parents:
21506
diff
changeset
|
47 |
18937 | 48 /** |
49 * \brief initialize the library | |
50 * \return library handle or NULL if failed | |
51 */ | |
20477 | 52 ass_library_t* ass_library_init(void); |
18937 | 53 |
54 /** | |
55 * \brief finalize the library | |
56 * \param priv library handle | |
57 */ | |
20477 | 58 void ass_library_done(ass_library_t*); |
59 | |
60 /** | |
61 * \brief set private font directory | |
62 * It is used for saving embedded fonts and also in font lookup. | |
63 */ | |
64 void ass_set_fonts_dir(ass_library_t* priv, const char* fonts_dir); | |
65 | |
66 void ass_set_extract_fonts(ass_library_t* priv, int extract); | |
67 | |
68 void ass_set_style_overrides(ass_library_t* priv, char** list); | |
18937 | 69 |
20477 | 70 /** |
71 * \brief initialize the renderer | |
72 * \param priv library handle | |
73 * \return renderer handle or NULL if failed | |
74 */ | |
75 ass_renderer_t* ass_renderer_init(ass_library_t*); | |
76 | |
77 /** | |
78 * \brief finalize the renderer | |
79 * \param priv renderer handle | |
80 */ | |
81 void ass_renderer_done(ass_renderer_t* priv); | |
82 | |
83 void ass_set_frame_size(ass_renderer_t* priv, int w, int h); | |
84 void ass_set_margins(ass_renderer_t* priv, int t, int b, int l, int r); | |
85 void ass_set_use_margins(ass_renderer_t* priv, int use); | |
86 void ass_set_aspect_ratio(ass_renderer_t* priv, double ar); | |
87 void ass_set_font_scale(ass_renderer_t* priv, double font_scale); | |
23134
1de2a46a0987
Add -ass-hinting option for setting font hinting method.
eugeni
parents:
21506
diff
changeset
|
88 void ass_set_hinting(ass_renderer_t* priv, ass_hinting_t ht); |
24554 | 89 void ass_set_line_spacing(ass_renderer_t* priv, double line_spacing); |
20477 | 90 |
91 /** | |
92 * \brief set font lookup defaults | |
93 */ | |
94 int ass_set_fonts(ass_renderer_t* priv, const char* default_font, const char* default_family); | |
18937 | 95 |
96 /** | |
97 * \brief render a frame, producing a list of ass_image_t | |
98 * \param priv library | |
99 * \param track subtitle track | |
100 * \param now video timestamp in milliseconds | |
101 */ | |
21506
8174acbf0633
Speed up ASS subtitles display by detecting changes between two consecutive
eugeni
parents:
21458
diff
changeset
|
102 ass_image_t* ass_render_frame(ass_renderer_t *priv, ass_track_t* track, long long now, int* detect_change); |
18937 | 103 |
104 | |
20477 | 105 // The following functions operate on track objects and do not need an ass_renderer // |
18937 | 106 |
107 /** | |
108 * \brief allocate a new empty track object | |
109 * \return pointer to empty track | |
110 */ | |
20477 | 111 ass_track_t* ass_new_track(ass_library_t*); |
18937 | 112 |
113 /** | |
114 * \brief deallocate track and all its child objects (styles and events) | |
115 * \param track track to deallocate | |
116 */ | |
117 void ass_free_track(ass_track_t* track); | |
118 | |
119 /** | |
120 * \brief allocate new style | |
121 * \param track track | |
122 * \return newly allocated style id | |
123 */ | |
124 int ass_alloc_style(ass_track_t* track); | |
125 | |
126 /** | |
127 * \brief allocate new event | |
128 * \param track track | |
129 * \return newly allocated event id | |
130 */ | |
131 int ass_alloc_event(ass_track_t* track); | |
132 | |
133 /** | |
19474
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
134 * \brief delete a style |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
135 * \param track track |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
136 * \param sid style id |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
137 * Deallocates style data. Does not modify track->n_styles. |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
138 */ |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
139 void ass_free_style(ass_track_t* track, int sid); |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
140 |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
141 /** |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
142 * \brief delete an event |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
143 * \param track track |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
144 * \param eid event id |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
145 * Deallocates event data. Does not modify track->n_events. |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
146 */ |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
147 void ass_free_event(ass_track_t* track, int eid); |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
148 |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
149 /** |
25514 | 150 * \brief Parse Codec Private section of subtitle stream |
18937 | 151 * \param track target track |
152 * \param data string to parse | |
153 * \param size length of data | |
154 */ | |
19492 | 155 void ass_process_codec_private(ass_track_t* track, char *data, int size); |
18937 | 156 |
157 /** | |
25515 | 158 * \brief Parse a chunk of subtitle stream data. In Matroska, this contains exactly 1 event (or a commentary). |
18937 | 159 * \param track track |
160 * \param data string to parse | |
161 * \param size length of data | |
162 * \param timecode starting time of the event (milliseconds) | |
163 * \param duration duration of the event (milliseconds) | |
164 */ | |
19492 | 165 void ass_process_chunk(ass_track_t* track, char *data, int size, long long timecode, long long duration); |
18937 | 166 |
23424
7286d245bf33
Move code for reading a file and recoding it to utf-8 to a separate function.
eugeni
parents:
23134
diff
changeset
|
167 char* read_file_recode(char* fname, char* codepage, int* size); |
7286d245bf33
Move code for reading a file and recoding it to utf-8 to a separate function.
eugeni
parents:
23134
diff
changeset
|
168 |
18937 | 169 /** |
170 * \brief Read subtitles from file. | |
171 * \param fname file name | |
172 * \return newly allocated track | |
173 */ | |
20477 | 174 ass_track_t* ass_read_file(ass_library_t* library, char* fname, char* codepage); |
18937 | 175 |
176 /** | |
20603 | 177 * \brief Read subtitles from memory. |
178 * \param library libass library object | |
179 * \param buf pointer to subtitles text | |
180 * \param bufsize size of buffer | |
181 * \param codepage recode buffer contents from given codepage | |
182 * \return newly allocated track | |
183 */ | |
184 ass_track_t* ass_read_memory(ass_library_t* library, char* buf, size_t bufsize, char* codepage); | |
185 /** | |
19652
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19638
diff
changeset
|
186 * \brief read styles from file into already initialized track |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19638
diff
changeset
|
187 * \return 0 on success |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19638
diff
changeset
|
188 */ |
20477 | 189 int ass_read_styles(ass_track_t* track, char* fname, char* codepage); |
19652
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19638
diff
changeset
|
190 |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19638
diff
changeset
|
191 /** |
21455 | 192 * \brief Add a memory font. |
18937 | 193 * \param name attachment name |
194 * \param data binary font data | |
195 * \param data_size data size | |
196 */ | |
21458
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
21455
diff
changeset
|
197 void ass_add_font(ass_library_t* library, char* name, char* data, int data_size); |
18937 | 198 |
199 /** | |
25613
f00333e3facf
Copy font data to ass_library instead of referencing demuxer-owned memory.
eugeni
parents:
25535
diff
changeset
|
200 * \brief Remove all fonts stored in ass_library object |
f00333e3facf
Copy font data to ass_library instead of referencing demuxer-owned memory.
eugeni
parents:
25535
diff
changeset
|
201 */ |
f00333e3facf
Copy font data to ass_library instead of referencing demuxer-owned memory.
eugeni
parents:
25535
diff
changeset
|
202 void ass_clear_fonts(ass_library_t* library); |
f00333e3facf
Copy font data to ass_library instead of referencing demuxer-owned memory.
eugeni
parents:
25535
diff
changeset
|
203 |
f00333e3facf
Copy font data to ass_library instead of referencing demuxer-owned memory.
eugeni
parents:
25535
diff
changeset
|
204 /** |
18937 | 205 * \brief Calculates timeshift from now to the start of some other subtitle event, depending on movement parameter |
206 * \param track subtitle track | |
207 * \param now current time, ms | |
208 * \param movement how many events to skip from the one currently displayed | |
209 * +2 means "the one after the next", -1 means "previous" | |
210 * \return timeshift, ms | |
211 */ | |
212 long long ass_step_sub(ass_track_t* track, long long now, int movement); | |
213 | |
25897
aaebaf255b23
Consistently give all libass multiple inclusion guards a LIBASS_ prefix.
diego
parents:
25613
diff
changeset
|
214 #endif /* LIBASS_ASS_H */ |