comparison libass/ass.h @ 18937:9e95ac641e77

Initial libass release (without mencoder support).
author eugeni
date Fri, 07 Jul 2006 18:26:51 +0000
parents
children 07209f48e527
comparison
equal deleted inserted replaced
18936:b80b0c115a24 18937:9e95ac641e77
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 /**
113 * \brief Process Codec Private section of subtitle stream
114 * \param track target track
115 * \param data string to parse
116 * \param size length of data
117 */
118 void ass_process_chunk(ass_track_t* track, char *data, int size);
119
120 /**
121 * \brief Process a chunk of subtitle stream data. In matroska, this containes exactly 1 event (or a commentary)
122 * \param track track
123 * \param data string to parse
124 * \param size length of data
125 * \param timecode starting time of the event (milliseconds)
126 * \param duration duration of the event (milliseconds)
127 */
128 void ass_process_line(ass_track_t* track, char *data, int size, long long timecode, long long duration);
129
130 /**
131 * \brief Read subtitles from file.
132 * \param fname file name
133 * \return newly allocated track
134 */
135 ass_track_t* ass_read_file(char* fname);
136
137 /**
138 * \brief Process embedded matroska font. Saves it to ~/.mplayer/fonts.
139 * \param name attachment name
140 * \param data binary font data
141 * \param data_size data size
142 */
143 void ass_process_font(const char* name, char* data, int data_size);
144
145 /**
146 * \brief Calculates timeshift from now to the start of some other subtitle event, depending on movement parameter
147 * \param track subtitle track
148 * \param now current time, ms
149 * \param movement how many events to skip from the one currently displayed
150 * +2 means "the one after the next", -1 means "previous"
151 * \return timeshift, ms
152 */
153 long long ass_step_sub(ass_track_t* track, long long now, int movement);
154
155 #endif
156