Mercurial > mplayer.hg
annotate libass/ass.h @ 19843:5f447cbb63b4
Fixed missed sync tag, thanks to Andrew Savchenko
author | voroshil |
---|---|
date | Sat, 16 Sep 2006 03:42:08 +0000 |
parents | 2c016957360a |
children | fa122b7c71c6 |
rev | line source |
---|---|
18937 | 1 #ifndef __ASS_H__ |
2 #define __ASS_H__ | |
3 | |
4 #include "ass_types.h" | |
5 | |
6 /// Libass "library object". Contents are private. | |
7 typedef struct ass_instance_s ass_instance_t; | |
8 | |
9 /// used in ass_configure | |
10 typedef struct ass_settings_s { | |
11 int frame_width; | |
12 int frame_height; | |
13 double font_size_coeff; // font size multiplier | |
14 double line_spacing; // additional line spacing (in frame pixels) | |
15 int top_margin; // height of top margin. Everything except toptitles is shifted down by top_margin. | |
16 int bottom_margin; // height of bottom margin. (frame_height - top_margin - bottom_margin) is original video height. | |
19538 | 17 int left_margin; |
18 int right_margin; | |
19 int use_margins; // 0 - place all subtitles inside original frame | |
20 // 1 - use margins for placing toptitles and subtitles | |
18937 | 21 double aspect; // frame aspect ratio, d_width / d_height. |
22 } ass_settings_t; | |
23 | |
24 /// a linked list of images produced by ass renderer | |
25 typedef struct ass_image_s { | |
26 int w, h; // bitmap width/height | |
27 int stride; // bitmap stride | |
28 unsigned char* bitmap; // 1bpp stride*h alpha buffer | |
29 uint32_t color; // RGBA | |
30 int dst_x, dst_y; // bitmap placement inside the video frame | |
31 | |
32 struct ass_image_s* next; // linked list | |
33 } ass_image_t; | |
34 | |
35 /** | |
36 * \brief initialize the library | |
37 * \return library handle or NULL if failed | |
38 */ | |
39 ass_instance_t* ass_init(void); | |
40 | |
41 /** | |
42 * \brief finalize the library | |
43 * \param priv library handle | |
44 */ | |
45 void ass_done(ass_instance_t* priv); | |
46 | |
47 /** | |
48 * \brief configure the library | |
49 * \param priv library handle | |
50 * \param config struct with configuration parameters. Caller is free to reuse it after this function returns. | |
51 */ | |
52 void ass_configure(ass_instance_t* priv, const ass_settings_t* config); | |
53 | |
54 /** | |
55 * \brief render a frame, producing a list of ass_image_t | |
56 * \param priv library | |
57 * \param track subtitle track | |
58 * \param now video timestamp in milliseconds | |
59 */ | |
60 ass_image_t* ass_render_frame(ass_instance_t *priv, ass_track_t* track, long long now); | |
61 | |
62 | |
63 // The following functions operate on track objects and do not need an ass_instance // | |
64 | |
65 /** | |
66 * \brief allocate a new empty track object | |
67 * \return pointer to empty track | |
68 */ | |
69 ass_track_t* ass_new_track(void); | |
70 | |
71 /** | |
72 * \brief deallocate track and all its child objects (styles and events) | |
73 * \param track track to deallocate | |
74 */ | |
75 void ass_free_track(ass_track_t* track); | |
76 | |
77 /** | |
78 * \brief allocate new style | |
79 * \param track track | |
80 * \return newly allocated style id | |
81 */ | |
82 int ass_alloc_style(ass_track_t* track); | |
83 | |
84 /** | |
85 * \brief allocate new event | |
86 * \param track track | |
87 * \return newly allocated event id | |
88 */ | |
89 int ass_alloc_event(ass_track_t* track); | |
90 | |
91 /** | |
19474
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
92 * \brief delete a style |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
93 * \param track track |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
94 * \param sid style id |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
95 * Deallocates style data. Does not modify track->n_styles. |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
96 */ |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
97 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
|
98 |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
99 /** |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
100 * \brief delete an event |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
101 * \param track track |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
102 * \param eid event id |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
103 * Deallocates event data. Does not modify track->n_events. |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
104 */ |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
105 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
|
106 |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
107 /** |
18937 | 108 * \brief Process Codec Private section of subtitle stream |
109 * \param track target track | |
110 * \param data string to parse | |
111 * \param size length of data | |
112 */ | |
19492 | 113 void ass_process_codec_private(ass_track_t* track, char *data, int size); |
18937 | 114 |
115 /** | |
116 * \brief Process a chunk of subtitle stream data. In matroska, this containes exactly 1 event (or a commentary) | |
117 * \param track track | |
118 * \param data string to parse | |
119 * \param size length of data | |
120 * \param timecode starting time of the event (milliseconds) | |
121 * \param duration duration of the event (milliseconds) | |
122 */ | |
19492 | 123 void ass_process_chunk(ass_track_t* track, char *data, int size, long long timecode, long long duration); |
18937 | 124 |
125 /** | |
126 * \brief Read subtitles from file. | |
127 * \param fname file name | |
128 * \return newly allocated track | |
129 */ | |
130 ass_track_t* ass_read_file(char* fname); | |
131 | |
132 /** | |
19652
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19638
diff
changeset
|
133 * \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
|
134 * \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
|
135 */ |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19638
diff
changeset
|
136 int ass_read_styles(ass_track_t* track, char* fname); |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19638
diff
changeset
|
137 |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19638
diff
changeset
|
138 /** |
18937 | 139 * \brief Process embedded matroska font. Saves it to ~/.mplayer/fonts. |
140 * \param name attachment name | |
141 * \param data binary font data | |
142 * \param data_size data size | |
143 */ | |
144 void ass_process_font(const char* name, char* data, int data_size); | |
145 | |
146 /** | |
147 * \brief Calculates timeshift from now to the start of some other subtitle event, depending on movement parameter | |
148 * \param track subtitle track | |
149 * \param now current time, ms | |
150 * \param movement how many events to skip from the one currently displayed | |
151 * +2 means "the one after the next", -1 means "previous" | |
152 * \return timeshift, ms | |
153 */ | |
154 long long ass_step_sub(ass_track_t* track, long long now, int movement); | |
155 | |
156 #endif | |
157 |