Compare commits

...

96 Commits

Author SHA1 Message Date
Antonin Descampe
5d40f5ad3b adding two tags for version 1.3 and 1.4 2011-07-03 18:56:21 +00:00
Francois-Olivier Devaux
287fb0b8fd Bug fixed by David Bruken. Fixed memory allocation issue in opj_malloc.h.
Possible errors in pi_create_encode handled
2007-12-21 10:19:01 +00:00
Antonin Descampe
847b082b64 changed variables names alpha, beta, gamma, delta in dwt.c to avoid re-declarations on Macosx 2007-12-19 14:45:35 +00:00
Francois-Olivier Devaux
5f995bcf4b Fixed allocation problem in pi.c 2007-12-19 13:57:57 +00:00
Parvatha Elangovan
64ed560f4f In pi.c, removed the Recursive function pi_check_next_level() and modified the code. 2007-12-19 12:28:40 +00:00
Francois-Olivier Devaux
1a33a09726 In mqc.h, changed MQC_NUMCTXS from 32 to 19 as JPEG 2000 only allows 19 possible contexts 2007-12-19 09:13:52 +00:00
Francois-Olivier Devaux
26606c71c8 First import of JAVAOpenJPEG, a Java wrapper of OpenJPEG, developed by Patrick Piscaglia of Telemis (www.telemis.com). Thank you Patrick for this new module ! 2007-12-10 13:16:01 +00:00
Giuseppe Baruffa
e06bcd027f Added index.h and index.c in VC6 projects; wrapped index.h in the C++ preprocessor; modified OPJViewer project and some files. 2007-11-29 14:38:26 +00:00
Francois-Olivier Devaux
9e5d165e79 Fixed the maximum number of resolutions a user can discard while decoding.
Added an error state in J2K_STATE (j2k.c)
2007-11-27 14:00:45 +00:00
Francois-Olivier Devaux
efa5f7977c Created the file index.c in the codec directory. This file handles the creation of index files, at encoding and decoding.
Fixed bugs during the creation of the index (PCRL progression order)
2007-11-27 12:38:52 +00:00
Francois-Olivier Devaux
c458af9cd6 Avoided ABI breakage 2007-11-14 11:34:48 +00:00
Francois-Olivier Devaux
010ae27471 Patch by Callum Lerwick. The opj_tcd_cblk array is one of the largest allocations, because it contains a bunch of static buffers. This also makes it a major source of cache thrashing. This patch allocates the buffers from the heap, and dynamically sizes them in the decoder. I have not yet managed to dynamically size them in the encoder, getting the decoder to do it was tricky enough... I also split opj_tcd_cblk_t into separate encode and decode versions. A lot of fields were not used by both, so this cuts its size even further. 2007-11-14 10:52:02 +00:00
Francois-Olivier Devaux
24e189e4d8 Patch by Callum Lerwick. This patch rearranges the largest memory allocations so they're allocated as late as possible, and freed as soon as possible. This cuts memory usage by about half on two large test images. 2007-11-14 08:45:00 +00:00
Francois-Olivier Devaux
61a15672bb Patch by Callum Lerwick. Instead of reinventing realloc, j2k_read_sod now just uses opj_realloc in j2k.c 2007-11-14 08:29:12 +00:00
Francois-Olivier Devaux
dbeebe72b9 Patch by Dzonatas and Callum Lerwick. Fp/vectorization patch which basically converts most of the irreversible decode codepath to floating point, eliminating a few rounds of int/fp conversion, resulting in a vast performance improvement, and an increase in accuracy. 2007-11-13 17:35:12 +00:00
Mathieu Malaterre
014694b04f BUG: Fix name of project 2007-11-08 14:52:45 +00:00
Mathieu Malaterre
6a1588c78e ENH: remove hardcoded value. It is a user-configurable option, which default to the same... 2007-11-08 14:46:53 +00:00
Mathieu Malaterre
6d7f5ccc8d ENH: do not set ffast-math for all configurations, please 2007-11-08 14:41:45 +00:00
Francois-Olivier Devaux
4bb067642f Patches from Callum Lewick: Fixed some spelling errors in dwt.c. 2007-11-08 14:29:39 +00:00
Francois-Olivier Devaux
c38de0728d In t1.c, small change to avoid calling twice t1_getwmsedec()
Patch from Callum Lewick. Basic gcc optimization flags in cmake and makefile match.
2007-11-08 14:26:03 +00:00
Giuseppe Baruffa
b93c12564d Restoring wrap_j2k_in_mj2.c, which I did not want to commit at all in rev469 2007-11-05 13:14:51 +00:00
Giuseppe Baruffa
95d760a173 Fixed a bug which prevented JPWL from working on multi-tiled images; added some more fields in the interface info structures (keep a list of markers, save start packet number for each tile) 2007-11-05 13:05:07 +00:00
Giuseppe Baruffa
123a680669 Improved success for the linux build; OPJViewer shows all the COM contents 2007-10-23 14:33:40 +00:00
Francois-Olivier Devaux
9e114bcaa4 Patch from Callum Lewick. Memset patch. See ChangeLog for more details. Thanks Callum ! 2007-10-18 12:26:11 +00:00
Francois-Olivier Devaux
5fdc05d18d Changed the ROI parameter in the image_to_j2k codec to make it correspond to the documentation (i.e. -ROI c=0,U=25) 2007-10-18 08:14:43 +00:00
Francois-Olivier Devaux
1f11a4fe90 Changed the way the image structure is allocated when the decoding parameters include some resolutions to discard. This should have a significant impact for the decoding of huge images when some resolutions are discarder (-r parameter)
Warning: The output image size is now reduced when discarding resolutions !
2007-10-12 15:04:34 +00:00
Francois-Olivier Devaux
ab0473aa42 *Patch from Callum Lewick. Clean up of j2klib.h for the aligned malloc stuff.
*convert.c: Changed some error comments for TIFF images
2007-10-10 06:17:28 +00:00
Francois-Olivier Devaux
4b60f17bba Patch from Callum Lewick. Fixed dwt.c where an alignment in buffer was problematic under x86_64. 2007-09-27 12:20:12 +00:00
Mathieu Malaterre
6265dcfb11 BUG: Fix previous patch from Callum Lerwick. I have no clue what CMAKE_INSTALL_LIBDIR refers too. Bump up cmake 2.2 restriction to cmake 2.4 because of previous patch not backward compatible. Properly set the SOVERSION in a cross plateform way (yes WIN32 is a plateform) 2007-09-25 14:54:49 +00:00
Parvatha Elangovan
7e40a9475a Fixed issues with generation of SOP marker. 2007-09-19 14:56:19 +00:00
Parvatha Elangovan
a6ba04cdf4 Fixed issues with Reading and Writing TIF images in convert.c to avoid segmentation fault.
Fixed issues relating to using user specified rates for CINEMA option for multiple images.
2007-09-18 13:07:29 +00:00
Francois-Olivier Devaux
55c4c14352 OpenJPEG library interface modified to retain compatibility with version 1.2. Sorry if some of you already adapted their code to the previous interface, but we want to avoid a ABI break.... 2007-09-17 15:11:20 +00:00
Francois-Olivier Devaux
569bbb0077 Fixed issues with cstr_info when codestream has components with different number of resolutions. 2007-09-17 14:00:43 +00:00
Francois-Olivier Devaux
abfba20b99 Patch from Callum Lerwick. Fixed the library linking so it links with the soversion properly set. Fixes up the install targets so that it interacts properly with RPM. Install target for MJ2. Sets some necessary and useful CFLAGS if gcc is in use. 2007-09-12 09:04:03 +00:00
Francois-Olivier Devaux
09231c317d Updated the MJ2 codec to be compatible with the recent changes in the OpenJPEG library. 2007-09-12 08:52:18 +00:00
Giuseppe Baruffa
1e705438e4 JPWL encoding is finalized correctly into the JP2 file format; added an additional structure in opj_codestream_info, to keep a record of the written markers 2007-09-11 15:21:12 +00:00
Giuseppe Baruffa
d70a0415b9 Adapted the JPWL and OPJViewer code to new interface; fixed a samll bug in JPWL which created large EPBs even when null protection was specified 2007-09-07 23:16:31 +00:00
Francois-Olivier Devaux
3816e0edf4 Indexes can now be generated when decoding J2K codestreams. 2007-09-07 15:01:55 +00:00
Mathieu Malaterre
e7149e0c56 ENH: license.txt was dos on my linux box. Make it native instead. 2007-09-07 13:52:43 +00:00
Mathieu Malaterre
3392d99487 BUG: cannot run tests if EXAMPLES are not built 2007-09-07 13:49:57 +00:00
Mathieu Malaterre
263e0f3bb2 ENH: make it a little more user friendly 2007-09-07 13:27:16 +00:00
Mathieu Malaterre
b29cff9b9c ENH: Add cmake code to do testing if user has properly setup a testimages directory 2007-09-07 13:21:17 +00:00
Mathieu Malaterre
2479921c71 ENH: Upon failure, properly return error code (!=0) 2007-09-07 13:06:36 +00:00
Mathieu Malaterre
53471a76f1 ENH: Fix unitialized read in img_fol (we may need a smarter initialize than memset) 2007-09-06 16:49:15 +00:00
Mathieu Malaterre
8ac5e7023c ENH: Add very simple tests (simply run command line with no option) 2007-09-06 16:38:06 +00:00
Giuseppe Baruffa
dfcacb8247 One more field in the codestream_info struct for recording the number of packets per tile part; JPWL now distributes the EPBs in all the tile part headers 2007-09-06 15:59:39 +00:00
Mathieu Malaterre
cf95a80be6 ENH: Add CMake/doxygen output 2007-09-06 15:10:15 +00:00
Mathieu Malaterre
be5db9489e ENH: add Java j2kviewer but do not compile it using cmake since cmake has too poor support for Java. Should create a custom command running ant instead. 2007-09-06 14:56:23 +00:00
Mathieu Malaterre
f3456a27e7 ENH: add Java j2kviewer but do not compile it using cmake since cmake has too poor support for Java. Should create a custom command running ant instead. 2007-09-06 14:56:00 +00:00
Mathieu Malaterre
375754f1e6 ENH: CMake: start compiling index_create. OpenJPEG.rc update copyright year 2007-09-06 14:46:24 +00:00
Mathieu Malaterre
f9c5f4565a ENH: CMake: output all executable/libs into one single directory 2007-09-06 11:01:10 +00:00
Mathieu Malaterre
86da5c2589 ENH: CMake: output all executable/libs into one single directory 2007-09-06 11:01:00 +00:00
Mathieu Malaterre
23891ede86 ENH: update changelog 2007-09-06 10:53:41 +00:00
Mathieu Malaterre
b4dc6fc133 ENH: add cmake for jp3d 2007-09-06 10:51:38 +00:00
Mathieu Malaterre
0533b5b78e Move include file that collides with system include to the correct directory (no need to be present for the lib, only codec need it) 2007-09-06 10:49:19 +00:00
Mathieu Malaterre
976ca18103 ENH: Add jpwl. Also remove old deprecated way of linking lib math on unix 2007-09-06 10:23:40 +00:00
Mathieu Malaterre
7e874368f7 ENH: Start building mj2 2007-09-06 10:13:05 +00:00
Giuseppe Baruffa
d3d2a36fbc Added some fields in the codestream_info structure: they are used to record the position of single tile parts. Changed also the write_index function in the codec, to reflect the presence of this new information. 2007-09-04 14:19:55 +00:00
Giuseppe Baruffa
564e16d5ce Added the knowledge of JPSEC SEC and INSEC markers (you have to compile the JPWL project). Management of these markers is limited to skipping them without crashing: no real security function at this stage. Deprecated USE_JPSEC and USE_JPWL will be removed next 2007-09-03 13:30:59 +00:00
Giuseppe Baruffa
c4313f0b39 Fixed save capabilities in OPJViewer due to recent code upgrade 2007-08-31 10:55:15 +00:00
Francois-Olivier Devaux
7a2d96efe1 Added information regarding the end of packet position in the index 2007-08-30 15:32:51 +00:00
Francois-Olivier Devaux
acfe0ad645 Changed the OpenJPEG library interface to enable users to access information regarding the codestream (also called index). 2007-08-30 09:51:20 +00:00
Francois-Olivier Devaux
d07fa5d9d0 Fixed wrong destructors called in openjpeg.c
Fixed bug in j2k_decode_jpt_stream
2007-08-28 10:13:58 +00:00
Parvatha Elangovan
c101f8049c The end of main header is calculated after TLM and POC marker for Dcinema. 2007-08-24 15:11:01 +00:00
Francois-Olivier Devaux
bd0b6ec2fd Fixed problem with _mm_malloc under OSX. Thanks to Callum Lerwick for solving that issue. 2007-08-24 13:46:44 +00:00
Francois-Olivier Devaux
1d02a8b595 Use <xmmintrin.h> for WIN32, else use <mm_malloc.h> 2007-08-21 12:57:39 +00:00
Francois-Olivier Devaux
07be749bf2 Moved the orient flipping into the ctxno_zc table.
Thanks to Callum Lerwick who provided all these great patches !
2007-08-21 12:51:57 +00:00
Francois-Olivier Devaux
2952874cb8 Replaced the large ctxno_mag lookup table with a small bit of inline-able branchless code 2007-08-21 12:42:55 +00:00
Francois-Olivier Devaux
1cfbdcc9ce Consolidated some calls to mqc_setcurctx. Cleaned up t1_generate_luts to output the proper types. 2007-08-21 12:36:05 +00:00
Francois-Olivier Devaux
d4d23c7eb5 Reworks of t1_updateflags to get rid of the shift operation. mqc_setcurctx moved to the header to allow it to be inlined into the t1. 2007-08-21 12:30:08 +00:00
Francois-Olivier Devaux
adca52578d Memory leaks fixed 2007-08-21 12:21:35 +00:00
Francois-Olivier Devaux
3810e943b1 Aligned malloc using Intel's _mm_malloc(), cleanup on the t1 memory allocation, getting rid of some leftover debug code 2007-08-21 12:13:54 +00:00
Francois-Olivier Devaux
ca2a0114a2 Minor cleanup patch, that gets rid of a bunch of "old style declaration" warnings from Intel's compiler 2007-08-21 12:02:23 +00:00
Francois-Olivier Devaux
2c75c27ee8 Solved problems with codec reading from image file directory when filename had more than one "." in name 2007-08-21 10:50:47 +00:00
Francois-Olivier Devaux
1d0dbeb232 Robustified MJ2 codecs 2007-08-21 10:18:40 +00:00
Francois-Olivier Devaux
d9924962ff Added support for Visual Studio 2005 2007-08-21 10:17:35 +00:00
Francois-Olivier Devaux
00e440ebdb Corrected allocation to take into account the EOC marker 2007-08-21 09:06:13 +00:00
Francois-Olivier Devaux
17f0828c74 Fixed _strnicmp bug 2007-08-20 15:26:01 +00:00
Francois-Olivier Devaux
8298fd2b0a Added support for the TGA file format in the codec 2007-08-20 15:20:42 +00:00
Francois-Olivier Devaux
7dcb817e6a Fixed the DCinema filesize allocation. It now includes the SOT marker size 2007-08-08 09:41:16 +00:00
Giuseppe Baruffa
9cf692e897 Added a basic saving capability to OPJViewer 2007-08-02 12:45:28 +00:00
Francois-Olivier Devaux
4f4aa1d49f Lighter version of libtiff uploaded (without JPEG support). 2007-07-19 15:04:39 +00:00
Francois-Olivier Devaux
9e5a83d8f9 Delete Tiffconf.h 2007-07-19 13:49:33 +00:00
Francois-Olivier Devaux
c45b8e6c38 Updated libtiff library version to 3.8.2 (for WIN32)
Updated BMP and PxM truncation when decoding J2K files with more than 8 bits (convert.c)
2007-07-19 13:44:04 +00:00
Francois-Olivier Devaux
64d72b7bfd Fixed raw option to encode raw images with more than three components. 2007-07-18 09:45:59 +00:00
Francois-Olivier Devaux
b7ce19709d Added support for RAW images. This module has been developped by the University of Perugia team. Thanks to them ! 2007-07-17 16:19:41 +00:00
Francois-Olivier Devaux
5dec8bbbe9 2007-07-13 13:07:07 +00:00
Giuseppe Baruffa
4a50efe542 Fixed a bug in JPWL module, which prevented to exploit the full error correction capability of RS codes (e.g. it gave up at 5 errors, even if 6 were correctable); defined a JPWL_MAXIMUM_EPB_ROOM for better customization of the maximum dimension of EPBs (the dimension is pre-calculated on an hypothesis, if it goes beyond 65535 there will be problems, thus we give a little less than the max, let's say 65450) 2007-07-12 08:31:01 +00:00
Antonin Descampe
bdb18ab19c fixed the size of the memory allocation in cio.c (confusion between bits and bytes) 2007-07-08 16:38:51 +00:00
Giuseppe Baruffa
167fb6337b Previous, home, and next frame buttons for exploring MJ2 files in OPJViewer 2007-06-21 14:00:32 +00:00
Francois-Olivier Devaux
c924975434 Output image color space set when decoding a JP2 file 2007-06-21 08:26:03 +00:00
Giuseppe Baruffa
92398409a5 Reload image doesn't crash in OPJViewer; more settings saved to registry 2007-06-18 13:05:28 +00:00
Giuseppe Baruffa
c647671607 added toolbar to OPJViewer 2007-06-17 23:13:04 +00:00
Giuseppe Baruffa
2845d9bf64 Possibility to disable parsing in OPJViewer; also, saves common settings to the registry; automatic build numbering 2007-06-16 17:28:47 +00:00
Francois-Olivier Devaux
3d626da232 Fixed the generation of index files. Now works with cinema formats. 2007-06-15 13:27:43 +00:00
Antonin Descampe
f428a306a1 changed the dylib-version to 1.2.0 2007-06-05 09:00:34 +00:00
135 changed files with 18424 additions and 6015 deletions

View File

@@ -7,8 +7,7 @@
# For this purpose you can define a CMake var: OPENJPEG_NAMESPACE to whatever you like
# e.g.:
# SET(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
PROJECT(OPENJPEG C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.2)
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
IF(NOT OPENJPEG_NAMESPACE)
SET(OPENJPEG_NAMESPACE "OPENJPEG")
@@ -17,23 +16,37 @@ ENDIF(NOT OPENJPEG_NAMESPACE)
# In all cases:
STRING(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
PROJECT(${JPEG_NAMESPACE} C)
PROJECT(${OPENJPEG_NAMESPACE} C)
# Do full dependency headers.
INCLUDE_REGULAR_EXPRESSION("^.*$")
#-----------------------------------------------------------------------------
# OPENJPEG version number, usefull for packaging and doxygen doc:
SET(OPENJPEG_MAJOR_VERSION 1)
SET(OPENJPEG_MINOR_VERSION 0)
SET(OPENJPEG_BUILD_VERSION 0)
# OPENJPEG version number, useful for packaging and doxygen doc:
SET(OPENJPEG_VERSION_MAJOR 1)
SET(OPENJPEG_VERSION_MINOR 2)
SET(OPENJPEG_VERSION_BUILD 0)
SET(OPENJPEG_VERSION
"${OPENJPEG_MAJOR_VERSION}.${OPENJPEG_MINOR_VERSION}.${OPENJPEG_BUILD_VERSION}")
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
# This setting of SOVERSION assumes that any API change
# will increment either the minor or major version number of openjpeg
SET(OPENJPEG_LIBRARY_PROPERTIES
VERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
SOVERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}"
)
#-----------------------------------------------------------------------------
# OpenJPEG build configuration options.
OPTION(BUILD_SHARED_LIBS "Build OpenJPEG with shared libraries." OFF)
#-----------------------------------------------------------------------------
SET (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
SET (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
#-----------------------------------------------------------------------------
# For the codec...
OPTION(BUILD_EXAMPLES "Build the Examples (codec...)." OFF)
@@ -53,16 +66,35 @@ ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
SUBDIRS(
libopenjpeg
mj2
# cmake 2.4.5 has poor java support
#j2kviewer/src
)
IF(NOT UNIX)
SUBDIRS(
jpwl
jp3d
indexer_JPIP
)
ENDIF(NOT UNIX)
#-----------------------------------------------------------------------------
# Build example only if requested
IF(BUILD_EXAMPLES)
SUBDIRS(codec)
ENDIF(BUILD_EXAMPLES)
#-----------------------------------------------------------------------------
# For the documentation
OPTION(BUILD_DOCUMENTATION "Build the doxygen documentation" OFF)
IF(BUILD_DOCUMENTATION)
SUBDIRS(doc)
ENDIF(BUILD_DOCUMENTATION)
#-----------------------------------------------------------------------------
# For openjpeg team if they ever want Dart+CMake
IF(OPJ_STANDALONE)
IF(OPENJPEG_STANDALONE)
INCLUDE(Dart)
MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
IF(BUILD_TESTING)
@@ -70,8 +102,25 @@ IF(OPJ_STANDALONE)
SET(BUILDNAME "OpenJPEG-${CMAKE_SYSTEM}-${CMAKE_C_COMPILER}" CACHE STRING "Name of build on the dashboard")
MARK_AS_ADVANCED(BUILDNAME)
ENDIF(BUILD_TESTING)
ENDIF(OPJ_STANDALONE)
ENDIF(OPENJPEG_STANDALONE)
# TODO, technically we should add tests, e.g:
# Adding test with dataset from:
# http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
# http://www.jpeg.org/jpeg2000guide/testimages/testimages.html
#-----------------------------------------------------------------------------
# Adding JPEG2000_CONFORMANCE_DATA_ROOT
FIND_PATH(JPEG2000_CONFORMANCE_DATA_ROOT testimages.html
${OPENJPEG_SOURCE_DIR}/../jpeg2000testimages
$ENV{JPEG2000_CONFORMANCE_DATA_ROOT}
)
#-----------------------------------------------------------------------------
# Compiler specific flags:
IF(CMAKE_COMPILER_IS_GNUCC)
# For all builds, make sure openjpeg is std99 compliant:
SET(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}")
# Do not use ffast-math for all build, it would produce incorrect results, only set for release:
SET(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
ENDIF(CMAKE_COMPILER_IS_GNUCC)

235
ChangeLog
View File

@@ -5,6 +5,222 @@ What's New for OpenJPEG
! : changed
+ : added
December 21, 2007
* [FOD] Bug fixed by David Bruken. Fixed memory allocation issue in opj_malloc.h
! [FOD] Possible errors in pi_create_encode handled
December 19, 2007
* [Antonin] changed variables names alpha, beta, gamma, delta in dwt.c to avoid re-declarations on Macosx
! [Parvatha] In pi.c, removed the Recursive function pi_check_next_level() and modified the code.
* [FOD] Fixed allocation problem in pi.c
December 19, 2007
+ [FOD] In mqc.h, changed MQC_NUMCTXS from 32 to 19 as there are only 19 possible contexts
December 10, 2007
+ [FOD] First import of JAVAOpenJPEG, a Java wrapper of OpenJPEG, developed by Patrick Piscaglia of Telemis (www.telemis.com).
Thank you Patrick for this new module !
November 29, 2007
! [GB] Added index.h and index.c in VC6 projects; wrapped index.h in the C++ preprocessor; modified OPJViewer project and some files.
November 14, 2007
+ [FOD] Created the file index.c in the codec directory. This file handles the creation of index files,
at encoding and decoding.
* [FOD] Fixed bugs during the creation of the index (PCRL progression order)
* [FOD] Fixed the maximum number of resolutions a user can discard while decoding.
Added an error state in J2K_STATE (j2k.c)
November 14, 2007
! [FOD] - First Patch by Callum Lerwick. Instead of reinventing realloc, j2k_read_sod now just uses opj_realloc in j2k.c
- Second Patch by Callum Lerwick. This patch rearranges the largest memory allocations so they're allocated as
late as possible, and freed as soon as possible. This cuts memory usage by about half on two large test images.
- Third Patch by Callum Lerwick. The opj_tcd_cblk array is one of the largest allocations, because it
contains a bunch of static buffers. This also makes it a major source of cache thrashing. This patch allocates
the buffers from the heap, and dynamically sizes them in the decoder. I have not yet managed to dynamically size
them in the encoder, getting the decoder to do it was tricky enough... I also split opj_tcd_cblk_t into separate
encode and decode versions. A lot of fields were not used by both, so this cuts its size even further.
* [FOD] Avoided ABI breakage
November 13, 2007
! [FOD] Patch by Dzonatas and Callum Lerwick.
Fp/vectorization patch which basically converts most of the irreversible decode codepath to floating point,
eliminating a few rounds of int/fp conversion, resulting in a vast performance improvement,
and an increase in accuracy.
November 8, 2007
! [FOD] In t1.c, small change to avoid calling twice t1_getwmsedec()
Patches from Callum Lewick:
- Basic gcc optimization flags in cmake and makefile match.
- Fixed some spelling errors in dwt.c.
November 5, 2007
*+ [GB] Fixed a bug which prevented JPWL from working on multi-tiled images; added some more fields in the interface info structures
(keep a list of markers, save start packet number for each tile)
October 23, 2007
* [GB] Improved success for the linux build; OPJViewer shows all the COM contents
October 18, 2007
* [FOD] Changed the ROI parameter in the image_to_j2k codec to make it correspond to the documentation (i.e. -ROI c=0,U=25)
* [FOD] Patch from Callum Lewick. Memset patch.
The main idea of the patch is that currently opj_malloc clears all allocations, which unnecessarily
dirties up the cache and eats bandwidth. This patch makes it no longer do so, and I've painstakingly determined which allocations actually need
to be cleared and changed them to use opj_calloc() instead. I previously tried to just get rid of the opj_*alloc wrappers but that
idea was nixed, so this time I'm trying it with macros. I also put in a gcc pragma that helps enforce their use. Which got messy. :) It caught a
few places they weren't used but it also revealed that the mj2 tools are not very cleanly separated from the library. It includes all the
internal headers, but it wasn't using the malloc wrappers. I figured the binaries should be "external" and have minimal knowledge of the
internals of the library. I patched them to not include opj_includes.h, and include only the internal headers they actually need. However,
they're using the opj_clock() function, which is in with the malloc wrappers. So I decided to move the malloc wrappers to their own header.
But mj2.c seems to want to be "internal", so I patched it to use the wrappers. Note that this patch changes the semantics of opj_malloc, it no longer
clears the memory it allocates. If you need it to be cleared, you must use opj_calloc instead, or memset it yourself. It is also somewhat
invasive, please test it extensively. I've been pounding on it all summer with my test suite, Second Life, and valgrind, and it checks out clean.
October 12, 2007
* [FOD] Changed the way the image structure is allocated when the decoding parameters include some resolutions to discard.
This should have a significant impact for the decoding of huge images when some resolutions are discarder (-r parameter)
Warning: The output image size is now reduced when discarding resolutions !
October 10, 2007
* [FOD] Patch from Callum Lewick. Clean up of j2klib.h for the aligned malloc stuff.
It makes it work right with mingw, as _mm_malloc() isn't a macro, attempts to pave the way to using cmake
to check for this stuff and combines a patch from Dana Fagerstrom at Sun that makes it use memalign() on Solaris
convert.c: Changed some error comments for TIFF images
September 27, 2007
* [FOD] Patch from Callum Lewick. Fixed dwt.c where an alignment in buffer was problematic under x86_64.
September 25, 2007
* [Mathieu Malaterre] BUG: Fix previous patch from Callum Lerwick. I have no
clue what CMAKE_INSTALL_LIBDIR refers too. Bump up cmake 2.2 restriction to
cmake 2.4 because of previous patch (not backward compatible). Properly set the SOVERSION in a cross plateform way (yes WIN32 is a platform)
September 19, 2007
* [Parvatha] Fixed issues with generation of SOP marker.
September 18, 2007
* [Parvatha] Fixed issues with Reading and Writing TIF images in convert.c to avoid segmentation fault.
* [Parvatha] Fixed issues relating to using user specified rates for CINEMA option for multiple images.
September 17, 2007
* [FOD] Fixed issues with cstr_info when codestream has components with different number of resolutions.
! [FOD] OpenJPEG library interface modified to retain compatibility with version 1.2
September 12, 2007
* [FOD] Patch from Callum Lerwick.
Fixed the library linking so it links with the soversion properly set.
Fixes up the install targets so that it interacts properly with RPM.
Install target for MJ2. Sets some necessary and useful CFLAGS if gcc is in use.
* [FOD] Updated the MJ2 codec to be compatible with the recent changes in the OpenJPEG library
September 11, 2007
* [GB] JPWL encoding is finalized correctly into the JP2 file format; added an additional structure in opj_codestream_info, to keep a record of the written markers
September 8, 2007
* [GB] Adapted the JPWL and OPJViewer code to new interface; fixed a samll bug in JPWL which created large EPBs even when null protection was specified
September 7, 2007
+ [FOD] Indexes can now be generated when decoding J2K codestreams.
* [Mathieu Malaterre] Upon failure, properly return error code (!=0).
* [Mathieu Malaterre] CMake: Add cmake code to do testing if user has properly setup a testimages directory
September 6, 2007
+ [Mathieu Malaterre] CMake: start compiling mj2, jpwl and jp3d
+ [Mathieu Malaterre] CMake: output all executable/libs into one single directory
+ [Mathieu Malaterre] CMake: start compiling index_create
+ [Mathieu Malaterre] OpenJPEG.rc update copyright year
+ [Mathieu Malaterre] CMake: add Java j2kviewer but do not compile it using cmake since cmake has too poor support for Java. Should create a custom command running ant instead.
+ [Mathieu Malaterre] CMake: Add doxygen output
+ [GB] One more field in the codestream_info struct for recording the number of packets per tile part; JPWL now distributes the EPBs in all the tile part headers
+ [Mathieu Malaterre] CMake: Add very simple tests (simply run command line with no option)
* [Mathieu Malaterre] Fix unitialized read in img_fol (we may need a smarter initialize than memset)
September 4, 2007
+ [GB] Added some fields in the codestream_info structure: they are used to record the position of single tile parts.
Changed also the write_index function in the codec, to reflect the presence of this new information.
September 3, 2007
+ [GB] Added the knowledge of JPSEC SEC and INSEC markers (you have to compile the JPWL project). Management of these markers is limited to skipping them without crashing:
no real security function at this stage. Deprecated USE_JPSEC will be removed next
August 31, 2007
* [GB] Fixed save capabilities in OPJViewer due to recent code upgrade
August 30, 2007
* [FOD] Changed the OpenJPEG library interface to enable users to access information regarding the codestream (also called codestream index).
This index is usefull for all applications requiring to have a scalable acces to the codestream (like JPIP applications, ...)
Currently, this information is only available when encoding an image.
+ [FOD] Added the information regarding the end of packet position in the index
August 28, 2007
* [FOD] Fixed wrong destructors called in openjpeg.c
* [FOD] Fixed bug in j2k_decode_jpt_stream
August 24, 2007
* [Parvatha] The end of main header is calculated after TLM and POC marker for Dcinema.
August 21, 2007
+ [FOD] Added support for Visual Studio 2005
* [FOD] Robustified MJ2 codecs
* [Parvatha] Solved problems with codec reading from image file directory when filename had more than one "." in name
* [Callum Lerwick] Minor cleanup patch, that gets rid of a bunch of "old style declaration" warnings from Intel's compiler
* [Callum Lerwick] Aligned malloc using Intel's _mm_malloc(). Cleanup on the t1 memory allocation, getting rid of some leftover debug code
* [Callum Lerwick] Memory leaks fixed
* [Callum Lerwick] Reworks of t1_updateflags to get rid of the shift operation
* [Callum Lerwick] mqc_setcurctx moved to the header to allow it to be inlined into the t1.
* [Callum Lerwick] Consolidated some calls to mqc_setcurctx.
* [Callum Lerwick] Cleaned up t1_generate_luts to output the proper types.
* [Callum Lerwick] Replaced the large ctxno_mag lookup table with a small bit of inline-able branchless code
* [Callum Lerwick] Moved the orient flipping into the ctxno_zc table.
August 20, 2007
+ [FOD] Added support for the TGA file format in the codec
August 08, 2007
* [Parvatha] Fixed the DCinema filesize allocation. It now includes the SOT marker size
August 02, 2007
+ [GB] Added a basic saving capability to OPJViewer
July 18, 2007
! [FOD] Updated libtiff library version to 3.8.2 (for WIN32)
* [FOD] Updated BMP and PxM truncation when decoding J2K files with more than 8 bits
July 17, 2007
* [FOD] Fixed raw option for images with more than three components
July 17, 2007
+ [FOD] Added support for RAW images. This module has been developped by the University of Perugia team. Thanks to them ! [image_to_j2k.c j2k_to_image.c convert.c convert.h]
July 13, 2007
! [FOD] Modified the memory allocation for codestreams containing multiple tiles. The memory is now allocated for each tile indenpendently,
leading to an important decrease of the virtual memory needed. [j2k.c tcd.h tcd.c]
! [FOD] Modified old comments about the ability to decode mega-images and comments about the disk size necessary to do this. [image_to_j2k.c and frames_to_mj2.c]
* [FOD] Added 2000 bytes for the memory allocation in cio.c for the minimum size of headers (useful in case of very small images) [cio.c]
July 12, 2007
* [GB] fixed a bug in JPWL module, which prevented to exploit the full error correction capability of RS codes (e.g. it gave up at 5 errors,
even if 6 were correctable); defined a JPWL_MAXIMUM_EPB_ROOM for better customization of the maximum dimension of EPBs (the dimension
is pre-calculated on an hypothesis, if it goes beyond 65535 there will be problems, thus we give a little less than the max, let's say 65450)
July 8, 2007
* [ANTONIN] fixed the size of the memory allocation in cio.c (confusion between bits and bytes)
June 21, 2007
* [FOD] Output image color space set when decoding a JP2 file in jp2.c
+ [GB] Previous, home, and next frame buttons for exploring MJ2 files in OPJViewer
June 18, 2007
* [GB] Reload image doesn't crash in OPJViewer; more settings saved to registry
June 16, 2007
+ [GB] Possibility to disable parsing in OPJViewer; also, saves common settings to the registry
June 15, 2007
* [FOD] Fixed the generation of index files
----------------------
MAY 4, 2007
VERSION 1.2.0 RELEASED
@@ -21,13 +237,16 @@ May 31, 2007
* [FOD] Fixed the parameters used for cinema compression (9-7 transform used instead of 5-3). Modified "image_to_j2k.c"
May 24, 2007
* [FOD] Bug fixed by Sylvain Munaut. Change in the reading of the POC marker. Since COD/COC can be anywhere in the header, the decoder cannot always know while decoding the POC marker the value of numlayers and numresolution.
* [FOD] Bug fixed by Sylvain Munaut. Change in the reading of the POC marker. Since COD/COC can be anywhere in the header, the decoder cannot always know while decoding the POC marker
the value of numlayers and numresolution.
May 23, 2007
! [FOD] Patch suggested by Callum Lerwick <seg@haxxed.com>: "This makes the t1 data arrays dynamic, which greatly reduces cache thrashing. Also, some minor cleanup to prevent unnecessary casts"
May 22, 2007
! [FOD] Patch suggested by Callum Lerwick <seg@haxxed.com>: "Some formatting cleanups, so that the long function definitions and calls fit on screen. Use of prefix increment which is theoretically faster, in practice any sane compiler can optimize a postfix increment but its best not to count on such things. Consolidation of some redundant calculations in the inner loops, which becomes very useful in the future autovectorize patch."
! [FOD] Patch suggested by Callum Lerwick <seg@haxxed.com>: "Some formatting cleanups,
so that the long function definitions and calls fit on screen. Use of prefix increment which is theoretically faster, in practice any sane compiler can optimize a postfix
increment but its best not to count on such things. Consolidation of some redundant calculations in the inner loops, which becomes very useful in the future autovectorize patch."
! [FOD] Patch suggested by Callum Lerwick <seg@haxxed.com>: "This changes the flag code in t1 to use a flag_t type, which can then be changed to reduce RAM usage. It is now typedef to a short."
! [FOD] Patch suggested by Callum Lerwick <seg@haxxed.com>: "This patch makes the t1 LUTs static. I actually intend this as a prelude to possibly eliminating some or all of the LUTs entirely."
@@ -76,14 +295,17 @@ March 29, 2007
* [Parvatha] Equation to check multiple tile precincts. Modification pi.c
! [Parvatha] array size generation of pi->include in pi_initialise_encode().Modification in pi.c
* [Parvatha] modification in pi_create_encode for tile part generation.Modification in pi.c
+ [Parvatha] In tcd_rateallocate a variable stable_threshold which holds the valid threshold value. This is used to avoid error in case of a wrong threshold value in the last iteration. Modification in tcd.c.
+ [Parvatha] In tcd_rateallocate a variable stable_threshold which holds the valid threshold value.
This is used to avoid error in case of a wrong threshold value in the last iteration. Modification in tcd.c.
March 28, 2007
* [FOD] Fixed an historical bug in t1.c that leaded to the inclusion of useless 0xFF in the codestream. Thanks to Sylvain, Pascal and Parvatha !
March 27, 2007
+ [GB] Improved parsing in OPJViewer, as well some minor aesthetic modifications; support for image rendering with bit depths lower than 8 bits; can display an arbitrary frame of an MJ2 file (only in B/W, though); can reload a file; better resizing capabilities
* [GB] Following to Herv<72>'s suggestions, all the exit() calls, added by JPWL strict checking in t2.c and j2k.c, have been substituted with (object free'ing + opj_evt_message(EVT_ERROR) + return)
+ [GB] Improved parsing in OPJViewer, as well some minor aesthetic modifications; support for image rendering with bit depths lower than 8 bits;
can display an arbitrary frame of an MJ2 file (only in B/W, though); can reload a file; better resizing capabilities
* [GB] Following to Herv<72>'s suggestions, all the exit() calls, added by JPWL strict checking in t2.c and j2k.c,
have been substituted with (object free'ing + opj_evt_message(EVT_ERROR) + return)
+ [GB] Added linking to TIFF library in the JPWL VC6 workspaces
March 23, 2007
@@ -129,7 +351,8 @@ VERSION 1.1.1 RELEASED
----------------------
February 23, 2007
* [GB] Fixed a copy-and-paste type assignment error (bool instead of int) in the JPWL section of decoder parameters structure in openjpeg.h; minor type-casting in jpwl_lib.c. As a result, now OPJViewer should run correctly when built against the most current SVN trunk of LibOpenJPEG.lib
* [GB] Fixed a copy-and-paste type assignment error (bool instead of int) in the JPWL section of decoder parameters structure in openjpeg.h; minor type-casting in jpwl_lib.c.
As a result, now OPJViewer should run correctly when built against the most current SVN trunk of LibOpenJPEG.lib
+ [GB] Linux makefile for the JPWL module; newlines at end of JPWL files
February 22, 2007

20
DllOpenJPEG.sln Normal file
View File

@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DllOpenJPEG", "DllOpenJPEG.vcproj", "{89AC992C-5E2C-4E6B-A453-61C1DF446216}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{89AC992C-5E2C-4E6B-A453-61C1DF446216}.Debug|Win32.ActiveCfg = Debug|Win32
{89AC992C-5E2C-4E6B-A453-61C1DF446216}.Debug|Win32.Build.0 = Debug|Win32
{89AC992C-5E2C-4E6B-A453-61C1DF446216}.Release|Win32.ActiveCfg = Release|Win32
{89AC992C-5E2C-4E6B-A453-61C1DF446216}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

670
DllOpenJPEG.vcproj Normal file
View File

@@ -0,0 +1,670 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="DllOpenJPEG"
ProjectGUID="{89AC992C-5E2C-4E6B-A453-61C1DF446216}"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Release/DllOpenJPEG.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
FavorSizeOrSpeed="1"
WholeProgramOptimization="false"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OPJ_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\Release/DllOpenJPEG.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1036"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="Release/OpenJPEG.dll"
LinkIncremental="1"
SuppressStartupBanner="true"
ProgramDatabaseFile=".\Release/OpenJPEG.pdb"
LinkTimeCodeGeneration="0"
ImportLibrary=".\Release/OpenJPEG.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release/DllOpenJPEG.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="if not exist dist mkdir dist&#x0D;&#x0A;copy libopenjpeg\openjpeg.h dist&#x0D;&#x0A;copy Release\OpenJPEG.dll dist&#x0D;&#x0A;copy Release\OpenJPEG.lib dist&#x0D;&#x0A;"
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Debug/DllOpenJPEG.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;OPJ_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug/DllOpenJPEG.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1036"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="Debug/OpenJPEGd.dll"
LinkIncremental="2"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/OpenJPEGd.pdb"
ImportLibrary=".\Debug/OpenJPEGd.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/DllOpenJPEG.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="if not exist dist mkdir dist&#x0D;&#x0A;copy libopenjpeg\openjpeg.h dist&#x0D;&#x0A;copy Debug\OpenJPEGd.dll dist&#x0D;&#x0A;copy Debug\OpenJPEGd.lib dist&#x0D;&#x0A;"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="libopenjpeg\bio.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\cio.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\dwt.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\event.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\image.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\j2k.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\j2k_lib.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\jp2.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\jpt.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\mct.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\mqc.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\openjpeg.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\pi.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\raw.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\t1.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\t2.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\tcd.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\tgt.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl"
>
<File
RelativePath="libopenjpeg\bio.h"
>
</File>
<File
RelativePath="libopenjpeg\cio.h"
>
</File>
<File
RelativePath="libopenjpeg\dwt.h"
>
</File>
<File
RelativePath="libopenjpeg\event.h"
>
</File>
<File
RelativePath="libopenjpeg\fix.h"
>
</File>
<File
RelativePath="libopenjpeg\image.h"
>
</File>
<File
RelativePath="libopenjpeg\int.h"
>
</File>
<File
RelativePath="libopenjpeg\j2k.h"
>
</File>
<File
RelativePath="libopenjpeg\j2k_lib.h"
>
</File>
<File
RelativePath="libopenjpeg\jp2.h"
>
</File>
<File
RelativePath="libopenjpeg\jpt.h"
>
</File>
<File
RelativePath="libopenjpeg\mct.h"
>
</File>
<File
RelativePath="libopenjpeg\mqc.h"
>
</File>
<File
RelativePath="libopenjpeg\openjpeg.h"
>
</File>
<File
RelativePath="libopenjpeg\opj_includes.h"
>
</File>
<File
RelativePath="libopenjpeg\pi.h"
>
</File>
<File
RelativePath="libopenjpeg\raw.h"
>
</File>
<File
RelativePath="libopenjpeg\t1.h"
>
</File>
<File
RelativePath="libopenjpeg\t2.h"
>
</File>
<File
RelativePath="libopenjpeg\tcd.h"
>
</File>
<File
RelativePath="libopenjpeg\tgt.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,53 @@
# Build the demo app, small examples
# First thing define the common source:
SET(common_SRCS
convert.c
)
# Then check if getopt is present:
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
SET(DONT_HAVE_GETOPT 1)
IF(UNIX) #I am pretty sure only *nix sys have this anyway
CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
# Seems like we need the contrary:
IF(CMAKE_HAVE_GETOPT_H)
SET(DONT_HAVE_GETOPT 0)
ENDIF(CMAKE_HAVE_GETOPT_H)
ENDIF(UNIX)
# If not getopt was found then add it to the lib:
IF(DONT_HAVE_GETOPT)
ADD_DEFINITIONS(-DDONT_HAVE_GETOPT)
SET(common_SRCS
${common_SRCS}
compat/getopt.c
)
ENDIF(DONT_HAVE_GETOPT)
# Headers file are located here:
INCLUDE_DIRECTORIES(
${OPENJPEG_SOURCE_DIR}/libopenjpeg
)
# Do the proper thing when building static...if only there was configured
# headers or def files instead
IF(NOT BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DOPJ_STATIC)
ENDIF(NOT BUILD_SHARED_LIBS)
FIND_PACKAGE(TIFF REQUIRED)
# Loop over all executables:
FOREACH(exe j2k_to_image image_to_j2k)
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
TARGET_LINK_LIBRARIES(${exe} ${OPJ_PREFIX}openjpeg ${TIFF_LIBRARIES})
# On unix you need to link to the math library:
IF(UNIX)
TARGET_LINK_LIBRARIES(${exe} -lm)
ENDIF(UNIX)
# Install exe
INSTALL_TARGETS(/bin/ ${exe})
ENDFOREACH(exe)

1989
JavaOpenJPEG/JavaOpenJPEG.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,110 @@
# Microsoft Developer Studio Project File - Name="image_to_j2k" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=image_to_j2k - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "image_to_j2k.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "image_to_j2k.mak" CFG="image_to_j2k - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "image_to_j2k - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "image_to_j2k - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "image_to_j2k - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"libc"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "image_to_j2k - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x40c /d "_DEBUG"
# ADD RSC /l 0x40c /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "image_to_j2k - Win32 Release"
# Name "image_to_j2k - Win32 Debug"
# Begin Source File
SOURCE=.\convert.c
# End Source File
# Begin Source File
SOURCE=.\convert.h
# End Source File
# Begin Source File
SOURCE=.\compat\getopt.c
# End Source File
# Begin Source File
SOURCE=.\compat\getopt.h
# End Source File
# Begin Source File
SOURCE=.\image_to_j2k.c
# End Source File
# End Target
# End Project

View File

@@ -0,0 +1,44 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "LibOpenJPEG"=..\LibOpenJPEG.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "image_to_j2k"=.\image_to_j2k.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name LibOpenJPEG
End Project Dependency
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -0,0 +1,276 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="JavaOpenJPEG"
ProjectGUID="{9D538724-B030-464C-A419-C80B3BC0D020}"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1"
OptimizeForWindowsApplication="TRUE"
AdditionalIncludeDirectories="C:\users\pp\telemis\working\projects\codecs\OpenJPEG2000\codec;../libopenjpeg;&quot;../../../../3rdparty/windows/java-jni/include&quot;;&quot;../../../../3rdparty/windows/java-jni/include/win32&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OPJ_STATIC;CHECK_THRESHOLDS"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
PrecompiledHeaderFile=".\Release/JavaOpenJPEG.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib"
OutputFile="../../dlls/win32/JavaOpenJPEG.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
IgnoreDefaultLibraryNames="libc"
ProgramDatabaseFile=".\Release/JavaOpenJPEG.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Release/JavaOpenJPEG.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1036"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
GlobalOptimizations="FALSE"
InlineFunctionExpansion="0"
FavorSizeOrSpeed="0"
OptimizeForWindowsApplication="FALSE"
AdditionalIncludeDirectories="../libopenjpeg,../../../../3rdparty/windows/java-jni/include,../../../../3rdparty/windows/java-jni/include/win32"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OPJ_STATIC"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug/JavaOpenJPEG.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib"
OutputFile=".\Debug/JavaOpenJPEG.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
IgnoreDefaultLibraryNames="libc"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/JavaOpenJPEG.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/JavaOpenJPEG.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1036"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release64|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1"
OptimizeForWindowsApplication="TRUE"
AdditionalIncludeDirectories="../libopenjpeg;../../../../3rdparty/windows/java-jni/include;../../../../3rdparty/windows/java-jni/include/win32"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OPJ_STATIC"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
PrecompiledHeaderFile=".\Release64/JavaOpenJPEG.pch"
AssemblerListingLocation=".\Release64/"
ObjectFile=".\Release64/"
ProgramDataBaseFileName=".\Release64/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="3"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/machine:AMD64"
AdditionalDependencies="odbc32.lib odbccp32.lib &quot;C:\Program Files\Microsoft Platform SDK\Lib\AMD64\bufferoverflowu.lib&quot;"
OutputFile="../../dlls/win32/JavaOpenJPEG.W64.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
IgnoreDefaultLibraryNames="libc"
ProgramDatabaseFile=".\Release64/JavaOpenJPEG.pdb"
SubSystem="1"
TargetMachine="0"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Release/JavaOpenJPEG.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1036"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\codec\convert.c">
</File>
<File
RelativePath="..\codec\convert.h">
</File>
<File
RelativePath="..\codec\dirent.h">
</File>
<File
RelativePath="..\codec\compat\getopt.c">
</File>
<File
RelativePath="..\codec\compat\getopt.h">
</File>
<File
RelativePath="..\codec\index.c">
</File>
<File
RelativePath="..\codec\index.h">
</File>
<File
RelativePath="JavaOpenJPEG.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release64|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath=".\JavaOpenJPEGDecoder.c">
</File>
<File
RelativePath=".\org_openJpeg_OpenJPEGJavaDecoder.h">
</File>
<File
RelativePath=".\org_openJpeg_OpenJPEGJavaEncoder.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,897 @@
/*
* 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) 2006-2007, Parvatha Elangovan
* Copyright (c) 2007, Patrick Piscaglia (Telemis)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <jni.h>
#include <math.h>
#include "openjpeg.h"
#include "compat/getopt.h"
#include "convert.h"
#include "dirent.h"
#include "org_openJpeg_OpenJPEGJavaDecoder.h"
#ifndef WIN32
#define stricmp strcasecmp
#define strnicmp strncasecmp
#endif
/* ----------------------------------------------------------------------- */
#define J2K_CFMT 0
#define JP2_CFMT 1
#define JPT_CFMT 2
#define PXM_DFMT 10
#define PGX_DFMT 11
#define BMP_DFMT 12
#define YUV_DFMT 13
#define TIF_DFMT 14
#define RAW_DFMT 15
#define TGA_DFMT 16
/* ----------------------------------------------------------------------- */
typedef struct callback_variables {
JNIEnv *env;
/** 'jclass' object used to call a Java method from the C */
jobject *jobj;
/** 'jclass' object used to call a Java method from the C */
jmethodID message_mid;
jmethodID error_mid;
} callback_variables_t;
typedef struct dircnt{
/** Buffer for holding images read from Directory*/
char *filename_buf;
/** Pointer to the buffer*/
char **filename;
}dircnt_t;
typedef struct img_folder{
/** The directory path of the folder containing input images*/
char *imgdirpath;
/** Output format*/
char *out_format;
/** Enable option*/
char set_imgdir;
/** Enable Cod Format for output*/
char set_out_format;
}img_fol_t;
void decode_help_display() {
fprintf(stdout,"HELP\n----\n\n");
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
/* UniPG>> */
fprintf(stdout,"List of parameters for the JPEG 2000 "
#ifdef USE_JPWL
"+ JPWL "
#endif /* USE_JPWL */
"decoder:\n");
/* <<UniPG */
fprintf(stdout,"\n");
fprintf(stdout,"\n");
fprintf(stdout," -ImgDir \n");
fprintf(stdout," Image file Directory path \n");
fprintf(stdout," -OutFor \n");
fprintf(stdout," REQUIRED only if -ImgDir is used\n");
fprintf(stdout," Need to specify only format without filename <BMP> \n");
fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, BMP format\n");
fprintf(stdout," -i <compressed file>\n");
fprintf(stdout," REQUIRED only if an Input image directory not specified\n");
fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
fprintf(stdout," is identified based on its suffix.\n");
fprintf(stdout," -o <decompressed file>\n");
fprintf(stdout," REQUIRED\n");
fprintf(stdout," Currently accepts PGM-files, PPM-files, PNM-files, PGX-files and\n");
fprintf(stdout," BMP-files. Binary data is written to the file (not ascii). If a PGX\n");
fprintf(stdout," filename is given, there will be as many output files as there are\n");
fprintf(stdout," components: an indice starting from 0 will then be appended to the\n");
fprintf(stdout," output filename, just before the \"pgx\" extension. If a PGM filename\n");
fprintf(stdout," is given and there are more than one component, only the first component\n");
fprintf(stdout," will be written to the file.\n");
fprintf(stdout," -r <reduce factor>\n");
fprintf(stdout," Set the number of highest resolution levels to be discarded. The\n");
fprintf(stdout," image resolution is effectively divided by 2 to the power of the\n");
fprintf(stdout," number of discarded levels. The reduce factor is limited by the\n");
fprintf(stdout," smallest total number of decomposition levels among tiles.\n");
fprintf(stdout," -l <number of quality layers to decode>\n");
fprintf(stdout," Set the maximum number of quality layers to decode. If there are\n");
fprintf(stdout," less quality layers than the specified number, all the quality layers\n");
fprintf(stdout," are decoded.\n");
/* UniPG>> */
#ifdef USE_JPWL
fprintf(stdout," -W <options>\n");
fprintf(stdout," Activates the JPWL correction capability, if the codestream complies.\n");
fprintf(stdout," Options can be a comma separated list of <param=val> tokens:\n");
fprintf(stdout," c, c=numcomps\n");
fprintf(stdout," numcomps is the number of expected components in the codestream\n");
fprintf(stdout," (search of first EPB rely upon this, default is %d)\n", JPWL_EXPECTED_COMPONENTS);
#endif /* USE_JPWL */
/* <<UniPG */
fprintf(stdout,"\n");
}
/* -------------------------------------------------------------------------- */
int get_num_images(char *imgdirpath){
DIR *dir;
struct dirent* content;
int num_images = 0;
/*Reading the input images from given input directory*/
dir= opendir(imgdirpath);
if(!dir){
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
return 0;
}
while((content=readdir(dir))!=NULL){
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
continue;
num_images++;
}
return num_images;
}
int load_images(dircnt_t *dirptr, char *imgdirpath){
DIR *dir;
struct dirent* content;
int i = 0;
/*Reading the input images from given input directory*/
dir= opendir(imgdirpath);
if(!dir){
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
return 1;
}else {
fprintf(stderr,"Folder opened successfully\n");
}
while((content=readdir(dir))!=NULL){
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
continue;
strcpy(dirptr->filename[i],content->d_name);
i++;
}
return 0;
}
int get_file_format(char *filename) {
unsigned int i;
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "j2k", "jp2", "jpt", "j2c" };
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT };
char * ext = strrchr(filename, '.');
if (ext == NULL)
return -1;
ext++;
if(ext) {
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
if(strnicmp(ext, extension[i], 3) == 0) {
return format[i];
}
}
}
return -1;
}
/* -------------------------------------------------------------------------- */
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
/* parse the command line */
int totlen;
option_t long_option[]={
{"ImgDir",REQ_ARG, NULL ,'y'},
{"OutFor",REQ_ARG, NULL ,'O'},
};
/* UniPG>> */
const char optlist[] = "i:o:r:l:hx:"
#ifdef USE_JPWL
"W:"
#endif /* USE_JPWL */
;
/*for (i=0; i<argc; i++) {
printf("[%s]",argv[i]);
}
printf("\n");*/
/* <<UniPG */
totlen=sizeof(long_option);
img_fol->set_out_format = 0;
reset_options_reading();
while (1) {
int c = getopt_long(argc, argv,optlist,long_option,totlen);
if (c == -1)
break;
switch (c) {
case 'i': /* input file */
{
char *infile = optarg;
parameters->decod_format = get_file_format(infile);
switch(parameters->decod_format) {
case J2K_CFMT:
case JP2_CFMT:
case JPT_CFMT:
break;
default:
fprintf(stderr,
"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
infile);
return 1;
}
strncpy(parameters->infile, infile, sizeof(parameters->infile)-1);
}
break;
/* ----------------------------------------------------- */
case 'o': /* output file */
{
char *outfile = optarg;
parameters->cod_format = get_file_format(outfile);
switch(parameters->cod_format) {
case PGX_DFMT:
case PXM_DFMT:
case BMP_DFMT:
case TIF_DFMT:
case RAW_DFMT:
case TGA_DFMT:
break;
default:
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outfile);
return 1;
}
strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
}
break;
/* ----------------------------------------------------- */
case 'O': /* output format */
{
char outformat[50];
char *of = optarg;
sprintf(outformat,".%s",of);
img_fol->set_out_format = 1;
parameters->cod_format = get_file_format(outformat);
switch(parameters->cod_format) {
case PGX_DFMT:
img_fol->out_format = "pgx";
break;
case PXM_DFMT:
img_fol->out_format = "ppm";
break;
case BMP_DFMT:
img_fol->out_format = "bmp";
break;
case TIF_DFMT:
img_fol->out_format = "tif";
break;
case RAW_DFMT:
img_fol->out_format = "raw";
break;
case TGA_DFMT:
img_fol->out_format = "raw";
break;
default:
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outformat);
return 1;
break;
}
}
break;
/* ----------------------------------------------------- */
case 'r': /* reduce option */
{
sscanf(optarg, "%d", &parameters->cp_reduce);
}
break;
/* ----------------------------------------------------- */
case 'l': /* layering option */
{
sscanf(optarg, "%d", &parameters->cp_layer);
}
break;
/* ----------------------------------------------------- */
case 'h': /* display an help description */
decode_help_display();
return 1;
/* ------------------------------------------------------ */
case 'y': /* Image Directory path */
{
img_fol->imgdirpath = (char*)malloc(strlen(optarg) + 1);
strcpy(img_fol->imgdirpath,optarg);
img_fol->set_imgdir=1;
}
break;
/* ----------------------------------------------------- */
/* UniPG>> */
#ifdef USE_JPWL
case 'W': /* activate JPWL correction */
{
char *token = NULL;
token = strtok(optarg, ",");
while(token != NULL) {
/* search expected number of components */
if (*token == 'c') {
static int compno;
compno = JPWL_EXPECTED_COMPONENTS; /* predefined no. of components */
if(sscanf(token, "c=%d", &compno) == 1) {
/* Specified */
if ((compno < 1) || (compno > 256)) {
fprintf(stderr, "ERROR -> invalid number of components c = %d\n", compno);
return 1;
}
parameters->jpwl_exp_comps = compno;
} else if (!strcmp(token, "c")) {
/* default */
parameters->jpwl_exp_comps = compno; /* auto for default size */
} else {
fprintf(stderr, "ERROR -> invalid components specified = %s\n", token);
return 1;
};
}
/* search maximum number of tiles */
if (*token == 't') {
static int tileno;
tileno = JPWL_MAXIMUM_TILES; /* maximum no. of tiles */
if(sscanf(token, "t=%d", &tileno) == 1) {
/* Specified */
if ((tileno < 1) || (tileno > JPWL_MAXIMUM_TILES)) {
fprintf(stderr, "ERROR -> invalid number of tiles t = %d\n", tileno);
return 1;
}
parameters->jpwl_max_tiles = tileno;
} else if (!strcmp(token, "t")) {
/* default */
parameters->jpwl_max_tiles = tileno; /* auto for default size */
} else {
fprintf(stderr, "ERROR -> invalid tiles specified = %s\n", token);
return 1;
};
}
/* next token or bust */
token = strtok(NULL, ",");
};
parameters->jpwl_correct = true;
fprintf(stdout, "JPWL correction capability activated\n");
fprintf(stdout, "- expecting %d components\n", parameters->jpwl_exp_comps);
}
break;
#endif /* USE_JPWL */
/* <<UniPG */
/* ----------------------------------------------------- */
default:
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
break;
}
}
/* No check for possible errors before the -i and -o options are of course not mandatory*/
return 0;
}
/* -------------------------------------------------------------------------- */
/**
error callback returning the message to Java andexpecting a callback_variables_t client object
*/
void error_callback(const char *msg, void *client_data) {
callback_variables_t* vars = (callback_variables_t*) client_data;
JNIEnv *env = vars->env;
jstring jbuffer;
jbuffer = (*env)->NewStringUTF(env, msg);
(*env)->ExceptionClear(env);
(*env)->CallVoidMethod(env, *(vars->jobj), vars->error_mid, jbuffer);
if ((*env)->ExceptionOccurred(env)) {
fprintf(stderr,"C: Exception during call back method\n");
(*env)->ExceptionDescribe(env);
(*env)->ExceptionClear(env);
}
(*env)->DeleteLocalRef(env, jbuffer);
}
/**
warning callback returning the message to Java andexpecting a callback_variables_t client object
*/
void warning_callback(const char *msg, void *client_data) {
callback_variables_t* vars = (callback_variables_t*) client_data;
JNIEnv *env = vars->env;
jstring jbuffer;
jbuffer = (*env)->NewStringUTF(env, msg);
(*env)->ExceptionClear(env);
(*env)->CallVoidMethod(env, *(vars->jobj), vars->message_mid, jbuffer);
if ((*env)->ExceptionOccurred(env)) {
fprintf(stderr,"C: Exception during call back method\n");
(*env)->ExceptionDescribe(env);
(*env)->ExceptionClear(env);
}
(*env)->DeleteLocalRef(env, jbuffer);
}
/**
information callback returning the message to Java andexpecting a callback_variables_t client object
*/
void info_callback(const char *msg, void *client_data) {
callback_variables_t* vars = (callback_variables_t*) client_data;
JNIEnv *env = vars->env;
jstring jbuffer;
jbuffer = (*env)->NewStringUTF(env, msg);
(*env)->ExceptionClear(env);
(*env)->CallVoidMethod(env, *(vars->jobj), vars->message_mid, jbuffer);
if ((*env)->ExceptionOccurred(env)) {
fprintf(stderr,"C: Exception during call back method\n");
(*env)->ExceptionDescribe(env);
(*env)->ExceptionClear(env);
}
(*env)->DeleteLocalRef(env, jbuffer);
}
/* --------------------------------------------------------------------------
-------------------- 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 */
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 */
opj_image_t *image = NULL;
FILE *fsrc = NULL;
unsigned char *src = NULL;
int file_length;
int num_images;
int i,j,imageno;
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
opj_cio_t *cio = NULL;
int w,h;
long min_value, max_value;
short tempS; unsigned char tempUC, tempUC1, tempUC2;
// ==> Access variables to the Java member variables
jsize arraySize;
jclass cls;
jobject object;
jboolean isCopy;
jfieldID fid;
jbyteArray jba;
jshortArray jsa;
jintArray jia;
jbyte *jbBody, *ptrBBody;
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
/* configure the event callbacks */
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
event_mgr.error_handler = error_callback;
event_mgr.warning_handler = warning_callback;
event_mgr.info_handler = info_callback;
// 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
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, and converts it into a char** to simulate command line arguments.
arraySize = (*env)->GetArrayLength(env, javaParameters);
argc = (int) arraySize +1;
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);
argv[i] = (*env)->GetStringUTFChars(env, object, &isCopy);
}
/*printf("C: decoder params = ");
for (i=0; i<argc; i++) {
printf("[%s]",argv[i]);
}
printf("\n");*/
/* set decoding parameters to default values */
opj_set_default_decoder_parameters(&parameters);
parameters.decod_format = J2K_CFMT;
/* parse input and get user encoding parameters */
if(parse_cmdline_decoder(argc, argv, &parameters,&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]);
num_images=1;
// Get additional information from the Java object variables
fid = (*env)->GetFieldID(env, cls,"skippedResolutions", "I");
parameters.cp_reduce = (short) (*env)->GetIntField(env, obj, fid);
/*Decoding image one by one*/
for(imageno = 0; imageno < num_images ; imageno++)
{
image = NULL;
fprintf(stderr,"\n");
/* read the input file and put it in memory into the 'src' object, if the -i option is given in JavaParameters.
Implemented for debug purpose. */
/* -------------------------------------------------------------- */
if (parameters.infile && parameters.infile[0]!='\0') {
//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);
return 1;
}
fseek(fsrc, 0, SEEK_END);
file_length = ftell(fsrc);
fseek(fsrc, 0, SEEK_SET);
src = (unsigned char *) malloc(file_length);
fread(src, 1, file_length, fsrc);
fclose(fsrc);
//printf("C: %d bytes read from file\n",file_length);
} else {
// 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);
jbBody = (*env)->GetByteArrayElements(env, jba, &isCopy);
src = (unsigned char*)jbBody;
}
/* decode the code-stream */
/* ---------------------- */
switch(parameters.decod_format) {
case J2K_CFMT:
{
/* JPEG-2000 codestream */
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_J2K);
/* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, &msgErrorCallback_vars);
/* setup the decoder decoding parameters using user parameters */
opj_setup_decoder(dinfo, &parameters);
/* open a byte stream */
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */
image = opj_decode(dinfo, cio);
if(!image) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
opj_destroy_decompress(dinfo);
opj_cio_close(cio);
return 1;
}
/* close the byte stream */
opj_cio_close(cio);
}
break;
case JP2_CFMT:
{
/* JPEG 2000 compressed image data */
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_JP2);
/* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, &msgErrorCallback_vars);
/* setup the decoder decoding parameters using the current image and user parameters */
opj_setup_decoder(dinfo, &parameters);
/* open a byte stream */
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */
image = opj_decode(dinfo, cio);
if(!image) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
opj_destroy_decompress(dinfo);
opj_cio_close(cio);
return 1;
}
/* close the byte stream */
opj_cio_close(cio);
}
break;
case JPT_CFMT:
{
/* JPEG 2000, JPIP */
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_JPT);
/* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, &msgErrorCallback_vars);
/* setup the decoder decoding parameters using user parameters */
opj_setup_decoder(dinfo, &parameters);
/* open a byte stream */
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */
image = opj_decode(dinfo, cio);
if(!image) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
opj_destroy_decompress(dinfo);
opj_cio_close(cio);
return 1;
}
/* close the byte stream */
opj_cio_close(cio);
}
break;
default:
fprintf(stderr, "skipping file..\n");
continue;
}
/* free the memory containing the code-stream */
if (parameters.infile && parameters.infile[0]!='\0') {
free(src);
} else {
(*env)->ReleaseByteArrayElements(env, jba, jbBody, 0);
}
src = NULL;
/* create output image.
If the -o parameter is given in the JavaParameters, write the decoded version into a file.
Implemented for debug purpose. */
/* ---------------------------------- */
switch (parameters.cod_format) {
case PXM_DFMT: /* PNM PGM PPM */
if (imagetopnm(image, parameters.outfile)) {
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
}
else {
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
}
break;
case PGX_DFMT: /* PGX */
if(imagetopgx(image, parameters.outfile)){
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
}
else {
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
}
break;
case BMP_DFMT: /* BMP */
if(imagetobmp(image, parameters.outfile)){
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
}
else {
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
}
break;
}
// ========= 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;
w = image->comps[0].w;
h = image->comps[0].h;
if (image->numcomps==3) { // 3 components color image
ptr = image->comps[0].data;
ptr1 = image->comps[1].data;
ptr2 = image->comps[2].data;
#ifdef CHECK_THRESHOLDS
if (image->comps[0].sgnd) {
min_value = 0;
max_value = 255;
} else {
min_value = -128;
max_value = 127;
}
#endif
// 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: 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]);
tempUC1 = (unsigned char)(ptr1[i]);
tempUC2 = (unsigned char)(ptr2[i]);
#ifdef CHECK_THRESHOLDS
if (tempUC < min_value)
tempUC=min_value;
else if (tempUC > max_value)
tempUC=max_value;
if (tempUC1 < min_value)
tempUC1=min_value;
else if (tempUC1 > max_value)
tempUC1=max_value;
if (tempUC2 < min_value)
tempUC2=min_value;
else if (tempUC2 > max_value)
tempUC2=max_value;
#endif
*(ptrIBody++) = (int) ( (tempUC2<<16) + (tempUC1<<8) + tempUC );
}
(*env)->ReleaseIntArrayElements(env, jia, jiBody, 0);
} else { // 1 component 8 or 16 bpp image
ptr = image->comps[0].data;
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);
jbBody = (*env)->GetByteArrayElements(env, jba, 0);
ptrBBody = jbBody;
#ifdef CHECK_THRESHOLDS
if (image->comps[0].sgnd) {
min_value = 0;
max_value = 255;
} else {
min_value = -128;
max_value = 127;
}
#endif
//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
if (tempUC<min_value)
tempUC = min_value;
else if (tempUC > max_value)
tempUC = max_value;
#endif
*(ptrBBody++) = tempUC;
}
(*env)->ReleaseByteArrayElements(env, jba, jbBody, 0);
printf("C: image8 transfered to Java\n");
} else {
fid = (*env)->GetFieldID(env, cls,"image16", "[S");
jsa = (*env)->GetObjectField(env, obj, fid);
jsBody = (*env)->GetShortArrayElements(env, jsa, 0);
ptrSBody = jsBody;
#ifdef CHECK_THRESHOLDS
if (image->comps[0].sgnd) {
min_value = 0;
max_value = 65535;
} else {
min_value = -32768;
max_value = 32767;
}
printf("C: minValue = %d, maxValue = %d\n", min_value, max_value);
#endif
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
if (tempS<min_value) {
printf("C: value %d truncated to %d\n", tempS, min_value);
tempS = min_value;
} else if (tempS > max_value) {
printf("C: value %d truncated to %d\n", tempS, max_value);
tempS = max_value;
}
#endif
*(ptrSBody++) = tempS;
}
(*env)->ReleaseShortArrayElements(env, jsa, jsBody, 0);
printf("C: image16 completely filled\n");
}
}
/* free remaining structures */
if(dinfo) {
opj_destroy_decompress(dinfo);
}
/* free image data structure */
opj_image_destroy(image);
}
return 1; /* OK */
}
//end main

14
JavaOpenJPEG/Makefile Normal file
View File

@@ -0,0 +1,14 @@
# Makefile for the main OpenJPEG codecs: j2k_to_image and image_to_j2k
CFLAGS = -O3 -lstdc++ # -g -p -pg
all: j2k_to_image image_to_j2k
j2k_to_image: j2k_to_image.c ../libopenjpeg.a
gcc $(CFLAGS) compat/getopt.c convert.c j2k_to_image.c -o j2k_to_image -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
image_to_j2k: image_to_j2k.c ../libopenjpeg.a
gcc $(CFLAGS) compat/getopt.c convert.c image_to_j2k.c -o image_to_j2k -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
clean:
rm -f j2k_to_image image_to_j2k

View File

@@ -0,0 +1,230 @@
/*
* $Id: $
*
* Copyright (c) 1999-2007 Telemis SA. All Rights Reserved
* Author: Patrick Piscaglia, Telemis s.a.
*/
package org.openJpeg;
import java.util.Vector;
/** This class decodes one J2K codestream into an image (width + height + depth + pixels[],
* using the OpenJPEG.org library.
* To be able to log messages, the called must register a IJavaJ2KDecoderLogger object.
*/
public class OpenJPEGJavaDecoder {
public interface IJavaJ2KDecoderLogger {
public void logDecoderMessage(String message);
public void logDecoderError(String message);
}
private static boolean isInitialized = false;
// ===== decompression parameters =============>
// These value may be changed for each image
private String[] decoder_arguments = null;
/** number of resolutions decompositions */
private int nbResolutions = -1;
/** the quality layers */
private int[] layers = null;
/** Contains the 8 bpp version of the image. May NOT be filled together with image16 or image24.<P>
* We store in Java the 8 or 16 bpp version of the image while the decoder uses a 32 bpp version, because <UL>
* <LI> the storage capacity required is smaller
* <LI> the transfer Java <-- C will be faster
* <LI> the conversion byte/short ==> int will be done faster by the C
* </UL>*/
private byte[] image8 = null;
/** Contains the 16 bpp version of the image. May NOT be filled together with image8 or image24*/
private short[] image16 = null;
/** Contains the 24 bpp version of the image. May NOT be filled together with image8 or image16 */
private int[] image24 = null;
/** Holds the J2K compressed bytecode to decode */
private byte compressedStream[] = null;
/** Holds the compressed version of the index file, to be used by the decoder */
private byte compressedIndex[] = null;
/** Width and Height of the image */
private int width = -1;
private int height = -1;
private int depth = -1;
/** This parameter is never used in Java but is read by the C library to know the number of resolutions to skip when decoding,
* i.e. if there are 5 resolutions and skipped=1 ==> decode until resolution 4. */
private int skippedResolutions = 0;
private Vector<IJavaJ2KDecoderLogger> loggers = new Vector();
public OpenJPEGJavaDecoder(String openJPEGlibraryFullPathAndName, IJavaJ2KDecoderLogger messagesAndErrorsLogger) throws ExceptionInInitializerError
{
this(openJPEGlibraryFullPathAndName);
loggers.addElement(messagesAndErrorsLogger);
}
public OpenJPEGJavaDecoder(String openJPEGlibraryFullPathAndName) throws ExceptionInInitializerError
{
if (!isInitialized) {
try {
System.load(openJPEGlibraryFullPathAndName);
isInitialized = true;
} catch (Throwable t) {
throw new ExceptionInInitializerError("OpenJPEG Java Decoder: probably impossible to find the C library");
}
}
}
public void addLogger(IJavaJ2KDecoderLogger messagesAndErrorsLogger) {
loggers.addElement(messagesAndErrorsLogger);
}
public void removeLogger(IJavaJ2KDecoderLogger messagesAndErrorsLogger) {
loggers.removeElement(messagesAndErrorsLogger);
}
public int decodeJ2KtoImage() {
if ((image16 == null || (image16 != null && image16.length != width*height)) && (depth==-1 || depth==16)) {
image16 = new short[width*height];
logMessage("OpenJPEGJavaDecoder.decompressImage: image16 length = " + image16.length + " (" + width + " x " + height + ") ");
}
if ((image8 == null || (image8 != null && image8.length != width*height)) && (depth==-1 || depth==8)) {
image8 = new byte[width*height];
logMessage("OpenJPEGJavaDecoder.decompressImage: image8 length = " + image8.length + " (" + width + " x " + height + ") ");
}
if ((image24 == null || (image24 != null && image24.length != width*height)) && (depth==-1 || depth==24)) {
image24 = new int[width*height];
logMessage("OpenJPEGJavaDecoder.decompressImage: image24 length = " + image24.length + " (" + width + " x " + height + ") ");
}
String[] arguments = new String[0 + (decoder_arguments != null ? decoder_arguments.length : 0)];
int offset = 0;
if (decoder_arguments != null) {
for (int i=0; i<decoder_arguments.length; i++) {
arguments[i+offset] = decoder_arguments[i];
}
}
return internalDecodeJ2KtoImage(arguments);
}
/**
* Decode the j2k stream given in the codestream byte[] and fills the image8, image16 or image24 array, according to the bit depth.
*/
private native int internalDecodeJ2KtoImage(String[] parameters);
/** Image depth in bpp */
public int getDepth() {
return depth;
}
/** Image depth in bpp */
public void setDepth(int depth) {
this.depth = depth;
}
/** Image height in pixels */
public int getHeight() {
return height;
}
/** Image height in pixels */
public void setHeight(int height) {
this.height = height;
}
/** Number of resolutions contained in the image */
public int getNbResolutions() {
return nbResolutions;
}
/** Number of resolutions contained in the image */
public void setNbResolutions(int nbResolutions) {
this.nbResolutions = nbResolutions;
}
/** Width of the image in pixels */
public int getWidth() {
return width;
}
/** Width of the image in pixels */
public void setWidth(int width) {
this.width = width;
}
/** Contains the decompressed version of the image, if the depth in is [9,16] bpp.
* Returns NULL otherwise.
*/
public short[] getImage16() {
return image16;
}
/** Contains the decompressed version of the image, if the depth in is [17,24] bpp and the image is in color.
* Returns NULL otherwise.
*/
public int[] getImage24() {
return image24;
}
/** Contains the decompressed version of the image, if the depth in is [1,8] bpp.
* Returns NULL otherwise.
*/
public byte[] getImage8() {
return image8;
}
/** Sets the compressed version of the index file for this image.
* This index file is used by the decompressor
*/
public void setCompressedIndex(byte[] compressedIndex) {
this.compressedIndex = compressedIndex;
}
/** Sets the codestream to be decoded */
public void setCompressedStream(byte[] compressedStream) {
this.compressedStream = compressedStream;
}
/** @return the compressed code stream length, or -1 if not defined */
public long getCodestreamLength() {
if (compressedStream == null)
return -1;
else return compressedStream.length;
}
/** This method is called either directly or by the C methods */
public void logMessage(String message) {
for (IJavaJ2KDecoderLogger logger:loggers)
logger.logDecoderMessage(message);
}
/** This method is called either directly or by the C methods */
public void logError(String error) {
for (IJavaJ2KDecoderLogger logger:loggers)
logger.logDecoderError(error);
}
public void reset() {
nbResolutions = -1;
layers = null;
image8 = null;
image16 = null;
image24 = null;
compressedStream = null;
compressedIndex = null;
width = -1;
height = -1;
depth = -1;
}
public void setSkippedResolutions(int numberOfSkippedResolutions) {
skippedResolutions = numberOfSkippedResolutions;
}
/** Contains all the decoding arguments other than the input/output file */
public void setDecoderArguments(String[] argumentsForTheDecoder) {
decoder_arguments = argumentsForTheDecoder;
}
}

View File

@@ -0,0 +1,318 @@
/*
* $Id: $
*
* Copyright (c) 1999-2007 Telemis SA. All Rights Reserved
*
* Author: Patrick Piscaglia, Telemis s.a.
*/
package org.openJpeg;
import java.io.File;
import java.util.Vector;
/** This class encodes one image into the J2K format,
* using the OpenJPEG.org library.
* To be able to log messages, the called must register a IJavaJ2KEncoderLogger object.
*/
public class OpenJPEGJavaEncoder {
public interface IJavaJ2KEncoderLogger {
public void logEncoderMessage(String message);
public void logEncoderError(String message);
}
private static boolean isInitialized = false;
// ===== Compression parameters =============>
// These value may be changed for each image
private String[] encoder_arguments = null;
/** number of resolutions decompositions */
private int nbResolutions = -1;
/** the quality layers, expressed as compression rate */
private float[] ratioLayers = null;
/** the quality layers, expressed as PSNR values. This variable, if defined, has priority over the ratioLayers variable */
private float[] psnrLayers = null;
/** Contains the 8 bpp version of the image. May NOT be filled together with image16 or image24.<P>
* We store the 8 or 16 bpp version of the original image while the encoder uses a 32 bpp version, because <UL>
* <LI> the storage capacity required is smaller
* <LI> the transfer Java --> C will be faster
* <LI> the conversion byte/short ==> int will be done faster by the C
* </UL>*/
private byte[] image8 = null;
/** Contains the 16 bpp version of the image. May NOT be filled together with image8 or image24*/
private short[] image16 = null;
/** Contains the 24 bpp version of the image. May NOT be filled together with image8 or image16 */
private int[] image24 = null;
/** Holds the result of the compression, i.e. the J2K compressed bytecode */
private byte compressedStream[] = null;
/** Holds the compressed stream length, which may be smaller than compressedStream.length if this byte[] is pre-allocated */
private long compressedStreamLength = -1;
/** Holds the compressed version of the index file, returned by the encoder */
private byte compressedIndex[] = null;
/** Width and Height of the image */
private int width = -1;
private int height = -1;
private int depth = -1;
/** Tile size. We suppose the same size for the horizontal and vertical tiles.
* If size == -1 ==> no tiling */
private int tileSize = -1;
// <===== Compression parameters =============
private Vector<IJavaJ2KEncoderLogger> loggers = new Vector();
public OpenJPEGJavaEncoder(String openJPEGlibraryFullPathAndName, IJavaJ2KEncoderLogger messagesAndErrorsLogger) throws ExceptionInInitializerError
{
this(openJPEGlibraryFullPathAndName);
loggers.addElement(messagesAndErrorsLogger);
}
public OpenJPEGJavaEncoder(String openJPEGlibraryFullPathAndName) throws ExceptionInInitializerError
{
if (!isInitialized) {
try {
String absolutePath = (new File(openJPEGlibraryFullPathAndName)).getCanonicalPath();
System.load(absolutePath);
isInitialized = true;
} catch (Throwable t) {
t.printStackTrace();
throw new ExceptionInInitializerError("OpenJPEG Java Encoder: probably impossible to find the C library");
}
}
}
public void addLogger(IJavaJ2KEncoderLogger messagesAndErrorsLogger) {
loggers.addElement(messagesAndErrorsLogger);
}
public void removeLogger(IJavaJ2KEncoderLogger messagesAndErrorsLogger) {
loggers.removeElement(messagesAndErrorsLogger);
}
/** This method compresses the given image.<P>
* It returns the compressed J2K codestream into the compressedStream byte[].<P>
* It also returns the compression index as a compressed form, into the compressedIndex byte[].<P>
* One of the image8, image16 or image24 arrays must be correctly initialized and filled.<P>
* The width, height and depth variables must be correctly filled.<P>
* The nbResolutions, nbLayers and if needed the float[] psnrLayers or ratioLayers must also be filled before calling this method.
*/
public void encodeImageToJ2K() {
// Need to allocate / reallocate the compressed stream buffer ? (size = max possible size = original image size)
if (compressedStream== null || (compressedStream.length != width*height*depth/8)) {
logMessage("OpenJPEGJavaEncoder.encodeImageToJ2K: (re-)allocating " + (width*height*depth/8) + " bytes for the compressedStream");
compressedStream = new byte[width*height*depth/8];
}
// Arguments =
// - number of resolutions "-n 5" : 2
// - size of tile "-t 512,512" : 2
//
// Image width, height, depth and pixels are directly fetched by C from the Java class
int nbArgs = 2 + (tileSize == -1 ? 0 : 2) + (encoder_arguments != null ? encoder_arguments.length : 0);
if (psnrLayers != null && psnrLayers.length>0 && psnrLayers[0] != 0)
// If psnrLayers is defined and doesn't just express "lossless"
nbArgs += 2;
else if (ratioLayers != null && ratioLayers.length>0 && ratioLayers[0]!=0.0)
nbArgs += 2;
String[] arguments = new String[nbArgs];
int offset = 0;
arguments[offset] = "-n"; arguments[offset+1] = "" + nbResolutions; offset += 2;
if (tileSize!= -1) {
arguments[offset++] = "-t";
arguments[offset++] = "" + tileSize + "," + tileSize;
}
// If PSNR layers are defined, use them to encode the images
if (psnrLayers != null && psnrLayers.length>0 && psnrLayers[0]!=-1) {
arguments[offset++] = "-q";
String s = "";
for (int i=0; i<psnrLayers.length; i++)
s += psnrLayers[i] + ",";
arguments[offset++] = s.substring(0, s.length()-1);
} else if (ratioLayers != null && ratioLayers.length>0 && ratioLayers[0]!=0.0) {
// Specify quality ratioLayers, as compression ratios
arguments[offset++] = "-r";
String s = "";
for (int i=0; i<ratioLayers.length; i++)
s += ratioLayers[i] + ",";
arguments[offset++] = s.substring(0, s.length()-1);
}
if (encoder_arguments != null) {
for (int i=0; i<encoder_arguments.length; i++) {
arguments[i+offset] = encoder_arguments[i];
}
}
logMessage("Encoder additional arguments = " + arrayToString(arguments));
long startTime = (new java.util.Date()).getTime();
compressedStreamLength = internalEncodeImageToJ2K(arguments);
logMessage("compression time = " + ((new java.util.Date()).getTime() - startTime) + " msec");
}
/**
* Fills the compressedStream byte[] and the compressedIndex byte[]
* @return the codestream length.
*/
private native long internalEncodeImageToJ2K(String[] parameters);
/** Image depth in bpp */
public int getDepth() {
return depth;
}
/** Image depth in bpp */
public void setDepth(int depth) {
this.depth = depth;
}
/** Image height in pixels */
public int getHeight() {
return height;
}
/** Image height in pixels */
public void setHeight(int height) {
this.height = height;
}
/** This method must be called in depth in [9,16].
* @param an array of shorts, containing width*height values
*/
public void setImage16(short[] image16) {
this.image16 = image16;
}
/** This method must be called in depth in [17,24] for RGB images.
* @param an array of int, containing width*height values
*/
public void setImage24(int[] image24) {
this.image24 = image24;
}
/** This method must be called in depth in [1,8].
* @param an array of bytes, containing width*height values
*/
public void setImage8(byte[] image8) {
this.image8 = image8;
}
/** Return the ratioLayers, i.e. the compression ratio for each quality layer.
* If the last value is 0.0, last layer is lossless compressed.
*/
public float[] getRatioLayers() {
return ratioLayers;
}
/**
* sets the quality layers.
* At least one level.
* Each level is expressed as a compression ratio (float).
* If the last value is 0.0, the last layer will be losslessly compressed
*/
public void setRatioLayers(float[] layers) {
this.ratioLayers = layers;
}
/** Return the PSNR Layers, i.e. the target PSNR for each quality layer.
* If the last value is -1, last layer is lossless compressed.
*/
public float[] getPsnrLayers() {
return psnrLayers;
}
/**
* sets the quality layers.
* At least one level.
* Each level is expressed as a target PSNR (float).
* If the last value is -1, the last layer will be losslessly compressed
*/
public void setPsnrLayers(float[] layers) {
this.psnrLayers = layers;
}
/** Set the number of resolutions that must be created */
public void setNbResolutions(int nbResolutions) {
this.nbResolutions = nbResolutions;
}
public int getWidth() {
return width;
}
/** Width of the image, in pixels */
public void setWidth(int width) {
this.width = width;
}
/** Return the compressed index file.
* Syntax: TODO PP:
*/
public byte[] getCompressedIndex() {
return compressedIndex;
}
public void setCompressedIndex(byte[] index) {
compressedIndex = index;
}
public byte[] getCompressedStream() {
return compressedStream;
}
public void reset() {
nbResolutions = -1;
ratioLayers = null;
psnrLayers = null;
image8 = null;
image16 = null;
image24 = null;
compressedStream = null;
compressedIndex = null;
width = -1;
height = -1;
depth = -1;
}
public short[] getImage16() {
return image16;
}
public int[] getImage24() {
return image24;
}
public byte[] getImage8() {
return image8;
}
/** Sets the size of the tiles. We assume square tiles */
public void setTileSize(int tileSize) {
this.tileSize = tileSize;
}
/** Contains all the encoding arguments other than the input/output file, compression ratio, tile size */
public void setEncoderArguments(String[] argumentsForTheEncoder) {
encoder_arguments = argumentsForTheEncoder;
}
public void logMessage(String message) {
for (IJavaJ2KEncoderLogger logger:loggers)
logger.logEncoderMessage(message);
}
public void logError(String error) {
for (IJavaJ2KEncoderLogger logger:loggers)
logger.logEncoderError(error);
}
public long getCompressedStreamLength() {
return compressedStreamLength;
}
private String arrayToString(String[] array) {
if (array == null)
return "NULL";
StringBuffer sb = new StringBuffer();
for (int i=0; i<array.length; i++)
sb.append(array[i]).append(" ");
sb.delete(sb.length()-1, sb.length());
return sb.toString();
}
}

View File

@@ -0,0 +1,21 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_openJpeg_OpenJPEGJavaDecoder */
#ifndef _Included_org_openJpeg_OpenJPEGJavaDecoder
#define _Included_org_openJpeg_OpenJPEGJavaDecoder
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_openJpeg_OpenJPEGJavaDecoder
* Method: internalDecodeJ2KtoImage
* Signature: ([Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2KtoImage
(JNIEnv *, jobject, jobjectArray);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,21 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_openJpeg_OpenJPEGJavaEncoder */
#ifndef _Included_org_openJpeg_OpenJPEGJavaEncoder
#define _Included_org_openJpeg_OpenJPEGJavaEncoder
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_openJpeg_OpenJPEGJavaEncoder
* Method: internalEncodeImageToJ2K
* Signature: ([Ljava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_org_openJpeg_OpenJPEGJavaEncoder_internalEncodeImageToJ2K
(JNIEnv *, jobject, jobjectArray);
#ifdef __cplusplus
}
#endif
#endif

20
LibOpenJPEG.sln Normal file
View File

@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibOpenJPEG", "LibOpenJPEG.vcproj", "{6A47DBE3-8F80-4ABE-8688-5F8DC620977C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6A47DBE3-8F80-4ABE-8688-5F8DC620977C}.Debug|Win32.ActiveCfg = Debug|Win32
{6A47DBE3-8F80-4ABE-8688-5F8DC620977C}.Debug|Win32.Build.0 = Debug|Win32
{6A47DBE3-8F80-4ABE-8688-5F8DC620977C}.Release|Win32.ActiveCfg = Release|Win32
{6A47DBE3-8F80-4ABE-8688-5F8DC620977C}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

642
LibOpenJPEG.vcproj Normal file
View File

@@ -0,0 +1,642 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="LibOpenJPEG"
ProjectGUID="{4F27AA53-4181-4A1A-8238-3931B0A41048}"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
WholeProgramOptimization="false"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\Release/LibOpenJPEG.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1036"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\Release\LibOpenJPEG.lib"
SuppressStartupBanner="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release/LibOpenJPEG.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="if not exist dist mkdir dist&#x0D;&#x0A;copy Release\LibOpenJPEG.lib dist&#x0D;&#x0A;copy libopenjpeg\openjpeg.h dist&#x0D;&#x0A;"
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
InlineFunctionExpansion="0"
EnableIntrinsicFunctions="false"
FavorSizeOrSpeed="1"
WholeProgramOptimization="false"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug/LibOpenJPEG.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1036"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="Debug\LibOpenJPEGd.lib"
SuppressStartupBanner="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/LibOpenJPEG.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="if not exist dist mkdir dist&#x0D;&#x0A;copy Debug\LibOpenJPEGd.lib dist&#x0D;&#x0A;copy libopenjpeg\openjpeg.h dist&#x0D;&#x0A;"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="libopenjpeg\bio.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\cio.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\dwt.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\event.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\image.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\j2k.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\j2k_lib.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\jp2.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\jpt.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\mct.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\mqc.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\openjpeg.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\pi.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\raw.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\t1.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\t2.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\tcd.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="libopenjpeg\tgt.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl"
>
<File
RelativePath="libopenjpeg\bio.h"
>
</File>
<File
RelativePath="libopenjpeg\cio.h"
>
</File>
<File
RelativePath="libopenjpeg\dwt.h"
>
</File>
<File
RelativePath="libopenjpeg\event.h"
>
</File>
<File
RelativePath="libopenjpeg\fix.h"
>
</File>
<File
RelativePath="libopenjpeg\image.h"
>
</File>
<File
RelativePath="libopenjpeg\int.h"
>
</File>
<File
RelativePath="libopenjpeg\j2k.h"
>
</File>
<File
RelativePath="libopenjpeg\j2k_lib.h"
>
</File>
<File
RelativePath="libopenjpeg\jp2.h"
>
</File>
<File
RelativePath="libopenjpeg\jpt.h"
>
</File>
<File
RelativePath="libopenjpeg\mct.h"
>
</File>
<File
RelativePath="libopenjpeg\mqc.h"
>
</File>
<File
RelativePath="libopenjpeg\openjpeg.h"
>
</File>
<File
RelativePath="libopenjpeg\opj_includes.h"
>
</File>
<File
RelativePath=".\libopenjpeg\opj_malloc.h"
>
</File>
<File
RelativePath="libopenjpeg\pi.h"
>
</File>
<File
RelativePath="libopenjpeg\raw.h"
>
</File>
<File
RelativePath="libopenjpeg\t1.h"
>
</File>
<File
RelativePath="libopenjpeg\t1_luts.h"
>
</File>
<File
RelativePath="libopenjpeg\t2.h"
>
</File>
<File
RelativePath="libopenjpeg\tcd.h"
>
</File>
<File
RelativePath="libopenjpeg\tgt.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -4,7 +4,7 @@ VER_MAJOR = 2
VER_MINOR = 1.2.0
SRCS = ./libopenjpeg/bio.c ./libopenjpeg/cio.c ./libopenjpeg/dwt.c ./libopenjpeg/event.c ./libopenjpeg/image.c ./libopenjpeg/j2k.c ./libopenjpeg/j2k_lib.c ./libopenjpeg/jp2.c ./libopenjpeg/jpt.c ./libopenjpeg/mct.c ./libopenjpeg/mqc.c ./libopenjpeg/openjpeg.c ./libopenjpeg/pi.c ./libopenjpeg/raw.c ./libopenjpeg/t1.c ./libopenjpeg/t2.c ./libopenjpeg/tcd.c ./libopenjpeg/tgt.c
INCLS = ./libopenjpeg/bio.h ./libopenjpeg/cio.h ./libopenjpeg/dwt.h ./libopenjpeg/event.h ./libopenjpeg/fix.h ./libopenjpeg/image.h ./libopenjpeg/int.h ./libopenjpeg/j2k.h ./libopenjpeg/j2k_lib.h ./libopenjpeg/jp2.h ./libopenjpeg/jpt.h ./libopenjpeg/mct.h ./libopenjpeg/mqc.h ./libopenjpeg/openjpeg.h ./libopenjpeg/pi.h ./libopenjpeg/raw.h ./libopenjpeg/t1.h ./libopenjpeg/t2.h ./libopenjpeg/tcd.h ./libopenjpeg/tgt.h ./libopenjpeg/opj_includes.h
INCLS = ./libopenjpeg/bio.h ./libopenjpeg/cio.h ./libopenjpeg/dwt.h ./libopenjpeg/event.h ./libopenjpeg/fix.h ./libopenjpeg/image.h ./libopenjpeg/int.h ./libopenjpeg/j2k.h ./libopenjpeg/j2k_lib.h ./libopenjpeg/jp2.h ./libopenjpeg/jpt.h ./libopenjpeg/mct.h ./libopenjpeg/mqc.h ./libopenjpeg/openjpeg.h ./libopenjpeg/pi.h ./libopenjpeg/raw.h ./libopenjpeg/t1.h ./libopenjpeg/t2.h ./libopenjpeg/tcd.h ./libopenjpeg/tgt.h ./libopenjpeg/opj_malloc.h ./libopenjpeg/opj_includes.h
INCLUDE = -Ilibopenjpeg
# General configuration variables:
@@ -18,7 +18,7 @@ INSTALL_INCLUDE = $(PREFIX)/include
# Converts cr/lf to just lf
DOS2UNIX = dos2unix
COMPILERFLAGS = -O3 -fPIC
COMPILERFLAGS = -Wall -O3 -ffast-math -std=c99 -fPIC
LIBRARIES = -lstdc++
MODULES = $(SRCS:.c=.o)

View File

@@ -1,7 +1,7 @@
# MacOSX makefile for OpenJPEG
VER_MAJOR = 1
VER_MINOR = 1.1
VER_MAJOR = 2
VER_MINOR = 1.2.0
SRCS = ./libopenjpeg/bio.c ./libopenjpeg/cio.c ./libopenjpeg/dwt.c ./libopenjpeg/event.c ./libopenjpeg/image.c ./libopenjpeg/j2k.c ./libopenjpeg/j2k_lib.c ./libopenjpeg/jp2.c ./libopenjpeg/jpt.c ./libopenjpeg/mct.c ./libopenjpeg/mqc.c ./libopenjpeg/openjpeg.c ./libopenjpeg/pi.c ./libopenjpeg/raw.c ./libopenjpeg/t1.c ./libopenjpeg/t2.c ./libopenjpeg/tcd.c ./libopenjpeg/tgt.c
INCLS = ./libopenjpeg/bio.h ./libopenjpeg/cio.h ./libopenjpeg/dwt.h ./libopenjpeg/event.h ./libopenjpeg/fix.h ./libopenjpeg/image.h ./libopenjpeg/int.h ./libopenjpeg/j2k.h ./libopenjpeg/j2k_lib.h ./libopenjpeg/jp2.h ./libopenjpeg/jpt.h ./libopenjpeg/mct.h ./libopenjpeg/mqc.h ./libopenjpeg/openjpeg.h ./libopenjpeg/pi.h ./libopenjpeg/raw.h ./libopenjpeg/t1.h ./libopenjpeg/t2.h ./libopenjpeg/tcd.h ./libopenjpeg/tgt.h ./libopenjpeg/opj_includes.h

View File

@@ -1,4 +1,4 @@
# Makefile for the main JPWL OpenJPEG codecs: JPWL_ j2k_to_image and JPWL_image_to_j2k
# Makefile for OPJViewer
# General configuration variables:
CC = $(shell wx-config-2.8 --cxx)
@@ -6,7 +6,7 @@ AR = ar
CFLAGS = -DUSE_JPWL -DwxUSE_LIBOPENJPEG -DwxUSE_GUI=1 -DOPJ_STATIC -DOPJ_HTMLABOUT $(shell wx-config-2.8 --cxxflags) # -g -p -pg -DUSE_JPWL
OPJV_SRCS = source/imagj2k.cpp source/imagmj2.cpp source/wxj2kparser.cpp source/imagjp2.cpp source/OPJViewer.cpp source/wxjp2parser.cpp
OPJV_SRCS = source/imagj2k.cpp source/imagmj2.cpp source/wxj2kparser.cpp source/imagjp2.cpp source/OPJViewer.cpp source/wxjp2parser.cpp source/OPJViewer.cpp source/OPJThreads.cpp
MODULES = $(OPJV_SRCS:.cpp=.o)

View File

@@ -42,16 +42,21 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /G6 /MD /W3 /GX /O2 /I "c:\programmi\wxWidgets-2.8.0\lib\vc_lib\msw" /I "c:\programmi\wxWidgets-2.8.0\include" /I ".." /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D WINVER=0x400 /D "_MT" /D wxUSE_GUI=1 /D "wxUSE_LIBOPENJPEG" /D "OPJ_STATIC" /D "USE_JPWL" /D "OPJ_HTMLABOUT" /D "OPJ_MANYFORMATS" /FR /FD /c
# ADD CPP /nologo /G6 /MD /W3 /GX /O2 /I "d:\programmi\wxWidgets-2.8.0\lib\vc_lib\msw" /I "d:\programmi\wxWidgets-2.8.0\include" /I ".." /I "../libopenjpeg" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D WINVER=0x400 /D "_MT" /D wxUSE_GUI=1 /D "wxUSE_LIBOPENJPEG" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /D "USE_MXF" /D "OPJ_HTMLABOUT" /D "OPJ_MANYFORMATS" /D "OPJ_INICONFIG" /FR /FD /c
# ADD BASE RSC /l 0x410 /d "NDEBUG"
# ADD RSC /l 0x409 /i "c:\programmi\wxWidgets-2.8.0\include" /d "NDEBUG"
# ADD RSC /l 0x409 /i "d:\programmi\wxWidgets-2.8.0\include" /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wxzlib.lib wxregex.lib wxpng.lib wxjpeg.lib wxbase28.lib wxmsw28_core.lib wxmsw28_html.lib wxmsw28_adv.lib wxmsw28_core.lib wxbase28.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregex.lib wxexpat.lib LibOpenJPEG_JPWL.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libcmt.lib" /libpath:"c:\programmi\wxWidgets-2.8.0\lib\vc_lib" /libpath:"..\jpwl\Release" /IGNORE:4089
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wxzlib.lib wxregex.lib wxpng.lib wxjpeg.lib wxbase28.lib wxmsw28_core.lib wxmsw28_html.lib wxmsw28_adv.lib wxmsw28_core.lib wxbase28.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregex.lib wxexpat.lib LibOpenJPEG_JPWL.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libcmt.lib" /libpath:"d:\programmi\wxWidgets-2.8.0\lib\vc_lib" /libpath:"..\jpwl\Release" /IGNORE:4089
# SUBTRACT LINK32 /pdb:none
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=Update build number
PostBuild_Cmds=buildupdate.bat
# End Special Build Tool
!ELSEIF "$(CFG)" == "OPJViewer - Win32 Debug"
@@ -67,15 +72,15 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "d:\Programmi\wxWidgets-2.8.0\INCLUDE" /I "d:\programmi\wxWidgets-2.8.0\lib\vc_lib\msw" /I "d:\programmi\wxWidgets-2.8.0\include" /I ".." /D "_DEBUG" /D "__WXDEBUG__" /D WXDEBUG=1 /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D WINVER=0x400 /D "_MT" /D wxUSE_GUI=1 /D "wxUSE_LIBOPENJPEG" /D "OPJ_STATIC" /D "USE_JPWL" /D "OPJ_HTMLABOUT" /FR /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "c:\Programmi\wxWidgets-2.8.0\INCLUDE" /I "c:\programmi\wxWidgets-2.8.0\lib\vc_lib\msw" /I "c:\programmi\wxWidgets-2.8.0\include" /I ".." /D "_DEBUG" /D "__WXDEBUG__" /D WXDEBUG=1 /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D WINVER=0x400 /D "_MT" /D wxUSE_GUI=1 /D "wxUSE_LIBOPENJPEG" /D "OPJ_STATIC" /D "USE_JPWL" /D "OPJ_HTMLABOUT" /FR /FD /GZ /c
# ADD BASE RSC /l 0x410 /d "_DEBUG"
# ADD RSC /l 0x410 /i "d:\programmi\wxWidgets-2.8.0\include" /d "_DEBUG"
# ADD RSC /l 0x410 /i "c:\programmi\wxWidgets-2.8.0\include" /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wxzlibd.lib wxregexd.lib wxpngd.lib wxjpegd.lib wxtiffd.lib wxbase28d.lib wxmsw28d_core.lib wxmsw28d_html.lib wxmsw28d_adv.lib LibOpenJPEG_JPWLd.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcmtd.lib" /pdbtype:sept /libpath:"d:\programmi\wxWidgets-2.8.0\lib\vc_lib" /libpath:"..\jpwl\Debug"
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib wxzlibd.lib wxregexd.lib wxpngd.lib wxjpegd.lib wxtiffd.lib wxbase28d.lib wxmsw28d_core.lib wxmsw28d_html.lib wxmsw28d_adv.lib LibOpenJPEG_JPWLd.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcmtd.lib" /pdbtype:sept /libpath:"c:\programmi\wxWidgets-2.8.0\lib\vc_lib" /libpath:"..\jpwl\Debug"
# SUBTRACT LINK32 /pdb:none
!ENDIF
@@ -106,6 +111,26 @@ SOURCE=.\source\imagmj2.cpp
# End Source File
# Begin Source File
SOURCE=.\source\imagmxf.cpp
# End Source File
# Begin Source File
SOURCE=..\codec\index.c
# End Source File
# Begin Source File
SOURCE=.\source\OPJAbout.cpp
# End Source File
# Begin Source File
SOURCE=.\source\OPJDialogs.cpp
# End Source File
# Begin Source File
SOURCE=.\source\OPJThreads.cpp
# End Source File
# Begin Source File
SOURCE=.\source\OPJViewer.cpp
# End Source File
# Begin Source File
@@ -126,6 +151,19 @@ SOURCE=.\source\about_htm.h
# End Source File
# Begin Source File
SOURCE=.\source\build.h
!IF "$(CFG)" == "OPJViewer - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "OPJViewer - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\source\imagj2k.h
# End Source File
# Begin Source File
@@ -138,6 +176,14 @@ SOURCE=.\source\imagmj2.h
# End Source File
# Begin Source File
SOURCE=.\source\imagmxf.h
# End Source File
# Begin Source File
SOURCE=..\codec\index.h
# End Source File
# Begin Source File
SOURCE=.\source\OPJViewer.h
# End Source File
# End Group
@@ -146,6 +192,50 @@ SOURCE=.\source\OPJViewer.h
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\source\wx\msw\blank.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\bullseye.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\cdrom.ico
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\computer.ico
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\cross.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\drive.ico
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\file1.ico
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\floppy.ico
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\folder1.ico
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\folder2.ico
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\hand.cur
# End Source File
# Begin Source File
SOURCE=.\source\icon1.xpm
# End Source File
# Begin Source File
@@ -166,6 +256,10 @@ SOURCE=.\source\icon5.xpm
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\magnif1.cur
# End Source File
# Begin Source File
SOURCE=.\source\opj_logo.xpm
# End Source File
# Begin Source File
@@ -188,6 +282,38 @@ SOURCE=.\source\OPJViewer.rc
SOURCE=.\source\OPJViewer16.xpm
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\pbrush.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\pencil.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\pntleft.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\pntright.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\removble.ico
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\rightarr.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\roller.cur
# End Source File
# Begin Source File
SOURCE=.\source\wx\msw\std.ico
# End Source File
# End Group
# End Target
# End Project

View File

@@ -42,3 +42,7 @@ Name: {userdesktop}\OPJViewer; Filename: {app}\OPJViewer.exe; Tasks: desktopicon
[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:

View File

@@ -1,21 +1,16 @@
===============================================================================
JPEG2000 Visualization Software - OPJViewer
Version 0.1 alpha
Version 0.3 alpha
===============================================================================
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.0 as GUI engine.
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
@@ -27,7 +22,7 @@ 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.0 framework (you have to download it from http://www.wxwidgets.org/ and compile the wx* libraries).
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
-------------------------------------------
@@ -52,8 +47,7 @@ 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.
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;

15
OPJViewer/buildupdate.bat Normal file
View File

@@ -0,0 +1,15 @@
::== buildupdate.bat
@echo off
setLocal EnableDelayedExpansion
for /f "tokens=2,* delims=^(^) " %%a in ('find /v "" ^< .\source\build.h') do (
rem echo %%a
set /A M = %%a + 1
echo Build %%a done^!
echo wxT^("!M!"^) > buildtemp283746825t347
)
if exist buildtemp283746825t347 move /Y buildtemp283746825t347 .\source\build.h
if exist buildtemp283746825t347 del /F /Q buildtemp283746825t347
::==

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

View File

@@ -98,11 +98,17 @@
#include <wx/imaglist.h>
#include "wx/toolbar.h"
#include "wx/artprov.h"
#include "libopenjpeg/openjpeg.h"
#include "imagj2k.h"
#include "imagjp2.h"
#include "imagmj2.h"
#ifdef USE_MXF
#include "imagmxf.h"
#endif // USE_MXF
#ifdef __WXMSW__
typedef unsigned __int64 int8byte;
@@ -128,6 +134,7 @@ typedef unsigned long long int8byte;
#define OPJ_APPLICATION_VERSION wxT("0.3 alpha")
#define OPJ_APPLICATION_TITLEBAR OPJ_APPLICATION_NAME wxT(" ") OPJ_APPLICATION_VERSION
#define OPJ_APPLICATION_COPYRIGHT wxT("(C) 2007, Giuseppe Baruffa")
#define OPJ_APPLICATION_VENDOR wxT("OpenJPEG")
#ifdef __WXMSW__
#define OPJ_APPLICATION_PLATFORM wxT("Windows")
@@ -137,10 +144,27 @@ typedef unsigned long long int8byte;
#define OPJ_APPLICATION_PLATFORM wxT("Linux")
#endif
#define OPJ_FRAME_WIDTH 800
#define OPJ_FRAME_HEIGHT 600
#define OPJ_BROWSER_WIDTH 300
#define OPJ_PEEKER_HEIGHT 130
#define OPJ_CANVAS_BORDER 10
#define OPJ_CANVAS_COLOUR *wxWHITE
#ifdef USE_JPWL
//#define MYJPWL_MAX_NO_TILESPECS JPWL_MAX_NO_TILESPECS
#define MYJPWL_MAX_NO_TILESPECS 4
#endif // USE_JPWL
class OPJDecoThread;
class OPJEncoThread;
class OPJParseThread;
WX_DEFINE_ARRAY_PTR(wxThread *, wxArrayThread);
class OPJChildFrame;
@@ -158,23 +182,24 @@ class OPJViewerApp: public wxApp
// other methods
bool OnInit(void);
int OnExit(void);
void SetShowImages(bool show) { m_showImages = show; }
bool ShowImages() const { return m_showImages; }
void ShowCmdLine(const wxCmdLineParser& parser);
// all the threads currently alive - as soon as the thread terminates, it's
// removed from the array
wxArrayThread m_deco_threads, m_parse_threads;
wxArrayThread m_deco_threads, m_parse_threads, m_enco_threads;
// crit section protects access to all of the arrays below
wxCriticalSection m_deco_critsect, m_parse_critsect;
wxCriticalSection m_deco_critsect, m_parse_critsect, m_enco_critsect;
// semaphore used to wait for the threads to exit, see OPJFrame::OnQuit()
wxSemaphore m_deco_semAllDone, m_parse_semAllDone;
wxSemaphore m_deco_semAllDone, m_parse_semAllDone, m_enco_semAllDone;
// the last exiting thread should post to m_semAllDone if this is true
// (protected by the same m_critsect)
bool m_deco_waitingUntilAllDone, m_parse_waitingUntilAllDone;
bool m_deco_waitingUntilAllDone, m_parse_waitingUntilAllDone, m_enco_waitingUntilAllDone;
// the list of all filenames written in the command line
wxArrayString m_filelist;
@@ -183,13 +208,36 @@ class OPJViewerApp: public wxApp
int m_resizemethod;
// decoding engine parameters
bool m_enabledeco;
bool m_enabledeco, m_enableparse;
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
#ifdef USE_JPWL
bool m_enablejpwl;
bool m_enablejpwl, m_enablejpwle;
int m_expcomps, m_maxtiles;
int m_framewidth, m_frameheight;
#endif // USE_JPWL
// encoding engine parameters
wxString m_subsampling, m_origin, m_rates, m_comment, m_index, m_quality;
wxString m_cbsize, m_prsize, m_tsize, m_torigin, m_poc;
bool m_enablecomm, m_enableidx, m_multicomp, m_irreversible, m_enablesop, m_enableeph;
bool m_enablebypass, m_enablereset, m_enablerestart, m_enablevsc, m_enableerterm;
bool m_enablesegmark, m_enablepoc;
bool m_enablequality;
int m_resolutions, m_progression;
#ifdef USE_JPWL
int m_hprotsel[MYJPWL_MAX_NO_TILESPECS], m_pprotsel[MYJPWL_MAX_NO_TILESPECS];
int m_htileval[MYJPWL_MAX_NO_TILESPECS], m_ptileval[MYJPWL_MAX_NO_TILESPECS],
m_ppackval[MYJPWL_MAX_NO_TILESPECS];
int m_sensisel[MYJPWL_MAX_NO_TILESPECS], m_stileval[MYJPWL_MAX_NO_TILESPECS];
#endif // USE_JPWL
// some layout settings
bool m_showtoolbar, m_showbrowser, m_showpeeker;
int m_browserwidth, m_peekerheight;
// application configuration
wxConfig *OPJconfig;
// private methods and variables
private:
bool m_showImages, m_showButtons;
@@ -221,10 +269,11 @@ class OPJCanvas: public wxScrolledWindow
#endif //__WXGTK__
}
OPJDecoThread *CreateDecoThread(void);
OPJEncoThread *CreateEncoThread(void);
OPJChildFrame *m_childframe;
wxBitmap m_image, m_image100;
wxFileName m_fname;
wxFileName m_fname, m_savename;
long m_zooml;
DECLARE_EVENT_TABLE()
@@ -245,10 +294,10 @@ class OPJMarkerData : public wxTreeItemData
const wxChar *GetDesc1() const { return m_desc.c_str(); }
const wxChar *GetDesc2() const { return m_filestring.c_str(); }
wxFileOffset m_start, m_length;
wxString m_desc;
// private methods and variables
private:
wxString m_desc;
wxString m_filestring;
};
@@ -364,17 +413,33 @@ class OPJFrame: public wxMDIParentFrame
void OnSize(wxSizeEvent& WXUNUSED(event));
void OnAbout(wxCommandEvent& WXUNUSED(event));
void OnFileOpen(wxCommandEvent& WXUNUSED(event));
void OnFileSaveAs(wxCommandEvent& WXUNUSED(event));
void OnMemoryOpen(wxCommandEvent& WXUNUSED(event));
void OnQuit(wxCommandEvent& WXUNUSED(event));
void OnClose(wxCommandEvent& WXUNUSED(event));
void OnZoom(wxCommandEvent& WXUNUSED(event));
void OnFit(wxCommandEvent& WXUNUSED(event));
void OnToggleBrowser(wxCommandEvent& WXUNUSED(event));
void OnTogglePeeker(wxCommandEvent& WXUNUSED(event));
void OnToggleToolbar(wxCommandEvent& WXUNUSED(event));
void OnReload(wxCommandEvent& event);
void OnPrevFrame(wxCommandEvent& event);
void OnHomeFrame(wxCommandEvent& event);
void OnNextFrame(wxCommandEvent& event);
void OnLessLayers(wxCommandEvent& event);
void OnAllLayers(wxCommandEvent& event);
void OnMoreLayers(wxCommandEvent& event);
void OnLessRes(wxCommandEvent& event);
void OnFullRes(wxCommandEvent& event);
void OnMoreRes(wxCommandEvent& event);
void OnPrevComp(wxCommandEvent& event);
void OnAllComps(wxCommandEvent& event);
void OnNextComp(wxCommandEvent& event);
void OnSetsEnco(wxCommandEvent& event);
void OnSetsDeco(wxCommandEvent& event);
void OnSashDrag(wxSashEvent& event);
void OpenFiles(wxArrayString paths, wxArrayString filenames);
void SaveFile(wxArrayString paths, wxArrayString filenames);
void OnNotebook(wxNotebookEvent& event);
void Rescale(int scale, OPJChildFrame *child);
@@ -382,6 +447,7 @@ class OPJFrame: public wxMDIParentFrame
OPJChildFrameHash m_childhash;
wxSashLayoutWindow* markerTreeWindow;
wxSashLayoutWindow* loggingWindow;
wxToolBar* tool_bar;
void Resize(int number);
wxNotebook *m_bookCtrl;
wxNotebook *m_bookCtrlbottom;
@@ -429,17 +495,33 @@ enum {
OPJFRAME_FILEEXIT = wxID_EXIT,
OPJFRAME_HELPABOUT = wxID_ABOUT,
OPJFRAME_FILEOPEN,
OPJFRAME_MEMORYOPEN,
OPJFRAME_FILESAVEAS,
OPJFRAME_FILETOGGLEB,
OPJFRAME_FILETOGGLEP,
OPJFRAME_FILETOGGLET,
OPJFRAME_VIEWZOOM,
OPJFRAME_VIEWFIT,
OPJFRAME_VIEWRELOAD,
OPJFRAME_VIEWPREVFRAME,
OPJFRAME_VIEWHOMEFRAME,
OPJFRAME_VIEWNEXTFRAME,
OPJFRAME_VIEWLESSLAYERS,
OPJFRAME_VIEWALLLAYERS,
OPJFRAME_VIEWMORELAYERS,
OPJFRAME_VIEWLESSRES,
OPJFRAME_VIEWFULLRES,
OPJFRAME_VIEWMORERES,
OPJFRAME_VIEWPREVCOMP,
OPJFRAME_VIEWALLCOMPS,
OPJFRAME_VIEWNEXTCOMP,
OPJFRAME_FILECLOSE,
OPJFRAME_SETSENCO,
OPJFRAME_SETSDECO,
OPJFRAME_BROWSEWIN = 10000,
OPJFRAME_LOGWIN
OPJFRAME_LOGWIN,
OPJFRAME_TOOLBAR
};
@@ -494,6 +576,26 @@ enum
LEFT_NOTEBOOK_ID
};
class OPJEncoThread : public wxThread
{
public:
OPJEncoThread(OPJCanvas *canvas);
// thread execution starts here
virtual void *Entry();
// called when the thread exits - whether it terminates normally or is
// stopped with Delete() (but not when it is Kill()ed!)
virtual void OnExit();
// write something to the text control
void WriteText(const wxString& text);
public:
unsigned m_count;
OPJCanvas *m_canvas;
};
class OPJDecoThread : public wxThread
{
public:
@@ -569,21 +671,48 @@ public:
wxBookCtrlBase* m_settingsNotebook;
wxPanel* CreateMainSettingsPage(wxWindow* parent);
wxPanel* CreatePart1SettingsPage(wxWindow* parent);
wxPanel* CreatePart1_1SettingsPage(wxWindow* parent);
wxPanel* CreatePart1_2SettingsPage(wxWindow* parent);
/* wxPanel* CreatePart3SettingsPage(wxWindow* parent);*/
void OnEnableComm(wxCommandEvent& event);
void OnEnableIdx(wxCommandEvent& event);
void OnEnablePoc(wxCommandEvent& event);
void OnRadioQualityRate(wxCommandEvent& event);
#ifdef USE_JPWL
void OnEnableJPWL(wxCommandEvent& event);
/* wxPanel* CreatePart11SettingsPage(wxWindow* parent);
wxCheckBox *m_enablejpwlCheck;*/
wxPanel* CreatePart11SettingsPage(wxWindow* parent);
/*wxCheckBox *m_enablejpwlCheck;*/
wxChoice *m_hprotChoice[MYJPWL_MAX_NO_TILESPECS];
wxSpinCtrl *m_htileCtrl[MYJPWL_MAX_NO_TILESPECS];
wxChoice *m_pprotChoice[MYJPWL_MAX_NO_TILESPECS];
wxSpinCtrl *m_ptileCtrl[MYJPWL_MAX_NO_TILESPECS];
wxSpinCtrl *m_ppackCtrl[MYJPWL_MAX_NO_TILESPECS];
wxChoice *m_sensiChoice[MYJPWL_MAX_NO_TILESPECS];
wxSpinCtrl *m_stileCtrl[MYJPWL_MAX_NO_TILESPECS];
void OnHprotSelect(wxCommandEvent& event);
void OnPprotSelect(wxCommandEvent& event);
void OnSensiSelect(wxCommandEvent& event);
#endif // USE_JPWL
wxTextCtrl *m_subsamplingCtrl, *m_originCtrl, *m_rateCtrl, *m_commentCtrl;
wxRadioButton *m_rateRadio, *m_qualityRadio;
wxTextCtrl *m_indexCtrl, *m_qualityCtrl, *m_cbsizeCtrl, *m_prsizeCtrl, *m_pocCtrl;
wxTextCtrl *m_tsizeCtrl, *m_toriginCtrl;
wxRadioBox *progressionBox;
wxCheckBox *m_enablecommCheck, *m_enableidxCheck, *m_mctCheck, *m_irrevCheck;
wxCheckBox *m_sopCheck, *m_ephCheck, *m_enablebypassCheck, *m_enableresetCheck,
*m_enablerestartCheck, *m_enablevscCheck, *m_enableertermCheck, *m_enablesegmarkCheck;
wxCheckBox *m_enablepocCheck, *m_enablejpwlCheck;
wxSpinCtrl *m_resolutionsCtrl;
protected:
enum {
OPJENCO_ENABLEJPWL = 100,
OPJENCO_RATEFACTOR,
OPJENCO_RATERADIO,
OPJENCO_QUALITYFACTOR,
OPJENCO_QUALITYRADIO,
OPJENCO_RESNUMBER,
OPJENCO_CODEBLOCKSIZE,
OPJENCO_PRECINCTSIZE,
@@ -598,13 +727,25 @@ protected:
OPJENCO_ENABLEVSC,
OPJENCO_ENABLEERTERM,
OPJENCO_ENABLESEGMARK,
OPJENCO_ENABLEPOC,
OPJENCO_ROICOMP,
OPJENCO_ROISHIFT,
OPJENCO_IMORIG,
OPJENCO_TILORIG,
OPJENCO_ENABLEMCT,
OPJENCO_ENABLEIRREV,
OPJENCO_ENABLEINDEX,
OPJENCO_INDEXNAME
OPJENCO_INDEXNAME,
OPJENCO_POCSPEC,
OPJENCO_ENABLECOMM,
OPJENCO_COMMENTTEXT,
OPJENCO_HPROT,
OPJENCO_HTILE,
OPJENCO_PPROT,
OPJENCO_PTILE,
OPJENCO_PPACK,
OPJENCO_SENSI,
OPJENCO_STILE
};
DECLARE_EVENT_TABLE()
@@ -619,7 +760,7 @@ public:
~OPJDecoderDialog();
wxBookCtrlBase* m_settingsNotebook;
wxCheckBox *m_enabledecoCheck;
wxCheckBox *m_enabledecoCheck, *m_enableparseCheck;
wxSpinCtrl *m_reduceCtrl, *m_layerCtrl, *m_numcompsCtrl;
wxRadioBox* m_resizeBox;
@@ -644,6 +785,7 @@ protected:
OPJDECO_QUALITYLAYERS,
OPJDECO_NUMCOMPS,
OPJDECO_ENABLEDECO,
OPJDECO_ENABLEPARSE,
OPJDECO_ENABLEJPWL,
OPJDECO_EXPCOMPS,
OPJDECO_MAXTILES,

View File

@@ -22,8 +22,10 @@ OPJ_APPLICATION " " OPJ_APPLICATION_VERSION
"<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.</font><br>"
"<font size=-2 color=red>* Build: " wxVERSION_STRING ", " __DATE__ ", " __TIME__ "</font><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>")
#ifdef USE_JPWL
wxT("<font size=-2 color=green>- Compiled with JPWL support</font><br>")
#endif // USE_JPWL

1
OPJViewer/source/build.h Normal file
View File

@@ -0,0 +1 @@
wxT("404")

View File

@@ -131,6 +131,7 @@ bool wxJ2KHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
unsigned char *src = NULL;
unsigned char *ptr;
int file_length;
opj_codestream_info_t cstr_info; /* Codestream information structure */
// destroy the image
image->Destroy();
@@ -188,7 +189,7 @@ bool wxJ2KHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */
opjimage = opj_decode(dinfo, cio);
opjimage = opj_decode_with_info(dinfo, cio, &cstr_info);
if (!opjimage) {
#ifndef __WXGTK__
wxMutexGuiEnter();
@@ -230,19 +231,475 @@ bool wxJ2KHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
}
#define CINEMA_24_CS 1302083 /* Codestream length for 24fps */
#define CINEMA_48_CS 651041 /* Codestream length for 48fps */
#define COMP_24_CS 1041666 /* Maximum size per color component for 2K & 4K @ 24fps */
#define COMP_48_CS 520833 /* Maximum size per color component for 2K @ 48fps */
// save the j2k codestream
bool wxJ2KHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbose )
bool wxJ2KHandler::SaveFile( wxImage *wimage, wxOutputStream& stream, bool verbose )
{
opj_cparameters_t parameters; /* compression parameters */
opj_event_mgr_t event_mgr; /* event manager */
opj_image_t *oimage = NULL;
opj_image_cmptparm_t *cmptparm;
opj_cio_t *cio = NULL;
opj_codestream_info_t cstr_info;
int codestream_length;
bool bSuccess;
int i;
char indexfilename[OPJ_PATH_LEN] = ""; /* index file name */
/*
configure the event callbacks (not required)
setting of each callback is optionnal
*/
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
event_mgr.error_handler = j2k_error_callback;
event_mgr.warning_handler = j2k_warning_callback;
event_mgr.info_handler = j2k_info_callback;
/* set encoding parameters to default values */
opj_set_default_encoder_parameters(&parameters);
/* load parameters */
parameters.cp_cinema = OFF;
/* subsampling */
if (sscanf(m_subsampling.ToAscii(), "%d,%d", &(parameters.subsampling_dx), &(parameters.subsampling_dy)) != 2) {
wxLogError(wxT("Wrong sub-sampling encoder setting: dx,dy"));
return false;
}
/* compression rates */
if ((m_rates != wxT("")) && (!m_enablequality)) {
const char *s1 = m_rates.ToAscii();
wxLogMessage(wxT("rates %s"), s1);
while (sscanf(s1, "%f", &(parameters.tcp_rates[parameters.tcp_numlayers])) == 1) {
parameters.tcp_numlayers++;
while (*s1 && *s1 != ',') {
s1++;
}
if (!*s1)
break;
s1++;
}
wxLogMessage(wxT("%d layers"), parameters.tcp_numlayers);
parameters.cp_disto_alloc = 1;
}
/* image quality, dB */
if ((m_quality != wxT("")) && (m_enablequality)) {
const char *s2 = m_quality.ToAscii();
wxLogMessage(wxT("qualities %s"), s2);
while (sscanf(s2, "%f", &parameters.tcp_distoratio[parameters.tcp_numlayers]) == 1) {
parameters.tcp_numlayers++;
while (*s2 && *s2 != ',') {
s2++;
}
if (!*s2)
break;
s2++;
}
wxLogMessage(wxT("%d layers"), parameters.tcp_numlayers);
parameters.cp_fixed_quality = 1;
}
/* image origin */
if (sscanf(m_origin.ToAscii(), "%d,%d", &parameters.image_offset_x0, &parameters.image_offset_y0) != 2) {
wxLogError(wxT("bad coordinate of the image origin: x0,y0"));
return false;
}
/* Create comment for codestream */
if(m_enablecomm) {
parameters.cp_comment = (char *) malloc(strlen(m_comment.ToAscii()) + 1);
if(parameters.cp_comment) {
strcpy(parameters.cp_comment, m_comment.ToAscii());
}
} else {
parameters.cp_comment = NULL;
}
/* indexing file */
if (m_enableidx) {
strncpy(indexfilename, m_index.ToAscii(), OPJ_PATH_LEN);
wxLogMessage(wxT("index file is %s"), indexfilename);
}
/* if no rate entered, lossless by default */
if (parameters.tcp_numlayers == 0) {
parameters.tcp_rates[0] = 0; /* MOD antonin : losslessbug */
parameters.tcp_numlayers++;
parameters.cp_disto_alloc = 1;
}
/* irreversible transform */
parameters.irreversible = (m_irreversible == true) ? 1 : 0;
/* resolutions */
parameters.numresolution = m_resolutions;
/* codeblocks size */
if (m_cbsize != wxT("")) {
int cblockw_init = 0, cblockh_init = 0;
sscanf(m_cbsize.ToAscii(), "%d,%d", &cblockw_init, &cblockh_init);
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024 || cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
wxLogError(wxT("!! Size of code_block error !! Restrictions:\n width*height<=4096\n 4<=width,height<= 1024"));
return false;
}
parameters.cblockw_init = cblockw_init;
parameters.cblockh_init = cblockh_init;
}
/* precincts size */
if (m_prsize != wxT("")) {
char sep;
int res_spec = 0;
char *s = (char *) m_prsize.c_str();
do {
sep = 0;
sscanf(s, "[%d,%d]%c", &parameters.prcw_init[res_spec], &parameters.prch_init[res_spec], &sep);
parameters.csty |= 0x01;
res_spec++;
s = strpbrk(s, "]") + 2;
} while (sep == ',');
parameters.res_spec = res_spec;
}
/* tiles */
if (m_tsize != wxT("")) {
sscanf(m_tsize.ToAscii(), "%d,%d", &parameters.cp_tdx, &parameters.cp_tdy);
parameters.tile_size_on = true;
}
/* tile origin */
if (sscanf(m_torigin.ToAscii(), "%d,%d", &parameters.cp_tx0, &parameters.cp_ty0) != 2) {
wxLogError(wxT("tile offset setting error: X0,Y0"));
return false;
}
/* use SOP */
if (m_enablesop)
parameters.csty |= 0x02;
/* use EPH */
if (m_enableeph)
parameters.csty |= 0x04;
/* multiple component transform */
if (m_multicomp)
parameters.tcp_mct = 1;
else
parameters.tcp_mct = 0;
/* mode switch */
parameters.mode = (m_enablebypass ? 1 : 0) + (m_enablereset ? 2 : 0)
+ (m_enablerestart ? 4 : 0) + (m_enablevsc ? 8 : 0)
+ (m_enableerterm ? 16 : 0) + (m_enablesegmark ? 32 : 0);
/* progression order */
switch (m_progression) {
/* LRCP */
case 0:
parameters.prog_order = LRCP;
break;
/* RLCP */
case 1:
parameters.prog_order = RLCP;
break;
/* RPCL */
case 2:
parameters.prog_order = RPCL;
break;
/* PCRL */
case 3:
parameters.prog_order = PCRL;
break;
/* CPRL */
case 4:
parameters.prog_order = CPRL;
break;
/* DCI2K24 */
case 5:
parameters.cp_cinema = CINEMA2K_24;
parameters.cp_rsiz = CINEMA2K;
break;
/* DCI2K48 */
case 6:
parameters.cp_cinema = CINEMA2K_48;
parameters.cp_rsiz = CINEMA2K;
break;
/* DCI4K */
case 7:
parameters.cp_cinema = CINEMA4K_24;
parameters.cp_rsiz = CINEMA4K;
break;
default:
break;
}
/* check cinema */
if (parameters.cp_cinema) {
/* set up */
parameters.tile_size_on = false;
parameters.cp_tdx=1;
parameters.cp_tdy=1;
/*Tile part*/
parameters.tp_flag = 'C';
parameters.tp_on = 1;
/*Tile and Image shall be at (0,0)*/
parameters.cp_tx0 = 0;
parameters.cp_ty0 = 0;
parameters.image_offset_x0 = 0;
parameters.image_offset_y0 = 0;
/*Codeblock size= 32*32*/
parameters.cblockw_init = 32;
parameters.cblockh_init = 32;
parameters.csty |= 0x01;
/*The progression order shall be CPRL*/
parameters.prog_order = CPRL;
/* No ROI */
parameters.roi_compno = -1;
parameters.subsampling_dx = 1;
parameters.subsampling_dy = 1;
/* 9-7 transform */
parameters.irreversible = 1;
}
/* convert wx image into opj image */
cmptparm = (opj_image_cmptparm_t*) malloc(3 * sizeof(opj_image_cmptparm_t));
/* initialize opj image components */
memset(&cmptparm[0], 0, 3 * sizeof(opj_image_cmptparm_t));
for(i = 0; i < 3; i++) {
cmptparm[i].prec = 8;
cmptparm[i].bpp = 8;
cmptparm[i].sgnd = false;
cmptparm[i].dx = parameters.subsampling_dx;
cmptparm[i].dy = parameters.subsampling_dy;
cmptparm[i].w = wimage->GetWidth();
cmptparm[i].h = wimage->GetHeight();
}
/* create the image */
oimage = opj_image_create(3, &cmptparm[0], CLRSPC_SRGB);
if(!oimage) {
if (cmptparm)
free(cmptparm);
return false;
}
/* set image offset and reference grid */
oimage->x0 = parameters.image_offset_x0;
oimage->y0 = parameters.image_offset_y0;
oimage->x1 = parameters.image_offset_x0 + (wimage->GetWidth() - 1) * 1 + 1;
oimage->y1 = parameters.image_offset_y0 + (wimage->GetHeight() - 1) * 1 + 1;
/* load image data */
unsigned char *value = wimage->GetData();
int area = wimage->GetWidth() * wimage->GetHeight();
for (i = 0; i < area; i++) {
oimage->comps[0].data[i] = *(value++);
oimage->comps[1].data[i] = *(value++);
oimage->comps[2].data[i] = *(value++);
}
/* check cinema again */
if (parameters.cp_cinema) {
int i;
float temp_rate;
opj_poc_t *POC = NULL;
switch (parameters.cp_cinema) {
case CINEMA2K_24:
case CINEMA2K_48:
if (parameters.numresolution > 6) {
parameters.numresolution = 6;
}
if (!((oimage->comps[0].w == 2048) | (oimage->comps[0].h == 1080))) {
wxLogWarning(wxT("Image coordinates %d x %d is not 2K compliant. JPEG Digital Cinema Profile-3 "
"(2K profile) compliance requires that at least one of coordinates match 2048 x 1080"),
oimage->comps[0].w, oimage->comps[0].h);
parameters.cp_rsiz = STD_RSIZ;
}
break;
case CINEMA4K_24:
if (parameters.numresolution < 1) {
parameters.numresolution = 1;
} else if (parameters.numresolution > 7) {
parameters.numresolution = 7;
}
if (!((oimage->comps[0].w == 4096) | (oimage->comps[0].h == 2160))) {
wxLogWarning(wxT("Image coordinates %d x %d is not 4K compliant. JPEG Digital Cinema Profile-4"
"(4K profile) compliance requires that at least one of coordinates match 4096 x 2160"),
oimage->comps[0].w, oimage->comps[0].h);
parameters.cp_rsiz = STD_RSIZ;
}
parameters.POC[0].tile = 1;
parameters.POC[0].resno0 = 0;
parameters.POC[0].compno0 = 0;
parameters.POC[0].layno1 = 1;
parameters.POC[0].resno1 = parameters.numresolution - 1;
parameters.POC[0].compno1 = 3;
parameters.POC[0].prg1 = CPRL;
parameters.POC[1].tile = 1;
parameters.POC[1].resno0 = parameters.numresolution - 1;
parameters.POC[1].compno0 = 0;
parameters.POC[1].layno1 = 1;
parameters.POC[1].resno1 = parameters.numresolution;
parameters.POC[1].compno1 = 3;
parameters.POC[1].prg1 = CPRL;
parameters.numpocs = 2;
break;
}
switch (parameters.cp_cinema) {
case CINEMA2K_24:
case CINEMA4K_24:
for (i = 0 ; i < parameters.tcp_numlayers; i++) {
temp_rate = 0;
if (parameters.tcp_rates[i] == 0) {
parameters.tcp_rates[0] = ((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) /
(CINEMA_24_CS * 8 * oimage->comps[0].dx * oimage->comps[0].dy);
}else{
temp_rate = ((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) /
(parameters.tcp_rates[i] * 8 * oimage->comps[0].dx * oimage->comps[0].dy);
if (temp_rate > CINEMA_24_CS ) {
parameters.tcp_rates[i]= ((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) /
(CINEMA_24_CS * 8 * oimage->comps[0].dx * oimage->comps[0].dy);
} else {
/* do nothing */
}
}
}
parameters.max_comp_size = COMP_24_CS;
break;
case CINEMA2K_48:
for (i = 0; i < parameters.tcp_numlayers; i++) {
temp_rate = 0 ;
if (parameters.tcp_rates[i] == 0) {
parameters.tcp_rates[0] = ((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) /
(CINEMA_48_CS * 8 * oimage->comps[0].dx * oimage->comps[0].dy);
}else{
temp_rate =((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) /
(parameters.tcp_rates[i] * 8 * oimage->comps[0].dx * oimage->comps[0].dy);
if (temp_rate > CINEMA_48_CS ){
parameters.tcp_rates[0]= ((float) (oimage->numcomps * oimage->comps[0].w * oimage->comps[0].h * oimage->comps[0].prec)) /
(CINEMA_48_CS * 8 * oimage->comps[0].dx * oimage->comps[0].dy);
}else{
/* do nothing */
}
}
}
parameters.max_comp_size = COMP_48_CS;
break;
}
parameters.cp_disto_alloc = 1;
}
/* get a J2K compressor handle */
opj_cinfo_t* cinfo = opj_create_compress(CODEC_J2K);
/* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
/* setup the encoder parameters using the current image and user parameters */
opj_setup_encoder(cinfo, &parameters, oimage);
/* open a byte stream for writing */
/* allocate memory for all tiles */
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
/* encode the image */
bSuccess = opj_encode_with_info(cinfo, cio, oimage, &cstr_info);
if (!bSuccess) {
opj_cio_close(cio);
opj_destroy_compress(cinfo);
opj_image_destroy(oimage);
if (cmptparm)
free(cmptparm);
if(parameters.cp_comment)
free(parameters.cp_comment);
if(parameters.cp_matrice)
free(parameters.cp_matrice);
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogError(wxT("J2K: Couldn't save image -> not implemented."));
wxLogError(wxT("failed to encode image"));
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
return false;
}
codestream_length = cio_tell(cio);
wxLogMessage(wxT("Codestream: %d bytes"), codestream_length);
/* write the buffer to stream */
stream.Write(cio->buffer, codestream_length);
/* close and free the byte stream */
opj_cio_close(cio);
/* Write the index to disk */
if (*indexfilename) {
if (write_index_file(&cstr_info, indexfilename)) {
wxLogError(wxT("Failed to output index file"));
}
}
/* free remaining compression structures */
opj_destroy_compress(cinfo);
/* free image data */
opj_image_destroy(oimage);
if (cmptparm)
free(cmptparm);
if(parameters.cp_comment)
free(parameters.cp_comment);
if(parameters.cp_matrice)
free(parameters.cp_matrice);
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogMessage(wxT("J2K: Image encoded!"));
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
return true;
}
#ifdef __VISUALC__
#pragma warning(default:4611)

View File

@@ -45,6 +45,7 @@
#include "wx/image.h"
#include "libopenjpeg/openjpeg.h"
#include "codec/index.h"
#define wxBITMAP_TYPE_J2K 47
@@ -67,6 +68,7 @@ public:
m_type = wxBITMAP_TYPE_J2K;
m_mime = wxT("image/j2k");
/* decoding */
m_reducefactor = 0;
m_qualitylayers = 0;
m_components = 0;
@@ -75,6 +77,54 @@ public:
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
@@ -84,6 +134,40 @@ public:
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 );
@@ -92,6 +176,7 @@ protected:
#endif
private:
OPJ_PROG_ORDER give_progression(char progression[4]);
DECLARE_DYNAMIC_CLASS(wxJ2KHandler)
};

View File

@@ -135,6 +135,7 @@ bool wxJP2Handler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
unsigned char *src = NULL;
unsigned char *ptr;
int file_length;
opj_codestream_info_t cstr_info; /* Codestream information structure */
// destroy the image
image->Destroy();
@@ -193,7 +194,7 @@ bool wxJP2Handler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */
opjimage = opj_decode(dinfo, cio);
opjimage = opj_decode_with_info(dinfo, cio, &cstr_info);
if (!opjimage) {
#ifndef __WXGTK__
wxMutexGuiEnter();

View File

@@ -130,10 +130,18 @@ void mj2_info_callback(const char *msg, void *client_data) {
/* From little endian to big endian, 2 and 4 bytes */
#define BYTE_SWAP2(X) ((X & 0x00FF) << 8) | ((X & 0xFF00) >> 8)
#define BYTE_SWAP4(X) ((X & 0x000000FF) << 24) | ((X & 0x0000FF00) << 8) | ((X & 0x00FF0000) >> 8) | ((X & 0xFF000000) >> 24)
#ifdef __WXGTK__
#define BYTE_SWAP8(X) ((X & 0x00000000000000FFULL) << 56) | ((X & 0x000000000000FF00ULL) << 40) | \
((X & 0x0000000000FF0000ULL) << 24) | ((X & 0x00000000FF000000ULL) << 8) | \
((X & 0x000000FF00000000ULL) >> 8) | ((X & 0x0000FF0000000000ULL) >> 24) | \
((X & 0x00FF000000000000ULL) >> 40) | ((X & 0xFF00000000000000ULL) >> 56)
#else
#define BYTE_SWAP8(X) ((X & 0x00000000000000FF) << 56) | ((X & 0x000000000000FF00) << 40) | \
((X & 0x0000000000FF0000) << 24) | ((X & 0x00000000FF000000) << 8) | \
((X & 0x000000FF00000000) >> 8) | ((X & 0x0000FF0000000000) >> 24) | \
((X & 0x00FF000000000000) >> 40) | ((X & 0xFF00000000000000) >> 56)
#endif
/* From codestream to int values */
#define STREAM_TO_UINT32(C, P) (((unsigned long int) (C)[(P) + 0] << 24) + \
@@ -610,6 +618,7 @@ bool wxMJ2Handler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
unsigned char *ptr;
int file_length, jp2c_point, jp2h_point;
unsigned long int jp2hboxlen, jp2cboxlen;
opj_codestream_info_t cstr_info; /* Codestream information structure */
// destroy the image
image->Destroy();
@@ -691,7 +700,7 @@ bool wxMJ2Handler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose,
cio = opj_cio_open((opj_common_ptr)dinfo, src, my_jPheadSIZE + jp2hboxlen + jp2cboxlen);
/* decode the stream and fill the image structure */
opjimage = opj_decode(dinfo, cio);
opjimage = opj_decode_with_info(dinfo, cio, &cstr_info);
if (!opjimage) {
wxMutexGuiEnter();
wxLogError(wxT("MJ2: failed to decode image!"));

View File

@@ -0,0 +1,274 @@
/*
* 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.cpp
// Purpose: wxImage MXF (Material eXchange Format) JPEG 2000 file format handler
// Author: Giuseppe Baruffa - based on imagjpeg.cpp, Vaclav Slavik
// RCS-ID: $Id: imagmxf.cpp,v 0.00 2007/11/19 17:00:00 MW Exp $
// Copyright: (c) Giuseppe Baruffa
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef USE_MXF
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_IMAGE && wxUSE_LIBOPENJPEG
#include "imagmxf.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
#include "wx/app.h"
#include "wx/intl.h"
#include "wx/bitmap.h"
#include "wx/module.h"
#endif
#include "libopenjpeg/openjpeg.h"
#include "wx/filefn.h"
#include "wx/wfstream.h"
// ----------------------------------------------------------------------------
// types
// ----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// wxMXFHandler
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMXFHandler,wxImageHandler)
#if wxUSE_STREAMS
//------------- JPEG 2000 Data Source Manager
#define J2K_CFMT 0
#define JP2_CFMT 1
#define JPT_CFMT 2
#define MJ2_CFMT 3
#define PXM_DFMT 0
#define PGX_DFMT 1
#define BMP_DFMT 2
#define YUV_DFMT 3
#define MAX_MESSAGE_LEN 200
/* sample error callback expecting a FILE* client object */
void mxf_error_callback(const char *msg, void *client_data) {
int message_len = strlen(msg) - 1;
if (msg[message_len] != '\n')
message_len = MAX_MESSAGE_LEN;
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogMessage(wxT("[ERROR] %.*s"), message_len, msg);
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
}
/* sample warning callback expecting a FILE* client object */
void mxf_warning_callback(const char *msg, void *client_data) {
int message_len = strlen(msg) - 1;
if (msg[message_len] != '\n')
message_len = MAX_MESSAGE_LEN;
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogMessage(wxT("[WARNING] %.*s"), message_len, msg);
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
}
/* sample debug callback expecting no client object */
void mxf_info_callback(const char *msg, void *client_data) {
int message_len = strlen(msg) - 1;
if (msg[message_len] != '\n')
message_len = MAX_MESSAGE_LEN;
#ifndef __WXGTK__
wxMutexGuiEnter();
#endif /* __WXGTK__ */
wxLogMessage(wxT("[INFO] %.*s"), message_len, msg);
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
}
/////////////////////////////////////////////////
/////////////////////////////////////////////////
// load the mxf file format
bool wxMXFHandler::LoadFile(wxImage *image, wxInputStream& stream, bool verbose, int index)
{
opj_dparameters_t parameters; /* decompression parameters */
opj_event_mgr_t event_mgr; /* event manager */
opj_image_t *opjimage = NULL;
unsigned char *src = NULL;
unsigned char *ptr;
int file_length, j2k_point, j2k_len;
opj_codestream_info_t cstr_info; /* Codestream information structure */
// destroy the image
image->Destroy();
/* handle to a decompressor */
opj_dinfo_t* dinfo = NULL;
opj_cio_t *cio = NULL;
/* configure the event callbacks (not required) */
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
event_mgr.error_handler = mxf_error_callback;
event_mgr.warning_handler = mxf_warning_callback;
event_mgr.info_handler = mxf_info_callback;
/* set decoding parameters to default values */
opj_set_default_decoder_parameters(&parameters);
/* prepare parameters */
strncpy(parameters.infile, "", sizeof(parameters.infile)-1);
strncpy(parameters.outfile, "", sizeof(parameters.outfile)-1);
parameters.decod_format = J2K_CFMT;
parameters.cod_format = BMP_DFMT;
if (m_reducefactor)
parameters.cp_reduce = m_reducefactor;
if (m_qualitylayers)
parameters.cp_layer = m_qualitylayers;
/*if (n_components)
parameters. = n_components;*/
/* JPWL only */
#ifdef USE_JPWL
parameters.jpwl_exp_comps = m_expcomps;
parameters.jpwl_max_tiles = m_maxtiles;
parameters.jpwl_correct = m_enablejpwl;
#endif /* USE_JPWL */
/* get a decoder handle */
dinfo = opj_create_decompress(CODEC_J2K);
/* find length of the stream */
stream.SeekI(0, wxFromEnd);
file_length = (int) stream.TellI();
/* search for the m_framenum codestream position and length */
//jp2c_point = searchjp2c(stream, file_length, m_framenum);
//jp2c_len = searchjp2c(stream, file_length, m_framenum);
j2k_point = 0;
j2k_len = 10;
// malloc memory source
src = (unsigned char *) malloc(j2k_len);
// copy the jp2c
stream.SeekI(j2k_point, wxFromStart);
stream.Read(src, j2k_len);
/* catch events using our callbacks and give a local context */
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
/* setup the decoder decoding parameters using user parameters */
opj_setup_decoder(dinfo, &parameters);
/* open a byte stream */
cio = opj_cio_open((opj_common_ptr)dinfo, src, j2k_len);
/* decode the stream and fill the image structure */
opjimage = opj_decode_with_info(dinfo, cio, &cstr_info);
if (!opjimage) {
wxMutexGuiEnter();
wxLogError(wxT("MXF: failed to decode image!"));
wxMutexGuiLeave();
opj_destroy_decompress(dinfo);
opj_cio_close(cio);
free(src);
return false;
}
/* close the byte stream */
opj_cio_close(cio);
/* common rendering method */
#include "imagjpeg2000.cpp"
wxMutexGuiEnter();
wxLogMessage(wxT("MXF: image loaded."));
wxMutexGuiLeave();
/* close openjpeg structs */
opj_destroy_decompress(dinfo);
opj_image_destroy(opjimage);
free(src);
if (!image->Ok())
return false;
else
return true;
}
// save the mxf file format
bool wxMXFHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbose )
{
wxLogError(wxT("MXF: Couldn't save movie -> not implemented."));
return false;
}
#ifdef __VISUALC__
#pragma warning(default:4611)
#endif /* VC++ */
// recognize the MXF JPEG 2000 starting box
bool wxMXFHandler::DoCanRead( wxInputStream& stream )
{
unsigned char hdr[4];
if ( !stream.Read(hdr, WXSIZEOF(hdr)) )
return false;
return (hdr[0] == 0x06 &&
hdr[1] == 0x0E &&
hdr[2] == 0x2B &&
hdr[3] == 0x34);
}
#endif // wxUSE_STREAMS
#endif // wxUSE_LIBOPENJPEG
#endif // USE_MXF

View File

@@ -0,0 +1,96 @@
/*
* 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"
//-----------------------------------------------------------------------------
// wxMXFHandler
//-----------------------------------------------------------------------------
#if wxUSE_LIBOPENJPEG
#include "wx/image.h"
#include "libopenjpeg/openjpeg.h"
#define wxBITMAP_TYPE_MXF 50
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;
#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;
#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_

View File

@@ -255,7 +255,8 @@ void OPJParseThread::ParseJ2KFile(wxFile *m_file, wxFileOffset offset, wxFileOff
wxString::FromAscii(marker_name[m]) +
wxString::Format(wxT(" (0x%04X)"), marker_val[m]),
image, imageSel,
new OPJMarkerData(wxT("MARK"), m_tree->m_fname.GetFullPath(), offset, offset + currlen + 1)
new OPJMarkerData(wxT("MARK") + wxString::Format(wxT(" (%d)"), marker_val[m]),
m_tree->m_fname.GetFullPath(), offset, offset + currlen + 1)
);
// append some info
@@ -303,6 +304,7 @@ void OPJParseThread::ParseJ2KFile(wxFile *m_file, wxFileOffset offset, wxFileOff
};
break;
#ifdef USE_JPWL
/////////
// RED //
/////////
@@ -550,6 +552,15 @@ void OPJParseThread::ParseJ2KFile(wxFile *m_file, wxFileOffset offset, wxFileOff
}
break;
#endif // USE_JPWL
#ifdef USE_JPSEC
case SEC_VAL:
{
}
break;
#endif // USE_JPSEC
/////////
// SIZ //

View File

@@ -60,6 +60,8 @@ typedef enum {
TRAK_BOX,
TKHD_BOX,
MDIA_BOX,
MDHD_BOX,
HDLR_BOX,
MINF_BOX,
VMHD_BOX,
STBL_BOX,
@@ -102,6 +104,8 @@ struct boxdef {
#define TRAK_SIGN "trak"
#define TKHD_SIGN "tkhd"
#define MDIA_SIGN "mdia"
#define MDHD_SIGN "mdhd"
#define HDLR_SIGN "hdlr"
#define MINF_SIGN "minf"
#define VMHD_SIGN "vmhd"
#define STBL_SIGN "stbl"
@@ -231,6 +235,22 @@ struct boxdef j22box[] =
/* req */ {1, 1, 1},
/* ins */ TRAK_BOX},
/* sign */ {MDHD_SIGN,
/* short */ "Media Header box",
/* long */ "The media header declares overall information which is media-independent, and relevant to characteristics "
"of the media in a track",
/* sbox */ 0,
/* req */ {1, 1, 1},
/* ins */ MDIA_BOX},
/* sign */ {HDLR_SIGN,
/* short */ "Handler Reference box",
/* long */ "This box within a Media Box declares the process by which the media-data in the track may be presented, "
"and thus, the nature of the media in a track",
/* sbox */ 0,
/* req */ {1, 1, 1},
/* ins */ MDIA_BOX},
/* sign */ {MINF_SIGN,
/* short */ "Media Information box",
/* long */ "This box contains all the objects which declare characteristic information of the media in the track",
@@ -303,10 +323,18 @@ struct boxdef j22box[] =
/* From little endian to big endian, 2 and 4 bytes */
#define BYTE_SWAP2(X) ((X & 0x00FF) << 8) | ((X & 0xFF00) >> 8)
#define BYTE_SWAP4(X) ((X & 0x000000FF) << 24) | ((X & 0x0000FF00) << 8) | ((X & 0x00FF0000) >> 8) | ((X & 0xFF000000) >> 24)
#define BYTE_SWAP8(X) (((X & 0x00000000000000FF) << 56) | ((X & 0x000000000000FF00) << 40) | \
#ifdef __WXGTK__
#define BYTE_SWAP8(X) ((X & 0x00000000000000FFULL) << 56) | ((X & 0x000000000000FF00ULL) << 40) | \
((X & 0x0000000000FF0000ULL) << 24) | ((X & 0x00000000FF000000ULL) << 8) | \
((X & 0x000000FF00000000ULL) >> 8) | ((X & 0x0000FF0000000000ULL) >> 24) | \
((X & 0x00FF000000000000ULL) >> 40) | ((X & 0xFF00000000000000ULL) >> 56)
#else
#define BYTE_SWAP8(X) ((X & 0x00000000000000FF) << 56) | ((X & 0x000000000000FF00) << 40) | \
((X & 0x0000000000FF0000) << 24) | ((X & 0x00000000FF000000) << 8) | \
((X & 0x000000FF00000000) >> 8) | ((X & 0x0000FF0000000000) >> 24) | \
((X & 0x00FF000000000000) >> 40) | ((X & 0xFF00000000000000) >> 56))
((X & 0x00FF000000000000) >> 40) | ((X & 0xFF00000000000000) >> 56)
#endif
/* From codestream to int values */
#define STREAM_TO_UINT32(C, P) (((unsigned long int) (C)[(P) + 0] << 24) + \
@@ -821,6 +849,113 @@ int OPJParseThread::box_handler_function(int boxtype, wxFile *fileid, wxFileOffs
};
break;
/* Media Header box */
case (MDHD_BOX): {
unsigned long int version;
unsigned short int language;
fileid->Read(&version, sizeof(unsigned long int));
version = BYTE_SWAP4(version);
if (version == 0) {
unsigned long int creation_time, modification_time, timescale, duration;
fileid->Read(&creation_time, sizeof(unsigned long int));
creation_time = BYTE_SWAP4(creation_time);
fileid->Read(&modification_time, sizeof(unsigned long int));
modification_time = BYTE_SWAP4(modification_time);
fileid->Read(&timescale, sizeof(unsigned long int));
timescale = BYTE_SWAP4(timescale);
fileid->Read(&duration, sizeof(unsigned long int));
duration = BYTE_SWAP4(duration);
const long unix_time = creation_time - 2082844800L;
wxTreeItemId currid = m_tree->AppendItem(parentid,
wxString::Format(wxT("Creation time: %u (%.24s)"), creation_time, ctime(&unix_time)),
m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
new OPJMarkerData(wxT("INFO"))
);
const long unix_time1 = modification_time - 2082844800L;
currid = m_tree->AppendItem(parentid,
wxString::Format(wxT("Modification time: %u (%.24s)"), modification_time, ctime(&unix_time1)),
m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
new OPJMarkerData(wxT("INFO"))
);
currid = m_tree->AppendItem(parentid,
wxString::Format(wxT("Timescale: %u (%.6fs)"), timescale, 1.0 / (float) timescale),
m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
new OPJMarkerData(wxT("INFO"))
);
currid = m_tree->AppendItem(parentid,
wxString::Format(wxT("Duration: %u (%.3fs)"), duration, (float) duration / (float) timescale),
m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
new OPJMarkerData(wxT("INFO"))
);
} else {
int8byte creation_time, modification_time, duration;
unsigned long int timescale;
fileid->Read(&creation_time, sizeof(int8byte));
creation_time = BYTE_SWAP8(creation_time);
fileid->Read(&modification_time, sizeof(int8byte));
modification_time = BYTE_SWAP8(modification_time);
fileid->Read(&timescale, sizeof(unsigned long int));
timescale = BYTE_SWAP4(timescale);
fileid->Read(&duration, sizeof(int8byte));
duration = BYTE_SWAP8(duration);
wxTreeItemId currid = m_tree->AppendItem(parentid,
wxString::Format(wxT("Creation time: %u"), creation_time),
m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
new OPJMarkerData(wxT("INFO"))
);
currid = m_tree->AppendItem(parentid,
wxString::Format(wxT("Modification time: %u"), modification_time),
m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
new OPJMarkerData(wxT("INFO"))
);
currid = m_tree->AppendItem(parentid,
wxString::Format(wxT("Timescale: %u"), timescale),
m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
new OPJMarkerData(wxT("INFO"))
);
currid = m_tree->AppendItem(parentid,
wxString::Format(wxT("Duration: %u"), duration),
m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
new OPJMarkerData(wxT("INFO"))
);
}
fileid->Read(&language, sizeof(unsigned short int));
wxTreeItemId currid = m_tree->AppendItem(parentid,
wxString::Format(wxT("Language: %d (%c%c%c)"), language & 0xEFFF,
0x60 + (char) ((language >> 10) & 0x001F), 0x60 + (char) ((language >> 5) & 0x001F), 0x60 + (char) ((language >> 0) & 0x001F)),
m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
new OPJMarkerData(wxT("INFO"))
);
};
break;
/* Media Handler box */
case (HDLR_BOX): {
unsigned long int version, predefined, temp[3];
char handler[4], name[256];
int namelen = wxMin(256, (filelimit - filepoint - 24));
fileid->Read(&version, sizeof(unsigned long int));
version = BYTE_SWAP4(version);
fileid->Read(&predefined, sizeof(unsigned long int));
fileid->Read(handler, 4 * sizeof(char));
fileid->Read(&temp, 3 * sizeof(unsigned long int));
fileid->Read(name, namelen * sizeof(char));
wxTreeItemId currid = m_tree->AppendItem(parentid,
wxString::Format(wxT("Handler: %.4s"), handler),
m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
new OPJMarkerData(wxT("INFO"))
);
currid = m_tree->AppendItem(parentid,
wxString::Format(wxT("Name: %.255s"), name),
m_tree->TreeCtrlIcon_File, m_tree->TreeCtrlIcon_File + 1,
new OPJMarkerData(wxT("INFO"))
);
}
break;
/* not yet implemented */
default:

View File

@@ -49,7 +49,7 @@ BEGIN
VALUE "FileDescription", "OpenJPEG\0"
VALUE "FileVersion", "1, 1, 0, 0\0"
VALUE "InternalName", "OpenJPEG\0"
VALUE "LegalCopyright", "Copyright <20> 2002-2006, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium\0"
VALUE "LegalCopyright", "Copyright <20> 2002-2007, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium\0"
VALUE "LegalTrademarks", "See http://www.openjpeg.org for details\0"
VALUE "OriginalFilename", "OpenJPEG.dll\0"
VALUE "PrivateBuild", "\0"

View File

@@ -6,4 +6,4 @@ Basic instructions on how to build using CMake (CMake 2.4.5 or newer is required
cd bin
cmake .. -DBUILD_EXAMPLES:BOOL=ON
make
./codec/j2k_to_image
./bin/j2k_to_image

View File

@@ -3,7 +3,9 @@
# First thing define the common source:
SET(common_SRCS
convert.c
index.c
)
# Then check if getopt is present:
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
SET(DONT_HAVE_GETOPT 1)
@@ -24,7 +26,6 @@ IF(DONT_HAVE_GETOPT)
)
ENDIF(DONT_HAVE_GETOPT)
# Headers file are located here:
INCLUDE_DIRECTORIES(
${OPENJPEG_SOURCE_DIR}/libopenjpeg
@@ -42,12 +43,26 @@ FIND_PACKAGE(TIFF REQUIRED)
FOREACH(exe j2k_to_image image_to_j2k)
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
TARGET_LINK_LIBRARIES(${exe} ${OPJ_PREFIX}openjpeg ${TIFF_LIBRARIES})
ADD_TEST(${exe} ${EXECUTABLE_OUTPUT_PATH}/${exe})
# calling those exe without option will make them fail always:
SET_TESTS_PROPERTIES(${exe} PROPERTIES WILL_FAIL TRUE)
# On unix you need to link to the math library:
IF(UNIX)
TARGET_LINK_LIBRARIES(${exe} -lm)
TARGET_LINK_LIBRARIES(${exe} m)
ENDIF(UNIX)
# Install exe
INSTALL_TARGETS(/bin/ ${exe})
ENDFOREACH(exe)
# Do testing here, once we know the examples are being built:
FILE(GLOB_RECURSE OPENJPEG_DATA_IMAGES_GLOB
"${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2k"
"${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2c"
"${JPEG2000_CONFORMANCE_DATA_ROOT}/*.jp2"
)
FOREACH(filename ${OPENJPEG_DATA_IMAGES_GLOB})
GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
ADD_TEST(j2i-${filename_temp} ${EXECUTABLE_OUTPUT_PATH}/j2k_to_image -i ${filename} -o ${filename_temp}.tif)
ENDFOREACH(filename)

View File

@@ -5,10 +5,10 @@ CFLAGS = -O3 -lstdc++ # -g -p -pg
all: j2k_to_image image_to_j2k
j2k_to_image: j2k_to_image.c ../libopenjpeg.a
gcc $(CFLAGS) compat/getopt.c convert.c j2k_to_image.c -o j2k_to_image -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
gcc $(CFLAGS) compat/getopt.c index.c convert.c j2k_to_image.c -o j2k_to_image -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
image_to_j2k: image_to_j2k.c ../libopenjpeg.a
gcc $(CFLAGS) compat/getopt.c convert.c image_to_j2k.c -o image_to_j2k -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
gcc $(CFLAGS) compat/getopt.c index.c convert.c image_to_j2k.c -o image_to_j2k -L.. -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
clean:
rm -f j2k_to_image image_to_j2k

View File

@@ -59,7 +59,11 @@ typedef struct option
#define BADARG (int)':'
#define EMSG ""
/* As this class remembers its values from one Java call to the other, reset the values before each use */
void reset_options_reading() {
opterr = 1;
optind = 1;
}
/*
* getopt --
@@ -132,7 +136,7 @@ struct option *longopts, int totlen) {
char param = 1;
again:
if (optind>argc || !argv[optind] || *argv[optind]!='-')
if (optind >= argc || !argv[optind] || *argv[optind]!='-')
return -1;
if (argv[optind][0]=='-' && argv[optind][1]==0) {
@@ -251,7 +255,7 @@ found:
}// end of single character
}//end '-'
fprintf(stderr,"Invalid option %s\n");
fprintf(stderr,"Invalid option\n");
++optind;
return (BADCH);;
}//end function

File diff suppressed because it is too large Load Diff

View File

@@ -31,8 +31,28 @@
#ifndef __J2K_CONVERT_H
#define __J2K_CONVERT_H
opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters);
/**@name RAW image encoding parameters */
/*@{*/
typedef struct raw_cparameters {
/** width of the raw image */
int rawWidth;
/** height of the raw image */
int rawHeight;
/** components of the raw image */
int rawComp;
/** bit depth of the raw image */
int rawBitDepth;
/** signed/unsigned raw image */
bool rawSigned;
/*@}*/
} raw_cparameters_t;
/* TGA conversion */
opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters);
int imagetotga(opj_image_t * image, const char *outfile);
/* BMP conversion */
opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters);
int imagetobmp(opj_image_t *image, const char *outfile);
/* TIFF to image conversion*/
@@ -45,12 +65,14 @@ Load a single image component encoded in PGX file format
@return Returns a greyscale image if successful, returns NULL otherwise
*/
opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters);
int imagetopgx(opj_image_t *image, const char *outfile);
opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters);
int imagetopnm(opj_image_t *image, const char *outfile);
/* RAW conversion */
int imagetoraw(opj_image_t * image, const char *outfile);
opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp);
#endif /* __J2K_CONVERT_H */

View File

@@ -32,11 +32,13 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "openjpeg.h"
#include "compat/getopt.h"
#include "convert.h"
#include "dirent.h"
#include "index.h"
#ifndef WIN32
#define stricmp strcasecmp
@@ -54,6 +56,8 @@
#define BMP_DFMT 12
#define YUV_DFMT 13
#define TIF_DFMT 14
#define RAW_DFMT 15
#define TGA_DFMT 16
/* ----------------------------------------------------------------------- */
#define CINEMA_24_CS 1302083 /*Codestream length for 24fps*/
@@ -77,7 +81,8 @@ typedef struct img_folder{
char set_imgdir;
/** Enable Cod Format for output*/
char set_out_format;
/** User specified rate stored in case of cinema option*/
float *rates;
}img_fol_t;
void encode_help_display() {
@@ -98,10 +103,6 @@ void encode_help_display() {
fprintf(stdout,"The markers written to the main_header are : SOC SIZ COD QCD COM.\n");
fprintf(stdout,"COD and QCD never appear in the tile_header.\n");
fprintf(stdout,"\n");
fprintf(stdout,"- This coder can encode a mega image, a test was made on a 24000x24000 pixels \n");
fprintf(stdout,"color image. You need enough disk space memory (twice the original) to encode \n");
fprintf(stdout,"the image,i.e. for a 1.5 GB image you need a minimum of 3GB of disk memory)\n");
fprintf(stdout,"\n");
fprintf(stdout,"By default:\n");
fprintf(stdout,"------------\n");
fprintf(stdout,"\n");
@@ -138,9 +139,9 @@ void encode_help_display() {
fprintf(stdout,"-OutFor \n");
fprintf(stdout," REQUIRED only if -ImgDir is used\n");
fprintf(stdout," Need to specify only format without filename <BMP> \n");
fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, BMP format\n");
fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA formats\n");
fprintf(stdout,"\n");
fprintf(stdout,"-i : source file (-i source.pnm also *.pgm, *.ppm) \n");
fprintf(stdout,"-i : source file (-i source.pnm also *.pgm, *.ppm, *.bmp, *.tif, *.raw, *.tga) \n");
fprintf(stdout," When using this option -o must be used\n");
fprintf(stdout,"\n");
fprintf(stdout,"-o : destination file (-o dest.j2k or .jp2) \n");
@@ -149,10 +150,10 @@ void encode_help_display() {
fprintf(stdout,"\n");
fprintf(stdout,"-h : display the help information \n ");
fprintf(stdout,"\n");
fprintf(stdout,"-cinema2k : Digital Cinema 2K profile compliant codestream for 2K resolution.(-cinema2k 24 or 48) \n");
fprintf(stdout,"-cinema2K : Digital Cinema 2K profile compliant codestream for 2K resolution.(-cinema2k 24 or 48) \n");
fprintf(stdout," Need to specify the frames per second for a 2K resolution. Only 24 or 48 fps is allowed\n");
fprintf(stdout,"\n");
fprintf(stdout,"-cinema4k : Digital Cinema 4K profile compliant codestream for 4K resolution \n");
fprintf(stdout,"-cinema4K : Digital Cinema 4K profile compliant codestream for 4K resolution \n");
fprintf(stdout," Frames per second not required. Default value is 24fps\n");
fprintf(stdout,"\n");
fprintf(stdout,"-r : different compression ratios for successive layers (-r 20,10,5)\n ");
@@ -199,7 +200,7 @@ void encode_help_display() {
fprintf(stdout,"\n");
fprintf(stdout,"-ROI : c=%%d,U=%%d : quantization indices upshifted \n");
fprintf(stdout," for component c=%%d [%%d = 0,1,2]\n");
fprintf(stdout," with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI:c=0,U=25) \n");
fprintf(stdout," with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI c=0,U=25) \n");
fprintf(stdout,"\n");
fprintf(stdout,"-d : offset of the origin of the image (-d 150,300) \n");
fprintf(stdout,"\n");
@@ -211,31 +212,31 @@ void encode_help_display() {
#ifdef USE_JPWL
fprintf(stdout,"-W : adoption of JPWL (Part 11) capabilities (-W params)\n");
fprintf(stdout," The parameters can be written and repeated in any order:\n");
fprintf(stdout," [h<tile><=type>,s<tile><=method>,a=<addr>,z=<size>,g=<range>,...\n");
fprintf(stdout," ...,p<tile:pack><=type>]\n");
fprintf(stdout," [h<tilepart><=type>,s<tilepart><=method>,a=<addr>,...\n");
fprintf(stdout," ...,z=<size>,g=<range>,p<tilepart:pack><=type>]\n");
fprintf(stdout,"\n");
fprintf(stdout," h selects the header error protection (EPB): 'type' can be\n");
fprintf(stdout," [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]\n");
fprintf(stdout," if 'tile' is absent, it applies to main and tile headers\n");
fprintf(stdout," if 'tile' is present, it applies from that tile\n");
fprintf(stdout," onwards, up to the next h<tile> spec, or to the last tile\n");
fprintf(stdout," if 'tilepart' is absent, it is for main and tile headers\n");
fprintf(stdout," if 'tilepart' is present, it applies from that tile\n");
fprintf(stdout," onwards, up to the next h<> spec, or to the last tilepart\n");
fprintf(stdout," in the codestream (max. %d specs)\n", JPWL_MAX_NO_TILESPECS);
fprintf(stdout,"\n");
fprintf(stdout," p selects the packet error protection (EEP/UEP with EPBs)\n");
fprintf(stdout," to be applied to raw data: 'type' can be\n");
fprintf(stdout," [0=none 1,absent=predefined 16=CRC-16 32=CRC-32 37-128=RS]\n");
fprintf(stdout," if 'tile:pack' is absent, it starts from tile 0, packet 0\n");
fprintf(stdout," if 'tile:pack' is present, it applies from that tile\n");
fprintf(stdout," if 'tilepart:pack' is absent, it is from tile 0, packet 0\n");
fprintf(stdout," if 'tilepart:pack' is present, it applies from that tile\n");
fprintf(stdout," and that packet onwards, up to the next packet spec\n");
fprintf(stdout," or to the last packet in the last tile in the codestream\n");
fprintf(stdout," or to the last packet in the last tilepart in the stream\n");
fprintf(stdout," (max. %d specs)\n", JPWL_MAX_NO_PACKSPECS);
fprintf(stdout,"\n");
fprintf(stdout," s enables sensitivity data insertion (ESD): 'method' can be\n");
fprintf(stdout," [-1=NO ESD 0=RELATIVE ERROR 1=MSE 2=MSE REDUCTION 3=PSNR\n");
fprintf(stdout," 4=PSNR INCREMENT 5=MAXERR 6=TSE 7=RESERVED]\n");
fprintf(stdout," if 'tile' is absent, it applies to main header only\n");
fprintf(stdout," if 'tile' is present, it applies from that tile\n");
fprintf(stdout," onwards, up to the next s<tile> spec, or to the last tile\n");
fprintf(stdout," if 'tilepart' is absent, it is for main header only\n");
fprintf(stdout," if 'tilepart' is present, it applies from that tile\n");
fprintf(stdout," onwards, up to the next s<> spec, or to the last tilepart\n");
fprintf(stdout," in the codestream (max. %d specs)\n", JPWL_MAX_NO_TILESPECS);
fprintf(stdout,"\n");
fprintf(stdout," g determines the addressing mode: <range> can be\n");
@@ -248,15 +249,16 @@ void encode_help_display() {
fprintf(stdout," 1/2 bytes, for the transformed pseudo-floating point value\n");
fprintf(stdout,"\n");
fprintf(stdout," ex.:\n");
fprintf(stdout," h,h0=64,h3=16,h5=32,p0=78,p0:24=56,p1,p3:0=0,p3:20=32,s=0,s0=6,s3=-1,a=0,g=1,z=1\n");
fprintf(stdout," h,h0=64,h3=16,h5=32,p0=78,p0:24=56,p1,p3:0=0,p3:20=32,s=0,\n");
fprintf(stdout," s0=6,s3=-1,a=0,g=1,z=1\n");
fprintf(stdout," means\n");
fprintf(stdout," predefined EPB in MH, rs(64,32) from TPH 0 to TPH 2,\n");
fprintf(stdout," CRC-16 in TPH 3 and TPH 4, CRC-32 in remaining TPHs,\n");
fprintf(stdout," UEP rs(78,32) for packets 0 to 23 of tile 0,\n");
fprintf(stdout," UEP rs(56,32) for packets 24 to the last of tile 0,\n");
fprintf(stdout," UEP rs default for packets of tile 1,\n");
fprintf(stdout," no UEP for packets 0 to 19 of tile 3,\n");
fprintf(stdout," UEP CRC-32 for packets 20 of tile 3 to last tile,\n");
fprintf(stdout," UEP rs(56,32) for packs. 24 to the last of tilepart 0,\n");
fprintf(stdout," UEP rs default for packets of tilepart 1,\n");
fprintf(stdout," no UEP for packets 0 to 19 of tilepart 3,\n");
fprintf(stdout," UEP CRC-32 for packs. 20 of tilepart 3 to last tilepart,\n");
fprintf(stdout," relative sensitivity ESD for MH,\n");
fprintf(stdout," TSE ESD from TPH 0 to TPH 2, byte range with automatic\n");
fprintf(stdout," size of addresses and 1 byte for each sensitivity value\n");
@@ -282,20 +284,28 @@ void encode_help_display() {
fprintf(stdout,"Image_height Image_width\n");
fprintf(stdout,"progression order\n");
fprintf(stdout,"Tiles_size_X Tiles_size_Y\n");
/* UniPG>> */
fprintf(stdout,"Tiles_nb_X Tiles_nb_Y\n");
/* <<UniPG */
fprintf(stdout,"Components_nb\n");
fprintf(stdout,"Layers_nb\n");
fprintf(stdout,"decomposition_levels\n");
fprintf(stdout,"[Precincts_size_X_res_Nr Precincts_size_Y_res_Nr]...\n");
fprintf(stdout," [Precincts_size_X_res_0 Precincts_size_Y_res_0]\n");
fprintf(stdout,"Main_header_start_position\n");
fprintf(stdout,"Main_header_end_position\n");
fprintf(stdout,"Codestream_size\n");
fprintf(stdout,"Tile_0 start_pos end_Theader end_pos TotalDisto NumPix MaxMSE\n");
fprintf(stdout,"Tile_1 '' '' '' '' '' ''\n");
fprintf(stdout,"\n");
fprintf(stdout,"INFO ON TILES\n");
fprintf(stdout,"tileno start_pos end_hd end_tile nbparts disto nbpix disto/nbpix\n");
fprintf(stdout,"Tile_0 start_pos end_Theader end_pos NumParts TotalDisto NumPix MaxMSE\n");
fprintf(stdout,"Tile_1 '' '' '' '' '' '' ''\n");
fprintf(stdout,"...\n");
fprintf(stdout,"Tile_Nt '' '' '' '' '' ''\n");
fprintf(stdout,"Tile_Nt '' '' '' '' '' '' ''\n");
fprintf(stdout,"...\n");
fprintf(stdout,"TILE 0 DETAILS\n");
fprintf(stdout,"part_nb tileno num_packs start_pos end_tph_pos end_pos\n");
fprintf(stdout,"...\n");
fprintf(stdout,"Progression_string\n");
fprintf(stdout,"pack_nb tileno layno resno compno precno start_pos end_ph_pos end_pos disto\n");
fprintf(stdout,"Tpacket_0 Tile layer res. comp. prec. start_pos end_pos disto\n");
fprintf(stdout,"...\n");
fprintf(stdout,"Tpacket_Np '' '' '' '' '' '' '' ''\n");
@@ -375,10 +385,10 @@ int load_images(dircnt_t *dirptr, char *imgdirpath){
int get_file_format(char *filename) {
unsigned int i;
static const char *extension[] = {
"pgx", "pnm", "pgm", "ppm", "bmp","tif", "j2k", "jp2", "j2c"
"pgx", "pnm", "pgm", "ppm", "bmp", "tif", "raw", "tga", "j2k", "jp2", "j2c"
};
static const int format[] = {
PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT,TIF_DFMT, J2K_CFMT, JP2_CFMT, J2K_CFMT
PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, J2K_CFMT, JP2_CFMT, J2K_CFMT
};
char * ext = strrchr(filename, '.');
if (ext == NULL)
@@ -389,7 +399,6 @@ int get_file_format(char *filename) {
return format[i];
}
}
return -1;
}
@@ -402,6 +411,7 @@ char * get_file_name(char *name){
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]="";
strcpy(image_filename,dirptr->filename[imageno]);
fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
@@ -413,6 +423,10 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_cparamet
//Set output file
strcpy(temp_ofname,get_file_name(image_filename));
while((temp_p = strtok(NULL,".")) != NULL){
strcat(temp_ofname,temp1);
sprintf(temp1,".%s",temp_p);
}
if(img_fol->set_out_format==1){
sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
strncpy(parameters->outfile, outfilename, sizeof(outfilename));
@@ -471,7 +485,7 @@ void cinema_parameters(opj_cparameters_t *parameters){
}
void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image){
void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol){
int i;
float temp_rate;
opj_poc_t *POC = NULL;
@@ -483,7 +497,9 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image){
parameters->numresolution = 6;
}
if (!((image->comps[0].w == 2048) | (image->comps[0].h == 1080))){
fprintf(stdout,"Image coordinates %d x %d is not 2K compliant.\nJPEG Digital Cinema Profile-3 (2K profile) compliance requires that at least one of coordinates match 2048 x 1080\n",image->comps[0].w,image->comps[0].h);
fprintf(stdout,"Image coordinates %d x %d is not 2K compliant.\nJPEG Digital Cinema Profile-3 "
"(2K profile) compliance requires that at least one of coordinates match 2048 x 1080\n",
image->comps[0].w,image->comps[0].h);
parameters->cp_rsiz = STD_RSIZ;
}
break;
@@ -495,7 +511,9 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image){
parameters->numresolution = 7;
}
if (!((image->comps[0].w == 4096) | (image->comps[0].h == 2160))){
fprintf(stdout,"Image coordinates %d x %d is not 4K compliant.\nJPEG Digital Cinema Profile-4 (4K profile) compliance requires that atleast one of coordinates match 4096 x 2160\n",image->comps[0].w,image->comps[0].h);
fprintf(stdout,"Image coordinates %d x %d is not 4K compliant.\nJPEG Digital Cinema Profile-4"
"(4K profile) compliance requires that at least one of coordinates match 4096 x 2160\n",
image->comps[0].w,image->comps[0].h);
parameters->cp_rsiz = STD_RSIZ;
}
parameters->numpocs = initialise_4K_poc(parameters->POC,parameters->numresolution);
@@ -507,15 +525,17 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image){
case CINEMA4K_24:
for(i=0 ; i<parameters->tcp_numlayers ; i++){
temp_rate = 0 ;
if (parameters->tcp_rates[i]== 0){
if (img_fol->rates[i]== 0){
parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
}else{
temp_rate =((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(parameters->tcp_rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
(img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
if (temp_rate > CINEMA_24_CS ){
parameters->tcp_rates[i]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy);
}else{
parameters->tcp_rates[i]= img_fol->rates[i];
}
}
}
@@ -525,15 +545,17 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image){
case CINEMA2K_48:
for(i=0 ; i<parameters->tcp_numlayers ; i++){
temp_rate = 0 ;
if (parameters->tcp_rates[i]== 0){
if (img_fol->rates[i]== 0){
parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
}else{
temp_rate =((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(parameters->tcp_rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
(img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
if (temp_rate > CINEMA_48_CS ){
parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
}else{
parameters->tcp_rates[i]= img_fol->rates[i];
}
}
}
@@ -545,7 +567,8 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image){
/* ------------------------------------------------------------------------------------ */
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,img_fol_t *img_fol) {
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;
option_t long_option[]={
{"cinema2K",REQ_ARG, NULL ,'w'},
@@ -556,11 +579,11 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
{"EPH",NO_ARG, NULL ,'E'},
{"OutFor",REQ_ARG, NULL ,'O'},
{"POC",REQ_ARG, NULL ,'P'},
{"ROI",REQ_ARG, NULL ,'R'},
};
/* parse the command line */
/* UniPG>> */
const char optlist[] = "i:o:hr:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:"
const char optlist[] = "i:o:hr:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:F:"
#ifdef USE_JPWL
"W:"
#endif /* USE_JPWL */
@@ -568,10 +591,10 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
totlen=sizeof(long_option);
img_fol->set_out_format=0;
raw_cp->rawWidth = 0;
while (1) {
int c = getopt_long(argc, argv, optlist,long_option,totlen);
/* <<UniPG */
if (c == -1)
break;
switch (c) {
@@ -584,11 +607,13 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
case PXM_DFMT:
case BMP_DFMT:
case TIF_DFMT:
case RAW_DFMT:
case TGA_DFMT:
break;
default:
fprintf(stderr,
"!! Unrecognized format for infile : %s "
"[accept only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp or *.tif] !!\n\n",
"[accept only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga] !!\n\n",
infile);
return 1;
}
@@ -607,7 +632,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
case JP2_CFMT:
break;
default:
fprintf(stderr, "Unknown output format image %s [only *.j2k, *.jp2]!! \n", outfile);
fprintf(stderr, "Unknown output format image %s [only *.j2k, *.j2c or *.jp2]!! \n", outfile);
return 1;
}
strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
@@ -628,7 +653,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
img_fol->out_format = optarg;
break;
default:
fprintf(stderr, "Unknown output format image [only j2k, jp2]!! \n");
fprintf(stderr, "Unknown output format image [only j2k, j2c, jp2]!! \n");
return 1;
}
}
@@ -656,6 +681,41 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
/* ----------------------------------------------------- */
case 'F': /* Raw image format parameters */
{
char signo;
char *s = optarg;
if (sscanf(s, "%d,%d,%d,%d,%c", &raw_cp->rawWidth, &raw_cp->rawHeight, &raw_cp->rawComp, &raw_cp->rawBitDepth, &signo) == 5) {
if (signo == 's') {
raw_cp->rawSigned = true;
fprintf(stdout,"\nRaw file parameters: %d,%d,%d,%d Signed\n", raw_cp->rawWidth, raw_cp->rawHeight, raw_cp->rawComp, raw_cp->rawBitDepth);
}
else if (signo == 'u') {
raw_cp->rawSigned = false;
fprintf(stdout,"\nRaw file parameters: %d,%d,%d,%d Unsigned\n", raw_cp->rawWidth, raw_cp->rawHeight, raw_cp->rawComp, raw_cp->rawBitDepth);
}
else {
fprintf(stderr,"\nError: invalid raw image parameters: Unknown sign of raw file\n");
fprintf(stderr,"Please use the Format option -F:\n");
fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
fprintf(stderr,"Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
fprintf(stderr,"Aborting\n");
}
}
else {
fprintf(stderr,"\nError: invalid raw image parameters\n");
fprintf(stderr,"Please use the Format option -F:\n");
fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
fprintf(stderr,"Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
fprintf(stderr,"Aborting\n");
return 1;
}
}
break;
/* ----------------------------------------------------- */
case 'q': /* add fixed_quality */
{
char *s = optarg;
@@ -780,8 +840,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
case 'x': /* creation of index file */
{
char *index = optarg;
strncpy(parameters->index, index, sizeof(parameters->index)-1);
parameters->index_on = 1;
strncpy(indexfilename, index, OPJ_PATH_LEN);
}
break;
@@ -895,9 +954,9 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
case 'R': /* ROI */
{
if (sscanf(optarg, "OI:c=%d,U=%d", &parameters->roi_compno,
if (sscanf(optarg, "c=%d,U=%d", &parameters->roi_compno,
&parameters->roi_shift) != 2) {
fprintf(stderr, "ROI error !! [-ROI:c='compno',U='shift']\n");
fprintf(stderr, "ROI error !! [-ROI c='compno',U='shift']\n");
return 1;
}
}
@@ -995,9 +1054,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
int hprot, pprot, sens, addr, size, range;
/* we need to enable indexing */
if (!parameters->index_on) {
strncpy(parameters->index, JPWL_PRIVATEINDEX_NAME, sizeof(parameters->index)-1);
parameters->index_on = 1;
if (!indexfilename) {
strncpy(indexfilename, JPWL_PRIVATEINDEX_NAME, OPJ_PATH_LEN);
}
/* search for different protection methods */
@@ -1026,11 +1084,11 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
/* Tile part header, specified */
if (!((hprot == 0) || (hprot == 1) || (hprot == 16) || (hprot == 32) ||
((hprot >= 37) && (hprot <= 128)))) {
fprintf(stderr, "ERROR -> invalid tile header protection method h = %d\n", hprot);
fprintf(stderr, "ERROR -> invalid tile part header protection method h = %d\n", hprot);
return 1;
}
if (tile < 0) {
fprintf(stderr, "ERROR -> invalid tile number on protection method t = %d\n", tile);
fprintf(stderr, "ERROR -> invalid tile part number on protection method t = %d\n", tile);
return 1;
}
if (tilespec < JPWL_MAX_NO_TILESPECS) {
@@ -1041,7 +1099,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
} else if(sscanf(token, "h%d", &tile) == 1) {
/* Tile part header, unspecified */
if (tile < 0) {
fprintf(stderr, "ERROR -> invalid tile number on protection method t = %d\n", tile);
fprintf(stderr, "ERROR -> invalid tile part number on protection method t = %d\n", tile);
return 1;
}
if (tilespec < JPWL_MAX_NO_TILESPECS) {
@@ -1087,7 +1145,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
return 1;
}
if (tile < 0) {
fprintf(stderr, "ERROR -> invalid tile number on protection method p = %d\n", tile);
fprintf(stderr, "ERROR -> invalid tile part number on protection method p = %d\n", tile);
return 1;
}
if (packspec < JPWL_MAX_NO_PACKSPECS) {
@@ -1104,7 +1162,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
return 1;
}
if (tile < 0) {
fprintf(stderr, "ERROR -> invalid tile number on protection method p = %d\n", tile);
fprintf(stderr, "ERROR -> invalid tile part number on protection method p = %d\n", tile);
return 1;
}
if (pack < 0) {
@@ -1125,7 +1183,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
return 1;
}
if (tile < 0) {
fprintf(stderr, "ERROR -> invalid tile number on protection method p = %d\n", tile);
fprintf(stderr, "ERROR -> invalid tile part number on protection method p = %d\n", tile);
return 1;
}
if (pack < 0) {
@@ -1141,7 +1199,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
} else if (sscanf(token, "p%d", &tile) == 1) {
/* default from a tile on */
if (tile < 0) {
fprintf(stderr, "ERROR -> invalid tile number on protection method p = %d\n", tile);
fprintf(stderr, "ERROR -> invalid tile part number on protection method p = %d\n", tile);
return 1;
}
if (packspec < JPWL_MAX_NO_PACKSPECS) {
@@ -1182,11 +1240,11 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
} else if(sscanf(token, "s%d=%d", &tile, &sens) == 2) {
/* Tile part header, specified */
if ((sens < -1) || (sens > 7)) {
fprintf(stderr, "ERROR -> invalid tile header sensitivity method s = %d\n", sens);
fprintf(stderr, "ERROR -> invalid tile part header sensitivity method s = %d\n", sens);
return 1;
}
if (tile < 0) {
fprintf(stderr, "ERROR -> invalid tile number on sensitivity method t = %d\n", tile);
fprintf(stderr, "ERROR -> invalid tile part number on sensitivity method t = %d\n", tile);
return 1;
}
if (tilespec < JPWL_MAX_NO_TILESPECS) {
@@ -1197,7 +1255,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
} else if(sscanf(token, "s%d", &tile) == 1) {
/* Tile part header, unspecified */
if (tile < 0) {
fprintf(stderr, "ERROR -> invalid tile number on sensitivity method t = %d\n", tile);
fprintf(stderr, "ERROR -> invalid tile part number on sensitivity method t = %d\n", tile);
return 1;
}
if (tilespec < JPWL_MAX_NO_TILESPECS) {
@@ -1348,6 +1406,15 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
}
}
if (parameters->decod_format == RAW_DFMT && raw_cp->rawWidth == 0) {
fprintf(stderr,"\nError: invalid raw image parameters\n");
fprintf(stderr,"Please use the Format option -F:\n");
fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
fprintf(stderr,"Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
fprintf(stderr,"Aborting\n");
return 1;
}
if ((parameters->cp_disto_alloc || parameters->cp_fixed_alloc || parameters->cp_fixed_quality)
&& (!(parameters->cp_disto_alloc ^ parameters->cp_fixed_alloc ^ parameters->cp_fixed_quality))) {
fprintf(stderr, "Error: options -r -q and -f cannot be used together !!\n");
@@ -1414,6 +1481,9 @@ int main(int argc, char **argv) {
int i,num_images;
int imageno;
dircnt_t *dirptr;
raw_cparameters_t raw_cp;
opj_codestream_info_t cstr_info; /* Codestream information structure */
char indexfilename[OPJ_PATH_LEN]; /* index file name */
/*
configure the event callbacks (not required)
@@ -1427,16 +1497,23 @@ int main(int argc, char **argv) {
/* set encoding parameters to default values */
opj_set_default_encoder_parameters(&parameters);
/* Initialize indexfilename and img_fol */
*indexfilename = 0;
memset(&img_fol,0,sizeof(img_fol_t));
/* parse input and get user encoding parameters */
if(parse_cmdline_encoder(argc, argv, &parameters,&img_fol) == 1) {
return 0;
if(parse_cmdline_encoder(argc, argv, &parameters,&img_fol, &raw_cp, indexfilename) == 1) {
return 1;
}
if (parameters.cp_cinema){
img_fol.rates = (float*)malloc(parameters.tcp_numlayers * sizeof(float));
for(i=0; i< parameters.tcp_numlayers; i++){
img_fol.rates[i] = parameters.tcp_rates[i];
}
cinema_parameters(&parameters);
}
/* Create comment for codestream */
if(parameters.cp_comment == NULL) {
const char comment[] = "Created by OpenJPEG version ";
@@ -1451,19 +1528,15 @@ int main(int argc, char **argv) {
sprintf(parameters.cp_comment,"%s%s", comment, version);
#endif
/* <<UniPG */
}
/* Read directory if necessary */
if(img_fol.set_imgdir==1){
num_images=get_num_images(img_fol.imgdirpath);
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
if(dirptr){
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); // Stores at max 10 image file names
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
if(!dirptr->filename_buf){
return 0;
}
@@ -1482,13 +1555,10 @@ int main(int argc, char **argv) {
num_images=1;
}
/*Encoding image one by one*/
for(imageno=0;imageno<num_images;imageno++)
{
for(imageno=0;imageno<num_images;imageno++) {
image = NULL;
fprintf(stderr,"\n");
if(img_fol.set_imgdir==1){
if (get_next_file(imageno, dirptr,&img_fol, &parameters)) {
fprintf(stderr,"skipping file...\n");
@@ -1504,7 +1574,10 @@ int main(int argc, char **argv) {
break;
case TIF_DFMT:
break;
case RAW_DFMT:
break;
case TGA_DFMT:
break;
default:
fprintf(stderr,"skipping file...\n");
continue;
@@ -1545,12 +1618,28 @@ int main(int argc, char **argv) {
return 1;
}
break;
case RAW_DFMT:
image = rawtoimage(parameters.infile, &parameters, &raw_cp);
if (!image) {
fprintf(stderr, "Unable to load raw file\n");
return 1;
}
break;
case TGA_DFMT:
image = tgatoimage(parameters.infile, &parameters);
if (!image) {
fprintf(stderr, "Unable to load tga file\n");
return 1;
}
break;
}
/* Decide if MCT should be used */
parameters.tcp_mct = image->numcomps == 3 ? 1 : 0;
if(parameters.cp_cinema){
cinema_setup_encoder(&parameters,image);
cinema_setup_encoder(&parameters,image,&img_fol);
}
/* encode the destination image */
@@ -1575,7 +1664,10 @@ int main(int argc, char **argv) {
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
/* encode the image */
bSuccess = opj_encode(cinfo, cio, image, parameters.index);
if (*indexfilename) // If need to extract codestream information
bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
else
bSuccess = opj_encode(cinfo, cio, image, NULL);
if (!bSuccess) {
opj_cio_close(cio);
fprintf(stderr, "failed to encode image\n");
@@ -1596,9 +1688,18 @@ int main(int argc, char **argv) {
/* close and free the byte stream */
opj_cio_close(cio);
/* Write the index to disk */
if (*indexfilename) {
bSuccess = write_index_file(&cstr_info, indexfilename);
if (bSuccess) {
fprintf(stderr, "Failed to output index file into [%s]\n", indexfilename);
}
}
/* free remaining compression structures */
opj_destroy_compress(cinfo);
if (*indexfilename)
opj_destroy_cstr_info(&cstr_info);
} else { /* JP2 format output */
int codestream_length;
opj_cio_t *cio = NULL;
@@ -1618,7 +1719,10 @@ int main(int argc, char **argv) {
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
/* encode the image */
bSuccess = opj_encode(cinfo, cio, image, parameters.index);
if (*indexfilename) // If need to extract codestream information
bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
else
bSuccess = opj_encode(cinfo, cio, image, NULL);
if (!bSuccess) {
opj_cio_close(cio);
fprintf(stderr, "failed to encode image\n");
@@ -1638,9 +1742,18 @@ int main(int argc, char **argv) {
/* close and free the byte stream */
opj_cio_close(cio);
/* Write the index to disk */
if (*indexfilename) {
bSuccess = write_index_file(&cstr_info, indexfilename);
if (bSuccess) {
fprintf(stderr, "Failed to output index file\n");
}
}
/* free remaining compression structures */
opj_destroy_compress(cinfo);
if (*indexfilename)
opj_destroy_cstr_info(&cstr_info);
}
/* free image data */
@@ -1653,4 +1766,3 @@ int main(int argc, char **argv) {
return 0;
}

View File

@@ -51,7 +51,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"libc"
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"LIBC"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "image_to_j2k - Win32 Debug"
@@ -77,7 +77,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"LIBC" /nodefaultlib:"LIBCMT" /pdbtype:sept
# SUBTRACT LINK32 /pdb:none
!ENDIF
@@ -106,5 +106,13 @@ SOURCE=.\compat\getopt.h
SOURCE=.\image_to_j2k.c
# End Source File
# Begin Source File
SOURCE=.\index.c
# End Source File
# Begin Source File
SOURCE=.\index.h
# End Source File
# End Target
# End Project

BIN
codec/image_to_j2k.sln Normal file

Binary file not shown.

292
codec/image_to_j2k.vcproj Normal file
View File

@@ -0,0 +1,292 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="image_to_j2k"
ProjectGUID="{81FBE6CF-1DFB-413F-8215-0851F8E2D252}"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Release/image_to_j2k.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="../libopenjpeg"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\Release/image_to_j2k.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1036"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib"
OutputFile=".\Release/image_to_j2k.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
IgnoreDefaultLibraryNames="LIBC"
ProgramDatabaseFile=".\Release/image_to_j2k.pdb"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release/image_to_j2k.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/image_to_j2k.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../libopenjpeg"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug/image_to_j2k.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1036"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib"
OutputFile=".\Debug/image_to_j2k.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
IgnoreDefaultLibraryNames="LIBC,LIBCMT"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/image_to_j2k.pdb"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/image_to_j2k.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="convert.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="convert.h"
>
</File>
<File
RelativePath="compat\getopt.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="compat\getopt.h"
>
</File>
<File
RelativePath="image_to_j2k.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath=".\index.c"
>
</File>
<File
RelativePath=".\index.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

391
codec/index.c Normal file
View File

@@ -0,0 +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);
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;
}

49
codec/index.h Normal file
View File

@@ -0,0 +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 */

View File

@@ -32,11 +32,13 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "openjpeg.h"
#include "compat/getopt.h"
#include "convert.h"
#include "dirent.h"
#include "index.h"
#ifndef WIN32
#define stricmp strcasecmp
@@ -54,6 +56,8 @@
#define BMP_DFMT 12
#define YUV_DFMT 13
#define TIF_DFMT 14
#define RAW_DFMT 15
#define TGA_DFMT 16
/* ----------------------------------------------------------------------- */
@@ -95,15 +99,15 @@ void decode_help_display() {
fprintf(stdout," -OutFor \n");
fprintf(stdout," REQUIRED only if -ImgDir is used\n");
fprintf(stdout," Need to specify only format without filename <BMP> \n");
fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, BMP format\n");
fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA formats\n");
fprintf(stdout," -i <compressed file>\n");
fprintf(stdout," REQUIRED only if an Input image directory not specified\n");
fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
fprintf(stdout," is identified based on its suffix.\n");
fprintf(stdout," -o <decompressed file>\n");
fprintf(stdout," REQUIRED\n");
fprintf(stdout," Currently accepts PGM-files, PPM-files, PNM-files, PGX-files and\n");
fprintf(stdout," BMP-files. Binary data is written to the file (not ascii). If a PGX\n");
fprintf(stdout," Currently accepts PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA files\n");
fprintf(stdout," Binary data is written to the file (not ascii). If a PGX\n");
fprintf(stdout," filename is given, there will be as many output files as there are\n");
fprintf(stdout," components: an indice starting from 0 will then be appended to the\n");
fprintf(stdout," output filename, just before the \"pgx\" extension. If a PGM filename\n");
@@ -118,6 +122,9 @@ void decode_help_display() {
fprintf(stdout," Set the maximum number of quality layers to decode. If there are\n");
fprintf(stdout," less quality layers than the specified number, all the quality layers\n");
fprintf(stdout," are decoded.\n");
fprintf(stdout," -x \n");
fprintf(stdout," Create an index file *.Idx (-x index_name.Idx) \n");
fprintf(stdout,"\n");
/* UniPG>> */
#ifdef USE_JPWL
fprintf(stdout," -W <options>\n");
@@ -181,8 +188,8 @@ int load_images(dircnt_t *dirptr, char *imgdirpath){
int get_file_format(char *filename) {
unsigned int i;
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "j2k", "jp2", "jpt", "j2c" };
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT };
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "j2k", "jp2", "jpt", "j2c" };
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT };
char * ext = strrchr(filename, '.');
if (ext == NULL)
return -1;
@@ -200,6 +207,7 @@ int get_file_format(char *filename) {
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
char *temp_p, temp1[OPJ_PATH_LEN]="";
strcpy(image_filename,dirptr->filename[imageno]);
fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
@@ -211,6 +219,10 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparamet
//Set output file
strcpy(temp_ofname,strtok(image_filename,"."));
while((temp_p = strtok(NULL,".")) != NULL){
strcat(temp_ofname,temp1);
sprintf(temp1,".%s",temp_p);
}
if(img_fol->set_out_format==1){
sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
strncpy(parameters->outfile, outfilename, sizeof(outfilename));
@@ -218,10 +230,8 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparamet
return 0;
}
/* -------------------------------------------------------------------------- */
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
/* parse the command line */
int totlen;
option_t long_option[]={
@@ -229,14 +239,14 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
{"OutFor",REQ_ARG, NULL ,'O'},
};
/* UniPG>> */
const char optlist[] = "i:o:r:l:h"
const char optlist[] = "i:o:r:l:hx:"
/* UniPG>> */
#ifdef USE_JPWL
"W:"
#endif /* USE_JPWL */
;
/* <<UniPG */
;
totlen=sizeof(long_option);
img_fol->set_out_format = 0;
while (1) {
@@ -274,9 +284,11 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
case PXM_DFMT:
case BMP_DFMT:
case TIF_DFMT:
case RAW_DFMT:
case TGA_DFMT:
break;
default:
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx or *.bmp]!! \n", outfile);
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outfile);
return 1;
}
strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
@@ -305,8 +317,14 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
case TIF_DFMT:
img_fol->out_format = "tif";
break;
case RAW_DFMT:
img_fol->out_format = "raw";
break;
case TGA_DFMT:
img_fol->out_format = "raw";
break;
default:
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx or *.bmp]!! \n");
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outformat);
return 1;
break;
}
@@ -347,6 +365,13 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
}
break;
/* ----------------------------------------------------- */
case 'x': /* Creation of index file */
{
char *index = optarg;
strncpy(indexfilename, index, OPJ_PATH_LEN);
}
break;
/* ----------------------------------------------------- */
/* UniPG>> */
#ifdef USE_JPWL
@@ -434,7 +459,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
}
if(img_fol->set_out_format == 0){
fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX,BMP!!\n");
fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
return 1;
}
if(!((parameters->outfile[0] == 0))){
@@ -443,9 +468,9 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
}
}else{
if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
fprintf(stderr, "Error: One of option; -i or -ImgDir must be specified\n");
fprintf(stderr, "Error: When using -i; -o must be used\n");
fprintf(stderr, "usage: image_to_j2k -i *.j2k/jp2 -o *.pgm/ppm/pnm/pgx/bmp(+ options)\n");
fprintf(stderr, "Error: One of the options -i or -ImgDir must be specified\n");
fprintf(stderr, "Error: When using -i, -o must be used\n");
fprintf(stderr, "usage: image_to_j2k -i *.j2k/jp2/j2c -o *.pgm/ppm/pnm/pgx/bmp/tif/raw/tga(+ options)\n");
return 1;
}
}
@@ -492,6 +517,8 @@ int main(int argc, char **argv) {
dircnt_t *dirptr;
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
opj_cio_t *cio = NULL;
opj_codestream_info_t cstr_info; /* Codestream information structure */
char indexfilename[OPJ_PATH_LEN]; /* index file name */
/* configure the event callbacks (not required) */
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
@@ -502,12 +529,16 @@ int main(int argc, char **argv) {
/* set decoding parameters to default values */
opj_set_default_decoder_parameters(&parameters);
/* Initialize indexfilename and img_fol */
*indexfilename = 0;
memset(&img_fol,0,sizeof(img_fol_t));
/* parse input and get user encoding parameters */
if(parse_cmdline_decoder(argc, argv, &parameters,&img_fol) == 1) {
return 0;
if(parse_cmdline_decoder(argc, argv, &parameters,&img_fol, indexfilename) == 1) {
return 1;
}
/* Initialize reading of directory */
if(img_fol.set_imgdir==1){
num_images=get_num_images(img_fol.imgdirpath);
@@ -535,9 +566,7 @@ int main(int argc, char **argv) {
}
/*Encoding image one by one*/
for(imageno = 0; imageno < num_images ; imageno++)
{
for(imageno = 0; imageno < num_images ; imageno++) {
image = NULL;
fprintf(stderr,"\n");
@@ -546,10 +575,8 @@ int main(int argc, char **argv) {
fprintf(stderr,"skipping file...\n");
continue;
}
}
/* read the input file and put it in memory */
/* ---------------------------------------- */
fsrc = fopen(parameters.infile, "rb");
@@ -564,8 +591,6 @@ int main(int argc, char **argv) {
fread(src, 1, file_length, fsrc);
fclose(fsrc);
/* decode the code-stream */
/* ---------------------- */
@@ -587,6 +612,9 @@ 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
image = opj_decode_with_info(dinfo, cio, &cstr_info);
else
image = opj_decode(dinfo, cio);
if(!image) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
@@ -597,6 +625,15 @@ int main(int argc, char **argv) {
/* close the byte stream */
opj_cio_close(cio);
/* Write the index to disk */
if (*indexfilename) {
char bSuccess;
bSuccess = write_index_file(&cstr_info, indexfilename);
if (bSuccess) {
fprintf(stderr, "Failed to output index file\n");
}
}
}
break;
@@ -617,6 +654,9 @@ 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
image = opj_decode_with_info(dinfo, cio, &cstr_info);
else
image = opj_decode(dinfo, cio);
if(!image) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
@@ -628,6 +668,14 @@ int main(int argc, char **argv) {
/* close the byte stream */
opj_cio_close(cio);
/* Write the index to disk */
if (*indexfilename) {
char bSuccess;
bSuccess = write_index_file(&cstr_info, indexfilename);
if (bSuccess) {
fprintf(stderr, "Failed to output index file\n");
}
}
}
break;
@@ -648,6 +696,9 @@ 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
image = opj_decode_with_info(dinfo, cio, &cstr_info);
else
image = opj_decode(dinfo, cio);
if(!image) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
@@ -658,6 +709,15 @@ int main(int argc, char **argv) {
/* close the byte stream */
opj_cio_close(cio);
/* Write the index to disk */
if (*indexfilename) {
char bSuccess;
bSuccess = write_index_file(&cstr_info, indexfilename);
if (bSuccess) {
fprintf(stderr, "Failed to output index file\n");
}
}
}
break;
@@ -708,12 +768,33 @@ int main(int argc, char **argv) {
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
}
break;
case RAW_DFMT: /* RAW */
if(imagetoraw(image, parameters.outfile)){
fprintf(stdout,"Error generating raw file. Outfile %s not generated\n",parameters.outfile);
}
else {
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
}
break;
case TGA_DFMT: /* TGA */
if(imagetotga(image, parameters.outfile)){
fprintf(stdout,"Error generating tga file. Outfile %s not generated\n",parameters.outfile);
}
else {
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
}
break;
}
/* free remaining structures */
if(dinfo) {
opj_destroy_decompress(dinfo);
}
/* free codestream information structure */
if (*indexfilename)
opj_destroy_cstr_info(&cstr_info);
/* free image data structure */
opj_image_destroy(image);
@@ -722,3 +803,6 @@ int main(int argc, char **argv) {
}
//end main

View File

@@ -76,7 +76,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libc" /nodefaultlib:"libcmt" /pdbtype:sept
# SUBTRACT LINK32 /pdb:none
!ENDIF
@@ -103,6 +103,14 @@ SOURCE=.\compat\getopt.h
# End Source File
# Begin Source File
SOURCE=.\index.c
# End Source File
# Begin Source File
SOURCE=.\index.h
# End Source File
# Begin Source File
SOURCE=.\j2k_to_image.c
# End Source File
# End Target

BIN
codec/j2k_to_image.sln Normal file

Binary file not shown.

291
codec/j2k_to_image.vcproj Normal file
View File

@@ -0,0 +1,291 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="j2k_to_image"
ProjectGUID="{28931669-81A2-4B90-8981-CD707C4E76E6}"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/j2k_to_image.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../libopenjpeg"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug/j2k_to_image.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1036"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib"
OutputFile=".\Debug/j2k_to_image.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
IgnoreDefaultLibraryNames="libc,libcmt"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/j2k_to_image.pdb"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/j2k_to_image.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Release/j2k_to_image.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="../libopenjpeg"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OPJ_STATIC;_CRT_SECURE_NO_DEPRECATE"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\Release/j2k_to_image.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1036"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib"
OutputFile=".\Release/j2k_to_image.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
IgnoreDefaultLibraryNames="libc"
ProgramDatabaseFile=".\Release/j2k_to_image.pdb"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release/j2k_to_image.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="convert.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="convert.h"
>
</File>
<File
RelativePath="compat\getopt.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="compat\getopt.h"
>
</File>
<File
RelativePath=".\index.c"
>
</File>
<File
RelativePath=".\index.h"
>
</File>
<File
RelativePath="j2k_to_image.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

12
doc/CMakeLists.txt Normal file
View File

@@ -0,0 +1,12 @@
FIND_PACKAGE(Doxygen REQUIRED)
# The Doxyfile.dox is poorly defined and produce output
# in the source dir
ADD_CUSTOM_TARGET(doxygen
# By default doxygen target is added to the 'all' target. Project is small
# thus running doxygen is not too time consuming
ALL
${DOXYGEN}
${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.dox
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

View File

@@ -190,7 +190,8 @@ EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED = USE_JPWL
PREDEFINED = USE_JPWL \
USE_JPSEC
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------

View File

@@ -0,0 +1,5 @@
# index_create
ADD_EXECUTABLE(index_create
bio.c cio.c int.c pi.c t2.c tgt.c tcd.c index_create.c jpip.c jp2.c
)

View File

@@ -0,0 +1,8 @@
PROJECT(j2kviewer Java)
ADD_LIBRARY(j2kviewer
Exec.java
ImageViewer.java
MML.java
PgmImage.java
)

11
jp3d/CMakeLists.txt Normal file
View File

@@ -0,0 +1,11 @@
# Linux makefile for OpenJPEG
#VER_MAJOR = 1
#VER_MINOR = 0.0
SUBDIRS(
libjp3dvm
codec
)

53
jp3d/codec/CMakeLists.txt Normal file
View File

@@ -0,0 +1,53 @@
# Build the demo app, small examples
# First thing define the common source:
SET(common_SRCS
convert.c
)
# Then check if getopt is present:
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
SET(DONT_HAVE_GETOPT 1)
IF(UNIX) #I am pretty sure only *nix sys have this anyway
CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
# Seems like we need the contrary:
IF(CMAKE_HAVE_GETOPT_H)
SET(DONT_HAVE_GETOPT 0)
ENDIF(CMAKE_HAVE_GETOPT_H)
ENDIF(UNIX)
# If not getopt was found then add it to the lib:
IF(DONT_HAVE_GETOPT)
ADD_DEFINITIONS(-DDONT_HAVE_GETOPT)
SET(common_SRCS
${common_SRCS}
compat/getopt.c
)
ENDIF(DONT_HAVE_GETOPT)
# Headers file are located here:
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/../libjp3dvm
)
# Do the proper thing when building static...if only there was configured
# headers or def files instead
#IF(NOT BUILD_SHARED_LIBS)
# ADD_DEFINITIONS(-DOPJ_STATIC)
#ENDIF(NOT BUILD_SHARED_LIBS)
#FIND_PACKAGE(TIFF REQUIRED)
# Loop over all executables:
FOREACH(exe jp3d_to_volume volume_to_jp3d)
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
TARGET_LINK_LIBRARIES(${exe} ${OPJ_PREFIX}openjp3dvm) # ${TIFF_LIBRARIES})
# On unix you need to link to the math library:
IF(UNIX)
TARGET_LINK_LIBRARIES(${exe} m)
ENDIF(UNIX)
# Install exe
INSTALL_TARGETS(/bin/ ${exe})
ENDFOREACH(exe)

View File

@@ -0,0 +1,24 @@
INCLUDE_REGULAR_EXPRESSION("^.*$")
# Defines the source code for the library
SET(JP3DVM_SRCS
bio.c cio.c dwt.c event.c jp3d.c jp3d_lib.c mct.c mqc.c openjpeg.c pi.c raw.c t1.c t1_3d.c t2.c tcd.c tgt.c volume.c
)
# Pass proper definition to preprocessor to generate shared lib
IF(WIN32)
IF(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DOPJ_EXPORTS)
ELSE(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DOPJ_STATIC)
ENDIF(BUILD_SHARED_LIBS)
ENDIF(WIN32)
# Create the library
#ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS})
ADD_LIBRARY(${OPJ_PREFIX}openjp3dvm ${JP3DVM_SRCS})
# Install library
INSTALL_TARGETS(/lib/ ${OPJ_PREFIX}openjp3dvm)
# Install includes files
INSTALL_FILES(/include .h)

55
jpwl/CMakeLists.txt Executable file
View File

@@ -0,0 +1,55 @@
# Makefile for the main JPWL OpenJPEG codecs: JPWL_ j2k_to_image and JPWL_image_to_j2k
ADD_DEFINITIONS(-DUSE_JPWL)
SET(OPJ_SRCS
../libopenjpeg/bio.c
../libopenjpeg/cio.c
../libopenjpeg/dwt.c
../libopenjpeg/event.c
../libopenjpeg/image.c
../libopenjpeg/j2k.c
../libopenjpeg/j2k_lib.c
../libopenjpeg/jp2.c
../libopenjpeg/jpt.c
../libopenjpeg/mct.c
../libopenjpeg/mqc.c
../libopenjpeg/openjpeg.c
../libopenjpeg/pi.c
../libopenjpeg/raw.c
../libopenjpeg/t1.c
../libopenjpeg/t2.c
../libopenjpeg/tcd.c
../libopenjpeg/tgt.c
)
SET(JPWL_SRCS crc.c jpwl.c jpwl_lib.c rs.c)
ADD_LIBRARY(openjpeg_JPWL ${JPWL_SRCS} ${OPJ_SRCS})
# Do the proper thing when building static...if only there was configured
# headers or def files instead
#IF(NOT BUILD_SHARED_LIBS)
# ADD_DEFINITIONS(-DOPJ_STATIC)
#ENDIF(NOT BUILD_SHARED_LIBS)
INCLUDE_DIRECTORIES(
${OPENJPEG_SOURCE_DIR}/libopenjpeg
)
FIND_PACKAGE(TIFF REQUIRED)
ADD_EXECUTABLE(JPWL_j2k_to_image
../codec/convert.c ../codec/j2k_to_image.c
)
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image openjpeg_JPWL ${TIFF_LIBRARIES})
IF(UNIX)
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image m)
ENDIF(UNIX)
ADD_EXECUTABLE(JPWL_image_to_j2k
../codec/convert.c ../codec/image_to_j2k.c)
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k openjpeg_JPWL ${TIFF_LIBRARIES})
IF(UNIX)
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k m)
ENDIF(UNIX)

View File

@@ -42,7 +42,8 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /D "USE_JPWL" /FR /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /FR /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x80c /d "NDEBUG"
# ADD RSC /l 0x80c /d "NDEBUG"
BSC32=bscmake.exe
@@ -50,7 +51,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib LibOpenJPEG_JPWL.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"libcmt.lib" /libpath:"Release"
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib LibOpenJPEG_JPWL.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /machine:I386 /libpath:"Release"
!ELSEIF "$(CFG)" == "JPWL_image_to_j2k - Win32 Debug"
@@ -66,7 +67,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /D "USE_JPWL" /FR /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /FR /FD /GZ /c
# ADD BASE RSC /l 0x80c /d "_DEBUG"
# ADD RSC /l 0x80c /d "_DEBUG"
BSC32=bscmake.exe
@@ -97,6 +98,10 @@ SOURCE=..\codec\compat\getopt.c
SOURCE=..\codec\image_to_j2k.c
# End Source File
# Begin Source File
SOURCE=..\codec\index.c
# End Source File
# End Group
# Begin Group "Header Files"
@@ -111,6 +116,10 @@ SOURCE=..\codec\compat\getopt.h
# End Source File
# Begin Source File
SOURCE=..\codec\index.h
# End Source File
# Begin Source File
SOURCE=..\libopenjpeg\openjpeg.h
# End Source File
# End Group

View File

@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /D "USE_JPWL" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /YX /FD /c
# ADD BASE RSC /l 0x80c /d "NDEBUG"
# ADD RSC /l 0x80c /d "NDEBUG"
BSC32=bscmake.exe
@@ -50,7 +50,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"libcmt.lib"
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libs/libtiff/libtiff.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "JPWL_j2k_to_image - Win32 Debug"
@@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /D "USE_JPWL" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /YX /FD /GZ /c
# ADD BASE RSC /l 0x80c /d "_DEBUG"
# ADD RSC /l 0x80c /d "_DEBUG"
BSC32=bscmake.exe
@@ -91,28 +91,16 @@ SOURCE=..\codec\convert.c
# End Source File
# Begin Source File
SOURCE=.\crc.c
# End Source File
# Begin Source File
SOURCE=..\codec\compat\getopt.c
# End Source File
# Begin Source File
SOURCE=..\codec\index.c
# End Source File
# Begin Source File
SOURCE=..\codec\j2k_to_image.c
# End Source File
# Begin Source File
SOURCE=.\jpwl.c
# End Source File
# Begin Source File
SOURCE=.\jpwl_lib.c
# End Source File
# Begin Source File
SOURCE=.\rs.c
# End Source File
# End Group
# Begin Group "Header Files"
@@ -131,6 +119,10 @@ SOURCE=..\codec\compat\getopt.h
# End Source File
# Begin Source File
SOURCE=..\codec\index.h
# End Source File
# Begin Source File
SOURCE=.\jpwl.h
# End Source File
# Begin Source File

View File

@@ -41,7 +41,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /YX /FD /c
# ADD BASE RSC /l 0x80c /d "NDEBUG"
# ADD RSC /l 0x80c /d "NDEBUG"
BSC32=bscmake.exe
@@ -64,7 +64,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "OPJ_STATIC" /D "USE_JPWL" /D "USE_JPSEC" /YX /FD /GZ /c
# ADD BASE RSC /l 0x80c /d "_DEBUG"
# ADD RSC /l 0x80c /d "_DEBUG"
BSC32=bscmake.exe
@@ -245,6 +245,10 @@ SOURCE=..\libopenjpeg\opj_includes.h
# End Source File
# Begin Source File
SOURCE=..\libopenjpeg\opj_malloc.h
# End Source File
# Begin Source File
SOURCE=..\libopenjpeg\pi.h
# End Source File
# Begin Source File

View File

@@ -1,20 +1,54 @@
# Makefile for the main JPWL OpenJPEG codecs: JPWL_ j2k_to_image and JPWL_image_to_j2k
# Linux makefile for OpenJPEG + JPWL
VER_MAJOR = 2
VER_MINOR = 1.2.0
JPWL_SRCS = ./crc.c ./jpwl.c ./jpwl_lib.c ./rs.c
SRCS = ../libopenjpeg/bio.c ../libopenjpeg/cio.c ../libopenjpeg/dwt.c ../libopenjpeg/event.c ../libopenjpeg/image.c ../libopenjpeg/j2k.c ../libopenjpeg/j2k_lib.c ../libopenjpeg/jp2.c ../libopenjpeg/jpt.c ../libopenjpeg/mct.c ../libopenjpeg/mqc.c ../libopenjpeg/openjpeg.c ../libopenjpeg/pi.c ../libopenjpeg/raw.c ../libopenjpeg/t1.c ../libopenjpeg/t2.c ../libopenjpeg/tcd.c ../libopenjpeg/tgt.c $(JPWL_SRCS)
INCLS = ../libopenjpeg/bio.h ../libopenjpeg/cio.h ../libopenjpeg/dwt.h ../libopenjpeg/event.h ../libopenjpeg/fix.h ../libopenjpeg/image.h ../libopenjpeg/int.h ../libopenjpeg/j2k.h ../libopenjpeg/j2k_lib.h ../libopenjpeg/jp2.h ../libopenjpeg/jpt.h ../libopenjpeg/mct.h ../libopenjpeg/mqc.h ../libopenjpeg/openjpeg.h ../libopenjpeg/pi.h ../libopenjpeg/raw.h ../libopenjpeg/t1.h ../libopenjpeg/t2.h ../libopenjpeg/tcd.h ../libopenjpeg/tgt.h ../libopenjpeg/opj_malloc.h ../libopenjpeg/opj_includes.h
INCLUDE = -Ilibopenjpeg_JPWL
# General configuration variables:
CC = gcc
AR = ar
CFLAGS = -O3 -DUSE_JPWL # -g -p -pg -DUSE_JPWL
PREFIX = /usr
INSTALL_LIBDIR = $(PREFIX)/lib
INSTALL_INCLUDE = $(PREFIX)/include
OPJ_SRCS = ../libopenjpeg/bio.c ../libopenjpeg/cio.c ../libopenjpeg/dwt.c ../libopenjpeg/event.c ../libopenjpeg/image.c ../libopenjpeg/j2k.c ../libopenjpeg/j2k_lib.c ../libopenjpeg/jp2.c ../libopenjpeg/jpt.c ../libopenjpeg/mct.c ../libopenjpeg/mqc.c ../libopenjpeg/openjpeg.c ../libopenjpeg/pi.c ../libopenjpeg/raw.c ../libopenjpeg/t1.c ../libopenjpeg/t2.c ../libopenjpeg/tcd.c ../libopenjpeg/tgt.c
JPWL_SRCS = crc.c jpwl.c jpwl_lib.c rs.c
# Converts cr/lf to just lf
DOS2UNIX = dos2unix
COMPILERFLAGS = -O3 -fPIC
LIBRARIES = -lstdc++
MODULES = $(SRCS:.c=.o)
CFLAGS = $(COMPILERFLAGS) $(INCLUDE) -DUSE_JPWL
TARGET = openjpeg_JPWL
STATICLIB = lib$(TARGET).a
SHAREDLIB = lib$(TARGET)-$(VER_MAJOR).$(VER_MINOR).so
LIBNAME = lib$(TARGET).so.$(VER_MAJOR)
MODULES = $(OPJ_SRCS:.c=.o) $(JPWL_SRCS:.c=.o)
all: JPWL_image_to_j2k JPWL_j2k_to_image
default: all
all: OpenJPEG_JPWL JPWL_image_to_j2k JPWL_j2k_to_image
dist: OpenJPEG_JPWL
install -d dist
install -m 644 $(STATICLIB) dist
install -m 755 $(SHAREDLIB) dist
ln -sf $(SHAREDLIB) dist/$(LIBNAME)
install libopenjpeg/openjpeg.h dist
dos2unix:
@$(DOS2UNIX) $(SRCS) $(INCLS)
OpenJPEG_JPWL: $(STATICLIB) $(SHAREDLIB)
JPWL_codec: JPWL_j2k_to_image JPWL_image_to_j2k $(STATICLIB)
.c.o:
$(CC) $(CFLAGS) -c $< -o $@
@@ -22,12 +56,28 @@ all: JPWL_image_to_j2k JPWL_j2k_to_image
$(STATICLIB): $(MODULES)
$(AR) r $@ $(MODULES)
JPWL_j2k_to_image: ../codec/j2k_to_image.c $(STATICLIB)
gcc $(CFLAGS) ../codec/convert.c ../codec/j2k_to_image.c -o JPWL_j2k_to_image -I ../libopenjpeg/ -L . -lopenjpeg_JPWL -lm -lstdc++
$(SHAREDLIB): $(MODULES)
$(CC) -s -shared -Wl,-soname,$(LIBNAME) -o $@ $(MODULES) $(LIBRARIES)
JPWL_image_to_j2k: ../codec/image_to_j2k.c $(STATICLIB)
gcc $(CFLAGS) ../codec/convert.c ../codec/image_to_j2k.c -o JPWL_image_to_j2k -I ../libopenjpeg/ -L . -lopenjpeg_JPWL -lm -lstdc++
JPWL_j2k_to_image: ../codec/j2k_to_image.c
gcc $(CFLAGS) ../codec/convert.c ../codec/j2k_to_image.c -o JPWL_j2k_to_image -I ../libopenjpeg/ -L . -lopenjpeg_JPWL -lm -ltiff
clean:
rm -f JPWL_j2k_to_image JPWL_image_to_j2k *.o *.a
cd ../libopenjpeg; rm -f *.o
JPWL_image_to_j2k: ../codec/image_to_j2k.c
gcc $(CFLAGS) ../codec/convert.c ../codec/image_to_j2k.c -o JPWL_image_to_j2k -I ../libopenjpeg/ -L . -lopenjpeg_JPWL -lm -ltiff
install: OpenJPEG
install -d '$(DESTDIR)$(INSTALL_LIBDIR)' '$(DESTDIR)$(INSTALL_INCLUDE)'
install -m 644 -o root -g root $(STATICLIB) '$(DESTDIR)$(INSTALL_LIBDIR)'
ranlib '$(DESTDIR)$(INSTALL_LIBDIR)/$(STATICLIB)'
install -m 755 -o root -g root $(SHAREDLIB) '$(DESTDIR)$(INSTALL_LIBDIR)'
ln -sf $(SHAREDLIB) '$(DESTDIR)$(INSTALL_LIBDIR)/$(LIBNAME)'
install -m 644 -o root -g root libopenjpeg/openjpeg.h '$(DESTDIR)$(INSTALL_INCLUDE)'
-ldconfig
cleanlib:
rm -rf core dist/ u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB) $(LIBNAME)
cleancodec:
rm -f JPWL_j2k_to_image JPWL_image_to_j2k JPWL_j2k_to_image.o JPWL_image_to_j2k.o
clean: cleanlib cleancodec

View File

@@ -29,20 +29,20 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef USE_JPWL
#include "../libopenjpeg/opj_includes.h"
#ifdef USE_JPWL
/** @defgroup JPWL JPWL - JPEG-2000 Part11 (JPWL) codestream manager */
/*@{*/
/** @name Local static variables */
/*@{*/
/** position of markers to insert */
static jpwl_marker_t jwmarker[JPWL_MAX_NO_MARKERS];
/** number of prepared markers */
/** number of JPWL prepared markers */
static int jwmarker_num;
/** properties of JPWL markers to insert */
static jpwl_marker_t jwmarker[JPWL_MAX_NO_MARKERS];
/*@}*/
@@ -88,42 +88,114 @@ their relevant wishlist position
int jpwl_markcomp(const void *arg1, const void *arg2);
/** write an EPB MS to a buffer
@param j2k J2K compressor handle
@param epbmark pointer to the EPB MS
@param buf pointer to the memory buffer
*/
void jpwl_epb_write(jpwl_epb_ms_t *epbmark, unsigned char *buf);
void jpwl_epb_write(opj_j2k_t *j2k, jpwl_epb_ms_t *epbmark, unsigned char *buf);
/** write an EPC MS to a buffer
@param j2k J2K compressor handle
@param epcmark pointer to the EPC MS
@param buf pointer to the memory buffer
*/
void jpwl_epc_write(jpwl_epc_ms_t *epcmark, unsigned char *buf);
void jpwl_epc_write(opj_j2k_t *j2k, jpwl_epc_ms_t *epcmark, unsigned char *buf);
/** write an ESD MS to a buffer
@param j2k J2K compressor handle
@param esdmark pointer to the ESD MS
@param buf pointer to the memory buffer
*/
void jpwl_esd_write(jpwl_esd_ms_t *esdmark, unsigned char *buf);
void jpwl_esd_write(opj_j2k_t *j2k, jpwl_esd_ms_t *esdmark, unsigned char *buf);
/*-----------------------------------------------------------------*/
void jpwl_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
int mm;
/* let's reset some settings */
/* clear the existing markers */
for (mm = 0; mm < jwmarker_num; mm++) {
switch (jwmarker[mm].id) {
case J2K_MS_EPB:
free(jwmarker[mm].epbmark);
break;
case J2K_MS_EPC:
free(jwmarker[mm].epcmark);
break;
case J2K_MS_ESD:
free(jwmarker[mm].esdmark);
break;
case J2K_MS_RED:
free(jwmarker[mm].redmark);
break;
default:
break;
}
}
/* clear the marker structure array */
memset(jwmarker, 0, sizeof(jpwl_marker_t) * JPWL_MAX_NO_MARKERS);
/* no more markers in the list */
jwmarker_num = 0;
/* let's begin creating a marker list, according to user wishes */
jpwl_prepare_marks(j2k, cio, image);
/* now we dump the JPWL markers on the codestream */
jpwl_dump_marks(j2k, cio, image);
/* do not know exactly what is this for,
but it gets called during index creation */
j2k->pos_correction = 0;
}
void j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len) {
if (!cstr_info)
return;
/* expand the list? */
if ((cstr_info->marknum + 1) > cstr_info->maxmarknum) {
cstr_info->maxmarknum = 100 + (int) ((float) cstr_info->maxmarknum * 1.0F);
cstr_info->marker = opj_realloc(cstr_info->marker, cstr_info->maxmarknum);
}
/* add the marker */
cstr_info->marker[cstr_info->marknum].type = type;
cstr_info->marker[cstr_info->marknum].pos = pos;
cstr_info->marker[cstr_info->marknum].len = len;
cstr_info->marknum++;
}
void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
unsigned short int socsiz_len = 0;
int ciopos = cio_tell(cio);
int ciopos = cio_tell(cio), soc_pos = j2k->cstr_info->main_head_start;
unsigned char *socp = NULL;
int tileno, tilespec, hprot, sens, pprot, packspec, lastileno, packno;
int tileno, acc_tpno, tpno, tilespec, hprot, sens, pprot, packspec, lastileno, packno;
jpwl_epb_ms_t *epb_mark;
jpwl_epc_ms_t *epc_mark;
jpwl_esd_ms_t *esd_mark;
/* find SOC + SIZ length */
/* find (SOC + SIZ) length */
/* I assume SIZ is always the first marker after SOC */
cio_seek(cio, 4);
cio_seek(cio, soc_pos + 4);
socsiz_len = (unsigned short int) cio_read(cio, 2) + 4; /* add the 2 marks length itself */
cio_seek(cio, 0);
cio_seek(cio, soc_pos + 0);
socp = cio_getbp(cio); /* pointer to SOC */
/*
@@ -142,7 +214,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
if (epc_mark) {
jwmarker[jwmarker_num].id = J2K_MS_EPC; /* its type */
jwmarker[jwmarker_num].epcmark = epc_mark; /* the EPC */
jwmarker[jwmarker_num].pos = socsiz_len; /* after SIZ */
jwmarker[jwmarker_num].pos = soc_pos + socsiz_len; /* after SIZ */
jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos + 0.1; /* not so first */
jwmarker[jwmarker_num].len = epc_mark->Lepc; /* its length */
jwmarker[jwmarker_num].len_ready = true; /* ready */
@@ -179,7 +251,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
(unsigned char) j2k->cp->sens_MH, /* sensitivity method */
j2k->cp->sens_size, /* sensitivity size */
-1, /* this ESD is in main header */
0 /*j2k->image_info->num*/, /* number of packets in codestream */
0 /*j2k->cstr_info->num*/, /* number of packets in codestream */
NULL /*sensval*/ /* pointer to sensitivity data of packets */
)) {
@@ -187,7 +259,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
jwmarker[jwmarker_num].id = J2K_MS_ESD; /* its type */
jwmarker[jwmarker_num].esdmark = esd_mark; /* the EPB */
jwmarker[jwmarker_num].pos = socsiz_len; /* we choose to place it after SIZ */
jwmarker[jwmarker_num].pos = soc_pos + socsiz_len; /* we choose to place it after SIZ */
jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos + 0.2; /* not first at all! */
jwmarker[jwmarker_num].len = esd_mark->Lesd; /* its length */
jwmarker[jwmarker_num].len_ready = true; /* not ready, yet */
@@ -212,24 +284,35 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
/*
ESD MSs for Tile Part Headers
*/
/* cycle through TPHs */
/* cycle through tiles */
sens = -1; /* default spec: no ESD */
tilespec = 0; /* first tile spec */
for (tileno = 0; tileno < j2k->image_info->tw * j2k->image_info->th; tileno++) {
acc_tpno = 0;
for (tileno = 0; tileno < j2k->cstr_info->tw * j2k->cstr_info->th; tileno++) {
opj_event_msg(j2k->cinfo, EVT_INFO,
"Tile %d has %d tile part(s)\n",
tileno, j2k->cstr_info->tile[tileno].num_tps
);
/* for every tile part in the tile */
for (tpno = 0; tpno < j2k->cstr_info->tile[tileno].num_tps; tpno++, acc_tpno++) {
int sot_len, Psot, Psotp, mm;
unsigned long sot_pos, post_sod_pos;
unsigned long int left_THmarks_len;
sot_pos = j2k->image_info->tile[tileno].start_pos;
/******* sot_pos = j2k->cstr_info->tile[tileno].start_pos; */
sot_pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos;
cio_seek(cio, sot_pos + 2);
sot_len = cio_read(cio, 2); /* SOT Len */
cio_skip(cio, 2);
Psotp = cio_tell(cio);
Psot = cio_read(cio, 4); /* tile length */
post_sod_pos = j2k->image_info->tile[tileno].end_header + 1;
/******* post_sod_pos = j2k->cstr_info->tile[tileno].end_header + 1; */
post_sod_pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_end_header + 1;
left_THmarks_len = post_sod_pos - sot_pos;
/* add all the lengths of the markers which are len-ready and stay within SOT and SOD */
@@ -245,7 +328,8 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
}
}
if ((tilespec < JPWL_MAX_NO_TILESPECS) && (j2k->cp->sens_TPH_tileno[tilespec] == tileno))
/******* if ((tilespec < JPWL_MAX_NO_TILESPECS) && (j2k->cp->sens_TPH_tileno[tilespec] == tileno)) */
if ((tilespec < JPWL_MAX_NO_TILESPECS) && (j2k->cp->sens_TPH_tileno[tilespec] == acc_tpno))
/* we got a specification from this tile onwards */
sens = j2k->cp->sens_TPH[tilespec++];
@@ -269,7 +353,8 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
jwmarker[jwmarker_num].id = J2K_MS_ESD; /* its type */
jwmarker[jwmarker_num].esdmark = esd_mark; /* the EPB */
jwmarker[jwmarker_num].pos = j2k->image_info->tile[tileno].start_pos + sot_len + 2; /* after SOT */
/****** jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].start_pos + sot_len + 2; */ /* after SOT */
jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos + sot_len + 2; /* after SOT */
jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos + 0.2; /* not first at all! */
jwmarker[jwmarker_num].len = esd_mark->Lesd; /* its length */
jwmarker[jwmarker_num].len_ready = true; /* ready, yet */
@@ -284,18 +369,23 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
cio_write(cio, Psot + esd_mark->Lesd + 2, 4);
opj_event_msg(j2k->cinfo, EVT_INFO,
"TPH ESDs: tile %02d, method %d\n",
tileno,
/******* "TPH ESDs: tile %02d, method %d\n", */
"TPH ESDs: tile %02d, part %02d, method %d\n",
/******* tileno, */
tileno, tpno,
sens
);
} else {
/* ooops, problems */
opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH ESD #%d\n", tileno);
/***** opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH ESD #%d\n", tileno); */
opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH ESD #%d,%d\n", tileno, tpno);
};
}
}
};
/*
@@ -307,7 +397,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
int mm;
/* position of SOT */
unsigned int sot_pos = j2k->image_info->main_head_end + 1;
unsigned int sot_pos = j2k->cstr_info->main_head_end + 1;
/* how much space is there between end of SIZ and beginning of SOT? */
int left_MHmarks_len = sot_pos - socsiz_len;
@@ -341,7 +431,7 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
jwmarker[jwmarker_num].id = J2K_MS_EPB; /* its type */
jwmarker[jwmarker_num].epbmark = epb_mark; /* the EPB */
jwmarker[jwmarker_num].pos = socsiz_len; /* after SIZ */
jwmarker[jwmarker_num].pos = soc_pos + socsiz_len; /* after SIZ */
jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos; /* first first first! */
jwmarker[jwmarker_num].len = epb_mark->Lepb; /* its length */
jwmarker[jwmarker_num].len_ready = true; /* ready */
@@ -371,15 +461,26 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
lastileno = 0;
packspec = 0;
pprot = -1;
for (tileno = 0; tileno < j2k->image_info->tw * j2k->image_info->th; tileno++) {
acc_tpno = 0;
for (tileno = 0; tileno < j2k->cstr_info->tw * j2k->cstr_info->th; tileno++) {
opj_event_msg(j2k->cinfo, EVT_INFO,
"Tile %d has %d tile part(s)\n",
tileno, j2k->cstr_info->tile[tileno].num_tps
);
/* for every tile part in the tile */
for (tpno = 0; tpno < j2k->cstr_info->tile[tileno].num_tps; tpno++, acc_tpno++) {
int sot_len, Psot, Psotp, mm, epb_index = 0, prot_len = 0;
unsigned long sot_pos, post_sod_pos;
unsigned long int left_THmarks_len, epbs_len = 0;
int startpack = 0, stoppack = j2k->image_info->num;
int startpack = 0, stoppack = j2k->cstr_info->packno;
int first_tp_pack, last_tp_pack;
jpwl_epb_ms_t *tph_epb = NULL;
sot_pos = j2k->image_info->tile[tileno].start_pos;
/****** sot_pos = j2k->cstr_info->tile[tileno].start_pos; */
sot_pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos;
cio_seek(cio, sot_pos + 2);
sot_len = cio_read(cio, 2); /* SOT Len */
cio_skip(cio, 2);
@@ -387,7 +488,8 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
Psot = cio_read(cio, 4); /* tile length */
/* a-priori length of the data dwelling between SOT and SOD */
post_sod_pos = j2k->image_info->tile[tileno].end_header + 1;
/****** post_sod_pos = j2k->cstr_info->tile[tileno].end_header + 1; */
post_sod_pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_end_header + 1;
left_THmarks_len = post_sod_pos - (sot_pos + sot_len + 2);
/* add all the lengths of the JPWL markers which are len-ready and stay within SOT and SOD */
@@ -403,8 +505,9 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
}
}
if ((tilespec < JPWL_MAX_NO_TILESPECS) && (j2k->cp->hprot_TPH_tileno[tilespec] == tileno))
/* we got a specification from this tile onwards */
/****** if ((tilespec < JPWL_MAX_NO_TILESPECS) && (j2k->cp->hprot_TPH_tileno[tilespec] == tileno)) */
if ((tilespec < JPWL_MAX_NO_TILESPECS) && (j2k->cp->hprot_TPH_tileno[tilespec] == acc_tpno))
/* we got a specification from this tile part onwards */
hprot = j2k->cp->hprot_TPH[tilespec++];
/* must this TPH have an EPB MS? */
@@ -426,7 +529,8 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
if (jwmarker_num < JPWL_MAX_NO_MARKERS) {
jwmarker[jwmarker_num].id = J2K_MS_EPB; /* its type */
jwmarker[jwmarker_num].epbmark = epb_mark; /* the EPB */
jwmarker[jwmarker_num].pos = j2k->image_info->tile[tileno].start_pos + sot_len + 2; /* after SOT */
/****** jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].start_pos + sot_len + 2; */ /* after SOT */
jwmarker[jwmarker_num].pos = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos + sot_len + 2; /* after SOT */
jwmarker[jwmarker_num].dpos = (double) jwmarker[jwmarker_num].pos; /* first first first! */
jwmarker[jwmarker_num].len = epb_mark->Lepb; /* its length */
jwmarker[jwmarker_num].len_ready = true; /* ready */
@@ -440,8 +544,10 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
Psot += epb_mark->Lepb + 2;
opj_event_msg(j2k->cinfo, EVT_INFO,
"TPH EPB : tile %02d, prot. %d\n",
tileno,
/***** "TPH EPB : tile %02d, prot. %d\n", */
"TPH EPB : tile %02d, part %02d, prot. %d\n",
/***** tileno, */
tileno, tpno,
hprot
);
@@ -450,40 +556,56 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
} else {
/* ooops, problems */
opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH EPB #%d\n", tileno);
/****** opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH EPB #%d\n", tileno); */
opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not create TPH EPB in #%d,d\n", tileno, tpno);
};
}
startpack = 0;
/* EPB MSs for UEP packet data protection in Tile Parts */
for (packno = 0; packno < j2k->image_info->num; packno++) {
/****** for (packno = 0; packno < j2k->cstr_info->num; packno++) { */
/*first_tp_pack = (tpno > 0) ? (first_tp_pack + j2k->cstr_info->tile[tileno].tp[tpno - 1].tp_numpacks) : 0;*/
first_tp_pack = j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pack;
last_tp_pack = first_tp_pack + j2k->cstr_info->tile[tileno].tp[tpno].tp_numpacks - 1;
for (packno = 0; packno < j2k->cstr_info->tile[tileno].tp[tpno].tp_numpacks; packno++) {
/******** if ((packspec < JPWL_MAX_NO_PACKSPECS) &&
(j2k->cp->pprot_tileno[packspec] == tileno) && (j2k->cp->pprot_packno[packspec] == packno)) { */
if ((packspec < JPWL_MAX_NO_PACKSPECS) &&
(j2k->cp->pprot_tileno[packspec] == tileno) && (j2k->cp->pprot_packno[packspec] == packno)) {
(j2k->cp->pprot_tileno[packspec] == acc_tpno) && (j2k->cp->pprot_packno[packspec] == packno)) {
/* we got a specification from this tile and packet onwards */
/* print the previous spec */
if (packno > 0) {
stoppack = packno - 1;
opj_event_msg(j2k->cinfo, EVT_INFO,
"UEP EPBs: tile %02d, packs. %02d-%02d (B %d-%d), prot. %d\n",
tileno,
/***** "UEP EPBs: tile %02d, packs. %02d-%02d (B %d-%d), prot. %d\n", */
"UEP EPBs: tile %02d, part %02d, packs. %02d-%02d (B %d-%d), prot. %d\n",
/***** tileno, */
tileno, tpno,
startpack,
stoppack,
j2k->image_info->tile[tileno].packet[startpack].start_pos,
j2k->image_info->tile[tileno].packet[stoppack].end_pos,
/***** j2k->cstr_info->tile[tileno].packet[startpack].start_pos, */
j2k->cstr_info->tile[tileno].packet[first_tp_pack + startpack].start_pos,
/***** j2k->cstr_info->tile[tileno].packet[stoppack].end_pos, */
j2k->cstr_info->tile[tileno].packet[first_tp_pack + stoppack].end_pos,
pprot);
prot_len = j2k->image_info->tile[tileno].packet[stoppack].end_pos + 1 -
j2k->image_info->tile[tileno].packet[startpack].start_pos;
/***** prot_len = j2k->cstr_info->tile[tileno].packet[stoppack].end_pos + 1 -
j2k->cstr_info->tile[tileno].packet[startpack].start_pos; */
prot_len = j2k->cstr_info->tile[tileno].packet[first_tp_pack + stoppack].end_pos + 1 -
j2k->cstr_info->tile[tileno].packet[first_tp_pack + startpack].start_pos;
/*
particular case: if this is the last header and the last packet,
then it is better to protect even the EOC marker
*/
if ((tileno == ((j2k->image_info->tw * j2k->image_info->th) - 1)) &&
(stoppack == (j2k->image_info->num - 1)))
/****** if ((tileno == ((j2k->cstr_info->tw * j2k->cstr_info->th) - 1)) &&
(stoppack == (j2k->cstr_info->num - 1))) */
if ((tileno == ((j2k->cstr_info->tw * j2k->cstr_info->th) - 1)) &&
(tpno == (j2k->cstr_info->tile[tileno].num_tps - 1)) &&
(stoppack == last_tp_pack))
/* add the EOC len */
prot_len += 2;
@@ -497,7 +619,8 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
false, /* inside MH */
&epb_index, /* pointer to EPB index */
pprot, /* protection type */
(double) (j2k->image_info->tile[tileno].start_pos + sot_len + 2) + 0.0001, /* position */
/****** (double) (j2k->cstr_info->tile[tileno].start_pos + sot_len + 2) + 0.0001, */ /* position */
(double) (j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos + sot_len + 2) + 0.0001, /* position */
tileno, /* number of tile */
0, /* length of pre-data */
prot_len /*4000*/ /* length of post-data */
@@ -517,23 +640,32 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
if (pprot >= 0) {
opj_event_msg(j2k->cinfo, EVT_INFO,
"UEP EPBs: tile %02d, packs. %02d-%02d (B %d-%d), prot. %d\n",
tileno,
/**** "UEP EPBs: tile %02d, packs. %02d-%02d (B %d-%d), prot. %d\n", */
"UEP EPBs: tile %02d, part %02d, packs. %02d-%02d (B %d-%d), prot. %d\n",
/**** tileno, */
tileno, tpno,
startpack,
stoppack,
j2k->image_info->tile[tileno].packet[startpack].start_pos,
j2k->image_info->tile[tileno].packet[stoppack].end_pos,
/***** j2k->image_info->tile[tileno].packet[startpack].start_pos,
j2k->image_info->tile[tileno].packet[stoppack].end_pos, */
j2k->cstr_info->tile[tileno].packet[first_tp_pack + startpack].start_pos,
j2k->cstr_info->tile[tileno].packet[first_tp_pack + stoppack].end_pos,
pprot);
prot_len = j2k->image_info->tile[tileno].packet[stoppack].end_pos + 1 -
j2k->image_info->tile[tileno].packet[startpack].start_pos;
/***** prot_len = j2k->cstr_info->tile[tileno].packet[stoppack].end_pos + 1 -
j2k->cstr_info->tile[tileno].packet[startpack].start_pos; */
prot_len = j2k->cstr_info->tile[tileno].packet[first_tp_pack + stoppack].end_pos + 1 -
j2k->cstr_info->tile[tileno].packet[first_tp_pack + startpack].start_pos;
/*
particular case: if this is the last header and the last packet,
then it is better to protect even the EOC marker
*/
if ((tileno == ((j2k->image_info->tw * j2k->image_info->th) - 1)) &&
(stoppack == (j2k->image_info->num - 1)))
/***** if ((tileno == ((j2k->cstr_info->tw * j2k->cstr_info->th) - 1)) &&
(stoppack == (j2k->cstr_info->num - 1))) */
if ((tileno == ((j2k->cstr_info->tw * j2k->cstr_info->th) - 1)) &&
(tpno == (j2k->cstr_info->tile[tileno].num_tps - 1)) &&
(stoppack == last_tp_pack))
/* add the EOC len */
prot_len += 2;
@@ -547,7 +679,8 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
false, /* inside MH */
&epb_index, /* pointer to EPB index */
pprot, /* protection type */
(double) (j2k->image_info->tile[tileno].start_pos + sot_len + 2) + 0.0001, /* position */
/***** (double) (j2k->cstr_info->tile[tileno].start_pos + sot_len + 2) + 0.0001,*/ /* position */
(double) (j2k->cstr_info->tile[tileno].tp[tpno].tp_start_pos + sot_len + 2) + 0.0001, /* position */
tileno, /* number of tile */
0, /* length of pre-data */
prot_len /*4000*/ /* length of post-data */
@@ -565,6 +698,8 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
cio_seek(cio, Psotp);
cio_write(cio, Psot, 4);
}
};
/* reset the position */
@@ -575,9 +710,9 @@ void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
int mm;
unsigned long int old_size = j2k->image_info->codestream_size;
unsigned long int old_size = j2k->cstr_info->codestream_size;
unsigned long int new_size = old_size;
int ciopos = cio_tell(cio);
int ciopos = cio_tell(cio), soc_pos = j2k->cstr_info->main_head_start;
unsigned char *jpwl_buf, *orig_buf;
unsigned long int orig_pos;
double epbcoding_time = 0.0, esdcoding_time = 0.0;
@@ -592,16 +727,20 @@ void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
new_size += jwmarker[mm].len + 2;
}
/* allocate a temporary buffer of proper size */
if (!(jpwl_buf = (unsigned char *) opj_malloc((size_t) new_size * sizeof (unsigned char)))) {
opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not allocate room for JPWL temp codestream buffer\n");
/* allocate a new buffer of proper size */
if (!(jpwl_buf = (unsigned char *) opj_malloc((size_t) (new_size + soc_pos) * sizeof(unsigned char)))) {
opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not allocate room for JPWL codestream buffer\n");
exit(1);
};
/* copy the jp2 part, if any */
orig_buf = jpwl_buf;
memcpy(jpwl_buf, cio->buffer, soc_pos);
jpwl_buf += soc_pos;
/* cycle through markers */
orig_pos = 0; /* start from the beginning */
cio_seek(cio, 0); /* rewind the original */
orig_pos = soc_pos + 0; /* start from the beginning */
cio_seek(cio, soc_pos + 0); /* rewind the original */
for (mm = 0; mm < jwmarker_num; mm++) {
/*
@@ -619,15 +758,15 @@ void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
switch (jwmarker[mm].id) {
case J2K_MS_EPB:
jpwl_epb_write(jwmarker[mm].epbmark, jpwl_buf);
jpwl_epb_write(j2k, jwmarker[mm].epbmark, jpwl_buf);
break;
case J2K_MS_EPC:
jpwl_epc_write(jwmarker[mm].epcmark, jpwl_buf);
jpwl_epc_write(j2k, jwmarker[mm].epcmark, jpwl_buf);
break;
case J2K_MS_ESD:
jpwl_esd_write(jwmarker[mm].esdmark, jpwl_buf);
jpwl_esd_write(j2k, jwmarker[mm].esdmark, jpwl_buf);
break;
case J2K_MS_RED:
@@ -638,6 +777,10 @@ void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
break;
};
/* we update the markers struct */
if (j2k->cstr_info)
j2k->cstr_info->marker[j2k->cstr_info->marknum - 1].pos = (jpwl_buf - orig_buf);
/* we set the marker dpos to the new position in the JPWL codestream */
jwmarker[mm].dpos = (double) (jpwl_buf - orig_buf);
@@ -647,15 +790,15 @@ void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
}
/* finish remaining original codestream */
memcpy(jpwl_buf, cio_getbp(cio), old_size - orig_pos);
jpwl_buf += old_size - orig_pos;
cio_seek(cio, old_size);
memcpy(jpwl_buf, cio_getbp(cio), old_size - (orig_pos - soc_pos));
jpwl_buf += old_size - (orig_pos - soc_pos);
cio_seek(cio, soc_pos + old_size);
/*
update info file based on added markers
*/
if (!jpwl_update_info(j2k, jwmarker, jwmarker_num))
opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not update OPJ image_info structure\n");
opj_event_msg(j2k->cinfo, EVT_ERROR, "Could not update OPJ cstr_info structure\n");
/* now we need to repass some markers and fill their data fields */
@@ -746,14 +889,14 @@ void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image) {
/* free original cio buffer and set it to the JPWL one */
opj_free(cio->buffer);
/*cio->cinfo;*/ /* no change */
/*cio->openmode;*/ /* no change */
cio->buffer = jpwl_buf - new_size;
cio->length = new_size;
cio->start = jpwl_buf - new_size;
cio->end = jpwl_buf - 1;
cio->bp = jpwl_buf - new_size;
cio_seek(cio, new_size);
cio->cinfo = cio->cinfo; /* no change */
cio->openmode = cio->openmode; /* no change */
cio->buffer = orig_buf;
cio->length = new_size + soc_pos;
cio->start = cio->buffer;
cio->end = cio->buffer + cio->length;
cio->bp = cio->buffer;
cio_seek(cio, soc_pos + new_size);
}
@@ -864,6 +1007,10 @@ void j2k_write_epc(opj_j2k_t *j2k) {
cio_write(cio, Pcrc, 2);
cio_seek(cio, Lepcp + Lepc);
/* marker struct update */
j2k_add_marker(j2k->cstr_info, J2K_MS_EPC, Lepcp - 2, Lepc + 2);
}
void j2k_read_epb(opj_j2k_t *j2k) {
@@ -1012,6 +1159,9 @@ void j2k_write_epb(opj_j2k_t *j2k) {
cio_write(cio, Lepb, 2); /* Lepb */
cio_seek(cio, Lepbp + Lepb);
/* marker struct update */
j2k_add_marker(j2k->cstr_info, J2K_MS_EPB, Lepbp - 2, Lepb + 2);
}
void j2k_read_esd(opj_j2k_t *j2k) {
@@ -1069,6 +1219,7 @@ void j2k_read_red(opj_j2k_t *j2k) {
bool jpwl_check_tile(opj_j2k_t *j2k, opj_tcd_t *tcd, int tileno) {
#ifdef oerhgierhgvhreit4u
/*
we navigate through the tile and find possible invalid parameters:
this saves a lot of crashes!!!!!
@@ -1130,9 +1281,77 @@ bool jpwl_check_tile(opj_j2k_t *j2k, opj_tcd_t *tcd, int tileno) {
}
}
#endif
return true;
}
/*@}*/
#endif /* USE_JPWL */
#ifdef USE_JPSEC
/** @defgroup JPSEC JPSEC - JPEG-2000 Part 8 (JPSEC) codestream manager */
/*@{*/
/** @name Local static functions */
/*@{*/
void j2k_read_sec(opj_j2k_t *j2k) {
unsigned short int Lsec;
opj_cio_t *cio = j2k->cio;
/* Simply read the SEC length */
Lsec = cio_read(cio, 2);
/* Now we write them to screen */
opj_event_msg(j2k->cinfo, EVT_INFO,
"SEC(%d)\n",
cio_tell(cio) - 2
);
cio_skip(cio, Lsec - 2);
}
void j2k_write_sec(opj_j2k_t *j2k) {
unsigned short int Lsec = 24;
int i;
opj_cio_t *cio = j2k->cio;
cio_write(cio, J2K_MS_SEC, 2); /* SEC */
cio_write(cio, Lsec, 2);
/* write dummy data */
for (i = 0; i < Lsec - 2; i++)
cio_write(cio, 0, 1);
}
void j2k_read_insec(opj_j2k_t *j2k) {
unsigned short int Linsec;
opj_cio_t *cio = j2k->cio;
/* Simply read the INSEC length */
Linsec = cio_read(cio, 2);
/* Now we write them to screen */
opj_event_msg(j2k->cinfo, EVT_INFO,
"INSEC(%d)\n",
cio_tell(cio) - 2
);
cio_skip(cio, Linsec - 2);
}
/*@}*/
/*@}*/
#endif /* USE_JPSEC */

View File

@@ -205,6 +205,14 @@ typedef struct jpwl_marker {
bool data_ready;
} jpwl_marker_t;
/**
Encode according to JPWL specs
@param j2k J2K handle
@param cio codestream handle
@param image image handle
*/
void jpwl_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image);
/**
Prepare the list of JPWL markers, after the Part 1 codestream
has been finalized (index struct is full)
@@ -227,6 +235,7 @@ Read the EPC marker (Error Protection Capability)
@param j2k J2K handle
*/
void j2k_read_epc(opj_j2k_t *j2k);
/**
Write the EPC marker (Error Protection Capability), BUT the DL field is always set to 0
(this simplifies the management of EPBs and it is openly stated in the standard
@@ -235,21 +244,25 @@ are not yet implemented
@param j2k J2K handle
*/
void j2k_write_epc(opj_j2k_t *j2k);
/**
Read the EPB marker (Error Protection Block)
@param j2k J2K handle
*/
void j2k_read_epb(opj_j2k_t *j2k);
/**
Write the EPB marker (Error Protection Block)
@param j2k J2K handle
*/
void j2k_write_epb(opj_j2k_t *j2k);
/**
Read the ESD marker (Error Sensitivity Descriptor)
@param j2k J2K handle
*/
void j2k_read_esd(opj_j2k_t *j2k);
/**
Read the RED marker (Residual Error Descriptor)
@param j2k J2K handle
@@ -321,6 +334,8 @@ bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esdmark, unsigned char *buf);
bool jpwl_epb_fill(opj_j2k_t *j2k, jpwl_epb_ms_t *epbmark, unsigned char *buf, unsigned char *post_buf);
void j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len);
/** corrects the data in the JPWL codestream
@param j2k J2K compressor handle
@return true if correction is performed correctly
@@ -379,5 +394,32 @@ Computes the minimum between two integers
#endif /* USE_JPWL */
#ifdef USE_JPSEC
/** @defgroup JPSEC JPSEC - JPEG-2000 Part 8 (JPSEC) codestream manager */
/*@{*/
/**
Read the SEC marker (SEcured Codestream)
@param j2k J2K handle
*/
void j2k_read_sec(opj_j2k_t *j2k);
/**
Write the SEC marker (SEcured Codestream)
@param j2k J2K handle
*/
void j2k_write_sec(opj_j2k_t *j2k);
/**
Read the INSEC marker (SEcured Codestream)
@param j2k J2K handle
*/
void j2k_read_insec(opj_j2k_t *j2k);
/*@}*/
#endif /* USE_JPSEC */
#endif /* __JPWL_H */

View File

@@ -32,6 +32,7 @@
#ifdef USE_JPWL
#include "../libopenjpeg/opj_includes.h"
#include <limits.h>
/** Minimum and maximum values for the double->pfp conversion */
#define MIN_V1 0.0
@@ -128,20 +129,25 @@ int jpwl_epbs_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num,
while (post_len > 0) {
/* maximum postlen in order to respect EPB size
(we use 65450 instead of 65535 for keeping room for EPB parms)*/
(we use JPWL_MAXIMUM_EPB_ROOM instead of 65535 for keeping room for EPB parms)*/
/* (message word size) * (number of containable parity words) */
max_postlen = k_post * (unsigned long int) floor(65450.0 / (double) (n_post - k_post));
max_postlen = k_post * (unsigned long int) floor((double) JPWL_MAXIMUM_EPB_ROOM / (double) (n_post - k_post));
/* maximum postlen in order to respect EPB size */
if (*idx == 0)
/* (we use (65500 - L2) instead of 65535 for keeping room for EPB parms + pre-data) */
/* (we use (JPWL_MAXIMUM_EPB_ROOM - L2) instead of 65535 for keeping room for EPB parms + pre-data) */
/* (message word size) * (number of containable parity words) */
max_postlen = k_post * (unsigned long int) floor((double) (65500 - L2) / (double) (n_post - k_post));
max_postlen = k_post * (unsigned long int) floor((double) (JPWL_MAXIMUM_EPB_ROOM - L2) / (double) (n_post - k_post));
else
/* (we use 65500 instead of 65535 for keeping room for EPB parms) */
/* (we use JPWL_MAXIMUM_EPB_ROOM instead of 65535 for keeping room for EPB parms) */
/* (message word size) * (number of containable parity words) */
max_postlen = k_post * (unsigned long int) floor(65500.0 / (double) (n_post - k_post));
max_postlen = k_post * (unsigned long int) floor((double) JPWL_MAXIMUM_EPB_ROOM / (double) (n_post - k_post));
/* null protection case */
/* the max post length can be as large as the LDPepb field can host */
if (hprot == 0)
max_postlen = INT_MAX;
/* length to use */
dL4 = min(max_postlen, post_len);
@@ -289,7 +295,7 @@ jpwl_epb_ms_t *jpwl_epb_create(opj_j2k_t *j2k, bool latest, bool packed, int til
return epb;
}
void jpwl_epb_write(jpwl_epb_ms_t *epb, unsigned char *buf) {
void jpwl_epb_write(opj_j2k_t *j2k, jpwl_epb_ms_t *epb, unsigned char *buf) {
/* Marker */
*(buf++) = (unsigned char) (J2K_MS_EPB >> 8);
@@ -317,6 +323,10 @@ void jpwl_epb_write(jpwl_epb_ms_t *epb, unsigned char *buf) {
/* Data */
/*memcpy(buf, epb->data, (size_t) epb->Lepb - 11);*/
memset(buf, 0, (size_t) epb->Lepb - 11);
/* update markers struct */
j2k_add_marker(j2k->cstr_info, J2K_MS_EPB, -1, epb->Lepb + 2);
};
@@ -793,7 +803,7 @@ bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_l
/* Initialize RS structures */
P = n_pre - k_pre;
NN_P = NN - P;
tt = (int) floor((float) P / 2.0F);
tt = (int) floor((float) P / 2.0F); /* correction capability of the code */
memset(codeword, 0, NN);
parityword = codeword + NN_P;
init_rs(NN_P);
@@ -834,7 +844,8 @@ bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_l
/*if (conn == NULL)
opj_event_msg(j2k->cinfo, EVT_INFO, "codeword is correctly decoded\n");*/
} else if (status < tt) {
} else if (status <= tt) {
/* it has corrected 0 <= errs <= tt */
/*if (conn == NULL)
opj_event_msg(j2k->cinfo, EVT_WARNING, "%d errors corrected in codeword\n", status);*/
errnum += status;
@@ -848,21 +859,21 @@ bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_l
/* advance parity buffer */
if ((status >= 0) && (status < tt))
if ((status >= 0) && (status <= tt))
/* copy back corrected parity only if all is OK */
memcpy(L2_buf, parityword, P);
L2_buf += P;
/* advance message buffer */
if (remaining < k_pre) {
if ((status >= 0) && (status < tt))
if ((status >= 0) && (status <= tt))
/* copy back corrected data only if all is OK */
memcpy(L1_buf, codeword, remaining);
L1_buf += remaining;
remaining = 0;
} else {
if ((status >= 0) && (status < tt))
if ((status >= 0) && (status <= tt))
/* copy back corrected data only if all is OK */
memcpy(L1_buf, codeword, k_pre);
L1_buf += k_pre;
@@ -1043,7 +1054,7 @@ bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_l
/* Initialize RS structures */
P = n_post - k_post;
NN_P = NN - P;
tt = (int) floor((float) P / 2.0F);
tt = (int) floor((float) P / 2.0F); /* again, correction capability */
memset(codeword, 0, NN);
parityword = codeword + NN_P;
init_rs(NN_P);
@@ -1080,7 +1091,7 @@ bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_l
/*if (conn == NULL)
opj_event_msg(j2k->cinfo, EVT_INFO, "codeword is correctly decoded\n");*/
} else if (status < tt) {
} else if (status <= tt) {
/*if (conn == NULL)
opj_event_msg(j2k->cinfo, EVT_WARNING, "%d errors corrected in codeword\n", status);*/
errnum += status;
@@ -1094,21 +1105,21 @@ bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_l
/* advance parity buffer */
if ((status >= 0) && (status < tt))
if ((status >= 0) && (status <= tt))
/* copy back corrected data only if all is OK */
memcpy(L3_buf, parityword, P);
L3_buf += P;
/* advance message buffer */
if (remaining < k_post) {
if ((status >= 0) && (status < tt))
if ((status >= 0) && (status <= tt))
/* copy back corrected data only if all is OK */
memcpy(L4_buf, codeword, remaining);
L4_buf += remaining;
remaining = 0;
} else {
if ((status >= 0) && (status < tt))
if ((status >= 0) && (status <= tt))
/* copy back corrected data only if all is OK */
memcpy(L4_buf, codeword, k_post);
L4_buf += k_post;
@@ -1138,7 +1149,7 @@ bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_l
return true;
}
void jpwl_epc_write(jpwl_epc_ms_t *epc, unsigned char *buf) {
void jpwl_epc_write(opj_j2k_t *j2k, jpwl_epc_ms_t *epc, unsigned char *buf) {
/* Marker */
*(buf++) = (unsigned char) (J2K_MS_EPC >> 8);
@@ -1164,6 +1175,10 @@ void jpwl_epc_write(jpwl_epc_ms_t *epc, unsigned char *buf) {
/* Data */
/*memcpy(buf, epc->data, (size_t) epc->Lepc - 9);*/
memset(buf, 0, (size_t) epc->Lepc - 9);
/* update markers struct */
j2k_add_marker(j2k->cstr_info, J2K_MS_EPC, -1, epc->Lepc + 2);
};
int jpwl_esds_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num,
@@ -1215,7 +1230,7 @@ jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comp, unsigned char addrm, un
if (ad_size == 0)
/* if there are more than 66% of (2^16 - 1) bytes, switch to 4 bytes
(we keep space for possible EPBs being inserted) */
ad_size = (j2k->image_info->codestream_size > (1 * 65535 / 3)) ? 4 : 2;
ad_size = (j2k->cstr_info->codestream_size > (1 * 65535 / 3)) ? 4 : 2;
esd->sensval_size = ad_size + ad_size + se_size;
break;
@@ -1224,7 +1239,7 @@ jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comp, unsigned char addrm, un
/* auto sense address size */
if (ad_size == 0)
/* if there are more than 2^16 - 1 packets, switch to 4 bytes */
ad_size = (j2k->image_info->num > 65535) ? 4 : 2;
ad_size = (j2k->cstr_info->packno > 65535) ? 4 : 2;
esd->sensval_size = ad_size + ad_size + se_size;
break;
@@ -1245,17 +1260,17 @@ jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comp, unsigned char addrm, un
/* just based on the portions of a codestream */
case (0):
/* MH + no. of THs + no. of packets */
svalnum = 1 + (j2k->image_info->tw * j2k->image_info->th) * (1 + j2k->image_info->num);
svalnum = 1 + (j2k->cstr_info->tw * j2k->cstr_info->th) * (1 + j2k->cstr_info->packno);
break;
/* all the ones that are based on the packets */
default:
if (tileno < 0)
/* MH: all the packets and all the tiles info is written */
svalnum = j2k->image_info->tw * j2k->image_info->th * j2k->image_info->num;
svalnum = j2k->cstr_info->tw * j2k->cstr_info->th * j2k->cstr_info->packno;
else
/* TPH: only that tile info is written */
svalnum = j2k->image_info->num;
svalnum = j2k->cstr_info->packno;
break;
}
@@ -1355,26 +1370,26 @@ bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
buf += 7;
/* let's fill the data fields */
for (vv = (esd->tileno < 0) ? 0 : (j2k->image_info->num * esd->tileno); vv < esd->svalnum; vv++) {
for (vv = (esd->tileno < 0) ? 0 : (j2k->cstr_info->packno * esd->tileno); vv < esd->svalnum; vv++) {
int thistile = vv / j2k->image_info->num, thispacket = vv % j2k->image_info->num;
int thistile = vv / j2k->cstr_info->packno, thispacket = vv % j2k->cstr_info->packno;
/* skip for the hack some lines below */
if (thistile == j2k->image_info->tw * j2k->image_info->th)
if (thistile == j2k->cstr_info->tw * j2k->cstr_info->th)
break;
/* starting tile distortion */
if (thispacket == 0) {
TSE = j2k->image_info->tile[thistile].distotile;
oldMSE = TSE / j2k->image_info->tile[thistile].nbpix;
TSE = j2k->cstr_info->tile[thistile].distotile;
oldMSE = TSE / j2k->cstr_info->tile[thistile].numpix;
oldPSNR = 10.0 * log10(Omax2 / oldMSE);
}
/* TSE */
TSE -= j2k->image_info->tile[thistile].packet[thispacket].disto;
TSE -= j2k->cstr_info->tile[thistile].packet[thispacket].disto;
/* MSE */
MSE = TSE / j2k->image_info->tile[thistile].nbpix;
MSE = TSE / j2k->cstr_info->tile[thistile].numpix;
/* PSNR */
PSNR = 10.0 * log10(Omax2 / MSE);
@@ -1390,9 +1405,9 @@ bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
/* byte range */
case (1):
/* start address of packet */
addr1 = (j2k->image_info->tile[thistile].packet[thispacket].start_pos) & addrmask;
addr1 = (j2k->cstr_info->tile[thistile].packet[thispacket].start_pos) & addrmask;
/* end address of packet */
addr2 = (j2k->image_info->tile[thistile].packet[thispacket].end_pos) & addrmask;
addr2 = (j2k->cstr_info->tile[thistile].packet[thispacket].end_pos) & addrmask;
break;
/* packet range */
@@ -1416,7 +1431,7 @@ bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
if ((thistile == 0) && !doneMH) {
/* we have to manage MH addresses */
addr1 = 0; /* start of MH */
addr2 = j2k->image_info->main_head_end; /* end of MH */
addr2 = j2k->cstr_info->main_head_end; /* end of MH */
/* set special dvalue for this MH */
dvalue = -10.0;
doneMH = true; /* don't come here anymore */
@@ -1424,8 +1439,8 @@ bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
} else if (!doneTPH) {
/* we have to manage TPH addresses */
addr1 = j2k->image_info->tile[thistile].start_pos;
addr2 = j2k->image_info->tile[thistile].end_header;
addr1 = j2k->cstr_info->tile[thistile].start_pos;
addr2 = j2k->cstr_info->tile[thistile].end_header;
/* set special dvalue for this TPH */
dvalue = -1.0;
doneTPH = true; /* don't come here till the next tile */
@@ -1483,7 +1498,7 @@ bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
else
/* packet: first is most important, and then in decreasing order
down to the last, which counts for 1 */
dvalue = jpwl_pfp_to_double((unsigned short) (j2k->image_info->num - thispacket), esd->se_size);
dvalue = jpwl_pfp_to_double((unsigned short) (j2k->cstr_info->packno - thispacket), esd->se_size);
break;
/* MSE */
@@ -1554,7 +1569,7 @@ bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
return true;
}
void jpwl_esd_write(jpwl_esd_ms_t *esd, unsigned char *buf) {
void jpwl_esd_write(opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf) {
/* Marker */
*(buf++) = (unsigned char) (J2K_MS_ESD >> 8);
@@ -1579,6 +1594,10 @@ void jpwl_esd_write(jpwl_esd_ms_t *esd, unsigned char *buf) {
else
memset(buf, 0xAA, (size_t) esd->Lesd - 5);
/*memcpy(buf, esd->data, (size_t) esd->Lesd - 5);*/
/* update markers struct */
j2k_add_marker(j2k->cstr_info, J2K_MS_ESD, -1, esd->Lesd + 2);
}
unsigned short int jpwl_double_to_pfp(double V, int bytes) {
@@ -1656,8 +1675,8 @@ bool jpwl_update_info(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int jwmarker_num)
int mm;
unsigned long int addlen;
opj_image_info_t *info = j2k->image_info;
int tileno, packno, numtiles = info->th * info->tw, numpacks = info->num;
opj_codestream_info_t *info = j2k->cstr_info;
int tileno, tpno, packno, numtiles = info->th * info->tw, numpacks = info->packno;
if (!j2k || !jwmarker ) {
opj_event_msg(j2k->cinfo, EVT_ERROR, "J2K handle or JPWL markers list badly allocated\n");
@@ -1696,22 +1715,56 @@ bool jpwl_update_info(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int jwmarker_num)
/* end_pos: increment with markers before the end of this tile */
/* code is disabled, since according to JPWL no markers can be beyond TPH */
/*addlen = 0;
addlen = 0;
for (mm = 0; mm < jwmarker_num; mm++)
if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].end_pos)
addlen += jwmarker[mm].len + 2;*/
addlen += jwmarker[mm].len + 2;
info->tile[tileno].end_pos += addlen;
/* navigate through all the tile parts */
for (tpno = 0; tpno < info->tile[tileno].num_tps; tpno++) {
/* start_pos: increment with markers before SOT */
addlen = 0;
for (mm = 0; mm < jwmarker_num; mm++)
if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].tp[tpno].tp_start_pos)
addlen += jwmarker[mm].len + 2;
info->tile[tileno].tp[tpno].tp_start_pos += addlen;
/* end_header: increment with markers before of it */
addlen = 0;
for (mm = 0; mm < jwmarker_num; mm++)
if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].tp[tpno].tp_end_header)
addlen += jwmarker[mm].len + 2;
info->tile[tileno].tp[tpno].tp_end_header += addlen;
/* end_pos: increment with markers before the end of this tile part */
addlen = 0;
for (mm = 0; mm < jwmarker_num; mm++)
if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].tp[tpno].tp_end_pos)
addlen += jwmarker[mm].len + 2;
info->tile[tileno].tp[tpno].tp_end_pos += addlen;
}
/* navigate through all the packets in this tile */
for (packno = 0; packno < numpacks; packno++) {
/* start_pos: increment with markers before the packet */
/* disabled for the same reason as before */
addlen = 0;
for (mm = 0; mm < jwmarker_num; mm++)
if (jwmarker[mm].pos <= (unsigned long int) info->tile[tileno].packet[packno].start_pos)
addlen += jwmarker[mm].len + 2;
info->tile[tileno].packet[packno].start_pos += addlen;
/* end_ph_pos: increment with markers before the packet */
/* disabled for the same reason as before */
/*addlen = 0;
for (mm = 0; mm < jwmarker_num; mm++)
if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].packet[packno].start_pos)
if (jwmarker[mm].pos < (unsigned long int) info->tile[tileno].packet[packno].end_ph_pos)
addlen += jwmarker[mm].len + 2;*/
info->tile[tileno].packet[packno].start_pos += addlen;
info->tile[tileno].packet[packno].end_ph_pos += addlen;
/* end_pos: increment if marker is before the end of packet */
/* disabled for the same reason as before */
@@ -1724,6 +1777,8 @@ bool jpwl_update_info(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int jwmarker_num)
}
}
/* reorder the markers list */
return true;
}

View File

@@ -32,9 +32,13 @@ ENDIF(WIN32)
# Create the library
ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS})
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME} PROPERTIES
${OPENJPEG_LIBRARY_PROPERTIES})
# Install library
INSTALL_TARGETS(/lib/ ${OPENJPEG_LIBRARY_NAME})
INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}
DESTINATION lib)
# Install includes files
INSTALL_FILES(/include .h)
INSTALL(FILES openjpeg.h
DESTINATION ${INCLUDE_INSTALL_DIR}/openjpeg)

View File

@@ -114,7 +114,7 @@ static int bio_getbit(opj_bio_t *bio) {
==========================================================
*/
opj_bio_t* bio_create() {
opj_bio_t* bio_create(void) {
opj_bio_t *bio = (opj_bio_t*)opj_malloc(sizeof(opj_bio_t));
return bio;
}

View File

@@ -64,7 +64,7 @@ typedef struct opj_bio {
Create a new BIO handle
@return Returns a new BIO handle if successful, returns NULL otherwise
*/
opj_bio_t* bio_create();
opj_bio_t* bio_create(void);
/**
Destroy a previously created BIO handle
@param bio BIO handle to destroy

View File

@@ -58,9 +58,10 @@ opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer
opj_free(cio);
return NULL;
}
cio->length = (int) (1.3 * cp->img_size);
cio->length = (unsigned int) (0.1625 * cp->img_size + 2000); /* 0.1625 = 1.3/8 and 2000 bytes as a minimum for headers */
cio->buffer = (unsigned char *)opj_malloc(cio->length);
if(!cio->buffer) {
opj_event_msg(cio->cinfo, EVT_ERROR, "Error allocating memory for compressed bitstream\n");
opj_free(cio);
return NULL;
}
@@ -139,7 +140,7 @@ bool cio_byteout(opj_cio_t *cio, unsigned char v) {
*/
unsigned char cio_bytein(opj_cio_t *cio) {
if (cio->bp >= cio->end) {
opj_event_msg(cio->cinfo, EVT_ERROR, "read error\n");
opj_event_msg(cio->cinfo, EVT_ERROR, "read error: passed the end of the codestream (start = %d, current = %d, end = %d\n", cio->start, cio->bp, cio->end);
return 0;
}
return *cio->bp++;

View File

@@ -5,6 +5,8 @@
* 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, Jonathan Ballard <dzonatas@dzonux.net>
* Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,6 +31,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef __SSE__
#include <xmmintrin.h>
#endif
#include "opj_includes.h"
@@ -48,6 +53,26 @@ typedef struct dwt_local{
int cas;
} dwt_t;
typedef union {
float f[4];
} v4;
typedef struct v4dwt_local {
v4* wavelet ;
int dn ;
int sn ;
int cas ;
} v4dwt_t ;
static const float dwt_alpha = 1.586134342f; // 12994
static const float dwt_beta = 0.052980118f; // 434
static const float dwt_gamma = -0.882911075f; // -7233
static const float dwt_delta = -0.443506852f; // -3633
static const float K = 1.230174105f; // 10078
/* FIXME: What is this constant? */
static const float c13318 = 1.625732422f;
/*@}*/
/**
@@ -75,11 +100,11 @@ Inverse lazy transform (vertical)
*/
static void dwt_interleave_v(dwt_t* v, int *a, int x);
/**
Forward 5-3 wavelet tranform in 1-D
Forward 5-3 wavelet transform in 1-D
*/
static void dwt_encode_1(int *a, int dn, int sn, int cas);
/**
Inverse 5-3 wavelet tranform in 1-D
Inverse 5-3 wavelet transform in 1-D
*/
static void dwt_decode_1(dwt_t *v);
/**
@@ -87,17 +112,13 @@ Forward 9-7 wavelet transform in 1-D
*/
static void dwt_encode_1_real(int *a, int dn, int sn, int cas);
/**
Inverse 9-7 wavelet transform in 1-D
*/
static void dwt_decode_1_real(dwt_t *v);
/**
FIXME : comment ???
Explicit calculation of the Quantization Stepsizes
*/
static void dwt_encode_stepsize(int stepsize, int numbps, opj_stepsize_t *bandno_stepsize);
/**
Inverse wavelet tranform in 2-D.
Inverse wavelet transform in 2-D.
*/
static void dwt_decode_tile(opj_tcd_tilecomp_t * tilec, int stop , DWT1DFN fn);
static void dwt_decode_tile(opj_tcd_tilecomp_t* tilec, int i, DWT1DFN fn);
/*@}*/
@@ -199,7 +220,7 @@ static void dwt_interleave_v(dwt_t* v, int *a, int x) {
/* <summary> */
/* Forward 5-3 wavelet tranform in 1-D. */
/* Forward 5-3 wavelet transform in 1-D. */
/* </summary> */
static void dwt_encode_1(int *a, int dn, int sn, int cas) {
int i;
@@ -220,7 +241,7 @@ static void dwt_encode_1(int *a, int dn, int sn, int cas) {
}
/* <summary> */
/* Inverse 5-3 wavelet tranform in 1-D. */
/* Inverse 5-3 wavelet transform in 1-D. */
/* </summary> */
static void dwt_decode_1_(int *a, int dn, int sn, int cas) {
int i;
@@ -241,7 +262,7 @@ static void dwt_decode_1_(int *a, int dn, int sn, int cas) {
}
/* <summary> */
/* Inverse 5-3 wavelet tranform in 1-D. */
/* Inverse 5-3 wavelet transform in 1-D. */
/* </summary> */
static void dwt_decode_1(dwt_t *v) {
dwt_decode_1_(v->mem, v->dn, v->sn, v->cas);
@@ -285,102 +306,6 @@ static void dwt_encode_1_real(int *a, int dn, int sn, int cas) {
}
}
static void dwt_decode_sm(dwt_t* v, int k, int n, int x) {
int m = k > n ? n : k;
int l = v->mem[1]; //D(0);
int j;
int i;
for (i = 0; i < m; i++) {
j = l;
WS(i) -= fix_mul( ( l = WD(i) ) + j , x);
}
if( i < k ) {
l = fix_mul( l + l , x );
for (; i < k; i++)
WS(i) -= l;
}
}
static void dwt_decode_sp(dwt_t* v, int k, int n, int x) {
int m = k > n ? n : k;
int l = v->mem[1]; //D(0);
int j;
int i;
for (i = 0; i < m; i++) {
j = l;
WS(i) += fix_mul( ( l = WD(i) ) + j , x);
}
if( i < k ) {
l = fix_mul( l + l , x );
for (; i < k; i++)
WS(i) += l;
}
}
static void dwt_decode_dm(dwt_t* v, int k, int n, int x) {
int m = k >= n ? n-1 : k;
int l = v->mem[0]; //S(0);
int i;
int j;
for (i = 0; i < m; i++) {
j = l;
WD(i) -= fix_mul( ( l = WS(i+1) ) + j , x);
}
if( i < k ) {
l = fix_mul( l + l , x );
for (; i < k; i++)
WD(i) -= l;
}
}
static void dwt_decode_dp(dwt_t* v, int k, int n, int x) {
int m = k >= n ? n-1 : k;
int l = v->mem[0]; //S(0);
int i;
int j;
for (i = 0; i < m; i++) {
j = l;
WD(i) += fix_mul( ( l = WS(i+1) ) + j , x);
}
if( i < k ) {
l = fix_mul( l + l , x );
for (; i < k; i++)
WD(i) += l;
}
}
/* <summary> */
/* Inverse 9-7 wavelet transform in 1-D. */
/* </summary> */
static void dwt_decode_1_real(dwt_t* v) {
int i;
if (!v->cas) {
if ((v->dn > 0) || (v->sn > 1)) { /* NEW : CASE ONE ELEMENT */
for (i = 0; i < v->sn; i++)
WS(i) = fix_mul(WS(i), 10078); /* 10076 */
for (i = 0; i < v->dn; i++)
WD(i) = fix_mul(WD(i), 13318); /* 13320 */
dwt_decode_sm(v, v->sn, v->dn, 3633);
dwt_decode_dm(v, v->dn, v->sn, 7233);
dwt_decode_sp(v, v->sn, v->dn, 434);
dwt_decode_dp(v, v->dn, v->sn, 12994);
}
} else {
if ((v->sn > 0) || (v->dn > 1)) { /* NEW : CASE ONE ELEMENT */
for (i = 0; i < v->sn; i++)
WD(i) = fix_mul(WD(i), 10078); /* 10076 */
for (i = 0; i < v->dn; i++)
WS(i) = fix_mul(WS(i), 13318); /* 13320 */
dwt_decode_dm(v, v->sn, v->dn, 3633);
dwt_decode_sm(v, v->dn, v->sn, 7233);
dwt_decode_dp(v, v->sn, v->dn, 434);
dwt_decode_sp(v, v->dn, v->sn, 12994);
}
}
}
static void dwt_encode_stepsize(int stepsize, int numbps, opj_stepsize_t *bandno_stepsize) {
int p, n;
p = int_floorlog2(stepsize) - 13;
@@ -396,7 +321,7 @@ static void dwt_encode_stepsize(int stepsize, int numbps, opj_stepsize_t *bandno
*/
/* <summary> */
/* Forward 5-3 wavelet tranform in 2-D. */
/* Forward 5-3 wavelet transform in 2-D. */
/* </summary> */
void dwt_encode(opj_tcd_tilecomp_t * tilec) {
int i, j, k;
@@ -411,7 +336,7 @@ void dwt_encode(opj_tcd_tilecomp_t * tilec) {
for (i = 0; i < l; i++) {
int rw; /* width of the resolution level computed */
int rh; /* heigth of the resolution level computed */
int rh; /* height of the resolution level computed */
int rw1; /* width of the resolution level once lower than computed one */
int rh1; /* height of the resolution level once lower than computed one */
int cas_col; /* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
@@ -452,10 +377,10 @@ void dwt_encode(opj_tcd_tilecomp_t * tilec) {
/* <summary> */
/* Inverse 5-3 wavelet tranform in 2-D. */
/* Inverse 5-3 wavelet transform in 2-D. */
/* </summary> */
void dwt_decode(opj_tcd_tilecomp_t * tilec, int stop) {
dwt_decode_tile(tilec, stop, &dwt_decode_1);
void dwt_decode(opj_tcd_tilecomp_t* tilec, int numres) {
dwt_decode_tile(tilec, numres, &dwt_decode_1);
}
@@ -494,7 +419,7 @@ void dwt_encode_real(opj_tcd_tilecomp_t * tilec) {
for (i = 0; i < l; i++) {
int rw; /* width of the resolution level computed */
int rh; /* heigth of the resolution level computed */
int rh; /* height of the resolution level computed */
int rw1; /* width of the resolution level once lower than computed one */
int rh1; /* height of the resolution level once lower than computed one */
int cas_col; /* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
@@ -534,14 +459,6 @@ void dwt_encode_real(opj_tcd_tilecomp_t * tilec) {
}
/* <summary> */
/* Inverse 9-7 wavelet transform in 2-D. */
/* </summary> */
void dwt_decode_real(opj_tcd_tilecomp_t * tilec, int stop) {
dwt_decode_tile(tilec, stop, dwt_decode_1_real);
}
/* <summary> */
/* Get gain of 9-7 wavelet transform. */
/* </summary> */
@@ -582,7 +499,7 @@ void dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, int prec) {
/* <summary> */
/* Determine maximum computed resolution level for inverse wavelet transform */
/* </summary> */
static int dwt_decode_max_resolution(opj_tcd_resolution_t* r, int i) {
static int dwt_decode_max_resolution(opj_tcd_resolution_t* restrict r, int i) {
int mr = 1;
int w;
while( --i ) {
@@ -597,65 +514,312 @@ static int dwt_decode_max_resolution(opj_tcd_resolution_t* r, int i) {
/* <summary> */
/* Inverse wavelet tranform in 2-D. */
/* Inverse wavelet transform in 2-D. */
/* </summary> */
static void dwt_decode_tile(opj_tcd_tilecomp_t * tilec, int stop, DWT1DFN dwt_1D) {
opj_tcd_resolution_t* tr;
int i, j, k;
int *a = NULL;
int *aj = NULL;
int *m;
int w; //, l;
int rw; /* width of the resolution level computed */
int rh; /* heigth of the resolution level computed */
static void dwt_decode_tile(opj_tcd_tilecomp_t* tilec, int numres, DWT1DFN dwt_1D) {
dwt_t h;
dwt_t v;
if( 1 > ( i = tilec->numresolutions - stop ) )
return ;
opj_tcd_resolution_t* tr = tilec->resolutions;
tr = tilec->resolutions;
int rw = tr->x1 - tr->x0; /* width of the resolution level computed */
int rh = tr->y1 - tr->y0; /* height of the resolution level computed */
w = tilec->x1-tilec->x0;
a = tilec->data;
int w = tilec->x1 - tilec->x0;
m = (int*)opj_malloc(sizeof(int) * (dwt_decode_max_resolution(tr, i)+5));
h.mem = v.mem = (int*)( (unsigned)m + 16 - ( (unsigned)m % 16 ) ) ;
h.mem = opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int));
v.mem = h.mem;
while( --numres) {
int * restrict tiledp = tilec->data;
int j;
++tr;
h.sn = rw;
v.sn = rh;
rw = tr->x1 - tr->x0;
rh = tr->y1 - tr->y0;
while( --i ) {
tr++;
h.sn = rw;
v.sn = rh;
h.dn = ( rw = tr->x1 - tr->x0 ) - h.sn;
v.dn = ( rh = tr->y1 - tr->y0 ) - v.sn;
h.dn = rw - h.sn;
h.cas = tr->x0 % 2;
for(j = 0; j < rh; ++j) {
dwt_interleave_h(&h, &tiledp[j*w]);
(dwt_1D)(&h);
memcpy(&tiledp[j*w], h.mem, rw * sizeof(int));
}
v.dn = rh - v.sn;
v.cas = tr->y0 % 2;
aj = a;
j = rh;
while( j-- ) {
dwt_interleave_h(&h, aj);
(dwt_1D)(&h);
k = rw;
while( k-- )
aj[k] = h.mem[k];
aj += w;
for(j = 0; j < rw; ++j){
int k;
dwt_interleave_v(&v, &tiledp[j], w);
(dwt_1D)(&v);
for(k = 0; k < rh; ++k) {
tiledp[k * w + j] = v.mem[k];
}
}
}
opj_aligned_free(h.mem);
}
aj = a;
j = rw;
while( j-- ) {
dwt_interleave_v(&v, aj, w);
(dwt_1D)(&v);
k = rh;
while( k-- )
aj[k * w] = v.mem[k];
aj++;
static void v4dwt_interleave_h(v4dwt_t* restrict w, float* restrict a, int x, int size){
float* restrict bi = (float*) (w->wavelet + w->cas);
int count = w->sn;
int i, k;
for(k = 0; k < 2; ++k){
for(i = 0; i < count; ++i){
int j = i;
bi[i*8 ] = a[j];
j += x;
if(j > size) continue;
bi[i*8 + 1] = a[j];
j += x;
if(j > size) continue;
bi[i*8 + 2] = a[j];
j += x;
if(j > size) continue;
bi[i*8 + 3] = a[j];
}
bi = (float*) (w->wavelet + 1 - w->cas);
a += w->sn;
size -= w->sn;
count = w->dn;
}
}
opj_free(m);
static void v4dwt_interleave_v(v4dwt_t* restrict v , float* restrict a , int x){
v4* restrict bi = v->wavelet + v->cas;
int i;
for(i = 0; i < v->sn; ++i){
memcpy(&bi[i*2], &a[i*x], 4 * sizeof(float));
}
a += v->sn * x;
bi = v->wavelet + 1 - v->cas;
for(i = 0; i < v->dn; ++i){
memcpy(&bi[i*2], &a[i*x], 4 * sizeof(float));
}
}
#ifdef __SSE__
static void v4dwt_decode_step1_sse(v4* w, int count, const __m128 c){
__m128* restrict vw = (__m128*) w;
int i;
for(i = 0; i < count; ++i){
__m128 tmp = vw[i*2];
vw[i*2] = tmp * c;
}
}
static void v4dwt_decode_step2_sse(v4* l, v4* w, int k, int m, __m128 c){
__m128* restrict vl = (__m128*) l;
__m128* restrict vw = (__m128*) w;
int i;
for(i = 0; i < m; ++i){
__m128 tmp1 = vl[ 0];
__m128 tmp2 = vw[-1];
__m128 tmp3 = vw[ 0];
vw[-1] = tmp2 + ((tmp1 + tmp3) * c);
vl = vw;
vw += 2;
}
if(m >= k){
return;
}
c += c;
c *= vl[0];
for(; m < k; ++m){
__m128 tmp = vw[-1];
vw[-1] = tmp + c;
vw += 2;
}
}
#else
static void v4dwt_decode_step1(v4* w, int count, const float c){
float* restrict fw = (float*) w;
int i;
for(i = 0; i < count; ++i){
float tmp1 = fw[i*8 ];
float tmp2 = fw[i*8 + 1];
float tmp3 = fw[i*8 + 2];
float tmp4 = fw[i*8 + 3];
fw[i*8 ] = tmp1 * c;
fw[i*8 + 1] = tmp2 * c;
fw[i*8 + 2] = tmp3 * c;
fw[i*8 + 3] = tmp4 * c;
}
}
static void v4dwt_decode_step2(v4* l, v4* w, int k, int m, float c){
float* restrict fl = (float*) l;
float* restrict fw = (float*) w;
int i;
for(i = 0; i < m; ++i){
float tmp1_1 = fl[0];
float tmp1_2 = fl[1];
float tmp1_3 = fl[2];
float tmp1_4 = fl[3];
float tmp2_1 = fw[-4];
float tmp2_2 = fw[-3];
float tmp2_3 = fw[-2];
float tmp2_4 = fw[-1];
float tmp3_1 = fw[0];
float tmp3_2 = fw[1];
float tmp3_3 = fw[2];
float tmp3_4 = fw[3];
fw[-4] = tmp2_1 + ((tmp1_1 + tmp3_1) * c);
fw[-3] = tmp2_2 + ((tmp1_2 + tmp3_2) * c);
fw[-2] = tmp2_3 + ((tmp1_3 + tmp3_3) * c);
fw[-1] = tmp2_4 + ((tmp1_4 + tmp3_4) * c);
fl = fw;
fw += 8;
}
if(m < k){
float c1;
float c2;
float c3;
float c4;
c += c;
c1 = fl[0] * c;
c2 = fl[1] * c;
c3 = fl[2] * c;
c4 = fl[3] * c;
for(; m < k; ++m){
float tmp1 = fw[-4];
float tmp2 = fw[-3];
float tmp3 = fw[-2];
float tmp4 = fw[-1];
fw[-4] = tmp1 + c1;
fw[-3] = tmp2 + c2;
fw[-2] = tmp3 + c3;
fw[-1] = tmp4 + c4;
fw += 8;
}
}
}
#endif
/* <summary> */
/* Inverse 9-7 wavelet transform in 1-D. */
/* </summary> */
static void v4dwt_decode(v4dwt_t* restrict dwt){
int a, b;
if(dwt->cas == 0) {
if(!((dwt->dn > 0) || (dwt->sn > 1))){
return;
}
a = 0;
b = 1;
}else{
if(!((dwt->sn > 0) || (dwt->dn > 1))) {
return;
}
a = 1;
b = 0;
}
#ifdef __SSE__
v4dwt_decode_step1_sse(dwt->wavelet+a, dwt->sn, _mm_set1_ps(K));
v4dwt_decode_step1_sse(dwt->wavelet+b, dwt->dn, _mm_set1_ps(c13318));
v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(dwt_delta));
v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(dwt_gamma));
v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(dwt_beta));
v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(dwt_alpha));
#else
v4dwt_decode_step1(dwt->wavelet+a, dwt->sn, K);
v4dwt_decode_step1(dwt->wavelet+b, dwt->dn, c13318);
v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), dwt_delta);
v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), dwt_gamma);
v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), dwt_beta);
v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), dwt_alpha);
#endif
}
/* <summary> */
/* Inverse 9-7 wavelet transform in 2-D. */
/* </summary> */
void dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, int numres){
v4dwt_t h;
v4dwt_t v;
opj_tcd_resolution_t* res = tilec->resolutions;
int rw = res->x1 - res->x0; /* width of the resolution level computed */
int rh = res->y1 - res->y0; /* height of the resolution level computed */
int w = tilec->x1 - tilec->x0;
h.wavelet = (v4*) opj_aligned_malloc((dwt_decode_max_resolution(res, numres)+5) * sizeof(v4));
v.wavelet = h.wavelet;
while( --numres) {
float * restrict aj = (float*) tilec->data;
int bufsize = (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0);
int j;
h.sn = rw;
v.sn = rh;
++res;
rw = res->x1 - res->x0; /* width of the resolution level computed */
rh = res->y1 - res->y0; /* height of the resolution level computed */
h.dn = rw - h.sn;
h.cas = res->x0 % 2;
for(j = rh; j > 0; j -= 4){
v4dwt_interleave_h(&h, aj, w, bufsize);
v4dwt_decode(&h);
if(j >= 4){
int k;
for(k = rw; --k >= 0;){
aj[k ] = h.wavelet[k].f[0];
aj[k+w ] = h.wavelet[k].f[1];
aj[k+w*2] = h.wavelet[k].f[2];
aj[k+w*3] = h.wavelet[k].f[3];
}
}else{
int k;
for(k = rw; --k >= 0;){
switch(j) {
case 3: aj[k+w*2] = h.wavelet[k].f[2];
case 2: aj[k+w ] = h.wavelet[k].f[1];
case 1: aj[k ] = h.wavelet[k].f[0];
}
}
}
aj += w*4;
bufsize -= w*4;
}
v.dn = rh - v.sn;
v.cas = res->y0 % 2;
aj = (float*) tilec->data;
for(j = rw; j > 0; j -= 4){
v4dwt_interleave_v(&v, aj, w);
v4dwt_decode(&v);
if(j >= 4){
int k;
for(k = 0; k < rh; ++k){
memcpy(&aj[k*w], &v.wavelet[k], 4 * sizeof(float));
}
}else{
int k;
for(k = 0; k < rh; ++k){
memcpy(&aj[k*w], &v.wavelet[k], j * sizeof(float));
}
}
aj += 4;
}
}
opj_aligned_free(h.wavelet);
}

View File

@@ -57,9 +57,9 @@ void dwt_encode(opj_tcd_tilecomp_t * tilec);
Inverse 5-3 wavelet tranform in 2-D.
Apply a reversible inverse DWT transform to a component of an image.
@param tilec Tile component information (current tile)
@param stop FIXME Number of decoded resolution levels ?
@param numres Number of resolution levels to decode
*/
void dwt_decode(opj_tcd_tilecomp_t * tilec, int stop);
void dwt_decode(opj_tcd_tilecomp_t* tilec, int numres);
/**
Get the gain of a subband for the reversible 5-3 DWT.
@param orient Number that identifies the subband (0->LL, 1->HL, 2->LH, 3->HH)
@@ -83,9 +83,9 @@ void dwt_encode_real(opj_tcd_tilecomp_t * tilec);
Inverse 9-7 wavelet transform in 2-D.
Apply an irreversible inverse DWT transform to a component of an image.
@param tilec Tile component information (current tile)
@param stop FIXME Number of decoded resolution levels ?
@param numres Number of resolution levels to decode
*/
void dwt_decode_real(opj_tcd_tilecomp_t * tilec, int stop);
void dwt_decode_real(opj_tcd_tilecomp_t* tilec, int numres);
/**
Get the gain of a subband for the irreversible 9-7 DWT.
@param orient Number that identifies the subband (0->LL, 1->HL, 2->LH, 3->HH)
@@ -100,9 +100,9 @@ Get the norm of a wavelet function of a subband at a specified level for the irr
*/
double dwt_getnorm_real(int level, int orient);
/**
FIXME : comment ???
@param tccp
@param prec
Explicit calculation of the Quantization Stepsizes
@param tccp Tile-component coding parameters
@param prec Precint analyzed
*/
void dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, int prec);
/* ----------------------------------------------------------------------- */

View File

@@ -26,7 +26,7 @@
#include "opj_includes.h"
opj_image_t* opj_image_create0() {
opj_image_t* opj_image_create0(void) {
opj_image_t *image = (opj_image_t*)opj_malloc(sizeof(opj_image_t));
return image;
}
@@ -35,13 +35,14 @@ opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *c
int compno;
opj_image_t *image = NULL;
image = (opj_image_t*)opj_malloc(sizeof(opj_image_t));
image = (opj_image_t*) opj_calloc(1, sizeof(opj_image_t));
if(image) {
image->color_space = clrspc;
image->numcomps = numcmpts;
/* allocate memory for the per-component information */
image->comps = (opj_image_comp_t*)opj_malloc(image->numcomps * sizeof(opj_image_comp_t));
if(!image->comps) {
fprintf(stderr,"Unable to allocate memory for image.\n");
opj_image_destroy(image);
return NULL;
}
@@ -57,8 +58,9 @@ opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *c
comp->prec = cmptparms[compno].prec;
comp->bpp = cmptparms[compno].bpp;
comp->sgnd = cmptparms[compno].sgnd;
comp->data = (int*)opj_malloc(comp->w * comp->h * sizeof(int));
comp->data = (int*) opj_calloc(comp->w * comp->h, sizeof(int));
if(!comp->data) {
fprintf(stderr,"Unable to allocate memory for image.\n");
opj_image_destroy(image);
return NULL;
}

View File

@@ -40,7 +40,7 @@ Create an empty image
@todo this function should be removed
@return returns an empty image if successful, returns NULL otherwise
*/
opj_image_t* opj_image_create0();
opj_image_t* opj_image_create0(void);
/*@}*/

File diff suppressed because it is too large Load Diff

View File

@@ -79,13 +79,18 @@ The functions in J2K.C have for goal to read/write the several parts of the code
#define J2K_MS_COM 0xff64 /**< COM marker value */
/* UniPG>> */
#ifdef USE_JPWL
#define J2K_MS_EPC 0xff68 /**< EPC marker value (Part11) */
#define J2K_MS_EPB 0xff66 /**< EPB marker value (Part11) */
#define J2K_MS_ESD 0xff67 /**< ESD marker value (Part11) */
#define J2K_MS_RED 0xff69 /**< RED marker value (Part11) */
#define J2K_MS_EPC 0xff68 /**< EPC marker value (Part 11: JPEG 2000 for Wireless) */
#define J2K_MS_EPB 0xff66 /**< EPB marker value (Part 11: JPEG 2000 for Wireless) */
#define J2K_MS_ESD 0xff67 /**< ESD marker value (Part 11: JPEG 2000 for Wireless) */
#define J2K_MS_RED 0xff69 /**< RED marker value (Part 11: JPEG 2000 for Wireless) */
#endif /* USE_JPWL */
#ifdef USE_JPSEC
#define J2K_MS_SEC 0xff65 /**< SEC marker value (Part 8: Secure JPEG 2000) */
#define J2K_MS_INSEC 0xff94 /**< INSEC marker value (Part 8: Secure JPEG 2000) */
#endif /* USE_JPSEC */
/* <<UniPG */
/* ----------------------------------------------------------------------- */
/**
@@ -99,7 +104,8 @@ typedef enum J2K_STATUS {
J2K_STATE_TPHSOT = 0x0008, /**< the decoding process is in a tile part header and expects a SOT marker */
J2K_STATE_TPH = 0x0010, /**< the decoding process is in a tile part header */
J2K_STATE_MT = 0x0020, /**< the EOC marker has just been read */
J2K_STATE_NEOC = 0x0040 /**< the decoding process must not expect a EOC marker because the codestream is truncated */
J2K_STATE_NEOC = 0x0040, /**< the decoding process must not expect a EOC marker because the codestream is truncated */
J2K_STATE_ERR = 0x0080 /**< the decoding process has encountered an error */
} J2K_STATUS;
/* ----------------------------------------------------------------------- */
@@ -222,8 +228,6 @@ typedef struct opj_cp {
int layer;
/** if == NO_LIMITATION, decode entire codestream; if == LIMIT_TO_MAIN_HEADER then only decode the main header */
OPJ_LIMIT_DECODING limit_decoding;
/** 0 = no index || 1 = index */
int index_on;
/** XTOsiz */
int tx0;
/** YTOsiz */
@@ -304,92 +308,6 @@ typedef struct opj_cp {
/* <<UniPG */
} opj_cp_t;
/**
Information concerning a packet inside tile
*/
typedef struct opj_packet_info {
/** start position */
int start_pos;
/** end position */
int end_pos;
/** ADD for Marcela */
double disto;
} opj_packet_info_t;
/**
Index structure : information regarding tiles inside image
*/
typedef struct opj_tile_info {
/** value of thresh for each layer by tile cfr. Marcela */
double *thresh;
/** number of tile */
int num_tile;
/** start position */
int start_pos;
/** end position of the header */
int end_header;
/** end position */
int end_pos;
/** precinct number for each resolution level (width) */
int pw[33];
/** precinct number for each resolution level (height) */
int ph[33];
/** precinct size (in power of 2), in X for each resolution level */
int pdx[33];
/** precinct size (in power of 2), in Y for each resolution level */
int pdy[33];
/** information concerning packets inside tile */
opj_packet_info_t *packet;
/** add fixed_quality */
int nbpix;
/** add fixed_quality */
double distotile;
} opj_tile_info_t;
/**
Index structure
*/
typedef struct opj_image_info {
/** 0 = no index || 1 = index */
int index_on;
/** maximum distortion reduction on the whole image (add for Marcela) */
double D_max;
/** packet number */
int num;
/** writing the packet in the index with t2_encode_packets */
int index_write;
/** image width */
int image_w;
/** image height */
int image_h;
/** progression order */
OPJ_PROG_ORDER prog;
/** tile size in x */
int tile_x;
/** tile size in y */
int tile_y;
/** */
int tile_Ox;
/** */
int tile_Oy;
/** number of tiles in X */
int tw;
/** number of tiles in Y */
int th;
/** component numbers */
int comp;
/** number of layer */
int layer;
/** number of decomposition */
int decomposition;
/** main header position */
int main_head_end;
/** codestream's size */
int codestream_size;
/** information regarding tiles inside image */
opj_tile_info_t *tile;
} opj_image_info_t;
/**
JPEG-2000 codestream reader/writer
*/
@@ -445,7 +363,7 @@ typedef struct opj_j2k {
/** pointer to the coding parameters */
opj_cp_t *cp;
/** helper used to write the index file */
opj_image_info_t *image_info;
opj_codestream_info_t *cstr_info;
/** pointer to the byte i/o stream */
opj_cio_t *cio;
} opj_j2k_t;
@@ -475,16 +393,18 @@ void j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters);
Decode an image from a JPEG-2000 codestream
@param j2k J2K decompressor handle
@param cio Input buffer stream
@param cstr_info Codestream information structure if required, NULL otherwise
@return Returns a decoded image if successful, returns NULL otherwise
*/
opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio);
opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *cstr_info);
/**
Decode an image form a JPT-stream (JPEG 2000, JPIP)
@param j2k J2K decompressor handle
@param cio Input buffer stream
@param cstr_info Codestream information structure if required, NULL otherwise
@return Returns a decoded image if successful, returns NULL otherwise
*/
opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, opj_cio_t *cio);
opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *cstr_info);
/**
Creates a J2K compression structure
@param cinfo Codec context info
@@ -513,10 +433,11 @@ Encode an image into a JPEG-2000 codestream
@param j2k J2K compressor handle
@param cio Output buffer stream
@param image Image to encode
@param index Name of the index file if required, NULL otherwise
@param cstr_info Codestream information structure if required, NULL otherwise
@return Returns true if successful, returns false otherwise
*/
bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, char *index);
bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
/* ----------------------------------------------------------------------- */
/*@}*/

View File

@@ -33,7 +33,7 @@
#endif /* WIN32 */
#include "opj_includes.h"
double opj_clock() {
double opj_clock(void) {
#ifdef WIN32
/* WIN32: use QueryPerformance (very accurate) */
LARGE_INTEGER freq , t ;
@@ -57,20 +57,3 @@ double opj_clock() {
#endif
}
void* opj_malloc( size_t size ) {
void *memblock = malloc(size);
if(memblock) {
memset(memblock, 0, size);
}
return memblock;
}
void* opj_realloc( void *memblock, size_t size ) {
return realloc(memblock, size);
}
void opj_free( void *memblock ) {
free(memblock);
}

View File

@@ -29,7 +29,7 @@
@file j2k_lib.h
@brief Internal functions
The functions in J2K_LIB.C are internal utilities mainly used for memory management.
The functions in J2K_LIB.C are internal utilities mainly used for timing.
*/
/** @defgroup MISC MISC - Miscellaneous internal functions */
@@ -43,28 +43,7 @@ The functions in J2K_LIB.C are internal utilities mainly used for memory managem
Difference in successive opj_clock() calls tells you the elapsed time
@return Returns time in seconds
*/
double opj_clock();
/**
Allocate a memory block with elements initialized to 0
@param size Bytes to allocate
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
*/
void* opj_malloc( size_t size );
/**
Reallocate memory blocks.
@param memblock Pointer to previously allocated memory block
@param size New size in bytes
@return Returns a void pointer to the reallocated (and possibly moved) memory block
*/
void* opj_realloc( void *memblock, size_t size );
/**
Deallocates or frees a memory block.
@param memblock Previously allocated memory block to be freed
*/
void opj_free( void *memblock );
double opj_clock(void);
/* ----------------------------------------------------------------------- */
/*@}*/

View File

@@ -71,7 +71,7 @@ Read the FTYP box - File type box
@return Returns true if successful, returns false otherwise
*/
static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio);
static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, char *index);
static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
static bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset);
static void jp2_write_jp(opj_cio_t *cio);
/**
@@ -404,7 +404,7 @@ static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) {
return true;
}
static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, char *index) {
static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
unsigned int j2k_codestream_offset, j2k_codestream_length;
opj_jp2_box_t box;
@@ -416,7 +416,7 @@ static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, ch
/* J2K encoding */
j2k_codestream_offset = cio_tell(cio);
if(!j2k_encode(j2k, cio, image, index)) {
if(!j2k_encode(j2k, cio, image, cstr_info)) {
opj_event_msg(j2k->cinfo, EVT_ERROR, "Failed to encode image\n");
return 0;
}
@@ -507,7 +507,7 @@ static bool jp2_read_struct(opj_jp2_t *jp2, opj_cio_t *cio) {
/* ----------------------------------------------------------------------- */
opj_jp2_t* jp2_create_decompress(opj_common_ptr cinfo) {
opj_jp2_t *jp2 = (opj_jp2_t*)opj_malloc(sizeof(opj_jp2_t));
opj_jp2_t *jp2 = (opj_jp2_t*) opj_calloc(1, sizeof(opj_jp2_t));
if(jp2) {
jp2->cinfo = cinfo;
/* create the J2K codec */
@@ -541,7 +541,7 @@ void jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters) {
/* further JP2 initializations go here */
}
opj_image_t* jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio) {
opj_image_t* jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, opj_codestream_info_t *cstr_info) {
opj_common_ptr cinfo;
opj_image_t *image = NULL;
@@ -558,11 +558,21 @@ opj_image_t* jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio) {
}
/* J2K decoding */
image = j2k_decode(jp2->j2k, cio);
image = j2k_decode(jp2->j2k, cio, cstr_info);
if(!image) {
opj_event_msg(cinfo, EVT_ERROR, "Failed to decode J2K image\n");
}
/* Set Image Color Space */
if (jp2->enumcs == 16)
image->color_space = CLRSPC_SRGB;
else if (jp2->enumcs == 17)
image->color_space = CLRSPC_GRAY;
else if (jp2->enumcs == 18)
image->color_space = CLRSPC_SYCC;
else
image->color_space = CLRSPC_UNKNOWN;
return image;
}
@@ -676,7 +686,7 @@ void jp2_setup_encoder(opj_jp2_t *jp2, opj_cparameters_t *parameters, opj_image_
}
bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, char *index) {
bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
/* JP2 encoding */
@@ -689,7 +699,7 @@ bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, char *index)
/* J2K encoding */
if(!jp2_write_jp2c(jp2, cio, image, index)) {
if(!jp2_write_jp2c(jp2, cio, image, cstr_info)) {
opj_event_msg(jp2->cinfo, EVT_ERROR, "Failed to encode image\n");
return false;
}

View File

@@ -136,9 +136,10 @@ void jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters);
Decode an image from a JPEG-2000 file stream
@param jp2 JP2 decompressor handle
@param cio Input buffer stream
@param cstr_info Codestream information structure if required, NULL otherwise
@return Returns a decoded image if successful, returns NULL otherwise
*/
opj_image_t* jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio);
opj_image_t* jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, opj_codestream_info_t *cstr_info);
/**
Creates a JP2 compression structure
@param cinfo Codec context info
@@ -163,10 +164,10 @@ Encode an image into a JPEG-2000 file stream
@param jp2 JP2 compressor handle
@param cio Output buffer stream
@param image Image to encode
@param index Name of the index file if required, NULL otherwise
@param cstr_info Codestream information structure if required, NULL otherwise
@return Returns true if successful, returns false otherwise
*/
bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, char *index);
bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
/* ----------------------------------------------------------------------- */
/*@}*/

View File

@@ -44,16 +44,20 @@ static const double mct_norms_real[3] = { 1.732, 1.805, 1.573 };
/* <summary> */
/* Foward reversible MCT. */
/* </summary> */
void mct_encode(int *c0, int *c1, int *c2, int n) {
void mct_encode(
int* restrict c0,
int* restrict c1,
int* restrict c2,
int n)
{
int i;
for (i = 0; i < n; i++) {
int r, g, b, y, u, v;
r = c0[i];
g = c1[i];
b = c2[i];
y = (r + (g << 1) + b) >> 2;
u = b - g;
v = r - g;
for(i = 0; i < n; ++i) {
int r = c0[i];
int g = c1[i];
int b = c2[i];
int y = (r + (g * 2) + b) >> 2;
int u = b - g;
int v = r - g;
c0[i] = y;
c1[i] = u;
c2[i] = v;
@@ -63,16 +67,20 @@ void mct_encode(int *c0, int *c1, int *c2, int n) {
/* <summary> */
/* Inverse reversible MCT. */
/* </summary> */
void mct_decode(int *c0, int *c1, int *c2, int n) {
void mct_decode(
int* restrict c0,
int* restrict c1,
int* restrict c2,
int n)
{
int i;
for (i = 0; i < n; i++) {
int y, u, v, r, g, b;
y = c0[i];
u = c1[i];
v = c2[i];
g = y - ((u + v) >> 2);
r = v + g;
b = u + g;
for (i = 0; i < n; ++i) {
int y = c0[i];
int u = c1[i];
int v = c2[i];
int g = y - ((u + v) >> 2);
int r = v + g;
int b = u + g;
c0[i] = r;
c1[i] = g;
c2[i] = b;
@@ -89,16 +97,20 @@ double mct_getnorm(int compno) {
/* <summary> */
/* Foward irreversible MCT. */
/* </summary> */
void mct_encode_real(int *c0, int *c1, int *c2, int n) {
void mct_encode_real(
int* restrict c0,
int* restrict c1,
int* restrict c2,
int n)
{
int i;
for (i = 0; i < n; i++) {
int r, g, b, y, u, v;
r = c0[i];
g = c1[i];
b = c2[i];
y = fix_mul(r, 2449) + fix_mul(g, 4809) + fix_mul(b, 934);
u = -fix_mul(r, 1382) - fix_mul(g, 2714) + fix_mul(b, 4096);
v = fix_mul(r, 4096) - fix_mul(g, 3430) - fix_mul(b, 666);
for(i = 0; i < n; ++i) {
int r = c0[i];
int g = c1[i];
int b = c2[i];
int y = fix_mul(r, 2449) + fix_mul(g, 4809) + fix_mul(b, 934);
int u = -fix_mul(r, 1382) - fix_mul(g, 2714) + fix_mul(b, 4096);
int v = fix_mul(r, 4096) - fix_mul(g, 3430) - fix_mul(b, 666);
c0[i] = y;
c1[i] = u;
c2[i] = v;
@@ -108,16 +120,20 @@ void mct_encode_real(int *c0, int *c1, int *c2, int n) {
/* <summary> */
/* Inverse irreversible MCT. */
/* </summary> */
void mct_decode_real(int *c0, int *c1, int *c2, int n) {
void mct_decode_real(
float* restrict c0,
float* restrict c1,
float* restrict c2,
int n)
{
int i;
for (i = 0; i < n; i++) {
int y, u, v, r, g, b;
y = c0[i];
u = c1[i];
v = c2[i];
r = y + fix_mul(v, 11485);
g = y - fix_mul(u, 2819) - fix_mul(v, 5850);
b = y + fix_mul(u, 14516);
for(i = 0; i < n; ++i) {
float y = c0[i];
float u = c1[i];
float v = c2[i];
float r = y + (v * 1.402f);
float g = y - (u * 0.34413f) - (v * (0.71414f));
float b = y + (u * 1.772f);
c0[i] = r;
c1[i] = g;
c2[i] = b;

View File

@@ -83,7 +83,7 @@ Apply an irreversible multi-component inverse transform to an image
@param c2 Samples for blue chrominance component
@param n Number of samples for each component
*/
void mct_decode_real(int *c0, int *c1, int *c2, int n);
void mct_decode_real(float* c0, float* c1, float* c2, int n);
/**
Get norm of the basis function used for the irreversible multi-component transform
@param compno Number of the component (0->Y, 1->U, 2->V)

View File

@@ -344,7 +344,7 @@ static void mqc_renormd(opj_mqc_t *mqc) {
==========================================================
*/
opj_mqc_t* mqc_create() {
opj_mqc_t* mqc_create(void) {
opj_mqc_t *mqc = (opj_mqc_t*)opj_malloc(sizeof(opj_mqc_t));
return mqc;
}
@@ -371,10 +371,6 @@ void mqc_init_enc(opj_mqc_t *mqc, unsigned char *bp) {
mqc->start = bp;
}
void mqc_setcurctx(opj_mqc_t *mqc, int ctxno) {
mqc->curctx = &mqc->ctxs[ctxno];
}
void mqc_encode(opj_mqc_t *mqc, int d) {
if ((*mqc->curctx)->mps == d) {
mqc_codemps(mqc);

View File

@@ -56,7 +56,7 @@ typedef struct opj_mqc_state {
struct opj_mqc_state *nlps;
} opj_mqc_state_t;
#define MQC_NUMCTXS 32
#define MQC_NUMCTXS 19
/**
MQ coder
@@ -79,7 +79,7 @@ typedef struct opj_mqc {
Create a new MQC handle
@return Returns a new MQC handle if successful, returns NULL otherwise
*/
opj_mqc_t* mqc_create();
opj_mqc_t* mqc_create(void);
/**
Destroy a previously created MQC handle
@param mqc MQC handle to destroy
@@ -116,7 +116,7 @@ Set the current context used for coding/decoding
@param mqc MQC handle
@param ctxno Number that identifies the context
*/
void mqc_setcurctx(opj_mqc_t *mqc, int ctxno);
#define mqc_setcurctx(mqc, ctxno) (mqc)->curctx = &(mqc)->ctxs[(int)(ctxno)]
/**
Encode a symbol using the MQ-coder
@param mqc MQC handle

View File

@@ -53,7 +53,7 @@ DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
/* ---------------------------------------------------------------------- */
const char* OPJ_CALLCONV opj_version() {
const char* OPJ_CALLCONV opj_version(void) {
return OPENJPEG_VERSION;
}
@@ -148,20 +148,23 @@ void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *param
}
opj_image_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio) {
return opj_decode_with_info(dinfo, cio, NULL);
}
opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *cio, opj_codestream_info_t *cstr_info) {
if(dinfo && cio) {
switch(dinfo->codec_format) {
case CODEC_J2K:
return j2k_decode((opj_j2k_t*)dinfo->j2k_handle, cio);
return j2k_decode((opj_j2k_t*)dinfo->j2k_handle, cio, cstr_info);
case CODEC_JPT:
return j2k_decode_jpt_stream((opj_j2k_t*)dinfo->j2k_handle, cio);
return j2k_decode_jpt_stream((opj_j2k_t*)dinfo->j2k_handle, cio, cstr_info);
case CODEC_JP2:
return jp2_decode((opj_jp2_t*)dinfo->jp2_handle, cio);
return jp2_decode((opj_jp2_t*)dinfo->jp2_handle, cio, cstr_info);
case CODEC_UNKNOWN:
default:
break;
}
}
return NULL;
}
@@ -203,10 +206,10 @@ void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo) {
/* destroy the codec */
switch(cinfo->codec_format) {
case CODEC_J2K:
j2k_destroy_decompress((opj_j2k_t*)cinfo->j2k_handle);
j2k_destroy_compress((opj_j2k_t*)cinfo->j2k_handle);
break;
case CODEC_JP2:
jp2_destroy_decompress((opj_jp2_t*)cinfo->jp2_handle);
jp2_destroy_compress((opj_jp2_t*)cinfo->jp2_handle);
break;
case CODEC_JPT:
case CODEC_UNKNOWN:
@@ -288,20 +291,39 @@ void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *param
}
bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index) {
if (index != NULL)
opj_event_msg((opj_common_ptr)cinfo, EVT_WARNING, "Set index to NULL when calling the opj_encode function.\n"
"To extract the index, use the opj_encode_with_info() function.\n"
"No index will be generated during this encoding\n");
return opj_encode_with_info(cinfo, cio, image, NULL);
}
bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
if(cinfo && cio && image) {
switch(cinfo->codec_format) {
case CODEC_J2K:
return j2k_encode((opj_j2k_t*)cinfo->j2k_handle, cio, image, index);
return j2k_encode((opj_j2k_t*)cinfo->j2k_handle, cio, image, cstr_info);
case CODEC_JP2:
return jp2_encode((opj_jp2_t*)cinfo->jp2_handle, cio, image, index);
return jp2_encode((opj_jp2_t*)cinfo->jp2_handle, cio, image, cstr_info);
case CODEC_JPT:
case CODEC_UNKNOWN:
default:
break;
}
}
return false;
}
void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) {
if (cstr_info) {
int tileno;
for (tileno = 0; tileno < cstr_info->tw * cstr_info->th; tileno++) {
opj_tile_info_t *tile_info = &cstr_info->tile[tileno];
opj_free(tile_info->thresh);
opj_free(tile_info->packet);
opj_free(tile_info->tp);
}
opj_free(cstr_info->tile);
opj_free(cstr_info->marker);
}
}

View File

@@ -104,6 +104,7 @@ braindamage below.
#define JPWL_EXPECTED_COMPONENTS 3 /**< Expect this number of components, so you'll find better the first EPB */
#define JPWL_MAXIMUM_TILES 8192 /**< Expect this maximum number of tiles, to avoid some crashes */
#define JPWL_MAXIMUM_HAMMING 2 /**< Expect this maximum number of bit errors in marker id's */
#define JPWL_MAXIMUM_EPB_ROOM 65450 /**< Expect this maximum number of bytes for composition of EPBs */
/* <<UniPG */
/*
@@ -302,9 +303,9 @@ typedef struct opj_cparameters {
char infile[OPJ_PATH_LEN];
/** output file name */
char outfile[OPJ_PATH_LEN];
/** creation of an index file, default to 0 (false) */
/** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
int index_on;
/** index file name */
/** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
char index[OPJ_PATH_LEN];
/** subimage encoding: origin image offset in x direction */
int image_offset_x0;
@@ -579,6 +580,142 @@ typedef struct opj_image_comptparm {
int sgnd;
} opj_image_cmptparm_t;
/*
==========================================================
Information on the JPEG 2000 codestream
==========================================================
*/
/**
Index structure : Information concerning a packet inside tile
*/
typedef struct opj_packet_info {
/** packet start position (including SOP marker if it exists) */
int start_pos;
/** end of packet header position (including EPH marker if it exists)*/
int end_ph_pos;
/** packet end position */
int end_pos;
/** packet distorsion */
double disto;
} opj_packet_info_t;
/**
Index structure : Information concerning tile-parts
*/
typedef struct opj_tp_info {
/** start position of tile part */
int tp_start_pos;
/** end position of tile part header */
int tp_end_header;
/** end position of tile part */
int tp_end_pos;
/** start packet of tile part */
int tp_start_pack;
/** number of packets of tile part */
int tp_numpacks;
} opj_tp_info_t;
/**
Index structure : information regarding tiles
*/
typedef struct opj_tile_info {
/** value of thresh for each layer by tile cfr. Marcela */
double *thresh;
/** number of tile */
int tileno;
/** start position */
int start_pos;
/** end position of the header */
int end_header;
/** end position */
int end_pos;
/** precinct number for each resolution level (width) */
int pw[33];
/** precinct number for each resolution level (height) */
int ph[33];
/** precinct size (in power of 2), in X for each resolution level */
int pdx[33];
/** precinct size (in power of 2), in Y for each resolution level */
int pdy[33];
/** information concerning packets inside tile */
opj_packet_info_t *packet;
/** add fixed_quality */
int numpix;
/** add fixed_quality */
double distotile;
/** number of tile parts */
int num_tps;
/** information concerning tile parts */
opj_tp_info_t *tp;
} opj_tile_info_t;
/* UniPG>> */
/**
Marker structure
*/
typedef struct opj_marker_info_t {
/** marker type */
unsigned short int type;
/** position in codestream */
int pos;
/** length, marker val included */
int len;
} opj_marker_info_t;
/* <<UniPG */
/**
Index structure of the codestream
*/
typedef struct opj_codestream_info {
/** maximum distortion reduction on the whole image (add for Marcela) */
double D_max;
/** packet number */
int packno;
/** writing the packet in the index with t2_encode_packets */
int index_write;
/** image width */
int image_w;
/** image height */
int image_h;
/** progression order */
OPJ_PROG_ORDER prog;
/** tile size in x */
int tile_x;
/** tile size in y */
int tile_y;
/** */
int tile_Ox;
/** */
int tile_Oy;
/** number of tiles in X */
int tw;
/** number of tiles in Y */
int th;
/** component numbers */
int numcomps;
/** number of layer */
int numlayers;
/** number of decomposition for each component */
int *numdecompos;
/* UniPG>> */
/** number of markers */
int marknum;
/** list of markers */
opj_marker_info_t *marker;
/** actual size of markers array */
int maxmarknum;
/* <<UniPG */
/** main header position */
int main_head_start;
/** main header position */
int main_head_end;
/** codestream's size */
int codestream_size;
/** information regarding tiles inside image */
opj_tile_info_t *tile;
} opj_codestream_info_t;
#ifdef __cplusplus
extern "C" {
#endif
@@ -590,7 +727,7 @@ extern "C" {
==========================================================
*/
OPJ_API const char * OPJ_CALLCONV opj_version();
OPJ_API const char * OPJ_CALLCONV opj_version(void);
/*
==========================================================
@@ -694,6 +831,15 @@ Decode an image from a JPEG-2000 codestream
@return Returns a decoded image if successful, returns NULL otherwise
*/
OPJ_API opj_image_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio);
/**
Decode an image from a JPEG-2000 codestream and extract the codestream information
@param dinfo decompressor handle
@param cio Input buffer stream
@param cstr_info Codestream information structure if needed afterwards, NULL otherwise
@return Returns a decoded image if successful, returns NULL otherwise
*/
OPJ_API opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *cio, opj_codestream_info_t *cstr_info);
/**
Creates a J2K/JP2 compression structure
@param format Coder to select
@@ -729,9 +875,9 @@ Set encoding parameters to default values, that means :
OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
/**
Setup the encoder parameters using the current image and using user parameters.
@param cinfo compressor handle
@param parameters compression parameters
@param image input filled image
@param cinfo Compressor handle
@param parameters Compression parameters
@param image Input filled image
*/
OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image);
/**
@@ -739,10 +885,24 @@ Encode an image into a JPEG-2000 codestream
@param cinfo compressor handle
@param cio Output buffer stream
@param image Image to encode
@param index Name of the index file if required, NULL otherwise
@param index Depreacted -> Set to NULL. To extract index, used opj_encode_wci()
@return Returns true if successful, returns false otherwise
*/
OPJ_API bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
/**
Encode an image into a JPEG-2000 codestream and extract the codestream information
@param cinfo compressor handle
@param cio Output buffer stream
@param image Image to encode
@param cstr_info Codestream information structure if needed afterwards, NULL otherwise
@return Returns true if successful, returns false otherwise
*/
OPJ_API bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
/**
Destroy Codestream information after compression or decompression
@param cstr_info Codestream information structure
*/
OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info);
#ifdef __cplusplus
}

View File

@@ -54,6 +54,11 @@
==========================================================
*/
/* Ignore GCC attributes if this is not GCC */
#ifndef __GNUC__
#define __attribute__(x) /* __attribute__(x) */
#endif
/*
The inline keyword is supported by C99 but not by C90.
Most compilers implement their own version of this keyword ...
@@ -71,7 +76,32 @@ Most compilers implement their own version of this keyword ...
#endif /* defined(<Compiler>) */
#endif /* INLINE */
/* Are restricted pointers available? (C99) */
#if (__STDC_VERSION__ != 199901L)
/* Not a C99 compiler */
#ifdef __GNUC__
#define restrict __restrict__
#else
#define restrict /* restrict */
#endif
#endif
/* MSVC does not have lrintf */
#ifdef _MSC_VER
static INLINE long lrintf(float f){
int i;
_asm{
fld f
fistp i
};
return i;
}
#endif
#include "j2k_lib.h"
#include "opj_malloc.h"
#include "event.h"
#include "cio.h"

145
libopenjpeg/opj_malloc.h Normal file
View File

@@ -0,0 +1,145 @@
/*
* Copyright (c) 2005, Herv<72> Drolon, FreeImage Team
* Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
* 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 __OPJ_MALLOC_H
#define __OPJ_MALLOC_H
/**
@file opj_malloc.h
@brief Internal functions
The functions in opj_malloc.h are internal utilities used for memory management.
*/
/** @defgroup MISC MISC - Miscellaneous internal functions */
/*@{*/
/** @name Exported functions */
/*@{*/
/* ----------------------------------------------------------------------- */
/**
Allocate an uninitialized memory block
@param size Bytes to allocate
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
*/
#define opj_malloc(size) malloc(size)
/**
Allocate a memory block with elements initialized to 0
@param num Blocks to allocate
@param size Bytes per block to allocate
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
*/
#define opj_calloc(num, size) calloc(num, size)
/**
Allocate memory aligned to a 16 byte boundry
@param size Bytes to allocate
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
*/
/* FIXME: These should be set with cmake tests, but we're currently not requiring use of cmake */
#ifdef WIN32
/* Someone should tell the mingw people that their malloc.h ought to provide _mm_malloc() */
#ifdef __GNUC__
#include <mm_malloc.h>
#define HAVE_MM_MALLOC
#else /* MSVC, Intel C++ */
#include <malloc.h>
#ifdef _mm_malloc
#define HAVE_MM_MALLOC
#endif
#endif
#else /* Not WIN32 */
#if defined(__sun)
#define HAVE_MEMALIGN
#elif defined(__GNUC__)
#define HAVE_MEMALIGN
#include <malloc.h>
/* Linux x86_64 and OSX always align allocations to 16 bytes */
#elif !defined(__amd64__) && !defined(__APPLE__)
/* FIXME: Yes, this is a big assumption */
#define HAVE_POSIX_MEMALIGN
#endif
#endif
#define opj_aligned_malloc(size) malloc(size)
#define opj_aligned_free(m) free(m)
#ifdef HAVE_MM_MALLOC
#undef opj_aligned_malloc
#define opj_aligned_malloc(size) _mm_malloc(size, 16)
#undef opj_aligned_free
#define opj_aligned_free(m) _mm_free(m)
#endif
#ifdef HAVE_MEMALIGN
extern void* memalign(size_t, size_t);
#undef opj_aligned_malloc
#define opj_aligned_malloc(size) memalign(16, (size))
#undef opj_aligned_free
#define opj_aligned_free(m) free(m)
#endif
#ifdef HAVE_POSIX_MEMALIGN
#undef opj_aligned_malloc
extern int posix_memalign(void**, size_t, size_t);
static INLINE void* __attribute__ ((malloc)) opj_aligned_malloc(size_t size){
void* mem = NULL;
posix_memalign(&mem, 16, size);
return mem;
}
#undef opj_aligned_free
#define opj_aligned_free(m) free(m)
#endif
/**
Reallocate memory blocks.
@param memblock Pointer to previously allocated memory block
@param size New size in bytes
@return Returns a void pointer to the reallocated (and possibly moved) memory block
*/
#define opj_realloc(m, s) realloc(m, s)
/**
Deallocates or frees a memory block.
@param memblock Previously allocated memory block to be freed
*/
#define opj_free(m) free(m)
#ifdef __GNUC__
#pragma GCC poison malloc calloc realloc free
#endif
/* ----------------------------------------------------------------------- */
/*@}*/
/*@}*/
#endif /* __OPJ_MALLOC_H */

View File

@@ -413,12 +413,10 @@ opj_pi_iterator_t *pi_create_decode(opj_image_t *image, opj_cp_t *cp, int tileno
opj_pi_iterator_t *pi = NULL;
opj_tcp_t *tcp = NULL;
opj_tccp_t *tccp = NULL;
size_t array_size;
tcp = &cp->tcps[tileno];
array_size = (tcp->numpocs + 1) * sizeof(opj_pi_iterator_t);
pi = (opj_pi_iterator_t *) opj_malloc(array_size);
pi = (opj_pi_iterator_t*) opj_calloc((tcp->numpocs + 1), sizeof(opj_pi_iterator_t));
if(!pi) {
/* TODO: throw an error */
return NULL;
@@ -436,14 +434,12 @@ opj_pi_iterator_t *pi_create_decode(opj_image_t *image, opj_cp_t *cp, int tileno
pi[pino].ty1 = int_min(cp->ty0 + (q + 1) * cp->tdy, image->y1);
pi[pino].numcomps = image->numcomps;
array_size = image->numcomps * sizeof(opj_pi_comp_t);
pi[pino].comps = (opj_pi_comp_t *) opj_malloc(array_size);
pi[pino].comps = (opj_pi_comp_t*) opj_calloc(image->numcomps, sizeof(opj_pi_comp_t));
if(!pi[pino].comps) {
/* TODO: throw an error */
pi_destroy(pi, cp, tileno);
return NULL;
}
memset(pi[pino].comps, 0, array_size);
for (compno = 0; compno < pi->numcomps; compno++) {
int tcx0, tcy0, tcx1, tcy1;
@@ -453,8 +449,7 @@ opj_pi_iterator_t *pi_create_decode(opj_image_t *image, opj_cp_t *cp, int tileno
comp->dy = image->comps[compno].dy;
comp->numresolutions = tccp->numresolutions;
array_size = comp->numresolutions * sizeof(opj_pi_resolution_t);
comp->resolutions = (opj_pi_resolution_t *) opj_malloc(array_size);
comp->resolutions = (opj_pi_resolution_t*) opj_calloc(comp->numresolutions, sizeof(opj_pi_resolution_t));
if(!comp->resolutions) {
/* TODO: throw an error */
pi_destroy(pi, cp, tileno);
@@ -507,8 +502,7 @@ opj_pi_iterator_t *pi_create_decode(opj_image_t *image, opj_cp_t *cp, int tileno
pi[pino].step_l = maxres * pi[pino].step_r;
if (pino == 0) {
array_size = image->numcomps * maxres * tcp->numlayers * maxprec * sizeof(short int);
pi[pino].include = (short int *) opj_malloc(array_size);
pi[pino].include = (short int*) opj_calloc(image->numcomps * maxres * tcp->numlayers * maxprec, sizeof(short int));
if(!pi[pino].include) {
/* TODO: throw an error */
pi_destroy(pi, cp, tileno);
@@ -554,12 +548,10 @@ opj_pi_iterator_t *pi_initialise_encode(opj_image_t *image, opj_cp_t *cp, int ti
opj_pi_iterator_t *pi = NULL;
opj_tcp_t *tcp = NULL;
opj_tccp_t *tccp = NULL;
size_t array_size;
tcp = &cp->tcps[tileno];
array_size = (tcp->numpocs + 1) * sizeof(opj_pi_iterator_t);
pi = (opj_pi_iterator_t *) opj_malloc(array_size);
pi = (opj_pi_iterator_t*) opj_calloc((tcp->numpocs + 1), sizeof(opj_pi_iterator_t));
if(!pi) { return NULL;}
pi->tp_on = cp->tp_on;
@@ -573,13 +565,11 @@ opj_pi_iterator_t *pi_initialise_encode(opj_image_t *image, opj_cp_t *cp, int ti
pi[pino].ty1 = int_min(cp->ty0 + (q + 1) * cp->tdy, image->y1);
pi[pino].numcomps = image->numcomps;
array_size = image->numcomps * sizeof(opj_pi_comp_t);
pi[pino].comps = (opj_pi_comp_t *) opj_malloc(array_size);
pi[pino].comps = (opj_pi_comp_t*) opj_calloc(image->numcomps, sizeof(opj_pi_comp_t));
if(!pi[pino].comps) {
pi_destroy(pi, cp, tileno);
return NULL;
}
memset(pi[pino].comps, 0, array_size);
for (compno = 0; compno < pi[pino].numcomps; compno++) {
int tcx0, tcy0, tcx1, tcy1;
@@ -589,8 +579,7 @@ opj_pi_iterator_t *pi_initialise_encode(opj_image_t *image, opj_cp_t *cp, int ti
comp->dy = image->comps[compno].dy;
comp->numresolutions = tccp->numresolutions;
array_size = comp->numresolutions * sizeof(opj_pi_resolution_t);
comp->resolutions = (opj_pi_resolution_t *) opj_malloc(array_size);
comp->resolutions = (opj_pi_resolution_t*) opj_malloc(comp->numresolutions * sizeof(opj_pi_resolution_t));
if(!comp->resolutions) {
pi_destroy(pi, cp, tileno);
return NULL;
@@ -653,8 +642,7 @@ opj_pi_iterator_t *pi_initialise_encode(opj_image_t *image, opj_cp_t *cp, int ti
}
if (pino == 0) {
array_size = tcp->numlayers * pi[pino].step_l * sizeof(short int);
pi[pino].include = (short int *) opj_malloc(array_size);
pi[pino].include = (short int*) opj_calloc(tcp->numlayers * pi[pino].step_l, sizeof(short int));
if(!pi[pino].include) {
pi_destroy(pi, cp, tileno);
return NULL;
@@ -665,7 +653,7 @@ opj_pi_iterator_t *pi_initialise_encode(opj_image_t *image, opj_cp_t *cp, int ti
}
/* Generation of boundaries for each prog flag*/
if(tcp->POC & (t2_mode == FINAL_PASS)){
if(tcp->POC && ( cp->cinema || ((!cp->cinema) && (t2_mode == FINAL_PASS)))){
tcp->pocs[pino].compS= tcp->pocs[pino].compno0;
tcp->pocs[pino].compE= tcp->pocs[pino].compno1;
tcp->pocs[pino].resS = tcp->pocs[pino].resno0;
@@ -738,100 +726,32 @@ bool pi_next(opj_pi_iterator_t * pi) {
return false;
}
int pi_check_next_level(int pos,opj_cp_t *cp,int tileno, int pino, char *prog){
int i,l;
opj_tcp_t *tcps =&cp->tcps[tileno];
opj_poc_t *tcp = &tcps->pocs[pino];
if(pos>=0){
for(i=pos;pos>=0;i--){
switch(prog[i]){
case 'R':
if(tcp->res_t==tcp->resE){
l=pi_check_next_level(pos-1,cp,tileno,pino,prog);
if(l==1){
return 1;
}else{
return 0;
}
}else{
return 1;
}
break;
case 'C':
if(tcp->comp_t==tcp->compE){
l=pi_check_next_level(pos-1,cp,tileno,pino,prog);
if(l==1){
return 1;
}else{
return 0;
}
}else{
return 1;
}
break;
case 'L':
if(tcp->lay_t==tcp->layE){
l=pi_check_next_level(pos-1,cp,tileno,pino,prog);
if(l==1){
return 1;
}else{
return 0;
}
}else{
return 1;
}
break;
case 'P':
switch(tcp->prg){
case LRCP||RLCP:
if(tcp->prc_t == tcp->prcE){
l=pi_check_next_level(i-1,cp,tileno,pino,prog);
if(l==1){
return 1;
}else{
return 0;
}
}else{
return 1;
}
break;
default:
if(tcp->tx0_t == tcp->txE){
//TY
if(tcp->ty0_t == tcp->tyE){
l=pi_check_next_level(i-1,cp,tileno,pino,prog);
if(l==1){
return 1;
}else{
return 0;
}
}else{
return 1;
}//TY
}else{
return 1;
}
break;
}//end case P
}//end switch
}//end for
}//end if
return 0;
}
void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos){
char *prog;
int i,l;
bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp){
char prog[4];
int i;
int incr_top=1,resetX=0;
opj_tcp_t *tcps =&cp->tcps[tileno];
opj_poc_t *tcp= &tcps->pocs[pino];
prog = j2k_convert_progression_order(tcp->prg);
pi[pino].first = 1;
pi[pino].poc.prg = tcp->prg;
if(!(cp->tp_on)){
switch(tcp->prg){
case CPRL: strncpy(prog, "CPRL",4);
break;
case LRCP: strncpy(prog, "LRCP",4);
break;
case PCRL: strncpy(prog, "PCRL",4);
break;
case RLCP: strncpy(prog, "RLCP",4);
break;
case RPCL: strncpy(prog, "RPCL",4);
break;
case PROG_UNKNOWN:
return true;
}
if(!(cp->tp_on && ((!cp->cinema && (t2_mode == FINAL_PASS)) || cp->cinema))){
pi[pino].poc.resno0 = tcp->resS;
pi[pino].poc.resno1 = tcp->resE;
pi[pino].poc.compno0 = tcp->compS;
@@ -845,69 +765,147 @@ void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,
pi[pino].poc.tx1 = tcp->txE;
pi[pino].poc.ty1 = tcp->tyE;
}else {
for(i=tppos+1;i<4;i++){
if( tpnum < cur_totnum_tp){
for(i=3;i>=0;i--){
switch(prog[i]){
case 'R':
pi[pino].poc.resno0 = tcp->resS;
pi[pino].poc.resno1 = tcp->resE;
break;
case 'C':
if (i > tppos){
pi[pino].poc.compno0 = tcp->compS;
pi[pino].poc.compno1 = tcp->compE;
break;
case 'L':
pi[pino].poc.layno0 = tcp->layS;
pi[pino].poc.layno1 = tcp->layE;
break;
case 'P':
switch(tcp->prg){
case LRCP:
case RLCP:
pi[pino].poc.precno0 = tcp->prcS;
pi[pino].poc.precno1 = tcp->prcE;
break;
default:
pi[pino].poc.tx0 = tcp->txS;
pi[pino].poc.ty0 = tcp->tyS;
pi[pino].poc.tx1 = tcp->txE;
pi[pino].poc.ty1 = tcp->tyE;
break;
}
break;
}
}
}else{
if (tpnum == 0){
for(i=tppos;i>=0;i--){
switch(prog[i]){
case 'C':
tcp->comp_t = tcp->compS;
pi[pino].poc.compno0 = tcp->comp_t;
pi[pino].poc.compno1 = tcp->comp_t+1;
tcp->comp_t+=1;
}else{
if (incr_top == 1){
if(tcp->comp_t ==tcp->compE){
tcp->comp_t = tcp->compS;
pi[pino].poc.compno0 = tcp->comp_t;
pi[pino].poc.compno1 = tcp->comp_t+1;
tcp->comp_t+=1;
incr_top=1;
}else{
pi[pino].poc.compno0 = tcp->comp_t;
pi[pino].poc.compno1 = tcp->comp_t+1;
tcp->comp_t+=1;
incr_top=0;
}
}else{
pi[pino].poc.compno0 = tcp->comp_t-1;
pi[pino].poc.compno1 = tcp->comp_t;
}
}
}
break;
case 'R':
if (i > tppos){
pi[pino].poc.resno0 = tcp->resS;
pi[pino].poc.resno1 = tcp->resE;
}else{
if (tpnum == 0){
tcp->res_t = tcp->resS;
pi[pino].poc.resno0 = tcp->res_t;
pi[pino].poc.resno1 = tcp->res_t+1;
tcp->res_t+=1;
}else{
if (incr_top == 1){
if(tcp->res_t==tcp->resE){
tcp->res_t = tcp->resS;
pi[pino].poc.resno0 = tcp->res_t;
pi[pino].poc.resno1 = tcp->res_t+1;
tcp->res_t+=1;
incr_top=1;
}else{
pi[pino].poc.resno0 = tcp->res_t;
pi[pino].poc.resno1 = tcp->res_t+1;
tcp->res_t+=1;
incr_top=0;
}
}else{
pi[pino].poc.resno0 = tcp->res_t - 1;
pi[pino].poc.resno1 = tcp->res_t;
}
}
}
break;
case 'L':
if (i > tppos){
pi[pino].poc.layno0 = tcp->layS;
pi[pino].poc.layno1 = tcp->layE;
}else{
if (tpnum == 0){
tcp->lay_t = tcp->layS;
pi[pino].poc.layno0 = tcp->lay_t;
pi[pino].poc.layno1 = tcp->lay_t+1;
tcp->lay_t+=1;
}else{
if (incr_top == 1){
if(tcp->lay_t == tcp->layE){
tcp->lay_t = tcp->layS;
pi[pino].poc.layno0 = tcp->lay_t;
pi[pino].poc.layno1 = tcp->lay_t+1;
tcp->lay_t+=1;
incr_top=1;
}else{
pi[pino].poc.layno0 = tcp->lay_t;
pi[pino].poc.layno1 = tcp->lay_t+1;
tcp->lay_t+=1;
incr_top=0;
}
}else{
pi[pino].poc.layno0 = tcp->lay_t - 1;
pi[pino].poc.layno1 = tcp->lay_t;
}
}
}
break;
case 'P':
switch(tcp->prg){
case LRCP:
case RLCP:
if (i > tppos){
pi[pino].poc.precno0 = tcp->prcS;
pi[pino].poc.precno1 = tcp->prcE;
}else{
if (tpnum == 0){
tcp->prc_t = tcp->prcS;
pi[pino].poc.precno0 = tcp->prc_t;
pi[pino].poc.precno1 = tcp->prc_t+1;
tcp->prc_t+=1;
}else{
if (incr_top == 1){
if(tcp->prc_t == tcp->prcE){
tcp->prc_t = tcp->prcS;
pi[pino].poc.precno0 = tcp->prc_t;
pi[pino].poc.precno1 = tcp->prc_t+1;
tcp->prc_t+=1;
incr_top=1;
}else{
pi[pino].poc.precno0 = tcp->prc_t;
pi[pino].poc.precno1 = tcp->prc_t+1;
tcp->prc_t+=1;
incr_top=0;
}
}else{
pi[pino].poc.precno0 = tcp->prc_t - 1;
pi[pino].poc.precno1 = tcp->prc_t;
}
}
}
break;
default:
if (i > tppos){
pi[pino].poc.tx0 = tcp->txS;
pi[pino].poc.ty0 = tcp->tyS;
pi[pino].poc.tx1 = tcp->txE;
pi[pino].poc.ty1 = tcp->tyE;
}else{
if (tpnum == 0){
tcp->tx0_t = tcp->txS;
tcp->ty0_t = tcp->tyS;
pi[pino].poc.tx0 = tcp->tx0_t;
@@ -916,137 +914,15 @@ void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,
pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
tcp->tx0_t = pi[pino].poc.tx1;
tcp->ty0_t = pi[pino].poc.ty1;
break;
}
break;
}
}
incr_top=1;
}else{
for(i=tppos;i>=0;i--){
switch(prog[i]){
case 'C':
pi[pino].poc.compno0 = tcp->comp_t-1;
pi[pino].poc.compno1 = tcp->comp_t;
break;
case 'R':
pi[pino].poc.resno0 = tcp->res_t-1;
pi[pino].poc.resno1 = tcp->res_t;
break;
case 'L':
pi[pino].poc.layno0 = tcp->lay_t-1;
pi[pino].poc.layno1 = tcp->lay_t;
break;
case 'P':
switch(tcp->prg){
case LRCP:
case RLCP:
pi[pino].poc.precno0 = tcp->prc_t-1;
pi[pino].poc.precno1 = tcp->prc_t;
break;
default:
pi[pino].poc.tx0 = tcp->tx0_t - tcp->dx - (tcp->tx0_t % tcp->dx);
pi[pino].poc.tx1 = tcp->tx0_t ;
pi[pino].poc.ty0 = tcp->ty0_t - tcp->dy - (tcp->ty0_t % tcp->dy);
pi[pino].poc.ty1 = tcp->ty0_t ;
break;
}
break;
}
if (incr_top == 1){
switch(prog[i]){
case 'R':
if(tcp->res_t==tcp->resE){
l=pi_check_next_level(i-1,cp,tileno,pino,prog);
if(l==1){
tcp->res_t = tcp->resS;
pi[pino].poc.resno0 = tcp->res_t;
pi[pino].poc.resno1 = tcp->res_t+1;
tcp->res_t+=1;
incr_top=1;
}else{
incr_top=0;
}
}else{
pi[pino].poc.resno0 = tcp->res_t;
pi[pino].poc.resno1 = tcp->res_t+1;
tcp->res_t+=1;
incr_top=0;
}
break;
case 'C':
if(tcp->comp_t ==tcp->compE){
l=pi_check_next_level(i-1,cp,tileno,pino,prog);
if(l==1){
tcp->comp_t = tcp->compS;
pi[pino].poc.compno0 = tcp->comp_t;
pi[pino].poc.compno1 = tcp->comp_t+1;
tcp->comp_t+=1;
incr_top=1;
}else{
incr_top=0;
}
}else{
pi[pino].poc.compno0 = tcp->comp_t;
pi[pino].poc.compno1 = tcp->comp_t+1;
tcp->comp_t+=1;
incr_top=0;
}
break;
case 'L':
if(tcp->lay_t == tcp->layE){
l=pi_check_next_level(i-1,cp,tileno,pino,prog);
if(l==1){
tcp->lay_t = tcp->layS;
pi[pino].poc.layno0 = tcp->lay_t;
pi[pino].poc.layno1 = tcp->lay_t+1;
tcp->lay_t+=1;
incr_top=1;
}else{
incr_top=0;
}
}else{
pi[pino].poc.layno0 = tcp->lay_t;
pi[pino].poc.layno1 = tcp->lay_t+1;
tcp->lay_t+=1;
incr_top=0;
}
break;
case 'P':
switch(tcp->prg){
case LRCP:
case RLCP:
if(tcp->prc_t == tcp->prcE){
l=pi_check_next_level(i-1,cp,tileno,pino,prog);
if(l==1){
tcp->prc_t = tcp->prcS;
pi[pino].poc.precno0 = tcp->prc_t;
pi[pino].poc.precno1 = tcp->prc_t+1;
tcp->prc_t+=1;
incr_top=1;
}else{
incr_top=0;
}
}else{
pi[pino].poc.precno0 = tcp->prc_t;
pi[pino].poc.precno1 = tcp->prc_t+1;
tcp->prc_t+=1;
incr_top=0;
}
break;
default:
if(tcp->tx0_t >= tcp->txE){
if(tcp->ty0_t >= tcp->tyE){
l=pi_check_next_level(i-1,cp,tileno,pino,prog);
if(l==1){
tcp->ty0_t = tcp->tyS;
pi[pino].poc.ty0 = tcp->ty0_t;
pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
tcp->ty0_t = pi[pino].poc.ty1;
incr_top=1;resetX=1;
}else{
incr_top=0;resetX=0;
}
}else{
pi[pino].poc.ty0 = tcp->ty0_t;
pi[pino].poc.ty1 = tcp->ty0_t + tcp->dy - (tcp->ty0_t % tcp->dy);
@@ -1063,8 +939,18 @@ void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,
pi[pino].poc.tx0 = tcp->tx0_t;
pi[pino].poc.tx1 = tcp->tx0_t + tcp->dx- (tcp->tx0_t % tcp->dx);
tcp->tx0_t = pi[pino].poc.tx1;
pi[pino].poc.ty0 = tcp->ty0_t - tcp->dy - (tcp->ty0_t % tcp->dy);
pi[pino].poc.ty1 = tcp->ty0_t ;
incr_top=0;
}
}else{
pi[pino].poc.tx0 = tcp->tx0_t - tcp->dx - (tcp->tx0_t % tcp->dx);
pi[pino].poc.tx1 = tcp->tx0_t ;
pi[pino].poc.ty0 = tcp->ty0_t - tcp->dy - (tcp->ty0_t % tcp->dy);
pi[pino].poc.ty1 = tcp->ty0_t ;
}
}
}
break;
}
break;
@@ -1072,7 +958,6 @@ void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,
}
}
}
}
return false;
}

View File

@@ -117,8 +117,10 @@ Modify the packet iterator for enabling tile part generation
@param tileno Number that identifies the tile for which to list the packets
@param tpnum Tile part number of the current tile
@param tppos The position of the tile part flag in the progression order
@param cur_totnum_tp The total number of tile parts in the current tile
@return Returns true if an error is detected
*/
void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos);
bool pi_create_encode(opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp);
/**
Create a packet iterator for Decoder
@param image Raw image for which the packets will be listed

View File

@@ -42,7 +42,7 @@
==========================================================
*/
opj_raw_t* raw_create() {
opj_raw_t* raw_create(void) {
opj_raw_t *raw = (opj_raw_t*)opj_malloc(sizeof(opj_raw_t));
return raw;
}

View File

@@ -67,7 +67,7 @@ typedef struct opj_raw {
Create a new RAW handle
@return Returns a new RAW handle if successful, returns NULL otherwise
*/
opj_raw_t* raw_create();
opj_raw_t* raw_create(void);
/**
Destroy a previously created RAW handle
@param raw RAW handle to destroy

View File

@@ -39,9 +39,9 @@
/** @name Local static functions */
/*@{*/
static char t1_getctxno_zc(int f, int orient);
static INLINE char t1_getctxno_zc(int f, int orient);
static char t1_getctxno_sc(int f);
static char t1_getctxno_mag(int f);
static INLINE int t1_getctxno_mag(int f);
static char t1_getspb(int f);
static short t1_getnmsedec_sig(int x, int bitpos);
static short t1_getnmsedec_ref(int x, int bitpos);
@@ -194,7 +194,7 @@ Encode 1 code-block
*/
static void t1_encode_cblk(
opj_t1_t *t1,
opj_tcd_cblk_t * cblk,
opj_tcd_cblk_enc_t* cblk,
int orient,
int compno,
int level,
@@ -213,7 +213,7 @@ Decode 1 code-block
*/
static void t1_decode_cblk(
opj_t1_t *t1,
opj_tcd_cblk_t * cblk,
opj_tcd_cblk_dec_t* cblk,
int orient,
int roishift,
int cblksty);
@@ -232,8 +232,10 @@ static char t1_getctxno_sc(int f) {
return lut_ctxno_sc[(f & (T1_SIG_PRIM | T1_SGN)) >> 4];
}
static char t1_getctxno_mag(int f) {
return lut_ctxno_mag[(f & T1_SIG_OTH) | (((f & T1_REFINE) != 0) << 11)];
static int t1_getctxno_mag(int f) {
int tmp1 = (f & T1_SIG_OTH) ? T1_CTXNO_MAG + 1 : T1_CTXNO_MAG;
int tmp2 = (f & T1_REFINE) ? T1_CTXNO_MAG + 2 : tmp1;
return (tmp2);
}
static char t1_getspb(int f) {
@@ -261,21 +263,22 @@ static void t1_updateflags(flag_t *flagsp, int s, int stride) {
flag_t *sp = flagsp + stride;
static const flag_t mod[] = {
T1_SIG_S, T1_SIG_N, T1_SIG_E, T1_SIG_W,
T1_SIG_S | T1_SGN_S, T1_SIG_N | T1_SGN_N, T1_SIG_E | T1_SGN_E, T1_SIG_W | T1_SGN_W
T1_SIG_S, T1_SIG_S|T1_SGN_S,
T1_SIG_E, T1_SIG_E|T1_SGN_E,
T1_SIG_W, T1_SIG_W|T1_SGN_W,
T1_SIG_N, T1_SIG_N|T1_SGN_N
};
s <<= 2;
np[-1] |= T1_SIG_SE;
np[0] |= mod[s];
np[1] |= T1_SIG_SW;
flagsp[-1] |= mod[s+2];
flagsp[1] |= mod[s+3];
flagsp[0] |= T1_SIG;
flagsp[1] |= mod[s+4];
sp[-1] |= T1_SIG_NE;
sp[0] |= mod[s+1];
sp[0] |= mod[s+6];
sp[1] |= T1_SIG_NW;
}
@@ -297,25 +300,22 @@ static void t1_enc_sigpass_step(
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
v = int_abs(*datap) & one ? 1 : 0;
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient)); /* ESSAI */
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
mqc_bypass_enc(mqc, v);
} else {
mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient));
mqc_encode(mqc, v);
}
if (v) {
v = *datap < 0 ? 1 : 0;
*nmsedec += t1_getnmsedec_sig(int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
mqc_setcurctx(mqc, t1_getctxno_sc(flag)); /* ESSAI */
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
mqc_bypass_enc(mqc, v);
} else {
mqc_setcurctx(mqc, t1_getctxno_sc(flag));
mqc_encode(mqc, v ^ t1_getspb(flag));
}
t1_updateflags(flagsp, v, t1->flags_stride);
*flagsp |= T1_SIG;
}
*flagsp |= T1_VISIT;
}
@@ -342,7 +342,6 @@ static void t1_dec_sigpass_step(
v = raw_decode(raw); /* ESSAI */
*datap = v ? -oneplushalf : oneplushalf;
t1_updateflags(flagsp, v, t1->flags_stride);
*flagsp |= T1_SIG;
}
} else {
mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient));
@@ -351,7 +350,6 @@ static void t1_dec_sigpass_step(
v = mqc_decode(mqc) ^ t1_getspb(flag);
*datap = v ? -oneplushalf : oneplushalf;
t1_updateflags(flagsp, v, t1->flags_stride);
*flagsp |= T1_SIG;
}
}
*flagsp |= T1_VISIT;
@@ -434,11 +432,10 @@ static void t1_enc_refpass_step(
if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
*nmsedec += t1_getnmsedec_ref(int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
v = int_abs(*datap) & one ? 1 : 0;
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
mqc_setcurctx(mqc, t1_getctxno_mag(flag)); /* ESSAI */
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
mqc_bypass_enc(mqc, v);
} else {
mqc_setcurctx(mqc, t1_getctxno_mag(flag));
mqc_encode(mqc, v);
}
*flagsp |= T1_REFINE;
@@ -461,11 +458,10 @@ static void t1_dec_refpass_step(
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
if (type == T1_TYPE_RAW) {
mqc_setcurctx(mqc, t1_getctxno_mag(flag)); /* ESSAI */
if (type == T1_TYPE_RAW) {
v = raw_decode(raw);
} else {
mqc_setcurctx(mqc, t1_getctxno_mag(flag));
v = mqc_decode(mqc);
}
t = v ? poshalf : neghalf;
@@ -560,7 +556,6 @@ LABEL_PARTIAL:
v = *datap < 0 ? 1 : 0;
mqc_encode(mqc, v ^ t1_getspb(flag));
t1_updateflags(flagsp, v, t1->flags_stride);
*flagsp |= T1_SIG;
}
}
*flagsp &= ~T1_VISIT;
@@ -591,7 +586,6 @@ LABEL_PARTIAL:
v = mqc_decode(mqc) ^ t1_getspb(flag);
*datap = v ? -oneplushalf : oneplushalf;
t1_updateflags(flagsp, v, t1->flags_stride);
*flagsp |= T1_SIG;
}
}
*flagsp &= ~T1_VISIT;
@@ -758,53 +752,47 @@ static double t1_getwmsedec(
return wmsedec;
}
static void allocate_buffers(
static bool allocate_buffers(
opj_t1_t *t1,
int w,
int h)
{
int datasize;
int datasize=w * h;
int flagssize;
datasize=w * h;
//fprintf(stderr,"w=%i h=%i datasize=%i flagssize=%i\n",w,h,datasize,flagssize);
if(datasize > t1->datasize){
//fprintf(stderr,"Allocating t1->data: datasize=%i\n",datasize);
free(t1->data);
t1->data=malloc(datasize * sizeof(int));
opj_aligned_free(t1->data);
t1->data = (int*) opj_aligned_malloc(datasize * sizeof(int));
if(!t1->data){
return;
return false;
}
t1->datasize=datasize;
}
//memset(t1->data,0xff,t1->datasize);
memset(t1->data,0,datasize * sizeof(int));
t1->flags_stride=w+2;
flagssize=t1->flags_stride * (h+2);
if(flagssize > t1->flagssize){
//fprintf(stderr,"Allocating t1->flags: flagssize=%i\n",flagssize);
free(t1->flags);
t1->flags=malloc(flagssize * sizeof(flag_t));
opj_aligned_free(t1->flags);
t1->flags = (flag_t*) opj_aligned_malloc(flagssize * sizeof(flag_t));
if(!t1->flags){
fprintf(stderr,"Allocating t1->flags FAILED!\n");
return;
return false;
}
t1->flagssize=flagssize;
}
//memset(t1->flags,0xff,t1->flagssize);
memset(t1->flags,0,flagssize * sizeof(flag_t));
t1->w=w;
t1->h=h;
return true;
}
/** mod fixed_quality */
static void t1_encode_cblk(
opj_t1_t *t1,
opj_tcd_cblk_t * cblk,
opj_tcd_cblk_enc_t* cblk,
int orient,
int compno,
int level,
@@ -814,21 +802,20 @@ static void t1_encode_cblk(
int numcomps,
opj_tcd_tile_t * tile)
{
int i, j;
int passno;
int bpno, passtype;
int max;
int nmsedec = 0;
double cumwmsedec = 0.0;
char type = T1_TYPE_MQ;
opj_mqc_t *mqc = t1->mqc; /* MQC component */
int passno, bpno, passtype;
int nmsedec = 0;
int i, max;
char type = T1_TYPE_MQ;
double tempwmsedec;
max = 0;
for (j = 0; j < t1->h; ++j) {
for (i = 0; i < t1->w; ++i) {
max = int_max(max, int_abs(t1->data[(j * t1->w) + i]));
}
for (i = 0; i < t1->w * t1->h; ++i) {
int tmp = abs(t1->data[i]);
max = int_max(max, tmp);
}
cblk->numbps = max ? (int_floorlog2(max) + 1) - T1_NMSEDEC_FRACBITS : 0;
@@ -863,8 +850,9 @@ static void t1_encode_cblk(
}
/* fixed_quality */
cumwmsedec += t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid, stepsize, numcomps);
tile->distotile += t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid, stepsize, numcomps);
tempwmsedec = t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid, stepsize, numcomps);
cumwmsedec += tempwmsedec;
tile->distotile += tempwmsedec;
/* Code switch "RESTART" (i.e. TERMALL) */
if ((cblksty & J2K_CCP_CBLKSTY_TERMALL) && !((passtype == 2) && (bpno - 1 < 0))) {
@@ -937,22 +925,25 @@ static void t1_encode_cblk(
static void t1_decode_cblk(
opj_t1_t *t1,
opj_tcd_cblk_t * cblk,
opj_tcd_cblk_dec_t* cblk,
int orient,
int roishift,
int cblksty)
{
opj_raw_t *raw = t1->raw; /* RAW component */
opj_mqc_t *mqc = t1->mqc; /* MQC component */
int bpno, passtype;
int segno, passno;
char type = T1_TYPE_MQ; /* BYPASS mode */
opj_raw_t *raw = t1->raw; /* RAW component */
opj_mqc_t *mqc = t1->mqc; /* MQC component */
allocate_buffers(
if(!allocate_buffers(
t1,
cblk->x1 - cblk->x0,
cblk->y1 - cblk->y0);
cblk->y1 - cblk->y0))
{
return;
}
bpno = roishift + cblk->numbps - 1;
passtype = 2;
@@ -967,10 +958,14 @@ static void t1_decode_cblk(
/* BYPASS mode */
type = ((bpno <= (cblk->numbps - 1) - 4) && (passtype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
/* FIXME: slviewer gets here with a null pointer. Why? Partially downloaded and/or corrupt textures? */
if(seg->data == NULL){
continue;
}
if (type == T1_TYPE_RAW) {
raw_init_dec(raw, seg->data, seg->len);
raw_init_dec(raw, (*seg->data) + seg->dataindex, seg->len);
} else {
mqc_init_dec(mqc, seg->data, seg->len);
mqc_init_dec(mqc, (*seg->data) + seg->dataindex, seg->len);
}
for (passno = 0; passno < seg->numpasses; ++passno) {
@@ -1003,7 +998,7 @@ static void t1_decode_cblk(
/* ----------------------------------------------------------------------- */
opj_t1_t* t1_create(opj_common_ptr cinfo) {
opj_t1_t *t1 = (opj_t1_t*) malloc(sizeof(opj_t1_t));
opj_t1_t *t1 = (opj_t1_t*) opj_malloc(sizeof(opj_t1_t));
if(!t1)
return NULL;
@@ -1012,10 +1007,10 @@ opj_t1_t* t1_create(opj_common_ptr cinfo) {
t1->mqc = mqc_create();
t1->raw = raw_create();
t1->datasize=0;
t1->data=NULL;
t1->flagssize=0;
t1->flags=NULL;
t1->datasize=0;
t1->flagssize=0;
return t1;
}
@@ -1025,9 +1020,9 @@ void t1_destroy(opj_t1_t *t1) {
/* destroy MQC and RAW handles */
mqc_destroy(t1->mqc);
raw_destroy(t1->raw);
free(t1->data);
free(t1->flags);
free(t1);
opj_aligned_free(t1->data);
opj_aligned_free(t1->flags);
opj_free(t1);
}
}
@@ -1042,22 +1037,28 @@ void t1_encode_cblks(
for (compno = 0; compno < tile->numcomps; ++compno) {
opj_tcd_tilecomp_t* tilec = &tile->comps[compno];
opj_tccp_t* tccp = &tcp->tccps[compno];
int tile_w = tilec->x1 - tilec->x0;
for (resno = 0; resno < tilec->numresolutions; ++resno) {
opj_tcd_resolution_t *res = &tilec->resolutions[resno];
for (bandno = 0; bandno < res->numbands; ++bandno) {
opj_tcd_band_t *band = &res->bands[bandno];
opj_tcd_band_t* restrict band = &res->bands[bandno];
for (precno = 0; precno < res->pw * res->ph; ++precno) {
opj_tcd_precinct_t *prc = &band->precincts[precno];
for (cblkno = 0; cblkno < prc->cw * prc->ch; ++cblkno) {
int x, y, w, i, j, orient;
opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
int* restrict datap;
int* restrict tiledp;
int cblk_w;
int cblk_h;
int i, j;
x = cblk->x0 - band->x0;
y = cblk->y0 - band->y0;
int x = cblk->x0 - band->x0;
int y = cblk->y0 - band->y0;
if (band->bandno & 1) {
opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
x += pres->x1 - pres->x0;
@@ -1067,45 +1068,47 @@ void t1_encode_cblks(
y += pres->y1 - pres->y0;
}
allocate_buffers(
if(!allocate_buffers(
t1,
cblk->x1 - cblk->x0,
cblk->y1 - cblk->y0);
cblk->y1 - cblk->y0))
{
return;
}
w = tilec->x1 - tilec->x0;
if (tcp->tccps[compno].qmfbid == 1) {
for (j = 0; j < t1->h; ++j) {
for (i = 0; i < t1->w; ++i) {
t1->data[(j * t1->w) + i] =
tilec->data[(x + i) + (y + j) * w] << T1_NMSEDEC_FRACBITS;
datap=t1->data;
cblk_w = t1->w;
cblk_h = t1->h;
tiledp=&tilec->data[(y * tile_w) + x];
if (tccp->qmfbid == 1) {
for (j = 0; j < cblk_h; ++j) {
for (i = 0; i < cblk_w; ++i) {
int tmp = tiledp[(j * tile_w) + i];
datap[(j * cblk_w) + i] = tmp << T1_NMSEDEC_FRACBITS;
}
}
} else { /* if (tcp->tccps[compno].qmfbid == 0) */
for (j = 0; j < t1->h; ++j) {
for (i = 0; i < t1->w; ++i) {
t1->data[(j * t1->w) + i] =
} else { /* if (tccp->qmfbid == 0) */
for (j = 0; j < cblk_h; ++j) {
for (i = 0; i < cblk_w; ++i) {
int tmp = tiledp[(j * tile_w) + i];
datap[(j * cblk_w) + i] =
fix_mul(
tilec->data[x + i + (y + j) * w],
tmp,
8192 * 8192 / ((int) floor(band->stepsize * 8192))) >> (11 - T1_NMSEDEC_FRACBITS);
}
}
}
orient = band->bandno; /* FIXME */
if (orient == 2) {
orient = 1;
} else if (orient == 1) {
orient = 2;
}
t1_encode_cblk(
t1,
cblk,
orient,
band->bandno,
compno,
tilec->numresolutions - 1 - resno,
tcp->tccps[compno].qmfbid,
tccp->qmfbid,
band->stepsize,
tcp->tccps[compno].cblksty,
tccp->cblksty,
tile->numcomps,
tile);
@@ -1118,40 +1121,36 @@ void t1_encode_cblks(
void t1_decode_cblks(
opj_t1_t* t1,
opj_tcd_tile_t *tile,
opj_tcp_t *tcp)
opj_tcd_tilecomp_t* tilec,
opj_tccp_t* tccp)
{
int compno, resno, bandno, precno, cblkno;
int resno, bandno, precno, cblkno;
for (compno = 0; compno < tile->numcomps; ++compno) {
opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
int tile_w = tilec->x1 - tilec->x0;
for (resno = 0; resno < tilec->numresolutions; ++resno) {
opj_tcd_resolution_t* res = &tilec->resolutions[resno];
for (bandno = 0; bandno < res->numbands; ++bandno) {
opj_tcd_band_t *band = &res->bands[bandno];
opj_tcd_band_t* restrict band = &res->bands[bandno];
for (precno = 0; precno < res->pw * res->ph; ++precno) {
opj_tcd_precinct_t *prc = &band->precincts[precno];
opj_tcd_precinct_t* precinct = &band->precincts[precno];
for (cblkno = 0; cblkno < prc->cw * prc->ch; ++cblkno) {
int x, y, w, i, j, orient, cblk_w, cblk_h;
opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
orient = band->bandno; /* FIXME */
if (orient == 2) {
orient = 1;
} else if (orient == 1) {
orient = 2;
}
for (cblkno = 0; cblkno < precinct->cw * precinct->ch; ++cblkno) {
opj_tcd_cblk_dec_t* cblk = &precinct->cblks.dec[cblkno];
int* restrict datap;
void* restrict tiledp;
int cblk_w, cblk_h;
int x, y;
int i, j;
t1_decode_cblk(
t1,
cblk,
orient,
tcp->tccps[compno].roishift,
tcp->tccps[compno].cblksty);
band->bandno,
tccp->roishift,
tccp->cblksty);
x = cblk->x0 - band->x0;
y = cblk->y0 - band->y0;
@@ -1164,47 +1163,46 @@ void t1_decode_cblks(
y += pres->y1 - pres->y0;
}
cblk_w = cblk->x1 - cblk->x0;
cblk_h = cblk->y1 - cblk->y0;
datap=t1->data;
cblk_w = t1->w;
cblk_h = t1->h;
if (tcp->tccps[compno].roishift) {
int thresh = 1 << tcp->tccps[compno].roishift;
if (tccp->roishift) {
int thresh = 1 << tccp->roishift;
for (j = 0; j < cblk_h; ++j) {
for (i = 0; i < cblk_w; ++i) {
int val = t1->data[(j * t1->w) + i];
int mag = int_abs(val);
int val = datap[(j * cblk_w) + i];
int mag = abs(val);
if (mag >= thresh) {
mag >>= tcp->tccps[compno].roishift;
t1->data[(j * t1->w) + i] = val < 0 ? -mag : mag;
mag >>= tccp->roishift;
datap[(j * cblk_w) + i] = val < 0 ? -mag : mag;
}
}
}
}
w = tilec->x1 - tilec->x0;
if (tcp->tccps[compno].qmfbid == 1) {
tiledp=(void*)&tilec->data[(y * tile_w) + x];
if (tccp->qmfbid == 1) {
for (j = 0; j < cblk_h; ++j) {
for (i = 0; i < cblk_w; ++i) {
tilec->data[x + i + (y + j) * w] = t1->data[(j * t1->w) + i]/2;
int tmp = datap[(j * cblk_w) + i];
((int*)tiledp)[(j * tile_w) + i] = tmp / 2;
}
}
} else { /* if (tcp->tccps[compno].qmfbid == 0) */
} else { /* if (tccp->qmfbid == 0) */
for (j = 0; j < cblk_h; ++j) {
for (i = 0; i < cblk_w; ++i) {
if (t1->data[(j * t1->w) + i] >> 1 == 0) {
tilec->data[x + i + (y + j) * w] = 0;
} else {
double tmp = (double)(t1->data[(j * t1->w) + i] * band->stepsize * 4096.0);
int tmp2 = ((int) (floor(fabs(tmp)))) + ((int) floor(fabs(tmp*2))%2);
tilec->data[x + i + (y + j) * w] = ((tmp<0)?-tmp2:tmp2);
}
float tmp = datap[(j * cblk_w) + i] * band->stepsize;
((float*)tiledp)[(j * tile_w) + i] = tmp;
}
}
}
opj_free(cblk->data);
opj_free(cblk->segs);
} /* cblkno */
opj_free(precinct->cblks.dec);
} /* precno */
} /* bandno */
} /* resno */
} /* compno */
}

View File

@@ -138,7 +138,7 @@ Decode the code-blocks of a tile
@param tile The tile to decode
@param tcp Tile coding parameters
*/
void t1_decode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp);
void t1_decode_cblks(opj_t1_t* t1, opj_tcd_tilecomp_t* tilec, opj_tccp_t* tccp);
/* ----------------------------------------------------------------------- */
/*@}*/

View File

@@ -146,16 +146,6 @@ static int t1_init_ctxno_sc(int f) {
return (T1_CTXNO_SC + n);
}
static int t1_init_ctxno_mag(int f) {
int n;
if (!(f & T1_REFINE))
n = (f & (T1_SIG_OTH)) ? 1 : 0;
else
n = 2;
return (T1_CTXNO_MAG + n);
}
static int t1_init_spb(int f) {
int hc, vc, n;
@@ -197,7 +187,6 @@ int main(){
double u, v, t;
int lut_ctxno_zc[1024];
int lut_ctxno_mag[4096];
int lut_nmsedec_sig[1 << T1_NMSEDEC_BITS];
int lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS];
int lut_nmsedec_ref[1 << T1_NMSEDEC_BITS];
@@ -208,11 +197,17 @@ int main(){
// lut_ctxno_zc
for (j = 0; j < 4; ++j) {
for (i = 0; i < 256; ++i) {
lut_ctxno_zc[(j << 8) | i] = t1_init_ctxno_zc(i, j);
int orient = j;
if (orient == 2) {
orient = 1;
} else if (orient == 1) {
orient = 2;
}
lut_ctxno_zc[(orient << 8) | i] = t1_init_ctxno_zc(i, j);
}
}
printf("static int8_t lut_ctxno_zc[1024] = {\n ");
printf("static char lut_ctxno_zc[1024] = {\n ");
for (i = 0; i < 1023; ++i) {
printf("%i, ", lut_ctxno_zc[i]);
if(!((i+1)&0x1f))
@@ -221,7 +216,7 @@ int main(){
printf("%i\n};\n\n", lut_ctxno_zc[1023]);
// lut_ctxno_sc
printf("static int8_t lut_ctxno_sc[256] = {\n ");
printf("static char lut_ctxno_sc[256] = {\n ");
for (i = 0; i < 255; ++i) {
printf("0x%x, ", t1_init_ctxno_sc(i << 4));
if(!((i+1)&0xf))
@@ -229,23 +224,8 @@ int main(){
}
printf("0x%x\n};\n\n", t1_init_ctxno_sc(255 << 4));
// lut_ctxno_mag
for (j = 0; j < 2; ++j) {
for (i = 0; i < 2048; ++i) {
lut_ctxno_mag[(j << 11) + i] = t1_init_ctxno_mag((j ? T1_REFINE : 0) | i);
}
}
printf("static int8_t lut_ctxno_mag[4096] = {\n ");
for (i = 0; i < 4095; ++i) {
printf("%i, ", lut_ctxno_mag[i]);
if(!((i+1)&0xf))
printf("\n ");
}
printf("%i\n};\n\n", lut_ctxno_mag[4095]);
// lut_spb
printf("static int8_t lut_spb[256] = {\n ");
printf("static char lut_spb[256] = {\n ");
for (i = 0; i < 255; ++i) {
printf("%i, ", t1_init_spb(i << 4));
if(!((i+1)&0x1f))
@@ -279,16 +259,16 @@ int main(){
(int) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
}
printf("static int16_t lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {\n ");
printf("static short lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {\n ");
dump_array16(&lut_nmsedec_sig, 1 << T1_NMSEDEC_BITS);
printf("static int16_t lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {\n ");
printf("static short lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {\n ");
dump_array16(&lut_nmsedec_sig0, 1 << T1_NMSEDEC_BITS);
printf("static int16_t lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {\n ");
printf("static short lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {\n ");
dump_array16(&lut_nmsedec_ref, 1 << T1_NMSEDEC_BITS);
printf("static int16_t lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {\n ");
printf("static short lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {\n ");
dump_array16(&lut_nmsedec_ref0, 1 << T1_NMSEDEC_BITS);
return 0;

Some files were not shown because too many files have changed in this diff Show More