Expand description
tc-gpu (stream magic TCG1): a GPU-decodable, random-access variant of
the wavelet codec whose decode is integer only, so a CPU and a GPU
decoder produce the same bytes.
§Layout
- The field is cut into independent bricks (3D
B³, 2DB²tiles), each with its own CDF 9/7 pyramid and its own entropy-coded lanes. A header index of brick sizes gives random access: a sub-box decodes only the bricks it touches. - Values live on a fixed-point grid
x ≈ v·2^e(vani32);eis chosen so|x|/2^e ≤ 2^23(the finali32 → f32conversion is exact) and|x − mean|/2^e ≤ 2^20(transform headroom insidei32).
§Decode (integer only)
- Coefficients. Each brick is coded in
lanesindependent rANS lanes (32-bit state, 16-bit words, 16-bit probabilities). Bands go coarse → fine; inside a band the lines along the fastest axis are split into passes by the parity of their(y, z)position (4 passes in 3D:(0,0) (1,1) (1,0) (0,1); 3 in 2D:y≡0 mod 4,y≡2 mod 4, oddy). A line conditions only on lines of earlier passes, coarser bands, and its own earlier samples, so every line of a pass decodes in parallel; lines of a pass are dealt round-robin to the lanes. Each lane owns its adaptive binary models (the hand model’s binarization: significance, adaptive-Golomb unary, low bits, sign) — adaptation is per lane, which is what keeps lanes independent. - Prediction. Per (level, orientation, pass) a 6-tap Q12 predictor
over
W, WW, Σfaces, Σdiagonals, Σ(±2 lines), parent, restricted to what the pass can see. - Dequantization in fixed point:
c = ⌊|q|·m/2^s⌉ − ⌊δ·m/2^(s+9)⌉with a per-band 31-bit step mantissam. - Inverse CDF 9/7 lifting in
i32with Q24 constants and round-half-up products⌊(a·k + 2^23)/2^24⌋(a 32×32→64 multiply). - Max-abs corrections
v += k·corrin the integer domain, thenf32 = (v + mean) as f32 · 2^e— exact, since|v| < 2^24and the scale is a normal power of two. Cells the grid still pushes past the bound are stored as rawf32bits.
Structs§
- Band
Info - Per-band decode parameters.
- Brick
Ref - A brick of a parsed stream.
- DecSink
- Decoder sink over a brick’s lanes.
- Feats
- Everything the coder derives for one coefficient.
- GpuConfig
- tc-gpu options.
- GpuStats
- Encoder statistics.
- Parsed
- A parsed stream header + brick index.
- RansDec
- Decoder of one lane.
- RecSink
- Encoder sink: records
(cum, freq)per lane in decode order. - Shape
- A brick shape and its pyramid.
Constants§
- ESC0
- Escape (Elias-gamma unary) models.
- LOW0
- Low-bit models.
- MAG0
- Magnitude unary models.
- MAGIC
- Stream magic.
- MINIT
- Two-rate adaptive bit model packed in a
u32(fast in the low half). - NDL
- Number of centroid offsets.
- NKEY
- Number of distinct predictor keys addressable.
- NMODEL
- Models per coefficient lane.
- NOMODEL
- Models of the outlier lane (count, gap, |k| gamma unaries).
- NTAP
- Number of predictor taps.
- QL
- Fixed-point shift of the lifting constants.
- SGN0
- Sign models.
- SIG0
- Model offsets inside one lane’s state.
- VMAX
- Largest magnitude allowed into the final
i32 → f32conversion.
Traits§
- Sink
- A symbol sink/source for one brick: binary decisions at a probability, and raw bit chunks, per lane.
Functions§
- code_
brick - Code (encode or decode) a brick’s coefficients
q;adaptselects per-lane adaptive models (else the priors are static probabilities). - decode_
box_ bits - Decode the sub-box
[lo, hi)(3D coordinates) withthreadsthreads; returnsf32bits in box layout. - decode_
box_ parsed decode_box_bitson an already parsed stream.- decode_
brick_ fix - Decode one brick to fixed-point values after corrections (brick-local layout) — the integer reference pipeline.
- decode_
f32 - Decode a whole stream to
f32withthreadsthreads. - dequant
- Dequantize one value of band
b. - encode_
f32 - Encode
x(row-majorf32, 1D–3D) as a tc-gpu stream. - encode_
f32_ mt encode_f32withthreadsworker threads (output bytes are identical for any thread count).- inverse_
int - Inverse multi-level integer CDF 9/7 on a brick.
- lift_
consts - Inverse-lifting constants (Q24):
1/κ, κ, −δ, −γ, −β, −α. - mulsh
⌊(a·b + 2^(s−1)) / 2^s⌋, low 32 bits (the GPU emulates the 64-bit product).- npass_
of - Pass count of a band.
- parse
- Parse a stream’s header and brick index.
- pass_
lattice - Lines of pass
pform a latticez ≡ rz (mod sz),y ≡ ry (mod sy)(band-relative): returns(rz, sz, ry, sy). - pass_of
- Pass of band-relative line
(zr, yr). - prior_
table - The 64 prior probabilities
P(1)·2^16(logistic grid, step 0.28 in logit). - rans_
encode - rANS-encode one lane (symbols in decode order) into 16-bit words.
- to_
f32_ bits f32bits of fixed-pointvat scale2^e(exact:|v| < 2^24).