|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Module-private declarations shared by the two encoder translation units of the software JPEG codec. More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_err.h"#include "ra8_jpeg_sw_internal.h"Go to the source code of this file.
Data Structures | |
| struct | ra8_jpeg_enc_ctx_t |
| Encoder state – buffer cursor, bit accumulator, scaled quant tables, Huffman LUTs and DC predictors. More... | |
Functions | |
| void | priv_jpeg_sw_enc_emit_u16 (ra8_jpeg_enc_ctx_t *e, uint16_t v) |
| Append a 16-bit big-endian word to the JPEG byte stream. | |
| void | priv_jpeg_sw_enc_put_bits (ra8_jpeg_enc_ctx_t *e, uint32_t code, uint8_t n) |
| Push n bits MSB-first into the entropy stream with stuffing. | |
| void | priv_jpeg_sw_enc_flush_bits (ra8_jpeg_enc_ctx_t *e) |
| Flush any partial byte at the end of a scan with 1-fill. | |
| void | priv_jpeg_sw_enc_build_huff (ra8_jpeg_enc_ctx_t *e, uint16_t *total_dc_l, uint16_t *total_ac_l, uint16_t *total_dc_c, uint16_t *total_ac_c) |
| Build the four Annex K.3.3 Huffman code/size LUTs. | |
| void | priv_jpeg_sw_enc_headers (ra8_jpeg_enc_ctx_t *e, uint16_t w, uint16_t h, uint16_t total_dc_l, uint16_t total_ac_l, uint16_t total_dc_c, uint16_t total_ac_c) |
| Emit the SOI/APP0/DQT/SOF0/DHT/SOS header segments. | |
Module-private declarations shared by the two encoder translation units of the software JPEG codec.
The pure-software baseline JPEG encoder is split across two translation units to keep each file under the maintainability line cap:
Every symbol referenced by both units lives here: the encoder context struct and the ra8_jpeg_sw_priv_enc_* primitives the pixel pipeline 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_encode_internal.h.
| void priv_jpeg_sw_enc_build_huff | ( | ra8_jpeg_enc_ctx_t * | e, |
| uint16_t * | total_dc_l, | ||
| uint16_t * | total_ac_l, | ||
| uint16_t * | total_dc_c, | ||
| uint16_t * | total_ac_c ) |
Build the four Annex K.3.3 Huffman code/size LUTs.
Canonical-builds the luma/chroma DC/AC code and size look-up tables into the encoder context and returns each table's symbol count for the DHT emitters. Defined in ra8_jpeg_sw_encode_emit.c.
| [in,out] | e | Encoder context (code/size LUTs written). |
| [out] | total_dc_l | Luma DC symbol count. |
| [out] | total_ac_l | Luma AC symbol count. |
| [out] | total_dc_c | Chroma DC symbol count. |
| [out] | total_ac_c | Chroma AC symbol count. |
Build the four Annex K.3.3 Huffman code/size LUTs.
Definition at line 318 of file ra8_jpeg_sw_encode_emit.c.
References ra8_jpeg_enc_ctx_t::code_ac_c, ra8_jpeg_enc_ctx_t::code_ac_l, ra8_jpeg_enc_ctx_t::code_dc_c, ra8_jpeg_enc_ctx_t::code_dc_l, internal_enc_build_codes(), k_ra8_jpeg_huff_lengths, RA8_PRIV, s_hbits_ac_chroma, s_hbits_ac_luma, s_hbits_dc_chroma, s_hbits_dc_luma, s_hval_ac_chroma, s_hval_ac_luma, s_hval_dc_chroma, s_hval_dc_luma, ra8_jpeg_enc_ctx_t::size_ac_c, ra8_jpeg_enc_ctx_t::size_ac_l, ra8_jpeg_enc_ctx_t::size_dc_c, and ra8_jpeg_enc_ctx_t::size_dc_l.
Referenced by internal_enc_run().
| void priv_jpeg_sw_enc_emit_u16 | ( | ra8_jpeg_enc_ctx_t * | e, |
| uint16_t | v ) |
Append a 16-bit big-endian word to the JPEG byte stream.
Emits the high byte then the low byte through the internal byte emitter; sets e->overflow instead of writing past e->cap. Defined in ra8_jpeg_sw_encode_emit.c.
| [in,out] | e | Encoder context (cursor advances). |
| [in] | v | Value to append (marker code or length field). |
Append a 16-bit big-endian word to the JPEG byte stream.
Definition at line 216 of file ra8_jpeg_sw_encode_emit.c.
References internal_enc_emit_u8(), k_jpeg_byte_mask, k_ra8_jpeg_byte_shift, and RA8_PRIV.
Referenced by internal_enc_emit_app0_jfif(), internal_enc_emit_dht_one(), internal_enc_emit_dqt(), internal_enc_emit_sof0(), internal_enc_emit_sos(), and internal_enc_run().
| void priv_jpeg_sw_enc_flush_bits | ( | ra8_jpeg_enc_ctx_t * | e | ) |
Flush any partial byte at the end of a scan with 1-fill.
Pads the residual bit_cnt bits with ones (T.81 sec F.1.2.3) so the final entropy byte is complete before the EOI marker. Defined in ra8_jpeg_sw_encode_emit.c.
| [in,out] | e | Encoder context (bit buffer + cursor mutate). |
Flush any partial byte at the end of a scan with 1-fill.
Definition at line 238 of file ra8_jpeg_sw_encode_emit.c.
References ra8_jpeg_enc_ctx_t::bit_buf, ra8_jpeg_enc_ctx_t::bit_cnt, k_jpeg_byte_mask, k_ra8_jpeg_byte_shift, priv_jpeg_sw_enc_put_bits(), and RA8_PRIV.
Referenced by internal_enc_run().
| void priv_jpeg_sw_enc_headers | ( | ra8_jpeg_enc_ctx_t * | e, |
| uint16_t | w, | ||
| uint16_t | h, | ||
| uint16_t | total_dc_l, | ||
| uint16_t | total_ac_l, | ||
| uint16_t | total_dc_c, | ||
| uint16_t | total_ac_c ) |
Emit the SOI/APP0/DQT/SOF0/DHT/SOS header segments.
Writes every byte that precedes the entropy-coded scan of a 4:2:0 YCbCr baseline stream, in JFIF 1.1 order. Defined in ra8_jpeg_sw_encode_emit.c.
| [in,out] | e | Encoder context (cursor advances). |
| [in] | w | Image width in pixels. |
| [in] | h | Image height in pixels. |
| [in] | total_dc_l | Luma DC symbol count (from build_huff). |
| [in] | total_ac_l | Luma AC symbol count. |
| [in] | total_dc_c | Chroma DC symbol count. |
| [in] | total_ac_c | Chroma AC symbol count. |
Emit the SOI/APP0/DQT/SOF0/DHT/SOS header segments.
Definition at line 543 of file ra8_jpeg_sw_encode_emit.c.
References internal_enc_emit_app0_jfif(), internal_enc_emit_dht_one(), internal_enc_emit_dqt(), internal_enc_emit_sof0(), internal_enc_emit_sos(), k_jpeg_dht_ac_chroma, RA8_PRIV, s_hbits_ac_chroma, s_hbits_ac_luma, s_hbits_dc_chroma, s_hbits_dc_luma, s_hval_ac_chroma, s_hval_ac_luma, s_hval_dc_chroma, and s_hval_dc_luma.
Referenced by internal_enc_run().
| void priv_jpeg_sw_enc_put_bits | ( | ra8_jpeg_enc_ctx_t * | e, |
| uint32_t | code, | ||
| uint8_t | n ) |
Push n bits MSB-first into the entropy stream with stuffing.
Accumulates bits and flushes whole bytes, inserting the T.81 sec F.1.2.3 0x00 stuffing byte after every emitted 0xFF. Defined in ra8_jpeg_sw_encode_emit.c.
| [in,out] | e | Encoder context (bit buffer + cursor mutate). |
| [in] | code | Right-aligned code bits to append. |
| [in] | n | Number of significant bits in code (0..24). |
Push n bits MSB-first into the entropy stream with stuffing.
Definition at line 223 of file ra8_jpeg_sw_encode_emit.c.
References ra8_jpeg_enc_ctx_t::bit_buf, ra8_jpeg_enc_ctx_t::bit_cnt, internal_enc_emit_u8(), k_ra8_jpeg_byte_shift, k_ra8_jpeg_marker_byte, and RA8_PRIV.
Referenced by internal_enc_block(), internal_enc_block_ac(), and priv_jpeg_sw_enc_flush_bits().