diff --git a/thirdparty/libheif/HPKBUILD b/thirdparty/libheif/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..a2ef30f6e9fdca1220016379ee04e0562cefdc01 --- /dev/null +++ b/thirdparty/libheif/HPKBUILD @@ -0,0 +1,87 @@ +# Contributor: Jeff Han +# Maintainer: Jeff Han +pkgname=libheif +pkgver=v1.15.2 +pkgrel=0 +pkgdesc="libheif is an HEIF and AVIF file format decoder and encoder." +url="https://github.com/strukturag/libheif" +archs=("armeabi-v7a" "arm64-v8a") +license=("GNU LESSER GENERAL PUBLIC LICENSE") +depends=("jpeg" "libpng") +makedepends=() + +source="https://github.com/strukturag/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +autounpack=true +downloadpackage=true +buildtools="configure" + +builddir=$pkgname-${pkgver:1} +packagename=$builddir.tar.gz + +source envset.sh +host= + +autogenflag=true + +prepare() { + if $autogenflag + then + cd $builddir + ./autogen.sh > `pwd`/build.log 2>&1 + autogenflag=false + cd $OLDPWD + fi + mkdir -p $builddir/$ARCH-build + if [ $ARCH == "armeabi-v7a" ] + then + setarm32ENV + host=arm-linux + export LDFLAGS="${OHOS_SDK}/native/llvm/lib/clang/$CLANG_VERSION/lib/arm-linux-ohos/a7_hard_neon-vfpv4/libclang_rt.builtins.a ${LDFLAGS}" + fi + if [ $ARCH == "arm64-v8a" ] + then + setarm64ENV + host=aarch64-linux + export LDFLAGS="${OHOS_SDK}/native/llvm/lib/clang/$CLANG_VERSION/lib/aarch64-linux-ohos/libclang_rt.builtins.a ${LDFLAGS}" + fi +} + +build() { + cd $builddir/$ARCH-build + # 不强依赖jpeg和libpng, 下方的写法能找到libpng但是找不到jpeg. 显示开启测试 + PKG_CONFIG_PATH="${pkgconfigpath}" libpng_CFLAGS="-I$LYCIUM_ROOT/usr/libpng/$ARCH/include" libpng_LIBS="-L$LYCIUM_ROOT/usr/libpng/$ARCH/lib -lpng" ../configure "$@" --host=$host --enable-tests --disable-go --disable-gdk-pixbuf --disable-aom --disable-libde265 --disable-x265 --disable-rav1e --disable-dav1d --enable-svt > `pwd`/build.log 2>&1 + make -j4 >> `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir/$ARCH-build + make install >> `pwd`/build.log 2>&1 + cd $OLDPWD + if [ $ARCH == "armeabi-v7a" ] + then + unsetarm32ENV + fi + if [ $ARCH == "arm64-v8a" ] + then + unsetarm64ENV + fi + unset host +} + +check() { + cd $builddir/$ARCH-build/tests + sed -i '/.*test-local: heif-unit-tests/c\test-local: #heif-unit-tests' Makefile + cd $OLDPWD + echo "The test must be on an OpenHarmony device!" + # real test CMD + # make -C tests test-local +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/$packagename +} diff --git a/thirdparty/libheif/README.OpenSource b/thirdparty/libheif/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..82754eafe8ab6dc65563f868be1fed5d423075d2 --- /dev/null +++ b/thirdparty/libheif/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "libheif", + "License": "GNU LESSER GENERAL PUBLIC LICENSE", + "License File": "COPYING", + "Version Number": "v1.15.2", + "Owner": "chenbaodi@huawei.com", + "Upstream URL": "https://github.com/strukturag/libheif/archive/refs/tags/v1.15.2.tar.gz", + "Description": "libheif is an HEIF and AVIF file format decoder and encoder." + } +] diff --git a/thirdparty/libheif/README_zh.md b/thirdparty/libheif/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..f30ae7f241281c8f0d7c3f40a77f60b0f4676f38 --- /dev/null +++ b/thirdparty/libheif/README_zh.md @@ -0,0 +1,12 @@ +# libheif三方库说明 +## 功能简介 +libheif是HEIF和AVIF文件格式编解码三方库。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:v1.15.2 +- 当前适配的功能:支持HEIF和AVIF文件格式编解码 +- [GNU LESSER GENERAL PUBLIC LICENSE](https://github.com/strukturag/libheif/blob/master/COPYING) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/libheif/SHA512SUM b/thirdparty/libheif/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..c821ed04d5f638afbc3a37d7986b6875c5d88b7d --- /dev/null +++ b/thirdparty/libheif/SHA512SUM @@ -0,0 +1 @@ +075a7aba14be6abcd8ff129ba94f6195cd5c1a4197a96f3214c323e0028f1b4810e8ea54ecb5c5711f6ebab8be92087c06ca3a1a222ebe9047fc1323ab6e56e5 libheif-1.15.2.tar.gz diff --git a/thirdparty/libheif/docs/hap_integrate.md b/thirdparty/libheif/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..02ce503d84d15fedc5aaa9ce3b6e7f6958421f8f --- /dev/null +++ b/thirdparty/libheif/docs/hap_integrate.md @@ -0,0 +1,97 @@ +# libheif 集成到应用hap + +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 + +## 开发环境 + +- ubuntu20.04 +- [OpenHarmony3.2Release镜像](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fdayu200_standard_arm32.tar.gz) +- [ohos_sdk_public 3.2.11.9 (API Version 9 Release)](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fohos-sdk-windows_linux-public.tar.gz) +- [DevEco Studio 3.1 Beta2](https://gitee.com/link?target=https%3A%2F%2Fcontentcenter-vali-drcn.dbankcdn.cn%2Fpvt_2%2FDeveloperAlliance_package_901_9%2Ff3%2Fv3%2FuJyuq3syQ2ak4hE1QZmAug%2Fdevecostudio-windows-3.1.0.400.zip%3FHW-CC-KV%3DV1%26HW-CC-Date%3D20230408T013335Z%26HW-CC-Expire%3D315360000%26HW-CC-Sign%3D96262721EDC9B34E6F62E66884AB7AE2A94C2A7B8C28D6F7FC891F46EB211A70) +- [准备三方库构建环境](../../../tools/README.md#编译环境准备) +- [准备三方库测试环境](../../../tools/README.md#ci环境准备) + +## 编译三方库 + +- 下载本仓库 + + ```shell + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ```shell + tpc_c_cplusplus/thirdparty/libheif #三方库libheif的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将libheif拷贝至tools/main目录下 + + ```shell + cd tpc_c_cplusplus + cp thirdparty/libheif tools/main -rf + ``` + +- 在tools目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + + ```shell + cd tools + ./build.sh libheif + ``` + +- 三方库头文件及生成的库 + + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ```shell + libheif/arm64-v8a libheif/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 +   + + ![thirdparty_install_dir](pic/libheif_install_dir.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + + ```shell + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libheif/${OHOS_ARCH}/lib/libheif.a) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libheif/${OHOS_ARCH}/include) + ``` + + ![libheif_usage](pic/libheif_usage.png) + +## 测试三方库 + +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行 +``` + cd tests + sed -i '/.*test-local: heif-unit-tests/c\test-local: #heif-unit-tests' Makefile + cd .. + make -C tests test-local +``` +(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + + ![libheif_test](pic/libheif_test.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) +- [通过DevEco Studio开发一个NAPI工程](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md) \ No newline at end of file diff --git a/thirdparty/libheif/docs/pic/libheif_install_dir.png b/thirdparty/libheif/docs/pic/libheif_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..64216d524eeed9af02d79543db5138934a9e1df5 Binary files /dev/null and b/thirdparty/libheif/docs/pic/libheif_install_dir.png differ diff --git a/thirdparty/libheif/docs/pic/libheif_test.png b/thirdparty/libheif/docs/pic/libheif_test.png new file mode 100644 index 0000000000000000000000000000000000000000..af402ea5cf10c0ed6ea19220c8440eae8a87cbfc Binary files /dev/null and b/thirdparty/libheif/docs/pic/libheif_test.png differ diff --git a/thirdparty/libheif/docs/pic/libheif_usage.png b/thirdparty/libheif/docs/pic/libheif_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..c78466b047f1f329a55f5e9692a5fc8e1d10b61e Binary files /dev/null and b/thirdparty/libheif/docs/pic/libheif_usage.png differ