A Shorten file has five byte-aligned bytes and then one continuous bit stream, read most
significant bit first. This page follows FFmpeg’s decoder and the shorten manual
page. The original Shorten source and its technical report were not available to check
against.
Signature and version
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 4 | Signature | ajkg (bytes 61 6A 6B 67) |
| 4 | 1 | Version | The format version |
| Version | Notes |
|---|---|
| 0 | Header numbers use fixed code widths. There are no block size or mean fields |
| 1 | Header numbers use the ulong code, and the header gains its extra fields |
| 2 | Adds rounding to the running means, and an offset of 32 in linear prediction |
| 3 | The same bit stream as 2. Generates seek tables |
Number codes
All numbers after the version byte use Rice codes. The width k depends on the
field.
| Name | Reads as |
|---|---|
uvar(k) | A run of 0 bits ended by a 1 bit (the count is the quotient), then k bits. The value is (quotient << k) + bits |
svar(k) | Read uvar(k + 1) as u. The value is (u >> 1) ^ −(u & 1): 0, −1, 1, −2 and so on |
ulong | Read uvar(2) as k, then uvar(k) |
Header fields
In version 0 only the first two fields exist.
| Field | Code in version 0 | Code from version 1 | Meaning |
|---|---|---|---|
| Type | uvar(4) | ulong | The sample type |
| Channels | uvar(0) | ulong | Number of channels. FFmpeg accepts 1 to 8 |
| Block size | Absent; 256 | ulong | Samples in a block. FFmpeg accepts up to 65,535 |
| Maximum LPC order | Absent | ulong | The highest linear prediction order used; 0 means polynomial prediction only |
| Mean blocks | Absent | ulong | How many past blocks form the running mean |
| Skip count | Absent | ulong | Bytes to skip next. FFmpeg reads each as 8 bits |
Sample types
| Value | Name | Samples |
|---|---|---|
| 1 | S8 | Signed 8-bit |
| 2 | U8 | Unsigned 8-bit |
| 3 | S16HL | Signed 16-bit, high byte first |
| 4 | U16HL | Unsigned 16-bit, high byte first |
| 5 | S16LH | Signed 16-bit, low byte first |
| 6 | U16LH | Unsigned 16-bit, low byte first |
The shorten program also accepts µ-law and A-law input, but the numeric codes
for these could not be confirmed. FFmpeg decodes only types 2, 3 and 5.
The original file’s header
The header is followed by commands. FFmpeg requires the first to be a verbatim command holding the start of the original file, at least 44 bytes of RIFF WAVE or AIFF data, from which it takes the sample rate and bit depth (8 or 16). The rest of the file’s format is taken from this copy.
Seek tables
Version 3 of the format generates seek tables. According to the manual page, they can be
written to a separate file with the suffix .skt, written to any named file, or
appended to a Shorten file. They can also be removed again. Their byte layout could not be
confirmed from any readable public source, and FFmpeg does not use them.