static int build_vlc(AVCodecContext *avctx, VLC *vlc, const uint32_t *table)

{

    Node nodes[512];

    uint32_t bits[256];

    int16_t lens[256];

    uint8_t xlat[256];

    int cur_node, i, j, pos = 0;



    ff_free_vlc(vlc);



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

        nodes[i].count = table[i];

        nodes[i].sym   = i;

        nodes[i].n0    = -2;

        nodes[i].l     = i;

        nodes[i].r     = i;

    }



    cur_node = 256;

    j = 0;

    do {

        for (i = 0; ; i++) {

            int new_node = j;

            int first_node = cur_node;

            int second_node = cur_node;

            int nd, st;



            nodes[cur_node].count = -1;



            do {

                int val = nodes[new_node].count;

                if (val && (val < nodes[first_node].count)) {

                    if (val >= nodes[second_node].count) {

                        first_node = new_node;

                    } else {

                        first_node = second_node;

                        second_node = new_node;

                    }

                }

                new_node += 1;

            } while (new_node != cur_node);



            if (first_node == cur_node)

                break;



            nd = nodes[second_node].count;

            st = nodes[first_node].count;

            nodes[second_node].count = 0;

            nodes[first_node].count  = 0;

            nodes[cur_node].count = nd + st;

            nodes[cur_node].sym = -1;

            nodes[cur_node].n0 = cur_node;

            nodes[cur_node].l = first_node;

            nodes[cur_node].r = second_node;

            cur_node++;

        }

        j++;

    } while (cur_node - 256 == j);



    get_tree_codes(bits, lens, xlat, nodes, cur_node - 1, 0, 0, &pos);



    return ff_init_vlc_sparse(vlc, 10, pos, lens, 2, 2, bits, 4, 4, xlat, 1, 1, 0);

}

static int build_vlc(AVCodecContext *avctx, VLC *vlc, const uint32_t *table)

{

    Node nodes[512];

    uint32_t bits[256];

    int16_t lens[256];

    uint8_t xlat[256];

    int cur_node, i, j, pos = 0;



    ff_free_vlc(vlc);



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

        nodes[i].count = table[i];

        nodes[i].sym   = i;

        nodes[i].n0    = -2;

        nodes[i].l     = i;

        nodes[i].r     = i;

    }



    cur_node = 256;

    j = 0;

    do {

        for (i = 0; ; i++) {

            int new_node = j;

            int first_node = cur_node;

            int second_node = cur_node;

            int nd, st;



            nodes[cur_node].count = -1;



            do {

                int val = nodes[new_node].count;

                if (val && (val < nodes[first_node].count)) {

                    if (val >= nodes[second_node].count) {

                        first_node = new_node;

                    } else {

                        first_node = second_node;

                        second_node = new_node;

                    }

                }

                new_node += 1;

            } while (new_node != cur_node);



            if (first_node == cur_node)

                break;



            nd = nodes[second_node].count;

            st = nodes[first_node].count;

            nodes[second_node].count = 0;

            nodes[first_node].count  = 0;

            nodes[cur_node].count = nd + st;

            nodes[cur_node].sym = -1;

            nodes[cur_node].n0 = cur_node;

            nodes[cur_node].l = first_node;

            nodes[cur_node].r = second_node;

            cur_node++;

        }

        j++;

    } while (cur_node - 256 == j);



    get_tree_codes(bits, lens, xlat, nodes, cur_node - 1, 0, 0, &pos);



    return ff_init_vlc_sparse(vlc, 10, pos, lens, 2, 2, bits, 4, 4, xlat, 1, 1, 0);

}

            int nd, st;
static int FUNC_0(AVCodecContext *VAR_0, VLC *VAR_1, const uint32_t *VAR_2)

{

    Node nodes[512];

    uint32_t bits[256];

    int16_t lens[256];

    uint8_t xlat[256];

    int VAR_3, VAR_4, VAR_5, VAR_6 = 0;



    ff_free_vlc(VAR_1);



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

        nodes[VAR_4].count = VAR_2[VAR_4];

        nodes[VAR_4].sym   = VAR_4;

        nodes[VAR_4].n0    = -2;

        nodes[VAR_4].l     = VAR_4;

        nodes[VAR_4].r     = VAR_4;

    }



    VAR_3 = 256;

    VAR_5 = 0;

    do {

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

            int VAR_7 = VAR_5;

            int VAR_8 = VAR_3;

            int VAR_9 = VAR_3;

            int VAR_10, VAR_11;



            nodes[VAR_3].count = -1;



            do {

                int VAR_12 = nodes[VAR_7].count;

                if (VAR_12 && (VAR_12 < nodes[VAR_8].count)) {

                    if (VAR_12 >= nodes[VAR_9].count) {

                        VAR_8 = VAR_7;

                    } else {

                        VAR_8 = VAR_9;

                        VAR_9 = VAR_7;

                    }

                }

                VAR_7 += 1;

            } while (VAR_7 != VAR_3);



            if (VAR_8 == VAR_3)

                break;



            VAR_10 = nodes[VAR_9].count;

            VAR_11 = nodes[VAR_8].count;

            nodes[VAR_9].count = 0;

            nodes[VAR_8].count  = 0;

            nodes[VAR_3].count = VAR_10 + VAR_11;

            nodes[VAR_3].sym = -1;

            nodes[VAR_3].n0 = VAR_3;

            nodes[VAR_3].l = VAR_8;

            nodes[VAR_3].r = VAR_9;

            VAR_3++;

        }

        VAR_5++;

    } while (VAR_3 - 256 == VAR_5);



    get_tree_codes(bits, lens, xlat, nodes, VAR_3 - 1, 0, 0, &VAR_6);



    return ff_init_vlc_sparse(VAR_1, 10, VAR_6, lens, 2, 2, bits, 4, 4, xlat, 1, 1, 0);

}

static int FUNC_0(AVCodecContext *VAR_0, VLC *VAR_1, const uint32_t *VAR_2)
{ Node nodes[512]; uint32_t bits[256]; int16_t lens[256]; uint8_t xlat[256]; int VAR_3, VAR_4, VAR_5, VAR_6 = 0; ff_free_vlc(VAR_1); for (VAR_4 = 0; VAR_4 < 256; VAR_4++) { nodes[VAR_4].count = VAR_2[VAR_4]; nodes[VAR_4].sym   = VAR_4; nodes[VAR_4].n0    = -2; nodes[VAR_4].l     = VAR_4; nodes[VAR_4].r     = VAR_4; } VAR_3 = 256; VAR_5 = 0; do { for (VAR_4 = 0; ; VAR_4++) { int VAR_7 = VAR_5; int VAR_8 = VAR_3; int VAR_9 = VAR_3; int VAR_10, VAR_11; nodes[VAR_3].count = -1; do { int VAR_12 = nodes[VAR_7].count; if (VAR_12 && (VAR_12 < nodes[VAR_8].count)) { if (VAR_12 >= nodes[VAR_9].count) { VAR_8 = VAR_7; } else { VAR_8 = VAR_9; VAR_9 = VAR_7; } } VAR_7 += 1; } while (VAR_7 != VAR_3); if (VAR_8 == VAR_3)
break; VAR_10 = nodes[VAR_9].count; VAR_11 = nodes[VAR_8].count; nodes[VAR_9].count = 0; nodes[VAR_8].count  = 0; nodes[VAR_3].count = VAR_10 + VAR_11; nodes[VAR_3].sym = -1; nodes[VAR_3].n0 = VAR_3; nodes[VAR_3].l = VAR_8; nodes[VAR_3].r = VAR_9; VAR_3++; } VAR_5++; } while (VAR_3 - 256 == VAR_5); get_tree_codes(bits, lens, xlat, nodes, VAR_3 - 1, 0, 0, &VAR_6); return ff_init_vlc_sparse(VAR_1, 10, VAR_6, lens, 2, 2, bits, 4, 4, xlat, 1, 1, 0); }