mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-27 17:21:05 +00:00
libavcodec/htmlsubtitles.c: make tags case-insensitive
Signed-off-by: DongHoon Kang <nanuda.kang@gmail.com> Signed-off-by: Clément Bœsch <u@pkh.me>
This commit is contained in:
parent
1af615683e
commit
db8f615d68
@ -117,12 +117,12 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)
|
|||||||
if ((param = strchr(tagname, ' ')))
|
if ((param = strchr(tagname, ' ')))
|
||||||
*param++ = 0;
|
*param++ = 0;
|
||||||
if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||
|
if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||
|
||||||
( tag_close && sptr > 0 && !strcmp(stack[sptr-1].tag, tagname))) {
|
( tag_close && sptr > 0 && !av_strcasecmp(stack[sptr-1].tag, tagname))) {
|
||||||
int i, j, unknown = 0;
|
int i, j, unknown = 0;
|
||||||
in += len + tag_close;
|
in += len + tag_close;
|
||||||
if (!tag_close)
|
if (!tag_close)
|
||||||
memset(stack+sptr, 0, sizeof(*stack));
|
memset(stack+sptr, 0, sizeof(*stack));
|
||||||
if (!strcmp(tagname, "font")) {
|
if (!av_strcasecmp(tagname, "font")) {
|
||||||
if (tag_close) {
|
if (tag_close) {
|
||||||
for (i=PARAM_NUMBER-1; i>=0; i--)
|
for (i=PARAM_NUMBER-1; i>=0; i--)
|
||||||
if (stack[sptr-1].param[i][0])
|
if (stack[sptr-1].param[i][0])
|
||||||
@ -133,7 +133,7 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (param) {
|
while (param) {
|
||||||
if (!strncmp(param, "size=", 5)) {
|
if (!av_strncasecmp(param, "size=", 5)) {
|
||||||
unsigned font_size;
|
unsigned font_size;
|
||||||
param += 5 + (param[5] == '"');
|
param += 5 + (param[5] == '"');
|
||||||
if (sscanf(param, "%u", &font_size) == 1) {
|
if (sscanf(param, "%u", &font_size) == 1) {
|
||||||
@ -141,13 +141,13 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)
|
|||||||
sizeof(stack[0].param[PARAM_SIZE]),
|
sizeof(stack[0].param[PARAM_SIZE]),
|
||||||
"{\\fs%u}", font_size);
|
"{\\fs%u}", font_size);
|
||||||
}
|
}
|
||||||
} else if (!strncmp(param, "color=", 6)) {
|
} else if (!av_strncasecmp(param, "color=", 6)) {
|
||||||
param += 6 + (param[6] == '"');
|
param += 6 + (param[6] == '"');
|
||||||
snprintf(stack[sptr].param[PARAM_COLOR],
|
snprintf(stack[sptr].param[PARAM_COLOR],
|
||||||
sizeof(stack[0].param[PARAM_COLOR]),
|
sizeof(stack[0].param[PARAM_COLOR]),
|
||||||
"{\\c&H%X&}",
|
"{\\c&H%X&}",
|
||||||
html_color_parse(log_ctx, param));
|
html_color_parse(log_ctx, param));
|
||||||
} else if (!strncmp(param, "face=", 5)) {
|
} else if (!av_strncasecmp(param, "face=", 5)) {
|
||||||
param += 5 + (param[5] == '"');
|
param += 5 + (param[5] == '"');
|
||||||
len = strcspn(param,
|
len = strcspn(param,
|
||||||
param[-1] == '"' ? "\"" :" ");
|
param[-1] == '"' ? "\"" :" ");
|
||||||
@ -165,9 +165,9 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)
|
|||||||
if (stack[sptr].param[i][0])
|
if (stack[sptr].param[i][0])
|
||||||
av_bprintf(dst, "%s", stack[sptr].param[i]);
|
av_bprintf(dst, "%s", stack[sptr].param[i]);
|
||||||
}
|
}
|
||||||
} else if (tagname[0] && !tagname[1] && strspn(tagname, "bisu") == 1) {
|
} else if (tagname[0] && !tagname[1] && av_stristr("bisu", tagname)) {
|
||||||
av_bprintf(dst, "{\\%c%d}", tagname[0], !tag_close);
|
av_bprintf(dst, "{\\%c%d}", (char)av_tolower(tagname[0]), !tag_close);
|
||||||
} else if (!strcmp(tagname, "br")) {
|
} else if (!av_strcasecmp(tagname, "br")) {
|
||||||
av_bprintf(dst, "\\N");
|
av_bprintf(dst, "\\N");
|
||||||
} else {
|
} else {
|
||||||
unknown = 1;
|
unknown = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user