The Annoyance Filter.pdf - Fourmilab
The Annoyance Filter.pdf - Fourmilab
The Annoyance Filter.pdf - Fourmilab
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
82 FLASH STREAM DECODER ANNOYANCE-FILTER §100<br />
100. Flash stream decoder.<br />
<strong>The</strong> flashStream is a specialisation of applicationStringParser which contains all of the logic needed<br />
to parse a Macromedia Flash script (.swf) file. This class remains abstract in that it does not implement<br />
the nextString method; that is left for the flashTextExtractor class, of which this class is the parent.<br />
This decoder is based on the swfparse.cpp program written by David Michie, which is available on<br />
the OpenSWF.org site.<br />
〈 Class definitions 10 〉 +≡<br />
class flashStream : public applicationStringParser {<br />
protected:<br />
〈 Flash file tag values 110 〉;<br />
〈 Flash file action codes 111 〉;<br />
〈 Flash text field mode definitions 112 〉;<br />
〈 Flash file data structures 113 〉; /∗ Header fields ∗/<br />
unsigned char sig [3]; /∗ Signature: “FWS” in ASCII ∗/<br />
unsigned char version ; /∗ Version number ∗/<br />
unsigned int fileLength ; /∗ Length of entire file in bytes ∗/<br />
rect frameSize ; /∗ Frame size in TWIPS ∗/<br />
unsigned short frameRate ; /∗ Frames per second (8.8 bit fixed) ∗/<br />
unsigned short frameCount ; /∗ Total frames in animation ∗/<br />
/∗ Current tag information ∗/<br />
tagType tType ; /∗ Tag type ∗/<br />
unsigned int tDataLen ; /∗ Length of data chunk ∗/ /∗ Bit stream decoder storage ∗/<br />
unsigned int bitBuf , bitPos ;<br />
public:<br />
flashStream(mailFolder ∗f = Λ)<br />
: applicationStringParser(f) { }<br />
void readHeader (void); /∗ Read header into memory ∗/<br />
void describe (ostream &os = cout ); /∗ Describe stream ∗/<br />
bool nextTag (void); /∗ Read next tag identifier and length of tag data ∗/<br />
/∗ Retrieve properties of current tag ∗/<br />
tagType getTagType (void) const<br />
{<br />
return tType ;<br />
}<br />
unsigned int getTagDataLength (void) const<br />
{<br />
return tDataLen ;<br />
}<br />
void ignoreTag (unsigned int lookedAhead = 0);<br />
/∗ Ignore data for tag we aren’t interested in ∗/<br />
virtual void close (void)<br />
{<br />
applicationStringParser ::close ( );<br />
}<br />
protected:<br />
〈 Read 16 and 32 bit quantities from Flash file 108 〉; /∗ Skip n bytes of the input stream ∗/<br />
void skip8n (const int n)<br />
{<br />
for (int i = 0; (¬eof ) ∧ (i < n); i++) {