34 return rgba[0] | rgba[1] << 8 | rgba[2] << 16;
52 while (buf->len > 0 && buf->str[buf->len - 1] ==
' ')
53 buf->str[--buf->len] = 0;
57 const char *
in,
int x1,
int y1,
int x2,
int y2)
59 char *param,
buffer[128], tmp[128];
60 int len, tag_close, sptr = 1, line_start = 1, an = 0,
end = 0;
68 if (x1 >= 0 && y1 >= 0) {
69 if (x2 >= 0 && y2 >= 0 && (x2 != x1 || y2 != y1))
70 av_bprintf(dst,
"{\\an1}{\\move(%d,%d,%d,%d)}", x1, y1, x2, y2);
72 av_bprintf(dst,
"{\\an1}{\\pos(%d,%d)}", x1, y1);
75 for (; !
end && *
in; in++) {
95 an += sscanf(in,
"{\\an%*1u}%n", &len) >= 0 && len > 0;
96 if ((an != 1 && (len = 0, sscanf(in,
"{\\%*[^}]}%n", &len) >= 0 && len > 0)) ||
97 (len = 0, sscanf(in,
"{%*1[CcFfoPSsYy]:%*[^}]}%n", &len) >= 0 && len > 0)) {
103 tag_close = in[1] ==
'/';
105 if (sscanf(in+tag_close+1,
"%127[^>]>%n", buffer, &len) >= 1 && len > 0) {
106 if ((param = strchr(buffer,
' ')))
109 ( tag_close && sptr > 0 && !strcmp(stack[sptr-1].
tag, buffer))) {
110 int i, j, unknown = 0;
111 in += len + tag_close;
113 memset(stack+sptr, 0,
sizeof(*stack));
114 if (!strcmp(buffer,
"font")) {
117 if (stack[sptr-1].param[i][0])
118 for (j=sptr-2; j>=0; j--)
119 if (stack[j].param[i][0]) {
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])
157 }
else if (!buffer[1] && strspn(buffer,
"bisu") == 1) {
158 av_bprintf(dst,
"{\\%c%d}", buffer[0], !tag_close);
161 snprintf(tmp,
sizeof(tmp),
"</%s>", buffer);
165 }
else if (unknown && !strstr(in, tmp)) {
166 in -= len + tag_close;
170 sizeof(stack[0].
tag));
178 if (*in !=
' ' && *in !=
'\r' && *in !=
'\n')
182 while (dst->len >= 2 && !strncmp(&dst->str[dst->len - 2],
"\\N", 2))
184 dst->str[dst->len] = 0;
193 int ts_start, ts_end, x1 = -1, y1 = -1, x2 = -1, y2 = -1;
197 if (p && size == 16) {
204 if (avpkt->
size <= 0)
224 *got_sub_ptr = sub->num_rects > 0;
228 #if CONFIG_SRT_DECODER
240 #if CONFIG_SUBRIP_DECODER