![](https://csdnimg.cn/release/download_crawler_static/5325207/bg12.jpg)
SMPTE 377M-2004
Page 18 of 101 pages
Each partition may align certain KLV elements to a KLV alignment grid (KAG). The KLV alignment grid
defines the number of bytes between gridlines to which the first byte of the Key of certain KLV elements may
be aligned. The first gridline in any partition is the first byte of the key of the partition pack that defines that
partition. Specific KLV items that may be aligned to a gridline include the preface set (of the header metadata)
and the index table segment set. Individual essence container specifications shall define which KLV elements
shall lie on a gridline. All partitions that use the KAG shall ensure that the end of that partition is padded to a
gridline defined by that partition.
A KAG value of “0” defines that the grid value is undefined; e.g., there may once have been a KAG but it may
no longer be valid for some reason. A KAG value of “1” defines that there is no grid; i.e., byte alignment. Any
KAG value between, and including, “2” and “1048576” defines a valid grid size. A KAG value in excess of
“1048576” (1 Mbyte, 2
20
) is not permitted.
NOTE –
The upper limit of 1 Mbyte is provided to minimize receiver buffer requirements.
If grid alignment is used, then all partitions of the same type in the file should use grid alignment. The KAG
size is specified in every partition pack and is valid for that partition only. The KAG size shall be constant for
all partitions with segments from the same essence container. However, specific applications may require a
different KAG size value for different essence containers (for example, an MXF file that has a high resolution
primary video and an alternate low resolution preview video might use different KAG sizes for the essence
container of each video).
If the KAG size of any partition is changed, then the values of appropriate items within the partition (e.g.,
partition pack, index tables) should be changed accordingly. If an MXF application modifies the KAG size in a
partition and the dependant partition items are not updated, then the KAG value should be set to 0. The KAG
size parameter is a performance enhancement parameter. It is possible that some files may have the KAG
value incorrectly set.
Essence container specifications may define a KAG value which MXF encoders should use, however, all
decoders shall correctly parse a file whether the KAG parameter is correct or not.
NOTE – Application writers should be aware that incorrect values of KAG size may lead to performance degradation,
especially when MXF files are transferred to and from certain classes of machine. Applications may also be degraded by
the requirements of KAG implementation. Its use is therefore optional.
5.4.2 MXF byte order
This section defines the byte order of the value fields in KLV packets used in MXF files. The byte order of
essence data as a value in a KLV packet shall be defined by the appropriate specification.
For all other parts of the MXF specification, all multi-byte values in any KLV packet shall be coded as big-
endian (most significant byte first), wherever the value is sensitive to the byte order. Examples of simple multi-
byte values affected by byte order are: UInt16, Uint32, Uint64 and UTF-16.
Compound data types shall have all component multi-byte values coded as big-endian.
5.4.3 Encoding constraints
This document constrains several aspects of MXF encoding. Other documents, such as operational pattern
and essence container specifications, may further constrain aspects of MXF encoding for reasons particular
to their requirements.
5.5 Run-in sequence
In certain specialized operational patterns, the header partition may be preceded by a non-KLV coded run-in. This is
to allow synchronization bytes or “camouflage” bytes to be added at the front of the file in specialized applications.