annotate libass/ass.h @ 20361:87c1bd5096de

remove outdated reference to "tvout-voodoo"; fixes compilation
author kraymer
date Sun, 22 Oct 2006 15:48:38 +0000
parents fa122b7c71c6
children e8adc3778348
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20008
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
1 // -*- c-basic-offset: 8; indent-tabs-mode: t -*-
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
2 // vim:ts=8:sw=8:noet:ai:
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
3 /*
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
4 Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
5
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
6 This program is free software; you can redistribute it and/or modify
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
7 it under the terms of the GNU General Public License as published by
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
8 the Free Software Foundation; either version 2 of the License, or
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
9 (at your option) any later version.
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
10
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
11 This program is distributed in the hope that it will be useful,
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
14 GNU General Public License for more details.
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
15
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
16 You should have received a copy of the GNU General Public License
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
17 along with this program; if not, write to the Free Software
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
19 */
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19652
diff changeset
20
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
21 #ifndef __ASS_H__
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
22 #define __ASS_H__
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
23
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
24 #include "ass_types.h"
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
25
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
26 /// Libass "library object". Contents are private.
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
27 typedef struct ass_instance_s ass_instance_t;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
28
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
29 /// used in ass_configure
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
30 typedef struct ass_settings_s {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
31 int frame_width;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
32 int frame_height;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
33 double font_size_coeff; // font size multiplier
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
34 double line_spacing; // additional line spacing (in frame pixels)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
35 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
36 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
37 int left_margin;
ed0ae2df0fe8 Add right and left margins support to libass.
eugeni
parents: 19492
diff changeset
38 int right_margin;
ed0ae2df0fe8 Add right and left margins support to libass.
eugeni
parents: 19492
diff changeset
39 int use_margins; // 0 - place all subtitles inside original frame
ed0ae2df0fe8 Add right and left margins support to libass.
eugeni
parents: 19492
diff changeset
40 // 1 - use margins for placing toptitles and subtitles
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
41 double aspect; // frame aspect ratio, d_width / d_height.
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
42 } ass_settings_t;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
43
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
44 /// a linked list of images produced by ass renderer
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
45 typedef struct ass_image_s {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
46 int w, h; // bitmap width/height
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
47 int stride; // bitmap stride
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
48 unsigned char* bitmap; // 1bpp stride*h alpha buffer
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
49 uint32_t color; // RGBA
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
50 int dst_x, dst_y; // bitmap placement inside the video frame
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
51
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
52 struct ass_image_s* next; // linked list
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
53 } ass_image_t;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
54
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
55 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
56 * \brief initialize the library
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
57 * \return library handle or NULL if failed
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
58 */
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
59 ass_instance_t* ass_init(void);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
60
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
61 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
62 * \brief finalize the library
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
63 * \param priv library handle
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
64 */
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
65 void ass_done(ass_instance_t* priv);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
66
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
67 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
68 * \brief configure the library
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
69 * \param priv library handle
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
70 * \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
71 */
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
72 void ass_configure(ass_instance_t* priv, const ass_settings_t* config);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
73
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
74 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
75 * \brief render a frame, producing a list of ass_image_t
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
76 * \param priv library
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
77 * \param track subtitle track
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
78 * \param now video timestamp in milliseconds
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
79 */
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
80 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
81
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
82
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
83 // 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
84
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
85 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
86 * \brief allocate a new empty track object
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
87 * \return pointer to empty track
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
88 */
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
89 ass_track_t* ass_new_track(void);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
90
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
91 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
92 * \brief deallocate track and all its child objects (styles and events)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
93 * \param track track to deallocate
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
94 */
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
95 void ass_free_track(ass_track_t* track);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
96
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
97 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
98 * \brief allocate new style
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
99 * \param track track
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
100 * \return newly allocated style id
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
101 */
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
102 int ass_alloc_style(ass_track_t* track);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
103
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
104 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
105 * \brief allocate new event
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
106 * \param track track
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
107 * \return newly allocated event id
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
108 */
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
109 int ass_alloc_event(ass_track_t* track);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
110
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
111 /**
19474
07209f48e527 Add public functions for removal of styles and events.
eugeni
parents: 18937
diff changeset
112 * \brief delete a style
07209f48e527 Add public functions for removal of styles and events.
eugeni
parents: 18937
diff changeset
113 * \param track track
07209f48e527 Add public functions for removal of styles and events.
eugeni
parents: 18937
diff changeset
114 * \param sid style id
07209f48e527 Add public functions for removal of styles and events.
eugeni
parents: 18937
diff changeset
115 * Deallocates style data. Does not modify track->n_styles.
07209f48e527 Add public functions for removal of styles and events.
eugeni
parents: 18937
diff changeset
116 */
07209f48e527 Add public functions for removal of styles and events.
eugeni
parents: 18937
diff changeset
117 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
118
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 * \brief delete an event
07209f48e527 Add public functions for removal of styles and events.
eugeni
parents: 18937
diff changeset
121 * \param track track
07209f48e527 Add public functions for removal of styles and events.
eugeni
parents: 18937
diff changeset
122 * \param eid event id
07209f48e527 Add public functions for removal of styles and events.
eugeni
parents: 18937
diff changeset
123 * Deallocates event data. Does not modify track->n_events.
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 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
126
07209f48e527 Add public functions for removal of styles and events.
eugeni
parents: 18937
diff changeset
127 /**
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
128 * \brief Process Codec Private section of subtitle stream
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
129 * \param track target track
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
130 * \param data string to parse
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
131 * \param size length of data
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
132 */
19492
c8daf3471201 SSA/ASS parser reworked, with 2 main results:
eugeni
parents: 19474
diff changeset
133 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
134
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
135 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
136 * \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
137 * \param track track
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
138 * \param data string to parse
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
139 * \param size length of data
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
140 * \param timecode starting time of the event (milliseconds)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
141 * \param duration duration of the event (milliseconds)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
142 */
19492
c8daf3471201 SSA/ASS parser reworked, with 2 main results:
eugeni
parents: 19474
diff changeset
143 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
144
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
145 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
146 * \brief Read subtitles from file.
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
147 * \param fname file name
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
148 * \return newly allocated track
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
149 */
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
150 ass_track_t* ass_read_file(char* fname);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
151
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
152 /**
19652
2c016957360a Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents: 19638
diff changeset
153 * \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
154 * \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
155 */
2c016957360a Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents: 19638
diff changeset
156 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
157
2c016957360a Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents: 19638
diff changeset
158 /**
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
159 * \brief Process embedded matroska font. Saves it to ~/.mplayer/fonts.
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
160 * \param name attachment name
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
161 * \param data binary font data
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
162 * \param data_size data size
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
163 */
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
164 void ass_process_font(const char* name, char* data, int data_size);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
165
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
166 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
167 * \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
168 * \param track subtitle track
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
169 * \param now current time, ms
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
170 * \param movement how many events to skip from the one currently displayed
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
171 * +2 means "the one after the next", -1 means "previous"
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
172 * \return timeshift, ms
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
173 */
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
174 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
175
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
176 #endif
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
177