6. ASF top-level index objects

This section describes the various types of index objects that can appear at the end of an ASF file. More than one of these can coexist. For guidelines concerning which type of index to use for maximum backward compatibility, see section 8.2.12.


6.1 ASF top-level Simple Index Object (optional but recommended when appropriate, 1 for each non-hidden video stream)

For each video stream in an ASF file, there should be one instance of the Simple Index Object. Additionally, the instances of the Simple Index Object shall be ordered by stream number.


Index entries in the Simple Index Object are in terms of Presentation Times. The corresponding Packet Number field values (of the Index Entry, see below) indicate the packet number of the ASF Data Packet with the closest past key frame. Note that for video streams that contain both key frames and non-key frames, the Packet Number field will always point to the closest past key frame.


For a description of how to determine which video streams should be indexed with the Simple Index Object, see section 8.2.12.


The Simple Index Object was defined in previous versions of this specification.


The Simple Index Object is represented using the following structure.


Field name

Field type

Size (bits)

Object ID

GUID

128

Object Size

QWORD

64

File ID

GUID

128

Index Entry Time Interval

QWORD

64

Maximum Packet Count

DWORD

32

Index Entries Count

DWORD

32

Index Entries

See below

varies


The fields are defined as follows:


Object ID

Specifies the GUID for the Simple Index Object. The value of this field shall be set to ASF_Simple_Index_Object.

Object Size

Specifies the size, in bytes, of the Simple Index Object. Valid values are at least 56 bytes.

File ID

Specifies the unique identifier for this ASF file. The value of this field should be changed every time the file is modified in any way. The value of this field may be set to 0 or set to be identical to the value of the File ID field of the Data Object and the Header Object. ASF parsers may safely ignore this value.

Index Entry Time Interval

Specifies the time interval between each index entry in 100-nanosecond units. The most common value is 10000000, to indicate that the index entries are in 1-second intervals, though other values can be used as well.

Maximum Packet Count

Specifies the maximum Packet Count value of all Index Entries.

Index Entries Count

Specifies the number of Index Entries structures contained in the next field.

Index Entries

The structure of each Index Entry is shown in the following table.

Field name

Field type

Size (bits)

Packet Number

DWORD

32

Packet Count

WORD

16


The fields are defined as follows:

Packet Number

Specifies the number of the Data Packet associated with this index entry. Note that for video streams that contain both key frames and non-key frames, this field will always point to the closest key frame prior to the time interval.

Packet Count

Specifies the number of Data Packets to send at this index entry. If a video key frame has been fragmented into two Data Packets, the value of this field will be equal to 2.

6.2 ASF top-level Index Object (optional but recommended when appropriate, 0 or 1)

This top-level ASF object supplies the necessary indexing information for an ASF file that contains more than just a plain script-audio-video combination. It includes stream-specific indexing information based on an adjustable index entry time interval. The index is designed to be broken into blocks to facilitate storage that is more space-efficient by using 32-bit offsets relative to a 64-bit base. That is, each index block has a full 64-bit offset in the block header that is added to the 32-bit offsets found in each index entry. If a file is larger than 2^32 bytes, then multiple index blocks can be used to fully index the entire large file while still keeping index entry offsets at 32 bits.


Indices into the Index Object are in terms of presentation times. The corresponding Offset field values of the Index Entry (see the following table) are byte offsets that, when combined with the Block Position value of the Index Block, indicate the starting location in bytes of an ASF Data Packet relative to the start of the first ASF Data Packet in the file.


An offset value of 0xFFFFFFFF is used to indicate an invalid offset value. Invalid offsets signify that this particular index entry does not identify a valid indexible point. Invalid offsets may occur for the initial index entries of a digital media stream whose first ASF Data Packet has a non-zero send time. Invalid offsets may also occur in the case where a digital media stream has a large gap in the presentation time of successive objects.


The Index Object is not recommended for use with files where the Send Time of the first Data Packet within the Data Object has a Send Time value significantly greater than zero (otherwise the index itself will be sparse and inefficient).


Any ASF file containing an Index Object shall also contain an Index Parameters Object in its ASF Header.


The Index Object is represented using the following structure.


Field name

Field type

Size (bits)

Object ID

GUID

128

Object Size

QWORD

64

Index Entry Time Interval

DWORD

32

Index Specifiers Count

WORD

16

Index Blocks Count

DWORD

32

Index Specifiers

See section 4.9

varies

Index Blocks

See below

varies


The fields are defined as follows:

Object ID

Specifies the GUID for the Index Object. The value of this field shall be set to ASF_Index_Object.

Object Size

Specifies the size, in bytes, of the Index Object. Valid values are at least 34 bytes.

Index Entry Time Interval

Specifies the time interval between each index entry in ms.

Index Specifiers Count

Specifies the number of Index Specifiers structures in this Index Object.

Index Blocks Count

Specifies the number of Index Blocks structures in this Index Object.

Index Specifiers

Index Specifiers are described in section 4.9. The ones in this field shall be exactly the same as those listed in the corresponding Index Parameters Object.

Index Blocks

The structure of individual Index Block entries is shown in the following table.

Field name

Field type

Size (bits)

Index Entry Count

DWORD

32

Block Positions

QWORD

varies

Index Entries

See below

varies


The fields are defined as follows:

Index Entry Count

Specifies the number of Index Entries in the block.

Block Positions

Specifies a list of byte offsets of the beginnings of the blocks relative to the beginning of the first Data Packet (for example, the beginning of the Data Object + 50 bytes). The number of entries in this list is specified by the value of the Index Specifiers Count field. The order of those byte offsets is tied to the order in which Index Specifiers are listed.

Index Entries

The structure of individual Index Entries is shown in the following table.

Field name

Field type

Size (bits)

Offsets

DWORD

varies

The field is defined as follows:

Offsets

The size of the Offsets field within each Index Entry structure is 32 bits multiplied by the value of the Index Specifiers Count field. For example, if the Index Specifiers Count is 3, then there are three 32-bit offsets in each Index Entry. Index Entry offsets are ordered according to the ordering specified by the Index Parameters Object, thereby permitting the same stream to be potentially indexed by multiple Index Types (that is, Nearest Past Cleanpoint, Nearest Past Object, Nearest Past Data Packet). An offset value of 0xffffffff indicates an invalid offset value; see the beginning of this section for information about invalid offset values.


6.3 ASF top-level Media Object Index Object (optional, 0 or 1)

This top-level ASF object supplies media object indexing information for the streams of an ASF file. It includes stream-specific indexing information based on an adjustable index entry media object count interval. This object can be used to index all the video frames or key frames in a video stream. The index is designed to be broken into blocks to facilitate storage that is more space-efficient by using 32-bit offsets relative to a 64-bit base. That is, each index block has a full 64-bit offset in the block header that is added to the 32-bit offset found in each index entry. If a file is larger than 2^32 bytes, then multiple index blocks can be used to fully index the entire large file while still keeping index entry offsets at 32 bits.


Indices into the Media Object Index Object are in terms of media object numbers, with the first frame for a given stream in the ASF file corresponding to entry 0 in the Media Object Index Object. The corresponding Offset field values of the Index Entry (see the following table) are byte offsets that, when combined with the Block Position value of the Index Block, indicate the starting location in bytes of an ASF Data Packet relative to the start of the first ASF Data Packet in the file.


Any ASF file containing a Media Object Index Object shall also contain a Media Object Index Parameters Object in its ASF Header.


The ASF Media Object Index Object is represented using the following structure.


Field name

Field type

Size (bits)

Object ID

GUID

128

Object Size

QWORD

64

Index Entry Count Interval

DWORD

32

Index Specifiers Count

WORD

16

Index Blocks Count

DWORD

32

Index Specifiers

See section 4.10

varies

Index Blocks

See below

varies


The fields are defined as follows:

Object ID

Specifies the GUID for the Media Object Index Object. The value of this field shall be set to ASF_Media_Object_Index_Object.

Object Size

Specifies the size, in bytes, of the Media Object Index Object. Valid values are at least 34 bytes.

Index Entry Count Interval

Specifies the interval between each index entry in number of media objects.

Index Specifiers Count

Specifies the number of Index Specifiers structures in this Media Object Index Object.

Index Blocks Count

Specifies the number of Index Block structures in this Media Object Index Object.

Index Specifiers

Index Specifiers are described in Section 4.10. The ones in this field shall be exactly the same as those listed in the corresponding Media Object Index Parameters Object.

Index Blocks

The structure of each Index Block is shown in the following table.

Field name

Field type

Size (bits)

Index Entry Count

DWORD

32

Block Positions

QWORD

varies

Index Entries

See below

varies


The fields are defined as follows:

Index Entry Count

Specifies the number of Index Entries in the block.

Block Positions

Specifies a list of byte offsets of the beginning of the blocks relative to the beginning of the first Data Packet (for example, the beginning of the Data Object + 50 bytes). The number of entries in this list is specified by the value of the Index Specifiers Count field. The order of those byte offsets is tied to the order in which Index Specifiers are listed.

Index Entries

The structure of each Index Entry is shown in the following table.

Field name

Field type

Size (bits)

Offsets

DWORD

varies

The field is defined as follows:

Offsets

The size of the Offsets field within each Index Entry structure is 32 bits multiplied by the value of the Index Specifiers Count field. For example, if the Index Specifiers Count is 2, then there are two 32-bit offsets in each Index Entry. Index Entry offsets are ordered according to the ordering specified by the Media Object Index Parameters Object, thereby permitting the same stream to be potentially indexed by multiple Index Types (that is, Nearest Past Media Object, or Nearest Past Cleanpoint).

6.4 ASF top-level Timecode Index Object (optional, 0 or 1)

This top-level ASF object supplies timecode indexing information for the streams of an ASF file. It includes stream-specific indexing information based on the timecodes found in the file. If the Timecode Index Object is used, it is recommended that timecodes be stored as a Payload Extension System on the appropriate stream (see section 7.3.2.1). It is also recommended that every timecode appearing in the ASF file have a corresponging index entry.


The index is designed to be broken into blocks to facilitate storage that is more space-efficient by using 32-bit offsets relative to a 64-bit base. That is, each index block has a full 64-bit offset in the block header that is added to the 32-bit offsets found in each index entry. If a file is larger than 2^32 bytes, then multiple index blocks can be used to fully index the entire large file while still keeping index entry offsets at 32 bits.


To locate an object with a particular timecode in an ASF file, one would typically look through the Timecode Index Object in blocks of the appropriate range and try to locate the nearest possible timecode. The corresponding Offset field values of the Index Entry (see the following table) are byte offsets that, when combined with the Block Position value of the Index Block, indicate the starting location in bytes of an ASF Data Packet relative to the start of the first ASF Data Packet in the file.


Any ASF file containing a Timecode Index Object shall also contain a Timecode Index Parameters Object in its ASF Header.


The Timecode Index Object is represented using the following structure.


Field name

Field type

Size (bits)

Object ID

GUID

128

Object Size

QWORD

64

Reserved

DWORD

32

Index Specifiers Count

WORD

16

Index Blocks Count

DWORD

32

Index Specifiers

See section 4.11

varies

Index Blocks

See below

varies


The fields are defined as follows:

Object ID

Specifies the GUID for the Media Object Index Object. The value of this field shall be set to ASF_Timecode_Index_Object.

Object Size

Specifies the size, in bytes, of the Timecode Index Object. Valid values are at least 34 bytes.

Reserved

Reserved, must be 1.

Index Specifiers Count

Specifies the number of Index Specifiers structures in this Timecode Index Object.

Index Blocks Count

Specifies the number of Index Block structures in this Timecode Index Object.

Index Specifiers

Index Specifiers are described in section 4.11. The ones in this field shall be exactly the same as those listed in the corresponding Timecode Index Parameters Object.



Index Blocks

The structure of indiviudal Index Block entries is shown in the following table.

Field name

Field type

Size (bits)

Index Entry Count

DWORD

32

Timecode Range

WORD

16

Block Positions

QWORD

varies

Index Entries

See below

varies


The fields are defined as follows:

Index Entry Count

Specifies the number of Index Entries in the block.

Timecode Range

Specifies the timecode range for this block. Subsequent blocks must contain range numbers greater than or equal to this one. For an explanation of ASF timecodes, see section 7.3.2.1.

Block Positions

Specifies a list of byte offsets of the beginning of the blocks relative to the beginning of the first Data Packet (for example, the beginning of the Data Object + 50 bytes). The number of entries in this list is specified by the value of the Index Specifiers Count field. The order of those byte offsets is tied to the order in which Index Specifiers are listed.

Index Entries

The structure of individual Index Entries is shown in the following table.

Field name

Field type

Size (bits)

Timecode

See below

32

Offsets

DWORD

varies

The fields are defined as follows:

Timecode

This is the 4-byte timecode for these entries. For an explanation of ASF timecodes, see section 7.3.2.1.

Offsets

The size of the Offsets field within each Index Entry structure is 32 bits multiplied by the value of the Index Specifiers Count field. For example, if the Index Specifiers Count is 2, then there are two 32-bit offsets in each Index Entry. Index Entry offsets are ordered according to the ordering specified by the Media Object Index Parameters Object, thereby permitting the same stream to be potentially indexed by multiple Index Types (that is, Nearest Past Media Object, or Nearest Past Cleanpoint).