Skip to main content

🥩 Raw KLV Decode

The Raw KLV Decode test verifies that buffered KLV payload bytes form complete KLV packets and can be decoded into raw KLV items.

What This Test Does

The test feeds captured KLV payload bytes into the raw KLV push decoder and checks that decoding can continue cleanly across payload boundaries on each detected KLV PID.

This catches packet-level decode problems such as:

  • truncated KLV packets
  • invalid BER lengths
  • trailing partial packets at the end of a stream
  • payload regions that contain KLV bytes but never produce a complete decodable packet

When a decode error is reported, the inspector records the first available source packet location so the failing region can be reviewed in context.

✅ Pass Criteria

The test passes when each inspected KLV PID either:

  • contains no KLV payloads to inspect, or
  • yields decodable raw KLV packets without packet-level decode errors, including packets that span multiple payload buffers

❌ Fail Criteria

The test fails when:

  • the raw KLV decoder reports a packet-level decode error such as klv: packet is incomplete or klv: invalid BER length, or
  • KLV payload bytes are present on a PID but no decodable raw KLV packet can be formed from them

Example

A passing case is a KLV packet that starts in one payload buffer and finishes in the next. The decoder combines those bytes and counts one successfully decoded raw KLV packet.

A failing case is a stream where earlier packets decode correctly, but a later packet is structurally corrupted or truncated. In the validation tests, this commonly appears as klv: packet is incomplete and is reported at the first source packet associated with the failing byte region.

The example chart below shows raw KLV decode failures plotted by byte offset. Each point marks a payload region where the decoder could no longer assemble a complete KLV packet. This makes it easy to see whether the corruption is isolated to a few packets or repeated across the file, and the hover details identify the affected PID, approximate time, packet index, byte offset, and decoder error.

Raw KLV decode failure chart

Test file

  • klv-corrupt-packets.ts