Mercurial > mplayer.hg
annotate libass/ass.h @ 19595:c19e6c7487b1
Avoid a potential strdup(NULL)
Fix sig11 with rtsp://wms.stream.aol.com/aol/us/moviefone/movies/2006/jesuscamp_027214/prestigethe_trlr_01_460.wmv
author | rtogni |
---|---|
date | Wed, 30 Aug 2006 20:18:27 +0000 |
parents | ed0ae2df0fe8 |
children | a3473d990fed |
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 start rendering a frame | |
56 * \param priv library | |
57 * \param track subtitle track | |
58 * \param now video timestamp in milliseconds | |
59 */ | |
60 int ass_start_frame(ass_instance_t *priv, ass_track_t* track, long long now); | |
61 | |
62 /** | |
63 * \brief render a single event | |
64 * uses library, track and timestamp from the previous call to ass_start_frame | |
65 */ | |
66 int ass_render_event(ass_event_t* event); | |
67 | |
68 /** | |
69 * \brief done rendering frame, give out the results | |
70 * \return a list of images for blending | |
71 */ | |
72 ass_image_t* ass_end_frame(void); // returns linked list of images to render | |
73 | |
74 /** | |
75 * \brief render a frame, producing a list of ass_image_t | |
76 * \param priv library | |
77 * \param track subtitle track | |
78 * \param now video timestamp in milliseconds | |
79 * This function is equivalent to | |
80 * ass_start_frame() | |
81 * for events: start <= now < end: | |
82 * ass_render_event() | |
83 * ass_end_frame() | |
84 */ | |
85 ass_image_t* ass_render_frame(ass_instance_t *priv, ass_track_t* track, long long now); | |
86 | |
87 | |
88 // The following functions operate on track objects and do not need an ass_instance // | |
89 | |
90 /** | |
91 * \brief allocate a new empty track object | |
92 * \return pointer to empty track | |
93 */ | |
94 ass_track_t* ass_new_track(void); | |
95 | |
96 /** | |
97 * \brief deallocate track and all its child objects (styles and events) | |
98 * \param track track to deallocate | |
99 */ | |
100 void ass_free_track(ass_track_t* track); | |
101 | |
102 /** | |
103 * \brief allocate new style | |
104 * \param track track | |
105 * \return newly allocated style id | |
106 */ | |
107 int ass_alloc_style(ass_track_t* track); | |
108 | |
109 /** | |
110 * \brief allocate new event | |
111 * \param track track | |
112 * \return newly allocated event id | |
113 */ | |
114 int ass_alloc_event(ass_track_t* track); | |
115 | |
116 /** | |
19474
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
117 * \brief delete a style |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
118 * \param track track |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
119 * \param sid style id |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
120 * Deallocates style data. Does not modify track->n_styles. |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
121 */ |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
122 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
|
123 |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
124 /** |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
125 * \brief delete an event |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
126 * \param track track |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
127 * \param eid event id |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
128 * Deallocates event data. Does not modify track->n_events. |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
129 */ |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
130 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
|
131 |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
18937
diff
changeset
|
132 /** |
18937 | 133 * \brief Process Codec Private section of subtitle stream |
134 * \param track target track | |
135 * \param data string to parse | |
136 * \param size length of data | |
137 */ | |
19492 | 138 void ass_process_codec_private(ass_track_t* track, char *data, int size); |
18937 | 139 |
140 /** | |
141 * \brief Process a chunk of subtitle stream data. In matroska, this containes exactly 1 event (or a commentary) | |
142 * \param track track | |
143 * \param data string to parse | |
144 * \param size length of data | |
145 * \param timecode starting time of the event (milliseconds) | |
146 * \param duration duration of the event (milliseconds) | |
147 */ | |
19492 | 148 void ass_process_chunk(ass_track_t* track, char *data, int size, long long timecode, long long duration); |
18937 | 149 |
150 /** | |
151 * \brief Read subtitles from file. | |
152 * \param fname file name | |
153 * \return newly allocated track | |
154 */ | |
155 ass_track_t* ass_read_file(char* fname); | |
156 | |
157 /** | |
158 * \brief Process embedded matroska font. Saves it to ~/.mplayer/fonts. | |
159 * \param name attachment name | |
160 * \param data binary font data | |
161 * \param data_size data size | |
162 */ | |
163 void ass_process_font(const char* name, char* data, int data_size); | |
164 | |
165 /** | |
166 * \brief Calculates timeshift from now to the start of some other subtitle event, depending on movement parameter | |
167 * \param track subtitle track | |
168 * \param now current time, ms | |
169 * \param movement how many events to skip from the one currently displayed | |
170 * +2 means "the one after the next", -1 means "previous" | |
171 * \return timeshift, ms | |
172 */ | |
173 long long ass_step_sub(ass_track_t* track, long long now, int movement); | |
174 | |
175 #endif | |
176 |