Mercurial > mplayer.hg
annotate libass/ass_mp.c @ 19867:7110631d6601
Reword the font section to be a bit more descriptive.
author | diego |
---|---|
date | Sun, 17 Sep 2006 14:58:00 +0000 |
parents | ae983f0a1cac |
children | fa122b7c71c6 |
rev | line source |
---|---|
19405 | 1 #include <inttypes.h> |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
2 #include <string.h> |
19484
6eb79b2384f8
use of malloc without prototype.. very bad on 64bit archs
rfelker
parents:
19405
diff
changeset
|
3 #include <stdlib.h> |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
4 |
19643
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
5 #include "mp_msg.h" |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
6 |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
7 #include "ass.h" |
19646 | 8 #include "ass_utils.h" |
18937 | 9 #include "ass_mp.h" |
10 | |
11 // libass-related command line options | |
12 int ass_enabled = 0; | |
13 float ass_font_scale = 1.; | |
14 float ass_line_spacing = 0.; | |
15 int ass_top_margin = 0; | |
16 int ass_bottom_margin = 0; | |
17 int extract_embedded_fonts = 0; | |
19495 | 18 char **ass_force_style_list = NULL; |
19563 | 19 int ass_use_margins = 0; |
19646 | 20 char* ass_color = NULL; |
21 char* ass_border_color = NULL; | |
19652
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19646
diff
changeset
|
22 char* ass_styles_file = NULL; |
18937 | 23 |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
24 extern int font_fontconfig; |
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
25 extern char* font_name; |
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
26 extern float text_font_scale_factor; |
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
27 extern int subtitle_autoscale; |
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
28 |
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
29 extern double ass_internal_font_size_coeff; |
19584
586e7d259d05
Apply -ass-force-style also to tracks generated from subdata.
eugeni
parents:
19563
diff
changeset
|
30 extern void process_force_style(ass_track_t* track); |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
31 |
19643
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
32 ass_track_t* ass_default_track() { |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
33 ass_track_t* track = ass_new_track(); |
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
34 |
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
35 track->track_type = TRACK_TYPE_ASS; |
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
36 track->Timer = 100.; |
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
37 track->PlayResX = 384; |
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
38 track->PlayResY = 288; |
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
39 track->WrapStyle = 0; |
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
40 |
19652
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19646
diff
changeset
|
41 if (ass_styles_file) |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19646
diff
changeset
|
42 ass_read_styles(track, ass_styles_file); |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19646
diff
changeset
|
43 |
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19646
diff
changeset
|
44 if (track->n_styles == 0) { |
19653
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
45 ass_style_t* style; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
46 int sid; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
47 double fs; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
48 uint32_t c1, c2; |
19652
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19646
diff
changeset
|
49 |
19653
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
50 sid = ass_alloc_style(track); |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
51 style = track->styles + sid; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
52 style->Name = strdup("Default"); |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
53 style->FontName = (font_fontconfig && font_name) ? strdup(font_name) : strdup("Sans"); |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
54 |
19653
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
55 fs = track->PlayResY * text_font_scale_factor / 100. / ass_internal_font_size_coeff; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
56 // approximate autoscale coefficients |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
57 if (subtitle_autoscale == 2) |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
58 fs *= 1.3; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
59 else if (subtitle_autoscale == 3) |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
60 fs *= 1.4; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
61 style->FontSize = fs; |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
62 |
19653
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
63 if (ass_color) c1 = strtoll(ass_color, NULL, 16); |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
64 else c1 = 0xFFFF0000; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
65 if (ass_border_color) c2 = strtoll(ass_border_color, NULL, 16); |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
66 else c2 = 0x00000000; |
19646 | 67 |
19653
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
68 style->PrimaryColour = c1; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
69 style->SecondaryColour = c1; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
70 style->OutlineColour = c2; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
71 style->BackColour = 0x00000000; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
72 style->BorderStyle = 1; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
73 style->Alignment = 2; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
74 style->Outline = 2; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
75 style->MarginL = 30; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
76 style->MarginR = 30; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
77 style->MarginV = 20; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
78 style->ScaleX = 1.; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
79 style->ScaleY = 1.; |
19652
2c016957360a
Add -ass-styles option. It allows to load styles from a file and use them
eugeni
parents:
19646
diff
changeset
|
80 } |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
81 |
19654
ae983f0a1cac
Apply -ass-force-style also to matroska plaintext subs.
eugeni
parents:
19653
diff
changeset
|
82 process_force_style(track); |
19643
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
83 return track; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
84 } |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
85 |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
86 static int check_duplicate_plaintext_event(ass_track_t* track) |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
87 { |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
88 int i; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
89 ass_event_t* evt = track->events + track->n_events - 1; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
90 |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
91 for (i = 0; i<track->n_events - 1; ++i) // ignoring last event, it is the one we are comparing with |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
92 if (track->events[i].Start == evt->Start && |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
93 track->events[i].Duration == evt->Duration && |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
94 strcmp(track->events[i].Text, evt->Text) == 0) |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
95 return 1; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
96 return 0; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
97 } |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
98 |
19643
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
99 /** |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
100 * \brief Convert subtitle to ass_event_t for the given track |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
101 * \param ass_track_t track |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
102 * \param sub subtitle to convert |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
103 * \return event id |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
104 * note: assumes that subtitle is _not_ fps-based; caller must manually correct |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
105 * Start and Duration in other case. |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
106 **/ |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
107 int ass_process_subtitle(ass_track_t* track, subtitle* sub) |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
108 { |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
109 int eid; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
110 ass_event_t* event; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
111 int len = 0, j; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
112 char* p; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
113 char* end; |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
114 |
19643
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
115 eid = ass_alloc_event(track); |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
116 event = track->events + eid; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
117 |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
118 event->Start = sub->start * 10; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
119 event->Duration = (sub->end - sub->start) * 10; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
120 event->Style = 0; |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
121 |
19653
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
122 for (j = 0; j < sub->lines; ++j) |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
123 len += sub->text[j] ? strlen(sub->text[j]) : 0; |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
124 |
19653
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
125 len += 2 * sub->lines; // '\N', including the one after the last line |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
126 len += 6; // {\anX} |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
127 len += 1; // '\0' |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
128 |
19653
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
129 event->Text = malloc(len); |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
130 end = event->Text + len; |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
131 p = event->Text; |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
132 |
19653
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
133 if (sub->alignment) |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
134 p += snprintf(p, end - p, "{\\an%d}", sub->alignment); |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
135 |
19653
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
136 for (j = 0; j < sub->lines; ++j) |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
137 p += snprintf(p, end - p, "%s ", sub->text[j]); |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
138 |
19653
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
139 p--; // remove last ' ' |
c03c705573c1
Cosmetics: restore indentation after recent changes.
eugeni
parents:
19652
diff
changeset
|
140 *p = 0; |
19643
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
141 |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
142 if (check_duplicate_plaintext_event(track)) { |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
143 ass_free_event(track, eid); |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
144 track->n_events--; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
145 return -1; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
146 } |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
147 |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
148 mp_msg(MSGT_GLOBAL, MSGL_V, "plaintext event at %" PRId64 ", +%" PRId64 ": %s \n", |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
149 (int64_t)event->Start, (int64_t)event->Duration, event->Text); |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
150 |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
151 return eid; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
152 } |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
153 |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
154 |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
155 /** |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
156 * \brief Convert subdata to ass_track |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
157 * \param subdata subtitles struct from subreader |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
158 * \param fps video framerate |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
159 * \return newly allocated ass_track, filled with subtitles from subdata |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
160 */ |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
161 ass_track_t* ass_read_subdata(sub_data* subdata, double fps) { |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
162 ass_track_t* track; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
163 int i; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
164 |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
165 track = ass_default_track(); |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
166 track->name = subdata->filename ? strdup(subdata->filename) : 0; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
167 |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
168 for (i = 0; i < subdata->sub_num; ++i) { |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
169 int eid = ass_process_subtitle(track, subdata->subtitles + i); |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
170 if (eid < 0) |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
171 continue; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
172 if (!subdata->sub_uses_time) { |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
173 track->events[eid].Start *= 100. / fps; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
174 track->events[eid].Duration *= 100. / fps; |
f48d49b400cf
Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents:
19592
diff
changeset
|
175 } |
19401
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
176 } |
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
177 return track; |
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
178 } |
c0c3a2f8bb32
Add subdata to ass_track conversion for external subtitles.
eugeni
parents:
18937
diff
changeset
|
179 |