diff --git a/jbig2enc/BUILD.gn b/jbig2enc/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..aaa308bf62fe3f4a4dd3f195e0286b41227fe8d4 --- /dev/null +++ b/jbig2enc/BUILD.gn @@ -0,0 +1,98 @@ +# Copyright (c) 2019-2022 Huawei Device Co., Ltd. All rights reserved. +# 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. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + + +declare_args() { + enable_test = false +} + +config("jbig2enc_config") { + cflags = [ + "-Wall", + "-Wno-error=unused-const-variable", + "-DVERSION=\"0.29\"" + ] + + ldflags = [ + "-lm", + ] +} + +ohos_shared_library("jbig2enc_shared") { + sources = [ + "jbig2enc/src/jbig2enc.cc", + "jbig2enc/src/jbig2arith.cc", + "jbig2enc/src/jbig2sym.cc", + "jbig2enc/src/jbig2comparator.cc", + ] + + include_dirs = [ + "jbig2enc/src", + "//third_party/leptonica/leptonica/src", + "//third_party/leptonica/adapted" + ] + + configs = [ ":jbig2enc_config" ] + + deps = [ + "//third_party/leptonica:leptonica", + "//third_party/libpng:libpng" + ] + + part_name = "jbig2enc" +} + +ohos_executable("jbig2") { + sources = [ + "jbig2enc/src/jbig2.cc", + ] + configs = [ ":jbig2enc_config" ] + + include_dirs = [ + "jbig2enc/src", + "//third_party/leptonica/leptonica/src", + "//third_party/leptonica/adapted" + ] + + deps = [ + ":jbig2enc_shared", + "//third_party/leptonica:leptonica", + "//third_party/libpng:libpng" + ] + part_name = "jbig2enc" +} + +action("init_includes") { + script = "adapted/init_includes.sh" + sources = [ "//third_party/jbig2enc/adapted" ] + outputs = [ "${target_out_dir}" ] + args = [ + rebase_path("//third_party/jbig2enc",root_build_dir) + ] +} + +group("jbig2enc") { + deps = [ + ":jbig2enc_shared", + ":init_includes" + ] + + if (enable_test) { + deps += [ + ":jbig2" + ] + } +} diff --git a/jbig2enc/README.OpenSource b/jbig2enc/README.OpenSource new file mode 100755 index 0000000000000000000000000000000000000000..267cdd368a5bf6d481b70c2cd0d615f178d7a23b --- /dev/null +++ b/jbig2enc/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name" : "jbig2enc", + "License" : "Apache License", + "License File" : "LICENSE", + "Version Number" : "0.29", + "Owner" : "huangminzhong2@huawei.com", + "Upstream URL" : "https://github.com/agl/jbig2enc", + "Description" : "This is an encoder for JBIG2." + } +] diff --git a/jbig2enc/README_zh.md b/jbig2enc/README_zh.md new file mode 100755 index 0000000000000000000000000000000000000000..14c8f12678bbb5d708c31fcfa3714ec0a8bb8dcf --- /dev/null +++ b/jbig2enc/README_zh.md @@ -0,0 +1,17 @@ +# jbig2enc 三方库说明 + +## 功能简介 + +jbig2enc是 JBIG2文件的编码器。 + +## 使用约束 + +- ROM版本:OpenHarmony3.2 beta1 +- 三方库版本:0.29 +- 当前适配的功能:[JBIG2](https://github.com/agl/jbig2enc/blob/0.29/fcd14492.pdf) 文件编码, 图片格式转换 +- License:[Apache License](https://github.com/agl/jbig2enc/blob/0.29/COPYING) + +## 集成方式 + +- [系统Rom包集成](./docs/rom_integrate.md) + diff --git a/jbig2enc/adapted/init_includes.sh b/jbig2enc/adapted/init_includes.sh new file mode 100755 index 0000000000000000000000000000000000000000..dab82dcec9317f31279d808954b0fe24c2b61e38 --- /dev/null +++ b/jbig2enc/adapted/init_includes.sh @@ -0,0 +1,2 @@ +#!/bin/bash +cd $1 && find jbig2enc |grep "allheaders.h" -rF | awk -F : '{print $1}' | xargs sed -i 's///g' diff --git a/jbig2enc/bundle.json b/jbig2enc/bundle.json new file mode 100755 index 0000000000000000000000000000000000000000..67e6a20f302c658c88ac0c4ffd4e1fe09f57a2e1 --- /dev/null +++ b/jbig2enc/bundle.json @@ -0,0 +1,33 @@ +{ + "name": "@ohos/jbig2enc", + "description": "This is an encoder for JBIG2.", + "version": "0.29", + "license": "Apache License", + "publishAs": "", + "segment": { + "destPath": "third_party/jbig2enc" + }, + "dirs": {}, + "scripts": {}, + "readmePath": { + "en": "README" + }, + "component": { + "name": "jbig2enc", + "subsystem": "thirdparty", + "syscap": [], + "features": [], + "adapted_system_type": ["standard"], + "rom": "", + "ram": "", + "deps": { + "components": [], + "third_party": [] + }, + "build": { + "sub_component": ["//third_party/jbig2enc:jbig2enc"], + "inner_kits": [], + "test": [] + } + } +} diff --git a/jbig2enc/docs/pic/result.png b/jbig2enc/docs/pic/result.png new file mode 100755 index 0000000000000000000000000000000000000000..cc76049f68900bff879a7c6b05a412775fabf474 Binary files /dev/null and b/jbig2enc/docs/pic/result.png differ diff --git a/jbig2enc/docs/rom_integrate.md b/jbig2enc/docs/rom_integrate.md new file mode 100755 index 0000000000000000000000000000000000000000..99d0cf49969e8e61216c461fe848a28fb3728033 --- /dev/null +++ b/jbig2enc/docs/rom_integrate.md @@ -0,0 +1,123 @@ +# jbig2enc如何集成到系统Rom +## 准备源码工程 +本库是基于OpenHarmony-v3.2-Beta1版本,在RK3568开发板上验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 +### 准备系统Rom源码 +系统源码获取请参考:[OpenHarmony源码下载](https://gitee.com/openharmony/docs/blob/OpenHarmony-v3.2-Beta2/zh-cn/release-notes/OpenHarmony-v3.2-beta1.md) +### 增加构建脚本及配置文件 +- 下载本仓库代码 + ``` + cd ~ + git clone git@gitee.com:openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` +- 三方库目录结构 + ``` + tpc_c_cplusplus/jbig2enc #三方库jbig2enc的目录结构如下 + ├── adapted #存放三方库适配需要的代码文件 + ├── docs #存放三方库相关文档的文件夹 + ├── BUILD.gn #构建脚本,支持rom包集成 + ├── bundle.json #三方库组件定义文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` +- 将三方库拷贝到OpenHarmony源码的third_party目录下 + ``` + cp ~/tpc_c_cplusplus/jbig2enc ~/openharmony/third_party -rf + ``` +### 准备三方库源码 + +- 下载三方库jbig2enc + +``` +cd ~/openharmony/third_party/jbig2enc #进入三方库目录 +git clone https://github.com/agl/jbig2enc.git -b 0.29 --depth=1 #下载三方库源码 +``` +- 下载依赖库leptonica + + 依赖库下载及适配参考:[leptonica的Rom集成](https://gitee.com/openharmony-sig/tpc_c_cplusplus/leptonica) + +## 系统Rom中引入三方库 + +准备完三方库代码后,我们需要将三方库加入到编译构建体系中。标准系统编译构建可以参考文档[标准系统编译构建指导](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Beta1/zh-cn/device-dev/subsystems/subsys-build-standard-large.md) +我们默认三方库是属于OpenHarmony的thirdparty子系统,如果需要自己定义子系统参考文档[如何为三方库组件中添加一个三方库](https://gitee.com/openharmony-sig/knowledge/blob/master/docs/openharmony_getstarted/port_thirdparty/README.md) +新增需要编译的组件,在OpenHarmony源码的vendor/hihope/rk3568/config.json文件中,新增需要编译的组件,如下代码段所示,在thirdparty子系统下面新增jbig2enc组件 + +``` + { + "subsystem": "thirdparty", + "components": [ + { + "component": "musl", + "features": [] + }, + { + "component": "jbig2enc", + "features": [] + } + ] + } + +``` +## 系统Rom中引入三方库测试程序 +如果需要编译测试用例,在OpenHarmony源码的vendor/hihope/rk3568/config.json文件,对应组件的features中打开编译选项,如下 +``` + { + "subsystem": "thirdparty", + "components": [ + { + "component": "musl", + "features": [] + }, + { + "component": "jbig2enc", + "features": ["enable_test=true"] + } + ] + } +``` +## 编译工程 +在OpenHarmony源码根目录下 +``` +cd ~/openharmony +``` +- 选择平台 + ``` + hb set #hb set 命令会列出所有可选平台,这里我们选择rk3568 + ``` +- 执行编译 + ``` + hb build --target-cpu arm #编译32位系统 + hb build --target-cpu arm64 #编译64位系统 + ``` +- 生成文件的路径,可执行文件和库文件都在out/rk3568/thirdparty/jbig2enc目录下,同时也打包到了镜像中 +## 运行效果 +将编译生成的库和测试文件放到板子上运行,为避免每次将文件推入设备都烧录整个镜像,我们使用hdc_std工具将文件推到开发板上 +- 首先将hdc_std工具编译出来 + 工具编译出来所在路径out/sdk/ohos-sdk/windows/toolchains/hdc_std.exe + + ``` + hb set #源码根目录下使用hb set 选择产品ohos-sdk + hb build #然后编译 + ``` + +- 将工具拷贝到Windows,可以为工具目录配置环境变量,也可以在工具所在目录打开windows命令行 + +- 将原生库测试需要的所有文件打包成jbig2enc.tar,并拷贝到windows下 + +- 将文件推送到开发板,在windows命令行进行如下操作 + ``` + hdc_std shell mount -oremount,rw / #修改系统权限为可读写 + hdc_std file send jbig2enc.tar / #将文件包推入开发板 + hdc_std shell #进入开发板 + tar xvf jbig2enc.tar #解压 + #注意需要将库拷贝到/system/lib 或者/system/lib64目录下 + ``` + +- 运行测试程序
+ 测试用例非常多,这里演示其中几个用例,如下图 + ![result](pic/result.png) +## 参考资料 +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) +- [如何为三方库组件中添加一个三方库](https://gitee.com/openharmony-sig/knowledge/blob/master/docs/openharmony_getstarted/port_thirdparty/README.md) +- [标准系统编译构建指导](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Beta1/zh-cn/device-dev/subsystems/subsys-build-standard-large.md) \ No newline at end of file