前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >全志T113在内核中采用硬解jpeg方式实现开机动画

全志T113在内核中采用硬解jpeg方式实现开机动画

作者头像
阿志小管家
发布2024-02-02 18:27:43
1320
发布2024-02-02 18:27:43
举报

参考几位大神的logo替换方法以及相关问题:

  1. https://bbs.aw-ol.com/topic/2217/
  2. https://bbs.aw-ol.com/topic/2546/

主要实现思路:在kernel中,将jpg图片通过VE解码,连续显示形成动画。先将视频按帧截取成jpg图片,打包成特定格式的二进制文件。把资源包放入到一个指定分区中,在uboot阶段加载资源包,并告知kernel将资源包的内存区域保留出来。

资源包制作

代码语言:javascript
复制
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 数组

。。。

使用方法:

代码语言:javascript
复制
./bin/demo [图片路径] [资源包路径] [图片数量]

如:

代码语言:javascript
复制
./bin/demo bin/Capture100/ bin/animation.fex 90

log输出:

代码语言:javascript
复制
pic_num:90
output:bin/animation.fex

资源包的制作和内核中读取的格式相对应,如有需要可自行拓展。

资源包存放

新建一个分区

代码语言:javascript
复制
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修改

合入补丁

通过

代码语言:javascript
复制
CONFIG_ANIMATION_MEM_RESERVE

控制功能的开启关闭。

从emmc读取整个分区,分区越大耗时越久,可适当减少分区大小。

kernel修改 合入补丁

通过

代码语言:javascript
复制
CONFIG_ANIMATION_MEM_RESERVE

宏开启

注意编解码VE和显示DE驱动代码的初始化的先后顺序

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2024-02-02,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档