Compare commits
60 Commits
openjpeg-1
...
v2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6cb0c86e2 | ||
|
|
a937c91694 | ||
|
|
c49becae30 | ||
|
|
9e0e3611c5 | ||
|
|
9fba123a7a | ||
|
|
fef7d00dc8 | ||
|
|
a916dcd052 | ||
|
|
cc01949777 | ||
|
|
287be4e683 | ||
|
|
dea5c48227 | ||
|
|
68e1771ae5 | ||
|
|
6ab100903e | ||
|
|
3e5715a994 | ||
|
|
9f446c88e8 | ||
|
|
2f9e80da9c | ||
|
|
871cd3968f | ||
|
|
e5bfc65137 | ||
|
|
315179c719 | ||
|
|
cab60a170d | ||
|
|
889aa9227b | ||
|
|
8dcd3318c2 | ||
|
|
f71e6e7879 | ||
|
|
3a44c91ea3 | ||
|
|
786dee8782 | ||
|
|
5badc82fa9 | ||
|
|
ecd70f033c | ||
|
|
0c69d6e1a8 | ||
|
|
306e58761a | ||
|
|
eb1baa78fc | ||
|
|
414b680e53 | ||
|
|
b1342da5c5 | ||
|
|
27850206b5 | ||
|
|
5bffbfc638 | ||
|
|
49f47e2b00 | ||
|
|
1f348833dd | ||
|
|
f509865242 | ||
|
|
173ad641aa | ||
|
|
3b28bfcb3c | ||
|
|
04c131a315 | ||
|
|
40c092bbc3 | ||
|
|
576f380eba | ||
|
|
8a634d0fe3 | ||
|
|
f9e6b81176 | ||
|
|
a346da0599 | ||
|
|
b2d22d6bc0 | ||
|
|
73b4d32638 | ||
|
|
67b5ab3c04 | ||
|
|
935baae8fc | ||
|
|
324c949cfd | ||
|
|
dc9459029f | ||
|
|
ca3f19c7e3 | ||
|
|
5238a26db5 | ||
|
|
ec400c4fa5 | ||
|
|
b1d8788a46 | ||
|
|
1915409c92 | ||
|
|
c5ec4896fe | ||
|
|
fcede9f913 | ||
|
|
46c3dc4bdf | ||
|
|
7caaea18b7 | ||
|
|
8407e057c9 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,4 +0,0 @@
|
||||
|
||||
CMakeLists.txt.user
|
||||
|
||||
*.bak
|
||||
13
AUTHORS
13
AUTHORS
@@ -1,13 +0,0 @@
|
||||
Authors of OpenJPEG
|
||||
See also the files THANKS and CHANGES
|
||||
|
||||
David Janssens designed and implemented the first version of OpenJPEG.
|
||||
Kaori Hagihara designed and implemented the first version of OpenJPIP.
|
||||
Jerome Fimes implemented the alpha version of OpenJPEG v2.
|
||||
Giuseppe Baruffa added the JPWL functionalities.
|
||||
Yannick Verschueren,
|
||||
Herve Drolon,
|
||||
Francois-Olivier Devaux,
|
||||
Antonin Descampe
|
||||
improved the libraries and utilities.
|
||||
|
||||
612
CHANGES
Normal file
612
CHANGES
Normal file
@@ -0,0 +1,612 @@
|
||||
What's New for OpenJPEG
|
||||
|
||||
* : fixed
|
||||
- : removed
|
||||
! : changed
|
||||
+ : added
|
||||
|
||||
April 13, 2011
|
||||
* [antonin] fixed dllexport definition (credit to vincent torri)
|
||||
|
||||
April 12, 2011
|
||||
- [antonin] Removed folders mj2, JavaOpenJpeg, jpwl, OPJViewer (not compliant with v2). Removed obsolete windows project files. Removed obsolete Makefiles (only build method currently supported with v2 branch: cmake). Renamed ChangeLog to CHANGES. Renamed License.txt to LICENSE. Removed obsolete README files.
|
||||
* [antonin] Fixed internal function names conflict with Jasper (http://code.google.com/p/openjpeg/issues/detail?id=30)
|
||||
|
||||
November 25, 2010
|
||||
* [antonin] Fix leak in jp2_read_header_procedure() (from even.rouault, see issue 29 on googlecode)
|
||||
|
||||
Jun 22, 2010
|
||||
+ [MM] Import j2k_dump from trunk (much faster!)
|
||||
|
||||
Jun 21, 2010
|
||||
* [MM] Move CMake files to CMake folder
|
||||
* [MM] Remove some warnings in code
|
||||
* [MM] j2k_to_image properly return error code
|
||||
* [MM] increase coverage by testing all codecs
|
||||
* [MM] fix installation. Place in subfolder to handle both API
|
||||
* [MM] Start using cmake API for easy packaging
|
||||
|
||||
April 8, 2010
|
||||
* [FOD] Fixed problem with Borland C++ Builder (Borland C do not have lrintf). Thanks Marek Mauder for this fix.
|
||||
* [FOD] Fixed pi.c bug (issue 15 on google code). Thanks to Anton Lionel for catching this.
|
||||
* [FOD] Fixed MJ2 codec bugs (issues 23-24 on google code). Thanks to Winfried for these patches.
|
||||
|
||||
March 26, 2010
|
||||
+ [FOD] Added support for "jpc" codestreams which are equivalent to "j2c" codestreams. Thanks to Winfried for this patch
|
||||
|
||||
March 24, 2010
|
||||
* [FOD] Code improvements using 'g++-4.4.0' to trace the code. Thanks to Winfried for this patch.
|
||||
|
||||
March 7, 2010
|
||||
* [FOD] Fixed small compatibility issues with win32 in codec (moved include <strings.h>)
|
||||
|
||||
March 5,2010
|
||||
! [FOD] Updated makefiles for v1.4 and v2.0
|
||||
|
||||
February 16, 2010
|
||||
* [FOD] Fixed libopenjpeg Makefile
|
||||
|
||||
January 20, 2010
|
||||
! [FOD] Created a new constant in openjpeg.h to differentiate the case when the colorspace is not supported by the library and when it is not specified in the codestream. Suggested by Matteo Italia.
|
||||
|
||||
September 10, 2009
|
||||
* [antonin] fixed minor bugs which were triggering warnings at compilation (different signedness, wrong pointer type, etc)
|
||||
|
||||
August 21, 2008
|
||||
* [antonin] found a bug in tcd.c that was preventing to find the correct threshold in tcd_rateallocate.c for high-precision images. Applied a temporary patch but a better solution should be found.
|
||||
|
||||
August 8, 2008
|
||||
! [FOD] Modified the way raw images with more that 8bpp are read and written
|
||||
|
||||
August 2nd, 2008
|
||||
* [Mathieu Malaterre] remove INLINE from forward decl. Fix CMakeLists.txt for UNIX platforms
|
||||
|
||||
August 1st, 2008
|
||||
- [antonin] removed t1_generate_luts.c, useless in version 2.
|
||||
! [antonin] updated XCode project file for mac users.
|
||||
|
||||
---------------------------
|
||||
July 31, 2008
|
||||
CREATION OF A OPJ V2 BRANCH
|
||||
---------------------------
|
||||
|
||||
July 31, 2008
|
||||
+ [antonin] created a branch for openjpeg version 2. Modifications that have been applied to the trunk after revision 483 should be re-applied on the branch (version 2 has been developed based on revision 483).
|
||||
|
||||
July 9, 2008
|
||||
+ [Parvatha] Added the default lossless parameter to opj_set_default_encoder_parameters in openjpeg.c.
|
||||
|
||||
June 12, 2008
|
||||
* [antonin] fixed a bug in dirent.h that prevented codec on Linux Alpha Systems to compile correctly. Thanks to RobinC.
|
||||
|
||||
May 22, 2008
|
||||
* [antonin] fixed a bug in j2k.c (j2k_write_sod) that allowed to get negative rates, thanks zhong1985624 for pointing this.
|
||||
|
||||
May 22, 2008
|
||||
* [antonin] additional test to avoid crash due to invalid image size, patch by Christopher Layne
|
||||
|
||||
May 20, 2008
|
||||
* [antonin] memory leak fixed in openjpeg.c (opj_destroy_cstr_info()), patch by Carsten Juttner
|
||||
|
||||
March 12, 2008
|
||||
+ [GB] help line for the -F option in j2k_to_image
|
||||
|
||||
March 4, 2008
|
||||
! [FOD] Changed Java files copyright in JavaOpenJPEG module
|
||||
|
||||
February 28, 2008
|
||||
* [FOD] Fixed openjpeg.c for proper initialization of codec context structures (dinfo in opj_create_compress()
|
||||
and opj_create_decompress(). Bug fix suggested by Andrey V. Kiselev
|
||||
* [FOD] Clean up of opj_aligned_malloc(), to just forgo the use of posix_memalign(),
|
||||
as apparently memalign() is what is working better for everyone. Patch by Callum.
|
||||
|
||||
February 28, 2008
|
||||
- [FOD] Removed the J2KViewer module, which has been replaced by OPJViewer
|
||||
* [FOD] Fixed the error handling of j2k_decode in jp2.c, thanks to Robin Cornelius
|
||||
|
||||
February 11, 2008
|
||||
* [GB] Minor style modifications to comply with c99 compiler flag; removed Microsoft-specific "union-in-struct" syntax; Re-enabled cstr_info struct creation when -W switch is specified
|
||||
! [GB] Changed a number of things in opjviewer (e.g., decoding thread does not execute GUI calls anymore), to have it running under linux --> it is better than before, but still crashes
|
||||
|
||||
February 5, 2008
|
||||
! [Parvatha] In convert.c, corrected imagetobmp() conversion for grayscale. In tcd.c, corrected Rate modification in
|
||||
tcd_init_encode(). Thanks to Jeremy Furtek and Jérôme Fimes.
|
||||
|
||||
January 31, 2008
|
||||
! [GB] In opjviewer, unification of JPEG 2000 family handlers (*.jp2, *.mj2, *.j2k) in a single file
|
||||
|
||||
January 22, 2008
|
||||
! [FOD] In image.c, changed the opj_image_create0() memory allocation from malloc() to calloc() in order
|
||||
to avoid segfaults when freeing the memory allocated for the coding of bad images.
|
||||
Thanks to Christopher Layne for this improvement.
|
||||
|
||||
January 17, 2008
|
||||
+ [antonin] Initial commit of Xcode project directory (XCode 2.5 for macosx)
|
||||
available targets : libopenjpeg (stat and dyn), image_to_j2k, j2k_to_image
|
||||
|
||||
January 16, 2008
|
||||
* [antonin] fixed opj_malloc.h for macosx (bugfix provided by janpeder, thanks)
|
||||
|
||||
January 11, 2008
|
||||
+ [FOD] Added missing files to JavaOpenJPEG project (files from Patrick Piscaglia)
|
||||
|
||||
January 4, 2008
|
||||
* [Parvatha] Patch by Callum Lerwick. Fixed bug during encoding using tile option in tcd.c
|
||||
|
||||
----------------------
|
||||
December 21, 2007
|
||||
VERSION 1.3.0 RELEASED
|
||||
----------------------
|
||||
|
||||
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
|
||||
----------------------
|
||||
|
||||
May 4, 2007
|
||||
* [FOD] Bugs corrected in decoding of command line (getopt.c), in the handling of 16 bit files (t1.c and tcd.c) and the calculation of elapsed time for multiple tiles parts (tcd.c and tdc.h).
|
||||
|
||||
June 2, 2007
|
||||
+ [GB] OPJViewer opens now BMP, PNG, GIF, PNM, TIFF (with wxWidgets internals); added an encoder settings tab, for future integration with "save file as..." in JPEG 2000 format
|
||||
|
||||
May 31, 2007
|
||||
* [FOD] Fixed the handling of 16bit TIFF files for cinema compression. Modified "convert.c"
|
||||
* [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.
|
||||
|
||||
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>: "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."
|
||||
|
||||
May 11, 2007
|
||||
- [FOD] JP3D library Binaries removed from SVN.
|
||||
! [FOD] MJ2 codec updated from LibOpenJPEG version 0.97 to LibOpenJPEG version 1. Hence, the MJ2 codec will now take advantage of all the improvements and optimizations done on the LibOpenJPEG library.
|
||||
! [FOD] Possibility to choose to apply MCT (multiple component transform) enabled, and new decoding_limit: DECODE_ALL_BUT_PACKETS (openjpeg.h)
|
||||
|
||||
April 26, 2007
|
||||
+ [gdcm] Add basic steps on how to use CMake for building examples (README.cmake)
|
||||
|
||||
April 25, 2007
|
||||
+ [FOD] Modification of the openjpeg.h file to avoid and ABI break with v1.1, removed the dangerous #IFDEF JPWL and added tcp_mct in cparameters.
|
||||
|
||||
April 23, 2007
|
||||
+ [GB] Enable/disable image decoding in OPJViewer
|
||||
|
||||
April 12,2007
|
||||
* [Parvatha] Fixed Error in tiftoimage(). Modification in convert.c.
|
||||
|
||||
April 10,2007
|
||||
+ [Parvatha] Accepting "j2c" as format for Encoding and Decoding. Modification in image_to_j2k.c.
|
||||
* [Parvatha] Modified imagetotif() to read images with signed data. Modification in convert.c.
|
||||
|
||||
April 5, 2007
|
||||
! [FOD] fix.h optimized. Thanks a lot to Dzonatas <dzonatas at dzonux.net> !
|
||||
! [FOD] dwt.c optimized. Thanks a lot to Dzonatas <dzonatas at dzonux.net> !
|
||||
! [FOD] t1.c optimized. Thanks a lot to Callum Lerwick <seg at haxxed.com> !
|
||||
|
||||
April 4,2007
|
||||
+ [Parvatha] Digital cinema compliance for 4K chosen by "-cinema4K" option. Modification in image_to_j2k.c.
|
||||
+ [Parvatha] Bit rate limitation for each color component. Modification in image_to_j2k.c, t2.c.
|
||||
* [Parvatha] Modified and tested Progression order change "-POC" option. Modification in image_to_j2k.c, j2k.c, pi.c.
|
||||
+ [Parvatha] Function j2k_check_poc_val() to check for possible loss of packets in case of wrong POC declaration. Modification in j2k.c.
|
||||
+ [Parvatha] Structure T2_MODE. This tells if the t2_encode_packets() is called during Threshold calculation or in Final pass. Modification in j2k.h, tcd.c
|
||||
|
||||
March 30, 2007
|
||||
* [GB] OPJViewer should now work under Linux, at least with not big j2k files. Tested under Suse 10.1 64 bit.
|
||||
|
||||
March 29, 2007
|
||||
* [Parvatha] Enable accepting file names with `-´ symbol .Modification getopt.c
|
||||
* [Parvatha] Rsiz profile name generation to be STD_RSIZ for profiles which are not DCI compliant.Modification in image_to_j2k.c
|
||||
! [Parvatha] renamed convert_progression_order to j2k_convert_progression_order. Modification j2k.c
|
||||
* [Parvatha] Calculation of number of tile part in each tile in j2k_calculate_tp. Modification j2k.c
|
||||
! [Parvatha] j2k_setup_encoder to set bit rate limitation for digital cinema compliance with quality option. Modification in j2k.c
|
||||
* [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.
|
||||
|
||||
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é'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
|
||||
* [antonin] Fixed Makefile.osx and changed Readme.osx accordingly
|
||||
|
||||
March 21, 2007
|
||||
* [Parvatha] Fixed j2k_prog_order_list[]. Modifications in j2k.c.
|
||||
* [Parvatha] Fixed t1_decode_cblks. Modifications in t1.c.
|
||||
|
||||
March 20, 2007
|
||||
+ [Parvatha] Added feature for generation of tile parts. Modifications in image_to_j2k.c, openjpeg.c, j2k.c, pi.c
|
||||
+ [Parvatha] Added function j2k_write_tlm(),to generate TLM marker for a Digital cinema compliant codestream. Modifications in j2k.c.
|
||||
|
||||
March 14, 2007
|
||||
* [FOD] Fixed linux makefile, with help from David Fries and Guido
|
||||
|
||||
March 7, 2007
|
||||
+ [Parvatha] Added option for Digital cinema profile compliant codestream. This can be chosen by "-cinema2K" or "-cinema4K" for a 2K and 4K compliance respectively. The feature for tileparts has not been implemented in this version. Modification in image_to_j2k.c
|
||||
+ [Parvatha] Added the Digital Cinema profiles (CINEMA2K and CINEMA4K) to the list of profiles recognized in the codestream SIZ marker segment. Modification in openjpeg.h,j2k.c
|
||||
+ [Parvatha] Added feature for constant quality within bitrate defined in Digital cinema standards. Modification in tcd.c
|
||||
! [Parvatha] Modified the method of generation of buffer length. Modification in cio.c
|
||||
|
||||
|
||||
March 1, 2007
|
||||
* [FOD] Modified codec projects (*.dsp) and makefile to include the tiff library (modified codec/image_to_j2k.dsp codec/j2k_to_image.dsp and codec/makefile)
|
||||
+ [GB] Zoom capability and decoder settings dialog in OPJViewer; modified JPWL library .dsp project in order to create a library with embedded JPWL functions
|
||||
|
||||
February 28, 2007
|
||||
+ [Parvatha] Enabled compression of TIF image format to j2k by tifftoimage() and decompression of codestream to TIF image format using imagetotif(). Modifications in image_to_j2k.c, j2k_to_image.c, convert.c, convert.h
|
||||
* [antonin] fixed a bug in context numerotation that prevented the RESET switch to work correctly : mqc_reset_enc in mqc.c
|
||||
* [Fod] Corrected codec Makefile by adding the compilation of "compat/getopt.c"
|
||||
|
||||
February 27, 2007
|
||||
* [Parvatha] Made get_file_format function more robust. Modifications in image_to_j2k.c, j2k_to_image.c, getopt.c, getopt.h
|
||||
|
||||
February 26, 2007
|
||||
+ [Parvatha] Option to read images from a Folder whose path is specified in the Input parameters by "-ImgDir" along with output decod format specified by "-OutFor" . Modifications in image_to_j2k.c, j2k_to_image.c, getopt.c, getopt.h
|
||||
+ [Parvatha] Enabling use of multi character input parameters in the codec. Modifications in image_to_j2k.c, j2k_to_image.c, getopt.c, getopt.h
|
||||
|
||||
----------------------
|
||||
February 23, 2007
|
||||
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] Linux makefile for the JPWL module; newlines at end of JPWL files
|
||||
|
||||
February 22, 2007
|
||||
+ [FOD] Added the OPJViewer Module (/OPJViewer), developed by Giuseppe Baruffa of the university of Perugia
|
||||
|
||||
February 21, 2007
|
||||
+ [FOD] Algorithmic optimizations in t1.c, thanks to Guido J. !
|
||||
|
||||
February 19, 2007
|
||||
+ [FOD] Added OPJ_LIMIT_DECODING enabling us to limit the decoding to main header (modified openjpeg.c, openjpeg.h, j2k.c and j2k.h)
|
||||
|
||||
February 13, 2007
|
||||
! [FOD] David Fries suggestions. In image_to_j2k and j2k_to_image, strncpy() functions: instead of specifying the path size macro, let the compiler read the length out of the array entry.
|
||||
! [FOD] David Fries suggestions. Makefile modified. -fPIC flag used for 64-bit compilation. Move operation (rather than copy) for the dist library creation, and -p flag added.
|
||||
|
||||
January 31, 2007
|
||||
! [FOD] Extra tokens at the end of #endif directive corrected in openjpeg.c, j2k.c and image_to_j2k.c -> no more warnings in linux compilation
|
||||
! [FOD] Linux Makefile added for the codec
|
||||
|
||||
January 30, 2007
|
||||
! [FOD] Use of OPJ_PATH_LEN (defined as 4096) to be the maximum allowed size for filenames instead of MAX_PATH which is not always defined. This caused some programs using OpenJPEG to crash. Modifications in openjpeg.h j2k_to_image.c and image_to_j2k.c
|
||||
! [FOD] Correction of the syntax usage in MJ2_codec/mj2_to_frames.c
|
||||
|
||||
January 23, 2007
|
||||
! [FOD] Modification in the context numbers, to reflect what has been specified in standard, in libopenjpeg/t1.h
|
||||
|
||||
December 07, 2006
|
||||
+ [Giuseppe Baruffa] Antonin verified that the MacOS build suffered from a missing definition of the "min" macro; I've added this definition (properly #ifndef'ed) into both jpwl.h and rs.h
|
||||
|
||||
December 05, 2006
|
||||
* [Giuseppe Baruffa] Better fix of the TPH EPBs bug in JPWL module
|
||||
* [GB] Fixed the UEP bug in JPWL module; now, during a UEP specification, RS protection or CRC check can be switched off for selected range of packets, and consequently reswitched on without confusing the decoder
|
||||
+ [GB] Added some lines in the help of JPWL_image_to_j2k, specifying that when using error protection on data packets, this must be paired with header protection, i.e. there cannot be packet protection without header protection
|
||||
|
||||
December 04, 2006
|
||||
|
||||
+ [Francois-Olivier Devaux] New tag: version1.0 (includes codec and libopenjpeg directories)
|
||||
Total update of JPWL module
|
||||
- [FOD] removed directories jpwl/decoder, jpwl/encoder, jpwl/decoder_02, jpwl/encoder_02
|
||||
+ [FOD] added in JPWL directory crc.h, jpwl.h, rs.h, crc.c, jpwl.c, jpwl_lib.c, rs.c, JPWL_image_to_j2k.dsp, JPWL_j2k_to_image.dsp, LibOpenJPEG_JPWL.dsp, JPWL_image_to_j2k.dsw, JPWL_j2k_to_image.dsw
|
||||
! [FOD] Modifications of libopenjpeg to integrate JPWL module (in libopenjpeg directory): j2k.c, j2k.h, openjpeg.c, openjpeg.h, opj_includes.g, t2.c
|
||||
! [FOD] Modification of codec to integrate JPWL module (in codec directory): image_to_j2k.c, j2k_to_image.c
|
||||
* [FOD] Corrected incorrect fprintf() formatting in codec/convert.c
|
||||
* [FOD] Code optimization usinq vsprintf() command in libopenjpeg/event.c
|
||||
* [Giuseppe Baruffa] Fixed a bug in TPH EPBs parameters: now, "last in current header" information is correctly signaled
|
||||
|
||||
October 31, 2006
|
||||
* [Antonin] fixed a bug in the computation of the mantissa (mu)
|
||||
+ [Antonin] added the ability to specify the rate as "float" (before : integer)
|
||||
|
||||
August 18, 2006
|
||||
* [Antonin] fixed a bug in j2k_to_image.c, that prevented the -l option to work correctly.
|
||||
|
||||
August 4, 2006
|
||||
* [Antonin] fixed a bug in pi.c, line 473, that appeared when more than 100 precincts were generated in a resolution level.
|
||||
|
||||
July 28, 2006
|
||||
+ [Antonin Descampe] added a readme in /mj2 to warn people that it only works with opj0.97
|
||||
|
||||
July 21, 2006
|
||||
* [Mathieu Malaterre] Install exe and lib and include correctly
|
||||
* [Mathieu Malaterre] Fixed mem leaks and greyscale bmp
|
||||
* [Mathieu Malaterre] Fix pgx name length + random memory access
|
||||
! [Mathieu Malaterre] API is now const
|
||||
|
||||
March 19, 2006
|
||||
* [Antonin] fixed a bug in t1.c that prevented in some cases a true lossless compression (thanks to Don Mimlitch for reporting this bug)
|
||||
|
||||
February 12, 2006
|
||||
- [Herve Drolon] removed unneeded working variables in opj_tcd_t
|
||||
|
||||
February 04, 2006
|
||||
* [galt] fixed a bug in codec/convert.c::imagetobmp
|
||||
|
||||
February 01, 2006
|
||||
! [Herve Drolon] changed function definitions of INT and FIX modules to 'inline'
|
||||
+ [Herve Drolon] added a VERSION resource to the DLL version of OpenJPEG
|
||||
|
||||
January 31, 2006
|
||||
* [Mathieu Malaterre] Fix compilation using default openjpeg.dsw
|
||||
* [Herve Drolon] fixed various minor warnings occuring under icc9 and bcc32
|
||||
- [Mathieu Malaterre] Remove all references to OPJ_EXPORT, no declspec in header file anymore
|
||||
+ [Mathieu Malaterre] Add a def.in file which is a template for Module Definition
|
||||
+ [Herve Drolon] added MSVC project and compiler directives to build a 'standard' WIN32 DLL
|
||||
! [Mathieu Malaterre] Update CMake to match the new shared lib system (no more def file)
|
||||
|
||||
January 27, 2006
|
||||
* [Antonin Descampe] fixed a two initialization problems in t1.c and tcd.c
|
||||
|
||||
January 26, 2006
|
||||
* [Herve Drolon] fixed various minor warnings occuring under gcc
|
||||
* [__david__] fixed a segfault in codec/image_to_j2k.c & codec/j2k_to_image.c
|
||||
* [__david__] fixed help option in codec/j2k_to_image & codec/image_to_j2k
|
||||
|
||||
January 25, 2006
|
||||
! [Mathieu Malaterre] Sync with ITK repository, also add ref to doxygen
|
||||
! [Mathieu Malaterre] Add a lot of comments on the CMake build system
|
||||
! [Mathieu Malaterre] Fix MINGW32 and BORLAND compilation problems.
|
||||
|
||||
January 25, 2006
|
||||
* [Antonin Descampe] fixed a problem in convert.c when multiple comments
|
||||
+ [Antonin Descampe] added cmake files to the project
|
||||
! [Antonin Descampe] fix.c : replaced "WIN32" by "_MSC_VER" for int64
|
||||
+ [Antonin Descampe] added "OPJ_EXPORT" in openjpeg.h to generate shared lib with win32
|
||||
! [Antonin Descampe] removed all CtrlM from files
|
||||
|
||||
January 24, 2006
|
||||
! [Antonin Descampe] event.c : replaced "WIN32" by "_MSC_VER" for i2a
|
||||
|
||||
January 20, 2006
|
||||
* [Antonin Descampe] fixed various minor warnings with gdcm patches
|
||||
|
||||
January 19, 2006
|
||||
* [Herve Drolon] fixed a bug in jp2_read_ihdr (need to allocate jp2->comps)
|
||||
|
||||
January 18, 2006
|
||||
* [Herve Drolon] changed the name of j2k_realloc to opj_realloc
|
||||
* [Herve Drolon] fixed a bug in opj_cio_open when saving 48-bit images (wrong buffer size calculation)
|
||||
|
||||
December 8, 2005
|
||||
* [Antonin Descampe] fixed a bug when specifying a rate '-r' => no distortion info was available in the index
|
||||
* [Antonin Descampe] fixed a bug in t1_getwmsedec (stepsize was divided by 8192)
|
||||
|
||||
December 5, 2005 - 1.1.0
|
||||
@@ -1,34 +1,21 @@
|
||||
#----------------------------------------------------------------------
|
||||
#
|
||||
# For further details regarding this file,
|
||||
# see http://www.cmake.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest
|
||||
# For further details regarding this file,
|
||||
# see http://www.vtk.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest
|
||||
#
|
||||
# and
|
||||
# http://www.kitware.com/blog/home/post/27
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000)
|
||||
SET(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
|
||||
SET(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 2000)
|
||||
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 50)
|
||||
SET (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 50)
|
||||
|
||||
SET(CTEST_CUSTOM_COVERAGE_EXCLUDE
|
||||
${CTEST_CUSTOM_COVERAGE_EXCLUDE}
|
||||
${CTEST_CUSTOM_COVERAGE_EXCLUDE}
|
||||
|
||||
# Exclude files from the Testing directories
|
||||
".*/tests/.*"
|
||||
|
||||
# Exclude files from the ThirdParty Utilities directories
|
||||
".*/thirdparty/.*"
|
||||
)
|
||||
# Exclude files from the Testing directories
|
||||
".*/Testing/.*"
|
||||
)
|
||||
|
||||
SET(CTEST_CUSTOM_WARNING_EXCEPTION
|
||||
${CTEST_CUSTOM_WARNING_EXCEPTION}
|
||||
|
||||
|
||||
# Suppress warning caused by intentional messages about deprecation
|
||||
".*warning,.* is deprecated"
|
||||
# supress warnings caused by 3rd party libs:
|
||||
".*thirdparty.*"
|
||||
"libtiff.*has no symbols"
|
||||
"libpng.*has no symbols"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# cppcheck
|
||||
#
|
||||
# Copyright (c) 2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
|
||||
find_program(CPPCHECK_EXECUTABLE
|
||||
cppcheck
|
||||
)
|
||||
|
||||
mark_as_advanced(
|
||||
CPPCHECK_EXECUTABLE
|
||||
)
|
||||
@@ -1,20 +0,0 @@
|
||||
# Look for the header file.
|
||||
FIND_PATH(FCGI_INCLUDE_DIR NAMES fastcgi.h)
|
||||
|
||||
# Look for the library.
|
||||
FIND_LIBRARY(FCGI_LIBRARY NAMES fcgi)
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set FCGI_FOUND to TRUE if all listed variables are TRUE.
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FCGI DEFAULT_MSG FCGI_LIBRARY FCGI_INCLUDE_DIR)
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(FCGI_FOUND)
|
||||
SET(FCGI_LIBRARIES ${FCGI_LIBRARY})
|
||||
SET(FCGI_INCLUDE_DIRS ${FCGI_INCLUDE_DIR})
|
||||
ELSE(FCGI_FOUND)
|
||||
SET(FCGI_LIBRARIES)
|
||||
SET(FCGI_INCLUDE_DIRS)
|
||||
ENDIF(FCGI_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(FCGI_INCLUDE_DIR FCGI_LIBRARY)
|
||||
52
CMake/FindFreeImage.cmake
Normal file
52
CMake/FindFreeImage.cmake
Normal file
@@ -0,0 +1,52 @@
|
||||
#
|
||||
# Try to find the FreeImage library and include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# FREEIMAGE_FOUND
|
||||
# FREEIMAGE_INCLUDE_PATH
|
||||
# FREEIMAGE_LIBRARY
|
||||
#
|
||||
|
||||
IF (WIN32)
|
||||
FIND_PATH( FREEIMAGE_INCLUDE_PATH FreeImage.h
|
||||
${OPENJPEG_SOURCE_DIR}/libs/FreeImage
|
||||
DOC "The directory where FreeImage.h resides")
|
||||
FIND_LIBRARY( FREEIMAGE_LIBRARY
|
||||
NAMES FreeImage freeimage freeimage.s
|
||||
PATHS
|
||||
${OPENJPEG_SOURCE_DIR}/libs/FreeImage
|
||||
DOC "The FreeImage library")
|
||||
ELSE (WIN32)
|
||||
FIND_PATH( FREEIMAGE_INCLUDE_PATH FreeImage.h
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/sw/include
|
||||
/opt/local/include
|
||||
DOC "The directory where FreeImage.h resides")
|
||||
FIND_LIBRARY( FREEIMAGE_LIBRARY
|
||||
NAMES FreeImage freeimage
|
||||
PATHS
|
||||
/usr/lib64
|
||||
/usr/lib
|
||||
/usr/local/lib64
|
||||
/usr/local/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
DOC "The FreeImage library")
|
||||
ENDIF (WIN32)
|
||||
|
||||
SET(FREEIMAGE_LIBRARIES ${FREEIMAGE_LIBRARY})
|
||||
|
||||
IF (FREEIMAGE_INCLUDE_PATH AND FREEIMAGE_LIBRARY)
|
||||
SET( FREEIMAGE_FOUND TRUE CACHE BOOL "Set to TRUE if GLEW is found, FALSE otherwise")
|
||||
ELSE (FREEIMAGE_INCLUDE_PATH AND FREEIMAGE_LIBRARY)
|
||||
SET( FREEIMAGE_FOUND FALSE CACHE BOOL "Set to TRUE if GLEW is found, FALSE otherwise")
|
||||
ENDIF (FREEIMAGE_INCLUDE_PATH AND FREEIMAGE_LIBRARY)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
FREEIMAGE_FOUND
|
||||
FREEIMAGE_LIBRARY
|
||||
FREEIMAGE_LIBRARIES
|
||||
FREEIMAGE_INCLUDE_PATH)
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#
|
||||
# this module looks for JPYLYZER
|
||||
# http://jpylyzer.openpreservation.org
|
||||
#
|
||||
|
||||
find_program(JPYLYZER_EXECUTABLE
|
||||
jpylyzer
|
||||
)
|
||||
|
||||
mark_as_advanced(
|
||||
JPYLYZER_EXECUTABLE
|
||||
)
|
||||
@@ -1,19 +0,0 @@
|
||||
#
|
||||
# this module looks for KAKADu
|
||||
# http://www.kakadusoftware.com/
|
||||
#
|
||||
#
|
||||
# Copyright (c) 2006-2011 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
|
||||
FIND_PROGRAM(KDU_EXPAND_EXECUTABLE
|
||||
kdu_expand
|
||||
)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
KDU_EXPAND_EXECUTABLE
|
||||
)
|
||||
@@ -1,31 +0,0 @@
|
||||
# - Find LCMS library
|
||||
# Find the native LCMS includes and library
|
||||
# Once done this will define
|
||||
#
|
||||
# LCMS_INCLUDE_DIR - Where to find lcms.h, etc.
|
||||
# LCMS_LIBRARIES - Libraries to link against to use LCMS.
|
||||
# LCMS_FOUND - If false, do not try to use LCMS.
|
||||
#
|
||||
# also defined, but not for general use are
|
||||
# LCMS_LIBRARY, where to find the LCMS library.
|
||||
|
||||
#=============================================================================
|
||||
#=============================================================================
|
||||
|
||||
FIND_PATH(LCMS_INCLUDE_DIR lcms.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
|
||||
|
||||
SET(LCMS_NAMES ${LCMS_NAMES} lcms liblcms liblcms_static)
|
||||
|
||||
FIND_LIBRARY(LCMS_LIBRARY NAMES ${LCMS_NAMES} )
|
||||
|
||||
MARK_AS_ADVANCED(LCMS_INCLUDE_DIR LCMS_LIBRARY)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set LCMS_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS DEFAULT_MSG LCMS_LIBRARY LCMS_INCLUDE_DIR)
|
||||
|
||||
IF(LCMS_FOUND)
|
||||
SET( LCMS_INCLUDE_DIRS ${LCMS_INCLUDE_DIR})
|
||||
SET( LCMS_LIBRARIES ${LCMS_LIBRARY} )
|
||||
ENDIF(LCMS_FOUND)
|
||||
@@ -1,31 +0,0 @@
|
||||
# - Find LCMS2 library
|
||||
# Find the native LCMS2 includes and library
|
||||
# Once done this will define
|
||||
#
|
||||
# LCMS2_INCLUDE_DIR - Where to find lcms2.h, etc.
|
||||
# LCMS2_LIBRARIES - Libraries to link against to use LCMS2.
|
||||
# LCMS2_FOUND - If false, do not try to use LCMS2.
|
||||
#
|
||||
# also defined, but not for general use are
|
||||
# LCMS2_LIBRARY - Where to find the LCMS2 library.
|
||||
|
||||
#=============================================================================
|
||||
#=============================================================================
|
||||
|
||||
FIND_PATH(LCMS2_INCLUDE_DIR lcms2.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
|
||||
|
||||
SET(LCMS2_NAMES ${LCMS2_NAMES} lcms2 liblcms2 liblcms2_static)
|
||||
|
||||
FIND_LIBRARY(LCMS2_LIBRARY NAMES ${LCMS2_NAMES} )
|
||||
|
||||
MARK_AS_ADVANCED(LCMS2_INCLUDE_DIR LCMS2_LIBRARY)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set LCMS2_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS2 DEFAULT_MSG LCMS2_LIBRARY LCMS2_INCLUDE_DIR)
|
||||
|
||||
IF(LCMS2_FOUND)
|
||||
SET( LCMS2_INCLUDE_DIRS ${LCMS2_INCLUDE_DIR})
|
||||
SET( LCMS2_LIBRARIES ${LCMS2_LIBRARY} )
|
||||
ENDIF(LCMS2_FOUND)
|
||||
3
CMake/Free_CMakeImport.cmake
Normal file
3
CMake/Free_CMakeImport.cmake
Normal file
@@ -0,0 +1,3 @@
|
||||
SET(CMAKE_MODULE_PATH "${OPENJPEG_SOURCE_DIR}/CMake")
|
||||
FIND_PACKAGE(FreeImage REQUIRED)
|
||||
ADD_DEFINITIONS ( -DFREEIMAGE_LIB )
|
||||
@@ -1,9 +0,0 @@
|
||||
# JPIP test driver
|
||||
#message(STATUS "${D_URL}")
|
||||
file(DOWNLOAD
|
||||
"${D_URL}"
|
||||
"${D_FILE}"
|
||||
LOG log
|
||||
EXPECTED_MD5 "${EXPECTED_MD5}"
|
||||
)
|
||||
message(STATUS "LOG: ${log}")
|
||||
@@ -1,70 +0,0 @@
|
||||
# package bundler
|
||||
if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||
if(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake")
|
||||
set(CMAKE_INSTALL_MFC_LIBRARIES 0)
|
||||
set(CMAKE_INSTALL_DEBUG_LIBRARIES 0)
|
||||
if(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
|
||||
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
|
||||
endif()
|
||||
include(${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake)
|
||||
endif(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake")
|
||||
|
||||
set(OPJ_PACKAGE_DESCRIPTION_SUMMARY "OpenJPEG - OpenJPEG a JPEG 2000 implementation.")
|
||||
set(OPJ_PACKAGE_CONTACT "openjpeg users <openjpeg@googlegroups.com>")
|
||||
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${OPJ_PACKAGE_DESCRIPTION_SUMMARY})
|
||||
set(CPACK_PACKAGE_VENDOR "OpenJPEG Team")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" COPYONLY
|
||||
)
|
||||
# For PackageMaker on MacOSX it is important to have a file extension:
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${OPENJPEG_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${OPENJPEG_VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${OPENJPEG_VERSION_BUILD}")
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "openjpeg-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||
|
||||
# Make this explicit here, rather than accepting the CPack default value,
|
||||
# so we can refer to it:
|
||||
SET(CPACK_PACKAGE_NAME "${OPENJPEG_LIBRARY_NAME}")
|
||||
|
||||
IF(NOT DEFINED CPACK_SYSTEM_NAME)
|
||||
# make sure package is not Cygwin-unknown, for Cygwin just
|
||||
# cygwin is good for the system name
|
||||
IF("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||
SET(CPACK_SYSTEM_NAME Cygwin)
|
||||
ELSE("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||
SET(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
|
||||
ENDIF("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
|
||||
ENDIF(NOT DEFINED CPACK_SYSTEM_NAME)
|
||||
IF(${CPACK_SYSTEM_NAME} MATCHES Windows)
|
||||
IF(CMAKE_CL_64)
|
||||
SET(CPACK_SYSTEM_NAME win64-x64)
|
||||
ELSE(CMAKE_CL_64)
|
||||
SET(CPACK_SYSTEM_NAME win32-x86)
|
||||
ENDIF(CMAKE_CL_64)
|
||||
ENDIF(${CPACK_SYSTEM_NAME} MATCHES Windows)
|
||||
|
||||
IF(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
|
||||
# if the CPACK_PACKAGE_FILE_NAME is not defined by the cache
|
||||
# default to source package - system, on cygwin system is not
|
||||
# needed
|
||||
IF(CYGWIN)
|
||||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
|
||||
ELSE(CYGWIN)
|
||||
SET(CPACK_PACKAGE_FILE_NAME
|
||||
"${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
|
||||
ENDIF(CYGWIN)
|
||||
ENDIF(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
|
||||
|
||||
set(CPACK_BUNDLE_NAME "OpenJPEG ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
|
||||
configure_file(${CMAKE_ROOT}/Templates/AppleInfo.plist
|
||||
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
||||
SET(CPACK_BUNDLE_PLIST
|
||||
${CMAKE_CURRENT_BINARY_DIR}/opj.plist)
|
||||
#include(BundleUtilities)
|
||||
|
||||
include(CPack)
|
||||
endiF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||
@@ -11,29 +11,24 @@ SET(OPENJPEG_MINOR_VERSION "@OPENJPEG_VERSION_MINOR@")
|
||||
SET(OPENJPEG_BUILD_VERSION "@OPENJPEG_VERSION_BUILD@")
|
||||
|
||||
# The libraries.
|
||||
SET(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARY_NAME@")
|
||||
SET(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARIES@")
|
||||
|
||||
# The CMake macros dir.
|
||||
SET(OPENJPEG_CMAKE_DIR "@OPENJPEG_INSTALL_PACKAGE_DIR@")
|
||||
SET(OPENJPEG_CMAKE_DIR "@OPENJPEG_CMAKE_DIR_CONFIG@")
|
||||
|
||||
# The configuration options.
|
||||
SET(OPENJPEG_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
|
||||
SET(OPENJPEG_BUILD_SHARED_LIBS "@OPENJPEG_BUILD_SHARED_LIBS@")
|
||||
|
||||
# The "use" file.
|
||||
SET(OPENJPEG_USE_FILE "@OPENJPEG_USE_FILE_CONFIG@")
|
||||
|
||||
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
# The following is inspired from:
|
||||
# http://www.cmake.org/Wiki/CMake/Tutorials/Packaging#Packaging_and_Exporting
|
||||
# However the following is difficult to handle:
|
||||
# get_filename_component(myproj_INCLUDE_DIRS "${SELF_DIR}/../../include/myproj" ABSOLUTE)
|
||||
# it asssumes a non multi-arch system, where 'include' is located '../include' from lib
|
||||
# therefore we need to take into account the number of subdirs in OPENJPEG_INSTALL_LIB_DIR
|
||||
if(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||
# This is an install tree
|
||||
include(${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/@relative_parent@/@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
|
||||
get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/../../@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
|
||||
set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_ROOT})
|
||||
set(OPENJPEG_LIBRARIES openjpeg)
|
||||
|
||||
else(EXISTS ${SELF_DIR}/OpenJPEGTargets.cmake)
|
||||
if(EXISTS ${SELF_DIR}/OpenJPEGExports.cmake)
|
||||
|
||||
51
CMake/mymachine_openjpeg.cmake
Normal file
51
CMake/mymachine_openjpeg.cmake
Normal file
@@ -0,0 +1,51 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
# simply copy this file anywhere on your system and execute like this:
|
||||
# ctest -S mymachine_openjpeg.cmake -V
|
||||
# This will retrieve/compile/run tests/upload to cdash OpenJPEG
|
||||
# results will be available at: http://my.cdash.org/index.php?project=OPENJPEG
|
||||
|
||||
# Begin User inputs:
|
||||
set( CTEST_SITE "mymachine" ) # generally the output of hostname
|
||||
set( CTEST_DASHBOARD_ROOT "/tmp" ) # writable path
|
||||
set( CTEST_CMAKE_GENERATOR "Unix Makefiles" ) # What is your compilation apps ?
|
||||
set( CTEST_BUILD_CONFIGURATION Debug) # What type of build do you want ?
|
||||
set( ENV{CFLAGS} "-Wall" ) # just for fun...
|
||||
|
||||
# For testing we need to define the path to J2KP4files
|
||||
# wget http://www.crc.ricoh.com/~gormish/jpeg2000conformance/j2kp4files_v1_5.zip
|
||||
# unzip j2kp4files_v1_5.zip
|
||||
set( CACHE_CONTENTS "
|
||||
BUILD_TESTING:BOOL=TRUE
|
||||
JPEG2000_CONFORMANCE_DATA_ROOT:PATH=${CTEST_SOURCE_DIRECTORY}/J2KP4files" )
|
||||
# End User inputs:
|
||||
|
||||
# You do not need to change anything after that:
|
||||
# 1. openjpeg specific:
|
||||
set( CTEST_PROJECT_NAME "OPENJPEG" )
|
||||
set( CTEST_SOURCE_NAME OpenJPEG)
|
||||
set( CTEST_BUILD_NAME "${CMAKE_SYSTEM}-${CTEST_CMAKE_GENERATOR}-${CTEST_BUILD_CONFIGURATION}")
|
||||
set( CTEST_BINARY_NAME "${CTEST_SOURCE_NAME}-${CTEST_BUILD_NAME}")
|
||||
|
||||
# 2. cdash/openjpeg specific:
|
||||
# svn checkout http://openjpeg.googlecode.com/svn/trunk/ openjpeg-read-only
|
||||
set( CTEST_SVN_URL "http://openjpeg.googlecode.com/svn/")
|
||||
set( CTEST_UPDATE_COMMAND "svn")
|
||||
#set( CTEST_CHECKOUT_COMMAND "${CTEST_UPDATE_COMMAND} co ${CTEST_SVN_URL}/trunk ${CTEST_SOURCE_NAME}")
|
||||
set( CTEST_CHECKOUT_COMMAND "${CTEST_UPDATE_COMMAND} co ${CTEST_SVN_URL}/branches/v2 ${CTEST_SOURCE_NAME}")
|
||||
|
||||
# 3. cmake specific:
|
||||
set( CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_SOURCE_NAME}")
|
||||
set( CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_BINARY_NAME}")
|
||||
set( CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
|
||||
|
||||
ctest_empty_binary_directory( "${CTEST_BINARY_DIRECTORY}" )
|
||||
file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" "${CACHE_CONTENTS}")
|
||||
|
||||
# Perform the Nightly build
|
||||
ctest_start(Nightly)
|
||||
ctest_update(SOURCE "${CTEST_SOURCE_DIRECTORY}")
|
||||
ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}")
|
||||
ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}")
|
||||
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}")
|
||||
ctest_submit()
|
||||
|
||||
307
CMakeLists.txt
307
CMakeLists.txt
@@ -11,9 +11,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
|
||||
IF(COMMAND CMAKE_POLICY)
|
||||
CMAKE_POLICY(SET CMP0003 NEW)
|
||||
if (NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
endif()
|
||||
ENDIF(COMMAND CMAKE_POLICY)
|
||||
|
||||
IF(NOT OPENJPEG_NAMESPACE)
|
||||
@@ -30,74 +27,29 @@ INCLUDE_REGULAR_EXPRESSION("^.*$")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# OPENJPEG version number, useful for packaging and doxygen doc:
|
||||
SET(OPENJPEG_VERSION_MAJOR 1)
|
||||
SET(OPENJPEG_VERSION_MINOR 5)
|
||||
SET(OPENJPEG_VERSION_BUILD 3)
|
||||
SET(OPENJPEG_VERSION_MAJOR 2)
|
||||
SET(OPENJPEG_VERSION_MINOR 0)
|
||||
SET(OPENJPEG_VERSION_BUILD 0)
|
||||
SET(OPENJPEG_VERSION
|
||||
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||
SET(PACKAGE_VERSION
|
||||
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
|
||||
|
||||
# Because autotools does not support X.Y notation for SOVERSION, we have to use
|
||||
# two numerorations, one for the openjpeg version and one for openjpeg soversion
|
||||
# version | soversion
|
||||
# 1.0 | 0
|
||||
# 1.1 | 1
|
||||
# 1.2 | 2
|
||||
# 1.3 | 3
|
||||
# 1.4 | 4
|
||||
# 1.5 | 5
|
||||
# 1.5.1 | 5
|
||||
# 2.0 | 6
|
||||
# above is the recommendation by the OPJ team. If you really need to override this default,
|
||||
# you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
|
||||
# cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg
|
||||
if(NOT OPENJPEG_SOVERSION)
|
||||
SET(OPENJPEG_SOVERSION 5)
|
||||
endif(NOT OPENJPEG_SOVERSION)
|
||||
# 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_SOVERSION}"
|
||||
SOVERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}"
|
||||
)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Path to additional CMake modules
|
||||
SET(CMAKE_MODULE_PATH
|
||||
${CMAKE_SOURCE_DIR}/CMake
|
||||
${CMAKE_MODULE_PATH})
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
|
||||
# warnings
|
||||
IF(WIN32)
|
||||
IF(NOT BORLAND)
|
||||
IF(NOT CYGWIN)
|
||||
IF(NOT MINGW)
|
||||
IF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
|
||||
ADD_DEFINITIONS(
|
||||
-D_CRT_FAR_MAPPINGS_NO_DEPRECATE
|
||||
-D_CRT_IS_WCTYPE_NO_DEPRECATE
|
||||
-D_CRT_MANAGED_FP_NO_DEPRECATE
|
||||
-D_CRT_NONSTDC_NO_DEPRECATE
|
||||
-D_CRT_SECURE_NO_DEPRECATE
|
||||
-D_CRT_SECURE_NO_DEPRECATE_GLOBALS
|
||||
-D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
|
||||
-D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
|
||||
-D_CRT_VCCLRIT_NO_DEPRECATE
|
||||
-D_SCL_SECURE_NO_DEPRECATE
|
||||
)
|
||||
ENDIF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
|
||||
ENDIF(NOT MINGW)
|
||||
ENDIF(NOT CYGWIN)
|
||||
ENDIF(NOT BORLAND)
|
||||
ENDIF(WIN32)
|
||||
|
||||
# You will also need to define a value for the following variables:
|
||||
# OPENJPEG_INSTALL_BIN_DIR - binary dir (executables)
|
||||
# OPENJPEG_INSTALL_LIB_DIR - library dir (libs)
|
||||
# OPENJPEG_INSTALL_DATA_DIR - share dir (say, examples, data, etc)
|
||||
# OPENJPEG_INSTALL_INCLUDE_DIR - include dir (headers)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Install directories
|
||||
|
||||
STRING(TOLOWER ${PROJECT_NAME} projectname)
|
||||
SET(OPENJPEG_INSTALL_SUBDIR "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
|
||||
SET(subdir "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_BIN_DIR)
|
||||
SET(OPENJPEG_INSTALL_BIN_DIR "bin")
|
||||
@@ -107,95 +59,129 @@ IF(NOT OPENJPEG_INSTALL_LIB_DIR)
|
||||
SET(OPENJPEG_INSTALL_LIB_DIR "lib")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_LIB_DIR)
|
||||
|
||||
# The following will compute the amount of parent dir to go
|
||||
# from include to lib. it works nicely with
|
||||
# OPENJPEG_INSTALL_LIB_DIR=lib
|
||||
# OPENJPEG_INSTALL_LIB_DIR=lib/
|
||||
# OPENJPEG_INSTALL_LIB_DIR=/lib
|
||||
# OPENJPEG_INSTALL_LIB_DIR=lib/gnu-linux-x64
|
||||
STRING(REPLACE "/" ";" relative_to_lib ${OPENJPEG_INSTALL_LIB_DIR})
|
||||
set(relative_parent "..")
|
||||
foreach( elem ${relative_to_lib})
|
||||
set( relative_parent "${relative_parent}/.." )
|
||||
endforeach()
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
||||
SET(OPENJPEG_INSTALL_SHARE_DIR "share")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_SHARE_DIR)
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_DATA_DIR)
|
||||
SET(OPENJPEG_INSTALL_DATA_DIR "${OPENJPEG_INSTALL_SHARE_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
SET(OPENJPEG_INSTALL_DATA_DIR "share/${subdir}")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_DATA_DIR)
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||
SET(OPENJPEG_INSTALL_INCLUDE_DIR "include/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
SET(OPENJPEG_INSTALL_INCLUDE_DIR "include/${subdir}")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_MAN_DIR)
|
||||
SET(OPENJPEG_INSTALL_MAN_DIR "share/man/")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_MAN_DIR)
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_DOC_DIR)
|
||||
SET(OPENJPEG_INSTALL_DOC_DIR "share/doc/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
SET(OPENJPEG_INSTALL_DOC_DIR "share/doc/${subdir}")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_DOC_DIR)
|
||||
|
||||
if(NOT OPENJPEG_INSTALL_JNI_DIR)
|
||||
if(WIN32)
|
||||
set(OPENJPEG_INSTALL_JNI_DIR ${OPENJPEG_INSTALL_BIN_DIR})
|
||||
else()
|
||||
set(OPENJPEG_INSTALL_JNI_DIR ${OPENJPEG_INSTALL_LIB_DIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
IF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||
# We could install *.cmake files in share/ however those files contains
|
||||
# hardcoded path to libraries on a multi-arch system (fedora/debian) those
|
||||
# path will be different (lib/i386-linux-gnu vs lib/x86_64-linux-gnu)
|
||||
SET(OPENJPEG_INSTALL_PACKAGE_DIR "${OPENJPEG_INSTALL_LIB_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
|
||||
SET(OPENJPEG_INSTALL_PACKAGE_DIR ${OPENJPEG_INSTALL_LIB_DIR}/${subdir}
|
||||
CACHE INTERNAL "")
|
||||
ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Big endian test:
|
||||
INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
|
||||
TEST_BIG_ENDIAN(OPJ_BIG_ENDIAN)
|
||||
# Test for some required system information.
|
||||
INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Setup file for setting custom ctest vars
|
||||
CONFIGURE_FILE(
|
||||
${CMAKE_SOURCE_DIR}/CMake/CTestCustom.cmake.in
|
||||
${CMAKE_BINARY_DIR}/CTestCustom.cmake
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMake/CTestCustom.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
|
||||
@ONLY
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# OpenJPEG build configuration options.
|
||||
OPTION(BUILD_SHARED_LIBS "Build OpenJPEG shared library and link executables against it." ON)
|
||||
OPTION(BUILD_SHARED_LIBS "Build OpenJPEG with shared libraries." OFF)
|
||||
OPTION(ENABLE_PROFILING "Enable profiling for the library" 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)
|
||||
|
||||
|
||||
# configure name mangling to allow multiple libraries to coexist
|
||||
# peacefully
|
||||
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
||||
SET(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
|
||||
@ONLY)
|
||||
@ONLY IMMEDIATE)
|
||||
ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# pkgconfig support
|
||||
IF(UNIX)
|
||||
# install in lib and not share (see multi-arch note above)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libopenjpeg1.pc.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc @ONLY)
|
||||
INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenjpeg1.pc DESTINATION
|
||||
${OPENJPEG_INSTALL_LIB_DIR}/pkgconfig )
|
||||
INSTALL( CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
\"libopenjpeg1.pc\"
|
||||
\"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_SHARE_DIR}/pkgconfig/libopenjpeg.pc\")")
|
||||
ENDIF(UNIX)
|
||||
# Configure files with settings for use by the build.
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/opj_configure.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/opj_configure.h)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Always build the library
|
||||
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
SUBDIRS(
|
||||
libopenjpeg
|
||||
# mj2
|
||||
#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 CDash+CMake
|
||||
OPTION(BUILD_TESTING "Build the tests." OFF)
|
||||
IF(BUILD_TESTING)
|
||||
ENABLE_TESTING()
|
||||
INCLUDE(CTest)
|
||||
ENDIF(BUILD_TESTING)
|
||||
|
||||
IF(BUILD_TESTING)
|
||||
SET(CMAKE_MODULE_PATH "${OPENJPEG_SOURCE_DIR}/CMake")
|
||||
FIND_PACKAGE(FreeImage)
|
||||
|
||||
SUBDIRS(
|
||||
test_V2_tile_handling
|
||||
)
|
||||
if(FREEIMAGE_FOUND)
|
||||
INCLUDE_DIRECTORIES( ${FREEIMAGE_INCLUDE_PATH} )
|
||||
SUBDIRS(
|
||||
test_Free_image_V2_tile_handling
|
||||
)
|
||||
endif(FREEIMAGE_FOUND)
|
||||
ENDIF(BUILD_TESTING)
|
||||
|
||||
# Adding test with dataset from:
|
||||
# http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
|
||||
# -> wget http://www.crc.ricoh.com/~gormish/jpeg2000conformance/j2kp4files_v1_5.zip
|
||||
# http://www.jpeg.org/jpeg2000guide/testimages/testimages.html
|
||||
#-----------------------------------------------------------------------------
|
||||
# Adding JPEG2000_CONFORMANCE_DATA_ROOT
|
||||
FIND_PATH(JPEG2000_CONFORMANCE_DATA_ROOT testimages.html
|
||||
${OPENJPEG_SOURCE_DIR}/../jpeg2000testimages
|
||||
$ENV{JPEG2000_CONFORMANCE_DATA_ROOT}
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Compiler specific flags:
|
||||
@@ -203,94 +189,11 @@ IF(CMAKE_COMPILER_IS_GNUCC)
|
||||
# For all builds, make sure openjpeg is std99 compliant:
|
||||
# SET(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
|
||||
# Do not use ffast-math for all build, it would produce incorrect results, only set for release:
|
||||
SET(OPENJPEG_LIBRARY_COMPILE_OPTIONS ${OPENJPEG_LIBRARY_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>")
|
||||
SET(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCC)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# opj_config.h generation (1/2)
|
||||
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||
CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
|
||||
CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
|
||||
CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
|
||||
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
|
||||
CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H)
|
||||
CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
|
||||
CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
|
||||
CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
|
||||
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Build Library
|
||||
INCLUDE_DIRECTORIES(BEFORE ${OPENJPEG_BINARY_DIR})
|
||||
ADD_SUBDIRECTORY(libopenjpeg)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Build Applications
|
||||
OPTION(BUILD_CODEC "Build the CODEC executables" ON)
|
||||
OPTION(BUILD_MJ2 "Build the MJ2 executables." OFF)
|
||||
OPTION(BUILD_JPWL "Build the JPWL library and executables" OFF)
|
||||
OPTION(BUILD_JPIP "Build the JPIP library and executables." OFF)
|
||||
IF(BUILD_JPIP)
|
||||
OPTION(BUILD_JPIP_SERVER "Build the JPIP server." OFF)
|
||||
ENDIF(BUILD_JPIP)
|
||||
OPTION(BUILD_VIEWER "Build the OPJViewer executable (C++)" OFF)
|
||||
OPTION(BUILD_JAVA "Build the openjpeg jar (Java)" OFF)
|
||||
OPTION(USE_SYSTEM_GETOPT "Prefer system installed getopt()" OFF)
|
||||
MARK_AS_ADVANCED(USE_SYSTEM_GETOPT)
|
||||
MARK_AS_ADVANCED(BUILD_VIEWER)
|
||||
MARK_AS_ADVANCED(BUILD_JAVA)
|
||||
|
||||
IF(BUILD_CODEC OR BUILD_MJ2)
|
||||
# OFF: It will only build 3rd party libs if they are not found on the system
|
||||
# ON: 3rd party libs will ALWAYS be build, and used
|
||||
OPTION(BUILD_THIRDPARTY "Build the thirdparty executables if it is needed" OFF)
|
||||
ADD_SUBDIRECTORY(thirdparty)
|
||||
ADD_SUBDIRECTORY(applications)
|
||||
ENDIF (BUILD_CODEC OR BUILD_MJ2)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# opj_config.h generation (2/2)
|
||||
CONFIGURE_FILE("${OPENJPEG_SOURCE_DIR}/opj_config.h.cmake.in"
|
||||
"${OPENJPEG_BINARY_DIR}/opj_config.h"
|
||||
@ONLY
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
|
||||
OPTION(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
|
||||
IF(BUILD_DOC)
|
||||
ADD_SUBDIRECTORY(doc)
|
||||
ENDIF(BUILD_DOC)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Buld Testing
|
||||
OPTION(BUILD_TESTING "Build the tests." OFF)
|
||||
IF(BUILD_TESTING)
|
||||
IF(BUILD_CODEC)
|
||||
ENABLE_TESTING()
|
||||
INCLUDE(CTest)
|
||||
|
||||
# Search openjpeg data needed for the tests
|
||||
# They could be found via svn on the OpenJPEG google code project
|
||||
# svn checkout http://openjpeg.googlecode.com/svn/data (about 70 Mo)
|
||||
FIND_PATH(OPJ_DATA_ROOT README-OPJ-Data
|
||||
PATHS $ENV{OPJ_DATA_ROOT} ${CMAKE_SOURCE_DIR}/../data
|
||||
${CMAKE_SOURCE_DIR}/../../data
|
||||
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
|
||||
# Add repository where to find tests
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
|
||||
ELSE(BUILD_CODEC)
|
||||
message(FATAL_ERROR "You need build codec to run the tests")
|
||||
ENDIF(BUILD_CODEC)
|
||||
ENDIF(BUILD_TESTING)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# install all targets referenced as OPENJPEGTargets
|
||||
INSTALL(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
|
||||
install(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
|
||||
CONFIGURE_FILE( ${OPENJPEG_SOURCE_DIR}/CMake/OpenJPEGConfig.cmake.in
|
||||
${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||
@ONLY
|
||||
@@ -299,11 +202,3 @@ INSTALL( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
|
||||
DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# install CHANGES and LICENSE
|
||||
IF(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
|
||||
INSTALL(FILES CHANGES DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||
ENDIF(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
|
||||
INSTALL(FILES LICENSE DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
|
||||
|
||||
INCLUDE (CMake/OpenJPEGCPack.cmake)
|
||||
|
||||
114
INSTALL
114
INSTALL
@@ -1,114 +0,0 @@
|
||||
|
||||
How to build and install openjpeg binaries
|
||||
==========================================
|
||||
|
||||
UNIX/LINUX similar systems
|
||||
--------------------------
|
||||
|
||||
1) Using autotools
|
||||
|
||||
It is highly recommended that pkg-config is installed. If needed, you have to
|
||||
properly set the environment variable PKG_CONFIG_PATH so that the .pc files
|
||||
are found.
|
||||
|
||||
To build from top-level directory, you can simply type:
|
||||
./bootstrap.sh
|
||||
./configure
|
||||
make
|
||||
|
||||
To keep all build files in a separate directory, you can type instead:
|
||||
./bootstrap.sh
|
||||
mkdir build
|
||||
cd build
|
||||
../configure
|
||||
make
|
||||
|
||||
To install:
|
||||
sudo make install
|
||||
|
||||
To clean:
|
||||
make clean
|
||||
make distclean
|
||||
|
||||
To build doc (requires 'doxygen' to be found on your system):
|
||||
(this will create an html directory in TOP_LEVEL/doc)
|
||||
make doc
|
||||
|
||||
Main './configure' options (type './configure --help' for more details)
|
||||
'--enable-mj2'
|
||||
'--enable-jpwl'
|
||||
'--enable-jpip'
|
||||
'--prefix=/path/to/install/directory' (example : '--prefix=$PWD/installed')
|
||||
'--enable-debug' (default : disabled)
|
||||
|
||||
You can also specify your own CFLAGS and LDFLAGS with (for example):
|
||||
CFLAGS="-O3 -pipe" LDFLAGS="-Wl,-s" ./configure
|
||||
|
||||
The (optional) dependencies of some binaries are libpng, libtiff, libcms 1 or 2
|
||||
and FastCGI. Only libtiff and FastCGI have no .pc file. There should be some
|
||||
automatic detection if they are installed in /usr, /usr/local or /opt/local.
|
||||
Otherwise, you can tune their detection (as well as for libpng and libcms1 or 2
|
||||
too) with the environment variables:
|
||||
|
||||
TIFF_CFLAGS
|
||||
TIFF_LIBS
|
||||
FCGI_CFLAGS
|
||||
FCGI_LIBS
|
||||
|
||||
See './configure --help' output for more details.
|
||||
|
||||
|
||||
2) Using cmake (see www.cmake.org)
|
||||
|
||||
Type:
|
||||
cmake .
|
||||
make
|
||||
|
||||
If you are root:
|
||||
make install
|
||||
|
||||
else if you have sudo power:
|
||||
sudo make install
|
||||
|
||||
else
|
||||
DESTDIR=$HOME/local make install
|
||||
|
||||
To build the Doxygen documentation (Doxygen needs to be found on the system):
|
||||
(A 'html' directory is generated in the 'doc' directory)
|
||||
make doc
|
||||
|
||||
Binaries are located in the 'bin' directory.
|
||||
|
||||
Main available cmake flags:
|
||||
* To specify the install path: '-DCMAKE_INSTALL_PREFIX=/path', or use DESTDIR env variable (see above)
|
||||
* To build the shared libraries and links the executables against it: '-DBUILD_SHARED_LIBS:bool=on' (default: 'ON')
|
||||
Note: when using this option, static libraries are not built and executables are dynamically linked.
|
||||
* To build the CODEC executables: '-DBUILD_CODEC:bool=on' (default: 'ON')
|
||||
* To build the MJ2 executables: '-DBUILD_MJ2:bool=on' (default: 'OFF')
|
||||
* To build the JPWL executables and JPWL library: '-DBUILD_JPWL:bool=on' (default: 'OFF')
|
||||
* To build the JPIP library and utilities: '-DBUILD_JPIP:bool=on' (default: 'OFF')
|
||||
* To enable testing (and automatic result upload to http://my.cdash.org/index.php?project=OPENJPEG):
|
||||
cmake . -DBUILD_TESTING:BOOL=ON -DOPJ_DATA_ROOT:PATH='path/to/the/data/directory'
|
||||
make
|
||||
make Experimental
|
||||
Note : JPEG2000 test files are available with 'svn checkout http://openjpeg.googlecode.com/svn/data' (about 70 Mo).
|
||||
If '-DOPJ_DATA_ROOT:PATH' option is omitted, test files will be automatically searched in '${CMAKE_SOURCE_DIR}/../data',
|
||||
corresponding to the location of the data directory when compiling from the trunk (and assuming the data directory has
|
||||
been checked out of course).
|
||||
|
||||
MACOSX
|
||||
------
|
||||
|
||||
The same building procedures as above (autotools and cmake) work for MACOSX.
|
||||
The xcode project file can also be used.
|
||||
|
||||
If it does not work, try adding the following flag to the cmake command :
|
||||
'-DCMAKE_OSX_ARCHITECTURES:STRING=i386'
|
||||
|
||||
WINDOWS
|
||||
-------
|
||||
|
||||
If you're using cygwin or MinGW+MSYS, the same procedures as for Unix can be used.
|
||||
|
||||
Otherwise you can use cmake to generate project files for the IDE you are using (VC2010, etc).
|
||||
Type 'cmake --help' for available generators on your platform.
|
||||
11
LICENSE
11
LICENSE
@@ -1,11 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2012, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2012, Professor Benoit Macq
|
||||
* Copyright (c) 2003-2012, Antonin Descampe
|
||||
* Copyright (c) 2003-2009, Francois-Olivier Devaux
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 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
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
75
Makefile.am
75
Makefile.am
@@ -1,75 +0,0 @@
|
||||
DISTCHECK_CONFIGURE_FLAGS = --enable-jpip=yes --enable-jpip-server=yes --enable-jpwl=yes --enable-mj2=yes
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
SUBDIRS = libopenjpeg applications doc
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libopenjpeg1.pc
|
||||
|
||||
if WANT_JPWL
|
||||
pkgconfig_DATA += libopenjpeg-jpwl.pc
|
||||
endif
|
||||
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
Makefile.in \
|
||||
aclocal.m4 \
|
||||
config.guess \
|
||||
opj_config.h.in \
|
||||
opj_config.h.in~ \
|
||||
config.sub \
|
||||
configure \
|
||||
depcomp \
|
||||
install-sh \
|
||||
ltmain.sh \
|
||||
missing
|
||||
|
||||
EXTRA_DIST = \
|
||||
CMake/CTestCustom.cmake.in \
|
||||
CMake/FindFCGI.cmake \
|
||||
CMake/FindLCMS2.cmake \
|
||||
CMake/FindLCMS.cmake \
|
||||
CMake/OpenJPEGConfig.cmake.in \
|
||||
CMakeLists.txt \
|
||||
CTestConfig.cmake \
|
||||
AUTHORS \
|
||||
CHANGES \
|
||||
INSTALL \
|
||||
LICENSE \
|
||||
NEWS \
|
||||
README \
|
||||
THANKS \
|
||||
bootstrap.sh \
|
||||
libopenjpeg1.pc.cmake \
|
||||
libopenjpeg1.pc.in \
|
||||
libopenjpeg-jpwl.pc.in \
|
||||
opj_config.h.cmake.in \
|
||||
m4/opj_check_lib.m4 \
|
||||
m4/opj_doxygen.m4 \
|
||||
m4/pkg.m4
|
||||
|
||||
.PHONY: doc
|
||||
|
||||
# Documentation
|
||||
|
||||
doc:
|
||||
@echo "entering doc/"
|
||||
@cd doc && make doc
|
||||
|
||||
install-data-hook:
|
||||
if HAVE_WIN32
|
||||
$(LN_S) -f libopenjpeg1.pc $(DESTDIR)$(pkgconfigdir)/libopenjpeg.pc
|
||||
else
|
||||
$(LN_S) -nf libopenjpeg1.pc $(DESTDIR)$(pkgconfigdir)/libopenjpeg.pc
|
||||
endif
|
||||
@echo -e " (PC)\t$(pkgconfigdir)/libopenjpeg1.pc" >> $(top_builddir)/report.txt
|
||||
@echo -e " (LN)\t$(pkgconfigdir)/libopenjpeg.pc" >> $(top_builddir)/report.txt
|
||||
if WANT_JPWL
|
||||
@echo -e " (PC)\t$(pkgconfigdir)/libopenjpeg-jpwl.pc" >> $(top_builddir)/report.txt
|
||||
endif
|
||||
@cat $(top_builddir)/report.txt
|
||||
@rm $(top_builddir)/report.txt
|
||||
|
||||
uninstall-hook:
|
||||
rm -f $(DESTDIR)$(pkgconfigdir)/libopenjpeg.pc
|
||||
24
NEWS
24
NEWS
@@ -1,24 +0,0 @@
|
||||
|
||||
OpenJPEG NEWS - user visible changes
|
||||
====================================
|
||||
|
||||
Changes from OpenJPEG 1.5.1 to OpenJPEG 1.5.0
|
||||
----------------------------------------------
|
||||
|
||||
Security:
|
||||
|
||||
* Fixes: CVE-2012-3535
|
||||
* Fixes: CVE-2012-3358
|
||||
|
||||
New Features:
|
||||
|
||||
* Use a new API scheme and solve the SOVERSIONing in OpenJPEG
|
||||
* Allow better integration with multi-arch system
|
||||
* Compile & Install Java bindings (CMake)
|
||||
* Install required addXMLinJP2 (JPIP)
|
||||
|
||||
Misc:
|
||||
|
||||
* fix linker error by resolving all symbols (eg. missing -lm)
|
||||
* fix some man page typos
|
||||
* Huge amount of bug fixes. See CHANGES for details.
|
||||
109
OpenJPEG.rc
Normal file
109
OpenJPEG.rc
Normal file
@@ -0,0 +1,109 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// French (France) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,1,0,0
|
||||
PRODUCTVERSION 1,1,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "000004b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "The OpenJPEG library is an open-source JPEG 2000 codec. \0"
|
||||
VALUE "CompanyName", "OpenJPEG\0"
|
||||
VALUE "FileDescription", "OpenJPEG\0"
|
||||
VALUE "FileVersion", "1, 1, 0, 0\0"
|
||||
VALUE "InternalName", "OpenJPEG\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"
|
||||
VALUE "ProductName", "OpenJPEG\0"
|
||||
VALUE "ProductVersion", "1, 1, 0, 0\0"
|
||||
VALUE "SpecialBuild", "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x0, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // French (France) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
25
README
25
README
@@ -1,25 +0,0 @@
|
||||
|
||||
OPENJPEG LIBRARY and APPLICATIONS
|
||||
----------------------------------
|
||||
|
||||
Details on folders hierarchy:
|
||||
|
||||
* libopenjpeg: contains the sources of the openjpeg library
|
||||
* jpwl: contains the additional sources if you want to build a JPWL-flavoured library.
|
||||
* applications: contains all applications that use the openjpeg library
|
||||
* common: common files to all applications
|
||||
* codec: a basic codec
|
||||
* mj2: motion jpeg 2000 executables
|
||||
* JavaOpenJPEG: java jni to use openjpeg in a java program
|
||||
* jpip: complete client-server architecture for remote browsing of jpeg 2000 images. See corresponding README for more details.
|
||||
* OPJViewer: gui for displaying j2k files (based on wxWidget)
|
||||
* thirdparty: thirdparty libraries used by some applications. These libraries will be built only if there are not found on the system. Note that libopenjpeg itself does not have any dependency.
|
||||
* doc: doxygen documentation setup file and man pages
|
||||
* tests: configuration files and utilities for the openjpeg test suite. All test images are located in 'http://openjpeg.googlecode.com/svn/data' folder.
|
||||
* CMake: cmake related files
|
||||
* m4: autotools related files
|
||||
|
||||
see LICENSE for license and copyright information.
|
||||
see INSTALL for installation procedures.
|
||||
see NEWS for user visible changes in successive releases.
|
||||
see CHANGES for per-revision changes.
|
||||
9
README.cmake
Normal file
9
README.cmake
Normal file
@@ -0,0 +1,9 @@
|
||||
Basic instructions on how to build using CMake (CMake 2.4.5 or newer is required)
|
||||
|
||||
svn co http://www.openjpeg.org/svn/trunk
|
||||
cd trunk
|
||||
mkdir bin
|
||||
cd bin
|
||||
cmake .. -DBUILD_EXAMPLES:BOOL=ON
|
||||
make
|
||||
./bin/j2k_to_image
|
||||
26
README.v2
Normal file
26
README.v2
Normal file
@@ -0,0 +1,26 @@
|
||||
Preliminary notes
|
||||
-----------------
|
||||
|
||||
The Version 2 of openjpeg has been currently added as a branch on the repository.
|
||||
|
||||
All the trunk has been copied and files that needed to change have been patched. In comparison with the trunk, the 'jp3d' directory has been removed because it's based on a modified version of libopenjpeg version 1 and there is no plan to make it reach the version 2 status. Idem with the 'indexer_JPIP', which is obsolete and should be rewritten from scratch.
|
||||
|
||||
At the time of the branch creation, the following files and directories have been updated (or added) for version 2 :
|
||||
* libopenjpeg/
|
||||
* codec/
|
||||
* test_Free_image_V2_tile_handling/ : a test program that uses libopenjpeg v2 and libfreeimage (see libs) to implement a basic codec.
|
||||
* test_V2_tile_handling/ : a test program that generates a random image and (de)compresses it with libopenjpeg v2.
|
||||
* CMakeLists.txt
|
||||
* Free_CMakeImport.cmake
|
||||
* opj_configure.h.in
|
||||
|
||||
Other files and directories from the trunk (project files, jpwl/, OPJViewer/, ...) have also been copied in the branch and should be modified progressively to comply with v2. Check the Changelog for updates on this topic.
|
||||
|
||||
Enjoy v2 and feel free to contribute !
|
||||
|
||||
|
||||
Instructions to compile v2
|
||||
--------------------------
|
||||
|
||||
to be added.
|
||||
|
||||
33
THANKS
33
THANKS
@@ -1,33 +0,0 @@
|
||||
OpenJPEG THANKS file
|
||||
|
||||
Many people have contributed to OpenJPEG by reporting problems, suggesting various improvements,
|
||||
or submitting actual code. Here is a list of these people. Help me keep
|
||||
it complete and exempt of errors.
|
||||
|
||||
Mathieu Malaterre
|
||||
Winfried Szukalski
|
||||
Vincent Torri
|
||||
Bob Friesenhahn
|
||||
Callum Lerwick
|
||||
Dzonatas Sol
|
||||
Mickaël Savinaud
|
||||
Julien Malik
|
||||
Jerôme Fimes
|
||||
Herve Drolon
|
||||
Yannick Verschueren
|
||||
Sebastien Lugan
|
||||
Kaori Hagihara
|
||||
Peter Wimmer
|
||||
Francois-Olivier Devaux
|
||||
Antonin Descampe
|
||||
David Janssens
|
||||
Pr. Benoit Macq
|
||||
Luis Ibanez
|
||||
Ben Boeckel
|
||||
Vincent Nicolas
|
||||
Glenn Pearson
|
||||
Giuseppe Baruffa
|
||||
Arnaud Maye
|
||||
Rex Dieter
|
||||
David Burken
|
||||
Parvatha Elangovan
|
||||
@@ -1,22 +0,0 @@
|
||||
# Build the each application if it needed
|
||||
|
||||
IF(BUILD_CODEC)
|
||||
ADD_SUBDIRECTORY(codec)
|
||||
ENDIF(BUILD_CODEC)
|
||||
|
||||
IF(BUILD_MJ2)
|
||||
ADD_SUBDIRECTORY(mj2)
|
||||
ENDIF(BUILD_MJ2)
|
||||
|
||||
# Client & Server:
|
||||
IF(BUILD_JPIP)
|
||||
ADD_SUBDIRECTORY(jpip)
|
||||
ENDIF(BUILD_JPIP)
|
||||
|
||||
IF(BUILD_VIEWER)
|
||||
ADD_SUBDIRECTORY(OPJViewer)
|
||||
ENDIF(BUILD_VIEWER)
|
||||
|
||||
IF(BUILD_JAVA)
|
||||
ADD_SUBDIRECTORY(JavaOpenJPEG)
|
||||
ENDIF(BUILD_JAVA)
|
||||
@@ -1,82 +0,0 @@
|
||||
#JavaOpenJPEG/CMakeLists.txt
|
||||
|
||||
# First thing define the common source:
|
||||
SET(openjpegjni_SRCS
|
||||
JavaOpenJPEGDecoder.c
|
||||
JavaOpenJPEG.c
|
||||
${OPENJPEG_SOURCE_DIR}/applications/codec/index.c
|
||||
${OPENJPEG_SOURCE_DIR}/applications/codec/convert.c
|
||||
#${OPENJPEG_SOURCE_DIR}/applications/common/color.c
|
||||
)
|
||||
if(NOT USE_SYSTEM_GETOPT)
|
||||
list(APPEND openjpegjni_SRCS
|
||||
${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c
|
||||
)
|
||||
endif()
|
||||
|
||||
# JNI binding:
|
||||
find_package(JNI REQUIRED)
|
||||
include_directories(${JNI_INCLUDE_DIRS})
|
||||
|
||||
# required header file:
|
||||
include_directories(
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||
${OPENJPEG_SOURCE_DIR}/applications/common
|
||||
${OPENJPEG_SOURCE_DIR}/applications/codec
|
||||
)
|
||||
|
||||
add_library(openjpegjni MODULE
|
||||
${openjpegjni_SRCS}
|
||||
)
|
||||
# Java module should not have a SONAME:
|
||||
set_property(TARGET openjpegjni PROPERTY NO_SONAME 1)
|
||||
|
||||
TARGET_LINK_LIBRARIES(openjpegjni ${OPENJPEG_LIBRARY_NAME})
|
||||
|
||||
if(UNIX)
|
||||
target_link_libraries(openjpegjni m)
|
||||
endif()
|
||||
|
||||
INSTALL(TARGETS openjpegjni
|
||||
EXPORT OpenJPEGTargets
|
||||
LIBRARY DESTINATION ${OPENJPEG_INSTALL_JNI_DIR} COMPONENT Libraries
|
||||
)
|
||||
|
||||
# build jar:
|
||||
FIND_PACKAGE(Java 1.5 REQUIRED) # javac, jar
|
||||
|
||||
# User can override this:
|
||||
if(NOT DEFINED JAVA_SOURCE_VERSION)
|
||||
set(JAVA_SOURCE_VERSION 1.5)
|
||||
endif()
|
||||
if(NOT DEFINED JAVA_TARGET_VERSION)
|
||||
set(JAVA_TARGET_VERSION 1.5)
|
||||
endif()
|
||||
|
||||
# build dep list:
|
||||
file(GLOB java_srcs "java-sources/org/openJpeg/*.java")
|
||||
|
||||
# make sure target javac dir exists:
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes)
|
||||
# Build java
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
||||
COMMAND ${Java_JAVAC_EXECUTABLE}
|
||||
-source ${JAVA_SOURCE_VERSION} -target ${JAVA_TARGET_VERSION}
|
||||
-sourcepath "${CMAKE_CURRENT_SOURCE_DIR}/java-sources"
|
||||
${java_srcs} -d ${CMAKE_CURRENT_BINARY_DIR}/classes
|
||||
COMMAND ${Java_JAR_EXECUTABLE} cvf ${LIBRARY_OUTPUT_PATH}/openjpeg.jar org
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/classes
|
||||
DEPENDS ${java_srcs}
|
||||
COMMENT "javac *.java; jar cvf -> openjpeg.jar"
|
||||
)
|
||||
|
||||
# name the target
|
||||
ADD_CUSTOM_TARGET(OpenJPEGJavaJar ALL
|
||||
DEPENDS ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
||||
COMMENT "building openjpeg.jar"
|
||||
)
|
||||
|
||||
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/openjpeg.jar
|
||||
DESTINATION ${OPENJPEG_INSTALL_SHARE_DIR} COMPONENT JavaModule
|
||||
)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,905 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 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 "opj_getopt.h"
|
||||
#include "convert.h"
|
||||
#include "dirent.h"
|
||||
#include "org_openJpeg_OpenJPEGJavaDecoder.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#define stricmp strcasecmp
|
||||
#define strnicmp strncasecmp
|
||||
#endif
|
||||
|
||||
#include "format_defs.h"
|
||||
|
||||
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 * const argv[], opj_dparameters_t *parameters,img_fol_t *img_fol) {
|
||||
/* parse the command line */
|
||||
int totlen;
|
||||
opj_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 = opj_getopt_long(argc, argv,optlist,long_option,totlen);
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
case 'i': /* input file */
|
||||
{
|
||||
char *infile = opj_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 = opj_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 = opj_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(opj_optarg, "%d", ¶meters->cp_reduce);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
|
||||
case 'l': /* layering option */
|
||||
{
|
||||
sscanf(opj_optarg, "%d", ¶meters->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(opj_optarg) + 1);
|
||||
|
||||
if(img_fol->imgdirpath == NULL) return 1;
|
||||
|
||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||
img_fol->set_imgdir=1;
|
||||
}
|
||||
break;
|
||||
/* ----------------------------------------------------- */
|
||||
/* UniPG>> */
|
||||
#ifdef USE_JPWL
|
||||
|
||||
case 'W': /* activate JPWL correction */
|
||||
{
|
||||
char *token = NULL;
|
||||
|
||||
token = strtok(opj_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, opj_optarg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* No check for possible errors before the -i and -o options are of course not mandatory*/
|
||||
|
||||
return 0;
|
||||
}/* parse_cmdline_decoder() */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
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);
|
||||
}
|
||||
|
||||
#define FAILS -1
|
||||
#define OK 0
|
||||
/* --------------------------------------------------------------------------
|
||||
-------------------- MAIN METHOD, CALLED BY JAVA -----------------------*/
|
||||
JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2KtoImage(JNIEnv *env, jobject obj, jobjectArray javaParameters) {
|
||||
int argc; /* To simulate the command line parameters (taken from the javaParameters variable) and be able to re-use the */
|
||||
const char **argv; /* 'parse_cmdline_decoder' method taken from the j2k_to_image project */
|
||||
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 */
|
||||
jint retval = FAILS;
|
||||
|
||||
/* 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 */
|
||||
|
||||
arraySize = (*env)->GetArrayLength(env, javaParameters);
|
||||
argc = (int) arraySize +1;
|
||||
argv = (const char **)malloc(argc*sizeof(char*));
|
||||
|
||||
if(argv == NULL) return FAILS;
|
||||
|
||||
argv[0] = "ProgramName.exe";/* The program name: useless */
|
||||
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(¶meters);
|
||||
parameters.decod_format = J2K_CFMT;
|
||||
|
||||
/* parse input and get user encoding parameters */
|
||||
j = parse_cmdline_decoder(argc, (char * const*)argv, ¶meters,&img_fol);
|
||||
|
||||
/* Release the Java arguments array */
|
||||
for (i=1; i<argc; i++)
|
||||
(*env)->ReleaseStringUTFChars(env,
|
||||
(*env)->GetObjectArrayElement(env, javaParameters, i-1), argv[i]);
|
||||
|
||||
if(j == 1) goto fin; /* failure */
|
||||
|
||||
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);
|
||||
goto fin;
|
||||
}
|
||||
fseek(fsrc, 0, SEEK_END);
|
||||
file_length = ftell(fsrc);
|
||||
fseek(fsrc, 0, SEEK_SET);
|
||||
src = (unsigned char *) malloc(file_length);
|
||||
|
||||
if(src == NULL) goto fin;
|
||||
|
||||
fread(src, 1, file_length, fsrc);
|
||||
fclose(fsrc);
|
||||
/* printf("C: %d bytes read from file\n",file_length); */
|
||||
} else {
|
||||
/* Preparing the transfer of the codestream from Java to C */
|
||||
/* printf("C: before transferring 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, ¶meters);
|
||||
|
||||
/* 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);
|
||||
goto fin;
|
||||
}
|
||||
|
||||
/* 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, ¶meters);
|
||||
|
||||
/* 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);
|
||||
goto fin;
|
||||
}
|
||||
|
||||
/* 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, ¶meters);
|
||||
|
||||
/* 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);
|
||||
goto fin;
|
||||
}
|
||||
|
||||
/* 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 = -128;
|
||||
max_value = 127;
|
||||
} else {
|
||||
min_value = 0;
|
||||
max_value = 255;
|
||||
}
|
||||
#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: transferring 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 transferring 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 = -128;
|
||||
max_value = 127;
|
||||
} else {
|
||||
min_value = 0;
|
||||
max_value = 255;
|
||||
}
|
||||
#endif
|
||||
/* printf("C: transferring %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 = -32768;
|
||||
max_value = 32767;
|
||||
} else {
|
||||
min_value = 0;
|
||||
max_value = 65535;
|
||||
}
|
||||
printf("C: minValue = %d, maxValue = %d\n", min_value, max_value);
|
||||
#endif
|
||||
printf("C: transferring %d shorts to Java image16 pointer = %d\n", w*h,ptrSBody);
|
||||
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);
|
||||
|
||||
}
|
||||
retval = OK;
|
||||
|
||||
fin:
|
||||
free(argv);
|
||||
|
||||
return retval;
|
||||
}
|
||||
/* end main MAIN */
|
||||
|
||||
@@ -1,250 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 2002-2007, Patrick Piscaglia, Telemis s.a.
|
||||
* 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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,338 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 2002-2007, Patrick Piscaglia, Telemis s.a.
|
||||
* 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.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/* 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
|
||||
@@ -1,21 +0,0 @@
|
||||
/* 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
|
||||
@@ -1,19 +0,0 @@
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
SUBDIRS = codec
|
||||
|
||||
if WANT_MJ2
|
||||
SUBDIRS += mj2
|
||||
endif
|
||||
|
||||
if WANT_JPIP_CODE
|
||||
SUBDIRS += jpip
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
CMakeLists.txt \
|
||||
common/color.c \
|
||||
common/color.h \
|
||||
common/format_defs.h \
|
||||
common/opj_getopt.c \
|
||||
common/opj_getopt.h
|
||||
@@ -1,25 +0,0 @@
|
||||
PROJECT(viewer CXX)
|
||||
|
||||
FIND_PACKAGE(wxWidgets REQUIRED)
|
||||
INCLUDE(${wxWidgets_USE_FILE})
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../..
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
)
|
||||
|
||||
# original flags:
|
||||
# -DUSE_JPWL -DwxUSE_LIBOPENJPEG -DwxUSE_GUI=1 -DOPJ_STATIC -DOPJ_HTMLABOUT -DOPJ_INICONFIG -DUSE_JPSEC -DOPJ_MANYFORMATS
|
||||
ADD_DEFINITIONS(-DwxUSE_LIBOPENJPEG -DOPENJPEG_VERSION="1.5.0")
|
||||
SET(OPJV_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/imagjpeg2000.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/wxj2kparser.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJViewer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/wxjp2parser.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJDialogs.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJThreads.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/OPJAbout.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../codec/index.c
|
||||
)
|
||||
ADD_EXECUTABLE(opjviewer ${OPJV_SRCS})
|
||||
TARGET_LINK_LIBRARIES(opjviewer ${wxWidgets_LIBRARIES} openjpeg)
|
||||
@@ -1,48 +0,0 @@
|
||||
; Script generated by the Inno Setup Script Wizard.
|
||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
[Setup]
|
||||
AppName=OPJViewer
|
||||
AppVerName=OPJViewer 0.4 beta
|
||||
AppPublisher=OpenJPEG
|
||||
AppPublisherURL=http://www.openjpeg.org
|
||||
AppSupportURL=http://www.openjpeg.org
|
||||
AppUpdatesURL=http://www.openjpeg.org
|
||||
DefaultDirName={pf}\OPJViewer
|
||||
DefaultGroupName=OPJViewer
|
||||
OutputDir=setup
|
||||
OutputBaseFilename=OPJViewer04beta_setup
|
||||
Compression=lzma
|
||||
SolidCompression=true
|
||||
InfoBeforeFile=source\readmebefore.txt
|
||||
InfoAfterFile=source\readmeafter.txt
|
||||
LicenseFile=source\license.txt
|
||||
VersionInfoVersion=0.4.0.0
|
||||
VersionInfoCompany=OpenJPEG
|
||||
VersionInfoDescription=JPEG 2000 viewer
|
||||
ShowLanguageDialog=yes
|
||||
SetupIconFile=source\OPJViewer.ico
|
||||
|
||||
[Languages]
|
||||
Name: english; MessagesFile: compiler:Default.isl
|
||||
|
||||
[Tasks]
|
||||
Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
|
||||
|
||||
[Files]
|
||||
Source: Release\OPJViewer.exe; DestDir: {app}; Flags: ignoreversion
|
||||
;Source: about\about.htm; DestDir: {app}/about; Flags: ignoreversion
|
||||
;Source: about\opj_logo.png; DestDir: {app}/about; Flags: ignoreversion
|
||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||
|
||||
[Icons]
|
||||
Name: {group}\OPJViewer; Filename: {app}\OPJViewer.exe; WorkingDir: {app}; IconIndex: 0
|
||||
Name: {group}\{cm:UninstallProgram,OPJViewer}; Filename: {uninstallexe}
|
||||
Name: {userdesktop}\OPJViewer; Filename: {app}\OPJViewer.exe; Tasks: desktopicon; WorkingDir: {app}; IconIndex: 0
|
||||
|
||||
[Run]
|
||||
Filename: {app}\OPJViewer.exe; Description: {cm:LaunchProgram,OPJViewer}; Flags: nowait postinstall skipifsilent; WorkingDir: {app}
|
||||
|
||||
[Registry]
|
||||
Root: HKCU; Subkey: Software\OpenJPEG; ValueType: none; ValueData: 1; Flags: uninsdeletekey; Tasks: ; Languages:
|
||||
Root: HKCU; Subkey: Software\OpenJPEG\OPJViewer; ValueType: none; ValueData: 1; Flags: uninsdeletekey; Tasks: ; Languages:
|
||||
@@ -1,100 +0,0 @@
|
||||
===============================================================================
|
||||
JPEG2000 Visualization Software - OPJViewer
|
||||
|
||||
Version 0.4 beta
|
||||
===============================================================================
|
||||
|
||||
|
||||
1. Scope
|
||||
=============
|
||||
|
||||
This document describes the installation and use of the OPJViewer in the framework of OpenJPEG library.
|
||||
|
||||
This implementation has been developed using the OpenJPEG library as decoding engine and wxWidgets 2.8 as GUI engine.
|
||||
|
||||
If you find some bugs or if you have problems using the viewer, please send an e-mail to jpwl@diei.unipg.it
|
||||
|
||||
2. Installing the viewer
|
||||
==========================
|
||||
|
||||
There are two options available, at the moment:
|
||||
|
||||
a) compile from source code
|
||||
b) download a precompiled binary.
|
||||
|
||||
In order to use option a), it is mandatory to have compiled and built the LibOpenJPEG_JPWL library and the wxWidgets 2.8 framework (you have to download it from http://www.wxwidgets.org/ and compile the wx* libraries).
|
||||
|
||||
2.1. Compiling the source code in Windows
|
||||
-------------------------------------------
|
||||
|
||||
The steps required to compile the viewer under windows are:
|
||||
|
||||
a) Download at least the libopenjpeg, jpwl, and opjviewer folders from the SVN trunk.
|
||||
b) Open the OPJViewer.dsw workspace with Visual C++ 6 and activate the "OPJViewer - Win32 Release" configuration.
|
||||
c) In the configuration settings, go to the C++ tab and modify the wxWidgets paths in order to reflect your wx* install configuration (Preprocessor -> Additional include directories): simply update each instance of the two wx paths, do not remove or add them.
|
||||
d) In the configuration settings, go to the Link tab and modify the wxWidgets path in order to reflect your wx* install configuration (Input -> Additional library path): simply update the wx path.
|
||||
e) In the configuration settings, go to the Resources tab and modify the wxWidgets path in order to reflect your wx* install configuration (Additional resource include directories): simply update the wx path.
|
||||
f) Build!
|
||||
g) Run!
|
||||
h) (OPTIONAL) Prepare an installer by compiling the InnoSetup script OPJViewer.iss (you need to download InnoSetup from http://www.jrsoftware.org/isinfo.php).
|
||||
|
||||
2.1.1 Additional libraries
|
||||
----------------------------
|
||||
|
||||
Since we are also working on the Digital Cinema JPEG 2000, we are integrating the viewer with the MXF library, which is used to prepare the DCPs for digital movies. You can enable its linking in the code by specifying the USE_MXF preprocessor directive but, remember, the integration is at a very early stage.
|
||||
|
||||
2.2. Compiling the source code in Unix-like systems
|
||||
-----------------------------------------------------
|
||||
|
||||
The porting is possible and under way.
|
||||
|
||||
|
||||
3. General information on the viewer
|
||||
====================================
|
||||
|
||||
This viewer is conceived to open and display information and image content of J2K, JP2, and MJ2 files.
|
||||
The viewer application interface is divided into three main panels:
|
||||
- a browsing pane;
|
||||
- a viewing pane;
|
||||
- a log/peek pane.
|
||||
|
||||
The browsing pane will present the markers or boxes hierarchy, with position (byte number where marker/box starts and stops) and length information (i.e., inner length as signalled by marker/box and total length, with marker/box sign included), in the following form:
|
||||
|
||||
filename
|
||||
|
|
||||
|_ #000: Marker/Box short name (Hex code)
|
||||
| |
|
||||
| |_ *** Marker/Box long name ***
|
||||
| |_ startbyte > stopbyte, inner_length + marker/box sign length (total length)
|
||||
| |_ Additional info, depending on the marker/box type
|
||||
| |_ ...
|
||||
|
|
||||
|_ #001: Marker/Box short name (Hex code)
|
||||
| |
|
||||
| |_ ...
|
||||
|
|
||||
...
|
||||
|
||||
|
||||
The viewing pane will display the decoded image contained in the JPEG 2000 file.
|
||||
It should display correctly images as large as 4000x2000, provided that a couple of GB of RAM are available. Nothing is known about the display of larger sizes: let us know if you manage to get it working.
|
||||
|
||||
|
||||
The log/peek pane is shared among two different subpanels:
|
||||
|
||||
- the log panel will report a lot of debugging info coming out from the wx GUI as well as from the openjpeg library
|
||||
- the peek pane tries to give a peek on the codestream/file portion which is currently selected in the browsing pane. It shows both hex and ascii values corresponding to the marker/box section.
|
||||
|
||||
|
||||
4. Known bugs and limitations
|
||||
===============================
|
||||
|
||||
4.1. Bugs
|
||||
-----------
|
||||
|
||||
*
|
||||
|
||||
4.2. Limitations
|
||||
------------------
|
||||
|
||||
* For mj2 files, rendering is only in B/W
|
||||
@@ -1,36 +0,0 @@
|
||||
<html>
|
||||
<body bgcolor="#FFFFFF">
|
||||
<table cellspacing=7 cellpadding=1 border=0 width="100%">
|
||||
<tr>
|
||||
<td rowspan=3 valign=top align=center width=70>
|
||||
<img src="opj_logo.png"><br><br>
|
||||
</td>
|
||||
<td align=center>
|
||||
<font size=+2 color="#000000"><b>OPJViewer v0.2 alpha</b></font><br>
|
||||
<font size=+0 color="#000000"><b>A JPEG 2000 image viewer</b></font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr height=3 valign=center>
|
||||
<td valign=center bgcolor=#cc3300></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=justify>
|
||||
<center><font size=+0 color="#000000"><a href="http://www.openjpeg.org/">OpenJPEG</a></font></center>
|
||||
<font size=-1 color="#000000">The OpenJPEG library is an open-source JPEG 2000 codec written in C language.
|
||||
In addition to the basic codec, various other features are under development,
|
||||
among them the JP2 and MJ2 (Motion JPEG 2000) file formats, an indexing tool
|
||||
useful for the JPIP protocol, JPWL-tools for error-resilience, ...</font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2 bgcolor="#CC3300" height=3 valign=center></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<font size=-2 color="#444444">OpenJPEG is © 2002-2007 <a href="http://www.tele.ucl.ac.be/">TELE</a> - <a href="http://www.uclouvain.be/">Universit<EFBFBD> Catholique de Louvain</a></font><br>
|
||||
<font size=-2 color="#444444">OPJViewer is also © 2005-2007 <a href="http://dsplab.diei.unipg.it/">DSPLab</a> - <a href="http://www.unipg.it/">Universit<EFBFBD> degli studi di Perugia</a></font>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 6.3 KiB |
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universita'<27> degli studi di Perugia (UPG), Italy
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifdef USE_MXF
|
||||
#include "mxflib/mxflib.h"
|
||||
#endif // USE_MXF
|
||||
|
||||
#include "OPJViewer.h"
|
||||
|
||||
// about window for the frame
|
||||
void OPJFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
#ifdef OPJ_HTMLABOUT
|
||||
#include "about_htm.h"
|
||||
#include "opj_logo.xpm"
|
||||
|
||||
wxBoxSizer *topsizer;
|
||||
wxHtmlWindow *html;
|
||||
wxDialog dlg(this, wxID_ANY, wxString(_("About")));
|
||||
|
||||
wxMemoryFSHandler::AddFile(wxT("opj_logo.xpm"), wxBitmap(opj_logo), wxBITMAP_TYPE_XPM);
|
||||
|
||||
topsizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
html = new wxHtmlWindow(&dlg, wxID_ANY, wxDefaultPosition, wxSize(320, 250), wxHW_SCROLLBAR_NEVER);
|
||||
html->SetBorders(0);
|
||||
//html->LoadPage(wxT("about/about.htm"));
|
||||
//html->SetPage("<html><body>Hello, world!</body></html>");
|
||||
html->SetPage(htmlaboutpage);
|
||||
html->SetSize(html->GetInternalRepresentation()->GetWidth(),
|
||||
html->GetInternalRepresentation()->GetHeight());
|
||||
|
||||
topsizer->Add(html, 1, wxALL, 10);
|
||||
|
||||
topsizer->Add(new wxStaticLine(&dlg, wxID_ANY), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
|
||||
|
||||
wxButton *bu1 = new wxButton(&dlg, wxID_OK, wxT("OK"));
|
||||
bu1->SetDefault();
|
||||
|
||||
topsizer->Add(bu1, 0, wxALL | wxALIGN_RIGHT, 15);
|
||||
|
||||
dlg.SetSizer(topsizer);
|
||||
topsizer->Fit(&dlg);
|
||||
|
||||
dlg.ShowModal();
|
||||
|
||||
#else
|
||||
|
||||
wxMessageBox(wxString::Format(OPJ_APPLICATION_TITLEBAR
|
||||
wxT("\n\n")
|
||||
wxT("Built with %s and OpenJPEG ")
|
||||
wxT(OPENJPEG_VERSION)
|
||||
wxT("\non ") wxT(__DATE__) wxT(", ") wxT(__TIME__)
|
||||
wxT("\nRunning under %s\n\n")
|
||||
OPJ_APPLICATION_COPYRIGHT,
|
||||
wxVERSION_STRING,
|
||||
wxGetOsDescription().c_str()),
|
||||
wxT("About ") OPJ_APPLICATION_NAME,
|
||||
wxOK | wxICON_INFORMATION,
|
||||
this
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -1,28 +0,0 @@
|
||||
/* XPM */
|
||||
static char *OPJChild16[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 16 6 1",
|
||||
" c black",
|
||||
". c #008000",
|
||||
"X c red",
|
||||
"o c #800080",
|
||||
"O c gray100",
|
||||
"+ c None",
|
||||
/* pixels */
|
||||
"++++++++++++++++",
|
||||
"+OOOOOOOOOOOOOO+",
|
||||
"+OooooooooooooO+",
|
||||
"+OooooooooooooO+",
|
||||
"+OooOOOOOOOOOoO+",
|
||||
"+OooO.......OoO+",
|
||||
"+OooO.......OoO+",
|
||||
"+OooO..OOO..OoO+",
|
||||
"+OooO..OXO..OoO+",
|
||||
"+OooO..OOO..OoO+",
|
||||
"+OooO.......OoO+",
|
||||
"+OooO.......OoO+",
|
||||
"+OooOOOOOOOOOoO+",
|
||||
"+OooooooooooooO+",
|
||||
"+OOOOOOOOOOOOOO+",
|
||||
"++++++++++++++++"
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,812 +0,0 @@
|
||||
/*
|
||||
* 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: sashtest.h
|
||||
// Purpose: Layout window/sash sample
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id: sashtest.h,v 1.5 2005/06/02 12:04:24 JS Exp $
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: treectrl.h
|
||||
// Purpose: wxTreeCtrl sample
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id: treetest.h,v 1.50 2006/11/04 11:26:51 VZ Exp $
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dialogs.h
|
||||
// Purpose: Common dialogs demo
|
||||
// Author: Julian Smart
|
||||
// Modified by: ABX (2004) - adjustementd for conditional building
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id: dialogs.h,v 1.50 2006/10/08 14:12:59 VZ Exp $
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __OPJ_VIEWER_H__
|
||||
#define __OPJ_VIEWER_H__
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#include "wx/mdi.h"
|
||||
#endif
|
||||
|
||||
#include "wx/toolbar.h"
|
||||
#include "wx/laywin.h"
|
||||
#include "wx/treectrl.h"
|
||||
|
||||
#include "icon1.xpm"
|
||||
#include "icon2.xpm"
|
||||
#include "icon3.xpm"
|
||||
#include "icon4.xpm"
|
||||
#include "icon5.xpm"
|
||||
|
||||
#include "wx/filedlg.h"
|
||||
#include "wx/toolbar.h"
|
||||
#include <wx/filename.h>
|
||||
#include <wx/busyinfo.h>
|
||||
#include <wx/cmdline.h>
|
||||
#include <wx/file.h>
|
||||
#include "wx/notebook.h"
|
||||
#include <wx/numdlg.h>
|
||||
|
||||
#include "wx/propdlg.h"
|
||||
#include "wx/spinctrl.h"
|
||||
|
||||
#include <wx/dnd.h>
|
||||
#include "wx/wxhtml.h"
|
||||
#include "wx/statline.h"
|
||||
#include <wx/fs_mem.h>
|
||||
|
||||
#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"
|
||||
#include "imagjpeg2000.h"
|
||||
#ifdef USE_MXF
|
||||
#include "imagmxf.h"
|
||||
#endif // USE_MXF
|
||||
|
||||
#ifdef __WXMSW__
|
||||
typedef unsigned __int64 int8byte;
|
||||
#endif // __WXMSW__
|
||||
|
||||
#ifdef __WXGTK__
|
||||
typedef unsigned long long int8byte;
|
||||
#endif // __WXGTK__
|
||||
|
||||
#define USE_GENERIC_TREECTRL 0
|
||||
#define USE_PENCIL_ON_CANVAS 0
|
||||
|
||||
#if USE_GENERIC_TREECTRL
|
||||
#include "wx/generic/treectlg.h"
|
||||
#ifndef wxTreeCtrl
|
||||
#define wxTreeCtrl wxGenericTreeCtrl
|
||||
#define sm_classwxTreeCtrl sm_classwxGenericTreeCtrl
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define OPJ_APPLICATION wxT("OPJViewer")
|
||||
#define OPJ_APPLICATION_NAME wxT("OpenJPEG Viewer")
|
||||
#define OPJ_APPLICATION_VERSION wxT("0.4 beta")
|
||||
#define OPJ_APPLICATION_TITLEBAR OPJ_APPLICATION_NAME wxT(" ") OPJ_APPLICATION_VERSION
|
||||
#define OPJ_APPLICATION_COPYRIGHT wxT("(C) 2007-2008, Giuseppe Baruffa")
|
||||
#define OPJ_APPLICATION_VENDOR wxT("OpenJPEG")
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#define OPJ_APPLICATION_PLATFORM wxT("Windows")
|
||||
#endif
|
||||
|
||||
#ifdef __WXGTK__
|
||||
#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;
|
||||
|
||||
//////////////////////////////////
|
||||
// this is our main application //
|
||||
//////////////////////////////////
|
||||
class OPJViewerApp: public wxApp
|
||||
{
|
||||
// public methods and variables
|
||||
public:
|
||||
|
||||
// class constructor
|
||||
OPJViewerApp() { m_showImages = true; m_showButtons = false; }
|
||||
|
||||
// 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, m_enco_threads;
|
||||
|
||||
// crit section protects access to all of the arrays below
|
||||
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, 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, m_enco_waitingUntilAllDone;
|
||||
|
||||
// the list of all filenames written in the command line
|
||||
wxArrayString m_filelist;
|
||||
|
||||
// displaying engine parameters
|
||||
int m_resizemethod;
|
||||
|
||||
// decoding engine parameters
|
||||
bool m_enabledeco, m_enableparse;
|
||||
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||
#ifdef USE_JPWL
|
||||
bool m_enablejpwl, m_enablejpwle;
|
||||
int m_expcomps, m_maxtiles;
|
||||
#endif // USE_JPWL
|
||||
int m_framewidth, m_frameheight;
|
||||
|
||||
// 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;
|
||||
|
||||
};
|
||||
|
||||
DECLARE_APP(OPJViewerApp)
|
||||
|
||||
///////////////////////////////////////////
|
||||
// this canvas is used to draw the image //
|
||||
///////////////////////////////////////////
|
||||
class OPJCanvas: public wxScrolledWindow
|
||||
{
|
||||
// public methods and variables
|
||||
public:
|
||||
|
||||
// class constructor
|
||||
OPJCanvas(wxFileName fname, wxWindow *parent, const wxPoint& pos, const wxSize& size);
|
||||
|
||||
virtual void OnDraw(wxDC& dc);
|
||||
void OnEvent(wxMouseEvent& event);
|
||||
void WriteText(const wxString& text) {
|
||||
#ifndef __WXGTK__
|
||||
wxMutexGuiEnter();
|
||||
#endif //__WXGTK__
|
||||
wxLogMessage(text);
|
||||
#ifndef __WXGTK__
|
||||
wxMutexGuiLeave();
|
||||
#endif //__WXGTK__
|
||||
}
|
||||
|
||||
void OnThreadSignal(wxCommandEvent& event);
|
||||
|
||||
OPJDecoThread *CreateDecoThread(void);
|
||||
OPJEncoThread *CreateEncoThread(void);
|
||||
|
||||
|
||||
OPJChildFrame *m_childframe;
|
||||
|
||||
wxBitmap m_image, m_image100;
|
||||
wxFileName m_fname, m_savename;
|
||||
long m_zooml;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
// the data associated to each tree leaf or node //
|
||||
///////////////////////////////////////////////////
|
||||
class OPJMarkerData : public wxTreeItemData
|
||||
{
|
||||
// public methods and variables
|
||||
public:
|
||||
|
||||
// class constructor
|
||||
OPJMarkerData(const wxString& desc, const wxString& fname = wxT(""), wxFileOffset start = 0, wxFileOffset length = 0) : m_desc(desc), m_filestring(fname) { m_start = start; m_length = length; }
|
||||
|
||||
void ShowInfo(wxTreeCtrl *tree);
|
||||
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_filestring;
|
||||
};
|
||||
|
||||
|
||||
class OPJMarkerTree : public wxTreeCtrl
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
TreeCtrlIcon_File,
|
||||
TreeCtrlIcon_FileSelected,
|
||||
TreeCtrlIcon_Folder,
|
||||
TreeCtrlIcon_FolderSelected,
|
||||
TreeCtrlIcon_FolderOpened
|
||||
};
|
||||
|
||||
OPJMarkerTree() { };
|
||||
OPJMarkerTree(wxWindow *parent, OPJChildFrame *subframe, wxFileName fname, wxString name, const wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size,
|
||||
long style);
|
||||
virtual ~OPJMarkerTree(){};
|
||||
OPJParseThread *CreateParseThread(wxTreeItemId parentid = 0x00, OPJChildFrame *subframe = NULL);
|
||||
void WriteText(const wxString& text) { wxMutexGuiEnter(); wxLogMessage(text); wxMutexGuiLeave(); }
|
||||
|
||||
wxFileName m_fname;
|
||||
wxTextCtrl *m_peektextCtrl;
|
||||
OPJChildFrame *m_childframe;
|
||||
|
||||
/*void OnBeginDrag(wxTreeEvent& event);
|
||||
void OnBeginRDrag(wxTreeEvent& event);
|
||||
void OnEndDrag(wxTreeEvent& event);*/
|
||||
/*void OnBeginLabelEdit(wxTreeEvent& event);
|
||||
void OnEndLabelEdit(wxTreeEvent& event);*/
|
||||
/*void OnDeleteItem(wxTreeEvent& event);*/
|
||||
/*void OnContextMenu(wxContextMenuEvent& event);*/
|
||||
void OnItemMenu(wxTreeEvent& event);
|
||||
/*void OnGetInfo(wxTreeEvent& event);
|
||||
void OnSetInfo(wxTreeEvent& event);*/
|
||||
/*void OnItemExpanded(wxTreeEvent& event);*/
|
||||
void OnItemExpanding(wxTreeEvent& event);
|
||||
/*void OnItemCollapsed(wxTreeEvent& event);
|
||||
void OnItemCollapsing(wxTreeEvent& event);*/
|
||||
void OnSelChanged(wxTreeEvent& event);
|
||||
/*void OnSelChanging(wxTreeEvent& event);*/
|
||||
/*void OnTreeKeyDown(wxTreeEvent& event);*/
|
||||
/*void OnItemActivated(wxTreeEvent& event);*/
|
||||
/*void OnItemRClick(wxTreeEvent& event);*/
|
||||
/*void OnRMouseDown(wxMouseEvent& event);
|
||||
void OnRMouseUp(wxMouseEvent& event);
|
||||
void OnRMouseDClick(wxMouseEvent& event);*/
|
||||
/*void GetItemsRecursively(const wxTreeItemId& idParent,
|
||||
wxTreeItemIdValue cookie = 0);*/
|
||||
|
||||
void CreateImageList(int size = 16);
|
||||
void CreateButtonsImageList(int size = 11);
|
||||
|
||||
/*void AddTestItemsToTree(size_t numChildren, size_t depth);*/
|
||||
/*void DoSortChildren(const wxTreeItemId& item, bool reverse = false)
|
||||
{ m_reverseSort = reverse; wxTreeCtrl::SortChildren(item); }*/
|
||||
/*void DoEnsureVisible() { if (m_lastItem.IsOk()) EnsureVisible(m_lastItem); }*/
|
||||
/*void DoToggleIcon(const wxTreeItemId& item);*/
|
||||
/*void ShowMenu(wxTreeItemId id, const wxPoint& pt);*/
|
||||
|
||||
int ImageSize(void) const { return m_imageSize; }
|
||||
|
||||
void SetLastItem(wxTreeItemId id) { m_lastItem = id; }
|
||||
|
||||
protected:
|
||||
/*virtual int OnCompareItems(const wxTreeItemId& i1, const wxTreeItemId& i2);*/
|
||||
|
||||
// is this the test item which we use in several event handlers?
|
||||
/*bool IsTestItem(const wxTreeItemId& item)
|
||||
{
|
||||
// the test item is the first child folder
|
||||
return GetItemParent(item) == GetRootItem() && !GetPrevSibling(item);
|
||||
}*/
|
||||
|
||||
private:
|
||||
/*void AddItemsRecursively(const wxTreeItemId& idParent,
|
||||
size_t nChildren,
|
||||
size_t depth,
|
||||
size_t folder);*/
|
||||
|
||||
void LogEvent(const wxChar *name, const wxTreeEvent& event);
|
||||
|
||||
int m_imageSize; // current size of images
|
||||
bool m_reverseSort; // flag for OnCompareItems
|
||||
wxTreeItemId m_lastItem, // for OnEnsureVisible()
|
||||
m_draggedItem; // item being dragged right now
|
||||
|
||||
// NB: due to an ugly wxMSW hack you _must_ use DECLARE_DYNAMIC_CLASS()
|
||||
// if you want your overloaded OnCompareItems() to be called.
|
||||
// OTOH, if you don't want it you may omit the next line - this will
|
||||
// make default (alphabetical) sorting much faster under wxMSW.
|
||||
DECLARE_DYNAMIC_CLASS(OPJMarkerTree)
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// this hash map stores all the trees of currently opened images, with an integer key
|
||||
WX_DECLARE_HASH_MAP(int, OPJMarkerTree*, wxIntegerHash, wxIntegerEqual, OPJMarkerTreeHash);
|
||||
|
||||
// this hash map stores all the children of currently opened images, with an integer key
|
||||
WX_DECLARE_HASH_MAP(int, OPJChildFrame*, wxIntegerHash, wxIntegerEqual, OPJChildFrameHash);
|
||||
|
||||
// Define a new frame
|
||||
class OPJFrame: public wxMDIParentFrame
|
||||
{
|
||||
public:
|
||||
|
||||
OPJFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
|
||||
|
||||
~OPJFrame(void);
|
||||
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& 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);
|
||||
void OnThreadLogmsg(wxCommandEvent& event);
|
||||
|
||||
OPJMarkerTreeHash m_treehash;
|
||||
OPJChildFrameHash m_childhash;
|
||||
wxSashLayoutWindow* markerTreeWindow;
|
||||
wxSashLayoutWindow* loggingWindow;
|
||||
wxToolBar* tool_bar;
|
||||
void Resize(int number);
|
||||
wxNotebook *m_bookCtrl;
|
||||
wxNotebook *m_bookCtrlbottom;
|
||||
wxTextCtrl *m_textCtrlbrowse;
|
||||
|
||||
private:
|
||||
void TogStyle(int id, long flag);
|
||||
|
||||
void DoSort(bool reverse = false);
|
||||
|
||||
wxPanel *m_panel;
|
||||
wxTextCtrl *m_textCtrl;
|
||||
|
||||
void DoSetBold(bool bold = true);
|
||||
|
||||
protected:
|
||||
wxSashLayoutWindow* m_topWindow;
|
||||
wxSashLayoutWindow* m_leftWindow2;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
class OPJChildFrame: public wxMDIChildFrame
|
||||
{
|
||||
public:
|
||||
OPJCanvas *m_canvas;
|
||||
OPJChildFrame(OPJFrame *parent, wxFileName fname, int winnumber, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
|
||||
~OPJChildFrame(void);
|
||||
void OnActivate(wxActivateEvent& event);
|
||||
/*void OnQuit(wxCommandEvent& WXUNUSED(event));*/
|
||||
void OnClose(wxCloseEvent& event);
|
||||
void OnGotFocus(wxFocusEvent& event);
|
||||
void OnLostFocus(wxFocusEvent& event);
|
||||
OPJFrame *m_frame;
|
||||
wxFileName m_fname;
|
||||
int m_winnumber;
|
||||
|
||||
unsigned long m_twidth, m_theight, m_tx, m_ty;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// frame and main menu ids
|
||||
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_TOOLBAR,
|
||||
|
||||
OPJFRAME_THREADLOGMSG,
|
||||
OPJCANVAS_THREADSIGNAL
|
||||
};
|
||||
|
||||
|
||||
// menu and control ids
|
||||
enum
|
||||
{
|
||||
TreeTest_Quit = wxID_EXIT,
|
||||
TreeTest_About = wxID_ABOUT,
|
||||
TreeTest_TogButtons = wxID_HIGHEST,
|
||||
TreeTest_TogTwist,
|
||||
TreeTest_TogLines,
|
||||
TreeTest_TogEdit,
|
||||
TreeTest_TogHideRoot,
|
||||
TreeTest_TogRootLines,
|
||||
TreeTest_TogBorder,
|
||||
TreeTest_TogFullHighlight,
|
||||
TreeTest_SetFgColour,
|
||||
TreeTest_SetBgColour,
|
||||
TreeTest_ResetStyle,
|
||||
TreeTest_Highlight,
|
||||
TreeTest_Dump,
|
||||
TreeTest_DumpSelected,
|
||||
TreeTest_Count,
|
||||
TreeTest_CountRec,
|
||||
TreeTest_Sort,
|
||||
TreeTest_SortRev,
|
||||
TreeTest_SetBold,
|
||||
TreeTest_ClearBold,
|
||||
TreeTest_Rename,
|
||||
TreeTest_Delete,
|
||||
TreeTest_DeleteChildren,
|
||||
TreeTest_DeleteAll,
|
||||
TreeTest_Recreate,
|
||||
TreeTest_ToggleImages,
|
||||
TreeTest_ToggleButtons,
|
||||
TreeTest_SetImageSize,
|
||||
TreeTest_ToggleSel,
|
||||
TreeTest_CollapseAndReset,
|
||||
TreeTest_EnsureVisible,
|
||||
TreeTest_AddItem,
|
||||
TreeTest_InsertItem,
|
||||
TreeTest_IncIndent,
|
||||
TreeTest_DecIndent,
|
||||
TreeTest_IncSpacing,
|
||||
TreeTest_DecSpacing,
|
||||
TreeTest_ToggleIcon,
|
||||
TreeTest_Select,
|
||||
TreeTest_Unselect,
|
||||
TreeTest_SelectRoot,
|
||||
TreeTest_Ctrl = 1000,
|
||||
BOTTOM_NOTEBOOK_ID,
|
||||
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:
|
||||
OPJDecoThread(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 OPJParseThread : public wxThread
|
||||
{
|
||||
public:
|
||||
OPJParseThread(OPJMarkerTree *tree, wxTreeItemId parentid = 0x00);
|
||||
|
||||
// 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);
|
||||
void LoadFile(wxFileName fname);
|
||||
void ParseJ2KFile(wxFile *m_file, wxFileOffset offset, wxFileOffset length, wxTreeItemId parentid);
|
||||
void ParseJP2File(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit, wxTreeItemId parentid);
|
||||
|
||||
unsigned m_count;
|
||||
OPJMarkerTree *m_tree;
|
||||
wxTreeItemId m_parentid;
|
||||
|
||||
private:
|
||||
int jpeg2000parse(wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
|
||||
wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
|
||||
int box_handler_function(int boxtype, wxFile *fileid, wxFileOffset filepoint, wxFileOffset filelimit,
|
||||
wxTreeItemId parentid, int level, char *scansign, unsigned long int *scanpoint);
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Drag and drop files target
|
||||
class OPJDnDFile: public wxFileDropTarget
|
||||
{
|
||||
public:
|
||||
OPJDnDFile(OPJFrame *pOwner) { m_pOwner = pOwner; }
|
||||
virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
|
||||
|
||||
private:
|
||||
OPJFrame *m_pOwner;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Property sheet dialog: encoder
|
||||
class OPJEncoderDialog: public wxPropertySheetDialog
|
||||
{
|
||||
DECLARE_CLASS(OPJEncoderDialog)
|
||||
public:
|
||||
OPJEncoderDialog(wxWindow* parent, int dialogType);
|
||||
~OPJEncoderDialog();
|
||||
|
||||
wxBookCtrlBase* m_settingsNotebook;
|
||||
|
||||
wxPanel* CreateMainSettingsPage(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;*/
|
||||
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,
|
||||
OPJENCO_TILESIZE,
|
||||
OPJENCO_PROGRESSION,
|
||||
OPJENCO_SUBSAMPLING,
|
||||
OPJENCO_ENABLESOP,
|
||||
OPJENCO_ENABLEEPH,
|
||||
OPJENCO_ENABLEBYPASS,
|
||||
OPJENCO_ENABLERESET,
|
||||
OPJENCO_ENABLERESTART,
|
||||
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_POCSPEC,
|
||||
OPJENCO_ENABLECOMM,
|
||||
OPJENCO_COMMENTTEXT,
|
||||
OPJENCO_HPROT,
|
||||
OPJENCO_HTILE,
|
||||
OPJENCO_PPROT,
|
||||
OPJENCO_PTILE,
|
||||
OPJENCO_PPACK,
|
||||
OPJENCO_SENSI,
|
||||
OPJENCO_STILE
|
||||
};
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// Property sheet dialog: decoder
|
||||
class OPJDecoderDialog: public wxPropertySheetDialog
|
||||
{
|
||||
DECLARE_CLASS(OPJDecoderDialog)
|
||||
public:
|
||||
OPJDecoderDialog(wxWindow* parent, int dialogType);
|
||||
~OPJDecoderDialog();
|
||||
|
||||
wxBookCtrlBase* m_settingsNotebook;
|
||||
wxCheckBox *m_enabledecoCheck, *m_enableparseCheck;
|
||||
wxSpinCtrl *m_reduceCtrl, *m_layerCtrl, *m_numcompsCtrl;
|
||||
wxRadioBox* m_resizeBox;
|
||||
|
||||
void OnEnableDeco(wxCommandEvent& event);
|
||||
|
||||
wxPanel* CreateMainSettingsPage(wxWindow* parent);
|
||||
wxPanel* CreatePart1SettingsPage(wxWindow* parent);
|
||||
wxPanel* CreatePart3SettingsPage(wxWindow* parent);
|
||||
#ifdef USE_JPWL
|
||||
void OnEnableJPWL(wxCommandEvent& event);
|
||||
wxPanel* CreatePart11SettingsPage(wxWindow* parent);
|
||||
wxSpinCtrl *m_expcompsCtrl, *m_maxtilesCtrl;
|
||||
wxCheckBox *m_enablejpwlCheck;
|
||||
#endif // USE_JPWL
|
||||
wxSpinCtrl *m_framenumCtrl;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
enum {
|
||||
OPJDECO_RESMETHOD = 100,
|
||||
OPJDECO_REDUCEFACTOR,
|
||||
OPJDECO_QUALITYLAYERS,
|
||||
OPJDECO_NUMCOMPS,
|
||||
OPJDECO_ENABLEDECO,
|
||||
OPJDECO_ENABLEPARSE,
|
||||
OPJDECO_ENABLEJPWL,
|
||||
OPJDECO_EXPCOMPS,
|
||||
OPJDECO_MAXTILES,
|
||||
OPJDECO_FRAMENUM
|
||||
};
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif //__OPJ_VIEWER_H__
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -1,3 +0,0 @@
|
||||
OPJChild16 ICON OPJChild.ico
|
||||
OPJViewer16 ICON OPJViewer.ico
|
||||
#include "wx/msw/wx.rc"
|
||||
@@ -1,26 +0,0 @@
|
||||
/* XPM */
|
||||
static char *OPJViewer16[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 16 4 1",
|
||||
" c black",
|
||||
". c #800000",
|
||||
"X c red",
|
||||
"o c None",
|
||||
/* pixels */
|
||||
"oooooooooooooooo",
|
||||
"ooo.XXXXoooooooo",
|
||||
"ooXXoo .Xooooooo",
|
||||
"o..oooo .ooooooo",
|
||||
"oX.oooo ooooooo",
|
||||
"oX.oooo .ooooooo",
|
||||
"oXXoooo .ooooooo",
|
||||
"o.XXoo .oooooooo",
|
||||
"oo.XXXXooooooooo",
|
||||
"ooooooooo.Xo .oo",
|
||||
"ooooooooo X. ooo",
|
||||
"oooooooooo...ooo",
|
||||
"oooooooooo XXooo",
|
||||
"oooooooooo .Xooo",
|
||||
"oooooooooooooooo",
|
||||
"oooooooooooooooo"
|
||||
};
|
||||
@@ -1,54 +0,0 @@
|
||||
wxString htmlaboutpage = wxT(
|
||||
"<html>"
|
||||
"<body bgcolor=#FFFFFF>"
|
||||
"<table cellspacing=7 cellpadding=1 border=0 width=100%>"
|
||||
"<tr>"
|
||||
"<td rowspan=3 valign=top align=center width=70>"
|
||||
"<img src=\"memory:opj_logo.xpm\"><br><br>"
|
||||
"</td>"
|
||||
"<td align=center>"
|
||||
"<font size=+0 color=#000000><b>"
|
||||
OPJ_APPLICATION " " OPJ_APPLICATION_VERSION
|
||||
"</b></font><br>"
|
||||
"<font size=-1 color=#000000><b>A JPEG 2000 image viewer</b></font><br>"
|
||||
"<font size=-2 color=#000000><b>" OPJ_APPLICATION_PLATFORM " version</b></font>"
|
||||
"</td>"
|
||||
"</tr>"
|
||||
"<tr height=3 valign=center>"
|
||||
"<td valign=center bgcolor=#cc3300></td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td align=justify>"
|
||||
"<center><font size=+0 color=#000000><a href=\"http://www.openjpeg.org/\">OpenJPEG</a></font></center>"
|
||||
"<p><font size=-1 color=#000000>The OpenJPEG library is an open-source JPEG 2000 codec written in C language. "
|
||||
"In addition to the basic codec, various other features are under development.</font></p><br>"
|
||||
"<font size=-2 color=red>* Build: ")
|
||||
#include "build.h"
|
||||
wxT(", " __DATE__ ", " __TIME__ "</font><br>")
|
||||
wxT("<font size=-2 color=red>* " wxVERSION_STRING "</font><br>")
|
||||
wxT("<font size=-2 color=red>* OpenJPEG " OPENJPEG_VERSION " (")
|
||||
#ifdef USE_JPWL
|
||||
wxT("<font size=-2 color=green>JPWL</font> ")
|
||||
#endif // USE_JPWL
|
||||
#ifdef USE_JPSEC
|
||||
wxT("<font size=-2 color=green>JPSEC</font> ")
|
||||
#endif // USE_JPSEC
|
||||
wxT(")</font><br>")
|
||||
#ifdef USE_MXF
|
||||
wxT("<font size=-2 color=red>* MXFLib " MXFLIB_VERSION_MAJOR "." MXFLIB_VERSION_MINOR "." MXFLIB_VERSION_TWEAK " (" MXFLIB_VERSION_BUILD ")</font><br>")
|
||||
#endif // USE_MXF
|
||||
wxT("</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td colspan=2 bgcolor=#CC3300 height=3 valign=center></td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td colspan=2>"
|
||||
"<font size=-2 color=#444444>OpenJPEG is © 2002-2008 <a href=\"http://www.tele.ucl.ac.be/\">TELE</a> - <a href=\"http://www.uclouvain.be/\">Universite' Catholique de Louvain</a></font><br>"
|
||||
"<font size=-2 color=#444444>OPJViewer is © 2007-2008 <a href=\"http://dsplab.diei.unipg.it/\">DSPLab</a> - <a href=\"http://www.unipg.it/\">Universita' degli studi di Perugia</a></font>"
|
||||
"</td>"
|
||||
"</tr>"
|
||||
"</table>"
|
||||
"</body>"
|
||||
"</html>"
|
||||
);
|
||||
@@ -1 +0,0 @@
|
||||
wxT("491")
|
||||
@@ -1,79 +0,0 @@
|
||||
/* XPM */
|
||||
static const char *icon1_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"32 32 41 1",
|
||||
"> c #97C4E7",
|
||||
"# c #4381AA",
|
||||
"d c #FFFFFF",
|
||||
"< c #71B2DE",
|
||||
"+ c #538BB1",
|
||||
"& c #D1E5F5",
|
||||
"q c #63B3DE",
|
||||
"6 c #F1F4F7",
|
||||
"* c #CAE1F3",
|
||||
"y c #7AC4E5",
|
||||
"= c #C3DDF1",
|
||||
"X c #74A1BD",
|
||||
"- c #BCD9EF",
|
||||
"5 c #619BC4",
|
||||
"3 c #E6EAF1",
|
||||
"2 c #4B8EBF",
|
||||
"o c #6B97B6",
|
||||
". c #4B82A8",
|
||||
" c None",
|
||||
"w c #54A6D8",
|
||||
"1 c #71A8D1",
|
||||
", c #85BBE2",
|
||||
"t c #EFF6FC",
|
||||
"7 c #DEEDF8",
|
||||
"@ c #4388B4",
|
||||
"a c #F7FBFD",
|
||||
"$ c #D7E0E9",
|
||||
"r c #FAFCFE",
|
||||
"4 c #DAEAF7",
|
||||
"e c #E9F3FA",
|
||||
"0 c #76BAE2",
|
||||
"% c #7FA6C0",
|
||||
"s c #FDFDFE",
|
||||
"O c #5896BE",
|
||||
"p c #B6D5EE",
|
||||
"8 c #87ABC3",
|
||||
": c #A5CCEA",
|
||||
"9 c #E5F0F9",
|
||||
"; c #AFD1EC",
|
||||
"i c #F4F9FD",
|
||||
"u c #8FB0C3",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" .XXXooOO++@#$ ",
|
||||
" %&*=-;:>>,<123 ",
|
||||
" %4&*=-;:>>,1>56 ",
|
||||
" %74&*=-;:>>1*>56 ",
|
||||
" 89700qqqqwq1e*>X ",
|
||||
" 8e974&*=-;:1re*>8 ",
|
||||
" 8te974&*=-;11111# ",
|
||||
" 8tty000qqqqqww>,+ ",
|
||||
" uitte974&*=-p:>>+ ",
|
||||
" uaitte974&*=-p:>O ",
|
||||
" uaayyyy000qqqqp:O ",
|
||||
" uraaitte974&*=-po ",
|
||||
" urraaitte974&*=-o ",
|
||||
" usryyyyyyy000q*=X ",
|
||||
" ussrraaitte974&*X ",
|
||||
" udssrraaitte974&X ",
|
||||
" uddyyyyyyyyyy074% ",
|
||||
" udddssrraaitte97% ",
|
||||
" uddddssrraaitte9% ",
|
||||
" udddddssrraaitte8 ",
|
||||
" uddddddssrraaitt8 ",
|
||||
" uuuuuuuuuuuuuu88u ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "
|
||||
};
|
||||
@@ -1,53 +0,0 @@
|
||||
/* XPM */
|
||||
static const char *icon2_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"32 32 15 1",
|
||||
". c Black",
|
||||
"O c #97C4E7",
|
||||
"$ c #63B3DE",
|
||||
"@ c #CAE1F3",
|
||||
"; c #7AC4E5",
|
||||
"* c #74A1BD",
|
||||
"+ c #619BC4",
|
||||
"o c #4B8EBF",
|
||||
" c None",
|
||||
"% c #54A6D8",
|
||||
"= c #FAFCFE",
|
||||
"& c #E9F3FA",
|
||||
"# c #76BAE2",
|
||||
"X c #C00000",
|
||||
"- c #87ABC3",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ............. ",
|
||||
" .XXXXXXXXXX.o. ",
|
||||
" .XXXXXXXXXX.O+. ",
|
||||
" .XXXXXXXXXX.@O+. ",
|
||||
" .XX##$$$$%$.&@O* ",
|
||||
" .XXXXXXXXXX.=&@O- ",
|
||||
" .XXXXXXXXXX...... ",
|
||||
" .XX;###$$$$$%%XX. ",
|
||||
" .XXXXXXXXXXXXXXX. ",
|
||||
" .XXXXXXXXXXXXXXX. ",
|
||||
" .XX;;;;###$$$$XX. ",
|
||||
" .XXXXXXXXXXXXXXX. ",
|
||||
" .XXXXXXXXXXXXXXX. ",
|
||||
" .XX;;;;;;;###$XX. ",
|
||||
" .XXXXXXXXXXXXXXX. ",
|
||||
" .XXXXXXXXXXXXXXX. ",
|
||||
" .XX;;;;;;;;;;#XX. ",
|
||||
" .XXXXXXXXXXXXXXX. ",
|
||||
" .XXXXXXXXXXXXXXX. ",
|
||||
" .XXXXXXXXXXXXXXX. ",
|
||||
" .XXXXXXXXXXXXXXX. ",
|
||||
" ................. ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "
|
||||
};
|
||||
@@ -1,79 +0,0 @@
|
||||
/* XPM */
|
||||
static const char *icon3_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"32 32 41 1",
|
||||
"6 c #EDF2FB",
|
||||
"- c #AAC1E8",
|
||||
": c #B9CDED",
|
||||
"X c #295193",
|
||||
", c #C6D6F0",
|
||||
"a c #4A7CCE",
|
||||
"u c #779DDB",
|
||||
"y c #7FA2DD",
|
||||
"$ c #3263B4",
|
||||
"5 c #EAF0FA",
|
||||
". c #2D59A3",
|
||||
"o c #6E96D8",
|
||||
"* c #356AC1",
|
||||
"r c #F7F9FD",
|
||||
"> c #BED0EE",
|
||||
"3 c #E1E9F7",
|
||||
"7 c #F0F5FC",
|
||||
"< c #CBD9F1",
|
||||
"2 c #DAE5F6",
|
||||
"# c #3161B1",
|
||||
" c None",
|
||||
"0 c #FDFEFF",
|
||||
"= c #9FB9E5",
|
||||
"e c #AEC5EA",
|
||||
"t c #89A9DF",
|
||||
"q c #98B5E4",
|
||||
"p c #5584D1",
|
||||
"d c #3A70CA",
|
||||
"@ c #305FAC",
|
||||
"i c #5D89D3",
|
||||
"1 c #D2DFF4",
|
||||
"% c #3366B9",
|
||||
"9 c #FAFCFE",
|
||||
"8 c #F5F8FD",
|
||||
"s c #4075CC",
|
||||
"O c #638ED5",
|
||||
"w c #90AFE2",
|
||||
"& c #3467BC",
|
||||
"+ c #2F5DA9",
|
||||
"; c #B3C8EB",
|
||||
"4 c #E5EDF9",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ......X ",
|
||||
" .oooooO+ ",
|
||||
" .ooooooo. ",
|
||||
" .+@@@##$%%&&&&&****. ",
|
||||
" .=-;:>,<12345678900. ",
|
||||
" .q=-;:>,<1234567890. ",
|
||||
" .wq=-e:>,<12345678r. ",
|
||||
" .twq=-e:>,<12345678. ",
|
||||
" .ytwq=-e:>,<1234567. ",
|
||||
" .uytwq=-e:>,<123456. ",
|
||||
" .ouytwq=-e:>,<12345. ",
|
||||
" .Oouytwq=-e;>,<1234. ",
|
||||
" .iOouytwq=-e;>,<123. ",
|
||||
" .piOouytwq=-e;>,<12. ",
|
||||
" .apiOouytwq=-e;>,<1. ",
|
||||
" .sapiOouytwq=-e;>,<. ",
|
||||
" .dsapiOouytwq=-e;>,. ",
|
||||
" ...................# ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "
|
||||
};
|
||||
@@ -1,43 +0,0 @@
|
||||
/* XPM */
|
||||
static const char *icon4_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"32 32 5 1",
|
||||
". c Black",
|
||||
"o c #8399B4",
|
||||
"X c #8DA0B9",
|
||||
" c None",
|
||||
"O c #800000",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ....... ",
|
||||
" .XXXXXo. ",
|
||||
" .XXXXXXX. ",
|
||||
" .................... ",
|
||||
" .OOOOOOOOOOOOOOOOOO. ",
|
||||
" .OOOOOOOOOOOOOOOOOO. ",
|
||||
" .OOOOOOOOOOOOOOOOOO. ",
|
||||
" .OOOOOOOOOOOOOOOOOO. ",
|
||||
" .OOOOOOOOOOOOOOOOOO. ",
|
||||
" .OOOOOOOOOOOOOOOOOO. ",
|
||||
" .OOOOOOOOOOOOOOOOOO. ",
|
||||
" .OOOOOOOOOOOOOOOOOO. ",
|
||||
" .OOOOOOOOOOOOOOOOOO. ",
|
||||
" .OOOOOOOOOOOOOOOOOO. ",
|
||||
" .OOOOOOOOOOOOOOOOOO. ",
|
||||
" .OOOOOOOOOOOOOOOOOO. ",
|
||||
" .OOOOOOOOOOOOOOOOOO. ",
|
||||
" .................... ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "
|
||||
};
|
||||
@@ -1,79 +0,0 @@
|
||||
/* XPM */
|
||||
static const char *icon5_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"32 32 41 1",
|
||||
"0 c #AAC1E8",
|
||||
"q c #B9CDED",
|
||||
"X c #295193",
|
||||
"e c #C6D6F0",
|
||||
"a c #4A7CCE",
|
||||
"& c #779DDB",
|
||||
"* c #7FA2DD",
|
||||
"2 c #EAF0FA",
|
||||
"@ c #2D59A3",
|
||||
"o c #6E96D8",
|
||||
"y c #356AC1",
|
||||
"d c #214279",
|
||||
"w c #BED0EE",
|
||||
"= c #85A7DF",
|
||||
"< c #E1E9F7",
|
||||
"3 c #F0F5FC",
|
||||
"s c #CBD9F1",
|
||||
", c #DAE5F6",
|
||||
"7 c #3161B1",
|
||||
" c None",
|
||||
". c #274D8B",
|
||||
"6 c #FDFEFF",
|
||||
"i c #E7EEF9",
|
||||
"9 c #9FB9E5",
|
||||
"- c #89A9DF",
|
||||
"8 c #98B5E4",
|
||||
"$ c #5584D1",
|
||||
"+ c #3569BF",
|
||||
"% c #305FAC",
|
||||
"O c #5D89D3",
|
||||
"> c #D2DFF4",
|
||||
"p c #3366B9",
|
||||
"5 c #FAFCFE",
|
||||
"4 c #F5F8FD",
|
||||
"t c #4075CC",
|
||||
"u c #638ED5",
|
||||
"r c #CEDCF2",
|
||||
"; c #90AFE2",
|
||||
"# c #2F5DA9",
|
||||
": c #B3C8EB",
|
||||
"1 c #E5EDF9",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ......X ",
|
||||
" XoooooO. ",
|
||||
" Xoooooo+. ",
|
||||
" Xooooooo@XXXXXXXXXX# ",
|
||||
" Xoooooooooooooooooo# ",
|
||||
" Xoooooooooooooooooo# ",
|
||||
" Xoo$################### ",
|
||||
" Xoo%O&*=-;:>,<123445667 ",
|
||||
" XooX890:qwer>,<123445q# ",
|
||||
" Xoty;890:qwer>,<12344# ",
|
||||
" Xo%u-;890:qwer>,<i234# ",
|
||||
" XoX&*-;890:qwer>,<i2r# ",
|
||||
" Xtpo&*-;890:qwer>,<i# ",
|
||||
" X%auo&*-;890:qwer>,<# ",
|
||||
" XX$Ouo&*-;890:qwer>s# ",
|
||||
" d%a$Ouo&*-;890:qwer# ",
|
||||
" d+ta$Ouo&*-;890:qwe# ",
|
||||
" d..................# ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,177 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: imagalljpeg2000.h
|
||||
// Purpose: wxImage JPEG 2000 family file format handler
|
||||
// Author: G. Baruffa - based on imagjpeg.h, Vaclav Slavik
|
||||
// RCS-ID: $Id: imagalljpeg2000.h,v 0.0 2008/01/31 11:22:00 VZ Exp $
|
||||
// Copyright: (c) Giuseppe Baruffa
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_IMAGJPEG2000_H_
|
||||
#define _WX_IMAGJPEG2000_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxJPEG2000Handler
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_LIBOPENJPEG
|
||||
|
||||
#include "wx/image.h"
|
||||
#include "libopenjpeg/openjpeg.h"
|
||||
#include "codec/index.h"
|
||||
|
||||
#define wxBITMAP_TYPE_JPEG2000 50
|
||||
|
||||
class WXDLLEXPORT wxJPEG2000Handler: public wxImageHandler
|
||||
{
|
||||
public:
|
||||
inline wxJPEG2000Handler()
|
||||
{
|
||||
m_name = wxT("JPEG 2000 family file format");
|
||||
m_extension = wxT("mj2");
|
||||
m_type = wxBITMAP_TYPE_JPEG2000;
|
||||
m_mime = wxT("image/mj2");
|
||||
|
||||
/* decoding */
|
||||
m_reducefactor = 0;
|
||||
m_qualitylayers = 0;
|
||||
m_components = 0;
|
||||
#ifdef USE_JPWL
|
||||
m_enablejpwl = true;
|
||||
m_expcomps = JPWL_EXPECTED_COMPONENTS;
|
||||
m_maxtiles = JPWL_MAXIMUM_TILES;
|
||||
#endif // USE_JPWL
|
||||
|
||||
/* encoding */
|
||||
m_subsampling = wxT("1,1");
|
||||
m_origin = wxT("0,0");
|
||||
m_rates = wxT("20,10,5");
|
||||
m_quality = wxT("30,35,40");
|
||||
m_enablequality = false;
|
||||
m_multicomp = false;
|
||||
m_irreversible = false;
|
||||
m_resolutions = 6;
|
||||
m_progression = 0;
|
||||
m_cbsize = wxT("32,32");
|
||||
m_prsize = wxT("[128,128],[128,128]");
|
||||
m_tsize = wxT("");
|
||||
m_torigin = wxT("0,0");
|
||||
/*m_progression
|
||||
m_resilience*/
|
||||
m_enablesop = false;
|
||||
m_enableeph = false;
|
||||
m_enablereset = false;
|
||||
m_enablesegmark = false;
|
||||
m_enablevsc = false;
|
||||
m_enablerestart = false;
|
||||
m_enableerterm = false;
|
||||
m_enablebypass = false;
|
||||
/*m_roicompo
|
||||
m_roiup
|
||||
m_indexfname*/
|
||||
m_enableidx = false;
|
||||
m_index = wxT("index.txt");
|
||||
m_enablepoc = false;
|
||||
m_poc = wxT("T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL");
|
||||
m_enablecomm = true;
|
||||
|
||||
#if defined __WXMSW__
|
||||
m_comment = wxT("Created by OPJViewer Win32 - OpenJPEG version ");
|
||||
#elif defined __WXGTK__
|
||||
m_comment = wxT("Created by OPJViewer Lin32 - OpenJPEG version ");
|
||||
#else
|
||||
m_comment = wxT("Created by OPJViewer - OpenJPEG version ");
|
||||
#endif
|
||||
|
||||
#ifdef USE_JPWL
|
||||
m_comment += wxString::Format(wxT("%s with JPWL"), (char *) opj_version());
|
||||
#else
|
||||
m_comment += wxString::Format(wxT("%s"), (char *) opj_version());
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// decoding engine parameters
|
||||
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||
#ifdef USE_JPWL
|
||||
bool m_enablejpwl;
|
||||
int m_expcomps, m_maxtiles;
|
||||
#endif // USE_JPWL
|
||||
|
||||
// encoding engine parameters
|
||||
wxString m_subsampling;
|
||||
wxString m_origin;
|
||||
wxString m_rates;
|
||||
wxString m_quality;
|
||||
bool m_enablequality;
|
||||
bool m_multicomp;
|
||||
bool m_irreversible;
|
||||
int m_resolutions;
|
||||
int m_progression;
|
||||
wxString m_cbsize;
|
||||
wxString m_prsize;
|
||||
wxString m_tsize;
|
||||
wxString m_torigin;
|
||||
/*m_progression
|
||||
m_resilience*/
|
||||
bool m_enablesop;
|
||||
bool m_enableeph;
|
||||
bool m_enablebypass;
|
||||
bool m_enableerterm;
|
||||
bool m_enablerestart;
|
||||
bool m_enablereset;
|
||||
bool m_enablesegmark;
|
||||
bool m_enablevsc;
|
||||
/*m_roicompo
|
||||
m_roiup
|
||||
m_indexfname*/
|
||||
bool m_enableidx;
|
||||
wxString m_index;
|
||||
bool m_enablecomm;
|
||||
wxString m_comment;
|
||||
bool m_enablepoc;
|
||||
wxString m_poc;
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
virtual bool LoadFile(wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1);
|
||||
virtual bool SaveFile(wxImage *image, wxOutputStream& stream, bool verbose=true);
|
||||
protected:
|
||||
virtual bool DoCanRead(wxInputStream& stream);
|
||||
#endif
|
||||
|
||||
private:
|
||||
OPJ_PROG_ORDER give_progression(char progression[4]);
|
||||
DECLARE_DYNAMIC_CLASS(wxJPEG2000Handler)
|
||||
};
|
||||
|
||||
#endif // wxUSE_LIBOPENJPEG
|
||||
|
||||
#endif // _WX_IMAGJPEG2000_H_
|
||||
|
||||
@@ -1,502 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#include "mxflib/mxflib.h"
|
||||
using namespace mxflib;
|
||||
|
||||
namespace
|
||||
{
|
||||
//! Structure holding information about the essence in each body stream
|
||||
struct EssenceInfo
|
||||
{
|
||||
UMIDPtr PackageID;
|
||||
PackagePtr Package;
|
||||
MDObjectPtr Descriptor;
|
||||
};
|
||||
//! Map of EssenceInfo structures indexed by BodySID
|
||||
typedef std::map<UInt32, EssenceInfo> EssenceInfoMap;
|
||||
|
||||
//! The map of essence info for this file
|
||||
EssenceInfoMap EssenceLookup;
|
||||
};
|
||||
|
||||
//! Build an EssenceInfoMap for the essence in a given file
|
||||
/*! \return True if al OK, else false
|
||||
*/
|
||||
bool BuildEssenceInfo(MXFFilePtr &File, EssenceInfoMap &EssenceLookup);
|
||||
|
||||
// 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
|
||||
|
||||
#include <stdarg.h>
|
||||
#define MAX_MESSAGE_LEN 200
|
||||
|
||||
//------------- MXF Manager
|
||||
|
||||
// Debug and error messages
|
||||
|
||||
//! Display a warning message
|
||||
void mxflib::warning(const char *Fmt, ...)
|
||||
{
|
||||
char msg[MAX_MESSAGE_LEN];
|
||||
va_list args;
|
||||
|
||||
va_start(args, Fmt);
|
||||
_vsnprintf(msg, MAX_MESSAGE_LEN, Fmt, args);
|
||||
va_end(args);
|
||||
|
||||
int message_len = strlen(msg) - 1;
|
||||
if (msg[message_len] != '\n')
|
||||
message_len = MAX_MESSAGE_LEN;
|
||||
#ifndef __WXGTK__
|
||||
wxMutexGuiEnter();
|
||||
#endif /* __WXGTK__ */
|
||||
wxLogMessage(wxT("[WARNING_MXF] %.*s"), message_len, msg);
|
||||
#ifndef __WXGTK__
|
||||
wxMutexGuiLeave();
|
||||
#endif /* __WXGTK__ */
|
||||
}
|
||||
|
||||
//! Display an error message
|
||||
void mxflib::error(const char *Fmt, ...)
|
||||
{
|
||||
char msg[MAX_MESSAGE_LEN];
|
||||
va_list args;
|
||||
|
||||
va_start(args, Fmt);
|
||||
_vsnprintf(msg, MAX_MESSAGE_LEN, Fmt, args);
|
||||
va_end(args);
|
||||
|
||||
int message_len = strlen(msg) - 1;
|
||||
if (msg[message_len] != '\n')
|
||||
message_len = MAX_MESSAGE_LEN;
|
||||
#ifndef __WXGTK__
|
||||
wxMutexGuiEnter();
|
||||
#endif /* __WXGTK__ */
|
||||
wxLogMessage(wxT("[ERROR_MXF] %.*s"), message_len, msg);
|
||||
#ifndef __WXGTK__
|
||||
wxMutexGuiLeave();
|
||||
#endif /* __WXGTK__ */
|
||||
}
|
||||
|
||||
//! Display an error message
|
||||
void mxflib::debug(const char *Fmt, ...)
|
||||
{
|
||||
char msg[MAX_MESSAGE_LEN];
|
||||
va_list args;
|
||||
|
||||
va_start(args, Fmt);
|
||||
_vsnprintf(msg, MAX_MESSAGE_LEN, Fmt, args);
|
||||
va_end(args);
|
||||
|
||||
int message_len = strlen(msg) - 1;
|
||||
if (msg[message_len] != '\n')
|
||||
message_len = MAX_MESSAGE_LEN;
|
||||
#ifndef __WXGTK__
|
||||
wxMutexGuiEnter();
|
||||
#endif /* __WXGTK__ */
|
||||
wxLogMessage(wxT("[DEBUG_MXF] %.*s"), message_len, msg);
|
||||
#ifndef __WXGTK__
|
||||
wxMutexGuiLeave();
|
||||
#endif /* __WXGTK__ */
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------- 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
|
||||
|
||||
/* 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 */
|
||||
|
||||
// simply display the version of the library
|
||||
wxLogMessage(wxT("Version of MXF: %s "), wxString::FromAscii(LibraryVersion().c_str()));
|
||||
//wxLogMessage(wxT("MXF file name: %s"), m_filename.GetFullPath());
|
||||
|
||||
// open MXF file
|
||||
MXFFilePtr TestFile = new MXFFile;
|
||||
if (! TestFile->Open(m_filename.GetFullPath().c_str(), true))
|
||||
{
|
||||
wxLogError(wxT("Could not find %s"), m_filename.GetFullPath().c_str());
|
||||
return false;
|
||||
} else
|
||||
wxLogMessage(wxT("Found %s"), m_filename.GetFullPath().c_str());
|
||||
|
||||
// Get the size
|
||||
TestFile->SeekEnd();
|
||||
wxLogMessage(wxT("Size is %d bytes"), TestFile->Tell());
|
||||
TestFile->Seek(0);
|
||||
|
||||
// essence information
|
||||
//BuildEssenceInfo(TestFile, EssenceLookup);
|
||||
|
||||
// close MXF file
|
||||
TestFile->Close();
|
||||
|
||||
return false;
|
||||
|
||||
// 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(¶meters);
|
||||
|
||||
/* 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, ¶meters);
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
//! Build an EssenceInfoMap for the essence in a given file
|
||||
/*! \return True if al OK, else false
|
||||
*/
|
||||
bool BuildEssenceInfo(MXFFilePtr &File, EssenceInfoMap &EssenceLookup)
|
||||
{
|
||||
// Empty any old data
|
||||
EssenceLookup.clear();
|
||||
|
||||
// Get the master metadata set (or the header if we must)
|
||||
PartitionPtr MasterPartition = File->ReadMasterPartition();
|
||||
if(!MasterPartition)
|
||||
{
|
||||
File->Seek(0);
|
||||
MasterPartition = File->ReadPartition();
|
||||
warning("File %s does not contain a cloased copy of header metadata - using the open copy in the file header\n", File->Name.c_str());
|
||||
}
|
||||
|
||||
if(!MasterPartition)
|
||||
{
|
||||
error("Could not read header metadata from file %s\n", File->Name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read and parse the metadata
|
||||
MasterPartition->ReadMetadata();
|
||||
MetadataPtr HMeta = MasterPartition->ParseMetadata();
|
||||
|
||||
if(!HMeta)
|
||||
{
|
||||
error("Could not read header metadata from file %s\n", File->Name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Scan the Essence container data sets to get PackageID to BodySID mapping */
|
||||
MDObjectPtr ECDSet = HMeta[ContentStorage_UL];
|
||||
if(ECDSet) ECDSet = ECDSet->GetLink();
|
||||
if(ECDSet) ECDSet = ECDSet[EssenceContainerDataBatch_UL];
|
||||
if(!ECDSet)
|
||||
{
|
||||
error("Header metadata in file %s does not contain an EssenceContainerData set\n", File->Name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
MDObject::iterator it = ECDSet->begin();
|
||||
while(it != ECDSet->end())
|
||||
{
|
||||
MDObjectPtr ThisECDSet = (*it).second->GetLink();
|
||||
MDObjectPtr PackageID;
|
||||
if(ThisECDSet) PackageID = ThisECDSet->Child(LinkedPackageUID_UL);
|
||||
if(PackageID)
|
||||
{
|
||||
EssenceInfo NewEI;
|
||||
NewEI.PackageID = new UMID(PackageID->PutData()->Data);
|
||||
|
||||
// Inset the basic essence info - but not if this is external essence (BodySID == 0)
|
||||
UInt32 BodySID = ThisECDSet->GetUInt(BodySID_UL);
|
||||
if(BodySID) EssenceLookup[BodySID] = NewEI;
|
||||
}
|
||||
it++;
|
||||
}
|
||||
|
||||
/* Now find the other items for the essence lookup map */
|
||||
if(EssenceLookup.size())
|
||||
{
|
||||
PackageList::iterator it = HMeta->Packages.begin();
|
||||
while(it != HMeta->Packages.end())
|
||||
{
|
||||
// Only Source Packages are of interest
|
||||
if((*it)->IsA(SourcePackage_UL))
|
||||
{
|
||||
MDObjectPtr Descriptor = (*it)->Child(Descriptor_UL);
|
||||
if(Descriptor) Descriptor = Descriptor->GetLink();
|
||||
|
||||
if(Descriptor)
|
||||
{
|
||||
MDObjectPtr PackageID = (*it)->Child(PackageUID_UL);
|
||||
if(PackageID)
|
||||
{
|
||||
UMIDPtr TheID = new UMID(PackageID->PutData()->Data);
|
||||
|
||||
/* Now do a lookup in the essence lookup map (it will need to be done the long way here */
|
||||
EssenceInfoMap::iterator EL_it = EssenceLookup.begin();
|
||||
while(EL_it != EssenceLookup.end())
|
||||
{
|
||||
if((*((*EL_it).second.PackageID)) == (*TheID))
|
||||
{
|
||||
// If found, set the missing items and stop searching
|
||||
(*EL_it).second.Package = (*it);
|
||||
(*EL_it).second.Descriptor = Descriptor;
|
||||
break;
|
||||
}
|
||||
EL_it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#endif // wxUSE_STREAMS
|
||||
|
||||
#endif // wxUSE_LIBOPENJPEG
|
||||
|
||||
#endif // USE_MXF
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: imagmxf.h
|
||||
// Purpose: wxImage MXF (Material eXchange Format) JPEG 2000 file format handler
|
||||
// Author: G. Baruffa - based on imagjpeg.h, Vaclav Slavik
|
||||
// RCS-ID: $Id: imagmj2.h,v 0.0 2007/11/19 17:00:00 VZ Exp $
|
||||
// Copyright: (c) Giuseppe Baruffa
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_IMAGMXF_H_
|
||||
#define _WX_IMAGMXF_H_
|
||||
|
||||
#ifdef USE_MXF
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/filename.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxMXFHandler
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_LIBOPENJPEG
|
||||
|
||||
#include "wx/image.h"
|
||||
#include "libopenjpeg/openjpeg.h"
|
||||
|
||||
#define wxBITMAP_TYPE_MXF 51
|
||||
|
||||
class WXDLLEXPORT wxMXFHandler: public wxImageHandler
|
||||
{
|
||||
public:
|
||||
inline wxMXFHandler()
|
||||
{
|
||||
m_name = wxT("MXF JPEG 2000 file format");
|
||||
m_extension = wxT("mxf");
|
||||
m_type = wxBITMAP_TYPE_MXF;
|
||||
m_mime = wxT("image/mxf");
|
||||
|
||||
m_reducefactor = 0;
|
||||
m_qualitylayers = 0;
|
||||
m_components = 0;
|
||||
m_filename = wxT("");
|
||||
#ifdef USE_JPWL
|
||||
m_enablejpwl = true;
|
||||
m_expcomps = JPWL_EXPECTED_COMPONENTS;
|
||||
m_maxtiles = JPWL_MAXIMUM_TILES;
|
||||
#endif // USE_JPWL
|
||||
}
|
||||
|
||||
// decoding engine parameters
|
||||
int m_reducefactor, m_qualitylayers, m_components, m_framenum;
|
||||
wxFileName m_filename;
|
||||
#ifdef USE_JPWL
|
||||
bool m_enablejpwl;
|
||||
int m_expcomps, m_maxtiles;
|
||||
#endif // USE_JPWL
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 );
|
||||
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=true );
|
||||
protected:
|
||||
virtual bool DoCanRead( wxInputStream& stream );
|
||||
#endif
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxMXFHandler)
|
||||
};
|
||||
|
||||
#endif // wxUSE_LIBOPENJPEG
|
||||
|
||||
#endif // USE_MXF
|
||||
|
||||
#endif // _WX_IMAGMXF_H_
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
Copyright (c) 2001-2003, David Janssens
|
||||
Copyright (c) 2002-2003, Yannick Verschueren
|
||||
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
Copyright (c) 2007, Digital Signal Processing Laboratory, Universit<69> degli studi di Perugia (UPG), Italy
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditionsare met:
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -1,285 +0,0 @@
|
||||
/* XPM */
|
||||
static char *opj_logo[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"90 61 218 2",
|
||||
" c #BE3D12",
|
||||
". c #BF461D",
|
||||
"X c #AD5435",
|
||||
"o c #B64925",
|
||||
"O c #B54E2B",
|
||||
"+ c #BC4620",
|
||||
"@ c #BB4B25",
|
||||
"# c #BC4E29",
|
||||
"$ c #B5502F",
|
||||
"% c #BD512C",
|
||||
"& c #B45334",
|
||||
"* c #B35638",
|
||||
"= c #B45B3D",
|
||||
"- c #BB5533",
|
||||
"; c #BE5937",
|
||||
": c #BC5C3D",
|
||||
"> c #9C766A",
|
||||
", c #AD5D42",
|
||||
"< c #B55F41",
|
||||
"1 c #BA5E40",
|
||||
"2 c #A7634D",
|
||||
"3 c #A76C57",
|
||||
"4 c #AA6750",
|
||||
"5 c #AC6B56",
|
||||
"6 c #AA6E5A",
|
||||
"7 c #A4705E",
|
||||
"8 c #B46045",
|
||||
"9 c #B1644B",
|
||||
"0 c #BD6244",
|
||||
"q c #B96448",
|
||||
"w c #BC694D",
|
||||
"e c #B36B53",
|
||||
"r c #B26E58",
|
||||
"t c #BB6C52",
|
||||
"y c #B2725D",
|
||||
"u c #BD7056",
|
||||
"i c #BB745C",
|
||||
"p c #A67566",
|
||||
"a c #A57B6D",
|
||||
"s c #AE7562",
|
||||
"d c #AB7867",
|
||||
"f c #AA7C6C",
|
||||
"g c #A07E73",
|
||||
"h c #AA7F71",
|
||||
"j c #B37661",
|
||||
"k c #B47863",
|
||||
"l c #B27D6B",
|
||||
"z c #BB7863",
|
||||
"x c #BA7E69",
|
||||
"c c #C73605",
|
||||
"v c #C63A0B",
|
||||
"b c #CB3300",
|
||||
"n c #CA3807",
|
||||
"m c #C93A0A",
|
||||
"M c #C43E11",
|
||||
"N c #C93E10",
|
||||
"B c #C44115",
|
||||
"V c #C3441A",
|
||||
"C c #C4481E",
|
||||
"Z c #CA4113",
|
||||
"A c #C94519",
|
||||
"S c #CB481C",
|
||||
"D c #C24A23",
|
||||
"F c #C24F28",
|
||||
"G c #CD4D23",
|
||||
"H c #C4522D",
|
||||
"J c #CB532B",
|
||||
"K c #C25632",
|
||||
"L c #C35936",
|
||||
"P c #C25C3B",
|
||||
"I c #C85630",
|
||||
"U c #CB5933",
|
||||
"Y c #CB5E3A",
|
||||
"T c #D05026",
|
||||
"R c #CC613D",
|
||||
"E c #C26343",
|
||||
"W c #C46748",
|
||||
"Q c #C1694C",
|
||||
"! c #CD6744",
|
||||
"~ c #CA6C4D",
|
||||
"^ c #C37155",
|
||||
"/ c #C4755B",
|
||||
"( c #CB7356",
|
||||
") c #C8765B",
|
||||
"_ c #D06D4C",
|
||||
"` c #D07253",
|
||||
"' c #D47B5E",
|
||||
"] c #C37B63",
|
||||
"[ c #C27E68",
|
||||
"{ c #C97F68",
|
||||
"} c #A68175",
|
||||
"| c #A48479",
|
||||
" . c #AD8172",
|
||||
".. c #AD8578",
|
||||
"X. c #AB897D",
|
||||
"o. c #B1806F",
|
||||
"O. c #BA816F",
|
||||
"+. c #B38373",
|
||||
"@. c #B58778",
|
||||
"#. c #B3897B",
|
||||
"$. c #BA8472",
|
||||
"%. c #BB8C7C",
|
||||
"&. c #C2816B",
|
||||
"*. c #CD846C",
|
||||
"=. c #C38470",
|
||||
"-. c #C38976",
|
||||
";. c #C38D7B",
|
||||
":. c #CC8973",
|
||||
">. c #CF8F7A",
|
||||
",. c #CB907D",
|
||||
"<. c #D1937F",
|
||||
"1. c #948E8C",
|
||||
"2. c #9D8C86",
|
||||
"3. c #9D8F89",
|
||||
"4. c #96908E",
|
||||
"5. c #9C918D",
|
||||
"6. c #949392",
|
||||
"7. c #9B9492",
|
||||
"8. c #9D9997",
|
||||
"9. c #9D9C9C",
|
||||
"0. c #A38B83",
|
||||
"q. c #AA8D83",
|
||||
"w. c #A4918B",
|
||||
"e. c #AC9087",
|
||||
"r. c #AB938C",
|
||||
"t. c #A49590",
|
||||
"y. c #A29996",
|
||||
"u. c #A19D9C",
|
||||
"i. c #AA9790",
|
||||
"p. c #AC9994",
|
||||
"a. c #AC9E99",
|
||||
"s. c #B18D81",
|
||||
"d. c #B59084",
|
||||
"f. c #B49389",
|
||||
"g. c #BA9184",
|
||||
"h. c #B89589",
|
||||
"j. c #BA988D",
|
||||
"k. c #B29B93",
|
||||
"l. c #BC9C92",
|
||||
"z. c #ACA19D",
|
||||
"x. c #B1A19D",
|
||||
"c. c #BCA39B",
|
||||
"v. c #A3A3A3",
|
||||
"b. c #ABA5A3",
|
||||
"n. c #AEA9A7",
|
||||
"m. c #ABABAA",
|
||||
"M. c #B3A5A1",
|
||||
"N. c #B3A9A6",
|
||||
"B. c #B3ADAA",
|
||||
"V. c #B9A6A0",
|
||||
"C. c #B9AAA5",
|
||||
"Z. c #BAADA9",
|
||||
"A. c #B4B0AF",
|
||||
"S. c #BAB0AD",
|
||||
"D. c #B4B3B3",
|
||||
"F. c #BAB5B3",
|
||||
"G. c #BDB8B6",
|
||||
"H. c #BBBBBB",
|
||||
"J. c #C39384",
|
||||
"K. c #C0978A",
|
||||
"L. c #C2998B",
|
||||
"P. c #CA9483",
|
||||
"I. c #CD9A8A",
|
||||
"U. c #C19D92",
|
||||
"Y. c #D69B89",
|
||||
"T. c #DB9680",
|
||||
"R. c #C2A095",
|
||||
"E. c #C4A69C",
|
||||
"W. c #CCA193",
|
||||
"Q. c #C8A599",
|
||||
"!. c #CBA99D",
|
||||
"~. c #C6AEA6",
|
||||
"^. c #CCACA2",
|
||||
"/. c #CBB2AB",
|
||||
"(. c #C3B8B5",
|
||||
"). c #C2BDBC",
|
||||
"_. c #C9B9B3",
|
||||
"`. c #D3ADA0",
|
||||
"'. c #D3B4A9",
|
||||
"]. c #DCB2A4",
|
||||
"[. c #DEB6A8",
|
||||
"{. c #D1BFB9",
|
||||
"}. c #D9BEB5",
|
||||
"|. c #C5C0BE",
|
||||
" X c #CDC0BC",
|
||||
".X c #D2C1BB",
|
||||
"XX c #DDC3BB",
|
||||
"oX c #E0C5BC",
|
||||
"OX c #E0C8BF",
|
||||
"+X c #C2C2C2",
|
||||
"@X c #CBC4C2",
|
||||
"#X c #CDC8C6",
|
||||
"$X c #CCCBCB",
|
||||
"%X c #D2C6C2",
|
||||
"&X c #D1CECD",
|
||||
"*X c #DDC8C1",
|
||||
"=X c #DECFCA",
|
||||
"-X c #D9D1CE",
|
||||
";X c #D3D3D3",
|
||||
":X c #D9D5D4",
|
||||
">X c #DED9D7",
|
||||
",X c #DBDBDB",
|
||||
"<X c #E1CAC3",
|
||||
"1X c #E2CFC8",
|
||||
"2X c #E1D3CE",
|
||||
"3X c #E2D5D0",
|
||||
"4X c #E5D8D3",
|
||||
"5X c #E4DDDB",
|
||||
"6X c #E8DBD6",
|
||||
"7X c #EADEDA",
|
||||
"8X c #E6E0DE",
|
||||
"9X c #EBE0DC",
|
||||
"0X c #E4E4E4",
|
||||
"qX c #E8E2E0",
|
||||
"wX c #EBEBEB",
|
||||
"eX c #F0EAE8",
|
||||
"rX c #F3F3F3",
|
||||
"tX c #FEFEFE",
|
||||
/* pixels */
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXrXrXtXrXrXrXrXrXrXrXtXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXrXtXrXrXrXwXwXrXwXrXrXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXrXrXrXwXwX0X0XqX0X0X0X0XwXwXwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXrXtXrXwXwX2X[.[.].].].].].1XwXrXwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXrXrXrXwX0X0XL.J b b b b b b b J '.0X0XwXwXrXrXrXrXrXrXrXrXrXrXtXrXrXrXtXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXtXtXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXrXrXwX0XXXt m b m B V N b b v >.;X0XwXwXwXwXrXwXwXrXrXrXrXtXrXtXrXrXrXwXrXrXrXrXrXrXrXrXrXrXrXwXrXrXwXrXrXrXtXtXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXrXrXrX0X,X'.S b b P l.z.M.k.w n b b g.;X,X,X,X0X0X0X0X0XwXwXwXwXwXwXwXwXwX0X0X0XwX0X0XwXwXwXwX0X0X0X0X0X0XwXwXwXwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXrXrXrXwX0X:XT.m b A ] G.D.D.m.$.m b b $.$X&X.X}.XX>XOX}.oXXX<X0X0XwXwXwX0X2XXXoXXXoXOX5X0XwX0X1XoXXX5X*X}.}.oX<XqXrXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXrXrXwX0X,XL.b b D M.H.D.D.D.D.m.L b b W H.Z.# b Y / m b b b Z P.:X:X:X$X:.Z b b b b n :.;X;X;XR b A &.Z b b b b *.wXwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXrXwX0X:X$.b b E B.H.H.D.D.D.D.P b b E H.V.. b U L v v n b b ( #X;X$X~.Y b m N m b b ! {.&X#XI b C R v v n b b ! 0XwXrXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXrXwX0X:X!.A b Z F.H.H.H.H.H.D.m.L b b e b.+.b b V k i.r.t n b b s.H.x v b L q.b.p.D b b t F.$.n b M l a.M.y b b A :X0XwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXrXwX0X:XL.m b D H.).H.+XH.H.H.D.H b b 6 v.j b b - a.A.m.@.m b b h D.< b b w z.b.b.P b b q B.z b b @ B.D.m...v b G :X,XwXwXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXwX0X,X&X/ b b , D.H.+X+X+X+XH.f.B b b 5.8.M b M w.v.v.v.r.D b b h l v b b M V v b b q u.X b n @.v.m.v.j b b Q &X,X0XwXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXwX0X,X$X^ b b , H.H.+X+XH.H.H.s.N b n 7.7.v b B 8.v.v.v.w.M b b g r b b b n n n b b b b e y.O b n X.m.v.n.e b b u &X,X0XrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXrX0X,X$X/ b b + F.H.H.H.+XH.d.b b M | 8.> c b @ 9.v.9.u., b b - 3.& b b 7 1.1.4.4.4.6.7.9.w.m b + t.v.m.p.D b b K.;X,X0XwXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXwX0X,X$X-.b b b i D.H.G.H.J.N b b = 9.9.5 c b B 7.9.v.y.b b m f 4.O b b 3 6.6.6.g 9 4 h u.h b b - b.m.m.s.b b N ~.;X,X0XwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXwX0X,X;XE.G b b I z ] ] ] W n b H l 9.8.9 b b m e 6 r e b b # 0.y.< b b O 6 p 6 < # ; q.v.t b b 0 n.A.A.+.b b H _.;X,XwXwXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXwXwX,X;X#Xf.b b b b b b b b b - a.v.v.w.@ b b v b b b b b @ b.m.v.w.M b b b b b b v ..m.n.A b n g.H.H.H.4 b b [ &X,X0XwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXwXwX0X:X$XZ.Q H v n b m B H E x n.m.m.q.B b v < . v N + E z m.m.m.b.e - M m v M - t k.D.m.; # - V.H.+XH.s # # K.:X,X0XwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXrXwXwX,X,X$X+XG.Z.Z.B.C.S.F.H.H.H.D.D.j b b q v.b.a.n.B.H.H.+X+X+XH.H.D.Z.C.Z.Z.F.H.H.+X+XH.).H.$X&X&X;X$X#X#X:X,X0XwXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXrXrXwX0X,X;X#X+X+X+XH.H.+X+X+XH.H.H.D.e b n i n.m.D.H.H.+X#X$X$X+X+X+X+XH.H.H.H.+X+X+X$X&X&X&X$X;X;X;X:X;X:X,X,X0XwXwXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXrXrXwXwX,X,X;X;X$X$X$X;X;X&X;X$X#X+XF b v s.H.H.+X$X&X;X;X,X,X,X;X:X;X;X;X;X;X;X:X,X,X,X0X,X0X,X0X0X0X0X0X0X0XwXwXrXtXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXrXtXrXwXwX0X,X:X;X;X;X;X;X:X;X;X;X$X+XC b B k.+X+X$X$X;X,X,X0X0X0X0X0X;X,X,X,X,X,X,X,X,X0X0X0X0X0X0XwX0X0X0XwXwXrXrXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXrXrXrXrXwXwXwX0X0X0X0X0X0X0X,X,X:X^.^.!.$X$X;X,X,X0XwXwXwXwXwXwXwXwX0X0X0X0XwXwXwXwXwXwXrXrXwXrXrXrXrXrXrXrXrXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXrXrXrXrXwXwXwXwX0XwXwXwX0X0X,X:X;X$X&X&X;X,X,X0XwXwXwXrXrXrXrXrXwXwXwXwXwXwXwXrXrXrXwXrXrXrXrXrXrXrXrXrXrXtXrXtXtXrXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXrXrXrXrXrXrXrXrXrXwXwXwXwX0X,X0X0X0XwXwXrXrXrXrXrXrXrXrXrXrXrXrXrXrXwXrXrXrXrXrXtXrXrXrXtXrXrXrXrXrXrXrXrXrXtXtXtXrXrXtXtXtXtXrXrXtXrXrXtXrXtXrXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXrXtXtXrXtXrXrXrXrXrXrXwXwXwX0XwX0XwXwXwXrXrXrXtXtXrXrXrXrXrXrXrXrXwXrXwXrXwXwXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXtXrXrXtXtXrXrXrXrXrXrXrXrXrXrXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXwXrXrXrXrXrXrXtXrXtXrXrXrXrXrXwXwXwXwXwX0X0XwX0XwXwXwXwXwXwXwXrXwXwXwX0X0X0X0XwX0XwXwXrXrXrXwXrXwXwXwX0XwX0XwXwXwXrXrXrXrXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrXrXrXrXrXtXtXrXrXtXrXrXeX7X7X9XwXwXwX5X3X3X3X2X2X2X5X0XwXwXwXwXwX8X3X3X2X2X2X2X2X3X6X6X7XwXwXwXwXwXwX7X1XXXOXOX1X8XwXwXrXrXrXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXtXtXrXrXrXwXT.T T :.,X,X-X` G G G G G G U _ J.-X,X,X,X[ G G G G G G G G G G _ >XwX0X,X&XI.R N b b b m ! `.5XwXrXrXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXtXtXrXtXrXrXrXwX0X' b b ] >X,X%XJ b b b b b b b b Q {.:X;X:Xq b b b b b b b b b b Y >X0X,X-X'.^ n b b b b b m *.1XwXwXrXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrX0X0X%XL b b L.@X+X-.b b M L L L D b b b M V.+X(.N b b D H H H H H U U W.;X&X^.H b b n W -.-.W n b b J &XwXrXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXwXwX0X XF b b U.+X+X[ b b D z z j P v b b N U.H.S.m b m E Q t ^ ) / ) ) /.$X$X;.m b n A %.H.H.J.N b b N .XwXwXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXwXwX,X:X!.m b L N.D.m.* b b y v.v.v.v.p.n b M f.m.w b b D u.v.m.m.D.G.H.H.+X).g.b b B j.F.D.D.D.D.l.; F I /.0XwXrXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXwX,X:XU.n b E B.A.n.$ b b s v.9.v.v.r.n n M r.b.1 b b D u.v.m.m.D.D.H.H.).H.k b b # M.G.D.D.D.D.Z.t w u _.0XwXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXwXwX,X;X$XJ b m h b.v.i.m b M a 5.5.2.p M b c < 8.2.+ b b M o o o o # % j G.H.g.m b A M.D.D.D.B.M.M.M.M.Z.(.:X0XwXrXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrXrXwX,X,X&X(.n b M 0.v.v.s b b b b b n b b c b M u.v.g M b b b b b b b b b i G.D.0 b b 8 D.D.H.G.P n b b n b U :X,XwXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrXwX0X,X;X$XV.n b M w.v.9.< b b b b b b b b c H r 9.v.a n b * < < w w Q Q g.D.B.: b b r D.D.D.m.C b b b b b ) ;X0XwXrXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrX6XP.=.K.;X#X+Xx n b D v.u.7.. b b M D . D & 2 q.b.b.v.v.< b b X 6.9.9.b.m.D.D.D.D.n.# b b f D.D.D.b.= 1 * N b n !.;X,XwXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXrXrXwX<X~ P x $X+XH.z b b - v.v.3.M b b < r r r k 0.a.m.m.m.v.# b b , 6.9.v.m.D.D.D.H.D.z.O b b s D.D.D.N.f l 9 v b M ~.;X,XwXrXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXrXwX0XY.n b e H.H.V.F b b p b.v.h v b v v.m.A.D.H.+X+X+XH.D.p.b b m p 9.v.m.D.D.H.H.H.D.N.- b b - m.A.D.A.m.a.B b b - (.:X0XwXrXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXwXwX0XY.n b ; Z.C.$.A b v 0.m.m.l n b M m.D.D.H.+X#X+X+XH.H.r.b b m < d l l l $.;.J.V.H.B.w b b C @.s.a.k.#.j n b b : ).:X,XwXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXwXwX0X'.N b b A B n b n z m.D.B.0 b b 9 H.H.+X$X;X:X;X$X$X+Xl b b b b b b b b b b b s.H.H.B.H b b b n Z Z b b V n b ] $X:X0XwXrXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXwX0X,X.XR b b b b b A P d.D.D.C.H b b j H.$X$X;X:X,X,X;X;X+X/ b b b b b b b b b b b a.H.H.D.u G b b b b b B H : v m ;.$X,XwXwXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXwXwX,X:X Xg.j 5 y s.C.H.H.+X+X|.E.Q.Q. X;X;X,X0XwXwX0X0X,X;X/.U.j.h.g.f.h.j.U.U.U.!.$X$X+X+XH.Z.g.y 4 6 l x.D.A.l.~.#X,X0XwXrXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXwX0X:X$XG.k.e.f.B.H.H.+X$X$X$X#X$X$X;X;X,X0XwXwXwXwX0X0X;X$X+XH.D.D.D.F.H.+X+X#X&X$X;X$X$X+X+XA.r.X.e.a.H.H.H.+X+X;X,X0XwXrXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXwX,X,X$X&X$X$X$X$X;X;X,X,X,X,X,X,X0XwXwXwXrXtXrXrXwXwX0X,X;X$X$X+X$X$X$X;X;X:X,X,X,X,X,X;X$X&X#X#X$X$X$X$X$X;X,X,X0XwXrXrXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXwXwX0X,X:X;X;X$X;X;X:X,X,X0X0X,X0X0X0XwXwXwXrXrXtXrXrXwXwX0X;X;X$X&X$X$X&X:X,X,X,X,X0X,X,X:X;X;X$X$X$X$X$X;X:X,X,X0XwXwXrXrXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXrXwXwXwX0X0X0X0X0X0XwXwXwXwXwXwXwXwXrXwXrXtXtXrXtXtXrXrXrXwX0X0X0X0X,X,X0X0X0X0XwXwXwXwXwXwX0X0X0X,X,X,X,X0X0XwXwXwXrXtXrXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrXwXwX0X0X0X0X0XwXwXwXrXwXrXrXrXrXrXtXrXtXtXtXtXrXrXrXwXwXwX0X0X0X0X0X0X0XwXwXwXwXwXwXwXwXwX0X0X0X0XwXwXwXwXwXrXrXrXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXrXrXrXrXrXrXrXrXrXrXtXtXrXtXtXrXtXtXtXtXtXtXtXrXtXrXtXrXrXrXrXwXwXrXrXrXrXrXrXrXtXrXrXrXrXrXrXrXwXrXrXrXrXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXrXtXrXrXrXrXrXrXtXtXrXtXrXtXrXrXtXtXtXtXtXtXtXtXtXtXtXrXrXrXrXrXrXrXrXrXrXrXtXtXrXtXrXrXtXrXrXrXrXrXrXrXrXtXrXrXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX",
|
||||
"tXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtXtX"
|
||||
};
|
||||
@@ -1,34 +0,0 @@
|
||||
This viewer is conceived to open and display information and image content of J2K, JP2,
|
||||
and MJ2 files.
|
||||
The viewer application interface is divided into three main panels:
|
||||
- a browsing pane;
|
||||
- a viewing pane;
|
||||
- a log/peek pane.
|
||||
|
||||
The browsing pane will present the markers or boxes hierarchy, with position (byte number where marker/box starts and stops) and length information (i.e., inner length as signalled by marker/box and total length, with marker/box sign included), in the following form:
|
||||
|
||||
filename
|
||||
|
|
||||
|_ #000: Marker/Box short name (Hex code)
|
||||
| |
|
||||
| |_ *** Marker/Box long name ***
|
||||
| |_ startbyte > stopbyte, inner_length + marker/box sign length (total length)
|
||||
| |_ Additional info, depending on the marker/box type
|
||||
| |_ ...
|
||||
|
|
||||
|_ #001: Marker/Box short name (Hex code)
|
||||
| |
|
||||
| |_ ...
|
||||
|
|
||||
...
|
||||
|
||||
|
||||
The viewing pane will display the decoded image contained in the JPEG 2000 file.
|
||||
It should display correctly images as large as 4000x2000, provided that a couple of GB of RAM are available. Nothing is known about the display of larger sizes: let us know if you manage to get it working.
|
||||
|
||||
|
||||
The log/peek pane is shared among two different subpanels:
|
||||
|
||||
- the log panel will report a lot of debugging info coming out from the wx GUI as well as from the openjpeg library
|
||||
- the peek pane tries to give a peek on the codestream/file portion which is currently selected in the browsing pane. It shows both hex and ascii values corresponding to the marker/box section.
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
What is OpenJPEG ?
|
||||
==================
|
||||
The OpenJPEG library is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the use of JPEG 2000, the new still-image compression standard from the Joint Photographic Experts Group (JPEG). In addition to the basic codec, various other features are under development, among them the JP2 and MJ2 (Motion JPEG 2000) file formats, an indexing tool useful for the JPIP protocol, JPWL-tools for error-resilience, a Java-viewer for j2k-images, ...
|
||||
|
||||
Who can use the library ?
|
||||
=========================
|
||||
Anybody. As the OpenJPEG library is released under the BSD license, anybody can use or modify the library, even for commercial applications. The only restriction is to retain the copyright in the sources or the binaries documentation.
|
||||
|
||||
Who is developing the library ?
|
||||
===============================
|
||||
The library is developed by the Communications and Remote Sensing Lab (TELE), in the Universit<69> Catholique de Louvain (UCL). The JPWL module is developped and maintained by the Digital Signal Processing Lab (DSPLab) of the University of Perugia, Italy (UNIPG). As our purpose is to make OpenJPEG really useful for those interested in the image compression field, any feedback/advices are obviously welcome ! We will do our best to handle them quickly.
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,120 +0,0 @@
|
||||
# Build the demo app, small examples
|
||||
|
||||
# First thing define the common source:
|
||||
SET(common_SRCS
|
||||
convert.c
|
||||
converttif.c
|
||||
convertbmp.c
|
||||
convertpng.c
|
||||
index.c
|
||||
${OPENJPEG_SOURCE_DIR}/applications/common/color.c
|
||||
)
|
||||
if(NOT USE_SYSTEM_GETOPT)
|
||||
list(APPEND common_SRCS
|
||||
${OPENJPEG_SOURCE_DIR}/applications/common/opj_getopt.c
|
||||
)
|
||||
endif()
|
||||
|
||||
# Headers file are located here:
|
||||
INCLUDE_DIRECTORIES(
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||
${LCMS_INCLUDE_DIRNAME}
|
||||
${OPENJPEG_SOURCE_DIR}/applications/common
|
||||
${Z_INCLUDE_DIRNAME}
|
||||
${PNG_INCLUDE_DIRNAME}
|
||||
${TIFF_INCLUDE_DIRNAME}
|
||||
)
|
||||
|
||||
IF(WIN32)
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
ADD_DEFINITIONS(-DOPJ_EXPORTS)
|
||||
ELSE(BUILD_SHARED_LIBS)
|
||||
ADD_DEFINITIONS(-DOPJ_STATIC)
|
||||
ENDIF(BUILD_SHARED_LIBS)
|
||||
ENDIF(WIN32)
|
||||
|
||||
# Loop over all executables:
|
||||
FOREACH(exe j2k_to_image image_to_j2k j2k_dump)
|
||||
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
|
||||
TARGET_LINK_LIBRARIES(${exe} ${OPENJPEG_LIBRARY_NAME}
|
||||
${PNG_LIBNAME} ${TIFF_LIBNAME} ${LCMS_LIBNAME}
|
||||
)
|
||||
# To support universal exe:
|
||||
IF(ZLIB_FOUND AND APPLE)
|
||||
TARGET_LINK_LIBRARIES(${exe} z)
|
||||
ELSe(ZLIB_FOUND AND APPLE)
|
||||
TARGET_LINK_LIBRARIES(${exe} ${Z_LIBNAME})
|
||||
ENDIF(ZLIB_FOUND AND APPLE)
|
||||
|
||||
# On unix you need to link to the math library:
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(${exe} m)
|
||||
ENDIF(UNIX)
|
||||
# Install exe
|
||||
INSTALL(TARGETS ${exe}
|
||||
EXPORT OpenJPEGTargets
|
||||
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||
)
|
||||
ENDFOREACH(exe)
|
||||
|
||||
# Install man pages
|
||||
INSTALL(
|
||||
FILES ${OPENJPEG_SOURCE_DIR}/doc/man/man1/image_to_j2k.1
|
||||
${OPENJPEG_SOURCE_DIR}/doc/man/man1/j2k_dump.1
|
||||
${OPENJPEG_SOURCE_DIR}/doc/man/man1/j2k_to_image.1
|
||||
DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man1)
|
||||
#
|
||||
|
||||
IF(BUILD_JPWL)
|
||||
ADD_EXECUTABLE(JPWL_j2k_to_image
|
||||
j2k_to_image.c
|
||||
${common_SRCS}
|
||||
)
|
||||
|
||||
SET_PROPERTY(
|
||||
TARGET JPWL_j2k_to_image
|
||||
APPEND PROPERTY COMPILE_DEFINITIONS USE_JPWL
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${OPENJPEG_LIBRARY_NAME}_JPWL
|
||||
${LCMS_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME})
|
||||
|
||||
# To support universal exe:
|
||||
IF(ZLIB_FOUND AND APPLE)
|
||||
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image z)
|
||||
ELSe(ZLIB_FOUND AND APPLE)
|
||||
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${Z_LIBNAME})
|
||||
ENDIF(ZLIB_FOUND AND APPLE)
|
||||
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image m)
|
||||
ENDIF(UNIX)
|
||||
|
||||
ADD_EXECUTABLE(JPWL_image_to_j2k
|
||||
image_to_j2k.c
|
||||
${common_SRCS}
|
||||
)
|
||||
|
||||
SET_PROPERTY(
|
||||
TARGET JPWL_image_to_j2k
|
||||
APPEND PROPERTY COMPILE_DEFINITIONS USE_JPWL
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${OPENJPEG_LIBRARY_NAME}_JPWL
|
||||
${LCMS_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME})
|
||||
|
||||
# To support universal exe:
|
||||
IF(ZLIB_FOUND AND APPLE)
|
||||
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k z)
|
||||
ELSe(ZLIB_FOUND AND APPLE)
|
||||
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${Z_LIBNAME})
|
||||
ENDIF(ZLIB_FOUND AND APPLE)
|
||||
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k m)
|
||||
ENDIF(UNIX)
|
||||
|
||||
INSTALL(TARGETS JPWL_image_to_j2k JPWL_j2k_to_image
|
||||
DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
|
||||
)
|
||||
ENDIF(BUILD_JPWL)
|
||||
@@ -1,118 +0,0 @@
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
bin_PROGRAMS = j2k_to_image image_to_j2k j2k_dump
|
||||
|
||||
if WANT_JPWL
|
||||
bin_PROGRAMS += JPWL_j2k_to_image JPWL_image_to_j2k
|
||||
endif
|
||||
|
||||
j2k_to_image_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/codec \
|
||||
-I$(top_builddir)/applications/codec \
|
||||
-I$(top_srcdir)/applications/common \
|
||||
-I$(top_builddir)/applications/common \
|
||||
-I$(top_srcdir)/libopenjpeg \
|
||||
-I$(top_builddir)/libopenjpeg \
|
||||
@PNG_CFLAGS@ \
|
||||
@TIFF_CFLAGS@ \
|
||||
@LCMS1_CFLAGS@ \
|
||||
@LCMS2_CFLAGS@
|
||||
j2k_to_image_CFLAGS =
|
||||
j2k_to_image_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @LCMS1_LIBS@ @LCMS2_LIBS@ @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||
j2k_to_image_SOURCES = \
|
||||
../common/color.c \
|
||||
../common/opj_getopt.c \
|
||||
convert.c \
|
||||
index.c \
|
||||
j2k_to_image.c \
|
||||
../common/color.h
|
||||
|
||||
image_to_j2k_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/codec \
|
||||
-I$(top_builddir)/applications/codec \
|
||||
-I$(top_srcdir)/applications/common \
|
||||
-I$(top_builddir)/applications/common \
|
||||
-I$(top_srcdir)/libopenjpeg \
|
||||
-I$(top_builddir)/libopenjpeg \
|
||||
@PNG_CFLAGS@ \
|
||||
@TIFF_CFLAGS@
|
||||
image_to_j2k_CFLAGS =
|
||||
image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||
image_to_j2k_SOURCES = \
|
||||
../common/opj_getopt.c \
|
||||
convert.c \
|
||||
index.c \
|
||||
image_to_j2k.c \
|
||||
convert.h \
|
||||
../common/format_defs.h \
|
||||
index.h
|
||||
|
||||
j2k_dump_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/codec \
|
||||
-I$(top_builddir)/applications/codec \
|
||||
-I$(top_srcdir)/applications/common \
|
||||
-I$(top_builddir)/applications/common \
|
||||
-I$(top_srcdir)/libopenjpeg \
|
||||
-I$(top_builddir)/libopenjpeg
|
||||
j2k_dump_CFLAGS =
|
||||
j2k_dump_LDADD = $(top_builddir)/libopenjpeg/libopenjpeg.la -lm
|
||||
j2k_dump_SOURCES = \
|
||||
../common/opj_getopt.c \
|
||||
index.c \
|
||||
j2k_dump.c \
|
||||
../common/opj_getopt.h \
|
||||
index.h
|
||||
|
||||
JPWL_j2k_to_image_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/common \
|
||||
-I$(top_builddir)/applications/common \
|
||||
-I$(top_srcdir)/libopenjpeg \
|
||||
-I$(top_builddir)/libopenjpeg \
|
||||
-DUSE_JPWL \
|
||||
@TIFF_CFLAGS@ \
|
||||
@PNG_CFLAGS@ \
|
||||
@LCMS1_CFLAGS@ \
|
||||
@LCMS2_CFLAGS@
|
||||
JPWL_j2k_to_image_CFLAGS =
|
||||
JPWL_j2k_to_image_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @LCMS1_LIBS@ @LCMS2_LIBS@ @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||
JPWL_j2k_to_image_SOURCES = \
|
||||
../common/color.c \
|
||||
../common/opj_getopt.c \
|
||||
index.c \
|
||||
convert.c \
|
||||
j2k_to_image.c
|
||||
|
||||
JPWL_image_to_j2k_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/common \
|
||||
-I$(top_builddir)/applications/common \
|
||||
-I$(top_srcdir)/libopenjpeg \
|
||||
-I$(top_builddir)/libopenjpeg \
|
||||
-DUSE_JPWL \
|
||||
@TIFF_CFLAGS@ \
|
||||
@PNG_CFLAGS@
|
||||
JPWL_image_to_j2k_CFLAGS =
|
||||
JPWL_image_to_j2k_LDADD = $(top_builddir)/libopenjpeg/jpwl/libopenjpeg_JPWL.la @TIFF_LIBS@ @PNG_LIBS@ -lm
|
||||
|
||||
JPWL_image_to_j2k_SOURCES = \
|
||||
../common/opj_getopt.c \
|
||||
index.c \
|
||||
convert.c \
|
||||
image_to_j2k.c
|
||||
|
||||
EXTRA_DIST = \
|
||||
CMakeLists.txt \
|
||||
windirent.h
|
||||
|
||||
install-data-hook:
|
||||
@echo -e " (B)\t$(bindir)/j2k_to_image$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
@echo -e " (B)\t$(bindir)/image_to_j2k$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
@echo -e " (B)\t$(bindir)/j2k_dump$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
if WANT_JPWL
|
||||
@echo -e " (B)\t$(bindir)/JPWL_j2k_to_image$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
@echo -e " (B)\t$(bindir)/JPWL_image_to_j2k$(EXEEXT)" >> $(top_builddir)/report.txt
|
||||
endif
|
||||
@@ -1,8 +0,0 @@
|
||||
Simple codec compilation
|
||||
------------------------
|
||||
Once you've built the library, you might want to test it with a basic codec. To do this, go to the codec directory and either use the provided Makefile or use one of the following commands to build an encoder and decoder respectively:
|
||||
|
||||
gcc index.c convert.c image_to_j2k.c -o image_to_j2k -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
|
||||
gcc index.c convert.c j2k_to_image.c -o j2k_to_image -lopenjpeg -I ../libopenjpeg/ -lm -ltiff
|
||||
|
||||
You should add '-L..' to those lines if you did not use the 'install' target when building the library.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,995 +0,0 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "opj_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "openjpeg.h"
|
||||
#include "convert.h"
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#if defined(_WIN32)
|
||||
typedef signed __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#error unsupported platform
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint16_t bfType; /* 'BM' for Bitmap (19776) */
|
||||
uint32_t bfSize; /* Size of the file */
|
||||
uint16_t bfReserved1; /* Reserved : 0 */
|
||||
uint16_t bfReserved2; /* Reserved : 0 */
|
||||
uint32_t bfOffBits; /* Offset */
|
||||
} OPJ_BITMAPFILEHEADER;
|
||||
|
||||
typedef struct {
|
||||
uint32_t biSize; /* Size of the structure in bytes */
|
||||
uint32_t biWidth; /* Width of the image in pixels */
|
||||
uint32_t biHeight; /* Heigth of the image in pixels */
|
||||
uint16_t biPlanes; /* 1 */
|
||||
uint16_t biBitCount; /* Number of color bits by pixels */
|
||||
uint32_t biCompression; /* Type of encoding 0: none 1: RLE8 2: RLE4 */
|
||||
uint32_t biSizeImage; /* Size of the image in bytes */
|
||||
uint32_t biXpelsPerMeter; /* Horizontal (X) resolution in pixels/meter */
|
||||
uint32_t biYpelsPerMeter; /* Vertical (Y) resolution in pixels/meter */
|
||||
uint32_t biClrUsed; /* Number of color used in the image (0: ALL) */
|
||||
uint32_t biClrImportant; /* Number of important color (0: ALL) */
|
||||
uint32_t biRedMask; /* Red channel bit mask */
|
||||
uint32_t biGreenMask; /* Green channel bit mask */
|
||||
uint32_t biBlueMask; /* Blue channel bit mask */
|
||||
uint32_t biAlphaMask; /* Alpha channel bit mask */
|
||||
uint32_t biColorSpaceType; /* Color space type */
|
||||
uint8_t biColorSpaceEP[36]; /* Color space end points */
|
||||
uint32_t biRedGamma; /* Red channel gamma */
|
||||
uint32_t biGreenGamma; /* Green channel gamma */
|
||||
uint32_t biBlueGamma; /* Blue channel gamma */
|
||||
uint32_t biIntent; /* Intent */
|
||||
uint32_t biIccProfileData; /* ICC profile data */
|
||||
uint32_t biIccProfileSize; /* ICC profile size */
|
||||
uint32_t biReserved; /* Reserved */
|
||||
} OPJ_BITMAPINFOHEADER;
|
||||
|
||||
static void opj_applyLUT8u_8u32s_C1R(
|
||||
uint8_t const* pSrc, int32_t srcStride,
|
||||
int32_t* pDst, int32_t dstStride,
|
||||
uint8_t const* pLUT,
|
||||
uint32_t width, uint32_t height)
|
||||
{
|
||||
uint32_t y;
|
||||
|
||||
for (y = height; y != 0U; --y) {
|
||||
uint32_t x;
|
||||
|
||||
for(x = 0; x < width; x++)
|
||||
{
|
||||
pDst[x] = (int32_t)pLUT[pSrc[x]];
|
||||
}
|
||||
pSrc += srcStride;
|
||||
pDst += dstStride;
|
||||
}
|
||||
}
|
||||
|
||||
static void opj_applyLUT8u_8u32s_C1P3R(
|
||||
uint8_t const* pSrc, int32_t srcStride,
|
||||
int32_t* const* pDst, int32_t const* pDstStride,
|
||||
uint8_t const* const* pLUT,
|
||||
uint32_t width, uint32_t height)
|
||||
{
|
||||
uint32_t y;
|
||||
int32_t* pR = pDst[0];
|
||||
int32_t* pG = pDst[1];
|
||||
int32_t* pB = pDst[2];
|
||||
uint8_t const* pLUT_R = pLUT[0];
|
||||
uint8_t const* pLUT_G = pLUT[1];
|
||||
uint8_t const* pLUT_B = pLUT[2];
|
||||
|
||||
for (y = height; y != 0U; --y) {
|
||||
uint32_t x;
|
||||
|
||||
for(x = 0; x < width; x++)
|
||||
{
|
||||
uint8_t idx = pSrc[x];
|
||||
pR[x] = (int32_t)pLUT_R[idx];
|
||||
pG[x] = (int32_t)pLUT_G[idx];
|
||||
pB[x] = (int32_t)pLUT_B[idx];
|
||||
}
|
||||
pSrc += srcStride;
|
||||
pR += pDstStride[0];
|
||||
pG += pDstStride[1];
|
||||
pB += pDstStride[2];
|
||||
}
|
||||
}
|
||||
|
||||
static void bmp24toimage(const uint8_t* pData, uint32_t stride, opj_image_t* image)
|
||||
{
|
||||
int index;
|
||||
uint32_t width, height;
|
||||
uint32_t x, y;
|
||||
const uint8_t *pSrc = NULL;
|
||||
|
||||
width = image->comps[0].w;
|
||||
height = image->comps[0].h;
|
||||
|
||||
index = 0;
|
||||
pSrc = pData + (height - 1U) * stride;
|
||||
for(y = 0; y < height; y++)
|
||||
{
|
||||
for(x = 0; x < width; x++)
|
||||
{
|
||||
image->comps[0].data[index] = (int32_t)pSrc[3*x+2]; /* R */
|
||||
image->comps[1].data[index] = (int32_t)pSrc[3*x+1]; /* G */
|
||||
image->comps[2].data[index] = (int32_t)pSrc[3*x+0]; /* B */
|
||||
index++;
|
||||
}
|
||||
pSrc -= stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void bmp_mask_get_shift_and_prec(uint32_t mask, uint32_t* shift, uint32_t* prec)
|
||||
{
|
||||
uint32_t l_shift, l_prec;
|
||||
|
||||
l_shift = l_prec = 0U;
|
||||
|
||||
if (mask != 0U) {
|
||||
while ((mask & 1U) == 0U) {
|
||||
mask >>= 1;
|
||||
l_shift++;
|
||||
}
|
||||
while (mask & 1U) {
|
||||
mask >>= 1;
|
||||
l_prec++;
|
||||
}
|
||||
}
|
||||
*shift = l_shift; *prec = l_prec;
|
||||
}
|
||||
|
||||
static void bmpmask32toimage(const uint8_t* pData, uint32_t stride, opj_image_t* image, uint32_t redMask, uint32_t greenMask, uint32_t blueMask, uint32_t alphaMask)
|
||||
{
|
||||
int index;
|
||||
uint32_t width, height;
|
||||
uint32_t x, y;
|
||||
const uint8_t *pSrc = NULL;
|
||||
opj_bool hasAlpha = OPJ_FALSE;
|
||||
uint32_t redShift, redPrec;
|
||||
uint32_t greenShift, greenPrec;
|
||||
uint32_t blueShift, bluePrec;
|
||||
uint32_t alphaShift, alphaPrec;
|
||||
|
||||
width = image->comps[0].w;
|
||||
height = image->comps[0].h;
|
||||
|
||||
hasAlpha = image->numcomps > 3U;
|
||||
|
||||
bmp_mask_get_shift_and_prec(redMask, &redShift, &redPrec);
|
||||
bmp_mask_get_shift_and_prec(greenMask, &greenShift, &greenPrec);
|
||||
bmp_mask_get_shift_and_prec(blueMask, &blueShift, &bluePrec);
|
||||
bmp_mask_get_shift_and_prec(alphaMask, &alphaShift, &alphaPrec);
|
||||
|
||||
image->comps[0].bpp = redPrec;
|
||||
image->comps[0].prec = redPrec;
|
||||
image->comps[1].bpp = greenPrec;
|
||||
image->comps[1].prec = greenPrec;
|
||||
image->comps[2].bpp = bluePrec;
|
||||
image->comps[2].prec = bluePrec;
|
||||
if (hasAlpha) {
|
||||
image->comps[3].bpp = alphaPrec;
|
||||
image->comps[3].prec = alphaPrec;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
pSrc = pData + (height - 1U) * stride;
|
||||
for(y = 0; y < height; y++)
|
||||
{
|
||||
for(x = 0; x < width; x++)
|
||||
{
|
||||
uint32_t value = 0U;
|
||||
|
||||
value |= ((uint32_t)pSrc[4*x+0]) << 0;
|
||||
value |= ((uint32_t)pSrc[4*x+1]) << 8;
|
||||
value |= ((uint32_t)pSrc[4*x+2]) << 16;
|
||||
value |= ((uint32_t)pSrc[4*x+3]) << 24;
|
||||
|
||||
image->comps[0].data[index] = (int32_t)((value & redMask) >> redShift); /* R */
|
||||
image->comps[1].data[index] = (int32_t)((value & greenMask) >> greenShift); /* G */
|
||||
image->comps[2].data[index] = (int32_t)((value & blueMask) >> blueShift); /* B */
|
||||
if (hasAlpha) {
|
||||
image->comps[3].data[index] = (int32_t)((value & alphaMask) >> alphaShift); /* A */
|
||||
}
|
||||
index++;
|
||||
}
|
||||
pSrc -= stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void bmpmask16toimage(const uint8_t* pData, uint32_t stride, opj_image_t* image, uint32_t redMask, uint32_t greenMask, uint32_t blueMask, uint32_t alphaMask)
|
||||
{
|
||||
int index;
|
||||
uint32_t width, height;
|
||||
uint32_t x, y;
|
||||
const uint8_t *pSrc = NULL;
|
||||
opj_bool hasAlpha = OPJ_FALSE;
|
||||
uint32_t redShift, redPrec;
|
||||
uint32_t greenShift, greenPrec;
|
||||
uint32_t blueShift, bluePrec;
|
||||
uint32_t alphaShift, alphaPrec;
|
||||
|
||||
width = image->comps[0].w;
|
||||
height = image->comps[0].h;
|
||||
|
||||
hasAlpha = image->numcomps > 3U;
|
||||
|
||||
bmp_mask_get_shift_and_prec(redMask, &redShift, &redPrec);
|
||||
bmp_mask_get_shift_and_prec(greenMask, &greenShift, &greenPrec);
|
||||
bmp_mask_get_shift_and_prec(blueMask, &blueShift, &bluePrec);
|
||||
bmp_mask_get_shift_and_prec(alphaMask, &alphaShift, &alphaPrec);
|
||||
|
||||
image->comps[0].bpp = redPrec;
|
||||
image->comps[0].prec = redPrec;
|
||||
image->comps[1].bpp = greenPrec;
|
||||
image->comps[1].prec = greenPrec;
|
||||
image->comps[2].bpp = bluePrec;
|
||||
image->comps[2].prec = bluePrec;
|
||||
if (hasAlpha) {
|
||||
image->comps[3].bpp = alphaPrec;
|
||||
image->comps[3].prec = alphaPrec;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
pSrc = pData + (height - 1U) * stride;
|
||||
for(y = 0; y < height; y++)
|
||||
{
|
||||
for(x = 0; x < width; x++)
|
||||
{
|
||||
uint32_t value = 0U;
|
||||
|
||||
value |= ((uint32_t)pSrc[2*x+0]) << 0;
|
||||
value |= ((uint32_t)pSrc[2*x+1]) << 8;
|
||||
|
||||
image->comps[0].data[index] = (int32_t)((value & redMask) >> redShift); /* R */
|
||||
image->comps[1].data[index] = (int32_t)((value & greenMask) >> greenShift); /* G */
|
||||
image->comps[2].data[index] = (int32_t)((value & blueMask) >> blueShift); /* B */
|
||||
if (hasAlpha) {
|
||||
image->comps[3].data[index] = (int32_t)((value & alphaMask) >> alphaShift); /* A */
|
||||
}
|
||||
index++;
|
||||
}
|
||||
pSrc -= stride;
|
||||
}
|
||||
}
|
||||
|
||||
static opj_image_t* bmp8toimage(const uint8_t* pData, uint32_t stride, opj_image_t* image, uint8_t const* const* pLUT)
|
||||
{
|
||||
uint32_t width, height;
|
||||
const uint8_t *pSrc = NULL;
|
||||
|
||||
width = image->comps[0].w;
|
||||
height = image->comps[0].h;
|
||||
|
||||
pSrc = pData + (height - 1U) * stride;
|
||||
if (image->numcomps == 1U) {
|
||||
opj_applyLUT8u_8u32s_C1R(pSrc, -(int32_t)stride, image->comps[0].data, (int32_t)width, pLUT[0], width, height);
|
||||
}
|
||||
else {
|
||||
int32_t* pDst[3];
|
||||
int32_t pDstStride[3];
|
||||
|
||||
pDst[0] = image->comps[0].data; pDst[1] = image->comps[1].data; pDst[2] = image->comps[2].data;
|
||||
pDstStride[0] = (int32_t)width; pDstStride[1] = (int32_t)width; pDstStride[2] = (int32_t)width;
|
||||
opj_applyLUT8u_8u32s_C1P3R(pSrc, -(int32_t)stride, pDst, pDstStride, pLUT, width, height);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
static opj_bool bmp_read_file_header(FILE* IN, OPJ_BITMAPFILEHEADER* header)
|
||||
{
|
||||
header->bfType = (uint16_t)getc(IN);
|
||||
header->bfType |= (uint16_t)((uint32_t)getc(IN) << 8);
|
||||
|
||||
if (header->bfType != 19778) {
|
||||
fprintf(stderr,"Error, not a BMP file!\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* FILE HEADER */
|
||||
/* ------------- */
|
||||
header->bfSize = (uint32_t)getc(IN);
|
||||
header->bfSize |= (uint32_t)getc(IN) << 8;
|
||||
header->bfSize |= (uint32_t)getc(IN) << 16;
|
||||
header->bfSize |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->bfReserved1 = (uint16_t)getc(IN);
|
||||
header->bfReserved1 |= (uint16_t)((uint32_t)getc(IN) << 8);
|
||||
|
||||
header->bfReserved2 = (uint16_t)getc(IN);
|
||||
header->bfReserved2 |= (uint16_t)((uint32_t)getc(IN) << 8);
|
||||
|
||||
header->bfOffBits = (uint32_t)getc(IN);
|
||||
header->bfOffBits |= (uint32_t)getc(IN) << 8;
|
||||
header->bfOffBits |= (uint32_t)getc(IN) << 16;
|
||||
header->bfOffBits |= (uint32_t)getc(IN) << 24;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
static opj_bool bmp_read_info_header(FILE* IN, OPJ_BITMAPINFOHEADER* header)
|
||||
{
|
||||
memset(header, 0, sizeof(*header));
|
||||
/* INFO HEADER */
|
||||
/* ------------- */
|
||||
header->biSize = (uint32_t)getc(IN);
|
||||
header->biSize |= (uint32_t)getc(IN) << 8;
|
||||
header->biSize |= (uint32_t)getc(IN) << 16;
|
||||
header->biSize |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
switch (header->biSize) {
|
||||
case 12U: /* BITMAPCOREHEADER */
|
||||
case 40U: /* BITMAPINFOHEADER */
|
||||
case 52U: /* BITMAPV2INFOHEADER */
|
||||
case 56U: /* BITMAPV3INFOHEADER */
|
||||
case 108U: /* BITMAPV4HEADER */
|
||||
case 124U: /* BITMAPV5HEADER */
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"Error, unknown BMP header size %d\n", header->biSize);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
header->biWidth = (uint32_t)getc(IN);
|
||||
header->biWidth |= (uint32_t)getc(IN) << 8;
|
||||
header->biWidth |= (uint32_t)getc(IN) << 16;
|
||||
header->biWidth |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biHeight = (uint32_t)getc(IN);
|
||||
header->biHeight |= (uint32_t)getc(IN) << 8;
|
||||
header->biHeight |= (uint32_t)getc(IN) << 16;
|
||||
header->biHeight |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biPlanes = (uint16_t)getc(IN);
|
||||
header->biPlanes |= (uint16_t)((uint32_t)getc(IN) << 8);
|
||||
|
||||
header->biBitCount = (uint16_t)getc(IN);
|
||||
header->biBitCount |= (uint16_t)((uint32_t)getc(IN) << 8);
|
||||
|
||||
if(header->biSize >= 40U) {
|
||||
header->biCompression = (uint32_t)getc(IN);
|
||||
header->biCompression |= (uint32_t)getc(IN) << 8;
|
||||
header->biCompression |= (uint32_t)getc(IN) << 16;
|
||||
header->biCompression |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biSizeImage = (uint32_t)getc(IN);
|
||||
header->biSizeImage |= (uint32_t)getc(IN) << 8;
|
||||
header->biSizeImage |= (uint32_t)getc(IN) << 16;
|
||||
header->biSizeImage |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biXpelsPerMeter = (uint32_t)getc(IN);
|
||||
header->biXpelsPerMeter |= (uint32_t)getc(IN) << 8;
|
||||
header->biXpelsPerMeter |= (uint32_t)getc(IN) << 16;
|
||||
header->biXpelsPerMeter |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biYpelsPerMeter = (uint32_t)getc(IN);
|
||||
header->biYpelsPerMeter |= (uint32_t)getc(IN) << 8;
|
||||
header->biYpelsPerMeter |= (uint32_t)getc(IN) << 16;
|
||||
header->biYpelsPerMeter |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biClrUsed = (uint32_t)getc(IN);
|
||||
header->biClrUsed |= (uint32_t)getc(IN) << 8;
|
||||
header->biClrUsed |= (uint32_t)getc(IN) << 16;
|
||||
header->biClrUsed |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biClrImportant = (uint32_t)getc(IN);
|
||||
header->biClrImportant |= (uint32_t)getc(IN) << 8;
|
||||
header->biClrImportant |= (uint32_t)getc(IN) << 16;
|
||||
header->biClrImportant |= (uint32_t)getc(IN) << 24;
|
||||
}
|
||||
|
||||
if(header->biSize >= 56U) {
|
||||
header->biRedMask = (uint32_t)getc(IN);
|
||||
header->biRedMask |= (uint32_t)getc(IN) << 8;
|
||||
header->biRedMask |= (uint32_t)getc(IN) << 16;
|
||||
header->biRedMask |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biGreenMask = (uint32_t)getc(IN);
|
||||
header->biGreenMask |= (uint32_t)getc(IN) << 8;
|
||||
header->biGreenMask |= (uint32_t)getc(IN) << 16;
|
||||
header->biGreenMask |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biBlueMask = (uint32_t)getc(IN);
|
||||
header->biBlueMask |= (uint32_t)getc(IN) << 8;
|
||||
header->biBlueMask |= (uint32_t)getc(IN) << 16;
|
||||
header->biBlueMask |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biAlphaMask = (uint32_t)getc(IN);
|
||||
header->biAlphaMask |= (uint32_t)getc(IN) << 8;
|
||||
header->biAlphaMask |= (uint32_t)getc(IN) << 16;
|
||||
header->biAlphaMask |= (uint32_t)getc(IN) << 24;
|
||||
}
|
||||
|
||||
if(header->biSize >= 108U) {
|
||||
header->biColorSpaceType = (uint32_t)getc(IN);
|
||||
header->biColorSpaceType |= (uint32_t)getc(IN) << 8;
|
||||
header->biColorSpaceType |= (uint32_t)getc(IN) << 16;
|
||||
header->biColorSpaceType |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
if (fread(&(header->biColorSpaceEP), 1U, sizeof(header->biColorSpaceEP), IN) != sizeof(header->biColorSpaceEP)) {
|
||||
fprintf(stderr,"Error, can't read BMP header\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
header->biRedGamma = (uint32_t)getc(IN);
|
||||
header->biRedGamma |= (uint32_t)getc(IN) << 8;
|
||||
header->biRedGamma |= (uint32_t)getc(IN) << 16;
|
||||
header->biRedGamma |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biGreenGamma = (uint32_t)getc(IN);
|
||||
header->biGreenGamma |= (uint32_t)getc(IN) << 8;
|
||||
header->biGreenGamma |= (uint32_t)getc(IN) << 16;
|
||||
header->biGreenGamma |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biBlueGamma = (uint32_t)getc(IN);
|
||||
header->biBlueGamma |= (uint32_t)getc(IN) << 8;
|
||||
header->biBlueGamma |= (uint32_t)getc(IN) << 16;
|
||||
header->biBlueGamma |= (uint32_t)getc(IN) << 24;
|
||||
}
|
||||
|
||||
if(header->biSize >= 124U) {
|
||||
header->biIntent = (uint32_t)getc(IN);
|
||||
header->biIntent |= (uint32_t)getc(IN) << 8;
|
||||
header->biIntent |= (uint32_t)getc(IN) << 16;
|
||||
header->biIntent |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biIccProfileData = (uint32_t)getc(IN);
|
||||
header->biIccProfileData |= (uint32_t)getc(IN) << 8;
|
||||
header->biIccProfileData |= (uint32_t)getc(IN) << 16;
|
||||
header->biIccProfileData |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biIccProfileSize = (uint32_t)getc(IN);
|
||||
header->biIccProfileSize |= (uint32_t)getc(IN) << 8;
|
||||
header->biIccProfileSize |= (uint32_t)getc(IN) << 16;
|
||||
header->biIccProfileSize |= (uint32_t)getc(IN) << 24;
|
||||
|
||||
header->biReserved = (uint32_t)getc(IN);
|
||||
header->biReserved |= (uint32_t)getc(IN) << 8;
|
||||
header->biReserved |= (uint32_t)getc(IN) << 16;
|
||||
header->biReserved |= (uint32_t)getc(IN) << 24;
|
||||
}
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static opj_bool bmp_read_raw_data(FILE* IN, uint8_t* pData, uint32_t stride, uint32_t width, uint32_t height)
|
||||
{
|
||||
OPJ_ARG_NOT_USED(width);
|
||||
|
||||
if ( fread(pData, sizeof(uint8_t), stride * height, IN) != (stride * height) )
|
||||
{
|
||||
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static opj_bool bmp_read_rle8_data(FILE* IN, uint8_t* pData, uint32_t stride, uint32_t width, uint32_t height)
|
||||
{
|
||||
uint32_t x, y;
|
||||
uint8_t *pix;
|
||||
const uint8_t *beyond;
|
||||
|
||||
beyond = pData + stride * height;
|
||||
pix = pData;
|
||||
|
||||
x = y = 0U;
|
||||
while (y < height)
|
||||
{
|
||||
int c = getc(IN);
|
||||
|
||||
if (c) {
|
||||
int j;
|
||||
uint8_t c1 = (uint8_t)getc(IN);
|
||||
|
||||
for (j = 0; (j < c) && (x < width) && ((size_t)pix < (size_t)beyond); j++, x++, pix++) {
|
||||
*pix = c1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
c = getc(IN);
|
||||
if (c == 0x00) { /* EOL */
|
||||
x = 0;
|
||||
++y;
|
||||
pix = pData + y * stride + x;
|
||||
}
|
||||
else if (c == 0x01) { /* EOP */
|
||||
break;
|
||||
}
|
||||
else if (c == 0x02) { /* MOVE by dxdy */
|
||||
c = getc(IN);
|
||||
x += (uint32_t)c;
|
||||
c = getc(IN);
|
||||
y += (uint32_t)c;
|
||||
pix = pData + y * stride + x;
|
||||
}
|
||||
else /* 03 .. 255 */
|
||||
{
|
||||
int j;
|
||||
for (j = 0; (j < c) && (x < width) && ((size_t)pix < (size_t)beyond); j++, x++, pix++)
|
||||
{
|
||||
uint8_t c1 = (uint8_t)getc(IN);
|
||||
*pix = c1;
|
||||
}
|
||||
if ((uint32_t)c & 1U) { /* skip padding byte */
|
||||
getc(IN);
|
||||
}
|
||||
}
|
||||
}
|
||||
}/* while() */
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static opj_bool bmp_read_rle4_data(FILE* IN, uint8_t* pData, uint32_t stride, uint32_t width, uint32_t height)
|
||||
{
|
||||
uint32_t x, y;
|
||||
uint8_t *pix;
|
||||
const uint8_t *beyond;
|
||||
|
||||
beyond = pData + stride * height;
|
||||
pix = pData;
|
||||
x = y = 0U;
|
||||
while(y < height)
|
||||
{
|
||||
int c = getc(IN);
|
||||
if(c == EOF) break;
|
||||
|
||||
if(c) {/* encoded mode */
|
||||
int j;
|
||||
uint8_t c1 = (uint8_t)getc(IN);
|
||||
|
||||
for (j = 0; (j < c) && (x < width) && ((size_t)pix < (size_t)beyond); j++, x++, pix++) {
|
||||
*pix = (uint8_t)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU));
|
||||
}
|
||||
}
|
||||
else { /* absolute mode */
|
||||
c = getc(IN);
|
||||
if(c == EOF) break;
|
||||
|
||||
if(c == 0x00) { /* EOL */
|
||||
x = 0; y++; pix = pData + y * stride;
|
||||
}
|
||||
else if(c == 0x01) { /* EOP */
|
||||
break;
|
||||
}
|
||||
else if(c == 0x02) { /* MOVE by dxdy */
|
||||
c = getc(IN); x += (uint32_t)c;
|
||||
c = getc(IN); y += (uint32_t)c;
|
||||
pix = pData + y * stride + x;
|
||||
}
|
||||
else { /* 03 .. 255 : absolute mode */
|
||||
int j;
|
||||
uint8_t c1 = 0U;
|
||||
|
||||
for (j = 0; (j < c) && (x < width) && ((size_t)pix < (size_t)beyond); j++, x++, pix++) {
|
||||
if((j&1) == 0) {
|
||||
c1 = (uint8_t)getc(IN);
|
||||
}
|
||||
*pix = (uint8_t)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU));
|
||||
}
|
||||
if(((c&3) == 1) || ((c&3) == 2)) { /* skip padding byte */
|
||||
getc(IN);
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* while(y < height) */
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters)
|
||||
{
|
||||
opj_image_cmptparm_t cmptparm[4]; /* maximum of 4 components */
|
||||
uint8_t lut_R[256], lut_G[256], lut_B[256];
|
||||
uint8_t const* pLUT[3];
|
||||
opj_image_t * image = NULL;
|
||||
FILE *IN;
|
||||
OPJ_BITMAPFILEHEADER File_h;
|
||||
OPJ_BITMAPINFOHEADER Info_h;
|
||||
uint32_t i, palette_len, numcmpts = 1U;
|
||||
opj_bool l_result = OPJ_FALSE;
|
||||
uint8_t* pData = NULL;
|
||||
uint32_t stride;
|
||||
|
||||
pLUT[0] = lut_R; pLUT[1] = lut_G; pLUT[2] = lut_B;
|
||||
|
||||
IN = fopen(filename, "rb");
|
||||
if (!IN)
|
||||
{
|
||||
fprintf(stderr, "Failed to open %s for reading !!\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!bmp_read_file_header(IN, &File_h)) {
|
||||
fclose(IN);
|
||||
return NULL;
|
||||
}
|
||||
if (!bmp_read_info_header(IN, &Info_h)) {
|
||||
fclose(IN);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Load palette */
|
||||
if (Info_h.biBitCount <= 8U)
|
||||
{
|
||||
memset(&lut_R[0], 0, sizeof(lut_R));
|
||||
memset(&lut_G[0], 0, sizeof(lut_G));
|
||||
memset(&lut_B[0], 0, sizeof(lut_B));
|
||||
|
||||
palette_len = Info_h.biClrUsed;
|
||||
if((palette_len == 0U) && (Info_h.biBitCount <= 8U)) {
|
||||
palette_len = (1U << Info_h.biBitCount);
|
||||
}
|
||||
if (palette_len > 256U) {
|
||||
palette_len = 256U;
|
||||
}
|
||||
if (palette_len > 0U) {
|
||||
uint8_t has_color = 0U;
|
||||
for (i = 0U; i < palette_len; i++) {
|
||||
lut_B[i] = (uint8_t)getc(IN);
|
||||
lut_G[i] = (uint8_t)getc(IN);
|
||||
lut_R[i] = (uint8_t)getc(IN);
|
||||
(void)getc(IN); /* padding */
|
||||
has_color |= (lut_B[i] ^ lut_G[i]) | (lut_G[i] ^ lut_R[i]);
|
||||
}
|
||||
if(has_color) {
|
||||
numcmpts = 3U;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
numcmpts = 3U;
|
||||
if ((Info_h.biCompression == 3) && (Info_h.biAlphaMask != 0U)) {
|
||||
numcmpts++;
|
||||
}
|
||||
}
|
||||
|
||||
stride = ((Info_h.biWidth * Info_h.biBitCount + 31U) / 32U) * 4U; /* rows are aligned on 32bits */
|
||||
if (Info_h.biBitCount == 4 && Info_h.biCompression == 2) { /* RLE 4 gets decoded as 8 bits data for now... */
|
||||
stride = ((Info_h.biWidth * 8U + 31U) / 32U) * 4U;
|
||||
}
|
||||
pData = (uint8_t *) calloc(1, stride * Info_h.biHeight * sizeof(uint8_t));
|
||||
if (pData == NULL) {
|
||||
fclose(IN);
|
||||
return NULL;
|
||||
}
|
||||
/* Place the cursor at the beginning of the image information */
|
||||
fseek(IN, 0, SEEK_SET);
|
||||
fseek(IN, (long)File_h.bfOffBits, SEEK_SET);
|
||||
|
||||
switch (Info_h.biCompression) {
|
||||
case 0:
|
||||
case 3:
|
||||
/* read raw data */
|
||||
l_result = bmp_read_raw_data(IN, pData, stride, Info_h.biWidth, Info_h.biHeight);
|
||||
break;
|
||||
case 1:
|
||||
/* read rle8 data */
|
||||
l_result = bmp_read_rle8_data(IN, pData, stride, Info_h.biWidth, Info_h.biHeight);
|
||||
break;
|
||||
case 2:
|
||||
/* read rle4 data */
|
||||
l_result = bmp_read_rle4_data(IN, pData, stride, Info_h.biWidth, Info_h.biHeight);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unsupported BMP compression\n");
|
||||
l_result = OPJ_FALSE;
|
||||
break;
|
||||
}
|
||||
if (!l_result) {
|
||||
free(pData);
|
||||
fclose(IN);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* create the image */
|
||||
memset(&cmptparm[0], 0, sizeof(cmptparm));
|
||||
for(i = 0; i < 4U; i++)
|
||||
{
|
||||
cmptparm[i].prec = 8;
|
||||
cmptparm[i].bpp = 8;
|
||||
cmptparm[i].sgnd = 0;
|
||||
cmptparm[i].dx = parameters->subsampling_dx;
|
||||
cmptparm[i].dy = parameters->subsampling_dy;
|
||||
cmptparm[i].w = Info_h.biWidth;
|
||||
cmptparm[i].h = Info_h.biHeight;
|
||||
}
|
||||
|
||||
image = opj_image_create(numcmpts, &cmptparm[0], (numcmpts == 1U) ? CLRSPC_GRAY : CLRSPC_SRGB);
|
||||
if(!image) {
|
||||
fclose(IN);
|
||||
free(pData);
|
||||
return NULL;
|
||||
}
|
||||
/* if (numcmpts == 4U) {
|
||||
image->comps[3].alpha = 1;
|
||||
} */
|
||||
|
||||
/* set image offset and reference grid */
|
||||
image->x0 = (uint32_t)parameters->image_offset_x0;
|
||||
image->y0 = (uint32_t)parameters->image_offset_y0;
|
||||
image->x1 = image->x0 + (Info_h.biWidth - 1U) * (uint32_t)parameters->subsampling_dx + 1U;
|
||||
image->y1 = image->y0 + (Info_h.biHeight - 1U) * (uint32_t)parameters->subsampling_dy + 1U;
|
||||
|
||||
/* Read the data */
|
||||
if (Info_h.biBitCount == 24 && Info_h.biCompression == 0) { /*RGB */
|
||||
bmp24toimage(pData, stride, image);
|
||||
}
|
||||
else if (Info_h.biBitCount == 8 && Info_h.biCompression == 0) { /* RGB 8bpp Indexed */
|
||||
bmp8toimage(pData, stride, image, pLUT);
|
||||
}
|
||||
else if (Info_h.biBitCount == 8 && Info_h.biCompression == 1) { /*RLE8*/
|
||||
bmp8toimage(pData, stride, image, pLUT);
|
||||
}
|
||||
else if (Info_h.biBitCount == 4 && Info_h.biCompression == 2) { /*RLE4*/
|
||||
bmp8toimage(pData, stride, image, pLUT); /* RLE 4 gets decoded as 8 bits data for now */
|
||||
}
|
||||
else if (Info_h.biBitCount == 32 && Info_h.biCompression == 0) { /* RGBX */
|
||||
bmpmask32toimage(pData, stride, image, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, 0x00000000U);
|
||||
}
|
||||
else if (Info_h.biBitCount == 32 && Info_h.biCompression == 3) { /* bitmask */
|
||||
bmpmask32toimage(pData, stride, image, Info_h.biRedMask, Info_h.biGreenMask, Info_h.biBlueMask, Info_h.biAlphaMask);
|
||||
}
|
||||
else if (Info_h.biBitCount == 16 && Info_h.biCompression == 0) { /* RGBX */
|
||||
bmpmask16toimage(pData, stride, image, 0x7C00U, 0x03E0U, 0x001FU, 0x0000U);
|
||||
}
|
||||
else if (Info_h.biBitCount == 16 && Info_h.biCompression == 3) { /* bitmask */
|
||||
if ((Info_h.biRedMask == 0U) && (Info_h.biGreenMask == 0U) && (Info_h.biBlueMask == 0U)) {
|
||||
Info_h.biRedMask = 0xF800U;
|
||||
Info_h.biGreenMask = 0x07E0U;
|
||||
Info_h.biBlueMask = 0x001FU;
|
||||
}
|
||||
bmpmask16toimage(pData, stride, image, Info_h.biRedMask, Info_h.biGreenMask, Info_h.biBlueMask, Info_h.biAlphaMask);
|
||||
}
|
||||
else {
|
||||
opj_image_destroy(image);
|
||||
image = NULL;
|
||||
fprintf(stderr, "Other system than 24 bits/pixels or 8 bits (no RLE coding) is not yet implemented [%d]\n", Info_h.biBitCount);
|
||||
}
|
||||
free(pData);
|
||||
fclose(IN);
|
||||
return image;
|
||||
}
|
||||
|
||||
int imagetobmp(opj_image_t * image, const char *outfile) {
|
||||
int w, h;
|
||||
int i, pad;
|
||||
FILE *fdest = NULL;
|
||||
int adjustR, adjustG, adjustB;
|
||||
|
||||
if (image->comps[0].prec < 8) {
|
||||
fprintf(stderr, "Unsupported number of components: %d\n", image->comps[0].prec);
|
||||
return 1;
|
||||
}
|
||||
if (image->numcomps >= 3 && image->comps[0].dx == image->comps[1].dx
|
||||
&& image->comps[1].dx == image->comps[2].dx
|
||||
&& image->comps[0].dy == image->comps[1].dy
|
||||
&& image->comps[1].dy == image->comps[2].dy
|
||||
&& image->comps[0].prec == image->comps[1].prec
|
||||
&& image->comps[1].prec == image->comps[2].prec) {
|
||||
|
||||
/* -->> -->> -->> -->>
|
||||
24 bits color
|
||||
<<-- <<-- <<-- <<-- */
|
||||
|
||||
fdest = fopen(outfile, "wb");
|
||||
if (!fdest) {
|
||||
fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
w = (int)image->comps[0].w;
|
||||
h = (int)image->comps[0].h;
|
||||
|
||||
fprintf(fdest, "BM");
|
||||
|
||||
/* FILE HEADER */
|
||||
/* ------------- */
|
||||
fprintf(fdest, "%c%c%c%c",
|
||||
(uint8_t) (h * w * 3 + 3 * h * (w % 2) + 54) & 0xff,
|
||||
(uint8_t) ((h * w * 3 + 3 * h * (w % 2) + 54) >> 8) & 0xff,
|
||||
(uint8_t) ((h * w * 3 + 3 * h * (w % 2) + 54) >> 16) & 0xff,
|
||||
(uint8_t) ((h * w * 3 + 3 * h * (w % 2) + 54) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (54) & 0xff, ((54) >> 8) & 0xff,((54) >> 16) & 0xff, ((54) >> 24) & 0xff);
|
||||
|
||||
/* INFO HEADER */
|
||||
/* ------------- */
|
||||
fprintf(fdest, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff, ((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (uint8_t) ((w) & 0xff),
|
||||
(uint8_t) ((w) >> 8) & 0xff,
|
||||
(uint8_t) ((w) >> 16) & 0xff,
|
||||
(uint8_t) ((w) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (uint8_t) ((h) & 0xff),
|
||||
(uint8_t) ((h) >> 8) & 0xff,
|
||||
(uint8_t) ((h) >> 16) & 0xff,
|
||||
(uint8_t) ((h) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
|
||||
fprintf(fdest, "%c%c", (24) & 0xff, ((24) >> 8) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (uint8_t) (3 * h * w + 3 * h * (w % 2)) & 0xff,
|
||||
(uint8_t) ((h * w * 3 + 3 * h * (w % 2)) >> 8) & 0xff,
|
||||
(uint8_t) ((h * w * 3 + 3 * h * (w % 2)) >> 16) & 0xff,
|
||||
(uint8_t) ((h * w * 3 + 3 * h * (w % 2)) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
|
||||
if (image->comps[0].prec > 8) {
|
||||
adjustR = (int)image->comps[0].prec - 8;
|
||||
printf("BMP CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
|
||||
}
|
||||
else
|
||||
adjustR = 0;
|
||||
if (image->comps[1].prec > 8) {
|
||||
adjustG = (int)image->comps[1].prec - 8;
|
||||
printf("BMP CONVERSION: Truncating component 1 from %d bits to 8 bits\n", image->comps[1].prec);
|
||||
}
|
||||
else
|
||||
adjustG = 0;
|
||||
if (image->comps[2].prec > 8) {
|
||||
adjustB = (int)image->comps[2].prec - 8;
|
||||
printf("BMP CONVERSION: Truncating component 2 from %d bits to 8 bits\n", image->comps[2].prec);
|
||||
}
|
||||
else
|
||||
adjustB = 0;
|
||||
|
||||
for (i = 0; i < w * h; i++) {
|
||||
uint8_t rc, gc, bc;
|
||||
int r, g, b;
|
||||
|
||||
r = image->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||
r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
||||
r = ((r >> adjustR)+((r >> (adjustR-1))%2));
|
||||
if(r > 255) r = 255; else if(r < 0) r = 0;
|
||||
rc = (uint8_t)r;
|
||||
|
||||
g = image->comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||
g += (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
|
||||
g = ((g >> adjustG)+((g >> (adjustG-1))%2));
|
||||
if(g > 255) g = 255; else if(g < 0) g = 0;
|
||||
gc = (uint8_t)g;
|
||||
|
||||
b = image->comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||
b += (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0);
|
||||
b = ((b >> adjustB)+((b >> (adjustB-1))%2));
|
||||
if(b > 255) b = 255; else if(b < 0) b = 0;
|
||||
bc = (uint8_t)b;
|
||||
|
||||
fprintf(fdest, "%c%c%c", bc, gc, rc);
|
||||
|
||||
if ((i + 1) % w == 0) {
|
||||
for (pad = (3 * w) % 4 ? 4 - (3 * w) % 4 : 0; pad > 0; pad--) /* ADD */
|
||||
fprintf(fdest, "%c", 0);
|
||||
}
|
||||
}
|
||||
fclose(fdest);
|
||||
} else { /* Gray-scale */
|
||||
|
||||
/* -->> -->> -->> -->>
|
||||
8 bits non code (Gray scale)
|
||||
<<-- <<-- <<-- <<-- */
|
||||
|
||||
fdest = fopen(outfile, "wb");
|
||||
if (!fdest) {
|
||||
fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
|
||||
return 1;
|
||||
}
|
||||
w = (int)image->comps[0].w;
|
||||
h = (int)image->comps[0].h;
|
||||
|
||||
fprintf(fdest, "BM");
|
||||
|
||||
/* FILE HEADER */
|
||||
/* ------------- */
|
||||
fprintf(fdest, "%c%c%c%c", (uint8_t) (h * w + 54 + 1024 + h * (w % 2)) & 0xff,
|
||||
(uint8_t) ((h * w + 54 + 1024 + h * (w % 2)) >> 8) & 0xff,
|
||||
(uint8_t) ((h * w + 54 + 1024 + h * (w % 2)) >> 16) & 0xff,
|
||||
(uint8_t) ((h * w + 54 + 1024 + w * (w % 2)) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (54 + 1024) & 0xff, ((54 + 1024) >> 8) & 0xff,
|
||||
((54 + 1024) >> 16) & 0xff,
|
||||
((54 + 1024) >> 24) & 0xff);
|
||||
|
||||
/* INFO HEADER */
|
||||
/* ------------- */
|
||||
fprintf(fdest, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff, ((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (uint8_t) ((w) & 0xff),
|
||||
(uint8_t) ((w) >> 8) & 0xff,
|
||||
(uint8_t) ((w) >> 16) & 0xff,
|
||||
(uint8_t) ((w) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (uint8_t) ((h) & 0xff),
|
||||
(uint8_t) ((h) >> 8) & 0xff,
|
||||
(uint8_t) ((h) >> 16) & 0xff,
|
||||
(uint8_t) ((h) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
|
||||
fprintf(fdest, "%c%c", (8) & 0xff, ((8) >> 8) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff, ((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (uint8_t) (h * w + h * (w % 2)) & 0xff,
|
||||
(uint8_t) ((h * w + h * (w % 2)) >> 8) & 0xff,
|
||||
(uint8_t) ((h * w + h * (w % 2)) >> 16) & 0xff,
|
||||
(uint8_t) ((h * w + h * (w % 2)) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff, ((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff, ((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
|
||||
fprintf(fdest, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff, ((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
|
||||
|
||||
if (image->comps[0].prec > 8) {
|
||||
adjustR = (int)image->comps[0].prec - 8;
|
||||
printf("BMP CONVERSION: Truncating component 0 from %d bits to 8 bits\n", image->comps[0].prec);
|
||||
}else
|
||||
adjustR = 0;
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
fprintf(fdest, "%c%c%c%c", i, i, i, 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < w * h; i++) {
|
||||
int r;
|
||||
|
||||
r = image->comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
|
||||
r += (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
|
||||
r = ((r >> adjustR)+((r >> (adjustR-1))%2));
|
||||
if(r > 255) r = 255; else if(r < 0) r = 0;
|
||||
|
||||
fprintf(fdest, "%c", (uint8_t)r);
|
||||
|
||||
if ((i + 1) % w == 0) {
|
||||
for (pad = w % 4 ? 4 - w % 4 : 0; pad > 0; pad--) /* ADD */
|
||||
fprintf(fdest, "%c", 0);
|
||||
}
|
||||
}
|
||||
fclose(fdest);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,496 +0,0 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||
* Copyright (c) 2015, Matthieu Darbois
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "opj_config.h"
|
||||
|
||||
#ifndef HAVE_LIBPNG
|
||||
# error HAVE_LIBPNG_NOT_DEFINED
|
||||
#endif /* HAVE_LIBPNG */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <zlib.h>
|
||||
#include <png.h>
|
||||
|
||||
#include "openjpeg.h"
|
||||
#include "convert.h"
|
||||
|
||||
#define PNG_MAGIC "\x89PNG\x0d\x0a\x1a\x0a"
|
||||
#define MAGIC_SIZE 8
|
||||
/* PNG allows bits per sample: 1, 2, 4, 8, 16 */
|
||||
|
||||
|
||||
static void convert_16u32s_C1R(const png_byte* pSrc, png_int_32* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < length; i++) {
|
||||
png_int_32 val0 = *pSrc++;
|
||||
png_int_32 val1 = *pSrc++;
|
||||
pDst[i] = val0 << 8 | val1;
|
||||
}
|
||||
}
|
||||
|
||||
opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
|
||||
{
|
||||
png_structp png = NULL;
|
||||
png_infop info = NULL;
|
||||
double gamma;
|
||||
int bit_depth, interlace_type,compression_type, filter_type;
|
||||
png_uint_32 i;
|
||||
png_uint_32 width, height = 0U;
|
||||
int color_type;
|
||||
FILE *reader = NULL;
|
||||
png_byte** rows = NULL;
|
||||
png_int_32* row32s = NULL;
|
||||
/* j2k: */
|
||||
opj_image_t *image = NULL;
|
||||
opj_image_cmptparm_t cmptparm[4];
|
||||
png_uint_32 nr_comp;
|
||||
png_byte sigbuf[8];
|
||||
convert_XXx32s_C1R cvtXXTo32s = NULL;
|
||||
convert_32s_CXPX cvtCxToPx = NULL;
|
||||
png_int_32* planes[4];
|
||||
|
||||
if((reader = fopen(read_idf, "rb")) == NULL)
|
||||
{
|
||||
fprintf(stderr,"pngtoimage: can not open %s\n",read_idf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(fread(sigbuf, 1, MAGIC_SIZE, reader) != MAGIC_SIZE
|
||||
|| memcmp(sigbuf, PNG_MAGIC, MAGIC_SIZE) != 0)
|
||||
{
|
||||
fprintf(stderr,"pngtoimage: %s is no valid PNG file\n",read_idf);
|
||||
goto fin;
|
||||
}
|
||||
|
||||
if((png = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||
NULL, NULL, NULL)) == NULL)
|
||||
goto fin;
|
||||
if((info = png_create_info_struct(png)) == NULL)
|
||||
goto fin;
|
||||
|
||||
if(setjmp(png_jmpbuf(png)))
|
||||
goto fin;
|
||||
|
||||
png_init_io(png, reader);
|
||||
png_set_sig_bytes(png, MAGIC_SIZE);
|
||||
|
||||
png_read_info(png, info);
|
||||
|
||||
if(png_get_IHDR(png, info, &width, &height,
|
||||
&bit_depth, &color_type, &interlace_type,
|
||||
&compression_type, &filter_type) == 0)
|
||||
goto fin;
|
||||
|
||||
/* png_set_expand():
|
||||
* expand paletted images to RGB, expand grayscale images of
|
||||
* less than 8-bit depth to 8-bit depth, and expand tRNS chunks
|
||||
* to alpha channels.
|
||||
*/
|
||||
if(color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||
png_set_expand(png);
|
||||
}
|
||||
|
||||
if(png_get_valid(png, info, PNG_INFO_tRNS)) {
|
||||
png_set_expand(png);
|
||||
}
|
||||
/* We might wan't to expand background */
|
||||
/*
|
||||
if(png_get_valid(png, info, PNG_INFO_bKGD)) {
|
||||
png_color_16p bgnd;
|
||||
png_get_bKGD(png, info, &bgnd);
|
||||
png_set_background(png, bgnd, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
|
||||
}
|
||||
*/
|
||||
|
||||
if( !png_get_gAMA(png, info, &gamma))
|
||||
gamma = 1.0;
|
||||
|
||||
/* we're not displaying but converting, screen gamma == 1.0 */
|
||||
png_set_gamma(png, 1.0, gamma);
|
||||
|
||||
png_read_update_info(png, info);
|
||||
|
||||
color_type = png_get_color_type(png, info);
|
||||
|
||||
switch (color_type) {
|
||||
case PNG_COLOR_TYPE_GRAY:
|
||||
nr_comp = 1;
|
||||
break;
|
||||
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||
nr_comp = 2;
|
||||
break;
|
||||
case PNG_COLOR_TYPE_RGB:
|
||||
nr_comp = 3;
|
||||
break;
|
||||
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||
nr_comp = 4;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"pngtoimage: colortype %d is not supported\n", color_type);
|
||||
goto fin;
|
||||
}
|
||||
cvtCxToPx = convert_32s_CXPX_LUT[nr_comp];
|
||||
bit_depth = png_get_bit_depth(png, info);
|
||||
|
||||
switch (bit_depth) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
cvtXXTo32s = convert_XXu32s_C1R_LUT[bit_depth];
|
||||
break;
|
||||
case 16: /* 16 bpp is specific to PNG */
|
||||
cvtXXTo32s = convert_16u32s_C1R;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"pngtoimage: bit depth %d is not supported\n", bit_depth);
|
||||
goto fin;
|
||||
}
|
||||
|
||||
|
||||
rows = (png_byte**)calloc(height+1, sizeof(png_byte*));
|
||||
for(i = 0; i < height; ++i)
|
||||
rows[i] = (png_byte*)malloc(png_get_rowbytes(png,info));
|
||||
|
||||
png_read_image(png, rows);
|
||||
|
||||
/* Create image */
|
||||
memset(cmptparm, 0, sizeof(cmptparm));
|
||||
for(i = 0; i < nr_comp; ++i)
|
||||
{
|
||||
cmptparm[i].prec = (png_uint_32)bit_depth;
|
||||
/* bits_per_pixel: 8 or 16 */
|
||||
cmptparm[i].bpp = (png_uint_32)bit_depth;
|
||||
cmptparm[i].sgnd = 0;
|
||||
cmptparm[i].dx = (png_uint_32)params->subsampling_dx;
|
||||
cmptparm[i].dy = (png_uint_32)params->subsampling_dy;
|
||||
cmptparm[i].w = (png_uint_32)width;
|
||||
cmptparm[i].h = (png_uint_32)height;
|
||||
}
|
||||
|
||||
image = opj_image_create(nr_comp, &cmptparm[0], (nr_comp > 2U) ? CLRSPC_SRGB : CLRSPC_GRAY);
|
||||
if(image == NULL) goto fin;
|
||||
image->x0 = (png_uint_32)params->image_offset_x0;
|
||||
image->y0 = (png_uint_32)params->image_offset_y0;
|
||||
image->x1 = (png_uint_32)(image->x0 + (width - 1) * (png_uint_32)params->subsampling_dx + 1 + image->x0);
|
||||
image->y1 = (png_uint_32)(image->y0 + (height - 1) * (png_uint_32)params->subsampling_dy + 1 + image->y0);
|
||||
|
||||
row32s = (png_int_32 *)malloc((size_t)width * nr_comp * sizeof(png_int_32));
|
||||
if(row32s == NULL) goto fin;
|
||||
|
||||
/* Set alpha channel */
|
||||
/* image->comps[nr_comp-1U].alpha = 1U - (nr_comp & 1U); */
|
||||
|
||||
for(i = 0; i < nr_comp; i++)
|
||||
{
|
||||
planes[i] = image->comps[i].data;
|
||||
}
|
||||
|
||||
for(i = 0; i < height; ++i)
|
||||
{
|
||||
cvtXXTo32s(rows[i], row32s, (size_t)width * nr_comp);
|
||||
cvtCxToPx(row32s, planes, width);
|
||||
planes[0] += width;
|
||||
planes[1] += width;
|
||||
planes[2] += width;
|
||||
planes[3] += width;
|
||||
}
|
||||
fin:
|
||||
if(rows)
|
||||
{
|
||||
for(i = 0; i < height; ++i)
|
||||
free(rows[i]);
|
||||
free(rows);
|
||||
}
|
||||
if (row32s) {
|
||||
free(row32s);
|
||||
}
|
||||
if(png)
|
||||
png_destroy_read_struct(&png, &info, NULL);
|
||||
|
||||
fclose(reader);
|
||||
|
||||
return image;
|
||||
|
||||
}/* pngtoimage() */
|
||||
|
||||
|
||||
static void convert_32s16u_C1R(const png_int_32* pSrc, png_byte* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < length; i++) {
|
||||
png_uint_32 val = (png_uint_32)pSrc[i];
|
||||
*pDst++ = (png_byte)(val >> 8);
|
||||
*pDst++ = (png_byte)val;
|
||||
}
|
||||
}
|
||||
int imagetopng(opj_image_t * image, const char *write_idf)
|
||||
{
|
||||
FILE * volatile writer = NULL;
|
||||
png_structp png = NULL;
|
||||
png_infop info = NULL;
|
||||
png_bytep volatile row_buf = NULL;
|
||||
int nr_comp, color_type;
|
||||
volatile int prec;
|
||||
png_color_8 sig_bit;
|
||||
png_int_32 const* planes[4];
|
||||
int i;
|
||||
png_int_32* volatile buffer32s = NULL;
|
||||
|
||||
volatile int fails = 1;
|
||||
|
||||
memset(&sig_bit, 0, sizeof(sig_bit));
|
||||
prec = (int)image->comps[0].prec;
|
||||
planes[0] = image->comps[0].data;
|
||||
nr_comp = (int)image->numcomps;
|
||||
|
||||
if (nr_comp > 4) {
|
||||
nr_comp = 4;
|
||||
}
|
||||
for (i = 1; i < nr_comp; ++i) {
|
||||
if (image->comps[0].dx != image->comps[i].dx) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].dy != image->comps[i].dy) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].prec != image->comps[i].prec) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].sgnd != image->comps[i].sgnd) {
|
||||
break;
|
||||
}
|
||||
planes[i] = image->comps[i].data;
|
||||
}
|
||||
if (i != nr_comp) {
|
||||
fprintf(stderr,"imagetopng: All components shall have the same subsampling, same bit depth, same sign.\n");
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < nr_comp; ++i) {
|
||||
clip_component(&(image->comps[i]), image->comps[0].prec);
|
||||
}
|
||||
if(prec > 8 && prec < 16)
|
||||
{
|
||||
for (i = 0; i < nr_comp; ++i) {
|
||||
scale_component(&(image->comps[i]), 16);
|
||||
}
|
||||
prec = 16;
|
||||
}
|
||||
else if(prec < 8 && nr_comp > 1)/* GRAY_ALPHA, RGB, RGB_ALPHA */
|
||||
{
|
||||
for (i = 0; i < nr_comp; ++i) {
|
||||
scale_component(&(image->comps[i]), 8);
|
||||
}
|
||||
prec = 8;
|
||||
} else if((prec > 1) && (prec < 8) && ((prec == 6) || ((prec & 1)==1))) { /* GRAY with non native precision */
|
||||
if ((prec == 5) || (prec == 6)) {
|
||||
prec = 8;
|
||||
} else {
|
||||
prec++;
|
||||
}
|
||||
for (i = 0; i < nr_comp; ++i) {
|
||||
scale_component(&(image->comps[i]), (png_uint_32)prec);
|
||||
}
|
||||
}
|
||||
|
||||
if(prec != 1 && prec != 2 && prec != 4 && prec != 8 && prec != 16)
|
||||
{
|
||||
fprintf(stderr,"imagetopng: can not create %s\n\twrong bit_depth %d\n", write_idf, prec);
|
||||
return fails;
|
||||
}
|
||||
|
||||
writer = fopen(write_idf, "wb");
|
||||
|
||||
if(writer == NULL) return fails;
|
||||
|
||||
/* Create and initialize the png_struct with the desired error handler
|
||||
* functions. If you want to use the default stderr and longjump method,
|
||||
* you can supply NULL for the last three parameters. We also check that
|
||||
* the library version is compatible with the one used at compile time,
|
||||
* in case we are using dynamically linked libraries. REQUIRED.
|
||||
*/
|
||||
png = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||
NULL, NULL, NULL);
|
||||
/*png_voidp user_error_ptr, user_error_fn, user_warning_fn); */
|
||||
|
||||
if(png == NULL) goto fin;
|
||||
|
||||
/* Allocate/initialize the image information data. REQUIRED
|
||||
*/
|
||||
info = png_create_info_struct(png);
|
||||
|
||||
if(info == NULL) goto fin;
|
||||
|
||||
/* Set error handling. REQUIRED if you are not supplying your own
|
||||
* error handling functions in the png_create_write_struct() call.
|
||||
*/
|
||||
if(setjmp(png_jmpbuf(png))) goto fin;
|
||||
|
||||
/* I/O initialization functions is REQUIRED
|
||||
*/
|
||||
png_init_io(png, writer);
|
||||
|
||||
/* Set the image information here. Width and height are up to 2^31,
|
||||
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
|
||||
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
|
||||
* PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
|
||||
* or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or
|
||||
* PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
|
||||
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE.
|
||||
* REQUIRED
|
||||
*
|
||||
* ERRORS:
|
||||
*
|
||||
* color_type == PNG_COLOR_TYPE_PALETTE && bit_depth > 8
|
||||
* color_type == PNG_COLOR_TYPE_RGB && bit_depth < 8
|
||||
* color_type == PNG_COLOR_TYPE_GRAY_ALPHA && bit_depth < 8
|
||||
* color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8
|
||||
*
|
||||
*/
|
||||
png_set_compression_level(png, Z_BEST_COMPRESSION);
|
||||
|
||||
if(nr_comp >= 3) /* RGB(A) */
|
||||
{
|
||||
color_type = PNG_COLOR_TYPE_RGB;
|
||||
sig_bit.red = sig_bit.green = sig_bit.blue = (png_byte)prec;
|
||||
}
|
||||
else /* GRAY(A) */
|
||||
{
|
||||
color_type = PNG_COLOR_TYPE_GRAY;
|
||||
sig_bit.gray = (png_byte)prec;
|
||||
}
|
||||
if((nr_comp & 1) == 0) /* ALPHA */
|
||||
{
|
||||
color_type |= PNG_COLOR_MASK_ALPHA;
|
||||
sig_bit.alpha = (png_byte)prec;
|
||||
}
|
||||
|
||||
png_set_IHDR(png, info, image->comps[0].w, image->comps[0].h, prec, color_type,
|
||||
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
png_set_sBIT(png, info, &sig_bit);
|
||||
/* png_set_gamma(png, 2.2, 1./2.2); */
|
||||
/* png_set_sRGB(png, info, PNG_sRGB_INTENT_PERCEPTUAL); */
|
||||
png_write_info(png, info);
|
||||
|
||||
/* setup conversion */
|
||||
{
|
||||
size_t rowStride;
|
||||
png_size_t png_row_size;
|
||||
|
||||
png_row_size = png_get_rowbytes(png, info);
|
||||
rowStride = ((size_t)image->comps[0].w * (size_t)nr_comp * (size_t)prec + 7U) / 8U;
|
||||
if (rowStride != (size_t)png_row_size) {
|
||||
fprintf(stderr, "Invalid PNG row size\n");
|
||||
goto fin;
|
||||
}
|
||||
row_buf = (png_bytep)malloc(png_row_size);
|
||||
if (row_buf == NULL) {
|
||||
fprintf(stderr, "Can't allocate memory for PNG row\n");
|
||||
goto fin;
|
||||
}
|
||||
buffer32s = (png_int_32*)malloc((size_t)image->comps[0].w * (size_t)nr_comp * sizeof(png_int_32));
|
||||
if (buffer32s == NULL) {
|
||||
fprintf(stderr, "Can't allocate memory for interleaved 32s row\n");
|
||||
goto fin;
|
||||
}
|
||||
}
|
||||
|
||||
/* convert */
|
||||
{
|
||||
size_t width= image->comps[0].w;
|
||||
int y;
|
||||
convert_32s_PXCX cvtPxToCx = convert_32s_PXCX_LUT[nr_comp];
|
||||
convert_32sXXx_C1R cvt32sToPack = NULL;
|
||||
png_int_32 adjust = image->comps[0].sgnd ? 1 << (prec - 1) : 0;
|
||||
png_bytep row_buf_cpy = row_buf;
|
||||
png_int_32* buffer32s_cpy = buffer32s;
|
||||
|
||||
switch (prec) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
cvt32sToPack = convert_32sXXu_C1R_LUT[prec];
|
||||
break;
|
||||
case 16:
|
||||
cvt32sToPack = convert_32s16u_C1R;
|
||||
break;
|
||||
default:
|
||||
/* never here */
|
||||
break;
|
||||
}
|
||||
|
||||
for(y = 0; y < image->comps[0].h; ++y)
|
||||
{
|
||||
cvtPxToCx(planes, buffer32s_cpy, width, adjust);
|
||||
cvt32sToPack(buffer32s_cpy, row_buf_cpy, width * (size_t)nr_comp);
|
||||
png_write_row(png, row_buf_cpy);
|
||||
planes[0] += width;
|
||||
planes[1] += width;
|
||||
planes[2] += width;
|
||||
planes[3] += width;
|
||||
}
|
||||
}
|
||||
|
||||
png_write_end(png, info);
|
||||
|
||||
fails = 0;
|
||||
|
||||
fin:
|
||||
if(png) {
|
||||
png_destroy_write_struct(&png, &info);
|
||||
}
|
||||
if(row_buf) {
|
||||
free(row_buf);
|
||||
}
|
||||
if(buffer32s) {
|
||||
free(buffer32s);
|
||||
}
|
||||
fclose(writer);
|
||||
|
||||
if(fails) (void)remove(write_idf); /* ignore return value */
|
||||
|
||||
return fails;
|
||||
}/* imagetopng() */
|
||||
@@ -1,633 +0,0 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||
* Copyright (c) 2003-2014, Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||
* Copyright (c) 2015, Matthieu Darbois
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "opj_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef HAVE_LIBTIFF
|
||||
# error HAVE_LIBTIFF_NOT_DEFINED
|
||||
#endif /* HAVE_LIBTIFF */
|
||||
|
||||
#include <tiffio.h>
|
||||
#include "openjpeg.h"
|
||||
#include "convert.h"
|
||||
|
||||
/* -->> -->> -->> -->>
|
||||
|
||||
TIFF IMAGE FORMAT
|
||||
|
||||
<<-- <<-- <<-- <<-- */
|
||||
|
||||
static void tif_32sto10u(const int32* pSrc, uint8* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < (length & ~(size_t)3U); i+=4U) {
|
||||
uint32 src0 = (uint32)pSrc[i+0];
|
||||
uint32 src1 = (uint32)pSrc[i+1];
|
||||
uint32 src2 = (uint32)pSrc[i+2];
|
||||
uint32 src3 = (uint32)pSrc[i+3];
|
||||
|
||||
*pDst++ = (uint8)(src0 >> 2);
|
||||
*pDst++ = (uint8)(((src0 & 0x3U) << 6) | (src1 >> 4));
|
||||
*pDst++ = (uint8)(((src1 & 0xFU) << 4) | (src2 >> 6));
|
||||
*pDst++ = (uint8)(((src2 & 0x3FU) << 2) | (src3 >> 8));
|
||||
*pDst++ = (uint8)(src3);
|
||||
}
|
||||
|
||||
if (length & 3U) {
|
||||
uint32 src0 = (uint32)pSrc[i+0];
|
||||
uint32 src1 = 0U;
|
||||
uint32 src2 = 0U;
|
||||
length = length & 3U;
|
||||
|
||||
if (length > 1U) {
|
||||
src1 = (uint32)pSrc[i+1];
|
||||
if (length > 2U) {
|
||||
src2 = (uint32)pSrc[i+2];
|
||||
}
|
||||
}
|
||||
*pDst++ = (uint8)(src0 >> 2);
|
||||
*pDst++ = (uint8)(((src0 & 0x3U) << 6) | (src1 >> 4));
|
||||
if (length > 1U) {
|
||||
*pDst++ = (uint8)(((src1 & 0xFU) << 4) | (src2 >> 6));
|
||||
if (length > 2U) {
|
||||
*pDst++ = (uint8)(((src2 & 0x3FU) << 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_32sto12u(const int32* pSrc, uint8* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < (length & ~(size_t)1U); i+=2U) {
|
||||
uint32 src0 = (uint32)pSrc[i+0];
|
||||
uint32 src1 = (uint32)pSrc[i+1];
|
||||
|
||||
*pDst++ = (uint8)(src0 >> 4);
|
||||
*pDst++ = (uint8)(((src0 & 0xFU) << 4) | (src1 >> 8));
|
||||
*pDst++ = (uint8)(src1);
|
||||
}
|
||||
|
||||
if (length & 1U) {
|
||||
uint32 src0 = (uint32)pSrc[i+0];
|
||||
*pDst++ = (uint8)(src0 >> 4);
|
||||
*pDst++ = (uint8)(((src0 & 0xFU) << 4));
|
||||
}
|
||||
}
|
||||
static void tif_32sto14u(const int32* pSrc, uint8* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < (length & ~(size_t)3U); i+=4U) {
|
||||
uint32 src0 = (uint32)pSrc[i+0];
|
||||
uint32 src1 = (uint32)pSrc[i+1];
|
||||
uint32 src2 = (uint32)pSrc[i+2];
|
||||
uint32 src3 = (uint32)pSrc[i+3];
|
||||
|
||||
*pDst++ = (uint8)(src0 >> 6);
|
||||
*pDst++ = (uint8)(((src0 & 0x3FU) << 2) | (src1 >> 12));
|
||||
*pDst++ = (uint8)(src1 >> 4);
|
||||
*pDst++ = (uint8)(((src1 & 0xFU) << 4) | (src2 >> 10));
|
||||
*pDst++ = (uint8)(src2 >> 2);
|
||||
*pDst++ = (uint8)(((src2 & 0x3U) << 6) | (src3 >> 8));
|
||||
*pDst++ = (uint8)(src3);
|
||||
}
|
||||
|
||||
if (length & 3U) {
|
||||
uint32 src0 = (uint32)pSrc[i+0];
|
||||
uint32 src1 = 0U;
|
||||
uint32 src2 = 0U;
|
||||
length = length & 3U;
|
||||
|
||||
if (length > 1U) {
|
||||
src1 = (uint32)pSrc[i+1];
|
||||
if (length > 2U) {
|
||||
src2 = (uint32)pSrc[i+2];
|
||||
}
|
||||
}
|
||||
*pDst++ = (uint8)(src0 >> 6);
|
||||
*pDst++ = (uint8)(((src0 & 0x3FU) << 2) | (src1 >> 12));
|
||||
if (length > 1U) {
|
||||
*pDst++ = (uint8)(src1 >> 4);
|
||||
*pDst++ = (uint8)(((src1 & 0xFU) << 4) | (src2 >> 10));
|
||||
if (length > 2U) {
|
||||
*pDst++ = (uint8)(src2 >> 2);
|
||||
*pDst++ = (uint8)(((src2 & 0x3U) << 6));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_32sto16u(const int32* pSrc, uint16* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < length; ++i) {
|
||||
pDst[i] = (uint16)pSrc[i];
|
||||
}
|
||||
}
|
||||
|
||||
int imagetotif(opj_image_t * image, const char *outfile)
|
||||
{
|
||||
int width, height;
|
||||
int bps,adjust, sgnd;
|
||||
int tiPhoto;
|
||||
TIFF *tif;
|
||||
tdata_t buf;
|
||||
tsize_t strip_size;
|
||||
int32 i, numcomps;
|
||||
size_t rowStride;
|
||||
int32* buffer32s = NULL;
|
||||
int32 const* planes[4];
|
||||
convert_32s_PXCX cvtPxToCx = NULL;
|
||||
convert_32sXXx_C1R cvt32sToTif = NULL;
|
||||
|
||||
bps = image->comps[0].prec;
|
||||
planes[0] = image->comps[0].data;
|
||||
|
||||
numcomps = image->numcomps;
|
||||
|
||||
if (numcomps > 2) {
|
||||
tiPhoto = PHOTOMETRIC_RGB;
|
||||
if (numcomps > 4) {
|
||||
numcomps = 4;
|
||||
}
|
||||
} else {
|
||||
tiPhoto = PHOTOMETRIC_MINISBLACK;
|
||||
}
|
||||
for (i = 1; i < numcomps; ++i) {
|
||||
if (image->comps[0].dx != image->comps[i].dx) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].dy != image->comps[i].dy) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].prec != image->comps[i].prec) {
|
||||
break;
|
||||
}
|
||||
if (image->comps[0].sgnd != image->comps[i].sgnd) {
|
||||
break;
|
||||
}
|
||||
planes[i] = image->comps[i].data;
|
||||
}
|
||||
if (i != numcomps) {
|
||||
fprintf(stderr,"imagetotif: All components shall have the same subsampling, same bit depth.\n");
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if((bps > 16) || ((bps != 1) && (bps & 1))) bps = 0;
|
||||
if(bps == 0)
|
||||
{
|
||||
fprintf(stderr,"imagetotif: Bits=%d, Only 1, 2, 4, 6, 8, 10, 12, 14 and 16 bits implemented\n",bps);
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
return 1;
|
||||
}
|
||||
tif = TIFFOpen(outfile, "wb");
|
||||
if (!tif)
|
||||
{
|
||||
fprintf(stderr, "imagetotif:failed to open %s for writing\n", outfile);
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < numcomps; ++i) {
|
||||
clip_component(&(image->comps[i]), image->comps[0].prec);
|
||||
}
|
||||
cvtPxToCx = convert_32s_PXCX_LUT[numcomps];
|
||||
switch (bps) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 6:
|
||||
case 8:
|
||||
cvt32sToTif = convert_32sXXu_C1R_LUT[bps];
|
||||
break;
|
||||
case 10:
|
||||
cvt32sToTif = tif_32sto10u;
|
||||
break;
|
||||
case 12:
|
||||
cvt32sToTif = tif_32sto12u;
|
||||
break;
|
||||
case 14:
|
||||
cvt32sToTif = tif_32sto14u;
|
||||
break;
|
||||
case 16:
|
||||
cvt32sToTif = (convert_32sXXx_C1R)tif_32sto16u;
|
||||
break;
|
||||
default:
|
||||
/* never here */
|
||||
break;
|
||||
}
|
||||
sgnd = (int)image->comps[0].sgnd;
|
||||
adjust = sgnd ? 1 << (image->comps[0].prec - 1) : 0;
|
||||
width = (int)image->comps[0].w;
|
||||
height = (int)image->comps[0].h;
|
||||
|
||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
|
||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
|
||||
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, numcomps);
|
||||
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
|
||||
TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
|
||||
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, tiPhoto);
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
|
||||
|
||||
strip_size = TIFFStripSize(tif);
|
||||
rowStride = ((size_t)width * numcomps * (size_t)bps + 7U) / 8U;
|
||||
if (rowStride != (size_t)strip_size) {
|
||||
fprintf(stderr, "Invalid TIFF strip size\n");
|
||||
TIFFClose(tif);
|
||||
return 1;
|
||||
}
|
||||
buf = _TIFFmalloc(strip_size);
|
||||
if (buf == NULL) {
|
||||
TIFFClose(tif);
|
||||
return 1;
|
||||
}
|
||||
buffer32s = (int32 *)malloc((size_t)width * numcomps * sizeof(int32));
|
||||
if (buffer32s == NULL) {
|
||||
_TIFFfree(buf);
|
||||
TIFFClose(tif);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < image->comps[0].h; ++i) {
|
||||
cvtPxToCx(planes, buffer32s, (size_t)width, adjust);
|
||||
cvt32sToTif(buffer32s, (uint8 *)buf, (size_t)width * numcomps);
|
||||
(void)TIFFWriteEncodedStrip(tif, i, (void*)buf, strip_size);
|
||||
planes[0] += width;
|
||||
planes[1] += width;
|
||||
planes[2] += width;
|
||||
planes[3] += width;
|
||||
}
|
||||
_TIFFfree((void*)buf);
|
||||
TIFFClose(tif);
|
||||
free(buffer32s);
|
||||
|
||||
return 0;
|
||||
}/* imagetotif() */
|
||||
|
||||
static void tif_10uto32s(const uint8* pSrc, int32* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < (length & ~(size_t)3U); i+=4U) {
|
||||
uint32 val0 = *pSrc++;
|
||||
uint32 val1 = *pSrc++;
|
||||
uint32 val2 = *pSrc++;
|
||||
uint32 val3 = *pSrc++;
|
||||
uint32 val4 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (int32)((val0 << 2) | (val1 >> 6));
|
||||
pDst[i+1] = (int32)(((val1 & 0x3FU) << 4) | (val2 >> 4));
|
||||
pDst[i+2] = (int32)(((val2 & 0xFU) << 6) | (val3 >> 2));
|
||||
pDst[i+3] = (int32)(((val3 & 0x3U) << 8) | val4);
|
||||
|
||||
}
|
||||
if (length & 3U) {
|
||||
uint32 val0 = *pSrc++;
|
||||
uint32 val1 = *pSrc++;
|
||||
length = length & 3U;
|
||||
pDst[i+0] = (int32)((val0 << 2) | (val1 >> 6));
|
||||
|
||||
if (length > 1U) {
|
||||
uint32 val2 = *pSrc++;
|
||||
pDst[i+1] = (int32)(((val1 & 0x3FU) << 4) | (val2 >> 4));
|
||||
if (length > 2U) {
|
||||
uint32 val3 = *pSrc++;
|
||||
pDst[i+2] = (int32)(((val2 & 0xFU) << 6) | (val3 >> 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void tif_12uto32s(const uint8* pSrc, int32* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < (length & ~(size_t)1U); i+=2U) {
|
||||
uint32 val0 = *pSrc++;
|
||||
uint32 val1 = *pSrc++;
|
||||
uint32 val2 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (int32)((val0 << 4) | (val1 >> 4));
|
||||
pDst[i+1] = (int32)(((val1 & 0xFU) << 8) | val2);
|
||||
}
|
||||
if (length & 1U) {
|
||||
uint32 val0 = *pSrc++;
|
||||
uint32 val1 = *pSrc++;
|
||||
pDst[i+0] = (int32)((val0 << 4) | (val1 >> 4));
|
||||
}
|
||||
}
|
||||
static void tif_14uto32s(const uint8* pSrc, int32* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < (length & ~(size_t)3U); i+=4U) {
|
||||
uint32 val0 = *pSrc++;
|
||||
uint32 val1 = *pSrc++;
|
||||
uint32 val2 = *pSrc++;
|
||||
uint32 val3 = *pSrc++;
|
||||
uint32 val4 = *pSrc++;
|
||||
uint32 val5 = *pSrc++;
|
||||
uint32 val6 = *pSrc++;
|
||||
|
||||
pDst[i+0] = (int32)((val0 << 6) | (val1 >> 2));
|
||||
pDst[i+1] = (int32)(((val1 & 0x3U) << 12) | (val2 << 4) | (val3 >> 4));
|
||||
pDst[i+2] = (int32)(((val3 & 0xFU) << 10) | (val4 << 2) | (val5 >> 6));
|
||||
pDst[i+3] = (int32)(((val5 & 0x3FU) << 8) | val6);
|
||||
|
||||
}
|
||||
if (length & 3U) {
|
||||
uint32 val0 = *pSrc++;
|
||||
uint32 val1 = *pSrc++;
|
||||
length = length & 3U;
|
||||
pDst[i+0] = (int32)((val0 << 6) | (val1 >> 2));
|
||||
|
||||
if (length > 1U) {
|
||||
uint32 val2 = *pSrc++;
|
||||
uint32 val3 = *pSrc++;
|
||||
pDst[i+1] = (int32)(((val1 & 0x3U) << 12) | (val2 << 4) | (val3 >> 4));
|
||||
if (length > 2U) {
|
||||
uint32 val4 = *pSrc++;
|
||||
uint32 val5 = *pSrc++;
|
||||
pDst[i+2] = (int32)(((val3 & 0xFU) << 10) | (val4 << 2) | (val5 >> 6));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* seems that libtiff decodes this to machine endianness */
|
||||
static void tif_16uto32s(const uint16* pSrc, int32* pDst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < length; i++) {
|
||||
pDst[i] = pSrc[i];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* libtiff/tif_getimage.c : 1,2,4,8,16 bitspersample accepted
|
||||
* CINEMA : 12 bit precision
|
||||
*/
|
||||
opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
||||
{
|
||||
int subsampling_dx = parameters->subsampling_dx;
|
||||
int subsampling_dy = parameters->subsampling_dy;
|
||||
TIFF *tif;
|
||||
tdata_t buf;
|
||||
tstrip_t strip;
|
||||
tsize_t strip_size;
|
||||
int j, currentPlane, numcomps = 0, w, h;
|
||||
OPJ_COLOR_SPACE color_space = CLRSPC_UNKNOWN;
|
||||
opj_image_cmptparm_t cmptparm[4]; /* RGBA */
|
||||
opj_image_t *image = NULL;
|
||||
int has_alpha = 0;
|
||||
unsigned short tiBps, tiPhoto, tiSf, tiSpp, tiPC;
|
||||
unsigned int tiWidth, tiHeight;
|
||||
opj_bool is_cinema = (parameters->cp_cinema != OFF) ? OPJ_TRUE : OPJ_FALSE;
|
||||
convert_XXx32s_C1R cvtTifTo32s = NULL;
|
||||
convert_32s_CXPX cvtCxToPx = NULL;
|
||||
int32* buffer32s = NULL;
|
||||
int32* planes[4];
|
||||
size_t rowStride;
|
||||
|
||||
tif = TIFFOpen(filename, "r");
|
||||
|
||||
if(!tif)
|
||||
{
|
||||
fprintf(stderr, "tiftoimage:Failed to open %s for reading\n", filename);
|
||||
return 0;
|
||||
}
|
||||
tiBps = tiPhoto = tiSf = tiSpp = tiPC = 0;
|
||||
tiWidth = tiHeight = 0;
|
||||
|
||||
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &tiWidth);
|
||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &tiHeight);
|
||||
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &tiBps);
|
||||
TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &tiSf);
|
||||
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &tiSpp);
|
||||
TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &tiPhoto);
|
||||
TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &tiPC);
|
||||
w= (int)tiWidth;
|
||||
h= (int)tiHeight;
|
||||
|
||||
if((tiBps > 16U) || ((tiBps != 1U) && (tiBps & 1U))) {
|
||||
fprintf(stderr,"tiftoimage: Bits=%d, Only 1, 2, 4, 6, 8, 10, 12, 14 and 16 bits implemented\n",tiBps);
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
TIFFClose(tif);
|
||||
return NULL;
|
||||
}
|
||||
if(tiPhoto != PHOTOMETRIC_MINISBLACK && tiPhoto != PHOTOMETRIC_RGB) {
|
||||
fprintf(stderr,"tiftoimage: Bad color format %d.\n\tOnly RGB(A) and GRAY(A) has been implemented\n",(int) tiPhoto);
|
||||
fprintf(stderr,"\tAborting\n");
|
||||
TIFFClose(tif);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (tiBps) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 6:
|
||||
case 8:
|
||||
cvtTifTo32s = convert_XXu32s_C1R_LUT[tiBps];
|
||||
break;
|
||||
/* others are specific to TIFF */
|
||||
case 10:
|
||||
cvtTifTo32s = tif_10uto32s;
|
||||
break;
|
||||
case 12:
|
||||
cvtTifTo32s = tif_12uto32s;
|
||||
break;
|
||||
case 14:
|
||||
cvtTifTo32s = tif_14uto32s;
|
||||
break;
|
||||
case 16:
|
||||
cvtTifTo32s = (convert_XXx32s_C1R)tif_16uto32s;
|
||||
break;
|
||||
default:
|
||||
/* never here */
|
||||
break;
|
||||
}
|
||||
|
||||
{/* From: tiff-4.0.x/libtiff/tif_getimage.c : */
|
||||
uint16* sampleinfo;
|
||||
uint16 extrasamples;
|
||||
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES,
|
||||
&extrasamples, &sampleinfo);
|
||||
|
||||
if(extrasamples >= 1)
|
||||
{
|
||||
switch(sampleinfo[0])
|
||||
{
|
||||
case EXTRASAMPLE_UNSPECIFIED:
|
||||
/* Workaround for some images without correct info about alpha channel
|
||||
*/
|
||||
if(tiSpp > 3)
|
||||
has_alpha = 1;
|
||||
break;
|
||||
|
||||
case EXTRASAMPLE_ASSOCALPHA: /* data pre-multiplied */
|
||||
case EXTRASAMPLE_UNASSALPHA: /* data not pre-multiplied */
|
||||
has_alpha = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else /* extrasamples == 0 */
|
||||
if(tiSpp == 4 || tiSpp == 2) has_alpha = 1;
|
||||
}
|
||||
|
||||
/* initialize image components */
|
||||
memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t));
|
||||
|
||||
if ((tiPhoto == PHOTOMETRIC_RGB) && (is_cinema) && (tiBps != 12U)) {
|
||||
fprintf(stdout,"WARNING:\n"
|
||||
"Input image bitdepth is %d bits\n"
|
||||
"TIF conversion has automatically rescaled to 12-bits\n"
|
||||
"to comply with cinema profiles.\n",
|
||||
tiBps);
|
||||
} else {
|
||||
is_cinema = 0U;
|
||||
}
|
||||
|
||||
if(tiPhoto == PHOTOMETRIC_RGB) /* RGB(A) */
|
||||
{
|
||||
numcomps = 3 + has_alpha;
|
||||
color_space = CLRSPC_SRGB;
|
||||
}
|
||||
else if (tiPhoto == PHOTOMETRIC_MINISBLACK) /* GRAY(A) */
|
||||
{
|
||||
numcomps = 1 + has_alpha;
|
||||
color_space = CLRSPC_GRAY;
|
||||
}
|
||||
|
||||
cvtCxToPx = convert_32s_CXPX_LUT[numcomps];
|
||||
if (tiPC == PLANARCONFIG_SEPARATE) {
|
||||
cvtCxToPx = convert_32s_CXPX_LUT[1]; /* override */
|
||||
tiSpp = 1U; /* consider only one sample per plane */
|
||||
}
|
||||
|
||||
for(j = 0; j < numcomps; j++)
|
||||
{
|
||||
cmptparm[j].prec = tiBps;
|
||||
cmptparm[j].bpp = tiBps;
|
||||
cmptparm[j].dx = (uint32)subsampling_dx;
|
||||
cmptparm[j].dy = (uint32)subsampling_dy;
|
||||
cmptparm[j].w = (uint32)w;
|
||||
cmptparm[j].h = (uint32)h;
|
||||
}
|
||||
|
||||
image = opj_image_create((uint32)numcomps, &cmptparm[0], color_space);
|
||||
if(!image)
|
||||
{
|
||||
TIFFClose(tif);
|
||||
return NULL;
|
||||
}
|
||||
/* set image offset and reference grid */
|
||||
image->x0 = (uint32)parameters->image_offset_x0;
|
||||
image->y0 = (uint32)parameters->image_offset_y0;
|
||||
image->x1 = !image->x0 ? (uint32)(w - 1) * (uint32)subsampling_dx + 1 :
|
||||
image->x0 + (uint32)(w - 1) * (uint32)subsampling_dx + 1;
|
||||
image->y1 = !image->y0 ? (uint32)(h - 1) * (uint32)subsampling_dy + 1 :
|
||||
image->y0 + (uint32)(h - 1) * (uint32)subsampling_dy + 1;
|
||||
|
||||
for(j = 0; j < numcomps; j++)
|
||||
{
|
||||
planes[j] = image->comps[j].data;
|
||||
}
|
||||
/* image->comps[numcomps - 1].alpha = (uint16)(1 - (numcomps & 1)); */
|
||||
|
||||
strip_size = TIFFStripSize(tif);
|
||||
|
||||
buf = _TIFFmalloc(strip_size);
|
||||
if (buf == NULL) {
|
||||
TIFFClose(tif);
|
||||
opj_image_destroy(image);
|
||||
return NULL;
|
||||
}
|
||||
rowStride = ((size_t)w * tiSpp * tiBps + 7U) / 8U;
|
||||
buffer32s = (int32 *)malloc((size_t)w * tiSpp * sizeof(int32));
|
||||
if (buffer32s == NULL) {
|
||||
_TIFFfree(buf);
|
||||
TIFFClose(tif);
|
||||
opj_image_destroy(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strip = 0;
|
||||
currentPlane = 0;
|
||||
do
|
||||
{
|
||||
planes[0] = image->comps[currentPlane].data; /* to manage planar data */
|
||||
h= (int)tiHeight;
|
||||
/* Read the Image components */
|
||||
for(; (h > 0) && (strip < TIFFNumberOfStrips(tif)); strip++)
|
||||
{
|
||||
const uint8 *dat8;
|
||||
size_t ssize;
|
||||
|
||||
ssize = (size_t)TIFFReadEncodedStrip(tif, strip, buf, strip_size);
|
||||
dat8 = (const uint8*)buf;
|
||||
|
||||
while (ssize >= rowStride) {
|
||||
cvtTifTo32s(dat8, buffer32s, (size_t)w * tiSpp);
|
||||
cvtCxToPx(buffer32s, planes, (size_t)w);
|
||||
planes[0] += w;
|
||||
planes[1] += w;
|
||||
planes[2] += w;
|
||||
planes[3] += w;
|
||||
dat8 += rowStride;
|
||||
ssize -= rowStride;
|
||||
h--;
|
||||
}
|
||||
}
|
||||
currentPlane++;
|
||||
} while ((tiPC == PLANARCONFIG_SEPARATE) && (currentPlane < numcomps));
|
||||
|
||||
free(buffer32s);
|
||||
_TIFFfree(buf);
|
||||
TIFFClose(tif);
|
||||
|
||||
if (is_cinema) {
|
||||
for (j=0; j < numcomps; ++j) {
|
||||
scale_component(&(image->comps[j]), 12);
|
||||
}
|
||||
|
||||
}
|
||||
return image;
|
||||
|
||||
}/* tiftoimage() */
|
||||
|
||||
@@ -1,691 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Mathieu Malaterre, GDCM
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "windirent.h"
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#define _stricmp strcasecmp
|
||||
#define _strnicmp strncasecmp
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include "opj_config.h"
|
||||
#include "openjpeg.h"
|
||||
#include "j2k.h"
|
||||
#include "jp2.h"
|
||||
#include "opj_getopt.h"
|
||||
#include "convert.h"
|
||||
#include "index.h"
|
||||
|
||||
#include "format_defs.h"
|
||||
|
||||
typedef struct dircnt{
|
||||
/** Buffer for holding images read from Directory*/
|
||||
char *filename_buf;
|
||||
/** Pointer to the buffer*/
|
||||
char **filename;
|
||||
}dircnt_t;
|
||||
|
||||
|
||||
typedef struct img_folder{
|
||||
/** The directory path of the folder containing input images*/
|
||||
char *imgdirpath;
|
||||
/** Output format*/
|
||||
const char *out_format;
|
||||
/** Enable option*/
|
||||
char set_imgdir;
|
||||
/** Enable Cod Format for output*/
|
||||
char set_out_format;
|
||||
|
||||
}img_fol_t;
|
||||
|
||||
void decode_help_display(void) {
|
||||
fprintf(stdout,"HELP for j2k_dump\n----\n\n");
|
||||
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||
|
||||
/* UniPG>> */
|
||||
fprintf(stdout,"List of parameters for the JPEG 2000 "
|
||||
#ifdef USE_JPWL
|
||||
"+ JPWL "
|
||||
#endif /* USE_JPWL */
|
||||
"decoder:\n");
|
||||
/* <<UniPG */
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout," -ImgDir \n");
|
||||
fprintf(stdout," Image file Directory path \n");
|
||||
fprintf(stdout," -i <compressed file>\n");
|
||||
fprintf(stdout," REQUIRED only if an Input image directory not specified\n");
|
||||
fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n");
|
||||
fprintf(stdout," is identified based on its suffix.\n");
|
||||
fprintf(stdout," -o <output file>\n");
|
||||
fprintf(stdout," OPTIONAL\n");
|
||||
fprintf(stdout," Output file where file info will be dump.\n");
|
||||
fprintf(stdout," By default it will be in the stdout.\n");
|
||||
fprintf(stdout,"\n");
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
static void j2k_dump_image(FILE *fd, opj_image_t * img);
|
||||
static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp);
|
||||
|
||||
int get_num_images(char *imgdirpath){
|
||||
DIR *dir;
|
||||
struct dirent* content;
|
||||
int num_images = 0;
|
||||
|
||||
/*Reading the input images from given input directory*/
|
||||
|
||||
dir= opendir(imgdirpath);
|
||||
if(!dir){
|
||||
fprintf(stderr,"Could not open Folder %s\n",imgdirpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while((content=readdir(dir))!=NULL){
|
||||
if(strcmp(".",content->d_name)==0 || strcmp("..",content->d_name)==0 )
|
||||
continue;
|
||||
num_images++;
|
||||
}
|
||||
closedir(dir);
|
||||
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++;
|
||||
}
|
||||
closedir(dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_file_format(char *filename) {
|
||||
unsigned int i;
|
||||
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
|
||||
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
|
||||
char * ext = strrchr(filename, '.');
|
||||
if (ext == NULL)
|
||||
return -1;
|
||||
ext++;
|
||||
if(ext) {
|
||||
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
||||
if(_strnicmp(ext, extension[i], 3) == 0) {
|
||||
return format[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
|
||||
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
|
||||
char *temp_p, temp1[OPJ_PATH_LEN]="";
|
||||
|
||||
strcpy(image_filename,dirptr->filename[imageno]);
|
||||
fprintf(stderr,"File Number %d \"%s\"\n",imageno,image_filename);
|
||||
parameters->decod_format = get_file_format(image_filename);
|
||||
if (parameters->decod_format == -1)
|
||||
return 1;
|
||||
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
|
||||
strncpy(parameters->infile, infilename, sizeof(infilename));
|
||||
|
||||
/*Set output file*/
|
||||
strcpy(temp_ofname,strtok(image_filename,"."));
|
||||
while((temp_p = strtok(NULL,".")) != NULL){
|
||||
strcat(temp_ofname,temp1);
|
||||
sprintf(temp1,".%s",temp_p);
|
||||
}
|
||||
if(img_fol->set_out_format==1){
|
||||
sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format);
|
||||
strncpy(parameters->outfile, outfilename, sizeof(outfilename));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
|
||||
/* parse the command line */
|
||||
int totlen, c;
|
||||
opj_option_t long_option[]={
|
||||
{"ImgDir",REQ_ARG, NULL ,'y'},
|
||||
#ifdef USE_SYSTEM_GETOPT
|
||||
{0,0,0,0} /* GNU getopt_long requirement */
|
||||
#endif
|
||||
};
|
||||
const char optlist[] = "i:o:h";
|
||||
|
||||
OPJ_ARG_NOT_USED(indexfilename);
|
||||
|
||||
totlen=sizeof(long_option);
|
||||
img_fol->set_out_format = 0;
|
||||
do {
|
||||
#ifdef USE_SYSTEM_GETOPT
|
||||
c = opj_getopt_long(argc, argv,optlist,long_option,0);
|
||||
#else
|
||||
c = opj_getopt_long(argc, argv,optlist,long_option,totlen);
|
||||
#endif
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
case 'i': /* input file */
|
||||
{
|
||||
char *infile = opj_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 = opj_optarg;
|
||||
strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'h': /* display an help description */
|
||||
decode_help_display();
|
||||
return 1;
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
case 'y': /* Image Directory path */
|
||||
{
|
||||
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
|
||||
strcpy(img_fol->imgdirpath,opj_optarg);
|
||||
img_fol->set_imgdir=1;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
default:
|
||||
fprintf(stderr,"[WARNING] An invalid option has been ignored\n");
|
||||
break;
|
||||
}
|
||||
}while(c != -1);
|
||||
|
||||
/* check for possible errors */
|
||||
if(img_fol->set_imgdir==1){
|
||||
if(!(parameters->infile[0]==0)){
|
||||
fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
|
||||
return 1;
|
||||
}
|
||||
if(img_fol->set_out_format == 0){
|
||||
fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
|
||||
fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
|
||||
return 1;
|
||||
}
|
||||
if(!(parameters->outfile[0] == 0)){
|
||||
fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
|
||||
return 1;
|
||||
}
|
||||
}else{
|
||||
if( parameters->infile[0] == 0 ) {
|
||||
fprintf(stderr, "Example: %s -i image.j2k\n",argv[0]);
|
||||
fprintf(stderr, " Try: %s -h\n",argv[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
sample error callback expecting a FILE* client object
|
||||
*/
|
||||
void error_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[ERROR] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample warning callback expecting a FILE* client object
|
||||
*/
|
||||
void warning_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[WARNING] %s", msg);
|
||||
}
|
||||
/**
|
||||
sample debug callback expecting no client object
|
||||
*/
|
||||
void info_callback(const char *msg, void *client_data) {
|
||||
(void)client_data;
|
||||
fprintf(stdout, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
opj_dparameters_t parameters; /* decompression parameters */
|
||||
img_fol_t img_fol;
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
opj_image_t *image = NULL;
|
||||
FILE *fsrc = NULL, *fout = NULL;
|
||||
unsigned char *src = NULL;
|
||||
int file_length;
|
||||
int num_images;
|
||||
int i,imageno;
|
||||
dircnt_t *dirptr = NULL;
|
||||
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
|
||||
opj_cio_t *cio = NULL;
|
||||
opj_codestream_info_t cstr_info; /* Codestream information structure */
|
||||
char indexfilename[OPJ_PATH_LEN]; /* index file name */
|
||||
|
||||
/* configure the event callbacks (not required) */
|
||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
event_mgr.error_handler = error_callback;
|
||||
event_mgr.warning_handler = warning_callback;
|
||||
event_mgr.info_handler = info_callback;
|
||||
|
||||
/* set decoding parameters to default values */
|
||||
opj_set_default_decoder_parameters(¶meters);
|
||||
|
||||
/* Initialize indexfilename and img_fol */
|
||||
*indexfilename = 0;
|
||||
memset(&img_fol,0,sizeof(img_fol_t));
|
||||
|
||||
/* parse input and get user encoding parameters */
|
||||
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* j2k_dump focuses on j2k codestream and skips JP2 boxes */
|
||||
parameters.flags = 1;
|
||||
/* j2k_dump shall not actually decode packets (parsing codestream is enough). */
|
||||
parameters.cp_limit_decoding = DECODE_ALL_BUT_PACKETS;
|
||||
|
||||
/* Initialize reading of directory */
|
||||
if(img_fol.set_imgdir==1){
|
||||
num_images=get_num_images(img_fol.imgdirpath);
|
||||
|
||||
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
|
||||
if(dirptr){
|
||||
dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
|
||||
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
|
||||
|
||||
if(!dirptr->filename_buf){
|
||||
return 1;
|
||||
}
|
||||
for(i=0;i<num_images;i++){
|
||||
dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
|
||||
}
|
||||
}
|
||||
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||
return 1;
|
||||
}
|
||||
if (num_images==0){
|
||||
fprintf(stdout,"Folder is empty\n");
|
||||
return 1;
|
||||
}
|
||||
}else{
|
||||
num_images=1;
|
||||
}
|
||||
|
||||
/* */
|
||||
if (parameters.outfile[0] != 0)
|
||||
{
|
||||
fout = fopen(parameters.outfile,"w");
|
||||
if (!fout)
|
||||
{
|
||||
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.outfile);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
fout = stdout;
|
||||
|
||||
/*Encoding image one by one*/
|
||||
for(imageno = 0; imageno < num_images ; imageno++)
|
||||
{
|
||||
image = NULL;
|
||||
fprintf(stderr,"\n");
|
||||
|
||||
if(img_fol.set_imgdir==1){
|
||||
if (get_next_file(imageno, dirptr,&img_fol, ¶meters)) {
|
||||
fprintf(stderr,"skipping file...\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* read the input file and put it in memory */
|
||||
/* ---------------------------------------- */
|
||||
fsrc = fopen(parameters.infile, "rb");
|
||||
if (!fsrc) {
|
||||
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
||||
return 1;
|
||||
}
|
||||
fseek(fsrc, 0, SEEK_END);
|
||||
file_length = ftell(fsrc);
|
||||
fseek(fsrc, 0, SEEK_SET);
|
||||
src = (unsigned char *) malloc(file_length);
|
||||
if (fread(src, 1, file_length, fsrc) != (size_t)file_length)
|
||||
{
|
||||
free(src);
|
||||
fclose(fsrc);
|
||||
fclose(fout);
|
||||
fprintf(stderr, "\nERROR: fread return a number of element different from the expected.\n");
|
||||
return 1;
|
||||
}
|
||||
fclose(fsrc);
|
||||
|
||||
/* decode the code-stream */
|
||||
/* ---------------------- */
|
||||
|
||||
switch(parameters.decod_format) {
|
||||
case J2K_CFMT:
|
||||
{
|
||||
/* JPEG-2000 codestream */
|
||||
|
||||
/* get a decoder handle */
|
||||
dinfo = opj_create_decompress(CODEC_J2K);
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
|
||||
/* decode the stream and fill the image structure */
|
||||
if (*indexfilename) /* If need to extract codestream information*/
|
||||
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||
else
|
||||
image = opj_decode(dinfo, cio);
|
||||
if(!image) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
fclose(fout);
|
||||
free(src);
|
||||
return 1;
|
||||
}
|
||||
/* dump image */
|
||||
j2k_dump_image(fout, image);
|
||||
|
||||
/* dump cp */
|
||||
j2k_dump_cp(fout, image, ((opj_j2k_t*)dinfo->j2k_handle)->cp);
|
||||
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
|
||||
/* Write the index to disk */
|
||||
if (*indexfilename) {
|
||||
opj_bool bSuccess;
|
||||
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||
if (bSuccess) {
|
||||
fprintf(stderr, "Failed to output index file\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case JP2_CFMT:
|
||||
{
|
||||
/* JPEG 2000 compressed image data */
|
||||
|
||||
/* get a decoder handle */
|
||||
dinfo = opj_create_decompress(CODEC_JP2);
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using the current image and user parameters */
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
|
||||
/* decode the stream and fill the image structure */
|
||||
if (*indexfilename) /* If need to extract codestream information*/
|
||||
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||
else
|
||||
image = opj_decode(dinfo, cio);
|
||||
if(!image) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
fclose(fout);
|
||||
free(src);
|
||||
return 1;
|
||||
}
|
||||
/* dump image */
|
||||
if(image->icc_profile_buf)
|
||||
{
|
||||
free(image->icc_profile_buf); image->icc_profile_buf = NULL;
|
||||
}
|
||||
j2k_dump_image(fout, image);
|
||||
|
||||
/* dump cp */
|
||||
j2k_dump_cp(fout, image, ((opj_jp2_t*)dinfo->jp2_handle)->j2k->cp);
|
||||
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
|
||||
/* Write the index to disk */
|
||||
if (*indexfilename) {
|
||||
opj_bool bSuccess;
|
||||
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||
if (bSuccess) {
|
||||
fprintf(stderr, "Failed to output index file\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case JPT_CFMT:
|
||||
{
|
||||
/* JPEG 2000, JPIP */
|
||||
|
||||
/* get a decoder handle */
|
||||
dinfo = opj_create_decompress(CODEC_JPT);
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
|
||||
/* decode the stream and fill the image structure */
|
||||
if (*indexfilename) /* If need to extract codestream information*/
|
||||
image = opj_decode_with_info(dinfo, cio, &cstr_info);
|
||||
else
|
||||
image = opj_decode(dinfo, cio);
|
||||
if(!image) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
fclose(fout);
|
||||
free(src);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
|
||||
/* Write the index to disk */
|
||||
if (*indexfilename) {
|
||||
opj_bool bSuccess;
|
||||
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||
if (bSuccess) {
|
||||
fprintf(stderr, "Failed to output index file\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "skipping file..\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* free the memory containing the code-stream */
|
||||
free(src);
|
||||
src = NULL;
|
||||
|
||||
/* free remaining structures */
|
||||
if(dinfo) {
|
||||
opj_destroy_decompress(dinfo);
|
||||
}
|
||||
/* free codestream information structure */
|
||||
if (*indexfilename)
|
||||
opj_destroy_cstr_info(&cstr_info);
|
||||
/* free image data structure */
|
||||
opj_image_destroy(image);
|
||||
|
||||
}
|
||||
|
||||
fclose(fout);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static void j2k_dump_image(FILE *fd, opj_image_t * img) {
|
||||
int compno;
|
||||
fprintf(fd, "image {\n");
|
||||
fprintf(fd, " x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0, img->x1, img->y1);
|
||||
fprintf(fd, " numcomps=%d\n", img->numcomps);
|
||||
for (compno = 0; compno < img->numcomps; compno++) {
|
||||
opj_image_comp_t *comp = &img->comps[compno];
|
||||
fprintf(fd, " comp %d {\n", compno);
|
||||
fprintf(fd, " dx=%d, dy=%d\n", comp->dx, comp->dy);
|
||||
fprintf(fd, " prec=%d\n", comp->prec);
|
||||
/*fprintf(fd, " bpp=%d\n", comp->bpp);*/
|
||||
fprintf(fd, " sgnd=%d\n", comp->sgnd);
|
||||
fprintf(fd, " }\n");
|
||||
}
|
||||
fprintf(fd, "}\n");
|
||||
}
|
||||
|
||||
static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp) {
|
||||
int tileno, compno, layno, bandno, resno, numbands;
|
||||
fprintf(fd, "coding parameters {\n");
|
||||
fprintf(fd, " tx0=%d, ty0=%d\n", cp->tx0, cp->ty0);
|
||||
fprintf(fd, " tdx=%d, tdy=%d\n", cp->tdx, cp->tdy);
|
||||
fprintf(fd, " tw=%d, th=%d\n", cp->tw, cp->th);
|
||||
for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
|
||||
opj_tcp_t *tcp = &cp->tcps[tileno];
|
||||
fprintf(fd, " tile %d {\n", tileno);
|
||||
fprintf(fd, " csty=%x\n", tcp->csty);
|
||||
fprintf(fd, " prg=%d\n", tcp->prg);
|
||||
fprintf(fd, " numlayers=%d\n", tcp->numlayers);
|
||||
fprintf(fd, " mct=%d\n", tcp->mct);
|
||||
fprintf(fd, " rates=");
|
||||
for (layno = 0; layno < tcp->numlayers; layno++) {
|
||||
fprintf(fd, "%.1f ", tcp->rates[layno]);
|
||||
}
|
||||
fprintf(fd, "\n");
|
||||
for (compno = 0; compno < img->numcomps; compno++) {
|
||||
opj_tccp_t *tccp = &tcp->tccps[compno];
|
||||
fprintf(fd, " comp %d {\n", compno);
|
||||
fprintf(fd, " csty=%x\n", tccp->csty);
|
||||
fprintf(fd, " numresolutions=%d\n", tccp->numresolutions);
|
||||
fprintf(fd, " cblkw=%d\n", tccp->cblkw);
|
||||
fprintf(fd, " cblkh=%d\n", tccp->cblkh);
|
||||
fprintf(fd, " cblksty=%x\n", tccp->cblksty);
|
||||
fprintf(fd, " qmfbid=%d\n", tccp->qmfbid);
|
||||
fprintf(fd, " qntsty=%d\n", tccp->qntsty);
|
||||
fprintf(fd, " numgbits=%d\n", tccp->numgbits);
|
||||
fprintf(fd, " roishift=%d\n", tccp->roishift);
|
||||
fprintf(fd, " stepsizes=");
|
||||
numbands = tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2;
|
||||
for (bandno = 0; bandno < numbands; bandno++) {
|
||||
fprintf(fd, "(%d,%d) ", tccp->stepsizes[bandno].mant,
|
||||
tccp->stepsizes[bandno].expn);
|
||||
}
|
||||
fprintf(fd, "\n");
|
||||
|
||||
if (tccp->csty & J2K_CCP_CSTY_PRT) {
|
||||
fprintf(fd, " prcw=");
|
||||
for (resno = 0; resno < tccp->numresolutions; resno++) {
|
||||
fprintf(fd, "%d ", tccp->prcw[resno]);
|
||||
}
|
||||
fprintf(fd, "\n");
|
||||
fprintf(fd, " prch=");
|
||||
for (resno = 0; resno < tccp->numresolutions; resno++) {
|
||||
fprintf(fd, "%d ", tccp->prch[resno]);
|
||||
}
|
||||
fprintf(fd, "\n");
|
||||
}
|
||||
fprintf(fd, " }\n");
|
||||
}
|
||||
fprintf(fd, " }\n");
|
||||
}
|
||||
fprintf(fd, "}\n");
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,537 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 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
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "opj_config.h"
|
||||
#include "openjpeg.h"
|
||||
#include "color.h"
|
||||
|
||||
#ifdef HAVE_LIBLCMS2
|
||||
#include <lcms2.h>
|
||||
#endif
|
||||
#ifdef HAVE_LIBLCMS1
|
||||
#include <lcms.h>
|
||||
#endif
|
||||
|
||||
/*--------------------------------------------------------
|
||||
Matrix for sYCC, Amendment 1 to IEC 61966-2-1
|
||||
|
||||
Y : 0.299 0.587 0.114 :R
|
||||
Cb: -0.1687 -0.3312 0.5 :G
|
||||
Cr: 0.5 -0.4187 -0.0812 :B
|
||||
|
||||
Inverse:
|
||||
|
||||
R: 1 -3.68213e-05 1.40199 :Y
|
||||
G: 1.00003 -0.344125 -0.714128 :Cb - 2^(prec - 1)
|
||||
B: 0.999823 1.77204 -8.04142e-06 :Cr - 2^(prec - 1)
|
||||
|
||||
-----------------------------------------------------------*/
|
||||
static void sycc_to_rgb(int offset, int upb, int y, int cb, int cr,
|
||||
int *out_r, int *out_g, int *out_b)
|
||||
{
|
||||
int r, g, b;
|
||||
|
||||
cb -= offset; cr -= offset;
|
||||
r = y + (int)(1.402 * (float)cr);
|
||||
if(r < 0) r = 0; else if(r > upb) r = upb; *out_r = r;
|
||||
|
||||
g = y - (int)(0.344 * (float)cb + 0.714 * (float)cr);
|
||||
if(g < 0) g = 0; else if(g > upb) g = upb; *out_g = g;
|
||||
|
||||
b = y + (int)(1.772 * (float)cb);
|
||||
if(b < 0) b = 0; else if(b > upb) b = upb; *out_b = b;
|
||||
}
|
||||
|
||||
static void sycc444_to_rgb(opj_image_t *img)
|
||||
{
|
||||
int *d0, *d1, *d2, *r, *g, *b;
|
||||
const int *y, *cb, *cr;
|
||||
unsigned int maxw, maxh, max, i;
|
||||
int offset, upb;
|
||||
|
||||
upb = (int)img->comps[0].prec;
|
||||
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||
|
||||
maxw = (unsigned int)img->comps[0].w; maxh = (unsigned int)img->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
|
||||
y = img->comps[0].data;
|
||||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
|
||||
for(i = 0U; i < max; ++i)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++cb; ++cr; ++r; ++g; ++b;
|
||||
}
|
||||
free(img->comps[0].data); img->comps[0].data = d0;
|
||||
free(img->comps[1].data); img->comps[1].data = d1;
|
||||
free(img->comps[2].data); img->comps[2].data = d2;
|
||||
|
||||
}/* sycc444_to_rgb() */
|
||||
|
||||
static void sycc422_to_rgb(opj_image_t *img)
|
||||
{
|
||||
int *d0, *d1, *d2, *r, *g, *b;
|
||||
const int *y, *cb, *cr;
|
||||
unsigned int maxw, maxh, max;
|
||||
int offset, upb;
|
||||
unsigned int i, j;
|
||||
|
||||
upb = (int)img->comps[0].prec;
|
||||
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||
|
||||
maxw = (unsigned int)img->comps[0].w; maxh = (unsigned int)img->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
|
||||
y = img->comps[0].data;
|
||||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
|
||||
for(i=0U; i < maxh; ++i)
|
||||
{
|
||||
for(j=0U; j < (maxw & ~(unsigned int)1U); j += 2U)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b; ++cb; ++cr;
|
||||
}
|
||||
if (j < maxw) {
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b; ++cb; ++cr;
|
||||
}
|
||||
}
|
||||
free(img->comps[0].data); img->comps[0].data = d0;
|
||||
free(img->comps[1].data); img->comps[1].data = d1;
|
||||
free(img->comps[2].data); img->comps[2].data = d2;
|
||||
|
||||
img->comps[1].w = maxw; img->comps[1].h = maxh;
|
||||
img->comps[2].w = maxw; img->comps[2].h = maxh;
|
||||
img->comps[1].dx = img->comps[0].dx;
|
||||
img->comps[2].dx = img->comps[0].dx;
|
||||
img->comps[1].dy = img->comps[0].dy;
|
||||
img->comps[2].dy = img->comps[0].dy;
|
||||
}/* sycc422_to_rgb() */
|
||||
|
||||
static void sycc420_to_rgb(opj_image_t *img)
|
||||
{
|
||||
int *d0, *d1, *d2, *r, *g, *b, *nr, *ng, *nb;
|
||||
const int *y, *cb, *cr, *ny;
|
||||
unsigned int maxw, maxh, max;
|
||||
int offset, upb;
|
||||
unsigned int i, j;
|
||||
|
||||
upb = (int)img->comps[0].prec;
|
||||
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||
|
||||
maxw = (unsigned int)img->comps[0].w; maxh = (unsigned int)img->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
|
||||
y = img->comps[0].data;
|
||||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
|
||||
for(i=0U; i < (maxh & ~(unsigned int)1U); i += 2U)
|
||||
{
|
||||
ny = y + maxw;
|
||||
nr = r + maxw; ng = g + maxw; nb = b + maxw;
|
||||
|
||||
for(j=0; j < (maxw & ~(unsigned int)1U); j += 2U)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
|
||||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
++ny; ++nr; ++ng; ++nb;
|
||||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
|
||||
}
|
||||
if(j < maxw)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
++y; ++r; ++g; ++b;
|
||||
|
||||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
|
||||
}
|
||||
y += maxw; r += maxw; g += maxw; b += maxw;
|
||||
}
|
||||
if(i < maxh)
|
||||
{
|
||||
for(j=0U; j < (maxw & ~(unsigned int)1U); j += 2U)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++r; ++g; ++b;
|
||||
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++r; ++g; ++b; ++cb; ++cr;
|
||||
}
|
||||
if(j < maxw)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
free(img->comps[0].data); img->comps[0].data = d0;
|
||||
free(img->comps[1].data); img->comps[1].data = d1;
|
||||
free(img->comps[2].data); img->comps[2].data = d2;
|
||||
|
||||
img->comps[1].w = maxw; img->comps[1].h = maxh;
|
||||
img->comps[2].w = maxw; img->comps[2].h = maxh;
|
||||
img->comps[1].dx = img->comps[0].dx;
|
||||
img->comps[2].dx = img->comps[0].dx;
|
||||
img->comps[1].dy = img->comps[0].dy;
|
||||
img->comps[2].dy = img->comps[0].dy;
|
||||
|
||||
}/* sycc420_to_rgb() */
|
||||
|
||||
void color_sycc_to_rgb(opj_image_t *img)
|
||||
{
|
||||
if(img->numcomps < 3)
|
||||
{
|
||||
img->color_space = CLRSPC_GRAY;
|
||||
return;
|
||||
}
|
||||
|
||||
if((img->comps[0].dx == 1)
|
||||
&& (img->comps[1].dx == 2)
|
||||
&& (img->comps[2].dx == 2)
|
||||
&& (img->comps[0].dy == 1)
|
||||
&& (img->comps[1].dy == 2)
|
||||
&& (img->comps[2].dy == 2))/* horizontal and vertical sub-sample */
|
||||
{
|
||||
sycc420_to_rgb(img);
|
||||
}
|
||||
else
|
||||
if((img->comps[0].dx == 1)
|
||||
&& (img->comps[1].dx == 2)
|
||||
&& (img->comps[2].dx == 2)
|
||||
&& (img->comps[0].dy == 1)
|
||||
&& (img->comps[1].dy == 1)
|
||||
&& (img->comps[2].dy == 1))/* horizontal sub-sample only */
|
||||
{
|
||||
sycc422_to_rgb(img);
|
||||
}
|
||||
else
|
||||
if((img->comps[0].dx == 1)
|
||||
&& (img->comps[1].dx == 1)
|
||||
&& (img->comps[2].dx == 1)
|
||||
&& (img->comps[0].dy == 1)
|
||||
&& (img->comps[1].dy == 1)
|
||||
&& (img->comps[2].dy == 1))/* no sub-sample */
|
||||
{
|
||||
sycc444_to_rgb(img);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"%s:%d:color_sycc_to_rgb\n\tCAN NOT CONVERT\n", __FILE__,__LINE__);
|
||||
return;
|
||||
}
|
||||
img->color_space = CLRSPC_SRGB;
|
||||
|
||||
}/* color_sycc_to_rgb() */
|
||||
|
||||
#if defined(HAVE_LIBLCMS2) || defined(HAVE_LIBLCMS1)
|
||||
#ifdef HAVE_LIBLCMS1
|
||||
/* Bob Friesenhahn proposed:*/
|
||||
#define cmsSigXYZData icSigXYZData
|
||||
#define cmsSigLabData icSigLabData
|
||||
#define cmsSigCmykData icSigCmykData
|
||||
#define cmsSigYCbCrData icSigYCbCrData
|
||||
#define cmsSigLuvData icSigLuvData
|
||||
#define cmsSigGrayData icSigGrayData
|
||||
#define cmsSigRgbData icSigRgbData
|
||||
#define cmsUInt32Number DWORD
|
||||
|
||||
#define cmsColorSpaceSignature icColorSpaceSignature
|
||||
#define cmsGetHeaderRenderingIntent cmsTakeRenderingIntent
|
||||
|
||||
#endif /* HAVE_LIBLCMS1 */
|
||||
|
||||
void color_apply_icc_profile(opj_image_t *image)
|
||||
{
|
||||
cmsHPROFILE in_prof, out_prof;
|
||||
cmsHTRANSFORM transform;
|
||||
cmsColorSpaceSignature in_space, out_space;
|
||||
cmsUInt32Number intent, in_type, out_type, nr_samples;
|
||||
int *r, *g, *b;
|
||||
int prec, i, max, max_w, max_h;
|
||||
OPJ_COLOR_SPACE oldspace;
|
||||
|
||||
in_prof =
|
||||
cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
|
||||
#ifdef DEBUG_PROFILE
|
||||
FILE *icm = fopen("debug.icm","wb");
|
||||
fwrite( image->icc_profile_buf,1, image->icc_profile_len,icm);
|
||||
fclose(icm);
|
||||
#endif
|
||||
|
||||
if(in_prof == NULL) return;
|
||||
|
||||
in_space = cmsGetPCS(in_prof);
|
||||
out_space = cmsGetColorSpace(in_prof);
|
||||
intent = cmsGetHeaderRenderingIntent(in_prof);
|
||||
|
||||
|
||||
max_w = (int)image->comps[0].w;
|
||||
max_h = (int)image->comps[0].h;
|
||||
prec = (int)image->comps[0].prec;
|
||||
oldspace = image->color_space;
|
||||
|
||||
if(out_space == cmsSigRgbData) /* enumCS 16 */
|
||||
{
|
||||
if( prec <= 8 )
|
||||
{
|
||||
in_type = TYPE_RGB_8;
|
||||
out_type = TYPE_RGB_8;
|
||||
}
|
||||
else
|
||||
{
|
||||
in_type = TYPE_RGB_16;
|
||||
out_type = TYPE_RGB_16;
|
||||
}
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = CLRSPC_SRGB;
|
||||
}
|
||||
else if(out_space == cmsSigGrayData) /* enumCS 17 */
|
||||
{
|
||||
in_type = TYPE_GRAY_8;
|
||||
out_type = TYPE_RGB_8;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = CLRSPC_SRGB;
|
||||
}
|
||||
else if(out_space == cmsSigYCbCrData) /* enumCS 18 */
|
||||
{
|
||||
in_type = TYPE_YCbCr_16;
|
||||
out_type = TYPE_RGB_16;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = CLRSPC_SRGB;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_PROFILE
|
||||
fprintf(stderr,"%s:%d: color_apply_icc_profile\n\tICC Profile has unknown "
|
||||
"output colorspace(%#x)(%c%c%c%c)\n\tICC Profile ignored.\n",
|
||||
__FILE__,__LINE__,out_space,
|
||||
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||
(out_space>>8) & 0xff, out_space & 0xff);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PROFILE
|
||||
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tchannels(%d) prec(%d) w(%d) h(%d)"
|
||||
"\n\tprofile: in(%p) out(%p)\n",__FILE__,__LINE__,image->numcomps,prec,
|
||||
max_w,max_h, (void*)in_prof,(void*)out_prof);
|
||||
|
||||
fprintf(stderr,"\trender_intent (%u)\n\t"
|
||||
"color_space: in(%#x)(%c%c%c%c) out:(%#x)(%c%c%c%c)\n\t"
|
||||
" type: in(%u) out:(%u)\n",
|
||||
intent,
|
||||
in_space,
|
||||
(in_space>>24) & 0xff,(in_space>>16) & 0xff,
|
||||
(in_space>>8) & 0xff, in_space & 0xff,
|
||||
|
||||
out_space,
|
||||
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||
(out_space>>8) & 0xff, out_space & 0xff,
|
||||
|
||||
in_type,out_type
|
||||
);
|
||||
#else
|
||||
(void)prec;
|
||||
(void)in_space;
|
||||
#endif /* DEBUG_PROFILE */
|
||||
|
||||
transform = cmsCreateTransform(in_prof, in_type, out_prof, out_type, intent, 0);
|
||||
|
||||
#ifdef HAVE_LIBLCMS2
|
||||
/* Possible for: LCMS_VERSION >= 2000 :*/
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
#endif
|
||||
|
||||
if(transform == NULL)
|
||||
{
|
||||
#ifdef DEBUG_PROFILE
|
||||
fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
||||
"ICC Profile ignored.\n",__FILE__,__LINE__);
|
||||
#endif
|
||||
image->color_space = oldspace;
|
||||
#ifdef HAVE_LIBLCMS1
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if(image->numcomps > 2)/* RGB, RGBA */
|
||||
{
|
||||
if( prec <= 8 )
|
||||
{
|
||||
unsigned char *inbuf, *outbuf, *in, *out;
|
||||
max = max_w * max_h;
|
||||
nr_samples = (cmsUInt32Number)max * 3 * (cmsUInt32Number)sizeof(unsigned char);
|
||||
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned char)*r++;
|
||||
*in++ = (unsigned char)*g++;
|
||||
*in++ = (unsigned char)*b++;
|
||||
}
|
||||
|
||||
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++;
|
||||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned short *inbuf, *outbuf, *in, *out;
|
||||
max = max_w * max_h;
|
||||
nr_samples = (cmsUInt32Number)max * 3 * (cmsUInt32Number)sizeof(unsigned short);
|
||||
in = inbuf = (unsigned short*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned short*)malloc(nr_samples);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned short)*r++;
|
||||
*in++ = (unsigned short)*g++;
|
||||
*in++ = (unsigned short)*b++;
|
||||
}
|
||||
|
||||
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++;
|
||||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
}
|
||||
}
|
||||
else /* GRAY, GRAYA */
|
||||
{
|
||||
unsigned char *in, *inbuf, *out, *outbuf;
|
||||
max = max_w * max_h;
|
||||
nr_samples = (cmsUInt32Number)max * 3 * sizeof(unsigned char);
|
||||
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||
|
||||
image->comps = (opj_image_comp_t*)realloc(image->comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
|
||||
|
||||
if(image->numcomps == 2)
|
||||
image->comps[3] = image->comps[1];
|
||||
|
||||
image->comps[1] = image->comps[0];
|
||||
image->comps[2] = image->comps[0];
|
||||
|
||||
image->comps[1].data = (int*)calloc((size_t)max, sizeof(int));
|
||||
image->comps[2].data = (int*)calloc((size_t)max, sizeof(int));
|
||||
|
||||
image->numcomps += 2;
|
||||
|
||||
r = image->comps[0].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned char)*r++;
|
||||
}
|
||||
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++; *g++ = (int)*out++; *b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
|
||||
}/* if(image->numcomps */
|
||||
|
||||
cmsDeleteTransform(transform);
|
||||
|
||||
#ifdef HAVE_LIBLCMS1
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
#endif
|
||||
}/* color_apply_icc_profile() */
|
||||
|
||||
#endif /* HAVE_LIBLCMS2 || HAVE_LIBLCMS1 */
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 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
|
||||
* 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_COLOR_H_
|
||||
#define _OPJ_COLOR_H_
|
||||
|
||||
extern void color_sycc_to_rgb(opj_image_t *img);
|
||||
extern void color_apply_icc_profile(opj_image_t *image);
|
||||
|
||||
#endif /* _OPJ_COLOR_H_ */
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 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
|
||||
* 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_FORMAT_DEFS_H_
|
||||
#define _OPJ_FORMAT_DEFS_H_
|
||||
|
||||
#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
|
||||
#define PNG_DFMT 17
|
||||
|
||||
#endif /* _OPJ_FORMAT_DEFS_H_ */
|
||||
@@ -1,51 +0,0 @@
|
||||
/* last review : october 29th, 2002 */
|
||||
|
||||
#include "opj_config.h"
|
||||
|
||||
#ifdef USE_SYSTEM_GETOPT
|
||||
#include <getopt.h>
|
||||
|
||||
#define opj_opterr opterr
|
||||
#define opj_optind optind
|
||||
#define opj_optopt optopt
|
||||
#define opj_optreset optreset
|
||||
#define opj_optarg optarg
|
||||
|
||||
typedef struct option opj_option_t;
|
||||
|
||||
#define NO_ARG no_argument
|
||||
#define REQ_ARG required_argument
|
||||
#define OPT_ARG optional_argument
|
||||
|
||||
#define opj_getopt getopt
|
||||
#define opj_getopt_long getopt_long
|
||||
|
||||
#else
|
||||
#ifndef _GETOPT_H_
|
||||
#define _GETOPT_H_
|
||||
|
||||
typedef struct opj_option
|
||||
{
|
||||
const char *name;
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
} opj_option_t;
|
||||
|
||||
#define NO_ARG 0
|
||||
#define REQ_ARG 1
|
||||
#define OPT_ARG 2
|
||||
|
||||
extern int opj_opterr;
|
||||
extern int opj_optind;
|
||||
extern int opj_optopt;
|
||||
extern int opj_optreset;
|
||||
extern char *opj_optarg;
|
||||
|
||||
extern int opj_getopt(int nargc, char *const *nargv, const char *ostr);
|
||||
extern int opj_getopt_long(int argc, char * const argv[], const char *optstring,
|
||||
const opj_option_t *longopts, int totlen);
|
||||
extern void reset_options_reading(void);
|
||||
|
||||
#endif /* _GETOPT_H_ */
|
||||
#endif /* USE_SYSTEM_GETOPT */
|
||||
@@ -1,127 +0,0 @@
|
||||
What's New for OpenJPIP
|
||||
|
||||
* : fixed
|
||||
- : removed
|
||||
! : changed
|
||||
+ : added
|
||||
|
||||
Feburary 28, 2012
|
||||
+ [kaori] enabled the opj_server to reply the first query consisting with len request from kakadu client
|
||||
|
||||
February 9, 2012
|
||||
* [kaori] fixed Doxygen configuration file to document the utilities
|
||||
+ [kaori] added execution argument to set port number for opj_dec_server, opj_viewer*
|
||||
|
||||
January 26, 2012
|
||||
! [kaori] unapplied auxtrans_manager to the local mode
|
||||
|
||||
December 24, 2011
|
||||
* [kaori] additional modification for the warning
|
||||
|
||||
December 22, 2011
|
||||
* [kaori] fixed auxtrans_manager to enable MAC
|
||||
* [kaori] warnings due to disregarding return value are removed
|
||||
|
||||
November 30, 2011
|
||||
+ [kaori] TCP return (http-tcp) implemented
|
||||
|
||||
November 16, 2011
|
||||
* [kaori] fixed Region of Interest option, and memory leak of opj_dec_server
|
||||
+ [kaori] new feature to target JP2 files from www (libcurl required)
|
||||
* [kaori] fixed opj_server execusion error (instant terminating) with autotool, cmake still need to be fixed
|
||||
|
||||
November 8, 2011
|
||||
! [kaori] updated main page of doxygen
|
||||
|
||||
November 3, 2011
|
||||
* [kaori] solved memory leak of opj_server
|
||||
! [kaori] removed redundant defines
|
||||
|
||||
November 2, 2011
|
||||
* [antonin] additional patches for autotools and cmake
|
||||
|
||||
October 26, 2011
|
||||
* [kaori] additional patches for autotool are applied
|
||||
|
||||
October 25, 2011
|
||||
* [kaori] patches for cmake and autotool are applied
|
||||
* [kaori] fixed client viewer to be compatible with server response header both Content-type and Content-Type
|
||||
|
||||
October 20, 2011
|
||||
+ [added] API style in openJPIP library
|
||||
! [kaori] rearranged directories, applications are all under util/ directory, currently only 'make -f Makefile.nix' works
|
||||
|
||||
October 18, 2011
|
||||
! [kaori] rearranged opj_server, opj_dec_server directory
|
||||
|
||||
October 14, 2011
|
||||
+ [kaori] enable all progression orders
|
||||
|
||||
October 12, 2011
|
||||
+ [kaori] enable layers requests; restricting the number of codesream quality layers
|
||||
|
||||
October 11, 2011
|
||||
+ [antonin] enable JPT-stream request from client viewer option (credit to kaori)
|
||||
|
||||
October 10, 2011
|
||||
- [antonin] removed obsolete indexer utility (credit to kaori)
|
||||
+ [antonin] enabled JPP-stream (credit to kaori)
|
||||
|
||||
September 16, 2011
|
||||
+ [kaori] enabled stateless requests from the opj_viewers
|
||||
|
||||
Septempber 1, 2011
|
||||
* [kaori] changed terminating status of opj_server in debug/non-server mode
|
||||
|
||||
August 27, 2011
|
||||
* [antonin] fixed missing include directory in opj_client/opj_dec_server/CMakeLists.txt
|
||||
|
||||
August 26, 2011
|
||||
* [antonin] fixed cmake and autotools files to reflect recent indexer changes in JPIP
|
||||
! [kaori] indexer using the latest openjpeg library
|
||||
* [antonin] fixed cmake and autotools files to reflect recent changes in JPIP
|
||||
! [kaori] fixed Makefile.nix to load openjpeg library from this archive
|
||||
|
||||
August 25, 2011
|
||||
+ [kaori] added tid request support to JPIP client
|
||||
+ [kaori] added quit JPIP server request
|
||||
|
||||
August 24, 2011
|
||||
+ [kaori] added cachemodel_manager, which had been managed in target_manager previously
|
||||
+ [kaori] added tid request support to JPIP server
|
||||
|
||||
August 16, 2011
|
||||
* [antonin] fixed cmake support for openjpip
|
||||
|
||||
August 12, 2011
|
||||
+ [antonin] added cmake support to openjpip
|
||||
|
||||
July 6, 2011
|
||||
* [antonin] JPIP : fixed autotools to work with recent name changes
|
||||
|
||||
July 5, 2011
|
||||
! [kaori] changed parameter, file names, message names regarding JPT-stream to JPIP-stream, which handles also JPP-stream
|
||||
|
||||
May 26, 2011
|
||||
! [antonin] changed Makefile to Makefile.nix to avoid having autotools overwrite them.
|
||||
|
||||
May 23, 2011
|
||||
+ [antonin] added autotools for the 'tools' directory
|
||||
+ [antonin] added autotools as a build method for jpip (credit to Vincent Torri)
|
||||
|
||||
May 10, 2011
|
||||
! [kaori] opj_viewer removed the xml functions (for users without Xersus2)
|
||||
+ [kaori] renamed opj_viewer to opj_viewer_xerces ( needs Xersus2)
|
||||
! [kaori] Modification of opj_dec_server to be portable to windows
|
||||
|
||||
May 9, 2011
|
||||
* [kaori] Removal of c99 from the compile option (to be compatible to win platform) and bool definition in libopenjpip/bool.h
|
||||
|
||||
May 9, 2011
|
||||
* [antonin] OpenJPIP: small bug fixes to compile on win platform
|
||||
|
||||
May 8, 2011
|
||||
* [antonin] OpenJPIP: fixed several bugs in opj_server (removal of strsep function, duplication of query string) + some changes to compile opj_server under windows (replacement of strcasecmp(), bzero()).
|
||||
|
||||
April 14, 2011
|
||||
+ [antonin] initial commit of OpenJPIP 1.0, a JPIP client-server architecture based on OpenJPEG (see README file in jpip directory for more details)
|
||||
@@ -1,16 +0,0 @@
|
||||
# required dep for server:
|
||||
IF(BUILD_JPIP_SERVER)
|
||||
FIND_PACKAGE(CURL REQUIRED)
|
||||
FIND_PACKAGE(FCGI REQUIRED)
|
||||
FIND_PACKAGE(Threads REQUIRED)
|
||||
IF(NOT CMAKE_USE_PTHREADS_INIT)
|
||||
MESSAGE(FATAL_ERROR "Only pthread are supported")
|
||||
ENDIF(NOT CMAKE_USE_PTHREADS_INIT)
|
||||
ENDIF(BUILD_JPIP_SERVER)
|
||||
|
||||
# JPIP library:
|
||||
ADD_SUBDIRECTORY(libopenjpip)
|
||||
|
||||
# JPIP binaries:
|
||||
ADD_SUBDIRECTORY(util)
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
SUBDIRS = libopenjpip util
|
||||
@@ -1,149 +0,0 @@
|
||||
========================================================================
|
||||
OpenJPIP software 2.1 ReadMe
|
||||
|
||||
OpenJPEG:
|
||||
http://www.openjpeg.org
|
||||
|
||||
Written by:
|
||||
Kaori Hagihara
|
||||
UCL/SST/ICTM/ELEN
|
||||
February 18 2011
|
||||
========================================================================
|
||||
|
||||
Contents:
|
||||
1. Introduction
|
||||
2. License
|
||||
3. System requirements
|
||||
4. Implementing instructions
|
||||
5. JP2 encoding instructions
|
||||
|
||||
|
||||
----------
|
||||
1. Introduction
|
||||
----------
|
||||
|
||||
OpenJPIP software is an implementation of JPEG 2000 Part9: Interactivity tools, APIs and protocols (JPIP).
|
||||
( For more info about JPIP, check the website: http://www.jpeg.org/jpeg2000/j2kpart9.html)
|
||||
The current implementation uses some results from the 2KAN project (http://www.2kan.org).
|
||||
|
||||
Version 2.1 covers:
|
||||
- JPT-stream (Tile) and JPP-stream (Precinct) media types
|
||||
- Session, channels, cache model managements
|
||||
- JPIP over HTTP, HTTP requests and TCP return
|
||||
- Indexing JPEG 2000 files
|
||||
- Embedding XML formatted metadata
|
||||
- Region Of Interest (ROI) requests
|
||||
- Access to JP2 files with their URL
|
||||
|
||||
----------
|
||||
2. License
|
||||
----------
|
||||
|
||||
This software is released under the BSD license, anybody can use or modify the library, even for commercial applications.
|
||||
The only restriction is to retain the copyright in the sources or the binaries documentation.
|
||||
Neither the author, nor the university accept any responsibility for any kind of error or data loss which may occur during usage.
|
||||
|
||||
----------
|
||||
3. System requirements
|
||||
----------
|
||||
|
||||
- FastCGI development kit (C libraries) at server (http://www.fastcgi.com)
|
||||
- libcURL library
|
||||
- Java application launcher at client
|
||||
<Optional>
|
||||
- Xerces2 java XML parser on the client for accessing embedded image metadata (http://xerces.apache.org/xerces2-j)
|
||||
|
||||
We tested this software with a virtual server running on the same Linux machine as the clients.
|
||||
|
||||
----------
|
||||
4. Building instructions
|
||||
----------
|
||||
|
||||
A Makefile is available in the same directory as this README file. Simply type 'make' and it will build all the required C-executables.
|
||||
Concerning the java-based opj_viewer, simply type 'ant' in the corresponding directory (requires 'ant' utility of course)
|
||||
|
||||
The documentation can be build this way (requires doxygen utility):
|
||||
cd doc
|
||||
doxygen Doxyfile
|
||||
|
||||
----------
|
||||
5. Usage
|
||||
----------
|
||||
|
||||
Preliminary notes :
|
||||
* HTML documentation is available at http://www.openjpeg.org/jpip/doc/html
|
||||
* Example image is available at http://www.openjpeg.org/jpip/data/copenhague1.zip (20 Mb !)
|
||||
|
||||
Webserver:
|
||||
You need a webserver running with the fastcgi module enabled and correctly configured.
|
||||
For Apache, add the following line to your /etc/apache2/mods-available/fastcgi.conf configuration file:
|
||||
|
||||
FastCGIExternalServer /var/www/myFCGI -host localhost:3000
|
||||
|
||||
where /var/www is your DocumentRoot.
|
||||
Please refer to 'http://www.openjpeg.org/jpip/doc/ApacheFastCGITutorial.pdf' for more details.
|
||||
|
||||
Server:
|
||||
1. Store JP2 files in the same directory as opj_server
|
||||
|
||||
2. Launch opj_server from the server terminal:
|
||||
% spawn-fcgi -f ./opj_server -p 3000 -n
|
||||
|
||||
For shutting down JPIP server:
|
||||
%GET http://hostname/myFCGI?quitJPIP
|
||||
Notice, http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
|
||||
Requst message "quitJPIP" can be changed in Makfile, modify -DQUIT_SIGNAL=\"quitJPIP\"
|
||||
|
||||
Client:
|
||||
1. Launch image decoding server, and keep it alive as long as image viewers are open
|
||||
% ./opj_dec_server [portnumber (50000 by default)]
|
||||
|
||||
You might prefer to implement this program from another directory since cache files are saved in the working directory.
|
||||
% mkdir cache
|
||||
% cd cache
|
||||
% ../opj_dec_server
|
||||
|
||||
2. Open image viewers (as many as needed)
|
||||
% java -jar opj_viewer.jar http://hostname/myFCGI path/filename.jp2 [hostname] [portnumber] [stateless/session] [jptstream/jppstream] [tcp/udp]
|
||||
( The arguments
|
||||
- http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
|
||||
- path/filename.jp2 is the server local path or URL of a JP2 file
|
||||
- host name of opj_dec_server, localhost by default
|
||||
- portnumber of opj_dec_server, 50000 by default
|
||||
- request type stateless for no caching, session (default) for caching
|
||||
- return media type, JPT-stream tile based stream, or JPP-stream (default) precinct based stream
|
||||
- auxiliary return protocol, tcp or udp (udp is not implemented yet), if not given, return data is filled in http chunk
|
||||
Image viewer GUI instructions:
|
||||
Scale up request: Enlarge the window
|
||||
ROI request: Select a region by mouse click and drag, then click inside the red frame of the selected region
|
||||
<If Xerces2 is installed>
|
||||
% java -jar opj_viewer_xerces.jar http://hostname/myFCGI JP2_filename.jp2
|
||||
Annotate image with ROI information in XML metadata: Click button "Region Of Interest"
|
||||
Open a new window presenting an aligned image with a locally stored image: Click button "Image Registration" (Under Construction)
|
||||
|
||||
3. Quit the image decoding server through the telnet, be sure all image viewers are closed
|
||||
% telnet localhost 50000
|
||||
quit
|
||||
|
||||
----------
|
||||
5. JP2 encoding instructions
|
||||
----------
|
||||
|
||||
An example to encode a TIF image "copenhague1.tif" at resolution 4780x4050, 8bit/pixel, grayscale.
|
||||
% ./image_to_j2k -i copenhague1.tif -o copenhague1.jp2 -p RPCL -c [64,64] -t 640,480 -jpip -TP R
|
||||
|
||||
options
|
||||
-jpip : embed index table 'cidx' box into the output JP2 file (obligation for JPIP)
|
||||
-TP R : partition a tile into tile parts of different resolution levels (obligation for JPT-stream)
|
||||
|
||||
<Option>
|
||||
3. Embed metadata into JP2 file
|
||||
% ./addXMLinJP2 copenhague1.jp2 copenhague1.xml
|
||||
Input metadata file "copenhague1.xml" looks like:
|
||||
<xmlbox>
|
||||
<roi name="island" x="1890" y="1950" w="770" h="310"/>
|
||||
<roi name="ship" x="750" y="330" w="100" h="60"/>
|
||||
<roi name="airport" x="650" y="1800" w="650" h="800"/>
|
||||
<roi name="harbor" x="4200" y="1650" w="130" h="130"/>
|
||||
<irt refimg="name1.jp2" m1="0.50" m2="-0.50" m3="0" m4="0.80" m5="-0.80" m6="0" m7="500" m8="1000" m9="0"/>
|
||||
</xmlbox>
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 61 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.2 KiB |
@@ -1,72 +0,0 @@
|
||||
INCLUDE_REGULAR_EXPRESSION("^.*$")
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||
${FCGI_INCLUDE_DIRS}
|
||||
${CURL_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# Defines the source code for the library
|
||||
SET(OPENJPIP_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/boxheader_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/codestream_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/imgreg_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/marker_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/msgqueue_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/box_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/faixbox_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/index_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/metadata_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/placeholder_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/byte_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ihdrbox_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/manfbox_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mhixbox_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/target_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cachemodel_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/j2kheader_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/jp2k_encoder.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/openjpip.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/query_parser.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/channel_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/session_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/jpip_parser.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sock_manager.c
|
||||
)
|
||||
|
||||
SET(SERVER_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/auxtrans_manager.c
|
||||
)
|
||||
|
||||
SET(LOCAL_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/jp2k_decoder.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/imgsock_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/jpipstream_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cache_manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/dec_clientmsg_handler.c
|
||||
)
|
||||
|
||||
# Build the library
|
||||
ADD_LIBRARY(openjpip_local STATIC ${OPENJPIP_SRCS} ${LOCAL_SRCS})
|
||||
TARGET_LINK_LIBRARIES(openjpip_local ${OPENJPEG_LIBRARY_NAME})
|
||||
IF(WIN32)
|
||||
# add Winsock on windows+mingw
|
||||
TARGET_LINK_LIBRARIES(openjpip_local ws2_32)
|
||||
ENDIF(WIN32)
|
||||
|
||||
# Install library
|
||||
INSTALL(TARGETS openjpip_local
|
||||
EXPORT OpenJPEGTargets
|
||||
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
|
||||
)
|
||||
|
||||
IF(BUILD_JPIP_SERVER)
|
||||
ADD_LIBRARY(openjpip_server STATIC ${OPENJPIP_SRCS} ${SERVER_SRCS})
|
||||
TARGET_LINK_LIBRARIES(openjpip_server ${FCGI_LIBRARIES} ${CURL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
||||
SET_TARGET_PROPERTIES(openjpip_server
|
||||
PROPERTIES COMPILE_FLAGS "-DSERVER")
|
||||
INSTALL(TARGETS openjpip_server
|
||||
EXPORT OpenJPEGTargets
|
||||
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
|
||||
)
|
||||
ENDIF(BUILD_JPIP_SERVER)
|
||||
@@ -1,151 +0,0 @@
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
includesdir = $(includedir)/openjpeg-$(MAJOR_NR).$(MINOR_NR)
|
||||
includes_HEADERS =
|
||||
|
||||
lib_LTLIBRARIES =
|
||||
|
||||
if WANT_JPIP
|
||||
lib_LTLIBRARIES += libopenjpip_local.la
|
||||
endif
|
||||
|
||||
if WANT_JPIP_SERVER
|
||||
lib_LTLIBRARIES += libopenjpip_server.la
|
||||
endif
|
||||
|
||||
JPIP_SRC = \
|
||||
openjpip.c \
|
||||
query_parser.c \
|
||||
channel_manager.c \
|
||||
session_manager.c \
|
||||
jpip_parser.c \
|
||||
boxheader_manager.c \
|
||||
codestream_manager.c \
|
||||
imgreg_manager.c \
|
||||
marker_manager.c \
|
||||
msgqueue_manager.c \
|
||||
box_manager.c \
|
||||
faixbox_manager.c \
|
||||
index_manager.c \
|
||||
metadata_manager.c \
|
||||
placeholder_manager.c \
|
||||
byte_manager.c \
|
||||
ihdrbox_manager.c \
|
||||
manfbox_manager.c \
|
||||
mhixbox_manager.c \
|
||||
target_manager.c \
|
||||
cachemodel_manager.c \
|
||||
j2kheader_manager.c \
|
||||
jp2k_encoder.c \
|
||||
sock_manager.c \
|
||||
openjpip.h \
|
||||
bool.h \
|
||||
boxheader_manager.h \
|
||||
box_manager.h \
|
||||
byte_manager.h \
|
||||
codestream_manager.h \
|
||||
faixbox_manager.h \
|
||||
ihdrbox_manager.h \
|
||||
imgreg_manager.h \
|
||||
index_manager.h \
|
||||
manfbox_manager.h \
|
||||
marker_manager.h \
|
||||
metadata_manager.h \
|
||||
mhixbox_manager.h \
|
||||
msgqueue_manager.h \
|
||||
placeholder_manager.h \
|
||||
target_manager.h \
|
||||
cachemodel_manager.h \
|
||||
j2kheader_manager.h \
|
||||
jp2k_encoder.h \
|
||||
query_parser.h \
|
||||
channel_manager.h \
|
||||
session_manager.h \
|
||||
jpip_parser.h \
|
||||
jp2k_decoder.h \
|
||||
sock_manager.h
|
||||
|
||||
SERVER_SRC = auxtrans_manager.c \
|
||||
auxtrans_manager.h
|
||||
|
||||
LOCAL_SRC = jp2k_decoder.c \
|
||||
imgsock_manager.c \
|
||||
jpipstream_manager.c \
|
||||
cache_manager.c \
|
||||
dec_clientmsg_handler.c \
|
||||
imgsock_manager.h \
|
||||
jpipstream_manager.h \
|
||||
cache_manager.h \
|
||||
dec_clientmsg_handler.h
|
||||
|
||||
libopenjpip_server_la_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/applications/jpip/libopenjpip \
|
||||
-I$(top_builddir)/applications/jpip/libopenjpip \
|
||||
@FCGI_CFLAGS@ \
|
||||
@LIBCURL_CFLAGS@ \
|
||||
-DSERVER
|
||||
libopenjpip_server_la_CFLAGS = @THREAD_CFLAGS@
|
||||
libopenjpip_server_la_LIBADD = @FCGI_LIBS@ @LIBCURL_LIBS@ @THREAD_LIBS@ -lm
|
||||
libopenjpip_server_la_LDFLAGS = -no-undefined -version-info @lt_version@
|
||||
libopenjpip_server_la_SOURCES = $(JPIP_SRC) $(SERVER_SRC)
|
||||
|
||||
libopenjpip_local_la_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/libopenjpeg \
|
||||
-I$(top_builddir)/libopenjpeg \
|
||||
-I$(top_srcdir)/applications/jpip/libopenjpip \
|
||||
-I$(top_builddir)/applications/jpip/libopenjpip \
|
||||
@LIBCURL_CFLAGS@
|
||||
libopenjpip_local_la_CFLAGS =
|
||||
libopenjpip_local_la_LIBADD = $(top_builddir)/libopenjpeg/libopenjpeg.la -lm
|
||||
libopenjpip_local_la_LDFLAGS = -no-undefined -version-info @lt_version@
|
||||
libopenjpip_local_la_SOURCES = $(JPIP_SRC) $(LOCAL_SRC)
|
||||
|
||||
install-data-hook:
|
||||
if WANT_JPIP_SERVER
|
||||
@echo -e " (LA)\t$(libdir)/libopenjpip_server.la" >> $(top_builddir)/report.txt
|
||||
if BUILD_SHARED
|
||||
@( $(call solist_s) ) >> $(top_builddir)/report.txt
|
||||
endif
|
||||
if BUILD_STATIC
|
||||
@echo -e " (A)\t$(base_s)/$(a_s)" >> $(top_builddir)/report.txt
|
||||
endif
|
||||
endif
|
||||
if WANT_JPIP
|
||||
@echo -e " (LA)\t$(libdir)/libopenjpip_local.la" >> $(top_builddir)/report.txt
|
||||
if BUILD_SHARED
|
||||
@( $(call solist_c) ) >> $(top_builddir)/report.txt
|
||||
endif
|
||||
if BUILD_STATIC
|
||||
@echo -e " (A)\t$(base_c)/$(a_c)" >> $(top_builddir)/report.txt
|
||||
endif
|
||||
endif
|
||||
|
||||
solist_s = $(foreach f, $(dll_s) $(so_s), echo -e ' $(SO_PREFIX)\t$(base_s)/$(f)' ;)
|
||||
get_tok_s = $(shell grep -E "^$(1)=" libopenjpip_server.la | cut -d "'" -f 2)
|
||||
base_s = $(call get_tok_s,libdir)
|
||||
so_s = $(call get_tok_s,library_names)
|
||||
a_s = $(call get_tok_s,old_library)
|
||||
|
||||
solist_c = $(foreach f, $(dll_c) $(so_c), echo -e ' $(SO_PREFIX)\t$(base_c)/$(f)' ;)
|
||||
get_tok_c = $(shell grep -E "^$(1)=" libopenjpip_local.la | cut -d "'" -f 2)
|
||||
base_c = $(call get_tok_c,libdir)
|
||||
so_c = $(call get_tok_c,library_names)
|
||||
a_c = $(call get_tok_c,old_library)
|
||||
|
||||
if HAVE_WIN32
|
||||
SO_PREFIX = (DLL)
|
||||
dll_s = $(call get_tok_s,dlname)
|
||||
dll_c = $(call get_tok_c,dlname)
|
||||
else
|
||||
if HAVE_DARWIN
|
||||
SO_PREFIX = (DY)
|
||||
dll_s =
|
||||
dll_c =
|
||||
else
|
||||
SO_PREFIX = (SO)
|
||||
dll_s =
|
||||
dll_c =
|
||||
endif
|
||||
endif
|
||||
@@ -1,267 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 "auxtrans_manager.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <process.h>
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER */
|
||||
|
||||
auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport)
|
||||
{
|
||||
auxtrans_param_t auxtrans;
|
||||
|
||||
auxtrans.tcpauxport = tcp_auxport;
|
||||
auxtrans.udpauxport = udp_auxport;
|
||||
|
||||
if( 49152 <= tcp_auxport && tcp_auxport <= 65535)
|
||||
auxtrans.tcplistensock = open_listeningsocket( tcp_auxport);
|
||||
else
|
||||
auxtrans.tcplistensock = -1;
|
||||
|
||||
auxtrans.udplistensock = -1;
|
||||
/* open listening socket for udp later */
|
||||
|
||||
return auxtrans;
|
||||
}
|
||||
|
||||
void close_aux_transport( auxtrans_param_t auxtrans)
|
||||
{
|
||||
if( auxtrans.tcplistensock != -1)
|
||||
if( close_socket( auxtrans.tcplistensock) != 0)
|
||||
perror("close");
|
||||
|
||||
if( auxtrans.udplistensock != -1)
|
||||
if( close_socket( auxtrans.udplistensock) != 0)
|
||||
perror("close");
|
||||
}
|
||||
|
||||
|
||||
/*!< auxiliary response parameters */
|
||||
typedef struct aux_response_param{
|
||||
char *cid; /*!< channel ID */
|
||||
unsigned char *data; /*!< sending data */
|
||||
int datalen; /*!< length of data */
|
||||
int maxlenPerFrame; /*!< maximum data length to send per frame */
|
||||
SOCKET listensock; /*!< listeing socket */
|
||||
#ifdef _WIN32
|
||||
HANDLE hTh; /*!< thread handle */
|
||||
#endif
|
||||
} aux_response_param_t;
|
||||
|
||||
aux_response_param_t * gene_auxresponse( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int datalen, int maxlenPerFrame);
|
||||
|
||||
void delete_auxresponse( aux_response_param_t **auxresponse);
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
unsigned __stdcall aux_streaming( void *arg);
|
||||
#else
|
||||
void * aux_streaming( void *arg);
|
||||
#endif
|
||||
|
||||
void send_responsedata_on_aux( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int datalen, int maxlenPerFrame)
|
||||
{
|
||||
aux_response_param_t *auxresponse;
|
||||
#ifdef _WIN32
|
||||
unsigned int threadId;
|
||||
#else
|
||||
pthread_t thread;
|
||||
int status;
|
||||
#endif
|
||||
|
||||
if( istcp){
|
||||
if( auxtrans.tcplistensock == -1){
|
||||
fprintf( FCGI_stderr, "Error: error in send_responsedata_on_aux(), tcp listening socket no open\n");
|
||||
return;
|
||||
}
|
||||
|
||||
auxresponse = gene_auxresponse( istcp, auxtrans, cid, data, datalen, maxlenPerFrame);
|
||||
|
||||
#ifdef _WIN32
|
||||
auxresponse->hTh = (HANDLE)_beginthreadex( NULL, 0, &aux_streaming, auxresponse, 0, &threadId);
|
||||
if( auxresponse->hTh == 0)
|
||||
fprintf( FCGI_stderr,"ERRO: pthread_create() %s", strerror( (int)auxresponse->hTh));
|
||||
#else
|
||||
status = pthread_create( &thread, NULL, &aux_streaming, auxresponse);
|
||||
if( status != 0)
|
||||
fprintf( FCGI_stderr,"ERROR: pthread_create() %s",strerror(status));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
fprintf( FCGI_stderr, "Error: error in send_responsedata_on_aux(), udp not implemented\n");
|
||||
}
|
||||
|
||||
aux_response_param_t * gene_auxresponse( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int datalen, int maxlenPerFrame)
|
||||
{
|
||||
aux_response_param_t *auxresponse;
|
||||
|
||||
auxresponse = (aux_response_param_t *)malloc( sizeof(aux_response_param_t));
|
||||
|
||||
auxresponse->cid = strdup( cid);
|
||||
auxresponse->data = data;
|
||||
auxresponse->datalen = datalen;
|
||||
auxresponse->maxlenPerFrame = maxlenPerFrame;
|
||||
auxresponse->listensock = istcp ? auxtrans.tcplistensock : auxtrans.udplistensock;
|
||||
|
||||
return auxresponse;
|
||||
}
|
||||
|
||||
void delete_auxresponse( aux_response_param_t **auxresponse)
|
||||
{
|
||||
free( (*auxresponse)->cid);
|
||||
free( (*auxresponse)->data);
|
||||
free( *auxresponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify cid sent from client
|
||||
*
|
||||
* @param [in] connected_socket file descriptor of the connected socket
|
||||
* @param [in] refcid refenrece channel ID
|
||||
* @param [in] fp file pointer for log of aux stream
|
||||
* @return true if identified, false otherwise
|
||||
*/
|
||||
bool identify_cid( SOCKET connected_socket, char refcid[], FILE *fp);
|
||||
|
||||
bool recv_ack( SOCKET connected_socket, void *data);
|
||||
|
||||
#ifdef _WIN32
|
||||
unsigned __stdcall aux_streaming( void *arg)
|
||||
#else
|
||||
void * aux_streaming( void *arg)
|
||||
#endif
|
||||
{
|
||||
SOCKET connected_socket;
|
||||
unsigned char *chunk, *ptr;
|
||||
int maxLenOfBody, remlen, chunklen;
|
||||
const int headlen = 8;
|
||||
|
||||
aux_response_param_t *auxresponse = (aux_response_param_t *)arg;
|
||||
|
||||
#ifdef _WIN32
|
||||
CloseHandle( auxresponse->hTh);
|
||||
#else
|
||||
pthread_detach( pthread_self());
|
||||
#endif
|
||||
|
||||
chunk = (unsigned char *)malloc( auxresponse->maxlenPerFrame);
|
||||
maxLenOfBody = auxresponse->maxlenPerFrame - headlen;
|
||||
remlen = auxresponse->datalen;
|
||||
|
||||
while((connected_socket = accept_socket( auxresponse->listensock)) != -1){
|
||||
if( identify_cid( connected_socket, auxresponse->cid, FCGI_stderr)){
|
||||
ptr = auxresponse->data;
|
||||
while( 0 < remlen){
|
||||
memset( chunk, 0, auxresponse->maxlenPerFrame);
|
||||
|
||||
chunklen = remlen<maxLenOfBody?remlen:maxLenOfBody;
|
||||
chunklen += headlen;
|
||||
|
||||
chunk[0] = (chunklen >> 8) & 0xff;
|
||||
chunk[1] = chunklen & 0xff;
|
||||
|
||||
memcpy( chunk+headlen, ptr, chunklen-headlen);
|
||||
|
||||
do{
|
||||
send_stream( connected_socket, chunk, chunklen);
|
||||
}while( !recv_ack( connected_socket, chunk));
|
||||
|
||||
remlen -= maxLenOfBody;
|
||||
ptr += maxLenOfBody;
|
||||
}
|
||||
if( close_socket( connected_socket) != 0)
|
||||
perror("close");
|
||||
break;
|
||||
}
|
||||
}
|
||||
free( chunk);
|
||||
|
||||
delete_auxresponse( &auxresponse);
|
||||
|
||||
#ifdef _WIN32
|
||||
_endthreadex(0);
|
||||
#else
|
||||
pthread_exit(0);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool identify_cid( SOCKET connected_socket, char refcid[], FILE *fp)
|
||||
{
|
||||
char *cid;
|
||||
bool succeed;
|
||||
|
||||
if(!(cid = receive_string( connected_socket))){
|
||||
fprintf( fp, "Error: error in identify_cid(), while receiving cid from client\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
succeed = false;
|
||||
if( strncmp( refcid, cid, strlen( refcid)) == 0)
|
||||
succeed = true;
|
||||
|
||||
free( cid);
|
||||
|
||||
return succeed;
|
||||
}
|
||||
|
||||
bool recv_ack( SOCKET connected_socket, void *data)
|
||||
{
|
||||
char *header;
|
||||
bool succeed;
|
||||
|
||||
header = receive_stream( connected_socket, 8);
|
||||
|
||||
if( memcmp( header, data, 8) != 0)
|
||||
succeed = false;
|
||||
else
|
||||
succeed = true;
|
||||
|
||||
free( header);
|
||||
|
||||
return succeed;
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 AUXTRANS_MANAGER_H_
|
||||
# define AUXTRANS_MANAGER_H_
|
||||
|
||||
#include "sock_manager.h"
|
||||
|
||||
/** auxiliary transport setting parameters*/
|
||||
typedef struct auxtrans_param{
|
||||
int tcpauxport; /**< tcp port*/
|
||||
int udpauxport; /**< udp port*/
|
||||
SOCKET tcplistensock; /**< listenning socket for aux tcp (-1 if not open)*/
|
||||
SOCKET udplistensock; /**< listenning socket for aux udp (-1 if not open)*/
|
||||
} auxtrans_param_t;
|
||||
|
||||
/**
|
||||
* Initialize auxiliary transport server of JPIP server
|
||||
*
|
||||
* @param[in] tcp_auxport opening tcp auxiliary port ( 0 not to open, valid No. 49152–65535)
|
||||
* @param[in] udp_auxport opening udp auxiliary port ( 0 not to open, valid No. 49152–65535)
|
||||
* @return intialized transport parameters
|
||||
*/
|
||||
auxtrans_param_t init_aux_transport( int tcp_auxport, int udp_auxport);
|
||||
|
||||
/**
|
||||
* Close auxiliary transport server of JPIP server
|
||||
*
|
||||
* @param[in] auxtrans closing transport server
|
||||
*/
|
||||
void close_aux_transport( auxtrans_param_t auxtrans);
|
||||
|
||||
/**
|
||||
* Send response data on aux transport
|
||||
*
|
||||
* @param[in] istcp true if tcp, false if udp
|
||||
* @param[in] auxtrans available transport parameters
|
||||
* @param[in] cid channel ID
|
||||
* @param[in] data sending data
|
||||
* @param[in] length length of data
|
||||
* @param[in] maxlenPerFrame maximum data length to send per frame
|
||||
*/
|
||||
void send_responsedata_on_aux( bool istcp, auxtrans_param_t auxtrans, char cid[], void *data, int length, int maxlenPerFrame);
|
||||
|
||||
#endif /* !AUXTRANS_MANAGER_H_ */
|
||||
@@ -1,415 +0,0 @@
|
||||
/*
|
||||
* $Id: box_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* 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 <ctype.h>
|
||||
#include "box_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
|
||||
boxlist_param_t * gene_boxlist()
|
||||
{
|
||||
boxlist_param_t *boxlist;
|
||||
|
||||
boxlist = (boxlist_param_t *)malloc( sizeof(boxlist_param_t));
|
||||
|
||||
boxlist->first = NULL;
|
||||
boxlist->last = NULL;
|
||||
|
||||
return boxlist;
|
||||
}
|
||||
|
||||
boxlist_param_t * get_boxstructure( int fd, Byte8_t offset, Byte8_t length)
|
||||
{
|
||||
boxlist_param_t *boxlist;
|
||||
box_param_t *box;
|
||||
int pos;
|
||||
|
||||
boxlist = NULL;
|
||||
pos = offset;
|
||||
do{
|
||||
if(!(box = gene_boxbyOffset( fd, pos)))
|
||||
break;
|
||||
|
||||
pos += box->length;
|
||||
|
||||
if( !boxlist)
|
||||
boxlist = gene_boxlist();
|
||||
insert_box_into_list( box, boxlist);
|
||||
}while( pos < (int)(offset+length));
|
||||
|
||||
return boxlist;
|
||||
}
|
||||
|
||||
box_param_t * gene_boxbyOffset( int fd, Byte8_t offset)
|
||||
{
|
||||
Byte_t *data;
|
||||
Byte8_t boxlen, headlen;
|
||||
char *boxtype;
|
||||
box_param_t *box;
|
||||
|
||||
/* read LBox and TBox*/
|
||||
if(!(data = fetch_bytes( fd, offset, 8))){
|
||||
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %lld)\n", fd, offset);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
headlen = 8;
|
||||
boxlen = (Byte8_t)big4(data);
|
||||
boxtype = (char *)(data+4);
|
||||
|
||||
/* box type constraint*/
|
||||
if( !isalpha(boxtype[0]) || !isalpha(boxtype[1]) ||
|
||||
(!isalnum(boxtype[2])&&!isspace(boxtype[2])) ||
|
||||
(!isalpha(boxtype[3])&&!isspace(boxtype[3]))){
|
||||
free( data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( boxlen == 1){
|
||||
Byte_t *data2;
|
||||
headlen = 16;
|
||||
/* read XLBox*/
|
||||
if((data2 = fetch_bytes( fd, offset+8, 8))){
|
||||
boxlen = big8(data2);
|
||||
free(data2);
|
||||
}
|
||||
else{
|
||||
fprintf( FCGI_stderr, "Error: error in gene_boxbyOffset( %d, %lld)\n", fd, offset);
|
||||
free( data);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
box = (box_param_t *)malloc( sizeof( box_param_t));
|
||||
box->fd = fd;
|
||||
box->offset = offset;
|
||||
box->headlen = headlen;
|
||||
box->length = boxlen;
|
||||
strncpy( box->type, boxtype, 4);
|
||||
box->next = NULL;
|
||||
free( data);
|
||||
return box;
|
||||
}
|
||||
|
||||
box_param_t * gene_boxbyOffinStream( Byte_t *stream, Byte8_t offset)
|
||||
{
|
||||
Byte8_t boxlen, headlen;
|
||||
char *boxtype;
|
||||
box_param_t *box;
|
||||
|
||||
/* read LBox and TBox*/
|
||||
headlen = 8;
|
||||
boxlen = (Byte8_t)big4( stream);
|
||||
boxtype = (char *)( stream+4);
|
||||
|
||||
/* box type constraint*/
|
||||
if( !isalpha(boxtype[0]) || !isalpha(boxtype[1]) ||
|
||||
(!isalnum(boxtype[2])&&!isspace(boxtype[2])) ||
|
||||
(!isalpha(boxtype[3])&&!isspace(boxtype[3]))){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( boxlen == 1){
|
||||
headlen = 16;
|
||||
boxlen = big8( stream+8); /* read XLBox*/
|
||||
}
|
||||
box = (box_param_t *)malloc( sizeof( box_param_t));
|
||||
box->fd = -1;
|
||||
box->offset = offset;
|
||||
box->headlen = headlen;
|
||||
box->length = boxlen;
|
||||
strncpy( box->type, boxtype, 4);
|
||||
box->next = NULL;
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
|
||||
box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, const char TBox[])
|
||||
{
|
||||
Byte8_t pos;
|
||||
Byte_t *data;
|
||||
Byte8_t boxlen, headlen;
|
||||
char *boxtype;
|
||||
box_param_t *foundbox;
|
||||
|
||||
|
||||
if( length==0){ /* set the max length*/
|
||||
if( (length = get_filesize( fd) - offset) <= 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pos = offset;
|
||||
while( pos < offset+length-7){ /* LBox+TBox-1=7*/
|
||||
|
||||
/* read LBox and TBox*/
|
||||
if((data = fetch_bytes( fd, pos, 8))){
|
||||
headlen = 8;
|
||||
boxlen = (Byte8_t)big4(data);
|
||||
boxtype = (char *)(data+4);
|
||||
|
||||
if( boxlen == 1){
|
||||
Byte_t *data2;
|
||||
headlen = 16;
|
||||
/* read XLBox*/
|
||||
if((data2 = fetch_bytes( fd, pos+8, 8))){
|
||||
boxlen = big8(data2);
|
||||
free(data2);
|
||||
}
|
||||
else{
|
||||
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %lld, %lld, %s)\n", fd, offset, length, TBox);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if( strncmp ( boxtype, TBox, 4) == 0){
|
||||
foundbox = (box_param_t *)malloc( sizeof( box_param_t));
|
||||
foundbox->fd = fd;
|
||||
foundbox->offset = pos;
|
||||
foundbox->headlen = headlen;
|
||||
foundbox->length = boxlen;
|
||||
strncpy( foundbox->type, TBox, 4);
|
||||
foundbox->next = NULL;
|
||||
free( data);
|
||||
return foundbox;
|
||||
}
|
||||
free( data);
|
||||
}
|
||||
else{
|
||||
fprintf( FCGI_stderr, "Error: error in gene_boxbyType( %d, %lld, %lld, %s)\n", fd, offset, length, TBox);
|
||||
return NULL;
|
||||
}
|
||||
pos+= boxlen;
|
||||
}
|
||||
fprintf( FCGI_stderr, "Error: Box %s not found\n", TBox);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t length, const char TBox[])
|
||||
{
|
||||
Byte8_t pos;
|
||||
Byte_t *data;
|
||||
Byte8_t boxlen, headlen;
|
||||
char *boxtype;
|
||||
box_param_t *foundbox;
|
||||
|
||||
|
||||
if( length<=0){ /* set the max length*/
|
||||
fprintf( FCGI_stderr, "func gene_boxbyTypeinStream(), max length must be more than 0\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pos = offset;
|
||||
while( pos < offset+length-7){ /* LBox+TBox-1=7*/
|
||||
|
||||
/* read LBox and TBox*/
|
||||
data = stream + pos;
|
||||
headlen = 8;
|
||||
boxlen = (Byte8_t)big4(data);
|
||||
boxtype = (char *)(data+4);
|
||||
|
||||
if( boxlen == 1){
|
||||
/* read XLBox*/
|
||||
headlen = 16;
|
||||
boxlen = big8( data+8);
|
||||
}
|
||||
|
||||
if( strncmp ( boxtype, TBox, 4) == 0){
|
||||
foundbox = (box_param_t *)malloc( sizeof( box_param_t));
|
||||
foundbox->fd = -1;
|
||||
foundbox->offset = pos;
|
||||
foundbox->headlen = headlen;
|
||||
foundbox->length = boxlen;
|
||||
strncpy( foundbox->type, TBox, 4);
|
||||
foundbox->next = NULL;
|
||||
return foundbox;
|
||||
}
|
||||
pos+= boxlen;
|
||||
}
|
||||
fprintf( FCGI_stderr, "Error: Box %s not found\n", TBox);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
box_param_t * gene_childboxbyOffset( box_param_t *superbox, Byte8_t offset)
|
||||
{
|
||||
return gene_boxbyOffset( superbox->fd, get_DBoxoff( superbox)+offset);
|
||||
}
|
||||
|
||||
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, const char TBox[])
|
||||
{
|
||||
return gene_boxbyType( superbox->fd, get_DBoxoff( superbox)+offset, get_DBoxlen( superbox)-offset, TBox);
|
||||
}
|
||||
|
||||
Byte8_t get_DBoxoff( box_param_t *box)
|
||||
{
|
||||
return box->offset+box->headlen;
|
||||
}
|
||||
|
||||
Byte8_t get_DBoxlen( box_param_t *box)
|
||||
{
|
||||
return box->length-box->headlen;
|
||||
}
|
||||
|
||||
Byte_t * fetch_headbytes( box_param_t *box)
|
||||
{
|
||||
return fetch_bytes( box->fd, box->offset, box->headlen);
|
||||
}
|
||||
|
||||
Byte_t * fetch_DBoxbytes( box_param_t *box, long offset, int size)
|
||||
{
|
||||
return fetch_bytes( box->fd, get_DBoxoff( box)+offset, size);
|
||||
}
|
||||
|
||||
Byte_t fetch_DBox1byte( box_param_t *box, long offset)
|
||||
{
|
||||
return fetch_1byte( box->fd, get_DBoxoff( box)+offset);
|
||||
}
|
||||
|
||||
Byte2_t fetch_DBox2bytebigendian( box_param_t *box, long offset)
|
||||
{
|
||||
return fetch_2bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
||||
}
|
||||
|
||||
Byte4_t fetch_DBox4bytebigendian( box_param_t *box, long offset)
|
||||
{
|
||||
return fetch_4bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
||||
}
|
||||
|
||||
Byte8_t fetch_DBox8bytebigendian( box_param_t *box, long offset)
|
||||
{
|
||||
return fetch_8bytebigendian( box->fd, get_DBoxoff( box)+offset);
|
||||
}
|
||||
|
||||
box_param_t * search_box( const char type[], boxlist_param_t *boxlist)
|
||||
{
|
||||
box_param_t *foundbox;
|
||||
|
||||
foundbox = boxlist->first;
|
||||
|
||||
while( foundbox != NULL){
|
||||
|
||||
if( strncmp( type, foundbox->type, 4) == 0)
|
||||
return foundbox;
|
||||
|
||||
foundbox = foundbox->next;
|
||||
}
|
||||
fprintf( FCGI_stderr, "Error: Box %s not found\n", type);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void print_box( box_param_t *box)
|
||||
{
|
||||
fprintf( logstream, "box info:\n"
|
||||
"\t type: %.4s\n"
|
||||
"\t offset: %lld %#llx\n"
|
||||
"\t header length: %d\n"
|
||||
"\t length: %lld %#llx\n", box->type, box->offset, box->offset, box->headlen, box->length, box->length);
|
||||
}
|
||||
|
||||
void print_allbox( boxlist_param_t *boxlist)
|
||||
{
|
||||
box_param_t *ptr;
|
||||
|
||||
if( !boxlist)
|
||||
return;
|
||||
|
||||
ptr = boxlist->first;
|
||||
if( !ptr)
|
||||
fprintf( logstream, "no box\n");
|
||||
|
||||
fprintf( logstream, "all box info: \n");
|
||||
while( ptr != NULL){
|
||||
print_box( ptr);
|
||||
ptr=ptr->next;
|
||||
}
|
||||
}
|
||||
|
||||
void delete_box_in_list( box_param_t **box, boxlist_param_t *boxlist)
|
||||
{
|
||||
box_param_t *ptr;
|
||||
|
||||
if( *box == boxlist->first)
|
||||
boxlist->first = (*box)->next;
|
||||
else{
|
||||
ptr = boxlist->first;
|
||||
while( ptr->next != *box){
|
||||
ptr=ptr->next;
|
||||
}
|
||||
ptr->next = (*box)->next;
|
||||
|
||||
if( *box == boxlist->last)
|
||||
boxlist->last = ptr;
|
||||
}
|
||||
free( *box);
|
||||
}
|
||||
|
||||
void delete_box_in_list_by_type( char type[], boxlist_param_t *boxlist)
|
||||
{
|
||||
box_param_t *box;
|
||||
|
||||
box = search_box( type, boxlist);
|
||||
delete_box_in_list( &box, boxlist);
|
||||
}
|
||||
|
||||
void delete_boxlist( boxlist_param_t **boxlist)
|
||||
{
|
||||
box_param_t *boxPtr, *boxNext;
|
||||
|
||||
if(!(*boxlist))
|
||||
return;
|
||||
|
||||
boxPtr = (*boxlist)->first;
|
||||
while( boxPtr != NULL){
|
||||
boxNext=boxPtr->next;
|
||||
free( boxPtr);
|
||||
boxPtr=boxNext;
|
||||
}
|
||||
free( *boxlist);
|
||||
}
|
||||
|
||||
void insert_box_into_list( box_param_t *box, boxlist_param_t *boxlist)
|
||||
{
|
||||
if( boxlist->first)
|
||||
boxlist->last->next = box;
|
||||
else
|
||||
boxlist->first = box;
|
||||
boxlist->last = box;
|
||||
}
|
||||
@@ -1,264 +0,0 @@
|
||||
/*
|
||||
* $Id: box_manager.h 44 2011-02-15 12:32:29Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* 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 BOX_MANAGER_H_
|
||||
# define BOX_MANAGER_H_
|
||||
|
||||
#include "byte_manager.h"
|
||||
|
||||
/** box parameters*/
|
||||
typedef struct box_param{
|
||||
int fd; /**< file descriptor*/
|
||||
Byte8_t offset; /**< byte position of the whole Box (LBox) in the file*/
|
||||
Byte_t headlen; /**< header length 8 or 16*/
|
||||
Byte8_t length; /**< length of the whole Box*/
|
||||
char type[4]; /**< type of information in the DBox*/
|
||||
struct box_param *next; /**< pointer to the next box*/
|
||||
} box_param_t;
|
||||
|
||||
|
||||
/** Box list parameters*/
|
||||
typedef struct boxlist_param{
|
||||
box_param_t *first; /**< first box pointer of the list*/
|
||||
box_param_t *last; /**< last box pointer of the list*/
|
||||
} boxlist_param_t;
|
||||
|
||||
|
||||
/**
|
||||
* generate a box list
|
||||
*
|
||||
* @return pointer to the generated box list
|
||||
*/
|
||||
boxlist_param_t * gene_boxlist();
|
||||
|
||||
/**
|
||||
* get box structure of JP2 file
|
||||
*
|
||||
* @param[in] fd file descriptor
|
||||
* @param[in] offset offset of the decomposing region
|
||||
* @param[in] length length of the decomposing region
|
||||
* @return pointer to the generated boxlist
|
||||
*/
|
||||
boxlist_param_t * get_boxstructure( int fd, Byte8_t offset, Byte8_t length);
|
||||
|
||||
|
||||
/**
|
||||
* generate box from JP2 file at the given offset
|
||||
*
|
||||
* @param[in] fd file discriptor of the JP2 file
|
||||
* @param[in] offset Box offset
|
||||
* @return pointer to the structure of generate box parameters
|
||||
*/
|
||||
box_param_t * gene_boxbyOffset( int fd, Byte8_t offset);
|
||||
|
||||
|
||||
/**
|
||||
* generate box from code stream (JPP or JPT stream) at the given offset
|
||||
*
|
||||
* @param[in] stream code stream of a box
|
||||
* @param[in] offset Box offset of the whole stream
|
||||
* @return pointer to the structure of generate box parameters
|
||||
*/
|
||||
box_param_t * gene_boxbyOffinStream( Byte_t *stream, Byte8_t offset);
|
||||
|
||||
/**
|
||||
* generate(search) box from JP2 file
|
||||
*
|
||||
* @param[in] fd file discriptor of the JP2 file
|
||||
* @param[in] offset start Byte position of the search
|
||||
* @param[in] length Byte length of the search, if 0, size to the end of file
|
||||
* @param[in] TBox Box Type
|
||||
* @return pointer to the structure of generate/found box parameters
|
||||
*/
|
||||
box_param_t * gene_boxbyType( int fd, Byte8_t offset, Byte8_t length, const char TBox[]);
|
||||
|
||||
/**
|
||||
* generate(search) box from code stream
|
||||
*
|
||||
* @param[in] stream code stream ( from the first byte)
|
||||
* @param[in] offset start Byte position of the search
|
||||
* @param[in] length Byte length of the search, if 0, size to the end of file
|
||||
* @param[in] TBox Box Type
|
||||
* @return pointer to the structure of generate/found box parameters
|
||||
*/
|
||||
box_param_t * gene_boxbyTypeinStream( Byte_t *stream, Byte8_t offset, Byte8_t length, const char TBox[]);
|
||||
|
||||
/**
|
||||
* generate child box from JP2 file at the given offset
|
||||
*
|
||||
* @param[in] superbox super box pointer
|
||||
* @param[in] offset offset from DBox first byte of superbox
|
||||
* @return pointer to the structure of generate box parameters
|
||||
*/
|
||||
box_param_t * gene_childboxbyOffset( box_param_t *superbox, Byte8_t offset);
|
||||
|
||||
/**
|
||||
* generate(search) box from JP2 file
|
||||
*
|
||||
* @param[in] superbox super box pointer
|
||||
* @param[in] offset offset from DBox first byte of superbox
|
||||
* @param[in] TBox Box Type
|
||||
* @return pointer to the structure of generate/found box parameters
|
||||
*/
|
||||
box_param_t * gene_childboxbyType( box_param_t *superbox, Byte8_t offset, const char TBox[]);
|
||||
|
||||
/**
|
||||
* get DBox offset
|
||||
*
|
||||
* @param[in] box box pointer
|
||||
* @return DBox offset (byte position) in the file
|
||||
*/
|
||||
Byte8_t get_DBoxoff( box_param_t *box);
|
||||
|
||||
|
||||
/**
|
||||
* get DBox length
|
||||
*
|
||||
* @param[in] box box pointer
|
||||
* @return DBox length ( content length)
|
||||
*/
|
||||
Byte8_t get_DBoxlen( box_param_t *box);
|
||||
|
||||
|
||||
/**
|
||||
* fetch header bytes in file stream
|
||||
*
|
||||
* @param[in] box box pointer
|
||||
* @return pointer to the fetched bytes
|
||||
*/
|
||||
Byte_t * fetch_headbytes( box_param_t *box);
|
||||
|
||||
|
||||
/**
|
||||
* fetch DBox (Box Contents) bytes of data in file stream
|
||||
*
|
||||
* @param[in] box box pointer
|
||||
* @param[in] offset start Byte position in DBox
|
||||
* @param[in] size Byte length
|
||||
* @return pointer to the fetched data
|
||||
*/
|
||||
Byte_t * fetch_DBoxbytes( box_param_t *box, long offset, int size);
|
||||
|
||||
/**
|
||||
* fetch DBox (Box Contents) 1-byte Byte codes in file stream
|
||||
*
|
||||
* @param[in] box box pointer
|
||||
* @param[in] offset start Byte position in DBox
|
||||
* @return fetched code
|
||||
*/
|
||||
Byte_t fetch_DBox1byte( box_param_t *box, long offset);
|
||||
|
||||
/**
|
||||
* fetch DBox (Box Contents) 2-byte big endian Byte codes in file stream
|
||||
*
|
||||
* @param[in] box box pointer
|
||||
* @param[in] offset start Byte position in DBox
|
||||
* @return fetched code
|
||||
*/
|
||||
Byte2_t fetch_DBox2bytebigendian( box_param_t *box, long offset);
|
||||
|
||||
/**
|
||||
* fetch DBox (Box Contents) 4-byte big endian Byte codes in file stream
|
||||
*
|
||||
* @param[in] box box pointer
|
||||
* @param[in] offset start Byte position in DBox
|
||||
* @return fetched code
|
||||
*/
|
||||
Byte4_t fetch_DBox4bytebigendian( box_param_t *box, long offset);
|
||||
|
||||
/**
|
||||
* fetch DBox (Box Contents) 8-byte big endian Byte codes in file stream
|
||||
*
|
||||
* @param[in] box box pointer
|
||||
* @param[in] offset start Byte position in DBox
|
||||
* @return fetched code
|
||||
*/
|
||||
Byte8_t fetch_DBox8bytebigendian( box_param_t *box, long offset);
|
||||
|
||||
|
||||
/**
|
||||
* search a box by box type
|
||||
*
|
||||
* @param[in] type box type
|
||||
* @param[in] boxlist box list pointer
|
||||
* @return found box pointer
|
||||
*/
|
||||
box_param_t * search_box( const char type[], boxlist_param_t *boxlist);
|
||||
|
||||
/**
|
||||
* print box parameters
|
||||
*
|
||||
* @param[in] box box pointer
|
||||
*/
|
||||
void print_box( box_param_t *box);
|
||||
|
||||
|
||||
/**
|
||||
* print all box parameters
|
||||
*
|
||||
* @param[in] boxlist box list pointer
|
||||
*/
|
||||
void print_allbox( boxlist_param_t *boxlist);
|
||||
|
||||
/**
|
||||
* delete a box in list
|
||||
*
|
||||
* @param[in,out] box address of the deleting box pointer
|
||||
* @param[in] boxlist box list pointer
|
||||
*/
|
||||
void delete_box_in_list( box_param_t **box, boxlist_param_t *boxlist);
|
||||
|
||||
|
||||
/**
|
||||
* delete a box in list by Type
|
||||
*
|
||||
* @param[in,out] type box type
|
||||
* @param[in] boxlist box list pointer
|
||||
*/
|
||||
void delete_box_in_list_by_type( char type[], boxlist_param_t *boxlist);
|
||||
|
||||
|
||||
/**
|
||||
* delete box list
|
||||
*
|
||||
* @param[in,out] boxlist address of the box list pointer
|
||||
*/
|
||||
void delete_boxlist( boxlist_param_t **boxlist);
|
||||
|
||||
|
||||
/**
|
||||
* insert a box into list
|
||||
*
|
||||
* @param[in] box box pointer
|
||||
* @param[in] boxlist box list pointer
|
||||
*/
|
||||
void insert_box_into_list( box_param_t *box, boxlist_param_t *boxlist);
|
||||
|
||||
#endif /* !BOX_MANAGER_H_ */
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* $Id: boxheader_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "boxheader_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
|
||||
|
||||
boxheader_param_t * gene_boxheader( int fd, Byte8_t offset)
|
||||
{
|
||||
Byte8_t boxlen;
|
||||
Byte_t headlen;
|
||||
char *boxtype;
|
||||
boxheader_param_t *boxheader;
|
||||
|
||||
boxlen = fetch_4bytebigendian( fd, offset);
|
||||
boxtype = (char *)fetch_bytes( fd, offset+4, 4);
|
||||
headlen = 8;
|
||||
|
||||
if( boxlen == 1){ /* read XLBox */
|
||||
boxlen = fetch_8bytebigendian( fd, offset+8);
|
||||
headlen = 16;
|
||||
}
|
||||
|
||||
boxheader = (boxheader_param_t *)malloc( sizeof( boxheader_param_t));
|
||||
boxheader->headlen = headlen;
|
||||
boxheader->length = boxlen;
|
||||
strncpy( boxheader->type, boxtype, 4);
|
||||
boxheader->next = NULL;
|
||||
|
||||
free( boxtype);
|
||||
return boxheader;
|
||||
}
|
||||
|
||||
boxheader_param_t * gene_childboxheader( box_param_t *superbox, Byte8_t offset)
|
||||
{
|
||||
return gene_boxheader( superbox->fd, get_DBoxoff( superbox)+offset);
|
||||
}
|
||||
|
||||
void print_boxheader( boxheader_param_t *boxheader)
|
||||
{
|
||||
fprintf( logstream, "boxheader info:\n"
|
||||
"\t type: %.4s\n"
|
||||
"\t length:%lld %#llx\n", boxheader->type, boxheader->length, boxheader->length);
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* $Id: boxheader_manager.h 44 2011-02-15 12:32:29Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* 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 BOXHEADER_MANAGER_H_
|
||||
# define BOXHEADER_MANAGER_H_
|
||||
|
||||
#include "byte_manager.h"
|
||||
#include "box_manager.h"
|
||||
|
||||
/** box header parameters*/
|
||||
typedef struct boxheader_param{
|
||||
Byte_t headlen; /**< header length 8 or 16*/
|
||||
Byte8_t length; /**< length of the reference Box*/
|
||||
char type[4]; /**< type of information in the DBox*/
|
||||
struct boxheader_param *next; /**< pointer to the next header box*/
|
||||
} boxheader_param_t;
|
||||
|
||||
|
||||
/**
|
||||
* generate a box header at the given offset
|
||||
*
|
||||
* @param[in] fd file discriptor of the JP2 file
|
||||
* @param[in] offset Box offset
|
||||
* @return pointer to the structure of generate box header parameters
|
||||
*/
|
||||
boxheader_param_t * gene_boxheader( int fd, Byte8_t offset);
|
||||
|
||||
/**
|
||||
* generate a child box header at the given offset
|
||||
*
|
||||
* @param[in] superbox super box pointer
|
||||
* @param[in] offset offset from DBox first byte of superbox
|
||||
* @return pointer to the structure of generate box header parameters
|
||||
*/
|
||||
boxheader_param_t * gene_childboxheader( box_param_t *superbox, Byte8_t offset);
|
||||
|
||||
/**
|
||||
* print box header parameters
|
||||
*
|
||||
* @param[in] boxheader boxheader pointer
|
||||
*/
|
||||
void print_boxheader( boxheader_param_t *boxheader);
|
||||
|
||||
#endif /* !BOXHEADER_MANAGER_H_ */
|
||||
@@ -1,172 +0,0 @@
|
||||
/*
|
||||
* $Id: byte_manager.c 44 2011-02-15 12:32:29Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* 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>
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include "byte_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
|
||||
|
||||
Byte_t * fetch_bytes( int fd, long offset, int size)
|
||||
{
|
||||
Byte_t *data;
|
||||
|
||||
if( lseek( fd, offset, SEEK_SET)==-1){
|
||||
fprintf( FCGI_stdout, "Reason: Target broken (fseek error)\r\n");
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld, %d)\n", fd, offset, size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (Byte_t *)malloc( size);
|
||||
|
||||
if( read( fd, data, size) != size){
|
||||
free( data);
|
||||
fprintf( FCGI_stdout, "Reason: Target broken (read error)\r\n");
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %ld, %d)\n", fd, offset, size);
|
||||
return NULL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
Byte_t fetch_1byte( int fd, long offset)
|
||||
{
|
||||
Byte_t code;
|
||||
|
||||
if( lseek( fd, offset, SEEK_SET)==-1){
|
||||
fprintf( FCGI_stdout, "Reason: Target broken (seek error)\r\n");
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_1byte( %d, %lld)\n", fd, offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( read( fd, &code, 1) != 1){
|
||||
fprintf( FCGI_stdout, "Reason: Target broken (read error)\r\n");
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_bytes( %d, %lld)\n", fd, offset);
|
||||
return 0;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
Byte2_t fetch_2bytebigendian( int fd, long offset)
|
||||
{
|
||||
Byte_t *data;
|
||||
Byte2_t code;
|
||||
|
||||
if(!(data = fetch_bytes( fd, offset, 2))){
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_2bytebigendian( %d, %lld)\n", fd, offset);
|
||||
return 0;
|
||||
}
|
||||
code = big2(data);
|
||||
free( data);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
Byte4_t fetch_4bytebigendian( int fd, long offset)
|
||||
{
|
||||
Byte_t *data;
|
||||
Byte4_t code;
|
||||
|
||||
if(!(data = fetch_bytes( fd, offset, 4))){
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_4bytebigendian( %d, %lld)\n", fd, offset);
|
||||
return 0;
|
||||
}
|
||||
code = big4(data);
|
||||
free( data);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
Byte8_t fetch_8bytebigendian( int fd, long offset)
|
||||
{
|
||||
Byte_t *data;
|
||||
Byte8_t code;
|
||||
|
||||
if(!(data = fetch_bytes( fd, offset, 8))){
|
||||
fprintf( FCGI_stderr, "Error: error in fetch_8bytebigendian( %d, %lld)\n", fd, offset);
|
||||
return 0;
|
||||
}
|
||||
code = big8(data);
|
||||
free( data);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
Byte2_t big2( Byte_t *buf)
|
||||
{
|
||||
return (((Byte2_t) buf[0]) << 8) + ((Byte2_t) buf[1]);
|
||||
}
|
||||
|
||||
Byte4_t big4( Byte_t *buf)
|
||||
{
|
||||
return (((((((Byte4_t) buf[0]) << 8) + ((Byte4_t) buf[1])) << 8)
|
||||
+ ((Byte4_t) buf[2])) << 8) + ((Byte4_t) buf[3]);
|
||||
}
|
||||
|
||||
Byte8_t big8( Byte_t *buf)
|
||||
{
|
||||
return (((Byte8_t) big4 (buf)) << 32)
|
||||
+ ((Byte8_t) big4 (buf + 4));
|
||||
}
|
||||
|
||||
void modify_4Bytecode( Byte4_t code, Byte_t *stream)
|
||||
{
|
||||
*stream = (Byte_t) ((Byte4_t)(code & 0xff000000) >> 24);
|
||||
*(stream+1) = (Byte_t) ((Byte4_t)(code & 0x00ff0000) >> 16);
|
||||
*(stream+2) = (Byte_t) ((Byte4_t)(code & 0x0000ff00) >> 8);
|
||||
*(stream+3) = (Byte_t) (code & 0x000000ff);
|
||||
}
|
||||
|
||||
Byte8_t get_filesize( int fd)
|
||||
{
|
||||
struct stat sb;
|
||||
|
||||
if( fstat( fd, &sb) == -1){
|
||||
fprintf( FCGI_stdout, "Reason: Target broken (fstat error)\r\n");
|
||||
fprintf( FCGI_stderr, "Error: error in get_filesize( %d)\n", fd);
|
||||
return 0;
|
||||
}
|
||||
return (Byte8_t)sb.st_size;
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* $Id: byte_manager.h 44 2011-02-15 12:32:29Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* 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 BYTE_MANAGER_H_
|
||||
#define BYTE_MANAGER_H_
|
||||
|
||||
#include "opj_config.h"
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
typedef uint8_t Byte_t;
|
||||
typedef uint16_t Byte2_t;
|
||||
typedef uint32_t Byte4_t;
|
||||
typedef uint64_t Byte8_t;
|
||||
#else
|
||||
#if defined(_WIN32)
|
||||
/** 1Byte parameter type*/
|
||||
typedef unsigned __int8 Byte_t;
|
||||
/** 2Byte parameter type*/
|
||||
typedef unsigned __int16 Byte2_t;
|
||||
/** 4Byte parameter type*/
|
||||
typedef unsigned __int32 Byte4_t;
|
||||
/** 8Byte parameter type*/
|
||||
typedef unsigned __int64 Byte8_t;
|
||||
#else
|
||||
#error unsupported platform
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* fetch bytes of data in file stream
|
||||
*
|
||||
* @param[in] fd file discriptor
|
||||
* @param[in] offset start Byte position
|
||||
* @param[in] size Byte length
|
||||
* @return pointer to the fetched data
|
||||
*/
|
||||
Byte_t * fetch_bytes( int fd, long offset, int size);
|
||||
|
||||
|
||||
/**
|
||||
* fetch a 1-byte Byte codes in file stream
|
||||
*
|
||||
* @param[in] fd file discriptor
|
||||
* @param[in] offset start Byte position
|
||||
* @return fetched codes
|
||||
*/
|
||||
Byte_t fetch_1byte( int fd, long offset);
|
||||
|
||||
/**
|
||||
* fetch a 2-byte big endian Byte codes in file stream
|
||||
*
|
||||
* @param[in] fd file discriptor
|
||||
* @param[in] offset start Byte position
|
||||
* @return fetched codes
|
||||
*/
|
||||
Byte2_t fetch_2bytebigendian( int fd, long offset);
|
||||
|
||||
/**
|
||||
* fetch a 4-byte big endian Byte codes in file stream
|
||||
*
|
||||
* @param[in] fd file discriptor
|
||||
* @param[in] offset start Byte position
|
||||
* @return fetched codes
|
||||
*/
|
||||
Byte4_t fetch_4bytebigendian( int fd, long offset);
|
||||
|
||||
/**
|
||||
* fetch a 8-byte big endian Byte codes in file stream
|
||||
*
|
||||
* @param[in] fd file discriptor
|
||||
* @param[in] offset start Byte position
|
||||
* @return fetched codes
|
||||
*/
|
||||
Byte8_t fetch_8bytebigendian( int fd, long offset);
|
||||
|
||||
|
||||
/**
|
||||
* convert 2-byte big endian Byte codes to number
|
||||
*
|
||||
* @param[in] buf Byte codes
|
||||
* @return resolved number
|
||||
*/
|
||||
Byte2_t big2( Byte_t *buf);
|
||||
|
||||
/**
|
||||
* convert 4-byte big endian Byte codes to number
|
||||
*
|
||||
* @param[in] buf Byte codes
|
||||
* @return resolved number
|
||||
*/
|
||||
Byte4_t big4( Byte_t *buf);
|
||||
|
||||
/**
|
||||
* convert 8-byte big endian Byte codes to number
|
||||
*
|
||||
* @param[in] buf Byte codes
|
||||
* @return resolved number
|
||||
*/
|
||||
Byte8_t big8( Byte_t *buf);
|
||||
|
||||
/**
|
||||
* modify 4Byte code in a codestream
|
||||
*
|
||||
* @param[in] code code value
|
||||
* @param[out] stream modifying codestream
|
||||
*/
|
||||
void modify_4Bytecode( Byte4_t code, Byte_t *stream);
|
||||
|
||||
/**
|
||||
* Get file size
|
||||
*
|
||||
* @param[in] fd file discriptor
|
||||
* @return file size
|
||||
*/
|
||||
Byte8_t get_filesize( int fd);
|
||||
|
||||
#endif /* !BYTE_MANAGER_H_ */
|
||||
@@ -1,275 +0,0 @@
|
||||
/*
|
||||
* $Id: cache_manager.c 53 2011-05-09 16:55:39Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "cache_manager.h"
|
||||
|
||||
cachelist_param_t * gene_cachelist()
|
||||
{
|
||||
cachelist_param_t *cachelist;
|
||||
|
||||
cachelist = (cachelist_param_t *)malloc( sizeof(cachelist_param_t));
|
||||
|
||||
cachelist->first = NULL;
|
||||
cachelist->last = NULL;
|
||||
|
||||
return cachelist;
|
||||
}
|
||||
|
||||
void delete_cachelist(cachelist_param_t **cachelist)
|
||||
{
|
||||
cache_param_t *cachePtr, *cacheNext;
|
||||
|
||||
cachePtr = (*cachelist)->first;
|
||||
while( cachePtr != NULL){
|
||||
cacheNext=cachePtr->next;
|
||||
delete_cache( &cachePtr);
|
||||
cachePtr=cacheNext;
|
||||
}
|
||||
free( *cachelist);
|
||||
}
|
||||
|
||||
cache_param_t * gene_cache( char *targetname, int csn, char *tid, char *cid)
|
||||
{
|
||||
cache_param_t *cache;
|
||||
|
||||
cache = (cache_param_t *)malloc( sizeof(cache_param_t));
|
||||
cache->filename = strdup( targetname);
|
||||
cache->tid = strdup( tid);
|
||||
cache->csn = csn;
|
||||
cache->cid = (char **)malloc( sizeof(char *));
|
||||
*cache->cid = strdup( cid);
|
||||
cache->numOfcid = 1;
|
||||
#if 1
|
||||
cache->metadatalist = NULL;
|
||||
#else
|
||||
cache->metadatalist = gene_metadatalist();
|
||||
#endif
|
||||
cache->ihdrbox = NULL;
|
||||
cache->next = NULL;
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
void delete_cache( cache_param_t **cache)
|
||||
{
|
||||
int i;
|
||||
|
||||
free( (*cache)->filename);
|
||||
free( (*cache)->tid);
|
||||
|
||||
delete_metadatalist( &(*cache)->metadatalist);
|
||||
|
||||
if((*cache)->ihdrbox)
|
||||
free((*cache)->ihdrbox);
|
||||
for( i=0; i<(*cache)->numOfcid; i++)
|
||||
free( (*cache)->cid[i]);
|
||||
free( (*cache)->cid);
|
||||
free( *cache);
|
||||
}
|
||||
|
||||
void insert_cache_into_list( cache_param_t *cache, cachelist_param_t *cachelist)
|
||||
{
|
||||
if( cachelist->first)
|
||||
cachelist->last->next = cache;
|
||||
else
|
||||
cachelist->first = cache;
|
||||
cachelist->last = cache;
|
||||
}
|
||||
|
||||
cache_param_t * search_cache( char targetname[], cachelist_param_t *cachelist)
|
||||
{
|
||||
cache_param_t *foundcache;
|
||||
|
||||
if( !targetname)
|
||||
return NULL;
|
||||
|
||||
foundcache = cachelist->first;
|
||||
|
||||
while( foundcache != NULL){
|
||||
|
||||
if( strcmp( targetname, foundcache->filename) == 0)
|
||||
return foundcache;
|
||||
|
||||
foundcache = foundcache->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cache_param_t * search_cacheBycsn( int csn, cachelist_param_t *cachelist)
|
||||
{
|
||||
cache_param_t *foundcache;
|
||||
|
||||
foundcache = cachelist->first;
|
||||
|
||||
while( foundcache != NULL){
|
||||
|
||||
if( csn == foundcache->csn)
|
||||
return foundcache;
|
||||
foundcache = foundcache->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist)
|
||||
{
|
||||
cache_param_t *foundcache;
|
||||
int i;
|
||||
|
||||
if( !cid)
|
||||
return NULL;
|
||||
|
||||
foundcache = cachelist->first;
|
||||
|
||||
while( foundcache != NULL){
|
||||
for( i=0; i<foundcache->numOfcid; i++)
|
||||
if( strcmp( cid, foundcache->cid[i]) == 0)
|
||||
return foundcache;
|
||||
foundcache = foundcache->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cache_param_t * search_cacheBytid( char tid[], cachelist_param_t *cachelist)
|
||||
{
|
||||
cache_param_t *foundcache;
|
||||
|
||||
if( !tid)
|
||||
return NULL;
|
||||
|
||||
foundcache = cachelist->first;
|
||||
|
||||
while( foundcache != NULL){
|
||||
if( strcmp( tid, foundcache->tid) == 0)
|
||||
return foundcache;
|
||||
foundcache = foundcache->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void add_cachecid( char *cid, cache_param_t *cache)
|
||||
{
|
||||
if( !cid)
|
||||
return;
|
||||
|
||||
if( (cache->cid = realloc( cache->cid, (cache->numOfcid+1)*sizeof(char *))) == NULL){
|
||||
fprintf( stderr, "failed to add new cid to cache table in add_cachecid()\n");
|
||||
return;
|
||||
}
|
||||
|
||||
cache->cid[ cache->numOfcid] = strdup( cid);
|
||||
|
||||
cache->numOfcid ++;
|
||||
}
|
||||
|
||||
void update_cachetid( char *tid, cache_param_t *cache)
|
||||
{
|
||||
if( !tid)
|
||||
return;
|
||||
|
||||
if( tid[0] != '0' && strcmp( tid, cache->tid) !=0){
|
||||
fprintf( stderr, "tid is updated to %s for %s\n", tid, cache->filename);
|
||||
free( cache->tid);
|
||||
cache->tid = strdup( tid);
|
||||
}
|
||||
}
|
||||
|
||||
void remove_cidInCache( char *cid, cache_param_t *cache);
|
||||
|
||||
void remove_cachecid( char *cid, cachelist_param_t *cachelist)
|
||||
{
|
||||
cache_param_t *cache;
|
||||
|
||||
cache = search_cacheBycid( cid, cachelist);
|
||||
remove_cidInCache( cid, cache);
|
||||
}
|
||||
|
||||
void remove_cidInCache( char *cid, cache_param_t *cache)
|
||||
{
|
||||
int idx = -1;
|
||||
char **tmp;
|
||||
int i, j;
|
||||
|
||||
for( i=0; i<cache->numOfcid; i++)
|
||||
if( strcmp( cid, cache->cid[i]) == 0){
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
|
||||
if( idx == -1){
|
||||
fprintf( stderr, "cid: %s not found\n", cid);
|
||||
return;
|
||||
}
|
||||
|
||||
tmp = cache->cid;
|
||||
|
||||
cache->cid = (char **)malloc( (cache->numOfcid-1)*sizeof(char *));
|
||||
|
||||
for( i=0, j=0; i<cache->numOfcid; i++){
|
||||
if( i != idx){
|
||||
cache->cid[j] = strdup( tmp[i]);
|
||||
j++;
|
||||
}
|
||||
free( tmp[i]);
|
||||
}
|
||||
free( tmp);
|
||||
|
||||
cache->numOfcid --;
|
||||
}
|
||||
|
||||
void print_cache( cache_param_t *cache)
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf( stdout,"cache\n");
|
||||
fprintf( stdout,"\t filename: %s\n", cache->filename);
|
||||
fprintf( stdout,"\t tid: %s\n", cache->tid);
|
||||
fprintf( stdout,"\t csn: %d\n", cache->csn);
|
||||
fprintf( stdout,"\t cid:");
|
||||
|
||||
for( i=0; i<cache->numOfcid; i++)
|
||||
fprintf( stdout," %s", cache->cid[i]);
|
||||
fprintf( stdout,"\n");
|
||||
}
|
||||
|
||||
void print_allcache( cachelist_param_t *cachelist)
|
||||
{
|
||||
cache_param_t *ptr;
|
||||
|
||||
fprintf( stdout,"cache list\n");
|
||||
|
||||
ptr = cachelist->first;
|
||||
while( ptr != NULL){
|
||||
print_cache( ptr);
|
||||
ptr=ptr->next;
|
||||
}
|
||||
}
|
||||
@@ -1,177 +0,0 @@
|
||||
/*
|
||||
* $Id: cache_manager.h 44 2011-02-15 12:32:29Z kaori $
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* 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 CACHE_MANAGER_H_
|
||||
# define CACHE_MANAGER_H_
|
||||
|
||||
#include "metadata_manager.h"
|
||||
#include "ihdrbox_manager.h"
|
||||
|
||||
/** cache parameters*/
|
||||
typedef struct cache_param{
|
||||
char *filename; /**< file name*/
|
||||
char *tid; /**< taregt identifier*/
|
||||
int csn; /**< codestream number*/
|
||||
char **cid; /**< dynamic array of channel identifiers*/
|
||||
int numOfcid; /**< number of cids*/
|
||||
metadatalist_param_t *metadatalist; /**< metadata-bin list*/
|
||||
ihdrbox_param_t *ihdrbox; /**< ihdrbox*/
|
||||
struct cache_param *next; /**< pointer to the next cache*/
|
||||
} cache_param_t;
|
||||
|
||||
/**< cache list parameters*/
|
||||
typedef struct cachelist_param{
|
||||
cache_param_t *first; /**< first cache pointer of the list*/
|
||||
cache_param_t *last; /**< last cache pointer of the list*/
|
||||
} cachelist_param_t;
|
||||
|
||||
|
||||
/**
|
||||
* generate a cache list
|
||||
*
|
||||
* @return pointer to the generated cache list
|
||||
*/
|
||||
cachelist_param_t * gene_cachelist();
|
||||
|
||||
/**
|
||||
* delete cache list
|
||||
*
|
||||
* @param[in,out] cachelist address of the cache list pointer
|
||||
*/
|
||||
void delete_cachelist(cachelist_param_t **cachelist);
|
||||
|
||||
/**
|
||||
* generate a cache
|
||||
*
|
||||
* @param[in] targetname target file name
|
||||
* @param[in] csn codestream number
|
||||
* @param[in] tid target identifier
|
||||
* @param[in] cid channel identifier
|
||||
* @return pointer to the generated cache
|
||||
*/
|
||||
cache_param_t * gene_cache( char *targetname, int csn, char *tid, char *cid);
|
||||
|
||||
/**
|
||||
* delete a cache
|
||||
*
|
||||
* @param[in] cache address of the cache pointer
|
||||
*/
|
||||
void delete_cache( cache_param_t **cache);
|
||||
|
||||
/**
|
||||
* insert a cache into list
|
||||
*
|
||||
* @param[in] cache cache pointer
|
||||
* @param[in] cachelist cache list pointer
|
||||
*/
|
||||
void insert_cache_into_list( cache_param_t *cache, cachelist_param_t *cachelist);
|
||||
|
||||
|
||||
/**
|
||||
* search a cache by target name
|
||||
*
|
||||
* @param[in] targetname target filename
|
||||
* @param[in] cachelist cache list pointer
|
||||
* @return found cache pointer
|
||||
*/
|
||||
cache_param_t * search_cache( char targetname[], cachelist_param_t *cachelist);
|
||||
|
||||
|
||||
/**
|
||||
* search a cache by csn
|
||||
*
|
||||
* @param[in] csn codestream number
|
||||
* @param[in] cachelist cache list pointer
|
||||
* @return found cache pointer
|
||||
*/
|
||||
cache_param_t * search_cacheBycsn( int csn, cachelist_param_t *cachelist);
|
||||
|
||||
|
||||
/**
|
||||
* search a cache by cid
|
||||
*
|
||||
* @param[in] cid channel identifer
|
||||
* @param[in] cachelist cache list pointer
|
||||
* @return found cache pointer
|
||||
*/
|
||||
cache_param_t * search_cacheBycid( char cid[], cachelist_param_t *cachelist);
|
||||
|
||||
|
||||
/**
|
||||
* search a cache by tid
|
||||
*
|
||||
* @param[in] tid target identifer
|
||||
* @param[in] cachelist cache list pointer
|
||||
* @return found cache pointer
|
||||
*/
|
||||
cache_param_t * search_cacheBytid( char tid[], cachelist_param_t *cachelist);
|
||||
|
||||
/**
|
||||
* add cid into a cache
|
||||
*
|
||||
* @param[in] cid channel identifier
|
||||
* @param[in] cache cache pointer
|
||||
*/
|
||||
void add_cachecid( char *cid, cache_param_t *cache);
|
||||
|
||||
|
||||
/**
|
||||
* update tid of a cache
|
||||
*
|
||||
* @param[in] tid target identifier
|
||||
* @param[in] cache cache pointer
|
||||
*/
|
||||
void update_cachetid( char *tid, cache_param_t *cache);
|
||||
|
||||
|
||||
/**
|
||||
* remove cid in cache
|
||||
*
|
||||
* @param[in] cid channel identifier
|
||||
* @param[in] cachelist cachelist pointer
|
||||
*/
|
||||
void remove_cachecid( char *cid, cachelist_param_t *cachelist);
|
||||
|
||||
|
||||
/**
|
||||
* print cache parameters
|
||||
*
|
||||
* @param[in] cache cache pointer
|
||||
*/
|
||||
void print_cache( cache_param_t *cache);
|
||||
|
||||
/**
|
||||
* print all cache parameters
|
||||
*
|
||||
* @param[in] cachelist cache list pointer
|
||||
*/
|
||||
void print_allcache( cachelist_param_t *cachelist);
|
||||
|
||||
#endif /* !CACHE_MANAGER_H_ */
|
||||
@@ -1,235 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2011, Professor Benoit Macq
|
||||
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
#include "cachemodel_manager.h"
|
||||
#include "faixbox_manager.h"
|
||||
|
||||
#ifdef SERVER
|
||||
#include "fcgi_stdio.h"
|
||||
#define logstream FCGI_stdout
|
||||
#else
|
||||
#define FCGI_stdout stdout
|
||||
#define FCGI_stderr stderr
|
||||
#define logstream stderr
|
||||
#endif /*SERVER*/
|
||||
|
||||
|
||||
cachemodellist_param_t * gene_cachemodellist(void)
|
||||
{
|
||||
cachemodellist_param_t *cachemodellist;
|
||||
|
||||
cachemodellist = (cachemodellist_param_t *)malloc( sizeof(cachemodellist_param_t));
|
||||
|
||||
cachemodellist->first = NULL;
|
||||
cachemodellist->last = NULL;
|
||||
|
||||
return cachemodellist;
|
||||
}
|
||||
|
||||
cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target, bool reqJPP)
|
||||
{
|
||||
cachemodel_param_t *cachemodel;
|
||||
faixbox_param_t *tilepart;
|
||||
faixbox_param_t *precpacket;
|
||||
size_t numOfelem;
|
||||
Byte8_t numOftiles;
|
||||
int i;
|
||||
|
||||
cachemodel = (cachemodel_param_t *)malloc( sizeof(cachemodel_param_t));
|
||||
|
||||
refer_target( target, &cachemodel->target);
|
||||
|
||||
if( reqJPP){
|
||||
if( target->jppstream)
|
||||
cachemodel->jppstream = true;
|
||||
else
|
||||
cachemodel->jppstream = false;
|
||||
} else{ /* reqJPT */
|
||||
if( target->jptstream)
|
||||
cachemodel->jppstream = false;
|
||||
else
|
||||
cachemodel->jppstream = true;
|
||||
}
|
||||
|
||||
cachemodel->mhead_model = false;
|
||||
|
||||
tilepart = target->codeidx->tilepart;
|
||||
numOftiles = get_m( tilepart);
|
||||
numOfelem = get_nmax( tilepart)*numOftiles;
|
||||
cachemodel->tp_model = (bool *)calloc( 1, numOfelem*sizeof(bool));
|
||||
cachemodel->th_model = (bool *)calloc( 1, numOftiles*sizeof(bool));
|
||||
cachemodel->pp_model = (bool **)malloc( target->codeidx->SIZ.Csiz*sizeof(bool *));
|
||||
for( i=0; i<target->codeidx->SIZ.Csiz; i++){
|
||||
precpacket = target->codeidx->precpacket[i];
|
||||
cachemodel->pp_model[i] = (bool *)calloc( 1, get_nmax(precpacket)*get_m(precpacket)*sizeof(bool));
|
||||
}
|
||||
cachemodel->next = NULL;
|
||||
|
||||
if( cachemodellist){
|
||||
if( cachemodellist->first) /* there are one or more entries */
|
||||
cachemodellist->last->next = cachemodel;
|
||||
else /* first entry */
|
||||
cachemodellist->first = cachemodel;
|
||||
cachemodellist->last = cachemodel;
|
||||
}
|
||||
|
||||
#ifndef SERVER
|
||||
fprintf( logstream, "local log: cachemodel generated\n");
|
||||
#endif
|
||||
|
||||
return cachemodel;
|
||||
}
|
||||
|
||||
void print_cachemodel( cachemodel_param_t cachemodel)
|
||||
{
|
||||
target_param_t *target;
|
||||
Byte8_t TPnum; /* num of tile parts in each tile */
|
||||
Byte8_t Pmax; /* max num of packets per tile */
|
||||
Byte8_t i, j, k;
|
||||
int n; /* FIXME: Is this large enough ? */
|
||||
|
||||
target = cachemodel.target;
|
||||
|
||||
fprintf( logstream, "target: %s\n", target->targetname);
|
||||
fprintf( logstream, "\t main header model: %d\n", cachemodel.mhead_model);
|
||||
|
||||
fprintf( logstream, "\t tile part model:\n");
|
||||
TPnum = get_nmax( target->codeidx->tilepart);
|
||||
|
||||
for( i=0, n=0; i<target->codeidx->SIZ.YTnum; i++){
|
||||
for( j=0; j<target->codeidx->SIZ.XTnum; j++){
|
||||
for( k=0; k<TPnum; k++)
|
||||
fprintf( logstream, "%d", cachemodel.tp_model[n++]);
|
||||
fprintf( logstream, " ");
|
||||
}
|
||||
fprintf( logstream, "\n");
|
||||
}
|
||||
|
||||
fprintf( logstream, "\t tile header and precinct packet model:\n");
|
||||
for( i=0; i<target->codeidx->SIZ.XTnum*target->codeidx->SIZ.YTnum; i++){
|
||||
fprintf( logstream, "\t tile.%llud %d\n", i, cachemodel.th_model[i]);
|
||||
for( j=0; j<target->codeidx->SIZ.Csiz; j++){
|
||||
fprintf( logstream, "\t compo.%llud: ", j);
|
||||
Pmax = get_nmax( target->codeidx->precpacket[j]);
|
||||
for( k=0; k<Pmax; k++)
|
||||
fprintf( logstream, "%d", cachemodel.pp_model[j][i*Pmax+k]);
|
||||
fprintf( logstream, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cachemodel_param_t * search_cachemodel( target_param_t *target, cachemodellist_param_t *cachemodellist)
|
||||
{
|
||||
cachemodel_param_t *foundcachemodel;
|
||||
|
||||
foundcachemodel = cachemodellist->first;
|
||||
|
||||
while( foundcachemodel != NULL){
|
||||
|
||||
if( foundcachemodel->target == target)
|
||||
return foundcachemodel;
|
||||
|
||||
foundcachemodel = foundcachemodel->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void delete_cachemodellist( cachemodellist_param_t **cachemodellist)
|
||||
{
|
||||
cachemodel_param_t *cachemodelPtr, *cachemodelNext;
|
||||
|
||||
cachemodelPtr = (*cachemodellist)->first;
|
||||
while( cachemodelPtr != NULL){
|
||||
cachemodelNext=cachemodelPtr->next;
|
||||
delete_cachemodel( &cachemodelPtr);
|
||||
cachemodelPtr=cachemodelNext;
|
||||
}
|
||||
free(*cachemodellist);
|
||||
}
|
||||
|
||||
void delete_cachemodel( cachemodel_param_t **cachemodel)
|
||||
{
|
||||
int i;
|
||||
|
||||
unrefer_target( (*cachemodel)->target);
|
||||
|
||||
free( (*cachemodel)->tp_model);
|
||||
free( (*cachemodel)->th_model);
|
||||
|
||||
for( i=0; i<(*cachemodel)->target->codeidx->SIZ.Csiz; i++)
|
||||
free( (*cachemodel)->pp_model[i]);
|
||||
free( (*cachemodel)->pp_model);
|
||||
|
||||
#ifndef SERVER
|
||||
fprintf( logstream, "local log: cachemodel deleted\n");
|
||||
#endif
|
||||
free( *cachemodel);
|
||||
}
|
||||
|
||||
bool is_allsent( cachemodel_param_t cachemodel)
|
||||
{
|
||||
target_param_t *target;
|
||||
Byte8_t TPnum; /* num of tile parts in each tile */
|
||||
Byte8_t Pmax; /* max num of packets per tile */
|
||||
Byte8_t i, j, k;
|
||||
int n; /* FIXME: is this large enough ? */
|
||||
|
||||
target = cachemodel.target;
|
||||
|
||||
if( !cachemodel.mhead_model)
|
||||
return false;
|
||||
|
||||
TPnum = get_nmax( target->codeidx->tilepart);
|
||||
|
||||
if( cachemodel.jppstream){
|
||||
for( i=0; i<target->codeidx->SIZ.XTnum*target->codeidx->SIZ.YTnum; i++){
|
||||
if( !cachemodel.th_model[i])
|
||||
return false;
|
||||
|
||||
for( j=0; j<target->codeidx->SIZ.Csiz; j++){
|
||||
Pmax = get_nmax( target->codeidx->precpacket[j]);
|
||||
for( k=0; k<Pmax; k++)
|
||||
if( !cachemodel.pp_model[j][i*Pmax+k])
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
for( i=0, n=0; i<target->codeidx->SIZ.YTnum; i++)
|
||||
for( j=0; j<target->codeidx->SIZ.XTnum; j++)
|
||||
for( k=0; k<TPnum; k++)
|
||||
if( !cachemodel.tp_model[n++])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user