Psygnosis YOP

From MultimediaWiki
(Redirected from YOP)
Jump to navigation Jump to search

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

For each frame:

+  0 UI32  Unknown_0           -- unused/ignored, some length?
+  4 RGB   Palette[PalColors]  -- palette part for this frame, 6 bits per component
+xxx UI8   Sound[SoundLen]     -- ADPCM-encoded sound data, mono, 22050Hz, 1840 samples per frame
+yyy UI8   Video[...]          -- encoded video data, variable length
+zzz UI8   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.