annotate sub/subassconvert.c @ 37195:ac6c37d85d65 default tip

configure: Fix initialization of variable def_local_aligned_32 It contiained the #define of HAVE_LOCAL_ALIGNED_16 instead of HAVE_LOCAL_ALIGNED_32.
author al
date Sun, 28 Sep 2014 18:38:41 +0000
parents 389d43c448b3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32462
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
1 /*
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
2 * Subtitles converter to SSA/ASS in order to allow special formatting
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
3 *
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
4 * This file is part of MPlayer.
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
5 *
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
6 * MPlayer is free software; you can redistribute it and/or modify
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
9 * (at your option) any later version.
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
10 *
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
11 * MPlayer is distributed in the hope that it will be useful,
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
14 * GNU General Public License for more details.
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
15 *
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License along
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
19 */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
20
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
21 #include <string.h>
35903
389d43c448b3 Add missing strings.h #includes for strcasecmp().
diego
parents: 34976
diff changeset
22 #include <strings.h>
32462
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
23 #include <stdint.h>
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
24 #include <stdlib.h>
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
25 #include <stdio.h>
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
26 #include <stdarg.h>
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
27
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
28 #include "mp_msg.h"
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
29 #include "help_mp.h"
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
30 #include "bstr.h"
32464
22888a8cb312 Do not use a path for including files in the same directory.
reimar
parents: 32462
diff changeset
31 #include "subassconvert.h"
32462
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
32 #include "libavutil/common.h"
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
33
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
34 struct line {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
35 char *buf;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
36 size_t bufsize;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
37 size_t len;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
38 };
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
39
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
40 #ifdef __GNUC__
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
41 static void append_text(struct line *dst, char *fmt, ...) __attribute__ ((format(printf, 2, 3)));
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
42 #endif
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
43
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
44 static void append_text(struct line *dst, char *fmt, ...)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
45 {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
46 va_list va;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
47 int ret;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
48
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
49 va_start(va, fmt);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
50 ret = vsnprintf(dst->buf + dst->len, dst->bufsize - dst->len, fmt, va);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
51 if (ret >= 0) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
52 dst->len += ret;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
53 if (dst->len > dst->bufsize)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
54 dst->len = dst->bufsize;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
55 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
56 va_end(va);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
57 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
58
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
59 static int indexof(const char *s, int c)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
60 {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
61 char *f = strchr(s, c);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
62 return f ? (f - s) : -1;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
63 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
64
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
65
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
66
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
67 /*
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
68 * SubRip
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
69 *
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
70 * Support basic tags (italic, bold, underline, strike-through)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
71 * and font tag with size, color and face attributes.
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
72 *
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
73 */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
74
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
75 struct font_tag {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
76 struct bstr face;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
77 int size;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
78 uint32_t color;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
79 };
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
80
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
81 static const struct tag_conv {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
82 const char *from;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
83 const char *to;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
84 } subrip_basic_tags[] = {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
85 {"<i>", "{\\i1}"}, {"</i>", "{\\i0}"},
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
86 {"<b>", "{\\b1}"}, {"</b>", "{\\b0}"},
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
87 {"<u>", "{\\u1}"}, {"</u>", "{\\u0}"},
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
88 {"<s>", "{\\s1}"}, {"</s>", "{\\s0}"},
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
89 {"{", "\\{"}, {"}", "\\}"},
34757
da38eb1e2069 subassconvert: handle "\r\n" line ends
cboesch
parents: 32464
diff changeset
90 {"\r\n", "\\N"}, {"\n", "\\N"}, {"\r", "\\N"},
32462
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
91 };
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
92
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
93 static const struct {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
94 const char *s;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
95 uint32_t v;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
96 } subrip_web_colors[] = {
34912
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
97 /* Named CSS3 colors in BGR format; a subset of those
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
98 at http://www.w3.org/TR/css3-color/#svg-color */
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
99 {"aqua", 0xffff00},
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
100 {"black", 0x000000},
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
101 {"blue", 0xff0000},
34913
69fe59abe044 Add a few new CSS colors.
cehoyos
parents: 34912
diff changeset
102 {"cyan", 0xffff00},
34912
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
103 {"fuchsia", 0xff00ff},
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
104 {"gray", 0x808080},
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
105 {"green", 0x008000},
34913
69fe59abe044 Add a few new CSS colors.
cehoyos
parents: 34912
diff changeset
106 {"grey", 0x808080},
34912
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
107 {"lime", 0x00ff00},
34913
69fe59abe044 Add a few new CSS colors.
cehoyos
parents: 34912
diff changeset
108 {"magenta", 0xff00ff},
34912
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
109 {"maroon", 0x000080},
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
110 {"navy", 0x800000},
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
111 {"olive", 0x008080},
34913
69fe59abe044 Add a few new CSS colors.
cehoyos
parents: 34912
diff changeset
112 {"orange", 0x00a5ff},
69fe59abe044 Add a few new CSS colors.
cehoyos
parents: 34912
diff changeset
113 {"pink", 0xcbc0ff},
34912
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
114 {"purple", 0x800080},
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
115 {"red", 0x0000ff},
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
116 {"silver", 0xc0c0c0},
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
117 {"teal", 0x808000},
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
118 {"white", 0xffffff},
3f8886645ebd Order colour names alphabetically / better match W3 list.
cehoyos
parents: 34758
diff changeset
119 {"yellow", 0x00ffff},
32462
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
120 };
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
121
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
122 #define SUBRIP_MAX_STACKED_FONT_TAGS 16
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
123 #define SUBRIP_FLAG_COLOR 0x01000000
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
124
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
125 /**
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
126 * \brief Convert SubRip lines into ASS markup
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
127 * \param orig original SubRip lines. The content will remain untouched.
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
128 * \param dest ASS markup destination buffer.
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
129 * \param dest_buffer_size maximum size for the destination buffer.
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
130 */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
131 void subassconvert_subrip(const char *orig, char *dest, size_t dest_buffer_size)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
132 {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
133 /* line is not const to avoid warnings with strtol, etc.
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
134 * orig content won't be changed */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
135 char *line = (char *)orig;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
136 struct line new_line = {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
137 .buf = dest,
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
138 .bufsize = dest_buffer_size,
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
139 };
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
140 struct font_tag font_stack[SUBRIP_MAX_STACKED_FONT_TAGS];
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
141 int sp = 0;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
142
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
143 font_stack[0] = (struct font_tag){}; // type with all defaults
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
144 while (*line && new_line.len < new_line.bufsize - 1) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
145 char *orig_line = line;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
146 int i;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
147
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
148 for (i = 0; i < FF_ARRAY_ELEMS(subrip_basic_tags); i++) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
149 const struct tag_conv *tag = &subrip_basic_tags[i];
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
150 int from_len = strlen(tag->from);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
151 if (strncmp(line, tag->from, from_len) == 0) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
152 append_text(&new_line, "%s", tag->to);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
153 line += from_len;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
154 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
155 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
156
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
157 if (strncmp(line, "</font>", 7) == 0) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
158 /* Closing font tag */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
159 line += 7;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
160
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
161 if (sp > 0) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
162 struct font_tag *tag = &font_stack[sp];
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
163 struct font_tag *last_tag = &tag[-1];
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
164 sp--;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
165
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
166 if (tag->size) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
167 if (!last_tag->size)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
168 append_text(&new_line, "{\\fs}");
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
169 else if (last_tag->size != tag->size)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
170 append_text(&new_line, "{\\fs%d}", last_tag->size);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
171 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
172
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
173 if (tag->color & SUBRIP_FLAG_COLOR) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
174 if (!(last_tag->color & SUBRIP_FLAG_COLOR))
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
175 append_text(&new_line, "{\\c}");
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
176 else if (last_tag->color != tag->color)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
177 append_text(&new_line, "{\\c&H%06X&}",
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
178 last_tag->color & 0xffffff);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
179 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
180
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
181 if (tag->face.len) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
182 if (!last_tag->face.len)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
183 append_text(&new_line, "{\\fn}");
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
184 else if (bstrcmp(last_tag->face, tag->face) != 0)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
185 append_text(&new_line, "{\\fn%.*s}",
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
186 BSTR_P(last_tag->face));
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
187 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
188 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
189 } else if (strncmp(line, "<font ", 6) == 0
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
190 && sp + 1 < FF_ARRAY_ELEMS(font_stack)) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
191 /* Opening font tag */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
192 char *potential_font_tag_start = line;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
193 int len_backup = new_line.len;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
194 struct font_tag *tag = &font_stack[sp + 1];
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
195 int has_valid_attr = 0;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
196
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
197 *tag = tag[-1]; // keep values from previous tag
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
198 line += 6;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
199
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
200 while (*line && *line != '>') {
34976
482418e9e922 subassconvert: better handling of invalid SubRip tag attributes.
cboesch
parents: 34913
diff changeset
201 if (strncmp(line, "size=", 5) == 0) {
482418e9e922 subassconvert: better handling of invalid SubRip tag attributes.
cboesch
parents: 34913
diff changeset
202 line += 5;
482418e9e922 subassconvert: better handling of invalid SubRip tag attributes.
cboesch
parents: 34913
diff changeset
203 if (*line == '"') line++;
32462
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
204 tag->size = strtol(line, &line, 10);
34976
482418e9e922 subassconvert: better handling of invalid SubRip tag attributes.
cboesch
parents: 34913
diff changeset
205 if (!tag->size)
32462
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
206 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
207 append_text(&new_line, "{\\fs%d}", tag->size);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
208 has_valid_attr = 1;
34976
482418e9e922 subassconvert: better handling of invalid SubRip tag attributes.
cboesch
parents: 34913
diff changeset
209 } else if (strncmp(line, "color=", 6) == 0) {
482418e9e922 subassconvert: better handling of invalid SubRip tag attributes.
cboesch
parents: 34913
diff changeset
210 line += 6;
482418e9e922 subassconvert: better handling of invalid SubRip tag attributes.
cboesch
parents: 34913
diff changeset
211 if (*line == '"') line++;
32462
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
212 if (*line == '#') {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
213 // #RRGGBB format
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
214 line++;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
215 tag->color = strtol(line, &line, 16) & 0x00ffffff;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
216 tag->color = ((tag->color & 0xff) << 16) |
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
217 (tag->color & 0xff00) |
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
218 ((tag->color & 0xff0000) >> 16) |
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
219 SUBRIP_FLAG_COLOR;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
220 } else {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
221 // Standard web colors
34976
482418e9e922 subassconvert: better handling of invalid SubRip tag attributes.
cboesch
parents: 34913
diff changeset
222 int i;
32462
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
223 for (i = 0; i < FF_ARRAY_ELEMS(subrip_web_colors); i++) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
224 const char *color = subrip_web_colors[i].s;
34976
482418e9e922 subassconvert: better handling of invalid SubRip tag attributes.
cboesch
parents: 34913
diff changeset
225 const int len = strlen(color);
482418e9e922 subassconvert: better handling of invalid SubRip tag attributes.
cboesch
parents: 34913
diff changeset
226 if (strncasecmp(line, color, len) == 0) {
32462
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
227 tag->color = SUBRIP_FLAG_COLOR | subrip_web_colors[i].v;
34976
482418e9e922 subassconvert: better handling of invalid SubRip tag attributes.
cboesch
parents: 34913
diff changeset
228 line += len;
32462
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
229 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
230 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
231 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
232
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
233 if (i == FF_ARRAY_ELEMS(subrip_web_colors)) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
234 /* We didn't find any matching color */
34976
482418e9e922 subassconvert: better handling of invalid SubRip tag attributes.
cboesch
parents: 34913
diff changeset
235 line += strcspn(line, "\" >");
32462
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
236 mp_msg(MSGT_SUBREADER, MSGL_WARN,
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
237 MSGTR_SUBTITLES_SubRip_UnknownFontColor, orig);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
238 append_text(&new_line, "{\\c}");
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
239 continue;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
240 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
241 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
242 append_text(&new_line, "{\\c&H%06X&}", tag->color & 0xffffff);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
243 has_valid_attr = 1;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
244 } else if (strncmp(line, "face=\"", 6) == 0) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
245 /* Font face attribute */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
246 int len;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
247 line += 6;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
248 len = indexof(line, '"');
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
249 if (len <= 0)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
250 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
251 tag->face.start = line;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
252 tag->face.len = len;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
253 line += len;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
254 append_text(&new_line, "{\\fn%.*s}", BSTR_P(tag->face));
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
255 has_valid_attr = 1;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
256 }
34976
482418e9e922 subassconvert: better handling of invalid SubRip tag attributes.
cboesch
parents: 34913
diff changeset
257 if (*line != '>')
482418e9e922 subassconvert: better handling of invalid SubRip tag attributes.
cboesch
parents: 34913
diff changeset
258 line++;
32462
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
259 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
260
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
261 if (!has_valid_attr || *line != '>') { /* Not valid font tag */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
262 line = potential_font_tag_start;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
263 new_line.len = len_backup;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
264 } else {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
265 sp++;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
266 line++;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
267 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
268 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
269
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
270 /* Tag conversion code didn't match */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
271 if (line == orig_line)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
272 new_line.buf[new_line.len++] = *line++;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
273 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
274 new_line.buf[new_line.len] = 0;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
275 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
276
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
277
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
278 /*
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
279 * MicroDVD
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
280 *
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
281 * Based on the specifications found here:
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
282 * https://trac.videolan.org/vlc/ticket/1825#comment:6
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
283 */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
284
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
285 struct microdvd_tag {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
286 char key;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
287 int persistent;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
288 uint32_t data1;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
289 uint32_t data2;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
290 struct bstr data_string;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
291 };
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
292
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
293 #define MICRODVD_PERSISTENT_OFF 0
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
294 #define MICRODVD_PERSISTENT_ON 1
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
295 #define MICRODVD_PERSISTENT_OPENED 2
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
296
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
297 // Color, Font, Size, cHarset, stYle, Position, cOordinate
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
298 #define MICRODVD_TAGS "cfshyYpo"
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
299
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
300 static void microdvd_set_tag(struct microdvd_tag *tags, struct microdvd_tag tag)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
301 {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
302 int tag_index = indexof(MICRODVD_TAGS, tag.key);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
303
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
304 if (tag_index < 0)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
305 return;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
306 memcpy(&tags[tag_index], &tag, sizeof(tag));
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
307 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
308
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
309 // italic, bold, underline, strike-through
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
310 #define MICRODVD_STYLES "ibus"
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
311
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
312 static char *microdvd_load_tags(struct microdvd_tag *tags, char *s)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
313 {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
314 while (*s == '{') {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
315 char *start = s;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
316 char tag_char = *(s + 1);
34758
e301516e3c83 subassconvert: use standard struct zero init.
cboesch
parents: 34757
diff changeset
317 struct microdvd_tag tag = {0};
32462
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
318
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
319 if (!tag_char || *(s + 2) != ':')
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
320 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
321 s += 3;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
322
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
323 switch (tag_char) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
324
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
325 /* Style */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
326 case 'Y':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
327 tag.persistent = MICRODVD_PERSISTENT_ON;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
328 case 'y':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
329 while (*s && *s != '}') {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
330 int style_index = indexof(MICRODVD_STYLES, *s);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
331
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
332 if (style_index >= 0)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
333 tag.data1 |= (1 << style_index);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
334 s++;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
335 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
336 if (*s != '}')
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
337 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
338 /* We must distinguish persistent and non-persistent styles
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
339 * to handle this kind of style tags: {y:ib}{Y:us} */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
340 tag.key = tag_char;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
341 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
342
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
343 /* Color */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
344 case 'C':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
345 tag.persistent = MICRODVD_PERSISTENT_ON;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
346 case 'c':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
347 tag.data1 = strtol(s, &s, 16) & 0x00ffffff;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
348 if (*s != '}')
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
349 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
350 tag.key = 'c';
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
351 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
352
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
353 /* Font name */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
354 case 'F':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
355 tag.persistent = MICRODVD_PERSISTENT_ON;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
356 case 'f':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
357 {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
358 int len = indexof(s, '}');
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
359 if (len < 0)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
360 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
361 tag.data_string.start = s;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
362 tag.data_string.len = len;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
363 s += len;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
364 tag.key = 'f';
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
365 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
366 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
367
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
368 /* Font size */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
369 case 'S':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
370 tag.persistent = MICRODVD_PERSISTENT_ON;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
371 case 's':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
372 tag.data1 = strtol(s, &s, 10);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
373 if (*s != '}')
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
374 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
375 tag.key = 's';
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
376 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
377
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
378 /* Charset */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
379 case 'H':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
380 {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
381 //TODO: not yet handled, just parsed.
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
382 int len = indexof(s, '}');
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
383 if (len < 0)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
384 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
385 tag.data_string.start = s;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
386 tag.data_string.len = len;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
387 s += len;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
388 tag.key = 'h';
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
389 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
390 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
391
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
392 /* Position */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
393 case 'P':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
394 tag.persistent = MICRODVD_PERSISTENT_ON;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
395 tag.data1 = (*s++ == '1');
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
396 if (*s != '}')
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
397 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
398 tag.key = 'p';
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
399 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
400
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
401 /* Coordinates */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
402 case 'o':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
403 tag.persistent = MICRODVD_PERSISTENT_ON;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
404 tag.data1 = strtol(s, &s, 10);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
405 if (*s != ',')
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
406 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
407 s++;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
408 tag.data2 = strtol(s, &s, 10);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
409 if (*s != '}')
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
410 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
411 tag.key = 'o';
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
412 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
413
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
414 default: /* Unknown tag, we consider it's text */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
415 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
416 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
417
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
418 if (tag.key == 0)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
419 return start;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
420
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
421 microdvd_set_tag(tags, tag);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
422 s++;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
423 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
424 return s;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
425 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
426
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
427 static void microdvd_open_tags(struct line *new_line, struct microdvd_tag *tags)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
428 {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
429 int i, sidx;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
430 for (i = 0; i < sizeof(MICRODVD_TAGS) - 1; i++) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
431 if (tags[i].persistent == MICRODVD_PERSISTENT_OPENED)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
432 continue;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
433 switch (tags[i].key) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
434 case 'Y':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
435 case 'y':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
436 for (sidx = 0; sidx < sizeof(MICRODVD_STYLES) - 1; sidx++)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
437 if (tags[i].data1 & (1 << sidx))
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
438 append_text(new_line, "{\\%c1}", MICRODVD_STYLES[sidx]);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
439 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
440
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
441 case 'c':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
442 append_text(new_line, "{\\c&H%06X&}", tags[i].data1);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
443 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
444
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
445 case 'f':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
446 append_text(new_line, "{\\fn%.*s}", BSTR_P(tags[i].data_string));
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
447 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
448
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
449 case 's':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
450 append_text(new_line, "{\\fs%d}", tags[i].data1);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
451 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
452
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
453 case 'p':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
454 if (tags[i].data1 == 0)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
455 append_text(new_line, "{\\an8}");
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
456 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
457
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
458 case 'o':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
459 append_text(new_line, "{\\pos(%d,%d)}",
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
460 tags[i].data1, tags[i].data2);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
461 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
462 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
463 if (tags[i].persistent == MICRODVD_PERSISTENT_ON)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
464 tags[i].persistent = MICRODVD_PERSISTENT_OPENED;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
465 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
466 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
467
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
468 static void microdvd_close_no_persistent_tags(struct line *new_line,
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
469 struct microdvd_tag *tags)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
470 {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
471 int i, sidx;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
472
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
473 for (i = sizeof(MICRODVD_TAGS) - 2; i; i--) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
474 if (tags[i].persistent != MICRODVD_PERSISTENT_OFF)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
475 continue;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
476 switch (tags[i].key) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
477
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
478 case 'y':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
479 for (sidx = sizeof(MICRODVD_STYLES) - 2; sidx >= 0; sidx--)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
480 if (tags[i].data1 & (1 << sidx))
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
481 append_text(new_line, "{\\%c0}", MICRODVD_STYLES[sidx]);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
482 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
483
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
484 case 'c':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
485 append_text(new_line, "{\\c}");
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
486 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
487
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
488 case 'f':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
489 append_text(new_line, "{\\fn}");
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
490 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
491
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
492 case 's':
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
493 append_text(new_line, "{\\fs}");
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
494 break;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
495 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
496 tags[i].key = 0;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
497 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
498 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
499
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
500 /**
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
501 * \brief Convert MicroDVD lines into ASS markup
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
502 * \param orig original MicroDVD line. The content will remain untouched.
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
503 * \param dest ASS markup destination buffer.
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
504 * \param dest_buffer_size maximum size for the destination buffer.
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
505 */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
506 void subassconvert_microdvd(const char *orig, char *dest, size_t dest_buffer_size)
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
507 {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
508 /* line is not const to avoid warnings with strtol, etc.
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
509 * orig content won't be changed */
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
510 char *line = (char *)orig;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
511 struct line new_line = {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
512 .buf = dest,
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
513 .bufsize = dest_buffer_size,
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
514 };
34758
e301516e3c83 subassconvert: use standard struct zero init.
cboesch
parents: 34757
diff changeset
515 struct microdvd_tag tags[sizeof(MICRODVD_TAGS) - 1] = {{0}};
32462
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
516
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
517 while (*line) {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
518 line = microdvd_load_tags(tags, line);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
519 microdvd_open_tags(&new_line, tags);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
520
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
521 while (*line && *line != '|')
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
522 new_line.buf[new_line.len++] = *line++;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
523
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
524 if (*line == '|') {
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
525 microdvd_close_no_persistent_tags(&new_line, tags);
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
526 append_text(&new_line, "\\N");
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
527 line++;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
528 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
529 }
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
530 new_line.buf[new_line.len] = 0;
6e7c20b56c89 Move subassconvert.[ch] to the sub directory.
cigaes
parents:
diff changeset
531 }