int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,

                   void *log_ctx)

{

    char *tail, color_string2[128];

    const ColorEntry *entry;

    int len, hex_offset = 0;



    if (color_string[0] == '#') {

        hex_offset = 1;

    } else if (!strncmp(color_string, "0x", 2))

        hex_offset = 2;



    if (slen < 0)

        slen = strlen(color_string);

    av_strlcpy(color_string2, color_string + hex_offset,

               FFMIN(slen-hex_offset+1, sizeof(color_string2)));

    if ((tail = strchr(color_string2, ALPHA_SEP)))

        *tail++ = 0;

    len = strlen(color_string2);

    rgba_color[3] = 255;



    if (!av_strcasecmp(color_string2, "random") || !av_strcasecmp(color_string2, "bikeshed")) {

        int rgba = av_get_random_seed();

        rgba_color[0] = rgba >> 24;

        rgba_color[1] = rgba >> 16;

        rgba_color[2] = rgba >> 8;

        rgba_color[3] = rgba;

    } else if (hex_offset ||

               strspn(color_string2, "0123456789ABCDEFabcdef") == len) {

        char *tail;

        unsigned int rgba = strtoul(color_string2, &tail, 16);



        if (*tail || (len != 6 && len != 8)) {

            av_log(log_ctx, AV_LOG_ERROR, "Invalid 0xRRGGBB[AA] color string: '%s'\n", color_string2);

            return AVERROR(EINVAL);

        }

        if (len == 8) {

            rgba_color[3] = rgba;

            rgba >>= 8;

        }

        rgba_color[0] = rgba >> 16;

        rgba_color[1] = rgba >> 8;

        rgba_color[2] = rgba;

    } else {

        entry = bsearch(color_string2,

                        color_table,

                        FF_ARRAY_ELEMS(color_table),

                        sizeof(ColorEntry),

                        color_table_compare);

        if (!entry) {

            av_log(log_ctx, AV_LOG_ERROR, "Cannot find color '%s'\n", color_string2);

            return AVERROR(EINVAL);

        }

        memcpy(rgba_color, entry->rgb_color, 3);

    }



    if (tail) {

        unsigned long int alpha;

        const char *alpha_string = tail;

        if (!strncmp(alpha_string, "0x", 2)) {

            alpha = strtoul(alpha_string, &tail, 16);

        } else {

            alpha = 255 * strtod(alpha_string, &tail);

        }



        if (tail == alpha_string || *tail || alpha > 255) {

            av_log(log_ctx, AV_LOG_ERROR, "Invalid alpha value specifier '%s' in '%s'\n",

                   alpha_string, color_string);

            return AVERROR(EINVAL);

        }

        rgba_color[3] = alpha;

    }



    return 0;

}

int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,

                   void *log_ctx)

{

    char *tail, color_string2[128];

    const ColorEntry *entry;

    int len, hex_offset = 0;



    if (color_string[0] == '#') {

        hex_offset = 1;

    } else if (!strncmp(color_string, "0x", 2))

        hex_offset = 2;



    if (slen < 0)

        slen = strlen(color_string);

    av_strlcpy(color_string2, color_string + hex_offset,

               FFMIN(slen-hex_offset+1, sizeof(color_string2)));

    if ((tail = strchr(color_string2, ALPHA_SEP)))

        *tail++ = 0;

    len = strlen(color_string2);

    rgba_color[3] = 255;



    if (!av_strcasecmp(color_string2, "random") || !av_strcasecmp(color_string2, "bikeshed")) {

        int rgba = av_get_random_seed();

        rgba_color[0] = rgba >> 24;

        rgba_color[1] = rgba >> 16;

        rgba_color[2] = rgba >> 8;

        rgba_color[3] = rgba;

    } else if (hex_offset ||

               strspn(color_string2, "0123456789ABCDEFabcdef") == len) {

        char *tail;

        unsigned int rgba = strtoul(color_string2, &tail, 16);



        if (*tail || (len != 6 && len != 8)) {

            av_log(log_ctx, AV_LOG_ERROR, "Invalid 0xRRGGBB[AA] color string: '%s'\n", color_string2);

            return AVERROR(EINVAL);

        }

        if (len == 8) {

            rgba_color[3] = rgba;

            rgba >>= 8;

        }

        rgba_color[0] = rgba >> 16;

        rgba_color[1] = rgba >> 8;

        rgba_color[2] = rgba;

    } else {

        entry = bsearch(color_string2,

                        color_table,

                        FF_ARRAY_ELEMS(color_table),

                        sizeof(ColorEntry),

                        color_table_compare);

        if (!entry) {

            av_log(log_ctx, AV_LOG_ERROR, "Cannot find color '%s'\n", color_string2);

            return AVERROR(EINVAL);

        }

        memcpy(rgba_color, entry->rgb_color, 3);

    }



    if (tail) {

        unsigned long int alpha;

        const char *alpha_string = tail;

        if (!strncmp(alpha_string, "0x", 2)) {

            alpha = strtoul(alpha_string, &tail, 16);

        } else {

            alpha = 255 * strtod(alpha_string, &tail);

        }



        if (tail == alpha_string || *tail || alpha > 255) {

            av_log(log_ctx, AV_LOG_ERROR, "Invalid alpha value specifier '%s' in '%s'\n",

                   alpha_string, color_string);

            return AVERROR(EINVAL);

        }

        rgba_color[3] = alpha;

    }



    return 0;

}

            alpha = 255 * strtod(alpha_string, &tail);
int FUNC_0(uint8_t *VAR_0, const char *VAR_1, int VAR_2,

                   void *VAR_3)

{

    char *VAR_10, VAR_5[128];

    const ColorEntry *VAR_6;

    int VAR_7, VAR_8 = 0;



    if (VAR_1[0] == '#') {

        VAR_8 = 1;

    } else if (!strncmp(VAR_1, "0x", 2))

        VAR_8 = 2;



    if (VAR_2 < 0)

        VAR_2 = strlen(VAR_1);

    av_strlcpy(VAR_5, VAR_1 + VAR_8,

               FFMIN(VAR_2-VAR_8+1, sizeof(VAR_5)));

    if ((VAR_10 = strchr(VAR_5, ALPHA_SEP)))

        *VAR_10++ = 0;

    VAR_7 = strlen(VAR_5);

    VAR_0[3] = 255;



    if (!av_strcasecmp(VAR_5, "random") || !av_strcasecmp(VAR_5, "bikeshed")) {

        int VAR_10 = av_get_random_seed();

        VAR_0[0] = VAR_10 >> 24;

        VAR_0[1] = VAR_10 >> 16;

        VAR_0[2] = VAR_10 >> 8;

        VAR_0[3] = VAR_10;

    } else if (VAR_8 ||

               strspn(VAR_5, "0123456789ABCDEFabcdef") == VAR_7) {

        char *VAR_10;

        unsigned int VAR_10 = strtoul(VAR_5, &VAR_10, 16);



        if (*VAR_10 || (VAR_7 != 6 && VAR_7 != 8)) {

            av_log(VAR_3, AV_LOG_ERROR, "Invalid 0xRRGGBB[AA] color string: '%s'\n", VAR_5);

            return AVERROR(EINVAL);

        }

        if (VAR_7 == 8) {

            VAR_0[3] = VAR_10;

            VAR_10 >>= 8;

        }

        VAR_0[0] = VAR_10 >> 16;

        VAR_0[1] = VAR_10 >> 8;

        VAR_0[2] = VAR_10;

    } else {

        VAR_6 = bsearch(VAR_5,

                        color_table,

                        FF_ARRAY_ELEMS(color_table),

                        sizeof(ColorEntry),

                        color_table_compare);

        if (!VAR_6) {

            av_log(VAR_3, AV_LOG_ERROR, "Cannot find color '%s'\n", VAR_5);

            return AVERROR(EINVAL);

        }

        memcpy(VAR_0, VAR_6->rgb_color, 3);

    }



    if (VAR_10) {

        unsigned long int VAR_10;

        const char *VAR_11 = VAR_10;

        if (!strncmp(VAR_11, "0x", 2)) {

            VAR_10 = strtoul(VAR_11, &VAR_10, 16);

        } else {

            VAR_10 = 255 * strtod(VAR_11, &VAR_10);

        }



        if (VAR_10 == VAR_11 || *VAR_10 || VAR_10 > 255) {

            av_log(VAR_3, AV_LOG_ERROR, "Invalid VAR_10 value specifier '%s' in '%s'\n",

                   VAR_11, VAR_1);

            return AVERROR(EINVAL);

        }

        VAR_0[3] = VAR_10;

    }



    return 0;

}

int FUNC_0(uint8_t *VAR_0, const char *VAR_1, int VAR_2,
void *VAR_3)
{ char *VAR_10, VAR_5[128]; const ColorEntry *VAR_6; int VAR_7, VAR_8 = 0; if (VAR_1[0] == '#') { VAR_8 = 1; } else if (!strncmp(VAR_1, "0x", 2)) VAR_8 = 2; if (VAR_2 < 0)
VAR_2 = strlen(VAR_1); av_strlcpy(VAR_5, VAR_1 + VAR_8,
FFMIN(VAR_2-VAR_8+1, sizeof(VAR_5))); if ((VAR_10 = strchr(VAR_5, ALPHA_SEP)))
*VAR_10++ = 0; VAR_7 = strlen(VAR_5); VAR_0[3] = 255; if (!av_strcasecmp(VAR_5, "random") || !av_strcasecmp(VAR_5, "bikeshed")) { int VAR_10 = av_get_random_seed(); VAR_0[0] = VAR_10 >> 24; VAR_0[1] = VAR_10 >> 16; VAR_0[2] = VAR_10 >> 8; VAR_0[3] = VAR_10; } else if (VAR_8 || strspn(VAR_5, "0123456789ABCDEFabcdef") == VAR_7) { char *VAR_10; unsigned int VAR_10 = strtoul(VAR_5, &VAR_10, 16); if (*VAR_10 || (VAR_7 != 6 && VAR_7 != 8)) { av_log(VAR_3, AV_LOG_ERROR, "Invalid 0xRRGGBB[AA] color string: '%s'\n", VAR_5); return AVERROR(EINVAL); } if (VAR_7 == 8) { VAR_0[3] = VAR_10; VAR_10 >>= 8; } VAR_0[0] = VAR_10 >> 16; VAR_0[1] = VAR_10 >> 8; VAR_0[2] = VAR_10; } else { VAR_6 = bsearch(VAR_5,
color_table,
FF_ARRAY_ELEMS(color_table),
sizeof(ColorEntry),
color_table_compare); if (!VAR_6) { av_log(VAR_3, AV_LOG_ERROR, "Cannot find color '%s'\n", VAR_5); return AVERROR(EINVAL); } memcpy(VAR_0, VAR_6->rgb_color, 3); } if (VAR_10) { unsigned long int VAR_10; const char *VAR_11 = VAR_10; if (!strncmp(VAR_11, "0x", 2)) { VAR_10 = strtoul(VAR_11, &VAR_10, 16); } else { VAR_10 = 255 * strtod(VAR_11, &VAR_10); } if (VAR_10 == VAR_11 || *VAR_10 || VAR_10 > 255) { av_log(VAR_3, AV_LOG_ERROR, "Invalid VAR_10 value specifier '%s' in '%s'\n",
VAR_11, VAR_1); return AVERROR(EINVAL); } VAR_0[3] = VAR_10; } return 0; }