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