ActionScript SWF 文件头解析

阅读(4044)
字段 类型 含义
Signature UI8(Unsigned Integer,下同) Signature byte: “F” indicates uncompressed “C” indicates a zlib compressed SWF (SWF 6 and later only) “Z” indicates a LZMA compressed SWF (SWF 13 and later only)
Signature UI8 Signature byte always “W”
Signature UI8 Signature byte always “S”
Signature UI8 Single byte file version (for example, 0x06 for SWF 6)
FileLength UI32 文件大小,单位 bytes
FrameSize RECT Frame size in twips
FrameRate UI16 Frame delay in 8.8 fixed number of frames per second
Signature UI8
FrameCount UI8 包含的总帧数

The header begins with a three-byte signature of one of:

  • 0x46, 0x57, 0x53 (“FWS”). An FWS signature indicates an uncompressed SWF file.
  • 0x43, 0x57, 0x53 (“CWS”). A CWS indicates that the entire file after the first 8 bytes (that is, after the FileLength field) was compressed by using the ZLIB open standard. The data format that the ZLIB library uses is described by Request for Comments (RFCs) documents 1950 to 1952. CWS file compression is permitted in SWF 6 or later only.
  • 0x46, 0x57, 0x53 (“FWS”). An FWS signature indicates an uncompressed SWF file.
  • 0x5a, 0x57, 0x53 (“ZWS”). A ZWS indicates that the entire file after the first 8 bytes (that is, after the FileLength field) was compressed by using the LZMA open standard: http://www.7-zip.org/sdk.html. ZWS file compression is permitted in SWF 13 or later only.

A one-byte version number follows the signature. The version number is not an ASCII character, but an 8-bit
number. For example, for SWF 4, the version byte is 0x04, not the ASCII character “4” (0x34).

The FileLength field is the total length of the SWF file, including the header. If this is an uncompressed SWF file
(FWS signature), the FileLength field should exactly match the file size. If this is a compressed SWF file (CWS
signature), the FileLength field indicates the total length of the file after decompression, and thus generally does
not match the file size. Having the uncompressed size available can make the decompression process more
efficient.

The FrameSize field defines the width and height of the on-screen display. This field is stored as a RECT
structure, meaning that its size may vary according to the number of bits needed to encode the coordinates. The
FrameSize RECT always has Xmin and Ymin value of 0; the Xmax and Ymax members define the width and height
(see Using bit values).

The FrameRate is the desired playback rate in frames per second. This rate is not guaranteed if, for example,
Flash Player is running on a slow or busy CPU.
The FrameCount is the total number of frames in this SWF file.

内容来自官方: http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/swf/pdf/swf-file-format-spec.pdf

Tags: