|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Module-private declarations shared across the software JPEGcodec translation units. More...
Go to the source code of this file.
Data Structures | |
| struct | ra8_jpeg_bitreader_t |
| Big-endian bit reader over an entropy-coded segment. More... | |
| struct | ra8_jpeg_htab_t |
| Decoded Huffman table – 256 entries indexed by symbol order. More... | |
| struct | ra8_jpeg_dec_ctx_t |
| Decoder state shared by the whole-buffer and streaming drivers. More... | |
Functions | |
| static uint8_t | internal_clamp_u8 (int32_t v) |
| Clamp v to the unsigned 8-bit pixel range. | |
| static uint16_t | internal_read_be16 (const uint8_t *p) |
| Read a 16-bit big-endian word from p. | |
| static void | internal_write_be16 (uint8_t *p, uint16_t v) |
| Write a 16-bit big-endian word into p. | |
| int32_t | priv_jpeg_sw_br_get_bits (ra8_jpeg_bitreader_t *br, uint8_t n) |
| Pop n bits MSB-first; returns -1 on underflow. | |
| void | priv_jpeg_sw_htab_build (ra8_jpeg_htab_t *h) |
| Build canonical code/size and mincode/maxcode tables. | |
| int32_t | priv_jpeg_sw_htab_decode (ra8_jpeg_bitreader_t *br, const ra8_jpeg_htab_t *h) |
| Decode one Huffman symbol from br using table h. | |
| int32_t | priv_jpeg_sw_huff_extend (int32_t v, uint8_t n) |
| Decode a signed n-bit DCT coefficient (T.81 F.1.2.1.3). | |
| void | priv_jpeg_sw_idct8x8 (int32_t *block) |
| Full 8x8 inverse DCT, in place. | |
| void | priv_jpeg_sw_ycc_to_rgb (int32_t y, int32_t cb, int32_t cr, uint8_t *out_r, uint8_t *out_g, uint8_t *out_b) |
| Convert a YCbCr triple to RGB (BT.601, fixed-point). | |
| ra8_err_t | priv_jpeg_sw_skip_segment (ra8_jpeg_dec_ctx_t *d) |
| Skip an unrecognized variable-length segment. | |
| ra8_err_t | priv_jpeg_sw_parse_dqt (ra8_jpeg_dec_ctx_t *d) |
| Parse a DQT segment (T.81 sec B.2.4.1) into d->qtab. | |
| ra8_err_t | priv_jpeg_sw_parse_dht (ra8_jpeg_dec_ctx_t *d) |
| Parse a DHT segment (T.81 sec B.2.4.2) and build its tables. | |
| ra8_err_t | priv_jpeg_sw_parse_sof0 (ra8_jpeg_dec_ctx_t *d) |
| Parse the SOF0 frame header (T.81 sec B.2.2). | |
| ra8_err_t | priv_jpeg_sw_parse_sos (ra8_jpeg_dec_ctx_t *d) |
| Parse the SOS scan header (T.81 sec B.2.3) selectors. | |
| ra8_err_t | priv_jpeg_sw_block (ra8_jpeg_dec_ctx_t *d, ra8_jpeg_bitreader_t *br, uint8_t ci, int32_t *outblk) |
| Entropy-decode one 8x8 block of dequantized coefficients. | |
| void | priv_jpeg_sw_idct_into (int32_t *coeffs, uint8_t *tile) |
| IDCT a coefficient block and emit level-shifted 8-bit samples. | |
| ra8_err_t | priv_jpeg_sw_mcu_y (ra8_jpeg_dec_ctx_t *d, ra8_jpeg_bitreader_t *br, uint8_t *y_tile, uint16_t mcu_w_px) |
| Decode the hmax*vmax luma blocks of one MCU into the Y tile. | |
| ra8_err_t | priv_jpeg_sw_mcu_chroma (ra8_jpeg_dec_ctx_t *d, ra8_jpeg_bitreader_t *br, uint8_t *cb_tile, uint8_t *cr_tile) |
| Decode the Cb and Cr 8x8 blocks of one MCU. | |
| ra8_err_t | priv_jpeg_sw_dispatch (ra8_jpeg_dec_ctx_t *d, bool *got_sof, ra8_jpeg_dec_marker_action_t *action) |
| Dispatch one JPEG marker segment in a decode driver loop. | |
Variables | |
| static const uint8_t | s_zigzag [64] |
| Zig-zag de-interleave order (T.81 Figure 5). | |
| static const int32_t | s_dct_cos_q14 [8][8] |
| Cosine table cos((2n+1)*k*pi/16) * 2^14, k = row, n = col. | |
| static const int32_t | s_dct_w_q14 [8] |
| sqrt(2/N)*C(k) DCT normalization weights, Q14. | |
Module-private declarations shared across the software JPEG
codec translation units.
The pure-software baseline JPEG codec is split across three translation units to keep each file under the maintainability line cap:
Every symbol referenced by more than one of those units lives in this header: the shared C23 typed-enum constant blocks, the two read-only DSP look-up tables, the inline byte/pixel helpers, the bit-reader and Huffman-table struct types, and the prototypes for the decode primitives that the parser unit calls into.
Spec citations are tagged T.81 sec X.Y "..." and refer to ITU-T Recommendation T.81 (1992) | ISO/IEC 10918-1.
Definition in file ra8_jpeg_sw_internal.h.
| enum jpeg_dsp_shift_t : uint8_t |
Fixed-point IDCT / YCbCr shift amounts.
Definition at line 63 of file ra8_jpeg_sw_internal.h.
| enum jpeg_enc_field_t : uint8_t |
JPEG component sampling / table-selector bytes (positional).
| Enumerator | |
|---|---|
| k_jpeg_samp_2x2 | JPEG samp 2x2. |
| k_jpeg_samp_1x1 | JPEG samp 1x1. |
| k_jpeg_dht_ac_chroma | JPEG dht ac chroma. |
| k_jpeg_sos_sel_chroma | JPEG sos sel chroma. |
Definition at line 100 of file ra8_jpeg_sw_internal.h.
| enum jpeg_enc_t : uint16_t |
JPEG encoder quality scaling and segment field values.
Definition at line 89 of file ra8_jpeg_sw_internal.h.
| enum jpeg_marker_range_t : uint16_t |
JPEG SOF marker range and stuffing markers.
Definition at line 80 of file ra8_jpeg_sw_internal.h.
| enum jpeg_misc_t : uint16_t |
Misc JPEG masks / offsets.
Definition at line 53 of file ra8_jpeg_sw_internal.h.
| enum jpeg_ycc_coeff_t : int16_t |
Q15 BT.601 YCbCr->RGB coefficients (== Q16 / 2).
| Enumerator | |
|---|---|
| k_cr_r_q15 | 1.40200 / 2 * 2^15. |
| k_cb_b_q15 | 1.77200 / 2 * 2^15. |
| k_cb_g_q15 | Cb g q15. |
| k_cr_g_q15 | Cr g q15. |
Definition at line 72 of file ra8_jpeg_sw_internal.h.
| enum ra8_jpeg_color_coef_t : int32_t |
BT.601 RGB<->YCbCr fixed-point coefficients (Q16).
Same constants the IJG jccolor.c and jdcolor.c files use (see also T.871 / JFIF colour conversion). All values are fixed-point Q16 (multiply by 1 << 16 and round).
Definition at line 195 of file ra8_jpeg_sw_internal.h.
| enum ra8_jpeg_const_t : uint16_t |
Sizes and indices used throughout the codec.
Definition at line 138 of file ra8_jpeg_sw_internal.h.
| enum ra8_jpeg_dec_marker_action_t : uint8_t |
Result of priv_jpeg_sw_dispatch(): what the driver does next.
| Enumerator | |
|---|---|
| k_ra8_jpeg_dec_continue | Keep scanning markers. |
| k_ra8_jpeg_dec_scan | SOS reached; the driver should run its scan loop. |
| k_ra8_jpeg_dec_eoi | EOI reached; the driver should stop with an error. |
Definition at line 600 of file ra8_jpeg_sw_internal.h.
| enum ra8_jpeg_marker_t : uint16_t |
JPEG segment marker bytes (T.81 sec B.1.1.3 "Marker assignments").
The high byte is always 0xFF.
Definition at line 112 of file ra8_jpeg_sw_internal.h.
| enum ra8_jpeg_shift_t : uint8_t |
Shift amounts and signed-cast helpers.
Definition at line 164 of file ra8_jpeg_sw_internal.h.
|
inlinestatic |
Clamp v to the unsigned 8-bit pixel range.
Saturating cast used by the IDCT output stage so out-of-range coefficients map to the legal 8-bit pixel domain. Pure helper.
| [in] | v | Signed integer value to saturate. |
| 0 | v was negative. |
| 255 | v was > 255. |
| (u8)v | v was in 0..255. |
Definition at line 294 of file ra8_jpeg_sw_internal.h.
References k_ra8_jpeg_pixel_max, and RA8_INTERNAL.
Referenced by priv_jpeg_sw_idct_into(), and priv_jpeg_sw_ycc_to_rgb().
|
inlinestatic |
Read a 16-bit big-endian word from p.
JPEG marker payloads use big-endian length prefixes. Inline helper keeps the parser sites free of byte-shifting noise.
| [in] | p | Non-NULL pointer to two readable bytes. |
| 0..65535 | (p[0] << 8) | p[1]. |
Definition at line 325 of file ra8_jpeg_sw_internal.h.
References k_ra8_jpeg_byte_shift, and RA8_INTERNAL.
Referenced by internal_dims_parse_sof0(), internal_dims_step(), internal_js_begin(), priv_jpeg_sw_parse_dht(), priv_jpeg_sw_parse_dqt(), priv_jpeg_sw_parse_sof0(), priv_jpeg_sw_parse_sos(), priv_jpeg_sw_skip_segment(), ra8_jpeg_sw_decode(), and ra8_jpeg_sw_get_dimensions().
|
inlinestatic |
Write a 16-bit big-endian word into p.
Encoder helper for emitting JPEG marker payloads (length prefixes, SOFn / DHT / DQT field counts).
| [out] | p | Non-NULL pointer to two writable bytes. |
| [in] | v | Value to encode. |
Definition at line 348 of file ra8_jpeg_sw_internal.h.
References k_jpeg_byte_mask, k_ra8_jpeg_byte_shift, and RA8_INTERNAL.
| ra8_err_t priv_jpeg_sw_block | ( | ra8_jpeg_dec_ctx_t * | d, |
| ra8_jpeg_bitreader_t * | br, | ||
| uint8_t | ci, | ||
| int32_t * | outblk ) |
Entropy-decode one 8x8 block of dequantized coefficients.
T.81 sec F.2.2: DC difference + AC run-length decode against the component's Huffman tables, dequantized through its quant table, de-zigzagged into row-major order.
| [in,out] | d | Decoder context (DC predictor mutates). |
| [in,out] | br | Bit reader over the entropy-coded segment. |
| [in] | ci | Component index (0 = luma). |
| [out] | outblk | 64-entry coefficient block. |
| k_ra8_ok | Block decoded. |
| k_ra8_err_protocol_error | Stream underflow / illegal symbol. |
Entropy-decode one 8x8 block of dequantized coefficients.
Definition at line 392 of file ra8_jpeg_sw_decode.c.
References ra8_jpeg_dec_ctx_t::comp_dc_id, ra8_jpeg_dec_ctx_t::comp_dc_pred, ra8_jpeg_dec_ctx_t::comp_qid, ra8_jpeg_dec_ctx_t::hdc, internal_dec_block_ac(), k_ra8_err_protocol_error, k_ra8_jpeg_block_size, priv_jpeg_sw_br_get_bits(), priv_jpeg_sw_htab_decode(), priv_jpeg_sw_huff_extend(), ra8_jpeg_dec_ctx_t::qtab, and RA8_PRIV.
Referenced by priv_jpeg_sw_mcu_chroma(), and priv_jpeg_sw_mcu_y().
| int32_t priv_jpeg_sw_br_get_bits | ( | ra8_jpeg_bitreader_t * | br, |
| uint8_t | n ) |
Pop n bits MSB-first; returns -1 on underflow.
Tops off the accumulator from the entropy stream, then drains n MSBs as a non-negative integer. Defined in ra8_jpeg_sw.c; the parser unit calls it while decoding DC/AC magnitude bits.
| [in,out] | br | Bit reader (state mutated in place). |
| [in] | n | Number of bits to consume (0..16). |
| >=0 | n-bit unsigned value drained from the accumulator. |
| -1 | Underflow / EOI before n bits were available. |
Calls internal_br_fill to top off the accumulator, then drains n MSBs as a non-negative integer.
| [in,out] | br | Bit reader (state mutated in place). |
| [in] | n | Number of bits to consume (0..16). |
| >=0 | n-bit unsigned value drained from the accumulator. |
| -1 | Underflow / EOI before n bits were available. |
Definition at line 134 of file ra8_jpeg_sw.c.
References ra8_jpeg_bitreader_t::acc, internal_br_fill(), ra8_jpeg_bitreader_t::nbits, and RA8_PRIV.
Referenced by internal_dec_block_ac(), priv_jpeg_sw_block(), and priv_jpeg_sw_htab_decode().
| ra8_err_t priv_jpeg_sw_dispatch | ( | ra8_jpeg_dec_ctx_t * | d, |
| bool * | got_sof, | ||
| ra8_jpeg_dec_marker_action_t * | action ) |
Dispatch one JPEG marker segment in a decode driver loop.
Parses one marker following the 0xFF prefix at d->cursor and updates the decoder context. Unknown APPn/COM payloads are skipped; RST markers are consumed as standalone bytes.
| [in,out] | d | Decoder context (cursor advances). |
| [in,out] | got_sof | Tracks whether SOF0 has been parsed yet. |
| [out] | action | What the driver should do next. |
| k_ra8_ok | Marker handled (see *action). |
| k_ra8_err_protocol_error | Malformed marker / truncated stream / SOS before SOF. |
| k_ra8_err_not_supported | Unsupported SOFn (progressive, ...). |
Dispatch one JPEG marker segment in a decode driver loop.
Definition at line 810 of file ra8_jpeg_sw_decode.c.
References ra8_jpeg_dec_ctx_t::cursor, internal_dec_dispatch_tail(), k_jpeg_marker_ff00, k_jpeg_marker_jpg, k_jpeg_marker_sof1, k_jpeg_marker_sof_hi, k_ra8_err_not_supported, k_ra8_err_protocol_error, k_ra8_jpeg_dec_continue, k_ra8_jpeg_marker_byte, k_ra8_jpeg_marker_dht, k_ra8_jpeg_marker_sof0, k_ra8_ok, priv_jpeg_sw_parse_sof0(), RA8_PRIV, ra8_jpeg_dec_ctx_t::src, and ra8_jpeg_dec_ctx_t::src_len.
Referenced by internal_dec_run(), and internal_js_parse_markers().
| void priv_jpeg_sw_htab_build | ( | ra8_jpeg_htab_t * | h | ) |
Build canonical code/size and mincode/maxcode tables.
Implements T.81 Annex C "Generation of size table" + "Generation of code table" plus the Annex F.2.2.3 mincode/maxcode/valptr tables used by the symbol decoder. Defined in ra8_jpeg_sw.c; the parser unit calls it from dec_parse_dht().
| [in,out] | h | Huffman table (BITS / VALS in, derived tables out). |
Definition at line 192 of file ra8_jpeg_sw.c.
References ra8_jpeg_htab_t::bits, ra8_jpeg_htab_t::huffcode, ra8_jpeg_htab_t::huffsize, internal_htab_build_lookup(), k_ra8_jpeg_huff_lengths, RA8_PRIV, and ra8_jpeg_htab_t::total.
Referenced by internal_dec_parse_dht_one().
| int32_t priv_jpeg_sw_htab_decode | ( | ra8_jpeg_bitreader_t * | br, |
| const ra8_jpeg_htab_t * | h ) |
Decode one Huffman symbol from br using table h.
Single-bit greedy lookup per T.81 F.2.2.3 "Decoder code-length algorithm". Returns -1 on stream underflow or table miss. Defined in ra8_jpeg_sw.c; the parser unit calls it from dec_block().
| [in,out] | br | Bit reader (state mutated in place). |
| [in] | h | Pre-built canonical Huffman table. |
| >=0 | Symbol value from h->vals. |
| -1 | Stream underflow or table miss. |
Single-bit greedy lookup per T.81 F.2.2.3 "Decoder code-length algorithm". Returns -1 on stream underflow or table miss.
| [in,out] | br | Bit reader (state mutated in place). |
| [in] | h | Pre-built canonical Huffman table. |
| >=0 | Symbol value from h->vals. |
| -1 | Stream underflow or table miss. |
Definition at line 250 of file ra8_jpeg_sw.c.
References internal_br_fill(), k_ra8_jpeg_huff_lengths, ra8_jpeg_htab_t::mincode, ra8_jpeg_bitreader_t::nbits, priv_jpeg_sw_br_get_bits(), RA8_PRIV, ra8_jpeg_htab_t::total, ra8_jpeg_htab_t::valptr, and ra8_jpeg_htab_t::vals.
Referenced by internal_dec_block_ac(), and priv_jpeg_sw_block().
| int32_t priv_jpeg_sw_huff_extend | ( | int32_t | v, |
| uint8_t | n ) |
Decode a signed n-bit DCT coefficient (T.81 F.1.2.1.3).
Extends a non-negative n-bit pattern into the signed range documented at T.81 Figure F.12 "EXTEND". A leading-zero pattern is treated as the negative of the symmetric positive value. Defined in ra8_jpeg_sw.c; the parser unit calls it from dec_block().
| [in] | v | Non-negative bit pattern from the bit reader. |
| [in] | n | Number of significant bits. |
| 0..(1<<n)-1 | v had its high bit set (positive value). |
| -(1<<n)+1..0 | v had its high bit clear (negative value). |
Extends a non-negative n-bit pattern into the signed range documented at T.81 Figure F.12 "EXTEND". A leading-zero pattern is treated as the negative of the symmetric positive value.
| [in] | v | Non-negative bit pattern from the bit reader. |
| [in] | n | Number of significant bits. |
| 0..(1<<n)-1 | v had its high bit set (positive value). |
| -(1<<n)+1..0 | v had its high bit clear (negative value). |
Definition at line 305 of file ra8_jpeg_sw.c.
References RA8_PRIV.
Referenced by internal_dec_block_ac(), and priv_jpeg_sw_block().
| void priv_jpeg_sw_idct8x8 | ( | int32_t * | block | ) |
Full 8x8 inverse DCT, in place.
Two-pass separable IDCT (rows then columns) using the shared Q14 cosine basis. Defined in ra8_jpeg_sw.c; the parser unit calls it from dec_idct_into().
| [in,out] | block | 64-entry row-major coefficient block, IDCTed in place. |
Definition at line 352 of file ra8_jpeg_sw.c.
References internal_inv_dct_1d_norm(), k_ra8_jpeg_block_dim, k_ra8_jpeg_block_size, and RA8_PRIV.
Referenced by priv_jpeg_sw_idct_into().
| void priv_jpeg_sw_idct_into | ( | int32_t * | coeffs, |
| uint8_t * | tile ) |
IDCT a coefficient block and emit level-shifted 8-bit samples.
Runs the shared 8x8 IDCT, then level-shifts and clamps each sample.
| [in,out] | coeffs | 64-entry coefficient block (IDCTed in place). |
| [out] | tile | 64-byte destination sample tile. |
IDCT a coefficient block and emit level-shifted 8-bit samples.
Definition at line 425 of file ra8_jpeg_sw_decode.c.
References internal_clamp_u8(), k_ra8_jpeg_block_size, k_ra8_jpeg_level_offset, priv_jpeg_sw_idct8x8(), and RA8_PRIV.
Referenced by priv_jpeg_sw_mcu_chroma(), and priv_jpeg_sw_mcu_y().
| ra8_err_t priv_jpeg_sw_mcu_chroma | ( | ra8_jpeg_dec_ctx_t * | d, |
| ra8_jpeg_bitreader_t * | br, | ||
| uint8_t * | cb_tile, | ||
| uint8_t * | cr_tile ) |
Decode the Cb and Cr 8x8 blocks of one MCU.
Consumes one Cb block then one Cr block, IDCTing each into its tile.
| [in,out] | d | Decoder context (DC predictors mutate). |
| [in,out] | br | Bit-reader positioned at the next chroma block. |
| [out] | cb_tile | 64-byte buffer for reconstructed Cb pixels. |
| [out] | cr_tile | 64-byte buffer for reconstructed Cr pixels. |
| k_ra8_ok | Both chroma blocks decoded. |
| k_ra8_err_protocol_error | Underlying block decode failed. |
Decode the Cb and Cr 8x8 blocks of one MCU.
Definition at line 493 of file ra8_jpeg_sw_decode.c.
References k_ra8_jpeg_block_size, k_ra8_ok, priv_jpeg_sw_block(), priv_jpeg_sw_idct_into(), and RA8_PRIV.
Referenced by internal_dec_decode_mcu(), and internal_js_decode_mcu().
| ra8_err_t priv_jpeg_sw_mcu_y | ( | ra8_jpeg_dec_ctx_t * | d, |
| ra8_jpeg_bitreader_t * | br, | ||
| uint8_t * | y_tile, | ||
| uint16_t | mcu_w_px ) |
Decode the hmax*vmax luma blocks of one MCU into the Y tile.
Decodes hmax*vmax successive luma blocks into their tile sub-rectangles.
| [in,out] | d | Decoder context (DC predictors mutate). |
| [in,out] | br | Bit-reader positioned at the next luma block. |
| [out] | y_tile | Output tile of (mcu_w_px x mcu_h_px) luma px. |
| [in] | mcu_w_px | MCU width in pixels. |
| k_ra8_ok | All luma blocks consumed. |
| k_ra8_err_protocol_error | Underlying block decode failed. |
Decode the hmax*vmax luma blocks of one MCU into the Y tile.
Definition at line 472 of file ra8_jpeg_sw_decode.c.
References ra8_jpeg_dec_ctx_t::hmax, internal_dec_copy_block_to_tile(), k_ra8_jpeg_block_size, k_ra8_ok, priv_jpeg_sw_block(), priv_jpeg_sw_idct_into(), RA8_PRIV, and ra8_jpeg_dec_ctx_t::vmax.
Referenced by internal_dec_decode_mcu(), and internal_js_decode_mcu().
| ra8_err_t priv_jpeg_sw_parse_dht | ( | ra8_jpeg_dec_ctx_t * | d | ) |
Parse a DHT segment (T.81 sec B.2.4.2) and build its tables.
T.81 sec B.2.4.2: reads the BITS/VALS lists and canonical-builds the table.
| [in,out] | d | Decoder context (cursor advances; tables written). |
| k_ra8_ok | Table(s) parsed and built. |
| k_ra8_err_protocol_error | Truncated / malformed segment. |
| k_ra8_err_not_supported | Table class / id out of range. |
Parse a DHT segment (T.81 sec B.2.4.2) and build its tables.
Definition at line 158 of file ra8_jpeg_sw_decode.c.
References ra8_jpeg_dec_ctx_t::cursor, internal_dec_parse_dht_one(), internal_read_be16(), k_ra8_err_protocol_error, k_ra8_ok, RA8_PRIV, ra8_jpeg_dec_ctx_t::src, and ra8_jpeg_dec_ctx_t::src_len.
Referenced by internal_dec_dispatch_tail().
| ra8_err_t priv_jpeg_sw_parse_dqt | ( | ra8_jpeg_dec_ctx_t * | d | ) |
Parse a DQT segment (T.81 sec B.2.4.1) into d->qtab.
T.81 sec B.2.4.1: de-zigzags each 8-bit table into d->qtab.
| [in,out] | d | Decoder context (cursor advances; tables written). |
| k_ra8_ok | Table(s) parsed. |
| k_ra8_err_protocol_error | Truncated / malformed segment. |
| k_ra8_err_not_supported | 16-bit precision table. |
Parse a DQT segment (T.81 sec B.2.4.1) into d->qtab.
Definition at line 68 of file ra8_jpeg_sw_decode.c.
References ra8_jpeg_dec_ctx_t::cursor, internal_read_be16(), k_ra8_err_not_supported, k_ra8_err_protocol_error, k_ra8_jpeg_block_size, k_ra8_jpeg_nibble_mask, k_ra8_jpeg_nibble_shift, k_ra8_jpeg_quant_tabs, k_ra8_ok, ra8_jpeg_dec_ctx_t::qtab, RA8_PRIV, s_zigzag, ra8_jpeg_dec_ctx_t::src, and ra8_jpeg_dec_ctx_t::src_len.
Referenced by internal_dec_dispatch_tail().
| ra8_err_t priv_jpeg_sw_parse_sof0 | ( | ra8_jpeg_dec_ctx_t * | d | ) |
Parse the SOF0 frame header (T.81 sec B.2.2).
T.81 sec B.2.2: reads precision, dimensions and per-component sampling.
| [in,out] | d | Decoder context (dims/sampling written). |
| k_ra8_ok | Baseline frame accepted. |
| k_ra8_err_protocol_error | Truncated / malformed segment. |
| k_ra8_err_not_supported | Non-8-bit precision, component count not 1/3, or a chroma layout other than 4:4:4 / 4:2:0. |
Parse the SOF0 frame header (T.81 sec B.2.2).
Definition at line 258 of file ra8_jpeg_sw_decode.c.
References ra8_jpeg_dec_ctx_t::cursor, ra8_jpeg_dec_ctx_t::height, internal_dec_check_chroma_layout(), internal_dec_parse_sof0_components(), internal_read_be16(), k_ra8_err_not_supported, k_ra8_err_protocol_error, ra8_jpeg_dec_ctx_t::ncomp, RA8_PRIV, ra8_jpeg_dec_ctx_t::src, ra8_jpeg_dec_ctx_t::src_len, and ra8_jpeg_dec_ctx_t::width.
Referenced by priv_jpeg_sw_dispatch().
| ra8_err_t priv_jpeg_sw_parse_sos | ( | ra8_jpeg_dec_ctx_t * | d | ) |
Parse the SOS scan header (T.81 sec B.2.3) selectors.
T.81 sec B.2.3: binds each scan component to its DC/AC table selectors.
| [in,out] | d | Decoder context (per-component table ids written). |
| k_ra8_ok | Scan header accepted. |
| k_ra8_err_protocol_error | Truncated / malformed segment. |
| k_ra8_err_not_supported | Component count mismatch or selector out of range. |
Parse the SOS scan header (T.81 sec B.2.3) selectors.
Definition at line 291 of file ra8_jpeg_sw_decode.c.
References ra8_jpeg_dec_ctx_t::comp_ac_id, ra8_jpeg_dec_ctx_t::comp_dc_id, ra8_jpeg_dec_ctx_t::comp_id, ra8_jpeg_dec_ctx_t::cursor, internal_read_be16(), k_ra8_err_not_supported, k_ra8_err_protocol_error, k_ra8_jpeg_huff_ids, k_ra8_jpeg_nibble_mask, k_ra8_jpeg_nibble_shift, k_ra8_ok, ra8_jpeg_dec_ctx_t::ncomp, RA8_PRIV, ra8_jpeg_dec_ctx_t::src, and ra8_jpeg_dec_ctx_t::src_len.
Referenced by internal_dec_dispatch_tail().
| ra8_err_t priv_jpeg_sw_skip_segment | ( | ra8_jpeg_dec_ctx_t * | d | ) |
Skip an unrecognized variable-length segment.
Reads the 16-bit big-endian segment length at d->cursor and advances past the payload, bounds-checked against d->src_len.
| [in,out] | d | Decoder context (cursor advances). |
| k_ra8_ok | Segment skipped. |
| k_ra8_err_protocol_error | Truncated / malformed length field. |
Skip an unrecognized variable-length segment.
Definition at line 54 of file ra8_jpeg_sw_decode.c.
References ra8_jpeg_dec_ctx_t::cursor, internal_read_be16(), k_ra8_err_protocol_error, k_ra8_ok, RA8_PRIV, ra8_jpeg_dec_ctx_t::src, and ra8_jpeg_dec_ctx_t::src_len.
Referenced by internal_dec_dispatch_tail().
| void priv_jpeg_sw_ycc_to_rgb | ( | int32_t | y, |
| int32_t | cb, | ||
| int32_t | cr, | ||
| uint8_t * | out_r, | ||
| uint8_t * | out_g, | ||
| uint8_t * | out_b ) |
Convert a YCbCr triple to RGB (BT.601, fixed-point).
Defined in ra8_jpeg_sw.c; the parser unit calls it from the MCU pixel-emit loop. The MVE-accelerated row helper is enabled when __ARM_FEATURE_MVE is defined; the scalar path is what host tests exercise.
| [in] | y | Luma sample. |
| [in] | cb | Cb chroma sample (level-offset removed inside). |
| [in] | cr | Cr chroma sample (level-offset removed inside). |
| [out] | out_r | Receives the red channel byte. |
| [out] | out_g | Receives the green channel byte. |
| [out] | out_b | Receives the blue channel byte. |
MVE-accelerated path is enabled when __ARM_FEATURE_MVE is defined (Cortex-M85 target). Host tests run the scalar path.
| [in,out] | cb | See function signature. |
| [in,out] | cr | See function signature. |
| [in,out] | out_b | See function signature. |
| [in,out] | out_g | See function signature. |
| [in,out] | out_r | See function signature. |
| [in,out] | y | See function signature. |
Definition at line 402 of file ra8_jpeg_sw.c.
References internal_clamp_u8(), k_ra8_jpeg_cb_b, k_ra8_jpeg_cb_g, k_ra8_jpeg_cr_g, k_ra8_jpeg_cr_r, k_ra8_jpeg_level_offset, k_ra8_jpeg_yuv_shift, and RA8_PRIV.
Referenced by internal_dec_emit_mcu_rgb(), and internal_js_emit_mcu().
|
static |
Cosine table cos((2n+1)*k*pi/16) * 2^14, k = row, n = col.
Shared by both forward and inverse 1-D DCT so the encoder and decoder are guaranteed to use a numerically identical basis. Q14 picks the largest scale that lets a row sum fit in int32_t for 16-bit pre-normalized inputs. Read-only; each translation unit holds its own copy.
Definition at line 235 of file ra8_jpeg_sw_internal.h.
Referenced by internal_fwd_dct_1d_norm(), and internal_inv_dct_1d_norm().
|
static |
sqrt(2/N)*C(k) DCT normalization weights, Q14.
The cosine table is Q14; this sqrt(2/N)*C(k) weight is also Q14 so the inner accumulator is Q28, which the DCT row loops shift back to Q0 with a >>14 round on emit. Read-only; each translation unit holds its own copy.
Definition at line 255 of file ra8_jpeg_sw_internal.h.
Referenced by internal_fwd_dct_1d_norm(), and internal_inv_dct_1d_norm().
|
static |
Zig-zag de-interleave order (T.81 Figure 5).
s_zigzag[i] returns the row-major 0..63 position that the i-th transmitted coefficient lives at inside an 8x8 block. Read-only; each translation unit holds its own copy.
Definition at line 219 of file ra8_jpeg_sw_internal.h.
Referenced by internal_dec_block_ac(), internal_enc_block(), internal_enc_emit_dqt(), and priv_jpeg_sw_parse_dqt().