char *av_base64_encode(uint8_t * src, int len)

{

    static const char b64[] =

        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

    char *ret, *dst;

    unsigned i_bits = 0;

    int i_shift = 0;

    int bytes_remaining = len;



    if (len < UINT_MAX / 4) {

        ret = dst = av_malloc(len * 4 / 3 + 12);

    } else

        return NULL;



    if (len) {                  // special edge case, what should we really do here?

        while (bytes_remaining) {

            i_bits = (i_bits << 8) + *src++;

            bytes_remaining--;

            i_shift += 8;



            do {

                *dst++ = b64[(i_bits << 6 >> i_shift) & 0x3f];

                i_shift -= 6;

            } while (i_shift > 6 || (bytes_remaining == 0 && i_shift > 0));

        }

        while ((dst - ret) & 3)

            *dst++ = '=';

    }

    *dst = '\0';



    return ret;

}

char *av_base64_encode(uint8_t * src, int len)

{

    static const char b64[] =

        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

    char *ret, *dst;

    unsigned i_bits = 0;

    int i_shift = 0;

    int bytes_remaining = len;



    if (len < UINT_MAX / 4) {

        ret = dst = av_malloc(len * 4 / 3 + 12);

    } else

        return NULL;



    if (len) {                  

        while (bytes_remaining) {

            i_bits = (i_bits << 8) + *src++;

            bytes_remaining--;

            i_shift += 8;



            do {

                *dst++ = b64[(i_bits << 6 >> i_shift) & 0x3f];

                i_shift -= 6;

            } while (i_shift > 6 || (bytes_remaining == 0 && i_shift > 0));

        }

        while ((dst - ret) & 3)

            *dst++ = '=';

    }

    *dst = '\0';



    return ret;

}

char *FUNC_0(uint8_t * VAR_0, int VAR_1)

{

    static const char VAR_2[] =

        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

    char *VAR_3, *VAR_4;

    unsigned VAR_5 = 0;

    int VAR_6 = 0;

    int VAR_7 = VAR_1;



    if (VAR_1 < UINT_MAX / 4) {

        VAR_3 = VAR_4 = av_malloc(VAR_1 * 4 / 3 + 12);

    } else

        return NULL;



    if (VAR_1) {                  

        while (VAR_7) {

            VAR_5 = (VAR_5 << 8) + *VAR_0++;

            VAR_7--;

            VAR_6 += 8;



            do {

                *VAR_4++ = VAR_2[(VAR_5 << 6 >> VAR_6) & 0x3f];

                VAR_6 -= 6;

            } while (VAR_6 > 6 || (VAR_7 == 0 && VAR_6 > 0));

        }

        while ((VAR_4 - VAR_3) & 3)

            *VAR_4++ = '=';

    }

    *VAR_4 = '\0';



    return VAR_3;

}

char *FUNC_0(uint8_t * VAR_0, int VAR_1)
{ static const char VAR_2[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; char *VAR_3, *VAR_4; unsigned VAR_5 = 0; int VAR_6 = 0; int VAR_7 = VAR_1; if (VAR_1 < UINT_MAX / 4) { VAR_3 = VAR_4 = av_malloc(VAR_1 * 4 / 3 + 12); } else return NULL; if (VAR_1) { while (VAR_7) { VAR_5 = (VAR_5 << 8) + *VAR_0++; VAR_7--; VAR_6 += 8; do { *VAR_4++ = VAR_2[(VAR_5 << 6 >> VAR_6) & 0x3f]; VAR_6 -= 6; } while (VAR_6 > 6 || (VAR_7 == 0 && VAR_6 > 0)); } while ((VAR_4 - VAR_3) & 3)
*VAR_4++ = '='; } *VAR_4 = '\0'; return VAR_3; }