T113在内核中采用硬解jpeg方式实现开机动画
-
参考几位大神的logo替换方法以及相关问题:
主要实现思路:在kernel中,将jpg图片通过VE解码,连续显示形成动画。先将视频按帧截取成jpg图片,打包成特定格式的二进制文件。把资源包放入到一个指定分区中,在uboot阶段加载资源包,并告知kernel将资源包的内存区域保留出来。
资源包制作
int test_pic(int argc, char **argv) { FILE *fp_in; FILE *fp_out; int rc; char bmpfile[1024] = {0}; char path_out[1024] = {0}; int i = 0; char buffer[4096]; unsigned int length = 0; int pic_num = 100; if (argc > 3) { pic_num = atoi(argv[3]); } printf("pic_num:%d\n", pic_num); sprintf(path_out, "%s", argv[2]); printf("output:%s\n", path_out); fp_out = fopen(path_out, "wb+"); if (fp_out == NULL) { printf("Open file %s error\n", bmpfile); return (-1); } fwrite(&pic_num, 4, 1, fp_out); for (i = 0; i < pic_num; i++) { sprintf(bmpfile, "%s/1 (%d).jpg", argv[1], i + 1); fp_in = fopen(bmpfile, "rb"); if (fp_in == NULL) { printf("Open file %s error\n", bmpfile); return (-1); } length = get_file_size(bmpfile); if (length < 1) { printf(" file %s error\n", bmpfile); return (-1); } fwrite(&length, 4, 1, fp_out); while (!feof(fp_in)) { rc = fread(buffer, 1, 1024, fp_in); if (rc < 1) printf("file %s error\n", bmpfile); fwrite(buffer, 1, rc, fp_out); } fclose(fp_in); } fclose(fp_out); return 0; }
将所有图片打包成一份二进制文件,并命名为animation.fex,文件内容格式如下:
图片总数量 第一张图片大小(int) 第一张图片内容 第二张图片大小(int) 第二张图片内容 依此类推 int int char 数组 int char 数组 。。。 使用方法:
./bin/demo [图片路径] [资源包路径] [图片数量]
如:
./bin/demo bin/Capture100/ bin/animation.fex 90
log输出:
pic_num:90 output:bin/animation.fex
资源包的制作和内核中读取的格式相对应,如有需要可自行拓展。
资源包存放
新建一个分区
diff --git a/configs/demo2.0/longan/sys_partition.fex b/configs/demo2.0/longan/sys_partition.fex index c67aca3..1e12607 100755 --- a/configs/demo2.0/longan/sys_partition.fex +++ b/configs/demo2.0/longan/sys_partition.fex @@ -68,9 +68,9 @@ size = 16384 ;------------------------------>mmcblk0p6/nand0p6 [partition] - name = recovery - size = 231072 - ;downloadfile = "recovery.fex" + name = animation + size = 102400 + downloadfile = "animation.fex" user_type = 0x8000 ;------------------------------>mmcblk0p7/nand0p7 diff --git a/pack b/pack index d57362b..77e7b1f 100755 --- a/pack +++ b/pack @@ -164,6 +164,7 @@ ${LICHEE_COMMON_CONFIG_DIR}/tools/cardscript.fex ${LICHEE_COMMON_CONFIG_DIR}/tools/cardscript_secure.fex ${LICHEE_CHIP_CONFIG_DIR}/tools/cardscript.fex ${LICHEE_CHIP_CONFIG_DIR}/tools/cardscript_secure.fex +${LICHEE_CHIP_CONFIG_DIR}/tools/animation.fex ${LICHEE_COMMON_CONFIG_DIR}/tools/cardtool.fex ${LICHEE_CHIP_CONFIG_DIR}/tools/cardtool.fex ${LICHEE_COMMON_CONFIG_DIR}/tools/usbtool.fex
uboot修改
合入补丁
通过
CONFIG_ANIMATION_MEM_RESERVE
控制功能的开启关闭。
从emmc读取整个分区,分区越大耗时越久,可适当减少分区大小。
kernel修改
合入补丁通过
CONFIG_ANIMATION_MEM_RESERVE
宏开启
注意编解码VE和显示DE驱动代码的初始化的先后顺序
-
whycan
-
whycan
-
whycan
Copyright © 2023 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号