Mercurial > mplayer.hg
annotate libass/ass.h @ 19484:6eb79b2384f8
use of malloc without prototype.. very bad on 64bit archs
author | rfelker |
---|---|
date | Mon, 21 Aug 2006 22:02:49 +0000 |
parents | 07209f48e527 |
children | c8daf3471201 |
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. | |
17 double aspect; // frame aspect ratio, d_width / d_height. | |
18 } ass_settings_t; | |
19 | |
20 /// a linked list of images produced by ass renderer | |
21 typedef struct ass_image_s { | |
22 int w, h; // bitmap width/height | |
23 int stride; // bitmap stride | |
24 unsigned char* bitmap; // 1bpp stride*h alpha buffer | |
25 uint32_t color; // RGBA | |
26 int dst_x, dst_y; // bitmap placement inside the video frame | |
27 | |
28 struct ass_image_s* next; // linked list | |
29 } ass_image_t; | |
30 | |
31 /** | |
32 * \brief initialize the library | |
33 * \return library handle or NULL if failed | |
34 */ | |
35 ass_instance_t* ass_init(void); | |
36 | |
37 /** | |
38 * \brief finalize the library | |
39 * \param priv library handle | |
40 */ | |
41 void ass_done(ass_instance_t* priv); | |
42 | |
43 /** | |
44 * \brief configure the library | |
45 * \param priv library handle | |
46 * \param config struct with configuration parameters. Caller is free to reuse it after this function returns. | |
47 */ | |
48 void ass_configure(ass_instance_t* priv, const ass_settings_t* config); | |
49 | |
50 /** | |
51 * \brief start rendering a frame | |
52 * \param priv library | |
53 * \param track subtitle track | |
54 * \param now video timestamp in milliseconds | |
55 */ | |
56 int ass_start_frame(ass_instance_t *priv, ass_track_t* track, long long now); | |
57 | |
58 /** | |
59 * \brief render a single event | |
60 * uses library, track and timestamp from the previous call to ass_start_frame | |
61 */ | |
62 int ass_render_event(ass_event_t* event); | |
63 | |
64 /** | |
65 * \brief done rendering frame, give out the results | |
66 * \return a list of images for blending | |
67 */ | |
68 ass_image_t* ass_end_frame(void); // returns linked list of images to render | |
69 | |
70 /** | |
71 * \brief render a frame, producing a list of ass_image_t | |
72 * \param priv library | |
73 * \param track subtitle track | |
74 * \param now video timestamp in milliseconds | |
75 * This function is equivalent to | |
76 * ass_start_frame() | |
77 * for events: start <= now < end: | |
78 * ass_render_event() | |
79 * ass_end_frame() | |
80 */ | |
81 ass_image_t* ass_render_frame(ass_instance_t *priv, ass_track_t* track, long long now); | |
82 | |
83 | |
84 // The following functions operate on track objects and do not need an ass_instance // | |
85 | |
86 /** | |
87 * \brief allocate a new empty track object | |
88 * \return pointer to empty track | |
89 */ | |
90 ass_track_t* ass_new_track(void); | |
91 | |
92 /** | |
93 * \brief deallocate track and all its child objects (styles and events) | |
94 * \param track track to deallocate | |
95 */ | |
96 void ass_free_track(ass_track_t* track); | |
97 | |
98 /** | |
99 * \brief allocate new style | |
100 * \param track track | |
101 * \return newly allocated style id | |
102 */ | |
103 int ass_alloc_style(ass_track_t* track); | |
104 | |
105 /** | |
106 * \brief allocate new event | |
107 * \param track track | |
108 * \return newly allocated event id | |
109 */ | |
110 int ass_alloc_event(ass_track_t* track); | |
111 | |
112 /** | |
19474
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
113 * \brief delete a style |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
114 * \param track track |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
115 * \param sid style id |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
116 * Deallocates style data. Does not modify track->n_styles. |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
117 */ |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
118 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
|
119 |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
120 /** |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
121 * \brief delete an event |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
122 * \param track track |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
123 * \param eid event id |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
124 * Deallocates event data. Does not modify track->n_events. |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
125 */ |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
126 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
|
127 |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
128 /** |
18937 | 129 * \brief Process Codec Private section of subtitle stream |
130 * \param track target track | |
131 * \param data string to parse | |
132 * \param size length of data | |
133 */ | |
134 void ass_process_chunk(ass_track_t* track, char *data, int size); | |
135 | |
136 /** | |
137 * \brief Process a chunk of subtitle stream data. In matroska, this containes exactly 1 event (or a commentary) | |
138 * \param track track | |
139 * \param data string to parse | |
140 * \param size length of data | |
141 * \param timecode starting time of the event (milliseconds) | |
142 * \param duration duration of the event (milliseconds) | |
143 */ | |
144 void ass_process_line(ass_track_t* track, char *data, int size, long long timecode, long long duration); | |
145 | |
146 /** | |
147 * \brief Read subtitles from file. | |
148 * \param fname file name | |
149 * \return newly allocated track | |
150 */ | |
151 ass_track_t* ass_read_file(char* fname); | |
152 | |
153 /** | |
154 * \brief Process embedded matroska font. Saves it to ~/.mplayer/fonts. | |
155 * \param name attachment name | |
156 * \param data binary font data | |
157 * \param data_size data size | |
158 */ | |
159 void ass_process_font(const char* name, char* data, int data_size); | |
160 | |
161 /** | |
162 * \brief Calculates timeshift from now to the start of some other subtitle event, depending on movement parameter | |
163 * \param track subtitle track | |
164 * \param now current time, ms | |
165 * \param movement how many events to skip from the one currently displayed | |
166 * +2 means "the one after the next", -1 means "previous" | |
167 * \return timeshift, ms | |
168 */ | |
169 long long ass_step_sub(ass_track_t* track, long long now, int movement); | |
170 | |
171 #endif | |
172 |