模拟城市中文网

 找回密码
 入住
搜索
查看: 2856|回复: 7

EA MAD文件格式分析

[复制链接]
发表于 2010-1-27 16:37 | 显示全部楼层 |阅读模式
之前lrdcq也发过关于MAD的文件格式,点我
今天在逛ST SM论坛,无意的发现了以下的东西

来自:http://wiki.multimedia.cx/index.php?title=Electronic_Arts_MAD
          有兴趣想研究其他格式的可以来这里看
          http://wiki.multimedia.cx/index.php?title=Electronic_Arts_Formats

正文:





MAD is a video codec used in various games published by companies under the Electronic Arts umbrella. The codec is an evolution of the earlier TGQ and TQI codecs, adding motion compensation and low-quality frame concepts. MAD is an abbreviation for "Madcow Movie".


See Electronic Arts Formats for file format description. Each MADk, MADm and MADe chunk corresponds to a video frame, where MADk is an intra-frame, MADm is an inter-frame and MADe is a low-quality-inter frame. Low-quality-inter frames are identical to inter frames, but are not used for motion compensation and are discarded immediately after presentation. Each frame is divided into 16x16 pixel macroblocks, with each macroblock further divided into with four 8x8 luma and two half-resolution 8x8 chroma blocks. Standard MPEG-1 block ordering is used.
Each chunk begins with a 16 byte header, followed by a bitstream. Symbols within the header are encoded using 16-bit little-endian most-to-least-significant bit packing. <FIXME: explain bit packing>. Although frame type is reported within the header, the field is not valid in some samples, and is therefore unreliable. Frame type should be inferred from the chunk type.

  1.    Offset   Data_type   Name         Description
  2.    0x0000   four bytes  unknown      always zero
  3.    0x0000   le_u16      unknown
  4.    0x0006   le_u16      frame_rate   milliseconds per frame
  5.    0x0008   le_u16      width        image width (pixels)
  6.    0x000a   le_u16      height       image height (pixels)
  7.    0x000c   u8          unknown
  8.    0x000d   u8          quantizer    frame quantizer
  9.    0x000e   u8          frame_type   not valid for all samples
  10.    0x000f   u8          unknown
  11.    for each vertical macroblock
  12.        for each horizontal macroblock
  13.            decode_mb
复制代码
Macroblock composition is based on a 6-bit block type, where each bit indicates the type of an 8x8 block within macroblock. The least-significant-bit corresponds to the first block. A clear bit indicates an intra-block, and a set bit indicates a motion-compensated block.
For intra frames, the block type is assumed to be all clear. For inter and low-quality inter frames, the block type is derived from a VLC. If the block type is none zero, then a full-pel motion vector is read from the bitstream. A description of the block_type VLC and decoding algorithm is provided below.
  1. if (intra frame)
  2. block_type = 000000b
  3. else // inter or low-quality-inter frame
  4. switch get_vlc()
  5. case 1b : block_type = 111111b
  6. case 01b : block_type = get_bits(6);
  7. case 00b : block_type = 000000b

  8. if (block_type != 0)
  9. x = GetVector();
  10. y = GetVector();

  11. for i = 0 through 5 // for each block
  12. if block_type & (1<<I)
  13. mc_offset = GetVector()
  14. motion_compensation
  15. else
  16. decode_coeffs
复制代码
Full-pel 8x8 block motion compensation is performed using the motion vector. Following the compensation step, each pixel in the block is offset by the mc_offset value and clipped to 0, 255.



Vector values are read from the bitstream using the following algorithm.
  1.     value = 0
  2.    if (get_bits(1))
  3.        if (get_bits(1))
  4.            value = -17
  5.        value += get_bits(4) + 1
复制代码
All coefficients, including DC, are decoded using the MPEG-1 AC run-length VLC technique. The RLVLC table is identical to that used for the TGQ codec and coefficients are ordered using the EA zigzag scan pattern. Dequantization is performed by multiplying the coefficients by a dequantization table. This table is calculated for each frame using the frame quantizer.
  1.     dequant_table[0] = base_table[0] * base_table2[0]
  2.    for i equals 0 through 63
  3.        dequant_table = (base_table*base_table2*frame_quant + 4) / 8

  4.    where base_table and base_table2 are defined in TGQ and TQI respectively.
复制代码

[ 本帖最后由 legojohn 于 2010-1-27 16:47 编辑 ]

评分

参与人数 1威望 +2 收起 理由
rszxh + 2 好象在本站看到过 谁帮我找找? ...

查看全部评分

发表于 2010-1-27 17:00 | 显示全部楼层
不懂 好深奥啊
回复 支持 反对

使用道具 举报

发表于 2010-1-27 17:35 | 显示全部楼层
都英语的看不懂
回复 支持 反对

使用道具 举报

发表于 2010-1-27 17:48 | 显示全部楼层
得特别说明没事不要看XD
回复 支持 反对

使用道具 举报

发表于 2010-1-27 23:04 | 显示全部楼层
看不懂。
本想說能否有將地圖改得更大的希望  不過應是我妄想
回复 支持 反对

使用道具 举报

发表于 2010-1-28 02:02 | 显示全部楼层
SC4系统的极限能挖掘的现在基本都挖掘到了吧......
回复 支持 反对

使用道具 举报

发表于 2010-1-28 07:26 | 显示全部楼层

回复 5# 的帖子

我相信这个经过编译了……
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-1-28 18:12 | 显示全部楼层
原帖由 天唐永thianz 于 2010/1/27 23:04 发表
看不懂。
本想說能否有將地圖改得更大的希望  不過應是我妄想


地图?
SC4的这仅有的两个MAD不是开头“EA Games"和SC4游戏的动画么?

又不是开源,就是MAD格式标准......

仔细看一下,第一行开头写的是“Mad is a video..."
话说LSSS有没有仔细看呢

[ 本帖最后由 legojohn 于 2010-1-28 18:16 编辑 ]
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 入住

本版积分规则

小黑屋|手机版|模拟城市中文网

GMT+8, 2024-11-18 19:36 , Processed in 0.024259 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表