12.06.2015 Views

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

§108 ANNOYANCE-FILTER FLASH STREAM DECODER 87<br />

108. 16 and 32 bit quantities are stored in little-endian byte order. <strong>The</strong>se methods, declared within<br />

the class so they’re inlined in the interest of efficiency, use the get8 primitive byte input method to<br />

assemble the wider quantities. <strong>The</strong> get16n and get32n methods read a series of n consecutive values of<br />

the corresponding type into an array.<br />

〈 Read 16 and 32 bit quantities from Flash file 108 〉 ≡<br />

unsigned short get16 (void)<br />

{<br />

unsigned short u16 ;<br />

}<br />

u16 = get8 ( );<br />

u16 |= get8 ( ) ≪ 8;<br />

return u16 ;<br />

unsigned int get32 (void)<br />

{<br />

unsigned int u32 ;<br />

}<br />

u32 = get8 ( );<br />

u32 |= get8 ( ) ≪ 8;<br />

u32 |= get8 ( ) ≪ 16;<br />

u32 |= get8 ( ) ≪ 24;<br />

return u32 ;<br />

void get16n (unsigned short ∗buf , const int n)<br />

{<br />

for (int i = 0; (¬eof ) ∧ (i < n); i++) {<br />

buf [i] = get16 ( );<br />

}<br />

}<br />

void get32n (unsigned int ∗buf , const int n)<br />

{<br />

for (int i = 0; (¬eof ) ∧ (i < n); i++) {<br />

buf [i] = get32 ( );<br />

}<br />

}<br />

This code is used in section 100.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!