diff --git a/vendor/.gitkeep b/vendor/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/vendor/opensource/xvp_osd/include/easy_log.h b/vendor/opensource/xvp_osd/include/easy_log.h new file mode 100755 index 0000000000000000000000000000000000000000..415901bd75b1ffa3fa069b40dc3d12838c42f3ca --- /dev/null +++ b/vendor/opensource/xvp_osd/include/easy_log.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2025 UncleRoderick@hotmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef EASY_LOG_H +#define EASY_LOG_H + +#include +#include +#include + +#ifdef __cplusplus +#if __cplusplus +extern "C"{ +#endif +#endif /* End of #ifdef __cplusplus */ + +#define HL_RED //"\033[1;31m" // 亮红 +#define HL_GREEN //"\033[1;32m" // 亮绿 +#define HL_YEL //"\033[1;33m" // 亮黄 +#define BROWN //"\033[0;33m" // 灰 +#define WHITE //"\033[1;37m" // 白 +#define NORMAL //"\033[0m" // 恢复正常 + +enum LOG_LEVEL { + LOG_LEVEL_OFF = 0, + LOG_LEVEL_ERR, + LOG_LEVEL_WARN, + LOG_LEVEL_INFO, + LOG_LEVEL_DBG, + LOG_LEVEL_ALL, +}; + +static const int log_level = LOG_LEVEL_ALL; + +#define LOGE(fmt, ...) \ +do { \ + time_t timeSec; \ + struct tm timeTm; \ + timeSec = time(NULL); \ + localtime_r(&timeSec, &timeTm); \ + struct timeval tv = {0}; \ + gettimeofday(&tv, NULL); \ + if (log_level >= LOG_LEVEL_ERR) \ + printf(HL_RED "%04d/%02d/%02d %02d:%02d:%02d.%04ld[%s line:%d]:" fmt "\n", \ + 1900 + timeTm.tm_year, 1 + timeTm.tm_mon, timeTm.tm_mday, timeTm.tm_hour, timeTm.tm_min, \ + timeTm.tm_sec, (long int)tv.tv_usec/1000, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ +} \ +while (0) + +#define LOGW(fmt, ...) \ +do { \ + time_t timeSec; \ + struct tm timeTm; \ + timeSec = time(NULL); \ + localtime_r(&timeSec, &timeTm); \ + struct timeval tv = {0}; \ + gettimeofday(&tv, NULL); \ + if (log_level >= LOG_LEVEL_ERR) \ + printf(HL_YEL "%04d/%02d/%02d %02d:%02d:%02d.%04ld[%s line:%d]:" fmt "\n", \ + 1900 + timeTm.tm_year, 1 + timeTm.tm_mon, timeTm.tm_mday, timeTm.tm_hour, timeTm.tm_min, \ + timeTm.tm_sec, (long int)(tv.tv_usec/1000), __FUNCTION__, __LINE__, ##__VA_ARGS__); \ +} \ +while (0) + +#define LOGI(fmt, ...) \ +do { \ + time_t timeSec; \ + struct tm timeTm; \ + timeSec = time(NULL); \ + localtime_r(&timeSec, &timeTm); \ + struct timeval tv = {0}; \ + gettimeofday(&tv, NULL); \ + if (log_level >= LOG_LEVEL_ERR) \ + printf(WHITE "%04d/%02d/%02d %02d:%02d:%02d.%04ld[%s line:%d]:" fmt "\n", \ + 1900 + timeTm.tm_year, 1 + timeTm.tm_mon, timeTm.tm_mday, timeTm.tm_hour, timeTm.tm_min, \ + timeTm.tm_sec, (long int)(tv.tv_usec/1000), __FUNCTION__, __LINE__, ##__VA_ARGS__); \ +} \ +while (0) + +#define LOGD(fmt, ...) \ +do { \ + time_t timeSec; \ + struct tm timeTm; \ + timeSec = time(NULL); \ + localtime_r(&timeSec, &timeTm); \ + struct timeval tv = {0}; \ + gettimeofday(&tv, NULL); \ + if (log_level >= LOG_LEVEL_ERR) \ + printf(HL_GREEN "%04d/%02d/%02d %02d:%02d:%02d.%04ld[%s line:%d]:" fmt "\n", \ + 1900 + timeTm.tm_year, 1 + timeTm.tm_mon, timeTm.tm_mday, timeTm.tm_hour, timeTm.tm_min, \ + timeTm.tm_sec, (long int)(tv.tv_usec/1000), __FUNCTION__, __LINE__, ##__VA_ARGS__); \ +} \ +while (0) + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif /* End of #ifdef __cplusplus */ + +#endif /* End of #ifndef */ diff --git a/vendor/opensource/xvp_osd/include/xvp_common_osd.h b/vendor/opensource/xvp_osd/include/xvp_common_osd.h new file mode 100755 index 0000000000000000000000000000000000000000..c748412943598d63aa2c452b35cc29d23271f156 --- /dev/null +++ b/vendor/opensource/xvp_osd/include/xvp_common_osd.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2025 UncleRoderick@hotmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef XVP_COMMON_OSD_H +#define XVP_COMMON_OSD_H + +#include "ot_common_region.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef struct { + int factor; + unsigned int font_color; + unsigned int border_color; + int stride; + int width; + int height; +} xvp_osd_info; + +typedef struct { + ot_rgn_chn_attr chn_attr; + xvp_osd_info osd_info; + td_s32 handle; + ot_mpp_chn chn; +} sample_mpp_osd_info; + +const char *xvp_common_osd_get_version(void); +int xvp_common_osd_init(char *hzk_file); +void xvp_common_osd_exit(void); +void xvp_common_osd_draw_text(unsigned char *bitmap_data, unsigned char *text_string, + int offset_x, int offset_y, xvp_osd_info *osd_info); +int xvp_common_osd_draw_poit(unsigned char *bitmap_data, int start_x, int start_y, xvp_osd_info *osd_info); +int xvp_common_osd_draw_line(unsigned char *bitmap_data, int start_x, int start_y, int end_x, int end_y, + unsigned char border_width, xvp_osd_info *osd_info); +int xvp_common_osd_draw_rect(unsigned char *bitmap_data, int start_x, int start_y, int end_x, int end_y, + unsigned char border_width, xvp_osd_info *osd_info); +int xvp_common_osd_parse_string(char *str, int *max_len, int *line_cnt); +int xvp_common_osd_calculate_canvas_size(char *str, int factor, int *width, int *height); +int xvp_common_osd_string_filter(char *src, char *dst, int dst_len, int max_line_num, int max_line_len); +int xvp_common_osd_utf8_to_gb2312(const unsigned char *in_buf, int in_len, unsigned char *out_buf); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/vendor/opensource/xvp_osd/lib/libxvp_osd.a b/vendor/opensource/xvp_osd/lib/libxvp_osd.a new file mode 100755 index 0000000000000000000000000000000000000000..aa2ca940a8574f89dc400312b059c8708ccd6ac1 Binary files /dev/null and b/vendor/opensource/xvp_osd/lib/libxvp_osd.a differ diff --git a/vendor/zsks/README.md b/vendor/zsks/README.md new file mode 100755 index 0000000000000000000000000000000000000000..11ba4322c56bde47bb583887c0225d311447b894 --- /dev/null +++ b/vendor/zsks/README.md @@ -0,0 +1,121 @@ +## 1.项目介绍 + +* 本目录是由中山旷视微电子科技有限责任公司与海思深度合作的生态开源项目,旨在为广大开发者提供便利、高效、好用的第三方软件及工具。助力海思生态更上一个台阶。 +* demo目录是我们基于SS928平台开发的实用案例,包括:基于OpenCV的人脸检测案例、基于HNR的夜间超微光案例、基于YoloV8的水果识别及语音播报案例、基于KCF的目标跟踪案例、基于YoloV8的强逆光下的人脸检测案例,同时我们还基于IVE实现了OpenCV的硬件加速,帮助熟悉OpenCV的开发者,以最小的学习成本,就能够很好的使用海思SS928平台的硬件加速模块。 +* 我们基于SS928平台移植的常见第三方软件,包括:python、numpy、OpenCV、libv4l2、alsa-lib、ffmpeg、libacamera第三方软件,doc目录就是我们提供的相关移植文档和开发文档,旨在帮助开发者快速移植场见的第三方软件。同时我们还对海思SS928的MPP模块进行了python化的封装,让开发者只需要使用几行python代码,就能够很好的完成一个海思案例的开发。 +* patch目录,是我们基于SS928的SDK包,提供的一些补丁代码,方便开发者更好的使用我们的参考案例。 + +## 2.参考案例简介 + +### [2.1.opencv_dnn](./demo/opencv_dnn/README.md) + +* 本案例主要是基于OpenCV,将USB camera采集到的图片送到人脸检测模型进行推理,将得到的结果通过HDMI,显示在外接显示屏上面。 + +### [2.2.hnr_auto](./demo/hnr_auto/README.md) + +* 本案例主要是基于海思的hnr案例,实现夜间超微光的功能,当外接ISO到达一定阈值是,自动切换到hnr模型,使得在黑暗条件下也能清楚看到画面。 + +### [2.3.fruit_identify](./demo/fruit_identify/README.md) + +* 本案例是基于YoloV8实现的一个水果分类的案例,通过USB Camera,将采集到的图片送到水果检测模型中进行推理,当检测到特定水果时,会通过外接显示屏实时显示水果的种类以及执行度,并框住水果的具体位置,并通过耳机播放出此时识别到的水果类别。 + +### [2.4.sample_kcf_track](./demo/sample_kcf_track/README.md) + +* 基于KCF+Track模型,通过USB Camera,将采集到的图片送到KFC+trak模型,实现对目标的实时跟踪效果。 + +### [2.5.face_detection](./demo/face_detection/README.md) + +* 本案例主要使用pytorch框架,基于YoloV8,使用大量的特殊场景下的人脸数据,训练出来的强逆光下的人脸检测模型,通过USB Camera,将采集到的图片送到人脸检测模型中进行推理,当检测到人脸时,会在人脸区域画出矩形,并实时的通过外接HDMI线显示在外接显示屏上。 + +## 3.第三方软件 + +### [3.1.python](./docs/python/README.md) + +* 文档主要包括python源码包下载、依赖软件安装、交叉编译及安装、板端测试等内容。 + +### [3.2.numpy](./docs/numpy/README.md) + +* 文档主要包括numpy源码包下载、交叉编译及安装、板端测试等内容。 +* 注意:在板端使用numpy之前,必须按照3.1中的内容,把python移植好。 + +### [3.3.opencv](./docs/opencv/README.md) + +* 文档主要包括python源码包下载、交叉编译及安装、板端测试(包括python代码和CPP的测试)等内容。 +* 注意:如果想使用python代码调用OpenCV接口,必须按照3.1中的内容,把python移植好。 + +### [3.4.libv4l2](./docs/libv4l2/README.md) + +* 文档主要包括libv4l2源码包下载、依赖软件安装、交叉编译及安装、板端测试等内容。 + +### [3.5.alsa-lib](./docs/alsa-lib/README.md) + +* 文档主要包括alsa-lib源码包下载、依赖软件安装、交叉编译及安装、板端测试等内容。 + +### [3.6.ffmpeg](./docs/ffmpeg/README.md) + +* 文档主要包括ffmpeg源码包下载、依赖软件安装、交叉编译及安装、板端测试,以及ffmpeg硬件加速(调用SS928的硬件编解码模块)等内容。 + +### [3.7.libcamera](./docs/libcamera/README.md) + +* 文档主要包括libcamera源码包下载、依赖软件安装、交叉编译及安装、板端测试等内容。 + + + +## 4.patch介绍 + +### 4.1 USB camera补丁 + +* 主要是基于海思的MPP sample添加v4l2等适配代码,确保USB camera能够正常使用。 +* 如果在a55_linux/mpp/sample/common/sample_comm.h中没有相关代码,说明你还没有合并我们的patch。 + +image-20250918185148122 + +* 打补丁的具体步骤如下,到pegasus/platform的ss928v100_xxx目录下,执行下面的命令。 + +```sh +# 注意:这里的xxx请根据实际情况进行修改 +# 如果你是OpenHarmony,就是SS928V100_clang +# 如果是Ubuntu或者OpenEuler就是SS928V100_gcc + +cd pegasus/platform/ss928v100_xxx + +patch -p1 < ../../vendor/zsks/patch/0001-support-USB-Camera-and-zsks-demo.patch +``` + +![image-20251030111331648](pic/image-20251030111331648.png) + +### 4.2 os04a10 sensor 补丁 + +* 0002-support-os04a10-and-hnr.patch:是sensor os04a10的驱动代码。 + +* 步骤1:在编译之前先确保pegasus/platform/ss928v100_xxx/smp/a55_linux/mpp/sample目录下是否有 omnivision_os04a10这个文件夹,如果没有则需要进行下面的步骤。 + + ![image-20251030114812656](pic/image-20251030114812656.png) + + * 进入到pegasus/platform/ss928v100_xxx目录下,把omnivision_os04a10的补丁打入 + + ```sh + # 注意:如果你的操作系统是Ubuntu或者OpenEuler,就是ss928v100_gcc + cd pegasus/platform/ss928v100_clang + + patch -p1 < ../../vendor/zsks/patch/0002-support-os04a10-and-hnr.patch + ``` + + ![image-20251030115229578](pic/image-20251030115229578.png) + + * 然后进入到sample目录下,对omnivision_os04a10进行编译,编译成功后会在pegasus/platform/ss928v100_clang/smp/a55_linux/mpp/out/lib生成 libsns_os04a10.a和libsns_os04a10.so库文件。 + + ```sh + cd smp/a55_linux/mpp/sample/omnivision_os04a10/ + + # 注意:这里绝对路径请根据自己服务器的实际情况进行修改 + export PATH=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin:$PATH + export SYSROOT_PATH=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot + + make clean && make + ``` + + ![image-20251030142816023](pic/image-20251030142816023.png) + + + diff --git a/vendor/zsks/demo/face_detection/Makefile b/vendor/zsks/demo/face_detection/Makefile new file mode 100755 index 0000000000000000000000000000000000000000..f55474e3474cc3b5d764a4cc9086b55cd9aa03a2 --- /dev/null +++ b/vendor/zsks/demo/face_detection/Makefile @@ -0,0 +1,45 @@ +# 编译所需的公共文件 +include ../mk.param + +# 编译后生成的可执行文件名 +TARGET := main + +# 编译此工程需要包含的头文件 +CFLAGS += -I$(SDK_LINUX_INCLUDE_DIR)/ +CFLAGS += -I$(SDK_SAMPLE_COMMON_DIR)/ +CFLAGS += -I$(SDK_LINUX_INCLUDE_DIR)/svp_npu + +# 编译此工程需要依赖的.c或.cpp文件 +SMP_SRCS := $(SDK_SAMPLE_COMMON_DIR)/sample_comm_sys.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_ipc.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_isp.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vi.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vo.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_mipi_tx.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vpss.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/loadbmp.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vdec.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_venc.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sdk_init.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sdk_exit.c +SMP_SRCS += $(wildcard $(SVP_COMMON_DIR)/*.c) +SMP_SRCS += $(FACE_DETECTION_SAMPLE_DIR)/face_detection.c + +# 编译此工程需要包含的库和宏 +CFLAGS += -O3 -g -Wall -DUSE_USB_CAMERA +CFLAGS += -fstack-protector-strong +MPI_LIBS += $(SDK_LINUX_OUT_LIB)/libsns_os04a10.a + +# 根据实际的类型设置,可以用set_sensor脚本设置 +SENSOR0_TYPE = -DSENSOR0_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT +SENSOR1_TYPE = -DSENSOR1_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT +SENSOR2_TYPE = -DSENSOR1_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT +SENSOR3_TYPE = -DSENSOR1_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT + +CFLAGS += $(SENSOR0_TYPE) +CFLAGS += $(SENSOR1_TYPE) +CFLAGS += $(SENSOR2_TYPE) +CFLAGS += $(SENSOR3_TYPE) +# 编译工程所需的mk文件 + +include ../sdk_linux.mk diff --git a/vendor/zsks/demo/face_detection/README.md b/vendor/zsks/demo/face_detection/README.md new file mode 100755 index 0000000000000000000000000000000000000000..ddfc027333b65f3eacb919f0750cb290de596604 --- /dev/null +++ b/vendor/zsks/demo/face_detection/README.md @@ -0,0 +1,129 @@ +## 2.5、face_detection 操作指导 + +### 2.5.1、face_detection 程序简介 + +* face_detection sample基于SS928V100平台开发,以EulerPi套件为例,face_detection sample是通过USB Camera,将采集到的图片送到人脸检测模型中进行推理,当检测到人脸时,会在人脸区域画出矩形框,并通过外接HDMI线实时的显示在外接显示屏上。 +* face_detection 案例主要是使用pytorch框架,基于YoloV8网络,使用widerface、FDDB、UFDD等开源数据集,共1.3万多张训练出来在强光、逆光、暗光下的人脸检测模型。 + +### 2.5.2、目录 + +```shell +pegasus/vendor/zsks/demo/face_detection +|── data # 模型文件 +|── Makefile # 编译脚本 +└── face_detection.c # face_detection sample业务代码 +``` + +![image-20250919144926220](pic/image-20250919144926220.png) + +* 根据外接显示屏的输出参数进行配置,比如说我的外接显示屏的输出是1080P60,如果smp/a55_linux/mpp/sample/svp/common/sample_common_svp.c ample_common_svp_get_def_vo_cfg函数的intf_sync为OT_VO_OUT_1080P30,则需要把他修改为OT_VO_OUT_1080P60。 + +![image-20251023102053075](pic/image-20251023102053075.png) + +### 2.5.3、编译 + +* **注意:在编译zsks的demo之前,请确保你已经按照[patch介绍中的步骤](../../README.md#4patch介绍)把补丁打入海思SDK的sample目录下了**。 + +* 步骤1:先根据自己选择的操作系统,进入到对应的Pegasus所在目录下。 + +* 步骤2:使用Makefile的方式进行单编 + +* 在Ubuntu的命令行终端,分步执行下面的命令,单编 face_detection sample + + ``` + cd pegasus/vendor/zsks/demo/face_detection + + make clean && make + ``` + + * 在face_detection/out目录下,生成一个名为 main 的 可执行文件,如下图所示: + + ![image-20251023095337519](pic/image-20251023095337519.png) + +### 2.5.4、拷贝可执行程序和依赖文件至开发板的mnt目录下 + +**方式一:使用SD卡进行资料文件的拷贝** + +* 首先需要自己准备一张Micro sd卡(16G 左右即可),还得有一个Micro sd卡的读卡器。 + +image-20221114150205685 + +* 步骤1:将编译后生成的可执行文件main和资源文件data,拷贝到SD卡中。 + +![image-20251023100347550](pic/image-20251023100347550.png) + +* 步骤2:可执行文件拷贝成功后,将内存卡插入开发板的SD卡槽中,可通过挂载的方式挂载到板端,可选择SD卡 mount指令进行挂载。 + +image-20250210161601541 + +* 在开发板的终端,执行下面的命令进行SD卡的挂载 + * 如果挂载失败,可以参考[这个issue尝试解决](https://gitee.com/HiSpark/HiSpark_NICU2022/issues/I54932?from=project-issue) + + +```shell +mount -t vfat /dev/mmcblk1p1 /mnt +# 其中/dev/mmcblk1p1需要根据实际块设备号修改 +``` + +* 挂载成功后,如下图所示: + +![image-20251023102549783](pic/image-20251023102549783.png) + +**方式二:使用NFS挂载的方式进行资料文件的拷贝** + +* 首先需要自己准备一根网线 +* 步骤1:参考[博客链接](https://blog.csdn.net/Wu_GuiMing/article/details/115872995?spm=1001.2014.3001.5501)中的内容,进行nfs的环境搭建 +* 步骤2:将编译后生成的可执行文件main和资源文件data,拷贝到Windows的nfs共享路径下 + +![image-20251023100136196](pic/image-20251023100136196.png) + +* 步骤3:在开发板的终端执行下面的命令,将Windows的nfs共享路径挂载至开发板的mnt目录下 + * 注意:这里IP地址请根据你开发板和电脑主机的实际IP地址进行填写 + + +``` +ifconfig eth0 192.168.100.100 + +mount -o nolock,addr=192.168.100.10 -t nfs 192.168.100.10:/d/nfs /mnt +``` + +![image-20251023101210815](pic/image-20251023101210815.png) + +### 2.5.5、硬件连接 + +* 准备一个外接显示器和HDMI数据线,将HDMI的一头接在开发板的HDMI输出口,将HDMI的另外一头接在外接显示器的HDMI输入口。 + +![image-20250213112932380](pic/image-20250213112932380.png) + +* 将USB 摄像头接在EulerPi开发板的USB接口上。 + +image-20250919150630870 + +### 2.5.6、功能验证 + +* 在开发板的终端执行下面的命令,运行可执行文件 + +``` +cd /mnt + +chmod +x main + +./main +``` + +![image-20251023101503216](pic/image-20251023101503216.png) + +* 此时,在HDMI的外接显示屏上即可出现实时码流,如下图所示: + +image-20250210170027454 + +* 如果您看到的现象和下图现象不一致,可以确认一下USB涉嫌头是否插入到开发板的USB口,并且在开发板的/dev目录下能够看到video0 和 video1两个设备节点。如果没有这两个设备节点,请确保镜像烧录正常。 + +![image-20250919151018659](pic/image-20250919151018659.png) + +* 正常情况下,我们会在外接显示屏上看到人脸的区域被框出来,且在比较黑暗或者强逆光条件下,也能比较好的检测到人脸。![image-20250919151605632](pic/image-20250919151605632.png) + +* 敲两下回车即可关闭程序 + +![image-20250919151519310](pic/image-20250919151519310.png) + diff --git a/vendor/zsks/demo/face_detection/data/model/face_detection.om b/vendor/zsks/demo/face_detection/data/model/face_detection.om new file mode 100755 index 0000000000000000000000000000000000000000..4765828d501e8d424ae023e6cedff0bb4cf24a5e Binary files /dev/null and b/vendor/zsks/demo/face_detection/data/model/face_detection.om differ diff --git a/vendor/zsks/demo/face_detection/face_detection.c b/vendor/zsks/demo/face_detection/face_detection.c new file mode 100755 index 0000000000000000000000000000000000000000..8ea929af313ab8866645da498e69585b0397322a --- /dev/null +++ b/vendor/zsks/demo/face_detection/face_detection.c @@ -0,0 +1,515 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * Copyright (c) 2025 Zhongshan Kuangshi Microelectronics Technology Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Modifications Author: yaohongtao (yht@cust.edu.cn) +*/ +#include +#include +#include +#include +#include +#include +#include +#include "securec.h" +#include "svp_acl.h" +#include "svp_acl_rt.h" +#include "svp_acl_ext.h" +#include "sdk_module_init.h" +#include "sample_common_svp.h" +#include "sample_common_svp_npu.h" +#include "sample_common_svp_npu_model.h" + +/* 新增v4l2相关头文件 */ +#include // 文件控制 +#include // 错误处理 +#include // POSIX API +#include // IO控制 +#include // 内存映射 +#include // select复用 +#include // v4l2核心 + +#define SAMPLE_SVP_NPU_RESNET50_INPUT_FILE_NUM 1 +#define SAMPLE_SVP_NPU_LSTM_INPUT_FILE_NUM 4 +#define SAMPLE_SVP_NPU_SHAERD_WORK_BUF_NUM 1 +#define SAMPLE_SVP_NPU_YOLO_TYPE_NUM 12 +#define SAMPLE_SVP_NPU_YOLO_THRESHOLD_NUM 1 + +#define SAMPLE_SVP_NPU_PATH_LEN 0x100 +static td_bool g_svp_npu_terminate_signal = TD_FALSE; +static td_s32 g_svp_npu_dev_id = 0; +static sample_svp_npu_task_info g_svp_npu_task[SAMPLE_SVP_NPU_MAX_TASK_NUM] = {0}; +static sample_svp_npu_shared_work_buf g_svp_npu_shared_work_buf[SAMPLE_SVP_NPU_SHAERD_WORK_BUF_NUM] = {0}; + +static sample_svp_npu_threshold g_svp_npu_yolo_threshold[SAMPLE_SVP_NPU_YOLO_TYPE_NUM] = { + {0.9, 0.15, 1.0, 1.0, "rpn_data"}, // yolov8 +}; + +static sample_svp_npu_roi_info g_svp_npu_yolo_roi_info[SAMPLE_SVP_NPU_YOLO_TYPE_NUM] = { + {"output0", "output0_"}, // yolov8 +}; + +static ot_sample_svp_rect_info g_svp_npu_rect_info = {0}; +static td_bool g_svp_npu_thread_stop = TD_FALSE; +static pthread_t g_svp_npu_thread = 0; +static sample_vo_cfg g_svp_npu_vo_cfg = { 0 }; +static pthread_t g_svp_npu_vdec_thread = 0; +static ot_vb_pool_info g_svp_npu_vb_pool_info; +static td_void *g_svp_npu_vb_virt_addr = TD_NULL; + +static ot_sample_svp_media_cfg g_svp_npu_media_cfg = { + .svp_switch = {TD_FALSE, TD_TRUE}, + .pic_type = {PIC_1080P, PIC_CIF}, + .chn_num = OT_SVP_MAX_VPSS_CHN_NUM, +}; + +static sample_vdec_attr g_svp_npu_vdec_cfg = { + .type = OT_PT_MJPEG, + .mode = OT_VDEC_SEND_MODE_FRAME, + .width = FHD_WIDTH, + .height = FHD_HEIGHT, + .sample_vdec_picture.pixel_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_420, /* 420:pixel_format */ + .sample_vdec_picture.alpha = 0, /* 0:alpha */ + .display_frame_num = 2, /* 2:display_frame_num */ + .frame_buf_cnt = 5, /* 5:2+2+1 */ +}; + +static vdec_thread_param g_svp_npu_vdec_param = { + .chn_id = 0, + + .v4l2_device = "/dev/video0", // 摄像头设备 + .width = FHD_WIDTH, // 采集分辨率宽 + .height = FHD_HEIGHT, // 采集分辨率高 + .pixel_format = V4L2_PIX_FMT_MJPEG, // MJPEG格式 + + .type = OT_PT_MJPEG, + .stream_mode = OT_VDEC_SEND_MODE_FRAME, + .interval_time = 1000, /* 1000:interval_time */ + .pts_init = 0, + .pts_increase = 0, + .e_thread_ctrl = THREAD_CTRL_START, + .circle_send = TD_TRUE, + .milli_sec = 0, + .min_buf_size = (FHD_WIDTH * FHD_HEIGHT * 3) >> 1, /* 3:chn_size */ + .fps = 30, +}; + +static td_void sample_svp_npu_acl_terminate(td_void) +{ + if (g_svp_npu_terminate_signal == TD_TRUE) { + printf("\033[0;31mprogram termination abnormally!\033[0;39m\n"); + } +} + +/* function : svp npu signal handle */ +td_void sample_svp_npu_acl_handle_sig(td_void) +{ + g_svp_npu_terminate_signal = TD_TRUE; +} + +static td_void sample_svp_npu_acl_deinit(td_void) +{ + svp_acl_error ret; + + ret = svp_acl_rt_reset_device(g_svp_npu_dev_id); + if (ret != SVP_ACL_SUCCESS) { + sample_svp_trace_err("reset device fail\n"); + } + sample_svp_trace_info("end to reset device is %d\n", g_svp_npu_dev_id); + + ret = svp_acl_finalize(); + if (ret != SVP_ACL_SUCCESS) { + sample_svp_trace_err("finalize acl fail\n"); + } + sample_svp_trace_info("end to finalize acl\n"); + (td_void)sample_common_svp_check_sys_exit(); +} + +static td_s32 sample_svp_npu_acl_init(const td_char *acl_config_path, td_bool vi_en) +{ + /* svp acl init */ + svp_acl_rt_run_mode run_mode; + svp_acl_error ret; + td_bool is_mpi_init; + + is_mpi_init = sample_common_svp_check_sys_init(vi_en); + sample_svp_check_exps_return(is_mpi_init != TD_TRUE, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "mpi init failed!\n"); + + ret = svp_acl_init(acl_config_path); + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "acl init failed!\n"); + + sample_svp_trace_info("svp acl init success!\n"); + + /* open device */ + ret = svp_acl_rt_set_device(g_svp_npu_dev_id); + if (ret != SVP_ACL_SUCCESS) { + (td_void)svp_acl_finalize(); + sample_svp_trace_err("svp acl open device %d failed!\n", g_svp_npu_dev_id); + return TD_FAILURE; + } + sample_svp_trace_info("open device %d success!\n", g_svp_npu_dev_id); + + /* get run mode */ + ret = svp_acl_rt_get_run_mode(&run_mode); + if ((ret != SVP_ACL_SUCCESS) || (run_mode != SVP_ACL_DEVICE)) { + (td_void)svp_acl_rt_reset_device(g_svp_npu_dev_id); + (td_void)svp_acl_finalize(); + sample_svp_trace_err("acl get run mode failed!\n"); + return TD_FAILURE; + } + sample_svp_trace_info("get run mode success!\n"); + + return TD_SUCCESS; +} + +static td_s32 sample_svp_npu_acl_dataset_init(td_u32 task_idx) +{ + td_s32 ret = sample_common_svp_npu_create_input(&g_svp_npu_task[task_idx]); + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "create input failed!\n"); + + ret = sample_common_svp_npu_create_output(&g_svp_npu_task[task_idx]); + if (ret != TD_SUCCESS) { + sample_common_svp_npu_destroy_input(&g_svp_npu_task[task_idx]); + sample_svp_trace_err("execute create output fail.\n"); + return TD_FAILURE; + } + return TD_SUCCESS; +} + +static td_void sample_svp_npu_acl_dataset_deinit(td_u32 task_idx) +{ + (td_void)sample_common_svp_npu_destroy_input(&g_svp_npu_task[task_idx]); + (td_void)sample_common_svp_npu_destroy_output(&g_svp_npu_task[task_idx]); +} + +static td_void sample_svp_npu_acl_deinit_task(td_u32 task_num, td_u32 shared_work_buf_idx) +{ + td_u32 task_idx; + + for (task_idx = 0; task_idx < task_num; task_idx++) { + (td_void)sample_common_svp_npu_destroy_work_buf(&g_svp_npu_task[task_idx]); + (td_void)sample_common_svp_npu_destroy_task_buf(&g_svp_npu_task[task_idx]); + (td_void)sample_svp_npu_acl_dataset_deinit(task_idx); + (td_void)memset_s(&g_svp_npu_task[task_idx], sizeof(sample_svp_npu_task_cfg), 0, + sizeof(sample_svp_npu_task_cfg)); + } + if (g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_ptr != TD_NULL) { + (td_void)svp_acl_rt_free(g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_ptr); + g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_ptr = TD_NULL; + g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_size = 0; + g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_stride = 0; + } +} + +static td_s32 sample_svp_npu_acl_create_shared_work_buf(td_u32 task_num, td_u32 shared_work_buf_idx) +{ + td_u32 task_idx; + td_u32 work_buf_size; + td_u32 work_buf_stride; + td_s32 ret; + + for (task_idx = 0; task_idx < task_num; task_idx++) { + ret = sample_common_svp_npu_get_work_buf_info(&g_svp_npu_task[task_idx], &work_buf_size, &work_buf_stride); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th task work buf info failed!\n", task_idx); + + if (g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_size < work_buf_size) { + g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_size = work_buf_size; + g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_stride = work_buf_stride; + } + } + ret = svp_acl_rt_malloc_cached(&g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_ptr, + g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_size, SVP_ACL_MEM_MALLOC_NORMAL_ONLY); + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "malloc %u-th shared work buf failed!\n", shared_work_buf_idx); + + (td_void)svp_acl_rt_mem_flush(g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_ptr, + g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_size); + return TD_SUCCESS; +} + +static td_s32 sample_svp_npu_acl_init_task(td_u32 task_num, td_bool is_share_work_buf, + td_u32 shared_work_buf_idx) +{ + td_u32 task_idx; + td_s32 ret; + + if (is_share_work_buf == TD_TRUE) { + ret = sample_svp_npu_acl_create_shared_work_buf(task_num, shared_work_buf_idx); + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "create shared work buf failed!\n"); + } + + for (task_idx = 0; task_idx < task_num; task_idx++) { + ret = sample_svp_npu_acl_dataset_init(task_idx); + if (ret != TD_SUCCESS) { + goto task_init_end_0; + } + ret = sample_common_svp_npu_create_task_buf(&g_svp_npu_task[task_idx]); + if (ret != TD_SUCCESS) { + sample_svp_trace_err("create task buf failed.\n"); + goto task_init_end_0; + } + if (is_share_work_buf == TD_FALSE) { + ret = sample_common_svp_npu_create_work_buf(&g_svp_npu_task[task_idx]); + } else { + /* if all tasks are on the same stream, work buf can be shared */ + ret = sample_common_svp_npu_share_work_buf(&g_svp_npu_shared_work_buf[shared_work_buf_idx], + &g_svp_npu_task[task_idx]); + } + if (ret != TD_SUCCESS) { + sample_svp_trace_err("create work buf failed.\n"); + goto task_init_end_0; + } + } + return TD_SUCCESS; + +task_init_end_0: + (td_void)sample_svp_npu_acl_deinit_task(task_num, shared_work_buf_idx); + return ret; +} + +static td_s32 sample_svp_npu_acl_frame_proc(const ot_video_frame_info *ext_frame, + const ot_video_frame_info *base_frame, td_void *args) +{ + td_s32 ret; + td_void *virt_addr = TD_NULL; + sample_svp_npu_detection_info *detection_info = TD_NULL; + sample_svp_npu_thread_args *thread_args = (sample_svp_npu_thread_args *)args; + td_u32 size = (td_u32)(ext_frame->video_frame.height * ext_frame->video_frame.stride[0] * + SAMPLE_SVP_NPU_IMG_THREE_CHN / SAMPLE_SVP_NPU_DOUBLE); + + virt_addr = g_svp_npu_vb_virt_addr + + (ext_frame->video_frame.phys_addr[0] - g_svp_npu_vb_pool_info.pool_phy_addr); + ret = sample_common_svp_npu_update_input_data_buffer_info(virt_addr, size, + ext_frame->video_frame.stride[0], 0, &g_svp_npu_task[0]); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "update data buffer failed!\n"); + + ret = sample_common_svp_npu_model_execute(&g_svp_npu_task[0]); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "model execute failed!\n"); + + if (thread_args->model_name == SAMPLE_SVP_NPU_RFCN || thread_args->model_name == SAMPLE_SVP_NPU_YOLO) { + detection_info = thread_args->detection_info; + if (detection_info->is_cpu_rpn == TD_FALSE) { + ret = sample_common_svp_npu_roi_to_rect(&g_svp_npu_task[0], detection_info, ext_frame, base_frame, + &g_svp_npu_rect_info); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "roi to rect failed!\n"); + } else { + ret = sample_common_svp_npu_roi_to_rect_cpu(&g_svp_npu_task[0], detection_info, ext_frame, base_frame, + &g_svp_npu_rect_info); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "roi to rect failed!\n"); + } + ret = sample_common_svp_vgs_fill_rect(base_frame, &g_svp_npu_rect_info, SAMPLE_SVP_NPU_RECT_COLOR); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "vgs fill rect failed!\n"); + for (int i = 0; i < g_svp_npu_rect_info.num; i++) { + printf("score:%lf, class_id:%d\r\n", g_svp_npu_rect_info.rect[i].score, + g_svp_npu_rect_info.rect[i].class_id); + } + } + return ret; +} + +static td_s32 sample_svp_npu_acl_vb_map(td_u32 vb_pool_idx) +{ + td_s32 ret; + + if (g_svp_npu_vb_virt_addr == TD_NULL) { + ret = ss_mpi_vb_get_pool_info(g_svp_npu_media_cfg.vb_pool[vb_pool_idx], &g_svp_npu_vb_pool_info); + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get pool info failed!\n"); + g_svp_npu_vb_virt_addr = ss_mpi_sys_mmap(g_svp_npu_vb_pool_info.pool_phy_addr, + g_svp_npu_vb_pool_info.pool_size); + sample_svp_check_exps_return(g_svp_npu_vb_virt_addr == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "map vb pool failed!\n"); + } + return TD_SUCCESS; +} + +static td_void *sample_svp_npu_acl_vdec_to_vo(td_void *args) +{ + td_s32 ret; + ot_video_frame_info base_frame; + ot_video_frame_info ext_frame; + const td_s32 milli_sec = SAMPLE_SVP_NPU_MILLIC_SEC; + const ot_vo_layer vo_layer = 0; + const ot_vo_chn vo_chn = 0; + const td_s32 vpss_grp = 0; + td_s32 vpss_chn[] = { OT_VPSS_CHN0, OT_VPSS_CHN1 }; + td_u32 size; + td_u32 stride; + td_u8 *data = TD_NULL; + + (td_void)prctl(PR_SET_NAME, "svp_npu_vdec_to_vo", 0, 0, 0); + + ret = svp_acl_rt_set_device(g_svp_npu_dev_id); + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, "open device failed!\n"); + + ret = sample_svp_npu_acl_vb_map(OT_VPSS_CHN1); + sample_svp_check_exps_goto(ret != TD_SUCCESS, fail_0, SAMPLE_SVP_ERR_LEVEL_ERROR, "map vb pool failed!\n"); + + ret = sample_common_svp_npu_get_input_data_buffer_info(&g_svp_npu_task[0], 0, &data, &size, &stride); + sample_svp_check_exps_goto(ret != TD_SUCCESS, fail_1, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),get_input_data_buffer_info failed!\n", ret); + + while (g_svp_npu_thread_stop == TD_FALSE) { + ret = ss_mpi_vpss_get_chn_frame(vpss_grp, vpss_chn[1], &ext_frame, milli_sec); + sample_svp_check_exps_continue(ret != TD_SUCCESS, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),ss_mpi_vpss_get_chn_frame failed, vpss_grp(%d), vpss_chn(%d)!\n", ret, vpss_grp, vpss_chn[1]); + + ret = ss_mpi_vpss_get_chn_frame(vpss_grp, vpss_chn[0], &base_frame, milli_sec); + sample_svp_check_exps_goto(ret != TD_SUCCESS, ext_release, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),ss_mpi_vpss_get_chn_frame failed, VPSS_GRP(%d), VPSS_CHN(%d)!\n", ret, vpss_grp, vpss_chn[0]); + + ret = sample_svp_npu_acl_frame_proc(&ext_frame, &base_frame, args); + sample_svp_check_exps_goto(ret != TD_SUCCESS, base_release, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_svp_npu_acl_frame_proc failed!\n", ret); + + ret = sample_common_svp_venc_vo_send_stream(&g_svp_npu_media_cfg.svp_switch, 0, vo_layer, vo_chn, &base_frame); + sample_svp_check_exps_goto(ret != TD_SUCCESS, base_release, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_svp_venc_vo_send_stream failed!\n", ret); +base_release: + ret = ss_mpi_vpss_release_chn_frame(vpss_grp, vpss_chn[0], &base_frame); + sample_svp_check_exps_trace(ret != TD_SUCCESS, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),release_frame failed,grp(%d) chn(%d)!\n", ret, vpss_grp, vpss_chn[0]); +ext_release: + ret = ss_mpi_vpss_release_chn_frame(vpss_grp, vpss_chn[1], &ext_frame); + sample_svp_check_exps_trace(ret != TD_SUCCESS, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),release_frame failed,grp(%d) chn(%d)!\n", ret, vpss_grp, vpss_chn[1]); + } + ret = sample_common_svp_npu_update_input_data_buffer_info(data, size, stride, 0, &g_svp_npu_task[0]); + sample_svp_check_exps_trace(ret != TD_SUCCESS, SAMPLE_SVP_ERR_LEVEL_ERROR, "update buffer failed!\n"); +fail_1: + (td_void)ss_mpi_sys_munmap(g_svp_npu_vb_virt_addr, g_svp_npu_vb_pool_info.pool_size); +fail_0: + (td_void)svp_acl_rt_reset_device(g_svp_npu_dev_id); + return TD_NULL; +} + +static td_void sample_svp_npu_acl_pause(td_void) +{ + printf("---------------press Enter key to exit!---------------\n"); + if (g_svp_npu_terminate_signal == TD_TRUE) { + return; + } + (td_void)getchar(); + if (g_svp_npu_terminate_signal == TD_TRUE) { + return; + } +} + +static td_void sample_svp_npu_acl_set_task_info(td_u32 model_idx) +{ + g_svp_npu_task[0].cfg.max_batch_num = 1; + g_svp_npu_task[0].cfg.dynamic_batch_num = 1; + g_svp_npu_task[0].cfg.total_t = 0; + g_svp_npu_task[0].cfg.is_cached = TD_TRUE; + g_svp_npu_task[0].cfg.model_idx = model_idx; +} + +static td_void sample_svp_npu_acl_set_detection_info(sample_svp_npu_detection_info *detection_info, td_u32 index, + td_bool is_cpu_rpn) +{ + detection_info->num_name = g_svp_npu_yolo_roi_info[index].roi_num_name; + detection_info->roi_name = g_svp_npu_yolo_roi_info[index].roi_class_name; + detection_info->has_background = TD_FALSE; + detection_info->is_cpu_rpn = is_cpu_rpn; + detection_info->idx = index; + /* use PIC_BUTT to be a flag, get the input resolution form om */ + g_svp_npu_media_cfg.pic_type[1] = PIC_BUTT; + g_svp_npu_terminate_signal = TD_FALSE; +} + +/* function : show the sample of yolo. RPN processed by npu */ +td_void sample_face_detection(void) +{ + td_s32 ret; + const td_u32 model_idx = 0; + const td_char *om_model_path = "./data/model/face_detection.om"; + sample_svp_npu_detection_info detection_info = {0}; + sample_svp_npu_thread_args args = {SAMPLE_SVP_NPU_YOLO, &detection_info}; + + sample_svp_npu_acl_set_detection_info(&detection_info, 0, TD_FALSE); + + if (g_svp_npu_terminate_signal == TD_FALSE) { + /* init acl */ + ret = sample_svp_npu_acl_init(TD_NULL, TD_FALSE); + sample_svp_check_exps_return_void(ret != TD_SUCCESS, SAMPLE_SVP_ERR_LEVEL_ERROR, "init failed!\n"); + + /* load model */ + ret = sample_common_svp_npu_load_model(om_model_path, model_idx, TD_FALSE); + sample_svp_check_exps_goto(ret != TD_SUCCESS, process_end0, SAMPLE_SVP_ERR_LEVEL_ERROR, + "load model failed!\n"); + + /* get input resolution */ + ret = sample_common_svp_npu_get_input_resolution(model_idx, 0, &g_svp_npu_media_cfg.pic_size[1]); + sample_svp_check_exps_goto(ret != TD_SUCCESS, process_end1, SAMPLE_SVP_ERR_LEVEL_ERROR, + "load model failed!\n"); + + /* start vdec vpss venc vo */ + ret = sample_common_svp_create_vb_start_vdec_vpss_vo(&g_svp_npu_vdec_cfg, &g_svp_npu_vdec_param, + &g_svp_npu_vdec_thread, &g_svp_npu_media_cfg, &g_svp_npu_vo_cfg); + sample_svp_check_exps_goto(ret != TD_SUCCESS, process_end1, SAMPLE_SVP_ERR_LEVEL_DEBUG, + "init media failed!\n"); + + /* set cfg */ + sample_svp_npu_acl_set_task_info(model_idx); + + ret = sample_svp_npu_acl_init_task(1, TD_FALSE, 0); + sample_svp_check_exps_goto(ret != TD_SUCCESS, process_end2, SAMPLE_SVP_ERR_LEVEL_ERROR, "init task failed!\n"); + } + /* process */ + if (g_svp_npu_terminate_signal == TD_FALSE) { + ret = sample_common_svp_npu_set_threshold(&g_svp_npu_yolo_threshold[0], SAMPLE_SVP_NPU_YOLO_THRESHOLD_NUM, + &g_svp_npu_task[0]); + sample_svp_check_exps_goto(ret != TD_SUCCESS, process_end3, SAMPLE_SVP_ERR_LEVEL_ERROR, + "set threshold failed!\n"); + + g_svp_npu_thread_stop = TD_FALSE; + ret = pthread_create(&g_svp_npu_thread, 0, sample_svp_npu_acl_vdec_to_vo, (td_void*)&args); + + sample_svp_check_exps_goto(ret != 0, process_end3, SAMPLE_SVP_ERR_LEVEL_ERROR, "create thread failed!\n"); + + (td_void)sample_svp_npu_acl_pause(); + + g_svp_npu_thread_stop = TD_TRUE; + pthread_join(g_svp_npu_thread, TD_NULL); + } + +process_end3: + (td_void)sample_svp_npu_acl_deinit_task(1, 0); +process_end2: + (td_void)sample_common_svp_destroy_vb_stop_vdec_vpss_vo(&g_svp_npu_vdec_param, &g_svp_npu_vdec_thread, + &g_svp_npu_media_cfg, &g_svp_npu_vo_cfg); +process_end1: + (td_void)sample_common_svp_npu_unload_model(model_idx); +process_end0: + (td_void)sample_svp_npu_acl_deinit(); + (td_void)sample_svp_npu_acl_terminate(); +} + +int main(void) +{ +#ifdef CONFIG_USER_SPACE + SDK_init(); +#endif + + sample_face_detection(); + +#ifdef CONFIG_USER_SPACE + SDK_exit(); +#endif + + return 0; +} diff --git a/vendor/zsks/demo/face_detection/pic/image-20221114150205685.png b/vendor/zsks/demo/face_detection/pic/image-20221114150205685.png new file mode 100755 index 0000000000000000000000000000000000000000..4dc4215c962c57ba0e31548fb98c29c789f149d9 Binary files /dev/null and b/vendor/zsks/demo/face_detection/pic/image-20221114150205685.png differ diff --git a/vendor/zsks/demo/face_detection/pic/image-20250210161601541.png b/vendor/zsks/demo/face_detection/pic/image-20250210161601541.png new file mode 100755 index 0000000000000000000000000000000000000000..80845ece8131933a4cd56ae3bd6119c38e0abd26 Binary files /dev/null and b/vendor/zsks/demo/face_detection/pic/image-20250210161601541.png differ diff --git a/vendor/zsks/demo/face_detection/pic/image-20250210170027454.png b/vendor/zsks/demo/face_detection/pic/image-20250210170027454.png new file mode 100755 index 0000000000000000000000000000000000000000..c06081fc2c963af4d1fa8af506804beedefe1b0b Binary files /dev/null and b/vendor/zsks/demo/face_detection/pic/image-20250210170027454.png differ diff --git a/vendor/zsks/demo/face_detection/pic/image-20250213112932380.png b/vendor/zsks/demo/face_detection/pic/image-20250213112932380.png new file mode 100755 index 0000000000000000000000000000000000000000..8b591b3437544859f4ec76b9ca03867cc401078c Binary files /dev/null and b/vendor/zsks/demo/face_detection/pic/image-20250213112932380.png differ diff --git a/vendor/zsks/demo/face_detection/pic/image-20250919144926220.png b/vendor/zsks/demo/face_detection/pic/image-20250919144926220.png new file mode 100755 index 0000000000000000000000000000000000000000..05539339d8f1667a5e5002fe17e94fdd1dc89de2 Binary files /dev/null and b/vendor/zsks/demo/face_detection/pic/image-20250919144926220.png differ diff --git a/vendor/zsks/demo/face_detection/pic/image-20250919150630870.png b/vendor/zsks/demo/face_detection/pic/image-20250919150630870.png new file mode 100755 index 0000000000000000000000000000000000000000..2d661646429af7ee314241ca3f86556060d7911e Binary files /dev/null and b/vendor/zsks/demo/face_detection/pic/image-20250919150630870.png differ diff --git a/vendor/zsks/demo/face_detection/pic/image-20250919151018659.png b/vendor/zsks/demo/face_detection/pic/image-20250919151018659.png new file mode 100755 index 0000000000000000000000000000000000000000..9b09507893b65d2142be49e6461daa31a81855c4 Binary files /dev/null and b/vendor/zsks/demo/face_detection/pic/image-20250919151018659.png differ diff --git a/vendor/zsks/demo/face_detection/pic/image-20250919151519310.png b/vendor/zsks/demo/face_detection/pic/image-20250919151519310.png new file mode 100755 index 0000000000000000000000000000000000000000..7f6d881a5d0e6d3f72b7a43d089b5c5a75d7f048 Binary files /dev/null and b/vendor/zsks/demo/face_detection/pic/image-20250919151519310.png differ diff --git a/vendor/zsks/demo/face_detection/pic/image-20250919151605632.png b/vendor/zsks/demo/face_detection/pic/image-20250919151605632.png new file mode 100755 index 0000000000000000000000000000000000000000..c6aa9aad5685495d6bad5ba5d4e0c09e31ed3c7a Binary files /dev/null and b/vendor/zsks/demo/face_detection/pic/image-20250919151605632.png differ diff --git a/vendor/zsks/demo/face_detection/pic/image-20251023095337519.png b/vendor/zsks/demo/face_detection/pic/image-20251023095337519.png new file mode 100755 index 0000000000000000000000000000000000000000..b0478a2959f250a93b12e43570a388d69b2f60d1 Binary files /dev/null and b/vendor/zsks/demo/face_detection/pic/image-20251023095337519.png differ diff --git a/vendor/zsks/demo/face_detection/pic/image-20251023100136196.png b/vendor/zsks/demo/face_detection/pic/image-20251023100136196.png new file mode 100755 index 0000000000000000000000000000000000000000..c1b6906ce6ab14d4703a09cf465fc3caf00ec3d0 Binary files /dev/null and b/vendor/zsks/demo/face_detection/pic/image-20251023100136196.png differ diff --git a/vendor/zsks/demo/face_detection/pic/image-20251023100347550.png b/vendor/zsks/demo/face_detection/pic/image-20251023100347550.png new file mode 100755 index 0000000000000000000000000000000000000000..5b02ccd845367df696cd076e73a53b45f811ae09 Binary files /dev/null and b/vendor/zsks/demo/face_detection/pic/image-20251023100347550.png differ diff --git a/vendor/zsks/demo/face_detection/pic/image-20251023101210815.png b/vendor/zsks/demo/face_detection/pic/image-20251023101210815.png new file mode 100755 index 0000000000000000000000000000000000000000..de9d64bdfa6a7b200ab4878ac8caebff709a349d Binary files /dev/null and b/vendor/zsks/demo/face_detection/pic/image-20251023101210815.png differ diff --git a/vendor/zsks/demo/face_detection/pic/image-20251023101503216.png b/vendor/zsks/demo/face_detection/pic/image-20251023101503216.png new file mode 100755 index 0000000000000000000000000000000000000000..684eb0e29b050e472c5e4ce1ea65861f2d6f5ff3 Binary files /dev/null and b/vendor/zsks/demo/face_detection/pic/image-20251023101503216.png differ diff --git a/vendor/zsks/demo/face_detection/pic/image-20251023102053075.png b/vendor/zsks/demo/face_detection/pic/image-20251023102053075.png new file mode 100755 index 0000000000000000000000000000000000000000..6fc62dd35e3dcfeb36a6e3ba1e7cea3e008660ed Binary files /dev/null and b/vendor/zsks/demo/face_detection/pic/image-20251023102053075.png differ diff --git a/vendor/zsks/demo/face_detection/pic/image-20251023102549783.png b/vendor/zsks/demo/face_detection/pic/image-20251023102549783.png new file mode 100755 index 0000000000000000000000000000000000000000..5b213c9e78709eaf94c0764a24761bd124d8dc75 Binary files /dev/null and b/vendor/zsks/demo/face_detection/pic/image-20251023102549783.png differ diff --git a/vendor/zsks/demo/fruit_identify/Makefile b/vendor/zsks/demo/fruit_identify/Makefile new file mode 100755 index 0000000000000000000000000000000000000000..60a196e7b4e7aed6990ea1f0461e9667b14c5e4c --- /dev/null +++ b/vendor/zsks/demo/fruit_identify/Makefile @@ -0,0 +1,62 @@ +# 编译所需的公共文件 +include ../mk.param + +# 编译后生成的可执行文件名 +TARGET := main + +# 编译此工程需要包含的头文件 +CFLAGS += -I$(SDK_LINUX_INCLUDE_DIR)/ +CFLAGS += -I$(SDK_SAMPLE_COMMON_DIR)/ +CFLAGS += -I$(AUDIO_SAMPLE)/adp/ +CFLAGS += -I$(SDK_LINUX_INCLUDE_DIR)/svp_npu +CFLAGS += -I$(FRUIT_IDENTIFY_SAMPLE_DIR)/ +CFLAGS += -I$(FRUIT_IDENTIFY_SAMPLE_DIR)/common/ +CFLAGS += -I$(THIRD_PARTY_DIR)/xvp_osd/include/ + +# 编译此工程需要依赖的.c或.cpp文件 +SMP_SRCS := $(AUDIO_SAMPLE)/adp/audio_aac_adp.c +SMP_SRCS += $(AUDIO_SAMPLE)/adp/audio_dl_adp.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_sys.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_audio.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_ipc.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_isp.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vi.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vo.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_mipi_tx.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vpss.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/loadbmp.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vdec.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_venc.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sdk_init.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sdk_exit.c +SMP_SRCS += $(FRUIT_IDENTIFY_SAMPLE_DIR)/fruit_identify.c +SMP_SRCS += $(FRUIT_IDENTIFY_SAMPLE_DIR)/sample_audio.c +SMP_SRCS += $(FRUIT_IDENTIFY_SAMPLE_DIR)/common/sample_common_svp_npu_model.c +SMP_SRCS += $(FRUIT_IDENTIFY_SAMPLE_DIR)/common/sample_common_svp_npu.c +SMP_SRCS += $(FRUIT_IDENTIFY_SAMPLE_DIR)/common/sample_common_svp_osd.c +SMP_SRCS += $(FRUIT_IDENTIFY_SAMPLE_DIR)/common/sample_common_svp.c + +# 编译此工程需要包含的库和宏 +CFLAGS += -O3 -g -Wall -DUSE_USB_CAMERA +CFLAGS += -fstack-protector-strong +MPI_LIBS += $(THIRD_PARTY_DIR)/xvp_osd/lib/libxvp_osd.a +MPI_LIBS += $(SDK_LINUX_OUT_LIB)/libsns_os04a10.a +CFLAGS += -DOT_ACODEC_TYPE_INNER +CFLAGS += -DOT_ACODEC_TYPE_HDMI + +# 根据实际的类型设置,可以用set_sensor脚本设置 +SENSOR0_TYPE = -DSENSOR0_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT +SENSOR1_TYPE = -DSENSOR1_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT +SENSOR2_TYPE = -DSENSOR1_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT +SENSOR3_TYPE = -DSENSOR1_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT + +CFLAGS += $(SENSOR0_TYPE) +CFLAGS += $(SENSOR1_TYPE) +CFLAGS += $(SENSOR2_TYPE) +CFLAGS += $(SENSOR3_TYPE) + +# 编译工程所需的mk文件 + +include ../sdk_linux.mk + + diff --git a/vendor/zsks/demo/fruit_identify/README.md b/vendor/zsks/demo/fruit_identify/README.md new file mode 100755 index 0000000000000000000000000000000000000000..b99c9e5cc636a67d659771dba653b29f87191b38 --- /dev/null +++ b/vendor/zsks/demo/fruit_identify/README.md @@ -0,0 +1,130 @@ +## 2.3、fruit_identify操作指导 + +### 2.3.1、fruit_identify程序简介 + +* fruit_identify sample基于SS928V100平台开发,以EulerPi套件为例,fruit_identify sample是通过USB Camera,将采集到的图片送到水果检测模型中进行推理,当检测到特定水果时,会通过外接显示屏实时显示水果的种类以及执行度,并框住水果的具体位置,并通过耳机播放出此时识别到的水果类别。 +* fruit_identify案例主要是使用pytorch框架,基于YoloV8网络,使用自行标注的水果数据集训练出来的水果分类模型。 + +### 2.3.2、目录 + +```shell +pegasus/vendor/zsks/demo/fruit_identify +|── common # 基于海思mpp/sample中的svp/common/目录下修改的代码,新增了OSD部分的内容 +|── data # 模型文件和汉字库 +|── fruit_audio # 不同水果的音频文件 +|── Makefile # 编译脚本 +|── fruit_identify.c # fruit_identif sample业务代码 +|── sample_audio.c # 音频播放的业务代码 +└── sample_audio.h # 音频播放的头文件 +``` + +![image-20250919173612332](pic/image-20250919173612332.png) + +### 2.3.3、编译 + +* **注意:在编译zsks的demo之前,请确保你已经按照[patch介绍中的步骤](../../README.md#4patch介绍)把补丁打入海思SDK的sample目录下了**。 + +* 步骤1:先根据自己选择的操作系统,进入到对应的Pegasus所在目录下。 + +* 步骤2:使用Makefile的方式进行单编 + +* 在Ubuntu的命令行终端,分步执行下面的命令,单编 fruit_identify sample + + ``` + cd pegasus/vendor/zsks/demo/fruit_identify + + make clean && make + ``` + + * 在fruit_identify/out目录下,生成一个名为main的 可执行文件,如下图所示: + + ![image-20251023103457181](pic/image-20251023103457181.png) + +### 2.3.4、拷贝可执行程序和依赖文件至开发板的mnt目录下 + +**方式一:使用SD卡进行资料文件的拷贝** + +* 首先需要自己准备一张Micro sd卡(16G 左右即可),还得有一个Micro sd卡的读卡器。 + +image-20221114150205685 + +* 步骤1:将编译后生成的可执行文件、data目录(里面有模型和字库),音频文件都拷贝到SD卡中。 + +![image-20251023103623167](pic/image-20251023103623167.png) + +* 步骤2:可执行文件拷贝成功后,将内存卡插入开发板的SD卡槽中,可通过挂载的方式挂载到板端,可选择SD卡 mount指令进行挂载。 + +image-20250210161601541 + +* 在开发板的终端,执行下面的命令进行SD卡的挂载 + * 如果挂载失败,可以参考[这个issue尝试解决](https://gitee.com/HiSpark/HiSpark_NICU2022/issues/I54932?from=project-issue) + + +```shell +mount -t vfat /dev/mmcblk1p1 /mnt +# 其中/dev/mmcblk1p1需要根据实际块设备号修改 +``` + +* 挂载成功后,如下图所示: + +![image-20251023103850695](pic/image-20251023103850695.png) + +**方式二:使用NFS挂载的方式进行资料文件的拷贝** + +* 首先需要自己准备一根网线 +* 步骤1:参考[博客链接](https://blog.csdn.net/Wu_GuiMing/article/details/115872995?spm=1001.2014.3001.5501)中的内容,进行nfs的环境搭建 +* 步骤2:将编译后生成的可执行文件、data目录(里面有模型和字库),音频文件都拷贝到Windows的nfs共享路径下 + +![image-20251023103700404](pic/image-20251023103700404.png) + +* 步骤3:在开发板的终端执行下面的命令,将Windows的nfs共享路径挂载至开发板的mnt目录下 + * 注意:这里IP地址请根据你开发板和电脑主机的实际IP地址进行填写 + + +``` +ifconfig eth0 192.168.100.100 + +mount -o nolock,addr=192.168.100.10 -t nfs 192.168.100.10:/d/nfs /mnt +``` + +![image-20251023103944837](pic/image-20251023103944837.png) + +### 2.3.5、硬件连接 + +* 准备一个外接显示器和HDMI数据线,将HDMI的一头接在开发板的HDMI输出口,将HDMI的另外一头接在外接显示器的HDMI输入口。 + +![image-20250213112932380](pic/image-20250213112932380.png) + +* 将USB 摄像头接在EulerPi开发板的USB接口上。 + +image-20250919150630870 + +### 2.3.6、功能验证 + +* 在开发板的终端执行下面的命令,运行可执行文件 + +``` +cd /mnt + +chmod +x main + +./main +``` + +![image-20251023110809454](pic/image-20251023110809454.png) + +* 此时,在HDMI的外接显示屏上即可出现实时码流,如下图所示: + +image-20250210170027454 + +* 如果您看到的现象和下图现象不一致,可以确认一下USB涉嫌头是否插入到开发板的USB口,并且在开发板的/dev目录下能够看到video0 和 video1两个设备节点。如果没有这两个设备节点,请确保镜像烧录正常。 + +![image-20250919151018659](pic/image-20250919151018659.png) + +* 正常情况下,我们会在外接显示屏上看到有水果的区域被框出来。且在框框的左上角显示水果的种类和置信度,并且你可以在开发板上面接上耳机,可以听到检测到的水果的具体语音播报。 + +![image-20250919180706355](pic/image-20250919180706355.png) + +* 敲两下回车即可关闭程序 + +![image-20250919151519310](pic/image-20250919151519310.png) \ No newline at end of file diff --git a/vendor/zsks/demo/fruit_identify/common/sample_common_svp.c b/vendor/zsks/demo/fruit_identify/common/sample_common_svp.c new file mode 100755 index 0000000000000000000000000000000000000000..79778ec97254e1250f4ea6820348267955f8df4d --- /dev/null +++ b/vendor/zsks/demo/fruit_identify/common/sample_common_svp.c @@ -0,0 +1,1036 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "sample_common_svp.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "ot_common.h" +#include "ot_common_video.h" +#include "ot_common_sys.h" +#include "ot_common_svp.h" +#include "ss_mpi_vb.h" +#include "sample_comm.h" + +#define OT_VPSS_CHN_NUM 2 +#define OT_SAMPLE_IVE_MAX_POOL_CNT 128 +#define OT_SAMPLE_IVE_DRAW_THICK 2 + +#define SAMPLE_SVP_BLK_CNT 16 +#define SMAPLE_SVP_DISPLAY_BUF_LEN 3 +#define SAMPLE_SVP_VI_CHN_INTERVAL 4 +#define SAMPLE_SVP_VDEC_CHN_0 0 +#define SAMPLE_SVP_VDEC_CHN_NUM 1 +#define SAMPLE_SVP_VPSS_BORDER_WIDTH 2 +#define SAMPLE_SVP_VO_DIS_BUF_LEN 3 +#define SAMPLE_SVP_MAX_WIDTH 32768 +#define SAMPLE_SVP_NUM_TWO 2 +#define SAMPLE_SVP_DSP_BIN_NUM_PER 4 +#define SAMPLE_SVP_DSP_MEM_TYPE_SYS_DDR 0 +#define SAMPLE_SVP_DSP_MEM_TYPE_IRAM 1 +#define SAMPLE_SVP_DSP_MEM_TYPE_DRAM_0 2 +#define SAMPLE_SVP_DSP_MEM_TYPE_DRAM_1 3 + +static td_bool g_sample_svp_init_flag = TD_FALSE; + +static td_s32 sample_common_svp_get_pic_type_by_sns_type(sample_sns_type sns_type, ot_pic_size size[], td_u32 num) +{ + sample_svp_check_exps_return(num > OT_VPSS_CHN_NUM, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "num(%u) can't be larger than (%u)\n", num, OT_VPSS_CHN_NUM); + switch (sns_type) { + case HY_S0603_MIPI_8M_30FPS_12BIT: + case HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1: + size[0] = PIC_3840X2160; + break; + default: + size[0] = PIC_3840X2160; + break; + } + return TD_SUCCESS; +} + +static td_s32 sample_comm_svp_get_pic_size(ot_pic_size pic_type, td_u64 *size) +{ + td_s32 ret; + ot_pic_buf_attr pic_buf_attr = {0}; + ot_size pic_size = {0}; + + ret = sample_comm_sys_get_pic_size(pic_type, &pic_size); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "sample_comm_sys_get_pic_size failed,Error(%#x)!\n", ret); + pic_buf_attr.width = pic_size.width; + pic_buf_attr.height = pic_size.height; + pic_buf_attr.compress_mode = OT_COMPRESS_MODE_NONE; + pic_buf_attr.align = OT_DEFAULT_ALIGN; + pic_buf_attr.bit_width = OT_DATA_BIT_WIDTH_8; + pic_buf_attr.pixel_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_422; + *size = ot_common_get_pic_buf_size(&pic_buf_attr); + return TD_SUCCESS; +} + +/* System init */ +static td_s32 sample_comm_svp_sys_init(td_bool vi_en) +{ + td_s32 ret; + ot_vb_cfg vb_cfg; + ot_pic_size pic_type; + td_u64 size = 0; + sample_sns_type sns_type = SENSOR0_TYPE; + + ret = ss_mpi_sys_exit(); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x):ss_mpi_sys_exit failed!\n", ret); + ret = ss_mpi_vb_exit(); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x):ss_mpi_vb_exit failed!\n", ret); + + (td_void)memset_s(&vb_cfg, sizeof(ot_vb_cfg), 0, sizeof(ot_vb_cfg)); + + if (vi_en == TD_FALSE) { + vb_cfg.max_pool_cnt = SAMPLE_SVP_VB_POOL_NUM; + vb_cfg.common_pool[1].blk_size = SAMPLE_SVP_D1_PAL_WIDTH * SAMPLE_SVP_D1_PAL_HEIGHT * SAMPLE_SVP_VB_POOL_NUM; + vb_cfg.common_pool[1].blk_cnt = 1; + } else { + ret = sample_common_svp_get_pic_type_by_sns_type(sns_type, &pic_type, OT_SVP_MAX_VPSS_CHN_NUM); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "sample_common_svp_get_pic_type_by_sns_type failed!\n"); + ret = sample_comm_svp_get_pic_size(pic_type, &size); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x):sample_common_svp_npu_get_pic_size failed!\n", ret); + vb_cfg.max_pool_cnt = SAMPLE_SVP_VB_POOL_NUM; + vb_cfg.common_pool[1].blk_size = size; + vb_cfg.common_pool[1].blk_cnt = SAMPLE_SVP_BLK_CNT; + } + + ret = ss_mpi_vb_set_cfg((const ot_vb_cfg *)&vb_cfg); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x):ss_mpi_vb_set_config failed!\n", ret); + + ret = ss_mpi_vb_init(); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x):ss_mpi_vb_init failed!\n", ret); + + ret = ss_mpi_sys_init(); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x):ss_mpi_sys_init failed!\n", ret); + + return ret; +} + +/* System exit */ +static td_s32 sample_comm_svp_sys_exit(td_void) +{ + td_s32 ret; + + ret = ss_mpi_sys_exit(); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x):ss_mpi_sys_exit failed!\n", ret); + + ret = ss_mpi_vb_exit(); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x):ss_mpi_vb_exit failed!\n", ret); + + return TD_SUCCESS; +} + +/* System init */ +td_s32 sample_common_svp_check_sys_init(td_bool vi_en) +{ + if (g_sample_svp_init_flag == TD_FALSE) { + if (sample_comm_svp_sys_init(vi_en) != TD_SUCCESS) { + sample_svp_trace_err("Svp mpi init failed!\n"); + return TD_FALSE; + } + g_sample_svp_init_flag = TD_TRUE; + } + + sample_svp_trace_info("Svp mpi init ok!\n"); + return TD_TRUE; +} + +/* System exit */ +td_void sample_common_svp_check_sys_exit(td_void) +{ + td_s32 ret; + + if (g_sample_svp_init_flag == TD_TRUE) { + ret = sample_comm_svp_sys_exit(); + if (ret != TD_SUCCESS) { + sample_svp_trace_err("svp mpi exit failed!\n"); + } + } + g_sample_svp_init_flag = TD_FALSE; + sample_svp_trace_info("Svp mpi exit ok!\n"); +} + +/* Align */ +td_u32 sample_common_svp_align(td_u32 size, td_u16 align) +{ + td_u32 stride; + + sample_svp_check_exps_return(align == 0, 0, SAMPLE_SVP_ERR_LEVEL_ERROR, "align can't be zero!\n"); + sample_svp_check_exps_return((size < 1) || (size > SAMPLE_SVP_MAX_WIDTH), 0, SAMPLE_SVP_ERR_LEVEL_ERROR, + "size(%u) must be [1, %u]\n", size, SAMPLE_SVP_MAX_WIDTH); + stride = size + (align - size % align) % align; + return stride; +} + +/* Create mem info */ +td_s32 sample_common_svp_create_mem_info(ot_svp_mem_info *mem_info, td_u32 size, td_u32 addr_offset) +{ + td_s32 ret = TD_FAILURE; + td_u32 size_tmp; + + sample_svp_check_exps_return(mem_info == TD_NULL, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "mem_info can't be zero\n"); + + size_tmp = size + addr_offset; + mem_info->size = size; + ret = ss_mpi_sys_mmz_alloc((td_phys_addr_t *)(&mem_info->phys_addr), + (void **)&mem_info->virt_addr, TD_NULL, TD_NULL, size_tmp); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x):ss_mpi_sys_alloc failed!\n", ret); + + mem_info->phys_addr += addr_offset; + mem_info->virt_addr += addr_offset; + + return ret; +} + +/* Destory mem info */ +td_void sample_common_svp_destroy_mem_info(ot_svp_mem_info *mem_info, td_u32 addr_offset) +{ + sample_svp_check_exps_return_void(mem_info == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, "mem_info can't be zero\n"); + + if ((mem_info->virt_addr != 0) && (mem_info->phys_addr != 0)) { + (td_void)ss_mpi_sys_mmz_free(mem_info->phys_addr - addr_offset, + sample_svp_convert_addr_to_ptr(void, (mem_info->virt_addr - addr_offset))); + } + (td_void)memset_s(mem_info, sizeof(*mem_info), 0, sizeof(*mem_info)); +} +/* Malloc memory */ +td_s32 sample_common_svp_malloc_mem(td_char *mmb, td_char *zone, td_phys_addr_t *phys_addr, + td_void **virt_addr, td_u32 size) +{ + td_s32 ret = TD_FAILURE; + + sample_svp_check_exps_return(phys_addr == TD_NULL, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "phys_addr can't be null\n"); + sample_svp_check_exps_return(virt_addr == TD_NULL, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "virt_addr can't be null\n"); + ret = ss_mpi_sys_mmz_alloc((td_phys_addr_t *)phys_addr, virt_addr, mmb, zone, size); + + return ret; +} + +/* Malloc memory with cached */ +td_s32 sample_common_svp_malloc_cached(td_char *mmb, td_char *zone, td_phys_addr_t *phys_addr, + td_void **virt_addr, td_u32 size) +{ + td_s32 ret = TD_FAILURE; + + sample_svp_check_exps_return(phys_addr == TD_NULL, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "phys_addr can't be null\n"); + sample_svp_check_exps_return(virt_addr == TD_NULL, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "virt_addr can't be null\n"); + ret = ss_mpi_sys_mmz_alloc_cached((td_phys_addr_t *)phys_addr, virt_addr, mmb, zone, size); + + return ret; +} + +/* Fulsh cached */ +td_s32 sample_common_svp_flush_cache(td_phys_addr_t phys_addr, td_void *virt_addr, td_u32 size) +{ + td_s32 ret = TD_FAILURE; + + sample_svp_check_exps_return(virt_addr == TD_NULL, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "virt_addr can't be null\n"); + ret = ss_mpi_sys_flush_cache((td_phys_addr_t)phys_addr, virt_addr, size); + return ret; +} + +/* + * function : Init Vb + */ +static td_s32 sample_common_svp_vb_init(ot_pic_size *pic_type, ot_size *pic_size, + td_u32 vpss_chn_num) +{ + td_s32 ret; + td_u32 i; + ot_vb_cfg vb_cfg = {0}; + ot_pic_buf_attr pic_buf_attr; + ot_vb_calc_cfg calc_cfg; + ot_vi_vpss_mode_type mode_type = OT_VI_ONLINE_VPSS_OFFLINE; + ot_vi_video_mode video_mode = OT_VI_VIDEO_MODE_NORM; + + vb_cfg.max_pool_cnt = OT_SAMPLE_IVE_MAX_POOL_CNT; + + ret = sample_comm_sys_get_pic_size(pic_type[0], &pic_size[0]); + sample_svp_check_exps_goto(ret != TD_SUCCESS, vb_fail_0, SAMPLE_SVP_ERR_LEVEL_ERROR, + "sample_comm_sys_get_pic_size failed,Error(%#x)!\n", ret); + pic_buf_attr.width = pic_size[0].width; + pic_buf_attr.height = pic_size[0].height; + pic_buf_attr.align = OT_DEFAULT_ALIGN; + pic_buf_attr.bit_width = OT_DATA_BIT_WIDTH_8; + pic_buf_attr.pixel_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_422; + pic_buf_attr.compress_mode = OT_COMPRESS_MODE_NONE; + + ot_common_get_pic_buf_cfg(&pic_buf_attr, &calc_cfg); + + vb_cfg.common_pool[0].blk_size = calc_cfg.vb_size; + vb_cfg.common_pool[0].blk_cnt = SAMPLE_SVP_BLK_CNT; + + for (i = 1; (i < vpss_chn_num) && (i < OT_VB_MAX_COMMON_POOLS); i++) { + ret = sample_comm_sys_get_pic_size(pic_type[i], &pic_size[i]); + sample_svp_check_exps_goto(ret != TD_SUCCESS, vb_fail_0, SAMPLE_SVP_ERR_LEVEL_ERROR, + "sample_comm_sys_get_pic_size failed,Error(%#x)!\n", ret); + pic_buf_attr.width = pic_size[i].width; + pic_buf_attr.height = pic_size[i].height; + pic_buf_attr.compress_mode = OT_COMPRESS_MODE_NONE; + pic_buf_attr.align = OT_DEFAULT_ALIGN; + + ot_common_get_pic_buf_cfg(&pic_buf_attr, &calc_cfg); + + /* comm video buffer */ + vb_cfg.common_pool[i].blk_size = calc_cfg.vb_size; + vb_cfg.common_pool[i].blk_cnt = SAMPLE_SVP_BLK_CNT; + } + + ret = sample_comm_sys_init_with_vb_supplement(&vb_cfg, OT_VB_SUPPLEMENT_BNR_MOT_MASK); + sample_svp_check_exps_goto(ret != TD_SUCCESS, vb_fail_1, SAMPLE_SVP_ERR_LEVEL_ERROR, + "sample_comm_sys_init failed,Error(%#x)!\n", ret); + + ret = sample_comm_vi_set_vi_vpss_mode(mode_type, video_mode); + sample_svp_check_exps_goto(ret != TD_SUCCESS, vb_fail_1, SAMPLE_SVP_ERR_LEVEL_ERROR, + "sample_comm_vi_set_vi_vpss_mode failed!\n"); + return ret; +vb_fail_1: + sample_comm_sys_exit(); +vb_fail_0: + return ret; +} + +td_s32 sample_common_svp_vgs_fill_rect(const ot_video_frame_info *frame_info, + ot_sample_svp_rect_info *rect, td_u32 color) +{ + ot_vgs_handle vgs_handle = -1; + td_s32 ret = TD_FAILURE; + td_u16 i; + ot_vgs_task_attr vgs_task; + ot_cover vgs_add_cover; + + sample_svp_check_exps_return(frame_info == TD_NULL, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "frame_info can't be null\n"); + sample_svp_check_exps_return(rect == TD_NULL, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "rect can't be null\n"); + sample_svp_check_exps_return(rect->num > OT_SVP_RECT_NUM, ret, + SAMPLE_SVP_ERR_LEVEL_ERROR, "rect->num can't lager than %u\n", OT_SVP_RECT_NUM); + if (rect->num == 0) { + return TD_SUCCESS; + } + + ret = ss_mpi_vgs_begin_job(&vgs_handle); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Vgs begin job fail,Error(%#x)\n", ret); + + ret = memcpy_s(&vgs_task.img_in, sizeof(ot_video_frame_info), frame_info, sizeof(ot_video_frame_info)); + sample_svp_check_exps_goto(ret != EOK, fail, SAMPLE_SVP_ERR_LEVEL_ERROR, "get img_in failed\n"); + ret = memcpy_s(&vgs_task.img_out, sizeof(ot_video_frame_info), frame_info, sizeof(ot_video_frame_info)); + sample_svp_check_exps_goto(ret != EOK, fail, SAMPLE_SVP_ERR_LEVEL_ERROR, "get img_out failed\n"); + + vgs_add_cover.type = OT_COVER_QUAD; + vgs_add_cover.color = color; + for (i = 0; i < rect->num; i++) { + vgs_add_cover.quad.is_solid = TD_FALSE; + vgs_add_cover.quad.thick = OT_SAMPLE_IVE_DRAW_THICK; + ret = memcpy_s(vgs_add_cover.quad.point, sizeof(rect->rect[i].point), + rect->rect[i].point, sizeof(rect->rect[i].point)); + sample_svp_check_exps_goto(ret != EOK, fail, SAMPLE_SVP_ERR_LEVEL_ERROR, "get point failed\n"); + ret = ss_mpi_vgs_add_cover_task(vgs_handle, &vgs_task, &vgs_add_cover, 1); + sample_svp_check_exps_goto(ret != TD_SUCCESS, fail, SAMPLE_SVP_ERR_LEVEL_ERROR, + "ss_mpi_vgs_add_cover_task fail,Error(%#x)\n", ret); + } + ret = ss_mpi_vgs_end_job(vgs_handle); + sample_svp_check_exps_goto(ret != TD_SUCCESS, fail, SAMPLE_SVP_ERR_LEVEL_ERROR, + "ss_mpi_vgs_end_job fail,Error(%#x)\n", ret); + return ret; +fail: + ss_mpi_vgs_cancel_job(vgs_handle); + return ret; +} + +/* function : Start Vpss */ +static td_s32 sample_common_svp_start_vpss(td_s32 vpss_grp_cnt, ot_size *pic_size, td_u32 vpss_chn_num) +{ + td_u32 i; + ot_vpss_chn_attr vpss_chn_attr[OT_VPSS_MAX_CHN_NUM]; + ot_vpss_grp_attr vpss_grp_attr; + td_bool chn_enable[OT_VPSS_MAX_CHN_NUM] = { TD_TRUE, TD_TRUE, TD_FALSE, TD_FALSE }; + ot_vpss_grp vpss_grp; + td_s32 ret; + + (td_void)memset_s(&vpss_grp_attr, sizeof(ot_vpss_grp_attr), 0, sizeof(ot_vpss_grp_attr)); + sample_comm_vpss_get_default_grp_attr(&vpss_grp_attr); + vpss_grp_attr.max_width = pic_size[0].width; + vpss_grp_attr.max_height = pic_size[0].height; + vpss_grp_attr.nr_attr.compress_mode = OT_COMPRESS_MODE_NONE; + /* VPSS only onle channel0 support compress seg mode */ + sample_comm_vpss_get_default_chn_attr(&vpss_chn_attr[0]); + vpss_chn_attr[0].width = pic_size[0].width; + vpss_chn_attr[0].height = pic_size[0].height; + vpss_chn_attr[0].compress_mode = OT_COMPRESS_MODE_NONE; + vpss_chn_attr[0].depth = 1; + + for (i = 1; i < vpss_chn_num; i++) { + (td_void)memset_s(&vpss_chn_attr[i], sizeof(ot_vpss_chn_attr), 0, sizeof(ot_vpss_chn_attr)); + sample_comm_vpss_get_default_chn_attr(&vpss_chn_attr[i]); + vpss_chn_attr[i].width = pic_size[i].width; + vpss_chn_attr[i].height = pic_size[i].height; + vpss_chn_attr[i].compress_mode = OT_COMPRESS_MODE_NONE; + vpss_chn_attr[i].depth = 1; + } + + for (vpss_grp = 0; vpss_grp < vpss_grp_cnt; vpss_grp++) { + ret = sample_common_vpss_start(vpss_grp, chn_enable, &vpss_grp_attr, vpss_chn_attr, OT_VPSS_MAX_CHN_NUM); + if (ret != TD_SUCCESS) { + sample_svp_trace_err("failed with %#x!\n", ret); + return TD_FAILURE; + } + } + return TD_SUCCESS; +} + +/* function : Stop Vpss */ +static td_void sample_common_svp_stop_vpss(td_s32 vpss_grp_cnt, td_u32 vpss_chn_num) +{ + ot_vpss_grp vpss_grp = 0; + td_bool chn_enable[OT_VPSS_MAX_CHN_NUM] = { TD_FALSE, TD_FALSE, TD_FALSE, TD_FALSE }; + td_s32 i; + for (i = 0; (i < vpss_chn_num) && (i < OT_VPSS_MAX_CHN_NUM); i++) { + chn_enable[i] = TD_TRUE; + } + for (i = 0; (i < vpss_grp_cnt) && (i < OT_VPSS_MAX_CHN_NUM); i++) { + sample_common_vpss_stop(vpss_grp, chn_enable, OT_VPSS_MAX_CHN_NUM); + vpss_grp++; + } +} + +static td_s32 sample_common_svp_get_def_vo_cfg(sample_vo_cfg *vo_cfg) +{ + ot_rect def_disp_rect = {0, 0, 1920, 1080}; + ot_size def_img_size = {1920, 1080}; + + if (vo_cfg == TD_NULL) { + sample_svp_trace_err("error:argument can not be TD_NULL\n"); + return TD_FAILURE; + } + + vo_cfg->vo_dev = SAMPLE_VO_DEV_UHD; + + vo_cfg->vo_intf_type = OT_VO_INTF_HDMI; + vo_cfg->intf_sync = OT_VO_OUT_1080P60; + vo_cfg->bg_color = COLOR_RGB_BLACK; + vo_cfg->pix_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_420; + vo_cfg->disp_rect = def_disp_rect; + vo_cfg->image_size = def_img_size; + vo_cfg->vo_part_mode = OT_VO_PARTITION_MODE_SINGLE; + vo_cfg->dis_buf_len = 3; /* 3: def buf len for single */ + vo_cfg->dst_dynamic_range = OT_DYNAMIC_RANGE_SDR8; + vo_cfg->vo_mode = VO_MODE_1MUX; + vo_cfg->compress_mode = OT_COMPRESS_MODE_NONE; + + return TD_SUCCESS; +} + +/* + * function : Start Vo + */ +static td_s32 sample_common_svp_start_vo(const ot_sample_svp_switch *vo_venc_switch, sample_vo_cfg *vo_cfg) +{ + td_s32 ret; + sample_svp_check_exps_return(vo_venc_switch == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "vo_venc_switch can't be null\n"); + sample_svp_check_exps_return(vo_cfg == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "vo_cfg can't be null\n"); + + if (vo_venc_switch->is_vo_open == TD_FALSE) { + return TD_SUCCESS; + } + ret = sample_common_svp_get_def_vo_cfg(vo_cfg); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_svp_get_def_vo_cfg failed!\n", ret); + ret = sample_comm_vo_start_vo(vo_cfg); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_comm_vo_start_vo failed!\n", ret); + return ret; +} + +/* + * function : Stop Vo + */ +static td_void sample_common_svp_stop_vo(const ot_sample_svp_switch *vo_venc_switch, sample_vo_cfg *vo_cfg) +{ + sample_svp_check_exps_return_void(vo_venc_switch == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, + "vo_venc_switch can't be null\n"); + sample_svp_check_exps_return_void(vo_cfg == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, "vo_cfg can't be null\n"); + + if (vo_venc_switch->is_vo_open == TD_FALSE) { + return; + } + (td_void)sample_comm_vo_stop_vo(vo_cfg); +} + +static td_s32 sample_common_svp_vi_bind_multi_vpss(td_s32 vpss_grp_cnt, td_s32 vi_chn_cnt, + td_s32 vi_chn_interval) +{ + td_s32 ret; + td_s32 loop; + ot_vi_chn vi_chn; + ot_vpss_grp vpss_grp = 0; + + for (loop = 0; loop < vi_chn_cnt && vpss_grp < vpss_grp_cnt; loop++) { + vi_chn = loop * vi_chn_interval; + ret = sample_comm_vi_bind_vpss(0, vi_chn, vpss_grp, 0); + if (ret != TD_SUCCESS) { + sample_svp_trace_err("vi bind vpss failed!\n"); + return ret; + } + vpss_grp++; + } + + return TD_SUCCESS; +} + +static td_s32 sample_common_svp_vi_unbind_multi_vpss(td_s32 vpss_grp_cnt, td_s32 vi_chn_cnt, + td_s32 vi_chn_interval) +{ + td_s32 ret; + td_s32 loop; + ot_vi_chn vi_chn; + ot_vpss_grp vpss_grp = 0; + + for (loop = 0; loop < vi_chn_cnt && vpss_grp < vpss_grp_cnt; loop++) { + vi_chn = loop * vi_chn_interval; + ret = sample_comm_vi_un_bind_vpss(0, vi_chn, vpss_grp, 0); + if (ret != TD_SUCCESS) { + sample_svp_trace_err("vi bind vpss failed!\n"); + return ret; + } + + vpss_grp++; + } + + return TD_SUCCESS; +} + +static td_s32 sample_common_svp_set_vi_cfg(sample_vi_cfg *vi_cfg, ot_pic_size *pic_type, + td_u32 pic_type_len, ot_pic_size *ext_pic_size_type, sample_sns_type sns_type) +{ + sample_comm_vi_get_default_vi_cfg(sns_type, vi_cfg); + sample_svp_check_exps_return(pic_type_len < OT_VPSS_CHN_NUM, + TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "pic_type_len is illegal!\n"); + pic_type[1] = *ext_pic_size_type; + + return TD_SUCCESS; +} + +static td_s32 sample_common_svp_start_venc(const ot_sample_svp_switch *switch_ptr, + sample_vo_cfg *vo_cfg, ot_pic_size *pic_type, td_u32 chn_num) +{ + td_s32 ret = TD_SUCCESS; + ot_venc_chn h264_chn = 0; + sample_comm_venc_chn_param chn_param; + ot_size ven_size = {1920, 1080}; + + sample_svp_check_exps_goto(chn_num == 0, end_0, SAMPLE_SVP_ERR_LEVEL_ERROR, "Error(%#x),chn_num(%u) can't be 0!\n", + ret, chn_num); + if (switch_ptr->is_venc_open == TD_TRUE) { + ret = sample_comm_venc_get_gop_attr(OT_VENC_GOP_MODE_NORMAL_P, &chn_param.gop_attr); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_0, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_comm_venc_get_gop_attr failed!\n", ret); + chn_param.frame_rate = 30; /* 30 is a number */ + chn_param.stats_time = 1; /* 1 is a number */ + chn_param.gop = 30; /* 30 is a number */ + chn_param.venc_size = ven_size; + chn_param.size = pic_type[0]; + chn_param.profile = 0; + chn_param.is_rcn_ref_share_buf = TD_TRUE; + + chn_param.type = OT_PT_H264; + chn_param.rc_mode = SAMPLE_RC_CBR; + + ret = sample_comm_venc_start(h264_chn, &chn_param); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_0, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_comm_venc_start failed!\n", ret); + + ret = sample_comm_venc_start_get_stream(&h264_chn, 1); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_1, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_comm_venc_start_get_stream failed!\n", ret); + } + return ret; + +end_1: + if (switch_ptr->is_venc_open == TD_TRUE) { + sample_comm_venc_stop(h264_chn); + } +end_0: + sample_common_svp_stop_vo(switch_ptr, vo_cfg); + return ret; +} + +/* + * function : Start Vi/Vpss/Venc/Vo + */ +td_s32 sample_common_svp_start_vi_vpss_venc_vo(sample_vi_cfg *vi_cfg, + ot_sample_svp_switch *switch_ptr, ot_pic_size *ext_pic_size_type) +{ + ot_size pic_size[OT_VPSS_CHN_NUM]; + ot_pic_size pic_type[OT_VPSS_CHN_NUM]; + sample_vo_cfg vo_cfg; + ot_pic_size venc_pic_type[SAMPLE_SVP_VDEC_CHN_NUM] = {PIC_1080P}; + + const td_s32 vpss_grp_cnt = 1; + td_s32 ret = TD_FAILURE; + sample_sns_type sns_type = SENSOR0_TYPE; + + sample_svp_check_exps_return(vi_cfg == TD_NULL, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "vi_cfg can't be null\n"); + sample_svp_check_exps_return(switch_ptr == TD_NULL, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "switch_ptr can't be null\n"); + sample_svp_check_exps_return(ext_pic_size_type == TD_NULL, ret, + SAMPLE_SVP_ERR_LEVEL_ERROR, "ext_pic_size_type can't be null\n"); + + ret = sample_common_svp_get_pic_type_by_sns_type(sns_type, pic_type, OT_VPSS_CHN_NUM); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "sample_common_svp_get_pic_type_by_sns_type failed!\n"); + ret = sample_common_svp_set_vi_cfg(vi_cfg, pic_type, OT_VPSS_CHN_NUM, ext_pic_size_type, sns_type); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "sample_common_svp_set_vi_cfg failed,Error:%#x\n", ret); + + /* step 1: Init vb */ + ret = sample_common_svp_vb_init(pic_type, pic_size, OT_VPSS_CHN_NUM); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_svp_vb_init failed!\n", ret); + + /* step 2: Start vi */ + ret = sample_comm_vi_start_vi(vi_cfg); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_init_1, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_comm_vi_start_vi failed!\n", ret); + + /* step 3: Bind vpss to vi */ + ret = sample_common_svp_vi_bind_multi_vpss(vpss_grp_cnt, 1, 1); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_init_2, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_vi_bind_multi_vpss failed!\n", ret); + + /* step 4: Start vpss */ + ret = sample_common_svp_start_vpss(vpss_grp_cnt, pic_size, OT_VPSS_CHN_NUM); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_init_3, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_svp_start_vpss failed!\n", ret); + + /* step 5: Set vi frame, Start Vo */ + ret = sample_common_svp_start_vo(switch_ptr, &vo_cfg); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_init_4, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_svp_set_vi_frame failed!\n", ret); + + /* step 6: Start Venc */ + ret = sample_common_svp_start_venc(switch_ptr, &vo_cfg, venc_pic_type, SAMPLE_SVP_VDEC_CHN_NUM); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_init_4, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_svp_start_vencb failed!\n", ret); + + return TD_SUCCESS; +end_init_4: + sample_common_svp_stop_vpss(vpss_grp_cnt, OT_VPSS_CHN_NUM); +end_init_3: + ret = sample_common_svp_vi_unbind_multi_vpss(vpss_grp_cnt, 1, 1); + sample_svp_check_exps_trace(ret != TD_SUCCESS, SAMPLE_SVP_ERR_LEVEL_ERROR, "svp_vi_unbind_multi_vpss failed!\n"); +end_init_2: + sample_comm_vi_stop_vi(vi_cfg); +end_init_1: /* system exit */ + sample_comm_sys_exit(); + (td_void)memset_s(vi_cfg, sizeof(sample_vi_cfg), 0, sizeof(sample_vi_cfg)); + return ret; +} +static td_void sample_common_svp_stop_venc(const ot_sample_svp_switch *vo_venc_switch) +{ + if (vo_venc_switch->is_venc_open == TD_TRUE) { + sample_comm_venc_stop_get_stream(1); + sample_comm_venc_stop(0); + } +} +/* + * function : Stop Vi/Vpss/Venc/Vo + */ +td_void sample_common_svp_stop_vi_vpss_venc_vo(sample_vi_cfg *vi_cfg, + ot_sample_svp_switch *switch_ptr) +{ + sample_vo_cfg vo_cfg = {0}; + td_s32 ret; + const td_s32 vpss_grp_cnt = 1; + + sample_svp_check_exps_return_void(vi_cfg == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, "vi_cfg can't be null\n"); + sample_svp_check_exps_return_void(switch_ptr == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, "switch_ptr can't be null\n"); + + sample_common_svp_stop_venc(switch_ptr); + + if (switch_ptr->is_vo_open == TD_TRUE) { + (td_void)sample_common_svp_get_def_vo_cfg(&vo_cfg); + sample_common_svp_stop_vo(switch_ptr, &vo_cfg); + } + + ret = sample_common_svp_vi_unbind_multi_vpss(vpss_grp_cnt, 1, 1); + sample_svp_check_exps_trace(ret != TD_SUCCESS, SAMPLE_SVP_ERR_LEVEL_ERROR, + "sample_common_svp_vi_unbind_multi_vpss failed\n"); + sample_common_svp_stop_vpss(vpss_grp_cnt, OT_VPSS_CHN_NUM); + sample_comm_vi_stop_vi(vi_cfg); + sample_comm_sys_exit(); + + (td_void)memset_s(vi_cfg, sizeof(sample_vi_cfg), 0, sizeof(sample_vi_cfg)); +} + +static td_s32 sample_common_svp_start_vdec(td_u32 chn_num, sample_vdec_attr *vdec_attr, td_u32 arr_len) +{ + td_s32 ret; + ret = sample_comm_vdec_init_vb_pool(chn_num, vdec_attr, arr_len); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_comm_vdec_init_vb_pool failed!\n", ret); + + ret = sample_comm_vdec_start(chn_num, vdec_attr, arr_len); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_1, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x), sample_comm_vdec_start failed!\n", ret); + + ret = ss_mpi_vdec_set_display_mode(SAMPLE_SVP_VDEC_CHN_0, OT_VIDEO_DISPLAY_MODE_PREVIEW); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_1, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x), sample_comm_vdec_start failed!\n", ret); + + return ret; +end_1: + sample_comm_vdec_exit_vb_pool(); + return ret; +} + +static td_void sample_common_svp_stop_vdec(td_u32 chn_num) +{ + td_s32 ret; + ret = sample_comm_vdec_stop(chn_num); + sample_svp_check_exps_trace(ret != TD_SUCCESS, SAMPLE_SVP_ERR_LEVEL_ERROR, "sample_comm_vdec_stop failed\n"); + sample_comm_vdec_exit_vb_pool(); +} + +static td_s32 sample_common_svp_vpss_bind_vdec(td_s32 vpss_grp_cnt, td_s32 vdec_chn) +{ + td_s32 i; + td_s32 j; + td_s32 ret; + for (i = 0; i < vpss_grp_cnt; i++) { + ret = sample_comm_vdec_bind_vpss(vdec_chn, i); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_1, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x), sample_comm_vdec_bind_vpss failed!\n", ret); + } + return ret; +end_1: + for (j = 0; j < i; j++) { + sample_comm_vdec_un_bind_vpss(vdec_chn, j); + } + return ret; +} + +static td_void sample_common_svp_vpss_unbind_vdec(td_s32 vpss_grp_cnt, td_s32 vdec_chn) +{ + td_s32 i; + for (i = 0; i < vpss_grp_cnt; i++) { + sample_comm_vdec_un_bind_vpss(vdec_chn, i); + } +} + +static td_s32 sample_common_svp_create_vb(ot_sample_svp_media_cfg *media_cfg) +{ + td_s32 ret = OT_INVALID_VALUE; + td_u32 i; + td_u32 j; + td_u64 blk_size; + ot_vb_pool_cfg vb_pool_cfg = { 0 }; + ot_pic_buf_attr pic_buf_attr = {0}; + + sample_svp_check_exps_return(media_cfg == TD_NULL, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "media_cfg is NULL!\n"); + + sample_svp_check_exps_return((media_cfg->chn_num == 0) || (media_cfg->chn_num > OT_SVP_MAX_VPSS_CHN_NUM), ret, + SAMPLE_SVP_ERR_LEVEL_ERROR, "media_cfg->chn_num must be [1, %d],Error(%#x)!\n", OT_SVP_MAX_VPSS_CHN_NUM, ret); + + for (i = 0; i < media_cfg->chn_num; i++) { + if (media_cfg->pic_type[i] != PIC_BUTT) { + ret = sample_comm_sys_get_pic_size(media_cfg->pic_type[i], &media_cfg->pic_size[i]); + sample_svp_check_exps_goto(ret != TD_SUCCESS, vb_fail_0, SAMPLE_SVP_ERR_LEVEL_ERROR, + "sample_comm_sys_get_pic_size failed,Error(%#x)!\n", ret); + } + pic_buf_attr.width = media_cfg->pic_size[i].width; + pic_buf_attr.height = media_cfg->pic_size[i].height; + pic_buf_attr.compress_mode = OT_COMPRESS_MODE_NONE; + pic_buf_attr.align = OT_DEFAULT_ALIGN; + pic_buf_attr.bit_width = OT_DATA_BIT_WIDTH_8; + pic_buf_attr.pixel_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_422; + blk_size = ot_common_get_pic_buf_size(&pic_buf_attr); + vb_pool_cfg.blk_size = blk_size; + vb_pool_cfg.blk_cnt = SAMPLE_SVP_BLK_CNT; + media_cfg->vb_pool[i] = ss_mpi_vb_create_pool(&vb_pool_cfg); + } + return TD_SUCCESS; +vb_fail_0: + for (j = 0; j < i; j++) { + (td_void)ss_mpi_vb_destroy_pool(media_cfg->vb_pool[j]); + } + return TD_FAILURE; +} + +static td_void sample_common_svp_destroy_vb(ot_sample_svp_media_cfg *media_cfg) +{ + td_u32 i; + for (i = 0; i < media_cfg->chn_num; i++) { + (td_void)ss_mpi_vb_destroy_pool(media_cfg->vb_pool[i]); + } +} +static td_s32 sample_common_svp_vpss_attach_vb(ot_sample_svp_media_cfg *media_cfg, td_s32 vpss_grp_cnt) +{ + ot_vpss_grp grp; + ot_vpss_grp grp_tmp; + ot_vpss_chn chn; + ot_vpss_grp chn_tmp; + td_s32 ret; + + for (grp = 0; grp < vpss_grp_cnt; grp++) { + for (chn = 0; chn < media_cfg->chn_num; chn++) { + ret = ss_mpi_vpss_attach_vb_pool(grp, chn, media_cfg->vb_pool[chn]); + if (ret == TD_SUCCESS) { + continue; + } + for (chn_tmp = 0; chn_tmp < chn; chn_tmp++) { + (td_void)ss_mpi_vpss_detach_vb_pool(grp, chn_tmp); + } + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_0, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x), ss_mpi_vpss_attach_vb_pool failed!\n", ret); + } + } + return ret; +end_0: + for (grp_tmp = 0; grp_tmp < grp; grp_tmp++) { + for (chn_tmp = 0; chn_tmp < media_cfg->chn_num; chn_tmp++) { + (td_void)ss_mpi_vpss_detach_vb_pool(grp_tmp, chn_tmp); + } + } + return ret; +} + +static td_void sample_common_svp_vpss_detach_vb(ot_sample_svp_media_cfg *media_cfg, td_s32 vpss_grp_cnt) +{ + ot_vpss_grp grp; + ot_vpss_chn chn; + + for (grp = 0; grp < vpss_grp_cnt; grp++) { + for (chn = 0; chn < media_cfg->chn_num; chn++) { + (td_void)ss_mpi_vpss_detach_vb_pool(grp, chn); + } + } +} + +td_s32 sample_common_svp_create_vb_start_vdec_vpss_vo(sample_vdec_attr *vdec_attr, vdec_thread_param *vdec_send, + pthread_t *vdec_thread, ot_sample_svp_media_cfg *media_cfg, sample_vo_cfg *vo_cfg) +{ + const td_s32 vpss_grp_cnt = 1; + td_s32 ret; + /* step 1: Init vb */ + ret = sample_common_svp_create_vb(media_cfg); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_svp_create_vb failed!\n", ret); + /* step 2: start vdec */ + ret = sample_common_svp_start_vdec(SAMPLE_SVP_VDEC_CHN_NUM, vdec_attr, SAMPLE_SVP_VDEC_CHN_NUM); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_init_1, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x), sample_common_svp_start_vdec failed!\n", ret); + /* step 3: Start vpss */ + ret = sample_common_svp_start_vpss(vpss_grp_cnt, media_cfg->pic_size, media_cfg->chn_num); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_init_2, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_svp_start_vpss failed!\n", ret); + + ret = sample_common_svp_vpss_attach_vb(media_cfg, vpss_grp_cnt); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_init_3, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_svp_start_vpss failed!\n", ret); + + /* step 4: Bind vpss to vdec */ + ret = sample_common_svp_vpss_bind_vdec(vpss_grp_cnt, SAMPLE_SVP_VDEC_CHN_0); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_init_4, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_comm_vdec_bind_vpss failed!\n", ret); + + /* step 5: Start vo */ + ret = sample_common_svp_start_vo(&(media_cfg->svp_switch), vo_cfg); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_init_5, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_svp_start_vo failed!\n", ret); + + /* step 5: Start Send thread */ + sample_comm_vdec_start_send_stream(SAMPLE_SVP_VDEC_CHN_NUM, vdec_send, vdec_thread, SAMPLE_SVP_VDEC_CHN_NUM, + SAMPLE_SVP_VDEC_CHN_NUM); + + /* step 6: Start Venc */ + ret = sample_common_svp_start_venc(&(media_cfg->svp_switch), vo_cfg, media_cfg->pic_type, + SAMPLE_SVP_VDEC_CHN_NUM); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_init_6, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_svp_start_venc failed!\n", ret); + + return ret; +end_init_6: + sample_comm_vdec_stop_send_stream(SAMPLE_SVP_VDEC_CHN_NUM, vdec_send, vdec_thread, SAMPLE_SVP_VDEC_CHN_NUM, + SAMPLE_SVP_VDEC_CHN_NUM); + sample_common_svp_stop_vo(&(media_cfg->svp_switch), vo_cfg); +end_init_5: + sample_common_svp_vpss_unbind_vdec(vpss_grp_cnt, SAMPLE_SVP_VDEC_CHN_0); +end_init_4: + sample_common_svp_vpss_detach_vb(media_cfg, vpss_grp_cnt); +end_init_3: + sample_common_svp_stop_vpss(vpss_grp_cnt, media_cfg->chn_num); +end_init_2: + sample_common_svp_stop_vdec(SAMPLE_SVP_VDEC_CHN_NUM); +end_init_1: + sample_common_svp_destroy_vb(media_cfg); + return ret; +} + +td_void sample_common_svp_destroy_vb_stop_vdec_vpss_vo(vdec_thread_param *vdec_send, pthread_t *vdec_thread, + ot_sample_svp_media_cfg *media_cfg, sample_vo_cfg *vo_cfg) +{ + const td_s32 vpss_grp_cnt = 1; + + sample_svp_check_exps_return_void(media_cfg == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, "media_cfg is NULL!\n"); + + sample_svp_check_exps_return_void((media_cfg->chn_num == 0) || (media_cfg->chn_num > OT_SVP_MAX_VPSS_CHN_NUM), + SAMPLE_SVP_ERR_LEVEL_ERROR, "media_cfg->chn_num must be [1, %u]!\n", OT_SVP_MAX_VPSS_CHN_NUM); + + sample_common_svp_stop_venc(&(media_cfg->svp_switch)); + + sample_comm_vdec_stop_send_stream(SAMPLE_SVP_VDEC_CHN_NUM, vdec_send, vdec_thread, SAMPLE_SVP_VDEC_CHN_NUM, + SAMPLE_SVP_VDEC_CHN_NUM); + sample_common_svp_stop_vo(&(media_cfg->svp_switch), vo_cfg); + sample_common_svp_vpss_unbind_vdec(vpss_grp_cnt, SAMPLE_SVP_VDEC_CHN_0); + sample_common_svp_vpss_detach_vb(media_cfg, vpss_grp_cnt); + sample_common_svp_stop_vpss(vpss_grp_cnt, media_cfg->chn_num); + sample_common_svp_stop_vdec(SAMPLE_SVP_VDEC_CHN_NUM); + sample_common_svp_destroy_vb(media_cfg); +} + +td_s32 sample_common_svp_venc_vo_send_stream(const ot_sample_svp_switch *vo_venc_switch, ot_venc_chn venc_chn, + ot_vo_layer vo_layer, ot_vo_chn vo_chn, const ot_video_frame_info *frame) +{ + td_s32 ret = OT_INVALID_VALUE; + + sample_svp_check_exps_return((vo_venc_switch == TD_NULL || frame == TD_NULL), ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "vo_venc_switch is NULL!\n"); + if (vo_venc_switch->is_venc_open) { + ret = ss_mpi_venc_send_frame(venc_chn, frame, OT_SVP_TIMEOUT); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),ss_mpi_venc_send_frame failed!\n", ret); + } + if (vo_venc_switch->is_vo_open) { + ret = ss_mpi_vo_send_frame(vo_layer, vo_chn, frame, OT_SVP_TIMEOUT); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),ss_mpi_vo_send_frame failed!\n", ret); + } + return TD_SUCCESS; +} + +static td_s32 sample_common_svp_npu_get_pic_size(ot_sample_svp_media_cfg *media_cfg) +{ + td_s32 ret; + ret = sample_comm_sys_get_pic_size(media_cfg->pic_type[0], &media_cfg->pic_size[0]); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "sample_comm_sys_get_pic_size failed,Error(%#x)!\n", ret); + return TD_SUCCESS; +} + +/* + * function : Start Vi/Vpss/Vo + */ +td_s32 sample_common_svp_npu_start_vi_vpss_vo(sample_vi_cfg *vi_cfg, ot_sample_svp_media_cfg *media_cfg, + sample_vo_cfg *vo_cfg) +{ + td_s32 ret; + const td_s32 vpss_grp_cnt = 1; + sample_sns_type sns_type = SENSOR0_TYPE; + + ret = sample_common_svp_get_pic_type_by_sns_type(sns_type, media_cfg->pic_type, OT_SVP_MAX_VPSS_CHN_NUM); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "sample_common_svp_get_pic_type_by_sns_type failed!\n"); + sample_comm_vi_get_default_vi_cfg(sns_type, vi_cfg); + + ret = sample_common_svp_npu_get_pic_size(media_cfg); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x):sample_common_svp_npu_get_pic_size failed!\n", ret); + + /* step 1: Init vb */ + ret = sample_common_svp_create_vb(media_cfg); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_svp_create_vb failed!\n", ret); + + /* step 2: Start vi */ + ret = sample_comm_vi_start_vi(vi_cfg); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_init_1, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_comm_vi_start_vi failed!\n", ret); + + /* step 3: Bind vpss to vi */ + ret = sample_common_svp_vi_bind_multi_vpss(vpss_grp_cnt, 1, 1); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_init_2, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_vi_bind_multi_vpss failed!\n", ret); + + /* step 4: Start vpss */ + ret = sample_common_svp_start_vpss(vpss_grp_cnt, media_cfg->pic_size, media_cfg->chn_num); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_init_3, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_svp_start_vpss failed!\n", ret); + + /* step 5: attach vb */ + ret = sample_common_svp_vpss_attach_vb(media_cfg, vpss_grp_cnt); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_init_4, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_svp_start_vpss failed!\n", ret); + + /* step 6: Start vo */ + ret = sample_common_svp_start_vo(&(media_cfg->svp_switch), vo_cfg); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end_init_5, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_svp_start_vo failed!\n", ret); + + return ret; + +end_init_5: + sample_common_svp_vpss_detach_vb(media_cfg, vpss_grp_cnt); +end_init_4: + sample_common_svp_stop_vpss(vpss_grp_cnt, media_cfg->chn_num); +end_init_3: + sample_common_svp_vi_unbind_multi_vpss(vpss_grp_cnt, 1, 1); +end_init_2: + sample_comm_vi_stop_vi(vi_cfg); +end_init_1: + sample_common_svp_destroy_vb(media_cfg); + return ret; +} + +td_void sample_common_svp_destroy_vb_stop_vi_vpss_vo(sample_vi_cfg *vi_cfg, ot_sample_svp_media_cfg *media_cfg, + sample_vo_cfg *vo_cfg) +{ + const td_s32 vpss_grp_cnt = 1; + + sample_svp_check_exps_return_void(media_cfg == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, "media_cfg is NULL!\n"); + + sample_svp_check_exps_return_void((media_cfg->chn_num == 0) || (media_cfg->chn_num > OT_SVP_MAX_VPSS_CHN_NUM), + SAMPLE_SVP_ERR_LEVEL_ERROR, "media_cfg->chn_num must be [1, %u]!\n", OT_SVP_MAX_VPSS_CHN_NUM); + + sample_common_svp_stop_vo(&(media_cfg->svp_switch), vo_cfg); + sample_common_svp_vpss_detach_vb(media_cfg, vpss_grp_cnt); + sample_common_svp_stop_vpss(vpss_grp_cnt, media_cfg->chn_num); + sample_common_svp_vi_unbind_multi_vpss(vpss_grp_cnt, 1, 1); + sample_comm_vi_stop_vi(vi_cfg); + sample_common_svp_destroy_vb(media_cfg); +} diff --git a/vendor/zsks/demo/fruit_identify/common/sample_common_svp.h b/vendor/zsks/demo/fruit_identify/common/sample_common_svp.h new file mode 100755 index 0000000000000000000000000000000000000000..4ba556b17669a3b834ffea68f50343a60fc6d3ea --- /dev/null +++ b/vendor/zsks/demo/fruit_identify/common/sample_common_svp.h @@ -0,0 +1,298 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef SAMPLE_COMMON_SVP_H +#define SAMPLE_COMMON_SVP_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ss_mpi_sys.h" +#include "ot_common.h" +#include "ot_common_svp.h" +#include "sample_comm.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C"{ +#endif +#endif /* __cplusplus */ + +#define OT_SVP_RECT_NUM 64 +#define OT_POINT_NUM 4 +#define OT_SVP_MAX_VPSS_CHN_NUM 2 +#define OT_SVP_TIMEOUT 2000 + +typedef enum { + SAMPLE_SVP_ERR_LEVEL_DEBUG = 0x0, /* debug-level */ + SAMPLE_SVP_ERR_LEVEL_INFO = 0x1, /* informational */ + SAMPLE_SVP_ERR_LEVEL_NOTICE = 0x2, /* normal but significant condition */ + SAMPLE_SVP_ERR_LEVEL_WARNING = 0x3, /* warning conditions */ + SAMPLE_SVP_ERR_LEVEL_ERROR = 0x4, /* error conditions */ + SAMPLE_SVP_ERR_LEVEL_CRIT = 0x5, /* critical conditions */ + SAMPLE_SVP_ERR_LEVEL_ALERT = 0x6, /* action must be taken immediately */ + SAMPLE_SVP_ERR_LEVEL_FATAL = 0x7, /* just for compatibility with previous version */ + + SAMPLE_SVP_ERR_LEVEL_BUTT +} sample_svp_err_level; + +typedef struct { + ot_point point[OT_POINT_NUM]; + td_float score; + td_u16 class_id; +} ot_sample_svp_rect; + +typedef struct { + td_u16 num; + ot_sample_svp_rect rect[OT_SVP_RECT_NUM]; +} ot_sample_svp_rect_info; + +typedef struct { + td_bool is_venc_open; + td_bool is_vo_open; +} ot_sample_svp_switch; + +typedef struct { + ot_sample_svp_switch svp_switch; + ot_size pic_size[OT_SVP_MAX_VPSS_CHN_NUM]; + ot_pic_size pic_type[OT_SVP_MAX_VPSS_CHN_NUM]; + ot_vb_pool vb_pool[OT_SVP_MAX_VPSS_CHN_NUM]; + td_u32 chn_num; +} ot_sample_svp_media_cfg; + +#define sample_svp_printf(level_str, msg, ...) \ +do { \ + fprintf(stderr, "[level]:%s,[func]:%s [line]:%d [info]:"msg, level_str, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ +} while (0) + +#define sample_svp_printf_red(level_str, msg, ...) \ +do { \ + fprintf(stderr, "\033[0;31m [level]:%s,[func]:%s [line]:%d [info]:"msg"\033[0;39m\n", level_str, __FUNCTION__, \ + __LINE__, ##__VA_ARGS__); \ +} while (0) +/* system is unusable */ +#define sample_svp_trace_fatal(msg, ...) sample_svp_printf_red("Fatal", msg, ##__VA_ARGS__) +/* action must be taken immediately */ +#define sample_svp_trace_alert(msg, ...) sample_svp_printf_red("Alert", msg, ##__VA_ARGS__) +/* critical conditions */ +#define sample_svp_trace_critical(msg, ...) sample_svp_printf_red("Critical", msg, ##__VA_ARGS__) +/* error conditions */ +#define sample_svp_trace_err(msg, ...) sample_svp_printf_red("Error", msg, ##__VA_ARGS__) +/* warning conditions */ +#define sample_svp_trace_warning(msg, ...) sample_svp_printf("Warning", msg, ##__VA_ARGS__) +/* normal but significant condition */ +#define sample_svp_trace_notic(msg, ...) sample_svp_printf("Notice", msg, ##__VA_ARGS__) +/* informational */ +#define sample_svp_trace_info(msg, ...) sample_svp_printf("Info", msg, ##__VA_ARGS__) +/* debug-level messages */ +#define sample_svp_trace_debug(msg, ...) sample_svp_printf("Debug", msg, ##__VA_ARGS__) + +/* exps is true, goto */ +#define sample_svp_check_exps_goto(exps, label, level, msg, ...) \ +do { \ + if ((exps)) { \ + sample_svp_trace_err(msg, ## __VA_ARGS__); \ + goto label; \ + } \ +} while (0) +/* exps is true, return td_void */ +#define sample_svp_check_exps_return_void(exps, level, msg, ...) \ +do { \ + if ((exps)) { \ + sample_svp_trace_err(msg, ##__VA_ARGS__); \ + return; \ + } \ +} while (0) +/* exps is true, return ret */ +#define sample_svp_check_exps_return(exps, ret, level, msg, ...) \ +do { \ + if ((exps)) { \ + sample_svp_trace_err(msg, ##__VA_ARGS__); \ + return (ret); \ + } \ +} while (0) \ +/* exps is true, trace */ +#define sample_svp_check_exps_trace(exps, level, msg, ...) \ +do { \ + if ((exps)) { \ + sample_svp_trace_err(msg, ##__VA_ARGS__); \ + } \ +} while (0) + +#define sample_svp_check_exps_continue(exps, level, msg, ...) \ +do { \ + if ((exps)) { \ + sample_svp_trace_err(msg, ##__VA_ARGS__); \ + continue; \ + } \ +} while (0) \ + +/* exps is not success, trace */ +#define sample_svp_check_failed_trace(exps, level, msg, ...) \ +do { \ + if ((exps) != TD_SUCCESS) { \ + sample_svp_trace_err(msg, ##__VA_ARGS__); \ + } \ +} while (0) + +/* exps is not success, goto */ +#define sample_svp_check_failed_goto(exps, label, level, msg, ...) \ +do { \ + if ((exps) != TD_SUCCESS) { \ + sample_svp_trace_err(msg, ## __VA_ARGS__); \ + goto label; \ + } \ +} while (0) \ + +/* exps is not sucecss, return */ +#define sample_svp_check_failed_return(exps, ret, level, msg, ...) \ +do { \ + if ((exps) != TD_SUCCESS) { \ + sample_svp_trace_err(msg, ##__VA_ARGS__); \ + return (ret); \ + } \ +} while (0) + +/* exps is not equal to success, goto with level SAMPLE_SVP_ERR_LEVEL_ERROR */ +#define sample_svp_check_failed_err_level_goto(exps, label, msg, ...) \ +do { \ + if ((exps) != TD_SUCCESS) { \ + sample_svp_trace_err(msg, ## __VA_ARGS__); \ + goto label; \ + } \ +} while (0) + +/* exps is not equal to success, return with level SAMPLE_SVP_ERR_LEVEL_ERROR */ +#define sample_svp_check_failed_err_level_return(exps, ret, msg, ...) \ +do { \ + if ((exps) != TD_SUCCESS) { \ + sample_svp_trace_err(msg, ## __VA_ARGS__); \ + return (ret); \ + } \ +} while (0) + +/* exps is not equal success, trace with level SAMPLE_SVP_ERR_LEVEL_ERROR */ +#define sample_svp_check_failed_err_level_trace(exps, msg, ...) \ +do { \ + if ((exps) != TD_SUCCESS) { \ + sample_svp_trace_err(msg, ##__VA_ARGS__); \ + } \ +} while (0) + +#define sample_svp_pause() \ +do { \ + printf("---------------press Enter key to exit!---------------\n"); \ + (void)getchar(); \ +} while (0) + +#define SAMPLE_SVP_VB_POOL_NUM 2 +#define SAMPLE_SVP_ALIGN_16 16 +#define SAMPLE_SVP_ALIGN_32 32 +#define SAMPLE_SVP_D1_PAL_HEIGHT 576 +#define SAMPLE_SVP_D1_PAL_WIDTH 704 +#define sample_svp_convert_addr_to_ptr(type, addr) ((type *)(td_uintptr_t)(addr)) +#define sample_svp_convert_ptr_to_addr(type, addr) ((type)(td_uintptr_t)(addr)) + +/* free mmz */ +#define sample_svp_mmz_free(phys, virt) \ +do { \ + if (((phys) != 0) && ((virt) != 0)) { \ + ss_mpi_sys_mmz_free((td_phys_addr_t)(phys), (td_void*)(td_uintptr_t)(virt)); \ + (phys) = 0; \ + (virt) = 0; \ + } \ +} while (0) + +#define sample_svp_close_file(fp) \ +do { \ + if ((fp) != TD_NULL) { \ + fclose((fp)); \ + (fp) = TD_NULL; \ + } \ +} while (0) + +/* System init */ +td_s32 sample_common_svp_check_sys_init(td_bool vi_en); + +/* System exit */ +td_void sample_common_svp_check_sys_exit(td_void); + +/* Align */ +td_u32 sample_common_svp_align(td_u32 size, td_u16 align); + +/* Create mem info */ +td_s32 sample_common_svp_create_mem_info(ot_svp_mem_info *mem_info, td_u32 size, td_u32 addr_offsset); + +/* Destory mem info */ +td_void sample_common_svp_destroy_mem_info(ot_svp_mem_info *mem_info, td_u32 addr_offsset); + +/* Malloc memory */ +td_s32 sample_common_svp_malloc_mem(td_char *mmb, td_char *zone, td_phys_addr_t *phys_addr, + td_void **virt_addr, td_u32 size); + +/* Malloc memory with cached */ +td_s32 sample_common_svp_malloc_cached(td_char *mmb, td_char *zone, td_phys_addr_t *phys_addr, + td_void **virt_addr, td_u32 size); + +/* Fulsh cached */ +td_s32 sample_common_svp_flush_cache(td_phys_addr_t phys_addr, td_void *virt_addr, td_u32 size); + +/* function : Call vgs to fill rect */ +td_s32 sample_common_svp_vgs_fill_rect(const ot_video_frame_info *frame_info, + ot_sample_svp_rect_info *rect, td_u32 color); + +/* function : Start Vi/Vpss/Venc/Vo */ +td_s32 sample_common_svp_start_vi_vpss_venc_vo(sample_vi_cfg *vi_config, + ot_sample_svp_switch *switch_ptr, ot_pic_size *ext_pic_size_type); + +/* function : Stop Vi/Vpss/Venc/Vo */ +td_void sample_common_svp_stop_vi_vpss_venc_vo(sample_vi_cfg *vi_config, + ot_sample_svp_switch *switch_ptr); + +/* + * Start Vdec/Vpss/Vo + */ +td_s32 sample_common_svp_create_vb_start_vdec_vpss_vo(sample_vdec_attr *vdec_attr, + vdec_thread_param *vdec_send, pthread_t *vdec_thread, ot_sample_svp_media_cfg *media_cfg, + sample_vo_cfg *vo_cfg); +/* + * Stop Vdec/Vpss/Vo + */ +td_void sample_common_svp_destroy_vb_stop_vdec_vpss_vo(vdec_thread_param *vdec_send, + pthread_t *vdec_thread, ot_sample_svp_media_cfg *media_cfg, sample_vo_cfg *vo_cfg); +/* + * Send stream to venc/vo + */ +td_s32 sample_common_svp_venc_vo_send_stream(const ot_sample_svp_switch *vo_venc_switch, + ot_venc_chn venc_chn, ot_vo_layer vo_layer, ot_vo_chn vo_chn, const ot_video_frame_info *frame); + +td_s32 sample_common_svp_npu_start_vi_vpss_vo(sample_vi_cfg *vi_cfg, ot_sample_svp_media_cfg *media_cfg, + sample_vo_cfg *vo_cfg); + +td_void sample_common_svp_destroy_vb_stop_vi_vpss_vo(sample_vi_cfg *vi_cfg, ot_sample_svp_media_cfg *media_cfg, + sample_vo_cfg *vo_cfg); +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif /* __cplusplus */ +#endif /* SAMPLE_COMMON_SVP_H */ diff --git a/vendor/zsks/demo/fruit_identify/common/sample_common_svp_npu.c b/vendor/zsks/demo/fruit_identify/common/sample_common_svp_npu.c new file mode 100755 index 0000000000000000000000000000000000000000..64ae73c394907fe461c04bc7611bcce526affccf --- /dev/null +++ b/vendor/zsks/demo/fruit_identify/common/sample_common_svp_npu.c @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "sample_common_svp_npu.h" +#include "ot_common.h" +#include "ot_common_svp.h" +#include "sample_comm.h" +#include "sample_common_svp.h" + +/* acl init */ + td_s32 sample_common_svp_npu_acl_init(const td_char *acl_config_path, td_s32 dev_id) +{ + svp_acl_rt_run_mode run_mode; + svp_acl_error ret; + /* svp acl init */ + ret = svp_acl_init(acl_config_path); + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "acl init failed!\n"); + sample_svp_trace_info("svp acl init success!\n"); + /* open device */ + ret = svp_acl_rt_set_device(dev_id); + sample_svp_check_exps_goto(ret != SVP_ACL_SUCCESS, end_0, SAMPLE_SVP_ERR_LEVEL_ERROR, + "svp acl open device %d failed!\n", dev_id); + + sample_svp_trace_info("open device %d success!\n", dev_id); + /* get run mode */ + ret = svp_acl_rt_get_run_mode(&run_mode); + sample_svp_check_exps_goto(ret != SVP_ACL_SUCCESS, end_1, SAMPLE_SVP_ERR_LEVEL_ERROR, + "acl get run mode failed!\n"); + sample_svp_check_exps_goto(run_mode != SVP_ACL_DEVICE, end_1, SAMPLE_SVP_ERR_LEVEL_ERROR, + "run mode(%d) is not equal to %d!\n", run_mode, SVP_ACL_DEVICE); + + sample_svp_trace_info("get run mode success!\n"); + return TD_SUCCESS; +end_1: + (td_void)svp_acl_rt_reset_device(dev_id); +end_0: + (td_void)svp_acl_finalize(); + return TD_FAILURE; +} + +/* acl deinit */ +td_void sample_common_svp_npu_acl_deinit(td_s32 dev_id) +{ + svp_acl_error ret; + + ret = svp_acl_rt_reset_device(dev_id); + if (ret != SVP_ACL_SUCCESS) { + sample_svp_trace_err("reset device fail\n"); + } + sample_svp_trace_info("end to reset device is %d\n", dev_id); + + ret = svp_acl_finalize(); + if (ret != SVP_ACL_SUCCESS) { + sample_svp_trace_err("finalize acl fail\n"); + } + sample_svp_trace_info("end to finalize acl\n"); +} diff --git a/vendor/zsks/demo/fruit_identify/common/sample_common_svp_npu.h b/vendor/zsks/demo/fruit_identify/common/sample_common_svp_npu.h new file mode 100755 index 0000000000000000000000000000000000000000..79c1e54cf7bdc1f99e3b78d8719b1a8d79b97138 --- /dev/null +++ b/vendor/zsks/demo/fruit_identify/common/sample_common_svp_npu.h @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SAMPLE_COMMON_SVP_NPU_H +#define SAMPLE_COMMON_SVP_NPU_H +#include "ot_type.h" +#include "svp_acl.h" +#include "svp_acl_mdl.h" +#include "xvp_common_osd.h" + +#define SAMPLE_SVP_NPU_MAX_THREAD_NUM 16 +#define SAMPLE_SVP_NPU_MAX_TASK_NUM 16 +#define SAMPLE_SVP_NPU_MAX_MODEL_NUM 1 +#define SAMPLE_SVP_NPU_EXTRA_INPUT_NUM 2 +#define SAMPLE_SVP_NPU_BYTE_BIT_NUM 8 +#define SAMPLE_SVP_NPU_SHOW_TOP_NUM 5 +#define SAMPLE_SVP_NPU_MAX_NAME_LEN 32 +#define SAMPLE_SVP_NPU_MAX_MEM_SIZE 0xFFFFFFFF +#define SAMPLE_SVP_NPU_RECT_LEFT_TOP 0 +#define SAMPLE_SVP_NPU_RECT_RIGHT_TOP 1 +#define SAMPLE_SVP_NPU_RECT_RIGHT_BOTTOM 2 +#define SAMPLE_SVP_NPU_RECT_LEFT_BOTTOM 3 +#define SAMPLE_SVP_NPU_THRESHOLD_NUM 4 + +#define SAMPLE_SVP_NPU_RFCN_THRESHOLD_NUM 2 +#define SAMPLE_SVP_NPU_AICPU_WAIT_TIME 1000 +#define SAMPLE_SVP_NPU_RECT_COLOR 0x0000FF00 +#define SAMPLE_SVP_NPU_MILLIC_SEC 20000 +#define SAMPLE_SVP_NPU_IMG_THREE_CHN 3 +#define SAMPLE_SVP_NPU_DOUBLE 2 +#define SAMPLE_SVP_NPU_YOLO_CLASS_NUM 80 +#define SAMPLE_SVP_NPU_YOLO_CPU_OUT_NUM 3 +#define SAMPLE_SVP_NPU_YOLO_SCALE_SIZE 3 +#define SAMPLE_SVP_NPU_YOLO_OUT_PARM_NUM 85 +#define SAMPLE_SVP_NPU_YOLO_CLASS_MEMBER_NUM 6 +#define SAMPLE_SVP_NPU_YOLO_SCORE_THRESHOLE 0.5 + +typedef struct { + td_u32 model_id; + td_bool is_load_flag; + td_ulong model_mem_size; + td_void *model_mem_ptr; + svp_acl_mdl_desc *model_desc; + size_t input_num; + size_t output_num; + size_t dynamic_batch_idx; +} sample_svp_npu_model_info; + +typedef struct { + td_u32 max_batch_num; + td_u32 dynamic_batch_num; + td_u32 total_t; + td_bool is_cached; + td_u32 model_idx; +} sample_svp_npu_task_cfg; + +typedef struct { + sample_svp_npu_task_cfg cfg; + svp_acl_mdl_dataset *input_dataset; + svp_acl_mdl_dataset *output_dataset; + td_void *task_buf_ptr; + size_t task_buf_size; + size_t task_buf_stride; + td_void *work_buf_ptr; + size_t work_buf_size; + size_t work_buf_stride; +} sample_svp_npu_task_info; + +typedef struct { + td_void *work_buf_ptr; + size_t work_buf_size; + size_t work_buf_stride; +} sample_svp_npu_shared_work_buf; + +typedef struct { + td_float score; + td_u32 class_id; +} sample_svp_npu_top_n_result; + +typedef struct { + td_char *num_name; + td_char *roi_name; + td_bool has_background; + td_u32 roi_offset; + td_bool is_cpu_rpn; + td_u32 idx; +} sample_svp_npu_detection_info; + +typedef enum { + SAMPLE_SVP_NPU_RFCN = 0, + SAMPLE_SVP_NPU_YOLO = 1, + SAMPLE_SVP_NPU_HRNET = 2, + SAMPLE_SVP_NPU_MODEL_NAME_BUTT, +} svp_npu_model_name; + +typedef struct { + svp_npu_model_name model_name; + sample_svp_npu_detection_info *detection_info; + sample_mpp_osd_info mpp_osd_info; +} sample_svp_npu_thread_args; + +typedef struct { + td_char roi_num_name[SAMPLE_SVP_NPU_MAX_NAME_LEN]; + td_char roi_class_name[SAMPLE_SVP_NPU_MAX_NAME_LEN]; +} sample_svp_npu_roi_info; + +typedef struct { + td_float nms_threshold; + td_float score_threshold; + td_float min_height; + td_float min_width; + td_char *name; +} sample_svp_npu_threshold; + +typedef struct { + td_float score; + td_float xcenter; + td_float ycenter; + td_float w; + td_float h; + td_float class_id; +} sample_svp_npu_valid_box; + +typedef struct { + td_float lx; + td_float ly; + td_float rx; + td_float ry; + td_float score; + td_float class_id; + td_float area; +} sample_svp_npu_roi_box; + +typedef struct { + td_float *out_data; + size_t idx; + size_t w_stride_offset; + td_float score_thr; + td_u32 out_width; + td_u32 chn_step; + td_u32 out_height_idx; + td_u32 obj_score_offset; +} sample_svp_npu_detection_inner_param; + +/* acl init */ +td_s32 sample_common_svp_npu_acl_init(const td_char *acl_config_path, td_s32 dev_id); +/* acl deinit */ +td_void sample_common_svp_npu_acl_deinit(td_s32 dev_id); + +#endif diff --git a/vendor/zsks/demo/fruit_identify/common/sample_common_svp_npu_model.c b/vendor/zsks/demo/fruit_identify/common/sample_common_svp_npu_model.c new file mode 100755 index 0000000000000000000000000000000000000000..69810ed42427c37772e05602b63092caaee089b8 --- /dev/null +++ b/vendor/zsks/demo/fruit_identify/common/sample_common_svp_npu_model.c @@ -0,0 +1,1503 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * Copyright (c) 2025 Zhongshan Kuangshi Microelectronics Technology Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Modifications Author: yaohongtao (yht@cust.edu.cn) + */ +#include +#include +#include "svp_acl_rt.h" +#include "svp_acl_ext.h" +#include "sample_common_svp.h" +#include "sample_common_svp_npu_model.h" + +#define SAMPLE_SVP_NPU_H_DIM_IDX 2 +#define SAMPLE_SVP_NPU_W_DIM_IDX 3 +#define SAMPLE_SVP_NPU_DIM_NUM 4 +static sample_svp_npu_model_info g_svp_npu_model[SAMPLE_SVP_NPU_MAX_MODEL_NUM] = {0}; + +static td_s32 sample_svp_npu_get_model_base_info(td_u32 model_index) +{ + svp_acl_error ret; + + g_svp_npu_model[model_index].input_num = svp_acl_mdl_get_num_inputs(g_svp_npu_model[model_index].model_desc); + sample_svp_check_exps_return(g_svp_npu_model[model_index].input_num < SAMPLE_SVP_NPU_EXTRA_INPUT_NUM + 1, + TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "get input num failed!\n"); + + g_svp_npu_model[model_index].output_num = svp_acl_mdl_get_num_outputs(g_svp_npu_model[model_index].model_desc); + sample_svp_check_exps_return(g_svp_npu_model[model_index].output_num < 1, + TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "get output num failed!\n"); + + ret = svp_acl_mdl_get_input_index_by_name(g_svp_npu_model[model_index].model_desc, + SVP_ACL_DYNAMIC_TENSOR_NAME, &g_svp_npu_model[model_index].dynamic_batch_idx); + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get dynamic batch idx failed, model id is %u, error code is %d!\n", model_index, ret); + + return TD_SUCCESS; +} + +static td_s32 sample_svp_npu_get_line_num_and_line_byte_num(const sample_svp_npu_task_info *task, td_u32 idx, + td_bool is_input, td_u32 *total_line_num, td_u32 *line_byte_num) +{ + td_s32 ret; + td_u32 i; + svp_acl_mdl_io_dims dims; + svp_acl_data_type data_type; + size_t data_size; + + if (is_input == TD_TRUE) { + ret = svp_acl_mdl_get_input_dims(g_svp_npu_model[task->cfg.model_idx].model_desc, idx, &dims); + } else { + ret = svp_acl_mdl_get_output_dims(g_svp_npu_model[task->cfg.model_idx].model_desc, idx, &dims); + } + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th input/output dims failed!\n", idx); + + if (is_input == TD_TRUE) { + data_type = svp_acl_mdl_get_input_data_type(g_svp_npu_model[task->cfg.model_idx].model_desc, idx); + } else { + data_type = svp_acl_mdl_get_output_data_type(g_svp_npu_model[task->cfg.model_idx].model_desc, idx); + } + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th input/output data type failed!\n", idx); + + data_size = svp_acl_data_type_size(data_type); + sample_svp_check_exps_return(data_size == 0, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "get data size failed!\n"); + + *line_byte_num = dims.dims[dims.dim_count - 1] * + ((data_size + SAMPLE_SVP_NPU_BYTE_BIT_NUM - 1) / SAMPLE_SVP_NPU_BYTE_BIT_NUM); + + *total_line_num = 1; + for (i = 0; i < dims.dim_count - 1; i++) { + *total_line_num *= dims.dims[i]; + } + /* lstm xt line num */ + if ((task->cfg.total_t != 0) && (idx == 0)) { + sample_svp_check_exps_return(task->cfg.total_t > dims.dims[0], TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "total t(%u) can't be greater than max total t(%ld)!\n", task->cfg.total_t, dims.dims[0]); + *total_line_num /= dims.dims[0]; + *total_line_num *= task->cfg.total_t; + } + return TD_SUCCESS; +} + +static td_s32 sample_svp_check_task_cfg(const sample_svp_npu_task_info *task) +{ + sample_svp_check_exps_return(task == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "task is NULL!\n"); + + sample_svp_check_exps_return(task->cfg.max_batch_num == 0, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "max_batch_num(%u) is 0!\n", task->cfg.max_batch_num); + + sample_svp_check_exps_return(task->cfg.dynamic_batch_num == 0, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "dynamic_batch_num(%u) is 0!\n", task->cfg.dynamic_batch_num); + + sample_svp_check_exps_return(task->cfg.total_t != 0 && task->cfg.dynamic_batch_num != 1, TD_FAILURE, + SAMPLE_SVP_ERR_LEVEL_ERROR, "dynamic_batch_num(%u) should be 1 when total_t(%u) is not 0!\n", + task->cfg.dynamic_batch_num, task->cfg.total_t); + + sample_svp_check_exps_return((task->cfg.is_cached != TD_TRUE && task->cfg.is_cached != TD_FALSE), TD_FAILURE, + SAMPLE_SVP_ERR_LEVEL_ERROR, "is_cached(%u) should be [%u, %u]!\n", task->cfg.is_cached, TD_FALSE, TD_TRUE); + + sample_svp_check_exps_return(task->cfg.model_idx >= SAMPLE_SVP_NPU_MAX_MODEL_NUM, TD_FAILURE, + SAMPLE_SVP_ERR_LEVEL_ERROR, "model_idx(%u) should be less than %u!\n", + task->cfg.model_idx, SAMPLE_SVP_NPU_MAX_MODEL_NUM); + + sample_svp_check_exps_return(g_svp_npu_model[task->cfg.model_idx].model_desc == TD_NULL, TD_FAILURE, + SAMPLE_SVP_ERR_LEVEL_ERROR, "%u-th model_desc is NULL!\n", task->cfg.model_idx); + return TD_SUCCESS; +} + +td_s32 sample_common_svp_npu_get_input_data(const td_char *src[], td_u32 file_num, + const sample_svp_npu_task_info *task) +{ + td_s32 ret; + td_u32 i; + td_u32 line; + td_u32 total_line_num; + td_u32 line_byte_num; + td_char path[PATH_MAX] = { 0 }; + size_t stride; + size_t size; + size_t input_num; + FILE *fp = TD_NULL; + td_void *data = TD_NULL; + svp_acl_data_buffer *data_buffer = TD_NULL; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return TD_FAILURE; + } + sample_svp_check_exps_return(src == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "src is NULL!\n"); + + input_num = g_svp_npu_model[task->cfg.model_idx].input_num - SAMPLE_SVP_NPU_EXTRA_INPUT_NUM; + sample_svp_check_exps_return(input_num != file_num, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "input file num(%u) should be equal to %lu!\n", file_num, input_num); + + for (i = 0; i < file_num; i++) { + sample_svp_check_exps_return(realpath(src[i], path) == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Invalid file!\n"); + + fp = fopen(path, "rb"); + sample_svp_check_exps_return(fp == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "open file failed!\n"); + + ret = sample_svp_npu_get_line_num_and_line_byte_num(task, i, TD_TRUE, &total_line_num, &line_byte_num); + sample_svp_check_exps_goto(ret != TD_SUCCESS, end, SAMPLE_SVP_ERR_LEVEL_ERROR, "get line num failed!\n"); + + data_buffer = svp_acl_mdl_get_dataset_buffer(task->input_dataset, i); + sample_svp_check_exps_goto(data_buffer == TD_NULL, end, SAMPLE_SVP_ERR_LEVEL_ERROR, "get data buffer NULL!\n"); + + data = svp_acl_get_data_buffer_addr(data_buffer); + sample_svp_check_exps_goto(data == TD_NULL, end, SAMPLE_SVP_ERR_LEVEL_ERROR, "get data addr NULL!\n"); + + stride = svp_acl_get_data_buffer_stride(data_buffer); + sample_svp_check_exps_goto(stride == 0, end, SAMPLE_SVP_ERR_LEVEL_ERROR, "get data stride failed!\n"); + + size = svp_acl_get_data_buffer_size(data_buffer); + sample_svp_check_exps_goto(size < (td_u64)task->cfg.dynamic_batch_num * total_line_num * stride, end, + SAMPLE_SVP_ERR_LEVEL_ERROR, "%u-th data buffer size(%lu) is less than needed(%llu)!\n", + i, size, (td_u64)task->cfg.dynamic_batch_num * total_line_num * stride); + + for (line = 0; line < task->cfg.dynamic_batch_num * total_line_num; line++) { + ret = fread(data + line * stride, line_byte_num, 1, fp); + sample_svp_check_exps_goto(ret != 1, end, SAMPLE_SVP_ERR_LEVEL_ERROR, "Read file failed!\n"); + } + if (task->cfg.is_cached == TD_TRUE) { + (td_void)svp_acl_rt_mem_flush(data, task->cfg.dynamic_batch_num * total_line_num * stride); + } + (td_void)fclose(fp); + } + return TD_SUCCESS; + +end: + if (fp != TD_NULL) { + (td_void)fclose(fp); + } + return TD_FAILURE; +} + +static td_s32 sample_svp_npu_read_model(const td_char *model_path, td_u32 model_index, td_bool is_cached) +{ + FILE *fp = TD_NULL; + td_s32 ret; + + /* Get model file size */ + fp = fopen(model_path, "rb"); + sample_svp_check_exps_return(fp == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "open model file failed, model file is %s!\n", model_path); + + ret = fseek(fp, 0L, SEEK_END); + sample_svp_check_exps_goto(ret == -1, end_0, SAMPLE_SVP_ERR_LEVEL_ERROR, "fseek failed!\n"); + + g_svp_npu_model[model_index].model_mem_size = ftell(fp); + sample_svp_check_exps_goto(g_svp_npu_model[model_index].model_mem_size <= 0, end_0, + SAMPLE_SVP_ERR_LEVEL_ERROR, "ftell failed!\n"); + + ret = fseek(fp, 0L, SEEK_SET); + sample_svp_check_exps_goto(ret == -1, end_0, SAMPLE_SVP_ERR_LEVEL_ERROR, "fseek failed!\n"); + + /* malloc model file mem */ + if (is_cached == TD_TRUE) { + ret = svp_acl_rt_malloc_cached(&g_svp_npu_model[model_index].model_mem_ptr, + g_svp_npu_model[model_index].model_mem_size, SVP_ACL_MEM_MALLOC_NORMAL_ONLY); + } else { + ret = svp_acl_rt_malloc(&g_svp_npu_model[model_index].model_mem_ptr, + g_svp_npu_model[model_index].model_mem_size, SVP_ACL_MEM_MALLOC_NORMAL_ONLY); + } + sample_svp_check_exps_goto(ret != SVP_ACL_SUCCESS, end_0, SAMPLE_SVP_ERR_LEVEL_ERROR, + "malloc mem failed, erroe code %d!\n", ret); + + ret = fread(g_svp_npu_model[model_index].model_mem_ptr, g_svp_npu_model[model_index].model_mem_size, 1, fp); + sample_svp_check_exps_goto(ret != 1, end_1, SAMPLE_SVP_ERR_LEVEL_ERROR, "read model file failed!\n"); + + if (is_cached == TD_TRUE) { + ret = svp_acl_rt_mem_flush(g_svp_npu_model[model_index].model_mem_ptr, + g_svp_npu_model[model_index].model_mem_size); + sample_svp_check_exps_goto(ret != SVP_ACL_SUCCESS, end_1, SAMPLE_SVP_ERR_LEVEL_ERROR, + "flush mem failed!, error code is %d\n", ret); + } + (td_void)fclose(fp); + return TD_SUCCESS; +end_1: + (td_void)svp_acl_rt_free(g_svp_npu_model[model_index].model_mem_ptr); +end_0: + (td_void)fclose(fp); + return TD_FAILURE; +} + +static td_s32 sample_svp_npu_create_desc(td_u32 model_index) +{ + svp_acl_error ret; + + g_svp_npu_model[model_index].model_desc = svp_acl_mdl_create_desc(); + sample_svp_check_exps_return(g_svp_npu_model[model_index].model_desc == TD_NULL, TD_FAILURE, + SAMPLE_SVP_ERR_LEVEL_ERROR, "create model description failed!\n"); + + ret = svp_acl_mdl_get_desc(g_svp_npu_model[model_index].model_desc, g_svp_npu_model[model_index].model_id); + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, + SAMPLE_SVP_ERR_LEVEL_ERROR, "get model description failed, error code is %d!\n", ret); + + sample_svp_trace_info("create model description success!\n"); + + return TD_SUCCESS; +} + +td_s32 sample_common_svp_npu_load_model(const td_char *model_path, td_u32 model_index, td_bool is_cached) +{ + td_s32 ret; + + sample_svp_check_exps_return(g_svp_npu_model[model_index].is_load_flag == TD_TRUE, TD_FAILURE, + SAMPLE_SVP_ERR_LEVEL_ERROR, "%u-th node has already loaded a model!\n", model_index); + + ret = sample_svp_npu_read_model(model_path, model_index, is_cached); + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, + SAMPLE_SVP_ERR_LEVEL_ERROR, "query model failed, model file is %s!\n", model_path); + + ret = svp_acl_mdl_load_from_mem(g_svp_npu_model[model_index].model_mem_ptr, + g_svp_npu_model[model_index].model_mem_size, &g_svp_npu_model[model_index].model_id); + sample_svp_check_exps_goto(ret != SVP_ACL_SUCCESS, end_0, + SAMPLE_SVP_ERR_LEVEL_ERROR, "load model from mem failed, error code is %d!\n", ret); + + ret = sample_svp_npu_create_desc(model_index); + sample_svp_check_exps_goto(ret != SVP_ACL_SUCCESS, end_0, + SAMPLE_SVP_ERR_LEVEL_ERROR, "create desc failed, model file is %s!\n", model_path); + + ret = sample_svp_npu_get_model_base_info(model_index); + sample_svp_check_exps_goto(ret != SVP_ACL_SUCCESS, end_1, + SAMPLE_SVP_ERR_LEVEL_ERROR, "get model base info failed, model file is %s!\n", model_path); + + sample_svp_trace_info("load mem_size:%lu, id:%d!\n", g_svp_npu_model[model_index].model_mem_size, + g_svp_npu_model[model_index].model_id); + + g_svp_npu_model[model_index].is_load_flag = TD_TRUE; + sample_svp_trace_info("load model %s success!\n", model_path); + + return TD_SUCCESS; +end_1: + (td_void)svp_acl_mdl_destroy_desc(g_svp_npu_model[model_index].model_desc); + g_svp_npu_model[model_index].model_desc = TD_NULL; +end_0: + (td_void)svp_acl_rt_free(g_svp_npu_model[model_index].model_mem_ptr); + g_svp_npu_model[model_index].model_mem_ptr = TD_NULL; + g_svp_npu_model[model_index].model_mem_size = 0; + return TD_FAILURE; +} + +td_void sample_common_svp_npu_unload_model(td_u32 model_index) +{ + svp_acl_error ret; + + sample_svp_check_exps_return_void(g_svp_npu_model[model_index].is_load_flag != TD_TRUE, + SAMPLE_SVP_ERR_LEVEL_ERROR, "%u-th node has not loaded a model!\n", model_index); + + ret = svp_acl_mdl_unload(g_svp_npu_model[model_index].model_id); + if (ret != SVP_ACL_SUCCESS) { + sample_svp_trace_err("unload model failed, model_id is %u, error code is %d!\n", + g_svp_npu_model[model_index].model_id, ret); + } + + if (g_svp_npu_model[model_index].model_desc != TD_NULL) { + (td_void)svp_acl_mdl_destroy_desc(g_svp_npu_model[model_index].model_desc); + g_svp_npu_model[model_index].model_desc = TD_NULL; + } + + if (g_svp_npu_model[model_index].model_mem_ptr != TD_NULL) { + (td_void)svp_acl_rt_free(g_svp_npu_model[model_index].model_mem_ptr); + g_svp_npu_model[model_index].model_mem_ptr = TD_NULL; + g_svp_npu_model[model_index].model_mem_size = 0; + } + + g_svp_npu_model[model_index].is_load_flag = TD_FALSE; + sample_svp_trace_info("unload model SUCCESS, model id is %u!\n", g_svp_npu_model[model_index].model_id); +} + +static td_s32 sample_svp_npu_malloc_mem(td_void **buffer, td_u32 buffer_size, td_bool is_cached) +{ + svp_acl_error ret; + + if (is_cached == TD_TRUE) { + ret = svp_acl_rt_malloc_cached(buffer, buffer_size, SVP_ACL_MEM_MALLOC_NORMAL_ONLY); + } else { + ret = svp_acl_rt_malloc(buffer, buffer_size, SVP_ACL_MEM_MALLOC_NORMAL_ONLY); + } + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "can't malloc buffer, size is %u, error code is %d!\n", buffer_size, ret); + + (td_void)memset_s(*buffer, buffer_size, 0, buffer_size); + if (is_cached == TD_TRUE) { + (td_void)svp_acl_rt_mem_flush(*buffer, buffer_size); + } + return ret; +} + +static td_void sample_svp_npu_destroy_data_buffer(svp_acl_data_buffer *input_data) +{ + td_void *data = svp_acl_get_data_buffer_addr(input_data); + (td_void)svp_acl_rt_free(data); + (td_void)svp_acl_destroy_data_buffer(input_data); +} + +static svp_acl_data_buffer *sample_common_svp_npu_create_input_data_buffer(sample_svp_npu_task_info *task, td_u32 idx) +{ + size_t buffer_size; + size_t stride; + td_void *input_buffer = TD_NULL; + svp_acl_data_buffer *input_data = TD_NULL; + + stride = svp_acl_mdl_get_input_default_stride(g_svp_npu_model[task->cfg.model_idx].model_desc, idx); + sample_svp_check_exps_return(stride == 0, input_data, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th input stride failed!\n", idx); + + buffer_size = svp_acl_mdl_get_input_size_by_index(g_svp_npu_model[task->cfg.model_idx].model_desc, idx) * + (td_u64)task->cfg.max_batch_num; + sample_svp_check_exps_return((buffer_size == 0 || buffer_size > SAMPLE_SVP_NPU_MAX_MEM_SIZE), input_data, + SAMPLE_SVP_ERR_LEVEL_ERROR, "buffer_size(%lu) can't be 0 and should be less than %u!\n", + buffer_size, SAMPLE_SVP_NPU_MAX_MEM_SIZE); + + if (sample_svp_npu_malloc_mem(&input_buffer, (td_u32)buffer_size, task->cfg.is_cached) != TD_SUCCESS) { + sample_svp_trace_err("%u-th input malloc mem failed!\n", idx); + return input_data; + } + + input_data = svp_acl_create_data_buffer(input_buffer, buffer_size, stride); + if (input_data == TD_NULL) { + sample_svp_trace_err("can't create %u-th input data buffer!\n", idx); + (td_void)svp_acl_rt_free(input_buffer); + return input_data; + } + if (idx == g_svp_npu_model[task->cfg.model_idx].input_num - SAMPLE_SVP_NPU_EXTRA_INPUT_NUM) { + task->task_buf_ptr = input_buffer; + task->task_buf_size = buffer_size; + task->task_buf_stride = stride; + } else if (idx == g_svp_npu_model[task->cfg.model_idx].input_num - 1) { + task->work_buf_ptr = input_buffer; + task->work_buf_size = buffer_size; + task->work_buf_stride = stride; + } + return input_data; +} + +static svp_acl_data_buffer *sample_common_svp_npu_create_output_data_buffer(const sample_svp_npu_task_info *task, + td_u32 idx) +{ + size_t buffer_size; + size_t stride; + td_void *output_buffer = TD_NULL; + svp_acl_data_buffer *output_data = TD_NULL; + + stride = svp_acl_mdl_get_output_default_stride(g_svp_npu_model[task->cfg.model_idx].model_desc, idx); + sample_svp_check_exps_return(stride == 0, output_data, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th output stride failed!\n", idx); + + buffer_size = svp_acl_mdl_get_output_size_by_index(g_svp_npu_model[task->cfg.model_idx].model_desc, idx) * + (td_u64)task->cfg.max_batch_num; + sample_svp_check_exps_return((buffer_size == 0 || buffer_size > SAMPLE_SVP_NPU_MAX_MEM_SIZE), output_data, + SAMPLE_SVP_ERR_LEVEL_ERROR, "buffer_size(%lu) can't be 0 and should be less than %u!\n", + buffer_size, SAMPLE_SVP_NPU_MAX_MEM_SIZE); + + if (sample_svp_npu_malloc_mem(&output_buffer, buffer_size, task->cfg.is_cached) != TD_SUCCESS) { + sample_svp_trace_err("%u-th output malloc mem failed!\n", idx); + return output_data; + } + + output_data = svp_acl_create_data_buffer(output_buffer, buffer_size, stride); + if (output_data == TD_NULL) { + sample_svp_trace_err("can't create %u-th output data buffer!\n", idx); + (td_void)svp_acl_rt_free(output_buffer); + return output_data; + } + return output_data; +} + +td_s32 sample_common_svp_npu_create_input(sample_svp_npu_task_info *task) +{ + svp_acl_error ret; + td_u32 i; + svp_acl_data_buffer *input_data = TD_NULL; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return TD_FAILURE; + } + + task->input_dataset = svp_acl_mdl_create_dataset(); + sample_svp_check_exps_return(task->input_dataset == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "create input dataset failed!\n"); + + for (i = 0; i < g_svp_npu_model[task->cfg.model_idx].input_num - SAMPLE_SVP_NPU_EXTRA_INPUT_NUM; i++) { + input_data = sample_common_svp_npu_create_input_data_buffer(task, i); + if (input_data == TD_NULL) { + sample_svp_trace_err("create %u-th input data buffer failed!\n", i); + (td_void)sample_common_svp_npu_destroy_input(task); + return TD_FAILURE; + } + + ret = svp_acl_mdl_add_dataset_buffer(task->input_dataset, input_data); + if (ret != SVP_ACL_SUCCESS) { + sample_svp_trace_err("add %u-th input data buffer failed!\n", i); + (td_void)sample_svp_npu_destroy_data_buffer(input_data); + (td_void)sample_common_svp_npu_destroy_input(task); + return TD_FAILURE; + } + } + return TD_SUCCESS; +} + +td_s32 sample_common_svp_npu_create_output(sample_svp_npu_task_info *task) +{ + svp_acl_error ret; + td_u32 i; + svp_acl_data_buffer *output_data = TD_NULL; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return TD_FAILURE; + } + + task->output_dataset = svp_acl_mdl_create_dataset(); + sample_svp_check_exps_return(task->input_dataset == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "create output dataset failed!\n"); + + for (i = 0; i < g_svp_npu_model[task->cfg.model_idx].output_num; i++) { + output_data = sample_common_svp_npu_create_output_data_buffer(task, i); + if (output_data == TD_NULL) { + sample_svp_trace_err("create %u-th output data buffer failed!\n", i); + (td_void)sample_common_svp_npu_destroy_input(task); + return TD_FAILURE; + } + ret = svp_acl_mdl_add_dataset_buffer(task->output_dataset, output_data); + if (ret != SVP_ACL_SUCCESS) { + sample_svp_trace_err("add %u-th output data buffer failed!\n", i); + (td_void)sample_svp_npu_destroy_data_buffer(output_data); + (td_void)sample_common_svp_npu_destroy_output(task); + return TD_FAILURE; + } + } + + return TD_SUCCESS; +} + +td_void sample_common_svp_npu_destroy_input(sample_svp_npu_task_info *task) +{ + td_u32 i; + size_t input_num; + svp_acl_data_buffer *data_buffer = TD_NULL; + td_void *data = TD_NULL; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return; + } + + if (task->input_dataset == TD_NULL) { + return; + } + + input_num = svp_acl_mdl_get_dataset_num_buffers(task->input_dataset); + for (i = 0; i < input_num; i++) { + data_buffer = svp_acl_mdl_get_dataset_buffer(task->input_dataset, i); + if (i < g_svp_npu_model[task->cfg.model_idx].input_num - SAMPLE_SVP_NPU_EXTRA_INPUT_NUM) { + data = svp_acl_get_data_buffer_addr(data_buffer); + (td_void)svp_acl_rt_free(data); + } + (td_void)svp_acl_destroy_data_buffer(data_buffer); + } + (td_void)svp_acl_mdl_destroy_dataset(task->input_dataset); + task->input_dataset = TD_NULL; +} + +td_void sample_common_svp_npu_destroy_output(sample_svp_npu_task_info *task) +{ + td_u32 i; + size_t output_num; + svp_acl_data_buffer *data_buffer = TD_NULL; + td_void *data = TD_NULL; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return; + } + + if (task->output_dataset == TD_NULL) { + return; + } + + output_num = svp_acl_mdl_get_dataset_num_buffers(task->output_dataset); + + for (i = 0; i < output_num; i++) { + data_buffer = svp_acl_mdl_get_dataset_buffer(task->output_dataset, i); + data = svp_acl_get_data_buffer_addr(data_buffer); + (td_void)svp_acl_rt_free(data); + (td_void)svp_acl_destroy_data_buffer(data_buffer); + } + + (td_void)svp_acl_mdl_destroy_dataset(task->output_dataset); + task->output_dataset = TD_NULL; +} + +td_void sample_common_svp_npu_destroy_task_buf(sample_svp_npu_task_info *task) +{ + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return; + } + + if (task->task_buf_ptr == TD_NULL) { + return; + } + (td_void)svp_acl_rt_free(task->task_buf_ptr); + task->task_buf_ptr = TD_NULL; + task->task_buf_stride = 0; + task->task_buf_size = 0; +} + +td_void sample_common_svp_npu_destroy_work_buf(sample_svp_npu_task_info *task) +{ + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return; + } + + if (task->work_buf_ptr == TD_NULL) { + return; + } + (td_void)svp_acl_rt_free(task->work_buf_ptr); + task->work_buf_ptr = TD_NULL; + task->work_buf_stride = 0; + task->work_buf_size = 0; +} + +td_s32 sample_common_svp_npu_create_task_buf(sample_svp_npu_task_info *task) +{ + size_t num; + svp_acl_data_buffer *task_buf = TD_NULL; + svp_acl_error ret; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return TD_FAILURE; + } + sample_svp_check_exps_return(task->input_dataset == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "input_dataset is NULL!\n"); + + num = svp_acl_mdl_get_dataset_num_buffers(task->input_dataset); + sample_svp_check_exps_return(num != g_svp_npu_model[task->cfg.model_idx].input_num - SAMPLE_SVP_NPU_EXTRA_INPUT_NUM, + TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "num of data buffer(%lu) should be %lu when create task buf!\n", + num, g_svp_npu_model[task->cfg.model_idx].input_num - SAMPLE_SVP_NPU_EXTRA_INPUT_NUM); + + task_buf = sample_common_svp_npu_create_input_data_buffer(task, + g_svp_npu_model[task->cfg.model_idx].input_num - SAMPLE_SVP_NPU_EXTRA_INPUT_NUM); + sample_svp_check_exps_return(task_buf == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "create task buf failed!\n"); + + ret = svp_acl_mdl_add_dataset_buffer(task->input_dataset, task_buf); + if (ret != SVP_ACL_SUCCESS) { + sample_svp_trace_err("add task buf failed!\n"); + (td_void)sample_svp_npu_destroy_data_buffer(task_buf); + return TD_FAILURE; + } + return TD_SUCCESS; +} + +td_s32 sample_common_svp_npu_create_work_buf(sample_svp_npu_task_info *task) +{ + size_t num; + svp_acl_data_buffer *work_buf = TD_NULL; + svp_acl_error ret; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return TD_FAILURE; + } + + sample_svp_check_exps_return(task->input_dataset == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "input_dataset is NULL!\n"); + + num = svp_acl_mdl_get_dataset_num_buffers(task->input_dataset); + sample_svp_check_exps_return(num != g_svp_npu_model[task->cfg.model_idx].input_num - 1, + TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "num of data buffer(%lu) should be %lu when create work buf!\n", + num, g_svp_npu_model[task->cfg.model_idx].input_num - 1); + + work_buf = sample_common_svp_npu_create_input_data_buffer(task, g_svp_npu_model[task->cfg.model_idx].input_num - 1); + sample_svp_check_exps_return(work_buf == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "create work buf failed!\n"); + + ret = svp_acl_mdl_add_dataset_buffer(task->input_dataset, work_buf); + if (ret != SVP_ACL_SUCCESS) { + sample_svp_trace_err("add work buf failed!\n"); + (td_void)sample_svp_npu_destroy_data_buffer(work_buf); + return TD_FAILURE; + } + return TD_SUCCESS; +} + +td_s32 sample_common_svp_npu_get_work_buf_info(const sample_svp_npu_task_info *task, + td_u32 *work_buf_size, td_u32 *work_buf_stride) +{ + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return TD_FAILURE; + } + + *work_buf_stride = (td_u32)svp_acl_mdl_get_input_default_stride(g_svp_npu_model[task->cfg.model_idx].model_desc, + g_svp_npu_model[task->cfg.model_idx].input_num - 1); + if (*work_buf_stride == 0) { + sample_svp_trace_err("get work buf stride failed!\n"); + return TD_FAILURE; + } + + *work_buf_size = (td_u32)svp_acl_mdl_get_input_size_by_index(g_svp_npu_model[task->cfg.model_idx].model_desc, + g_svp_npu_model[task->cfg.model_idx].input_num - 1); + if (*work_buf_size == 0) { + sample_svp_trace_err("get work buf size failed!\n"); + return TD_FAILURE; + } + return TD_SUCCESS; +} + +td_s32 sample_common_svp_npu_share_work_buf(const sample_svp_npu_shared_work_buf *shared_work_buf, + const sample_svp_npu_task_info *task) +{ + svp_acl_error ret; + svp_acl_data_buffer *work_buf = TD_NULL; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return TD_FAILURE; + } + + sample_svp_check_exps_return(shared_work_buf == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "shared_work_buf is NULL!\n"); + + sample_svp_check_exps_return(shared_work_buf->work_buf_ptr == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "work_buf_ptr is NULL!\n"); + + sample_svp_check_exps_return(task->work_buf_ptr != TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "task has created work buf!\n"); + + work_buf = svp_acl_create_data_buffer(shared_work_buf->work_buf_ptr, shared_work_buf->work_buf_size, + shared_work_buf->work_buf_stride); + sample_svp_check_exps_return(work_buf == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "create work buf failed!\n"); + + ret = svp_acl_mdl_add_dataset_buffer(task->input_dataset, work_buf); + if (ret != SVP_ACL_SUCCESS) { + sample_svp_trace_err("add work buf failed!\n"); + (td_void)svp_acl_destroy_data_buffer(work_buf); + return TD_FAILURE; + } + + return TD_SUCCESS; +} + +/* print the top n confidence values with indexes */ +static td_void sample_svp_npu_sort_output_result(const td_float *src, td_u32 src_len, + sample_svp_npu_top_n_result *dst, td_u32 dst_len) +{ + td_u32 i; + td_u32 j; + td_u32 index; + td_bool charge; + + for (i = 0; i < src_len; i++) { + charge = TD_FALSE; + + for (j = 0; j < dst_len; j++) { + if (src[i] > dst[j].score) { + index = j; + charge = TD_TRUE; + break; + } + } + + if (charge == TD_TRUE) { + for (j = dst_len - 1; j > index; j--) { + dst[j].score = dst[j - 1].score; + dst[j].class_id = dst[j - 1].class_id; + } + dst[index].score = src[i]; + dst[index].class_id = i; + } + } +} + +td_void sample_common_svp_npu_output_classification_result(const sample_svp_npu_task_info *task) +{ + svp_acl_data_buffer *data_buffer = TD_NULL; + td_void *data = TD_NULL; + td_u32 i; + td_u32 j; + td_u32 n; + svp_acl_error ret; + size_t stride; + svp_acl_mdl_io_dims dims; + sample_svp_npu_top_n_result top[SAMPLE_SVP_NPU_SHOW_TOP_NUM] = { 0 }; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return; + } + + sample_svp_check_exps_return_void(task->output_dataset == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, + "task->output_dataset is NULL!\n"); + + for (i = 0; i < svp_acl_mdl_get_dataset_num_buffers(task->output_dataset); i++) { + data_buffer = svp_acl_mdl_get_dataset_buffer(task->output_dataset, i); + sample_svp_check_exps_return_void(data_buffer == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th data buffer is NULL!\n", i); + + data = svp_acl_get_data_buffer_addr(data_buffer); + sample_svp_check_exps_return_void(data == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th data addr is NULL!\n", i); + + stride = svp_acl_get_data_buffer_stride(data_buffer); + sample_svp_check_exps_return_void(data == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th data stride is 0!\n", i); + + ret = svp_acl_mdl_get_output_dims(g_svp_npu_model[task->cfg.model_idx].model_desc, i, &dims); + sample_svp_check_exps_return_void(data == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th output dims failed, error code is %d!\n", i, ret); + + for (n = 0; n < task->cfg.dynamic_batch_num; n++) { + (td_void)sample_svp_npu_sort_output_result(data, (td_u32)dims.dims[dims.dim_count - 1], + top, SAMPLE_SVP_NPU_SHOW_TOP_NUM); + sample_svp_trace_info("%u-th batch result:\n", n); + for (j = 0; j < SAMPLE_SVP_NPU_SHOW_TOP_NUM; j++) { + sample_svp_trace_info("top %d: value[%lf], class_id[%u]!\n", j, top[j].score, top[j].class_id); + } + data += stride; + (td_void)memset_s(top, sizeof(top), 0, sizeof(top)); + } + } + + sample_svp_trace_info("output data success!\n"); +} + +td_s32 sample_common_svp_npu_set_dynamic_batch(const sample_svp_npu_task_info *task) +{ + svp_acl_error ret; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return TD_FAILURE; + } + ret = svp_acl_mdl_set_dynamic_batch_size(g_svp_npu_model[task->cfg.model_idx].model_id, + task->input_dataset, g_svp_npu_model[task->cfg.model_idx].dynamic_batch_idx, task->cfg.dynamic_batch_num); + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "set dynamic batch size failed, model id is %u, error code is %d!\n", + g_svp_npu_model[task->cfg.model_idx].model_id, ret); + + if (task->cfg.total_t != 0) { + ret = svp_acl_mdl_set_total_t(g_svp_npu_model[task->cfg.model_idx].model_id, + task->input_dataset, task->cfg.total_t); + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "set total_t failed, model id is %u, error code is %d!\n", + g_svp_npu_model[task->cfg.model_idx].model_id, ret); + } + + return TD_SUCCESS; +} + +td_s32 sample_common_svp_npu_model_execute(const sample_svp_npu_task_info *task) +{ + svp_acl_data_buffer *data_buffer = TD_NULL; + td_void *data = TD_NULL; + size_t size; + td_u32 i; + svp_acl_error ret; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return TD_FAILURE; + } + + ret = svp_acl_mdl_execute(g_svp_npu_model[task->cfg.model_idx].model_id, task->input_dataset, task->output_dataset); + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "svp_acl_mdl_execute failed, model_id is %u, error code is %d!\n", + g_svp_npu_model[task->cfg.model_idx].model_id, ret); + + if (task->cfg.is_cached == TD_TRUE) { + for (i = 0; i < g_svp_npu_model[task->cfg.model_idx].output_num; i++) { + data_buffer = svp_acl_mdl_get_dataset_buffer(task->output_dataset, i); + sample_svp_check_exps_return(data_buffer == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th output data_buffer is NULL!\n", i); + + data = svp_acl_get_data_buffer_addr(data_buffer); + sample_svp_check_exps_return(data == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th output data is NULL!\n", i); + + size = svp_acl_get_data_buffer_size(data_buffer) / task->cfg.max_batch_num * task->cfg.dynamic_batch_num; + sample_svp_check_exps_return(size == 0, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th output data size is 0!\n", i); + + ret = svp_acl_rt_mem_flush(data, size); + sample_svp_check_exps_return(data_buffer == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "flush %u-th output data failed, error code is %d!\n", i, ret); + } + } + return ret; +} + +static td_void sample_svp_npu_dump_dataset(const sample_svp_npu_task_info *task, const td_char *file_name, + td_bool is_input) +{ + td_u32 i; + td_u32 line; + td_u32 total_line_num; + td_u32 line_byte_num; + td_u32 data_num; + svp_acl_error ret; + size_t size; + size_t stride; + svp_acl_data_buffer *data_buffer = TD_NULL; + svp_acl_mdl_dataset *dataset = TD_NULL; + td_void *data = TD_NULL; + FILE *fp = TD_NULL; + td_char name[SAMPLE_SVP_NPU_MAX_NAME_LEN] = {'\0'}; + + data_num = is_input == TD_TRUE ? g_svp_npu_model[task->cfg.model_idx].input_num - SAMPLE_SVP_NPU_EXTRA_INPUT_NUM : + g_svp_npu_model[task->cfg.model_idx].output_num; + dataset = is_input == TD_TRUE ? task->input_dataset : task->output_dataset; + + for (i = 0; i < data_num; i++) { + ret = sample_svp_npu_get_line_num_and_line_byte_num(task, i, is_input, &total_line_num, &line_byte_num); + sample_svp_check_exps_return_void(ret != TD_SUCCESS, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get line num and line byte num failed!\n"); + + data_buffer = svp_acl_mdl_get_dataset_buffer(dataset, i); + sample_svp_check_exps_return_void(data_buffer == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th data_buffer failed!\n", i); + + data = svp_acl_get_data_buffer_addr(data_buffer); + sample_svp_check_exps_return_void(data == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th data addr failed!\n", i); + + stride = svp_acl_get_data_buffer_stride(data_buffer); + sample_svp_check_exps_return_void(stride == 0, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th data stride failed!\n", i); + + size = svp_acl_get_data_buffer_size(data_buffer); + sample_svp_check_exps_return_void(size == 0, SAMPLE_SVP_ERR_LEVEL_ERROR, "get %u-th data size failed!\n", i); + + sample_svp_check_exps_return_void(size < (td_u64)task->cfg.dynamic_batch_num * total_line_num * stride, + SAMPLE_SVP_ERR_LEVEL_ERROR, "%u-th data buffer size(%lu) is less than needed(%llu)!\n", + i, size, (td_u64)task->cfg.dynamic_batch_num * total_line_num * stride); + + ret = snprintf_s(name, SAMPLE_SVP_NPU_MAX_NAME_LEN - 1, SAMPLE_SVP_NPU_MAX_NAME_LEN - 1, file_name, i); + sample_svp_check_exps_return_void(ret < 0, SAMPLE_SVP_ERR_LEVEL_ERROR, "create file name failed!\n"); + + fp = fopen(name, "wb"); + sample_svp_check_exps_return_void(fp == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, "open file failed!\n"); + + for (line = 0; line < task->cfg.dynamic_batch_num * total_line_num; line++) { + ret = fwrite(data, line_byte_num, 1, fp); + if (ret != 1) { + fclose(fp); + sample_svp_check_exps_return_void(ret != 1, SAMPLE_SVP_ERR_LEVEL_ERROR, "write file failed!\n"); + } + data += stride; + } + (td_void)fclose(fp); + } +} + +td_void sample_common_svp_npu_dump_task_data(const sample_svp_npu_task_info *task) +{ + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return; + } + + sample_svp_check_exps_return_void(task->input_dataset == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, + "task->input_dataset is NULL!\n"); + sample_svp_check_exps_return_void(task->output_dataset == TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, + "task->input_dataset is NULL!\n"); + + (td_void)sample_svp_npu_dump_dataset(task, "input_%u.bin", TD_TRUE); + (td_void)sample_svp_npu_dump_dataset(task, "output_%u.bin", TD_FALSE); +} + +td_s32 sample_common_svp_npu_update_input_data_buffer_info(td_u8 *virt_addr, td_u32 size, td_u32 stride, td_u32 idx, + const sample_svp_npu_task_info *task) +{ + svp_acl_data_buffer *data_buffer = TD_NULL; + svp_acl_error ret; + + data_buffer = svp_acl_mdl_get_dataset_buffer(task->input_dataset, idx); + sample_svp_check_exps_return(data_buffer == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th data_buffer failed!\n", idx); + ret = svp_acl_update_data_buffer(data_buffer, (td_void *)virt_addr, size, stride); + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "update data buffer failed!\n"); + return TD_SUCCESS; +} + +td_s32 sample_common_svp_npu_get_input_data_buffer_info(const sample_svp_npu_task_info *task, td_u32 idx, + td_u8 **virt_addr, td_u32 *size, td_u32 *stride) +{ + svp_acl_data_buffer *data_buffer = TD_NULL; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return TD_FAILURE; + } + sample_svp_check_exps_return(virt_addr == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "virt_addr is NULL!\n"); + sample_svp_check_exps_return(size == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "size is NULL!\n"); + sample_svp_check_exps_return(stride == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "size is NULL!\n"); + + data_buffer = svp_acl_mdl_get_dataset_buffer(task->input_dataset, idx); + sample_svp_check_exps_return(data_buffer == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get 0-th data_buffer failed!\n"); + *size = (td_u32)svp_acl_get_data_buffer_size(data_buffer); + *stride = (td_u32)svp_acl_get_data_buffer_stride(data_buffer); + *virt_addr = (td_u8 *)svp_acl_get_data_buffer_addr(data_buffer); + return TD_SUCCESS; +} + +static td_s32 sample_svp_npu_get_roi_num(const sample_svp_npu_task_info *task, sample_svp_npu_detection_info *info, + ot_sample_svp_rect_info *rect_info) +{ + svp_acl_error ret; + size_t num_idx; + svp_acl_mdl_io_dims dims; + svp_acl_data_buffer *data_buffer = TD_NULL; + td_float *data = TD_NULL; + td_float total_num = 0.0; + td_u32 start = 0; + td_u32 i; + + ret = svp_acl_mdl_get_output_index_by_name(g_svp_npu_model[task->cfg.model_idx].model_desc, + info->num_name, &num_idx); + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get num idx failed!\n"); + + ret = svp_acl_mdl_get_output_dims(g_svp_npu_model[task->cfg.model_idx].model_desc, num_idx, &dims); + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get num dims failed!\n"); + + data_buffer = svp_acl_mdl_get_dataset_buffer(task->output_dataset, num_idx); + sample_svp_check_exps_return(data_buffer == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get num data_buffer is NULL!\n"); + + data = (td_float *)svp_acl_get_data_buffer_addr(data_buffer); + sample_svp_check_exps_return(data == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "get num data is NULL!\n"); + + if (info->has_background == TD_TRUE) { + info->roi_offset = (td_u32)(*data); + start++; + } + + for (i = start; i < dims.dims[dims.dim_count - 1]; i++) { + total_num += *(data + i); + } + rect_info->num = (td_u32)total_num; + return TD_SUCCESS; +} + +static td_s32 sample_svp_npu_get_roi(const sample_svp_npu_task_info *task, const sample_svp_npu_detection_info *info, + const ot_video_frame_info *proc_frame, const ot_video_frame_info *show_frame, ot_sample_svp_rect_info *rect_info) +{ + svp_acl_error ret; + size_t roi_idx; + size_t stride; + svp_acl_data_buffer *data_buffer = TD_NULL; + td_float *x_min = TD_NULL; + td_float *y_min = TD_NULL; + td_float *x_max = TD_NULL; + td_float *y_max = TD_NULL; + td_float *score = TD_NULL; + td_float *class_id = TD_NULL; + td_u32 roi_offset = info->roi_offset; + td_u32 i; + + ret = svp_acl_mdl_get_output_index_by_name(g_svp_npu_model[task->cfg.model_idx].model_desc, + info->roi_name, &roi_idx); + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get roi idx failed!\n"); + + data_buffer = svp_acl_mdl_get_dataset_buffer(task->output_dataset, roi_idx); + sample_svp_check_exps_return(data_buffer == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get roi data_buffer is NULL!\n"); + + stride = svp_acl_get_data_buffer_stride(data_buffer); + sample_svp_check_exps_return(stride == 0, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "get roi stride is 0!\n"); + + x_min = (td_float *)svp_acl_get_data_buffer_addr(data_buffer); + sample_svp_check_exps_return(x_min == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "get roi data is NULL!\n"); + y_min = x_min + stride / sizeof(td_float); + x_max = y_min + stride / sizeof(td_float); + y_max = x_max + stride / sizeof(td_float); + score = y_max + stride / sizeof(td_float); + class_id = score + stride / sizeof(td_float); + + for (i = 0; i < rect_info->num; i++) { + rect_info->rect[i].point[SAMPLE_SVP_NPU_RECT_LEFT_TOP].x = (td_u32)((td_float)x_min[roi_offset] / + proc_frame->video_frame.width * show_frame->video_frame.width) & (~1); + rect_info->rect[i].point[SAMPLE_SVP_NPU_RECT_LEFT_TOP].y = (td_u32)((td_float)y_min[roi_offset] / + proc_frame->video_frame.height * show_frame->video_frame.height) & (~1); + + rect_info->rect[i].point[SAMPLE_SVP_NPU_RECT_RIGHT_TOP].x = (td_u32)((td_float)x_max[roi_offset] / + proc_frame->video_frame.width * show_frame->video_frame.width) & (~1); + rect_info->rect[i].point[SAMPLE_SVP_NPU_RECT_RIGHT_TOP].y = + rect_info->rect[i].point[SAMPLE_SVP_NPU_RECT_LEFT_TOP].y; + + rect_info->rect[i].point[SAMPLE_SVP_NPU_RECT_RIGHT_BOTTOM].x = + rect_info->rect[i].point[SAMPLE_SVP_NPU_RECT_RIGHT_TOP].x; + rect_info->rect[i].point[SAMPLE_SVP_NPU_RECT_RIGHT_BOTTOM].y = (td_u32)((td_float)y_max[roi_offset] / + proc_frame->video_frame.height * show_frame->video_frame.height) & (~1); + + rect_info->rect[i].point[SAMPLE_SVP_NPU_RECT_LEFT_BOTTOM].x = + rect_info->rect[i].point[SAMPLE_SVP_NPU_RECT_LEFT_TOP].x; + rect_info->rect[i].point[SAMPLE_SVP_NPU_RECT_LEFT_BOTTOM].y = + rect_info->rect[i].point[SAMPLE_SVP_NPU_RECT_RIGHT_BOTTOM].y; + + rect_info->rect[i].score = (td_float)((td_float)score[roi_offset]); + rect_info->rect[i].class_id = (td_u16)((td_float)class_id[roi_offset]); + + roi_offset++; + } + return TD_SUCCESS; +} + +static td_float sample_svp_npu_calc_iou(const sample_svp_npu_roi_box* box1, const sample_svp_npu_roi_box* box2) +{ + td_float area1 = box1->area; + td_float area2 = box2->area; + td_float xx1 = (box1->lx > box2->lx) ? box1->lx : box2->lx; + td_float yy1 = (box1->ly > box2->ly) ? box1->ly : box2->ly; + td_float xx2 = (box1->rx < box2->rx) ? box1->rx : box2->rx; + td_float yy2 = (box1->ry < box2->ry) ? box1->ry : box2->ry; + td_float w = (0.0f > (xx2 - xx1 + 1)) ? 0.0f : (xx2 - xx1 + 1); + td_float h = (0.0f > (yy2 - yy1 + 1)) ? 0.0f : (yy2 - yy1 + 1); + td_float inter = w * h; + td_float ovr = inter /(area1 + area2 - inter); + return ovr; +} + +static td_void sample_svp_npu_multiclass_nms(sample_svp_npu_roi_box *roi_box, td_u32 *roi_box_num, + sample_svp_npu_valid_box* valid_box, td_u32 valid_box_num) +{ + float nms_thr = 0.45; /* 0.45: threshold of ROI */ + for (td_u32 i = 0; i < valid_box_num; i++) { + sample_svp_npu_valid_box *item = &valid_box[i]; + td_float box_x_center = item->xcenter; + td_float box_y_center = item->ycenter; + td_float box_width = item->w; + td_float box_height = item->h; + + td_float x1 = (box_x_center - box_width / 2); + td_float y1 = (box_y_center - box_height / 2); + td_float x2 = (box_x_center + box_width / 2); + td_float y2 = (box_y_center + box_height / 2); + td_float area = (x2 - x1 + 1) * (y2 - y1 + 1); + td_bool keep = TD_TRUE; + /* lx, ly, rx, ry, score, class id, area */ + sample_svp_npu_roi_box box = {x1, y1, x2, y2, item->score, item->class_id, area}; + for (td_u32 j = 0; j < *roi_box_num; j++) { + if (sample_svp_npu_calc_iou(&box, &roi_box[j]) > nms_thr) { + keep = TD_FALSE; + break; + } + } + if (keep) { + if (*roi_box_num >= OT_SVP_RECT_NUM) { + sample_svp_trace_err("roi_box_num [%u] is large than %u!\n", *roi_box_num, OT_SVP_RECT_NUM); + return; + } + roi_box[*roi_box_num].lx = box.lx; + roi_box[*roi_box_num].ly = box.ly; + roi_box[*roi_box_num].rx = box.rx; + roi_box[*roi_box_num].ry = box.ry; + roi_box[*roi_box_num].score = box.score; + roi_box[*roi_box_num].class_id = box.class_id; + roi_box[*roi_box_num].area = box.area; + *roi_box_num = *roi_box_num + 1; + } + } +} + +inline static td_float sample_svp_npu_sig_mod(td_float a) +{ + return 1.0f / (1.0f + exp(-a)); +} + +static td_void sample_svp_npu_get_max_score_and_idx(td_u32 obj_score_idx, td_u32 chn_step, const td_float* out_data, + td_float *max_cls_score, td_u32 *max_cls_id) +{ + td_u32 cls_score_idx = obj_score_idx + chn_step; + for (td_u32 c = 0; c < SAMPLE_SVP_NPU_YOLO_CLASS_NUM; c++) { + td_float cls_score_val = out_data[cls_score_idx]; + if (cls_score_val > *max_cls_score) { + *max_cls_score = cls_score_val; + *max_cls_id = c; + } + cls_score_idx += chn_step; + } +} +static td_u32 g_sample_svp_npu_anchor_grids[SAMPLE_SVP_NPU_YOLO_CPU_OUT_NUM][SAMPLE_SVP_NPU_YOLO_CLASS_MEMBER_NUM] = { + {116, 90, 156, 198, 373, 326}, + {30, 61, 62, 45, 59, 119}, + {10, 13, 16, 30, 33, 23} +}; + +static td_void sample_svp_npu_process_per_dectection_inner(const sample_svp_npu_detection_inner_param *inner_param, + td_float *grids_x, td_float *grids_y, sample_svp_npu_valid_box* valid_box, td_u32 *valid_box_num) +{ + td_float box_hieght; + td_u32 expanded_strides[SAMPLE_SVP_NPU_YOLO_CPU_OUT_NUM] = { 32, 16, 8 }; + td_u32 out_height_idx = inner_param->out_height_idx; + td_u32 chn_step = inner_param->chn_step; + td_float score_thr = inner_param->score_thr; + td_float *out_data = inner_param->out_data; + size_t w_stride_offset = inner_param->w_stride_offset; + td_u32 obj_score_offset = inner_param->obj_score_offset; + td_u32 offset = out_height_idx * inner_param->w_stride_offset; + for (td_u32 j = 0; j < inner_param->out_width; j++) { + for (td_u32 k = 0; k < SAMPLE_SVP_NPU_YOLO_SCALE_SIZE; k++) { + offset = j + out_height_idx * w_stride_offset + k * chn_step * SAMPLE_SVP_NPU_YOLO_OUT_PARM_NUM; + td_u32 obj_score_idx = offset + obj_score_offset; + td_float obj_score_val = sample_svp_npu_sig_mod(out_data[obj_score_idx]); + if (obj_score_val <= score_thr) { + continue; + } + if (*valid_box_num >= OT_SVP_RECT_NUM) { + sample_svp_trace_err("valid_box_num [%u] is large than %u!\n", *valid_box_num, OT_SVP_RECT_NUM); + return; + } + /* max score */ + td_float max_cls_score = 0.0f; + td_u32 max_cls_id = 0; + sample_svp_npu_get_max_score_and_idx(obj_score_idx, chn_step, out_data, &max_cls_score, &max_cls_id); + + td_float confidence_score = sample_svp_npu_sig_mod(max_cls_score) * obj_score_val; + if (confidence_score > score_thr) { + /* gen box info */ + td_u32 x_center_idx = offset; + td_u32 y_center_idx = x_center_idx + chn_step; + td_u32 box_width_idx = y_center_idx + chn_step; + td_u32 box_height_idx = box_width_idx + chn_step; + td_float x_center = (sample_svp_npu_sig_mod(out_data[x_center_idx]) * SAMPLE_SVP_NPU_DOUBLE + + grids_x[j]) * expanded_strides[inner_param->idx]; + td_float y_center = (sample_svp_npu_sig_mod(out_data[y_center_idx]) * SAMPLE_SVP_NPU_DOUBLE + + grids_y[out_height_idx]) * expanded_strides[inner_param->idx]; + td_float tmp_value = sample_svp_npu_sig_mod(out_data[box_width_idx]) * SAMPLE_SVP_NPU_DOUBLE; + td_float box_width = tmp_value * tmp_value * g_sample_svp_npu_anchor_grids[inner_param->idx][(k << 1)]; + tmp_value = sample_svp_npu_sig_mod(out_data[box_height_idx]) * SAMPLE_SVP_NPU_DOUBLE; + box_hieght = tmp_value * tmp_value * g_sample_svp_npu_anchor_grids[inner_param->idx][(k << 1) +1]; + valid_box[*valid_box_num].score = confidence_score; + valid_box[*valid_box_num].xcenter = x_center; + valid_box[*valid_box_num].ycenter = y_center; + valid_box[*valid_box_num].w = box_width; + valid_box[*valid_box_num].h = box_hieght; + valid_box[*valid_box_num].class_id = (td_float)max_cls_id; + *valid_box_num = *valid_box_num + 1; + } + } + } +} + +static td_void sample_svp_npu_process_per_dectection(const sample_svp_npu_task_info *task, td_u32 idx, + sample_svp_npu_valid_box* valid_box, td_u32 *valid_box_num) +{ + td_u32 out_height; + svp_acl_mdl_io_dims out_dims; + sample_svp_npu_detection_inner_param inner_param; + svp_acl_data_buffer* data_buffer = TD_NULL; + td_u32 h_sizes[SAMPLE_SVP_NPU_YOLO_CPU_OUT_NUM] = { 20, 40, 80 }; + td_u32 w_sizes[SAMPLE_SVP_NPU_YOLO_CPU_OUT_NUM] = { 20, 40, 80 }; + /* gen grids */ + td_float grids_x[SAMPLE_SVP_NPU_YOLO_CLASS_NUM] = {0}; + td_float grids_y[SAMPLE_SVP_NPU_YOLO_CLASS_NUM] = {0}; + + svp_acl_mdl_get_output_dims(g_svp_npu_model[task->cfg.model_idx].model_desc, idx, &out_dims); + data_buffer = svp_acl_mdl_get_dataset_buffer(task->output_dataset, idx); + out_height = out_dims.dims[out_dims.dim_count - SAMPLE_SVP_NPU_DOUBLE]; + inner_param.out_width = out_dims.dims[out_dims.dim_count - 1]; + if (out_height > SAMPLE_SVP_NPU_YOLO_CLASS_NUM || inner_param.out_width > SAMPLE_SVP_NPU_YOLO_CLASS_NUM) { + sample_svp_trace_err("out_width[%u] or out_width[%u] is large than %u!\n", + out_height, inner_param.out_width, SAMPLE_SVP_NPU_YOLO_CLASS_NUM); + return; + } + + inner_param.score_thr = SAMPLE_SVP_NPU_YOLO_SCORE_THRESHOLE; + inner_param.idx = idx; + inner_param.out_data = (td_float *)svp_acl_get_data_buffer_addr(data_buffer); + inner_param.w_stride_offset = + svp_acl_mdl_get_output_default_stride(g_svp_npu_model[task->cfg.model_idx].model_desc, idx) / sizeof(td_float); + inner_param.chn_step = out_height * inner_param.w_stride_offset; + + for (td_u32 i = 0; i < h_sizes[idx]; i++) { + grids_y[i] = i - SAMPLE_SVP_NPU_YOLO_SCORE_THRESHOLE; + } + for (td_u32 i = 0; i < w_sizes[idx]; i++) { + grids_x[i] = i - SAMPLE_SVP_NPU_YOLO_SCORE_THRESHOLE; + } + inner_param.obj_score_offset = sizeof(td_float) * inner_param.chn_step; + for (td_u32 i = 0; i < out_height; i++) { + inner_param.out_height_idx = i; + sample_svp_npu_process_per_dectection_inner(&inner_param, grids_x, grids_y, valid_box, valid_box_num); + } +} + +static td_void sample_svp_npu_filter_yolo_box(const sample_svp_npu_task_info *task, + sample_svp_npu_valid_box* valid_box, td_u32 *valid_box_num) +{ + td_u32 out_num = svp_acl_mdl_get_num_outputs(g_svp_npu_model[task->cfg.model_idx].model_desc); + if (out_num > SAMPLE_SVP_NPU_YOLO_CPU_OUT_NUM) { + sample_svp_trace_err("output num [%u] is large than 3!\n", out_num); + return; + } + + /* gen box */ + for (td_u32 n = 0; n < out_num; n++) { + sample_svp_npu_process_per_dectection(task, n, valid_box, valid_box_num); + } +} + +static td_void sample_svp_npu_fill_rect_info(const ot_video_frame_info *proc_frame, + const ot_video_frame_info *show_frame, const sample_svp_npu_roi_box *roi_box, + td_u32 roi_box_num, ot_sample_svp_rect_info *rect_info) +{ + td_u32 rect_num = 0; + td_float w_multiples = (td_float)show_frame->video_frame.width / (td_float)proc_frame->video_frame.width; + td_float h_multiples = (td_float)show_frame->video_frame.height / (td_float)proc_frame->video_frame.height; + for (td_u32 i = 0; i < roi_box_num; i++) { + if (roi_box[i].score > 1.0f || roi_box[i].score < 0.0f) { + continue; + } + rect_info->rect[rect_num].point[SAMPLE_SVP_NPU_RECT_LEFT_TOP].x = (td_u32)(roi_box[i].lx * w_multiples) & (~1); + rect_info->rect[rect_num].point[SAMPLE_SVP_NPU_RECT_LEFT_TOP].y = (td_u32)(roi_box[i].ly * h_multiples) & (~1); + rect_info->rect[rect_num].point[SAMPLE_SVP_NPU_RECT_RIGHT_TOP].x = (td_u32)(roi_box[i].rx * w_multiples) & (~1); + rect_info->rect[rect_num].point[SAMPLE_SVP_NPU_RECT_RIGHT_TOP].y = + rect_info->rect[rect_num].point[SAMPLE_SVP_NPU_RECT_LEFT_TOP].y; + rect_info->rect[rect_num].point[SAMPLE_SVP_NPU_RECT_RIGHT_BOTTOM].x = + rect_info->rect[rect_num].point[SAMPLE_SVP_NPU_RECT_RIGHT_TOP].x; + rect_info->rect[rect_num].point[SAMPLE_SVP_NPU_RECT_RIGHT_BOTTOM].y = + (td_u32)(roi_box[i].ry * h_multiples) & (~1); + rect_info->rect[rect_num].point[SAMPLE_SVP_NPU_RECT_LEFT_BOTTOM].x = + rect_info->rect[rect_num].point[SAMPLE_SVP_NPU_RECT_LEFT_TOP].x; + rect_info->rect[rect_num].point[SAMPLE_SVP_NPU_RECT_LEFT_BOTTOM].y = + rect_info->rect[rect_num].point[SAMPLE_SVP_NPU_RECT_RIGHT_BOTTOM].y; + rect_num++; + } + rect_info->num = rect_num; +} + +static td_s32 cmp_valid_box(const void *item1, const void *item2) +{ + sample_svp_npu_valid_box *box1 = (sample_svp_npu_valid_box *)item1; + sample_svp_npu_valid_box *box2 = (sample_svp_npu_valid_box *)item2; + if (box1->score > box2->score) { + return 1; + } + return 0; +} + +static td_s32 cmp_roi_box(const void *item1, const void *item2) +{ + sample_svp_npu_roi_box *box1 = (sample_svp_npu_roi_box *)item1; + sample_svp_npu_roi_box *box2 = (sample_svp_npu_roi_box *)item2; + if (box1->class_id < box2->class_id) { + return 1; + } else if (box1->class_id == box2->class_id) { + return box1->score > box2->score; + } + return 0; +} + +static td_s32 sample_svp_npu_get_roi_by_cpu(const sample_svp_npu_task_info *task, + const sample_svp_npu_detection_info *info, const ot_video_frame_info *proc_frame, + const ot_video_frame_info *show_frame, ot_sample_svp_rect_info *rect_info) +{ + td_u32 valid_box_num = 0; + td_u32 roi_box_num = 0; + sample_svp_npu_valid_box valid_box[OT_SVP_RECT_NUM] = {0}; + sample_svp_npu_roi_box roi_box[OT_SVP_RECT_NUM] = {0}; + + sample_svp_npu_filter_yolo_box(task, valid_box, &valid_box_num); + qsort((td_void *)valid_box, valid_box_num, sizeof(sample_svp_npu_valid_box), cmp_valid_box); + + sample_svp_npu_multiclass_nms(roi_box, &roi_box_num, valid_box, valid_box_num); + if (roi_box_num == 0) { + sample_svp_trace_info("No target object is detected !!!\n"); + return TD_SUCCESS; + } + qsort((td_void *)roi_box, roi_box_num, sizeof(sample_svp_npu_roi_box), cmp_roi_box); + sample_svp_npu_fill_rect_info(proc_frame, show_frame, roi_box, roi_box_num, rect_info); + + return TD_SUCCESS; +} + +td_s32 sample_common_svp_npu_roi_to_rect(const sample_svp_npu_task_info *task, + sample_svp_npu_detection_info *detection_info, const ot_video_frame_info *proc_frame, + const ot_video_frame_info *show_frame, ot_sample_svp_rect_info *rect_info) +{ + td_s32 ret; + td_u32 i; + td_float max_confidence = 0.0f; + td_u32 max_index = 0; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return TD_FAILURE; + } + sample_svp_check_exps_return(detection_info == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "detection_info is NULL!\n"); + sample_svp_check_exps_return(proc_frame == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "proc_frame is NULL!\n"); + sample_svp_check_exps_return(show_frame == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "show_frame is NULL!\n"); + sample_svp_check_exps_return(rect_info == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "rect_info is NULL!\n"); + + detection_info->roi_offset = 0; + ret = sample_svp_npu_get_roi_num(task, detection_info, rect_info); + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get roi num failed!\n"); + + ret = sample_svp_npu_get_roi(task, detection_info, proc_frame, show_frame, rect_info); + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get roi failed!\n"); + + // 新增部分:筛选置信度最高的矩形框 + if (rect_info->num > 0) { + // 1. 查找置信度最高的矩形框 + for (i = 0; i < rect_info->num; i++) { + if (rect_info->rect[i].score > max_confidence) { + max_confidence = rect_info->rect[i].score; + max_index = i; + } + } + + // 2. 只保留置信度最高的矩形框 + if (rect_info->num > 1) { + rect_info->rect[0] = rect_info->rect[max_index]; + rect_info->num = 1; + } + } + + return TD_SUCCESS; +} + +td_s32 sample_common_svp_npu_roi_to_rect_cpu(const sample_svp_npu_task_info *task, + sample_svp_npu_detection_info *detection_info, const ot_video_frame_info *proc_frame, + const ot_video_frame_info *show_frame, ot_sample_svp_rect_info *rect_info) +{ + td_s32 ret; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return TD_FAILURE; + } + sample_svp_check_exps_return(detection_info == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "detection_info is NULL!\n"); + sample_svp_check_exps_return(proc_frame == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "proc_frame is NULL!\n"); + sample_svp_check_exps_return(show_frame == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "show_frame is NULL!\n"); + sample_svp_check_exps_return(rect_info == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "rect_info is NULL!\n"); + + ret = sample_svp_npu_get_roi_by_cpu(task, detection_info, proc_frame, show_frame, rect_info); + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get roi failed!\n"); + + return TD_SUCCESS; +} + +td_s32 sample_common_svp_npu_set_threshold(sample_svp_npu_threshold threshold[], td_u32 threshold_num, + const sample_svp_npu_task_info *task) +{ + td_u32 i; + td_u32 n; + svp_acl_error ret; + svp_acl_data_buffer *data_buffer = TD_NULL; + td_float *data = TD_NULL; + size_t idx; + size_t size; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return TD_FAILURE; + } + sample_svp_check_exps_return(threshold == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "threshold is NULL!\n"); + sample_svp_check_exps_return(threshold_num == 0, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "threshold_num is 0!\n"); + + for (i = 0; i < threshold_num; i++) { + ret = svp_acl_mdl_get_input_index_by_name(g_svp_npu_model[task->cfg.model_idx].model_desc, + threshold[i].name, &idx); + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get roi idx failed!\n"); + + data_buffer = svp_acl_mdl_get_dataset_buffer(task->input_dataset, idx); + sample_svp_check_exps_return(data_buffer == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get roi data_buffer is NULL!\n"); + + size = svp_acl_get_data_buffer_size(data_buffer); + sample_svp_check_exps_return(size < SAMPLE_SVP_NPU_THRESHOLD_NUM * sizeof(td_float), TD_FAILURE, + SAMPLE_SVP_ERR_LEVEL_ERROR, "get size(%lu) is less than %lu!\n", + size, SAMPLE_SVP_NPU_THRESHOLD_NUM * sizeof(td_float)); + + data = (td_float *)svp_acl_get_data_buffer_addr(data_buffer); + sample_svp_check_exps_return(data == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get roi data is NULL!\n"); + n = 0; + data[n++] = threshold[i].nms_threshold; + data[n++] = threshold[i].score_threshold; + data[n++] = threshold[i].min_height; + data[n++] = threshold[i].min_width; + } + return TD_SUCCESS; +} + +td_s32 sample_common_svp_npu_check_has_aicpu_task(const sample_svp_npu_task_info *task, td_bool *has_aicpu_task) +{ + td_u32 aicpu_task_num; + svp_acl_error ret; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); + return TD_FAILURE; + } + sample_svp_check_exps_return(has_aicpu_task == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "has_aicpu_task is NULL!\n"); + + ret = svp_acl_ext_get_mdl_aicpu_task_num(g_svp_npu_model[task->cfg.model_idx].model_id, &aicpu_task_num); + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get aicpu task num failed, error code is %d!\n", ret); + + *has_aicpu_task = (aicpu_task_num == 0) ? TD_FALSE : TD_TRUE; + return TD_SUCCESS; +} + +sample_svp_npu_model_info* sample_common_svp_npu_get_model_info(td_u32 model_idx) +{ + sample_svp_check_exps_return(model_idx >= SAMPLE_SVP_NPU_MAX_MODEL_NUM, NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, + "model_idx(%u) must be [0, %u)!\n", model_idx, SAMPLE_SVP_NPU_MAX_MODEL_NUM); + return &g_svp_npu_model[model_idx]; +} + +td_s32 sample_common_svp_npu_get_input_resolution(td_u32 model_idx, td_u32 input_idx, + ot_size *pic_size) +{ + svp_acl_error ret; + svp_acl_mdl_io_dims dims = {0}; + + ret = svp_acl_mdl_get_input_dims(g_svp_npu_model[model_idx].model_desc, input_idx, &dims); + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get num dims failed!\n"); + pic_size->height = dims.dims[dims.dim_count - SAMPLE_SVP_NPU_H_DIM_IDX]; // NCHW + pic_size->width = dims.dims[dims.dim_count - 1]; // NCHW + return TD_SUCCESS; +} diff --git a/vendor/zsks/demo/fruit_identify/common/sample_common_svp_npu_model.h b/vendor/zsks/demo/fruit_identify/common/sample_common_svp_npu_model.h new file mode 100755 index 0000000000000000000000000000000000000000..18ff9e359a4c3cf2345f9c98d1821a1dcc2b5e93 --- /dev/null +++ b/vendor/zsks/demo/fruit_identify/common/sample_common_svp_npu_model.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SAMPLE_COMMON_SVP_NPU_MODEL_H +#define SAMPLE_COMMON_SVP_NPU_MODEL_H +#include "ot_type.h" +#include "svp_acl_mdl.h" +#include "sample_common_svp.h" +#include "sample_common_svp_npu.h" + +td_s32 sample_common_svp_npu_get_input_data(const td_char *src[], td_u32 file_num, + const sample_svp_npu_task_info *task); + +td_s32 sample_common_svp_npu_load_model(const td_char *model_path, td_u32 model_index, td_bool is_cached); +td_void sample_common_svp_npu_unload_model(td_u32 model_index); + +td_s32 sample_common_svp_npu_create_input(sample_svp_npu_task_info *task); +td_s32 sample_common_svp_npu_create_output(sample_svp_npu_task_info *task); +td_void sample_common_svp_npu_destroy_input(sample_svp_npu_task_info *task); +td_void sample_common_svp_npu_destroy_output(sample_svp_npu_task_info *task); + +td_s32 sample_common_svp_npu_create_task_buf(sample_svp_npu_task_info *task); +td_s32 sample_common_svp_npu_create_work_buf(sample_svp_npu_task_info *task); +td_void sample_common_svp_npu_destroy_task_buf(sample_svp_npu_task_info *task); +td_void sample_common_svp_npu_destroy_work_buf(sample_svp_npu_task_info *task); + +td_s32 sample_common_svp_npu_get_work_buf_info(const sample_svp_npu_task_info *task, + td_u32 *work_buf_size, td_u32 *work_buf_stride); +td_s32 sample_common_svp_npu_share_work_buf(const sample_svp_npu_shared_work_buf *shared_work_buf, + const sample_svp_npu_task_info *task); + +td_s32 sample_common_svp_npu_set_dynamic_batch(const sample_svp_npu_task_info *task); +td_s32 sample_common_svp_npu_model_execute(const sample_svp_npu_task_info *task); +td_void sample_common_svp_npu_output_classification_result(const sample_svp_npu_task_info *task); + +td_void sample_common_svp_npu_dump_task_data(const sample_svp_npu_task_info *task); + +td_s32 sample_common_svp_npu_set_threshold(sample_svp_npu_threshold threshold[], td_u32 threshold_num, + const sample_svp_npu_task_info *task); + +td_s32 sample_common_svp_npu_roi_to_rect(const sample_svp_npu_task_info *task, + sample_svp_npu_detection_info *detection_info, const ot_video_frame_info *proc_frame, + const ot_video_frame_info *show_frame, ot_sample_svp_rect_info *rect_info); + +td_s32 sample_common_svp_npu_roi_to_rect_cpu(const sample_svp_npu_task_info *task, + sample_svp_npu_detection_info *detection_info, const ot_video_frame_info *proc_frame, + const ot_video_frame_info *show_frame, ot_sample_svp_rect_info *rect_info); + +td_s32 sample_common_svp_npu_update_input_data_buffer_info(td_u8 *virt_addr, td_u32 size, td_u32 stride, td_u32 idx, + const sample_svp_npu_task_info *task); + +td_s32 sample_common_svp_npu_get_input_data_buffer_info(const sample_svp_npu_task_info *task, td_u32 idx, + td_u8 **virt_addr, td_u32 *size, td_u32 *stride); + +td_s32 sample_common_svp_npu_check_has_aicpu_task(const sample_svp_npu_task_info *task, td_bool *has_aicpu_task); + +sample_svp_npu_model_info* sample_common_svp_npu_get_model_info(td_u32 model_idx); + +td_s32 sample_common_svp_npu_get_input_resolution(td_u32 model_idx, td_u32 input_idx, + ot_size *pic_size); +#endif diff --git a/vendor/zsks/demo/fruit_identify/common/sample_common_svp_osd.c b/vendor/zsks/demo/fruit_identify/common/sample_common_svp_osd.c new file mode 100755 index 0000000000000000000000000000000000000000..2d0dcd4ef7ab8db1dcfdfa63d51f427e680806ff --- /dev/null +++ b/vendor/zsks/demo/fruit_identify/common/sample_common_svp_osd.c @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2025 Zhongshan Kuangshi Microelectronics Technology Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contact Information + * Author: yaohongtao + * Phone: +86-18604465633 + * Email: yht@cust.edu.cn + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "sample_comm.h" +#include "easy_log.h" +#include "xvp_common_osd.h" +#include "sample_common_svp_npu.h" + +#define OVERLAY_MIN_HANDLE 20 +#define BUFFER_SIZE 16 +#define CLASS_BUFFER_SIZE 10 +#define DOUBLE_OF_SIZE 2 +#define BACKGROUND_ALPHA 255 +#define OSD_BUFFER_SIZE 32 +#define WIDTH_OF_MIN 1920 +#define HEIGHT_OF_MIN 1080 +#define WIDTH_OF_MAX 2560 +#define HEIGHT_OF_MAX 1440 + +void sample_osd_region_init(ot_rgn_attr *region, ot_size img_size) +{ + td_s32 i; + region->type = OT_RGN_OVERLAYEX; + region->attr.overlay.canvas_num = 2; /* 2: canvas num */ + + for (i = 0; i < OT_RGN_CLUT_NUM; i++) { + region->attr.overlay.clut[i] = (td_u32)(0x000fff0f * (i + 1) * (i + 1)); + region->attr.overlay.clut[i] |= 0xff000000; + } + region->attr.overlay.pixel_format = OT_PIXEL_FORMAT_ARGB_1555; + region->attr.overlay.size.width = img_size.width * DOUBLE_OF_SIZE; + region->attr.overlay.size.height = img_size.height * DOUBLE_OF_SIZE; + region->attr.overlay.bg_color = 0xffff; +} + +void sample_osd_chn_attr_init(ot_rgn_chn_attr *chn_attr) +{ + chn_attr->type = OT_RGN_OVERLAYEX; + chn_attr->is_show = TD_TRUE; + chn_attr->attr.overlay_chn.bg_alpha = BACKGROUND_ALPHA; + chn_attr->attr.overlay_chn.fg_alpha = BACKGROUND_ALPHA; + chn_attr->attr.overlay_chn.qp_info.enable = TD_FALSE; + chn_attr->attr.overlay_chn.qp_info.is_abs_qp = TD_FALSE; + chn_attr->attr.overlay_chn.qp_info.qp_val = 0; + chn_attr->attr.overlay_chn.dst = OT_RGN_ATTACH_JPEG_MAIN; + chn_attr->attr.overlay_chn.layer = 0; +} + +void sample_osd_info_init(xvp_osd_info *osd_info, ot_rgn_attr region) +{ + osd_info->border_color = 0x0; + osd_info->font_color = SAMPLE_SVP_NPU_RECT_COLOR; + osd_info->factor = 2; /* 2: factor of osd info */ + osd_info->width = region.attr.overlay.size.width; + osd_info->height = region.attr.overlay.size.height; + osd_info->stride = region.attr.overlay.size.width; +} + +int sample_osd_init(sample_mpp_osd_info *mpp_osd_info) +{ + printf("sample_osd_init ...\r\n"); + td_s32 ret; + ot_rgn_attr region = {0}; + ot_mpp_chn chn = {0}; + ot_rgn_chn_attr chn_attr = {0}; + xvp_osd_info osd_info = {0}; + char osd_str[BUFFER_SIZE] = "scissors 0.00"; + unsigned char gb_str[BUFFER_SIZE] = {0}; + ot_size img_size = {BUFFER_SIZE}; + + chn.mod_id = OT_ID_VPSS; + chn.dev_id = 0; + chn.chn_id = 0; + + xvp_common_osd_utf8_to_gb2312((unsigned char *)osd_str, strlen(osd_str), gb_str); + xvp_common_osd_calculate_canvas_size(gb_str, 1, &img_size.width, &img_size.height); + printf("%s-%d l:%d w:%u h:%u\n", __func__, __LINE__, strlen(gb_str), img_size.width, img_size.height); + + sample_osd_region_init(®ion, img_size); + + ret = ss_mpi_rgn_create(mpp_osd_info->handle, ®ion); + if (ret != TD_SUCCESS) { + LOGE("ss_mpi_rgn_create failed with %#x!", ret); + } + + sample_osd_chn_attr_init(&chn_attr); + ret = ss_mpi_rgn_attach_to_chn(mpp_osd_info->handle, &chn, &chn_attr); + if (ret != TD_SUCCESS) { + LOGE("ss_mpi_rgn_attach_to_chn failed with %#x!", ret); + } + + sample_osd_info_init(&osd_info, region); + mpp_osd_info->chn = chn; + mpp_osd_info->chn_attr = chn_attr; + mpp_osd_info->osd_info = osd_info; + + xvp_common_osd_init(NULL); + + return 0; +} + +int sample_osd_exit(sample_mpp_osd_info *mpp_osd_info) +{ + printf("sample_osd_exit ...\r\n"); + td_s32 ret; + xvp_common_osd_exit(); + + ret = ss_mpi_rgn_detach_from_chn(mpp_osd_info->handle, &mpp_osd_info->chn); + if (ret != TD_SUCCESS) { + LOGE("ss_mpi_rgn_detach_from_chn failed with %#x!", ret); + } + + ret = ss_mpi_rgn_destroy(mpp_osd_info->handle); + if (ret != TD_SUCCESS) { + LOGE("ss_mpi_rgn_destroy failed with %#x!", ret); + } + + return 0; +} + +int sample_osd_draw_text(td_float score, td_u16 class_id, td_u16 x, td_u16 y, + sample_mpp_osd_info mpp_osd_info) +{ + printf("sample_osd_draw_text ...\r\n"); + td_s32 ret; + const char classes[][CLASS_BUFFER_SIZE] = {"梨子", "西瓜", "橙子", "香蕉", "苹果"}; + char osd_str[OSD_BUFFER_SIZE] = "西瓜 0.00"; + unsigned char gb_str[OSD_BUFFER_SIZE] = {0}; + ot_size img_size = {0}; + ot_bmp bitmap = {0}; + + bitmap.width = mpp_osd_info.osd_info.width; + bitmap.height = mpp_osd_info.osd_info.height; + bitmap.pixel_format = OT_PIXEL_FORMAT_ARGB_1555; + bitmap.data = (td_void*)malloc(bitmap.width * bitmap.height * DOUBLE_OF_SIZE); + + ret = snprintf(osd_str, sizeof(osd_str), "%s %0.2f", classes[class_id], score); + if (ret < 0) { + printf("%s:snprintf failed, ret:0x%x.\n", __FUNCTION__, ret); + } + memset_sp(bitmap.data, bitmap.width * bitmap.height * DOUBLE_OF_SIZE, 0x0, + bitmap.width * bitmap.height * DOUBLE_OF_SIZE); + memset_sp(gb_str, sizeof(gb_str), 0, sizeof(gb_str)); + xvp_common_osd_utf8_to_gb2312((unsigned char *)osd_str, strlen(osd_str), gb_str); + + xvp_common_osd_draw_text((unsigned char *)bitmap.data, gb_str, 0, 0, &mpp_osd_info.osd_info); + ret = ss_mpi_rgn_set_bmp(mpp_osd_info.handle, &bitmap); + if (ret != TD_SUCCESS) { + LOGE("ss_mpi_rgn_set_bmp failed with %#x!", ret); + } + int min_x = (int)(x * WIDTH_OF_MIN / WIDTH_OF_MAX); + int min_y = (int)(y * HEIGHT_OF_MIN / HEIGHT_OF_MAX); + + if ((min_x % DOUBLE_OF_SIZE) != 0) { + min_x = min_x + 1; + } + if ((min_y % DOUBLE_OF_SIZE) != 0) { + min_y = min_y + 1; + } + printf("min_x:%d, min_y:%d\r\n", min_x, min_y); + mpp_osd_info.chn_attr.attr.overlay_chn.point.x = min_x; + mpp_osd_info.chn_attr.attr.overlay_chn.point.y = min_y; + mpp_osd_info.chn_attr.is_show = TD_TRUE; + ss_mpi_rgn_set_display_attr(mpp_osd_info.handle, &mpp_osd_info.chn, &mpp_osd_info.chn_attr); + + if (bitmap.data != NULL) { + free(bitmap.data); + bitmap.data = NULL; + } + + return 0; +} + +int sample_osd_clean_text(sample_mpp_osd_info mpp_osd_info) +{ + ss_mpi_rgn_set_display_attr(mpp_osd_info.handle, &mpp_osd_info.chn, &mpp_osd_info.chn_attr); +} diff --git a/vendor/zsks/demo/fruit_identify/common/sample_common_svp_osd.h b/vendor/zsks/demo/fruit_identify/common/sample_common_svp_osd.h new file mode 100755 index 0000000000000000000000000000000000000000..96841f847f43bbdf44b8e098772a83f31cdf82b9 --- /dev/null +++ b/vendor/zsks/demo/fruit_identify/common/sample_common_svp_osd.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Zhongshan Kuangshi Microelectronics Technology Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contact Information + * Author: yaohongtao + * Phone: +86-18604465633 + * Email: yht@cust.edu.cn + */ + +#ifndef SAMPLE_COMMON_SVP_OSD_H +#define SAMPLE_COMMON_SVP_OSD_H +#include "xvp_common_osd.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int sample_osd_init(sample_mpp_osd_info *mpp_osd_info); +int sample_osd_exit(sample_mpp_osd_info *mpp_osd_info); +int sample_osd_draw_text(td_float score, td_u16 class_id, td_u16 x, td_u16 y, sample_mpp_osd_info mpp_osd_info); +int sample_osd_clean_text(sample_mpp_osd_info mpp_osd_info); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/vendor/zsks/demo/fruit_identify/data/hzk/hzk16 b/vendor/zsks/demo/fruit_identify/data/hzk/hzk16 new file mode 100755 index 0000000000000000000000000000000000000000..460e0550372c3317fe0b901b14e84ce65ddc9e50 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/data/hzk/hzk16 differ diff --git a/vendor/zsks/demo/fruit_identify/data/model/fruit_identify.om b/vendor/zsks/demo/fruit_identify/data/model/fruit_identify.om new file mode 100755 index 0000000000000000000000000000000000000000..c8bda4529527724097744a302b5c311f530ccdb2 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/data/model/fruit_identify.om differ diff --git a/vendor/zsks/demo/fruit_identify/fruit_audio/apple/audio_chn0.aac b/vendor/zsks/demo/fruit_identify/fruit_audio/apple/audio_chn0.aac new file mode 100755 index 0000000000000000000000000000000000000000..be17a8c4b7dc63b33b3ec46196db5cedb1ab7a25 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/fruit_audio/apple/audio_chn0.aac differ diff --git a/vendor/zsks/demo/fruit_identify/fruit_audio/banana/audio_chn0.aac b/vendor/zsks/demo/fruit_identify/fruit_audio/banana/audio_chn0.aac new file mode 100755 index 0000000000000000000000000000000000000000..f7f529304bd73f4de175ba167ae501075c852b00 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/fruit_audio/banana/audio_chn0.aac differ diff --git a/vendor/zsks/demo/fruit_identify/fruit_audio/orange/audio_chn0.aac b/vendor/zsks/demo/fruit_identify/fruit_audio/orange/audio_chn0.aac new file mode 100755 index 0000000000000000000000000000000000000000..41d79b4688bcaba26971ff36e7bbd3bf42f47fbc Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/fruit_audio/orange/audio_chn0.aac differ diff --git a/vendor/zsks/demo/fruit_identify/fruit_audio/pear/audio_chn0.aac b/vendor/zsks/demo/fruit_identify/fruit_audio/pear/audio_chn0.aac new file mode 100755 index 0000000000000000000000000000000000000000..cf40ce599eda4aaad8d6bc75465fd1117cd0d8ac Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/fruit_audio/pear/audio_chn0.aac differ diff --git a/vendor/zsks/demo/fruit_identify/fruit_audio/watermelon/audio_chn0.aac b/vendor/zsks/demo/fruit_identify/fruit_audio/watermelon/audio_chn0.aac new file mode 100755 index 0000000000000000000000000000000000000000..7a13293d952ff025530b18bb49670a522013da11 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/fruit_audio/watermelon/audio_chn0.aac differ diff --git a/vendor/zsks/demo/fruit_identify/fruit_identify.c b/vendor/zsks/demo/fruit_identify/fruit_identify.c new file mode 100755 index 0000000000000000000000000000000000000000..d79b29e479c4829dc294934ca9b7b586c381b57b --- /dev/null +++ b/vendor/zsks/demo/fruit_identify/fruit_identify.c @@ -0,0 +1,709 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * Copyright (c) 2025 Zhongshan Kuangshi Microelectronics Technology Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Modifications Author: yaohongtao (yht@cust.edu.cn) + */ + +#include +#include +#include +#include +#include +/* 新增v4l2相关头文件 */ +#include // 文件控制 +#include // 错误处理 +#include // POSIX API +#include // 字符串操作 +#include // 内存映射 +#include // IO控制 +#include // select复用 +#include // v4l2核心 + +#include "svp_acl_rt.h" +#include "svp_acl.h" +#include "svp_acl_ext.h" +#include "sample_audio.h" // 包含音频文件 +#include "audio_aac_adp.h" +#include "sdk_module_init.h" +#include "common/sample_common_svp_osd.h" // osd头文件 +#include "common/sample_common_svp.h" +#include "common/sample_common_svp_npu.h" +#include "common/sample_common_svp_npu_model.h" + +#define SAMPLE_SVP_NPU_SHAERD_WORK_BUF_NUM 1 +#define SAMPLE_SVP_NPU_YOLO_TYPE_NUM 12 +#define SAMPLE_SVP_NPU_YOLO_THRESHOLD_NUM 1 +#define SAMPLE_SVP_NPU_PATH_LEN 0x100 + +static int g_last_played_class_id = -1; +static td_bool g_svp_npu_terminate_signal = TD_FALSE; +static td_s32 g_svp_npu_dev_id = 0; +static sample_svp_npu_task_info g_svp_npu_task[SAMPLE_SVP_NPU_MAX_TASK_NUM] = {0}; +static sample_svp_npu_shared_work_buf g_svp_npu_shared_work_buf[SAMPLE_SVP_NPU_SHAERD_WORK_BUF_NUM] = {0}; + +static sample_svp_npu_threshold g_svp_npu_rfcn_threshold[SAMPLE_SVP_NPU_RFCN_THRESHOLD_NUM] = { + {0.7, 0.0, 16.0, 16.0, "rpn_data"}, {0.3, 0.9, 16.0, 16.0, "rpn_data1"} +}; + +static sample_svp_npu_threshold g_svp_npu_yolo_threshold[SAMPLE_SVP_NPU_YOLO_TYPE_NUM] = { + {0.9, 0.15, 1.0, 1.0, "rpn_data"}, // yolov8 +}; + +static sample_svp_npu_roi_info g_svp_npu_yolo_roi_info[SAMPLE_SVP_NPU_YOLO_TYPE_NUM] = { + {"output0", "output0_"}, // yolov8 +}; + +static sample_vi_cfg g_vi_config; +static ot_sample_svp_rect_info g_svp_npu_rect_info = {0}; +static td_bool g_svp_npu_thread_stop = TD_FALSE; +static pthread_t g_svp_npu_thread = 0; +static sample_vo_cfg g_svp_npu_vo_cfg = { 0 }; +static pthread_t g_svp_npu_vdec_thread = 0; +static ot_vb_pool_info g_svp_npu_vb_pool_info; +static td_void *g_svp_npu_vb_virt_addr = TD_NULL; + +static ot_sample_svp_media_cfg g_svp_npu_media_cfg = { + .svp_switch = {TD_FALSE, TD_TRUE}, + .pic_type = {PIC_1080P, PIC_CIF}, + .chn_num = OT_SVP_MAX_VPSS_CHN_NUM, +}; + +static sample_vdec_attr g_svp_npu_vdec_cfg = { + .type = OT_PT_MJPEG, + .mode = OT_VDEC_SEND_MODE_FRAME, + .width = FHD_WIDTH, + .height = FHD_HEIGHT, + .sample_vdec_picture.pixel_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_420, /* 420:pixel_format */ + .sample_vdec_picture.alpha = 0, /* 0:alpha */ + .display_frame_num = 2, /* 2:display_frame_num */ + .frame_buf_cnt = 5, /* 5:2+2+1 */ +}; + +static vdec_thread_param g_svp_npu_vdec_param = { + .chn_id = 0, + + .v4l2_device = "/dev/video0", // 摄像头设备 + .width = FHD_WIDTH, // 采集分辨率宽 + .height = FHD_HEIGHT, // 采集分辨率高 + .pixel_format = V4L2_PIX_FMT_MJPEG, // MJPEG格式 + + .type = OT_PT_MJPEG, + .stream_mode = OT_VDEC_SEND_MODE_FRAME, + .interval_time = 1000, /* 1000:interval_time */ + .pts_init = 0, + .pts_increase = 0, + .e_thread_ctrl = THREAD_CTRL_START, + .circle_send = TD_TRUE, + .milli_sec = 0, + .min_buf_size = (FHD_WIDTH * FHD_HEIGHT * 3) >> 1, /* 3:chn_size */ + .fps = 30, +}; + +// 音频线程 +typedef struct { + int class_id; +} audio_play_param; + +void* audio_play_thread(void* arg) +{ + audio_play_param* param = (audio_play_param*)arg; + td_s32 audio_ret = TD_SUCCESS; + + switch (param->class_id) { + case 0: + audio_ret = sample_audio_adec_ao("fruit_audio", "pear"); + break; + case 1: + audio_ret = sample_audio_adec_ao("fruit_audio", "watermelon"); + break; + case 2: /* 2: case of orange */ + audio_ret = sample_audio_adec_ao("fruit_audio", "orange"); + break; + case 3: /* 3: case of banana */ + audio_ret = sample_audio_adec_ao("fruit_audio", "banana"); + break; + case 4: /* 4: case of apple */ + audio_ret = sample_audio_adec_ao("fruit_audio", "apple"); + break; + default: + audio_ret = TD_SUCCESS; + break; + } + + if (audio_ret != TD_SUCCESS) { + sample_svp_trace_err("play audio failed!\n"); + } else { + sample_svp_trace_info("play audio success!\n"); + } + + free(param); // 释放参数 + return NULL; +} + +static td_void sample_svp_npu_acl_terminate(td_void) +{ + if (g_svp_npu_terminate_signal == TD_TRUE) { + printf("\033[0;31mprogram termination abnormally!\033[0;39m\n"); + } +} + +/* function : svp npu signal handle */ +td_void sample_svp_npu_acl_handle_sig(td_void) +{ + g_svp_npu_terminate_signal = TD_TRUE; +} + +static td_void sample_svp_npu_acl_deinit(td_void) +{ + svp_acl_error ret; + + ret = svp_acl_rt_reset_device(g_svp_npu_dev_id); + if (ret != SVP_ACL_SUCCESS) { + sample_svp_trace_err("reset device fail\n"); + } + sample_svp_trace_info("end to reset device is %d\n", g_svp_npu_dev_id); + + ret = svp_acl_finalize(); + if (ret != SVP_ACL_SUCCESS) { + sample_svp_trace_err("finalize acl fail\n"); + } + sample_svp_trace_info("end to finalize acl\n"); + (td_void)sample_common_svp_check_sys_exit(); +} + +static td_s32 sample_svp_npu_acl_init(const td_char *acl_config_path, td_bool vi_en) +{ + /* svp acl init */ + svp_acl_rt_run_mode run_mode; + svp_acl_error ret; + td_bool is_mpi_init; + + is_mpi_init = sample_common_svp_check_sys_init(vi_en); + sample_svp_check_exps_return(is_mpi_init != TD_TRUE, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "mpi init failed!\n"); + + ret = svp_acl_init(acl_config_path); + sample_svp_check_exps_return(ret != SVP_ACL_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "acl init failed!\n"); + + sample_svp_trace_info("svp acl init success!\n"); + + /* open device */ + ret = svp_acl_rt_set_device(g_svp_npu_dev_id); + if (ret != SVP_ACL_SUCCESS) { + (td_void)svp_acl_finalize(); + sample_svp_trace_err("svp acl open device %d failed!\n", g_svp_npu_dev_id); + return TD_FAILURE; + } + sample_svp_trace_info("open device %d success!\n", g_svp_npu_dev_id); + + /* get run mode */ + ret = svp_acl_rt_get_run_mode(&run_mode); + if ((ret != SVP_ACL_SUCCESS) || (run_mode != SVP_ACL_DEVICE)) { + (td_void)svp_acl_rt_reset_device(g_svp_npu_dev_id); + (td_void)svp_acl_finalize(); + sample_svp_trace_err("acl get run mode failed!\n"); + return TD_FAILURE; + } + sample_svp_trace_info("get run mode success!\n"); + + return TD_SUCCESS; +} + +static td_s32 sample_svp_npu_acl_dataset_init(td_u32 task_idx) +{ + td_s32 ret = sample_common_svp_npu_create_input(&g_svp_npu_task[task_idx]); + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, "create input failed!\n"); + + ret = sample_common_svp_npu_create_output(&g_svp_npu_task[task_idx]); + if (ret != TD_SUCCESS) { + sample_common_svp_npu_destroy_input(&g_svp_npu_task[task_idx]); + sample_svp_trace_err("execute create output fail.\n"); + return TD_FAILURE; + } + return TD_SUCCESS; +} + +static td_void sample_svp_npu_acl_dataset_deinit(td_u32 task_idx) +{ + (td_void)sample_common_svp_npu_destroy_input(&g_svp_npu_task[task_idx]); + (td_void)sample_common_svp_npu_destroy_output(&g_svp_npu_task[task_idx]); +} + +static td_void *sample_svp_npu_acl_thread_execute(td_void *args) +{ + td_s32 ret; + td_u32 task_idx = *(td_u32 *)args; + + ret = svp_acl_rt_set_device(g_svp_npu_dev_id); + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, + "open device %d failed!\n", g_svp_npu_dev_id); + + ret = sample_common_svp_npu_model_execute(&g_svp_npu_task[task_idx]); + if (ret != SVP_ACL_SUCCESS) { + sample_svp_trace_err("execute inference failed of task[%u]!\n", task_idx); + } + + ret = svp_acl_rt_reset_device(g_svp_npu_dev_id); + if (ret != SVP_ACL_SUCCESS) { + sample_svp_trace_err("task[%u] reset device failed!\n", task_idx); + } + return TD_NULL; +} + +static td_void sample_svp_npu_acl_model_execute_multithread() +{ + pthread_t execute_threads[SAMPLE_SVP_NPU_MAX_THREAD_NUM] = {0}; + td_u32 idx[SAMPLE_SVP_NPU_MAX_THREAD_NUM] = {0}; + td_u32 task_idx; + + for (task_idx = 0; task_idx < SAMPLE_SVP_NPU_MAX_THREAD_NUM; task_idx++) { + idx[task_idx] = task_idx; + pthread_create(&execute_threads[task_idx], NULL, sample_svp_npu_acl_thread_execute, &idx[task_idx]); + } + + td_void *waitret[SAMPLE_SVP_NPU_MAX_THREAD_NUM]; + for (task_idx = 0; task_idx < SAMPLE_SVP_NPU_MAX_THREAD_NUM; task_idx++) { + pthread_join(execute_threads[task_idx], &waitret[task_idx]); + } + + for (task_idx = 0; task_idx < SAMPLE_SVP_NPU_MAX_THREAD_NUM; task_idx++) { + sample_svp_trace_info("output %u-th task data\n", task_idx); + sample_common_svp_npu_output_classification_result(&g_svp_npu_task[task_idx]); + } +} + +static td_void sample_svp_npu_acl_deinit_task(td_u32 task_num, td_u32 shared_work_buf_idx) +{ + td_u32 task_idx; + + for (task_idx = 0; task_idx < task_num; task_idx++) { + (td_void)sample_common_svp_npu_destroy_work_buf(&g_svp_npu_task[task_idx]); + (td_void)sample_common_svp_npu_destroy_task_buf(&g_svp_npu_task[task_idx]); + (td_void)sample_svp_npu_acl_dataset_deinit(task_idx); + (td_void)memset_s(&g_svp_npu_task[task_idx], sizeof(sample_svp_npu_task_cfg), 0, + sizeof(sample_svp_npu_task_cfg)); + } + if (g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_ptr != TD_NULL) { + (td_void)svp_acl_rt_free(g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_ptr); + g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_ptr = TD_NULL; + g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_size = 0; + g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_stride = 0; + } +} + +static td_s32 sample_svp_npu_acl_create_shared_work_buf(td_u32 task_num, td_u32 shared_work_buf_idx) +{ + td_u32 task_idx; + td_u32 work_buf_size; + td_u32 work_buf_stride; + td_s32 ret; + + for (task_idx = 0; task_idx < task_num; task_idx++) { + ret = sample_common_svp_npu_get_work_buf_info(&g_svp_npu_task[task_idx], &work_buf_size, &work_buf_stride); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get %u-th task work buf info failed!\n", task_idx); + + if (g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_size < work_buf_size) { + g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_size = work_buf_size; + g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_stride = work_buf_stride; + } + } + ret = svp_acl_rt_malloc_cached(&g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_ptr, + g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_size, SVP_ACL_MEM_MALLOC_NORMAL_ONLY); + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "malloc %u-th shared work buf failed!\n", shared_work_buf_idx); + + (td_void)svp_acl_rt_mem_flush(g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_ptr, + g_svp_npu_shared_work_buf[shared_work_buf_idx].work_buf_size); + return TD_SUCCESS; +} + +static td_s32 sample_svp_npu_acl_init_task(td_u32 task_num, td_bool is_share_work_buf, + td_u32 shared_work_buf_idx) +{ + td_u32 task_idx; + td_s32 ret; + + if (is_share_work_buf == TD_TRUE) { + ret = sample_svp_npu_acl_create_shared_work_buf(task_num, shared_work_buf_idx); + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "create shared work buf failed!\n"); + } + + for (task_idx = 0; task_idx < task_num; task_idx++) { + ret = sample_svp_npu_acl_dataset_init(task_idx); + if (ret != TD_SUCCESS) { + goto task_init_end_0; + } + ret = sample_common_svp_npu_create_task_buf(&g_svp_npu_task[task_idx]); + if (ret != TD_SUCCESS) { + sample_svp_trace_err("create task buf failed.\n"); + goto task_init_end_0; + } + if (is_share_work_buf == TD_FALSE) { + ret = sample_common_svp_npu_create_work_buf(&g_svp_npu_task[task_idx]); + } else { + /* if all tasks are on the same stream, work buf can be shared */ + ret = sample_common_svp_npu_share_work_buf(&g_svp_npu_shared_work_buf[shared_work_buf_idx], + &g_svp_npu_task[task_idx]); + } + if (ret != TD_SUCCESS) { + sample_svp_trace_err("create work buf failed.\n"); + goto task_init_end_0; + } + } + return TD_SUCCESS; + +task_init_end_0: + (td_void)sample_svp_npu_acl_deinit_task(task_num, shared_work_buf_idx); + return ret; +} + +// 辅助函数:根据class_id播放音频(如果类别发生变化) +static void play_audio_if_class_changed(void) +{ + int max_idx = -1; + double max_score = 0.5; + + // 检测到目标时,启动音频播放线程 + for (int i = 0; i < g_svp_npu_rect_info.num; i++) { + if (g_svp_npu_rect_info.rect[i].score >= max_score) { + if (max_idx == -1 || g_svp_npu_rect_info.rect[i].score > g_svp_npu_rect_info.rect[max_idx].score) { + max_idx = i; + } + } + } + // ...existing code... + if (max_idx != -1) { + int current_class_id = g_svp_npu_rect_info.rect[max_idx].class_id; + if (current_class_id != g_last_played_class_id) { + pthread_t audio_thread; + audio_play_param* param = malloc(sizeof(audio_play_param)); + if (param != NULL) { + param->class_id = current_class_id; + pthread_create(&audio_thread, NULL, audio_play_thread, param); + pthread_detach(audio_thread); // 不阻塞主流程 + g_last_played_class_id = current_class_id; // 只在播放时更新 + } + } + } +} + +static void get_detection_results(void) +{ + // 循环打印置信度和类别ID + for (int i = 0; i < g_svp_npu_rect_info.num; i++) { + const char* class_name = NULL; + switch (g_svp_npu_rect_info.rect[i].class_id) { + case 0: + class_name = "梨子"; + break; + case 1: + class_name = "西瓜"; + break; + case 2: /* 2: case of orange */ + class_name = "橘子"; + break; + case 3: /* 3: case of banana */ + class_name = "香蕉"; + break; + case 4: /* 4: case of apple */ + class_name = "苹果"; + break; + default: + class_name = "未知"; + break; + } + printf("score:%lf, class_id:%d, name:%s\r\n", + g_svp_npu_rect_info.rect[i].score, + g_svp_npu_rect_info.rect[i].class_id, + class_name); + } +} + +static td_s32 sample_svp_npu_acl_frame_proc(const ot_video_frame_info *ext_frame, + const ot_video_frame_info *base_frame, td_void *args) +{ + td_s32 ret; + td_void *virt_addr = TD_NULL; + sample_svp_npu_detection_info *detection_info = TD_NULL; + sample_svp_npu_thread_args *thread_args = (sample_svp_npu_thread_args *)args; + td_u32 size = (td_u32)(ext_frame->video_frame.height * ext_frame->video_frame.stride[0] * + SAMPLE_SVP_NPU_IMG_THREE_CHN / SAMPLE_SVP_NPU_DOUBLE); + + virt_addr = g_svp_npu_vb_virt_addr + + (ext_frame->video_frame.phys_addr[0] - g_svp_npu_vb_pool_info.pool_phy_addr); + ret = sample_common_svp_npu_update_input_data_buffer_info(virt_addr, size, + ext_frame->video_frame.stride[0], 0, &g_svp_npu_task[0]); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "update data buffer failed!\n"); + + ret = sample_common_svp_npu_model_execute(&g_svp_npu_task[0]); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "model execute failed!\n"); + + play_audio_if_class_changed(); + + // ...existing code... + if (thread_args->model_name == SAMPLE_SVP_NPU_RFCN || thread_args->model_name == SAMPLE_SVP_NPU_YOLO) { + detection_info = thread_args->detection_info; + if (detection_info->is_cpu_rpn == TD_FALSE) { + ret = sample_common_svp_npu_roi_to_rect(&g_svp_npu_task[0], detection_info, ext_frame, base_frame, + &g_svp_npu_rect_info); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "roi to rect failed!\n"); + } else { + ret = sample_common_svp_npu_roi_to_rect_cpu(&g_svp_npu_task[0], detection_info, ext_frame, base_frame, + &g_svp_npu_rect_info); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "roi to rect failed!\n"); + } + ret = sample_common_svp_vgs_fill_rect(base_frame, &g_svp_npu_rect_info, SAMPLE_SVP_NPU_RECT_COLOR); + sample_svp_check_exps_return(ret != TD_SUCCESS, ret, SAMPLE_SVP_ERR_LEVEL_ERROR, "vgs fill rect failed!\n"); + + // 在屏幕上打印信息检测到的水果信息 + int i; + for (i = 0; i < (g_svp_npu_rect_info.num); i++) { + sample_osd_draw_text(g_svp_npu_rect_info.rect[i].score, g_svp_npu_rect_info.rect[i].class_id, + g_svp_npu_rect_info.rect[i].point[0].x, g_svp_npu_rect_info.rect[i].point[0].y, + thread_args->mpp_osd_info); + } + if (g_svp_npu_rect_info.num == 0) { + thread_args->mpp_osd_info.chn_attr.is_show = TD_FALSE; + sample_osd_clean_text(thread_args->mpp_osd_info); + } + } + get_detection_results(); + + return ret; +} + +static td_s32 sample_svp_npu_acl_vb_map(td_u32 vb_pool_idx) +{ + td_s32 ret; + + if (g_svp_npu_vb_virt_addr == TD_NULL) { + ret = ss_mpi_vb_get_pool_info(g_svp_npu_media_cfg.vb_pool[vb_pool_idx], &g_svp_npu_vb_pool_info); + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get pool info failed!\n"); + g_svp_npu_vb_virt_addr = ss_mpi_sys_mmap(g_svp_npu_vb_pool_info.pool_phy_addr, + g_svp_npu_vb_pool_info.pool_size); + sample_svp_check_exps_return(g_svp_npu_vb_virt_addr == TD_NULL, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "map vb pool failed!\n"); + } + return TD_SUCCESS; +} + +static td_void *sample_svp_npu_acl_vdec_to_vo(td_void *args) +{ + td_s32 ret; + ot_video_frame_info base_frame; + ot_video_frame_info ext_frame; + const td_s32 milli_sec = SAMPLE_SVP_NPU_MILLIC_SEC; + const ot_vo_layer vo_layer = 0; + const ot_vo_chn vo_chn = 0; + const td_s32 vpss_grp = 0; + td_s32 vpss_chn[] = { OT_VPSS_CHN0, OT_VPSS_CHN1 }; + td_u32 size; + td_u32 stride; + td_u8 *data = TD_NULL; + + (td_void)prctl(PR_SET_NAME, "svp_npu_vdec_to_vo", 0, 0, 0); + + ret = svp_acl_rt_set_device(g_svp_npu_dev_id); + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_NULL, SAMPLE_SVP_ERR_LEVEL_ERROR, "open device failed!\n"); + + ret = sample_svp_npu_acl_vb_map(OT_VPSS_CHN1); + sample_svp_check_exps_goto(ret != TD_SUCCESS, fail_0, SAMPLE_SVP_ERR_LEVEL_ERROR, "map vb pool failed!\n"); + + ret = sample_common_svp_npu_get_input_data_buffer_info(&g_svp_npu_task[0], 0, &data, &size, &stride); + sample_svp_check_exps_goto(ret != TD_SUCCESS, fail_1, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),get_input_data_buffer_info failed!\n", ret); + + while (g_svp_npu_thread_stop == TD_FALSE) { + ret = ss_mpi_vpss_get_chn_frame(vpss_grp, vpss_chn[1], &ext_frame, milli_sec); + sample_svp_check_exps_continue(ret != TD_SUCCESS, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),ss_mpi_vpss_get_chn_frame failed, vpss_grp(%d), vpss_chn(%d)!\n", ret, vpss_grp, vpss_chn[1]); + + ret = ss_mpi_vpss_get_chn_frame(vpss_grp, vpss_chn[0], &base_frame, milli_sec); + sample_svp_check_exps_goto(ret != TD_SUCCESS, ext_release, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),ss_mpi_vpss_get_chn_frame failed, VPSS_GRP(%d), VPSS_CHN(%d)!\n", ret, vpss_grp, vpss_chn[0]); + + ret = sample_svp_npu_acl_frame_proc(&ext_frame, &base_frame, args); + sample_svp_check_exps_goto(ret != TD_SUCCESS, base_release, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_svp_npu_acl_frame_proc failed!\n", ret); + + ret = sample_common_svp_venc_vo_send_stream(&g_svp_npu_media_cfg.svp_switch, 0, vo_layer, vo_chn, &base_frame); + sample_svp_check_exps_goto(ret != TD_SUCCESS, base_release, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),sample_common_svp_venc_vo_send_stream failed!\n", ret); +base_release: + ret = ss_mpi_vpss_release_chn_frame(vpss_grp, vpss_chn[0], &base_frame); + sample_svp_check_exps_trace(ret != TD_SUCCESS, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),release_frame failed,grp(%d) chn(%d)!\n", ret, vpss_grp, vpss_chn[0]); +ext_release: + ret = ss_mpi_vpss_release_chn_frame(vpss_grp, vpss_chn[1], &ext_frame); + sample_svp_check_exps_trace(ret != TD_SUCCESS, SAMPLE_SVP_ERR_LEVEL_ERROR, + "Error(%#x),release_frame failed,grp(%d) chn(%d)!\n", ret, vpss_grp, vpss_chn[1]); + } + ret = sample_common_svp_npu_update_input_data_buffer_info(data, size, stride, 0, &g_svp_npu_task[0]); + sample_svp_check_exps_trace(ret != TD_SUCCESS, SAMPLE_SVP_ERR_LEVEL_ERROR, "update buffer failed!\n"); +fail_1: + (td_void)ss_mpi_sys_munmap(g_svp_npu_vb_virt_addr, g_svp_npu_vb_pool_info.pool_size); +fail_0: + (td_void)svp_acl_rt_reset_device(g_svp_npu_dev_id); + return TD_NULL; +} + +static td_void sample_svp_npu_acl_pause(td_void) +{ + printf("---------------press Enter key to exit!---------------\n"); + if (g_svp_npu_terminate_signal == TD_TRUE) { + return; + } + (td_void)getchar(); + if (g_svp_npu_terminate_signal == TD_TRUE) { + return; + } +} + +static td_void sample_svp_npu_acl_set_task_info(td_u32 model_idx) +{ + g_svp_npu_task[0].cfg.max_batch_num = 1; + g_svp_npu_task[0].cfg.dynamic_batch_num = 1; + g_svp_npu_task[0].cfg.total_t = 0; + g_svp_npu_task[0].cfg.is_cached = TD_TRUE; + g_svp_npu_task[0].cfg.model_idx = model_idx; +} + +static td_void sample_svp_npu_acl_set_detection_info(sample_svp_npu_detection_info *detection_info, td_u32 index, + td_bool is_cpu_rpn) +{ + detection_info->num_name = g_svp_npu_yolo_roi_info[index].roi_num_name; + detection_info->roi_name = g_svp_npu_yolo_roi_info[index].roi_class_name; + detection_info->has_background = TD_FALSE; + detection_info->is_cpu_rpn = is_cpu_rpn; + detection_info->idx = index; + /* use PIC_BUTT to be a flag, get the input resolution form om */ + g_svp_npu_media_cfg.pic_type[1] = PIC_BUTT; + g_svp_npu_terminate_signal = TD_FALSE; +} + +static void sample_svp_audio_init() +{ + // 初始化音频编解码器 + ss_mpi_aenc_aac_init(); + ss_mpi_adec_aac_init(); +} + +static void sample_svp_audio_exit() +{ + // 反初始化音频 + ss_mpi_aenc_aac_deinit(); + ss_mpi_adec_aac_deinit(); +} + +/* 处理线程管理模块 */ +static td_s32 start_processing_thread(sample_svp_npu_thread_args *args) +{ + td_s32 ret; + + ret = sample_common_svp_npu_set_threshold(&g_svp_npu_yolo_threshold[0], + SAMPLE_SVP_NPU_YOLO_THRESHOLD_NUM, &g_svp_npu_task[0]); + + sample_svp_audio_init(); + g_svp_npu_thread_stop = TD_FALSE; + + ret = pthread_create(&g_svp_npu_thread, 0, sample_svp_npu_acl_vdec_to_vo, (td_void*)args); + + return TD_SUCCESS; +} + +/* function : show the sample of yolo. RPN processed by npu */ +td_void sample_svp_npu_acl_yolo_npu(void) +{ + td_s32 ret; + ot_mpp_chn chn; + td_s32 handle; + const td_u32 model_idx = 0; + const td_char *om_model_path = "./data/model/fruit_identify.om"; + sample_svp_npu_detection_info detection_info = {0}; + sample_svp_npu_thread_args args = {SAMPLE_SVP_NPU_YOLO, &detection_info}; + + sample_svp_npu_acl_set_detection_info(&detection_info, 0, TD_FALSE); + + if (g_svp_npu_terminate_signal == TD_FALSE) { + /* init acl */ + ret = sample_svp_npu_acl_init(TD_NULL, TD_FALSE); + sample_svp_check_exps_return_void(ret != TD_SUCCESS, SAMPLE_SVP_ERR_LEVEL_ERROR, "init failed!\n"); + + /* load model */ + ret = sample_common_svp_npu_load_model(om_model_path, model_idx, TD_FALSE); + sample_svp_check_exps_goto(ret != TD_SUCCESS, process_end0, SAMPLE_SVP_ERR_LEVEL_ERROR, + "load model failed!\n"); + + /* get input resolution */ + ret = sample_common_svp_npu_get_input_resolution(model_idx, 0, &g_svp_npu_media_cfg.pic_size[1]); + sample_svp_check_exps_goto(ret != TD_SUCCESS, process_end1, SAMPLE_SVP_ERR_LEVEL_ERROR, + "load model failed!\n"); + + /* start vdec vpss venc vo */ + ret = sample_common_svp_create_vb_start_vdec_vpss_vo(&g_svp_npu_vdec_cfg, &g_svp_npu_vdec_param, + &g_svp_npu_vdec_thread, &g_svp_npu_media_cfg, &g_svp_npu_vo_cfg); + sample_svp_check_exps_goto(ret != TD_SUCCESS, process_end1, SAMPLE_SVP_ERR_LEVEL_DEBUG, + "init media failed!\n"); + + // osd init + sample_osd_init(&args.mpp_osd_info); + + /* set cfg */ + sample_svp_npu_acl_set_task_info(model_idx); + + ret = sample_svp_npu_acl_init_task(1, TD_FALSE, 0); + sample_svp_check_exps_goto(ret != TD_SUCCESS, process_end2, SAMPLE_SVP_ERR_LEVEL_ERROR, "init task failed!\n"); + } + /* process */ + if (g_svp_npu_terminate_signal == TD_FALSE) { + // 处理线程启动 + ret = start_processing_thread(&args); + sample_svp_check_exps_goto(ret != 0, process_end3, SAMPLE_SVP_ERR_LEVEL_ERROR, "create thread failed!\n"); + + (td_void)sample_svp_npu_acl_pause(); + + g_svp_npu_thread_stop = TD_TRUE; + pthread_join(g_svp_npu_thread, TD_NULL); + } + +process_end3: + (td_void)sample_svp_npu_acl_deinit_task(1, 0); +process_end2: + sample_osd_exit(&args.mpp_osd_info); + (td_void)sample_common_svp_destroy_vb_stop_vdec_vpss_vo(&g_svp_npu_vdec_param, &g_svp_npu_vdec_thread, + &g_svp_npu_media_cfg, &g_svp_npu_vo_cfg); +process_end1: + (td_void)sample_common_svp_npu_unload_model(model_idx); +process_end0: + (td_void)sample_svp_npu_acl_deinit(); + (td_void)sample_svp_npu_acl_terminate(); + sample_svp_audio_exit(); +} + +int main(void) +{ +#ifdef CONFIG_USER_SPACE + SDK_init(); +#endif + sample_svp_npu_acl_yolo_npu(); +#ifdef CONFIG_USER_SPACE + SDK_exit(); +#endif + + return 0; +} diff --git a/vendor/zsks/demo/fruit_identify/pic/image-20221114150205685.png b/vendor/zsks/demo/fruit_identify/pic/image-20221114150205685.png new file mode 100755 index 0000000000000000000000000000000000000000..4dc4215c962c57ba0e31548fb98c29c789f149d9 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/pic/image-20221114150205685.png differ diff --git a/vendor/zsks/demo/fruit_identify/pic/image-20250210161601541.png b/vendor/zsks/demo/fruit_identify/pic/image-20250210161601541.png new file mode 100755 index 0000000000000000000000000000000000000000..80845ece8131933a4cd56ae3bd6119c38e0abd26 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/pic/image-20250210161601541.png differ diff --git a/vendor/zsks/demo/fruit_identify/pic/image-20250210170027454.png b/vendor/zsks/demo/fruit_identify/pic/image-20250210170027454.png new file mode 100755 index 0000000000000000000000000000000000000000..c06081fc2c963af4d1fa8af506804beedefe1b0b Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/pic/image-20250210170027454.png differ diff --git a/vendor/zsks/demo/fruit_identify/pic/image-20250213112932380.png b/vendor/zsks/demo/fruit_identify/pic/image-20250213112932380.png new file mode 100755 index 0000000000000000000000000000000000000000..8b591b3437544859f4ec76b9ca03867cc401078c Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/pic/image-20250213112932380.png differ diff --git a/vendor/zsks/demo/fruit_identify/pic/image-20250919150630870.png b/vendor/zsks/demo/fruit_identify/pic/image-20250919150630870.png new file mode 100755 index 0000000000000000000000000000000000000000..91f881e85b3292118336ce2c3d81968e4aee8c26 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/pic/image-20250919150630870.png differ diff --git a/vendor/zsks/demo/fruit_identify/pic/image-20250919151018659.png b/vendor/zsks/demo/fruit_identify/pic/image-20250919151018659.png new file mode 100755 index 0000000000000000000000000000000000000000..9b09507893b65d2142be49e6461daa31a81855c4 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/pic/image-20250919151018659.png differ diff --git a/vendor/zsks/demo/fruit_identify/pic/image-20250919151519310.png b/vendor/zsks/demo/fruit_identify/pic/image-20250919151519310.png new file mode 100755 index 0000000000000000000000000000000000000000..7f6d881a5d0e6d3f72b7a43d089b5c5a75d7f048 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/pic/image-20250919151519310.png differ diff --git a/vendor/zsks/demo/fruit_identify/pic/image-20250919173612332.png b/vendor/zsks/demo/fruit_identify/pic/image-20250919173612332.png new file mode 100755 index 0000000000000000000000000000000000000000..7d412e9790e77c051e4de9ee7caf93f440cf4348 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/pic/image-20250919173612332.png differ diff --git a/vendor/zsks/demo/fruit_identify/pic/image-20250919180706355.png b/vendor/zsks/demo/fruit_identify/pic/image-20250919180706355.png new file mode 100755 index 0000000000000000000000000000000000000000..ba4971e35c5cdaaf64386cebfa6a896383e61c7d Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/pic/image-20250919180706355.png differ diff --git a/vendor/zsks/demo/fruit_identify/pic/image-20251023103457181.png b/vendor/zsks/demo/fruit_identify/pic/image-20251023103457181.png new file mode 100755 index 0000000000000000000000000000000000000000..88b9ef12b22044790ffea9b20b9829e7b88d1792 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/pic/image-20251023103457181.png differ diff --git a/vendor/zsks/demo/fruit_identify/pic/image-20251023103623167.png b/vendor/zsks/demo/fruit_identify/pic/image-20251023103623167.png new file mode 100755 index 0000000000000000000000000000000000000000..f19b0fc1e3a19b42eebcd8202cdf8fd1d408c6f1 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/pic/image-20251023103623167.png differ diff --git a/vendor/zsks/demo/fruit_identify/pic/image-20251023103700404.png b/vendor/zsks/demo/fruit_identify/pic/image-20251023103700404.png new file mode 100755 index 0000000000000000000000000000000000000000..1d46490b430a11ceab5efbcae4e90690b6850fd5 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/pic/image-20251023103700404.png differ diff --git a/vendor/zsks/demo/fruit_identify/pic/image-20251023103850695.png b/vendor/zsks/demo/fruit_identify/pic/image-20251023103850695.png new file mode 100755 index 0000000000000000000000000000000000000000..f7266d4498a5b248efe056d3da9238bc0616dd27 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/pic/image-20251023103850695.png differ diff --git a/vendor/zsks/demo/fruit_identify/pic/image-20251023103944837.png b/vendor/zsks/demo/fruit_identify/pic/image-20251023103944837.png new file mode 100755 index 0000000000000000000000000000000000000000..f7d3b45140ff5f6eef00ea2e80bf5ce366a20793 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/pic/image-20251023103944837.png differ diff --git a/vendor/zsks/demo/fruit_identify/pic/image-20251023110809454.png b/vendor/zsks/demo/fruit_identify/pic/image-20251023110809454.png new file mode 100755 index 0000000000000000000000000000000000000000..4a0801ed60ba0dd2747ea0c163d402d046a3bcc2 Binary files /dev/null and b/vendor/zsks/demo/fruit_identify/pic/image-20251023110809454.png differ diff --git a/vendor/zsks/demo/fruit_identify/sample_audio.c b/vendor/zsks/demo/fruit_identify/sample_audio.c new file mode 100755 index 0000000000000000000000000000000000000000..22d334818f0b025fb71e80c4ec8196f06ea0bc8e --- /dev/null +++ b/vendor/zsks/demo/fruit_identify/sample_audio.c @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "sample_comm.h" +#include "audio_aac_adp.h" +#include "audio_dl_adp.h" +#include "ot_resample.h" + +#include "sample_audio.h" + +static ot_payload_type g_payload_type = OT_PT_AAC; +static td_bool g_aio_resample = TD_FALSE; +static ot_audio_sample_rate g_in_sample_rate = OT_AUDIO_SAMPLE_RATE_BUTT; +static ot_audio_sample_rate g_out_sample_rate = OT_AUDIO_SAMPLE_RATE_BUTT; + +#define sample_dbg(ret) \ + do { \ + printf("ret = %#x, fuc:%s, line:%d\n", ret, __FUNCTION__, __LINE__); \ + } while (0) + +#define sample_res_check_null_ptr(ptr) \ + do { \ + if ((td_u8*)(ptr) == TD_NULL) { \ + printf("ptr is TD_NULL,fuc:%s,line:%d\n", __FUNCTION__, __LINE__); \ + return TD_FAILURE; \ + } \ + } while (0) + +/* function : PT number to string */ +static char *sample_audio_pt2_str(ot_payload_type type) +{ + if (type == OT_PT_G711A) { + return "g711a"; + } else if (type == OT_PT_G711U) { + return "g711u"; + } else if (type == OT_PT_ADPCMA) { + return "adpcm"; + } else if (type == OT_PT_G726) { + return "g726"; + } else if (type == OT_PT_LPCM) { + return "pcm"; + } else if (type == OT_PT_AAC) { + return "aac"; + } else { + return "data"; + } +} + +/* function : open adec file */ +static FILE *sample_audio_open_adec_file(ot_adec_chn ad_chn, ot_payload_type type, + const td_char *file_name1, const td_char *file_name2) +{ + FILE *fd = TD_NULL; + td_char asz_file_name[FILE_NAME_LEN] = {0}; + td_s32 ret; + td_char path[PATH_MAX] = {0}; + + /* create file for save stream */ +#ifdef __LITEOS__ + ret = snprintf_s(asz_file_name, FILE_NAME_LEN, FILE_NAME_LEN - 1, + "/sharefs/audio_chn%d.%s", ad_chn, sample_audio_pt2_str(type)); +#else + ret = snprintf_s(asz_file_name, FILE_NAME_LEN, FILE_NAME_LEN - 1, + "%s/%s/audio_chn%d.%s", file_name1, file_name2, ad_chn, sample_audio_pt2_str(type)); +#endif + if (ret < 0) { + printf("[func]:%s [line]:%d [info]:%s\n", __FUNCTION__, __LINE__, "get adec file name failed"); + return TD_NULL; + } + + if (asz_file_name[0] == '\0') { + printf("[func]:%s [line]:%d [info]:%s\n", __FUNCTION__, __LINE__, "adec file name is NULL"); + return TD_NULL; + } + + if (strlen(asz_file_name) > (FILE_NAME_LEN - 1)) { + printf("[func]:%s [line]:%d [info]:%s\n", __FUNCTION__, __LINE__, "adec file name extra long"); + return TD_NULL; + } + + if (realpath(asz_file_name, path) == TD_NULL) { + printf("[func]:%s [line]:%d [info]:%s\n", __FUNCTION__, __LINE__, "adec file name realpath fail"); + return TD_NULL; + } + + fd = fopen(path, "rb"); + if (fd == NULL) { + printf("%s: open file %s failed\n", __FUNCTION__, asz_file_name); + return NULL; + } + printf("open stream file:\"%s\" for adec ok\n", asz_file_name); + return fd; +} + +static td_void sample_audio_adec_ao_init_param(ot_aio_attr *aio_attr, ot_audio_dev *ao_dev) +{ + aio_attr->sample_rate = OT_AUDIO_SAMPLE_RATE_48000; + aio_attr->bit_width = OT_AUDIO_BIT_WIDTH_16; + aio_attr->work_mode = OT_AIO_MODE_I2S_MASTER; + aio_attr->snd_mode = OT_AUDIO_SOUND_MODE_STEREO; + aio_attr->expand_flag = 0; + aio_attr->frame_num = 30; /* 30:frame num */ + if (g_payload_type == OT_PT_AAC) { + aio_attr->point_num_per_frame = AACLC_SAMPLES_PER_FRAME; + } else { + aio_attr->point_num_per_frame = SAMPLE_AUDIO_POINT_NUM_PER_FRAME; + } + aio_attr->chn_cnt = 2; /* 2:chn num */ +#ifdef OT_ACODEC_TYPE_INNER + *ao_dev = SAMPLE_AUDIO_INNER_AO_DEV; + aio_attr->clk_share = 1; + aio_attr->i2s_type = OT_AIO_I2STYPE_INNERCODEC; +#else + *ao_dev = SAMPLE_AUDIO_EXTERN_AO_DEV; + aio_attr->clk_share = 1; + aio_attr->i2s_type = OT_AIO_I2STYPE_EXTERN; +#endif + g_aio_resample = TD_FALSE; + g_in_sample_rate = OT_AUDIO_SAMPLE_RATE_BUTT; + g_out_sample_rate = OT_AUDIO_SAMPLE_RATE_BUTT; +} + +td_void sample_audio_adec_ao_inner(ot_audio_dev ao_dev, ot_ao_chn ao_chn, ot_adec_chn ad_chn, + const td_char *file_name1, const td_char *file_name2) +{ + td_s32 ret; + FILE *fd = NULL; + + ret = sample_comm_audio_ao_bind_adec(ao_dev, ao_chn, ad_chn); + if (ret != TD_SUCCESS) { + sample_dbg(ret); + return; + } + + fd = sample_audio_open_adec_file(ad_chn, g_payload_type, file_name1, file_name2); + if (fd == TD_NULL) { + sample_dbg(TD_FAILURE); + goto adec_ao_err0; + } + + ret = sample_comm_audio_creat_trd_file_adec(ad_chn, fd); + if (ret != TD_SUCCESS) { + sample_dbg(ret); + fclose(fd); + fd = TD_NULL; + goto adec_ao_err0; + } + + printf("bind adec:%d to ao(%d,%d) ok \n", ad_chn, ao_dev, ao_chn); + + sleep(2); /* 2: sleep 2 seconds */ + + ret = sample_comm_audio_destory_trd_file_adec(ad_chn); + if (ret != TD_SUCCESS) { + sample_dbg(ret); + } + +adec_ao_err0: + ret = sample_comm_audio_ao_unbind_adec(ao_dev, ao_chn, ad_chn); + if (ret != TD_SUCCESS) { + sample_dbg(ret); + } + + return; +} + +/* function : file -> adec -> ao */ +td_s32 sample_audio_adec_ao(const td_char *file_name1, const td_char *file_name2) +{ + td_s32 ret; + td_u32 ao_chn_cnt; + td_u32 adec_chn_cnt; + ot_audio_dev ao_dev; + ot_aio_attr aio_attr; + const ot_ao_chn ao_chn = 0; + const ot_adec_chn ad_chn = 0; + + sample_audio_adec_ao_init_param(&aio_attr, &ao_dev); + + adec_chn_cnt = aio_attr.chn_cnt >> ((td_u32)aio_attr.snd_mode); + ret = sample_comm_audio_start_adec(adec_chn_cnt, g_payload_type); + if (ret != TD_SUCCESS) { + sample_dbg(ret); + goto adec_ao_err3; + } + + ao_chn_cnt = aio_attr.chn_cnt; + ret = sample_comm_audio_start_ao(ao_dev, ao_chn_cnt, &aio_attr, g_in_sample_rate, g_aio_resample); + if (ret != TD_SUCCESS) { + sample_dbg(ret); + goto adec_ao_err2; + } + + ret = sample_comm_audio_cfg_acodec(&aio_attr); + if (ret != TD_SUCCESS) { + sample_dbg(ret); + goto adec_ao_err1; + } + + sample_audio_adec_ao_inner(ao_dev, ao_chn, ad_chn, file_name1, file_name2); + +adec_ao_err1: + ret = sample_comm_audio_stop_ao(ao_dev, ao_chn_cnt, g_aio_resample); + if (ret != TD_SUCCESS) { + sample_dbg(ret); + } + +adec_ao_err2: + ret = sample_comm_audio_stop_adec(ad_chn); + if (ret != TD_SUCCESS) { + sample_dbg(ret); + } + +adec_ao_err3: + return ret; +} \ No newline at end of file diff --git a/vendor/zsks/demo/fruit_identify/sample_audio.h b/vendor/zsks/demo/fruit_identify/sample_audio.h new file mode 100755 index 0000000000000000000000000000000000000000..ebb5b5babcfbd3795ee222442abad02c792fec35 --- /dev/null +++ b/vendor/zsks/demo/fruit_identify/sample_audio.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __SAMPLE_AUDIO_ADEC_AO_H__ +#define __SAMPLE_AUDIO_ADEC_AO_H__ + +#include "sample_comm.h" + +td_s32 sample_audio_adec_ao(const td_char *file_name1, const td_char *file_name2); + + +#endif /* __SAMPLE_AUDIO_ADEC_AO_H__ */ \ No newline at end of file diff --git a/vendor/zsks/demo/hnr_auto/Makefile b/vendor/zsks/demo/hnr_auto/Makefile new file mode 100755 index 0000000000000000000000000000000000000000..1496407428b58b5df5856f4e7d161260a51aca4c --- /dev/null +++ b/vendor/zsks/demo/hnr_auto/Makefile @@ -0,0 +1,45 @@ +# 编译所需的公共文件 +include ../mk.param + +# 编译后生成的可执行文件名 +TARGET := hnr_auto + +# 编译此工程需要包含的头文件 +CFLAGS += -I$(SDK_LINUX_INCLUDE_DIR)/ +CFLAGS += -I$(SDK_SAMPLE_COMMON_DIR)/ + +# 编译此工程需要依赖的.c或.cpp文件 +SMP_SRCS := $(SDK_SAMPLE_COMMON_DIR)/sample_comm_sys.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_ipc.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_isp.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vi.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vo.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_mipi_tx.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vpss.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/loadbmp.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vdec.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_venc.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sdk_init.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sdk_exit.c +SMP_SRCS += $(HNR_AUTO_SAMPLE_DIR)/sample_hnr.c + +# 编译此工程需要包含的库和宏 +MPI_LIBS += $(SDK_LINUX_OUT_LIB)/libss_pqp.a +MPI_LIBS += $(SDK_LINUX_OUT_LIB)/libss_hnr.a +CFLAGS += -O3 -g -Wall -DSAMPLE_HNR_SUPPORT +CFLAGS += -fstack-protector-strong + +# 根据实际的类型设置,可以用set_sensor脚本设置 +SENSOR0_TYPE = -DSENSOR0_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT +SENSOR1_TYPE = -DSENSOR1_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT +SENSOR2_TYPE = -DSENSOR1_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT +SENSOR3_TYPE = -DSENSOR1_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT + +CFLAGS += $(SENSOR0_TYPE) +CFLAGS += $(SENSOR1_TYPE) +CFLAGS += $(SENSOR2_TYPE) +CFLAGS += $(SENSOR3_TYPE) +# 编译工程所需的mk文件 + +include ../sdk_linux.mk + diff --git a/vendor/zsks/demo/hnr_auto/README.md b/vendor/zsks/demo/hnr_auto/README.md new file mode 100755 index 0000000000000000000000000000000000000000..bda713a1a7ac7fb7945feb5db6c53313d6bb3014 --- /dev/null +++ b/vendor/zsks/demo/hnr_auto/README.md @@ -0,0 +1,136 @@ +## 2.2、hnr_auto操作指导 + +### 2.2.1、hnr_auto程序简介 + +* hnr_auto 基于SS928V100平台开发,以EulerPi套件为例,hnr_auto 是基于海思的hnr案例,实现夜间超微光的功能,当外接ISO到达一定阈值是,自动切换到hnr模型,使得在黑暗条件下也能清楚看到画面。 + +### 2.2.2、目录 + +```shell +pegasus/vendor/zsks/demo/hnr_auto +|── Makefile # 编译脚本 +|── readme.txt # hnr的操作说明 +└──hnr_auto.c # hnr_auto业务代码 +``` + +![image-20250919192904220](pic/image-20250919192904220.png) + +### 2.2.3、编译 + +* **注意:在编译zsks的demo之前,请确保你已经按照[patch介绍中的步骤](../../README.md#4patch介绍)把补丁打入海思SDK的sample目录下了**。 + +* 步骤1:先根据自己选择的操作系统,进入到对应的Pegasus所在目录下。 + +* 步骤2:使用Makefile的方式进行单编 + +* 在Ubuntu的命令行终端,分步执行下面的命令,单编 hnr_auto + + ``` + cd ../../../../../../../vendor/zsks/demo/hnr_auto/ + + make clean && make + ``` + + ![image-20251030143349837](pic/image-20251030143349837.png) + + * 在hnr_auto/out目录下,生成一个名为main的 可执行文件,如下图所示: + + ![image-20251030143505034](pic/image-20251030143505034.png) + +### 2.2.4、拷贝可执行程序和依赖文件至开发板的mnt目录下 + +**方式一:使用SD卡进行资料文件的拷贝** + +* 首先需要自己准备一张Micro sd卡(16G 左右即可),还得有一个Micro sd卡的读卡器。 + +image-20221114150205685 + +* 步骤1:将编译后生成的可执行文件拷贝到SD卡中。 +* 步骤2:将ss928v100_clang/smp/a55_linux/mpp/sample/hnr/目录下的cfg模型文件拷贝到SD卡中。 + +![image-20251030144458528](pic/image-20251030144458528.png) + +* 步骤3:可执行文件拷贝成功后,将内存卡插入开发板的SD卡槽中,可通过挂载的方式挂载到板端,可选择SD卡 mount指令进行挂载。 + +image-20250210161601541 + +* 在开发板的终端,执行下面的命令进行SD卡的挂载 + * 如果挂载失败,可以参考[这个issue尝试解决](https://gitee.com/HiSpark/HiSpark_NICU2022/issues/I54932?from=project-issue) + + +```shell +mount -t vfat /dev/mmcblk1p1 /mnt +# 其中/dev/mmcblk1p1需要根据实际块设备号修改 +``` + +* 挂载成功后,如下图所示: + +![image-20251030150209706](pic/image-20251030150209706.png) + +**方式二:使用NFS挂载的方式进行资料文件的拷贝** + +* 首先需要自己准备一根网线 +* 步骤1:参考[博客链接](https://blog.csdn.net/Wu_GuiMing/article/details/115872995?spm=1001.2014.3001.5501)中的内容,进行nfs的环境搭建 +* 步骤2:将编译后生成的可执行文件拷贝到Windows的nfs共享路径下 +* 步骤2:将ss928v100_clang/smp/a55_linux/mpp/sample/hnr/目录下的cfg模型文件拷贝到Windows的nfs共享路径下 + +![image-20251030144417819](pic/image-20251030144417819.png) + +* 步骤3:在开发板的终端执行下面的命令,将Windows的nfs共享路径挂载至开发板的mnt目录下 + * 注意:这里IP地址请根据你开发板和电脑主机的实际IP地址进行填写 + + +``` +ifconfig eth0 192.168.100.100 + +mount -o nolock,addr=192.168.100.10 -t nfs 192.168.100.10:/d/nfs /mnt +``` + +![image-20251030150312214](pic/image-20251030150312214.png) + +### 2.2.5、硬件连接 + +* 准备一个外接显示器和HDMI数据线,将HDMI的一头接在开发板的HDMI输出口,将HDMI的另外一头接在外接显示器的HDMI输入口。 + +![image-20250213112932380](pic/image-20250213112932380.png) + +* 将摄像头与sensor板进行连接,然后将sensor板接在EulerPi开发板上。 + +![image-20250213113543142](pic/image-20250213113543142.png) + +### 2.2.6、功能验证 + +* 在开发板的终端执行下面的命令,运行可执行文件 + +``` +cd /mnt/ + +chmod +x main + +./main 0 +``` + +![image-20251030150411696](pic/image-20251030150411696.png) + +* 此时,在HDMI的外接显示屏上即可出现实时码流,如下图所示: + +image-20250210170027454 + +* 如果您看到的现象和下图现象不一致,可以确认一下镜头盖是否未取下来。 +* 如果您看到的画面是非常模糊的,您可以尝试左右拧动镜头,进行手动对焦,直到画面清晰。 + +* 当我们把摄像头置于暗光环境下,当ISO值达到一定阈值后,就会调用AIISP的HNR模型,使得在暗光条件下也能看清画面。 + +* HNR关闭状态 + + ![image-20250919194128847](pic/image-20250919194128847.png) + +* HNR打开状态 + +![image-20250919194305216](pic/image-20250919194305216.png) + + + +* 敲两下回传,即可关闭程序 + +![image-20250919151519310](pic/image-20250919151519310.png) \ No newline at end of file diff --git a/vendor/zsks/demo/hnr_auto/pic/image-20221114150205685.png b/vendor/zsks/demo/hnr_auto/pic/image-20221114150205685.png new file mode 100755 index 0000000000000000000000000000000000000000..4dc4215c962c57ba0e31548fb98c29c789f149d9 Binary files /dev/null and b/vendor/zsks/demo/hnr_auto/pic/image-20221114150205685.png differ diff --git a/vendor/zsks/demo/hnr_auto/pic/image-20250210161601541.png b/vendor/zsks/demo/hnr_auto/pic/image-20250210161601541.png new file mode 100755 index 0000000000000000000000000000000000000000..80845ece8131933a4cd56ae3bd6119c38e0abd26 Binary files /dev/null and b/vendor/zsks/demo/hnr_auto/pic/image-20250210161601541.png differ diff --git a/vendor/zsks/demo/hnr_auto/pic/image-20250210170027454.png b/vendor/zsks/demo/hnr_auto/pic/image-20250210170027454.png new file mode 100755 index 0000000000000000000000000000000000000000..c06081fc2c963af4d1fa8af506804beedefe1b0b Binary files /dev/null and b/vendor/zsks/demo/hnr_auto/pic/image-20250210170027454.png differ diff --git a/vendor/zsks/demo/hnr_auto/pic/image-20250213112932380.png b/vendor/zsks/demo/hnr_auto/pic/image-20250213112932380.png new file mode 100755 index 0000000000000000000000000000000000000000..8b591b3437544859f4ec76b9ca03867cc401078c Binary files /dev/null and b/vendor/zsks/demo/hnr_auto/pic/image-20250213112932380.png differ diff --git a/vendor/zsks/demo/hnr_auto/pic/image-20250213113543142.png b/vendor/zsks/demo/hnr_auto/pic/image-20250213113543142.png new file mode 100755 index 0000000000000000000000000000000000000000..15bbff4bf80a63c49a2789af09eb34623a92c525 Binary files /dev/null and b/vendor/zsks/demo/hnr_auto/pic/image-20250213113543142.png differ diff --git a/vendor/zsks/demo/hnr_auto/pic/image-20250919151519310.png b/vendor/zsks/demo/hnr_auto/pic/image-20250919151519310.png new file mode 100755 index 0000000000000000000000000000000000000000..7f6d881a5d0e6d3f72b7a43d089b5c5a75d7f048 Binary files /dev/null and b/vendor/zsks/demo/hnr_auto/pic/image-20250919151519310.png differ diff --git a/vendor/zsks/demo/hnr_auto/pic/image-20250919192904220.png b/vendor/zsks/demo/hnr_auto/pic/image-20250919192904220.png new file mode 100755 index 0000000000000000000000000000000000000000..e16c8c0c28b06460ad08318442f83291062f9b01 Binary files /dev/null and b/vendor/zsks/demo/hnr_auto/pic/image-20250919192904220.png differ diff --git a/vendor/zsks/demo/hnr_auto/pic/image-20250919194128847.png b/vendor/zsks/demo/hnr_auto/pic/image-20250919194128847.png new file mode 100755 index 0000000000000000000000000000000000000000..53cfad04c5880acffb06d7fe23eae057bb5c36c4 Binary files /dev/null and b/vendor/zsks/demo/hnr_auto/pic/image-20250919194128847.png differ diff --git a/vendor/zsks/demo/hnr_auto/pic/image-20250919194305216.png b/vendor/zsks/demo/hnr_auto/pic/image-20250919194305216.png new file mode 100755 index 0000000000000000000000000000000000000000..0aebb9016538c88d3250ed9d379384c2212578c6 Binary files /dev/null and b/vendor/zsks/demo/hnr_auto/pic/image-20250919194305216.png differ diff --git a/vendor/zsks/demo/hnr_auto/pic/image-20251030143349837.png b/vendor/zsks/demo/hnr_auto/pic/image-20251030143349837.png new file mode 100755 index 0000000000000000000000000000000000000000..d8fc36e52d500665099c560824a1ce77e976c8e6 Binary files /dev/null and b/vendor/zsks/demo/hnr_auto/pic/image-20251030143349837.png differ diff --git a/vendor/zsks/demo/hnr_auto/pic/image-20251030143505034.png b/vendor/zsks/demo/hnr_auto/pic/image-20251030143505034.png new file mode 100755 index 0000000000000000000000000000000000000000..a32c00352c8b16e6babfe75cf172159f0d64ede0 Binary files /dev/null and b/vendor/zsks/demo/hnr_auto/pic/image-20251030143505034.png differ diff --git a/vendor/zsks/demo/hnr_auto/pic/image-20251030144417819.png b/vendor/zsks/demo/hnr_auto/pic/image-20251030144417819.png new file mode 100755 index 0000000000000000000000000000000000000000..17fb9759a4623d11a2064bb06139c2e3991e0c3b Binary files /dev/null and b/vendor/zsks/demo/hnr_auto/pic/image-20251030144417819.png differ diff --git a/vendor/zsks/demo/hnr_auto/pic/image-20251030144458528.png b/vendor/zsks/demo/hnr_auto/pic/image-20251030144458528.png new file mode 100755 index 0000000000000000000000000000000000000000..75488eafb2ad85bd9fed46c319cfcf2beebfa4bf Binary files /dev/null and b/vendor/zsks/demo/hnr_auto/pic/image-20251030144458528.png differ diff --git a/vendor/zsks/demo/hnr_auto/pic/image-20251030150209706.png b/vendor/zsks/demo/hnr_auto/pic/image-20251030150209706.png new file mode 100755 index 0000000000000000000000000000000000000000..657a730d2503f77fbcf135346a156b01895f221e Binary files /dev/null and b/vendor/zsks/demo/hnr_auto/pic/image-20251030150209706.png differ diff --git a/vendor/zsks/demo/hnr_auto/pic/image-20251030150312214.png b/vendor/zsks/demo/hnr_auto/pic/image-20251030150312214.png new file mode 100755 index 0000000000000000000000000000000000000000..fcd4df83556b7bf7aef37455d8240f6c8423f590 Binary files /dev/null and b/vendor/zsks/demo/hnr_auto/pic/image-20251030150312214.png differ diff --git a/vendor/zsks/demo/hnr_auto/pic/image-20251030150411696.png b/vendor/zsks/demo/hnr_auto/pic/image-20251030150411696.png new file mode 100755 index 0000000000000000000000000000000000000000..cf4acccbccfb29ab156200afb7c30cf688ed8211 Binary files /dev/null and b/vendor/zsks/demo/hnr_auto/pic/image-20251030150411696.png differ diff --git a/vendor/zsks/demo/hnr_auto/sample_hnr.c b/vendor/zsks/demo/hnr_auto/sample_hnr.c new file mode 100755 index 0000000000000000000000000000000000000000..641a166afeed68eb73ace4cae9bade255f524804 --- /dev/null +++ b/vendor/zsks/demo/hnr_auto/sample_hnr.c @@ -0,0 +1,1623 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include "ss_mpi_ae.h" +#include "ss_mpi_hnr.h" +#include "sample_ipc.h" +#include "ot_sns_ctrl.h" +#include "sample_comm.h" +#include "ot_common_hnr.h" +#include "sdk_module_init.h" + +ot_size g_mcf_chn_out_size[OT_MCF_MAX_PHYS_CHN_NUM] = { 0 }; +td_bool g_mcf_chn_enable[OT_MCF_MAX_PHYS_CHN_NUM] = {TD_TRUE, TD_FALSE, TD_FALSE}; +#define MCF_VENC_WIDHT_3840 3840 +#define MCF_VNEC_HEIGHT_2160 2160 +#define MCF_BIND_VPSS_GRP 2 + +#define VO_WIDTH 1920 +#define VO_HEIGTH 1080 + +#define VENC_WIDTH 3840 +#define VENC_HEIGTH 2160 + +#define VB_HNR_CNT 9 +#define VB_HNR_SNAP_CNT 7 +#define VB_HNR_SNAP_ADVANCED_CNT 9 +#define VB_HNR_BLEND_CNT 11 +#define VB_MCF_YUV_CNT 30 + +#define VB_COMMON_LINE_CNT 5 +#define VB_COMMON_WDR_CNT 10 + +volatile static sig_atomic_t g_sig_flag = 0; +static ot_vb_pool g_vb_pool = OT_VB_INVALID_POOL_ID; +ot_hnr_attr hnr_attr; +typedef struct { + td_bool is_wdr_mode; + ot_hnr_ref_mode ref_mode; + td_bool normal_blend; + ot_vi_video_mode video_mode; +} sample_hnr_param; + +typedef struct { + ot_vi_pipe video_pipe; + ot_vi_pipe snap_pipe; + pthread_t thread_id; + td_bool start; +} sample_hnr_snap_thread_info; + +static sample_hnr_snap_thread_info g_snap_thread_info; + +typedef struct { + ot_vi_pipe video_pipe; + td_u32 iso; + pthread_t thread_id; + td_bool start; +} sample_hnr_vi_thread_info; +static sample_hnr_vi_thread_info g_vi_thread_info; + +static sample_vo_cfg g_vo_cfg = { + .vo_dev = SAMPLE_VO_DEV_UHD, + .vo_intf_type = OT_VO_INTF_HDMI, + .intf_sync = OT_VO_OUT_1080P60, + .bg_color = COLOR_RGB_BLACK, + .pix_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_420, + .disp_rect = {0, 0, VO_WIDTH, VO_HEIGTH}, + .image_size = {VO_WIDTH, VO_HEIGTH}, + .vo_part_mode = OT_VO_PARTITION_MODE_SINGLE, + .dis_buf_len = 3, /* 3: def buf len for single */ + .dst_dynamic_range = OT_DYNAMIC_RANGE_SDR8, + .vo_mode = VO_MODE_1MUX, + .compress_mode = OT_COMPRESS_MODE_NONE, +}; + +static sample_comm_venc_chn_param g_venc_chn_param = { + .frame_rate = 30, /* 30 is a number */ + .stats_time = 1, /* 1 is a number */ + .gop = 30, /* 30 is a number */ + .venc_size = {VENC_WIDTH, VENC_HEIGTH}, + .size = PIC_3840X2160, + .profile = 0, + .is_rcn_ref_share_buf = TD_FALSE, + .gop_attr = { + .gop_mode = OT_VENC_GOP_MODE_NORMAL_P, + .normal_p = {2}, + }, + .type = OT_PT_H265, + .rc_mode = SAMPLE_RC_CBR, +}; + +// 设置非阻塞键盘输入的函数 +static void set_nonblocking_mode() +{ + struct termios ttystate; + tcgetattr(STDIN_FILENO, &ttystate); + ttystate.c_lflag &= ~ICANON; // 禁用规范模式 + ttystate.c_lflag &= ~ECHO; // 禁用回显 + ttystate.c_cc[VMIN] = 0; // 无最小字符要求 + ttystate.c_cc[VTIME] = 0; // 无超时 + tcsetattr(STDIN_FILENO, TCSANOW, &ttystate); +} + +// 恢复终端设置(可选) +static void restore_terminal() +{ + struct termios ttystate; + tcgetattr(STDIN_FILENO, &ttystate); + ttystate.c_lflag |= ICANON; + ttystate.c_lflag |= ECHO; + tcsetattr(STDIN_FILENO, TCSANOW, &ttystate); +} + +static td_void sample_hnr_pause() +{ + fd_set readfds; + struct timeval tv; + FD_ZERO(&readfds); + FD_SET(STDIN_FILENO, &readfds); + tv.tv_sec = 0; // 0 秒 + tv.tv_usec = 10000; // 10000 10毫秒超时 + + if (select(STDIN_FILENO + 1, &readfds, NULL, NULL, &tv) > 0) { + if (FD_ISSET(STDIN_FILENO, &readfds)) { + // 清空输入缓冲区 + char buf[10]; + read(STDIN_FILENO, buf, sizeof(buf)); + printf("\nKey pressed: Exiting...\n"); + g_vi_thread_info.start = 0; // 设置退出标志 + } + } +} + +static td_s32 g_hnr_cfg_id[OT_HNR_MAX_CFG_NUM] = {-1}; +static td_void sample_get_char(td_char *s) +{ + if (g_sig_flag == 1) { + return; + } + + printf("---------------press any key to %s!---------------\n", s); + (td_void)getchar(); +} + +static td_void sample_hnr_usage(char *prg_name) +{ + printf("usage : %s \n", prg_name); + printf("index:\n"); + printf(" (0) hnr line mode : base mode, has reference frame\n"); + printf(" (1) hnr wdr mode : wdr and long frame mode\n"); + printf(" (2) hnr line and none ref mode : no reference frame\n"); + printf(" (3) hnr line mode + normal blend : base mode and normal blend on\n"); + printf(" (4) hnr snap advanced mode: advanced mode of no reference frame \n"); + printf(" (5) hnr line switch to wdr: line mode and hnr normal blend switch to wdr mode\n"); +} + +static td_void sample_hnr_get_default_vb_config(const ot_size *size, ot_vb_cfg *vb_cfg, td_u32 vb_cnt) +{ + ot_vb_calc_cfg calc_cfg; + ot_pic_buf_attr buf_attr; + + (td_void)memset_s(vb_cfg, sizeof(ot_vb_cfg), 0, sizeof(ot_vb_cfg)); + vb_cfg->max_pool_cnt = 128; /* 128 blks */ + + buf_attr.width = size->width; + buf_attr.height = size->height; + buf_attr.align = OT_DEFAULT_ALIGN; + buf_attr.bit_width = OT_DATA_BIT_WIDTH_8; + buf_attr.pixel_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_422; + buf_attr.compress_mode = OT_COMPRESS_MODE_NONE; + ot_common_get_pic_buf_cfg(&buf_attr, &calc_cfg); + + vb_cfg->common_pool[0].blk_size = calc_cfg.vb_size; + vb_cfg->common_pool[0].blk_cnt = vb_cnt; +} + +#ifdef SAMPLE_MEM_SHARE_ENABLE +static td_void sample_hnr_init_mem_share(td_void) +{ + td_u32 i; + ot_vb_common_pools_id pools_id = {0}; + + if (ss_mpi_vb_get_common_pool_id(&pools_id) != TD_SUCCESS) { + sample_print("get common pool_id failed!\n"); + return; + } + for (i = 0; i < pools_id.pool_cnt; ++i) { + ss_mpi_vb_pool_share_all(pools_id.pool[i]); + } +} +#endif + +static td_s32 sample_hnr_sys_init(ot_size *in_size, ot_vi_video_mode video_mode, ot_vi_vpss_mode_type mode_type, + td_u32 vb_cnt) +{ + td_s32 ret; + ot_vb_cfg vb_cfg; + td_u32 supplement_config; + + sample_hnr_get_default_vb_config(in_size, &vb_cfg, vb_cnt); + + supplement_config = OT_VB_SUPPLEMENT_BNR_MOT_MASK; + ret = sample_comm_sys_init_with_vb_supplement(&vb_cfg, supplement_config); + if (ret != TD_SUCCESS) { + return TD_FAILURE; + } + +#ifdef SAMPLE_MEM_SHARE_ENABLE + sample_hnr_init_mem_share(); +#endif + + ret = sample_comm_vi_set_vi_vpss_mode(mode_type, video_mode); + if (ret != TD_SUCCESS) { + return TD_FAILURE; + } + + return TD_SUCCESS; +} + +static td_char *hnr_common_get_param_file(ot_hnr_ref_mode ref_mode) +{ + td_char *param_file = TD_NULL; + + if (ref_mode == OT_HNR_REF_MODE_NORM) { + param_file = "./cfg/normal_hnr.bin"; + } else { + param_file = "./cfg/snap_hnr.bin"; + } + + printf("load config file %s\n", param_file); + return param_file; +} + +static td_s32 hnr_common_load_mem(ot_hnr_mem_info *mem, ot_hnr_ref_mode ref_mode) +{ + td_s32 ret; + td_char *param_file = TD_NULL; + FILE *fp = TD_NULL; + + param_file = hnr_common_get_param_file(ref_mode); + /* Get model file size */ + fp = fopen(param_file, "rb"); + if (fp == TD_NULL) { + sample_print("open file %s err!\n", param_file); + return TD_FAILURE; + } + + ret = fseek(fp, 0L, SEEK_END); + if (ret != TD_SUCCESS) { + sample_print("fseek end failed!\n"); + goto fail_0; + } + + mem->size = ftell(fp); + if (mem->size <= 0) { + sample_print("ftell failed!\n"); + goto fail_0; + } + + ret = fseek(fp, 0L, SEEK_SET); + if (ret != TD_SUCCESS) { + sample_print("fseek set failed!\n"); + goto fail_0; + } + + /* malloc model file mem */ + ret = ss_mpi_sys_mmz_alloc(&(mem->phys_addr), &(mem->virt_addr), "hnr_cfg", TD_NULL, mem->size); + if (ret != TD_SUCCESS) { + sample_print("malloc mmz failed!\n"); + goto fail_0; + } + + ret = fread(mem->virt_addr, mem->size, 1, fp); + if (ret != 1) { + sample_print("read model file failed!\n"); + goto fail_1; + } + + ret = fclose(fp); + if (ret != 0) { + sample_print("close file error\n"); + } + return TD_SUCCESS; + +fail_1: + ss_mpi_sys_mmz_free(mem->phys_addr, mem->virt_addr); + mem->phys_addr = 0; + mem->virt_addr = TD_NULL; +fail_0: + if (fp != TD_NULL) { + fclose(fp); + } + return TD_FAILURE; +} + +static td_void hnr_common_unload_mem(ot_hnr_mem_info *param_mem) +{ + if ((param_mem->phys_addr != 0) && (param_mem->virt_addr != TD_NULL)) { + (td_void)ss_mpi_sys_mmz_free(param_mem->phys_addr, param_mem->virt_addr); + } +} + +static td_s32 sample_hnr_set_attr(ot_vi_pipe vi_pipe, sample_hnr_param *hnr_param) +{ + td_s32 ret; + ret = ss_mpi_hnr_get_attr(vi_pipe, &hnr_attr); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_hnr_get_attr error\n"); + return ret; + } + + hnr_attr.enable = TD_TRUE; + hnr_attr.bnr_bypass = (hnr_param->normal_blend == TD_TRUE) ? TD_FALSE : TD_TRUE; + hnr_attr.normal_blend = hnr_param->normal_blend; + hnr_attr.op_type = OT_OP_MODE_MANUAL; + hnr_attr.manual_attr.param.sfs = 31; /* sfs: 31 */ + hnr_attr.manual_attr.param.tfs = 31; /* tfs: 31 */ + ret = ss_mpi_hnr_set_attr(vi_pipe, &hnr_attr); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_hnr_set_attr error\n"); + return ret; + } + + return TD_SUCCESS; +} + +static td_s32 sample_hnr_load_cfg(ot_size in_size, ot_hnr_cfg *hnr_cfg, ot_hnr_ref_mode ref_mode) +{ + td_s32 ret; + + ret = hnr_common_load_mem((ot_hnr_mem_info *)&(hnr_cfg->mem_info), ref_mode); + if (ret != TD_SUCCESS) { + sample_print("hnr_common_load_mem error\n"); + return ret; + } + + if (ref_mode != OT_HNR_REF_MODE_NORM) { + hnr_cfg->image_size.width = in_size.width; + hnr_cfg->image_size.height = in_size.height; + hnr_cfg->is_wdr_mode = TD_FALSE; + ret = ss_mpi_hnr_load_cfg(hnr_cfg, &g_hnr_cfg_id[0]); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_hnr_load_cfg error(%#x)\n", ret); + goto unload_mem; + } + return ret; + } + + hnr_cfg->image_size.width = in_size.width; + hnr_cfg->image_size.height = in_size.height; + hnr_cfg->is_wdr_mode = TD_FALSE; + ret = ss_mpi_hnr_load_cfg(hnr_cfg, &g_hnr_cfg_id[0]); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_hnr_load_cfg error(%#x)\n", ret); + goto unload_mem; + } + + hnr_cfg->is_wdr_mode = TD_TRUE; + ret = ss_mpi_hnr_load_cfg(hnr_cfg, &g_hnr_cfg_id[1]); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_hnr_load_cfg error(%#x)\n", ret); + goto unload_mem; + } + return ret; + +unload_mem: + hnr_common_unload_mem((ot_hnr_mem_info *)&(hnr_cfg->mem_info)); + return ret; +} + +static td_void sample_hnr_unload_cfg(ot_hnr_cfg *hnr_cfg, ot_hnr_ref_mode ref_mode) +{ + if (ss_mpi_hnr_unload_cfg(g_hnr_cfg_id[0]) != TD_SUCCESS) { + sample_print("ss_mpi_hnr_unload_cfg error\n"); + } + if (ref_mode == OT_HNR_REF_MODE_NORM) { + if (ss_mpi_hnr_unload_cfg(g_hnr_cfg_id[1]) != TD_SUCCESS) { + sample_print("ss_mpi_hnr_unload_cfg error\n"); + } + } + hnr_common_unload_mem((ot_hnr_mem_info *)&(hnr_cfg->mem_info)); +} + +static td_s32 sample_hnr_start(ot_vi_pipe vi_pipe, ot_size in_size, ot_hnr_cfg *hnr_cfg, + sample_hnr_param *hnr_param) +{ + td_s32 ret = ss_mpi_hnr_init(); + ot_hnr_alg_cfg attr; + + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_hnr_init error(%#x)\n", ret); + return ret; + } + + ret = sample_hnr_load_cfg(in_size, hnr_cfg, hnr_param->ref_mode); + if (ret != TD_SUCCESS) { + goto task_exit; + } + + attr.ref_mode = hnr_param->ref_mode; /* ref mode NORM: need reference frame; NONE: no reference frame */ + ret = ss_mpi_hnr_set_alg_cfg(vi_pipe, &attr); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_hnr_set_alg_cfg error(%#x)\n", ret); + goto unload_cfg; + } + sleep(3); // 3 sleep 3s + + ret = ss_mpi_hnr_enable(vi_pipe); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_hnr_enable error(%#x)\n", ret); + goto unload_cfg; + } + + ret = sample_hnr_set_attr(vi_pipe, hnr_param); + if (ret != TD_SUCCESS) { + sample_print("sample_hnr_set_attr error(%#x)\n", ret); + goto hnr_disable; + } + + return ret; + +hnr_disable: + ss_mpi_hnr_disable(vi_pipe); +unload_cfg: + sample_hnr_unload_cfg(hnr_cfg, hnr_param->ref_mode); +task_exit: + ss_mpi_hnr_exit(); + + return ret; +} + +static td_s32 sample_hnr_stop(ot_vi_pipe vi_pipe, ot_hnr_cfg *hnr_cfg, sample_hnr_param *hnr_param) +{ + td_s32 return_value = TD_SUCCESS; + td_s32 ret; + + ret = ss_mpi_hnr_disable(vi_pipe); + if (ret != TD_SUCCESS) { + return_value = TD_FAILURE; + sample_print("ss_mpi_hnr_disable false error(%#x)\n", ret); + } + + ret = ss_mpi_hnr_unload_cfg(g_hnr_cfg_id[0]); + if (ret != TD_SUCCESS) { + return_value = TD_FAILURE; + sample_print("ss_mpi_hnr_unload_cfg error(%#x)\n", ret); + } + + if (hnr_param->ref_mode == OT_HNR_REF_MODE_NORM) { + ret = ss_mpi_hnr_unload_cfg(g_hnr_cfg_id[1]); + if (ret != TD_SUCCESS) { + return_value = TD_FAILURE; + sample_print("ss_mpi_hnr_unload_cfg error(%#x)\n", ret); + } + } + hnr_common_unload_mem((ot_hnr_mem_info *)&(hnr_cfg->mem_info)); + + ss_mpi_hnr_exit(); + return return_value; +} + +static td_s32 sample_hnr_start_vpss(ot_vpss_grp grp, ot_size *in_size) +{ + td_s32 ret; + ot_low_delay_info low_delay_info; + ot_vpss_grp_attr grp_attr; + ot_vpss_chn_attr chn_attr; + td_bool chn_enable[OT_VPSS_MAX_PHYS_CHN_NUM] = {TD_TRUE, TD_FALSE, TD_FALSE, TD_FALSE}; + + sample_comm_vpss_get_default_grp_attr(&grp_attr); + grp_attr.max_width = in_size->width; + grp_attr.max_height = in_size->height; + sample_comm_vpss_get_default_chn_attr(&chn_attr); + chn_attr.width = in_size->width; + chn_attr.height = in_size->height; + + ret = sample_common_vpss_start(grp, chn_enable, &grp_attr, &chn_attr, OT_VPSS_MAX_PHYS_CHN_NUM); + if (ret != TD_SUCCESS) { + return ret; + } + + low_delay_info.enable = TD_TRUE; + low_delay_info.line_cnt = 200; /* 200: lowdelay line */ + low_delay_info.one_buf_en = TD_FALSE; + ret = ss_mpi_vpss_set_low_delay_attr(grp, 0, &low_delay_info); + if (ret != TD_SUCCESS) { + sample_common_vpss_stop(grp, chn_enable, OT_VPSS_MAX_PHYS_CHN_NUM); + return ret; + } + + return TD_SUCCESS; +} + +static td_s32 sample_hnr_start_vo(sample_vo_mode vo_mode) +{ + g_vo_cfg.vo_mode = vo_mode; + + return sample_comm_vo_start_vo(&g_vo_cfg); +} + +static td_void sample_hnr_stop_vo(td_void) +{ + sample_comm_vo_stop_vo(&g_vo_cfg); +} + +static td_s32 sample_hnr_start_venc(ot_venc_chn venc_chn[], td_u32 venc_chn_len, td_u32 chn_num) +{ + td_s32 i; + td_s32 ret; + + for (i = 0; i < (td_s32)chn_num && i < venc_chn_len; i++) { + ret = sample_comm_venc_start(venc_chn[i], &g_venc_chn_param); + if (ret != TD_SUCCESS) { + goto exit; + } + } + + ret = sample_comm_venc_start_get_stream(venc_chn, chn_num); + if (ret != TD_SUCCESS) { + goto exit; + } + + return TD_SUCCESS; + +exit: + for (i = i - 1; i >= 0; i--) { + sample_comm_venc_stop(venc_chn[i]); + } + return TD_FAILURE; +} + +static td_s32 sample_hnr_start_venc_and_vo(ot_vpss_grp vpss_grp[], td_u32 grp_num, ot_size *in_size) +{ + td_u32 i; + td_s32 ret; + sample_vo_mode vo_mode = VO_MODE_1MUX; + const ot_vpss_chn vpss_chn = 0; + const ot_vo_layer vo_layer = 0; + ot_vo_chn vo_chn[4] = {0, 1, 2, 3}; /* 4: max chn num, 0/1/2/3 chn id */ + ot_venc_chn venc_chn[4] = {0, 1, 2, 3}; /* 4: max chn num, 0/1/2/3 chn id */ + + if (grp_num > 1) { + vo_mode = VO_MODE_4MUX; + } + + ret = sample_hnr_start_vo(vo_mode); + if (ret != TD_SUCCESS) { + goto start_vo_failed; + } + + g_venc_chn_param.venc_size.width = in_size->width; + g_venc_chn_param.venc_size.height = in_size->height; + + if (SENSOR0_TYPE == HY_S0603_MIPI_8M_30FPS_12BIT) { + g_venc_chn_param.size = PIC_3840X2160; + } else { + g_venc_chn_param.size = PIC_1080P; + } + + ret = sample_hnr_start_venc(venc_chn, sizeof(venc_chn) / sizeof(ot_venc_chn), grp_num); + if (ret != TD_SUCCESS) { + goto start_venc_failed; + } + + for (i = 0; i < grp_num; i++) { + sample_comm_vpss_bind_vo(vpss_grp[i], vpss_chn, vo_layer, vo_chn[i]); + sample_comm_vpss_bind_venc(vpss_grp[i], vpss_chn, venc_chn[i]); + } + return TD_SUCCESS; + +start_venc_failed: + sample_hnr_stop_vo(); +start_vo_failed: + return TD_FAILURE; +} + +static td_void sample_hnr_stop_vpss(ot_vpss_grp grp) +{ + td_bool chn_enable[OT_VPSS_MAX_PHYS_CHN_NUM] = {TD_TRUE, TD_FALSE, TD_FALSE, TD_FALSE}; + + sample_common_vpss_stop(grp, chn_enable, OT_VPSS_MAX_PHYS_CHN_NUM); +} + +static td_void sample_hnr_stop_venc(ot_venc_chn venc_chn[], td_u32 venc_chn_len, td_u32 chn_num) +{ + td_u32 i; + + sample_comm_venc_stop_get_stream(chn_num); + + for (i = 0; i < chn_num && i < venc_chn_len; i++) { + sample_comm_venc_stop(venc_chn[i]); + } +} + +static td_void sample_hnr_stop_venc_and_vo(ot_vpss_grp vpss_grp[], td_u32 grp_num) +{ + td_u32 i; + const ot_vpss_chn vpss_chn = 0; + const ot_vo_layer vo_layer = 0; + ot_vo_chn vo_chn[4] = {0, 1, 2, 3}; /* 4: max chn num, 0/1/2/3 chn id */ + ot_venc_chn venc_chn[4] = {0, 1, 2, 3}; /* 4: max chn num, 0/1/2/3 chn id */ + + for (i = 0; i < grp_num; i++) { + sample_comm_vpss_un_bind_vo(vpss_grp[i], vpss_chn, vo_layer, vo_chn[i]); + sample_comm_vpss_un_bind_venc(vpss_grp[i], vpss_chn, venc_chn[i]); + } + + sample_hnr_stop_venc(venc_chn, sizeof(venc_chn) / sizeof(ot_venc_chn), grp_num); + sample_hnr_stop_vo(); +} + +static td_void sample_hnr_sensor_cfg(ot_vi_pipe vi_pipe, sample_sns_type sns_type) +{ + return; +} + +static td_s32 sample_hnr_comm_start_vi(ot_vi_pipe vi_pipe, const sample_vi_cfg *vi_cfg, ot_size *in_size, + td_u32 vb_cnt) +{ + td_s32 ret; + td_s32 blk_size; + ot_vb_pool vb_pool; + ot_vb_pool_cfg vb_pool_cfg = {0}; + + blk_size = ot_hnr_get_pic_buf_size(in_size->width, in_size->height); + vb_pool_cfg.blk_size = blk_size; + vb_pool_cfg.blk_cnt = vb_cnt; + vb_pool_cfg.remap_mode = OT_VB_REMAP_MODE_NONE; + vb_pool = ss_mpi_vb_create_pool(&vb_pool_cfg); + if (vb_pool == OT_VB_INVALID_POOL_ID) { + sample_print("create user pool failed!\n"); + return TD_FAILURE; + } + + ret = sample_comm_vi_start_vi(vi_cfg); + if (ret != TD_SUCCESS) { + sample_print("start vi failed.\n"); + return ret; + } + + ret = ss_mpi_vi_pipe_set_vb_src(vi_pipe, OT_VB_SRC_USER); + if (ret != TD_SUCCESS) { + sample_print("vi pipe set vb src failed.\n"); + return ret; + } + + ret = ss_mpi_vi_pipe_attach_vb_pool(vi_pipe, vb_pool); + if (ret != TD_SUCCESS) { + sample_print("vi pipe attach vb pool failed.\n"); + return ret; + } + + g_vb_pool = vb_pool; + + return TD_SUCCESS; +} + +static td_s32 sample_hnr_start_vi(ot_vi_pipe vi_pipe, const sample_vi_cfg *vi_cfg, ot_size *in_size, + sample_hnr_param *hnr_param, td_u32 vb_cnt) +{ + td_s32 ret; + ot_vi_vpss_mode_type mode_type; + td_u32 common_vb_num = hnr_param->is_wdr_mode ? VB_COMMON_WDR_CNT : VB_COMMON_LINE_CNT; + + if (hnr_param->ref_mode == OT_HNR_REF_MODE_NORM) { + mode_type = (hnr_param->video_mode == OT_VI_VIDEO_MODE_ADVANCED) ? + OT_VI_ONLINE_VPSS_OFFLINE : OT_VI_OFFLINE_VPSS_ONLINE; + } else { + mode_type = OT_VI_OFFLINE_VPSS_ONLINE; + } + + if (sample_hnr_sys_init(in_size, hnr_param->video_mode, mode_type, common_vb_num) != TD_SUCCESS) { + return TD_FAILURE; + } + + ret = sample_hnr_comm_start_vi(vi_pipe, vi_cfg, in_size, vb_cnt); + + return ret; +} + +static td_s32 sample_hnr_switch_start_vi(ot_vi_pipe vi_pipe, const sample_vi_cfg *vi_cfg, ot_size *in_size) +{ + td_s32 ret; + td_s32 blk_size; + ot_vb_pool vb_pool; + ot_vb_pool_cfg vb_pool_cfg = {0}; + + blk_size = ot_hnr_get_pic_buf_size(in_size->width, in_size->height); + vb_pool_cfg.blk_size = blk_size; + vb_pool_cfg.blk_cnt = VB_HNR_BLEND_CNT; + vb_pool_cfg.remap_mode = OT_VB_REMAP_MODE_NONE; + vb_pool = ss_mpi_vb_create_pool(&vb_pool_cfg); + if (vb_pool == OT_VB_INVALID_POOL_ID) { + sample_print("create user pool failed!\n"); + return TD_FAILURE; + } + + ret = sample_comm_vi_mode_switch_start_vi(vi_cfg, TD_FALSE, (const ot_size *)&in_size); + if (ret != TD_SUCCESS) { + sample_print("start vi failed.\n"); + return ret; + } + + ret = ss_mpi_vi_pipe_set_vb_src(vi_pipe, OT_VB_SRC_USER); + if (ret != TD_SUCCESS) { + sample_print("vi pipe set vb src failed.\n"); + return ret; + } + + ret = ss_mpi_vi_pipe_attach_vb_pool(vi_pipe, vb_pool); + if (ret != TD_SUCCESS) { + sample_print("vi pipe attach vb pool failed.\n"); + return ret; + } + + g_vb_pool = vb_pool; + + return TD_SUCCESS; +} + +static td_void sample_hnr_stop_vi(ot_vi_pipe vi_pipe, const sample_vi_cfg *vi_cfg) +{ + sample_comm_vi_stop_vi(vi_cfg); + + if (g_vb_pool != OT_VB_INVALID_POOL_ID) { + ss_mpi_vb_destroy_pool(g_vb_pool); + g_vb_pool = OT_VB_INVALID_POOL_ID; + } +} + +static td_void *sample_hnr_vi_thread(td_void *param) +{ + td_s32 ret; + ot_isp_frame_info isp_frame_info; + sample_hnr_vi_thread_info *vi_thread_info = (sample_hnr_vi_thread_info *)param; + while (vi_thread_info->start == TD_TRUE) { + ret = ss_mpi_isp_get_frame_info(vi_thread_info->video_pipe, &isp_frame_info); + if (ret != TD_SUCCESS) { + break; + } + g_vi_thread_info.iso = isp_frame_info.iso; + } + + return TD_NULL; +} + +static td_s32 sample_hnr_vi_create_thread(ot_vi_pipe video_pipe, ot_vi_pipe capture_pipe) +{ + td_s32 ret; + g_vi_thread_info.video_pipe = video_pipe; + + ret = pthread_create(&g_vi_thread_info.thread_id, TD_NULL, sample_hnr_vi_thread, &g_vi_thread_info); + if (ret != 0) { + sample_print("create capture thread failed!\n"); + return TD_FAILURE; + } + g_vi_thread_info.start = TD_TRUE; + + return TD_SUCCESS; +} + +static td_void sample_hnr_vi_destroy_thread(td_void) +{ + if (g_vi_thread_info.start == TD_TRUE) { + g_vi_thread_info.start = TD_FALSE; + pthread_join(g_vi_thread_info.thread_id, NULL); + } +} + +static td_s32 sample_hnr_set_long_frame_mode(ot_vi_pipe vi_pipe, td_bool is_wdr_mode) +{ + td_s32 ret; + ot_isp_exposure_attr exp_attr; + ot_isp_wdr_fs_attr fswdr_attr; + + if (is_wdr_mode == TD_FALSE) { + return TD_SUCCESS; + } + + sample_get_char("set long frame mode"); + + ret = ss_mpi_isp_get_exposure_attr(vi_pipe, &exp_attr); + if (ret != TD_SUCCESS) { + printf("ss_mpi_isp_get_exposure_attr error[0x%x]\n", ret); + return TD_FAILURE; + } + + exp_attr.auto_attr.fswdr_mode = OT_ISP_FSWDR_LONG_FRAME_MODE; + ret = ss_mpi_isp_set_exposure_attr(vi_pipe, &exp_attr); + if (ret != TD_SUCCESS) { + printf("ss_mpi_isp_set_exposure_attr error[0x%x]\n", ret); + return TD_FAILURE; + } + + ret = ss_mpi_isp_get_fswdr_attr(vi_pipe, &fswdr_attr); + if (ret != TD_SUCCESS) { + printf("ss_mpi_isp_get_fswdr_attr error[0x%x]\n", ret); + return TD_FAILURE; + } + + fswdr_attr.wdr_merge_mode = OT_ISP_MERGE_WDR_MODE; + ret = ss_mpi_isp_set_fswdr_attr(vi_pipe, &fswdr_attr); + if (ret != TD_SUCCESS) { + printf("ss_mpi_isp_set_fswdr_attr error[0x%x]\n", ret); + return TD_FAILURE; + } + + return ret; +} + +static td_void sample_hnr_get_default_cfg(sample_sns_type sns_type, ot_vi_pipe vi_pipe, ot_vi_video_mode video_mode, + ot_size *size, sample_vi_cfg *vi_cfg) +{ + sample_comm_vi_get_size_by_sns_type(sns_type, size); + sample_comm_vi_get_default_vi_cfg(sns_type, vi_cfg); + + if (video_mode == OT_VI_VIDEO_MODE_NORM) { + vi_cfg->pipe_info[vi_pipe].pipe_attr.compress_mode = OT_COMPRESS_MODE_NONE; + } +} + +static td_s32 sample_hnr_set_dpc_crosstalk(ot_vi_pipe vi_pipe, sample_sns_type sns_type, td_bool hnr_enable) +{ + td_s32 ret; + ot_isp_dp_dynamic_attr dp_dynamic_attr; + ot_isp_cr_attr crosstalk_attr; + ret = ss_mpi_isp_get_dp_dynamic_attr(vi_pipe, &dp_dynamic_attr); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_isp_get_dp_dynamic_attr failed.\n"); + return TD_FAILURE; + } + printf("----dp_dynamic_attr.enable=%d, crosstalk_attr.en=%d\n", dp_dynamic_attr.enable, crosstalk_attr.en); + ret = ss_mpi_isp_get_crosstalk_attr(vi_pipe, &crosstalk_attr); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_isp_get_crosstalk_attr failed.\n"); + return TD_FAILURE; + } + + if( hnr_enable == TD_TRUE) { + printf("---- HNR Open\n"); + dp_dynamic_attr.enable = TD_FALSE; + crosstalk_attr.en = TD_FALSE; + } else { + printf("---- HNR Close\n"); + dp_dynamic_attr.enable = TD_TRUE; + crosstalk_attr.en = TD_TRUE; + } + + ret = ss_mpi_isp_set_dp_dynamic_attr(vi_pipe, &dp_dynamic_attr); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_isp_set_dp_dynamic_attr failed.\n"); + return TD_FAILURE; + } + + ret = ss_mpi_isp_set_crosstalk_attr(vi_pipe, &crosstalk_attr); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_isp_set_crosstalk_attr failed.\n"); + return TD_FAILURE; + } + + return TD_SUCCESS; +} + +static td_s32 sample_hnr_set_blc(ot_vi_pipe vi_pipe, sample_sns_type sns_type) +{ + td_s32 i; + td_s32 j; + td_s32 ret; + ot_isp_black_level_attr black_level_attr; + + ret = ss_mpi_isp_get_black_level_attr(vi_pipe, &black_level_attr); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_isp_get_black_level_attr failed.\n"); + return TD_FAILURE; + } + + black_level_attr.user_black_level_en = TD_TRUE; + + for (i = 0; i < OT_ISP_WDR_MAX_FRAME_NUM; i++) { + for (j = 0; j < OT_ISP_BAYER_CHN_NUM; j++) { + black_level_attr.user_black_level[i][j] = 1200; /* user_black_level of hnr default as 1200 */ + } + } + + if (sns_type == HY_S0603_MIPI_8M_30FPS_12BIT) { + black_level_attr.black_level_mode = OT_ISP_BLACK_LEVEL_MODE_DYNAMIC; + } + + ret = ss_mpi_isp_set_black_level_attr(vi_pipe, &black_level_attr); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_isp_set_black_level_attr failed.\n"); + return TD_FAILURE; + } + + return TD_SUCCESS; +} + +static td_s32 sample_hnr_switch_first_route_line(sample_sns_type sns_type, ot_hnr_cfg *hnr_cfg) +{ + const ot_vi_pipe vi_pipe = 0; + const ot_vi_chn vi_chn = 0; + ot_vpss_grp vpss_grp[1] = {0}; + const td_u32 grp_num = 1; + const ot_vpss_chn vpss_chn = 0; + sample_vi_cfg vi_cfg; + ot_size in_size; + td_s32 ret = TD_FAILURE; + sample_hnr_param hnr_param = {TD_FALSE, OT_HNR_REF_MODE_NORM, TD_TRUE, OT_VI_VIDEO_MODE_NORM}; + ot_vi_vpss_mode_type mode_type = OT_VI_OFFLINE_VPSS_ONLINE; + + sample_hnr_get_default_cfg(sns_type, vi_pipe, hnr_param.video_mode, &in_size, &vi_cfg); + + if (sample_hnr_sys_init(&in_size, hnr_param.video_mode, mode_type, VB_COMMON_WDR_CNT) != TD_SUCCESS) { + return TD_FAILURE; + } + + if (sample_hnr_comm_start_vi(vi_pipe, &vi_cfg, &in_size, VB_HNR_BLEND_CNT) != TD_SUCCESS) { + return TD_FAILURE; + } + + sample_hnr_sensor_cfg(vi_pipe, sns_type); + + sample_comm_vi_bind_vpss(vi_pipe, vi_chn, vpss_grp[0], vpss_chn); + + if (sample_hnr_start_vpss(vpss_grp[0], &in_size) != TD_SUCCESS) { + goto stop_vi; + } + + if (sample_hnr_start_venc_and_vo(vpss_grp, grp_num, &in_size) != TD_SUCCESS) { + goto stop_vpss; + } + + if (sample_hnr_set_blc(vi_pipe, sns_type) != TD_SUCCESS) { + goto stop_venc_and_vo; + } + + if (sample_hnr_start(vi_pipe, in_size, hnr_cfg, &hnr_param) != TD_SUCCESS) { + goto stop_venc_and_vo; + } + + sample_get_char("exit line mode"); + + ret = ss_mpi_hnr_disable(vi_pipe); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_hnr_disable false error(%#x)\n", ret); + } + +stop_venc_and_vo: + sample_hnr_stop_venc_and_vo(vpss_grp, grp_num); +stop_vpss: + sample_hnr_stop_vpss(vpss_grp[0]); +stop_vi: + sample_comm_vi_un_bind_vpss(vi_pipe, vi_chn, vpss_grp[0], vpss_chn); + if (ret == TD_SUCCESS) { + sample_comm_vi_mode_switch_stop_vi(&vi_cfg); + } else { + sample_comm_vi_stop_vi(&vi_cfg); + } + + return ret; +} + +static td_s32 sample_hnr_switch_second_route_wdr(sample_sns_type sns_type, ot_hnr_cfg *hnr_cfg) +{ + const ot_vi_pipe vi_pipe = 1; + const ot_vi_pipe master_pipe = 0; + const ot_vi_chn vi_chn = 0; + ot_vpss_grp vpss_grp[1] = {0}; + const td_u32 grp_num = 1; + const ot_vpss_chn vpss_chn = 0; + ot_size in_size; + sample_vi_cfg vi_cfg; + td_s32 ret = TD_FAILURE; + sample_hnr_param hnr_param = {TD_TRUE, OT_HNR_REF_MODE_NORM, TD_FALSE, OT_VI_VIDEO_MODE_NORM}; + + sample_comm_vi_get_size_by_sns_type(sns_type, &in_size); + sample_comm_vi_get_default_vi_cfg(sns_type, &vi_cfg); + + sample_hnr_get_default_cfg(sns_type, vi_pipe, hnr_param.video_mode, &in_size, &vi_cfg); + + if (sample_hnr_switch_start_vi(vi_pipe, &vi_cfg, &in_size) != TD_SUCCESS) { + return TD_FAILURE; + } + + sample_hnr_sensor_cfg(vi_pipe, sns_type); + sample_comm_vi_bind_vpss(master_pipe, vi_chn, vpss_grp[0], vpss_chn); + + if (sample_hnr_start_vpss(vpss_grp[0], &in_size) != TD_SUCCESS) { + goto stop_vi; + } + + if (sample_hnr_start_venc_and_vo(vpss_grp, grp_num, &in_size) != TD_SUCCESS) { + goto stop_vpss; + } + + if (sample_hnr_set_blc(master_pipe, sns_type) != TD_SUCCESS) { + goto stop_venc_and_vo; + } + + sample_get_char("enable hnr"); + + ret = ss_mpi_hnr_enable(vi_pipe); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_hnr_enable false error(%#x)\n", ret); + goto exit; + } + + ret = sample_hnr_set_attr(vi_pipe, &hnr_param); + if (ret != TD_SUCCESS) { + sample_print("sample_hnr_set_attr error(%#x)\n", ret); + } + + sample_get_char("exit wdr mode"); + +exit: + sample_hnr_stop(vi_pipe, hnr_cfg, &hnr_param); +stop_venc_and_vo: + sample_hnr_stop_venc_and_vo(vpss_grp, grp_num); +stop_vpss: + sample_hnr_stop_vpss(vpss_grp[0]); +stop_vi: + sample_comm_vi_un_bind_vpss(master_pipe, vi_chn, vpss_grp[0], vpss_chn); + sample_comm_vi_stop_vi(&vi_cfg); + + return ret; +} + +static td_s32 sample_hnr_line_switch_to_wdr(td_void) +{ + td_s32 ret; + sample_vi_cfg vi_cfg; + ot_size in_size; + const ot_vi_pipe vi_pipe = 0; + ot_vi_video_mode video_mode = OT_VI_VIDEO_MODE_NORM; + sample_sns_type sns_type = SENSOR0_TYPE; + ot_hnr_cfg hnr_cfg; + ot_vi_vpss_mode_type mode_type = OT_VI_OFFLINE_VPSS_ONLINE; + + sample_hnr_get_default_cfg(sns_type, vi_pipe, video_mode, &in_size, &vi_cfg); + + if (sample_hnr_sys_init(&in_size, video_mode, mode_type, VB_COMMON_WDR_CNT) != TD_SUCCESS) { + return TD_FAILURE; + } + + ret = sample_hnr_switch_first_route_line(sns_type, &hnr_cfg); + if (ret != TD_SUCCESS) { + return ret; + } + + printf("switch to wdr mode\n"); + + if (sns_type == HY_S0603_MIPI_8M_30FPS_12BIT) { + sns_type = HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1; + } else if (sns_type == OV_OS04A10_MIPI_4M_30FPS_12BIT) { + sns_type = OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1; + } else { + sns_type = OV_OS04A10_MIPI_4M_30FPS_12BIT; + } + + ret = sample_hnr_switch_second_route_wdr(sns_type, &hnr_cfg); + sample_comm_sys_exit(); + + return ret; +} + +static td_s32 sample_hnr_check_support(ot_vi_pipe vi_pipe, sample_hnr_param *hnr_param) +{ + if (hnr_param->is_wdr_mode == TD_TRUE) { + if (hnr_param->video_mode != OT_VI_VIDEO_MODE_NORM) { + sample_print("not support OT_VI_VIDEO_MODE_ADVANCED in wdr mode, must be OT_VI_VIDEO_MODE_NORM \n"); + return TD_FAILURE; + } + + if (hnr_param->normal_blend != TD_FALSE) { + sample_print("normal_blend must be false in wdr mode\n"); + return TD_FAILURE; + } + + if (vi_pipe >= OT_VI_MAX_PHYS_PIPE_NUM) { + sample_print("vi_pipe must be phy pipe in wdr mode\n"); + return TD_FAILURE; + } + } + + return TD_SUCCESS; +} + +static td_u32 sample_hnr_get_vb_cnt(sample_hnr_param *hnr_param) +{ + td_u32 vb_cnt = 0; + if (hnr_param->ref_mode == OT_HNR_REF_MODE_NORM) { + vb_cnt = hnr_param->normal_blend ? VB_HNR_BLEND_CNT : VB_HNR_CNT; + } else if (hnr_param->ref_mode == OT_HNR_REF_MODE_NONE) { + vb_cnt = VB_HNR_SNAP_CNT; + } else if (hnr_param->ref_mode == OT_HNR_REF_MODE_NONE_ADVANCED) { + vb_cnt = VB_HNR_SNAP_ADVANCED_CNT; + } + + return vb_cnt; +} + +static td_s32 sample_hnr(sample_hnr_param *hnr_param) +{ + td_s32 ret = TD_FAILURE; + sample_vi_cfg vi_cfg; + sample_sns_type sns_type = hnr_param->is_wdr_mode ? OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1 : SENSOR0_TYPE; + const td_u32 vb_cnt = sample_hnr_get_vb_cnt(hnr_param); + const ot_vi_pipe vi_pipe = hnr_param->is_wdr_mode ? 1 : 0; /* 1-long frame of wdr */ + const ot_vi_pipe master_pipe = 0; + const ot_vi_chn vi_chn = 0; + ot_vpss_grp vpss_grp[1] = {0}; + ot_size in_size; + ot_hnr_cfg hnr_cfg; + + sample_hnr_get_default_cfg(sns_type, vi_pipe, hnr_param->video_mode, &in_size, &vi_cfg); + if (sample_hnr_check_support(vi_pipe, hnr_param) != TD_SUCCESS) { + return TD_FAILURE; + } + + if (sample_hnr_start_vi(vi_pipe, &vi_cfg, &in_size, hnr_param, vb_cnt) != TD_SUCCESS) { + goto sys_exit; + } + sample_hnr_sensor_cfg(vi_pipe, sns_type); + sample_comm_vi_bind_vpss(master_pipe, vi_chn, vpss_grp[0], 0); + if (sample_hnr_start_vpss(vpss_grp[0], &in_size) != TD_SUCCESS) { + goto stop_vi; + } + if (sample_hnr_start_venc_and_vo(vpss_grp, sizeof(vpss_grp) / sizeof(vpss_grp[0]), &in_size) != TD_SUCCESS) { + goto stop_vpss; + } + if (sample_hnr_set_blc(master_pipe, sns_type) != TD_SUCCESS) { + goto stop_venc_and_vo; + } + if (sample_hnr_vi_create_thread(vi_pipe, vi_pipe) != TD_SUCCESS) { + goto stop_venc_and_vo; + } + + set_nonblocking_mode(); + printf(">>>9:sample_hnr_start\n"); + while (g_vi_thread_info.start) { + sample_hnr_pause(); + if (g_vi_thread_info.iso > 25600) { // 25600 start hnr + if (hnr_attr.enable == TD_FALSE) { + printf(" ----iso = %d\n", g_vi_thread_info.iso); + if (sample_hnr_start(vi_pipe, in_size, &hnr_cfg, hnr_param) != TD_SUCCESS) { + goto stop_venc_and_vo; + } + if (sample_hnr_set_dpc_crosstalk(master_pipe, sns_type, hnr_attr.enable) != TD_SUCCESS) { + goto stop_venc_and_vo; + } + printf(">>>10:sample_hnr_long_frame_mode\n"); + if (sample_hnr_set_long_frame_mode(master_pipe, hnr_param->is_wdr_mode) != TD_SUCCESS) { + goto stop_hnr; + } + } else { + continue; + } + printf("----hnr_attr.enable=%d\n", hnr_attr.enable); + } else if ((g_vi_thread_info.iso < 12800) && (hnr_attr.enable == TD_TRUE)) { // 12800 close hnr + printf(">>>>setp9: Close HNR state\n"); + hnr_attr.enable = TD_FALSE; + printf("----hnr_attr.enable=%d\n", hnr_attr.enable); + if (sample_hnr_set_dpc_crosstalk(master_pipe, sns_type, hnr_attr.enable) != TD_SUCCESS) { + goto stop_venc_and_vo; + } + sample_hnr_stop(vi_pipe, &hnr_cfg, hnr_param); + } else { + printf("---- Maintaining current state, hnr.enable=%s, iso = %d\n", + hnr_attr.enable ? "ON" : "OFF", g_vi_thread_info.iso); + continue; + } + } + + restore_terminal(); // 恢复终端设置 + sample_get_char("exit"); + sample_hnr_vi_destroy_thread(); + ret = TD_SUCCESS; + +stop_hnr: + sample_hnr_stop(vi_pipe, &hnr_cfg, hnr_param); +stop_venc_and_vo: + sample_hnr_stop_venc_and_vo(vpss_grp, sizeof(vpss_grp) / sizeof(vpss_grp[0])); +stop_vpss: + sample_hnr_stop_vpss(vpss_grp[0]); +stop_vi: + sample_comm_vi_un_bind_vpss(master_pipe, vi_chn, vpss_grp[0], 0); + sample_hnr_stop_vi(vi_pipe, &vi_cfg); +sys_exit: + sample_comm_sys_exit(); + return ret; +} + +static td_void *sample_hnr_snap_thread(td_void *param) +{ + td_s32 ret; + const td_s32 milli_sec = 1000; /* 1000: wait 1000ms */ + ot_video_frame_info get_frame_info; + ot_vi_frame_dump_attr dump_attr; + sample_hnr_snap_thread_info *thread_info = (sample_hnr_snap_thread_info *)param; + const ot_video_frame_info *send_frame_info[1]; + + dump_attr.enable = TD_TRUE; + dump_attr.depth = 3; /* 3: dump depth is 3 */ + ret = ss_mpi_vi_set_pipe_frame_dump_attr(thread_info->video_pipe, &dump_attr); + if (ret != TD_SUCCESS) { + sample_print("set pipe frame dump attr failed! ret:0x%x\n", ret); + return TD_NULL; + } + + ret = ss_mpi_vi_set_pipe_frame_source(thread_info->snap_pipe, OT_VI_PIPE_FRAME_SOURCE_USER); + if (ret != TD_SUCCESS) { + sample_print("vi set pipe frame source failed!\n"); + return TD_NULL; + } + + while (thread_info->start == TD_TRUE) { + ret = ss_mpi_vi_get_pipe_frame(thread_info->video_pipe, &get_frame_info, milli_sec); + if (ret != TD_SUCCESS) { + break; + } + + ret = ss_mpi_isp_run_once(thread_info->snap_pipe); + if (ret != TD_SUCCESS) { + sample_print("isp run once failed!\n"); + goto exit0; + } + + send_frame_info[0] = &get_frame_info; + ret = ss_mpi_vi_send_pipe_raw(thread_info->snap_pipe, send_frame_info, 1, milli_sec); + if (ret != TD_SUCCESS) { + sample_print("vi send pipe bas dump frame failed!\n"); + } + +exit0: + ret = ss_mpi_vi_release_pipe_frame(thread_info->video_pipe, &get_frame_info); + if (ret != TD_SUCCESS) { + sample_print("release pipe frame failed!\n"); + return TD_NULL; + } + } + + return TD_NULL; +} + +static td_s32 sample_hnr_snap_create_thread(ot_vi_pipe video_pipe, ot_vi_pipe capture_pipe) +{ + td_s32 ret; + + g_snap_thread_info.video_pipe = video_pipe; + g_snap_thread_info.snap_pipe = capture_pipe; + ret = pthread_create(&g_snap_thread_info.thread_id, TD_NULL, sample_hnr_snap_thread, &g_snap_thread_info); + if (ret != 0) { + sample_print("create capture thread failed!\n"); + return TD_FAILURE; + } + g_snap_thread_info.start = TD_TRUE; + + return TD_SUCCESS; +} + +static td_void sample_hnr_snap_set_vi_cfg(sample_sns_type sns_type, ot_vi_pipe vi_pipe, ot_vi_video_mode video_mode, + ot_size *size, sample_vi_cfg *vi_cfg) +{ + sample_hnr_get_default_cfg(sns_type, vi_pipe, video_mode, size, vi_cfg); + vi_cfg->pipe_info[vi_pipe].pipe_attr.compress_mode = OT_COMPRESS_MODE_NONE; + vi_cfg->pipe_info[vi_pipe].isp_need_run = TD_FALSE; +} + +static td_void sample_hnr_snap_destroy_thread(td_void) +{ + if (g_snap_thread_info.start == TD_TRUE) { + g_snap_thread_info.start = TD_FALSE; + pthread_join(g_snap_thread_info.thread_id, NULL); + } +} + +static td_s32 sample_hnr_snap(sample_hnr_param *hnr_param) +{ + td_s32 ret = TD_FAILURE; + sample_vi_cfg vi_cfg; + sample_sns_type sns_type = SENSOR0_TYPE; + const ot_vi_pipe vi_pipe = 0; + const ot_vi_chn vi_chn = 0; + ot_vpss_grp vpss_grp[1] = {0}; + ot_size in_size; + ot_hnr_cfg hnr_cfg; + const td_u32 vb_cnt = sample_hnr_get_vb_cnt(hnr_param); + + sample_hnr_snap_set_vi_cfg(sns_type, vi_pipe, hnr_param->video_mode, &in_size, &vi_cfg); + + if (sample_hnr_check_support(vi_pipe, hnr_param) != TD_SUCCESS) { + return TD_FAILURE; + } + + if (sample_hnr_start_vi(vi_pipe, &vi_cfg, &in_size, hnr_param, vb_cnt) != TD_SUCCESS) { + goto sys_exit; + } + + sample_hnr_sensor_cfg(vi_pipe, sns_type); + + sample_comm_vi_bind_vpss(vi_pipe, vi_chn, vpss_grp[0], 0); + if (sample_hnr_start_vpss(vpss_grp[0], &in_size) != TD_SUCCESS) { + goto stop_vi; + } + + if (sample_hnr_start_venc_and_vo(vpss_grp, sizeof(vpss_grp) / sizeof(vpss_grp[0]), &in_size) != TD_SUCCESS) { + goto stop_vpss; + } + + if (sample_hnr_set_blc(vi_pipe, sns_type) != TD_SUCCESS) { + goto stop_venc_and_vo; + } + + if (sample_hnr_vi_create_thread(vi_pipe, vi_pipe) != TD_SUCCESS) { + goto stop_venc_and_vo; + } + + set_nonblocking_mode(); + printf(">>>>snap_9: sample_hnr_start\n"); + while (g_vi_thread_info.start) { + sample_hnr_pause(); + if (g_vi_thread_info.iso > 25600) { // 25600 start hnr + if (hnr_attr.enable == TD_FALSE) { + printf(" ----g_vi_thread_info.iso = %d\n", g_vi_thread_info.iso); + if (sample_hnr_start(vi_pipe, in_size, &hnr_cfg, hnr_param) != TD_SUCCESS) { + goto stop_venc_and_vo; + } + if (sample_hnr_snap_create_thread(vi_pipe, vi_pipe) != TD_SUCCESS) { + goto stop_hnr; + } + if (sample_hnr_set_dpc_crosstalk(vi_pipe, sns_type, hnr_attr.enable) != TD_SUCCESS) { + goto stop_venc_and_vo; + } + } else { + continue; + } + printf("----hnr_attr.enable=%d\n", hnr_attr.enable); + } else if ((g_vi_thread_info.iso < 12800) && (hnr_attr.enable == TD_TRUE)) { // 12800 close hnr + printf(">>>>setp_9: Close HNR state\n"); + hnr_attr.enable = TD_FALSE; + printf("----hnr_attr.enable=%d\n", hnr_attr.enable); + if (sample_hnr_set_dpc_crosstalk(vi_pipe, sns_type, hnr_attr.enable) != TD_SUCCESS) { + goto stop_venc_and_vo; + } + sample_hnr_stop(vi_pipe, &hnr_cfg, hnr_param); + } else { + printf("---- Maintaining current state, hnr.enable=%s, iso = %d\n", + hnr_attr.enable ? "ON" : "OFF", g_vi_thread_info.iso); + continue; + } + } + restore_terminal(); // 恢复终端设置 + sample_get_char("exit"); + sample_hnr_vi_destroy_thread(); + sample_hnr_snap_destroy_thread(); + + ret = TD_SUCCESS; + +stop_hnr: + sample_hnr_stop(vi_pipe, &hnr_cfg, hnr_param); +stop_venc_and_vo: + sample_hnr_stop_venc_and_vo(vpss_grp, sizeof(vpss_grp) / sizeof(vpss_grp[0])); +stop_vpss: + sample_hnr_stop_vpss(vpss_grp[0]); +stop_vi: + sample_comm_vi_un_bind_vpss(vi_pipe, vi_chn, vpss_grp[0], 0); + sample_hnr_stop_vi(vi_pipe, &vi_cfg); +sys_exit: + sample_comm_sys_exit(); + return ret; +} + +static td_void sample_hnr_handle_sig(td_s32 signo) +{ + if (signo == SIGINT || signo == SIGTERM) { + g_sig_flag = 1; + } +} + +static td_void sample_register_sig_handler(td_void (*sig_handle)(td_s32)) +{ + struct sigaction sa; + + (td_void)memset_s(&sa, sizeof(struct sigaction), 0, sizeof(struct sigaction)); + sa.sa_handler = sig_handle; + sa.sa_flags = 0; + sigaction(SIGINT, &sa, TD_NULL); + sigaction(SIGTERM, &sa, TD_NULL); +} + +static td_s32 sample_hnr_execute_case(td_u32 case_index) +{ + td_s32 ret = TD_FAILURE; + sample_hnr_param hnr_param; + + switch (case_index) { + case 0: /* 0 hnr line mode */ + hnr_param.is_wdr_mode = TD_FALSE; + hnr_param.ref_mode = OT_HNR_REF_MODE_NORM; + hnr_param.normal_blend = TD_FALSE; + hnr_param.video_mode = OT_VI_VIDEO_MODE_ADVANCED; + ret = sample_hnr(&hnr_param); + break; + case 1: /* 1 hnr wdr mode */ + hnr_param.is_wdr_mode = TD_TRUE; + hnr_param.ref_mode = OT_HNR_REF_MODE_NORM; + hnr_param.normal_blend = TD_FALSE; + hnr_param.video_mode = OT_VI_VIDEO_MODE_NORM; + ret = sample_hnr(&hnr_param); + break; + case 2: /* 2 hnr line mode, snap */ + hnr_param.is_wdr_mode = TD_FALSE; + hnr_param.ref_mode = OT_HNR_REF_MODE_NONE; + hnr_param.normal_blend = TD_FALSE; + hnr_param.video_mode = OT_VI_VIDEO_MODE_ADVANCED; + ret = sample_hnr(&hnr_param); + break; + case 3: /* 3 hnr line mode, normal blend */ + hnr_param.is_wdr_mode = TD_FALSE; + hnr_param.ref_mode = OT_HNR_REF_MODE_NORM; + hnr_param.normal_blend = TD_TRUE; + hnr_param.video_mode = OT_VI_VIDEO_MODE_NORM; + ret = sample_hnr(&hnr_param); + break; + case 4: /* 4 hnr snap advanced mode, advanced mode of no reference frame */ + hnr_param.is_wdr_mode = TD_FALSE; + hnr_param.ref_mode = OT_HNR_REF_MODE_NONE_ADVANCED; + hnr_param.normal_blend = TD_FALSE; + hnr_param.video_mode = OT_VI_VIDEO_MODE_ADVANCED; + ret = sample_hnr_snap(&hnr_param); + break; + case 5: /* 5 hnr line switch to wdr */ + ret = sample_hnr_line_switch_to_wdr(); + break; + + default: + break; + } + return ret; +} + +static td_s32 sample_hnr_msg_proc_vb_pool_share(td_s32 pid) +{ + td_s32 ret; + td_u32 i; + td_bool isp_states[OT_VI_MAX_PIPE_NUM]; +#ifndef SAMPLE_MEM_SHARE_ENABLE + ot_vb_common_pools_id pools_id = {0}; + + if (ss_mpi_vb_get_common_pool_id(&pools_id) != TD_SUCCESS) { + sample_print("get common pool_id failed!\n"); + return TD_FAILURE; + } + + for (i = 0; i < pools_id.pool_cnt; ++i) { + if (ss_mpi_vb_pool_share(pools_id.pool[i], pid) != TD_SUCCESS) { + sample_print("vb pool share failed!\n"); + return TD_FAILURE; + } + } +#endif + ret = sample_comm_vi_get_isp_run_state(isp_states, OT_VI_MAX_PIPE_NUM); + if (ret != TD_SUCCESS) { + sample_print("get isp states fail\n"); + return TD_FAILURE; + } + + for (i = 0; i < OT_VI_MAX_PIPE_NUM; i++) { + if (!isp_states[i]) { + continue; + } + ret = ss_mpi_isp_mem_share(i, pid); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_isp_mem_share vi_pipe %d, pid %d fail\n", i, pid); + } + } + + return TD_SUCCESS; +} + +static td_void sample_hnr_msg_proc_vb_pool_unshare(td_s32 pid) +{ + td_s32 ret; + td_u32 i; + td_bool isp_states[OT_VI_MAX_PIPE_NUM]; +#ifndef SAMPLE_MEM_SHARE_ENABLE + ot_vb_common_pools_id pools_id = {0}; + if (ss_mpi_vb_get_common_pool_id(&pools_id) == TD_SUCCESS) { + for (i = 0; i < pools_id.pool_cnt; ++i) { + ret = ss_mpi_vb_pool_unshare(pools_id.pool[i], pid); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_vb_pool_unshare pool %d, pid %d fail\n", pools_id.pool[i], pid); + } + } + } +#endif + ret = sample_comm_vi_get_isp_run_state(isp_states, OT_VI_MAX_PIPE_NUM); + if (ret != TD_SUCCESS) { + sample_print("get isp states fail\n"); + return; + } + + for (i = 0; i < OT_VI_MAX_PIPE_NUM; i++) { + if (!isp_states[i]) { + continue; + } + ret = ss_mpi_isp_mem_unshare(i, pid); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_isp_mem_unshare vi_pipe %d, pid %d fail\n", i, pid); + } + } +} + +static td_s32 sample_hnr_ipc_msg_proc(const sample_ipc_msg_req_buf *msg_req_buf, + td_bool *is_need_fb, sample_ipc_msg_res_buf *msg_res_buf) +{ + td_s32 ret; + + if (msg_req_buf == TD_NULL || is_need_fb == TD_NULL) { + return TD_FAILURE; + } + + /* need feedback default */ + *is_need_fb = TD_TRUE; + + switch ((sample_msg_type)msg_req_buf->msg_type) { + case SAMPLE_MSG_TYPE_VB_POOL_SHARE_REQ: { + if (msg_res_buf == TD_NULL) { + return TD_FAILURE; + } + ret = sample_hnr_msg_proc_vb_pool_share(msg_req_buf->msg_data.pid); + msg_res_buf->msg_type = SAMPLE_MSG_TYPE_VB_POOL_SHARE_RES; + msg_res_buf->msg_data.is_req_success = (ret == TD_SUCCESS) ? TD_TRUE : TD_FALSE; + break; + } + case SAMPLE_MSG_TYPE_VB_POOL_UNSHARE_REQ: { + if (msg_res_buf == TD_NULL) { + return TD_FAILURE; + } + sample_hnr_msg_proc_vb_pool_unshare(msg_req_buf->msg_data.pid); + msg_res_buf->msg_type = SAMPLE_MSG_TYPE_VB_POOL_UNSHARE_RES; + msg_res_buf->msg_data.is_req_success = TD_TRUE; + break; + } + default: { + printf("unsupported msg type(%ld)!\n", msg_req_buf->msg_type); + return TD_FAILURE; + } + } + return TD_SUCCESS; +} + +#ifdef __LITEOS__ +td_s32 app_main(td_s32 argc, td_char *argv[]) +#else +td_s32 main(td_s32 argc, td_char *argv[]) +#endif +{ + td_s32 ret; + td_u32 index; + + if (argc != 2) { /* 2:arg num */ + sample_hnr_usage(argv[0]); + return TD_FAILURE; + } + + if (!strncmp(argv[1], "-h", 2)) { /* 2:arg num */ + sample_hnr_usage(argv[0]); + return TD_FAILURE; + } + + if ((strlen(argv[1]) != 1) || + (argv[1][0] < '0' || argv[1][0] > '5')) { /* only support case 0/1/2/3/4/5 */ + sample_hnr_usage(argv[0]); + return TD_FAILURE; + } + +#ifndef __LITEOS__ + sample_register_sig_handler(sample_hnr_handle_sig); +#endif + if (sample_ipc_server_init(sample_hnr_ipc_msg_proc) != TD_SUCCESS) { + printf("sample_ipc_server_init failed!!!\n"); + } +#ifdef CONFIG_USER_SPACE + sample_print("sdk init\n"); + SDK_init(); +#endif + index = atoi(argv[1]); + ret = sample_hnr_execute_case(index); + if ((ret == TD_SUCCESS) && (g_sig_flag == 0)) { + sample_print("\033[0;32mprogram exit normally!\033[0;39m\n"); + } else { + sample_print("\033[0;31mprogram exit abnormally!\033[0;39m\n"); + } + + sample_ipc_server_deinit(); + +#ifdef CONFIG_USER_SPACE + sample_print("sdk exit\n"); + SDK_exit(); +#endif +#ifdef __LITEOS__ + return ret; +#else + exit(ret); +#endif +} diff --git a/vendor/zsks/demo/mk.param b/vendor/zsks/demo/mk.param new file mode 100755 index 0000000000000000000000000000000000000000..8c276513da9aacbc99bb991c2622cf1121924911 --- /dev/null +++ b/vendor/zsks/demo/mk.param @@ -0,0 +1,60 @@ +# 各模块makefile均应在前面include此文件 +export ROOT_DIR := ../../../../ +export SDK_ROOT := $(ROOT_DIR)/platform/ss928v100_clang +export CUST_ROOT := $(ROOT_DIR)/vendor/zsks/ +export THIRD_PARTY_DIR := $(ROOT_DIR)/vendor/opensource +export MPP_DIR := $(SDK_ROOT)/smp/a55_linux/mpp +export OUTPUT_DIR := $(CUST_ROOT)/demo/output/ +export OBJS_DIR := $(CUST_ROOT)/demo/obj/ + +# 交叉编译器 +CLANG_PATH := $(ROOT_DIR)/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm +export SYSROOT_PATH := $(ROOT_DIR)/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot +COMPILER_PATH := $(CLANG_PATH)/bin/ +export CC:=$(COMPILER_PATH)/clang --target=aarch64-linux-ohos -Wno-unused-command-line-argument --sysroot $(SYSROOT_PATH) -isystem $(SYSROOT_PATH)/usr/include +export CXXCPP := $(COMPILER_PATH)/clang++ --target=aarch64-linux-ohos --sysroot=$(CLANG_PATH)/sysroot -nostdinc -isystem $(CLANG_PATH)/include/c++/v1 -isystem $(CLANG_PATH)/lib/clang/15.0.4/include -isystem $(SYSROOT_PATH)/usr/include/aarch64-linux-ohos -D_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION=2 -D__ARM_NEON=1 -D__ARM_NEON__=1 -mfpu=neon -resource-dir=$(CLANG_PATH)/lib/clang/15.0.4 +CC += -fuse-ld=lld -rtlib=compiler-rt + +# 编译所依赖的库目录 +export SDK_LINUX_OUT_LIB := $(MPP_DIR)/out/lib +export SDK_LINUX_OUT_SVP_NPU_LIB := $(SDK_LINUX_OUT_LIB)/svp_npu + +# 编译所依赖的头文件和源文件目录 +export SDK_LINUX_INCLUDE_DIR := $(MPP_DIR)/out/include +export SDK_SAMPLE_COMMON_DIR := $(MPP_DIR)/sample/common +export SVP_COMMON_DIR := $(MPP_DIR)/sample/svp/common + +# 第三方软件的库和头文件 +export OPENCV_LIB := $(THIRD_PARTY_DIR)/opencv/lib +export OPENCV_INCLUDE := $(THIRD_PARTY_DIR)/opencv/include/opencv4 + +# target输出的存储目录 +export TARGET_ROOT := ./ +export TARGET_DIR := $(TARGET_ROOT)/out/ + +export AUDIO_SAMPLE := $(MPP_DIR)/sample/audio/ +# cust 项目子模块目录 +export FACE_DETECTION_SAMPLE_DIR := $(CUST_ROOT)/demo/face_detection +export FRUIT_IDENTIFY_SAMPLE_DIR := $(CUST_ROOT)/demo/fruit_identify +export HNR_AUTO_SAMPLE_DIR := $(CUST_ROOT)/demo/hnr_auto +export KCF_TRACK_SAMPLE_DIR := $(CUST_ROOT)/demo/sample_kcf_track +export OPENCV_DNN_SAMPLE_DIR := $(CUST_ROOT)/demo/opencv_dnn + +################ select audio codec type for your sample ################ +#external acodec +#ACODEC_TYPE ?= ACODEC_TYPE_ES8388 +ACODEC_TYPE ?= ACODEC_TYPE_INNER +INNER_HDMI ?= y + +ifeq ($(ACODEC_TYPE), ACODEC_TYPE_ES8388) + CFLAGS += -DOT_ACODEC_TYPE_ES8388 +endif + +ifeq ($(INNER_HDMI), y) + CFLAGS += -DOT_ACODEC_TYPE_HDMI +endif + +ifeq ($(ACODEC_TYPE), ACODEC_TYPE_INNER) + CFLAGS += -DOT_ACODEC_TYPE_INNER +endif + diff --git a/vendor/zsks/demo/opencv_dnn/Makefile b/vendor/zsks/demo/opencv_dnn/Makefile new file mode 100755 index 0000000000000000000000000000000000000000..e7fd79d1b675e228512a1dd8867e07f42782d082 --- /dev/null +++ b/vendor/zsks/demo/opencv_dnn/Makefile @@ -0,0 +1,55 @@ +# 编译所需的公共文件 +include ../mk.param + +# 编译后生成的可执行文件名 +TARGET := main + +# 编译此工程需要包含的头文件 +CFLAGS += -I$(SDK_LINUX_INCLUDE_DIR)/ +CFLAGS += -I$(SDK_SAMPLE_COMMON_DIR)/ +CFLAGS += -Wno-psabi -I$(OPENCV_INCLUDE)/ +CFLAGS += -I$(OPENCV_DNN_SAMPLE_DIR)/ + + +# 编译此工程需要依赖的.c文件 +SMP_SRCS := $(SDK_SAMPLE_COMMON_DIR)/sample_comm_sys.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_ipc.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_isp.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vi.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vo.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_mipi_tx.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vpss.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/loadbmp.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vdec.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_venc.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sdk_exit.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sdk_init.c +SMP_SRCS += $(OPENCV_DNN_SAMPLE_DIR)/host_uvc.c +SMP_SRCS += $(OPENCV_DNN_SAMPLE_DIR)/media_vdec.c + +# 编译此工程需要依赖的.cpp文件 +CPP_SRCS += $(OPENCV_DNN_SAMPLE_DIR)/main.cpp + +# 编译此工程需要包含的库和宏 +CFLAGS += -O3 -g -Wall -DSAMPLE_HNR_SUPPORT +CFLAGS += -fstack-protector-strong +MPI_LIBS += -L$(OPENCV_LIB)/ +MPI_LIBS += -lopencv_videoio -lopencv_calib3d -lopencv_dnn -lopencv_core -lopencv_video +MPI_LIBS += -lopencv_flann -lopencv_features2d -lopencv_highgui -lopencv_imgcodecs +MPI_LIBS += -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching +MPI_LIBS += $(SDK_LINUX_OUT_LIB)/libsns_os04a10.a + +# 根据实际的类型设置,可以用set_sensor脚本设置 +SENSOR0_TYPE = -DSENSOR0_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT +SENSOR1_TYPE = -DSENSOR1_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT +SENSOR2_TYPE = -DSENSOR1_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT +SENSOR3_TYPE = -DSENSOR1_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT + +CFLAGS += $(SENSOR0_TYPE) +CFLAGS += $(SENSOR1_TYPE) +CFLAGS += $(SENSOR2_TYPE) +CFLAGS += $(SENSOR3_TYPE) +# 编译工程所需的mk文件 + +include ../sdk_linux.mk + diff --git a/vendor/zsks/demo/opencv_dnn/README.md b/vendor/zsks/demo/opencv_dnn/README.md new file mode 100755 index 0000000000000000000000000000000000000000..ebf83d843f5b46ed0aefdcea55391a5c1e21fc63 --- /dev/null +++ b/vendor/zsks/demo/opencv_dnn/README.md @@ -0,0 +1,141 @@ +## 2.1、opencv_dnn操作指导 + +### 2.1.1、opencv_dnn程序简介 + +* opencv_dnn sample基于SS928V100平台开发,以EulerPi套件为例,opencv_dnn sample是通过USB camera采集到的图片送到人脸检测模型进行推理,将得到的结果通过HDMI,显示在外接显示屏上面。 +* opencv_dnn案例,模型推理是在CPU上实现了,没有调用svp_npu的接口,都是调用opencv的接口来实现。 + +### 2.1.2、目录 + +```shell +pegasus/vendor/zsks/demo/opencv_dnn +|── media_vdec.c # 主要是将推理的结果在HDMI外接显示器上显示 +|── media_vdec.h +|── Makefile # 编译脚本 +|── main.cpp # opencv_dnn sample业务代码 +|── host_uvc.c #参考海思SDK的host_uvc代码 +└── host_uvc.h +``` + +![image-20250919181207847](pic/image-20250919181207847.png) + +* 请在opencv_dnn目录下创建一个onnx的文件夹,然后访问链接下载[onnx模型](https://github.com/opencv/opencv_zoo/blob/main/models/face_detection_yunet/face_detection_yunet_2023mar.onnx),并放入onnx目录下 + +![image-20251015164912907](pic/image-20251015164912907.png) + +![image-20251015165024778](pic/image-20251015165024778.png) + +* 在编译之前请确保你已经按照[opencv的移植文档](../../docs/opencv/README.md),对opencv进行交叉编译并将生成的库文件复制到opensource目录下了。具体目录结构如下 + +![image-20251023111425708](pic/image-20251023111425708.png) + +### 2.1.3、编译 + +* **注意:在编译zsks的demo之前,请确保你已经按照[patch介绍中的步骤](../../README.md#4patch介绍)把补丁打入海思SDK的sample目录下了**。 + +* 步骤1:先根据自己选择的操作系统,进入到对应的Pegasus所在目录下。 + +* 步骤2:使用Makefile的方式进行单编 + +* 在Ubuntu的命令行终端,分步执行下面的命令,单编 opencv_dnn sample + + ``` + cd pegasus/vendor/zsks/demo/opencv_dnn + + make clean && make + ``` + + * 在opencv_dnn/out目录下,生成一个名为main的可执行文件,如下图所示: + + ![image-20251023111135567](pic/image-20251023111135567.png) + +### 2.1.4、拷贝可执行程序和依赖文件至开发板的mnt目录下 + +**方式一:使用SD卡进行资料文件的拷贝** + +* 首先需要自己准备一张Micro sd卡(16G 左右即可),还得有一个Micro sd卡的读卡器。 + +image-20221114150205685 + +* 步骤1:将编译后生成的可执行文件、onnx模型文件、opencv的lib文件都拷贝到SD卡中。 + +![image-20251023112130092](pic/image-20251023112130092.png) + +* 步骤2:可执行文件拷贝成功后,将内存卡插入开发板的SD卡槽中,可通过挂载的方式挂载到板端,可选择SD卡 mount指令进行挂载。 + +image-20250210161601541 + +* 在开发板的终端,执行下面的命令进行SD卡的挂载 + * 如果挂载失败,可以参考[这个issue尝试解决](https://gitee.com/HiSpark/HiSpark_NICU2022/issues/I54932?from=project-issue) + + +```shell +mount -t vfat /dev/mmcblk1p1 /mnt +# 其中/dev/mmcblk1p1需要根据实际块设备号修改 +``` + +* 挂载成功后,如下图所示: + +![image-20251023112228717](pic/image-20251023112228717.png) + +**方式二:使用NFS挂载的方式进行资料文件的拷贝** + +* 首先需要自己准备一根网线 +* 步骤1:参考[博客链接](https://blog.csdn.net/Wu_GuiMing/article/details/115872995?spm=1001.2014.3001.5501)中的内容,进行nfs的环境搭建 +* 步骤2:将编译后生成的可执行文件、onnx模型文件、opencv库(在pegasus/vendor/opensource/opencv/lib目录下)都拷贝到Windows的nfs共享路径下 + +![image-20251023112328619](pic/image-20251023112328619.png) + +* 步骤3:在开发板的终端执行下面的命令,将Windows的nfs共享路径挂载至开发板的mnt目录下 + * 注意:这里IP地址请根据你开发板和电脑主机的实际IP地址进行填写 + + +``` +ifconfig eth0 192.168.100.100 +mount -o nolock,addr=192.168.100.10 -t nfs 192.168.100.10:/d/nfs /mnt +``` + +![image-20251023112352692](pic/image-20251023112352692.png) + +### 2.1.5、硬件连接 + +* 准备一个外接显示器和HDMI数据线,将HDMI的一头接在开发板的HDMI输出口,将HDMI的另外一头接在外接显示器的HDMI输入口。 + +![image-20250213112932380](pic/image-20250213112932380.png) + +* 将USB 摄像头接在EulerPi开发板的USB接口上。 + +image-20250919150630870 + +### 2.1.6、功能验证 + +* 在开发板的终端执行下面的命令,运行可执行文件 + +```c +# 把opencv的库添加到环境变量中 +export LD_LIBRARY_PATH=/mnt/lib:$LD_LIBRARY_PATH + +cd /mnt + +chmod +x main + +./main /dev/media0 -fMJPEG -s1920x1080 -Ftest.mjpg +``` + +![image-20251023112451423](pic/image-20251023112451423.png) + +* 此时,在HDMI的外接显示屏上即可出现实时码流,如下图所示: + +image-20250210170027454 + +* 如果您看到的现象和下图现象不一致,可以确认一下USB涉嫌头是否插入到开发板的USB口,并且在开发板的/dev目录下能够看到video0 和 video1两个设备节点。如果没有这两个设备节点,请确保镜像烧录正常。 + +![image-20250919151018659](pic/image-20250919151018659.png) + +* 正常情况下,我们会在外接显示屏上看到有人脸的区域被框出来,且在框框的左上角显示置信度。 + +![image-20250919183224310](pic/image-20250919183224310.png) + +* Ctrl + C,然后回车即可关闭程序 + +![image-20250919151519310](pic/image-20250919151519310.png) \ No newline at end of file diff --git a/vendor/zsks/demo/opencv_dnn/host_uvc.c b/vendor/zsks/demo/opencv_dnn/host_uvc.c new file mode 100755 index 0000000000000000000000000000000000000000..ee4620bdfdfcf0dd790ddd675b4f008e15a46ef2 --- /dev/null +++ b/vendor/zsks/demo/opencv_dnn/host_uvc.c @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * Copyright (c) 2025 Zhongshan Kuangshi Microelectronics Technology Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Modifications Author: yaohongtao (yht@cust.edu.cn) + */ +#include +#include +#include +#include +#include +#include +#include +#include "host_uvc.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +#define array_size(a) (sizeof(a) / sizeof((a)[0])) + +format_info g_pixel_formats[] = { + { "YUYV", V4L2_PIX_FMT_YUYV, 1 }, + { "MJPEG", V4L2_PIX_FMT_MJPEG, 1 }, + { "H264", V4L2_PIX_FMT_H264, 1 }, + { "H265", V4L2_PIX_FMT_H265, 1 }, + { "NV12", V4L2_PIX_FMT_NV12, 1 }, + { "NV21", V4L2_PIX_FMT_NV21, 1 }, +}; + +static struct option g_opts[] = { + {"file", 2, 0, 'F'}, /* 2 is a number */ + {"format", 1, 0, 'f'}, + {"help", 0, 0, 'h'}, + {"size", 1, 0, 's'}, + {0, 0, 0, 0} +}; + +static const format_info *sample_uvc_v4l2_format_by_fourcc(td_u32 fourcc) +{ + td_u32 i; + + for (i = 0; i < array_size(g_pixel_formats); ++i) { + if (g_pixel_formats[i].fourcc == fourcc) { + return &g_pixel_formats[i]; + } + } + return TD_NULL; +} + +static td_void sample_uvc_usage(const td_char *argv0) +{ + printf("sample_uvc_usage: %s device [options]\n", argv0); + printf("supported options:\n"); + printf("-f, --format format set the video format\n"); + printf("-F, --file[=name] write file\n"); + printf("-h, --help show help info\n"); + printf("-s, --size WxH set the frame size (eg. 1920x1080)\n\n"); + printf("inquire USB device format: ./sample_uvc --enum-formats\n\n"); + printf("example of setting USB device format:\n"); + printf(" ./opencv_dnn /dev/media0 -fH264 -s1920x1080 -Ftest.h264\n"); + printf(" ./opencv_dnn /dev/media0 -fH265 -s1920x1080 -Ftest.h265\n"); + printf(" ./opencv_dnn /dev/media0 -fMJPEG -s1920x1080 -Ftest.mjpg\n"); + printf(" ./opencv_dnn /dev/media0 -fYUYV -s1920x1080 -Ftest.yuv\n"); + printf(" ./opencv_dnn /dev/media0 -fNV21 -s640x360 -Ftest.yuv\n\n"); + printf("note: set macro MEDIA_WORK to 0 to write file on disk.\n\n"); +} + +static const format_info *sample_uvc_v4l2_format_by_name(const td_char *name) +{ + td_u32 i; + for (i = 0; i < array_size(g_pixel_formats); ++i) { + if (!strcmp(g_pixel_formats[i].name, name)) { + return &g_pixel_formats[i]; + } + } + return TD_NULL; +} + +static td_void sample_uvc_list_formats(td_void) +{ + td_u32 i; + for (i = 0; i < array_size(g_pixel_formats); i++) { + sample_print("%s (\"%c%c%c%c\", %u planes)\n", g_pixel_formats[i].name, g_pixel_formats[i].fourcc & 0xff, + (g_pixel_formats[i].fourcc >> 8) & 0xff, (g_pixel_formats[i].fourcc >> 16) & 0xff, /* 8,16:shift */ + (g_pixel_formats[i].fourcc >> 24) & 0xff, g_pixel_formats[i].n_planes); /* 24:shift */ + } +} + +static td_s32 sample_uvc_get_opt(td_s32 argc, td_char *argv[], uvc_ctrl_info *ctrl_info) +{ + td_s32 c; + const format_info *info; + td_char *endptr; + + while ((c = getopt_long(argc, argv, "B:c::Cd:f:F::hi:Iln:p::q:r:R::s:t:uw:x:", g_opts, TD_NULL)) != -1) { + switch (c) { + case 'f': + if (!strcmp("help", optarg)) { + sample_uvc_list_formats(); + return TD_FAILURE; + } + ctrl_info->do_set_format = 1; + info = sample_uvc_v4l2_format_by_name(optarg); + if (info == TD_NULL) { + sample_print("Unsupported video format '%s'\n", optarg); + return TD_FAILURE; + } + ctrl_info->pixelformat = info->fourcc; + break; + case 'F': + ctrl_info->do_file = 1; + if (optarg) { + ctrl_info->pattern = optarg; + } + break; + case 'h': + sample_uvc_usage(argv[0]); + return TD_FAILURE; + case 's': + ctrl_info->do_capture = 1; + ctrl_info->do_set_format = 1; + ctrl_info->width = strtol(optarg, &endptr, 10); /* 10:base */ + if (*endptr != 'x' || endptr == optarg) { + sample_print("Invalid size '%s'\n", optarg); + return TD_FAILURE; + } + ctrl_info->height = strtol(endptr + 1, &endptr, 10); /* 10:base */ + if (*endptr != 0) { + sample_print("Invalid size '%s'\n", optarg); + return TD_FAILURE; + } + break; + default: + sample_print("Run %s -h for help.\n", argv[0]); + return TD_FAILURE; + } + } + return TD_SUCCESS; +} + +static td_void sample_uvc_ctrl_info_init(uvc_ctrl_info *ctrl_info) +{ + ctrl_info->pattern = "frame-#.bin"; + ctrl_info->width = 640; /* 640:width */ + ctrl_info->height = 480; /* 480:height */ + ctrl_info->pixelformat = V4L2_PIX_FMT_YUYV; +} + +const td_char *sample_uvc_v4l2_format_name(td_u32 fourcc) +{ + const format_info *format; + static td_char format_name[5]; /* 5: array len */ + td_u32 i; + format = sample_uvc_v4l2_format_by_fourcc(fourcc); + if (format) { + return format->name; + } + + for (i = 0; i < 4; ++i) { /* 4: format */ + format_name[i] = fourcc & 0xff; + fourcc >>= 8; /* 8: shift */ + } + + format_name[4] = '\0'; /* 4: end */ + return format_name; +} + +td_s32 sample_host_uvc(td_s32 argc, td_char *argv[], uvc_ctrl_info *ctrl_info) +{ + int ret; + sample_uvc_ctrl_info_init(ctrl_info); + ret = sample_uvc_get_opt(argc, argv, ctrl_info); + if (ret != TD_SUCCESS) { + return TD_FAILURE; + } + if (optind >= argc) { + sample_uvc_usage(argv[0]); + return TD_FAILURE; + } + return TD_SUCCESS ; +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif /* End of #ifdef __cplusplus */ diff --git a/vendor/zsks/demo/opencv_dnn/host_uvc.h b/vendor/zsks/demo/opencv_dnn/host_uvc.h new file mode 100755 index 0000000000000000000000000000000000000000..2260d03101ecb6a09ad12f938aca663b297f8059 --- /dev/null +++ b/vendor/zsks/demo/opencv_dnn/host_uvc.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __HOST_UVC_H__ +#define __HOST_UVC_H__ + +#include +#include +#include +#include "sample_comm.h" +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +#ifndef V4L2_PIX_FMT_H265 +#define V4L2_PIX_FMT_H265 v4l2_fourcc('H', '2', '6', '5') /* H.265 aka HEVC */ +#endif + +typedef struct { + const td_char *name; + td_u32 fourcc; + td_char n_planes; +} format_info; + +typedef struct { + const td_char *pattern; + const td_char *type_name; + td_s32 do_capture; + td_s32 do_set_format; + td_u32 pixelformat; + td_s32 do_file; + td_u32 input; + td_u32 width; + td_u32 height; +} uvc_ctrl_info; + +td_s32 sample_host_uvc(td_s32 argc, td_char *argv[], uvc_ctrl_info *ctrl_info); +const td_char *sample_uvc_v4l2_format_name(td_u32 fourcc); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif /* End of #ifdef __cplusplus */ + +#endif /* end of #ifndef __HOST_UVC_H__ */ diff --git a/vendor/zsks/demo/opencv_dnn/main.cpp b/vendor/zsks/demo/opencv_dnn/main.cpp new file mode 100755 index 0000000000000000000000000000000000000000..1b31d540155755992e62b75f60ee6d7e2ccc434b --- /dev/null +++ b/vendor/zsks/demo/opencv_dnn/main.cpp @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2025 Zhongshan Kuangshi Microelectronics Technology Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contact Information + * Author: yaohongtao + * Phone: +86-18604465633 + * Email: yht@cust.edu.cn + */ + +#include +#include +#include +#include +#include +#include +#include "host_uvc.h" +#include "media_vdec.h" +#include "sdk_module_init.h" + +using namespace cv; +using namespace std; +using namespace std::chrono; + +td_bool g_uvc_exit = TD_FALSE; + +// 优化内存管理类 +class MemoryManager { +public: + static void optimizeMemory() + { + cv::setUseOptimized(true); + cv::setNumThreads(4); /* 4: Number of CPU cores */ + } +}; + +static void sample_uvc_exit_signal_handler(int signal) +{ + printf("收到退出信号,准备退出...\n"); + g_uvc_exit = TD_TRUE; +} + +int main(int argc, char** argv) +{ + // 优化内存使用 + MemoryManager::optimizeMemory(); + + int ret; + uvc_ctrl_info ctrl_info = {0}; + struct sigaction sig_exit; + sig_exit.sa_handler = sample_uvc_exit_signal_handler; + sigaction(SIGINT, &sig_exit, nullptr); + sigaction(SIGTERM, &sig_exit, nullptr); + ret = sample_host_uvc(argc, argv, &ctrl_info); + if (ret != TD_SUCCESS) { + return TD_FAILURE; + } +#ifdef CONFIG_USER_SPACE + SDK_init(); +#endif + // OpenCV V4L2 video capture + VideoCapture cap(0, cv::CAP_V4L2); + if (!cap.isOpened()) { + printf("Error: Failed to open camera device!\n"); + return -1; + } + + int width = ctrl_info.width; + int height = ctrl_info.height; + int fps = 30; + + // 设置摄像头参数 + cap.set(CAP_PROP_FRAME_WIDTH, width); + cap.set(CAP_PROP_FRAME_HEIGHT, height); + cap.set(CAP_PROP_FPS, fps); + cap.set(CAP_PROP_BUFFERSIZE, 4); /* 4: Increase buffer size */ + + // 根据格式设置摄像头参数 + const char* type_name = sample_uvc_v4l2_format_name(ctrl_info.pixelformat); + if (strcmp(type_name, "MJPEG") == 0) { + cap.set(CAP_PROP_FOURCC, VideoWriter::fourcc('M', 'J', 'P', 'G')); + } else if (strcmp(type_name, "YUYV") == 0) { + cap.set(CAP_PROP_FOURCC, VideoWriter::fourcc('Y', 'U', 'Y', 'V')); + } else { + std::cerr << "只支持 YUYV 或 MJPEG 格式,请用 -fYUYV 或 -fMJPEG 参数启动!" << std::endl; + return -1; + } + + // 验证设置是否成功 + int actual_width = cap.get(CAP_PROP_FRAME_WIDTH); + int actual_height = cap.get(CAP_PROP_FRAME_HEIGHT); + double actual_fps = cap.get(CAP_PROP_FPS); + + printf("Requested resolution: %dx%d @ %d fps\n", width, height, fps); + printf("Actual resolution: %dx%d @ %.2f fps\n", actual_width, actual_height, actual_fps); + printf("Using format: %s\n", type_name); + + if (actual_width != width || actual_height != height) { + printf("Warning: Camera does not support requested resolution, using actual resolution\n"); + width = actual_width; + height = actual_height; + } + + // 初始化人脸检测器,使用更快的参数 + const string modelPath = "./onnx/face_detection_yunet_2023mar.onnx"; + Ptr detector = FaceDetectorYN::create( + /* 256 144 input width height 0.6 score_threshold 0.7 nms_threshold */ + modelPath, "", Size(256, 144), 0.6, 0.7, 100); /* 100 top_k */ + if (!detector) { + printf("Error: Failed to create face detector\n"); + return -1; + } + + // 初始化媒体链路 + if (sample_uvc_media_init(type_name, width, height) != TD_SUCCESS) { + std::cerr << "media start failed!" << std::endl; + return -1; + } + + const int MAX_RETRIES = 3; /* 3: max retries */ + int retry_count = 0; + bool device_reconnected = false; + int empty_frame_count = 0; + const int MAX_EMPTY_FRAMES = 10; /* 10: max empty frames */ + + // 预分配Mat对象 + Mat frame; + Mat faces; + Mat yuvFrame; + vector mjpeg_buffer; + mjpeg_buffer.reserve(width * height * 3 / 2); /* 3 / 2 YUV420 memory size */ + + // 创建MJPEG编码器 + vector mjpeg_params = { + IMWRITE_JPEG_QUALITY, 90, /* 90: JPEG quality */ + IMWRITE_JPEG_OPTIMIZE, 1, + IMWRITE_JPEG_PROGRESSIVE, 0 + }; + + // 预分配VPSS缓冲区 + ot_size pic_size; + pic_size.width = static_cast(width); + pic_size.height = static_cast(height); + + if (strcmp(type_name, "YUYV") == 0) { + // 预分配YUYV缓冲区,每个像素2字节 + yuvFrame.create(height, width, CV_8UC2); + } + + // 新增:人脸检测相关变量 + int frame_count = 0; + vector last_detected_faces; + vector last_confidence_scores; + const int DETECT_INTERVAL = 5; /* 5: Detect every 5 frames */ + + while (!g_uvc_exit) { + cap >> frame; + + if (frame.empty()) { + empty_frame_count++; + printf("Empty frame %d/%d, attempting to reconnect...\n", empty_frame_count, MAX_EMPTY_FRAMES); + + if (empty_frame_count >= MAX_EMPTY_FRAMES) { + if (retry_count < MAX_RETRIES) { + printf("Attempting to reconnect camera (attempt %d/%d)...\n", retry_count + 1, MAX_RETRIES); + cap.release(); + sleep(1); + + cap.open(0, cv::CAP_V4L2); + if (cap.isOpened()) { + cap.set(CAP_PROP_FRAME_WIDTH, width); + cap.set(CAP_PROP_FRAME_HEIGHT, height); + cap.set(CAP_PROP_FPS, fps); + cap.set(CAP_PROP_BUFFERSIZE, 4); /* 4 cap prop buffer size */ + if (strcmp(type_name, "MJPEG") == 0) { + cap.set(CAP_PROP_FOURCC, VideoWriter::fourcc('M', 'J', 'P', 'G')); + } else { + cap.set(CAP_PROP_FOURCC, VideoWriter::fourcc('Y', 'U', 'Y', 'V')); + } + + actual_width = cap.get(CAP_PROP_FRAME_WIDTH); + actual_height = cap.get(CAP_PROP_FRAME_HEIGHT); + actual_fps = cap.get(CAP_PROP_FPS); + + printf("Camera reconnected successfully\n"); + printf("New resolution: %dx%d @ %.2f fps\n", actual_width, actual_height, actual_fps); + + retry_count = 0; + empty_frame_count = 0; + device_reconnected = true; + continue; + } + retry_count++; + printf("Retry %d/%d failed\n", retry_count, MAX_RETRIES); + } else { + printf("Failed to reconnect after %d attempts\n", MAX_RETRIES); + break; + } + } + continue; + } + + empty_frame_count = 0; + retry_count = 0; + + if (device_reconnected) { + printf("Reinitializing media pipeline...\n"); + if (sample_uvc_media_init(type_name, width, height) != TD_SUCCESS) { + std::cerr << "media reinit failed!" << std::endl; + break; + } + device_reconnected = false; + } + + // 人脸检测逻辑 + frame_count++; + bool is_detect_frame = (frame_count % DETECT_INTERVAL == 0); + + if (is_detect_frame) { + // 预处理阶段 + Mat small_frame; + resize(frame, small_frame, Size(256, 144), 0, 0, INTER_NEAREST); /* 256 144 resize width height */ + + // 检测阶段 + detector->detect(small_frame, faces); + + // 处理检测结果 + const int minFaceSize = 50; /* 50 min face size */ + last_detected_faces.clear(); + last_confidence_scores.clear(); + + if (faces.rows > 0) { + float scale_x = static_cast(frame.cols) / small_frame.cols; + float scale_y = static_cast(frame.rows) / small_frame.rows; + + for (int i = 0; i < faces.rows; ++i) { + int x = static_cast(faces.at(i, 0) * scale_x); + int y = static_cast(faces.at(i, 1) * scale_y); + int w = static_cast(faces.at(i, 2) * scale_x); /* 2 the number of width */ + int h = static_cast(faces.at(i, 3) * scale_y); /* 3 the number of heigth */ + float score = faces.at(i, 4); /* 4 the number of socre */ + + if (w >= minFaceSize && h >= minFaceSize) { + last_detected_faces.emplace_back(x, y, w, h); + last_confidence_scores.push_back(score); + } + } + } + } + + // 绘制人脸框 + for (size_t i = 0; i < last_detected_faces.size(); ++i) { + rectangle(frame, last_detected_faces[i], Scalar(0, 255, 0), 2); /* 0 255 0 R G B, 2 Line width */ + char scoreText[20]; /* 20 text buffer size */ + ret = snprintf(scoreText, sizeof(scoreText), "Conf: %.2f", + last_confidence_scores[i] / 100); /* 100 get the percentage */ + if (ret < 0) { + printf("[func]:%s [line]:%d [info]:snprintf failed\n", __FUNCTION__, __LINE__); + break; + } + putText(frame, scoreText, Point(last_detected_faces[i].x, + last_detected_faces[i].y - 5), /* 5 pic height minus 5 */ + /* 0.5 scaling ratio 0 255 0 R G B, 1 Line width */ + FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0, 255, 0), 1); + } + + // 后续处理保持不变 + if (strcmp(type_name, "MJPEG") == 0) { + imencode(".jpg", frame, mjpeg_buffer, mjpeg_params); + ret = sample_uvc_media_send_data(mjpeg_buffer.data(), mjpeg_buffer.size(), + width, &pic_size, "MJPEG"); + } else { + // YUYV格式转换 + cvtColor(frame, yuvFrame, COLOR_BGR2YUV_YUY2); + ret = sample_uvc_media_send_data(yuvFrame.data, yuvFrame.total() * yuvFrame.elemSize(), + yuvFrame.step, &pic_size, "YUYV"); + } + + if (ret != 0) { + ret = -errno; + std::cerr << "write error: " << strerror(-ret) << std::endl; + } + } + + printf("--media exit...\n"); + sample_uvc_media_stop_receive_data(); + sample_uvc_media_exit(); + cap.release(); + +#ifdef CONFIG_USER_SPACE + SDK_exit(); +#endif + + return 0; +} diff --git a/vendor/zsks/demo/opencv_dnn/media_vdec.c b/vendor/zsks/demo/opencv_dnn/media_vdec.c new file mode 100755 index 0000000000000000000000000000000000000000..82957d723c4931c394fc55b2444b60911ef79baf --- /dev/null +++ b/vendor/zsks/demo/opencv_dnn/media_vdec.c @@ -0,0 +1,803 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * Copyright (c) 2025 Zhongshan Kuangshi Microelectronics Technology Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Modifications Author: yaohongtao (yht@cust.edu.cn) + */ + +#include "media_vdec.h" +#include + +ot_vb_src g_vdec_vb_source = OT_VB_SRC_MOD; + +#define REF_NUM 2 +#define DISPLAY_NUM 2 + +static vdec_display_cfg g_vdec_display_cfg = { + .pic_size = PIC_1080P, + .intf_sync = OT_VO_OUT_1080P60, + .intf_type = OT_VO_INTF_HDMI, +}; + +static td_u32 g_input_width; +static td_u32 g_input_height; +static ot_size g_disp_size; +sample_vo_cfg g_vo_config; +static td_bool g_is_need_vdec = TD_TRUE; + +static td_s32 sample_uvc_init_module_vb(sample_vdec_attr *sample_vdec, td_u32 vdec_chn_num, ot_payload_type type, + td_u32 len) +{ + td_u32 i; + td_s32 ret; + for (i = 0; (i < vdec_chn_num) && (i < len); i++) { + sample_vdec[i].type = type; + sample_vdec[i].width = g_input_width; + sample_vdec[i].height = g_input_height; + sample_vdec[i].mode = sample_comm_vdec_get_lowdelay_en() ? OT_VDEC_SEND_MODE_COMPAT : + OT_VDEC_SEND_MODE_FRAME; + sample_vdec[i].sample_vdec_video.dec_mode = OT_VIDEO_DEC_MODE_IP; + sample_vdec[i].sample_vdec_video.bit_width = OT_DATA_BIT_WIDTH_8; + if (type == OT_PT_JPEG) { + sample_vdec[i].sample_vdec_video.ref_frame_num = 0; + } else { + sample_vdec[i].sample_vdec_video.ref_frame_num = REF_NUM; + } + sample_vdec[i].display_frame_num = DISPLAY_NUM; + sample_vdec[i].frame_buf_cnt = (type == OT_PT_JPEG) ? (sample_vdec[i].display_frame_num + 1) : + (sample_vdec[i].sample_vdec_video.ref_frame_num + sample_vdec[i].display_frame_num + 1); + if (type == OT_PT_JPEG) { + sample_vdec[i].sample_vdec_picture.pixel_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_420; + sample_vdec[i].sample_vdec_picture.alpha = 255; /* 255:pic alpha value */ + } + } + ret = sample_comm_vdec_init_vb_pool(vdec_chn_num, &sample_vdec[0], len); + if (ret != TD_SUCCESS) { + sample_print("init mod common vb fail for %#x!\n", ret); + return ret; + } + return ret; +} + +static td_s32 sample_uvc_init_sys_and_vb(sample_vdec_attr *sample_vdec, td_u32 vdec_chn_num, ot_payload_type type, + td_u32 len) +{ + ot_vb_cfg vb_cfg; + ot_pic_buf_attr buf_attr = {0}; + td_s32 ret; + ret = sample_comm_sys_get_pic_size(g_vdec_display_cfg.pic_size, &g_disp_size); + if (ret != TD_SUCCESS) { + sample_print("sys get pic size fail for %#x!\n", ret); + return ret; + } + buf_attr.align = 0; + buf_attr.bit_width = OT_DATA_BIT_WIDTH_8; + buf_attr.compress_mode = OT_COMPRESS_MODE_SEG; + buf_attr.height = 2160; /* 2160:height */ + buf_attr.width = 3840; /* 3840:width */ + buf_attr.pixel_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_420; + + (td_void)memset_s(&vb_cfg, sizeof(ot_vb_cfg), 0, sizeof(ot_vb_cfg)); + vb_cfg.max_pool_cnt = 1; + vb_cfg.common_pool[0].blk_cnt = 10 * vdec_chn_num; /* 10:common vb cnt */ + vb_cfg.common_pool[0].blk_size = ot_common_get_pic_buf_size(&buf_attr); + ret = sample_comm_sys_init(&vb_cfg); + if (ret != TD_SUCCESS) { + sample_print("init sys fail for %#x!\n", ret); + sample_comm_sys_exit(); + return ret; + } + + if (g_is_need_vdec == TD_TRUE) { + ret = sample_uvc_init_module_vb(&sample_vdec[0], vdec_chn_num, type, len); + if (ret != TD_SUCCESS) { + sample_print("init mod vb fail for %#x!\n", ret); + sample_comm_vdec_exit_vb_pool(); + sample_comm_sys_exit(); + return ret; + } + } + + return ret; +} + +static td_s32 sample_uvc_vdec_bind_vpss(td_u32 vpss_grp_num) +{ + td_u32 i; + td_s32 ret = TD_SUCCESS; + for (i = 0; i < vpss_grp_num; i++) { + ret = sample_comm_vdec_bind_vpss(i, i); + if (ret != TD_SUCCESS) { + sample_print("vdec bind vpss fail for %#x!\n", ret); + return ret; + } + } + return ret; +} + +static td_void sample_uvc_stop_vpss(ot_vpss_grp vpss_grp, td_bool *vpss_chn_enable, td_u32 chn_array_size) +{ + td_s32 i; + for (i = vpss_grp; i >= 0; i--) { + vpss_grp = i; + sample_common_vpss_stop(vpss_grp, &vpss_chn_enable[0], chn_array_size); + } +} + +static td_s32 sample_uvc_vdec_unbind_vpss(td_u32 vpss_grp_num) +{ + td_u32 i; + td_s32 ret = TD_SUCCESS; + for (i = 0; i < vpss_grp_num; i++) { + ret = sample_comm_vdec_un_bind_vpss(i, i); + if (ret != TD_SUCCESS) { + sample_print("vdec unbind vpss fail for %#x!\n", ret); + } + } + return ret; +} + +static td_void sample_uvc_config_vpss_grp_attr(ot_vpss_grp_attr *vpss_grp_attr) +{ + vpss_grp_attr->max_width = g_input_width; + vpss_grp_attr->max_height = g_input_height; + vpss_grp_attr->frame_rate.src_frame_rate = -1; + vpss_grp_attr->frame_rate.dst_frame_rate = -1; + vpss_grp_attr->pixel_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_420; + vpss_grp_attr->nr_en = TD_FALSE; + vpss_grp_attr->ie_en = TD_FALSE; + vpss_grp_attr->dci_en = TD_FALSE; + vpss_grp_attr->dei_mode = OT_VPSS_DEI_MODE_OFF; + vpss_grp_attr->buf_share_en = TD_FALSE; +} + +static td_void sample_uvc_stop_vdec(td_u32 vdec_chn_num) +{ + if (g_is_need_vdec == TD_FALSE) { + return; + } + sample_comm_vdec_stop(vdec_chn_num); + sample_comm_vdec_exit_vb_pool(); + + return; +} + +static td_s32 sample_uvc_start_vdec(sample_vdec_attr *sample_vdec, td_u32 vdec_chn_num, td_u32 len) +{ + td_s32 ret; + + if (g_is_need_vdec == TD_FALSE) { + return TD_SUCCESS; + } + ret = sample_comm_vdec_start(vdec_chn_num, &sample_vdec[0], len); + if (ret != TD_SUCCESS) { + sample_print("start VDEC fail for %#x!\n", ret); + sample_uvc_stop_vdec(vdec_chn_num); + } + + return ret; +} + +static td_s32 sample_uvc_config_vpss_ldy_attr(td_u32 vpss_grp_num) +{ + td_u32 i; + td_s32 ret; + ot_low_delay_info vpss_ldy_info; + + for (i = 0; i < vpss_grp_num; i++) { + ret = ss_mpi_vpss_get_low_delay_attr(i, 0, &vpss_ldy_info); + if (ret != TD_SUCCESS) { + sample_print("vpss get low delay attr fail for %#x!\n", ret); + return ret; + } + vpss_ldy_info.enable = TD_TRUE; + vpss_ldy_info.line_cnt = g_disp_size.height / 4 * 1; /* 1/4:lowdelay line num */ + ret = ss_mpi_vpss_set_low_delay_attr(i, 0, &vpss_ldy_info); + if (ret != TD_SUCCESS) { + sample_print("vpss set low delay attr fail for %#x!\n", ret); + return ret; + } + } + return TD_SUCCESS; +} + +static td_s32 sample_uvc_start_vpss(ot_vpss_grp *vpss_grp, td_u32 vpss_grp_num, + td_bool *vpss_chn_enable, td_u32 arr_len) +{ + td_u32 i; + td_s32 ret; + ot_vpss_chn_attr vpss_chn_attr[OT_VPSS_MAX_CHN_NUM]; + ot_vpss_grp_attr vpss_grp_attr = {0}; + sample_uvc_config_vpss_grp_attr(&vpss_grp_attr); + (td_void)memset_s(vpss_chn_enable, arr_len * sizeof(td_bool), 0, arr_len * sizeof(td_bool)); + if (arr_len > 1) { + vpss_chn_enable[0] = TD_TRUE; + vpss_chn_attr[0].width = g_disp_size.width; + vpss_chn_attr[0].height = g_disp_size.height; + vpss_chn_attr[0].chn_mode = OT_VPSS_CHN_MODE_USER; + vpss_chn_attr[0].compress_mode = OT_COMPRESS_MODE_NONE; + vpss_chn_attr[0].pixel_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_420; + vpss_chn_attr[0].video_format = OT_VIDEO_FORMAT_LINEAR; + vpss_chn_attr[0].frame_rate.src_frame_rate = -1; + vpss_chn_attr[0].frame_rate.dst_frame_rate = -1; + vpss_chn_attr[0].depth = 0; + vpss_chn_attr[0].mirror_en = TD_FALSE; + vpss_chn_attr[0].flip_en = TD_FALSE; + vpss_chn_attr[0].border_en = TD_FALSE; + vpss_chn_attr[0].aspect_ratio.mode = OT_ASPECT_RATIO_NONE; + } + + for (i = 0; i < vpss_grp_num; i++) { + *vpss_grp = i; + ret = sample_common_vpss_start(*vpss_grp, &vpss_chn_enable[0], + &vpss_grp_attr, vpss_chn_attr, OT_VPSS_MAX_CHN_NUM); + if (ret != TD_SUCCESS) { + sample_print("start VPSS fail for %#x!\n", ret); + sample_uvc_stop_vpss(*vpss_grp, &vpss_chn_enable[0], OT_VPSS_MAX_CHN_NUM); + return ret; + } + } + ret = sample_uvc_config_vpss_ldy_attr(vpss_grp_num); + if (ret != TD_SUCCESS) { + sample_uvc_stop_vpss(*vpss_grp, &vpss_chn_enable[0], OT_VPSS_MAX_CHN_NUM); + return ret; + } + ret = sample_uvc_vdec_bind_vpss(vpss_grp_num); + if (ret != TD_SUCCESS) { + sample_uvc_vdec_unbind_vpss(vpss_grp_num); + sample_uvc_stop_vpss(*vpss_grp, &vpss_chn_enable[0], OT_VPSS_MAX_CHN_NUM); + } + return ret; +} + +static td_s32 sample_uvc_vpss_bind_vo(sample_vo_cfg vo_config, td_u32 vpss_grp_num) +{ + td_u32 i; + ot_vo_layer vo_layer; + td_s32 ret = TD_SUCCESS; + vo_layer = vo_config.vo_dev; + for (i = 0; i < vpss_grp_num; i++) { + ret = sample_comm_vpss_bind_vo(i, 0, vo_layer, i); + if (ret != TD_SUCCESS) { + sample_print("vpss bind vo fail for %#x!\n", ret); + return ret; + } + } + return ret; +} + +static td_s32 sample_uvc_vpss_unbind_vo(td_u32 vpss_grp_num, sample_vo_cfg vo_config) +{ + td_u32 i; + ot_vo_layer vo_layer = vo_config.vo_dev; + td_s32 ret = TD_SUCCESS; + for (i = 0; i < vpss_grp_num; i++) { + ret = sample_comm_vpss_un_bind_vo(i, 0, vo_layer, i); + if (ret != TD_SUCCESS) { + sample_print("vpss unbind vo fail for %#x!\n", ret); + } + } + return ret; +} + +static td_void sample_uvc_get_default_vo_cfg(sample_vo_cfg *vo_config) +{ + vo_config->vo_dev = SAMPLE_VO_DEV_UHD; + vo_config->vo_intf_type = g_vdec_display_cfg.intf_type; + vo_config->intf_sync = g_vdec_display_cfg.intf_sync; + vo_config->pic_size = g_vdec_display_cfg.pic_size; + vo_config->bg_color = COLOR_RGB_BLUE; + vo_config->dis_buf_len = 3; /* 3:buf length */ + vo_config->dst_dynamic_range = OT_DYNAMIC_RANGE_SDR8; + vo_config->vo_mode = VO_MODE_1MUX; + vo_config->pix_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_420; + vo_config->disp_rect.x = 0; + vo_config->disp_rect.y = 0; + vo_config->disp_rect.width = g_disp_size.width; + vo_config->disp_rect.height = g_disp_size.height; + vo_config->image_size.width = g_disp_size.width; + vo_config->image_size.height = g_disp_size.height; + vo_config->vo_part_mode = OT_VO_PARTITION_MODE_SINGLE; + vo_config->compress_mode = OT_COMPRESS_MODE_NONE; +} + +static td_s32 sample_uvc_start_vo(sample_vo_cfg *vo_config, td_u32 vpss_grp_num) +{ + td_s32 ret; + sample_uvc_get_default_vo_cfg(vo_config); + ret = sample_comm_vo_start_vo(vo_config); + if (ret != TD_SUCCESS) { + sample_print("start VO fail for %#x!\n", ret); + sample_comm_vo_stop_vo(vo_config); + return ret; + } + ret = sample_uvc_vpss_bind_vo(*vo_config, vpss_grp_num); + if (ret != TD_SUCCESS) { + sample_uvc_vpss_unbind_vo(vpss_grp_num, *vo_config); + sample_comm_vo_stop_vo(vo_config); + } + + return ret; +} + +static ot_payload_type sample_uvc_get_payload_type(const td_char *type_name) +{ + if (strcmp(type_name, "H264") == 0) { + return OT_PT_H264; + } else if (strcmp(type_name, "H265") == 0) { + return OT_PT_H265; + } else if (strcmp(type_name, "MJPEG") == 0) { + return OT_PT_JPEG; + } else { + sample_print("type name error!\n"); + return OT_PT_BUTT; + } +} + +static td_void sample_uvc_update_vdec_flag(const td_char *type_name) +{ + if ((strcmp(type_name, "H264") == 0) || + (strcmp(type_name, "H265") == 0) || + (strcmp(type_name, "MJPEG") == 0)) { + g_is_need_vdec = TD_TRUE; + } else { + g_is_need_vdec = TD_FALSE; + } +} + +td_s32 sample_uvc_media_init(const td_char *type_name, td_u32 width, td_u32 height) +{ + td_s32 ret; + td_u32 vdec_chn_num; + td_u32 vpss_grp_num; + sample_vdec_attr sample_vdec[OT_VDEC_MAX_CHN_NUM]; + td_bool vpss_chn_enable[OT_VPSS_MAX_CHN_NUM]; + ot_vpss_grp vpss_grp; + + ot_payload_type payload_type = OT_PT_H264; + vdec_chn_num = 1; + vpss_grp_num = vdec_chn_num; + g_input_width = width; + g_input_height = height; + sample_uvc_update_vdec_flag(type_name); + + if (g_is_need_vdec == TD_TRUE) { + payload_type = sample_uvc_get_payload_type(type_name); + if (payload_type == OT_PT_BUTT) { + return TD_FAILURE; + } + } + ret = sample_uvc_init_sys_and_vb(&sample_vdec[0], vdec_chn_num, payload_type, OT_VDEC_MAX_CHN_NUM); + if (ret != TD_SUCCESS) { + return ret; + } + ret = sample_uvc_start_vdec(&sample_vdec[0], vdec_chn_num, OT_VDEC_MAX_CHN_NUM); + if (ret != TD_SUCCESS) { + goto stop_sys; + } + ret = sample_uvc_start_vpss(&vpss_grp, vpss_grp_num, &vpss_chn_enable[0], OT_VPSS_MAX_CHN_NUM); + if (ret != TD_SUCCESS) { + goto stop_vdec; + } + ret = sample_uvc_start_vo(&g_vo_config, vpss_grp_num); + if (ret != TD_SUCCESS) { + goto stop_vpss; + } + + return TD_SUCCESS; + +stop_vpss: + ret = sample_uvc_vdec_unbind_vpss(vpss_grp_num); + sample_uvc_stop_vpss(vpss_grp, &vpss_chn_enable[0], OT_VPSS_MAX_CHN_NUM); +stop_vdec: + sample_uvc_stop_vdec(vdec_chn_num); +stop_sys: + sample_comm_sys_exit(); + + return TD_FAILURE; +} + +td_s32 sample_uvc_media_exit(td_void) +{ + td_u32 vdec_chn_num = 1; + td_u32 vpss_grp_num = 1; + ot_vpss_grp vpss_grp = 0; + td_bool vpss_chn_enable[OT_VPSS_MAX_CHN_NUM] = {0}; + vpss_chn_enable[0] = TD_TRUE; + + (td_void)sample_uvc_vpss_unbind_vo(vpss_grp_num, g_vo_config); + sample_comm_vo_stop_vo(&g_vo_config); + (td_void)sample_uvc_vdec_unbind_vpss(vpss_grp_num); + sample_uvc_stop_vpss(vpss_grp, &vpss_chn_enable[0], OT_VPSS_MAX_CHN_NUM); + sample_uvc_stop_vdec(vdec_chn_num); + sample_comm_sys_exit(); + + return TD_SUCCESS; +} + +static td_void sample_uvc_cut_stream_for_mjpeg(td_void *data, td_u32 size, td_s32 chn_id, + td_s32 *read_num, td_u32 *start) +{ + td_s32 i; + td_u32 len; + td_s32 read_len = size; + td_u8 *buf = data; + td_bool find_start = TD_FALSE; + for (i = 0; i < read_len - 1; i++) { + if (buf[i] == 0xFF && buf[i + 1] == 0xD8) { /* 0xFFD8: JPEG起始标记 */ + *start = i; + find_start = TD_TRUE; + i = i + 2; /* 2: 跳过标记长度 */ + break; + } + } + + /* 3: 检查下一个标记头所需长度 */ + for (; i < read_len - 3; i++) { + if ((buf[i] == 0xFF) && (buf[i + 1] & 0xF0) == 0xE0) { + len = (buf[i + 2] << 8) + buf[i + 3]; /* 2 3 index 8: 长度字段占2字节 */ + i += 1 + len; + } else { + break; + } + } + + for (; i < read_len - 1; i++) { + if (buf[i] == 0xFF && buf[i + 1] == 0xD9) { /* 0xFFD9: JPEG结束标记 */ + break; + } + } + read_len = i + 2; /* 2: 包含结束标记 */ + + if (find_start == TD_FALSE) { + sample_print("chn %d can not find JPEG start code! read_len %d!\n", chn_id, read_len); + } + + *read_num = read_len; +} + +static td_void sample_uvc_cut_stream_for_h264(td_void *data, td_u32 size, td_s32 chn_id, td_s32 *read_num) +{ + td_bool find_start = TD_FALSE; + td_bool find_end = TD_FALSE; + td_s32 i; + td_u8 *buf = data; + td_s32 read_len = size; + for (i = 0; i < read_len - 8; i++) { /* 8: 起始码最小长度 */ + int tmp = buf[i + 3] & 0x1F; /* 0x1F: NALU类型掩码 */ + /* 0x5: IDR帧, 0x1: 非IDR帧 0x80: 关键帧标志 2 index */ + if (buf[i] == 0 && buf[i + 1] == 0 && buf[i + 2] == 1 && + (((tmp == 0x5 || tmp == 0x1) && ((buf[i + 4] & 0x80) == 0x80)) || /* 4 index */ + (tmp == 20 && (buf[i + 7] & 0x80) == 0x80))) { /* 20 帧起始类型 7 index */ + find_start = TD_TRUE; + i += 8; /* 8: 跳过起始码 */ + break; + } + } + + for (; i < read_len - 8; i++) { /* 8: 查找结束所需最小长度 */ + int tmp = buf[i + 3] & 0x1F; /* 0x1F: NALU类型掩码 */ + if (buf[i] == 0 && buf[i + 1] == 0 && buf[i + 2] == 1 && /* 2 index */ + (tmp == 15 || tmp == 7 || tmp == 8 || tmp == 6 || /* 15 SEI 7 SPS 8 PPS 6 SEI */ + ((tmp == 5 || tmp == 1) && ((buf[i + 4] & 0x80) == 0x80)) || /* 5 1 帧起始类型 4 index */ + (tmp == 20 && (buf[i + 7] & 0x80) == 0x80))) { /* 20 帧起始类型 7 index */ + find_end = TD_TRUE; + break; + } + } + + if (i > 0) { + read_len = i; + } + + if (find_start == TD_FALSE) { + sample_print("chn %d can not find H264 start code! read_len %d!\n", chn_id, read_len); + } + + if (find_end == TD_FALSE) { + read_len = i + 8; /* 8: 包含下一帧起始码 */ + } + + *read_num = read_len; +} + +static td_void sample_uvc_cut_stream_for_h265(td_void *data, td_u32 size, td_s32 chn_id, td_s32 *read_num) +{ + td_bool find_start = TD_FALSE; + td_bool find_end = TD_FALSE; + td_bool new_pic = TD_FALSE; + td_s32 i; + td_u8 *buf = data; + td_s32 read_len = size; + for (i = 0; i < read_len - 6; i++) { /* 6:h265 frame start code length */ + td_u32 tmp = (buf[i + 3] & 0x7E) >> 1; /* 0x7E:frame start marker 3:index */ + new_pic = (buf[i + 0] == 0 && buf[i + 1] == 0 && buf[i + 2] == 1 && /* 1 2:index */ + (tmp <= 21) && ((buf[i + 5] & 0x80) == 0x80)); /* 5:index 21 0x80:frame start marker */ + + if (new_pic) { + find_start = TD_TRUE; + i += 6; /* 6:h265 frame start code length */ + break; + } + } + + for (; i < read_len - 6; i++) { /* 6:h265 frame start code length */ + td_u32 tmp = (buf[i + 3] & 0x7E) >> 1; /* 0x7E:frame start marker 3:index */ + new_pic = (buf[i + 0] == 0 && buf[i + 1] == 0 && buf[i + 2] == 1 && /* 1 2:index */ + (tmp == 32 || tmp == 33 || tmp == 34 || tmp == 39 || tmp == 40 || /* 32 33 34 39 40:frame start marker */ + ((tmp <= 21) && (buf[i + 5] & 0x80) == 0x80))); /* 5:index 21 0x80:frame start marker */ + + if (new_pic) { + find_end = TD_TRUE; + break; + } + } + + if (i > 0) { + read_len = i; + } + + if (find_start == TD_FALSE) { + sample_print("chn %d can not find H265 start code! read_len %d!\n", chn_id, read_len); + } + + if (find_end == TD_FALSE) { + read_len = i + 6; /* 6:h265 frame start code length */ + } + + *read_num = read_len; +} + +static td_s32 sample_uvc_prepare_frame_info(ot_vb_blk vb_blk, const ot_pic_buf_attr *buf_attr, + const ot_vb_calc_cfg *calc_cfg, ot_video_frame_info *video_frame) +{ + video_frame->video_frame.header_phys_addr[0] = ss_mpi_vb_handle_to_phys_addr(vb_blk); + if (video_frame->video_frame.header_phys_addr[0] == TD_NULL) { + sample_print("ss_mpi_vb_handle_to_phys_addr fail\n"); + return TD_FAILURE; + } + + video_frame->video_frame.header_virt_addr[0] = + (td_u8*)ss_mpi_sys_mmap(video_frame->video_frame.header_phys_addr[0], calc_cfg->vb_size); + if (video_frame->video_frame.header_virt_addr[0] == TD_NULL) { + sample_print("ss_mpi_sys_mmap fail\n"); + return TD_FAILURE; + } + + video_frame->mod_id = OT_ID_VGS; + video_frame->pool_id = ss_mpi_vb_handle_to_pool_id(vb_blk); + + video_frame->video_frame.header_phys_addr[1] = + video_frame->video_frame.header_phys_addr[0] + calc_cfg->head_y_size; + video_frame->video_frame.header_virt_addr[1] = + video_frame->video_frame.header_virt_addr[0] + calc_cfg->head_y_size; + video_frame->video_frame.phys_addr[0] = + video_frame->video_frame.header_phys_addr[0] + calc_cfg->head_size; + video_frame->video_frame.phys_addr[1] = + video_frame->video_frame.phys_addr[0] + calc_cfg->main_y_size; + video_frame->video_frame.virt_addr[0] = + video_frame->video_frame.header_virt_addr[0] + calc_cfg->head_size; + video_frame->video_frame.virt_addr[1] = + video_frame->video_frame.virt_addr[0] + calc_cfg->main_y_size; + video_frame->video_frame.header_stride[0] = calc_cfg->head_stride; + video_frame->video_frame.header_stride[1] = calc_cfg->head_stride; + video_frame->video_frame.stride[0] = calc_cfg->main_stride; + video_frame->video_frame.stride[1] = calc_cfg->main_stride; + + video_frame->video_frame.width = buf_attr->width; + video_frame->video_frame.height = buf_attr->height; + video_frame->video_frame.dynamic_range = OT_DYNAMIC_RANGE_SDR8; + video_frame->video_frame.compress_mode = OT_COMPRESS_MODE_NONE; + video_frame->video_frame.video_format = OT_VIDEO_FORMAT_LINEAR; + video_frame->video_frame.field = OT_VIDEO_FIELD_FRAME; + video_frame->video_frame.pixel_format = OT_PIXEL_FORMAT_YUV_SEMIPLANAR_420; + + return TD_SUCCESS; +} + +static td_void sample_uvc_buf_attr_init(const ot_size *pic_size, ot_pic_buf_attr *buf_attr) +{ + buf_attr->width = pic_size->width; + buf_attr->height = pic_size->height; + buf_attr->pixel_format = OT_PIXEL_FORMAT_YUV_SEMIPLANAR_420; + buf_attr->compress_mode = OT_COMPRESS_MODE_NONE; + buf_attr->align = 0; + buf_attr->bit_width = OT_DATA_BIT_WIDTH_8; +} + +static td_void sample_uvc_yuyv_to_nv12(td_char *image_in, td_u32 width, td_u32 height, + td_u32 size, td_char *image_out) +{ + td_s32 pixel_num = width * height; + td_u32 cycle_num = size / pixel_num / 2; /* 2: YUYV格式中每个像素占2字节 */ + + td_char *y = image_out; + td_char *uv = image_out + pixel_num; + + td_char *start = image_in; + td_u32 i = 0; + td_u32 j = 0; + td_u32 k = 0; + + /* Y */ + for (i = 0; i < cycle_num; i++) { + int index = 0; + for (j = 0; j < pixel_num * 2; j = j + 2) { /* 2: 跳过UV分量,每次取Y */ + *(y + index) = *(start + j); + index++; + } + start = image_in + pixel_num * 2 * i; /* 2: 每帧YUYV数据跨度 */ + y = y + pixel_num * 3 / 2; /* 3/2: NV12中Y+UV的总大小比例 */ + } + + /* UV */ + start = image_in; + for (i = 0; i < cycle_num; i++) { + int uv_index = 0; + for (j = 0; j < height; j = j + 2) { /* 2: 隔行采样UV */ + /* 2: YUYV宽度步进 4: 每两个像素的YUYV数据块 1: 取U分量的位置偏移 2: 取下一个V分量的偏移 */ + for (k = j * width * 2 + 1; k < width * 2 * (j + 1); k = k + 4) { + *(uv + uv_index) = *(start + k); /* U分量 */ + *(uv + uv_index + 1) = *(start + k + 2); /* 2 取下一个V分量的偏移 */ + uv_index += 2; /* 2: UV平面存储步进 */ + } + } + start = image_in + pixel_num * 2 * i; /* 2: 每帧YUYV数据跨度 */ + uv = uv + pixel_num * 3 / 2; /* 3/2: NV12中Y+UV的总大小比例 */ + } +} + +static td_void sample_uvc_update_vb_cfg(ot_pixel_format pixel_format, td_u32 stride, const ot_size *pic_size, + ot_vb_calc_cfg *calc_cfg) +{ + if (pixel_format != OT_PIXEL_FORMAT_YUYV_PACKAGE_422) { + return; + } + + calc_cfg->main_stride = stride >> 1; + calc_cfg->main_y_size = calc_cfg->main_stride * pic_size->height; +} + +static td_s32 sample_uvc_send_frame_to_vpss(td_void *data, td_u32 size, td_u32 stride, + const ot_size *pic_size, ot_pixel_format pixel_format) +{ + td_s32 ret; + ot_vpss_grp grp = 0; + ot_video_frame_info frame_info = {0}; + td_s32 milli_sec = -1; + ot_vb_blk vb_blk; + ot_pic_buf_attr buf_attr; + ot_vb_calc_cfg calc_cfg; + sample_uvc_buf_attr_init(pic_size, &buf_attr); + ot_common_get_pic_buf_cfg(&buf_attr, &calc_cfg); + sample_uvc_update_vb_cfg(pixel_format, stride, pic_size, &calc_cfg); + vb_blk = ss_mpi_vb_get_blk(OT_VB_INVALID_POOL_ID, calc_cfg.vb_size, TD_NULL); + if (vb_blk == OT_VB_INVALID_HANDLE) { + sample_print("get vb blk(size:%d) failed!\n", calc_cfg.vb_size); + return TD_FAILURE; + } + ret = sample_uvc_prepare_frame_info(vb_blk, &buf_attr, &calc_cfg, &frame_info); + if (ret != TD_SUCCESS) { + return ret; + } + + if (pixel_format == OT_PIXEL_FORMAT_YUYV_PACKAGE_422) { + sample_uvc_yuyv_to_nv12(data, pic_size->width, pic_size->height, size, frame_info.video_frame.virt_addr[0]); + } else { + frame_info.video_frame.pixel_format = pixel_format; + (td_void)memcpy_s(frame_info.video_frame.virt_addr[0], size, data, size); + } + ret = ss_mpi_vpss_send_frame(grp, &frame_info, milli_sec); + if (ret != TD_SUCCESS) { + sample_print("send frame to vpss failed!\n"); + } + ss_mpi_sys_munmap(frame_info.video_frame.virt_addr[0], calc_cfg.vb_size); + ret = ss_mpi_vb_release_blk(vb_blk); + if (ret != TD_SUCCESS) { + sample_print("release vb failed!\n"); + return TD_FAILURE; + } + + return ret; +} + +static td_s32 sample_uvc_get_pixel_format(const td_char *type_name, ot_pixel_format *pixel_format) +{ + if (strcmp(type_name, "YUYV") == 0) { + *pixel_format = OT_PIXEL_FORMAT_YUYV_PACKAGE_422; + } else if (strcmp(type_name, "NV12") == 0) { + *pixel_format = OT_PIXEL_FORMAT_YUV_SEMIPLANAR_420; + } else if (strcmp(type_name, "NV21") == 0) { + *pixel_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_420; + } else { + sample_print("pixel format error!\n"); + return TD_FAILURE; + } + + return TD_SUCCESS; +} + +td_s32 sample_uvc_media_send_data(td_void *data, td_u32 size, td_u32 stride, + const ot_size *pic_size, const td_char *type_name) +{ + td_bool end_of_stream = TD_FALSE; + td_s32 read_len = size; + td_u8 *buf = data; + ot_vdec_stream vdec_stream; + td_u32 start = 0; + td_s32 ret; + td_s32 chn_id = 0; + ot_pixel_format pixel_format; + td_bool send_again = TD_TRUE; + + if (strcmp(type_name, "MJPEG") == 0) { + sample_uvc_cut_stream_for_mjpeg(data, size, chn_id, &read_len, &start); + } else if (strcmp(type_name, "H264") == 0) { + sample_uvc_cut_stream_for_h264(data, size, chn_id, &read_len); + } else if (strcmp(type_name, "H265") == 0) { + sample_uvc_cut_stream_for_h265(data, size, chn_id, &read_len); + } else { + ret = sample_uvc_get_pixel_format(type_name, &pixel_format); + if (ret != TD_SUCCESS) { + return ret; + } + return sample_uvc_send_frame_to_vpss(data, size, stride, pic_size, pixel_format); + } + + vdec_stream.addr = buf + start; + vdec_stream.len = read_len; + vdec_stream.end_of_frame = TD_TRUE; + vdec_stream.end_of_stream = end_of_stream; + vdec_stream.need_display = 1; + + while (send_again == TD_TRUE) { + ss_mpi_sys_get_cur_pts(&vdec_stream.pts); + ret = ss_mpi_vdec_send_stream(chn_id, &vdec_stream, 0); + if (ret != TD_SUCCESS) { + usleep(1000); /* 1000 sleep 1000us */ + sample_print("send stream to vdec failed!\n"); + continue; + } else { + end_of_stream = TD_FALSE; + } + send_again = TD_FALSE; + } + usleep(1000); /* 1000 sleep 1000us */ + + return TD_SUCCESS; +} + +td_s32 sample_uvc_media_stop_receive_data(td_void) +{ + ot_vdec_stream vdec_stream = {0}; + td_u32 vdec_chn_num = 1; + td_s32 chn_id = 0; + + if (g_is_need_vdec == TD_FALSE) { + return TD_SUCCESS; + } + + vdec_stream.end_of_stream = TD_TRUE; + ss_mpi_vdec_send_stream(chn_id, &vdec_stream, -1); + ss_mpi_vdec_stop_recv_stream(vdec_chn_num); + + return TD_SUCCESS; +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif /* End of #ifdef __cplusplus */ diff --git a/vendor/zsks/demo/opencv_dnn/media_vdec.h b/vendor/zsks/demo/opencv_dnn/media_vdec.h new file mode 100755 index 0000000000000000000000000000000000000000..dcd6942734b98e09e5befc75a6cac348d7fa38c8 --- /dev/null +++ b/vendor/zsks/demo/opencv_dnn/media_vdec.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MEDIA_VDEC_H__ +#define __MEDIA_VDEC_H__ + +#include "sample_comm.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +td_s32 sample_uvc_media_init(const td_char *type_name, td_u32 width, td_u32 height); +td_s32 sample_uvc_media_exit(td_void); +td_s32 sample_uvc_media_send_data(td_void *data, td_u32 data_size, td_u32 stride, + const ot_size *pic_size, const td_char *type_name); +td_s32 sample_uvc_media_stop_receive_data(td_void); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif /* End of #ifdef __cplusplus */ + + +#endif /* end of #ifndef __MEDIA_VDEC_H__ */ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20221114150205685.png b/vendor/zsks/demo/opencv_dnn/pic/image-20221114150205685.png new file mode 100755 index 0000000000000000000000000000000000000000..4dc4215c962c57ba0e31548fb98c29c789f149d9 Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20221114150205685.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20250210161601541.png b/vendor/zsks/demo/opencv_dnn/pic/image-20250210161601541.png new file mode 100755 index 0000000000000000000000000000000000000000..80845ece8131933a4cd56ae3bd6119c38e0abd26 Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20250210161601541.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20250210170027454.png b/vendor/zsks/demo/opencv_dnn/pic/image-20250210170027454.png new file mode 100755 index 0000000000000000000000000000000000000000..c06081fc2c963af4d1fa8af506804beedefe1b0b Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20250210170027454.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20250213112932380.png b/vendor/zsks/demo/opencv_dnn/pic/image-20250213112932380.png new file mode 100755 index 0000000000000000000000000000000000000000..8b591b3437544859f4ec76b9ca03867cc401078c Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20250213112932380.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20250919150630870.png b/vendor/zsks/demo/opencv_dnn/pic/image-20250919150630870.png new file mode 100755 index 0000000000000000000000000000000000000000..91f881e85b3292118336ce2c3d81968e4aee8c26 Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20250919150630870.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20250919151018659.png b/vendor/zsks/demo/opencv_dnn/pic/image-20250919151018659.png new file mode 100755 index 0000000000000000000000000000000000000000..9b09507893b65d2142be49e6461daa31a81855c4 Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20250919151018659.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20250919151519310.png b/vendor/zsks/demo/opencv_dnn/pic/image-20250919151519310.png new file mode 100755 index 0000000000000000000000000000000000000000..7f6d881a5d0e6d3f72b7a43d089b5c5a75d7f048 Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20250919151519310.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20250919181207847.png b/vendor/zsks/demo/opencv_dnn/pic/image-20250919181207847.png new file mode 100755 index 0000000000000000000000000000000000000000..e7b214656ea49472a2ed39c51e8356741282c478 Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20250919181207847.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20250919183224310.png b/vendor/zsks/demo/opencv_dnn/pic/image-20250919183224310.png new file mode 100755 index 0000000000000000000000000000000000000000..b539dd4175d5937062827ba614b2993165d510e4 Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20250919183224310.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20251015164912907.png b/vendor/zsks/demo/opencv_dnn/pic/image-20251015164912907.png new file mode 100755 index 0000000000000000000000000000000000000000..aa6e135f4c791b23615ebf00f1b70a85e7375162 Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20251015164912907.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20251015165024778.png b/vendor/zsks/demo/opencv_dnn/pic/image-20251015165024778.png new file mode 100755 index 0000000000000000000000000000000000000000..0648761c44f09bf97c9f57f2bc50e6002f8acd17 Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20251015165024778.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20251023111135567.png b/vendor/zsks/demo/opencv_dnn/pic/image-20251023111135567.png new file mode 100755 index 0000000000000000000000000000000000000000..62dfa69dc6c65a8bdbb15179c67c80488603cb4b Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20251023111135567.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20251023111425708.png b/vendor/zsks/demo/opencv_dnn/pic/image-20251023111425708.png new file mode 100755 index 0000000000000000000000000000000000000000..e332a7048949ea2d4ec6c2008065868f1e9f02f7 Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20251023111425708.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20251023112130092.png b/vendor/zsks/demo/opencv_dnn/pic/image-20251023112130092.png new file mode 100755 index 0000000000000000000000000000000000000000..e9116e45957d13d4768c7042ee3d4b538664e7d0 Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20251023112130092.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20251023112228717.png b/vendor/zsks/demo/opencv_dnn/pic/image-20251023112228717.png new file mode 100755 index 0000000000000000000000000000000000000000..574bbf96ec5810820bc59643b895b0dded7a6208 Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20251023112228717.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20251023112328619.png b/vendor/zsks/demo/opencv_dnn/pic/image-20251023112328619.png new file mode 100755 index 0000000000000000000000000000000000000000..32547b0c69a9fb73e9143b6db15d34b81f45b2ca Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20251023112328619.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20251023112352692.png b/vendor/zsks/demo/opencv_dnn/pic/image-20251023112352692.png new file mode 100755 index 0000000000000000000000000000000000000000..536a306e1a28d57fcc24ef1b92b3304c832760de Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20251023112352692.png differ diff --git a/vendor/zsks/demo/opencv_dnn/pic/image-20251023112451423.png b/vendor/zsks/demo/opencv_dnn/pic/image-20251023112451423.png new file mode 100755 index 0000000000000000000000000000000000000000..28b7023a83d7eff1212f38bbd2fb6e606f6be596 Binary files /dev/null and b/vendor/zsks/demo/opencv_dnn/pic/image-20251023112451423.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/Makefile b/vendor/zsks/demo/sample_kcf_track/Makefile new file mode 100755 index 0000000000000000000000000000000000000000..861b75ad92f311325c03965f29e557d327481b0a --- /dev/null +++ b/vendor/zsks/demo/sample_kcf_track/Makefile @@ -0,0 +1,49 @@ +# 编译所需的公共文件 +include ../mk.param + +# 编译后生成的可执行文件名 +TARGET := main + +# 编译此工程需要包含的头文件 +CFLAGS += -I$(SDK_LINUX_INCLUDE_DIR)/ +CFLAGS += -I$(SDK_SAMPLE_COMMON_DIR)/ +CFLAGS += -I$(SDK_LINUX_INCLUDE_DIR)/svp_npu +CFLAGS += -I$(KCF_TRACK_SAMPLE_DIR)/ + +# 编译此工程需要依赖的.c或.cpp文件 +SMP_SRCS := $(SDK_SAMPLE_COMMON_DIR)/sample_comm_sys.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_ipc.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_isp.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vi.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vo.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_mipi_tx.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vpss.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/loadbmp.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_vdec.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sample_comm_venc.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sdk_init.c +SMP_SRCS += $(SDK_SAMPLE_COMMON_DIR)/sdk_exit.c +SMP_SRCS += $(wildcard $(SVP_COMMON_DIR)/*.c) +SMP_SRCS += $(KCF_TRACK_SAMPLE_DIR)/main.c +SMP_SRCS += $(KCF_TRACK_SAMPLE_DIR)/sample_kcf_track.c +SMP_SRCS += $(KCF_TRACK_SAMPLE_DIR)/sample_svp_npu_process.c + +# 编译此工程需要包含的库和宏 +MPI_LIBS += $(SDK_LINUX_OUT_LIB)/libsns_os04a10.a +CFLAGS += -O3 -g -Wall -DUSE_USB_CAMERA +CFLAGS += -fstack-protector-strong + +# 根据实际的类型设置,可以用set_sensor脚本设置 +SENSOR0_TYPE = -DSENSOR0_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT +SENSOR1_TYPE = -DSENSOR1_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT +SENSOR2_TYPE = -DSENSOR1_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT +SENSOR3_TYPE = -DSENSOR1_TYPE=OV_OS04A10_MIPI_4M_30FPS_12BIT + +CFLAGS += $(SENSOR0_TYPE) +CFLAGS += $(SENSOR1_TYPE) +CFLAGS += $(SENSOR2_TYPE) +CFLAGS += $(SENSOR3_TYPE) +# 编译工程所需的mk文件 + +include ../sdk_linux.mk + diff --git a/vendor/zsks/demo/sample_kcf_track/README.md b/vendor/zsks/demo/sample_kcf_track/README.md new file mode 100755 index 0000000000000000000000000000000000000000..928e07974e520df86e729bdd56bbf35f84df588f --- /dev/null +++ b/vendor/zsks/demo/sample_kcf_track/README.md @@ -0,0 +1,142 @@ +## 2.4、sample_kcf_track操作指导 + +### 2.4.1、sample_kcf_track程序简介 + +* sample_kcf_track 基于SS928V100平台开发,以EulerPi套件为例,sample_kcf_track 基于KCF+Track模型,通过USB Camera,将采集到的图片送到KFC+trak模型,实现对目标的实时跟踪效果。 + +### 2.4.2、目录 + +```shell +pegasus/vendor/zsks/demo/sample_kcf_track +|── main.c # sample_kcf_track的主入口 +|── Makefile # 编译脚本 +|── sample_kcf_track.c # sample_kcf_track业务代码 +|── sample_kcf_track.h # sample_kcf_track业务代码头文件 +|── sample_svp_npu_process.c # 调用SVP_NPU的业务代码 +└── sample_svp_npu_process.c # 调用SVP_NPU的头文件 +``` + +![image-20250919184816530](pic/image-20250919184816530.png) + +* 根据外接显示屏的输出参数进行配置,比如说我的外接显示屏的输出是1080P60,如果smp/a55_linux/mpp/sample/svp/common/sample_common_svp.c ample_common_svp_get_def_vo_cfg函数的intf_sync为OT_VO_OUT_1080P30,则需要把他修改为OT_VO_OUT_1080P60。 + +![image-20251023102053075](pic/image-20251023102053075.png) + +### 2.4.3、编译 + +* **注意:在编译zsks的demo之前,请确保你已经按照[patch介绍中的步骤](../../README.md#4patch介绍)把补丁打入海思SDK的sample目录下了**。 + +* 步骤1:先根据自己选择的操作系统,进入到对应的Pegasus所在目录下。 + +* 步骤2:使用Makefile的方式进行单编 + +* 在Ubuntu的命令行终端,分步执行下面的命令,单编 sample_kcf_track + + ``` + cd pegasus/vendor/zsks/demo/sample_kcf_track + + make clean && make + ``` + + * 在sample_kcf_track/out目录下,生成一个名为main的可执行文件,如下图所示: + + ![image-20251023114014999](pic/image-20251023114014999.png) + +### 2.4.4、拷贝可执行程序和依赖文件至开发板的mnt目录下 + +**方式一:使用SD卡进行资料文件的拷贝** + +* 首先需要自己准备一张Micro sd卡(16G 左右即可),还得有一个Micro sd卡的读卡器。 + +image-20221114150205685 + +* 步骤1:将编译后生成的可执行文件main,拷贝到SD卡中。 + +![image-20251023100505047](pic/image-20251023100505047.png) + +* 步骤2:可执行文件拷贝成功后,将内存卡插入开发板的SD卡槽中,可通过挂载的方式挂载到板端,可选择SD卡 mount指令进行挂载。 + +image-20250210161601541 + +* 在开发板的终端,执行下面的命令进行SD卡的挂载 + * 如果挂载失败,可以参考[这个issue尝试解决](https://gitee.com/HiSpark/HiSpark_NICU2022/issues/I54932?from=project-issue) + + +```shell +mount -t vfat /dev/mmcblk1p1 /mnt +# 其中/dev/mmcblk1p1需要根据实际块设备号修改 +``` + +* 挂载成功后,如下图所示: + +![image-20251023114317633](pic/image-20251023114317633.png) + +**方式二:使用NFS挂载的方式进行资料文件的拷贝** + +* 首先需要自己准备一根网线 +* 步骤1:参考[博客链接](https://blog.csdn.net/Wu_GuiMing/article/details/115872995?spm=1001.2014.3001.5501)中的内容,进行nfs的环境搭建 +* 步骤2:将编译后生成的可执行文件main,拷贝到Windows的nfs共享路径下 + +![image-20251023100536744](pic/image-20251023100536744.png) + +* 步骤3:在开发板的终端执行下面的命令,将Windows的nfs共享路径挂载至开发板的mnt目录下 + * 注意:这里IP地址请根据你开发板和电脑主机的实际IP地址进行填写 + + +``` +ifconfig eth0 192.168.100.100 + +mount -o nolock,addr=192.168.100.10 -t nfs 192.168.100.10:/d/nfs /mnt +``` + +![image-20251023114345977](pic/image-20251023114345977.png) + +### 2.4.5、硬件连接 + +* 准备一个外接显示器和HDMI数据线,将HDMI的一头接在开发板的HDMI输出口,将HDMI的另外一头接在外接显示器的HDMI输入口。 + +![image-20250213112932380](pic/image-20250213112932380.png) + +* 将USB 摄像头接在EulerPi开发板的USB接口上。 + +image-20250919150630870 + +### 2.4.6、功能验证 + +* 在开发板的终端执行下面的命令,运行可执行文件 + +``` +cd /mnt + +chmod +x main + +./main +``` + +![image-20251023114430657](pic/image-20251023114430657.png) + +* 此时,在HDMI的外接显示屏上即可出现实时码流,如下图所示: + +image-20250210170027454 + +* 如果您看到的现象和下图现象不一致,可以确认一下USB涉嫌头是否插入到开发板的USB口,并且在开发板的/dev目录下能够看到video0 和 video1两个设备节点。如果没有这两个设备节点,请确保镜像烧录正常。 + +![image-20250919151018659](pic/image-20250919151018659.png) + +* 正常情况下,我们会在外接显示屏上看到USB Camera采集到的画面。 +* 步骤1:按下键盘的空格键,会在屏幕的正中间显示一个红色的框框。 + +![image-20250919192349341](pic/image-20250919192349341.png) + +* 步骤2:把需要跟踪的目标放在红色框框内,然后再按一下空格键,此时红色框会变绿,如果没有变,可以重复一次。 +* 步骤3:移动需要跟踪的目标,绿色框会跟着目标一起移动。 + +![image-20250919192115350](pic/image-20250919192137187.png) + +* 当目标不在sensor视野范围内,绿框会变成黄色。 + +![image-20250919192243361](pic/image-20250919192243361.png) + +* 输入Q键,即可关闭程序 + +![image-20250919151519310](pic/image-20250919151519310.png) \ No newline at end of file diff --git a/vendor/zsks/demo/sample_kcf_track/main.c b/vendor/zsks/demo/sample_kcf_track/main.c new file mode 100755 index 0000000000000000000000000000000000000000..e25ac821e9157105a1a40b36e6b158cbc3614f8c --- /dev/null +++ b/vendor/zsks/demo/sample_kcf_track/main.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * Copyright (c) 2025 Zhongshan Kuangshi Microelectronics Technology Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Modifications Author: yaohongtao (yht@cust.edu.cn) + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sdk_module_init.h" +#include "securec.h" +#include "sample_svp_npu_process.h" + +int main(int argc, char *argv[]) +{ + td_s32 ret; + +#ifdef CONFIG_USER_SPACE + SDK_init(); +#endif + + sample_svp_npu_acl_v4l2_kcf(); + +#ifdef CONFIG_USER_SPACE + SDK_exit(); +#endif + return 0; +} diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20221114150205685.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20221114150205685.png new file mode 100755 index 0000000000000000000000000000000000000000..4dc4215c962c57ba0e31548fb98c29c789f149d9 Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20221114150205685.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20250210161601541.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20250210161601541.png new file mode 100755 index 0000000000000000000000000000000000000000..80845ece8131933a4cd56ae3bd6119c38e0abd26 Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20250210161601541.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20250210170027454.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20250210170027454.png new file mode 100755 index 0000000000000000000000000000000000000000..c06081fc2c963af4d1fa8af506804beedefe1b0b Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20250210170027454.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20250213112932380.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20250213112932380.png new file mode 100755 index 0000000000000000000000000000000000000000..8b591b3437544859f4ec76b9ca03867cc401078c Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20250213112932380.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20250919150630870.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20250919150630870.png new file mode 100755 index 0000000000000000000000000000000000000000..91f881e85b3292118336ce2c3d81968e4aee8c26 Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20250919150630870.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20250919151018659.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20250919151018659.png new file mode 100755 index 0000000000000000000000000000000000000000..9b09507893b65d2142be49e6461daa31a81855c4 Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20250919151018659.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20250919151519310.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20250919151519310.png new file mode 100755 index 0000000000000000000000000000000000000000..7f6d881a5d0e6d3f72b7a43d089b5c5a75d7f048 Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20250919151519310.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20250919184816530.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20250919184816530.png new file mode 100755 index 0000000000000000000000000000000000000000..9f81d194b1ca8d431ad615849d2c569296579979 Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20250919184816530.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20250919192137187.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20250919192137187.png new file mode 100755 index 0000000000000000000000000000000000000000..40ae9c3bd0c0aa31a35641ceb139f98b193505cf Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20250919192137187.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20250919192243361.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20250919192243361.png new file mode 100755 index 0000000000000000000000000000000000000000..a2231c40a1430a678ed005050c743925f2ff02e1 Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20250919192243361.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20250919192349341.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20250919192349341.png new file mode 100755 index 0000000000000000000000000000000000000000..e5ba33632d982e6806c584cc20fe487bb61389d6 Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20250919192349341.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20251023100505047.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20251023100505047.png new file mode 100755 index 0000000000000000000000000000000000000000..25285f788edc601a27e2dadbc2cc4800d62c1a8a Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20251023100505047.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20251023100536744.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20251023100536744.png new file mode 100755 index 0000000000000000000000000000000000000000..f399cbaa84a0f413594d2a082db25ab84a257084 Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20251023100536744.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20251023102053075.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20251023102053075.png new file mode 100755 index 0000000000000000000000000000000000000000..6fc62dd35e3dcfeb36a6e3ba1e7cea3e008660ed Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20251023102053075.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20251023114014999.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20251023114014999.png new file mode 100755 index 0000000000000000000000000000000000000000..eca5b8f8a17acda9378c05491b7357d6ae0fd7ce Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20251023114014999.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20251023114317633.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20251023114317633.png new file mode 100755 index 0000000000000000000000000000000000000000..36789df9bbb5ebe76950defe29ed4e1ac4df6f2b Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20251023114317633.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20251023114345977.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20251023114345977.png new file mode 100755 index 0000000000000000000000000000000000000000..4d258790884b235f6f7dce98c0d697f4d17bce88 Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20251023114345977.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/pic/image-20251023114430657.png b/vendor/zsks/demo/sample_kcf_track/pic/image-20251023114430657.png new file mode 100755 index 0000000000000000000000000000000000000000..921d330fc278312fb2c23e73fc2b3be5dd48bc29 Binary files /dev/null and b/vendor/zsks/demo/sample_kcf_track/pic/image-20251023114430657.png differ diff --git a/vendor/zsks/demo/sample_kcf_track/sample_kcf_track.c b/vendor/zsks/demo/sample_kcf_track/sample_kcf_track.c new file mode 100755 index 0000000000000000000000000000000000000000..066ecf22c1ead737fd4ecd2e259e3a73cf900bd0 --- /dev/null +++ b/vendor/zsks/demo/sample_kcf_track/sample_kcf_track.c @@ -0,0 +1,570 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * Copyright (c) 2025 Zhongshan Kuangshi Microelectronics Technology Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Modifications Author: yaohongtao (yht@cust.edu.cn) + */ +#include +#include +#include +#include +#include +#include "ss_mpi_ive.h" +#include "sample_common_svp.h" +#include "sample_common_ive.h" +#include "sample_kcf_track.h" + +#define KCF_QUEUE_LEN 4 /* 简化环形队列深度 */ + +/* **** 新增:KCF 用到的全局结构 **** */ +static sample_yolo_kcf_info g_kcf_info = {0}; /* 资源句柄、互斥锁等 */ +static ot_sample_svp_rect_info g_new_rect; /* NPU 推过来的检测框 */ +static pthread_mutex_t g_rect_mutex = PTHREAD_MUTEX_INITIALIZER; +static td_bool g_has_new_rect = TD_FALSE; /* 标记框是否更新 */ +static td_bool g_stop_flag = TD_FALSE; +static pthread_t g_get_frame_thd = 0; +static pthread_t g_track_thd = 0; +static int g_kcf_mode = 0; // 0=只画红框, 1=跟踪 + +// 新增:全局保存最后有效框和丢失计数(替代线程内的局部静态变量) +static ot_sample_svp_rect_info g_last_valid_rect = {0}; +static td_s32 g_lost_count = 0; + +#define KCF_BOX_WIDTH 200 // 统一宽度 +#define KCF_BOX_HEIGHT 200 // 统一高度 + +static void kcf_rect_to_roi_info(const ot_sample_svp_rect_info *rect, td_u32 base_w, td_u32 base_h) +{ + if (rect->num == 0) { + return; + } + // 只用第0个框,不做任何选择 + g_kcf_info.roi_num = 1; + g_kcf_info.roi_info[0].roi_id = 0; + g_kcf_info.roi_info[0].roi.x = rect->rect[0].point[0].x * OT_SAMPLE_QUARTER_OF_1M; + g_kcf_info.roi_info[0].roi.y = rect->rect[0].point[0].y * OT_SAMPLE_QUARTER_OF_1M; + g_kcf_info.roi_info[0].roi.width = rect->rect[0].point[1].x - rect->rect[0].point[0].x; + g_kcf_info.roi_info[0].roi.height = rect->rect[0].point[2].y - rect->rect[0].point[1].y; /* 2 index */ + // 后续宽高限制代码可保留 + if (g_kcf_info.roi_info[0].roi.width > 684) { /* 684 pic width */ + g_kcf_info.roi_info[0].roi.width = 684; /* 684 pic width */ + } + if (g_kcf_info.roi_info[0].roi.height > 684) { /* 684 pic height */ + g_kcf_info.roi_info[0].roi.height = 684; /* 684 pic height */ + } + if (g_kcf_info.roi_info[0].roi.width < KCF_BOX_WIDTH) { + g_kcf_info.roi_info[0].roi.width = KCF_BOX_WIDTH; + } + if (g_kcf_info.roi_info[0].roi.height < KCF_BOX_HEIGHT) { + g_kcf_info.roi_info[0].roi.height = KCF_BOX_HEIGHT; + } + if ((g_kcf_info.roi_info[0].roi.x / OT_SAMPLE_QUARTER_OF_1M) + g_kcf_info.roi_info[0].roi.width > base_w) { + g_kcf_info.roi_info[0].roi.x = (base_w - g_kcf_info.roi_info[0].roi.width) * OT_SAMPLE_QUARTER_OF_1M; + } + if ((g_kcf_info.roi_info[0].roi.y / OT_SAMPLE_QUARTER_OF_1M) + g_kcf_info.roi_info[0].roi.height > base_h) { + g_kcf_info.roi_info[0].roi.y = (base_h - g_kcf_info.roi_info[0].roi.height) * OT_SAMPLE_QUARTER_OF_1M; + } + if (g_kcf_info.roi_info[0].roi.x < 0) { + g_kcf_info.roi_info[0].roi.x = 0; + } + if (g_kcf_info.roi_info[0].roi.y < 0) { + g_kcf_info.roi_info[0].roi.y = 0; + } + if (g_kcf_info.roi_info[0].roi.width & 1) { + g_kcf_info.roi_info[0].roi.width--; + } + if (g_kcf_info.roi_info[0].roi.height & 1) { + g_kcf_info.roi_info[0].roi.height--; + } +} + +/* **** 简单把 video_frame 填到 ot_svp_img **** */ +static void kcf_fill_image(const ot_video_frame_info *frame, ot_svp_img *img) +{ + img->phys_addr[0] = frame->video_frame.phys_addr[0]; + img->phys_addr[1] = frame->video_frame.phys_addr[1]; + img->stride[0] = frame->video_frame.stride[0]; + img->stride[1] = frame->video_frame.stride[1]; + img->width = frame->video_frame.width; + img->height = frame->video_frame.height; + + /* 根据 VPSS 输出像素格式决定 IVE 输入类型 */ + switch (frame->video_frame.pixel_format) { + case OT_PIXEL_FORMAT_YVU_SEMIPLANAR_420: + case OT_PIXEL_FORMAT_YUV_SEMIPLANAR_420: + img->type = OT_SVP_IMG_TYPE_YUV420SP; + break; + case OT_PIXEL_FORMAT_YVU_SEMIPLANAR_422: + case OT_PIXEL_FORMAT_YUV_SEMIPLANAR_422: + img->type = OT_SVP_IMG_TYPE_YUV422SP; + break; + default: + /* 回退为 420,必要时可扩展 */ + img->type = OT_SVP_IMG_TYPE_YUV420SP; + break; + } +} + +typedef struct { + td_s32 x; + td_s32 y; + td_s32 w; + td_s32 h; +} BoxPosition; + +// 限制框在画面范围内 +static void clamp_box_to_frame(BoxPosition* box, const ot_video_frame_info* frame) +{ + const td_s32 max_w = frame->video_frame.width - 2; /* 2 pixel */ + const td_s32 max_h = frame->video_frame.height - 2; /* 2 pixel */ + + // 确保最小尺寸 + box->w = (box->w > KCF_BOX_WIDTH) ? box->w : KCF_BOX_WIDTH; + box->h = (box->h > KCF_BOX_HEIGHT) ? box->h : KCF_BOX_HEIGHT; + + /* 4 允许超出的最大范围(框宽的1/4) */ + const td_s32 max_overlap = box->w / 4; + if (box->x + box->w > max_w + max_overlap) { + box->x = max_w - box->w; + } + if (box->y + box->h > max_h + max_overlap) { + box->y = max_h - box->h; + } +} + +// 消除位置抖动 +static void smooth_box_position(BoxPosition* current, BoxPosition* last, td_bool* is_first_frame) +{ + if (*is_first_frame) { + *last = *current; + *is_first_frame = TD_FALSE; + return; + } + + // 微小变化时保持上一帧位置 + if (abs(current->x - last->x) <= 2 && abs(current->y - last->y) <= 2 && /* 2 pixel */ + abs(current->w - last->w) <= 2 && abs(current->h - last->h) <= 2) { /* 2 pixel */ + *current = *last; + } else { + *last = *current; + } +} + +// 确保坐标和尺寸为偶数 +static void align_to_even(BoxPosition* box) +{ + box->x &= ~1; // 清除最低位保证为偶数 + box->y &= ~1; + box->w &= ~1; + box->h &= ~1; +} + +// 设置矩形顶点坐标 +static void set_rect_points(ot_sample_svp_rect* rect, const BoxPosition* box) +{ + rect->point[0].x = box->x; + rect->point[0].y = box->y; + rect->point[1].x = box->x + box->w; + rect->point[1].y = box->y; + rect->point[2].x = box->x + box->w; /* 2 index of 2 */ + rect->point[2].y = box->y + box->h; /* 2 index of 2 */ + rect->point[3].x = box->x; /* 3 index of 3 */ + rect->point[3].y = box->y + box->h; /* 3 index of 3 */ +} + +static void kcf_bbox_to_rect(const ot_ive_kcf_bbox bbox[], td_u32 num, + const ot_video_frame_info* frame, ot_sample_svp_rect_info* rect) +{ + rect->num = (num > 0) ? 1 : 0; + if (rect->num == 0) { + return; + } + // 初始化转换参数 + static BoxPosition last_box = {0}; + static td_bool first_frame = TD_TRUE; + + BoxPosition current = { + .x = bbox[0].roi_info.roi.x / OT_SAMPLE_QUARTER_OF_1M, + .y = bbox[0].roi_info.roi.y / OT_SAMPLE_QUARTER_OF_1M, + .w = bbox[0].roi_info.roi.width, + .h = bbox[0].roi_info.roi.height + }; + + // 处理流程 + clamp_box_to_frame(¤t, frame); + smooth_box_position(¤t, &last_box, &first_frame); + align_to_even(¤t); + + // 设置输出矩形 + set_rect_points(&rect->rect[0], ¤t); +} +/* 边界检测辅助函数 */ +static td_bool is_touching_border(const ot_sample_svp_rect *rect, td_s32 screen_w, + td_s32 screen_h, td_s32 threshold) +{ + td_s32 rect_left = rect->point[0].x; + td_s32 rect_top = rect->point[0].y; + td_s32 rect_right = rect->point[1].x; + td_s32 rect_bottom = rect->point[2].y; + + return (rect_left <= threshold) || (rect_top <= threshold) || + ((screen_w - rect_right) <= threshold) || ((screen_h - rect_bottom) <= threshold); +} + +/* 绘制矩形辅助函数 */ +static void draw_tracking_rect(const ot_video_frame_info *frm, + const ot_sample_svp_rect_info *rect_info, td_bool is_touching_border) +{ + td_u32 color = is_touching_border ? 0x00FFFF00 : 0x0000FF00; + sample_common_svp_vgs_fill_rect(frm, rect_info, color); +} + +/* KCF训练辅助函数 */ +static void train_kcf_on_new_rect(const ot_video_frame_info *frm) +{ + pthread_mutex_lock(&g_rect_mutex); + kcf_rect_to_roi_info(&g_new_rect, frm->video_frame.width, frm->video_frame.height); + g_has_new_rect = TD_FALSE; + pthread_mutex_unlock(&g_rect_mutex); + + td_s32 ret = ss_mpi_ive_kcf_get_train_obj( + g_kcf_info.padding, g_kcf_info.roi_info, + g_kcf_info.roi_num, &g_kcf_info.cos_win_x, + &g_kcf_info.cos_win_y, &g_kcf_info.gauss_peak, + &g_kcf_info.obj_list); + if (ret != TD_SUCCESS) { + printf("[KCF] get_train_obj failed 0x%x, w=%u h=%u\n", ret, + g_kcf_info.roi_info[0].roi.width, + g_kcf_info.roi_info[0].roi.height); + } else { + printf("[KCF] train_obj_num=%u\n", g_kcf_info.obj_list.train_obj_num); + } +} + +/* 处理丢失目标情况 */ +static void handle_lost_target(const ot_video_frame_info *frm) +{ + g_lost_count++; + printf("[KCF] Lost target (count=%d), keep last rect\n", g_lost_count); + + if (g_last_valid_rect.num > 0) { + sample_common_svp_vgs_fill_rect(frm, &g_last_valid_rect, 0x00FFFF00); + } + + if (g_lost_count >= 10 && g_last_valid_rect.num > 0) { /* 10 lost count */ + pthread_mutex_lock(&g_rect_mutex); + g_new_rect = g_last_valid_rect; + g_has_new_rect = TD_TRUE; + pthread_mutex_unlock(&g_rect_mutex); + g_lost_count = 0; + } +} + +static void process_kcf_tracking(const ot_video_frame_info* frm, + ot_sample_svp_rect_info* draw_rect) +{ + td_s32 ret; + ot_ive_handle handle = 0; + ot_svp_img src_img; + + // 填充图像数据 + kcf_fill_image(frm, &src_img); + + // 执行KCF处理 + ret = ss_mpi_ive_kcf_proc(&handle, &src_img, &g_kcf_info.obj_list, + &g_kcf_info.kcf_proc_ctrl, TD_TRUE); + if (ret != TD_SUCCESS) { + printf("[KCF] kcf_proc failed 0x%x\n", ret); + g_kcf_info.bbox_obj_num = 0; + return; + } + + // 获取目标边界框 + ret = ss_mpi_ive_kcf_get_obj_bbox(&g_kcf_info.obj_list, g_kcf_info.bbox, + &g_kcf_info.bbox_obj_num, &g_kcf_info.kcf_bbox_ctrl); + if (ret != TD_SUCCESS) { + printf("[KCF] get_obj_bbox failed 0x%x\n", ret); + g_kcf_info.bbox_obj_num = 0; + return; + } + + // 处理有效目标 + if (g_kcf_info.bbox_obj_num > 0) { + kcf_bbox_to_rect(g_kcf_info.bbox, g_kcf_info.bbox_obj_num, frm, draw_rect); + + td_s32 screen_w = frm->video_frame.width - 2; + td_s32 screen_h = frm->video_frame.height - 2; + td_bool touching_border = is_touching_border( + &draw_rect->rect[0], screen_w, screen_h, 5); + + draw_tracking_rect(frm, draw_rect, touching_border); + g_last_valid_rect = *draw_rect; + g_lost_count = 0; + } +} + +/* 主线程函数(重构后) */ +static void *kcf_track_thread(void *args) +{ + (void)args; + td_s32 ret; + const ot_vo_layer vo_layer = 0; + const ot_vo_chn vo_chn = 0; + const td_s32 milli_sec = 20; + const td_s32 vpss_grp = 0; + const td_s32 vpss_chn = 0; + ot_sample_svp_rect_info draw_rect = {0}; + + while (!g_stop_flag) { + ot_video_frame_info frm; + ret = ss_mpi_vpss_get_chn_frame(vpss_grp, vpss_chn, &frm, milli_sec); + if (ret != TD_SUCCESS) { + usleep(1000); // 1000 sleep 1ms + continue; + } + + // 红框模式处理 + if (g_kcf_mode == 0) { + ot_ive_kcf_bbox initial_bbox[1]; + initial_bbox[0].roi_info = g_kcf_info.roi_info[0]; + kcf_bbox_to_rect(initial_bbox, 1, &frm, &draw_rect); + sample_common_svp_vgs_fill_rect(&frm, &draw_rect, 0x00FF0000); + g_kcf_info.bbox_obj_num = 0; + goto send_and_release; + } + + // 训练模式处理 + if (g_has_new_rect) { + train_kcf_on_new_rect(&frm); + } + + // 跟踪模式处理 + if (g_kcf_mode == 1 && (g_kcf_info.obj_list.train_obj_num != 0 || + g_kcf_info.obj_list.track_obj_num != 0)) { + process_kcf_tracking(&frm, &draw_rect); + } else if (g_kcf_mode == 1) { + g_kcf_info.bbox_obj_num = 0; + } + // 处理丢失目标 + if (g_kcf_mode == 1 && g_kcf_info.bbox_obj_num == 0) { + handle_lost_target(&frm); + } + + send_and_release: + ret = sample_common_svp_venc_vo_send_stream(&g_kcf_info.svp_switch, 0, + vo_layer, vo_chn, &frm); + if (ret != TD_SUCCESS) { + printf("[KCF] sample_common_svp_venc_vo_send_stream failed 0x%x\n", ret); + } + (td_void)ss_mpi_vpss_release_chn_frame(vpss_grp, vpss_chn, &frm); + usleep(8000); // 8000 sleep 8ms + } + return TD_NULL; +} + +static void sample_kcf_info_init(ot_svp_mem_info total_mem, td_u32 list_mem_size) +{ + g_kcf_info.list_mem = total_mem; + g_kcf_info.list_mem.size = list_mem_size; + + g_kcf_info.gauss_peak.phys_addr = g_kcf_info.list_mem.phys_addr + list_mem_size; + g_kcf_info.gauss_peak.virt_addr = g_kcf_info.list_mem.virt_addr + list_mem_size; + g_kcf_info.gauss_peak.size = SAMPLE_KCF_GAUSS_PEAK_SIZE; + + g_kcf_info.cos_win_x.phys_addr = g_kcf_info.gauss_peak.phys_addr + SAMPLE_KCF_GAUSS_PEAK_SIZE; + g_kcf_info.cos_win_x.virt_addr = g_kcf_info.gauss_peak.virt_addr + SAMPLE_KCF_GAUSS_PEAK_SIZE; + g_kcf_info.cos_win_x.size = SAMPLE_KCF_COS_WIN_SIZE; + + g_kcf_info.cos_win_y.phys_addr = g_kcf_info.cos_win_x.phys_addr + SAMPLE_KCF_COS_WIN_SIZE; + g_kcf_info.cos_win_y.virt_addr = g_kcf_info.cos_win_x.virt_addr + SAMPLE_KCF_COS_WIN_SIZE; + g_kcf_info.cos_win_y.size = SAMPLE_KCF_COS_WIN_SIZE; + + g_kcf_info.kcf_proc_ctrl.tmp_buf.phys_addr = + g_kcf_info.cos_win_y.phys_addr + SAMPLE_KCF_COS_WIN_SIZE; + g_kcf_info.kcf_proc_ctrl.tmp_buf.virt_addr = + g_kcf_info.cos_win_y.virt_addr + SAMPLE_KCF_COS_WIN_SIZE; + g_kcf_info.kcf_proc_ctrl.tmp_buf.size = SAMPLE_KCF_TEMP_BUF_SIZE; +} + +static void sample_kcf_proc_ctrl_init(void) +{ + g_kcf_info.kcf_proc_ctrl.csc_mode = OT_IVE_CSC_MODE_VIDEO_BT709_YUV_TO_RGB; + /* 0.001 learning rate 1024 Quantization scaling factor 32 Additional scaling factor */ + g_kcf_info.kcf_proc_ctrl.interp_factor = (td_u1q15)(0.001 * 1024 * 32); /* 降低学习率,减少抖动 ≈327 */ + g_kcf_info.kcf_proc_ctrl.lamda = 10; /* 10 lamda */ + g_kcf_info.kcf_proc_ctrl.sigma = (td_u0q8)(0.5 * 256); /* 0.5 * 256 降低sigma,提高稳定性 ≈77 */ + g_kcf_info.kcf_proc_ctrl.norm_trunc_alfa = (td_u4q12)(0.15 * 4096); /* 0.15 * 4096 降低截断因子 ≈614 */ + g_kcf_info.kcf_proc_ctrl.response_threshold = 5; /* 5 提高阈值,减少误检 */ + g_kcf_info.kcf_proc_ctrl.core_id = OT_IVE_KCF_CORE0; +} + +static void sample_kcf_bbox_ctrl_init(void) +{ + g_kcf_info.kcf_bbox_ctrl.max_bbox_num = SAMPLE_KCF_LIST_NODE_MAX; + g_kcf_info.kcf_bbox_ctrl.response_threshold = 12; /* 12 threshold */ + g_kcf_info.padding = 48; /* 48 padding */ +} + +static td_s32 sample_kcf_media_cfg(const ot_sample_svp_media_cfg *media_cfg) +{ + if (media_cfg != TD_NULL) { + g_kcf_info.svp_switch = media_cfg->svp_switch; /* {TD_FALSE, TD_TRUE} */ + } else { + g_kcf_info.svp_switch.is_venc_open = TD_FALSE; + g_kcf_info.svp_switch.is_vo_open = TD_TRUE; + } + + g_stop_flag = TD_FALSE; + // Removed g_get_frame_thd creation + if (pthread_create(&g_track_thd, NULL, kcf_track_thread, NULL) != 0) { + return TD_FAILURE; + } + // 在 sample_kcf_track_init 末尾添加 + g_kcf_info.roi_num = 1; + g_kcf_info.roi_info[0].roi_id = 0; + td_u32 safe_margin = 50; /* 50 Edge safety distance */ + td_u32 init_x = (1920 - KCF_BOX_WIDTH) / 2; /* 1920 PIC of width */ + td_u32 init_y = (1080 - KCF_BOX_HEIGHT) / 2; /* 1080 PIC of width */ + // 确保初始位置不靠近边缘(至少50像素缓冲) + if (init_x < safe_margin) init_x = safe_margin; + if (init_y < safe_margin) init_y = safe_margin; + g_kcf_info.roi_info[0].roi.x = init_x * OT_SAMPLE_QUARTER_OF_1M; + g_kcf_info.roi_info[0].roi.y = init_y * OT_SAMPLE_QUARTER_OF_1M; + g_kcf_info.roi_info[0].roi.width = KCF_BOX_WIDTH; + g_kcf_info.roi_info[0].roi.height = KCF_BOX_HEIGHT; + + return TD_SUCCESS; +} + +td_s32 sample_kcf_track_init(const ot_sample_svp_media_cfg *media_cfg, sample_vo_cfg *vo_cfg) +{ + memset(&g_kcf_info, 0, sizeof(g_kcf_info)); + pthread_mutex_init(&g_kcf_info.det_mutex, NULL); + + /* ---------------- KCF 内存初始化 ---------------- */ + td_s32 ret; + td_u32 list_mem_size; + td_u32 total_size; + + /* 1. 计算对象链表大小 */ + ret = ss_mpi_ive_kcf_get_mem_size(SAMPLE_KCF_LIST_NODE_MAX, &list_mem_size); + if (ret != TD_SUCCESS) { + printf("kcf get mem size failed 0x%x\n", ret); + return ret; + } + + /* 2. 申请一整块连续内存 (list + gauss + cosX + cosY + tmp) */ + total_size = list_mem_size + SAMPLE_KCF_GAUSS_PEAK_SIZE + + SAMPLE_KCF_COS_WIN_SIZE * 2 + SAMPLE_KCF_TEMP_BUF_SIZE; /* 2 is a number */ + + ot_svp_mem_info total_mem = {0}; + ret = sample_common_ive_create_mem_info(&total_mem, total_size); + if (ret != TD_SUCCESS) { + printf("kcf alloc total mem failed 0x%x\n", ret); + return ret; + } + + /* 3. 切分子区域 */ + sample_kcf_info_init(total_mem, list_mem_size); + + /* 4. 创建对象链表 */ + ret = ss_mpi_ive_kcf_create_obj_list(&g_kcf_info.list_mem, SAMPLE_KCF_LIST_NODE_MAX, &g_kcf_info.obj_list); + if (ret != TD_SUCCESS) { + printf("create obj list err 0x%x\n", ret); + return ret; + } + + /* 5. 生成 GaussPeak / CosWin 窗口 */ + g_kcf_info.padding = 48; /* 48 is 1.5*32 */ + ret = ss_mpi_ive_kcf_create_gauss_peak(g_kcf_info.padding, &g_kcf_info.gauss_peak); + if (ret != TD_SUCCESS) { + printf("create gauss peak err 0x%x\n", ret); + return ret; + } + ret = ss_mpi_ive_kcf_create_cos_win(&g_kcf_info.cos_win_x, &g_kcf_info.cos_win_y); + if (ret != TD_SUCCESS) { + printf("create cos win err 0x%x\n", ret); + return ret; + } + + /* 6. 填写 kcf_proc_ctrl 默认参数 */ + sample_kcf_proc_ctrl_init(); + + /* 7. 初始化 bbox ctrl */ + sample_kcf_bbox_ctrl_init(); + + /* 8. 继承媒体配置中的开关,使 KCF 线程能够把结果帧送到 VO/VENC */ + ret = sample_kcf_media_cfg(media_cfg); + if (ret != TD_SUCCESS) { + printf("kcf media cfg err 0x%x\n", ret); + return ret; + } + + return TD_SUCCESS; +} + +void sample_kcf_track_deinit(void) +{ + g_stop_flag = TD_TRUE; + // Removed g_get_frame_thd join + if (g_track_thd) { + pthread_join(g_track_thd, NULL); + } + /* 释放 KCF 内存与对象链表 */ + ss_mpi_ive_kcf_destroy_obj_list(&g_kcf_info.obj_list); + + /* 仅需释放一次整块内存,避免重复 free 导致 mmb not found 警告 */ + sample_svp_mmz_free(g_kcf_info.list_mem.phys_addr, g_kcf_info.list_mem.virt_addr); + + pthread_mutex_destroy(&g_kcf_info.det_mutex); +} + +// 修改 sample_kcf_set_det_rect,只在切换到跟踪模式时设置 g_has_new_rect +void sample_kcf_set_det_rect(const ot_sample_svp_rect_info *rect, int mode) +{ + pthread_mutex_lock(&g_rect_mutex); + g_new_rect = *rect; + if (mode == 1) { + ss_mpi_ive_kcf_destroy_obj_list(&g_kcf_info.obj_list); + ss_mpi_ive_kcf_create_obj_list(&g_kcf_info.list_mem, SAMPLE_KCF_LIST_NODE_MAX, &g_kcf_info.obj_list); + g_has_new_rect = TD_TRUE; + // 重置上一次的黄色框信息,避免切换时残留 + memset(&g_last_valid_rect, 0, sizeof(ot_sample_svp_rect_info)); + g_lost_count = 0; + } else if (mode == 0) { // 切换到红色框模式:强制红框回到中央 + // 计算屏幕中央坐标(基于1920x1080分辨率) + td_u32 center_x = (1920 - KCF_BOX_WIDTH) / 2; // 中央x坐标 + td_u32 center_y = (1080 - KCF_BOX_HEIGHT) / 2; // 中央y坐标 + // 重置红框的初始位置到中央(与初始化时一致) + g_kcf_info.roi_info[0].roi.x = center_x * OT_SAMPLE_QUARTER_OF_1M; + g_kcf_info.roi_info[0].roi.y = center_y * OT_SAMPLE_QUARTER_OF_1M; + // 保持宽高不变(KCF_BOX_WIDTH x KCF_BOX_HEIGHT) + g_kcf_info.roi_info[0].roi.width = KCF_BOX_WIDTH; + g_kcf_info.roi_info[0].roi.height = KCF_BOX_HEIGHT; + } + g_kcf_mode = mode; + + if (mode == 0) { + g_kcf_info.obj_list.train_obj_num = 0; + g_kcf_info.obj_list.track_obj_num = 0; + g_kcf_info.bbox_obj_num = 0; + } + pthread_mutex_unlock(&g_rect_mutex); +} + +td_u32 sample_kcf_get_bbox_num(void) +{ + return g_kcf_info.bbox_obj_num; +} diff --git a/vendor/zsks/demo/sample_kcf_track/sample_kcf_track.h b/vendor/zsks/demo/sample_kcf_track/sample_kcf_track.h new file mode 100755 index 0000000000000000000000000000000000000000..5ad8a3327f0f37a09f8c46cface5afa1b3d987f8 --- /dev/null +++ b/vendor/zsks/demo/sample_kcf_track/sample_kcf_track.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * Copyright (c) 2025 Zhongshan Kuangshi Microelectronics Technology Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Modifications Author: yaohongtao (yht@cust.edu.cn) + */ + +#ifndef SAMPLE_KCF_TRACK_H +#define SAMPLE_KCF_TRACK_H + +#include +#include "sample_comm.h" +#include "ot_common_svp.h" +#include "sample_common_svp.h" +#include "sample_common_ive.h" + +#ifndef SAMPLE_YOLO_KCF_INFO_T +#define SAMPLE_YOLO_KCF_INFO_T +#define SAMPLE_KCF_MAX_OBJ 4 + +typedef struct { + ot_ive_roi_info roi_info[SAMPLE_KCF_MAX_OBJ]; + td_u32 roi_num; + + /* 训练相关内存 */ + ot_svp_mem_info cos_win_x; + ot_svp_mem_info cos_win_y; + ot_svp_mem_info gauss_peak; + ot_svp_mem_info list_mem; /* KCF 对象链表内存 */ + ot_ive_kcf_obj_list obj_list; + ot_ive_kcf_proc_ctrl kcf_proc_ctrl; + ot_ive_kcf_bbox_ctrl kcf_bbox_ctrl; + + /* 跟踪结果 */ + ot_ive_kcf_bbox bbox[SAMPLE_KCF_MAX_OBJ]; + td_u32 bbox_obj_num; + + /* 帧缓存 */ + ot_video_frame_info frame_info_arr[1]; + + /* 互斥 */ + pthread_mutex_t det_mutex; + + /* 其它 */ + td_u3q5 padding; /* 调 API 需要的 padding 值 */ + ot_sample_svp_switch svp_switch; + sample_vo_cfg vo_cfg; /* VO configuration */ +} sample_yolo_kcf_info; +#endif + +#define SAMPLE_KCF_LIST_NODE_MAX 64 +#define SAMPLE_KCF_GAUSS_PEAK_SIZE 455680 +#define SAMPLE_KCF_COS_WIN_SIZE 832 +#define SAMPLE_KCF_TEMP_BUF_SIZE 47616 + +/* 说明: + * 1. sample_kcf_track_init 内部会创建获取帧+跟踪线程并一直运行; + * 2. 检测线程(NPU/RFCN 或 YOLO)每获得一次新检测框,调用 sample_kcf_set_det_rect + * 把第一只目标的 rect 信息推送给 KCF,KCF 会在下一帧里自动训练 / 跟踪; + * 3. sample_kcf_track_deinit 会安全地结束线程并释放内存。 + */ +td_s32 sample_kcf_track_init(const ot_sample_svp_media_cfg *media_cfg, sample_vo_cfg *vo_cfg); +void sample_kcf_track_deinit(void); + +void sample_kcf_set_det_rect(const ot_sample_svp_rect_info *rect, int mode); + +td_u32 sample_kcf_get_bbox_num(void); + +#endif /* SAMPLE_KCF_TRACK_H */ diff --git a/vendor/zsks/demo/sample_kcf_track/sample_svp_npu_process.c b/vendor/zsks/demo/sample_kcf_track/sample_svp_npu_process.c new file mode 100755 index 0000000000000000000000000000000000000000..b20b14d13e36993561a01f531a926f48a7269407 --- /dev/null +++ b/vendor/zsks/demo/sample_kcf_track/sample_svp_npu_process.c @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * Copyright (c) 2025 Zhongshan Kuangshi Microelectronics Technology Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Modifications Author: yaohongtao (yht@cust.edu.cn) + */ +#include +#include +#include +#include +#include +#include "sample_comm.h" +#include "sample_common_svp.h" +#include "sample_common_svp_npu.h" +#include "sample_common_svp_npu_model.h" +#include "sample_kcf_track.h" +#include "sample_svp_npu_process.h" + +#ifndef OT_SAMPLE_SYS_ALIGN_SIZE +#define OT_SAMPLE_SYS_ALIGN_SIZE 64 // 常见对齐值,根据 SDK 调整 +#endif +#ifndef CIF_WIDTH +#define CIF_WIDTH 200 +#endif +#ifndef CIF_HEIGHT +#define CIF_HEIGHT 200 +#endif + +// getch实现放在文件顶部 +static int getch(void) +{ + struct termios oldt; + struct termios newt; + int ch; + tcgetattr(STDIN_FILENO, &oldt); + newt = oldt; + newt.c_lflag &= ~(ICANON | ECHO); + tcsetattr(STDIN_FILENO, TCSANOW, &newt); + ch = getchar(); + tcsetattr(STDIN_FILENO, TCSANOW, &oldt); + return ch; +} + +td_s32 sample_common_svp_get_def_vo_cfg(sample_vo_cfg *vo_cfg); +static td_bool g_svp_npu_terminate_signal = TD_FALSE; +static sample_vi_cfg g_vi_config; + +static ot_sample_svp_rect_info g_svp_npu_rect_info = {0}; +static td_bool g_svp_npu_thread_stop = TD_FALSE; +static pthread_t g_svp_npu_thread = 0; +static sample_vo_cfg g_svp_npu_vo_cfg = { 0 }; +static pthread_t g_svp_npu_vdec_thread = 0; +static ot_vb_pool_info g_svp_npu_vb_pool_info; +static td_void *g_svp_npu_vb_virt_addr = TD_NULL; + +static ot_sample_svp_media_cfg g_svp_npu_media_cfg = { + .svp_switch = {TD_FALSE, TD_TRUE}, + .pic_type = {PIC_1080P, PIC_CIF}, // Changed to PIC_1080P for main stream + .chn_num = OT_SVP_MAX_VPSS_CHN_NUM, +}; + +static sample_vdec_attr g_svp_npu_vdec_cfg = { + .type = OT_PT_MJPEG, + .mode = OT_VDEC_SEND_MODE_FRAME, + .width = FHD_WIDTH, // Changed to FHD_WIDTH + .height = FHD_HEIGHT, // Changed to FHD_HEIGHT + .sample_vdec_picture.pixel_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_420, /* 420:pixel_format */ + .sample_vdec_picture.alpha = 0, /* 0:alpha */ + .display_frame_num = 1, /* Keep 1 */ + .frame_buf_cnt = 3, /* Keep 3 */ +}; + +static vdec_thread_param g_svp_npu_vdec_param = { + .chn_id = 0, + + .v4l2_device = "/dev/video0", // 摄像头设备 + .width = FHD_WIDTH, // Changed to FHD_WIDTH + .height = FHD_HEIGHT, // Changed to FHD_HEIGHT + .pixel_format = V4L2_PIX_FMT_MJPEG, // MJPEG格式 + + .type = OT_PT_MJPEG, + .stream_mode = OT_VDEC_SEND_MODE_FRAME, + .interval_time = 1000, /* 1000:interval_time */ + .pts_init = 0, + .pts_increase = 0, + .e_thread_ctrl = THREAD_CTRL_START, + .circle_send = TD_TRUE, + .milli_sec = 0, + .min_buf_size = (FHD_WIDTH * FHD_HEIGHT * 3) >> 1, /* 3 Re-calculated for 1080P */ + .fps = 30, /* 30 fps */ +}; + +td_void sample_vb_cfg_init(ot_vb_cfg *vb_cfg, ot_size size_1080p, ot_size size_cif) +{ + td_u64 raw_size_1080p = 0; + td_u64 raw_size_cif = 0; + + raw_size_1080p = (td_u64)size_1080p.width * size_1080p.height * 3 / 2; /* 3 2 YUV420: 1.5 bytes per pixel */ + vb_cfg->max_pool_cnt = 2; /* 2 pool */ + vb_cfg->common_pool[0].blk_size = (raw_size_1080p + OT_SAMPLE_SYS_ALIGN_SIZE - 1) & ~(OT_SAMPLE_SYS_ALIGN_SIZE - 1); + vb_cfg->common_pool[0].blk_cnt = 10; // 块数,根据需要调整(对于1080P,建议10-20) + + raw_size_cif = (td_u64)size_cif.width * size_cif.height * 3 / 2; /* 3 2 raw size */ + vb_cfg->common_pool[1].blk_size = (raw_size_cif + OT_SAMPLE_SYS_ALIGN_SIZE - 1) & ~(OT_SAMPLE_SYS_ALIGN_SIZE - 1); + vb_cfg->common_pool[1].blk_cnt = 4; /* 4 pool */ +} + +td_void sample_center_rect_init(ot_sample_svp_rect_info *center_rect) +{ + int frame_w = FHD_WIDTH; + int frame_h = FHD_HEIGHT; // Use FHD resolution for initial box + int box_w = CIF_WIDTH; + int box_h = CIF_HEIGHT; // A reasonable box size for FHD + int x = (frame_w - box_w) / 2; /* 2 half of x */ + int y = (frame_h - box_h) / 2; /* 2 half of y */ + + center_rect->num = 1; + center_rect->rect[0].point[0].x = x; + center_rect->rect[0].point[0].y = y; + center_rect->rect[0].point[1].x = x + box_w; + center_rect->rect[0].point[1].y = y; + center_rect->rect[0].point[2].x = x + box_w; /* 2 index of 2 */ + center_rect->rect[0].point[2].y = y + box_h; /* 2 index of 2 */ + center_rect->rect[0].point[3].x = x; /* 3 index of 3 */ + center_rect->rect[0].point[3].y = y + box_h; /* 3 index of 3 */ + + printf("[MAIN-2] Setting input rect: (%d,%d) to (%d,%d)\n", + center_rect->rect[0].point[0].x, center_rect->rect[0].point[0].y, + center_rect->rect[0].point[2].x, center_rect->rect[0].point[2].y); /* 2 index of 2 */ +} + +// 1. 程序启动时,推送中心红框,KCF只画红框不训练 +static td_void sample_svp_npu_kcf_tracking_loop(td_void) +{ + ot_sample_svp_rect_info center_rect = {0}; + sample_center_rect_init(¢er_rect); + sample_kcf_set_det_rect(¢er_rect, 0); // 0=只画红框 + + int tracking_on = 0; // 0=红框, 1=跟踪 + // FIX: Use non-blocking input check to avoid blocking termination signal + struct termios oldt; + struct termios newt; + tcgetattr(STDIN_FILENO, &oldt); + newt = oldt; + newt.c_lflag &= ~(ICANON | ECHO); + tcsetattr(STDIN_FILENO, TCSANOW, &newt); + + while (!g_svp_npu_terminate_signal) { + int ch = getch(); + if (ch == ' ') { + tracking_on = !tracking_on; // 切换模式 + if (tracking_on) { + sample_kcf_set_det_rect(¢er_rect, 1); // 进入跟踪模式,重新训练KCF + printf("[MAIN] Set to tracking mode\n"); + } else { + sample_kcf_set_det_rect(¢er_rect, 0); // 回到红框模式 + printf("[MAIN] Set to red box mode\n"); + } + } else if (ch == 'q') { + break; + } + usleep(100000); // 100000 100ms poll to reduce CPU usage + } + // Restore terminal settings + tcsetattr(STDIN_FILENO, TCSANOW, &oldt); +} + +td_void sample_svp_npu_acl_v4l2_kcf(td_void) +{ + td_s32 ret; + ot_vb_cfg vb_cfg = {0}; + ot_size size_cif; + ot_size size_1080p; + + g_svp_npu_terminate_signal = TD_FALSE; /* 清除退出标志 */ + // 计算 1080P 的 blk_size + sample_comm_sys_get_pic_size(PIC_1080P, &size_1080p); // 从 SDK 获取标准分辨率 (1920x1080) + // 计算 CIF 的 blk_size + sample_comm_sys_get_pic_size(PIC_CIF, &size_cif); // 从 SDK 获取标准分辨率 (352x288) + sample_vb_cfg_init(&vb_cfg, size_1080p, size_cif); + ret = sample_comm_sys_init(&vb_cfg); // 初始化系统 VB + if (ret != TD_SUCCESS) { + printf("[SYS] init failed 0x%x\n", ret); + return; + } + /* ** 2. 新增:获取默认VO配置 ** */ + ret = sample_common_svp_get_def_vo_cfg(&g_svp_npu_vo_cfg); + if (ret != TD_SUCCESS) { + printf("[VO] get default config failed 0x%x\n", ret); + sample_comm_sys_exit(); // **** 新增:清理系统 VB **** + return; + } + /* 3. 根据采集分辨率重新设定 VB 图像类型,避免无谓的 4K 内存开销 */ + g_svp_npu_media_cfg.pic_type[0] = PIC_1080P; + g_svp_npu_media_cfg.pic_type[1] = PIC_CIF; /* 备用,不使用 */ + + /* 4. 启动 V4L2->VDEC->VPSS->VO 通路(内部自动绑定) */ + ret = sample_common_svp_create_vb_start_vdec_vpss_vo(&g_svp_npu_vdec_cfg, &g_svp_npu_vdec_param, + &g_svp_npu_vdec_thread, &g_svp_npu_media_cfg, &g_svp_npu_vo_cfg); + if (ret != TD_SUCCESS) { + printf("[PIPE] create pipeline failed 0x%x\n", ret); + sample_common_svp_destroy_vb_stop_vdec_vpss_vo(&g_svp_npu_vdec_param, &g_svp_npu_vdec_thread, + &g_svp_npu_media_cfg, &g_svp_npu_vo_cfg); + return; + } + /* 4. 启动 KCF 跟踪——内部线程会从 VPSS grp0 chn0 拉帧并画框 */ + ret = sample_kcf_track_init(&g_svp_npu_media_cfg, &g_svp_npu_vo_cfg); + if (ret != TD_SUCCESS) { + printf("[KCF] init failed 0x%x\n", ret); + sample_common_svp_destroy_vb_stop_vdec_vpss_vo(&g_svp_npu_vdec_param, &g_svp_npu_vdec_thread, + &g_svp_npu_media_cfg, &g_svp_npu_vo_cfg); + return; + } + + sample_svp_npu_kcf_tracking_loop(); + + sample_kcf_track_deinit(); + sample_common_svp_destroy_vb_stop_vdec_vpss_vo(&g_svp_npu_vdec_param, &g_svp_npu_vdec_thread, + &g_svp_npu_media_cfg, &g_svp_npu_vo_cfg); + sample_comm_sys_exit(); +} diff --git a/vendor/zsks/demo/sample_kcf_track/sample_svp_npu_process.h b/vendor/zsks/demo/sample_kcf_track/sample_svp_npu_process.h new file mode 100755 index 0000000000000000000000000000000000000000..567813211ca3b08fabc8cafda3d1610218d3007b --- /dev/null +++ b/vendor/zsks/demo/sample_kcf_track/sample_svp_npu_process.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. + * Copyright (c) 2025 Zhongshan Kuangshi Microelectronics Technology Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Modifications Author: yaohongtao (yht@cust.edu.cn) + */ + +#ifndef SAMPLE_SVP_NPU_PROCESS_H +#define SAMPLE_SVP_NPU_PROCESS_H +#include "ot_type.h" + +/* function : show the sample of v4l2 -> VDEC -> VPSS -> KCF -> VGS/VO */ +td_void sample_svp_npu_acl_v4l2_kcf(td_void); + +#endif diff --git a/vendor/zsks/demo/sdk_linux.mk b/vendor/zsks/demo/sdk_linux.mk new file mode 100755 index 0000000000000000000000000000000000000000..b9ce68fb47b0629f6df090e87372fb918e2449f5 --- /dev/null +++ b/vendor/zsks/demo/sdk_linux.mk @@ -0,0 +1,93 @@ +#==================================================== +# SDK libs +#==================================================== +MPI_LIBS += -L$(TARGET_DIR) +MPI_LIBS += -L$(SDK_LINUX_OUT_LIB) +MPI_LIBS += -L$(SYSROOT_PATH)/lib +#MPI_LIBS += -L$(SYSROOT_PATH)/usr/lib +#MPI_LIBS += -L$(OUT_UNSTRIPPED_LIB) +MPI_LIBS += -lot_osal -lot_base -lot_sys -lot_chnl -lot_rgn -lot_vpp -lot_vo -lot_vgs -lot_vpss -lsecurec +MPI_LIBS += -lot_vdec -lot_h265e -lot_h264e -lot_jpege -lot_venc -lot_vedu -lot_vi -lot_mpi_isp -lot_rc -lot_jpegd +MPI_LIBS += -lot_sensor_i2c -lot_sensor_spi -lot_aio -lot_ai -lot_ao -lot_aenc -lot_adec -lot_acodec -lot_irq +MPI_LIBS += -lss_mpi -lss_mau -lss_dpu_match -lss_ive -lss_dpu_rect -lss_pqp -lss_hdmi -lot_vfmw -lot_isp -lot_dis +MPI_LIBS += -lot_gdc -lss_ae -lss_isp -lot_isp -lss_awb -lss_dehaze -lss_extend_stats -lss_drc -lss_ldci -lss_crb -lss_bnr -lss_voice_engine -lss_upvqe -lss_dnvqe +MPI_LIBS += -lss_calcflicker -lss_ir_auto -lss_acs -lss_acs -lsns_hy_s0603 -laac_comm -laac_dec -laac_enc -laac_sbr_dec -laac_sbr_enc +#MPI_LIBS += -lsns_os08a20 -lsns_os05a10_2l_slave -lsns_imx347_slave -lsns_imx485 -lsns_os04a10 -lsns_os08b10 +MPI_LIBS += $(SDK_LINUX_OUT_LIB)/svp_npu/libsvp_acl.a +MPI_LIBS += -L$(SDK_LINUX_OUT_LIB)/svp_npu -lprotobuf-c + +# 设置浮点运算, cpu类型, 链接器的相关设置 +CFLAGS += -Dss928v100 -DOT_XXXX -lpthread -lm -ldl -DISP_V2 -lc++ -lc -Wall -fsigned-char -mcpu=cortex-a53 -ldl -ffunction-sections -fdata-sections -O2 -fstack-protector-strong -fPIC -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fPIE -pie -s -Wall -fsigned-char -DOT_RELEASE -DVER_X=1 -DVER_Y=0 -DVER_Z=0 -DVER_P=0 -DVER_B=10 -DUSER_BIT_64 -DKERNEL_BIT_64 -Wno-date-time + +#==================================================== +# SDK include +#==================================================== +CFLAGS += -I$(SDK_LINUX_INCLUDE_DIR) +#CFLAGS += -I$(BOUNDS_CHECKING_DIR) +CFLAGS += -I$(SDK_SAMPLE_COMMON_DIR) +CFLAGS += -I$(SVP_COMMON_DIR) + +#==================================================== +# Source FileList +#==================================================== +SOURCE_TREE := $(ROOT_DIR) +BUILD_TREE := $(ROOT_DIR) + +#==================================================== +# Objects FileList +#==================================================== +SRC_ROOT := $(SOURCE_TREE) +OBJ_ROOT := $(OBJS_DIR) +OBJS := $(SMP_SRCS:$(SRC_ROOT)%.c=$(OBJ_ROOT)%.o) +OBJS := $(sort $(OBJS)) +OBJS_DIR := $(sort $(dir $(OBJS))) +CPP_OBJS := $(CPP_SRCS:$(SRC_ROOT)%.cpp=$(OBJ_ROOT)%.o) +OBJS_DIR += $(sort $(dir $(CPP_OBJS))) + +#==================================================== +# Create Directory +#==================================================== +CreateDir = $(shell [ -d $1 ] || mkdir -p $1 || echo ":mkdir '$1' fail") +CreateResult := +dummy := $(call CreateDir, $(OBJS_ROOT)) +dummy += $(foreach dir, $(OBJS_DIR), CreateResult += $(call CreateDir, $(dir))) +ifneq ($(strip CreateDir),) + err = $(error $(CreateResult)) +endif + +#==================================================== +# Compile rules +#==================================================== +MKDIRS := $(TARGET_DIR) + +.PHONY : clean all +all: $(TARGET) + +$(TARGET): $(OBJS) $(CPP_OBJS) | $(MKDIRS) + @echo ... ld $@ + @echo ... $(TARGET) + @$(CC) $(CFLAGS) $(FLAG_LD) -o $(TARGET_DIR)/$@ $^ -Wl,--start-group $(MPI_LIBS) -Wl,--end-group + +$(CPP_OBJS) : $(OBJ_ROOT)/%.o : $(SRC_ROOT)/%.cpp + @echo @@@ c++ $^ + $(CXXCPP) $(FLAG_LD) $(CFLAGS) -c "$<" -o "$@" -w + +$(OBJS) : $(OBJ_ROOT)/%.o : $(SRC_ROOT)/%.c + @echo @@@ cc $^ + @$(CC) $(FLAG_LD) $(CFLAGS) -c "$<" -o "$@" -w + +$(MKDIRS): + mkdir -p $@ + +echo =========== $(TARGET) build success ================= + +clean: + @rm -rf $(TARGET_DIR) + @rm -rf $(OBJ_ROOT) + +cleanstream: + @rm -f *.h264 + @rm -f *.h265 + @rm -f *.jpg + @rm -f *.mjp + @rm -f *.mp4 diff --git a/vendor/zsks/docs/alsa-lib/README.md b/vendor/zsks/docs/alsa-lib/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7840a0c6815f67a4d5e70ecf6cf6a7ee629c77eb --- /dev/null +++ b/vendor/zsks/docs/alsa-lib/README.md @@ -0,0 +1,230 @@ +# alsa-lib移植 + +* alsa-lib 是 Linux 系统中处理音频的核心组件。 + alsa-lib:音频功能的底层基础 + 它是 ALSA(Advanced Linux Sound Architecture,高级 Linux 声音架构)的核心库,主要作用是提供统一的音频硬件接口。 + 核心功能:封装了与声卡硬件交互的复杂逻辑,向上层应用程序提供标准化的 API(如 C 语言接口),让开发者无需直接操作硬件驱动,就能实现音频播放、录音等功能。 + 包含内容:主要生成动态链接库(如 libasound.so),是所有基于 ALSA 的程序的依赖基础;附带少量示例工具(如 aserver,一个简单的音频服务器 demo)。 + +## 1、软硬件环境 + +* 开发板:海鸥派 +* 交叉编译工具链:OHOS (dev) clang version 15.0.4 +* 编译链路径:pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin +* python版本:Python-3.13.2 +* 移植的alsa-lib版本:alsa-lib-1.1.7 + +## 2、交叉编译alsa-lib + +### 步骤1:获取源码 + +* 在服务器的命令行,分步执行下面的命令,下载alsa-lib-1.1.7源码 + +~~~bash +# (可根据需要替换版本号) +wget https://www.alsa-project.org/files/pub/lib/alsa-lib-1.1.7.tar.bz2 + +# 解压源码包 +tar -xjvf alsa-lib-1.1.7.tar.bz2 +rm alsa-lib-1.1.7.tar.bz2 + +# 进入源码目录 +cd alsa-lib-1.1.7 +~~~ + +![image-20251017172451263](pic/image-20251017172451263.png) + +### 步骤2:配置环境变量 + +* 在服务器的命令行分步执行下面的命令,配置环境变量 + +~~~bash +export SYSROOT=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot +export CC=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang +export CXX=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang++ +export AR=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-ar +export RANLIB=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-ranlib +export CFLAGS="--sysroot=$SYSROOT" +export CXXFLAGS="--sysroot=$SYSROOT" +export LDFLAGS="--sysroot=$SYSROOT" +~~~ + +![image-20251017172745509](pic/image-20251017172745509.png) + +* 在服务器的命令执行下面的命令,更新config文件 + +```sh +#核心原因是config.sub和config.guess脚本版本过旧,先移除 +rm -rf config.sub config.guess + +# 下载 config.sub +wget -O config.sub https://git.savannah.gnu.org/cgit/config.git/plain/config.sub + +# 下载 config.guess +wget -O config.guess https://git.savannah.gnu.org/cgit/config.git/plain/config.guess + +#检查更新后是否有支持ohos +grep -i "ohos" config.sub +``` + +![image-20251017172824538](pic/image-20251017172824538.png) + +![image-20251017172849064](pic/image-20251017172849064.png) + +### 步骤3:配置命令 + +* 服务器的命令行执行下面的命令,进行meson的构建。 + +~~~bash +./configure \ + --host=aarch64-linux-ohos \ + --prefix=/home/openharmony/pegasus/vendor/opensource/alsa-lib-1.1.7/install \ + --enable-shared \ + --disable-static \ + --disable-python \ + --with-pic \ + --disable-alisp \ + --disable-old-symbols \ + CC=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang +~~~ + +![image-20251017173155196](pic/image-20251017173155196.png) + +### 步骤4:编译安装 + +* 服务器的命令行执行下面的命令,进行alsa-lib的编译和安装 + +~~~bash +make -j$(nproc) 2>&1 | tee make_output.log +make install +~~~ + +![image-20250904165253761](./pic/image-20250904165253761.png) + +![image-20250904165432734](./pic/image-20250904165432734.png) + +* 编译成功后,会在install目录下生成下面的文件 + +![image-20251017173447490](pic/image-20251017173447490.png) + +## 3、板端测试 + +### 3.1 编译代码 + +* 将下面的代码复制到alsa_test.c中,在服务器上编译,得到可执行文件后放到板端执行。 + +~~~bash +#include +#include + +int main() { + int ret; + snd_pcm_t *handle; // PCM设备句柄 + snd_pcm_hw_params_t *params; // 硬件参数结构体 + + // 1. 打开PCM播放设备(默认设备) + ret = snd_pcm_open(&handle, "default", SND_PCM_STREAM_PLAYBACK, 0); + if (ret < 0) { + fprintf(stderr, "无法打开PCM设备: %s\n", snd_strerror(ret)); + return 1; + } + + // 2. 初始化硬件参数 + snd_pcm_hw_params_alloca(¶ms); + snd_pcm_hw_params_any(handle, params); + + // 设置参数: interleaved模式、采样格式(16位小端)、声道(双声道) + snd_pcm_hw_params_set_access(handle, params, SND_PCM_ACCESS_RW_INTERLEAVED); + snd_pcm_hw_params_set_format(handle, params, SND_PCM_FORMAT_S16_LE); + snd_pcm_hw_params_set_channels(handle, params, 2); + + // 设置采样率(44.1kHz) + unsigned int val = 44100; + snd_pcm_hw_params_set_rate_near(handle, params, &val, NULL); + + // 应用参数 + ret = snd_pcm_hw_params(handle, params); + if (ret < 0) { + fprintf(stderr, "无法设置PCM参数: %s\n", snd_strerror(ret)); + snd_pcm_close(handle); + return 1; + } + + // 3. 生成简单的正弦波音频数据(测试播放) + short buffer[1024]; + for (int i = 0; i < 1024; i++) { + buffer[i] = 32767 * sin(2 * 3.1415926 * 440 * i / 44100); // 440Hz正弦波 + } + + // 4. 播放音频(写入PCM设备) + ret = snd_pcm_writei(handle, buffer, 1024); + if (ret < 0) { + // 处理欠载错误(可尝试恢复) + ret = snd_pcm_recover(handle, ret, 0); + if (ret < 0) { + fprintf(stderr, "播放失败: %s\n", snd_strerror(ret)); + snd_pcm_close(handle); + return 1; + } + } + + // 5. 关闭设备 + snd_pcm_drain(handle); // 等待播放完成 + snd_pcm_close(handle); + printf("测试完成:正弦波播放成功\n"); + return 0; +} +~~~ + +* 在服务器的命令行执行下面的命令,编译该代码 +* 注意:这里的决定路径请根据自己服务器的实际情况进行填写 + +~~~bash +/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang alsa_test.c -o alsa_test -lasound \ +--sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot \ +-L /home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot/usr/lib/aarch64-linux-ohos \ + -lc \ +-I/home/openharmony/pegasus/vendor/opensource/alsa-lib-1.1.7/install/include \ +-L/home/openharmony/pegasus/vendor/opensource/alsa-lib-1.1.7/install/lib +~~~ + +![image-20251017174647517](pic/image-20251017174647517.png) + +### 3.2 NFS 共享 + +* nfs配置可参考参考链接: + +~~~bash +https://blog.csdn.net/weixin_34326429/article/details/92163791 +~~~ + +### 3.3 挂载NFS + +* 将第2章步骤4生成的install文件下载到本地(我这里是把install重命名为alsa_install了),然后拷贝到NFS的目录下 +* 再将3.1节编译生成的alsa_test下载到本地,然后拷贝到NFS的目录下 + +* 在开发板的命令行终端执行下面的命令,配置IP地址,并进行NFS挂载 + +~~~bash +ifconfig eth0 192.168.137.0 netmask 255.255.252.0 +route add default gw 192.168.137.1 +mount -o nolock,addr=192.168.137.1 -t nfs 192.168.137.1:/nfs /mnt +~~~ + +### 3.4 配置环境变量 + +* 在开发板的命令行执行下面的命令,配置alsa的环境变量 + +~~~bash +export PATH=/mnt/alsa_install/bin:$PATH +export LD_LIBRARY_PATH=/mnt/alsa_install/lib:$LD_LIBRARY_PATH +export ALSA_CONFIG_PATH=/mnt/alsa_install/share/alsa/alsa.conf:/mnt/alsa_install/share/alsa/cards/aliases.conf:/mnt/alsa_install/share/alsa/pcm/default.conf +~~~ + +![image-20251020152649127](pic/image-20251020152649127.png) + +~~~bash +chmod +x ./alsa_test +./alsa_test +~~~ + diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250903211122837.png b/vendor/zsks/docs/alsa-lib/pic/image-20250903211122837.png new file mode 100644 index 0000000000000000000000000000000000000000..e5e1a3283ff757d2867062c934003d84257ee3c8 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250903211122837.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904100830962.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904100830962.png new file mode 100644 index 0000000000000000000000000000000000000000..5a60335f31e8348429e2fde87dca3662882414f7 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904100830962.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904103350656.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904103350656.png new file mode 100644 index 0000000000000000000000000000000000000000..9e06f2bd6467f730735c161a23cf81f07f1b8bfd Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904103350656.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904103533301.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904103533301.png new file mode 100644 index 0000000000000000000000000000000000000000..b9c7489569f82a76e5c0ab2646361963d25fe950 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904103533301.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904103636103.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904103636103.png new file mode 100644 index 0000000000000000000000000000000000000000..6b61fd5a609a4bdaf278c963de73d64f2b3abe05 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904103636103.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904103828253.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904103828253.png new file mode 100644 index 0000000000000000000000000000000000000000..d1b84e9ea4a93c6639df14a197a2a6ed9ee0e775 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904103828253.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904104156703.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904104156703.png new file mode 100644 index 0000000000000000000000000000000000000000..198beecc6217c854f1c072651c5ccc6dd97720ee Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904104156703.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904113014566.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904113014566.png new file mode 100644 index 0000000000000000000000000000000000000000..97d90f6510fdc89d6c4473ffecabe0caac74e0af Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904113014566.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904113329622.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904113329622.png new file mode 100644 index 0000000000000000000000000000000000000000..494b08517939bb52dba3dddf4201b82e8a08acb6 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904113329622.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904113515712.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904113515712.png new file mode 100644 index 0000000000000000000000000000000000000000..6290f925c8bc9d0f7017d26320960e1820140189 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904113515712.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904113639259.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904113639259.png new file mode 100644 index 0000000000000000000000000000000000000000..827c90050c198fa02a3313360dca48be91edcbb6 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904113639259.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904113704266.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904113704266.png new file mode 100644 index 0000000000000000000000000000000000000000..cdbcf6e171b10ae0713f0217ce1c764b6e9c564a Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904113704266.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904143920431.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904143920431.png new file mode 100644 index 0000000000000000000000000000000000000000..bbba9d4935ea43429a600ec64dfe14119f90a735 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904143920431.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904144609428.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904144609428.png new file mode 100644 index 0000000000000000000000000000000000000000..ff29749d89fab1166b46eee624e72297948d1b94 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904144609428.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904144720470.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904144720470.png new file mode 100644 index 0000000000000000000000000000000000000000..e0529247489c0470c3d147c268bb5d97e59565f1 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904144720470.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904144926010.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904144926010.png new file mode 100644 index 0000000000000000000000000000000000000000..8d0b234ad3f45ea454352a050b887c07d72e66b4 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904144926010.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904145236942.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904145236942.png new file mode 100644 index 0000000000000000000000000000000000000000..5a60335f31e8348429e2fde87dca3662882414f7 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904145236942.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904145701210.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904145701210.png new file mode 100644 index 0000000000000000000000000000000000000000..9e06f2bd6467f730735c161a23cf81f07f1b8bfd Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904145701210.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904145948379.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904145948379.png new file mode 100644 index 0000000000000000000000000000000000000000..6b61fd5a609a4bdaf278c963de73d64f2b3abe05 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904145948379.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904151336527.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904151336527.png new file mode 100644 index 0000000000000000000000000000000000000000..795733fffe8f88aa19965ae0ab26d8c6c9663b22 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904151336527.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904152000503.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904152000503.png new file mode 100644 index 0000000000000000000000000000000000000000..a1fc3703b4a3bb495da282853fe62b782df1b6aa Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904152000503.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904165253761.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904165253761.png new file mode 100644 index 0000000000000000000000000000000000000000..718827a13a2417025076b6dde68b08786980189b Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904165253761.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904165432734.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904165432734.png new file mode 100644 index 0000000000000000000000000000000000000000..473263f18da1570a63375b6fc39227f9694a55b5 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904165432734.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904173140314.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904173140314.png new file mode 100644 index 0000000000000000000000000000000000000000..dee25e389a1a55565647ec4983c05599faf8229f Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904173140314.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904173633025.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904173633025.png new file mode 100644 index 0000000000000000000000000000000000000000..b029515ebfbf810dec8116658a8c796d249dc6b6 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904173633025.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904173809627.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904173809627.png new file mode 100644 index 0000000000000000000000000000000000000000..6fa1f8881872628428ef718a10c3b5f871643b50 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904173809627.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904173927739.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904173927739.png new file mode 100644 index 0000000000000000000000000000000000000000..d8d4b29e3f02ae342edcd8b7d344ba1ba3733970 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904173927739.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904174022615.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904174022615.png new file mode 100644 index 0000000000000000000000000000000000000000..b707369cd7400cbb1ad8b4d2f61e05c05bd51afc Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904174022615.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904182859475.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904182859475.png new file mode 100644 index 0000000000000000000000000000000000000000..9d58e6507f989dfac64d897d23362133d9056256 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904182859475.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904191234866.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904191234866.png new file mode 100644 index 0000000000000000000000000000000000000000..a4153ee3ac64fdb4d38326b7f589db62f6934321 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904191234866.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904191947983.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904191947983.png new file mode 100644 index 0000000000000000000000000000000000000000..aa149d5994b3281249c6b942b7478700c6e9bf42 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904191947983.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904192346977.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904192346977.png new file mode 100644 index 0000000000000000000000000000000000000000..38c0de5552375ef5db7e6abe9bc602cd85c028e1 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904192346977.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904192419116.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904192419116.png new file mode 100644 index 0000000000000000000000000000000000000000..6c523b6c5557261677700db84f7a7c7f443602d7 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904192419116.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250904193742624.png b/vendor/zsks/docs/alsa-lib/pic/image-20250904193742624.png new file mode 100644 index 0000000000000000000000000000000000000000..438d3875b0f9134152b8294c297c97b7ae5b630b Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250904193742624.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250905094629530.png b/vendor/zsks/docs/alsa-lib/pic/image-20250905094629530.png new file mode 100644 index 0000000000000000000000000000000000000000..5566985c274a58203ebf31aba03ade23957e2292 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250905094629530.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250905101539245.png b/vendor/zsks/docs/alsa-lib/pic/image-20250905101539245.png new file mode 100644 index 0000000000000000000000000000000000000000..619c068e1d4315c52831997b9dbbe16463e56888 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250905101539245.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250905101612375.png b/vendor/zsks/docs/alsa-lib/pic/image-20250905101612375.png new file mode 100644 index 0000000000000000000000000000000000000000..d8695cec0605742808d81edae00f728db220399c Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250905101612375.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250905101636280.png b/vendor/zsks/docs/alsa-lib/pic/image-20250905101636280.png new file mode 100644 index 0000000000000000000000000000000000000000..d885425e40dc8672fba8063d340808e04954f4cf Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250905101636280.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250905101752805.png b/vendor/zsks/docs/alsa-lib/pic/image-20250905101752805.png new file mode 100644 index 0000000000000000000000000000000000000000..2da44b646ed833201d91808f70a6dc23c5ec59fe Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250905101752805.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250905103524391.png b/vendor/zsks/docs/alsa-lib/pic/image-20250905103524391.png new file mode 100644 index 0000000000000000000000000000000000000000..dbf4aab601266fb38839d78bda2923857d6793dc Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250905103524391.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250905110002197.png b/vendor/zsks/docs/alsa-lib/pic/image-20250905110002197.png new file mode 100644 index 0000000000000000000000000000000000000000..506ffb6f4c10de7bc5c4437a236a265603656d61 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250905110002197.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250908145127235.png b/vendor/zsks/docs/alsa-lib/pic/image-20250908145127235.png new file mode 100644 index 0000000000000000000000000000000000000000..930e0d2bc8d9283c755c45cf2b710ee05fdac5ca Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250908145127235.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20250908152550633.png b/vendor/zsks/docs/alsa-lib/pic/image-20250908152550633.png new file mode 100644 index 0000000000000000000000000000000000000000..0782a0e2326097075d1a1effa4c4ebc9e1b9e78b Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20250908152550633.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20251017172451263.png b/vendor/zsks/docs/alsa-lib/pic/image-20251017172451263.png new file mode 100755 index 0000000000000000000000000000000000000000..13321c0c58829114a99aa63f3290832785c8730b Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20251017172451263.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20251017172745509.png b/vendor/zsks/docs/alsa-lib/pic/image-20251017172745509.png new file mode 100755 index 0000000000000000000000000000000000000000..acc80e4256784721b3a3ef3eb5e1c5882c78e467 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20251017172745509.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20251017172824538.png b/vendor/zsks/docs/alsa-lib/pic/image-20251017172824538.png new file mode 100755 index 0000000000000000000000000000000000000000..f2ead8650a5a7d5e708d246186e3006d0f9709ed Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20251017172824538.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20251017172849064.png b/vendor/zsks/docs/alsa-lib/pic/image-20251017172849064.png new file mode 100755 index 0000000000000000000000000000000000000000..0575ccd1094df9f9311acbe384cbfc11aaa23b42 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20251017172849064.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20251017173155196.png b/vendor/zsks/docs/alsa-lib/pic/image-20251017173155196.png new file mode 100755 index 0000000000000000000000000000000000000000..a57f1261c2e07d10c7e4f4d8f6d04162b3481206 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20251017173155196.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20251017173447490.png b/vendor/zsks/docs/alsa-lib/pic/image-20251017173447490.png new file mode 100755 index 0000000000000000000000000000000000000000..8582e902cd1b387215cd094f3235b51be855c76c Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20251017173447490.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20251017174647517.png b/vendor/zsks/docs/alsa-lib/pic/image-20251017174647517.png new file mode 100755 index 0000000000000000000000000000000000000000..595ba99c60230d2228205ad813e050e096b9cb82 Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20251017174647517.png differ diff --git a/vendor/zsks/docs/alsa-lib/pic/image-20251020152649127.png b/vendor/zsks/docs/alsa-lib/pic/image-20251020152649127.png new file mode 100755 index 0000000000000000000000000000000000000000..e25c700619eb17689e61258daccb752035464ccd Binary files /dev/null and b/vendor/zsks/docs/alsa-lib/pic/image-20251020152649127.png differ diff --git "a/vendor/zsks/docs/ffmpeg/FFmpeg_CPU\344\270\216\347\241\254\344\273\266\347\274\226\350\247\243\347\240\201\351\200\237\345\272\246\345\257\271\346\257\224.xlsx" "b/vendor/zsks/docs/ffmpeg/FFmpeg_CPU\344\270\216\347\241\254\344\273\266\347\274\226\350\247\243\347\240\201\351\200\237\345\272\246\345\257\271\346\257\224.xlsx" new file mode 100644 index 0000000000000000000000000000000000000000..86f42c39ddfb1fc9ef7241519e128f101f18c777 Binary files /dev/null and "b/vendor/zsks/docs/ffmpeg/FFmpeg_CPU\344\270\216\347\241\254\344\273\266\347\274\226\350\247\243\347\240\201\351\200\237\345\272\246\345\257\271\346\257\224.xlsx" differ diff --git a/vendor/zsks/docs/ffmpeg/README.md b/vendor/zsks/docs/ffmpeg/README.md new file mode 100644 index 0000000000000000000000000000000000000000..60466288d963aab62b9c9651f8744accbc1f1bf9 --- /dev/null +++ b/vendor/zsks/docs/ffmpeg/README.md @@ -0,0 +1,721 @@ +# FFmpeg移植 + +## 1、软硬件环境 + +* 开发板:海鸥派 +* 交叉编译工具链:OHOS (dev) clang version 15.0.4 + +* 编译链路径:pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin +* Python版本:Python-3.13.2 +* 移植的ffmpeg版本:FFmpeg-6.0 + +## 2、安装依赖 + +* 由于在编译ffmpeg的时候,需要依赖其他第三方软件,因此在编译ffmpeg之前,我们先把它依赖的第三方软件全部交叉编译出来。 + +### 步骤1:交叉编译v4l2 + +* 可以参考[v4l2的移植文档](../libv4l2/README.md)的前两章节,完成v4l2的移植工作。 + +### 步骤2:交叉编译x264 + +* 在服务器的命令行执行下面的命令,下载源码,配置编译链 + +```sh +cd pegasus/vendor/opensource/ + +git clone https://code.videolan.org/videolan/x264.git + +cd x264 +``` + +* 修改config.sub文件,在125行添加 linux-ohos* | + +![image-20251021144741884](pic/image-20251021144741884.png) + +* 执行下面的命令,配置编译环境,对代码进行编译 + +```sh +CC="/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang \ + --sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot" \ +CXX="/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang++ \ + --sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot" \ +CFLAGS="-march=armv8-a -mfpu=neon" \ +./configure \ +--host=aarch64-linux-ohos \ +--prefix=$(pwd)/install \ +--enable-shared + +make -j$(nproc) && make install +``` + +![image-20251021150217681](pic/image-20251021150217681.png) + +* 编译成功后会在install目录下生成如下文件 + +![image-20251021154212147](pic/image-20251021154212147.png) + +### 步骤3:交叉编译x265 + +* 在服务器的命令行执行下面的命令,下载源码 + +```sh +cd ../ + +wget https://bitbucket.org/multicoreware/x265_git/downloads/x265_3.5.tar.gz + +tar xf x265_3.5.tar.gz + +rm x265_3.5.tar.gz + +cd x265_3.5 +``` + +![image-20251021154533551](pic/image-20251021154533551.png) + +![image-20251021154614257](pic/image-20251021154614257.png) + +* 将下面内容替换到x265_3.5/build/aarch64-linux/crosscompile.cmake文件中 +* 注意:里面的库、头文件等的绝对路径请根据自己服务器的实际情况进行修改。 + +```sh +# crosscompile.cmake for cross compiling x265 for aarch64 with OHOS toolchain +# This feature is only supported as experimental. Use with caution. +# Please report bugs on bitbucket +# Run cmake with: cmake -DCMAKE_TOOLCHAIN_FILE=crosscompile.cmake -G "Unix Makefiles" ../../source && ccmake ../../source + +# Enable ARM cross-compilation +set(CROSS_COMPILE_ARM 1) + +# Specify the target system +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +# Specify the OHOS target (emulate config.sub behavior) +set(CMAKE_SYSTEM_VERSION ohos) + +# Specify the cross compiler +set(CMAKE_C_COMPILER /home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang) +set(CMAKE_CXX_COMPILER /home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang++) +set(CMAKE_ASM_COMPILER /home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang) +set(CMAKE_AR /home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-ar) +set(CMAKE_LINKER /home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/lld) +set(CMAKE_RANLIB /home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-ranlib) +set(CMAKE_STRIP /home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-strip) + +# Specify the target environment (sysroot) +set(CMAKE_SYSROOT /home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot) + +# Compiler and linker flags +set(CMAKE_C_FLAGS "-fPIC -target aarch64-unknown-linux-ohos" CACHE STRING "C flags") +set(CMAKE_CXX_FLAGS "-fPIC -target aarch64-unknown-linux-ohos" CACHE STRING "C++ flags") +set(CMAKE_ASM_FLAGS "-fPIC -target aarch64-unknown-linux-ohos" CACHE STRING "ASM flags") +set(CMAKE_EXE_LINKER_FLAGS "-fPIC" CACHE STRING "Linker flags") + +# Include and library paths for Hisi SDK and dependencies +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/home/openharmony/pegasus/vendor/opensource/x264/install/include" CACHE STRING "C flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/home/openharmony/pegasus/vendor/opensource/x264/install/include" CACHE STRING "C++ flags") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/home/openharmony/pegasus/vendor/opensource/x264/install/lib" CACHE STRING "Linker flags") + +# Search paths for libraries and headers +set(CMAKE_FIND_ROOT_PATH /home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot /home/openharmony/pegasus/vendor/opensource/x264/install /home/openharmony/pegasus/vendor/opensource/v4l-utils/install) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# PKG_CONFIG_PATH for finding dependencies +set(ENV{PKG_CONFIG_PATH} "/home/openharmony/pegasus/vendor/opensource/v4l-utils/install/lib/pkgconfig:/home/openharmony/pegasus/vendor/opensource/v4l-utils/install/lib/pkgconfig") + +# Debug output to verify configuration +message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}") +message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}") +message(STATUS "CMAKE_SYSROOT: ${CMAKE_SYSROOT}") +message(STATUS "CMAKE_FIND_ROOT_PATH: ${CMAKE_FIND_ROOT_PATH}") +message(STATUS "PKG_CONFIG_PATH: $ENV{PKG_CONFIG_PATH}") +``` + +* 在服务器的命令行执行下面的命令,配置编译选项 + +```sh +cd /home/openharmony/pegasus/vendor/opensource/x265_3.5 + +cmake ./source \ + -G "Unix Makefiles" \ + -DCMAKE_SYSTEM_NAME=Linux \ + -DCMAKE_SYSTEM_PROCESSOR=aarch64 \ + -DCMAKE_SYSTEM_VERSION=ohos \ + -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \ + -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ + -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ + -DCMAKE_INSTALL_PREFIX="$(pwd)/install" \ + -DENABLE_SHARED=ON \ + -DENABLE_PIC=ON \ + -DHIGH_BIT_DEPTH=ON \ + -DEXPORT_C_API=ON \ + -DENABLE_ASSEMBLY=OFF \ + -Wno-dev + +make -j$(nproc)&&make install +``` + +![image-20251021161044799](pic/image-20251021161044799.png) + +![image-20251021161134241](pic/image-20251021161134241.png) + +* 编译完成后,会在install目录下生成如下文件 + +![image-20251021161216433](pic/image-20251021161216433.png) + +## 3、交叉编译FFmpeg + +### 步骤1:下载源码 + +* 在服务器的命令行执行下面的命令,下载ffmpeg源码 + +```sh +cd ../ + +git clone -b release/6.0 https://gitee.com/zhongshankuangshi/ffmpeg.git + +cd ffmpeg +``` + +![image-20251021205649485](pic/image-20251021205649485.png) + +### 步骤2:环境变量配置 + +* 注意这里出现的决定路径的地址,请根据自己服务器的具体情况进行修改。 + +```sh +export CC=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang +export CXX=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang++ +export AR=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-ar +export LD=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/lld +export RANLIB=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-ranlib +export STRIP=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-strip + +export PKG_CONFIG_PATH="/home/openharmony/pegasus/vendor/opensource/x264/install/lib/pkgconfig:$PKG_CONFIG_PATH" +export CXXFLAGS="-I/home/openharmony/pegasus/vendor/opensource/x264/install/include $CXXFLAGS" +export LDFLAGS="-L/home/openharmony/pegasus/vendor/opensource/x264/install/lib $LDFLAGS" + +export PKG_CONFIG_PATH="/home/openharmony/pegasus/vendor/opensource/x265_3.5/install/lib/pkgconfig:$PKG_CONFIG_PATH" +export CXXFLAGS="-I/home/openharmony/pegasus/vendor/opensource/x265_3.5/install/include $CXXFLAGS" +export LDFLAGS="-L/home/openharmony/pegasus/vendor/opensource/x265_3.5/install/lib $LDFLAGS" + +export PKG_CONFIG_PATH="/home/openharmony/pegasus/vendor/opensource/v4l-utils/install/lib/pkgconfig:$PKG_CONFIG_PATH" +export CXXFLAGS="-I/home/openharmony/pegasus/vendor/opensource/v4l-utils/install/include $CXXFLAGS" +export LDFLAGS="-L/home/openharmony/pegasus/vendor/opensource/v4l-utils/install/lib $LDFLAGS" +``` + +![image-20251021205900311](pic/image-20251021205900311.png) + +### 步骤3:修改相关编译脚本 + +* 在pegasus/platform/ss928v100_clang/smp/a55_linux/mpp/sample/common/makefile的第4行,添加一个fPIC选项到CFLAGS,如下图所示: + +![image-20251022142837408](pic/image-20251022142837408.png) + +* 然后进入到pegasus/platform/ss928v100_clang/smp/a55_linux/mpp/sample/common目录下,执行 make clean && make 命令,重新生成.o文件 +* 注意:请根据自己服务器的实际情况修改里面的绝对路径 + +```sh +export PATH=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin:$PATH + +export SYSROOT_PATH=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot + +make clean && make +``` + +![image-20251022150813007](pic/image-20251022150813007.png) + +* 在ffmpeg目录下创建一个build_ffmpeg.sh脚本,把下面的内容复制进去 + +* 注意:请根据自己服务器的实际情况修改里面的绝对路径 + +![image-20251022150910879](pic/image-20251022150910879.png) + +```sh +#!/bin/bash + +# 设置交叉编译工具链的根目录 +TOOLCHAIN_ROOT="/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm" +# 交叉编译工具链前缀 +CROSS_PREFIX="aarch64-unknown-linux-ohos" +# 设置sysroot路径 +SYSROOT="/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot" + +# C 和 C++ 编译器 +CC="${TOOLCHAIN_ROOT}/bin/${CROSS_PREFIX}-clang" +CXX="${TOOLCHAIN_ROOT}/bin/${CROSS_PREFIX}-clang++" +export AR="${TOOLCHAIN_ROOT}/bin/llvm-ar" +export LD="${TOOLCHAIN_ROOT}/bin/lld" +export RANLIB="${TOOLCHAIN_ROOT}/bin/llvm-ranlib" +export STRIP="${TOOLCHAIN_ROOT}/bin/llvm-strip" + +# 获取当前脚本目录 +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +WORK_DIR="$(pwd)" + +# 安装目录 +PREFIX="${WORK_DIR}/install" + +# 海思SDK路径 +HISI_SDK_BASE="/home/openharmony/pegasus/platform/ss928v100_clang/smp/a55_linux" +HISI_MPP_BASE="${HISI_SDK_BASE}/mpp" +HISI_COMMON_DIR="/home/openharmony/pegasus/platform/ss928v100_clang/smp/a55_linux/mpp/sample/common" + +# 配置PKG_CONFIG_PATH +export PKG_CONFIG_PATH="/home/openharmony/pegasus/vendor/opensource/x264/install/lib/pkgconfig:$PKG_CONFIG_PATH" +export PKG_CONFIG_PATH="/home/openharmony/pegasus/vendor/opensource/x265_3.5/install/lib/pkgconfig:$PKG_CONFIG_PATH" +export PKG_CONFIG_PATH="/home/openharmony/pegasus/vendor/opensource/v4l-utils/install/lib/pkgconfig:$PKG_CONFIG_PATH" + +# 查找FFmpeg源码目录 +FFMPEG_SRC="../ffmpeg" +# 创建SDK初始化库目录 +SDK_LIB_DIR="$(pwd)/hisi_sdk_lib" +mkdir -p "$SDK_LIB_DIR" +# 定义所有SDK库目录,添加更多可能的搜索路径 +ALL_SDK_LIB_DIRS=( + "${HISI_MPP_BASE}/out/lib" + "${HISI_MPP_BASE}/out/lib/svp_npu" + "${HISI_COMMON_DIR}" +) + +# 获取实际存在的海思SDK库列表 +echo "扫描实际存在的海思SDK库文件..." +AVAILABLE_LIBS=() +for dir in "${ALL_SDK_LIB_DIRS[@]}"; do + if [ -d "$dir" ]; then + echo "扫描库目录: $dir" + # 查找所有.so和.a库文件 + for lib_path in "${dir}/lib"*.so "${dir}/lib"*.a; do + if [ -f "$lib_path" ]; then + # 提取库名称(去除路径、lib前缀和扩展名) + lib_name=$(basename "$lib_path" .so) + lib_name=$(basename "$lib_name" .a) + lib_name=${lib_name#lib} + + # 仅添加新的库,避免重复 + if ! [[ " ${AVAILABLE_LIBS[@]} " =~ " ${lib_name} " ]]; then + AVAILABLE_LIBS+=("$lib_name") + echo "✓ 找到库: $lib_name ($lib_path)" + fi + fi + done + else + echo "⚠ 库目录不存在: $dir" + fi +done + +echo "总共找到 ${#AVAILABLE_LIBS[@]} 个海思SDK库" + +# 检查关键库是否存在,使用ss_mpi作为ot_mpi的替代 +CRITICAL_LIBS=("securec" "ot_osal" "ss_mpi" "ot_base") +for lib in "${CRITICAL_LIBS[@]}"; do + if [[ " ${AVAILABLE_LIBS[@]} " =~ " ${lib} " ]]; then + echo "✓ 关键库 ${lib} 存在" + else + echo "⚠ 警告: 关键库 ${lib} 缺失" + fi +done + +# 验证已编译的目标文件是否存在 +REQUIRED_OBJS=( + "${HISI_COMMON_DIR}/sdk_init.o" + "${HISI_COMMON_DIR}/sdk_exit.o" +) + +COMPILED_OBJECTS=() +for obj in "${REQUIRED_OBJS[@]}"; do + if [ -f "$obj" ]; then + COMPILED_OBJECTS+=("$obj") + echo "✓ 找到已编译目标文件: $(basename "$obj")" + else + echo "✗ 缺失已编译目标文件: $(basename "$obj")" + echo "请确保在 ${HISI_COMMON_DIR} 目录下存在该文件" + exit 1 + fi +done + +for obj_path in "${HISI_COMMON_DIR}"/*.o; do + # 跳过已经添加的sdk_init.o和sdk_exit.o + if [ -f "$obj_path" ] && [[ ! " ${COMPILED_OBJECTS[@]} " =~ " ${obj_path} " ]]; then + COMPILED_OBJECTS+=("$obj_path") + echo "✓ 添加额外目标文件: $(basename "$obj_path")" + fi +done + +# 构建链接参数 - 自动链接所有找到的库 +LINK_LIBS="" +LINKED_COUNT=0 + +echo "按顺序链接所有找到的海思SDK库:" +for lib in "${AVAILABLE_LIBS[@]}"; do + LINK_LIBS="${LINK_LIBS} -l${lib}" + echo "✓ 链接库: ${lib}" + ((LINKED_COUNT++)) +done + +# 构建动态库链接命令,添加处理非PIC代码的选项 +echo "构建动态库链接命令..." +LINK_CMD="$CC -shared -fPIC --sysroot=$SYSROOT" +LINK_CMD="${LINK_CMD} -o ${SDK_LIB_DIR}/libhisi_sdk_init.so" +LINK_CMD="${LINK_CMD} ${COMPILED_OBJECTS[*]}" + +# 添加所有SDK库目录到链接命令(包括common目录) +for dir in "${ALL_SDK_LIB_DIRS[@]}"; do + LINK_CMD="${LINK_CMD} -L${dir}" +done + +# 添加处理非PIC代码的链接选项 +LINK_CMD="${LINK_CMD} ${LINK_LIBS}" +LINK_CMD="${LINK_CMD} -lpthread -lm -lstdc++ -ldl -lrt" +LINK_CMD="${LINK_CMD} -Wl,--allow-shlib-undefined" +LINK_CMD="${LINK_CMD} -Wl,-allow-multiple-definition" # 允许多重定义 +LINK_CMD="${LINK_CMD} -Wl,-z,notext" # 允许非PIC代码在共享库中 + +echo "执行链接命令:" +echo "${LINK_CMD}" +echo "==========================================" + +eval "${LINK_CMD}" + +if [ $? -ne 0 ]; then + echo "✗ 动态库创建失败" + echo "尝试使用简化链接参数..." + + # 只链接关键库的简化版本,使用ss_mpi替代ot_mpi + SIMPLE_LINK_CMD="$CC -shared -fPIC --sysroot=$SYSROOT" + SIMPLE_LINK_CMD="${SIMPLE_LINK_CMD} -o ${SDK_LIB_DIR}/libhisi_sdk_init.so" + SIMPLE_LINK_CMD="${SIMPLE_LINK_CMD} ${COMPILED_OBJECTS[*]}" + + # 添加所有SDK库目录到简化链接命令 + for dir in "${ALL_SDK_LIB_DIRS[@]}"; do + SIMPLE_LINK_CMD="${SIMPLE_LINK_CMD} -L${dir}" + done + + # 使用ss_mpi替代ot_mpi + SIMPLE_LINK_CMD="${SIMPLE_LINK_CMD} -lsecurec -lot_osal -lss_mpi" + SIMPLE_LINK_CMD="${SIMPLE_LINK_CMD} -lpthread -lm -lstdc++ -ldl" + SIMPLE_LINK_CMD="${SIMPLE_LINK_CMD} -Wl,--allow-shlib-undefined" + SIMPLE_LINK_CMD="${SIMPLE_LINK_CMD} -Wl,-allow-multiple-definition" + SIMPLE_LINK_CMD="${SIMPLE_LINK_CMD} -Wl,-z,notext" + + echo "执行简化链接命令:" + echo "${SIMPLE_LINK_CMD}" + eval "${SIMPLE_LINK_CMD}" + + if [ $? -ne 0 ]; then + echo "✗ 动态库创建失败" + echo "建议尝试重新编译common目录下的目标文件,添加-fPIC选项:" + echo "cd ${HISI_COMMON_DIR}" + echo "${CC} -c -fPIC *.c -I${HISI_MPP_BASE}/include -I${HISI_SDK_BASE}/include" + exit 1 + fi +fi + +echo "✓ 海思SDK初始化动态库创建完成!" + +if [ -f "${SDK_LIB_DIR}/libhisi_sdk_init.so" ]; then + echo "✓ 动态库文件存在" + ls -la "${SDK_LIB_DIR}/libhisi_sdk_init.so" + + # 检查符号 + echo "" + echo "检查关键符号:" + REQUIRED_SYMBOLS=("SDK_init" "SDK_exit") + for symbol in "${REQUIRED_SYMBOLS[@]}"; do + if ${CROSS_PREFIX}-nm -D "${SDK_LIB_DIR}/libhisi_sdk_init.so" 2>/dev/null | grep -q "$symbol" || \ + ${CROSS_PREFIX}-objdump -T "${SDK_LIB_DIR}/libhisi_sdk_init.so" 2>/dev/null | grep -q "$symbol"; then + echo "✓ 符号 $symbol 存在" + else + echo "⚠ 符号 $symbol 可能缺失" + fi + done + +else + echo "✗ 动态库文件不存在" + exit 1 +fi + +# 设置编译标志,添加-fPIC +CFLAGS="--sysroot=$SYSROOT -fPIC" +CFLAGS="${CFLAGS} -I${HISI_COMMON_DIR}" # 添加common目录的头文件路径 +CFLAGS="${CFLAGS} -I${HISI_MPP_BASE}/out/include" +CFLAGS="${CFLAGS} -DHISI_SDK_ENABLED" +export CFLAGS + +# 设置C++编译标志,添加-fPIC +export CXXFLAGS="--sysroot=$SYSROOT -fPIC" + +# 设置链接标志 +LDFLAGS="--sysroot=$SYSROOT" +LDFLAGS="${LDFLAGS} -L${SDK_LIB_DIR}" + +# 添加所有SDK库目录到链接标志(包括common目录) +for dir in "${ALL_SDK_LIB_DIRS[@]}"; do + LDFLAGS="${LDFLAGS} -L${dir}" +done + +# 设置运行时库搜索路径 +LDFLAGS="${LDFLAGS} -Wl,--allow-shlib-undefined" +LDFLAGS="${LDFLAGS} -Wl,-allow-multiple-definition" + +# 链接库 +LDFLAGS="${LDFLAGS} -lhisi_sdk_init" +LDFLAGS="${LDFLAGS} ${LINK_LIBS}" +LDFLAGS="${LDFLAGS} -lpthread -lm -lstdc++ -ldl -lrt" +export LDFLAGS + +#echo "CFLAGS: ${CFLAGS}" +#echo "LDFLAGS: ${LDFLAGS}" + +# 构建configure命令 +function gen_cfg_cmd() { + printf "%s " \ + "${FFMPEG_SRC}/configure" \ + "--prefix=$PREFIX" \ + "--arch=aarch64" \ + "--target-os=linux" \ + "--enable-cross-compile" \ + "--disable-x86asm" \ + "--disable-static" \ + "--enable-shared" \ + "--cc=$CC" \ + "--cxx=$CXX" \ + "--strip=$STRIP" \ + "--ld=$CXX" \ + "--sysroot=$SYSROOT" \ + "--enable-libx264" \ + "--enable-libx265" \ + "--enable-gpl" \ + "--enable-encoder=h264_ss928" \ + "--enable-encoder=h265_ss928" \ + "--enable-encoder=mjpeg_ss928" \ + "--enable-decoder=h264_ss928" \ + "--enable-decoder=h265_ss928" \ + "--enable-decoder=mjpeg_ss928" \ + "--extra-cflags='$CFLAGS'" \ + "--extra-ldflags='$LDFLAGS'" + echo +} + +# 执行configure +echo "==========================================" +echo "开始配置FFmpeg..." +echo "==========================================" +cfg_cmd=$(gen_cfg_cmd) +echo "$cfg_cmd" +echo "==========================================" +eval "$cfg_cmd" +``` + +### 步骤4:编译ffmpeg + +* 在服务器的命令行,执行下面的命令,进行编译ffmpeg前的配置 + +```sh +chmod +x build_ffmpeg.sh + +./build_ffmpeg.sh +``` + +![image-20251022151107143](pic/image-20251022151107143.png) + +* 在服务器的命令行,执行下面的命令,进行ffmpeg的编译 + +```sh +make -j$(nproc) && make install +``` + +![image-20251022151357987](pic/image-20251022151357987.png) + +* 编译完成之后,会在install目录下生成下面的内容 + +![image-20251022151320279](pic/image-20251022151320279.png) + +* 并且在ffmpeg目录下生成一个hisi_sdk_lib的文件夹,里面有一个libhisi_sdk_init.so库 + +![image-20251022151540301](pic/image-20251022151540301.png) + +### 步骤5:编译sample + +* 在服务器的命令行,执行下面的命令,分别编译ffmpeg和hisi目录下的编解码案例 + +```sh +cd sample/ffmpeg + +make + +cd ../hisi + +make +``` + +![image-20251022155440903](pic/image-20251022155440903.png) + +![image-20251022155422517](pic/image-20251022155422517.png) + + + +## 4、板端验证 + +### 步骤1:配置板端环境 + +* 1、确保开发板已经烧录OpenHarmony操作系统 +* 2、使用网线将开发板与你的电脑进行连接,确保二者处于同一局域网内 +* 3、配置开发板的IP地址,并确保开发板与电脑能够互相ping通 + +```sh +# 注意:这里的eth0的IP地址,请根据自己的网络IP网段进行合理配置 +ifconfig eth0 192.168.100.100 + +# 添加权限 +echo 0 9999999 > /proc/sys/net/ipv4/ping_group_range +``` + +![image-20251010094441549](pic/image-20251010094441549.png) + +### 步骤2:准备ffmpeg依赖文件 + +* 1、将第2章交叉编译生成的v4l2、x264、x265的install目录,下载并拷贝到NFS挂载目录 +* 2、将第三章交叉编译ffmpeg生成的install目录,下载并拷贝到NFS挂载目录 +* 3、将第三章步骤5,编译好后的sample目录,下载并拷贝到NFS挂载目录 +* 4、将libhisi_sdk_init.so下载并拷贝到ffmpeg_install/lib/目录下 +* 5、将mpp/out/lib下载并拷贝到NFS挂载目录 + +![image-20251022162128690](pic/image-20251022162128690.png) + +![image-20251022164347161](pic/image-20251022164347161.png) + +* 6、在开发板的命令行终端执行下面的命令,将电脑的nfs目录挂载到开发板的/mnt目录下(注意:这里请根据自己的IP地址及NFS配置进行合理的修改) + +```sh +mount -o nolock,addr=192.168.100.10 -t nfs 192.168.100.10:/d/nfs /mnt +``` + +![image-20251022162847658](pic/image-20251022162847658.png) + +* 因为我这里对每个库进行了打包,所以当我们把NFS挂载上后,需要对这些库进行解压才能正常使用 + +![image-20251022163123950](pic/image-20251022163123950.png) + +* 7、在开发板的命令行终端执行下面的命令,配置各个库的环境变量 + +```sh +export PATH=/mnt/ffmpeg/ffmpeg_install/bin:$PATH +export LD_LIBRARY_PATH=/mnt/ffmpeg/ffmpeg_install/lib:/mnt/ffmpeg/lib:/mnt/ffmpeg/lib/svp_npu:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=/mnt/ffmpeg/v4l2_install/lib:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=/mnt/ffmpeg/x264_install/lib:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=/mnt/ffmpeg/x265_install/lib:$LD_LIBRARY_PATH + +chmod +x /mnt/ffmpeg/ffmpeg_install/bin/* +``` + +![image-20251022163146923](pic/image-20251022163146923.png) + +### 步骤3:测试ffmpeg是否正常工作 + +* 在开发板的命令行,执行下面的命令,获取ffmpeg的版本号 + +```sh +cd /mnt/ffmpeg/ffmpeg_install/bin/ + +ffmpeg -version +``` + +image-20251022170611820 + +### 步骤4:测试sample案例 + +* 注意:sample/hisi/目录下的是调用了海思硬件编解码模块,实现了硬件加速。sample/ffmpeg/目录下就是调用了ffmpeg的原始编解码接口。 +* 在开发板的命令行终端执行下面的命令,运行相关程序 + +```sh +cd /mnt/ffmpeg/sample/hisi + +chmod +x * + +# hisi编码 +./hisi_264venc /dev/video0 h264_ss928 640 480 30 + +cd /mnt/ffmpeg/sample/ffmpeg + +chmod +x * +# ffmpeg编码 +./264enc /dev/video0 640 480 30 +``` + +![image-20251022175239062](pic/image-20251022175239062.png) + +![image-20251022175457018](pic/image-20251022175457018.png) + +* 在开发板的命令行分步执行下面的命令,测试解码案例 + +```sh +cd /mnt/ffmpeg/sample/hisi + +# hisi解码 +./hisi_264vdec h264_ss928_output.h264 output + +# ffmpeg解码 +./264dec libx264_output.h264 output +``` + +![image-20251022175651926](pic/image-20251022175651926.png) + +![image-20251022175749466](pic/image-20251022175749466.png) + +* 如果想在自己的代码中使用ffmpeg调用hisi的硬件编解码模块,可以使用avcodec_find_decoder_by_name接口来实现 + +```c +avcodec_find_decoder_by_name("h264ss928"); + +avcodec_find_decoder_by_name("h265_ss928"); + +avcodec_find_decoder_by_name("mjpeg_ss928"); + +avcodec_find_encoder_by_name("h264_ss928"); + +avcodec_find_encoder_by_name("h265_ss928"); + +avcodec_find_encoder_by_name("mjpeg_ss928"); +``` + +## 5、海思硬件编解码与ffmpeg原生编解码对比 + +* decoder + +| 数据/解码器 | h264 | h264_ss928 | hevc | h265_ss928 | mjpeg | mjpeg_ss928 | +| ------------------- | --------------------- | --------------------- | --------------------- | --------------------- | --------------------- | --------------------- | +| 视频参数 | 1920x1080
@30FPS | 1920x1080
@30FPS | 1920x1080
@30FPS | 1920x1080
@30FPS | 1920x1080
@30FPS | 1920x1080
@30FPS | +| 总处理帧数 | 85 | 207 | 21 | 221 | 125 | 217 | +| 总解码时间(ms) | 4547.785 | 8592.903 | 4566.406 | 9147.614 | 3020.907 | 93398.829 | +| 总发送时间(ms) | | | 4566.203 | 8168.024(89.3%) | | 9007.92 | +| 总接收时间(ms) | | | 0.203 | 1004.696(10.7%) | | 335.712 | +| 平均解码时间(ms/帧) | 53.503 | 41.512 | 217.448 | 41.401 | 20.167 | 43.036 | +| 平均发送时间(ms/帧) | | | 217.438 | 36.959 | | | +| 平均接收时间(ms/帧) | | | 0.01 | 4.546 | | | +| 最短解码时间(ms) | 0.036 | 40.653 | 191.937 | 40.699 | 22.408 | 40.909 | +| 最长解码时间(ms) | 74.43 | 42.67 | 307.397 | 44.188 | 26.027 | 83.292 | +| 时间差值(ms) | 12.534 | | 115.46 | 3.489 | 3.599 | 42.383 | +| 解码帧率(FPS) | 18.69 | 24.09 | 4.6 | 24.15 | 41.38 | 23.24 | +| 每秒处理像素(MP/s) | | | 9.54 | 50.09 | 19.09 | 12.52 | + +* encoder + +| 数据/编码器 | libx264 | h264_ss928 | libx265 | h265_ss928 | mjpeg | mjpeg_ss928 | +| ----------------------------- | ------------------------ | --------------------- | --------------------- | --------------------- | --------------------- | --------------------- | +| 视频参数 | 1920x1080
@30FPS | 1920x1080
@30FPS | 1920x1080
@30FPS | 1920x1080
@30FPS | 1920x1080
@30FPS | 1920x1080
@30FPS | +| 总处理帧数 | 85 | 208 | 21 | 222 | 114 | 218 | +| 总耗时(s) | 30.45 | 14.05 | 41.62 | 15.56 | 16.36 | 15.1 | +| 平均FPS | 11.19 | 14.8 | 0.5 | 14.27 | 6.97 | 14.44 | +| 平均格式转换时间(ms/帧) | 3 | 65.22 | 11.52 | 66.91 | 51.11 | 66.17 | +| 平均编码时间(ms/帧) | 342.35 | 2.25 | 1957.39 | 3.07 | 89.4 | 2.99 | +| 编码效率(编码时间/理论帧间隔) | 1027.05% | 6.74% | 5872.18% | 9.20% | 268.21% | 8.97% | +| 总编码时间(s) | 29.01 | 0.47 | 41.11 | 0.68 | 10.19 | 0.65 | +| 总转换时间(s) | 0.95 | 13.57 | 0.24 | 14.85 | 5.83 | 14.43 | +| 输出文件大小(MB) | 1.26 | | 0.32 | 13.28 | 17.44 | 11.86 | +| 压缩比 | 39.29:1 | | 192.04:1 | 49.60:1 | 19.39:1 | 54.52:1 | +| 平均码率(kbps) | 347.13 | | 65.39 | 7158.57 | 8941.11 | 6589.71 | +| 性能评级 | 极高压缩率,编码需要优化 | 编码优秀 | 压缩良好,编码不足 | 编码优秀 | 需优化 | 优秀 | diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20250915232849-tjfqh3n.png b/vendor/zsks/docs/ffmpeg/pic/image-20250915232849-tjfqh3n.png new file mode 100644 index 0000000000000000000000000000000000000000..21fda5fcf1869c2dcf558d468c9a2f86398af70f Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20250915232849-tjfqh3n.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20250915232913-7et18x6.png b/vendor/zsks/docs/ffmpeg/pic/image-20250915232913-7et18x6.png new file mode 100644 index 0000000000000000000000000000000000000000..fde025e7a494293a9f3e8bf900e3d1f3119a89e8 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20250915232913-7et18x6.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20250915232951-jif09al.png b/vendor/zsks/docs/ffmpeg/pic/image-20250915232951-jif09al.png new file mode 100644 index 0000000000000000000000000000000000000000..31c380ac27cdb37a5e5c579297fb07dac19fd32c Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20250915232951-jif09al.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20250915233247-0qbuniv.png b/vendor/zsks/docs/ffmpeg/pic/image-20250915233247-0qbuniv.png new file mode 100644 index 0000000000000000000000000000000000000000..1e2554a359f21877ef8c2c0ddf477e75b2c31e05 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20250915233247-0qbuniv.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251010094441549.png b/vendor/zsks/docs/ffmpeg/pic/image-20251010094441549.png new file mode 100755 index 0000000000000000000000000000000000000000..e981001ec636db595d2766310bf95a49e58f3914 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251010094441549.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251021144741884.png b/vendor/zsks/docs/ffmpeg/pic/image-20251021144741884.png new file mode 100755 index 0000000000000000000000000000000000000000..e481421c729bc4011b4cad2cf22518be016f4260 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251021144741884.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251021150217681.png b/vendor/zsks/docs/ffmpeg/pic/image-20251021150217681.png new file mode 100755 index 0000000000000000000000000000000000000000..b1256530ef6e2b2bd83736558601545ff8b6c0b7 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251021150217681.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251021154212147.png b/vendor/zsks/docs/ffmpeg/pic/image-20251021154212147.png new file mode 100755 index 0000000000000000000000000000000000000000..595e9639aa561f56eb2dd4155a6f69f19a91e910 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251021154212147.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251021154533551.png b/vendor/zsks/docs/ffmpeg/pic/image-20251021154533551.png new file mode 100755 index 0000000000000000000000000000000000000000..b106a565c5e18e058c6d57a7aaba66d57220f0e4 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251021154533551.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251021154614257.png b/vendor/zsks/docs/ffmpeg/pic/image-20251021154614257.png new file mode 100755 index 0000000000000000000000000000000000000000..ce0236fa509a1f00ee893369cc026769520406ae Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251021154614257.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251021161044799.png b/vendor/zsks/docs/ffmpeg/pic/image-20251021161044799.png new file mode 100755 index 0000000000000000000000000000000000000000..7a84e2650c691eeaf3e0da8fbaed35592e172075 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251021161044799.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251021161134241.png b/vendor/zsks/docs/ffmpeg/pic/image-20251021161134241.png new file mode 100755 index 0000000000000000000000000000000000000000..16158c56b5ff0f57bac2ae30a4eaca37e25e17f9 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251021161134241.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251021161216433.png b/vendor/zsks/docs/ffmpeg/pic/image-20251021161216433.png new file mode 100755 index 0000000000000000000000000000000000000000..a3739b57a6967609a503a01e901cb81957c8bfaf Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251021161216433.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251021205649485.png b/vendor/zsks/docs/ffmpeg/pic/image-20251021205649485.png new file mode 100755 index 0000000000000000000000000000000000000000..f5a12debb0aab543c5d0e327d1e10b1bee943dd9 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251021205649485.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251021205900311.png b/vendor/zsks/docs/ffmpeg/pic/image-20251021205900311.png new file mode 100755 index 0000000000000000000000000000000000000000..995d820967e8a942a065956d51b38d48757d76a3 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251021205900311.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022142837408.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022142837408.png new file mode 100755 index 0000000000000000000000000000000000000000..e249c0aede872c03525e5ac1992f16ce105f576d Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022142837408.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022150813007.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022150813007.png new file mode 100755 index 0000000000000000000000000000000000000000..4d631cb10f69e307842107f01212b973d4ed81b8 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022150813007.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022150910879.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022150910879.png new file mode 100755 index 0000000000000000000000000000000000000000..c7b729ea84e50b92fbe266a27a1c163aa2c5762f Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022150910879.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022151107143.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022151107143.png new file mode 100755 index 0000000000000000000000000000000000000000..eb5a5e8e0712b9e94a31929defb4765dd6ac08a6 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022151107143.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022151320279.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022151320279.png new file mode 100755 index 0000000000000000000000000000000000000000..a0af3d027c9e0b43333964a2706c3d449145f8aa Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022151320279.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022151357987.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022151357987.png new file mode 100755 index 0000000000000000000000000000000000000000..3492af0c2d6a9a740dcd9e822879e3579d6b44ac Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022151357987.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022151540301.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022151540301.png new file mode 100755 index 0000000000000000000000000000000000000000..f34bd883a0d5cd2637ba771560609ebe2d871195 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022151540301.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022155422517.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022155422517.png new file mode 100755 index 0000000000000000000000000000000000000000..e286666db8543a020f5f99b2857f8cca0f7ee2c4 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022155422517.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022155440903.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022155440903.png new file mode 100755 index 0000000000000000000000000000000000000000..6f579547291f2da2bb336c9e74e70abe82e9eb32 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022155440903.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022162128690.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022162128690.png new file mode 100755 index 0000000000000000000000000000000000000000..72f9513422d72a7141b187bd34f2e248b36e0a56 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022162128690.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022162847658.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022162847658.png new file mode 100755 index 0000000000000000000000000000000000000000..1213dd041032b7021581ae0c2d6d662a52e52ff0 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022162847658.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022163123950.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022163123950.png new file mode 100755 index 0000000000000000000000000000000000000000..cc97d736b87dd5d60d902df9b1c697259aa8566e Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022163123950.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022163146923.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022163146923.png new file mode 100755 index 0000000000000000000000000000000000000000..73349a81e9600c6b33e5e5945f8ccde92d30fb5f Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022163146923.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022164347161.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022164347161.png new file mode 100755 index 0000000000000000000000000000000000000000..c845bb9b545b91f51c6aa7509dfe695104a85d5c Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022164347161.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022170611820.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022170611820.png new file mode 100755 index 0000000000000000000000000000000000000000..f8bb1cb8216cf9d9081fc7e11bffaaa6329452cb Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022170611820.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022175239062.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022175239062.png new file mode 100755 index 0000000000000000000000000000000000000000..55d79571b64ab870c61a17e1ee9487cb635142e8 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022175239062.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022175457018.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022175457018.png new file mode 100755 index 0000000000000000000000000000000000000000..2206fcf88a1299ca6816af70637998036b59f4d0 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022175457018.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022175651926.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022175651926.png new file mode 100755 index 0000000000000000000000000000000000000000..740f3d30765246b6614355ac73dba47f8894e4e1 Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022175651926.png differ diff --git a/vendor/zsks/docs/ffmpeg/pic/image-20251022175749466.png b/vendor/zsks/docs/ffmpeg/pic/image-20251022175749466.png new file mode 100755 index 0000000000000000000000000000000000000000..98e0cdd447690c49b46e766bfac8db37741d051e Binary files /dev/null and b/vendor/zsks/docs/ffmpeg/pic/image-20251022175749466.png differ diff --git a/vendor/zsks/docs/libcamera/README.md b/vendor/zsks/docs/libcamera/README.md new file mode 100755 index 0000000000000000000000000000000000000000..832a7ce9d7f6f5e7409dcacbca1760e18b783b84 --- /dev/null +++ b/vendor/zsks/docs/libcamera/README.md @@ -0,0 +1,466 @@ +# libcamera移植 + +## 1、软硬件环境 +* 开发板:海鸥派 +* 交叉编译工具链:OHOS (dev) clang version 15.0.4 + +* 编译链路径:pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin +* Python版本:Python-3.13.2 +* 移植的libcamera版本:libcamera-0.5 + +## 2、配置python环境 + +* 步骤1:为了满足python3.13.2的移植要求,我们需要先把服务器的python版本改为3.13.2,且按照[Python的移植步骤](../python/README.md),把Python-3.13.2交叉编译好。 +* 步骤2:按照[numpy的移植文档](../numpy/README.md)第2节的步骤3,把虚拟环境创建好。 + +```sh +cd pegasus/vendor/opensource/Python-3.13.2 + +# 激活环境 +. crossenv_aarch64/bin/activate +``` + +![image-20251020160523558](pic/image-20251020160523558.png) + +## 3.安装依赖 + +* 由于在编译libacamera的时候,需要依赖其他第三方软件,因此在编译libacamera之前,我们先把它依赖的第三方软件全部交叉编译出来。 + +### 步骤1: 配置依赖的环境变量 + +* 在服务器的命令行执行下面的命令,配置交叉编译时依赖的环境变量。这里的绝对路径请根据自己服务器实际情况进行修改。 + +```sh +export CC=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang +export CXX=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang++ +export AR=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-ar +export LD=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/ld.lld +export RANLIB=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-ranlib +export STRIP=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-strip +``` + +### 步骤2:交叉编译依赖第三方软件 + +**注意:**在交叉编译之前,请一定确保OpenHarmony的代码下载完成,且整编通过,具体可参考[ohos编译](https://gitee.com/HiSpark/pegasus/blob/master/docs/OpenHarmony%20Small%E7%89%88%E6%9C%AC%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/OpenHarmony%20Small%E7%89%88%E6%9C%AC%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97.md#ohos%E7%BC%96%E8%AF%91)的内容 + +#### 1、libevent的交叉编译 + +* 在服务器的命令行执行下面的命令,下载源码,配置编译链 + +```sh +# 由于zlib也属于第三方软件,可以在opensource目录下进行移植 +cd pegasus/vendor/opensource/ + +wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz + +tar -xzvf libevent-2.1.12-stable.tar.gz +rm libevent-2.1.12-stable.tar.gz + +cd libevent-2.1.12-stable + +# 注意:这里的路径请根据自己的Pegasus目录进行修改 +export CC="/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang --sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot" +``` + +![image-20251020162138430](pic/image-20251020162138430.png) + +![image-20251020162307165](pic/image-20251020162307165.png) + +* 在服务器的命令行执行下面的命令,修改配置脚本和部分代码,确保编译时不会报错 + +```sh +sed -i 's/| -kaos\*/| -kaos\* | -ohos\*/g' ./build-aux/config.sub +sed -i 's/linux-uclibc\*/linux-uclibc\* | linux-ohos\*/g' ./build-aux/config.sub + +sed -i 's/arc4random_buf/libevent_arc4random_buf/g' ./arc4random.c +sed -i 's/arc4random_buf/libevent_arc4random_buf/g' evutil_rand.c +``` + +![image-20251020162427982](pic/image-20251020162427982.png) + +* 在服务器的命令行执行下面的命令,编译libevent + +```sh +./configure --prefix=$PWD/install --host=aarch64-linux-ohos --disable-openssl + +make && make install +``` + +![image-20251020162558010](pic/image-20251020162558010.png) + +![image-20251020162712286](pic/image-20251020162712286.png) + +* 编译成功后,会在install目录下生成以下文件 + +![image-20251020163215884](pic/image-20251020163215884.png) + +#### 2、tiff的交叉编译 + +* 在服务器的命令行执行下面的命令,进行openssl的交叉编译 + +```sh +cd ../ + +wget http://download.osgeo.org/libtiff/tiff-4.5.1.tar.gz + +tar -xzf tiff-4.5.1.tar.gz +rm tiff-4.5.1.tar.gz + +cd tiff-4.5.1 +``` + +![image-20251020163840912](pic/image-20251020163840912.png) + +* 在./config/config.sub文件中添加OHOS的编译依赖,确保编译时不会报错 + * 在1761行添加 | ohos* + * 在1782行添加 | linux-ohos* + +![image-20251020164239531](pic/image-20251020164239531.png) + +* 在服务器的命令行执行下面的命令,编译ttif + +```sh +./configure --prefix=$PWD/install --host=aarch64-linux-ohos --with-sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot CFLAGS="--sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot" CXXFLAGS="--sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot" + +make && make install +``` + +![image-20251020164718454](pic/image-20251020164718454.png) + +![image-20251020164811557](pic/image-20251020164811557.png) + +* 编译完成后,会在install目录下生成如下的文件 + +![image-20251020165144726](pic/image-20251020165144726.png) + +#### 3、jpeg-9d的交叉编译 + +* 在服务器的命令行执行下面的命令,进行libffi的交叉编译 + +```sh +cd ../ + +wget https://www.ijg.org/files/jpegsrc.v9d.tar.gz +tar -zxvf jpegsrc.v9d.tar.gz + +rm jpegsrc.v9d.tar.gz + +cd jpegsrc.v9d +``` + +![image-20251020165513929](pic/image-20251020165513929.png) + +* 在服务器的命令行执行下面的命令,修改配置脚本和部分代码,确保编译时不会报错 + +```sh +sed -i 's/| -kaos\*/| -kaos\* | -ohos\*/g' config.sub +sed -i 's/linux-uclibc\*/linux-uclibc\* | linux-ohos\*/g' config.sub +``` + +![image-20251020165626871](pic/image-20251020165626871.png) + +* 执行下面的命令,交叉编译jpeg-9d + + +```sh +export CC="/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang --sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot" + +./configure --prefix=$PWD/install --host=aarch64-linux-ohos + +make && make install +``` + +![image-20251020165719960](pic/image-20251020165719960.png) + +![image-20251020165802562](pic/image-20251020165802562.png) + +* 编译完成后,会在install目录下生成如下的文件 + +![image-20251020165955883](pic/image-20251020165955883.png) + +#### 2、openssl的交叉编译 + +* 在服务器的命令行执行下面的命令,进行openssl的交叉编译 + +```sh +cd ../ + +wget https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_1_1_1w.tar.gz + +tar -xvf OpenSSL_1_1_1w.tar.gz +rm OpenSSL_1_1_1w.tar.gz + +cd openssl-OpenSSL_1_1_1w + +perl Configure linux-aarch64 --prefix=$PWD/install + +make CC="/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang --sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot" LDFLAGS="--sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot -L/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot/usr/lib" + +make install +``` + +![image-20251009173438071](pic/image-20251009173438071.png) + +![image-20251009173659012](pic/image-20251009173659012.png) + +![image-20251009174036856](pic/image-20251009174036856.png) + +![image-20251009174105488](pic/image-20251009174105488.png) + +### 步骤3:安装依赖软件 + +* 在服务器的命令行执行下面的命令,安装依赖软件 + +```sh +apt-get install ninja-build libevent-dev libjpeg-dev + +# 使用apt下载的meson版本太低不符合要求 +pip3 install meson==1.6 jinja2 pyyaml ply pybind11 -i https://pypi.tuna.tsinghua.edu.cn/simple +``` + +![image-20251020170606044](pic/image-20251020170606044.png) + +## 4、交叉编译libcamera + +### 步骤1:下载源码 + +* 在服务器的命令行执行下面的命令,进行libcamera的交叉编译 + +```sh +cd ../ + +git clone https://git.libcamera.org/libcamera/libcamera.git + +cd libcamera +``` + +![image-20251020172340245](pic/image-20251020172340245.png) + +### 步骤2:配置编译环境 + +* 在libcamera目录下创建一个cross_file.txt文件,然后把下面的内容复制进去。 +* 注意:下面内容中涉及到绝对路径的地方,请根据自己服务器的实际情况进行修改 + +```sh +[binaries] +c = '/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang' +cpp = '/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang++' +ar = '/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-ar' +strip = '/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-strip' +pkg-config = '/usr/bin/pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'aarch64' +endian = 'little' + +[properties] +sys_root = '/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot' +libdir = '/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot/usr/lib' +includedir = '/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot/usr/include' + +[built-in options] +c_args = ['--sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot', '-isystem', '/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot/usr/include'] +cpp_args = ['--sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot', '-isystem', '/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/include/libcxx-ohos/include/c++/v1', '-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER', '-std=c++17', '-I/home/openharmony/pegasus/vendor/opensource/tiff-4.5.1/install/include', '-I/home/openharmony/pegasus/vendor/opensource/libevent-2.1.12-stable/install/include', '-I/home/openharmony/pegasus/vendor/opensource/openssl-OpenSSL_1_1_1w/install/include', '-I/home/openharmony/pegasus/vendor/opensource/jpeg-9d/install/include',] + +c_link_args = ['--sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot'] +cpp_link_args = ['--sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot', '-L/home/openharmony/pegasus/vendor/opensource/tiff-4.5.1/install/lib', '-L/home/openharmony/pegasus/vendor/opensource/libevent-2.1.12-stable/install/lib', '-L/home/openharmony/pegasus/vendor/opensource/openssl-OpenSSL_1_1_1w/install/lib', '-L/home/openharmony/pegasus/vendor/opensource/jpeg-9d/install/lib',] +``` + +* 结合第三章内容,配置依赖软件的环境变量。 +* 注意:下面内容中涉及到绝对路径的地方,请根据自己服务器的实际情况进行修改 + +```sh +export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/openharmony/pegasus/vendor/opensource/tiff-4.5.1/install/lib/pkgconfig:/home/openharmony/pegasus/vendor/opensource/libevent-2.1.12-stable/install/lib/pkgconfig:/home/openharmony/pegasus/vendor/opensource/openssl-OpenSSL_1_1_1w/install/lib/pkgconfig:/home/openharmony/pegasus/vendor/opensource/jpeg-9d/install/lib/pkgconfig +``` + +### 步骤3:修改代码 + +* /home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot/usr/include/aarch64-linux-ohos/linux/videodev2.h 文件中内容,如图所示,在文件的71行下添加14和15两个参数: + +```c + V4L2_BUF_TYPE_META_OUTPUT = 14, + V4L2_CAP_META_OUTPUT = 15, +``` + +![image-20251021093857925](pic/image-20251021093857925.png) + +* 修改libcamera/src/libcamera/process.cpp,在152行处添加下面内容。 + +```c +struct clone_args { + uint64_t flags; /* Flags bit mask */ + uint64_t pidfd; /* Where to store PID file descriptor*/ + uint64_t child_tid; /* Where to store child TID */ + uint64_t parent_tid; /* Where to store child TID */ + uint64_t exit_signal; /* Signal to deliver to parent on child termination */ + uint64_t stack; /* Pointer to lowest byte of stack */ + uint64_t stack_size; /* Size of stack */ + uint64_t tls; /* Location of new TLS */ +}; +``` + +![image-20251021110807481](pic/image-20251021110807481.png) + +### 步骤4:编译源码 + +* 执行下面的命令,使用meson进行编译前的配置 + +```sh +meson setup \ + --cross-file cross_file.txt \ + --prefix=$(pwd)/install \ + -Dcam=enabled \ + -Ddocumentation=disabled \ + -Dpycamera=enabled \ + build . 2>&1 | tee meson_output.log +``` + +![image-20251021094913442](pic/image-20251021094913442.png) + +* 执行下面的命令,进行源码的编译 + +```sh +cd build + +ninja +``` + +![image-20251021110457253](pic/image-20251021110457253.png) + +### 步骤5:修改报错 + +* 如果在编译的时候出现下面的错误 + +![image-20251021105919871](pic/image-20251021105919871.png) + +* 需要修改两个位置的代码 +* 在libcamera/subprojects/libpisp/src/helpers/media_device.cpp 文件的第行,添加一个头文件 #include + +![image-20251021110324282](pic/image-20251021110324282.png) + +* 在libcamera/subprojects/libpisp/src/helpers/v4l2_device.cpp文件的24~30行,添加下面的内容 + +```c +#ifndef V4L2_PIX_FMT_RGBX32 +#define V4L2_PIX_FMT_RGBX32 v4l2_fourcc('R', 'G', 'B', 'X') +#endif + +#ifndef V4L2_PIX_FMT_BGRX32 +#define V4L2_PIX_FMT_BGRX32 v4l2_fourcc('B', 'G', 'R', 'X') +#endif +``` + +![image-20251021110201136](pic/image-20251021110201136.png) + +* 然后删掉build目录,重新执行下面的命令,编译源码 + +```sh +cd /home/openharmony/pegasus/vendor/opensource/libcamera + +rm build + +meson setup \ + --cross-file cross_file.txt \ + --prefix=$(pwd)/install \ + -Dcam=enabled \ + -Ddocumentation=disabled \ + -Dpycamera=disabled \ + build . 2>&1 | tee meson_output.log + +ninja -C build +ninja -C build install + +cd build + +ninja + +ninja install +``` + +![image-20251021111005830](pic/image-20251021111005830.png) + +* 编译成功后,会在libcamera的install目录生成如下内容 + +![image-20251021111051030](pic/image-20251021111051030.png) + +## 5.板端测试 + +### 步骤1:配置板端环境 + +* 1、确保开发板已经烧录OpenHarmony操作系统 +* 2、使用网线将开发板与你的电脑进行连接,确保二者处于同一局域网内 +* 3、配置开发板的IP地址,并确保开发板与电脑能够互相ping通 + +```sh +# 注意:这里的eth0的IP地址,请根据自己的网络IP网段进行合理配置 +ifconfig eth0 192.168.100.100 + +# 添加权限 +echo 0 9999999 > /proc/sys/net/ipv4/ping_group_range +``` + +### 步骤2:准备libacamera依赖文件 + +* 1、将第4章交叉编译libcamera后,生成的install文件夹拷贝到你的NFS挂载目录(这里把install重命名为libcamera_install) +* 2、将第3章步骤2交叉编译的依赖软件中的libevent\_pthreads-2.1.so.7、libevent-2.1.so.7、libcrypto.so.1.1、libtiff.so.6都下载下来,并复制到libcamera_install的lib目录下 +* 3、如果你想使用Python调用libcamera的接口,需要把libcamera_install/lib/python3.13/site-packages中的 libcamera复制到Python的install/lib/python3.13/site-packages目录下,具体可参考[Python的移植文档](../python/README.md)。 +* 4、将下的这些库都复制到Python的install/lib/python3.13/lib-dynload目录下 + +![image-20251021112836269](pic/image-20251021112836269.png) + +* 5、在开发板的命令行执行下面的命令,将电脑的nfs目录挂载到开发板的/mnt目录下(注意:这里请根据自己的IP地址及NFS配置进行合理的修改) + +```sh +mount -o nolock,addr=192.168.100.10 -t nfs 192.168.100.10:/d/nfs /mnt +``` + +* 6、在开发板的命令行执行下面的命令,配置python的环境变量,确保python运行时能够找到依赖 + +```sh +export PATH=/mnt/install/bin:$PATH +export PYTHONPATH=/mnt/install/lib/python3.13:$PYTHONPATH +export LD_LIBRARY_PATH=/mnt/install/lib/python3.13/lib-dynload:$LD_LIBRARY_PATH +``` + +* 7、在开发板的命令行执行下面的命令,配置libcamera的环境变量,确保libcamera运行时能够找到依赖 + +```sh +export PATH=/mnt/libcamera_install/bin:$PATH +export LD_LIBRARY_PATH=/mnt/libcamera_install/lib:$LD_LIBRARY_PATH +``` + +### 步骤3:运行cam工具 + +* 在开发板的命令行执行下面的命令,给cam添加可执行权限 + +```sh +chmod +x /mnt/libcamera_install/bin/* +``` + +* 运行 cam -c 1 -I 可以查看当前摄像机支持的分辨率和格式: + +![image-20251022111145401](pic/image-20251022111145401.png) + +* 拉取图片: + + ```sh + # 可以通过cam参数 -s 设置图片分辨率、图片格式等等: + cam -c 1 --capture=10 --file=1.jpg + ``` + + ![image-20251022111205861](pic/image-20251022111205861.png) + +* 拉取视频流:(10帧,分辨率1920x1080,格式为YUYV) + + ```sh + cam -c 1 -C10 -s width=1920,height=1080,role=video,pixelformat=YUYV --file=/mnt/1.yuv + ``` + + ![image-20251022111249409](pic/image-20251022111249409.png) + + + + + diff --git a/vendor/zsks/docs/libcamera/pic/image-20251009173438071.png b/vendor/zsks/docs/libcamera/pic/image-20251009173438071.png new file mode 100755 index 0000000000000000000000000000000000000000..abd97d0442d4134130a4102c0bb5be8781218b64 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251009173438071.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251009173659012.png b/vendor/zsks/docs/libcamera/pic/image-20251009173659012.png new file mode 100755 index 0000000000000000000000000000000000000000..d3c95af0bdef74808f59af6922f3c0dd9bdffc26 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251009173659012.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251009174036856.png b/vendor/zsks/docs/libcamera/pic/image-20251009174036856.png new file mode 100755 index 0000000000000000000000000000000000000000..71cbbffc86935e2d55fcf0260092b5ccf46369ba Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251009174036856.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251009174105488.png b/vendor/zsks/docs/libcamera/pic/image-20251009174105488.png new file mode 100755 index 0000000000000000000000000000000000000000..1dca90f249e54c3ba3a54f64c14b8236de38642a Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251009174105488.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020160523558.png b/vendor/zsks/docs/libcamera/pic/image-20251020160523558.png new file mode 100755 index 0000000000000000000000000000000000000000..8378f1a983dd85346cdbcdccd9ed1cc9d847c39e Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020160523558.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020162138430.png b/vendor/zsks/docs/libcamera/pic/image-20251020162138430.png new file mode 100755 index 0000000000000000000000000000000000000000..0050be6b1455dc457f2932004469736148a024b6 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020162138430.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020162307165.png b/vendor/zsks/docs/libcamera/pic/image-20251020162307165.png new file mode 100755 index 0000000000000000000000000000000000000000..73247e11f11e955079b6f473a2c0c9fa0955ee2f Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020162307165.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020162427982.png b/vendor/zsks/docs/libcamera/pic/image-20251020162427982.png new file mode 100755 index 0000000000000000000000000000000000000000..b34ac6ba4f2da8f5aa9160f7a3bc5a36e9fb1791 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020162427982.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020162558010.png b/vendor/zsks/docs/libcamera/pic/image-20251020162558010.png new file mode 100755 index 0000000000000000000000000000000000000000..d29fdb0ae0da169210c3db01af1026ea906c94e8 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020162558010.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020162712286.png b/vendor/zsks/docs/libcamera/pic/image-20251020162712286.png new file mode 100755 index 0000000000000000000000000000000000000000..bf625e27b3dbc7b523d15ec8e6e494e11617dc78 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020162712286.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020163215884.png b/vendor/zsks/docs/libcamera/pic/image-20251020163215884.png new file mode 100755 index 0000000000000000000000000000000000000000..a49d19cd1f2708d12aa72b85642f12804135e08a Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020163215884.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020163840912.png b/vendor/zsks/docs/libcamera/pic/image-20251020163840912.png new file mode 100755 index 0000000000000000000000000000000000000000..da32bad41287013834a96c2353b46e0c32a0995f Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020163840912.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020164239531.png b/vendor/zsks/docs/libcamera/pic/image-20251020164239531.png new file mode 100755 index 0000000000000000000000000000000000000000..3a63648e1dd0ee35169fb98f13c90cdbd32e80ee Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020164239531.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020164718454.png b/vendor/zsks/docs/libcamera/pic/image-20251020164718454.png new file mode 100755 index 0000000000000000000000000000000000000000..30f4bf59e56a131a2d261c0344830625ed73c9c8 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020164718454.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020164811557.png b/vendor/zsks/docs/libcamera/pic/image-20251020164811557.png new file mode 100755 index 0000000000000000000000000000000000000000..c9b7c315a17421158dda8ae7d5081895c54793f1 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020164811557.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020165144726.png b/vendor/zsks/docs/libcamera/pic/image-20251020165144726.png new file mode 100755 index 0000000000000000000000000000000000000000..668bb41f23e474c4be978ef3d86b40dea06150d9 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020165144726.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020165513929.png b/vendor/zsks/docs/libcamera/pic/image-20251020165513929.png new file mode 100755 index 0000000000000000000000000000000000000000..d75be917e4a0cb09677fd4377a1ee0869192d181 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020165513929.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020165626871.png b/vendor/zsks/docs/libcamera/pic/image-20251020165626871.png new file mode 100755 index 0000000000000000000000000000000000000000..7722c8825608d4ebb526f249239ba4a8a77d874b Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020165626871.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020165719960.png b/vendor/zsks/docs/libcamera/pic/image-20251020165719960.png new file mode 100755 index 0000000000000000000000000000000000000000..e0aafce1e2f46463854812033695d833a69b51b9 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020165719960.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020165802562.png b/vendor/zsks/docs/libcamera/pic/image-20251020165802562.png new file mode 100755 index 0000000000000000000000000000000000000000..fc7098ed0fc3c16f9d63858f4e0212c20476e9fc Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020165802562.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020165955883.png b/vendor/zsks/docs/libcamera/pic/image-20251020165955883.png new file mode 100755 index 0000000000000000000000000000000000000000..fc20fcfb1db598b41190b01818e912e9d3574d5c Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020165955883.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020170606044.png b/vendor/zsks/docs/libcamera/pic/image-20251020170606044.png new file mode 100755 index 0000000000000000000000000000000000000000..3dbd9fd102246666f83409ca8ba17c3950174831 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020170606044.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251020172340245.png b/vendor/zsks/docs/libcamera/pic/image-20251020172340245.png new file mode 100755 index 0000000000000000000000000000000000000000..11e3393352686482431e1daf743a506f95536931 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251020172340245.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251021093857925.png b/vendor/zsks/docs/libcamera/pic/image-20251021093857925.png new file mode 100755 index 0000000000000000000000000000000000000000..9de66c7aa73004601b9e954737571de19f40f913 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251021093857925.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251021094913442.png b/vendor/zsks/docs/libcamera/pic/image-20251021094913442.png new file mode 100755 index 0000000000000000000000000000000000000000..7029a695cc1b2b9a4e7f180f534e8506fa1a62e3 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251021094913442.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251021105919871.png b/vendor/zsks/docs/libcamera/pic/image-20251021105919871.png new file mode 100755 index 0000000000000000000000000000000000000000..6048787f578fa0534a0c728261b06812c4bdb0de Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251021105919871.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251021110201136.png b/vendor/zsks/docs/libcamera/pic/image-20251021110201136.png new file mode 100755 index 0000000000000000000000000000000000000000..0de72baccd3d30ae318b0415d01b4215410d4a64 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251021110201136.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251021110324282.png b/vendor/zsks/docs/libcamera/pic/image-20251021110324282.png new file mode 100755 index 0000000000000000000000000000000000000000..e634d648146fadff8aa1858cb395fd1e6eb20c84 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251021110324282.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251021110457253.png b/vendor/zsks/docs/libcamera/pic/image-20251021110457253.png new file mode 100755 index 0000000000000000000000000000000000000000..d2d6b7589918136834962f0e4c2abe5aed02b481 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251021110457253.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251021110807481.png b/vendor/zsks/docs/libcamera/pic/image-20251021110807481.png new file mode 100755 index 0000000000000000000000000000000000000000..fb9fc5d06865ca44cfe44716f462add1532a3b33 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251021110807481.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251021111005830.png b/vendor/zsks/docs/libcamera/pic/image-20251021111005830.png new file mode 100755 index 0000000000000000000000000000000000000000..0f58a54ac11af46742b5abd2afcd2e6b7551cbe0 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251021111005830.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251021111051030.png b/vendor/zsks/docs/libcamera/pic/image-20251021111051030.png new file mode 100755 index 0000000000000000000000000000000000000000..bd03361a2062a1d81b46ca530ff298ff8b79b665 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251021111051030.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251021112836269.png b/vendor/zsks/docs/libcamera/pic/image-20251021112836269.png new file mode 100755 index 0000000000000000000000000000000000000000..8e9f97abb2e6c1a4809d6cdf61f00c9473bb679b Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251021112836269.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251022111145401.png b/vendor/zsks/docs/libcamera/pic/image-20251022111145401.png new file mode 100755 index 0000000000000000000000000000000000000000..2bba43c28bdd4923ec9ed5fd596cea810817474f Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251022111145401.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251022111205861.png b/vendor/zsks/docs/libcamera/pic/image-20251022111205861.png new file mode 100755 index 0000000000000000000000000000000000000000..6bc3ea024acc72a132d886c57a5b5289e604ab01 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251022111205861.png differ diff --git a/vendor/zsks/docs/libcamera/pic/image-20251022111249409.png b/vendor/zsks/docs/libcamera/pic/image-20251022111249409.png new file mode 100755 index 0000000000000000000000000000000000000000..bb7b51611cfa2a8a4a3326c7f6b3cf8c27977b87 Binary files /dev/null and b/vendor/zsks/docs/libcamera/pic/image-20251022111249409.png differ diff --git a/vendor/zsks/docs/libv4l2/README.md b/vendor/zsks/docs/libv4l2/README.md new file mode 100644 index 0000000000000000000000000000000000000000..22e4030a1c54f0277d67518f084b94571c228026 --- /dev/null +++ b/vendor/zsks/docs/libv4l2/README.md @@ -0,0 +1,441 @@ +# libv4l2移植 + +## 1、软硬件环境 + +* 开发板:海鸥派 +* 交叉编译工具链:OHOS (dev) clang version 15.0.4 +* 编译链路径:pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin +* python版本:Python-3.13.2 +* 移植的libv4l2版本:OpenCV-4.13 + +## 2、交叉编译libv4l2 + +### 步骤1:获取源码 + +* 在服务器的命令行,分步执行下面的命令,下载v4l-utils源码 + +~~~bash +git clone https://git.linuxtv.org/v4l-utils.git + +cd v4l-utils +~~~ + +### 步骤2:创建交叉编译配置文件 + +[constants] +toolchain = '/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin' +sysroot = '/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot' + +* 在v4l-utils目录下创建一个hisi-cross.txt文件,把下面的内容复制进去并保存。 + +~~~bash +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'aarch64' +endian = 'little' + +[binaries] +c = '/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang' +cpp = '/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang++' +ar = '/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-ar' +ranlib = '/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-ranlib' +strip = '/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-strip' +pkg-config = '/usr/bin/pkg-config' + +[properties] +sysroot = '/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot' +c_args = ['--sysroot=' + sysroot, '--target=aarch64-linux-ohos', '-I' + sysroot + '/usr/include'] +c_link_args = ['--sysroot=' + sysroot, '--target=aarch64-linux-ohos', '-fuse-ld=lld', '-L' + sysroot + '/usr/lib/aarch64-linux-ohos', '-L' + sysroot + '/lib', '-lc'] +~~~ + +### 步骤3.加载配置并生成构建文件 + +#### argp库交叉编译 + +* 在服务器的命令行分步执行下面的命令,下载argp源码 + +```sh +#获取源码 +wget https://www.lysator.liu.se/~nisse/misc/argp-standalone-1.3.tar.gz +tar xf argp-standalone-1.3.tar.gz +rm argp-standalone-1.3.tar.gz +cd argp-standalone-1.3 +``` + +![image-20251017153708743](pic/image-20251017153708743.png) + +* 在服务器的命令行分步执行下面的命令,配置环境变量 + +```sh +#配置变量 +export SYSROOT=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot +export CC=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang +export CXX=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang++ +export AR=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-ar +export RANLIB=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-ranlib +export CFLAGS="--sysroot=$SYSROOT" +export CXXFLAGS="--sysroot=$SYSROOT" +export LDFLAGS="--sysroot=$SYSROOT" +``` + +![image-20251017154000326](pic/image-20251017154000326.png) + +* 在服务器的命令行分步执行下面的命令,对argp代码进行编译 + +~~~bash +#配置文件 +./configure \ + --host=aarch64-linux-ohos \ + --prefix=$SYSROOT/usr \ + --disable-shared \ + --enable-static + +#编译安装 +make -j$(nproc) && make install +~~~ + +![image-20251017154359756](pic/image-20251017154359756.png) + +![image-20251017154546402](pic/image-20251017154546402.png) + +* 在服务器的命令行分步执行下面的命令,复制argp.h和libargp.a到sysroot对应目录下 + +~~~bash +# 复制头文件 argp.h 到 sysroot 的 include 目录 +cp ./argp.h $SYSROOT/usr/include/ + +# 复制静态库 libargp.a 到 sysroot 的 lib 目录 +cp ./libargp.a $SYSROOT/usr/lib/ + +# 确保文件权限正确 +chmod 644 $SYSROOT/usr/include/argp.h +chmod 644 $SYSROOT/usr/lib/libargp.a +~~~ + +![image-20251017154814146](pic/image-20251017154814146.png) + +### 步骤4:meson构建 + +* 在服务器的命令行执行下面的命令,进行meson的构建。 +* 注意:如果你之前有参考过numpy或者opencv的移植文档,这里需要退出虚拟环境(source ~/.bashrc)。 + +~~~bash +cd ../ + +# 下载meson +python3 -m pip install meson -i https://pypi.tuna.tsinghua.edu.cn/simple + +cd v4l-utils +~~~ + +* 修改contrib/test/meson.build,将第89~102行代码注释掉 + +![image-20251017160603013](pic/image-20251017160603013.png) + +* 进入到v4l-utils的build目录下 + +~~~bash +# 使用meson进行构建 +meson setup \ + --cross-file hisi-cross.txt \ + --prefix /home/openharmony/pegasus/vendor/opensource/v4l-utils/install \ + -Ddoxygen-doc=disabled \ + -Dudevdir=lib/udev \ + -Djpeg=disabled \ + build . 2>&1 | tee meson_output.log + +cd build + +ninja && ninja install +~~~ + +![image-20251017155057453](pic/image-20251017155057453.png) + +![image-20251017163810406](pic/image-20251017163810406.png) + +* 执行成功后会在v4l-utils/install目录下生成如下文件 + +![image-20251017163852692](pic/image-20251017163852692.png) + +## 3.测试 + +### 3.1 NFS 共享 + +* nfs配置可参考参考链接: + +~~~bash +https://blog.csdn.net/weixin_34326429/article/details/92163791 +~~~ + +### 3.2 挂载NFS + +* 在开发板的命令行终端执行下面的命令,配置IP地址,并进行NFS挂载 + +~~~bash +ifconfig eth0 192.168.137.0 netmask 255.255.252.0 +route add default gw 192.168.137.1 +mount -o nolock,addr=192.168.137.1 -t nfs 192.168.137.1:/nfs /mnt +~~~ + +### 3.3 配置环境变量 + +* 将第2章步骤4生成的install文件下载到本地 + +![image-20250904143920431](pic/image-20250904143920431.png) + +* 为了区分,我将install文件名改为libv4l2_install +* 在开发板的命令行终端执行下面的命令,配置环境变量 + +~~~bash +cd mnt + +export PATH=/mnt/libv4l2_install/bin:$PATH +export LD_LIBRARY_PATH=/mnt/libv4l2_install/lib:$LD_LIBRARY_PATH +chmod +x /mnt/libv4l2_install/bin/v4l2-ctl +~~~ + +### 3.4测试 + +#### 3.4.1 测试v4l2-ctl工具 + +* 测试列出所有设备 + +~~~bash +v4l2-ctl --list-devices +~~~ + +![image-20250904144609428](pic/image-20250904144609428.png) + +* 测试查看usb摄像头支持的图像格式和分辨率 + +~~~bash +v4l2-ctl -d /dev/video0 --list-formats-ext +~~~ + +![image-20250904144720470](pic/image-20250904144720470.png) + +* 测试采集一帧图像 + +~~~bash +v4l2-ctl -d /dev/video0 \ + --set-fmt-video=width=1920,height=1080,pixelformat=MJPG \ + --stream-mmap \ + --stream-count=1 \ + --stream-to=v4l2test.jpg +~~~ + +![image-20250904144926010](pic/image-20250904144926010.png) + +#### 3.4.2 接口调用demo + +* 把下面的内容复制到test_libv4l2.c中,在服务器上编译,得到可执行文件后放到板端执行。 + +~~~bash +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) { + int fd; + char *dev_name = "/dev/video0"; // 默认视频设备 + struct v4l2_capability cap; + struct v4l2_format fmt; + struct v4l2_buffer buf; + struct v4l2_requestbuffers req; // 新增:用于请求缓冲区 + void *buffer; + + if (argc > 1) { + dev_name = argv[1]; + } + + printf("测试libv4l2是否正常工作...\n"); + printf("尝试打开视频设备: %s\n", dev_name); + + // 打开视频设备 + fd = v4l2_open(dev_name, O_RDWR | O_NONBLOCK, 0); + if (fd < 0) { + perror("无法打开视频设备"); + return EXIT_FAILURE; + } + printf("成功打开视频设备\n"); + + // 查询设备能力 + if (v4l2_ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0) { + perror("无法查询设备能力"); + v4l2_close(fd); + return EXIT_FAILURE; + } + printf("设备信息:\n"); + printf(" 名称: %s\n", cap.card); + printf(" 驱动: %s\n", cap.driver); + printf(" 总线: %s\n", cap.bus_info); + + // 检查是否支持视频捕获和流式IO + if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { + fprintf(stderr, "设备不支持视频捕获\n"); + v4l2_close(fd); + return EXIT_FAILURE; + } + if (!(cap.capabilities & V4L2_CAP_STREAMING)) { + fprintf(stderr, "设备不支持流式IO\n"); + v4l2_close(fd); + return EXIT_FAILURE; + } + + // 设置视频格式 + memset(&fmt, 0, sizeof(fmt)); + fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + fmt.fmt.pix.width = 640; + fmt.fmt.pix.height = 480; + fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; + fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; + + if (v4l2_ioctl(fd, VIDIOC_S_FMT, &fmt) < 0) { + perror("无法设置视频格式"); + v4l2_close(fd); + return EXIT_FAILURE; + } + printf("成功设置视频格式: %dx%d, 格式: YUYV\n", + fmt.fmt.pix.width, fmt.fmt.pix.height); + + // 新增:请求缓冲区(关键步骤) + memset(&req, 0, sizeof(req)); + req.count = 1; // 请求1个缓冲区 + req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + req.memory = V4L2_MEMORY_MMAP; // 使用内存映射方式 + + if (v4l2_ioctl(fd, VIDIOC_REQBUFS, &req) < 0) { + perror("无法请求缓冲区"); + v4l2_close(fd); + return EXIT_FAILURE; + } + printf("成功请求 %d 个缓冲区\n", req.count); + + // 查询缓冲区信息 + memset(&buf, 0, sizeof(buf)); + buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + buf.memory = V4L2_MEMORY_MMAP; + buf.index = 0; // 查询第0个缓冲区 + + if (v4l2_ioctl(fd, VIDIOC_QUERYBUF, &buf) < 0) { + perror("无法查询缓冲区"); + v4l2_close(fd); + return EXIT_FAILURE; + } + + // 映射缓冲区 + buffer = v4l2_mmap(NULL, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, buf.m.offset); + if (buffer == MAP_FAILED) { + perror("无法映射缓冲区"); + v4l2_close(fd); + return EXIT_FAILURE; + } + printf("成功映射缓冲区,大小: %d bytes\n", buf.length); + + // 将缓冲区放入队列 + if (v4l2_ioctl(fd, VIDIOC_QBUF, &buf) < 0) { + perror("无法将缓冲区放入队列"); + v4l2_munmap(buffer, buf.length); + v4l2_close(fd); + return EXIT_FAILURE; + } + + // 开始捕获 + enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + if (v4l2_ioctl(fd, VIDIOC_STREAMON, &type) < 0) { + perror("无法开始捕获"); + v4l2_munmap(buffer, buf.length); + v4l2_close(fd); + return EXIT_FAILURE; + } + printf("开始视频捕获...\n"); + + // 等待帧就绪 + fd_set fds; + struct timeval tv; + int r; + + FD_ZERO(&fds); + FD_SET(fd, &fds); + tv.tv_sec = 2; + tv.tv_usec = 0; + + r = select(fd + 1, &fds, NULL, NULL, &tv); + if (r == -1) { + perror("select失败"); + v4l2_ioctl(fd, VIDIOC_STREAMOFF, &type); + v4l2_munmap(buffer, buf.length); + v4l2_close(fd); + return EXIT_FAILURE; + } + if (r == 0) { + fprintf(stderr, "捕获超时\n"); + v4l2_ioctl(fd, VIDIOC_STREAMOFF, &type); + v4l2_munmap(buffer, buf.length); + v4l2_close(fd); + return EXIT_FAILURE; + } + + // 从队列中取出缓冲区 + if (v4l2_ioctl(fd, VIDIOC_DQBUF, &buf) < 0) { + perror("无法从队列中取出缓冲区"); + v4l2_ioctl(fd, VIDIOC_STREAMOFF, &type); + v4l2_munmap(buffer, buf.length); + v4l2_close(fd); + return EXIT_FAILURE; + } + + printf("成功捕获一帧图像,大小: %d bytes\n", buf.bytesused); + + // 停止捕获 + if (v4l2_ioctl(fd, VIDIOC_STREAMOFF, &type) < 0) { + perror("无法停止捕获"); + v4l2_munmap(buffer, buf.length); + v4l2_close(fd); + return EXIT_FAILURE; + } + + // 清理资源 + v4l2_munmap(buffer, buf.length); + v4l2_close(fd); + + printf("所有测试操作完成,libv4l2工作正常!\n"); + return EXIT_SUCCESS; +} + +~~~ + +* 在服务器的命令行执行下面的命令,编译该代码 +* 注意:这里的决定路径请根据自己服务器的实际情况进行填写 + +~~~bash +/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang -o test_libv4l2 test_libv4l2.c \ +--sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot \ +-I/home/openharmony/pegasus/vendor/opensource/v4l-utils/install/include \ +-I/home/openharmony/pegasus/vendor/opensource/v4l-utils/lib/include \ +-L/home/openharmony/pegasus/vendor/opensource/v4l-utils/install/lib \ +-lv4l2 +~~~ + +![image-20251017170636644](pic/image-20251017170636644.png) + +~~~bash +#1.将可执行文件test_libv4l2下载并挂载上板端 +cd mnt +#2.添加v4l2的相关环境变量,参考5.3配置环境变量 +chmod +x test_libv4l2 +#3.运行测试 +./test_libv4l2 +~~~ + +![image-20251017170534770](pic/image-20251017170534770.png) + + + diff --git a/vendor/zsks/docs/libv4l2/pic/image-20250904143920431.png b/vendor/zsks/docs/libv4l2/pic/image-20250904143920431.png new file mode 100755 index 0000000000000000000000000000000000000000..bbba9d4935ea43429a600ec64dfe14119f90a735 Binary files /dev/null and b/vendor/zsks/docs/libv4l2/pic/image-20250904143920431.png differ diff --git a/vendor/zsks/docs/libv4l2/pic/image-20250904144609428.png b/vendor/zsks/docs/libv4l2/pic/image-20250904144609428.png new file mode 100755 index 0000000000000000000000000000000000000000..ff29749d89fab1166b46eee624e72297948d1b94 Binary files /dev/null and b/vendor/zsks/docs/libv4l2/pic/image-20250904144609428.png differ diff --git a/vendor/zsks/docs/libv4l2/pic/image-20250904144720470.png b/vendor/zsks/docs/libv4l2/pic/image-20250904144720470.png new file mode 100755 index 0000000000000000000000000000000000000000..e0529247489c0470c3d147c268bb5d97e59565f1 Binary files /dev/null and b/vendor/zsks/docs/libv4l2/pic/image-20250904144720470.png differ diff --git a/vendor/zsks/docs/libv4l2/pic/image-20250904144926010.png b/vendor/zsks/docs/libv4l2/pic/image-20250904144926010.png new file mode 100755 index 0000000000000000000000000000000000000000..8d0b234ad3f45ea454352a050b887c07d72e66b4 Binary files /dev/null and b/vendor/zsks/docs/libv4l2/pic/image-20250904144926010.png differ diff --git a/vendor/zsks/docs/libv4l2/pic/image-20251017153708743.png b/vendor/zsks/docs/libv4l2/pic/image-20251017153708743.png new file mode 100755 index 0000000000000000000000000000000000000000..8c893c832ee47793ac777c6f01adc6745217e3e5 Binary files /dev/null and b/vendor/zsks/docs/libv4l2/pic/image-20251017153708743.png differ diff --git a/vendor/zsks/docs/libv4l2/pic/image-20251017154000326.png b/vendor/zsks/docs/libv4l2/pic/image-20251017154000326.png new file mode 100755 index 0000000000000000000000000000000000000000..c19aaed11960beb276f707cd09d86f14afe9c68a Binary files /dev/null and b/vendor/zsks/docs/libv4l2/pic/image-20251017154000326.png differ diff --git a/vendor/zsks/docs/libv4l2/pic/image-20251017154359756.png b/vendor/zsks/docs/libv4l2/pic/image-20251017154359756.png new file mode 100755 index 0000000000000000000000000000000000000000..d6acb9d4d038ee0d099762a3df3e149ee8ba10b5 Binary files /dev/null and b/vendor/zsks/docs/libv4l2/pic/image-20251017154359756.png differ diff --git a/vendor/zsks/docs/libv4l2/pic/image-20251017154546402.png b/vendor/zsks/docs/libv4l2/pic/image-20251017154546402.png new file mode 100755 index 0000000000000000000000000000000000000000..cf70a7e1ea2cae27fb955e2876beef5e73d8224a Binary files /dev/null and b/vendor/zsks/docs/libv4l2/pic/image-20251017154546402.png differ diff --git a/vendor/zsks/docs/libv4l2/pic/image-20251017154814146.png b/vendor/zsks/docs/libv4l2/pic/image-20251017154814146.png new file mode 100755 index 0000000000000000000000000000000000000000..897aff759d0b5fe56a37a07e4a49b36435b3d644 Binary files /dev/null and b/vendor/zsks/docs/libv4l2/pic/image-20251017154814146.png differ diff --git a/vendor/zsks/docs/libv4l2/pic/image-20251017155057453.png b/vendor/zsks/docs/libv4l2/pic/image-20251017155057453.png new file mode 100755 index 0000000000000000000000000000000000000000..e238beb06f5522b7c3ed3e29a2be4188b5b74724 Binary files /dev/null and b/vendor/zsks/docs/libv4l2/pic/image-20251017155057453.png differ diff --git a/vendor/zsks/docs/libv4l2/pic/image-20251017160603013.png b/vendor/zsks/docs/libv4l2/pic/image-20251017160603013.png new file mode 100755 index 0000000000000000000000000000000000000000..9e43a76e1d7c5402a3688dcd3db9ddf1515f1961 Binary files /dev/null and b/vendor/zsks/docs/libv4l2/pic/image-20251017160603013.png differ diff --git a/vendor/zsks/docs/libv4l2/pic/image-20251017163810406.png b/vendor/zsks/docs/libv4l2/pic/image-20251017163810406.png new file mode 100755 index 0000000000000000000000000000000000000000..f758eb88dfeab772a2de52eb1f25bd30c0fa68c0 Binary files /dev/null and b/vendor/zsks/docs/libv4l2/pic/image-20251017163810406.png differ diff --git a/vendor/zsks/docs/libv4l2/pic/image-20251017163852692.png b/vendor/zsks/docs/libv4l2/pic/image-20251017163852692.png new file mode 100755 index 0000000000000000000000000000000000000000..8741b85f5f948bf38fce2ae59028cea3e79ee5ed Binary files /dev/null and b/vendor/zsks/docs/libv4l2/pic/image-20251017163852692.png differ diff --git a/vendor/zsks/docs/libv4l2/pic/image-20251017170534770.png b/vendor/zsks/docs/libv4l2/pic/image-20251017170534770.png new file mode 100755 index 0000000000000000000000000000000000000000..a2455a87b302ed14a2dfffa395db5ebf116dae08 Binary files /dev/null and b/vendor/zsks/docs/libv4l2/pic/image-20251017170534770.png differ diff --git a/vendor/zsks/docs/libv4l2/pic/image-20251017170636644.png b/vendor/zsks/docs/libv4l2/pic/image-20251017170636644.png new file mode 100755 index 0000000000000000000000000000000000000000..934bd3d01462445d61aafb08c7a24c8a4cedd9fe Binary files /dev/null and b/vendor/zsks/docs/libv4l2/pic/image-20251017170636644.png differ diff --git a/vendor/zsks/docs/numpy/README.md b/vendor/zsks/docs/numpy/README.md new file mode 100755 index 0000000000000000000000000000000000000000..785a885732605f5c8f0559e2079866679320897b --- /dev/null +++ b/vendor/zsks/docs/numpy/README.md @@ -0,0 +1,271 @@ +# numpy移植 + +## 1、软硬件环境 + +开发板:海鸥派 +交叉编译工具链:OHOS (dev) clang version 15.0.4 + +编译链路径:pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin + +python版本:Python-3.13.2 + +移植的numpy版本:numpy-v2.2.5 + +## 2、交叉编译numpy + +### 步骤1:下载numpy源码 + +* 分步执行下面的命令,下载Numpy源码 + +```sh +cd pegasus/vendor/opensource + +git clone https://github.com/numpy/numpy.git + +cd numpy + +# 加载子模块 +git submodule update --init + +# 切到自己想要的版本,我这里选择v2.2.5 +git checkout v2.2.5 +``` + +![image-20251010105452576](pic/image-20251010105452576.png) + +![image-20251010105525630](pic/image-20251010105525630.png) + +### 步骤2:配置编译脚本 + +* 在numpy源码根目录下创建一个ohos-build.meson.ini 文件,然后把下面的内容复制进去并保存。 + +```ini +# toolchain和sysroot路径,请根据自己服务器的实际路径进行填写 + +[constants] +toolchain = '/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin' +sysroot = '/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot' +host_cpu = 'aarch64' +host_arch = 'aarch64' +common_flags = ['--sysroot=' + sysroot, '--target=' + host_cpu + '-linux-ohos'] + +[built-in options] +c_args = common_flags +cpp_args = common_flags +c_link_args = common_flags +cpp_link_args = common_flags + +[properties] +sizeof_long_double = 8 +longdouble_format = 'IEEE_DOUBLE_LE' + +[binaries] +c = toolchain / 'aarch64-unknown-linux-ohos-clang' +cpp = toolchain / 'aarch64-unknown-linux-ohos-clang++' +# 这里的python为虚拟环境的python路径 +python = '/home/openharmony/pegasus/vendor/opensource/Python-3.13.2/install/include/python3.13' +cython = '' +cython3 = cython +as = toolchain / 'llvm-as' +ld = toolchain / 'ld.lld' +c_ld = ld +cpp_ld = ld +lld = toolchain / 'ld.lld' +strip = toolchain / 'llvm-strip' +ranlib = toolchain / 'llvm-ranlib' +objdump = toolchain / 'llvm-objdump' +objcopy = toolchain / 'llvm-objcopy' +readelf = toolchain / 'llvm-readelf' +nm = toolchain / 'llvm-nm' +ar = toolchain / 'llvm-ar' +profdata = toolchain / 'llvm-profdata' + +[host_machine] +system = 'ohos' +kernel = 'linux' +cpu_family = host_cpu +cpu = host_cpu +endian = 'little' +``` + +### 步骤3:配置编译虚拟环境 + +* 创建crossenv虚拟环境,用于Numpy的编译 + +```sh +# 下载ninja +apt-get install ninja-build + +# 下载cpython +pip3 install cython -i https://pypi.tuna.tsinghua.edu.cn/simple + +# 下载crossenv +pip3 install crossenv + +# 在Python-3.13.2目录下创建crossenv虚拟环境 +# /home/openharmony/pegasus/vendor/opensource/Python-3.13.2/install 为交叉编译后的python路径 +cd Python-3.13.2 +python3 -m crossenv /home/openharmony/pegasus/vendor/opensource/Python-3.13.2/install/bin/python3 crossenv_aarch64 + +# 激活环境 +. crossenv_aarch64/bin/activate + +cd ../numpy + +# 配置 VENDORED_MESON,具体路径请根据自己numpy实际路径进行配置 + +VENDORED_MESON=/home/openharmony/pegasus/vendor/opensource/numpy/vendored-meson/meson/meson.py +python ${VENDORED_MESON} setup --reconfigure --prefix=$PWD/install --cross-file ./ohos-build.meson.ini build-ohos + +cd build-ohos + +# 编译Numpy +python ${VENDORED_MESON} compile + +# 安装 numpy +python ${VENDORED_MESON} install +``` + +![image-20251010154244943](pic/image-20251010154244943.png) + +![image-20251010155502489](pic/image-20251010155502489.png) + +![image-20251010155613680](pic/image-20251010155613680.png) + +![image-20251010155721678](pic/image-20251010155721678.png) + +![image-20251010155900494](pic/image-20251010155900494.png) + +* 生成的numpy安装包在numpy/install/lib/python3.13/site-packages/numpy/目录下 + +![image-20251010160053388](pic/image-20251010160053388.png) + + + +## 3、板端测试 + +### 步骤1:配置板端环境 + +* 1、确保开发板已经烧录OpenHarmony操作系统 +* 2、使用网线将开发板与你的电脑进行连接,确保二者处于同一局域网内 +* 3、配置开发板的IP地址,并确保开发板与电脑能够互相ping通 + +```sh +# 注意:这里的eth0的IP地址,请根据自己的网络IP网段进行合理配置 +ifconfig eth0 192.168.100.100 + +# 添加权限 +echo 0 9999999 > /proc/sys/net/ipv4/ping_group_range +``` + +![image-20251010094441549](pic/image-20251010094441549.png) + +### 步骤2:准备python依赖文件 + +* 1、将python移植第4章 交叉编译python3.13.2后,生成的install文件夹拷贝到你的NFS挂载目录 +* 2、再将numpy/install/lib/python3.13/site-packages下的numpy复制到install/lib/目录下。 +* 3、再根据python第三章移植的内容,将libz.so.1、 libssl.so.1.1 、 libcrypto.so.1.1文件复制到install/lib/python3.13/lib-dynload目录下 + +* 4、执行下面的,命令将电脑的nfs目录挂载到开发板的/mnt目录下(注意:这里请根据自己的IP地址及NFS配置进行合理的修改) + +```mk1.sh +mount -o nolock,addr=192.168.100.10 -t nfs 192.168.100.10:/d/nfs /mnt +``` + +![image-20251010163427786](pic/image-20251010163427786.png) + +![image-20251010161646562](pic/image-20251010161646562.png) + +* 3、配置python的环境变量,确保python运行时能够找到依赖 + +```mk1.sh +export PATH=/mnt/install/bin:$PATH +export PYTHONPATH=/mnt/install/lib/python3.13:$PYTHONPATH +export LD_LIBRARY_PATH=/mnt/install/lib/python3.13/lib-dynload:$LD_LIBRARY_PATH +``` + +image-20251010101732852 + +### 步骤3:使用python调用numpy接口: + +* 先输入python,进入板端python环境,然后输入import numpy 敲回车,如果没有任何报错,说明numpy移植成功 + +![image-20251010162222908](pic/image-20251010162222908.png) + +* 将下面的内容复制到numpy_test.py中 + +```python +import numpy as np +import time + +def test_numpy_functionality(): + """测试 NumPy 的基本功能""" + print("=" * 50) + print("NumPy 功能测试") + print("=" * 50) + + # 1. 创建数组 + arr1 = np.array([1, 2, 3, 4, 5]) + arr2 = np.arange(0, 10, 2) # 类似 range,但生成数组 + arr3 = np.zeros((3, 3)) # 3x3 零矩阵 + arr4 = np.random.rand(2, 2) # 2x2 随机矩阵 + + print("\n1. 数组创建:") + print(f"arr1: {arr1}") + print(f"arr2 (0到10步长2): {arr2}") + print(f"arr3 (3x3零矩阵):\n{arr3}") + print(f"arr4 (2x2随机矩阵):\n{arr4}") + + # 2. 数学运算 + print("\n2. 数学运算:") + print(f"arr1 + 10: {arr1 + 10}") # 广播机制 + print(f"arr1 * arr2 (前5项): {arr1 * arr2[:5]}") + print(f"sin(arr2): {np.sin(arr2)}") # 三角函数 + + # 3. 矩阵乘法 + matrix_a = np.array([[1, 2], [3, 4]]) + matrix_b = np.array([[5, 6], [7, 8]]) + dot_product = np.dot(matrix_a, matrix_b) # 矩阵乘法 + print("\n3. 矩阵乘法 (np.dot):") + print(f"matrix_a:\n{matrix_a}") + print(f"matrix_b:\n{matrix_b}") + print(f"结果:\n{dot_product}") + + # 4. 性能对比:NumPy vs 纯Python + print("\n4. 性能对比 (计算1百万个数的平方):") + size = 1_000_000 + + # 纯Python + py_list = list(range(size)) + start = time.time() + py_result = [x ** 2 for x in py_list] + py_time = time.time() - start + + # NumPy + np_arr = np.arange(size) + start = time.time() + np_result = np_arr ** 2 + np_time = time.time() - start + + print(f"纯Python耗时: {py_time:.5f} 秒") + print(f"NumPy耗时: {np_time:.5f} 秒") + print(f"NumPy比Python快 {py_time / np_time:.1f} 倍!") + + # 5. 高级功能:条件筛选 + print("\n5. 条件筛选 (找出arr2中大于5的数):") + filtered = arr2[arr2 > 5] + print(f"原始数组: {arr2}") + print(f"筛选结果: {filtered}") + +if __name__ == "__main__": + test_numpy_functionality() +``` + +* 然后执行下面的命令,运行numpy测试代码 + +```sh +python3 numpy_test.py +``` + +![image-20251010163638261](pic/image-20251010163638261.png) + diff --git a/vendor/zsks/docs/numpy/pic/image-20251010094441549.png b/vendor/zsks/docs/numpy/pic/image-20251010094441549.png new file mode 100755 index 0000000000000000000000000000000000000000..e981001ec636db595d2766310bf95a49e58f3914 Binary files /dev/null and b/vendor/zsks/docs/numpy/pic/image-20251010094441549.png differ diff --git a/vendor/zsks/docs/numpy/pic/image-20251010105452576.png b/vendor/zsks/docs/numpy/pic/image-20251010105452576.png new file mode 100755 index 0000000000000000000000000000000000000000..220d510fc77baff9461ee6909320d22b21c44fb1 Binary files /dev/null and b/vendor/zsks/docs/numpy/pic/image-20251010105452576.png differ diff --git a/vendor/zsks/docs/numpy/pic/image-20251010105525630.png b/vendor/zsks/docs/numpy/pic/image-20251010105525630.png new file mode 100755 index 0000000000000000000000000000000000000000..7823d256141b5acfaf95d2775898fb64b87594d6 Binary files /dev/null and b/vendor/zsks/docs/numpy/pic/image-20251010105525630.png differ diff --git a/vendor/zsks/docs/numpy/pic/image-20251010154244943.png b/vendor/zsks/docs/numpy/pic/image-20251010154244943.png new file mode 100755 index 0000000000000000000000000000000000000000..fb667f2474dd511d568e3a2a444911ad04ee7080 Binary files /dev/null and b/vendor/zsks/docs/numpy/pic/image-20251010154244943.png differ diff --git a/vendor/zsks/docs/numpy/pic/image-20251010155502489.png b/vendor/zsks/docs/numpy/pic/image-20251010155502489.png new file mode 100755 index 0000000000000000000000000000000000000000..3de9e193106f68677ae53a9ebc46d4183b0626b2 Binary files /dev/null and b/vendor/zsks/docs/numpy/pic/image-20251010155502489.png differ diff --git a/vendor/zsks/docs/numpy/pic/image-20251010155613680.png b/vendor/zsks/docs/numpy/pic/image-20251010155613680.png new file mode 100755 index 0000000000000000000000000000000000000000..e06097a6cf6445f85f16753a9db00dcd7f9f0c92 Binary files /dev/null and b/vendor/zsks/docs/numpy/pic/image-20251010155613680.png differ diff --git a/vendor/zsks/docs/numpy/pic/image-20251010155721678.png b/vendor/zsks/docs/numpy/pic/image-20251010155721678.png new file mode 100755 index 0000000000000000000000000000000000000000..ebce63b3c6256a1a9e1d9df76674ad6d87157ffa Binary files /dev/null and b/vendor/zsks/docs/numpy/pic/image-20251010155721678.png differ diff --git a/vendor/zsks/docs/numpy/pic/image-20251010155900494.png b/vendor/zsks/docs/numpy/pic/image-20251010155900494.png new file mode 100755 index 0000000000000000000000000000000000000000..2da7eb24782e381b745c5318c352671ff5a1a6a7 Binary files /dev/null and b/vendor/zsks/docs/numpy/pic/image-20251010155900494.png differ diff --git a/vendor/zsks/docs/numpy/pic/image-20251010160053388.png b/vendor/zsks/docs/numpy/pic/image-20251010160053388.png new file mode 100755 index 0000000000000000000000000000000000000000..18d4e661ba770e0d0399ee08c98150eab65cae15 Binary files /dev/null and b/vendor/zsks/docs/numpy/pic/image-20251010160053388.png differ diff --git a/vendor/zsks/docs/numpy/pic/image-20251010161646562.png b/vendor/zsks/docs/numpy/pic/image-20251010161646562.png new file mode 100755 index 0000000000000000000000000000000000000000..17728a71c2f2e11d52b0905b0aa2ae5a103d9f96 Binary files /dev/null and b/vendor/zsks/docs/numpy/pic/image-20251010161646562.png differ diff --git a/vendor/zsks/docs/numpy/pic/image-20251010162222908.png b/vendor/zsks/docs/numpy/pic/image-20251010162222908.png new file mode 100755 index 0000000000000000000000000000000000000000..21a9bb31eede98c9394c4b923c3b6fd7ca27b8fa Binary files /dev/null and b/vendor/zsks/docs/numpy/pic/image-20251010162222908.png differ diff --git a/vendor/zsks/docs/numpy/pic/image-20251010163427786.png b/vendor/zsks/docs/numpy/pic/image-20251010163427786.png new file mode 100755 index 0000000000000000000000000000000000000000..15763c53409aed093869168bc0c2916e81b9df5c Binary files /dev/null and b/vendor/zsks/docs/numpy/pic/image-20251010163427786.png differ diff --git a/vendor/zsks/docs/numpy/pic/image-20251010163638261.png b/vendor/zsks/docs/numpy/pic/image-20251010163638261.png new file mode 100755 index 0000000000000000000000000000000000000000..b6640ac996ba6fd27c69be5b56e6a19b6222cd0f Binary files /dev/null and b/vendor/zsks/docs/numpy/pic/image-20251010163638261.png differ diff --git a/vendor/zsks/docs/opencv/README.md b/vendor/zsks/docs/opencv/README.md new file mode 100755 index 0000000000000000000000000000000000000000..34950cfe49d680d2cc16b0f999b82ae3012ce96e --- /dev/null +++ b/vendor/zsks/docs/opencv/README.md @@ -0,0 +1,380 @@ +# OpenCV移植 + +## 1、软硬件环境 + +开发板:海鸥派 +交叉编译工具链:OHOS (dev) clang version 15.0.4 + +编译链路径:pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin + +python版本:Python-3.13.2 + +移植的OpenCV版本:OpenCV-4.13 + +## 2、交叉编译OpenCV + +### 步骤1:安装依赖软件 + +* 在服务器的命令行执行下面的命令,安装OpenCV交叉编译是的依赖软件 + +```sh +apt-get install cmake libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python3-dev python3-numpy libdc1394-dev libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev -y +``` + +![image-20251013144111854](pic/image-20251013144111854.png) + +* 先进入到python目录下,确保虚拟环境已经开启,关于如何搭建虚拟环境,可参考[numpy移植文档第2章的步骤3](../numpy/README.md)。 + +```sh +cd opensource/Python-3.13.2 + +. crossenv_aarch64/bin/activate +``` + +![image-20251016145037570](pic/image-20251016145037570.png) + +### 步骤2:下载OpenCV源码 + +```sh +cd ../ + +git clone https://github.com/opencv/opencv.git + +cd opencv +``` + +### 步骤3:运行脚本 + +* 进入opencv源码并创建build文件夹: + +```sh +mkdir build + +cd build +``` + +* 把下面的内容复制到build_opencv.sh中: + +```sh +#!/bin/bash +set -e +BuildDir=. +ToolChain=/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin +SYSROOT=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot +if [ ! -d "$BuildDir" ]; then + echo "create ${BuildDir}..." + mkdir -p ${BuildDir} +fi +cd ${BuildDir} + +echo "building OpenCV4" + +cmake -D CMAKE_BUILD_TYPE=RELEASE \ + -D BUILD_SHARED_LIBS=ON \ + -D CMAKE_FIND_ROOT_PATH=${ToolChain}/ \ + -D CMAKE_SYSROOT=${SYSROOT} \ + -D CMAKE_TOOLCHAIN_FILE=../platforms/linux/aarch64-gnu.toolchain.cmake \ + -D CMAKE_C_COMPILER=${ToolChain}/aarch64-unknown-linux-ohos-clang \ + -D CMAKE_CXX_COMPILER=${ToolChain}/aarch64-unknown-linux-ohos-clang++ \ + -D CMAKE_INSTALL_PREFIX=${BuildDir}/install \ + -D WITH_TBB=ON \ + -D WITH_EIGEN=ON \ + -D BUILD_ZLIB=ON \ + -D BUILD_TIFF=ON \ + -D BUILD_JASPER=ON \ + -D BUILD_JPEG=ON \ + -D BUILD_PNG=ON \ + -D WITH_LIBV4L=ON \ + -D BUILD_opencv_python=ON \ + # 这里的python为交叉编译成功后的python路径 + -D PYTHON3_INCLUDE_PATH=/home/openharmony/pegasus/vendor/opensource/Python-3.13.2/install/include/python3.13 \ + -D PYTHON3_NUMPY_INCLUDE_DIRS=/home/openharmony/pegasus/vendor/opensource/numpy/install/lib/python3.13/site-packages/numpy/_core/include \ + -D ENABLE_PRECOMPILED_HEADERS=OFF \ + -D BUILD_EXAMPLES=OFF \ + -D BUILD_TESTS=OFF \ + -D BUILD_PERF_TESTS=OFF \ + -D BUILD_WITH_DEBUG_INFO=OFF \ + -D BUILD_DOCS=OFF \ + -D WITH_OPENCL=OFF \ + -D WITH_1394=OFF \ + ../ + +make -j$(nproc) +``` + +![image-20251013150324179](pic/image-20251013150324179.png) + +* 出现下面的打印信息,说明OpenCV交叉编译成功: + +![image-20251013150632408](pic/image-20251013150632408.png) + +* 执行下面的命令,进行OpenCV的安装: + +```sh +make install +``` + +![image-20251013150714220](pic/image-20251013150714220.png) + +* 安装成功后,会在install目录下生成以下文件。 + +![image-20251013150935466](pic/image-20251013150935466.png) + +## 3、使用python调用OpenCV接口 + +* 1、将python移植第4章 交叉编译python3.13.2后,生成的install文件夹拷贝到你的NFS挂载目录 +* 2、再将opencv/build/install/lib下的库文件复制到install/lib/python3.13/lib-dynload目录下。 +* 3、再根据python第三章移植的内容,将libz.so.1、 libssl.so.1.1 、 libcrypto.so.1.1文件复制到install/lib/python3.13/lib-dynload目录下 + +![image-20251013164259362](pic/image-20251013164259362.png) + +* 4、将opencv/build/install/lib/python3.13/site-packages/cv2 复制到 install/lib/python3.13/site-packages目录下 + +![image-20251013181456311](pic/image-20251013181456311.png) + +* 5、执行下面的,命令将电脑的nfs目录挂载到开发板的/mnt目录下,然后配置环境变量 + +```sh +# 注意:这里的eth0的IP地址,请根据自己的网络IP网段进行合理配置 +ifconfig eth0 192.168.100.100 + +mount -o nolock,addr=192.168.100.10 -t nfs 192.168.100.10:/d/nfs /mnt + +export PATH=/mnt/install/bin:$PATH +export PYTHONPATH=/mnt/install/lib/python3.13:$PYTHONPATH +export LD_LIBRARY_PATH=/mnt/install/lib/python3.13/lib-dynload:$LD_LIBRARY_PATH +``` + +![image-20251013181928810](pic/image-20251013181928810.png) + +* 在开发板的命令行执行下面的命令,进入python环境,导入cv2 + +```sh +cd /mnt/install/bin + +python3 +``` + +* 在python3环境输入import cv2,如果没有任何报错,说明opencv接口调用成功 + +![image-20251016151507324](pic/image-20251016151507324.png) + +* 将下面的内容复制到opencv_test.py文件中,测试基本功能。 + +```mk1.sh +import cv2 +import numpy as np +import os + +def test_opencv_without_ui(): + """无UI的OpenCV功能测试(通过文件保存和日志输出验证)""" + print("=" * 50) + print("OpenCV 无UI测试") + print("=" * 50) + + # 创建临时测试目录 + os.makedirs("opencv_test_output", exist_ok=True) + print("[日志] 创建输出目录: opencv_test_output") + + # 1. 生成测试图像 + test_image = np.zeros((200, 200, 3), dtype=np.uint8) + cv2.rectangle(test_image, (50, 50), (150, 150), (0, 255, 0), 2) + cv2.putText(test_image, "OpenCV Test", (30, 30), + cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1) + cv2.imwrite("opencv_test_output/test_image.png", test_image) + print("[日志] 生成测试图像: test_image.png") + + # 2. 图像处理(灰度化+边缘检测) + gray_image = cv2.cvtColor(test_image, cv2.COLOR_BGR2GRAY) + edges = cv2.Canny(gray_image, 100, 200) + cv2.imwrite("opencv_test_output/edges.png", edges) + print("[日志] 生成边缘检测结果: edges.png") + + # 3. 矩阵运算测试(修复:转换为float32) + mat_a = np.random.rand(3, 3).astype(np.float32) # 改为浮点矩阵 + mat_b = np.random.rand(3, 3).astype(np.float32) + mat_mult = cv2.gemm(mat_a, mat_b, 1, None, 0) + print("[矩阵运算] A * B = \n", mat_mult) + + # 4. 摄像头测试(无UI模式) + cap = cv2.VideoCapture(0) + if not cap.isOpened(): + print("[警告] 未检测到摄像头,跳过摄像头测试") + else: + ret, frame = cap.read() + if ret: + cv2.imwrite("opencv_test_output/camera_capture.png", frame) + print("[日志] 摄像头捕获成功: camera_capture.png") + cap.release() + + # 5. 特征检测(ORB) + orb = cv2.ORB_create() + kp = orb.detect(gray_image, None) + kp_image = cv2.drawKeypoints(gray_image, kp, None, color=(0, 255, 0)) + cv2.imwrite("opencv_test_output/keypoints.png", kp_image) + print("[日志] 生成特征点检测结果: keypoints.png") + print(f"[特征检测] 共检测到 {len(kp)} 个特征点") + + # 6. 性能测试 + start_time = cv2.getTickCount() + for _ in range(100): + _ = cv2.blur(test_image, (5, 5)) + end_time = cv2.getTickCount() + print(f"[性能] 100次模糊运算耗时: {(end_time - start_time)/cv2.getTickFrequency():.4f}秒") + + print("\n测试完成!结果已保存至 opencv_test_output 目录") + +if __name__ == "__main__": + test_opencv_without_ui() +``` + +* 在开发板的命令行执行下面的命令,运行opencv_test.py + +```sh +python3 opencv_test.py +``` + +![image-20251016151851058](pic/image-20251016151851058.png) + +![image-20251016151915487](pic/image-20251016151915487.png) + +## 4、测试Opencv调用usb摄像头 + +* 将下面的内容复制到opencv_usb_camera_test.py文件中,测试opencv调用usb摄像头的基本功能。 + +```mk1.sh +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import cv2 +import time + +def main(device_index=0, num_frames=100, backend=cv2.CAP_V4L2): + """ + 在无 UI 情况下从 USB 摄像头读取 num_frames 帧并打印每帧的尺寸。 + + :param device_index: 摄像头索引,0 表示第一个设备 + :param num_frames: 要读取的帧数 + :param backend: OpenCV 后端,可选 CAP_V4L2、CAP_ANY 等 + """ + # 打开摄像头 + cap = cv2.VideoCapture(device_index, backend) + if not cap.isOpened(): + print(f"无法打开摄像头 (index={device_index})") + return + + print("开始读取帧…按 Ctrl+C 可中断") + + try: + for i in range(num_frames): + ret, frame = cap.read() + if not ret: + print(f"第 {i} 帧读取失败,退出") + break + + # 示例处理:打印帧的分辨率 + h, w = frame.shape[:2] + print(f"帧 {i+1}/{num_frames} 大小:{w}x{h}") + + # 模拟处理时间 + time.sleep(0.01) + + except KeyboardInterrupt: + print("用户中断") + finally: + cap.release() + print("摄像头已释放,程序结束") + +if __name__ == "__main__": + # 可以通过修改以下参数来指定设备号或读取帧数 + main(device_index=0, num_frames=200) + +``` + +* 在开发板的命令行执行下面的命令,运行opencv_usb_camera_test.py + +```sh +python opencv_usb_camera_test.py +``` + +![image-20251016152114408](pic/image-20251016152114408.png) + + + +## 5、测试opencv中dnn模块 + +* 将下面的内容复制到opencv_dnn_test.py文件中,测试opencv调用dnn模块,实现人脸检测的基本功能。 + +```mk1.sh +import cv2 + +# 1. 读取图片 +image_path = "image.png" # 替换为你的图片路径 +img = cv2.imread(image_path) +if img is None: + print("无法加载图片") + exit(1) +orig_h, orig_w = img.shape[:2] + +# 2. 初始化 FaceDetectorYN,使用原图大小并调松参数 +detector = cv2.FaceDetectorYN.create( + model="face_detection_yunet_2023mar.onnx", + config="", + input_size=(orig_w, orig_h), # 与原图一致 + score_threshold=0.4, # 提高置信度阈值到 0.4 + nms_threshold=0.5, # NMS 阈值 + top_k=200 # 保留最多 200 个候选 +) + +# 3. 检测人脸 +_, faces = detector.detect(img) + +# 4. 后处理:剔除过小的框 +min_size = 50 # 小于 50 像素的宽高都视为噪声 +filtered = [] +if faces is not None: + for face in faces: + x, y, w, h, score = face[:5].astype(int) + # 保留宽高都不小于阈值的框 + if w >= min_size and h >= min_size: + filtered.append((x, y, w, h, score)) + +# 5. 在图像上绘制过滤后的人脸框 +for x, y, w, h, score in filtered: + cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2) + cv2.putText( + img, + f"{score/100:.2f}", + (x, y - 5), + cv2.FONT_HERSHEY_SIMPLEX, + 0.5, + (0, 255, 0), + 1 + ) + +# 6. 保存结果并输出检测到的人脸数量 +output_path = "output_image.jpg" +cv2.imwrite(output_path, img) +print(f"检测完成,检测到 {len(filtered)} 张人脸,结果已保存到 {output_path}") +``` + +* 请自行下载一个带有人脸的图片放入install/bin/目录下,然后把图片重命名为image.png。 +* 然后访问链接下载[onnx模型](https://github.com/opencv/opencv_zoo/blob/main/models/face_detection_yunet/face_detection_yunet_2023mar.onnx),并将该模型也放入install/bin/目录下。 + +![image-20251016153030674](pic/image-20251016153030674.png) + +* 在开发板的命令行执行下面的命令,运行opencv_dnn_test.py + +```sh +python3 opencv_dnn_test.py +``` + +![image-20251016153323187](pic/image-20251016153323187.png) + +检测前: + +![image-20251016153355942](pic/image-20251016153355942.png) + +检测后: + +![image-20251016153418154](pic/image-20251016153418154.png) diff --git a/vendor/zsks/docs/opencv/pic/image-20251013144111854.png b/vendor/zsks/docs/opencv/pic/image-20251013144111854.png new file mode 100755 index 0000000000000000000000000000000000000000..6b19a9f636c3d236c00a3044f73dffdc0d3f06fd Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251013144111854.png differ diff --git a/vendor/zsks/docs/opencv/pic/image-20251013150324179.png b/vendor/zsks/docs/opencv/pic/image-20251013150324179.png new file mode 100755 index 0000000000000000000000000000000000000000..ea84672bd20544c2d8a9e481f8c92c8e93353d7b Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251013150324179.png differ diff --git a/vendor/zsks/docs/opencv/pic/image-20251013150632408.png b/vendor/zsks/docs/opencv/pic/image-20251013150632408.png new file mode 100755 index 0000000000000000000000000000000000000000..8a388cfeb9b9c11c14cbc381728e54382c8cb187 Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251013150632408.png differ diff --git a/vendor/zsks/docs/opencv/pic/image-20251013150714220.png b/vendor/zsks/docs/opencv/pic/image-20251013150714220.png new file mode 100755 index 0000000000000000000000000000000000000000..625eb55460f1be5c55d9c6e0aea66dc8091b3498 Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251013150714220.png differ diff --git a/vendor/zsks/docs/opencv/pic/image-20251013150935466.png b/vendor/zsks/docs/opencv/pic/image-20251013150935466.png new file mode 100755 index 0000000000000000000000000000000000000000..ae0e2447108e472311f55f8b6d5eb32e61130c77 Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251013150935466.png differ diff --git a/vendor/zsks/docs/opencv/pic/image-20251013164259362.png b/vendor/zsks/docs/opencv/pic/image-20251013164259362.png new file mode 100755 index 0000000000000000000000000000000000000000..77cbdce6858beb95660e98547ed11b4f50f7296f Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251013164259362.png differ diff --git a/vendor/zsks/docs/opencv/pic/image-20251013181456311.png b/vendor/zsks/docs/opencv/pic/image-20251013181456311.png new file mode 100755 index 0000000000000000000000000000000000000000..ae6f1a8080a476ac036c1adda7d491c627b019b5 Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251013181456311.png differ diff --git a/vendor/zsks/docs/opencv/pic/image-20251013181928810.png b/vendor/zsks/docs/opencv/pic/image-20251013181928810.png new file mode 100755 index 0000000000000000000000000000000000000000..5462015631c5b6c2dfaa6adbf3e718ee423c9e7b Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251013181928810.png differ diff --git a/vendor/zsks/docs/opencv/pic/image-20251016145037570.png b/vendor/zsks/docs/opencv/pic/image-20251016145037570.png new file mode 100755 index 0000000000000000000000000000000000000000..d8396af5cd30d099c9e33297df7f72d47f87fc97 Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251016145037570.png differ diff --git a/vendor/zsks/docs/opencv/pic/image-20251016151507324.png b/vendor/zsks/docs/opencv/pic/image-20251016151507324.png new file mode 100755 index 0000000000000000000000000000000000000000..f4f2e5a7a70127f12e0d8e1ad45e135577e3c715 Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251016151507324.png differ diff --git a/vendor/zsks/docs/opencv/pic/image-20251016151851058.png b/vendor/zsks/docs/opencv/pic/image-20251016151851058.png new file mode 100755 index 0000000000000000000000000000000000000000..ba7dbc16eccffd7f4e3045984263489fc8f02c97 Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251016151851058.png differ diff --git a/vendor/zsks/docs/opencv/pic/image-20251016151915487.png b/vendor/zsks/docs/opencv/pic/image-20251016151915487.png new file mode 100755 index 0000000000000000000000000000000000000000..ae019ea6575ab93b8472df4d0c8026b58b6e993a Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251016151915487.png differ diff --git a/vendor/zsks/docs/opencv/pic/image-20251016152114408.png b/vendor/zsks/docs/opencv/pic/image-20251016152114408.png new file mode 100755 index 0000000000000000000000000000000000000000..76b62ea9ee2fcbf8a77d5271da52cee911e3704e Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251016152114408.png differ diff --git a/vendor/zsks/docs/opencv/pic/image-20251016153030674.png b/vendor/zsks/docs/opencv/pic/image-20251016153030674.png new file mode 100755 index 0000000000000000000000000000000000000000..41d31eeefd1e31d8cdf2b9455288c9b316a834d9 Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251016153030674.png differ diff --git a/vendor/zsks/docs/opencv/pic/image-20251016153323187.png b/vendor/zsks/docs/opencv/pic/image-20251016153323187.png new file mode 100755 index 0000000000000000000000000000000000000000..93050893423c439913e9fc35db3984c85617ecd9 Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251016153323187.png differ diff --git a/vendor/zsks/docs/opencv/pic/image-20251016153355942.png b/vendor/zsks/docs/opencv/pic/image-20251016153355942.png new file mode 100755 index 0000000000000000000000000000000000000000..f5d5f95bb5c5732a4f3fa9782d9c8bf932ac4bb2 Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251016153355942.png differ diff --git a/vendor/zsks/docs/opencv/pic/image-20251016153418154.png b/vendor/zsks/docs/opencv/pic/image-20251016153418154.png new file mode 100755 index 0000000000000000000000000000000000000000..764009360a2028ccb7ed14fe1d70d4e4604216f0 Binary files /dev/null and b/vendor/zsks/docs/opencv/pic/image-20251016153418154.png differ diff --git a/vendor/zsks/docs/python/README.md b/vendor/zsks/docs/python/README.md new file mode 100755 index 0000000000000000000000000000000000000000..30eea6b679de52d8e652a4c39adc4262e155b1f4 --- /dev/null +++ b/vendor/zsks/docs/python/README.md @@ -0,0 +1,487 @@ +# Python3移植 + +## 1、软硬件环境 +开发板:海鸥派 +交叉编译工具链:OHOS (dev) clang version 15.0.4 + +编译链路径:pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin + +移植的Python版本:Python-3.13.2 + +## 2、配置python环境 + +* 为了满足python3.13.2的移植要求,我们需要先把服务器的python版本改为3.13.2 +* **步骤1**:在服务器的命令行终端执行下面的命令,下载python3.13.2并安装 + +```shell +wget https://www.python.org/ftp/python/3.13.2/Python-3.13.2.tgz + +tar -xvzf Python-3.13.2.tgz +rm Python-3.13.2.tgz + +cd Python-3.13.2 + +./configure --enable-optimizations --enable-shared + +make -j$(nproc) + +make altinstall +``` + +![image-20251010143023136](pic/image-20251010143023136.png) + +![image-20251010143136574](pic/image-20251010143136574.png) + +![image-20251010143226900](pic/image-20251010143226900.png) + +![image-20251010143640847](pic/image-20251010143640847.png) + +* **步骤2:**创建python环境,是python3.13.2生效 +* 在服务器的命令行执行下面的命令,配置python环境变量 + +```sh +rm /usr/bin/python3 + +ln -s /usr/local/bin/python3.13 /usr/bin/python3 + +# 在~/.bashrc文件末尾添加下面的内容 +export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + +# 执行下面的命令,让环境变量生效 +source ~/.bashrc +``` + +![image-20251010144051579](pic/image-20251010144051579.png) + +![image-20251010144137718](pic/image-20251010144137718.png) + +## 3.安装依赖软件 + +### 步骤1: 安装依赖软件包 + +* 在服务器的命令行执行下面的命令,下载移植python所需软件 +* 注意:由于本文档环境是root用户,请根据自己的实际服务器环境,选择是否需要在命令前加sudo + +``` +apt-get update +apt-get upgrade -y +apt-get install openssl libssl-dev gcc make cmake -y +``` + +### 步骤2:交叉编译依赖第三方软件 + +**注意:**在交叉编译之前,请一定确保OpenHarmony的代码下载完成,且整编通过,具体可参考[ohos编译](https://gitee.com/HiSpark/pegasus/blob/master/docs/OpenHarmony%20Small%E7%89%88%E6%9C%AC%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/OpenHarmony%20Small%E7%89%88%E6%9C%AC%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97.md#ohos%E7%BC%96%E8%AF%91)的内容 + +#### 1、zlib的交叉编译 + +* 在服务器的命令行执行下面的命令,进行zlib的交叉编译 + +```sh +# 由于zlib也属于第三方软件,可以在opensource目录下进行移植 +cd pegasus/vendor/opensource/ + +wget http://zlib.net/zlib-1.3.1.tar.gz + +tar -xvf zlib-1.3.1.tar.gz +rm zlib-1.3.1.tar.gz + +cd zlib-1.3.1/ + +# 注意:这里的路径请根据自己的Pegasus目录进行修改 +export CC="/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang --sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot" + +./configure --prefix=$PWD/install + +# 注意:这里的路径请根据自己的Pegasus目录进行修改 +make LDFLAGS="--sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot -L/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot/usr/lib" + +make install +``` + +![image-20251009170325172](pic/image-20251009170325172.png) + +![image-20251009171708407](pic/image-20251009171708407.png) + +![image-20251009171921919](pic/image-20251009171921919.png) + +![image-20251009172007367](pic/image-20251009172007367.png) + +#### 2、openssl的交叉编译 + +* 在服务器的命令行执行下面的命令,进行openssl的交叉编译 + +```sh +cd ../ + +wget https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_1_1_1w.tar.gz + +tar -xvf OpenSSL_1_1_1w.tar.gz +rm OpenSSL_1_1_1w.tar.gz + +cd openssl-OpenSSL_1_1_1w + +perl Configure linux-aarch64 --prefix=$PWD/install + +make CC="/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang --sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot" LDFLAGS="--sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot -L/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot/usr/lib" + +make install +``` + +![image-20251009173438071](pic/image-20251009173438071.png) + +![image-20251009173659012](pic/image-20251009173659012.png) + +![image-20251009174036856](pic/image-20251009174036856.png) + +![image-20251009174105488](pic/image-20251009174105488.png) + +#### 3、libffi的交叉编译 + +* 在服务器的命令行执行下面的命令,进行libffi的交叉编译 + +```sh +cd ../ + +wget https://github.com/libffi/libffi/archive/refs/tags/v3.4.7.tar.gz + +tar -xvf v3.4.7.tar.gz +rm v3.4.7.tar.gz + +cd libffi-3.4.7/ + +./autogen.sh +``` + +![image-20251009174843560](pic/image-20251009174843560.png) + +![image-20251009174953996](pic/image-20251009174953996.png) + +* 修改 config.sub 文件中两处内容 + + * 1、在1771行后面添加内容 | ohos* + + ![image-20251009175248076](pic/image-20251009175248076.png) + + * 2、在 1832行添加 | linux-ohos*- + + ![image-20251009175416655](pic/image-20251009175416655.png) + +* 保持config.sub文件之后,执行下面的命令,交叉编译libffi + +```sh + +export CC="/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang --sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot" + +./configure --prefix=$PWD/install --host=aarch64-linux-ohos + +make && make install +``` + +![image-20251009175706346](pic/image-20251009175706346.png) + +![image-20251009175825681](pic/image-20251009175825681.png) + +![image-20251009175854834](pic/image-20251009175854834.png) + +#### 4、libuuid的交叉编译 + +* 在服务器的命令行执行下面的命令,进行libuuid的交叉编译 + +```sh +cd ../ + +wget https://downloads.sourceforge.net/project/libuuid/libuuid-1.0.3.tar.gz + +tar -xvf libuuid-1.0.3.tar.gz + +rm libuuid-1.0.3.tar.gz + +cd libuuid-1.0.3 + +# 修改 config.sub 文件: + +sed -i 's/| -kaos\*/| -kaos\* | -ohos\*/g' config.sub + +sed -i 's/linux-uclibc\*/linux-uclibc\* | linux-ohos\*/g' config.sub + +export CC="/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang --sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot" + +./configure --prefix=$PWD/install --enable-shared --host=aarch64-linux-ohos + +make && make install +``` + +![image-20251009180156789](pic/image-20251009180156789.png) + +![image-20251009180424732](pic/image-20251009180424732.png) + +![image-20251009180446492](pic/image-20251009180446492.png) + +![image-20251009180509397](pic/image-20251009180509397.png) + +#### 5、xz的交叉编译 + +* 在服务器的命令行执行下面的命令,进行xz的交叉编译 + +```sh +cd ../ + +wget https://tukaani.org/xz/xz-5.2.5.tar.gz +tar -zxvf xz-5.2.5.tar.gz +rm xz-5.2.5.tar.gz +cd xz-5.2.5 + +sed -i 's/| -kaos\*/| -kaos\* | -ohos\*/g' ./build-aux/config.sub +sed -i 's/linux-uclibc\*/linux-uclibc\* | linux-ohos\*/g' ./build-aux/config.sub + +export CC="/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang --sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot" + +./configure --prefix=$PWD/install --enable-shared --host=aarch64-linux-ohos + +make && make install +``` + +![image-20251009181033404](pic/image-20251009181033404.png) + +![image-20251009181219093](pic/image-20251009181219093.png) + +![image-20251009181250942](pic/image-20251009181250942.png) + +![image-20251009181318999](pic/image-20251009181318999.png) + +#### 6、readline的交叉编译 + +* 在服务器的命令行执行下面的命令,进行readline的交叉编译 + +```sh +cd ../ + +wget https://mirrors.aliyun.com/gnu/readline/readline-8.2.tar.gz +tar xzf readline-8.2.tar.gz +rm readline-8.2.tar.gz +cd readline-8.2 +``` + +![image-20251009191238117](pic/image-20251009191238117.png) + +* 修改 support/config.sub 文件中一处内容 + +* 在1757行添加 | ohos* +* 在1775行添加 | linux-ohos* + +![image-20251009193532253](pic/image-20251009193532253.png) + +* support/config.sub 文件保存好后,在服务器的命令行终端,分别执行下面的命令 + +```sh +export CC="/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin/aarch64-unknown-linux-ohos-clang --sysroot=/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot" + +./configure --host=aarch64-linux-ohos --prefix=$PWD/install --disable-install-examples + +make && make install +``` + +![image-20251009195217103](pic/image-20251009195217103.png) + +![image-20251009191946638](pic/image-20251009191946638.png) + +![image-20251009200013989](pic/image-20251009200013989.png) + +## 4、交叉编译python3.13.2 + +* 在服务器的命令行执行下面的命令,进行python3.13.2的交叉编译 + +```sh +cd ../ + +wget https://www.python.org/ftp/python/3.13.2/Python-3.13.2.tgz + +tar -xvzf Python-3.13.2.tgz + +rm Python-3.13.2.tgz + +cd Python-3.13.2 +``` + +* 修改 config.sub 文件中两处内容 + * 在1772行 添加: | ohos* + * 在 1833行添加: | linux-ohos*- + +image-20251009200915614 + +![image-20251009201117880](pic/image-20251009201117880.png) + +* 修改configure文件,将7021~7027行的内容 改为下面的内容 + +```sh +if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then + if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH = x; then + MULTIARCH=$PLATFORM_TRIPLET + fi +fi +``` + +* 修改前 + +![image-20251009201657474](pic/image-20251009201657474.png) + +* 修改后 + +![image-20251009201624874](pic/image-20251009201624874.png) + +* 执行下面的命令,交叉编译python + +```sh +CROSS_TOOLCHAIN_DIR="/home/openharmony/pegasus/os/OpenHarmony/ohos/prebuilts/clang/ohos/linux-x86_64/llvm/bin" +SYSROOT="/home/openharmony/pegasus/os/OpenHarmony/ohos/out/hispark_ss928v100/ipcamera_hispark_ss928v100_linux/sysroot" + +CC="${CROSS_TOOLCHAIN_DIR}/aarch64-unknown-linux-ohos-clang" \ +CXX="${CROSS_TOOLCHAIN_DIR}/aarch64-unknown-linux-ohos-clang++" \ +AR="${CROSS_TOOLCHAIN_DIR}/llvm-ar" \ +LD="${CROSS_TOOLCHAIN_DIR}/ld.lld" \ +RANLIB="${CROSS_TOOLCHAIN_DIR}/llvm-ranlib" \ +STRIP="${CROSS_TOOLCHAIN_DIR}/llvm-strip" \ +CFLAGS="--sysroot=${SYSROOT} -fPIC" \ +CXXFLAGS="--sysroot=${SYSROOT} -fPIC" \ +LDFLAGS="--sysroot=${SYSROOT}" \ +./configure \ +--host=aarch64-linux-ohos \ +--build=x86_64-pc-linux-gnu \ +--target=aarch64-linux-ohos \ +--prefix="$PWD/install" \ +--disable-ipv6 \ +ac_cv_file__dev_ptmx="yes" \ +ac_cv_file__dev_ptc="yes" \ +--with-openssl=../openssl-OpenSSL_1_1_1w/install \ +--with-build-python=python3.13 2>&1 | tee config.log.txt + +CFLAGS="-I../zlib-1.3.1/install/include \ + -I../xz-5.2.5/install/include \ + -I../libffi-3.4.7/install/include \ + -I../readline-8.2/install/include \ + -I../libuuid-1.0.3/install/include/uuid" +CPPFLAGS="-I../openssl-OpenSSL_1_1_1w/install/include" +LDFLAGS="-L../zlib-1.3.1/install/lib \ + -L../xz-5.2.5/install/lib \ + -L../libffi-3.4.7/install/lib \ + -L../readline-8.2/install/lib \ + -L../libuuid-1.0.3/install/lib \ + -L../openssl-OpenSSL_1_1_1w/install/lib" + +CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" make 2>&1 | tee make.log.txt +``` + +![image-20251009202143477](pic/image-20251009202143477.png) + +![image-20251009202450693](pic/image-20251009202450693.png) + +```sh +make install 2>1 | tee install.log.txt +``` + +![image-20251009202940688](pic/image-20251009202940688.png) + +![image-20251009203011267](pic/image-20251009203011267.png) + +## 5.板端测试 + +### 步骤1:配置板端环境 + +* 1、确保开发板已经烧录OpenHarmony操作系统 +* 2、使用网线将开发板与你的电脑进行连接,确保二者处于同一局域网内 +* 3、配置开发板的IP地址,并确保开发板与电脑能够互相ping通 + +```sh +# 注意:这里的eth0的IP地址,请根据自己的网络IP网段进行合理配置 +ifconfig eth0 192.168.100.100 + +# 添加权限 +echo 0 9999999 > /proc/sys/net/ipv4/ping_group_range +``` + +![image-20251010094441549](pic/image-20251010094441549.png) + +### 步骤2:准备python依赖文件 + +* 1、将第4章交叉编译python3.13.2后,生成的install文件夹拷贝到你的NFS挂载目录(如果没有网线,SD卡也是可以挂载到开发板的) +* 2、执行下面的,命令将电脑的nfs目录挂载到开发板的/mnt目录下(注意:这里请根据自己的IP地址及NFS配置进行合理的修改) + +```mk1.sh +mount -o nolock,addr=192.168.100.10 -t nfs 192.168.100.10:/d/nfs /mnt +``` + +![image-20251010100758153](pic/image-20251010100758153.png) + +* 3、配置python的环境变量,确保python运行时能够找到依赖 + +```mk1.sh +export PATH=/mnt/install/bin:$PATH +export PYTHONPATH=/mnt/install/lib/python3.13:$PYTHONPATH +export LD_LIBRARY_PATH=/mnt/install/lib/python3.13/lib-dynload:$LD_LIBRARY_PATH +``` + +image-20251010101732852 + +### 步骤3:运行python代码 + +* 如果第一次移植python3,需要给python3添加可执行权限才能运行 + +```sh +chmod +x /mnt/install/bin/python3 +``` + +* 输入python3,查看结果 + +![image-20251010101851439](pic/image-20251010101851439.png) + +* 在板端测试python代码,将下面的内容全部复制到 python_test.py 文件中 + +```python +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +print("Hello, World!") + +import os +import sys +import datetime + +def main(): + if sys.version_info < (3, 6): + print("Error: Requires Python 3.6 or higher") + sys.exit(1) + + current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + user = os.getenv("USER", "unknown_user") + +def multi_language(): + languages = { + "Chinese": "ni hao shijie ", + "Spanish": "?Hola Mundo!", + "French": "Bonjour le monde!", + "Japanese": "shijie nihao" + } + + try: + for lang, greeting in languages.items(): + print(f"{lang}: {greeting}") + except UnicodeEncodeError: + print("Encoding error detected. Try setting environment variable:") + print("export PYTHONIOENCODING=utf-8") + +if __name__ == "__main__": + main() + multi_language() + + # basic I/O + input("\nPress Enter to exit...") +``` + +* 使用下面命令,运行python_test.py代码,查看现象,如果现象如下图所示,说明移植成功 + +```sh +python3 python_test.py +``` + +image-20251010102204475 + diff --git a/vendor/zsks/docs/python/pic/image-20251009170325172.png b/vendor/zsks/docs/python/pic/image-20251009170325172.png new file mode 100755 index 0000000000000000000000000000000000000000..2acbe6f36b1d75ea359aae5f8a7912264ce0751e Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009170325172.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009171708407.png b/vendor/zsks/docs/python/pic/image-20251009171708407.png new file mode 100755 index 0000000000000000000000000000000000000000..704d95da933fe0d18f33d651fb18b9e936e3430f Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009171708407.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009171921919.png b/vendor/zsks/docs/python/pic/image-20251009171921919.png new file mode 100755 index 0000000000000000000000000000000000000000..7896aea248c4b1f73eefa3fc963b2dee3780dc65 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009171921919.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009172007367.png b/vendor/zsks/docs/python/pic/image-20251009172007367.png new file mode 100755 index 0000000000000000000000000000000000000000..48fc436f2e1b3fa0f9083d0202f4d9cdff368ec6 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009172007367.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009173438071.png b/vendor/zsks/docs/python/pic/image-20251009173438071.png new file mode 100755 index 0000000000000000000000000000000000000000..abd97d0442d4134130a4102c0bb5be8781218b64 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009173438071.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009173659012.png b/vendor/zsks/docs/python/pic/image-20251009173659012.png new file mode 100755 index 0000000000000000000000000000000000000000..d3c95af0bdef74808f59af6922f3c0dd9bdffc26 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009173659012.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009174036856.png b/vendor/zsks/docs/python/pic/image-20251009174036856.png new file mode 100755 index 0000000000000000000000000000000000000000..71cbbffc86935e2d55fcf0260092b5ccf46369ba Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009174036856.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009174105488.png b/vendor/zsks/docs/python/pic/image-20251009174105488.png new file mode 100755 index 0000000000000000000000000000000000000000..1dca90f249e54c3ba3a54f64c14b8236de38642a Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009174105488.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009174843560.png b/vendor/zsks/docs/python/pic/image-20251009174843560.png new file mode 100755 index 0000000000000000000000000000000000000000..093e8dbca1958a97b0a1a924934a76ac70ef7a42 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009174843560.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009174953996.png b/vendor/zsks/docs/python/pic/image-20251009174953996.png new file mode 100755 index 0000000000000000000000000000000000000000..54629a9e0f9d4aabf5a0e4f26b975c3ddfc0b209 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009174953996.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009175248076.png b/vendor/zsks/docs/python/pic/image-20251009175248076.png new file mode 100755 index 0000000000000000000000000000000000000000..f54f82efa876c74fa32b61354ce31124aafa8411 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009175248076.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009175416655.png b/vendor/zsks/docs/python/pic/image-20251009175416655.png new file mode 100755 index 0000000000000000000000000000000000000000..249a912c114736f43987c7481a4c1f701c903de0 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009175416655.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009175706346.png b/vendor/zsks/docs/python/pic/image-20251009175706346.png new file mode 100755 index 0000000000000000000000000000000000000000..9a5a4ce0e605560bcf3c853d002dabe295593cc9 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009175706346.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009175825681.png b/vendor/zsks/docs/python/pic/image-20251009175825681.png new file mode 100755 index 0000000000000000000000000000000000000000..a80c1f1487b94144385dac67027667510f35442f Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009175825681.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009175854834.png b/vendor/zsks/docs/python/pic/image-20251009175854834.png new file mode 100755 index 0000000000000000000000000000000000000000..98a944284bc9bed30571f197dfb8ff6744d5ddb8 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009175854834.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009180156789.png b/vendor/zsks/docs/python/pic/image-20251009180156789.png new file mode 100755 index 0000000000000000000000000000000000000000..c821dcdebb6d3969e9bd07d63d47fae318ee8f02 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009180156789.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009180424732.png b/vendor/zsks/docs/python/pic/image-20251009180424732.png new file mode 100755 index 0000000000000000000000000000000000000000..3e3e8b169d9ea66de61a28bfbced96c0b821f305 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009180424732.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009180446492.png b/vendor/zsks/docs/python/pic/image-20251009180446492.png new file mode 100755 index 0000000000000000000000000000000000000000..82a33c448dd5b2656b348bc758e55fae1fce7a9e Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009180446492.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009180509397.png b/vendor/zsks/docs/python/pic/image-20251009180509397.png new file mode 100755 index 0000000000000000000000000000000000000000..089d35f9b1d107605bcff947cecf7b259a83fec9 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009180509397.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009181033404.png b/vendor/zsks/docs/python/pic/image-20251009181033404.png new file mode 100755 index 0000000000000000000000000000000000000000..d250aaa0d7a0c36a7704cffa958e0f3f5347a161 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009181033404.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009181219093.png b/vendor/zsks/docs/python/pic/image-20251009181219093.png new file mode 100755 index 0000000000000000000000000000000000000000..4ba2d44bd45aaf792db002519040e12827990381 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009181219093.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009181250942.png b/vendor/zsks/docs/python/pic/image-20251009181250942.png new file mode 100755 index 0000000000000000000000000000000000000000..5afde18c86892741866744a0ad784183cb664a3e Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009181250942.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009181318999.png b/vendor/zsks/docs/python/pic/image-20251009181318999.png new file mode 100755 index 0000000000000000000000000000000000000000..6b54c6d96ea1576da55d790a0ffe4bf24b8954d4 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009181318999.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009191238117.png b/vendor/zsks/docs/python/pic/image-20251009191238117.png new file mode 100755 index 0000000000000000000000000000000000000000..abe489d74208fb6fdf472c96b57eddc938353e58 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009191238117.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009191946638.png b/vendor/zsks/docs/python/pic/image-20251009191946638.png new file mode 100755 index 0000000000000000000000000000000000000000..250a8349e41239e58e43688961617bbd320291c4 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009191946638.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009193532253.png b/vendor/zsks/docs/python/pic/image-20251009193532253.png new file mode 100755 index 0000000000000000000000000000000000000000..8c5764606b13d42c5454c0c106404b35ed4000c3 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009193532253.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009195217103.png b/vendor/zsks/docs/python/pic/image-20251009195217103.png new file mode 100755 index 0000000000000000000000000000000000000000..ede25b81fed5a4dbb470ee466eee3c02f2f211ff Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009195217103.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009200013989.png b/vendor/zsks/docs/python/pic/image-20251009200013989.png new file mode 100755 index 0000000000000000000000000000000000000000..1256aca756ed2b3604132215e1f12b37ce67cccc Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009200013989.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009200915614.png b/vendor/zsks/docs/python/pic/image-20251009200915614.png new file mode 100755 index 0000000000000000000000000000000000000000..ccca0579c41e1e2f42a48c1bcaafaf378a0de654 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009200915614.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009201117880.png b/vendor/zsks/docs/python/pic/image-20251009201117880.png new file mode 100755 index 0000000000000000000000000000000000000000..7ab251224398ad9a736fead3312777334bd83295 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009201117880.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009201624874.png b/vendor/zsks/docs/python/pic/image-20251009201624874.png new file mode 100755 index 0000000000000000000000000000000000000000..3604562217d5322d60a695d073753cbf4d9260e6 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009201624874.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009201657474.png b/vendor/zsks/docs/python/pic/image-20251009201657474.png new file mode 100755 index 0000000000000000000000000000000000000000..6d6a52ff1da0a37fc15e73fd5f8df8fbb0502d1c Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009201657474.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009202143477.png b/vendor/zsks/docs/python/pic/image-20251009202143477.png new file mode 100755 index 0000000000000000000000000000000000000000..12d778905520fd6a1b734edf450d9977677c9c24 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009202143477.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009202450693.png b/vendor/zsks/docs/python/pic/image-20251009202450693.png new file mode 100755 index 0000000000000000000000000000000000000000..08e1430c7f30533da40714205d12fd88a075e23f Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009202450693.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009202940688.png b/vendor/zsks/docs/python/pic/image-20251009202940688.png new file mode 100755 index 0000000000000000000000000000000000000000..c5385242c9f454412e5550fc9fc4d656d438c630 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009202940688.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251009203011267.png b/vendor/zsks/docs/python/pic/image-20251009203011267.png new file mode 100755 index 0000000000000000000000000000000000000000..bc9856619fb390f96226690c3659a30425bd0ec1 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251009203011267.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251010094441549.png b/vendor/zsks/docs/python/pic/image-20251010094441549.png new file mode 100755 index 0000000000000000000000000000000000000000..e981001ec636db595d2766310bf95a49e58f3914 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251010094441549.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251010100758153.png b/vendor/zsks/docs/python/pic/image-20251010100758153.png new file mode 100755 index 0000000000000000000000000000000000000000..736f301b3d0ea7959a6b1f1b7f23d3767d6945f8 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251010100758153.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251010101732852.png b/vendor/zsks/docs/python/pic/image-20251010101732852.png new file mode 100755 index 0000000000000000000000000000000000000000..94055797bd0dd668e7618a2c5d31c064914198b1 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251010101732852.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251010101851439.png b/vendor/zsks/docs/python/pic/image-20251010101851439.png new file mode 100755 index 0000000000000000000000000000000000000000..8921b22c17311aca77633404696f7a853cd557d5 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251010101851439.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251010102204475.png b/vendor/zsks/docs/python/pic/image-20251010102204475.png new file mode 100755 index 0000000000000000000000000000000000000000..307037ddcfe30cc5560341d337c06f5ad876a2db Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251010102204475.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251010143023136.png b/vendor/zsks/docs/python/pic/image-20251010143023136.png new file mode 100755 index 0000000000000000000000000000000000000000..2432a1dd7f3002c59b3a311276aa596efa692839 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251010143023136.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251010143136574.png b/vendor/zsks/docs/python/pic/image-20251010143136574.png new file mode 100755 index 0000000000000000000000000000000000000000..3e4887f3f65c92b3d964a3766ceab62b3ca80463 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251010143136574.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251010143226900.png b/vendor/zsks/docs/python/pic/image-20251010143226900.png new file mode 100755 index 0000000000000000000000000000000000000000..cab5f395641fff439c2ca4d25781d954c7672526 Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251010143226900.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251010143640847.png b/vendor/zsks/docs/python/pic/image-20251010143640847.png new file mode 100755 index 0000000000000000000000000000000000000000..93009cf6ef951ba857d5e3609938138f911c678d Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251010143640847.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251010144051579.png b/vendor/zsks/docs/python/pic/image-20251010144051579.png new file mode 100755 index 0000000000000000000000000000000000000000..d22c6a78869110a3633e5acea33c7540464f7f4b Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251010144051579.png differ diff --git a/vendor/zsks/docs/python/pic/image-20251010144137718.png b/vendor/zsks/docs/python/pic/image-20251010144137718.png new file mode 100755 index 0000000000000000000000000000000000000000..fc8d081784eb990a6c92c989b99faa5b13f8cd4c Binary files /dev/null and b/vendor/zsks/docs/python/pic/image-20251010144137718.png differ diff --git a/vendor/zsks/patch/0001-support-USB-Camera-and-zsks-demo.patch b/vendor/zsks/patch/0001-support-USB-Camera-and-zsks-demo.patch new file mode 100644 index 0000000000000000000000000000000000000000..9b13c291de9ffdc3effed949c8e2afe7ff3ec783 --- /dev/null +++ b/vendor/zsks/patch/0001-support-USB-Camera-and-zsks-demo.patch @@ -0,0 +1,411 @@ +From b72edbf57cebd3604021d92ba663c34d0a9bdb1a Mon Sep 17 00:00:00 2001 +From: wgm2022 <1480559020@qq.com> +Date: Thu, 30 Oct 2025 11:03:18 +0800 +Subject: [PATCH] support USB Camera and zsks demo + +--- + smp/a55_linux/mpp/sample/common/sample_comm.h | 6 + + .../mpp/sample/common/sample_comm_vdec.c | 251 ++++++++++++++++++ + .../mpp/sample/svp/common/sample_common_svp.c | 4 +- + .../mpp/sample/svp/common/sample_common_svp.h | 2 + + .../svp/common/sample_common_svp_npu_model.c | 28 ++ + 5 files changed, 289 insertions(+), 2 deletions(-) + +diff --git a/smp/a55_linux/mpp/sample/common/sample_comm.h b/smp/a55_linux/mpp/sample/common/sample_comm.h +index 10c8cbd..ac2a272 100644 +--- a/smp/a55_linux/mpp/sample/common/sample_comm.h ++++ b/smp/a55_linux/mpp/sample/common/sample_comm.h +@@ -538,6 +538,12 @@ typedef struct { + td_u64 last_time; + td_u64 time_gap; + td_u64 fps; ++# ifdef USE_USB_CAMERA ++ td_char *v4l2_device; // v4l2设备路径,如"/dev/video0" ++ td_u32 width; // 摄像头采集分辨率宽 ++ td_u32 height; // 摄像头采集分辨率高 ++ td_u32 pixel_format; // 像素格式(如V4L2_PIX_FMT_MJPEG) ++# endif + } vdec_thread_param; + + typedef struct { +diff --git a/smp/a55_linux/mpp/sample/common/sample_comm_vdec.c b/smp/a55_linux/mpp/sample/common/sample_comm_vdec.c +index a0c9ad9..1b9439e 100644 +--- a/smp/a55_linux/mpp/sample/common/sample_comm_vdec.c ++++ b/smp/a55_linux/mpp/sample/common/sample_comm_vdec.c +@@ -32,6 +32,18 @@ + #include + #include "sample_comm.h" + ++#ifdef USE_USB_CAMERA ++/* 新增v4l2相关头文件 */ ++#include // 文件控制 ++#include // POSIX API ++#include // IO控制 ++#include // 内存映射 ++#include // select复用 ++#include // v4l2核心 ++#include // 错误处理 ++#include // 字符串操作 ++#endif ++ + #define SEND_STREAM_CNT 5 + #define VDEC_SECOND 1000000 + #define SAMPLE_VDEC_LOW_DELAY_LINE_CNT 16 +@@ -633,6 +645,244 @@ td_s32 sample_comm_vdec_check_send_stream_param(vdec_thread_param *thread_param, + return TD_SUCCESS; + } + ++#ifdef USE_USB_CAMERA ++ ++td_void *sample_comm_vdec_send_stream(td_void *args) ++{ ++ printf("vdec send stream thread start\n"); ++ ++ vdec_thread_param *thread_param = (vdec_thread_param *)args; ++ ot_vdec_stream stream; ++ printf("sample_comm_vdec_send_stream v4l2 \r\n"); ++ // v4l2专用变量 ++ td_s32 v4l2_fd = -1; ++ struct v4l2_capability cap; ++ struct v4l2_format fmt; ++ struct v4l2_requestbuffers req; ++ struct v4l2_buffer v4l2_buf; ++ enum v4l2_buf_type buf_type; ++ fd_set fds; ++ struct timeval tv; ++ td_u8 *v4l2_buffers[4] = {NULL}; ++ td_u32 buffer_count = 0; ++ td_u32 max_buffer_length = 0; ++ ++ prctl(PR_SET_NAME, "v4l2_to_vdec", 0, 0, 0); ++ ++ // 参数验证 ++ if (thread_param == NULL) { ++ sample_print("线程参数为空!"); ++ return (td_void *)TD_FAILURE; ++ } ++ ++ sample_print("启动v4l2摄像头采集: %s", thread_param->v4l2_device); ++ ++ // 1. 打开v4l2设备 ++ v4l2_fd = open(thread_param->v4l2_device, O_RDWR | O_NONBLOCK, 0); ++ if (v4l2_fd < 0) { ++ sample_print("无法打开摄像头 %s: %s", ++ thread_param->v4l2_device, strerror(errno)); ++ return (td_void *)(TD_FAILURE); ++ } ++ ++ // 2. 查询设备能力 ++ if (ioctl(v4l2_fd, VIDIOC_QUERYCAP, &cap) < 0) { ++ sample_print("VIDIOC_QUERYCAP错误: %s", strerror(errno)); ++ goto v4l2_cleanup; ++ } ++ ++ if (!(cap.capabilities & V4L2_CAP_STREAMING)) { ++ sample_print("设备不支持流式传输"); ++ goto v4l2_cleanup; ++ } ++ ++ // 3. 设置视频格式 ++ memset(&fmt, 0, sizeof(fmt)); ++ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ++ fmt.fmt.pix.width = thread_param->width; ++ fmt.fmt.pix.height = thread_param->height; ++ fmt.fmt.pix.pixelformat = thread_param->pixel_format; ++ fmt.fmt.pix.field = V4L2_FIELD_ANY; ++ ++ if (ioctl(v4l2_fd, VIDIOC_S_FMT, &fmt) < 0) { ++ sample_print("VIDIOC_S_FMT错误: %s", strerror(errno)); ++ goto v4l2_cleanup; ++ } ++ ++ // 4. 设置帧率(可选) ++ struct v4l2_streamparm parm; ++ memset(&parm, 0, sizeof(parm)); ++ parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ++ parm.parm.capture.timeperframe.numerator = 1; ++ parm.parm.capture.timeperframe.denominator = thread_param->fps; ++ if (ioctl(v4l2_fd, VIDIOC_S_PARM, &parm) < 0) { ++ sample_print("设置帧率失败,使用默认值: %s", strerror(errno)); ++ } ++ ++ // 5. 请求缓冲区 ++ memset(&req, 0, sizeof(req)); ++ req.count = 4; // 使用4个缓冲区 ++ req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ++ req.memory = V4L2_MEMORY_MMAP; ++ ++ if (ioctl(v4l2_fd, VIDIOC_REQBUFS, &req) < 0) { ++ sample_print("VIDIOC_REQBUFS错误: %s", strerror(errno)); ++ goto v4l2_cleanup; ++ } ++ ++ buffer_count = req.count; ++ max_buffer_length = 0; ++ ++ // 6. 映射缓冲区 ++ for (td_u32 i = 0; i < buffer_count; ++i) { ++ memset(&v4l2_buf, 0, sizeof(v4l2_buf)); ++ v4l2_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ++ v4l2_buf.memory = V4L2_MEMORY_MMAP; ++ v4l2_buf.index = i; ++ ++ if (ioctl(v4l2_fd, VIDIOC_QUERYBUF, &v4l2_buf) < 0) { ++ sample_print("VIDIOC_QUERYBUF错误: %s", strerror(errno)); ++ goto v4l2_cleanup; ++ } ++ ++ // 记录最大缓冲区长度 ++ if (v4l2_buf.length > max_buffer_length) { ++ max_buffer_length = v4l2_buf.length; ++ } ++ ++ v4l2_buffers[i] = mmap(NULL, v4l2_buf.length, ++ PROT_READ | PROT_WRITE, ++ MAP_SHARED, ++ v4l2_fd, ++ v4l2_buf.m.offset); ++ ++ if (v4l2_buffers[i] == MAP_FAILED) { ++ sample_print("mmap失败: %s", strerror(errno)); ++ v4l2_buffers[i] = NULL; ++ goto v4l2_cleanup; ++ } ++ } ++ ++ // 7. 将缓冲区放入队列 ++ for (td_u32 i = 0; i < buffer_count; ++i) { ++ memset(&v4l2_buf, 0, sizeof(v4l2_buf)); ++ v4l2_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ++ v4l2_buf.memory = V4L2_MEMORY_MMAP; ++ v4l2_buf.index = i; ++ ++ if (ioctl(v4l2_fd, VIDIOC_QBUF, &v4l2_buf) < 0) { ++ sample_print("VIDIOC_QBUF错误: %s", strerror(errno)); ++ goto v4l2_cleanup; ++ } ++ } ++ ++ // 8. 启动视频流 ++ buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ++ if (ioctl(v4l2_fd, VIDIOC_STREAMON, &buf_type) < 0) { ++ sample_print("VIDIOC_STREAMON错误: %s", strerror(errno)); ++ goto v4l2_cleanup; ++ } ++ ++ sample_print("v4l2摄像头已启动: %s, %dx%d@%llufps, 格式: %c%c%c%c", ++ thread_param->v4l2_device, ++ thread_param->width, ++ thread_param->height, ++ thread_param->fps, ++ thread_param->pixel_format & 0xFF, ++ (thread_param->pixel_format >> 8) & 0xFF, ++ (thread_param->pixel_format >> 16) & 0xFF, ++ (thread_param->pixel_format >> 24) & 0xFF); ++ ++ // 9. 主循环:采集并发送到VDEC ++ while (thread_param->e_thread_ctrl == THREAD_CTRL_START) { ++ FD_ZERO(&fds); ++ FD_SET(v4l2_fd, &fds); ++ ++ // 设置超时时间(2秒) ++ tv.tv_sec = 2; ++ tv.tv_usec = 0; ++ ++ td_s32 r = select(v4l2_fd + 1, &fds, NULL, NULL, &tv); ++ if (r == -1) { ++ if (errno == EINTR) continue; // 被信号中断 ++ sample_print("select错误: %s", strerror(errno)); ++ break; ++ } ++ ++ if (r == 0) { ++ sample_print("select超时"); ++ continue; ++ } ++ ++ // 从队列获取缓冲区 ++ memset(&v4l2_buf, 0, sizeof(v4l2_buf)); ++ v4l2_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ++ v4l2_buf.memory = V4L2_MEMORY_MMAP; ++ ++ if (ioctl(v4l2_fd, VIDIOC_DQBUF, &v4l2_buf) < 0) { ++ sample_print("VIDIOC_DQBUF错误: %s", strerror(errno)); ++ continue; ++ } ++ ++ // 检查有效数据长度 ++ if (v4l2_buf.bytesused == 0) { ++ sample_print("接收到空帧"); ++ goto requeue_buffer; ++ } ++ ++ // 封装VDEC流结构 ++ memset(&stream, 0, sizeof(ot_vdec_stream)); ++ stream.addr = v4l2_buffers[v4l2_buf.index]; ++ stream.len = v4l2_buf.bytesused; ++ stream.end_of_stream = TD_FALSE; ++ ++ // 使用系统时间作为PTS ++ struct timeval now; ++ gettimeofday(&now, NULL); ++ stream.pts = now.tv_sec * 1000000 + now.tv_usec; // 单位微秒 ++ ++ // 发送到VDEC ++ td_s32 s32Ret = ss_mpi_vdec_send_stream(thread_param->chn_id, &stream, 30); // 30ms超时 ++ if (s32Ret != TD_SUCCESS) { ++ sample_print("发送到VDEC失败, ret=%#x", s32Ret); ++ } ++ ++requeue_buffer: ++ // 将缓冲区重新放回队列 ++ if (ioctl(v4l2_fd, VIDIOC_QBUF, &v4l2_buf) < 0) { ++ sample_print("VIDIOC_QBUF错误: %s", strerror(errno)); ++ break; ++ } ++ } ++ ++ // 10. 发送流结束标志 ++ memset(&stream, 0, sizeof(ot_vdec_stream)); ++ stream.end_of_stream = TD_TRUE; ++ ss_mpi_vdec_send_stream(thread_param->chn_id, &stream, -1); ++ ++ sample_print("v4l2采集线程退出"); ++ ++v4l2_cleanup: ++ // 11. 停止视频流 ++ if (v4l2_fd >= 0) { ++ buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ++ ioctl(v4l2_fd, VIDIOC_STREAMOFF, &buf_type); ++ } ++ ++ // 12. 释放v4l2资源 ++ for (td_u32 i = 0; i < buffer_count; ++i) { ++ if (v4l2_buffers[i]) { ++ munmap(v4l2_buffers[i], max_buffer_length); ++ } ++ } ++ ++ if (v4l2_fd >= 0) { ++ close(v4l2_fd); ++ } ++ ++ return (td_void *)TD_SUCCESS; ++} ++#else + td_void *sample_comm_vdec_send_stream(td_void *args) + { + vdec_thread_param *thread_param = (vdec_thread_param *)args; +@@ -691,6 +941,7 @@ end1: + path = TD_NULL; + return (td_void *)TD_SUCCESS; + } ++#endif + + td_void sample_comm_vdec_cmd_not_circle_send(td_u32 chn_num, vdec_thread_param *vdec_send, + pthread_t *vdec_thread, td_u32 send_arr_len, td_u32 thread_arr_len) +diff --git a/smp/a55_linux/mpp/sample/svp/common/sample_common_svp.c b/smp/a55_linux/mpp/sample/svp/common/sample_common_svp.c +index 3b3b289..c37bbc1 100644 +--- a/smp/a55_linux/mpp/sample/svp/common/sample_common_svp.c ++++ b/smp/a55_linux/mpp/sample/svp/common/sample_common_svp.c +@@ -428,7 +428,7 @@ static td_void sample_common_svp_stop_vpss(td_s32 vpss_grp_cnt, td_u32 vpss_chn_ + } + } + +-static td_s32 sample_common_svp_get_def_vo_cfg(sample_vo_cfg *vo_cfg) ++td_s32 sample_common_svp_get_def_vo_cfg(sample_vo_cfg *vo_cfg) + { + ot_rect def_disp_rect = {0, 0, 1920, 1080}; + ot_size def_img_size = {1920, 1080}; +@@ -441,7 +441,7 @@ static td_s32 sample_common_svp_get_def_vo_cfg(sample_vo_cfg *vo_cfg) + vo_cfg->vo_dev = SAMPLE_VO_DEV_UHD; + + vo_cfg->vo_intf_type = OT_VO_INTF_HDMI; +- vo_cfg->intf_sync = OT_VO_OUT_1080P30; ++ vo_cfg->intf_sync = OT_VO_OUT_1080P60; + vo_cfg->bg_color = COLOR_RGB_BLACK; + vo_cfg->pix_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_420; + vo_cfg->disp_rect = def_disp_rect; +diff --git a/smp/a55_linux/mpp/sample/svp/common/sample_common_svp.h b/smp/a55_linux/mpp/sample/svp/common/sample_common_svp.h +index 626a2d6..dd86d96 100644 +--- a/smp/a55_linux/mpp/sample/svp/common/sample_common_svp.h ++++ b/smp/a55_linux/mpp/sample/svp/common/sample_common_svp.h +@@ -60,6 +60,8 @@ typedef enum { + + typedef struct { + ot_point point[OT_POINT_NUM]; ++ td_float score; ++ td_u16 class_id; + } ot_sample_svp_rect; + + typedef struct { +diff --git a/smp/a55_linux/mpp/sample/svp/common/sample_common_svp_npu_model.c b/smp/a55_linux/mpp/sample/svp/common/sample_common_svp_npu_model.c +index 3f811f0..c1f4b5b 100644 +--- a/smp/a55_linux/mpp/sample/svp/common/sample_common_svp_npu_model.c ++++ b/smp/a55_linux/mpp/sample/svp/common/sample_common_svp_npu_model.c +@@ -999,6 +999,8 @@ static td_s32 sample_svp_npu_get_roi(const sample_svp_npu_task_info *task, const + td_float *y_min = TD_NULL; + td_float *x_max = TD_NULL; + td_float *y_max = TD_NULL; ++ td_float *score = TD_NULL; ++ td_float *class_id = TD_NULL; + td_u32 roi_offset = info->roi_offset; + td_u32 i; + +@@ -1019,6 +1021,8 @@ static td_s32 sample_svp_npu_get_roi(const sample_svp_npu_task_info *task, const + y_min = x_min + stride / sizeof(td_float); + x_max = y_min + stride / sizeof(td_float); + y_max = x_max + stride / sizeof(td_float); ++ score = y_max + stride / sizeof(td_float); ++ class_id = score + stride / sizeof(td_float); + + for (i = 0; i < rect_info->num; i++) { + rect_info->rect[i].point[SAMPLE_SVP_NPU_RECT_LEFT_TOP].x = (td_u32)((td_float)x_min[roi_offset] / +@@ -1040,6 +1044,10 @@ static td_s32 sample_svp_npu_get_roi(const sample_svp_npu_task_info *task, const + rect_info->rect[i].point[SAMPLE_SVP_NPU_RECT_LEFT_TOP].x; + rect_info->rect[i].point[SAMPLE_SVP_NPU_RECT_LEFT_BOTTOM].y = + rect_info->rect[i].point[SAMPLE_SVP_NPU_RECT_RIGHT_BOTTOM].y; ++ ++ rect_info->rect[i].score = (td_float)((td_float)score[roi_offset]); ++ rect_info->rect[i].class_id = (td_u16)((td_float)class_id[roi_offset]); ++ + roi_offset++; + } + return TD_SUCCESS; +@@ -1319,6 +1327,9 @@ td_s32 sample_common_svp_npu_roi_to_rect(const sample_svp_npu_task_info *task, + const ot_video_frame_info *show_frame, ot_sample_svp_rect_info *rect_info) + { + td_s32 ret; ++ td_u32 i; ++ td_float max_confidence = 0.0f; ++ td_u32 max_index = 0; + + if (sample_svp_check_task_cfg(task) != TD_SUCCESS) { + sample_svp_trace_err("check task cfg failed!\n"); +@@ -1342,6 +1353,23 @@ td_s32 sample_common_svp_npu_roi_to_rect(const sample_svp_npu_task_info *task, + sample_svp_check_exps_return(ret != TD_SUCCESS, TD_FAILURE, SAMPLE_SVP_ERR_LEVEL_ERROR, + "get roi failed!\n"); + ++ // �������֣�ɸѡ���Ŷ���ߵľ��ο� ++ if (rect_info->num > 0) { ++ // 1. �������Ŷ���ߵľ��ο� ++ for (i = 0; i < rect_info->num; i++) { ++ if (rect_info->rect[i].score > max_confidence) { ++ max_confidence = rect_info->rect[i].score; ++ max_index = i; ++ } ++ } ++ ++ // 2. ֻ�������Ŷ���ߵľ��ο� ++ if (rect_info->num > 1) { ++ rect_info->rect[0] = rect_info->rect[max_index]; ++ rect_info->num = 1; ++ } ++ } ++ + return TD_SUCCESS; + } + +-- +2.34.1 + diff --git a/vendor/zsks/patch/0002-support-os04a10-and-hnr.patch b/vendor/zsks/patch/0002-support-os04a10-and-hnr.patch new file mode 100644 index 0000000000000000000000000000000000000000..c5efe720f1f9ed966fea9d67d8b0cadf9a17ce98 --- /dev/null +++ b/vendor/zsks/patch/0002-support-os04a10-and-hnr.patch @@ -0,0 +1,5549 @@ +From 1e4af3685897bf5d64b442ea49b8fab5dff48dd0 Mon Sep 17 00:00:00 2001 +From: wgm2022 <1480559020@qq.com> +Date: Thu, 30 Oct 2025 11:06:50 +0800 +Subject: [PATCH] support os04a10 and hnr + +--- + smp/a55_linux/mpp/sample/Makefile | 2 +- + smp/a55_linux/mpp/sample/Makefile.param | 10 +- + smp/a55_linux/mpp/sample/common/sample_comm.h | 2 + + .../mpp/sample/common/sample_comm_isp.c | 44 + + .../mpp/sample/common/sample_comm_vi.c | 94 +- + .../mpp/sample/common/sdk_module_init.h | 2 +- + smp/a55_linux/mpp/sample/hnr/sample_hnr.c | 38 +- + .../mpp/sample/omnivision_os04a10/Makefile | 56 + + .../sample/omnivision_os04a10/os04a10_cmos.c | 1140 ++++++ + .../sample/omnivision_os04a10/os04a10_cmos.h | 84 + + .../omnivision_os04a10/os04a10_cmos_ex.h | 3097 +++++++++++++++++ + .../omnivision_os04a10/os04a10_sensor_ctl.c | 585 ++++ + smp/a55_linux/mpp/sample/vio/sample_vio.c | 17 +- + 13 files changed, 5143 insertions(+), 28 deletions(-) + create mode 100644 smp/a55_linux/mpp/sample/omnivision_os04a10/Makefile + create mode 100644 smp/a55_linux/mpp/sample/omnivision_os04a10/os04a10_cmos.c + create mode 100644 smp/a55_linux/mpp/sample/omnivision_os04a10/os04a10_cmos.h + create mode 100644 smp/a55_linux/mpp/sample/omnivision_os04a10/os04a10_cmos_ex.h + create mode 100644 smp/a55_linux/mpp/sample/omnivision_os04a10/os04a10_sensor_ctl.c + +diff --git a/smp/a55_linux/mpp/sample/Makefile b/smp/a55_linux/mpp/sample/Makefile +index 10ed1c4..3cf2899 100644 +--- a/smp/a55_linux/mpp/sample/Makefile ++++ b/smp/a55_linux/mpp/sample/Makefile +@@ -3,7 +3,7 @@ ifeq ($(PARAM_FILE), ) + include $(PARAM_FILE) + endif + +-target=$(shell ls -d */ | sed "s;/;;g" | grep -v "common\|aisr\|avs\|mcf\|PHOTO\|heif\|hnr\|uvc\|scene_auto\|svc_rate_auto\|hy_s0603") ++target=$(shell ls -d */ | sed "s;/;;g" | grep -v "common\|aisr\|avs\|mcf\|PHOTO\|heif\|hnr\|uvc\|scene_auto\|svc_rate_auto\|hy_s0603\|omnivision_os04a10") + + target_clean=$(addsuffix _clean,$(target)) + +diff --git a/smp/a55_linux/mpp/sample/Makefile.param b/smp/a55_linux/mpp/sample/Makefile.param +index 553b29d..1980868 100644 +--- a/smp/a55_linux/mpp/sample/Makefile.param ++++ b/smp/a55_linux/mpp/sample/Makefile.param +@@ -7,13 +7,14 @@ endif + ################# select sensor type for your sample ############################### + #### HY_S0603_MIPI_8M_30FPS_12BIT ################# + #### HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1 ################# ++#### OV_OS04A10_MIPI_4M_30FPS_12BIT ################# + + ## change sensor type here. default: hy_s0603 + +-SENSOR0_TYPE ?= HY_S0603_MIPI_8M_30FPS_12BIT +-SENSOR1_TYPE ?= HY_S0603_MIPI_8M_30FPS_12BIT +-SENSOR2_TYPE ?= HY_S0603_MIPI_8M_30FPS_12BIT +-SENSOR3_TYPE ?= HY_S0603_MIPI_8M_30FPS_12BIT ++SENSOR0_TYPE ?= OV_OS04A10_MIPI_4M_30FPS_12BIT ++SENSOR1_TYPE ?= OV_OS04A10_MIPI_4M_30FPS_12BIT ++SENSOR2_TYPE ?= OV_OS04A10_MIPI_4M_30FPS_12BIT ++SENSOR3_TYPE ?= OV_OS04A10_MIPI_4M_30FPS_12BIT + + MPI_LIBS := $(REL_LIB)/libss_mpi.a + +@@ -33,6 +34,7 @@ MPI_LIBS += $(REL_LIB)/libss_ir_auto.a + MPI_LIBS += $(REL_LIB)/libss_acs.a + MPI_LIBS += $(REL_LIB)/libss_acs.a + MPI_LIBS += $(REL_LIB)/libsns_hy_s0603.a ++MPI_LIBS += $(REL_LIB)/libsns_os04a10.a + endif + + +diff --git a/smp/a55_linux/mpp/sample/common/sample_comm.h b/smp/a55_linux/mpp/sample/common/sample_comm.h +index ac2a272..faf674f 100644 +--- a/smp/a55_linux/mpp/sample/common/sample_comm.h ++++ b/smp/a55_linux/mpp/sample/common/sample_comm.h +@@ -232,6 +232,8 @@ typedef enum { + typedef enum { + HY_S0603_MIPI_8M_30FPS_12BIT, + HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1, ++ OV_OS04A10_MIPI_4M_30FPS_12BIT, ++ OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1, + SNS_TYPE_BUTT, + } sample_sns_type; + +diff --git a/smp/a55_linux/mpp/sample/common/sample_comm_isp.c b/smp/a55_linux/mpp/sample/common/sample_comm_isp.c +index 52d2aaf..bf6e417 100644 +--- a/smp/a55_linux/mpp/sample/common/sample_comm_isp.c ++++ b/smp/a55_linux/mpp/sample/common/sample_comm_isp.c +@@ -53,6 +53,7 @@ static ot_isp_sns_type g_sns_type[OT_VI_MAX_PIPE_NUM] = {(ot_isp_sns_type)SNS_TY + static pthread_t g_isp_pid[OT_VI_MAX_DEV_NUM] = {0}; + + extern ot_isp_sns_obj g_sns_hy_s0603_obj; ++extern ot_isp_sns_obj g_sns_os04a10_obj; + + /* IspPub attr */ + static ot_isp_pub_attr g_isp_pub_attr_hy_s0603_mipi_8m_30fps = { +@@ -85,6 +86,38 @@ static ot_isp_pub_attr g_isp_pub_attr_hy_s0603_mipi_8m_30fps_wdr2to1 = { + }, + }; + ++static ot_isp_pub_attr g_isp_pub_attr_ov_os04a10_mipi_4m_30fps = { ++ {0, 0, WIDTH_2688, HEIGHT_1520}, ++ {WIDTH_2688, HEIGHT_1520}, ++ 30, ++ OT_ISP_BAYER_RGGB, ++ OT_WDR_MODE_NONE, ++ 0, ++ 0, ++ 0, ++ { ++ 0, ++ {0, 0, 2688, 1520}, ++ }, ++}; ++ ++static ot_isp_pub_attr g_isp_pub_attr_ov_os04a10_mipi_4m_30fps_wdr2to1 = { ++ {0, 0, WIDTH_2688, HEIGHT_1520}, ++ {WIDTH_2688, HEIGHT_1520}, ++ 30, ++ OT_ISP_BAYER_RGGB, ++ OT_WDR_MODE_2To1_LINE, ++ 0, ++ 0, ++ 0, ++ { ++ 0, ++ {0, 0, 2688, 1520}, ++ }, ++}; ++ ++ ++ + td_s32 sample_comm_isp_get_pub_attr_by_sns(sample_sns_type sns_type, ot_isp_pub_attr *pub_attr) + { + switch (sns_type) { +@@ -96,6 +129,14 @@ td_s32 sample_comm_isp_get_pub_attr_by_sns(sample_sns_type sns_type, ot_isp_pub_ + (td_void)memcpy_s(pub_attr, sizeof(ot_isp_pub_attr), + &g_isp_pub_attr_hy_s0603_mipi_8m_30fps_wdr2to1, sizeof(ot_isp_pub_attr)); + break; ++ case OV_OS04A10_MIPI_4M_30FPS_12BIT: ++ (td_void)memcpy_s(pub_attr, sizeof(ot_isp_pub_attr), ++ &g_isp_pub_attr_ov_os04a10_mipi_4m_30fps, sizeof(ot_isp_pub_attr)); ++ break; ++ case OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1: ++ (td_void)memcpy_s(pub_attr, sizeof(ot_isp_pub_attr), ++ &g_isp_pub_attr_ov_os04a10_mipi_4m_30fps_wdr2to1, sizeof(ot_isp_pub_attr)); ++ break; + default: + (td_void)memcpy_s(pub_attr, sizeof(ot_isp_pub_attr), + &g_isp_pub_attr_hy_s0603_mipi_8m_30fps, sizeof(ot_isp_pub_attr)); +@@ -111,6 +152,9 @@ ot_isp_sns_obj *sample_comm_isp_get_sns_obj(sample_sns_type sns_type) + case HY_S0603_MIPI_8M_30FPS_12BIT: + case HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1: + return &g_sns_hy_s0603_obj; ++ case OV_OS04A10_MIPI_4M_30FPS_12BIT: ++ case OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1: ++ return &g_sns_os04a10_obj; + default: + return TD_NULL; + } +diff --git a/smp/a55_linux/mpp/sample/common/sample_comm_vi.c b/smp/a55_linux/mpp/sample/common/sample_comm_vi.c +index 3e5325d..9b5c0d5 100644 +--- a/smp/a55_linux/mpp/sample/common/sample_comm_vi.c ++++ b/smp/a55_linux/mpp/sample/common/sample_comm_vi.c +@@ -111,6 +111,43 @@ static combo_dev_attr_t g_mipi_4lane_chn0_sensor_hy_s0603_10bit_8m_wdr2to1_attr + } + }; + ++static combo_dev_attr_t g_mipi_4lane_chn0_sensor_ov_os04a10_12bit_4m_nowdr_attr = { ++ .devno = 0, ++ .input_mode = INPUT_MODE_MIPI, ++ .data_rate = MIPI_DATA_RATE_X1, ++ .img_rect = {0, 0, WIDTH_2688, HEIGHT_1520}, ++ .mipi_attr = { ++ DATA_TYPE_RAW_12BIT, ++ OT_MIPI_WDR_MODE_NONE, ++ {0, 1, 2, 3, -1, -1, -1, -1} ++ } ++}; ++ ++static combo_dev_attr_t g_mipi_4lane_chn0_sensor_ov_os04a10_12bit_4m_nowdr_dev2_attr = { ++ .devno = 2, /* dev2 */ ++ .input_mode = INPUT_MODE_MIPI, ++ .data_rate = MIPI_DATA_RATE_X1, ++ .img_rect = {0, 0, WIDTH_2688, HEIGHT_1520}, ++ .mipi_attr = { ++ DATA_TYPE_RAW_12BIT, ++ OT_MIPI_WDR_MODE_NONE, ++ {4, 5, 6, 7, -1, -1, -1, -1} ++ } ++}; ++ ++static combo_dev_attr_t g_mipi_4lane_chn0_sensor_ov_os04a10_10bit_4m_wdr2to1_attr = { ++ .devno = 0, ++ .input_mode = INPUT_MODE_MIPI, ++ .data_rate = MIPI_DATA_RATE_X1, ++ .img_rect = {0, 0, WIDTH_2688, HEIGHT_1520}, ++ .mipi_attr = { ++ DATA_TYPE_RAW_10BIT, ++ OT_MIPI_WDR_MODE_VC, ++ {0, 1, 2, 3, -1, -1, -1, -1} ++ } ++}; ++ ++ + static td_void sample_comm_vi_get_mipi_attr(sample_sns_type sns_type, combo_dev_attr_t *combo_attr) + { + td_u32 ob_height = OB_HEIGHT_START; +@@ -120,15 +157,25 @@ static td_void sample_comm_vi_get_mipi_attr(sample_sns_type sns_type, combo_dev_ + (td_void)memcpy_s(combo_attr, sizeof(combo_dev_attr_t), + &g_mipi_4lane_chn0_sensor_hy_s0603_12bit_8m_nowdr_attr, sizeof(combo_dev_attr_t)); + break; +- case HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1: ++ case HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1: + ob_height = OB_HEIGHT_END; + (td_void)memcpy_s(combo_attr, sizeof(combo_dev_attr_t), + &g_mipi_4lane_chn0_sensor_hy_s0603_10bit_8m_wdr2to1_attr, sizeof(combo_dev_attr_t)); + break; ++ case OV_OS04A10_MIPI_4M_30FPS_12BIT: ++ //ob_height = OB_HEIGHT_END; ++ (td_void)memcpy_s(combo_attr, sizeof(combo_dev_attr_t), ++ &g_mipi_4lane_chn0_sensor_ov_os04a10_12bit_4m_nowdr_attr, sizeof(combo_dev_attr_t)); ++ break; ++ case OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1: ++ ob_height = OB_HEIGHT_END; ++ (td_void)memcpy_s(combo_attr, sizeof(combo_dev_attr_t), ++ &g_mipi_4lane_chn0_sensor_ov_os04a10_10bit_4m_wdr2to1_attr, sizeof(combo_dev_attr_t)); ++ break; + + default: + (td_void)memcpy_s(combo_attr, sizeof(combo_dev_attr_t), +- &g_mipi_4lane_chn0_sensor_hy_s0603_12bit_8m_nowdr_attr, sizeof(combo_dev_attr_t)); ++ &g_mipi_4lane_chn0_sensor_ov_os04a10_12bit_4m_nowdr_attr, sizeof(combo_dev_attr_t)); + } + combo_attr->img_rect.height = combo_attr->img_rect.height + ob_height; + } +@@ -138,9 +185,17 @@ static td_void sample_comm_vi_get_mipi_ext_data_attr(sample_sns_type sns_type, e + switch (sns_type) { + case HY_S0603_MIPI_8M_30FPS_12BIT: + case HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1: ++ case OV_OS04A10_MIPI_4M_30FPS_12BIT: ++ case OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1: + (td_void)memcpy_s(ext_data_attr, sizeof(ext_data_type_t), + &g_mipi_ext_data_type_12bit_8m_nowdr_attr, sizeof(ext_data_type_t)); + break; ++ //case OV_OS04A10_MIPI_4M_30FPS_12BIT: ++ //case OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1: ++ // (td_void)memcpy_s(ext_data_attr, sizeof(ext_data_type_t), ++ // &g_mipi_ext_data_type_12bit_8m_nowdr_attr, sizeof(ext_data_type_t)); ++ // break; ++ + + default: + (td_void)memcpy_s(ext_data_attr, sizeof(ext_data_type_t), +@@ -164,7 +219,16 @@ static td_void sample_comm_vi_get_mipi_attr_by_dev_id(sample_sns_type sns_type, + &g_mipi_4lane_chn0_sensor_hy_s0603_12bit_8m_nowdr_dev2_attr, sizeof(combo_dev_attr_t)); + } + break; +- ++ case OV_OS04A10_MIPI_4M_30FPS_12BIT: ++ //ob_height = OB_HEIGHT_END; ++ if (vi_dev == 0) { ++ (td_void)memcpy_s(combo_attr, sizeof(combo_dev_attr_t), ++ &g_mipi_4lane_chn0_sensor_ov_os04a10_12bit_4m_nowdr_attr, sizeof(combo_dev_attr_t)); ++ } else if (vi_dev == 2) { /* dev2 */ ++ (td_void)memcpy_s(combo_attr, sizeof(combo_dev_attr_t), ++ &g_mipi_4lane_chn0_sensor_ov_os04a10_12bit_4m_nowdr_dev2_attr, sizeof(combo_dev_attr_t)); ++ } ++ break; + + default: + (td_void)memcpy_s(combo_attr, sizeof(combo_dev_attr_t), +@@ -215,10 +279,12 @@ static ot_vi_dev_attr g_mipi_raw_dev_attr = { + .data_reverse = TD_FALSE, + + /* input size */ +- .in_size = {WIDTH_3840, HEIGHT_2160}, +- ++ .in_size = {WIDTH_2688, HEIGHT_1520}, ++ //.in_size = {WIDTH_3840, HEIGHT_2160}, ++ + /* data rate */ + .data_rate = OT_DATA_RATE_X1, ++ + }; + + static td_void sample_comm_vi_get_dev_attr_by_intf_mode(ot_vi_intf_mode intf_mode, ot_vi_dev_attr *dev_attr) +@@ -242,6 +308,11 @@ td_void sample_comm_vi_get_size_by_sns_type(sample_sns_type sns_type, ot_size *s + size->width = WIDTH_3840; + size->height = HEIGHT_2160; + break; ++ case OV_OS04A10_MIPI_4M_30FPS_12BIT: ++ case OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1: ++ size->width = WIDTH_2688; ++ size->height = HEIGHT_1520; ++ break; + + default: + size->width = WIDTH_1920; +@@ -258,6 +329,11 @@ td_u32 sample_comm_vi_get_obheight_by_sns_type(sample_sns_type sns_type) + case HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1: + ob_height = OB_HEIGHT_END; + break; ++ case OV_OS04A10_MIPI_4M_30FPS_12BIT: ++ case OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1: ++ ob_height = OB_HEIGHT_START; ++ break; ++ + default: + break; + } +@@ -269,8 +345,10 @@ static td_u32 sample_comm_vi_get_pipe_num_by_sns_type(sample_sns_type sns_type) + { + switch (sns_type) { + case HY_S0603_MIPI_8M_30FPS_12BIT: ++ case OV_OS04A10_MIPI_4M_30FPS_12BIT: + return 1; + case HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1: ++ case OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1: + return 2; /* 2 pipe */ + + default: +@@ -282,9 +360,11 @@ static ot_wdr_mode sample_comm_vi_get_wdr_mode_by_sns_type(sample_sns_type sns_t + { + switch (sns_type) { + case HY_S0603_MIPI_8M_30FPS_12BIT: ++ case OV_OS04A10_MIPI_4M_30FPS_12BIT: + return OT_WDR_MODE_NONE; + + case HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1: ++ case OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1: + return OT_WDR_MODE_2To1_LINE; + + default: +@@ -297,7 +377,7 @@ td_void sample_comm_vi_get_default_sns_info(sample_sns_type sns_type, sample_sns + sns_info->sns_type = sns_type; + sns_info->sns_clk_src = 0; + sns_info->sns_rst_src = 0; +- sns_info->bus_id = 2; /* i2c2 */ ++ sns_info->bus_id = 5; /* i2c -- 2 */ + } + + td_void sample_comm_vi_get_default_mipi_info(sample_sns_type sns_type, sample_mipi_info *mipi_info) +@@ -2514,4 +2594,4 @@ td_s32 sample_comm_vi_send_wdr_frame(ot_vi_bind_pipe *bind_pipe) + g_send_pipe_pthread = TD_FALSE; + pthread_join(thread_id, TD_NULL); + return ret; +-} +\ No newline at end of file ++} +diff --git a/smp/a55_linux/mpp/sample/common/sdk_module_init.h b/smp/a55_linux/mpp/sample/common/sdk_module_init.h +index 0c788c0..54f1930 100644 +--- a/smp/a55_linux/mpp/sample/common/sdk_module_init.h ++++ b/smp/a55_linux/mpp/sample/common/sdk_module_init.h +@@ -24,7 +24,7 @@ + extern "C" { + #endif + +-#define INIT_PQP 0 ++#define INIT_PQP 1 + + int ot_base_mod_init(void); + int ot_sys_mod_init(void); +diff --git a/smp/a55_linux/mpp/sample/hnr/sample_hnr.c b/smp/a55_linux/mpp/sample/hnr/sample_hnr.c +index 8aa1da6..965aa64 100755 +--- a/smp/a55_linux/mpp/sample/hnr/sample_hnr.c ++++ b/smp/a55_linux/mpp/sample/hnr/sample_hnr.c +@@ -66,7 +66,7 @@ static sample_hnr_snap_thread_info g_snap_thread_info; + static sample_vo_cfg g_vo_cfg = { + .vo_dev = SAMPLE_VO_DEV_UHD, + .vo_intf_type = OT_VO_INTF_HDMI, +- .intf_sync = OT_VO_OUT_1080P30, ++ .intf_sync = OT_VO_OUT_1080P60, + .bg_color = COLOR_RGB_BLACK, + .pix_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_420, + .disp_rect = {0, 0, VO_WIDTH, VO_HEIGTH}, +@@ -349,6 +349,8 @@ static td_void sample_hnr_unload_cfg(ot_hnr_cfg *hnr_cfg, ot_hnr_ref_mode ref_mo + static td_s32 sample_hnr_start(ot_vi_pipe vi_pipe, ot_size in_size, ot_hnr_cfg *hnr_cfg, + sample_hnr_param *hnr_param) + { ++ printf("----step9_1: ss_mpi_hnr_init\n"); ++ printf("-------w=%d, h=%d \n" , in_size.width, in_size.height); + td_s32 ret = ss_mpi_hnr_init(); + ot_hnr_alg_cfg attr; + +@@ -357,26 +359,31 @@ static td_s32 sample_hnr_start(ot_vi_pipe vi_pipe, ot_size in_size, ot_hnr_cfg * + return ret; + } + ++ printf("----step9_2: sample_hnr_load_cfg\n"); + ret = sample_hnr_load_cfg(in_size, hnr_cfg, hnr_param->ref_mode); + if (ret != TD_SUCCESS) { + goto task_exit; + } + + attr.ref_mode = hnr_param->ref_mode; /* ref mode NORM: need reference frame; NONE: no reference frame */ ++ printf("----step9_3: ss_mpi_hnr_set_alg_cfg\n"); + ret = ss_mpi_hnr_set_alg_cfg(vi_pipe, &attr); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_hnr_set_alg_cfg error(%#x)\n", ret); + goto unload_cfg; + } + ++ printf("----step9_4: sample_get_char\n"); + sample_get_char("enable hnr"); + ++ printf("----step9_5: ss_mpi_hnr_enable\n"); + ret = ss_mpi_hnr_enable(vi_pipe); + if (ret != TD_SUCCESS) { + sample_print("ss_mpi_hnr_enable error(%#x)\n", ret); + goto unload_cfg; + } + ++ printf("----step9_4: sample_hnr_set_attr\n"); + ret = sample_hnr_set_attr(vi_pipe, hnr_param); + if (ret != TD_SUCCESS) { + sample_print("sample_hnr_set_attr error(%#x)\n", ret); +@@ -934,8 +941,10 @@ static td_s32 sample_hnr_line_switch_to_wdr(td_void) + + if (sns_type == HY_S0603_MIPI_8M_30FPS_12BIT) { + sns_type = HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1; ++ } else if (sns_type == OV_OS04A10_MIPI_4M_30FPS_12BIT) { ++ sns_type = OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1; + } else { +- sns_type = HY_S0603_MIPI_8M_30FPS_12BIT; ++ sns_type = OV_OS04A10_MIPI_4M_30FPS_12BIT; + } + + ret = sample_hnr_switch_second_route_wdr(sns_type, &hnr_cfg); +@@ -989,7 +998,7 @@ static td_s32 sample_hnr(sample_hnr_param *hnr_param) + { + td_s32 ret = TD_FAILURE; + sample_vi_cfg vi_cfg; +- sample_sns_type sns_type = hnr_param->is_wdr_mode ? HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1 : SENSOR0_TYPE; ++ sample_sns_type sns_type = hnr_param->is_wdr_mode ? OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1 : SENSOR0_TYPE; + const td_u32 vb_cnt = sample_hnr_get_vb_cnt(hnr_param); + const ot_vi_pipe vi_pipe = hnr_param->is_wdr_mode ? 1 : 0; /* 1-long frame of wdr */ + const ot_vi_pipe master_pipe = 0; +@@ -998,35 +1007,37 @@ static td_s32 sample_hnr(sample_hnr_param *hnr_param) + ot_size in_size; + ot_hnr_cfg hnr_cfg; + ++ printf(">>>1:sample_hnr_get_default_cfg\n"); + sample_hnr_get_default_cfg(sns_type, vi_pipe, hnr_param->video_mode, &in_size, &vi_cfg); +- ++ printf(">>>2:sample_hnr_check_support\n"); + if (sample_hnr_check_support(vi_pipe, hnr_param) != TD_SUCCESS) { + return TD_FAILURE; + } +- ++ printf(">>>3:sample_hnr_start_vi\n"); + if (sample_hnr_start_vi(vi_pipe, &vi_cfg, &in_size, hnr_param, vb_cnt) != TD_SUCCESS) { + goto sys_exit; + } +- ++ printf(">>>4:sample_hnr_sensor_cfg\n"); + sample_hnr_sensor_cfg(vi_pipe, sns_type); +- ++ printf(">>>5:sample_comm_vi_bind_vpss, vi_chn bind vpss_chn\n"); + sample_comm_vi_bind_vpss(master_pipe, vi_chn, vpss_grp[0], 0); ++ printf(">>>6:sample_hnr_start_vpss\n"); + if (sample_hnr_start_vpss(vpss_grp[0], &in_size) != TD_SUCCESS) { + goto stop_vi; + } +- ++ printf(">>>7:sample_hnr_start_venc_and_vo\n"); + if (sample_hnr_start_venc_and_vo(vpss_grp, sizeof(vpss_grp) / sizeof(vpss_grp[0]), &in_size) != TD_SUCCESS) { + goto stop_vpss; + } +- ++ printf(">>>8:sample_hnr_set_blc\n"); + if (sample_hnr_set_blc(master_pipe, sns_type) != TD_SUCCESS) { + goto stop_venc_and_vo; + } +- ++ printf(">>>9:sample_hnr_start\n"); + if (sample_hnr_start(vi_pipe, in_size, &hnr_cfg, hnr_param) != TD_SUCCESS) { + goto stop_venc_and_vo; + } +- ++ printf(">>>10:sample_hnr_set_long_frame_mod\n"); + if (sample_hnr_set_long_frame_mode(master_pipe, hnr_param->is_wdr_mode) != TD_SUCCESS) { + goto stop_hnr; + } +@@ -1035,15 +1046,20 @@ static td_s32 sample_hnr(sample_hnr_param *hnr_param) + ret = TD_SUCCESS; + + stop_hnr: ++ printf(">>>11:sample_hnr_stop\n"); + sample_hnr_stop(vi_pipe, &hnr_cfg, hnr_param); + stop_venc_and_vo: ++ printf(">>>12:sample_hnr_stop_venc_and_vo\n"); + sample_hnr_stop_venc_and_vo(vpss_grp, sizeof(vpss_grp) / sizeof(vpss_grp[0])); + stop_vpss: ++ printf(">>>13:sample_hnr_stop_vpss\n"); + sample_hnr_stop_vpss(vpss_grp[0]); + stop_vi: ++ printf(">>>14:sample_hnr_stop_vi\n"); + sample_comm_vi_un_bind_vpss(master_pipe, vi_chn, vpss_grp[0], 0); + sample_hnr_stop_vi(vi_pipe, &vi_cfg); + sys_exit: ++ printf(">>>15:sample_comm_sys_exit\n"); + sample_comm_sys_exit(); + return ret; + } +diff --git a/smp/a55_linux/mpp/sample/omnivision_os04a10/Makefile b/smp/a55_linux/mpp/sample/omnivision_os04a10/Makefile +new file mode 100644 +index 0000000..bfed4e5 +--- /dev/null ++++ b/smp/a55_linux/mpp/sample/omnivision_os04a10/Makefile +@@ -0,0 +1,56 @@ ++include ../Makefile.param ++ ++LIBPATH = ./lib ++OBJPATH = $(TEMP_PATH)/$(subst $(SDK_PATH)/,,$(CURDIR))/obj ++ ++ARFLAGS = rcv ++ARFLAGS_SO = $(LIBS_LD_CFLAGS) ++ARFLAGS_SO += -shared -fPIC -o ++CFLAGS += -Wall -fPIC -D$(OT_FPGA) ++CFLAGS += -O2 ++CFLAGS += $(LIBS_CFLAGS) ++ ++ifeq ($(ISP_INI_CONFIG), y) ++CFLAGS += -D INIFILE_CONFIG_MODE ++endif ++ ++ifeq ($(OT_GDB),OT_GDB) ++CFLAGS += -g ++endif ++ ++ifeq ($(CONFIG_JPEGEDCF), y) ++ CFLAGS += -D ENABLE_JPEGEDCF ++endif ++ ++CUR_INC := ./ ++INC := $(COMM_INC) ++DEPEND_FILE := $(foreach file,$(subst -I, ,$(CUR_INC)), $(wildcard $(file)/*.h)) ++ ++# COMPILE = $(CC) $(CFLAGS) $(DFLAGS) -lm ++ ++# $(CUR_INC)/%.o: ./%.c $(DEPEND_FILE) ++# @[ -e $(LIBPATH) ] || mkdir -p $(LIBPATH) ++# @$(COMPILE) -o $@ -c $< $(INC) ++ ++SRCS = $(wildcard ./*.c) ++OBJS = $(SRCS:%.c=%.o) ++ ++# CFLAGS += -I$(REL_INC) -I$(CUR_INC) ++# $(error "===[$(COMM_INC)]====") ++ ++LIB_NAME := libsns_os04a10 ++TARGETLIB := $(LIBPATH)/$(LIB_NAME).a ++TARGETLIB_SO := $(LIBPATH)/$(LIB_NAME).so ++ ++all:$(TARGETLIB) ++$(TARGETLIB):$(OBJS) ++ @mkdir -p $(LIBPATH) ++ @($(AR) $(ARFLAGS) $(TARGETLIB) $(OBJS)) ++ @($(CC) $(ARFLAGS_SO) $(TARGETLIB_SO) $(OBJS)) ++ @cp -f $(TARGETLIB) $(REL_LIB)/ ++ @cp -f $(TARGETLIB_SO) $(REL_LIB)/ ++ ++clean: ++ @$(RM) -rf $(TARGETLIB) $(OBJS) ++ @$(RM) -rf $(LIBPATH) ++ +diff --git a/smp/a55_linux/mpp/sample/omnivision_os04a10/os04a10_cmos.c b/smp/a55_linux/mpp/sample/omnivision_os04a10/os04a10_cmos.c +new file mode 100644 +index 0000000..45601d9 +--- /dev/null ++++ b/smp/a55_linux/mpp/sample/omnivision_os04a10/os04a10_cmos.c +@@ -0,0 +1,1140 @@ ++/* ++ * Copyright (c) 2025 HiSilicon (Shanghai) Technologies Co., Ltd. ++ * ++ * Licensed under the Apache License, Version 2.0 (the "License"); ++ * you may not use this file except in compliance with the License. ++ * You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++#include ++#include ++#include ++#include "ss_mpi_isp.h" ++#include "ss_mpi_ae.h" ++#include "ss_mpi_awb.h" ++ ++#include "os04a10_cmos_ex.h" ++#include "os04a10_cmos.h" ++ ++#define OS04A10_ID 4 ++#define SENSOR_OS04A10_WIDTH 2688 ++#define SENSOR_OS04A10_HEIGHT 1520 ++ ++#define higher_4bits(x) (((x) & 0xf0000) >> 16) ++#define high_8bits(x) (((x) & 0xff00) >> 8) ++#define low_8bits(x) ((x) & 0x00ff) ++#define low_2bits(x) ((x) & 0x0003) ++ ++/**************************************************************************** ++ * global variables * ++ ****************************************************************************/ ++#define os04a10_sensor_set_ctx(dev, ctx) ((g_os04a10_sns_state[dev]) = (ctx)) ++#define os04a10_sensor_reset_ctx(dev) (g_os04a10_sns_state[dev] = TD_NULL) ++ ++static ot_isp_fswdr_mode g_fswdr_mode[OT_ISP_MAX_PIPE_NUM] = { ++ [0 ... OT_ISP_MAX_PIPE_NUM - 1] = OT_ISP_FSWDR_NORMAL_MODE ++}; ++ ++static td_u32 g_max_time_get_cnt[OT_ISP_MAX_PIPE_NUM] = {0}; ++static td_u32 g_init_exposure[OT_ISP_MAX_PIPE_NUM] = {0}; ++static td_u32 g_lines_per500ms[OT_ISP_MAX_PIPE_NUM] = {0}; ++static td_u32 g_ae_stat_pos[OT_ISP_MAX_PIPE_NUM] = {0}; ++ ++static td_u16 g_init_wb_gain[OT_ISP_MAX_PIPE_NUM][OT_ISP_RGB_CHN_NUM] = {{0}}; ++static td_u16 g_sample_r_gain[OT_ISP_MAX_PIPE_NUM] = {0}; ++static td_u16 g_sample_b_gain[OT_ISP_MAX_PIPE_NUM] = {0}; ++static td_bool g_quick_start_en[OT_ISP_MAX_PIPE_NUM] = {TD_FALSE}; ++ ++static td_bool g_ae_route_ex_valid[OT_ISP_MAX_PIPE_NUM] = {0}; ++static ot_isp_ae_route g_init_ae_route[OT_ISP_MAX_PIPE_NUM] = {{0}}; ++static ot_isp_ae_route_ex g_init_ae_route_ex[OT_ISP_MAX_PIPE_NUM] = {{0}}; ++static ot_isp_ae_route g_init_ae_route_sf[OT_ISP_MAX_PIPE_NUM] = {{0}}; ++static ot_isp_ae_route_ex g_init_ae_route_sf_ex[OT_ISP_MAX_PIPE_NUM] = {{0}}; ++ ++ot_isp_sns_commbus g_os04a10_bus_info[OT_ISP_MAX_PIPE_NUM] = { ++ [0] = { .i2c_dev = 0 }, ++ [1 ... OT_ISP_MAX_PIPE_NUM - 1] = { .i2c_dev = -1 } ++}; ++ ++ot_isp_sns_state *g_os04a10_sns_state[OT_ISP_MAX_PIPE_NUM] = {TD_NULL}; ++ ++static td_bool blc_clamp_info[OT_ISP_MAX_PIPE_NUM] = {[0 ...(OT_ISP_MAX_PIPE_NUM - 1)] = TD_TRUE}; ++ot_isp_sns_commbus *os04a10_get_bus_info(ot_vi_pipe vi_pipe) ++{ ++ return &g_os04a10_bus_info[vi_pipe]; ++} ++ ++ot_isp_sns_state *os04a10_get_ctx(ot_vi_pipe vi_pipe) ++{ ++ return g_os04a10_sns_state[vi_pipe]; ++} ++ ++const os04a10_video_mode_tbl g_os04a10_mode_tbl[OS04A10_MODE_BUTT] = { ++ {OS04A10_VMAX_4M_30FPS_12BIT_LINEAR, OS04A10_FULL_LINES_MAX, 30, 5, ++ 2692, 1524, 0, OT_WDR_MODE_NONE, "OS04A10_4M_30FPS_12BIT_LINEAR_MODE"}, ++}; ++ ++/**************************************************************************** ++ * local variables * ++ ****************************************************************************/ ++/* Os04a10 Register Address */ ++#define OS04A10_EXPO_H_ADDR 0x3501 ++#define OS04A10_EXPO_L_ADDR 0x3502 ++#define OS04A10_AGAIN_H_ADDR 0x3508 ++#define OS04A10_AGAIN_L_ADDR 0x3509 ++#define OS04A10_DGAIN_H_ADDR 0x350a ++#define OS04A10_DGAIN_M_ADDR 0x350b ++#define OS04A10_DGAIN_L_ADDR 0x350c ++#define OS04A10_VMAX_H_ADDR 0x380e ++#define OS04A10_VMAX_L_ADDR 0x380f ++#define OS04A10_HCG_1_ADDR 0x376C ++#define OS04A10_GROUP_1_ADDR 0x320d ++#define OS04A10_GROUP_2_ADDR 0x3208 ++#define OS04A10_GROUP_3_ADDR 0x3208 ++#define OS04A10_GROUP_4_ADDR 0x320d ++#define OS04A10_GROUP_5_ADDR 0x320a ++#define OS04A10_GROUP_6_ADDR 0x320e ++ ++ ++#define os04a10_err_mode_print(sensor_image_mode, sns_state) \ ++do { \ ++ isp_err_trace("Not support! Width:%d, Height:%d, Fps:%f, WDRMode:%d\n", \ ++ (sensor_image_mode)->width, \ ++ (sensor_image_mode)->height, \ ++ (sensor_image_mode)->fps, \ ++ (sns_state)->wdr_mode); \ ++} while (0) ++ ++static td_void cmos_get_ae_comm_default(ot_vi_pipe vi_pipe, ot_isp_ae_sensor_default *ae_sns_dft, ++ const ot_isp_sns_state *sns_state) ++{ ++ ae_sns_dft->full_lines_std = sns_state->fl_std; ++ ae_sns_dft->flicker_freq = 50 * 256; /* light flicker freq: 50Hz, accuracy: 256 */ ++ ae_sns_dft->full_lines_max = OS04A10_FULL_LINES_MAX; ++ ae_sns_dft->hmax_times = (1000000000) / (sns_state->fl_std * 30); /* 1000000000ns, 30fps */ ++ ++ ae_sns_dft->int_time_accu.accu_type = OT_ISP_AE_ACCURACY_LINEAR; ++ ae_sns_dft->int_time_accu.accuracy = 1; ++ ae_sns_dft->int_time_accu.offset = 0; ++ ++ ae_sns_dft->again_accu.accu_type = OT_ISP_AE_ACCURACY_LINEAR; ++ ae_sns_dft->again_accu.accuracy = 0.0625; /* accuracy: 0.0625 */ ++ ++ ae_sns_dft->dgain_accu.accu_type = OT_ISP_AE_ACCURACY_LINEAR; ++ ae_sns_dft->dgain_accu.accuracy = 0.0009765625; /* accuracy: 0.0009765625 */ ++ ++ ae_sns_dft->isp_dgain_shift = 8; /* accuracy: 8 */ ++ ae_sns_dft->min_isp_dgain_target = 1 << ae_sns_dft->isp_dgain_shift; ++ ae_sns_dft->max_isp_dgain_target = 32 << ae_sns_dft->isp_dgain_shift; /* max 32 */ ++ if (g_lines_per500ms[vi_pipe] == 0) { ++ ae_sns_dft->lines_per500ms = sns_state->fl_std * 30 / 2; /* 30fps, div 2 */ ++ } else { ++ ae_sns_dft->lines_per500ms = g_lines_per500ms[vi_pipe]; ++ } ++ ++ ae_sns_dft->max_iris_fno = OT_ISP_IRIS_F_NO_1_4; ++ ae_sns_dft->min_iris_fno = OT_ISP_IRIS_F_NO_5_6; ++ ++ ae_sns_dft->ae_route_ex_valid = TD_FALSE; ++ ae_sns_dft->ae_route_attr.total_num = 0; ++ ae_sns_dft->ae_route_attr_ex.total_num = 0; ++ ae_sns_dft->quick_start.quick_start_enable = g_quick_start_en[vi_pipe]; ++ ae_sns_dft->quick_start.black_frame_num = 0; ++ ae_sns_dft->ae_stat_pos = g_ae_stat_pos[vi_pipe]; /* 1 use be stat to AE */ ++ ++ return; ++} ++ ++static td_void cmos_get_ae_linear_default(ot_vi_pipe vi_pipe, ot_isp_ae_sensor_default *ae_sns_dft, ++ const ot_isp_sns_state *sns_state) ++{ ++ ae_sns_dft->max_again = 992; /* max 992 */ ++ ae_sns_dft->min_again = 16; /* min 16 */ ++ ae_sns_dft->max_again_target = ae_sns_dft->max_again; ++ ae_sns_dft->min_again_target = ae_sns_dft->min_again; ++ ++ ae_sns_dft->max_dgain = 1024; /* max 1024 */ ++ ae_sns_dft->min_dgain = 1024; /* min 1024 */ ++ ae_sns_dft->max_dgain_target = ae_sns_dft->max_dgain; ++ ae_sns_dft->min_dgain_target = ae_sns_dft->min_dgain; ++ ++ ae_sns_dft->ae_compensation = 0x40; ++ ae_sns_dft->ae_exp_mode = OT_ISP_AE_EXP_HIGHLIGHT_PRIOR; ++ ae_sns_dft->init_exposure = g_init_exposure[vi_pipe] ? g_init_exposure[vi_pipe] : 76151; /* init 76151 */ ++ ++ ae_sns_dft->max_int_time = sns_state->fl_std - 8; /* sub 8 */ ++ ae_sns_dft->min_int_time = 1; /* min int 1 */ ++ ae_sns_dft->max_int_time_target = 65535; /* max int 65535 */ ++ ae_sns_dft->min_int_time_target = ae_sns_dft->min_int_time; ++ ae_sns_dft->ae_route_ex_valid = g_ae_route_ex_valid[vi_pipe]; ++ (td_void)memcpy_s(&ae_sns_dft->ae_route_attr, sizeof(ot_isp_ae_route), ++ &g_init_ae_route[vi_pipe], sizeof(ot_isp_ae_route)); ++ (td_void)memcpy_s(&ae_sns_dft->ae_route_attr_ex, sizeof(ot_isp_ae_route_ex), ++ &g_init_ae_route_ex[vi_pipe], sizeof(ot_isp_ae_route_ex)); ++ return; ++} ++ ++static td_s32 cmos_get_ae_default(ot_vi_pipe vi_pipe, ot_isp_ae_sensor_default *ae_sns_dft) ++{ ++ ot_isp_sns_state *sns_state = TD_NULL; ++ ++ sensor_check_pointer_return(ae_sns_dft); ++ os04a10_sensor_get_ctx(vi_pipe, sns_state); ++ sensor_check_pointer_return(sns_state); ++ ++ (td_void)memset_s(&ae_sns_dft->ae_route_attr, sizeof(ot_isp_ae_route), 0, sizeof(ot_isp_ae_route)); ++ ++ cmos_get_ae_comm_default(vi_pipe, ae_sns_dft, sns_state); ++ ++ switch (sns_state->wdr_mode) { ++ case OT_WDR_MODE_NONE: /* linear mode */ ++ cmos_get_ae_linear_default(vi_pipe, ae_sns_dft, sns_state); ++ break; ++ default: ++ cmos_get_ae_linear_default(vi_pipe, ae_sns_dft, sns_state); ++ break; ++ } ++ ++ return TD_SUCCESS; ++} ++ ++static td_void cmos_config_vmax(ot_isp_sns_state *sns_state, td_u32 vmax) ++{ ++ if (sns_state->wdr_mode == OT_WDR_MODE_NONE) { ++ sns_state->regs_info[0].i2c_data[VMAX_L_IDX].data = low_8bits(vmax); ++ sns_state->regs_info[0].i2c_data[VMAX_H_IDX].data = high_8bits(vmax); ++ } ++ ++ return; ++} ++ ++/* the function of sensor set fps */ ++static td_void cmos_fps_set(ot_vi_pipe vi_pipe, td_float fps, ot_isp_ae_sensor_default *ae_sns_dft) ++{ ++ td_u32 lines, lines_max, vmax; ++ td_float max_fps, min_fps; ++ ot_isp_sns_state *sns_state = TD_NULL; ++ ++ sensor_check_pointer_void_return(ae_sns_dft); ++ os04a10_sensor_get_ctx(vi_pipe, sns_state); ++ sensor_check_pointer_void_return(sns_state); ++ ++ lines = g_os04a10_mode_tbl[sns_state->img_mode].ver_lines; ++ lines_max = g_os04a10_mode_tbl[sns_state->img_mode].max_ver_lines; ++ max_fps = g_os04a10_mode_tbl[sns_state->img_mode].max_fps; ++ min_fps = g_os04a10_mode_tbl[sns_state->img_mode].min_fps; ++ ++ if ((fps > max_fps) || (fps < min_fps)) { ++ isp_err_trace("Not support Fps: %f\n", fps); ++ return; ++ } ++ ++ vmax = lines * max_fps / div_0_to_1_float(fps); ++ vmax = (vmax > lines_max) ? lines_max : vmax; ++ ++ cmos_config_vmax(sns_state, vmax); ++ ++ sns_state->fl_std = vmax; ++ ae_sns_dft->lines_per500ms = lines * 15; /* *15 */ ++ ++ ae_sns_dft->fps = fps; ++ ae_sns_dft->full_lines_std = sns_state->fl_std; ++ ae_sns_dft->max_int_time = sns_state->fl_std - 10; /* sub 10 */ ++ sns_state->fl[0] = sns_state->fl_std; ++ ae_sns_dft->full_lines = sns_state->fl[0]; ++ ae_sns_dft->hmax_times = ++ (1000000000) / (sns_state->fl_std * div_0_to_1_float(fps)); /* 1000000000ns */ ++ ++ return; ++} ++ ++static td_void cmos_slow_framerate_set(ot_vi_pipe vi_pipe, td_u32 full_lines, ot_isp_ae_sensor_default *ae_sns_dft) ++{ ++ td_u32 lines_max; ++ td_u32 vmax; ++ ot_isp_sns_state *sns_state = TD_NULL; ++ sensor_check_pointer_void_return(ae_sns_dft); ++ os04a10_sensor_get_ctx(vi_pipe, sns_state); ++ sensor_check_pointer_void_return(sns_state); ++ ++ lines_max = g_os04a10_mode_tbl[sns_state->img_mode].max_ver_lines; ++ ++ vmax = full_lines; ++ vmax = (vmax > lines_max) ? lines_max : vmax; ++ sns_state->fl[0] = vmax; ++ ++ switch (sns_state->wdr_mode) { ++ case OT_WDR_MODE_NONE: ++ sns_state->regs_info[0].i2c_data[VMAX_L_IDX].data = low_8bits(sns_state->fl[0]); ++ sns_state->regs_info[0].i2c_data[VMAX_H_IDX].data = high_8bits(sns_state->fl[0]); ++ break; ++ default: ++ break; ++ } ++ ++ ae_sns_dft->full_lines = sns_state->fl[0]; ++ ae_sns_dft->max_int_time = sns_state->fl[0] - 10; /* max_int_time: Flstd - 10 */ ++ ++ return; ++} ++ ++static td_void cmos_inttime_update_linear(ot_vi_pipe vi_pipe, td_u32 int_time) ++{ ++ ot_isp_sns_state *sns_state = TD_NULL; ++ td_u32 value; ++ ++ os04a10_sensor_get_ctx(vi_pipe, sns_state); ++ sensor_check_pointer_void_return(sns_state); ++ ++ value = int_time; ++ ++ sns_state->regs_info[0].i2c_data[EXPO_L_IDX].data = low_8bits(value); ++ sns_state->regs_info[0].i2c_data[EXPO_H_IDX].data = high_8bits(value); ++ ++ return; ++} ++ ++/* while isp notify ae to update sensor regs, ae call these funcs. */ ++static td_void cmos_inttime_update(ot_vi_pipe vi_pipe, td_u32 int_time) ++{ ++ ot_isp_sns_state *sns_state = TD_NULL; ++ ++ os04a10_sensor_get_ctx(vi_pipe, sns_state); ++ sensor_check_pointer_void_return(sns_state); ++ ++ if (sns_state->wdr_mode == OT_WDR_MODE_NONE) { ++ cmos_inttime_update_linear(vi_pipe, int_time); ++ } ++ ++ return; ++} ++ ++static td_void cmos_gains_regs_set(ot_vi_pipe vi_pipe, ot_isp_sns_state *sns_state, ++ td_u32 again_reg, td_u32 dgain_reg, td_u32 hcg_1_reg) ++{ ++ if (sns_state->wdr_mode == OT_WDR_MODE_NONE) { ++ sns_state->regs_info[0].i2c_data[AGAIN_L_IDX].data = ((again_reg & 0xf) << 4); /* shift 4 */ ++ sns_state->regs_info[0].i2c_data[AGAIN_H_IDX].data = ((again_reg & 0xf0) >> 4); /* shift 4 */ ++ sns_state->regs_info[0].i2c_data[DGAIN_L_IDX].data = ((dgain_reg & 0x03) << 6); /* shift 6 */ ++ sns_state->regs_info[0].i2c_data[DGAIN_M_IDX].data = ((dgain_reg & 0x03FC) >> 2); /* shift 2 */ ++ sns_state->regs_info[0].i2c_data[DGAIN_H_IDX].data = ((dgain_reg & 0x3C00) >> 10); /* shift 10 */ ++ sns_state->regs_info[0].i2c_data[HCG_1_IDX].data = (hcg_1_reg & 0xff); ++ } else { ++ } ++ ++ return; ++} ++ ++static td_void cmos_gains_update(ot_vi_pipe vi_pipe, td_u32 again, td_u32 dgain) ++{ ++ ot_isp_sns_state *sns_state = TD_NULL; ++ td_u32 again_reg, dgain_reg, hcg_1_reg; ++ ++ os04a10_sensor_get_ctx(vi_pipe, sns_state); ++ sensor_check_pointer_void_return(sns_state); ++ ++ if (again < 0x44) { ++ hcg_1_reg = 0x10; ++ } else { ++ hcg_1_reg = 0x00; ++ again = (td_u32)((td_float)again / 4.25 + 0.5); /* HCG gain equal 4.25, 0.5 */ ++ } ++ ++ again_reg = clip3(again, 0x10, 0xF8); ++ dgain_reg = clip3(dgain, 0x400, 0x3FFF); ++ ++ cmos_gains_regs_set(vi_pipe, sns_state, again_reg, dgain_reg, hcg_1_reg); ++ ++ return; ++} ++ ++static td_void cmos_get_inttime_max_2to1_line(ot_vi_pipe vi_pipe, td_u32 *ratio, ++ ot_isp_ae_int_time_range *int_time, td_u32 *lf_max_int_time) ++{ ++ td_u32 short_max0; ++ td_u32 short_max; ++ td_u32 short_time_min_limit; ++ ot_isp_sns_state *sns_state = TD_NULL; ++ ++ os04a10_sensor_get_ctx(vi_pipe, sns_state); ++ sensor_check_pointer_void_return(sns_state); ++ ++ short_time_min_limit = 2; /* short_time_min_limit 2 */ ++ ++ if (g_fswdr_mode[vi_pipe] == OT_ISP_FSWDR_LONG_FRAME_MODE) { ++ short_max0 = sns_state->fl[1] - 20 - sns_state->wdr_int_time[0]; /* sensor limit: sub 20 */ ++ short_max = sns_state->fl[0] - 20; /* sensor limit: sub 20 */ ++ short_max = (short_max0 < short_max) ? short_max0 : short_max; ++ int_time->int_time_max[0] = short_time_min_limit; ++ int_time->int_time_min[0] = short_time_min_limit; ++ int_time->int_time_max[1] = short_max; ++ int_time->int_time_min[1] = short_time_min_limit; ++ return; ++ } else { ++ short_max0 = ((sns_state->fl[1] - 20 - sns_state->wdr_int_time[0]) * 0x40) / div_0_to_1(ratio[0]); /* sub 20 */ ++ ++ short_max = ((sns_state->fl[0] - 20) * 0x40) / (ratio[0] + 0x40); /* sub 20 */ ++ short_max = (short_max0 < short_max) ? short_max0 : short_max; ++ short_max = (short_max == 0) ? 1 : short_max; ++ } ++ *lf_max_int_time = sns_state->fl[0] - 20; /* sub 20 */ ++ ++ if (short_max >= short_time_min_limit) { ++ int_time->int_time_max[0] = short_max; ++ int_time->int_time_max[1] = (int_time->int_time_max[0] * ratio[0]) >> 6; /* shift 6 */ ++ int_time->int_time_min[0] = short_time_min_limit; ++ int_time->int_time_min[1] = (int_time->int_time_min[0] * ratio[0]) >> 6; /* shift 6 */ ++ } else { ++ short_max = short_time_min_limit; ++ ++ int_time->int_time_max[0] = short_max; ++ int_time->int_time_max[1] = (int_time->int_time_max[0] * 0xFFF) >> 6; /* shift 6 */ ++ int_time->int_time_min[0] = int_time->int_time_max[0]; ++ int_time->int_time_min[1] = int_time->int_time_max[1]; ++ } ++ ++ return; ++} ++ ++static td_void cmos_get_inttime_max(ot_vi_pipe vi_pipe, td_u16 man_ratio_enable, td_u32 *ratio, ++ ot_isp_ae_int_time_range *int_time, td_u32 *lf_max_int_time) ++{ ++ ot_isp_sns_state *sns_state = TD_NULL; ++ ot_unused(man_ratio_enable); ++ sensor_check_pointer_void_return(ratio); ++ sensor_check_pointer_void_return(int_time); ++ sensor_check_pointer_void_return(lf_max_int_time); ++ os04a10_sensor_get_ctx(vi_pipe, sns_state); ++ sensor_check_pointer_void_return(sns_state); ++ ++ switch (sns_state->wdr_mode) { ++ case OT_WDR_MODE_2To1_LINE: ++ cmos_get_inttime_max_2to1_line(vi_pipe, ratio, int_time, lf_max_int_time); ++ break; ++ default: ++ break; ++ } ++ ++ return; ++} ++ ++/* Only used in LINE_WDR mode */ ++static td_void cmos_ae_fswdr_attr_set(ot_vi_pipe vi_pipe, ot_isp_ae_fswdr_attr *ae_fswdr_attr) ++{ ++ sensor_check_pointer_void_return(ae_fswdr_attr); ++ ++ g_fswdr_mode[vi_pipe] = ae_fswdr_attr->fswdr_mode; ++ g_max_time_get_cnt[vi_pipe] = 0; ++ ++ return; ++} ++ ++static td_s32 cmos_init_ae_exp_function(ot_isp_ae_sensor_exp_func *exp_func) ++{ ++ sensor_check_pointer_return(exp_func); ++ ++ (td_void)memset_s(exp_func, sizeof(ot_isp_ae_sensor_exp_func), 0, sizeof(ot_isp_ae_sensor_exp_func)); ++ ++ exp_func->pfn_cmos_get_ae_default = cmos_get_ae_default; ++ exp_func->pfn_cmos_fps_set = cmos_fps_set; ++ exp_func->pfn_cmos_slow_framerate_set = cmos_slow_framerate_set; ++ exp_func->pfn_cmos_inttime_update = cmos_inttime_update; ++ exp_func->pfn_cmos_gains_update = cmos_gains_update; ++ exp_func->pfn_cmos_get_inttime_max = cmos_get_inttime_max; ++ exp_func->pfn_cmos_ae_fswdr_attr_set = cmos_ae_fswdr_attr_set; ++ ++ return TD_SUCCESS; ++} ++ ++/* awb static param for Fuji Lens New IR_Cut */ ++#define CALIBRATE_STATIC_TEMP 5000 ++#define CALIBRATE_STATIC_WB_R_GAIN 527 ++#define CALIBRATE_STATIC_WB_GR_GAIN 256 ++#define CALIBRATE_STATIC_WB_GB_GAIN 256 ++#define CALIBRATE_STATIC_WB_B_GAIN 526 ++ ++/* Calibration results for Auto WB Planck */ ++#define CALIBRATE_AWB_P1 1 ++#define CALIBRATE_AWB_P2 241 ++#define CALIBRATE_AWB_Q1 (-15) ++#define CALIBRATE_AWB_A1 159211 ++#define CALIBRATE_AWB_B1 128 ++#define CALIBRATE_AWB_C1 (-104902) ++ ++/* Rgain and Bgain of the golden sample */ ++#define GOLDEN_RGAIN 0 ++#define GOLDEN_BGAIN 0 ++static td_s32 cmos_get_awb_default(ot_vi_pipe vi_pipe, ot_isp_awb_sensor_default *awb_sns_dft) ++{ ++ ot_isp_sns_state *sns_state = TD_NULL; ++ ++ sensor_check_pointer_return(awb_sns_dft); ++ os04a10_sensor_get_ctx(vi_pipe, sns_state); ++ sensor_check_pointer_return(sns_state); ++ ++ (td_void)memset_s(awb_sns_dft, sizeof(ot_isp_awb_sensor_default), 0, sizeof(ot_isp_awb_sensor_default)); ++ awb_sns_dft->wb_ref_temp = CALIBRATE_STATIC_TEMP; /* wb_ref_temp 4950 */ ++ ++ awb_sns_dft->gain_offset[0] = CALIBRATE_STATIC_WB_R_GAIN; ++ awb_sns_dft->gain_offset[1] = CALIBRATE_STATIC_WB_GR_GAIN; ++ awb_sns_dft->gain_offset[2] = CALIBRATE_STATIC_WB_GB_GAIN; /* index 2 */ ++ awb_sns_dft->gain_offset[3] = CALIBRATE_STATIC_WB_B_GAIN; /* index 3 */ ++ ++ awb_sns_dft->wb_para[0] = CALIBRATE_AWB_P1; ++ awb_sns_dft->wb_para[1] = CALIBRATE_AWB_P2; ++ awb_sns_dft->wb_para[2] = CALIBRATE_AWB_Q1; /* index 2 */ ++ awb_sns_dft->wb_para[3] = CALIBRATE_AWB_A1; /* index 3 */ ++ awb_sns_dft->wb_para[4] = CALIBRATE_AWB_B1; /* index 4 */ ++ awb_sns_dft->wb_para[5] = CALIBRATE_AWB_C1; /* index 5 */ ++ ++ awb_sns_dft->golden_rgain = GOLDEN_RGAIN; ++ awb_sns_dft->golden_bgain = GOLDEN_BGAIN; ++ ++ switch (sns_state->wdr_mode) { ++ case OT_WDR_MODE_NONE: ++ (td_void)memcpy_s(&awb_sns_dft->ccm, sizeof(ot_isp_awb_ccm), &g_awb_ccm, sizeof(ot_isp_awb_ccm)); ++ (td_void)memcpy_s(&awb_sns_dft->agc_tbl, sizeof(ot_isp_awb_agc_table), ++ &g_awb_agc_table, sizeof(ot_isp_awb_agc_table)); ++ break; ++ default: ++ (td_void)memcpy_s(&awb_sns_dft->ccm, sizeof(ot_isp_awb_ccm), &g_awb_ccm, sizeof(ot_isp_awb_ccm)); ++ (td_void)memcpy_s(&awb_sns_dft->agc_tbl, sizeof(ot_isp_awb_agc_table), ++ &g_awb_agc_table, sizeof(ot_isp_awb_agc_table)); ++ break; ++ } ++ ++ awb_sns_dft->init_rgain = g_init_wb_gain[vi_pipe][0]; /* 0: Rgain */ ++ awb_sns_dft->init_ggain = g_init_wb_gain[vi_pipe][1]; /* 1: Ggain */ ++ awb_sns_dft->init_bgain = g_init_wb_gain[vi_pipe][2]; /* 2: Bgain */ ++ awb_sns_dft->sample_rgain = g_sample_r_gain[vi_pipe]; ++ awb_sns_dft->sample_bgain = g_sample_b_gain[vi_pipe]; ++ ++ return TD_SUCCESS; ++} ++ ++static td_s32 cmos_init_awb_exp_function(ot_isp_awb_sensor_exp_func *exp_func) ++{ ++ sensor_check_pointer_return(exp_func); ++ ++ (td_void)memset_s(exp_func, sizeof(ot_isp_awb_sensor_exp_func), 0, sizeof(ot_isp_awb_sensor_exp_func)); ++ ++ exp_func->pfn_cmos_get_awb_default = cmos_get_awb_default; ++ ++ return TD_SUCCESS; ++} ++ ++static ot_isp_cmos_dng_color_param g_dng_color_param = {{ 378, 256, 430 }, { 439, 256, 439 }}; ++ ++static td_void cmos_get_isp_dng_default(const ot_isp_sns_state *sns_state, ot_isp_cmos_default *isp_def) ++{ ++ (td_void)memcpy_s(&isp_def->dng_color_param, sizeof(ot_isp_cmos_dng_color_param), &g_dng_color_param, ++ sizeof(ot_isp_cmos_dng_color_param)); ++ ++ switch (sns_state->img_mode) { ++ case OS04A10_4M_30FPS_12BIT_LINEAR_MODE: ++ isp_def->sensor_mode.dng_raw_format.bits_per_sample = 12; /* 12bit */ ++ isp_def->sensor_mode.dng_raw_format.white_level = 4095; /* max 4095 */ ++ break; ++ default: ++ isp_def->sensor_mode.dng_raw_format.bits_per_sample = 12; /* 12bit */ ++ isp_def->sensor_mode.dng_raw_format.white_level = 4095; /* max 4095 */ ++ break; ++ } ++ ++ isp_def->sensor_mode.dng_raw_format.default_scale.default_scale_hor.denominator = 1; ++ isp_def->sensor_mode.dng_raw_format.default_scale.default_scale_hor.numerator = 1; ++ isp_def->sensor_mode.dng_raw_format.default_scale.default_scale_ver.denominator = 1; ++ isp_def->sensor_mode.dng_raw_format.default_scale.default_scale_ver.numerator = 1; ++ isp_def->sensor_mode.dng_raw_format.cfa_repeat_pattern_dim.repeat_pattern_dim_row = 2; /* pattern 2 */ ++ isp_def->sensor_mode.dng_raw_format.cfa_repeat_pattern_dim.repeat_pattern_dim_col = 2; /* pattern 2 */ ++ isp_def->sensor_mode.dng_raw_format.black_level_repeat_dim.repeat_row = 2; /* pattern 2 */ ++ isp_def->sensor_mode.dng_raw_format.black_level_repeat_dim.repeat_col = 2; /* pattern 2 */ ++ isp_def->sensor_mode.dng_raw_format.cfa_layout = OT_ISP_CFALAYOUT_TYPE_RECTANGULAR; ++ isp_def->sensor_mode.dng_raw_format.cfa_plane_color[0] = 0; ++ isp_def->sensor_mode.dng_raw_format.cfa_plane_color[1] = 1; ++ isp_def->sensor_mode.dng_raw_format.cfa_plane_color[2] = 2; /* index 2, cfa_plane_color 2 */ ++ isp_def->sensor_mode.dng_raw_format.cfa_pattern[0] = 0; ++ isp_def->sensor_mode.dng_raw_format.cfa_pattern[1] = 1; ++ isp_def->sensor_mode.dng_raw_format.cfa_pattern[2] = 1; /* index 2, cfa_pattern 1 */ ++ isp_def->sensor_mode.dng_raw_format.cfa_pattern[3] = 2; /* index 3, cfa_pattern 2 */ ++ isp_def->sensor_mode.valid_dng_raw_format = TD_TRUE; ++ ++ return; ++} ++ ++static void cmos_get_isp_linear_default(ot_isp_cmos_default *isp_def) ++{ ++ isp_def->key.bit1_demosaic = 1; ++ isp_def->demosaic = &g_cmos_demosaic; ++ isp_def->key.bit1_sharpen = 1; ++ isp_def->sharpen = &g_cmos_yuv_sharpen; ++ isp_def->key.bit1_drc = 1; ++ isp_def->drc = &g_cmos_drc; ++ isp_def->key.bit1_bayer_nr = 1; ++ isp_def->bayer_nr = &g_cmos_bayer_nr; ++ isp_def->key.bit1_anti_false_color = 1; ++ isp_def->anti_false_color = &g_cmos_anti_false_color; ++ isp_def->key.bit1_ldci = 1; ++ isp_def->ldci = &g_cmos_ldci; ++ isp_def->key.bit1_gamma = 1; ++ isp_def->gamma = &g_cmos_gamma; ++#ifdef CONFIG_OT_ISP_CR_SUPPORT ++ isp_def->key.bit1_ge = 1; ++ isp_def->ge = &g_cmos_ge; ++#endif ++ isp_def->key.bit1_dehaze = 1; ++ isp_def->dehaze = &g_cmos_dehaze; ++ isp_def->key.bit1_ca = 1; ++ isp_def->ca = &g_cmos_ca; ++ isp_def->key.bit1_crb = 1; ++ isp_def->crb = &g_cmos_crb; ++ (td_void)memcpy_s(&isp_def->noise_calibration, sizeof(ot_isp_noise_calibration), ++ &g_cmos_noise_calibration, sizeof(ot_isp_noise_calibration)); ++ return; ++} ++ ++static td_s32 cmos_get_isp_default(ot_vi_pipe vi_pipe, ot_isp_cmos_default *isp_def) ++{ ++ ot_isp_sns_state *sns_state = TD_NULL; ++ ++ sensor_check_pointer_return(isp_def); ++ os04a10_sensor_get_ctx(vi_pipe, sns_state); ++ sensor_check_pointer_return(sns_state); ++ ++ (td_void)memset_s(isp_def, sizeof(ot_isp_cmos_default), 0, sizeof(ot_isp_cmos_default)); ++#ifdef CONFIG_OT_ISP_CA_SUPPORT ++ isp_def->key.bit1_ca = 1; ++ isp_def->ca = &g_cmos_ca; ++#endif ++ isp_def->key.bit1_clut = 1; ++ isp_def->clut = &g_cmos_clut; ++ ++ isp_def->key.bit1_dpc = 1; ++ isp_def->dpc = &g_cmos_dpc; ++ ++ isp_def->key.bit1_wdr = 1; ++ isp_def->wdr = &g_cmos_wdr; ++ ++ isp_def->key.bit1_lsc = 0; ++ isp_def->lsc = &g_cmos_lsc; ++ ++ isp_def->key.bit1_acs = 0; ++ isp_def->acs = &g_cmos_acs; ++ ++ isp_def->key.bit1_crb = 1; ++ isp_def->crb = &g_cmos_crb; ++#ifdef CONFIG_OT_ISP_PREGAMMA_SUPPORT ++ isp_def->key.bit1_pregamma = 1; ++ isp_def->pregamma = &g_cmos_pregamma; ++#endif ++ switch (sns_state->wdr_mode) { ++ case OT_WDR_MODE_NONE: ++ cmos_get_isp_linear_default(isp_def); ++ break; ++ default: ++ cmos_get_isp_linear_default(isp_def); ++ break; ++ } ++ ++ isp_def->wdr_switch_attr.exp_ratio[0] = 0x40; ++ ++ if (sns_state->wdr_mode == OT_WDR_MODE_2To1_LINE) { ++ isp_def->wdr_switch_attr.exp_ratio[0] = 0x400; ++ } ++ ++ isp_def->sensor_mode.sensor_id = OS04A10_ID; ++ isp_def->sensor_mode.sensor_mode = sns_state->img_mode; ++ cmos_get_isp_dng_default(sns_state, isp_def); ++ ++ return TD_SUCCESS; ++} ++ ++static td_s32 cmos_get_isp_black_level(ot_vi_pipe vi_pipe, ot_isp_cmos_black_level *black_level) ++{ ++ td_s32 i; ++ ot_isp_sns_state *sns_state = TD_NULL; ++ ++ sensor_check_pointer_return(black_level); ++ os04a10_sensor_get_ctx(vi_pipe, sns_state); ++ sensor_check_pointer_return(sns_state); ++ ++ (td_void)memcpy_s(black_level, sizeof(ot_isp_cmos_black_level), &g_cmos_blc, sizeof(ot_isp_cmos_black_level)); ++ ++ /* Don't need to update black level when iso change */ ++ black_level->auto_attr.update = TD_FALSE; ++ ++ /* black level of linear mode */ ++ for (i = 0; i < OT_ISP_BAYER_CHN_NUM; i++) { ++ black_level->auto_attr.black_level[0][i] = 0x400; ++ } ++ ++ return TD_SUCCESS; ++} ++ ++static td_s32 cmos_get_isp_blc_clamp_info(ot_vi_pipe vi_pipe, td_bool *blc_clamp_en) ++{ ++ sensor_check_pointer_return(blc_clamp_en); ++ ++ *blc_clamp_en = blc_clamp_info[vi_pipe]; ++ ++ return TD_SUCCESS; ++} ++ ++static td_void cmos_set_pixel_detect(ot_vi_pipe vi_pipe, td_bool enable) ++{ ++ td_u32 full_lines_5fps; ++ ot_isp_sns_state *sns_state = TD_NULL; ++ ++ os04a10_sensor_get_ctx(vi_pipe, sns_state); ++ sensor_check_pointer_void_return(sns_state); ++ ++ if (sns_state->wdr_mode == OT_WDR_MODE_2To1_LINE) { ++ return; ++ } else { ++ if (sns_state->img_mode == OS04A10_4M_30FPS_12BIT_LINEAR_MODE) { ++ full_lines_5fps = (OS04A10_VMAX_4M_30FPS_12BIT_LINEAR * 30) / 5; /* 30fps, 5fps */ ++ } else { ++ return; ++ } ++ } ++ ++ if (enable) { /* setup for ISP pixel calibration mode */ ++ os04a10_write_register(vi_pipe, OS04A10_AGAIN_L_ADDR, 0x00); ++ os04a10_write_register(vi_pipe, OS04A10_AGAIN_H_ADDR, 0x01); ++ ++ os04a10_write_register(vi_pipe, OS04A10_DGAIN_L_ADDR, 0x00); ++ os04a10_write_register(vi_pipe, OS04A10_DGAIN_M_ADDR, 0x00); ++ os04a10_write_register(vi_pipe, OS04A10_DGAIN_H_ADDR, 0x01); ++ ++ os04a10_write_register(vi_pipe, OS04A10_VMAX_L_ADDR, low_8bits(full_lines_5fps)); ++ os04a10_write_register(vi_pipe, OS04A10_VMAX_H_ADDR, high_8bits(full_lines_5fps)); ++ ++ os04a10_write_register(vi_pipe, OS04A10_EXPO_L_ADDR, low_8bits(full_lines_5fps - 10)); ++ os04a10_write_register(vi_pipe, OS04A10_EXPO_H_ADDR, high_8bits(full_lines_5fps - 10)); ++ } else { /* setup for ISP 'normal mode' */ ++ sns_state->fl_std = (sns_state->fl_std > OS04A10_FULL_LINES_MAX) ? OS04A10_FULL_LINES_MAX : sns_state->fl_std; ++ os04a10_write_register(vi_pipe, OS04A10_VMAX_L_ADDR, low_8bits(sns_state->fl_std)); ++ os04a10_write_register(vi_pipe, OS04A10_VMAX_H_ADDR, high_8bits(sns_state->fl_std)); ++ sns_state->sync_init = TD_FALSE; ++ } ++ ++ return; ++} ++ ++static td_s32 cmos_set_wdr_mode(ot_vi_pipe vi_pipe, td_u8 mode) ++{ ++ ot_isp_sns_state *sns_state = TD_NULL; ++ ++ os04a10_sensor_get_ctx(vi_pipe, sns_state); ++ sensor_check_pointer_return(sns_state); ++ ++ sns_state->sync_init = TD_FALSE; ++ ++ switch (mode & 0x3F) { ++ case OT_WDR_MODE_NONE: ++ sns_state->wdr_mode = OT_WDR_MODE_NONE; ++ printf("linear mode\n"); ++ break; ++ ++ case OT_WDR_MODE_BUILT_IN: ++ sns_state->wdr_mode = OT_WDR_MODE_BUILT_IN; ++ printf("2to1 line WDR 4k mode(60fps->30fps)\n"); ++ break; ++ ++ default: ++ isp_err_trace("NOT support this mode!\n"); ++ return TD_FAILURE; ++ } ++ ++ (td_void)memset_s(sns_state->wdr_int_time, sizeof(sns_state->wdr_int_time), 0, sizeof(sns_state->wdr_int_time)); ++ ++ return TD_SUCCESS; ++} ++ ++static td_void cmos_comm_sns_reg_info_init(ot_vi_pipe vi_pipe, ot_isp_sns_state *sns_state) ++{ ++ td_u32 i; ++ sns_state->regs_info[0].sns_type = OT_ISP_SNS_I2C_TYPE; ++ sns_state->regs_info[0].com_bus.i2c_dev = g_os04a10_bus_info[vi_pipe].i2c_dev; ++ sns_state->regs_info[0].cfg2_valid_delay_max = 2; /* delay_max 2 */ ++ sns_state->regs_info[0].reg_num = REG_MAX_IDX; ++ ++ for (i = 0; i < sns_state->regs_info[0].reg_num; i++) { ++ sns_state->regs_info[0].i2c_data[i].update = TD_TRUE; ++ sns_state->regs_info[0].i2c_data[i].dev_addr = OS04A10_I2C_ADDR; ++ sns_state->regs_info[0].i2c_data[i].addr_byte_num = OS04A10_ADDR_BYTE; ++ sns_state->regs_info[0].i2c_data[i].data_byte_num = OS04A10_DATA_BYTE; ++ } ++ ++ /* Linear Mode Regs */ ++ sns_state->regs_info[0].i2c_data[EXPO_L_IDX].delay_frame_num = 0; ++ sns_state->regs_info[0].i2c_data[EXPO_L_IDX].reg_addr = OS04A10_EXPO_L_ADDR; ++ sns_state->regs_info[0].i2c_data[EXPO_H_IDX].delay_frame_num = 0; ++ sns_state->regs_info[0].i2c_data[EXPO_H_IDX].reg_addr = OS04A10_EXPO_H_ADDR; ++ ++ sns_state->regs_info[0].i2c_data[AGAIN_L_IDX].delay_frame_num = 0; ++ sns_state->regs_info[0].i2c_data[AGAIN_L_IDX].reg_addr = OS04A10_AGAIN_L_ADDR; ++ sns_state->regs_info[0].i2c_data[AGAIN_H_IDX].delay_frame_num = 0; ++ sns_state->regs_info[0].i2c_data[AGAIN_H_IDX].reg_addr = OS04A10_AGAIN_H_ADDR; ++ ++ sns_state->regs_info[0].i2c_data[DGAIN_L_IDX].delay_frame_num = 0; ++ sns_state->regs_info[0].i2c_data[DGAIN_L_IDX].reg_addr = OS04A10_DGAIN_L_ADDR; ++ sns_state->regs_info[0].i2c_data[DGAIN_M_IDX].delay_frame_num = 0; ++ sns_state->regs_info[0].i2c_data[DGAIN_M_IDX].reg_addr = OS04A10_DGAIN_M_ADDR; ++ sns_state->regs_info[0].i2c_data[DGAIN_H_IDX].delay_frame_num = 0; ++ sns_state->regs_info[0].i2c_data[DGAIN_H_IDX].reg_addr = OS04A10_DGAIN_H_ADDR; ++ ++ sns_state->regs_info[0].i2c_data[VMAX_L_IDX].delay_frame_num = 0; ++ sns_state->regs_info[0].i2c_data[VMAX_L_IDX].reg_addr = OS04A10_VMAX_L_ADDR; ++ sns_state->regs_info[0].i2c_data[VMAX_H_IDX].delay_frame_num = 0; ++ sns_state->regs_info[0].i2c_data[VMAX_H_IDX].reg_addr = OS04A10_VMAX_H_ADDR; ++ ++ sns_state->regs_info[0].i2c_data[GROUP1].delay_frame_num = 1; ++ sns_state->regs_info[0].i2c_data[GROUP1].reg_addr = OS04A10_GROUP_1_ADDR; ++ ++ sns_state->regs_info[0].i2c_data[GROUP2].delay_frame_num = 1; ++ sns_state->regs_info[0].i2c_data[GROUP2].reg_addr = OS04A10_GROUP_2_ADDR; ++ ++ sns_state->regs_info[0].i2c_data[HCG_1_IDX].delay_frame_num = 1; ++ sns_state->regs_info[0].i2c_data[HCG_1_IDX].interrupt_pos = 0; ++ sns_state->regs_info[0].i2c_data[HCG_1_IDX].reg_addr = OS04A10_HCG_1_ADDR; ++ ++ sns_state->regs_info[0].i2c_data[GROUP3].delay_frame_num = 1; ++ sns_state->regs_info[0].i2c_data[GROUP3].reg_addr = OS04A10_GROUP_3_ADDR; ++ ++ sns_state->regs_info[0].i2c_data[GROUP4].delay_frame_num = 1; ++ sns_state->regs_info[0].i2c_data[GROUP4].reg_addr = OS04A10_GROUP_4_ADDR; ++ ++ sns_state->regs_info[0].i2c_data[GROUP5].delay_frame_num = 1; ++ sns_state->regs_info[0].i2c_data[GROUP5].reg_addr = OS04A10_GROUP_5_ADDR; ++ ++ sns_state->regs_info[0].i2c_data[GROUP6].delay_frame_num = 1; ++ sns_state->regs_info[0].i2c_data[GROUP6].reg_addr = OS04A10_GROUP_6_ADDR; ++ ++ return; ++} ++ ++static td_void cmos_sns_reg_info_update(ot_vi_pipe vi_pipe, ot_isp_sns_state *sns_state) ++{ ++ td_u32 i; ++ ot_unused(vi_pipe); ++ ++ for (i = 0; i < sns_state->regs_info[0].reg_num; i++) { ++ if (sns_state->regs_info[0].i2c_data[i].data == ++ sns_state->regs_info[1].i2c_data[i].data) { ++ sns_state->regs_info[0].i2c_data[i].update = TD_FALSE; ++ } else { ++ if (i != HCG_1_IDX) { ++ sns_state->regs_info[0].i2c_data[i].update = TD_TRUE; ++ } else { ++ sns_state->regs_info[0].i2c_data[GROUP1].update = TD_TRUE; ++ sns_state->regs_info[0].i2c_data[GROUP2].update = TD_TRUE; ++ sns_state->regs_info[0].i2c_data[HCG_1_IDX].update = TD_TRUE; ++ sns_state->regs_info[0].i2c_data[GROUP3].update = TD_TRUE; ++ sns_state->regs_info[0].i2c_data[GROUP4].update = TD_TRUE; ++ sns_state->regs_info[0].i2c_data[GROUP5].update = TD_TRUE; ++ sns_state->regs_info[0].i2c_data[GROUP6].update = TD_TRUE; ++ break; ++ } ++ } ++ } ++ ++ return; ++} ++ ++static td_s32 cmos_get_sns_regs_info(ot_vi_pipe vi_pipe, ot_isp_sns_regs_info *sns_regs_info) ++{ ++ ot_isp_sns_state *sns_state = TD_NULL; ++ ++ sensor_check_pointer_return(sns_regs_info); ++ os04a10_sensor_get_ctx(vi_pipe, sns_state); ++ sensor_check_pointer_return(sns_state); ++ ++ if ((sns_state->sync_init == TD_FALSE) || (sns_regs_info->config == TD_FALSE)) { ++ cmos_comm_sns_reg_info_init(vi_pipe, sns_state); ++ sns_state->regs_info[0].i2c_data[GROUP1].data = 0x00; ++ sns_state->regs_info[0].i2c_data[GROUP2].data = 0x01; ++ sns_state->regs_info[0].i2c_data[GROUP3].data = 0x11; ++ sns_state->regs_info[0].i2c_data[GROUP4].data = 0x05; ++ sns_state->regs_info[0].i2c_data[GROUP5].data = 0x01; ++ sns_state->regs_info[0].i2c_data[GROUP6].data = 0xa0; ++ sns_state->sync_init = TD_TRUE; ++ } else { ++ cmos_sns_reg_info_update(vi_pipe, sns_state); ++ } ++ ++ sns_regs_info->config = TD_FALSE; ++ (td_void)memcpy_s(sns_regs_info, sizeof(ot_isp_sns_regs_info), ++ &sns_state->regs_info[0], sizeof(ot_isp_sns_regs_info)); ++ (td_void)memcpy_s(&sns_state->regs_info[1], sizeof(ot_isp_sns_regs_info), ++ &sns_state->regs_info[0], sizeof(ot_isp_sns_regs_info)); ++ sns_state->fl[1] = sns_state->fl[0]; ++ ++ return TD_SUCCESS; ++} ++ ++static td_void cmos_config_image_mode_param(ot_vi_pipe vi_pipe, td_u8 sensor_image_mode, ++ ot_isp_sns_state *sns_state) ++{ ++ ot_unused(vi_pipe); ++ switch (sensor_image_mode) { ++ case OS04A10_4M_30FPS_12BIT_LINEAR_MODE: ++ sns_state->fl_std = OS04A10_VMAX_4M_30FPS_12BIT_LINEAR; ++ break; ++ default: ++ sns_state->fl_std = OS04A10_VMAX_4M_30FPS_12BIT_LINEAR; ++ break; ++ } ++ ++ return; ++} ++ ++static td_s32 cmos_set_image_mode(ot_vi_pipe vi_pipe, const ot_isp_cmos_sensor_image_mode *sensor_image_mode) ++{ ++ td_u32 i; ++ td_u8 image_mode; ++ ot_isp_sns_state *sns_state = TD_NULL; ++ sensor_check_pointer_return(sensor_image_mode); ++ os04a10_sensor_get_ctx(vi_pipe, sns_state); ++ sensor_check_pointer_return(sns_state); ++ ++ image_mode = sns_state->img_mode; ++ ++ for (i = 0; i < OS04A10_MODE_BUTT; i++) { ++ if (sensor_image_mode->fps <= g_os04a10_mode_tbl[i].max_fps && ++ sensor_image_mode->width <= g_os04a10_mode_tbl[i].width && ++ sensor_image_mode->height <= g_os04a10_mode_tbl[i].height && ++ sns_state->wdr_mode == g_os04a10_mode_tbl[i].wdr_mode) { ++ image_mode = (os04a10_res_mode)i; ++ break; ++ } ++ } ++ ++ if (i >= OS04A10_MODE_BUTT) { ++ os04a10_err_mode_print(sensor_image_mode, sns_state); ++ return TD_FAILURE; ++ } ++ ++ cmos_config_image_mode_param(vi_pipe, image_mode, sns_state); ++ ++ if ((sns_state->init == TD_TRUE) && (image_mode == sns_state->img_mode)) { ++ return OT_ISP_DO_NOT_NEED_SWITCH_IMAGEMODE; /* Don't need to switch image_mode */ ++ } ++ ++ sns_state->sync_init = TD_FALSE; ++ sns_state->img_mode = image_mode; ++ sns_state->fl[0] = sns_state->fl_std; ++ sns_state->fl[1] = sns_state->fl[0]; ++ ++ return TD_SUCCESS; ++} ++ ++static td_void sensor_global_init(ot_vi_pipe vi_pipe) ++{ ++ ot_isp_sns_state *sns_state = TD_NULL; ++ ++ os04a10_sensor_get_ctx(vi_pipe, sns_state); ++ sensor_check_pointer_void_return(sns_state); ++ ++ sns_state->init = TD_FALSE; ++ sns_state->sync_init = TD_FALSE; ++ sns_state->img_mode = OS04A10_4M_30FPS_12BIT_LINEAR_MODE; ++ sns_state->wdr_mode = OT_WDR_MODE_NONE; ++ sns_state->fl_std = OS04A10_VMAX_4M_30FPS_12BIT_LINEAR; ++ sns_state->fl[0] = OS04A10_VMAX_4M_30FPS_12BIT_LINEAR; ++ sns_state->fl[1] = OS04A10_VMAX_4M_30FPS_12BIT_LINEAR; ++ ++ (td_void)memset_s(&sns_state->regs_info[0], sizeof(ot_isp_sns_regs_info), 0, sizeof(ot_isp_sns_regs_info)); ++ (td_void)memset_s(&sns_state->regs_info[1], sizeof(ot_isp_sns_regs_info), 0, sizeof(ot_isp_sns_regs_info)); ++ ++ return; ++} ++ ++static td_s32 cmos_init_sensor_exp_function(ot_isp_sensor_exp_func *sensor_exp_func) ++{ ++ sensor_check_pointer_return(sensor_exp_func); ++ ++ (td_void)memset_s(sensor_exp_func, sizeof(ot_isp_sensor_exp_func), 0, sizeof(ot_isp_sensor_exp_func)); ++ ++ sensor_exp_func->pfn_cmos_sensor_init = os04a10_init; ++ sensor_exp_func->pfn_cmos_sensor_exit = os04a10_exit; ++ sensor_exp_func->pfn_cmos_sensor_global_init = sensor_global_init; ++ sensor_exp_func->pfn_cmos_set_image_mode = cmos_set_image_mode; ++ sensor_exp_func->pfn_cmos_set_wdr_mode = cmos_set_wdr_mode; ++ sensor_exp_func->pfn_cmos_get_isp_default = cmos_get_isp_default; ++ sensor_exp_func->pfn_cmos_get_isp_black_level = cmos_get_isp_black_level; ++ sensor_exp_func->pfn_cmos_get_blc_clamp_info = cmos_get_isp_blc_clamp_info; ++ sensor_exp_func->pfn_cmos_set_pixel_detect = cmos_set_pixel_detect; ++ sensor_exp_func->pfn_cmos_get_sns_reg_info = cmos_get_sns_regs_info; ++ ++ return TD_SUCCESS; ++} ++ ++static td_s32 os04a10_set_bus_info(ot_vi_pipe vi_pipe, ot_isp_sns_commbus sns_bus_info) ++{ ++ g_os04a10_bus_info[vi_pipe].i2c_dev = sns_bus_info.i2c_dev; ++ ++ return TD_SUCCESS; ++} ++ ++static td_s32 sensor_ctx_init(ot_vi_pipe vi_pipe) ++{ ++ ot_isp_sns_state *sns_state_ctx = TD_NULL; ++ ++ os04a10_sensor_get_ctx(vi_pipe, sns_state_ctx); ++ ++ if (sns_state_ctx == TD_NULL) { ++ sns_state_ctx = (ot_isp_sns_state *)malloc(sizeof(ot_isp_sns_state)); ++ if (sns_state_ctx == TD_NULL) { ++ isp_err_trace("Isp[%d] SnsCtx malloc memory failed!\n", vi_pipe); ++ return OT_ERR_ISP_NOMEM; ++ } ++ } ++ ++ (td_void)memset_s(sns_state_ctx, sizeof(ot_isp_sns_state), 0, sizeof(ot_isp_sns_state)); ++ ++ os04a10_sensor_set_ctx(vi_pipe, sns_state_ctx); ++ ++ return TD_SUCCESS; ++} ++ ++static td_void sensor_ctx_exit(ot_vi_pipe vi_pipe) ++{ ++ ot_isp_sns_state *sns_state_ctx = TD_NULL; ++ ++ os04a10_sensor_get_ctx(vi_pipe, sns_state_ctx); ++ sensor_free(sns_state_ctx); ++ os04a10_sensor_reset_ctx(vi_pipe); ++ ++ return; ++} ++ ++static td_s32 sensor_register_callback(ot_vi_pipe vi_pipe, ot_isp_3a_alg_lib *ae_lib, ot_isp_3a_alg_lib *awb_lib) ++{ ++ td_s32 ret; ++ ot_isp_sensor_register isp_register; ++ ot_isp_ae_sensor_register ae_register; ++ ot_isp_awb_sensor_register awb_register; ++ ot_isp_sns_attr_info sns_attr_info; ++ ++ sensor_check_pointer_return(ae_lib); ++ sensor_check_pointer_return(awb_lib); ++ ++ ret = sensor_ctx_init(vi_pipe); ++ if (ret != TD_SUCCESS) { ++ return TD_FAILURE; ++ } ++ ++ sns_attr_info.sensor_id = OS04A10_ID; ++ ret = cmos_init_sensor_exp_function(&isp_register.sns_exp); ++ if (ret != TD_SUCCESS) { ++ isp_err_trace("cmos init exp function failed!\n"); ++ return TD_FAILURE; ++ } ++ ret = ot_mpi_isp_sensor_reg_callback(vi_pipe, &sns_attr_info, &isp_register); ++ if (ret != TD_SUCCESS) { ++ isp_err_trace("sensor register callback function failed!\n"); ++ return ret; ++ } ++ ++ ret = cmos_init_ae_exp_function(&ae_register.sns_exp); ++ if (ret != TD_SUCCESS) { ++ isp_err_trace("cmos init ae exp function failed!\n"); ++ return TD_FAILURE; ++ } ++ ret = ot_mpi_ae_sensor_reg_callback(vi_pipe, ae_lib, &sns_attr_info, &ae_register); ++ if (ret != TD_SUCCESS) { ++ isp_err_trace("sensor register callback function to ae lib failed!\n"); ++ return ret; ++ } ++ ++ ret = cmos_init_awb_exp_function(&awb_register.sns_exp); ++ if (ret != TD_SUCCESS) { ++ isp_err_trace("cmos init awb exp function failed!\n"); ++ return TD_FAILURE; ++ } ++ ret = ot_mpi_awb_sensor_reg_callback(vi_pipe, awb_lib, &sns_attr_info, &awb_register); ++ if (ret != TD_SUCCESS) { ++ isp_err_trace("sensor register callback function to awb lib failed!\n"); ++ return ret; ++ } ++ ++ return TD_SUCCESS; ++} ++ ++static td_s32 sensor_unregister_callback(ot_vi_pipe vi_pipe, ot_isp_3a_alg_lib *ae_lib, ot_isp_3a_alg_lib *awb_lib) ++{ ++ td_s32 ret; ++ ++ sensor_check_pointer_return(ae_lib); ++ sensor_check_pointer_return(awb_lib); ++ ++ ret = ot_mpi_isp_sensor_unreg_callback(vi_pipe, OS04A10_ID); ++ if (ret != TD_SUCCESS) { ++ isp_err_trace("sensor unregister callback function failed!\n"); ++ return ret; ++ } ++ ++ ret = ot_mpi_ae_sensor_unreg_callback(vi_pipe, ae_lib, OS04A10_ID); ++ if (ret != TD_SUCCESS) { ++ isp_err_trace("sensor unregister callback function to ae lib failed!\n"); ++ return ret; ++ } ++ ++ ret = ot_mpi_awb_sensor_unreg_callback(vi_pipe, awb_lib, OS04A10_ID); ++ if (ret != TD_SUCCESS) { ++ isp_err_trace("sensor unregister callback function to awb lib failed!\n"); ++ return ret; ++ } ++ ++ sensor_ctx_exit(vi_pipe); ++ return TD_SUCCESS; ++} ++ ++static td_s32 sensor_set_init(ot_vi_pipe vi_pipe, ot_isp_init_attr *init_attr) ++{ ++ sensor_check_pointer_return(init_attr); ++ ++ g_init_exposure[vi_pipe] = init_attr->exposure; ++ g_lines_per500ms[vi_pipe] = init_attr->lines_per500ms; ++ g_init_wb_gain[vi_pipe][0] = init_attr->wb_r_gain; /* 0: rgain */ ++ g_init_wb_gain[vi_pipe][1] = init_attr->wb_g_gain; /* 1: ggain */ ++ g_init_wb_gain[vi_pipe][2] = init_attr->wb_b_gain; /* 2: bgain */ ++ g_sample_r_gain[vi_pipe] = init_attr->sample_r_gain; ++ g_sample_b_gain[vi_pipe] = init_attr->sample_b_gain; ++ g_quick_start_en[vi_pipe] = init_attr->quick_start_en; ++ g_ae_stat_pos[vi_pipe] = init_attr->ae_stat_pos; ++ ++ g_ae_route_ex_valid[vi_pipe] = init_attr->ae_route_ex_valid; ++ (td_void)memcpy_s(&g_init_ae_route[vi_pipe], sizeof(ot_isp_ae_route), ++ &init_attr->ae_route, sizeof(ot_isp_ae_route)); ++ (td_void)memcpy_s(&g_init_ae_route_ex[vi_pipe], sizeof(ot_isp_ae_route_ex), ++ &init_attr->ae_route_ex, sizeof(ot_isp_ae_route_ex)); ++ (td_void)memcpy_s(&g_init_ae_route_sf[vi_pipe], sizeof(ot_isp_ae_route), ++ &init_attr->ae_route_sf, sizeof(ot_isp_ae_route)); ++ (td_void)memcpy_s(&g_init_ae_route_sf_ex[vi_pipe], sizeof(ot_isp_ae_route_ex), ++ &init_attr->ae_route_sf_ex, sizeof(ot_isp_ae_route_ex)); ++ ++ return TD_SUCCESS; ++} ++ ++ot_isp_sns_obj g_sns_os04a10_obj = { ++ .pfn_register_callback = sensor_register_callback, ++ .pfn_un_register_callback = sensor_unregister_callback, ++ .pfn_standby = os04a10_standby, ++ .pfn_restart = os04a10_restart, ++ .pfn_mirror_flip = TD_NULL, ++ .pfn_set_blc_clamp = TD_NULL, ++ .pfn_write_reg = os04a10_write_register, ++ .pfn_read_reg = os04a10_read_register, ++ .pfn_set_bus_info = os04a10_set_bus_info, ++ .pfn_set_init = sensor_set_init ++}; +diff --git a/smp/a55_linux/mpp/sample/omnivision_os04a10/os04a10_cmos.h b/smp/a55_linux/mpp/sample/omnivision_os04a10/os04a10_cmos.h +new file mode 100644 +index 0000000..29569fa +--- /dev/null ++++ b/smp/a55_linux/mpp/sample/omnivision_os04a10/os04a10_cmos.h +@@ -0,0 +1,84 @@ ++/* ++ Copyright (c), 2001-2024, Shenshu Tech. Co., Ltd. ++ */ ++ ++#ifndef OS04A10_CMOS_H ++#define OS04A10_CMOS_H ++ ++#include "ot_common_isp.h" ++#include "ot_sns_ctrl.h" ++#include "securec.h" ++ ++#ifdef __cplusplus ++#if __cplusplus ++extern "C" { ++#endif ++#endif ++ ++#ifndef clip3 ++#define clip3(x, min, max) ((x) < (min) ? (min) : ((x) > (max) ? (max) : (x))) ++#endif ++ ++ ++#define OS04A10_I2C_ADDR 0x6c ++#define OS04A10_ADDR_BYTE 2 ++#define OS04A10_DATA_BYTE 1 ++#define os04a10_sensor_get_ctx(dev, ctx) ((ctx) = os04a10_get_ctx(dev)) ++ ++#define OS04A10_FULL_LINES_MAX 0x2610 ++#define OS04A10_INCREASE_LINES 0 /* make real fps less than stand fps because NVR require */ ++#define OS04A10_VMAX_4M_30FPS_12BIT_LINEAR (1624 + OS04A10_INCREASE_LINES) ++ ++typedef enum { ++ OS04A10_4M_30FPS_12BIT_LINEAR_MODE = 0, ++ OS04A10_MODE_BUTT ++} os04a10_res_mode; ++ ++typedef struct { ++ td_u32 ver_lines; ++ td_u32 max_ver_lines; ++ td_float max_fps; ++ td_float min_fps; ++ td_u32 width; ++ td_u32 height; ++ td_u8 sns_mode; ++ ot_wdr_mode wdr_mode; ++ const char *mode_name; ++} os04a10_video_mode_tbl; ++ ++typedef enum { ++ EXPO_L_IDX = 0, ++ EXPO_H_IDX, ++ AGAIN_L_IDX, ++ AGAIN_H_IDX, ++ DGAIN_L_IDX, ++ DGAIN_M_IDX, ++ DGAIN_H_IDX, ++ VMAX_L_IDX, ++ VMAX_H_IDX, ++ GROUP1, ++ GROUP2, ++ HCG_1_IDX, ++ GROUP3, ++ GROUP4, ++ GROUP5, ++ GROUP6, ++ REG_MAX_IDX ++}os04a10_linear_reg_index; ++ ++ot_isp_sns_state *os04a10_get_ctx(ot_vi_pipe vi_pipe); ++ot_isp_sns_commbus *os04a10_get_bus_info(ot_vi_pipe vi_pipe); ++ ++td_void os04a10_init(ot_vi_pipe vi_pipe); ++td_void os04a10_exit(ot_vi_pipe vi_pipe); ++td_void os04a10_standby(ot_vi_pipe vi_pipe); ++td_void os04a10_restart(ot_vi_pipe vi_pipe); ++td_s32 os04a10_write_register(ot_vi_pipe vi_pipe, td_u32 addr, td_u32 data); ++td_s32 os04a10_read_register(ot_vi_pipe vi_pipe, td_u32 addr); ++ ++#ifdef __cplusplus ++#if __cplusplus ++} ++#endif ++#endif /* End of #ifdef __cplusplus */ ++#endif /* OS04A10_CMOS_H */ +diff --git a/smp/a55_linux/mpp/sample/omnivision_os04a10/os04a10_cmos_ex.h b/smp/a55_linux/mpp/sample/omnivision_os04a10/os04a10_cmos_ex.h +new file mode 100644 +index 0000000..f84bf2e +--- /dev/null ++++ b/smp/a55_linux/mpp/sample/omnivision_os04a10/os04a10_cmos_ex.h +@@ -0,0 +1,3097 @@ ++/* ++ Copyright (c), 2001-2024, Shenshu Tech. Co., Ltd. ++ */ ++ ++#ifndef OS04A10_CMOS_EX_H ++#define OS04A10_CMOS_EX_H ++ ++#include "ot_common_awb.h" ++#include "ot_common_isp.h" ++#include "ot_common_sns.h" ++ ++#ifdef __cplusplus ++#if __cplusplus ++extern "C" { ++#endif ++#endif ++ ++static const ot_isp_cmos_black_level g_cmos_blc = { ++ TD_FALSE, /* user_black_level_en */ ++ { ++ {1200, 1200, 1200, 1200}, ++ {1200, 1200, 1200, 1200}, ++ {1200, 1200, 1200, 1200}, ++ {1200, 1200, 1200, 1200}, ++ }, /* user_black_level */ ++ OT_ISP_BLACK_LEVEL_MODE_AUTO, /* ot_isp_black_level_mode */ ++ { ++ { ++ {1024, 1024, 1024, 1024}, ++ {1024, 1024, 1024, 1024}, ++ {1024, 1024, 1024, 1024}, ++ {1024, 1024, 1024, 1024}, ++ }, ++ }, /* manual_attr */ ++ { ++ OT_ISP_DYNAMIC_PATTERN_RGB, /* ot_isp_black_level_dynamic_pattern */ ++ {0, 0, 2592, 14}, /* ob_area */ ++ 0, /* low_threshold */ ++ 4095, /* high_threshold */ ++ {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* dynablc offset */ ++ 0x0, /* dynablc tolerance */ ++ 0x0, /* filter_strength */ ++ 0x0, /* separate_mode */ ++ {1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024}, ++ 0, ++ /* calibration black level */ ++ }, /* dynamic_attr */ ++ { ++ 0, /* update mode 0 */ ++ { ++ {1024, 1024, 1024, 1024}, /* black level 1024 */ ++ {1024, 1024, 1024, 1024}, /* black level 1024 */ ++ {1024, 1024, 1024, 1024}, /* black level 1024 */ ++ {1024, 1024, 1024, 1024}, /* black level 1024 */ ++ }, ++ }, ++ { ++ {2688, 1520}, ++ }, ++}; ++ ++static const ot_isp_dp_dynamic_auto_attr g_cmos_dpc = { ++ { 0, 0, 0, 152, 220, 220, 220, 220, 220, 220, 152, 152, 152, 152, 152, 152 }, /* strength[16] */ ++ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50 }, /* blend_ratio[16] */ ++}; ++ ++#ifdef CONFIG_OT_ISP_CR_SUPPORT ++static const ot_isp_cr_attr g_cmos_ge = { ++ 1, /* en */ ++ 9, /* slope */ ++ 9, /* sensi_slope */ ++ 300, /* sensi_threshold */ ++ { 128, 128, 128, 128, 129, 129, 129, 129, 130, 130, 130, 130, 131, 131, 131, 131 }, /* strength */ ++ { 300, 300, 300, 300, 310, 310, 310, 310, 320, 320, 320, 320, 330, 330, 330, 330 }, /* threshold */ ++ { 1024, 1024, 1024, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048 } /* np_offset */ ++}; ++#endif ++ ++static const ot_isp_demosaic_attr g_cmos_demosaic = { ++ 1, /* en */ ++ OT_OP_MODE_AUTO, /* op_type */ ++ { ++ 48, /* nddm_strength */ ++ 64, /* nddm_mf_detail_strength */ ++ 0, /* nddm_hf_detail_strength */ ++ 2, /* detail_smooth_range */ ++ 0, /* color_noise_f_threshold */ ++ 8, /* color_noise_f_strength */ ++ 1, /* color_noise_y_threshold */ ++ 10, /* color_noise_y_strength */ ++ }, ++ { ++ /* nddm_strength */ ++ { 48, 48, 48, 54, 54, 54, 48, 40, 40, 48, 48, 48, 48, 48, 48, 48 }, ++ /* nddm_mf_detail_strength */ ++ { 82, 74, 68, 60, 54, 50, 44, 40, 40, 40, 40, 32, 16, 16, 16, 16 }, ++ /* nddm_hf_detail_strength */ ++ { 0, 0, 1, 2, 4, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, ++ /* detail_smooth_range */ ++ { 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 5, 7, 7, 7, 7 }, ++ /* color_noise_f_threshold */ ++ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, ++ /* color_noise_f_strength */ ++ { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }, ++ /* color_noise_y_threshold */ ++ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, ++ /* color_noise_y_strength */ ++ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, ++ } ++}; ++ ++static const ot_isp_anti_false_color_attr g_cmos_anti_false_color = { ++ 1, /* en */ ++ OT_OP_MODE_AUTO, /* op_type */ ++ { 8, 8 }, /* manual_attr */ ++ { ++ { 10, 10, 8, 8, 7, 7, 7, 6, 6, 6, 5, 4, 3, 2, 1, 0 }, /* anti_false_color_threshold */ ++ { 12, 12, 8, 8, 7, 7, 7, 6, 6, 6, 5, 4, 3, 2, 1, 0 }, /* anti_false_color_strength */ ++ } ++}; ++ ++/* BAYER NR */ ++static ot_isp_noise_calibration g_cmos_noise_calibration = { ++ { ++ 6400, 0.0001548619, -0.4611639237, 0.0000000130, -0.0001639422, 2.1603885856, ++ 0.0001318677, 0.0220043103, 0.0000000104, 0.0000052716, 0.0067668941, 0, 0, 0, 0, 0 ++ } ++}; ++ ++static const ot_isp_nr_attr g_cmos_bayer_nr = { ++ 1, /* bEnable */ ++ 0, /* enOpType */ ++ 1, /* tnr_enable */ ++ 0, /* lsc_nr_enable */ ++ 0, /* lsc_ratio1 */ ++ 1, /* lsc_ratio2 */ ++ { ++ 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, ++ 85, 85, 85, 85, 85, 85, 90, 90, 90, 95, 95, 95, 100, 100, 100, 100, 100 ++ }, /* CoringRatio */ ++ ++ /* snr_cfg */ ++ { ++ { ++ /* snr auto */ ++ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, /* sfm_thresh */ ++ {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* sfm0_mode */ ++ { ++ {108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108}, ++ {108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108}, ++ {108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108}, ++ {108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108} ++ }, ++ {13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13}, /* sfm0_ex_strength */ ++ {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}, /* sfm0_ext_detail_prot */ ++ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* sfm0_normal_edge_str */ ++ {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}, /* sfm1_detail_prot */ ++ {32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32}, /* sfm1_coarstr */ ++ {128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}, /* finestr */ ++ {50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50}, /* coring_wgt */ ++ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} /* coring_mot_th */ ++ }, ++ ++ { ++ /* snr manual */ ++ 255, /* sfm_thresh */ ++ 1, /* sfm0_mode */ ++ { 108, 108, 108, 108 }, /* snr_sfm0_coarstr */ ++ 13, /* sfm0_ex_strength */ ++ 16, /* sfm0_ext_detail_prot */ ++ 0, /* sfm0_normal_edge_str */ ++ 16, /* sfm1_detail_prot */ ++ 32, /* sfm1_coarstr */ ++ 128, /* finestr */ ++ 50, /* coring_wgt */ ++ 0, /* coring_mot_th */ ++ }, ++ }, ++ /* tnr_cfg */ ++ { ++ { ++ /* tnr auto */ ++ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* md_mode */ ++ {0, 0, 0, 16, 24, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32}, /* md_anti_flicker_str */ ++ {24, 24, 20, 20, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}, /* md_static_ratio */ ++ {32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32}, /* md_static_finestr */ ++ {0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 60, 60, 60, 60, 60, 60}, /* tnr_tss */ ++ {128, 128, 128, 128, 180, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, /* tnr_tfr */ ++ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, /* tnr_tfs */ ++ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* user_define_md */ ++ {0, 0, 0, 0, 0, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* user_define_slope */ ++ {0, 0, 0, 0, 0, 90, 90, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* user_define_dark_thresh */ ++ {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}, /* user_define_color_thresh */ ++ {26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26}, /* sfr_r */ ++ {32, 32, 32, 32, 32, 32, 32, 128, 128, 128, 80, 80, 80, 80, 80, 80}, /* sfr_g */ ++ {26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26}, /* sfr_b */ ++ }, ++ { ++ 0, /* md_mode */ ++ 64, /* md_anti_flicker_str */ ++ 32, /* md_static_ratio */ ++ 32, /* md_static_finestr */ ++ 0, /* tnr_tss */ ++ 255, /* tnr_tfr */ ++ 255, /* tnr_tfs */ ++ 0, /* user_define_md */ ++ 0, /* user_define_bright_thresh */ ++ 90, /* user_define_dark_thresh */ ++ 16, /* user_define_color_thresh */ ++ 26, /* sfr_r */ ++ 32, /* sfr_g */ ++ 26, /* sfr_b */ ++ } ++ }, ++ ++ /* wdr_cfg */ ++ { ++ {16, 16, 16, 16}, /* sfm0_wdr_frame_str */ ++ {16, 16, 16, 16}, /* sfm0_fusion_frame_str */ ++ 16, ++ 16, ++ {16, 16, 16, 16}, /* md_wdr_frame_str */ ++ {16, 16, 16, 16}, /* md_fusion_frame_str */ ++ } ++}; ++ ++static const ot_isp_ldci_attr g_cmos_ldci = { ++ /* enable */ ++ 1, ++ /* gauss_lpf_sigma */ ++ 36, ++ /* ot_op_mode */ ++ 0, ++ ++ /* ot_isp_ldci_manual_attr */ ++ { ++ /* ot_isp_ldci_he_wgt_attr */ ++ { ++ /* he_pos_wgt */ ++ { ++ 50, 80, 32 ++ }, ++ /* he_neg_wgt */ ++ { ++ 60, 80, 128 ++ } ++ }, ++ ++ /* blc_ctrl */ ++ 20 ++ }, ++ ++ /* ot_isp_ldci_auto_attr */ ++ { ++ /* he_wgt[OT_ISP_AUTO_ISO_NUM] */ ++ { ++ {{48, 80, 32}, {60, 80, 128}}, ++ {{45, 80, 16}, {45, 80, 128}}, ++ {{42, 70, 0}, {45, 80, 128}}, ++ {{40, 70, 0}, {45, 80, 0}}, ++ {{35, 70, 0}, {45, 80, 0}}, ++ {{32, 64, 0}, {24, 72, 0}}, ++ {{12, 24, 0}, {12, 64, 0}}, ++ {{8, 20, 0}, {8, 54, 0}}, ++ {{6, 12, 0}, {6, 36, 0}}, ++ {{0, 8, 0}, {0, 8, 0}}, ++ {{0, 6, 0}, {0, 6, 0}}, ++ {{0, 2, 0}, {0, 2, 0}}, ++ {{0, 1, 0}, {0, 1, 0}}, ++ {{0, 1, 0}, {0, 1, 0}}, ++ {{0, 1, 0}, {0, 1, 0}}, ++ {{0, 1, 0}, {0, 1, 0}} ++ }, ++ ++ /* blc_ctrl */ ++ { 20, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 } ++ }, ++ ++ /* tpr_incr_coef */ ++ 8, ++ /* tpr_decr_coef */ ++ 8 ++}; ++ ++static const ot_isp_gamma_attr g_cmos_gamma = { ++ 1, ++ { ++ 0, 13, 27, 40, 54, 68, 81, 95, 108, 121, 135, 150, 166, 180, 195, 210, 226, 242, ++ 259, 269, 281, 292, 303, 315, 327, 339, 352, 364, 376, 389, 402, 415, 425, 435, 446, 456, ++ 467, 477, 488, 499, 510, 521, 532, 543, 555, 566, 578, 591, 602, 613, 625, 636, 648, 659, ++ 671, 683, 695, 708, 721, 734, 748, 762, 777, 792, 809, 817, 826, 836, 845, 855, 865, 875, ++ 885, 896, 906, 917, 928, 939, 950, 961, 972, 983, 994, 1005, 1017, 1028, 1039, 1051, 1062, 1073, ++ 1085, 1096, 1107, 1118, 1129, 1140, 1151, 1161, 1172, 1182, 1193, 1203, 1213, 1223, 1234, 1244, 1254, 1264, ++ 1274, 1284, 1295, 1305, 1315, 1325, 1336, 1346, 1357, 1367, 1378, 1389, 1400, 1411, 1422, 1433, 1445, 1456, ++ 1468, 1480, 1493, 1499, 1505, 1511, 1518, 1524, 1531, 1537, 1544, 1551, 1558, 1564, 1571, 1578, 1585, 1592, ++ 1599, 1607, 1614, 1621, 1628, 1635, 1643, 1650, 1657, 1665, 1672, 1679, 1687, 1694, 1702, 1709, 1716, 1724, ++ 1731, 1738, 1746, 1753, 1761, 1768, 1775, 1783, 1790, 1797, 1804, 1811, 1819, 1826, 1833, 1840, 1847, 1854, ++ 1861, 1867, 1874, 1881, 1888, 1894, 1901, 1907, 1914, 1920, 1926, 1932, 1939, 1945, 1951, 1956, 1962, 1968, ++ 1974, 1980, 1986, 1991, 1997, 2003, 2008, 2014, 2020, 2025, 2031, 2036, 2042, 2047, 2052, 2058, 2063, 2068, ++ 2074, 2079, 2084, 2089, 2094, 2099, 2105, 2110, 2115, 2120, 2125, 2130, 2135, 2140, 2145, 2150, 2154, 2159, ++ 2164, 2169, 2174, 2179, 2183, 2188, 2193, 2198, 2202, 2207, 2212, 2217, 2221, 2226, 2231, 2235, 2240, 2244, ++ 2249, 2254, 2258, 2263, 2268, 2272, 2277, 2281, 2286, 2290, 2295, 2299, 2304, 2308, 2312, 2317, 2321, 2325, ++ 2330, 2334, 2338, 2342, 2347, 2351, 2355, 2359, 2363, 2368, 2372, 2376, 2380, 2384, 2388, 2392, 2396, 2400, ++ 2404, 2408, 2412, 2416, 2420, 2424, 2428, 2432, 2436, 2439, 2443, 2447, 2451, 2455, 2459, 2463, 2466, 2470, ++ 2474, 2478, 2482, 2485, 2489, 2493, 2497, 2500, 2504, 2508, 2512, 2515, 2519, 2523, 2527, 2530, 2534, 2538, ++ 2541, 2545, 2548, 2552, 2556, 2559, 2563, 2566, 2570, 2574, 2577, 2581, 2584, 2588, 2591, 2594, 2598, 2601, ++ 2605, 2608, 2612, 2615, 2618, 2622, 2625, 2629, 2632, 2635, 2639, 2642, 2645, 2649, 2652, 2655, 2659, 2662, ++ 2665, 2668, 2672, 2675, 2678, 2681, 2685, 2688, 2691, 2694, 2698, 2701, 2704, 2707, 2710, 2714, 2717, 2720, ++ 2723, 2727, 2730, 2733, 2736, 2739, 2743, 2746, 2749, 2752, 2755, 2758, 2762, 2765, 2768, 2771, 2774, 2777, ++ 2781, 2784, 2787, 2790, 2793, 2796, 2800, 2803, 2806, 2809, 2812, 2815, 2818, 2821, 2824, 2827, 2831, 2834, ++ 2837, 2840, 2843, 2846, 2849, 2852, 2855, 2858, 2861, 2864, 2867, 2870, 2873, 2876, 2879, 2882, 2885, 2887, ++ 2890, 2893, 2896, 2899, 2902, 2905, 2908, 2910, 2913, 2916, 2919, 2922, 2924, 2927, 2930, 2933, 2936, 2938, ++ 2941, 2944, 2946, 2949, 2952, 2954, 2957, 2960, 2962, 2965, 2967, 2970, 2972, 2975, 2978, 2980, 2983, 2985, ++ 2988, 2990, 2993, 2995, 2998, 3000, 3002, 3005, 3007, 3010, 3012, 3015, 3017, 3019, 3022, 3024, 3026, 3029, ++ 3031, 3034, 3036, 3038, 3041, 3043, 3045, 3048, 3050, 3052, 3055, 3057, 3059, 3062, 3064, 3066, 3069, 3071, ++ 3073, 3075, 3078, 3080, 3082, 3085, 3087, 3089, 3092, 3094, 3096, 3098, 3101, 3103, 3105, 3107, 3110, 3112, ++ 3114, 3116, 3119, 3121, 3123, 3125, 3128, 3130, 3132, 3134, 3136, 3139, 3141, 3143, 3145, 3147, 3149, 3152, ++ 3154, 3156, 3158, 3160, 3162, 3165, 3167, 3169, 3171, 3173, 3175, 3177, 3179, 3182, 3184, 3186, 3188, 3190, ++ 3192, 3194, 3196, 3198, 3201, 3203, 3205, 3207, 3209, 3211, 3213, 3215, 3217, 3219, 3221, 3223, 3225, 3227, ++ 3230, 3232, 3234, 3236, 3238, 3240, 3242, 3244, 3246, 3248, 3250, 3252, 3254, 3256, 3258, 3260, 3262, 3264, ++ 3266, 3268, 3270, 3272, 3274, 3276, 3278, 3280, 3282, 3283, 3285, 3287, 3289, 3291, 3293, 3295, 3297, 3299, ++ 3301, 3303, 3305, 3307, 3309, 3311, 3312, 3314, 3316, 3318, 3320, 3322, 3324, 3326, 3328, 3330, 3332, 3334, ++ 3335, 3337, 3339, 3341, 3343, 3345, 3347, 3349, 3351, 3353, 3355, 3356, 3358, 3360, 3362, 3364, 3366, 3368, ++ 3370, 3371, 3373, 3375, 3377, 3379, 3381, 3382, 3384, 3386, 3388, 3390, 3392, 3393, 3395, 3397, 3399, 3401, ++ 3403, 3404, 3406, 3408, 3410, 3412, 3413, 3415, 3417, 3419, 3421, 3423, 3424, 3426, 3428, 3430, 3432, 3434, ++ 3435, 3437, 3439, 3441, 3443, 3445, 3447, 3448, 3450, 3452, 3454, 3456, 3458, 3460, 3462, 3464, 3466, 3468, ++ 3470, 3472, 3474, 3475, 3477, 3479, 3481, 3483, 3486, 3488, 3490, 3492, 3494, 3496, 3498, 3500, 3502, 3504, ++ 3506, 3508, 3510, 3512, 3514, 3517, 3519, 3521, 3523, 3525, 3527, 3529, 3531, 3533, 3536, 3538, 3540, 3542, ++ 3544, 3546, 3548, 3550, 3553, 3555, 3557, 3559, 3561, 3563, 3565, 3568, 3570, 3572, 3574, 3576, 3578, 3580, ++ 3582, 3585, 3587, 3589, 3591, 3593, 3595, 3597, 3599, 3601, 3603, 3605, 3608, 3610, 3612, 3614, 3616, 3618, ++ 3620, 3622, 3624, 3626, 3628, 3630, 3632, 3634, 3636, 3638, 3640, 3642, 3645, 3647, 3649, 3651, 3653, 3655, ++ 3657, 3659, 3661, 3663, 3665, 3667, 3669, 3671, 3673, 3675, 3677, 3679, 3681, 3683, 3685, 3687, 3689, 3691, ++ 3693, 3695, 3697, 3699, 3701, 3704, 3706, 3708, 3710, 3712, 3714, 3716, 3718, 3720, 3722, 3724, 3726, 3728, ++ 3730, 3732, 3734, 3736, 3738, 3740, 3742, 3744, 3746, 3748, 3750, 3752, 3754, 3756, 3758, 3760, 3762, 3764, ++ 3766, 3767, 3769, 3771, 3773, 3775, 3777, 3779, 3781, 3783, 3785, 3787, 3789, 3791, 3793, 3795, 3797, 3799, ++ 3801, 3803, 3804, 3806, 3808, 3810, 3812, 3814, 3816, 3818, 3820, 3822, 3824, 3826, 3828, 3830, 3832, 3834, ++ 3836, 3837, 3839, 3841, 3843, 3845, 3847, 3849, 3851, 3853, 3855, 3857, 3858, 3860, 3862, 3864, 3866, 3868, ++ 3870, 3872, 3873, 3875, 3877, 3879, 3881, 3883, 3885, 3887, 3888, 3890, 3892, 3894, 3896, 3898, 3900, 3902, ++ 3904, 3905, 3907, 3909, 3911, 3913, 3915, 3917, 3919, 3920, 3922, 3924, 3926, 3928, 3930, 3932, 3934, 3935, ++ 3937, 3939, 3941, 3943, 3945, 3947, 3949, 3950, 3952, 3954, 3955, 3957, 3959, 3961, 3963, 3965, 3967, 3969, ++ 3971, 3972, 3974, 3976, 3977, 3979, 3981, 3983, 3985, 3987, 3989, 3991, 3993, 3994, 3996, 3998, 4000, 4001, ++ 4003, 4005, 4006, 4008, 4010, 4012, 4014, 4016, 4018, 4020, 4022, 4023, 4025, 4027, 4028, 4030, 4032, 4034, ++ 4036, 4037, 4039, 4041, 4042, 4044, 4046, 4048, 4050, 4052, 4054, 4056, 4058, 4059, 4061, 4063, 4064, 4066, ++ 4068, 4070, 4072, 4073, 4075, 4077, 4078, 4080, 4082, 4084, 4086, 4087, 4089, 4091, 4092, 4094, 4095, ++ }, ++ 3, ++}; ++ ++#ifdef CONFIG_OT_ISP_PREGAMMA_SUPPORT ++static const ot_isp_pregamma_attr g_cmos_pregamma = { ++ 0, ++ { ++ 0, 12417, 21619, 29902, 37641, 44997, 52063, 58896, 65536, 72012, 78344, 84552, ++ 90647, 96641, 102544, 108363, 114105, 119775, 125379, 130921, 136406, 141835, 147213, 152542, ++ 157825, 163065, 168262, 173420, 178540, 183623, 188671, 193686, 198668, 203619, 208541, 213433, ++ 218298, 223136, 227947, 232734, 237496, 242234, 246949, 251642, 256313, 260962, 265592, 270201, ++ 274790, 279360, 283912, 288446, 292962, 297460, 301942, 306407, 310855, 315288, 319706, 324108, ++ 328495, 332868, 337226, 341571, 345901, 350218, 354522, 358813, 363091, 367356, 371609, 375850, ++ 380079, 384296, 388502, 392696, 396880, 401052, 405213, 409364, 413504, 417634, 421754, 425863, ++ 429963, 434053, 438134, 442205, 446266, 450319, 454362, 458396, 462422, 466438, 470446, 474446, ++ 478437, 482420, 486395, 490361, 494320, 498270, 502213, 506148, 510076, 513996, 517908, 521813, ++ 525711, 529601, 533485, 537361, 541231, 545093, 548949, 552798, 556640, 560475, 564305, 568127, ++ 571943, 575753, 579557, 583354, 587145, 590930, 594709, 598482, 602249, 606010, 609765, 613515, ++ 617259, 620997, 624729, 628456, 632178, 635894, 639604, 643309, 647009, 650704, 654393, 658077, ++ 661756, 665430, 669099, 672763, 676421, 680075, 683724, 687368, 691008, 694642, 698272, 701897, ++ 705517, 709133, 712744, 716351, 719953, 723550, 727143, 730732, 734316, 737896, 741471, 745043, ++ 748610, 752172, 755731, 759285, 762835, 766381, 769923, 773461, 776995, 780525, 784050, 787572, ++ 791090, 794604, 798114, 801620, 805123, 808622, 812116, 815608, 819095, 822579, 826059, 829535, ++ 833008, 836477, 839942, 843404, 846862, 850317, 853768, 857216, 860661, 864102, 867539, 870973, ++ 874404, 877831, 881255, 884676, 888093, 891507, 894918, 898326, 901730, 905131, 908529, 911924, ++ 915316, 918704, 922090, 925472, 928851, 932227, 935600, 938970, 942337, 945701, 949062, 952420, ++ 955775, 959127, 962477, 965823, 969166, 972507, 975845, 979179, 982511, 985840, 989167, 992490, ++ 995811, 999129, 1002444, 1005757, 1009067, 1012374, 1015678, 1018980, 1022279, 1025575, 1028869, 1032160, ++ 1035448, 1038734, 1042017, 1045298, 1048575 ++ } ++}; ++#endif ++ ++static const ot_isp_sharpen_attr g_cmos_yuv_sharpen = { ++ /* en */ ++ 1, ++ /* motion_en */ ++ 0, ++ /* motion_threshold0 */ ++ 4, ++ /* motion_threshold1 */ ++ 10, ++ /* motion_gain0 */ ++ 0, ++ /* motion_gain1 */ ++ 255, ++ /* skin_umin */ ++ 99, ++ /* skin_vmin */ ++ 134, ++ /* skin_umax */ ++ 127, ++ /* skin_vmax */ ++ 128, ++ /* op_type */ ++ OT_OP_MODE_AUTO, ++ /* detail_map */ ++ OT_ISP_SHARPEN_NORMAL, ++ /* manual para */ ++ { ++ /* luma_wgt[OT_ISP_SHARPEN_LUMA_NUM] */ ++ { ++ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, ++ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 ++ }, ++ /* texture_strength[OT_ISP_SHARPEN_GAIN_NUM] */ ++ { ++ 250, 420, 390, 390, 390, 390, 390, 370, 350, 330, 310, 290, 270, 270, 270, 270, ++ 270, 270, 266, 260, 244, 230, 230, 230, 230, 230, 230, 210, 190, 190, 170, 150 ++ }, ++ /* edge_strength[OT_ISP_SHARPEN_GAIN_NUM] */ ++ { ++ 120, 123, 125, 128, 130, 135, 140, 148, 160, 168, 180, 190, 200, 210, 210, 210, ++ 210, 210, 200, 190, 185, 175, 165, 160, 146, 136, 130, 128, 125, 123, 120, 120 ++ }, ++ /* texture_freq */ ++ 190, ++ /* edge_freq */ ++ 128, ++ /* over_shoot */ ++ 65, ++ /* under_shoot */ ++ 75, ++ /* motion_texture_strength[OT_ISP_SHARPEN_GAIN_NUM] */ ++ { ++ 250, 420, 390, 390, 390, 390, 390, 370, 350, 330, 310, 290, 270, 270, 270, 270, ++ 270, 270, 266, 260, 244, 230, 230, 230, 230, 230, 230, 210, 190, 190, 170, 150 ++ }, ++ /* motion_edge_strength[OT_ISP_SHARPEN_GAIN_NUM] */ ++ { ++ 120, 123, 125, 128, 130, 135, 140, 148, 160, 168, 180, 190, 200, 210, 210, 210, ++ 210, 210, 200, 190, 185, 175, 165, 160, 146, 136, 130, 128, 125, 123, 120, 120 ++ }, ++ /* motion_texture_freq */ ++ 190, ++ /* motion_edge_freq */ ++ 128, ++ /* motion_over_shoot */ ++ 65, ++ /* motion_under_shoot */ ++ 75, ++ /* u8shoot_sup_str */ ++ 7, ++ /* u8shoot_sup_adj */ ++ 9, ++ /* detail_ctrl */ ++ 128, ++ /* detail_ctrl_threshold */ ++ 180, ++ /* edge_filt_strength */ ++ 60, ++ /* edge_filt_max_cap */ ++ 18, ++ /* r_gain */ ++ 20, ++ /* g_gain */ ++ 32, ++ /* b_gain */ ++ 20, ++ /* skin_gain */ ++ 25, ++ /* max_sharp_gain */ ++ 40, ++ }, ++ /* auto para */ ++ { ++ /* luma_wgt[OT_ISP_SHARPEN_GAIN_NUM][OT_ISP_AUTO_ISO_NUM] */ ++ { ++ { 31, 31, 28, 27, 27, 25, 25, 23, 23, 23, 23, 19, 19, 19, 19, 19 }, ++ { 31, 31, 28, 27, 27, 25, 25, 23, 23, 23, 23, 20, 20, 20, 20, 20 }, ++ { 31, 31, 28, 27, 27, 25, 25, 23, 23, 23, 23, 20, 20, 20, 20, 20 }, ++ { 31, 31, 28, 27, 27, 25, 25, 23, 23, 23, 23, 21, 21, 21, 21, 21 }, ++ { 31, 31, 28, 27, 27, 25, 25, 23, 23, 23, 23, 22, 22, 22, 22, 22 }, ++ { 31, 31, 28, 27, 27, 25, 25, 23, 23, 23, 23, 22, 22, 22, 22, 22 }, ++ { 31, 31, 28, 27, 27, 25, 25, 24, 24, 24, 24, 23, 23, 23, 23, 23 }, ++ { 31, 31, 28, 27, 27, 25, 25, 24, 24, 24, 24, 24, 24, 24, 24, 24 }, ++ { 31, 31, 28, 27, 27, 26, 26, 25, 25, 25, 25, 25, 25, 25, 25, 25 }, ++ { 31, 31, 28, 27, 27, 27, 27, 26, 26, 26, 26, 26, 26, 26, 26, 26 }, ++ { 31, 31, 28, 28, 28, 28, 28, 27, 27, 27, 27, 27, 27, 27, 27, 27 }, ++ { 31, 31, 28, 28, 28, 29, 29, 28, 28, 28, 28, 28, 28, 28, 28, 28 }, ++ { 31, 31, 29, 29, 29, 30, 30, 29, 29, 29, 29, 29, 29, 29, 29, 29 }, ++ { 31, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 }, ++ { 31, 31, 30, 30, 30, 31, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30 }, ++ { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, ++ { 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, ++ { 28, 29, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, ++ { 26, 28, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, ++ { 25, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, ++ { 25, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, ++ { 25, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, ++ { 25, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, ++ { 25, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, ++ { 25, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, ++ { 25, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, ++ { 25, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, ++ { 25, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, ++ { 25, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, ++ { 25, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, ++ { 25, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 }, ++ { 25, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 } ++ }, ++ /* texture_strength[OT_ISP_SHARPEN_GAIN_NUM][OT_ISP_AUTO_ISO_NUM] */ ++ { ++ { 88, 88, 88, 82, 82, 82, 75, 75, 75, 68, 68, 68, 68, 68, 68, 68 }, ++ { 95, 95, 95, 88, 88, 88, 80, 85, 81, 73, 73, 73, 73, 73, 73, 73 }, ++ { 104, 104, 104, 96, 96, 96, 88, 95, 89, 80, 80, 80, 80, 80, 80, 80 }, ++ { 116, 116, 116, 107, 107, 107, 98, 108, 101, 89, 89, 89, 89, 89, 89, 89 }, ++ { 127, 127, 127, 118, 118, 118, 108, 121, 114, 98, 98, 98, 98, 98, 98, 98 }, ++ { 139, 139, 139, 128, 128, 128, 118, 136, 130, 107, 107, 107, 107, 107, 107, 107 }, ++ { 150, 150, 150, 138, 138, 138, 127, 151, 145, 115, 115, 115, 115, 115, 115, 115 }, ++ { 156, 156, 156, 144, 144, 144, 132, 163, 157, 120, 120, 120, 120, 120, 120, 120 }, ++ { 160, 160, 160, 148, 148, 148, 135, 171, 164, 123, 123, 123, 123, 123, 123, 123 }, ++ { 163, 163, 163, 150, 150, 150, 138, 177, 169, 125, 125, 125, 125, 125, 125, 125 }, ++ { 165, 165, 165, 152, 152, 152, 140, 181, 171, 127, 127, 127, 127, 127, 127, 127 }, ++ { 166, 166, 166, 154, 154, 154, 141, 183, 173, 128, 128, 128, 128, 128, 128, 128 }, ++ { 166, 166, 166, 154, 154, 154, 141, 184, 173, 128, 128, 128, 128, 128, 128, 128 }, ++ { 165, 165, 165, 152, 152, 152, 140, 182, 173, 127, 127, 127, 127, 127, 127, 127 }, ++ { 164, 164, 164, 151, 151, 151, 139, 180, 171, 126, 126, 126, 126, 126, 126, 126 }, ++ { 161, 161, 161, 149, 149, 149, 136, 176, 168, 124, 124, 124, 124, 124, 124, 124 }, ++ { 157, 157, 157, 145, 145, 145, 133, 171, 165, 121, 121, 121, 121, 121, 121, 121 }, ++ { 152, 152, 152, 140, 140, 140, 129, 165, 162, 117, 117, 117, 117, 117, 117, 117 }, ++ { 147, 147, 147, 136, 136, 136, 124, 159, 157, 113, 113, 113, 113, 113, 113, 113 }, ++ { 140, 140, 140, 130, 130, 130, 119, 151, 152, 108, 108, 108, 108, 108, 108, 108 }, ++ { 133, 133, 133, 122, 122, 122, 112, 142, 145, 102, 102, 102, 102, 102, 102, 102 }, ++ { 125, 125, 125, 115, 115, 115, 106, 133, 137, 96, 96, 96, 96, 96, 96, 96 }, ++ { 117, 117, 117, 108, 108, 108, 99, 123, 129, 90, 90, 90, 90, 90, 90, 90 }, ++ { 111, 111, 111, 102, 102, 102, 94, 113, 120, 85, 85, 85, 85, 85, 85, 85 }, ++ { 103, 103, 103, 95, 95, 95, 87, 103, 111, 79, 79, 79, 79, 79, 79, 79 }, ++ { 95, 95, 95, 88, 88, 88, 80, 93, 102, 73, 73, 73, 73, 73, 73, 73 }, ++ { 87, 87, 87, 80, 80, 80, 74, 83, 93, 67, 67, 67, 67, 67, 67, 67 }, ++ { 78, 78, 78, 72, 72, 72, 66, 73, 84, 60, 60, 60, 60, 60, 60, 60 }, ++ { 70, 70, 70, 65, 65, 65, 59, 65, 73, 54, 54, 54, 54, 54, 54, 54 }, ++ { 62, 62, 62, 58, 58, 58, 53, 56, 62, 48, 48, 48, 48, 48, 48, 48 }, ++ { 57, 57, 57, 53, 53, 53, 48, 49, 51, 44, 44, 44, 44, 44, 44, 44 }, ++ { 52, 52, 52, 48, 48, 48, 44, 44, 44, 40, 40, 40, 40, 40, 40, 40 } ++ }, ++ /* edge_strength */ ++ { ++ { 183, 183, 183, 183, 183, 203, 203, 203, 223, 223, 223, 223, 223, 223, 223, 223 }, ++ { 186, 186, 186, 186, 186, 207, 207, 207, 228, 228, 228, 228, 228, 228, 228, 228 }, ++ { 191, 191, 191, 191, 191, 212, 212, 212, 233, 233, 233, 233, 233, 233, 233, 233 }, ++ { 197, 197, 197, 197, 197, 219, 219, 219, 241, 241, 241, 241, 241, 241, 241, 241 }, ++ { 203, 203, 203, 203, 203, 226, 226, 226, 249, 249, 249, 249, 249, 249, 249, 249 }, ++ { 209, 209, 209, 209, 209, 232, 232, 232, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 214, 214, 214, 214, 214, 238, 238, 238, 262, 262, 262, 262, 262, 262, 262, 262 }, ++ { 219, 219, 219, 219, 219, 243, 243, 243, 267, 267, 267, 267, 267, 267, 267, 267 }, ++ { 221, 221, 221, 221, 221, 246, 246, 246, 271, 271, 271, 271, 271, 271, 271, 271 }, ++ { 224, 224, 224, 224, 224, 249, 249, 249, 274, 274, 274, 274, 274, 274, 274, 274 }, ++ { 226, 226, 226, 226, 226, 251, 251, 251, 276, 276, 276, 276, 276, 276, 276, 276 }, ++ { 228, 228, 228, 228, 228, 253, 253, 253, 278, 278, 278, 278, 278, 278, 278, 278 }, ++ { 229, 229, 229, 229, 229, 254, 254, 254, 279, 279, 279, 279, 279, 279, 279, 279 }, ++ { 229, 229, 229, 229, 229, 254, 254, 254, 279, 279, 279, 279, 279, 279, 279, 279 }, ++ { 229, 229, 229, 229, 229, 254, 254, 254, 279, 279, 279, 279, 279, 279, 279, 279 }, ++ { 228, 228, 228, 228, 228, 253, 253, 253, 278, 278, 278, 278, 278, 278, 278, 278 }, ++ { 226, 226, 226, 226, 226, 251, 251, 251, 276, 276, 276, 276, 276, 276, 276, 276 }, ++ { 224, 224, 224, 224, 224, 249, 249, 249, 274, 274, 274, 274, 274, 274, 274, 274 }, ++ { 221, 221, 221, 221, 221, 246, 246, 246, 271, 271, 271, 271, 271, 271, 271, 271 }, ++ { 219, 219, 219, 219, 219, 243, 243, 243, 267, 267, 267, 267, 267, 267, 267, 267 }, ++ { 215, 215, 215, 215, 215, 239, 239, 239, 263, 263, 263, 263, 263, 263, 263, 263 }, ++ { 211, 211, 211, 211, 211, 234, 234, 234, 257, 257, 257, 257, 257, 257, 257, 257 }, ++ { 205, 205, 205, 205, 205, 228, 228, 228, 251, 251, 251, 251, 251, 251, 251, 251 }, ++ { 199, 199, 199, 199, 199, 221, 221, 221, 243, 243, 243, 243, 243, 243, 243, 243 }, ++ { 191, 191, 191, 191, 191, 212, 212, 212, 233, 233, 233, 233, 233, 233, 233, 233 }, ++ { 182, 182, 182, 182, 182, 202, 202, 202, 222, 222, 222, 222, 222, 222, 222, 222 }, ++ { 171, 171, 171, 171, 171, 190, 190, 190, 209, 209, 209, 209, 209, 209, 209, 209 }, ++ { 159, 159, 159, 159, 159, 177, 177, 177, 195, 195, 195, 195, 195, 195, 195, 195 }, ++ { 149, 149, 149, 149, 149, 165, 165, 165, 182, 182, 182, 182, 182, 182, 182, 182 }, ++ { 139, 139, 139, 139, 139, 154, 154, 154, 169, 169, 169, 169, 169, 169, 169, 169 }, ++ { 130, 130, 130, 130, 130, 144, 144, 144, 158, 158, 158, 158, 158, 158, 158, 158 }, ++ { 123, 123, 123, 123, 123, 137, 137, 137, 151, 151, 151, 151, 151, 151, 151, 151 } ++ }, ++ /* texture_freq[OT_ISP_AUTO_ISO_NUM] */ ++ { 200, 200, 190, 180, 180, 170, 160, 150, 130, 100, 80, 80, 80, 80, 80, 80 }, ++ /* edge_freq[OT_ISP_AUTO_ISO_NUM] */ ++ { 128, 128, 120, 120, 110, 110, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 }, ++ /* over_shoot[OT_ISP_AUTO_ISO_NUM] */ ++ { 50, 50, 50, 50, 50, 50, 50, 45, 40, 40, 40, 40, 40, 40, 40, 40 }, ++ /* under_shoot[OT_ISP_AUTO_ISO_NUM] */ ++ { 60, 60, 60, 60, 55, 55, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50 }, ++ /* motion_texture_strength[OT_ISP_SHARPEN_GAIN_NUM][OT_ISP_AUTO_ISO_NUM] */ ++ { ++ { 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149 }, ++ { 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154 }, ++ { 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161 }, ++ { 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170 }, ++ { 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180 }, ++ { 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190 }, ++ { 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 202 }, ++ { 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213 }, ++ { 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224 }, ++ { 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235 }, ++ { 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246 }, ++ { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262 }, ++ { 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, 268 }, ++ { 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272 }, ++ { 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, 273 }, ++ { 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, 272 }, ++ { 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, 269 }, ++ { 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264 }, ++ { 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, 257 }, ++ { 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 249 }, ++ { 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240 }, ++ { 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230 }, ++ { 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219 }, ++ { 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209 }, ++ { 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198 }, ++ { 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188 }, ++ { 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178 }, ++ { 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169 }, ++ { 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161, 161 }, ++ { 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155 }, ++ { 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150 } ++ }, ++ /* motion_edge_strength */ ++ { ++ { 195, 195, 195, 195, 195, 195, 400, 440, 500, 475, 475, 475, 475, 475, 475, 475 }, ++ { 210, 210, 200, 200, 200, 200, 400, 440, 500, 485, 485, 485, 485, 485, 485, 485 }, ++ { 235, 235, 220, 220, 220, 220, 400, 440, 500, 495, 495, 495, 495, 495, 495, 495 }, ++ { 260, 260, 230, 230, 230, 230, 400, 440, 500, 500, 500, 500, 500, 500, 500, 500 }, ++ { 295, 295, 240, 240, 240, 240, 400, 440, 500, 510, 510, 510, 510, 510, 510, 510 }, ++ { 320, 320, 250, 250, 250, 250, 400, 440, 500, 520, 520, 520, 520, 520, 520, 520 }, ++ { 340, 340, 260, 260, 260, 260, 420, 460, 540, 530, 530, 530, 530, 530, 530, 530 }, ++ { 350, 350, 270, 270, 270, 270, 420, 460, 540, 540, 540, 540, 540, 540, 540, 540 }, ++ { 360, 360, 280, 280, 280, 280, 420, 460, 540, 545, 545, 545, 545, 545, 545, 545 }, ++ { 360, 360, 280, 280, 280, 280, 420, 460, 540, 550, 550, 550, 550, 550, 550, 550 }, ++ { 355, 355, 285, 285, 285, 285, 420, 460, 540, 560, 560, 560, 560, 560, 560, 560 }, ++ { 345, 345, 290, 290, 290, 290, 420, 460, 540, 565, 565, 565, 565, 565, 565, 565 }, ++ { 335, 335, 290, 290, 290, 290, 420, 460, 540, 570, 570, 570, 570, 570, 570, 570 }, ++ { 330, 330, 295, 295, 295, 295, 430, 470, 550, 575, 575, 575, 575, 575, 575, 575 }, ++ { 325, 325, 295, 295, 295, 295, 430, 470, 550, 580, 580, 580, 580, 580, 580, 580 }, ++ { 320, 320, 295, 295, 295, 295, 440, 470, 550, 575, 575, 575, 575, 575, 575, 575 }, ++ { 315, 315, 295, 295, 295, 295, 440, 470, 550, 570, 570, 570, 570, 570, 570, 570 }, ++ { 310, 310, 295, 295, 295, 295, 450, 480, 580, 565, 565, 565, 565, 565, 565, 565 }, ++ { 305, 305, 295, 295, 295, 295, 460, 500, 580, 560, 560, 560, 560, 560, 560, 560 }, ++ { 295, 295, 290, 290, 290, 290, 460, 500, 580, 555, 555, 555, 555, 555, 555, 555 }, ++ { 285, 285, 285, 285, 285, 285, 460, 500, 580, 550, 550, 550, 550, 550, 550, 550 }, ++ { 280, 280, 280, 280, 280, 280, 460, 500, 580, 540, 540, 540, 540, 540, 540, 540 }, ++ { 275, 275, 275, 275, 275, 275, 460, 500, 580, 535, 535, 535, 535, 535, 535, 535 }, ++ { 265, 265, 265, 265, 265, 265, 460, 500, 580, 530, 530, 530, 530, 530, 530, 530 }, ++ { 250, 250, 250, 250, 250, 250, 460, 500, 580, 520, 520, 520, 520, 520, 520, 520 }, ++ { 240, 240, 240, 240, 240, 240, 470, 500, 580, 515, 515, 515, 515, 515, 515, 515 }, ++ { 220, 220, 220, 220, 220, 220, 470, 500, 580, 510, 510, 510, 510, 510, 510, 510 }, ++ { 200, 200, 200, 200, 200, 200, 470, 500, 580, 500, 500, 500, 500, 500, 500, 500 }, ++ { 180, 180, 180, 180, 180, 180, 480, 500, 580, 495, 495, 495, 495, 495, 495, 495 }, ++ { 160, 160, 160, 160, 160, 160, 480, 500, 580, 485, 485, 485, 485, 485, 485, 485 }, ++ { 140, 140, 140, 140, 140, 140, 480, 500, 580, 480, 480, 480, 480, 480, 480, 480 }, ++ { 125, 125, 125, 125, 125, 125, 480, 500, 580, 470, 470, 470, 470, 470, 470, 470 } ++ }, ++ /* motion_texture_freq[OT_ISP_AUTO_ISO_NUM] */ ++ { 200, 190, 190, 170, 170, 170, 160, 140, 128, 128, 128, 100, 100, 100, 100, 100 }, ++ /* motion_edge_freq[OT_ISP_AUTO_ISO_NUM] */ ++ { 128, 100, 100, 100, 100, 100, 100, 100, 100, 100, 96, 96, 96, 96, 96, 96 }, ++ /* motion_over_shoot[OT_ISP_AUTO_ISO_NUM] */ ++ { 65, 65, 62, 64, 64, 64, 56, 52, 50, 50, 30, 10, 10, 10, 10, 10 }, ++ /* motion_under_shoot[OT_ISP_AUTO_ISO_NUM] */ ++ { 65, 65, 62, 64, 64, 64, 54, 50, 50, 30, 20, 20, 15, 15, 15, 15 }, ++ /* shoot_sup_strength[OT_ISP_AUTO_ISO_NUM] */ ++ { 7, 7, 6, 6, 5, 5, 4, 4, 3, 0, 0, 0, 0, 0, 0, 0 }, ++ /* shoot_sup_adj[OT_ISP_AUTO_ISO_NUM] */ ++ { 9, 9, 8, 8, 7, 7, 6, 6, 5, 0, 0, 0, 0, 0, 0, 0 }, ++ /* detail_ctrl[OT_ISP_AUTO_ISO_NUM] */ ++ { 128, 128, 128, 128, 128, 128, 128, 128, 120, 120, 120, 120, 120, 120, 120, 120 }, ++ /* detail_ctrl_threshold[OT_ISP_AUTO_ISO_NUM] */ ++ { 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160 }, ++ /* edge_filt_strength[OT_ISP_AUTO_ISO_NUM] */ ++ { 58, 58, 58, 58, 60, 60, 60, 52, 50, 50, 50, 50, 50, 50, 50, 50 }, ++ /* edge_filt_max_cap */ ++ { 18, 18, 18, 18, 18, 18, 20, 18, 16, 15, 15, 15, 15, 15, 15, 15 }, ++ /* r_gain[OT_ISP_AUTO_ISO_NUM] */ ++ { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 }, ++ /* g_gain[OT_ISP_AUTO_ISO_NUM] */ ++ { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 }, ++ /* b_gain[OT_ISP_AUTO_ISO_NUM] */ ++ { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 }, ++ /* skin_gain[OT_ISP_AUTO_ISO_NUM] */ ++ { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 }, ++ /* max_sharp_gain[OT_ISP_AUTO_ISO_NUM] */ ++ { 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 }, ++ }, ++}; ++ ++static ot_isp_awb_ccm g_awb_ccm = { ++ 4, ++ { ++ { ++ 6420, ++ { 0x0196, 0x8092, 0x8004, 0x805B, 0x01B4, 0x8059, 0x801A, 0x808C, 0x01A6 }, ++ }, ++ { ++ 4949, ++ { 0x01A0, 0x809F, 0x8001, 0x8066, 0x01A7, 0x8041, 0x800C, 0x80F1, 0x01FD }, ++ }, ++ { ++ 3630, ++ { 0x01A0, 0x8084, 0x801C, 0x8083, 0x01C3, 0x8040, 0x0008, 0x811E, 0x0216 }, ++ }, ++ { ++ 2525, ++ { 0x02A7, 0x81CC, 0x0025, 0x806D, 0x01A6, 0x8039, 0x802A, 0x8133, 0x025D }, ++ }, ++ { ++ 2100, ++ { 0x0100, 0x0000, 0x0000, 0x0000, 0x0100, 0x0000, 0x0000, 0x0000, 0x0100 }, ++ }, ++ { ++ 1600, ++ { 0x0100, 0x0000, 0x0000, 0x0000, 0x0100, 0x0000, 0x0000, 0x0000, 0x0100 }, ++ }, ++ { ++ 1400, ++ { 0x0100, 0x0000, 0x0000, 0x0000, 0x0100, 0x0000, 0x0000, 0x0000, 0x0100 }, ++ }, ++ }, ++}; ++ ++static ot_isp_awb_agc_table g_awb_agc_table = { ++ /* bvalid */ ++ 1, ++ ++ /* 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 */ ++ /* saturation */ ++ { 128, 128, 128, 128, 124, 120, 116, 112, 108, 104, 100, 94, 90, 90, 90, 90 } ++}; ++ ++static const ot_isp_wdr_fs_attr g_cmos_wdr = { ++ /* ot_isp_wdr_merge_mode */ ++ OT_ISP_MERGE_FUSION_MODE, ++ ++ /* ot_isp_wdr_combine_attr */ ++ { ++ /* motion_comp */ ++ 1, ++ ++ /* forcelong_coarse */ ++ 1, ++ ++ /* short_thr */ ++ 4032, ++ ++ /* long_thr */ ++ 3008, ++ ++ /* force_long */ ++ 1, ++ ++ /* force_long_low_threshold */ ++ 500, ++ ++ /* force_long_hig_threshold */ ++ 700, ++ ++ /* ot_isp_fswdr_mdt_attr */ ++ { ++ /* short_expo_chk */ ++ 0, ++ ++ /* short_check_thd */ ++ 0x8, ++ ++ /* md_ref_flicker */ ++ 1, ++ ++ /* mdt_still_thd */ ++ 0x14, ++ ++ /* mdt_full_threshold */ ++ 254, ++ ++ /* mdt_long_blend */ ++ 0x0, ++ ++ /* ot_op_mode motion_comp */ ++ OT_OP_MODE_AUTO, ++ ++ /* ot_isp_fswdr_manual_attr */ ++ { ++ /* md_thr_low_gain */ ++ 64, 64 ++ }, ++ ++ /* ot_isp_fswdr_auto_attr */ ++ { ++ /* md_thr_low_gain[10][16] */ ++ { ++ { 45, 45, 45, 64, 96, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 45, 45, 45, 64, 96, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 24, 24, 24, 45, 64, 96, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 24, 24, 24, 45, 64, 96, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 45, 45, 45, 45, 64, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 45, 45, 45, 45, 64, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 64, 64, 64, 64, 128, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 128, 128, 128, 128, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 128, 128, 128, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } ++ }, ++ ++ /* md_thr_hig_gain[10][16] */ ++ { ++ { 64, 64, 64, 64, 96, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 64, 64, 64, 64, 96, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 45, 45, 45, 64, 96, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 45, 45, 45, 64, 96, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 64, 64, 64, 64, 96, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 64, 64, 64, 64, 96, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 128, 128, 128, 128, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, ++ }, ++ }, ++ }, ++ ++ /* forcelong_coarse_low_threshold */ ++ 3520, ++ ++ /* forcelong_coarse_high_threshold */ ++ 4160, ++ }, ++ ++ /* ot_isp_fusion_attr */ ++ { ++ { 15420, 12000, 12000, 12000 }, ++ }, ++ ++}; ++ ++static const ot_isp_dehaze_attr g_cmos_dehaze = { ++ /* enable */ ++ 0, ++ /* user_lut_enable */ ++ 0, ++ /* dehaze_lut */ ++ { ++ 0, 9, 13, 17, 21, 25, 29, 33, 37, 42, 46, 50, 54, 58, 62, 67, 71, 75, 79, 83, 87, 91, ++ 95, 99, 102, 106, 110, 114, 117, 121, 124, 128, 131, 134, 137, 141, 144, 147, 150, ++ 153, 156, 159, 162, 165, 168, 170, 173, 176, 178, 181, 184, 186, 189, 191, 193, 196, ++ 198, 200, 203, 205, 207, 209, 211, 213, 215, 217, 219, 221, 222, 224, 226, 228, 229, ++ 231, 232, 234, 235, 237, 238, 240, 241, 242, 243, 244, 246, 247, 248, 249, 249, 250, ++ 251, 252, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, ++ 255, 255, 255, 255, 255, 255, 255, 255, 254, 254, 253, 253, 252, 251, 251, 250, 249, ++ 249, 248, 247, 247, 246, 245, 244, 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, ++ 233, 232, 231, 230, 229, 227, 226, 225, 223, 222, 221, 219, 218, 216, 215, 213, 212, ++ 210, 209, 208, 206, 205, 203, 201, 200, 198, 197, 195, 193, 192, 190, 188, 187, 185, ++ 183, 181, 180, 178, 176, 174, 172, 170, 169, 167, 165, 163, 161, 159, 157, 155, 153, ++ 151, 149, 147, 145, 143, 140, 138, 136, 134, 132, 130, 128, 125, 123, 121, 119, 116, ++ 114, 112, 110, 107, 105, 103, 100, 98, 96, 93, 91, 89, 86, 84, 81, 79, 77, 74, 72, 69, ++ 67, 64, 62, 59, 57, 54, 52, 49, 47, 44, 42, 39, 37, 34, 31, 29, 26, 24, 21, 18, 16, 13, 11, ++ 8, 5, 3, 0 ++ }, ++ /* op_type */ ++ 0, ++ /* auto_strength */ ++ { ++ 128 ++ }, ++ /* manual_strength */ ++ { ++ 128 ++ }, ++ /* tmprflt_incr_coef */ ++ 8, ++ /* tmprflt_decr_coef */ ++ 64, ++}; ++ ++static const ot_isp_drc_attr g_cmos_drc = { ++ /* enable */ ++ 0, ++ /* curve_select */ ++ OT_ISP_DRC_CURVE_ASYMMETRY, ++ /* purple_reduction_strength */ ++ 35, ++ /* bright_gain_limit */ ++ 10, ++ /* bright_gain_limit_step */ ++ 8, ++ /* dark_gain_limit_luma */ ++ 0, ++ /* dark_gain_limit_chroma */ ++ 0, ++ /* contrast_ctrl */ ++ 8, ++ /* rim_reduction_strength */ ++ 32, ++ /* rim_reduction_threshold */ ++ 30, ++ /* color_correction_lut[OT_ISP_DRC_CC_NODE_NUM] */ ++ {1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024}, ++ /* tone_mapping_value[OT_ISP_DRC_TM_NODE_NUM] */ ++ {8, 8, 16, 24, 31, 39, 48, 56, 65, 75, 85, 95, 106, 118, 130, 143, ++ 156, 170, 185, 201, 218, 235, 254, 274, 294, 316, 339, 364, 390, 417, 446, 477, ++ 509, 543, 579, 617, 658, 701, 746, 794, 844, 898, 955, 1015, 1078, 1145, 1216, 1291, ++ 1370, 1454, 1543, 1637, 1736, 1841, 1952, 2069, 2194, 2325, 2465, 2612, 2767, 2932, 3106, 3290, ++ 3485, 3691, 3909, 4140, 4384, 4641, 4914, 5202, 5507, 5830, 6171, 6531, 6913, 7316, 7742, 8193, ++ 8669, 9173, 9705, 10268, 10863, 11492, 12145, 12808, 13483, 14171, 14872, 15587, 16319, 17069, 17840, 18635, ++ 19458, 19881, 20313, 20754, 21204, 21661, 22122, 22586, 23053, 23525, 24000, 24480, 24965, 25455, 25950, 26451, ++ 26959, 27473, 27995, 28524, 29062, 29609, 30165, 30732, 31309, 31899, 32501, 33116, 33746, 34391, 35043, 35706, ++ 36381, 37066, 37763, 38472, 39192, 39925, 40671, 41429, 42201, 42591, 42986, 43383, 43784, 44189, 44597, 45008, ++ 45424, 45842, 46265, 46691, 47121, 47555, 47993, 48434, 48880, 49329, 49783, 50241, 50703, 51169, 51639, 52113, ++ 52592, 53075, 53564, 54056, 54552, 55054, 55560, 56071, 56586, 56846, 57107, 57369, 57632, 57896, 58162, 58429, ++ 58697, 58967, 59238, 59510, 59783, 60057, 60333, 60611, 60889, 61169, 61451, 61733, 62017, 62303, 62589, 62877, ++ 63167, 63458, 63750, 64044, 64340, 64636, 64934, 65234}, ++ /* spatial_filter_coef */ ++ 1, ++ /* range_filter_coef */ ++ 2, ++ /* detail_adjust_coef */ ++ 8, ++ /* local_mixing_bright[OT_ISP_DRC_LMIX_NODE_NUM] */ ++ {15, 17, 18, 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 36, 37, 39, 40, 42, ++ 43, 45, 46, 48, 49, 51, 53, 54, 56, 57, 59, 61, 62, 63, 64}, ++ /* local_mixing_dark[OT_ISP_DRC_LMIX_NODE_NUM] */ ++ {15, 17, 18, 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 36, 37, 39, 40, 42, ++ 43, 45, 46, 48, 49, 51, 53, 54, 56, 57, 59, 61, 62, 63, 64}, ++ /* filter_coef_x[OT_ISP_DRC_FLTX_NODE_NUM] */ ++ {3, 3, 3}, ++ /* filter_low_threshold_x[OT_ISP_DRC_FLTX_NODE_NUM] */ ++ {2, 2, 2}, ++ /* filter_high_threshold_x[OT_ISP_DRC_FLTX_NODE_NUM] */ ++ {5, 5, 5}, ++ /* detail_adjust_coef_x */ ++ 0, ++ /* local_mixing_bright_x[OT_ISP_DRC_LMIX_NODE_NUM] */ ++ {0, 4, 8, 12, 16, 20, 25, 29, 33, 41, 49, 56, 64, 72, 80, 88, 96, 93, ++ 90, 87, 84, 80, 77, 74, 71, 68, 65, 62, 60, 57, 54, 51, 48}, ++ /* local_mixing_dark_x[OT_ISP_DRC_LMIX_NODE_NUM] */ ++ {0, 4, 8, 12, 16, 20, 25, 29, 33, 41, 49, 56, 64, 72, 80, 88, 96, 93, ++ 90, 87, 84, 80, 77, 74, 71, 68, 65, 62, 60, 57, 54, 51, 48}, ++ /* blend_luma_max */ ++ 200, ++ /* blend_luma_bright_min */ ++ 0, ++ /* blend_luma_bright_threshold */ ++ 60, ++ /* blend_luma_bright_slope */ ++ 12, ++ /* blend_luma_dark_min */ ++ 0, ++ /* blend_luma_dark_threshold */ ++ 40, ++ /* blend_luma_dark_slope */ ++ 12, ++ /* blend_detail_max */ ++ 255, ++ /* blend_detail_bright_min */ ++ 0, ++ /* blend_detail_bright_threshold */ ++ 20, ++ /* blend_detail_bright_slope */ ++ 12, ++ /* blend_detail_dark_min */ ++ 0, ++ /* blend_detail_dark_threshold */ ++ 20, ++ /* blend_detail_dark_slope */ ++ 12, ++ /* detail_adjust_coef_blend */ ++ 0, ++ /* low_saturation_color_ctrl */ ++ 0, ++ /* high_saturation_color_ctrl */ ++ 15, ++ /* color_correction_ctrl */ ++ 1, ++ /* op_type */ ++ OT_OP_MODE_AUTO, ++ /* manual_attr */ ++ { ++ /* manual_strength */ ++ 1023, ++ }, ++ /* auto_attr */ ++ { ++ /* auto_strength */ ++ 512, ++ /* auto_strength_max */ ++ 1023, ++ /* auto_strength_min */ ++ 512, ++ }, ++ /* asymmetry_curve */ ++ { ++ /* asymmetry */ ++ 6, ++ /* second_pole */ ++ 200, ++ /* stretch */ ++ 40, ++ /* compress */ ++ 170 ++ } ++}; ++ ++static const ot_isp_crb_attr g_cmos_crb = { ++ /* CRB */ ++ 0, ++ /* Y */ ++ 0, ++ /* auto para */ ++ { ++ { 900, 890, 880, 870, 860, 850, 845, 840, 835, 830 }, ++ { 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024 }, ++ }, ++ /* manual para */ ++ { ++ 1024, 1024, ++ }, ++}; ++ ++#ifdef CONFIG_OT_ISP_CA_SUPPORT ++static const ot_isp_ca_attr g_cmos_ca = { ++ /* CA */ ++ 1, ++ 0, ++ { ++ { ++ 36, 58, 81, 96, 111, 123, 136, 147, 158, 170, 182, 194, 207, 217, 228, 243, 259, 274, ++ 290, 303, 317, 331, 345, 357, 369, 382, 396, 408, 420, 432, 444, 456, 468, 480, 492, 503, ++ 515, 524, 534, 545, 556, 565, 574, 585, 597, 605, 614, 623, 632, 640, 648, 657, 666, 673, ++ 681, 689, 697, 703, 709, 716, 723, 728, 734, 741, 748, 753, 758, 764, 771, 775, 780, 784, ++ 788, 794, 800, 804, 808, 811, 815, 818, 822, 825, 829, 833, 837, 839, 841, 844, 848, 851, ++ 854, 856, 858, 861, 864, 866, 868, 869, 871, 874, 878, 879, 881, 883, 885, 887, 890, 891, ++ 893, 895, 897, 898, 900, 901, 903, 904, 906, 907, 909, 910, 912, 913, 915, 916, 918, 919, ++ 921, 922, 924, 925, 926, 927, 929, 930, 931, 932, 934, 935, 936, 937, 938, 939, 941, 942, ++ 943, 944, 945, 946, 947, 948, 949, 950, 951, 951, 952, 953, 954, 955, 956, 957, 958, 959, ++ 961, 961, 962, 963, 964, 965, 966, 967, 968, 968, 969, 969, 970, 970, 971, 972, 973, 973, ++ 974, 975, 976, 976, 977, 978, 979, 979, 980, 980, 981, 982, 983, 983, 984, 984, 985, 985, ++ 986, 987, 988, 988, 989, 989, 990, 990, 991, 991, 992, 992, 993, 994, 995, 995, 996, 996, ++ 997, 997, 998, 998, 999, 999, 1000, 1000, 1001, 1002, 1004, 1004, 1005, 1005, 1006, 1006, 1007, 1008, ++ 1009, 1009, 1010, 1010, 1011, 1011, 1012, 1013, 1014, 1015, 1016, 1016, 1017, 1018, 1019, 1019, 1020, 1021, ++ 1022, 1023, 1024, 1024 ++ }, ++ /* ISO */ ++ { 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1000, 950, 900, 900, 800, 800, 800, 800, 800 }, ++ }, ++ { ++ { ++ 56, 58, 60, 62, 64, 66, 68, 69, 71, 72, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, ++ 88, 89, 91, 93, 94, 96, 98, 99, 101, 102, 104, 105, 106, 108, 109, 110, 111, 112, 113, 115, 116, ++ 117, 118, 119, 119, 120, 121, 122, 123, 124, 125, 125, 126, 127, 128, 128, 129, 130, 131, 131, 132, 133, ++ 134, 135, 136, 136, 137, 138, 139, 141, 142, 143, 144, 145, 146, 147, 149, 150, 151, 152, 153, 155, 156, ++ 157, 158, 159, 161, 162, 163, 164, 165, 166, 167, 168, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, ++ 180, 181, 182, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 193, 194, 195, 196, 197, 197, 198, 198, ++ 198, 199, 199, 198, 198, 198, 198, 197, 196, 196, 195, 194, 193, 192, 191, 190, 189, 187, 186, 185, 184, ++ 183, 181, 180, 179, 178, 177, 175, 174, 173, 172, 170, 169, 168, 167, 165, 164, 163, 161, 160, 159, 157, ++ 156, 155, 153, 152, 151, 149, 148, 146, 145, 144, 142, 141, 139, 138, 136, 135, 133, 132, 130, 129, 127, ++ 126, 124, 123, 121, 119, 118, 116, 115, 114, 113, 111, 110, 110, 109, 108, 108, 108, 108, 108, 109, 110, ++ 111, 112, 113, 114, 115, 116, 118, 119, 121, 122, 124, 125, 127, 128, 130, 131, 133, 134, 136, 137, 139, ++ 140, 142, 143, 145, 146, 148, 149, 151, 152, 154, 155, 157, 158, 160, 161, 163, 164, 166, 167, 169, 170, ++ 172, 173, 175, 176 ++ }, ++ { ++ 232, 228, 225, 222, 219, 216, 214, 211, 208, 205, 202, 200, 197, 194, 192, 189, 186, 184, 181, 179, 176, ++ 174, 171, 169, 166, 163, 161, 158, 156, 153, 151, 148, 146, 143, 141, 139, 136, 134, 132, 130, 128, 125, ++ 123, 121, 119, 117, 115, 112, 110, 108, 106, 104, 101, 99, 97, 95, 92, 90, 88, 86, 83, 81, 79, ++ 77, 75, 73, 71, 69, 67, 65, 64, 62, 61, 60, 59, 58, 57, 56, 55, 55, 54, 54, 54, 53, ++ 53, 52, 52, 52, 51, 51, 50, 50, 50, 49, 49, 49, 48, 48, 48, 47, 47, 47, 46, 46, 46, ++ 45, 45, 45, 44, 44, 44, 43, 43, 43, 42, 42, 42, 42, 41, 41, 41, 41, 40, 40, 40, 40, ++ 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, 41, 42, 42, 42, 43, 43, 44, 44, 44, 45, ++ 45, 46, 46, 46, 47, 47, 48, 48, 49, 49, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54, ++ 55, 55, 56, 56, 57, 57, 58, 58, 59, 60, 60, 61, 61, 62, 62, 63, 64, 64, 65, 66, 67, ++ 67, 68, 69, 70, 71, 72, 73, 75, 76, 78, 79, 81, 82, 84, 86, 87, 89, 91, 92, 94, 96, ++ 97, 99, 100, 102, 103, 105, 106, 108, 109, 111, 112, 114, 115, 117, 118, 119, 121, 122, 124, 125, 127, ++ 129, 130, 132, 133, 135, 136, 138, 139, 141, 143, 144, 146, 147, 149, 151, 152, 154, 155, 157, 159, 160, ++ 162, 164, 166, 167 ++ }, ++ { ++ 92, 91, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 75, 74, 73, 72, ++ 72, 72, 72, 73, 74, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 85, 86, 87, 87, 88, 88, ++ 88, 88, 89, 89, 89, 89, 89, 89, 88, 88, 88, 88, 87, 87, 87, 87, 87, 86, 86, 86, 87, ++ 87, 87, 88, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 99, 100, 101, 102, 103, 105, 106, 107, ++ 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 125, 126, 127, 128, 129, 130, ++ 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 147, 148, 149, 150, 151, 152, ++ 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 166, 167, 168, 169, 170, 171, 172, ++ 172, 173, 174, 175, 176, 176, 177, 178, 179, 180, 181, 181, 182, 183, 184, 185, 185, 186, 187, 188, 189, ++ 190, 190, 191, 192, 193, 194, 194, 195, 196, 197, 198, 199, 200, 200, 201, 202, 203, 204, 205, 206, 207, ++ 208, 208, 209, 210, 211, 212, 213, 214, 215, 215, 216, 217, 217, 218, 218, 219, 219, 219, 219, 219, 219, ++ 219, 218, 218, 217, 216, 215, 215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, ++ 200, 199, 198, 197, 196, 195, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, ++ 180, 179, 178, 176 ++ }, ++ }, ++}; ++#endif ++ ++static const ot_isp_cmos_lsc g_cmos_lsc = { ++ /* cmos_lsc_attr */ ++ { ++ /* en */ ++ 1, ++ /* mesh_strength */ ++ 4096, ++ /* blend_ratio */ ++ 256, ++ /* bnr_lsc_auto_en */ ++ 0 ++ }, ++ /* cmos_lsc_lut */ ++ { ++ /* mesh_scale */ ++ 1, ++ /* x_grid_width */ ++ {60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60}, ++ /* y_grid_width */ ++ {33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34}, ++ /* lsc_gain_lut */ ++ { ++ { ++ /* r_gain: */ ++ { ++ 745, 673, 608, 561, 519, 484, 452, 428, 408, 387, 371, 357, 347, 338, 334, 328, 328, ++ 328, 332, 337, 348, 356, 367, 382, 399, 425, 449, 479, 515, 557, 605, 665, 719, 716, ++ 660, 599, 550, 508, 474, 446, 420, 399, 380, 363, 350, 342, 333, 326, 323, 322, 322, ++ 325, 332, 338, 349, 360, 374, 392, 414, 439, 470, 505, 545, 595, 650, 704, 701, 640, ++ 580, 536, 495, 464, 433, 409, 388, 370, 355, 343, 333, 324, 317, 313, 312, 312, 317, ++ 322, 329, 340, 350, 366, 382, 403, 429, 458, 491, 533, 578, 630, 684, 676, 626, 569, ++ 521, 485, 451, 424, 400, 380, 361, 345, 334, 324, 316, 309, 306, 304, 305, 307, 313, ++ 320, 332, 340, 356, 373, 395, 417, 448, 478, 518, 563, 614, 668, 663, 608, 557, 510, ++ 473, 440, 412, 389, 371, 352, 338, 326, 316, 307, 301, 298, 296, 296, 298, 305, 311, ++ 322, 332, 347, 363, 384, 410, 436, 467, 508, 546, 599, 647, 647, 595, 541, 498, 465, ++ 430, 403, 381, 362, 346, 332, 319, 308, 300, 294, 290, 288, 289, 290, 296, 302, 313, ++ 325, 339, 356, 375, 398, 427, 456, 493, 536, 588, 640, 633, 580, 533, 488, 452, 424, ++ 397, 374, 355, 338, 324, 313, 301, 295, 288, 283, 281, 281, 283, 288, 296, 305, 317, ++ 332, 348, 368, 392, 417, 449, 485, 524, 574, 630, 619, 567, 519, 482, 446, 415, 389, ++ 368, 348, 333, 317, 307, 297, 288, 281, 276, 275, 274, 277, 282, 289, 299, 310, 325, ++ 342, 361, 383, 410, 439, 474, 515, 565, 621, 608, 561, 513, 471, 438, 409, 384, 362, ++ 345, 327, 313, 301, 291, 283, 276, 271, 269, 268, 270, 276, 284, 293, 305, 320, 336, ++ 356, 377, 402, 431, 467, 507, 552, 605, 597, 552, 507, 466, 433, 403, 379, 357, 339, ++ 323, 308, 297, 287, 279, 272, 267, 264, 264, 266, 271, 281, 288, 300, 315, 331, 349, ++ 371, 397, 426, 462, 499, 545, 597, 591, 543, 498, 461, 428, 400, 373, 352, 336, 318, ++ 305, 293, 283, 275, 268, 263, 261, 261, 262, 268, 275, 285, 296, 310, 327, 345, 368, ++ 393, 420, 455, 492, 539, 591, 584, 539, 493, 456, 425, 396, 371, 350, 330, 315, 302, ++ 290, 280, 272, 264, 261, 259, 260, 261, 265, 273, 283, 295, 308, 323, 343, 363, 389, ++ 416, 450, 488, 533, 578, 582, 536, 489, 452, 422, 394, 368, 348, 328, 313, 299, 287, ++ 277, 268, 262, 259, 259, 259, 260, 263, 269, 281, 291, 305, 320, 338, 359, 384, 413, ++ 446, 485, 528, 571, 574, 534, 489, 451, 419, 392, 367, 345, 327, 313, 298, 285, 276, ++ 267, 261, 258, 257, 257, 260, 262, 269, 280, 291, 304, 317, 336, 357, 381, 410, 443, ++ 481, 521, 565, 574, 533, 489, 450, 416, 388, 366, 344, 325, 310, 296, 285, 275, 266, ++ 260, 257, 257, 258, 259, 261, 268, 278, 290, 302, 317, 335, 356, 381, 407, 439, 477, ++ 519, 563, 571, 533, 486, 448, 416, 389, 365, 344, 324, 309, 295, 284, 274, 266, 259, ++ 256, 256, 257, 259, 261, 268, 278, 290, 302, 316, 334, 356, 381, 408, 438, 474, 518, ++ 561, 571, 533, 486, 449, 416, 388, 366, 344, 325, 309, 296, 285, 274, 266, 259, 256, ++ 256, 256, 259, 261, 268, 279, 289, 302, 317, 334, 355, 380, 408, 437, 473, 516, 559, ++ 574, 531, 488, 451, 419, 389, 366, 344, 326, 309, 297, 285, 275, 266, 260, 256, 256, ++ 256, 259, 262, 269, 280, 291, 303, 317, 336, 356, 381, 408, 438, 474, 518, 559, 574, ++ 533, 489, 452, 419, 393, 366, 345, 327, 311, 298, 287, 277, 267, 261, 256, 256, 256, ++ 259, 264, 272, 281, 291, 304, 318, 338, 357, 381, 409, 439, 475, 519, 561, 584, 536, ++ 491, 454, 424, 394, 369, 347, 330, 313, 299, 288, 279, 269, 263, 258, 257, 257, 261, ++ 266, 274, 283, 293, 306, 322, 338, 359, 383, 409, 443, 478, 521, 565, 586, 541, 496, ++ 460, 425, 397, 372, 350, 332, 316, 304, 291, 282, 273, 266, 262, 261, 261, 263, 268, ++ 276, 285, 297, 309, 324, 342, 361, 386, 412, 445, 484, 526, 571, 593, 545, 504, 464, ++ 429, 400, 376, 355, 336, 319, 306, 295, 284, 275, 271, 266, 263, 266, 267, 273, 280, ++ 289, 300, 314, 329, 345, 366, 389, 417, 450, 489, 533, 574, 597, 557, 507, 467, 434, ++ 404, 381, 359, 338, 325, 310, 298, 289, 281, 274, 269, 269, 269, 273, 276, 283, 292, ++ 304, 317, 332, 348, 371, 395, 422, 455, 495, 538, 584, 608, 563, 515, 473, 438, 412, ++ 385, 365, 345, 328, 315, 304, 295, 285, 280, 275, 274, 274, 277, 281, 288, 298, 309, ++ 322, 336, 355, 375, 399, 429, 462, 499, 545, 588, 621, 571, 521, 481, 446, 417, 391, ++ 370, 350, 335, 322, 308, 299, 290, 284, 282, 280, 280, 283, 287, 292, 302, 313, 325, ++ 342, 359, 381, 406, 434, 469, 510, 550, 595, 630, 582, 533, 489, 452, 425, 398, 376, ++ 357, 340, 327, 315, 305, 298, 291, 288, 285, 285, 288, 293, 299, 308, 319, 332, 347, ++ 366, 387, 413, 443, 474, 515, 561, 603, 645, 597, 545, 504, 464, 433, 404, 383, 364, ++ 348, 334, 323, 311, 304, 298, 294, 291, 292, 296, 299, 306, 315, 325, 338, 355, 372, ++ 395, 419, 451, 486, 523, 571, 619, 660, 608, 557, 513, 473, 444, 415, 394, 373, 357, ++ 342, 329, 319, 312, 305, 301, 299, 299, 303, 306, 313, 322, 334, 346, 361, 381, 403, ++ 428, 460, 495, 534, 586, 628, 676, 626, 571, 528, 486, 454, 426, 401, 381, 363, 349, ++ 336, 327, 318, 313, 309, 307, 306, 309, 314, 320, 330, 343, 355, 371, 389, 413, 438, ++ 469, 505, 546, 595, 642, 701, 642, 588, 539, 499, 466, 436, 410, 393, 375, 359, 346, ++ 336, 327, 322, 317, 316, 316, 318, 323, 329, 338, 350, 363, 381, 400, 424, 450, 481, ++ 518, 561, 610, 663, 722, 663, 603, 559, 515, 478, 450, 425, 402, 385, 370, 356, 345, ++ 337, 330, 327, 325, 325, 327, 333, 338, 348, 360, 373, 389, 411, 434, 462, 493, 533, ++ 576, 630, 681, 748, 681, 623, 572, 531, 492, 464, 437, 414, 396, 380, 366, 356, 347, ++ 340, 337, 335, 335, 338, 343, 350, 359, 370, 384, 401, 421, 446, 473, 508, 546, 591, ++ 645, 707, 762, 701, 638, 586, 536, 504, 470, 446, 423, 402, 385, 372, 362, 353, 348, ++ 343, 340, 341, 345, 350, 356, 366, 378, 391, 410, 429, 454, 482, 516, 557, 601, 663, ++ 716, ++ }, ++ ++ /* gr_gain: */ ++ { ++ 702, 643, 590, 540, 499, 468, 437, 414, 394, 376, 361, 348, 339, 331, 324, 321, 320, ++ 321, 326, 329, 337, 348, 357, 371, 389, 411, 434, 463, 496, 537, 582, 637, 695, 684, ++ 633, 576, 529, 491, 459, 430, 407, 388, 370, 355, 342, 333, 324, 318, 316, 313, 315, ++ 318, 323, 330, 341, 349, 363, 381, 403, 426, 454, 486, 526, 572, 623, 676, 668, 615, ++ 560, 515, 479, 448, 418, 397, 378, 361, 346, 334, 324, 317, 311, 307, 306, 306, 309, ++ 316, 322, 331, 342, 355, 372, 393, 415, 443, 474, 511, 557, 607, 660, 652, 599, 546, ++ 502, 468, 436, 410, 388, 370, 352, 337, 327, 317, 308, 303, 300, 297, 298, 301, 306, ++ 313, 323, 333, 347, 363, 382, 405, 432, 461, 498, 542, 593, 642, 635, 583, 536, 493, ++ 457, 426, 401, 379, 362, 344, 331, 319, 310, 302, 295, 292, 290, 290, 292, 298, 306, ++ 313, 324, 337, 354, 373, 396, 422, 451, 487, 530, 578, 629, 620, 572, 523, 483, 448, ++ 418, 394, 371, 354, 337, 324, 313, 303, 296, 290, 285, 283, 283, 286, 291, 297, 306, ++ 317, 331, 347, 365, 387, 414, 443, 478, 518, 565, 616, 608, 560, 512, 474, 441, 411, ++ 386, 364, 348, 331, 318, 307, 297, 290, 284, 280, 276, 277, 279, 283, 291, 300, 312, ++ 324, 341, 358, 381, 405, 434, 468, 509, 556, 608, 595, 552, 506, 467, 434, 405, 380, ++ 359, 342, 327, 313, 302, 292, 285, 278, 273, 270, 270, 273, 278, 285, 295, 306, 318, ++ 334, 353, 373, 398, 427, 460, 499, 544, 599, 588, 542, 497, 459, 426, 398, 375, 355, ++ 337, 322, 309, 297, 288, 280, 273, 269, 266, 265, 268, 273, 280, 289, 300, 313, 329, ++ 348, 369, 393, 419, 454, 493, 537, 590, 577, 536, 492, 454, 422, 394, 371, 350, 333, ++ 317, 305, 294, 284, 276, 269, 265, 261, 261, 264, 268, 276, 285, 296, 310, 324, 343, ++ 364, 387, 414, 447, 485, 529, 583, 572, 527, 485, 448, 417, 389, 365, 347, 329, 313, ++ 301, 290, 281, 272, 266, 261, 259, 258, 260, 265, 272, 282, 292, 306, 321, 339, 359, ++ 382, 411, 441, 479, 523, 571, 567, 524, 482, 446, 415, 386, 363, 343, 326, 311, 298, ++ 287, 277, 269, 262, 259, 257, 257, 258, 262, 269, 279, 291, 302, 318, 335, 356, 379, ++ 406, 436, 474, 517, 556, 563, 521, 479, 443, 412, 385, 362, 342, 323, 308, 295, 285, ++ 276, 267, 261, 257, 257, 256, 259, 260, 268, 277, 289, 301, 316, 333, 352, 377, 404, ++ 433, 470, 511, 552, 560, 517, 478, 443, 409, 384, 361, 340, 321, 307, 295, 283, 273, ++ 265, 260, 256, 256, 256, 257, 260, 267, 276, 287, 299, 315, 330, 350, 374, 402, 431, ++ 467, 508, 549, 557, 516, 475, 441, 408, 383, 359, 339, 321, 306, 292, 282, 273, 265, ++ 259, 256, 256, 256, 257, 260, 266, 276, 287, 299, 312, 329, 350, 372, 398, 428, 465, ++ 505, 544, 557, 516, 474, 439, 408, 382, 359, 339, 321, 305, 292, 282, 272, 264, 258, ++ 256, 256, 256, 258, 260, 267, 276, 286, 298, 312, 329, 349, 372, 398, 428, 463, 505, ++ 542, 558, 515, 477, 439, 408, 381, 360, 338, 321, 306, 293, 282, 272, 264, 258, 256, ++ 256, 256, 257, 260, 267, 276, 287, 298, 312, 329, 348, 371, 398, 426, 462, 502, 541, ++ 558, 516, 478, 442, 411, 382, 359, 339, 323, 307, 294, 283, 273, 265, 258, 256, 256, ++ 256, 257, 261, 268, 277, 288, 300, 313, 330, 349, 371, 397, 427, 462, 505, 542, 559, ++ 520, 479, 443, 412, 384, 361, 340, 323, 308, 295, 285, 275, 267, 260, 256, 256, 256, ++ 258, 262, 269, 279, 289, 301, 315, 333, 351, 373, 398, 428, 466, 505, 543, 566, 521, ++ 480, 445, 414, 387, 363, 342, 325, 311, 296, 286, 276, 269, 262, 257, 257, 257, 260, ++ 264, 272, 281, 291, 304, 317, 334, 353, 376, 402, 431, 467, 508, 549, 571, 525, 484, ++ 448, 416, 389, 366, 346, 328, 312, 300, 289, 280, 271, 265, 261, 259, 260, 263, 267, ++ 274, 283, 294, 306, 321, 336, 356, 379, 405, 432, 471, 514, 553, 574, 530, 488, 454, ++ 421, 393, 370, 349, 331, 316, 303, 291, 282, 276, 269, 264, 263, 264, 265, 271, 278, ++ 287, 297, 308, 323, 340, 360, 381, 408, 439, 474, 519, 558, 583, 539, 495, 457, 425, ++ 398, 373, 354, 335, 320, 307, 296, 286, 279, 273, 269, 268, 268, 270, 275, 282, 291, ++ 301, 313, 327, 343, 363, 386, 414, 445, 483, 523, 566, 591, 545, 501, 463, 432, 404, ++ 379, 359, 341, 325, 312, 301, 291, 283, 278, 273, 273, 272, 276, 280, 286, 295, 305, ++ 318, 332, 348, 369, 391, 417, 449, 487, 530, 572, 599, 557, 510, 471, 437, 411, 386, ++ 365, 347, 331, 318, 306, 297, 290, 284, 279, 277, 278, 281, 285, 291, 300, 311, 323, ++ 337, 355, 373, 398, 425, 458, 494, 538, 577, 615, 567, 521, 480, 445, 417, 393, 371, ++ 353, 337, 324, 312, 302, 295, 290, 286, 284, 285, 287, 291, 297, 306, 316, 328, 343, ++ 361, 380, 405, 433, 466, 501, 544, 589, 627, 579, 532, 490, 455, 424, 399, 378, 361, ++ 345, 330, 318, 310, 302, 297, 292, 291, 291, 293, 297, 304, 312, 323, 336, 350, 368, ++ 388, 413, 439, 474, 511, 555, 598, 643, 594, 544, 500, 466, 434, 409, 386, 368, 352, ++ 339, 327, 317, 310, 304, 300, 298, 299, 300, 305, 311, 319, 330, 342, 357, 375, 396, ++ 421, 448, 482, 523, 566, 611, 657, 611, 557, 513, 476, 446, 420, 396, 377, 361, 347, ++ 335, 324, 317, 312, 307, 306, 306, 308, 312, 318, 327, 337, 351, 365, 384, 405, 429, ++ 459, 493, 532, 579, 623, 681, 625, 573, 529, 489, 457, 431, 407, 387, 370, 356, 343, ++ 334, 327, 319, 316, 313, 315, 317, 321, 327, 335, 347, 359, 373, 394, 414, 439, 469, ++ 506, 546, 593, 643, 696, 643, 588, 542, 505, 469, 443, 417, 397, 379, 365, 353, 342, ++ 335, 329, 324, 323, 323, 325, 329, 335, 345, 356, 369, 386, 404, 425, 450, 483, 517, ++ 558, 611, 663, 720, 660, 607, 558, 516, 484, 455, 432, 407, 390, 374, 363, 352, 343, ++ 339, 335, 333, 331, 335, 339, 345, 354, 365, 378, 396, 414, 436, 463, 496, 531, 574, ++ 626, 681, 737, 673, 619, 571, 527, 492, 462, 437, 416, 397, 382, 369, 360, 350, 344, ++ 341, 338, 337, 340, 345, 351, 361, 371, 386, 402, 420, 443, 471, 505, 541, 582, 637, ++ 690, ++ }, ++ ++ /* gb_gain: */ ++ { ++ 705, 645, 587, 539, 500, 468, 438, 413, 394, 377, 360, 348, 338, 331, 325, 321, 320, ++ 322, 326, 330, 336, 347, 356, 371, 389, 409, 433, 462, 496, 533, 581, 638, 691, 688, ++ 633, 575, 529, 489, 459, 429, 406, 387, 370, 354, 342, 332, 324, 318, 314, 314, 314, ++ 318, 323, 330, 340, 349, 364, 381, 400, 426, 455, 485, 523, 569, 624, 680, 668, 614, ++ 562, 516, 480, 448, 419, 397, 378, 360, 347, 334, 324, 317, 311, 307, 306, 306, 309, ++ 315, 322, 331, 341, 353, 372, 392, 415, 443, 473, 512, 556, 609, 659, 648, 599, 547, ++ 504, 468, 438, 409, 388, 370, 352, 337, 327, 317, 308, 302, 299, 297, 297, 301, 306, ++ 314, 323, 332, 345, 363, 381, 405, 430, 462, 498, 541, 592, 638, 635, 583, 536, 493, ++ 458, 427, 401, 380, 361, 343, 330, 319, 309, 301, 296, 292, 290, 291, 292, 298, 305, ++ 313, 324, 338, 355, 373, 395, 422, 453, 487, 529, 578, 622, 618, 570, 524, 484, 448, ++ 419, 394, 372, 353, 337, 323, 313, 303, 295, 290, 286, 283, 283, 286, 290, 297, 306, ++ 318, 330, 348, 365, 388, 412, 443, 477, 517, 564, 617, 610, 563, 512, 474, 440, 411, ++ 387, 365, 348, 331, 318, 307, 297, 290, 283, 278, 277, 277, 278, 283, 291, 299, 312, ++ 324, 340, 358, 380, 405, 434, 469, 507, 555, 607, 598, 551, 506, 468, 432, 405, 380, ++ 359, 343, 326, 313, 302, 293, 285, 278, 274, 271, 270, 273, 278, 285, 293, 304, 318, ++ 334, 351, 373, 398, 427, 461, 499, 543, 597, 588, 543, 497, 460, 428, 399, 374, 355, ++ 337, 322, 309, 298, 288, 279, 273, 269, 265, 265, 268, 273, 280, 288, 300, 313, 329, ++ 347, 367, 390, 419, 455, 493, 537, 591, 578, 537, 492, 453, 423, 394, 371, 350, 333, ++ 317, 305, 293, 284, 276, 269, 264, 261, 261, 264, 268, 275, 284, 296, 308, 325, 343, ++ 364, 386, 414, 447, 485, 528, 579, 572, 529, 487, 449, 418, 390, 366, 348, 330, 314, ++ 301, 290, 279, 273, 265, 261, 258, 259, 260, 264, 272, 281, 292, 305, 320, 338, 358, ++ 382, 409, 440, 477, 522, 567, 568, 525, 483, 447, 415, 388, 364, 344, 326, 312, 298, ++ 287, 277, 269, 262, 258, 257, 257, 259, 261, 269, 278, 290, 302, 318, 336, 355, 379, ++ 407, 437, 473, 516, 555, 562, 519, 479, 444, 412, 385, 363, 343, 324, 308, 296, 284, ++ 276, 267, 261, 257, 257, 257, 258, 261, 268, 277, 289, 301, 316, 332, 352, 375, 404, ++ 434, 469, 511, 552, 562, 518, 477, 440, 411, 384, 361, 340, 322, 307, 294, 283, 274, ++ 265, 260, 256, 256, 257, 258, 260, 266, 275, 287, 300, 314, 330, 351, 374, 402, 430, ++ 467, 508, 548, 561, 517, 475, 440, 410, 382, 359, 338, 322, 306, 293, 282, 273, 265, ++ 258, 256, 256, 257, 257, 260, 265, 275, 287, 299, 313, 330, 350, 373, 398, 428, 464, ++ 505, 544, 559, 516, 475, 440, 408, 382, 358, 339, 321, 305, 293, 282, 272, 264, 258, ++ 256, 256, 256, 257, 260, 266, 275, 287, 298, 312, 329, 349, 372, 398, 428, 462, 503, ++ 542, 559, 516, 475, 440, 408, 382, 358, 340, 322, 306, 293, 282, 273, 264, 258, 256, ++ 256, 256, 257, 261, 267, 277, 287, 298, 313, 329, 349, 371, 398, 427, 462, 502, 542, ++ 559, 517, 476, 440, 409, 383, 359, 338, 322, 307, 293, 283, 273, 265, 258, 256, 256, ++ 256, 257, 261, 268, 277, 287, 299, 314, 330, 349, 372, 398, 428, 462, 503, 543, 562, ++ 521, 480, 443, 412, 385, 362, 341, 323, 308, 296, 285, 274, 267, 260, 256, 256, 256, ++ 257, 262, 269, 279, 289, 301, 315, 332, 351, 373, 399, 428, 465, 507, 544, 564, 522, ++ 481, 445, 414, 387, 364, 343, 325, 311, 297, 287, 277, 269, 262, 257, 257, 257, 260, ++ 265, 272, 281, 291, 303, 318, 335, 353, 375, 401, 432, 468, 509, 551, 571, 525, 485, ++ 448, 417, 390, 367, 346, 329, 313, 300, 290, 280, 272, 265, 261, 260, 260, 262, 267, ++ 274, 283, 294, 306, 320, 337, 356, 379, 405, 434, 470, 513, 553, 576, 531, 489, 454, ++ 421, 394, 370, 350, 332, 317, 303, 293, 283, 274, 269, 265, 263, 264, 266, 272, 278, ++ 287, 297, 309, 323, 340, 359, 382, 408, 438, 476, 517, 559, 583, 540, 496, 458, 426, ++ 397, 374, 355, 336, 320, 307, 296, 287, 279, 274, 269, 268, 269, 271, 276, 282, 291, ++ 301, 313, 328, 344, 364, 387, 414, 445, 482, 523, 562, 593, 548, 504, 465, 432, 405, ++ 380, 358, 341, 325, 312, 301, 292, 283, 278, 274, 273, 273, 276, 280, 286, 295, 306, ++ 318, 332, 349, 368, 390, 418, 450, 487, 530, 570, 603, 559, 513, 473, 438, 409, 387, ++ 365, 348, 331, 318, 307, 297, 290, 284, 280, 278, 278, 282, 286, 292, 300, 311, 323, ++ 338, 355, 374, 398, 426, 458, 495, 535, 575, 615, 569, 524, 481, 447, 417, 394, 372, ++ 354, 338, 324, 313, 305, 296, 290, 286, 284, 284, 287, 291, 297, 306, 316, 329, 343, ++ 362, 380, 405, 432, 464, 501, 544, 586, 631, 582, 532, 492, 456, 426, 400, 380, 362, ++ 345, 331, 319, 311, 302, 297, 293, 291, 291, 293, 298, 303, 313, 323, 336, 349, 369, ++ 388, 413, 439, 473, 511, 555, 597, 645, 596, 543, 502, 466, 435, 409, 387, 369, 352, ++ 340, 328, 318, 310, 304, 301, 298, 299, 301, 305, 311, 320, 330, 343, 357, 376, 397, ++ 421, 449, 484, 522, 565, 613, 660, 607, 560, 515, 479, 447, 419, 397, 378, 363, 348, ++ 336, 325, 318, 312, 308, 306, 307, 308, 313, 319, 327, 338, 350, 365, 384, 405, 430, ++ 460, 493, 535, 579, 626, 681, 625, 575, 530, 488, 459, 432, 406, 387, 371, 357, 344, ++ 335, 326, 319, 316, 314, 314, 317, 322, 328, 336, 347, 359, 376, 394, 416, 440, 470, ++ 507, 544, 594, 642, 697, 645, 592, 543, 506, 473, 444, 418, 398, 380, 366, 354, 344, ++ 335, 330, 325, 324, 324, 325, 330, 336, 346, 357, 369, 386, 403, 425, 453, 482, 517, ++ 560, 609, 659, 722, 665, 607, 560, 519, 484, 455, 430, 408, 390, 374, 364, 352, 344, ++ 339, 336, 334, 332, 336, 338, 345, 355, 365, 379, 395, 414, 436, 463, 495, 532, 575, ++ 626, 681, 739, 678, 621, 574, 531, 493, 463, 438, 417, 398, 382, 369, 359, 351, 346, ++ 341, 340, 338, 341, 345, 352, 362, 372, 385, 401, 422, 444, 469, 504, 542, 588, 639, ++ 693, ++ }, ++ ++ /* b_gain: */ ++ { ++ 669, 620, 567, 522, 485, 456, 427, 402, 385, 368, 353, 341, 334, 327, 321, 317, 316, ++ 317, 320, 326, 334, 341, 353, 367, 382, 404, 426, 456, 483, 524, 569, 620, 682, 657, ++ 610, 554, 512, 477, 445, 419, 397, 380, 361, 346, 337, 327, 320, 315, 311, 310, 310, ++ 315, 320, 328, 337, 346, 358, 374, 396, 419, 445, 477, 514, 558, 610, 660, 645, 590, ++ 541, 503, 463, 435, 408, 388, 370, 354, 340, 329, 320, 313, 307, 304, 301, 303, 307, ++ 311, 318, 328, 338, 351, 367, 385, 408, 435, 465, 503, 543, 595, 642, 623, 576, 527, ++ 488, 454, 425, 400, 381, 361, 345, 332, 320, 312, 305, 299, 296, 295, 295, 298, 305, ++ 309, 320, 329, 342, 358, 378, 398, 424, 456, 488, 527, 578, 620, 610, 567, 518, 478, ++ 445, 416, 391, 371, 354, 337, 326, 315, 306, 298, 292, 289, 287, 288, 290, 296, 303, ++ 310, 320, 334, 351, 368, 388, 415, 445, 478, 516, 567, 612, 600, 552, 505, 468, 436, ++ 408, 384, 365, 346, 331, 319, 309, 300, 292, 286, 284, 281, 280, 285, 288, 294, 304, ++ 314, 327, 342, 360, 382, 406, 436, 468, 507, 549, 605, 587, 541, 495, 460, 429, 401, ++ 380, 358, 341, 327, 315, 305, 295, 287, 280, 277, 274, 275, 278, 281, 288, 297, 309, ++ 320, 337, 354, 375, 398, 426, 460, 497, 539, 592, 578, 531, 490, 456, 422, 396, 371, ++ 353, 337, 322, 309, 300, 290, 281, 277, 271, 270, 269, 271, 276, 283, 293, 303, 316, ++ 330, 349, 368, 393, 419, 454, 488, 535, 585, 567, 524, 483, 447, 418, 389, 367, 349, ++ 332, 317, 305, 295, 286, 278, 271, 268, 264, 263, 266, 271, 278, 287, 297, 311, 326, ++ 343, 365, 387, 414, 446, 483, 522, 578, 560, 516, 477, 440, 413, 385, 364, 344, 328, ++ 315, 300, 291, 281, 273, 268, 262, 261, 261, 262, 268, 275, 283, 294, 307, 322, 340, ++ 358, 383, 408, 440, 477, 516, 569, 549, 512, 472, 438, 406, 382, 358, 341, 326, 310, ++ 298, 288, 278, 270, 263, 260, 257, 258, 261, 263, 271, 279, 291, 305, 318, 335, 354, ++ 379, 405, 434, 471, 512, 556, 547, 509, 468, 435, 405, 380, 357, 339, 320, 307, 296, ++ 285, 276, 269, 262, 258, 257, 258, 260, 262, 269, 278, 289, 301, 317, 332, 352, 375, ++ 401, 431, 466, 507, 547, 545, 505, 466, 434, 402, 378, 355, 337, 320, 305, 294, 283, ++ 272, 265, 260, 256, 256, 257, 258, 261, 267, 276, 288, 299, 314, 330, 351, 371, 398, ++ 426, 462, 503, 541, 541, 505, 465, 430, 401, 377, 354, 334, 317, 303, 292, 281, 272, ++ 264, 259, 256, 257, 257, 259, 261, 266, 274, 286, 298, 310, 329, 349, 369, 396, 425, ++ 460, 500, 537, 539, 503, 463, 431, 400, 374, 353, 334, 317, 303, 290, 280, 270, 263, ++ 258, 256, 256, 257, 259, 261, 265, 276, 285, 297, 310, 327, 347, 368, 395, 424, 459, ++ 495, 533, 537, 503, 465, 431, 399, 373, 352, 333, 317, 302, 289, 280, 271, 263, 257, ++ 256, 256, 256, 258, 260, 265, 274, 286, 297, 311, 327, 346, 368, 391, 422, 456, 495, ++ 533, 539, 503, 465, 431, 400, 374, 353, 333, 317, 303, 290, 279, 270, 263, 257, 256, ++ 256, 256, 257, 261, 267, 276, 286, 297, 310, 327, 345, 368, 394, 421, 456, 493, 531, ++ 539, 503, 462, 430, 401, 376, 353, 334, 318, 303, 291, 280, 271, 264, 257, 256, 256, ++ 256, 257, 261, 267, 277, 287, 298, 311, 327, 346, 368, 395, 421, 456, 495, 531, 541, ++ 505, 465, 434, 402, 377, 355, 337, 319, 304, 292, 283, 273, 265, 260, 256, 256, 256, ++ 259, 262, 269, 278, 288, 300, 314, 329, 348, 369, 396, 422, 457, 498, 535, 547, 509, ++ 466, 434, 407, 381, 358, 338, 320, 307, 296, 285, 277, 268, 262, 257, 256, 257, 261, ++ 263, 271, 280, 289, 301, 316, 330, 351, 373, 397, 425, 460, 502, 537, 549, 512, 471, ++ 438, 408, 383, 360, 341, 325, 309, 297, 288, 278, 271, 264, 261, 259, 261, 262, 268, ++ 273, 284, 293, 305, 318, 334, 353, 375, 400, 429, 466, 505, 539, 556, 516, 477, 440, ++ 413, 386, 366, 343, 328, 314, 300, 290, 280, 273, 268, 264, 262, 263, 265, 271, 277, ++ 286, 296, 307, 322, 338, 356, 380, 404, 435, 469, 509, 545, 565, 522, 482, 446, 416, ++ 390, 369, 350, 331, 317, 305, 295, 285, 278, 272, 268, 267, 268, 270, 275, 281, 289, ++ 299, 312, 326, 341, 360, 383, 408, 438, 474, 514, 552, 571, 535, 490, 453, 422, 396, ++ 372, 354, 336, 322, 309, 299, 289, 281, 276, 272, 271, 272, 274, 280, 286, 293, 305, ++ 317, 330, 345, 366, 387, 415, 442, 480, 518, 560, 580, 541, 497, 460, 427, 401, 379, ++ 358, 341, 328, 315, 305, 295, 288, 282, 278, 278, 277, 280, 285, 291, 298, 308, 320, ++ 334, 351, 371, 393, 420, 450, 485, 525, 565, 597, 549, 507, 466, 436, 408, 384, 366, ++ 346, 332, 320, 310, 301, 295, 287, 283, 283, 284, 285, 290, 297, 305, 315, 327, 341, ++ 357, 375, 400, 425, 456, 491, 535, 573, 607, 565, 516, 478, 445, 418, 391, 373, 356, ++ 341, 328, 317, 307, 300, 295, 290, 289, 291, 292, 296, 301, 310, 321, 333, 349, 365, ++ 383, 407, 435, 466, 505, 541, 587, 623, 576, 529, 488, 454, 425, 402, 382, 364, 350, ++ 336, 322, 316, 307, 300, 298, 297, 298, 299, 303, 309, 317, 328, 341, 354, 371, 390, ++ 416, 443, 475, 512, 554, 600, 642, 590, 541, 503, 466, 436, 409, 388, 371, 356, 343, ++ 332, 322, 315, 309, 306, 305, 305, 307, 310, 316, 326, 337, 347, 364, 380, 400, 424, ++ 454, 483, 522, 567, 612, 651, 607, 554, 514, 478, 447, 422, 399, 382, 366, 352, 340, ++ 330, 322, 317, 315, 313, 313, 315, 318, 326, 333, 344, 357, 371, 390, 410, 434, 463, ++ 495, 537, 578, 623, 672, 623, 573, 531, 491, 460, 434, 409, 390, 374, 360, 348, 339, ++ 332, 327, 322, 321, 321, 325, 327, 334, 342, 353, 368, 381, 400, 420, 445, 477, 509, ++ 547, 595, 642, 692, 642, 590, 543, 505, 475, 443, 422, 402, 384, 370, 358, 349, 341, ++ 337, 331, 330, 330, 332, 337, 343, 351, 363, 375, 390, 409, 433, 456, 485, 522, 560, ++ 612, 663, 705, 657, 605, 554, 514, 482, 454, 431, 412, 389, 378, 365, 354, 350, 343, ++ 338, 337, 337, 340, 342, 351, 358, 368, 383, 397, 416, 436, 465, 493, 533, 571, 623, ++ 682, ++ }, ++ }, ++ { ++ /* r_gain: */ ++ { ++ 745, 673, 608, 561, 519, 484, 452, 428, 408, 387, 371, 357, 347, 338, 334, 328, 328, ++ 328, 332, 337, 348, 356, 367, 382, 399, 425, 449, 479, 515, 557, 605, 665, 719, 716, ++ 660, 599, 550, 508, 474, 446, 420, 399, 380, 363, 350, 342, 333, 326, 323, 322, 322, ++ 325, 332, 338, 349, 360, 374, 392, 414, 439, 470, 505, 545, 595, 650, 704, 701, 640, ++ 580, 536, 495, 464, 433, 409, 388, 370, 355, 343, 333, 324, 317, 313, 312, 312, 317, ++ 322, 329, 340, 350, 366, 382, 403, 429, 458, 491, 533, 578, 630, 684, 676, 626, 569, ++ 521, 485, 451, 424, 400, 380, 361, 345, 334, 324, 316, 309, 306, 304, 305, 307, 313, ++ 320, 332, 340, 356, 373, 395, 417, 448, 478, 518, 563, 614, 668, 663, 608, 557, 510, ++ 473, 440, 412, 389, 371, 352, 338, 326, 316, 307, 301, 298, 296, 296, 298, 305, 311, ++ 322, 332, 347, 363, 384, 410, 436, 467, 508, 546, 599, 647, 647, 595, 541, 498, 465, ++ 430, 403, 381, 362, 346, 332, 319, 308, 300, 294, 290, 288, 289, 290, 296, 302, 313, ++ 325, 339, 356, 375, 398, 427, 456, 493, 536, 588, 640, 633, 580, 533, 488, 452, 424, ++ 397, 374, 355, 338, 324, 313, 301, 295, 288, 283, 281, 281, 283, 288, 296, 305, 317, ++ 332, 348, 368, 392, 417, 449, 485, 524, 574, 630, 619, 567, 519, 482, 446, 415, 389, ++ 368, 348, 333, 317, 307, 297, 288, 281, 276, 275, 274, 277, 282, 289, 299, 310, 325, ++ 342, 361, 383, 410, 439, 474, 515, 565, 621, 608, 561, 513, 471, 438, 409, 384, 362, ++ 345, 327, 313, 301, 291, 283, 276, 271, 269, 268, 270, 276, 284, 293, 305, 320, 336, ++ 356, 377, 402, 431, 467, 507, 552, 605, 597, 552, 507, 466, 433, 403, 379, 357, 339, ++ 323, 308, 297, 287, 279, 272, 267, 264, 264, 266, 271, 281, 288, 300, 315, 331, 349, ++ 371, 397, 426, 462, 499, 545, 597, 591, 543, 498, 461, 428, 400, 373, 352, 336, 318, ++ 305, 293, 283, 275, 268, 263, 261, 261, 262, 268, 275, 285, 296, 310, 327, 345, 368, ++ 393, 420, 455, 492, 539, 591, 584, 539, 493, 456, 425, 396, 371, 350, 330, 315, 302, ++ 290, 280, 272, 264, 261, 259, 260, 261, 265, 273, 283, 295, 308, 323, 343, 363, 389, ++ 416, 450, 488, 533, 578, 582, 536, 489, 452, 422, 394, 368, 348, 328, 313, 299, 287, ++ 277, 268, 262, 259, 259, 259, 260, 263, 269, 281, 291, 305, 320, 338, 359, 384, 413, ++ 446, 485, 528, 571, 574, 534, 489, 451, 419, 392, 367, 345, 327, 313, 298, 285, 276, ++ 267, 261, 258, 257, 257, 260, 262, 269, 280, 291, 304, 317, 336, 357, 381, 410, 443, ++ 481, 521, 565, 574, 533, 489, 450, 416, 388, 366, 344, 325, 310, 296, 285, 275, 266, ++ 260, 257, 257, 258, 259, 261, 268, 278, 290, 302, 317, 335, 356, 381, 407, 439, 477, ++ 519, 563, 571, 533, 486, 448, 416, 389, 365, 344, 324, 309, 295, 284, 274, 266, 259, ++ 256, 256, 257, 259, 261, 268, 278, 290, 302, 316, 334, 356, 381, 408, 438, 474, 518, ++ 561, 571, 533, 486, 449, 416, 388, 366, 344, 325, 309, 296, 285, 274, 266, 259, 256, ++ 256, 256, 259, 261, 268, 279, 289, 302, 317, 334, 355, 380, 408, 437, 473, 516, 559, ++ 574, 531, 488, 451, 419, 389, 366, 344, 326, 309, 297, 285, 275, 266, 260, 256, 256, ++ 256, 259, 262, 269, 280, 291, 303, 317, 336, 356, 381, 408, 438, 474, 518, 559, 574, ++ 533, 489, 452, 419, 393, 366, 345, 327, 311, 298, 287, 277, 267, 261, 256, 256, 256, ++ 259, 264, 272, 281, 291, 304, 318, 338, 357, 381, 409, 439, 475, 519, 561, 584, 536, ++ 491, 454, 424, 394, 369, 347, 330, 313, 299, 288, 279, 269, 263, 258, 257, 257, 261, ++ 266, 274, 283, 293, 306, 322, 338, 359, 383, 409, 443, 478, 521, 565, 586, 541, 496, ++ 460, 425, 397, 372, 350, 332, 316, 304, 291, 282, 273, 266, 262, 261, 261, 263, 268, ++ 276, 285, 297, 309, 324, 342, 361, 386, 412, 445, 484, 526, 571, 593, 545, 504, 464, ++ 429, 400, 376, 355, 336, 319, 306, 295, 284, 275, 271, 266, 263, 266, 267, 273, 280, ++ 289, 300, 314, 329, 345, 366, 389, 417, 450, 489, 533, 574, 597, 557, 507, 467, 434, ++ 404, 381, 359, 338, 325, 310, 298, 289, 281, 274, 269, 269, 269, 273, 276, 283, 292, ++ 304, 317, 332, 348, 371, 395, 422, 455, 495, 538, 584, 608, 563, 515, 473, 438, 412, ++ 385, 365, 345, 328, 315, 304, 295, 285, 280, 275, 274, 274, 277, 281, 288, 298, 309, ++ 322, 336, 355, 375, 399, 429, 462, 499, 545, 588, 621, 571, 521, 481, 446, 417, 391, ++ 370, 350, 335, 322, 308, 299, 290, 284, 282, 280, 280, 283, 287, 292, 302, 313, 325, ++ 342, 359, 381, 406, 434, 469, 510, 550, 595, 630, 582, 533, 489, 452, 425, 398, 376, ++ 357, 340, 327, 315, 305, 298, 291, 288, 285, 285, 288, 293, 299, 308, 319, 332, 347, ++ 366, 387, 413, 443, 474, 515, 561, 603, 645, 597, 545, 504, 464, 433, 404, 383, 364, ++ 348, 334, 323, 311, 304, 298, 294, 291, 292, 296, 299, 306, 315, 325, 338, 355, 372, ++ 395, 419, 451, 486, 523, 571, 619, 660, 608, 557, 513, 473, 444, 415, 394, 373, 357, ++ 342, 329, 319, 312, 305, 301, 299, 299, 303, 306, 313, 322, 334, 346, 361, 381, 403, ++ 428, 460, 495, 534, 586, 628, 676, 626, 571, 528, 486, 454, 426, 401, 381, 363, 349, ++ 336, 327, 318, 313, 309, 307, 306, 309, 314, 320, 330, 343, 355, 371, 389, 413, 438, ++ 469, 505, 546, 595, 642, 701, 642, 588, 539, 499, 466, 436, 410, 393, 375, 359, 346, ++ 336, 327, 322, 317, 316, 316, 318, 323, 329, 338, 350, 363, 381, 400, 424, 450, 481, ++ 518, 561, 610, 663, 722, 663, 603, 559, 515, 478, 450, 425, 402, 385, 370, 356, 345, ++ 337, 330, 327, 325, 325, 327, 333, 338, 348, 360, 373, 389, 411, 434, 462, 493, 533, ++ 576, 630, 681, 748, 681, 623, 572, 531, 492, 464, 437, 414, 396, 380, 366, 356, 347, ++ 340, 337, 335, 335, 338, 343, 350, 359, 370, 384, 401, 421, 446, 473, 508, 546, 591, ++ 645, 707, 762, 701, 638, 586, 536, 504, 470, 446, 423, 402, 385, 372, 362, 353, 348, ++ 343, 340, 341, 345, 350, 356, 366, 378, 391, 410, 429, 454, 482, 516, 557, 601, 663, ++ 716, ++ }, ++ ++ /* gr_gain: */ ++ { ++ 702, 643, 590, 540, 499, 468, 437, 414, 394, 376, 361, 348, 339, 331, 324, 321, 320, ++ 321, 326, 329, 337, 348, 357, 371, 389, 411, 434, 463, 496, 537, 582, 637, 695, 684, ++ 633, 576, 529, 491, 459, 430, 407, 388, 370, 355, 342, 333, 324, 318, 316, 313, 315, ++ 318, 323, 330, 341, 349, 363, 381, 403, 426, 454, 486, 526, 572, 623, 676, 668, 615, ++ 560, 515, 479, 448, 418, 397, 378, 361, 346, 334, 324, 317, 311, 307, 306, 306, 309, ++ 316, 322, 331, 342, 355, 372, 393, 415, 443, 474, 511, 557, 607, 660, 652, 599, 546, ++ 502, 468, 436, 410, 388, 370, 352, 337, 327, 317, 308, 303, 300, 297, 298, 301, 306, ++ 313, 323, 333, 347, 363, 382, 405, 432, 461, 498, 542, 593, 642, 635, 583, 536, 493, ++ 457, 426, 401, 379, 362, 344, 331, 319, 310, 302, 295, 292, 290, 290, 292, 298, 306, ++ 313, 324, 337, 354, 373, 396, 422, 451, 487, 530, 578, 629, 620, 572, 523, 483, 448, ++ 418, 394, 371, 354, 337, 324, 313, 303, 296, 290, 285, 283, 283, 286, 291, 297, 306, ++ 317, 331, 347, 365, 387, 414, 443, 478, 518, 565, 616, 608, 560, 512, 474, 441, 411, ++ 386, 364, 348, 331, 318, 307, 297, 290, 284, 280, 276, 277, 279, 283, 291, 300, 312, ++ 324, 341, 358, 381, 405, 434, 468, 509, 556, 608, 595, 552, 506, 467, 434, 405, 380, ++ 359, 342, 327, 313, 302, 292, 285, 278, 273, 270, 270, 273, 278, 285, 295, 306, 318, ++ 334, 353, 373, 398, 427, 460, 499, 544, 599, 588, 542, 497, 459, 426, 398, 375, 355, ++ 337, 322, 309, 297, 288, 280, 273, 269, 266, 265, 268, 273, 280, 289, 300, 313, 329, ++ 348, 369, 393, 419, 454, 493, 537, 590, 577, 536, 492, 454, 422, 394, 371, 350, 333, ++ 317, 305, 294, 284, 276, 269, 265, 261, 261, 264, 268, 276, 285, 296, 310, 324, 343, ++ 364, 387, 414, 447, 485, 529, 583, 572, 527, 485, 448, 417, 389, 365, 347, 329, 313, ++ 301, 290, 281, 272, 266, 261, 259, 258, 260, 265, 272, 282, 292, 306, 321, 339, 359, ++ 382, 411, 441, 479, 523, 571, 567, 524, 482, 446, 415, 386, 363, 343, 326, 311, 298, ++ 287, 277, 269, 262, 259, 257, 257, 258, 262, 269, 279, 291, 302, 318, 335, 356, 379, ++ 406, 436, 474, 517, 556, 563, 521, 479, 443, 412, 385, 362, 342, 323, 308, 295, 285, ++ 276, 267, 261, 257, 257, 256, 259, 260, 268, 277, 289, 301, 316, 333, 352, 377, 404, ++ 433, 470, 511, 552, 560, 517, 478, 443, 409, 384, 361, 340, 321, 307, 295, 283, 273, ++ 265, 260, 256, 256, 256, 257, 260, 267, 276, 287, 299, 315, 330, 350, 374, 402, 431, ++ 467, 508, 549, 557, 516, 475, 441, 408, 383, 359, 339, 321, 306, 292, 282, 273, 265, ++ 259, 256, 256, 256, 257, 260, 266, 276, 287, 299, 312, 329, 350, 372, 398, 428, 465, ++ 505, 544, 557, 516, 474, 439, 408, 382, 359, 339, 321, 305, 292, 282, 272, 264, 258, ++ 256, 256, 256, 258, 260, 267, 276, 286, 298, 312, 329, 349, 372, 398, 428, 463, 505, ++ 542, 558, 515, 477, 439, 408, 381, 360, 338, 321, 306, 293, 282, 272, 264, 258, 256, ++ 256, 256, 257, 260, 267, 276, 287, 298, 312, 329, 348, 371, 398, 426, 462, 502, 541, ++ 558, 516, 478, 442, 411, 382, 359, 339, 323, 307, 294, 283, 273, 265, 258, 256, 256, ++ 256, 257, 261, 268, 277, 288, 300, 313, 330, 349, 371, 397, 427, 462, 505, 542, 559, ++ 520, 479, 443, 412, 384, 361, 340, 323, 308, 295, 285, 275, 267, 260, 256, 256, 256, ++ 258, 262, 269, 279, 289, 301, 315, 333, 351, 373, 398, 428, 466, 505, 543, 566, 521, ++ 480, 445, 414, 387, 363, 342, 325, 311, 296, 286, 276, 269, 262, 257, 257, 257, 260, ++ 264, 272, 281, 291, 304, 317, 334, 353, 376, 402, 431, 467, 508, 549, 571, 525, 484, ++ 448, 416, 389, 366, 346, 328, 312, 300, 289, 280, 271, 265, 261, 259, 260, 263, 267, ++ 274, 283, 294, 306, 321, 336, 356, 379, 405, 432, 471, 514, 553, 574, 530, 488, 454, ++ 421, 393, 370, 349, 331, 316, 303, 291, 282, 276, 269, 264, 263, 264, 265, 271, 278, ++ 287, 297, 308, 323, 340, 360, 381, 408, 439, 474, 519, 558, 583, 539, 495, 457, 425, ++ 398, 373, 354, 335, 320, 307, 296, 286, 279, 273, 269, 268, 268, 270, 275, 282, 291, ++ 301, 313, 327, 343, 363, 386, 414, 445, 483, 523, 566, 591, 545, 501, 463, 432, 404, ++ 379, 359, 341, 325, 312, 301, 291, 283, 278, 273, 273, 272, 276, 280, 286, 295, 305, ++ 318, 332, 348, 369, 391, 417, 449, 487, 530, 572, 599, 557, 510, 471, 437, 411, 386, ++ 365, 347, 331, 318, 306, 297, 290, 284, 279, 277, 278, 281, 285, 291, 300, 311, 323, ++ 337, 355, 373, 398, 425, 458, 494, 538, 577, 615, 567, 521, 480, 445, 417, 393, 371, ++ 353, 337, 324, 312, 302, 295, 290, 286, 284, 285, 287, 291, 297, 306, 316, 328, 343, ++ 361, 380, 405, 433, 466, 501, 544, 589, 627, 579, 532, 490, 455, 424, 399, 378, 361, ++ 345, 330, 318, 310, 302, 297, 292, 291, 291, 293, 297, 304, 312, 323, 336, 350, 368, ++ 388, 413, 439, 474, 511, 555, 598, 643, 594, 544, 500, 466, 434, 409, 386, 368, 352, ++ 339, 327, 317, 310, 304, 300, 298, 299, 300, 305, 311, 319, 330, 342, 357, 375, 396, ++ 421, 448, 482, 523, 566, 611, 657, 611, 557, 513, 476, 446, 420, 396, 377, 361, 347, ++ 335, 324, 317, 312, 307, 306, 306, 308, 312, 318, 327, 337, 351, 365, 384, 405, 429, ++ 459, 493, 532, 579, 623, 681, 625, 573, 529, 489, 457, 431, 407, 387, 370, 356, 343, ++ 334, 327, 319, 316, 313, 315, 317, 321, 327, 335, 347, 359, 373, 394, 414, 439, 469, ++ 506, 546, 593, 643, 696, 643, 588, 542, 505, 469, 443, 417, 397, 379, 365, 353, 342, ++ 335, 329, 324, 323, 323, 325, 329, 335, 345, 356, 369, 386, 404, 425, 450, 483, 517, ++ 558, 611, 663, 720, 660, 607, 558, 516, 484, 455, 432, 407, 390, 374, 363, 352, 343, ++ 339, 335, 333, 331, 335, 339, 345, 354, 365, 378, 396, 414, 436, 463, 496, 531, 574, ++ 626, 681, 737, 673, 619, 571, 527, 492, 462, 437, 416, 397, 382, 369, 360, 350, 344, ++ 341, 338, 337, 340, 345, 351, 361, 371, 386, 402, 420, 443, 471, 505, 541, 582, 637, ++ 690, ++ }, ++ ++ /* gb_gain: */ ++ { ++ 705, 645, 587, 539, 500, 468, 438, 413, 394, 377, 360, 348, 338, 331, 325, 321, 320, ++ 322, 326, 330, 336, 347, 356, 371, 389, 409, 433, 462, 496, 533, 581, 638, 691, 688, ++ 633, 575, 529, 489, 459, 429, 406, 387, 370, 354, 342, 332, 324, 318, 314, 314, 314, ++ 318, 323, 330, 340, 349, 364, 381, 400, 426, 455, 485, 523, 569, 624, 680, 668, 614, ++ 562, 516, 480, 448, 419, 397, 378, 360, 347, 334, 324, 317, 311, 307, 306, 306, 309, ++ 315, 322, 331, 341, 353, 372, 392, 415, 443, 473, 512, 556, 609, 659, 648, 599, 547, ++ 504, 468, 438, 409, 388, 370, 352, 337, 327, 317, 308, 302, 299, 297, 297, 301, 306, ++ 314, 323, 332, 345, 363, 381, 405, 430, 462, 498, 541, 592, 638, 635, 583, 536, 493, ++ 458, 427, 401, 380, 361, 343, 330, 319, 309, 301, 296, 292, 290, 291, 292, 298, 305, ++ 313, 324, 338, 355, 373, 395, 422, 453, 487, 529, 578, 622, 618, 570, 524, 484, 448, ++ 419, 394, 372, 353, 337, 323, 313, 303, 295, 290, 286, 283, 283, 286, 290, 297, 306, ++ 318, 330, 348, 365, 388, 412, 443, 477, 517, 564, 617, 610, 563, 512, 474, 440, 411, ++ 387, 365, 348, 331, 318, 307, 297, 290, 283, 278, 277, 277, 278, 283, 291, 299, 312, ++ 324, 340, 358, 380, 405, 434, 469, 507, 555, 607, 598, 551, 506, 468, 432, 405, 380, ++ 359, 343, 326, 313, 302, 293, 285, 278, 274, 271, 270, 273, 278, 285, 293, 304, 318, ++ 334, 351, 373, 398, 427, 461, 499, 543, 597, 588, 543, 497, 460, 428, 399, 374, 355, ++ 337, 322, 309, 298, 288, 279, 273, 269, 265, 265, 268, 273, 280, 288, 300, 313, 329, ++ 347, 367, 390, 419, 455, 493, 537, 591, 578, 537, 492, 453, 423, 394, 371, 350, 333, ++ 317, 305, 293, 284, 276, 269, 264, 261, 261, 264, 268, 275, 284, 296, 308, 325, 343, ++ 364, 386, 414, 447, 485, 528, 579, 572, 529, 487, 449, 418, 390, 366, 348, 330, 314, ++ 301, 290, 279, 273, 265, 261, 258, 259, 260, 264, 272, 281, 292, 305, 320, 338, 358, ++ 382, 409, 440, 477, 522, 567, 568, 525, 483, 447, 415, 388, 364, 344, 326, 312, 298, ++ 287, 277, 269, 262, 258, 257, 257, 259, 261, 269, 278, 290, 302, 318, 336, 355, 379, ++ 407, 437, 473, 516, 555, 562, 519, 479, 444, 412, 385, 363, 343, 324, 308, 296, 284, ++ 276, 267, 261, 257, 257, 257, 258, 261, 268, 277, 289, 301, 316, 332, 352, 375, 404, ++ 434, 469, 511, 552, 562, 518, 477, 440, 411, 384, 361, 340, 322, 307, 294, 283, 274, ++ 265, 260, 256, 256, 257, 258, 260, 266, 275, 287, 300, 314, 330, 351, 374, 402, 430, ++ 467, 508, 548, 561, 517, 475, 440, 410, 382, 359, 338, 322, 306, 293, 282, 273, 265, ++ 258, 256, 256, 257, 257, 260, 265, 275, 287, 299, 313, 330, 350, 373, 398, 428, 464, ++ 505, 544, 559, 516, 475, 440, 408, 382, 358, 339, 321, 305, 293, 282, 272, 264, 258, ++ 256, 256, 256, 257, 260, 266, 275, 287, 298, 312, 329, 349, 372, 398, 428, 462, 503, ++ 542, 559, 516, 475, 440, 408, 382, 358, 340, 322, 306, 293, 282, 273, 264, 258, 256, ++ 256, 256, 257, 261, 267, 277, 287, 298, 313, 329, 349, 371, 398, 427, 462, 502, 542, ++ 559, 517, 476, 440, 409, 383, 359, 338, 322, 307, 293, 283, 273, 265, 258, 256, 256, ++ 256, 257, 261, 268, 277, 287, 299, 314, 330, 349, 372, 398, 428, 462, 503, 543, 562, ++ 521, 480, 443, 412, 385, 362, 341, 323, 308, 296, 285, 274, 267, 260, 256, 256, 256, ++ 257, 262, 269, 279, 289, 301, 315, 332, 351, 373, 399, 428, 465, 507, 544, 564, 522, ++ 481, 445, 414, 387, 364, 343, 325, 311, 297, 287, 277, 269, 262, 257, 257, 257, 260, ++ 265, 272, 281, 291, 303, 318, 335, 353, 375, 401, 432, 468, 509, 551, 571, 525, 485, ++ 448, 417, 390, 367, 346, 329, 313, 300, 290, 280, 272, 265, 261, 260, 260, 262, 267, ++ 274, 283, 294, 306, 320, 337, 356, 379, 405, 434, 470, 513, 553, 576, 531, 489, 454, ++ 421, 394, 370, 350, 332, 317, 303, 293, 283, 274, 269, 265, 263, 264, 266, 272, 278, ++ 287, 297, 309, 323, 340, 359, 382, 408, 438, 476, 517, 559, 583, 540, 496, 458, 426, ++ 397, 374, 355, 336, 320, 307, 296, 287, 279, 274, 269, 268, 269, 271, 276, 282, 291, ++ 301, 313, 328, 344, 364, 387, 414, 445, 482, 523, 562, 593, 548, 504, 465, 432, 405, ++ 380, 358, 341, 325, 312, 301, 292, 283, 278, 274, 273, 273, 276, 280, 286, 295, 306, ++ 318, 332, 349, 368, 390, 418, 450, 487, 530, 570, 603, 559, 513, 473, 438, 409, 387, ++ 365, 348, 331, 318, 307, 297, 290, 284, 280, 278, 278, 282, 286, 292, 300, 311, 323, ++ 338, 355, 374, 398, 426, 458, 495, 535, 575, 615, 569, 524, 481, 447, 417, 394, 372, ++ 354, 338, 324, 313, 305, 296, 290, 286, 284, 284, 287, 291, 297, 306, 316, 329, 343, ++ 362, 380, 405, 432, 464, 501, 544, 586, 631, 582, 532, 492, 456, 426, 400, 380, 362, ++ 345, 331, 319, 311, 302, 297, 293, 291, 291, 293, 298, 303, 313, 323, 336, 349, 369, ++ 388, 413, 439, 473, 511, 555, 597, 645, 596, 543, 502, 466, 435, 409, 387, 369, 352, ++ 340, 328, 318, 310, 304, 301, 298, 299, 301, 305, 311, 320, 330, 343, 357, 376, 397, ++ 421, 449, 484, 522, 565, 613, 660, 607, 560, 515, 479, 447, 419, 397, 378, 363, 348, ++ 336, 325, 318, 312, 308, 306, 307, 308, 313, 319, 327, 338, 350, 365, 384, 405, 430, ++ 460, 493, 535, 579, 626, 681, 625, 575, 530, 488, 459, 432, 406, 387, 371, 357, 344, ++ 335, 326, 319, 316, 314, 314, 317, 322, 328, 336, 347, 359, 376, 394, 416, 440, 470, ++ 507, 544, 594, 642, 697, 645, 592, 543, 506, 473, 444, 418, 398, 380, 366, 354, 344, ++ 335, 330, 325, 324, 324, 325, 330, 336, 346, 357, 369, 386, 403, 425, 453, 482, 517, ++ 560, 609, 659, 722, 665, 607, 560, 519, 484, 455, 430, 408, 390, 374, 364, 352, 344, ++ 339, 336, 334, 332, 336, 338, 345, 355, 365, 379, 395, 414, 436, 463, 495, 532, 575, ++ 626, 681, 739, 678, 621, 574, 531, 493, 463, 438, 417, 398, 382, 369, 359, 351, 346, ++ 341, 340, 338, 341, 345, 352, 362, 372, 385, 401, 422, 444, 469, 504, 542, 588, 639, ++ 693, ++ }, ++ ++ /* b_gain: */ ++ { ++ 669, 620, 567, 522, 485, 456, 427, 402, 385, 368, 353, 341, 334, 327, 321, 317, 316, ++ 317, 320, 326, 334, 341, 353, 367, 382, 404, 426, 456, 483, 524, 569, 620, 682, 657, ++ 610, 554, 512, 477, 445, 419, 397, 380, 361, 346, 337, 327, 320, 315, 311, 310, 310, ++ 315, 320, 328, 337, 346, 358, 374, 396, 419, 445, 477, 514, 558, 610, 660, 645, 590, ++ 541, 503, 463, 435, 408, 388, 370, 354, 340, 329, 320, 313, 307, 304, 301, 303, 307, ++ 311, 318, 328, 338, 351, 367, 385, 408, 435, 465, 503, 543, 595, 642, 623, 576, 527, ++ 488, 454, 425, 400, 381, 361, 345, 332, 320, 312, 305, 299, 296, 295, 295, 298, 305, ++ 309, 320, 329, 342, 358, 378, 398, 424, 456, 488, 527, 578, 620, 610, 567, 518, 478, ++ 445, 416, 391, 371, 354, 337, 326, 315, 306, 298, 292, 289, 287, 288, 290, 296, 303, ++ 310, 320, 334, 351, 368, 388, 415, 445, 478, 516, 567, 612, 600, 552, 505, 468, 436, ++ 408, 384, 365, 346, 331, 319, 309, 300, 292, 286, 284, 281, 280, 285, 288, 294, 304, ++ 314, 327, 342, 360, 382, 406, 436, 468, 507, 549, 605, 587, 541, 495, 460, 429, 401, ++ 380, 358, 341, 327, 315, 305, 295, 287, 280, 277, 274, 275, 278, 281, 288, 297, 309, ++ 320, 337, 354, 375, 398, 426, 460, 497, 539, 592, 578, 531, 490, 456, 422, 396, 371, ++ 353, 337, 322, 309, 300, 290, 281, 277, 271, 270, 269, 271, 276, 283, 293, 303, 316, ++ 330, 349, 368, 393, 419, 454, 488, 535, 585, 567, 524, 483, 447, 418, 389, 367, 349, ++ 332, 317, 305, 295, 286, 278, 271, 268, 264, 263, 266, 271, 278, 287, 297, 311, 326, ++ 343, 365, 387, 414, 446, 483, 522, 578, 560, 516, 477, 440, 413, 385, 364, 344, 328, ++ 315, 300, 291, 281, 273, 268, 262, 261, 261, 262, 268, 275, 283, 294, 307, 322, 340, ++ 358, 383, 408, 440, 477, 516, 569, 549, 512, 472, 438, 406, 382, 358, 341, 326, 310, ++ 298, 288, 278, 270, 263, 260, 257, 258, 261, 263, 271, 279, 291, 305, 318, 335, 354, ++ 379, 405, 434, 471, 512, 556, 547, 509, 468, 435, 405, 380, 357, 339, 320, 307, 296, ++ 285, 276, 269, 262, 258, 257, 258, 260, 262, 269, 278, 289, 301, 317, 332, 352, 375, ++ 401, 431, 466, 507, 547, 545, 505, 466, 434, 402, 378, 355, 337, 320, 305, 294, 283, ++ 272, 265, 260, 256, 256, 257, 258, 261, 267, 276, 288, 299, 314, 330, 351, 371, 398, ++ 426, 462, 503, 541, 541, 505, 465, 430, 401, 377, 354, 334, 317, 303, 292, 281, 272, ++ 264, 259, 256, 257, 257, 259, 261, 266, 274, 286, 298, 310, 329, 349, 369, 396, 425, ++ 460, 500, 537, 539, 503, 463, 431, 400, 374, 353, 334, 317, 303, 290, 280, 270, 263, ++ 258, 256, 256, 257, 259, 261, 265, 276, 285, 297, 310, 327, 347, 368, 395, 424, 459, ++ 495, 533, 537, 503, 465, 431, 399, 373, 352, 333, 317, 302, 289, 280, 271, 263, 257, ++ 256, 256, 256, 258, 260, 265, 274, 286, 297, 311, 327, 346, 368, 391, 422, 456, 495, ++ 533, 539, 503, 465, 431, 400, 374, 353, 333, 317, 303, 290, 279, 270, 263, 257, 256, ++ 256, 256, 257, 261, 267, 276, 286, 297, 310, 327, 345, 368, 394, 421, 456, 493, 531, ++ 539, 503, 462, 430, 401, 376, 353, 334, 318, 303, 291, 280, 271, 264, 257, 256, 256, ++ 256, 257, 261, 267, 277, 287, 298, 311, 327, 346, 368, 395, 421, 456, 495, 531, 541, ++ 505, 465, 434, 402, 377, 355, 337, 319, 304, 292, 283, 273, 265, 260, 256, 256, 256, ++ 259, 262, 269, 278, 288, 300, 314, 329, 348, 369, 396, 422, 457, 498, 535, 547, 509, ++ 466, 434, 407, 381, 358, 338, 320, 307, 296, 285, 277, 268, 262, 257, 256, 257, 261, ++ 263, 271, 280, 289, 301, 316, 330, 351, 373, 397, 425, 460, 502, 537, 549, 512, 471, ++ 438, 408, 383, 360, 341, 325, 309, 297, 288, 278, 271, 264, 261, 259, 261, 262, 268, ++ 273, 284, 293, 305, 318, 334, 353, 375, 400, 429, 466, 505, 539, 556, 516, 477, 440, ++ 413, 386, 366, 343, 328, 314, 300, 290, 280, 273, 268, 264, 262, 263, 265, 271, 277, ++ 286, 296, 307, 322, 338, 356, 380, 404, 435, 469, 509, 545, 565, 522, 482, 446, 416, ++ 390, 369, 350, 331, 317, 305, 295, 285, 278, 272, 268, 267, 268, 270, 275, 281, 289, ++ 299, 312, 326, 341, 360, 383, 408, 438, 474, 514, 552, 571, 535, 490, 453, 422, 396, ++ 372, 354, 336, 322, 309, 299, 289, 281, 276, 272, 271, 272, 274, 280, 286, 293, 305, ++ 317, 330, 345, 366, 387, 415, 442, 480, 518, 560, 580, 541, 497, 460, 427, 401, 379, ++ 358, 341, 328, 315, 305, 295, 288, 282, 278, 278, 277, 280, 285, 291, 298, 308, 320, ++ 334, 351, 371, 393, 420, 450, 485, 525, 565, 597, 549, 507, 466, 436, 408, 384, 366, ++ 346, 332, 320, 310, 301, 295, 287, 283, 283, 284, 285, 290, 297, 305, 315, 327, 341, ++ 357, 375, 400, 425, 456, 491, 535, 573, 607, 565, 516, 478, 445, 418, 391, 373, 356, ++ 341, 328, 317, 307, 300, 295, 290, 289, 291, 292, 296, 301, 310, 321, 333, 349, 365, ++ 383, 407, 435, 466, 505, 541, 587, 623, 576, 529, 488, 454, 425, 402, 382, 364, 350, ++ 336, 322, 316, 307, 300, 298, 297, 298, 299, 303, 309, 317, 328, 341, 354, 371, 390, ++ 416, 443, 475, 512, 554, 600, 642, 590, 541, 503, 466, 436, 409, 388, 371, 356, 343, ++ 332, 322, 315, 309, 306, 305, 305, 307, 310, 316, 326, 337, 347, 364, 380, 400, 424, ++ 454, 483, 522, 567, 612, 651, 607, 554, 514, 478, 447, 422, 399, 382, 366, 352, 340, ++ 330, 322, 317, 315, 313, 313, 315, 318, 326, 333, 344, 357, 371, 390, 410, 434, 463, ++ 495, 537, 578, 623, 672, 623, 573, 531, 491, 460, 434, 409, 390, 374, 360, 348, 339, ++ 332, 327, 322, 321, 321, 325, 327, 334, 342, 353, 368, 381, 400, 420, 445, 477, 509, ++ 547, 595, 642, 692, 642, 590, 543, 505, 475, 443, 422, 402, 384, 370, 358, 349, 341, ++ 337, 331, 330, 330, 332, 337, 343, 351, 363, 375, 390, 409, 433, 456, 485, 522, 560, ++ 612, 663, 705, 657, 605, 554, 514, 482, 454, 431, 412, 389, 378, 365, 354, 350, 343, ++ 338, 337, 337, 340, 342, 351, 358, 368, 383, 397, 416, 436, 465, 493, 533, 571, 623, ++ 682, ++ }, ++ }, ++ }, ++ ++ /* bnr_lsc_gain_lut */ ++ { ++ /* r_gain */ ++ { ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096 ++ }, ++ /* gr_gain */ ++ { ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096 ++ }, ++ /* gb_gain */ ++ { ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096 ++ }, ++ /* b_gain */ ++ { ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, ++ 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096 ++ }, ++ }, ++ } ++}; ++ ++static const ot_isp_cmos_acs g_cmos_acs = { ++ /* acs_attr */ ++ { ++ /* en */ ++ 1, ++ /* y_strength */ ++ 256, ++ /* run_interval */ ++ 2, ++ /* lock_en */ ++ 0, ++ }, ++ /* acs_calib_param */ ++ { ++ /* light_index */ ++ { ++ -1, 23, 10, 5, 4, 1, 5, -1, 6, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ++ -1, -1, -1, 22, ++ -1, 0, 10, 14, 3, 14, 5, -1, 2, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ++ -1, -1, -1, 23, ++ }, ++ /* model_ar_min */ ++ -0.08f, ++ /* model_ar_step */ ++ 0.098f, ++ /* model_ab_min */ ++ 0, ++ /* model_ab_step */ ++ 0.28f, ++ /* light_type_g_high */ ++ 1, ++ /* light_type_g_low */ ++ 2 ++ }, ++ ++ /* acs_y_shading_lut */ ++ { ++ /* g_param_high_ct */ ++ { ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024 ++ }, ++ /* g_param_low_ct */ ++ { ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, ++ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024 ++ }, ++ }, ++ ++ /* acs_color_shading_lut */ ++ { ++ /* avg_rg_map */ ++ { ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000 ++ }, ++ ++ /* avg_bg_map */ ++ { ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000 ++ }, ++ ++ /* prof_rg_map */ ++ { ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000 ++ }, ++ ++ /* prof_bg_map */ ++ { ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, 1.000000000, ++ 1.000000000 ++ } ++ } ++}; ++ ++static const ot_isp_cmos_clut g_cmos_clut = { ++ { ++ 1, ++ 128, ++ 128, ++ 128, ++ }, ++ { ++ { ++ 0, 3149813, 1046533, 3149814, 6299621, 9450452, 6299622, 9450451, 12602304, ++ 16802729, 12602303, 16803752, 22052752, 26255221, 21005198, 25206643, 30457689, 35708733, ++ 29409112, 32563005, 39910177, 45161223, 35714854, 38866705, 49362669, 54612692, 42017535, ++ 45168367, 60912311, 68261528, 48319196, 52519622, 75610743, 3149814, 57769646, 4198390, ++ 2095110, 9451475, 3143687, 9451474, 6299621, 15755175, 6300644, 14706598, 12603326, ++ 23110515, 11554749, 21012342, 19956621, 29416257, 17859470, 25219913, 26263385, 32572189, ++ 23116638, 26276652, 31519533, 34675465, 26273592, 25232160, 33624849, 37828337, 26279717, ++ 24187669, 35727104, 5246965, 24184604, 6295538, 39930592, 9451473, 25238283, 9451472, ++ 4192261, 13658024, 6290435, 11559850, 7349219, 17865595, 7349218, 14716804, 11554749, ++ 19973973, 10506174, 14727012, 15761298, 18932542, 13663127, 11587410, 18920295, 15788854, ++ 14722931, 7395148, 19978055, 12645170, 13681497, 2153291, 17884985, 8393711, 9491278, ++ 9443307, 14741301, 9451472, 4249419, 8402896, 11597614, 9461678, 1072749387, 7363507, ++ 7341055, 10520463, 10487801, 6323098, 8398816, 8430453, 9447390, 2134918, 9456575, ++ 4241254, 8408001, 1070637947, 10515358, 1071693666, 7367590, 1063299959, 9475969, 1065403234, ++ 4229007, 1054911353, 6336364, 11541479, 39808, 12591075, 1097571, 8402896, 1067493240, ++ 8402896, 1068548962, 5264313, 1059105655, 3166143, 1061208932, 2125734, 1050717050, 1071670194, ++ 12586995, 1070629783, 14685164, 1064333224, 9448411, 1063292815, 10496985, 1054899107, 7358404, ++ 1053856653, 6308808, 1045462946, 4219823, 1044420494, 1071032, 1034977187, 1072723870, 12592094, ++ 1068525484, 12593114, 1066436498, 7354321, 1060140965, 6304722, 1059099533, 2115526, 1050704802, ++ 16333, 1049663373, 1067471805, 1040220066, 1063274441, 1040226191, 1058037688, 1029734309, 1052790727, ++ 15735781, 1047553974, 15737822, 1040208840, 10498007, 1037068214, 9449430, 1027625931, 4210635, ++ 1025534905, 3161039, 1015043022, 1071665089, 11545558, 1068516298, 9449426, 1063279546, 5256147, ++ 1058032584, 4207572, 1052795830, 1071658963, 1046499271, 1069560794, 1042311094, 1059077076, 1033917385, ++ 1055929311, 1030777783, 1046495190, 1021334477, 1041248229, 1019243450, 1032863706, 1008751568, 1025519596, ++ 14690264, 1019232223, 11546577, 1010838515, 8400852, 1005600740, 6303699, 996157434, 2111443, ++ 6304718, 1061847, 3160010, 1065368531, 2109398, 1062220764, 1060823, 1052786645, 1067461600, ++ 1048588258, 1065362407, 1040203736, 1051731946, 1033908201, 1047534581, 1026572253, 1034952692, 1018178543, ++ 1029705730, 1012940770, 1019223038, 1003498487, 1011877903, 998260711, 1002443783, 987768830, 994050075, ++ 8402891, 974131202, 4209605, 946862085, 4207569, 15302, 2110416, 1071641611, 1060827, ++ 11225, 11232, 2102257, 1059071973, 1063264237, 1056972782, 8402898, 1043342319, 1043336192, ++ 1038096380, 16801708, 1026564089, 1023410193, 1020267529, 26254200, 1010832386, 1005581344, 1002439701, ++ 36754246, 985665539, 986704943, 985660448, 45154078, 961547264, 966778940, 931132416, 55650040, ++ 17343, 1070593036, 1068492823, 1073739785, 13263, 2102257, 2046, 3151855, 9188, ++ 8401877, 5252066, 8403918, 1053825015, 15751092, 12602304, 15756196, 1033896968, 27300735, ++ 21003156, 22060919, 1015019545, 40949569, 31504222, 26263385, 996143144, 54595340, 40953649, ++ 28366660, 977266741, 67192538, 50402060, 32567088, 899670016, 1072690186, 59850468, 2096132, ++ 1067443224, 3151856, 1071638548, 3151853, 1072694271, 8402896, 1050621, 7355341, 5252067, ++ 16803749, 5253088, 10511275, 11551685, 25207666, 11555770, 12617612, 19951519, 31509326, ++ 18908045, 12624758, 34649951, 36760369, 24162150, 12628840, 47248165, 43059989, 27316045, ++ 11583326, 60893939, 1046535, 30466874, 5244924, 73491137, 3151854, 33618724, 4202471, ++ 1069541398, 8403917, 1044494, 4209616, 0, 12609447, 2100217, 4216760, 5253089, ++ 17863553, 5254110, 3174308, 12603324, 19968871, 8409020, 33686, 21006220, 21022550, ++ 11564955, 1069584269, 28358495, 21026632, 12621696, 1065392006, 34659134, 3145728, 12626799, ++ 8392690, 39910180, 4201450, 11582307, 5252067, 47258373, 6306766, 10536792, 2111445, ++ 1072688146, 7364529, 6289414, 1071663047, 1050619, 7371672, 4199410, 1066424253, 5253087, ++ 6329222, 4205532, 1060135861, 10507194, 4235131, 4212676, 1052797872, 15761299, 1092466, ++ 3171246, 1045458861, 18916210, 6294519, 1079197, 9443304, 19970910, 5251045, 1071679377, ++ 4203489, 21024591, 3160018, 1067488137, 1072705499, 22077248, 1068992, 1062247300, 1064318935, ++ 3142667, 1071670193, 9438202, 1055932372, 3149814, 1066431398, 6297579, 1046496211, 5254109, ++ 1061190559, 3156956, 1037060051, 6310847, 1054901146, 16334, 1026575315, 7368612, 9442285, ++ 1068519362, 7347165, 7374734, 5252066, 1063279544, 3154911, 5282688, 1061848, 1056991154, ++ 1069557731, 2140022, 1068515279, 1049653166, 1058023398, 1072738159, 1061178312, 1042314156, 1045440491, ++ 8387584, 1053840324, 11538412, 1032857583, 6296558, 1045452737, 7347172, 1020274676, 4205532, ++ 1036017600, 2108382, 1007690746, 2114504, 8395747, 1068512217, 3154899, 1072716728, 4203488, ++ 1060125653, 1057757, 1069575083, 1071655903, 1051739091, 1067458538, 1064335266, 1061171167, 1042302930, ++ 1051727861, 1058045852, 1050686431, 1031817171, 1035996161, 1052805016, 1040200673, 1022381012, 1020266508, ++ 11537395, 1028667364, 9444317, 1004535830, 7347175, 1017133030, 5251038, 963636228, 3156957, ++ 5251032, 1058785, 1064295459, 1071659987, 2106334, 1064314852, 1070592014, 1064323019, 1068508134, ++ 1051731944, 2100215, 1056985030, 1054875630, 1039149037, 9448410, 1049647042, 1041243126, 1026566130, ++ 20996013, 1041259457, 1026562045, 1013982199, 33592188, 1031823296, 1012928517, 1001399292, 46187343, ++ 11539429, 988809218, 4203471, 58781478, 6299617, 10190, 2106328, 1067442205, 1058783, ++ 9181, 9188, 1071641610, 1066414047, 1065360366, 1059068912, 2102258, 1055929311, 1047531517, ++ 1043338235, 9451474, 1045443552, 1030751244, 1027607558, 16801708, 1033910242, 1015019546, 1011876881, ++ 25200521, 1023424485, 997191719, 998243355, 32549738, 1011890152, 980412467, 950002688, 39896909, ++ 7348182, 1063245862, 1061146670, 1070589974, 4203483, 1069543440, 1067443224, 1073740805, 9186, ++ 1050619, 1073740803, 2103278, 1061168106, 9447392, 5250026, 6305745, 1047535602, 22043568, ++ 14697413, 10509236, 1033903098, 37787511, 27293589, 14710683, 1019220993, 53530435, 39889765, ++ 16813958, 999296002, 69272339, 52484923, 19964786, 977273856, 1065344032, 65078035, 1044493, ++ 10184, 1071641612, 1064293415, 1050621, 9173, 2101236, 1069542420, 1055723, 9190, ++ 9450453, 1023, 2110422, 1056970741, 18898860, 5252067, 3165122, 1039140868, 29396866, ++ 13650879, 3170225, 1023409171, 39892828, 21001114, 2126754, 1005581344, 49339194, 28350329, ++ 1082261, 988802093, 1068491802, 35699547, 5240834, 920635392, 1072691207, 43046719, 2101238, ++ 1059048498, 2103280, 1069539358, 8169, 1066394651, 8402896, 1071640589, 1071656925, 1072692229, ++ 14704559, 3066, 1068514257, 5249007, 19955601, 4204512, 1064324039, 14695371, 25205624, ++ 8408002, 1061181375, 30439316, 29407072, 12609447, 1056989111, 46183260, 1072688145, 15762320, ++ 6293494, 60877610, 1, 18913148, 3150831, 76618492, 2104300, 22065001, 1072701418, ++ 1063244842, 5257171, 1042452, 1066412005, 1068492822, 7361467, 1046533, 1059074016, 1072693249, ++ 8416166, 1052661, 1052783581, 5251046, 9469844, 2107360, 1045445594, 14698433, 10523524, ++ 3162060, 1038106584, 24147862, 3142664, 3168185, 6294505, 34644847, 1051642, 2124713, ++ 2103273, 44092235, 1055722, 2128796, 1070603243, 53538601, 13273, 1083279, 1061167085, ++ 1066392610, 1072710601, 6288392, 1050681328, 1070590993, 1070618556, 3146748, 1040195571, 0, ++ 1068524464, 1054704, 1030758390, 5253089, 1066430374, 1072703459, 1020272633, 11553728, 5243900, ++ 1069561815, 3150812, 16805792, 2101235, 1066419148, 1055716, 22056836, 1072701417, 1063276483, ++ 1068506093, 27305836, 1068510177, 1059085243, 1054873590, 32555860, 1064318937, 1054894004, 1042288639, ++ 1071637529, 1059078098, 9437177, 1028655112, 1073738762, 1052788685, 4197363, 1015021585, 1051640, ++ 1047547848, 1054701, 981459971, 3155936, 6294511, 1069556711, 1054849090, 6309830, 3150828, ++ 1063267298, 1063243820, 8413104, 1071652843, 1055929311, 1070589975, 9467805, 1063265257, 1049638876, ++ 5244924, 10521484, 1054877672, 1042300889, 17837015, 11574140, 1046490088, 1034961879, 33577899, ++ 3140623, 1038102504, 7342057, 48270206, 3144705, 1029713897, 4199401, 64010067, 1053682, ++ 4198370, 1055722, 1059046454, 10209, 2103271, 1065361388, 1065343012, 15313, 1069554668, ++ 1055924207, 1072689168, 1071665090, 1058020338, 1045438449, 5245942, 1069570998, 1046484984, 1036001268, ++ 14692311, 1067477931, 1034949630, 1025515512, 25187252, 1064335266, 1022365700, 1015029755, 35683216, ++ 8386561, 1003488257, 3149785, 46178158, 4196343, 6101, 2103263, 1064292394, 1054702, ++ 7137, 7145, 1068491802, 1070605285, 1067457518, 1062213618, 1072690186, 1066414045, 1052775419, ++ 1048581115, 3150835, 1061174229, 1037042695, 1034947588, 9449432, 1055933391, 1023409171, 1022362637, ++ 15748030, 1050692554, 1008727071, 1008730134, 22046628, 1044403142, 994044971, 969923584, 29393802, ++ 8389617, 1052750919, 1050652748, 1068489759, 4198382, 1061145649, 1059046455, 1070590994, 1055723, ++ 1070587931, 1067441185, 1072692227, 1067458538, 5243903, 2093066, 1053681, 1059070952, 19934168, ++ 11540459, 3156958, 1050683368, 36724647, 25183170, 6307786, 1042295784, 54563701, 40924053, ++ 8411064, 1033908200, 72402757, 56664936, 11561894, 1024472041, 1056948284, 71356221, 1073735699, ++ 6294497, 1064293416, 1055898688, 1073739784, 3150820, 1071639571, 1062195245, 1071646717, 7146, ++ 5245945, 1068491802, 1071650801, 1063263215, 16789463, 2096131, 1070605285, 1051727861, 29382575, ++ 9445351, 1069560793, 1040193531, 41976711, 19940293, 1068516301, 1028657153, 55618400, 30435234, ++ 1067470786, 1011877890, 1061145648, 40930175, 4191236, 994050048, 1067441183, 51425117, 1049598, ++ 5073, 1072689165, 1061144627, 1071648760, 6107, 4198388, 1066392609, 1067456498, 8168, ++ 12595159, 1070590995, 1063264237, 1060116468, 20991928, 1049599, 1059071975, 1045433345, 29389722, ++ 6299622, 1054879714, 1029701645, 37786492, 12599243, 1049637854, 1016068121, 1066391589, 18897841, ++ 5242869, 1001386021, 1069541398, 25196439, 2100212, 941603840, 1072691206, 32543613, 1070601204, ++ 1047504978, 2102258, 1067439142, 1063261173, 1056948284, 6302683, 1069540377, 1055922165, 1065343014, ++ 11552708, 1071641611, 1047533558, 1043470, 15753134, 3067, 1040194552, 11539437, 19953560, ++ 2105319, 1032854521, 28328896, 1071637529, 5257172, 2099173, 46167950, 1072689165, 7359425, ++ 1052650, 64007005, 1071644672, 10510255, 1069553649, 81846061, 1072699377, 12612509, 1059066871, ++ 1052750918, 10209, 1041432, 1048580094, 1061144626, 1063889, 1073737742, 1037043717, 1068490782, ++ 2116546, 1073740803, 1025508365, 2095111, 2120628, 1071648759, 999285763, 10492905, 3141644, ++ 1070604267, 1043305572, 22037443, 1047555, 1069558751, 1054846030, 35680155, 1071647738, 1069562835, ++ 1065337910, 48273267, 1069553649, 1067468744, 4186139, 61914957, 1066410985, 1066424253, 17826810, ++ 1059045433, 1064315872, 5238791, 34614226, 1064293416, 1061173208, 3144705, 52451240, 1069541399, ++ 1059079120, 2043, 70289276, 1048577, 5241852, 1069552629, 1049601108, 8396774, 1050617, ++ 1065360367, 1059043393, 16793544, 1070600182, 1061168106, 1067438124, 25191337, 1065359347, 1056975845, ++ 4188181, 33588107, 1059068913, 1051735008, 13633528, 41984877, 1053827055, 1047541723, 27274199, ++ 1064292397, 1047536621, 7338997, 39866291, 1068490781, 1041246187, 3147764, 54555535, 1071640591, ++ 4195309, 4084, 1055897668, 0, 1052655, 1066406900, 1062193204, 4202470, 1070601203, ++ 1059067893, 1069537315, 9452495, 1061164022, 1051727862, 3141647, 13652921, 1051726842, 1044388855, ++ 9440247, 17853347, 1042289662, 1036000248, 18884572, 22053773, 1032850434, 1028660218, 28328896, ++ 1070586911, 1018168321, 4194275, 37774244, 1071639571, 2013, 1051623, 1062193205, 1072691207, ++ 5093, 6125, 1066390567, 1072696313, 1069553647, 1064309748, 1070588953, 8169, 1056969721, ++ 1053823995, 1045513, 1061849, 1044383747, 1042286594, 5245942, 1065930, 1031798797, 1031799817, ++ 9446370, 2118587, 1020262423, 1020264465, 15743949, 3171245, 1007677474, 988796928, 20991929, ++ 3139600, 1040157805, 1038059632, 1068488740, 2094087, 1052746836, 1048551513, 1069540378, 1072694271, ++ 1065335867, 1060091970, 1070592015, 1070600182, 4185118, 1071632425, 1072692228, 1068506093, 19923963, ++ 11528202, 1072697335, 1065363428, 38809552, 26220519, 1056745, 1063269340, 58743714, 43008957, ++ 2109404, 1060125652, 78679922, 61894546, 4209614, 1056982988, 1046453340, 79731558, 1042451, ++ 6289406, 1056945223, 1045404766, 1072689164, 3146747, 1066387505, 1053798475, 1071643654, 3064, ++ 4187160, 1063240759, 1068500991, 1068504053, 15730681, 1072683041, 1066405881, 1062213618, 30419925, ++ 9433094, 1065359346, 1055923184, 46158765, 19929064, 1063264235, 1050682350, 61897605, 33569733, ++ 1061170148, 1044391916, 1052748876, 47211425, 4191232, 1038101483, 1060094010, 60852093, 2097150, ++ 6291436, 1068487720, 1052748877, 1070598141, 2099181, 3140625, 1059045436, 1065356284, 5105, ++ 11536375, 1065340972, 1060114427, 1065358324, 23078873, 1072686105, 1054872570, 1056969720, 34622394, ++ 6289411, 1049629690, 1047532540, 46164889, 14686186, 1044387833, 1038093312, 1059045436, 23082958, ++ 3144685, 1025509377, 1064291373, 32527282, 1050608, 1011874816, 1069539358, 41972629, 1070601205, ++ 986, 2093068, 1060094011, 1062211577, 4064, 7343094, 1064291374, 1053822974, 7146, ++ 14689247, 1068489760, 1045432323, 1063262196, 22036423, 1072688145, 1037042697, 1050677246, 29383598, ++ 2097152, 1016062978, 1038091272, 1065340973, 7346156, 1031761034, 1026554898, 1067441185, 12595160, ++ 1045398641, 1013969949, 1070589972, 17843139, 1061134422, 963622912, 1073739782, 24140718, 3128377, ++ 1033863288, 2101239, 1067438121, 19913753, 1046452321, 5251046, 1068489759, 37749748, 1059041352, ++ 9450453, 1070589973, 57682892, 1071631405, 12601283, 1071641610, 78665634, 12575756, 1071636508, ++ 1071646718, 1039107189, 29366246, 1071639571, 6128, 1050646624, 48251833, 1071641611, 1058787, ++ 1063234633, 68187018, 1069547521, 3158997, 2081841, 88123226, 1069551608, 5260231, 16769045, ++ 1041208423, 1069554669, 2090006, 30409717, 1051699282, 1069557731, 1073736720, 46147539, 1061141565, ++ 1069560793, 1072690185, 62933935, 1071633445, 3141641, 1069547523, 1046452320, 10480648, 1046534, ++ 1067453436, 1055893582, 23074791, 1070596098, 1065358325, 1065335868, 38813633, 1067452414, 1064311790, ++ 1036327, 54552474, 1063260154, 1062216679, 12576784, 70292337, 1060115446, 1060122592, 22022134, ++ 1048552533, 1055923186, 5237761, 34612186, 1056946243, 1052778479, 3144703, 46153662, 1064290353, ++ 4193270, 2046, 1053797452, 1072685085, 1050615, 1068502013, 1061141565, 7336964, 1070599161, ++ 1063259131, 1067437102, 17831913, 1064308730, 1058017275, 1073732638, 28325834, 1056968700, 1052775418, ++ 7335948, 39869353, 1050677247, 1047532538, 14682104, 51411849, 1043336193, 1042290681, 22028258, ++ 1055897668, 1032848385, 3142636, 30421964, 1061144629, 1047523, 1049582, 1062192183, 1067439142, ++ 3049, 4082, 1065340972, 1072687125, 1071650800, 1066405879, 1068489761, 5241857, 1061164023, ++ 1058017275, 1072687125, 10491883, 1050676223, 1049626624, 3143688, 17839059, 1040188424, 1041236998, ++ 6293497, 25185210, 1030749200, 1031799820, 10491882, 32532386, 1020262425, 1008720896, 14690267, ++ 1063241778, 1027563668, 1024417942, 1069538337, 1066390567, 1043299449, 1038055549, 1070588954, 1069540379, ++ 1060083805, 1052741732, 1070590995, 1071640589, 3126334, 1068477512, 1070593036, 0, 22009883, ++ 11521066, 1071643652, 3151854, 41944052, 29352965, 1070599163, 7351261, 63974344, 48240608, ++ 1071649779, 10501068, 86006683, 68173751, 1072700395, 14700475, 1034909824, 88107916, 2092043, ++ 1071635488, 1048547432, 1032812672, 1045513, 1071637527, 1062185040, 1045400682, 1071642630, 1071640591, ++ 3129397, 1056941141, 1068498947, 1070595078, 17817623, 1069529149, 1065354241, 1069549565, 34604021, ++ 9425955, 1062210558, 1069552627, 52438991, 23063556, 1059065852, 1069555688, 70274985, 37754852, ++ 1056968698, 1069558750, 1043303531, 54540225, 2094068, 1069561812, 1053794391, 70279069, 1049590, ++ 4189195, 1064285250, 1042255977, 1072696313, 2094087, 2083884, 1051697239, 1066404859, 1073740804, ++ 14672914, 1060090949, 1060113406, 1068499968, 26216438, 1070581810, 1053820929, 1065356284, 39855063, ++ 6282268, 1047528453, 1062212600, 54544310, 16773123, 1033890817, 1058019316, 1050649686, 28316649, ++ 1018119345, 1054874608, 1057993798, 40907724, 1037000852, 1050682349, 1066386485, 52449199, 1055881335, ++ 4191222, 1038371, 1050650707, 2070616, 3145719, 9432078, 1057993797, 22001719, 3064, ++ 18876407, 1064289334, 42981395, 1067453434, 28319710, 1070584870, 65012717, 1061163003, 38812613, ++ 4187157, 88090564, 1053822973, 1057994817, 11532289, 1027563671, 1046481920, 1063240757, 17830893, ++ 1043297407, 1038091265, 1068487720, 26225623, 1059032166, 1027604480, 1073734681, 34619329, 1025100, ++ 1046497, 5239818, 1060094012, 17809456, 998, 10487800, 1063241777, 35643409, 5101, ++ 15735782, 1067439143, 52429808, 1066406900, 23080916, 1070587931, 71312334, 1055920123, 1065340972, ++ 1044494, 1037006973, 1045432323, 1067440163, 4193280, 1049594985, 1034944524, 1069540378, 8392690, ++ 1061134421, 1025506325, 1071639568, 12591075, 1029183, 986691584, 1073739782, 16789460, 13618216, ++ 1019172002, 1051642, 1069537317, 28304398, 1034907783, 4200431, 1069539358, 40895475, 1051691115, ++ 6300643, 1070589975, 55582679, 1068475470, 1073734678, 1070592016, 1046451300, 12568621, 1072688146, ++ 1071642632, 1054843988, 32498694, 1071641613, 1070596096, 1064285251, 52434910, 1069545480, 1071648759, ++ 1073726514, 74466226, 1067450370, 1071650799, 9426975, 97547140, 1066404861, 1072702439, 19917835, ++ 1028615307, 1065357304, 3139597, 29361142, 1042252916, 1064310770, 2093066, 39853024, 1054840924, ++ 3141632, 1073739783, 1054847050, 1069528131, 2097151, 1070595077, 1061141566, 10473510, 1071645695, ++ 1066401794, 1067436082, 26208261, 1067452415, 1063258111, 1072682021, 42997730, 1062209535, 1061161981, ++ 5235735, 60832700, 1058015232, 1058017275, 12578824, 79717269, 1053820929, 1054872569, 17826809, ++ 1038058612, 1047528448, 3141620, 25170921, 1048549473, 1046505, 2096117, 1064291376, 1059040333, ++ 2029, 2039, 1067439144, 1069531192, 1072698354, 1069550586, 1069538336, 8378400, 1065357303, ++ 1063259132, 1072686104, 19918851, 1056968701, 1056966656, 1044495, 33559526, 1049625603, 1050674179, ++ 4192261, 47200199, 1041235978, 1044382727, 6293500, 61888422, 1033894929, 1027597312, 9441266, ++ 1046453342, 1013921981, 1009727679, 1073734678, 1054846030, 1033852063, 1027559586, 1072688146, 1062190142, ++ 1054830720, 1046441094, 1071640591, 1070582828, 2068574, 1065322600, 1071641611, 5234713, 24096827, ++ 11511880, 1070594055, 13628418, 47174676, 32491558, 1069547523, 23073771, 71303147, 54520832, ++ 1068500991, 33566674, 95431615, 76551128, 1068502012, 44058552, 1023365284, 98581424, 2093052, ++ 1055896647, 1040148617, 1020220579, 1047548, 1060094011, 1056932975, 1035954315, 2045, 1065339950, ++ 1024082, 1050640499, 1069549566, 1070586913, 19905587, 1066375257, 1065355263, 2092050, 39836690, ++ 9417790, 1062208512, 7339009, 58721262, 26202144, 1058014211, 13636591, 79701961, 45083648, ++ 1050670081, 19933149, 1032809610, 61871071, 1005526231, 26228683, 1046446196, 80753596, 1028602040, ++ 1065339952, 1060083805, 1030713479, 1050629272, 1066390568, 1027141, 1043301491, 1073706103, 1068489759, ++ 15714348, 1055889503, 24088661, 1070589973, 31449104, 1067428938, 48215089, 1072690187, 47186929, ++ 7323700, 73390091, 0, 63971282, 20961307, 98566116, 3149813, 1041205360, 34598912, ++ 1016020153, 5250025, 1052743775, 48238565, 1034900638, 8399837, 1063234636, 62925769, 1054829699, ++ 1073734681, 1073724473, 1041206380, 1073710183, 1072687124, 11522084, 1050647644, 19898442, 1071640591, ++ 24111117, 1060088908, 39828523, 1070593034, 35652597, 1069530171, 60808203, 1069546501, 48241628, ++ 5229609, 82837482, 1067451392, 1050648663, 14671894, 1027562650, 1066404858, 1057992777, 25162752, ++ 1042247812, 1065358325, 1065335867, 34607083, 1057981550, 1064311792, 1073728556, 46146517, 1073715286, ++ 3140608, 7330843, 1052747856, 15708222, 2095103, 15724554, 1057993796, 32491557, 1023, ++ 24118263, 1064288312, 49274891, 1069549567, 32511973, 1070583852, 66060272, 1065355263, 1060092989, ++ 2087966, 1038056572, 1060111360, 1064290355, 9432080, 1049594986, 1055918080, 1068486697, 15726592, ++ 1061133400, 1049625600, 1072684062, 20974577, 1073720390, 1044381696, 3139603, 28318689, 12566578, ++ 1043432, 8385543, 1063241780, 25154590, 1048555, 12583930, 1065340972, 37742601, 4079, ++ 17830894, 1068488740, 51380212, 1069552628, 1068488739, 1070587932, 1048550494, 1061163002, 1069539357, ++ 1073735699, 1056942160, 1052772352, 1070588951, 3142666, 1065333827, 1045431303, 1071639569, 5241856, ++ 1073725493, 1038089230, 1072690187, 8391671, 8376358, 1008714752, 1047556, 11539438, 17817623, ++ 1004480716, 1050621, 1073734680, 27257863, 1024410798, 2100215, 1072687124, 36700151, 1044340879, ++ 2092041, 1072688145, 1059044416, 1065320559, 1045511, 1071641613, 1063240758, 12558413, 1073739782, ++ 1071642633, 1068485677, 35636264, 1071643652, 1070595077, 1073731619, 59762688, 1067450371, 1069547521, ++ 5234713, 82843605, 1065353218, 1068500989, 10480655, 108019625, 1063257089, 1068502010, 16774149, ++ 1014973617, 1061159936, 2092028, 20972539, 1031756951, 1044463, 2095100, 1068489761, 1048541308, ++ 1048560, 1020, 1070587932, 1066373217, 4084, 1071646717, 1072686103, 10464323, 1069551607, ++ 1067452414, 1073736722, 29346851, 1063260155, 1063257088, 2093069, 49277952, 1058016255, 1060111361, ++ 4192263, 69211100, 1051722756, 1055917060, 6290434, 90191798, 1046478858, 1046473728, 7341054, ++ 1025466517, 1000279271, 995036391, 2092035, 1039104127, 1024403653, 1017063624, 1045506, 1052740713, ++ 1048529059, 1039090856, 1047553, 1067425874, 1073703039, 1062167688, 1072693248, 8370233, 26184795, ++ 11501670, 1071644672, 24106014, 52408372, 35628099, 1069547520, 39841792, 79680523, 60802078, ++ 1068498944, 55579618, 106954721, 85978104, 1066400768, 72363971, 1010773192, 111154128, 992932094, ++ 1035960441, 1031750827, 1007628486, 1019154652, 1046450280, 1052729486, 1025460396, 1045377209, 1057988693, ++ 1073708143, 1045389457, 1072647318, 1068479555, 21993552, 1064269941, 25128051, 6277166, 44021806, ++ 9409625, 53448783, 17816600, 67098635, 30388283, 80719914, 30405632, 90177511, 50318363, ++ 109040643, 41947112, 1022315690, 72347643, 1005525211, 54536143, 1039098001, 92278746, 1027551422, ++ 1047501918, 1055881336, 1019170982, 1049578656, 1054845008, 1073713247, 1034904719, 1072653442, 1062189122, ++ 17803332, 1050638457, 21987428, 1069532211, 36684840, 1066373218, 45063237, 4183076, 55566347, ++ 8365131, 69187622, 11527187, 74448877, 24099890, 92263430, 19920896, 1032809611, 40883224, ++ 1017068728, 28315630, 1046445175, 57667581, 1035948191, 36708315, 1060081763, 74451938, 1054828679, ++ 1057994818, 1073718350, 1031763077, 1073709166, 1062192184, 14661688, 1043301491, 18846805, 1066388526, ++ 29346850, 1055888481, 37727291, 1070585892, 44033034, 1067426895, 56607778, 1041433, 58720242, ++ 6273084, 76535816, 6287373, 1043303533, 18860072, 1029660821, 10484736, 1052743773, 31448084, ++ 1044345985, 14683124, 1063233613, 45085695, 1059030125, 19929064, 1073723453, 56625129, 1073715289, ++ 1068487718, 10471468, 1044354148, 14657605, 1069538336, 22009883, 1052745815, 30391345, 1070588954, ++ 32500744, 1061137482, 46124060, 1071638548, 44040182, 1069530172, 60809223, 1072689166, 1053797455, ++ 4180013, 1041204338, 1073739783, 1060090947, 13621278, 1052742755, 0, 1067434040, 22012943, ++ 1063231571, 2100218, 1073728556, 31455231, 1028164, 3149812, 7329824, 39847920, 12565557, ++ 2091018, 14672915, 1055897668, 23055397, 1044488, 22016006, 1061142587, 34592790, 1046535, ++ 29360121, 1066387506, 47179782, 1072692229, 1064291377, 1071632424, 1052748879, 1069546499, 1067438121, ++ 3136542, 1060090948, 1066401794, 1070585890, 8381460, 1067434042, 1064305665, 1073733659, 13627402, ++ 2082863, 1062208512, 4188179, 18872320, 9425956, 1060111360, 7335947, 24119286, 16768025, ++ 1042414, 11532292, 1068488740, 25158670, 1046511, 13632508, 1069538335, 33550339, 2034, ++ 1073736722, 1071637530, 1064292396, 1071648757, 1073737743, 1072687124, 1068487718, 1066405881, 1073737740, ++ 1043471, 1072684064, 1061161981, 1073738761, 3142666, 3137561, 1054868482, 1073739782, 5240837, ++ 7333907, 1049624583, 1047556, 7339008, 11529228, 1031788544, 1, 8390652, 15725574, ++ 988740855, 0, 2091012, 19920896, 1012865238, 1044468, 1044482, 2094090, 1036990644, ++ 1047540, 1046529, 3143688, 1061116049, 1013, 1, 3143685, 12548205, 1072697336, ++ 1072693248, 4193283, 38771784, 1069550585, 1070596096, 4193281, 66043936, 1066404860, 1069547520, ++ 4195327, 93318134, 1063258111, 1067450369, 5243902, 120591308, 1060110339, 1065352192, 6292478, ++ 1001331927, 986636560, 979296528, 0, 1021262010, 1014956267, 1006567661, 0, 1042240668, ++ 1043275974, 1032790219, 0, 1063219326, 1072644257, 1059012776, 0, 10456160, 27223163, ++ 12541061, 0, 32483391, 56592468, 38763617, 0, 55560221, 87010347, 67084348, ++ 0, 78638073, 118476802, 95404054, 0, 101715925, 999228653, 123725808, 0, ++ 1012875446, 1023353037, 993986794, 0, 1030706333, 1047477421, 1016014028, 0, 1047489669, ++ 1072650380, 1039088815, 0, 1065321580, 24082540, 1061116049, 0, 9411666, 49255498, ++ 10450035, 0, 27243574, 74429480, 33525845, 0, 46125082, 100652037, 56601654, ++ 0, 65007612, 1010772169, 80726038, 0, 82840542, 1031749806, 104851446, 0, ++ 1025466517, 1052727443, 1007628484, 0, 1039103105, 1072656504, 1026508971, 0, 1052739693, ++ 19893340, 1045388435, 0, 1066375257, 40870976, 1064268922, 0, 7318595, 62897188, ++ 9406561, 0, 22004781, 83875847, 28287048, 0, 36689942, 1023365286, 47167535, ++ 0, 51377150, 1040147600, 67096597, 0, 65014758, 1056929914, 85977083, 0, ++ 1038058613, 1073712228, 1022318750, 0, 1048547429, 16752717, 1037002891, 0, 1057988693, ++ 33535030, 1051688055, 0, 1068478533, 51365919, 1066372195, 0, 5226549, 68148232, ++ 7315535, 0, 15716387, 1034908803, 23048251, 0, 27254801, 1048544370, 37733414, ++ 0, 37746687, 1061131360, 53467154, 0, 48236524, 1073718351, 69200893, 0, ++ 1050649684, 13612093, 1035960441, 0, 1056944201, 27247659, 1046449258, 0, 1063238718, ++ 39834649, 1057987675, 0, 1070581810, 53470215, 1068476492, 0, 3133478, 1047500896, ++ 6272061, 0, 10477593, 1055892563, 17810477, 0, 17820685, 1065332807, 29348893, ++ 0, 25163776, 1031226, 40886286, 0, 31459315, 10471468, 52425726, 0, ++ 1062193204, 19911711, 1049601108, 0, 1065340973, 30400530, 1056944202, 0, 1068487718, ++ 39840772, 1064286271, 0, 1072684062, 1059044414, 1071629364, 0, 2090007, 1064289333, ++ 5229609, 0, 5237775, 1070582829, 13621279, 0, 9434119, 2085924, 20963348, ++ 0, 12581888, 8379419, 29355017, 0, 15730681, 14672915, 36698110, 0, ++ 1073735700, 19917834, 1063242800, 0, 1073736721, 26211330, 1066390569, 0, 1073737742, ++ 1070587931, 1070585891, 0, 1073738763, 1072686103, 1040412, 0, 1073739784, 1043474, ++ 5235734, 0, 1073740805, 3141646, 9432079, 0, 1047554, 5239818, 13627401, ++ 0, 0, 8386566, 17822723, 0, 1023, 10483714, 22020093, 0, ++ 1042420, 13631487, 2093067, 0, 1045492, 1044473, 3142665, 0, 1048565, ++ 1045496, 3143687, 0, 3062, 1047543, 3144708, 0, 1071647736, 1048567, ++ 4193282, 0, 1068502011, 1015, 4194304, 0, 1064307710, 1072694264, 4195327, ++ 0, 1061159937, 1072694265, 5243902, 0, 1054863360, 1072694268, 6292477, 0, ++ 972999971, 0, 0, 0, 1001320701, 0, 0, 0, 1029640408, ++ 0, 0, 0, 1057960115, 0, 0, 0, 12539022, 0, ++ 0, 0, 41907303, 0, 0, 0, 72325184, 0, 0, ++ 0, 102744086, 0, 0, 0, 133162989, 0, 0, 0, ++ 986641661, 0, 0, 0, 1010766045, 0, 0, 0, 1035940029, ++ 0, 0, 0, 1060064413, 0, 0, 0, 11495548, 0, ++ 0, 0, 36669531, 0, 0, 0, 61842489, 0, 0, ++ 0, 88065046, 0, 0, 0, 114288627, 0, 0, 0, ++ 1001331927, 0, 0, 0, 1021260988, 0, 0, 0, 1042238625, ++ 0, 0, 0, 1062167686, 0, 0, 0, 9404522, 0, ++ 0, 0, 30382159, 0, 0, 0, 52408370, 0, 0, ++ 0, 73387030, 0, 0, 0, 95414265, 0, 0, 0, ++ 1014973617, 0, 0, 0, 1031755931, 0, 0, 0, 1048538245, ++ 0, 0, 0, 1065320559, 0, 0, 0, 8361048, 0, ++ 0, 0, 25143362, 0, 0, 0, 42974251, 0, 0, ++ 0, 59757587, 0, 0, 0, 77589500, 0, 0, 0, ++ 1028615308, 0, 0, 0, 1042250874, 0, 0, 0, 1054837865, ++ 0, 0, 0, 1067424856, 0, 0, 0, 7318598, 0, ++ 0, 0, 19905588, 0, 0, 0, 33541154, 0, 0, ++ 0, 47176720, 0, 0, 0, 60813310, 0, 0, 0, ++ 1042256999, 0, 0, 0, 1051697242, 0, 0, 0, 1061136461, ++ 0, 0, 0, 1070576704, 0, 0, 0, 6275123, 0, ++ 0, 0, 15715366, 0, 0, 0, 25155609, 0, 0, ++ 0, 34595851, 0, 0, 0, 45085694, 0, 0, 0, ++ 1055897666, 0, 0, 0, 1062191161, 0, 0, 0, 1067436081, ++ 0, 0, 0, 1072681000, 0, 0, 0, 5232672, 0, ++ 0, 0, 11526167, 0, 0, 0, 16771086, 0, 0, ++ 0, 23064582, 0, 0, 0, 29359102, 0, 0, 0, ++ 1069539358, 0, 0, 0, 1071637529, 0, 0, 0, 1073735701, ++ 0, 0, 0, 2092048, 0, 0, 0, 4190220, 0, ++ 0, 0, 7336968, 0, 0, 0, 9435140, 0, 0, ++ 0, 12581889, 0, 0, 0, 14680061, 0, 0, 0, ++ 1043449, 0, 0, 0, 1044472, 0, 0, 0, 1046519, ++ 0, 0, 0, 1047543, 0, 0, 0, 1015, 0, ++ 0, 0, 1015, 0, 0, 0, 1072694264, 0, 0, ++ 0, 1072694266, 0, 0, 0, 0, 0, 0, 0, ++ 1071640590, 1072693248, 1071640590, 0, 2102258, 5252067, 3150834, 5252066, 9451474, ++ 12602303, 9451473, 12603325, 16802731, 21003158, 16803752, 21004176, 25204605, 31504223, ++ 25206646, 29408090, 36755264, 43054884, 33609537, 37810987, 48305929, 54604528, 42010392, ++ 45161222, 60903125, 67202746, 49360628, 53561056, 74549918, 0, 58810058, 1049599, ++ 1072689166, 6301665, 1073737741, 6301665, 3150834, 12603323, 3150833, 11555770, 8403919, ++ 19957644, 8403919, 17860492, 15756197, 27311960, 14707620, 24165215, 24159089, 32565044, ++ 21012341, 26270529, 30463812, 35717917, 25217870, 27324210, 34666278, 40967940, 27322168, ++ 28376866, 37818131, 2098174, 27325228, 4196347, 43070195, 6301664, 29428504, 6301662, ++ 2094091, 10507195, 4191240, 9457596, 4200431, 15762321, 5249005, 12614552, 8403918, ++ 18919275, 7355342, 13672312, 13658022, 19974994, 11560874, 12629860, 17864573, 17881926, ++ 13668231, 9487194, 19971933, 16835389, 13676397, 6343508, 18928459, 5245944, 11583326, ++ 7344116, 17882946, 6302685, 8439639, 6302684, 16837431, 7360446, 4247378, 6310850, ++ 6289412, 8418208, 8388607, 5269417, 6298603, 8425351, 7347176, 2129813, 7355342, ++ 5284726, 6306767, 1071682441, 8413103, 1093486, 5266357, 1066441602, 8422290, 1069594474, ++ 4224926, 1060152191, 7379837, 8393711, 1084302, 10491882, 3189617, 6302682, 1069586309, ++ 6302682, 1072739180, 4212678, 1063296896, 3163082, 1067497321, 1073075, 1057006463, 1071666109, ++ 10487802, 1070625700, 11537395, 1065378738, 7348197, 1064337306, 8397794, 1058041772, 5257168, ++ 1058047894, 4208594, 1049654185, 3167164, 1049660308, 1067971, 1040218024, 1072719787, 10492902, ++ 1068522423, 10493921, 1067482014, 6302681, 1061185454, 5254105, 1061192599, 1063887, 1053848490, ++ 14292, 1053854613, 1067469766, 1045460904, 1064320976, 1046515604, 1060131776, 1036024744, 1053837262, ++ 13636588, 1050696637, 13637605, 1043352525, 8397791, 1041260476, 8398813, 1032867791, 3158996, ++ 1030775741, 3158998, 1021333457, 1071662026, 10494940, 1068514258, 8398807, 1064325059, 4205529, ++ 1059079118, 3156954, 1054889918, 1071657945, 1048594381, 1069558750, 1045454780, 1060124633, 1038109646, ++ 1056975843, 1036018620, 1048590299, 1026576336, 1043344360, 1025533885, 1037056990, 1015042002, 1029712878, ++ 12591070, 1024474081, 10494935, 1016080372, 7350234, 1011891173, 6301656, 1001400314, 2109401, ++ 6302675, 1059804, 3156942, 1066415065, 2108378, 1063267296, 1058778, 1054881754, 1068509155, ++ 1049635813, 1066410984, 1042299868, 1052779500, 1036004331, 1049631733, 1030765535, 1038098421, 1022371825, ++ 1032851457, 1018182627, 1022368766, 1008740343, 1016072205, 1005599719, 1007686662, 995108861, 999292952, ++ 8399825, 981470210, 4206538, 955248644, 4205526, 12234, 2108372, 1068492821, 10207, ++ 10203, 10210, 1072694271, 1060120552, 1064311790, 1058021359, 5251046, 1045438448, 1045434366, ++ 1041242107, 12600261, 1030757369, 1027604494, 1024461831, 23100308, 1015026690, 1009776669, 1007682579, ++ 34648930, 993004547, 991947819, 991951902, 46194487, 969934848, 974119992, 940567552, 56691472, ++ 13252, 1067444248, 1065344034, 1070590995, 11218, 1072693248, 1071641611, 0, 9189, ++ 4201449, 2102259, 5253089, 1054873590, 11549645, 8400855, 11554748, 1035995142, 24146842, ++ 17850286, 18907026, 1019214870, 39892829, 29398906, 25207665, 1001386020, 53538599, 40946508, ++ 30457686, 982509617, 67183351, 51443491, 35707710, 910152704, 1069542420, 61939452, 1073738764, ++ 1064294436, 2046, 1068490781, 1051641, 1070593036, 5252067, 1072691208, 4205534, 2101237, ++ 12602303, 2103280, 8409022, 8399836, 22052753, 8402896, 11562913, 16798647, 30452584, ++ 15755175, 13667209, 31496058, 37801799, 22057857, 14720887, 47240001, 46199591, 28357475, ++ 15774568, 60885775, 1071640592, 33607498, 3143684, 74529504, 1050619, 38857521, 2102259, ++ 1066392607, 5253087, 1072687125, 3156958, 1071641609, 10506172, 1047555, 3163079, 2102257, ++ 15759256, 3151853, 3170227, 8401875, 19961724, 6306766, 1077155, 17851304, 23113575, ++ 10510255, 1072725911, 26253179, 25216851, 12615572, 1070631822, 34651991, 1045513, 14718847, ++ 6293498, 42001207, 2101238, 14723951, 3151853, 50397975, 4205534, 15776608, 1059807, ++ 1069540377, 6310850, 3141645, 1071659986, 1073739782, 7366570, 2099196, 1067469767, 3151854, ++ 7372694, 3153897, 1062229950, 7355342, 7376775, 3160018, 1056989111, 13657002, 6332283, ++ 3167165, 1051748274, 17861513, 5241856, 2123691, 7344111, 21014385, 3150831, 30621, ++ 3152872, 24165213, 2108382, 1071679378, 1072703459, 27317065, 16332, 1068536713, 1065365470, ++ 1043473, 1071666109, 8386561, 1058027482, 1048576, 1068524465, 5246963, 1049639896, 3152875, ++ 1065381799, 2105318, 1041252310, 5258192, 1061190560, 1072706521, 1032864726, 7363509, 7343093, ++ 1069564876, 7345123, 7369631, 4201450, 1065373634, 3152868, 7374734, 10209, 1060133818, ++ 1070605287, 6330241, 1068512216, 1053844405, 1059070954, 5285749, 1062223825, 1048603568, 1048585197, ++ 6288391, 1055934411, 9439219, 1037050865, 4197368, 1049644999, 5247979, 1025516533, 2105319, ++ 1042307012, 1056741, 1013982201, 1062869, 7345129, 1069558752, 3152855, 1072712644, 3152870, ++ 1061172188, 1056737, 1070619575, 1071653861, 1053834201, 1067458540, 1066429356, 1062217700, 1045446615, ++ 1052776438, 1063286692, 1052781540, 1037059030, 1039141888, 1058045853, 1043345380, 1028671446, 1024460810, ++ 9438202, 1033909222, 8392675, 1009778708, 5247983, 1023423464, 5248995, 973072388, 2105317, ++ 5248989, 1056742, 1060097074, 1071656924, 2105314, 1064313832, 1066393628, 1065368532, 1068507113, ++ 1053828075, 1073739783, 1059079118, 1055924208, 1042293743, 7346156, 1052789705, 1043340279, 1031807987, ++ 18891716, 1045451717, 1030756350, 1020273655, 33585045, 1038113731, 1018171396, 1008739324, 47228775, ++ 9440235, 996148225, 4200404, 60871485, 5248999, 8146, 2104284, 1063244841, 1056741, ++ 8159, 8166, 1068492823, 1067460580, 1066408942, 1060117489, 1, 1058024420, 1050678268, ++ 1046483963, 7348197, 1048588260, 1033896969, 1031801861, 15747011, 1038102501, 1019214870, 1017119759, ++ 24144799, 1028666343, 1003484195, 1002438680, 33592189, 1018180585, 986703919, 959438848, 43037533, ++ 6296540, 1057998902, 1055899708, 1067441184, 3152863, 1065344032, 1063245863, 1071640591, 8166, ++ 1072690187, 1070590994, 0, 1062215660, 7345136, 3147771, 5252066, 1049631731, 20988869, ++ 12594137, 10503111, 1037047802, 37780368, 26237868, 14704557, 1024462849, 54570845, 39882622, ++ 19954581, 1005586434, 70312749, 54574930, 24155006, 985661440, 1061146670, 68217640, 1071638550, ++ 7117, 1067443225, 1060096050, 1073739784, 8152, 1047556, 1066392608, 4087, 8167, ++ 7347176, 1071641612, 1057764, 1058019317, 17844163, 3149812, 3161040, 1042286595, 29389722, ++ 11547604, 4214718, 1026555920, 40934258, 19946417, 5268397, 1010825245, 52478797, 29392782, ++ 6322078, 995093545, 1065343012, 38839149, 3141642, 931119104, 1069542419, 47236941, 1049599, ++ 1053801537, 1023, 1065341992, 1072698355, 1062196267, 6300643, 1069541399, 1071653863, 1069541398, ++ 12601284, 1072691207, 1069559771, 2098175, 19949478, 2103280, 1067466704, 13641692, 27297673, ++ 7353301, 1064324038, 28336043, 33596269, 12604346, 1062229949, 46176118, 1069540379, 17854369, ++ 6291453, 61918020, 1072690188, 22054793, 2100215, 78707477, 3066, 27304818, 1071650801, ++ 1057997879, 3154915, 1071636509, 1066409964, 1064294436, 6307787, 1072689167, 1061169127, 1071640591, ++ 9459637, 1072693248, 1055928290, 3148791, 12611489, 1054702, 1049637854, 11546582, 15762318, ++ 2109402, 1044397019, 23092142, 1043472, 4212679, 5244911, 34637702, 1047555, 5266357, ++ 2101231, 46182239, 4085, 6319013, 1070602224, 57726779, 9189, 6324118, 1062214641, ++ 1063243821, 14293, 3140624, 1052777459, 1067442204, 1072711623, 2095109, 1044388853, 1072690186, ++ 1071667129, 3065, 1034951671, 3150834, 1070622637, 1071651821, 1026564089, 9450452, 4192260, ++ 1070607329, 2100192, 16799669, 1050619, 1068513237, 1053671, 23099287, 1072698354, 1066420171, ++ 1069553647, 30447483, 1068507113, 1063277505, 1056969719, 36746080, 1065364449, 1061183416, 1045434367, ++ 1068488739, 1061173209, 7336960, 1032849415, 1070590995, 1056980946, 3146746, 1020265487, 1073740803, ++ 1052789708, 4084, 989848579, 2103279, 5243894, 1069554670, 1049602131, 5256151, 2101235, ++ 1064313833, 1059044413, 8408000, 1070602224, 1059072996, 1068487718, 11559851, 1064311790, 1052782560, ++ 5237771, 13663127, 1056972781, 1047541725, 17831913, 16813956, 1049633771, 1041252313, 33571776, ++ 1041431, 1042294763, 7340015, 50360212, 1045514, 1034955754, 3148783, 67149672, 2044, ++ 4196327, 6127, 1054848069, 7149, 2102251, 1066407920, 1062193202, 11229, 1069553647, ++ 1058020338, 1069539358, 1072709582, 1059067892, 1048583156, 4192261, 1072713664, 1049630713, 1040194550, ++ 13638632, 1071669171, 1038095358, 1030758392, 25182150, 1070624679, 1027608579, 1021321210, 37774242, ++ 5238792, 1010828289, 3147742, 50367359, 3145727, 4057, 2101219, 1060095031, 4087, ++ 6115, 7147, 1065341991, 1070603246, 1068506095, 1063262195, 1070589974, 1067460581, 1054872570, ++ 1050678267, 3144705, 1063268317, 1041238021, 1039141891, 9444328, 1059077077, 1027604496, 1026556939, ++ 16791501, 1054884815, 1013970971, 1015021587, 25188274, 1050693577, 1000337446, 979360768, 33584023, ++ 8388600, 1046454361, 1044356189, 1065341994, 4196340, 1056946242, 1053799496, 1068490780, 5106, ++ 1067438123, 1063241778, 1071640590, 1067457519, 5236750, 1073733658, 0, 1061167085, 18880490, ++ 10486780, 4201450, 1053828076, 37766077, 25177045, 8401878, 1046489067, 56653708, 41966506, ++ 11552707, 1039150058, 75540316, 58754942, 15752111, 1031811050, 1051701324, 75544402, 1071636507, ++ 5243879, 1060095031, 1050651726, 1071639569, 3149801, 1069537314, 1057996859, 1071642630, 6125, ++ 5238792, 1066390568, 1071647739, 1064310770, 15734761, 1073736723, 1071651822, 1053825014, 29376451, ++ 8391672, 1071654881, 1044386811, 44067739, 19934167, 1072707540, 1032851456, 58758003, 31477684, ++ 1072711624, 1018169345, 1056947262, 44070800, 3141643, 1003486208, 1064292396, 56662893, 1046533, ++ 3029, 1070588954, 1056947263, 1070598143, 5085, 4192259, 1063242799, 1067454457, 7145, ++ 11541480, 1068489759, 1065359347, 1061165044, 20986826, 1073737740, 1062215660, 1047531519, 31481770, ++ 6295541, 1059071974, 1033896970, 41975691, 13642715, 1055928289, 1021312022, 1063242800, 20989888, ++ 4193274, 1007678497, 1067441186, 29385636, 1050617, 953137152, 1071639570, 37782409, 1070599161, ++ 1041208421, 1049599, 1064291376, 1064308728, 1051700302, 7347177, 1067440163, 1058018296, 1062192183, ++ 12597202, 1070589973, 1051726840, 1072684062, 18894778, 1073739782, 1045436409, 11535358, 25192355, ++ 2101236, 1038096377, 28322772, 1068488739, 6301664, 3145705, 47210405, 1070589975, 10501069, ++ 1051629, 66097012, 1071641610, 13652921, 1070601203, 84984644, 1072695292, 17852325, 1061164024, ++ 1047503958, 1055724, 1071635488, 1050677246, 1055897666, 3157980, 1071638550, 1041238020, 1065340973, ++ 5259212, 1071641612, 1031799819, 1073735702, 7361468, 1070596097, 1007674370, 9439225, 1042452, ++ 1071649780, 1037009015, 23079894, 1072690187, 1071652840, 1050646623, 36722607, 1071643651, 1071656923, ++ 1063235654, 51412871, 1069550586, 1072709582, 3132458, 66103135, 1068505072, 1072713666, 18868232, ++ 1053799495, 1067459559, 3139598, 35657700, 1061144629, 1065365469, 2094088, 54542266, 1067440164, ++ 1064319956, 1073740802, 74476431, 1073737743, 4191235, 1069550588, 1044354149, 7343094, 1049599, ++ 1066406902, 1054845008, 16788441, 1070599164, 1063263216, 1065335867, 26233786, 1066405880, 1060119529, ++ 3134499, 36728730, 1061164021, 1056975844, 14674949, 47222651, 1056971762, 1053832158, 28317671, ++ 1060095032, 1051729904, 6289403, 43006916, 1065341993, 1046488045, 3145722, 57696160, 1069540378, ++ 4194289, 3065, 1051699282, 1073738761, 1051635, 1067454456, 1059043393, 4198388, 1070600182, ++ 1061164024, 1067437103, 9447389, 1062211576, 1054872568, 2088987, 15745990, 1054871547, 1048582136, ++ 10482691, 22043567, 1046482942, 1041242105, 19929066, 27292567, 1038093314, 1034951673, 31470541, ++ 1067439145, 1025507329, 3144679, 41964465, 1069539357, 992, 1050603, 1057995840, 1070590993, ++ 4071, 5104, 1063241778, 1072692227, 1070602224, 1065358325, 1068488740, 5108, 1059066872, ++ 1055920123, 1042452, 2106340, 1047529473, 1046480897, 6290433, 4208596, 1035994122, 1035994119, ++ 11539437, 6309828, 1025506324, 1026555918, 18885592, 8412084, 1013969950, 998234112, 26231746, ++ 1041432, 1033861248, 1030714499, 1065339949, 1073737743, 1047498855, 1043303531, 1067440163, 1072691207, ++ 1062186060, 1056941139, 1069540376, 1070598142, 4180014, 1070579769, 1072690188, 1068504053, 20964361, ++ 11525146, 0, 1067458539, 39852002, 27263991, 3150833, 1066413026, 60834742, 45099983, ++ 6300643, 1064317913, 81818503, 65034149, 9450453, 1063272400, 1041206382, 83919738, 1072686106, ++ 5238789, 1052745816, 1039109231, 1071639571, 3143681, 1064286272, 1049600090, 1070593037, 1072695294, ++ 3133478, 1060090950, 1070595078, 1068502010, 16772103, 1070581807, 1068500990, 1064309751, 32511973, ++ 9430037, 1067454455, 1059067892, 49299391, 20973559, 1067457519, 1053826033, 66086807, 35661781, ++ 1066410983, 1049633774, 1047501915, 50351026, 3141638, 1044391916, 1056944201, 66089869, 1046532, ++ 5240817, 1066386485, 1047502939, 1070596098, 2098162, 2087967, 1054847050, 1066402816, 4085, ++ 12578820, 1063239736, 1063259134, 1066405879, 24123368, 1071633446, 1059065852, 1059065849, 36714440, ++ 6286352, 1054871547, 1050677245, 50354088, 15730679, 1050678266, 1042287616, 1054847049, 26223580, ++ 2095089, 1031799809, 1061142586, 36717503, 1050611, 1020263424, 1068486698, 47210402, 1071648759, ++ 1047518, 1041431, 1055896647, 1064308730, 2019, 8386562, 1061142585, 1056967678, 6123, ++ 16783339, 1066389547, 1049626626, 1064309748, 25178067, 1071636508, 1042285575, 1053822972, 33573817, ++ 3142667, 1024452610, 1042285574, 1062192183, 8391671, 1025464477, 1030750223, 1065340971, 15736803, ++ 1041199234, 1019213849, 1069539358, 22034381, 1057983591, 975157248, 1073736720, 29380536, 2074697, ++ 1026518157, 3145728, 1064290354, 20957224, 1041204340, 7345135, 1066390568, 40888322, 1054841946, ++ 12593117, 1068490782, 60823517, 1069529149, 17841100, 1071639570, 82853811, 12572701, 1068488740, ++ 1073739782, 1033859206, 30409719, 1069539355, 2100217, 1047496815, 50343884, 1070590994, 5250026, ++ 1061133400, 71326623, 1071642633, 7351260, 2077758, 93358960, 1071646719, 10501069, 16764962, ++ 1034911865, 1072698356, 1072685085, 32500738, 1046451299, 8169, 1071638551, 49288162, 1057991756, ++ 1059806, 1071640592, 67123135, 1070580788, 2092048, 1070594057, 1042253935, 10477592, 1073738764, ++ 1068498946, 1052744796, 24118263, 1071642631, 1068502010, 1063235656, 40905682, 1068498947, 1067456499, ++ 1033267, 57693099, 1065355262, 1067458539, 12572700, 74480515, 1063260153, 1066412003, 25161730, ++ 1043305573, 1061165045, 4189191, 37753831, 1052747858, 1059068912, 2094084, 51392458, 1061141567, ++ 3143675, 1073740803, 1050648664, 1071632426, 1049595, 1068498945, 1057992777, 8382483, 1071646716, ++ 1065355263, 1065336889, 18876407, 1065356285, 1061161981, 1073729576, 30418904, 1060113406, 1056968700, ++ 8381462, 44058552, 1053821951, 1052775418, 16774145, 56650648, 1048578049, 1048581113, 26218476, ++ 1051699281, 1040188416, 3141616, 35661782, 1057994817, 1046502, 2097138, 1059043392, 1064290354, ++ 2027, 3061, 1063240757, 1071635489, 1071650801, 1068503032, 1068486697, 5238797, 1063261175, ++ 1061161980, 1072685085, 12584951, 1053822974, 1052772352, 4189199, 20980703, 1044382725, 1045431301, ++ 9436161, 29375430, 1035993101, 1038091274, 13635570, 38819757, 1027602453, 1018159104, 19931106, ++ 1060092989, 1020218537, 1017072810, 1067439145, 1063242801, 1039100044, 1032807568, 1068489761, 1067440164, ++ 1056932974, 1049591925, 1070588954, 1071637527, 2073678, 1067424856, 1071639570, 2094088, 23053355, ++ 11515961, 1073738761, 5245944, 45081603, 31447062, 0, 10493926, 67114970, 50332657, ++ 2100215, 14692308, 90194862, 72362952, 4200431, 19940291, 1029661842, 93344670, 1043473, ++ 1068487720, 1044348025, 1026516113, 1073737742, 1069538336, 1060082783, 1040153723, 1071641610, 1069541399, ++ 2076740, 1053790307, 1070594055, 1070592014, 18861093, 1068476491, 1067450372, 1071643652, 36694018, ++ 9421873, 1065354240, 1071647737, 55579615, 25157651, 1064307710, 1072699374, 74464185, 40895475, ++ 1062211579, 1057763, 1038056570, 57681872, 2094072, 2110424, 1049596005, 75515821, 2097145, ++ 2091026, 1062184016, 1037009016, 1072696315, 1044494, 1031225, 1047499877, 1067453436, 1072690185, ++ 14668831, 1057989714, 1063259134, 1070595077, 29355010, 1069529150, 1058014209, 1066402816, 44045284, ++ 7327784, 1052771332, 1064307708, 58733509, 18868240, 1042280449, 1062212599, 1046451299, 31458293, ++ 1011822788, 1060116467, 1054843986, 44048345, 1032801446, 1058021358, 1064286273, 57687996, 1053780104, ++ 4190203, 1034286, 1046452319, 1016936, 2096123, 10477593, 1053796432, 23045190, 2044, ++ 20968449, 1062189121, 46123042, 1068502012, 31462378, 1069533233, 69201916, 1063259133, 43002832, ++ 4184095, 92279764, 1056967678, 1054846028, 13626380, 1022315688, 1050675200, 1061141567, 20973559, ++ 1039099022, 1044382720, 1067436081, 30415841, 1056930932, 1035993088, 1073731619, 39859147, 1021017, ++ 1044453, 6285331, 1055896646, 18853949, 1048552, 13629441, 1061142587, 37736478, 4078, ++ 19927023, 1065339951, 57667582, 1067455476, 27272156, 1070585891, 76550108, 1059065850, 1063241781, ++ 2090006, 1031761036, 1049626625, 1066389547, 6288392, 1045396599, 1040188425, 1069538338, 11536377, ++ 1060082785, 1031797777, 1072686103, 16783338, 1073719371, 998227968, 2093068, 23078875, 14662707, ++ 1011826871, 5241856, 1066389548, 30398490, 1029658779, 8392693, 1067440165, 46134271, 1047491709, ++ 11541480, 1069539358, 60821475, 1066374238, 1071636509, 1070589974, 1042253936, 12563517, 1071637528, ++ 1072689166, 1052743775, 33544216, 1070590994, 1073740805, 1063233614, 55575535, 1070593036, 1050620, ++ 1073723452, 78654404, 1070594054, 3150835, 11521065, 102782871, 1069547520, 5250026, 23060501, ++ 1021270174, 1069550586, 2091026, 34599936, 1037004933, 1070601205, 1043471, 45091818, 1051691116, ++ 2092037, 1072690188, 1051698260, 1067425874, 1046531, 1071642633, 1059041351, 10468405, 1072692227, ++ 1069546501, 1066384442, 28302357, 1068498946, 1066401794, 1073728557, 46138354, 1065354241, 1065355263, ++ 7329823, 65021900, 1062208513, 1063259132, 14673936, 84955046, 1058014209, 1062211578, 23066624, ++ 1031763077, 1053819904, 2092024, 30411760, 1043302512, 1045484, 2095096, 1061143608, 1055890523, ++ 1007, 2042, 1065339951, 1068478533, 5107, 1070599163, 1069536295, 8374316, 1067454455, ++ 1065356285, 1072684062, 22012945, 1060114428, 1060111360, 3139604, 35652596, 1053820929, 1054868482, ++ 7335946, 51389396, 1046478855, 1049625606, 11533312, 67126196, 1040186381, 1037035520, 15730679, ++ 1041206380, 1007624402, 1002381523, 1071636508, 1050647643, 1029651634, 1022311605, 1071637527, 1060089930, ++ 1051679889, 1043290263, 1072688147, 1069531191, 1014895, 1064268920, 1072689166, 5231652, 25140299, ++ 11506775, 1073738762, 15722510, 49267748, 34583605, 1073740805, 26215414, 75492347, 57661455, ++ 0, 37756893, 100668368, 81788904, 1050621, 49297347, 1017068726, 104867776, 2093055, ++ 1051699283, 1035950234, 1013924021, 1047551, 1057993797, 1054830718, 1030707355, 1023, 1064288312, ++ 1018977, 1047490690, 1071646719, 1070583850, 20950081, 1065322599, 1068500991, 3137563, 41928736, ++ 9413707, 1065354240, 10481674, 63959037, 28295214, 1063257089, 15730680, 84939736, 47176718, ++ 1059059712, 24124390, 1027562650, 67108845, 999228651, 31468499, 1042247811, 87039947, 1023354058, ++ 1061142585, 1057982571, 1025466518, 1048527017, 1064291376, 1073717330, 1039103105, 1072652423, 1067439143, ++ 16758840, 1052739692, 25133156, 1070587933, 34591772, 1066376278, 50307136, 1073736722, 51377150, ++ 7320639, 77579290, 3143687, 68161504, 23054375, 103803891, 6293499, 1037006974, 37741580, ++ 1010772170, 10490862, 1049594987, 53477361, 1031749806, 13639650, 1061133400, 68164565, 1052728465, ++ 1071635488, 1073721411, 1037009016, 1073706101, 1071637530, 12567598, 1047498855, 20942935, 1071638549, ++ 26205207, 1057988695, 42970168, 1070592015, 39842815, 1068478533, 64998425, 1070594057, 52431847, ++ 5227571, 87026680, 1070595075, 1046452322, 16765983, 1022315689, 1069549565, 1055892563, 28305418, ++ 1039098002, 1070600184, 1064285252, 38798325, 1055880314, 1070602226, 1073726516, 51386335, 1073712226, ++ 3139589, 9425956, 1048551514, 16753738, 2094084, 18867218, 1054846030, 34584624, 1047555, ++ 28308480, 1062189121, 53465110, 1070596098, 37751789, 1069532212, 71299068, 1066401793, 1056945222, ++ 3134502, 1033858184, 1063257089, 1062191163, 11526167, 1046446198, 1060111361, 1067436080, 18870280, ++ 1060081763, 1055917056, 1073730597, 26215416, 1073717327, 1051722752, 5234713, 34608104, 13612092, ++ 1043435, 11529229, 1060094012, 27248679, 1047533, 17823744, 1063241780, 41933843, 3056, ++ 23071731, 1067438123, 55570430, 1070601205, 1066389546, 1071634466, 1044353128, 1064308729, 1068488739, ++ 1041433, 1054841945, 1056967678, 1070587933, 5237775, 1064283211, 1049625604, 1072687126, 9435141, ++ 1073723452, 1043333130, 1044495, 13632507, 10471469, 1020251136, 4191240, 17829874, 20960286, ++ 996085986, 6290432, 1070586910, 31450126, 1018114242, 8390650, 1071637530, 41940991, 1040141474, ++ 1043470, 1071638549, 1055896647, 1063218304, 1045515, 1072688145, 1062190141, 12553309, 1073738761, ++ 1072690188, 1068483635, 36679736, 1072691207, 1073739783, 1036329, 62903312, 1071643652, 1047555, ++ 7329823, 88080358, 1069547523, 1023, 13624340, 114305979, 1068498945, 1050619, 20966409, ++ 1007628484, 1067451392, 2091008, 27261951, 1026509992, 1044465, 2094079, 1066390567, 1045390476, ++ 1047538, 1048575, 1069538337, 1064271983, 3061, 1072694271, 1072685083, 10460241, 1071648759, ++ 1069549567, 1042453, 31438897, 1066404858, 1067451392, 4189200, 52419599, 1062210558, 1064305665, ++ 7335946, 74448875, 1058014210, 1062208514, 10483716, 95429574, 1052770310, 1055912960, 13631487, ++ 1019170981, 993981691, 987691259, 1043463, 1034905742, 1020204248, 1011815642, 1044485, 1050639479, ++ 1046426804, 1035941049, 1046531, 1066374239, 1072649360, 1061114008, 1047553, 8367173, 26179691, ++ 11497590, 1047552, 25150506, 54500420, 37720146, 0, 42983437, 82821147, 63942701, ++ 1023, 60817391, 112192497, 90166279, 0, 77602768, 1005525210, 117439456, 0, ++ 1030713479, 1027552444, 1000283352, 0, 1043300468, 1050628253, 1021260988, 0, 1054839905, ++ 1073704062, 1042239648, 0, 1067427918, 23038046, 1063217283, 0, 6274105, 47163452, ++ 10454118, 0, 19910691, 71288858, 31432776, 0, 33548299, 95415286, 53460009, ++ 0, 47185907, 1017067706, 76535816, 0, 59774938, 1034899616, 98565096, 0, ++ 1042255977, 1053780102, 1013924021, 0, 1051696219, 1073709163, 1030706333, 0, 1060088908, ++ 18847824, 1047489670, 0, 1069530172, 38777908, 1065320558, 0, 4181036, 58706967, ++ 8362070, 0, 13622299, 79686650, 26192957, 0, 24112137, 1027562649, 44024867, ++ 0, 32506871, 1043296388, 61856777, 0, 42996708, 1057981550, 80739310, 0, ++ 1053798475, 1073715289, 1026516114, 0, 1059043393, 15707203, 1040152703, 0, 1065337910, ++ 31440940, 1053788268, 0, 1070583851, 47174677, 1067423833, 0, 2087967, 63959037, ++ 7318598, 0, 8382483, 1039106168, 20954162, 0, 14676999, 1050644584, 34590749, ++ 0, 19923962, 1062181975, 49275912, 0, 26218477, 1073720390, 62913523, 0, ++ 1065339949, 12565557, 1040156783, 0, 1067439143, 24103971, 1049598049, 0, 1069538336, ++ 36691985, 1059038290, 0, 1071637529, 48231422, 1069527108, 0, 1073736722, 1050648663, ++ 5226549, 0, 3141643, 1057991755, 15715366, 0, 5240836, 1066383423, 26205206, ++ 0, 6292477, 1033267, 36695046, 0, 9440246, 9424934, 47184887, 0, ++ 1042447, 17816601, 1052748876, 0, 1044493, 26208268, 1059043394, 0, 1045514, ++ 34600959, 1065336888, 0, 1072691208, 1061143607, 1071631406, 0, 1071643653, 1065339951, ++ 4183076, 0, 1070595075, 1070584871, 10477593, 0, 1068498946, 1039391, 17819663, ++ 0, 1067450368, 6284311, 24114180, 0, 1067452415, 10480655, 31457274, 0, ++ 1042417, 15725575, 1065340970, 0, 1046514, 20970495, 1068488740, 0, 1011, ++ 1072686103, 1070586910, 0, 4086, 1073735699, 1073734680, 0, 1068503033, 1043471, ++ 3139603, 0, 1064307708, 2093068, 6287373, 0, 1060111360, 3142664, 9434119, ++ 0, 1055917060, 4192261, 12580866, 0, 1043325952, 6290434, 14681084, 0, ++ 980346125, 6292479, 1043464, 0, 1006568682, 1044470, 1044486, 0, 1032791238, ++ 1046518, 1045508, 0, 1060062370, 1048566, 1046530, 0, 12544126, 2039, ++ 1047553, 0, 40863832, 1072696313, 0, 0, 69184560, 1070599162, 1023, ++ 0, 97506310, 1068500989, 1023, 0, 126877660, 1066402816, 0, 0, ++ 993986794, 0, 0, 0, 1016014027, 0, 0, 0, 1039089837, ++ 0, 0, 0, 1062165645, 0, 0, 0, 11499630, 0, ++ 0, 0, 34576461, 0, 0, 0, 58701867, 0, 0, ++ 0, 83875848, 0, 0, 0, 108002276, 0, 0, 0, ++ 1007628486, 0, 0, 0, 1025459373, 0, 0, 0, 1044339859, ++ 0, 0, 0, 1064268921, 0, 0, 0, 9407582, 0, ++ 0, 0, 29337666, 0, 0, 0, 49266726, 0, 0, ++ 0, 69196809, 0, 0, 0, 89127915, 0, 0, 0, ++ 1020220579, 0, 0, 0, 1035954318, 0, 0, 0, 1050638457, ++ 0, 0, 0, 1066372196, 0, 0, 0, 7315534, 0, ++ 0, 0, 23049271, 0, 0, 0, 39832608, 0, 0, ++ 0, 55566345, 0, 0, 0, 71302129, 0, 0, 0, ++ 1033861248, 0, 0, 0, 1045399664, 0, 0, 0, 1056937055, ++ 0, 0, 0, 1068475470, 0, 0, 0, 6272061, 0, ++ 0, 0, 17810476, 0, 0, 0, 30398490, 0, 0, ++ 0, 42985479, 0, 0, 0, 54524917, 0, 0, 0, ++ 1046453341, 0, 0, 0, 1054845009, 0, 0, 0, 1062188101, ++ 0, 0, 0, 1070578745, 0, 0, 0, 5228588, 0, ++ 0, 0, 13620256, 0, 0, 0, 22011923, 0, 0, ++ 0, 30404613, 0, 0, 0, 38797304, 0, 0, 0, ++ 1059045435, 0, 0, 0, 1063241779, 0, 0, 0, 1068486699, ++ 0, 0, 0, 1072683043, 0, 0, 0, 3137563, 0, ++ 0, 0, 8382483, 0, 0, 0, 13627403, 0, 0, ++ 0, 17822723, 0, 0, 0, 23068667, 0, 0, 0, ++ 1071637529, 0, 0, 0, 1072687125, 0, 0, 0, 1073736721, ++ 0, 0, 0, 1044493, 0, 0, 0, 2094090, 0, ++ 0, 0, 3143686, 0, 0, 0, 5241859, 0, 0, ++ 0, 6290433, 0, 0, 0, 7341054, 0, 0, 0, ++ 1042423, 0, 0, 0, 1045494, 0, 0, 0, 1047542, ++ 0, 0, 0, 1015, 0, 0, 0, 3064, 0, ++ 0, 0, 1071647738, 0, 0, 0, 1069550588, 0, 0, ++ 0, 1067452414, 0, 0, 0, 1065352192, 0, 0, 0, ++ } ++ }, ++}; ++ ++#ifdef __cplusplus ++#if __cplusplus ++} ++#endif ++#endif /* End of #ifdef __cplusplus */ ++ ++#endif /* OS08A20_CMOS_EX_H */ +diff --git a/smp/a55_linux/mpp/sample/omnivision_os04a10/os04a10_sensor_ctl.c b/smp/a55_linux/mpp/sample/omnivision_os04a10/os04a10_sensor_ctl.c +new file mode 100644 +index 0000000..d00c1c2 +--- /dev/null ++++ b/smp/a55_linux/mpp/sample/omnivision_os04a10/os04a10_sensor_ctl.c +@@ -0,0 +1,585 @@ ++/* ++ Copyright (c), 2001-2024, Shenshu Tech. Co., Ltd. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#ifdef OT_GPIO_I2C ++#include "gpioi2c_ex.h" ++#else ++#include "ot_i2c.h" ++#endif ++ ++#include "os04a10_cmos.h" ++ ++#define I2C_DEV_FILE_NUM 16 ++#define I2C_BUF_NUM 8 ++ ++static int g_fd[OT_ISP_MAX_PIPE_NUM] = {[0 ...(OT_ISP_MAX_PIPE_NUM - 1)] = -1}; ++ ++int os04a10_i2c_init(ot_vi_pipe vi_pipe) ++{ ++ int ret; ++ char dev_file[I2C_DEV_FILE_NUM] = {0}; ++ td_u8 dev_num; ++ ++ if (g_fd[vi_pipe] >= 0) { ++ return TD_SUCCESS; ++ } ++#ifdef OT_GPIO_I2C ++ g_fd[vi_pipe] = open("/dev/gpioi2c_ex", O_RDONLY, S_IRUSR); ++ if (g_fd[vi_pipe] < 0) { ++ isp_err_trace("Open gpioi2c_ex error!\n"); ++ return TD_FAILURE; ++ } ++#else ++ ot_isp_sns_commbus *os04a10businfo = TD_NULL; ++ os04a10businfo = os04a10_get_bus_info(vi_pipe); ++ dev_num = os04a10businfo->i2c_dev; ++ (td_void)snprintf_s(dev_file, sizeof(dev_file), sizeof(dev_file) - 1, "/dev/i2c-%u", dev_num); ++ ++ g_fd[vi_pipe] = open(dev_file, O_RDWR, S_IRUSR | S_IWUSR); ++ if (g_fd[vi_pipe] < 0) { ++ isp_err_trace("Open /dev/ot_i2c_drv-%u error!\n", dev_num); ++ return TD_FAILURE; ++ } ++ ++ ret = ioctl(g_fd[vi_pipe], OT_I2C_SLAVE_FORCE, (OS04A10_I2C_ADDR >> 1)); ++ if (ret < 0) { ++ isp_err_trace("I2C_SLAVE_FORCE error!\n"); ++ close(g_fd[vi_pipe]); ++ g_fd[vi_pipe] = -1; ++ return ret; ++ } ++#endif ++ ++ return TD_SUCCESS; ++} ++ ++int os04a10_i2c_exit(ot_vi_pipe vi_pipe) ++{ ++ if (g_fd[vi_pipe] >= 0) { ++ close(g_fd[vi_pipe]); ++ g_fd[vi_pipe] = -1; ++ return TD_SUCCESS; ++ } ++ return TD_FAILURE; ++} ++ ++td_s32 os04a10_read_register(ot_vi_pipe vi_pipe, td_u32 addr) ++{ ++ ot_unused(vi_pipe); ++ ot_unused(addr); ++ return TD_SUCCESS; ++} ++ ++td_s32 os04a10_write_register(ot_vi_pipe vi_pipe, td_u32 addr, td_u32 data) ++{ ++ if (g_fd[vi_pipe] < 0) { ++ return TD_SUCCESS; ++ } ++ ++#ifdef OT_GPIO_I2C ++ i2c_data.dev_addr = OS04A10_I2C_ADDR; ++ i2c_data.reg_addr = addr; ++ i2c_data.addr_byte_num = OS04A10_ADDR_BYTE; ++ i2c_data.data = data; ++ i2c_data.data_byte_num = OS04A10_DATA_BYTE; ++ ++ ret = ioctl(g_fd[vi_pipe], GPIO_I2C_WRITE, &i2c_data); ++ if (ret) { ++ isp_err_trace("GPIO-I2C write failed!\n"); ++ return ret; ++ } ++#else ++ td_u32 idx = 0; ++ td_s32 ret; ++ td_u8 buf[I2C_BUF_NUM]; ++ ++ if (OS04A10_ADDR_BYTE == 2) { /* 2 byte */ ++ buf[idx] = (addr >> 8) & 0xff; /* shift 8 */ ++ idx++; ++ buf[idx] = addr & 0xff; ++ idx++; ++ } else { ++ } ++ ++ if (OS04A10_DATA_BYTE == 2) { /* 2 byte */ ++ } else { ++ buf[idx] = data & 0xff; ++ idx++; ++ } ++ ++ ret = write(g_fd[vi_pipe], buf, OS04A10_ADDR_BYTE + OS04A10_DATA_BYTE); ++ if (ret < 0) { ++ isp_err_trace("I2C_WRITE error!\n"); ++ return TD_FAILURE; ++ } ++ ++#endif ++ return TD_SUCCESS; ++} ++ ++static void delay_ms(int ms) ++{ ++ usleep(ms * 1000); /* 1ms: 1000us */ ++ return; ++} ++ ++void os04a10_prog(ot_vi_pipe vi_pipe, const td_u32 *rom) ++{ ++ ot_unused(vi_pipe); ++ ot_unused(rom); ++ return; ++} ++ ++void os04a10_standby(ot_vi_pipe vi_pipe) ++{ ++ ot_unused(vi_pipe); ++ return; ++} ++ ++void os04a10_restart(ot_vi_pipe vi_pipe) ++{ ++ ot_unused(vi_pipe); ++ return; ++} ++ ++static void os04a10_linear_4m30_12bit_init(ot_vi_pipe vi_pipe); ++ ++static void os04a10_default_reg_init(ot_vi_pipe vi_pipe) ++{ ++ td_u32 i; ++ td_s32 ret = TD_SUCCESS; ++ ot_isp_sns_state *pastos04a10 = TD_NULL; ++ ++ pastos04a10 = os04a10_get_ctx(vi_pipe); ++ for (i = 0; i < pastos04a10->regs_info[0].reg_num; i++) { ++ ret += os04a10_write_register(vi_pipe, ++ pastos04a10->regs_info[0].i2c_data[i].reg_addr, ++ pastos04a10->regs_info[0].i2c_data[i].data); ++ } ++ ++ if (ret != TD_SUCCESS) { ++ isp_err_trace("write register failed!\n"); ++ } ++ ++ return; ++} ++ ++void os04a10_init(ot_vi_pipe vi_pipe) ++{ ++ td_bool init; ++ td_s32 ret; ++ ot_isp_sns_state *pastos04a10 = TD_NULL; ++ ++ pastos04a10 = os04a10_get_ctx(vi_pipe); ++ init = pastos04a10->init; ++ ++ ret = os04a10_i2c_init(vi_pipe); ++ if (ret != TD_SUCCESS) { ++ isp_err_trace("i2c init failed!\n"); ++ return; ++ } ++ ++ /* When sensor first init, config all registers */ ++ if (init == TD_FALSE) { ++ os04a10_linear_4m30_12bit_init(vi_pipe); ++ } else { ++ os04a10_linear_4m30_12bit_init(vi_pipe); ++ } ++ ++ pastos04a10->init = TD_TRUE; ++ return; ++} ++ ++void os04a10_exit(ot_vi_pipe vi_pipe) ++{ ++ td_s32 ret; ++ ++ ret = os04a10_i2c_exit(vi_pipe); ++ if (ret != TD_SUCCESS) { ++ isp_err_trace("OS04A10 exit failed!\n"); ++ } ++ ++ return; ++} ++ ++static td_s32 os04a10_linear_4m30_12bit_init_part1(ot_vi_pipe vi_pipe) ++{ ++ td_s32 ret = TD_SUCCESS; ++ ret += os04a10_write_register(vi_pipe, 0x0102, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x0305, 0x42); ++ ret += os04a10_write_register(vi_pipe, 0x0306, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x0307, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x0308, 0x05); ++ ret += os04a10_write_register(vi_pipe, 0x030a, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x0317, 0x0a); ++ ret += os04a10_write_register(vi_pipe, 0x0322, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x0323, 0x02); ++ ret += os04a10_write_register(vi_pipe, 0x0324, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x0325, 0x90); ++ ret += os04a10_write_register(vi_pipe, 0x0327, 0x05); ++ ret += os04a10_write_register(vi_pipe, 0x0329, 0x02); ++ ret += os04a10_write_register(vi_pipe, 0x032c, 0x02); ++ ret += os04a10_write_register(vi_pipe, 0x032d, 0x02); ++ ret += os04a10_write_register(vi_pipe, 0x032e, 0x02); ++ ret += os04a10_write_register(vi_pipe, 0x300f, 0x11); ++ ret += os04a10_write_register(vi_pipe, 0x3012, 0x41); ++ ret += os04a10_write_register(vi_pipe, 0x3026, 0x10); ++ ret += os04a10_write_register(vi_pipe, 0x3027, 0x08); ++ ret += os04a10_write_register(vi_pipe, 0x302d, 0x24); ++ ret += os04a10_write_register(vi_pipe, 0x3104, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x3106, 0x11); ++ ret += os04a10_write_register(vi_pipe, 0x3400, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3408, 0x05); ++ ret += os04a10_write_register(vi_pipe, 0x340c, 0x0c); ++ ret += os04a10_write_register(vi_pipe, 0x340d, 0xb0); ++ ret += os04a10_write_register(vi_pipe, 0x3425, 0x51); ++ ret += os04a10_write_register(vi_pipe, 0x3426, 0x10); ++ ret += os04a10_write_register(vi_pipe, 0x3427, 0x14); ++ ret += os04a10_write_register(vi_pipe, 0x3428, 0x10); ++ ret += os04a10_write_register(vi_pipe, 0x3429, 0x10); ++ ret += os04a10_write_register(vi_pipe, 0x342a, 0x10); ++ ret += os04a10_write_register(vi_pipe, 0x342b, 0x04); ++ ret += os04a10_write_register(vi_pipe, 0x3501, 0x02); ++ ret += os04a10_write_register(vi_pipe, 0x3504, 0x08); ++ ret += os04a10_write_register(vi_pipe, 0x3508, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x3509, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x350a, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x3544, 0x08); ++ ret += os04a10_write_register(vi_pipe, 0x3548, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x3549, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3584, 0x08); ++ ret += os04a10_write_register(vi_pipe, 0x3588, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x3589, 0x00); ++ ++ return ret; ++} ++ ++static td_s32 os04a10_linear_4m30_12bit_init_part2(ot_vi_pipe vi_pipe) ++{ ++ td_s32 ret = TD_SUCCESS; ++ ret += os04a10_write_register(vi_pipe, 0x3601, 0x70); ++ ret += os04a10_write_register(vi_pipe, 0x3604, 0xe3); ++ ret += os04a10_write_register(vi_pipe, 0x3605, 0xff); ++ ret += os04a10_write_register(vi_pipe, 0x3606, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x3608, 0xa8); ++ ret += os04a10_write_register(vi_pipe, 0x360a, 0xd0); ++ ret += os04a10_write_register(vi_pipe, 0x360b, 0x08); ++ ret += os04a10_write_register(vi_pipe, 0x360e, 0xc8); ++ ret += os04a10_write_register(vi_pipe, 0x360f, 0x66); ++ ret += os04a10_write_register(vi_pipe, 0x3610, 0x89); ++ ret += os04a10_write_register(vi_pipe, 0x3611, 0x8a); ++ ret += os04a10_write_register(vi_pipe, 0x3612, 0x4e); ++ ret += os04a10_write_register(vi_pipe, 0x3613, 0xbd); ++ ret += os04a10_write_register(vi_pipe, 0x3614, 0x9b); ++ ret += os04a10_write_register(vi_pipe, 0x362a, 0x0e); ++ ret += os04a10_write_register(vi_pipe, 0x362b, 0x0e); ++ ret += os04a10_write_register(vi_pipe, 0x362c, 0x0e); ++ ret += os04a10_write_register(vi_pipe, 0x362d, 0x09); ++ ret += os04a10_write_register(vi_pipe, 0x362e, 0x1a); ++ ret += os04a10_write_register(vi_pipe, 0x362f, 0x34); ++ ret += os04a10_write_register(vi_pipe, 0x3630, 0x67); ++ ret += os04a10_write_register(vi_pipe, 0x3631, 0x7f); ++ ret += os04a10_write_register(vi_pipe, 0x3638, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3643, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3644, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3645, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3646, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3647, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3648, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3649, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x364a, 0x04); ++ ret += os04a10_write_register(vi_pipe, 0x364c, 0x0e); ++ ret += os04a10_write_register(vi_pipe, 0x364d, 0x0e); ++ ret += os04a10_write_register(vi_pipe, 0x364e, 0x0e); ++ ret += os04a10_write_register(vi_pipe, 0x364f, 0x0e); ++ ret += os04a10_write_register(vi_pipe, 0x3650, 0xff); ++ ret += os04a10_write_register(vi_pipe, 0x3651, 0xff); ++ ret += os04a10_write_register(vi_pipe, 0x365a, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x365b, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x365c, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x365d, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3661, 0x07); ++ ret += os04a10_write_register(vi_pipe, 0x3662, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3663, 0x20); ++ ret += os04a10_write_register(vi_pipe, 0x3665, 0x12); ++ ++ return ret; ++} ++ ++static td_s32 os04a10_linear_4m30_12bit_init_part3(ot_vi_pipe vi_pipe) ++{ ++ td_s32 ret = TD_SUCCESS; ++ ret += os04a10_write_register(vi_pipe, 0x3667, 0xd4); ++ ret += os04a10_write_register(vi_pipe, 0x3668, 0x80); ++ ret += os04a10_write_register(vi_pipe, 0x366c, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x366d, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x366e, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x366f, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3671, 0x08); ++ ret += os04a10_write_register(vi_pipe, 0x3673, 0x2a); ++ ret += os04a10_write_register(vi_pipe, 0x3681, 0x80); ++ ret += os04a10_write_register(vi_pipe, 0x3700, 0x2d); ++ ret += os04a10_write_register(vi_pipe, 0x3701, 0x22); ++ ret += os04a10_write_register(vi_pipe, 0x3702, 0x25); ++ ret += os04a10_write_register(vi_pipe, 0x3703, 0x28); ++ ret += os04a10_write_register(vi_pipe, 0x3705, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3706, 0xf0); ++ ret += os04a10_write_register(vi_pipe, 0x3707, 0x0a); ++ ret += os04a10_write_register(vi_pipe, 0x3708, 0x36); ++ ret += os04a10_write_register(vi_pipe, 0x3709, 0x57); ++ ret += os04a10_write_register(vi_pipe, 0x370a, 0x03); ++ ret += os04a10_write_register(vi_pipe, 0x370b, 0x15); ++ ret += os04a10_write_register(vi_pipe, 0x3714, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x3719, 0x24); ++ ret += os04a10_write_register(vi_pipe, 0x371b, 0x1f); ++ ret += os04a10_write_register(vi_pipe, 0x371c, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x371d, 0x08); ++ ret += os04a10_write_register(vi_pipe, 0x373f, 0x63); ++ ret += os04a10_write_register(vi_pipe, 0x3740, 0x63); ++ ret += os04a10_write_register(vi_pipe, 0x3741, 0x63); ++ ret += os04a10_write_register(vi_pipe, 0x3742, 0x63); ++ ret += os04a10_write_register(vi_pipe, 0x3743, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x3756, 0xe7); ++ ret += os04a10_write_register(vi_pipe, 0x3757, 0xe7); ++ ret += os04a10_write_register(vi_pipe, 0x3762, 0x1c); ++ ret += os04a10_write_register(vi_pipe, 0x376c, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3776, 0x05); ++ ret += os04a10_write_register(vi_pipe, 0x3777, 0x22); ++ ret += os04a10_write_register(vi_pipe, 0x3779, 0x60); ++ ret += os04a10_write_register(vi_pipe, 0x377c, 0x48); ++ ret += os04a10_write_register(vi_pipe, 0x3784, 0x06); ++ ret += os04a10_write_register(vi_pipe, 0x3785, 0x0a); ++ ret += os04a10_write_register(vi_pipe, 0x3790, 0x10); ++ ret += os04a10_write_register(vi_pipe, 0x3793, 0x04); ++ ret += os04a10_write_register(vi_pipe, 0x3794, 0x07); ++ ret += os04a10_write_register(vi_pipe, 0x3796, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3797, 0x02); ++ ++ return ret; ++} ++ ++static td_s32 os04a10_linear_4m30_12bit_init_part4(ot_vi_pipe vi_pipe) ++{ ++ td_s32 ret = TD_SUCCESS; ++ ret += os04a10_write_register(vi_pipe, 0x379c, 0x4d); ++ ret += os04a10_write_register(vi_pipe, 0x37a1, 0x80); ++ ret += os04a10_write_register(vi_pipe, 0x37bb, 0x88); ++ ret += os04a10_write_register(vi_pipe, 0x37be, 0x48); ++ ret += os04a10_write_register(vi_pipe, 0x37bf, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x37c0, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x37c4, 0x72); ++ ret += os04a10_write_register(vi_pipe, 0x37c5, 0x72); ++ ret += os04a10_write_register(vi_pipe, 0x37c6, 0x72); ++ ret += os04a10_write_register(vi_pipe, 0x37ca, 0x21); ++ ret += os04a10_write_register(vi_pipe, 0x37cc, 0x15); ++ ret += os04a10_write_register(vi_pipe, 0x37cd, 0x90); ++ ret += os04a10_write_register(vi_pipe, 0x37cf, 0x02); ++ ret += os04a10_write_register(vi_pipe, 0x37d0, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x37d1, 0xf0); ++ ret += os04a10_write_register(vi_pipe, 0x37d2, 0x03); ++ ret += os04a10_write_register(vi_pipe, 0x37d3, 0x15); ++ ret += os04a10_write_register(vi_pipe, 0x37d4, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x37d5, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x37d6, 0x03); ++ ret += os04a10_write_register(vi_pipe, 0x37d7, 0x15); ++ ret += os04a10_write_register(vi_pipe, 0x37d8, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x37dc, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x37dd, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x37da, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x37db, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3800, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3801, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3802, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3803, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3804, 0x0a); ++ ret += os04a10_write_register(vi_pipe, 0x3805, 0x8f); ++ ret += os04a10_write_register(vi_pipe, 0x3806, 0x05); ++ ret += os04a10_write_register(vi_pipe, 0x3807, 0xff); ++ ret += os04a10_write_register(vi_pipe, 0x3808, 0x0a); ++ ret += os04a10_write_register(vi_pipe, 0x3809, 0x80); ++ ret += os04a10_write_register(vi_pipe, 0x380a, 0x05); ++ ret += os04a10_write_register(vi_pipe, 0x380b, 0xf0); ++ ret += os04a10_write_register(vi_pipe, 0x380c, 0x05); ++ ret += os04a10_write_register(vi_pipe, 0x380d, 0xc4); ++ ret += os04a10_write_register(vi_pipe, 0x380e, 0x06); ++ ret += os04a10_write_register(vi_pipe, 0x380f, 0x58); ++ ret += os04a10_write_register(vi_pipe, 0x3811, 0x09); ++ ret += os04a10_write_register(vi_pipe, 0x3813, 0x09); ++ ret += os04a10_write_register(vi_pipe, 0x3814, 0x01); ++ ++ return ret; ++} ++ ++static td_s32 os04a10_linear_4m30_12bit_init_part5(ot_vi_pipe vi_pipe) ++{ ++ td_s32 ret = TD_SUCCESS; ++ ret += os04a10_write_register(vi_pipe, 0x3815, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x3816, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x3817, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x381c, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3820, 0x02); ++ ret += os04a10_write_register(vi_pipe, 0x3821, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3822, 0x14); ++ ret += os04a10_write_register(vi_pipe, 0x3823, 0x18); ++ ret += os04a10_write_register(vi_pipe, 0x3826, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3827, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3833, 0x40); ++ ret += os04a10_write_register(vi_pipe, 0x384c, 0x05); ++ ret += os04a10_write_register(vi_pipe, 0x384d, 0xc4); ++ ret += os04a10_write_register(vi_pipe, 0x3858, 0x3c); ++ ret += os04a10_write_register(vi_pipe, 0x3865, 0x02); ++ ret += os04a10_write_register(vi_pipe, 0x3866, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3867, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3868, 0x02); ++ ret += os04a10_write_register(vi_pipe, 0x3900, 0x13); ++ ret += os04a10_write_register(vi_pipe, 0x3940, 0x13); ++ ret += os04a10_write_register(vi_pipe, 0x3980, 0x13); ++ ret += os04a10_write_register(vi_pipe, 0x3c01, 0x11); ++ ret += os04a10_write_register(vi_pipe, 0x3c05, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3c0f, 0x1c); ++ ret += os04a10_write_register(vi_pipe, 0x3c12, 0x0d); ++ ret += os04a10_write_register(vi_pipe, 0x3c19, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3c21, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x3c3a, 0x10); ++ ret += os04a10_write_register(vi_pipe, 0x3c3b, 0x18); ++ ret += os04a10_write_register(vi_pipe, 0x3c3d, 0xc6); ++ ret += os04a10_write_register(vi_pipe, 0x3c55, 0xcb); ++ ret += os04a10_write_register(vi_pipe, 0x3c5a, 0xe5); ++ ret += os04a10_write_register(vi_pipe, 0x3c5d, 0xcf); ++ ret += os04a10_write_register(vi_pipe, 0x3c5e, 0xcf); ++ ret += os04a10_write_register(vi_pipe, 0x3d8c, 0x70); ++ ret += os04a10_write_register(vi_pipe, 0x3d8d, 0x10); ++ ret += os04a10_write_register(vi_pipe, 0x4000, 0xf9); ++ ret += os04a10_write_register(vi_pipe, 0x4001, 0x2f); ++ ret += os04a10_write_register(vi_pipe, 0x4004, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x4005, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x4008, 0x02); ++ ret += os04a10_write_register(vi_pipe, 0x4009, 0x11); ++ ret += os04a10_write_register(vi_pipe, 0x400a, 0x03); ++ ret += os04a10_write_register(vi_pipe, 0x400b, 0x27); ++ ret += os04a10_write_register(vi_pipe, 0x400e, 0x40); ++ ++ return ret; ++} ++ ++static td_s32 os04a10_linear_4m30_12bit_init_part6(ot_vi_pipe vi_pipe) ++{ ++ td_s32 ret = TD_SUCCESS; ++ ret += os04a10_write_register(vi_pipe, 0x402e, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x402f, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x4030, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x4031, 0x80); ++ ret += os04a10_write_register(vi_pipe, 0x4032, 0x9f); ++ ret += os04a10_write_register(vi_pipe, 0x4033, 0x80); ++ ret += os04a10_write_register(vi_pipe, 0x4050, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x4051, 0x07); ++ ret += os04a10_write_register(vi_pipe, 0x4011, 0xbb); ++ ret += os04a10_write_register(vi_pipe, 0x410f, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x4288, 0xcf); ++ ret += os04a10_write_register(vi_pipe, 0x4289, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x428a, 0x46); ++ ret += os04a10_write_register(vi_pipe, 0x430b, 0xff); ++ ret += os04a10_write_register(vi_pipe, 0x430c, 0xff); ++ ret += os04a10_write_register(vi_pipe, 0x430d, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x430e, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x4314, 0x04); ++ ret += os04a10_write_register(vi_pipe, 0x4500, 0x18); ++ ret += os04a10_write_register(vi_pipe, 0x4501, 0x18); ++ ret += os04a10_write_register(vi_pipe, 0x4503, 0x10); ++ ret += os04a10_write_register(vi_pipe, 0x4504, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x4506, 0x32); ++ ret += os04a10_write_register(vi_pipe, 0x4507, 0x02); ++ ret += os04a10_write_register(vi_pipe, 0x4601, 0x30); ++ ret += os04a10_write_register(vi_pipe, 0x4603, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x460a, 0x50); ++ ret += os04a10_write_register(vi_pipe, 0x460c, 0x60); ++ ret += os04a10_write_register(vi_pipe, 0x4640, 0x62); ++ ret += os04a10_write_register(vi_pipe, 0x4646, 0xaa); ++ ret += os04a10_write_register(vi_pipe, 0x4647, 0x55); ++ ret += os04a10_write_register(vi_pipe, 0x4648, 0x99); ++ ret += os04a10_write_register(vi_pipe, 0x4649, 0x66); ++ ret += os04a10_write_register(vi_pipe, 0x464d, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x4654, 0x11); ++ ret += os04a10_write_register(vi_pipe, 0x4655, 0x22); ++ ret += os04a10_write_register(vi_pipe, 0x4800, 0x44); ++ ret += os04a10_write_register(vi_pipe, 0x480e, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x4810, 0xff); ++ ret += os04a10_write_register(vi_pipe, 0x4811, 0xff); ++ ret += os04a10_write_register(vi_pipe, 0x4813, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x481f, 0x30); ++ ret += os04a10_write_register(vi_pipe, 0x4837, 0x14); ++ ret += os04a10_write_register(vi_pipe, 0x484b, 0x27); ++ ret += os04a10_write_register(vi_pipe, 0x4d00, 0x4d); ++ ++ return ret; ++} ++ ++static td_s32 os04a10_linear_4m30_12bit_init_part7(ot_vi_pipe vi_pipe) ++{ ++ td_s32 ret = TD_SUCCESS; ++ ret += os04a10_write_register(vi_pipe, 0x4d01, 0x9d); ++ ret += os04a10_write_register(vi_pipe, 0x4d02, 0xb9); ++ ret += os04a10_write_register(vi_pipe, 0x4d03, 0x2e); ++ ret += os04a10_write_register(vi_pipe, 0x4d04, 0x4a); ++ ret += os04a10_write_register(vi_pipe, 0x4d05, 0x3d); ++ ret += os04a10_write_register(vi_pipe, 0x4d09, 0x4f); ++ ret += os04a10_write_register(vi_pipe, 0x5000, 0x17); ++ ret += os04a10_write_register(vi_pipe, 0x5001, 0x0d); ++ ret += os04a10_write_register(vi_pipe, 0x5080, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x50c0, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x5100, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x5200, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x5201, 0x00); ++ ret += os04a10_write_register(vi_pipe, 0x5202, 0x03); ++ ret += os04a10_write_register(vi_pipe, 0x5203, 0xff); ++ ret += os04a10_write_register(vi_pipe, 0x5780, 0x53); ++ ret += os04a10_write_register(vi_pipe, 0x5782, 0x60); ++ ret += os04a10_write_register(vi_pipe, 0x5783, 0xf0); ++ ret += os04a10_write_register(vi_pipe, 0x5786, 0x01); ++ ret += os04a10_write_register(vi_pipe, 0x5788, 0x60); ++ ret += os04a10_write_register(vi_pipe, 0x5789, 0xf0); ++ ret += os04a10_write_register(vi_pipe, 0x5792, 0x11); ++ ret += os04a10_write_register(vi_pipe, 0x5793, 0x33); ++ ret += os04a10_write_register(vi_pipe, 0x5857, 0xff); ++ ret += os04a10_write_register(vi_pipe, 0x5858, 0xff); ++ ret += os04a10_write_register(vi_pipe, 0x5859, 0xff); ++ ret += os04a10_write_register(vi_pipe, 0x58d7, 0xff); ++ ret += os04a10_write_register(vi_pipe, 0x58d8, 0xff); ++ ret += os04a10_write_register(vi_pipe, 0x58d9, 0xff); ++ ++ os04a10_default_reg_init(vi_pipe); ++ ++ delay_ms(0x5); ++ ret += os04a10_write_register(vi_pipe, 0x0100, 0x01); ++ return ret; ++} ++ ++static void os04a10_linear_4m30_12bit_init(ot_vi_pipe vi_pipe) ++{ ++ td_s32 ret = TD_SUCCESS; ++ ++ ret += os04a10_linear_4m30_12bit_init_part1(vi_pipe); ++ ret += os04a10_linear_4m30_12bit_init_part2(vi_pipe); ++ ret += os04a10_linear_4m30_12bit_init_part3(vi_pipe); ++ ret += os04a10_linear_4m30_12bit_init_part4(vi_pipe); ++ ret += os04a10_linear_4m30_12bit_init_part5(vi_pipe); ++ ret += os04a10_linear_4m30_12bit_init_part6(vi_pipe); ++ ret += os04a10_linear_4m30_12bit_init_part7(vi_pipe); ++ if (ret != TD_SUCCESS) { ++ isp_err_trace("os04a10 write register failed!\n"); ++ return; ++ } ++ ++ printf("========================================================================\n"); ++ printf("vi_pipe:%d,== os04a10 24Mclk 4M30fps(MIPI) 12bit linear init success! ==\n", vi_pipe); ++ printf("========================================================================\n"); ++ return; ++} +diff --git a/smp/a55_linux/mpp/sample/vio/sample_vio.c b/smp/a55_linux/mpp/sample/vio/sample_vio.c +index 28ba59a..a90343a 100644 +--- a/smp/a55_linux/mpp/sample/vio/sample_vio.c ++++ b/smp/a55_linux/mpp/sample/vio/sample_vio.c +@@ -63,7 +63,7 @@ static td_u16 g_lmf_coef[128] = { + static sample_vo_cfg g_vo_cfg = { + .vo_dev = SAMPLE_VO_DEV_UHD, + .vo_intf_type = OT_VO_INTF_HDMI, +- .intf_sync = OT_VO_OUT_1080P30, ++ .intf_sync = OT_VO_OUT_1080P60, + .bg_color = COLOR_RGB_BLACK, + .pix_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_420, + .disp_rect = {0, 0, 1920, 1080}, +@@ -673,10 +673,15 @@ static td_s32 sample_vio_switch_mode(td_void) + return ret; + } + +- if (sns_type == HY_S0603_MIPI_8M_30FPS_12BIT) { +- sns_type = HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1; ++ //if (sns_type == HY_S0603_MIPI_8M_30FPS_12BIT) { ++ // sns_type = HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1; ++ //} else { ++ // sns_type = HY_S0603_MIPI_8M_30FPS_12BIT; ++ //} ++ if (sns_type == OV_OS04A10_MIPI_4M_30FPS_12BIT) { ++ sns_type = OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1; + } else { +- sns_type = HY_S0603_MIPI_8M_30FPS_12BIT; ++ sns_type = OV_OS04A10_MIPI_4M_30FPS_12BIT; + } + + ret = sample_vio_switch_second_route(sns_type); +@@ -732,6 +737,8 @@ static td_s32 sample_vio_wdr(td_void) + + if (sns_type == HY_S0603_MIPI_8M_30FPS_12BIT) { + sns_type = HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1; ++ } else if (sns_type == OV_OS04A10_MIPI_4M_30FPS_12BIT) { ++ sns_type = OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1; + } + sample_comm_vi_get_size_by_sns_type(sns_type, &in_size); + sample_comm_vi_get_default_vi_cfg(sns_type, &vi_cfg); +@@ -788,6 +795,8 @@ static td_s32 sample_vio_wdr_send_frame(td_void) + sns_type = SENSOR0_TYPE; + if (sns_type == HY_S0603_MIPI_8M_30FPS_12BIT) { + sns_type = HY_S0603_MIPI_8M_30FPS_10BIT_WDR2TO1; ++ } else if(sns_type == OV_OS04A10_MIPI_4M_30FPS_12BIT) { ++ sns_type = OV_OS04A10_MIPI_4M_30FPS_10BIT_WDR2TO1; + } + sample_comm_vi_get_size_by_sns_type(sns_type, &in_size); + sample_comm_vi_get_default_vi_cfg(sns_type, &vi_cfg); +-- +2.34.1 + diff --git a/vendor/zsks/pic/image-20250918185148122.png b/vendor/zsks/pic/image-20250918185148122.png new file mode 100755 index 0000000000000000000000000000000000000000..ececc626b71b0015ca5c43b3ff9b022b19a0a0be Binary files /dev/null and b/vendor/zsks/pic/image-20250918185148122.png differ diff --git a/vendor/zsks/pic/image-20251030111331648.png b/vendor/zsks/pic/image-20251030111331648.png new file mode 100755 index 0000000000000000000000000000000000000000..e92d1d65637e7915b86b6fdc5e62c93d9536c2d7 Binary files /dev/null and b/vendor/zsks/pic/image-20251030111331648.png differ diff --git a/vendor/zsks/pic/image-20251030114812656.png b/vendor/zsks/pic/image-20251030114812656.png new file mode 100755 index 0000000000000000000000000000000000000000..c2c388b34776f49871f46b7d29b288371b4f5ac0 Binary files /dev/null and b/vendor/zsks/pic/image-20251030114812656.png differ diff --git a/vendor/zsks/pic/image-20251030115229578.png b/vendor/zsks/pic/image-20251030115229578.png new file mode 100755 index 0000000000000000000000000000000000000000..57643e77441cf781e77100d281b1b2bb21aef483 Binary files /dev/null and b/vendor/zsks/pic/image-20251030115229578.png differ diff --git a/vendor/zsks/pic/image-20251030142816023.png b/vendor/zsks/pic/image-20251030142816023.png new file mode 100755 index 0000000000000000000000000000000000000000..1db90afb0d51ab40eba68429f3137fd7d72cc034 Binary files /dev/null and b/vendor/zsks/pic/image-20251030142816023.png differ