34 return rgba[0] | rgba[1] << 8 | rgba[2] << 16;
51 const char *
in,
int x1,
int y1,
int x2,
int y2)
53 char *param,
buffer[128], tmp[128];
54 int len, tag_close, sptr = 1, line_start = 1, an = 0,
end = 0;
62 if (x1 >= 0 && y1 >= 0) {
63 if (x2 >= 0 && y2 >= 0 && (x2 != x1 || y2 != y1))
65 "{\\an1}{\\move(%d,%d,%d,%d)}", x1, y1, x2, y2);
67 snprintf(out, out_end-out,
"{\\an1}{\\pos(%d,%d)}", x1, y1);
71 for (; out < out_end && !
end && *
in; in++) {
80 while (out[-1] ==
' ')
83 if(out<out_end) out += strlen(out);
93 an += sscanf(in,
"{\\an%*1u}%n", &len) >= 0 && len > 0;
94 if ((an != 1 && (len = 0, sscanf(in,
"{\\%*[^}]}%n", &len) >= 0 && len > 0)) ||
95 (len = 0, sscanf(in,
"{%*1[CcFfoPSsYy]:%*[^}]}%n", &len) >= 0 && len > 0)) {
101 tag_close = in[1] ==
'/';
103 if (sscanf(in+tag_close+1,
"%127[^>]>%n", buffer, &len) >= 1 && len > 0) {
104 if ((param = strchr(buffer,
' ')))
107 ( tag_close && sptr > 0 && !strcmp(stack[sptr-1].
tag, buffer))) {
108 int i, j, unknown = 0;
109 in += len + tag_close;
111 memset(stack+sptr, 0,
sizeof(*stack));
112 if (!strcmp(buffer,
"font")) {
115 if (stack[sptr-1].param[i][0])
116 for (j=sptr-2; j>=0; j--)
117 if (stack[j].param[i][0]) {
119 "%s", stack[j].param[i]);
120 if(out<out_end) out += strlen(out);
125 if (!strncmp(param,
"size=", 5)) {
127 param += 5 + (param[5] ==
'"');
128 if (sscanf(param,
"%u", &font_size) == 1) {
129 snprintf(stack[sptr].param[PARAM_SIZE],
130 sizeof(stack[0].param[PARAM_SIZE]),
131 "{\\fs%u}", font_size);
133 }
else if (!strncmp(param,
"color=", 6)) {
134 param += 6 + (param[6] ==
'"');
135 snprintf(stack[sptr].param[PARAM_COLOR],
136 sizeof(stack[0].param[PARAM_COLOR]),
139 }
else if (!strncmp(param,
"face=", 5)) {
140 param += 5 + (param[5] ==
'"');
142 param[-1] ==
'"' ?
"\"" :
" ");
144 FFMIN(
sizeof(tmp), len+1));
146 snprintf(stack[sptr].param[PARAM_FACE],
147 sizeof(stack[0].param[PARAM_FACE]),
150 if ((param = strchr(param,
' ')))
154 if (stack[sptr].param[i][0]) {
156 "%s", stack[sptr].param[i]);
157 if(out<out_end) out += strlen(out);
160 }
else if (!buffer[1] && strspn(buffer,
"bisu") == 1) {
162 "{\\%c%d}", buffer[0], !tag_close);
163 if(out<out_end) out += strlen(out);
166 snprintf(tmp,
sizeof(tmp),
"</%s>", buffer);
170 }
else if (unknown && !strstr(in, tmp)) {
171 in -= len + tag_close;
175 sizeof(stack[0].
tag));
183 if (*in !=
' ' && *in !=
'\r' && *in !=
'\n')
187 out =
FFMIN(out, out_end-3);
188 while (!strncmp(out-2,
"\\N", 2))
190 while (out[-1] ==
' ')
196 static const char *
read_ts(
const char *
buf,
int *ts_start,
int *ts_end,
197 int *x1,
int *y1,
int *x2,
int *y2)
199 int i, hs, ms, ss, he,
me, se;
201 for (i=0; i<2; i++) {
203 int c = sscanf(buf,
"%d:%2d:%2d%*1[,.]%3d --> %d:%2d:%2d%*1[,.]%3d"
204 "%*[ ]X1:%u X2:%u Y1:%u Y2:%u",
205 &hs, &ms, &ss, ts_start, &he, &me, &se, ts_end,
207 buf += strcspn(buf,
"\n") + 1;
209 *ts_start = 100*(ss + 60*(ms + 60*hs)) + *ts_start/10;
210 *ts_end = 100*(se + 60*(me + 60*he)) + *ts_end /10;
221 int ts_start, ts_end, x1 = -1, y1 = -1, x2 = -1, y2 = -1;
223 const char *ptr = avpkt->
data;
228 if (p && size == 16) {
235 if (avpkt->
size <= 0)
238 while (ptr < end && *ptr) {
240 ptr =
read_ts(ptr, &ts_start, &ts_end, &x1, &y1, &x2, &y2);
257 *got_sub_ptr = sub->num_rects > 0;
261 #if CONFIG_SRT_DECODER
273 #if CONFIG_SUBRIP_DECODER