diff --git a/openjpeg/BUILD.gn b/openjpeg/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c1ae3597cb0acb65523e703a584f8f2ebc7f6885 --- /dev/null +++ b/openjpeg/BUILD.gn @@ -0,0 +1,244 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. +if (defined(ohos_lite)) { + import("//build/lite/config/component/lite_component.gni") +} else { + import("//build/ohos.gni") +} + +config("openjpeg_cflag_config") { + cflags = [ + "-Wno-unused-function", + ] +} + +ohos_shared_library("openjp2") { + sources = [ + "./openjpeg/src/lib/openjp2/thread.c", + "./openjpeg/src/lib/openjp2/bio.c", + "./openjpeg/src/lib/openjp2/cio.c", + "./openjpeg/src/lib/openjp2/dwt.c", + "./openjpeg/src/lib/openjp2/event.c", + "./openjpeg/src/lib/openjp2/ht_dec.c", + "./openjpeg/src/lib/openjp2/image.c", + "./openjpeg/src/lib/openjp2/invert.c", + "./openjpeg/src/lib/openjp2/j2k.c", + "./openjpeg/src/lib/openjp2/jp2.c", + "./openjpeg/src/lib/openjp2/mct.c", + "./openjpeg/src/lib/openjp2/mqc.c", + "./openjpeg/src/lib/openjp2/openjpeg.c", + "./openjpeg/src/lib/openjp2/opj_clock.c", + "./openjpeg/src/lib/openjp2/pi.c", + "./openjpeg/src/lib/openjp2/t1.c", + "./openjpeg/src/lib/openjp2/t2.c", + "./openjpeg/src/lib/openjp2/tcd.c", + "./openjpeg/src/lib/openjp2/tgt.c", + "./openjpeg/src/lib/openjp2/function_list.c", + "./openjpeg/src/lib/openjp2/opj_malloc.c", + "./openjpeg/src/lib/openjp2/sparse_array.c", + ] + + include_dirs = [ + "./openjpeg/src/lib/openjp2", + "./adapter/include", + ] + + configs = [ + ":openjpeg_cflag_config" + ] + + part_name = "openjpeg" +} + +config("openjpeg_test_config") { + cflags = [ + "-Wno-macro-redefined", + "-Wno-unused-variable" + ] + include_dirs = [ + "./openjpeg/src/lib/openjp2/", + "./openjpeg/src/bin/common/", + "./openjpeg/src/lib/jp2/", + "./openjpeg/src/bin/jp2/", + "./adapter/include/", + "//third_party/libtiff/libtiff/" + ] +} + +ohos_executable("test_tile_decoder") { + sources = [ + "./openjpeg/tests/test_tile_decoder.c", + "./openjpeg/src/bin/common/opj_getopt.c", + ] + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":openjp2", + "//third_party/libtiff:libtiff_shared", + ] + part_name = "openjpeg" +} + +ohos_executable("test_tile_encoder") { + sources = [ + "./openjpeg/tests/test_tile_encoder.c", + "./openjpeg/src/bin/common/opj_getopt.c", + ] + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":openjp2", + "//third_party/libtiff:libtiff_shared", + ] + part_name = "openjpeg" +} + + +ohos_executable("compare_dump_files") { + sources = [ + "./openjpeg/tests/compare_dump_files.c", + "./openjpeg/src/bin/common/opj_getopt.c", + ] + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":openjp2", + "//third_party/libtiff:libtiff_shared", + ] + part_name = "openjpeg" +} + +ohos_executable("compare_images") { + sources = [ + "./openjpeg/tests/compare_images.c", + "./openjpeg/src/bin/jp2/convert.c", + "./openjpeg/src/bin/jp2/converttif.c", + "./openjpeg/src/bin/common/opj_getopt.c", + ] + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":openjp2", + "//third_party/libtiff:libtiff_shared", + ] + part_name = "openjpeg" +} + +ohos_executable("compare_raw_files") { + sources = [ + "./openjpeg/tests/compare_raw_files.c", + "./openjpeg/src/bin/common/opj_getopt.c", + ] + + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":openjp2", + "//third_party/libtiff:libtiff_shared", + ] + part_name = "openjpeg" +} + +ohos_executable("j2k_random_tile_access") { + sources = [ + "./openjpeg/tests/j2k_random_tile_access.c", + "./openjpeg/src/bin/common/opj_getopt.c", + ] + + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":openjp2", + "//third_party/libtiff:libtiff_shared", + ] + part_name = "openjpeg" +} + +ohos_executable("pdf2jp2") { + sources = [ + "./openjpeg/tests/pdf2jp2.c", + "./openjpeg/src/bin/common/opj_getopt.c", + ] + + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":openjp2", + "//third_party/libtiff:libtiff_shared", + ] + part_name = "openjpeg" +} + +ohos_executable("test_decode_area") { + sources = [ + "./openjpeg/tests/test_decode_area.c", + "./openjpeg/src/bin/common/opj_getopt.c", + ] + + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":openjp2", + "//third_party/libtiff:libtiff_shared", + ] + part_name = "openjpeg" +} + +ohos_executable("ppm2rgb3") { + sources = [ + "./openjpeg/tests/ppm2rgb3.c", + "./openjpeg/src/bin/common/opj_getopt.c", + ] + + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":openjp2", + "//third_party/libtiff:libtiff_shared", + ] + part_name = "openjpeg" +} + +ohos_executable("testempty0") { + sources = [ + "./openjpeg/tests/unit/testempty0.c", + ] + + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":openjp2", + ] + part_name = "openjpeg" +} + + +ohos_executable("testempty1") { + sources = [ + "./openjpeg/tests/unit/testempty1.c", + ] + + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":openjp2", + ] + part_name = "openjpeg" +} + +ohos_executable("testempty2") { + sources = [ + "./openjpeg/tests/unit/testempty2.c", + ] + + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":openjp2", + ] + part_name = "openjpeg" +} + +group("openjpeg_test") { + deps = [ + ":test_tile_decoder", + ":test_tile_encoder", + ":compare_dump_files", + ":compare_images", + ":compare_raw_files", + ":j2k_random_tile_access", + ":pdf2jp2", + ":test_decode_area", + ":ppm2rgb3", + ":testempty0", + ":testempty1", + ":testempty2", + ] +} diff --git a/openjpeg/README.OpenSource b/openjpeg/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..5090dee175ef68348e68bfc7a0bb7b6749644f84 --- /dev/null +++ b/openjpeg/README.OpenSource @@ -0,0 +1,20 @@ +[ + { + "Name": "openJPEG", + "License": "Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium", + "License": "Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium", + "License": "Copyright (c) 2002-2014, Professor Benoit Macq", + "License": "Copyright (c) 2003-2014, Antonin Descampe", + "License": "Copyright (c) 2003-2009, Francois-Olivier Devaux", + "License": "Copyright (c) 2005, Herve Drolon, FreeImage Team", + "License": "Copyright (c) 2002-2003, Yannick Verschueren", + "License": "Copyright (c) 2001-2003, David Janssens", + "License": "Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France", + "License": "Copyright (c) 2012, CS Systemes d'Information, France", + "License File": "LICENSE.TXT", + "Version Number": "2.5", + "Owner": "yuguans@huawei.com", + "Upstream URL": "https://github.com/uclouvain/openjpeg", + "Description": "OpenJPEG is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the use of JPEG 2000, a still-image compression standard from the Joint Photographic Experts Group (JPEG). Since April 2015, it is officially recognized by ISO/IEC and ITU-T as a JPEG 2000 Reference Software." + } +] diff --git a/openjpeg/README_zh.md b/openjpeg/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..aa72722be1694a5e0f917decfdf4ef8696b82c6e --- /dev/null +++ b/openjpeg/README_zh.md @@ -0,0 +1,19 @@ +# openjpeg 三方库说明 +## 功能简介 +OpenJPEG 是用 C 语言编写的开源 JPEG 2000 编解码器。 + + + +## 使用约束 + +- ROM版本:OpenHarmony3.2 beta1 +- 三方库版本:v2.5.0 +- 当前适配的功能:[JPEG 2000](https://jpeg.org/jpeg2000/) 图像编解码 +- License:[The 2-Clause BSD License](https://github.com/uclouvain/openjpeg/blob/v2.5.0/LICENSE) + + + +## 集成方式 + ++ [系统Rom包集成](./docs/rom_integrate.md) + diff --git a/openjpeg/adapter/include/opj_apps_config.h b/openjpeg/adapter/include/opj_apps_config.h new file mode 100644 index 0000000000000000000000000000000000000000..1832c5a5f2316ea217374b21dd457b80135c9416 --- /dev/null +++ b/openjpeg/adapter/include/opj_apps_config.h @@ -0,0 +1,15 @@ +#include "opj_config_private.h" + +/* create opj_apps_config.h for CMake */ + +#define OPJ_HAVE_LIBPNG +#define OPJ_HAVE_PNG_H +#define OPJ_HAVE_LIBTIFF +#define OPJ_HAVE_TIFF_H + +/* #undef OPJ_HAVE_LIBLCMS1 */ +/* #undef OPJ_HAVE_LIBLCMS2 */ +/* #undef OPJ_HAVE_LCMS1_H */ +/* #undef OPJ_HAVE_LCMS2_H */ + + diff --git a/openjpeg/adapter/include/opj_config.h b/openjpeg/adapter/include/opj_config.h new file mode 100644 index 0000000000000000000000000000000000000000..6eae46c3452e28c0c13bed9da898cce0e99ce12a --- /dev/null +++ b/openjpeg/adapter/include/opj_config.h @@ -0,0 +1,10 @@ +/* create opj_config.h for CMake */ +#define OPJ_HAVE_STDINT_H 1 + +/*--------------------------------------------------------------------------*/ +/* OpenJPEG Versioning */ + +/* Version number. */ +#define OPJ_VERSION_MAJOR 2 +#define OPJ_VERSION_MINOR 5 +#define OPJ_VERSION_BUILD 0 diff --git a/openjpeg/adapter/include/opj_config_private.h b/openjpeg/adapter/include/opj_config_private.h new file mode 100644 index 0000000000000000000000000000000000000000..3aad25e618b008e609e5a6f63245946b24672a4b --- /dev/null +++ b/openjpeg/adapter/include/opj_config_private.h @@ -0,0 +1,49 @@ +/* create opj_config_private.h for CMake */ +#define OPJ_HAVE_INTTYPES_H 1 + +#define OPJ_PACKAGE_VERSION "2.5.0" + +/* Not used by openjp2*/ +/*#define HAVE_MEMORY_H 1*/ +/*#define HAVE_STDLIB_H 1*/ +/*#define HAVE_STRINGS_H 1*/ +/*#define HAVE_STRING_H 1*/ +/*#define HAVE_SYS_STAT_H 1*/ +/*#define HAVE_SYS_TYPES_H 1 */ +/*#define HAVE_UNISTD_H 1*/ + +/* #undef _LARGEFILE_SOURCE */ +/* #undef _LARGE_FILES */ +/* #undef _FILE_OFFSET_BITS */ +#define OPJ_HAVE_FSEEKO ON + +/* find whether or not have */ +#define OPJ_HAVE_MALLOC_H +/* check if function `aligned_alloc` exists */ +/* #undef OPJ_HAVE_ALIGNED_ALLOC */ +/* check if function `_aligned_malloc` exists */ +/* #undef OPJ_HAVE__ALIGNED_MALLOC */ +/* check if function `memalign` exists */ +#define OPJ_HAVE_MEMALIGN +/* check if function `posix_memalign` exists */ +#define OPJ_HAVE_POSIX_MEMALIGN + +#if !defined(_POSIX_C_SOURCE) +#if defined(OPJ_HAVE_FSEEKO) || defined(OPJ_HAVE_POSIX_MEMALIGN) +/* Get declarations of fseeko, ftello, posix_memalign. */ +#define _POSIX_C_SOURCE 200112L +#endif +#endif + +/* Byte order. */ +/* All compilers that support Mac OS X define either __BIG_ENDIAN__ or +__LITTLE_ENDIAN__ to match the endianness of the architecture being +compiled for. This is not necessarily the same as the architecture of the +machine doing the building. In order to support Universal Binaries on +Mac OS X, we prefer those defines to decide the endianness. +On other platforms we use the result of the TRY_RUN. */ +#if !defined(__APPLE__) +/* #undef OPJ_BIG_ENDIAN */ +#elif defined(__BIG_ENDIAN__) +# define OPJ_BIG_ENDIAN +#endif diff --git a/openjpeg/adapter/script/test_open_jpeg.sh b/openjpeg/adapter/script/test_open_jpeg.sh new file mode 100644 index 0000000000000000000000000000000000000000..72623c9af56a5a2d8bb909855bfaa87a2de93f40 --- /dev/null +++ b/openjpeg/adapter/script/test_open_jpeg.sh @@ -0,0 +1,153 @@ +#!/bin/bash + +j2kRandomTileAccess="j2k_random_tile_access" +testDecodeArea="test_decode_area" +testTileEncoder="test_tile_encoder" +testTileDecoder="test_tile_decoder" +testempty0="testempty0" +testempty1="testempty1" +testempty2="testempty2" + + + +function exe() +{ +exe=$1 +num=$# + + if [ $exe == $j2kRandomTileAccess ] + then + tag=$2 + echo "tag= $tag,exe = $exe" + + if [ -e $tag ] + then + chmod +x $exe + ./$exe $tag + else + echo "$tag is not exist" + fi + elif [ $exe == $testDecodeArea ] + then + if [ $num == 3 ] + then + tag=$2 + flag=$1 + if [ -e $tag ] + then + ./$exe $flag $tag + fi + elif [ $num == 6 ] + then + tag=$5 + if [ -e $tag ] + then + echo "./$*" + ./$* + fi + else + echo "exe $exe cmd failed!" + fi + elif [ $exe == $testTileEncoder ] + then + if [ $num == 1 ] + then + ./$exe + else + echo "./$*" + ./$* + fi + elif [ $exe == $testTileDecoder ] + then + echo "$*" + if [ $num == 1 ] + then + ./$* + elif [ $num == 5 ] + then + if [ -e $5 ] + then + ./$* + fi + fi + else + ./$exe + fi +} + + +function check_result() +{ +exe="md5sum" +tag=$1 +sum=$2 + if [ -e $tag ] + then + tmp=`md5sum $tag` + result=${tmp%% *} + + if [ $result == $sum ] + then + echo "test ok!" + fi + fi +} + + + +function run_test() +{ + exe $testTileEncoder + check_result test.j2k d50d345b669102ce18f7da78dc076546 + exe $testTileEncoder 3 2048 2048 1024 1024 8 1 tte1.j2k + check_result tte1.j2k dcb7dbfc7a3f552f5f01c35fb077a731 + exe $testTileEncoder 3 2048 2048 1024 1024 8 1 tte2.jp2 + check_result tte2.jp2 433f8b10a513510f490651d51637b1c0 + exe $testTileEncoder 1 2048 2048 1024 1024 8 1 tte3.j2k + check_result tte3.j2k 92f6fa2693a01ea0e184a9cb79261935 + exe $testTileEncoder 1 256 256 128 128 8 0 tte4.j2k + check_result tte4.j2k ddbd0406e23e35d9d76d53eec0aba6f7 + exe $testTileEncoder 1 512 512 256 256 8 0 tte5.j2k + check_result tte5.j2k f41e019f8a879220769b3122723448f1 + exe $testTileDecoder + check_result test.j2k d50d345b669102ce18f7da78dc076546 + exe $testTileDecoder 0 0 1024 1024 tte1.j2k + check_result tte1.j2k dcb7dbfc7a3f552f5f01c35fb077a731 + exe $testTileDecoder 0 0 1024 1024 tte2.jp2 + check_result tte2.jp2 433f8b10a513510f490651d51637b1c0 + exe $j2kRandomTileAccess tte1.j2k + exe $j2kRandomTileAccess tte2.jp2 + exe $j2kRandomTileAccess tte3.j2k + exe $j2kRandomTileAccess tte4.j2k + exe $j2kRandomTileAccess tte5.j2k + exe $testTileEncoder 1 256 256 32 32 8 0 reversible_no_precinct.j2k 4 4 3 0 0 0 + check_result reversible_no_precinct.j2k 5a03aed80730bb312b93a373af2619a7 + exe $testDecodeArea -q reversible_no_precinct.j2k + check_result reversible_no_precinct.j2k 5a03aed80730bb312b93a373af2619a7 + exe $testTileEncoder 1 203 201 17 19 8 0 reversible_203_201_17_19_no_precinct.j2k 4 4 3 0 0 0 + check_result reversible_203_201_17_19_no_precinct.j2k 080fe377819420d1bbac8c2a209c3faf + exe $testDecodeArea -q reversible_203_201_17_19_no_precinct.j2k + check_result reversible_203_201_17_19_no_precinct.j2k 080fe377819420d1bbac8c2a209c3faf + exe $testTileEncoder 1 256 256 32 32 8 0 reversible_with_precinct.j2k 4 4 3 0 0 0 16 16 + check_result reversible_with_precinct.j2k 2d7074173d443ad9e348b9f4db955994 + exe $testDecodeArea -q reversible_with_precinct.j2k + check_result reversible_with_precinct.j2k 2d7074173d443ad9e348b9f4db955994 + exe $testTileEncoder 1 256 256 32 32 8 1 irreversible_no_precinct.j2k 4 4 3 0 0 0 + check_result irreversible_no_precinct.j2k 9e8c1ac0e7c920e559a8deb74cc2e094 + exe $testDecodeArea -q irreversible_no_precinct.j2k + check_result irreversible_no_precinct.j2k 9e8c1ac0e7c920e559a8deb74cc2e094 + exe $testTileEncoder 1 203 201 17 19 8 1 irreversible_203_201_17_19_no_precinct.j2k 4 4 3 0 0 0 + check_result irreversible_203_201_17_19_no_precinct.j2k d58da7bdddbbeb733474f30757a31a87 + exe $testDecodeArea -q irreversible_203_201_17_19_no_precinct.j2k + heck_result irreversible_203_201_17_19_no_precinct.j2k d58da7bdddbbeb733474f30757a31a87 + exe $testTileEncoder 1 256 256 256 256 8 0 tda_single_tile.j2k + check_result tda_single_tile.j2k 35737f347486a97cbdd9a545df382584 + exe $testDecodeArea -q -strip_height 3 -strip_check tda_single_tile.j2k + check_result tda_single_tile.j2k 35737f347486a97cbdd9a545df382584 + exe $testempty0 + exe $testempty1 + exe $testempty2 +} + +run_test + diff --git a/openjpeg/docs/media/running_result.png b/openjpeg/docs/media/running_result.png new file mode 100644 index 0000000000000000000000000000000000000000..1769813e9f02e2a01d07e2288e8dccd6aaf3f356 Binary files /dev/null and b/openjpeg/docs/media/running_result.png differ diff --git a/openjpeg/docs/rom_integrate.md b/openjpeg/docs/rom_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..0a16b2ab273e310ed8019b6da5c664545aee36b4 --- /dev/null +++ b/openjpeg/docs/rom_integrate.md @@ -0,0 +1,256 @@ +# openjpeg如何集成到系统Rom + +## 准备源码工程 + +本库是基于OpenHarmony 3.2 beta1版本,在润和RK3568开发板上验证的。如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 + + + +### 准备系统Rom源码 + +源码获取方法请参照:[OpenHarmony3.2beta1源码下载](https://gitee.com/openharmony/docs/blob/OpenHarmony-v3.2-Beta1/zh-cn/release-notes/OpenHarmony-v3.2-beta1.md#源码获取) + + + +### 增加构建脚本及配置文件 + +- 下载本仓库代码 + + ``` + cd ~/ + git clone git@gitee.com:openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 仓库代码目录结构说明 + + ``` + cd ~/tpc_c_cplusplus/openjpeg/ # 进入到仓库代码库目录 + ``` + + ``` + openjpeg + |-- BUILD.gn # 编译构建脚本 + |-- ohos.build # 组件定义文件 + |-- README_zh.md # openjpeg 主页 + |-- README.OpenSource # openjpeg 源码的下载地址,版本,license等信息 + |-- docs # 存放 openjpeg 相关文档的文件夹 + |-- adapter # 存放三方库适配需要的代码文件 + ``` + +- 将本仓库文件夹拷贝到third_party下 + + ``` + cp -arf ~/tpc_c_cplusplus/openjpeg ~/OpenHarmony/third_party + ``` + + + +### 准备三方库源码 + +- 四方库依赖 + + openjpeg三方库的测试依赖[libtiff](../../libtiff),点击链接跳转至libtiff的Rom集成方法。 + +- 三方库源码下载 + + 将openjpeg-2.5.0源码下载到openjpeg目录并将其解压出来。 + + ``` + # 进入到openjpeg目录 + cd ~/OpenHarmony/third_party/openjpeg + + # 下载三方库 + wget https://github.com/uclouvain/openjpeg/archive/refs/tags/v2.5.0.zip + + # 解压库 + unzip v2.5.0.zip + + # 修改三方库源码文件夹名称 + mv openjpeg-2.5.0 openjpeg + + # 删除压缩包 + rm v2.5.0.zip + ``` + + + +## 系统Rom中引入三方库 + +准备完三方库代码后,我们需要将三方库加入到编译构建体系中。标准系统编译构建可以参考文档[标准系统编译构建指导](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Beta1/zh-cn/device-dev/subsystems/subsys-build-standard-large.md)。 + +我们默认三方库是属于OpenHarmony的thirdparty子系统,如果需要自己定义子系统参考文档[如何为三方库组件中添加一个三方库](./add_thirdparty_component.md)。 + +三方库子系统中添加组件 + +``` +# 打开//vendor/hihope/rk356/config.json文件,找到thirdparty子系统并添加一个openjpeg的组件 +{ + "subsystem": "thirdparty", + "components": [ + { + "component": "musl", + "features": [] + }, + { + "component": "openjpeg", + "features": [] + } + ] +}, +``` + + + +## 系统Rom中引入三方库测试程序 + +openjpeg原生库提供了测试程序且已完成了gn的适配,我们只需要在三方库目录下的ohos.build中添加测试程序的依赖即可,如: + +``` +{ + "subsystem": "thirdparty", + "parts":{ + "openjpeg": { + "module_list": [ + "//third_party/openjpeg:openjpeg_test" + ] + } + } +} +``` + + + +## 编译工程 + +- 进入源码根目录 + + ``` + cd ~/openharmony + ``` + +- 选择产品 + + ``` + # 运行hb set后会出现产品列表,在此我们选择 rk3568 + hb set + ``` + +- 运行编译 + + ``` + # --target-cpu arm 编译32位系统(未配置默认编译32位),如果需要编译64位的需要改为--target-cpu arm64 + # -f 全量编译,不加-f则为增量编译。每次设置完产品后建议进行全量编译。 + hb build --target-cpu arm -f + ``` + +- 查证编译结果 + + 正常编译完后会在out/rk3568/thirdparty/openjpeg/目录下生成 libopenjp2.z.so 动态库 和 test_tile_encoder 等 openjpeg_test 所包含的测试用可执行程序。同时这些程序也会打包到镜像中。 + + ``` + # 确认是否成功编译 openjp2 动态库 和 openjpeg_test 包含的可执行文件 + ls out/rk3568/thirdparty/openjpeg/ + ``` + + + +## 运行效果 + +- PC端hdc_std工具编译和使用 + + 将编译生成的库和测试文件推送到板子上运行,为避免每次将文件推入设备都烧录整个镜像,我们使用hdc_std工具将文件推送到开发板上。 + + 1. hdc_std工具编译 + + 成功执行如下指令后,hdc_std工具的路径为:out/sdk/ohos-sdk/windows/toolchains/hdc_std.exe。 + + ``` + # 源码根目录下使用hb set 选择产品ohos-sdk + hb set + + # 执行编译 + hb build + ``` + + 2. hdc_std工具使用 + + 将工具拷贝到Windows,可以为工具目录配置环境变量,也可以在工具所在目录打开windows命令行。 + + ``` + # 在工具所在目录打开windows命令行,输入.\hdc_std.exe -h查看工具使用说明 + D:\RKDevTool_Release_v2.94>.\hdc_std.exe -h + + OpenHarmony device connector(HDC) ... + + ---------------------------------global commands:---------------------------------- + -h/help - Print hdc help + -v/version - Print hdc version + -l 0-5 - Set runtime loglevel + -t connectkey - Use device with given connect key + ...... + ``` + +- 三方库运行环境打包和推送 + + 1. 将原生库测试需要的所有文件打包成openjpeg.tar.gz,并拷贝到windows系统下 + + ``` + # 进入用户目录 + cd ~ + + # 创建打包文件夹 + mkdir openjpeg + + # 复制测试脚本 + cp ~/openharmony/third_party/openjpeg/adapter/script/test_open_jpeg.sh openjpeg/ + + # 复制可执行程序和动态库 + cp ~/openharmony/out/rk3568/thirdparty/openjpeg/* openjpeg/ + + # 打包运行环境 + tar -zcvf openjpeg.tar.gz openjpeg/ + ``` + + 2. 将文件推送到开发板,在windows命令行进行如下操作 + + ``` + # 修改开发板系统文件读写权限 + hdc_std.exe shell mount -o remount,rw / + + # 推送文件到开发板系统 + hdc_std.exe file send .\openjpeg.tar.gz /data/ + + # 进入开发板系统 + hdc_std.exe shell + + # 解压文件包 + tar -zxvf openjpeg.tar.gz + + # 修改文件权限 + chmod 777 -R openjpeg/ + + # 将库文件拷贝到系统lib目录 + cp libopenjp2.z.so /system/lib/ + ``` + +- 运行测试程序 + + 1. 执行如下命令运行测试脚本,测试脚本会调用测试程序并将运行信息打印出来。 + + ``` + sh test_open_jpeg.sh + ``` + + 2. 运行中的日志信息会实时打印在终端,若日志信息中所有测试项目为test_ok,则说明通过了全部的测试项目。 + + ![image-20220922143536085](./media/running_result.png) + + + +## 参考资料 + +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 +- [OpenHarmony3.2beta1](https://gitee.com/openharmony/docs/blob/OpenHarmony-v3.2-Beta1/zh-cn/release-notes/OpenHarmony-v3.2-beta1.md)。 +- [OpenHarmony三方库组织地址](https://gitee.com/openharmony-tpc)。 +- [知识体系](https://gitee.com/openharmony-sig/knowledge)。 + diff --git a/openjpeg/ohos.build b/openjpeg/ohos.build new file mode 100644 index 0000000000000000000000000000000000000000..e48fa8b2af5ce3a1308181fd774ff6fced47e05e --- /dev/null +++ b/openjpeg/ohos.build @@ -0,0 +1,10 @@ +{ + "subsystem": "thirdparty", + "parts":{ + "openjpeg": { + "module_list": [ + "//third_party/openjpeg:openjp2" + ] + } + } +} \ No newline at end of file