Difference between revisions of "Delphine CIN"

From MultimediaWiki
Jump to navigation Jump to search
 
m (link to samples)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
* Extension: cin
* Extension: cin
* Company: [[Delphine Software International]]
* Company: [[Delphine Software International]]
* Samples: http://samples.mplayerhq.hu/game-formats/delphine_cin/


Delphine CIN is an [[FMV]] format used in the DOS version of the game [http://www.mobygames.com/game/fade-to-black Fade To Black].
Delphine CIN is an [[FMV]] format used in the DOS version of the game [http://www.mobygames.com/game/fade-to-black Fade To Black].
The CIN files contains both video and audio data with custom compression methods.
== Container Format ==
The layout of a CIN file is :
  struct FileHeader
  foreach AnimationFrame {
    struct FrameHeader
    byte PaletteData[]
    byte VideoData[]
    byte AudioData[]
  }
All data stored in the file and frame headers is in little endian.
== File Header ==
  bytes  0- 3 - file signature marker (0x55AA0000)
  bytes  4- 7 - maximum size of a video frame
  bytes  8- 9 - video frame width
  bytes 10-11 - video frame height
  bytes 12-15 - audio frame frequency (always 22050)
  byte    16 - number of audio frame bits (always 16)
  byte    17 - 0 = mono, 1 = stereo (always stereo)
  bytes 18-19 - maximum size of a sound frame
== Frame Header ==
  byte      0 - video frame type
  byte      1 - audio frame type
  bytes  2- 3 - number of palette colors
  bytes  4- 7 - video frame size
  bytes  8-11 - audio frame size
  bytes 12-15 - frame marker (0xAA55AA55)
== Video Frame Types ==
The video frame type field in the frame header specifies which set of decompression routines to use.
type  9 - RLE decode
type 34 - RLE decode, delta frame
type 35 - Huffman decode, RLE decode
type 36 - Huffman decode, RLE decode, delta frame
type 37 - Huffman decode
type 38 - LZSS decode
type 39 - LZSS decode, delta frame
== Video Frame Decoders ==
=== RLE Decoding ===
The following code is executed until end of data is reached :
 
  code = get next byte
  if (code & 0x80) repeat (code - 0x7f) times the following byte value
  else copy the following (code) bytes
=== Huffman Decoding ===
The first operation is to get the code_table :
  code_table = get first 15 bytes
Then, the following code is executed until end of data is reached :
  code = get next byte
  if (code >> 4) == 15 {
    b = get next byte
    output (code << 4) | (b >> 4)
    code = b & 15
  } else {
    output code_table[code >> 4]
    code &= 15
  }
  if code == 15 {
    b = get next byte
    output b
  } else {
    output code_table[code >> 4]
  }
=== Delta Frame Decoding ===
Source bytes are just added to destination bytes.
=== LZSS Decoding ===
The following code is executed until end of data is reached :
  code = get_next_byte
  foreach (bit in code) {
    if (bit is set) {
      b = get next byte
      output b
    } else {
      cmd = get next word le
      offset = cmd >> 4
      size = (cmd & 15) + 2
      copy 'size' bytes from (dst - offset - 1) to dst
      // note: buffer overlapping is (ab)used to repeat bytes
    }
== Audio Frame Types ==
The audio frame type is always equal to 1, which represents 22 KHz, 16 bits mono [[DPCM]].
The deltas are given by a geometric sequence with a multiplier equal to 32767 ^ (1 / 128).


[[Category:Video Codecs]]
[[Category:Video Codecs]]
[[Category:Game Formats]]
[[Category:Game Formats]]

Latest revision as of 22:30, 30 March 2008

Delphine CIN is an FMV format used in the DOS version of the game Fade To Black.

The CIN files contains both video and audio data with custom compression methods.

Container Format

The layout of a CIN file is :

 struct FileHeader
 foreach AnimationFrame {
   struct FrameHeader
   byte PaletteData[]
   byte VideoData[]
   byte AudioData[]
 }

All data stored in the file and frame headers is in little endian.

File Header

 bytes  0- 3 - file signature marker (0x55AA0000)
 bytes  4- 7 - maximum size of a video frame
 bytes  8- 9 - video frame width
 bytes 10-11 - video frame height
 bytes 12-15 - audio frame frequency (always 22050)
 byte     16 - number of audio frame bits (always 16)
 byte     17 - 0 = mono, 1 = stereo (always stereo)
 bytes 18-19 - maximum size of a sound frame

Frame Header

 byte      0 - video frame type
 byte      1 - audio frame type
 bytes  2- 3 - number of palette colors
 bytes  4- 7 - video frame size
 bytes  8-11 - audio frame size
 bytes 12-15 - frame marker (0xAA55AA55)

Video Frame Types

The video frame type field in the frame header specifies which set of decompression routines to use.

type  9 - RLE decode
type 34 - RLE decode, delta frame
type 35 - Huffman decode, RLE decode
type 36 - Huffman decode, RLE decode, delta frame
type 37 - Huffman decode
type 38 - LZSS decode
type 39 - LZSS decode, delta frame

Video Frame Decoders

RLE Decoding

The following code is executed until end of data is reached :

 code = get next byte
 if (code & 0x80) repeat (code - 0x7f) times the following byte value
 else copy the following (code) bytes


Huffman Decoding

The first operation is to get the code_table :

 code_table = get first 15 bytes

Then, the following code is executed until end of data is reached :

 code = get next byte
 if (code >> 4) == 15 {
   b = get next byte
   output (code << 4) | (b >> 4)
   code = b & 15
 } else {
   output code_table[code >> 4]
   code &= 15
 }
 if code == 15 {
   b = get next byte
   output b
 } else {
   output code_table[code >> 4]
 }


Delta Frame Decoding

Source bytes are just added to destination bytes.


LZSS Decoding

The following code is executed until end of data is reached :

 code = get_next_byte
 foreach (bit in code) {
   if (bit is set) {
     b = get next byte
     output b
   } else {
     cmd = get next word le
     offset = cmd >> 4
     size = (cmd & 15) + 2
     copy 'size' bytes from (dst - offset - 1) to dst
     // note: buffer overlapping is (ab)used to repeat bytes
   }


Audio Frame Types

The audio frame type is always equal to 1, which represents 22 KHz, 16 bits mono DPCM.

The deltas are given by a geometric sequence with a multiplier equal to 32767 ^ (1 / 128).