The following describes GIF Netscape Application extension, taken from here.
The block is 19 bytes long. First 14 bytes belongs to general
Application Extension format, syntax is described in GIF89a
Specification, section "26. Application Extension".
Syntax
0 | 0x21 | Extension Label
+---------------+
1 | 0xFF | Application Extension Label
+---------------+
2 | 0x0B | Block Size
+---------------+
3 | |
+- -+
4 | |
+- -+
5 | |
+- -+
6 | |
+- NETSCAPE -+ Application Identifier (8 bytes)
7 | |
+- -+
8 | |
+- -+
9 | |
+- -+
10 | |
+---------------+
11 | |
+- -+
12 | 2.0 | Application Authentication Code (3 bytes)
+- -+
13 | |
+===============+ --+
14 | 0x03 | Sub-block Data Size |
+---------------+ |
15 | 0x01 | Sub-block ID |
+---------------+ | Application Data Sub-block
16 | | |
+- -+ Loop Count (2 bytes) |
17 | | |
+===============+ --+
18 | 0x00 | Block Terminator
You already know the data up to NETSCAPE2.0
. The next byte 0x03
tells us the next data sub-block length which is always 3 bytes. The following 0x01
is the sub-block ID. For Netscape block, there is only one data sub-block and the ID is 1
.
The following 2 bytes specifies the loop count in little endian — how many times the image frames should be looped, which is 0, and 0 means loop forever.
The last byte 0x00
is used to terminate the data block. So when we meet a 0x00
where data sub-block length should be, we know there are no sub-blocks left and we need to stop reading the block.