code wiki / (root) / nx_flac.nx

nx_flac.nx

buildroot/runtime/nx_flac.nx

8608 B256 linesdepth 4pulls 4 transitivereach 3 importersview sourcekind librarytopic flac
docsdependenciesstructsconstsfunctions

about

nx_flac.nx -- FLAC lossless audio decoder core. The audio quadrant of this tree held PCM and nothing else. FLAC is the cheapest real codec to close that with: it is native in every browser, it is the archival lossless standard, and its whole decode path is integer arithmetic -- no transform, no float, no psychoacoustics. FLAC is MSB-first (unlike DEFLATE/VP8L), so this composes onto nx_bitstream_read_msb. Its residuals are Rice-coded, which nx_huffman.nx already names as a sibling of its own family. THE SIGN TRAP. Rice codes an unsigned value that must be UNFOLDED to signed by zigzag: even -> +n/2, odd -> -(n+1)/2. Getting that backwards produces audio that decodes without error and sounds like noise, because every residual has the wrong sign but the right magnitude. There is no checksum on the sample path that would catch it -- only the frame CRC, which many decoders skip. genealogy_id: flac_format_spec lineage_id: nx_flac_v1 license_tier: ORIGINAL

dependencies 2 imports · 3 importers

nx_syscalls.nx nx_bitstream.nx nx_flac.nx nx_flac_frame.nx nx_flac_frame_gate.nx nx_flac_gate.nx

imports: nx_syscalls.nxnx_bitstream.nx

imported by: nx_flac_frame.nxnx_flac_frame_gate.nxnx_flac_gate.nx

structs

none

consts

25const NX_MAGIC_1000000: i64 = 1000000
26const NX_MAGIC_88200: i64 = 88200
27const NX_MAGIC_176400: i64 = 176400
28const NX_MAGIC_192000: i64 = 192000
29const NX_MAGIC_8000: i64 = 8000
30const NX_MAGIC_16000: i64 = 16000
31const NX_MAGIC_22050: i64 = 22050
32const NX_MAGIC_24000: i64 = 24000
33const NX_MAGIC_32000: i64 = 32000
34const NX_MAGIC_44100: i64 = 44100
35const NX_MAGIC_48000: i64 = 48000
36const NX_MAGIC_96000: i64 = 96000
38const NX_FLAC_MAX_FIXED_ORDER: i64 = 4
39const NX_FLAC_SUB_CONSTANT: i64 = 0
40const NX_FLAC_SUB_VERBATIM: i64 = 1
41const NX_FLAC_SUB_FIXED: i64 = 2
42const NX_FLAC_SUB_LPC: i64 = 3
44const NX_FLAC_CH_INDEPENDENT: i64 = 0
45const NX_FLAC_CH_LEFT_SIDE: i64 = 1
46const NX_FLAC_CH_RIGHT_SIDE: i64 = 2
47const NX_FLAC_CH_MID_SIDE: i64 = 3

functions

54func nx_flac_unfold(v: i64) -> i64
59func nx_flac_fold(v: i64) -> i64
called by 1: main
71func nx_flac_read_rice(bs: *NxBitStream, param: i64) -> i64
95func nx_flac_fixed_predict(order: i64, p1: i64, p2: i64, p3: i64, p4: i64) -> i64
106func nx_flac_restore_fixed(buf: *i64, n: i64, order: i64) -> i64
132func nx_flac_restore_lpc(buf: *i64, n: i64, order: i64, coef: *i64, shift: i64) -> i64
157func nx_flac_undo_stereo(a: *i64, b: *i64, n: i64, mode: i64) -> i64
called by 1: main
185func nx_flac_block_size(code: i64) -> i64
194func nx_flac_sample_rate(code: i64) -> i64
211func nx_flac_bit_depth(code: i64) -> i64
228func nx_flac_crc8(data: *u8, n: i64) -> i64
249func nx_flac_is_stream(b: *u8, n: i64) -> i64
called by 1: main