Mercurial > mplayer.hg
annotate sub/ass_mp.c @ 36802:621b61818a0f
configure: add -Zhigh-mem linker flag for OS/2
x264 encoder crashes due to memory allocation failure. This fixes the problem.
author | komh |
---|---|
date | Thu, 20 Feb 2014 13:59:34 +0000 |
parents | 289d315088ad |
children |
rev | line source |
---|---|
32209 | 1 /* |
2 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com> | |
3 * | |
32210
f6ff1c427ff3
Adapt license header from libass to MPlayer boilerplate.
diego
parents:
32209
diff
changeset
|
4 * This file is part of MPlayer. |
32209 | 5 * |
32210
f6ff1c427ff3
Adapt license header from libass to MPlayer boilerplate.
diego
parents:
32209
diff
changeset
|
6 * MPlayer is free software; you can redistribute it and/or modify |
32209 | 7 * it under the terms of the GNU General Public License as published by |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
32210
f6ff1c427ff3
Adapt license header from libass to MPlayer boilerplate.
diego
parents:
32209
diff
changeset
|
11 * MPlayer is distributed in the hope that it will be useful, |
32209 | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License along | |
32210
f6ff1c427ff3
Adapt license header from libass to MPlayer boilerplate.
diego
parents:
32209
diff
changeset
|
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
32209 | 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 */ | |
20 | |
21 #include <inttypes.h> | |
22 #include <string.h> | |
23 #include <stdlib.h> | |
24 | |
25 #include "mp_msg.h" | |
26 #include "mpcommon.h" | |
27 #include "path.h" | |
32464
22888a8cb312
Do not use a path for including files in the same directory.
reimar
parents:
32461
diff
changeset
|
28 #include "subreader.h" |
32209 | 29 |
32464
22888a8cb312
Do not use a path for including files in the same directory.
reimar
parents:
32461
diff
changeset
|
30 #include "ass_mp.h" |
22888a8cb312
Do not use a path for including files in the same directory.
reimar
parents:
32461
diff
changeset
|
31 #include "eosd.h" |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
32 #include "mpcommon.h" |
32467 | 33 #include "sub.h" |
32209 | 34 #include "help_mp.h" |
32466
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
32464
diff
changeset
|
35 #include "font_load.h" |
32209 | 36 #include "stream/stream.h" |
37 | |
38 #ifdef CONFIG_FONTCONFIG | |
39 #include <fontconfig/fontconfig.h> | |
40 #endif | |
41 | |
42 // libass-related command line options | |
43 ASS_Library* ass_library; | |
44 int ass_enabled = 0; | |
45 float ass_font_scale = 1.; | |
46 float ass_line_spacing = 0.; | |
47 int ass_top_margin = 0; | |
48 int ass_bottom_margin = 0; | |
49 int extract_embedded_fonts = 1; | |
50 char **ass_force_style_list = NULL; | |
51 int ass_use_margins = 0; | |
52 char* ass_color = NULL; | |
53 char* ass_border_color = NULL; | |
54 char* ass_styles_file = NULL; | |
55 int ass_hinting = ASS_HINTING_NATIVE + 4; // native hinting for unscaled osd | |
56 | |
34475
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
57 static void init_style(ASS_Style *style, const char *name, double playres) |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
58 { |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
59 double fs; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
60 uint32_t c1, c2; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
61 style->Name = strdup(name); |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
62 style->FontName = (font_fontconfig >= 0 && sub_font_name) ? strdup(sub_font_name) : (font_fontconfig >= 0 && font_name) ? strdup(font_name) : strdup("Sans"); |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
63 style->treat_fontname_as_pattern = 1; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
64 |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
65 fs = playres * text_font_scale_factor / 100.; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
66 // approximate autoscale coefficients |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
67 if (subtitle_autoscale == 2) |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
68 fs *= 1.3; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
69 else if (subtitle_autoscale == 3) |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
70 fs *= 1.4; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
71 style->FontSize = fs; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
72 |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
73 if (ass_color) c1 = strtoll(ass_color, NULL, 16); |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
74 else c1 = 0xFFFF0000; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
75 if (ass_border_color) c2 = strtoll(ass_border_color, NULL, 16); |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
76 else c2 = 0x00000000; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
77 |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
78 style->PrimaryColour = c1; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
79 style->SecondaryColour = c1; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
80 style->OutlineColour = c2; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
81 style->BackColour = 0x00000000; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
82 style->BorderStyle = 1; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
83 style->Alignment = 2; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
84 style->Outline = 2; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
85 style->MarginL = 10; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
86 style->MarginR = 10; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
87 style->MarginV = 5; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
88 style->ScaleX = 1.; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
89 style->ScaleY = 1.; |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
90 } |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
91 |
32209 | 92 ASS_Track* ass_default_track(ASS_Library* library) { |
93 ASS_Track* track = ass_new_track(library); | |
94 | |
95 track->track_type = TRACK_TYPE_ASS; | |
96 track->Timer = 100.; | |
97 track->PlayResY = 288; | |
98 track->WrapStyle = 0; | |
99 | |
34476 | 100 if (track->n_styles == 0) { |
101 // stupid hack to stop libass to add a default track | |
102 // in front in ass_read_styles - this makes it impossible | |
103 // to completely override the "Default" track. | |
104 int sid = ass_alloc_style(track); | |
105 init_style(track->styles + sid, "MPlayerDummy", track->PlayResY); | |
106 } | |
107 | |
32209 | 108 if (ass_styles_file) |
109 ass_read_styles(track, ass_styles_file, sub_cp); | |
110 | |
34476 | 111 if (track->default_style <= 0) { |
34475
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
112 int sid = ass_alloc_style(track); |
45e9c10b2f5b
Extract setting up default ASS style to a separate function.
reimar
parents:
32467
diff
changeset
|
113 init_style(track->styles + sid, "Default", track->PlayResY); |
34476 | 114 track->default_style = sid; |
32209 | 115 } |
116 | |
117 ass_process_force_style(track); | |
118 return track; | |
119 } | |
120 | |
121 static int check_duplicate_plaintext_event(ASS_Track* track) | |
122 { | |
123 int i; | |
124 ASS_Event* evt = track->events + track->n_events - 1; | |
125 | |
126 for (i = 0; i<track->n_events - 1; ++i) // ignoring last event, it is the one we are comparing with | |
127 if (track->events[i].Start == evt->Start && | |
128 track->events[i].Duration == evt->Duration && | |
129 strcmp(track->events[i].Text, evt->Text) == 0) | |
130 return 1; | |
131 return 0; | |
132 } | |
133 | |
134 /** | |
135 * \brief Convert subtitle to ASS_Event for the given track | |
136 * \param track ASS_Track | |
137 * \param sub subtitle to convert | |
138 * \return event id | |
139 * note: assumes that subtitle is _not_ fps-based; caller must manually correct | |
140 * Start and Duration in other case. | |
141 **/ | |
142 int ass_process_subtitle(ASS_Track* track, subtitle* sub) | |
143 { | |
144 int eid; | |
145 ASS_Event* event; | |
146 int len = 0, j; | |
147 char* p; | |
148 char* end; | |
149 | |
150 eid = ass_alloc_event(track); | |
151 event = track->events + eid; | |
152 | |
153 event->Start = sub->start * 10; | |
154 event->Duration = (sub->end - sub->start) * 10; | |
34476 | 155 event->Style = track->default_style; |
32209 | 156 |
157 for (j = 0; j < sub->lines; ++j) | |
158 len += sub->text[j] ? strlen(sub->text[j]) : 0; | |
159 | |
160 len += 2 * sub->lines; // '\N', including the one after the last line | |
161 len += 6; // {\anX} | |
162 len += 1; // '\0' | |
163 | |
164 event->Text = malloc(len); | |
165 end = event->Text + len; | |
166 p = event->Text; | |
167 | |
168 if (sub->alignment) | |
169 p += snprintf(p, end - p, "{\\an%d}", sub->alignment); | |
170 | |
171 for (j = 0; j < sub->lines; ++j) | |
172 p += snprintf(p, end - p, "%s\\N", sub->text[j]); | |
173 | |
174 if (sub->lines > 0) p-=2; // remove last "\N" | |
175 *p = 0; | |
176 | |
177 if (check_duplicate_plaintext_event(track)) { | |
178 ass_free_event(track, eid); | |
179 track->n_events--; | |
180 return -1; | |
181 } | |
182 | |
183 mp_msg(MSGT_ASS, MSGL_V, "plaintext event at %" PRId64 ", +%" PRId64 ": %s \n", | |
184 (int64_t)event->Start, (int64_t)event->Duration, event->Text); | |
185 | |
186 return eid; | |
187 } | |
188 | |
189 | |
190 /** | |
191 * \brief Convert subdata to ASS_Track | |
192 * \param subdata subtitles struct from subreader | |
193 * \param fps video framerate | |
194 * \return newly allocated ASS_Track, filled with subtitles from subdata | |
195 */ | |
196 ASS_Track* ass_read_subdata(ASS_Library* library, sub_data* subdata, double fps) { | |
197 ASS_Track* track; | |
198 int i; | |
199 | |
200 track = ass_default_track(library); | |
201 track->name = subdata->filename ? strdup(subdata->filename) : 0; | |
202 | |
203 for (i = 0; i < subdata->sub_num; ++i) { | |
204 int eid = ass_process_subtitle(track, subdata->subtitles + i); | |
205 if (eid < 0) | |
206 continue; | |
207 if (!subdata->sub_uses_time) { | |
208 track->events[eid].Start *= 100. / fps; | |
209 track->events[eid].Duration *= 100. / fps; | |
210 } | |
211 } | |
212 return track; | |
213 } | |
214 | |
215 ASS_Track* ass_read_stream(ASS_Library* library, const char *fname, char *charset) { | |
216 char *buf = NULL; | |
217 ASS_Track *track; | |
218 size_t sz = 0; | |
219 size_t buf_alloc = 0; | |
220 stream_t *fd; | |
221 | |
222 fd = open_stream(fname, NULL, NULL); | |
223 if (!fd) { | |
224 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FopenFailed, fname); | |
225 return NULL; | |
226 } | |
227 if (fd->end_pos > STREAM_BUFFER_SIZE) | |
228 /* read entire file if size is known */ | |
229 buf_alloc = fd->end_pos; | |
230 for (;;) { | |
231 int i; | |
232 if (buf_alloc >= 100*1024*1024) { | |
233 mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan100M, fname); | |
234 sz = 0; | |
235 break; | |
236 } | |
237 if (buf_alloc < sz + STREAM_BUFFER_SIZE) | |
238 buf_alloc += STREAM_BUFFER_SIZE; | |
239 buf = realloc(buf, buf_alloc + 1); | |
240 i = stream_read(fd, buf + sz, buf_alloc - sz); | |
241 if (i <= 0) break; | |
242 sz += i; | |
243 } | |
244 free_stream(fd); | |
245 if (!sz) { | |
246 free(buf); | |
247 return NULL; | |
248 } | |
249 buf[sz] = 0; | |
250 buf = realloc(buf, sz + 1); | |
251 track = ass_read_memory(library, buf, sz, charset); | |
252 if (track) { | |
253 free(track->name); | |
254 track->name = strdup(fname); | |
255 } | |
256 free(buf); | |
257 return track; | |
258 } | |
259 | |
35122 | 260 static void ass_configure(ASS_Renderer* priv, int w, int h, int unscaled) { |
32209 | 261 int hinting; |
262 ass_set_frame_size(priv, w, h); | |
263 ass_set_use_margins(priv, ass_use_margins); | |
264 ass_set_font_scale(priv, ass_font_scale); | |
265 if (!unscaled && (ass_hinting & 4)) | |
266 hinting = 0; | |
267 else | |
268 hinting = ass_hinting & 3; | |
269 ass_set_hinting(priv, hinting); | |
270 ass_set_line_spacing(priv, ass_line_spacing); | |
271 } | |
272 | |
35122 | 273 static void ass_configure_fonts(ASS_Renderer* priv) { |
32209 | 274 char *dir, *path, *family; |
275 dir = get_path("fonts"); | |
276 if (font_fontconfig < 0 && sub_font_name) path = strdup(sub_font_name); | |
277 else if (font_fontconfig < 0 && font_name) path = strdup(font_name); | |
278 else path = get_path("subfont.ttf"); | |
279 if (font_fontconfig >= 0 && sub_font_name) family = strdup(sub_font_name); | |
280 else if (font_fontconfig >= 0 && font_name) family = strdup(font_name); | |
281 else family = 0; | |
282 | |
36645 | 283 ass_set_fonts(priv, path, family, font_fontconfig >= 0, NULL, 1); |
32209 | 284 |
285 free(dir); | |
286 free(path); | |
287 free(family); | |
288 } | |
289 | |
290 static void message_callback(int level, const char *format, va_list va, void *ctx) | |
291 { | |
292 int n; | |
293 char *str; | |
294 va_list dst; | |
295 | |
296 va_copy(dst, va); | |
297 n = vsnprintf(NULL, 0, format, va); | |
298 if (n > 0 && (str = malloc(n + 1))) { | |
299 vsnprintf(str, n + 1, format, dst); | |
300 mp_msg(MSGT_ASS, level, "[ass] %s\n", str); | |
301 free(str); | |
302 } | |
35233 | 303 va_end(dst); |
32209 | 304 } |
305 | |
34494 | 306 /** |
307 * Reset all per-file settings for next file. | |
308 */ | |
309 void ass_mp_reset_config(ASS_Library *l) { | |
310 ass_set_extract_fonts(l, extract_embedded_fonts); | |
311 ass_set_style_overrides(l, ass_force_style_list); | |
312 ass_force_reload = 1; | |
313 } | |
314 | |
32209 | 315 ASS_Library* ass_init(void) { |
316 ASS_Library* priv; | |
317 char* path = get_path("fonts"); | |
318 priv = ass_library_init(); | |
319 ass_set_message_cb(priv, message_callback, NULL); | |
320 ass_set_fonts_dir(priv, path); | |
34494 | 321 ass_mp_reset_config(priv); |
32209 | 322 free(path); |
323 return priv; | |
324 } | |
325 | |
326 int ass_force_reload = 0; // flag set if global ass-related settings were changed | |
327 | |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
328 /* EOSD source for ASS subtitles. */ |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
329 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
330 static ASS_Renderer *ass_renderer; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
331 static int prev_visibility; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
332 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
333 static void eosd_ass_update(struct mp_eosd_source *src, const struct mp_eosd_settings *res, double ts) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
334 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
335 long long ts_ms = (ts + sub_delay) * 1000 + .5; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
336 ASS_Image *aimg; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
337 struct mp_eosd_image *img; |
35123 | 338 if (res->changed || !src->initialized || ass_force_reload) { |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
339 double dar = (double) (res->w - res->ml - res->mr) / (res->h - res->mt - res->mb); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
340 ass_configure(ass_renderer, res->w, res->h, res->unscaled); |
35123 | 341 ass_set_margins(ass_renderer, res->mt + ass_top_margin, res->mb + ass_bottom_margin, res->ml, res->mr); |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
342 ass_set_aspect_ratio(ass_renderer, dar, (double)res->srcw / res->srch); |
32426
fbee56276c87
Add a flag "initialized" to the mp_eosd_source structure.
cigaes
parents:
32397
diff
changeset
|
343 src->initialized = 1; |
35123 | 344 ass_force_reload = 0; |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
345 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
346 aimg = sub_visibility && ass_track && ts != MP_NOPTS_VALUE ? |
35123 | 347 ass_render_frame(ass_renderer, ass_track, ts_ms, &src->changed) : |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
348 NULL; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
349 if (!aimg != !src->images) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
350 src->changed = 2; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
351 if (src->changed) { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
352 eosd_image_remove_all(src); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
353 while (aimg) { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
354 img = eosd_image_alloc(); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
355 img->w = aimg->w; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
356 img->h = aimg->h; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
357 img->bitmap = aimg->bitmap; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
358 img->stride = aimg->stride; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
359 img->color = aimg->color; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
360 img->dst_x = aimg->dst_x; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
361 img->dst_y = aimg->dst_y; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
362 eosd_image_append(src, img); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
363 aimg = aimg->next; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
364 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
365 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
366 prev_visibility = sub_visibility; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
367 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
368 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
369 static void eosd_ass_uninit(struct mp_eosd_source *src) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
370 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
371 eosd_image_remove_all(src); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
372 ass_renderer_done(ass_renderer); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
373 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
374 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
375 static struct mp_eosd_source eosd_ass = { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
376 .uninit = eosd_ass_uninit, |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
377 .update = eosd_ass_update, |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
378 .z_index = 10, |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
379 }; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
380 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
381 void eosd_ass_init(ASS_Library *ass_library) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
382 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
383 ass_renderer = ass_renderer_init(ass_library); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
384 if (!ass_renderer) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
385 return; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
386 ass_configure_fonts(ass_renderer); |
32397
b3110e526e19
EOSD: add a function to test if a source has already been registered.
cigaes
parents:
32391
diff
changeset
|
387 if (!eosd_registered(&eosd_ass)) |
b3110e526e19
EOSD: add a function to test if a source has already been registered.
cigaes
parents:
32391
diff
changeset
|
388 eosd_register(&eosd_ass); |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32210
diff
changeset
|
389 } |