diff --git a/thirdparty/libheif/HeifConvertTestJNI/Makefile.am b/thirdparty/libheif/HeifConvertTestJNI/Makefile.am deleted file mode 100644 index bb2909fbeca330b5e1f1f4c80275b6b3c4dfd0f5..0000000000000000000000000000000000000000 --- a/thirdparty/libheif/HeifConvertTestJNI/Makefile.am +++ /dev/null @@ -1,112 +0,0 @@ -AUTOMAKE_OPTIONS = subdir-objects - -examples = \ - heif-convert \ - heif-enc \ - heif-info - -examples_noinst = \ - heif-test \ - test-c-api - -dist_man_MANS = - -heif_convert_DEPENDENCIES = ../libheif/libheif.la -heif_convert_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir)/. -heif_convert_LDFLAGS = -heif_convert_LDADD = ../libheif/libheif.la -heif_convert_SOURCES = encoder.cc encoder.h heif_convert.cc encoder_y4m.cc encoder_y4m.h -dist_man_MANS += heif-convert.1 - - -if HAVE_LIBPNG -examples += heif-thumbnailer -heif_thumbnailer_DEPENDENCIES = ../libheif/libheif.la -heif_thumbnailer_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir) $(libpng_CFLAGS) -heif_thumbnailer_LDFLAGS = $(libpng_LIBS) -heif_thumbnailer_LDADD = ../libheif/libheif.la -heif_thumbnailer_SOURCES = encoder.cc encoder.h heif_thumbnailer.cc encoder_png.cc encoder_png.h -dist_man_MANS += heif-thumbnailer.1 -endif - -if HAVE_LIBJPEG -heif_convert_CXXFLAGS += $(libjpeg_CFLAGS) -heif_convert_LDADD += $(libjpeg_LIBS) -heif_convert_SOURCES += encoder_jpeg.cc encoder_jpeg.h -endif - -if HAVE_LIBPNG -heif_convert_CXXFLAGS += $(libpng_CFLAGS) -heif_convert_LDADD += $(libpng_LIBS) -heif_convert_SOURCES += encoder_png.cc encoder_png.h -endif - -heif_info_DEPENDENCIES = ../libheif/libheif.la -heif_info_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir) -heif_info_LDFLAGS = -heif_info_LDADD = ../libheif/libheif.la -heif_info_SOURCES = heif_info.cc -dist_man_MANS += heif-info.1 - -heif_enc_DEPENDENCIES = ../libheif/libheif.la -heif_enc_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir) -heif_enc_LDFLAGS = -heif_enc_LDADD = ../libheif/libheif.la -heif_enc_SOURCES = heif_enc.cc -dist_man_MANS += heif-enc.1 - -if HAVE_LIBJPEG -heif_enc_CXXFLAGS += $(libjpeg_CFLAGS) -heif_enc_LDADD += $(libjpeg_LIBS) -endif - -if HAVE_LIBPNG -heif_enc_CXXFLAGS += $(libpng_CFLAGS) -heif_enc_LDADD += $(libpng_LIBS) -endif - -heif_test_DEPENDENCIES = ../libheif/libheif.la -heif_test_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir) -heif_test_LDFLAGS = -heif_test_LDADD = ../libheif/libheif.la -heif_test_SOURCES = heif_test.cc - -test_c_api_DEPENDENCIES = ../libheif/libheif.la -test_c_api_CFLAGS = -I$(top_srcdir) -I$(top_builddir) -test_c_api_LDFLAGS = -test_c_api_LDADD = ../libheif/libheif.la -test_c_api_SOURCES = test_c_api.c - -EXTRA_DIST = \ - CMakeLists.txt \ - COPYING \ - demo.html \ - example.avif \ - example.heic - -if HAVE_GO -examples_noinst += \ - heif-test-go - -heif_test_go_SOURCES = heif-test.go - -gopath: - mkdir -p ${CURDIR}/src/github.com/strukturag/libheif - ln -sf ${CURDIR}/../go ${CURDIR}/src/github.com/strukturag/libheif/ - -heif-test-go: gopath $(top_builddir)/libheif/libheif.la $(top_builddir)/libheif.pc heif-test.go - GOPATH=${CURDIR} PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:$(abs_top_builddir):$(abs_top_builddir)/libde265/dist/lib/pkgconfig/ CGO_CFLAGS="-I$(abs_top_builddir)" CGO_LDFLAGS="-L$(abs_top_builddir)/libheif/.libs" LD_LIBRARY_PATH=$(abs_top_builddir)/libheif/.libs $(GO) build -o heif-test-go ${heif_test_go_SOURCES} - -format-go: ${heif_test_go_SOURCES} - $(GO) fmt ${heif_test_go_SOURCES} -else -format-go: - echo ""go" not present in "${PATH}", skipping formatting" -endif - -if WITH_EXAMPLES -bin_PROGRAMS = $(examples) -noinst_PROGRAMS = $(examples_noinst) -endif - -format-local: format-go diff --git a/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CMakeDetermineCompilerABI_C.bin b/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CMakeDetermineCompilerABI_C.bin index 4a5e899383be75670952232382ad5911c20c1d4a..683c3757b086cfbcb395fc9b74c3acddd60c9fff 100644 Binary files a/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CMakeDetermineCompilerABI_C.bin and b/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CMakeDetermineCompilerABI_C.bin differ diff --git a/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CMakeDetermineCompilerABI_CXX.bin b/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CMakeDetermineCompilerABI_CXX.bin index c039dc4f8e1dd21e5d2ade42aebc8a967c5d2775..eeaecc9c4b03fc1c83e45e9447d438bdc0d17712 100644 Binary files a/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CMakeDetermineCompilerABI_CXX.bin and b/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CMakeDetermineCompilerABI_CXX.bin differ diff --git a/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CompilerIdC/CompilerIdC.exe b/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CompilerIdC/CompilerIdC.exe index 709a530bf24115588665f7c56056e2079c9f81e8..b9b51d3d19af928d326739c41c876be463751833 100644 Binary files a/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CompilerIdC/CompilerIdC.exe and b/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CompilerIdC/CompilerIdC.exe differ diff --git a/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CompilerIdC/Debug/CMakeCCompilerId.obj b/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CompilerIdC/Debug/CMakeCCompilerId.obj index e6b9017686fbc200b3a03c54c00a878baf5cbe4a..c0b979c5ca11683e8914e237ee29e5b81c5c82b9 100644 Binary files a/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CompilerIdC/Debug/CMakeCCompilerId.obj and b/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CompilerIdC/Debug/CMakeCCompilerId.obj differ diff --git a/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CompilerIdCXX/CompilerIdCXX.exe b/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CompilerIdCXX/CompilerIdCXX.exe index 5ce37cb93a847296a078e6228cc4ce40efacf107..878aee204fb87cff1462feec2f9b3886ade48c21 100644 Binary files a/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CompilerIdCXX/CompilerIdCXX.exe and b/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CompilerIdCXX/CompilerIdCXX.exe differ diff --git a/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CompilerIdCXX/Debug/CMakeCXXCompilerId.obj b/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CompilerIdCXX/Debug/CMakeCXXCompilerId.obj index 2328652e3ed027d065bcf2f678add2f2b6644225..97d10a28d0cca31b170b6618eaae636c085eca95 100644 Binary files a/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CompilerIdCXX/Debug/CMakeCXXCompilerId.obj and b/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/3.23.0-rc2/CompilerIdCXX/Debug/CMakeCXXCompilerId.obj differ diff --git a/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/CMakeOutput.log b/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/CMakeOutput.log index 687e3e1df2c250f3d44b967b6ad8337a972f23c4..91dfe90bf6f3987831d322362e0f18c04ed7e446 100644 --- a/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/CMakeOutput.log +++ b/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/CMakeOutput.log @@ -9,7 +9,7 @@ The output was: Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved. -Build started 3/1/2022 8:15:06 PM. +Build started 3/2/2022 9:19:03 AM. Project "C:\Users\gregd\Documents\Source\autopsy\thirdparty\libheif\HeifConvertTestJNI\dist\CMakeFiles\3.23.0-rc2\CompilerIdC\CompilerIdC.vcxproj" on node 1 (default targets). PrepareForBuild: Creating directory "Debug\". @@ -35,7 +35,7 @@ Build succeeded. 0 Warning(s) 0 Error(s) -Time Elapsed 00:00:00.67 +Time Elapsed 00:00:00.64 Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CompilerIdC.exe" @@ -54,7 +54,7 @@ The output was: Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved. -Build started 3/1/2022 8:15:07 PM. +Build started 3/2/2022 9:19:04 AM. Project "C:\Users\gregd\Documents\Source\autopsy\thirdparty\libheif\HeifConvertTestJNI\dist\CMakeFiles\3.23.0-rc2\CompilerIdCXX\CompilerIdCXX.vcxproj" on node 1 (default targets). PrepareForBuild: Creating directory "Debug\". @@ -80,7 +80,7 @@ Build succeeded. 0 Warning(s) 0 Error(s) -Time Elapsed 00:00:00.61 +Time Elapsed 00:00:00.48 Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CompilerIdCXX.exe" @@ -92,42 +92,42 @@ The CXX compiler identification is MSVC, found in "C:/Users/gregd/Documents/Sour Detecting C compiler ABI info compiled with the following output: Change Dir: C:/Users/gregd/Documents/Source/autopsy/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/CMakeTmp -Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_d5263.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET Framework +Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_4b51a.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved. Microsoft (R) C/C++ Optimizing Compiler Version 19.31.31104 for x64 - Copyright (C) Microsoft Corporation. All rights reserved. CMakeCCompilerABI.c - cl /c /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_d5263.dir\Debug\\" /Fd"cmTC_d5263.dir\Debug\vc143.pdb" /external:W3 /Gd /TC /errorReport:queue "C:\Program Files\CMake\share\cmake-3.23\Modules\CMakeCCompilerABI.c" - cmTC_d5263.vcxproj -> C:\Users\gregd\Documents\Source\autopsy\thirdparty\libheif\HeifConvertTestJNI\dist\CMakeFiles\CMakeTmp\Debug\cmTC_d5263.exe + Copyright (C) Microsoft Corporation. All rights reserved. + cl /c /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_4b51a.dir\Debug\\" /Fd"cmTC_4b51a.dir\Debug\vc143.pdb" /external:W3 /Gd /TC /errorReport:queue "C:\Program Files\CMake\share\cmake-3.23\Modules\CMakeCCompilerABI.c" + cmTC_4b51a.vcxproj -> C:\Users\gregd\Documents\Source\autopsy\thirdparty\libheif\HeifConvertTestJNI\dist\CMakeFiles\CMakeTmp\Debug\cmTC_4b51a.exe Detecting CXX compiler ABI info compiled with the following output: Change Dir: C:/Users/gregd/Documents/Source/autopsy/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/CMakeTmp -Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_2a9c8.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET Framework +Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_d7e81.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved. Microsoft (R) C/C++ Optimizing Compiler Version 19.31.31104 for x64 Copyright (C) Microsoft Corporation. All rights reserved. CMakeCXXCompilerABI.cpp - cl /c /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"cmTC_2a9c8.dir\Debug\\" /Fd"cmTC_2a9c8.dir\Debug\vc143.pdb" /external:W3 /Gd /TP /errorReport:queue "C:\Program Files\CMake\share\cmake-3.23\Modules\CMakeCXXCompilerABI.cpp" - cmTC_2a9c8.vcxproj -> C:\Users\gregd\Documents\Source\autopsy\thirdparty\libheif\HeifConvertTestJNI\dist\CMakeFiles\CMakeTmp\Debug\cmTC_2a9c8.exe + cl /c /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"cmTC_d7e81.dir\Debug\\" /Fd"cmTC_d7e81.dir\Debug\vc143.pdb" /external:W3 /Gd /TP /errorReport:queue "C:\Program Files\CMake\share\cmake-3.23\Modules\CMakeCXXCompilerABI.cpp" + cmTC_d7e81.vcxproj -> C:\Users\gregd\Documents\Source\autopsy\thirdparty\libheif\HeifConvertTestJNI\dist\CMakeFiles\CMakeTmp\Debug\cmTC_d7e81.exe Performing C++ SOURCE FILE Test HAVE_JPEG_WRITE_ICC_PROFILE succeeded with the following output: Change Dir: C:/Users/gregd/Documents/Source/autopsy/thirdparty/libheif/HeifConvertTestJNI/dist/CMakeFiles/CMakeTmp -Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_87163.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET Framework +Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_02584.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved. Microsoft (R) C/C++ Optimizing Compiler Version 19.31.31104 for x64 src.cxx Copyright (C) Microsoft Corporation. All rights reserved. - cl /c /I"C:\Users\gregd\vcpkg\installed\x64-windows\include" /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D WIN32 /D _WINDOWS /D HAVE_JPEG_WRITE_ICC_PROFILE /D "CMAKE_INTDIR=\"Debug\"" /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"cmTC_87163.dir\Debug\\" /Fd"cmTC_87163.dir\Debug\vc143.pdb" /external:W3 /Gd /TP /errorReport:queue C:\Users\gregd\Documents\Source\autopsy\thirdparty\libheif\HeifConvertTestJNI\dist\CMakeFiles\CMakeTmp\src.cxx - cmTC_87163.vcxproj -> C:\Users\gregd\Documents\Source\autopsy\thirdparty\libheif\HeifConvertTestJNI\dist\CMakeFiles\CMakeTmp\Debug\cmTC_87163.exe + cl /c /I"C:\Users\gregd\vcpkg\installed\x64-windows\include" /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D WIN32 /D _WINDOWS /D HAVE_JPEG_WRITE_ICC_PROFILE /D "CMAKE_INTDIR=\"Debug\"" /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"cmTC_02584.dir\Debug\\" /Fd"cmTC_02584.dir\Debug\vc143.pdb" /external:W3 /Gd /TP /errorReport:queue C:\Users\gregd\Documents\Source\autopsy\thirdparty\libheif\HeifConvertTestJNI\dist\CMakeFiles\CMakeTmp\src.cxx + cmTC_02584.vcxproj -> C:\Users\gregd\Documents\Source\autopsy\thirdparty\libheif\HeifConvertTestJNI\dist\CMakeFiles\CMakeTmp\Debug\cmTC_02584.exe Source file was: diff --git a/thirdparty/libheif/HeifConvertTestJNI/org_sleuthkit_autopsy_modules_pictureanalyzer_impls_HeifJNI.cc b/thirdparty/libheif/HeifConvertTestJNI/org_sleuthkit_autopsy_modules_pictureanalyzer_impls_HeifJNI.cc index bb1c211863b6dcdb557e2022e54b3916ff3a3bbd..0dd7397633fb0ea8f089bf10b78294f1238d155a 100644 --- a/thirdparty/libheif/HeifConvertTestJNI/org_sleuthkit_autopsy_modules_pictureanalyzer_impls_HeifJNI.cc +++ b/thirdparty/libheif/HeifConvertTestJNI/org_sleuthkit_autopsy_modules_pictureanalyzer_impls_HeifJNI.cc @@ -27,18 +27,6 @@ #ifndef _Included_org_sleuthkit_autopsy_modules_pictureanalyzer_impls_HeifJNI #define _Included_org_sleuthkit_autopsy_modules_pictureanalyzer_impls_HeifJNI -//#if defined(HAVE_CONFIG_H) -//#include "config.h" -//#endif -// -//#include <cstring> -// -//#if defined(HAVE_UNISTD_H) -// -//#include <unistd.h> -// -//#endif - #include <fstream> #include <iostream> #include <sstream> @@ -59,355 +47,383 @@ class ContextReleaser { public: - ContextReleaser(struct heif_context* ctx) : ctx_(ctx) - {} + ContextReleaser(struct heif_context* ctx) : ctx_(ctx) + {} - ~ContextReleaser() - { - heif_context_free(ctx_); - } + ~ContextReleaser() + { + heif_context_free(ctx_); + } private: - struct heif_context* ctx_; + struct heif_context* ctx_; }; jint throwException(JNIEnv* env, const char* exceptionType, const char* message) { - jclass exClass; - exClass = env->FindClass(exceptionType); - return env->ThrowNew(exClass, message); + jclass exClass; + exClass = env->FindClass(exceptionType); + return env->ThrowNew(exClass, message); } jint throwIllegalArgument(JNIEnv* env, const char* message) { - std::string className = "java/lang/IllegalArgumentException"; - return throwException(env, className.c_str(), message); + std::string className = "java/lang/IllegalArgumentException"; + return throwException(env, className.c_str(), message); } jint throwIllegalState(JNIEnv* env, const char* message) { - std::string className = "java/lang/IllegalStateException"; - return throwException(env, className.c_str(), message); + std::string className = "java/lang/IllegalStateException"; + return throwException(env, className.c_str(), message); } -//void println(JNIEnv* env, std::string message) -//{ -// // Get system class -// jclass syscls = env->FindClass("java/lang/System"); -// // Lookup the "out" field -// jfieldID fid = env->GetStaticFieldID(syscls, "out", "Ljava/io/PrintStream;"); -// jobject out = env->GetStaticObjectField(syscls, fid); -// // Get PrintStream class -// jclass pscls = env->FindClass("java/io/PrintStream"); -// // Lookup printLn(String) -// jmethodID mid = env->GetMethodID(pscls, "println", "(Ljava/lang/String;)V"); -// // Invoke the method -// jchar* cppstr = (jchar*)message.c_str(); // make an array of jchar (UTF-16 unsigned short encoding) -// jstring str = env->NewString(cppstr, message.length()); -// env->CallVoidMethod(out, mid, str); -//} - int convertToDisk - (JNIEnv* env, jclass cls, jbyteArray byteArr, jstring outputPath) { +(JNIEnv* env, jclass cls, jbyteArray byteArr, jstring outputPath) { + + size_t arrLen = env->GetArrayLength(byteArr); + std::vector<jbyte> nativeByteArr(arrLen); + + boolean isCopy; + env->GetByteArrayRegion(byteArr, 0, arrLen, &nativeByteArr[0]); + std::string output_filename = env->GetStringUTFChars(outputPath, 0); + const int quality = 100; + +#ifdef _DEBUG + printf("Checking heif file type...\n"); +#endif + enum heif_filetype_result filetype_check = heif_check_filetype((const uint8_t*)&nativeByteArr[0], 12); + if (filetype_check == heif_filetype_no) { + throwIllegalArgument(env, "Input file is not an HEIF/AVIF file"); + return 1; + } + +#ifdef _DEBUG + printf("Checking heif file type supported...\n"); +#endif + if (filetype_check == heif_filetype_yes_unsupported) { + throwIllegalArgument(env, "Input file is an unsupported HEIF/AVIF file type"); + return 1; + } + +#ifdef _DEBUG + printf("Creating heif context...\n"); +#endif + struct heif_context* ctx = heif_context_alloc(); + if (!ctx) { + throwIllegalState(env, "Could not create context object"); + return 1; + } + +#ifdef _DEBUG + printf("Reading in heif bytes...\n"); +#endif + ContextReleaser cr(ctx); + struct heif_error err; + err = heif_context_read_from_memory_without_copy(ctx, (void*)&nativeByteArr[0], arrLen, nullptr); + if (err.code != 0) { + std::string err_message = "Could not read HEIF/AVIF file:"; + err_message += err.message; + throwIllegalState(env, err_message.c_str()); + return 1; + } + +#ifdef _DEBUG + printf("Checking heif file type...\n"); +#endif + int num_images = heif_context_get_number_of_top_level_images(ctx); + if (num_images == 0) { + throwIllegalState(env, "File doesn't contain any images"); + return 1; + } + +#ifdef _DEBUG + printf("File contains %d images. Reading in image ids...\n", num_images); +#endif + + std::vector<heif_item_id> image_IDs(num_images); + num_images = heif_context_get_list_of_top_level_image_IDs(ctx, image_IDs.data(), num_images); + +#ifdef _DEBUG + printf("Resetting encoder...\n"); +#endif + std::string filename; + std::unique_ptr<Encoder> encoder(new JpegEncoder(quality)); + + size_t image_index = 1; // Image filenames are "1" based. + + for (int idx = 0; idx < num_images; ++idx) { +#ifdef _DEBUG + printf("Looping through for image %d\n", idx); +#endif + + if (num_images > 1) { + std::ostringstream s; + s << output_filename.substr(0, output_filename.find_last_of('.')); + s << "-" << image_index; + s << output_filename.substr(output_filename.find_last_of('.')); + filename.assign(s.str()); +#ifdef _DEBUG + printf("Assigning filename of %s\n", s.str().c_str()); +#endif + } + else { + filename.assign(output_filename); +#ifdef _DEBUG + printf("Assigning filename of %s\n", output_filename.c_str()); +#endif + } + +#ifdef _DEBUG + printf("acquiring heif image handle...\n"); +#endif + struct heif_image_handle* handle; + err = heif_context_get_image_handle(ctx, image_IDs[idx], &handle); + if (err.code) { + std::string err_message = "Could not read HEIF/AVIF image "; + err_message += idx; + err_message += ": "; + err_message += err.message; + throwIllegalState(env, err_message.c_str()); + return 1; + } + +#ifdef _DEBUG + printf("handling alpha...\n"); +#endif + int has_alpha = heif_image_handle_has_alpha_channel(handle); + struct heif_decoding_options* decode_options = heif_decoding_options_alloc(); + encoder->UpdateDecodingOptions(handle, decode_options); + + int bit_depth = heif_image_handle_get_luma_bits_per_pixel(handle); + if (bit_depth < 0) { + heif_decoding_options_free(decode_options); + heif_image_handle_release(handle); + throwIllegalState(env, "Input image has undefined bit-depth"); + return 1; + } + +#ifdef _DEBUG + printf("decoding heif image...\n"); +#endif + struct heif_image* image; + err = heif_decode_image(handle, + &image, + encoder->colorspace(has_alpha), + encoder->chroma(has_alpha, bit_depth), + decode_options); + heif_decoding_options_free(decode_options); + if (err.code) { + heif_image_handle_release(handle); + std::string err_message = "Could not decode image: "; + err_message += idx; + err_message += ": "; + err_message += err.message; + throwIllegalState(env, err_message.c_str()); + return 1; + } + + + if (image) { +#ifdef _DEBUG + printf("valid image found.\n"); +#endif + bool written = encoder->Encode(handle, image, filename); + if (!written) { +#ifdef _DEBUG + printf("could not write image\n"); +#endif + } + else { +#ifdef _DEBUG + printf("Written to %s\n", filename.c_str()); +#endif + } + heif_image_release(image); + + + int has_depth = heif_image_handle_has_depth_image(handle); + if (has_depth) { +#ifdef _DEBUG + printf("has depth...\n"); +#endif + heif_item_id depth_id; + int nDepthImages = heif_image_handle_get_list_of_depth_image_IDs(handle, &depth_id, 1); + assert(nDepthImages == 1); + (void)nDepthImages; + + struct heif_image_handle* depth_handle; + err = heif_image_handle_get_depth_image_handle(handle, depth_id, &depth_handle); + if (err.code) { + heif_image_handle_release(handle); + throwIllegalState(env, "Could not read depth channel"); + return 1; + } + + int depth_bit_depth = heif_image_handle_get_luma_bits_per_pixel(depth_handle); + +#ifdef _DEBUG + printf("decoding depth image...\n"); +#endif + struct heif_image* depth_image; + err = heif_decode_image(depth_handle, + &depth_image, + encoder->colorspace(false), + encoder->chroma(false, depth_bit_depth), + nullptr); + if (err.code) { + heif_image_handle_release(depth_handle); + heif_image_handle_release(handle); + std::string err_message = "Could not decode depth image: "; + err_message += err.message; + throwIllegalState(env, err_message.c_str()); + return 1; + } + + std::ostringstream s; + s << output_filename.substr(0, output_filename.find('.')); + s << "-depth"; + s << output_filename.substr(output_filename.find('.')); + +#ifdef _DEBUG + printf("Encoding to %s.\n", s.str().c_str()); +#endif + written = encoder->Encode(depth_handle, depth_image, s.str()); + if (!written) { +#ifdef _DEBUG + printf("could not write depth image\n"); +#endif + } + else { +#ifdef _DEBUG + printf("Depth image written to %s\n", s.str().c_str()); +#endif + } + + heif_image_release(depth_image); + heif_image_handle_release(depth_handle); + } + + +#ifdef _DEBUG + printf("checking for aux images...\n"); +#endif + + // --- aux images + + int nAuxImages = heif_image_handle_get_number_of_auxiliary_images(handle, LIBHEIF_AUX_IMAGE_FILTER_OMIT_ALPHA | LIBHEIF_AUX_IMAGE_FILTER_OMIT_DEPTH); + + if (nAuxImages > 0) { +#ifdef _DEBUG + printf("found %d aux images.\n", nAuxImages); +#endif + + std::vector<heif_item_id> auxIDs(nAuxImages); + heif_image_handle_get_list_of_auxiliary_image_IDs(handle, + LIBHEIF_AUX_IMAGE_FILTER_OMIT_ALPHA | LIBHEIF_AUX_IMAGE_FILTER_OMIT_DEPTH, + auxIDs.data(), nAuxImages); + + for (heif_item_id auxId : auxIDs) { +#ifdef _DEBUG + printf("getting aux handle...\n"); +#endif - size_t arrLen = env->GetArrayLength(byteArr); - std::vector<jbyte> nativeByteArr(arrLen); - - boolean isCopy; - env->GetByteArrayRegion(byteArr, 0, arrLen, &nativeByteArr[0]); - std::string output_filename = env->GetStringUTFChars(outputPath, 0); - const int quality = 100; - - printf("Checking heif file type...\n"); - enum heif_filetype_result filetype_check = heif_check_filetype((const uint8_t*)&nativeByteArr[0], 12); - if (filetype_check == heif_filetype_no) { - // env->ReleaseByteArrayElements(byteArr, nativeByteArr, 0); - throwIllegalArgument(env, "Input file is not an HEIF/AVIF file"); - return 1; - } - - printf("Checking heif file type supported...\n"); - if (filetype_check == heif_filetype_yes_unsupported) { - // env->ReleaseByteArrayElements(byteArr, nativeByteArr, 0); - throwIllegalArgument(env, "Input file is an unsupported HEIF/AVIF file type"); - return 1; - } - - printf("Creating heif context...\n"); - struct heif_context* ctx = heif_context_alloc(); - if (!ctx) { - // env->ReleaseByteArrayElements(byteArr, nativeByteArr, 0); - throwIllegalState(env, "Could not create context object"); - return 1; - } - - printf("Reading in heif bytes...\n"); - ContextReleaser cr(ctx); - struct heif_error err; - err = heif_context_read_from_memory_without_copy(ctx, (void*)&nativeByteArr[0], arrLen, nullptr); - if (err.code != 0) { - // env->ReleaseByteArrayElements(byteArr, nativeByteArr, 0); - std::string err_message = "Could not read HEIF/AVIF file:"; - err_message += err.message; - throwIllegalState(env, err_message.c_str()); - return 1; - } - - printf("Checking heif file type...\n"); - int num_images = heif_context_get_number_of_top_level_images(ctx); - if (num_images == 0) { - // env->ReleaseByteArrayElements(byteArr, nativeByteArr, 0); - throwIllegalState(env, "File doesn't contain any images"); - return 1; - } - - printf("File contains %d images. Reading in image ids...\n", num_images); - - std::vector<heif_item_id> image_IDs(num_images); - num_images = heif_context_get_list_of_top_level_image_IDs(ctx, image_IDs.data(), num_images); - - printf("Resetting encoder...\n"); - std::string filename; - std::unique_ptr<Encoder> encoder(new JpegEncoder(quality)); - - size_t image_index = 1; // Image filenames are "1" based. - - for (int idx = 0; idx < num_images; ++idx) { - printf("Looping through for image %d\n", idx); - - if (num_images > 1) { - std::ostringstream s; - s << output_filename.substr(0, output_filename.find_last_of('.')); - s << "-" << image_index; - s << output_filename.substr(output_filename.find_last_of('.')); - filename.assign(s.str()); - printf("Assigning filename of %s\n", s.str().c_str()); - } - else { - filename.assign(output_filename); - printf("Assigning filename of %s\n", output_filename.c_str()); - } - - printf("acquiring heif image handle...\n"); - struct heif_image_handle* handle; - err = heif_context_get_image_handle(ctx, image_IDs[idx], &handle); - if (err.code) { - // env->ReleaseByteArrayElements(byteArr, nativeByteArr, 0); - std::string err_message = "Could not read HEIF/AVIF image "; - err_message += idx; - err_message += ": "; - err_message += err.message; - throwIllegalState(env, err_message.c_str()); - return 1; - } - - printf("handling alpha...\n"); - int has_alpha = heif_image_handle_has_alpha_channel(handle); - struct heif_decoding_options* decode_options = heif_decoding_options_alloc(); - encoder->UpdateDecodingOptions(handle, decode_options); - - int bit_depth = heif_image_handle_get_luma_bits_per_pixel(handle); - if (bit_depth < 0) { - heif_decoding_options_free(decode_options); - heif_image_handle_release(handle); - // env->ReleaseByteArrayElements(byteArr, nativeByteArr, 0); - throwIllegalState(env, "Input image has undefined bit-depth"); - return 1; - } - - printf("decoding heif image...\n"); - struct heif_image* image; - err = heif_decode_image(handle, - &image, - encoder->colorspace(has_alpha), - encoder->chroma(has_alpha, bit_depth), - decode_options); - heif_decoding_options_free(decode_options); - if (err.code) { - heif_image_handle_release(handle); - std::string err_message = "Could not decode image: "; - err_message += idx; - err_message += ": "; - err_message += err.message; - // env->ReleaseByteArrayElements(byteArr, nativeByteArr, 0); - throwIllegalState(env, err_message.c_str()); - return 1; - } - - - if (image) { - printf("valid image found.\n"); - bool written = encoder->Encode(handle, image, filename); - if (!written) { - printf("could not write image\n"); - } - else { - printf("Written to %s\n", filename.c_str()); - } - heif_image_release(image); - - - int has_depth = heif_image_handle_has_depth_image(handle); - if (has_depth) { - printf("has depth...\n"); - heif_item_id depth_id; - int nDepthImages = heif_image_handle_get_list_of_depth_image_IDs(handle, &depth_id, 1); - assert(nDepthImages == 1); - (void)nDepthImages; - - struct heif_image_handle* depth_handle; - err = heif_image_handle_get_depth_image_handle(handle, depth_id, &depth_handle); - if (err.code) { - heif_image_handle_release(handle); - // env->ReleaseByteArrayElements(byteArr, nativeByteArr, 0); - throwIllegalState(env, "Could not read depth channel"); - return 1; - } - - int depth_bit_depth = heif_image_handle_get_luma_bits_per_pixel(depth_handle); - - printf("decoding depth image...\n"); - struct heif_image* depth_image; - err = heif_decode_image(depth_handle, - &depth_image, - encoder->colorspace(false), - encoder->chroma(false, depth_bit_depth), - nullptr); - if (err.code) { - heif_image_handle_release(depth_handle); - heif_image_handle_release(handle); - // env->ReleaseByteArrayElements(byteArr, nativeByteArr, 0); - std::string err_message = "Could not decode depth image: "; - err_message += err.message; - throwIllegalState(env, err_message.c_str()); - return 1; - } - - std::ostringstream s; - s << output_filename.substr(0, output_filename.find('.')); - s << "-depth"; - s << output_filename.substr(output_filename.find('.')); - - printf("Encoding to %s.\n", s.str().c_str()); - written = encoder->Encode(depth_handle, depth_image, s.str()); - if (!written) { - printf("could not write depth image\n"); - } - else { - printf("Depth image written to %s\n", s.str().c_str()); - } - - heif_image_release(depth_image); - heif_image_handle_release(depth_handle); - } - - - printf("checking for aux images...\n"); - - // --- aux images - - int nAuxImages = heif_image_handle_get_number_of_auxiliary_images(handle, LIBHEIF_AUX_IMAGE_FILTER_OMIT_ALPHA | LIBHEIF_AUX_IMAGE_FILTER_OMIT_DEPTH); - - if (nAuxImages > 0) { - printf("found %d aux images.\n", nAuxImages); - - std::vector<heif_item_id> auxIDs(nAuxImages); - heif_image_handle_get_list_of_auxiliary_image_IDs(handle, - LIBHEIF_AUX_IMAGE_FILTER_OMIT_ALPHA | LIBHEIF_AUX_IMAGE_FILTER_OMIT_DEPTH, - auxIDs.data(), nAuxImages); - - for (heif_item_id auxId : auxIDs) { - printf("getting aux handle...\n"); - - struct heif_image_handle* aux_handle; - err = heif_image_handle_get_auxiliary_image_handle(handle, auxId, &aux_handle); - if (err.code) { - heif_image_handle_release(handle); - // env->ReleaseByteArrayElements(byteArr, nativeByteArr, 0); - throwIllegalState(env, "Could not read auxiliary image"); - return 1; - } - - printf("decoding aux handle image...\n"); - int aux_bit_depth = heif_image_handle_get_luma_bits_per_pixel(aux_handle); - - struct heif_image* aux_image; - err = heif_decode_image(aux_handle, - &aux_image, - encoder->colorspace(false), - encoder->chroma(false, aux_bit_depth), - nullptr); - if (err.code) { - heif_image_handle_release(aux_handle); - heif_image_handle_release(handle); - // env->ReleaseByteArrayElements(byteArr, nativeByteArr, 0); - std::string err_message = "Could not decode auxiliary image: "; - err_message += err.message; - throwIllegalState(env, err_message.c_str()); - return 1; - } - - printf("decoding aux image handle auxiliary type...\n"); - const char* auxTypeC = nullptr; - err = heif_image_handle_get_auxiliary_type(aux_handle, &auxTypeC); - if (err.code) { - heif_image_handle_release(aux_handle); - heif_image_handle_release(handle); - // env->ReleaseByteArrayElements(byteArr, nativeByteArr, 0); - std::string err_message = "Could not get type of auxiliary image: "; - err_message += err.message; - throwIllegalState(env, err_message.c_str()); - return 1; - } - - std::string auxType = std::string(auxTypeC); - - printf("freeing auxiliary type.\n"); - heif_image_handle_free_auxiliary_types(aux_handle, &auxTypeC); - - std::ostringstream s; - s << output_filename.substr(0, output_filename.find('.')); - s << "-" + auxType; - s << output_filename.substr(output_filename.find('.')); - throwIllegalArgument(env, s.str().c_str()); - - printf("Writing aux to output: %s\n", s.str().c_str()); - - written = encoder->Encode(aux_handle, aux_image, s.str()); - if (!written) { - printf("could not write auxiliary image\n"); - } - else { - printf("Auxiliary image written to %s\n", s.str().c_str()); - } - - heif_image_release(aux_image); - heif_image_handle_release(aux_handle); - } - } - - - heif_image_handle_release(handle); - } - - image_index++; - } - - // env->ReleaseByteArrayElements(byteArr, nativeByteArr, 0); - return 0; + struct heif_image_handle* aux_handle; + err = heif_image_handle_get_auxiliary_image_handle(handle, auxId, &aux_handle); + if (err.code) { + heif_image_handle_release(handle); + throwIllegalState(env, "Could not read auxiliary image"); + return 1; + } + +#ifdef _DEBUG + printf("decoding aux handle image...\n"); +#endif + int aux_bit_depth = heif_image_handle_get_luma_bits_per_pixel(aux_handle); + + struct heif_image* aux_image; + err = heif_decode_image(aux_handle, + &aux_image, + encoder->colorspace(false), + encoder->chroma(false, aux_bit_depth), + nullptr); + if (err.code) { + heif_image_handle_release(aux_handle); + heif_image_handle_release(handle); + std::string err_message = "Could not decode auxiliary image: "; + err_message += err.message; + throwIllegalState(env, err_message.c_str()); + return 1; + } + +#ifdef _DEBUG + printf("decoding aux image handle auxiliary type...\n"); +#endif + const char* auxTypeC = nullptr; + err = heif_image_handle_get_auxiliary_type(aux_handle, &auxTypeC); + if (err.code) { + heif_image_handle_release(aux_handle); + heif_image_handle_release(handle); + std::string err_message = "Could not get type of auxiliary image: "; + err_message += err.message; + throwIllegalState(env, err_message.c_str()); + return 1; + } + + std::string auxType = std::string(auxTypeC); + +#ifdef _DEBUG + printf("freeing auxiliary type.\n"); +#endif + heif_image_handle_free_auxiliary_types(aux_handle, &auxTypeC); + + std::ostringstream s; + s << output_filename.substr(0, output_filename.find('.')); + s << "-" + auxType; + s << output_filename.substr(output_filename.find('.')); + throwIllegalArgument(env, s.str().c_str()); + +#ifdef _DEBUG + printf("Writing aux to output: %s\n", s.str().c_str()); +#endif + + written = encoder->Encode(aux_handle, aux_image, s.str()); + if (!written) { +#ifdef _DEBUG + printf("could not write auxiliary image\n"); +#endif + } + else { +#ifdef _DEBUG + printf("Auxiliary image written to %s\n", s.str().c_str()); +#endif + } + + heif_image_release(aux_image); + heif_image_handle_release(aux_handle); + } + } + + + heif_image_handle_release(handle); + } + + image_index++; + } + return 0; } extern "C" { - /* - * Class: org_sleuthkit_autopsy_modules_pictureanalyzer_impls_HeifJNI - * Method: convertToDisk - * Signature: ([BLjava/lang/String;)V - */ - JNIEXPORT int JNICALL Java_org_sleuthkit_autopsy_modules_pictureanalyzer_impls_HeifJNI_convertToDisk - (JNIEnv* env, jclass cls, jbyteArray byteArr, jstring outputPath) { - return convertToDisk(env, cls, byteArr, outputPath); - } + /* + * Class: org_sleuthkit_autopsy_modules_pictureanalyzer_impls_HeifJNI + * Method: convertToDisk + * Signature: ([BLjava/lang/String;)V + */ + JNIEXPORT int JNICALL Java_org_sleuthkit_autopsy_modules_pictureanalyzer_impls_HeifJNI_convertToDisk + (JNIEnv* env, jclass cls, jbyteArray byteArr, jstring outputPath) { + return convertToDisk(env, cls, byteArr, outputPath); + } }