Compare commits
1 Commits
version.2.
...
opj-v1-bra
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c85e1a10cf |
15
AUTHORS
@@ -1,15 +0,0 @@
|
|||||||
Authors of OpenJPEG
|
|
||||||
See also the files THANKS and CHANGES
|
|
||||||
|
|
||||||
David Janssens designed and implemented the first version of OpenJPEG.
|
|
||||||
Kaori Hagihara designed and implemented the first version of OpenJPIP.
|
|
||||||
Jerome Fimes implemented the alpha version of OpenJPEG v2.
|
|
||||||
Giuseppe Baruffa added the JPWL functionalities.
|
|
||||||
Micka<EFBFBD>l Savinaud implemented the final OpenJPEG v2 version based on a big merge between 1.5 version and alpha version of v2.
|
|
||||||
Mathieu Malaterre participate to the OpenJPEG v2 version and release the OpenJPEG 1.5 and 1.5.1 version.
|
|
||||||
Yannick Verschueren,
|
|
||||||
Herve Drolon,
|
|
||||||
Francois-Olivier Devaux,
|
|
||||||
Antonin Descampe
|
|
||||||
improved the libraries and utilities.
|
|
||||||
|
|
||||||
21
CMake/CTestCustom.cmake.in
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#
|
||||||
|
# For further details regarding this file,
|
||||||
|
# see http://www.vtk.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest
|
||||||
|
#
|
||||||
|
|
||||||
|
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
|
||||||
|
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 50)
|
||||||
|
|
||||||
|
SET(CTEST_CUSTOM_COVERAGE_EXCLUDE
|
||||||
|
${CTEST_CUSTOM_COVERAGE_EXCLUDE}
|
||||||
|
|
||||||
|
# Exclude files from the Testing directories
|
||||||
|
".*/Testing/.*"
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(CTEST_CUSTOM_WARNING_EXCEPTION
|
||||||
|
${CTEST_CUSTOM_WARNING_EXCEPTION}
|
||||||
|
|
||||||
|
# Suppress warning caused by intentional messages about deprecation
|
||||||
|
".*warning,.* is deprecated"
|
||||||
|
)
|
||||||
15
CMake/CheckHaveGetopt.cmake
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Check if getopt is present:
|
||||||
|
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||||
|
SET(DONT_HAVE_GETOPT 1)
|
||||||
|
IF(UNIX) #I am pretty sure only *nix sys have this anyway
|
||||||
|
CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
|
||||||
|
# Seems like we need the contrary:
|
||||||
|
IF(CMAKE_HAVE_GETOPT_H)
|
||||||
|
SET(DONT_HAVE_GETOPT 0)
|
||||||
|
ENDIF(CMAKE_HAVE_GETOPT_H)
|
||||||
|
ENDIF(UNIX)
|
||||||
|
|
||||||
|
IF(DONT_HAVE_GETOPT)
|
||||||
|
ADD_DEFINITIONS(-DDONT_HAVE_GETOPT)
|
||||||
|
ENDIF(DONT_HAVE_GETOPT)
|
||||||
|
|
||||||
@@ -6,21 +6,21 @@
|
|||||||
# module to load OPENJPEG's settings for an external project.
|
# module to load OPENJPEG's settings for an external project.
|
||||||
@OPENJPEG_CONFIG_INSTALL_ONLY@
|
@OPENJPEG_CONFIG_INSTALL_ONLY@
|
||||||
# The OPENJPEG version number.
|
# The OPENJPEG version number.
|
||||||
set(OPENJPEG_MAJOR_VERSION "@OPENJPEG_VERSION_MAJOR@")
|
SET(OPENJPEG_MAJOR_VERSION "@OPENJPEG_VERSION_MAJOR@")
|
||||||
set(OPENJPEG_MINOR_VERSION "@OPENJPEG_VERSION_MINOR@")
|
SET(OPENJPEG_MINOR_VERSION "@OPENJPEG_VERSION_MINOR@")
|
||||||
set(OPENJPEG_BUILD_VERSION "@OPENJPEG_VERSION_BUILD@")
|
SET(OPENJPEG_BUILD_VERSION "@OPENJPEG_VERSION_BUILD@")
|
||||||
|
|
||||||
# The libraries.
|
# The libraries.
|
||||||
set(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARY_NAME@")
|
SET(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARIES@")
|
||||||
|
|
||||||
# The CMake macros dir.
|
# The CMake macros dir.
|
||||||
set(OPENJPEG_CMAKE_DIR "@OPENJPEG_INSTALL_PACKAGE_DIR@")
|
SET(OPENJPEG_CMAKE_DIR "@OPENJPEG_CMAKE_DIR_CONFIG@")
|
||||||
|
|
||||||
# The configuration options.
|
# The configuration options.
|
||||||
set(OPENJPEG_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
|
SET(OPENJPEG_BUILD_SHARED_LIBS "@OPENJPEG_BUILD_SHARED_LIBS@")
|
||||||
|
|
||||||
# The "use" file.
|
# The "use" file.
|
||||||
set(OPENJPEG_USE_FILE "@OPENJPEG_USE_FILE_CONFIG@")
|
SET(OPENJPEG_USE_FILE "@OPENJPEG_USE_FILE_CONFIG@")
|
||||||
|
|
||||||
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
@@ -29,20 +29,20 @@ if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
|||||||
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/../../@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
|
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/../../@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
|
||||||
set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_ROOT})
|
set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_ROOT})
|
||||||
|
|
||||||
else()
|
else(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
if(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
|
if(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
|
||||||
# This is a build tree
|
# This is a build tree
|
||||||
set( OPENJPEG_INCLUDE_DIRS @OPENJPEG_INCLUDE_PATH@)
|
SET( OPENJPEG_INCLUDE_DIRS @OPENJPEG_INCLUDE_PATH@)
|
||||||
|
|
||||||
include(${SELF_DIR}/OpenJPEGExports.cmake)
|
include(${SELF_DIR}/OpenJPEGExports.cmake)
|
||||||
|
|
||||||
else()
|
else(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
|
||||||
message(FATAL_ERROR "ooops")
|
message(FATAL_ERROR "ooops")
|
||||||
endif()
|
endif(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
|
||||||
endif()
|
endif(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||||
|
|
||||||
set(OPENJPEG_USE_FILE ${SELF_DIR}/UseOPENJPEG.cmake)
|
set(OPENJPEG_USE_FILE ${SELF_DIR}/UseOPENJPEG.cmake)
|
||||||
|
|
||||||
# Backward compatible part:
|
# Backward compatible part:
|
||||||
set(OPENJPEG_FOUND TRUE)
|
SET(OPENJPEG_FOUND TRUE)
|
||||||
|
|
||||||
370
CMakeLists.txt
@@ -6,73 +6,47 @@
|
|||||||
# you will eventually like to prefix the library to avoid linking confusion
|
# you will eventually like to prefix the library to avoid linking confusion
|
||||||
# For this purpose you can define a CMake var: OPENJPEG_NAMESPACE to whatever you like
|
# For this purpose you can define a CMake var: OPENJPEG_NAMESPACE to whatever you like
|
||||||
# e.g.:
|
# e.g.:
|
||||||
# set(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
|
# SET(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
|
||||||
cmake_minimum_required(VERSION 2.8.2)
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||||
|
|
||||||
if(COMMAND CMAKE_POLICY)
|
IF(COMMAND CMAKE_POLICY)
|
||||||
cmake_policy(SET CMP0003 NEW)
|
CMAKE_POLICY(SET CMP0003 NEW)
|
||||||
endif()
|
ENDIF(COMMAND CMAKE_POLICY)
|
||||||
|
|
||||||
if(NOT OPENJPEG_NAMESPACE)
|
IF(NOT OPENJPEG_NAMESPACE)
|
||||||
set(OPENJPEG_NAMESPACE "OPENJPEG")
|
SET(OPENJPEG_NAMESPACE "OPENJPEG")
|
||||||
set(OPENJPEG_STANDALONE 1)
|
SET(OPENJPEG_STANDALONE 1)
|
||||||
endif()
|
ENDIF(NOT OPENJPEG_NAMESPACE)
|
||||||
# In all cases:
|
# In all cases:
|
||||||
#string(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
|
STRING(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
|
||||||
set(OPENJPEG_LIBRARY_NAME openjp2)
|
|
||||||
|
|
||||||
project(${OPENJPEG_NAMESPACE} C)
|
PROJECT(${OPENJPEG_NAMESPACE} C)
|
||||||
|
|
||||||
# Do full dependency headers.
|
# Do full dependency headers.
|
||||||
include_regular_expression("^.*$")
|
INCLUDE_REGULAR_EXPRESSION("^.*$")
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# OPENJPEG version number, useful for packaging and doxygen doc:
|
# OPENJPEG version number, useful for packaging and doxygen doc:
|
||||||
set(OPENJPEG_VERSION_MAJOR 2)
|
SET(OPENJPEG_VERSION_MAJOR 1)
|
||||||
set(OPENJPEG_VERSION_MINOR 0)
|
SET(OPENJPEG_VERSION_MINOR 4)
|
||||||
set(OPENJPEG_VERSION_BUILD 0)
|
SET(OPENJPEG_VERSION_BUILD 0)
|
||||||
set(OPENJPEG_VERSION
|
SET(OPENJPEG_VERSION
|
||||||
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||||
set(PACKAGE_VERSION
|
SET(PACKAGE_VERSION
|
||||||
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||||
|
SET(OPENJPEG_LIBRARY_PROPERTIES
|
||||||
# Because autotools does not support X.Y notation for SOVERSION, we have to use
|
|
||||||
# two numbering, one for the openjpeg version and one for openjpeg soversion
|
|
||||||
# version | soversion
|
|
||||||
# 1.0 | 0
|
|
||||||
# 1.1 | 1
|
|
||||||
# 1.2 | 2
|
|
||||||
# 1.3 | 3
|
|
||||||
# 1.4 | 4
|
|
||||||
# 1.5 | 5
|
|
||||||
# 1.5.1 | 5
|
|
||||||
# 2.0 | 6
|
|
||||||
# above is the recommendation by the OPJ team. If you really need to override this default,
|
|
||||||
# you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
|
|
||||||
# cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg
|
|
||||||
if(NOT OPENJPEG_SOVERSION)
|
|
||||||
SET(OPENJPEG_SOVERSION 6)
|
|
||||||
endif(NOT OPENJPEG_SOVERSION)
|
|
||||||
set(OPENJPEG_LIBRARY_PROPERTIES
|
|
||||||
VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
|
VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
|
||||||
SOVERSION "${OPENJPEG_SOVERSION}"
|
SOVERSION "${OPENJPEG_VERSION_MAJOR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
|
||||||
# Path to additional CMake modules
|
|
||||||
set(CMAKE_MODULE_PATH
|
|
||||||
${CMAKE_SOURCE_DIR}/cmake
|
|
||||||
${CMAKE_MODULE_PATH})
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
|
||||||
# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
|
# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
|
||||||
# warnings
|
# warnings
|
||||||
if(WIN32)
|
IF(WIN32)
|
||||||
if(NOT BORLAND)
|
IF(NOT BORLAND)
|
||||||
if(NOT CYGWIN)
|
IF(NOT CYGWIN)
|
||||||
if(NOT MINGW)
|
IF(NOT MINGW)
|
||||||
if(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
|
IF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
|
||||||
add_definitions(
|
ADD_DEFINITIONS(
|
||||||
-D_CRT_FAR_MAPPINGS_NO_DEPRECATE
|
-D_CRT_FAR_MAPPINGS_NO_DEPRECATE
|
||||||
-D_CRT_IS_WCTYPE_NO_DEPRECATE
|
-D_CRT_IS_WCTYPE_NO_DEPRECATE
|
||||||
-D_CRT_MANAGED_FP_NO_DEPRECATE
|
-D_CRT_MANAGED_FP_NO_DEPRECATE
|
||||||
@@ -84,206 +58,204 @@ if(WIN32)
|
|||||||
-D_CRT_VCCLRIT_NO_DEPRECATE
|
-D_CRT_VCCLRIT_NO_DEPRECATE
|
||||||
-D_SCL_SECURE_NO_DEPRECATE
|
-D_SCL_SECURE_NO_DEPRECATE
|
||||||
)
|
)
|
||||||
endif()
|
ENDIF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
|
||||||
endif()
|
ENDIF(NOT MINGW)
|
||||||
endif()
|
ENDIF(NOT CYGWIN)
|
||||||
endif()
|
ENDIF(NOT BORLAND)
|
||||||
endif()
|
ENDIF(WIN32)
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Install directories
|
# Install directories
|
||||||
|
|
||||||
string(TOLOWER ${PROJECT_NAME} projectname)
|
STRING(TOLOWER ${PROJECT_NAME} projectname)
|
||||||
set(OPENJPEG_INSTALL_SUBDIR "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
|
SET(OPENJPEG_INSTALL_SUBDIR "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
|
||||||
|
|
||||||
if(NOT OPENJPEG_INSTALL_BIN_DIR)
|
IF(NOT OPENJPEG_INSTALL_BIN_DIR)
|
||||||
set(OPENJPEG_INSTALL_BIN_DIR "bin")
|
SET(OPENJPEG_INSTALL_BIN_DIR "bin")
|
||||||
endif()
|
ENDIF(NOT OPENJPEG_INSTALL_BIN_DIR)
|
||||||
|
|
||||||
if(NOT OPENJPEG_INSTALL_LIB_DIR)
|
IF(NOT OPENJPEG_INSTALL_LIB_DIR)
|
||||||
set(OPENJPEG_INSTALL_LIB_DIR "lib")
|
SET(OPENJPEG_INSTALL_LIB_DIR "lib")
|
||||||
endif()
|
ENDIF(NOT OPENJPEG_INSTALL_LIB_DIR)
|
||||||
|
|
||||||
if(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
IF(NOT OPENJPEG_INSTALL_DATA_DIR)
|
||||||
set(OPENJPEG_INSTALL_SHARE_DIR "share")
|
SET(OPENJPEG_INSTALL_DATA_DIR "share/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
endif()
|
ENDIF(NOT OPENJPEG_INSTALL_DATA_DIR)
|
||||||
|
|
||||||
if(NOT OPENJPEG_INSTALL_DATA_DIR)
|
IF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||||
set(OPENJPEG_INSTALL_DATA_DIR "${OPENJPEG_INSTALL_SHARE_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
SET(OPENJPEG_INSTALL_INCLUDE_DIR "include/")
|
||||||
endif()
|
ENDIF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||||
|
|
||||||
if(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
IF(NOT OPENJPEG_INSTALL_MAN_DIR)
|
||||||
set(OPENJPEG_INSTALL_INCLUDE_DIR "include/${OPENJPEG_INSTALL_SUBDIR}")
|
SET(OPENJPEG_INSTALL_MAN_DIR "share/man/")
|
||||||
endif()
|
ENDIF(NOT OPENJPEG_INSTALL_MAN_DIR)
|
||||||
|
|
||||||
if(NOT OPENJPEG_INSTALL_MAN_DIR)
|
IF(NOT OPENJPEG_INSTALL_DOC_DIR)
|
||||||
set(OPENJPEG_INSTALL_MAN_DIR "share/man/")
|
SET(OPENJPEG_INSTALL_DOC_DIR "share/doc/${OPENJPEG_INSTALL_SUBDIR}")
|
||||||
endif()
|
ENDIF(NOT OPENJPEG_INSTALL_DOC_DIR)
|
||||||
|
|
||||||
if(NOT OPENJPEG_INSTALL_DOC_DIR)
|
IF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||||
set(OPENJPEG_INSTALL_DOC_DIR "share/doc/${OPENJPEG_INSTALL_SUBDIR}")
|
SET(OPENJPEG_INSTALL_PACKAGE_DIR ${OPENJPEG_INSTALL_LIB_DIR}/${OPENJPEG_INSTALL_SUBDIR}
|
||||||
endif()
|
CACHE INTERNAL "")
|
||||||
|
ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||||
if(NOT OPENJPEG_INSTALL_JNI_DIR)
|
|
||||||
if(WIN32)
|
|
||||||
set(OPENJPEG_INSTALL_JNI_DIR ${OPENJPEG_INSTALL_BIN_DIR})
|
|
||||||
else()
|
|
||||||
set(OPENJPEG_INSTALL_JNI_DIR ${OPENJPEG_INSTALL_LIB_DIR})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
|
||||||
# We could install *.cmake files in share/ however those files contains
|
|
||||||
# hardcoded path to libraries on a multi-arch system (fedora/debian) those
|
|
||||||
# path will be different (lib/i386-linux-gnu vs lib/x86_64-linux-gnu)
|
|
||||||
set(OPENJPEG_INSTALL_PACKAGE_DIR "${OPENJPEG_INSTALL_LIB_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Big endian test:
|
# Test for some required system information.
|
||||||
include (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
|
INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
|
||||||
TEST_BIG_ENDIAN(OPJ_BIG_ENDIAN)
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Test for getopt being available in this system
|
||||||
|
INCLUDE (${OPENJPEG_SOURCE_DIR}/CMake/CheckHaveGetopt.cmake )
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Setup file for setting custom ctest vars
|
# Setup file for setting custom ctest vars
|
||||||
configure_file(
|
CONFIGURE_FILE(
|
||||||
${CMAKE_SOURCE_DIR}/cmake/CTestCustom.cmake.in
|
${CMAKE_SOURCE_DIR}/CMake/CTestCustom.cmake.in
|
||||||
${CMAKE_BINARY_DIR}/CTestCustom.cmake
|
${CMAKE_BINARY_DIR}/CTestCustom.cmake
|
||||||
@ONLY
|
@ONLY
|
||||||
)
|
)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# OpenJPEG build configuration options.
|
# OpenJPEG build configuration options.
|
||||||
option(BUILD_SHARED_LIBS "Build OpenJPEG shared library and link executables against it." ON)
|
OPTION(BUILD_SHARED_LIBS "Build OpenJPEG shared library and link executables against it." ON)
|
||||||
set (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
|
SET (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
|
||||||
set (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
|
SET (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
|
||||||
mark_as_advanced(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
|
MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# configure name mangling to allow multiple libraries to coexist
|
# configure name mangling to allow multiple libraries to coexist
|
||||||
# peacefully
|
# peacefully
|
||||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
||||||
set(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
|
SET(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
|
${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
|
||||||
@ONLY)
|
@ONLY IMMEDIATE)
|
||||||
endif()
|
ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# pkgconfig support
|
||||||
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libopenjpeg1.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc @ONLY)
|
||||||
|
INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc DESTINATION ${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||||
|
INSTALL( CODE
|
||||||
|
"EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink \"libopenjpeg1.pc\" \"\$ENV{DESTDIR}${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig/libopenjpeg.pc\")")
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Compiler specific flags:
|
# Compiler specific flags:
|
||||||
if(CMAKE_COMPILER_IS_GNUCC)
|
IF(CMAKE_COMPILER_IS_GNUCC)
|
||||||
# For all builds, make sure openjpeg is std99 compliant:
|
# For all builds, make sure openjpeg is std99 compliant:
|
||||||
# set(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
|
# SET(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
|
||||||
# Do not use ffast-math for all build, it would produce incorrect results, only set for release:
|
# Do not use ffast-math for all build, it would produce incorrect results, only set for release:
|
||||||
set(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
|
SET(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
|
||||||
endif()
|
ENDIF(CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# opj_config.h generation (1/2)
|
# opj_config.h generation
|
||||||
include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
FIND_FILE(HAVE_STRINGS_H_FOUND strings.h)
|
||||||
CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
|
IF(NOT HAVE_STRINGS_H_FOUND STREQUAL "HAVE_STRINGS_H_FOUND-NOTFOUND")
|
||||||
CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
|
FIND_FILE(HAVE_STRINGS_H strings.h)
|
||||||
CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
|
SET(HAS_STRINGS_H 1)
|
||||||
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
|
ENDIF()
|
||||||
CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H)
|
FIND_FILE(HAVE_INTTYPES_H_FOUND inttypes.h)
|
||||||
CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
|
IF(NOT HAVE_INTTYPES_H_FOUND STREQUAL "HAVE_INTTYPES_H_FOUND-NOTFOUND")
|
||||||
CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
|
FIND_FILE(HAVE_INTTYPES_H inttypes.h)
|
||||||
CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
|
SET(HAS_INTTYPES_H 1)
|
||||||
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
|
ENDIF()
|
||||||
# ssize_t
|
FIND_FILE(HAVE_MEMORY_H_FOUND memory.h)
|
||||||
include(CheckTypeSize)
|
IF(NOT HAVE_MEMORY_H_FOUND STREQUAL "HAVE_MEMORY_H_FOUND-NOTFOUND")
|
||||||
CHECK_TYPE_SIZE(ssize_t SSIZE_T)
|
FIND_FILE(HAVE_MEMORY_H memory.h)
|
||||||
|
SET(HAS_MEMORY_H 1)
|
||||||
# Enable Large file support
|
ENDIF()
|
||||||
include(TestLargeFiles)
|
FIND_FILE(HAVE_STDINT_H_FOUND stdint.h)
|
||||||
OPJ_TEST_LARGE_FILES(OPJ_HAVE_LARGEFILES)
|
IF(NOT HAVE_STDINT_H_FOUND STREQUAL "HAVE_STDINT_H_FOUND-NOTFOUND")
|
||||||
|
FIND_FILE(HAVE_STDINT_H stdint.h)
|
||||||
#-----------------------------------------------------------------------------
|
SET(HAS_STDINT_H 1)
|
||||||
# Build Library
|
ENDIF()
|
||||||
add_subdirectory(src)
|
FIND_FILE(HAVE_STDLIB_H_FOUND stdlib.h)
|
||||||
|
IF(NOT HAVE_STDLIB_H_FOUND STREQUAL "HAVE_STDLIB_H_FOUND-NOTFOUND")
|
||||||
#-----------------------------------------------------------------------------
|
FIND_FILE(HAVE_STDLIB_H stdlib.h)
|
||||||
# Build Applications
|
SET(HAS_STDLIB_H 1)
|
||||||
option(BUILD_CODEC "Build the CODEC executables" ON)
|
ENDIF()
|
||||||
option(BUILD_MJ2 "Build the MJ2 executables." OFF)
|
FIND_FILE(HAVE_STRING_H_FOUND string.h)
|
||||||
option(BUILD_JPWL "Build the JPWL library and executables" OFF)
|
IF(NOT HAVE_STRING_H_FOUND STREQUAL "HAVE_STRING_H_FOUND-NOTFOUND")
|
||||||
option(BUILD_JPIP "Build the JPIP library and executables." OFF)
|
FIND_FILE(HAVE_STRING_H string.h)
|
||||||
if(BUILD_JPIP)
|
SET(HAS_STRING_H 1)
|
||||||
option(BUILD_JPIP_SERVER "Build the JPIP server." OFF)
|
ENDIF()
|
||||||
endif()
|
FIND_FILE(HAVE_SYS_STAT_H_FOUND sys/stat.h)
|
||||||
option(BUILD_VIEWER "Build the OPJViewer executable (C++)" OFF)
|
IF(NOT HAVE_SYS_STAT_H_FOUND STREQUAL "HAVE_SYS_STAT_H_FOUND-NOTFOUND")
|
||||||
option(BUILD_JAVA "Build the openjpeg jar (Java)" OFF)
|
FIND_FILE(HAVE_SYS_STAT_H sys/stat.h)
|
||||||
option(BUILD_JP3D "Build the JP3D comp" OFF)
|
SET(HAS_SYS_STAT_H 1)
|
||||||
mark_as_advanced(BUILD_VIEWER)
|
ENDIF()
|
||||||
mark_as_advanced(BUILD_JAVA)
|
FIND_FILE(HAVE_SYS_TYPES_H_FOUND sys/types.h)
|
||||||
mark_as_advanced(BUILD_JP3D)
|
IF(NOT HAVE_SYS_TYPES_H_FOUND STREQUAL "HAVE_SYS_TYPES_H_FOUND-NOTFOUND")
|
||||||
|
FIND_FILE(HAVE_SYS_TYPES_H sys/types.h)
|
||||||
if(BUILD_CODEC OR BUILD_MJ2)
|
SET(HAS_SYS_TYPES_H 1)
|
||||||
# OFF: It will only build 3rd party libs if they are not found on the system
|
ENDIF()
|
||||||
# ON: 3rd party libs will ALWAYS be build, and used
|
FIND_FILE(HAVE_UNISTD_H_FOUND unistd.h)
|
||||||
option(BUILD_THIRDPARTY "Build the thirdparty executables if it is needed" OFF)
|
IF(NOT HAVE_UNISTD_H_FOUND STREQUAL "HAVE_UNISTD_H_FOUND-NOTFOUND")
|
||||||
add_subdirectory(thirdparty)
|
FIND_FILE(HAVE_UNISTD_H unistd.h)
|
||||||
add_subdirectory(src/bin)
|
SET(HAS_UNISTD_H 1)
|
||||||
endif ()
|
ENDIF()
|
||||||
add_subdirectory(wrapping)
|
CONFIGURE_FILE("${OPENJPEG_SOURCE_DIR}/opj_configh.cmake.in"
|
||||||
|
"${OPENJPEG_BINARY_DIR}/opj_config.h"
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# opj_config.h generation (2/2)
|
|
||||||
configure_file(
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/opj_config.h.cmake.in
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/src/lib/openjp2/opj_config.h
|
|
||||||
@ONLY
|
@ONLY
|
||||||
)
|
)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
|
# CDash+CMake : to be updated
|
||||||
option(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
|
OPTION(BUILD_TESTING "Build the tests." OFF)
|
||||||
if(BUILD_DOC)
|
IF(BUILD_TESTING)
|
||||||
add_subdirectory(doc)
|
ENABLE_TESTING()
|
||||||
endif()
|
INCLUDE(CTest)
|
||||||
|
ENDIF(BUILD_TESTING)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Buld Testing
|
# Build Library
|
||||||
option(BUILD_TESTING "Build the tests." OFF)
|
INCLUDE_DIRECTORIES(BEFORE ${OPENJPEG_BINARY_DIR})
|
||||||
if(BUILD_TESTING)
|
ADD_SUBDIRECTORY(libopenjpeg)
|
||||||
if(BUILD_CODEC)
|
|
||||||
enable_testing()
|
|
||||||
include(CTest)
|
|
||||||
|
|
||||||
# Search openjpeg data needed for the tests
|
#-----------------------------------------------------------------------------
|
||||||
# They could be found via svn on the OpenJPEG google code project
|
# Build Applications
|
||||||
# svn checkout http://openjpeg.googlecode.com/svn/data (about 70 Mo)
|
OPTION(BUILD_CODEC "Build the CODEC executables" ON)
|
||||||
find_path(OPJ_DATA_ROOT README-OPJ-Data
|
OPTION(BUILD_MJ2 "Build the MJ2 executables." OFF)
|
||||||
PATHS
|
ADD_SUBDIRECTORY(applications)
|
||||||
$ENV{OPJ_DATA_ROOT}
|
|
||||||
${CMAKE_SOURCE_DIR}/../data
|
|
||||||
)
|
|
||||||
|
|
||||||
# Add repository where to find tests
|
#-----------------------------------------------------------------------------
|
||||||
add_subdirectory(tests)
|
# Build JPWL-flavoured library and executables
|
||||||
|
OPTION(BUILD_JPWL "Build the JPWL library and executables" OFF)
|
||||||
|
|
||||||
else()
|
#-----------------------------------------------------------------------------
|
||||||
message(FATAL_ERROR "You need build codec to run the tests")
|
# Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
|
||||||
endif()
|
ADD_SUBDIRECTORY(doc)
|
||||||
endif()
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Tests data
|
||||||
|
IF(BUILD_TESTING)
|
||||||
|
# Adding test with dataset from:
|
||||||
|
# http://www.openjpeg.org/conformance/j2kp4files_v1_5.zip
|
||||||
|
# -> wget http://www.openjpeg.org/conformance/j2kp4files_v1_5.zip
|
||||||
|
# http://www.jpeg.org/jpeg2000guide/testimages/testimages.html
|
||||||
|
# Adding JPEG2000_CONFORMANCE_DATA_ROOT
|
||||||
|
FIND_PATH(JPEG2000_CONFORMANCE_DATA_ROOT testimages.html
|
||||||
|
${OPENJPEG_SOURCE_DIR}/../jpeg2000testimages
|
||||||
|
$ENV{JPEG2000_CONFORMANCE_DATA_ROOT}
|
||||||
|
)
|
||||||
|
ENDIF(BUILD_TESTING)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# install all targets referenced as OPENJPEGTargets
|
# install all targets referenced as OPENJPEGTargets
|
||||||
install(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
|
INSTALL(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
|
||||||
configure_file( ${OPENJPEG_SOURCE_DIR}/cmake/OpenJPEGConfig.cmake.in
|
CONFIGURE_FILE( ${OPENJPEG_SOURCE_DIR}/CMake/OpenJPEGConfig.cmake.in
|
||||||
${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||||
@ONLY
|
@ONLY
|
||||||
)
|
)
|
||||||
install( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
INSTALL( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||||
DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}
|
DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# install CHANGES and LICENSE
|
# install CHANGES and LICENSE
|
||||||
if(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
|
INSTALL(
|
||||||
install(FILES CHANGES DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
FILES CHANGES
|
||||||
endif()
|
LICENSE
|
||||||
install(FILES LICENSE DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||||
|
|
||||||
include (cmake/OpenJPEGCPack.cmake)
|
|
||||||
|
|||||||
85
INSTALL
@@ -2,10 +2,45 @@
|
|||||||
How to build and install openjpeg binaries
|
How to build and install openjpeg binaries
|
||||||
==========================================
|
==========================================
|
||||||
|
|
||||||
UNIX/LINUX/MacOSX/Windows systems
|
UNIX/LINUX similar systems
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
Using cmake (see www.cmake.org)
|
1) Using configure tools
|
||||||
|
|
||||||
|
To build from top-level directory, you can simply type:
|
||||||
|
./bootstrap.sh
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
|
||||||
|
To keep all build files in a separate directory, you can type instead:
|
||||||
|
./bootstrap.sh
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
../configure
|
||||||
|
make
|
||||||
|
|
||||||
|
To install:
|
||||||
|
sudo make install
|
||||||
|
|
||||||
|
To clean:
|
||||||
|
make clean
|
||||||
|
make distclean
|
||||||
|
|
||||||
|
To build doc (requires 'doxygen' to be found on your system):
|
||||||
|
(this will create an html directory in TOP_LEVEL/doc)
|
||||||
|
make doc
|
||||||
|
|
||||||
|
Main './configure' options (type './configure --help' for more details)
|
||||||
|
'--enable-mj2'
|
||||||
|
'--enable-jpwl'
|
||||||
|
'--prefix=/path/to/install/directory' (example : '--prefix=$PWD/installed')
|
||||||
|
'--enable-debug' (default : disabled)
|
||||||
|
|
||||||
|
You can also specify your own CFLAGS and LDFLAGS with (for example):
|
||||||
|
CFLAGS="-O3 -pipe" LDFLAGS="-Wl,-s" ./configure
|
||||||
|
|
||||||
|
|
||||||
|
2) Using cmake (see www.cmake.org)
|
||||||
|
|
||||||
Type:
|
Type:
|
||||||
cmake .
|
cmake .
|
||||||
@@ -13,12 +48,11 @@ Type:
|
|||||||
|
|
||||||
If you are root:
|
If you are root:
|
||||||
make install
|
make install
|
||||||
|
make clean
|
||||||
|
|
||||||
else if you have sudo power:
|
else:
|
||||||
sudo make install
|
sudo make install
|
||||||
|
make clean
|
||||||
else
|
|
||||||
DESTDIR=$HOME/local make install
|
|
||||||
|
|
||||||
To build the Doxygen documentation (Doxygen needs to be found on the system):
|
To build the Doxygen documentation (Doxygen needs to be found on the system):
|
||||||
(A 'html' directory is generated in the 'doc' directory)
|
(A 'html' directory is generated in the 'doc' directory)
|
||||||
@@ -27,32 +61,35 @@ To build the Doxygen documentation (Doxygen needs to be found on the system):
|
|||||||
Binaries are located in the 'bin' directory.
|
Binaries are located in the 'bin' directory.
|
||||||
|
|
||||||
Main available cmake flags:
|
Main available cmake flags:
|
||||||
* To specify the install path: '-DCMAKE_INSTALL_PREFIX=/path', or use DESTDIR env variable (see above)
|
* To specify the install path: '-DCMAKE_INSTALL_PREFIX=/path'
|
||||||
* To build the shared libraries and links the executables against it: '-DBUILD_SHARED_LIBS:bool=on' (default: 'ON')
|
* To build the shared libraries and links the executables against it: '-DBUILD_SHARED_LIBS:bool=on' (default: 'ON')
|
||||||
Note: when using this option, static libraries are not built and executables are dynamically linked.
|
Note: when using this option, static libraries are not built and executables are dynamically linked.
|
||||||
* To build the CODEC executables: '-DBUILD_CODEC:bool=on' (default: 'ON')
|
* To build the CODEC executables: '-DBUILD_CODEC:bool=on' (default: 'ON')
|
||||||
* To build the documentation: '-DBUILD_DOC:bool=on' (default: 'OFF')
|
|
||||||
* To build the MJ2 executables: '-DBUILD_MJ2:bool=on' (default: 'OFF')
|
* To build the MJ2 executables: '-DBUILD_MJ2:bool=on' (default: 'OFF')
|
||||||
* To build the JPWL executables and JPWL library: '-DBUILD_JPWL:bool=on' (default: 'OFF')
|
* To build the JPWL executables and JPWL library: '-DBUILD_JPWL:bool=on' (default: 'OFF')
|
||||||
* To build the JPIP library and utilities: '-DBUILD_JPIP:bool=on' (default: 'OFF')
|
|
||||||
** To build the JPIP server: '-DBUILD_JPIP_SERVER:bool=on' (default: 'OFF')
|
|
||||||
* To build the JP3D library and utilities: '-DBUILD_JP3D:bool=on' (default: 'OFF') (experimental)
|
|
||||||
* To build the Java binding: '-DBUILD_JAVA:bool=on' (default: 'OFF') (experimental).
|
|
||||||
** to choose which java implementation, you can set your JAVA_HOME env var.
|
|
||||||
* To build the wxWidgets/C++ viewer: 'BUILD_VIEWER:BOOL=ON' (default OFF) (experimental)
|
|
||||||
* To enable testing (and automatic result upload to http://my.cdash.org/index.php?project=OPENJPEG):
|
* To enable testing (and automatic result upload to http://my.cdash.org/index.php?project=OPENJPEG):
|
||||||
cmake . -DBUILD_TESTING:BOOL=ON -DOPJ_DATA_ROOT:PATH='path/to/the/data/directory'
|
cmake . -DBUILD_TESTING:BOOL=ON -DJPEG2000_CONFORMANCE_DATA_ROOT:PATH=/path/to/your/JPEG2000/test/files
|
||||||
make
|
make
|
||||||
make Experimental
|
make Experimental
|
||||||
Note : JPEG2000 test files are available with 'svn checkout http://openjpeg.googlecode.com/svn/data' (about 70 Mo).
|
Note : JPEG2000 test files are available here : http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
|
||||||
If '-DOPJ_DATA_ROOT:PATH' option is omitted, test files will be automatically searched in '${CMAKE_SOURCE_DIR}/../data',
|
|
||||||
corresponding to the location of the data directory when compiling from the trunk (and assuming the data directory has
|
3) Manually using Makefile.nix:
|
||||||
been checked out of course).
|
- Manually edit the config.nix file
|
||||||
|
- Manually create an opj_config.h file from opj_config.h.in.user
|
||||||
|
and edit this opj_config.h
|
||||||
|
- Then : (if 'WITH_JPWL' is defined in config.nix)
|
||||||
|
make -f Makefile.nix all
|
||||||
|
make -f Makefile.nix install
|
||||||
|
make -f Makefile.nix clean
|
||||||
|
make -f Makefile.nix uninstall
|
||||||
|
- If 'WITH_JPWL' is not defined in config.nix
|
||||||
|
and you want to clean/compile/install/uninstall JPWL:
|
||||||
|
call the respective target in the respective directory.
|
||||||
|
|
||||||
MACOSX
|
MACOSX
|
||||||
------
|
------
|
||||||
|
|
||||||
The same building procedures as above work for MACOSX.
|
The same building procedures as above (autotools and cmake) work for MACOSX.
|
||||||
The xcode project file can also be used.
|
The xcode project file can also be used.
|
||||||
|
|
||||||
If it does not work, try adding the following flag to the cmake command :
|
If it does not work, try adding the following flag to the cmake command :
|
||||||
@@ -61,9 +98,7 @@ If it does not work, try adding the following flag to the cmake command :
|
|||||||
WINDOWS
|
WINDOWS
|
||||||
-------
|
-------
|
||||||
|
|
||||||
You can use cmake to generate project files for the IDE you are using (VS2010, NMake, etc).
|
If you're using cygwin or MinGW, the same procedures as for Unix can be used.
|
||||||
|
|
||||||
|
Otherwise you can use cmake to generate project files for the IDE you are using (VC2010, etc).
|
||||||
Type 'cmake --help' for available generators on your platform.
|
Type 'cmake --help' for available generators on your platform.
|
||||||
|
|
||||||
Make sure to build the third party libs (png, zlib ...):
|
|
||||||
|
|
||||||
'-DBUILD_THIRDPARTY:BOOL=ON'
|
|
||||||
|
|||||||
14
LICENSE
@@ -1,14 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2012, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2012, Professor Benoit Macq
|
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||||
* Copyright (c) 2003-2012, Antonin Descampe
|
|
||||||
* Copyright (c) 2003-2009, Francois-Olivier Devaux
|
|
||||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
|
||||||
* Copyright (c) 2001-2003, David Janssens
|
* Copyright (c) 2001-2003, David Janssens
|
||||||
* Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
* Copyright (c) 2012, CS Systemes d'Information, France
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
*
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
|||||||
59
Makefile.am
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
DISTCHECK_CONFIGURE_FLAGS = --enable-jpip=yes --enable-jpwl=yes --enable-mj2=yes
|
||||||
|
|
||||||
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
|
SUBDIRS = libopenjpeg applications doc
|
||||||
|
|
||||||
|
pkgconfigdir = $(libdir)/pkgconfig
|
||||||
|
pkgconfig_DATA = libopenjpeg1.pc
|
||||||
|
|
||||||
|
|
||||||
|
MAINTAINERCLEANFILES = \
|
||||||
|
Makefile.in \
|
||||||
|
aclocal.m4 \
|
||||||
|
config.guess \
|
||||||
|
opj_config.h.in \
|
||||||
|
opj_config.h.in~ \
|
||||||
|
config.sub \
|
||||||
|
configure \
|
||||||
|
depcomp \
|
||||||
|
install-sh \
|
||||||
|
ltmain.sh \
|
||||||
|
missing
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
CMake/CheckHaveGetopt.cmake \
|
||||||
|
CMake/OpenJPEGConfig.cmake.in \
|
||||||
|
testing/CTestCustom.cmake.in \
|
||||||
|
testing/CTestConfig.cmake \
|
||||||
|
CMakeLists.txt \
|
||||||
|
LICENSE \
|
||||||
|
CHANGES \
|
||||||
|
README \
|
||||||
|
INSTALL \
|
||||||
|
bootstrap.sh \
|
||||||
|
libopenjpeg1.pc.cmake \
|
||||||
|
libopenjpeg1.pc.in \
|
||||||
|
opj_configh.cmake.in \
|
||||||
|
opj_config.h.in.user \
|
||||||
|
m4/opj_check_lib.m4 \
|
||||||
|
m4/opj_doxygen.m4 \
|
||||||
|
m4/pkg.m4
|
||||||
|
|
||||||
|
.PHONY: doc
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
|
||||||
|
doc:
|
||||||
|
@echo "entering doc/"
|
||||||
|
@cd doc && make doc
|
||||||
|
|
||||||
|
install-data-hook:
|
||||||
|
$(LN_S) -nf libopenjpeg1.pc $(DESTDIR)$(pkgconfigdir)/libopenjpeg.pc
|
||||||
|
@echo -e " (PC)\t$(pkgconfigdir)/libopenjpeg1.pc" >> $(top_builddir)/report.txt
|
||||||
|
@echo -e " (LN)\t$(pkgconfigdir)/libopenjpeg.pc" >> $(top_builddir)/report.txt
|
||||||
|
@cat $(top_builddir)/report.txt
|
||||||
|
@rm $(top_builddir)/report.txt
|
||||||
|
|
||||||
|
uninstall-hook:
|
||||||
|
rm -f $(DESTDIR)$(pkgconfigdir)/libopenjpeg.pc
|
||||||
183
Makefile.nix
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
#top Makefile.nix
|
||||||
|
include config.nix
|
||||||
|
|
||||||
|
TARGET = openjpeg
|
||||||
|
COMPILERFLAGS = -Wall -O3 -ffast-math -std=c99 -fPIC
|
||||||
|
|
||||||
|
INCLUDE = -I. -Ilibopenjpeg
|
||||||
|
LIBRARIES = -lstdc++
|
||||||
|
|
||||||
|
SRCS = ./libopenjpeg/bio.c ./libopenjpeg/cio.c ./libopenjpeg/dwt.c \
|
||||||
|
./libopenjpeg/event.c ./libopenjpeg/image.c ./libopenjpeg/j2k.c \
|
||||||
|
./libopenjpeg/j2k_lib.c ./libopenjpeg/jp2.c ./libopenjpeg/jpt.c \
|
||||||
|
./libopenjpeg/mct.c ./libopenjpeg/mqc.c ./libopenjpeg/openjpeg.c \
|
||||||
|
./libopenjpeg/pi.c ./libopenjpeg/raw.c ./libopenjpeg/t1.c \
|
||||||
|
./libopenjpeg/t2.c ./libopenjpeg/tcd.c ./libopenjpeg/tgt.c \
|
||||||
|
|
||||||
|
INCLS = ./libopenjpeg/bio.h ./libopenjpeg/cio.h ./libopenjpeg/dwt.h \
|
||||||
|
./libopenjpeg/event.h ./libopenjpeg/fix.h ./libopenjpeg/image.h \
|
||||||
|
./libopenjpeg/int.h ./libopenjpeg/j2k.h ./libopenjpeg/j2k_lib.h \
|
||||||
|
./libopenjpeg/jp2.h ./libopenjpeg/jpt.h ./libopenjpeg/mct.h \
|
||||||
|
./libopenjpeg/mqc.h ./libopenjpeg/openjpeg.h ./libopenjpeg/pi.h \
|
||||||
|
./libopenjpeg/raw.h ./libopenjpeg/t1.h ./libopenjpeg/t2.h \
|
||||||
|
./libopenjpeg/tcd.h ./libopenjpeg/tgt.h ./libopenjpeg/opj_malloc.h \
|
||||||
|
./libopenjpeg/opj_includes.h
|
||||||
|
|
||||||
|
INSTALL_LIBDIR = $(prefix)/lib
|
||||||
|
headerdir = openjpeg-$(MAJOR).$(MINOR)
|
||||||
|
INSTALL_INCLUDE = $(prefix)/include/$(headerdir)
|
||||||
|
|
||||||
|
# Converts cr/lf to just lf
|
||||||
|
DOS2UNIX = dos2unix
|
||||||
|
|
||||||
|
MODULES = $(SRCS:.c=.o)
|
||||||
|
|
||||||
|
CFLAGS = $(COMPILERFLAGS) $(INCLUDE)
|
||||||
|
|
||||||
|
LIBNAME = lib$(TARGET)
|
||||||
|
|
||||||
|
ifeq ($(ENABLE_SHARED),yes)
|
||||||
|
SHAREDLIB = $(LIBNAME).so.$(MAJOR).$(MINOR).$(BUILD)
|
||||||
|
else
|
||||||
|
STATICLIB = $(LIBNAME).a
|
||||||
|
endif
|
||||||
|
|
||||||
|
default: all
|
||||||
|
|
||||||
|
all: OpenJPEG
|
||||||
|
make -C codec -f Makefile.nix all
|
||||||
|
make -C mj2 -f Makefile.nix all
|
||||||
|
ifeq ($(WITH_JPWL),yes)
|
||||||
|
make -C jpwl -f Makefile.nix all
|
||||||
|
endif
|
||||||
|
ifeq ($(WITH_JP3D),yes)
|
||||||
|
make -C jp3d -f Makefile.nix all
|
||||||
|
endif
|
||||||
|
|
||||||
|
dos2unix:
|
||||||
|
@$(DOS2UNIX) $(SRCS) $(INCLS)
|
||||||
|
|
||||||
|
OpenJPEG: $(STATICLIB) $(SHAREDLIB)
|
||||||
|
install -d bin
|
||||||
|
ifeq ($(ENABLE_SHARED),yes)
|
||||||
|
install -m 755 $(SHAREDLIB) bin
|
||||||
|
(cd bin && ln -sf $(SHAREDLIB) $(LIBNAME).so.$(MAJOR).$(MINOR))
|
||||||
|
(cd bin && ln -sf $(SHAREDLIB) $(LIBNAME).so)
|
||||||
|
else
|
||||||
|
install -m 644 $(STATICLIB) bin
|
||||||
|
endif
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
ifeq ($(ENABLE_SHARED),yes)
|
||||||
|
$(SHAREDLIB): $(MODULES)
|
||||||
|
$(CC) -shared -Wl,-soname,$(LIBNAME) -o $@ $(MODULES) $(LIBRARIES)
|
||||||
|
else
|
||||||
|
$(STATICLIB): $(MODULES)
|
||||||
|
rm -f $(STATICLIB)
|
||||||
|
$(AR) r $@ $(MODULES)
|
||||||
|
endif
|
||||||
|
|
||||||
|
install: OpenJPEG
|
||||||
|
install -d $(DESTDIR)$(INSTALL_LIBDIR)
|
||||||
|
ifeq ($(ENABLE_SHARED),yes)
|
||||||
|
install -m 755 -o root -g root $(SHAREDLIB) $(DESTDIR)$(INSTALL_LIBDIR)
|
||||||
|
(cd $(DESTDIR)$(INSTALL_LIBDIR) && \
|
||||||
|
ln -sf $(SHAREDLIB) $(LIBNAME).so.$(MAJOR).$(MINOR) )
|
||||||
|
(cd $(DESTDIR)$(INSTALL_LIBDIR) && \
|
||||||
|
ln -sf $(SHAREDLIB) $(LIBNAME).so )
|
||||||
|
else
|
||||||
|
install -m 644 -o root -g root $(STATICLIB) $(DESTDIR)$(INSTALL_LIBDIR)
|
||||||
|
(cd $(DESTDIR)$(INSTALL_LIBDIR) && ranlib $(STATICLIB) )
|
||||||
|
endif
|
||||||
|
install -d $(DESTDIR)$(INSTALL_INCLUDE)
|
||||||
|
install -m 644 -o root -g root libopenjpeg/openjpeg.h \
|
||||||
|
$(DESTDIR)$(INSTALL_INCLUDE)
|
||||||
|
(cd $(DESTDIR)$(prefix)/include && \
|
||||||
|
ln -sf $(headerdir)/openjpeg.h openjpeg.h)
|
||||||
|
make -C codec -f Makefile.nix install
|
||||||
|
make -C mj2 -f Makefile.nix install
|
||||||
|
ifeq ($(WITH_JPWL),yes)
|
||||||
|
make -C jpwl -f Makefile.nix install
|
||||||
|
endif
|
||||||
|
ifeq ($(WITH_JP3D),yes)
|
||||||
|
make -C jp3d -f Makefile.nix install
|
||||||
|
endif
|
||||||
|
$(LDCONFIG)
|
||||||
|
make -C doc -f Makefile.nix install
|
||||||
|
|
||||||
|
ifeq ($(WITH_JPWL),yes)
|
||||||
|
jpwl-all:
|
||||||
|
make -C jpwl -f Makefile.nix all
|
||||||
|
|
||||||
|
jpwl-install: jpwl-all
|
||||||
|
make -C jpwl -f Makefile.nix install
|
||||||
|
$(LDCONFIG)
|
||||||
|
|
||||||
|
jpwl-clean:
|
||||||
|
make -C jpwl -f Makefile.nix clean
|
||||||
|
|
||||||
|
jpwl-uninstall:
|
||||||
|
make -C jpwl -f Makefile.nix uninstall
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(WITH_JP3D),yes)
|
||||||
|
jp3d-all:
|
||||||
|
make -C jp3d -f Makefile.nix all
|
||||||
|
|
||||||
|
jp3d-install: jp3d-all
|
||||||
|
make -C jp3d -f Makefile.nix install
|
||||||
|
$(LDCONFIG)
|
||||||
|
|
||||||
|
jp3d-clean:
|
||||||
|
make -C jp3d -f Makefile.nix clean
|
||||||
|
|
||||||
|
jp3d-uninstall:
|
||||||
|
make -C jp3d -f Makefile.nix uninstall
|
||||||
|
endif
|
||||||
|
|
||||||
|
doc-all:
|
||||||
|
make -C doc -f Makefile.nix all
|
||||||
|
|
||||||
|
doc-install: doc-all
|
||||||
|
make -C doc -f Makefile.nix install
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf bin
|
||||||
|
rm -f core u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB)
|
||||||
|
make -C codec -f Makefile.nix clean
|
||||||
|
make -C mj2 -f Makefile.nix clean
|
||||||
|
make -C doc -f Makefile.nix clean
|
||||||
|
ifeq ($(WITH_JPWL),yes)
|
||||||
|
make -C jpwl -f Makefile.nix clean
|
||||||
|
endif
|
||||||
|
ifeq ($(WITH_JP3D),yes)
|
||||||
|
make -C jp3d -f Makefile.nix clean
|
||||||
|
endif
|
||||||
|
|
||||||
|
doc-clean:
|
||||||
|
make -C doc -f Makefile.nix clean
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
ifeq ($(ENABLE_SHARED),yes)
|
||||||
|
(cd $(DESTDIR)$(INSTALL_LIBDIR) && \
|
||||||
|
rm -f $(LIBNAME).so $(LIBNAME).so.$(MAJOR).$(MINOR) $(SHAREDLIB) )
|
||||||
|
else
|
||||||
|
rm -f $(DESTDIR)$(INSTALL_LIBDIR)/$(STATICLIB)
|
||||||
|
endif
|
||||||
|
$(LDCONFIG)
|
||||||
|
rm -f $(DESTDIR)$(prefix)/include/openjpeg.h
|
||||||
|
rm -rf $(DESTDIR)$(INSTALL_INCLUDE)
|
||||||
|
make -C codec -f Makefile.nix uninstall
|
||||||
|
make -C mj2 -f Makefile.nix uninstall
|
||||||
|
make -C doc -f Makefile.nix uninstall
|
||||||
|
ifeq ($(WITH_JPWL),yes)
|
||||||
|
make -C jpwl -f Makefile.nix uninstall
|
||||||
|
endif
|
||||||
|
ifeq ($(WITH_JP3D),yes)
|
||||||
|
make -C jp3d -f Makefile.nix uninstall
|
||||||
|
endif
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
rm -rf bin
|
||||||
21
NEWS
@@ -1,21 +0,0 @@
|
|||||||
|
|
||||||
OpenJPEG NEWS - user visible changes
|
|
||||||
====================================
|
|
||||||
|
|
||||||
Changes from OpenJPEG 1.5.x to OpenJPEG 2.0.0
|
|
||||||
----------------------------------------------
|
|
||||||
|
|
||||||
New Features:
|
|
||||||
|
|
||||||
* streaming capabilities
|
|
||||||
* merge JP3D
|
|
||||||
|
|
||||||
API modifications:
|
|
||||||
|
|
||||||
* Use a 64bits capable API
|
|
||||||
|
|
||||||
Misc:
|
|
||||||
|
|
||||||
* removed autotools build system
|
|
||||||
* folders hierarchies reorganisation
|
|
||||||
* Huge amount of bug fixes. See CHANGES for details.
|
|
||||||
48
README
@@ -4,44 +4,20 @@ OPENJPEG LIBRARY and APPLICATIONS
|
|||||||
|
|
||||||
Details on folders hierarchy:
|
Details on folders hierarchy:
|
||||||
|
|
||||||
* src
|
* libopenjpeg: contains the sources of the openjpeg library
|
||||||
* lib
|
* jpwl: contains the additional sources if you want to build a JPWL-flavoured library.
|
||||||
* openjp2: contains the sources of the openjp2 library (Part 1 & 2)
|
* applications: contains all applications that use the openjpeg library
|
||||||
* openjpwl: contains the additional sources if you want to build a JPWL-flavoured library.
|
|
||||||
* openjpip: complete client-server architecture for remote browsing of jpeg 2000 images.
|
|
||||||
* openjp3d: JP3D implementation
|
|
||||||
* openmj2: MJ2 implementation
|
|
||||||
* bin: contains all applications that use the openjpeg library
|
|
||||||
* common: common files to all applications
|
* common: common files to all applications
|
||||||
* jp2: a basic codec
|
* codec: a basic codec
|
||||||
* mj2: motion jpeg 2000 executables
|
* mj2: motion jpeg 2000 executables
|
||||||
* jpip: OpenJPIP applications (server and dec server)
|
* JavaOpenJPEG: java jni to use openjpeg in a java program
|
||||||
* java: a Java client viewer for JPIP
|
* jpip: complete client-server architecture for remote browsing of jpeg 2000 images. See corresponding README for more details.
|
||||||
* jp3d: JP3D applications
|
* OPJViewer: gui for displaying j2k files (based on wxWidget)
|
||||||
* tcltk: a test tool for JP3D
|
* thirdparty: thirdparty libraries used by some applications. These libraries will be build only if there are not found on the system. Note that libopenjpeg itself does not have any dependency.
|
||||||
* wx
|
|
||||||
* OPJViewer: gui for displaying j2k files (based on wxWidget)
|
|
||||||
* wrapping
|
|
||||||
* java: java jni to use openjpeg in a java program
|
|
||||||
* thirdparty: thirdparty libraries used by some applications. These libraries will be built only if there are not found on the system. Note that libopenjpeg itself does not have any dependency.
|
|
||||||
* doc: doxygen documentation setup file and man pages
|
* doc: doxygen documentation setup file and man pages
|
||||||
* tests: configuration files and utilities for the openjpeg test suite. All test images are located in 'http://openjpeg.googlecode.com/svn/data' folder.
|
* testing: all files required to test the library and executables (obsolete)
|
||||||
* cmake: cmake related files
|
* CMake: cmake related files
|
||||||
|
* m4: autotools related files
|
||||||
|
|
||||||
see LICENSE for license and copyright information.
|
see LICENSE for license and copyright information
|
||||||
see INSTALL for installation procedures.
|
see INSTALL for installation procedures.
|
||||||
see NEWS for user visible changes in successive releases.
|
|
||||||
see CHANGES for per-revision changes.
|
|
||||||
|
|
||||||
----------------
|
|
||||||
API/ABI
|
|
||||||
|
|
||||||
OpenJPEG strives to provide a stable API/ABI for your applications. As such it
|
|
||||||
only exposes a limited subset of its functions. It uses a mecanism of
|
|
||||||
exporting/hiding functions. If you are unsure which functions you can use in
|
|
||||||
your applications, you should compile OpenJPEG using something similar to gcc:
|
|
||||||
-fvisibility=hidden compilation flag.
|
|
||||||
See also: http://gcc.gnu.org/wiki/Visibility
|
|
||||||
|
|
||||||
On windows, MSVC directly supports export/hidding function and as such the only
|
|
||||||
API available is the one supported by OpenJPEG.
|
|
||||||
|
|||||||
33
THANKS
@@ -1,33 +0,0 @@
|
|||||||
OpenJPEG THANKS file
|
|
||||||
|
|
||||||
Many people have contributed to OpenJPEG by reporting problems, suggesting various improvements,
|
|
||||||
or submitting actual code. Here is a list of these people. Help me keep
|
|
||||||
it complete and exempt of errors.
|
|
||||||
|
|
||||||
Winfried Szukalski
|
|
||||||
Vincent Torri
|
|
||||||
Bob Friesenhahn
|
|
||||||
Callum Lerwick
|
|
||||||
Dzonatas Sol
|
|
||||||
Julien Malik
|
|
||||||
Jerôme Fimes
|
|
||||||
Herve Drolon
|
|
||||||
Yannick Verschueren
|
|
||||||
Sebastien Lugan
|
|
||||||
Kaori Hagihara
|
|
||||||
Peter Wimmer
|
|
||||||
Francois-Olivier Devaux
|
|
||||||
Antonin Descampe
|
|
||||||
David Janssens
|
|
||||||
Pr. Benoit Macq
|
|
||||||
Luis Ibanez
|
|
||||||
Ben Boeckel
|
|
||||||
Vincent Nicolas
|
|
||||||
Glenn Pearson
|
|
||||||
Giuseppe Baruffa
|
|
||||||
Arnaud Maye
|
|
||||||
Rex Dieter
|
|
||||||
David Burken
|
|
||||||
Parvatha Elangovan
|
|
||||||
Hans Johnson
|
|
||||||
Luc Hermitte
|
|
||||||
130
applications/CMakeLists.txt
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
IF(BUILD_CODEC OR BUILD_MJ2)
|
||||||
|
#
|
||||||
|
#
|
||||||
|
IF(UNIX OR CYGWIN)
|
||||||
|
SET(CMAKE_INCLUDE_PATH /usr/include /usr/local/include /opt/include
|
||||||
|
/opt/local/include /usr/include/libpng /usr/include/libpng14
|
||||||
|
/usr/include/libpng12 /usr/local/include/libpng
|
||||||
|
/usr/local/include/libpng14 /usr/local/include/libpng12
|
||||||
|
/opt/include/libpng /opt/include/libpng14 /opt/include/libpng12
|
||||||
|
/opt/local/include/libpng /opt/local/include/libpng14)
|
||||||
|
SET(CMAKE_LIBRARY_PATH /usr/lib /usr/local/lib /opt/lib /opt/local/lib)
|
||||||
|
ENDIF()
|
||||||
|
#
|
||||||
|
FIND_PACKAGE(ZLIB)
|
||||||
|
#
|
||||||
|
IF(ZLIB_LIBRARY STREQUAL "ZLIB_LIBRARY-NOTFOUND")
|
||||||
|
SET(ZLIB_FOUND 0)
|
||||||
|
ENDIF(ZLIB_LIBRARY STREQUAL "ZLIB_LIBRARY-NOTFOUND")
|
||||||
|
#
|
||||||
|
IF(ZLIB_FOUND)
|
||||||
|
SET(HAVE_ZLIB_H 1)
|
||||||
|
SET(HABE_LIBZ 1)
|
||||||
|
SET(Z_LIBNAME ${ZLIB_LIBRARIES})
|
||||||
|
SET(Z_INCLUDE_DIRNAME ${ZLIB_INCLUDE_DIR})
|
||||||
|
ENDIF(ZLIB_FOUND)
|
||||||
|
#
|
||||||
|
FIND_PACKAGE(PNG)
|
||||||
|
#
|
||||||
|
IF(PNG_LIBRARY STREQUAL "PNG_LIBRARY-NOTFOUND")
|
||||||
|
SET(PNG_FOUND 0)
|
||||||
|
ENDIF(PNG_LIBRARY STREQUAL "PNG_LIBRARY-NOTFOUND")
|
||||||
|
#
|
||||||
|
IF(PNG_FOUND)
|
||||||
|
SET(HAVE_PNG_H 1)
|
||||||
|
SET(HAVE_LIBPNG 1)
|
||||||
|
SET(PNG_LIBNAME ${PNG_LIBRARIES})
|
||||||
|
SET(PNG_INCLUDE_DIRNAME ${PNG_INCLUDE_DIR})
|
||||||
|
ENDIF(PNG_FOUND)
|
||||||
|
#
|
||||||
|
FIND_PACKAGE(TIFF)
|
||||||
|
#
|
||||||
|
IF(TIFF_LIBRARY STREQUAL "TIFF_LIBRARY-NOTFOUND")
|
||||||
|
SET(TIFF_FOUND 0)
|
||||||
|
ENDIF(TIFF_LIBRARY STREQUAL "TIFF_LIBRARY-NOTFOUND")
|
||||||
|
#
|
||||||
|
IF(TIFF_FOUND)
|
||||||
|
SET(HAVE_TIFF_H 1)
|
||||||
|
SET(HAVE_LIBTIFF 1)
|
||||||
|
SET(TIFF_LIBNAME ${TIFF_LIBRARIES})
|
||||||
|
SET(TIFF_INCLUDE_DIRNAME ${TIFF_INCLUDE_DIR})
|
||||||
|
ENDIF(TIFF_FOUND)
|
||||||
|
#
|
||||||
|
SET(LCMS12_MISSING 1)
|
||||||
|
INCLUDE(${OPENJPEG_SOURCE_DIR}/thirdparty/FindLCMS2.cmake OPTIONAL)
|
||||||
|
#
|
||||||
|
IF(LCMS2_FOUND)
|
||||||
|
SET(LCMS12_MISSING 0)
|
||||||
|
SET(HAVE_LCMS2_H 1)
|
||||||
|
SET(HAVE_LIBLCMS2 1)
|
||||||
|
SET(LCMS_LIBNAME ${LCMS2_LIBRARY})
|
||||||
|
SET(LCMS_INCLUDE_DIRNAME ${LCMS2_INCLUDE_DIR})
|
||||||
|
ENDIF(LCMS2_FOUND)
|
||||||
|
#
|
||||||
|
IF(NOT LCMS2_FOUND)
|
||||||
|
INCLUDE(${OPENJPEG_SOURCE_DIR}/thirdparty/FindLCMS.cmake OPTIONAL)
|
||||||
|
#
|
||||||
|
IF(LCMS_FOUND)
|
||||||
|
SET(LCMS12_MISSING 0)
|
||||||
|
SET(HAVE_LCMS1_H 1)
|
||||||
|
SET(HAVE_LIBLCMS1 1)
|
||||||
|
SET(LCMS_LIBNAME ${LCMS_LIBRARY} )
|
||||||
|
SET(LCMS_INCLUDE_DIRNAME ${LCMS_INCLUDE_DIR})
|
||||||
|
ENDIF(LCMS_FOUND)
|
||||||
|
ENDIF(NOT LCMS2_FOUND)
|
||||||
|
#-------------------------------------------------------------
|
||||||
|
OPTION(BUILD_THIRDPARTY "Build the thirdparty executables" ON)
|
||||||
|
#
|
||||||
|
IF(NOT ZLIB_FOUND OR NOT PNG_FOUND OR NOT TIFF_FOUND OR LCMS12_MISSING)
|
||||||
|
IF(BUILD_THIRDPARTY)
|
||||||
|
SET(HAVE_ZLIB_H 1)
|
||||||
|
SET(HAVE_LIBZ 1)
|
||||||
|
SET(HAVE_PNG_H 1)
|
||||||
|
SET(HAVE_LIBPNG 1)
|
||||||
|
SET(HAVE_TIFF_H 1)
|
||||||
|
SET(HAVE_LIBTIFF 1)
|
||||||
|
SET(HAVE_LCMS2_H 1)
|
||||||
|
SET(HAVE_LIBLCMS2 1)
|
||||||
|
#
|
||||||
|
#ADD_SUBDIRECTORY(${OPENJPEG_SOURCE_DIR}/thirdparty)
|
||||||
|
#
|
||||||
|
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/thirdparty/lib)
|
||||||
|
#
|
||||||
|
IF(NOT ZLIB_FOUND)
|
||||||
|
INCLUDE_DIRECTORIES(${OPENJPEG_SOURCE_DIR}/thirdparty/include)
|
||||||
|
SET(ZLIB_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/include)
|
||||||
|
SET(Z_LIBNAME z)
|
||||||
|
SET(ZLIB_FOUND 1)
|
||||||
|
ENDIF(NOT ZLIB_FOUND)
|
||||||
|
#
|
||||||
|
IF(NOT PNG_FOUND)
|
||||||
|
SET(PNG_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/libpng)
|
||||||
|
SET(PNG_LIBNAME png)
|
||||||
|
SET(PNG_FOUND 1)
|
||||||
|
ENDIF(NOT PNG_FOUND)
|
||||||
|
#
|
||||||
|
IF(NOT LCMS_FOUND AND NOT LCMS2_FOUND)
|
||||||
|
SET(LCMS_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/liblcms2/include)
|
||||||
|
SET(LCMS_LIBNAME lcms2)
|
||||||
|
SET(LCMS2_FOUND 1)
|
||||||
|
ENDIF(NOT LCMS_FOUND AND NOT LCMS2_FOUND)
|
||||||
|
#
|
||||||
|
IF(NOT TIFF_FOUND)
|
||||||
|
SET(TIFF_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/libtiff)
|
||||||
|
SET(TIFF_LIBNAME tiff)
|
||||||
|
SET(TIFF_FOUND 1)
|
||||||
|
ENDIF(NOT TIFF_FOUND)
|
||||||
|
#
|
||||||
|
ENDIF(BUILD_THIRDPARTY)
|
||||||
|
ENDIF(NOT ZLIB_FOUND OR NOT PNG_FOUND OR NOT TIFF_FOUND OR LCMS12_MISSING)
|
||||||
|
#
|
||||||
|
ENDIF(BUILD_CODEC OR BUILD_MJ2)
|
||||||
|
#
|
||||||
|
IF(BUILD_CODEC)
|
||||||
|
ADD_SUBDIRECTORY(codec)
|
||||||
|
ENDIF(BUILD_CODEC)
|
||||||
|
#
|
||||||
|
IF(BUILD_MJ2)
|
||||||
|
ADD_SUBDIRECTORY(mj2)
|
||||||
|
ENDIF(BUILD_MJ2)
|
||||||
|
#
|
||||||
40
applications/JavaOpenJPEG/CMakeLists.txt
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#JavaOpenJPEG/CMakeLists.txt
|
||||||
|
|
||||||
|
# First thing define the common source:
|
||||||
|
SET(common_SRCS
|
||||||
|
../codec/convert.c
|
||||||
|
../codec/index.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# If not getopt was found then add it to the lib:
|
||||||
|
IF(DONT_HAVE_GETOPT)
|
||||||
|
SET(common_SRCS
|
||||||
|
${common_SRCS}
|
||||||
|
../common/getopt.c
|
||||||
|
)
|
||||||
|
ENDIF(DONT_HAVE_GETOPT)
|
||||||
|
|
||||||
|
|
||||||
|
# Headers file are located here:
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||||
|
${LCMS_INCLUDE_DIR}
|
||||||
|
${PNG_INCLUDE_DIR}
|
||||||
|
${ZLIB_INCLUDE_DIR}
|
||||||
|
${TIFF_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Loop over all executables:
|
||||||
|
FOREACH(exe j2k_to_image image_to_j2k)
|
||||||
|
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
|
||||||
|
TARGET_LINK_LIBRARIES(${exe} ${OPJ_PREFIX}openjpeg ${TIFF_LIBRARIES}
|
||||||
|
${PNG_LIBRARIES} ${ZLIB_LIBRARY} ${LCMS_LIB})
|
||||||
|
# On unix you need to link to the math library:
|
||||||
|
IF(UNIX)
|
||||||
|
TARGET_LINK_LIBRARIES(${exe} -lm)
|
||||||
|
ENDIF(UNIX)
|
||||||
|
# Install exe
|
||||||
|
INSTALL_TARGETS(/bin/ ${exe})
|
||||||
|
ENDFOREACH(exe)
|
||||||
|
|
||||||
|
|
||||||
@@ -37,8 +37,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "openjpeg.h"
|
#include "openjpeg.h"
|
||||||
#include "opj_includes.h"
|
#include "getopt.h"
|
||||||
#include "opj_getopt.h"
|
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
#include "dirent.h"
|
#include "dirent.h"
|
||||||
@@ -58,7 +57,7 @@
|
|||||||
|
|
||||||
extern int get_file_format(char *filename);
|
extern int get_file_format(char *filename);
|
||||||
extern void error_callback(const char *msg, void *client_data);
|
extern void error_callback(const char *msg, void *client_data);
|
||||||
extern void warning_callback(const char *msg, void *client_data);
|
extern warning_callback(const char *msg, void *client_data);
|
||||||
extern void info_callback(const char *msg, void *client_data);
|
extern void info_callback(const char *msg, void *client_data);
|
||||||
|
|
||||||
typedef struct callback_variables {
|
typedef struct callback_variables {
|
||||||
@@ -90,7 +89,7 @@ typedef struct img_folder{
|
|||||||
float *rates;
|
float *rates;
|
||||||
}img_fol_t;
|
}img_fol_t;
|
||||||
|
|
||||||
static void encode_help_display() {
|
void encode_help_display() {
|
||||||
fprintf(stdout,"HELP\n----\n\n");
|
fprintf(stdout,"HELP\n----\n\n");
|
||||||
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||||
|
|
||||||
@@ -205,8 +204,6 @@ static void encode_help_display() {
|
|||||||
fprintf(stdout," Indicate multiple modes by adding their values. \n");
|
fprintf(stdout," Indicate multiple modes by adding their values. \n");
|
||||||
fprintf(stdout," ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
|
fprintf(stdout," ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
|
||||||
fprintf(stdout,"\n");
|
fprintf(stdout,"\n");
|
||||||
fprintf(stdout,"-TP : devide packets of every tile into tile-parts (-TP R) [R, L, C]\n");
|
|
||||||
fprintf(stdout,"\n");
|
|
||||||
fprintf(stdout,"-x : create an index file *.Idx (-x index_name.Idx) \n");
|
fprintf(stdout,"-x : create an index file *.Idx (-x index_name.Idx) \n");
|
||||||
fprintf(stdout,"\n");
|
fprintf(stdout,"\n");
|
||||||
fprintf(stdout,"-ROI : c=%%d,U=%%d : quantization indices upshifted \n");
|
fprintf(stdout,"-ROI : c=%%d,U=%%d : quantization indices upshifted \n");
|
||||||
@@ -219,9 +216,6 @@ static void encode_help_display() {
|
|||||||
fprintf(stdout,"\n");
|
fprintf(stdout,"\n");
|
||||||
fprintf(stdout,"-I : use the irreversible DWT 9-7 (-I) \n");
|
fprintf(stdout,"-I : use the irreversible DWT 9-7 (-I) \n");
|
||||||
fprintf(stdout,"\n");
|
fprintf(stdout,"\n");
|
||||||
fprintf(stdout,"-jpip : write jpip codestream index box in JP2 output file\n");
|
|
||||||
fprintf(stdout," NOTICE: currently supports only RPCL order\n");
|
|
||||||
fprintf(stdout,"\n");
|
|
||||||
/* UniPG>> */
|
/* UniPG>> */
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
fprintf(stdout,"-W : adoption of JPWL (Part 11) capabilities (-W params)\n");
|
fprintf(stdout,"-W : adoption of JPWL (Part 11) capabilities (-W params)\n");
|
||||||
@@ -330,7 +324,7 @@ static void encode_help_display() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static OPJ_PROG_ORDER give_progression(const char progression[4]) {
|
OPJ_PROG_ORDER give_progression(char progression[4]) {
|
||||||
if(strncmp(progression, "LRCP", 4) == 0) {
|
if(strncmp(progression, "LRCP", 4) == 0) {
|
||||||
return LRCP;
|
return LRCP;
|
||||||
}
|
}
|
||||||
@@ -350,6 +344,18 @@ static OPJ_PROG_ORDER give_progression(const char progression[4]) {
|
|||||||
return PROG_UNKNOWN;
|
return PROG_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get logarithm of an integer and round downwards.
|
||||||
|
/// </summary>
|
||||||
|
int int_floorlog2(int a) {
|
||||||
|
int l;
|
||||||
|
for (l=0; a>1; l++) {
|
||||||
|
a>>=1;
|
||||||
|
}
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
static int initialise_4K_poc(opj_poc_t *POC, int numres){
|
static int initialise_4K_poc(opj_poc_t *POC, int numres){
|
||||||
POC[0].tile = 1;
|
POC[0].tile = 1;
|
||||||
POC[0].resno0 = 0;
|
POC[0].resno0 = 0;
|
||||||
@@ -368,8 +374,8 @@ static int initialise_4K_poc(opj_poc_t *POC, int numres){
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cinema_parameters(opj_cparameters_t *parameters){
|
void cinema_parameters(opj_cparameters_t *parameters){
|
||||||
parameters->tile_size_on = OPJ_FALSE;
|
parameters->tile_size_on = false;
|
||||||
parameters->cp_tdx=1;
|
parameters->cp_tdx=1;
|
||||||
parameters->cp_tdy=1;
|
parameters->cp_tdy=1;
|
||||||
|
|
||||||
@@ -401,7 +407,7 @@ static void cinema_parameters(opj_cparameters_t *parameters){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol){
|
void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol){
|
||||||
int i;
|
int i;
|
||||||
float temp_rate;
|
float temp_rate;
|
||||||
opj_poc_t *POC = NULL;
|
opj_poc_t *POC = NULL;
|
||||||
@@ -483,25 +489,24 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *imag
|
|||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------------------ */
|
||||||
static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
img_fol_t *img_fol, char *indexfilename) {
|
img_fol_t *img_fol, char *indexfilename) {
|
||||||
int i, j,totlen;
|
int i, j,totlen;
|
||||||
opj_option_t long_option[]={
|
option_t long_option[]={
|
||||||
{"cinema2K",REQ_ARG, NULL ,'w'},
|
{"cinema2K",REQ_ARG, NULL ,'w'},
|
||||||
{"cinema4K",NO_ARG, NULL ,'y'},
|
{"cinema4K",NO_ARG, NULL ,'y'},
|
||||||
{"ImgDir",REQ_ARG, NULL ,'z'},
|
{"ImgDir",REQ_ARG, NULL ,'z'},
|
||||||
{"TP",REQ_ARG, NULL ,'u'},
|
{"TP",REQ_ARG, NULL ,'v'},
|
||||||
{"SOP",NO_ARG, NULL ,'S'},
|
{"SOP",NO_ARG, NULL ,'S'},
|
||||||
{"EPH",NO_ARG, NULL ,'E'},
|
{"EPH",NO_ARG, NULL ,'E'},
|
||||||
{"OutFor",REQ_ARG, NULL ,'O'},
|
{"OutFor",REQ_ARG, NULL ,'O'},
|
||||||
{"POC",REQ_ARG, NULL ,'P'},
|
{"POC",REQ_ARG, NULL ,'P'},
|
||||||
{"ROI",REQ_ARG, NULL ,'R'},
|
{"ROI",REQ_ARG, NULL ,'R'},
|
||||||
{"jpip",NO_ARG, NULL, 'J'}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* parse the command line */
|
/* parse the command line */
|
||||||
/* UniPG>> */
|
/* UniPG>> */
|
||||||
const char optlist[] = "i:o:hr:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:F:u:"
|
const char optlist[] = "i:o:hr:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:F:"
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
"W:"
|
"W:"
|
||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
@@ -518,7 +523,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
reset_options_reading();
|
reset_options_reading();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int c = opj_getopt_long(argc, argv, optlist,long_option,totlen);
|
int c = getopt_long(argc, argv, optlist,long_option,totlen);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@@ -527,7 +532,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'o': /* output file */
|
case 'o': /* output file */
|
||||||
{
|
{
|
||||||
char *outfile = opj_optarg;
|
char *outfile = optarg;
|
||||||
parameters->cod_format = get_file_format(outfile);
|
parameters->cod_format = get_file_format(outfile);
|
||||||
switch(parameters->cod_format) {
|
switch(parameters->cod_format) {
|
||||||
case J2K_CFMT:
|
case J2K_CFMT:
|
||||||
@@ -545,14 +550,14 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
case 'O': /* output format */
|
case 'O': /* output format */
|
||||||
{
|
{
|
||||||
char outformat[50];
|
char outformat[50];
|
||||||
char *of = opj_optarg;
|
char *of = optarg;
|
||||||
sprintf(outformat,".%s",of);
|
sprintf(outformat,".%s",of);
|
||||||
img_fol->set_out_format = 1;
|
img_fol->set_out_format = 1;
|
||||||
parameters->cod_format = get_file_format(outformat);
|
parameters->cod_format = get_file_format(outformat);
|
||||||
switch(parameters->cod_format) {
|
switch(parameters->cod_format) {
|
||||||
case J2K_CFMT:
|
case J2K_CFMT:
|
||||||
case JP2_CFMT:
|
case JP2_CFMT:
|
||||||
img_fol->out_format = opj_optarg;
|
img_fol->out_format = optarg;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unknown output format image [only j2k, j2c, jp2]!! \n");
|
fprintf(stderr, "Unknown output format image [only j2k, j2c, jp2]!! \n");
|
||||||
@@ -567,7 +572,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'r': /* rates rates/distorsion */
|
case 'r': /* rates rates/distorsion */
|
||||||
{
|
{
|
||||||
char *s = opj_optarg;
|
char *s = optarg;
|
||||||
while (sscanf(s, "%f", ¶meters->tcp_rates[parameters->tcp_numlayers]) == 1) {
|
while (sscanf(s, "%f", ¶meters->tcp_rates[parameters->tcp_numlayers]) == 1) {
|
||||||
parameters->tcp_numlayers++;
|
parameters->tcp_numlayers++;
|
||||||
while (*s && *s != ',') {
|
while (*s && *s != ',') {
|
||||||
@@ -585,7 +590,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'q': /* add fixed_quality */
|
case 'q': /* add fixed_quality */
|
||||||
{
|
{
|
||||||
char *s = opj_optarg;
|
char *s = optarg;
|
||||||
while (sscanf(s, "%f", ¶meters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
|
while (sscanf(s, "%f", ¶meters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
|
||||||
parameters->tcp_numlayers++;
|
parameters->tcp_numlayers++;
|
||||||
while (*s && *s != ',') {
|
while (*s && *s != ',') {
|
||||||
@@ -607,7 +612,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
int *row = NULL, *col = NULL;
|
int *row = NULL, *col = NULL;
|
||||||
int numlayers = 0, numresolution = 0, matrix_width = 0;
|
int numlayers = 0, numresolution = 0, matrix_width = 0;
|
||||||
|
|
||||||
char *s = opj_optarg;
|
char *s = optarg;
|
||||||
sscanf(s, "%d", &numlayers);
|
sscanf(s, "%d", &numlayers);
|
||||||
s++;
|
s++;
|
||||||
if (numlayers > 9)
|
if (numlayers > 9)
|
||||||
@@ -616,7 +621,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
parameters->tcp_numlayers = numlayers;
|
parameters->tcp_numlayers = numlayers;
|
||||||
numresolution = parameters->numresolution;
|
numresolution = parameters->numresolution;
|
||||||
matrix_width = numresolution * 3;
|
matrix_width = numresolution * 3;
|
||||||
parameters->cp_matrice = (int *) opj_malloc(numlayers * matrix_width * sizeof(int));
|
parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int));
|
||||||
s = s + 2;
|
s = s + 2;
|
||||||
|
|
||||||
for (i = 0; i < numlayers; i++) {
|
for (i = 0; i < numlayers; i++) {
|
||||||
@@ -651,8 +656,8 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 't': /* tiles */
|
case 't': /* tiles */
|
||||||
{
|
{
|
||||||
sscanf(opj_optarg, "%d,%d", ¶meters->cp_tdx, ¶meters->cp_tdy);
|
sscanf(optarg, "%d,%d", ¶meters->cp_tdx, ¶meters->cp_tdy);
|
||||||
parameters->tile_size_on = OPJ_TRUE;
|
parameters->tile_size_on = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -660,7 +665,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'n': /* resolution */
|
case 'n': /* resolution */
|
||||||
{
|
{
|
||||||
sscanf(opj_optarg, "%d", ¶meters->numresolution);
|
sscanf(optarg, "%d", ¶meters->numresolution);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -670,7 +675,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
char sep;
|
char sep;
|
||||||
int res_spec = 0;
|
int res_spec = 0;
|
||||||
|
|
||||||
char *s = opj_optarg;
|
char *s = optarg;
|
||||||
do {
|
do {
|
||||||
sep = 0;
|
sep = 0;
|
||||||
sscanf(s, "[%d,%d]%c", ¶meters->prcw_init[res_spec],
|
sscanf(s, "[%d,%d]%c", ¶meters->prcw_init[res_spec],
|
||||||
@@ -689,7 +694,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
case 'b': /* code-block dimension */
|
case 'b': /* code-block dimension */
|
||||||
{
|
{
|
||||||
int cblockw_init = 0, cblockh_init = 0;
|
int cblockw_init = 0, cblockh_init = 0;
|
||||||
sscanf(opj_optarg, "%d,%d", &cblockw_init, &cblockh_init);
|
sscanf(optarg, "%d,%d", &cblockw_init, &cblockh_init);
|
||||||
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|
||||||
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
|
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@@ -706,7 +711,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'x': /* creation of index file */
|
case 'x': /* creation of index file */
|
||||||
{
|
{
|
||||||
char *index = opj_optarg;
|
char *index = optarg;
|
||||||
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -717,7 +722,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
{
|
{
|
||||||
char progression[4];
|
char progression[4];
|
||||||
|
|
||||||
strncpy(progression, opj_optarg, 4);
|
strncpy(progression, optarg, 4);
|
||||||
parameters->prog_order = give_progression(progression);
|
parameters->prog_order = give_progression(progression);
|
||||||
if (parameters->prog_order == -1) {
|
if (parameters->prog_order == -1) {
|
||||||
fprintf(stderr, "Unrecognized progression order "
|
fprintf(stderr, "Unrecognized progression order "
|
||||||
@@ -731,7 +736,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 's': /* subsampling factor */
|
case 's': /* subsampling factor */
|
||||||
{
|
{
|
||||||
if (sscanf(opj_optarg, "%d,%d", ¶meters->subsampling_dx,
|
if (sscanf(optarg, "%d,%d", ¶meters->subsampling_dx,
|
||||||
¶meters->subsampling_dy) != 2) {
|
¶meters->subsampling_dy) != 2) {
|
||||||
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
|
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
|
||||||
return 1;
|
return 1;
|
||||||
@@ -743,7 +748,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'd': /* coordonnate of the reference grid */
|
case 'd': /* coordonnate of the reference grid */
|
||||||
{
|
{
|
||||||
if (sscanf(opj_optarg, "%d,%d", ¶meters->image_offset_x0,
|
if (sscanf(optarg, "%d,%d", ¶meters->image_offset_x0,
|
||||||
¶meters->image_offset_y0) != 2) {
|
¶meters->image_offset_y0) != 2) {
|
||||||
fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
|
fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
|
||||||
"error !! [-d x0,y0]\n");
|
"error !! [-d x0,y0]\n");
|
||||||
@@ -765,7 +770,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
int numpocs = 0; /* number of progression order change (POC) default 0 */
|
int numpocs = 0; /* number of progression order change (POC) default 0 */
|
||||||
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
|
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
|
||||||
|
|
||||||
char *s = opj_optarg;
|
char *s = optarg;
|
||||||
POC = parameters->POC;
|
POC = parameters->POC;
|
||||||
|
|
||||||
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
|
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
|
||||||
@@ -807,7 +812,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
case 'M': /* Mode switch pas tous au point !! */
|
case 'M': /* Mode switch pas tous au point !! */
|
||||||
{
|
{
|
||||||
int value = 0;
|
int value = 0;
|
||||||
if (sscanf(opj_optarg, "%d", &value) == 1) {
|
if (sscanf(optarg, "%d", &value) == 1) {
|
||||||
for (i = 0; i <= 5; i++) {
|
for (i = 0; i <= 5; i++) {
|
||||||
int cache = value & (1 << i);
|
int cache = value & (1 << i);
|
||||||
if (cache)
|
if (cache)
|
||||||
@@ -821,7 +826,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'R': /* ROI */
|
case 'R': /* ROI */
|
||||||
{
|
{
|
||||||
if (sscanf(opj_optarg, "c=%d,U=%d", ¶meters->roi_compno,
|
if (sscanf(optarg, "c=%d,U=%d", ¶meters->roi_compno,
|
||||||
¶meters->roi_shift) != 2) {
|
¶meters->roi_shift) != 2) {
|
||||||
fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n");
|
fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n");
|
||||||
return 1;
|
return 1;
|
||||||
@@ -833,7 +838,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'T': /* Tile offset */
|
case 'T': /* Tile offset */
|
||||||
{
|
{
|
||||||
if (sscanf(opj_optarg, "%d,%d", ¶meters->cp_tx0, ¶meters->cp_ty0) != 2) {
|
if (sscanf(optarg, "%d,%d", ¶meters->cp_tx0, ¶meters->cp_ty0) != 2) {
|
||||||
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
|
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -844,9 +849,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'C': /* add a comment */
|
case 'C': /* add a comment */
|
||||||
{
|
{
|
||||||
parameters->cp_comment = (char*)opj_malloc(strlen(opj_optarg) + 1);
|
parameters->cp_comment = (char*)malloc(strlen(optarg) + 1);
|
||||||
if(parameters->cp_comment) {
|
if(parameters->cp_comment) {
|
||||||
strcpy(parameters->cp_comment, opj_optarg);
|
strcpy(parameters->cp_comment, optarg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -862,9 +867,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
case 'u': /* Tile part generation*/
|
case 'v': /* Tile part generation*/
|
||||||
{
|
{
|
||||||
parameters->tp_flag = opj_optarg[0];
|
parameters->tp_flag = optarg[0];
|
||||||
parameters->tp_on = 1;
|
parameters->tp_on = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -873,8 +878,8 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'z': /* Image Directory path */
|
case 'z': /* Image Directory path */
|
||||||
{
|
{
|
||||||
img_fol->imgdirpath = (char*)opj_malloc(strlen(opj_optarg) + 1);
|
img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
|
||||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
strcpy(img_fol->imgdirpath,optarg);
|
||||||
img_fol->set_imgdir=1;
|
img_fol->set_imgdir=1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -884,7 +889,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
case 'w': /* Digital Cinema 2K profile compliance*/
|
case 'w': /* Digital Cinema 2K profile compliance*/
|
||||||
{
|
{
|
||||||
int fps=0;
|
int fps=0;
|
||||||
sscanf(opj_optarg,"%d",&fps);
|
sscanf(optarg,"%d",&fps);
|
||||||
if(fps == 24){
|
if(fps == 24){
|
||||||
parameters->cp_cinema = CINEMA2K_24;
|
parameters->cp_cinema = CINEMA2K_24;
|
||||||
}else if(fps == 48 ){
|
}else if(fps == 48 ){
|
||||||
@@ -928,7 +933,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
/* search for different protection methods */
|
/* search for different protection methods */
|
||||||
|
|
||||||
/* break the option in comma points and parse the result */
|
/* break the option in comma points and parse the result */
|
||||||
token = strtok(opj_optarg, ",");
|
token = strtok(optarg, ",");
|
||||||
while(token != NULL) {
|
while(token != NULL) {
|
||||||
|
|
||||||
/* search header error protection method */
|
/* search header error protection method */
|
||||||
@@ -1233,9 +1238,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
break;
|
break;
|
||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
/* <<UniPG */
|
/* <<UniPG */
|
||||||
/* ------------------------------------------------------ */
|
|
||||||
|
|
||||||
break;
|
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -1324,7 +1327,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
start position in the codestream
|
start position in the codestream
|
||||||
end position of this packet
|
end position of this packet
|
||||||
*/
|
*/
|
||||||
static char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int* buffer_size) {
|
char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int* buffer_size) {
|
||||||
int tileno, compno, layno, resno, precno, pack_nb, x, y;
|
int tileno, compno, layno, resno, precno, pack_nb, x, y;
|
||||||
char* buffer = NULL;
|
char* buffer = NULL;
|
||||||
int buffer_pos = 0;
|
int buffer_pos = 0;
|
||||||
@@ -1333,11 +1336,11 @@ static char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int*
|
|||||||
prec_max = 0;
|
prec_max = 0;
|
||||||
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||||
for (resno = 0; resno < cstr_info->numdecompos[0] + 1; resno++) {
|
for (resno = 0; resno < cstr_info->numdecompos[0] + 1; resno++) {
|
||||||
prec_max = int_max(prec_max,cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno]);
|
prec_max = max(prec_max,cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute the size of the index buffer, in number of bytes*/
|
// Compute the size of the index buffer, in number of bytes*/
|
||||||
*buffer_size =
|
*buffer_size =
|
||||||
1 /* version */
|
1 /* version */
|
||||||
+ (10 /* image_w until decomposition */
|
+ (10 /* image_w until decomposition */
|
||||||
@@ -1346,18 +1349,18 @@ static char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int*
|
|||||||
+ cstr_info->tw * cstr_info->th * 4 /* tile info, without distorsion info */
|
+ cstr_info->tw * cstr_info->th * 4 /* tile info, without distorsion info */
|
||||||
+ cstr_info->tw*cstr_info->th * cstr_info->numlayers * (cstr_info->numdecompos[0] + 1) * cstr_info->numcomps * prec_max *8
|
+ cstr_info->tw*cstr_info->th * cstr_info->numlayers * (cstr_info->numdecompos[0] + 1) * cstr_info->numcomps * prec_max *8
|
||||||
) * sizeof(int);
|
) * sizeof(int);
|
||||||
/*printf("C: index buffer size = %d bytes\n", *buffer_size);*/
|
//printf("C: index buffer size = %d bytes\n", *buffer_size);
|
||||||
buffer = (char*) opj_malloc(*buffer_size);
|
buffer = (char*) malloc(*buffer_size);
|
||||||
|
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
/*opj_event_msg(j2k->cinfo, EVT_ERROR, "failed to allocate index buffer for writing %d int\n", *buffer_size);*/
|
//opj_event_msg(j2k->cinfo, EVT_ERROR, "failed to allocate index buffer for writing %d int\n", *buffer_size);
|
||||||
fprintf(stderr, "failed to allocate index buffer for writing %d int\n", *buffer_size);
|
fprintf(stderr, "failed to allocate index buffer for writing %d int\n", *buffer_size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[0] = 1; /* Version stored on a byte*/
|
buffer[0] = 1; // Version stored on a byte
|
||||||
buffer++;
|
buffer++;
|
||||||
/* Remaining informations are stored on a int.*/
|
// Remaining informations are stored on a int.
|
||||||
((int*)buffer)[buffer_pos++] = cstr_info->image_w;
|
((int*)buffer)[buffer_pos++] = cstr_info->image_w;
|
||||||
((int*)buffer)[buffer_pos++] = cstr_info->image_h;
|
((int*)buffer)[buffer_pos++] = cstr_info->image_h;
|
||||||
((int*)buffer)[buffer_pos++] = cstr_info->prog;
|
((int*)buffer)[buffer_pos++] = cstr_info->prog;
|
||||||
@@ -1582,7 +1585,7 @@ static char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int*
|
|||||||
} /* tileno */
|
} /* tileno */
|
||||||
|
|
||||||
if (buffer_pos > *buffer_size) {
|
if (buffer_pos > *buffer_size) {
|
||||||
/*opj_event_msg(j2k->cinfo, EVT_ERROR, "index creation: buffer_pos (%d) > buffer_size (%d)!\n", buffer_pos, *buffer_size);*/
|
//opj_event_msg(j2k->cinfo, EVT_ERROR, "index creation: buffer_pos (%d) > buffer_size (%d)!\n", buffer_pos, *buffer_size);
|
||||||
fprintf(stderr, "index creation: buffer_pos (%d) > buffer_size (%d)!\n", buffer_pos, *buffer_size);
|
fprintf(stderr, "index creation: buffer_pos (%d) > buffer_size (%d)!\n", buffer_pos, *buffer_size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1596,7 +1599,7 @@ static char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int*
|
|||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
------------ Get the image byte[] from the Java object -------------------*/
|
------------ Get the image byte[] from the Java object -------------------*/
|
||||||
|
|
||||||
static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj, jclass cls) {
|
opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj, jclass cls) {
|
||||||
int i,max,shift,w,h,depth;
|
int i,max,shift,w,h,depth;
|
||||||
opj_image_t * img = NULL;
|
opj_image_t * img = NULL;
|
||||||
int compno, numcomps;
|
int compno, numcomps;
|
||||||
@@ -1613,9 +1616,9 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec
|
|||||||
jbyte *jbBody;
|
jbyte *jbBody;
|
||||||
jshort *jsBody;
|
jshort *jsBody;
|
||||||
jint *jiBody;
|
jint *jiBody;
|
||||||
jboolean isCopy;
|
boolean isCopy;
|
||||||
|
|
||||||
/* Image width, height and depth*/
|
// Image width, height and depth
|
||||||
fid = (*env)->GetFieldID(env, cls,"width", "I");
|
fid = (*env)->GetFieldID(env, cls,"width", "I");
|
||||||
ji = (*env)->GetIntField(env, obj, fid);
|
ji = (*env)->GetIntField(env, obj, fid);
|
||||||
w = ji;
|
w = ji;
|
||||||
@@ -1628,7 +1631,7 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec
|
|||||||
ji = (*env)->GetIntField(env, obj, fid);
|
ji = (*env)->GetIntField(env, obj, fid);
|
||||||
depth = ji;
|
depth = ji;
|
||||||
|
|
||||||
/* Read the image*/
|
// Read the image
|
||||||
if (depth <=16) {
|
if (depth <=16) {
|
||||||
numcomps = 1;
|
numcomps = 1;
|
||||||
color_space = CLRSPC_GRAY;
|
color_space = CLRSPC_GRAY;
|
||||||
@@ -1643,8 +1646,8 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec
|
|||||||
cmptparm[0].y0 = parameters->image_offset_y0;
|
cmptparm[0].y0 = parameters->image_offset_y0;
|
||||||
cmptparm[0].w = !cmptparm[0].x0 ? (w - 1) * parameters->subsampling_dx + 1 : cmptparm[0].x0 + (w - 1) * parameters->subsampling_dx + 1;
|
cmptparm[0].w = !cmptparm[0].x0 ? (w - 1) * parameters->subsampling_dx + 1 : cmptparm[0].x0 + (w - 1) * parameters->subsampling_dx + 1;
|
||||||
cmptparm[0].h = !cmptparm[0].y0 ? (h - 1) * parameters->subsampling_dy + 1 : cmptparm[0].y0 + (h - 1) * parameters->subsampling_dy + 1;
|
cmptparm[0].h = !cmptparm[0].y0 ? (h - 1) * parameters->subsampling_dy + 1 : cmptparm[0].y0 + (h - 1) * parameters->subsampling_dy + 1;
|
||||||
/* Java types are always signed but we use them as unsigned types (shift of the negative part of
|
// Java types are always signed but we use them as unsigned types (shift of the negative part of
|
||||||
the pixels of the images in Telemis before entering the encoder).*/
|
// the pixels of the images in Telemis before entering the encoder).
|
||||||
cmptparm[0].sgnd = 0;
|
cmptparm[0].sgnd = 0;
|
||||||
if (depth<=16)
|
if (depth<=16)
|
||||||
cmptparm[0].prec=depth;
|
cmptparm[0].prec=depth;
|
||||||
@@ -1690,12 +1693,12 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec
|
|||||||
comp = &image->comps[compno];
|
comp = &image->comps[compno];
|
||||||
max = -100000;
|
max = -100000;
|
||||||
if (depth == 8) {
|
if (depth == 8) {
|
||||||
fid = (*env)->GetFieldID(env, cls,"image8", "[B"); /* byteArray []*/
|
fid = (*env)->GetFieldID(env, cls,"image8", "[B"); // byteArray []
|
||||||
jba = (*env)->GetObjectField(env, obj, fid);
|
jba = (*env)->GetObjectField(env, obj, fid);
|
||||||
len = (*env)->GetArrayLength(env, jba);
|
len = (*env)->GetArrayLength(env, jba);
|
||||||
|
|
||||||
jbBody = (*env)->GetPrimitiveArrayCritical(env, jba, &isCopy);
|
jbBody = (*env)->GetPrimitiveArrayCritical(env, jba, &isCopy);
|
||||||
/*printf("C: before transfering 8 bpp image\n");*/
|
//printf("C: before transfering 8 bpp image\n");
|
||||||
if (comp->sgnd) {
|
if (comp->sgnd) {
|
||||||
for(i=0; i< len;i++) {
|
for(i=0; i< len;i++) {
|
||||||
comp->data[i] = (char) jbBody[i];
|
comp->data[i] = (char) jbBody[i];
|
||||||
@@ -1709,13 +1712,13 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec
|
|||||||
}
|
}
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jba, jbBody, 0);
|
(*env)->ReleasePrimitiveArrayCritical(env, jba, jbBody, 0);
|
||||||
} else if(depth == 16) {
|
} else if(depth == 16) {
|
||||||
fid = (*env)->GetFieldID(env, cls,"image16", "[S"); /* shortArray []*/
|
fid = (*env)->GetFieldID(env, cls,"image16", "[S"); // shortArray []
|
||||||
jsa = (*env)->GetObjectField(env, obj, fid);
|
jsa = (*env)->GetObjectField(env, obj, fid);
|
||||||
len = (*env)->GetArrayLength(env, jsa);
|
len = (*env)->GetArrayLength(env, jsa);
|
||||||
|
|
||||||
jsBody = (*env)->GetPrimitiveArrayCritical(env, jsa, &isCopy);
|
jsBody = (*env)->GetPrimitiveArrayCritical(env, jsa, &isCopy);
|
||||||
/*printf("C: before transfering 16 bpp image\n");*/
|
//printf("C: before transfering 16 bpp image\n");
|
||||||
if (comp->sgnd) { /* Special behaviour to deal with signed elements ??*/
|
if (comp->sgnd) { // Special behaviour to deal with signed elements ??
|
||||||
comp->data[i] = (short) jsBody[i];
|
comp->data[i] = (short) jsBody[i];
|
||||||
for(i=0; i< len;i++) {
|
for(i=0; i< len;i++) {
|
||||||
if (comp->data[i] > max) max = comp->data[i];
|
if (comp->data[i] > max) max = comp->data[i];
|
||||||
@@ -1728,14 +1731,14 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec
|
|||||||
}
|
}
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jsa, jsBody, 0);
|
(*env)->ReleasePrimitiveArrayCritical(env, jsa, jsBody, 0);
|
||||||
} else if (depth == 24) {
|
} else if (depth == 24) {
|
||||||
fid = (*env)->GetFieldID(env, cls,"image24", "[I"); /* intArray []*/
|
fid = (*env)->GetFieldID(env, cls,"image24", "[I"); // intArray []
|
||||||
jia = (*env)->GetObjectField(env, obj, fid);
|
jia = (*env)->GetObjectField(env, obj, fid);
|
||||||
len = (*env)->GetArrayLength(env, jia);
|
len = (*env)->GetArrayLength(env, jia);
|
||||||
shift = compno*8;
|
shift = compno*8;
|
||||||
|
|
||||||
jiBody = (*env)->GetPrimitiveArrayCritical(env, jia, &isCopy);
|
jiBody = (*env)->GetPrimitiveArrayCritical(env, jia, &isCopy);
|
||||||
/*printf("C: before transfering 24 bpp image (component %d, signed = %d)\n", compno, comp->sgnd);*/
|
//printf("C: before transfering 24 bpp image (component %d, signed = %d)\n", compno, comp->sgnd);
|
||||||
if (comp->sgnd) { /* Special behaviour to deal with signed elements ?? XXXXX*/
|
if (comp->sgnd) { // Special behaviour to deal with signed elements ?? XXXXX
|
||||||
for(i=0; i< len;i++) {
|
for(i=0; i< len;i++) {
|
||||||
comp->data[i] = ( ((int) jiBody[i]) & (0xFF << shift) ) >> shift;
|
comp->data[i] = ( ((int) jiBody[i]) & (0xFF << shift) ) >> shift;
|
||||||
if (comp->data[i] > max) max = comp->data[i];
|
if (comp->data[i] > max) max = comp->data[i];
|
||||||
@@ -1750,7 +1753,7 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec
|
|||||||
}
|
}
|
||||||
comp->bpp = int_floorlog2(max)+1;
|
comp->bpp = int_floorlog2(max)+1;
|
||||||
comp->prec = comp->bpp;
|
comp->prec = comp->bpp;
|
||||||
/*printf("C: component %d: max %d, real bpp = %d\n", compno, max, comp->bpp);*/
|
//printf("C: component %d: max %d, real bpp = %d\n", compno, max, comp->bpp);
|
||||||
}
|
}
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
@@ -1761,7 +1764,7 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec
|
|||||||
JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImageToJ2K(JNIEnv *env, jobject obj, jobjectArray javaParameters) {
|
JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImageToJ2K(JNIEnv *env, jobject obj, jobjectArray javaParameters) {
|
||||||
int argc; /* To simulate the command line parameters (taken from the javaParameters variable) and be able to re-use the */
|
int argc; /* To simulate the command line parameters (taken from the javaParameters variable) and be able to re-use the */
|
||||||
char **argv; /* 'parse_cmdline_decoder' method taken from the j2k_to_image project */
|
char **argv; /* 'parse_cmdline_decoder' method taken from the j2k_to_image project */
|
||||||
opj_bool bSuccess;
|
bool bSuccess;
|
||||||
opj_cparameters_t parameters; /* compression parameters */
|
opj_cparameters_t parameters; /* compression parameters */
|
||||||
img_fol_t img_fol;
|
img_fol_t img_fol;
|
||||||
opj_event_mgr_t event_mgr; /* event manager */
|
opj_event_mgr_t event_mgr; /* event manager */
|
||||||
@@ -1771,9 +1774,9 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
||||||
char indexfilename[OPJ_PATH_LEN]; /* index file name */
|
char indexfilename[OPJ_PATH_LEN]; /* index file name */
|
||||||
|
|
||||||
char* compressed_index = NULL;
|
int* compressed_index = NULL;
|
||||||
int compressed_index_size=-1;
|
int compressed_index_size=-1;
|
||||||
/* ==> Access variables to the Java member variables*/
|
// ==> Access variables to the Java member variables
|
||||||
jsize arraySize;
|
jsize arraySize;
|
||||||
jclass cls;
|
jclass cls;
|
||||||
jobject object;
|
jobject object;
|
||||||
@@ -1782,18 +1785,18 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
jbyteArray jba;
|
jbyteArray jba;
|
||||||
jbyte *jbBody;
|
jbyte *jbBody;
|
||||||
callback_variables_t msgErrorCallback_vars;
|
callback_variables_t msgErrorCallback_vars;
|
||||||
/* <== access variable to the Java member variables.*/
|
// <== access variable to the Java member variables.
|
||||||
|
|
||||||
/* For the encoding and storage into the file*/
|
// For the encoding and storage into the file
|
||||||
opj_cinfo_t* cinfo;
|
opj_cinfo_t* cinfo;
|
||||||
int codestream_length;
|
int codestream_length;
|
||||||
opj_cio_t *cio = NULL;
|
opj_cio_t *cio = NULL;
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
|
|
||||||
/* JNI reference to the calling class*/
|
// JNI reference to the calling class
|
||||||
cls = (*env)->GetObjectClass(env, obj);
|
cls = (*env)->GetObjectClass(env, obj);
|
||||||
|
|
||||||
/* Pointers to be able to call a Java method for all the info and error messages*/
|
// Pointers to be able to call a Java method for all the info and error messages
|
||||||
msgErrorCallback_vars.env = env;
|
msgErrorCallback_vars.env = env;
|
||||||
msgErrorCallback_vars.jobj = &obj;
|
msgErrorCallback_vars.jobj = &obj;
|
||||||
msgErrorCallback_vars.message_mid = (*env)->GetMethodID(env, cls, "logMessage", "(Ljava/lang/String;)V");
|
msgErrorCallback_vars.message_mid = (*env)->GetMethodID(env, cls, "logMessage", "(Ljava/lang/String;)V");
|
||||||
@@ -1801,12 +1804,12 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
|
|
||||||
arraySize = (*env)->GetArrayLength(env, javaParameters);
|
arraySize = (*env)->GetArrayLength(env, javaParameters);
|
||||||
argc = (int) arraySize +1;
|
argc = (int) arraySize +1;
|
||||||
argv = opj_malloc(argc*sizeof(char*));
|
argv = malloc(argc*sizeof(char*));
|
||||||
argv[0] = "ProgramName.exe"; /* The program name: useless*/
|
argv[0] = "ProgramName.exe"; // The program name: useless
|
||||||
j=0;
|
j=0;
|
||||||
for (i=1; i<argc; i++) {
|
for (i=1; i<argc; i++) {
|
||||||
object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
|
object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
|
||||||
argv[i] = (char*)(*env)->GetStringUTFChars(env, object, &isCopy);
|
argv[i] = (*env)->GetStringUTFChars(env, object, &isCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*printf("C: ");
|
/*printf("C: ");
|
||||||
@@ -1826,7 +1829,7 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
/* set encoding parameters to default values */
|
/* set encoding parameters to default values */
|
||||||
opj_set_default_encoder_parameters(¶meters);
|
opj_set_default_encoder_parameters(¶meters);
|
||||||
parameters.cod_format = J2K_CFMT;
|
parameters.cod_format = J2K_CFMT;
|
||||||
/*parameters.index_on = 1;*/
|
//parameters.index_on = 1;
|
||||||
|
|
||||||
/* Initialize indexfilename and img_fol */
|
/* Initialize indexfilename and img_fol */
|
||||||
*indexfilename = 0;
|
*indexfilename = 0;
|
||||||
@@ -1834,13 +1837,13 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
|
|
||||||
/* parse input and get user encoding parameters */
|
/* parse input and get user encoding parameters */
|
||||||
if (parse_cmdline_encoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
|
if (parse_cmdline_encoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
|
||||||
/* Release the Java arguments array*/
|
// Release the Java arguments array
|
||||||
for (i=1; i<argc; i++)
|
for (i=1; i<argc; i++)
|
||||||
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release the Java arguments array*/
|
// Release the Java arguments array
|
||||||
for (i=1; i<argc; i++)
|
for (i=1; i<argc; i++)
|
||||||
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
||||||
|
|
||||||
@@ -1856,10 +1859,10 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
const char *version = opj_version();
|
const char *version = opj_version();
|
||||||
/* UniPG>> */
|
/* UniPG>> */
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
parameters.cp_comment = (char*)opj_malloc(clen+strlen(version)+11);
|
parameters.cp_comment = (char*)malloc(clen+strlen(version)+11);
|
||||||
sprintf(parameters.cp_comment,"%s%s with JPWL", comment, version);
|
sprintf(parameters.cp_comment,"%s%s with JPWL", comment, version);
|
||||||
#else
|
#else
|
||||||
parameters.cp_comment = (char*)opj_malloc(clen+strlen(version)+1);
|
parameters.cp_comment = (char*)malloc(clen+strlen(version)+1);
|
||||||
sprintf(parameters.cp_comment,"%s%s", comment, version);
|
sprintf(parameters.cp_comment,"%s%s", comment, version);
|
||||||
#endif
|
#endif
|
||||||
/* <<UniPG */
|
/* <<UniPG */
|
||||||
@@ -1876,7 +1879,7 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
fprintf(stderr,"\n");
|
fprintf(stderr,"\n");
|
||||||
|
|
||||||
image = loadImage(¶meters, env, obj, cls);
|
image = loadImage(¶meters, env, obj, cls);
|
||||||
/*printf("C: after load image: image = %d\n", image);*/
|
//printf("C: after load image: image = %d\n", image);
|
||||||
if (!image) {
|
if (!image) {
|
||||||
fprintf(stderr, "Unable to load image\n");
|
fprintf(stderr, "Unable to load image\n");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1895,7 +1898,7 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
if (parameters.cod_format == J2K_CFMT) { /* J2K format output */
|
if (parameters.cod_format == J2K_CFMT) { /* J2K format output */
|
||||||
cinfo = opj_create_compress(CODEC_J2K);
|
cinfo = opj_create_compress(CODEC_J2K);
|
||||||
} else { /* JP2 format output */
|
} else { /* JP2 format output */
|
||||||
cinfo = opj_create_compress(CODEC_JP2);
|
cinfo = opj_create_compress(CODEC_JP2);
|
||||||
}
|
}
|
||||||
/* catch events using our callbacks and give a local context */
|
/* catch events using our callbacks and give a local context */
|
||||||
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, &msgErrorCallback_vars);
|
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, &msgErrorCallback_vars);
|
||||||
@@ -1933,7 +1936,7 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
memcpy(jbBody, compressed_index, compressed_index_size);
|
memcpy(jbBody, compressed_index, compressed_index_size);
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jba, jbBody, 0);
|
(*env)->ReleasePrimitiveArrayCritical(env, jba, jbBody, 0);
|
||||||
(*env)->SetObjectField(env, obj, fid, jba);
|
(*env)->SetObjectField(env, obj, fid, jba);
|
||||||
opj_free(compressed_index);
|
free(compressed_index);
|
||||||
|
|
||||||
/* write the generated codestream to disk ? */
|
/* write the generated codestream to disk ? */
|
||||||
if (parameters.outfile[0]!='\0') {
|
if (parameters.outfile[0]!='\0') {
|
||||||
@@ -1966,8 +1969,8 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* free user parameters structure */
|
/* free user parameters structure */
|
||||||
if(parameters.cp_comment) opj_free(parameters.cp_comment);
|
if(parameters.cp_comment) free(parameters.cp_comment);
|
||||||
if(parameters.cp_matrice) opj_free(parameters.cp_matrice);
|
if(parameters.cp_matrice) free(parameters.cp_matrice);
|
||||||
|
|
||||||
return codestream_length;
|
return codestream_length;
|
||||||
}
|
}
|
||||||
@@ -37,8 +37,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "openjpeg.h"
|
#include "openjpeg.h"
|
||||||
#include "opj_includes.h"
|
#include "getopt.h"
|
||||||
#include "opj_getopt.h"
|
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
#include "dirent.h"
|
#include "dirent.h"
|
||||||
#include "org_openJpeg_OpenJPEGJavaDecoder.h"
|
#include "org_openJpeg_OpenJPEGJavaDecoder.h"
|
||||||
@@ -207,7 +206,7 @@ int get_file_format(char *filename) {
|
|||||||
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
|
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
|
||||||
/* parse the command line */
|
/* parse the command line */
|
||||||
int totlen;
|
int totlen;
|
||||||
opj_option_t long_option[]={
|
option_t long_option[]={
|
||||||
{"ImgDir",REQ_ARG, NULL ,'y'},
|
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||||
{"OutFor",REQ_ARG, NULL ,'O'},
|
{"OutFor",REQ_ARG, NULL ,'O'},
|
||||||
};
|
};
|
||||||
@@ -230,13 +229,13 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
reset_options_reading();
|
reset_options_reading();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
|
int c = getopt_long(argc, argv,optlist,long_option,totlen);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'i': /* input file */
|
case 'i': /* input file */
|
||||||
{
|
{
|
||||||
char *infile = opj_optarg;
|
char *infile = optarg;
|
||||||
parameters->decod_format = get_file_format(infile);
|
parameters->decod_format = get_file_format(infile);
|
||||||
switch(parameters->decod_format) {
|
switch(parameters->decod_format) {
|
||||||
case J2K_CFMT:
|
case J2K_CFMT:
|
||||||
@@ -257,7 +256,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
|
|
||||||
case 'o': /* output file */
|
case 'o': /* output file */
|
||||||
{
|
{
|
||||||
char *outfile = opj_optarg;
|
char *outfile = optarg;
|
||||||
parameters->cod_format = get_file_format(outfile);
|
parameters->cod_format = get_file_format(outfile);
|
||||||
switch(parameters->cod_format) {
|
switch(parameters->cod_format) {
|
||||||
case PGX_DFMT:
|
case PGX_DFMT:
|
||||||
@@ -280,7 +279,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
case 'O': /* output format */
|
case 'O': /* output format */
|
||||||
{
|
{
|
||||||
char outformat[50];
|
char outformat[50];
|
||||||
char *of = opj_optarg;
|
char *of = optarg;
|
||||||
sprintf(outformat,".%s",of);
|
sprintf(outformat,".%s",of);
|
||||||
img_fol->set_out_format = 1;
|
img_fol->set_out_format = 1;
|
||||||
parameters->cod_format = get_file_format(outformat);
|
parameters->cod_format = get_file_format(outformat);
|
||||||
@@ -316,7 +315,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
|
|
||||||
case 'r': /* reduce option */
|
case 'r': /* reduce option */
|
||||||
{
|
{
|
||||||
sscanf(opj_optarg, "%d", ¶meters->cp_reduce);
|
sscanf(optarg, "%d", ¶meters->cp_reduce);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -325,7 +324,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
|
|
||||||
case 'l': /* layering option */
|
case 'l': /* layering option */
|
||||||
{
|
{
|
||||||
sscanf(opj_optarg, "%d", ¶meters->cp_layer);
|
sscanf(optarg, "%d", ¶meters->cp_layer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -339,8 +338,8 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
|
|
||||||
case 'y': /* Image Directory path */
|
case 'y': /* Image Directory path */
|
||||||
{
|
{
|
||||||
img_fol->imgdirpath = (char*)opj_malloc(strlen(opj_optarg) + 1);
|
img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
|
||||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
strcpy(img_fol->imgdirpath,optarg);
|
||||||
img_fol->set_imgdir=1;
|
img_fol->set_imgdir=1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -352,7 +351,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
{
|
{
|
||||||
char *token = NULL;
|
char *token = NULL;
|
||||||
|
|
||||||
token = strtok(opj_optarg, ",");
|
token = strtok(optarg, ",");
|
||||||
while(token != NULL) {
|
while(token != NULL) {
|
||||||
|
|
||||||
/* search expected number of components */
|
/* search expected number of components */
|
||||||
@@ -419,7 +418,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
|
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -509,7 +508,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
int w,h;
|
int w,h;
|
||||||
long min_value, max_value;
|
long min_value, max_value;
|
||||||
short tempS; unsigned char tempUC, tempUC1, tempUC2;
|
short tempS; unsigned char tempUC, tempUC1, tempUC2;
|
||||||
/* ==> Access variables to the Java member variables*/
|
// ==> Access variables to the Java member variables
|
||||||
jsize arraySize;
|
jsize arraySize;
|
||||||
jclass cls;
|
jclass cls;
|
||||||
jobject object;
|
jobject object;
|
||||||
@@ -522,8 +521,8 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
jshort *jsBody, *ptrSBody;
|
jshort *jsBody, *ptrSBody;
|
||||||
jint *jiBody, *ptrIBody;
|
jint *jiBody, *ptrIBody;
|
||||||
callback_variables_t msgErrorCallback_vars;
|
callback_variables_t msgErrorCallback_vars;
|
||||||
/* <=== access variable to Java member variables */
|
// <=== access variable to Java member variables */
|
||||||
int *ptr, *ptr1, *ptr2; /* <== To transfer the decoded image to Java*/
|
int *ptr, *ptr1, *ptr2; // <== To transfer the decoded image to Java
|
||||||
|
|
||||||
/* configure the event callbacks */
|
/* configure the event callbacks */
|
||||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||||
@@ -531,24 +530,24 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
event_mgr.warning_handler = warning_callback;
|
event_mgr.warning_handler = warning_callback;
|
||||||
event_mgr.info_handler = info_callback;
|
event_mgr.info_handler = info_callback;
|
||||||
|
|
||||||
/* JNI reference to the calling class*/
|
// JNI reference to the calling class
|
||||||
cls = (*env)->GetObjectClass(env, obj);
|
cls = (*env)->GetObjectClass(env, obj);
|
||||||
|
|
||||||
/* Pointers to be able to call a Java method for all the info and error messages*/
|
// Pointers to be able to call a Java method for all the info and error messages
|
||||||
msgErrorCallback_vars.env = env;
|
msgErrorCallback_vars.env = env;
|
||||||
msgErrorCallback_vars.jobj = &obj;
|
msgErrorCallback_vars.jobj = &obj;
|
||||||
msgErrorCallback_vars.message_mid = (*env)->GetMethodID(env, cls, "logMessage", "(Ljava/lang/String;)V");
|
msgErrorCallback_vars.message_mid = (*env)->GetMethodID(env, cls, "logMessage", "(Ljava/lang/String;)V");
|
||||||
msgErrorCallback_vars.error_mid = (*env)->GetMethodID(env, cls, "logError", "(Ljava/lang/String;)V");
|
msgErrorCallback_vars.error_mid = (*env)->GetMethodID(env, cls, "logError", "(Ljava/lang/String;)V");
|
||||||
|
|
||||||
/* Get the String[] containing the parameters, and converts it into a char** to simulate command line arguments.*/
|
// Get the String[] containing the parameters, and converts it into a char** to simulate command line arguments.
|
||||||
arraySize = (*env)->GetArrayLength(env, javaParameters);
|
arraySize = (*env)->GetArrayLength(env, javaParameters);
|
||||||
argc = (int) arraySize +1;
|
argc = (int) arraySize +1;
|
||||||
argv = opj_malloc(argc*sizeof(char*));
|
argv = malloc(argc*sizeof(char*));
|
||||||
argv[0] = "ProgramName.exe"; /* The program name: useless*/
|
argv[0] = "ProgramName.exe"; // The program name: useless
|
||||||
j=0;
|
j=0;
|
||||||
for (i=1; i<argc; i++) {
|
for (i=1; i<argc; i++) {
|
||||||
object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
|
object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
|
||||||
argv[i] = (char*)(*env)->GetStringUTFChars(env, object, &isCopy);
|
argv[i] = (*env)->GetStringUTFChars(env, object, &isCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*printf("C: decoder params = ");
|
/*printf("C: decoder params = ");
|
||||||
@@ -563,18 +562,18 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
|
|
||||||
/* parse input and get user encoding parameters */
|
/* parse input and get user encoding parameters */
|
||||||
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol) == 1) {
|
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol) == 1) {
|
||||||
/* Release the Java arguments array*/
|
// Release the Java arguments array
|
||||||
for (i=1; i<argc; i++)
|
for (i=1; i<argc; i++)
|
||||||
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* Release the Java arguments array*/
|
// Release the Java arguments array
|
||||||
for (i=1; i<argc; i++)
|
for (i=1; i<argc; i++)
|
||||||
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
||||||
|
|
||||||
num_images=1;
|
num_images=1;
|
||||||
|
|
||||||
/* Get additional information from the Java object variables*/
|
// Get additional information from the Java object variables
|
||||||
fid = (*env)->GetFieldID(env, cls,"skippedResolutions", "I");
|
fid = (*env)->GetFieldID(env, cls,"skippedResolutions", "I");
|
||||||
parameters.cp_reduce = (short) (*env)->GetIntField(env, obj, fid);
|
parameters.cp_reduce = (short) (*env)->GetIntField(env, obj, fid);
|
||||||
|
|
||||||
@@ -588,7 +587,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
Implemented for debug purpose. */
|
Implemented for debug purpose. */
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
if (parameters.infile && parameters.infile[0]!='\0') {
|
if (parameters.infile && parameters.infile[0]!='\0') {
|
||||||
/*printf("C: opening [%s]\n", parameters.infile);*/
|
//printf("C: opening [%s]\n", parameters.infile);
|
||||||
fsrc = fopen(parameters.infile, "rb");
|
fsrc = fopen(parameters.infile, "rb");
|
||||||
if (!fsrc) {
|
if (!fsrc) {
|
||||||
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
||||||
@@ -597,13 +596,13 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
fseek(fsrc, 0, SEEK_END);
|
fseek(fsrc, 0, SEEK_END);
|
||||||
file_length = ftell(fsrc);
|
file_length = ftell(fsrc);
|
||||||
fseek(fsrc, 0, SEEK_SET);
|
fseek(fsrc, 0, SEEK_SET);
|
||||||
src = (unsigned char *) opj_malloc(file_length);
|
src = (unsigned char *) malloc(file_length);
|
||||||
fread(src, 1, file_length, fsrc);
|
fread(src, 1, file_length, fsrc);
|
||||||
fclose(fsrc);
|
fclose(fsrc);
|
||||||
/*printf("C: %d bytes read from file\n",file_length);*/
|
//printf("C: %d bytes read from file\n",file_length);
|
||||||
} else {
|
} else {
|
||||||
/* Preparing the transfer of the codestream from Java to C*/
|
// Preparing the transfer of the codestream from Java to C
|
||||||
/*printf("C: before transfering codestream\n");*/
|
//printf("C: before transfering codestream\n");
|
||||||
fid = (*env)->GetFieldID(env, cls,"compressedStream", "[B");
|
fid = (*env)->GetFieldID(env, cls,"compressedStream", "[B");
|
||||||
jba = (*env)->GetObjectField(env, obj, fid);
|
jba = (*env)->GetObjectField(env, obj, fid);
|
||||||
file_length = (*env)->GetArrayLength(env, jba);
|
file_length = (*env)->GetArrayLength(env, jba);
|
||||||
@@ -713,7 +712,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
|
|
||||||
/* free the memory containing the code-stream */
|
/* free the memory containing the code-stream */
|
||||||
if (parameters.infile && parameters.infile[0]!='\0') {
|
if (parameters.infile && parameters.infile[0]!='\0') {
|
||||||
opj_free(src);
|
free(src);
|
||||||
} else {
|
} else {
|
||||||
(*env)->ReleaseByteArrayElements(env, jba, jbBody, 0);
|
(*env)->ReleaseByteArrayElements(env, jba, jbBody, 0);
|
||||||
}
|
}
|
||||||
@@ -753,17 +752,17 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========= Return the image to the Java structure ===============*/
|
// ========= Return the image to the Java structure ===============
|
||||||
#ifdef CHECK_THRESHOLDS
|
#ifdef CHECK_THRESHOLDS
|
||||||
printf("C: checking thresholds\n");
|
printf("C: checking thresholds\n");
|
||||||
#endif
|
#endif
|
||||||
/* First compute the real with and height, in function of the resolutions decoded.*/
|
// First compute the real with and height, in function of the resolutions decoded.
|
||||||
/*wr = (image->comps[0].w + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;*/
|
//wr = (image->comps[0].w + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;
|
||||||
/*hr = (image->comps[0].h + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;*/
|
//hr = (image->comps[0].h + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;
|
||||||
w = image->comps[0].w;
|
w = image->comps[0].w;
|
||||||
h = image->comps[0].h;
|
h = image->comps[0].h;
|
||||||
|
|
||||||
if (image->numcomps==3) { /* 3 components color image*/
|
if (image->numcomps==3) { // 3 components color image
|
||||||
ptr = image->comps[0].data;
|
ptr = image->comps[0].data;
|
||||||
ptr1 = image->comps[1].data;
|
ptr1 = image->comps[1].data;
|
||||||
ptr2 = image->comps[2].data;
|
ptr2 = image->comps[2].data;
|
||||||
@@ -776,7 +775,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
max_value = 255;
|
max_value = 255;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Get the pointer to the Java structure where the data must be copied*/
|
// Get the pointer to the Java structure where the data must be copied
|
||||||
fid = (*env)->GetFieldID(env, cls,"image24", "[I");
|
fid = (*env)->GetFieldID(env, cls,"image24", "[I");
|
||||||
jia = (*env)->GetObjectField(env, obj, fid);
|
jia = (*env)->GetObjectField(env, obj, fid);
|
||||||
jiBody = (*env)->GetIntArrayElements(env, jia, 0);
|
jiBody = (*env)->GetIntArrayElements(env, jia, 0);
|
||||||
@@ -805,7 +804,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
}
|
}
|
||||||
(*env)->ReleaseIntArrayElements(env, jia, jiBody, 0);
|
(*env)->ReleaseIntArrayElements(env, jia, jiBody, 0);
|
||||||
|
|
||||||
} else { /* 1 component 8 or 16 bpp image*/
|
} else { // 1 component 8 or 16 bpp image
|
||||||
ptr = image->comps[0].data;
|
ptr = image->comps[0].data;
|
||||||
printf("C: before transfering a %d bpp image to java (length = %d)\n",image->comps[0].prec ,w*h);
|
printf("C: before transfering a %d bpp image to java (length = %d)\n",image->comps[0].prec ,w*h);
|
||||||
if (image->comps[0].prec<=8) {
|
if (image->comps[0].prec<=8) {
|
||||||
@@ -822,7 +821,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
max_value = 255;
|
max_value = 255;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/*printf("C: transfering %d shorts to Java image8 pointer = %d\n", wr*hr,ptrSBody);*/
|
//printf("C: transfering %d shorts to Java image8 pointer = %d\n", wr*hr,ptrSBody);
|
||||||
for (i=0; i<w*h; i++) {
|
for (i=0; i<w*h; i++) {
|
||||||
tempUC = (unsigned char) (ptr[i]);
|
tempUC = (unsigned char) (ptr[i]);
|
||||||
#ifdef CHECK_THRESHOLDS
|
#ifdef CHECK_THRESHOLDS
|
||||||
@@ -880,5 +879,5 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
|||||||
}
|
}
|
||||||
return 1; /* OK */
|
return 1; /* OK */
|
||||||
}
|
}
|
||||||
/*end main*/
|
//end main
|
||||||
|
|
||||||
14
applications/JavaOpenJPEG/Makefile
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Makefile for the main OpenJPEG codecs: j2k_to_image and image_to_j2k
|
||||||
|
|
||||||
|
CFLAGS = -O3 -lstdc++ # -g -p -pg
|
||||||
|
|
||||||
|
all: j2k_to_image image_to_j2k
|
||||||
|
|
||||||
|
j2k_to_image: j2k_to_image.c ../libopenjpeg.a
|
||||||
|
gcc $(CFLAGS) ../common/getopt.c convert.c j2k_to_image.c -o j2k_to_image -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
|
||||||
|
|
||||||
|
image_to_j2k: image_to_j2k.c ../libopenjpeg.a
|
||||||
|
gcc $(CFLAGS) ../common/getopt.c convert.c image_to_j2k.c -o image_to_j2k -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f j2k_to_image image_to_j2k
|
||||||
278
applications/JavaOpenJPEG/java-jni/include/jawt.h
Normal file
@@ -0,0 +1,278 @@
|
|||||||
|
/*
|
||||||
|
* @(#)jawt.h 1.10 03/12/19
|
||||||
|
*
|
||||||
|
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
||||||
|
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _JAVASOFT_JAWT_H_
|
||||||
|
#define _JAVASOFT_JAWT_H_
|
||||||
|
|
||||||
|
#include "jni.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* AWT native interface (new in JDK 1.3)
|
||||||
|
*
|
||||||
|
* The AWT native interface allows a native C or C++ application a means
|
||||||
|
* by which to access native structures in AWT. This is to facilitate moving
|
||||||
|
* legacy C and C++ applications to Java and to target the needs of the
|
||||||
|
* community who, at present, wish to do their own native rendering to canvases
|
||||||
|
* for performance reasons. Standard extensions such as Java3D also require a
|
||||||
|
* means to access the underlying native data structures of AWT.
|
||||||
|
*
|
||||||
|
* There may be future extensions to this API depending on demand.
|
||||||
|
*
|
||||||
|
* A VM does not have to implement this API in order to pass the JCK.
|
||||||
|
* It is recommended, however, that this API is implemented on VMs that support
|
||||||
|
* standard extensions, such as Java3D.
|
||||||
|
*
|
||||||
|
* Since this is a native API, any program which uses it cannot be considered
|
||||||
|
* 100% pure java.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* AWT Native Drawing Surface (JAWT_DrawingSurface).
|
||||||
|
*
|
||||||
|
* For each platform, there is a native drawing surface structure. This
|
||||||
|
* platform-specific structure can be found in jawt_md.h. It is recommended
|
||||||
|
* that additional platforms follow the same model. It is also recommended
|
||||||
|
* that VMs on Win32 and Solaris support the existing structures in jawt_md.h.
|
||||||
|
*
|
||||||
|
*******************
|
||||||
|
* EXAMPLE OF USAGE:
|
||||||
|
*******************
|
||||||
|
*
|
||||||
|
* In Win32, a programmer wishes to access the HWND of a canvas to perform
|
||||||
|
* native rendering into it. The programmer has declared the paint() method
|
||||||
|
* for their canvas subclass to be native:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* MyCanvas.java:
|
||||||
|
*
|
||||||
|
* import java.awt.*;
|
||||||
|
*
|
||||||
|
* public class MyCanvas extends Canvas {
|
||||||
|
*
|
||||||
|
* static {
|
||||||
|
* System.loadLibrary("mylib");
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* public native void paint(Graphics g);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* myfile.c:
|
||||||
|
*
|
||||||
|
* #include "jawt_md.h"
|
||||||
|
* #include <assert.h>
|
||||||
|
*
|
||||||
|
* JNIEXPORT void JNICALL
|
||||||
|
* Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics)
|
||||||
|
* {
|
||||||
|
* JAWT awt;
|
||||||
|
* JAWT_DrawingSurface* ds;
|
||||||
|
* JAWT_DrawingSurfaceInfo* dsi;
|
||||||
|
* JAWT_Win32DrawingSurfaceInfo* dsi_win;
|
||||||
|
* jboolean result;
|
||||||
|
* jint lock;
|
||||||
|
*
|
||||||
|
* // Get the AWT
|
||||||
|
* awt.version = JAWT_VERSION_1_3;
|
||||||
|
* result = JAWT_GetAWT(env, &awt);
|
||||||
|
* assert(result != JNI_FALSE);
|
||||||
|
*
|
||||||
|
* // Get the drawing surface
|
||||||
|
* ds = awt.GetDrawingSurface(env, canvas);
|
||||||
|
* assert(ds != NULL);
|
||||||
|
*
|
||||||
|
* // Lock the drawing surface
|
||||||
|
* lock = ds->Lock(ds);
|
||||||
|
* assert((lock & JAWT_LOCK_ERROR) == 0);
|
||||||
|
*
|
||||||
|
* // Get the drawing surface info
|
||||||
|
* dsi = ds->GetDrawingSurfaceInfo(ds);
|
||||||
|
*
|
||||||
|
* // Get the platform-specific drawing info
|
||||||
|
* dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
|
||||||
|
*
|
||||||
|
* //////////////////////////////
|
||||||
|
* // !!! DO PAINTING HERE !!! //
|
||||||
|
* //////////////////////////////
|
||||||
|
*
|
||||||
|
* // Free the drawing surface info
|
||||||
|
* ds->FreeDrawingSurfaceInfo(dsi);
|
||||||
|
*
|
||||||
|
* // Unlock the drawing surface
|
||||||
|
* ds->Unlock(ds);
|
||||||
|
*
|
||||||
|
* // Free the drawing surface
|
||||||
|
* awt.FreeDrawingSurface(ds);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* JAWT_Rectangle
|
||||||
|
* Structure for a native rectangle.
|
||||||
|
*/
|
||||||
|
typedef struct jawt_Rectangle {
|
||||||
|
jint x;
|
||||||
|
jint y;
|
||||||
|
jint width;
|
||||||
|
jint height;
|
||||||
|
} JAWT_Rectangle;
|
||||||
|
|
||||||
|
struct jawt_DrawingSurface;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* JAWT_DrawingSurfaceInfo
|
||||||
|
* Structure for containing the underlying drawing information of a component.
|
||||||
|
*/
|
||||||
|
typedef struct jawt_DrawingSurfaceInfo {
|
||||||
|
/*
|
||||||
|
* Pointer to the platform-specific information. This can be safely
|
||||||
|
* cast to a JAWT_Win32DrawingSurfaceInfo on Windows or a
|
||||||
|
* JAWT_X11DrawingSurfaceInfo on Solaris. See jawt_md.h for details.
|
||||||
|
*/
|
||||||
|
void* platformInfo;
|
||||||
|
/* Cached pointer to the underlying drawing surface */
|
||||||
|
struct jawt_DrawingSurface* ds;
|
||||||
|
/* Bounding rectangle of the drawing surface */
|
||||||
|
JAWT_Rectangle bounds;
|
||||||
|
/* Number of rectangles in the clip */
|
||||||
|
jint clipSize;
|
||||||
|
/* Clip rectangle array */
|
||||||
|
JAWT_Rectangle* clip;
|
||||||
|
} JAWT_DrawingSurfaceInfo;
|
||||||
|
|
||||||
|
#define JAWT_LOCK_ERROR 0x00000001
|
||||||
|
#define JAWT_LOCK_CLIP_CHANGED 0x00000002
|
||||||
|
#define JAWT_LOCK_BOUNDS_CHANGED 0x00000004
|
||||||
|
#define JAWT_LOCK_SURFACE_CHANGED 0x00000008
|
||||||
|
|
||||||
|
/*
|
||||||
|
* JAWT_DrawingSurface
|
||||||
|
* Structure for containing the underlying drawing information of a component.
|
||||||
|
* All operations on a JAWT_DrawingSurface MUST be performed from the same
|
||||||
|
* thread as the call to GetDrawingSurface.
|
||||||
|
*/
|
||||||
|
typedef struct jawt_DrawingSurface {
|
||||||
|
/*
|
||||||
|
* Cached reference to the Java environment of the calling thread.
|
||||||
|
* If Lock(), Unlock(), GetDrawingSurfaceInfo() or
|
||||||
|
* FreeDrawingSurfaceInfo() are called from a different thread,
|
||||||
|
* this data member should be set before calling those functions.
|
||||||
|
*/
|
||||||
|
JNIEnv* env;
|
||||||
|
/* Cached reference to the target object */
|
||||||
|
jobject target;
|
||||||
|
/*
|
||||||
|
* Lock the surface of the target component for native rendering.
|
||||||
|
* When finished drawing, the surface must be unlocked with
|
||||||
|
* Unlock(). This function returns a bitmask with one or more of the
|
||||||
|
* following values:
|
||||||
|
*
|
||||||
|
* JAWT_LOCK_ERROR - When an error has occurred and the surface could not
|
||||||
|
* be locked.
|
||||||
|
*
|
||||||
|
* JAWT_LOCK_CLIP_CHANGED - When the clip region has changed.
|
||||||
|
*
|
||||||
|
* JAWT_LOCK_BOUNDS_CHANGED - When the bounds of the surface have changed.
|
||||||
|
*
|
||||||
|
* JAWT_LOCK_SURFACE_CHANGED - When the surface itself has changed
|
||||||
|
*/
|
||||||
|
jint (JNICALL *Lock)
|
||||||
|
(struct jawt_DrawingSurface* ds);
|
||||||
|
/*
|
||||||
|
* Get the drawing surface info.
|
||||||
|
* The value returned may be cached, but the values may change if
|
||||||
|
* additional calls to Lock() or Unlock() are made.
|
||||||
|
* Lock() must be called before this can return a valid value.
|
||||||
|
* Returns NULL if an error has occurred.
|
||||||
|
* When finished with the returned value, FreeDrawingSurfaceInfo must be
|
||||||
|
* called.
|
||||||
|
*/
|
||||||
|
JAWT_DrawingSurfaceInfo* (JNICALL *GetDrawingSurfaceInfo)
|
||||||
|
(struct jawt_DrawingSurface* ds);
|
||||||
|
/*
|
||||||
|
* Free the drawing surface info.
|
||||||
|
*/
|
||||||
|
void (JNICALL *FreeDrawingSurfaceInfo)
|
||||||
|
(JAWT_DrawingSurfaceInfo* dsi);
|
||||||
|
/*
|
||||||
|
* Unlock the drawing surface of the target component for native rendering.
|
||||||
|
*/
|
||||||
|
void (JNICALL *Unlock)
|
||||||
|
(struct jawt_DrawingSurface* ds);
|
||||||
|
} JAWT_DrawingSurface;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* JAWT
|
||||||
|
* Structure for containing native AWT functions.
|
||||||
|
*/
|
||||||
|
typedef struct jawt {
|
||||||
|
/*
|
||||||
|
* Version of this structure. This must always be set before
|
||||||
|
* calling JAWT_GetAWT()
|
||||||
|
*/
|
||||||
|
jint version;
|
||||||
|
/*
|
||||||
|
* Return a drawing surface from a target jobject. This value
|
||||||
|
* may be cached.
|
||||||
|
* Returns NULL if an error has occurred.
|
||||||
|
* Target must be a java.awt.Component (should be a Canvas
|
||||||
|
* or Window for native rendering).
|
||||||
|
* FreeDrawingSurface() must be called when finished with the
|
||||||
|
* returned JAWT_DrawingSurface.
|
||||||
|
*/
|
||||||
|
JAWT_DrawingSurface* (JNICALL *GetDrawingSurface)
|
||||||
|
(JNIEnv* env, jobject target);
|
||||||
|
/*
|
||||||
|
* Free the drawing surface allocated in GetDrawingSurface.
|
||||||
|
*/
|
||||||
|
void (JNICALL *FreeDrawingSurface)
|
||||||
|
(JAWT_DrawingSurface* ds);
|
||||||
|
/*
|
||||||
|
* Since 1.4
|
||||||
|
* Locks the entire AWT for synchronization purposes
|
||||||
|
*/
|
||||||
|
void (JNICALL *Lock)(JNIEnv* env);
|
||||||
|
/*
|
||||||
|
* Since 1.4
|
||||||
|
* Unlocks the entire AWT for synchronization purposes
|
||||||
|
*/
|
||||||
|
void (JNICALL *Unlock)(JNIEnv* env);
|
||||||
|
/*
|
||||||
|
* Since 1.4
|
||||||
|
* Returns a reference to a java.awt.Component from a native
|
||||||
|
* platform handle. On Windows, this corresponds to an HWND;
|
||||||
|
* on Solaris and Linux, this is a Drawable. For other platforms,
|
||||||
|
* see the appropriate machine-dependent header file for a description.
|
||||||
|
* The reference returned by this function is a local
|
||||||
|
* reference that is only valid in this environment.
|
||||||
|
* This function returns a NULL reference if no component could be
|
||||||
|
* found with matching platform information.
|
||||||
|
*/
|
||||||
|
jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo);
|
||||||
|
|
||||||
|
} JAWT;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the AWT native structure. This function returns JNI_FALSE if
|
||||||
|
* an error occurs.
|
||||||
|
*/
|
||||||
|
_JNI_IMPORT_OR_EXPORT_
|
||||||
|
jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt);
|
||||||
|
|
||||||
|
#define JAWT_VERSION_1_3 0x00010003
|
||||||
|
#define JAWT_VERSION_1_4 0x00010004
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* !_JAVASOFT_JAWT_H_ */
|
||||||
237
applications/JavaOpenJPEG/java-jni/include/jdwpTransport.h
Normal file
@@ -0,0 +1,237 @@
|
|||||||
|
/*
|
||||||
|
* @(#)jdwpTransport.h 1.7 03/12/19
|
||||||
|
*
|
||||||
|
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
||||||
|
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Java Debug Wire Protocol Transport Service Provider Interface.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef JDWPTRANSPORT_H
|
||||||
|
#define JDWPTRANSPORT_H
|
||||||
|
|
||||||
|
#include "jni.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
JDWPTRANSPORT_VERSION_1_0 = 0x00010000
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct jdwpTransportNativeInterface_;
|
||||||
|
|
||||||
|
struct _jdwpTransportEnv;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
typedef _jdwpTransportEnv jdwpTransportEnv;
|
||||||
|
#else
|
||||||
|
typedef const struct jdwpTransportNativeInterface_ *jdwpTransportEnv;
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Errors. Universal errors with JVMTI/JVMDI equivalents keep the
|
||||||
|
* values the same.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
JDWPTRANSPORT_ERROR_NONE = 0,
|
||||||
|
JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT = 103,
|
||||||
|
JDWPTRANSPORT_ERROR_OUT_OF_MEMORY = 110,
|
||||||
|
JDWPTRANSPORT_ERROR_INTERNAL = 113,
|
||||||
|
JDWPTRANSPORT_ERROR_ILLEGAL_STATE = 201,
|
||||||
|
JDWPTRANSPORT_ERROR_IO_ERROR = 202,
|
||||||
|
JDWPTRANSPORT_ERROR_TIMEOUT = 203,
|
||||||
|
JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE = 204
|
||||||
|
} jdwpTransportError;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Structure to define capabilities
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
unsigned int can_timeout_attach :1;
|
||||||
|
unsigned int can_timeout_accept :1;
|
||||||
|
unsigned int can_timeout_handshake :1;
|
||||||
|
unsigned int reserved3 :1;
|
||||||
|
unsigned int reserved4 :1;
|
||||||
|
unsigned int reserved5 :1;
|
||||||
|
unsigned int reserved6 :1;
|
||||||
|
unsigned int reserved7 :1;
|
||||||
|
unsigned int reserved8 :1;
|
||||||
|
unsigned int reserved9 :1;
|
||||||
|
unsigned int reserved10 :1;
|
||||||
|
unsigned int reserved11 :1;
|
||||||
|
unsigned int reserved12 :1;
|
||||||
|
unsigned int reserved13 :1;
|
||||||
|
unsigned int reserved14 :1;
|
||||||
|
unsigned int reserved15 :1;
|
||||||
|
} JDWPTransportCapabilities;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Structures to define packet layout.
|
||||||
|
*
|
||||||
|
* See: http://java.sun.com/j2se/1.5/docs/guide/jpda/jdwp-spec.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum {
|
||||||
|
JDWPTRANSPORT_FLAGS_NONE = 0x0,
|
||||||
|
JDWPTRANSPORT_FLAGS_REPLY = 0x80
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
jint len;
|
||||||
|
jint id;
|
||||||
|
jbyte flags;
|
||||||
|
jbyte cmdSet;
|
||||||
|
jbyte cmd;
|
||||||
|
jbyte *data;
|
||||||
|
} jdwpCmdPacket;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
jint len;
|
||||||
|
jint id;
|
||||||
|
jbyte flags;
|
||||||
|
jshort errorCode;
|
||||||
|
jbyte *data;
|
||||||
|
} jdwpReplyPacket;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
union {
|
||||||
|
jdwpCmdPacket cmd;
|
||||||
|
jdwpReplyPacket reply;
|
||||||
|
} type;
|
||||||
|
} jdwpPacket;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* JDWP functions called by the transport.
|
||||||
|
*/
|
||||||
|
typedef struct jdwpTransportCallback {
|
||||||
|
void *(*alloc)(jint numBytes); /* Call this for all allocations */
|
||||||
|
void (*free)(void *buffer); /* Call this for all deallocations */
|
||||||
|
} jdwpTransportCallback;
|
||||||
|
|
||||||
|
typedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm,
|
||||||
|
jdwpTransportCallback *callback,
|
||||||
|
jint version,
|
||||||
|
jdwpTransportEnv** env);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Function Interface */
|
||||||
|
|
||||||
|
struct jdwpTransportNativeInterface_ {
|
||||||
|
/* 1 : RESERVED */
|
||||||
|
void *reserved1;
|
||||||
|
|
||||||
|
/* 2 : Get Capabilities */
|
||||||
|
jdwpTransportError (JNICALL *GetCapabilities)(jdwpTransportEnv* env,
|
||||||
|
JDWPTransportCapabilities *capabilities_ptr);
|
||||||
|
|
||||||
|
/* 3 : Attach */
|
||||||
|
jdwpTransportError (JNICALL *Attach)(jdwpTransportEnv* env,
|
||||||
|
const char* address,
|
||||||
|
jlong attach_timeout,
|
||||||
|
jlong handshake_timeout);
|
||||||
|
|
||||||
|
/* 4: StartListening */
|
||||||
|
jdwpTransportError (JNICALL *StartListening)(jdwpTransportEnv* env,
|
||||||
|
const char* address,
|
||||||
|
char** actual_address);
|
||||||
|
|
||||||
|
/* 5: StopListening */
|
||||||
|
jdwpTransportError (JNICALL *StopListening)(jdwpTransportEnv* env);
|
||||||
|
|
||||||
|
/* 6: Accept */
|
||||||
|
jdwpTransportError (JNICALL *Accept)(jdwpTransportEnv* env,
|
||||||
|
jlong accept_timeout,
|
||||||
|
jlong handshake_timeout);
|
||||||
|
|
||||||
|
/* 7: IsOpen */
|
||||||
|
jboolean (JNICALL *IsOpen)(jdwpTransportEnv* env);
|
||||||
|
|
||||||
|
/* 8: Close */
|
||||||
|
jdwpTransportError (JNICALL *Close)(jdwpTransportEnv* env);
|
||||||
|
|
||||||
|
/* 9: ReadPacket */
|
||||||
|
jdwpTransportError (JNICALL *ReadPacket)(jdwpTransportEnv* env,
|
||||||
|
jdwpPacket *pkt);
|
||||||
|
|
||||||
|
/* 10: Write Packet */
|
||||||
|
jdwpTransportError (JNICALL *WritePacket)(jdwpTransportEnv* env,
|
||||||
|
const jdwpPacket* pkt);
|
||||||
|
|
||||||
|
/* 11: GetLastError */
|
||||||
|
jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env,
|
||||||
|
char** error);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Use inlined functions so that C++ code can use syntax such as
|
||||||
|
* env->Attach("mymachine:5000", 10*1000, 0);
|
||||||
|
*
|
||||||
|
* rather than using C's :-
|
||||||
|
*
|
||||||
|
* (*env)->Attach(env, "mymachine:5000", 10*1000, 0);
|
||||||
|
*/
|
||||||
|
struct _jdwpTransportEnv {
|
||||||
|
const struct jdwpTransportNativeInterface_ *functions;
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
jdwpTransportError GetCapabilities(JDWPTransportCapabilities *capabilities_ptr) {
|
||||||
|
return functions->GetCapabilities(this, capabilities_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
jdwpTransportError Attach(const char* address, jlong attach_timeout,
|
||||||
|
jlong handshake_timeout) {
|
||||||
|
return functions->Attach(this, address, attach_timeout, handshake_timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
jdwpTransportError StartListening(const char* address,
|
||||||
|
char** actual_address) {
|
||||||
|
return functions->StartListening(this, address, actual_address);
|
||||||
|
}
|
||||||
|
|
||||||
|
jdwpTransportError StopListening(void) {
|
||||||
|
return functions->StopListening(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
jdwpTransportError Accept(jlong accept_timeout, jlong handshake_timeout) {
|
||||||
|
return functions->Accept(this, accept_timeout, handshake_timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
jboolean IsOpen(void) {
|
||||||
|
return functions->IsOpen(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
jdwpTransportError Close(void) {
|
||||||
|
return functions->Close(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
jdwpTransportError ReadPacket(jdwpPacket *pkt) {
|
||||||
|
return functions->ReadPacket(this, pkt);
|
||||||
|
}
|
||||||
|
|
||||||
|
jdwpTransportError WritePacket(const jdwpPacket* pkt) {
|
||||||
|
return functions->WritePacket(this, pkt);
|
||||||
|
}
|
||||||
|
|
||||||
|
jdwpTransportError GetLastError(char** error) {
|
||||||
|
return functions->GetLastError(this, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* JDWPTRANSPORT_H */
|
||||||
|
|
||||||
1951
applications/JavaOpenJPEG/java-jni/include/jni.h
Normal file
1012
applications/JavaOpenJPEG/java-jni/include/jvmdi.h
Normal file
642
applications/JavaOpenJPEG/java-jni/include/jvmpi.h
Normal file
@@ -0,0 +1,642 @@
|
|||||||
|
/*
|
||||||
|
* @(#)jvmpi.h 1.28 03/12/19
|
||||||
|
*
|
||||||
|
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
||||||
|
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _JAVASOFT_JVMPI_H_
|
||||||
|
#define _JAVASOFT_JVMPI_H_
|
||||||
|
|
||||||
|
#include "jni.h"
|
||||||
|
|
||||||
|
#define JVMPI_VERSION_1 ((jint)0x10000001) /* implied 0 for minor version */
|
||||||
|
#define JVMPI_VERSION_1_1 ((jint)0x10000002)
|
||||||
|
#define JVMPI_VERSION_1_2 ((jint)0x10000003)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
typedef void (*jvmpi_void_function_of_void)(void *);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
* Profiler interface data structures.
|
||||||
|
****************************************************************/
|
||||||
|
/* identifier types. */
|
||||||
|
struct _jobjectID;
|
||||||
|
typedef struct _jobjectID * jobjectID; /* type of object ids */
|
||||||
|
|
||||||
|
/* raw monitors */
|
||||||
|
struct _JVMPI_RawMonitor;
|
||||||
|
typedef struct _JVMPI_RawMonitor * JVMPI_RawMonitor;
|
||||||
|
|
||||||
|
/* call frame */
|
||||||
|
typedef struct {
|
||||||
|
jint lineno; /* line number in the source file */
|
||||||
|
jmethodID method_id; /* method executed in this frame */
|
||||||
|
} JVMPI_CallFrame;
|
||||||
|
|
||||||
|
/* call trace */
|
||||||
|
typedef struct {
|
||||||
|
JNIEnv *env_id; /* Env where trace was recorded */
|
||||||
|
jint num_frames; /* number of frames in this trace */
|
||||||
|
JVMPI_CallFrame *frames; /* frames */
|
||||||
|
} JVMPI_CallTrace;
|
||||||
|
|
||||||
|
/* method */
|
||||||
|
typedef struct {
|
||||||
|
char *method_name; /* name of method */
|
||||||
|
char *method_signature; /* signature of method */
|
||||||
|
jint start_lineno; /* -1 if native, abstract .. */
|
||||||
|
jint end_lineno; /* -1 if native, abstract .. */
|
||||||
|
jmethodID method_id; /* id assigned to this method */
|
||||||
|
} JVMPI_Method;
|
||||||
|
|
||||||
|
/* Field */
|
||||||
|
typedef struct {
|
||||||
|
char *field_name; /* name of field */
|
||||||
|
char *field_signature; /* signature of field */
|
||||||
|
} JVMPI_Field;
|
||||||
|
|
||||||
|
/* line number info for a compiled method */
|
||||||
|
typedef struct {
|
||||||
|
jint offset; /* offset from beginning of method */
|
||||||
|
jint lineno; /* lineno from beginning of src file */
|
||||||
|
} JVMPI_Lineno;
|
||||||
|
|
||||||
|
/* event */
|
||||||
|
typedef struct {
|
||||||
|
jint event_type; /* event_type */
|
||||||
|
JNIEnv *env_id; /* env where this event occured */
|
||||||
|
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
const char *class_name; /* class name */
|
||||||
|
char *source_name; /* name of source file */
|
||||||
|
jint num_interfaces; /* number of interfaces implemented */
|
||||||
|
jint num_methods; /* number of methods in the class */
|
||||||
|
JVMPI_Method *methods; /* methods */
|
||||||
|
jint num_static_fields; /* number of static fields */
|
||||||
|
JVMPI_Field *statics; /* static fields */
|
||||||
|
jint num_instance_fields; /* number of instance fields */
|
||||||
|
JVMPI_Field *instances; /* instance fields */
|
||||||
|
jobjectID class_id; /* id of the class object */
|
||||||
|
} class_load;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jobjectID class_id; /* id of the class object */
|
||||||
|
} class_unload;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
unsigned char *class_data; /* content of class file */
|
||||||
|
jint class_data_len; /* class file length */
|
||||||
|
unsigned char *new_class_data; /* instrumented class file */
|
||||||
|
jint new_class_data_len; /* new class file length */
|
||||||
|
void * (*malloc_f)(unsigned int); /* memory allocation function */
|
||||||
|
} class_load_hook;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jint arena_id;
|
||||||
|
jobjectID class_id; /* id of object class */
|
||||||
|
jint is_array; /* JVMPI_NORMAL_OBJECT, ... */
|
||||||
|
jint size; /* size in number of bytes */
|
||||||
|
jobjectID obj_id; /* id assigned to this object */
|
||||||
|
} obj_alloc;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jobjectID obj_id; /* id of the object */
|
||||||
|
} obj_free;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jint arena_id; /* cur arena id */
|
||||||
|
jobjectID obj_id; /* cur object id */
|
||||||
|
jint new_arena_id; /* new arena id */
|
||||||
|
jobjectID new_obj_id; /* new object id */
|
||||||
|
} obj_move;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jint arena_id; /* id of arena */
|
||||||
|
const char *arena_name; /* name of arena */
|
||||||
|
} new_arena;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jint arena_id; /* id of arena */
|
||||||
|
} delete_arena;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
char *thread_name; /* name of thread */
|
||||||
|
char *group_name; /* name of group */
|
||||||
|
char *parent_name; /* name of parent */
|
||||||
|
jobjectID thread_id; /* id of the thread object */
|
||||||
|
JNIEnv *thread_env_id;
|
||||||
|
} thread_start;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int dump_level; /* level of the heap dump info */
|
||||||
|
char *begin; /* where all the root records begin,
|
||||||
|
please see the heap dump buffer
|
||||||
|
format described below */
|
||||||
|
char *end; /* where the object records end. */
|
||||||
|
jint num_traces; /* number of thread traces,
|
||||||
|
0 if dump level = JVMPI_DUMP_LEVEL_0 */
|
||||||
|
JVMPI_CallTrace *traces; /* thread traces collected during
|
||||||
|
heap dump */
|
||||||
|
} heap_dump;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jobjectID obj_id; /* object id */
|
||||||
|
jobject ref_id; /* id assigned to the globalref */
|
||||||
|
} jni_globalref_alloc;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jobject ref_id; /* id of the global ref */
|
||||||
|
} jni_globalref_free;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jmethodID method_id; /* method */
|
||||||
|
} method;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jmethodID method_id; /* id of method */
|
||||||
|
jobjectID obj_id; /* id of target object */
|
||||||
|
} method_entry2;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jmethodID method_id; /* id of compiled method */
|
||||||
|
void *code_addr; /* code start addr. in memory */
|
||||||
|
jint code_size; /* code size */
|
||||||
|
jint lineno_table_size; /* size of lineno table */
|
||||||
|
JVMPI_Lineno *lineno_table; /* lineno info */
|
||||||
|
} compiled_method_load;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jmethodID method_id; /* id of unloaded compiled method */
|
||||||
|
} compiled_method_unload;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jmethodID method_id; /* id of the method the instruction belongs to */
|
||||||
|
jint offset; /* instruction offset in the method's bytecode */
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
jboolean is_true; /* whether true or false branch is taken */
|
||||||
|
} if_info;
|
||||||
|
struct {
|
||||||
|
jint key; /* top stack value used as an index */
|
||||||
|
jint low; /* min value of the index */
|
||||||
|
jint hi; /* max value of the index */
|
||||||
|
} tableswitch_info;
|
||||||
|
struct {
|
||||||
|
jint chosen_pair_index; /* actually chosen pair index (0-based)
|
||||||
|
* if chosen_pair_index == pairs_total then
|
||||||
|
* the 'default' branch is taken
|
||||||
|
*/
|
||||||
|
jint pairs_total; /* total number of lookupswitch pairs */
|
||||||
|
} lookupswitch_info;
|
||||||
|
} u;
|
||||||
|
} instruction;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
char *begin; /* beginning of dump buffer,
|
||||||
|
see below for format */
|
||||||
|
char *end; /* end of dump buffer */
|
||||||
|
jint num_traces; /* number of traces */
|
||||||
|
JVMPI_CallTrace *traces; /* traces of all threads */
|
||||||
|
jint *threads_status; /* status of all threads */
|
||||||
|
} monitor_dump;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
const char *name; /* name of raw monitor */
|
||||||
|
JVMPI_RawMonitor id; /* id */
|
||||||
|
} raw_monitor;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jobjectID object; /* Java object */
|
||||||
|
} monitor;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jobjectID object; /* Java object */
|
||||||
|
jlong timeout; /* timeout period */
|
||||||
|
} monitor_wait;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jlong used_objects;
|
||||||
|
jlong used_object_space;
|
||||||
|
jlong total_object_space;
|
||||||
|
} gc_info;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
jint data_len;
|
||||||
|
char *data;
|
||||||
|
} object_dump;
|
||||||
|
} u;
|
||||||
|
} JVMPI_Event;
|
||||||
|
|
||||||
|
/* interface functions */
|
||||||
|
typedef struct {
|
||||||
|
jint version; /* JVMPI version */
|
||||||
|
|
||||||
|
/* ------interface implemented by the profiler------ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called by the JVM to notify an event.
|
||||||
|
*/
|
||||||
|
void (*NotifyEvent)(JVMPI_Event *event);
|
||||||
|
|
||||||
|
/* ------interface implemented by the JVM------ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called by the profiler to enable/disable/send notification
|
||||||
|
* for a particular event type.
|
||||||
|
*
|
||||||
|
* event_type - event_type
|
||||||
|
* arg - event specific arg
|
||||||
|
*
|
||||||
|
* return JVMPI_NOT_AVAILABLE, JVMPI_SUCCESS or JVMPI_FAIL
|
||||||
|
*/
|
||||||
|
jint (*EnableEvent)(jint event_type, void *arg);
|
||||||
|
jint (*DisableEvent)(jint event_type, void *arg);
|
||||||
|
jint (*RequestEvent)(jint event_type, void *arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called by the profiler to get a stack
|
||||||
|
* trace from the JVM.
|
||||||
|
*
|
||||||
|
* trace - trace data structure to be filled
|
||||||
|
* depth - maximum depth of the trace.
|
||||||
|
*/
|
||||||
|
void (*GetCallTrace)(JVMPI_CallTrace *trace, jint depth);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called by profiler when it wants to exit/stop.
|
||||||
|
*/
|
||||||
|
void (*ProfilerExit)(jint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility functions provided by the JVM.
|
||||||
|
*/
|
||||||
|
JVMPI_RawMonitor (*RawMonitorCreate)(char *lock_name);
|
||||||
|
void (*RawMonitorEnter)(JVMPI_RawMonitor lock_id);
|
||||||
|
void (*RawMonitorExit)(JVMPI_RawMonitor lock_id);
|
||||||
|
void (*RawMonitorWait)(JVMPI_RawMonitor lock_id, jlong ms);
|
||||||
|
void (*RawMonitorNotifyAll)(JVMPI_RawMonitor lock_id);
|
||||||
|
void (*RawMonitorDestroy)(JVMPI_RawMonitor lock_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called by the profiler to get the current thread's CPU time.
|
||||||
|
*
|
||||||
|
* return time in nanoseconds;
|
||||||
|
*/
|
||||||
|
jlong (*GetCurrentThreadCpuTime)(void);
|
||||||
|
|
||||||
|
void (*SuspendThread)(JNIEnv *env);
|
||||||
|
void (*ResumeThread)(JNIEnv *env);
|
||||||
|
jint (*GetThreadStatus)(JNIEnv *env);
|
||||||
|
jboolean (*ThreadHasRun)(JNIEnv *env);
|
||||||
|
|
||||||
|
/* This function can be called safely only after JVMPI_EVENT_VM_INIT_DONE
|
||||||
|
notification by the JVM. */
|
||||||
|
jint (*CreateSystemThread)(char *name, jint priority, void (*f)(void *));
|
||||||
|
|
||||||
|
/* thread local storage access functions to avoid locking in time
|
||||||
|
critical functions */
|
||||||
|
void (*SetThreadLocalStorage)(JNIEnv *env_id, void *ptr);
|
||||||
|
void * (*GetThreadLocalStorage)(JNIEnv *env_id);
|
||||||
|
|
||||||
|
/* control GC */
|
||||||
|
void (*DisableGC)(void);
|
||||||
|
void (*EnableGC)(void);
|
||||||
|
void (*RunGC)(void);
|
||||||
|
|
||||||
|
jobjectID (*GetThreadObject)(JNIEnv *env);
|
||||||
|
jobjectID (*GetMethodClass)(jmethodID mid);
|
||||||
|
|
||||||
|
/* JNI <-> jobject conversions */
|
||||||
|
jobject (*jobjectID2jobject)(jobjectID jid);
|
||||||
|
jobjectID (*jobject2jobjectID)(jobject jobj);
|
||||||
|
|
||||||
|
void (*SuspendThreadList)
|
||||||
|
(jint reqCount, JNIEnv **reqList, jint *results);
|
||||||
|
void (*ResumeThreadList)
|
||||||
|
(jint reqCount, JNIEnv **reqList, jint *results);
|
||||||
|
} JVMPI_Interface;
|
||||||
|
|
||||||
|
/* type of argument passed to RequestEvent for heap dumps */
|
||||||
|
typedef struct {
|
||||||
|
jint heap_dump_level;
|
||||||
|
} JVMPI_HeapDumpArg;
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Constants and formats used in JVM Profiler Interface.
|
||||||
|
**********************************************************************/
|
||||||
|
/*
|
||||||
|
* Event type constants.
|
||||||
|
*/
|
||||||
|
#define JVMPI_EVENT_METHOD_ENTRY ((jint)1)
|
||||||
|
#define JVMPI_EVENT_METHOD_ENTRY2 ((jint)2)
|
||||||
|
#define JVMPI_EVENT_METHOD_EXIT ((jint)3)
|
||||||
|
|
||||||
|
#define JVMPI_EVENT_OBJECT_ALLOC ((jint)4)
|
||||||
|
#define JVMPI_EVENT_OBJECT_FREE ((jint)5)
|
||||||
|
#define JVMPI_EVENT_OBJECT_MOVE ((jint)6)
|
||||||
|
|
||||||
|
#define JVMPI_EVENT_COMPILED_METHOD_LOAD ((jint)7)
|
||||||
|
#define JVMPI_EVENT_COMPILED_METHOD_UNLOAD ((jint)8)
|
||||||
|
|
||||||
|
#define JVMPI_EVENT_INSTRUCTION_START ((jint)9)
|
||||||
|
|
||||||
|
#define JVMPI_EVENT_THREAD_START ((jint)33)
|
||||||
|
#define JVMPI_EVENT_THREAD_END ((jint)34)
|
||||||
|
|
||||||
|
#define JVMPI_EVENT_CLASS_LOAD_HOOK ((jint)35)
|
||||||
|
|
||||||
|
#define JVMPI_EVENT_HEAP_DUMP ((jint)37)
|
||||||
|
#define JVMPI_EVENT_JNI_GLOBALREF_ALLOC ((jint)38)
|
||||||
|
#define JVMPI_EVENT_JNI_GLOBALREF_FREE ((jint)39)
|
||||||
|
#define JVMPI_EVENT_JNI_WEAK_GLOBALREF_ALLOC ((jint)40)
|
||||||
|
#define JVMPI_EVENT_JNI_WEAK_GLOBALREF_FREE ((jint)41)
|
||||||
|
#define JVMPI_EVENT_CLASS_LOAD ((jint)42)
|
||||||
|
#define JVMPI_EVENT_CLASS_UNLOAD ((jint)43)
|
||||||
|
#define JVMPI_EVENT_DATA_DUMP_REQUEST ((jint)44)
|
||||||
|
#define JVMPI_EVENT_DATA_RESET_REQUEST ((jint)45)
|
||||||
|
|
||||||
|
#define JVMPI_EVENT_JVM_INIT_DONE ((jint)46)
|
||||||
|
#define JVMPI_EVENT_JVM_SHUT_DOWN ((jint)47)
|
||||||
|
|
||||||
|
#define JVMPI_EVENT_ARENA_NEW ((jint)48)
|
||||||
|
#define JVMPI_EVENT_ARENA_DELETE ((jint)49)
|
||||||
|
|
||||||
|
#define JVMPI_EVENT_OBJECT_DUMP ((jint)50)
|
||||||
|
|
||||||
|
#define JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTER ((jint)51)
|
||||||
|
#define JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTERED ((jint)52)
|
||||||
|
#define JVMPI_EVENT_RAW_MONITOR_CONTENDED_EXIT ((jint)53)
|
||||||
|
#define JVMPI_EVENT_MONITOR_CONTENDED_ENTER ((jint)54)
|
||||||
|
#define JVMPI_EVENT_MONITOR_CONTENDED_ENTERED ((jint)55)
|
||||||
|
#define JVMPI_EVENT_MONITOR_CONTENDED_EXIT ((jint)56)
|
||||||
|
#define JVMPI_EVENT_MONITOR_WAIT ((jint)57)
|
||||||
|
#define JVMPI_EVENT_MONITOR_WAITED ((jint)58)
|
||||||
|
#define JVMPI_EVENT_MONITOR_DUMP ((jint)59)
|
||||||
|
|
||||||
|
#define JVMPI_EVENT_GC_START ((jint)60)
|
||||||
|
#define JVMPI_EVENT_GC_FINISH ((jint)61)
|
||||||
|
|
||||||
|
#define JVMPI_MAX_EVENT_TYPE_VAL ((jint)61)
|
||||||
|
|
||||||
|
/* old definitions, to be removed */
|
||||||
|
#define JVMPI_EVENT_LOAD_COMPILED_METHOD ((jint)7)
|
||||||
|
#define JVMPI_EVENT_UNLOAD_COMPILED_METHOD ((jint)8)
|
||||||
|
#define JVMPI_EVENT_NEW_ARENA ((jint)48)
|
||||||
|
#define JVMPI_EVENT_DELETE_ARENA ((jint)49)
|
||||||
|
#define JVMPI_EVENT_DUMP_DATA_REQUEST ((jint)44)
|
||||||
|
#define JVMPI_EVENT_RESET_DATA_REQUEST ((jint)45)
|
||||||
|
#define JVMPI_EVENT_OBJ_ALLOC ((jint)4)
|
||||||
|
#define JVMPI_EVENT_OBJ_FREE ((jint)5)
|
||||||
|
#define JVMPI_EVENT_OBJ_MOVE ((jint)6)
|
||||||
|
|
||||||
|
#define JVMPI_REQUESTED_EVENT ((jint)0x10000000)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* enabling/disabling event notification.
|
||||||
|
*/
|
||||||
|
/* results */
|
||||||
|
#define JVMPI_SUCCESS ((jint)0)
|
||||||
|
#define JVMPI_NOT_AVAILABLE ((jint)1)
|
||||||
|
#define JVMPI_FAIL ((jint)-1)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Thread status
|
||||||
|
*/
|
||||||
|
enum {
|
||||||
|
JVMPI_THREAD_RUNNABLE = 1,
|
||||||
|
JVMPI_THREAD_MONITOR_WAIT,
|
||||||
|
JVMPI_THREAD_CONDVAR_WAIT
|
||||||
|
};
|
||||||
|
|
||||||
|
#define JVMPI_THREAD_SUSPENDED 0x8000
|
||||||
|
#define JVMPI_THREAD_INTERRUPTED 0x4000
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Thread priority
|
||||||
|
*/
|
||||||
|
#define JVMPI_MINIMUM_PRIORITY 1
|
||||||
|
#define JVMPI_MAXIMUM_PRIORITY 10
|
||||||
|
#define JVMPI_NORMAL_PRIORITY 5
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Object type constants.
|
||||||
|
*/
|
||||||
|
#define JVMPI_NORMAL_OBJECT ((jint)0)
|
||||||
|
#define JVMPI_CLASS ((jint)2)
|
||||||
|
#define JVMPI_BOOLEAN ((jint)4)
|
||||||
|
#define JVMPI_CHAR ((jint)5)
|
||||||
|
#define JVMPI_FLOAT ((jint)6)
|
||||||
|
#define JVMPI_DOUBLE ((jint)7)
|
||||||
|
#define JVMPI_BYTE ((jint)8)
|
||||||
|
#define JVMPI_SHORT ((jint)9)
|
||||||
|
#define JVMPI_INT ((jint)10)
|
||||||
|
#define JVMPI_LONG ((jint)11)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Monitor dump constants.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define JVMPI_MONITOR_JAVA 0x01
|
||||||
|
#define JVMPI_MONITOR_RAW 0x02
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Heap dump constants.
|
||||||
|
*/
|
||||||
|
#define JVMPI_GC_ROOT_UNKNOWN 0xff
|
||||||
|
#define JVMPI_GC_ROOT_JNI_GLOBAL 0x01
|
||||||
|
#define JVMPI_GC_ROOT_JNI_LOCAL 0x02
|
||||||
|
#define JVMPI_GC_ROOT_JAVA_FRAME 0x03
|
||||||
|
#define JVMPI_GC_ROOT_NATIVE_STACK 0x04
|
||||||
|
#define JVMPI_GC_ROOT_STICKY_CLASS 0x05
|
||||||
|
#define JVMPI_GC_ROOT_THREAD_BLOCK 0x06
|
||||||
|
#define JVMPI_GC_ROOT_MONITOR_USED 0x07
|
||||||
|
#define JVMPI_GC_ROOT_THREAD_OBJ 0x08
|
||||||
|
|
||||||
|
#define JVMPI_GC_CLASS_DUMP 0x20
|
||||||
|
#define JVMPI_GC_INSTANCE_DUMP 0x21
|
||||||
|
#define JVMPI_GC_OBJ_ARRAY_DUMP 0x22
|
||||||
|
#define JVMPI_GC_PRIM_ARRAY_DUMP 0x23
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Dump levels
|
||||||
|
*/
|
||||||
|
#define JVMPI_DUMP_LEVEL_0 ((jint)0)
|
||||||
|
#define JVMPI_DUMP_LEVEL_1 ((jint)1)
|
||||||
|
#define JVMPI_DUMP_LEVEL_2 ((jint)2)
|
||||||
|
|
||||||
|
/* Types used in dumps -
|
||||||
|
*
|
||||||
|
* u1: 1 byte
|
||||||
|
* u2: 2 bytes
|
||||||
|
* u4: 4 bytes
|
||||||
|
* u8: 8 bytes
|
||||||
|
*
|
||||||
|
* ty: u1 where:
|
||||||
|
* JVMPI_CLASS: object
|
||||||
|
* JVMPI_BOOLEAN: boolean
|
||||||
|
* JVMPI_CHAR: char
|
||||||
|
* JVMPI_FLOAT: float
|
||||||
|
* JVMPI_DOUBLE: double
|
||||||
|
* JVMPI_BYTE: byte
|
||||||
|
* JVMPI_SHORT: short
|
||||||
|
* JVMPI_INT: int
|
||||||
|
* JVMPI_LONG: long
|
||||||
|
*
|
||||||
|
* vl: values, exact type depends on the type of the value:
|
||||||
|
* JVMPI_BOOLEAN & JVMPI_BYTE: u1
|
||||||
|
* JVMPI_SHORT & JVMPI_CHAR: u2
|
||||||
|
* JVMPI_INT & JVMPI_FLOAT: u4
|
||||||
|
* JVMPI_LONG & JVMPI_DOUBLE: u8
|
||||||
|
* JVMPI_CLASS: jobjectID
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Format of the monitor dump buffer:
|
||||||
|
*
|
||||||
|
* u1 monitor type
|
||||||
|
*
|
||||||
|
* JVMPI_MONITOR_JAVA Java monitor
|
||||||
|
*
|
||||||
|
* jobjectID object
|
||||||
|
* JNIEnv * owner thread
|
||||||
|
* u4 entry count
|
||||||
|
* u4 # of threads waiting to enter
|
||||||
|
* [JNIEnv *]* threads waiting to enter
|
||||||
|
* u4 # of threads waiting to be notified
|
||||||
|
* [JNIEnv *]* threads waiting to be notified
|
||||||
|
*
|
||||||
|
* JVMPI_MONITOR_RAW raw monitor
|
||||||
|
*
|
||||||
|
* char * name
|
||||||
|
* JVMPI_RawMonitor raw monitor
|
||||||
|
* JNIEnv * owner thread
|
||||||
|
* u4 entry count
|
||||||
|
* u4 # of threads waiting to enter
|
||||||
|
* [JNIEnv *]* threads waiting to enter
|
||||||
|
* u4 # of threads waiting to be notified
|
||||||
|
* [JNIEnv *]* threads waiting to be notified
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Format of the heap dump buffer depends on the dump level
|
||||||
|
* specified in the JVMPI_HeapDumpArg passed to RequestEvent as arg.
|
||||||
|
* The default is JVMPI_DUMP_LEVEL_2.
|
||||||
|
*
|
||||||
|
* JVMPI_DUMP_LEVEL_0:
|
||||||
|
*
|
||||||
|
* u1 object type (JVMPI_CLASS ...)
|
||||||
|
* jobjectID object
|
||||||
|
*
|
||||||
|
* JVMPI_DUMP_LEVEL_1 and JVMPI_DUMP_LEVEL_2 use the following format:
|
||||||
|
* In the case of JVMPI_DUMP_LEVEL_1 the values of primitive fields in object
|
||||||
|
* instance dumps , the values of primitive statics in class dumps and the
|
||||||
|
* values of primitive arrays are excluded. JVMPI_DUMP_LEVEL_2 includes the
|
||||||
|
* primitive values.
|
||||||
|
*
|
||||||
|
* u1 record type
|
||||||
|
*
|
||||||
|
* JVMPI_GC_ROOT_UNKNOWN unknown root
|
||||||
|
*
|
||||||
|
* jobjectID object
|
||||||
|
*
|
||||||
|
* JVMPI_GC_ROOT_JNI_GLOBAL JNI global ref root
|
||||||
|
*
|
||||||
|
* jobjectID object
|
||||||
|
* jobject JNI global reference
|
||||||
|
*
|
||||||
|
* JVMPI_GC_ROOT_JNI_LOCAL JNI local ref
|
||||||
|
*
|
||||||
|
* jobjectID object
|
||||||
|
* JNIEnv * thread
|
||||||
|
* u4 frame # in stack trace (-1 for empty)
|
||||||
|
*
|
||||||
|
* JVMPI_GC_ROOT_JAVA_FRAME Java stack frame
|
||||||
|
*
|
||||||
|
* jobjectID object
|
||||||
|
* JNIEnv * thread
|
||||||
|
* u4 frame # in stack trace (-1 for empty)
|
||||||
|
*
|
||||||
|
* JVMPI_GC_ROOT_NATIVE_STACK Native stack
|
||||||
|
*
|
||||||
|
* jobjectID object
|
||||||
|
* JNIEnv * thread
|
||||||
|
*
|
||||||
|
* JVMPI_GC_ROOT_STICKY_CLASS System class
|
||||||
|
*
|
||||||
|
* jobjectID class object
|
||||||
|
*
|
||||||
|
* JVMPI_GC_ROOT_THREAD_BLOCK Reference from thread block
|
||||||
|
*
|
||||||
|
* jobjectID thread object
|
||||||
|
* JNIEnv * thread
|
||||||
|
*
|
||||||
|
* JVMPI_GC_ROOT_MONITOR_USED Busy monitor
|
||||||
|
*
|
||||||
|
* jobjectID object
|
||||||
|
*
|
||||||
|
* JVMPI_GC_CLASS_DUMP dump of a class object
|
||||||
|
*
|
||||||
|
* jobjectID class
|
||||||
|
* jobjectID super
|
||||||
|
* jobjectID class loader
|
||||||
|
* jobjectID signers
|
||||||
|
* jobjectID protection domain
|
||||||
|
* jobjectID class name
|
||||||
|
* void * reserved
|
||||||
|
*
|
||||||
|
* u4 instance size (in bytes)
|
||||||
|
*
|
||||||
|
* [jobjectID]* interfaces
|
||||||
|
*
|
||||||
|
* u2 size of constant pool
|
||||||
|
* [u2, constant pool index,
|
||||||
|
* ty, type,
|
||||||
|
* vl]* value
|
||||||
|
*
|
||||||
|
* [vl]* static field values
|
||||||
|
*
|
||||||
|
* JVMPI_GC_INSTANCE_DUMP dump of a normal object
|
||||||
|
*
|
||||||
|
* jobjectID object
|
||||||
|
* jobjectID class
|
||||||
|
* u4 number of bytes that follow
|
||||||
|
* [vl]* instance field values (class, followed
|
||||||
|
* by super, super's super ...)
|
||||||
|
*
|
||||||
|
* JVMPI_GC_OBJ_ARRAY_DUMP dump of an object array
|
||||||
|
*
|
||||||
|
* jobjectID array object
|
||||||
|
* u4 number of elements
|
||||||
|
* jobjectID element class
|
||||||
|
* [jobjectID]* elements
|
||||||
|
*
|
||||||
|
* JVMPI_GC_PRIM_ARRAY_DUMP dump of a primitive array
|
||||||
|
*
|
||||||
|
* jobjectID array object
|
||||||
|
* u4 number of elements
|
||||||
|
* ty element type
|
||||||
|
* [vl]* elements
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Format of the dump received in JVMPI_EVENT_OBJECT_DUMP:
|
||||||
|
* All the records have JVMPI_DUMP_LEVEL_2 information.
|
||||||
|
*
|
||||||
|
* u1 record type
|
||||||
|
*
|
||||||
|
* followed by a:
|
||||||
|
*
|
||||||
|
* JVMPI_GC_CLASS_DUMP,
|
||||||
|
* JVMPI_GC_INSTANCE_DUMP,
|
||||||
|
* JVMPI_GC_OBJ_ARRAY_DUMP, or
|
||||||
|
* JVMPI_GC_PRIM_ARRAY_DUMP record.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* !_JAVASOFT_JVMPI_H_ */
|
||||||
2181
applications/JavaOpenJPEG/java-jni/include/jvmti.h
Normal file
41
applications/JavaOpenJPEG/java-jni/include/win32/jawt_md.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* @(#)jawt_md.h 1.7 03/12/19
|
||||||
|
*
|
||||||
|
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
||||||
|
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _JAVASOFT_JAWT_MD_H_
|
||||||
|
#define _JAVASOFT_JAWT_MD_H_
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include "jawt.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Win32-specific declarations for AWT native interface.
|
||||||
|
* See notes in jawt.h for an example of use.
|
||||||
|
*/
|
||||||
|
typedef struct jawt_Win32DrawingSurfaceInfo {
|
||||||
|
/* Native window, DDB, or DIB handle */
|
||||||
|
union {
|
||||||
|
HWND hwnd;
|
||||||
|
HBITMAP hbitmap;
|
||||||
|
void* pbits;
|
||||||
|
};
|
||||||
|
/*
|
||||||
|
* This HDC should always be used instead of the HDC returned from
|
||||||
|
* BeginPaint() or any calls to GetDC().
|
||||||
|
*/
|
||||||
|
HDC hdc;
|
||||||
|
HPALETTE hpalette;
|
||||||
|
} JAWT_Win32DrawingSurfaceInfo;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* !_JAVASOFT_JAWT_MD_H_ */
|
||||||
19
applications/JavaOpenJPEG/java-jni/include/win32/jni_md.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* @(#)jni_md.h 1.14 03/12/19
|
||||||
|
*
|
||||||
|
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
||||||
|
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _JAVASOFT_JNI_MD_H_
|
||||||
|
#define _JAVASOFT_JNI_MD_H_
|
||||||
|
|
||||||
|
#define JNIEXPORT __declspec(dllexport)
|
||||||
|
#define JNIIMPORT __declspec(dllimport)
|
||||||
|
#define JNICALL __stdcall
|
||||||
|
|
||||||
|
typedef long jint;
|
||||||
|
typedef __int64 jlong;
|
||||||
|
typedef signed char jbyte;
|
||||||
|
|
||||||
|
#endif /* !_JAVASOFT_JNI_MD_H_ */
|
||||||
BIN
applications/JavaOpenJPEG/java-jni/lib/jvm.lib
Normal file
19
applications/Makefile.am
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
||||||
|
SUBDIRS = codec
|
||||||
|
|
||||||
|
if WANT_MJ2
|
||||||
|
SUBDIRS += mj2
|
||||||
|
endif
|
||||||
|
|
||||||
|
if WANT_JPIP
|
||||||
|
SUBDIRS += jpip
|
||||||
|
endif
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
CMakeLists.txt \
|
||||||
|
common/color.c \
|
||||||
|
common/color.h \
|
||||||
|
common/format_defs.h \
|
||||||
|
common/getopt.c \
|
||||||
|
common/getopt.h
|
||||||
41
applications/OPJViewer/Makefile
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Makefile for OPJViewer
|
||||||
|
|
||||||
|
# General configuration variables:
|
||||||
|
CC = $(shell wx-config-2.8 --cxx)
|
||||||
|
AR = ar
|
||||||
|
|
||||||
|
CFLAGS = -DUSE_JPWL -DwxUSE_LIBOPENJPEG -DwxUSE_GUI=1 -DOPJ_STATIC -DOPJ_HTMLABOUT -DOPJ_INICONFIG -DUSE_JPSEC -DOPJ_MANYFORMATS $(shell wx-config-2.8 --cxxflags) # -g -p -pg -DUSE_JPWL
|
||||||
|
|
||||||
|
OPJV_SRCS = source/imagjpeg2000.cpp source/wxj2kparser.cpp source/OPJViewer.cpp source/wxjp2parser.cpp source/OPJDialogs.cpp source/OPJThreads.cpp source/OPJAbout.cpp ../codec/index.c
|
||||||
|
|
||||||
|
MODULES = $(OPJV_SRCS:.cpp=.o)
|
||||||
|
|
||||||
|
all: opjviewer lib
|
||||||
|
|
||||||
|
.cpp.o:
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
lib:
|
||||||
|
cd ../jpwl; make
|
||||||
|
|
||||||
|
opjviewer: $(OPJV_SRCS) lib
|
||||||
|
$(CC) $(CFLAGS) -I .. -I ../codec -I ../libopenjpeg $(OPJV_SRCS) -o OPJViewer -L ../jpwl -lopenjpeg_JPWL -lm -lstdc++ -ltiff $(shell wx-config-2.8 --libs)
|
||||||
|
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f OPJViewer *.o *.a
|
||||||
|
cd ../libopenjpeg; rm -f *.o
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#.cpp.o :
|
||||||
|
# $(CXX) -g -c `wx-config-2.8 --cxxflags` -I ../.. -D wxUSE_LIBOPENJPEG -D wxHACK_BOOLEAN -o $@ $<
|
||||||
|
|
||||||
|
#all: $(PROGRAM)
|
||||||
|
|
||||||
|
#$(PROGRAM): $(OBJECTS)
|
||||||
|
# $(CXX) -o $(PROGRAM) $(OBJECTS) -lopenjpeg -L ../.. `wx-config-2.8 --libs`
|
||||||
|
|
||||||
|
#clean:
|
||||||
|
# rm -f *.o $(PROGRAM)
|
||||||
290
applications/OPJViewer/OPJViewer.dsp
Normal file
@@ -0,0 +1,290 @@
|
|||||||
|
# Microsoft Developer Studio Project File - Name="OPJViewer" - Package Owner=<4>
|
||||||
|
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||||
|
# ** DO NOT EDIT **
|
||||||
|
|
||||||
|
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||||
|
|
||||||
|
CFG=OPJVIEWER - WIN32 RELEASE
|
||||||
|
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||||
|
!MESSAGE use the Export Makefile command and run
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE NMAKE /f "OPJViewer.mak".
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE You can specify a configuration when running NMAKE
|
||||||
|
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE NMAKE /f "OPJViewer.mak" CFG="OPJVIEWER - WIN32 RELEASE"
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE Possible choices for configuration are:
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE "OPJViewer - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||||
|
!MESSAGE "OPJViewer - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||||
|
!MESSAGE
|
||||||
|
|
||||||
|
# Begin Project
|
||||||
|
# PROP AllowPerConfigDependencies 0
|
||||||
|
# PROP Scc_ProjName ""
|
||||||
|
# PROP Scc_LocalPath ""
|
||||||
|
CPP=cl.exe
|
||||||
|
RSC=rc.exe
|
||||||
|
|
||||||
|
!IF "$(CFG)" == "OPJViewer - Win32 Release"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 0
|
||||||
|
# PROP BASE Output_Dir "Release"
|
||||||
|
# PROP BASE Intermediate_Dir "Release"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 0
|
||||||
|
# PROP Output_Dir "Release"
|
||||||
|
# PROP Intermediate_Dir "Release"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||||
|
# ADD CPP /nologo /G6 /MD /W3 /GX /O2 /I "$(WXWIN28)\lib\vc_lib\msw" /I "$(WXWIN28)\include" /I ".." /I "..\libopenjpeg" /I "$(MXFLIB)" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D WINVER=0x400 /D "_MT" /D wxUSE_GUI=1 /D "wxUSE_LIBOPENJPEG" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /D "OPJ_HTMLABOUT" /D "OPJ_MANYFORMATS" /D "OPJ_INICONFIG" /FR /FD /Zm200 /c
|
||||||
|
# ADD BASE RSC /l 0x410 /d "NDEBUG"
|
||||||
|
# ADD RSC /l 0x409 /i "$(WXWIN28)\include" /d "NDEBUG"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wxzlib.lib wxregex.lib wxpng.lib wxjpeg.lib wxbase28.lib wxmsw28_core.lib wxmsw28_html.lib wxmsw28_adv.lib wxmsw28_core.lib wxbase28.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregex.lib wxexpat.lib LibOpenJPEG_JPWL.lib mxflib.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libcmt.lib" /libpath:"$(WXWIN28)\lib\vc_lib" /libpath:"..\jpwl\Release" /libpath:"$(MXFLIB)\build\msvc\Release" /IGNORE:4089
|
||||||
|
# SUBTRACT LINK32 /pdb:none /nodefaultlib
|
||||||
|
# Begin Special Build Tool
|
||||||
|
SOURCE="$(InputPath)"
|
||||||
|
PostBuild_Desc=Update build number
|
||||||
|
PostBuild_Cmds=buildupdate.bat
|
||||||
|
# End Special Build Tool
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "OPJViewer - Win32 Debug"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 1
|
||||||
|
# PROP BASE Output_Dir "OPJViewer___Win32_Debug"
|
||||||
|
# PROP BASE Intermediate_Dir "OPJViewer___Win32_Debug"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 1
|
||||||
|
# PROP Output_Dir "Debug"
|
||||||
|
# PROP Intermediate_Dir "Debug"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||||
|
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "$(WXWIN28)\INCLUDE" /I "$(WXWIN28)\lib\vc_lib\msw" /I "$(WXWIN28)\include" /I ".." /I "..\libopenjpeg" /I "$(MXFLIB)" /D "_DEBUG" /D "__WXDEBUG__" /D WXDEBUG=1 /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D WINVER=0x400 /D "_MT" /D wxUSE_GUI=1 /D "wxUSE_LIBOPENJPEG" /D "OPJ_STATIC" /D "USE_JPWL" /D "OPJ_HTMLABOUT" /D "OPJ_INICONFIG" /D "OPJ_MANYFORMATS" /D "USE_JPSEC" /FR /FD /GZ /Zm200 /c
|
||||||
|
# ADD BASE RSC /l 0x410 /d "_DEBUG"
|
||||||
|
# ADD RSC /l 0x410 /i "$(WXWIN28)\include" /d "_DEBUG"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wxzlibd.lib wxregexd.lib wxpngd.lib wxjpegd.lib wxtiffd.lib wxbase28d.lib wxmsw28d_core.lib wxmsw28d_html.lib wxmsw28d_adv.lib LibOpenJPEG_JPWLd.lib mxflib.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcmtd.lib" /pdbtype:sept /libpath:"$(WXWIN28)\lib\vc_lib" /libpath:"..\jpwl\Debug" /libpath:"$(MXFLIB)\build\msvc\Debug"
|
||||||
|
# SUBTRACT LINK32 /pdb:none
|
||||||
|
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
# Begin Target
|
||||||
|
|
||||||
|
# Name "OPJViewer - Win32 Release"
|
||||||
|
# Name "OPJViewer - Win32 Debug"
|
||||||
|
# Begin Group "Source Files"
|
||||||
|
|
||||||
|
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\imagjpeg2000.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\imagmxf.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\codec\index.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\OPJAbout.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\OPJDialogs.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\OPJThreads.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\OPJViewer.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wxj2kparser.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wxjp2parser.cpp
|
||||||
|
# End Source File
|
||||||
|
# End Group
|
||||||
|
# Begin Group "Header Files"
|
||||||
|
|
||||||
|
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\about_htm.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\build.h
|
||||||
|
# PROP Exclude_From_Build 1
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\imagjpeg2000.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\imagmxf.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\codec\index.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\OPJViewer.h
|
||||||
|
# End Source File
|
||||||
|
# End Group
|
||||||
|
# Begin Group "Resource Files"
|
||||||
|
|
||||||
|
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\blank.cur
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\bullseye.cur
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\cdrom.ico
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\computer.ico
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\cross.cur
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\drive.ico
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\file1.ico
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\floppy.ico
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\folder1.ico
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\folder2.ico
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\hand.cur
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\icon1.xpm
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\icon2.xpm
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\icon3.xpm
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\icon4.xpm
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\icon5.xpm
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\magnif1.cur
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\opj_logo.xpm
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\OPJChild.ico
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\OPJChild16.xpm
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\OPJViewer.ico
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\OPJViewer.rc
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\OPJViewer16.xpm
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\pbrush.cur
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\pencil.cur
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\pntleft.cur
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\pntright.cur
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\removble.ico
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\rightarr.cur
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\roller.cur
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\source\wx\msw\std.ico
|
||||||
|
# End Source File
|
||||||
|
# End Group
|
||||||
|
# End Target
|
||||||
|
# End Project
|
||||||
56
applications/OPJViewer/OPJViewer.dsw
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||||
|
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
Project: "LibOpenJPEG_JPWL"=..\jpwl\LibOpenJPEG_JPWL.dsp - Package Owner=<4>
|
||||||
|
|
||||||
|
Package=<5>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
Package=<4>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
Project: "OPJViewer"=.\OPJViewer.dsp - Package Owner=<4>
|
||||||
|
|
||||||
|
Package=<5>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
Package=<4>
|
||||||
|
{{{
|
||||||
|
Begin Project Dependency
|
||||||
|
Project_Dep_Name LibOpenJPEG_JPWL
|
||||||
|
End Project Dependency
|
||||||
|
}}}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
Project: "mxflib"="..\..\..\..\mxflib-1.0.0\build\msvc\mxflib.dsp" - Package Owner=<4>
|
||||||
|
|
||||||
|
Package=<5>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
Package=<4>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
Global:
|
||||||
|
|
||||||
|
Package=<5>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
Package=<3>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
15
applications/OPJViewer/buildupdate.bat
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
::== buildupdate.bat
|
||||||
|
@echo off
|
||||||
|
setLocal EnableDelayedExpansion
|
||||||
|
|
||||||
|
for /f "tokens=2,* delims=^(^) " %%a in ('find /v "" ^< .\source\build.h') do (
|
||||||
|
rem echo %%a
|
||||||
|
set /A M = %%a + 1
|
||||||
|
echo Build %%a done^!
|
||||||
|
echo wxT^("!M!"^) > buildtemp283746825t347
|
||||||
|
)
|
||||||
|
|
||||||
|
if exist buildtemp283746825t347 move /Y buildtemp283746825t347 .\source\build.h
|
||||||
|
if exist buildtemp283746825t347 del /F /Q buildtemp283746825t347
|
||||||
|
|
||||||
|
::==
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -360,22 +360,6 @@ wxPanel* OPJDecoderDialog::CreatePart11SettingsPage(wxWindow* parent)
|
|||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OPJDecoderDialog::OnEnableJPWL(wxCommandEvent& event)
|
|
||||||
{
|
|
||||||
if (event.IsChecked()) {
|
|
||||||
wxLogMessage(wxT("JPWL enabled"));
|
|
||||||
m_expcompsCtrl->Enable(true);
|
|
||||||
m_maxtilesCtrl->Enable(true);
|
|
||||||
} else {
|
|
||||||
wxLogMessage(wxT("JPWL disabled"));
|
|
||||||
m_expcompsCtrl->Enable(false);
|
|
||||||
m_maxtilesCtrl->Enable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // USE_JPWL
|
|
||||||
|
|
||||||
void OPJDecoderDialog::OnEnableDeco(wxCommandEvent& event)
|
void OPJDecoderDialog::OnEnableDeco(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
size_t pp;
|
size_t pp;
|
||||||
@@ -400,6 +384,22 @@ void OPJDecoderDialog::OnEnableDeco(wxCommandEvent& event)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OPJDecoderDialog::OnEnableJPWL(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
if (event.IsChecked()) {
|
||||||
|
wxLogMessage(wxT("JPWL enabled"));
|
||||||
|
m_expcompsCtrl->Enable(true);
|
||||||
|
m_maxtilesCtrl->Enable(true);
|
||||||
|
} else {
|
||||||
|
wxLogMessage(wxT("JPWL disabled"));
|
||||||
|
m_expcompsCtrl->Enable(false);
|
||||||
|
m_maxtilesCtrl->Enable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // USE_JPWL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1373,8 +1373,6 @@ void OPJFrame::OnFileSaveAs(wxCommandEvent& WXUNUSED(event))
|
|||||||
wxT("JPEG 2000 codestream (*.j2k)|*.j2k")
|
wxT("JPEG 2000 codestream (*.j2k)|*.j2k")
|
||||||
wxT("|JPEG 2000 file format (*.jp2)|*.jp2");
|
wxT("|JPEG 2000 file format (*.jp2)|*.jp2");
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
wxT("Houston we have a problem");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxFileDialog dialog(this, _T("Save image file"),
|
wxFileDialog dialog(this, _T("Save image file"),
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita degli studi di Perugia (UPG), Italy
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
#include "wx/toolbar.h"
|
#include "wx/toolbar.h"
|
||||||
#include "wx/artprov.h"
|
#include "wx/artprov.h"
|
||||||
|
|
||||||
#include "openjp2/openjpeg.h"
|
#include "libopenjpeg/openjpeg.h"
|
||||||
|
|
||||||
//#include "imagj2k.h"
|
//#include "imagj2k.h"
|
||||||
//#include "imagjp2.h"
|
//#include "imagjp2.h"
|
||||||
@@ -214,8 +214,8 @@ class OPJViewerApp: public wxApp
|
|||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
bool m_enablejpwl, m_enablejpwle;
|
bool m_enablejpwl, m_enablejpwle;
|
||||||
int m_expcomps, m_maxtiles;
|
int m_expcomps, m_maxtiles;
|
||||||
#endif // USE_JPWL
|
|
||||||
int m_framewidth, m_frameheight;
|
int m_framewidth, m_frameheight;
|
||||||
|
#endif // USE_JPWL
|
||||||
|
|
||||||
// encoding engine parameters
|
// encoding engine parameters
|
||||||
wxString m_subsampling, m_origin, m_rates, m_comment, m_index, m_quality;
|
wxString m_subsampling, m_origin, m_rates, m_comment, m_index, m_quality;
|
||||||
@@ -782,10 +782,9 @@ public:
|
|||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
void OnEnableJPWL(wxCommandEvent& event);
|
void OnEnableJPWL(wxCommandEvent& event);
|
||||||
wxPanel* CreatePart11SettingsPage(wxWindow* parent);
|
wxPanel* CreatePart11SettingsPage(wxWindow* parent);
|
||||||
wxSpinCtrl *m_expcompsCtrl, *m_maxtilesCtrl;
|
wxSpinCtrl *m_expcompsCtrl, *m_framenumCtrl, *m_maxtilesCtrl;
|
||||||
wxCheckBox *m_enablejpwlCheck;
|
wxCheckBox *m_enablejpwlCheck;
|
||||||
#endif // USE_JPWL
|
#endif // USE_JPWL
|
||||||
wxSpinCtrl *m_framenumCtrl;
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -1,5 +1,5 @@
|
|||||||
/* XPM */
|
/* XPM */
|
||||||
static const char *icon1_xpm[] = {
|
static char *icon1_xpm[] = {
|
||||||
/* columns rows colors chars-per-pixel */
|
/* columns rows colors chars-per-pixel */
|
||||||
"32 32 41 1",
|
"32 32 41 1",
|
||||||
"> c #97C4E7",
|
"> c #97C4E7",
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/* XPM */
|
/* XPM */
|
||||||
static const char *icon2_xpm[] = {
|
static char *icon2_xpm[] = {
|
||||||
/* columns rows colors chars-per-pixel */
|
/* columns rows colors chars-per-pixel */
|
||||||
"32 32 15 1",
|
"32 32 15 1",
|
||||||
". c Black",
|
". c Black",
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/* XPM */
|
/* XPM */
|
||||||
static const char *icon3_xpm[] = {
|
static char *icon3_xpm[] = {
|
||||||
/* columns rows colors chars-per-pixel */
|
/* columns rows colors chars-per-pixel */
|
||||||
"32 32 41 1",
|
"32 32 41 1",
|
||||||
"6 c #EDF2FB",
|
"6 c #EDF2FB",
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/* XPM */
|
/* XPM */
|
||||||
static const char *icon4_xpm[] = {
|
static char *icon4_xpm[] = {
|
||||||
/* columns rows colors chars-per-pixel */
|
/* columns rows colors chars-per-pixel */
|
||||||
"32 32 5 1",
|
"32 32 5 1",
|
||||||
". c Black",
|
". c Black",
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/* XPM */
|
/* XPM */
|
||||||
static const char *icon5_xpm[] = {
|
static char *icon5_xpm[] = {
|
||||||
/* columns rows colors chars-per-pixel */
|
/* columns rows colors chars-per-pixel */
|
||||||
"32 32 41 1",
|
"32 32 41 1",
|
||||||
"0 c #AAC1E8",
|
"0 c #AAC1E8",
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
#include "wx/module.h"
|
#include "wx/module.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "openjp2/openjpeg.h"
|
#include "libopenjpeg/openjpeg.h"
|
||||||
|
|
||||||
#include "wx/filefn.h"
|
#include "wx/filefn.h"
|
||||||
#include "wx/wfstream.h"
|
#include "wx/wfstream.h"
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita degli studi di Perugia (UPG), Italy
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -44,8 +44,8 @@
|
|||||||
#if wxUSE_LIBOPENJPEG
|
#if wxUSE_LIBOPENJPEG
|
||||||
|
|
||||||
#include "wx/image.h"
|
#include "wx/image.h"
|
||||||
#include "openjp2/openjpeg.h"
|
#include "libopenjpeg/openjpeg.h"
|
||||||
#include "jp2/index.h"
|
#include "codec/index.h"
|
||||||
|
|
||||||
#define wxBITMAP_TYPE_JPEG2000 50
|
#define wxBITMAP_TYPE_JPEG2000 50
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita degli studi di Perugia (UPG), Italy
|
* Copyright (c) 2007, Digital Signal Processing Laboratory, Università degli studi di Perugia (UPG), Italy
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -93,7 +93,7 @@ unsigned short int marker_val[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Marker names
|
// Marker names
|
||||||
static const char *marker_name[] = {
|
char *marker_name[] = {
|
||||||
"SOC", "SOT", "SOD", "EOC",
|
"SOC", "SOT", "SOD", "EOC",
|
||||||
"SIZ",
|
"SIZ",
|
||||||
"COD", "COC", "RGN", "QCD", "QCC", "POD",
|
"COD", "COC", "RGN", "QCD", "QCC", "POD",
|
||||||
@@ -109,7 +109,7 @@ static const char *marker_name[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Marker descriptions
|
// Marker descriptions
|
||||||
static const char *marker_descr[] = {
|
char *marker_descr[] = {
|
||||||
"Start of codestream", "Start of tile-part", "Start of data", "End of codestream",
|
"Start of codestream", "Start of tile-part", "Start of data", "End of codestream",
|
||||||
"Image and tile size",
|
"Image and tile size",
|
||||||
"Coding style default", "Coding style component", "Region-of-interest", "Quantization default",
|
"Coding style default", "Coding style component", "Region-of-interest", "Quantization default",
|
||||||
142
applications/codec/CMakeLists.txt
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
# Build the demo app, small examples
|
||||||
|
|
||||||
|
# First thing define the common source:
|
||||||
|
SET(common_SRCS
|
||||||
|
convert.c
|
||||||
|
index.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/common/color.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# If not getopt was found then add it to the lib:
|
||||||
|
IF(DONT_HAVE_GETOPT)
|
||||||
|
SET(common_SRCS
|
||||||
|
${common_SRCS}
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/common/getopt.c
|
||||||
|
)
|
||||||
|
ENDIF(DONT_HAVE_GETOPT)
|
||||||
|
|
||||||
|
# Headers file are located here:
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||||
|
${LCMS_INCLUDE_DIRNAME}
|
||||||
|
${OPENJPEG_SOURCE_DIR}/applications/common
|
||||||
|
${Z_INCLUDE_DIRNAME}
|
||||||
|
${PNG_INCLUDE_DIRNAME}
|
||||||
|
${TIFF_INCLUDE_DIRNAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
IF(WIN32)
|
||||||
|
IF(BUILD_SHARED_LIBS)
|
||||||
|
ADD_DEFINITIONS(-DOPJ_EXPORTS)
|
||||||
|
ELSE(BUILD_SHARED_LIBS)
|
||||||
|
ADD_DEFINITIONS(-DOPJ_STATIC)
|
||||||
|
ENDIF(BUILD_SHARED_LIBS)
|
||||||
|
ENDIF(WIN32)
|
||||||
|
|
||||||
|
# Loop over all executables:
|
||||||
|
FOREACH(exe j2k_to_image image_to_j2k j2k_dump)
|
||||||
|
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
|
||||||
|
TARGET_LINK_LIBRARIES(${exe} ${OPENJPEG_LIBRARY_NAME}
|
||||||
|
${Z_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME})
|
||||||
|
|
||||||
|
IF(LCMS_FOUND OR LCMS2_FOUND)
|
||||||
|
TARGET_LINK_LIBRARIES(${exe} ${LCMS_LIBNAME})
|
||||||
|
ENDIF(LCMS_FOUND OR LCMS2_FOUND)
|
||||||
|
|
||||||
|
ADD_TEST(${exe} ${EXECUTABLE_OUTPUT_PATH}/${exe})
|
||||||
|
# calling those exe without option will make them fail always:
|
||||||
|
SET_TESTS_PROPERTIES(${exe} PROPERTIES WILL_FAIL TRUE)
|
||||||
|
# On unix you need to link to the math library:
|
||||||
|
IF(UNIX)
|
||||||
|
TARGET_LINK_LIBRARIES(${exe} m)
|
||||||
|
ENDIF(UNIX)
|
||||||
|
# Install exe
|
||||||
|
INSTALL(TARGETS ${exe}
|
||||||
|
EXPORT OpenJPEGTargets
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||||
|
)
|
||||||
|
ENDFOREACH(exe)
|
||||||
|
|
||||||
|
# Install man pages
|
||||||
|
INSTALL(
|
||||||
|
FILES ${OPENJPEG_SOURCE_DIR}/doc/man/man1/image_to_j2k.1
|
||||||
|
${OPENJPEG_SOURCE_DIR}/doc/man/man1/j2k_dump.1
|
||||||
|
${OPENJPEG_SOURCE_DIR}/doc/man/man1/j2k_to_image.1
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man1)
|
||||||
|
#
|
||||||
|
|
||||||
|
IF(BUILD_JPWL)
|
||||||
|
ADD_EXECUTABLE(JPWL_j2k_to_image
|
||||||
|
j2k_to_image.c
|
||||||
|
${common_SRCS}
|
||||||
|
)
|
||||||
|
|
||||||
|
SET_PROPERTY(
|
||||||
|
TARGET JPWL_j2k_to_image
|
||||||
|
APPEND PROPERTY COMPILE_DEFINITIONS USE_JPWL
|
||||||
|
)
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${OPENJPEG_LIBRARY_NAME}_JPWL
|
||||||
|
${LCMS_LIBNAME} ${Z_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME})
|
||||||
|
|
||||||
|
IF(UNIX)
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image m)
|
||||||
|
ENDIF(UNIX)
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(JPWL_image_to_j2k
|
||||||
|
image_to_j2k.c
|
||||||
|
${common_SRCS}
|
||||||
|
)
|
||||||
|
|
||||||
|
SET_PROPERTY(
|
||||||
|
TARGET JPWL_image_to_j2k
|
||||||
|
APPEND PROPERTY COMPILE_DEFINITIONS USE_JPWL
|
||||||
|
)
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${OPENJPEG_LIBRARY_NAME}_JPWL
|
||||||
|
${LCMS_LIBNAME} ${Z_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME})
|
||||||
|
|
||||||
|
IF(UNIX)
|
||||||
|
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k m)
|
||||||
|
ENDIF(UNIX)
|
||||||
|
|
||||||
|
INSTALL(TARGETS JPWL_image_to_j2k JPWL_j2k_to_image
|
||||||
|
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||||
|
)
|
||||||
|
ENDIF(BUILD_JPWL)
|
||||||
|
|
||||||
|
if(BUILD_TESTING)
|
||||||
|
# Do testing here, once we know the examples are being built:
|
||||||
|
FILE(GLOB_RECURSE OPENJPEG_DATA_IMAGES_GLOB
|
||||||
|
"${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2k"
|
||||||
|
"${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2c"
|
||||||
|
"${JPEG2000_CONFORMANCE_DATA_ROOT}/*.jp2"
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach(filename ${OPENJPEG_DATA_IMAGES_GLOB})
|
||||||
|
get_filename_component(filename_temp ${filename} NAME)
|
||||||
|
get_filename_component(filename_ext ${filename} EXT)
|
||||||
|
execute_process(COMMAND ${EXECUTABLE_OUTPUT_PATH}/j2k_dump -i ${filename}
|
||||||
|
OUTPUT_VARIABLE dump_success
|
||||||
|
OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${filename_temp}.dump
|
||||||
|
ERROR_QUIET
|
||||||
|
)
|
||||||
|
if(dump_success)
|
||||||
|
file(READ ${CMAKE_CURRENT_BINARY_DIR}/${filename_temp}.dump numcomp_file)
|
||||||
|
string(REGEX REPLACE ".*numcomps=([0-9]+).*" "\\1"
|
||||||
|
numcomps "${numcomp_file}")
|
||||||
|
#message( "found:${output_variable} for ${filename_temp}" )
|
||||||
|
endif()
|
||||||
|
ADD_TEST(dump-${filename_temp} ${EXECUTABLE_OUTPUT_PATH}/j2k_dump -i ${filename})
|
||||||
|
foreach(codec_type ppm pgx bmp tif raw tga png)
|
||||||
|
ADD_TEST(j2i-${filename_temp}-${codec_type} ${EXECUTABLE_OUTPUT_PATH}/j2k_to_image -i ${filename} -o ${filename_temp}.${codec_type})
|
||||||
|
endforeach(codec_type)
|
||||||
|
foreach(codec_type ppm bmp tif tga png)
|
||||||
|
ADD_TEST(i2j-${filename_temp}-${codec_type} ${EXECUTABLE_OUTPUT_PATH}/image_to_j2k -i ${filename_temp}.${codec_type} -o ${filename_temp}.${codec_type}${filename_ext})
|
||||||
|
SET_TESTS_PROPERTIES(i2j-${filename_temp}-${codec_type} PROPERTIES DEPENDS j2i-${filename_temp}-${codec_type})
|
||||||
|
#if(UNIX)
|
||||||
|
# ADD_TEST(cmp-${filename_temp}-${codec_type} cmp ${filename} ${filename_temp}.${codec_type}${filename_ext})
|
||||||
|
#endif(UNIX)
|
||||||
|
endforeach(codec_type)
|
||||||
|
endforeach(filename)
|
||||||
|
endif(BUILD_TESTING)
|
||||||
118
applications/codec/Makefile.am
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
||||||
|
bin_PROGRAMS = j2k_to_image image_to_j2k j2k_dump
|
||||||
|
|
||||||
|
if WANT_JPWL
|
||||||
|
bin_PROGRAMS += JPWL_j2k_to_image JPWL_image_to_j2k
|
||||||
|
endif
|
||||||
|
|
||||||
|
j2k_to_image_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/codec \
|
||||||
|
-I$(top_builddir)/applications/codec \
|
||||||
|
-I$(top_srcdir)/applications/common \
|
||||||
|
-I$(top_builddir)/applications/common \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg \
|
||||||
|
@PNG_CFLAGS@ \
|
||||||
|
@TIFF_CFLAGS@ \
|
||||||
|
@LCMS1_CFLAGS@ \
|
||||||
|
@LCMS2_CFLAGS@
|
||||||
|
j2k_to_image_CFLAGS =
|
||||||
|
j2k_to_image_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @LCMS1_LIBS@ @LCMS2_LIBS@ @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||||
|
j2k_to_image_SOURCES = \
|
||||||
|
../common/color.c \
|
||||||
|
../common/getopt.c \
|
||||||
|
convert.c \
|
||||||
|
index.c \
|
||||||
|
j2k_to_image.c \
|
||||||
|
../common/color.h
|
||||||
|
|
||||||
|
image_to_j2k_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/codec \
|
||||||
|
-I$(top_builddir)/applications/codec \
|
||||||
|
-I$(top_srcdir)/applications/common \
|
||||||
|
-I$(top_builddir)/applications/common \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg \
|
||||||
|
@PNG_CFLAGS@ \
|
||||||
|
@TIFF_CFLAGS@
|
||||||
|
image_to_j2k_CFLAGS =
|
||||||
|
image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||||
|
image_to_j2k_SOURCES = \
|
||||||
|
../common/getopt.c \
|
||||||
|
convert.c \
|
||||||
|
index.c \
|
||||||
|
image_to_j2k.c \
|
||||||
|
convert.h \
|
||||||
|
../common/format_defs.h \
|
||||||
|
index.h
|
||||||
|
|
||||||
|
j2k_dump_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/codec \
|
||||||
|
-I$(top_builddir)/applications/codec \
|
||||||
|
-I$(top_srcdir)/applications/common \
|
||||||
|
-I$(top_builddir)/applications/common \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg
|
||||||
|
j2k_dump_CFLAGS =
|
||||||
|
j2k_dump_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la -lm
|
||||||
|
j2k_dump_SOURCES = \
|
||||||
|
../common/getopt.c \
|
||||||
|
index.c \
|
||||||
|
j2k_dump.c \
|
||||||
|
../common/getopt.h \
|
||||||
|
index.h
|
||||||
|
|
||||||
|
JPWL_j2k_to_image_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/common \
|
||||||
|
-I$(top_builddir)/applications/common \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg \
|
||||||
|
-DUSE_JPWL \
|
||||||
|
@TIFF_CFLAGS@ \
|
||||||
|
@PNG_CFLAGS@ \
|
||||||
|
@LCMS1_CFLAGS@ \
|
||||||
|
@LCMS2_CFLAGS@
|
||||||
|
JPWL_j2k_to_image_CFLAGS =
|
||||||
|
JPWL_j2k_to_image_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @LCMS1_LIBS@ @LCMS2_LIBS@ @TIFF_LIBS@ @PNG_LIBS@
|
||||||
|
JPWL_j2k_to_image_SOURCES = \
|
||||||
|
../common/color.c \
|
||||||
|
../common/getopt.c \
|
||||||
|
index.c \
|
||||||
|
convert.c \
|
||||||
|
j2k_to_image.c
|
||||||
|
|
||||||
|
JPWL_image_to_j2k_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/common \
|
||||||
|
-I$(top_builddir)/applications/common \
|
||||||
|
-I$(top_srcdir)/libopenjpeg \
|
||||||
|
-I$(top_builddir)/libopenjpeg \
|
||||||
|
-DUSE_JPWL \
|
||||||
|
@TIFF_CFLAGS@ \
|
||||||
|
@PNG_CFLAGS@
|
||||||
|
JPWL_image_to_j2k_CFLAGS =
|
||||||
|
JPWL_image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @TIFF_LIBS@ @PNG_LIBS@
|
||||||
|
|
||||||
|
JPWL_image_to_j2k_SOURCES = \
|
||||||
|
..//common/getopt.c \
|
||||||
|
index.c \
|
||||||
|
convert.c \
|
||||||
|
image_to_j2k.c
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
CMakeLists.txt \
|
||||||
|
windirent.h
|
||||||
|
|
||||||
|
install-data-hook:
|
||||||
|
@echo -e " (B)\t$(bindir)/j2k_to_image$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||||
|
@echo -e " (B)\t$(bindir)/image_to_j2k$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||||
|
@echo -e " (B)\t$(bindir)/j2k_dump$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||||
|
if WANT_JPWL
|
||||||
|
@echo -e " (B)\t$(bindir)/JPWL_j2k_to_image$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||||
|
@echo -e " (B)\t$(bindir)/JPWL_image_to_j2k$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||||
|
endif
|
||||||
68
applications/codec/Makefile.nix
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
#codec Makefile
|
||||||
|
include ../config.nix
|
||||||
|
|
||||||
|
CFLAGS = -Wall
|
||||||
|
|
||||||
|
INSTALL_BIN = $(prefix)/bin
|
||||||
|
|
||||||
|
INCLUDE = -I.. -I. -I../libopenjpeg -I../common
|
||||||
|
USERLIBS = -lm
|
||||||
|
|
||||||
|
ifeq ($(WITH_TIFF),yes)
|
||||||
|
INCLUDE += $(TIFF_INCLUDE)
|
||||||
|
USERLIBS += $(TIFF_LIB)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(WITH_PNG),yes)
|
||||||
|
INCLUDE += $(PNG_INCLUDE)
|
||||||
|
USERLIBS += $(PNG_LIB)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(WITH_LCMS2),yes)
|
||||||
|
INCLUDE += $(LCMS2_INCLUDE)
|
||||||
|
USERLIBS += $(LCMS2_LIB)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(WITH_LCMS1),yes)
|
||||||
|
INCLUDE += $(LCMS1_INCLUDE)
|
||||||
|
USERLIBS += $(LCMS1_LIB)
|
||||||
|
endif
|
||||||
|
|
||||||
|
CFLAGS += $(INCLUDE) -lstdc++ # -g -p -pg
|
||||||
|
|
||||||
|
all: j2k_to_image image_to_j2k j2k_dump
|
||||||
|
install -d ../bin
|
||||||
|
install j2k_to_image image_to_j2k j2k_dump ../bin
|
||||||
|
|
||||||
|
ifeq ($(ENABLE_SHARED),yes)
|
||||||
|
ELIB = ../libopenjpeg.so.$(MAJOR).$(MINOR).$(BUILD)
|
||||||
|
else
|
||||||
|
ELIB = ../libopenjpeg.a
|
||||||
|
endif
|
||||||
|
|
||||||
|
j2k_to_image: j2k_to_image.c $(ELIB)
|
||||||
|
$(CC) $(CFLAGS) ../common/getopt.c index.c convert.c \
|
||||||
|
../common/color.c j2k_to_image.c \
|
||||||
|
-o j2k_to_image $(ELIB) $(USERLIBS)
|
||||||
|
|
||||||
|
image_to_j2k: image_to_j2k.c $(ELIB)
|
||||||
|
$(CC) $(CFLAGS) ../common/getopt.c index.c convert.c image_to_j2k.c \
|
||||||
|
-o image_to_j2k $(ELIB) $(USERLIBS)
|
||||||
|
|
||||||
|
j2k_dump: j2k_dump.c $(ELIB)
|
||||||
|
$(CC) $(CFLAGS) ../common/getopt.c index.c j2k_dump.c \
|
||||||
|
-o j2k_dump $(ELIB) $(USERLIBS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f j2k_to_image image_to_j2k j2k_dump
|
||||||
|
|
||||||
|
install: all
|
||||||
|
install -d $(DESTDIR)$(INSTALL_BIN)
|
||||||
|
install -m 755 -o root -g root j2k_to_image $(DESTDIR)$(INSTALL_BIN)
|
||||||
|
install -m 755 -o root -g root image_to_j2k $(DESTDIR)$(INSTALL_BIN)
|
||||||
|
install -m 755 -o root -g root j2k_dump $(DESTDIR)$(INSTALL_BIN)
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -f $(DESTDIR)$(INSTALL_BIN)/j2k_to_image
|
||||||
|
rm -f $(DESTDIR)$(INSTALL_BIN)/image_to_j2k
|
||||||
|
rm -f $(DESTDIR)$(INSTALL_BIN)/j2k_dump
|
||||||
8
applications/codec/README
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
Simple codec compilation
|
||||||
|
------------------------
|
||||||
|
Once you've built the library, you might want to test it with a basic codec. To do this, go to the codec directory and either use the provided Makefile or use one of the following commands to build an encoder and decoder respectively:
|
||||||
|
|
||||||
|
gcc index.c convert.c image_to_j2k.c -o image_to_j2k -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
|
||||||
|
gcc index.c convert.c j2k_to_image.c -o j2k_to_image -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
|
||||||
|
|
||||||
|
You should add '-L..' to those lines if you did not use the 'install' target when building the library.
|
||||||
@@ -43,15 +43,15 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define strcasecmp _stricmp
|
|
||||||
#define strncasecmp _strnicmp
|
|
||||||
#else
|
#else
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
#define _stricmp strcasecmp
|
||||||
|
#define _strnicmp strncasecmp
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#include "opj_config.h"
|
#include "opj_config.h"
|
||||||
#include "openjpeg.h"
|
#include "openjpeg.h"
|
||||||
#include "opj_getopt.h"
|
#include "getopt.h"
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
|
|
||||||
@@ -82,8 +82,8 @@ typedef struct img_folder{
|
|||||||
float *rates;
|
float *rates;
|
||||||
}img_fol_t;
|
}img_fol_t;
|
||||||
|
|
||||||
static void encode_help_display(void) {
|
void encode_help_display() {
|
||||||
fprintf(stdout,"HELP for opj_jpwl_compress\n----\n\n");
|
fprintf(stdout,"HELP for image_to_j2k\n----\n\n");
|
||||||
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||||
|
|
||||||
/* UniPG>> */
|
/* UniPG>> */
|
||||||
@@ -193,8 +193,6 @@ static void encode_help_display(void) {
|
|||||||
fprintf(stdout," Indicate multiple modes by adding their values. \n");
|
fprintf(stdout," Indicate multiple modes by adding their values. \n");
|
||||||
fprintf(stdout," ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
|
fprintf(stdout," ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
|
||||||
fprintf(stdout,"\n");
|
fprintf(stdout,"\n");
|
||||||
fprintf(stdout,"-TP : devide packets of every tile into tile-parts (-TP R) [R, L, C]\n");
|
|
||||||
fprintf(stdout,"\n");
|
|
||||||
fprintf(stdout,"-x : create an index file *.Idx (-x index_name.Idx) \n");
|
fprintf(stdout,"-x : create an index file *.Idx (-x index_name.Idx) \n");
|
||||||
fprintf(stdout,"\n");
|
fprintf(stdout,"\n");
|
||||||
fprintf(stdout,"-ROI : c=%%d,U=%%d : quantization indices upshifted \n");
|
fprintf(stdout,"-ROI : c=%%d,U=%%d : quantization indices upshifted \n");
|
||||||
@@ -211,9 +209,6 @@ static void encode_help_display(void) {
|
|||||||
fprintf(stdout," -F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
|
fprintf(stdout," -F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
|
||||||
fprintf(stdout," Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
|
fprintf(stdout," Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
|
||||||
fprintf(stdout,"\n");
|
fprintf(stdout,"\n");
|
||||||
fprintf(stdout,"-jpip : write jpip codestream index box in JP2 output file\n");
|
|
||||||
fprintf(stdout," NOTICE: currently supports only RPCL order\n");
|
|
||||||
fprintf(stdout,"\n");
|
|
||||||
/* UniPG>> */
|
/* UniPG>> */
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
fprintf(stdout,"-W : adoption of JPWL (Part 11) capabilities (-W params)\n");
|
fprintf(stdout,"-W : adoption of JPWL (Part 11) capabilities (-W params)\n");
|
||||||
@@ -321,7 +316,7 @@ static void encode_help_display(void) {
|
|||||||
fprintf(stdout,"TotalDisto\n\n");
|
fprintf(stdout,"TotalDisto\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static OPJ_PROG_ORDER give_progression(const char progression[4]) {
|
OPJ_PROG_ORDER give_progression(char progression[4]) {
|
||||||
if(strncmp(progression, "LRCP", 4) == 0) {
|
if(strncmp(progression, "LRCP", 4) == 0) {
|
||||||
return LRCP;
|
return LRCP;
|
||||||
}
|
}
|
||||||
@@ -341,10 +336,10 @@ static OPJ_PROG_ORDER give_progression(const char progression[4]) {
|
|||||||
return PROG_UNKNOWN;
|
return PROG_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int get_num_images(char *imgdirpath){
|
int get_num_images(char *imgdirpath){
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent* content;
|
struct dirent* content;
|
||||||
unsigned int num_images = 0;
|
int num_images = 0;
|
||||||
|
|
||||||
/*Reading the input images from given input directory*/
|
/*Reading the input images from given input directory*/
|
||||||
|
|
||||||
@@ -363,7 +358,7 @@ static unsigned int get_num_images(char *imgdirpath){
|
|||||||
return num_images;
|
return num_images;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int load_images(dircnt_t *dirptr, char *imgdirpath){
|
int load_images(dircnt_t *dirptr, char *imgdirpath){
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent* content;
|
struct dirent* content;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -388,7 +383,7 @@ static int load_images(dircnt_t *dirptr, char *imgdirpath){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_file_format(char *filename) {
|
int get_file_format(char *filename) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
static const char *extension[] = {
|
static const char *extension[] = {
|
||||||
"pgx", "pnm", "pgm", "ppm", "pbm", "pam", "bmp", "tif", "raw", "tga", "png", "j2k", "jp2", "j2c", "jpc"
|
"pgx", "pnm", "pgm", "ppm", "pbm", "pam", "bmp", "tif", "raw", "tga", "png", "j2k", "jp2", "j2c", "jpc"
|
||||||
@@ -401,21 +396,21 @@ static int get_file_format(char *filename) {
|
|||||||
return -1;
|
return -1;
|
||||||
ext++;
|
ext++;
|
||||||
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
||||||
if(strcasecmp(ext, extension[i]) == 0) {
|
if(_strnicmp(ext, extension[i], 3) == 0) {
|
||||||
return format[i];
|
return format[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char * get_file_name(char *name){
|
char * get_file_name(char *name){
|
||||||
char *fname;
|
char *fname;
|
||||||
fname= (char*)malloc(OPJ_PATH_LEN*sizeof(char));
|
fname= (char*)malloc(OPJ_PATH_LEN*sizeof(char));
|
||||||
fname= strtok(name,".");
|
fname= strtok(name,".");
|
||||||
return fname;
|
return fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_cparameters_t *parameters){
|
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_cparameters_t *parameters){
|
||||||
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
|
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
|
||||||
char *temp_p, temp1[OPJ_PATH_LEN]="";
|
char *temp_p, temp1[OPJ_PATH_LEN]="";
|
||||||
|
|
||||||
@@ -427,7 +422,7 @@ static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_c
|
|||||||
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
|
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
|
||||||
strncpy(parameters->infile, infilename, sizeof(infilename));
|
strncpy(parameters->infile, infilename, sizeof(infilename));
|
||||||
|
|
||||||
/*Set output file*/
|
//Set output file
|
||||||
strcpy(temp_ofname,get_file_name(image_filename));
|
strcpy(temp_ofname,get_file_name(image_filename));
|
||||||
while((temp_p = strtok(NULL,".")) != NULL){
|
while((temp_p = strtok(NULL,".")) != NULL){
|
||||||
strcat(temp_ofname,temp1);
|
strcat(temp_ofname,temp1);
|
||||||
@@ -458,7 +453,7 @@ static int initialise_4K_poc(opj_poc_t *POC, int numres){
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cinema_parameters(opj_cparameters_t *parameters){
|
void cinema_parameters(opj_cparameters_t *parameters){
|
||||||
parameters->tile_size_on = OPJ_FALSE;
|
parameters->tile_size_on = OPJ_FALSE;
|
||||||
parameters->cp_tdx=1;
|
parameters->cp_tdx=1;
|
||||||
parameters->cp_tdy=1;
|
parameters->cp_tdy=1;
|
||||||
@@ -491,7 +486,7 @@ static void cinema_parameters(opj_cparameters_t *parameters){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol){
|
void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol){
|
||||||
int i;
|
int i;
|
||||||
float temp_rate;
|
float temp_rate;
|
||||||
|
|
||||||
@@ -576,24 +571,23 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *imag
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------------------ */
|
||||||
|
|
||||||
static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
img_fol_t *img_fol, raw_cparameters_t *raw_cp, char *indexfilename) {
|
img_fol_t *img_fol, raw_cparameters_t *raw_cp, char *indexfilename) {
|
||||||
int i, j, totlen, c;
|
int i, j,totlen;
|
||||||
opj_option_t long_option[]={
|
option_t long_option[]={
|
||||||
{"cinema2K",REQ_ARG, NULL ,'w'},
|
{"cinema2K",REQ_ARG, NULL ,'w'},
|
||||||
{"cinema4K",NO_ARG, NULL ,'y'},
|
{"cinema4K",NO_ARG, NULL ,'y'},
|
||||||
{"ImgDir",REQ_ARG, NULL ,'z'},
|
{"ImgDir",REQ_ARG, NULL ,'z'},
|
||||||
{"TP",REQ_ARG, NULL ,'u'},
|
{"TP",REQ_ARG, NULL ,'v'},
|
||||||
{"SOP",NO_ARG, NULL ,'S'},
|
{"SOP",NO_ARG, NULL ,'S'},
|
||||||
{"EPH",NO_ARG, NULL ,'E'},
|
{"EPH",NO_ARG, NULL ,'E'},
|
||||||
{"OutFor",REQ_ARG, NULL ,'O'},
|
{"OutFor",REQ_ARG, NULL ,'O'},
|
||||||
{"POC",REQ_ARG, NULL ,'P'},
|
{"POC",REQ_ARG, NULL ,'P'},
|
||||||
{"ROI",REQ_ARG, NULL ,'R'},
|
{"ROI",REQ_ARG, NULL ,'R'},
|
||||||
{"jpip",NO_ARG, NULL, 'J'}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* parse the command line */
|
/* parse the command line */
|
||||||
const char optlist[] = "i:o:r:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:F:u:J"
|
const char optlist[] = "i:o:r:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:F:"
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
"W:"
|
"W:"
|
||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
@@ -603,14 +597,14 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
img_fol->set_out_format=0;
|
img_fol->set_out_format=0;
|
||||||
raw_cp->rawWidth = 0;
|
raw_cp->rawWidth = 0;
|
||||||
|
|
||||||
do{
|
while (1) {
|
||||||
c = opj_getopt_long(argc, argv, optlist,long_option,totlen);
|
int c = getopt_long(argc, argv, optlist,long_option,totlen);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'i': /* input file */
|
case 'i': /* input file */
|
||||||
{
|
{
|
||||||
char *infile = opj_optarg;
|
char *infile = optarg;
|
||||||
parameters->decod_format = get_file_format(infile);
|
parameters->decod_format = get_file_format(infile);
|
||||||
switch(parameters->decod_format) {
|
switch(parameters->decod_format) {
|
||||||
case PGX_DFMT:
|
case PGX_DFMT:
|
||||||
@@ -636,7 +630,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'o': /* output file */
|
case 'o': /* output file */
|
||||||
{
|
{
|
||||||
char *outfile = opj_optarg;
|
char *outfile = optarg;
|
||||||
parameters->cod_format = get_file_format(outfile);
|
parameters->cod_format = get_file_format(outfile);
|
||||||
switch(parameters->cod_format) {
|
switch(parameters->cod_format) {
|
||||||
case J2K_CFMT:
|
case J2K_CFMT:
|
||||||
@@ -654,14 +648,14 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
case 'O': /* output format */
|
case 'O': /* output format */
|
||||||
{
|
{
|
||||||
char outformat[50];
|
char outformat[50];
|
||||||
char *of = opj_optarg;
|
char *of = optarg;
|
||||||
sprintf(outformat,".%s",of);
|
sprintf(outformat,".%s",of);
|
||||||
img_fol->set_out_format = 1;
|
img_fol->set_out_format = 1;
|
||||||
parameters->cod_format = get_file_format(outformat);
|
parameters->cod_format = get_file_format(outformat);
|
||||||
switch(parameters->cod_format) {
|
switch(parameters->cod_format) {
|
||||||
case J2K_CFMT:
|
case J2K_CFMT:
|
||||||
case JP2_CFMT:
|
case JP2_CFMT:
|
||||||
img_fol->out_format = opj_optarg;
|
img_fol->out_format = optarg;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unknown output format image [only j2k, j2c, jp2]!! \n");
|
fprintf(stderr, "Unknown output format image [only j2k, j2c, jp2]!! \n");
|
||||||
@@ -676,7 +670,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'r': /* rates rates/distorsion */
|
case 'r': /* rates rates/distorsion */
|
||||||
{
|
{
|
||||||
char *s = opj_optarg;
|
char *s = optarg;
|
||||||
parameters->tcp_numlayers = 0;
|
parameters->tcp_numlayers = 0;
|
||||||
while (sscanf(s, "%f", ¶meters->tcp_rates[parameters->tcp_numlayers]) == 1) {
|
while (sscanf(s, "%f", ¶meters->tcp_rates[parameters->tcp_numlayers]) == 1) {
|
||||||
parameters->tcp_numlayers++;
|
parameters->tcp_numlayers++;
|
||||||
@@ -697,7 +691,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
case 'F': /* Raw image format parameters */
|
case 'F': /* Raw image format parameters */
|
||||||
{
|
{
|
||||||
char signo;
|
char signo;
|
||||||
char *s = opj_optarg;
|
char *s = optarg;
|
||||||
if (sscanf(s, "%d,%d,%d,%d,%c", &raw_cp->rawWidth, &raw_cp->rawHeight, &raw_cp->rawComp, &raw_cp->rawBitDepth, &signo) == 5) {
|
if (sscanf(s, "%d,%d,%d,%d,%c", &raw_cp->rawWidth, &raw_cp->rawHeight, &raw_cp->rawComp, &raw_cp->rawBitDepth, &signo) == 5) {
|
||||||
if (signo == 's') {
|
if (signo == 's') {
|
||||||
raw_cp->rawSigned = OPJ_TRUE;
|
raw_cp->rawSigned = OPJ_TRUE;
|
||||||
@@ -730,7 +724,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'q': /* add fixed_quality */
|
case 'q': /* add fixed_quality */
|
||||||
{
|
{
|
||||||
char *s = opj_optarg;
|
char *s = optarg;
|
||||||
while (sscanf(s, "%f", ¶meters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
|
while (sscanf(s, "%f", ¶meters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
|
||||||
parameters->tcp_numlayers++;
|
parameters->tcp_numlayers++;
|
||||||
while (*s && *s != ',') {
|
while (*s && *s != ',') {
|
||||||
@@ -752,7 +746,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
int *row = NULL, *col = NULL;
|
int *row = NULL, *col = NULL;
|
||||||
int numlayers = 0, numresolution = 0, matrix_width = 0;
|
int numlayers = 0, numresolution = 0, matrix_width = 0;
|
||||||
|
|
||||||
char *s = opj_optarg;
|
char *s = optarg;
|
||||||
sscanf(s, "%d", &numlayers);
|
sscanf(s, "%d", &numlayers);
|
||||||
s++;
|
s++;
|
||||||
if (numlayers > 9)
|
if (numlayers > 9)
|
||||||
@@ -796,7 +790,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 't': /* tiles */
|
case 't': /* tiles */
|
||||||
{
|
{
|
||||||
sscanf(opj_optarg, "%d,%d", ¶meters->cp_tdx, ¶meters->cp_tdy);
|
sscanf(optarg, "%d,%d", ¶meters->cp_tdx, ¶meters->cp_tdy);
|
||||||
parameters->tile_size_on = OPJ_TRUE;
|
parameters->tile_size_on = OPJ_TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -805,7 +799,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'n': /* resolution */
|
case 'n': /* resolution */
|
||||||
{
|
{
|
||||||
sscanf(opj_optarg, "%d", ¶meters->numresolution);
|
sscanf(optarg, "%d", ¶meters->numresolution);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -815,7 +809,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
char sep;
|
char sep;
|
||||||
int res_spec = 0;
|
int res_spec = 0;
|
||||||
|
|
||||||
char *s = opj_optarg;
|
char *s = optarg;
|
||||||
do {
|
do {
|
||||||
sep = 0;
|
sep = 0;
|
||||||
sscanf(s, "[%d,%d]%c", ¶meters->prcw_init[res_spec],
|
sscanf(s, "[%d,%d]%c", ¶meters->prcw_init[res_spec],
|
||||||
@@ -834,7 +828,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
case 'b': /* code-block dimension */
|
case 'b': /* code-block dimension */
|
||||||
{
|
{
|
||||||
int cblockw_init = 0, cblockh_init = 0;
|
int cblockw_init = 0, cblockh_init = 0;
|
||||||
sscanf(opj_optarg, "%d,%d", &cblockw_init, &cblockh_init);
|
sscanf(optarg, "%d,%d", &cblockw_init, &cblockh_init);
|
||||||
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|
||||||
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
|
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@@ -851,7 +845,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'x': /* creation of index file */
|
case 'x': /* creation of index file */
|
||||||
{
|
{
|
||||||
char *index = opj_optarg;
|
char *index = optarg;
|
||||||
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -862,7 +856,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
{
|
{
|
||||||
char progression[4];
|
char progression[4];
|
||||||
|
|
||||||
strncpy(progression, opj_optarg, 4);
|
strncpy(progression, optarg, 4);
|
||||||
parameters->prog_order = give_progression(progression);
|
parameters->prog_order = give_progression(progression);
|
||||||
if (parameters->prog_order == -1) {
|
if (parameters->prog_order == -1) {
|
||||||
fprintf(stderr, "Unrecognized progression order "
|
fprintf(stderr, "Unrecognized progression order "
|
||||||
@@ -876,7 +870,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 's': /* subsampling factor */
|
case 's': /* subsampling factor */
|
||||||
{
|
{
|
||||||
if (sscanf(opj_optarg, "%d,%d", ¶meters->subsampling_dx,
|
if (sscanf(optarg, "%d,%d", ¶meters->subsampling_dx,
|
||||||
¶meters->subsampling_dy) != 2) {
|
¶meters->subsampling_dy) != 2) {
|
||||||
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
|
fprintf(stderr, "'-s' sub-sampling argument error ! [-s dx,dy]\n");
|
||||||
return 1;
|
return 1;
|
||||||
@@ -888,7 +882,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'd': /* coordonnate of the reference grid */
|
case 'd': /* coordonnate of the reference grid */
|
||||||
{
|
{
|
||||||
if (sscanf(opj_optarg, "%d,%d", ¶meters->image_offset_x0,
|
if (sscanf(optarg, "%d,%d", ¶meters->image_offset_x0,
|
||||||
¶meters->image_offset_y0) != 2) {
|
¶meters->image_offset_y0) != 2) {
|
||||||
fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
|
fprintf(stderr, "-d 'coordonnate of the reference grid' argument "
|
||||||
"error !! [-d x0,y0]\n");
|
"error !! [-d x0,y0]\n");
|
||||||
@@ -910,7 +904,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
int numpocs = 0; /* number of progression order change (POC) default 0 */
|
int numpocs = 0; /* number of progression order change (POC) default 0 */
|
||||||
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
|
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
|
||||||
|
|
||||||
char *s = opj_optarg;
|
char *s = optarg;
|
||||||
POC = parameters->POC;
|
POC = parameters->POC;
|
||||||
|
|
||||||
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
|
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
|
||||||
@@ -952,7 +946,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
case 'M': /* Mode switch pas tous au point !! */
|
case 'M': /* Mode switch pas tous au point !! */
|
||||||
{
|
{
|
||||||
int value = 0;
|
int value = 0;
|
||||||
if (sscanf(opj_optarg, "%d", &value) == 1) {
|
if (sscanf(optarg, "%d", &value) == 1) {
|
||||||
for (i = 0; i <= 5; i++) {
|
for (i = 0; i <= 5; i++) {
|
||||||
int cache = value & (1 << i);
|
int cache = value & (1 << i);
|
||||||
if (cache)
|
if (cache)
|
||||||
@@ -966,7 +960,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'R': /* ROI */
|
case 'R': /* ROI */
|
||||||
{
|
{
|
||||||
if (sscanf(opj_optarg, "c=%d,U=%d", ¶meters->roi_compno,
|
if (sscanf(optarg, "c=%d,U=%d", ¶meters->roi_compno,
|
||||||
¶meters->roi_shift) != 2) {
|
¶meters->roi_shift) != 2) {
|
||||||
fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n");
|
fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n");
|
||||||
return 1;
|
return 1;
|
||||||
@@ -978,7 +972,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'T': /* Tile offset */
|
case 'T': /* Tile offset */
|
||||||
{
|
{
|
||||||
if (sscanf(opj_optarg, "%d,%d", ¶meters->cp_tx0, ¶meters->cp_ty0) != 2) {
|
if (sscanf(optarg, "%d,%d", ¶meters->cp_tx0, ¶meters->cp_ty0) != 2) {
|
||||||
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
|
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -989,9 +983,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'C': /* add a comment */
|
case 'C': /* add a comment */
|
||||||
{
|
{
|
||||||
parameters->cp_comment = (char*)malloc(strlen(opj_optarg) + 1);
|
parameters->cp_comment = (char*)malloc(strlen(optarg) + 1);
|
||||||
if(parameters->cp_comment) {
|
if(parameters->cp_comment) {
|
||||||
strcpy(parameters->cp_comment, opj_optarg);
|
strcpy(parameters->cp_comment, optarg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1007,9 +1001,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
case 'u': /* Tile part generation*/
|
case 'v': /* Tile part generation*/
|
||||||
{
|
{
|
||||||
parameters->tp_flag = opj_optarg[0];
|
parameters->tp_flag = optarg[0];
|
||||||
parameters->tp_on = 1;
|
parameters->tp_on = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1018,8 +1012,8 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
|
|
||||||
case 'z': /* Image Directory path */
|
case 'z': /* Image Directory path */
|
||||||
{
|
{
|
||||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
|
||||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
strcpy(img_fol->imgdirpath,optarg);
|
||||||
img_fol->set_imgdir=1;
|
img_fol->set_imgdir=1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1029,7 +1023,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
case 'w': /* Digital Cinema 2K profile compliance*/
|
case 'w': /* Digital Cinema 2K profile compliance*/
|
||||||
{
|
{
|
||||||
int fps=0;
|
int fps=0;
|
||||||
sscanf(opj_optarg,"%d",&fps);
|
sscanf(optarg,"%d",&fps);
|
||||||
if(fps == 24){
|
if(fps == 24){
|
||||||
parameters->cp_cinema = CINEMA2K_24;
|
parameters->cp_cinema = CINEMA2K_24;
|
||||||
}else if(fps == 48 ){
|
}else if(fps == 48 ){
|
||||||
@@ -1073,7 +1067,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
/* search for different protection methods */
|
/* search for different protection methods */
|
||||||
|
|
||||||
/* break the option in comma points and parse the result */
|
/* break the option in comma points and parse the result */
|
||||||
token = strtok(opj_optarg, ",");
|
token = strtok(optarg, ",");
|
||||||
while(token != NULL) {
|
while(token != NULL) {
|
||||||
|
|
||||||
/* search header error protection method */
|
/* search header error protection method */
|
||||||
@@ -1375,21 +1369,14 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
break;
|
break;
|
||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
/* <<UniPG */
|
/* <<UniPG */
|
||||||
/* ------------------------------------------------------ */
|
|
||||||
|
|
||||||
case 'J': /* jpip on */
|
|
||||||
{
|
|
||||||
/*parameters->jpip_on = OPJ_TRUE;*/
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "ERROR -> Command line not valid\n");
|
fprintf(stderr, "ERROR -> Command line not valid\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}while(c != -1);
|
}
|
||||||
|
|
||||||
/* check for possible errors */
|
/* check for possible errors */
|
||||||
if (parameters->cp_cinema){
|
if (parameters->cp_cinema){
|
||||||
@@ -1466,21 +1453,21 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
|||||||
/**
|
/**
|
||||||
sample error callback expecting a FILE* client object
|
sample error callback expecting a FILE* client object
|
||||||
*/
|
*/
|
||||||
static void error_callback(const char *msg, void *client_data) {
|
void error_callback(const char *msg, void *client_data) {
|
||||||
FILE *stream = (FILE*)client_data;
|
FILE *stream = (FILE*)client_data;
|
||||||
fprintf(stream, "[ERROR] %s", msg);
|
fprintf(stream, "[ERROR] %s", msg);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
sample warning callback expecting a FILE* client object
|
sample warning callback expecting a FILE* client object
|
||||||
*/
|
*/
|
||||||
static void warning_callback(const char *msg, void *client_data) {
|
void warning_callback(const char *msg, void *client_data) {
|
||||||
FILE *stream = (FILE*)client_data;
|
FILE *stream = (FILE*)client_data;
|
||||||
fprintf(stream, "[WARNING] %s", msg);
|
fprintf(stream, "[WARNING] %s", msg);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
sample debug callback expecting a FILE* client object
|
sample debug callback expecting a FILE* client object
|
||||||
*/
|
*/
|
||||||
static void info_callback(const char *msg, void *client_data) {
|
void info_callback(const char *msg, void *client_data) {
|
||||||
FILE *stream = (FILE*)client_data;
|
FILE *stream = (FILE*)client_data;
|
||||||
fprintf(stream, "[INFO] %s", msg);
|
fprintf(stream, "[INFO] %s", msg);
|
||||||
}
|
}
|
||||||
@@ -1495,7 +1482,7 @@ int main(int argc, char **argv) {
|
|||||||
opj_image_t *image = NULL;
|
opj_image_t *image = NULL;
|
||||||
int i,num_images;
|
int i,num_images;
|
||||||
int imageno;
|
int imageno;
|
||||||
dircnt_t *dirptr = NULL;
|
dircnt_t *dirptr;
|
||||||
raw_cparameters_t raw_cp;
|
raw_cparameters_t raw_cp;
|
||||||
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
||||||
char indexfilename[OPJ_PATH_LEN]; /* index file name */
|
char indexfilename[OPJ_PATH_LEN]; /* index file name */
|
||||||
@@ -1550,7 +1537,7 @@ int main(int argc, char **argv) {
|
|||||||
num_images=get_num_images(img_fol.imgdirpath);
|
num_images=get_num_images(img_fol.imgdirpath);
|
||||||
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
||||||
if(dirptr){
|
if(dirptr){
|
||||||
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); // Stores at max 10 image file names
|
||||||
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
|
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
|
||||||
if(!dirptr->filename_buf){
|
if(!dirptr->filename_buf){
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1681,7 +1668,6 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
if (parameters.cod_format == J2K_CFMT) { /* J2K format output */
|
if (parameters.cod_format == J2K_CFMT) { /* J2K format output */
|
||||||
int codestream_length;
|
int codestream_length;
|
||||||
size_t res;
|
|
||||||
opj_cio_t *cio = NULL;
|
opj_cio_t *cio = NULL;
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
|
|
||||||
@@ -1699,8 +1685,8 @@ int main(int argc, char **argv) {
|
|||||||
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
|
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
|
||||||
|
|
||||||
/* encode the image */
|
/* encode the image */
|
||||||
if (*indexfilename) /* If need to extract codestream information*/
|
if (*indexfilename) // If need to extract codestream information
|
||||||
bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
|
bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
|
||||||
else
|
else
|
||||||
bSuccess = opj_encode(cinfo, cio, image, NULL);
|
bSuccess = opj_encode(cinfo, cio, image, NULL);
|
||||||
if (!bSuccess) {
|
if (!bSuccess) {
|
||||||
@@ -1716,11 +1702,7 @@ int main(int argc, char **argv) {
|
|||||||
fprintf(stderr, "failed to open %s for writing\n", parameters.outfile);
|
fprintf(stderr, "failed to open %s for writing\n", parameters.outfile);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
res = fwrite(cio->buffer, 1, codestream_length, f);
|
fwrite(cio->buffer, 1, codestream_length, f);
|
||||||
if( res < (size_t)codestream_length ) { /* FIXME */
|
|
||||||
fprintf(stderr, "failed to write %d (%s)\n", codestream_length, parameters.outfile);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
|
fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
|
||||||
@@ -1741,13 +1723,11 @@ int main(int argc, char **argv) {
|
|||||||
opj_destroy_cstr_info(&cstr_info);
|
opj_destroy_cstr_info(&cstr_info);
|
||||||
} else { /* JP2 format output */
|
} else { /* JP2 format output */
|
||||||
int codestream_length;
|
int codestream_length;
|
||||||
size_t res;
|
|
||||||
opj_cio_t *cio = NULL;
|
opj_cio_t *cio = NULL;
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
opj_cinfo_t *cinfo = NULL;
|
|
||||||
|
|
||||||
/* get a JP2 compressor handle */
|
/* get a JP2 compressor handle */
|
||||||
cinfo = opj_create_compress(CODEC_JP2);
|
opj_cinfo_t* cinfo = opj_create_compress(CODEC_JP2);
|
||||||
|
|
||||||
/* catch events using our callbacks and give a local context */
|
/* catch events using our callbacks and give a local context */
|
||||||
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
|
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
|
||||||
@@ -1760,8 +1740,8 @@ int main(int argc, char **argv) {
|
|||||||
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
|
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
|
||||||
|
|
||||||
/* encode the image */
|
/* encode the image */
|
||||||
if (*indexfilename /*|| parameters.jpip_on*/) /* If need to extract codestream information*/
|
if (*indexfilename) // If need to extract codestream information
|
||||||
bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
|
bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
|
||||||
else
|
else
|
||||||
bSuccess = opj_encode(cinfo, cio, image, NULL);
|
bSuccess = opj_encode(cinfo, cio, image, NULL);
|
||||||
if (!bSuccess) {
|
if (!bSuccess) {
|
||||||
@@ -1777,11 +1757,7 @@ int main(int argc, char **argv) {
|
|||||||
fprintf(stderr, "failed to open %s for writing\n", parameters.outfile);
|
fprintf(stderr, "failed to open %s for writing\n", parameters.outfile);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
res = fwrite(cio->buffer, 1, codestream_length, f);
|
fwrite(cio->buffer, 1, codestream_length, f);
|
||||||
if( res < (size_t)codestream_length ) { /* FIXME */
|
|
||||||
fprintf(stderr, "failed to write %d (%s)\n", codestream_length, parameters.outfile);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
|
fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
|
||||||
/* close and free the byte stream */
|
/* close and free the byte stream */
|
||||||
@@ -260,7 +260,7 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
|||||||
int x1 = x0 + cstr_info->tile_x;
|
int x1 = x0 + cstr_info->tile_x;
|
||||||
int y1 = y0 + cstr_info->tile_y;
|
int y1 = y0 + cstr_info->tile_y;
|
||||||
|
|
||||||
/* Count the maximum number of precincts */
|
// Count the maximum number of precincts
|
||||||
int max_numprec = 0;
|
int max_numprec = 0;
|
||||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||||
@@ -311,7 +311,7 @@ int write_index_file(opj_codestream_info_t *cstr_info, char *index) {
|
|||||||
} /* PCRL */
|
} /* PCRL */
|
||||||
|
|
||||||
else { /* CPRL */
|
else { /* CPRL */
|
||||||
/* Count the maximum number of precincts */
|
// Count the maximum number of precincts
|
||||||
int max_numprec = 0;
|
int max_numprec = 0;
|
||||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||||
634
applications/codec/j2k_dump.c
Normal file
@@ -0,0 +1,634 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 20010, Mathieu Malaterre, GDCM
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "windirent.h"
|
||||||
|
#else
|
||||||
|
#include <dirent.h>
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#include <strings.h>
|
||||||
|
#define _stricmp strcasecmp
|
||||||
|
#define _strnicmp strncasecmp
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
#include "opj_config.h"
|
||||||
|
#include "openjpeg.h"
|
||||||
|
#include "j2k.h"
|
||||||
|
#include "jp2.h"
|
||||||
|
#include "getopt.h"
|
||||||
|
#include "convert.h"
|
||||||
|
#include "index.h"
|
||||||
|
|
||||||
|
#include "format_defs.h"
|
||||||
|
|
||||||
|
typedef struct dircnt{
|
||||||
|
/** Buffer for holding images read from Directory*/
|
||||||
|
char *filename_buf;
|
||||||
|
/** Pointer to the buffer*/
|
||||||
|
char **filename;
|
||||||
|
}dircnt_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct img_folder{
|
||||||
|
/** The directory path of the folder containing input images*/
|
||||||
|
char *imgdirpath;
|
||||||
|
/** Output format*/
|
||||||
|
const char *out_format;
|
||||||
|
/** Enable option*/
|
||||||
|
char set_imgdir;
|
||||||
|
/** Enable Cod Format for output*/
|
||||||
|
char set_out_format;
|
||||||
|
|
||||||
|
}img_fol_t;
|
||||||
|
|
||||||
|
void decode_help_display() {
|
||||||
|
fprintf(stdout,"HELP for j2k_dump\n----\n\n");
|
||||||
|
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||||
|
|
||||||
|
/* UniPG>> */
|
||||||
|
fprintf(stdout,"List of parameters for the JPEG 2000 "
|
||||||
|
#ifdef USE_JPWL
|
||||||
|
"+ JPWL "
|
||||||
|
#endif /* USE_JPWL */
|
||||||
|
"decoder:\n");
|
||||||
|
/* <<UniPG */
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
fprintf(stdout," -ImgDir \n");
|
||||||
|
fprintf(stdout," Image file Directory path \n");
|
||||||
|
fprintf(stdout," -i <compressed file>\n");
|
||||||
|
fprintf(stdout," REQUIRED only if an Input image directory not specified\n");
|
||||||
|
fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
|
||||||
|
fprintf(stdout," is identified based on its suffix.\n");
|
||||||
|
fprintf(stdout,"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
static void j2k_dump_image(FILE *fd, opj_image_t * img);
|
||||||
|
static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp);
|
||||||
|
|
||||||
|
int get_num_images(char *imgdirpath){
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent* content;
|
||||||
|
int num_images = 0;
|
||||||
|
|
||||||
|
/*Reading the input images from given input directory*/
|
||||||
|
|
||||||
|
dir= opendir(imgdirpath);
|
||||||
|
if(!dir){
|
||||||
|
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
while((content=readdir(dir))!=NULL){
|
||||||
|
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
|
||||||
|
continue;
|
||||||
|
num_images++;
|
||||||
|
}
|
||||||
|
return num_images;
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_images(dircnt_t *dirptr, char *imgdirpath){
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent* content;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
/*Reading the input images from given input directory*/
|
||||||
|
|
||||||
|
dir= opendir(imgdirpath);
|
||||||
|
if(!dir){
|
||||||
|
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
|
||||||
|
return 1;
|
||||||
|
}else {
|
||||||
|
fprintf(stderr,"Folder opened successfully\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
while((content=readdir(dir))!=NULL){
|
||||||
|
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
strcpy(dirptr->filename[i],content->d_name);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_file_format(char *filename) {
|
||||||
|
unsigned int i;
|
||||||
|
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
|
||||||
|
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
|
||||||
|
char * ext = strrchr(filename, '.');
|
||||||
|
if (ext == NULL)
|
||||||
|
return -1;
|
||||||
|
ext++;
|
||||||
|
if(ext) {
|
||||||
|
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
||||||
|
if(_strnicmp(ext, extension[i], 3) == 0) {
|
||||||
|
return format[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
|
||||||
|
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
|
||||||
|
char *temp_p, temp1[OPJ_PATH_LEN]="";
|
||||||
|
|
||||||
|
strcpy(image_filename,dirptr->filename[imageno]);
|
||||||
|
fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
|
||||||
|
parameters->decod_format = get_file_format(image_filename);
|
||||||
|
if (parameters->decod_format == -1)
|
||||||
|
return 1;
|
||||||
|
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
|
||||||
|
strncpy(parameters->infile, infilename, sizeof(infilename));
|
||||||
|
|
||||||
|
//Set output file
|
||||||
|
strcpy(temp_ofname,strtok(image_filename,"."));
|
||||||
|
while((temp_p = strtok(NULL,".")) != NULL){
|
||||||
|
strcat(temp_ofname,temp1);
|
||||||
|
sprintf(temp1,".%s",temp_p);
|
||||||
|
}
|
||||||
|
if(img_fol->set_out_format==1){
|
||||||
|
sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
|
||||||
|
strncpy(parameters->outfile, outfilename, sizeof(outfilename));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
|
||||||
|
/* parse the command line */
|
||||||
|
int totlen;
|
||||||
|
option_t long_option[]={
|
||||||
|
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||||
|
};
|
||||||
|
|
||||||
|
const char optlist[] = "i:h";
|
||||||
|
totlen=sizeof(long_option);
|
||||||
|
img_fol->set_out_format = 0;
|
||||||
|
while (1) {
|
||||||
|
int c = getopt_long(argc, argv,optlist,long_option,totlen);
|
||||||
|
if (c == -1)
|
||||||
|
break;
|
||||||
|
switch (c) {
|
||||||
|
case 'i': /* input file */
|
||||||
|
{
|
||||||
|
char *infile = optarg;
|
||||||
|
parameters->decod_format = get_file_format(infile);
|
||||||
|
switch(parameters->decod_format) {
|
||||||
|
case J2K_CFMT:
|
||||||
|
case JP2_CFMT:
|
||||||
|
case JPT_CFMT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr,
|
||||||
|
"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
|
||||||
|
infile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
case 'h': /* display an help description */
|
||||||
|
decode_help_display();
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'y': /* Image Directory path */
|
||||||
|
{
|
||||||
|
img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
|
||||||
|
strcpy(img_fol->imgdirpath,optarg);
|
||||||
|
img_fol->set_imgdir=1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check for possible errors */
|
||||||
|
if(img_fol->set_imgdir==1){
|
||||||
|
if(!(parameters->infile[0]==0)){
|
||||||
|
fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(img_fol->set_out_format == 0){
|
||||||
|
fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
|
||||||
|
fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(!((parameters->outfile[0] == 0))){
|
||||||
|
fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if((parameters->infile[0] == 0) ) {
|
||||||
|
fprintf(stderr, "Example: %s -i image.j2k\n",argv[0]);
|
||||||
|
fprintf(stderr, " Try: %s -h\n",argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
sample error callback expecting a FILE* client object
|
||||||
|
*/
|
||||||
|
void error_callback(const char *msg, void *client_data) {
|
||||||
|
FILE *stream = (FILE*)client_data;
|
||||||
|
fprintf(stream, "[ERROR] %s", msg);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
sample warning callback expecting a FILE* client object
|
||||||
|
*/
|
||||||
|
void warning_callback(const char *msg, void *client_data) {
|
||||||
|
FILE *stream = (FILE*)client_data;
|
||||||
|
fprintf(stream, "[WARNING] %s", msg);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
sample debug callback expecting no client object
|
||||||
|
*/
|
||||||
|
void info_callback(const char *msg, void *client_data) {
|
||||||
|
(void)client_data;
|
||||||
|
fprintf(stdout, "[INFO] %s", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
opj_dparameters_t parameters; /* decompression parameters */
|
||||||
|
img_fol_t img_fol;
|
||||||
|
opj_event_mgr_t event_mgr; /* event manager */
|
||||||
|
opj_image_t *image = NULL;
|
||||||
|
FILE *fsrc = NULL;
|
||||||
|
unsigned char *src = NULL;
|
||||||
|
int file_length;
|
||||||
|
int num_images;
|
||||||
|
int i,imageno;
|
||||||
|
dircnt_t *dirptr = NULL;
|
||||||
|
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
|
||||||
|
opj_cio_t *cio = NULL;
|
||||||
|
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
||||||
|
char indexfilename[OPJ_PATH_LEN]; /* index file name */
|
||||||
|
|
||||||
|
/* configure the event callbacks (not required) */
|
||||||
|
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||||
|
event_mgr.error_handler = error_callback;
|
||||||
|
event_mgr.warning_handler = warning_callback;
|
||||||
|
event_mgr.info_handler = info_callback;
|
||||||
|
|
||||||
|
/* set decoding parameters to default values */
|
||||||
|
opj_set_default_decoder_parameters(¶meters);
|
||||||
|
|
||||||
|
/* Initialize indexfilename and img_fol */
|
||||||
|
*indexfilename = 0;
|
||||||
|
memset(&img_fol,0,sizeof(img_fol_t));
|
||||||
|
|
||||||
|
/* parse input and get user encoding parameters */
|
||||||
|
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize reading of directory */
|
||||||
|
if(img_fol.set_imgdir==1){
|
||||||
|
num_images=get_num_images(img_fol.imgdirpath);
|
||||||
|
|
||||||
|
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
||||||
|
if(dirptr){
|
||||||
|
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); // Stores at max 10 image file names
|
||||||
|
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
|
||||||
|
|
||||||
|
if(!dirptr->filename_buf){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
for(i=0;i<num_images;i++){
|
||||||
|
dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (num_images==0){
|
||||||
|
fprintf(stdout,"Folder is empty\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
num_images=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Encoding image one by one*/
|
||||||
|
for(imageno = 0; imageno < num_images ; imageno++)
|
||||||
|
{
|
||||||
|
image = NULL;
|
||||||
|
fprintf(stderr,"\n");
|
||||||
|
|
||||||
|
if(img_fol.set_imgdir==1){
|
||||||
|
if (get_next_file(imageno, dirptr,&img_fol, ¶meters)) {
|
||||||
|
fprintf(stderr,"skipping file...\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read the input file and put it in memory */
|
||||||
|
/* ---------------------------------------- */
|
||||||
|
fsrc = fopen(parameters.infile, "rb");
|
||||||
|
if (!fsrc) {
|
||||||
|
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
fseek(fsrc, 0, SEEK_END);
|
||||||
|
file_length = ftell(fsrc);
|
||||||
|
fseek(fsrc, 0, SEEK_SET);
|
||||||
|
src = (unsigned char *) malloc(file_length);
|
||||||
|
fread(src, 1, file_length, fsrc);
|
||||||
|
fclose(fsrc);
|
||||||
|
|
||||||
|
/* decode the code-stream */
|
||||||
|
/* ---------------------- */
|
||||||
|
|
||||||
|
switch(parameters.decod_format) {
|
||||||
|
case J2K_CFMT:
|
||||||
|
{
|
||||||
|
/* JPEG-2000 codestream */
|
||||||
|
|
||||||
|
/* get a decoder handle */
|
||||||
|
dinfo = opj_create_decompress(CODEC_J2K);
|
||||||
|
|
||||||
|
/* catch events using our callbacks and give a local context */
|
||||||
|
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||||
|
|
||||||
|
/* setup the decoder decoding parameters using user parameters */
|
||||||
|
opj_setup_decoder(dinfo, ¶meters);
|
||||||
|
|
||||||
|
/* open a byte stream */
|
||||||
|
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||||
|
|
||||||
|
/* decode the stream and fill the image structure */
|
||||||
|
if (*indexfilename) // If need to extract codestream information
|
||||||
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
|
else
|
||||||
|
image = opj_decode(dinfo, cio);
|
||||||
|
if(!image) {
|
||||||
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* dump image */
|
||||||
|
j2k_dump_image(stdout, image);
|
||||||
|
|
||||||
|
/* dump cp */
|
||||||
|
j2k_dump_cp(stdout, image, ((opj_j2k_t*)dinfo->j2k_handle)->cp);
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* Write the index to disk */
|
||||||
|
if (*indexfilename) {
|
||||||
|
char bSuccess;
|
||||||
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
|
if (bSuccess) {
|
||||||
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case JP2_CFMT:
|
||||||
|
{
|
||||||
|
/* JPEG 2000 compressed image data */
|
||||||
|
|
||||||
|
/* get a decoder handle */
|
||||||
|
dinfo = opj_create_decompress(CODEC_JP2);
|
||||||
|
|
||||||
|
/* catch events using our callbacks and give a local context */
|
||||||
|
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||||
|
|
||||||
|
/* setup the decoder decoding parameters using the current image and user parameters */
|
||||||
|
opj_setup_decoder(dinfo, ¶meters);
|
||||||
|
|
||||||
|
/* open a byte stream */
|
||||||
|
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||||
|
|
||||||
|
/* decode the stream and fill the image structure */
|
||||||
|
if (*indexfilename) // If need to extract codestream information
|
||||||
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
|
else
|
||||||
|
image = opj_decode(dinfo, cio);
|
||||||
|
if(!image) {
|
||||||
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* dump image */
|
||||||
|
if(image->icc_profile_buf)
|
||||||
|
{
|
||||||
|
free(image->icc_profile_buf); image->icc_profile_buf = NULL;
|
||||||
|
}
|
||||||
|
j2k_dump_image(stdout, image);
|
||||||
|
|
||||||
|
/* dump cp */
|
||||||
|
j2k_dump_cp(stdout, image, ((opj_jp2_t*)dinfo->jp2_handle)->j2k->cp);
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* Write the index to disk */
|
||||||
|
if (*indexfilename) {
|
||||||
|
char bSuccess;
|
||||||
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
|
if (bSuccess) {
|
||||||
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case JPT_CFMT:
|
||||||
|
{
|
||||||
|
/* JPEG 2000, JPIP */
|
||||||
|
|
||||||
|
/* get a decoder handle */
|
||||||
|
dinfo = opj_create_decompress(CODEC_JPT);
|
||||||
|
|
||||||
|
/* catch events using our callbacks and give a local context */
|
||||||
|
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||||
|
|
||||||
|
/* setup the decoder decoding parameters using user parameters */
|
||||||
|
opj_setup_decoder(dinfo, ¶meters);
|
||||||
|
|
||||||
|
/* open a byte stream */
|
||||||
|
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||||
|
|
||||||
|
/* decode the stream and fill the image structure */
|
||||||
|
if (*indexfilename) // If need to extract codestream information
|
||||||
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
|
else
|
||||||
|
image = opj_decode(dinfo, cio);
|
||||||
|
if(!image) {
|
||||||
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
opj_cio_close(cio);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close the byte stream */
|
||||||
|
opj_cio_close(cio);
|
||||||
|
|
||||||
|
/* Write the index to disk */
|
||||||
|
if (*indexfilename) {
|
||||||
|
char bSuccess;
|
||||||
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
|
if (bSuccess) {
|
||||||
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "skipping file..\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free the memory containing the code-stream */
|
||||||
|
free(src);
|
||||||
|
src = NULL;
|
||||||
|
|
||||||
|
/* free remaining structures */
|
||||||
|
if(dinfo) {
|
||||||
|
opj_destroy_decompress(dinfo);
|
||||||
|
}
|
||||||
|
/* free codestream information structure */
|
||||||
|
if (*indexfilename)
|
||||||
|
opj_destroy_cstr_info(&cstr_info);
|
||||||
|
/* free image data structure */
|
||||||
|
opj_image_destroy(image);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void j2k_dump_image(FILE *fd, opj_image_t * img) {
|
||||||
|
int compno;
|
||||||
|
fprintf(fd, "image {\n");
|
||||||
|
fprintf(fd, " x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0, img->x1, img->y1);
|
||||||
|
fprintf(fd, " numcomps=%d\n", img->numcomps);
|
||||||
|
for (compno = 0; compno < img->numcomps; compno++) {
|
||||||
|
opj_image_comp_t *comp = &img->comps[compno];
|
||||||
|
fprintf(fd, " comp %d {\n", compno);
|
||||||
|
fprintf(fd, " dx=%d, dy=%d\n", comp->dx, comp->dy);
|
||||||
|
fprintf(fd, " prec=%d\n", comp->prec);
|
||||||
|
//fprintf(fd, " bpp=%d\n", comp->bpp);
|
||||||
|
fprintf(fd, " sgnd=%d\n", comp->sgnd);
|
||||||
|
fprintf(fd, " }\n");
|
||||||
|
}
|
||||||
|
fprintf(fd, "}\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp) {
|
||||||
|
int tileno, compno, layno, bandno, resno, numbands;
|
||||||
|
fprintf(fd, "coding parameters {\n");
|
||||||
|
fprintf(fd, " tx0=%d, ty0=%d\n", cp->tx0, cp->ty0);
|
||||||
|
fprintf(fd, " tdx=%d, tdy=%d\n", cp->tdx, cp->tdy);
|
||||||
|
fprintf(fd, " tw=%d, th=%d\n", cp->tw, cp->th);
|
||||||
|
for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
|
||||||
|
opj_tcp_t *tcp = &cp->tcps[tileno];
|
||||||
|
fprintf(fd, " tile %d {\n", tileno);
|
||||||
|
fprintf(fd, " csty=%x\n", tcp->csty);
|
||||||
|
fprintf(fd, " prg=%d\n", tcp->prg);
|
||||||
|
fprintf(fd, " numlayers=%d\n", tcp->numlayers);
|
||||||
|
fprintf(fd, " mct=%d\n", tcp->mct);
|
||||||
|
fprintf(fd, " rates=");
|
||||||
|
for (layno = 0; layno < tcp->numlayers; layno++) {
|
||||||
|
fprintf(fd, "%.1f ", tcp->rates[layno]);
|
||||||
|
}
|
||||||
|
fprintf(fd, "\n");
|
||||||
|
for (compno = 0; compno < img->numcomps; compno++) {
|
||||||
|
opj_tccp_t *tccp = &tcp->tccps[compno];
|
||||||
|
fprintf(fd, " comp %d {\n", compno);
|
||||||
|
fprintf(fd, " csty=%x\n", tccp->csty);
|
||||||
|
fprintf(fd, " numresolutions=%d\n", tccp->numresolutions);
|
||||||
|
fprintf(fd, " cblkw=%d\n", tccp->cblkw);
|
||||||
|
fprintf(fd, " cblkh=%d\n", tccp->cblkh);
|
||||||
|
fprintf(fd, " cblksty=%x\n", tccp->cblksty);
|
||||||
|
fprintf(fd, " qmfbid=%d\n", tccp->qmfbid);
|
||||||
|
fprintf(fd, " qntsty=%d\n", tccp->qntsty);
|
||||||
|
fprintf(fd, " numgbits=%d\n", tccp->numgbits);
|
||||||
|
fprintf(fd, " roishift=%d\n", tccp->roishift);
|
||||||
|
fprintf(fd, " stepsizes=");
|
||||||
|
numbands = tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2;
|
||||||
|
for (bandno = 0; bandno < numbands; bandno++) {
|
||||||
|
fprintf(fd, "(%d,%d) ", tccp->stepsizes[bandno].mant,
|
||||||
|
tccp->stepsizes[bandno].expn);
|
||||||
|
}
|
||||||
|
fprintf(fd, "\n");
|
||||||
|
|
||||||
|
if (tccp->csty & J2K_CCP_CSTY_PRT) {
|
||||||
|
fprintf(fd, " prcw=");
|
||||||
|
for (resno = 0; resno < tccp->numresolutions; resno++) {
|
||||||
|
fprintf(fd, "%d ", tccp->prcw[resno]);
|
||||||
|
}
|
||||||
|
fprintf(fd, "\n");
|
||||||
|
fprintf(fd, " prch=");
|
||||||
|
for (resno = 0; resno < tccp->numresolutions; resno++) {
|
||||||
|
fprintf(fd, "%d ", tccp->prch[resno]);
|
||||||
|
}
|
||||||
|
fprintf(fd, "\n");
|
||||||
|
}
|
||||||
|
fprintf(fd, " }\n");
|
||||||
|
}
|
||||||
|
fprintf(fd, " }\n");
|
||||||
|
}
|
||||||
|
fprintf(fd, "}\n");
|
||||||
|
}
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
|
|
||||||
#include "opj_config.h"
|
#include "opj_config.h"
|
||||||
#include "openjpeg.h"
|
#include "openjpeg.h"
|
||||||
#include "opj_getopt.h"
|
#include "getopt.h"
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ typedef struct img_folder{
|
|||||||
|
|
||||||
}img_fol_t;
|
}img_fol_t;
|
||||||
|
|
||||||
void decode_help_display(void) {
|
void decode_help_display() {
|
||||||
fprintf(stdout,"HELP for j2k_to_image\n----\n\n");
|
fprintf(stdout,"HELP for j2k_to_image\n----\n\n");
|
||||||
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparamet
|
|||||||
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
|
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
|
||||||
strncpy(parameters->infile, infilename, sizeof(infilename));
|
strncpy(parameters->infile, infilename, sizeof(infilename));
|
||||||
|
|
||||||
/*Set output file*/
|
//Set output file
|
||||||
strcpy(temp_ofname,strtok(image_filename,"."));
|
strcpy(temp_ofname,strtok(image_filename,"."));
|
||||||
while((temp_p = strtok(NULL,".")) != NULL){
|
while((temp_p = strtok(NULL,".")) != NULL){
|
||||||
strcat(temp_ofname,temp1);
|
strcat(temp_ofname,temp1);
|
||||||
@@ -237,8 +237,8 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparamet
|
|||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
|
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
|
||||||
/* parse the command line */
|
/* parse the command line */
|
||||||
int totlen, c;
|
int totlen;
|
||||||
opj_option_t long_option[]={
|
option_t long_option[]={
|
||||||
{"ImgDir",REQ_ARG, NULL ,'y'},
|
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||||
{"OutFor",REQ_ARG, NULL ,'O'},
|
{"OutFor",REQ_ARG, NULL ,'O'},
|
||||||
};
|
};
|
||||||
@@ -253,14 +253,14 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
"h" ;
|
"h" ;
|
||||||
totlen=sizeof(long_option);
|
totlen=sizeof(long_option);
|
||||||
img_fol->set_out_format = 0;
|
img_fol->set_out_format = 0;
|
||||||
do {
|
while (1) {
|
||||||
c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
|
int c = getopt_long(argc, argv,optlist,long_option,totlen);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'i': /* input file */
|
case 'i': /* input file */
|
||||||
{
|
{
|
||||||
char *infile = opj_optarg;
|
char *infile = optarg;
|
||||||
parameters->decod_format = get_file_format(infile);
|
parameters->decod_format = get_file_format(infile);
|
||||||
switch(parameters->decod_format) {
|
switch(parameters->decod_format) {
|
||||||
case J2K_CFMT:
|
case J2K_CFMT:
|
||||||
@@ -281,7 +281,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
|
|
||||||
case 'o': /* output file */
|
case 'o': /* output file */
|
||||||
{
|
{
|
||||||
char *outfile = opj_optarg;
|
char *outfile = optarg;
|
||||||
parameters->cod_format = get_file_format(outfile);
|
parameters->cod_format = get_file_format(outfile);
|
||||||
switch(parameters->cod_format) {
|
switch(parameters->cod_format) {
|
||||||
case PGX_DFMT:
|
case PGX_DFMT:
|
||||||
@@ -305,7 +305,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
case 'O': /* output format */
|
case 'O': /* output format */
|
||||||
{
|
{
|
||||||
char outformat[50];
|
char outformat[50];
|
||||||
char *of = opj_optarg;
|
char *of = optarg;
|
||||||
sprintf(outformat,".%s",of);
|
sprintf(outformat,".%s",of);
|
||||||
img_fol->set_out_format = 1;
|
img_fol->set_out_format = 1;
|
||||||
parameters->cod_format = get_file_format(outformat);
|
parameters->cod_format = get_file_format(outformat);
|
||||||
@@ -344,7 +344,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
|
|
||||||
case 'r': /* reduce option */
|
case 'r': /* reduce option */
|
||||||
{
|
{
|
||||||
sscanf(opj_optarg, "%d", ¶meters->cp_reduce);
|
sscanf(optarg, "%d", ¶meters->cp_reduce);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -353,7 +353,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
|
|
||||||
case 'l': /* layering option */
|
case 'l': /* layering option */
|
||||||
{
|
{
|
||||||
sscanf(opj_optarg, "%d", ¶meters->cp_layer);
|
sscanf(optarg, "%d", ¶meters->cp_layer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -367,15 +367,15 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
|
|
||||||
case 'y': /* Image Directory path */
|
case 'y': /* Image Directory path */
|
||||||
{
|
{
|
||||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
|
||||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
strcpy(img_fol->imgdirpath,optarg);
|
||||||
img_fol->set_imgdir=1;
|
img_fol->set_imgdir=1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
case 'x': /* Creation of index file */
|
case 'x': /* Creation of index file */
|
||||||
{
|
{
|
||||||
char *index = opj_optarg;
|
char *index = optarg;
|
||||||
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
strncpy(indexfilename, index, OPJ_PATH_LEN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -387,7 +387,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
{
|
{
|
||||||
char *token = NULL;
|
char *token = NULL;
|
||||||
|
|
||||||
token = strtok(opj_optarg, ",");
|
token = strtok(optarg, ",");
|
||||||
while(token != NULL) {
|
while(token != NULL) {
|
||||||
|
|
||||||
/* search expected number of components */
|
/* search expected number of components */
|
||||||
@@ -454,10 +454,10 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
|||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
|
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}while(c != -1);
|
}
|
||||||
|
|
||||||
/* check for possible errors */
|
/* check for possible errors */
|
||||||
if(img_fol->set_imgdir==1){
|
if(img_fol->set_imgdir==1){
|
||||||
@@ -521,7 +521,7 @@ int main(int argc, char **argv) {
|
|||||||
int file_length;
|
int file_length;
|
||||||
int num_images;
|
int num_images;
|
||||||
int i,imageno;
|
int i,imageno;
|
||||||
dircnt_t *dirptr = NULL;
|
dircnt_t *dirptr;
|
||||||
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
|
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
|
||||||
opj_cio_t *cio = NULL;
|
opj_cio_t *cio = NULL;
|
||||||
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
||||||
@@ -551,7 +551,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
||||||
if(dirptr){
|
if(dirptr){
|
||||||
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); // Stores at max 10 image file names
|
||||||
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
|
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
|
||||||
|
|
||||||
if(!dirptr->filename_buf){
|
if(!dirptr->filename_buf){
|
||||||
@@ -595,13 +595,7 @@ int main(int argc, char **argv) {
|
|||||||
file_length = ftell(fsrc);
|
file_length = ftell(fsrc);
|
||||||
fseek(fsrc, 0, SEEK_SET);
|
fseek(fsrc, 0, SEEK_SET);
|
||||||
src = (unsigned char *) malloc(file_length);
|
src = (unsigned char *) malloc(file_length);
|
||||||
if (fread(src, 1, file_length, fsrc) != (size_t)file_length)
|
fread(src, 1, file_length, fsrc);
|
||||||
{
|
|
||||||
free(src);
|
|
||||||
fclose(fsrc);
|
|
||||||
fprintf(stderr, "\nERROR: fread return a number of element different from the expected.\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
fclose(fsrc);
|
fclose(fsrc);
|
||||||
|
|
||||||
/* decode the code-stream */
|
/* decode the code-stream */
|
||||||
@@ -625,7 +619,7 @@ int main(int argc, char **argv) {
|
|||||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||||
|
|
||||||
/* decode the stream and fill the image structure */
|
/* decode the stream and fill the image structure */
|
||||||
if (*indexfilename) /* If need to extract codestream information*/
|
if (*indexfilename) // If need to extract codestream information
|
||||||
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
else
|
else
|
||||||
image = opj_decode(dinfo, cio);
|
image = opj_decode(dinfo, cio);
|
||||||
@@ -633,7 +627,6 @@ int main(int argc, char **argv) {
|
|||||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
opj_destroy_decompress(dinfo);
|
opj_destroy_decompress(dinfo);
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
free(src);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -642,7 +635,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
/* Write the index to disk */
|
/* Write the index to disk */
|
||||||
if (*indexfilename) {
|
if (*indexfilename) {
|
||||||
opj_bool bSuccess;
|
char bSuccess;
|
||||||
bSuccess = write_index_file(&cstr_info, indexfilename);
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
if (bSuccess) {
|
if (bSuccess) {
|
||||||
fprintf(stderr, "Failed to output index file\n");
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
@@ -668,7 +661,7 @@ int main(int argc, char **argv) {
|
|||||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||||
|
|
||||||
/* decode the stream and fill the image structure */
|
/* decode the stream and fill the image structure */
|
||||||
if (*indexfilename) /* If need to extract codestream information*/
|
if (*indexfilename) // If need to extract codestream information
|
||||||
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
else
|
else
|
||||||
image = opj_decode(dinfo, cio);
|
image = opj_decode(dinfo, cio);
|
||||||
@@ -676,7 +669,6 @@ int main(int argc, char **argv) {
|
|||||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
opj_destroy_decompress(dinfo);
|
opj_destroy_decompress(dinfo);
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
free(src);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -685,7 +677,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
/* Write the index to disk */
|
/* Write the index to disk */
|
||||||
if (*indexfilename) {
|
if (*indexfilename) {
|
||||||
opj_bool bSuccess;
|
char bSuccess;
|
||||||
bSuccess = write_index_file(&cstr_info, indexfilename);
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
if (bSuccess) {
|
if (bSuccess) {
|
||||||
fprintf(stderr, "Failed to output index file\n");
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
@@ -711,7 +703,7 @@ int main(int argc, char **argv) {
|
|||||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||||
|
|
||||||
/* decode the stream and fill the image structure */
|
/* decode the stream and fill the image structure */
|
||||||
if (*indexfilename) /* If need to extract codestream information*/
|
if (*indexfilename) // If need to extract codestream information
|
||||||
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||||
else
|
else
|
||||||
image = opj_decode(dinfo, cio);
|
image = opj_decode(dinfo, cio);
|
||||||
@@ -719,7 +711,6 @@ int main(int argc, char **argv) {
|
|||||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||||
opj_destroy_decompress(dinfo);
|
opj_destroy_decompress(dinfo);
|
||||||
opj_cio_close(cio);
|
opj_cio_close(cio);
|
||||||
free(src);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -728,7 +719,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
/* Write the index to disk */
|
/* Write the index to disk */
|
||||||
if (*indexfilename) {
|
if (*indexfilename) {
|
||||||
opj_bool bSuccess;
|
char bSuccess;
|
||||||
bSuccess = write_index_file(&cstr_info, indexfilename);
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
if (bSuccess) {
|
if (bSuccess) {
|
||||||
fprintf(stderr, "Failed to output index file\n");
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
@@ -847,7 +838,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*end main*/
|
//end main
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@
|
|||||||
# error "not implemented"
|
# error "not implemented"
|
||||||
# elif defined(__sgi) /* Silicon Graphics */
|
# elif defined(__sgi) /* Silicon Graphics */
|
||||||
# define HAVE_DIRENT_H
|
# define HAVE_DIRENT_H
|
||||||
# elif defined(sun) || defined(__sun) /* Sun Solaris */
|
# elif defined(sun) || defined(_sun) /* Sun Solaris */
|
||||||
# define HAVE_DIRENT_H
|
# define HAVE_DIRENT_H
|
||||||
# elif defined(__FreeBSD__) /* FreeBSD */
|
# elif defined(__FreeBSD__) /* FreeBSD */
|
||||||
# define HAVE_DIRENT_H
|
# define HAVE_DIRENT_H
|
||||||
@@ -45,13 +45,8 @@
|
|||||||
#include <lcms.h>
|
#include <lcms.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OPJ_USE_LEGACY
|
|
||||||
#define OPJ_CLRSPC_GRAY CLRSPC_GRAY
|
|
||||||
#define OPJ_CLRSPC_SRGB CLRSPC_SRGB
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*--------------------------------------------------------
|
/*--------------------------------------------------------
|
||||||
Matrix for sYCC, Amendment 1 to IEC 61966-2-1
|
Matrix für sYCC, Amendment 1 to IEC 61966-2-1
|
||||||
|
|
||||||
Y : 0.299 0.587 0.114 :R
|
Y : 0.299 0.587 0.114 :R
|
||||||
Cb: -0.1687 -0.3312 0.5 :G
|
Cb: -0.1687 -0.3312 0.5 :G
|
||||||
@@ -222,7 +217,7 @@ void color_sycc_to_rgb(opj_image_t *img)
|
|||||||
{
|
{
|
||||||
if(img->numcomps < 3)
|
if(img->numcomps < 3)
|
||||||
{
|
{
|
||||||
img->color_space = OPJ_CLRSPC_GRAY;
|
img->color_space = CLRSPC_GRAY;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +256,7 @@ void color_sycc_to_rgb(opj_image_t *img)
|
|||||||
__FILE__,__LINE__);
|
__FILE__,__LINE__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
img->color_space = OPJ_CLRSPC_SRGB;
|
img->color_space = CLRSPC_SRGB;
|
||||||
|
|
||||||
}/* color_sycc_to_rgb() */
|
}/* color_sycc_to_rgb() */
|
||||||
|
|
||||||
@@ -311,7 +306,7 @@ void color_apply_icc_profile(opj_image_t *image)
|
|||||||
in_type = TYPE_RGB_16;
|
in_type = TYPE_RGB_16;
|
||||||
out_type = TYPE_RGB_16;
|
out_type = TYPE_RGB_16;
|
||||||
out_prof = cmsCreate_sRGBProfile();
|
out_prof = cmsCreate_sRGBProfile();
|
||||||
image->color_space = OPJ_CLRSPC_SRGB;
|
image->color_space = CLRSPC_SRGB;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if(out_space == cmsSigGrayData) /* enumCS 17 */
|
if(out_space == cmsSigGrayData) /* enumCS 17 */
|
||||||
@@ -319,7 +314,7 @@ void color_apply_icc_profile(opj_image_t *image)
|
|||||||
in_type = TYPE_GRAY_8;
|
in_type = TYPE_GRAY_8;
|
||||||
out_type = TYPE_RGB_8;
|
out_type = TYPE_RGB_8;
|
||||||
out_prof = cmsCreate_sRGBProfile();
|
out_prof = cmsCreate_sRGBProfile();
|
||||||
image->color_space = OPJ_CLRSPC_SRGB;
|
image->color_space = CLRSPC_SRGB;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if(out_space == cmsSigYCbCrData) /* enumCS 18 */
|
if(out_space == cmsSigYCbCrData) /* enumCS 18 */
|
||||||
@@ -327,7 +322,7 @@ void color_apply_icc_profile(opj_image_t *image)
|
|||||||
in_type = TYPE_YCbCr_16;
|
in_type = TYPE_YCbCr_16;
|
||||||
out_type = TYPE_RGB_16;
|
out_type = TYPE_RGB_16;
|
||||||
out_prof = cmsCreate_sRGBProfile();
|
out_prof = cmsCreate_sRGBProfile();
|
||||||
image->color_space = OPJ_CLRSPC_SRGB;
|
image->color_space = CLRSPC_SRGB;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -44,6 +44,5 @@
|
|||||||
#define RAW_DFMT 15
|
#define RAW_DFMT 15
|
||||||
#define TGA_DFMT 16
|
#define TGA_DFMT 16
|
||||||
#define PNG_DFMT 17
|
#define PNG_DFMT 17
|
||||||
#define RAWL_DFMT 18
|
|
||||||
|
|
||||||
#endif /* _OPJ_FORMAT_DEFS_H_ */
|
#endif /* _OPJ_FORMAT_DEFS_H_ */
|
||||||
@@ -34,110 +34,117 @@
|
|||||||
/* last review : october 29th, 2002 */
|
/* last review : october 29th, 2002 */
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
static char sccsid[] = "@(#)opj_getopt.c 8.3 (Berkeley) 4/27/95";
|
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "opj_getopt.h"
|
|
||||||
|
|
||||||
int opj_opterr = 1, /* if error message should be printed */
|
int opterr = 1, /* if error message should be printed */
|
||||||
opj_optind = 1, /* index into parent argv vector */
|
optind = 1, /* index into parent argv vector */
|
||||||
opj_optopt, /* character checked for validity */
|
optopt, /* character checked for validity */
|
||||||
opj_optreset; /* reset getopt */
|
optreset; /* reset getopt */
|
||||||
char *opj_optarg; /* argument associated with option */
|
const char *optarg; /* argument associated with option */
|
||||||
|
|
||||||
|
typedef struct option
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
int has_arg;
|
||||||
|
int *flag;
|
||||||
|
int val;
|
||||||
|
}option_t;
|
||||||
|
|
||||||
#define BADCH (int)'?'
|
#define BADCH (int)'?'
|
||||||
#define BADARG (int)':'
|
#define BADARG (int)':'
|
||||||
static char EMSG[]={""};
|
#define EMSG ""
|
||||||
|
|
||||||
/* As this class remembers its values from one Java call to the other, reset the values before each use */
|
/* As this class remembers its values from one Java call to the other, reset the values before each use */
|
||||||
void reset_options_reading(void) {
|
void reset_options_reading() {
|
||||||
opj_opterr = 1;
|
opterr = 1;
|
||||||
opj_optind = 1;
|
optind = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* getopt --
|
* getopt --
|
||||||
* Parse argc/argv argument vector.
|
* Parse argc/argv argument vector.
|
||||||
*/
|
*/
|
||||||
int opj_getopt(int nargc, char *const *nargv, const char *ostr) {
|
int getopt(int nargc, char *const *nargv, const char *ostr) {
|
||||||
# define __progname nargv[0]
|
# define __progname nargv[0]
|
||||||
static char *place = EMSG; /* option letter processing */
|
static const char *place = EMSG; /* option letter processing */
|
||||||
char *oli = NULL; /* option letter list index */
|
char *oli; /* option letter list index */
|
||||||
|
|
||||||
if (opj_optreset || !*place) { /* update scanning pointer */
|
if (optreset || !*place) { /* update scanning pointer */
|
||||||
opj_optreset = 0;
|
optreset = 0;
|
||||||
if (opj_optind >= nargc || *(place = nargv[opj_optind]) != '-') {
|
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (place[1] && *++place == '-') { /* found "--" */
|
if (place[1] && *++place == '-') { /* found "--" */
|
||||||
++opj_optind;
|
++optind;
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
} /* option letter okay? */
|
} /* option letter okay? */
|
||||||
if ((opj_optopt = (int) *place++) == (int) ':' ||
|
if ((optopt = (int) *place++) == (int) ':' ||
|
||||||
!(oli = strchr(ostr, opj_optopt))) {
|
!(oli = strchr(ostr, optopt))) {
|
||||||
/*
|
/*
|
||||||
* if the user didn't specify '-' as an option,
|
* if the user didn't specify '-' as an option,
|
||||||
* assume it means -1.
|
* assume it means -1.
|
||||||
*/
|
*/
|
||||||
if (opj_optopt == (int) '-')
|
if (optopt == (int) '-')
|
||||||
return (-1);
|
return (-1);
|
||||||
if (!*place)
|
if (!*place)
|
||||||
++opj_optind;
|
++optind;
|
||||||
if (opj_opterr && *ostr != ':') {
|
if (opterr && *ostr != ':') {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: illegal option -- %c\n", __progname, opj_optopt);
|
"%s: illegal option -- %c\n", __progname, optopt);
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*++oli != ':') { /* don't need argument */
|
if (*++oli != ':') { /* don't need argument */
|
||||||
opj_optarg = NULL;
|
optarg = NULL;
|
||||||
if (!*place)
|
if (!*place)
|
||||||
++opj_optind;
|
++optind;
|
||||||
} else { /* need an argument */
|
} else { /* need an argument */
|
||||||
if (*place) /* no white space */
|
if (*place) /* no white space */
|
||||||
opj_optarg = place;
|
optarg = place;
|
||||||
else if (nargc <= ++opj_optind) { /* no arg */
|
else if (nargc <= ++optind) { /* no arg */
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
if (*ostr == ':')
|
if (*ostr == ':')
|
||||||
return (BADARG);
|
return (BADARG);
|
||||||
if (opj_opterr) {
|
if (opterr) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: option requires an argument -- %c\n",
|
"%s: option requires an argument -- %c\n",
|
||||||
__progname, opj_optopt);
|
__progname, optopt);
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}
|
}
|
||||||
} else /* white space */
|
} else /* white space */
|
||||||
opj_optarg = nargv[opj_optind];
|
optarg = nargv[optind];
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
++opj_optind;
|
++optind;
|
||||||
}
|
}
|
||||||
return (opj_optopt); /* dump back option letter */
|
return (optopt); /* dump back option letter */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int opj_getopt_long(int argc, char * const argv[], const char *optstring,
|
int getopt_long(int argc, char * const argv[], const char *optstring,
|
||||||
const opj_option_t *longopts, int totlen) {
|
struct option *longopts, int totlen) {
|
||||||
static int lastidx,lastofs;
|
static int lastidx,lastofs;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
int i,len;
|
int i,len;
|
||||||
char param = 1;
|
char param = 1;
|
||||||
|
|
||||||
again:
|
again:
|
||||||
if (opj_optind >= argc || !argv[opj_optind] || *argv[opj_optind]!='-')
|
if (optind >= argc || !argv[optind] || *argv[optind]!='-')
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (argv[opj_optind][0]=='-' && argv[opj_optind][1]==0) {
|
if (argv[optind][0]=='-' && argv[optind][1]==0) {
|
||||||
if(opj_optind >= (argc - 1)){ /* no more input parameters */
|
if(optind >= (argc - 1)){ /* no more input parameters */
|
||||||
param = 0;
|
param = 0;
|
||||||
}
|
}
|
||||||
else{ /* more input parameters */
|
else{ /* more input parameters */
|
||||||
if(argv[opj_optind + 1][0] == '-'){
|
if(argv[optind + 1][0] == '-'){
|
||||||
param = 0; /* Missing parameter after '-' */
|
param = 0; /* Missing parameter after '-' */
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -147,108 +154,108 @@ again:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (param == 0) {
|
if (param == 0) {
|
||||||
++opj_optind;
|
++optind;
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argv[opj_optind][0]=='-') { /* long option */
|
if (argv[optind][0]=='-') { /* long option */
|
||||||
char* arg=argv[opj_optind]+1;
|
char* arg=argv[optind]+1;
|
||||||
const opj_option_t* o;
|
const struct option* o;
|
||||||
o=longopts;
|
o=longopts;
|
||||||
len=sizeof(longopts[0]);
|
len=sizeof(longopts[0]);
|
||||||
|
|
||||||
if (param > 1){
|
if (param > 1){
|
||||||
arg = argv[opj_optind+1];
|
arg = argv[optind+1];
|
||||||
opj_optind++;
|
optind++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
arg = argv[opj_optind]+1;
|
arg = argv[optind]+1;
|
||||||
|
|
||||||
if(strlen(arg)>1){
|
if(strlen(arg)>1){
|
||||||
for (i=0;i<totlen;i=i+len,o++) {
|
for (i=0;i<totlen;i=i+len,o++) {
|
||||||
if (!strcmp(o->name,arg)) { /* match */
|
if (!strcmp(o->name,arg)) { /* match */
|
||||||
if (o->has_arg == 0) {
|
if (o->has_arg == 0) {
|
||||||
if ((argv[opj_optind+1])&&(!(argv[opj_optind+1][0]=='-'))){
|
if ((argv[optind+1])&&(!(argv[optind+1][0]=='-'))){
|
||||||
fprintf(stderr,"%s: option does not require an argument. Ignoring %s\n",arg,argv[opj_optind+1]);
|
fprintf(stderr,"%s: option does not require an argument. Ignoring %s\n",arg,argv[optind+1]);
|
||||||
++opj_optind;
|
++optind;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
opj_optarg=argv[opj_optind+1];
|
optarg=argv[optind+1];
|
||||||
if(opj_optarg){
|
if(optarg){
|
||||||
if (opj_optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
|
if (optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
|
||||||
if (opj_opterr) {
|
if (opterr) {
|
||||||
fprintf(stderr,"%s: option requires an argument\n",arg);
|
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!opj_optarg && o->has_arg==1) { /* no argument there */
|
if (!optarg && o->has_arg==1) { /* no argument there */
|
||||||
if (opj_opterr) {
|
if (opterr) {
|
||||||
fprintf(stderr,"%s: option requires an argument \n",arg);
|
fprintf(stderr,"%s: option requires an argument \n",arg);
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++opj_optind;
|
++optind;
|
||||||
}
|
}
|
||||||
++opj_optind;
|
++optind;
|
||||||
if (o->flag)
|
if (o->flag)
|
||||||
*(o->flag)=o->val;
|
*(o->flag)=o->val;
|
||||||
else
|
else
|
||||||
return o->val;
|
return o->val;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}/*(end for)String not found in the list*/
|
}//(end for)String not found in the list
|
||||||
fprintf(stderr,"Invalid option %s\n",arg);
|
fprintf(stderr,"Invalid option %s\n",arg);
|
||||||
++opj_optind;
|
++optind;
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}else{ /*Single character input parameter*/
|
}else{ /*Single character input parameter*/
|
||||||
if (*optstring==':') return ':';
|
if (*optstring==':') return ':';
|
||||||
if (lastidx!=opj_optind) {
|
if (lastidx!=optind) {
|
||||||
lastidx=opj_optind; lastofs=0;
|
lastidx=optind; lastofs=0;
|
||||||
}
|
}
|
||||||
opj_optopt=argv[opj_optind][lastofs+1];
|
optopt=argv[optind][lastofs+1];
|
||||||
if ((tmp=strchr(optstring,opj_optopt))) {/*Found input parameter in list*/
|
if ((tmp=strchr(optstring,optopt))) {/*Found input parameter in list*/
|
||||||
if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */
|
if (*tmp==0) { /* apparently, we looked for \0, i.e. end of argument */
|
||||||
++opj_optind;
|
++optind;
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
if (tmp[1]==':') { /* argument expected */
|
if (tmp[1]==':') { /* argument expected */
|
||||||
if (tmp[2]==':' || argv[opj_optind][lastofs+2]) { /* "-foo", return "oo" as opj_optarg */
|
if (tmp[2]==':' || argv[optind][lastofs+2]) { /* "-foo", return "oo" as optarg */
|
||||||
if (!*(opj_optarg=argv[opj_optind]+lastofs+2)) opj_optarg=0;
|
if (!*(optarg=argv[optind]+lastofs+2)) optarg=0;
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
opj_optarg=argv[opj_optind+1];
|
optarg=argv[optind+1];
|
||||||
if(opj_optarg){
|
if(optarg){
|
||||||
if (opj_optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
|
if (optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
|
||||||
if (opj_opterr) {
|
if (opterr) {
|
||||||
fprintf(stderr,"%s: option requires an argument\n",arg);
|
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!opj_optarg) { /* missing argument */
|
if (!optarg) { /* missing argument */
|
||||||
if (opj_opterr) {
|
if (opterr) {
|
||||||
fprintf(stderr,"%s: option requires an argument\n",arg);
|
fprintf(stderr,"%s: option requires an argument\n",arg);
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++opj_optind;
|
++optind;
|
||||||
}else {/*Argument not expected*/
|
}else {/*Argument not expected*/
|
||||||
++lastofs;
|
++lastofs;
|
||||||
return opj_optopt;
|
return optopt;
|
||||||
}
|
}
|
||||||
found:
|
found:
|
||||||
++opj_optind;
|
++optind;
|
||||||
return opj_optopt;
|
return optopt;
|
||||||
} else { /* not found */
|
} else { /* not found */
|
||||||
fprintf(stderr,"Invalid option %s\n",arg);
|
fprintf(stderr,"Invalid option %s\n",arg);
|
||||||
++opj_optind;
|
++optind;
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}/*end of not found*/
|
}//end of not found
|
||||||
|
|
||||||
}/* end of single character*/
|
}// end of single character
|
||||||
}/*end '-'*/
|
}//end '-'
|
||||||
fprintf(stderr,"Invalid option\n");
|
fprintf(stderr,"Invalid option\n");
|
||||||
++opj_optind;
|
++optind;
|
||||||
return (BADCH);;
|
return (BADCH);;
|
||||||
}/*end function*/
|
}//end function
|
||||||
29
applications/common/getopt.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/* last review : october 29th, 2002 */
|
||||||
|
|
||||||
|
#ifndef _GETOPT_H_
|
||||||
|
#define _GETOPT_H_
|
||||||
|
|
||||||
|
typedef struct option
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
int has_arg;
|
||||||
|
int *flag;
|
||||||
|
int val;
|
||||||
|
}option_t;
|
||||||
|
|
||||||
|
#define NO_ARG 0
|
||||||
|
#define REQ_ARG 1
|
||||||
|
#define OPT_ARG 2
|
||||||
|
|
||||||
|
extern int opterr;
|
||||||
|
extern int optind;
|
||||||
|
extern int optopt;
|
||||||
|
extern int optreset;
|
||||||
|
extern char *optarg;
|
||||||
|
|
||||||
|
extern int getopt(int nargc, char *const *nargv, const char *ostr);
|
||||||
|
extern int getopt_long(int argc, char * const argv[], const char *optstring,
|
||||||
|
const struct option *longopts, int totlen);
|
||||||
|
extern void reset_options_reading();
|
||||||
|
|
||||||
|
#endif /* _GETOPT_H_ */
|
||||||
36
applications/jpip/CHANGES
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
What's New for OpenJPIP
|
||||||
|
|
||||||
|
* : fixed
|
||||||
|
- : removed
|
||||||
|
! : changed
|
||||||
|
+ : added
|
||||||
|
|
||||||
|
July 6, 2011
|
||||||
|
* [antonin] JPIP : fixed autotools to work with recent name changes
|
||||||
|
|
||||||
|
July 5, 2011
|
||||||
|
! [kaori] changed parameter, file names, message names regarding JPT-stream to JPIP-stream, which handles also JPP-stream
|
||||||
|
|
||||||
|
May 26, 2011
|
||||||
|
! [antonin] changed Makefile to Makefile.nix to avoid having autotools overwrite them.
|
||||||
|
|
||||||
|
May 23, 2011
|
||||||
|
+ [antonin] added autotools for the 'tools' directory
|
||||||
|
+ [antonin] added autotools as a build method for jpip (credit to Vincent Torri)
|
||||||
|
|
||||||
|
May 10, 2011
|
||||||
|
! [kaori] opj_viewer removed the xml functions (for users without Xersus2)
|
||||||
|
+ [kaori] renamed opj_viewer to opj_viewer_xerces ( needs Xersus2)
|
||||||
|
! [kaori] Modification of opj_dec_server to be portable to windows
|
||||||
|
|
||||||
|
May 9, 2011
|
||||||
|
* [kaori] Removal of c99 from the compile option (to be compatible to win platform) and bool definition in libopenjpip/bool.h
|
||||||
|
|
||||||
|
May 9, 2011
|
||||||
|
* [antonin] OpenJPIP: small bug fixes to compile on win platform
|
||||||
|
|
||||||
|
May 8, 2011
|
||||||
|
* [antonin] OpenJPIP: fixed several bugs in opj_server (removal of strsep function, duplication of query string) + some changes to compile opj_server under windows (replacement of strcasecmp(), bzero()).
|
||||||
|
|
||||||
|
April 14, 2011
|
||||||
|
+ [antonin] initial commit of OpenJPIP 1.0, a JPIP client-server architecture based on OpenJPEG (see README file in jpip directory for more details)
|
||||||
3
applications/jpip/Makefile.am
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
||||||
|
SUBDIRS = libopenjpip opj_server opj_client tools
|
||||||
19
applications/jpip/Makefile.nix
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
default: t_libopenjpip t_opj_server t_opj_dec_server t_tools
|
||||||
|
|
||||||
|
t_libopenjpip:
|
||||||
|
make -C libopenjpip -f Makefile.nix
|
||||||
|
|
||||||
|
t_opj_server:
|
||||||
|
make -C opj_server -f Makefile.nix
|
||||||
|
|
||||||
|
t_opj_dec_server:
|
||||||
|
make -C opj_client/opj_dec_server -f Makefile.nix
|
||||||
|
|
||||||
|
t_tools:
|
||||||
|
make -C tools -f Makefile.nix
|
||||||
|
|
||||||
|
clean:
|
||||||
|
make clean -C libopenjpip -f Makefile.nix
|
||||||
|
make clean -C opj_server -f Makefile.nix
|
||||||
|
make clean -C opj_client/opj_dec_server -f Makefile.nix
|
||||||
|
make clean -C tools -f Makefile.nix
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
========================================================================
|
========================================================================
|
||||||
OpenJPIP software 2.1 ReadMe
|
OpenJPIP software 1.0 ReadMe
|
||||||
|
|
||||||
OpenJPEG:
|
OpenJPEG:
|
||||||
http://www.openjpeg.org
|
http://www.openjpeg.org
|
||||||
@@ -26,14 +26,13 @@ OpenJPIP software is an implementation of JPEG 2000 Part9: Interactivity tools,
|
|||||||
( For more info about JPIP, check the website: http://www.jpeg.org/jpeg2000/j2kpart9.html)
|
( For more info about JPIP, check the website: http://www.jpeg.org/jpeg2000/j2kpart9.html)
|
||||||
The current implementation uses some results from the 2KAN project (http://www.2kan.org).
|
The current implementation uses some results from the 2KAN project (http://www.2kan.org).
|
||||||
|
|
||||||
Version 2.1 covers:
|
First Version 1.0 covers:
|
||||||
- JPT-stream (Tile) and JPP-stream (Precinct) media types
|
- JPT-stream (Tile based) media types
|
||||||
- Session, channels, cache model managements
|
- Session, channels, cache model managements
|
||||||
- JPIP over HTTP, HTTP requests and TCP return
|
- JPIP over HTTP
|
||||||
- Indexing JPEG 2000 files
|
- Indexing JPEG 2000 files
|
||||||
- Embedding XML formatted metadata
|
- Embedding XML formatted metadata
|
||||||
- Region Of Interest (ROI) requests
|
- Region Of Interest (ROI) requests
|
||||||
- Access to JP2 files with their URL
|
|
||||||
|
|
||||||
----------
|
----------
|
||||||
2. License
|
2. License
|
||||||
@@ -47,9 +46,10 @@ Neither the author, nor the university accept any responsibility for any kind of
|
|||||||
3. System requirements
|
3. System requirements
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
- OpenJPEG library (currently assumes it is installed on the system => will not use the one built higher in the directory structure)
|
||||||
- FastCGI development kit (C libraries) at server (http://www.fastcgi.com)
|
- FastCGI development kit (C libraries) at server (http://www.fastcgi.com)
|
||||||
- libcURL library
|
|
||||||
- Java application launcher at client
|
- Java application launcher at client
|
||||||
|
- Kakadu software ( http://www.kakadusoftware.com). Currently required to encode jpeg 2000 images with tile-parts. This will be implemented soon in openjpeg, making this requirement obsolete.
|
||||||
<Optional>
|
<Optional>
|
||||||
- Xerces2 java XML parser on the client for accessing embedded image metadata (http://xerces.apache.org/xerces2-j)
|
- Xerces2 java XML parser on the client for accessing embedded image metadata (http://xerces.apache.org/xerces2-j)
|
||||||
|
|
||||||
@@ -62,6 +62,8 @@ We tested this software with a virtual server running on the same Linux machine
|
|||||||
A Makefile is available in the same directory as this README file. Simply type 'make' and it will build all the required C-executables.
|
A Makefile is available in the same directory as this README file. Simply type 'make' and it will build all the required C-executables.
|
||||||
Concerning the java-based opj_viewer, simply type 'ant' in the corresponding directory (requires 'ant' utility of course)
|
Concerning the java-based opj_viewer, simply type 'ant' in the corresponding directory (requires 'ant' utility of course)
|
||||||
|
|
||||||
|
CMake files ar planned to be included ASAP.
|
||||||
|
|
||||||
The documentation can be build this way (requires doxygen utility):
|
The documentation can be build this way (requires doxygen utility):
|
||||||
cd doc
|
cd doc
|
||||||
doxygen Doxyfile
|
doxygen Doxyfile
|
||||||
@@ -89,14 +91,9 @@ Server:
|
|||||||
2. Launch opj_server from the server terminal:
|
2. Launch opj_server from the server terminal:
|
||||||
% spawn-fcgi -f ./opj_server -p 3000 -n
|
% spawn-fcgi -f ./opj_server -p 3000 -n
|
||||||
|
|
||||||
For shutting down JPIP server:
|
|
||||||
%GET http://hostname/myFCGI?quitJPIP
|
|
||||||
Notice, http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
|
|
||||||
Requst message "quitJPIP" can be changed in Makfile, modify -DQUIT_SIGNAL=\"quitJPIP\"
|
|
||||||
|
|
||||||
Client:
|
Client:
|
||||||
1. Launch image decoding server, and keep it alive as long as image viewers are open
|
1. Launch image decoding server, and keep it alive as long as image viewers are open
|
||||||
% ./opj_dec_server [portnumber (50000 by default)]
|
% ./opj_dec_server
|
||||||
|
|
||||||
You might prefer to implement this program from another directory since cache files are saved in the working directory.
|
You might prefer to implement this program from another directory since cache files are saved in the working directory.
|
||||||
% mkdir cache
|
% mkdir cache
|
||||||
@@ -104,15 +101,10 @@ Client:
|
|||||||
% ../opj_dec_server
|
% ../opj_dec_server
|
||||||
|
|
||||||
2. Open image viewers (as many as needed)
|
2. Open image viewers (as many as needed)
|
||||||
% java -jar opj_viewer.jar http://hostname/myFCGI path/filename.jp2 [hostname] [portnumber] [stateless/session] [jptstream/jppstream] [tcp/udp]
|
% java -jar opj_viewer.jar http://hostname/myFCGI JP2_filename.jp2
|
||||||
( The arguments
|
( The arguments
|
||||||
- http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
|
- http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
|
||||||
- path/filename.jp2 is the server local path or URL of a JP2 file
|
- JP2_filename.jp2 is the name of a JP2 file available on the server.)
|
||||||
- host name of opj_dec_server, localhost by default
|
|
||||||
- portnumber of opj_dec_server, 50000 by default
|
|
||||||
- request type stateless for no caching, session (default) for caching
|
|
||||||
- return media type, JPT-stream tile based stream, or JPP-stream (default) precinct based stream
|
|
||||||
- auxiliary return protocol, tcp or udp (udp is not implemented yet), if not given, return data is filled in http chunk
|
|
||||||
Image viewer GUI instructions:
|
Image viewer GUI instructions:
|
||||||
Scale up request: Enlarge the window
|
Scale up request: Enlarge the window
|
||||||
ROI request: Select a region by mouse click and drag, then click inside the red frame of the selected region
|
ROI request: Select a region by mouse click and drag, then click inside the red frame of the selected region
|
||||||
@@ -122,7 +114,7 @@ Client:
|
|||||||
Open a new window presenting an aligned image with a locally stored image: Click button "Image Registration" (Under Construction)
|
Open a new window presenting an aligned image with a locally stored image: Click button "Image Registration" (Under Construction)
|
||||||
|
|
||||||
3. Quit the image decoding server through the telnet, be sure all image viewers are closed
|
3. Quit the image decoding server through the telnet, be sure all image viewers are closed
|
||||||
% telnet localhost 50000
|
% telnet localhost 5000
|
||||||
quit
|
quit
|
||||||
|
|
||||||
----------
|
----------
|
||||||
@@ -130,11 +122,12 @@ Client:
|
|||||||
----------
|
----------
|
||||||
|
|
||||||
An example to encode a TIF image "copenhague1.tif" at resolution 4780x4050, 8bit/pixel, grayscale.
|
An example to encode a TIF image "copenhague1.tif" at resolution 4780x4050, 8bit/pixel, grayscale.
|
||||||
% ./image_to_j2k -i copenhague1.tif -o copenhague1.jp2 -p RPCL -c [64,64] -t 640,480 -jpip -TP R
|
|
||||||
|
|
||||||
options
|
1. J2K encoding using Kakadu with an option which introduces the tile-part flag at each resolution level
|
||||||
-jpip : embed index table 'cidx' box into the output JP2 file (obligation for JPIP)
|
% ./kdu_compress -i copenhague1.tif -o copenhague1.j2k Corder=RPCL ORGtparts=R Stiles={256,256}
|
||||||
-TP R : partition a tile into tile parts of different resolution levels (obligation for JPT-stream)
|
|
||||||
|
2. JP2 encoding with embedding indexing data
|
||||||
|
% ./index_create copenhague1.j2k copenhague1.jp2 2
|
||||||
|
|
||||||
<Option>
|
<Option>
|
||||||
3. Embed metadata into JP2 file
|
3. Embed metadata into JP2 file
|
||||||
1514
applications/jpip/doc/Doxyfile
Normal file
BIN
applications/jpip/doc/jpip_architect.png
Normal file
|
After Width: | Height: | Size: 62 KiB |
BIN
applications/jpip/doc/jpip_protocol.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
95
applications/jpip/libopenjpip/Makefile.am
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
||||||
|
includesdir = $(includedir)/openjpeg-$(MAJOR_NR).$(MINOR_NR)
|
||||||
|
includes_HEADERS =
|
||||||
|
|
||||||
|
lib_LTLIBRARIES = libopenjpip_server.la libopenjpip_local.la
|
||||||
|
|
||||||
|
JPIP_SRC = \
|
||||||
|
boxheader_manager.c \
|
||||||
|
codestream_manager.c \
|
||||||
|
imgreg_manager.c \
|
||||||
|
marker_manager.c \
|
||||||
|
msgqueue_manager.c \
|
||||||
|
box_manager.c \
|
||||||
|
faixbox_manager.c \
|
||||||
|
index_manager.c \
|
||||||
|
metadata_manager.c \
|
||||||
|
placeholder_manager.c \
|
||||||
|
byte_manager.c \
|
||||||
|
ihdrbox_manager.c \
|
||||||
|
manfbox_manager.c \
|
||||||
|
mhixbox_manager.c \
|
||||||
|
target_manager.c \
|
||||||
|
bool.h \
|
||||||
|
boxheader_manager.h \
|
||||||
|
box_manager.h \
|
||||||
|
byte_manager.h \
|
||||||
|
codestream_manager.h \
|
||||||
|
faixbox_manager.h \
|
||||||
|
ihdrbox_manager.h \
|
||||||
|
imgreg_manager.h \
|
||||||
|
index_manager.h \
|
||||||
|
manfbox_manager.h \
|
||||||
|
marker_manager.h \
|
||||||
|
metadata_manager.h \
|
||||||
|
mhixbox_manager.h \
|
||||||
|
msgqueue_manager.h \
|
||||||
|
placeholder_manager.h \
|
||||||
|
target_manager.h
|
||||||
|
|
||||||
|
libopenjpip_server_la_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/jpip/libopenjpip \
|
||||||
|
-I$(top_builddir)/applications/jpip/libopenjpip \
|
||||||
|
@FCGI_CFLAGS@ \
|
||||||
|
-DSERVER
|
||||||
|
libopenjpip_server_la_CFLAGS =
|
||||||
|
libopenjpip_server_la_LIBADD = @FCGI_LIBS@ -lm
|
||||||
|
libopenjpip_server_la_LDFLAGS = -no-undefined -version-info @lt_version@
|
||||||
|
libopenjpip_server_la_SOURCES = $(JPIP_SRC)
|
||||||
|
|
||||||
|
libopenjpip_local_la_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/applications/jpip/libopenjpip \
|
||||||
|
-I$(top_builddir)/applications/jpip/libopenjpip
|
||||||
|
libopenjpip_local_la_CFLAGS =
|
||||||
|
libopenjpip_local_la_LIBADD = -lm
|
||||||
|
libopenjpip_local_la_LDFLAGS = -no-undefined -version-info @lt_version@
|
||||||
|
libopenjpip_local_la_SOURCES = $(JPIP_SRC)
|
||||||
|
|
||||||
|
install-data-hook:
|
||||||
|
@echo -e " (LA)\t$(libdir)/libopenjpip_server.la" >> $(top_builddir)/report.txt
|
||||||
|
@( $(call solist_s) ) >> $(top_builddir)/report.txt
|
||||||
|
@echo -e " (A)\t$(base_s)/$(a_s)" >> $(top_builddir)/report.txt
|
||||||
|
@echo -e " (LA)\t$(libdir)/libopenjpip_local.la" >> $(top_builddir)/report.txt
|
||||||
|
@( $(call solist_c) ) >> $(top_builddir)/report.txt
|
||||||
|
@echo -e " (A)\t$(base_c)/$(a_c)" >> $(top_builddir)/report.txt
|
||||||
|
|
||||||
|
solist_s = $(foreach f, $(dll_s) $(so_s), echo -e ' $(SO_PREFIX)\t$(base_s)/$(f)' ;)
|
||||||
|
get_tok_s = $(shell grep -E "^$(1)=" libopenjpip_server.la | cut -d "'" -f 2)
|
||||||
|
base_s = $(call get_tok_s,libdir)
|
||||||
|
so_s = $(call get_tok_s,library_names)
|
||||||
|
a_s = $(call get_tok_s,old_library)
|
||||||
|
|
||||||
|
solist_c = $(foreach f, $(dll_c) $(so_c), echo -e ' $(SO_PREFIX)\t$(base_c)/$(f)' ;)
|
||||||
|
get_tok_c = $(shell grep -E "^$(1)=" libopenjpip_local.la | cut -d "'" -f 2)
|
||||||
|
base_c = $(call get_tok_c,libdir)
|
||||||
|
so_c = $(call get_tok_c,library_names)
|
||||||
|
a_c = $(call get_tok_c,old_library)
|
||||||
|
|
||||||
|
if HAVE_WIN32
|
||||||
|
SO_PREFIX = (DLL)
|
||||||
|
dll_s = $(call get_tok_s,dlname)
|
||||||
|
dll_c = $(call get_tok_c,dlname)
|
||||||
|
else
|
||||||
|
if HAVE_DARWIN
|
||||||
|
SO_PREFIX = (DY)
|
||||||
|
dll_s =
|
||||||
|
dll_c =
|
||||||
|
else
|
||||||
|
SO_PREFIX = (SO)
|
||||||
|
dll_s =
|
||||||
|
dll_c =
|
||||||
|
endif
|
||||||
|
endif
|
||||||
10
applications/jpip/libopenjpip/Makefile.nix
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
default: local server
|
||||||
|
|
||||||
|
local:
|
||||||
|
make -f comMakefile.mk
|
||||||
|
|
||||||
|
server:
|
||||||
|
rm *.o && make jpipserver=yes -f comMakefile.mk
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.a *.o *~
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
* $Id$
|
||||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
*
|
||||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -26,24 +28,25 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __J2K_INDEX_H
|
#ifndef BOOL_H_
|
||||||
#define __J2K_INDEX_H
|
# define BOOL_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifndef false
|
||||||
extern "C" {
|
#define false 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
#ifndef FALSE
|
||||||
Write a structured index to a file
|
#define FALSE 0
|
||||||
@param cstr_info Codestream information
|
|
||||||
@param index Index filename
|
|
||||||
@return Returns 0 if successful, returns 1 otherwise
|
|
||||||
*/
|
|
||||||
int write_index_file(opj_codestream_info_t *cstr_info, char *index);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __J2K_INDEX_H */
|
#ifndef true
|
||||||
|
#define true (!false)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE (!FALSE)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef char bool;
|
||||||
|
|
||||||
|
#endif /* !BOOL_H_ */
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id: box_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
@@ -28,13 +28,13 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
|
||||||
#include "box_manager.h"
|
#include "box_manager.h"
|
||||||
#include "opj_inttypes.h"
|
|
||||||
|
|
||||||
#ifdef SERVER
|
#ifdef SERVER
|
||||||
#include "fcgi_stdio.h"
|
#include "fcgi_stdio.h"
|
||||||
@@ -43,9 +43,9 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif /*SERVER*/
|
#endif //SERVER
|
||||||
|
|
||||||
boxlist_param_t * gene_boxlist(void)
|
boxlist_param_t * gene_boxlist()
|
||||||
{
|
{
|
||||||
boxlist_param_t *boxlist;
|
boxlist_param_t *boxlist;
|
||||||
|
|
||||||
@@ -57,41 +57,38 @@ boxlist_param_t * gene_boxlist(void)
|
|||||||
return boxlist;
|
return boxlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
boxlist_param_t * get_boxstructure( int fd, OPJ_OFF_T offset, OPJ_SIZE_T length)
|
boxlist_param_t * get_boxstructure( int fd, Byte8_t offset, Byte8_t length)
|
||||||
{
|
{
|
||||||
boxlist_param_t *boxlist;
|
boxlist_param_t *boxlist;
|
||||||
box_param_t *box;
|
box_param_t *box;
|
||||||
OPJ_OFF_T pos;
|
int pos;
|
||||||
|
|
||||||
boxlist = NULL;
|
boxlist = NULL;
|
||||||
pos = offset;
|
pos = offset;
|
||||||
assert( (OPJ_OFF_T)length>=0);
|
|
||||||
do{
|
do{
|
||||||
if(!(box = gene_boxbyOffset( fd, pos)))
|
if(!(box = gene_boxbyOffset( fd, pos)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
assert( (OPJ_OFF_T)box->length >= 0);
|
pos += box->length;
|
||||||
pos += (OPJ_OFF_T)box->length;
|
|
||||||
|
|
||||||
if( !boxlist)
|
if( !boxlist)
|
||||||
boxlist = gene_boxlist();
|
boxlist = gene_boxlist();
|
||||||
insert_box_into_list( box, boxlist);
|
insert_box_into_list( box, boxlist);
|
||||||
}while( pos < offset+(OPJ_OFF_T)length);
|
}while( pos < offset+length);
|
||||||
|
|
||||||
return boxlist;
|
return boxlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
box_param_t * gene_boxbyOffset( int fd, OPJ_OFF_T offset)
|
box_param_t * gene_boxbyOffset( int fd, Byte8_t offset)
|
||||||
{
|
{
|
||||||
Byte_t *data;
|
Byte_t *data;
|
||||||
Byte8_t boxlen;
|
Byte8_t boxlen, headlen;
|
||||||
Byte_t headlen;
|
|
||||||
char *boxtype;
|
char *boxtype;
|
||||||
box_param_t *box;
|
box_param_t *box;
|
||||||
|
|
||||||
/* read LBox and TBox*/
|
// read LBox and TBox
|
||||||
if(!(data = fetch_bytes( fd, offset, 8))){
|
if(!(data = fetch_bytes( fd, offset, 8))){
|
||||||
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %" PRId64 ")\n", fd, offset);
|
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %lld)\n", fd, offset);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,10 +96,10 @@ box_param_t * gene_boxbyOffset( int fd, OPJ_OFF_T offset)
|
|||||||
boxlen = (Byte8_t)big4(data);
|
boxlen = (Byte8_t)big4(data);
|
||||||
boxtype = (char *)(data+4);
|
boxtype = (char *)(data+4);
|
||||||
|
|
||||||
/* box type constraint*/
|
// box type constraint
|
||||||
if( !isalpha(boxtype[0]) || !isalpha(boxtype[1]) ||
|
if( !isalpha(boxtype[0]) || !isalpha(boxtype[1]) ||
|
||||||
(!isalnum(boxtype[2])&&!isspace(boxtype[2])) ||
|
(!isalnum(boxtype[2])&&!isblank(boxtype[2])) ||
|
||||||
(!isalpha(boxtype[3])&&!isspace(boxtype[3]))){
|
(!isalpha(boxtype[3])&&!isblank(boxtype[3]))){
|
||||||
free( data);
|
free( data);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -110,13 +107,13 @@ box_param_t * gene_boxbyOffset( int fd, OPJ_OFF_T offset)
|
|||||||
if( boxlen == 1){
|
if( boxlen == 1){
|
||||||
Byte_t *data2;
|
Byte_t *data2;
|
||||||
headlen = 16;
|
headlen = 16;
|
||||||
/* read XLBox*/
|
// read XLBox
|
||||||
if((data2 = fetch_bytes( fd, offset+8, 8))){
|
if((data2 = fetch_bytes( fd, offset+8, 8))){
|
||||||
boxlen = big8(data2);
|
boxlen = big8(data2);
|
||||||
free(data2);
|
free(data2);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %" PRId64 ")\n", fd, offset);
|
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %lld)\n", fd, offset);
|
||||||
free( data);
|
free( data);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -132,28 +129,27 @@ box_param_t * gene_boxbyOffset( int fd, OPJ_OFF_T offset)
|
|||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
box_param_t * gene_boxbyOffinStream( Byte_t *stream, OPJ_OFF_T offset)
|
box_param_t * gene_boxbyOffinStream( Byte_t *stream, Byte8_t offset)
|
||||||
{
|
{
|
||||||
Byte8_t boxlen;
|
Byte8_t boxlen, headlen;
|
||||||
Byte_t headlen;
|
|
||||||
char *boxtype;
|
char *boxtype;
|
||||||
box_param_t *box;
|
box_param_t *box;
|
||||||
|
|
||||||
/* read LBox and TBox*/
|
// read LBox and TBox
|
||||||
headlen = 8;
|
headlen = 8;
|
||||||
boxlen = (Byte8_t)big4( stream);
|
boxlen = (Byte8_t)big4( stream);
|
||||||
boxtype = (char *)( stream+4);
|
boxtype = (char *)( stream+4);
|
||||||
|
|
||||||
/* box type constraint*/
|
// box type constraint
|
||||||
if( !isalpha(boxtype[0]) || !isalpha(boxtype[1]) ||
|
if( !isalpha(boxtype[0]) || !isalpha(boxtype[1]) ||
|
||||||
(!isalnum(boxtype[2])&&!isspace(boxtype[2])) ||
|
(!isalnum(boxtype[2])&&!isblank(boxtype[2])) ||
|
||||||
(!isalpha(boxtype[3])&&!isspace(boxtype[3]))){
|
(!isalpha(boxtype[3])&&!isblank(boxtype[3]))){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( boxlen == 1){
|
if( boxlen == 1){
|
||||||
headlen = 16;
|
headlen = 16;
|
||||||
boxlen = big8( stream+8); /* read XLBox*/
|
boxlen = big8( stream+8); // read XLBox
|
||||||
}
|
}
|
||||||
box = (box_param_t *)malloc( sizeof( box_param_t));
|
box = (box_param_t *)malloc( sizeof( box_param_t));
|
||||||
box->fd = -1;
|
box->fd = -1;
|
||||||
@@ -167,30 +163,28 @@ box_param_t * gene_boxbyOffinStream( Byte_t *stream, OPJ_OFF_T offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
box_param_t * gene_boxbyType( int fd, OPJ_OFF_T offset, OPJ_SIZE_T length, const char TBox[])
|
box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, char TBox[])
|
||||||
{
|
{
|
||||||
OPJ_OFF_T pos;
|
Byte8_t pos;
|
||||||
Byte_t *data;
|
Byte_t *data;
|
||||||
Byte8_t boxlen;
|
Byte8_t boxlen, headlen;
|
||||||
Byte_t headlen;
|
|
||||||
char *boxtype;
|
char *boxtype;
|
||||||
box_param_t *foundbox;
|
box_param_t *foundbox;
|
||||||
|
|
||||||
|
|
||||||
if( length==0){ /* set the max length*/
|
if( length==0){ // set the max length
|
||||||
if( get_filesize( fd) <= offset )
|
struct stat sb;
|
||||||
|
if( fstat( fd, &sb) == -1){
|
||||||
|
fprintf( FCGI_stdout, "Reason: Target broken (fstat error)\r\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
assert( get_filesize( fd) > offset );
|
}
|
||||||
assert( offset >= 0 );
|
length = (Byte8_t)sb.st_size - offset;
|
||||||
length = (OPJ_SIZE_T)(get_filesize( fd) - offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = offset;
|
pos = offset;
|
||||||
assert( pos >= 0 );
|
while( pos < offset+length-7){ // LBox+TBox-1=7
|
||||||
assert( (OPJ_OFF_T)length >= 0 );
|
|
||||||
while( pos < offset+(OPJ_OFF_T)length-7){ /* LBox+TBox-1=7*/
|
|
||||||
|
|
||||||
/* read LBox and TBox*/
|
// read LBox and TBox
|
||||||
if((data = fetch_bytes( fd, pos, 8))){
|
if((data = fetch_bytes( fd, pos, 8))){
|
||||||
headlen = 8;
|
headlen = 8;
|
||||||
boxlen = (Byte8_t)big4(data);
|
boxlen = (Byte8_t)big4(data);
|
||||||
@@ -199,13 +193,13 @@ box_param_t * gene_boxbyType( int fd, OPJ_OFF_T offset, OPJ_SIZE_T length, const
|
|||||||
if( boxlen == 1){
|
if( boxlen == 1){
|
||||||
Byte_t *data2;
|
Byte_t *data2;
|
||||||
headlen = 16;
|
headlen = 16;
|
||||||
/* read XLBox*/
|
// read XLBox
|
||||||
if((data2 = fetch_bytes( fd, pos+8, 8))){
|
if((data2 = fetch_bytes( fd, pos+8, 8))){
|
||||||
boxlen = big8(data2);
|
boxlen = big8(data2);
|
||||||
free(data2);
|
free(data2);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %" PRId64 ", %" PRId64 ", %s)\n", fd, offset, length, TBox);
|
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %lld, %lld, %s)\n", fd, offset, length, TBox);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,39 +217,41 @@ box_param_t * gene_boxbyType( int fd, OPJ_OFF_T offset, OPJ_SIZE_T length, const
|
|||||||
free( data);
|
free( data);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %" PRId64 ", %" PRId64 ", %s)\n", fd, offset, length, TBox);
|
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %lld, %lld, %s)\n", fd, offset, length, TBox);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
assert( ((Byte8_t)pos+boxlen)>=(Byte8_t)pos);
|
pos+= boxlen;
|
||||||
pos+= (OPJ_OFF_T)boxlen;
|
|
||||||
}
|
}
|
||||||
fprintf( FCGI_stderr, "Error: Box %s not found\n", TBox);
|
fprintf( FCGI_stderr, "Error: Box %s not found\n", TBox);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, OPJ_OFF_T offset, OPJ_SIZE_T length, const char TBox[])
|
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t length, char TBox[])
|
||||||
{
|
{
|
||||||
OPJ_OFF_T pos;
|
Byte8_t pos;
|
||||||
Byte_t *data;
|
Byte_t *data;
|
||||||
Byte8_t boxlen;
|
Byte8_t boxlen, headlen;
|
||||||
Byte_t headlen;
|
|
||||||
char *boxtype;
|
char *boxtype;
|
||||||
box_param_t *foundbox;
|
box_param_t *foundbox;
|
||||||
|
|
||||||
pos = offset;
|
|
||||||
assert( pos >= 0 );
|
|
||||||
assert( (OPJ_OFF_T)length >= 0 );
|
|
||||||
while( pos < offset+(OPJ_OFF_T)(length)-7){ /* LBox+TBox-1=7*/
|
|
||||||
|
|
||||||
/* read LBox and TBox*/
|
if( length<=0){ // set the max length
|
||||||
|
fprintf( FCGI_stderr, "func gene_boxbyTypeinStream(), max length must be more than 0\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos = offset;
|
||||||
|
while( pos < offset+length-7){ // LBox+TBox-1=7
|
||||||
|
|
||||||
|
// read LBox and TBox
|
||||||
data = stream + pos;
|
data = stream + pos;
|
||||||
headlen = 8;
|
headlen = 8;
|
||||||
boxlen = (Byte8_t)big4(data);
|
boxlen = (Byte8_t)big4(data);
|
||||||
boxtype = (char *)(data+4);
|
boxtype = (char *)(data+4);
|
||||||
|
|
||||||
if( boxlen == 1){
|
if( boxlen == 1){
|
||||||
/* read XLBox*/
|
// read XLBox
|
||||||
headlen = 16;
|
headlen = 16;
|
||||||
boxlen = big8( data+8);
|
boxlen = big8( data+8);
|
||||||
}
|
}
|
||||||
@@ -270,39 +266,31 @@ box_param_t * gene_boxbyTypeinStream( Byte_t *stream, OPJ_OFF_T offset, OPJ_SIZE
|
|||||||
foundbox->next = NULL;
|
foundbox->next = NULL;
|
||||||
return foundbox;
|
return foundbox;
|
||||||
}
|
}
|
||||||
assert( ((Byte8_t)pos+boxlen)>=(Byte8_t)pos);
|
pos+= boxlen;
|
||||||
pos+= (OPJ_OFF_T)boxlen;
|
|
||||||
}
|
}
|
||||||
fprintf( FCGI_stderr, "Error: Box %s not found\n", TBox);
|
fprintf( FCGI_stderr, "Error: Box %s not found\n", TBox);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
box_param_t * gene_childboxbyOffset( box_param_t *superbox, OPJ_OFF_T offset)
|
box_param_t * gene_childboxbyOffset( box_param_t *superbox, Byte8_t offset)
|
||||||
{
|
{
|
||||||
return gene_boxbyOffset( superbox->fd, get_DBoxoff( superbox)+offset);
|
return gene_boxbyOffset( superbox->fd, get_DBoxoff( superbox)+offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
box_param_t * gene_childboxbyType( box_param_t *superbox, OPJ_OFF_T offset, const char TBox[])
|
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, char TBox[])
|
||||||
{
|
{
|
||||||
OPJ_SIZE_T DBOXlen = get_DBoxlen(superbox);
|
return gene_boxbyType( superbox->fd, get_DBoxoff( superbox)+offset, get_DBoxlen( superbox)-offset, TBox);
|
||||||
assert( offset >= 0 );
|
|
||||||
if( DBOXlen < (OPJ_SIZE_T)offset )
|
|
||||||
{
|
|
||||||
fprintf( FCGI_stderr, "Error: Impossible happen %lu < %ld\n", DBOXlen, offset);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return gene_boxbyType( superbox->fd, get_DBoxoff( superbox)+offset, DBOXlen-(OPJ_SIZE_T)offset, TBox);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OPJ_OFF_T get_DBoxoff( box_param_t *box)
|
Byte8_t get_DBoxoff( box_param_t *box)
|
||||||
{
|
{
|
||||||
return box->offset+box->headlen;
|
return box->offset+box->headlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
OPJ_SIZE_T get_DBoxlen( box_param_t *box)
|
Byte8_t get_DBoxlen( box_param_t *box)
|
||||||
{
|
{
|
||||||
return box->length - box->headlen;
|
return box->length-box->headlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte_t * fetch_headbytes( box_param_t *box)
|
Byte_t * fetch_headbytes( box_param_t *box)
|
||||||
@@ -310,32 +298,32 @@ Byte_t * fetch_headbytes( box_param_t *box)
|
|||||||
return fetch_bytes( box->fd, box->offset, box->headlen);
|
return fetch_bytes( box->fd, box->offset, box->headlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte_t * fetch_DBoxbytes( box_param_t *box, OPJ_OFF_T offset, OPJ_SIZE_T size)
|
Byte_t * fetch_DBoxbytes( box_param_t *box, long offset, int size)
|
||||||
{
|
{
|
||||||
return fetch_bytes( box->fd, get_DBoxoff( box)+offset, size);
|
return fetch_bytes( box->fd, get_DBoxoff( box)+offset, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte_t fetch_DBox1byte( box_param_t *box, OPJ_OFF_T offset)
|
Byte_t fetch_DBox1byte( box_param_t *box, long offset)
|
||||||
{
|
{
|
||||||
return fetch_1byte( box->fd, get_DBoxoff( box)+offset);
|
return fetch_1byte( box->fd, get_DBoxoff( box)+offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte2_t fetch_DBox2bytebigendian( box_param_t *box, OPJ_OFF_T offset)
|
Byte2_t fetch_DBox2bytebigendian( box_param_t *box, long offset)
|
||||||
{
|
{
|
||||||
return fetch_2bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
return fetch_2bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte4_t fetch_DBox4bytebigendian( box_param_t *box, OPJ_OFF_T offset)
|
Byte4_t fetch_DBox4bytebigendian( box_param_t *box, long offset)
|
||||||
{
|
{
|
||||||
return fetch_4bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
return fetch_4bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte8_t fetch_DBox8bytebigendian( box_param_t *box, OPJ_OFF_T offset)
|
Byte8_t fetch_DBox8bytebigendian( box_param_t *box, long offset)
|
||||||
{
|
{
|
||||||
return fetch_8bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
return fetch_8bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
box_param_t * search_box( const char type[], boxlist_param_t *boxlist)
|
box_param_t * search_box( char type[], boxlist_param_t *boxlist)
|
||||||
{
|
{
|
||||||
box_param_t *foundbox;
|
box_param_t *foundbox;
|
||||||
|
|
||||||
@@ -357,10 +345,9 @@ void print_box( box_param_t *box)
|
|||||||
{
|
{
|
||||||
fprintf( logstream, "box info:\n"
|
fprintf( logstream, "box info:\n"
|
||||||
"\t type: %.4s\n"
|
"\t type: %.4s\n"
|
||||||
"\t offset: %" PRId64 " %#" PRIx64 "\n"
|
"\t offset: %lld %#llx\n"
|
||||||
"\t header length: %d\n"
|
"\t header length: %d\n"
|
||||||
"\t length: %" PRId64 " %#" PRIx64 "\n", box->type, box->offset,
|
"\t length: %lld %#llx\n", box->type, box->offset, box->offset, box->headlen, box->length, box->length);
|
||||||
box->offset, box->headlen, box->length, box->length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_allbox( boxlist_param_t *boxlist)
|
void print_allbox( boxlist_param_t *boxlist)
|
||||||
@@ -400,7 +387,7 @@ void delete_box_in_list( box_param_t **box, boxlist_param_t *boxlist)
|
|||||||
free( *box);
|
free( *box);
|
||||||
}
|
}
|
||||||
|
|
||||||
void delete_box_in_list_by_type( const char type[], boxlist_param_t *boxlist)
|
void delete_box_in_list_by_type( char type[], boxlist_param_t *boxlist)
|
||||||
{
|
{
|
||||||
box_param_t *box;
|
box_param_t *box;
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id: box_manager.h 44 2011-02-15 12:32:29Z kaori $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
@@ -31,23 +31,24 @@
|
|||||||
#ifndef BOX_MANAGER_H_
|
#ifndef BOX_MANAGER_H_
|
||||||
# define BOX_MANAGER_H_
|
# define BOX_MANAGER_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include "byte_manager.h"
|
#include "byte_manager.h"
|
||||||
|
|
||||||
/** box parameters*/
|
//! box parameters
|
||||||
typedef struct box_param{
|
typedef struct box_param{
|
||||||
int fd; /**< file descriptor*/
|
int fd; //!< file descriptor
|
||||||
OPJ_OFF_T offset; /**< byte position of the whole Box (LBox) in the file*/
|
Byte8_t offset; //!< byte position of the whole Box (LBox) in the file
|
||||||
Byte_t headlen; /**< header length 8 or 16*/
|
Byte_t headlen; //!< header length 8 or 16
|
||||||
Byte8_t length; /**< length of the whole Box*/
|
Byte8_t length; //!< length of the whole Box
|
||||||
char type[4]; /**< type of information in the DBox*/
|
char type[4]; //!< type of information in the DBox
|
||||||
struct box_param *next; /**< pointer to the next box*/
|
struct box_param *next; //!< pointer to the next box
|
||||||
} box_param_t;
|
} box_param_t;
|
||||||
|
|
||||||
|
|
||||||
/** Box list parameters*/
|
//! Box list parameters
|
||||||
typedef struct boxlist_param{
|
typedef struct boxlist_param{
|
||||||
box_param_t *first; /**< first box pointer of the list*/
|
box_param_t *first; //!< first box pointer of the list
|
||||||
box_param_t *last; /**< last box pointer of the list*/
|
box_param_t *last; //!< last box pointer of the list
|
||||||
} boxlist_param_t;
|
} boxlist_param_t;
|
||||||
|
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ typedef struct boxlist_param{
|
|||||||
*
|
*
|
||||||
* @return pointer to the generated box list
|
* @return pointer to the generated box list
|
||||||
*/
|
*/
|
||||||
boxlist_param_t * gene_boxlist(void);
|
boxlist_param_t * gene_boxlist();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get box structure of JP2 file
|
* get box structure of JP2 file
|
||||||
@@ -66,7 +67,7 @@ boxlist_param_t * gene_boxlist(void);
|
|||||||
* @param[in] length length of the decomposing region
|
* @param[in] length length of the decomposing region
|
||||||
* @return pointer to the generated boxlist
|
* @return pointer to the generated boxlist
|
||||||
*/
|
*/
|
||||||
boxlist_param_t * get_boxstructure( int fd, OPJ_OFF_T offset, OPJ_SIZE_T length);
|
boxlist_param_t * get_boxstructure( int fd, Byte8_t offset, Byte8_t length);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,7 +77,7 @@ boxlist_param_t * get_boxstructure( int fd, OPJ_OFF_T offset, OPJ_SIZE_T length)
|
|||||||
* @param[in] offset Box offset
|
* @param[in] offset Box offset
|
||||||
* @return pointer to the structure of generate box parameters
|
* @return pointer to the structure of generate box parameters
|
||||||
*/
|
*/
|
||||||
box_param_t * gene_boxbyOffset( int fd, OPJ_OFF_T offset);
|
box_param_t * gene_boxbyOffset( int fd, Byte8_t offset);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,7 +87,7 @@ box_param_t * gene_boxbyOffset( int fd, OPJ_OFF_T offset);
|
|||||||
* @param[in] offset Box offset of the whole stream
|
* @param[in] offset Box offset of the whole stream
|
||||||
* @return pointer to the structure of generate box parameters
|
* @return pointer to the structure of generate box parameters
|
||||||
*/
|
*/
|
||||||
box_param_t * gene_boxbyOffinStream( Byte_t *stream, OPJ_OFF_T offset);
|
box_param_t * gene_boxbyOffinStream( Byte_t *stream, Byte8_t offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate(search) box from JP2 file
|
* generate(search) box from JP2 file
|
||||||
@@ -97,7 +98,7 @@ box_param_t * gene_boxbyOffinStream( Byte_t *stream, OPJ_OFF_T offset);
|
|||||||
* @param[in] TBox Box Type
|
* @param[in] TBox Box Type
|
||||||
* @return pointer to the structure of generate/found box parameters
|
* @return pointer to the structure of generate/found box parameters
|
||||||
*/
|
*/
|
||||||
box_param_t * gene_boxbyType( int fd, OPJ_OFF_T offset, OPJ_SIZE_T length, const char TBox[]);
|
box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, char TBox[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate(search) box from code stream
|
* generate(search) box from code stream
|
||||||
@@ -108,7 +109,7 @@ box_param_t * gene_boxbyType( int fd, OPJ_OFF_T offset, OPJ_SIZE_T length, const
|
|||||||
* @param[in] TBox Box Type
|
* @param[in] TBox Box Type
|
||||||
* @return pointer to the structure of generate/found box parameters
|
* @return pointer to the structure of generate/found box parameters
|
||||||
*/
|
*/
|
||||||
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, OPJ_OFF_T offset, OPJ_SIZE_T length, const char TBox[]);
|
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t length, char TBox[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate child box from JP2 file at the given offset
|
* generate child box from JP2 file at the given offset
|
||||||
@@ -117,7 +118,7 @@ box_param_t * gene_boxbyTypeinStream( Byte_t *stream, OPJ_OFF_T offset, OPJ_SIZE
|
|||||||
* @param[in] offset offset from DBox first byte of superbox
|
* @param[in] offset offset from DBox first byte of superbox
|
||||||
* @return pointer to the structure of generate box parameters
|
* @return pointer to the structure of generate box parameters
|
||||||
*/
|
*/
|
||||||
box_param_t * gene_childboxbyOffset( box_param_t *superbox, OPJ_OFF_T offset);
|
box_param_t * gene_childboxbyOffset( box_param_t *superbox, Byte8_t offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate(search) box from JP2 file
|
* generate(search) box from JP2 file
|
||||||
@@ -127,7 +128,7 @@ box_param_t * gene_childboxbyOffset( box_param_t *superbox, OPJ_OFF_T offset);
|
|||||||
* @param[in] TBox Box Type
|
* @param[in] TBox Box Type
|
||||||
* @return pointer to the structure of generate/found box parameters
|
* @return pointer to the structure of generate/found box parameters
|
||||||
*/
|
*/
|
||||||
box_param_t * gene_childboxbyType( box_param_t *superbox, OPJ_OFF_T offset, const char TBox[]);
|
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, char TBox[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get DBox offset
|
* get DBox offset
|
||||||
@@ -135,7 +136,7 @@ box_param_t * gene_childboxbyType( box_param_t *superbox, OPJ_OFF_T offset, cons
|
|||||||
* @param[in] box box pointer
|
* @param[in] box box pointer
|
||||||
* @return DBox offset (byte position) in the file
|
* @return DBox offset (byte position) in the file
|
||||||
*/
|
*/
|
||||||
OPJ_OFF_T get_DBoxoff( box_param_t *box);
|
Byte8_t get_DBoxoff( box_param_t *box);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,7 +145,7 @@ OPJ_OFF_T get_DBoxoff( box_param_t *box);
|
|||||||
* @param[in] box box pointer
|
* @param[in] box box pointer
|
||||||
* @return DBox length ( content length)
|
* @return DBox length ( content length)
|
||||||
*/
|
*/
|
||||||
OPJ_SIZE_T get_DBoxlen( box_param_t *box);
|
Byte8_t get_DBoxlen( box_param_t *box);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,7 +165,7 @@ Byte_t * fetch_headbytes( box_param_t *box);
|
|||||||
* @param[in] size Byte length
|
* @param[in] size Byte length
|
||||||
* @return pointer to the fetched data
|
* @return pointer to the fetched data
|
||||||
*/
|
*/
|
||||||
Byte_t * fetch_DBoxbytes( box_param_t *box, OPJ_OFF_T offset, OPJ_SIZE_T size);
|
Byte_t * fetch_DBoxbytes( box_param_t *box, long offset, int size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch DBox (Box Contents) 1-byte Byte codes in file stream
|
* fetch DBox (Box Contents) 1-byte Byte codes in file stream
|
||||||
@@ -173,7 +174,7 @@ Byte_t * fetch_DBoxbytes( box_param_t *box, OPJ_OFF_T offset, OPJ_SIZE_T size);
|
|||||||
* @param[in] offset start Byte position in DBox
|
* @param[in] offset start Byte position in DBox
|
||||||
* @return fetched code
|
* @return fetched code
|
||||||
*/
|
*/
|
||||||
Byte_t fetch_DBox1byte( box_param_t *box, OPJ_OFF_T offset);
|
Byte_t fetch_DBox1byte( box_param_t *box, long offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch DBox (Box Contents) 2-byte big endian Byte codes in file stream
|
* fetch DBox (Box Contents) 2-byte big endian Byte codes in file stream
|
||||||
@@ -182,7 +183,7 @@ Byte_t fetch_DBox1byte( box_param_t *box, OPJ_OFF_T offset);
|
|||||||
* @param[in] offset start Byte position in DBox
|
* @param[in] offset start Byte position in DBox
|
||||||
* @return fetched code
|
* @return fetched code
|
||||||
*/
|
*/
|
||||||
Byte2_t fetch_DBox2bytebigendian( box_param_t *box, OPJ_OFF_T offset);
|
Byte2_t fetch_DBox2bytebigendian( box_param_t *box, long offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch DBox (Box Contents) 4-byte big endian Byte codes in file stream
|
* fetch DBox (Box Contents) 4-byte big endian Byte codes in file stream
|
||||||
@@ -191,7 +192,7 @@ Byte2_t fetch_DBox2bytebigendian( box_param_t *box, OPJ_OFF_T offset);
|
|||||||
* @param[in] offset start Byte position in DBox
|
* @param[in] offset start Byte position in DBox
|
||||||
* @return fetched code
|
* @return fetched code
|
||||||
*/
|
*/
|
||||||
Byte4_t fetch_DBox4bytebigendian( box_param_t *box, OPJ_OFF_T offset);
|
Byte4_t fetch_DBox4bytebigendian( box_param_t *box, long offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch DBox (Box Contents) 8-byte big endian Byte codes in file stream
|
* fetch DBox (Box Contents) 8-byte big endian Byte codes in file stream
|
||||||
@@ -200,7 +201,7 @@ Byte4_t fetch_DBox4bytebigendian( box_param_t *box, OPJ_OFF_T offset);
|
|||||||
* @param[in] offset start Byte position in DBox
|
* @param[in] offset start Byte position in DBox
|
||||||
* @return fetched code
|
* @return fetched code
|
||||||
*/
|
*/
|
||||||
Byte8_t fetch_DBox8bytebigendian( box_param_t *box, OPJ_OFF_T offset);
|
Byte8_t fetch_DBox8bytebigendian( box_param_t *box, long offset);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -210,7 +211,7 @@ Byte8_t fetch_DBox8bytebigendian( box_param_t *box, OPJ_OFF_T offset);
|
|||||||
* @param[in] boxlist box list pointer
|
* @param[in] boxlist box list pointer
|
||||||
* @return found box pointer
|
* @return found box pointer
|
||||||
*/
|
*/
|
||||||
box_param_t * search_box( const char type[], boxlist_param_t *boxlist);
|
box_param_t * search_box( char type[], boxlist_param_t *boxlist);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* print box parameters
|
* print box parameters
|
||||||
@@ -242,7 +243,7 @@ void delete_box_in_list( box_param_t **box, boxlist_param_t *boxlist);
|
|||||||
* @param[in,out] type box type
|
* @param[in,out] type box type
|
||||||
* @param[in] boxlist box list pointer
|
* @param[in] boxlist box list pointer
|
||||||
*/
|
*/
|
||||||
void delete_box_in_list_by_type( const char type[], boxlist_param_t *boxlist);
|
void delete_box_in_list_by_type( char type[], boxlist_param_t *boxlist);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id: boxheader_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
@@ -28,12 +28,10 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "boxheader_manager.h"
|
#include "boxheader_manager.h"
|
||||||
#include "opj_inttypes.h"
|
|
||||||
|
|
||||||
#ifdef SERVER
|
#ifdef SERVER
|
||||||
#include "fcgi_stdio.h"
|
#include "fcgi_stdio.h"
|
||||||
@@ -42,10 +40,10 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif /*SERVER*/
|
#endif //SERVER
|
||||||
|
|
||||||
|
|
||||||
boxheader_param_t * gene_boxheader( int fd, OPJ_OFF_T offset)
|
boxheader_param_t * gene_boxheader( int fd, Byte8_t offset)
|
||||||
{
|
{
|
||||||
Byte8_t boxlen;
|
Byte8_t boxlen;
|
||||||
Byte_t headlen;
|
Byte_t headlen;
|
||||||
@@ -56,11 +54,10 @@ boxheader_param_t * gene_boxheader( int fd, OPJ_OFF_T offset)
|
|||||||
boxtype = (char *)fetch_bytes( fd, offset+4, 4);
|
boxtype = (char *)fetch_bytes( fd, offset+4, 4);
|
||||||
headlen = 8;
|
headlen = 8;
|
||||||
|
|
||||||
if( boxlen == 1){ /* read XLBox */
|
if( boxlen == 1){ // read XLBox
|
||||||
boxlen = fetch_8bytebigendian( fd, offset+8);
|
boxlen = fetch_8bytebigendian( fd, offset+8);
|
||||||
headlen = 16;
|
headlen = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
boxheader = (boxheader_param_t *)malloc( sizeof( boxheader_param_t));
|
boxheader = (boxheader_param_t *)malloc( sizeof( boxheader_param_t));
|
||||||
boxheader->headlen = headlen;
|
boxheader->headlen = headlen;
|
||||||
boxheader->length = boxlen;
|
boxheader->length = boxlen;
|
||||||
@@ -71,14 +68,14 @@ boxheader_param_t * gene_boxheader( int fd, OPJ_OFF_T offset)
|
|||||||
return boxheader;
|
return boxheader;
|
||||||
}
|
}
|
||||||
|
|
||||||
boxheader_param_t * gene_childboxheader( box_param_t *superbox, OPJ_OFF_T offset)
|
boxheader_param_t * gene_childboxheader( box_param_t *superbox, Byte8_t offset)
|
||||||
{
|
{
|
||||||
return gene_boxheader( superbox->fd, get_DBoxoff(superbox)+offset);
|
return gene_boxheader( superbox->fd, get_DBoxoff( superbox)+offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_boxheader( boxheader_param_t *boxheader)
|
void print_boxheader( boxheader_param_t *boxheader)
|
||||||
{
|
{
|
||||||
fprintf( logstream, "boxheader info:\n"
|
fprintf( logstream, "boxheader info:\n"
|
||||||
"\t type: %.4s\n"
|
"\t type: %.4s\n"
|
||||||
"\t length:%" PRId64 " %#" PRIx64 "\n", boxheader->type, boxheader->length, boxheader->length);
|
"\t length:%lld %#llx\n", boxheader->type, boxheader->length, boxheader->length);
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id: boxheader_manager.h 44 2011-02-15 12:32:29Z kaori $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
@@ -34,12 +34,12 @@
|
|||||||
#include "byte_manager.h"
|
#include "byte_manager.h"
|
||||||
#include "box_manager.h"
|
#include "box_manager.h"
|
||||||
|
|
||||||
/** box header parameters*/
|
//! box header parameters
|
||||||
typedef struct boxheader_param{
|
typedef struct boxheader_param{
|
||||||
Byte_t headlen; /**< header length 8 or 16*/
|
Byte_t headlen; //!< header length 8 or 16
|
||||||
Byte8_t length; /**< length of the reference Box*/
|
Byte8_t length; //!< length of the reference Box
|
||||||
char type[4]; /**< type of information in the DBox*/
|
char type[4]; //!< type of information in the DBox
|
||||||
struct boxheader_param *next; /**< pointer to the next header box*/
|
struct boxheader_param *next; //!< pointer to the next header box
|
||||||
} boxheader_param_t;
|
} boxheader_param_t;
|
||||||
|
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ typedef struct boxheader_param{
|
|||||||
* @param[in] offset Box offset
|
* @param[in] offset Box offset
|
||||||
* @return pointer to the structure of generate box header parameters
|
* @return pointer to the structure of generate box header parameters
|
||||||
*/
|
*/
|
||||||
boxheader_param_t * gene_boxheader( int fd, OPJ_OFF_T offset);
|
boxheader_param_t * gene_boxheader( int fd, Byte8_t offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate a child box header at the given offset
|
* generate a child box header at the given offset
|
||||||
@@ -59,7 +59,7 @@ boxheader_param_t * gene_boxheader( int fd, OPJ_OFF_T offset);
|
|||||||
* @param[in] offset offset from DBox first byte of superbox
|
* @param[in] offset offset from DBox first byte of superbox
|
||||||
* @return pointer to the structure of generate box header parameters
|
* @return pointer to the structure of generate box header parameters
|
||||||
*/
|
*/
|
||||||
boxheader_param_t * gene_childboxheader( box_param_t *superbox, OPJ_OFF_T offset);
|
boxheader_param_t * gene_childboxheader( box_param_t *superbox, Byte8_t offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* print box header parameters
|
* print box header parameters
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id: byte_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
@@ -28,15 +28,9 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <io.h>
|
|
||||||
#else
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
#include "byte_manager.h"
|
#include "byte_manager.h"
|
||||||
|
|
||||||
#ifdef SERVER
|
#ifdef SERVER
|
||||||
@@ -46,31 +40,31 @@
|
|||||||
#define FCGI_stdout stdout
|
#define FCGI_stdout stdout
|
||||||
#define FCGI_stderr stderr
|
#define FCGI_stderr stderr
|
||||||
#define logstream stderr
|
#define logstream stderr
|
||||||
#endif /*SERVER*/
|
#endif //SERVER
|
||||||
|
|
||||||
|
|
||||||
Byte_t * fetch_bytes( int fd, OPJ_OFF_T offset, OPJ_SIZE_T size)
|
Byte_t * fetch_bytes( int fd, long offset, int size)
|
||||||
{
|
{
|
||||||
Byte_t *data;
|
Byte_t *data;
|
||||||
|
|
||||||
if( lseek( fd, offset, SEEK_SET)==-1){
|
if( lseek( fd, offset, SEEK_SET)==-1){
|
||||||
fprintf( FCGI_stdout, "Reason: Target broken (fseek error)\r\n");
|
fprintf( FCGI_stdout, "Reason: Target broken (fseek error)\r\n");
|
||||||
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld, %lu)\n", fd, offset, size);
|
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld, %d)\n", fd, offset, size);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = (Byte_t *)malloc( size);
|
data = (Byte_t *)malloc( size);
|
||||||
|
|
||||||
if( (OPJ_SIZE_T)read( fd, data, size) != size){
|
if( read( fd, data, size) != size){
|
||||||
free( data);
|
free( data);
|
||||||
fprintf( FCGI_stdout, "Reason: Target broken (read error)\r\n");
|
fprintf( FCGI_stdout, "Reason: Target broken (read error)\r\n");
|
||||||
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld, %lu)\n", fd, offset, size);
|
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld, %d)\n", fd, offset, size);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte_t fetch_1byte( int fd, OPJ_OFF_T offset)
|
Byte_t fetch_1byte( int fd, long offset)
|
||||||
{
|
{
|
||||||
Byte_t code;
|
Byte_t code;
|
||||||
|
|
||||||
@@ -88,7 +82,7 @@ Byte_t fetch_1byte( int fd, OPJ_OFF_T offset)
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte2_t fetch_2bytebigendian( int fd, OPJ_OFF_T offset)
|
Byte2_t fetch_2bytebigendian( int fd, long offset)
|
||||||
{
|
{
|
||||||
Byte_t *data;
|
Byte_t *data;
|
||||||
Byte2_t code;
|
Byte2_t code;
|
||||||
@@ -103,7 +97,7 @@ Byte2_t fetch_2bytebigendian( int fd, OPJ_OFF_T offset)
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte4_t fetch_4bytebigendian( int fd, OPJ_OFF_T offset)
|
Byte4_t fetch_4bytebigendian( int fd, long offset)
|
||||||
{
|
{
|
||||||
Byte_t *data;
|
Byte_t *data;
|
||||||
Byte4_t code;
|
Byte4_t code;
|
||||||
@@ -118,7 +112,7 @@ Byte4_t fetch_4bytebigendian( int fd, OPJ_OFF_T offset)
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte8_t fetch_8bytebigendian( int fd, OPJ_OFF_T offset)
|
Byte8_t fetch_8bytebigendian( int fd, long offset)
|
||||||
{
|
{
|
||||||
Byte_t *data;
|
Byte_t *data;
|
||||||
Byte8_t code;
|
Byte8_t code;
|
||||||
@@ -136,7 +130,7 @@ Byte8_t fetch_8bytebigendian( int fd, OPJ_OFF_T offset)
|
|||||||
|
|
||||||
Byte2_t big2( Byte_t *buf)
|
Byte2_t big2( Byte_t *buf)
|
||||||
{
|
{
|
||||||
return (Byte2_t)((((Byte2_t) buf[0]) << 8) + ((Byte2_t) buf[1]));
|
return (((Byte2_t) buf[0]) << 8) + ((Byte2_t) buf[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte4_t big4( Byte_t *buf)
|
Byte4_t big4( Byte_t *buf)
|
||||||
@@ -150,23 +144,3 @@ Byte8_t big8( Byte_t *buf)
|
|||||||
return (((Byte8_t) big4 (buf)) << 32)
|
return (((Byte8_t) big4 (buf)) << 32)
|
||||||
+ ((Byte8_t) big4 (buf + 4));
|
+ ((Byte8_t) big4 (buf + 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
void modify_4Bytecode( Byte4_t code, Byte_t *stream)
|
|
||||||
{
|
|
||||||
*stream = (Byte_t) ((Byte4_t)(code & 0xff000000) >> 24);
|
|
||||||
*(stream+1) = (Byte_t) ((Byte4_t)(code & 0x00ff0000) >> 16);
|
|
||||||
*(stream+2) = (Byte_t) ((Byte4_t)(code & 0x0000ff00) >> 8);
|
|
||||||
*(stream+3) = (Byte_t) (code & 0x000000ff);
|
|
||||||
}
|
|
||||||
|
|
||||||
OPJ_OFF_T get_filesize( int fd)
|
|
||||||
{
|
|
||||||
struct stat sb;
|
|
||||||
|
|
||||||
if( fstat( fd, &sb) == -1){
|
|
||||||
fprintf( FCGI_stdout, "Reason: Target broken (fstat error)\r\n");
|
|
||||||
fprintf( FCGI_stderr, "Error: error in get_filesize( %d)\n", fd);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return sb.st_size;
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id: byte_manager.h 44 2011-02-15 12:32:29Z kaori $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||||
@@ -29,14 +29,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BYTE_MANAGER_H_
|
#ifndef BYTE_MANAGER_H_
|
||||||
#define BYTE_MANAGER_H_
|
# define BYTE_MANAGER_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
//! 1Byte parameter type
|
||||||
|
typedef unsigned char Byte_t;
|
||||||
|
|
||||||
|
//! 2Byte parameter type
|
||||||
|
typedef unsigned short int Byte2_t;
|
||||||
|
|
||||||
|
//! 4Byte parameter type
|
||||||
|
typedef unsigned int Byte4_t;
|
||||||
|
|
||||||
|
//! 8Byte parameter type
|
||||||
|
typedef unsigned long long int Byte8_t;
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include "opj_stdint.h"
|
|
||||||
typedef uint8_t Byte_t;
|
|
||||||
typedef uint16_t Byte2_t;
|
|
||||||
typedef uint32_t Byte4_t;
|
|
||||||
typedef uint64_t Byte8_t;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch bytes of data in file stream
|
* fetch bytes of data in file stream
|
||||||
@@ -46,7 +54,7 @@ typedef uint64_t Byte8_t;
|
|||||||
* @param[in] size Byte length
|
* @param[in] size Byte length
|
||||||
* @return pointer to the fetched data
|
* @return pointer to the fetched data
|
||||||
*/
|
*/
|
||||||
Byte_t * fetch_bytes( int fd, OPJ_OFF_T offset, OPJ_SIZE_T size);
|
Byte_t * fetch_bytes( int fd, long offset, int size);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,7 +64,7 @@ Byte_t * fetch_bytes( int fd, OPJ_OFF_T offset, OPJ_SIZE_T size);
|
|||||||
* @param[in] offset start Byte position
|
* @param[in] offset start Byte position
|
||||||
* @return fetched codes
|
* @return fetched codes
|
||||||
*/
|
*/
|
||||||
Byte_t fetch_1byte( int fd, OPJ_OFF_T offset);
|
Byte_t fetch_1byte( int fd, long offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch a 2-byte big endian Byte codes in file stream
|
* fetch a 2-byte big endian Byte codes in file stream
|
||||||
@@ -65,7 +73,7 @@ Byte_t fetch_1byte( int fd, OPJ_OFF_T offset);
|
|||||||
* @param[in] offset start Byte position
|
* @param[in] offset start Byte position
|
||||||
* @return fetched codes
|
* @return fetched codes
|
||||||
*/
|
*/
|
||||||
Byte2_t fetch_2bytebigendian( int fd, OPJ_OFF_T offset);
|
Byte2_t fetch_2bytebigendian( int fd, long offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch a 4-byte big endian Byte codes in file stream
|
* fetch a 4-byte big endian Byte codes in file stream
|
||||||
@@ -74,7 +82,7 @@ Byte2_t fetch_2bytebigendian( int fd, OPJ_OFF_T offset);
|
|||||||
* @param[in] offset start Byte position
|
* @param[in] offset start Byte position
|
||||||
* @return fetched codes
|
* @return fetched codes
|
||||||
*/
|
*/
|
||||||
Byte4_t fetch_4bytebigendian( int fd, OPJ_OFF_T offset);
|
Byte4_t fetch_4bytebigendian( int fd, long offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch a 8-byte big endian Byte codes in file stream
|
* fetch a 8-byte big endian Byte codes in file stream
|
||||||
@@ -83,7 +91,7 @@ Byte4_t fetch_4bytebigendian( int fd, OPJ_OFF_T offset);
|
|||||||
* @param[in] offset start Byte position
|
* @param[in] offset start Byte position
|
||||||
* @return fetched codes
|
* @return fetched codes
|
||||||
*/
|
*/
|
||||||
Byte8_t fetch_8bytebigendian( int fd, OPJ_OFF_T offset);
|
Byte8_t fetch_8bytebigendian( int fd, long offset);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,20 +118,5 @@ Byte4_t big4( Byte_t *buf);
|
|||||||
*/
|
*/
|
||||||
Byte8_t big8( Byte_t *buf);
|
Byte8_t big8( Byte_t *buf);
|
||||||
|
|
||||||
/**
|
|
||||||
* modify 4Byte code in a codestream
|
|
||||||
*
|
|
||||||
* @param[in] code code value
|
|
||||||
* @param[out] stream modifying codestream
|
|
||||||
*/
|
|
||||||
void modify_4Bytecode( Byte4_t code, Byte_t *stream);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get file size
|
|
||||||
*
|
|
||||||
* @param[in] fd file discriptor
|
|
||||||
* @return file size
|
|
||||||
*/
|
|
||||||
OPJ_OFF_T get_filesize( int fd);
|
|
||||||
|
|
||||||
#endif /* !BYTE_MANAGER_H_ */
|
#endif /* !BYTE_MANAGER_H_ */
|
||||||