int ff_ass_split_override_codes(const ASSCodesCallbacks *callbacks, void *priv,

                                const char *buf)

{

    const char *text = NULL;

    char new_line[2];

    int text_len = 0;



    while (*buf) {

        if (text && callbacks->text &&

            (sscanf(buf, "\\%1[nN]", new_line) == 1 ||

             !strncmp(buf, "{\\", 2))) {

            callbacks->text(priv, text, text_len);

            text = NULL;

        }

        if (sscanf(buf, "\\%1[nN]", new_line) == 1) {

            if (callbacks->new_line)

                callbacks->new_line(priv, new_line[0] == 'N');

            buf += 2;

        } else if (!strncmp(buf, "{\\", 2)) {

            buf++;

            while (*buf == '\\') {

                char style[2], c[2], sep[2], c_num[2] = "0", tmp[128] = {0};

                unsigned int color = 0xFFFFFFFF;

                int len, size = -1, an = -1, alpha = -1;

                int x1, y1, x2, y2, t1 = -1, t2 = -1;

                if (sscanf(buf, "\\%1[bisu]%1[01\\}]%n", style, c, &len) > 1) {

                    int close = c[0] == '0' ? 1 : c[0] == '1' ? 0 : -1;

                    len += close != -1;

                    if (callbacks->style)

                        callbacks->style(priv, style[0], close);

                } else if (sscanf(buf, "\\c%1[\\}]%n", sep, &len) > 0 ||

                           sscanf(buf, "\\c&H%X&%1[\\}]%n", &color, sep, &len) > 1 ||

                           sscanf(buf, "\\%1[1234]c%1[\\}]%n", c_num, sep, &len) > 1 ||

                           sscanf(buf, "\\%1[1234]c&H%X&%1[\\}]%n", c_num, &color, sep, &len) > 2) {

                    if (callbacks->color)

                        callbacks->color(priv, color, c_num[0] - '0');

                } else if (sscanf(buf, "\\alpha%1[\\}]%n", sep, &len) > 0 ||

                           sscanf(buf, "\\alpha&H%2X&%1[\\}]%n", &alpha, sep, &len) > 1 ||

                           sscanf(buf, "\\%1[1234]a%1[\\}]%n", c_num, sep, &len) > 1 ||

                           sscanf(buf, "\\%1[1234]a&H%2X&%1[\\}]%n", c_num, &alpha, sep, &len) > 2) {

                    if (callbacks->alpha)

                        callbacks->alpha(priv, alpha, c_num[0] - '0');

                } else if (sscanf(buf, "\\fn%1[\\}]%n", sep, &len) > 0 ||

                           sscanf(buf, "\\fn%127[^\\}]%1[\\}]%n", tmp, sep, &len) > 1) {

                    if (callbacks->font_name)

                        callbacks->font_name(priv, tmp[0] ? tmp : NULL);

                } else if (sscanf(buf, "\\fs%1[\\}]%n", sep, &len) > 0 ||

                           sscanf(buf, "\\fs%u%1[\\}]%n", &size, sep, &len) > 1) {

                    if (callbacks->font_size)

                        callbacks->font_size(priv, size);

                } else if (sscanf(buf, "\\a%1[\\}]%n", sep, &len) > 0 ||

                           sscanf(buf, "\\a%2u%1[\\}]%n", &an, sep, &len) > 1 ||

                           sscanf(buf, "\\an%1[\\}]%n", sep, &len) > 0 ||

                           sscanf(buf, "\\an%1u%1[\\}]%n", &an, sep, &len) > 1) {

                    if (an != -1 && buf[2] != 'n')

                        an = (an&3) + (an&4 ? 6 : an&8 ? 3 : 0);

                    if (callbacks->alignment)

                        callbacks->alignment(priv, an);

                } else if (sscanf(buf, "\\r%1[\\}]%n", sep, &len) > 0 ||

                           sscanf(buf, "\\r%127[^\\}]%1[\\}]%n", tmp, sep, &len) > 1) {

                    if (callbacks->cancel_overrides)

                        callbacks->cancel_overrides(priv, tmp);

                } else if (sscanf(buf, "\\move(%d,%d,%d,%d)%1[\\}]%n", &x1, &y1, &x2, &y2, sep, &len) > 4 ||

                           sscanf(buf, "\\move(%d,%d,%d,%d,%d,%d)%1[\\}]%n", &x1, &y1, &x2, &y2, &t1, &t2, sep, &len) > 6) {

                    if (callbacks->move)

                        callbacks->move(priv, x1, y1, x2, y2, t1, t2);

                } else if (sscanf(buf, "\\pos(%d,%d)%1[\\}]%n", &x1, &y1, sep, &len) > 2) {

                    if (callbacks->move)

                        callbacks->move(priv, x1, y1, x1, y1, -1, -1);

                } else if (sscanf(buf, "\\org(%d,%d)%1[\\}]%n", &x1, &y1, sep, &len) > 2) {

                    if (callbacks->origin)

                        callbacks->origin(priv, x1, y1);

                } else {

                    len = strcspn(buf+1, "\\}") + 2;  /* skip unknown code */

                }

                buf += len - 1;

            }

            if (*buf++ != '}')

                return AVERROR_INVALIDDATA;

        } else {

            if (!text) {

                text = buf;

                text_len = 1;

            } else

                text_len++;

            buf++;

        }

    }

    if (text && callbacks->text)

        callbacks->text(priv, text, text_len);

    if (callbacks->end)

        callbacks->end(priv);

    return 0;

}

int ff_ass_split_override_codes(const ASSCodesCallbacks *callbacks, void *priv,

                                const char *buf)

{

    const char *text = NULL;

    char new_line[2];

    int text_len = 0;



    while (*buf) {

        if (text && callbacks->text &&

            (sscanf(buf, "\\%1[nN]", new_line) == 1 ||

             !strncmp(buf, "{\\", 2))) {

            callbacks->text(priv, text, text_len);

            text = NULL;

        }

        if (sscanf(buf, "\\%1[nN]", new_line) == 1) {

            if (callbacks->new_line)

                callbacks->new_line(priv, new_line[0] == 'N');

            buf += 2;

        } else if (!strncmp(buf, "{\\", 2)) {

            buf++;

            while (*buf == '\\') {

                char style[2], c[2], sep[2], c_num[2] = "0", tmp[128] = {0};

                unsigned int color = 0xFFFFFFFF;

                int len, size = -1, an = -1, alpha = -1;

                int x1, y1, x2, y2, t1 = -1, t2 = -1;

                if (sscanf(buf, "\\%1[bisu]%1[01\\}]%n", style, c, &len) > 1) {

                    int close = c[0] == '0' ? 1 : c[0] == '1' ? 0 : -1;

                    len += close != -1;

                    if (callbacks->style)

                        callbacks->style(priv, style[0], close);

                } else if (sscanf(buf, "\\c%1[\\}]%n", sep, &len) > 0 ||

                           sscanf(buf, "\\c&H%X&%1[\\}]%n", &color, sep, &len) > 1 ||

                           sscanf(buf, "\\%1[1234]c%1[\\}]%n", c_num, sep, &len) > 1 ||

                           sscanf(buf, "\\%1[1234]c&H%X&%1[\\}]%n", c_num, &color, sep, &len) > 2) {

                    if (callbacks->color)

                        callbacks->color(priv, color, c_num[0] - '0');

                } else if (sscanf(buf, "\\alpha%1[\\}]%n", sep, &len) > 0 ||

                           sscanf(buf, "\\alpha&H%2X&%1[\\}]%n", &alpha, sep, &len) > 1 ||

                           sscanf(buf, "\\%1[1234]a%1[\\}]%n", c_num, sep, &len) > 1 ||

                           sscanf(buf, "\\%1[1234]a&H%2X&%1[\\}]%n", c_num, &alpha, sep, &len) > 2) {

                    if (callbacks->alpha)

                        callbacks->alpha(priv, alpha, c_num[0] - '0');

                } else if (sscanf(buf, "\\fn%1[\\}]%n", sep, &len) > 0 ||

                           sscanf(buf, "\\fn%127[^\\}]%1[\\}]%n", tmp, sep, &len) > 1) {

                    if (callbacks->font_name)

                        callbacks->font_name(priv, tmp[0] ? tmp : NULL);

                } else if (sscanf(buf, "\\fs%1[\\}]%n", sep, &len) > 0 ||

                           sscanf(buf, "\\fs%u%1[\\}]%n", &size, sep, &len) > 1) {

                    if (callbacks->font_size)

                        callbacks->font_size(priv, size);

                } else if (sscanf(buf, "\\a%1[\\}]%n", sep, &len) > 0 ||

                           sscanf(buf, "\\a%2u%1[\\}]%n", &an, sep, &len) > 1 ||

                           sscanf(buf, "\\an%1[\\}]%n", sep, &len) > 0 ||

                           sscanf(buf, "\\an%1u%1[\\}]%n", &an, sep, &len) > 1) {

                    if (an != -1 && buf[2] != 'n')

                        an = (an&3) + (an&4 ? 6 : an&8 ? 3 : 0);

                    if (callbacks->alignment)

                        callbacks->alignment(priv, an);

                } else if (sscanf(buf, "\\r%1[\\}]%n", sep, &len) > 0 ||

                           sscanf(buf, "\\r%127[^\\}]%1[\\}]%n", tmp, sep, &len) > 1) {

                    if (callbacks->cancel_overrides)

                        callbacks->cancel_overrides(priv, tmp);

                } else if (sscanf(buf, "\\move(%d,%d,%d,%d)%1[\\}]%n", &x1, &y1, &x2, &y2, sep, &len) > 4 ||

                           sscanf(buf, "\\move(%d,%d,%d,%d,%d,%d)%1[\\}]%n", &x1, &y1, &x2, &y2, &t1, &t2, sep, &len) > 6) {

                    if (callbacks->move)

                        callbacks->move(priv, x1, y1, x2, y2, t1, t2);

                } else if (sscanf(buf, "\\pos(%d,%d)%1[\\}]%n", &x1, &y1, sep, &len) > 2) {

                    if (callbacks->move)

                        callbacks->move(priv, x1, y1, x1, y1, -1, -1);

                } else if (sscanf(buf, "\\org(%d,%d)%1[\\}]%n", &x1, &y1, sep, &len) > 2) {

                    if (callbacks->origin)

                        callbacks->origin(priv, x1, y1);

                } else {

                    len = strcspn(buf+1, "\\}") + 2;  

                }

                buf += len - 1;

            }

            if (*buf++ != '}')

                return AVERROR_INVALIDDATA;

        } else {

            if (!text) {

                text = buf;

                text_len = 1;

            } else

                text_len++;

            buf++;

        }

    }

    if (text && callbacks->text)

        callbacks->text(priv, text, text_len);

    if (callbacks->end)

        callbacks->end(priv);

    return 0;

}

    while (*buf) {
int FUNC_0(const ASSCodesCallbacks *VAR_0, void *VAR_1,

                                const char *VAR_2)

{

    const char *VAR_3 = NULL;

    char VAR_4[2];

    int VAR_5 = 0;



    while (*VAR_2) {

        if (VAR_3 && VAR_0->VAR_3 &&

            (sscanf(VAR_2, "\\%1[nN]", VAR_4) == 1 ||

             !strncmp(VAR_2, "{\\", 2))) {

            VAR_0->VAR_3(VAR_1, VAR_3, VAR_5);

            VAR_3 = NULL;

        }

        if (sscanf(VAR_2, "\\%1[nN]", VAR_4) == 1) {

            if (VAR_0->VAR_4)

                VAR_0->VAR_4(VAR_1, VAR_4[0] == 'N');

            VAR_2 += 2;

        } else if (!strncmp(VAR_2, "{\\", 2)) {

            VAR_2++;

            while (*VAR_2 == '\\') {

                char VAR_6[2], VAR_7[2], VAR_8[2], VAR_9[2] = "0", VAR_10[128] = {0};

                unsigned int VAR_11 = 0xFFFFFFFF;

                int VAR_12, VAR_13 = -1, VAR_14 = -1, VAR_15 = -1;

                int VAR_16, VAR_17, VAR_18, VAR_19, VAR_20 = -1, VAR_21 = -1;

                if (sscanf(VAR_2, "\\%1[bisu]%1[01\\}]%n", VAR_6, VAR_7, &VAR_12) > 1) {

                    int VAR_22 = VAR_7[0] == '0' ? 1 : VAR_7[0] == '1' ? 0 : -1;

                    VAR_12 += VAR_22 != -1;

                    if (VAR_0->VAR_6)

                        VAR_0->VAR_6(VAR_1, VAR_6[0], VAR_22);

                } else if (sscanf(VAR_2, "\\VAR_7%1[\\}]%n", VAR_8, &VAR_12) > 0 ||

                           sscanf(VAR_2, "\\VAR_7&H%X&%1[\\}]%n", &VAR_11, VAR_8, &VAR_12) > 1 ||

                           sscanf(VAR_2, "\\%1[1234]VAR_7%1[\\}]%n", VAR_9, VAR_8, &VAR_12) > 1 ||

                           sscanf(VAR_2, "\\%1[1234]VAR_7&H%X&%1[\\}]%n", VAR_9, &VAR_11, VAR_8, &VAR_12) > 2) {

                    if (VAR_0->VAR_11)

                        VAR_0->VAR_11(VAR_1, VAR_11, VAR_9[0] - '0');

                } else if (sscanf(VAR_2, "\\VAR_15%1[\\}]%n", VAR_8, &VAR_12) > 0 ||

                           sscanf(VAR_2, "\\VAR_15&H%2X&%1[\\}]%n", &VAR_15, VAR_8, &VAR_12) > 1 ||

                           sscanf(VAR_2, "\\%1[1234]a%1[\\}]%n", VAR_9, VAR_8, &VAR_12) > 1 ||

                           sscanf(VAR_2, "\\%1[1234]a&H%2X&%1[\\}]%n", VAR_9, &VAR_15, VAR_8, &VAR_12) > 2) {

                    if (VAR_0->VAR_15)

                        VAR_0->VAR_15(VAR_1, VAR_15, VAR_9[0] - '0');

                } else if (sscanf(VAR_2, "\\fn%1[\\}]%n", VAR_8, &VAR_12) > 0 ||

                           sscanf(VAR_2, "\\fn%127[^\\}]%1[\\}]%n", VAR_10, VAR_8, &VAR_12) > 1) {

                    if (VAR_0->font_name)

                        VAR_0->font_name(VAR_1, VAR_10[0] ? VAR_10 : NULL);

                } else if (sscanf(VAR_2, "\\fs%1[\\}]%n", VAR_8, &VAR_12) > 0 ||

                           sscanf(VAR_2, "\\fs%u%1[\\}]%n", &VAR_13, VAR_8, &VAR_12) > 1) {

                    if (VAR_0->font_size)

                        VAR_0->font_size(VAR_1, VAR_13);

                } else if (sscanf(VAR_2, "\\a%1[\\}]%n", VAR_8, &VAR_12) > 0 ||

                           sscanf(VAR_2, "\\a%2u%1[\\}]%n", &VAR_14, VAR_8, &VAR_12) > 1 ||

                           sscanf(VAR_2, "\\VAR_14%1[\\}]%n", VAR_8, &VAR_12) > 0 ||

                           sscanf(VAR_2, "\\VAR_14%1u%1[\\}]%n", &VAR_14, VAR_8, &VAR_12) > 1) {

                    if (VAR_14 != -1 && VAR_2[2] != 'n')

                        VAR_14 = (VAR_14&3) + (VAR_14&4 ? 6 : VAR_14&8 ? 3 : 0);

                    if (VAR_0->alignment)

                        VAR_0->alignment(VAR_1, VAR_14);

                } else if (sscanf(VAR_2, "\\r%1[\\}]%n", VAR_8, &VAR_12) > 0 ||

                           sscanf(VAR_2, "\\r%127[^\\}]%1[\\}]%n", VAR_10, VAR_8, &VAR_12) > 1) {

                    if (VAR_0->cancel_overrides)

                        VAR_0->cancel_overrides(VAR_1, VAR_10);

                } else if (sscanf(VAR_2, "\\move(%d,%d,%d,%d)%1[\\}]%n", &VAR_16, &VAR_17, &VAR_18, &VAR_19, VAR_8, &VAR_12) > 4 ||

                           sscanf(VAR_2, "\\move(%d,%d,%d,%d,%d,%d)%1[\\}]%n", &VAR_16, &VAR_17, &VAR_18, &VAR_19, &VAR_20, &VAR_21, VAR_8, &VAR_12) > 6) {

                    if (VAR_0->move)

                        VAR_0->move(VAR_1, VAR_16, VAR_17, VAR_18, VAR_19, VAR_20, VAR_21);

                } else if (sscanf(VAR_2, "\\pos(%d,%d)%1[\\}]%n", &VAR_16, &VAR_17, VAR_8, &VAR_12) > 2) {

                    if (VAR_0->move)

                        VAR_0->move(VAR_1, VAR_16, VAR_17, VAR_16, VAR_17, -1, -1);

                } else if (sscanf(VAR_2, "\\org(%d,%d)%1[\\}]%n", &VAR_16, &VAR_17, VAR_8, &VAR_12) > 2) {

                    if (VAR_0->origin)

                        VAR_0->origin(VAR_1, VAR_16, VAR_17);

                } else {

                    VAR_12 = strcspn(VAR_2+1, "\\}") + 2;  

                }

                VAR_2 += VAR_12 - 1;

            }

            if (*VAR_2++ != '}')

                return AVERROR_INVALIDDATA;

        } else {

            if (!VAR_3) {

                VAR_3 = VAR_2;

                VAR_5 = 1;

            } else

                VAR_5++;

            VAR_2++;

        }

    }

    if (VAR_3 && VAR_0->VAR_3)

        VAR_0->VAR_3(VAR_1, VAR_3, VAR_5);

    if (VAR_0->end)

        VAR_0->end(VAR_1);

    return 0;

}

int FUNC_0(const ASSCodesCallbacks *VAR_0, void *VAR_1,
const char *VAR_2)
{ const char *VAR_3 = NULL; char VAR_4[2]; int VAR_5 = 0; while (*VAR_2) { if (VAR_3 && VAR_0->VAR_3 &&
(sscanf(VAR_2, "\\%1[nN]", VAR_4) == 1 ||
!strncmp(VAR_2, "{\\", 2))) { VAR_0->VAR_3(VAR_1, VAR_3, VAR_5); VAR_3 = NULL; } if (sscanf(VAR_2, "\\%1[nN]", VAR_4) == 1) { if (VAR_0->VAR_4)
VAR_0->VAR_4(VAR_1, VAR_4[0] == 'N'); VAR_2 += 2; } else if (!strncmp(VAR_2, "{\\", 2)) { VAR_2++; while (*VAR_2 == '\\') { char VAR_6[2], VAR_7[2], VAR_8[2], VAR_9[2] = "0", VAR_10[128] = {0}; unsigned int VAR_11 = 0xFFFFFFFF; int VAR_12, VAR_13 = -1, VAR_14 = -1, VAR_15 = -1; int VAR_16, VAR_17, VAR_18, VAR_19, VAR_20 = -1, VAR_21 = -1; if (sscanf(VAR_2, "\\%1[bisu]%1[01\\}]%n", VAR_6, VAR_7, &VAR_12) > 1) { int VAR_22 = VAR_7[0] == '0' ? 1 : VAR_7[0] == '1' ? 0 : -1; VAR_12 += VAR_22 != -1; if (VAR_0->VAR_6)
VAR_0->VAR_6(VAR_1, VAR_6[0], VAR_22); } else if (sscanf(VAR_2, "\\VAR_7%1[\\}]%n", VAR_8, &VAR_12) > 0 || sscanf(VAR_2, "\\VAR_7&H%X&%1[\\}]%n", &VAR_11, VAR_8, &VAR_12) > 1 || sscanf(VAR_2, "\\%1[1234]VAR_7%1[\\}]%n", VAR_9, VAR_8, &VAR_12) > 1 || sscanf(VAR_2, "\\%1[1234]VAR_7&H%X&%1[\\}]%n", VAR_9, &VAR_11, VAR_8, &VAR_12) > 2) { if (VAR_0->VAR_11)
VAR_0->VAR_11(VAR_1, VAR_11, VAR_9[0] - '0'); } else if (sscanf(VAR_2, "\\VAR_15%1[\\}]%n", VAR_8, &VAR_12) > 0 || sscanf(VAR_2, "\\VAR_15&H%2X&%1[\\}]%n", &VAR_15, VAR_8, &VAR_12) > 1 || sscanf(VAR_2, "\\%1[1234]a%1[\\}]%n", VAR_9, VAR_8, &VAR_12) > 1 || sscanf(VAR_2, "\\%1[1234]a&H%2X&%1[\\}]%n", VAR_9, &VAR_15, VAR_8, &VAR_12) > 2) { if (VAR_0->VAR_15)
VAR_0->VAR_15(VAR_1, VAR_15, VAR_9[0] - '0'); } else if (sscanf(VAR_2, "\\fn%1[\\}]%n", VAR_8, &VAR_12) > 0 || sscanf(VAR_2, "\\fn%127[^\\}]%1[\\}]%n", VAR_10, VAR_8, &VAR_12) > 1) { if (VAR_0->font_name)
VAR_0->font_name(VAR_1, VAR_10[0] ? VAR_10 : NULL); } else if (sscanf(VAR_2, "\\fs%1[\\}]%n", VAR_8, &VAR_12) > 0 || sscanf(VAR_2, "\\fs%u%1[\\}]%n", &VAR_13, VAR_8, &VAR_12) > 1) { if (VAR_0->font_size)
VAR_0->font_size(VAR_1, VAR_13); } else if (sscanf(VAR_2, "\\a%1[\\}]%n", VAR_8, &VAR_12) > 0 || sscanf(VAR_2, "\\a%2u%1[\\}]%n", &VAR_14, VAR_8, &VAR_12) > 1 || sscanf(VAR_2, "\\VAR_14%1[\\}]%n", VAR_8, &VAR_12) > 0 || sscanf(VAR_2, "\\VAR_14%1u%1[\\}]%n", &VAR_14, VAR_8, &VAR_12) > 1) { if (VAR_14 != -1 && VAR_2[2] != 'n')
VAR_14 = (VAR_14&3) + (VAR_14&4 ? 6 : VAR_14&8 ? 3 : 0); if (VAR_0->alignment)
VAR_0->alignment(VAR_1, VAR_14); } else if (sscanf(VAR_2, "\\r%1[\\}]%n", VAR_8, &VAR_12) > 0 || sscanf(VAR_2, "\\r%127[^\\}]%1[\\}]%n", VAR_10, VAR_8, &VAR_12) > 1) { if (VAR_0->cancel_overrides)
VAR_0->cancel_overrides(VAR_1, VAR_10); } else if (sscanf(VAR_2, "\\move(%d,%d,%d,%d)%1[\\}]%n", &VAR_16, &VAR_17, &VAR_18, &VAR_19, VAR_8, &VAR_12) > 4 || sscanf(VAR_2, "\\move(%d,%d,%d,%d,%d,%d)%1[\\}]%n", &VAR_16, &VAR_17, &VAR_18, &VAR_19, &VAR_20, &VAR_21, VAR_8, &VAR_12) > 6) { if (VAR_0->move)
VAR_0->move(VAR_1, VAR_16, VAR_17, VAR_18, VAR_19, VAR_20, VAR_21); } else if (sscanf(VAR_2, "\\pos(%d,%d)%1[\\}]%n", &VAR_16, &VAR_17, VAR_8, &VAR_12) > 2) { if (VAR_0->move)
VAR_0->move(VAR_1, VAR_16, VAR_17, VAR_16, VAR_17, -1, -1); } else if (sscanf(VAR_2, "\\org(%d,%d)%1[\\}]%n", &VAR_16, &VAR_17, VAR_8, &VAR_12) > 2) { if (VAR_0->origin)
VAR_0->origin(VAR_1, VAR_16, VAR_17); } else { VAR_12 = strcspn(VAR_2+1, "\\}") + 2; } VAR_2 += VAR_12 - 1; } if (*VAR_2++ != '}') return AVERROR_INVALIDDATA; } else { if (!VAR_3) { VAR_3 = VAR_2; VAR_5 = 1; } else VAR_5++; VAR_2++; } } if (VAR_3 && VAR_0->VAR_3)
VAR_0->VAR_3(VAR_1, VAR_3, VAR_5); if (VAR_0->end)
VAR_0->end(VAR_1); return 0; }