diff --git a/openjpeg/BUILD.gn b/openjpeg/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..7bbfed90fd2cc7d5fb89b608a867926ee343ead5 --- /dev/null +++ b/openjpeg/BUILD.gn @@ -0,0 +1,360 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# 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") + +declare_args() { + enable_openjpeg_test = false +} + +config("tiff_cflag_config") { + cflags = [ + "-Wno-unused-function", + "-D_FILE_OFFSET_BITS=64", + "-Wno-format", + "-Wno-misleading-indentation", + ] +} + +ohos_static_library("tiff") { + sources = [ + "openjpeg/thirdparty/libtiff/tif_aux.c", + "openjpeg/thirdparty/libtiff/tif_close.c", + "openjpeg/thirdparty/libtiff/tif_codec.c", + "openjpeg/thirdparty/libtiff/tif_color.c", + "openjpeg/thirdparty/libtiff/tif_compress.c", + "openjpeg/thirdparty/libtiff/tif_dir.c", + "openjpeg/thirdparty/libtiff/tif_dirinfo.c", + "openjpeg/thirdparty/libtiff/tif_dirread.c", + "openjpeg/thirdparty/libtiff/tif_dirwrite.c", + "openjpeg/thirdparty/libtiff/tif_dumpmode.c", + "openjpeg/thirdparty/libtiff/tif_error.c", + "openjpeg/thirdparty/libtiff/tif_extension.c", + "openjpeg/thirdparty/libtiff/tif_fax3.c", + "openjpeg/thirdparty/libtiff/tif_fax3sm.c", + "openjpeg/thirdparty/libtiff/tif_flush.c", + "openjpeg/thirdparty/libtiff/tif_getimage.c", + "openjpeg/thirdparty/libtiff/tif_jbig.c", + "openjpeg/thirdparty/libtiff/tif_jpeg.c", + "openjpeg/thirdparty/libtiff/tif_jpeg_12.c", + "openjpeg/thirdparty/libtiff/tif_luv.c", + "openjpeg/thirdparty/libtiff/tif_lzma.c", + "openjpeg/thirdparty/libtiff/tif_lzw.c", + "openjpeg/thirdparty/libtiff/tif_next.c", + "openjpeg/thirdparty/libtiff/tif_ojpeg.c", + "openjpeg/thirdparty/libtiff/tif_open.c", + "openjpeg/thirdparty/libtiff/tif_packbits.c", + "openjpeg/thirdparty/libtiff/tif_pixarlog.c", + "openjpeg/thirdparty/libtiff/tif_predict.c", + "openjpeg/thirdparty/libtiff/tif_print.c", + "openjpeg/thirdparty/libtiff/tif_read.c", + "openjpeg/thirdparty/libtiff/tif_strip.c", + "openjpeg/thirdparty/libtiff/tif_swab.c", + "openjpeg/thirdparty/libtiff/tif_thunder.c", + "openjpeg/thirdparty/libtiff/tif_tile.c", + "openjpeg/thirdparty/libtiff/tif_unix.c", + "openjpeg/thirdparty/libtiff/tif_version.c", + "openjpeg/thirdparty/libtiff/tif_warning.c", + "openjpeg/thirdparty/libtiff/tif_write.c", + "openjpeg/thirdparty/libtiff/tif_zip.c", + ] + include_dirs = [ + "./openjpeg/thirdparty/libtiff", + "./adapter/include/tiff", + ] + configs = [ ":tiff_cflag_config" ] +} + +config("lcms2_cflag_config") { + cflags = [ "-Wno-unused-function" ] +} + +ohos_static_library("lcms2") { + sources = [ + "./openjpeg/thirdparty/liblcms2/src/cmsalpha.c", + "./openjpeg/thirdparty/liblcms2/src/cmscam02.c", + "./openjpeg/thirdparty/liblcms2/src/cmscgats.c", + "./openjpeg/thirdparty/liblcms2/src/cmscnvrt.c", + "./openjpeg/thirdparty/liblcms2/src/cmserr.c", + "./openjpeg/thirdparty/liblcms2/src/cmsgamma.c", + "./openjpeg/thirdparty/liblcms2/src/cmsgmt.c", + "./openjpeg/thirdparty/liblcms2/src/cmshalf.c", + "./openjpeg/thirdparty/liblcms2/src/cmsintrp.c", + "./openjpeg/thirdparty/liblcms2/src/cmsio0.c", + "./openjpeg/thirdparty/liblcms2/src/cmsio1.c", + "./openjpeg/thirdparty/liblcms2/src/cmslut.c", + "./openjpeg/thirdparty/liblcms2/src/cmsmd5.c", + "./openjpeg/thirdparty/liblcms2/src/cmsmtrx.c", + "./openjpeg/thirdparty/liblcms2/src/cmsnamed.c", + "./openjpeg/thirdparty/liblcms2/src/cmsopt.c", + "./openjpeg/thirdparty/liblcms2/src/cmspack.c", + "./openjpeg/thirdparty/liblcms2/src/cmspcs.c", + "./openjpeg/thirdparty/liblcms2/src/cmsplugin.c", + "./openjpeg/thirdparty/liblcms2/src/cmsps2.c", + "./openjpeg/thirdparty/liblcms2/src/cmssamp.c", + "./openjpeg/thirdparty/liblcms2/src/cmssm.c", + "./openjpeg/thirdparty/liblcms2/src/cmstypes.c", + "./openjpeg/thirdparty/liblcms2/src/cmsvirt.c", + "./openjpeg/thirdparty/liblcms2/src/cmswtpnt.c", + "./openjpeg/thirdparty/liblcms2/src/cmsxform.c", + ] + include_dirs = [ + "./openjpeg/thirdparty/liblcms2/include", + "./openjpeg/thirdparty/liblcms2/src", + ] + configs = [ ":lcms2_cflag_config" ] +} + +config("openjpeg_cflag_config") { + cflags = [ + "-Wno-unused-function", + "-Wno-declaration-after-statement", + "-DMUTEX_pthread", + "-Dopenjp2_EXPORTS", + ] +} + +ohos_shared_library("openjp2") { + sources = [ + "./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/function_list.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/opj_malloc.c", + "./openjpeg/src/lib/openjp2/pi.c", + "./openjpeg/src/lib/openjp2/sparse_array.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/thread.c", + ] + + include_dirs = [ + "./openjpeg/src/lib/openjp2", + "./adapter/include", + "./adapter/include/tiff", + "./openjpeg/thirdparty/liblcms2/include", + ] + + configs = [ ":openjpeg_cflag_config" ] + + part_name = "openjpeg" +} + +config("openjpeg_test_config") { + cflags = [ + "-Wno-macro-redefined", + "-Wno-unused-variable", + "-DOPJ_HAVE_LIBLCMS2", + "-DOPJ_HAVE_LCMS2_H", + "-DOPJ_HAVE_TIFF_H", + "-DOPJ_HAVE_LIBTIFF", + ] + include_dirs = [ + "./openjpeg/src/lib/openjp2", + "./openjpeg/src/bin/common", + "./openjpeg/src/lib/jp2", + "./openjpeg/src/bin/jp2", + "./adapter/include", + "./adapter/include/tiff", + "./openjpeg/thirdparty/libtiff", + ] +} + +ohos_executable("test_tile_decoder") { + sources = [ + "./openjpeg/src/bin/common/opj_getopt.c", + "./openjpeg/tests/test_tile_decoder.c", + ] + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":lcms2", + ":openjp2", + ":tiff", + ] + part_name = "openjpeg" +} + +ohos_executable("test_tile_encoder") { + sources = [ + "./openjpeg/src/bin/common/opj_getopt.c", + "./openjpeg/tests/test_tile_encoder.c", + ] + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":lcms2", + ":openjp2", + ":tiff", + ] + part_name = "openjpeg" +} + +ohos_executable("compare_dump_files") { + sources = [ + "./openjpeg/src/bin/common/opj_getopt.c", + "./openjpeg/tests/compare_dump_files.c", + ] + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":lcms2", + ":openjp2", + ":tiff", + ] + part_name = "openjpeg" +} + +ohos_executable("compare_images") { + sources = [ + "./openjpeg/src/bin/common/opj_getopt.c", + "./openjpeg/src/bin/jp2/convert.c", + "./openjpeg/src/bin/jp2/converttif.c", + "./openjpeg/tests/compare_images.c", + ] + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":lcms2", + ":openjp2", + ":tiff", + ] + part_name = "openjpeg" +} + +ohos_executable("compare_raw_files") { + sources = [ + "./openjpeg/src/bin/common/opj_getopt.c", + "./openjpeg/tests/compare_raw_files.c", + ] + + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":lcms2", + ":openjp2", + ":tiff", + ] + part_name = "openjpeg" +} + +ohos_executable("j2k_random_tile_access") { + sources = [ + "./openjpeg/src/bin/common/opj_getopt.c", + "./openjpeg/tests/j2k_random_tile_access.c", + ] + + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":lcms2", + ":openjp2", + ":tiff", + ] + part_name = "openjpeg" +} + +ohos_executable("pdf2jp2") { + sources = [ + "./openjpeg/src/bin/common/opj_getopt.c", + "./openjpeg/tests/pdf2jp2.c", + ] + + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":lcms2", + ":openjp2", + ":tiff", + ] + part_name = "openjpeg" +} + +ohos_executable("test_decode_area") { + sources = [ + "./openjpeg/src/bin/common/opj_getopt.c", + "./openjpeg/tests/test_decode_area.c", + ] + + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":lcms2", + ":openjp2", + ":tiff", + ] + part_name = "openjpeg" +} + +ohos_executable("ppm2rgb3") { + sources = [ + "./openjpeg/src/bin/common/opj_getopt.c", + "./openjpeg/tests/ppm2rgb3.c", + ] + + public_configs = [ ":openjpeg_test_config" ] + deps = [ + ":lcms2", + ":openjp2", + ":tiff", + ] + 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") { + deps = [ ":openjp2" ] + if (enable_openjpeg_test) { + deps += [ + ":compare_dump_files", + ":compare_images", + ":compare_raw_files", + ":j2k_random_tile_access", + ":pdf2jp2", + ":ppm2rgb3", + ":test_decode_area", + ":test_tile_decoder", + ":test_tile_encoder", + ":testempty0", + ":testempty1", + ":testempty2", + ] + } +} diff --git a/openjpeg/README.OpenSource b/openjpeg/README.OpenSource new file mode 100755 index 0000000000000000000000000000000000000000..30935aae8c1942c8a5a5de2696d0f25468b7e28d --- /dev/null +++ b/openjpeg/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "openJPEG", + "License": 2-clauses BSD license, + "License File": "LICENSE.TXT", + "Version Number": "v2.5.0", + "Owner": "huangminzhong2@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 100755 index 0000000000000000000000000000000000000000..9aa0c5b62d223e3a53849b608daf6fca293db6fd --- /dev/null +++ b/openjpeg/README_zh.md @@ -0,0 +1,16 @@ +# 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 100755 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 100755 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 100755 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/include/tiff/tif_config.h b/openjpeg/adapter/include/tiff/tif_config.h new file mode 100755 index 0000000000000000000000000000000000000000..9549075c414e5b6e9de9d7feafaa77e2151f9df3 --- /dev/null +++ b/openjpeg/adapter/include/tiff/tif_config.h @@ -0,0 +1,261 @@ +/* libtiff/tif_config.h.cmake.in. Not generated, but originated from autoheader. */ +/* This file must be kept up-to-date with needed substitutions from libtiff/tif_config.h.in. */ + +/* Support CCITT Group 3 & 4 algorithms */ +#define CCITT_SUPPORT 1 + +/* Pick up YCbCr subsampling info from the JPEG data stream to support files + lacking the tag (default enabled). */ +#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 + +/* enable partial strip reading for large strips (experimental) */ +/* #undef CHUNKY_STRIP_READ_SUPPORT */ + +/* Support C++ stream API (requires C++ compiler) */ +/* #undef CXX_SUPPORT */ + +/* enable deferred strip/tile offset/size loading (experimental) */ +/* #undef DEFER_STRILE_LOAD */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `floor' function. */ +#define HAVE_FLOOR 1 + +/* Define to 1 if you have the `getopt' function. */ +#define HAVE_GETOPT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GLUT_GLUT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GL_GLUT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GL_GLU_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GL_GL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define to 1 if you have the `isascii' function. */ +#define HAVE_ISASCII 1 + +/* Define to 1 if you have the `jbg_newlen' function. */ +/* #undef HAVE_JBG_NEWLEN */ + +/* Define to 1 if you have the `lfind' function. */ +#define HAVE_LFIND 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MALLOC_H 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_OPENGL_GLU_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_OPENGL_GL_H */ + +/* Define to 1 if you have the `pow' function. */ +#define HAVE_POW 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SEARCH_H 1 + +/* Define to 1 if you have the `setmode' function. */ +/* #undef HAVE_SETMODE */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define to 1 if you have the `sqrt' function. */ +#define HAVE_SQRT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the `strcasecmp' function. */ +#define HAVE_STRCASECMP 1 + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strrchr' function. */ +#define HAVE_STRRCHR 1 + +/* Define to 1 if you have the `strstr' function. */ +#define HAVE_STRSTR 1 + +/* Define to 1 if you have the `strtol' function. */ +#define HAVE_STRTOL 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define to 1 if you have the `strtoull' function. */ +#define HAVE_STRTOULL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* 8/12 bit libjpeg dual mode enabled */ +/* #undef JPEG_DUAL_MODE_8_12 */ + +/* 12bit libjpeg primary include file with path */ +#define LIBJPEG_12_PATH + +/* Support LZMA2 compression */ +/* #undef LZMA_SUPPORT */ + +/* Name of package */ +#define PACKAGE "" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION ""4.0.6"" + +/* The size of `signed int', as computed by sizeof. */ +#define SIZEOF_SIGNED_INT 4 + +/* The size of `signed long', as computed by sizeof. */ +#define SIZEOF_SIGNED_LONG 8 + +/* The size of `signed long long', as computed by sizeof. */ +#define SIZEOF_SIGNED_LONG_LONG 8 + +/* The size of `signed short', as computed by sizeof. */ +#define SIZEOF_SIGNED_SHORT 2 + +/* The size of `unsigned char *', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_CHAR_P 8 + +/* The size of `unsigned int', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_INT 4 + +/* The size of `unsigned long', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_LONG 8 + +/* The size of `unsigned long long', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_LONG_LONG 8 + +/* The size of `unsigned short', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_SHORT 2 + +/* Default size of the strip in bytes (when strip chopping enabled) */ +#define STRIP_SIZE_DEFAULT 8192 + +/* Signed 32-bit type formatter */ +#define TIFF_INT32_FORMAT "%d" + +/* Signed 64-bit type formatter */ +#define TIFF_INT64_FORMAT "%lld" + +/* Pointer difference type formatter */ +#define TIFF_PTRDIFF_FORMAT "%ld" + +/* Unsigned size type formatter */ +#define TIFF_SIZE_FORMAT "" + +/* Signed size type formatter */ +#define TIFF_SSIZE_FORMAT "" + +/* Unsigned 32-bit type formatter */ +#define TIFF_UINT32_FORMAT "%u" + +/* Unsigned 64-bit type formatter */ +#define TIFF_UINT64_FORMAT "%llu" + +/* Unsigned 8-bit type */ +#define TIFF_UINT8_T uint8_t + +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* define to use win32 IO system */ +/* #undef USE_WIN32_FILEIO */ + +/* Version number of package */ +#define VERSION ""4.0.6"" + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +# undef WORDS_BIGENDIAN +# endif +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +#define _FILE_OFFSET_BITS 64 + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#define inline inline +#endif + +/* Define to `long int' if does not define. */ +#undef off_t + +/* Define to `unsigned int' if does not define. */ +#undef size_t diff --git a/openjpeg/adapter/include/tiff/tiffconf.h b/openjpeg/adapter/include/tiff/tiffconf.h new file mode 100755 index 0000000000000000000000000000000000000000..45c308390efe55d6b01c9b41a84f217d8d28ef82 --- /dev/null +++ b/openjpeg/adapter/include/tiff/tiffconf.h @@ -0,0 +1,115 @@ +/* + Configuration defines for installed libtiff. + This file maintained for backward compatibility. Do not use definitions + from this file in your programs. +*/ + +#ifndef _TIFFCONF_ +#define _TIFFCONF_ + +#include "tif_config.h" +#if defined( HAVE_STDINT_H ) +#include +#endif +#if defined( HAVE_UNISTD_H ) +#include +#endif + +/* Signed 16-bit type */ +#define TIFF_INT16_T int16_t + +/* Signed 32-bit type */ +#define TIFF_INT32_T int32_t + +/* Signed 64-bit type */ +#define TIFF_INT64_T int64_t + +/* Signed 8-bit type */ +#define TIFF_INT8_T int8_t + +/* Unsigned 16-bit type */ +#define TIFF_UINT16_T uint16_t + +/* Unsigned 32-bit type */ +#define TIFF_UINT32_T uint32_t + +/* Unsigned 64-bit type */ +#define TIFF_UINT64_T uint64_t + +/* Unsigned 8-bit type */ +#define TIFF_UINT8_T uint8_t + +/* Unsigned size type */ +#define TIFF_SIZE_T + +/* Signed size type */ +#define TIFF_SSIZE_T ssize_t + +/* Pointer difference type */ +#define TIFF_PTRDIFF_T ptrdiff_t + +/* Define as 0 or 1 according to the floating point format suported by the + machine */ +#define HAVE_IEEEFP 1 + +/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ +#define HOST_FILLORDER FILLORDER_LSB2MSB + +/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian + (Intel) */ +#define HOST_BIGENDIAN 0 + +/* Support CCITT Group 3 & 4 algorithms */ +#define CCITT_SUPPORT 1 + +/* Support LogLuv high dynamic range encoding */ +#define LOGLUV_SUPPORT 1 + +/* Support LZW algorithm */ +#define LZW_SUPPORT 1 + +/* Support NeXT 2-bit RLE algorithm */ +#define NEXT_SUPPORT 1 + +/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation + fails with unpatched IJG JPEG library) */ +/* #undef OJPEG_SUPPORT */ + +/* Support Macintosh PackBits algorithm */ +#define PACKBITS_SUPPORT 1 + +/* Support ThunderScan 4-bit RLE algorithm */ +#define THUNDER_SUPPORT 1 + +/* Support strip chopping (whether or not to convert single-strip uncompressed + images to mutiple strips of ~8Kb to reduce memory usage) */ +#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP + +/* Enable SubIFD tag (330) support */ +#define SUBIFD_SUPPORT 1 + +/* Treat extra sample as alpha (default enabled). The RGBA interface will + treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many + packages produce RGBA files but don't mark the alpha properly. */ +/*#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1*/ + +/* Pick up YCbCr subsampling info from the JPEG data stream to support files + lacking the tag (default enabled). */ +#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 + +/* Support MS MDI magic number files as TIFF */ +#define MDI_SUPPORT 1 + +/* + * Feature support definitions. + * XXX: These macros are obsoleted. Don't use them in your apps! + * Macros stays here for backward compatibility and should be always defined. + */ +#define COLORIMETRY_SUPPORT +#define YCBCR_SUPPORT +#define CMYK_SUPPORT +#define ICC_SUPPORT +#define PHOTOSHOP_SUPPORT +#define IPTC_SUPPORT + +#endif /* _TIFFCONF_ */ diff --git a/openjpeg/adapter/script/test_open_jpeg.sh b/openjpeg/adapter/script/test_open_jpeg.sh new file mode 100755 index 0000000000000000000000000000000000000000..892b4f84af6086b6b10372856d70f70ef4ac5116 --- /dev/null +++ b/openjpeg/adapter/script/test_open_jpeg.sh @@ -0,0 +1,166 @@ +#!/bin/bash + +# Copyright (c) 2022 Huawei Device Co., Ltd. +# 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. + +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/bundle.json b/openjpeg/bundle.json new file mode 100644 index 0000000000000000000000000000000000000000..4d560c74670d7acaa92bce393240ab2dafbf8451 --- /dev/null +++ b/openjpeg/bundle.json @@ -0,0 +1,33 @@ +{ + "name": "@ohos/openjpeg", + "description": "", + "version": "2.5.0", + "license": "2-Clause BSD", + "publishAs": "code-segment", + "segment": { + "destPath": "third_party/openjpeg" + }, + "dirs": {}, + "scripts": {}, + "readmePath": { + "en": "README" + }, + "component": { + "name": "openjpeg", + "subsystem": "thirdparty", + "syscap": [], + "features": [], + "adapted_system_type": [], + "rom": "", + "ram": "", + "deps": { + "components": [], + "third_party": [] + }, + "build": { + "sub_component": ["//third_party/openjpeg:openjpeg"], + "inner_kits": [], + "test": [] + } + } +} diff --git a/openjpeg/docs/media/running_result.png b/openjpeg/docs/media/running_result.png new file mode 100755 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 100755 index 0000000000000000000000000000000000000000..23fad823d5d5636be1e983d0a3262f0fa8624aac --- /dev/null +++ b/openjpeg/docs/rom_integrate.md @@ -0,0 +1,152 @@ +# 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#源码获取) + +### 增加构建脚本及配置文件 + +- 下载本仓库代码 + + ```shell + cd ~/ + git clone git@gitee.com:openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 仓库代码目录结构说明 + + ```shell + cd ~/tpc_c_cplusplus/openjpeg/ # 进入到仓库代码库目录 + ``` + + ```shell + openjpeg + |-- adapter # 存放三方库适配需要的代码文件 + |-- docs # 存放 openjpeg 相关文档的文件夹 + |-- BUILD.gn # 编译构建脚本 + |-- bundle.json # 三方库组件定义文件 + |-- README_zh.md # openjpeg 主页说明文档 + |-- README.OpenSource # openjpeg 源码的下载地址,版本,license等信息 + ``` + +- 将本仓库文件夹拷贝到OpenHarmony源码的third_party目录下 + + ```shell + cp -arf ~/tpc_c_cplusplus/openjpeg ~/OpenHarmony/third_party + ``` + +### 准备三方库源码 + +- 三方库源码下载 + + 将openjpeg-2.5.0源码下载到openjpeg目录并将其解压出来。 + + ```shell + cd ~/OpenHarmony/third_party/openjpeg + git clone https://github.com/uclouvain/openjpeg.git -b v2.5.0 + ``` + +## 系统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)。
+新增需要编译的组件,在OpenHarmony源码的vendor/hihope/rk3568/config.json文件中,新增需要编译的组件,如下代码段所示,在thirdparty子系统下面新增openjpeg组件 + +```json +{ + "subsystem": "thirdparty", + "components": [ + { + "component": "musl", + "features": [] + }, + { + "component": "openjpeg", + "features": [] + } + ] +} +``` + +## 系统Rom中引入三方库测试程序 + +如果需要编译测试用例,在OpenHarmony源码的vendor/hihope/rk3568/config.json文件,在对应组件的features中打开编译选项,如下 + +```json +{ + "subsystem": "thirdparty", + "components": [ + { + "component": "musl", + "features": [] + }, + { + "component": "openjpeg", + "features": ["enable_openjpeg_test=true"] + } + ] +} +``` + +## 编译工程 + +- 进入源码根目录 + + ```shell + cd ~/openharmony + ``` + +- 选择产品 + + ```shell + hb set # 运行hb set后会出现产品列表,在此我们选择 rk3568 + ``` + +- 执行编译 + + ```shell + hb build --target-cpu arm #编译32位系统 + hb build --target-cpu arm64 #编译64位系统 + ``` + +- 生成的可执行文件和库文件都在out/rk3568/thirdparty/openjpeg目录下,同时也打包到了镜像中 + +## 运行效果 + +将编译生成的库和测试文件放到板子上运行,为避免每次将文件推入设备都要烧录整个镜像,我们使用hdc_std工具将文件推到开发板上 + +- 首先将hdc_std工具编译出来
+ 执行以下命令进行编译hdc_std工具(工具编译出来所在路径out/sdk/ohos-sdk/windows/toolchains/hdc_std.exe): + + ```shell + hb set #源码根目录下使用hb set 选择产品ohos-sdk + hb build #然后编译 + ``` + +- 将工具拷贝到Windows,可以为工具目录配置环境变量,也可以在工具所在目录打开windows命令行 +- 将原生库测试需要的所有文件打包成openjpeg.tar,并拷贝到windows下 +- 将文件推送到开发板,在windows命令行进行如下操作 + + ```shell + hdc_std shell mount -o remount,rw / #修改系统权限为可读写 + hdc_std file send openjpeg.tar / #将文件包推入开发板 + hdc_std shell #进入开发板 + tar xvf openjpeg.tar #解压 + #注意需要将库拷贝到/system/lib 或者/system/lib64目录下 + ``` + +- 运行测试程序 + 在测试目录运行test_open_jpeg.sh脚本,若日志信息中所有测试项目为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/blob/master/docs/openharmony_getstarted/port_thirdparty/README.md)。 +- [知识体系](https://gitee.com/openharmony-sig/knowledge)。