XINTRA8

From MultimediaWiki
Jump to: navigation, search

An XIntra8 frame (also known as a J-type frame or J-frame) is a type of frame similar to an I-frame. They are used in Microsoft's MPEG-4 variation codec WMV2/WMV8 and the same coding method (with a different header) is used in WMV3 Complex Profile under the name "X8". XIntra8 frames are a type of intra frame (spatial prediction). This is why they are said to be similar to I-frames, because both B-frames and P-frames use inter-frame prediction (temporal prediction). XIntra8 frames operate on 8x8 pixel blocks. XIntra8 frame types are missing in WMV9. XIntra8 frames reportedly operate in 10 different modes (more information needed).

FFmpeg can now decode files containing Xintra8 frames, including those frames. If a stream contains Xintra8 frames the Xintra8 bit will be set in the stream's extradata.

Note: J-frame is the notation used by FFmpeg developers. The XMV SDK calls it XIntra8 frame and in WMV3 they are called Intra_X8.

The main differences between XIntra8-frames and I-frames:

  1. They are not derived from the MPEG-4 standard.
  2. The picture is coded as blocks, not as macroblocks.
  3. Each frame may use its own Huffman codes.

reference [1] (in German)

The patent describing the actual encoding and decoding method is US 7,263,232

Decoding

Overall decoding process:

 for(y = 0; y < blocks_height; y++){
   for(x = 0; x < blocks_width; x++){
     decode_block(luma, x, y);
     if ((x & 1) && (y & 1)){
       decode_block(chroma_u, x/2, y/2);
       decode_block(chroma_v, x/2, y/2);
     }
   }
 }

Huffman Decoding

When each type code is read for the first time, the reader checks if the VLC table is set. If not then it reads code lengths as nibbles and constructs a balanced tree from them.

Block Decoding

  1. Read "joint" code.
  2. Divide this code into two parts - DC value and block_coded bit.
  3. If block is coded then decode coefficients.
    1. Read code.
    2. Split read code into vector (value, skip, last).
    3. Skip skip coefficients and set coefficient value to value.
    4. If last is true then end decoding.

Decoding AC coefficient:

 vlc = read_vlc();
 base = some_table[vlc];
 if(!base) base = read_vlc();
 
 vlc =   0..15:  skip = 0; value = vlc;       last = 0;
 vlc = 16..19:  skip = 1; value = vlc-16; last = 0;
 vlc = 20..21:  skip = 2; value = vlc-20; last = 0;
 vlc =       22:  skip = 3; value = 0;         last = 0;
 vlc = 23..38:  skip = 0; value = vlc-23; last = 1;
 vlc = 39..42:  skip = 1; value = vlc-39; last = 1;
 vlc = 43..44:  skip = 2; value = vlc-43; last = 1;
 vlc =       45:  skip = 3; value = 0;         last = 1;
 vlc = 46..47:  skip = 0; value = Off0[vlc-46]+base; last = 0;
 vlc = 48..49:  skip = 1; value = Off0[vlc-46]+base; last = 0;
 vlc =     50:  skip = 0; value = Off0[vlc-46]+base; last = 0;
 vlc =     51:  skip = 1; value = Off0[vlc-46]+base; last = 0;
 vlc = 52..56:  skip = 0; value = Off0[vlc-46]+base; last = 0;
 vlc = 57..58:  skip = 0; value = Off0[vlc-46]+base; last = 0;
 vlc = 59..64:  skip = 0; value = Off1[vlc-59]+base; last = 1;
 vlc = 65..67:  skip = 1; value = Off1[vlc-59]+base; last = 1;
 vlc = 68..70:  skip = 0; value = Off1[vlc-59]+base; last = 1;
 vlc = 71..72:  skip = 1; value = Off1[vlc-59]+base; last = 1;
 vlc = 73..74:
  code = base & 3;
  base >>= 2;
  switch(code){
  case 0: skip = 2; value = base + 2;
  case 1: skip = 2; value = base + 3;
  case 2: skip = (base & 1)+3; value = (base>>1) + 3;
  case 3: skip = (base & 3)+5; value = (base>>2) + 3;
  }
  last = vlc - 73;
 else: skip = base>>7; value = (base>>1) & 0x3F; last = base & 1;

Tables

Arrays with the Huffman code lengths that WMV2 J-Frames use (not sure all are really used) in a sanitized form (decoder stores 2 per byte and with -1 offset). There are codes for values 0..11, 0..76 (these are used for AC decoding) and 0..33.

Huffman header:
index for code table: depends on number of code tables for mode (1, 2 or 3 bits)

gacCodeLengthsOrientLowRate[][] = {
    {2, 2, 3, 3, 3, 6, 5, 6, 6, 6, 6, 6},
    {1, 2, 3, 5, 5, 7, 6, 7, 7, 7, 7, 7}
};

gacCodeLengthsOrientHighRate[][] = {
    {1, 3, 3, 4, 4, 6, 5, 6, 6, 6, 6, 6},
    {5, 5, 5, 2, 2, 4, 5, 3, 4, 4, 5, 5},
    {2, 2, 3, 3, 3, 6, 6, 5, 6, 6, 6, 6},
    {3, 4, 4, 2, 2, 5, 5, 4, 5, 5, 5, 5}
};

gacCodeLengthsInterLowRate[][] = {
    {
      3,  4,  6,  6,  7,  6, 15,  8, 15,  9, 15,  9, 15, 15, 15, 14,
      5,  6,  9,  9,  7,  7,  9,  2,  3,  4,  4,  5,  6,  8,  7,  6,
      7,  8, 14,  7,  7,  7,  9,  5,  6,  9,  8,  9,  9, 14, 14, 14,
      8, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,  9, 14, 14, 14, 14,
     14, 14,  9, 14,  9, 14, 14, 14, 14,  9, 14, 14, 14
    },{
      3,  4,  4,  5,  6,  6,  6,  6,  7,  8,  8,  8,  8, 14, 10, 10,
      4,  5,  6,  7,  5,  6,  5,  4,  5,  5,  6,  6,  6,  6,  6,  7,
      8,  8,  7,  7,  7,  7,  8,  7,  7,  8,  8,  8, 14, 10,  9, 14,
      5,  9, 14, 14,  5,  8, 14, 14, 14,  6,  8,  7,  8,  9,  8, 14,
     14,  8,  9, 14, 14, 14, 14,  9, 14,  5,  8,  9, 14
    },{
      4,  5, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11,
     11, 11, 11, 11, 11, 11, 11,  1,  2,  5,  5,  5, 11, 11, 11, 11,
     11, 11, 11, 11, 11, 11, 11,  5, 11, 11, 11, 11, 11, 11, 11, 11,
     11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
     11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11
    },{
      8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
      8,  8,  8,  8,  8,  8,  8,  1,  8,  7,  7,  7,  7,  7,  7,  7,
      7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,
      7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,
      7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7
    },{
      9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
      9,  9,  9,  9,  9,  9,  8,  2,  1,  8,  8,  8,  8,  8,  8,  8,
      8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
      8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
      8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8
    },{
     10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
     10, 10, 10, 10,  9,  9,  9,  1,  3,  9,  9,  2,  9,  9,  9,  9,
      9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
      9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
      9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9
    },{
      2,  4,  5,  5,  6,  6,  7,  8,  8,  8,  9,  9, 10,  9, 10, 15,
      3,  5,  6,  6,  4,  7,  5,  5,  7,  7,  7,  8,  7,  7,  8,  8,
      8,  8,  8,  8,  8,  9,  8,  8,  8,  9, 15, 10, 10, 10, 15, 10,
      6,  9, 15, 15,  4,  6, 10, 15, 14,  6,  8, 14, 10, 14, 14, 14,
     14,  8, 10, 10, 14, 14, 14, 14, 14,  5, 10, 14, 14
    },{
      3,  4,  5,  5,  6,  8,  7,  6,  7, 13,  8,  8, 13, 13, 13,  8,
      4,  5,  7,  6,  6,  7,  6,  3,  5,  5,  4,  6,  6,  6,  5,  8,
      6,  6,  6,  6,  8,  8,  7,  5,  7,  7, 13,  7,  8, 13, 13, 13,
      7,  7, 13, 13,  8, 13, 13, 13, 13,  8, 13,  7,  8, 13, 13, 13,
     13,  8, 13, 13, 13, 13, 13,  8, 12,  6, 12, 12, 12
    }
};

gacCodeLengthsInterHighRate[][] = {
    {
      2,  3,  4,  5,  6,  7,  7,  7,  9,  8,  8,  8, 10, 10, 10, 10,
      4,  7,  9, 10,  6,  7,  7,  4,  4,  5,  5,  5,  6,  6,  6,  6,
      7,  7,  7,  7,  7,  7,  7,  8,  9, 10, 14, 14, 14, 14, 10, 14,
      9, 14, 14, 14,  8, 14, 14, 14, 14, 10, 14,  7,  8,  8,  9, 14,
     14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13
    },{
      3,  5,  7,  6,  6,  8,  8,  8, 14, 14,  7, 14, 14, 14, 14, 14,
      6,  8, 14,  8, 14, 14, 14,  2,  3,  5,  4,  4,  4,  6,  7,  7,
      7,  7,  8,  7,  6,  6,  6,  6,  8, 14,  8,  8,  8, 14, 14, 14,
      8, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13,  6, 13, 13, 13, 13,
     13,  7, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13
    },{
      2,  3,  3,  4,  5,  5,  6,  6,  7,  7,  7,  8,  8,  8,  9, 10,
      4,  6,  8,  9,  6,  9,  8,  5,  6,  6,  6,  7,  7,  7,  7,  7,
      7,  7,  7,  7,  7,  7,  8, 16, 16, 15, 12, 15, 15, 15,  8, 10,
      9, 12, 15, 15,  8, 15, 15, 15, 15,  9, 15,  7,  8,  8, 11, 12,
     15, 15, 15, 15, 15, 15, 15, 15, 15,  9, 15, 15, 15
    },{
      2,  3,  4,  5,  5,  6,  6,  7,  7,  8,  8,  9,  9,  9, 10, 10,
      3,  5,  7,  7,  4,  7,  5,  6,  7,  7,  7,  8,  8,  8,  8,  8,
      8,  9,  8,  8,  8,  9, 11, 10, 11, 15, 10, 15, 15, 15,  9, 11,
      7, 12, 15, 15,  5,  7,  8, 10, 11,  7, 10,  8,  8, 10, 10, 12,
     15, 11, 15, 15, 15, 15, 15, 15, 15,  7, 14, 12, 12
    },{
      3,  4,  4,  5,  6,  6,  6,  7,  6,  7,  8,  8,  8,  9,  9,  8,
      4,  5,  6,  6,  4,  6,  5,  5,  6,  6,  6,  6,  6,  6,  6,  7,
      7,  7,  7,  7,  7,  8, 11,  7,  7,  8,  9,  9,  9, 10,  9, 10,
      6,  8, 15, 15,  4,  7,  9, 15, 15,  6, 10,  7,  8,  8, 10,  9,
     15,  9, 10, 10, 10, 15, 14, 14, 14,  5,  9, 14, 14
    },{
      2,  4,  5,  5,  6,  6,  7,  8,  8,  8,  9, 11,  8, 10, 11, 15,
      3,  5,  6,  7,  4,  6,  5,  6,  7,  8,  7,  8,  7,  8,  7,  8,
      8,  9,  9,  9,  9,  9, 11,  9, 10, 11, 15, 10, 11, 11, 10, 11,
      6,  8, 15, 15,  4,  5,  7,  7,  9,  6,  8,  8, 10, 11, 15, 10,
     15, 10, 10, 15, 15, 14, 14, 14, 14,  5, 10, 11,  9
    },{
      2,  4,  5,  6,  6,  8,  9, 10, 10,  9, 15, 15, 10, 15, 10, 15,
      4,  5,  8,  8,  5,  9,  8,  3,  3,  4,  5,  6,  6,  7,  7,  7,
      8,  8,  9,  8, 10, 15,  9,  6,  6,  9, 10,  8,  8, 10, 15, 15,
      9, 15, 15, 15,  8, 15, 15, 15, 15,  9, 15,  9, 15, 15, 15, 15,
     15, 10, 10, 15, 15, 15, 15, 15, 15,  8, 14, 14, 14
    },{
      4, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
     11, 10, 10, 10, 10, 10, 10,  1,  2, 10,  4,  4, 10, 10, 10, 10,
     10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
     10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
     10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
   }
};

gacCodeLengthsIntraLowRate[][] = {
      3,  4,  5,  5,  5,  5,  6,  7,  6,  7,  8,  7,  7,  8,  8,  9,
      4,  6,  6,  7,  5,  8,  6,  4,  4,  5,  6,  6,  6,  6,  7,  7,
      7,  7,  7,  7,  7,  7,  7,  7,  7,  9,  9,  9, 11,  9,  6,  8,
      5,  7,  9,  9,  7, 10, 14, 14, 14,  7, 10,  7,  8,  9,  8,  7,
     14,  7,  7, 10, 10, 14, 14, 10, 14,  6,  9,  8, 14
    },{
      2,  4,  5,  5,  6,  7,  7,  7,  8,  9,  9,  9,  9, 15, 10, 11,
      3,  5,  6,  7,  4,  5,  4,  6,  7,  7,  8,  8,  7,  8,  9,  8,
      9,  9,  9,  9, 10, 11, 11,  9,  9, 11, 15, 10, 15, 15, 15, 15,
      6,  8, 15, 15,  4,  7,  8, 11, 15,  5,  8, 11, 10, 15, 15, 15,
     15,  9, 15, 14, 14, 14, 14, 14, 14,  5, 14, 14, 14
    },{
      3,  4,  4,  5,  6,  7,  6,  7,  9,  9,  8, 15,  9, 15, 15, 15,
      3,  5,  7,  7,  4,  6,  5,  4,  4,  5,  6,  6,  6,  6,  7,  8,
      7,  8, 10,  8,  9, 10, 10,  6,  7,  9,  9,  8, 10,  9, 15, 15,
      7,  9, 15, 15,  5,  8, 14, 14, 14,  6,  9,  9, 10, 10, 14, 14,
     14,  8, 14, 14, 10, 14, 14,  9, 14,  6,  8,  9, 14
    },{
      3,  4,  5,  5,  6,  6,  7,  7,  6,  6,  7,  7,  9,  9,  7,  8,
      5,  6,  9,  7,  6,  7,  7,  3,  3,  5,  5,  6,  6,  6,  7,  7,
      8,  8,  8,  8,  7,  6,  7,  7,  6,  8,  9, 14, 14, 14,  7,  9,
      7,  8, 14, 14,  8, 14, 13, 13, 13,  8, 13,  6,  7,  9,  6,  7,
     13,  7,  7, 13, 13, 13, 13, 13, 13,  8, 13,  9, 13
    },{
      2,  4,  5,  5,  6,  6,  7,  7,  7,  8,  9,  9, 10, 10, 10, 15,
      3,  5,  6,  7,  4,  6,  6,  4,  5,  6,  6,  6,  7,  7,  7,  7,
      8,  8,  8,  8,  8,  8, 10,  7,  8,  9,  9, 10, 10, 12, 10, 12,
      6,  8, 15, 15,  6,  9, 15, 15, 15,  7, 12, 10, 10, 15, 12, 11,
     15,  8,  9, 15, 12, 15, 15, 15, 14,  6, 12, 11, 14
    },{
      3,  4,  4,  5,  5,  6,  7,  8, 11,  9, 11, 10, 11, 15, 15, 15,
      4,  5,  6,  7,  5,  7,  6,  3,  4,  5,  5,  5,  5,  6,  6,  7,
      8,  8,  8,  7,  8,  9, 11,  5,  7,  8,  8,  7, 10,  9,  9, 15,
      7, 15, 15, 15,  7, 11, 15, 14, 14,  7, 14,  9, 10, 10,  9, 14,
     14,  8, 11, 14, 14, 14, 14,  9, 14,  7,  9, 14, 14
    },{
      3,  4,  4,  5,  5,  5,  5,  6,  7,  5,  7, 13,  7, 13,  7, 13,
      4,  6,  7,  7,  5,  7,  5,  6,  6,  7,  6,  7,  7, 13,  7,  7,
     13, 13, 12,  7,  7, 12, 12,  7, 12, 12, 12, 12, 12, 12,  5,  6,
      4,  5, 12,  7,  5, 12, 12, 12, 12,  6, 12,  6, 12, 12, 12, 12,
     12,  6, 12, 12, 12, 12, 12, 12, 12,  5, 12,  7, 12
    },{
      3,  4,  5,  6,  6,  8,  8,  8, 11, 15, 15, 15, 15, 15, 15, 15,
      4,  6,  7,  9,  5,  8,  8,  2,  3,  5,  5,  5,  6,  6,  8,  8,
      9,  8,  7,  8,  9, 11, 15,  5,  7,  8,  9,  8,  9,  9, 15, 15,
      8, 10, 15, 15,  8, 15, 15, 15, 15,  9, 15,  8,  9, 15, 15, 15,
     15,  9, 15, 15, 15, 15, 15, 10, 14,  7,  9, 14, 14
    }
};

gacCodeLengthsIntraHighRate[][] = {
    {
      3,  4,  4,  5,  6,  7,  6,  8,  8,  9, 10,  9,  9,  9, 15, 11,
      4,  5,  6,  7,  5,  7,  5,  3,  4,  5,  5,  5,  5,  6,  6,  7,
      8,  8,  8,  8,  8,  9, 10,  6,  7,  8,  8,  8, 11, 10, 11, 15,
      7, 14, 14, 14,  6, 10, 14, 14, 14,  7, 14,  8,  9, 11, 10, 11,
     14,  8, 10, 14, 14, 14, 14, 14, 14,  6,  9, 11, 14
    },{
      2,  3,  4,  5,  6,  6,  7,  8,  8,  8,  9,  9, 11, 11, 11, 11,
      3,  5,  6,  7,  4,  6,  4,  8,  9, 10,  9, 10, 10, 12, 10, 10,
     10, 10, 11, 12, 10, 12, 12, 15, 15, 15, 15, 14, 14, 14, 11, 11,
      8, 10, 12, 14,  4,  6,  7,  8, 10,  6,  8, 11, 10, 14, 11, 12,
     14, 14, 14, 14, 14, 14, 14, 14, 14,  6, 11, 11, 10
    },{
      3,  4,  5,  6,  7,  8,  8,  8, 10,  9, 10, 10, 16, 10, 10, 16,
      3,  5,  6,  8,  3,  5,  4,  7,  9,  9,  9,  9,  9, 10, 10, 10,
     10, 10, 10,  9, 10, 11, 16, 10, 11, 10, 11, 10, 16, 11, 15, 15,
      7,  9, 15, 15,  3,  4,  6,  6,  8,  5,  7, 15, 15, 15, 15, 11,
     15, 11, 11, 11, 15, 15, 15, 15, 15,  5, 11,  8,  8
    },{
      2,  3,  4,  4,  5,  5,  6,  6,  6,  6,  7,  7,  8,  8,  8,  9,
      4,  6,  7,  9,  6,  8,  7,  6,  6,  6,  6,  6,  7,  7,  7,  7,
      7,  7,  7,  7,  8,  8,  9, 11, 10, 15, 15, 15, 15, 15,  7,  8,
      8, 12,  9, 15,  7,  9, 15, 15, 15,  8, 11,  6,  7,  8,  8,  7,
      9, 11, 11, 15, 15, 15, 14, 14, 14,  8, 14, 14, 14
    },{
      2,  4,  5,  6,  6,  7,  7,  8,  8,  8,  9,  9, 10, 10, 14, 12,
      3,  5,  6,  7,  4,  6,  5,  5,  6,  6,  6,  7,  7,  8,  7,  8,
      8,  8,  8,  8,  9, 10, 10,  7,  8,  9,  9, 10, 11,  9,  9, 10,
      7,  8, 12, 12,  4,  6,  8,  8,  9,  6,  8,  9, 10, 10, 11, 10,
     11,  9,  9, 11, 11, 14, 14, 11, 14,  6,  9,  9, 10
    },{
      2,  3,  4,  5,  5,  6,  6,  7,  7,  7,  8,  8,  8,  9, 10,  9,
      3,  5,  7,  8,  5,  7,  6,  5,  6,  7,  7,  7,  8,  8,  7,  8,
      8,  8,  8,  8,  8,  9,  9, 11, 12, 12, 15, 13, 15, 15,  8,  9,
      8, 10,  9, 13,  5,  7,  9,  9, 15,  7, 11,  8,  8,  8,  9,  8,
     11, 12, 13, 15, 15, 15, 15, 15, 15,  7, 14, 11, 11
    },{
      3,  4,  4,  5,  5,  6,  6,  7,  8,  8,  8,  9,  9,  9, 11, 12,
      3,  5,  6,  7,  4,  6,  5,  4,  5,  6,  6,  7,  7,  7,  7,  7,
      7,  8,  8,  8,  9,  8, 10,  7,  8,  9, 11,  9, 10, 12,  9, 15,
      6,  7, 15, 15,  5,  7,  9, 11, 15,  6,  9,  8,  9, 10, 10, 11,
     15,  8,  9, 15, 15, 15, 14, 14, 14,  5, 10,  9, 14
    },{
      2,  4,  5,  6,  7,  7,  8,  8,  9,  9,  9, 10, 15, 15, 15, 15,
      3,  5,  6,  7,  4,  6,  4,  8,  8,  9, 10,  9, 10,  9, 10, 10,
     15, 10, 11, 11, 15, 10, 15,  9, 11, 15, 15, 11, 11, 15, 11, 15,
      7, 10, 15, 15,  3,  5,  7,  7,  9,  5,  7,  9, 11, 15, 14, 14,
     14,  9,  9, 14, 14, 14, 14, 14, 14,  5, 11,  8, 10
    }
};

gacCodeLengthsDCLowRate[][] = {
    { 5,  4,  4,  5,  5,  4,  5,  5,  7,  7, 12, 12, 12, 12, 12, 12, 12,
      3,  2,  3,  4,  5,  5,  7,  8, 12, 12, 12, 12, 12, 12, 12, 12, 12 },
    { 3,  3,  3,  4,  4,  3,  4,  4,  6,  7,  7, 11, 11, 11, 11, 11, 11,
      6,  4,  5,  5,  6,  5,  7,  7, 11,  7, 11, 11, 11, 11, 11, 10, 10 },
    { 7,  7,  6,  7,  6,  7,  8,  8, 13, 13, 13, 13, 13, 13, 13, 13, 12,
      1,  2,  3,  5,  6,  8, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 },
    { 4,  3,  3,  4,  4,  3,  3,  3,  5,  5,  7, 11, 11, 11, 11, 11, 11,
      5,  7,  6,  6,  7,  7,  7,  7, 11, 11, 11,  7, 11, 11, 11, 10, 10 },
    { 8,  7,  7,  7,  9,  8,  9, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13,
      2,  1,  3,  4,  6,  7,  9, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13 },
    { 7,  7,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
      6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  1,  6,  6,  6,  6,  6,  6 },
    { 5,  4,  5,  5,  6,  5,  6,  6,  8,  8, 13, 13, 13, 13, 13, 13, 13,
      2,  2,  3,  4,  5,  5,  8,  9, 13, 13, 13, 13, 13, 13, 13, 13, 13 },
    { 7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,
      1,  2,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7 }
};

gacCodeLengthsDCHighRate[][] = {
    { 5,  4,  5,  5,  5,  5,  6,  6,  8,  8, 13, 13, 13, 13, 13, 13, 13,
      2,  2,  3,  4,  5,  6,  8,  9, 13, 13, 13, 13, 13, 13, 13, 13, 13 },
    { 4,  3,  3,  4,  4,  3,  4,  3,  4,  4,  5,  6,  9,  9, 13, 13, 13,
      6,  6,  6,  7,  9,  7,  8,  9, 13, 13, 13, 12, 12,  9, 12, 12, 12 },
    { 4,  3,  3,  4,  4,  4,  4,  4,  6,  6,  7,  7, 12, 12, 12, 12, 12,
      4,  3,  4,  5,  6,  6,  7,  8, 12, 12, 12, 12, 12, 12, 12, 11, 11 },
    { 4,  2,  3,  3,  3,  3,  4,  4,  6,  6,  7,  8, 14, 14, 14, 14, 13,
      9,  7,  8,  8, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13 },
    { 7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,
      1,  2,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7 },
    { 5,  4,  5,  6,  6,  6,  7,  6,  7,  6,  8,  7,  8, 13, 13, 13, 13,
      3,  1,  3,  7,  8,  9, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12 },
    { 4,  2,  3,  3,  4,  4,  5,  6,  7,  7,  8, 14, 14, 10,  9, 14, 14,
      4,  3,  5,  6,  8,  8, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13 },
    { 6,  6,  6,  7,  7,  6,  6,  6,  7,  8,  8,  9, 10, 14, 14, 14, 14,
      1,  2,  4,  5,  6,  7,  8, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13 }
};

ReconstructionLevels[64] = {
    256,256,256,256,256,256,259,262,
    265,269,272,275,278,282,285,288,
    292,295,299,303,306,310,314,317,
    321,325,329,333,337,341,345,349,
    353,358,362,366,371,375,379,384,
    389,393,398,403,408,413,417,422,
    428,433,438,443,448,454,459,465,
    470,476,482,488,493,499,505,511,
};