Friday, June 17, 2005

 

SWF Rendering: Part 1

Now that I have the basics down, I've started to take a deeper look into SWF overall, in order to get a better feeling of where I'm going and what design decisions need to be made along the way. As part of this process, I've decided to write a set of articles explaining how the SWF rendering process works. This will serve three purposes:

In this article, we'll go over SWF interpretation up to and including definition tags. The next article will be dedicated to the interpretation of non-ActionScript control tags, and possibly the visual model that the SWF format should be interpreted with.

Step 1: Decoding Tags

Before anything else can happen, the data from the file must be parsed into data structures in memory. There are three major parts to this on the file wide scale:

  1. Header extraction
  2. Decompression (dependent on header)
  3. Tag extraction

"Tag extraction" is a bit vague, however; the RecordHeader data structure means that we could extract all of the tags simply by pulling the appropriate number of bytes out of the stream and store them in a character array. This wouldn't be very useful, however, since we still wouldn't know what information is trying to be conveyed by the file. Thus, we have a little more to do on the per record scale (header included):

  1. Know what type of record we're extracting
  2. Know the SWF primitives (their type, order and meaning) that make up the record
  3. Extract each primitive to a corresponding, size-compatible, in-memory variable.

Once we can extract tags in a meaningful manner, we have enough infrastructure to start processing them. Because SWF is a streamable format, we don't need to have the whole file before we start working.

Step 2: Definitions and The Dictionary

As definition tags are discovered, they are then added to the "dictionary." This is a static repository for all of the objects with definition tags (called "characters"). Other tags (called control tags) generally refer to one or more tags in the dictionary, applying transforms in a cumulative filtering (or "delta based") fashion. This makes implementing the dictionary straightforward, as all it has to do is allow new characters to be added, and report the values of existing characters.

Comments:
is there a mailing list for the project?
what stage is the renderer at? will it render flash4 animations? eg leaving aside actionscript etc.
 
1) yes (check out the sourceforge project), 2) somewhat kinda working? 3) See 2 :p.
 
Post a Comment

Links to this post:

Create a Link



<< Home

Note: I have been told by someone who recently downloaded the SWF specification that Macromedia has added a restrictive license to the end of the document. Because of this, newcomers will not be able to get a copy of the spec and still be able to contribute to GPLFlash's development. Since other developers (such as myself) already have access to the specification without the license, this should not pose a major problem in the short term. Please bear with us, and do not seek out or use this specification in conjunction with the GPLFlash project.