Motion Pixels

From MultimediaWiki
Revision as of 07:14, 8 March 2009 by Compn (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Motion Pixels version 1 (MVI1) was used in a single PC game, Treasure Quest while version 2 (MVI2) was used in a number of Movie CDs. All of these items were published by Sirius Publishing and the Motion Pixels codec is believed to still be owned by the company's CEO, Richard Gnant.

MVI belongs to the "old-school" family of video codecs and relies on interframe differences and adaptive delta-coding for horizontal lines of the picture. Delta coefficients are additionally Huffman-packed. For better compression at the cost of picture quality additional colorspace downsampling may be used. MVI2 adds smoother delta-coding and the ability to dynamically change downsampling for each frame.

Compressed MVI1 video may be carried in the custom MVI Container format.

Documentation Notes

As MVI2 version is merely an addition to MVI1, both formats will be documented together, where MVI2-specific features will be marked with V2 symbol.

MVI Codec

Compression Flags

When video is packaged inside AVI files, all vital codec's parameters carried in BITMAPINFOHEADER's biCompression field of the video stream. These flag bits are:

  • 0..3 (0x000F) - Colorspace Format (see below)
  • V2 9 (0x0200) - ...
  • V2 10 (0x0400) - ...
  • 11 - (0x0800) ...
  • 12 - (0x1000) Still-Frame mode
  • 13 - (0x2000) Frames are upside-down
  • 14 - (0x4000) Video was encoded using trial version of the codec (this flag tells original decoder to put watermark to the frame)
  • 15 - (0x8000) Image is interlaced (single-field, in MP's terminology), only odd lines carried

Colorspace Formats

Output always RGB, but as an extra compression feature, source image may be initially converted to one of listed formats:

  • 0 - RGB
  • 1 - YUV 4:2:2
  • 2 - YUV 4:1:1
  • 3 - YUV 8:1:1
  • 4 - YUV 16:1:1

Normal mode VS Still-Frame mode

When videos with small amount of changes encoded (ex, 'talking heads' or some static scenery) special trick may be performed. Very first frame contains all the scenery, while all successive frames take this first frame as a base and add neccessary changes to it. The tricky part is, that first frame contains such a 'change-frame' as well, so you have two logical frames in one physical. Offset to the base frame is located at (biSizeImage - 4) in the encoded data buffer. Change-frame located at it's start.

Bit Reader

Compressed data stored using binary stream. Bitreader operates with internal 32-bits queue and pops bits starting from the highest. TODO : Add sample


General Frame Structure

  • Frame Flags
  • Mask Block
  • Motion Block
  • Fill Block
  • V2 Extra Block
  • Deltas Bundle
    • Initial Position
    • Color Deltas
    • Huffman Tree
    • Packed Deltas Indicies

Frame Flags

Each frame begins with sequence of local flag bits. These bits are:

# of bits Present if Name Description
1 always KeyframeFlag Non-zero if this frame is a key frame (for Still-Frame mode this DOES NOT mean base frame change!)
V2 3 flags bit 9 ColorSpace Colorspace Format for this frame
V2 1 flags bit 9 ... ...
V2 1 flags bit 9 SmoothDeltas Use smooth delta-coding
V2 1 flags bit 9 HaveSerial (see next field)
V2 20 flags bit 9 + HaveSerial SerialNumber Encoder's serial number
V2 1 flags bit 9 ... ...
V2 8 flags bit 10 ... ...
V2 8 flags bit 10 ... ...

Mask Block

Mask block contains changes since the last frame. There are two types of masks - general masks, which tell what rectangular area has changed since last frame, and fill masks, which also specify colour value to fill that rectangle. If bit (buf[1]&2) is set then general masks are present along with fill mask, otherwise only fill masks are present.

Masks bistream:

   12 bits     count of masks with dimensions <= 256x256
   12 bits     count of masks with dimensions <= 16x16

Mask data is stored as <offset, width, height, [color]>. Offset size = ceil(log2(frame width * frame height)), width and height take 4 or 8 bits depending on mask max dimension, color value is present only for fill masks and takes 15 bits.

Motion Block

Fill Block

Extra Block

Color Deltas Bundle

Assembling the Frame