Difference between revisions of "Psygnosis YOP"

From MultimediaWiki
Jump to navigation Jump to search
(general edits)
m (→‎File Format: spelling)
Line 16: Line 16:
 
  +  7 byte  FrameSize          -- size of the single frame chunk in sectors (2048 bytes per sector)
 
  +  7 byte  FrameSize          -- size of the single frame chunk in sectors (2048 bytes per sector)
 
  +  8 word  Width              -- frame width
 
  +  8 word  Width              -- frame width
  +  A word  Heigth             -- frame height
+
  +  A word  Height             -- frame height
 
  +  C byte  PalColors          -- number of colors in palette per frame '''see notes'''
 
  +  C byte  PalColors          -- number of colors in palette per frame '''see notes'''
 
  +  D byte  FirstColor1        -- first color to update for odd frames (counting from 1)
 
  +  D byte  FirstColor1        -- first color to update for odd frames (counting from 1)

Revision as of 23:50, 3 March 2008

YOP is an FMV video format used in the computer game The City of the Lost Children by Psygnosis. The format uses very primitive pattern-based video compression and stock IMA ADPCM sound encoding.

File Format

A YOP file begins with the following 2048-bytes header:

+  0 word  Signature           -- "YO"
+  2 byte  Unknown_2           -- unused, but set to 1. Perhaps format version
+  3 byte  Unknown_3           -- unused, can be either 0 or 1. Format version minor?
+  4 word  NumFrames           -- number of frames
+  6 byte  Unknown_6           -- framerate?
+  7 byte  FrameSize           -- size of the single frame chunk in sectors (2048 bytes per sector)
+  8 word  Width               -- frame width
+  A word  Height              -- frame height
+  C byte  PalColors           -- number of colors in palette per frame see notes
+  D byte  FirstColor1         -- first color to update for odd frames (counting from 1)
+  E byte  FirstColor2         -- first color to update for even frames (counting from 1)
+  F byte  Unknown_C[3]        -- unused/zero
+ 12 word  SoundLen            -- size of the audio block for frame
+ 14 byte  Unknown_14[]        -- unknown/unused/padding to the next sector's boundary
+800 FRAME Frames[NumFrames]   -- video frames

For each frame:

+  0 dword Unknown_0           -- unused/ignored, some length?
+  4 RGB   Palette[PalColors]  -- palette part for this frame, 6 bits per component
+xxx byte  Sound[SoundLen]     -- ADPCM-encoded sound data, mono, 22050Hz, 1840 samples per frame
+yyy byte  Video[...]          -- encoded video data, variable length
+zzz byte  Padding[...]        -- unused/padding
---- total frame size is FrameSize * 2048

Notes

  • All multi-byte numbers are little-endian.
  • Both file header and each frame chunk are aligned/padded to 2048-byte boundaries.
  • Frame chunks have a fixed size (FrameSize * 2048), even if the actual payload size is much smaller.
  • Each frame comes with its own palette part, updating PalColors entries starting from FirstColor1 for odd and FirstColor2 for even frames respectively.
  • The IMA ADPCM audio decoding context (predictor and step index) is initialized to zero at the beginning of the playback and maintained across successive frames.

Video Compression

A video frame is broken into 2x2 macroblocks and each macroblock is decoded using the following algorithm:

tag = next nibble
tag is:
  0 : abcd
  1 : abca
  2 : abcb
  3 : abcc
  4 : abac
  5 : abaa
  6 : abab
  7 : abbc
  8 : aabc
  9 : aaba
  A : abba
  B : aabb
  C : aaab
  D : aaaa
  E : abbb
  F : read next tag and copy previously drawn block located at the following coordinates (in pixels) relative to the current block:
  tag is:
    0 : -4:-4
    1 : -2:-4
    2 :  0:-4
    3 :  2:-4
    4 : -4:-2
    5 : -4: 0
    6 : -3:-3
    7 : -1:-3
    8 :  1:-3
    9 :  3:-3
    A : -3:-1
    B : -2:-2
    C :  0:-2
    D :  2:-2
    E :  4:-2
    F : -2: 0
  • abcc means "read byte a and use it to paint pixel 1 (top left), read byte b and paint pixel 2 (top right), read byte c and paint pixel 3 (bottom left) and pixel 4 (bottom right)".
  • Tags are 4-bit nibbles, processed starting from the high one (bits 4..7), then lower (bits 0..3). However, complete bytes are consumed from the bytesteam, thus pixel bytes do not overlap with the tags.