static void generate_joint_tables(HYuvContext *s)

{

    uint16_t symbols[1 << VLC_BITS];

    uint16_t bits[1 << VLC_BITS];

    uint8_t len[1 << VLC_BITS];

    if (s->bitstream_bpp < 24) {

        int p, i, y, u;

        for (p = 0; p < 3; p++) {

            for (i = y = 0; y < 256; y++) {

                int len0  = s->len[0][y];

                int limit = VLC_BITS - len0;

                if (limit <= 0)

                    continue;

                for (u = 0; u < 256; u++) {

                    int len1 = s->len[p][u];

                    if (len1 > limit)

                        continue;

                    len[i]     = len0 + len1;

                    bits[i]    = (s->bits[0][y] << len1) + s->bits[p][u];

                    symbols[i] = (y << 8) + u;

                    if (symbols[i] != 0xffff) // reserved to mean "invalid"

                        i++;

                }

            }

            ff_free_vlc(&s->vlc[3 + p]);

            ff_init_vlc_sparse(&s->vlc[3 + p], VLC_BITS, i, len, 1, 1,

                               bits, 2, 2, symbols, 2, 2, 0);

        }

    } else {

        uint8_t (*map)[4] = (uint8_t(*)[4]) s->pix_bgr_map;

        int i, b, g, r, code;

        int p0 = s->decorrelate;

        int p1 = !s->decorrelate;

        /* Restrict the range to +/-16 because that's pretty much guaranteed

         * to cover all the combinations that fit in 11 bits total, and it

         *  does not matter if we miss a few rare codes. */

        for (i = 0, g = -16; g < 16; g++) {

            int len0   = s->len[p0][g & 255];

            int limit0 = VLC_BITS - len0;

            if (limit0 < 2)

                continue;

            for (b = -16; b < 16; b++) {

                int len1   = s->len[p1][b & 255];

                int limit1 = limit0 - len1;

                if (limit1 < 1)

                    continue;

                code = (s->bits[p0][g & 255] << len1) + s->bits[p1][b & 255];

                for (r = -16; r < 16; r++) {

                    int len2 = s->len[2][r & 255];

                    if (len2 > limit1)

                        continue;

                    len[i]  = len0 + len1 + len2;

                    bits[i] = (code << len2) + s->bits[2][r & 255];

                    if (s->decorrelate) {

                        map[i][G] = g;

                        map[i][B] = g + b;

                        map[i][R] = g + r;

                    } else {

                        map[i][B] = g;

                        map[i][G] = b;

                        map[i][R] = r;

                    }

                    i++;

                }

            }

        }

        ff_free_vlc(&s->vlc[3]);

        init_vlc(&s->vlc[3], VLC_BITS, i, len, 1, 1, bits, 2, 2, 0);

    }

}

static void generate_joint_tables(HYuvContext *s)

{

    uint16_t symbols[1 << VLC_BITS];

    uint16_t bits[1 << VLC_BITS];

    uint8_t len[1 << VLC_BITS];

    if (s->bitstream_bpp < 24) {

        int p, i, y, u;

        for (p = 0; p < 3; p++) {

            for (i = y = 0; y < 256; y++) {

                int len0  = s->len[0][y];

                int limit = VLC_BITS - len0;

                if (limit <= 0)

                    continue;

                for (u = 0; u < 256; u++) {

                    int len1 = s->len[p][u];

                    if (len1 > limit)

                        continue;

                    len[i]     = len0 + len1;

                    bits[i]    = (s->bits[0][y] << len1) + s->bits[p][u];

                    symbols[i] = (y << 8) + u;

                    if (symbols[i] != 0xffff) 

                        i++;

                }

            }

            ff_free_vlc(&s->vlc[3 + p]);

            ff_init_vlc_sparse(&s->vlc[3 + p], VLC_BITS, i, len, 1, 1,

                               bits, 2, 2, symbols, 2, 2, 0);

        }

    } else {

        uint8_t (*map)[4] = (uint8_t(*)[4]) s->pix_bgr_map;

        int i, b, g, r, code;

        int p0 = s->decorrelate;

        int p1 = !s->decorrelate;

        





        for (i = 0, g = -16; g < 16; g++) {

            int len0   = s->len[p0][g & 255];

            int limit0 = VLC_BITS - len0;

            if (limit0 < 2)

                continue;

            for (b = -16; b < 16; b++) {

                int len1   = s->len[p1][b & 255];

                int limit1 = limit0 - len1;

                if (limit1 < 1)

                    continue;

                code = (s->bits[p0][g & 255] << len1) + s->bits[p1][b & 255];

                for (r = -16; r < 16; r++) {

                    int len2 = s->len[2][r & 255];

                    if (len2 > limit1)

                        continue;

                    len[i]  = len0 + len1 + len2;

                    bits[i] = (code << len2) + s->bits[2][r & 255];

                    if (s->decorrelate) {

                        map[i][G] = g;

                        map[i][B] = g + b;

                        map[i][R] = g + r;

                    } else {

                        map[i][B] = g;

                        map[i][G] = b;

                        map[i][R] = r;

                    }

                    i++;

                }

            }

        }

        ff_free_vlc(&s->vlc[3]);

        init_vlc(&s->vlc[3], VLC_BITS, i, len, 1, 1, bits, 2, 2, 0);

    }

}

static void generate_joint_tables(HYuvContext *s)             ff_init_vlc_sparse(&s->vlc[3 + p], VLC_BITS, i, len, 1, 1,                                bits, 2, 2, symbols, 2, 2, 0);         init_vlc(&s->vlc[3], VLC_BITS, i, len, 1, 1, bits, 2, 2, 0);
static void FUNC_0(HYuvContext *VAR_0)

{

    uint16_t symbols[1 << VLC_BITS];

    uint16_t bits[1 << VLC_BITS];

    uint8_t len[1 << VLC_BITS];

    if (VAR_0->bitstream_bpp < 24) {

        int VAR_1, VAR_8, VAR_3, VAR_4;

        for (VAR_1 = 0; VAR_1 < 3; VAR_1++) {

            for (VAR_8 = VAR_3 = 0; VAR_3 < 256; VAR_3++) {

                int VAR_14  = VAR_0->len[0][VAR_3];

                int VAR_6 = VLC_BITS - VAR_14;

                if (VAR_6 <= 0)

                    continue;

                for (VAR_4 = 0; VAR_4 < 256; VAR_4++) {

                    int VAR_15 = VAR_0->len[VAR_1][VAR_4];

                    if (VAR_15 > VAR_6)

                        continue;

                    len[VAR_8]     = VAR_14 + VAR_15;

                    bits[VAR_8]    = (VAR_0->bits[0][VAR_3] << VAR_15) + VAR_0->bits[VAR_1][VAR_4];

                    symbols[VAR_8] = (VAR_3 << 8) + VAR_4;

                    if (symbols[VAR_8] != 0xffff) 

                        VAR_8++;

                }

            }

            ff_free_vlc(&VAR_0->vlc[3 + VAR_1]);

            ff_init_vlc_sparse(&VAR_0->vlc[3 + VAR_1], VLC_BITS, VAR_8, len, 1, 1,

                               bits, 2, 2, symbols, 2, 2, 0);

        }

    } else {

        uint8_t (*map)[4] = (uint8_t(*)[4]) VAR_0->pix_bgr_map;

        int VAR_8, VAR_8, VAR_9, VAR_10, VAR_11;

        int VAR_12 = VAR_0->decorrelate;

        int VAR_13 = !VAR_0->decorrelate;

        





        for (VAR_8 = 0, VAR_9 = -16; VAR_9 < 16; VAR_9++) {

            int VAR_14   = VAR_0->len[VAR_12][VAR_9 & 255];

            int VAR_14 = VLC_BITS - VAR_14;

            if (VAR_14 < 2)

                continue;

            for (VAR_8 = -16; VAR_8 < 16; VAR_8++) {

                int VAR_15   = VAR_0->len[VAR_13][VAR_8 & 255];

                int VAR_15 = VAR_14 - VAR_15;

                if (VAR_15 < 1)

                    continue;

                VAR_11 = (VAR_0->bits[VAR_12][VAR_9 & 255] << VAR_15) + VAR_0->bits[VAR_13][VAR_8 & 255];

                for (VAR_10 = -16; VAR_10 < 16; VAR_10++) {

                    int VAR_16 = VAR_0->len[2][VAR_10 & 255];

                    if (VAR_16 > VAR_15)

                        continue;

                    len[VAR_8]  = VAR_14 + VAR_15 + VAR_16;

                    bits[VAR_8] = (VAR_11 << VAR_16) + VAR_0->bits[2][VAR_10 & 255];

                    if (VAR_0->decorrelate) {

                        map[VAR_8][G] = VAR_9;

                        map[VAR_8][B] = VAR_9 + VAR_8;

                        map[VAR_8][R] = VAR_9 + VAR_10;

                    } else {

                        map[VAR_8][B] = VAR_9;

                        map[VAR_8][G] = VAR_8;

                        map[VAR_8][R] = VAR_10;

                    }

                    VAR_8++;

                }

            }

        }

        ff_free_vlc(&VAR_0->vlc[3]);

        init_vlc(&VAR_0->vlc[3], VLC_BITS, VAR_8, len, 1, 1, bits, 2, 2, 0);

    }

}

static void FUNC_0(HYuvContext *VAR_0)
{ uint16_t symbols[1 << VLC_BITS]; uint16_t bits[1 << VLC_BITS]; uint8_t len[1 << VLC_BITS]; if (VAR_0->bitstream_bpp < 24) { int VAR_1, VAR_8, VAR_3, VAR_4; for (VAR_1 = 0; VAR_1 < 3; VAR_1++) { for (VAR_8 = VAR_3 = 0; VAR_3 < 256; VAR_3++) { int VAR_14  = VAR_0->len[0][VAR_3]; int VAR_6 = VLC_BITS - VAR_14; if (VAR_6 <= 0)
continue; for (VAR_4 = 0; VAR_4 < 256; VAR_4++) { int VAR_15 = VAR_0->len[VAR_1][VAR_4]; if (VAR_15 > VAR_6)
continue; len[VAR_8]     = VAR_14 + VAR_15; bits[VAR_8]    = (VAR_0->bits[0][VAR_3] << VAR_15) + VAR_0->bits[VAR_1][VAR_4]; symbols[VAR_8] = (VAR_3 << 8) + VAR_4; if (symbols[VAR_8] != 0xffff)
VAR_8++; } } ff_free_vlc(&VAR_0->vlc[3 + VAR_1]); ff_init_vlc_sparse(&VAR_0->vlc[3 + VAR_1], VLC_BITS, VAR_8, len, 1, 1,
bits, 2, 2, symbols, 2, 2, 0); } } else { uint8_t (*map)[4] = (uint8_t(*)[4]) VAR_0->pix_bgr_map; int VAR_8, VAR_8, VAR_9, VAR_10, VAR_11; int VAR_12 = VAR_0->decorrelate; int VAR_13 = !VAR_0->decorrelate; for (VAR_8 = 0, VAR_9 = -16; VAR_9 < 16; VAR_9++) { int VAR_14   = VAR_0->len[VAR_12][VAR_9 & 255]; int VAR_14 = VLC_BITS - VAR_14; if (VAR_14 < 2)
continue; for (VAR_8 = -16; VAR_8 < 16; VAR_8++) { int VAR_15   = VAR_0->len[VAR_13][VAR_8 & 255]; int VAR_15 = VAR_14 - VAR_15; if (VAR_15 < 1)
continue; VAR_11 = (VAR_0->bits[VAR_12][VAR_9 & 255] << VAR_15) + VAR_0->bits[VAR_13][VAR_8 & 255]; for (VAR_10 = -16; VAR_10 < 16; VAR_10++) { int VAR_16 = VAR_0->len[2][VAR_10 & 255]; if (VAR_16 > VAR_15)
continue; len[VAR_8]  = VAR_14 + VAR_15 + VAR_16; bits[VAR_8] = (VAR_11 << VAR_16) + VAR_0->bits[2][VAR_10 & 255]; if (VAR_0->decorrelate) { map[VAR_8][G] = VAR_9; map[VAR_8][B] = VAR_9 + VAR_8; map[VAR_8][R] = VAR_9 + VAR_10; } else { map[VAR_8][B] = VAR_9; map[VAR_8][G] = VAR_8; map[VAR_8][R] = VAR_10; } VAR_8++; } } } ff_free_vlc(&VAR_0->vlc[3]); init_vlc(&VAR_0->vlc[3], VLC_BITS, VAR_8, len, 1, 1, bits, 2, 2, 0); } }