static int unpack_modes(Vp3DecodeContext *s, GetBitContext *gb)

{

    int i, j, k;

    int scheme;

    int current_macroblock;

    int current_fragment;

    int coding_mode;

    int custom_mode_alphabet[CODING_MODE_COUNT];



    if (s->keyframe) {

        for (i = 0; i < s->fragment_count; i++)

            s->all_fragments[i].coding_method = MODE_INTRA;



    } else {



        /* fetch the mode coding scheme for this frame */

        scheme = get_bits(gb, 3);



        /* is it a custom coding scheme? */

        if (scheme == 0) {




                custom_mode_alphabet[get_bits(gb, 3)] = i;

        }



        /* iterate through all of the macroblocks that contain 1 or more

         * coded fragments */

        for (i = 0; i < s->u_superblock_start; i++) {



            for (j = 0; j < 4; j++) {

                current_macroblock = s->superblock_macroblocks[i * 4 + j];

                if ((current_macroblock == -1) ||

                    (s->macroblock_coding[current_macroblock] == MODE_COPY))

                    continue;

                if (current_macroblock >= s->macroblock_count) {

                    av_log(s->avctx, AV_LOG_ERROR, "  vp3:unpack_modes(): bad macroblock number (%d >= %d)\n",

                        current_macroblock, s->macroblock_count);

                    return 1;

                }



                /* mode 7 means get 3 bits for each coding mode */

                if (scheme == 7)

                    coding_mode = get_bits(gb, 3);

                else if(scheme == 0)

                    coding_mode = custom_mode_alphabet

                        [get_vlc2(gb, s->mode_code_vlc.table, 3, 3)];

                else

                    coding_mode = ModeAlphabet[scheme-1]

                        [get_vlc2(gb, s->mode_code_vlc.table, 3, 3)];



                s->macroblock_coding[current_macroblock] = coding_mode;

                for (k = 0; k < 6; k++) {

                    current_fragment =

                        s->macroblock_fragments[current_macroblock * 6 + k];

                    if (current_fragment == -1)

                        continue;

                    if (current_fragment >= s->fragment_count) {

                        av_log(s->avctx, AV_LOG_ERROR, "  vp3:unpack_modes(): bad fragment number (%d >= %d)\n",

                            current_fragment, s->fragment_count);

                        return 1;

                    }

                    if (s->all_fragments[current_fragment].coding_method !=

                        MODE_COPY)

                        s->all_fragments[current_fragment].coding_method =

                            coding_mode;

                }

            }

        }

    }



    return 0;

}
static int unpack_modes(Vp3DecodeContext *s, GetBitContext *gb)

{

    int i, j, k;

    int scheme;

    int current_macroblock;

    int current_fragment;

    int coding_mode;

    int custom_mode_alphabet[CODING_MODE_COUNT];



    if (s->keyframe) {

        for (i = 0; i < s->fragment_count; i++)

            s->all_fragments[i].coding_method = MODE_INTRA;



    } else {



        

        scheme = get_bits(gb, 3);



        

        if (scheme == 0) {




                custom_mode_alphabet[get_bits(gb, 3)] = i;

        }



        



        for (i = 0; i < s->u_superblock_start; i++) {



            for (j = 0; j < 4; j++) {

                current_macroblock = s->superblock_macroblocks[i * 4 + j];

                if ((current_macroblock == -1) ||

                    (s->macroblock_coding[current_macroblock] == MODE_COPY))

                    continue;

                if (current_macroblock >= s->macroblock_count) {

                    av_log(s->avctx, AV_LOG_ERROR, "  vp3:unpack_modes(): bad macroblock number (%d >= %d)\n",

                        current_macroblock, s->macroblock_count);

                    return 1;

                }



                

                if (scheme == 7)

                    coding_mode = get_bits(gb, 3);

                else if(scheme == 0)

                    coding_mode = custom_mode_alphabet

                        [get_vlc2(gb, s->mode_code_vlc.table, 3, 3)];

                else

                    coding_mode = ModeAlphabet[scheme-1]

                        [get_vlc2(gb, s->mode_code_vlc.table, 3, 3)];



                s->macroblock_coding[current_macroblock] = coding_mode;

                for (k = 0; k < 6; k++) {

                    current_fragment =

                        s->macroblock_fragments[current_macroblock * 6 + k];

                    if (current_fragment == -1)

                        continue;

                    if (current_fragment >= s->fragment_count) {

                        av_log(s->avctx, AV_LOG_ERROR, "  vp3:unpack_modes(): bad fragment number (%d >= %d)\n",

                            current_fragment, s->fragment_count);

                        return 1;

                    }

                    if (s->all_fragments[current_fragment].coding_method !=

                        MODE_COPY)

                        s->all_fragments[current_fragment].coding_method =

                            coding_mode;

                }

            }

        }

    }



    return 0;

}
static int FUNC_0(Vp3DecodeContext *VAR_0, GetBitContext *VAR_1)

{

    int VAR_2, VAR_3, VAR_4;

    int VAR_5;

    int VAR_6;

    int VAR_7;

    int VAR_8;

    int VAR_9[CODING_MODE_COUNT];



    if (VAR_0->keyframe) {

        for (VAR_2 = 0; VAR_2 < VAR_0->fragment_count; VAR_2++)

            VAR_0->all_fragments[VAR_2].coding_method = MODE_INTRA;



    } else {



        

        VAR_5 = get_bits(VAR_1, 3);



        

        if (VAR_5 == 0) {




                VAR_9[get_bits(VAR_1, 3)] = VAR_2;

        }



        



        for (VAR_2 = 0; VAR_2 < VAR_0->u_superblock_start; VAR_2++) {



            for (VAR_3 = 0; VAR_3 < 4; VAR_3++) {

                VAR_6 = VAR_0->superblock_macroblocks[VAR_2 * 4 + VAR_3];

                if ((VAR_6 == -1) ||

                    (VAR_0->macroblock_coding[VAR_6] == MODE_COPY))

                    continue;

                if (VAR_6 >= VAR_0->macroblock_count) {

                    av_log(VAR_0->avctx, AV_LOG_ERROR, "  vp3:FUNC_0(): bad macroblock number (%d >= %d)\n",

                        VAR_6, VAR_0->macroblock_count);

                    return 1;

                }



                

                if (VAR_5 == 7)

                    VAR_8 = get_bits(VAR_1, 3);

                else if(VAR_5 == 0)

                    VAR_8 = VAR_9

                        [get_vlc2(VAR_1, VAR_0->mode_code_vlc.table, 3, 3)];

                else

                    VAR_8 = ModeAlphabet[VAR_5-1]

                        [get_vlc2(VAR_1, VAR_0->mode_code_vlc.table, 3, 3)];



                VAR_0->macroblock_coding[VAR_6] = VAR_8;

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

                    VAR_7 =

                        VAR_0->macroblock_fragments[VAR_6 * 6 + VAR_4];

                    if (VAR_7 == -1)

                        continue;

                    if (VAR_7 >= VAR_0->fragment_count) {

                        av_log(VAR_0->avctx, AV_LOG_ERROR, "  vp3:FUNC_0(): bad fragment number (%d >= %d)\n",

                            VAR_7, VAR_0->fragment_count);

                        return 1;

                    }

                    if (VAR_0->all_fragments[VAR_7].coding_method !=

                        MODE_COPY)

                        VAR_0->all_fragments[VAR_7].coding_method =

                            VAR_8;

                }

            }

        }

    }



    return 0;

}
static int FUNC_0(Vp3DecodeContext *VAR_0, GetBitContext *VAR_1)
{ int VAR_2, VAR_3, VAR_4; int VAR_5; int VAR_6; int VAR_7; int VAR_8; int VAR_9[CODING_MODE_COUNT]; if (VAR_0->keyframe) { for (VAR_2 = 0; VAR_2 < VAR_0->fragment_count; VAR_2++) VAR_0->all_fragments[VAR_2].coding_method = MODE_INTRA; } else { VAR_5 = get_bits(VAR_1, 3); if (VAR_5 == 0) { VAR_9[get_bits(VAR_1, 3)] = VAR_2; } for (VAR_2 = 0; VAR_2 < VAR_0->u_superblock_start; VAR_2++) { for (VAR_3 = 0; VAR_3 < 4; VAR_3++) { VAR_6 = VAR_0->superblock_macroblocks[VAR_2 * 4 + VAR_3]; if ((VAR_6 == -1) ||
(VAR_0->macroblock_coding[VAR_6] == MODE_COPY))
continue; if (VAR_6 >= VAR_0->macroblock_count) { av_log(VAR_0->avctx, AV_LOG_ERROR, "  vp3:FUNC_0(): bad macroblock number (%d >= %d)\n",
VAR_6, VAR_0->macroblock_count); return 1; } if (VAR_5 == 7)
VAR_8 = get_bits(VAR_1, 3); else if(VAR_5 == 0)
VAR_8 = VAR_9
[get_vlc2(VAR_1, VAR_0->mode_code_vlc.table, 3, 3)]; else
VAR_8 = ModeAlphabet[VAR_5-1]
[get_vlc2(VAR_1, VAR_0->mode_code_vlc.table, 3, 3)]; VAR_0->macroblock_coding[VAR_6] = VAR_8; for (VAR_4 = 0; VAR_4 < 6; VAR_4++) { VAR_7 =
VAR_0->macroblock_fragments[VAR_6 * 6 + VAR_4]; if (VAR_7 == -1)
continue; if (VAR_7 >= VAR_0->fragment_count) { av_log(VAR_0->avctx, AV_LOG_ERROR, "  vp3:FUNC_0(): bad fragment number (%d >= %d)\n",
VAR_7, VAR_0->fragment_count); return 1; } if (VAR_0->all_fragments[VAR_7].coding_method !=
MODE_COPY)
VAR_0->all_fragments[VAR_7].coding_method =
VAR_8; } } } } return 0; }