29typedef enum : int32_t {
65 return (uint8_t)component;
127 const uint32_t offset = row + (x * 3U);
128 output[0] = input->
data[offset];
129 output[1] = input->
data[offset + 1U];
130 output[2] = input->
data[offset + 2U];
133 const uint32_t pair = row + ((x & ~1U) * 2U);
134 const uint32_t yoff = ((x & 1U) == 0U) ? 1U : 3U;
137 input->
data[pair + 2U],
160 for (uint32_t y = 0U; y < out_height; y += 1U) {
161 const uint32_t source_y = (y * (uint32_t)input->
height) / out_height;
162 for (uint32_t x = 0U; x < out_width; x += 1U) {
163 const uint32_t source_x = (x * (uint32_t)input->
width) / out_width;
198 if (ctx ==
nullptr) {
201 if (input ==
nullptr) {
204 if (output_buffer ==
nullptr) {
207 if (out_frame ==
nullptr) {
210 if (output_buffer->
data ==
nullptr) {
213 if (output_buffer->
capacity == 0U) {
223 uint32_t produced = 0U;
235 .data = output_buffer->
data,
254 if (codec ==
nullptr) {
257 if (state ==
nullptr) {
260 if (cfg ==
nullptr) {
278 const uint32_t row_bytes = (uint32_t)cfg->
output_width * 3U;
279 if ((uint32_t)cfg->
output_height > (UINT32_MAX / row_bytes)) {
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
struct ra8_camera_codec_iface ra8_camera_codec_iface_t
Opaque codec vtable; concrete codec backends define its rows.
@ k_ra8_camera_format_rgb888
Packed R, G, B bytes per pixel.
@ k_ra8_camera_format_uyvy422
Packed Cb, Y0, Cr, Y1 pixel pairs.
@ k_ra8_camera_format_jpeg
Complete encoded JPEG byte stream.
camera_jpeg_color_t
BT.601 limited-range fixed-point conversion constants.
@ k_camera_jpeg_luma_scale
Fixed-point luma scale.
@ k_camera_jpeg_blue_cb
Cb contribution to blue.
@ k_camera_jpeg_shift
Fixed-point fractional-bit count.
@ k_camera_jpeg_u8_max
Maximum packed RGB channel value.
@ k_camera_jpeg_chroma_mid
Neutral chroma level.
@ k_camera_jpeg_luma_black
Limited-range black level.
@ k_camera_jpeg_red_cr
Cr contribution to red.
@ k_camera_jpeg_green_cb
Cb subtraction from green.
@ k_camera_jpeg_rounding
Fixed-point rounding bias.
@ k_camera_jpeg_green_cr
Cr subtraction from green.
static ra8_err_t internal_jpeg_sw_encode(void *ctx, const ra8_camera_frame_t *input, const ra8_camera_buffer_t *output_buffer, ra8_camera_frame_t *out_frame)
Convert and encode one raw frame with ra8_jpeg_sw.
ra8_err_t ra8_camera_codec_jpeg_sw_init(ra8_camera_codec_t *codec, ra8_camera_codec_jpeg_sw_state_t *state, const ra8_camera_codec_jpeg_sw_cfg_t *cfg)
Bind the software baseline-JPEG encoder backend.
static uint8_t internal_jpeg_sw_clamp(int32_t component)
Clamp a signed RGB component to one byte.
static void internal_jpeg_sw_ycbcr_to_rgb(uint8_t y, uint8_t cb, uint8_t cr, uint8_t *output)
Convert one limited-range YCbCr pixel to packed RGB888.
static void internal_jpeg_sw_prepare_rgb(const ra8_camera_codec_jpeg_sw_state_t *state, const ra8_camera_frame_t *input)
Nearest-neighbour sample input into the configured RGB workspace.
static void internal_jpeg_sw_read_rgb(const ra8_camera_frame_t *input, uint32_t x, uint32_t y, uint8_t *output)
Read one source pixel as RGB888.
static const ra8_camera_codec_iface_t s_jpeg_sw_codec_iface
Software JPEG codec vtable.
RGB888-to-JPEG software codec backend for ra8_camera.
Private source and codec vtables for ra8_camera backends.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_not_supported
Requested feature not compiled in, not wired, or not supported by this MCU variant.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Pure-software baseline JPEG (ISO/IEC 10918-1 / ITU-T T.81) codec.
@ k_ra8_jpeg_sw_quality_min
Lowest legal quality.
@ k_ra8_jpeg_sw_quality_max
Largest legal quality.
ra8_err_t ra8_jpeg_sw_encode(const uint8_t *rgb_buf, uint16_t width, uint16_t height, uint8_t quality, uint8_t *out_buf, uint32_t out_buf_len, uint32_t *out_len)
Encode a packed RGB888 frame as a baseline JPEG.
Caller-owned writable byte-buffer description.
uint32_t capacity
Writable byte capacity.
uint8_t * data
First writable byte, or NULL when capacity is zero.
Configuration and caller-owned RGB workspace for software JPEG.
uint16_t output_width
Encoded image width.
uint32_t rgb_workspace_capacity
Writable workspace bytes.
uint8_t quality
JPEG quality passed to the encoder.
uint16_t output_height
Encoded image height.
uint8_t * rgb_workspace
Caller-owned packed RGB workspace.
Caller-owned private state for the software JPEG backend.
ra8_camera_codec_jpeg_sw_cfg_t cfg
Validated configuration (private).
Caller-owned handle binding one image codec and its context.
void * ctx
Caller-owned backend context.
const ra8_camera_codec_iface_t * iface
Bound codec vtable (private).
Immutable view of one captured or encoded image.
ra8_camera_format_t format
Pixel or compressed-image layout.
const uint8_t * data
Borrowed immutable image bytes.
uint16_t height
Image height in pixels.
uint16_t width
Image width in pixels.
uint32_t stride_bytes
Bytes between uncompressed rows.