EZFlix

From MultimediaWiki
Jump to navigation Jump to search

EZFlix is a video codec created for 3DO console. It supports video resolution in up to 320x240 in multiples of 16. The reverse-engineered decoder can be found here.

The data is converted into YUV420 format, split into stripes 16 pixels high, delta compressed using prediction and deltas are coded with some fixed Huffman codebook.

Data organisation

Each frame is split into components, each one is stored in its own part of frame using one of the possible Huffman codebooks. Each component is coded in strips of widthx4 elements, six pixels in top left corner as well as six pixels in bottom right corner are coded together (so that the decoder can use SWAR for predicting all four rows of pixels simultaneously). Decoding is performed by decoding quantised delta values, adding them to the predicted data, converting output to RGB and outputting it.

Prediction

Predicted value is calculated like T + L + (T + L)/2 - TL and then it is averaged with the delta. Default top value is 64.

YUV to RGB conversion

 R' = (Y + V) & 0x7F
 G' = (Y + 0x60 - (V >> 1) - (U >> 2)) & 0x7F
 B' = (Y + U) & 0x7F

Then the values are expanded using the following gamma table:

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  3,  4,
   5,  7,  8,  9, 10, 12, 13, 15, 17, 19, 20, 22, 24, 26, 28, 30,
  32, 34, 36, 38, 40, 43, 45, 47, 49, 51, 53, 56, 58, 60, 63, 65,
  67, 70, 72, 74, 77, 79, 82, 84, 87, 89, 92, 94, 97, 99,102,104,
 107,109,112,115,117,120,122,125,128,130,133,136,139,141,144,147,
 150,152,155,158,161,164,166,169,172,175,178,181,183,186,189,192,
 195,198,201,204,207,210,213,216,219,222,225,228,231,234,237,240,
 243,246,249,252,255,255,255,255,255,255,255,255,255,255,255,255,
 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255

Huffman codebooks

  • tree 0: 0, 10, 110, 1110, 1111
  • tree 1: 00, 01, 10, 11
  • tree 2 is unused;
  • tree 3: 0, 10, 11
  • tree 4: 0, 10, 110, 111
  • tree 5: 0, 100, 101, 110, 111
  • tree 6: 00, 01, 10, 110, 111
  • tree 7: 0, 10, 110, 1110, 11110, 11111
  • tree 8: 0, 10, 1100, 1101, 1110, 1111
  • tree 9: 0, 100, 101, 110, 1110, 1111
  • tree 10: 00, 01, 10, 110, 1110, 1111
  • tree 11: 00, 01, 100, 101, 110, 111
  • tree 12: same as tree 3 but with the second set of symbols
  • tree 13: same as tree 10
  • tree 14: same as tree 0

Each streams has 3-6 symbols values mapped to its codebook values transmitted in the frame header. For trees 0-12 those symbols should be additionally multiplied by two.