Astro~/0.3
** Conformance / Lossless Data Compression * PAGE 19 / 23
** Astro * Conformance
** /conformance/ldc

Lossless Data Compression

PICS proforma: what this package implements, clause by clause.

Conformance Statement for pkg/ldc, CCSDS 121.0-B-3


A2.1 GENERAL INFORMATION

A2.1.1 Identification of PICS

FieldValue
Date of Statement (DD/MM/YYYY)23/08/2026
PICS Serial NumberASTRO-LDC-PICS-001
System Conformance Statement Cross-ReferenceThis document

A2.1.2 Identification of Implementation Under Test (IUT)

FieldValue
Implementation Nameastro/pkg/ldc
Implementation VersionSee go.mod / latest commit on main
Special ConfigurationNone
Other InformationGo library implementing the Rice adaptive entropy coder and its preprocessor, encoder and decoder both. Integer arithmetic throughout; no floating point appears anywhere in the package. Byte-slice in, byte-slice out, packetization is the caller's.

A2.1.3 Identification of Supplier

FieldValue
SupplierRavi Suhag
Contact Point for QueriesGitHub, github.com/ravisuhag/astro
Implementation Name(s) and Version(s)astro/pkg/ldc (Go package)
System Name(s)Astro

A2.1.4 Identification of Specification

FieldValue
SpecificationCCSDS 121.0-B-3 (Lossless Data Compression, Blue Book, Issue 3, August 2020)
Companion reportCCSDS 120.0-G-4 (Lossless Data Compression, Green Book, Issue 4, November 2021)
Have any exceptions been required?Yes [X] No [ ]

NOTE, Non-supported capabilities are identified in section A2.3. All of them are options the standard leaves to the application or defines for transport layers this package does not touch.

NOTE. This implementation is validated against the official CCSDS 121.0-B-2 test vectors published by the SLS Data Compression working group (as mirrored in libaec's data/121B2TestData). All 72 AllOptions and LowEntropyOptions vectors (36 in each set, covering resolutions 1 through 32) encode byte-identically and decode back to the exact samples; they are vendored in pkg/ldc/testdata/ and every one runs as TestVectors_* in vectors_test.go. The ExtendedParameters set is excluded for the reason given in section A2.3.


A2.2 REQUIREMENTS LIST

Table A-1: Adaptive entropy coder, parameters

ItemDescriptionReferenceStatusValues AllowedSupportNotes
LDC-1Block size J3.1.6M8, 16, 32, 64YesParams.BlockSize. Any other value is ErrInvalidBlockSize.
LDC-2Sample resolution n3.1.6M1 to 32 bitsYesParams.Resolution.
LDC-3Unsigned sample range3.1.6, 4.4M0 to 2^n-1Yes
LDC-4Signed sample range3.1.6, 4.4M-2^(n-1) to 2^(n-1)-1YesParams.Signed. Two's complement, sign extended from n bits. Requires the unit-delay predictor, see the interpretation note in A2.3.
LDC-5Option identifier attached to every coded data set3.1.1, 5.2.1.3M-YesAlways written, even when a subset of options is in use.

Table A-2: Code options

ItemDescriptionReferenceStatusSupportNotes
LDC-6Fundamental sequence option3.2MYesTable 3-1 transcribed as a test. Implemented as the split-sample option with k=0, which clause 3.3.2 says it is.
LDC-7Split-sample options3.3MYesEvery k the resolution allows: up to 5, 13 or 29 in the three basic columns of table 5-1.
LDC-8Split-sample field order3.3.3MYesAll FS codewords for the block first, then all split bits. Not interleaved. The spec is explicit and the obvious implementation is wrong.
LDC-9Second-extension option3.4MYesThe transform of clause 3.4.1, with δ_1 = 0 substituted on a reference block.
LDC-10Second-extension overflow3.4.2MYesAt 32-bit resolution the transform can exceed a 64-bit integer. The option reports itself unusable rather than wrapping. Clause 3.4.2's note that it "is only designed to be a useful option when all of the transformed symbols are small" is why this can never lose data.
LDC-11Zero-block option3.5MYesIncluding the ROS codeword and the 64-block segments of clause 3.5.2.
LDC-12Zero-block run codewords3.5.3, table 3-2MYesTable transcribed in full, including the ROS codeword displaced between four and five.
LDC-13Zero-block spans multiple blocks3.1.4, 3.5.1MYesOne coded data set covers the whole run.
LDC-14All-zeros with a reference sample3.5.1, 3.7.2MYesA reference block counts as all zeros when the J-1 samples after the reference are zero, whatever the reference itself is.
LDC-15No-compression option3.6MYes

Table A-3: Code selection

ItemDescriptionReferenceStatusSupportNotes
LDC-16Select the option minimizing encoded bits, identifier included3.7.1, 3.7.3MYesEvery option is priced without being emitted, which matters: an FS codeword at 32-bit resolution can be four billion bits long.
LDC-17Zero-block always selected for all-zeros runs3.7.2MYesNot priced against the others; imposed.
LDC-18Tie-breaking order3.7.4MYesNo compression, then second extension, then smallest k. Pinned by test, because it is not the order an implementer would guess.

Table A-4: Preprocessor

ItemDescriptionReferenceStatusSupportNotes
LDC-19Preprocessor may be omitted4.1OYesPredictorNone.
LDC-20Unit-delay predictor4.2.5MYesThe only predictor the standard specifies.
LDC-21First sample of a reference interval predicts itself4.2.5MYesSo its prediction error is zero.
LDC-22Bypass predictor4.2.3OYesPredicts zero, keeps the mapper.
LDC-23Application-specific predictor4.2.4ONoThe standard names it and does not define it. A file header requesting it is refused with ErrUnsupportedPredictor.
LDC-24Reference samples required only for previous-sample predictors4.2.6MYesInserted for the unit-delay predictor, and for nothing else.
LDC-25Reference sample is the first of a block, uncoded, leading the CDS4.2.6, 5.2.2MYes
LDC-26Reference sample interval r4.3MYes1 to 4096 blocks. Bounds the zero-block segments even when no reference samples are used.
LDC-27Prediction error mapper4.4MYesThe three-branch equation, with θ = min(x̂ - xmin, xmax - x̂). Verified against the worked table of Green Book clause 3.3.3, including the two rows past θ.
LDC-28Mapper is a bijection4.4MYesChecked exhaustively at low resolution across every predictor value.

Table A-5: Coded data set formats

ItemDescriptionReferenceStatusSupportNotes
LDC-29Option identification key5.2.1, table 5-1MYesAll five resolution columns, transcribed in full as a test.
LDC-30Basic code option set5.2.1.1MYes3, 4 and 5-bit identifiers by resolution.
LDC-31Restricted code option set5.2.1.1OYes1 and 2-bit identifiers, allowed only at n <= 4. Requesting it above that is ErrRestrictedNotAllowed.
LDC-32CDS format, FS and split-sample5.2.3MYes
LDC-33CDS format, no compression5.2.4MYes
LDC-34CDS format, zero block5.2.5MYes
LDC-35CDS format, second extension5.2.6MYesJ/2 symbols, per clause 3.4.1 and figure 5-4. The prose of clause 5.2.6 says "2J transformed pairs", which contradicts both and is read as a typo.
LDC-36Bit order MSB first1.5.2MYes

Table A-6: File format

ItemDescriptionReferenceStatusSupportNotes
LDC-37File header, 12 octets7.2.2, table 7-1OYesEvery field, encoded and decoded.
LDC-38Output word size B7.2.1.2OYes1 to 8 octets.
LDC-39Reserved fields are zerotable 7-1MYesAll three checked on decode; a set bit is ErrReservedFieldSet.
LDC-40Data Sensetable 7-1MYes'0' two's complement, '1' positive. The one field that reads the opposite way from the rest, and pinned by its own test for that reason.
LDC-41Application-specific mappertable 7-1ONoRefused with ErrUnsupportedMapper.
LDC-42File body is concatenated CDSes7.2.3.1OYes
LDC-43Zero fill to the word boundary7.2.3.2OYes

Table A-7: Packet formats

ItemDescriptionReferenceStatusSupportNotes
LDC-44CDSes inserted into space packets5.3ONoOut of scope by design: this package emits coded data sets and the caller packetizes, with pkg/spp.
LDC-45Compression identification packet6ONoThe standard marks section 6 optional. The file header of section 7 covers the same need and is implemented instead.

A2.3 EXCEPTIONS AND LIMITATIONS

Non-Supported Items

ItemDescriptionReason
LDC-23Application-specific predictorclause 4.2.4 names it and leaves it undefined: "such a predictor is unique to the application and is not specified in this Recommended Standard." There is nothing to implement. A file header requesting it is refused rather than silently decoded with the wrong predictor.
LDC-41Application-specific mapperSame reasoning, from table 7-1.
LDC-44Insertion into space packetsThe caller composes coded data sets into packets. Keeping the two apart is what lets this package be used with the file format, with packets, or with neither.
LDC-45Compression identification packetSection 6 is optional and duplicates what the file header carries.
-Reference-interval byte alignmentSome encoders pad the coded stream to a byte boundary at the end of each reference sample interval, an application framing choice the standard leaves open rather than a numbered requirement (libaec exposes it as its -p option). This decoder reads the coded data set as one continuous bit stream and cannot consume such streams. Seen in the official 121.0-B-2 ExtendedParameters/sar32bit.j16.r256.rz vector, which is why that set is not in testdata/.

Interpretations

Two places where the standard's text admits more than one reading, and the reading taken here:

WhereReading taken
Signed samples and the predictor (table 7-1, Data Sense)Table 7-1 makes the positive Data Sense "mandatory if preprocessor is bypassed or preprocessor absent". Read narrowly, that constrains only a section-7 file header field; read broadly, it says signed samples are meaningful only under the unit-delay predictor. This implementation takes the broad, conservative reading and enforces it in Params.Validate everywhere, not just in the file path: Signed with any predictor other than unit delay is refused with ErrUnsupportedPredictor. The narrow reading would let signed samples through with the bypass predictor outside the file format, and would then produce parameter sets a section-7 header cannot describe. Refusing keeps every compressible stream expressible as a file.
Second-extension CDS symbol count (clause 5.2.6)The prose says "2J transformed pairs", which contradicts clause 3.4.1 and figure 5-4 (J/2 symbols). Read as a typo; J/2 is implemented. Also recorded at LDC-35.

Implementation-Defined Limits

None of these limits are in the standard. The first two exist because a decoder must not be able to be told to exhaust memory; the third is a documented limitation of the one entry point that decodes without a sample count.

LimitValueWhy
Decodable sample count2^28 samplesThe header's Number of Samples field is 48 bits, so a twelve-octet file can claim 2^48 samples, a terabyte of output, and the decoder would size a slice from it before reading a coded bit.
FS codeword lengthBounded by the resolutionA run of zero octets in a corrupt stream would otherwise be read as an enormous sample value. ReadFS takes a limit and refuses past it.
Fill skipped by the unbounded Decompress7 bitsDecompress (no sample count) treats a trailing all-zero run of fewer than eight bits as clause 7.2.3.2 fill, which covers a B=1 file body exactly. A file written with an output word size B > 1 octet can carry up to 8B-1 fill bits, and without the count that tail cannot be told from a truncated coded data set, so Decompress fails with an error rather than guessing. DecompressCount and DecompressFile know the count and skip any fill. Pinned by TestDecompressRefusesLongWordFill.

Fully Supported Mandatory Items

Every mandatory item is supported. All five code options are implemented in both directions, along with both specified predictors, the mapper, the coded data set formats, and the option selection rule including its tie-breaks.

AreaItemsImplementation
ParametersLDC-1-5params.go
Bit packingLDC-36bits.go
Code optionsLDC-6-15options.go
SelectionLDC-16-18encoder.go
PreprocessorLDC-19-28preprocessor.go
CDS formatsLDC-29-35encoder.go, decoder.go
File formatLDC-37-43file.go

Verification

SourceWhat it pins
Blue Book table 3-1Fundamental sequence codewords
Blue Book table 3-2Zero-block run codewords, including ROS
Blue Book table 5-1Every option identifier at every resolution
Blue Book table 7-1File header, field by field
Blue Book clause 3.4.1The second-extension transform
Blue Book clause 3.7.4The tie-breaking order
Green Book clause 3.3.3The preprocessor and mapper, as a worked table
Green Book figure 3-4Zero-block segmentation and ROS

Annex A of the Green Book names a fuller vector set at cwe.ccsds.org/sls/docs/sls-dc/BB121B3TestData. That location requires a CCSDS login and returned HTTP 403, so it has not been run against this implementation. Anyone with access is encouraged to.