KLV

KLV

=Introduction=

KLV (Key-Length-Value) is a data encoding standard, often used to embed information in video feeds. Items are encoded into Key-Length-Value triplets, where key identifies the data, length specifies the data's length, and value is the data itself. It is defined in SMPTE 336M-2007 (Data Encoding Protocol Using Key-Length Value), approved by the Society of Motion Picture and Television Engineers. They exclusively [http://store.smpte.org/product-p/smpte%200336m-2007.htm sell the document for $65] .

=Byte Packing=

In a binary stream of data, a KLV set is broken down in the following fashion, with all integer-interpretation being Big Endian:

Key Field

The first few bytes are the Key, much like a key in a standard hashtable data structure. Keys can be 1, 2, 4, or 16 bytes in length. Presumably in a separate specification document you would agree on a key length for a given application. Sixteen byte keys are usually reserved for use as globally-registered unique identifiers, and the Value portion of such a packet usually contains a series of more KLV sets with smaller keys.

Length Field

Following the bytes for the Key are bytes for the Length field which will tell you how many bytes follow the length field and make up the Value portion. There are four kinds of encoding for the Length field: 1-byte, 2-byte, 4-byte and Basic Encoding Rules (BER). The 1-, 2-, and 4-byte variants are pretty straightforward: make an unsigned integer out of the bytes, and that integer is the number of bytes that follow.

BER length encoding is a bit more complicated but the most flexible. If the first byte in the length field does not have the high bit set (0x80), then that single byte represents an integer between 0 and 127 and indicates the number of Value bytes that immediately follows. If the high bit is set, then the lower seven bits indicate how many bytes follow that themselves make up a length field.

For example if the first byte of a BER length field is binary 10000010, that would indicate that the next two bytes make up an integer that then indicates how many Value bytes follow. Therefore a total of three bytes were taken up to specify a length.

Value Field

The remaining bytes are the Value field, and its contents can be whatever you like, including a chain of more KLV sets, as is often the case.

Example

In the following example, the four bytes represent a KLV set where the key is one byte, the length field is one byte (or possibly BER - you cannot tell from the example), and the value is two bytes: a zero and a three. In your application you would have previously agreed to a) use one-byte keys and b) use one-byte length encoding. Also presumably the key value "42" would mean something to you, perhaps it indicates that the value bytes 0x00 and 0x03 are an integer representing the value of your bicycle's odometer.

External links

* [http://sourceforge.net/projects/klvlib KLVLib - A C Library for KLV file I/O]
* [http://store.smpte.org/product-p/smpte%200336m-2007.htm Purchase The KLV Standard (SMPTE 336M-2007) ($65)]
* [http://iharder.sourceforge.net/current/java/klv/ A Java KLV library in the Public Domain]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • KLV — oder Klv steht für: Kapitallebensversicherung Key Length Value Protokoll Kinderlandverschickung Kleinwagen mit Verbrennungsmotor, motorisierte Eisenbahn Nebenfahrzeuge Kombinierter Ladungsverkehr Kosten und Leistungsverantwortung IATA Code des… …   Deutsch Wikipedia

  • Klv — steht für: Kapitallebensversicherung Key Length Value Protokoll Kinderlandverschickung Kombinierter Ladungsverkehr Kinder, Laien, Vorstände Kosten und Leistungsverantwortung IATA Code des Flughafen Karlsbad Karlovy Vary Airport …   Deutsch Wikipedia

  • KLV-Lager — Berliner Kinder in Hassitz bei Glatz während der Geographiestunde in einem der Klassenräume, Oktober 1940 Die Bezeichnung Kinderlandverschickung (KLV) wurde vor dem Zweiten Weltkrieg ausschließlich für die Erholungsverschickung von Kindern… …   Deutsch Wikipedia

  • KLV — Karlovy Vary, Czechoslovakia (Regional » Airport Codes) …   Abbreviations dictionary

  • KLV — Kalanchoe latent virus …   Medical dictionary

  • KLV — Karlovy Vary, Czechoslovakia internationale Flughafen Kennung …   Acronyms

  • klv — ISO 639 3 Code of Language ISO 639 2/B Code : ISO 639 2/T Code : ISO 639 1 Code : Scope : Individual Language Type : Living Language Name : Maskelynes …   Names of Languages ISO 639-3

  • KLV — Karlovy Vary, Czechoslovakia internationale Fughafen Kennung …   Acronyms von A bis Z

  • KLV — abbr. Kontrol Limitation Vitesse …   Dictionary of abbreviations

  • KLV — • Kalanchoe latent virus …   Dictionary of medical acronyms & abbreviations

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”