Mercurial > mplayer.hg
annotate libass/ass.c @ 19657:a75995bf41e6
Remove outdated references to CVS.
author | diego |
---|---|
date | Sun, 03 Sep 2006 19:30:57 +0000 |
parents | 2c016957360a |
children | 5a24682d9dd5 |
rev | line source |
---|---|
18937 | 1 #include "config.h" |
2 | |
3 #include <stdio.h> | |
4 #include <stdlib.h> | |
5 #include <string.h> | |
6 #include <assert.h> | |
7 #include <errno.h> | |
8 #include <sys/types.h> | |
9 #include <sys/stat.h> | |
10 #include <unistd.h> | |
19374 | 11 #include <inttypes.h> |
18937 | 12 |
13 #ifdef HAVE_ENCA | |
14 #include "subreader.h" // for guess_buffer_cp | |
15 #endif | |
16 | |
17 #ifdef USE_ICONV | |
18 #include <iconv.h> | |
19 extern char *sub_cp; | |
20 #endif | |
19492 | 21 extern int extract_embedded_fonts; |
19495 | 22 extern char** ass_force_style_list; |
18937 | 23 |
24 #include "mp_msg.h" | |
25 #include "ass.h" | |
26 #include "ass_utils.h" | |
27 #include "libvo/sub.h" // for utf8_get_char | |
28 | |
29 char *get_path(char *); | |
30 | |
19652
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
31 typedef enum {PST_UNKNOWN = 0, PST_INFO, PST_STYLES, PST_EVENTS, PST_FONTS} parser_state_t; |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
32 |
19492 | 33 struct parser_priv_s { |
19652
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
34 parser_state_t state; |
19492 | 35 char* fontname; |
36 char* fontdata; | |
37 int fontdata_size; | |
38 int fontdata_used; | |
39 }; | |
40 | |
18937 | 41 #define ASS_STYLES_ALLOC 20 |
42 #define ASS_EVENTS_ALLOC 200 | |
43 | |
44 void ass_free_track(ass_track_t* track) { | |
45 int i; | |
46 | |
19492 | 47 if (track->parser_priv) { |
48 if (track->parser_priv->fontname) | |
49 free(track->parser_priv->fontname); | |
50 if (track->parser_priv->fontdata) | |
51 free(track->parser_priv->fontdata); | |
52 free(track->parser_priv); | |
53 } | |
18937 | 54 if (track->style_format) |
55 free(track->style_format); | |
56 if (track->event_format) | |
57 free(track->event_format); | |
58 if (track->styles) { | |
19474
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
59 for (i = 0; i < track->n_styles; ++i) |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
60 ass_free_style(track, i); |
18937 | 61 free(track->styles); |
62 } | |
63 if (track->events) { | |
19474
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
64 for (i = 0; i < track->n_events; ++i) |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
65 ass_free_event(track, i); |
18937 | 66 free(track->events); |
67 } | |
68 } | |
69 | |
70 /// \brief Allocate a new style struct | |
71 /// \param track track | |
72 /// \return style id | |
73 int ass_alloc_style(ass_track_t* track) { | |
74 int sid; | |
75 | |
76 assert(track->n_styles <= track->max_styles); | |
77 | |
78 if (track->n_styles == track->max_styles) { | |
79 track->max_styles += ASS_STYLES_ALLOC; | |
80 track->styles = (ass_style_t*)realloc(track->styles, sizeof(ass_style_t)*track->max_styles); | |
81 } | |
82 | |
83 sid = track->n_styles++; | |
84 memset(track->styles + sid, 0, sizeof(ass_style_t)); | |
85 return sid; | |
86 } | |
87 | |
88 /// \brief Allocate a new event struct | |
89 /// \param track track | |
90 /// \return event id | |
91 int ass_alloc_event(ass_track_t* track) { | |
92 int eid; | |
93 | |
94 assert(track->n_events <= track->max_events); | |
95 | |
96 if (track->n_events == track->max_events) { | |
97 track->max_events += ASS_EVENTS_ALLOC; | |
98 track->events = (ass_event_t*)realloc(track->events, sizeof(ass_event_t)*track->max_events); | |
99 } | |
100 | |
101 eid = track->n_events++; | |
102 memset(track->events + eid, 0, sizeof(ass_event_t)); | |
103 return eid; | |
104 } | |
105 | |
19474
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
106 void ass_free_event(ass_track_t* track, int eid) { |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
107 ass_event_t* event = track->events + eid; |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
108 if (event->Name) |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
109 free(event->Name); |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
110 if (event->Effect) |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
111 free(event->Effect); |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
112 if (event->Text) |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
113 free(event->Text); |
19638
a3473d990fed
Better collision detection algorithm. The idea is to keep a subtitle in place
eugeni
parents:
19635
diff
changeset
|
114 if (event->render_priv) |
a3473d990fed
Better collision detection algorithm. The idea is to keep a subtitle in place
eugeni
parents:
19635
diff
changeset
|
115 free(event->render_priv); |
19474
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
116 } |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
117 |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
118 void ass_free_style(ass_track_t* track, int sid) { |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
119 ass_style_t* style = track->styles + sid; |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
120 if (style->Name) |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
121 free(style->Name); |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
122 if (style->FontName) |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
123 free(style->FontName); |
18937 | 124 } |
125 | |
126 // ============================================================================================== | |
127 | |
128 static void skip_spaces(char** str) { | |
129 char* p = *str; | |
130 while ((*p==' ') || (*p=='\t')) | |
131 ++p; | |
132 *str = p; | |
133 } | |
134 | |
135 static void rskip_spaces(char** str, char* limit) { | |
136 char* p = *str; | |
137 while ((p >= limit) && ((*p==' ') || (*p=='\t'))) | |
138 --p; | |
139 *str = p; | |
140 } | |
141 | |
142 /** | |
143 * \brief find style by name | |
144 * \param track track | |
145 * \param name style name | |
146 * \return index in track->styles | |
147 * Returnes 0 if no styles found => expects at least 1 style. | |
148 * Parsing code always adds "Default" style in the end. | |
149 */ | |
150 static int lookup_style(ass_track_t* track, char* name) { | |
151 int i; | |
19567 | 152 if (*name == '*') ++name; // FIXME: what does '*' really mean ? |
18937 | 153 for (i=0; i<track->n_styles; ++i) { |
154 // FIXME: mb strcasecmp ? | |
155 if (strcmp(track->styles[i].Name, name) == 0) | |
156 return i; | |
157 } | |
158 i = track->default_style; | |
159 mp_msg(MSGT_GLOBAL, MSGL_WARN, "[%p] Warning: no style named '%s' found, using '%s'\n", track, name, track->styles[i].Name); | |
160 return i; // use the first style | |
161 } | |
162 | |
163 static uint32_t string2color(char* p) { | |
164 uint32_t tmp; | |
165 (void)strtocolor(&p, &tmp); | |
166 return tmp; | |
167 } | |
168 | |
169 static long long string2timecode(char* p) { | |
170 unsigned h, m, s, ms; | |
171 long long tm; | |
172 int res = sscanf(p, "%1d:%2d:%2d.%2d", &h, &m, &s, &ms); | |
173 if (res < 4) { | |
174 mp_msg(MSGT_GLOBAL, MSGL_WARN, "bad timestamp\n"); | |
175 return 0; | |
176 } | |
177 tm = ((h * 60 + m) * 60 + s) * 1000 + ms * 10; | |
178 return tm; | |
179 } | |
180 | |
181 /** | |
182 * \brief converts numpad-style align to align. | |
183 */ | |
184 static int numpad2align(int val) { | |
185 int res, v; | |
186 v = (val - 1) / 3; // 0, 1 or 2 for vertical alignment | |
187 if (v != 0) v = 3 - v; | |
188 res = ((val - 1) % 3) + 1; // horizontal alignment | |
189 res += v*4; | |
190 return res; | |
191 } | |
192 | |
193 #define NEXT(str,token) \ | |
194 token = next_token(&str); \ | |
195 if (!token) break; | |
196 | |
197 #define ANYVAL(name,func) \ | |
198 } else if (strcasecmp(tname, #name) == 0) { \ | |
199 target->name = func(token); \ | |
200 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "%s = %s\n", #name, token); | |
19495 | 201 |
202 #define STRVAL(name) \ | |
203 } else if (strcasecmp(tname, #name) == 0) { \ | |
204 if (target->name != NULL) free(target->name); \ | |
205 target->name = strdup(token); \ | |
206 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "%s = %s\n", #name, token); | |
207 | |
18937 | 208 #define COLORVAL(name) ANYVAL(name,string2color) |
209 #define INTVAL(name) ANYVAL(name,atoi) | |
210 #define FPVAL(name) ANYVAL(name,atof) | |
211 #define TIMEVAL(name) ANYVAL(name,string2timecode) | |
212 #define STYLEVAL(name) \ | |
213 } else if (strcasecmp(tname, #name) == 0) { \ | |
214 target->name = lookup_style(track, token); \ | |
215 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "%s = %s\n", #name, token); | |
216 | |
217 #define ALIAS(alias,name) \ | |
218 if (strcasecmp(tname, #alias) == 0) {tname = #name;} | |
219 | |
220 static char* next_token(char** str) { | |
221 char* p = *str; | |
222 char* start; | |
223 skip_spaces(&p); | |
224 if (*p == '\0') { | |
225 *str = p; | |
226 return 0; | |
227 } | |
228 start = p; // start of the token | |
229 for (; (*p != '\0') && (*p != ','); ++p) {} | |
230 if (*p == '\0') { | |
231 *str = p; // eos found, str will point to '\0' at exit | |
232 } else { | |
233 *p = '\0'; | |
234 *str = p + 1; // ',' found, str will point to the next char (beginning of the next token) | |
235 } | |
236 --p; // end of current token | |
237 rskip_spaces(&p, start); | |
238 if (p < start) | |
239 p = start; // empty token | |
240 else | |
241 ++p; // the first space character, or '\0' | |
242 *p = '\0'; | |
243 return start; | |
244 } | |
245 /** | |
246 * \brief Parse the tail of Dialogue line | |
247 * \param track track | |
248 * \param event parsed data goes here | |
249 * \param str string to parse, zero-terminated | |
250 * \param n_ignored number of format options to skip at the beginning | |
251 */ | |
252 static int process_event_tail(ass_track_t* track, ass_event_t* event, char* str, int n_ignored) | |
253 { | |
254 char* token; | |
255 char* tname; | |
256 char* p = str; | |
257 int i; | |
258 ass_event_t* target = event; | |
259 | |
260 char* format = strdup(track->event_format); | |
261 char* q = format; // format scanning pointer | |
262 | |
263 for (i = 0; i < n_ignored; ++i) { | |
264 NEXT(q, tname); | |
265 } | |
266 | |
267 while (1) { | |
268 NEXT(q, tname); | |
269 if (strcasecmp(tname, "Text") == 0) { | |
270 char* last; | |
271 event->Text = strdup(p); | |
19612 | 272 if (*event->Text != 0) { |
273 last = event->Text + strlen(event->Text) - 1; | |
274 if (last >= event->Text && *last == '\r') | |
275 *last = 0; | |
276 } | |
18937 | 277 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "Text = %s\n", event->Text); |
278 event->Duration -= event->Start; | |
279 free(format); | |
280 return 0; // "Text" is always the last | |
281 } | |
282 NEXT(p, token); | |
283 | |
284 ALIAS(End,Duration) // temporarily store end timecode in event->Duration | |
285 if (0) { // cool ;) | |
19635 | 286 INTVAL(Layer) |
18937 | 287 STYLEVAL(Style) |
288 STRVAL(Name) | |
289 STRVAL(Effect) | |
290 INTVAL(MarginL) | |
291 INTVAL(MarginR) | |
292 INTVAL(MarginV) | |
293 TIMEVAL(Start) | |
294 TIMEVAL(Duration) | |
295 } | |
296 } | |
297 free(format); | |
298 return 1; | |
299 } | |
300 | |
301 /** | |
19495 | 302 * \brief Parse command line style overrides (--ass-force-style option) |
303 * \param track track to apply overrides to | |
304 * The format for overrides is [StyleName.]Field=Value | |
305 */ | |
19584
586e7d259d05
Apply -ass-force-style also to tracks generated from subdata.
eugeni
parents:
19567
diff
changeset
|
306 void process_force_style(ass_track_t* track) { |
19495 | 307 char **fs, *eq, *dt, *style, *tname, *token; |
308 ass_style_t* target; | |
309 int sid; | |
310 | |
311 if (!ass_force_style_list) return; | |
312 | |
313 for (fs = ass_force_style_list; *fs; ++fs) { | |
314 eq = strchr(*fs, '='); | |
315 if (!eq) | |
316 continue; | |
317 *eq = '\0'; | |
318 token = eq + 1; | |
319 | |
320 dt = strchr(*fs, '.'); | |
321 if (dt) { | |
322 *dt = '\0'; | |
323 style = *fs; | |
324 tname = dt + 1; | |
325 } else { | |
326 style = NULL; | |
327 tname = *fs; | |
328 } | |
329 for (sid = 0; sid < track->n_styles; ++sid) { | |
330 if (style == NULL || strcasecmp(track->styles[sid].Name, style) == 0) { | |
331 target = track->styles + sid; | |
332 if (0) { | |
333 STRVAL(FontName) | |
334 COLORVAL(PrimaryColour) | |
335 COLORVAL(SecondaryColour) | |
336 COLORVAL(OutlineColour) | |
337 COLORVAL(BackColour) | |
338 INTVAL(FontSize) | |
339 INTVAL(Bold) | |
340 INTVAL(Italic) | |
341 INTVAL(Underline) | |
342 INTVAL(StrikeOut) | |
343 INTVAL(Spacing) | |
344 INTVAL(Angle) | |
345 INTVAL(BorderStyle) | |
346 INTVAL(Alignment) | |
347 INTVAL(MarginL) | |
348 INTVAL(MarginR) | |
349 INTVAL(MarginV) | |
350 INTVAL(Encoding) | |
351 FPVAL(ScaleX) | |
352 FPVAL(ScaleY) | |
353 FPVAL(Outline) | |
354 FPVAL(Shadow) | |
355 } | |
356 } | |
357 } | |
358 *eq = '='; | |
359 if (dt) *dt = '.'; | |
360 } | |
361 } | |
362 | |
363 /** | |
18937 | 364 * \brief Parse the Style line |
365 * \param track track | |
366 * \param str string to parse, zero-terminated | |
367 * Allocates a new style struct. | |
368 */ | |
369 static int process_style(ass_track_t* track, char *str) | |
370 { | |
371 | |
372 char* token; | |
373 char* tname; | |
374 char* p = str; | |
375 char* format; | |
376 char* q; // format scanning pointer | |
377 int sid; | |
378 ass_style_t* style; | |
379 ass_style_t* target; | |
380 | |
381 if (!track->style_format) { | |
382 // no style format header | |
383 // probably an ancient script version | |
384 if (track->track_type == TRACK_TYPE_SSA) | |
385 track->style_format = strdup("Name, Fontname, Fontsize, PrimaryColour, SecondaryColour," | |
386 "TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline," | |
387 "Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding"); | |
388 else | |
389 track->style_format = strdup("Name, Fontname, Fontsize, PrimaryColour, SecondaryColour," | |
390 "OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut," | |
391 "ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow," | |
392 "Alignment, MarginL, MarginR, MarginV, Encoding"); | |
393 } | |
394 | |
395 q = format = strdup(track->style_format); | |
396 | |
397 mp_msg(MSGT_GLOBAL, MSGL_V, "[%p] Style: %s\n", track, str); | |
398 | |
399 sid = ass_alloc_style(track); | |
400 | |
401 style = track->styles + sid; | |
402 target = style; | |
403 // fill style with some default values | |
404 style->ScaleX = 100.; | |
405 style->ScaleY = 100.; | |
406 | |
407 while (1) { | |
408 NEXT(q, tname); | |
409 NEXT(p, token); | |
410 | |
411 // ALIAS(TertiaryColour,OutlineColour) // ignore TertiaryColour; it appears only in SSA, and is overridden by BackColour | |
412 | |
413 if (0) { // cool ;) | |
414 STRVAL(Name) | |
415 if ((strcmp(target->Name, "Default")==0) || (strcmp(target->Name, "*Default")==0)) | |
416 track->default_style = sid; | |
417 STRVAL(FontName) | |
418 COLORVAL(PrimaryColour) | |
419 COLORVAL(SecondaryColour) | |
420 COLORVAL(OutlineColour) // TertiaryColor | |
421 COLORVAL(BackColour) | |
422 // SSA uses BackColour for both outline and shadow | |
423 // this will destroy SSA's TertiaryColour, but i'm not going to use it anyway | |
424 if (track->track_type == TRACK_TYPE_SSA) | |
425 target->OutlineColour = target->BackColour; | |
426 INTVAL(FontSize) | |
427 INTVAL(Bold) | |
428 INTVAL(Italic) | |
429 INTVAL(Underline) | |
430 INTVAL(StrikeOut) | |
431 INTVAL(Spacing) | |
432 INTVAL(Angle) | |
433 INTVAL(BorderStyle) | |
434 INTVAL(Alignment) | |
435 if (track->track_type == TRACK_TYPE_ASS) | |
436 target->Alignment = numpad2align(target->Alignment); | |
437 INTVAL(MarginL) | |
438 INTVAL(MarginR) | |
439 INTVAL(MarginV) | |
440 INTVAL(Encoding) | |
441 FPVAL(ScaleX) | |
442 FPVAL(ScaleY) | |
443 FPVAL(Outline) | |
444 FPVAL(Shadow) | |
445 } | |
446 } | |
447 style->ScaleX /= 100.; | |
448 style->ScaleY /= 100.; | |
449 if (!style->Name) | |
450 style->Name = strdup("Default"); | |
451 if (!style->FontName) | |
452 style->FontName = strdup("Arial"); | |
453 free(format); | |
454 return 0; | |
455 | |
456 } | |
457 | |
19492 | 458 static int process_styles_line(ass_track_t* track, char *str) |
459 { | |
460 if (!strncmp(str,"Format:", 7)) { | |
461 char* p = str + 7; | |
462 skip_spaces(&p); | |
463 track->style_format = strdup(p); | |
464 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "Style format: %s\n", track->style_format); | |
465 } else if (!strncmp(str,"Style:", 6)) { | |
466 char* p = str + 6; | |
467 skip_spaces(&p); | |
468 process_style(track, p); | |
469 } | |
470 return 0; | |
471 } | |
472 | |
473 static int process_info_line(ass_track_t* track, char *str) | |
474 { | |
475 if (!strncmp(str, "PlayResX:", 9)) { | |
476 track->PlayResX = atoi(str + 9); | |
477 } else if (!strncmp(str,"PlayResY:", 9)) { | |
478 track->PlayResY = atoi(str + 9); | |
479 } else if (!strncmp(str,"Timer:", 6)) { | |
480 track->Timer = atof(str + 6); | |
481 } else if (!strncmp(str,"WrapStyle:", 10)) { | |
482 track->WrapStyle = atoi(str + 10); | |
483 } | |
484 return 0; | |
485 } | |
486 | |
487 static int process_events_line(ass_track_t* track, char *str) | |
488 { | |
489 if (!strncmp(str, "Format:", 7)) { | |
490 char* p = str + 7; | |
491 skip_spaces(&p); | |
492 track->event_format = strdup(p); | |
493 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "Event format: %s\n", track->event_format); | |
494 } else if (!strncmp(str, "Dialogue:", 9)) { | |
495 // This should never be reached for embedded subtitles. | |
496 // They have slightly different format and are parsed in ass_process_chunk, | |
497 // called directly from demuxer | |
498 int eid; | |
499 ass_event_t* event; | |
500 | |
501 str += 9; | |
502 skip_spaces(&str); | |
503 | |
504 eid = ass_alloc_event(track); | |
505 event = track->events + eid; | |
506 | |
507 process_event_tail(track, event, str, 0); | |
508 } else { | |
509 mp_msg(MSGT_GLOBAL, MSGL_V, "Not understood: %s \n", str); | |
510 } | |
511 return 0; | |
512 } | |
513 | |
514 // Copied from mkvtoolnix | |
515 static unsigned char* decode_chars(unsigned char c1, unsigned char c2, | |
516 unsigned char c3, unsigned char c4, unsigned char* dst, int cnt) | |
517 { | |
518 uint32_t value; | |
519 unsigned char bytes[3]; | |
520 int i; | |
521 | |
522 value = ((c1 - 33) << 18) + ((c2 - 33) << 12) + ((c3 - 33) << 6) + (c4 - 33); | |
523 bytes[2] = value & 0xff; | |
524 bytes[1] = (value & 0xff00) >> 8; | |
525 bytes[0] = (value & 0xff0000) >> 16; | |
526 | |
527 for (i = 0; i < cnt; ++i) | |
528 *dst++ = bytes[i]; | |
529 return dst; | |
530 } | |
531 | |
532 static int decode_font(ass_track_t* track) | |
533 { | |
534 unsigned char* p; | |
535 unsigned char* q; | |
536 int i; | |
537 int size; // original size | |
538 int dsize; // decoded size | |
539 unsigned char* buf = 0; | |
540 | |
541 mp_msg(MSGT_GLOBAL, MSGL_V, "font: %d bytes encoded data \n", track->parser_priv->fontdata_used); | |
542 size = track->parser_priv->fontdata_used; | |
543 if (size % 4 == 1) { | |
544 mp_msg(MSGT_GLOBAL, MSGL_ERR, "bad encoded data size\n"); | |
545 goto error_decode_font; | |
546 } | |
547 buf = malloc(size / 4 * 3 + 2); | |
548 q = buf; | |
549 for (i = 0, p = (unsigned char*)track->parser_priv->fontdata; i < size / 4; i++, p+=4) { | |
550 q = decode_chars(p[0], p[1], p[2], p[3], q, 3); | |
551 } | |
552 if (size % 4 == 2) { | |
553 q = decode_chars(p[0], p[1], 0, 0, q, 1); | |
554 } else if (size % 4 == 3) { | |
555 q = decode_chars(p[0], p[1], p[2], 0, q, 2); | |
556 } | |
557 dsize = q - buf; | |
558 assert(dsize <= size / 4 * 3 + 2); | |
559 | |
560 if (extract_embedded_fonts) | |
561 ass_process_font(track->parser_priv->fontname, (char*)buf, dsize); | |
562 | |
563 error_decode_font: | |
564 if (buf) free(buf); | |
565 free(track->parser_priv->fontname); | |
566 free(track->parser_priv->fontdata); | |
567 track->parser_priv->fontname = 0; | |
568 track->parser_priv->fontdata = 0; | |
569 track->parser_priv->fontdata_size = 0; | |
570 track->parser_priv->fontdata_used = 0; | |
571 return 0; | |
572 } | |
573 | |
574 static char* validate_fname(char* name); | |
575 | |
576 static int process_fonts_line(ass_track_t* track, char *str) | |
577 { | |
578 int len; | |
579 | |
580 if (!strncmp(str, "fontname:", 9)) { | |
581 char* p = str + 9; | |
582 skip_spaces(&p); | |
583 if (track->parser_priv->fontname) { | |
584 decode_font(track); | |
585 } | |
586 track->parser_priv->fontname = validate_fname(p); | |
587 mp_msg(MSGT_GLOBAL, MSGL_V, "fontname: %s\n", track->parser_priv->fontname); | |
588 return 0; | |
589 } | |
590 | |
591 if (!track->parser_priv->fontname) { | |
592 mp_msg(MSGT_GLOBAL, MSGL_V, "Not understood: %s \n", str); | |
593 return 0; | |
594 } | |
595 | |
596 len = strlen(str); | |
597 if (len > 80) { | |
598 mp_msg(MSGT_GLOBAL, MSGL_WARN, "Font line too long: %d, %s\n", len, str); | |
599 return 0; | |
600 } | |
601 if (track->parser_priv->fontdata_used + len > track->parser_priv->fontdata_size) { | |
602 track->parser_priv->fontdata_size += 100 * 1024; | |
603 track->parser_priv->fontdata = realloc(track->parser_priv->fontdata, track->parser_priv->fontdata_size); | |
604 } | |
605 memcpy(track->parser_priv->fontdata + track->parser_priv->fontdata_used, str, len); | |
606 track->parser_priv->fontdata_used += len; | |
607 | |
608 return 0; | |
609 } | |
610 | |
18937 | 611 /** |
612 * \brief Parse a header line | |
613 * \param track track | |
614 * \param str string to parse, zero-terminated | |
615 */ | |
19492 | 616 static int process_line(ass_track_t* track, char *str) |
18937 | 617 { |
19492 | 618 if (strstr(str, "[Script Info]")) { // FIXME: strstr to skip possible BOM at the beginning of the script |
619 track->parser_priv->state = PST_INFO; | |
620 } else if (!strncmp(str, "[V4 Styles]", 11)) { | |
621 track->parser_priv->state = PST_STYLES; | |
622 track->track_type = TRACK_TYPE_SSA; | |
623 } else if (!strncmp(str, "[V4+ Styles]", 12)) { | |
624 track->parser_priv->state = PST_STYLES; | |
625 track->track_type = TRACK_TYPE_ASS; | |
626 } else if (!strncmp(str, "[Events]", 8)) { | |
627 track->parser_priv->state = PST_EVENTS; | |
628 } else if (!strncmp(str, "[Fonts]", 7)) { | |
629 track->parser_priv->state = PST_FONTS; | |
630 } else { | |
631 switch (track->parser_priv->state) { | |
632 case PST_INFO: | |
633 process_info_line(track, str); | |
634 break; | |
635 case PST_STYLES: | |
636 process_styles_line(track, str); | |
637 break; | |
638 case PST_EVENTS: | |
639 process_events_line(track, str); | |
640 break; | |
641 case PST_FONTS: | |
642 process_fonts_line(track, str); | |
643 break; | |
644 default: | |
645 break; | |
18937 | 646 } |
19492 | 647 } |
648 | |
649 // there is no explicit end-of-font marker in ssa/ass | |
650 if ((track->parser_priv->state != PST_FONTS) && (track->parser_priv->fontname)) | |
651 decode_font(track); | |
652 | |
653 return 0; | |
654 } | |
655 | |
656 static int process_text(ass_track_t* track, char* str) | |
657 { | |
658 char* p = str; | |
659 while(1) { | |
660 char* q; | |
661 for (;((*p=='\r')||(*p=='\n'));++p) {} | |
662 for (q=p; ((*q!='\0')&&(*q!='\r')&&(*q!='\n')); ++q) {}; | |
663 if (q==p) | |
664 break; | |
665 if (*q != '\0') | |
666 *(q++) = '\0'; | |
667 process_line(track, p); | |
668 if (*q == '\0') | |
669 break; | |
670 p = q; | |
18937 | 671 } |
672 return 0; | |
673 } | |
674 | |
675 /** | |
676 * \brief Process CodecPrivate section of subtitle stream | |
677 * \param track track | |
678 * \param data string to parse | |
679 * \param size length of data | |
19492 | 680 CodecPrivate section contains [Stream Info] and [V4+ Styles] ([V4 Styles] for SSA) sections |
18937 | 681 */ |
19492 | 682 void ass_process_codec_private(ass_track_t* track, char *data, int size) |
18937 | 683 { |
684 char* str = malloc(size + 1); | |
685 int sid; | |
686 | |
687 memcpy(str, data, size); | |
688 str[size] = '\0'; | |
689 | |
19492 | 690 process_text(track, str); |
18937 | 691 free(str); |
692 | |
693 // add "Default" style to the end | |
694 // will be used if track does not contain a default style (or even does not contain styles at all) | |
695 sid = ass_alloc_style(track); | |
696 track->styles[sid].Name = strdup("Default"); | |
697 track->styles[sid].FontName = strdup("Arial"); | |
698 | |
699 if (!track->event_format) { | |
700 // probably an mkv produced by ancient mkvtoolnix | |
701 // such files don't have [Events] and Format: headers | |
19492 | 702 track->parser_priv->state = PST_EVENTS; |
18937 | 703 if (track->track_type == TRACK_TYPE_SSA) |
704 track->event_format = strdup("Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"); | |
705 else | |
706 track->event_format = strdup("Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text"); | |
707 } | |
19495 | 708 |
709 process_force_style(track); | |
18937 | 710 } |
711 | |
712 static int check_duplicate_event(ass_track_t* track, int ReadOrder) | |
713 { | |
714 int i; | |
715 for (i = 0; i<track->n_events - 1; ++i) // ignoring last event, it is the one we are comparing with | |
716 if (track->events[i].ReadOrder == ReadOrder) | |
717 return 1; | |
718 return 0; | |
719 } | |
720 | |
721 /** | |
722 * \brief Process a chunk of subtitle stream data. In matroska, this containes exactly 1 event (or a commentary) | |
723 * \param track track | |
724 * \param data string to parse | |
725 * \param size length of data | |
726 * \param timecode starting time of the event (milliseconds) | |
727 * \param duration duration of the event (milliseconds) | |
728 */ | |
19492 | 729 void ass_process_chunk(ass_track_t* track, char *data, int size, long long timecode, long long duration) |
18937 | 730 { |
731 char* str; | |
732 int eid; | |
733 char* p; | |
734 char* token; | |
735 ass_event_t* event; | |
736 | |
737 if (!track->event_format) { | |
738 mp_msg(MSGT_GLOBAL, MSGL_WARN, "Event format header missing\n"); | |
739 return; | |
740 } | |
741 | |
742 str = malloc(size + 1); | |
743 memcpy(str, data, size); | |
744 str[size] = '\0'; | |
19378 | 745 mp_msg(MSGT_GLOBAL, MSGL_V, "event at %" PRId64 ", +%" PRId64 ": %s \n", (int64_t)timecode, (int64_t)duration, str); |
18937 | 746 |
747 eid = ass_alloc_event(track); | |
748 event = track->events + eid; | |
749 | |
750 p = str; | |
751 | |
752 do { | |
753 NEXT(p, token); | |
754 event->ReadOrder = atoi(token); | |
755 if (check_duplicate_event(track, event->ReadOrder)) | |
756 break; | |
757 | |
758 NEXT(p, token); | |
759 event->Layer = atoi(token); | |
760 | |
761 process_event_tail(track, event, p, 3); | |
762 | |
763 event->Start = timecode; | |
764 event->Duration = duration; | |
765 | |
766 free(str); | |
767 return; | |
768 // dump_events(tid); | |
769 } while (0); | |
770 // some error | |
19474
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
771 ass_free_event(track, eid); |
07209f48e527
Add public functions for removal of styles and events.
eugeni
parents:
19405
diff
changeset
|
772 track->n_events--; |
18937 | 773 free(str); |
774 } | |
775 | |
776 #ifdef USE_ICONV | |
777 /** \brief recode buffer to utf-8 | |
778 * constraint: sub_cp != 0 | |
779 * \param data pointer to text buffer | |
780 * \param size buffer size | |
781 * \return a pointer to recoded buffer, caller is responsible for freeing it | |
782 **/ | |
783 static char* sub_recode(char* data, size_t size) | |
784 { | |
785 static iconv_t icdsc = (iconv_t)(-1); | |
786 char* tocp = "UTF-8"; | |
787 char* outbuf; | |
788 assert(sub_cp); | |
789 | |
790 { | |
791 char* cp_tmp = sub_cp; | |
792 #ifdef HAVE_ENCA | |
793 char enca_lang[3], enca_fallback[100]; | |
794 if (sscanf(sub_cp, "enca:%2s:%99s", enca_lang, enca_fallback) == 2 | |
795 || sscanf(sub_cp, "ENCA:%2s:%99s", enca_lang, enca_fallback) == 2) { | |
796 cp_tmp = guess_buffer_cp((unsigned char*)data, size, enca_lang, enca_fallback); | |
797 } | |
798 #endif | |
799 if ((icdsc = iconv_open (tocp, cp_tmp)) != (iconv_t)(-1)){ | |
800 mp_msg(MSGT_SUBREADER,MSGL_V,"LIBSUB: opened iconv descriptor.\n"); | |
801 } else | |
802 mp_msg(MSGT_SUBREADER,MSGL_ERR,"LIBSUB: error opening iconv descriptor.\n"); | |
803 #ifdef HAVE_ENCA | |
804 if (cp_tmp) free(cp_tmp); | |
805 #endif | |
806 } | |
807 | |
808 { | |
809 size_t osize = size; | |
810 size_t ileft = size; | |
811 size_t oleft = size - 1; | |
812 char* ip; | |
813 char* op; | |
814 size_t rc; | |
815 | |
816 outbuf = malloc(size); | |
817 ip = data; | |
818 op = outbuf; | |
819 | |
820 while (ileft) { | |
821 rc = iconv(icdsc, &ip, &ileft, &op, &oleft); | |
822 if (rc == (size_t)(-1)) { | |
823 if (errno == E2BIG) { | |
824 int offset = op - outbuf; | |
825 outbuf = (char*)realloc(outbuf, osize + size); | |
826 op = outbuf + offset; | |
827 osize += size; | |
828 oleft += size; | |
829 } else { | |
830 mp_msg(MSGT_SUBREADER, MSGL_WARN, "LIBSUB: error recoding file.\n"); | |
831 return NULL; | |
832 } | |
833 } | |
834 } | |
835 outbuf[osize - oleft - 1] = 0; | |
836 } | |
837 | |
838 if (icdsc != (iconv_t)(-1)) { | |
839 (void)iconv_close(icdsc); | |
840 icdsc = (iconv_t)(-1); | |
841 mp_msg(MSGT_SUBREADER,MSGL_V,"LIBSUB: closed iconv descriptor.\n"); | |
842 } | |
843 | |
844 return outbuf; | |
845 } | |
846 #endif // ICONV | |
847 | |
848 /** | |
19652
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
849 * \brief read file contents into newly allocated buffer, recoding to utf-8 |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
850 */ |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
851 static char* read_file(char* fname) |
18937 | 852 { |
853 int res; | |
854 long sz; | |
855 long bytes_read; | |
856 char* buf; | |
19652
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
857 |
18937 | 858 FILE* fp = fopen(fname, "rb"); |
859 if (!fp) { | |
860 mp_msg(MSGT_GLOBAL, MSGL_WARN, "ass_read_file(%s): fopen failed\n", fname); | |
861 return 0; | |
862 } | |
863 res = fseek(fp, 0, SEEK_END); | |
864 if (res == -1) { | |
865 mp_msg(MSGT_GLOBAL, MSGL_WARN, "ass_read_file(%s): fseek failed\n", fname); | |
866 fclose(fp); | |
867 return 0; | |
868 } | |
869 | |
870 sz = ftell(fp); | |
871 rewind(fp); | |
872 | |
873 if (sz > 10*1024*1024) { | |
874 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ass_read_file(%s): Refusing to load subtitles larger than 10M\n", fname); | |
875 fclose(fp); | |
876 return 0; | |
877 } | |
878 | |
879 mp_msg(MSGT_GLOBAL, MSGL_V, "file size: %ld\n", sz); | |
880 | |
881 buf = malloc(sz + 1); | |
882 assert(buf); | |
883 bytes_read = 0; | |
884 do { | |
885 res = fread(buf + bytes_read, 1, sz - bytes_read, fp); | |
886 if (res <= 0) { | |
887 mp_msg(MSGT_GLOBAL, MSGL_INFO, "Read failed, %d: %s\n", errno, strerror(errno)); | |
888 fclose(fp); | |
889 free(buf); | |
890 return 0; | |
891 } | |
892 bytes_read += res; | |
893 } while (sz - bytes_read > 0); | |
894 buf[sz] = '\0'; | |
895 fclose(fp); | |
896 | |
897 #ifdef USE_ICONV | |
898 if (sub_cp) { | |
899 char* tmpbuf = sub_recode(buf, sz); | |
900 free(buf); | |
901 buf = tmpbuf; | |
902 } | |
903 #endif | |
19652
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
904 return buf; |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
905 } |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
906 |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
907 /** |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
908 * \brief Read subtitles from file. |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
909 * \param fname file name |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
910 * \return newly allocated track |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
911 */ |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
912 ass_track_t* ass_read_file(char* fname) |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
913 { |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
914 char* buf; |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
915 ass_track_t* track; |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
916 |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
917 buf = read_file(fname); |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
918 if (!buf) |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
919 return 0; |
18937 | 920 |
921 track = ass_new_track(); | |
922 track->name = strdup(fname); | |
923 | |
924 // process header | |
19492 | 925 process_text(track, buf); |
926 | |
927 // there is no explicit end-of-font marker in ssa/ass | |
928 if (track->parser_priv->fontname) | |
929 decode_font(track); | |
930 | |
18937 | 931 free(buf); |
932 | |
19492 | 933 if (track->track_type == TRACK_TYPE_UNKNOWN) { |
18937 | 934 ass_free_track(track); |
935 return 0; | |
936 } | |
937 | |
19495 | 938 process_force_style(track); |
939 | |
18937 | 940 mp_msg(MSGT_GLOBAL, MSGL_INFO, "LIBASS: added subtitle file: %s (%d styles, %d events)\n", fname, track->n_styles, track->n_events); |
941 | |
942 // dump_events(forced_tid); | |
943 return track; | |
944 } | |
945 | |
19652
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
946 /** |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
947 * \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:
19639
diff
changeset
|
948 */ |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
949 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:
19639
diff
changeset
|
950 { |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
951 char* buf; |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
952 parser_state_t old_state; |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
953 |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
954 buf = read_file(fname); |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
955 if (!buf) |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
956 return 1; |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
957 |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
958 old_state = track->parser_priv->state; |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
959 track->parser_priv->state = PST_STYLES; |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
960 process_text(track, buf); |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
961 track->parser_priv->state = old_state; |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
962 |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
963 return 0; |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
964 } |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19639
diff
changeset
|
965 |
18937 | 966 static char* validate_fname(char* name) |
967 { | |
968 char* fname; | |
969 char* p; | |
970 char* q; | |
971 unsigned code; | |
972 int sz = strlen(name); | |
973 | |
974 q = fname = malloc(sz + 1); | |
975 p = name; | |
976 while (*p) { | |
977 code = utf8_get_char(&p); | |
978 if (code == 0) | |
979 break; | |
980 if ( (code > 0x7F) || | |
981 (code == '\\') || | |
982 (code == '/') || | |
983 (code == ':') || | |
984 (code == '*') || | |
985 (code == '?') || | |
986 (code == '<') || | |
987 (code == '>') || | |
988 (code == '|') || | |
989 (code == 0)) | |
990 { | |
991 *q++ = '_'; | |
992 } else { | |
993 *q++ = code; | |
994 } | |
995 if (p - name > sz) | |
996 break; | |
997 } | |
998 *q = 0; | |
999 return fname; | |
1000 } | |
1001 | |
1002 /** | |
1003 * \brief Process embedded matroska font. Saves it to ~/.mplayer/fonts. | |
1004 * \param name attachment name | |
1005 * \param data binary font data | |
1006 * \param data_size data size | |
1007 */ | |
1008 void ass_process_font(const char* name, char* data, int data_size) | |
1009 { | |
1010 char buf[1000]; | |
1011 FILE* fp = 0; | |
1012 int rc; | |
1013 struct stat st; | |
1014 char* fname; | |
1015 | |
1016 char* fonts_dir = get_path("fonts"); | |
1017 rc = stat(fonts_dir, &st); | |
1018 if (rc) { | |
1019 int res; | |
1020 #ifndef __MINGW32__ | |
1021 res = mkdir(fonts_dir, 0700); | |
1022 #else | |
1023 res = mkdir(fonts_dir); | |
1024 #endif | |
1025 if (res) { | |
1026 mp_msg(MSGT_GLOBAL, MSGL_WARN, "Failed to create: %s\n", fonts_dir); | |
1027 } | |
1028 } else if (!S_ISDIR(st.st_mode)) { | |
1029 mp_msg(MSGT_GLOBAL, MSGL_WARN, "Not a directory: %s\n", fonts_dir); | |
1030 } | |
1031 | |
1032 fname = validate_fname((char*)name); | |
1033 | |
1034 snprintf(buf, 1000, "%s/%s", fonts_dir, fname); | |
1035 free(fname); | |
1036 free(fonts_dir); | |
1037 | |
1038 fp = fopen(buf, "wb"); | |
1039 if (!fp) return; | |
1040 | |
1041 fwrite(data, data_size, 1, fp); | |
1042 fclose(fp); | |
1043 } | |
1044 | |
1045 long long ass_step_sub(ass_track_t* track, long long now, int movement) { | |
1046 int i; | |
1047 | |
1048 if (movement == 0) return 0; | |
1049 if (track->n_events == 0) return 0; | |
1050 | |
1051 if (movement < 0) | |
1052 for (i = 0; (i < track->n_events) && ((long long)(track->events[i].Start + track->events[i].Duration) <= now); ++i) {} | |
1053 else | |
1054 for (i = track->n_events - 1; (i >= 0) && ((long long)(track->events[i].Start) > now); --i) {} | |
1055 | |
1056 // -1 and n_events are ok | |
1057 assert(i >= -1); assert(i <= track->n_events); | |
1058 i += movement; | |
1059 if (i < 0) i = 0; | |
1060 if (i >= track->n_events) i = track->n_events - 1; | |
1061 return ((long long)track->events[i].Start) - now; | |
1062 } | |
1063 | |
1064 ass_track_t* ass_new_track(void) { | |
1065 ass_track_t* track = calloc(1, sizeof(ass_track_t)); | |
19492 | 1066 track->parser_priv = calloc(1, sizeof(parser_priv_t)); |
18937 | 1067 return track; |
1068 } | |
1069 |