BMV: Difference between revisions

From MultimediaWiki
Jump to navigation Jump to search
Line 46: Line 46:
Each blob contains a byte with multipliers and actual data. Two multipliers are stored in a single byte which is cyclically rotated left by one  
Each blob contains a byte with multipliers and actual data. Two multipliers are stored in a single byte which is cyclically rotated left by one  


   mult_table[16] = { 16512, 8256, 4128, 2064, 1032, 516, 258, 192, 217, 129, 88, 64, 56, 48, 40, 36, 32 }
   mult_table[16] = { 16512, 8256, 4128, 2064, 1032, 516, 258, 192, 129, 88, 64, 56, 48, 40, 36, 32 }


   t = get_byte();
   t = get_byte();

Revision as of 00:08, 3 December 2008

  • Extensions: bmv
  • Company: Teeny Weeny Games

BMV is the file extension for FMV used in Discworld 2 and Discworld 3 games, actual format differs for them.

Discworld 2 BMV

Container format

File has no header and consists of series of packets. Each packet starts with the byte showing its type and except NOP and END packets all other packets have 24-bit little-endian length field.

Packet type meaning:

 0x00    NOP
 0x01    END
 0x02    Inter frame
 0x03    Intra frame
 
Frame types can additionally have a set of flags:
 0x04   packet contains scroll offset
 0x08   palette is included
 0x10   commands (e.g. for subtitles)
 0x20   audio is present
 0x40   extended mode
 0x80   text is present (for command)

Data is stored in this order:

 audio (3675 bytes for old audio block, 1 + blobs*65 for newer one)
 commands
 palette (768 bytes)
 screen offset (2 bytes)
 picture data

Since text string are loaded from game resources, it is not described here.

Video

Video is packed like RLE.

Audio

Audio is decoded per blobs. Each blob contains a byte with multipliers and actual data. Two multipliers are stored in a single byte which is cyclically rotated left by one

 mult_table[16] = { 16512, 8256, 4128, 2064, 1032, 516, 258, 192, 129, 88, 64, 56, 48, 40, 36, 32 }
 t = get_byte();
 t = (t >> 1) | ((t & 0x1) << 7);
 mul1 = mult_table[t & 0xF];
 mul2 = mult_table[t >> 4];
Audio is decoded by fetching byte, multiplying it by mul1 or mul2 (even samples - by mul1, odd samples - by mul2) and dividing by 32:
 int8_t *src;
 for(i = 0; i < 64; i += 2){
   outsamples[i  ] = (*src++ * mul1) >> 5;
   outsamples[i+1] = (*src++ * mul2) >> 5;
   blobsize--;
 }