static inline int svq3_decode_block(GetBitContext *gb, DCTELEM *block,

                                    int index, const int type)

{

    static const uint8_t *const scan_patterns[4] =

    { luma_dc_zigzag_scan, zigzag_scan, svq3_scan, chroma_dc_scan };



    int run, level, sign, vlc, limit;

    const int intra = (3 * type) >> 2;

    const uint8_t *const scan = scan_patterns[type];



    for (limit = (16 >> intra); index < 16; index = limit, limit += 8) {

        for (; (vlc = svq3_get_ue_golomb(gb)) != 0; index++) {



          if (vlc == INVALID_VLC)

              return -1;



          sign = (vlc & 0x1) - 1;

          vlc  = (vlc + 1) >> 1;



          if (type == 3) {

              if (vlc < 3) {

                  run   = 0;

                  level = vlc;

              } else if (vlc < 4) {

                  run   = 1;

                  level = 1;

              } else {

                  run   = (vlc & 0x3);

                  level = ((vlc + 9) >> 2) - run;

              }

          } else {

              if (vlc < 16) {

                  run   = svq3_dct_tables[intra][vlc].run;

                  level = svq3_dct_tables[intra][vlc].level;

              } else if (intra) {

                  run   = (vlc & 0x7);

                  level = (vlc >> 3) + ((run == 0) ? 8 : ((run < 2) ? 2 : ((run < 5) ? 0 : -1)));

              } else {

                  run   = (vlc & 0xF);

                  level = (vlc >> 4) + ((run == 0) ? 4 : ((run < 3) ? 2 : ((run < 10) ? 1 : 0)));

              }

          }



          if ((index += run) >= limit)

              return -1;



          block[scan[index]] = (level ^ sign) - sign;

        }



        if (type != 2) {

            break;

        }

    }



    return 0;

}

static inline int svq3_decode_block(GetBitContext *gb, DCTELEM *block,

                                    int index, const int type)

{

    static const uint8_t *const scan_patterns[4] =

    { luma_dc_zigzag_scan, zigzag_scan, svq3_scan, chroma_dc_scan };



    int run, level, sign, vlc, limit;

    const int intra = (3 * type) >> 2;

    const uint8_t *const scan = scan_patterns[type];



    for (limit = (16 >> intra); index < 16; index = limit, limit += 8) {

        for (; (vlc = svq3_get_ue_golomb(gb)) != 0; index++) {



          if (vlc == INVALID_VLC)

              return -1;



          sign = (vlc & 0x1) - 1;

          vlc  = (vlc + 1) >> 1;



          if (type == 3) {

              if (vlc < 3) {

                  run   = 0;

                  level = vlc;

              } else if (vlc < 4) {

                  run   = 1;

                  level = 1;

              } else {

                  run   = (vlc & 0x3);

                  level = ((vlc + 9) >> 2) - run;

              }

          } else {

              if (vlc < 16) {

                  run   = svq3_dct_tables[intra][vlc].run;

                  level = svq3_dct_tables[intra][vlc].level;

              } else if (intra) {

                  run   = (vlc & 0x7);

                  level = (vlc >> 3) + ((run == 0) ? 8 : ((run < 2) ? 2 : ((run < 5) ? 0 : -1)));

              } else {

                  run   = (vlc & 0xF);

                  level = (vlc >> 4) + ((run == 0) ? 4 : ((run < 3) ? 2 : ((run < 10) ? 1 : 0)));

              }

          }



          if ((index += run) >= limit)

              return -1;



          block[scan[index]] = (level ^ sign) - sign;

        }



        if (type != 2) {

            break;

        }

    }



    return 0;

}

static inline int FUNC_0(GetBitContext *VAR_0, DCTELEM *VAR_1,

                                    int VAR_2, const int VAR_3)

{

    static const uint8_t *const VAR_4[4] =

    { luma_dc_zigzag_scan, zigzag_scan, svq3_scan, chroma_dc_scan };



    int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;

    const int VAR_10 = (3 * VAR_3) >> 2;

    const uint8_t *const VAR_11 = VAR_4[VAR_3];



    for (VAR_9 = (16 >> VAR_10); VAR_2 < 16; VAR_2 = VAR_9, VAR_9 += 8) {

        for (; (VAR_8 = svq3_get_ue_golomb(VAR_0)) != 0; VAR_2++) {



          if (VAR_8 == INVALID_VLC)

              return -1;



          VAR_7 = (VAR_8 & 0x1) - 1;

          VAR_8  = (VAR_8 + 1) >> 1;



          if (VAR_3 == 3) {

              if (VAR_8 < 3) {

                  VAR_5   = 0;

                  VAR_6 = VAR_8;

              } else if (VAR_8 < 4) {

                  VAR_5   = 1;

                  VAR_6 = 1;

              } else {

                  VAR_5   = (VAR_8 & 0x3);

                  VAR_6 = ((VAR_8 + 9) >> 2) - VAR_5;

              }

          } else {

              if (VAR_8 < 16) {

                  VAR_5   = svq3_dct_tables[VAR_10][VAR_8].VAR_5;

                  VAR_6 = svq3_dct_tables[VAR_10][VAR_8].VAR_6;

              } else if (VAR_10) {

                  VAR_5   = (VAR_8 & 0x7);

                  VAR_6 = (VAR_8 >> 3) + ((VAR_5 == 0) ? 8 : ((VAR_5 < 2) ? 2 : ((VAR_5 < 5) ? 0 : -1)));

              } else {

                  VAR_5   = (VAR_8 & 0xF);

                  VAR_6 = (VAR_8 >> 4) + ((VAR_5 == 0) ? 4 : ((VAR_5 < 3) ? 2 : ((VAR_5 < 10) ? 1 : 0)));

              }

          }



          if ((VAR_2 += VAR_5) >= VAR_9)

              return -1;



          VAR_1[VAR_11[VAR_2]] = (VAR_6 ^ VAR_7) - VAR_7;

        }



        if (VAR_3 != 2) {

            break;

        }

    }



    return 0;

}

static inline int FUNC_0(GetBitContext *VAR_0, DCTELEM *VAR_1,
int VAR_2, const int VAR_3)
{ static const uint8_t *const VAR_4[4] =
{ luma_dc_zigzag_scan, zigzag_scan, svq3_scan, chroma_dc_scan }; int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9; const int VAR_10 = (3 * VAR_3) >> 2; const uint8_t *const VAR_11 = VAR_4[VAR_3]; for (VAR_9 = (16 >> VAR_10); VAR_2 < 16; VAR_2 = VAR_9, VAR_9 += 8) { for (; (VAR_8 = svq3_get_ue_golomb(VAR_0)) != 0; VAR_2++) { if (VAR_8 == INVALID_VLC)
return -1; VAR_7 = (VAR_8 & 0x1) - 1; VAR_8  = (VAR_8 + 1) >> 1; if (VAR_3 == 3) { if (VAR_8 < 3) { VAR_5   = 0; VAR_6 = VAR_8; } else if (VAR_8 < 4) { VAR_5   = 1; VAR_6 = 1; } else { VAR_5   = (VAR_8 & 0x3); VAR_6 = ((VAR_8 + 9) >> 2) - VAR_5; } } else { if (VAR_8 < 16) { VAR_5   = svq3_dct_tables[VAR_10][VAR_8].VAR_5; VAR_6 = svq3_dct_tables[VAR_10][VAR_8].VAR_6; } else if (VAR_10) { VAR_5   = (VAR_8 & 0x7); VAR_6 = (VAR_8 >> 3) + ((VAR_5 == 0) ? 8 : ((VAR_5 < 2) ? 2 : ((VAR_5 < 5) ? 0 : -1))); } else { VAR_5   = (VAR_8 & 0xF); VAR_6 = (VAR_8 >> 4) + ((VAR_5 == 0) ? 4 : ((VAR_5 < 3) ? 2 : ((VAR_5 < 10) ? 1 : 0))); } } if ((VAR_2 += VAR_5) >= VAR_9)
return -1; VAR_1[VAR_11[VAR_2]] = (VAR_6 ^ VAR_7) - VAR_7; } if (VAR_3 != 2) { break; } } return 0; }