Compare commits
3 Commits
openjpeg-1
...
version.1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d97b181d3 | ||
|
|
d9b74ea6a8 | ||
|
|
166b42eb54 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,4 +0,0 @@
|
||||
|
||||
CMakeLists.txt.user
|
||||
|
||||
*.bak
|
||||
@@ -28,7 +28,5 @@ SET(CTEST_CUSTOM_WARNING_EXCEPTION
|
||||
# Suppress warning caused by intentional messages about deprecation
|
||||
".*warning,.* is deprecated"
|
||||
# supress warnings caused by 3rd party libs:
|
||||
".*thirdparty.*"
|
||||
"libtiff.*has no symbols"
|
||||
"libpng.*has no symbols"
|
||||
".*/thirdparty/.*"
|
||||
)
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# cppcheck
|
||||
#
|
||||
# Copyright (c) 2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
|
||||
find_program(CPPCHECK_EXECUTABLE
|
||||
cppcheck
|
||||
)
|
||||
|
||||
mark_as_advanced(
|
||||
CPPCHECK_EXECUTABLE
|
||||
)
|
||||
@@ -17,4 +17,4 @@ ELSE(FCGI_FOUND)
|
||||
SET(FCGI_INCLUDE_DIRS)
|
||||
ENDIF(FCGI_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(FCGI_INCLUDE_DIR FCGI_LIBRARY)
|
||||
MARK_AS_ADVANCED(FCGI_INCLUDE_DIRS FCGI_LIBRARIES)
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#
|
||||
# this module looks for JPYLYZER
|
||||
# http://jpylyzer.openpreservation.org
|
||||
#
|
||||
|
||||
find_program(JPYLYZER_EXECUTABLE
|
||||
jpylyzer
|
||||
)
|
||||
|
||||
mark_as_advanced(
|
||||
JPYLYZER_EXECUTABLE
|
||||
)
|
||||
20
CMake/FindPTHREAD.cmake
Normal file
20
CMake/FindPTHREAD.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
# Look for the header file.
|
||||
FIND_PATH(PTHREAD_INCLUDE_DIR NAMES pthread.h)
|
||||
|
||||
# Look for the library.
|
||||
FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthread)
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set PTHREAD_FOUND to TRUE if all listed variables are TRUE.
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PTHREAD DEFAULT_MSG PTHREAD_LIBRARY PTHREAD_INCLUDE_DIR)
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(PTHREAD_FOUND)
|
||||
SET(PTHREAD_LIBRARIES ${PTHREAD_LIBRARY})
|
||||
SET(PTHREAD_INCLUDE_DIRS ${PTHREAD_INCLUDE_DIR})
|
||||
ELSE(PTHREAD_FOUND)
|
||||
SET(PTHREAD_LIBRARIES)
|
||||
SET(PTHREAD_INCLUDE_DIRS)
|
||||
ENDIF(PTHREAD_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(PTHREAD_INCLUDE_DIRS PTHREAD_LIBRARIES)
|
||||
@@ -11,28 +11,22 @@ SET(OPENJPEG_MINOR_VERSION "@OPENJPEG_VERSION_MINOR@")
|
||||
SET(OPENJPEG_BUILD_VERSION "@OPENJPEG_VERSION_BUILD@")
|
||||
|
||||
# The libraries.
|
||||
SET(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARY_NAME@")
|
||||
SET(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARIES@")
|
||||
|
||||
# The CMake macros dir.
|
||||
SET(OPENJPEG_CMAKE_DIR "@OPENJPEG_INSTALL_PACKAGE_DIR@")
|
||||
SET(OPENJPEG_CMAKE_DIR "@OPENJPEG_CMAKE_DIR_CONFIG@")
|
||||
|
||||
# The configuration options.
|
||||
SET(OPENJPEG_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
|
||||
SET(OPENJPEG_BUILD_SHARED_LIBS "@OPENJPEG_BUILD_SHARED_LIBS@")
|
||||
|
||||
# The "use" file.
|
||||
SET(OPENJPEG_USE_FILE "@OPENJPEG_USE_FILE_CONFIG@")
|
||||
|
||||
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
# The following is inspired from:
|
||||
# http://www.cmake.org/Wiki/CMake/Tutorials/Packaging#Packaging_and_Exporting
|
||||
# However the following is difficult to handle:
|
||||
# get_filename_component(myproj_INCLUDE_DIRS "${SELF_DIR}/../../include/myproj" ABSOLUTE)
|
||||
# it asssumes a non multi-arch system, where 'include' is located '../include' from lib
|
||||
# therefore we need to take into account the number of subdirs in OPENJPEG_INSTALL_LIB_DIR
|
||||
if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||
# This is an install tree
|
||||
include(${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/@relative_parent@/@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})
|
||||
|
||||
else(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||
|
||||
@@ -11,9 +11,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
|
||||
IF(COMMAND CMAKE_POLICY)
|
||||
CMAKE_POLICY(SET CMP0003 NEW)
|
||||
if (NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
endif()
|
||||
ENDIF(COMMAND CMAKE_POLICY)
|
||||
|
||||
IF(NOT OPENJPEG_NAMESPACE)
|
||||
@@ -32,32 +29,14 @@ INCLUDE_REGULAR_EXPRESSION("^.*$")
|
||||
# OPENJPEG version number, useful for packaging and doxygen doc:
|
||||
SET(OPENJPEG_VERSION_MAJOR 1)
|
||||
SET(OPENJPEG_VERSION_MINOR 5)
|
||||
SET(OPENJPEG_VERSION_BUILD 3)
|
||||
SET(OPENJPEG_VERSION_BUILD 0)
|
||||
SET(OPENJPEG_VERSION
|
||||
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||
SET(PACKAGE_VERSION
|
||||
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||
|
||||
# Because autotools does not support X.Y notation for SOVERSION, we have to use
|
||||
# two numerorations, 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 5)
|
||||
endif(NOT OPENJPEG_SOVERSION)
|
||||
SET(OPENJPEG_LIBRARY_PROPERTIES
|
||||
VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
|
||||
SOVERSION "${OPENJPEG_SOVERSION}"
|
||||
SOVERSION "${OPENJPEG_VERSION_MAJOR}"
|
||||
)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
@@ -107,18 +86,6 @@ IF(NOT OPENJPEG_INSTALL_LIB_DIR)
|
||||
SET(OPENJPEG_INSTALL_LIB_DIR "lib")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_LIB_DIR)
|
||||
|
||||
# The following will compute the amount of parent dir to go
|
||||
# from include to lib. it works nicely with
|
||||
# OPENJPEG_INSTALL_LIB_DIR=lib
|
||||
# OPENJPEG_INSTALL_LIB_DIR=lib/
|
||||
# OPENJPEG_INSTALL_LIB_DIR=/lib
|
||||
# OPENJPEG_INSTALL_LIB_DIR=lib/gnu-linux-x64
|
||||
STRING(REPLACE "/" ";" relative_to_lib ${OPENJPEG_INSTALL_LIB_DIR})
|
||||
set(relative_parent "..")
|
||||
foreach( elem ${relative_to_lib})
|
||||
set( relative_parent "${relative_parent}/.." )
|
||||
endforeach()
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
||||
SET(OPENJPEG_INSTALL_SHARE_DIR "share")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
||||
@@ -128,7 +95,7 @@ IF(NOT OPENJPEG_INSTALL_DATA_DIR)
|
||||
ENDIF(NOT OPENJPEG_INSTALL_DATA_DIR)
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||
SET(OPENJPEG_INSTALL_INCLUDE_DIR "include/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
SET(OPENJPEG_INSTALL_INCLUDE_DIR "include/")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_MAN_DIR)
|
||||
@@ -139,19 +106,8 @@ IF(NOT OPENJPEG_INSTALL_DOC_DIR)
|
||||
SET(OPENJPEG_INSTALL_DOC_DIR "share/doc/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_DOC_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}")
|
||||
SET(OPENJPEG_INSTALL_PACKAGE_DIR "${OPENJPEG_INSTALL_SHARE_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@@ -187,14 +143,13 @@ ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
||||
#-----------------------------------------------------------------------------
|
||||
# pkgconfig support
|
||||
IF(UNIX)
|
||||
# install in lib and not share (see multi-arch note above)
|
||||
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 )
|
||||
${OPENJPEG_INSTALL_SHARE_DIR}/pkgconfig )
|
||||
INSTALL( CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
\"libopenjpeg1.pc\"
|
||||
\"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_SHARE_DIR}/pkgconfig/libopenjpeg.pc\")")
|
||||
\"\$ENV{DESTDIR}${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig/libopenjpeg.pc\")")
|
||||
ENDIF(UNIX)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@@ -203,7 +158,7 @@ IF(CMAKE_COMPILER_IS_GNUCC)
|
||||
# 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.
|
||||
# Do not use ffast-math for all build, it would produce incorrect results, only set for release:
|
||||
SET(OPENJPEG_LIBRARY_COMPILE_OPTIONS ${OPENJPEG_LIBRARY_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>")
|
||||
SET(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCC)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@@ -236,8 +191,6 @@ IF(BUILD_JPIP)
|
||||
ENDIF(BUILD_JPIP)
|
||||
OPTION(BUILD_VIEWER "Build the OPJViewer executable (C++)" OFF)
|
||||
OPTION(BUILD_JAVA "Build the openjpeg jar (Java)" OFF)
|
||||
OPTION(USE_SYSTEM_GETOPT "Prefer system installed getopt()" OFF)
|
||||
MARK_AS_ADVANCED(USE_SYSTEM_GETOPT)
|
||||
MARK_AS_ADVANCED(BUILD_VIEWER)
|
||||
MARK_AS_ADVANCED(BUILD_JAVA)
|
||||
|
||||
@@ -275,9 +228,9 @@ IF(BUILD_TESTING)
|
||||
# They could be found via svn on the OpenJPEG google code project
|
||||
# svn checkout http://openjpeg.googlecode.com/svn/data (about 70 Mo)
|
||||
FIND_PATH(OPJ_DATA_ROOT README-OPJ-Data
|
||||
PATHS $ENV{OPJ_DATA_ROOT} ${CMAKE_SOURCE_DIR}/../data
|
||||
${CMAKE_SOURCE_DIR}/../../data
|
||||
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
|
||||
PATHS
|
||||
$ENV{OPJ_DATA_ROOT}
|
||||
${CMAKE_SOURCE_DIR}/../data
|
||||
)
|
||||
|
||||
# Add repository where to find tests
|
||||
@@ -301,9 +254,9 @@ INSTALL( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# install CHANGES and LICENSE
|
||||
IF(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
|
||||
INSTALL(FILES CHANGES DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||
ENDIF(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
|
||||
INSTALL(FILES LICENSE DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||
INSTALL(
|
||||
FILES CHANGES
|
||||
LICENSE
|
||||
DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||
|
||||
INCLUDE (CMake/OpenJPEGCPack.cmake)
|
||||
|
||||
11
INSTALL
11
INSTALL
@@ -66,13 +66,12 @@ Type:
|
||||
|
||||
If you are root:
|
||||
make install
|
||||
make clean
|
||||
|
||||
else if you have sudo power:
|
||||
else:
|
||||
sudo make install
|
||||
|
||||
else
|
||||
DESTDIR=$HOME/local make install
|
||||
|
||||
make clean
|
||||
|
||||
To build the Doxygen documentation (Doxygen needs to be found on the system):
|
||||
(A 'html' directory is generated in the 'doc' directory)
|
||||
make doc
|
||||
@@ -80,7 +79,7 @@ To build the Doxygen documentation (Doxygen needs to be found on the system):
|
||||
Binaries are located in the 'bin' directory.
|
||||
|
||||
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')
|
||||
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')
|
||||
|
||||
34
NEWS
34
NEWS
@@ -2,23 +2,33 @@
|
||||
OpenJPEG NEWS - user visible changes
|
||||
====================================
|
||||
|
||||
Changes from OpenJPEG 1.5.1 to OpenJPEG 1.5.0
|
||||
Changes from OpenJPEG 1.4.0 to OpenJPEG 1.5.0
|
||||
----------------------------------------------
|
||||
|
||||
Security:
|
||||
|
||||
* Fixes: CVE-2012-3535
|
||||
* Fixes: CVE-2012-3358
|
||||
|
||||
New Features:
|
||||
|
||||
* Use a new API scheme and solve the SOVERSIONing in OpenJPEG
|
||||
* Allow better integration with multi-arch system
|
||||
* Compile & Install Java bindings (CMake)
|
||||
* Install required addXMLinJP2 (JPIP)
|
||||
* openjpip:
|
||||
- complete client-server architecture for remote browsing of jpeg 2000 images.
|
||||
- located in 'applications/jpip'.
|
||||
- see corresponding README for more details.
|
||||
|
||||
API modifications:
|
||||
|
||||
* 'bool' type has been replaced by 'opj_bool' type. 'stdbool.h' is no more required.
|
||||
|
||||
Misc:
|
||||
|
||||
* fix linker error by resolving all symbols (eg. missing -lm)
|
||||
* fix some man page typos
|
||||
* added this NEWS file.
|
||||
* improved cmake and autotools build methods.
|
||||
* removed manual makefiles, VS project files and XCode project files.
|
||||
* added a 'thirdparty' directory to contain all dependencies.
|
||||
- These libraries will be build only if there are not found on the system.
|
||||
- Note that libopenjpeg itself does not have any dependency.
|
||||
* changed the directory hierarchy of the whole project. See README files for details.
|
||||
* tests : a complete test suite has been setup.
|
||||
- both JPEG 2000 conformance tests and non-regressions tests are configured.
|
||||
- results are submitted to the OpenJPEG dashboard (http://my.cdash.org/index.php?project=OPENJPEG)
|
||||
- images are located in 'http://openjpeg.googlecode.com/svn/data' folder.
|
||||
- configuration files and utilities are located in 'tests' folder.
|
||||
* OPJViewer re-activated (need wxWidgets)
|
||||
* Huge amount of bug fixes. See CHANGES for details.
|
||||
|
||||
@@ -4,15 +4,7 @@
|
||||
SET(openjpegjni_SRCS
|
||||
JavaOpenJPEGDecoder.c
|
||||
JavaOpenJPEG.c
|
||||
${OPENJPEG_SOURCE_DIR}/applications/codec/index.c
|
||||
${OPENJPEG_SOURCE_DIR}/applications/codec/convert.c
|
||||
#${OPENJPEG_SOURCE_DIR}/applications/common/color.c
|
||||
)
|
||||
if(NOT USE_SYSTEM_GETOPT)
|
||||
list(APPEND openjpegjni_SRCS
|
||||
${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c
|
||||
)
|
||||
endif()
|
||||
|
||||
# JNI binding:
|
||||
find_package(JNI REQUIRED)
|
||||
@@ -28,31 +20,10 @@ include_directories(
|
||||
add_library(openjpegjni MODULE
|
||||
${openjpegjni_SRCS}
|
||||
)
|
||||
# Java module should not have a SONAME:
|
||||
set_property(TARGET openjpegjni PROPERTY NO_SONAME 1)
|
||||
|
||||
TARGET_LINK_LIBRARIES(openjpegjni ${OPENJPEG_LIBRARY_NAME})
|
||||
|
||||
if(UNIX)
|
||||
target_link_libraries(openjpegjni m)
|
||||
endif()
|
||||
|
||||
INSTALL(TARGETS openjpegjni
|
||||
EXPORT OpenJPEGTargets
|
||||
LIBRARY DESTINATION ${OPENJPEG_INSTALL_JNI_DIR} COMPONENT Libraries
|
||||
)
|
||||
|
||||
# build jar:
|
||||
FIND_PACKAGE(Java 1.5 REQUIRED) # javac, jar
|
||||
|
||||
# User can override this:
|
||||
if(NOT DEFINED JAVA_SOURCE_VERSION)
|
||||
set(JAVA_SOURCE_VERSION 1.5)
|
||||
endif()
|
||||
if(NOT DEFINED JAVA_TARGET_VERSION)
|
||||
set(JAVA_TARGET_VERSION 1.5)
|
||||
endif()
|
||||
|
||||
# build dep list:
|
||||
file(GLOB java_srcs "java-sources/org/openJpeg/*.java")
|
||||
|
||||
@@ -61,9 +32,7 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes)
|
||||
# Build java
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
||||
COMMAND ${Java_JAVAC_EXECUTABLE}
|
||||
-source ${JAVA_SOURCE_VERSION} -target ${JAVA_TARGET_VERSION}
|
||||
-sourcepath "${CMAKE_CURRENT_SOURCE_DIR}/java-sources"
|
||||
COMMAND ${Java_JAVAC_EXECUTABLE} -sourcepath "${CMAKE_CURRENT_SOURCE_DIR}/java-sources"
|
||||
${java_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes
|
||||
COMMAND ${Java_JAR_EXECUTABLE} cvf ${LIBRARY_OUTPUT_PATH}/openjpeg.jar org
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes
|
||||
@@ -76,7 +45,3 @@ ADD_CUSTOM_TARGET(OpenJPEGJavaJar ALL
|
||||
DEPENDS ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
||||
COMMENT "building openjpeg.jar"
|
||||
)
|
||||
|
||||
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
||||
DESTINATION ${OPENJPEG_INSTALL_SHARE_DIR} COMPONENT JavaModule
|
||||
)
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
extern int get_file_format(char *filename);
|
||||
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);
|
||||
|
||||
typedef struct callback_variables {
|
||||
@@ -349,11 +349,10 @@ OPJ_PROG_ORDER give_progression(char progression[4]) {
|
||||
return PROG_UNKNOWN;
|
||||
}
|
||||
|
||||
/*
|
||||
* <summary>
|
||||
* Get logarithm of an integer and round downwards.
|
||||
* </summary>
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Get logarithm of an integer and round downwards.
|
||||
/// </summary>
|
||||
int int_floorlog2(int a) {
|
||||
int l;
|
||||
for (l=0; a>1; l++) {
|
||||
@@ -495,7 +494,7 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------ */
|
||||
int parse_cmdline_encoder(int argc, char * const argv[], opj_cparameters_t *parameters,
|
||||
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||
img_fol_t *img_fol, char *indexfilename) {
|
||||
int i, j,totlen;
|
||||
opj_option_t long_option[]={
|
||||
@@ -629,8 +628,6 @@ int parse_cmdline_encoder(int argc, char * const argv[], opj_cparameters_t *para
|
||||
numresolution = parameters->numresolution;
|
||||
matrix_width = numresolution * 3;
|
||||
parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int));
|
||||
if(parameters->cp_matrice == NULL) return 1;
|
||||
|
||||
s = s + 2;
|
||||
|
||||
for (i = 0; i < numlayers; i++) {
|
||||
@@ -859,9 +856,6 @@ int parse_cmdline_encoder(int argc, char * const argv[], opj_cparameters_t *para
|
||||
case 'C': /* add a comment */
|
||||
{
|
||||
parameters->cp_comment = (char*)malloc(strlen(opj_optarg) + 1);
|
||||
|
||||
if(parameters->cp_comment == NULL) return 1;
|
||||
|
||||
if(parameters->cp_comment) {
|
||||
strcpy(parameters->cp_comment, opj_optarg);
|
||||
}
|
||||
@@ -891,9 +885,6 @@ int parse_cmdline_encoder(int argc, char * const argv[], opj_cparameters_t *para
|
||||
case 'z': /* Image Directory path */
|
||||
{
|
||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||
|
||||
if(img_fol->imgdirpath == NULL) return 1;
|
||||
|
||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||
img_fol->set_imgdir=1;
|
||||
}
|
||||
@@ -1361,7 +1352,7 @@ char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int* buffer
|
||||
}
|
||||
}
|
||||
|
||||
/* Compute the size of the index buffer, in number of bytes*/
|
||||
// Compute the size of the index buffer, in number of bytes*/
|
||||
*buffer_size =
|
||||
1 /* version */
|
||||
+ (10 /* image_w until decomposition */
|
||||
@@ -1370,18 +1361,18 @@ char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int* buffer
|
||||
+ 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
|
||||
) * sizeof(int);
|
||||
/*printf("C: index buffer size = %d bytes\n", *buffer_size); */
|
||||
//printf("C: index buffer size = %d bytes\n", *buffer_size);
|
||||
buffer = (char*) malloc(*buffer_size);
|
||||
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
||||
buffer[0] = 1; /* Version stored on a byte */
|
||||
buffer[0] = 1; // Version stored on a byte
|
||||
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_h;
|
||||
((int*)buffer)[buffer_pos++] = cstr_info->prog;
|
||||
@@ -1606,7 +1597,7 @@ char* create_index_into_byte_array(opj_codestream_info_t *cstr_info, int* buffer
|
||||
} /* tileno */
|
||||
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
@@ -1639,7 +1630,7 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
|
||||
jint *jiBody;
|
||||
jboolean isCopy;
|
||||
|
||||
/* Image width, height and depth */
|
||||
// Image width, height and depth
|
||||
fid = (*env)->GetFieldID(env, cls,"width", "I");
|
||||
ji = (*env)->GetIntField(env, obj, fid);
|
||||
w = ji;
|
||||
@@ -1652,7 +1643,7 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
|
||||
ji = (*env)->GetIntField(env, obj, fid);
|
||||
depth = ji;
|
||||
|
||||
/* Read the image */
|
||||
// Read the image
|
||||
if (depth <=16) {
|
||||
numcomps = 1;
|
||||
color_space = CLRSPC_GRAY;
|
||||
@@ -1667,10 +1658,8 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
|
||||
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].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 the pixels of the images in
|
||||
* Telemis before entering the encoder).
|
||||
*/
|
||||
// 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).
|
||||
cmptparm[0].sgnd = 0;
|
||||
if (depth<=16)
|
||||
cmptparm[0].prec=depth;
|
||||
@@ -1716,12 +1705,12 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
|
||||
comp = &image->comps[compno];
|
||||
max = -100000;
|
||||
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);
|
||||
len = (*env)->GetArrayLength(env, jba);
|
||||
|
||||
jbBody = (*env)->GetPrimitiveArrayCritical(env, jba, &isCopy);
|
||||
/* printf("C: before transferring 8 bpp image\n"); */
|
||||
//printf("C: before transfering 8 bpp image\n");
|
||||
if (comp->sgnd) {
|
||||
for(i=0; i< len;i++) {
|
||||
comp->data[i] = (char) jbBody[i];
|
||||
@@ -1735,14 +1724,13 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
|
||||
}
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, jba, jbBody, 0);
|
||||
} 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);
|
||||
len = (*env)->GetArrayLength(env, jsa);
|
||||
|
||||
jsBody = (*env)->GetPrimitiveArrayCritical(env, jsa, &isCopy);
|
||||
/*printf("C: before transferring 16 bpp image\n"); */
|
||||
if (comp->sgnd) {
|
||||
/* Special behaviour to deal with signed elements ?? */
|
||||
//printf("C: before transfering 16 bpp image\n");
|
||||
if (comp->sgnd) { // Special behaviour to deal with signed elements ??
|
||||
comp->data[i] = (short) jsBody[i];
|
||||
for(i=0; i< len;i++) {
|
||||
if (comp->data[i] > max) max = comp->data[i];
|
||||
@@ -1755,15 +1743,14 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
|
||||
}
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, jsa, jsBody, 0);
|
||||
} 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);
|
||||
len = (*env)->GetArrayLength(env, jia);
|
||||
shift = compno*8;
|
||||
|
||||
jiBody = (*env)->GetPrimitiveArrayCritical(env, jia, &isCopy);
|
||||
/*printf("C: before transferring 24 bpp image (component %d, signed = %d)\n", compno, comp->sgnd);*/
|
||||
if (comp->sgnd) {
|
||||
/* Special behaviour to deal with signed elements ?? XXXXX */
|
||||
//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
|
||||
for(i=0; i< len;i++) {
|
||||
comp->data[i] = ( ((int) jiBody[i]) & (0xFF << shift) ) >> shift;
|
||||
if (comp->data[i] > max) max = comp->data[i];
|
||||
@@ -1778,7 +1765,7 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
|
||||
}
|
||||
comp->bpp = int_floorlog2(max)+1;
|
||||
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;
|
||||
}
|
||||
@@ -1788,7 +1775,7 @@ opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobject obj,
|
||||
-------------------- MAIN METHOD, CALLED BY JAVA -----------------------*/
|
||||
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 */
|
||||
const 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;
|
||||
opj_cparameters_t parameters; /* compression parameters */
|
||||
img_fol_t img_fol;
|
||||
@@ -1796,12 +1783,12 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
||||
opj_image_t *image = NULL;
|
||||
int i,j,num_images;
|
||||
int imageno;
|
||||
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 */
|
||||
|
||||
int* compressed_index = NULL;
|
||||
int compressed_index_size=-1;
|
||||
/* ==> Access variables to the Java member variables */
|
||||
// ==> Access variables to the Java member variables
|
||||
jsize arraySize;
|
||||
jclass cls;
|
||||
jobject object;
|
||||
@@ -1810,20 +1797,18 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
||||
jbyteArray jba;
|
||||
jbyte *jbBody;
|
||||
callback_variables_t msgErrorCallback_vars;
|
||||
/* <== access variable to the Java member variables. */
|
||||
jlong retval = -1;
|
||||
/* For the encoding and storage into the file */
|
||||
// <== access variable to the Java member variables.
|
||||
|
||||
// For the encoding and storage into the file
|
||||
opj_cinfo_t* cinfo;
|
||||
int codestream_length = -1;
|
||||
int codestream_length;
|
||||
opj_cio_t *cio = NULL;
|
||||
FILE *f = NULL;
|
||||
|
||||
/* JNI reference to the calling class */
|
||||
// JNI reference to the calling class
|
||||
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.jobj = &obj;
|
||||
msgErrorCallback_vars.message_mid = (*env)->GetMethodID(env, cls, "logMessage", "(Ljava/lang/String;)V");
|
||||
@@ -1831,11 +1816,8 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
||||
|
||||
arraySize = (*env)->GetArrayLength(env, javaParameters);
|
||||
argc = (int) arraySize +1;
|
||||
argv = (const char **)malloc(argc*sizeof(char*));
|
||||
|
||||
if(argv == NULL) return -1;
|
||||
|
||||
argv[0] = "ProgramName.exe";/* The program name: useless */
|
||||
argv = malloc(argc*sizeof(char*));
|
||||
argv[0] = "ProgramName.exe"; // The program name: useless
|
||||
j=0;
|
||||
for (i=1; i<argc; i++) {
|
||||
object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
|
||||
@@ -1859,21 +1841,23 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
||||
/* set encoding parameters to default values */
|
||||
opj_set_default_encoder_parameters(¶meters);
|
||||
parameters.cod_format = J2K_CFMT;
|
||||
/* parameters.index_on = 1; */
|
||||
//parameters.index_on = 1;
|
||||
|
||||
/* Initialize indexfilename and img_fol */
|
||||
*indexfilename = 0;
|
||||
memset(&img_fol,0,sizeof(img_fol_t));
|
||||
|
||||
/* parse input and get user encoding parameters */
|
||||
j = parse_cmdline_encoder(argc, (char *const*)argv, ¶meters,&img_fol, indexfilename);
|
||||
/* parse input and get user encoding parameters */
|
||||
if (parse_cmdline_encoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
|
||||
// Release the Java arguments array
|
||||
for (i=1; i<argc; i++)
|
||||
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Release the Java arguments array */
|
||||
// Release the Java arguments array
|
||||
for (i=1; i<argc; i++)
|
||||
(*env)->ReleaseStringUTFChars(env,
|
||||
(*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
||||
|
||||
if(j == 1) goto fin; /* failure */
|
||||
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
||||
|
||||
if (parameters.cp_cinema){
|
||||
cinema_parameters(¶meters);
|
||||
@@ -1888,15 +1872,9 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
||||
/* UniPG>> */
|
||||
#ifdef USE_JPWL
|
||||
parameters.cp_comment = (char*)malloc(clen+strlen(version)+11);
|
||||
|
||||
if(parameters.cp_comment == NULL) goto fin;
|
||||
|
||||
sprintf(parameters.cp_comment,"%s%s with JPWL", comment, version);
|
||||
#else
|
||||
parameters.cp_comment = (char*)malloc(clen+strlen(version)+1);
|
||||
|
||||
if(parameters.cp_comment == NULL) goto fin;
|
||||
|
||||
sprintf(parameters.cp_comment,"%s%s", comment, version);
|
||||
#endif
|
||||
/* <<UniPG */
|
||||
@@ -1913,10 +1891,10 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
||||
fprintf(stderr,"\n");
|
||||
|
||||
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) {
|
||||
fprintf(stderr, "Unable to load image\n");
|
||||
goto fin;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Decide if MCT should be used */
|
||||
@@ -1950,7 +1928,7 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
||||
if (!bSuccess) {
|
||||
opj_cio_close(cio);
|
||||
fprintf(stderr, "failed to encode image\n");
|
||||
goto fin;
|
||||
return -1;
|
||||
}
|
||||
codestream_length = cio_tell(cio);
|
||||
|
||||
@@ -1962,8 +1940,7 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
||||
}
|
||||
}
|
||||
|
||||
compressed_index = (int*)
|
||||
create_index_into_byte_array(&cstr_info, &compressed_index_size);
|
||||
compressed_index = create_index_into_byte_array(&cstr_info, &compressed_index_size);
|
||||
/* Allocates the Java compressedIndex byte[] and sends this index into the Java object */
|
||||
fid = (*env)->GetFieldID(env, cls,"compressedIndex", "[B");
|
||||
jba = (*env)->NewByteArray(env, compressed_index_size+1);
|
||||
@@ -1978,14 +1955,14 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
||||
f = fopen(parameters.outfile, "wb");
|
||||
if (!f) {
|
||||
fprintf(stderr, "failed to open [%s] for writing\n", parameters.outfile);
|
||||
goto fin;
|
||||
return -1;
|
||||
}
|
||||
fwrite(cio->buffer, 1, codestream_length, f);
|
||||
fclose(f);
|
||||
fprintf(stdout,"Generated outfile [%s]\n",parameters.outfile);
|
||||
}
|
||||
|
||||
/* Write the generated codestream to the Java pre-allocated compressedStream byte[] */
|
||||
/* Write the generated codestream to the Java pre-allocated compressedStream byte[] */
|
||||
fid = (*env)->GetFieldID(env, cls,"compressedStream", "[B");
|
||||
jba = (*env)->GetObjectField(env, obj, fid);
|
||||
jbBody = (*env)->GetPrimitiveArrayCritical(env, jba, 0);
|
||||
@@ -2007,10 +1984,5 @@ JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImag
|
||||
if(parameters.cp_comment) free(parameters.cp_comment);
|
||||
if(parameters.cp_matrice) free(parameters.cp_matrice);
|
||||
|
||||
retval = codestream_length;
|
||||
|
||||
fin:
|
||||
free(argv);
|
||||
|
||||
return retval;
|
||||
return codestream_length;
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ int get_file_format(char *filename) {
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int parse_cmdline_decoder(int argc, char * const 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 */
|
||||
int totlen;
|
||||
opj_option_t long_option[]={
|
||||
@@ -339,9 +339,6 @@ int parse_cmdline_decoder(int argc, char * const argv[], opj_dparameters_t *para
|
||||
case 'y': /* Image Directory path */
|
||||
{
|
||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||
|
||||
if(img_fol->imgdirpath == NULL) return 1;
|
||||
|
||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||
img_fol->set_imgdir=1;
|
||||
}
|
||||
@@ -429,7 +426,7 @@ int parse_cmdline_decoder(int argc, char * const argv[], opj_dparameters_t *para
|
||||
/* No check for possible errors before the -i and -o options are of course not mandatory*/
|
||||
|
||||
return 0;
|
||||
}/* parse_cmdline_decoder() */
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@@ -491,13 +488,12 @@ void info_callback(const char *msg, void *client_data) {
|
||||
(*env)->DeleteLocalRef(env, jbuffer);
|
||||
}
|
||||
|
||||
#define FAILS -1
|
||||
#define OK 0
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
-------------------- MAIN METHOD, CALLED BY JAVA -----------------------*/
|
||||
JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2KtoImage(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 */
|
||||
const 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_dparameters_t parameters; /* decompression parameters */
|
||||
img_fol_t img_fol;
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
@@ -512,7 +508,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
||||
int w,h;
|
||||
long min_value, max_value;
|
||||
short tempS; unsigned char tempUC, tempUC1, tempUC2;
|
||||
/* ==> Access variables to the Java member variables */
|
||||
// ==> Access variables to the Java member variables
|
||||
jsize arraySize;
|
||||
jclass cls;
|
||||
jobject object;
|
||||
@@ -525,9 +521,8 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
||||
jshort *jsBody, *ptrSBody;
|
||||
jint *jiBody, *ptrIBody;
|
||||
callback_variables_t msgErrorCallback_vars;
|
||||
/* <=== access variable to Java member variables */
|
||||
int *ptr, *ptr1, *ptr2;/* <== To transfer the decoded image to Java */
|
||||
jint retval = FAILS;
|
||||
// <=== access variable to Java member variables */
|
||||
int *ptr, *ptr1, *ptr2; // <== To transfer the decoded image to Java
|
||||
|
||||
/* configure the event callbacks */
|
||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
@@ -535,26 +530,20 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
||||
event_mgr.warning_handler = warning_callback;
|
||||
event_mgr.info_handler = info_callback;
|
||||
|
||||
/* JNI reference to the calling class */
|
||||
// JNI reference to the calling class
|
||||
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.jobj = &obj;
|
||||
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");
|
||||
|
||||
/* Get the String[] containing the parameters */
|
||||
|
||||
// Get the String[] containing the parameters, and converts it into a char** to simulate command line arguments.
|
||||
arraySize = (*env)->GetArrayLength(env, javaParameters);
|
||||
argc = (int) arraySize +1;
|
||||
argv = (const char **)malloc(argc*sizeof(char*));
|
||||
|
||||
if(argv == NULL) return FAILS;
|
||||
|
||||
argv[0] = "ProgramName.exe";/* The program name: useless */
|
||||
argv = malloc(argc*sizeof(char*));
|
||||
argv[0] = "ProgramName.exe"; // The program name: useless
|
||||
j=0;
|
||||
for (i=1; i<argc; i++) {
|
||||
object = (*env)->GetObjectArrayElement(env, javaParameters, i-1);
|
||||
@@ -572,18 +561,19 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
||||
parameters.decod_format = J2K_CFMT;
|
||||
|
||||
/* parse input and get user encoding parameters */
|
||||
j = parse_cmdline_decoder(argc, (char * const*)argv, ¶meters,&img_fol);
|
||||
|
||||
/* Release the Java arguments array */
|
||||
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol) == 1) {
|
||||
// Release the Java arguments array
|
||||
for (i=1; i<argc; i++)
|
||||
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
||||
return -1;
|
||||
}
|
||||
// Release the Java arguments array
|
||||
for (i=1; i<argc; i++)
|
||||
(*env)->ReleaseStringUTFChars(env,
|
||||
(*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
||||
|
||||
if(j == 1) goto fin; /* failure */
|
||||
(*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
||||
|
||||
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");
|
||||
parameters.cp_reduce = (short) (*env)->GetIntField(env, obj, fid);
|
||||
|
||||
@@ -597,25 +587,22 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
||||
Implemented for debug purpose. */
|
||||
/* -------------------------------------------------------------- */
|
||||
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");
|
||||
if (!fsrc) {
|
||||
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
||||
goto fin;
|
||||
return 1;
|
||||
}
|
||||
fseek(fsrc, 0, SEEK_END);
|
||||
file_length = ftell(fsrc);
|
||||
fseek(fsrc, 0, SEEK_SET);
|
||||
src = (unsigned char *) malloc(file_length);
|
||||
|
||||
if(src == NULL) goto fin;
|
||||
|
||||
fread(src, 1, file_length, fsrc);
|
||||
fclose(fsrc);
|
||||
/* printf("C: %d bytes read from file\n",file_length); */
|
||||
//printf("C: %d bytes read from file\n",file_length);
|
||||
} else {
|
||||
/* Preparing the transfer of the codestream from Java to C */
|
||||
/* printf("C: before transferring codestream\n"); */
|
||||
// Preparing the transfer of the codestream from Java to C
|
||||
//printf("C: before transfering codestream\n");
|
||||
fid = (*env)->GetFieldID(env, cls,"compressedStream", "[B");
|
||||
jba = (*env)->GetObjectField(env, obj, fid);
|
||||
file_length = (*env)->GetArrayLength(env, jba);
|
||||
@@ -649,7 +636,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
goto fin;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* close the byte stream */
|
||||
@@ -679,7 +666,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
goto fin;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* close the byte stream */
|
||||
@@ -710,7 +697,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
goto fin;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* close the byte stream */
|
||||
@@ -765,21 +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
|
||||
printf("C: checking thresholds\n");
|
||||
#endif
|
||||
/* 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;
|
||||
hr = (image->comps[0].h + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;
|
||||
---*/
|
||||
// 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;
|
||||
//hr = (image->comps[0].h + (1 << image->comps[0].factor) -1) >> image->comps[0].factor;
|
||||
w = image->comps[0].w;
|
||||
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;
|
||||
ptr1 = image->comps[1].data;
|
||||
ptr2 = image->comps[2].data;
|
||||
@@ -792,12 +775,12 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
||||
max_value = 255;
|
||||
}
|
||||
#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");
|
||||
jia = (*env)->GetObjectField(env, obj, fid);
|
||||
jiBody = (*env)->GetIntArrayElements(env, jia, 0);
|
||||
ptrIBody = jiBody;
|
||||
printf("C: transferring image24: %d int to Java pointer=%d\n",image->numcomps*w*h, ptrIBody);
|
||||
printf("C: transfering image24: %d int to Java pointer=%d\n",image->numcomps*w*h, ptrIBody);
|
||||
|
||||
for (i=0; i<w*h; i++) {
|
||||
tempUC = (unsigned char)(ptr[i]);
|
||||
@@ -821,9 +804,9 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
||||
}
|
||||
(*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;
|
||||
printf("C: before transferring 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) {
|
||||
fid = (*env)->GetFieldID(env, cls,"image8", "[B");
|
||||
jba = (*env)->GetObjectField(env, obj, fid);
|
||||
@@ -838,7 +821,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
||||
max_value = 255;
|
||||
}
|
||||
#endif
|
||||
/* printf("C: transferring %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++) {
|
||||
tempUC = (unsigned char) (ptr[i]);
|
||||
#ifdef CHECK_THRESHOLDS
|
||||
@@ -866,7 +849,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
||||
}
|
||||
printf("C: minValue = %d, maxValue = %d\n", min_value, max_value);
|
||||
#endif
|
||||
printf("C: transferring %d shorts to Java image16 pointer = %d\n", w*h,ptrSBody);
|
||||
printf("C: transfering %d shorts to Java image16 pointer = %d\n", w*h,ptrSBody);
|
||||
for (i=0; i<w*h; i++) {
|
||||
tempS = (short) (ptr[i]);
|
||||
#ifdef CHECK_THRESHOLDS
|
||||
@@ -894,12 +877,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
|
||||
opj_image_destroy(image);
|
||||
|
||||
}
|
||||
retval = OK;
|
||||
|
||||
fin:
|
||||
free(argv);
|
||||
|
||||
return retval;
|
||||
return 1; /* OK */
|
||||
}
|
||||
/* end main MAIN */
|
||||
//end main
|
||||
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
PROJECT(viewer CXX)
|
||||
|
||||
FIND_PACKAGE(wxWidgets REQUIRED)
|
||||
INCLUDE(${wxWidgets_USE_FILE})
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../..
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
)
|
||||
|
||||
# original flags:
|
||||
# -DUSE_JPWL -DwxUSE_LIBOPENJPEG -DwxUSE_GUI=1 -DOPJ_STATIC -DOPJ_HTMLABOUT -DOPJ_INICONFIG -DUSE_JPSEC -DOPJ_MANYFORMATS
|
||||
ADD_DEFINITIONS(-DwxUSE_LIBOPENJPEG -DOPENJPEG_VERSION="1.5.0")
|
||||
SET(OPJV_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/imagjpeg2000.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/wxj2kparser.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJViewer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/wxjp2parser.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJDialogs.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJThreads.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJAbout.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../codec/index.c
|
||||
)
|
||||
ADD_EXECUTABLE(opjviewer ${OPJV_SRCS})
|
||||
TARGET_LINK_LIBRARIES(opjviewer ${wxWidgets_LIBRARIES} openjpeg)
|
||||
PROJECT(viewer CXX)
|
||||
|
||||
FIND_PACKAGE(wxWidgets REQUIRED)
|
||||
INCLUDE(${wxWidgets_USE_FILE})
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../..
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
)
|
||||
|
||||
# original flags:
|
||||
# -DUSE_JPWL -DwxUSE_LIBOPENJPEG -DwxUSE_GUI=1 -DOPJ_STATIC -DOPJ_HTMLABOUT -DOPJ_INICONFIG -DUSE_JPSEC -DOPJ_MANYFORMATS
|
||||
ADD_DEFINITIONS(-DwxUSE_LIBOPENJPEG -DOPENJPEG_VERSION="1.5.0")
|
||||
SET(OPJV_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/imagjpeg2000.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/wxj2kparser.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJViewer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/wxjp2parser.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJDialogs.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJThreads.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJAbout.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../codec/index.c
|
||||
)
|
||||
ADD_EXECUTABLE(opjviewer ${OPJV_SRCS})
|
||||
TARGET_LINK_LIBRARIES(opjviewer ${wxWidgets_LIBRARIES} openjpeg)
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
; Script generated by the Inno Setup Script Wizard.
|
||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
[Setup]
|
||||
AppName=OPJViewer
|
||||
AppVerName=OPJViewer 0.4 beta
|
||||
AppPublisher=OpenJPEG
|
||||
AppPublisherURL=http://www.openjpeg.org
|
||||
AppSupportURL=http://www.openjpeg.org
|
||||
AppUpdatesURL=http://www.openjpeg.org
|
||||
DefaultDirName={pf}\OPJViewer
|
||||
DefaultGroupName=OPJViewer
|
||||
OutputDir=setup
|
||||
OutputBaseFilename=OPJViewer04beta_setup
|
||||
Compression=lzma
|
||||
SolidCompression=true
|
||||
InfoBeforeFile=source\readmebefore.txt
|
||||
InfoAfterFile=source\readmeafter.txt
|
||||
LicenseFile=source\license.txt
|
||||
VersionInfoVersion=0.4.0.0
|
||||
VersionInfoCompany=OpenJPEG
|
||||
VersionInfoDescription=JPEG 2000 viewer
|
||||
ShowLanguageDialog=yes
|
||||
SetupIconFile=source\OPJViewer.ico
|
||||
|
||||
[Languages]
|
||||
Name: english; MessagesFile: compiler:Default.isl
|
||||
|
||||
[Tasks]
|
||||
Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
|
||||
|
||||
[Files]
|
||||
Source: Release\OPJViewer.exe; DestDir: {app}; Flags: ignoreversion
|
||||
;Source: about\about.htm; DestDir: {app}/about; Flags: ignoreversion
|
||||
;Source: about\opj_logo.png; DestDir: {app}/about; Flags: ignoreversion
|
||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||
|
||||
[Icons]
|
||||
Name: {group}\OPJViewer; Filename: {app}\OPJViewer.exe; WorkingDir: {app}; IconIndex: 0
|
||||
Name: {group}\{cm:UninstallProgram,OPJViewer}; Filename: {uninstallexe}
|
||||
Name: {userdesktop}\OPJViewer; Filename: {app}\OPJViewer.exe; Tasks: desktopicon; WorkingDir: {app}; IconIndex: 0
|
||||
|
||||
[Run]
|
||||
Filename: {app}\OPJViewer.exe; Description: {cm:LaunchProgram,OPJViewer}; Flags: nowait postinstall skipifsilent; WorkingDir: {app}
|
||||
|
||||
[Registry]
|
||||
Root: HKCU; Subkey: Software\OpenJPEG; ValueType: none; ValueData: 1; Flags: uninsdeletekey; Tasks: ; Languages:
|
||||
Root: HKCU; Subkey: Software\OpenJPEG\OPJViewer; ValueType: none; ValueData: 1; Flags: uninsdeletekey; Tasks: ; Languages:
|
||||
; Script generated by the Inno Setup Script Wizard.
|
||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
[Setup]
|
||||
AppName=OPJViewer
|
||||
AppVerName=OPJViewer 0.4 beta
|
||||
AppPublisher=OpenJPEG
|
||||
AppPublisherURL=http://www.openjpeg.org
|
||||
AppSupportURL=http://www.openjpeg.org
|
||||
AppUpdatesURL=http://www.openjpeg.org
|
||||
DefaultDirName={pf}\OPJViewer
|
||||
DefaultGroupName=OPJViewer
|
||||
OutputDir=setup
|
||||
OutputBaseFilename=OPJViewer04beta_setup
|
||||
Compression=lzma
|
||||
SolidCompression=true
|
||||
InfoBeforeFile=source\readmebefore.txt
|
||||
InfoAfterFile=source\readmeafter.txt
|
||||
LicenseFile=source\license.txt
|
||||
VersionInfoVersion=0.4.0.0
|
||||
VersionInfoCompany=OpenJPEG
|
||||
VersionInfoDescription=JPEG 2000 viewer
|
||||
ShowLanguageDialog=yes
|
||||
SetupIconFile=source\OPJViewer.ico
|
||||
|
||||
[Languages]
|
||||
Name: english; MessagesFile: compiler:Default.isl
|
||||
|
||||
[Tasks]
|
||||
Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
|
||||
|
||||
[Files]
|
||||
Source: Release\OPJViewer.exe; DestDir: {app}; Flags: ignoreversion
|
||||
;Source: about\about.htm; DestDir: {app}/about; Flags: ignoreversion
|
||||
;Source: about\opj_logo.png; DestDir: {app}/about; Flags: ignoreversion
|
||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||
|
||||
[Icons]
|
||||
Name: {group}\OPJViewer; Filename: {app}\OPJViewer.exe; WorkingDir: {app}; IconIndex: 0
|
||||
Name: {group}\{cm:UninstallProgram,OPJViewer}; Filename: {uninstallexe}
|
||||
Name: {userdesktop}\OPJViewer; Filename: {app}\OPJViewer.exe; Tasks: desktopicon; WorkingDir: {app}; IconIndex: 0
|
||||
|
||||
[Run]
|
||||
Filename: {app}\OPJViewer.exe; Description: {cm:LaunchProgram,OPJViewer}; Flags: nowait postinstall skipifsilent; WorkingDir: {app}
|
||||
|
||||
[Registry]
|
||||
Root: HKCU; Subkey: Software\OpenJPEG; ValueType: none; ValueData: 1; Flags: uninsdeletekey; Tasks: ; Languages:
|
||||
Root: HKCU; Subkey: Software\OpenJPEG\OPJViewer; ValueType: none; ValueData: 1; Flags: uninsdeletekey; Tasks: ; Languages:
|
||||
|
||||
@@ -1,100 +1,100 @@
|
||||
===============================================================================
|
||||
JPEG2000 Visualization Software - OPJViewer
|
||||
|
||||
Version 0.4 beta
|
||||
===============================================================================
|
||||
|
||||
|
||||
1. Scope
|
||||
=============
|
||||
|
||||
This document describes the installation and use of the OPJViewer in the framework of OpenJPEG library.
|
||||
|
||||
This implementation has been developed using the OpenJPEG library as decoding engine and wxWidgets 2.8 as GUI engine.
|
||||
|
||||
If you find some bugs or if you have problems using the viewer, please send an e-mail to jpwl@diei.unipg.it
|
||||
|
||||
2. Installing the viewer
|
||||
==========================
|
||||
|
||||
There are two options available, at the moment:
|
||||
|
||||
a) compile from source code
|
||||
b) download a precompiled binary.
|
||||
|
||||
In order to use option a), it is mandatory to have compiled and built the LibOpenJPEG_JPWL library and the wxWidgets 2.8 framework (you have to download it from http://www.wxwidgets.org/ and compile the wx* libraries).
|
||||
|
||||
2.1. Compiling the source code in Windows
|
||||
-------------------------------------------
|
||||
|
||||
The steps required to compile the viewer under windows are:
|
||||
|
||||
a) Download at least the libopenjpeg, jpwl, and opjviewer folders from the SVN trunk.
|
||||
b) Open the OPJViewer.dsw workspace with Visual C++ 6 and activate the "OPJViewer - Win32 Release" configuration.
|
||||
c) In the configuration settings, go to the C++ tab and modify the wxWidgets paths in order to reflect your wx* install configuration (Preprocessor -> Additional include directories): simply update each instance of the two wx paths, do not remove or add them.
|
||||
d) In the configuration settings, go to the Link tab and modify the wxWidgets path in order to reflect your wx* install configuration (Input -> Additional library path): simply update the wx path.
|
||||
e) In the configuration settings, go to the Resources tab and modify the wxWidgets path in order to reflect your wx* install configuration (Additional resource include directories): simply update the wx path.
|
||||
f) Build!
|
||||
g) Run!
|
||||
h) (OPTIONAL) Prepare an installer by compiling the InnoSetup script OPJViewer.iss (you need to download InnoSetup from http://www.jrsoftware.org/isinfo.php).
|
||||
|
||||
2.1.1 Additional libraries
|
||||
----------------------------
|
||||
|
||||
Since we are also working on the Digital Cinema JPEG 2000, we are integrating the viewer with the MXF library, which is used to prepare the DCPs for digital movies. You can enable its linking in the code by specifying the USE_MXF preprocessor directive but, remember, the integration is at a very early stage.
|
||||
|
||||
2.2. Compiling the source code in Unix-like systems
|
||||
-----------------------------------------------------
|
||||
|
||||
The porting is possible and under way.
|
||||
|
||||
|
||||
3. General information on the viewer
|
||||
====================================
|
||||
|
||||
This viewer is conceived to open and display information and image content of J2K, JP2, and MJ2 files.
|
||||
The viewer application interface is divided into three main panels:
|
||||
- a browsing pane;
|
||||
- a viewing pane;
|
||||
- a log/peek pane.
|
||||
|
||||
The browsing pane will present the markers or boxes hierarchy, with position (byte number where marker/box starts and stops) and length information (i.e., inner length as signalled by marker/box and total length, with marker/box sign included), in the following form:
|
||||
|
||||
filename
|
||||
|
|
||||
|_ #000: Marker/Box short name (Hex code)
|
||||
| |
|
||||
| |_ *** Marker/Box long name ***
|
||||
| |_ startbyte > stopbyte, inner_length + marker/box sign length (total length)
|
||||
| |_ Additional info, depending on the marker/box type
|
||||
| |_ ...
|
||||
|
|
||||
|_ #001: Marker/Box short name (Hex code)
|
||||
| |
|
||||
| |_ ...
|
||||
|
|
||||
...
|
||||
|
||||
|
||||
The viewing pane will display the decoded image contained in the JPEG 2000 file.
|
||||
It should display correctly images as large as 4000x2000, provided that a couple of GB of RAM are available. Nothing is known about the display of larger sizes: let us know if you manage to get it working.
|
||||
|
||||
|
||||
The log/peek pane is shared among two different subpanels:
|
||||
|
||||
- the log panel will report a lot of debugging info coming out from the wx GUI as well as from the openjpeg library
|
||||
- the peek pane tries to give a peek on the codestream/file portion which is currently selected in the browsing pane. It shows both hex and ascii values corresponding to the marker/box section.
|
||||
|
||||
|
||||
4. Known bugs and limitations
|
||||
===============================
|
||||
|
||||
4.1. Bugs
|
||||
-----------
|
||||
|
||||
*
|
||||
|
||||
4.2. Limitations
|
||||
------------------
|
||||
|
||||
* For mj2 files, rendering is only in B/W
|
||||
===============================================================================
|
||||
JPEG2000 Visualization Software - OPJViewer
|
||||
|
||||
Version 0.4 beta
|
||||
===============================================================================
|
||||
|
||||
|
||||
1. Scope
|
||||
=============
|
||||
|
||||
This document describes the installation and use of the OPJViewer in the framework of OpenJPEG library.
|
||||
|
||||
This implementation has been developed using the OpenJPEG library as decoding engine and wxWidgets 2.8 as GUI engine.
|
||||
|
||||
If you find some bugs or if you have problems using the viewer, please send an e-mail to jpwl@diei.unipg.it
|
||||
|
||||
2. Installing the viewer
|
||||
==========================
|
||||
|
||||
There are two options available, at the moment:
|
||||
|
||||
a) compile from source code
|
||||
b) download a precompiled binary.
|
||||
|
||||
In order to use option a), it is mandatory to have compiled and built the LibOpenJPEG_JPWL library and the wxWidgets 2.8 framework (you have to download it from http://www.wxwidgets.org/ and compile the wx* libraries).
|
||||
|
||||
2.1. Compiling the source code in Windows
|
||||
-------------------------------------------
|
||||
|
||||
The steps required to compile the viewer under windows are:
|
||||
|
||||
a) Download at least the libopenjpeg, jpwl, and opjviewer folders from the SVN trunk.
|
||||
b) Open the OPJViewer.dsw workspace with Visual C++ 6 and activate the "OPJViewer - Win32 Release" configuration.
|
||||
c) In the configuration settings, go to the C++ tab and modify the wxWidgets paths in order to reflect your wx* install configuration (Preprocessor -> Additional include directories): simply update each instance of the two wx paths, do not remove or add them.
|
||||
d) In the configuration settings, go to the Link tab and modify the wxWidgets path in order to reflect your wx* install configuration (Input -> Additional library path): simply update the wx path.
|
||||
e) In the configuration settings, go to the Resources tab and modify the wxWidgets path in order to reflect your wx* install configuration (Additional resource include directories): simply update the wx path.
|
||||
f) Build!
|
||||
g) Run!
|
||||
h) (OPTIONAL) Prepare an installer by compiling the InnoSetup script OPJViewer.iss (you need to download InnoSetup from http://www.jrsoftware.org/isinfo.php).
|
||||
|
||||
2.1.1 Additional libraries
|
||||
----------------------------
|
||||
|
||||
Since we are also working on the Digital Cinema JPEG 2000, we are integrating the viewer with the MXF library, which is used to prepare the DCPs for digital movies. You can enable its linking in the code by specifying the USE_MXF preprocessor directive but, remember, the integration is at a very early stage.
|
||||
|
||||
2.2. Compiling the source code in Unix-like systems
|
||||
-----------------------------------------------------
|
||||
|
||||
The porting is possible and under way.
|
||||
|
||||
|
||||
3. General information on the viewer
|
||||
====================================
|
||||
|
||||
This viewer is conceived to open and display information and image content of J2K, JP2, and MJ2 files.
|
||||
The viewer application interface is divided into three main panels:
|
||||
- a browsing pane;
|
||||
- a viewing pane;
|
||||
- a log/peek pane.
|
||||
|
||||
The browsing pane will present the markers or boxes hierarchy, with position (byte number where marker/box starts and stops) and length information (i.e., inner length as signalled by marker/box and total length, with marker/box sign included), in the following form:
|
||||
|
||||
filename
|
||||
|
|
||||
|_ #000: Marker/Box short name (Hex code)
|
||||
| |
|
||||
| |_ *** Marker/Box long name ***
|
||||
| |_ startbyte > stopbyte, inner_length + marker/box sign length (total length)
|
||||
| |_ Additional info, depending on the marker/box type
|
||||
| |_ ...
|
||||
|
|
||||
|_ #001: Marker/Box short name (Hex code)
|
||||
| |
|
||||
| |_ ...
|
||||
|
|
||||
...
|
||||
|
||||
|
||||
The viewing pane will display the decoded image contained in the JPEG 2000 file.
|
||||
It should display correctly images as large as 4000x2000, provided that a couple of GB of RAM are available. Nothing is known about the display of larger sizes: let us know if you manage to get it working.
|
||||
|
||||
|
||||
The log/peek pane is shared among two different subpanels:
|
||||
|
||||
- the log panel will report a lot of debugging info coming out from the wx GUI as well as from the openjpeg library
|
||||
- the peek pane tries to give a peek on the codestream/file portion which is currently selected in the browsing pane. It shows both hex and ascii values corresponding to the marker/box section.
|
||||
|
||||
|
||||
4. Known bugs and limitations
|
||||
===============================
|
||||
|
||||
4.1. Bugs
|
||||
-----------
|
||||
|
||||
*
|
||||
|
||||
4.2. Limitations
|
||||
------------------
|
||||
|
||||
* For mj2 files, rendering is only in B/W
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
<html>
|
||||
<body bgcolor="#FFFFFF">
|
||||
<table cellspacing=7 cellpadding=1 border=0 width="100%">
|
||||
<tr>
|
||||
<td rowspan=3 valign=top align=center width=70>
|
||||
<img src="opj_logo.png"><br><br>
|
||||
</td>
|
||||
<td align=center>
|
||||
<font size=+2 color="#000000"><b>OPJViewer v0.2 alpha</b></font><br>
|
||||
<font size=+0 color="#000000"><b>A JPEG 2000 image viewer</b></font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr height=3 valign=center>
|
||||
<td valign=center bgcolor=#cc3300></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=justify>
|
||||
<center><font size=+0 color="#000000"><a href="http://www.openjpeg.org/">OpenJPEG</a></font></center>
|
||||
<font size=-1 color="#000000">The OpenJPEG library is an open-source JPEG 2000 codec written in C language.
|
||||
In addition to the basic codec, various other features are under development,
|
||||
among them the JP2 and MJ2 (Motion JPEG 2000) file formats, an indexing tool
|
||||
useful for the JPIP protocol, JPWL-tools for error-resilience, ...</font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2 bgcolor="#CC3300" height=3 valign=center></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<font size=-2 color="#444444">OpenJPEG is © 2002-2007 <a href="http://www.tele.ucl.ac.be/">TELE</a> - <a href="http://www.uclouvain.be/">Universit<EFBFBD> Catholique de Louvain</a></font><br>
|
||||
<font size=-2 color="#444444">OPJViewer is also © 2005-2007 <a href="http://dsplab.diei.unipg.it/">DSPLab</a> - <a href="http://www.unipg.it/">Universit<EFBFBD> degli studi di Perugia</a></font>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
<html>
|
||||
<body bgcolor="#FFFFFF">
|
||||
<table cellspacing=7 cellpadding=1 border=0 width="100%">
|
||||
<tr>
|
||||
<td rowspan=3 valign=top align=center width=70>
|
||||
<img src="opj_logo.png"><br><br>
|
||||
</td>
|
||||
<td align=center>
|
||||
<font size=+2 color="#000000"><b>OPJViewer v0.2 alpha</b></font><br>
|
||||
<font size=+0 color="#000000"><b>A JPEG 2000 image viewer</b></font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr height=3 valign=center>
|
||||
<td valign=center bgcolor=#cc3300></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=justify>
|
||||
<center><font size=+0 color="#000000"><a href="http://www.openjpeg.org/">OpenJPEG</a></font></center>
|
||||
<font size=-1 color="#000000">The OpenJPEG library is an open-source JPEG 2000 codec written in C language.
|
||||
In addition to the basic codec, various other features are under development,
|
||||
among them the JP2 and MJ2 (Motion JPEG 2000) file formats, an indexing tool
|
||||
useful for the JPIP protocol, JPWL-tools for error-resilience, ...</font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2 bgcolor="#CC3300" height=3 valign=center></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<font size=-2 color="#444444">OpenJPEG is © 2002-2007 <a href="http://www.tele.ucl.ac.be/">TELE</a> - <a href="http://www.uclouvain.be/">Universit<EFBFBD> Catholique de Louvain</a></font><br>
|
||||
<font size=-2 color="#444444">OPJViewer is also © 2005-2007 <a href="http://dsplab.diei.unipg.it/">DSPLab</a> - <a href="http://www.unipg.it/">Universit<EFBFBD> degli studi di Perugia</a></font>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,87 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita'<27> degli studi di Perugia (UPG), Italy
|
||||
* 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.
|
||||
*/
|
||||
#ifdef USE_MXF
|
||||
#include "mxflib/mxflib.h"
|
||||
#endif // USE_MXF
|
||||
|
||||
#include "OPJViewer.h"
|
||||
|
||||
// about window for the frame
|
||||
void OPJFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
#ifdef OPJ_HTMLABOUT
|
||||
#include "about_htm.h"
|
||||
#include "opj_logo.xpm"
|
||||
|
||||
wxBoxSizer *topsizer;
|
||||
wxHtmlWindow *html;
|
||||
wxDialog dlg(this, wxID_ANY, wxString(_("About")));
|
||||
|
||||
wxMemoryFSHandler::AddFile(wxT("opj_logo.xpm"), wxBitmap(opj_logo), wxBITMAP_TYPE_XPM);
|
||||
|
||||
topsizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(320, 250), wxHW_SCROLLBAR_NEVER);
|
||||
html->SetBorders(0);
|
||||
//html->LoadPage(wxT("about/about.htm"));
|
||||
//html->SetPage("<html><body>Hello, world!</body></html>");
|
||||
html->SetPage(htmlaboutpage);
|
||||
html->SetSize(html->GetInternalRepresentation()->GetWidth(),
|
||||
html->GetInternalRepresentation()->GetHeight());
|
||||
|
||||
topsizer->Add(html, 1, wxALL, 10);
|
||||
|
||||
topsizer->Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
|
||||
|
||||
wxButton *bu1 = new wxButton(&dlg, wxID_OK, wxT("OK"));
|
||||
bu1->SetDefault();
|
||||
|
||||
topsizer->Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
|
||||
|
||||
dlg.SetSizer(topsizer);
|
||||
topsizer->Fit(&dlg);
|
||||
|
||||
dlg.ShowModal();
|
||||
|
||||
#else
|
||||
|
||||
wxMessageBox(wxString::Format(OPJ_APPLICATION_TITLEBAR
|
||||
wxT("\n\n")
|
||||
wxT("Built with %s and OpenJPEG ")
|
||||
wxT(OPENJPEG_VERSION)
|
||||
wxT("\non ") wxT(__DATE__) wxT(", ") wxT(__TIME__)
|
||||
wxT("\nRunning under %s\n\n")
|
||||
OPJ_APPLICATION_COPYRIGHT,
|
||||
wxVERSION_STRING,
|
||||
wxGetOsDescription().c_str()),
|
||||
wxT("About ") OPJ_APPLICATION_NAME,
|
||||
wxOK | wxICON_INFORMATION,
|
||||
this
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita'<27> degli studi di Perugia (UPG), Italy
|
||||
* 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.
|
||||
*/
|
||||
#ifdef USE_MXF
|
||||
#include "mxflib/mxflib.h"
|
||||
#endif // USE_MXF
|
||||
|
||||
#include "OPJViewer.h"
|
||||
|
||||
// about window for the frame
|
||||
void OPJFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
#ifdef OPJ_HTMLABOUT
|
||||
#include "about_htm.h"
|
||||
#include "opj_logo.xpm"
|
||||
|
||||
wxBoxSizer *topsizer;
|
||||
wxHtmlWindow *html;
|
||||
wxDialog dlg(this, wxID_ANY, wxString(_("About")));
|
||||
|
||||
wxMemoryFSHandler::AddFile(wxT("opj_logo.xpm"), wxBitmap(opj_logo), wxBITMAP_TYPE_XPM);
|
||||
|
||||
topsizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(320, 250), wxHW_SCROLLBAR_NEVER);
|
||||
html->SetBorders(0);
|
||||
//html->LoadPage(wxT("about/about.htm"));
|
||||
//html->SetPage("<html><body>Hello, world!</body></html>");
|
||||
html->SetPage(htmlaboutpage);
|
||||
html->SetSize(html->GetInternalRepresentation()->GetWidth(),
|
||||
html->GetInternalRepresentation()->GetHeight());
|
||||
|
||||
topsizer->Add(html, 1, wxALL, 10);
|
||||
|
||||
topsizer->Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
|
||||
|
||||
wxButton *bu1 = new wxButton(&dlg, wxID_OK, wxT("OK"));
|
||||
bu1->SetDefault();
|
||||
|
||||
topsizer->Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
|
||||
|
||||
dlg.SetSizer(topsizer);
|
||||
topsizer->Fit(&dlg);
|
||||
|
||||
dlg.ShowModal();
|
||||
|
||||
#else
|
||||
|
||||
wxMessageBox(wxString::Format(OPJ_APPLICATION_TITLEBAR
|
||||
wxT("\n\n")
|
||||
wxT("Built with %s and OpenJPEG ")
|
||||
wxT(OPENJPEG_VERSION)
|
||||
wxT("\non ") wxT(__DATE__) wxT(", ") wxT(__TIME__)
|
||||
wxT("\nRunning under %s\n\n")
|
||||
OPJ_APPLICATION_COPYRIGHT,
|
||||
wxVERSION_STRING,
|
||||
wxGetOsDescription().c_str()),
|
||||
wxT("About ") OPJ_APPLICATION_NAME,
|
||||
wxOK | wxICON_INFORMATION,
|
||||
this
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
/* XPM */
|
||||
static char *OPJChild16[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 16 6 1",
|
||||
" c black",
|
||||
". c #008000",
|
||||
"X c red",
|
||||
"o c #800080",
|
||||
"O c gray100",
|
||||
"+ c None",
|
||||
/* pixels */
|
||||
"++++++++++++++++",
|
||||
"+OOOOOOOOOOOOOO+",
|
||||
"+OooooooooooooO+",
|
||||
"+OooooooooooooO+",
|
||||
"+OooOOOOOOOOOoO+",
|
||||
"+OooO.......OoO+",
|
||||
"+OooO.......OoO+",
|
||||
"+OooO..OOO..OoO+",
|
||||
"+OooO..OXO..OoO+",
|
||||
"+OooO..OOO..OoO+",
|
||||
"+OooO.......OoO+",
|
||||
"+OooO.......OoO+",
|
||||
"+OooOOOOOOOOOoO+",
|
||||
"+OooooooooooooO+",
|
||||
"+OOOOOOOOOOOOOO+",
|
||||
"++++++++++++++++"
|
||||
};
|
||||
/* XPM */
|
||||
static char *OPJChild16[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 16 6 1",
|
||||
" c black",
|
||||
". c #008000",
|
||||
"X c red",
|
||||
"o c #800080",
|
||||
"O c gray100",
|
||||
"+ c None",
|
||||
/* pixels */
|
||||
"++++++++++++++++",
|
||||
"+OOOOOOOOOOOOOO+",
|
||||
"+OooooooooooooO+",
|
||||
"+OooooooooooooO+",
|
||||
"+OooOOOOOOOOOoO+",
|
||||
"+OooO.......OoO+",
|
||||
"+OooO.......OoO+",
|
||||
"+OooO..OOO..OoO+",
|
||||
"+OooO..OXO..OoO+",
|
||||
"+OooO..OOO..OoO+",
|
||||
"+OooO.......OoO+",
|
||||
"+OooO.......OoO+",
|
||||
"+OooOOOOOOOOOoO+",
|
||||
"+OooooooooooooO+",
|
||||
"+OOOOOOOOOOOOOO+",
|
||||
"++++++++++++++++"
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,3 @@
|
||||
OPJChild16 ICON OPJChild.ico
|
||||
OPJViewer16 ICON OPJViewer.ico
|
||||
OPJChild16 ICON OPJChild.ico
|
||||
OPJViewer16 ICON OPJViewer.ico
|
||||
#include "wx/msw/wx.rc"
|
||||
@@ -1,26 +1,26 @@
|
||||
/* XPM */
|
||||
static char *OPJViewer16[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 16 4 1",
|
||||
" c black",
|
||||
". c #800000",
|
||||
"X c red",
|
||||
"o c None",
|
||||
/* pixels */
|
||||
"oooooooooooooooo",
|
||||
"ooo.XXXXoooooooo",
|
||||
"ooXXoo .Xooooooo",
|
||||
"o..oooo .ooooooo",
|
||||
"oX.oooo ooooooo",
|
||||
"oX.oooo .ooooooo",
|
||||
"oXXoooo .ooooooo",
|
||||
"o.XXoo .oooooooo",
|
||||
"oo.XXXXooooooooo",
|
||||
"ooooooooo.Xo .oo",
|
||||
"ooooooooo X. ooo",
|
||||
"oooooooooo...ooo",
|
||||
"oooooooooo XXooo",
|
||||
"oooooooooo .Xooo",
|
||||
"oooooooooooooooo",
|
||||
"oooooooooooooooo"
|
||||
};
|
||||
/* XPM */
|
||||
static char *OPJViewer16[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 16 4 1",
|
||||
" c black",
|
||||
". c #800000",
|
||||
"X c red",
|
||||
"o c None",
|
||||
/* pixels */
|
||||
"oooooooooooooooo",
|
||||
"ooo.XXXXoooooooo",
|
||||
"ooXXoo .Xooooooo",
|
||||
"o..oooo .ooooooo",
|
||||
"oX.oooo ooooooo",
|
||||
"oX.oooo .ooooooo",
|
||||
"oXXoooo .ooooooo",
|
||||
"o.XXoo .oooooooo",
|
||||
"oo.XXXXooooooooo",
|
||||
"ooooooooo.Xo .oo",
|
||||
"ooooooooo X. ooo",
|
||||
"oooooooooo...ooo",
|
||||
"oooooooooo XXooo",
|
||||
"oooooooooo .Xooo",
|
||||
"oooooooooooooooo",
|
||||
"oooooooooooooooo"
|
||||
};
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
wxString htmlaboutpage = wxT(
|
||||
"<html>"
|
||||
"<body bgcolor=#FFFFFF>"
|
||||
"<table cellspacing=7 cellpadding=1 border=0 width=100%>"
|
||||
"<tr>"
|
||||
"<td rowspan=3 valign=top align=center width=70>"
|
||||
"<img src=\"memory:opj_logo.xpm\"><br><br>"
|
||||
"</td>"
|
||||
"<td align=center>"
|
||||
"<font size=+0 color=#000000><b>"
|
||||
OPJ_APPLICATION " " OPJ_APPLICATION_VERSION
|
||||
"</b></font><br>"
|
||||
"<font size=-1 color=#000000><b>A JPEG 2000 image viewer</b></font><br>"
|
||||
"<font size=-2 color=#000000><b>" OPJ_APPLICATION_PLATFORM " version</b></font>"
|
||||
"</td>"
|
||||
"</tr>"
|
||||
"<tr height=3 valign=center>"
|
||||
"<td valign=center bgcolor=#cc3300></td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td align=justify>"
|
||||
"<center><font size=+0 color=#000000><a href=\"http://www.openjpeg.org/\">OpenJPEG</a></font></center>"
|
||||
"<p><font size=-1 color=#000000>The OpenJPEG library is an open-source JPEG 2000 codec written in C language. "
|
||||
"In addition to the basic codec, various other features are under development.</font></p><br>"
|
||||
"<font size=-2 color=red>* Build: ")
|
||||
#include "build.h"
|
||||
wxT(", " __DATE__ ", " __TIME__ "</font><br>")
|
||||
wxT("<font size=-2 color=red>* " wxVERSION_STRING "</font><br>")
|
||||
wxT("<font size=-2 color=red>* OpenJPEG " OPENJPEG_VERSION " (")
|
||||
#ifdef USE_JPWL
|
||||
wxT("<font size=-2 color=green>JPWL</font> ")
|
||||
#endif // USE_JPWL
|
||||
#ifdef USE_JPSEC
|
||||
wxT("<font size=-2 color=green>JPSEC</font> ")
|
||||
#endif // USE_JPSEC
|
||||
wxT(")</font><br>")
|
||||
#ifdef USE_MXF
|
||||
wxT("<font size=-2 color=red>* MXFLib " MXFLIB_VERSION_MAJOR "." MXFLIB_VERSION_MINOR "." MXFLIB_VERSION_TWEAK " (" MXFLIB_VERSION_BUILD ")</font><br>")
|
||||
#endif // USE_MXF
|
||||
wxT("</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td colspan=2 bgcolor=#CC3300 height=3 valign=center></td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td colspan=2>"
|
||||
"<font size=-2 color=#444444>OpenJPEG is © 2002-2008 <a href=\"http://www.tele.ucl.ac.be/\">TELE</a> - <a href=\"http://www.uclouvain.be/\">Universite' Catholique de Louvain</a></font><br>"
|
||||
"<font size=-2 color=#444444>OPJViewer is © 2007-2008 <a href=\"http://dsplab.diei.unipg.it/\">DSPLab</a> - <a href=\"http://www.unipg.it/\">Universita' degli studi di Perugia</a></font>"
|
||||
"</td>"
|
||||
"</tr>"
|
||||
"</table>"
|
||||
"</body>"
|
||||
"</html>"
|
||||
);
|
||||
wxString htmlaboutpage = wxT(
|
||||
"<html>"
|
||||
"<body bgcolor=#FFFFFF>"
|
||||
"<table cellspacing=7 cellpadding=1 border=0 width=100%>"
|
||||
"<tr>"
|
||||
"<td rowspan=3 valign=top align=center width=70>"
|
||||
"<img src=\"memory:opj_logo.xpm\"><br><br>"
|
||||
"</td>"
|
||||
"<td align=center>"
|
||||
"<font size=+0 color=#000000><b>"
|
||||
OPJ_APPLICATION " " OPJ_APPLICATION_VERSION
|
||||
"</b></font><br>"
|
||||
"<font size=-1 color=#000000><b>A JPEG 2000 image viewer</b></font><br>"
|
||||
"<font size=-2 color=#000000><b>" OPJ_APPLICATION_PLATFORM " version</b></font>"
|
||||
"</td>"
|
||||
"</tr>"
|
||||
"<tr height=3 valign=center>"
|
||||
"<td valign=center bgcolor=#cc3300></td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td align=justify>"
|
||||
"<center><font size=+0 color=#000000><a href=\"http://www.openjpeg.org/\">OpenJPEG</a></font></center>"
|
||||
"<p><font size=-1 color=#000000>The OpenJPEG library is an open-source JPEG 2000 codec written in C language. "
|
||||
"In addition to the basic codec, various other features are under development.</font></p><br>"
|
||||
"<font size=-2 color=red>* Build: ")
|
||||
#include "build.h"
|
||||
wxT(", " __DATE__ ", " __TIME__ "</font><br>")
|
||||
wxT("<font size=-2 color=red>* " wxVERSION_STRING "</font><br>")
|
||||
wxT("<font size=-2 color=red>* OpenJPEG " OPENJPEG_VERSION " (")
|
||||
#ifdef USE_JPWL
|
||||
wxT("<font size=-2 color=green>JPWL</font> ")
|
||||
#endif // USE_JPWL
|
||||
#ifdef USE_JPSEC
|
||||
wxT("<font size=-2 color=green>JPSEC</font> ")
|
||||
#endif // USE_JPSEC
|
||||
wxT(")</font><br>")
|
||||
#ifdef USE_MXF
|
||||
wxT("<font size=-2 color=red>* MXFLib " MXFLIB_VERSION_MAJOR "." MXFLIB_VERSION_MINOR "." MXFLIB_VERSION_TWEAK " (" MXFLIB_VERSION_BUILD ")</font><br>")
|
||||
#endif // USE_MXF
|
||||
wxT("</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td colspan=2 bgcolor=#CC3300 height=3 valign=center></td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td colspan=2>"
|
||||
"<font size=-2 color=#444444>OpenJPEG is © 2002-2008 <a href=\"http://www.tele.ucl.ac.be/\">TELE</a> - <a href=\"http://www.uclouvain.be/\">Universite' Catholique de Louvain</a></font><br>"
|
||||
"<font size=-2 color=#444444>OPJViewer is © 2007-2008 <a href=\"http://dsplab.diei.unipg.it/\">DSPLab</a> - <a href=\"http://www.unipg.it/\">Universita' degli studi di Perugia</a></font>"
|
||||
"</td>"
|
||||
"</tr>"
|
||||
"</table>"
|
||||
"</body>"
|
||||
"</html>"
|
||||
);
|
||||
|
||||
@@ -1 +1 @@
|
||||
wxT("491")
|
||||
wxT("491")
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,177 +1,177 @@
|
||||
/*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||
* 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.
|
||||
*/
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: imagalljpeg2000.h
|
||||
// Purpose: wxImage JPEG 2000 family file format handler
|
||||
// Author: G. Baruffa - based on imagjpeg.h, Vaclav Slavik
|
||||
// RCS-ID: $Id: imagalljpeg2000.h,v 0.0 2008/01/31 11:22:00 VZ Exp $
|
||||
// Copyright: (c) Giuseppe Baruffa
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_IMAGJPEG2000_H_
|
||||
#define _WX_IMAGJPEG2000_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxJPEG2000Handler
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_LIBOPENJPEG
|
||||
|
||||
#include "wx/image.h"
|
||||
#include "libopenjpeg/openjpeg.h"
|
||||
#include "codec/index.h"
|
||||
|
||||
#define wxBITMAP_TYPE_JPEG2000 50
|
||||
|
||||
class WXDLLEXPORT wxJPEG2000Handler: public wxImageHandler
|
||||
{
|
||||
public:
|
||||
inline wxJPEG2000Handler()
|
||||
{
|
||||
m_name = wxT("JPEG 2000 family file format");
|
||||
m_extension = wxT("mj2");
|
||||
m_type = wxBITMAP_TYPE_JPEG2000;
|
||||
m_mime = wxT("image/mj2");
|
||||
|
||||
/* decoding */
|
||||
m_reducefactor = 0;
|
||||
m_qualitylayers = 0;
|
||||
m_components = 0;
|
||||
#ifdef USE_JPWL
|
||||
m_enablejpwl = true;
|
||||
m_expcomps = JPWL_EXPECTED_COMPONENTS;
|
||||
m_maxtiles = JPWL_MAXIMUM_TILES;
|
||||
#endif // USE_JPWL
|
||||
|
||||
/* encoding */
|
||||
m_subsampling = wxT("1,1");
|
||||
m_origin = wxT("0,0");
|
||||
m_rates = wxT("20,10,5");
|
||||
m_quality = wxT("30,35,40");
|
||||
m_enablequality = false;
|
||||
m_multicomp = false;
|
||||
m_irreversible = false;
|
||||
m_resolutions = 6;
|
||||
m_progression = 0;
|
||||
m_cbsize = wxT("32,32");
|
||||
m_prsize = wxT("[128,128],[128,128]");
|
||||
m_tsize = wxT("");
|
||||
m_torigin = wxT("0,0");
|
||||
/*m_progression
|
||||
m_resilience*/
|
||||
m_enablesop = false;
|
||||
m_enableeph = false;
|
||||
m_enablereset = false;
|
||||
m_enablesegmark = false;
|
||||
m_enablevsc = false;
|
||||
m_enablerestart = false;
|
||||
m_enableerterm = false;
|
||||
m_enablebypass = false;
|
||||
/*m_roicompo
|
||||
m_roiup
|
||||
m_indexfname*/
|
||||
m_enableidx = false;
|
||||
m_index = wxT("index.txt");
|
||||
m_enablepoc = false;
|
||||
m_poc = wxT("T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL");
|
||||
m_enablecomm = true;
|
||||
|
||||
#if defined __WXMSW__
|
||||
m_comment = wxT("Created by OPJViewer Win32 - OpenJPEG version ");
|
||||
#elif defined __WXGTK__
|
||||
m_comment = wxT("Created by OPJViewer Lin32 - OpenJPEG version ");
|
||||
#else
|
||||
m_comment = wxT("Created by OPJViewer - OpenJPEG version ");
|
||||
#endif
|
||||
|
||||
#ifdef USE_JPWL
|
||||
m_comment += wxString::Format(wxT("%s with JPWL"), (char *) opj_version());
|
||||
#else
|
||||
m_comment += wxString::Format(wxT("%s"), (char *) opj_version());
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// decoding engine parameters
|
||||
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||
#ifdef USE_JPWL
|
||||
bool m_enablejpwl;
|
||||
int m_expcomps, m_maxtiles;
|
||||
#endif // USE_JPWL
|
||||
|
||||
// encoding engine parameters
|
||||
wxString m_subsampling;
|
||||
wxString m_origin;
|
||||
wxString m_rates;
|
||||
wxString m_quality;
|
||||
bool m_enablequality;
|
||||
bool m_multicomp;
|
||||
bool m_irreversible;
|
||||
int m_resolutions;
|
||||
int m_progression;
|
||||
wxString m_cbsize;
|
||||
wxString m_prsize;
|
||||
wxString m_tsize;
|
||||
wxString m_torigin;
|
||||
/*m_progression
|
||||
m_resilience*/
|
||||
bool m_enablesop;
|
||||
bool m_enableeph;
|
||||
bool m_enablebypass;
|
||||
bool m_enableerterm;
|
||||
bool m_enablerestart;
|
||||
bool m_enablereset;
|
||||
bool m_enablesegmark;
|
||||
bool m_enablevsc;
|
||||
/*m_roicompo
|
||||
m_roiup
|
||||
m_indexfname*/
|
||||
bool m_enableidx;
|
||||
wxString m_index;
|
||||
bool m_enablecomm;
|
||||
wxString m_comment;
|
||||
bool m_enablepoc;
|
||||
wxString m_poc;
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
virtual bool LoadFile(wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1);
|
||||
virtual bool SaveFile(wxImage *image, wxOutputStream& stream, bool verbose=true);
|
||||
protected:
|
||||
virtual bool DoCanRead(wxInputStream& stream);
|
||||
#endif
|
||||
|
||||
private:
|
||||
OPJ_PROG_ORDER give_progression(char progression[4]);
|
||||
DECLARE_DYNAMIC_CLASS(wxJPEG2000Handler)
|
||||
};
|
||||
|
||||
#endif // wxUSE_LIBOPENJPEG
|
||||
|
||||
#endif // _WX_IMAGJPEG2000_H_
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||
* 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.
|
||||
*/
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: imagalljpeg2000.h
|
||||
// Purpose: wxImage JPEG 2000 family file format handler
|
||||
// Author: G. Baruffa - based on imagjpeg.h, Vaclav Slavik
|
||||
// RCS-ID: $Id: imagalljpeg2000.h,v 0.0 2008/01/31 11:22:00 VZ Exp $
|
||||
// Copyright: (c) Giuseppe Baruffa
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_IMAGJPEG2000_H_
|
||||
#define _WX_IMAGJPEG2000_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxJPEG2000Handler
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_LIBOPENJPEG
|
||||
|
||||
#include "wx/image.h"
|
||||
#include "libopenjpeg/openjpeg.h"
|
||||
#include "codec/index.h"
|
||||
|
||||
#define wxBITMAP_TYPE_JPEG2000 50
|
||||
|
||||
class WXDLLEXPORT wxJPEG2000Handler: public wxImageHandler
|
||||
{
|
||||
public:
|
||||
inline wxJPEG2000Handler()
|
||||
{
|
||||
m_name = wxT("JPEG 2000 family file format");
|
||||
m_extension = wxT("mj2");
|
||||
m_type = wxBITMAP_TYPE_JPEG2000;
|
||||
m_mime = wxT("image/mj2");
|
||||
|
||||
/* decoding */
|
||||
m_reducefactor = 0;
|
||||
m_qualitylayers = 0;
|
||||
m_components = 0;
|
||||
#ifdef USE_JPWL
|
||||
m_enablejpwl = true;
|
||||
m_expcomps = JPWL_EXPECTED_COMPONENTS;
|
||||
m_maxtiles = JPWL_MAXIMUM_TILES;
|
||||
#endif // USE_JPWL
|
||||
|
||||
/* encoding */
|
||||
m_subsampling = wxT("1,1");
|
||||
m_origin = wxT("0,0");
|
||||
m_rates = wxT("20,10,5");
|
||||
m_quality = wxT("30,35,40");
|
||||
m_enablequality = false;
|
||||
m_multicomp = false;
|
||||
m_irreversible = false;
|
||||
m_resolutions = 6;
|
||||
m_progression = 0;
|
||||
m_cbsize = wxT("32,32");
|
||||
m_prsize = wxT("[128,128],[128,128]");
|
||||
m_tsize = wxT("");
|
||||
m_torigin = wxT("0,0");
|
||||
/*m_progression
|
||||
m_resilience*/
|
||||
m_enablesop = false;
|
||||
m_enableeph = false;
|
||||
m_enablereset = false;
|
||||
m_enablesegmark = false;
|
||||
m_enablevsc = false;
|
||||
m_enablerestart = false;
|
||||
m_enableerterm = false;
|
||||
m_enablebypass = false;
|
||||
/*m_roicompo
|
||||
m_roiup
|
||||
m_indexfname*/
|
||||
m_enableidx = false;
|
||||
m_index = wxT("index.txt");
|
||||
m_enablepoc = false;
|
||||
m_poc = wxT("T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL");
|
||||
m_enablecomm = true;
|
||||
|
||||
#if defined __WXMSW__
|
||||
m_comment = wxT("Created by OPJViewer Win32 - OpenJPEG version ");
|
||||
#elif defined __WXGTK__
|
||||
m_comment = wxT("Created by OPJViewer Lin32 - OpenJPEG version ");
|
||||
#else
|
||||
m_comment = wxT("Created by OPJViewer - OpenJPEG version ");
|
||||
#endif
|
||||
|
||||
#ifdef USE_JPWL
|
||||
m_comment += wxString::Format(wxT("%s with JPWL"), (char *) opj_version());
|
||||
#else
|
||||
m_comment += wxString::Format(wxT("%s"), (char *) opj_version());
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// decoding engine parameters
|
||||
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||
#ifdef USE_JPWL
|
||||
bool m_enablejpwl;
|
||||
int m_expcomps, m_maxtiles;
|
||||
#endif // USE_JPWL
|
||||
|
||||
// encoding engine parameters
|
||||
wxString m_subsampling;
|
||||
wxString m_origin;
|
||||
wxString m_rates;
|
||||
wxString m_quality;
|
||||
bool m_enablequality;
|
||||
bool m_multicomp;
|
||||
bool m_irreversible;
|
||||
int m_resolutions;
|
||||
int m_progression;
|
||||
wxString m_cbsize;
|
||||
wxString m_prsize;
|
||||
wxString m_tsize;
|
||||
wxString m_torigin;
|
||||
/*m_progression
|
||||
m_resilience*/
|
||||
bool m_enablesop;
|
||||
bool m_enableeph;
|
||||
bool m_enablebypass;
|
||||
bool m_enableerterm;
|
||||
bool m_enablerestart;
|
||||
bool m_enablereset;
|
||||
bool m_enablesegmark;
|
||||
bool m_enablevsc;
|
||||
/*m_roicompo
|
||||
m_roiup
|
||||
m_indexfname*/
|
||||
bool m_enableidx;
|
||||
wxString m_index;
|
||||
bool m_enablecomm;
|
||||
wxString m_comment;
|
||||
bool m_enablepoc;
|
||||
wxString m_poc;
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
virtual bool LoadFile(wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1);
|
||||
virtual bool SaveFile(wxImage *image, wxOutputStream& stream, bool verbose=true);
|
||||
protected:
|
||||
virtual bool DoCanRead(wxInputStream& stream);
|
||||
#endif
|
||||
|
||||
private:
|
||||
OPJ_PROG_ORDER give_progression(char progression[4]);
|
||||
DECLARE_DYNAMIC_CLASS(wxJPEG2000Handler)
|
||||
};
|
||||
|
||||
#endif // wxUSE_LIBOPENJPEG
|
||||
|
||||
#endif // _WX_IMAGJPEG2000_H_
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,99 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||
* 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.
|
||||
*/
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: imagmxf.h
|
||||
// Purpose: wxImage MXF (Material eXchange Format) JPEG 2000 file format handler
|
||||
// Author: G. Baruffa - based on imagjpeg.h, Vaclav Slavik
|
||||
// RCS-ID: $Id: imagmj2.h,v 0.0 2007/11/19 17:00:00 VZ Exp $
|
||||
// Copyright: (c) Giuseppe Baruffa
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_IMAGMXF_H_
|
||||
#define _WX_IMAGMXF_H_
|
||||
|
||||
#ifdef USE_MXF
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/filename.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxMXFHandler
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_LIBOPENJPEG
|
||||
|
||||
#include "wx/image.h"
|
||||
#include "libopenjpeg/openjpeg.h"
|
||||
|
||||
#define wxBITMAP_TYPE_MXF 51
|
||||
|
||||
class WXDLLEXPORT wxMXFHandler: public wxImageHandler
|
||||
{
|
||||
public:
|
||||
inline wxMXFHandler()
|
||||
{
|
||||
m_name = wxT("MXF JPEG 2000 file format");
|
||||
m_extension = wxT("mxf");
|
||||
m_type = wxBITMAP_TYPE_MXF;
|
||||
m_mime = wxT("image/mxf");
|
||||
|
||||
m_reducefactor = 0;
|
||||
m_qualitylayers = 0;
|
||||
m_components = 0;
|
||||
m_filename = wxT("");
|
||||
#ifdef USE_JPWL
|
||||
m_enablejpwl = true;
|
||||
m_expcomps = JPWL_EXPECTED_COMPONENTS;
|
||||
m_maxtiles = JPWL_MAXIMUM_TILES;
|
||||
#endif // USE_JPWL
|
||||
}
|
||||
|
||||
// decoding engine parameters
|
||||
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||
wxFileName m_filename;
|
||||
#ifdef USE_JPWL
|
||||
bool m_enablejpwl;
|
||||
int m_expcomps, m_maxtiles;
|
||||
#endif // USE_JPWL
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 );
|
||||
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=true );
|
||||
protected:
|
||||
virtual bool DoCanRead( wxInputStream& stream );
|
||||
#endif
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxMXFHandler)
|
||||
};
|
||||
|
||||
#endif // wxUSE_LIBOPENJPEG
|
||||
|
||||
#endif // USE_MXF
|
||||
|
||||
#endif // _WX_IMAGMXF_H_
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||
* 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.
|
||||
*/
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: imagmxf.h
|
||||
// Purpose: wxImage MXF (Material eXchange Format) JPEG 2000 file format handler
|
||||
// Author: G. Baruffa - based on imagjpeg.h, Vaclav Slavik
|
||||
// RCS-ID: $Id: imagmj2.h,v 0.0 2007/11/19 17:00:00 VZ Exp $
|
||||
// Copyright: (c) Giuseppe Baruffa
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_IMAGMXF_H_
|
||||
#define _WX_IMAGMXF_H_
|
||||
|
||||
#ifdef USE_MXF
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/filename.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxMXFHandler
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_LIBOPENJPEG
|
||||
|
||||
#include "wx/image.h"
|
||||
#include "libopenjpeg/openjpeg.h"
|
||||
|
||||
#define wxBITMAP_TYPE_MXF 51
|
||||
|
||||
class WXDLLEXPORT wxMXFHandler: public wxImageHandler
|
||||
{
|
||||
public:
|
||||
inline wxMXFHandler()
|
||||
{
|
||||
m_name = wxT("MXF JPEG 2000 file format");
|
||||
m_extension = wxT("mxf");
|
||||
m_type = wxBITMAP_TYPE_MXF;
|
||||
m_mime = wxT("image/mxf");
|
||||
|
||||
m_reducefactor = 0;
|
||||
m_qualitylayers = 0;
|
||||
m_components = 0;
|
||||
m_filename = wxT("");
|
||||
#ifdef USE_JPWL
|
||||
m_enablejpwl = true;
|
||||
m_expcomps = JPWL_EXPECTED_COMPONENTS;
|
||||
m_maxtiles = JPWL_MAXIMUM_TILES;
|
||||
#endif // USE_JPWL
|
||||
}
|
||||
|
||||
// decoding engine parameters
|
||||
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||
wxFileName m_filename;
|
||||
#ifdef USE_JPWL
|
||||
bool m_enablejpwl;
|
||||
int m_expcomps, m_maxtiles;
|
||||
#endif // USE_JPWL
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 );
|
||||
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=true );
|
||||
protected:
|
||||
virtual bool DoCanRead( wxInputStream& stream );
|
||||
#endif
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxMXFHandler)
|
||||
};
|
||||
|
||||
#endif // wxUSE_LIBOPENJPEG
|
||||
|
||||
#endif // USE_MXF
|
||||
|
||||
#endif // _WX_IMAGMXF_H_
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
Copyright (c) 2001-2003, David Janssens
|
||||
Copyright (c) 2002-2003, Yannick Verschueren
|
||||
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditionsare 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.
|
||||
|
||||
Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
Copyright (c) 2001-2003, David Janssens
|
||||
Copyright (c) 2002-2003, Yannick Verschueren
|
||||
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditionsare 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.
|
||||
@@ -1,34 +1,34 @@
|
||||
This viewer is conceived to open and display information and image content of J2K, JP2,
|
||||
and MJ2 files.
|
||||
The viewer application interface is divided into three main panels:
|
||||
- a browsing pane;
|
||||
- a viewing pane;
|
||||
- a log/peek pane.
|
||||
|
||||
The browsing pane will present the markers or boxes hierarchy, with position (byte number where marker/box starts and stops) and length information (i.e., inner length as signalled by marker/box and total length, with marker/box sign included), in the following form:
|
||||
|
||||
filename
|
||||
|
|
||||
|_ #000: Marker/Box short name (Hex code)
|
||||
| |
|
||||
| |_ *** Marker/Box long name ***
|
||||
| |_ startbyte > stopbyte, inner_length + marker/box sign length (total length)
|
||||
| |_ Additional info, depending on the marker/box type
|
||||
| |_ ...
|
||||
|
|
||||
|_ #001: Marker/Box short name (Hex code)
|
||||
| |
|
||||
| |_ ...
|
||||
|
|
||||
...
|
||||
|
||||
|
||||
The viewing pane will display the decoded image contained in the JPEG 2000 file.
|
||||
It should display correctly images as large as 4000x2000, provided that a couple of GB of RAM are available. Nothing is known about the display of larger sizes: let us know if you manage to get it working.
|
||||
|
||||
|
||||
The log/peek pane is shared among two different subpanels:
|
||||
|
||||
- the log panel will report a lot of debugging info coming out from the wx GUI as well as from the openjpeg library
|
||||
- the peek pane tries to give a peek on the codestream/file portion which is currently selected in the browsing pane. It shows both hex and ascii values corresponding to the marker/box section.
|
||||
|
||||
This viewer is conceived to open and display information and image content of J2K, JP2,
|
||||
and MJ2 files.
|
||||
The viewer application interface is divided into three main panels:
|
||||
- a browsing pane;
|
||||
- a viewing pane;
|
||||
- a log/peek pane.
|
||||
|
||||
The browsing pane will present the markers or boxes hierarchy, with position (byte number where marker/box starts and stops) and length information (i.e., inner length as signalled by marker/box and total length, with marker/box sign included), in the following form:
|
||||
|
||||
filename
|
||||
|
|
||||
|_ #000: Marker/Box short name (Hex code)
|
||||
| |
|
||||
| |_ *** Marker/Box long name ***
|
||||
| |_ startbyte > stopbyte, inner_length + marker/box sign length (total length)
|
||||
| |_ Additional info, depending on the marker/box type
|
||||
| |_ ...
|
||||
|
|
||||
|_ #001: Marker/Box short name (Hex code)
|
||||
| |
|
||||
| |_ ...
|
||||
|
|
||||
...
|
||||
|
||||
|
||||
The viewing pane will display the decoded image contained in the JPEG 2000 file.
|
||||
It should display correctly images as large as 4000x2000, provided that a couple of GB of RAM are available. Nothing is known about the display of larger sizes: let us know if you manage to get it working.
|
||||
|
||||
|
||||
The log/peek pane is shared among two different subpanels:
|
||||
|
||||
- the log panel will report a lot of debugging info coming out from the wx GUI as well as from the openjpeg library
|
||||
- the peek pane tries to give a peek on the codestream/file portion which is currently selected in the browsing pane. It shows both hex and ascii values corresponding to the marker/box section.
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
What is OpenJPEG ?
|
||||
==================
|
||||
The OpenJPEG library is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the use of JPEG 2000, the new still-image compression standard from the Joint Photographic Experts Group (JPEG). In addition to the basic codec, various other features are under development, among them the JP2 and MJ2 (Motion JPEG 2000) file formats, an indexing tool useful for the JPIP protocol, JPWL-tools for error-resilience, a Java-viewer for j2k-images, ...
|
||||
|
||||
Who can use the library ?
|
||||
=========================
|
||||
Anybody. As the OpenJPEG library is released under the BSD license, anybody can use or modify the library, even for commercial applications. The only restriction is to retain the copyright in the sources or the binaries documentation.
|
||||
|
||||
Who is developing the library ?
|
||||
===============================
|
||||
What is OpenJPEG ?
|
||||
==================
|
||||
The OpenJPEG library is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the use of JPEG 2000, the new still-image compression standard from the Joint Photographic Experts Group (JPEG). In addition to the basic codec, various other features are under development, among them the JP2 and MJ2 (Motion JPEG 2000) file formats, an indexing tool useful for the JPIP protocol, JPWL-tools for error-resilience, a Java-viewer for j2k-images, ...
|
||||
|
||||
Who can use the library ?
|
||||
=========================
|
||||
Anybody. As the OpenJPEG library is released under the BSD license, anybody can use or modify the library, even for commercial applications. The only restriction is to retain the copyright in the sources or the binaries documentation.
|
||||
|
||||
Who is developing the library ?
|
||||
===============================
|
||||
The library is developed by the Communications and Remote Sensing Lab (TELE), in the Universit<69> Catholique de Louvain (UCL). The JPWL module is developped and maintained by the Digital Signal Processing Lab (DSPLab) of the University of Perugia, Italy (UNIPG). As our purpose is to make OpenJPEG really useful for those interested in the image compression field, any feedback/advices are obviously welcome ! We will do our best to handle them quickly.
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -3,17 +3,10 @@
|
||||
# First thing define the common source:
|
||||
SET(common_SRCS
|
||||
convert.c
|
||||
converttif.c
|
||||
convertbmp.c
|
||||
convertpng.c
|
||||
index.c
|
||||
${OPENJPEG_SOURCE_DIR}/applications/common/color.c
|
||||
${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c
|
||||
)
|
||||
if(NOT USE_SYSTEM_GETOPT)
|
||||
list(APPEND common_SRCS
|
||||
${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c
|
||||
)
|
||||
endif()
|
||||
|
||||
# Headers file are located here:
|
||||
INCLUDE_DIRECTORIES(
|
||||
|
||||
@@ -78,7 +78,7 @@ JPWL_j2k_to_image_CPPFLAGS = \
|
||||
@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@ -lm
|
||||
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/opj_getopt.c \
|
||||
@@ -96,7 +96,7 @@ JPWL_image_to_j2k_CPPFLAGS = \
|
||||
@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@ -lm
|
||||
JPWL_image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @TIFF_LIBS@ @PNG_LIBS@
|
||||
|
||||
JPWL_image_to_j2k_SOURCES = \
|
||||
../common/opj_getopt.c \
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -47,21 +47,6 @@ typedef struct raw_cparameters {
|
||||
/*@}*/
|
||||
} raw_cparameters_t;
|
||||
|
||||
/* Component precision scaling */
|
||||
void clip_component(opj_image_comp_t* component, int precision);
|
||||
void scale_component(opj_image_comp_t* component, int precision);
|
||||
|
||||
/* planar / interleaved conversions */
|
||||
typedef void (* convert_32s_CXPX)(const int* pSrc, int* const* pDst, size_t length);
|
||||
extern const convert_32s_CXPX convert_32s_CXPX_LUT[5];
|
||||
typedef void (* convert_32s_PXCX)(int const* const* pSrc, int* pDst, size_t length, int adjust);
|
||||
extern const convert_32s_PXCX convert_32s_PXCX_LUT[5];
|
||||
/* bit depth conversions */
|
||||
typedef void (* convert_XXx32s_C1R)(const unsigned char* pSrc, int* pDst, size_t length);
|
||||
extern const convert_XXx32s_C1R convert_XXu32s_C1R_LUT[9]; /* up to 8bpp */
|
||||
typedef void (* convert_32sXXx_C1R)(const int* pSrc, unsigned char* pDst, size_t length);
|
||||
extern const convert_32sXXx_C1R convert_32sXXu_C1R_LUT[9]; /* up to 8bpp */
|
||||
|
||||
/* TGA conversion */
|
||||
opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters);
|
||||
int imagetotga(opj_image_t * image, const char *outfile);
|
||||
|
||||
@@ -1,995 +0,0 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||
* 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 "opj_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "openjpeg.h"
|
||||
#include "convert.h"
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#if defined(_WIN32)
|
||||
typedef signed __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#error unsupported platform
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint16_t bfType; /* 'BM' for Bitmap (19776) */
|
||||
uint32_t bfSize; /* Size of the file */
|
||||
uint16_t bfReserved1; /* Reserved : 0 */
|
||||
uint16_t bfReserved2; /* Reserved : 0 */
|
||||
uint32_t bfOffBits; /* Offset */
|
||||
} OPJ_BITMAPFILEHEADER;
|
||||
|
||||
typedef struct {
|
||||
uint32_t biSize; /* Size of the structure in bytes */
|
||||
uint32_t biWidth; /* Width of the image in pixels */
|
||||
uint32_t biHeight; /* Heigth of the image in pixels */
|
||||
uint16_t biPlanes; /* 1 */
|
||||
uint16_t biBitCount; /* Number of color bits by pixels */
|
||||
uint32_t biCompression; /* Type of encoding 0: none 1: RLE8 2: RLE4 */
|
||||
uint32_t biSizeImage; /* Size of the image in bytes */
|
||||
uint32_t biXpelsPerMeter; /* Horizontal (X) resolution in pixels/meter */
|
||||
uint32_t biYpelsPerMeter; /* Vertical (Y) resolution in pixels/meter */
|
||||
uint32_t biClrUsed; /* Number of color used in the image (0: ALL) */
|
||||
uint32_t biClrImportant; /* Number of important color (0: ALL) */
|
||||
uint32_t biRedMask; /* Red channel bit mask */
|
||||
uint32_t biGreenMask; /* Green channel bit mask */
|
||||
uint32_t biBlueMask; /* Blue channel bit mask */
|
||||
uint32_t biAlphaMask; /* Alpha channel bit mask */
|
||||
uint32_t biColorSpaceType; /* Color space type */
|
||||
uint8_t biColorSpaceEP[36]; /* Color space end points */
|
||||
uint32_t biRedGamma; /* Red channel gamma */
|
||||
uint32_t biGreenGamma; /* Green channel gamma */
|
||||
uint32_t biBlueGamma; /* Blue channel gamma */
|
||||
uint32_t biIntent; /* Intent */
|
||||
uint32_t biIccProfileData; /* ICC profile data */
|
||||
uint32_t biIccProfileSize; /* ICC profile size */
|
||||
uint32_t biReserved; /* Reserved */
|
||||
} OPJ_BITMAPINFOHEADER;
|
||||
|
||||
static void opj_applyLUT8u_8u32s_C1R(
|
||||
uint8_t const* pSrc, int32_t srcStride,
|
||||
int32_t* pDst, int32_t dstStride,
|
||||
uint8_t const* pLUT,
|
||||
uint32_t width, uint32_t height)
|
||||
{
|
||||
uint32_t y;
|
||||
|
||||
for (y = height; y != 0U; --y) {
|
||||
uint32_t x;
|
||||
|
||||
for(x = 0; x < width; x++)
|
||||
{
|
||||
pDst[x] = (int32_t)pLUT[pSrc[x]];
|
||||
}
|
||||
pSrc += srcStride;
|
||||
pDst += dstStride;
|
||||
}
|
||||
}
|
||||
|
||||
static void opj_applyLUT8u_8u32s_C1P3R(
|
||||
uint8_t const* pSrc, int32_t srcStride,
|
||||
int32_t* const* pDst, int32_t const* pDstStride,
|
||||
uint8_t const* const* pLUT,
|
||||
uint32_t width, uint32_t height)
|
||||
{
|
||||
uint32_t y;
|
||||
int32_t* pR = pDst[0];
|
||||
int32_t* pG = pDst[1];
|
||||
int32_t* pB = pDst[2];
|
||||
uint8_t const* pLUT_R = pLUT[0];
|
||||
uint8_t const* pLUT_G = pLUT[1];
|
||||
uint8_t const* pLUT_B = pLUT[2];
|
||||
|
||||
for (y = height; y != 0U; --y) {
|
||||
uint32_t x;
|
||||
|
||||
for(x = 0; x < width; x++)
|
||||
{
|
||||
uint8_t idx = pSrc[x];
|
||||
pR[x] = (int32_t)pLUT_R[idx];
|
||||
pG[x] = (int32_t)pLUT_G[idx];
|
||||
pB[x] = (int32_t)pLUT_B[idx];
|
||||
}
|
||||
pSrc += srcStride;
|
||||
pR += pDstStride[0];
|
||||
pG += pDstStride[1];
|
||||
pB += pDstStride[2];
|
||||
}
|
||||
}
|
||||
|
||||
static void bmp24toimage(const uint8_t* pData, uint32_t stride, opj_image_t* image)
|
||||
{
|
||||
int index;
|
||||
uint32_t width, height;
|
||||
uint32_t x, y;
|
||||
const uint8_t *pSrc = NULL;
|
||||
|
||||
width = image->comps[0].w;
|
||||
height = image->comps[0].h;
|
||||
|
||||
index = 0;
|
||||
pSrc = pData + (height - 1U) * stride;
|
||||
for(y = 0; y < height; y++)
|
||||
{
|
||||
for(x = 0; x < width; x++)
|
||||
{
|
||||
image->comps[0].data[index] = (int32_t)pSrc[3*x+2]; /* R */
|
||||
image->comps[1].data[index] = (int32_t)pSrc[3*x+1]; /* G */
|
||||
image->comps[2].data[index] = (int32_t)pSrc[3*x+0]; /* B */
|
||||
index++;
|
||||
}
|
||||
pSrc -= stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void bmp_mask_get_shift_and_prec(uint32_t mask, uint32_t* shift, uint32_t* prec)
|
||||
{
|
||||
uint32_t l_shift, l_prec;
|
||||
|
||||
l_shift = l_prec = 0U;
|
||||
|
||||
if (mask != 0U) {
|
||||
while ((mask & 1U) == 0U) {
|
||||
mask >>= 1;
|
||||
l_shift++;
|
||||
}
|
||||
while (mask & 1U) {
|
||||
mask >>= 1;
|
||||
l_prec++;
|
||||
}
|
||||
}
|
||||
*shift = l_shift; *prec = l_prec;
|
||||
}
|
||||
|
||||
static void bmpmask32toimage(const uint8_t* pData, uint32_t stride, opj_image_t* image, uint32_t redMask, uint32_t greenMask, uint32_t blueMask, uint32_t alphaMask)
|
||||
{
|
||||
int index;
|
||||
uint32_t width, height;
|
||||
uint32_t x, y;
|
||||
const uint8_t *pSrc = NULL;
|
||||
opj_bool hasAlpha = OPJ_FALSE;
|
||||
uint32_t redShift, redPrec;
|
||||
uint32_t greenShift, greenPrec;
|
||||
uint32_t blueShift, bluePrec;
|
||||
uint32_t alphaShift, alphaPrec;
|
||||
|
||||
width = image->comps[0].w;
|
||||
height = image->comps[0].h;
|
||||
|
||||
hasAlpha = image->numcomps > 3U;
|
||||
|
||||
bmp_mask_get_shift_and_prec(redMask, &redShift, &redPrec);
|
||||
bmp_mask_get_shift_and_prec(greenMask, &greenShift, &greenPrec);
|
||||
bmp_mask_get_shift_and_prec(blueMask, &blueShift, &bluePrec);
|
||||
bmp_mask_get_shift_and_prec(alphaMask, &alphaShift, &alphaPrec);
|
||||
|
||||
image->comps[0].bpp = redPrec;
|
||||
image->comps[0].prec = redPrec;
|
||||
image->comps[1].bpp = greenPrec;
|
||||
image->comps[1].prec = greenPrec;
|
||||
image->comps[2].bpp = bluePrec;
|
||||
image->comps[2].prec = bluePrec;
|
||||
if (hasAlpha) {
|
||||
image->comps[3].bpp = alphaPrec;
|
||||
image->comps[3].prec = alphaPrec;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
pSrc = pData + (height - 1U) * stride;
|
||||
for(y = 0; y < height; y++)
|
||||
{
|
||||
for(x = 0; x < width; x++)
|
||||
{
|
||||
uint32_t value = 0U;
|
||||
|
||||
value |= ((uint32_t)pSrc[4*x+0]) << 0;
|
||||
value |= ((uint32_t)pSrc[4*x+1]) << 8;
|
||||
value |= ((uint32_t)pSrc[4*x+2]) << 16;
|
||||
value |= ((uint32_t)pSrc[4*x+3]) << 24;
|
||||
|
||||
image->comps[0].data[index] = (int32_t)((value & redMask) >> redShift); /* R */
|
||||
image->comps[1].data[index] = (int32_t)((value & greenMask) >> greenShift); /* G */
|
||||
image->comps[2].data[index] = (int32_t)((value & blueMask) >> blueShift); /* B */
|
||||
if (hasAlpha) {
|
||||
image->comps[3].data[index] = (int32_t)((value & alphaMask) >> alphaShift); /* A */
|
||||
}
|
||||
index++;
|
||||
}
|
||||
pSrc -= stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void bmpmask16toimage(const uint8_t* pData, uint32_t stride, opj_image_t* image, uint32_t redMask, uint32_t greenMask, uint32_t blueMask, uint32_t alphaMask)
|
||||
{
|
||||
int index;
|
||||
uint32_t width, height;
|
||||
uint32_t x, y;
|
||||
const uint8_t *pSrc = NULL;
|
||||
opj_bool hasAlpha = OPJ_FALSE;
|
||||
uint32_t redShift, redPrec;
|
||||
uint32_t greenShift, greenPrec;
|
||||
uint32_t blueShift, bluePrec;
|
||||
uint32_t alphaShift, alphaPrec;
|
||||
|
||||
width = image->comps[0].w;
|
||||
height = image->comps[0].h;
|
||||
|
||||
hasAlpha = image->numcomps > 3U;
|
||||
|
||||
bmp_mask_get_shift_and_prec(redMask, &redShift, &redPrec);
|
||||
bmp_mask_get_shift_and_prec(greenMask, &greenShift, &greenPrec);
|
||||
bmp_mask_get_shift_and_prec(blueMask, &blueShift, &bluePrec);
|
||||
bmp_mask_get_shift_and_prec(alphaMask, &alphaShift, &alphaPrec);
|
||||
|
||||
image->comps[0].bpp = redPrec;
|
||||
image->comps[0].prec = redPrec;
|
||||
image->comps[1].bpp = greenPrec;
|
||||
image->comps[1].prec = greenPrec;
|
||||
image->comps[2].bpp = bluePrec;
|
||||
image->comps[2].prec = bluePrec;
|
||||
if (hasAlpha) {
|
||||
image->comps[3].bpp = alphaPrec;
|
||||
image->comps[3].prec = alphaPrec;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
pSrc = pData + (height - 1U) * stride;
|
||||
for(y = 0; y < height; y++)
|
||||
{
|
||||
for(x = 0; x < width; x++)
|
||||
{
|
||||
uint32_t value = 0U;
|
||||
|
||||
value |= ((uint32_t)pSrc[2*x+0]) << 0;
|
||||
value |= ((uint32_t)pSrc[2*x+1]) << 8;
|
||||
|
||||
image->comps[0].data[index] = (int32_t)((value & redMask) >> redShift); /* R */
|
||||
image->comps[1].data[index] = (int32_t)((value & greenMask) >> greenShift); /* G */
|
||||
image->comps[2].data[index] = (int32_t)((value & blueMask) >> blueShift); /* B */
|
||||
if (hasAlpha) {
|
||||
image->comps[3].data[index] = (int32_t)((value & alphaMask) >> alphaShift); /* A */
|
||||
}
|
||||
index++;
|
||||
}
|
||||
pSrc -= stride;
|
||||
}
|
||||
}
|
||||
|
||||
static opj_image_t* bmp8toimage(const uint8_t* pData, uint32_t stride, opj_image_t* image, uint8_t const* const* pLUT)
|
||||
{
|
||||
uint32_t width, height;
|
||||
const uint8_t *pSrc = NULL;
|
||||
|
||||
width = image->comps[0].w;
|
||||
height = image->comps[0].h;
|
||||
|
||||
pSrc = pData + (height - 1U) * stride;
|
||||
if (image->numcomps == 1U) {
|
||||
opj_applyLUT8u_8u32s_C1R(pSrc, -(int32_t)stride, image->comps[0].data, (int32_t)width, pLUT[0], width, height);
|
||||
}
|
||||
else {
|
||||
int32_t* pDst[3];
|
||||
int32_t pDstStride[3];
|
||||
|
||||
pDst[0] = image->comps[0].data; pDst[1] = image->comps[1].data; pDst[2] = image->comps[2].data;
|
||||
pDstStride[0] = (int32_t)width; pDstStride[1] = (int32_t)width; pDstStride[2] = (int32_t)width;
|
||||
opj_applyLUT8u_8u32s_C1P3R(pSrc, -(int32_t)stride, pDst, pDstStride, pLUT, width, height);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
static opj_bool bmp_read_file_header(FILE* IN, OPJ_BITMAPFILEHEADER* header)
|
||||
{
|
||||
header->bfType = (uint16_t)getc(IN);
|
||||
header->bfType |= (uint16_t)((uint32_t)getc(IN) << 8);
|
||||
|
||||
if (header->bfType != 19778) {
|
||||
fprintf(stderr,"Error, not a BMP file!\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* FILE HEADER */
|
||||
/* ------------- */
|
||||
header->bfSize = (uint32_t)getc(IN);
|
||||
header->bfSize |= (uint32_t)getc(IN) << 8;
|
||||
header->bfSize |= (uint32_t)getc(IN) << 16;
|
||||
header->bfSize |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->bfReserved1 = (uint16_t)getc(IN);
|
||||
header->bfReserved1 |= (uint16_t)((uint32_t)getc(IN) << 8);
|
||||
|
||||
header->bfReserved2 = (uint16_t)getc(IN);
|
||||
header->bfReserved2 |= (uint16_t)((uint32_t)getc(IN) << 8);
|
||||
|
||||
header->bfOffBits = (uint32_t)getc(IN);
|
||||
header->bfOffBits |= (uint32_t)getc(IN) << 8;
|
||||
header->bfOffBits |= (uint32_t)getc(IN) << 16;
|
||||
header->bfOffBits |= (uint32_t)getc(IN) << 24;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
static opj_bool bmp_read_info_header(FILE* IN, OPJ_BITMAPINFOHEADER* header)
|
||||
{
|
||||
memset(header, 0, sizeof(*header));
|
||||
/* INFO HEADER */
|
||||
/* ------------- */
|
||||
header->biSize = (uint32_t)getc(IN);
|
||||
header->biSize |= (uint32_t)getc(IN) << 8;
|
||||
header->biSize |= (uint32_t)getc(IN) << 16;
|
||||
header->biSize |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
switch (header->biSize) {
|
||||
case 12U: /* BITMAPCOREHEADER */
|
||||
case 40U: /* BITMAPINFOHEADER */
|
||||
case 52U: /* BITMAPV2INFOHEADER */
|
||||
case 56U: /* BITMAPV3INFOHEADER */
|
||||
case 108U: /* BITMAPV4HEADER */
|
||||
case 124U: /* BITMAPV5HEADER */
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"Error, unknown BMP header size %d\n", header->biSize);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
header->biWidth = (uint32_t)getc(IN);
|
||||
header->biWidth |= (uint32_t)getc(IN) << 8;
|
||||
header->biWidth |= (uint32_t)getc(IN) << 16;
|
||||
header->biWidth |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biHeight = (uint32_t)getc(IN);
|
||||
header->biHeight |= (uint32_t)getc(IN) << 8;
|
||||
header->biHeight |= (uint32_t)getc(IN) << 16;
|
||||
header->biHeight |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biPlanes = (uint16_t)getc(IN);
|
||||
header->biPlanes |= (uint16_t)((uint32_t)getc(IN) << 8);
|
||||
|
||||
header->biBitCount = (uint16_t)getc(IN);
|
||||
header->biBitCount |= (uint16_t)((uint32_t)getc(IN) << 8);
|
||||
|
||||
if(header->biSize >= 40U) {
|
||||
header->biCompression = (uint32_t)getc(IN);
|
||||
header->biCompression |= (uint32_t)getc(IN) << 8;
|
||||
header->biCompression |= (uint32_t)getc(IN) << 16;
|
||||
header->biCompression |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biSizeImage = (uint32_t)getc(IN);
|
||||
header->biSizeImage |= (uint32_t)getc(IN) << 8;
|
||||
header->biSizeImage |= (uint32_t)getc(IN) << 16;
|
||||
header->biSizeImage |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biXpelsPerMeter = (uint32_t)getc(IN);
|
||||
header->biXpelsPerMeter |= (uint32_t)getc(IN) << 8;
|
||||
header->biXpelsPerMeter |= (uint32_t)getc(IN) << 16;
|
||||
header->biXpelsPerMeter |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biYpelsPerMeter = (uint32_t)getc(IN);
|
||||
header->biYpelsPerMeter |= (uint32_t)getc(IN) << 8;
|
||||
header->biYpelsPerMeter |= (uint32_t)getc(IN) << 16;
|
||||
header->biYpelsPerMeter |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biClrUsed = (uint32_t)getc(IN);
|
||||
header->biClrUsed |= (uint32_t)getc(IN) << 8;
|
||||
header->biClrUsed |= (uint32_t)getc(IN) << 16;
|
||||
header->biClrUsed |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biClrImportant = (uint32_t)getc(IN);
|
||||
header->biClrImportant |= (uint32_t)getc(IN) << 8;
|
||||
header->biClrImportant |= (uint32_t)getc(IN) << 16;
|
||||
header->biClrImportant |= (uint32_t)getc(IN) << 24;
|
||||
}
|
||||
|
||||
if(header->biSize >= 56U) {
|
||||
header->biRedMask = (uint32_t)getc(IN);
|
||||
header->biRedMask |= (uint32_t)getc(IN) << 8;
|
||||
header->biRedMask |= (uint32_t)getc(IN) << 16;
|
||||
header->biRedMask |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biGreenMask = (uint32_t)getc(IN);
|
||||
header->biGreenMask |= (uint32_t)getc(IN) << 8;
|
||||
header->biGreenMask |= (uint32_t)getc(IN) << 16;
|
||||
header->biGreenMask |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biBlueMask = (uint32_t)getc(IN);
|
||||
header->biBlueMask |= (uint32_t)getc(IN) << 8;
|
||||
header->biBlueMask |= (uint32_t)getc(IN) << 16;
|
||||
header->biBlueMask |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biAlphaMask = (uint32_t)getc(IN);
|
||||
header->biAlphaMask |= (uint32_t)getc(IN) << 8;
|
||||
header->biAlphaMask |= (uint32_t)getc(IN) << 16;
|
||||
header->biAlphaMask |= (uint32_t)getc(IN) << 24;
|
||||
}
|
||||
|
||||
if(header->biSize >= 108U) {
|
||||
header->biColorSpaceType = (uint32_t)getc(IN);
|
||||
header->biColorSpaceType |= (uint32_t)getc(IN) << 8;
|
||||
header->biColorSpaceType |= (uint32_t)getc(IN) << 16;
|
||||
header->biColorSpaceType |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
if (fread(&(header->biColorSpaceEP), 1U, sizeof(header->biColorSpaceEP), IN) != sizeof(header->biColorSpaceEP)) {
|
||||
fprintf(stderr,"Error, can't read BMP header\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
header->biRedGamma = (uint32_t)getc(IN);
|
||||
header->biRedGamma |= (uint32_t)getc(IN) << 8;
|
||||
header->biRedGamma |= (uint32_t)getc(IN) << 16;
|
||||
header->biRedGamma |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biGreenGamma = (uint32_t)getc(IN);
|
||||
header->biGreenGamma |= (uint32_t)getc(IN) << 8;
|
||||
header->biGreenGamma |= (uint32_t)getc(IN) << 16;
|
||||
header->biGreenGamma |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biBlueGamma = (uint32_t)getc(IN);
|
||||
header->biBlueGamma |= (uint32_t)getc(IN) << 8;
|
||||
header->biBlueGamma |= (uint32_t)getc(IN) << 16;
|
||||
header->biBlueGamma |= (uint32_t)getc(IN) << 24;
|
||||
}
|
||||
|
||||
if(header->biSize >= 124U) {
|
||||
header->biIntent = (uint32_t)getc(IN);
|
||||
header->biIntent |= (uint32_t)getc(IN) << 8;
|
||||
header->biIntent |= (uint32_t)getc(IN) << 16;
|
||||
header->biIntent |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biIccProfileData = (uint32_t)getc(IN);
|
||||
header->biIccProfileData |= (uint32_t)getc(IN) << 8;
|
||||
header->biIccProfileData |= (uint32_t)getc(IN) << 16;
|
||||
header->biIccProfileData |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biIccProfileSize = (uint32_t)getc(IN);
|
||||
header->biIccProfileSize |= (uint32_t)getc(IN) << 8;
|
||||
header->biIccProfileSize |= (uint32_t)getc(IN) << 16;
|
||||
header->biIccProfileSize |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biReserved = (uint32_t)getc(IN);
|
||||
header->biReserved |= (uint32_t)getc(IN) << 8;
|
||||
header->biReserved |= (uint32_t)getc(IN) << 16;
|
||||
header->biReserved |= (uint32_t)getc(IN) << 24;
|
||||
}
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static opj_bool bmp_read_raw_data(FILE* IN, uint8_t* pData, uint32_t stride, uint32_t width, uint32_t height)
|
||||
{
|
||||
OPJ_ARG_NOT_USED(width);
|
||||
|
||||
if ( fread(pData, sizeof(uint8_t), stride * height, IN) != (stride * height) )
|
||||
{
|
||||
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static opj_bool bmp_read_rle8_data(FILE* IN, uint8_t* pData, uint32_t stride, uint32_t width, uint32_t height)
|
||||
{
|
||||
uint32_t x, y;
|
||||
uint8_t *pix;
|
||||
const uint8_t *beyond;
|
||||
|
||||
beyond = pData + stride * height;
|
||||
pix = pData;
|
||||
|
||||
x = y = 0U;
|
||||
while (y < height)
|
||||
{
|
||||
int c = getc(IN);
|
||||
|
||||
if (c) {
|
||||
int j;
|
||||
uint8_t c1 = (uint8_t)getc(IN);
|
||||
|
||||
for (j = 0; (j < c) && (x < width) && ((size_t)pix < (size_t)beyond); j++, x++, pix++) {
|
||||
*pix = c1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
c = getc(IN);
|
||||
if (c == 0x00) { /* EOL */
|
||||
x = 0;
|
||||
++y;
|
||||
pix = pData + y * stride + x;
|
||||
}
|
||||
else if (c == 0x01) { /* EOP */
|
||||
break;
|
||||
}
|
||||
else if (c == 0x02) { /* MOVE by dxdy */
|
||||
c = getc(IN);
|
||||
x += (uint32_t)c;
|
||||
c = getc(IN);
|
||||
y += (uint32_t)c;
|
||||
pix = pData + y * stride + x;
|
||||
}
|
||||
else /* 03 .. 255 */
|
||||
{
|
||||
int j;
|
||||
for (j = 0; (j < c) && (x < width) && ((size_t)pix < (size_t)beyond); j++, x++, pix++)
|
||||
{
|
||||
uint8_t c1 = (uint8_t)getc(IN);
|
||||
*pix = c1;
|
||||
}
|
||||
if ((uint32_t)c & 1U) { /* skip padding byte */
|
||||
getc(IN);
|
||||
}
|
||||
}
|
||||
}
|
||||
}/* while() */
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static opj_bool bmp_read_rle4_data(FILE* IN, uint8_t* pData, uint32_t stride, uint32_t width, uint32_t height)
|
||||
{
|
||||
uint32_t x, y;
|
||||
uint8_t *pix;
|
||||
const uint8_t *beyond;
|
||||
|
||||
beyond = pData + stride * height;
|
||||
pix = pData;
|
||||
x = y = 0U;
|
||||
while(y < height)
|
||||
{
|
||||
int c = getc(IN);
|
||||
if(c == EOF) break;
|
||||
|
||||
if(c) {/* encoded mode */
|
||||
int j;
|
||||
uint8_t c1 = (uint8_t)getc(IN);
|
||||
|
||||
for (j = 0; (j < c) && (x < width) && ((size_t)pix < (size_t)beyond); j++, x++, pix++) {
|
||||
*pix = (uint8_t)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU));
|
||||
}
|
||||
}
|
||||
else { /* absolute mode */
|
||||
c = getc(IN);
|
||||
if(c == EOF) break;
|
||||
|
||||
if(c == 0x00) { /* EOL */
|
||||
x = 0; y++; pix = pData + y * stride;
|
||||
}
|
||||
else if(c == 0x01) { /* EOP */
|
||||
break;
|
||||
}
|
||||
else if(c == 0x02) { /* MOVE by dxdy */
|
||||
c = getc(IN); x += (uint32_t)c;
|
||||
c = getc(IN); y += (uint32_t)c;
|
||||
pix = pData + y * stride + x;
|
||||
}
|
||||
else { /* 03 .. 255 : absolute mode */
|
||||
int j;
|
||||
uint8_t c1 = 0U;
|
||||
|
||||
for (j = 0; (j < c) && (x < width) && ((size_t)pix < (size_t)beyond); j++, x++, pix++) {
|
||||
if((j&1) == 0) {
|
||||
c1 = (uint8_t)getc(IN);
|
||||
}
|
||||
*pix = (uint8_t)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU));
|
||||
}
|
||||
if(((c&3) == 1) || ((c&3) == 2)) { /* skip padding byte */
|
||||
getc(IN);
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* while(y < height) */
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
|
||||
{
|
||||
opj_image_cmptparm_t cmptparm[4]; /* maximum of 4 components */
|
||||
uint8_t lut_R[256], lut_G[256], lut_B[256];
|
||||
uint8_t const* pLUT[3];
|
||||
opj_image_t * image = NULL;
|
||||
FILE *IN;
|
||||
OPJ_BITMAPFILEHEADER File_h;
|
||||
OPJ_BITMAPINFOHEADER Info_h;
|
||||
uint32_t i, palette_len, numcmpts = 1U;
|
||||
opj_bool l_result = OPJ_FALSE;
|
||||
uint8_t* pData = NULL;
|
||||
uint32_t stride;
|
||||
|
||||
pLUT[0] = lut_R; pLUT[1] = lut_G; pLUT[2] = lut_B;
|
||||
|
||||
IN = fopen(filename, "rb");
|
||||
if (!IN)
|
||||
{
|
||||
fprintf(stderr, "Failed to open %s for reading !!\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!bmp_read_file_header(IN, &File_h)) {
|
||||
fclose(IN);
|
||||
return NULL;
|
||||
}
|
||||
if (!bmp_read_info_header(IN, &Info_h)) {
|
||||
fclose(IN);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Load palette */
|
||||
if (Info_h.biBitCount <= 8U)
|
||||
{
|
||||
memset(&lut_R[0], 0, sizeof(lut_R));
|
||||
memset(&lut_G[0], 0, sizeof(lut_G));
|
||||
memset(&lut_B[0], 0, sizeof(lut_B));
|
||||
|
||||
palette_len = Info_h.biClrUsed;
|
||||
if((palette_len == 0U) && (Info_h.biBitCount <= 8U)) {
|
||||
palette_len = (1U << Info_h.biBitCount);
|
||||
}
|
||||
if (palette_len > 256U) {
|
||||
palette_len = 256U;
|
||||
}
|
||||
if (palette_len > 0U) {
|
||||
uint8_t has_color = 0U;
|
||||
for (i = 0U; i < palette_len; i++) {
|
||||
lut_B[i] = (uint8_t)getc(IN);
|
||||
lut_G[i] = (uint8_t)getc(IN);
|
||||
lut_R[i] = (uint8_t)getc(IN);
|
||||
(void)getc(IN); /* padding */
|
||||
has_color |= (lut_B[i] ^ lut_G[i]) | (lut_G[i] ^ lut_R[i]);
|
||||
}
|
||||
if(has_color) {
|
||||
numcmpts = 3U;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
numcmpts = 3U;
|
||||
if ((Info_h.biCompression == 3) && (Info_h.biAlphaMask != 0U)) {
|
||||
numcmpts++;
|
||||
}
|
||||
}
|
||||
|
||||
stride = ((Info_h.biWidth * Info_h.biBitCount + 31U) / 32U) * 4U; /* rows are aligned on 32bits */
|
||||
if (Info_h.biBitCount == 4 && Info_h.biCompression == 2) { /* RLE 4 gets decoded as 8 bits data for now... */
|
||||
stride = ((Info_h.biWidth * 8U + 31U) / 32U) * 4U;
|
||||
}
|
||||
pData = (uint8_t *) calloc(1, stride * Info_h.biHeight * sizeof(uint8_t));
|
||||
if (pData == NULL) {
|
||||
fclose(IN);
|
||||
return NULL;
|
||||
}
|
||||
/* Place the cursor at the beginning of the image information */
|
||||
fseek(IN, 0, SEEK_SET);
|
||||
fseek(IN, (long)File_h.bfOffBits, SEEK_SET);
|
||||
|
||||
switch (Info_h.biCompression) {
|
||||
case 0:
|
||||
case 3:
|
||||
/* read raw data */
|
||||
l_result = bmp_read_raw_data(IN, pData, stride, Info_h.biWidth, Info_h.biHeight);
|
||||
break;
|
||||
case 1:
|
||||
/* read rle8 data */
|
||||
l_result = bmp_read_rle8_data(IN, pData, stride, Info_h.biWidth, Info_h.biHeight);
|
||||
break;
|
||||
case 2:
|
||||
/* read rle4 data */
|
||||
l_result = bmp_read_rle4_data(IN, pData, stride, Info_h.biWidth, Info_h.biHeight);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unsupported BMP compression\n");
|
||||
l_result = OPJ_FALSE;
|
||||
break;
|
||||
}
|
||||
if (!l_result) {
|
||||
free(pData);
|
||||
fclose(IN);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* create the image */
|
||||
memset(&cmptparm[0], 0, sizeof(cmptparm));
|
||||
for(i = 0; i < 4U; i++)
|
||||
{
|
||||
cmptparm[i].prec = 8;
|
||||
cmptparm[i].bpp = 8;
|
||||
cmptparm[i].sgnd = 0;
|
||||
cmptparm[i].dx = parameters->subsampling_dx;
|
||||
cmptparm[i].dy = parameters->subsampling_dy;
|
||||
cmptparm[i].w = Info_h.biWidth;
|
||||
cmptparm[i].h = Info_h.biHeight;
|
||||
}
|
||||
|
||||
image = opj_image_create(numcmpts, &cmptparm[0], (numcmpts == 1U) ? CLRSPC_GRAY : CLRSPC_SRGB);
|
||||
if(!image) {
|
||||
fclose(IN);
|
||||
free(pData);
|
||||
return NULL;
|
||||
}
|
||||
/* if (numcmpts == 4U) {
|
||||
image->comps[3].alpha = 1;
|
||||
} */
|
||||
|
||||
/* set image offset and reference grid */
|
||||
image->x0 = (uint32_t)parameters->image_offset_x0;
|
||||
image->y0 = (uint32_t)parameters->image_offset_y0;
|
||||
image->x1 = image->x0 + (Info_h.biWidth - 1U) * (uint32_t)parameters->subsampling_dx + 1U;
|
||||
image->y1 = image->y0 + (Info_h.biHeight - 1U) * (uint32_t)parameters->subsampling_dy + 1U;
|
||||
|
||||
/* Read the data */
|
||||
if (Info_h.biBitCount == 24 && Info_h.biCompression == 0) { /*RGB */
|
||||
bmp24toimage(pData, stride, image);
|
||||
}
|
||||
else if (Info_h.biBitCount == 8 && Info_h.biCompression == 0) { /* RGB 8bpp Indexed */
|
||||
bmp8toimage(pData, stride, image, pLUT);
|
||||
}
|
||||
else if (Info_h.biBitCount == 8 && Info_h.biCompression == 1) { /*RLE8*/
|
||||
bmp8toimage(pData, stride, image, pLUT);
|
||||
}
|
||||
else if (Info_h.biBitCount == 4 && Info_h.biCompression == 2) { /*RLE4*/
|
||||
bmp8toimage(pData, stride, image, pLUT); /* RLE 4 gets decoded as 8 bits data for now */
|
||||
}
|
||||
else if (Info_h.biBitCount == 32 && Info_h.biCompression == 0) { /* RGBX */
|
||||
bmpmask32toimage(pData, stride, image, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, 0x00000000U);
|
||||
}
|
||||
else if (Info_h.biBitCount == 32 && Info_h.biCompression == 3) { /* bitmask */
|
||||
bmpmask32toimage(pData, stride, image, Info_h.biRedMask, Info_h.biGreenMask, Info_h.biBlueMask, Info_h.biAlphaMask);
|
||||
}
|
||||
else if (Info_h.biBitCount == 16 && Info_h.biCompression == 0) { /* RGBX */
|
||||
bmpmask16toimage(pData, stride, image, 0x7C00U, 0x03E0U, 0x001FU, 0x0000U);
|
||||
}
|
||||
else if (Info_h.biBitCount == 16 && Info_h.biCompression == 3) { /* bitmask */
|
||||
if ((Info_h.biRedMask == 0U) && (Info_h.biGreenMask == 0U) && (Info_h.biBlueMask == 0U)) {
|
||||
Info_h.biRedMask = 0xF800U;
|
||||
Info_h.biGreenMask = 0x07E0U;
|
||||
Info_h.biBlueMask = 0x001FU;
|
||||
}
|
||||
bmpmask16toimage(pData, stride, image, Info_h.biRedMask, Info_h.biGreenMask, Info_h.biBlueMask, Info_h.biAlphaMask);
|
||||
}
|
||||
else {
|
||||
opj_image_destroy(image);
|
||||
image = NULL;
|
||||
fprintf(stderr, "Other system than 24 bits/pixels or 8 bits (no RLE coding) is not yet implemented [%d]\n", Info_h.biBitCount);
|
||||
}
|
||||
free(pData);
|
||||
fclose(IN);
|
||||
return image;
|
||||
}
|
||||
|
||||
int imagetobmp(opj_image_t * image, const char *outfile) {
|
||||
int w, h;
|
||||
int i, pad;
|
||||
FILE *fdest = NULL;
|
||||
int adjustR, adjustG, adjustB;
|
||||
|
||||
if (image->comps[0].prec < 8) {
|
||||
fprintf(stderr, "Unsupported number of components: %d\n", image->comps[0].prec);
|
||||
return 1;
|
||||
}
|
||||
if (image->numcomps >= 3 && image->comps[0].dx == image->comps[1].dx
|
||||
&& image->comps[1].dx == image->comps[2].dx
|
||||
&& image->comps[0].dy == image->comps[1].dy
|
||||
&& image->comps[1].dy == image->comps[2].dy
|
||||
&& image->comps[0].prec == image->comps[1].prec
|
||||
&& image->comps[1].prec == image->comps[2].prec) {
|
||||
|
||||
/* -->> -->> -->> -->>
|
||||
24 bits color
|
||||
<<-- <<-- <<-- <<-- */
|
||||
|
||||
fdest = fopen(outfile, "wb");
|
||||
if (!fdest) {
|
||||
fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
w = (int)image->comps[0].w;
|
||||
h = (int)image->comps[0].h;
|
||||
|
||||
fprintf(fdest, "BM");
|
||||
|
||||
/* FILE HEADER */
|
||||
/* ------------- */
|
||||
fprintf(fdest, "%c%c%c%c",
|
||||
(uint8_t) (h * w * 3 + 3 * h * (w % 2) + 54) & 0xff,
|
||||
(uint8_t) ((h * w * 3 + 3 * h * (w % 2) + 54) >> 8) & 0xff,
|
||||
(uint8_t) ((h * w * 3 + 3 * h * (w % 2) + 54) >> 16) & 0xff,
|
||||
(uint8_t) ((h * w * 3 + 3 * h * (w % 2) + 54) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (54) & 0xff, ((54) >> 8) & 0xff,((54) >> 16) & 0xff, ((54) >> 24) & 0xff);
|
||||
|
||||
/* INFO HEADER */
|
||||
/* ------------- */
|
||||
fprintf(fdest, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff, ((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (uint8_t) ((w) & 0xff),
|
||||
(uint8_t) ((w) >> 8) & 0xff,
|
||||
(uint8_t) ((w) >> 16) & 0xff,
|
||||
(uint8_t) ((w) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (uint8_t) ((h) & 0xff),
|
||||
(uint8_t) ((h) >> 8) & 0xff,
|
||||
(uint8_t) ((h) >> 16) & 0xff,
|
||||
(uint8_t) ((h) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
|
||||
fprintf(fdest, "%c%c", (24) & 0xff, ((24) >> 8) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (uint8_t) (3 * h * w + 3 * h * (w % 2)) & 0xff,
|
||||
(uint8_t) ((h * w * 3 + 3 * h * (w % 2)) >> 8) & 0xff,
|
||||
(uint8_t) ((h * w * 3 + 3 * h * (w % 2)) >> 16) & 0xff,
|
||||
(uint8_t) ((h * w * 3 + 3 * h * (w % 2)) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
|
||||
if (image->comps[0].prec > 8) {
|
||||
adjustR = (int)image->comps[0].prec - 8;
|
||||
printf("BMP CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
|
||||
}
|
||||
else
|
||||
adjustR = 0;
|
||||
if (image->comps[1].prec > 8) {
|
||||
adjustG = (int)image->comps[1].prec - 8;
|
||||
printf("BMP CONVERSION: Truncating component 1 from %d bits to 8 bits\n", image->comps[1].prec);
|
||||
}
|
||||
else
|
||||
adjustG = 0;
|
||||
if (image->comps[2].prec > 8) {
|
||||
adjustB = (int)image->comps[2].prec - 8;
|
||||
printf("BMP CONVERSION: Truncating component 2 from %d bits to 8 bits\n", image->comps[2].prec);
|
||||
}
|
||||
else
|
||||
adjustB = 0;
|
||||
|
||||
for (i = 0; i < w * h; i++) {
|
||||
uint8_t rc, gc, bc;
|
||||
int r, g, b;
|
||||
|
||||
r = image->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||
r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
||||
r = ((r >> adjustR)+((r >> (adjustR-1))%2));
|
||||
if(r > 255) r = 255; else if(r < 0) r = 0;
|
||||
rc = (uint8_t)r;
|
||||
|
||||
g = image->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||
g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
|
||||
g = ((g >> adjustG)+((g >> (adjustG-1))%2));
|
||||
if(g > 255) g = 255; else if(g < 0) g = 0;
|
||||
gc = (uint8_t)g;
|
||||
|
||||
b = image->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||
b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0);
|
||||
b = ((b >> adjustB)+((b >> (adjustB-1))%2));
|
||||
if(b > 255) b = 255; else if(b < 0) b = 0;
|
||||
bc = (uint8_t)b;
|
||||
|
||||
fprintf(fdest, "%c%c%c", bc, gc, rc);
|
||||
|
||||
if ((i + 1) % w == 0) {
|
||||
for (pad = (3 * w) % 4 ? 4 - (3 * w) % 4 : 0; pad > 0; pad--) /* ADD */
|
||||
fprintf(fdest, "%c", 0);
|
||||
}
|
||||
}
|
||||
fclose(fdest);
|
||||
} else { /* Gray-scale */
|
||||
|
||||
/* -->> -->> -->> -->>
|
||||
8 bits non code (Gray scale)
|
||||
<<-- <<-- <<-- <<-- */
|
||||
|
||||
fdest = fopen(outfile, "wb");
|
||||
if (!fdest) {
|
||||
fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
|
||||
return 1;
|
||||
}
|
||||
w = (int)image->comps[0].w;
|
||||
h = (int)image->comps[0].h;
|
||||
|
||||
fprintf(fdest, "BM");
|
||||
|
||||
/* FILE HEADER */
|
||||
/* ------------- */
|
||||
fprintf(fdest, "%c%c%c%c", (uint8_t) (h * w + 54 + 1024 + h * (w % 2)) & 0xff,
|
||||
(uint8_t) ((h * w + 54 + 1024 + h * (w % 2)) >> 8) & 0xff,
|
||||
(uint8_t) ((h * w + 54 + 1024 + h * (w % 2)) >> 16) & 0xff,
|
||||
(uint8_t) ((h * w + 54 + 1024 + w * (w % 2)) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (54 + 1024) & 0xff, ((54 + 1024) >> 8) & 0xff,
|
||||
((54 + 1024) >> 16) & 0xff,
|
||||
((54 + 1024) >> 24) & 0xff);
|
||||
|
||||
/* INFO HEADER */
|
||||
/* ------------- */
|
||||
fprintf(fdest, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff, ((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (uint8_t) ((w) & 0xff),
|
||||
(uint8_t) ((w) >> 8) & 0xff,
|
||||
(uint8_t) ((w) >> 16) & 0xff,
|
||||
(uint8_t) ((w) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (uint8_t) ((h) & 0xff),
|
||||
(uint8_t) ((h) >> 8) & 0xff,
|
||||
(uint8_t) ((h) >> 16) & 0xff,
|
||||
(uint8_t) ((h) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
|
||||
fprintf(fdest, "%c%c", (8) & 0xff, ((8) >> 8) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (uint8_t) (h * w + h * (w % 2)) & 0xff,
|
||||
(uint8_t) ((h * w + h * (w % 2)) >> 8) & 0xff,
|
||||
(uint8_t) ((h * w + h * (w % 2)) >> 16) & 0xff,
|
||||
(uint8_t) ((h * w + h * (w % 2)) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff, ((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff, ((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
|
||||
|
||||
if (image->comps[0].prec > 8) {
|
||||
adjustR = (int)image->comps[0].prec - 8;
|
||||
printf("BMP CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
|
||||
}else
|
||||
adjustR = 0;
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
fprintf(fdest, "%c%c%c%c", i, i, i, 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < w * h; i++) {
|
||||
int r;
|
||||
|
||||
r = image->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||
r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
||||
r = ((r >> adjustR)+((r >> (adjustR-1))%2));
|
||||
if(r > 255) r = 255; else if(r < 0) r = 0;
|
||||
|
||||
fprintf(fdest, "%c", (uint8_t)r);
|
||||
|
||||
if ((i + 1) % w == 0) {
|
||||
for (pad = w % 4 ? 4 - w % 4 : 0; pad > 0; pad--) /* ADD */
|
||||
fprintf(fdest, "%c", 0);
|
||||
}
|
||||
}
|
||||
fclose(fdest);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,496 +0,0 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||
* Copyright (c) 2015, Matthieu Darbois
|
||||
* 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 "opj_config.h"
|
||||
|
||||
#ifndef HAVE_LIBPNG
|
||||
# error HAVE_LIBPNG_NOT_DEFINED
|
||||
#endif /* HAVE_LIBPNG */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <zlib.h>
|
||||
#include <png.h>
|
||||
|
||||
#include "openjpeg.h"
|
||||
#include "convert.h"
|
||||
|
||||
#define PNG_MAGIC "\x89PNG\x0d\x0a\x1a\x0a"
|
||||
#define MAGIC_SIZE 8
|
||||
/* PNG allows bits per sample: 1, 2, 4, 8, 16 */
|
||||
|
||||
|
||||
static void convert_16u32s_C1R(const png_byte* pSrc, png_int_32* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < length; i++) {
|
||||
png_int_32 val0 = *pSrc++;
|
||||
png_int_32 val1 = *pSrc++;
|
||||
pDst[i] = val0 << 8 | val1;
|
||||
}
|
||||
}
|
||||
|
||||
opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
|
||||
{
|
||||
png_structp png = NULL;
|
||||
png_infop info = NULL;
|
||||
double gamma;
|
||||
int bit_depth, interlace_type,compression_type, filter_type;
|
||||
png_uint_32 i;
|
||||
png_uint_32 width, height = 0U;
|
||||
int color_type;
|
||||
FILE *reader = NULL;
|
||||
png_byte** rows = NULL;
|
||||
png_int_32* row32s = NULL;
|
||||
/* j2k: */
|
||||
opj_image_t *image = NULL;
|
||||
opj_image_cmptparm_t cmptparm[4];
|
||||
png_uint_32 nr_comp;
|
||||
png_byte sigbuf[8];
|
||||
convert_XXx32s_C1R cvtXXTo32s = NULL;
|
||||
convert_32s_CXPX cvtCxToPx = NULL;
|
||||
png_int_32* planes[4];
|
||||
|
||||
if((reader = fopen(read_idf, "rb")) == NULL)
|
||||
{
|
||||
fprintf(stderr,"pngtoimage: can not open %s\n",read_idf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(fread(sigbuf, 1, MAGIC_SIZE, reader) != MAGIC_SIZE
|
||||
|| memcmp(sigbuf, PNG_MAGIC, MAGIC_SIZE) != 0)
|
||||
{
|
||||
fprintf(stderr,"pngtoimage: %s is no valid PNG file\n",read_idf);
|
||||
goto fin;
|
||||
}
|
||||
|
||||
if((png = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||
NULL, NULL, NULL)) == NULL)
|
||||
goto fin;
|
||||
if((info = png_create_info_struct(png)) == NULL)
|
||||
goto fin;
|
||||
|
||||
if(setjmp(png_jmpbuf(png)))
|
||||
goto fin;
|
||||
|
||||
png_init_io(png, reader);
|
||||
png_set_sig_bytes(png, MAGIC_SIZE);
|
||||
|
||||
png_read_info(png, info);
|
||||
|
||||
if(png_get_IHDR(png, info, &width, &height,
|
||||
&bit_depth, &color_type, &interlace_type,
|
||||
&compression_type, &filter_type) == 0)
|
||||
goto fin;
|
||||
|
||||
/* png_set_expand():
|
||||
* expand paletted images to RGB, expand grayscale images of
|
||||
* less than 8-bit depth to 8-bit depth, and expand tRNS chunks
|
||||
* to alpha channels.
|
||||
*/
|
||||
if(color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||
png_set_expand(png);
|
||||
}
|
||||
|
||||
if(png_get_valid(png, info, PNG_INFO_tRNS)) {
|
||||
png_set_expand(png);
|
||||
}
|
||||
/* We might wan't to expand background */
|
||||
/*
|
||||
if(png_get_valid(png, info, PNG_INFO_bKGD)) {
|
||||
png_color_16p bgnd;
|
||||
png_get_bKGD(png, info, &bgnd);
|
||||
png_set_background(png, bgnd, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
||||
}
|
||||
*/
|
||||
|
||||
if( !png_get_gAMA(png, info, &gamma))
|
||||
gamma = 1.0;
|
||||
|
||||
/* we're not displaying but converting, screen gamma == 1.0 */
|
||||
png_set_gamma(png, 1.0, gamma);
|
||||
|
||||
png_read_update_info(png, info);
|
||||
|
||||
color_type = png_get_color_type(png, info);
|
||||
|
||||
switch (color_type) {
|
||||
case PNG_COLOR_TYPE_GRAY:
|
||||
nr_comp = 1;
|
||||
break;
|
||||
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||
nr_comp = 2;
|
||||
break;
|
||||
case PNG_COLOR_TYPE_RGB:
|
||||
nr_comp = 3;
|
||||
break;
|
||||
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||
nr_comp = 4;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"pngtoimage: colortype %d is not supported\n", color_type);
|
||||
goto fin;
|
||||
}
|
||||
cvtCxToPx = convert_32s_CXPX_LUT[nr_comp];
|
||||
bit_depth = png_get_bit_depth(png, info);
|
||||
|
||||
switch (bit_depth) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
cvtXXTo32s = convert_XXu32s_C1R_LUT[bit_depth];
|
||||
break;
|
||||
case 16: /* 16 bpp is specific to PNG */
|
||||
cvtXXTo32s = convert_16u32s_C1R;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"pngtoimage: bit depth %d is not supported\n", bit_depth);
|
||||
goto fin;
|
||||
}
|
||||
|
||||
|
||||
rows = (png_byte**)calloc(height+1, sizeof(png_byte*));
|
||||
for(i = 0; i < height; ++i)
|
||||
rows[i] = (png_byte*)malloc(png_get_rowbytes(png,info));
|
||||
|
||||
png_read_image(png, rows);
|
||||
|
||||
/* Create image */
|
||||
memset(cmptparm, 0, sizeof(cmptparm));
|
||||
for(i = 0; i < nr_comp; ++i)
|
||||
{
|
||||
cmptparm[i].prec = (png_uint_32)bit_depth;
|
||||
/* bits_per_pixel: 8 or 16 */
|
||||
cmptparm[i].bpp = (png_uint_32)bit_depth;
|
||||
cmptparm[i].sgnd = 0;
|
||||
cmptparm[i].dx = (png_uint_32)params->subsampling_dx;
|
||||
cmptparm[i].dy = (png_uint_32)params->subsampling_dy;
|
||||
cmptparm[i].w = (png_uint_32)width;
|
||||
cmptparm[i].h = (png_uint_32)height;
|
||||
}
|
||||
|
||||
image = opj_image_create(nr_comp, &cmptparm[0], (nr_comp > 2U) ? CLRSPC_SRGB : CLRSPC_GRAY);
|
||||
if(image == NULL) goto fin;
|
||||
image->x0 = (png_uint_32)params->image_offset_x0;
|
||||
image->y0 = (png_uint_32)params->image_offset_y0;
|
||||
image->x1 = (png_uint_32)(image->x0 + (width - 1) * (png_uint_32)params->subsampling_dx + 1 + image->x0);
|
||||
image->y1 = (png_uint_32)(image->y0 + (height - 1) * (png_uint_32)params->subsampling_dy + 1 + image->y0);
|
||||
|
||||
row32s = (png_int_32 *)malloc((size_t)width * nr_comp * sizeof(png_int_32));
|
||||
if(row32s == NULL) goto fin;
|
||||
|
||||
/* Set alpha channel */
|
||||
/* image->comps[nr_comp-1U].alpha = 1U - (nr_comp & 1U); */
|
||||
|
||||
for(i = 0; i < nr_comp; i++)
|
||||
{
|
||||
planes[i] = image->comps[i].data;
|
||||
}
|
||||
|
||||
for(i = 0; i < height; ++i)
|
||||
{
|
||||
cvtXXTo32s(rows[i], row32s, (size_t)width * nr_comp);
|
||||
cvtCxToPx(row32s, planes, width);
|
||||
planes[0] += width;
|
||||
planes[1] += width;
|
||||
planes[2] += width;
|
||||
planes[3] += width;
|
||||
}
|
||||
fin:
|
||||
if(rows)
|
||||
{
|
||||
for(i = 0; i < height; ++i)
|
||||
free(rows[i]);
|
||||
free(rows);
|
||||
}
|
||||
if (row32s) {
|
||||
free(row32s);
|
||||
}
|
||||
if(png)
|
||||
png_destroy_read_struct(&png, &info, NULL);
|
||||
|
||||
fclose(reader);
|
||||
|
||||
return image;
|
||||
|
||||
}/* pngtoimage() */
|
||||
|
||||
|
||||
static void convert_32s16u_C1R(const png_int_32* pSrc, png_byte* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < length; i++) {
|
||||
png_uint_32 val = (png_uint_32)pSrc[i];
|
||||
*pDst++ = (png_byte)(val >> 8);
|
||||
*pDst++ = (png_byte)val;
|
||||
}
|
||||
}
|
||||
int imagetopng(opj_image_t * image, const char *write_idf)
|
||||
{
|
||||
FILE * volatile writer = NULL;
|
||||
png_structp png = NULL;
|
||||
png_infop info = NULL;
|
||||
png_bytep volatile row_buf = NULL;
|
||||
int nr_comp, color_type;
|
||||
volatile int prec;
|
||||
png_color_8 sig_bit;
|
||||
png_int_32 const* planes[4];
|
||||
int i;
|
||||
png_int_32* volatile buffer32s = NULL;
|
||||
|
||||
volatile int fails = 1;
|
||||
|
||||
memset(&sig_bit, 0, sizeof(sig_bit));
|
||||
prec = (int)image->comps[0].prec;
|
||||
planes[0] = image->comps[0].data;
|
||||
nr_comp = (int)image->numcomps;
|
||||
|
||||
if (nr_comp > 4) {
|
||||
nr_comp = 4;
|
||||
}
|
||||
for (i = 1; i < nr_comp; ++i) {
|
||||
if (image->comps[0].dx != image->comps[i].dx) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].dy != image->comps[i].dy) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].prec != image->comps[i].prec) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].sgnd != image->comps[i].sgnd) {
|
||||
break;
|
||||
}
|
||||
planes[i] = image->comps[i].data;
|
||||
}
|
||||
if (i != nr_comp) {
|
||||
fprintf(stderr,"imagetopng: All components shall have the same subsampling, same bit depth, same sign.\n");
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < nr_comp; ++i) {
|
||||
clip_component(&(image->comps[i]), image->comps[0].prec);
|
||||
}
|
||||
if(prec > 8 && prec < 16)
|
||||
{
|
||||
for (i = 0; i < nr_comp; ++i) {
|
||||
scale_component(&(image->comps[i]), 16);
|
||||
}
|
||||
prec = 16;
|
||||
}
|
||||
else if(prec < 8 && nr_comp > 1)/* GRAY_ALPHA, RGB, RGB_ALPHA */
|
||||
{
|
||||
for (i = 0; i < nr_comp; ++i) {
|
||||
scale_component(&(image->comps[i]), 8);
|
||||
}
|
||||
prec = 8;
|
||||
} else if((prec > 1) && (prec < 8) && ((prec == 6) || ((prec & 1)==1))) { /* GRAY with non native precision */
|
||||
if ((prec == 5) || (prec == 6)) {
|
||||
prec = 8;
|
||||
} else {
|
||||
prec++;
|
||||
}
|
||||
for (i = 0; i < nr_comp; ++i) {
|
||||
scale_component(&(image->comps[i]), (png_uint_32)prec);
|
||||
}
|
||||
}
|
||||
|
||||
if(prec != 1 && prec != 2 && prec != 4 && prec != 8 && prec != 16)
|
||||
{
|
||||
fprintf(stderr,"imagetopng: can not create %s\n\twrong bit_depth %d\n", write_idf, prec);
|
||||
return fails;
|
||||
}
|
||||
|
||||
writer = fopen(write_idf, "wb");
|
||||
|
||||
if(writer == NULL) return fails;
|
||||
|
||||
/* Create and initialize the png_struct with the desired error handler
|
||||
* functions. If you want to use the default stderr and longjump method,
|
||||
* you can supply NULL for the last three parameters. We also check that
|
||||
* the library version is compatible with the one used at compile time,
|
||||
* in case we are using dynamically linked libraries. REQUIRED.
|
||||
*/
|
||||
png = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||
NULL, NULL, NULL);
|
||||
/*png_voidp user_error_ptr, user_error_fn, user_warning_fn); */
|
||||
|
||||
if(png == NULL) goto fin;
|
||||
|
||||
/* Allocate/initialize the image information data. REQUIRED
|
||||
*/
|
||||
info = png_create_info_struct(png);
|
||||
|
||||
if(info == NULL) goto fin;
|
||||
|
||||
/* Set error handling. REQUIRED if you are not supplying your own
|
||||
* error handling functions in the png_create_write_struct() call.
|
||||
*/
|
||||
if(setjmp(png_jmpbuf(png))) goto fin;
|
||||
|
||||
/* I/O initialization functions is REQUIRED
|
||||
*/
|
||||
png_init_io(png, writer);
|
||||
|
||||
/* Set the image information here. Width and height are up to 2^31,
|
||||
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
|
||||
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
|
||||
* PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
|
||||
* or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or
|
||||
* PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
|
||||
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE.
|
||||
* REQUIRED
|
||||
*
|
||||
* ERRORS:
|
||||
*
|
||||
* color_type == PNG_COLOR_TYPE_PALETTE && bit_depth > 8
|
||||
* color_type == PNG_COLOR_TYPE_RGB && bit_depth < 8
|
||||
* color_type == PNG_COLOR_TYPE_GRAY_ALPHA && bit_depth < 8
|
||||
* color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8
|
||||
*
|
||||
*/
|
||||
png_set_compression_level(png, Z_BEST_COMPRESSION);
|
||||
|
||||
if(nr_comp >= 3) /* RGB(A) */
|
||||
{
|
||||
color_type = PNG_COLOR_TYPE_RGB;
|
||||
sig_bit.red = sig_bit.green = sig_bit.blue = (png_byte)prec;
|
||||
}
|
||||
else /* GRAY(A) */
|
||||
{
|
||||
color_type = PNG_COLOR_TYPE_GRAY;
|
||||
sig_bit.gray = (png_byte)prec;
|
||||
}
|
||||
if((nr_comp & 1) == 0) /* ALPHA */
|
||||
{
|
||||
color_type |= PNG_COLOR_MASK_ALPHA;
|
||||
sig_bit.alpha = (png_byte)prec;
|
||||
}
|
||||
|
||||
png_set_IHDR(png, info, image->comps[0].w, image->comps[0].h, prec, color_type,
|
||||
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
png_set_sBIT(png, info, &sig_bit);
|
||||
/* png_set_gamma(png, 2.2, 1./2.2); */
|
||||
/* png_set_sRGB(png, info, PNG_sRGB_INTENT_PERCEPTUAL); */
|
||||
png_write_info(png, info);
|
||||
|
||||
/* setup conversion */
|
||||
{
|
||||
size_t rowStride;
|
||||
png_size_t png_row_size;
|
||||
|
||||
png_row_size = png_get_rowbytes(png, info);
|
||||
rowStride = ((size_t)image->comps[0].w * (size_t)nr_comp * (size_t)prec + 7U) / 8U;
|
||||
if (rowStride != (size_t)png_row_size) {
|
||||
fprintf(stderr, "Invalid PNG row size\n");
|
||||
goto fin;
|
||||
}
|
||||
row_buf = (png_bytep)malloc(png_row_size);
|
||||
if (row_buf == NULL) {
|
||||
fprintf(stderr, "Can't allocate memory for PNG row\n");
|
||||
goto fin;
|
||||
}
|
||||
buffer32s = (png_int_32*)malloc((size_t)image->comps[0].w * (size_t)nr_comp * sizeof(png_int_32));
|
||||
if (buffer32s == NULL) {
|
||||
fprintf(stderr, "Can't allocate memory for interleaved 32s row\n");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
|
||||
/* convert */
|
||||
{
|
||||
size_t width= image->comps[0].w;
|
||||
int y;
|
||||
convert_32s_PXCX cvtPxToCx = convert_32s_PXCX_LUT[nr_comp];
|
||||
convert_32sXXx_C1R cvt32sToPack = NULL;
|
||||
png_int_32 adjust = image->comps[0].sgnd ? 1 << (prec - 1) : 0;
|
||||
png_bytep row_buf_cpy = row_buf;
|
||||
png_int_32* buffer32s_cpy = buffer32s;
|
||||
|
||||
switch (prec) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
cvt32sToPack = convert_32sXXu_C1R_LUT[prec];
|
||||
break;
|
||||
case 16:
|
||||
cvt32sToPack = convert_32s16u_C1R;
|
||||
break;
|
||||
default:
|
||||
/* never here */
|
||||
break;
|
||||
}
|
||||
|
||||
for(y = 0; y < image->comps[0].h; ++y)
|
||||
{
|
||||
cvtPxToCx(planes, buffer32s_cpy, width, adjust);
|
||||
cvt32sToPack(buffer32s_cpy, row_buf_cpy, width * (size_t)nr_comp);
|
||||
png_write_row(png, row_buf_cpy);
|
||||
planes[0] += width;
|
||||
planes[1] += width;
|
||||
planes[2] += width;
|
||||
planes[3] += width;
|
||||
}
|
||||
}
|
||||
|
||||
png_write_end(png, info);
|
||||
|
||||
fails = 0;
|
||||
|
||||
fin:
|
||||
if(png) {
|
||||
png_destroy_write_struct(&png, &info);
|
||||
}
|
||||
if(row_buf) {
|
||||
free(row_buf);
|
||||
}
|
||||
if(buffer32s) {
|
||||
free(buffer32s);
|
||||
}
|
||||
fclose(writer);
|
||||
|
||||
if(fails) (void)remove(write_idf); /* ignore return value */
|
||||
|
||||
return fails;
|
||||
}/* imagetopng() */
|
||||
@@ -1,633 +0,0 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||
* Copyright (c) 2015, Matthieu Darbois
|
||||
* 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 "opj_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef HAVE_LIBTIFF
|
||||
# error HAVE_LIBTIFF_NOT_DEFINED
|
||||
#endif /* HAVE_LIBTIFF */
|
||||
|
||||
#include <tiffio.h>
|
||||
#include "openjpeg.h"
|
||||
#include "convert.h"
|
||||
|
||||
/* -->> -->> -->> -->>
|
||||
|
||||
TIFF IMAGE FORMAT
|
||||
|
||||
<<-- <<-- <<-- <<-- */
|
||||
|
||||
static void tif_32sto10u(const int32* pSrc, uint8* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < (length & ~(size_t)3U); i+=4U) {
|
||||
uint32 src0 = (uint32)pSrc[i+0];
|
||||
uint32 src1 = (uint32)pSrc[i+1];
|
||||
uint32 src2 = (uint32)pSrc[i+2];
|
||||
uint32 src3 = (uint32)pSrc[i+3];
|
||||
|
||||
*pDst++ = (uint8)(src0 >> 2);
|
||||
*pDst++ = (uint8)(((src0 & 0x3U) << 6) | (src1 >> 4));
|
||||
*pDst++ = (uint8)(((src1 & 0xFU) << 4) | (src2 >> 6));
|
||||
*pDst++ = (uint8)(((src2 & 0x3FU) << 2) | (src3 >> 8));
|
||||
*pDst++ = (uint8)(src3);
|
||||
}
|
||||
|
||||
if (length & 3U) {
|
||||
uint32 src0 = (uint32)pSrc[i+0];
|
||||
uint32 src1 = 0U;
|
||||
uint32 src2 = 0U;
|
||||
length = length & 3U;
|
||||
|
||||
if (length > 1U) {
|
||||
src1 = (uint32)pSrc[i+1];
|
||||
if (length > 2U) {
|
||||
src2 = (uint32)pSrc[i+2];
|
||||
}
|
||||
}
|
||||
*pDst++ = (uint8)(src0 >> 2);
|
||||
*pDst++ = (uint8)(((src0 & 0x3U) << 6) | (src1 >> 4));
|
||||
if (length > 1U) {
|
||||
*pDst++ = (uint8)(((src1 & 0xFU) << 4) | (src2 >> 6));
|
||||
if (length > 2U) {
|
||||
*pDst++ = (uint8)(((src2 & 0x3FU) << 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_32sto12u(const int32* pSrc, uint8* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < (length & ~(size_t)1U); i+=2U) {
|
||||
uint32 src0 = (uint32)pSrc[i+0];
|
||||
uint32 src1 = (uint32)pSrc[i+1];
|
||||
|
||||
*pDst++ = (uint8)(src0 >> 4);
|
||||
*pDst++ = (uint8)(((src0 & 0xFU) << 4) | (src1 >> 8));
|
||||
*pDst++ = (uint8)(src1);
|
||||
}
|
||||
|
||||
if (length & 1U) {
|
||||
uint32 src0 = (uint32)pSrc[i+0];
|
||||
*pDst++ = (uint8)(src0 >> 4);
|
||||
*pDst++ = (uint8)(((src0 & 0xFU) << 4));
|
||||
}
|
||||
}
|
||||
static void tif_32sto14u(const int32* pSrc, uint8* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < (length & ~(size_t)3U); i+=4U) {
|
||||
uint32 src0 = (uint32)pSrc[i+0];
|
||||
uint32 src1 = (uint32)pSrc[i+1];
|
||||
uint32 src2 = (uint32)pSrc[i+2];
|
||||
uint32 src3 = (uint32)pSrc[i+3];
|
||||
|
||||
*pDst++ = (uint8)(src0 >> 6);
|
||||
*pDst++ = (uint8)(((src0 & 0x3FU) << 2) | (src1 >> 12));
|
||||
*pDst++ = (uint8)(src1 >> 4);
|
||||
*pDst++ = (uint8)(((src1 & 0xFU) << 4) | (src2 >> 10));
|
||||
*pDst++ = (uint8)(src2 >> 2);
|
||||
*pDst++ = (uint8)(((src2 & 0x3U) << 6) | (src3 >> 8));
|
||||
*pDst++ = (uint8)(src3);
|
||||
}
|
||||
|
||||
if (length & 3U) {
|
||||
uint32 src0 = (uint32)pSrc[i+0];
|
||||
uint32 src1 = 0U;
|
||||
uint32 src2 = 0U;
|
||||
length = length & 3U;
|
||||
|
||||
if (length > 1U) {
|
||||
src1 = (uint32)pSrc[i+1];
|
||||
if (length > 2U) {
|
||||
src2 = (uint32)pSrc[i+2];
|
||||
}
|
||||
}
|
||||
*pDst++ = (uint8)(src0 >> 6);
|
||||
*pDst++ = (uint8)(((src0 & 0x3FU) << 2) | (src1 >> 12));
|
||||
if (length > 1U) {
|
||||
*pDst++ = (uint8)(src1 >> 4);
|
||||
*pDst++ = (uint8)(((src1 & 0xFU) << 4) | (src2 >> 10));
|
||||
if (length > 2U) {
|
||||
*pDst++ = (uint8)(src2 >> 2);
|
||||
*pDst++ = (uint8)(((src2 & 0x3U) << 6));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_32sto16u(const int32* pSrc, uint16* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < length; ++i) {
|
||||
pDst[i] = (uint16)pSrc[i];
|
||||
}
|
||||
}
|
||||
|
||||
int imagetotif(opj_image_t * image, const char *outfile)
|
||||
{
|
||||
int width, height;
|
||||
int bps,adjust, sgnd;
|
||||
int tiPhoto;
|
||||
TIFF *tif;
|
||||
tdata_t buf;
|
||||
tsize_t strip_size;
|
||||
int32 i, numcomps;
|
||||
size_t rowStride;
|
||||
int32* buffer32s = NULL;
|
||||
int32 const* planes[4];
|
||||
convert_32s_PXCX cvtPxToCx = NULL;
|
||||
convert_32sXXx_C1R cvt32sToTif = NULL;
|
||||
|
||||
bps = image->comps[0].prec;
|
||||
planes[0] = image->comps[0].data;
|
||||
|
||||
numcomps = image->numcomps;
|
||||
|
||||
if (numcomps > 2) {
|
||||
tiPhoto = PHOTOMETRIC_RGB;
|
||||
if (numcomps > 4) {
|
||||
numcomps = 4;
|
||||
}
|
||||
} else {
|
||||
tiPhoto = PHOTOMETRIC_MINISBLACK;
|
||||
}
|
||||
for (i = 1; i < numcomps; ++i) {
|
||||
if (image->comps[0].dx != image->comps[i].dx) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].dy != image->comps[i].dy) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].prec != image->comps[i].prec) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].sgnd != image->comps[i].sgnd) {
|
||||
break;
|
||||
}
|
||||
planes[i] = image->comps[i].data;
|
||||
}
|
||||
if (i != numcomps) {
|
||||
fprintf(stderr,"imagetotif: All components shall have the same subsampling, same bit depth.\n");
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if((bps > 16) || ((bps != 1) && (bps & 1))) bps = 0;
|
||||
if(bps == 0)
|
||||
{
|
||||
fprintf(stderr,"imagetotif: Bits=%d, Only 1, 2, 4, 6, 8, 10, 12, 14 and 16 bits implemented\n",bps);
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
return 1;
|
||||
}
|
||||
tif = TIFFOpen(outfile, "wb");
|
||||
if (!tif)
|
||||
{
|
||||
fprintf(stderr, "imagetotif:failed to open %s for writing\n", outfile);
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < numcomps; ++i) {
|
||||
clip_component(&(image->comps[i]), image->comps[0].prec);
|
||||
}
|
||||
cvtPxToCx = convert_32s_PXCX_LUT[numcomps];
|
||||
switch (bps) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 6:
|
||||
case 8:
|
||||
cvt32sToTif = convert_32sXXu_C1R_LUT[bps];
|
||||
break;
|
||||
case 10:
|
||||
cvt32sToTif = tif_32sto10u;
|
||||
break;
|
||||
case 12:
|
||||
cvt32sToTif = tif_32sto12u;
|
||||
break;
|
||||
case 14:
|
||||
cvt32sToTif = tif_32sto14u;
|
||||
break;
|
||||
case 16:
|
||||
cvt32sToTif = (convert_32sXXx_C1R)tif_32sto16u;
|
||||
break;
|
||||
default:
|
||||
/* never here */
|
||||
break;
|
||||
}
|
||||
sgnd = (int)image->comps[0].sgnd;
|
||||
adjust = sgnd ? 1 << (image->comps[0].prec - 1) : 0;
|
||||
width = (int)image->comps[0].w;
|
||||
height = (int)image->comps[0].h;
|
||||
|
||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
|
||||
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, numcomps);
|
||||
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
|
||||
TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
|
||||
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, tiPhoto);
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
|
||||
|
||||
strip_size = TIFFStripSize(tif);
|
||||
rowStride = ((size_t)width * numcomps * (size_t)bps + 7U) / 8U;
|
||||
if (rowStride != (size_t)strip_size) {
|
||||
fprintf(stderr, "Invalid TIFF strip size\n");
|
||||
TIFFClose(tif);
|
||||
return 1;
|
||||
}
|
||||
buf = _TIFFmalloc(strip_size);
|
||||
if (buf == NULL) {
|
||||
TIFFClose(tif);
|
||||
return 1;
|
||||
}
|
||||
buffer32s = (int32 *)malloc((size_t)width * numcomps * sizeof(int32));
|
||||
if (buffer32s == NULL) {
|
||||
_TIFFfree(buf);
|
||||
TIFFClose(tif);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < image->comps[0].h; ++i) {
|
||||
cvtPxToCx(planes, buffer32s, (size_t)width, adjust);
|
||||
cvt32sToTif(buffer32s, (uint8 *)buf, (size_t)width * numcomps);
|
||||
(void)TIFFWriteEncodedStrip(tif, i, (void*)buf, strip_size);
|
||||
planes[0] += width;
|
||||
planes[1] += width;
|
||||
planes[2] += width;
|
||||
planes[3] += width;
|
||||
}
|
||||
_TIFFfree((void*)buf);
|
||||
TIFFClose(tif);
|
||||
free(buffer32s);
|
||||
|
||||
return 0;
|
||||
}/* imagetotif() */
|
||||
|
||||
static void tif_10uto32s(const uint8* pSrc, int32* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < (length & ~(size_t)3U); i+=4U) {
|
||||
uint32 val0 = *pSrc++;
|
||||
uint32 val1 = *pSrc++;
|
||||
uint32 val2 = *pSrc++;
|
||||
uint32 val3 = *pSrc++;
|
||||
uint32 val4 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (int32)((val0 << 2) | (val1 >> 6));
|
||||
pDst[i+1] = (int32)(((val1 & 0x3FU) << 4) | (val2 >> 4));
|
||||
pDst[i+2] = (int32)(((val2 & 0xFU) << 6) | (val3 >> 2));
|
||||
pDst[i+3] = (int32)(((val3 & 0x3U) << 8) | val4);
|
||||
|
||||
}
|
||||
if (length & 3U) {
|
||||
uint32 val0 = *pSrc++;
|
||||
uint32 val1 = *pSrc++;
|
||||
length = length & 3U;
|
||||
pDst[i+0] = (int32)((val0 << 2) | (val1 >> 6));
|
||||
|
||||
if (length > 1U) {
|
||||
uint32 val2 = *pSrc++;
|
||||
pDst[i+1] = (int32)(((val1 & 0x3FU) << 4) | (val2 >> 4));
|
||||
if (length > 2U) {
|
||||
uint32 val3 = *pSrc++;
|
||||
pDst[i+2] = (int32)(((val2 & 0xFU) << 6) | (val3 >> 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_12uto32s(const uint8* pSrc, int32* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < (length & ~(size_t)1U); i+=2U) {
|
||||
uint32 val0 = *pSrc++;
|
||||
uint32 val1 = *pSrc++;
|
||||
uint32 val2 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (int32)((val0 << 4) | (val1 >> 4));
|
||||
pDst[i+1] = (int32)(((val1 & 0xFU) << 8) | val2);
|
||||
}
|
||||
if (length & 1U) {
|
||||
uint32 val0 = *pSrc++;
|
||||
uint32 val1 = *pSrc++;
|
||||
pDst[i+0] = (int32)((val0 << 4) | (val1 >> 4));
|
||||
}
|
||||
}
|
||||
static void tif_14uto32s(const uint8* pSrc, int32* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < (length & ~(size_t)3U); i+=4U) {
|
||||
uint32 val0 = *pSrc++;
|
||||
uint32 val1 = *pSrc++;
|
||||
uint32 val2 = *pSrc++;
|
||||
uint32 val3 = *pSrc++;
|
||||
uint32 val4 = *pSrc++;
|
||||
uint32 val5 = *pSrc++;
|
||||
uint32 val6 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (int32)((val0 << 6) | (val1 >> 2));
|
||||
pDst[i+1] = (int32)(((val1 & 0x3U) << 12) | (val2 << 4) | (val3 >> 4));
|
||||
pDst[i+2] = (int32)(((val3 & 0xFU) << 10) | (val4 << 2) | (val5 >> 6));
|
||||
pDst[i+3] = (int32)(((val5 & 0x3FU) << 8) | val6);
|
||||
|
||||
}
|
||||
if (length & 3U) {
|
||||
uint32 val0 = *pSrc++;
|
||||
uint32 val1 = *pSrc++;
|
||||
length = length & 3U;
|
||||
pDst[i+0] = (int32)((val0 << 6) | (val1 >> 2));
|
||||
|
||||
if (length > 1U) {
|
||||
uint32 val2 = *pSrc++;
|
||||
uint32 val3 = *pSrc++;
|
||||
pDst[i+1] = (int32)(((val1 & 0x3U) << 12) | (val2 << 4) | (val3 >> 4));
|
||||
if (length > 2U) {
|
||||
uint32 val4 = *pSrc++;
|
||||
uint32 val5 = *pSrc++;
|
||||
pDst[i+2] = (int32)(((val3 & 0xFU) << 10) | (val4 << 2) | (val5 >> 6));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* seems that libtiff decodes this to machine endianness */
|
||||
static void tif_16uto32s(const uint16* pSrc, int32* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < length; i++) {
|
||||
pDst[i] = pSrc[i];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* libtiff/tif_getimage.c : 1,2,4,8,16 bitspersample accepted
|
||||
* CINEMA : 12 bit precision
|
||||
*/
|
||||
opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
||||
{
|
||||
int subsampling_dx = parameters->subsampling_dx;
|
||||
int subsampling_dy = parameters->subsampling_dy;
|
||||
TIFF *tif;
|
||||
tdata_t buf;
|
||||
tstrip_t strip;
|
||||
tsize_t strip_size;
|
||||
int j, currentPlane, numcomps = 0, w, h;
|
||||
OPJ_COLOR_SPACE color_space = CLRSPC_UNKNOWN;
|
||||
opj_image_cmptparm_t cmptparm[4]; /* RGBA */
|
||||
opj_image_t *image = NULL;
|
||||
int has_alpha = 0;
|
||||
unsigned short tiBps, tiPhoto, tiSf, tiSpp, tiPC;
|
||||
unsigned int tiWidth, tiHeight;
|
||||
opj_bool is_cinema = (parameters->cp_cinema != OFF) ? OPJ_TRUE : OPJ_FALSE;
|
||||
convert_XXx32s_C1R cvtTifTo32s = NULL;
|
||||
convert_32s_CXPX cvtCxToPx = NULL;
|
||||
int32* buffer32s = NULL;
|
||||
int32* planes[4];
|
||||
size_t rowStride;
|
||||
|
||||
tif = TIFFOpen(filename, "r");
|
||||
|
||||
if(!tif)
|
||||
{
|
||||
fprintf(stderr, "tiftoimage:Failed to open %s for reading\n", filename);
|
||||
return 0;
|
||||
}
|
||||
tiBps = tiPhoto = tiSf = tiSpp = tiPC = 0;
|
||||
tiWidth = tiHeight = 0;
|
||||
|
||||
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &tiWidth);
|
||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &tiHeight);
|
||||
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &tiBps);
|
||||
TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &tiSf);
|
||||
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &tiSpp);
|
||||
TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &tiPhoto);
|
||||
TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &tiPC);
|
||||
w= (int)tiWidth;
|
||||
h= (int)tiHeight;
|
||||
|
||||
if((tiBps > 16U) || ((tiBps != 1U) && (tiBps & 1U))) {
|
||||
fprintf(stderr,"tiftoimage: Bits=%d, Only 1, 2, 4, 6, 8, 10, 12, 14 and 16 bits implemented\n",tiBps);
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
TIFFClose(tif);
|
||||
return NULL;
|
||||
}
|
||||
if(tiPhoto != PHOTOMETRIC_MINISBLACK && tiPhoto != PHOTOMETRIC_RGB) {
|
||||
fprintf(stderr,"tiftoimage: Bad color format %d.\n\tOnly RGB(A) and GRAY(A) has been implemented\n",(int) tiPhoto);
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
TIFFClose(tif);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (tiBps) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 6:
|
||||
case 8:
|
||||
cvtTifTo32s = convert_XXu32s_C1R_LUT[tiBps];
|
||||
break;
|
||||
/* others are specific to TIFF */
|
||||
case 10:
|
||||
cvtTifTo32s = tif_10uto32s;
|
||||
break;
|
||||
case 12:
|
||||
cvtTifTo32s = tif_12uto32s;
|
||||
break;
|
||||
case 14:
|
||||
cvtTifTo32s = tif_14uto32s;
|
||||
break;
|
||||
case 16:
|
||||
cvtTifTo32s = (convert_XXx32s_C1R)tif_16uto32s;
|
||||
break;
|
||||
default:
|
||||
/* never here */
|
||||
break;
|
||||
}
|
||||
|
||||
{/* From: tiff-4.0.x/libtiff/tif_getimage.c : */
|
||||
uint16* sampleinfo;
|
||||
uint16 extrasamples;
|
||||
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES,
|
||||
&extrasamples, &sampleinfo);
|
||||
|
||||
if(extrasamples >= 1)
|
||||
{
|
||||
switch(sampleinfo[0])
|
||||
{
|
||||
case EXTRASAMPLE_UNSPECIFIED:
|
||||
/* Workaround for some images without correct info about alpha channel
|
||||
*/
|
||||
if(tiSpp > 3)
|
||||
has_alpha = 1;
|
||||
break;
|
||||
|
||||
case EXTRASAMPLE_ASSOCALPHA: /* data pre-multiplied */
|
||||
case EXTRASAMPLE_UNASSALPHA: /* data not pre-multiplied */
|
||||
has_alpha = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else /* extrasamples == 0 */
|
||||
if(tiSpp == 4 || tiSpp == 2) has_alpha = 1;
|
||||
}
|
||||
|
||||
/* initialize image components */
|
||||
memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t));
|
||||
|
||||
if ((tiPhoto == PHOTOMETRIC_RGB) && (is_cinema) && (tiBps != 12U)) {
|
||||
fprintf(stdout,"WARNING:\n"
|
||||
"Input image bitdepth is %d bits\n"
|
||||
"TIF conversion has automatically rescaled to 12-bits\n"
|
||||
"to comply with cinema profiles.\n",
|
||||
tiBps);
|
||||
} else {
|
||||
is_cinema = 0U;
|
||||
}
|
||||
|
||||
if(tiPhoto == PHOTOMETRIC_RGB) /* RGB(A) */
|
||||
{
|
||||
numcomps = 3 + has_alpha;
|
||||
color_space = CLRSPC_SRGB;
|
||||
}
|
||||
else if (tiPhoto == PHOTOMETRIC_MINISBLACK) /* GRAY(A) */
|
||||
{
|
||||
numcomps = 1 + has_alpha;
|
||||
color_space = CLRSPC_GRAY;
|
||||
}
|
||||
|
||||
cvtCxToPx = convert_32s_CXPX_LUT[numcomps];
|
||||
if (tiPC == PLANARCONFIG_SEPARATE) {
|
||||
cvtCxToPx = convert_32s_CXPX_LUT[1]; /* override */
|
||||
tiSpp = 1U; /* consider only one sample per plane */
|
||||
}
|
||||
|
||||
for(j = 0; j < numcomps; j++)
|
||||
{
|
||||
cmptparm[j].prec = tiBps;
|
||||
cmptparm[j].bpp = tiBps;
|
||||
cmptparm[j].dx = (uint32)subsampling_dx;
|
||||
cmptparm[j].dy = (uint32)subsampling_dy;
|
||||
cmptparm[j].w = (uint32)w;
|
||||
cmptparm[j].h = (uint32)h;
|
||||
}
|
||||
|
||||
image = opj_image_create((uint32)numcomps, &cmptparm[0], color_space);
|
||||
if(!image)
|
||||
{
|
||||
TIFFClose(tif);
|
||||
return NULL;
|
||||
}
|
||||
/* set image offset and reference grid */
|
||||
image->x0 = (uint32)parameters->image_offset_x0;
|
||||
image->y0 = (uint32)parameters->image_offset_y0;
|
||||
image->x1 = !image->x0 ? (uint32)(w - 1) * (uint32)subsampling_dx + 1 :
|
||||
image->x0 + (uint32)(w - 1) * (uint32)subsampling_dx + 1;
|
||||
image->y1 = !image->y0 ? (uint32)(h - 1) * (uint32)subsampling_dy + 1 :
|
||||
image->y0 + (uint32)(h - 1) * (uint32)subsampling_dy + 1;
|
||||
|
||||
for(j = 0; j < numcomps; j++)
|
||||
{
|
||||
planes[j] = image->comps[j].data;
|
||||
}
|
||||
/* image->comps[numcomps - 1].alpha = (uint16)(1 - (numcomps & 1)); */
|
||||
|
||||
strip_size = TIFFStripSize(tif);
|
||||
|
||||
buf = _TIFFmalloc(strip_size);
|
||||
if (buf == NULL) {
|
||||
TIFFClose(tif);
|
||||
opj_image_destroy(image);
|
||||
return NULL;
|
||||
}
|
||||
rowStride = ((size_t)w * tiSpp * tiBps + 7U) / 8U;
|
||||
buffer32s = (int32 *)malloc((size_t)w * tiSpp * sizeof(int32));
|
||||
if (buffer32s == NULL) {
|
||||
_TIFFfree(buf);
|
||||
TIFFClose(tif);
|
||||
opj_image_destroy(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strip = 0;
|
||||
currentPlane = 0;
|
||||
do
|
||||
{
|
||||
planes[0] = image->comps[currentPlane].data; /* to manage planar data */
|
||||
h= (int)tiHeight;
|
||||
/* Read the Image components */
|
||||
for(; (h > 0) && (strip < TIFFNumberOfStrips(tif)); strip++)
|
||||
{
|
||||
const uint8 *dat8;
|
||||
size_t ssize;
|
||||
|
||||
ssize = (size_t)TIFFReadEncodedStrip(tif, strip, buf, strip_size);
|
||||
dat8 = (const uint8*)buf;
|
||||
|
||||
while (ssize >= rowStride) {
|
||||
cvtTifTo32s(dat8, buffer32s, (size_t)w * tiSpp);
|
||||
cvtCxToPx(buffer32s, planes, (size_t)w);
|
||||
planes[0] += w;
|
||||
planes[1] += w;
|
||||
planes[2] += w;
|
||||
planes[3] += w;
|
||||
dat8 += rowStride;
|
||||
ssize -= rowStride;
|
||||
h--;
|
||||
}
|
||||
}
|
||||
currentPlane++;
|
||||
} while ((tiPC == PLANARCONFIG_SEPARATE) && (currentPlane < numcomps));
|
||||
|
||||
free(buffer32s);
|
||||
_TIFFfree(buf);
|
||||
TIFFClose(tif);
|
||||
|
||||
if (is_cinema) {
|
||||
for (j=0; j < numcomps; ++j) {
|
||||
scale_component(&(image->comps[j]), 12);
|
||||
}
|
||||
|
||||
}
|
||||
return image;
|
||||
|
||||
}/* tiftoimage() */
|
||||
|
||||
@@ -82,7 +82,7 @@ typedef struct img_folder{
|
||||
float *rates;
|
||||
}img_fol_t;
|
||||
|
||||
static void encode_help_display(void) {
|
||||
void encode_help_display(void) {
|
||||
fprintf(stdout,"HELP for image_to_j2k\n----\n\n");
|
||||
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||
|
||||
@@ -321,7 +321,7 @@ static void encode_help_display(void) {
|
||||
fprintf(stdout,"TotalDisto\n\n");
|
||||
}
|
||||
|
||||
static OPJ_PROG_ORDER give_progression(char progression[4]) {
|
||||
OPJ_PROG_ORDER give_progression(char progression[4]) {
|
||||
if(strncmp(progression, "LRCP", 4) == 0) {
|
||||
return LRCP;
|
||||
}
|
||||
@@ -341,7 +341,7 @@ static OPJ_PROG_ORDER give_progression(char progression[4]) {
|
||||
return PROG_UNKNOWN;
|
||||
}
|
||||
|
||||
static int get_num_images(char *imgdirpath){
|
||||
int get_num_images(char *imgdirpath){
|
||||
DIR *dir;
|
||||
struct dirent* content;
|
||||
int num_images = 0;
|
||||
@@ -360,11 +360,10 @@ static int get_num_images(char *imgdirpath){
|
||||
continue;
|
||||
num_images++;
|
||||
}
|
||||
closedir(dir);
|
||||
return num_images;
|
||||
}
|
||||
|
||||
static int load_images(dircnt_t *dirptr, char *imgdirpath){
|
||||
int load_images(dircnt_t *dirptr, char *imgdirpath){
|
||||
DIR *dir;
|
||||
struct dirent* content;
|
||||
int i = 0;
|
||||
@@ -386,11 +385,10 @@ static int load_images(dircnt_t *dirptr, char *imgdirpath){
|
||||
strcpy(dirptr->filename[i],content->d_name);
|
||||
i++;
|
||||
}
|
||||
closedir(dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_file_format(char *filename) {
|
||||
int get_file_format(char *filename) {
|
||||
unsigned int i;
|
||||
static const char *extension[] = {
|
||||
"pgx", "pnm", "pgm", "ppm", "pbm", "pam", "bmp", "tif", "raw", "tga", "png", "j2k", "jp2", "j2c", "jpc"
|
||||
@@ -410,13 +408,14 @@ static int get_file_format(char *filename) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static char * get_file_name(char *name){
|
||||
char * get_file_name(char *name){
|
||||
char *fname;
|
||||
fname= (char*)malloc(OPJ_PATH_LEN*sizeof(char));
|
||||
fname= strtok(name,".");
|
||||
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 *temp_p, temp1[OPJ_PATH_LEN]="";
|
||||
|
||||
@@ -459,7 +458,7 @@ static int initialise_4K_poc(opj_poc_t *POC, int numres){
|
||||
return 2;
|
||||
}
|
||||
|
||||
static void cinema_parameters(opj_cparameters_t *parameters){
|
||||
void cinema_parameters(opj_cparameters_t *parameters){
|
||||
parameters->tile_size_on = OPJ_FALSE;
|
||||
parameters->cp_tdx=1;
|
||||
parameters->cp_tdy=1;
|
||||
@@ -492,7 +491,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;
|
||||
float temp_rate;
|
||||
|
||||
@@ -577,7 +576,7 @@ 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) {
|
||||
int i, j, totlen, c;
|
||||
opj_option_t long_option[]={
|
||||
@@ -590,10 +589,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
||||
{"OutFor",REQ_ARG, NULL ,'O'},
|
||||
{"POC",REQ_ARG, NULL ,'P'},
|
||||
{"ROI",REQ_ARG, NULL ,'R'},
|
||||
{"jpip",NO_ARG, NULL, 'J'},
|
||||
#ifdef USE_SYSTEM_GETOPT
|
||||
{0,0,0,0} /* GNU getopt_long requirement */
|
||||
#endif
|
||||
{"jpip",NO_ARG, NULL, 'J'}
|
||||
};
|
||||
|
||||
/* parse the command line */
|
||||
@@ -603,16 +599,12 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
||||
#endif /* USE_JPWL */
|
||||
"h";
|
||||
|
||||
totlen=sizeof(long_option);
|
||||
totlen=sizeof(long_option);
|
||||
img_fol->set_out_format=0;
|
||||
raw_cp->rawWidth = 0;
|
||||
|
||||
do{
|
||||
#ifdef USE_SYSTEM_GETOPT
|
||||
c = opj_getopt_long(argc, argv, optlist,long_option,0);
|
||||
#else
|
||||
c = opj_getopt_long(argc, argv, optlist,long_option,totlen);
|
||||
#endif
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
@@ -1393,10 +1385,10 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
|
||||
default:
|
||||
fprintf(stderr, "[WARNING] An invalid option has been ignored\n");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "ERROR -> Command line not valid\n");
|
||||
return 1;
|
||||
}
|
||||
}while(c != -1);
|
||||
|
||||
/* check for possible errors */
|
||||
@@ -1474,21 +1466,21 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
|
||||
/**
|
||||
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;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
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;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
}
|
||||
/**
|
||||
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;
|
||||
fprintf(stream, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
@@ -1,391 +1,391 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* 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 <math.h>
|
||||
#include <string.h>
|
||||
#include "openjpeg.h"
|
||||
#include "index.h"
|
||||
|
||||
/* ------------------------------------------------------------------------------------ */
|
||||
|
||||
/**
|
||||
Write a structured index to a file
|
||||
@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) {
|
||||
int tileno, compno, layno, resno, precno, pack_nb, x, y;
|
||||
FILE *stream = NULL;
|
||||
double total_disto = 0;
|
||||
/* UniPG>> */
|
||||
int tilepartno;
|
||||
char disto_on, numpix_on;
|
||||
|
||||
#ifdef USE_JPWL
|
||||
if (!strcmp(index, JPWL_PRIVATEINDEX_NAME))
|
||||
return 0;
|
||||
#endif /* USE_JPWL */
|
||||
/* <<UniPG */
|
||||
|
||||
if (!cstr_info)
|
||||
return 1;
|
||||
|
||||
stream = fopen(index, "w");
|
||||
if (!stream) {
|
||||
fprintf(stderr, "failed to open index file [%s] for writing\n", index);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (cstr_info->tile[0].distotile)
|
||||
disto_on = 1;
|
||||
else
|
||||
disto_on = 0;
|
||||
|
||||
if (cstr_info->tile[0].numpix)
|
||||
numpix_on = 1;
|
||||
else
|
||||
numpix_on = 0;
|
||||
|
||||
fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
|
||||
fprintf(stream, "%d\n", cstr_info->prog);
|
||||
fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
|
||||
fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
|
||||
fprintf(stream, "%d\n", cstr_info->numcomps);
|
||||
fprintf(stream, "%d\n", cstr_info->numlayers);
|
||||
fprintf(stream, "%d\n", cstr_info->numdecompos[0]); /* based on component 0 */
|
||||
|
||||
for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
|
||||
fprintf(stream, "[%d,%d] ",
|
||||
(1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 and component 0 */
|
||||
}
|
||||
|
||||
fprintf(stream, "\n");
|
||||
/* UniPG>> */
|
||||
fprintf(stream, "%d\n", cstr_info->main_head_start);
|
||||
/* <<UniPG */
|
||||
fprintf(stream, "%d\n", cstr_info->main_head_end);
|
||||
fprintf(stream, "%d\n", cstr_info->codestream_size);
|
||||
|
||||
fprintf(stream, "\nINFO ON TILES\n");
|
||||
fprintf(stream, "tileno start_pos end_hd end_tile nbparts");
|
||||
if (disto_on)
|
||||
fprintf(stream," disto");
|
||||
if (numpix_on)
|
||||
fprintf(stream," nbpix");
|
||||
if (disto_on && numpix_on)
|
||||
fprintf(stream," disto/nbpix");
|
||||
fprintf(stream, "\n");
|
||||
|
||||
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||
fprintf(stream, "%4d %9d %9d %9d %9d",
|
||||
cstr_info->tile[tileno].tileno,
|
||||
cstr_info->tile[tileno].start_pos,
|
||||
cstr_info->tile[tileno].end_header,
|
||||
cstr_info->tile[tileno].end_pos,
|
||||
cstr_info->tile[tileno].num_tps);
|
||||
if (disto_on)
|
||||
fprintf(stream," %9e", cstr_info->tile[tileno].distotile);
|
||||
if (numpix_on)
|
||||
fprintf(stream," %9d", cstr_info->tile[tileno].numpix);
|
||||
if (disto_on && numpix_on)
|
||||
fprintf(stream," %9e", cstr_info->tile[tileno].distotile / cstr_info->tile[tileno].numpix);
|
||||
fprintf(stream, "\n");
|
||||
}
|
||||
|
||||
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||
int start_pos, end_ph_pos, end_pos;
|
||||
double disto = 0;
|
||||
int max_numdecompos = 0;
|
||||
pack_nb = 0;
|
||||
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
if (max_numdecompos < cstr_info->numdecompos[compno])
|
||||
max_numdecompos = cstr_info->numdecompos[compno];
|
||||
}
|
||||
|
||||
fprintf(stream, "\nTILE %d DETAILS\n", tileno);
|
||||
fprintf(stream, "part_nb tileno start_pack num_packs start_pos end_tph_pos end_pos\n");
|
||||
for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
|
||||
fprintf(stream, "%4d %9d %9d %9d %9d %11d %9d\n",
|
||||
tilepartno, tileno,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_start_pack,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_numpacks,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_start_pos,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_end_header,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
|
||||
);
|
||||
|
||||
if (cstr_info->prog == LRCP) { /* LRCP */
|
||||
fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int prec_max;
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < prec_max; precno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %7d %5d %6d %6d %6d %6d %7d",
|
||||
pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* LRCP */
|
||||
|
||||
else if (cstr_info->prog == RLCP) { /* RLCP */
|
||||
fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos\n");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int prec_max;
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < prec_max; precno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d %9d %7d",
|
||||
pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* RLCP */
|
||||
|
||||
else if (cstr_info->prog == RPCL) { /* RPCL */
|
||||
|
||||
fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < numprec; precno++) {
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d %9d %7d",
|
||||
pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* precno */
|
||||
} /* compno */
|
||||
} /* resno */
|
||||
} /* RPCL */
|
||||
|
||||
else if (cstr_info->prog == PCRL) { /* PCRL */
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
|
||||
/* Count the maximum number of precincts */
|
||||
int max_numprec = 0;
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
if (numprec > max_numprec)
|
||||
max_numprec = numprec;
|
||||
}
|
||||
|
||||
fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (precno = 0; precno < max_numprec; precno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (precno >= numprec)
|
||||
continue;
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
|
||||
pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* resno */
|
||||
} /* compno */
|
||||
} /* precno */
|
||||
} /* PCRL */
|
||||
|
||||
else { /* CPRL */
|
||||
/* Count the maximum number of precincts */
|
||||
int max_numprec = 0;
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
if (numprec > max_numprec)
|
||||
max_numprec = numprec;
|
||||
}
|
||||
|
||||
fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
|
||||
for (precno = 0; precno < max_numprec; precno++) {
|
||||
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (precno >= numprec)
|
||||
continue;
|
||||
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
|
||||
pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* resno */
|
||||
} /* precno */
|
||||
} /* compno */
|
||||
} /* CPRL */
|
||||
} /* tileno */
|
||||
|
||||
if (disto_on) {
|
||||
fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */
|
||||
fprintf(stream, "%.8e\n", total_disto); /* SE totale */
|
||||
}
|
||||
/* UniPG>> */
|
||||
/* print the markers' list */
|
||||
if (cstr_info->marknum) {
|
||||
fprintf(stream, "\nMARKER LIST\n");
|
||||
fprintf(stream, "%d\n", cstr_info->marknum);
|
||||
fprintf(stream, "type\tstart_pos length\n");
|
||||
for (x = 0; x < cstr_info->marknum; x++)
|
||||
fprintf(stream, "%X\t%9d %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len);
|
||||
}
|
||||
/* <<UniPG */
|
||||
fclose(stream);
|
||||
|
||||
fprintf(stderr,"Generated index file %s\n", index);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* 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 <math.h>
|
||||
#include <string.h>
|
||||
#include "openjpeg.h"
|
||||
#include "index.h"
|
||||
|
||||
/* ------------------------------------------------------------------------------------ */
|
||||
|
||||
/**
|
||||
Write a structured index to a file
|
||||
@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) {
|
||||
int tileno, compno, layno, resno, precno, pack_nb, x, y;
|
||||
FILE *stream = NULL;
|
||||
double total_disto = 0;
|
||||
/* UniPG>> */
|
||||
int tilepartno;
|
||||
char disto_on, numpix_on;
|
||||
|
||||
#ifdef USE_JPWL
|
||||
if (!strcmp(index, JPWL_PRIVATEINDEX_NAME))
|
||||
return 0;
|
||||
#endif /* USE_JPWL */
|
||||
/* <<UniPG */
|
||||
|
||||
if (!cstr_info)
|
||||
return 1;
|
||||
|
||||
stream = fopen(index, "w");
|
||||
if (!stream) {
|
||||
fprintf(stderr, "failed to open index file [%s] for writing\n", index);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (cstr_info->tile[0].distotile)
|
||||
disto_on = 1;
|
||||
else
|
||||
disto_on = 0;
|
||||
|
||||
if (cstr_info->tile[0].numpix)
|
||||
numpix_on = 1;
|
||||
else
|
||||
numpix_on = 0;
|
||||
|
||||
fprintf(stream, "%d %d\n", cstr_info->image_w, cstr_info->image_h);
|
||||
fprintf(stream, "%d\n", cstr_info->prog);
|
||||
fprintf(stream, "%d %d\n", cstr_info->tile_x, cstr_info->tile_y);
|
||||
fprintf(stream, "%d %d\n", cstr_info->tw, cstr_info->th);
|
||||
fprintf(stream, "%d\n", cstr_info->numcomps);
|
||||
fprintf(stream, "%d\n", cstr_info->numlayers);
|
||||
fprintf(stream, "%d\n", cstr_info->numdecompos[0]); /* based on component 0 */
|
||||
|
||||
for (resno = cstr_info->numdecompos[0]; resno >= 0; resno--) {
|
||||
fprintf(stream, "[%d,%d] ",
|
||||
(1 << cstr_info->tile[0].pdx[resno]), (1 << cstr_info->tile[0].pdx[resno])); /* based on tile 0 and component 0 */
|
||||
}
|
||||
|
||||
fprintf(stream, "\n");
|
||||
/* UniPG>> */
|
||||
fprintf(stream, "%d\n", cstr_info->main_head_start);
|
||||
/* <<UniPG */
|
||||
fprintf(stream, "%d\n", cstr_info->main_head_end);
|
||||
fprintf(stream, "%d\n", cstr_info->codestream_size);
|
||||
|
||||
fprintf(stream, "\nINFO ON TILES\n");
|
||||
fprintf(stream, "tileno start_pos end_hd end_tile nbparts");
|
||||
if (disto_on)
|
||||
fprintf(stream," disto");
|
||||
if (numpix_on)
|
||||
fprintf(stream," nbpix");
|
||||
if (disto_on && numpix_on)
|
||||
fprintf(stream," disto/nbpix");
|
||||
fprintf(stream, "\n");
|
||||
|
||||
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||
fprintf(stream, "%4d %9d %9d %9d %9d",
|
||||
cstr_info->tile[tileno].tileno,
|
||||
cstr_info->tile[tileno].start_pos,
|
||||
cstr_info->tile[tileno].end_header,
|
||||
cstr_info->tile[tileno].end_pos,
|
||||
cstr_info->tile[tileno].num_tps);
|
||||
if (disto_on)
|
||||
fprintf(stream," %9e", cstr_info->tile[tileno].distotile);
|
||||
if (numpix_on)
|
||||
fprintf(stream," %9d", cstr_info->tile[tileno].numpix);
|
||||
if (disto_on && numpix_on)
|
||||
fprintf(stream," %9e", cstr_info->tile[tileno].distotile / cstr_info->tile[tileno].numpix);
|
||||
fprintf(stream, "\n");
|
||||
}
|
||||
|
||||
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
|
||||
int start_pos, end_ph_pos, end_pos;
|
||||
double disto = 0;
|
||||
int max_numdecompos = 0;
|
||||
pack_nb = 0;
|
||||
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
if (max_numdecompos < cstr_info->numdecompos[compno])
|
||||
max_numdecompos = cstr_info->numdecompos[compno];
|
||||
}
|
||||
|
||||
fprintf(stream, "\nTILE %d DETAILS\n", tileno);
|
||||
fprintf(stream, "part_nb tileno start_pack num_packs start_pos end_tph_pos end_pos\n");
|
||||
for (tilepartno = 0; tilepartno < cstr_info->tile[tileno].num_tps; tilepartno++)
|
||||
fprintf(stream, "%4d %9d %9d %9d %9d %11d %9d\n",
|
||||
tilepartno, tileno,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_start_pack,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_numpacks,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_start_pos,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_end_header,
|
||||
cstr_info->tile[tileno].tp[tilepartno].tp_end_pos
|
||||
);
|
||||
|
||||
if (cstr_info->prog == LRCP) { /* LRCP */
|
||||
fprintf(stream, "LRCP\npack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int prec_max;
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < prec_max; precno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %7d %5d %6d %6d %6d %6d %7d",
|
||||
pack_nb, tileno, layno, resno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* LRCP */
|
||||
|
||||
else if (cstr_info->prog == RLCP) { /* RLCP */
|
||||
fprintf(stream, "RLCP\npack_nb tileno resno layno compno precno start_pos end_ph_pos end_pos\n");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int prec_max;
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
prec_max = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < prec_max; precno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %5d %7d %6d %6d %9d %9d %7d",
|
||||
pack_nb, tileno, resno, layno, compno, precno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* RLCP */
|
||||
|
||||
else if (cstr_info->prog == RPCL) { /* RPCL */
|
||||
|
||||
fprintf(stream, "RPCL\npack_nb tileno resno precno compno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
for (precno = 0; precno < numprec; precno++) {
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor((float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (resno > cstr_info->numdecompos[compno])
|
||||
break;
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %5d %6d %6d %7d %9d %9d %7d",
|
||||
pack_nb, tileno, resno, precno, compno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* precno */
|
||||
} /* compno */
|
||||
} /* resno */
|
||||
} /* RPCL */
|
||||
|
||||
else if (cstr_info->prog == PCRL) { /* PCRL */
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
|
||||
/* Count the maximum number of precincts */
|
||||
int max_numprec = 0;
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
if (numprec > max_numprec)
|
||||
max_numprec = numprec;
|
||||
}
|
||||
|
||||
fprintf(stream, "PCRL\npack_nb tileno precno compno resno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (precno = 0; precno < max_numprec; precno++) {
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (precno >= numprec)
|
||||
continue;
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
|
||||
pack_nb, tileno, precno, compno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* resno */
|
||||
} /* compno */
|
||||
} /* precno */
|
||||
} /* PCRL */
|
||||
|
||||
else { /* CPRL */
|
||||
/* Count the maximum number of precincts */
|
||||
int max_numprec = 0;
|
||||
for (resno = 0; resno < max_numdecompos + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
if (numprec > max_numprec)
|
||||
max_numprec = numprec;
|
||||
}
|
||||
|
||||
fprintf(stream, "CPRL\npack_nb tileno compno precno resno layno start_pos end_ph_pos end_pos");
|
||||
if (disto_on)
|
||||
fprintf(stream, " disto");
|
||||
fprintf(stream,"\n");
|
||||
|
||||
for (compno = 0; compno < cstr_info->numcomps; compno++) {
|
||||
/* I suppose components have same XRsiz, YRsiz */
|
||||
int x0 = cstr_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tw * cstr_info->tile_x;
|
||||
int y0 = cstr_info->tile_Ox + (int)floor( (float)tileno/(float)cstr_info->tw ) * cstr_info->tile_y;
|
||||
int x1 = x0 + cstr_info->tile_x;
|
||||
int y1 = y0 + cstr_info->tile_y;
|
||||
|
||||
for (precno = 0; precno < max_numprec; precno++) {
|
||||
for (resno = 0; resno < cstr_info->numdecompos[compno] + 1; resno++) {
|
||||
int numprec = cstr_info->tile[tileno].pw[resno] * cstr_info->tile[tileno].ph[resno];
|
||||
int pcnx = cstr_info->tile[tileno].pw[resno];
|
||||
int pcx = (int) pow( 2, cstr_info->tile[tileno].pdx[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int pcy = (int) pow( 2, cstr_info->tile[tileno].pdy[resno] + cstr_info->numdecompos[compno] - resno );
|
||||
int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
|
||||
int precno_y = (int) floor( (float)precno/(float)pcnx );
|
||||
if (precno >= numprec)
|
||||
continue;
|
||||
|
||||
for(y = y0; y < y1; y++) {
|
||||
if (precno_y*pcy == y ) {
|
||||
for (x = x0; x < x1; x++) {
|
||||
if (precno_x*pcx == x ) {
|
||||
for (layno = 0; layno < cstr_info->numlayers; layno++) {
|
||||
start_pos = cstr_info->tile[tileno].packet[pack_nb].start_pos;
|
||||
end_ph_pos = cstr_info->tile[tileno].packet[pack_nb].end_ph_pos;
|
||||
end_pos = cstr_info->tile[tileno].packet[pack_nb].end_pos;
|
||||
disto = cstr_info->tile[tileno].packet[pack_nb].disto;
|
||||
fprintf(stream, "%4d %6d %6d %6d %5d %7d %9d %9d %7d",
|
||||
pack_nb, tileno, compno, precno, resno, layno, start_pos, end_ph_pos, end_pos);
|
||||
if (disto_on)
|
||||
fprintf(stream, " %8e", disto);
|
||||
fprintf(stream, "\n");
|
||||
total_disto += disto;
|
||||
pack_nb++;
|
||||
}
|
||||
}
|
||||
}/* x = x0..x1 */
|
||||
}
|
||||
} /* y = y0..y1 */
|
||||
} /* resno */
|
||||
} /* precno */
|
||||
} /* compno */
|
||||
} /* CPRL */
|
||||
} /* tileno */
|
||||
|
||||
if (disto_on) {
|
||||
fprintf(stream, "%8e\n", cstr_info->D_max); /* SE max */
|
||||
fprintf(stream, "%.8e\n", total_disto); /* SE totale */
|
||||
}
|
||||
/* UniPG>> */
|
||||
/* print the markers' list */
|
||||
if (cstr_info->marknum) {
|
||||
fprintf(stream, "\nMARKER LIST\n");
|
||||
fprintf(stream, "%d\n", cstr_info->marknum);
|
||||
fprintf(stream, "type\tstart_pos length\n");
|
||||
for (x = 0; x < cstr_info->marknum; x++)
|
||||
fprintf(stream, "%X\t%9d %9d\n", cstr_info->marker[x].type, cstr_info->marker[x].pos, cstr_info->marker[x].len);
|
||||
}
|
||||
/* <<UniPG */
|
||||
fclose(stream);
|
||||
|
||||
fprintf(stderr,"Generated index file %s\n", index);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __J2K_INDEX_H
|
||||
#define __J2K_INDEX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Write a structured index to a file
|
||||
@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 /* __J2K_INDEX_H */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __J2K_INDEX_H
|
||||
#define __J2K_INDEX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Write a structured index to a file
|
||||
@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 /* __J2K_INDEX_H */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Mathieu Malaterre, GDCM
|
||||
* Copyright (c) 20010, Mathieu Malaterre, GDCM
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -121,7 +121,6 @@ int get_num_images(char *imgdirpath){
|
||||
continue;
|
||||
num_images++;
|
||||
}
|
||||
closedir(dir);
|
||||
return num_images;
|
||||
}
|
||||
|
||||
@@ -147,7 +146,6 @@ int load_images(dircnt_t *dirptr, char *imgdirpath){
|
||||
strcpy(dirptr->filename[i],content->d_name);
|
||||
i++;
|
||||
}
|
||||
closedir(dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -201,22 +199,15 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||
int totlen, c;
|
||||
opj_option_t long_option[]={
|
||||
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||
#ifdef USE_SYSTEM_GETOPT
|
||||
{0,0,0,0} /* GNU getopt_long requirement */
|
||||
#endif
|
||||
};
|
||||
const char optlist[] = "i:o:h";
|
||||
|
||||
OPJ_ARG_NOT_USED(indexfilename);
|
||||
|
||||
totlen=sizeof(long_option);
|
||||
totlen=sizeof(long_option);
|
||||
img_fol->set_out_format = 0;
|
||||
do {
|
||||
#ifdef USE_SYSTEM_GETOPT
|
||||
c = opj_getopt_long(argc, argv,optlist,long_option,0);
|
||||
#else
|
||||
c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
|
||||
#endif
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
@@ -267,7 +258,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
default:
|
||||
fprintf(stderr,"[WARNING] An invalid option has been ignored\n");
|
||||
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
|
||||
break;
|
||||
}
|
||||
}while(c != -1);
|
||||
@@ -283,12 +274,12 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||
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)){
|
||||
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 ) {
|
||||
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;
|
||||
@@ -359,11 +350,6 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* j2k_dump focuses on j2k codestream and skips JP2 boxes */
|
||||
parameters.flags = 1;
|
||||
/* j2k_dump shall not actually decode packets (parsing codestream is enough). */
|
||||
parameters.cp_limit_decoding = DECODE_ALL_BUT_PACKETS;
|
||||
|
||||
/* Initialize reading of directory */
|
||||
if(img_fol.set_imgdir==1){
|
||||
num_images=get_num_images(img_fol.imgdirpath);
|
||||
@@ -459,7 +445,7 @@ int main(int argc, char *argv[])
|
||||
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*/
|
||||
if (*indexfilename) /* If need to extract codestream information*/
|
||||
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||
else
|
||||
image = opj_decode(dinfo, cio);
|
||||
@@ -508,7 +494,7 @@ int main(int argc, char *argv[])
|
||||
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*/
|
||||
if (*indexfilename) /* If need to extract codestream information*/
|
||||
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||
else
|
||||
image = opj_decode(dinfo, cio);
|
||||
|
||||
@@ -85,41 +85,7 @@ typedef struct img_folder{
|
||||
|
||||
}img_fol_t;
|
||||
|
||||
typedef enum opj_prec_mode
|
||||
{
|
||||
OPJ_PREC_MODE_CLIP,
|
||||
OPJ_PREC_MODE_SCALE
|
||||
} opj_precision_mode;
|
||||
|
||||
typedef struct opj_prec
|
||||
{
|
||||
int prec;
|
||||
opj_precision_mode mode;
|
||||
}opj_precision;
|
||||
|
||||
typedef struct opj_decompress_params
|
||||
{
|
||||
/** core library parameters */
|
||||
opj_dparameters_t core;
|
||||
|
||||
/** input file name */
|
||||
char infile[OPJ_PATH_LEN];
|
||||
/** output file name */
|
||||
char outfile[OPJ_PATH_LEN];
|
||||
/** input file format 0: J2K, 1: JP2, 2: JPT */
|
||||
int decod_format;
|
||||
/** output file format 0: PGX, 1: PxM, 2: BMP */
|
||||
int cod_format;
|
||||
|
||||
opj_precision* precision;
|
||||
int nb_precision;
|
||||
/* force output colorspace to RGB */
|
||||
int force_rgb;
|
||||
/* upsample components according to their dx/dy values */
|
||||
int upsample;
|
||||
}opj_decompress_parameters;
|
||||
|
||||
static void decode_help_display(void) {
|
||||
void decode_help_display(void) {
|
||||
fprintf(stdout,"HELP for j2k_to_image\n----\n\n");
|
||||
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||
|
||||
@@ -162,18 +128,6 @@ static void decode_help_display(void) {
|
||||
fprintf(stdout," are decoded.\n");
|
||||
fprintf(stdout," -x \n");
|
||||
fprintf(stdout," Create an index file *.Idx (-x index_name.Idx) \n");
|
||||
fprintf(stdout," -p <comp 0 precision>[C|S][,<comp 1 precision>[C|S][,...]]\n");
|
||||
fprintf(stdout," OPTIONAL\n");
|
||||
fprintf(stdout," Force the precision (bit depth) of components.\n");
|
||||
fprintf(stdout," There shall be at least 1 value. Theres no limit on the number of values (comma separated, last values ignored if too much values).\n");
|
||||
fprintf(stdout," If there are less values than components, the last value is used for remaining components.\n");
|
||||
fprintf(stdout," If 'C' is specified (default), values are clipped.\n");
|
||||
fprintf(stdout," If 'S' is specified, values are scaled.\n");
|
||||
fprintf(stdout," A 0 value can be specified (meaning original bit depth).\n");
|
||||
fprintf(stdout," -force-rgb\n");
|
||||
fprintf(stdout," Force output image colorspace to RGB\n");
|
||||
fprintf(stdout," -upsample\n");
|
||||
fprintf(stdout," Downsampled components will be upsampled to image size\n");
|
||||
fprintf(stdout,"\n");
|
||||
/* UniPG>> */
|
||||
#ifdef USE_JPWL
|
||||
@@ -190,112 +144,7 @@ static void decode_help_display(void) {
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
static opj_bool parse_precision(const char* option, opj_decompress_parameters* parameters)
|
||||
{
|
||||
const char* l_remaining = option;
|
||||
opj_bool l_result = OPJ_TRUE;
|
||||
|
||||
/* reset */
|
||||
if (parameters->precision) {
|
||||
free(parameters->precision);
|
||||
parameters->precision = NULL;
|
||||
}
|
||||
parameters->nb_precision = 0U;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
int prec;
|
||||
char mode;
|
||||
char comma;
|
||||
int count;
|
||||
|
||||
count = sscanf(l_remaining, "%d%c%c", &prec, &mode, &comma);
|
||||
if (count == 1) {
|
||||
mode = 'C';
|
||||
count++;
|
||||
}
|
||||
if ((count == 2) || (mode==',')) {
|
||||
if (mode==',') {
|
||||
mode = 'C';
|
||||
}
|
||||
comma=',';
|
||||
count = 3;
|
||||
}
|
||||
if (count == 3) {
|
||||
if ((prec < 1) || (prec > 32)) {
|
||||
fprintf(stderr,"Invalid precision %d in precision option %s\n", prec, option);
|
||||
l_result = OPJ_FALSE;
|
||||
break;
|
||||
}
|
||||
if ((mode != 'C') && (mode != 'S')) {
|
||||
fprintf(stderr,"Invalid precision mode %c in precision option %s\n", mode, option);
|
||||
l_result = OPJ_FALSE;
|
||||
break;
|
||||
}
|
||||
if (comma != ',') {
|
||||
fprintf(stderr,"Invalid character %c in precision option %s\n", comma, option);
|
||||
l_result = OPJ_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (parameters->precision == NULL) {
|
||||
/* first one */
|
||||
parameters->precision = (opj_precision *)malloc(sizeof(opj_precision));
|
||||
if (parameters->precision == NULL) {
|
||||
fprintf(stderr,"Could not allocate memory for precision option\n");
|
||||
l_result = OPJ_FALSE;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
int l_new_size = parameters->nb_precision + 1U;
|
||||
opj_precision* l_new;
|
||||
|
||||
if (l_new_size == 0U) {
|
||||
fprintf(stderr,"Could not allocate memory for precision option\n");
|
||||
l_result = OPJ_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
l_new = (opj_precision *)realloc(parameters->precision, l_new_size * sizeof(opj_precision));
|
||||
if (l_new == NULL) {
|
||||
fprintf(stderr,"Could not allocate memory for precision option\n");
|
||||
l_result = OPJ_FALSE;
|
||||
break;
|
||||
}
|
||||
parameters->precision = l_new;
|
||||
}
|
||||
|
||||
parameters->precision[parameters->nb_precision].prec = prec;
|
||||
switch (mode) {
|
||||
case 'C':
|
||||
parameters->precision[parameters->nb_precision].mode = OPJ_PREC_MODE_CLIP;
|
||||
break;
|
||||
case 'S':
|
||||
parameters->precision[parameters->nb_precision].mode = OPJ_PREC_MODE_SCALE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
parameters->nb_precision++;
|
||||
|
||||
l_remaining = strchr(l_remaining, ',');
|
||||
if (l_remaining == NULL) {
|
||||
break;
|
||||
}
|
||||
l_remaining += 1;
|
||||
} else {
|
||||
fprintf(stderr,"Could not parse precision option %s\n", option);
|
||||
l_result = OPJ_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return l_result;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
static int get_num_images(char *imgdirpath){
|
||||
int get_num_images(char *imgdirpath){
|
||||
DIR *dir;
|
||||
struct dirent* content;
|
||||
int num_images = 0;
|
||||
@@ -313,11 +162,10 @@ static int get_num_images(char *imgdirpath){
|
||||
continue;
|
||||
num_images++;
|
||||
}
|
||||
closedir(dir);
|
||||
return num_images;
|
||||
}
|
||||
|
||||
static int load_images(dircnt_t *dirptr, char *imgdirpath){
|
||||
int load_images(dircnt_t *dirptr, char *imgdirpath){
|
||||
DIR *dir;
|
||||
struct dirent* content;
|
||||
int i = 0;
|
||||
@@ -339,11 +187,10 @@ static int load_images(dircnt_t *dirptr, char *imgdirpath){
|
||||
strcpy(dirptr->filename[i],content->d_name);
|
||||
i++;
|
||||
}
|
||||
closedir(dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_file_format(char *filename) {
|
||||
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 };
|
||||
@@ -362,7 +209,7 @@ static int get_file_format(char *filename) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_decompress_parameters *parameters){
|
||||
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]="";
|
||||
|
||||
@@ -388,20 +235,15 @@ static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_d
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *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 */
|
||||
int totlen, c;
|
||||
opj_option_t long_option[]={
|
||||
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||
{"OutFor",REQ_ARG, NULL ,'O'},
|
||||
{"force-rgb", NO_ARG, NULL, 1},
|
||||
{"upsample", NO_ARG, NULL, 1},
|
||||
#ifdef USE_SYSTEM_GETOPT
|
||||
{0,0,0,0} /* GNU getopt_long requirement */
|
||||
#endif
|
||||
};
|
||||
|
||||
const char optlist[] = "i:o:r:l:x:p:"
|
||||
const char optlist[] = "i:o:r:l:x:"
|
||||
|
||||
/* UniPG>> */
|
||||
#ifdef USE_JPWL
|
||||
@@ -409,22 +251,13 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameter
|
||||
#endif /* USE_JPWL */
|
||||
/* <<UniPG */
|
||||
"h" ;
|
||||
|
||||
long_option[2].flag = &(parameters->force_rgb);
|
||||
long_option[3].flag = &(parameters->upsample);
|
||||
totlen=sizeof(long_option);
|
||||
img_fol->set_out_format = 0;
|
||||
do {
|
||||
#ifdef USE_SYSTEM_GETOPT
|
||||
c = opj_getopt_long(argc, argv,optlist,long_option,0);
|
||||
#else
|
||||
c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
|
||||
#endif
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
case 0: /* long opt with flag */
|
||||
break;
|
||||
case 'i': /* input file */
|
||||
{
|
||||
char *infile = opj_optarg;
|
||||
@@ -511,7 +344,7 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameter
|
||||
|
||||
case 'r': /* reduce option */
|
||||
{
|
||||
sscanf(opj_optarg, "%d", ¶meters->core.cp_reduce);
|
||||
sscanf(opj_optarg, "%d", ¶meters->cp_reduce);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -520,7 +353,7 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameter
|
||||
|
||||
case 'l': /* layering option */
|
||||
{
|
||||
sscanf(opj_optarg, "%d", ¶meters->core.cp_layer);
|
||||
sscanf(opj_optarg, "%d", ¶meters->cp_layer);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -547,15 +380,6 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameter
|
||||
}
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
case 'p': /* Force precision */
|
||||
{
|
||||
if (!parse_precision(opj_optarg, parameters))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
/* UniPG>> */
|
||||
#ifdef USE_JPWL
|
||||
|
||||
@@ -630,7 +454,7 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameter
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
default:
|
||||
fprintf(stderr,"[WARNING] An invalid option has been ignored\n");
|
||||
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
|
||||
break;
|
||||
}
|
||||
}while(c != -1);
|
||||
@@ -663,283 +487,32 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameter
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
static void set_default_parameters(opj_decompress_parameters* parameters)
|
||||
{
|
||||
if (parameters) {
|
||||
memset(parameters, 0, sizeof(opj_decompress_parameters));
|
||||
|
||||
/* default decoding parameters (command line specific) */
|
||||
parameters->decod_format = -1;
|
||||
parameters->cod_format = -1;
|
||||
|
||||
/* default decoding parameters (core) */
|
||||
opj_set_default_decoder_parameters(&(parameters->core));
|
||||
}
|
||||
}
|
||||
|
||||
static void destroy_parameters(opj_decompress_parameters* parameters)
|
||||
{
|
||||
if (parameters) {
|
||||
if (parameters->precision) {
|
||||
free(parameters->precision);
|
||||
parameters->precision = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
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;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
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;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample debug callback expecting no client object
|
||||
*/
|
||||
static void info_callback(const char *msg, void *client_data) {
|
||||
void info_callback(const char *msg, void *client_data) {
|
||||
(void)client_data;
|
||||
fprintf(stdout, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
static opj_image_t* convert_gray_to_rgb(opj_image_t* original)
|
||||
{
|
||||
int compno;
|
||||
opj_image_t* l_new_image = NULL;
|
||||
opj_image_cmptparm_t* l_new_components = NULL;
|
||||
|
||||
l_new_components = (opj_image_cmptparm_t*)malloc((original->numcomps + 2U) * sizeof(opj_image_cmptparm_t));
|
||||
if (l_new_components == NULL) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to allocate memory for RGB image!\n");
|
||||
opj_image_destroy(original);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
l_new_components[0].bpp = l_new_components[1].bpp = l_new_components[2].bpp = original->comps[0].bpp;
|
||||
l_new_components[0].dx = l_new_components[1].dx = l_new_components[2].dx = original->comps[0].dx;
|
||||
l_new_components[0].dy = l_new_components[1].dy = l_new_components[2].dy = original->comps[0].dy;
|
||||
l_new_components[0].h = l_new_components[1].h = l_new_components[2].h = original->comps[0].h;
|
||||
l_new_components[0].w = l_new_components[1].w = l_new_components[2].w = original->comps[0].w;
|
||||
l_new_components[0].prec = l_new_components[1].prec = l_new_components[2].prec = original->comps[0].prec;
|
||||
l_new_components[0].sgnd = l_new_components[1].sgnd = l_new_components[2].sgnd = original->comps[0].sgnd;
|
||||
l_new_components[0].x0 = l_new_components[1].x0 = l_new_components[2].x0 = original->comps[0].x0;
|
||||
l_new_components[0].y0 = l_new_components[1].y0 = l_new_components[2].y0 = original->comps[0].y0;
|
||||
|
||||
for(compno = 1; compno < original->numcomps; ++compno) {
|
||||
l_new_components[compno+2].bpp = original->comps[compno].bpp;
|
||||
l_new_components[compno+2].dx = original->comps[compno].dx;
|
||||
l_new_components[compno+2].dy = original->comps[compno].dy;
|
||||
l_new_components[compno+2].h = original->comps[compno].h;
|
||||
l_new_components[compno+2].w = original->comps[compno].w;
|
||||
l_new_components[compno+2].prec = original->comps[compno].prec;
|
||||
l_new_components[compno+2].sgnd = original->comps[compno].sgnd;
|
||||
l_new_components[compno+2].x0 = original->comps[compno].x0;
|
||||
l_new_components[compno+2].y0 = original->comps[compno].y0;
|
||||
}
|
||||
|
||||
l_new_image = opj_image_create(original->numcomps + 2, l_new_components, CLRSPC_SRGB);
|
||||
free(l_new_components);
|
||||
if (l_new_image == NULL) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to allocate memory for RGB image!\n");
|
||||
opj_image_destroy(original);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
l_new_image->x0 = original->x0;
|
||||
l_new_image->x1 = original->x1;
|
||||
l_new_image->y0 = original->y0;
|
||||
l_new_image->y1 = original->y1;
|
||||
|
||||
l_new_image->comps[0].factor = l_new_image->comps[1].factor = l_new_image->comps[2].factor = original->comps[0].factor;
|
||||
l_new_image->comps[0].resno_decoded = l_new_image->comps[1].resno_decoded = l_new_image->comps[2].resno_decoded = original->comps[0].resno_decoded;
|
||||
|
||||
memcpy(l_new_image->comps[0].data, original->comps[0].data, original->comps[0].w * original->comps[0].h * sizeof(int));
|
||||
memcpy(l_new_image->comps[1].data, original->comps[0].data, original->comps[0].w * original->comps[0].h * sizeof(int));
|
||||
memcpy(l_new_image->comps[2].data, original->comps[0].data, original->comps[0].w * original->comps[0].h * sizeof(int));
|
||||
|
||||
for(compno = 1; compno < original->numcomps; ++compno) {
|
||||
l_new_image->comps[compno+2].factor = original->comps[compno].factor;
|
||||
l_new_image->comps[compno+2].resno_decoded = original->comps[compno].resno_decoded;
|
||||
memcpy(l_new_image->comps[compno+2].data, original->comps[compno].data, original->comps[compno].w * original->comps[compno].h * sizeof(int));
|
||||
}
|
||||
opj_image_destroy(original);
|
||||
return l_new_image;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
static opj_image_t* upsample_image_components(opj_image_t* original)
|
||||
{
|
||||
opj_image_t* l_new_image = NULL;
|
||||
opj_image_cmptparm_t* l_new_components = NULL;
|
||||
opj_bool l_upsample_need = OPJ_FALSE;
|
||||
int compno;
|
||||
|
||||
for (compno = 0; compno < original->numcomps; ++compno) {
|
||||
if (original->comps[compno].factor > 0) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: -upsample not supported with reduction\n");
|
||||
opj_image_destroy(original);
|
||||
return NULL;
|
||||
}
|
||||
if ((original->comps[compno].dx > 1) || (original->comps[compno].dy > 1)) {
|
||||
l_upsample_need = OPJ_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!l_upsample_need) {
|
||||
return original;
|
||||
}
|
||||
/* Upsample is needed */
|
||||
l_new_components = (opj_image_cmptparm_t*)malloc(original->numcomps * sizeof(opj_image_cmptparm_t));
|
||||
if (l_new_components == NULL) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to allocate memory for upsampled components!\n");
|
||||
opj_image_destroy(original);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (compno = 0; compno < original->numcomps; ++compno) {
|
||||
opj_image_cmptparm_t* l_new_cmp = &(l_new_components[compno]);
|
||||
opj_image_comp_t* l_org_cmp = &(original->comps[compno]);
|
||||
|
||||
l_new_cmp->bpp = l_org_cmp->bpp;
|
||||
l_new_cmp->prec = l_org_cmp->prec;
|
||||
l_new_cmp->sgnd = l_org_cmp->sgnd;
|
||||
l_new_cmp->x0 = original->x0;
|
||||
l_new_cmp->y0 = original->y0;
|
||||
l_new_cmp->dx = 1;
|
||||
l_new_cmp->dy = 1;
|
||||
l_new_cmp->w = l_org_cmp->w; /* should be original->x1 - original->x0 for dx==1 */
|
||||
l_new_cmp->h = l_org_cmp->h; /* should be original->y1 - original->y0 for dy==0 */
|
||||
|
||||
if (l_org_cmp->dx > 1) {
|
||||
l_new_cmp->w = original->x1 - original->x0;
|
||||
}
|
||||
|
||||
if (l_org_cmp->dy > 1) {
|
||||
l_new_cmp->h = original->y1 - original->y0;
|
||||
}
|
||||
}
|
||||
|
||||
l_new_image = opj_image_create(original->numcomps, l_new_components, original->color_space);
|
||||
free(l_new_components);
|
||||
if (l_new_image == NULL) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to allocate memory for upsampled components!\n");
|
||||
opj_image_destroy(original);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
l_new_image->x0 = original->x0;
|
||||
l_new_image->x1 = original->x1;
|
||||
l_new_image->y0 = original->y0;
|
||||
l_new_image->y1 = original->y1;
|
||||
|
||||
for (compno = 0; compno < original->numcomps; ++compno) {
|
||||
opj_image_comp_t* l_new_cmp = &(l_new_image->comps[compno]);
|
||||
opj_image_comp_t* l_org_cmp = &(original->comps[compno]);
|
||||
|
||||
l_new_cmp->factor = l_org_cmp->factor;
|
||||
l_new_cmp->resno_decoded = l_org_cmp->resno_decoded;
|
||||
|
||||
if ((l_org_cmp->dx > 1) || (l_org_cmp->dy > 1)) {
|
||||
const int* l_src = l_org_cmp->data;
|
||||
int* l_dst = l_new_cmp->data;
|
||||
int y;
|
||||
int xoff, yoff;
|
||||
|
||||
/* need to take into account dx & dy */
|
||||
xoff = l_org_cmp->dx * l_org_cmp->x0 - original->x0;
|
||||
yoff = l_org_cmp->dy * l_org_cmp->y0 - original->y0;
|
||||
if ((xoff >= l_org_cmp->dx) || (yoff >= l_org_cmp->dy)) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: Invalid image/component parameters found when upsampling\n");
|
||||
opj_image_destroy(original);
|
||||
opj_image_destroy(l_new_image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (y = 0; y < yoff; ++y) {
|
||||
memset(l_dst, 0, l_new_cmp->w * sizeof(int));
|
||||
l_dst += l_new_cmp->w;
|
||||
}
|
||||
|
||||
if(l_new_cmp->h > (l_org_cmp->dy - 1)) { /* check subtraction overflow for really small images */
|
||||
for (; y < l_new_cmp->h - (l_org_cmp->dy - 1); y += l_org_cmp->dy) {
|
||||
int x, dy;
|
||||
int xorg;
|
||||
|
||||
xorg = 0;
|
||||
for (x = 0; x < xoff; ++x) {
|
||||
l_dst[x] = 0;
|
||||
}
|
||||
if (l_new_cmp->w > (l_org_cmp->dx - 1)) { /* check subtraction overflow for really small images */
|
||||
for (; x < l_new_cmp->w - (l_org_cmp->dx - 1); x += l_org_cmp->dx, ++xorg) {
|
||||
int dx;
|
||||
for (dx = 0; dx < l_org_cmp->dx; ++dx) {
|
||||
l_dst[x + dx] = l_src[xorg];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (; x < l_new_cmp->w; ++x) {
|
||||
l_dst[x] = l_src[xorg];
|
||||
}
|
||||
l_dst += l_new_cmp->w;
|
||||
|
||||
for (dy = 1; dy < l_org_cmp->dy; ++dy) {
|
||||
memcpy(l_dst, l_dst - l_new_cmp->w, l_new_cmp->w * sizeof(int));
|
||||
l_dst += l_new_cmp->w;
|
||||
}
|
||||
l_src += l_org_cmp->w;
|
||||
}
|
||||
}
|
||||
if (y < l_new_cmp->h) {
|
||||
int x;
|
||||
int xorg;
|
||||
|
||||
xorg = 0;
|
||||
for (x = 0; x < xoff; ++x) {
|
||||
l_dst[x] = 0;
|
||||
}
|
||||
if (l_new_cmp->w > (l_org_cmp->dx - 1)) { /* check subtraction overflow for really small images */
|
||||
for (; x < l_new_cmp->w - (l_org_cmp->dx - 1); x += l_org_cmp->dx, ++xorg) {
|
||||
int dx;
|
||||
for (dx = 0; dx < l_org_cmp->dx; ++dx) {
|
||||
l_dst[x + dx] = l_src[xorg];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (; x < l_new_cmp->w; ++x) {
|
||||
l_dst[x] = l_src[xorg];
|
||||
}
|
||||
l_dst += l_new_cmp->w;
|
||||
++y;
|
||||
for (; y < l_new_cmp->h; ++y) {
|
||||
memcpy(l_dst, l_dst - l_new_cmp->w, l_new_cmp->w * sizeof(int));
|
||||
l_dst += l_new_cmp->w;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
memcpy(l_new_cmp->data, l_org_cmp->data, l_org_cmp->w * l_org_cmp->h * sizeof(int));
|
||||
}
|
||||
}
|
||||
opj_image_destroy(original);
|
||||
return l_new_image;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
opj_decompress_parameters parameters; /* decompression parameters */
|
||||
opj_dparameters_t parameters; /* decompression parameters */
|
||||
img_fol_t img_fol;
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
opj_image_t *image = NULL;
|
||||
@@ -961,7 +534,7 @@ int main(int argc, char **argv) {
|
||||
event_mgr.info_handler = info_callback;
|
||||
|
||||
/* set decoding parameters to default values */
|
||||
set_default_parameters(¶meters);
|
||||
opj_set_default_decoder_parameters(¶meters);
|
||||
|
||||
/* Initialize indexfilename and img_fol */
|
||||
*indexfilename = 0;
|
||||
@@ -969,7 +542,6 @@ int main(int argc, char **argv) {
|
||||
|
||||
/* parse input and get user encoding parameters */
|
||||
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
|
||||
destroy_parameters(¶meters);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -983,7 +555,6 @@ int main(int argc, char **argv) {
|
||||
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
|
||||
|
||||
if(!dirptr->filename_buf){
|
||||
destroy_parameters(¶meters);
|
||||
return 1;
|
||||
}
|
||||
for(i=0;i<num_images;i++){
|
||||
@@ -991,12 +562,10 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||
destroy_parameters(¶meters);
|
||||
return 1;
|
||||
}
|
||||
if (num_images==0){
|
||||
fprintf(stdout,"Folder is empty\n");
|
||||
destroy_parameters(¶meters);
|
||||
return 1;
|
||||
}
|
||||
}else{
|
||||
@@ -1020,7 +589,6 @@ int main(int argc, char **argv) {
|
||||
fsrc = fopen(parameters.infile, "rb");
|
||||
if (!fsrc) {
|
||||
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
||||
destroy_parameters(¶meters);
|
||||
return 1;
|
||||
}
|
||||
fseek(fsrc, 0, SEEK_END);
|
||||
@@ -1032,7 +600,6 @@ int main(int argc, char **argv) {
|
||||
free(src);
|
||||
fclose(fsrc);
|
||||
fprintf(stderr, "\nERROR: fread return a number of element different from the expected.\n");
|
||||
destroy_parameters(¶meters);
|
||||
return 1;
|
||||
}
|
||||
fclose(fsrc);
|
||||
@@ -1052,7 +619,7 @@ int main(int argc, char **argv) {
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
opj_setup_decoder(dinfo, ¶meters.core);
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
@@ -1067,7 +634,6 @@ int main(int argc, char **argv) {
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
free(src);
|
||||
destroy_parameters(¶meters);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1096,7 +662,7 @@ int main(int argc, char **argv) {
|
||||
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.core);
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
@@ -1111,7 +677,6 @@ int main(int argc, char **argv) {
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
free(src);
|
||||
destroy_parameters(¶meters);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1140,7 +705,7 @@ int main(int argc, char **argv) {
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
opj_setup_decoder(dinfo, ¶meters.core);
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
@@ -1155,7 +720,6 @@ int main(int argc, char **argv) {
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
free(src);
|
||||
destroy_parameters(¶meters);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1182,89 +746,20 @@ int main(int argc, char **argv) {
|
||||
free(src);
|
||||
src = NULL;
|
||||
|
||||
if(image->color_space == CLRSPC_SYCC)
|
||||
{
|
||||
color_sycc_to_rgb(image);
|
||||
}
|
||||
if(image->color_space == CLRSPC_SYCC)
|
||||
{
|
||||
color_sycc_to_rgb(image);
|
||||
}
|
||||
|
||||
if(image->icc_profile_buf)
|
||||
{
|
||||
if(image->icc_profile_buf)
|
||||
{
|
||||
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
|
||||
color_apply_icc_profile(image);
|
||||
color_apply_icc_profile(image);
|
||||
#endif
|
||||
free(image->icc_profile_buf);
|
||||
image->icc_profile_buf = NULL; image->icc_profile_len = 0;
|
||||
}
|
||||
|
||||
/* Force output precision */
|
||||
/* ---------------------- */
|
||||
if (parameters.precision != NULL)
|
||||
{
|
||||
int compno;
|
||||
for (compno = 0; compno < image->numcomps; ++compno)
|
||||
{
|
||||
int precno = compno;
|
||||
int prec;
|
||||
|
||||
if (precno >= parameters.nb_precision) {
|
||||
precno = parameters.nb_precision - 1U;
|
||||
}
|
||||
|
||||
prec = parameters.precision[precno].prec;
|
||||
if (prec == 0) {
|
||||
prec = image->comps[compno].prec;
|
||||
}
|
||||
|
||||
switch (parameters.precision[precno].mode) {
|
||||
case OPJ_PREC_MODE_CLIP:
|
||||
clip_component(&(image->comps[compno]), prec);
|
||||
break;
|
||||
case OPJ_PREC_MODE_SCALE:
|
||||
scale_component(&(image->comps[compno]), prec);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Upsample components */
|
||||
/* ------------------- */
|
||||
if (parameters.upsample)
|
||||
{
|
||||
image = upsample_image_components(image);
|
||||
if (image == NULL) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to upsample image components!\n");
|
||||
destroy_parameters(¶meters);
|
||||
opj_destroy_decompress(dinfo);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Force RGB output */
|
||||
/* ---------------- */
|
||||
if (parameters.force_rgb)
|
||||
{
|
||||
switch (image->color_space) {
|
||||
case CLRSPC_SRGB:
|
||||
break;
|
||||
case CLRSPC_GRAY:
|
||||
image = convert_gray_to_rgb(image);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: don't know how to convert image to RGB colorspace!\n");
|
||||
opj_image_destroy(image);
|
||||
image = NULL;
|
||||
break;
|
||||
}
|
||||
if (image == NULL) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to convert to RGB image!\n");
|
||||
destroy_parameters(¶meters);
|
||||
opj_destroy_decompress(dinfo);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
free(image->icc_profile_buf);
|
||||
image->icc_profile_buf = NULL; image->icc_profile_len = 0;
|
||||
}
|
||||
|
||||
/* create output image */
|
||||
/* ------------------- */
|
||||
@@ -1350,7 +845,6 @@ int main(int argc, char **argv) {
|
||||
opj_image_destroy(image);
|
||||
|
||||
}
|
||||
destroy_parameters(¶meters);
|
||||
return 0;
|
||||
}
|
||||
/*end main*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -46,31 +46,31 @@
|
||||
#endif
|
||||
|
||||
/*--------------------------------------------------------
|
||||
Matrix for sYCC, Amendment 1 to IEC 61966-2-1
|
||||
|
||||
Y : 0.299 0.587 0.114 :R
|
||||
Cb: -0.1687 -0.3312 0.5 :G
|
||||
Cr: 0.5 -0.4187 -0.0812 :B
|
||||
|
||||
Inverse:
|
||||
|
||||
R: 1 -3.68213e-05 1.40199 :Y
|
||||
G: 1.00003 -0.344125 -0.714128 :Cb - 2^(prec - 1)
|
||||
B: 0.999823 1.77204 -8.04142e-06 :Cr - 2^(prec - 1)
|
||||
|
||||
-----------------------------------------------------------*/
|
||||
Matrix f<EFBFBD>r sYCC, Amendment 1 to IEC 61966-2-1
|
||||
|
||||
Y : 0.299 0.587 0.114 :R
|
||||
Cb: -0.1687 -0.3312 0.5 :G
|
||||
Cr: 0.5 -0.4187 -0.0812 :B
|
||||
|
||||
Inverse:
|
||||
|
||||
R: 1 -3.68213e-05 1.40199 :Y
|
||||
G: 1.00003 -0.344125 -0.714128 :Cb - 2^(prec - 1)
|
||||
B: 0.999823 1.77204 -8.04142e-06 :Cr - 2^(prec - 1)
|
||||
|
||||
-----------------------------------------------------------*/
|
||||
static void sycc_to_rgb(int offset, int upb, int y, int cb, int cr,
|
||||
int *out_r, int *out_g, int *out_b)
|
||||
int *out_r, int *out_g, int *out_b)
|
||||
{
|
||||
int r, g, b;
|
||||
|
||||
|
||||
cb -= offset; cr -= offset;
|
||||
r = y + (int)(1.402 * (float)cr);
|
||||
if(r < 0) r = 0; else if(r > upb) r = upb; *out_r = r;
|
||||
|
||||
|
||||
g = y - (int)(0.344 * (float)cb + 0.714 * (float)cr);
|
||||
if(g < 0) g = 0; else if(g > upb) g = upb; *out_g = g;
|
||||
|
||||
|
||||
b = y + (int)(1.772 * (float)cb);
|
||||
if(b < 0) b = 0; else if(b > upb) b = upb; *out_b = b;
|
||||
}
|
||||
@@ -79,206 +79,185 @@ static void sycc444_to_rgb(opj_image_t *img)
|
||||
{
|
||||
int *d0, *d1, *d2, *r, *g, *b;
|
||||
const int *y, *cb, *cr;
|
||||
unsigned int maxw, maxh, max, i;
|
||||
int offset, upb;
|
||||
|
||||
upb = (int)img->comps[0].prec;
|
||||
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||
|
||||
maxw = (unsigned int)img->comps[0].w; maxh = (unsigned int)img->comps[0].h;
|
||||
int maxw, maxh, max, i, offset, upb;
|
||||
|
||||
i = img->comps[0].prec;
|
||||
offset = 1<<(i - 1); upb = (1<<i)-1;
|
||||
|
||||
maxw = img->comps[0].w; maxh = img->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
|
||||
|
||||
y = img->comps[0].data;
|
||||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
|
||||
for(i = 0U; i < max; ++i)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++cb; ++cr; ++r; ++g; ++b;
|
||||
}
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++cb; ++cr; ++r; ++g; ++b;
|
||||
}
|
||||
free(img->comps[0].data); img->comps[0].data = d0;
|
||||
free(img->comps[1].data); img->comps[1].data = d1;
|
||||
free(img->comps[2].data); img->comps[2].data = d2;
|
||||
|
||||
|
||||
}/* sycc444_to_rgb() */
|
||||
|
||||
static void sycc422_to_rgb(opj_image_t *img)
|
||||
{
|
||||
{
|
||||
int *d0, *d1, *d2, *r, *g, *b;
|
||||
const int *y, *cb, *cr;
|
||||
unsigned int maxw, maxh, max;
|
||||
int offset, upb;
|
||||
unsigned int i, j;
|
||||
|
||||
upb = (int)img->comps[0].prec;
|
||||
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||
|
||||
maxw = (unsigned int)img->comps[0].w; maxh = (unsigned int)img->comps[0].h;
|
||||
int maxw, maxh, max, offset, upb;
|
||||
int i, j;
|
||||
|
||||
i = img->comps[0].prec;
|
||||
offset = 1<<(i - 1); upb = (1<<i)-1;
|
||||
|
||||
maxw = img->comps[0].w; maxh = img->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
|
||||
|
||||
y = img->comps[0].data;
|
||||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
|
||||
for(i=0U; i < maxh; ++i)
|
||||
{
|
||||
for(j=0U; j < (maxw & ~(unsigned int)1U); j += 2U)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b; ++cb; ++cr;
|
||||
}
|
||||
if (j < maxw) {
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b; ++cb; ++cr;
|
||||
}
|
||||
}
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||
|
||||
for(i=0; i < maxh; ++i)
|
||||
{
|
||||
for(j=0; j < maxw; j += 2)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++r; ++g; ++b;
|
||||
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++r; ++g; ++b; ++cb; ++cr;
|
||||
}
|
||||
}
|
||||
free(img->comps[0].data); img->comps[0].data = d0;
|
||||
free(img->comps[1].data); img->comps[1].data = d1;
|
||||
free(img->comps[2].data); img->comps[2].data = d2;
|
||||
|
||||
|
||||
img->comps[1].w = maxw; img->comps[1].h = maxh;
|
||||
img->comps[2].w = maxw; img->comps[2].h = maxh;
|
||||
img->comps[1].dx = img->comps[0].dx;
|
||||
img->comps[2].dx = img->comps[0].dx;
|
||||
img->comps[1].dy = img->comps[0].dy;
|
||||
img->comps[2].dy = img->comps[0].dy;
|
||||
|
||||
}/* sycc422_to_rgb() */
|
||||
|
||||
static void sycc420_to_rgb(opj_image_t *img)
|
||||
{
|
||||
int *d0, *d1, *d2, *r, *g, *b, *nr, *ng, *nb;
|
||||
const int *y, *cb, *cr, *ny;
|
||||
unsigned int maxw, maxh, max;
|
||||
int offset, upb;
|
||||
unsigned int i, j;
|
||||
|
||||
upb = (int)img->comps[0].prec;
|
||||
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||
|
||||
maxw = (unsigned int)img->comps[0].w; maxh = (unsigned int)img->comps[0].h;
|
||||
int maxw, maxh, max, offset, upb;
|
||||
int i, j;
|
||||
|
||||
i = img->comps[0].prec;
|
||||
offset = 1<<(i - 1); upb = (1<<i)-1;
|
||||
|
||||
maxw = img->comps[0].w; maxh = img->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
|
||||
|
||||
y = img->comps[0].data;
|
||||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
|
||||
for(i=0U; i < (maxh & ~(unsigned int)1U); i += 2U)
|
||||
{
|
||||
ny = y + maxw;
|
||||
nr = r + maxw; ng = g + maxw; nb = b + maxw;
|
||||
|
||||
for(j=0; j < (maxw & ~(unsigned int)1U); j += 2U)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
|
||||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
++ny; ++nr; ++ng; ++nb;
|
||||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
|
||||
}
|
||||
if(j < maxw)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
|
||||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
|
||||
}
|
||||
y += maxw; r += maxw; g += maxw; b += maxw;
|
||||
}
|
||||
if(i < maxh)
|
||||
{
|
||||
for(j=0U; j < (maxw & ~(unsigned int)1U); j += 2U)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++r; ++g; ++b;
|
||||
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++r; ++g; ++b; ++cb; ++cr;
|
||||
}
|
||||
if(j < maxw)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * max);
|
||||
|
||||
for(i=0; i < maxh; i += 2)
|
||||
{
|
||||
ny = y + maxw;
|
||||
nr = r + maxw; ng = g + maxw; nb = b + maxw;
|
||||
|
||||
for(j=0; j < maxw; j += 2)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++r; ++g; ++b;
|
||||
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++r; ++g; ++b;
|
||||
|
||||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
|
||||
++ny; ++nr; ++ng; ++nb;
|
||||
|
||||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
|
||||
++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
|
||||
}
|
||||
y += maxw; r += maxw; g += maxw; b += maxw;
|
||||
}
|
||||
free(img->comps[0].data); img->comps[0].data = d0;
|
||||
free(img->comps[1].data); img->comps[1].data = d1;
|
||||
free(img->comps[2].data); img->comps[2].data = d2;
|
||||
|
||||
|
||||
img->comps[1].w = maxw; img->comps[1].h = maxh;
|
||||
img->comps[2].w = maxw; img->comps[2].h = maxh;
|
||||
img->comps[1].dx = img->comps[0].dx;
|
||||
img->comps[2].dx = img->comps[0].dx;
|
||||
img->comps[1].dy = img->comps[0].dy;
|
||||
img->comps[2].dy = img->comps[0].dy;
|
||||
|
||||
|
||||
}/* sycc420_to_rgb() */
|
||||
|
||||
void color_sycc_to_rgb(opj_image_t *img)
|
||||
{
|
||||
if(img->numcomps < 3)
|
||||
{
|
||||
img->color_space = CLRSPC_GRAY;
|
||||
return;
|
||||
}
|
||||
|
||||
if(img->numcomps < 3)
|
||||
{
|
||||
img->color_space = CLRSPC_GRAY;
|
||||
return;
|
||||
}
|
||||
|
||||
if((img->comps[0].dx == 1)
|
||||
&& (img->comps[1].dx == 2)
|
||||
&& (img->comps[2].dx == 2)
|
||||
&& (img->comps[0].dy == 1)
|
||||
&& (img->comps[1].dy == 2)
|
||||
&& (img->comps[2].dy == 2))/* horizontal and vertical sub-sample */
|
||||
{
|
||||
sycc420_to_rgb(img);
|
||||
}
|
||||
else
|
||||
if((img->comps[0].dx == 1)
|
||||
&& (img->comps[1].dx == 2)
|
||||
&& (img->comps[2].dx == 2)
|
||||
&& (img->comps[0].dy == 1)
|
||||
&& (img->comps[1].dy == 1)
|
||||
&& (img->comps[2].dy == 1))/* horizontal sub-sample only */
|
||||
&& (img->comps[1].dx == 2)
|
||||
&& (img->comps[2].dx == 2)
|
||||
&& (img->comps[0].dy == 1)
|
||||
&& (img->comps[1].dy == 2)
|
||||
&& (img->comps[2].dy == 2))/* horizontal and vertical sub-sample */
|
||||
{
|
||||
sycc422_to_rgb(img);
|
||||
}
|
||||
else
|
||||
if((img->comps[0].dx == 1)
|
||||
&& (img->comps[1].dx == 1)
|
||||
&& (img->comps[2].dx == 1)
|
||||
&& (img->comps[0].dy == 1)
|
||||
&& (img->comps[1].dy == 1)
|
||||
&& (img->comps[2].dy == 1))/* no sub-sample */
|
||||
{
|
||||
sycc444_to_rgb(img);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"%s:%d:color_sycc_to_rgb\n\tCAN NOT CONVERT\n", __FILE__,__LINE__);
|
||||
return;
|
||||
}
|
||||
sycc420_to_rgb(img);
|
||||
}
|
||||
else
|
||||
if((img->comps[0].dx == 1)
|
||||
&& (img->comps[1].dx == 2)
|
||||
&& (img->comps[2].dx == 2)
|
||||
&& (img->comps[0].dy == 1)
|
||||
&& (img->comps[1].dy == 1)
|
||||
&& (img->comps[2].dy == 1))/* horizontal sub-sample only */
|
||||
{
|
||||
sycc422_to_rgb(img);
|
||||
}
|
||||
else
|
||||
if((img->comps[0].dx == 1)
|
||||
&& (img->comps[1].dx == 1)
|
||||
&& (img->comps[2].dx == 1)
|
||||
&& (img->comps[0].dy == 1)
|
||||
&& (img->comps[1].dy == 1)
|
||||
&& (img->comps[2].dy == 1))/* no sub-sample */
|
||||
{
|
||||
sycc444_to_rgb(img);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"%s:%d:color_sycc_to_rgb\n\tCAN NOT CONVERT\n",
|
||||
__FILE__,__LINE__);
|
||||
return;
|
||||
}
|
||||
img->color_space = CLRSPC_SRGB;
|
||||
|
||||
|
||||
}/* color_sycc_to_rgb() */
|
||||
|
||||
#if defined(HAVE_LIBLCMS2) || defined(HAVE_LIBLCMS1)
|
||||
@@ -307,226 +286,176 @@ void color_apply_icc_profile(opj_image_t *image)
|
||||
int *r, *g, *b;
|
||||
int prec, i, max, max_w, max_h;
|
||||
OPJ_COLOR_SPACE oldspace;
|
||||
|
||||
in_prof =
|
||||
cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
|
||||
#ifdef DEBUG_PROFILE
|
||||
FILE *icm = fopen("debug.icm","wb");
|
||||
fwrite( image->icc_profile_buf,1, image->icc_profile_len,icm);
|
||||
fclose(icm);
|
||||
#endif
|
||||
|
||||
|
||||
in_prof =
|
||||
cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
|
||||
|
||||
if(in_prof == NULL) return;
|
||||
|
||||
|
||||
in_space = cmsGetPCS(in_prof);
|
||||
out_space = cmsGetColorSpace(in_prof);
|
||||
intent = cmsGetHeaderRenderingIntent(in_prof);
|
||||
|
||||
|
||||
|
||||
max_w = (int)image->comps[0].w;
|
||||
max_h = (int)image->comps[0].h;
|
||||
prec = (int)image->comps[0].prec;
|
||||
max_w = image->comps[0].w; max_h = image->comps[0].h;
|
||||
prec = image->comps[0].prec;
|
||||
oldspace = image->color_space;
|
||||
|
||||
|
||||
if(out_space == cmsSigRgbData) /* enumCS 16 */
|
||||
{
|
||||
if( prec <= 8 )
|
||||
{
|
||||
in_type = TYPE_RGB_8;
|
||||
out_type = TYPE_RGB_8;
|
||||
}
|
||||
else
|
||||
{
|
||||
in_type = TYPE_RGB_16;
|
||||
out_type = TYPE_RGB_16;
|
||||
}
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = CLRSPC_SRGB;
|
||||
}
|
||||
else if(out_space == cmsSigGrayData) /* enumCS 17 */
|
||||
{
|
||||
in_type = TYPE_GRAY_8;
|
||||
out_type = TYPE_RGB_8;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = CLRSPC_SRGB;
|
||||
}
|
||||
else if(out_space == cmsSigYCbCrData) /* enumCS 18 */
|
||||
{
|
||||
in_type = TYPE_YCbCr_16;
|
||||
out_type = TYPE_RGB_16;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = CLRSPC_SRGB;
|
||||
}
|
||||
{
|
||||
in_type = TYPE_RGB_16;
|
||||
out_type = TYPE_RGB_16;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = CLRSPC_SRGB;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(out_space == cmsSigGrayData) /* enumCS 17 */
|
||||
{
|
||||
in_type = TYPE_GRAY_8;
|
||||
out_type = TYPE_RGB_8;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = CLRSPC_SRGB;
|
||||
}
|
||||
else
|
||||
if(out_space == cmsSigYCbCrData) /* enumCS 18 */
|
||||
{
|
||||
in_type = TYPE_YCbCr_16;
|
||||
out_type = TYPE_RGB_16;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = CLRSPC_SRGB;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_PROFILE
|
||||
fprintf(stderr,"%s:%d: color_apply_icc_profile\n\tICC Profile has unknown "
|
||||
"output colorspace(%#x)(%c%c%c%c)\n\tICC Profile ignored.\n",
|
||||
__FILE__,__LINE__,out_space,
|
||||
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||
(out_space>>8) & 0xff, out_space & 0xff);
|
||||
fprintf(stderr,"%s:%d: color_apply_icc_profile\n\tICC Profile has unknown "
|
||||
"output colorspace(%#x)(%c%c%c%c)\n\tICC Profile ignored.\n",
|
||||
__FILE__,__LINE__,out_space,
|
||||
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||
(out_space>>8) & 0xff, out_space & 0xff);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PROFILE
|
||||
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tchannels(%d) prec(%d) w(%d) h(%d)"
|
||||
"\n\tprofile: in(%p) out(%p)\n",__FILE__,__LINE__,image->numcomps,prec,
|
||||
max_w,max_h, (void*)in_prof,(void*)out_prof);
|
||||
|
||||
fprintf(stderr,"\trender_intent (%u)\n\t"
|
||||
"color_space: in(%#x)(%c%c%c%c) out:(%#x)(%c%c%c%c)\n\t"
|
||||
" type: in(%u) out:(%u)\n",
|
||||
intent,
|
||||
in_space,
|
||||
(in_space>>24) & 0xff,(in_space>>16) & 0xff,
|
||||
(in_space>>8) & 0xff, in_space & 0xff,
|
||||
|
||||
out_space,
|
||||
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||
(out_space>>8) & 0xff, out_space & 0xff,
|
||||
|
||||
in_type,out_type
|
||||
);
|
||||
#else
|
||||
(void)prec;
|
||||
(void)in_space;
|
||||
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tchannels(%d) prec(%d) w(%d) h(%d)"
|
||||
"\n\tprofile: in(%p) out(%p)\n",__FILE__,__LINE__,image->numcomps,prec,
|
||||
max_w,max_h, (void*)in_prof,(void*)out_prof);
|
||||
|
||||
fprintf(stderr,"\trender_intent (%u)\n\t"
|
||||
"color_space: in(%#x)(%c%c%c%c) out:(%#x)(%c%c%c%c)\n\t"
|
||||
" type: in(%u) out:(%u)\n",
|
||||
intent,
|
||||
in_space,
|
||||
(in_space>>24) & 0xff,(in_space>>16) & 0xff,
|
||||
(in_space>>8) & 0xff, in_space & 0xff,
|
||||
|
||||
out_space,
|
||||
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||
(out_space>>8) & 0xff, out_space & 0xff,
|
||||
|
||||
in_type,out_type
|
||||
);
|
||||
#endif /* DEBUG_PROFILE */
|
||||
|
||||
transform = cmsCreateTransform(in_prof, in_type, out_prof, out_type, intent, 0);
|
||||
|
||||
|
||||
transform = cmsCreateTransform(in_prof, in_type,
|
||||
out_prof, out_type, intent, 0);
|
||||
|
||||
#ifdef HAVE_LIBLCMS2
|
||||
/* Possible for: LCMS_VERSION >= 2000 :*/
|
||||
/* Possible for: LCMS_VERSION >= 2000 :*/
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
#endif
|
||||
|
||||
|
||||
if(transform == NULL)
|
||||
{
|
||||
{
|
||||
#ifdef DEBUG_PROFILE
|
||||
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
||||
"ICC Profile ignored.\n",__FILE__,__LINE__);
|
||||
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
||||
"ICC Profile ignored.\n",__FILE__,__LINE__);
|
||||
#endif
|
||||
image->color_space = oldspace;
|
||||
image->color_space = oldspace;
|
||||
#ifdef HAVE_LIBLCMS1
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(image->numcomps > 2)/* RGB, RGBA */
|
||||
{
|
||||
if( prec <= 8 )
|
||||
{
|
||||
unsigned char *inbuf, *outbuf, *in, *out;
|
||||
max = max_w * max_h;
|
||||
nr_samples = (cmsUInt32Number)max * 3 * (cmsUInt32Number)sizeof(unsigned char);
|
||||
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned char)*r++;
|
||||
*in++ = (unsigned char)*g++;
|
||||
*in++ = (unsigned char)*b++;
|
||||
}
|
||||
|
||||
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++;
|
||||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned short *inbuf, *outbuf, *in, *out;
|
||||
max = max_w * max_h;
|
||||
nr_samples = (cmsUInt32Number)max * 3 * (cmsUInt32Number)sizeof(unsigned short);
|
||||
in = inbuf = (unsigned short*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned short*)malloc(nr_samples);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned short)*r++;
|
||||
*in++ = (unsigned short)*g++;
|
||||
*in++ = (unsigned short)*b++;
|
||||
}
|
||||
|
||||
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++;
|
||||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
}
|
||||
}
|
||||
{
|
||||
unsigned short *inbuf, *outbuf, *in, *out;
|
||||
max = max_w * max_h; nr_samples = max * 3 * sizeof(unsigned short);
|
||||
in = inbuf = (unsigned short*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned short*)malloc(nr_samples);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned short)*r++;
|
||||
*in++ = (unsigned short)*g++;
|
||||
*in++ = (unsigned short)*b++;
|
||||
}
|
||||
|
||||
cmsDoTransform(transform, inbuf, outbuf, max);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++;
|
||||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
}
|
||||
else /* GRAY, GRAYA */
|
||||
{
|
||||
unsigned char *in, *inbuf, *out, *outbuf;
|
||||
max = max_w * max_h;
|
||||
nr_samples = (cmsUInt32Number)max * 3 * sizeof(unsigned char);
|
||||
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||
|
||||
image->comps = (opj_image_comp_t*)realloc(image->comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
|
||||
|
||||
if(image->numcomps == 2)
|
||||
image->comps[3] = image->comps[1];
|
||||
|
||||
image->comps[1] = image->comps[0];
|
||||
image->comps[2] = image->comps[0];
|
||||
|
||||
image->comps[1].data = (int*)calloc((size_t)max, sizeof(int));
|
||||
image->comps[2].data = (int*)calloc((size_t)max, sizeof(int));
|
||||
|
||||
image->numcomps += 2;
|
||||
|
||||
r = image->comps[0].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned char)*r++;
|
||||
}
|
||||
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++; *g++ = (int)*out++; *b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
|
||||
}/* if(image->numcomps */
|
||||
|
||||
{
|
||||
unsigned char *in, *inbuf, *out, *outbuf;
|
||||
|
||||
max = max_w * max_h; nr_samples = max * 3 * sizeof(unsigned char);
|
||||
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||
|
||||
image->comps = (opj_image_comp_t*)
|
||||
realloc(image->comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
|
||||
|
||||
if(image->numcomps == 2)
|
||||
image->comps[3] = image->comps[1];
|
||||
|
||||
image->comps[1] = image->comps[0];
|
||||
image->comps[2] = image->comps[0];
|
||||
|
||||
image->comps[1].data = (int*)calloc(max, sizeof(int));
|
||||
image->comps[2].data = (int*)calloc(max, sizeof(int));
|
||||
|
||||
image->numcomps += 2;
|
||||
|
||||
r = image->comps[0].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned char)*r++;
|
||||
}
|
||||
cmsDoTransform(transform, inbuf, outbuf, max);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++; *g++ = (int)*out++; *b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
|
||||
}/* if(image->numcomps */
|
||||
|
||||
cmsDeleteTransform(transform);
|
||||
|
||||
|
||||
#ifdef HAVE_LIBLCMS1
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
|
||||
@@ -10,7 +10,11 @@
|
||||
* 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.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
@@ -38,10 +42,6 @@ static char sccsid[] = "@(#)opj_getopt.c 8.3 (Berkeley) 4/27/95";
|
||||
#include <string.h>
|
||||
#include "opj_getopt.h"
|
||||
|
||||
#ifdef USE_SYSTEM_GETOPT
|
||||
#error
|
||||
#endif
|
||||
|
||||
int opj_opterr = 1, /* if error message should be printed */
|
||||
opj_optind = 1, /* index into parent argv vector */
|
||||
opj_optopt, /* character checked for validity */
|
||||
|
||||
@@ -1,26 +1,5 @@
|
||||
/* last review : october 29th, 2002 */
|
||||
|
||||
#include "opj_config.h"
|
||||
|
||||
#ifdef USE_SYSTEM_GETOPT
|
||||
#include <getopt.h>
|
||||
|
||||
#define opj_opterr opterr
|
||||
#define opj_optind optind
|
||||
#define opj_optopt optopt
|
||||
#define opj_optreset optreset
|
||||
#define opj_optarg optarg
|
||||
|
||||
typedef struct option opj_option_t;
|
||||
|
||||
#define NO_ARG no_argument
|
||||
#define REQ_ARG required_argument
|
||||
#define OPT_ARG optional_argument
|
||||
|
||||
#define opj_getopt getopt
|
||||
#define opj_getopt_long getopt_long
|
||||
|
||||
#else
|
||||
#ifndef _GETOPT_H_
|
||||
#define _GETOPT_H_
|
||||
|
||||
@@ -30,7 +9,7 @@ typedef struct opj_option
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
} opj_option_t;
|
||||
}opj_option_t;
|
||||
|
||||
#define NO_ARG 0
|
||||
#define REQ_ARG 1
|
||||
@@ -48,4 +27,3 @@ extern int opj_getopt_long(int argc, char * const argv[], const char *optstring,
|
||||
extern void reset_options_reading(void);
|
||||
|
||||
#endif /* _GETOPT_H_ */
|
||||
#endif /* USE_SYSTEM_GETOPT */
|
||||
|
||||
@@ -5,14 +5,7 @@ What's New for OpenJPIP
|
||||
! : changed
|
||||
+ : added
|
||||
|
||||
Feburary 28, 2012
|
||||
+ [kaori] enabled the opj_server to reply the first query consisting with len request from kakadu client
|
||||
|
||||
February 9, 2012
|
||||
* [kaori] fixed Doxygen configuration file to document the utilities
|
||||
+ [kaori] added execution argument to set port number for opj_dec_server, opj_viewer*
|
||||
|
||||
January 26, 2012
|
||||
January 26, 2011
|
||||
! [kaori] unapplied auxtrans_manager to the local mode
|
||||
|
||||
December 24, 2011
|
||||
|
||||
@@ -2,10 +2,7 @@
|
||||
IF(BUILD_JPIP_SERVER)
|
||||
FIND_PACKAGE(CURL REQUIRED)
|
||||
FIND_PACKAGE(FCGI REQUIRED)
|
||||
FIND_PACKAGE(Threads REQUIRED)
|
||||
IF(NOT CMAKE_USE_PTHREADS_INIT)
|
||||
MESSAGE(FATAL_ERROR "Only pthread are supported")
|
||||
ENDIF(NOT CMAKE_USE_PTHREADS_INIT)
|
||||
FIND_PACKAGE(PTHREAD REQUIRED)
|
||||
ENDIF(BUILD_JPIP_SERVER)
|
||||
|
||||
# JPIP library:
|
||||
|
||||
@@ -96,7 +96,7 @@ Server:
|
||||
|
||||
Client:
|
||||
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.
|
||||
% mkdir cache
|
||||
@@ -104,12 +104,10 @@ Client:
|
||||
% ../opj_dec_server
|
||||
|
||||
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 path/filename.jp2 [stateless/session] [jptstream/jppstream] [tcp/udp]
|
||||
( The arguments
|
||||
- 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
|
||||
- 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
|
||||
@@ -133,7 +131,7 @@ An example to encode a TIF image "copenhague1.tif" at resolution 4780x4050, 8bit
|
||||
% ./image_to_j2k -i copenhague1.tif -o copenhague1.jp2 -p RPCL -c [64,64] -t 640,480 -jpip -TP R
|
||||
|
||||
options
|
||||
-jpip : embed index table 'cidx' box into the output JP2 file (obligation for JPIP)
|
||||
-jpip : embed index table box into the output JP2 file (obligation for JPIP)
|
||||
-TP R : partition a tile into tile parts of different resolution levels (obligation for JPT-stream)
|
||||
|
||||
<Option>
|
||||
|
||||
@@ -568,7 +568,7 @@ WARN_LOGFILE =
|
||||
# directories like "/usr/src/myproject". Separate the files or directories
|
||||
# with spaces.
|
||||
|
||||
INPUT = .. ../libopenjpip ../util
|
||||
INPUT = .. ../libopenjpip ../opj_server ../opj_client/opj_dec_server ../tools ../tools/indexer
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
|
||||
|
||||
@@ -4,6 +4,7 @@ INCLUDE_DIRECTORIES(
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||
${FCGI_INCLUDE_DIRS}
|
||||
${CURL_INCLUDE_DIRS}
|
||||
${PTHREAD_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# Defines the source code for the library
|
||||
@@ -62,7 +63,7 @@ INSTALL(TARGETS openjpip_local
|
||||
|
||||
IF(BUILD_JPIP_SERVER)
|
||||
ADD_LIBRARY(openjpip_server STATIC ${OPENJPIP_SRCS} ${SERVER_SRCS})
|
||||
TARGET_LINK_LIBRARIES(openjpip_server ${FCGI_LIBRARIES} ${CURL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
||||
TARGET_LINK_LIBRARIES(openjpip_server ${FCGI_LIBRARIES} ${CURL_LIBRARIES} ${PTHREAD_LIBRARIES})
|
||||
SET_TARGET_PROPERTIES(openjpip_server
|
||||
PROPERTIES COMPILE_FLAGS "-DSERVER")
|
||||
INSTALL(TARGETS openjpip_server
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER */
|
||||
#endif //SERVER
|
||||
|
||||
auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport)
|
||||
auxtrans.tcplistensock = -1;
|
||||
|
||||
auxtrans.udplistensock = -1;
|
||||
/* open listening socket for udp later */
|
||||
// open listening socket for udp later
|
||||
|
||||
return auxtrans;
|
||||
}
|
||||
@@ -78,15 +78,15 @@ void close_aux_transport( auxtrans_param_t auxtrans)
|
||||
}
|
||||
|
||||
|
||||
/*!< auxiliary response parameters */
|
||||
//!< auxiliary response parameters
|
||||
typedef struct aux_response_param{
|
||||
char *cid; /*!< channel ID */
|
||||
unsigned char *data; /*!< sending data */
|
||||
int datalen; /*!< length of data */
|
||||
int maxlenPerFrame; /*!< maximum data length to send per frame */
|
||||
SOCKET listensock; /*!< listeing socket */
|
||||
char *cid; //!< channel ID
|
||||
unsigned char *data; //!< sending data
|
||||
int datalen; //!< length of data
|
||||
int maxlenPerFrame; //!< maximum data length to send per frame
|
||||
SOCKET listensock; //!< listeing socket
|
||||
#ifdef _WIN32
|
||||
HANDLE hTh; /*!< thread handle */
|
||||
HANDLE hTh; //!< thread handle
|
||||
#endif
|
||||
} aux_response_param_t;
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ box_param_t * gene_boxbyOffinStream( Byte_t *stream, Byte8_t offset)
|
||||
}
|
||||
|
||||
|
||||
box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, const char TBox[])
|
||||
box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, char TBox[])
|
||||
{
|
||||
Byte8_t pos;
|
||||
Byte_t *data;
|
||||
@@ -221,7 +221,7 @@ box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, const char
|
||||
return NULL;
|
||||
}
|
||||
|
||||
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t length, const char TBox[])
|
||||
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t length, char TBox[])
|
||||
{
|
||||
Byte8_t pos;
|
||||
Byte_t *data;
|
||||
@@ -272,7 +272,7 @@ box_param_t * gene_childboxbyOffset( box_param_t *superbox, Byte8_t offset)
|
||||
return gene_boxbyOffset( superbox->fd, get_DBoxoff( superbox)+offset);
|
||||
}
|
||||
|
||||
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, const char TBox[])
|
||||
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, char TBox[])
|
||||
{
|
||||
return gene_boxbyType( superbox->fd, get_DBoxoff( superbox)+offset, get_DBoxlen( superbox)-offset, TBox);
|
||||
}
|
||||
@@ -317,7 +317,7 @@ Byte8_t fetch_DBox8bytebigendian( box_param_t *box, long 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;
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ box_param_t * gene_boxbyOffinStream( Byte_t *stream, Byte8_t offset);
|
||||
* @param[in] TBox Box Type
|
||||
* @return pointer to the structure of generate/found box parameters
|
||||
*/
|
||||
box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_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
|
||||
@@ -108,7 +108,7 @@ box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, const char
|
||||
* @param[in] TBox Box Type
|
||||
* @return pointer to the structure of generate/found box parameters
|
||||
*/
|
||||
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_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
|
||||
@@ -127,7 +127,7 @@ box_param_t * gene_childboxbyOffset( box_param_t *superbox, Byte8_t offset);
|
||||
* @param[in] TBox Box Type
|
||||
* @return pointer to the structure of generate/found box parameters
|
||||
*/
|
||||
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, const char TBox[]);
|
||||
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, char TBox[]);
|
||||
|
||||
/**
|
||||
* get DBox offset
|
||||
@@ -210,7 +210,7 @@ Byte8_t fetch_DBox8bytebigendian( box_param_t *box, long offset);
|
||||
* @param[in] boxlist box list 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
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
#endif //SERVER
|
||||
|
||||
|
||||
boxheader_param_t * gene_boxheader( int fd, Byte8_t offset)
|
||||
@@ -55,7 +55,7 @@ boxheader_param_t * gene_boxheader( int fd, Byte8_t offset)
|
||||
boxtype = (char *)fetch_bytes( fd, offset+4, 4);
|
||||
headlen = 8;
|
||||
|
||||
if( boxlen == 1){ /* read XLBox */
|
||||
if( boxlen == 1){ // read XLBox
|
||||
boxlen = fetch_8bytebigendian( fd, offset+8);
|
||||
headlen = 16;
|
||||
}
|
||||
|
||||
@@ -76,13 +76,13 @@ Byte_t fetch_1byte( int fd, long offset)
|
||||
|
||||
if( lseek( fd, offset, SEEK_SET)==-1){
|
||||
fprintf( FCGI_stdout, "Reason: Target broken (seek error)\r\n");
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_1byte( %d, %lld)\n", fd, offset);
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_1byte( %d, %ld)\n", fd, offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( read( fd, &code, 1) != 1){
|
||||
fprintf( FCGI_stdout, "Reason: Target broken (read error)\r\n");
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %lld)\n", fd, offset);
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld)\n", fd, offset);
|
||||
return 0;
|
||||
}
|
||||
return code;
|
||||
@@ -94,7 +94,7 @@ Byte2_t fetch_2bytebigendian( int fd, long offset)
|
||||
Byte2_t code;
|
||||
|
||||
if(!(data = fetch_bytes( fd, offset, 2))){
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_2bytebigendian( %d, %lld)\n", fd, offset);
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_2bytebigendian( %d, %ld)\n", fd, offset);
|
||||
return 0;
|
||||
}
|
||||
code = big2(data);
|
||||
@@ -109,7 +109,7 @@ Byte4_t fetch_4bytebigendian( int fd, long offset)
|
||||
Byte4_t code;
|
||||
|
||||
if(!(data = fetch_bytes( fd, offset, 4))){
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_4bytebigendian( %d, %lld)\n", fd, offset);
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_4bytebigendian( %d, %ld)\n", fd, offset);
|
||||
return 0;
|
||||
}
|
||||
code = big4(data);
|
||||
@@ -124,7 +124,7 @@ Byte8_t fetch_8bytebigendian( int fd, long offset)
|
||||
Byte8_t code;
|
||||
|
||||
if(!(data = fetch_bytes( fd, offset, 8))){
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_8bytebigendian( %d, %lld)\n", fd, offset);
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_8bytebigendian( %d, %ld)\n", fd, offset);
|
||||
return 0;
|
||||
}
|
||||
code = big8(data);
|
||||
|
||||
@@ -29,29 +29,19 @@
|
||||
*/
|
||||
|
||||
#ifndef BYTE_MANAGER_H_
|
||||
#define BYTE_MANAGER_H_
|
||||
# define BYTE_MANAGER_H_
|
||||
|
||||
#include "opj_config.h"
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
typedef uint8_t Byte_t;
|
||||
typedef uint16_t Byte2_t;
|
||||
typedef uint32_t Byte4_t;
|
||||
typedef uint64_t Byte8_t;
|
||||
#else
|
||||
#if defined(_WIN32)
|
||||
/** 1Byte parameter type*/
|
||||
typedef unsigned __int8 Byte_t;
|
||||
typedef unsigned char Byte_t;
|
||||
|
||||
/** 2Byte parameter type*/
|
||||
typedef unsigned __int16 Byte2_t;
|
||||
typedef unsigned short int Byte2_t;
|
||||
|
||||
/** 4Byte parameter type*/
|
||||
typedef unsigned __int32 Byte4_t;
|
||||
typedef unsigned int Byte4_t;
|
||||
|
||||
/** 8Byte parameter type*/
|
||||
typedef unsigned __int64 Byte8_t;
|
||||
#else
|
||||
#error unsupported platform
|
||||
#endif
|
||||
#endif
|
||||
typedef unsigned long long int Byte8_t;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,10 +40,10 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
#endif //SERVER
|
||||
|
||||
|
||||
cachemodellist_param_t * gene_cachemodellist(void)
|
||||
cachemodellist_param_t * gene_cachemodellist()
|
||||
{
|
||||
cachemodellist_param_t *cachemodellist;
|
||||
|
||||
@@ -73,7 +73,7 @@ cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, ta
|
||||
cachemodel->jppstream = true;
|
||||
else
|
||||
cachemodel->jppstream = false;
|
||||
} else{ /* reqJPT */
|
||||
} else{ // reqJPT
|
||||
if( target->jptstream)
|
||||
cachemodel->jppstream = false;
|
||||
else
|
||||
@@ -95,9 +95,9 @@ cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, ta
|
||||
cachemodel->next = NULL;
|
||||
|
||||
if( cachemodellist){
|
||||
if( cachemodellist->first) /* there are one or more entries */
|
||||
if( cachemodellist->first) // there are one or more entries
|
||||
cachemodellist->last->next = cachemodel;
|
||||
else /* first entry */
|
||||
else // first entry
|
||||
cachemodellist->first = cachemodel;
|
||||
cachemodellist->last = cachemodel;
|
||||
}
|
||||
@@ -112,10 +112,9 @@ cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, ta
|
||||
void print_cachemodel( cachemodel_param_t cachemodel)
|
||||
{
|
||||
target_param_t *target;
|
||||
Byte8_t TPnum; /* num of tile parts in each tile */
|
||||
Byte8_t Pmax; /* max num of packets per tile */
|
||||
Byte8_t i, j, k;
|
||||
int n; /* FIXME: Is this large enough ? */
|
||||
Byte8_t TPnum; // num of tile parts in each tile
|
||||
Byte8_t Pmax; // max num of packets per tile
|
||||
int i, j, k, n;
|
||||
|
||||
target = cachemodel.target;
|
||||
|
||||
@@ -136,9 +135,9 @@ void print_cachemodel( cachemodel_param_t cachemodel)
|
||||
|
||||
fprintf( logstream, "\t tile header and precinct packet model:\n");
|
||||
for( i=0; i<target->codeidx->SIZ.XTnum*target->codeidx->SIZ.YTnum; i++){
|
||||
fprintf( logstream, "\t tile.%llud %d\n", i, cachemodel.th_model[i]);
|
||||
fprintf( logstream, "\t tile.%d %d\n", i, cachemodel.th_model[i]);
|
||||
for( j=0; j<target->codeidx->SIZ.Csiz; j++){
|
||||
fprintf( logstream, "\t compo.%llud: ", j);
|
||||
fprintf( logstream, "\t compo.%d: ", j);
|
||||
Pmax = get_nmax( target->codeidx->precpacket[j]);
|
||||
for( k=0; k<Pmax; k++)
|
||||
fprintf( logstream, "%d", cachemodel.pp_model[j][i*Pmax+k]);
|
||||
@@ -198,10 +197,9 @@ void delete_cachemodel( cachemodel_param_t **cachemodel)
|
||||
bool is_allsent( cachemodel_param_t cachemodel)
|
||||
{
|
||||
target_param_t *target;
|
||||
Byte8_t TPnum; /* num of tile parts in each tile */
|
||||
Byte8_t Pmax; /* max num of packets per tile */
|
||||
Byte8_t i, j, k;
|
||||
int n; /* FIXME: is this large enough ? */
|
||||
Byte8_t TPnum; // num of tile parts in each tile
|
||||
Byte8_t Pmax; // max num of packets per tile
|
||||
int i, j, k, n;
|
||||
|
||||
target = cachemodel.target;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ typedef struct cachemodellist_param{
|
||||
*
|
||||
* @return pointer to the generated cache model list
|
||||
*/
|
||||
cachemodellist_param_t * gene_cachemodellist(void);
|
||||
cachemodellist_param_t * gene_cachemodellist();
|
||||
|
||||
/**
|
||||
* generate a cache model under a list
|
||||
|
||||
@@ -32,9 +32,6 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "channel_manager.h"
|
||||
#ifdef _WIN32
|
||||
#define snprintf _snprintf /* Visual Studio */
|
||||
#endif
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
@@ -43,9 +40,9 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER */
|
||||
#endif //SERVER
|
||||
|
||||
channellist_param_t * gene_channellist(void)
|
||||
channellist_param_t * gene_channellist()
|
||||
{
|
||||
channellist_param_t *channellist;
|
||||
|
||||
@@ -71,12 +68,12 @@ channel_param_t * gene_channel( query_param_t query_param, auxtrans_param_t auxt
|
||||
channel = (channel_param_t *)malloc( sizeof(channel_param_t));
|
||||
channel->cachemodel = cachemodel;
|
||||
|
||||
/* set channel ID and get present time */
|
||||
// set channel ID and get present time
|
||||
snprintf( channel->cid, MAX_LENOFCID, "%x%x", (unsigned int)time( &channel->start_tm), (unsigned int)rand());
|
||||
|
||||
channel->aux = query_param.cnew;
|
||||
|
||||
/* only tcp implemented for now */
|
||||
// only tcp implemented for now
|
||||
if( channel->aux == udp)
|
||||
channel->aux = tcp;
|
||||
|
||||
@@ -104,9 +101,7 @@ channel_param_t * gene_channel( query_param_t query_param, auxtrans_param_t auxt
|
||||
|
||||
void set_channel_variable_param( query_param_t query_param, channel_param_t *channel)
|
||||
{
|
||||
/* set roi information */
|
||||
(void)query_param;
|
||||
(void)channel;
|
||||
// set roi information
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ typedef struct channellist_param{
|
||||
*
|
||||
* @return pointer to the generated channel list
|
||||
*/
|
||||
channellist_param_t * gene_channellist(void);
|
||||
channellist_param_t * gene_channellist();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER */
|
||||
#endif //SERVER
|
||||
|
||||
codestream_param_t set_codestream( int fd, Byte8_t offset, Byte8_t length)
|
||||
{
|
||||
|
||||
29
applications/jpip/libopenjpip/comMakefile.mk
Normal file
29
applications/jpip/libopenjpip/comMakefile.mk
Normal file
@@ -0,0 +1,29 @@
|
||||
ifdef jpipserver
|
||||
CFLAGS = -O3 -Wall -m32 -DSERVER
|
||||
LIBNAME = libopenjpip_server.a
|
||||
else
|
||||
J2KINCDIR = ../../../libopenjpeg
|
||||
CFLAGS = -O3 -Wall -I$(J2KINCDIR)
|
||||
LIBNAME = libopenjpip_local.a
|
||||
endif
|
||||
|
||||
all: $(LIBNAME)
|
||||
|
||||
ifdef jpipserver
|
||||
$(LIBNAME): openjpip.o target_manager.o byte_manager.o box_manager.o boxheader_manager.o manfbox_manager.o \
|
||||
mhixbox_manager.o marker_manager.o codestream_manager.o faixbox_manager.o index_manager.o \
|
||||
msgqueue_manager.o metadata_manager.o placeholder_manager.o ihdrbox_manager.o imgreg_manager.o \
|
||||
cachemodel_manager.o j2kheader_manager.o jp2k_encoder.o query_parser.o channel_manager.o \
|
||||
session_manager.o jpip_parser.o sock_manager.o auxtrans_manager.o
|
||||
ar r $@ $^
|
||||
else
|
||||
$(LIBNAME): openjpip.o target_manager.o byte_manager.o box_manager.o boxheader_manager.o manfbox_manager.o \
|
||||
mhixbox_manager.o marker_manager.o codestream_manager.o faixbox_manager.o index_manager.o \
|
||||
msgqueue_manager.o metadata_manager.o placeholder_manager.o ihdrbox_manager.o imgreg_manager.o \
|
||||
cachemodel_manager.o j2kheader_manager.o jp2k_encoder.o query_parser.o channel_manager.o \
|
||||
session_manager.o jpip_parser.o jp2k_decoder.o imgsock_manager.o jpipstream_manager.o cache_manager.o \
|
||||
dec_clientmsg_handler.o sock_manager.o
|
||||
ar r $@ $^
|
||||
endif
|
||||
clean:
|
||||
rm -f $(LIBNAME) *.o *~
|
||||
@@ -40,7 +40,7 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
#endif //SERVER
|
||||
|
||||
imgreg_param_t map_viewin2imgreg( const int fx, const int fy,
|
||||
const int rx, const int ry,
|
||||
@@ -106,13 +106,13 @@ void find_level( int maxlev, int *lev, int *fx, int *fy, int *xmin, int *ymin, i
|
||||
int xwidth = *xmax - *xmin;
|
||||
int ywidth = *ymax - *ymin;
|
||||
|
||||
/* Find smaller frame size for now (i.e. assume "round-down"). */
|
||||
/// Find smaller frame size for now (i.e. assume "round-down").
|
||||
if ((*fx < 1 && xwidth != 0) || (*fy < 1 && ywidth != 0)){
|
||||
fprintf( FCGI_stderr, "Frame size must be strictly positive");
|
||||
exit(-1);
|
||||
}
|
||||
else if( *lev < maxlev-1 && ( *fx < xwidth || *fy < ywidth)) {
|
||||
/* Simulate the ceil function. */
|
||||
// Simulate the ceil function.
|
||||
*xmin = ceil((double)*xmin/(double)2.0);
|
||||
*ymin = ceil((double)*ymin/(double)2.0);
|
||||
*xmax = ceil((double)*xmax/(double)2.0);
|
||||
@@ -149,7 +149,5 @@ void print_imgreg( imgreg_param_t imgreg)
|
||||
fprintf( logstream, "\t roff: %d, %d\n", imgreg.ox, imgreg.oy);
|
||||
fprintf( logstream, "\t rsiz: %d, %d\n", imgreg.sx, imgreg.sy);
|
||||
fprintf( logstream, "\t level: %d\n", imgreg.level);
|
||||
#else
|
||||
(void)imgreg;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -31,14 +31,14 @@
|
||||
#ifndef IMGREG_MANAGER_H_
|
||||
# define IMGREG_MANAGER_H_
|
||||
|
||||
/** image region parameters */
|
||||
//! image region parameters
|
||||
typedef struct imgreg_param{
|
||||
int xosiz, yosiz; /** offset from the origin of the reference grid
|
||||
at the decomposition level */
|
||||
int fx, fy; /** frame size (fsiz) */
|
||||
int ox, oy; /** offset (roff) */
|
||||
int sx, sy; /** region size (rsiz) */
|
||||
int level; /** decomposition level */
|
||||
int xosiz, yosiz; //!< offset from the origin of the reference grid
|
||||
//!at the decomposition level
|
||||
int fx, fy; //!< frame size (fsiz)
|
||||
int ox, oy; //!< offset (roff)
|
||||
int sx, sy; //!< region size (rsiz)
|
||||
int level; //!< decomposition level
|
||||
} imgreg_param_t;
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER */
|
||||
#endif //SERVER
|
||||
|
||||
|
||||
SIZmarker_param_t get_SIZmkrdata_from_j2kstream( Byte_t *SIZstream);
|
||||
@@ -76,7 +76,7 @@ bool get_mainheader_from_j2kstream( Byte_t *j2kstream, SIZmarker_param_t *SIZ, C
|
||||
|
||||
SIZmarker_param_t get_SIZmkrdata_from_j2kstream( Byte_t *SIZstream)
|
||||
{
|
||||
SIZmarker_param_t SIZ = {0};
|
||||
SIZmarker_param_t SIZ ={0};
|
||||
int i;
|
||||
|
||||
if( *SIZstream++ != 0xff || *SIZstream++ != 0x51){
|
||||
@@ -115,13 +115,6 @@ CODmarker_param_t get_CODmkrdata_from_j2kstream( Byte_t *CODstream)
|
||||
|
||||
if( *CODstream++ != 0xff || *CODstream++ != 0x52){
|
||||
fprintf( FCGI_stderr, "Error, COD marker not found in the reconstructed j2kstream\n");
|
||||
COD.Lcod = 0;
|
||||
COD.Scod = 0;
|
||||
COD.prog_order = 0;
|
||||
COD.numOflayers = 0;
|
||||
COD.numOfdecomp = 0;
|
||||
COD.XPsiz = 0;
|
||||
COD.YPsiz = 0;
|
||||
return COD;
|
||||
}
|
||||
|
||||
@@ -136,7 +129,7 @@ CODmarker_param_t get_CODmkrdata_from_j2kstream( Byte_t *CODstream)
|
||||
COD.YPsiz = (Byte4_t *)malloc( (COD.numOfdecomp+1)*sizeof(Byte4_t));
|
||||
|
||||
for( i=0; i<=COD.numOfdecomp; i++){
|
||||
/*precinct size */
|
||||
//precinct size
|
||||
COD.XPsiz[i] = pow( 2, *( CODstream+12+i) & 0x0F);
|
||||
COD.YPsiz[i] = pow( 2, (*( CODstream+12+i) & 0xF0) >> 4);
|
||||
}
|
||||
@@ -195,7 +188,7 @@ bool modify_SIZmkrstream( SIZmarker_param_t SIZ, int difOfdecomplev, Byte_t *SIZ
|
||||
SIZ.YTOsiz = ceil( (double)SIZ.YTOsiz/2.0);
|
||||
}
|
||||
|
||||
SIZstream += 4; /* skip Lsiz + Rsiz */
|
||||
SIZstream += 4; // skip Lsiz + Rsiz
|
||||
|
||||
modify_4Bytecode( SIZ.Xsiz, SIZstream);
|
||||
modify_4Bytecode( SIZ.Ysiz, SIZstream+4);
|
||||
@@ -229,9 +222,9 @@ Byte2_t modify_CODmkrstream( CODmarker_param_t COD, int numOfdecomp, Byte_t *COD
|
||||
CODstream += 2;
|
||||
}
|
||||
|
||||
CODstream += 5; /* skip Scod & SGcod */
|
||||
CODstream += 5; // skip Scod & SGcod
|
||||
|
||||
/* SPcod */
|
||||
// SPcod
|
||||
*CODstream++ = (Byte_t) numOfdecomp;
|
||||
|
||||
return newLcod;
|
||||
@@ -241,7 +234,7 @@ bool modify_COCmkrstream( int numOfdecomp, Byte_t *COCstream, Byte2_t Csiz, Byte
|
||||
|
||||
bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, Byte2_t Csiz, Byte8_t *j2klen)
|
||||
{
|
||||
Byte4_t Psot; /* tile part length ref A.4.2 Start of tile-part SOT */
|
||||
Byte4_t Psot; // tile part length ref A.4.2 Start of tile-part SOT
|
||||
Byte_t *thstream, *SOTstream, *Psot_stream;
|
||||
Byte2_t oldLcoc, newLcoc;
|
||||
|
||||
@@ -252,14 +245,14 @@ bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, B
|
||||
return false;
|
||||
}
|
||||
|
||||
SOTstream += 4; /* skip Lsot & Isot */
|
||||
SOTstream += 4; // skip Lsot & Isot
|
||||
Psot = (SOTstream[0]<<24)+(SOTstream[1]<<16)+(SOTstream[2]<<8)+(SOTstream[3]);
|
||||
Psot_stream = SOTstream;
|
||||
|
||||
thstream += 12; /* move to next marker (SOT always 12bytes) */
|
||||
thstream += 12; // move to next marker (SOT always 12bytes)
|
||||
|
||||
while( !( *thstream == 0xff && *(thstream+1) == 0x93)){ /* search SOD */
|
||||
if( numOfdecomp != -1 && *thstream == 0xff && *(thstream+1) == 0x53){ /* COC */
|
||||
while( !( *thstream == 0xff && *(thstream+1) == 0x93)){ // search SOD
|
||||
if( numOfdecomp != -1 && *thstream == 0xff && *(thstream+1) == 0x53){ // COC
|
||||
if( !modify_COCmkrstream( numOfdecomp, thstream, Csiz, &oldLcoc, &newLcoc))
|
||||
return false;
|
||||
|
||||
@@ -267,7 +260,7 @@ bool modify_tileheader( Byte_t *j2kstream, Byte8_t SOToffset, int numOfdecomp, B
|
||||
*j2klen -= ( oldLcoc - newLcoc);
|
||||
}
|
||||
thstream += 2;
|
||||
thstream += ((thstream[0]<<8)+(thstream[1])); /* marker length */
|
||||
thstream += ((thstream[0]<<8)+(thstream[1])); // marker length
|
||||
}
|
||||
|
||||
if( (*j2klen)-SOToffset != Psot){
|
||||
@@ -289,7 +282,7 @@ bool modify_COCmkrstream( int numOfdecomp, Byte_t *COCstream, Byte2_t Csiz, Byte
|
||||
*COCstream++ = (Byte_t)((Byte2_t)((*newLcoc) & 0xff00) >> 8);
|
||||
*COCstream++ = (Byte_t)((*newLcoc) & 0x00ff);
|
||||
|
||||
if( Csiz < 257) COCstream +=2; /* skip Ccoc & Scoc */
|
||||
if( Csiz < 257) COCstream +=2; // skip Ccoc & Scoc
|
||||
else COCstream += 3;
|
||||
|
||||
*COCstream = numOfdecomp;
|
||||
|
||||
@@ -125,8 +125,7 @@ void warning_callback(const char *msg, void *client_data) {
|
||||
*/
|
||||
void info_callback(const char *msg, void *client_data) {
|
||||
(void)client_data;
|
||||
(void)msg;
|
||||
/* fprintf(stdout, "[INFO] %s", msg); */
|
||||
// fprintf(stdout, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -191,7 +190,7 @@ Byte_t * imagetopnm(opj_image_t *image, ihdrbox_param_t **ihdrbox)
|
||||
r = image->comps[0].data[i];
|
||||
r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
||||
|
||||
/* if( adjustR > 0) */
|
||||
// if( adjustR > 0)
|
||||
*(ptr++) = (Byte_t) ((r >> adjustR)+((r >> (adjustR-1))%2));
|
||||
|
||||
if( image->numcomps == 3){
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
#endif //SERVER
|
||||
|
||||
|
||||
/**
|
||||
@@ -105,11 +105,11 @@ Byte_t * recons_jp2( msgqueue_param_t *msgqueue, Byte_t *jpipstream, Byte8_t csn
|
||||
if( ptr->phld){
|
||||
if( strncmp( (char *)ptr->phld->OrigBH+4, "jp2c", 4) == 0){
|
||||
jp2cDBoxOffset = *jp2len + ptr->phld->OrigBHlen;
|
||||
jp2stream = add_emptyboxstream( ptr->phld, jp2stream, jp2len); /* header only */
|
||||
jp2stream = add_emptyboxstream( ptr->phld, jp2stream, jp2len); // header only
|
||||
jp2cDBoxlen = *jp2len - jp2cDBoxOffset;
|
||||
}
|
||||
else
|
||||
jp2stream = add_emptyboxstream( ptr->phld, jp2stream, jp2len); /* header only */
|
||||
jp2stream = add_emptyboxstream( ptr->phld, jp2stream, jp2len); // header only
|
||||
}
|
||||
jp2stream = add_msgstream( ptr, jpipstream, jp2stream, jp2len);
|
||||
ptr = ptr->next;
|
||||
@@ -203,7 +203,7 @@ Byte_t * recons_codestream_from_JPTstream( msgqueue_param_t *msgqueue, Byte_t *j
|
||||
}
|
||||
ptr = msgqueue->first;
|
||||
while(( ptr = search_message( EXT_TILE_MSG, tileID, csn, ptr))!=NULL){
|
||||
if( ptr->aux > mindeclev){ /* FIXME: pointer comparison ? */
|
||||
if( ptr->aux > mindeclev){
|
||||
if( ptr->bin_offset == binOffset){
|
||||
found = true;
|
||||
j2kstream = add_msgstream( ptr, jpipstream, j2kstream, j2klen);
|
||||
@@ -625,7 +625,7 @@ Byte8_t get_last_tileID( msgqueue_param_t *msgqueue, Byte8_t csn, bool isJPPstre
|
||||
message_param_t * search_message( Byte8_t class_id, Byte8_t in_class_id, Byte8_t csn, message_param_t *msg)
|
||||
{
|
||||
while( msg != NULL){
|
||||
if( in_class_id == (Byte8_t)-1){
|
||||
if( in_class_id == -1){
|
||||
if( msg->class_id == class_id && msg->csn == csn)
|
||||
return msg;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
#endif //SERVER
|
||||
|
||||
|
||||
bool identify_target( query_param_t query_param, targetlist_param_t *targetlist, target_param_t **target)
|
||||
@@ -132,35 +132,35 @@ bool close_channel( query_param_t query_param,
|
||||
#ifndef SERVER
|
||||
fprintf( logstream, "local log: close all\n");
|
||||
#endif
|
||||
/* all channels associatd with the session will be closed */
|
||||
// all channels associatd with the session will be closed
|
||||
if( !delete_session( cursession, sessionlist))
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
/* check if all entry belonging to the same session */
|
||||
// check if all entry belonging to the same session
|
||||
|
||||
for( i=0, cclose=query_param.cclose; i<query_param.numOfcclose; i++, cclose += (strlen(cclose)+1)){
|
||||
|
||||
/* In case of the first entry of close cid */
|
||||
// In case of the first entry of close cid
|
||||
if( *cursession == NULL){
|
||||
if( !search_session_and_channel( cclose, sessionlist, cursession, curchannel))
|
||||
return false;
|
||||
}
|
||||
else /* second or more entry of close cid */
|
||||
else // second or more entry of close cid
|
||||
if( !(*curchannel=search_channel( cclose, (*cursession)->channellist))){
|
||||
fprintf( FCGI_stdout, "Reason: Cclose id %s is from another session\r\n", cclose);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* delete channels */
|
||||
// delete channels
|
||||
for( i=0, cclose=query_param.cclose; i<query_param.numOfcclose; i++, cclose += (strlen(cclose)+1)){
|
||||
*curchannel = search_channel( cclose, (*cursession)->channellist);
|
||||
delete_channel( curchannel, (*cursession)->channellist);
|
||||
}
|
||||
|
||||
if( (*cursession)->channellist->first == NULL || (*cursession)->channellist->last == NULL)
|
||||
/* In case of empty session */
|
||||
// In case of empty session
|
||||
delete_session( cursession, sessionlist);
|
||||
}
|
||||
return true;
|
||||
@@ -181,9 +181,8 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue);
|
||||
* @param[in] query_param structured query
|
||||
* @param[in] metadatalist pointer to metadata bin list
|
||||
* @param[in,out] msgqueue message queue pointer
|
||||
* @return if succeeded (true) or failed (false)
|
||||
*/
|
||||
bool enqueue_metabins( query_param_t query_param, metadatalist_param_t *metadatalist, msgqueue_param_t *msgqueue);
|
||||
void enqueue_metabins( query_param_t query_param, metadatalist_param_t *metadatalist, msgqueue_param_t *msgqueue);
|
||||
|
||||
|
||||
bool gene_JPIPstream( query_param_t query_param,
|
||||
@@ -195,14 +194,14 @@ bool gene_JPIPstream( query_param_t query_param,
|
||||
index_param_t *codeidx;
|
||||
cachemodel_param_t *cachemodel;
|
||||
|
||||
if( !cursession || !curchannel){ /* stateless */
|
||||
if( !cursession || !curchannel){ // stateless
|
||||
if( !target)
|
||||
return false;
|
||||
if( !(cachemodel = gene_cachemodel( NULL, target, query_param.return_type==JPPstream)))
|
||||
return false;
|
||||
*msgqueue = gene_msgqueue( true, cachemodel);
|
||||
}
|
||||
else{ /* session */
|
||||
else{ // session
|
||||
cachemodel = curchannel->cachemodel;
|
||||
target = cachemodel->target;
|
||||
*msgqueue = gene_msgqueue( false, cachemodel);
|
||||
@@ -222,22 +221,16 @@ bool gene_JPIPstream( query_param_t query_param,
|
||||
}
|
||||
}
|
||||
|
||||
/*meta*/
|
||||
//meta
|
||||
if( query_param.box_type[0][0] != 0 && query_param.len != 0)
|
||||
if( !enqueue_metabins( query_param, codeidx->metadatalist, *msgqueue))
|
||||
return false;
|
||||
|
||||
if( query_param.metadata_only)
|
||||
return true;
|
||||
enqueue_metabins( query_param, codeidx->metadatalist, *msgqueue);
|
||||
|
||||
/* main header */
|
||||
if( !cachemodel->mhead_model && query_param.len != 0)
|
||||
// image codestream
|
||||
if( query_param.fx > 0 && query_param.fy > 0){
|
||||
if( !cachemodel->mhead_model && query_param.len != 0)
|
||||
enqueue_mainheader( *msgqueue);
|
||||
|
||||
/* image codestream */
|
||||
if( (query_param.fx > 0 && query_param.fy > 0))
|
||||
enqueue_imagedata( query_param, *msgqueue);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -277,13 +270,13 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue)
|
||||
index_param_t *codeidx;
|
||||
imgreg_param_t imgreg;
|
||||
range_param_t tile_Xrange, tile_Yrange;
|
||||
Byte4_t u, v, tile_id;
|
||||
int u, v, tile_id;
|
||||
int xmin, xmax, ymin, ymax;
|
||||
int numOfreslev;
|
||||
|
||||
codeidx = msgqueue->cachemodel->target->codeidx;
|
||||
|
||||
if( !(msgqueue->cachemodel->jppstream) && get_nmax( codeidx->tilepart) == 1) /* normally not the case */
|
||||
if( !(msgqueue->cachemodel->jppstream) && get_nmax( codeidx->tilepart) == 1) // normally not the case
|
||||
numOfreslev = 1;
|
||||
else
|
||||
numOfreslev = codeidx->COD.numOfdecomp+1;
|
||||
@@ -303,20 +296,20 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue)
|
||||
tile_Xrange = get_tile_Xrange( codeidx->SIZ, tile_id, imgreg.level);
|
||||
|
||||
if( tile_Xrange.minvalue < tile_Xrange.maxvalue && tile_Yrange.minvalue < tile_Yrange.maxvalue){
|
||||
if( tile_Xrange.maxvalue <= (Byte4_t)(imgreg.xosiz + imgreg.ox) ||
|
||||
tile_Xrange.minvalue >= (Byte4_t)(imgreg.xosiz + imgreg.ox + imgreg.sx) ||
|
||||
tile_Yrange.maxvalue <= (Byte4_t)(imgreg.yosiz + imgreg.oy) ||
|
||||
tile_Yrange.minvalue >= (Byte4_t)(imgreg.yosiz + imgreg.oy + imgreg.sy)) {
|
||||
/*printf("Tile completely excluded from view-window %d\n", tile_id);*/
|
||||
/* Tile completely excluded from view-window */
|
||||
if( tile_Xrange.maxvalue <= imgreg.xosiz + imgreg.ox ||
|
||||
tile_Xrange.minvalue >= imgreg.xosiz + imgreg.ox + imgreg.sx ||
|
||||
tile_Yrange.maxvalue <= imgreg.yosiz + imgreg.oy ||
|
||||
tile_Yrange.minvalue >= imgreg.yosiz + imgreg.oy + imgreg.sy) {
|
||||
//printf("Tile completely excluded from view-window %d\n", tile_id);
|
||||
// Tile completely excluded from view-window
|
||||
}
|
||||
else if( tile_Xrange.minvalue >= (Byte4_t)(imgreg.xosiz + imgreg.ox) &&
|
||||
tile_Xrange.maxvalue <= (Byte4_t)(imgreg.xosiz + imgreg.ox + imgreg.sx) &&
|
||||
tile_Yrange.minvalue >= (Byte4_t)(imgreg.yosiz + imgreg.oy) &&
|
||||
tile_Yrange.maxvalue <= (Byte4_t)(imgreg.yosiz + imgreg.oy + imgreg.sy)) {
|
||||
/* Tile completely contained within view-window */
|
||||
/* high priority */
|
||||
/*printf("Tile completely contained within view-window %d\n", tile_id);*/
|
||||
else if( tile_Xrange.minvalue >= imgreg.xosiz + imgreg.ox &&
|
||||
tile_Xrange.maxvalue <= imgreg.xosiz + imgreg.ox + imgreg.sx &&
|
||||
tile_Yrange.minvalue >= imgreg.yosiz + imgreg.oy &&
|
||||
tile_Yrange.maxvalue <= imgreg.yosiz + imgreg.oy + imgreg.sy) {
|
||||
// Tile completely contained within view-window
|
||||
// high priority
|
||||
//printf("Tile completely contained within view-window %d\n", tile_id);
|
||||
if( msgqueue->cachemodel->jppstream){
|
||||
enqueue_tileheader( tile_id, msgqueue);
|
||||
enqueue_allprecincts( tile_id, imgreg.level, query_param.lastcomp, query_param.comps, query_param.layers, msgqueue);
|
||||
@@ -325,17 +318,16 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue)
|
||||
enqueue_tile( tile_id, imgreg.level, msgqueue);
|
||||
}
|
||||
else{
|
||||
/* Tile partially overlaps view-window */
|
||||
/* low priority */
|
||||
/*printf("Tile partially overlaps view-window %d\n", tile_id);*/
|
||||
// Tile partially overlaps view-window
|
||||
// low priority
|
||||
//printf("Tile partially overlaps view-window %d\n", tile_id);
|
||||
if( msgqueue->cachemodel->jppstream){
|
||||
enqueue_tileheader( tile_id, msgqueue);
|
||||
|
||||
/* FIXME: The following code is suspicious it implicitely cast an unsigned int to int, which truncates values */
|
||||
xmin = tile_Xrange.minvalue >= (Byte4_t)(imgreg.xosiz + imgreg.ox) ? 0 : imgreg.xosiz + imgreg.ox - tile_Xrange.minvalue;
|
||||
xmax = tile_Xrange.maxvalue <= (Byte4_t)(imgreg.xosiz + imgreg.ox + imgreg.sx) ? tile_Xrange.maxvalue - tile_Xrange.minvalue -1 : imgreg.xosiz + imgreg.ox + imgreg.sx - tile_Xrange.minvalue -1;
|
||||
ymin = tile_Yrange.minvalue >= (Byte4_t)(imgreg.yosiz + imgreg.oy) ? 0 : imgreg.yosiz + imgreg.oy - tile_Yrange.minvalue;
|
||||
ymax = tile_Yrange.maxvalue <= (Byte4_t)(imgreg.yosiz + imgreg.oy + imgreg.sy) ? tile_Yrange.maxvalue - tile_Yrange.minvalue -1 : imgreg.yosiz + imgreg.oy + imgreg.sy - tile_Yrange.minvalue -1;
|
||||
xmin = tile_Xrange.minvalue >= imgreg.xosiz + imgreg.ox ? 0 : imgreg.xosiz + imgreg.ox - tile_Xrange.minvalue;
|
||||
xmax = tile_Xrange.maxvalue <= imgreg.xosiz + imgreg.ox + imgreg.sx ? tile_Xrange.maxvalue - tile_Xrange.minvalue -1 : imgreg.xosiz + imgreg.ox + imgreg.sx - tile_Xrange.minvalue -1;
|
||||
ymin = tile_Yrange.minvalue >= imgreg.yosiz + imgreg.oy ? 0 : imgreg.yosiz + imgreg.oy - tile_Yrange.minvalue;
|
||||
ymax = tile_Yrange.maxvalue <= imgreg.yosiz + imgreg.oy + imgreg.sy ? tile_Yrange.maxvalue - tile_Yrange.minvalue -1 : imgreg.yosiz + imgreg.oy + imgreg.sy - tile_Yrange.minvalue -1;
|
||||
enqueue_precincts( xmin, xmax, ymin, ymax, tile_id, imgreg.level, query_param.lastcomp, query_param.comps, query_param.layers, msgqueue);
|
||||
}
|
||||
else
|
||||
@@ -347,7 +339,6 @@ void enqueue_imagedata( query_param_t query_param, msgqueue_param_t *msgqueue)
|
||||
}
|
||||
|
||||
|
||||
/* MM: shouldnt xmin/xmax be Byte4_t instead ? */
|
||||
void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int level, int lastcomp, bool *comps, int layers, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
index_param_t *codeidx;
|
||||
@@ -383,16 +374,16 @@ void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int
|
||||
xmaxP = XTsiz-1;
|
||||
|
||||
if( xmaxP < xmin || xminP > xmax || ymaxP < ymin || yminP > ymax){
|
||||
/* Precinct completely excluded from view-window */
|
||||
// Precinct completely excluded from view-window
|
||||
}
|
||||
else if( xminP >= xmin && xmaxP <= xmax && yminP >= ymin && ymaxP <= ymax){
|
||||
/* Precinct completely contained within view-window
|
||||
high priority */
|
||||
// Precinct completely contained within view-window
|
||||
// high priority
|
||||
enqueue_precinct( seq_id, tile_id, c, (dec_lev>level)?-1:layers, msgqueue);
|
||||
}
|
||||
else{
|
||||
/* Precinct partially overlaps view-window
|
||||
low priority */
|
||||
// Precinct partially overlaps view-window
|
||||
// low priority
|
||||
enqueue_precinct( seq_id, tile_id, c, (dec_lev>level)?-1:layers, msgqueue);
|
||||
}
|
||||
}
|
||||
@@ -428,26 +419,18 @@ void enqueue_allprecincts( int tile_id, int level, int lastcomp, bool *comps, in
|
||||
}
|
||||
}
|
||||
|
||||
bool enqueue_metabins( query_param_t query_param, metadatalist_param_t *metadatalist, msgqueue_param_t *msgqueue)
|
||||
void enqueue_metabins( query_param_t query_param, metadatalist_param_t *metadatalist, msgqueue_param_t *msgqueue)
|
||||
{
|
||||
int i;
|
||||
for( i=0; query_param.box_type[i][0]!=0 && i<MAX_NUMOFBOX; i++){
|
||||
if( query_param.box_type[i][0] == '*'){
|
||||
fprintf( FCGI_stdout, "Status: 501\r\n");
|
||||
fprintf( FCGI_stdout, "Reason: metareq with all box-property * not implemented\r\n");
|
||||
return false;
|
||||
// not implemented
|
||||
}
|
||||
else{
|
||||
int idx = search_metadataidx( query_param.box_type[i], metadatalist);
|
||||
|
||||
if( idx != -1)
|
||||
enqueue_metadata( idx, msgqueue);
|
||||
else{
|
||||
fprintf( FCGI_stdout, "Status: 400\r\n");
|
||||
fprintf( FCGI_stdout, "Reason: box-type %.4s not found\r\n", query_param.box_type[i]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ Byte_t * update_JPIPstream( Byte_t *newstream, int newstreamlen, Byte_t *cache_s
|
||||
return stream;
|
||||
}
|
||||
|
||||
void save_codestream( Byte_t *codestream, Byte8_t streamlen, const char *fmt)
|
||||
void save_codestream( Byte_t *codestream, Byte8_t streamlen, char *fmt)
|
||||
{
|
||||
time_t timer;
|
||||
struct tm *t_st;
|
||||
@@ -74,7 +74,7 @@ void save_codestream( Byte_t *codestream, Byte8_t streamlen, const char *fmt)
|
||||
Byte_t * jpipstream_to_pnm( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte8_t csn, int fw, int fh, ihdrbox_param_t **ihdrbox)
|
||||
{
|
||||
Byte_t *pnmstream;
|
||||
Byte_t *j2kstream; /* j2k or jp2 codestream */
|
||||
Byte_t *j2kstream; // j2k or jp2 codestream
|
||||
Byte8_t j2klen;
|
||||
|
||||
j2kstream = recons_j2k( msgqueue, jpipstream, csn, fw, fh, &j2klen);
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
Byte_t * update_JPIPstream( Byte_t *newstream, int newstreamlen, Byte_t *cache_stream, int *streamlen);
|
||||
|
||||
void save_codestream( Byte_t *codestream, Byte8_t streamlen, const char *fmt);
|
||||
void save_codestream( Byte_t *codestream, Byte8_t streamlen, char *fmt);
|
||||
|
||||
Byte_t * jpipstream_to_pnm( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte8_t csn, int fw, int fh, ihdrbox_param_t **ihdrbox);
|
||||
|
||||
|
||||
@@ -40,14 +40,14 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER */
|
||||
#endif //SERVER
|
||||
|
||||
manfbox_param_t * gene_manfbox( box_param_t *box)
|
||||
{
|
||||
manfbox_param_t *manf; /* manifest parameters */
|
||||
boxheader_param_t *bh; /* current box pointer */
|
||||
boxheader_param_t *last; /* last boxheader pointer of the list */
|
||||
Byte8_t pos; /* current position in manf_box contents; */
|
||||
manfbox_param_t *manf; // manifest parameters
|
||||
boxheader_param_t *bh; // current box pointer
|
||||
boxheader_param_t *last; // last boxheader pointer of the list
|
||||
int pos; // current position in manf_box contents;
|
||||
|
||||
manf = ( manfbox_param_t *)malloc( sizeof( manfbox_param_t));
|
||||
|
||||
@@ -59,7 +59,7 @@ manfbox_param_t * gene_manfbox( box_param_t *box)
|
||||
bh = gene_childboxheader( box, pos);
|
||||
pos += bh->headlen;
|
||||
|
||||
/* insert into the list */
|
||||
// insert into the list
|
||||
if( manf->first)
|
||||
last->next = bh;
|
||||
else
|
||||
@@ -77,7 +77,7 @@ void delete_manfbox( manfbox_param_t **manf)
|
||||
while( bhPtr != NULL){
|
||||
bhNext = bhPtr->next;
|
||||
#ifndef SERVER
|
||||
/* fprintf( logstream, "local log: boxheader %.4s deleted!\n", bhPtr->type); */
|
||||
// fprintf( logstream, "local log: boxheader %.4s deleted!\n", bhPtr->type);
|
||||
#endif
|
||||
free(bhPtr);
|
||||
bhPtr = bhNext;
|
||||
@@ -96,7 +96,7 @@ void print_manfbox( manfbox_param_t *manf)
|
||||
}
|
||||
}
|
||||
|
||||
boxheader_param_t * search_boxheader( const char type[], manfbox_param_t *manf)
|
||||
boxheader_param_t * search_boxheader( char type[], manfbox_param_t *manf)
|
||||
{
|
||||
boxheader_param_t *found;
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ void print_manfbox( manfbox_param_t *manf);
|
||||
* @param[in] manf manf box pointer
|
||||
* @return found box pointer
|
||||
*/
|
||||
boxheader_param_t * search_boxheader( const char type[], manfbox_param_t *manf);
|
||||
boxheader_param_t * search_boxheader( char type[], manfbox_param_t *manf);
|
||||
|
||||
|
||||
#endif /* !MANFBOX_MANAGER_H_ */
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER */
|
||||
#endif //SERVER
|
||||
|
||||
marker_param_t set_marker( codestream_param_t cs, Byte2_t code, Byte8_t offset, Byte2_t length)
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#endif /*SERVER*/
|
||||
|
||||
|
||||
metadatalist_param_t * gene_metadatalist(void)
|
||||
metadatalist_param_t * gene_metadatalist()
|
||||
{
|
||||
metadatalist_param_t *list;
|
||||
|
||||
@@ -77,6 +77,10 @@ metadatalist_param_t * const_metadatalist( int fd)
|
||||
phldlist = gene_placeholderlist();
|
||||
metadatalist = gene_metadatalist();
|
||||
|
||||
delete_box_in_list_by_type( "iptr", toplev_boxlist);
|
||||
delete_box_in_list_by_type( "cidx", toplev_boxlist);
|
||||
delete_box_in_list_by_type( "fidx", toplev_boxlist);
|
||||
|
||||
box = toplev_boxlist->first;
|
||||
idx = 0;
|
||||
while( box){
|
||||
|
||||
@@ -60,7 +60,7 @@ typedef struct metadatalist_param{
|
||||
*
|
||||
* @return pointer to the generated metadata list
|
||||
*/
|
||||
metadatalist_param_t * gene_metadatalist(void);
|
||||
metadatalist_param_t * gene_metadatalist();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,14 +40,14 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER */
|
||||
#endif //SERVER
|
||||
|
||||
|
||||
mhixbox_param_t * gene_mhixbox( box_param_t *box)
|
||||
{
|
||||
mhixbox_param_t *mhix;
|
||||
markeridx_param_t *mkridx, *lastmkidx;
|
||||
Byte8_t pos = 0;
|
||||
long pos = 0;
|
||||
|
||||
mhix = ( mhixbox_param_t *)malloc( sizeof( mhixbox_param_t));
|
||||
|
||||
@@ -129,7 +129,7 @@ void delete_mhixbox( mhixbox_param_t **mhix)
|
||||
while( mkPtr != NULL){
|
||||
mkNext=mkPtr->next;
|
||||
#ifndef SERVER
|
||||
/* fprintf( logstream, "local log: marker index %#x deleted!\n", mkPtr->code); */
|
||||
// fprintf( logstream, "local log: marker index %#x deleted!\n", mkPtr->code);
|
||||
#endif
|
||||
free(mkPtr);
|
||||
mkPtr=mkNext;
|
||||
|
||||
@@ -677,7 +677,7 @@ placeholder_param_t * parse_phld( Byte_t *datastream, Byte8_t metalength)
|
||||
phld = (placeholder_param_t *)malloc( sizeof(placeholder_param_t));
|
||||
|
||||
phld->LBox = big4( datastream);
|
||||
strncpy( phld->TBox, "phld", 4);
|
||||
strcpy( phld->TBox, "phld");
|
||||
phld->Flags = big4( datastream+8);
|
||||
phld->OrigID = big8( datastream+12);
|
||||
phld->OrigBHlen = metalength - 20;
|
||||
|
||||
@@ -115,7 +115,7 @@ bool process_JPIPrequest( server_record_t *rec, QR_t *qr)
|
||||
if( !close_channel( *(qr->query), rec->sessionlist, &cursession, &curchannel))
|
||||
return false;
|
||||
|
||||
if( (qr->query->fx > 0 && qr->query->fy > 0) || qr->query->box_type[0][0] != 0 || qr->query->len > 0)
|
||||
if( (qr->query->fx > 0 && qr->query->fy > 0) || qr->query->box_type[0][0] != 0)
|
||||
if( !gene_JPIPstream( *(qr->query), target, cursession, curchannel, &qr->msgqueue))
|
||||
return false;
|
||||
|
||||
@@ -141,29 +141,25 @@ void send_responsedata( server_record_t *rec, QR_t *qr)
|
||||
recons_stream_from_msgqueue( qr->msgqueue, fd);
|
||||
|
||||
add_EORmsg( fd, qr); /* needed at least for tcp and udp */
|
||||
|
||||
|
||||
len_of_jpipstream = get_filesize( fd);
|
||||
jpipstream = fetch_bytes( fd, 0, len_of_jpipstream);
|
||||
|
||||
|
||||
close( fd);
|
||||
remove( tmpfname);
|
||||
|
||||
fprintf( FCGI_stdout, "\r\n");
|
||||
|
||||
if( len_of_jpipstream){
|
||||
|
||||
if( qr->channel)
|
||||
if( qr->channel->aux == tcp || qr->channel->aux == udp){
|
||||
send_responsedata_on_aux( qr->channel->aux==tcp, rec->auxtrans, qr->channel->cid, jpipstream, len_of_jpipstream, 1000); /* 1KB per frame*/
|
||||
return;
|
||||
}
|
||||
|
||||
if( fwrite( jpipstream, len_of_jpipstream, 1, FCGI_stdout) != 1)
|
||||
fprintf( FCGI_stderr, "Error: failed to write jpipstream\n");
|
||||
}
|
||||
if( qr->channel)
|
||||
if( qr->channel->aux == tcp || qr->channel->aux == udp){
|
||||
send_responsedata_on_aux( qr->channel->aux==tcp, rec->auxtrans, qr->channel->cid, jpipstream, len_of_jpipstream, 1000); /* 1KB per frame*/
|
||||
return;
|
||||
}
|
||||
|
||||
if( fwrite( jpipstream, len_of_jpipstream, 1, FCGI_stdout) != 1)
|
||||
fprintf( FCGI_stderr, "Error: failed to write jpipstream\n");
|
||||
|
||||
free( jpipstream);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -183,7 +179,7 @@ void add_EORmsg( int fd, QR_t *qr)
|
||||
void end_QRprocess( server_record_t *rec, QR_t **qr)
|
||||
{
|
||||
/* TODO: record client preferences if necessary*/
|
||||
(void)rec; /* unused */
|
||||
|
||||
delete_query( &((*qr)->query));
|
||||
delete_msgqueue( &((*qr)->msgqueue));
|
||||
free( *qr);
|
||||
|
||||
@@ -41,11 +41,11 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
#endif //SERVER
|
||||
|
||||
|
||||
|
||||
placeholderlist_param_t * gene_placeholderlist(void)
|
||||
placeholderlist_param_t * gene_placeholderlist()
|
||||
{
|
||||
placeholderlist_param_t *list;
|
||||
|
||||
@@ -81,7 +81,7 @@ placeholder_param_t * gene_placeholder( box_param_t *box, int origID)
|
||||
placeholder = (placeholder_param_t *)malloc( sizeof(placeholder_param_t));
|
||||
|
||||
strncpy( placeholder->TBox, "phld", 4);
|
||||
placeholder->Flags = 1; /* only the access to the original contents of this box, for now */
|
||||
placeholder->Flags = 1; // only the access to the original contents of this box, for now
|
||||
placeholder->OrigID = origID;
|
||||
placeholder->OrigBH = fetch_headbytes( box);
|
||||
placeholder->OrigBHlen = box->headlen;
|
||||
|
||||
@@ -66,7 +66,7 @@ typedef struct placeholderlist_param{
|
||||
*
|
||||
* @return pointer to the generated placeholder list
|
||||
*/
|
||||
placeholderlist_param_t * gene_placeholderlist(void);
|
||||
placeholderlist_param_t * gene_placeholderlist();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
*
|
||||
* @return initial query parameters
|
||||
*/
|
||||
query_param_t * get_initquery(void);
|
||||
query_param_t * get_initquery();
|
||||
|
||||
/*
|
||||
* get a pair of field name and value from the string starting fieldname=fieldval&... format
|
||||
@@ -141,17 +141,14 @@ query_param_t * parse_query( char *query_string)
|
||||
query_param->return_type = JPTstream;
|
||||
}
|
||||
|
||||
else if( strcasecmp( fieldname, "len") == 0){
|
||||
else if( strcasecmp( fieldname, "len") == 0)
|
||||
sscanf( fieldval, "%d", &query_param->len);
|
||||
if( query_param->len == 2000) /* for kakadu client*/
|
||||
strncpy( query_param->box_type[0], "ftyp", 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
return query_param;
|
||||
}
|
||||
|
||||
query_param_t * get_initquery(void)
|
||||
query_param_t * get_initquery()
|
||||
{
|
||||
query_param_t *query;
|
||||
int i;
|
||||
@@ -333,7 +330,7 @@ void parse_req_box_prop( char *req_box_prop, int idx, query_param_t *query_param
|
||||
query_param->box_type[idx][0]='*';
|
||||
else
|
||||
strncpy( query_param->box_type[idx], req_box_prop, 4);
|
||||
|
||||
|
||||
if(( ptr = strchr( req_box_prop, ':'))){
|
||||
if( *(ptr+1)=='r')
|
||||
query_param->limit[idx] = -1;
|
||||
|
||||
@@ -41,10 +41,10 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER */
|
||||
#endif //SERVER
|
||||
|
||||
|
||||
sessionlist_param_t * gene_sessionlist(void)
|
||||
sessionlist_param_t * gene_sessionlist()
|
||||
{
|
||||
sessionlist_param_t *sessionlist;
|
||||
|
||||
@@ -67,9 +67,9 @@ session_param_t * gene_session( sessionlist_param_t *sessionlist)
|
||||
|
||||
session->next = NULL;
|
||||
|
||||
if( sessionlist->first) /* there are one or more entries */
|
||||
if( sessionlist->first) // there are one or more entries
|
||||
sessionlist->last->next = session;
|
||||
else /* first entry */
|
||||
else // first entry
|
||||
sessionlist->first = session;
|
||||
sessionlist->last = session;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ typedef struct sessionlist_param{
|
||||
*
|
||||
* @return pointer to the generated session list
|
||||
*/
|
||||
sessionlist_param_t * gene_sessionlist(void);
|
||||
sessionlist_param_t * gene_sessionlist();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,10 +34,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#ifdef __FreeBSD__
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -52,7 +48,7 @@
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
#endif //SERVER
|
||||
|
||||
SOCKET open_listeningsocket( int port)
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
|
||||
targetlist_param_t * gene_targetlist(void)
|
||||
targetlist_param_t * gene_targetlist()
|
||||
{
|
||||
targetlist_param_t *targetlist;
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ typedef struct targetlist_param{
|
||||
*
|
||||
* @return pointer to the generated target list
|
||||
*/
|
||||
targetlist_param_t * gene_targetlist(void);
|
||||
targetlist_param_t * gene_targetlist();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,14 +4,6 @@ INCLUDE_DIRECTORIES(
|
||||
${FCGI_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# Tool to embed metadata into JP2 file
|
||||
ADD_EXECUTABLE(addXMLinJP2 addXMLinJP2.c)
|
||||
# Install exe
|
||||
INSTALL(TARGETS addXMLinJP2
|
||||
EXPORT OpenJPEGTargets
|
||||
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||
)
|
||||
|
||||
IF(BUILD_JPIP_SERVER)
|
||||
|
||||
SET(OPJ_SERVER_SRCS
|
||||
@@ -55,105 +47,81 @@ FOREACH(exe ${EXES})
|
||||
ENDFOREACH(exe)
|
||||
|
||||
# Build the two java clients:
|
||||
FIND_PACKAGE(Java 1.5 COMPONENTS Development) # javac, jar
|
||||
FIND_PACKAGE(Java 1.5 REQUIRED) # javac, jar
|
||||
|
||||
# User can override this:
|
||||
if(NOT DEFINED JAVA_SOURCE_VERSION)
|
||||
set(JAVA_SOURCE_VERSION 1.5)
|
||||
endif()
|
||||
if(NOT DEFINED JAVA_TARGET_VERSION)
|
||||
set(JAVA_TARGET_VERSION 1.5)
|
||||
endif()
|
||||
# 1. opj_viewer
|
||||
# build dep list:
|
||||
file(GLOB java1_srcs "opj_viewer/src/*.java")
|
||||
|
||||
# Only build the java viewer if dev is found:
|
||||
if(Java_Development_FOUND AND Java_JAVAC_EXECUTABLE)
|
||||
set(jflags $ENV{JFLAGS})
|
||||
# 1. opj_viewer
|
||||
# make sure target javac dir exists:
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes1)
|
||||
# Build java
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
||||
COMMAND ${Java_JAVAC_EXECUTABLE}
|
||||
${java1_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes1
|
||||
COMMAND ${Java_JAR_EXECUTABLE} cfm ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/dist/manifest.txt -C
|
||||
${CMAKE_CURRENT_BINARY_DIR}/classes1 .
|
||||
DEPENDS ${java1_srcs}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/dist/manifest.txt
|
||||
COMMENT "javac *.java; jar cvf -> opj_viewer.jar"
|
||||
)
|
||||
|
||||
# name the target
|
||||
ADD_CUSTOM_TARGET(OPJViewerJar ALL
|
||||
DEPENDS ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
||||
COMMENT "building opj_viewer.jar"
|
||||
)
|
||||
|
||||
# 2. opj_viewer_xerces
|
||||
# search for package org.apache.xerces.parsers
|
||||
find_file(APACHE_XERCES_JAR
|
||||
NAMES xerces-j2.jar xercesImpl.jar
|
||||
PATHS /usr/share/java/
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
mark_as_advanced(APACHE_XERCES_JAR)
|
||||
|
||||
if(EXISTS ${APACHE_XERCES_JAR})
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer_xerces/dist/manifest.txt.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/opj_viewer_xerces/dist/manifest.txt
|
||||
@ONLY
|
||||
)
|
||||
# build dep list:
|
||||
file(GLOB java1_srcs "opj_viewer/src/*.java")
|
||||
file(GLOB java2_srcs "opj_viewer_xerces/src/*.java")
|
||||
|
||||
# Need some common files:
|
||||
list(APPEND java2_srcs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ImageManager.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ImgdecClient.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/JPIPHttpClient.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/MML.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/PnmImage.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/RegimViewer.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ResizeListener.java
|
||||
)
|
||||
|
||||
# make sure target javac dir exists:
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes1)
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes2)
|
||||
# Build java
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
||||
COMMAND ${Java_JAVAC_EXECUTABLE} ${jflags}
|
||||
-source ${JAVA_SOURCE_VERSION} -target ${JAVA_TARGET_VERSION}
|
||||
${java1_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes1
|
||||
COMMAND ${Java_JAR_EXECUTABLE} cfm ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/dist/manifest.txt -C
|
||||
${CMAKE_CURRENT_BINARY_DIR}/classes1 .
|
||||
DEPENDS ${java1_srcs}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/dist/manifest.txt
|
||||
COMMENT "javac *.java; jar cvf -> opj_viewer.jar"
|
||||
OUTPUT ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
||||
COMMAND ${Java_JAVAC_EXECUTABLE}
|
||||
-classpath ${APACHE_XERCES_JAR}
|
||||
${java2_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes2
|
||||
COMMAND ${Java_JAR_EXECUTABLE} cfm ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
||||
${CMAKE_CURRENT_BINARY_DIR}/opj_viewer_xerces/dist/manifest.txt
|
||||
-C ${CMAKE_CURRENT_BINARY_DIR}/classes2 .
|
||||
DEPENDS ${java2_srcs}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer_xerces/dist/manifest.txt.in
|
||||
COMMENT "javac *.java; jar cvf -> opj_viewer_xerces.jar"
|
||||
)
|
||||
|
||||
# name the target
|
||||
ADD_CUSTOM_TARGET(OPJViewerJar ALL
|
||||
DEPENDS ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
||||
COMMENT "building opj_viewer.jar"
|
||||
ADD_CUSTOM_TARGET(OPJViewerXercesJar ALL
|
||||
DEPENDS ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
||||
COMMENT "building opj_viewer_xerces.jar"
|
||||
)
|
||||
|
||||
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/opj_viewer.jar
|
||||
DESTINATION ${OPENJPEG_INSTALL_SHARE_DIR} COMPONENT JavaModule
|
||||
)
|
||||
|
||||
# 2. opj_viewer_xerces
|
||||
# search for package org.apache.xerces.parsers
|
||||
find_file(APACHE_XERCES_JAR
|
||||
NAMES xerces-j2.jar xercesImpl.jar
|
||||
PATHS /usr/share/java/
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
mark_as_advanced(APACHE_XERCES_JAR)
|
||||
|
||||
if(EXISTS ${APACHE_XERCES_JAR})
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer_xerces/dist/manifest.txt.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/opj_viewer_xerces/dist/manifest.txt
|
||||
@ONLY
|
||||
)
|
||||
# build dep list:
|
||||
file(GLOB java2_srcs "opj_viewer_xerces/src/*.java")
|
||||
|
||||
# Need some common files:
|
||||
list(APPEND java2_srcs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ImageManager.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ImgdecClient.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/JPIPHttpClient.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/MML.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/PnmImage.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/RegimViewer.java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer/src/ResizeListener.java
|
||||
)
|
||||
|
||||
# make sure target javac dir exists:
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes2)
|
||||
# Build java
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
||||
COMMAND ${Java_JAVAC_EXECUTABLE} ${jflags}
|
||||
-source ${JAVA_SOURCE_VERSION} -target ${JAVA_TARGET_VERSION}
|
||||
-classpath ${APACHE_XERCES_JAR}
|
||||
${java2_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes2
|
||||
COMMAND ${Java_JAR_EXECUTABLE} cfm ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
||||
${CMAKE_CURRENT_BINARY_DIR}/opj_viewer_xerces/dist/manifest.txt
|
||||
-C ${CMAKE_CURRENT_BINARY_DIR}/classes2 .
|
||||
DEPENDS ${java2_srcs}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_viewer_xerces/dist/manifest.txt.in
|
||||
COMMENT "javac *.java; jar cvf -> opj_viewer_xerces.jar"
|
||||
)
|
||||
|
||||
# name the target
|
||||
ADD_CUSTOM_TARGET(OPJViewerXercesJar ALL
|
||||
DEPENDS ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
||||
COMMENT "building opj_viewer_xerces.jar"
|
||||
)
|
||||
|
||||
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/opj_viewer_xerces.jar
|
||||
DESTINATION ${OPENJPEG_INSTALL_SHARE_DIR} COMPONENT JavaModule
|
||||
)
|
||||
endif()
|
||||
else(Java_Development_FOUND)
|
||||
message(WARNING "No java compiler found. Wont be able to build java viewer")
|
||||
endif()
|
||||
|
||||
@@ -73,15 +73,15 @@ char * read_xmlfile( char filename[], long *fsize);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fp;
|
||||
char *xmldata, type[]="xml ";
|
||||
long fsize, boxsize;
|
||||
|
||||
if( argc<3){
|
||||
fprintf( stderr, "USAGE: ./addXMLinJP2 modifing.jp2 adding.xml\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
FILE *fp;
|
||||
char *xmldata, type[]="xml ";
|
||||
long fsize, boxsize;
|
||||
|
||||
fp = open_jp2file( argv[1]);
|
||||
if( !fp)
|
||||
return -1;
|
||||
@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
|
||||
fputc( (boxsize>>8)&0xff, fp);
|
||||
fputc( boxsize&0xff, fp);
|
||||
fwrite( type, 4, 1, fp);
|
||||
fwrite( xmldata, (size_t)fsize, 1, fp);
|
||||
fwrite( xmldata, fsize, 1, fp);
|
||||
|
||||
free( xmldata);
|
||||
fclose(fp);
|
||||
@@ -111,14 +111,14 @@ FILE * open_jp2file( char filename[])
|
||||
fprintf( stderr, "Original JP2 %s not found\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
/* Check resource is a JP family file. */
|
||||
// Check resource is a JP family file.
|
||||
if( fseek( fp, 0, SEEK_SET)==-1){
|
||||
fclose(fp);
|
||||
fprintf( stderr, "Original JP2 %s broken (fseek error)\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (char *)malloc( 12); /* size of header */
|
||||
data = (char *)malloc( 12); // size of header
|
||||
if( fread( data, 12, 1, fp) != 1){
|
||||
free( data);
|
||||
fclose(fp);
|
||||
@@ -142,7 +142,7 @@ char * read_xmlfile( char filename[], long *fsize)
|
||||
FILE *fp;
|
||||
char *data;
|
||||
|
||||
/* fprintf( stderr, "open %s\n", filename); */
|
||||
// fprintf( stderr, "open %s\n", filename);
|
||||
if(!(fp = fopen( filename, "r"))){
|
||||
fprintf( stderr, "XML file %s not found\n", filename);
|
||||
return NULL;
|
||||
@@ -166,9 +166,9 @@ char * read_xmlfile( char filename[], long *fsize)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (char *)malloc( (size_t)*fsize);
|
||||
data = (char *)malloc( *fsize);
|
||||
|
||||
if( fread( data, (size_t)*fsize, 1, fp) != 1){
|
||||
if( fread( data, *fsize, 1, fp) != 1){
|
||||
fprintf( stderr, "XML file %s broken (read error)\n", filename);
|
||||
free( data);
|
||||
fclose(fp);
|
||||
|
||||
@@ -64,7 +64,7 @@ int main(int argc,char *argv[])
|
||||
if(!( fwrite_jp2k( argv[2], dec)))
|
||||
return -1;
|
||||
|
||||
/* output_log( true, false, false, dec); */
|
||||
// output_log( true, false, false, dec);
|
||||
|
||||
destroy_jpipdecoder( &dec);
|
||||
|
||||
|
||||
@@ -33,12 +33,11 @@
|
||||
*
|
||||
* \section impinst Implementing instructions
|
||||
* Launch opj_dec_server from a terminal in the same machine as JPIP client image viewers. \n
|
||||
* % ./opj_dec_server [portnumber]\n
|
||||
* ( portnumber=50000 by default)\n
|
||||
* % ./opj_dec_server \n
|
||||
* Keep it alive as long as image viewers are open.\n
|
||||
*
|
||||
* To quite the opj_dec_server, send a message "quit" through the telnet.\n
|
||||
* % telnet localhost 50000\n
|
||||
* % telnet localhost 5000\n
|
||||
* quit\n
|
||||
* Be sure all image viewers are closed.\n
|
||||
* Cache file in JPT format is stored in the working directly before it quites.
|
||||
@@ -46,7 +45,6 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "openjpip.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -57,22 +55,16 @@ int main(int argc, char *argv[]){
|
||||
|
||||
dec_server_record_t *server_record;
|
||||
client_t client;
|
||||
int port = 50000;
|
||||
int erreur;
|
||||
(void)erreur;
|
||||
|
||||
if( argc > 1)
|
||||
port = atoi( argv[1]);
|
||||
|
||||
#ifdef _WIN32
|
||||
erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32);
|
||||
int erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32);
|
||||
if( erreur!=0)
|
||||
fprintf( stderr, "Erreur initialisation Winsock error : %d %d\n",erreur,WSAGetLastError());
|
||||
else
|
||||
printf( "Initialisation Winsock\n");
|
||||
#endif /*_WIN32*/
|
||||
#endif //_WIN32
|
||||
|
||||
server_record = init_dec_server( port);
|
||||
server_record = init_dec_server( 50000);
|
||||
|
||||
while(( client = accept_connection( server_record)) != -1 )
|
||||
if(!handle_clientreq( client, server_record))
|
||||
|
||||
@@ -56,14 +56,11 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
WSADATA initialisation_win32;
|
||||
#endif /*_WIN32*/
|
||||
#endif //_WIN32
|
||||
|
||||
int main(void)
|
||||
{
|
||||
server_record_t *server_record;
|
||||
#ifdef SERVER
|
||||
char *query_string;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
int erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32);
|
||||
@@ -71,11 +68,13 @@ int main(void)
|
||||
fprintf( stderr, "Erreur initialisation Winsock error : %d %d\n",erreur,WSAGetLastError());
|
||||
else
|
||||
fprintf( stderr, "Initialisation Winsock\n");
|
||||
#endif /*_WIN32*/
|
||||
#endif //_WIN32
|
||||
|
||||
server_record = init_JPIPserver( 60000, 0);
|
||||
|
||||
#ifdef SERVER
|
||||
|
||||
char *query_string;
|
||||
while(FCGI_Accept() >= 0)
|
||||
#else
|
||||
|
||||
@@ -83,16 +82,17 @@ int main(void)
|
||||
while( fgets( query_string, 128, stdin) && query_string[0]!='\n')
|
||||
#endif
|
||||
{
|
||||
QR_t *qr;
|
||||
bool parse_status;
|
||||
|
||||
#ifdef SERVER
|
||||
query_string = getenv("QUERY_STRING");
|
||||
#endif /*SERVER*/
|
||||
#endif //SERVER
|
||||
|
||||
if( strcmp( query_string, QUIT_SIGNAL) == 0)
|
||||
break;
|
||||
|
||||
QR_t *qr;
|
||||
bool parse_status;
|
||||
|
||||
qr = parse_querystring( query_string);
|
||||
|
||||
parse_status = process_JPIPrequest( server_record, qr);
|
||||
@@ -103,10 +103,8 @@ int main(void)
|
||||
|
||||
if( parse_status)
|
||||
send_responsedata( server_record, qr);
|
||||
else{
|
||||
else
|
||||
fprintf( FCGI_stderr, "Error: JPIP request failed\n");
|
||||
fprintf( FCGI_stdout, "\r\n");
|
||||
}
|
||||
|
||||
end_QRprocess( server_record, &qr);
|
||||
}
|
||||
|
||||
@@ -35,12 +35,10 @@ public class ImageManager extends JPIPHttpClient
|
||||
private PnmImage pnmimage;
|
||||
private int origwidth;
|
||||
private int origheight;
|
||||
private ImgdecClient imgdecoder;
|
||||
|
||||
public ImageManager( String uri, String host, int port)
|
||||
public ImageManager( String uri)
|
||||
{
|
||||
super( uri);
|
||||
imgdecoder = new ImgdecClient( host, port);
|
||||
pnmimage = null;
|
||||
origwidth = 0;
|
||||
origheight = 0;
|
||||
@@ -49,7 +47,7 @@ public class ImageManager extends JPIPHttpClient
|
||||
public int getOrigWidth(){
|
||||
if( origwidth == 0){
|
||||
if( cid != null || tid != null){
|
||||
java.awt.Dimension dim = imgdecoder.query_imagesize( cid, tid);
|
||||
java.awt.Dimension dim = ImgdecClient.query_imagesize( cid, tid);
|
||||
if( dim != null){
|
||||
origwidth = dim.width;
|
||||
origheight = dim.height;
|
||||
@@ -71,10 +69,10 @@ public class ImageManager extends JPIPHttpClient
|
||||
|
||||
// Todo: check if the cid is for the same stream type
|
||||
if( reqcnew)
|
||||
refcid = imgdecoder.query_cid( j2kfilename);
|
||||
refcid = ImgdecClient.query_cid( j2kfilename);
|
||||
|
||||
if( refcid == null){
|
||||
String reftid = imgdecoder.query_tid( j2kfilename);
|
||||
String reftid = ImgdecClient.query_tid( j2kfilename);
|
||||
if( reftid == null)
|
||||
jpipstream = super.requestViewWindow( j2kfilename, reqfw, reqfh, reqcnew, reqaux, reqJPP, reqJPT);
|
||||
else
|
||||
@@ -84,7 +82,7 @@ public class ImageManager extends JPIPHttpClient
|
||||
jpipstream = super.requestViewWindow( reqfw, reqfh, refcid, reqcnew, reqaux, reqJPP, reqJPT);
|
||||
|
||||
System.err.println( "decoding to PNM image");
|
||||
if((pnmimage = imgdecoder.decode_jpipstream( jpipstream, j2kfilename, tid, cid, fw, fh))!=null){
|
||||
if((pnmimage = ImgdecClient.decode_jpipstream( jpipstream, j2kfilename, tid, cid, fw, fh))!=null){
|
||||
System.err.println( " done");
|
||||
return pnmimage.createROIImage( rx, ry, rw, rh);
|
||||
}
|
||||
@@ -101,7 +99,7 @@ public class ImageManager extends JPIPHttpClient
|
||||
byte[] jpipstream = super.requestViewWindow( reqfw, reqfh, reqrx, reqry, reqrw, reqrh);
|
||||
|
||||
System.err.println( "decoding to PNM image");
|
||||
if((pnmimage = imgdecoder.decode_jpipstream( jpipstream, tid, cid, fw, fh)) != null){
|
||||
if((pnmimage = ImgdecClient.decode_jpipstream( jpipstream, tid, cid, fw, fh)) != null){
|
||||
System.err.println( " done");
|
||||
return pnmimage.createROIImage( rx, ry, rw, rh);
|
||||
}
|
||||
@@ -119,9 +117,9 @@ public class ImageManager extends JPIPHttpClient
|
||||
byte[] jpipstream = super.requestXML();
|
||||
|
||||
if( jpipstream != null){
|
||||
imgdecoder.send_JPIPstream( jpipstream);
|
||||
ImgdecClient.send_JPIPstream( jpipstream);
|
||||
|
||||
xmldata = imgdecoder.get_XMLstream( cid);
|
||||
xmldata = ImgdecClient.get_XMLstream( cid);
|
||||
}
|
||||
return xmldata;
|
||||
}
|
||||
@@ -129,7 +127,7 @@ public class ImageManager extends JPIPHttpClient
|
||||
public void closeChannel()
|
||||
{
|
||||
if( cid != null){
|
||||
imgdecoder.destroy_cid( cid);
|
||||
ImgdecClient.destroy_cid( cid);
|
||||
super.closeChannel();
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user