chore: migrate project into clean repository

This commit is contained in:
yuuux
2026-08-13 16:50:52 +08:00
commit d1d25a09e7
27405 changed files with 9422808 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.13)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(listenai-cmake REQUIRED HINTS $ENV{ARCS_BASE})
project(arcs)
listenai_add_executable(${PROJECT_NAME})
target_sources(${PROJECT_NAME} PRIVATE src/main.c)

View File

@@ -0,0 +1 @@
osource "$ARCS_BASE/Kconfig"

View File

@@ -0,0 +1,210 @@
# JPEG 解码示例
## 功能说明
演示如何使用 IJG JPEG 库从内存缓冲区读取 JPEG 数据并解码为 RGB565 格式。本示例展示了如何设置自定义错误处理、从内存读取 JPEG 数据、配置解压缩参数、逐行解码图像数据,以及将 RGB888 转换为 RGB565 格式。
IJG (Independent JPEG Group) JPEG 库是一个广泛使用的 JPEG 图像压缩和解压缩库,支持多种输入输出格式和颜色空间。
## 硬件连接
无需外部连接,JPEG 解码为纯软件图像处理库。
## 示例内容
1. 定义自定义错误处理结构(使用 `setjmp`/`longjmp` 进行错误恢复)
2. 实现自定义错误处理函数 `my_error_exit`
3. 实现 RGB888 到 RGB565 的转换函数
6. 实现 JPEG 到 RGB565 的转换函数:
- 设置错误处理
- 创建解压缩对象
- 指定内存数据源
- 读取 JPEG 文件头
- 设置输出颜色空间为 RGB
- 启动解压缩器
- 获取图像尺寸
- 逐行读取并转换像素数据
- 完成解压缩并释放资源
7. 使用内置的测试 JPEG 数据(1x1 像素)进行转换测试
8. 打印转换结果和图像尺寸
9. 释放 RGB565 数据内存
## 编译运行
```{eval-rst}
.. include:: /sample_build.rst
```
## 预期输出
```
********Arcs SDK 0.1.0 @ v0.0.23.temp.docs-96-gf56c5084660d********
Running on hart-id: 1
I/elog [1034:42:44.159 1 elog_async] EasyLogger V2.2.99 is initialize success.
[I][sample] JPEG (from memory) to RGB565 converter sample
[I][sample] Conversion completed successfully
[I][sample] Image dimensions: 1 x 1
```
**说明**:
- 输出开头包含系统启动信息和日志系统初始化信息
- 示例使用内置的 1x1 像素 JPEG 数据进行测试
- 转换成功后显示图像尺寸
- 如果转换失败,会输出 "Conversion failed"
## 核心 API
| API | 说明 |
|-----|------|
| `jpeg_create_decompress()` | 创建 JPEG 解压缩对象 |
| `jpeg_mem_src()` | 指定内存数据源 |
| `jpeg_read_header()` | 读取 JPEG 文件头并获取图像信息 |
| `jpeg_start_decompress()` | 启动解压缩过程 |
| `jpeg_read_scanlines()` | 读取一行或多行扫描线数据 |
| `jpeg_finish_decompress()` | 完成解压缩 |
| `jpeg_destroy_decompress()` | 销毁解压缩对象并释放资源 |
| `jpeg_std_error()` | 获取标准错误处理管理器 |
## 关键代码
```c
/* 自定义错误处理结构 */
struct my_error_mgr {
struct jpeg_error_mgr pub; /* "public" fields */
jmp_buf setjmp_buffer; /* for return to caller */
};
/* 自定义错误处理函数 */
METHODDEF(void)
my_error_exit(j_common_ptr cinfo)
{
my_error_ptr myerr = (my_error_ptr) cinfo->err;
(*cinfo->err->output_message) (cinfo);
longjmp(myerr->setjmp_buffer, 1);
}
/* RGB888 到 RGB565 转换 */
static uint16_t rgb888_to_rgb565(uint8_t r, uint8_t g, uint8_t b)
{
uint16_t rgb565 = ((r & 0xF8) << 8) | /* 5 bits for red */
((g & 0xFC) << 3) | /* 6 bits for green */
((b & 0xF8) >> 3); /* 5 bits for blue */
return rgb565;
}
/* JPEG 到 RGB565 转换函数 */
int jpeg_memory_to_rgb565(const unsigned char *jpeg_data, size_t jpeg_size,
uint16_t **rgb565_output, int *width, int *height)
{
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
JSAMPARRAY buffer;
int row_stride;
uint16_t *rgb565_buffer = NULL;
/* 设置错误处理 */
cinfo.err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = my_error_exit;
/* 建立错误恢复点 */
if (setjmp(jerr.setjmp_buffer)) {
jpeg_destroy_decompress(&cinfo);
if (rgb565_buffer != NULL) {
free(rgb565_buffer);
}
return -1;
}
/* 初始化解压缩对象 */
jpeg_create_decompress(&cinfo);
/* 指定内存数据源 */
jpeg_mem_src(&cinfo, jpeg_data, jpeg_size);
/* 读取文件头 */
(void) jpeg_read_header(&cinfo, TRUE);
/* 设置输出颜色空间为 RGB */
cinfo.out_color_space = JCS_RGB;
/* 启动解压缩器 */
(void) jpeg_start_decompress(&cinfo);
/* 获取图像尺寸 */
*width = cinfo.output_width;
*height = cinfo.output_height;
/* 计算行步长 */
row_stride = cinfo.output_width * cinfo.output_components;
/* 分配行缓冲区 */
buffer = (*cinfo.mem->alloc_sarray)
((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
/* 分配 RGB565 输出缓冲区 */
rgb565_buffer = (uint16_t *)malloc(
cinfo.output_width * cinfo.output_height * sizeof(uint16_t));
/* 逐行处理 */
uint16_t *current_line = rgb565_buffer;
while (cinfo.output_scanline < cinfo.output_height) {
/* 读取一行像素 */
(void) jpeg_read_scanlines(&cinfo, buffer, 1);
/* 转换为 RGB565 */
for (int i = 0; i < cinfo.output_width; i++) {
uint8_t r = buffer[0][i * 3]; /* Red */
uint8_t g = buffer[0][i * 3 + 1]; /* Green */
uint8_t b = buffer[0][i * 3 + 2]; /* Blue */
current_line[i] = rgb888_to_rgb565(r, g, b);
}
current_line += cinfo.output_width;
}
/* 完成解压缩 */
(void) jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
/* 设置输出指针 */
*rgb565_output = rgb565_buffer;
return 0;
}
```
## 颜色格式说明
### RGB888 (24-bit)
- 每个像素 3 字节(红、绿、蓝各 1 字节)
- 红色:8 位(0-255)
- 绿色:8 位(0-255)
- 蓝色:8 位(0-255)
### RGB565 (16-bit)
- 每个像素 2 字节(16 位)
- 红色:5 位(高 5 位)
- 绿色:6 位(中间 6 位)
- 蓝色:5 位(低 5 位)
- 转换公式:`RGB565 = (R & 0xF8) << 8 | (G & 0xFC) << 3 | (B & 0xF8) >> 3`
## 配置说明
### 必需配置
- **`CONFIG_SDK_MODULE_IJG=y`**: 启用 IJG JPEG 库模块
### 可选配置
- **`CONFIG_MEM_CONFIG=y`**: 启用内存配置(如果需要)
## 注意事项
1. **错误处理**: IJG JPEG 库使用 `setjmp`/`longjmp` 机制进行错误处理,必须设置自定义错误处理函数,否则错误会导致程序崩溃
2. **内存管理**: 使用 `jpeg_mem_src()` 时,JPEG 数据必须完整存在于内存中,不能是流式数据
3. **资源清理**: 解压缩完成后必须调用 `jpeg_finish_decompress()` 和 `jpeg_destroy_decompress()` 释放资源
4. **输出缓冲区**: RGB565 输出缓冲区由调用者分配,使用完毕后必须由调用者释放(使用 `free()`)
5. **颜色空间**: 输出颜色空间设置为 `JCS_RGB`,输出为每像素 3 字节的 RGB888 格式,需要手动转换为 RGB565
6. **行缓冲区**: 使用 `alloc_sarray()` 分配的行缓冲区由 JPEG 库管理,无需手动释放
7. **图像尺寸**: 图像尺寸在 `jpeg_start_decompress()` 后通过 `cinfo.output_width` 和 `cinfo.output_height` 获取
8. **逐行处理**: 使用 `jpeg_read_scanlines()` 逐行读取数据,适合处理大图像,避免一次性加载整个图像到内存
9. **内存数据源**: 使用 IJG 库提供的 `jpeg_mem_src()` 函数从内存读取 JPEG 数据,该函数内部处理了内存源管理,无需手动实现

View File

@@ -0,0 +1,177 @@
#!/bin/bash
set -e
usage() {
echo "使用方式: $0 [选项]"
echo "选项:"
echo " -S, --Source <path> 指定项目源码路径 (默认为当前脚本所在目录)"
echo " -t, --target <target> 指定构建目标 (如 menuconfig)"
echo " -C, --Clean 清理构建目录"
echo " -B, --build 构建输出目录"
echo " -h, --help 显示此帮助信息"
echo " -r, --release 以 Release 模式构建 (移除 DEBUG_PATH 信息)"
echo " -w, --warnings-as-errors 将警告视为错误"
echo " -D<var>=<value> 传递 CMake 变量 (可多次使用)"
echo ""
echo "示例:"
echo " $0 -S samples/helloworld -DBOARD=arcs_mini 指定板型构建"
echo " $0 -S samples/helloworld -DBOARD=arcs_evb 使用 EVB 板型"
echo " $0 -S samples/helloworld -t menuconfig -DBOARD=arcs_mini 运行 menuconfig"
echo " $0 -C -S samples/helloworld -DBOARD=arcs_mini 清理并重新构建"
echo " $0 -S samples/helloworld -DBOARD=my_board -DBOARD_SEARCH_PATH=/path/to/boards 使用自定义板型"
exit 1
}
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
PROJECT_PATH="$SCRIPT_DIR"
TARGET=""
CLEAN=false
OUTPUT="build"
WARNINGS_AS_ERRORS=false
RELEASE=false
ARCS_BASE_DIR_NAME="arcs-sdk"
ARCS_DEV_TOOLS_DIR_NAME="listenai-dev-tools"
ARCS_DEV_TOOL_TOOLCHAIN_DIR_NAME="gcc"
ARCS_DEV_TOOL_LISTENAI_TOOLS_DIR_NAME="listenai-tools"
find_arcs_base() {
local current_dir=$(cd "$(dirname "$0")" && pwd)
local dir_name="$ARCS_BASE_DIR_NAME"
while [ "$current_dir" != "/" ]; do
if [ -d "$current_dir/$dir_name" ]; then
echo "Found ARCS_BASE: $current_dir/$dir_name"
export ARCS_BASE="$current_dir/$dir_name"
return 0
fi
current_dir=$(dirname "$current_dir")
done
echo "ARCS_BASE not found, Please add ARCS_BASE environment variable or set ARCS_BASE_DIR_NAME to the correct directory."
echo "Current Target ARCS_BASE directory name: $ARCS_BASE_DIR_NAME."
exit 1
}
find_dev_tools() {
local current_dir=$(cd "$(dirname "$0")" && pwd)
local dir_name="$ARCS_DEV_TOOLS_DIR_NAME"
echo "trying to find $dir_name in parent directories..."
while [ "$current_dir" != "/" ]; do
if [ -d "$current_dir/$dir_name" ]; then
echo "Found $dir_name: $current_dir/$dir_name"
if [ -d "$current_dir/$dir_name/$ARCS_DEV_TOOL_LISTENAI_TOOLS_DIR_NAME" ]; then
echo "Found LISTENAI_TOOLS_PATH: $current_dir/$dir_name/$ARCS_DEV_TOOL_LISTENAI_TOOLS_DIR_NAME"
export LISTENAI_TOOLS_PATH="$current_dir/$dir_name/$ARCS_DEV_TOOL_LISTENAI_TOOLS_DIR_NAME"
fi
if [ -d "$current_dir/$dir_name/$ARCS_DEV_TOOL_TOOLCHAIN_DIR_NAME" ]; then
echo "Found NUCLEI_TOOLCHAIN_PATH: $current_dir/$dir_name/$ARCS_DEV_TOOL_TOOLCHAIN_DIR_NAME"
export NUCLEI_TOOLCHAIN_PATH="$current_dir/$dir_name/$ARCS_DEV_TOOL_TOOLCHAIN_DIR_NAME"
fi
return 0
fi
current_dir=$(dirname "$current_dir")
done
}
while [[ $# -gt 0 ]]; do
case $1 in
-S|--Source)
PROJECT_PATH="$2"
shift 2
;;
-B|--build)
OUTPUT="$2"
shift 2
;;
-t|--target)
TARGET="$2"
shift 2
;;
-C|--Clean)
CLEAN=true
shift 1
;;
-w|--warnings-as-errors)
WARNINGS_AS_ERRORS=true
shift 1
;;
-h|--help)
usage
;;
-r|--release)
RELEASE=true
shift 1
;;
-D*)
CMAKE_VARS+=("$1")
shift 1
;;
*)
echo "未知参数: $1"
usage
;;
esac
done
echo "Source: $PROJECT_PATH"
echo "Target: $TARGET"
echo "Clean : $CLEAN"
if [ -z "$LISTENAI_TOOLS_PATH" ] || [ -z "$NUCLEI_TOOLCHAIN_PATH" ]; then
find_dev_tools
fi
if [ -z "${LISTENAI_TOOLS_PATH}" ]; then
export LISTENAI_TOOLS_PATH="请添加 LISTENAI_TOOLS_PATH 环境变量,或在此行设置正确的路径"
echo "请添加 LISTENAI_TOOLS_PATH 环境变量或者修改脚本后, 注释脚本第 $LINENO 行";exit 1;
fi
if [ -z "${NUCLEI_TOOLCHAIN_PATH}" ]; then
export NUCLEI_TOOLCHAIN_PATH="请添加 NUCLEI_TOOLCHAIN_PATH 环境变量,或在此行设置正确的路径"
echo "请添加 NUCLEI_TOOLCHAIN_PATH 环境变量或者修改脚本后, 注释脚本第 $LINENO 行";exit 1;
fi
############### 下面代码不用修改 ##################
# 构建工具的位置
CMAKE_PROGRAM="$LISTENAI_TOOLS_PATH/cmake/bin/cmake"
NINJA_PROGRAM="$LISTENAI_TOOLS_PATH/ninja/ninja"
# 配置环境变量 ARCS_BASE
if [ -z "$ARCS_BASE" ]; then
find_arcs_base
fi
if [ "$CLEAN" = true ]; then
rm -rf $OUTPUT
fi
# Initialize CMAKE_VARS array if it doesn't exist
declare -a CMAKE_VARS
# Add warnings-as-errors flag if enabled
if [ "$WARNINGS_AS_ERRORS" = true ]; then
CMAKE_VARS+=("-DCMAKE_C_FLAGS=-Werror")
CMAKE_VARS+=("-DCMAKE_CXX_FLAGS=-Werror")
echo "Treating warnings as errors"
fi
# Add release flags if enabled
if [ "$RELEASE" = true ]; then
CMAKE_VARS+=("-DENABLE_DEBUG_PATH=OFF")
echo "Release mode enabled (-DENABLE_DEBUG_PATH=OFF)"
fi
$CMAKE_PROGRAM -B "$OUTPUT" -G Ninja -S "$PROJECT_PATH" \
-DCMAKE_MAKE_PROGRAM="$NINJA_PROGRAM" \
"${CMAKE_VARS[@]}"
if [ -z "$TARGET" ]; then
$CMAKE_PROGRAM --build "$OUTPUT" -j4
else
$CMAKE_PROGRAM --build "$OUTPUT" --target "$TARGET"
fi

View File

@@ -0,0 +1,2 @@
# 项目可根据需要在此文件中设置对应的配置
CONFIG_SDK_MODULE_IJG=y

View File

@@ -0,0 +1,7 @@
tests:
samples.jpeg:
programmer: arcs
runner: uart
log_analyzer:
type: "regex"
pattern: "Conversion completed successfully"

View File

@@ -0,0 +1,264 @@
/*
* JPEG to RGB565 conversion sample from memory buffer
* Uses IJG library to decompress JPEG and convert to RGB565 format
*/
#include "lisa_log.h"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <setjmp.h>
/* Include IJG JPEG library header */
#include "jpeglib.h"
#include "jerror.h"
/* Error handling structure */
struct my_error_mgr {
struct jpeg_error_mgr pub; /* "public" fields */
jmp_buf setjmp_buffer; /* for return to caller */
};
typedef struct my_error_mgr *my_error_ptr;
/* Custom error handler for JPEG decompression */
METHODDEF(void)
my_error_exit(j_common_ptr cinfo)
{
/* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
my_error_ptr myerr = (my_error_ptr) cinfo->err;
/* Always display the message. */
(*cinfo->err->output_message) (cinfo);
/* Return control to the setjmp point */
longjmp(myerr->setjmp_buffer, 1);
}
/* Memory source manager for JPEG decompression from memory */
typedef struct {
struct jpeg_source_mgr pub; /* public fields */
const unsigned char *data; /* source data */
size_t data_size; /* size of data */
boolean start_of_data; /* have we gotten any data yet? */
} mem_source_mgr;
typedef mem_source_mgr *mem_src_ptr;
/* Memory source manager initialization */
METHODDEF(void)
init_mem_source(j_decompress_ptr cinfo)
{
mem_src_ptr src = (mem_src_ptr)cinfo->src;
src->start_of_data = TRUE;
}
/* Fill input buffer from memory */
METHODDEF(boolean)
fill_mem_input_buffer(j_decompress_ptr cinfo)
{
mem_src_ptr src = (mem_src_ptr)cinfo->src;
if (src->data_size == 0) {
/* Insert a fake EOI marker */
static const JOCTET EOI_BUFFER[2] = {0xFF, JPEG_EOI};
src->pub.next_input_byte = EOI_BUFFER;
src->pub.bytes_in_buffer = 2;
return FALSE;
}
src->pub.next_input_byte = src->data;
src->pub.bytes_in_buffer = src->data_size;
src->start_of_data = FALSE;
src->data_size = 0; /* We've consumed it all */
return TRUE;
}
/* Skip data in memory buffer */
METHODDEF(void)
skip_input_data(j_decompress_ptr cinfo, long num_bytes)
{
mem_src_ptr src = (mem_src_ptr)cinfo->src;
if (num_bytes > 0) {
while (num_bytes > (long)src->pub.bytes_in_buffer) {
num_bytes -= (long)src->pub.bytes_in_buffer;
(void)fill_mem_input_buffer(cinfo);
}
src->pub.next_input_byte += (size_t)num_bytes;
src->pub.bytes_in_buffer -= (size_t)num_bytes;
}
}
/* Term source - nothing to do */
METHODDEF(void)
term_source(j_decompress_ptr cinfo)
{
/* Nothing to do */
}
/* We're using the jpeg_mem_src function from the IJG library (jdatasrc.c) */
/* Convert RGB888 (24-bit) to RGB565 (16-bit) */
static uint16_t rgb888_to_rgb565(uint8_t r, uint8_t g, uint8_t b)
{
/* RGB565: 5 bits for red, 6 bits for green, 5 bits for blue */
uint16_t rgb565 = ((r & 0xF8) << 8) | /* 5 bits for red */
((g & 0xFC) << 3) | /* 6 bits for green */
((b & 0xF8) >> 3); /* 5 bits for blue */
return rgb565;
}
/* JPEG to RGB565 conversion function from memory buffer */
int jpeg_memory_to_rgb565(const unsigned char *jpeg_data, size_t jpeg_size,
uint16_t **rgb565_output, int *width, int *height)
{
/* JPEG decompression variables */
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
JSAMPARRAY buffer; /* Output row buffer */
int row_stride; /* Physical row width in output buffer */
uint16_t *rgb565_buffer = NULL; /* Buffer for all RGB565 pixels */
uint16_t *current_line = NULL; /* Pointer to current line in output buffer */
/* Set up the error handler */
cinfo.err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = my_error_exit;
/* Establish the setjmp return context for my_error_exit to use */
if (setjmp(jerr.setjmp_buffer)) {
/* If we get here, the JPEG code has signaled an error */
jpeg_destroy_decompress(&cinfo);
if (rgb565_buffer != NULL) {
free(rgb565_buffer);
}
return -1;
}
/* Initialize the JPEG decompression object */
jpeg_create_decompress(&cinfo);
/* Specify data source from memory */
jpeg_mem_src(&cinfo, jpeg_data, jpeg_size);
/* Read file header to get image information */
(void) jpeg_read_header(&cinfo, TRUE);
/* Set parameters for decompression */
/* Output colorspace - we want RGB */
cinfo.out_color_space = JCS_RGB;
/* Start decompressor */
(void) jpeg_start_decompress(&cinfo);
/* Get image dimensions */
*width = cinfo.output_width;
*height = cinfo.output_height;
/* Calculate row stride (bytes per row) */
row_stride = cinfo.output_width * cinfo.output_components;
/* Make a sample array to hold a row of JPEG pixels */
buffer = (*cinfo.mem->alloc_sarray)
((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
/* Allocate memory for the full RGB565 image */
rgb565_buffer = (uint16_t *)malloc(cinfo.output_width * cinfo.output_height * sizeof(uint16_t));
if (!rgb565_buffer) {
LOGI("Memory allocation failed\n");
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
return -1;
}
/* Point to the start of the buffer */
current_line = rgb565_buffer;
/* Process each scanline */
while (cinfo.output_scanline < cinfo.output_height) {
/* Read a line of pixels */
(void) jpeg_read_scanlines(&cinfo, buffer, 1);
/* Convert RGB to RGB565 */
for (int i = 0; i < cinfo.output_width; i++) {
uint8_t r = buffer[0][i * 3]; /* Red */
uint8_t g = buffer[0][i * 3 + 1]; /* Green */
uint8_t b = buffer[0][i * 3 + 2]; /* Blue */
/* Convert RGB888 to RGB565 */
current_line[i] = rgb888_to_rgb565(r, g, b);
}
/* Move to the next line in the output buffer */
current_line += cinfo.output_width;
}
/* Finish decompression */
(void) jpeg_finish_decompress(&cinfo);
/* Release the JPEG decompression object */
jpeg_destroy_decompress(&cinfo);
/* Set the output buffer pointer */
*rgb565_output = rgb565_buffer;
return 0;
}
/* This is a minimal valid 1x1 pixel JPEG image in binary form */
static const unsigned char sample_jpeg[] = {
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01,
0x01, 0x01, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43,
0x00, 0x08, 0x06, 0x06, 0x07, 0x06, 0x05, 0x08, 0x07, 0x07, 0x07, 0x09,
0x09, 0x08, 0x0a, 0x0c, 0x14, 0x0d, 0x0c, 0x0b, 0x0b, 0x0c, 0x19, 0x12,
0x13, 0x0f, 0x14, 0x1d, 0x1a, 0x1f, 0x1e, 0x1d, 0x1a, 0x1c, 0x1c, 0x20,
0x24, 0x2e, 0x27, 0x20, 0x22, 0x2c, 0x23, 0x1c, 0x1c, 0x28, 0x37, 0x29,
0x2c, 0x30, 0x31, 0x34, 0x34, 0x34, 0x1f, 0x27, 0x39, 0x3d, 0x38, 0x32,
0x3c, 0x2e, 0x33, 0x34, 0x32, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x09, 0x09,
0x09, 0x0c, 0x0b, 0x0c, 0x18, 0x0d, 0x0d, 0x18, 0x32, 0x21, 0x1c, 0x21,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
0x32, 0x32, 0xff, 0xc0, 0x00, 0x11, 0x08, 0x00, 0x01, 0x00, 0x01, 0x03,
0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x00,
0x15, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xff, 0xc4, 0x00, 0x14,
0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc4, 0x00, 0x14, 0x01, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xc4, 0x00, 0x14, 0x11, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03,
0x11, 0x00, 0x3f, 0x00, 0xb2, 0xc0, 0x07, 0xff, 0xd9
};
int main(int argc, char **argv)
{
LOGI("JPEG (from memory) to RGB565 converter sample\n");
uint16_t *rgb565_data = NULL;
int width, height;
/* Convert JPEG to RGB565 */
int result = jpeg_memory_to_rgb565(sample_jpeg, sizeof(sample_jpeg),
&rgb565_data, &width, &height);
if (result == 0) {
LOGI("Conversion completed successfully\n");
LOGI("Image dimensions: %d x %d\n", width, height);
/* You can now use the RGB565 data */
/* For example, display it on an LCD screen */
/* Don't forget to free the memory when done */
free(rgb565_data);
} else {
LOGI("Conversion failed\n");
}
return 0;
}