code wiki / (root) / nx_jpeg_sof.nx

nx_jpeg_sof.nx

buildroot/runtime/nx_jpeg_sof.nx

6561 B166 linesdepth 2pulls 2 transitivereach 80 importersview sourcekind librarytopic jpeg
docsdependenciesstructsconstsfunctions

about

nx_jpeg_sof.nx -- JPEG Start-of-Frame parser. Per ITU-T Rec. T.81 sec B.2.2 -- the SOF segment that establishes the image's dimensions, sample precision, and component descriptors. Baseline-DCT SOF0 (marker 0xC0) payload layout: Lf (2 bytes BE) -- segment length (already consumed by marker scanner; payload arrives without it) P (1 byte) -- sample precision (always 8 for baseline) Y (2 bytes BE) -- image height in pixels (rows) X (2 bytes BE) -- image width in pixels (cols) Nf (1 byte) -- component count (1=gray, 3=YCbCr, 4=CMYK) per component (3 bytes each): Ci (1 byte) -- component identifier (1..255) HiVi (1 byte) -- high4 = Hi sampling factor, low4 = Vi sampling factor Tqi (1 byte) -- quantization-table id (0..3) per T.81 sec B.2.2 Sampling factors are CRITICAL for chroma upsampling: e.g. 4:2:0 has Y component with H=2, V=2 and Cb/Cr with H=1, V=1 (luma sampled twice as densely in both axes). Progressive (SOF2 / 0xC2) payload format is identical to SOF0. Extended-sequential (SOF1 / 0xC1) is also identical. Only the scan-direction differs, which this parser doesn't care about. Lossless (SOF3 / 0xC3) and arithmetic-coded variants differ slightly -- not supported here. nx_safety_envelope: intended_use: "Frame-descriptor parsing for JPEG decode." sil_target: SIL1 evidence: [t81_section_b_2_2_canonical_basis, sealed_precision_enum, bounded_4_component_max] hazard_register: [bug-tape-sof-component-count-overflow, bug-tape-sof-malformed-precision, bug-tape-sof-zero-dimensions] residual_risk: "Caller must verify decoded Hi/Vi are in [1..4] before using as MCU sampling factor." verdict: NOT_YET_EVALUATED

dependencies 1 imports · 8 importers

nx_syscalls.nx nx_jpeg_sof.nx nx_jpeg_ascii.nx nx_jpeg_decode.nx nx_jpeg_decode_image.nx nx_jpeg_decode_image_test.nx nx_jpeg_mcu.nx nx_jpeg_mcu_test.nx nx_jpeg_progressive.nx nx_jpeg_sof_test.nx

imports: nx_syscalls.nx

imported by: nx_jpeg_ascii.nxnx_jpeg_decode.nxnx_jpeg_decode_image.nxnx_jpeg_decode_image_test.nxnx_jpeg_mcu.nxnx_jpeg_mcu_test.nxnx_jpeg_progressive.nxnx_jpeg_sof_test.nx

structs

59struct NxJpegSofComponent
69struct NxJpegFrame

consts

43const NX_JPEG_SOF_OK: i64 = 0
44const NX_JPEG_SOF_TRUNC: i64 = 1
45const NX_JPEG_SOF_BAD_PRECISION: i64 = 2 // P != 8 for baseline
46const NX_JPEG_SOF_BAD_NF: i64 = 3 // Nf == 0 or > 4
47const NX_JPEG_SOF_ZERO_DIM: i64 = 4 // X == 0 or Y == 0
48const NX_JPEG_SOF_BAD_SAMPLING: i64 = 5 // Hi or Vi 0 or > 4
49const NX_JPEG_SOF_BAD_TQ: i64 = 6 // Tqi > 3
50const NX_JPEG_SOF_RESULT_N: i64 = 7
66const NX_JPEG_SOF_COMP_BYTES: i64 = 32
79const NX_JPEG_FRAME_BYTES: i64 = 56

functions

52func nx_jpeg_sof_result_is_valid(v: i64) -> i64
91func nx_jpeg_sof_parse(payload: *u8, payload_len: i64,
149func nx_jpeg_sof_mcu_pixel_width(frame: *NxJpegFrame) -> i64
153func nx_jpeg_sof_mcu_pixel_height(frame: *NxJpegFrame) -> i64
158func nx_jpeg_sof_mcu_cols(frame: *NxJpegFrame) -> i64
163func nx_jpeg_sof_mcu_rows(frame: *NxJpegFrame) -> i64