Compare commits
255 Commits
avendor
...
version.1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8bdc993dcd | ||
|
|
16879e20ec | ||
|
|
b700cd9101 | ||
|
|
a6d7377213 | ||
|
|
d48feb45fc | ||
|
|
b5c8558934 | ||
|
|
521b9bef33 | ||
|
|
ed3aec55fd | ||
|
|
ef560f19a3 | ||
|
|
6b9d244449 | ||
|
|
16dc670030 | ||
|
|
acd2187a43 | ||
|
|
b8445ebec0 | ||
|
|
4b75a2784c | ||
|
|
2b3947e8a8 | ||
|
|
1c43ca006d | ||
|
|
bc145d8dc8 | ||
|
|
76ee6b8441 | ||
|
|
3adfd18602 | ||
|
|
9e42842bb5 | ||
|
|
a8591daa68 | ||
|
|
265de2ed0d | ||
|
|
36007b6a76 | ||
|
|
34661c5aea | ||
|
|
d53edb5ea7 | ||
|
|
16fbba79ec | ||
|
|
fb4ad9c507 | ||
|
|
9eaaf55f7a | ||
|
|
dc069254c3 | ||
|
|
b97f88bf7e | ||
|
|
2c03b73dff | ||
|
|
6cc148e226 | ||
|
|
f9d76c0be9 | ||
|
|
bcf7032b8b | ||
|
|
0ace960ea5 | ||
|
|
b420c330b2 | ||
|
|
7fd2ae9786 | ||
|
|
3d2f2b4048 | ||
|
|
9fc6e4f4bd | ||
|
|
07fa11a94c | ||
|
|
36c6e4abb9 | ||
|
|
15949d43d1 | ||
|
|
696cd710df | ||
|
|
2d416a8017 | ||
|
|
b565431251 | ||
|
|
480021bc33 | ||
|
|
af448b94a1 | ||
|
|
4bd7195ea6 | ||
|
|
331d3e523d | ||
|
|
b5aee428ba | ||
|
|
3386c7765a | ||
|
|
97a3327f99 | ||
|
|
173ccf70d4 | ||
|
|
7860407cb5 | ||
|
|
4d6bd49719 | ||
|
|
9aa9170110 | ||
|
|
4b3aabebd2 | ||
|
|
1093244d43 | ||
|
|
0577ed8e6e | ||
|
|
4f87b9abd1 | ||
|
|
abe8e93c21 | ||
|
|
f222743e19 | ||
|
|
190b4b7c9e | ||
|
|
d55af7fe7e | ||
|
|
817681fb98 | ||
|
|
f0721df1d9 | ||
|
|
76d29b8df1 | ||
|
|
2f9aae7671 | ||
|
|
0108506433 | ||
|
|
b883da435b | ||
|
|
6a4572a56f | ||
|
|
fba75d93c4 | ||
|
|
c2b399b363 | ||
|
|
786ec27a05 | ||
|
|
2a505f73c4 | ||
|
|
e318641bfa | ||
|
|
6566009e89 | ||
|
|
a350bdc1c4 | ||
|
|
23eeec8769 | ||
|
|
f31d963a64 | ||
|
|
5e0948c142 | ||
|
|
73ada6ce7f | ||
|
|
48311061c1 | ||
|
|
39ad332cee | ||
|
|
90a4692c48 | ||
|
|
fe720be147 | ||
|
|
8d7b0c9c05 | ||
|
|
33b5757921 | ||
|
|
355b88c15d | ||
|
|
74c1b3637e | ||
|
|
9ffd9e6619 | ||
|
|
1460d23294 | ||
|
|
75cf4f0906 | ||
|
|
85c327861a | ||
|
|
c5c3ca370e | ||
|
|
72de930d08 | ||
|
|
8a662fa4b1 | ||
|
|
7546f19b51 | ||
|
|
55fb4d0b67 | ||
|
|
61e353d652 | ||
|
|
5ff45287ea | ||
|
|
6b27c32ee8 | ||
|
|
44869986ca | ||
|
|
2f75846baf | ||
|
|
ec2b3b3b3f | ||
|
|
b9b72f1951 | ||
|
|
ebeb57d7d3 | ||
|
|
e6aae96217 | ||
|
|
511d342a94 | ||
|
|
a1ec600b42 | ||
|
|
06185ea2d1 | ||
|
|
fc42b3ec84 | ||
|
|
5432a70c79 | ||
|
|
d02b01dc85 | ||
|
|
cc3e813786 | ||
|
|
d280fdef70 | ||
|
|
40fd335947 | ||
|
|
6a52f1a9df | ||
|
|
197b0505cb | ||
|
|
f8d899c4f1 | ||
|
|
d5ecae07ad | ||
|
|
8f9f70f922 | ||
|
|
69dcece31a | ||
|
|
34c8a555fa | ||
|
|
fe33ebe83c | ||
|
|
237bb54678 | ||
|
|
95bc884365 | ||
|
|
e45e87cfb7 | ||
|
|
2dc3ca544d | ||
|
|
4fb43c8af0 | ||
|
|
a5d33c992d | ||
|
|
dbd4b4945b | ||
|
|
17704c6e2f | ||
|
|
a35e8df118 | ||
|
|
d9c1214282 | ||
|
|
0674edc2ca | ||
|
|
f335cb0e0b | ||
|
|
c447f6e6bc | ||
|
|
884c8429fc | ||
|
|
5cf0326dcb | ||
|
|
59835a580e | ||
|
|
08f7bfbb5f | ||
|
|
f61cda9b7d | ||
|
|
76016d509b | ||
|
|
4458ef921c | ||
|
|
c9ac67cd05 | ||
|
|
cff5df73d9 | ||
|
|
e398154212 | ||
|
|
0ea26e7ba6 | ||
|
|
8f3bd54c3d | ||
|
|
18a9bcb882 | ||
|
|
7ee36c3a4c | ||
|
|
7f8f47566f | ||
|
|
d6a523e091 | ||
|
|
ac634b1639 | ||
|
|
a0513798bb | ||
|
|
8f4d6bbeba | ||
|
|
cd98a4f740 | ||
|
|
e25e7e767e | ||
|
|
de75303c38 | ||
|
|
32ba9920db | ||
|
|
7ae6a670fa | ||
|
|
cf4f8be5f0 | ||
|
|
ec1b970a32 | ||
|
|
ee6d0cfba9 | ||
|
|
789f6f8e7a | ||
|
|
3d2a52cd82 | ||
|
|
384068ce8c | ||
|
|
7e518596e0 | ||
|
|
f9eb8f93c2 | ||
|
|
d54925f777 | ||
|
|
eae26f958e | ||
|
|
ee7c2c28f1 | ||
|
|
8a2e6ecd8b | ||
|
|
1b0a585256 | ||
|
|
29b6a4307a | ||
|
|
ad4857df94 | ||
|
|
a73e37301a | ||
|
|
255e296113 | ||
|
|
e4696a445d | ||
|
|
81f688433d | ||
|
|
0130af0ff4 | ||
|
|
2cbcbb25b0 | ||
|
|
5197135a0a | ||
|
|
4c67811f65 | ||
|
|
8e8afafae6 | ||
|
|
370cfc43a2 | ||
|
|
d101633cfa | ||
|
|
128bcc4f62 | ||
|
|
050737bea0 | ||
|
|
63e17a19eb | ||
|
|
61e85ded8b | ||
|
|
1cc9fa6815 | ||
|
|
7bdb0331a6 | ||
|
|
623f1d96cf | ||
|
|
1de9535b8c | ||
|
|
68ebc572fc | ||
|
|
5f44ec7d01 | ||
|
|
10aee43cbc | ||
|
|
7e2e09e2a9 | ||
|
|
86ce4d4c18 | ||
|
|
361edd25b7 | ||
|
|
85691a02a6 | ||
|
|
1f96f0e92a | ||
|
|
34a6c13a2d | ||
|
|
542f06007c | ||
|
|
fdbca0fc9d | ||
|
|
632902d7e3 | ||
|
|
9310f1b4a9 | ||
|
|
ed0a46eff5 | ||
|
|
8323900f73 | ||
|
|
c83ae7397d | ||
|
|
3b1bee0eec | ||
|
|
ba1cf545df | ||
|
|
bfb2f9f58b | ||
|
|
13b8ecfe44 | ||
|
|
9e9e188ebf | ||
|
|
5034581e69 | ||
|
|
85ec5eccf7 | ||
|
|
9c8fcc3616 | ||
|
|
7976b61c89 | ||
|
|
43a6b92345 | ||
|
|
f25acae0bc | ||
|
|
9225f53d62 | ||
|
|
eb1b017ec7 | ||
|
|
0ddef9b2db | ||
|
|
1bdb07cefe | ||
|
|
0a879e2207 | ||
|
|
f3c3eab744 | ||
|
|
08209f1d23 | ||
|
|
3ec116ae08 | ||
|
|
3b600a986c | ||
|
|
0d4a38f3a5 | ||
|
|
2410db2ae7 | ||
|
|
e1278bc691 | ||
|
|
899439a906 | ||
|
|
02e3a4ec77 | ||
|
|
7250ce0668 | ||
|
|
2ebe5f2c92 | ||
|
|
3c730a804b | ||
|
|
313975debf | ||
|
|
0abe8e1997 | ||
|
|
bc5c5115cb | ||
|
|
61ac18531a | ||
|
|
0ee21bdbfe | ||
|
|
d116ca5d10 | ||
|
|
26a630dad2 | ||
|
|
2c2730280e | ||
|
|
2e2ba14c53 | ||
|
|
9fa68ca811 | ||
|
|
d38080aa00 | ||
|
|
aa6c1d28ad | ||
|
|
ba4fd784f5 | ||
|
|
3d67d80d49 | ||
|
|
25e97927f9 |
77
CMakeLists.txt
Normal file
77
CMakeLists.txt
Normal file
@@ -0,0 +1,77 @@
|
||||
# Main CMakeLists.txt to build the OpenJPEG project using CMake (www.cmake.org)
|
||||
# Written by Mathieu Malaterre
|
||||
|
||||
# This CMake project will by default create a library called openjpeg
|
||||
# But if you want to use this project within your own (CMake) project
|
||||
# you will eventually like to prefix the library to avoid linking confusion
|
||||
# For this purpose you can define a CMake var: OPENJPEG_NAMESPACE to whatever you like
|
||||
# e.g.:
|
||||
# SET(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
|
||||
PROJECT(OPENJPEG C)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.2)
|
||||
|
||||
IF(NOT OPENJPEG_NAMESPACE)
|
||||
SET(OPENJPEG_NAMESPACE "OPENJPEG")
|
||||
SET(OPENJPEG_STANDALONE 1)
|
||||
ENDIF(NOT OPENJPEG_NAMESPACE)
|
||||
# In all cases:
|
||||
STRING(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
|
||||
|
||||
PROJECT(${JPEG_NAMESPACE} C)
|
||||
|
||||
# Do full dependency headers.
|
||||
INCLUDE_REGULAR_EXPRESSION("^.*$")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# OPENJPEG version number, usefull for packaging and doxygen doc:
|
||||
SET(OPENJPEG_MAJOR_VERSION 1)
|
||||
SET(OPENJPEG_MINOR_VERSION 0)
|
||||
SET(OPENJPEG_BUILD_VERSION 0)
|
||||
SET(OPENJPEG_VERSION
|
||||
"${OPENJPEG_MAJOR_VERSION}.${OPENJPEG_MINOR_VERSION}.${OPENJPEG_BUILD_VERSION}")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# OpenJPEG build configuration options.
|
||||
OPTION(BUILD_SHARED_LIBS "Build OpenJPEG with shared libraries." OFF)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# 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 IMMEDIATE)
|
||||
ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Always build the library
|
||||
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
SUBDIRS(
|
||||
libopenjpeg
|
||||
)
|
||||
#-----------------------------------------------------------------------------
|
||||
# Build example only if requested
|
||||
IF(BUILD_EXAMPLES)
|
||||
SUBDIRS(codec)
|
||||
ENDIF(BUILD_EXAMPLES)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# For openjpeg team if they ever want Dart+CMake
|
||||
IF(OPJ_STANDALONE)
|
||||
INCLUDE(Dart)
|
||||
MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
|
||||
IF(BUILD_TESTING)
|
||||
ENABLE_TESTING()
|
||||
SET(BUILDNAME "OpenJPEG-${CMAKE_SYSTEM}-${CMAKE_C_COMPILER}" CACHE STRING "Name of build on the dashboard")
|
||||
MARK_AS_ADVANCED(BUILDNAME)
|
||||
ENDIF(BUILD_TESTING)
|
||||
ENDIF(OPJ_STANDALONE)
|
||||
|
||||
# TODO, technically we should add tests, e.g:
|
||||
# http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
|
||||
|
||||
39
CVSROOT/checkCtrlM
Executable file
39
CVSROOT/checkCtrlM
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# checkCtrlM checks source code for explicit ctrl-M's
|
||||
# checks only files with the following extensions: .c, .cxx, .txx, .html, .htm
|
||||
# exits with 0, if all commited files pass the test.
|
||||
# exits with 1, if any one of the tests fails
|
||||
#
|
||||
# checkCtrlM can be run as a cvs commitinfo command.
|
||||
# The following commitinfo line (without the #) will run the script
|
||||
# ALL $CVSROOT/CVSROOT/checkCtrlM
|
||||
#
|
||||
failed=0
|
||||
#
|
||||
# skip the first arg, the directory
|
||||
shift 1
|
||||
|
||||
for file in "$@"; do
|
||||
#
|
||||
# select files with extentions .txx, .cxx, .h, .html, .htm, .c, .txt, .cmake
|
||||
match=`echo $file | egrep \[\.\]txx\$\|\[\.\]cxx\$\|\[\.\]h\$\|\[\.\]html\$\|\[\.\]htm\$\|\[\.\]c\$\|\[\.\]txt\$\|\[\.\]cmake\$`
|
||||
if [ "x$match" != "x" ] ; then
|
||||
count=`grep -n
|
||||
\$ /dev/null $file|wc -c`
|
||||
results=`expr $count \| 0`
|
||||
if [ "$results" != "0" ]; then
|
||||
echo "=========================================================="
|
||||
if [ $results -lt 200 ]; then
|
||||
grep -n
|
||||
\$ /dev/null $file
|
||||
fi
|
||||
echo ""
|
||||
echo "$file has ^M's. They must be removed before you can commit."
|
||||
echo "The problem count was $results"
|
||||
echo "=========================================================="
|
||||
failed=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
exit $failed
|
||||
32
CVSROOT/checkTabs
Executable file
32
CVSROOT/checkTabs
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/tcsh
|
||||
#
|
||||
# checkTabs checks source code for explicit TABS
|
||||
# checks only files with the following extensions: .c, .cxx, .txx,
|
||||
# exits with 0, if all commited files pass the test.
|
||||
# exits with 1, if any one of the tests fails
|
||||
#
|
||||
# checkTabs can be run as a cvs commitinfo command.
|
||||
# The following commitinfo line (without the #) will run the script
|
||||
# ALL $CVSROOT/CVSROOT/checkTabs
|
||||
#
|
||||
set failed=0
|
||||
#
|
||||
# skip the first arg, the directory
|
||||
foreach file ( $argv[2-] )
|
||||
#
|
||||
# select files with extentions .txx, .cxx, .h, .html, .htm
|
||||
set match=`echo $file | egrep \[\.\]txx\$\|\[\.\]cxx\$\|\[\.\]h\$\|\[\.\]cpp\$\|\[\.\]htm\$\|\[\.\]html\$\|\[\.\]c\$\|\[\.\]mm\$\|\[\.\]h.in\$\|\[\.\]hxx.in\$\|CMakeLists.txt\$\|\[\.\]cmake\$\|\[\.\]cmake.in\$`
|
||||
if ( $match == "" ) continue;
|
||||
set count=`grep -n " " /dev/null $file|wc -c`
|
||||
set results=`expr $count \| 0`
|
||||
if ( "$results" != "0" ) then
|
||||
echo "=========================================================="
|
||||
grep -n " " /dev/null $file
|
||||
echo ""
|
||||
echo "$file has explicit TABSs."
|
||||
echo "They must be converted to SPACES(2 per TAB) before you can commit."
|
||||
echo "=========================================================="
|
||||
set failed=1
|
||||
endif
|
||||
end
|
||||
exit $failed
|
||||
15
CVSROOT/checkoutlist
Normal file
15
CVSROOT/checkoutlist
Normal file
@@ -0,0 +1,15 @@
|
||||
# The "checkoutlist" file is used to support additional version controlled
|
||||
# administrative files in $CVSROOT/CVSROOT, such as template files.
|
||||
#
|
||||
# The first entry on a line is a filename which will be checked out from
|
||||
# the corresponding RCS file in the $CVSROOT/CVSROOT directory.
|
||||
# The remainder of the line is an error message to use if the file cannot
|
||||
# be checked out.
|
||||
#
|
||||
# File format:
|
||||
#
|
||||
# [<whitespace>]<filename><whitespace><error message><end-of-line>
|
||||
#
|
||||
# comment lines begin with '#'
|
||||
checkCtrlM cannot check out checkCtrlM
|
||||
checkTabs cannot check out checkTabs
|
||||
18
CVSROOT/commitinfo
Normal file
18
CVSROOT/commitinfo
Normal file
@@ -0,0 +1,18 @@
|
||||
# The "commitinfo" file is used to control pre-commit checks.
|
||||
# The filter on the right is invoked with the repository and a list
|
||||
# of files to check. A non-zero exit of the filter program will
|
||||
# cause the commit to be aborted.
|
||||
#
|
||||
# The first entry on a line is a regular expression which is tested
|
||||
# against the directory that the change is being committed to, relative
|
||||
# to the $CVSROOT. For the first match that is found, then the remainder
|
||||
# of the line is the name of the filter to run.
|
||||
#
|
||||
# If the repository name does not match any of the regular expressions in this
|
||||
# file, the "DEFAULT" line is used, if it is specified.
|
||||
#
|
||||
# If the name "ALL" appears as a regular expression it is always used
|
||||
# in addition to the first matching regex or "DEFAULT".
|
||||
|
||||
ALL $CVSROOT/CVSROOT/checkCtrlM %r/%p %s
|
||||
# ALL $CVSROOT/CVSROOT/checkTabs %r/%p %s
|
||||
14
CVSROOT/config
Normal file
14
CVSROOT/config
Normal file
@@ -0,0 +1,14 @@
|
||||
# Set this to "no" if pserver shouldn't check system users/passwords
|
||||
#SystemAuth=no
|
||||
|
||||
# Put CVS lock files in this directory rather than directly in the repository.
|
||||
#LockDir=/var/lock/cvs
|
||||
|
||||
# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top
|
||||
# level of the new working directory when using the `cvs checkout'
|
||||
# command.
|
||||
#TopLevelAdmin=no
|
||||
|
||||
# Set `LogHistory' to `all' or `TOFEWGCMAR' to log all transactions to the
|
||||
# history file, or a subset as needed (ie `TMAR' logs all write operations)
|
||||
#LogHistory=TOFEWGCMAR
|
||||
23
CVSROOT/cvswrappers
Normal file
23
CVSROOT/cvswrappers
Normal file
@@ -0,0 +1,23 @@
|
||||
# This file affects handling of files based on their names.
|
||||
#
|
||||
# The -t/-f options allow one to treat directories of files
|
||||
# as a single file, or to transform a file in other ways on
|
||||
# its way in and out of CVS.
|
||||
#
|
||||
# The -m option specifies whether CVS attempts to merge files.
|
||||
#
|
||||
# The -k option specifies keyword expansion (e.g. -kb for binary).
|
||||
#
|
||||
# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
|
||||
#
|
||||
# wildcard [option value][option value]...
|
||||
#
|
||||
# where option is one of
|
||||
# -f from cvs filter value: path to filter
|
||||
# -t to cvs filter value: path to filter
|
||||
# -m update methodology value: MERGE or COPY
|
||||
# -k expansion mode value: b, o, kkv, &c
|
||||
#
|
||||
# and value is a single-quote delimited value.
|
||||
# For example:
|
||||
#*.gif -k 'b'
|
||||
21
CVSROOT/editinfo
Normal file
21
CVSROOT/editinfo
Normal file
@@ -0,0 +1,21 @@
|
||||
# The "editinfo" file is used to allow verification of logging
|
||||
# information. It works best when a template (as specified in the
|
||||
# rcsinfo file) is provided for the logging procedure. Given a
|
||||
# template with locations for, a bug-id number, a list of people who
|
||||
# reviewed the code before it can be checked in, and an external
|
||||
# process to catalog the differences that were code reviewed, the
|
||||
# following test can be applied to the code:
|
||||
#
|
||||
# Making sure that the entered bug-id number is correct.
|
||||
# Validating that the code that was reviewed is indeed the code being
|
||||
# checked in (using the bug-id number or a seperate review
|
||||
# number to identify this particular code set.).
|
||||
#
|
||||
# If any of the above test failed, then the commit would be aborted.
|
||||
#
|
||||
# Actions such as mailing a copy of the report to each reviewer are
|
||||
# better handled by an entry in the loginfo file.
|
||||
#
|
||||
# One thing that should be noted is the the ALL keyword is not
|
||||
# supported. There can be only one entry that matches a given
|
||||
# repository.
|
||||
26
CVSROOT/loginfo
Normal file
26
CVSROOT/loginfo
Normal file
@@ -0,0 +1,26 @@
|
||||
# The "loginfo" file controls where "cvs commit" log information
|
||||
# is sent. The first entry on a line is a regular expression which must match
|
||||
# the directory that the change is being made to, relative to the
|
||||
# $CVSROOT. If a match is found, then the remainder of the line is a filter
|
||||
# program that should expect log information on its standard input.
|
||||
#
|
||||
# If the repository name does not match any of the regular expressions in this
|
||||
# file, the "DEFAULT" line is used, if it is specified.
|
||||
#
|
||||
# If the name ALL appears as a regular expression it is always used
|
||||
# in addition to the first matching regex or DEFAULT.
|
||||
#
|
||||
# You may specify a format string as part of the
|
||||
# filter. The string is composed of a `%' followed
|
||||
# by a single format character, or followed by a set of format
|
||||
# characters surrounded by `{' and `}' as separators. The format
|
||||
# characters are:
|
||||
#
|
||||
# s = file name
|
||||
# V = old version number (pre-checkin)
|
||||
# v = new version number (post-checkin)
|
||||
#
|
||||
# For example:
|
||||
#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog
|
||||
# or
|
||||
#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog
|
||||
29
CVSROOT/modules
Normal file
29
CVSROOT/modules
Normal file
@@ -0,0 +1,29 @@
|
||||
# Three different line formats are valid:
|
||||
# key -a aliases...
|
||||
# key [options] directory
|
||||
# key [options] directory files...
|
||||
#
|
||||
# Where "options" are composed of:
|
||||
# -i prog Run "prog" on "cvs commit" from top-level of module.
|
||||
# -o prog Run "prog" on "cvs checkout" of module.
|
||||
# -e prog Run "prog" on "cvs export" of module.
|
||||
# -t prog Run "prog" on "cvs rtag" of module.
|
||||
# -u prog Run "prog" on "cvs update" of module.
|
||||
# -d dir Place module in directory "dir" instead of module name.
|
||||
# -l Top-level directory only -- do not recurse.
|
||||
#
|
||||
# NOTE: If you change any of the "Run" options above, you'll have to
|
||||
# release and re-checkout any working directories of these modules.
|
||||
#
|
||||
# And "directory" is a path to a directory relative to $CVSROOT.
|
||||
#
|
||||
# The "-a" option specifies an alias. An alias is interpreted as if
|
||||
# everything on the right of the "-a" had been typed on the command line.
|
||||
#
|
||||
# You can encode a module within a module by using the special '&'
|
||||
# character to interpose another module into the current module. This
|
||||
# can be useful for creating a module that consists of many directories
|
||||
# spread out over the entire source repository.
|
||||
|
||||
opj-base -l -d . .
|
||||
openjpeg -a opj-base libopenjpeg codec doc
|
||||
12
CVSROOT/notify
Normal file
12
CVSROOT/notify
Normal file
@@ -0,0 +1,12 @@
|
||||
# The "notify" file controls where notifications from watches set by
|
||||
# "cvs watch add" or "cvs edit" are sent. The first entry on a line is
|
||||
# a regular expression which is tested against the directory that the
|
||||
# change is being made to, relative to the $CVSROOT. If it matches,
|
||||
# then the remainder of the line is a filter program that should contain
|
||||
# one occurrence of %s for the user to notify, and information on its
|
||||
# standard input.
|
||||
#
|
||||
# "ALL" or "DEFAULT" can be used in place of the regular expression.
|
||||
#
|
||||
# For example:
|
||||
#ALL mail %s -s "CVS notification"
|
||||
13
CVSROOT/rcsinfo
Normal file
13
CVSROOT/rcsinfo
Normal file
@@ -0,0 +1,13 @@
|
||||
# The "rcsinfo" file is used to control templates with which the editor
|
||||
# is invoked on commit and import.
|
||||
#
|
||||
# The first entry on a line is a regular expression which is tested
|
||||
# against the directory that the change is being made to, relative to the
|
||||
# $CVSROOT. For the first match that is found, then the remainder of the
|
||||
# line is the name of the file that contains the template.
|
||||
#
|
||||
# If the repository name does not match any of the regular expressions in this
|
||||
# file, the "DEFAULT" line is used, if it is specified.
|
||||
#
|
||||
# If the name "ALL" appears as a regular expression it is always used
|
||||
# in addition to the first matching regex or "DEFAULT".
|
||||
20
CVSROOT/taginfo
Normal file
20
CVSROOT/taginfo
Normal file
@@ -0,0 +1,20 @@
|
||||
# The "taginfo" file is used to control pre-tag checks.
|
||||
# The filter on the right is invoked with the following arguments:
|
||||
#
|
||||
# $1 -- tagname
|
||||
# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d
|
||||
# $3 -- repository
|
||||
# $4-> file revision [file revision ...]
|
||||
#
|
||||
# A non-zero exit of the filter program will cause the tag to be aborted.
|
||||
#
|
||||
# The first entry on a line is a regular expression which is tested
|
||||
# against the directory that the change is being committed to, relative
|
||||
# to the $CVSROOT. For the first match that is found, then the remainder
|
||||
# of the line is the name of the filter to run.
|
||||
#
|
||||
# If the repository name does not match any of the regular expressions in this
|
||||
# file, the "DEFAULT" line is used, if it is specified.
|
||||
#
|
||||
# If the name "ALL" appears as a regular expression it is always used
|
||||
# in addition to the first matching regex or "DEFAULT".
|
||||
21
CVSROOT/verifymsg
Normal file
21
CVSROOT/verifymsg
Normal file
@@ -0,0 +1,21 @@
|
||||
# The "verifymsg" file is used to allow verification of logging
|
||||
# information. It works best when a template (as specified in the
|
||||
# rcsinfo file) is provided for the logging procedure. Given a
|
||||
# template with locations for, a bug-id number, a list of people who
|
||||
# reviewed the code before it can be checked in, and an external
|
||||
# process to catalog the differences that were code reviewed, the
|
||||
# following test can be applied to the code:
|
||||
#
|
||||
# Making sure that the entered bug-id number is correct.
|
||||
# Validating that the code that was reviewed is indeed the code being
|
||||
# checked in (using the bug-id number or a seperate review
|
||||
# number to identify this particular code set.).
|
||||
#
|
||||
# If any of the above test failed, then the commit would be aborted.
|
||||
#
|
||||
# Actions such as mailing a copy of the report to each reviewer are
|
||||
# better handled by an entry in the loginfo file.
|
||||
#
|
||||
# One thing that should be noted is the the ALL keyword is not
|
||||
# supported. There can be only one entry that matches a given
|
||||
# repository.
|
||||
115
ChangeLog
Normal file
115
ChangeLog
Normal file
@@ -0,0 +1,115 @@
|
||||
What's New for OpenJPEG
|
||||
|
||||
* : fixed
|
||||
- : removed
|
||||
! : changed
|
||||
+ : added
|
||||
|
||||
January 31, 2007
|
||||
! [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
|
||||
273
DllOpenJPEG.dsp
Normal file
273
DllOpenJPEG.dsp
Normal file
@@ -0,0 +1,273 @@
|
||||
# Microsoft Developer Studio Project File - Name="DllOpenJPEG" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=DllOpenJPEG - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "DllOpenJPEG.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "DllOpenJPEG.mak" CFG="DllOpenJPEG - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "DllOpenJPEG - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "DllOpenJPEG - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "DllOpenJPEG - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DLLOPENJPEG_EXPORTS" /Yu"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OPJ_EXPORTS" /FD /c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40c /d "NDEBUG"
|
||||
# ADD RSC /l 0x40c /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release/OpenJPEG.dll"
|
||||
# Begin Special Build Tool
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Cmds=if not exist dist mkdir dist copy libopenjpeg\openjpeg.h dist copy Release\OpenJPEG.dll dist copy Release\OpenJPEG.lib dist
|
||||
# End Special Build Tool
|
||||
|
||||
!ELSEIF "$(CFG)" == "DllOpenJPEG - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DLLOPENJPEG_EXPORTS" /Yu"stdafx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OPJ_EXPORTS" /FD /GZ /c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40c /d "_DEBUG"
|
||||
# ADD RSC /l 0x40c /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Debug/OpenJPEGd.dll" /pdbtype:sept
|
||||
# Begin Special Build Tool
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Cmds=if not exist dist mkdir dist copy libopenjpeg\openjpeg.h dist copy Debug\OpenJPEGd.dll dist copy Debug\OpenJPEGd.lib dist
|
||||
# End Special Build Tool
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "DllOpenJPEG - Win32 Release"
|
||||
# Name "DllOpenJPEG - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\bio.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\cio.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\dwt.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\event.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\image.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\j2k.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\j2k_lib.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\jp2.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\jpt.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\mct.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\mqc.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\openjpeg.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\pi.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\raw.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\t1.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\t2.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\tcd.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\tgt.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\bio.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\cio.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\dwt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\event.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\fix.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\image.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\int.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\j2k.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\j2k_lib.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\jp2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\jpt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\mct.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\mqc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\openjpeg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\opj_includes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\pi.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\raw.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\t1.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\t2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\tcd.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\tgt.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\OpenJPEG.rc
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
258
LibOpenJPEG.dsp
Normal file
258
LibOpenJPEG.dsp
Normal file
@@ -0,0 +1,258 @@
|
||||
# Microsoft Developer Studio Project File - Name="LibOpenJPEG" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=LibOpenJPEG - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "LibOpenJPEG.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "LibOpenJPEG.mak" CFG="LibOpenJPEG - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "LibOpenJPEG - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "LibOpenJPEG - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "LibOpenJPEG - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "OPJ_STATIC" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x40c /d "NDEBUG"
|
||||
# ADD RSC /l 0x40c /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
# Begin Special Build Tool
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Cmds=if not exist dist mkdir dist copy Release\LibOpenJPEG.lib dist copy libopenjpeg\openjpeg.h dist
|
||||
# End Special Build Tool
|
||||
|
||||
!ELSEIF "$(CFG)" == "LibOpenJPEG - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "OPJ_STATIC" /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x40c /d "_DEBUG"
|
||||
# ADD RSC /l 0x40c /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"Debug\LibOpenJPEGd.lib"
|
||||
# Begin Special Build Tool
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Cmds=if not exist dist mkdir dist copy Debug\LibOpenJPEGd.lib dist copy libopenjpeg\openjpeg.h dist
|
||||
# End Special Build Tool
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "LibOpenJPEG - Win32 Release"
|
||||
# Name "LibOpenJPEG - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\bio.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\cio.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\dwt.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\event.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\image.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\j2k.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\j2k_lib.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\jp2.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\jpt.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\mct.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\mqc.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\openjpeg.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\pi.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\raw.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\t1.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\t2.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\tcd.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\tgt.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\bio.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\cio.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\dwt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\event.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\fix.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\image.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\int.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\j2k.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\j2k_lib.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\jp2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\jpt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\mct.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\mqc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\openjpeg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\opj_includes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\pi.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\raw.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\t1.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\t2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\tcd.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=libopenjpeg\tgt.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,29 +1,41 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "j2k_to_image"=".\j2k_to_image.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "DllOpenJPEG"=.\DllOpenJPEG.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "LibOpenJPEG"=.\LibOpenJPEG.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
72
Makefile
Normal file
72
Makefile
Normal file
@@ -0,0 +1,72 @@
|
||||
# Linux makefile for OpenJPEG
|
||||
|
||||
VER_MAJOR = 1
|
||||
VER_MINOR = 0.0
|
||||
|
||||
SRCS = ./libopenjpeg/bio.c ./libopenjpeg/cio.c ./libopenjpeg/dwt.c ./libopenjpeg/event.c ./libopenjpeg/image.c ./libopenjpeg/j2k.c ./libopenjpeg/j2k_lib.c ./libopenjpeg/jp2.c ./libopenjpeg/jpt.c ./libopenjpeg/mct.c ./libopenjpeg/mqc.c ./libopenjpeg/openjpeg.c ./libopenjpeg/pi.c ./libopenjpeg/raw.c ./libopenjpeg/t1.c ./libopenjpeg/t2.c ./libopenjpeg/tcd.c ./libopenjpeg/tgt.c
|
||||
INCLS = ./libopenjpeg/bio.h ./libopenjpeg/cio.h ./libopenjpeg/dwt.h ./libopenjpeg/event.h ./libopenjpeg/fix.h ./libopenjpeg/image.h ./libopenjpeg/int.h ./libopenjpeg/j2k.h ./libopenjpeg/j2k_lib.h ./libopenjpeg/jp2.h ./libopenjpeg/jpt.h ./libopenjpeg/mct.h ./libopenjpeg/mqc.h ./libopenjpeg/openjpeg.h ./libopenjpeg/pi.h ./libopenjpeg/raw.h ./libopenjpeg/t1.h ./libopenjpeg/t2.h ./libopenjpeg/tcd.h ./libopenjpeg/tgt.h ./libopenjpeg/opj_includes.h
|
||||
INCLUDE = -Ilibopenjpeg
|
||||
|
||||
# General configuration variables:
|
||||
CC = gcc
|
||||
AR = ar
|
||||
|
||||
INSTALLDIR = /usr/lib
|
||||
|
||||
# Converts cr/lf to just lf
|
||||
DOS2UNIX = dos2unix
|
||||
|
||||
COMPILERFLAGS = -O3
|
||||
LIBRARIES = -lstdc++
|
||||
|
||||
MODULES = $(SRCS:.c=.o)
|
||||
CFLAGS = $(COMPILERFLAGS) $(INCLUDE)
|
||||
|
||||
TARGET = openjpeg
|
||||
STATICLIB = lib$(TARGET).a
|
||||
SHAREDLIB = lib$(TARGET)-$(VER_MAJOR).$(VER_MINOR).so
|
||||
LIBNAME = lib$(TARGET).so.$(VER_MAJOR)
|
||||
|
||||
|
||||
|
||||
default: all
|
||||
|
||||
all: dist
|
||||
|
||||
dist: OpenJPEG
|
||||
mkdir dist
|
||||
cp *.a dist/
|
||||
cp *.so dist/
|
||||
cp libopenjpeg/openjpeg.h dist/
|
||||
|
||||
dos2unix:
|
||||
@$(DOS2UNIX) $(SRCS) $(INCLS)
|
||||
|
||||
OpenJPEG: $(STATICLIB) $(SHAREDLIB)
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(STATICLIB): $(MODULES)
|
||||
$(AR) r $@ $(MODULES)
|
||||
|
||||
$(SHAREDLIB): $(MODULES)
|
||||
$(CC) -s -shared -Wl,-soname,$(LIBNAME) -o $@ $(MODULES) $(LIBRARIES)
|
||||
|
||||
install:
|
||||
install -m 644 -o root -g root $(STATICLIB) $(INSTALLDIR)
|
||||
install -m 755 -o root -g root $(SHAREDLIB) $(INSTALLDIR)
|
||||
ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(LIBNAME)
|
||||
ldconfig
|
||||
|
||||
clean:
|
||||
rm -rf core dist/ u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB) $(LIBNAME)
|
||||
|
||||
osx:
|
||||
make -f Makefile.osx
|
||||
|
||||
osxinstall:
|
||||
make -f Makefile.osx install
|
||||
|
||||
osxclean:
|
||||
make -f Makefile.osx clean
|
||||
58
Makefile.osx
Normal file
58
Makefile.osx
Normal file
@@ -0,0 +1,58 @@
|
||||
# Mac OSX makefile for OpenJPEG
|
||||
|
||||
VER_MAJOR = 1
|
||||
VER_MINOR = 0.0
|
||||
|
||||
SRCS = ./libopenjpeg/bio.c ./libopenjpeg/cio.c ./libopenjpeg/dwt.c ./libopenjpeg/event.c ./libopenjpeg/image.c ./libopenjpeg/j2k.c ./libopenjpeg/j2k_lib.c ./libopenjpeg/jp2.c ./libopenjpeg/jpt.c ./libopenjpeg/mct.c ./libopenjpeg/mqc.c ./libopenjpeg/openjpeg.c ./libopenjpeg/pi.c ./libopenjpeg/raw.c ./libopenjpeg/t1.c ./libopenjpeg/t2.c ./libopenjpeg/tcd.c ./libopenjpeg/tgt.c
|
||||
INCLS = ./libopenjpeg/bio.h ./libopenjpeg/cio.h ./libopenjpeg/dwt.h ./libopenjpeg/event.h ./libopenjpeg/fix.h ./libopenjpeg/image.h ./libopenjpeg/int.h ./libopenjpeg/j2k.h ./libopenjpeg/j2k_lib.h ./libopenjpeg/jp2.h ./libopenjpeg/jpt.h ./libopenjpeg/mct.h ./libopenjpeg/mqc.h ./libopenjpeg/openjpeg.h ./libopenjpeg/pi.h ./libopenjpeg/raw.h ./libopenjpeg/t1.h ./libopenjpeg/t2.h ./libopenjpeg/tcd.h ./libopenjpeg/tgt.h ./libopenjpeg/opj_includes.h
|
||||
INCLUDE = -Ilibopenjpeg
|
||||
|
||||
# General configuration variables:
|
||||
CC = gcc
|
||||
LIBTOOL = libtool
|
||||
|
||||
INSTALLDIR = /usr/lib
|
||||
|
||||
COMPILERFLAGS = -O3
|
||||
LIBRARIES = -lc -lgcc -lstdc++
|
||||
|
||||
MODULES = $(SRCS:.c=.o)
|
||||
CFLAGS = $(COMPILERFLAGS) $(INCLUDE)
|
||||
|
||||
TARGET = openjpeg
|
||||
STATICLIB = lib$(TARGET).a
|
||||
SHAREDLIB = lib$(TARGET)-$(VER_MAJOR).$(VER_MINOR).dylib
|
||||
LIBNAME = lib$(TARGET).dylib.$(VER_MAJOR)
|
||||
|
||||
|
||||
|
||||
default: all
|
||||
|
||||
all: dist
|
||||
|
||||
dist: OpenJPEG
|
||||
mkdir dist
|
||||
cp *.a dist/
|
||||
cp *.dylib dist/
|
||||
cp libopenjpeg/openjpeg.h dist/
|
||||
|
||||
OpenJPEG: $(STATICLIB) $(SHAREDLIB)
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(STATICLIB): $(MODULES)
|
||||
$(LIBTOOL) -o $@ $(MODULES)
|
||||
|
||||
$(SHAREDLIB): $(MODULES)
|
||||
$(LIBTOOL) -dynamic $(LIBRARIES) -o $@ $(MODULES)
|
||||
|
||||
install:
|
||||
install -m 644 -o root -g wheel $(STATICLIB) $(INSTALLDIR)
|
||||
install -m 755 -o root -g wheel $(SHAREDLIB) $(INSTALLDIR)
|
||||
ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(LIBNAME)
|
||||
ranlib $(INSTALLDIR)/$(STATICLIB)
|
||||
|
||||
clean:
|
||||
rm -rf core dist/ u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB) $(LIBNAME)
|
||||
|
||||
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-2006, 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
|
||||
|
||||
32
README.linux
Normal file
32
README.linux
Normal file
@@ -0,0 +1,32 @@
|
||||
Release Notes
|
||||
--------------
|
||||
This version of the library has been tested under the following OS:
|
||||
- RedHat Linux 9.0
|
||||
|
||||
You should be able to link progams with the -lopenjpeg option after the library is compiled and installed.
|
||||
You can also statically link with libopenjpeg.a.
|
||||
If you use a really old version of gcc and it chokes on the CRs in the file, you can type 'make dos2unix'
|
||||
to run all of the files through dos2unix which converts CRLF to LF. This no longer appears to be required
|
||||
for RedHat 7.3 or 9.
|
||||
|
||||
Please let us know how this works for you under other Linux distributions or any other *nix.
|
||||
|
||||
Installation
|
||||
------------
|
||||
Note: You will need to have root privileges in order to install the library in the /usr/lib directory.
|
||||
The installation process is as simple as this :
|
||||
1) Enter the OpenJPEG directory
|
||||
2) Build the distribution :
|
||||
make
|
||||
make install
|
||||
3) Clean all files produced during the build process
|
||||
make clean
|
||||
|
||||
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 use one of the following commands to build an encoder and decoder respectively:
|
||||
|
||||
gcc convert.c image_to_j2k.c -o image_to_j2k -lopenjpeg -I ../libopenjpeg/ -lm
|
||||
gcc convert.c j2k_to_image.c -o j2k_to_image -lopenjpeg -I ../libopenjpeg/ -lm
|
||||
|
||||
You should add '-L..' to those lines if you did not use the 'install' target (and the 'clean' target neither...).
|
||||
40
README.msvc
Normal file
40
README.msvc
Normal file
@@ -0,0 +1,40 @@
|
||||
How to compile the library under MS VC++ 6.0
|
||||
--------------------------------------------
|
||||
|
||||
The library comes in two versions :
|
||||
- a static library that can be linked against any C/C++ program
|
||||
- a Dynamic Link Library (Windows DLL) that can be used in any C/C++ program and in most interpreted languages (e.g. VB, C#, ...).
|
||||
|
||||
In order to compile the library version *or* the DLL version, you will have to :
|
||||
|
||||
1) Open the MSVC workspace named LibOpenJPEG.dsw
|
||||
2) Set the choosen target as the active project, that means :
|
||||
a) Go to the Menu 'Build -> Set Active Configuration'
|
||||
b) Choose one of the following configuration :
|
||||
- DllOpenJPEG - Win32 Release => creates a DLL in release mode named OpenJPEG.dll
|
||||
- DllOpenJPEG - Win32 Debug => creates a DLL in debug mode named OpenJPEGd.dll
|
||||
- LibOpenJPEG - Win32 Release => creates a static library in release mode named LibOpenJPEG.lib
|
||||
- LibOpenJPEG - Win32 Debug => creates a static library in debug mode named LibOpenJPEGd.lib
|
||||
3) Build the project : Menu -> Build -> Rebuild All
|
||||
|
||||
The build process will create a directory named 'dist' that will contain all you need in order to use the library.
|
||||
|
||||
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 use one of the following projects to build an encoder and decoder respectively:
|
||||
- image_to_j2k.dsw
|
||||
- j2k_to_image.dsw
|
||||
|
||||
IMPORTANT NOTE :
|
||||
----------------
|
||||
|
||||
The encoder and decoder samples are configured to use the static version of the library. A link to the LibOpenJPEG static project is included in these projects so that you can build both a codec and the library in a single pass.
|
||||
|
||||
However, you MUST NOTE that in order to use LibOpenJPEG as a static library in your program, you NEED to add the following compiler directive to your project : OPJ_STATIC
|
||||
Look at the menu 'Project -> Settings -> C/C++ tab -> preprocessor definition' to see how this is configured.
|
||||
When using OpenJPEG as a DLL, this compiler directive MUST NOT be used.
|
||||
|
||||
|
||||
|
||||
|
||||
25
README.osx
Normal file
25
README.osx
Normal file
@@ -0,0 +1,25 @@
|
||||
Release Notes
|
||||
--------------
|
||||
This version of the library has been tested under OSX 10.3 using gcc 3.3.
|
||||
|
||||
While the makefiles will make a .dylib and a .a, it is recommended to simply staticly link with the .a file.
|
||||
|
||||
Installation
|
||||
------------
|
||||
Note: You will need to have root privileges in order to install the library in the /usr/lib directory.
|
||||
The installation process is as simple as this :
|
||||
1) Enter the OpenJPEG directory
|
||||
2) Build the distribution :
|
||||
make osx
|
||||
make osxinstall
|
||||
3) Clean all files produced during the build process
|
||||
make osxclean
|
||||
|
||||
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 use one of the following commands to build an encoder and decoder respectively:
|
||||
|
||||
gcc convert.c image_to_j2k.c -o image_to_j2k -lopenjpeg -I ../libopenjpeg/ -lm
|
||||
gcc convert.c j2k_to_image.c -o j2k_to_image -lopenjpeg -I ../libopenjpeg/ -lm
|
||||
|
||||
You should add '-L..' to those lines if you did not use the 'osxinstall' target (and the 'osxclean' target neither...).
|
||||
25
clean.bat
Normal file
25
clean.bat
Normal file
@@ -0,0 +1,25 @@
|
||||
rd Release /s /q
|
||||
rd Debug /s /q
|
||||
rd codec\Debug /s /q
|
||||
rd codec\Release /s /q
|
||||
rd dist /s /q
|
||||
del *.pch /s /q
|
||||
del *.ncb /s /q
|
||||
del *.opt /s /q
|
||||
del *.plg /s /q
|
||||
del *.obj /s /q
|
||||
del *.dll /s /q
|
||||
del *.exe /s /q
|
||||
del *.bsc /s /q
|
||||
del *.bak /s /q
|
||||
del *.pdb /s /q
|
||||
del *.sql /s /q
|
||||
del *.mdb /s /q
|
||||
del *.lib /s /q
|
||||
del *.exp /s /q
|
||||
del *.ilk /s /q
|
||||
del *.idb /s /q
|
||||
del *.aps /s /q
|
||||
del *.suo /s /q /a:h
|
||||
del *.o /s /q
|
||||
|
||||
51
codec/CMakeLists.txt
Normal file
51
codec/CMakeLists.txt
Normal file
@@ -0,0 +1,51 @@
|
||||
# Build the demo app, small examples
|
||||
|
||||
# First thing define the common source:
|
||||
SET(common_SRCS
|
||||
convert.c
|
||||
)
|
||||
# Then check if getopt is present:
|
||||
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||
SET(DONT_HAVE_GETOPT 1)
|
||||
IF(UNIX) #I am pretty sure only *nix sys have this anyway
|
||||
CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
|
||||
# Seems like we need the contrary:
|
||||
IF(CMAKE_HAVE_GETOPT_H)
|
||||
SET(DONT_HAVE_GETOPT 0)
|
||||
ENDIF(CMAKE_HAVE_GETOPT_H)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# If not getopt was found then add it to the lib:
|
||||
IF(DONT_HAVE_GETOPT)
|
||||
ADD_DEFINITIONS(-DDONT_HAVE_GETOPT)
|
||||
SET(common_SRCS
|
||||
${common_SRCS}
|
||||
compat/getopt.c
|
||||
)
|
||||
ENDIF(DONT_HAVE_GETOPT)
|
||||
|
||||
|
||||
# Headers file are located here:
|
||||
INCLUDE_DIRECTORIES(
|
||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
||||
)
|
||||
|
||||
# Do the proper thing when building static...if only there was configured
|
||||
# headers or def files instead
|
||||
IF(NOT BUILD_SHARED_LIBS)
|
||||
ADD_DEFINITIONS(-DOPJ_STATIC)
|
||||
ENDIF(NOT BUILD_SHARED_LIBS)
|
||||
|
||||
# Loop over all executables:
|
||||
FOREACH(exe j2k_to_image image_to_j2k)
|
||||
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
|
||||
TARGET_LINK_LIBRARIES(${exe} ${OPJ_PREFIX}openjpeg)
|
||||
# On unix you need to link to the math library:
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(${exe} -lm)
|
||||
ENDIF(UNIX)
|
||||
# Install exe
|
||||
INSTALL_TARGETS(/bin/ ${exe})
|
||||
ENDFOREACH(exe)
|
||||
|
||||
|
||||
14
codec/Makefile
Normal file
14
codec/Makefile
Normal file
@@ -0,0 +1,14 @@
|
||||
# Makefile for the main OpenJPEG codecs: j2k_to_image and image_to_j2k
|
||||
|
||||
CFLAGS = -O3 -lstdc++ # -g -p -pg
|
||||
|
||||
all: j2k_to_image image_to_j2k
|
||||
|
||||
j2k_to_image: j2k_to_image.c ../libopenjpeg.a
|
||||
gcc $(CFLAGS) convert.c j2k_to_image.c -o j2k_to_image -L.. -lopenjpeg -I ../libopenjpeg/ -lm
|
||||
|
||||
image_to_j2k: image_to_j2k.c ../libopenjpeg.a
|
||||
gcc $(CFLAGS) convert.c image_to_j2k.c -o image_to_j2k -L.. -lopenjpeg -I ../libopenjpeg/ -lm
|
||||
|
||||
clean:
|
||||
rm -f j2k_to_image image_to_j2k
|
||||
@@ -45,7 +45,7 @@ int opterr = 1, /* if error message should be printed */
|
||||
optind = 1, /* index into parent argv vector */
|
||||
optopt, /* character checked for validity */
|
||||
optreset; /* reset getopt */
|
||||
char *optarg; /* argument associated with option */
|
||||
const char *optarg; /* argument associated with option */
|
||||
|
||||
#define BADCH (int)'?'
|
||||
#define BADARG (int)':'
|
||||
@@ -55,13 +55,9 @@ char *optarg; /* argument associated with option */
|
||||
* getopt --
|
||||
* Parse argc/argv argument vector.
|
||||
*/
|
||||
int getopt(nargc, nargv, ostr)
|
||||
int nargc;
|
||||
char *const *nargv;
|
||||
const char *ostr;
|
||||
{
|
||||
int getopt(int nargc, char *const *nargv, const char *ostr) {
|
||||
# define __progname nargv[0]
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
static const char *place = EMSG; /* option letter processing */
|
||||
char *oli; /* option letter list index */
|
||||
|
||||
if (optreset || !*place) { /* update scanning pointer */
|
||||
1066
codec/convert.c
Normal file
1066
codec/convert.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,10 @@
|
||||
/*
|
||||
* 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) 2002-2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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
|
||||
@@ -25,15 +28,26 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __J2K_CONVERT_H
|
||||
#define __J2K_CONVERT_H
|
||||
|
||||
#include "j2k.h"
|
||||
opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters);
|
||||
|
||||
int bmptoimage(char *filename, j2k_image_t * img, int subsampling_dx,
|
||||
int subsampling_dy, int Dim[2]);
|
||||
int imagetobmp(opj_image_t *image, const char *outfile);
|
||||
|
||||
int pgxtoimage(char *filename, j2k_image_t * img, int tdy,
|
||||
int subsampling_dx, int subsampling_dy, int Dim[2],
|
||||
j2k_cp_t cp);
|
||||
/**
|
||||
Load a single image component encoded in PGX file format
|
||||
@param filename Name of the PGX file to load
|
||||
@param parameters *List ?*
|
||||
@return Returns a greyscale image if successful, returns NULL otherwise
|
||||
*/
|
||||
opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters);
|
||||
|
||||
int imagetopgx(opj_image_t *image, const char *outfile);
|
||||
|
||||
opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters);
|
||||
|
||||
int imagetopnm(opj_image_t *image, const char *outfile);
|
||||
|
||||
#endif /* __J2K_CONVERT_H */
|
||||
|
||||
int pnmtoimage(char *filename, j2k_image_t * img, int subsampling_dx,
|
||||
int subsampling_dy, int Dim[2]);
|
||||
1222
codec/image_to_j2k.c
Normal file
1222
codec/image_to_j2k.c
Normal file
File diff suppressed because it is too large
Load Diff
107
codec/image_to_j2k.dsp
Normal file
107
codec/image_to_j2k.dsp
Normal file
@@ -0,0 +1,107 @@
|
||||
# Microsoft Developer Studio Project File - Name="image_to_j2k" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=image_to_j2k - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "image_to_j2k.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "image_to_j2k.mak" CFG="image_to_j2k - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "image_to_j2k - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "image_to_j2k - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "image_to_j2k - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x40c /d "NDEBUG"
|
||||
# ADD RSC /l 0x40c /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "image_to_j2k - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x40c /d "_DEBUG"
|
||||
# ADD RSC /l 0x40c /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "image_to_j2k - Win32 Release"
|
||||
# Name "image_to_j2k - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\convert.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\convert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\compat\getopt.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\compat\getopt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\image_to_j2k.c
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,29 +1,44 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "image_to_j2k"=.\image_to_j2k.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "LibOpenJPEG"=..\LibOpenJPEG.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "image_to_j2k"=.\image_to_j2k.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name LibOpenJPEG
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
489
codec/j2k_to_image.c
Normal file
489
codec/j2k_to_image.c
Normal file
@@ -0,0 +1,489 @@
|
||||
/*
|
||||
* 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 "openjpeg.h"
|
||||
#include "compat/getopt.h"
|
||||
#include "convert.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#define stricmp strcasecmp
|
||||
#define strnicmp strncasecmp
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
#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
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
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," -i <compressed file>\n");
|
||||
fprintf(stdout," REQUIRED\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_file_format(char *filename) {
|
||||
unsigned int i;
|
||||
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp", "j2k", "jp2", "jpt" };
|
||||
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT };
|
||||
char * ext = strrchr(filename, '.') + 1;
|
||||
if(ext) {
|
||||
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
||||
if(strnicmp(ext, extension[i], 3) == 0) {
|
||||
return format[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters) {
|
||||
/* parse the command line */
|
||||
|
||||
/* UniPG>> */
|
||||
const char optlist[] = "i:o:r:l:h"
|
||||
|
||||
#ifdef USE_JPWL
|
||||
"W:"
|
||||
#endif /* USE_JPWL */
|
||||
;
|
||||
/* <<UniPG */
|
||||
|
||||
while (1) {
|
||||
int c = getopt(argc, argv, optlist); /* >>JPWL<< */
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
case 'i': /* input file */
|
||||
{
|
||||
char *infile = optarg;
|
||||
parameters->decod_format = get_file_format(infile);
|
||||
switch(parameters->decod_format) {
|
||||
case J2K_CFMT:
|
||||
case JP2_CFMT:
|
||||
case JPT_CFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"!! Unrecognized format for infile : %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
|
||||
infile);
|
||||
return 1;
|
||||
}
|
||||
strncpy(parameters->infile, infile, OPJ_PATH_LEN);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'o': /* output file */
|
||||
{
|
||||
char *outfile = optarg;
|
||||
parameters->cod_format = get_file_format(outfile);
|
||||
switch(parameters->cod_format) {
|
||||
case PGX_DFMT:
|
||||
case PXM_DFMT:
|
||||
case BMP_DFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx or *.bmp]!! \n", outfile);
|
||||
return 1;
|
||||
}
|
||||
strncpy(parameters->outfile, outfile, OPJ_PATH_LEN);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
|
||||
case 'r': /* reduce option */
|
||||
{
|
||||
sscanf(optarg, "%d", ¶meters->cp_reduce);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
|
||||
case 'l': /* layering option */
|
||||
{
|
||||
sscanf(optarg, "%d", ¶meters->cp_layer);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'h': /* display an help description */
|
||||
decode_help_display();
|
||||
return 1;
|
||||
|
||||
/* UniPG>> */
|
||||
#ifdef USE_JPWL
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'W': /* activate JPWL correction */
|
||||
{
|
||||
char *token = NULL;
|
||||
|
||||
token = strtok(optarg, ",");
|
||||
while(token != NULL) {
|
||||
|
||||
/* search expected number of components */
|
||||
if (*token == 'c') {
|
||||
|
||||
static int compno;
|
||||
|
||||
compno = JPWL_EXPECTED_COMPONENTS; /* predefined no. of components */
|
||||
|
||||
if(sscanf(token, "c=%d", &compno) == 1) {
|
||||
/* Specified */
|
||||
if ((compno < 1) || (compno > 256)) {
|
||||
fprintf(stderr, "ERROR -> invalid number of components c = %d\n", compno);
|
||||
return 1;
|
||||
}
|
||||
parameters->jpwl_exp_comps = compno;
|
||||
|
||||
} else if (!strcmp(token, "c")) {
|
||||
/* default */
|
||||
parameters->jpwl_exp_comps = compno; /* auto for default size */
|
||||
|
||||
} else {
|
||||
fprintf(stderr, "ERROR -> invalid components specified = %s\n", token);
|
||||
return 1;
|
||||
};
|
||||
}
|
||||
|
||||
/* search maximum number of tiles */
|
||||
if (*token == 't') {
|
||||
|
||||
static int tileno;
|
||||
|
||||
tileno = JPWL_MAXIMUM_TILES; /* maximum no. of tiles */
|
||||
|
||||
if(sscanf(token, "t=%d", &tileno) == 1) {
|
||||
/* Specified */
|
||||
if ((tileno < 1) || (tileno > JPWL_MAXIMUM_TILES)) {
|
||||
fprintf(stderr, "ERROR -> invalid number of tiles t = %d\n", tileno);
|
||||
return 1;
|
||||
}
|
||||
parameters->jpwl_max_tiles = tileno;
|
||||
|
||||
} else if (!strcmp(token, "t")) {
|
||||
/* default */
|
||||
parameters->jpwl_max_tiles = tileno; /* auto for default size */
|
||||
|
||||
} else {
|
||||
fprintf(stderr, "ERROR -> invalid tiles specified = %s\n", token);
|
||||
return 1;
|
||||
};
|
||||
}
|
||||
|
||||
/* next token or bust */
|
||||
token = strtok(NULL, ",");
|
||||
};
|
||||
parameters->jpwl_correct = true;
|
||||
fprintf(stdout, "JPWL correction capability activated\n");
|
||||
fprintf(stdout, "- expecting %d components\n", parameters->jpwl_exp_comps);
|
||||
}
|
||||
break;
|
||||
#endif /* USE_JPWL */
|
||||
/* <<UniPG */
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
default:
|
||||
fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, optarg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* check for possible errors */
|
||||
|
||||
if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
|
||||
fprintf(stderr,"ERROR -> At least one required argument is missing\nCheck j2k_to_image -h for usage information\n");
|
||||
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 */
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
opj_image_t *image = NULL;
|
||||
FILE *fsrc = NULL;
|
||||
unsigned char *src = NULL;
|
||||
int file_length;
|
||||
|
||||
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
|
||||
opj_cio_t *cio = NULL;
|
||||
|
||||
/* 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);
|
||||
|
||||
/* parse input and get user decoding parameters */
|
||||
if(parse_cmdline_decoder(argc, argv, ¶meters) == 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* read the input file and put it in memory */
|
||||
/* ---------------------------------------- */
|
||||
fsrc = fopen(parameters.infile, "rb");
|
||||
if (!fsrc) {
|
||||
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
||||
return 1;
|
||||
}
|
||||
fseek(fsrc, 0, SEEK_END);
|
||||
file_length = ftell(fsrc);
|
||||
fseek(fsrc, 0, SEEK_SET);
|
||||
src = (unsigned char *) malloc(file_length);
|
||||
fread(src, 1, file_length, fsrc);
|
||||
fclose(fsrc);
|
||||
|
||||
/* decode the code-stream */
|
||||
/* ---------------------- */
|
||||
|
||||
switch(parameters.decod_format) {
|
||||
case J2K_CFMT:
|
||||
{
|
||||
/* JPEG-2000 codestream */
|
||||
|
||||
/* get a decoder handle */
|
||||
dinfo = opj_create_decompress(CODEC_J2K);
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
|
||||
|
||||
/* setup the decoder decoding parameters using user parameters */
|
||||
opj_setup_decoder(dinfo, ¶meters);
|
||||
|
||||
/* open a byte stream */
|
||||
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
|
||||
|
||||
/* decode the stream and fill the image structure */
|
||||
image = opj_decode(dinfo, cio);
|
||||
if(!image) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
}
|
||||
break;
|
||||
|
||||
case JP2_CFMT:
|
||||
{
|
||||
/* JPEG 2000 compressed image data */
|
||||
|
||||
/* get a decoder handle */
|
||||
dinfo = opj_create_decompress(CODEC_JP2);
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, 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 */
|
||||
image = opj_decode(dinfo, cio);
|
||||
if(!image) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case JPT_CFMT:
|
||||
{
|
||||
/* JPEG 2000, JPIP */
|
||||
|
||||
/* get a decoder handle */
|
||||
dinfo = opj_create_decompress(CODEC_JPT);
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, 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 */
|
||||
image = opj_decode(dinfo, cio);
|
||||
if(!image) {
|
||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "ERROR -> j2k_to_image : Unknown input image format\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* free the memory containing the code-stream */
|
||||
free(src);
|
||||
src = NULL;
|
||||
|
||||
/* create output image */
|
||||
/* ------------------- */
|
||||
|
||||
switch (parameters.cod_format) {
|
||||
case PXM_DFMT: /* PNM PGM PPM */
|
||||
imagetopnm(image, parameters.outfile);
|
||||
break;
|
||||
|
||||
case PGX_DFMT: /* PGX */
|
||||
imagetopgx(image, parameters.outfile);
|
||||
break;
|
||||
|
||||
case BMP_DFMT: /* BMP */
|
||||
imagetobmp(image, parameters.outfile);
|
||||
break;
|
||||
}
|
||||
|
||||
/* free remaining structures */
|
||||
if(dinfo) {
|
||||
opj_destroy_decompress(dinfo);
|
||||
}
|
||||
|
||||
/* free image data structure */
|
||||
opj_image_destroy(image);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
106
codec/j2k_to_image.dsp
Normal file
106
codec/j2k_to_image.dsp
Normal file
@@ -0,0 +1,106 @@
|
||||
# Microsoft Developer Studio Project File - Name="j2k_to_image" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=j2k_to_image - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "j2k_to_image.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "j2k_to_image.mak" CFG="j2k_to_image - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "j2k_to_image - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "j2k_to_image - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "j2k_to_image - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../libopenjpeg" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x40c /d "NDEBUG"
|
||||
# ADD RSC /l 0x40c /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "j2k_to_image - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "OPJ_STATIC" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x40c /d "_DEBUG"
|
||||
# ADD RSC /l 0x40c /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "j2k_to_image - Win32 Release"
|
||||
# Name "j2k_to_image - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\convert.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\convert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\compat\getopt.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\compat\getopt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\j2k_to_image.c
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,29 +1,44 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "image_to_j2k"=.\image_to_j2k.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "LibOpenJPEG"=..\LibOpenJPEG.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "j2k_to_image"=.\j2k_to_image.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name LibOpenJPEG
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
233
doc/Doxyfile.dox
Normal file
233
doc/Doxyfile.dox
Normal file
@@ -0,0 +1,233 @@
|
||||
# Doxyfile 1.4.2
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = OpenJPEG
|
||||
PROJECT_NUMBER =
|
||||
OUTPUT_DIRECTORY = ../
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
USE_WINDOWS_ENCODING = YES
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF = "The $name class" \
|
||||
"The $name widget" \
|
||||
"The $name file" \
|
||||
is \
|
||||
provides \
|
||||
specifies \
|
||||
contains \
|
||||
represents \
|
||||
a \
|
||||
an \
|
||||
the
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = NO
|
||||
STRIP_FROM_PATH = C://
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = YES
|
||||
INHERIT_DOCS = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 8
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
SUBGROUPING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = NO
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = NO
|
||||
FILE_VERSION_FILTER =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = ../libopenjpeg \
|
||||
../jpwl
|
||||
FILE_PATTERNS = *.h \
|
||||
*.c
|
||||
RECURSIVE = NO
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS = *
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
VERBATIM_HEADERS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = NO
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = ./html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = NO
|
||||
TREEVIEW_WIDTH = 250
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = NO
|
||||
USE_PDFLATEX = NO
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED = USE_JPWL
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = NO
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
MAX_DOT_GRAPH_DEPTH = 1000
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
||||
23
indexer_JPIP/Makefile
Normal file
23
indexer_JPIP/Makefile
Normal file
@@ -0,0 +1,23 @@
|
||||
CC = gcc
|
||||
|
||||
LDFLAGS = -lm
|
||||
CFLAGS = -Wall
|
||||
|
||||
all: index_create
|
||||
|
||||
|
||||
bio.o : bio.c bio.h
|
||||
cio.o : cio.c cio.h
|
||||
int.o : int.c
|
||||
pi.o : pi.c pi.h int.h
|
||||
index_create.o : index_create.c j2k.h cio.h tcd.h int.h
|
||||
t2.o : t2.c t2.h tcd.h bio.h j2k.h pi.h tgt.h int.h cio.h
|
||||
tgt.o : tgt.c bio.h tgt.h
|
||||
tcd.o : tcd.c tcd.h t2.h int.h
|
||||
jpip.o : jpip.c j2k.h cio.h tcd.h int.h
|
||||
jp2.o : jp2.c j2k.h cio.h tcd.h int.h
|
||||
|
||||
index_create : bio.o cio.o int.o pi.o t2.o tgt.o tcd.o index_create.o jpip.o jp2.o
|
||||
|
||||
clean:
|
||||
rm -rf *.o *.*~ *~ core.*
|
||||
125
indexer_JPIP/bio.c
Normal file
125
indexer_JPIP/bio.c
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003, Yannick Verschueren
|
||||
* Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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 "bio.h"
|
||||
#include <setjmp.h>
|
||||
|
||||
static unsigned char *bio_start, *bio_end, *bio_bp;
|
||||
static unsigned int bio_buf;
|
||||
static int bio_ct;
|
||||
|
||||
extern jmp_buf j2k_error;
|
||||
|
||||
/// <summary>
|
||||
/// Number of bytes written.
|
||||
/// </summary>
|
||||
int bio_numbytes() {
|
||||
return bio_bp-bio_start;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Init decoder.
|
||||
/// </summary>
|
||||
/// <param name="bp">Input buffer</param>
|
||||
/// <param name="len">Input buffer length</param>
|
||||
void bio_init_dec(unsigned char *bp, int len) {
|
||||
bio_start=bp;
|
||||
bio_end=bp+len;
|
||||
bio_bp=bp;
|
||||
bio_buf=0;
|
||||
bio_ct=0;
|
||||
}
|
||||
|
||||
int bio_byteout()
|
||||
{
|
||||
bio_buf = (bio_buf << 8) & 0xffff;
|
||||
bio_ct = bio_buf == 0xff00 ? 7 : 8;
|
||||
if (bio_bp >= bio_end)
|
||||
return 1;
|
||||
*bio_bp++ = bio_buf >> 8;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read byte.
|
||||
/// </summary>
|
||||
int bio_bytein() {
|
||||
bio_buf=(bio_buf<<8)&0xffff;
|
||||
bio_ct=bio_buf==0xff00?7:8;
|
||||
if (bio_bp>=bio_end) return 1; //longjmp(j2k_error, 1);
|
||||
bio_buf|=*bio_bp++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read bit.
|
||||
/// </summary>
|
||||
int bio_getbit() {
|
||||
if (bio_ct==0) {
|
||||
bio_bytein();
|
||||
}
|
||||
bio_ct--;
|
||||
return (bio_buf>>bio_ct)&1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read bits.
|
||||
/// </summary>
|
||||
/// <param name="n">Number of bits to read</param>
|
||||
int bio_read(int n) {
|
||||
int i, v;
|
||||
v=0;
|
||||
for (i=n-1; i>=0; i--) {
|
||||
v+=bio_getbit()<<i;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flush bits.
|
||||
/// </summary>
|
||||
int bio_flush() {
|
||||
bio_ct=0;
|
||||
bio_byteout();
|
||||
if (bio_ct==7) {
|
||||
bio_ct=0;
|
||||
if ( bio_byteout()) return 1;;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
int bio_inalign() {
|
||||
bio_ct=0;
|
||||
if ((bio_buf&0xff)==0xff) {
|
||||
if( bio_bytein()) return 1;
|
||||
bio_ct=0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
||||
* Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -24,10 +26,13 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __BIO_H
|
||||
#define __BIO_H
|
||||
|
||||
#ifndef __FIX_H
|
||||
#define __FIX_H
|
||||
|
||||
int fix_mul(int a, int b);
|
||||
int bio_numbytes();
|
||||
void bio_init_dec(unsigned char *bp, int len);
|
||||
int bio_read(int n);
|
||||
int bio_flush();
|
||||
int bio_inalign();
|
||||
|
||||
#endif
|
||||
129
indexer_JPIP/cio.c
Normal file
129
indexer_JPIP/cio.c
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003, Yannick Verschueren
|
||||
* Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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 "cio.h"
|
||||
#include <setjmp.h>
|
||||
|
||||
static unsigned char *cio_start, *cio_end, *cio_bp;
|
||||
|
||||
extern jmp_buf j2k_error;
|
||||
|
||||
/// <summary>
|
||||
/// Number of bytes written.
|
||||
/// </summary>
|
||||
int cio_numbytes() {
|
||||
return cio_bp-cio_start;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get position in byte stream.
|
||||
/// </summary>
|
||||
int cio_tell() {
|
||||
return cio_bp-cio_start;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set position in byte stream.
|
||||
/// </summary>
|
||||
void cio_seek(int pos) {
|
||||
cio_bp=cio_start+pos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of bytes left before the end of the stream.
|
||||
/// </summary>
|
||||
int cio_numbytesleft() {
|
||||
return cio_end-cio_bp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get pointer to the current position in the stream.
|
||||
/// </summary>
|
||||
unsigned char *cio_getbp() {
|
||||
return cio_bp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize byte IO.
|
||||
/// </summary>
|
||||
void cio_init(unsigned char *bp, int len) {
|
||||
cio_start=bp;
|
||||
cio_end=bp+len;
|
||||
cio_bp=bp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write a byte.
|
||||
/// </summary>
|
||||
void cio_byteout(unsigned char v) {
|
||||
if (cio_bp>=cio_end) longjmp(j2k_error, 1);
|
||||
*cio_bp++=v;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a byte.
|
||||
/// </summary>
|
||||
unsigned char cio_bytein() {
|
||||
if (cio_bp>=cio_end) longjmp(j2k_error, 1);
|
||||
return *cio_bp++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write a byte.
|
||||
/// </summary>
|
||||
//void cio_write(unsigned int v, int n) {
|
||||
void cio_write(long long v, int n) {
|
||||
int i;
|
||||
for (i=n-1; i>=0; i--)
|
||||
{
|
||||
cio_byteout((unsigned char)((v>>(i<<3))&0xff));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read some bytes.
|
||||
/// </summary>
|
||||
/* unsigned int cio_read(int n) { */
|
||||
long long cio_read(int n) {
|
||||
int i;
|
||||
/*unsigned int v;*/
|
||||
long long v;
|
||||
v=0;
|
||||
for (i=n-1; i>=0; i--) {
|
||||
v+=cio_bytein()<<(i<<3);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write some bytes.
|
||||
/// </summary>
|
||||
void cio_skip(int n) {
|
||||
cio_bp+=n;
|
||||
}
|
||||
44
indexer_JPIP/cio.h
Normal file
44
indexer_JPIP/cio.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
||||
* Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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 __CIO_H
|
||||
#define __CIO_H
|
||||
|
||||
int cio_tell();
|
||||
void cio_seek(int pos);
|
||||
int cio_numbytes();
|
||||
int cio_numbytesleft();
|
||||
unsigned char *cio_getbp();
|
||||
void cio_init(unsigned char *bp, int len);
|
||||
/* void cio_write(unsigned int v, int n); */
|
||||
void cio_write(long long v, int n);
|
||||
/* unsigned int cio_read(int n); */
|
||||
long long cio_read(int n);
|
||||
void cio_skip(int n);
|
||||
|
||||
#endif
|
||||
@@ -26,24 +26,17 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __OPENJPEG_H
|
||||
#define __OPENJPEG_H
|
||||
|
||||
#include <j2k.h>
|
||||
#include <tcd.h>
|
||||
#include <jp2.h>
|
||||
|
||||
#include <bio.h>
|
||||
#include <cio.h>
|
||||
#include <dwt.h>
|
||||
#include <fix.h>
|
||||
#include <int.h>
|
||||
#include <mct.h>
|
||||
#include <mqc.h>
|
||||
#include <pi.h>
|
||||
#include <raw.h>
|
||||
#include <t1.h>
|
||||
#include <t2.h>
|
||||
#include <tgt.h>
|
||||
#include "fix.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#define int64 __int64
|
||||
#else
|
||||
#define int64 long long
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Multiply two fixed-precision rational numbers.
|
||||
/// </summary>
|
||||
int fix_mul(int a, int b) {
|
||||
return (int)((int64)a*(int64)b>>13);
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003, Yannick Verschueren
|
||||
* Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -24,7 +26,6 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __FIX_H
|
||||
#define __FIX_H
|
||||
|
||||
1218
indexer_JPIP/index_create.c
Normal file
1218
indexer_JPIP/index_create.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003, Yannick Verschueren
|
||||
* Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -26,50 +26,64 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __BIO_H
|
||||
#define __BIO_H
|
||||
/// <summary>
|
||||
/// Get the minimum of two integers.
|
||||
/// </summary>
|
||||
int int_min(int a, int b) {
|
||||
return a<b?a:b;
|
||||
}
|
||||
|
||||
/*
|
||||
* Number of bytes written.
|
||||
*/
|
||||
int bio_numbytes();
|
||||
/// <summary>
|
||||
/// Get the maximum of two integers.
|
||||
/// </summary>
|
||||
int int_max(int a, int b) {
|
||||
return a>b?a:b;
|
||||
}
|
||||
|
||||
/*
|
||||
* Init encoder.
|
||||
*
|
||||
* bp : Output buffer
|
||||
* len : Output buffer length
|
||||
*/
|
||||
void bio_init_enc(unsigned char *bp, int len);
|
||||
/// <summary>
|
||||
/// Clamp an integer inside an interval.
|
||||
/// </summary>
|
||||
int int_clamp(int a, int min, int max) {
|
||||
if (a<min) return min;
|
||||
if (a>max) return max;
|
||||
return a;
|
||||
}
|
||||
|
||||
/*
|
||||
* Init decoder.
|
||||
*
|
||||
* bp : Input buffer
|
||||
* len : Input buffer length
|
||||
*/
|
||||
void bio_init_dec(unsigned char *bp, int len);
|
||||
/// <summary>
|
||||
/// Get absolute value of integer.
|
||||
/// </summary>
|
||||
int int_abs(int a) {
|
||||
return a<0?-a:a;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write bits.
|
||||
*
|
||||
* v : Value of bits
|
||||
* n : Number of bits to write
|
||||
*/
|
||||
void bio_write(int v, int n);
|
||||
/// <summary>
|
||||
/// Divide an integer and round upwards.
|
||||
/// </summary>
|
||||
int int_ceildiv(int a, int b) {
|
||||
return (a+b-1)/b;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read bits.
|
||||
*
|
||||
* n : Number of bits to read
|
||||
*/
|
||||
int bio_read(int n);
|
||||
/// <summary>
|
||||
/// Divide an integer by a power of 2 and round upwards.
|
||||
/// </summary>
|
||||
int int_ceildivpow2(int a, int b) {
|
||||
return (a+(1<<b)-1)>>b;
|
||||
}
|
||||
|
||||
/*
|
||||
* Flush bits. Modified to eliminate longjmp !!
|
||||
*/
|
||||
int bio_flush();
|
||||
/// <summary>
|
||||
/// Divide an integer by a power of 2 and round downwards.
|
||||
/// </summary>
|
||||
int int_floordivpow2(int a, int b) {
|
||||
return a>>b;
|
||||
}
|
||||
|
||||
int bio_inalign(); /* modified to eliminated longjmp !! */
|
||||
|
||||
#endif
|
||||
/// <summary>
|
||||
/// Get logarithm of an integer and round downwards.
|
||||
/// </summary>
|
||||
int int_floorlog2(int a) {
|
||||
int l;
|
||||
for (l=0; a>1; l++) {
|
||||
a>>=1;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
41
indexer_JPIP/int.h
Normal file
41
indexer_JPIP/int.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003, Yannick Verschueren
|
||||
* Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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 __INT_H
|
||||
#define __INT_H
|
||||
|
||||
int int_min(int a, int b);
|
||||
int int_max(int a, int b);
|
||||
int int_clamp(int a, int min, int max);
|
||||
int int_abs(int a);
|
||||
int int_ceildiv(int a, int b);
|
||||
int int_ceildivpow2(int a, int b);
|
||||
int int_floordivpow2(int a, int b);
|
||||
int int_floorlog2(int a);
|
||||
|
||||
#endif
|
||||
288
indexer_JPIP/j2k.h
Normal file
288
indexer_JPIP/j2k.h
Normal file
@@ -0,0 +1,288 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
||||
* Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define VERSION "0.0.8"
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef LIBJ2K_EXPORTS
|
||||
#define LIBJ2K_API __declspec(dllexport)
|
||||
#else
|
||||
#define LIBJ2K_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define LIBJ2K_API
|
||||
#endif
|
||||
|
||||
#ifndef __J2K_H
|
||||
#define __J2K_H
|
||||
|
||||
#define J2K_MAXRLVLS 33
|
||||
#define J2K_MAXBANDS (3*J2K_MAXRLVLS+1)
|
||||
|
||||
#define J2K_CP_CSTY_PRT 0x01
|
||||
#define J2K_CP_CSTY_SOP 0x02
|
||||
#define J2K_CP_CSTY_EPH 0x04
|
||||
#define J2K_CCP_CSTY_PRT 0x01
|
||||
#define J2K_CCP_CBLKSTY_LAZY 0x01
|
||||
#define J2K_CCP_CBLKSTY_RESET 0x02
|
||||
#define J2K_CCP_CBLKSTY_TERMALL 0x04
|
||||
#define J2K_CCP_CBLKSTY_VSC 0x08
|
||||
#define J2K_CCP_CBLKSTY_PTERM 0x10
|
||||
#define J2K_CCP_CBLKSTY_SEGSYM 0x20
|
||||
#define J2K_CCP_QNTSTY_NOQNT 0
|
||||
#define J2K_CCP_QNTSTY_SIQNT 1
|
||||
#define J2K_CCP_QNTSTY_SEQNT 2
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int dx, dy; /* XRsiz, YRsiz */
|
||||
int prec; /* precision */
|
||||
int bpp; /* deapth of image in bits */
|
||||
int sgnd; /* signed */
|
||||
int *data; /* image-component data */
|
||||
} j2k_comp_t;
|
||||
|
||||
typedef struct {
|
||||
int version;
|
||||
int x0, y0; /* XOsiz, YOsiz */
|
||||
int x1, y1; /* Xsiz, Ysiz */
|
||||
int numcomps; /* number of components */
|
||||
int index_on; /* 0 = no index || 1 = index */
|
||||
j2k_comp_t *comps; /* image-components */
|
||||
} j2k_image_t;
|
||||
|
||||
typedef struct {
|
||||
int expn; /* exponent */
|
||||
int mant; /* mantissa */
|
||||
} j2k_stepsize_t;
|
||||
|
||||
typedef struct {
|
||||
int csty; /* coding style */
|
||||
int numresolutions; /* number of resolutions */
|
||||
int cblkw; /* width of code-blocks */
|
||||
int cblkh; /* height of code-blocks */
|
||||
int cblksty; /* code-block coding style */
|
||||
int qmfbid; /* discrete wavelet transform identifier */
|
||||
int qntsty; /* quantisation style */
|
||||
j2k_stepsize_t stepsizes[J2K_MAXBANDS]; /* stepsizes used for quantisation */
|
||||
int numgbits; /* number of guard bits */
|
||||
int roishift; /* Region of Interest shift */
|
||||
int prcw[J2K_MAXRLVLS]; /* Precinct width */
|
||||
int prch[J2K_MAXRLVLS]; /* Precinct height */
|
||||
} j2k_tccp_t;
|
||||
|
||||
typedef struct {
|
||||
int resno0, compno0;
|
||||
int layno1, resno1, compno1;
|
||||
int prg;
|
||||
int tile;
|
||||
char progorder[4];
|
||||
} j2k_poc_t;
|
||||
|
||||
typedef struct {
|
||||
int csty; /* coding style */
|
||||
int prg; /* progression order */
|
||||
int numlayers; /* number of layers */
|
||||
int mct; /* multi-component transform identifier */
|
||||
int rates[100]; /* rates of layers */
|
||||
int numpocs; /* number of progression order changes */
|
||||
int POC; /* Precise if a POC marker has been used O:NO, 1:YES */
|
||||
j2k_poc_t pocs[32]; /* progression order changes */
|
||||
unsigned char *ppt_data; /* packet header store there for futur use in t2_decode_packet */
|
||||
int ppt; /* If ppt == 1 --> there was a PPT marker for the present tile */
|
||||
int ppt_store; /* Use in case of multiple marker PPT (number of info already store) */
|
||||
j2k_tccp_t *tccps; /* tile-component coding parameters */
|
||||
} j2k_tcp_t;
|
||||
|
||||
typedef struct {
|
||||
int tx0, ty0; /* XTOsiz, YTOsiz */
|
||||
int tdx, tdy; /* XTsiz, YTsiz */
|
||||
int tw, th;
|
||||
unsigned char *ppm_data; /* packet header store there for futur use in t2_decode_packet */
|
||||
int ppm; /* If ppm == 1 --> there was a PPM marker for the present tile */
|
||||
int ppm_store; /* Use in case of multiple marker PPM (number of info already store) */
|
||||
int ppm_previous; /* Use in case of multiple marker PPM (case on non-finished previous info) */
|
||||
j2k_tcp_t *tcps; /* tile coding parameters */
|
||||
} j2k_cp_t;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Packet information : Layer level */
|
||||
typedef struct {
|
||||
int len; /* Length of the body of the packet */
|
||||
int len_header; /* Length of the header of the packet */
|
||||
int offset; /* Offset of the body of the packet */
|
||||
int offset_header; /* Offset of the header of the packet */
|
||||
} info_layer_t;
|
||||
|
||||
|
||||
/* Access to packet information : precinct level */
|
||||
typedef struct {
|
||||
info_layer_t *layer;
|
||||
} info_prec_t;
|
||||
|
||||
|
||||
/* Access to packet information : resolution level */
|
||||
typedef struct {
|
||||
info_prec_t *prec;
|
||||
} info_reso_t;
|
||||
|
||||
|
||||
/* Access to packet information : component level */
|
||||
typedef struct {
|
||||
info_reso_t *reso;
|
||||
} info_compo_t;
|
||||
|
||||
|
||||
/* Information about the marker */
|
||||
typedef struct {
|
||||
int type; /* type of marker [SIZ, QCD, POC, PPM, CRG, COD] appearing only once */
|
||||
int start_pos; /* Start position of the marker */
|
||||
int len; /* Length of the marker */
|
||||
} info_marker_t;
|
||||
|
||||
|
||||
/* Multiple marker in tile header */
|
||||
typedef struct{
|
||||
info_marker_t *COC; /* COC markers */
|
||||
int num_COC; /* Number of COC marker */
|
||||
int CzCOC; /* Current size of the vector COC */
|
||||
|
||||
info_marker_t *RGN; /* RGN markers */
|
||||
int num_RGN; /* Number of RGN marker */
|
||||
int CzRGN; /* Current size of the vector RGN */
|
||||
|
||||
info_marker_t *QCC; /* QCC markers */
|
||||
int num_QCC; /* Number of QCC marker */
|
||||
int CzQCC; /* Current size of the vector QCC */
|
||||
|
||||
info_marker_t *PLT; /* PLT markers */
|
||||
int num_PLT; /* Number of PLT marker */
|
||||
int CzPLT; /* Current size of the vector PLT */
|
||||
|
||||
info_marker_t *PPT; /* PPT markers */
|
||||
int num_PPT; /* Number of PPT marker */
|
||||
int CzPPT; /* Current size of the vector PPT */
|
||||
|
||||
info_marker_t *COM; /* COM markers */
|
||||
int num_COM; /* Number of COM marker */
|
||||
int CzCOM; /* Current size of the vector COC */
|
||||
} info_marker_mul_tile_t;
|
||||
|
||||
|
||||
/* Information about each tile_part for a particulary tile */
|
||||
typedef struct{
|
||||
int start_pos; /* Start position of the tile_part */
|
||||
int length; /* Length of the tile_part header + body */
|
||||
int length_header; /* Length of the header */
|
||||
int end_pos; /* End position of the tile part */
|
||||
int end_header; /* End position of the tile part header */
|
||||
|
||||
int num_reso_AUX; /* Number of resolution level completed */
|
||||
} info_tile_part_t;
|
||||
|
||||
|
||||
/* Information about each tile */
|
||||
typedef struct {
|
||||
int num_tile; /* Number of Tile */
|
||||
int pw, ph; /* number of precinct by tile */
|
||||
int num_packet; /* number of packet in the tile */
|
||||
info_compo_t *compo; /* component [packet] */
|
||||
|
||||
info_marker_t *marker; /* information concerning markers inside image [only one apparition] */
|
||||
info_marker_mul_tile_t marker_mul; /* information concerning markers inside image [multiple apparition] */
|
||||
int num_marker; /* number of marker */
|
||||
|
||||
int numparts; /* number of tile_part for this tile */
|
||||
info_tile_part_t *tile_parts; /* Information about each tile_part */
|
||||
int Cztile_parts; /* Current size of the tile_parts vector */
|
||||
} info_tile_t; /* index struct */
|
||||
|
||||
|
||||
/* Multiple marker in main header */
|
||||
typedef struct{
|
||||
info_marker_t *COC; /* COC markers */
|
||||
int num_COC; /* Number of COC marker */
|
||||
int CzCOC; /* Current size of the vector COC */
|
||||
|
||||
info_marker_t *RGN; /* RGN markers */
|
||||
int num_RGN; /* Number of RGN marker */
|
||||
int CzRGN; /* Current size of the vector RGN */
|
||||
|
||||
info_marker_t *QCC; /* QCC markers */
|
||||
int num_QCC; /* Number of QCC marker */
|
||||
int CzQCC; /* Current size of the vector QCC */
|
||||
|
||||
info_marker_t *TLM; /* TLM markers */
|
||||
int num_TLM; /* Number of TLM marker */
|
||||
int CzTLM; /* Current size of the vector TLM */
|
||||
|
||||
info_marker_t *PLM; /* PLM markers */
|
||||
int num_PLM; /* Number of PLM marker */
|
||||
int CzPLM; /* Current size of the vector PLM */
|
||||
|
||||
info_marker_t *PPM; /* PPM markers */
|
||||
int num_PPM; /* Number of PPM marker */
|
||||
int CzPPM; /* Current size of the vector PPM */
|
||||
|
||||
info_marker_t *COM; /* COM markers */
|
||||
int num_COM; /* Number of COM marker */
|
||||
int CzCOM; /* Current size of the vector COM */
|
||||
} info_marker_mul_t; /* index struct */
|
||||
|
||||
|
||||
/* Information about image */
|
||||
typedef struct {
|
||||
int Im_w, Im_h; /* Image width and Height */
|
||||
int Tile_x, Tile_y; /* Number of Tile in X and Y */
|
||||
int tw, th;
|
||||
int pw, ph; /* nombre precinct in X and Y */
|
||||
int pdx, pdy; /* size of precinct in X and Y */
|
||||
|
||||
int Prog; /* progression order */
|
||||
int Comp; /* Component numbers */
|
||||
int Layer; /* number of layer */
|
||||
int Decomposition; /* number of decomposition */
|
||||
|
||||
int Main_head_end; /* Main header position */
|
||||
int codestream_size; /* codestream's size */
|
||||
|
||||
info_marker_t *marker; /* information concerning markers inside image [only one apparition] */
|
||||
info_marker_mul_t marker_mul; /* information concerning markers inside image [multiple apparition] */
|
||||
int num_marker; /* number of marker */
|
||||
|
||||
int num_packet_max; /* Maximum number of packet */
|
||||
|
||||
int num_max_tile_parts; /* Maximum number of tile-part */
|
||||
info_tile_t *tile; /* information concerning tiles inside image */
|
||||
} info_image_t; /* index struct */
|
||||
|
||||
|
||||
#endif
|
||||
301
indexer_JPIP/jp2.c
Normal file
301
indexer_JPIP/jp2.c
Normal file
@@ -0,0 +1,301 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
||||
* Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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 "j2k.h"
|
||||
#include "cio.h"
|
||||
#include "tcd.h"
|
||||
#include "int.h"
|
||||
|
||||
#define JPIP_JPIP 0x6a706970
|
||||
|
||||
#define JP2_JP 0x6a502020
|
||||
#define JP2_FTYP 0x66747970
|
||||
#define JP2_JP2H 0x6a703268
|
||||
#define JP2_IHDR 0x69686472
|
||||
#define JP2_COLR 0x636f6c72
|
||||
#define JP2_JP2C 0x6a703263
|
||||
#define JP2_URL 0x75726c20
|
||||
#define JP2_DBTL 0x6474626c
|
||||
#define JP2_BPCC 0x62706363
|
||||
#define JP2 0x6a703220
|
||||
|
||||
|
||||
void jp2_write_url(char *Idx_file)
|
||||
{
|
||||
int len, lenp, i;
|
||||
char str[256];
|
||||
|
||||
sprintf(str, "%s", Idx_file);
|
||||
lenp=cio_tell();
|
||||
cio_skip(4);
|
||||
cio_write(JP2_URL, 4); // DBTL
|
||||
cio_write(0,1); // VERS
|
||||
cio_write(0,3); // FLAG
|
||||
|
||||
for (i=0; i<strlen(str); i++) {
|
||||
cio_write(str[i], 1);
|
||||
}
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len,4); // L
|
||||
cio_seek(lenp+len);
|
||||
}
|
||||
|
||||
void jp2_write_dbtl(char *Idx_file)
|
||||
{
|
||||
int len, lenp;
|
||||
|
||||
lenp=cio_tell();
|
||||
cio_skip(4);
|
||||
cio_write(JP2_DBTL, 4); // DBTL
|
||||
cio_write(1,2); // NDR : Only 1
|
||||
|
||||
jp2_write_url(Idx_file); // URL Box
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len,4); // L
|
||||
cio_seek(lenp+len);
|
||||
}
|
||||
|
||||
int jp2_write_ihdr(j2k_image_t *j2k_img)
|
||||
{
|
||||
int len, lenp,i;
|
||||
int depth_0,depth, sign, BPC_ok=1;
|
||||
|
||||
lenp=cio_tell();
|
||||
cio_skip(4);
|
||||
cio_write(JP2_IHDR, 4); // IHDR
|
||||
|
||||
cio_write(j2k_img->y1-j2k_img->x0,4); // HEIGHT
|
||||
cio_write(j2k_img->x1-j2k_img->x0,4); // WIDTH
|
||||
cio_write(j2k_img->numcomps,2); // NC
|
||||
|
||||
depth_0=j2k_img->comps[0].prec-1;
|
||||
sign=j2k_img->comps[0].sgnd;
|
||||
|
||||
for(i=1;i<j2k_img->numcomps;i++)
|
||||
{
|
||||
depth=j2k_img->comps[i].prec-1;
|
||||
sign=j2k_img->comps[i].sgnd;
|
||||
if(depth_0!=depth) BPC_ok=0;
|
||||
}
|
||||
|
||||
if (BPC_ok)
|
||||
cio_write(depth_0+(sign<<7),1);
|
||||
else
|
||||
cio_write(255,1);
|
||||
|
||||
cio_write(7,1); // C : Always 7
|
||||
cio_write(1,1); // UnkC, colorspace unknow
|
||||
cio_write(0,1); // IPR, no intellectual property
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len,4); // L
|
||||
cio_seek(lenp+len);
|
||||
|
||||
return BPC_ok;
|
||||
}
|
||||
|
||||
void jp2_write_bpcc(j2k_image_t *j2k_img)
|
||||
{
|
||||
int len, lenp, i;
|
||||
|
||||
lenp=cio_tell();
|
||||
cio_skip(4);
|
||||
cio_write(JP2_BPCC, 4); // BPCC
|
||||
|
||||
for(i=0;i<j2k_img->numcomps;i++)
|
||||
cio_write(j2k_img->comps[i].prec-1+(j2k_img->comps[i].sgnd<<7),1);
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len,4); // L
|
||||
cio_seek(lenp+len);
|
||||
}
|
||||
|
||||
void jp2_write_colr(int BPC_ok, j2k_image_t *j2k_img)
|
||||
{
|
||||
int len, lenp, meth;
|
||||
|
||||
lenp=cio_tell();
|
||||
cio_skip(4);
|
||||
cio_write(JP2_COLR, 4); // COLR
|
||||
|
||||
if ((j2k_img->numcomps==1 || j2k_img->numcomps==3) && (BPC_ok && j2k_img->comps[0].prec==8))
|
||||
meth=1;
|
||||
else
|
||||
meth=2;
|
||||
|
||||
cio_write(meth,1); // METH
|
||||
cio_write(0,1); // PREC
|
||||
cio_write(0,1); // APPROX
|
||||
|
||||
if (meth==1)
|
||||
cio_write(j2k_img->numcomps>1?16:17,4); // EnumCS
|
||||
|
||||
if (meth==2)
|
||||
cio_write(0,1); // PROFILE (??)
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len,4); // L
|
||||
cio_seek(lenp+len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the JP2H box
|
||||
*
|
||||
* JP2 Header box
|
||||
*
|
||||
*/
|
||||
void jp2_write_jp2h(j2k_image_t *j2k_img)
|
||||
{
|
||||
int len, lenp, BPC_ok;
|
||||
|
||||
lenp=cio_tell();
|
||||
cio_skip(4);
|
||||
cio_write(JP2_JP2H, 4); /* JP2H */
|
||||
|
||||
BPC_ok=jp2_write_ihdr(j2k_img);
|
||||
|
||||
if (!BPC_ok)
|
||||
jp2_write_bpcc(j2k_img);
|
||||
jp2_write_colr(BPC_ok, j2k_img);
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len,4); /* L */
|
||||
cio_seek(lenp+len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the FTYP box
|
||||
*
|
||||
* File type box
|
||||
*
|
||||
*/
|
||||
void jp2_write_ftyp()
|
||||
{
|
||||
int len, lenp;
|
||||
|
||||
lenp=cio_tell();
|
||||
cio_skip(4);
|
||||
cio_write(JP2_FTYP, 4); /* FTYP */
|
||||
|
||||
cio_write(JP2,4); /* BR */
|
||||
cio_write(0,4); /* MinV */
|
||||
cio_write(JP2,4); /* CL0 : JP2 */
|
||||
cio_write(JPIP_JPIP,4); /* CL1 : JPIP */
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len,4); /* L */
|
||||
cio_seek(lenp+len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the FTYP box
|
||||
*
|
||||
* File type box
|
||||
*
|
||||
*/
|
||||
void jp2_read_ftyp(int length)
|
||||
{
|
||||
int BR, MinV, type, i;
|
||||
|
||||
BR = cio_read(4); /* BR */
|
||||
MinV = cio_read(4); /* MinV */
|
||||
length-=8;
|
||||
|
||||
for (i=length/4;i>0;i--)
|
||||
type = cio_read(4); /* CLi : JP2, JPIP */
|
||||
}
|
||||
|
||||
int jp2_write_jp2c(char *J2K_file)
|
||||
{
|
||||
int len, lenp, totlen, i;
|
||||
FILE *src;
|
||||
char *j2kfile;
|
||||
|
||||
lenp=cio_tell();
|
||||
cio_skip(4);
|
||||
cio_write(JP2_JP2C, 4); // JP2C
|
||||
|
||||
src=fopen(J2K_file, "rb");
|
||||
fseek(src, 0, SEEK_END);
|
||||
totlen=ftell(src);
|
||||
fseek(src, 0, SEEK_SET);
|
||||
|
||||
j2kfile=(char*)malloc(totlen);
|
||||
fread(j2kfile, 1, totlen, src);
|
||||
fclose(src);
|
||||
|
||||
for (i=0;i<totlen;i++)
|
||||
cio_write(j2kfile[i],1);
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len,4); // L
|
||||
cio_seek(lenp+len);
|
||||
return lenp;
|
||||
}
|
||||
|
||||
void jp2_write_jp()
|
||||
{
|
||||
int len, lenp;
|
||||
|
||||
lenp=cio_tell();
|
||||
cio_skip(4);
|
||||
cio_write(JP2_JP, 4); // JP
|
||||
cio_write(0x0d0a870a,4);
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len,4); // L
|
||||
cio_seek(lenp+len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the JP box
|
||||
*
|
||||
* JPEG 2000 signature
|
||||
*
|
||||
* return 1 if error else 0
|
||||
*/
|
||||
int jp2_read_jp()
|
||||
{
|
||||
if (0x0d0a870a!=cio_read(4))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003, Yannick Verschueren
|
||||
* Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* All rights reserved.
|
||||
@@ -25,26 +24,21 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __JP2_H
|
||||
#define __JP2_H
|
||||
|
||||
#ifndef __OPENJPEG_H
|
||||
#define __OPENJPEG_H
|
||||
#include "j2k.h"
|
||||
|
||||
#include <j2k.h>
|
||||
#include <tcd.h>
|
||||
#include <jp2.h>
|
||||
#include <jpw.h>
|
||||
void jp2_write_url(char *Idx_file);
|
||||
|
||||
#include <bio.h>
|
||||
#include <cio.h>
|
||||
#include <dwt.h>
|
||||
#include <fix.h>
|
||||
#include <int.h>
|
||||
#include <mct.h>
|
||||
#include <mqc.h>
|
||||
#include <pi.h>
|
||||
#include <raw.h>
|
||||
#include <t1.h>
|
||||
#include <t2.h>
|
||||
#include <tgt.h>
|
||||
void jp2_write_dbtl(char *Idx_file);
|
||||
|
||||
void jp2_write_jp2h(j2k_image_t *j2k_img);
|
||||
|
||||
void jp2_write_ftyp();
|
||||
|
||||
int jp2_write_jp2c(char *J2K_file);
|
||||
|
||||
void jp2_write_jp();
|
||||
|
||||
#endif
|
||||
768
indexer_JPIP/jpip.c
Normal file
768
indexer_JPIP/jpip.c
Normal file
@@ -0,0 +1,768 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
||||
* Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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 <setjmp.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "j2k.h"
|
||||
#include "cio.h"
|
||||
#include "tcd.h"
|
||||
#include "int.h"
|
||||
|
||||
#define JPIP_CIDX 0x63696478 /* Codestream index */
|
||||
#define JPIP_CPTR 0x63707472 /* Codestream Finder Box */
|
||||
#define JPIP_MANF 0x6d616e66 /* Manifest Box */
|
||||
#define JPIP_FAIX 0x66616978 /* Fragment array Index box */
|
||||
#define JPIP_MHIX 0x6d686978 /* Main Header Index Table */
|
||||
#define JPIP_TPIX 0x74706978 /* Tile-part Index Table box */
|
||||
#define JPIP_THIX 0x74686978 /* Tile header Index Table box */
|
||||
#define JPIP_PPIX 0x70706978 /* Precinct Packet Index Table box */
|
||||
#define JPIP_PHIX 0x70686978 /* Packet Header index Table */
|
||||
#define JPIP_FIDX 0x66696478 /* File Index */
|
||||
#define JPIP_FPTR 0x66707472 /* File Finder */
|
||||
#define JPIP_PRXY 0x70727879 /* Proxy boxes */
|
||||
#define JPIP_IPTR 0x69707472 /* Index finder box */
|
||||
#define JPIP_PHLD 0x70686c64 /* Place holder */
|
||||
|
||||
#define JP2C 0x6a703263
|
||||
|
||||
//static info_marker_t marker_jpip[32], marker_local_jpip[32]; /* SIZE to precise ! */
|
||||
//static int num_marker_jpip, num_marker_local_jpip;
|
||||
|
||||
/*
|
||||
* Write the CPTR box
|
||||
*
|
||||
* Codestream finder box (box)
|
||||
*
|
||||
*/
|
||||
void jpip_write_cptr(int offset, info_image_t img)
|
||||
{
|
||||
int len, lenp;
|
||||
|
||||
lenp=cio_tell();
|
||||
cio_skip(4); /* L [at the end] */
|
||||
cio_write(JPIP_CPTR,4); /* T */
|
||||
cio_write(0,2); /* DR A PRECISER !! */
|
||||
cio_write(0,2); /* CONT */
|
||||
cio_write(offset,8); /* COFF A PRECISER !! */
|
||||
cio_write(img.codestream_size,8); /* CLEN */
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len, 4); /* L */
|
||||
cio_seek(lenp+len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the CPTR box
|
||||
*
|
||||
* Codestream finder box (box)
|
||||
*
|
||||
*/
|
||||
void jpip_read_cptr()
|
||||
{
|
||||
int DR, CONT;
|
||||
long long Coff, codestream_size;
|
||||
|
||||
DR = cio_read(2); /* DR */
|
||||
CONT = cio_read(2); /* CONT */
|
||||
Coff = cio_read(8); /* COFF */
|
||||
codestream_size = cio_read(8); /* CLEN */
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the MANF box
|
||||
*
|
||||
* Manifest box (box)
|
||||
*
|
||||
*/
|
||||
void jpip_write_manf(int second, int v, info_marker_t *marker)
|
||||
{
|
||||
int len, lenp, i;
|
||||
lenp=cio_tell();
|
||||
cio_skip(4); /* L [at the end] */
|
||||
cio_write(JPIP_MANF,4); /* T */
|
||||
|
||||
if (second) /* Write only during the second pass */
|
||||
{
|
||||
for(i=0;i<v;i++)
|
||||
{
|
||||
cio_write(marker[i].len,4); /* Marker length */
|
||||
cio_write(marker[i].type,4); /* Marker type */
|
||||
}
|
||||
}
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len, 4); /* L */
|
||||
cio_seek(lenp+len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the MANF box
|
||||
*
|
||||
* Manifest box (box)
|
||||
*
|
||||
*/
|
||||
void jpip_read_manf(int len)
|
||||
{
|
||||
int i, v, marker_len, marker_type;
|
||||
|
||||
v = (len - 8)/ 8;
|
||||
|
||||
for(i=0;i<v;i++)
|
||||
{
|
||||
marker_len = cio_read(4); /* Marker length */
|
||||
marker_type = cio_read(4); /* Marker type */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the MHIX box
|
||||
*
|
||||
* Main Header Index Table (box)
|
||||
*
|
||||
*/
|
||||
int jpip_write_mhix(info_image_t img, int status, int tileno)
|
||||
{
|
||||
int len, lenp, i;
|
||||
info_tile_t *tile;
|
||||
lenp=cio_tell();
|
||||
cio_skip(4); /* L [at the end] */
|
||||
cio_write(JPIP_MHIX, 4); /* MHIX */
|
||||
|
||||
if (status) /* MAIN HEADER */
|
||||
{
|
||||
cio_write(img.Main_head_end,8); /* TLEN */
|
||||
|
||||
for(i = 0; i < img.num_marker; i++) /* Marker restricted to 1 apparition */
|
||||
{
|
||||
cio_write(img.marker[i].type, 2);
|
||||
cio_write(0, 2);
|
||||
cio_write(img.marker[i].start_pos, 8);
|
||||
cio_write(img.marker[i].len, 2);
|
||||
}
|
||||
|
||||
/* Marker NOT restricted to 1 apparition */
|
||||
for(i = img.marker_mul.num_COC - 1; i >= 0; i--) /* COC */
|
||||
{
|
||||
cio_write(img.marker_mul.COC[i].type, 2);
|
||||
cio_write(i, 2);
|
||||
cio_write(img.marker_mul.COC[i].start_pos, 8);
|
||||
cio_write(img.marker_mul.COC[i].len, 2);
|
||||
}
|
||||
|
||||
for(i = img.marker_mul.num_RGN - 1; i >= 0; i--) /* RGN */
|
||||
{
|
||||
cio_write(img.marker_mul.RGN[i].type, 2);
|
||||
cio_write(i, 2);
|
||||
cio_write(img.marker_mul.RGN[i].start_pos, 8);
|
||||
cio_write(img.marker_mul.RGN[i].len, 2);
|
||||
}
|
||||
|
||||
for(i = img.marker_mul.num_QCC - 1; i >= 0; i--) /* QCC */
|
||||
{
|
||||
cio_write(img.marker_mul.QCC[i].type, 2);
|
||||
cio_write(i, 2);
|
||||
cio_write(img.marker_mul.QCC[i].start_pos, 8);
|
||||
cio_write(img.marker_mul.QCC[i].len, 2);
|
||||
}
|
||||
|
||||
for(i = img.marker_mul.num_TLM - 1; i >= 0; i--) /* TLM */
|
||||
{
|
||||
cio_write(img.marker_mul.TLM[i].type, 2);
|
||||
cio_write(i, 2);
|
||||
cio_write(img.marker_mul.TLM[i].start_pos, 8);
|
||||
cio_write(img.marker_mul.TLM[i].len, 2);
|
||||
}
|
||||
|
||||
for(i = img.marker_mul.num_PLM - 1; i >= 0; i--) /* PLM */
|
||||
{
|
||||
cio_write(img.marker_mul.PLM[i].type, 2);
|
||||
cio_write(i, 2);
|
||||
cio_write(img.marker_mul.PLM[i].start_pos, 8);
|
||||
cio_write(img.marker_mul.PLM[i].len, 2);
|
||||
}
|
||||
|
||||
for(i = img.marker_mul.num_PPM - 1; i >= 0; i--) /* PPM */
|
||||
{
|
||||
cio_write(img.marker_mul.PPM[i].type, 2);
|
||||
cio_write(i, 2);
|
||||
cio_write(img.marker_mul.PPM[i].start_pos, 8);
|
||||
cio_write(img.marker_mul.PPM[i].len, 2);
|
||||
}
|
||||
|
||||
for(i = img.marker_mul.num_COM - 1; i >= 0; i--) /* COM */
|
||||
{
|
||||
cio_write(img.marker_mul.COM[i].type, 2);
|
||||
cio_write(i, 2);
|
||||
cio_write(img.marker_mul.COM[i].start_pos, 8);
|
||||
cio_write(img.marker_mul.COM[i].len, 2);
|
||||
}
|
||||
}
|
||||
else /* TILE HEADER */
|
||||
{
|
||||
tile = &img.tile[tileno];
|
||||
cio_write(tile->tile_parts[0].length_header, 8); /* TLEN */
|
||||
|
||||
for(i = 0; i < tile->num_marker; i++) /* Marker restricted to 1 apparition */
|
||||
{
|
||||
cio_write(tile->marker[i].type, 2);
|
||||
cio_write(0, 2);
|
||||
cio_write(tile->marker[i].start_pos, 8);
|
||||
cio_write(tile->marker[i].len, 2);
|
||||
}
|
||||
|
||||
/* Marker NOT restricted to 1 apparition */
|
||||
for(i = tile->marker_mul.num_COC - 1; i >= 0; i--) /* COC */
|
||||
{
|
||||
cio_write(tile->marker_mul.COC[i].type, 2);
|
||||
cio_write(i, 2);
|
||||
cio_write(tile->marker_mul.COC[i].start_pos, 8);
|
||||
cio_write(tile->marker_mul.COC[i].len, 2);
|
||||
}
|
||||
|
||||
for(i = tile->marker_mul.num_RGN - 1; i >= 0; i--) /* RGN */
|
||||
{
|
||||
cio_write(tile->marker_mul.RGN[i].type, 2);
|
||||
cio_write(i, 2);
|
||||
cio_write(tile->marker_mul.RGN[i].start_pos, 8);
|
||||
cio_write(tile->marker_mul.RGN[i].len, 2);
|
||||
}
|
||||
|
||||
for(i = tile->marker_mul.num_QCC - 1; i >= 0; i--) /* QCC */
|
||||
{
|
||||
cio_write(tile->marker_mul.QCC[i].type, 2);
|
||||
cio_write(i, 2);
|
||||
cio_write(tile->marker_mul.QCC[i].start_pos, 8);
|
||||
cio_write(tile->marker_mul.QCC[i].len, 2);
|
||||
}
|
||||
|
||||
for(i = tile->marker_mul.num_PLT - 1; i >= 0; i--) /* PLT */
|
||||
{
|
||||
cio_write(tile->marker_mul.PLT[i].type,2);
|
||||
cio_write(i,2);
|
||||
cio_write(tile->marker_mul.PLT[i].start_pos,8);
|
||||
cio_write(tile->marker_mul.PLT[i].len,2);
|
||||
}
|
||||
|
||||
for(i = tile->marker_mul.num_PPT - 1; i >= 0; i--) /* PPT */
|
||||
{
|
||||
cio_write(tile->marker_mul.PPT[i].type, 2);
|
||||
cio_write(i, 2);
|
||||
cio_write(tile->marker_mul.PPT[i].start_pos, 8);
|
||||
cio_write(tile->marker_mul.PPT[i].len, 2);
|
||||
}
|
||||
|
||||
for(i = tile->marker_mul.num_COM - 1; i >= 0; i--) /* COM */
|
||||
{
|
||||
cio_write(tile->marker_mul.COM[i].type, 2);
|
||||
cio_write(i, 2);
|
||||
cio_write(tile->marker_mul.COM[i].start_pos, 8);
|
||||
cio_write(tile->marker_mul.COM[i].len, 2);
|
||||
}
|
||||
}
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len, 4); /* L */
|
||||
cio_seek(lenp+len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the MHIX box
|
||||
*
|
||||
* Main Header Index Table (box)
|
||||
*
|
||||
*/
|
||||
void jpip_read_mhix(int len)
|
||||
{
|
||||
int i, v, marker_type, marker_start_pos, marker_len, marker_remains;
|
||||
|
||||
v = (len - 8) / 14;
|
||||
|
||||
for (i=0; i<v ; i++)
|
||||
{
|
||||
marker_type = cio_read(2); /* Type of the marker */
|
||||
marker_remains = cio_read(2); /* Number of same markers following */
|
||||
marker_start_pos = cio_read(2); /* Start position of the marker */
|
||||
marker_len = cio_read(2); /* Length of the marker */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the FAIX box
|
||||
*
|
||||
* Fragment array Index box (box)
|
||||
*
|
||||
*/
|
||||
int jpip_write_faix(int v, int compno, info_image_t img, j2k_cp_t *j2k_cp, int version)
|
||||
{
|
||||
int len, lenp, i, j;
|
||||
/*int version = 0;*/
|
||||
int tileno, resno, precno, layno, num_packet=0;
|
||||
|
||||
lenp=cio_tell();
|
||||
cio_skip(4); /* L [at the end] */
|
||||
cio_write(JPIP_FAIX, 4); /* FAIX */
|
||||
cio_write(version,1); /* Version 0 = 4 bytes */
|
||||
|
||||
switch(v)
|
||||
{
|
||||
case 0: /* TPIX */
|
||||
cio_write(img.num_max_tile_parts,(version & 0x01)?8:4); /* NMAX */
|
||||
cio_write(img.tw*img.th,(version & 0x01)?8:4); /* M */
|
||||
for (i = 0; i < img.tw*img.th; i++)
|
||||
{
|
||||
for (j = 0; j < img.tile[i].numparts ; j++)
|
||||
{
|
||||
cio_write(img.tile[i].tile_parts[j].start_pos,(version & 0x01)?8:4); /* start position */
|
||||
cio_write(img.tile[i].tile_parts[j].length,(version & 0x01)?8:4); /* length */
|
||||
if (version & 0x02)
|
||||
cio_write(img.tile[i].tile_parts[j].num_reso_AUX,4); /* Aux_i,j : Auxiliary value */
|
||||
//cio_write(0,4);
|
||||
}
|
||||
/* PADDING */
|
||||
while (j < img.num_max_tile_parts)
|
||||
{
|
||||
cio_write(0,(version & 0x01)?8:4); /* start position */
|
||||
cio_write(0,(version & 0x01)?8:4); /* length */
|
||||
if (version & 0x02)
|
||||
cio_write(0,4); /* Aux_i,j : Auxiliary value */
|
||||
j++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* case 1: */ /* THIX */
|
||||
/* cio_write(1,(version & 0x01)?8:4); */ /* NMAX */
|
||||
/* cio_write(img.tw*img.th,(version & 0x01)?8:4); */ /* M */
|
||||
/* for (i=0;i<img.tw*img.th;i++) */
|
||||
/* { */
|
||||
/* cio_write(img.tile[i].start_pos,(version & 0x01)?8:4); */ /* start position */
|
||||
/* cio_write(img.tile[i].end_header-img.tile[i].start_pos,(version & 0x01)?8:4); */ /* length */
|
||||
/* if (version & 0x02)*/
|
||||
/* cio_write(0,4); */ /* Aux_i,j : Auxiliary value */
|
||||
/* } */
|
||||
/* break; */
|
||||
|
||||
case 2: /* PPIX NOT FINISHED !! */
|
||||
cio_write(img.num_packet_max,(version & 0x01)?8:4); /* NMAX */
|
||||
cio_write(img.tw*img.th,(version & 0x01)?8:4); /* M */
|
||||
for(tileno=0;tileno<img.tw*img.th;tileno++)
|
||||
{
|
||||
info_tile_t *tile_Idx = &img.tile[tileno];
|
||||
info_compo_t *compo_Idx = &tile_Idx->compo[compno];
|
||||
int correction;
|
||||
|
||||
num_packet=0;
|
||||
|
||||
if(j2k_cp->tcps[tileno].csty&J2K_CP_CSTY_EPH)
|
||||
correction=3;
|
||||
else
|
||||
correction=1;
|
||||
for(resno=0;resno<img.Decomposition+1;resno++)
|
||||
{
|
||||
info_reso_t *reso_Idx = &compo_Idx->reso[resno];
|
||||
for (precno=0;precno<img.tile[tileno].pw*img.tile[tileno].ph;precno++)
|
||||
{
|
||||
info_prec_t *prec_Idx = &reso_Idx->prec[precno];
|
||||
for(layno=0;layno<img.Layer;layno++)
|
||||
{
|
||||
info_layer_t *layer_Idx = &prec_Idx->layer[layno];
|
||||
cio_write(layer_Idx->offset,(version & 0x01)?8:4); /* start position */
|
||||
cio_write((layer_Idx->len_header-correction)?0:layer_Idx->len,(version & 0x01)?8:4); /* length */
|
||||
if (version & 0x02)
|
||||
cio_write(0,4); /* Aux_i,j : Auxiliary value */
|
||||
num_packet++;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* PADDING */
|
||||
while (num_packet < img.num_packet_max)
|
||||
{
|
||||
cio_write(0,(version & 0x01)?8:4); /* start position */
|
||||
cio_write(0,(version & 0x01)?8:4); /* length */
|
||||
if (version & 0x02)
|
||||
cio_write(0,4); /* Aux_i,j : Auxiliary value */
|
||||
num_packet++;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 3: /* PHIX NOT FINISHED !! */
|
||||
cio_write(img.num_packet_max,(version & 0x01)?8:4); /* NMAX */
|
||||
cio_write(img.tw*img.th,(version & 0x01)?8:4); /* M */
|
||||
for(tileno=0;tileno<img.tw*img.th;tileno++)
|
||||
{
|
||||
info_tile_t *tile_Idx = &img.tile[tileno];
|
||||
info_compo_t *compo_Idx = &tile_Idx->compo[compno];
|
||||
int correction;
|
||||
|
||||
num_packet = 0;
|
||||
if(j2k_cp->tcps[tileno].csty&J2K_CP_CSTY_EPH)
|
||||
correction=3;
|
||||
else
|
||||
correction=1;
|
||||
for(resno=0;resno<img.Decomposition+1;resno++)
|
||||
{
|
||||
info_reso_t *reso_Idx = &compo_Idx->reso[resno];
|
||||
for (precno=0;precno<img.tile[tileno].pw*img.tile[tileno].ph;precno++)
|
||||
{
|
||||
info_prec_t *prec_Idx = &reso_Idx->prec[precno];
|
||||
for(layno=0;layno<img.Layer;layno++)
|
||||
{
|
||||
info_layer_t *layer_Idx = &prec_Idx->layer[layno];
|
||||
cio_write(layer_Idx->offset_header,(version & 0x01)?8:4); /* start position */
|
||||
cio_write((layer_Idx->len_header-correction)?0:layer_Idx->len_header,(version & 0x01)?8:4); /* length */
|
||||
if (version & 0x02)
|
||||
cio_write(0,4); /* Aux_i,j : Auxiliary value */
|
||||
num_packet++;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* PADDING */
|
||||
while (num_packet<img.num_packet_max)
|
||||
{
|
||||
cio_write(0,(version & 0x01)?8:4); /* start position */
|
||||
cio_write(0,(version & 0x01)?8:4); /* length */
|
||||
if (version & 0x02)
|
||||
cio_write(0,4); /* Aux_i,j : Auxiliary value */
|
||||
num_packet++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len, 4); /* L */
|
||||
cio_seek(lenp+len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the TPIX box
|
||||
*
|
||||
* Tile-part Index table box (superbox)
|
||||
*
|
||||
*/
|
||||
int jpip_write_tpix(info_image_t img, j2k_cp_t *j2k_cp, int version)
|
||||
{
|
||||
int len, lenp;
|
||||
lenp=cio_tell();
|
||||
cio_skip(4); /* L [at the end] */
|
||||
cio_write(JPIP_TPIX, 4); /* TPIX */
|
||||
|
||||
jpip_write_faix(0,0,img, j2k_cp, version);
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len, 4); /* L */
|
||||
cio_seek(lenp+len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the THIX box
|
||||
*
|
||||
* Tile header Index table box (superbox)
|
||||
*
|
||||
*/
|
||||
//int jpip_write_thix(info_image_t img, j2k_cp_t *j2k_cp)
|
||||
// {
|
||||
// int len, lenp;
|
||||
// lenp=cio_tell();
|
||||
// cio_skip(4); /* L [at the end] */
|
||||
// cio_write(JPIP_THIX, 4); /* THIX */
|
||||
|
||||
// jpip_write_faix(1,0,img, j2k_cp);
|
||||
|
||||
// len=cio_tell()-lenp;
|
||||
// cio_seek(lenp);
|
||||
// cio_write(len, 4); /* L */
|
||||
// cio_seek(lenp+len);
|
||||
|
||||
// return len;
|
||||
//}
|
||||
|
||||
int jpip_write_thix(info_image_t img, j2k_cp_t *j2k_cp)
|
||||
{
|
||||
int len, lenp, i;
|
||||
int tileno;
|
||||
info_marker_t *marker;
|
||||
int num_marker_local_jpip;
|
||||
|
||||
marker = (info_marker_t*)calloc(sizeof(info_marker_t), j2k_cp->tw*j2k_cp->th);
|
||||
|
||||
for ( i = 0; i < 2 ; i++ )
|
||||
{
|
||||
if (i) cio_seek(lenp);
|
||||
|
||||
lenp = cio_tell();
|
||||
cio_skip(4); /* L [at the end] */
|
||||
cio_write(JPIP_THIX, 4); /* THIX */
|
||||
jpip_write_manf(i, j2k_cp->tw*j2k_cp->th, marker);
|
||||
num_marker_local_jpip=img.Comp;
|
||||
|
||||
for (tileno = 0; tileno < j2k_cp->tw*j2k_cp->th; tileno++)
|
||||
{
|
||||
marker[tileno].len = jpip_write_mhix(img, 1, tileno);
|
||||
marker[tileno].type = JPIP_MHIX;
|
||||
}
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len, 4); /* L */
|
||||
cio_seek(lenp+len);
|
||||
}
|
||||
|
||||
free(marker);
|
||||
|
||||
return len;
|
||||
}
|
||||
/*
|
||||
* Write the PPIX box
|
||||
*
|
||||
* Precinct Packet Index table box (superbox)
|
||||
*
|
||||
*/
|
||||
int jpip_write_ppix(info_image_t img,j2k_cp_t *j2k_cp)
|
||||
{
|
||||
int len, lenp, compno, i;
|
||||
info_marker_t *marker;
|
||||
int num_marker_local_jpip;
|
||||
marker = (info_marker_t*)calloc(sizeof(info_marker_t), img.Comp);
|
||||
|
||||
for (i=0;i<2;i++)
|
||||
{
|
||||
if (i) cio_seek(lenp);
|
||||
|
||||
lenp=cio_tell();
|
||||
cio_skip(4); /* L [at the end] */
|
||||
cio_write(JPIP_PPIX, 4); /* PPIX */
|
||||
jpip_write_manf(i,img.Comp,marker);
|
||||
num_marker_local_jpip=img.Comp;
|
||||
|
||||
for (compno=0; compno<img.Comp; compno++)
|
||||
{
|
||||
marker[compno].len=jpip_write_faix(2,compno,img, j2k_cp, 0);
|
||||
marker[compno].type=JPIP_FAIX;
|
||||
}
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len, 4); /* L */
|
||||
cio_seek(lenp+len);
|
||||
}
|
||||
|
||||
free(marker);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the PHIX box
|
||||
*
|
||||
* Packet Header Index table box (superbox)
|
||||
*
|
||||
*/
|
||||
int jpip_write_phix(info_image_t img, j2k_cp_t *j2k_cp)
|
||||
{
|
||||
int len, lenp=0, compno, i;
|
||||
info_marker_t *marker;
|
||||
|
||||
marker = (info_marker_t*)calloc(sizeof(info_marker_t), img.Comp);
|
||||
|
||||
for (i=0;i<2;i++)
|
||||
{
|
||||
if (i) cio_seek(lenp);
|
||||
|
||||
lenp=cio_tell();
|
||||
cio_skip(4); /* L [at the end] */
|
||||
cio_write(JPIP_PHIX, 4); /* PHIX */
|
||||
|
||||
jpip_write_manf(i,img.Comp,marker);
|
||||
|
||||
for (compno=0; compno<img.Comp; compno++)
|
||||
{
|
||||
marker[compno].len=jpip_write_faix(3,compno,img, j2k_cp, 0);
|
||||
marker[compno].type=JPIP_FAIX;
|
||||
}
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len, 4); /* L */
|
||||
cio_seek(lenp+len);
|
||||
}
|
||||
|
||||
free(marker);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the CIDX box
|
||||
*
|
||||
* Codestream Index box (superbox)
|
||||
*
|
||||
*/
|
||||
int jpip_write_cidx(int offset, info_image_t img, j2k_cp_t *j2k_cp, int version)
|
||||
{
|
||||
int len, lenp = 0, i;
|
||||
info_marker_t *marker_jpip;
|
||||
int num_marker_jpip = 0;
|
||||
|
||||
marker_jpip = (info_marker_t*)calloc(sizeof(info_marker_t), 32);
|
||||
|
||||
for (i=0;i<2;i++)
|
||||
{
|
||||
if(i)
|
||||
cio_seek(lenp);
|
||||
|
||||
lenp=cio_tell();
|
||||
|
||||
cio_skip(4); /* L [at the end] */
|
||||
cio_write(JPIP_CIDX, 4); /* CIDX */
|
||||
jpip_write_cptr(offset, img);
|
||||
|
||||
jpip_write_manf(i,num_marker_jpip, marker_jpip);
|
||||
|
||||
num_marker_jpip=0;
|
||||
marker_jpip[num_marker_jpip].len=jpip_write_mhix(img, 0, 0);
|
||||
marker_jpip[num_marker_jpip].type=JPIP_MHIX;
|
||||
num_marker_jpip++;
|
||||
|
||||
marker_jpip[num_marker_jpip].len=jpip_write_tpix(img, j2k_cp, version);
|
||||
marker_jpip[num_marker_jpip].type=JPIP_TPIX;
|
||||
num_marker_jpip++;
|
||||
|
||||
marker_jpip[num_marker_jpip].len=jpip_write_thix(img, j2k_cp);
|
||||
marker_jpip[num_marker_jpip].type=JPIP_THIX;
|
||||
num_marker_jpip++;
|
||||
|
||||
marker_jpip[num_marker_jpip].len=jpip_write_ppix(img, j2k_cp);
|
||||
marker_jpip[num_marker_jpip].type=JPIP_PPIX;
|
||||
num_marker_jpip++;
|
||||
|
||||
marker_jpip[num_marker_jpip].len=jpip_write_phix(img, j2k_cp);
|
||||
marker_jpip[num_marker_jpip].type=JPIP_PHIX;
|
||||
num_marker_jpip++;
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len, 4); /* L */
|
||||
cio_seek(lenp+len);
|
||||
}
|
||||
|
||||
free(marker_jpip);
|
||||
|
||||
return len;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the IPTR box
|
||||
*
|
||||
* Index Finder box
|
||||
*
|
||||
*/
|
||||
void jpip_write_iptr(int offset, int length)
|
||||
{
|
||||
int len, lenp;
|
||||
lenp=cio_tell();
|
||||
cio_skip(4); /* L [at the end] */
|
||||
cio_write(JPIP_IPTR, 4); /* IPTR */
|
||||
|
||||
cio_write(offset,8);
|
||||
cio_write(length,8);
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len, 4); /* L */
|
||||
cio_seek(lenp+len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the PRXY box
|
||||
*
|
||||
* proxy (box)
|
||||
*
|
||||
*/
|
||||
void jpip_write_prxy(int offset_jp2c, int length_jp2c, int offset_idx, int length_idx)
|
||||
{
|
||||
int len, lenp;
|
||||
lenp=cio_tell();
|
||||
cio_skip(4); /* L [at the end] */
|
||||
cio_write(JPIP_PRXY, 4); /* IPTR */
|
||||
|
||||
cio_write(offset_jp2c,8); /* OOFF */
|
||||
cio_write(length_jp2c,4); /* OBH part 1 */
|
||||
cio_write(JP2C,4); /* OBH part 2 */
|
||||
|
||||
cio_write(1,1); /* NI */
|
||||
|
||||
cio_write(offset_idx,8); /* IOFF */
|
||||
cio_write(length_idx,4); /* IBH part 1 */
|
||||
cio_write(JPIP_CIDX,4); /* IBH part 2 */
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len, 4); /* L */
|
||||
cio_seek(lenp+len);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Write the FIDX box
|
||||
*
|
||||
* File Index (superbox)
|
||||
*
|
||||
*/
|
||||
int jpip_write_fidx(int offset_jp2c, int length_jp2c, int offset_idx, int length_idx)
|
||||
{
|
||||
int len, lenp;
|
||||
lenp=cio_tell();
|
||||
cio_skip(4); /* L [at the end] */
|
||||
cio_write(JPIP_FIDX, 4); /* IPTR */
|
||||
|
||||
jpip_write_prxy(offset_jp2c, length_jp2c, offset_idx, offset_jp2c);
|
||||
|
||||
len=cio_tell()-lenp;
|
||||
cio_seek(lenp);
|
||||
cio_write(len, 4); /* L */
|
||||
cio_seek(lenp+len);
|
||||
|
||||
return len;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003, Yannick Verschueren
|
||||
* Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* All rights reserved.
|
||||
@@ -26,25 +25,18 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __OPENJPEG_H
|
||||
#define __OPENJPEG_H
|
||||
#ifndef __JPIP_H
|
||||
#define __JPIP_H
|
||||
|
||||
#include <j2k.h>
|
||||
#include <tcd.h>
|
||||
#include <jp2.h>
|
||||
#include <jpw.h>
|
||||
#include "j2k.h"
|
||||
|
||||
#include <bio.h>
|
||||
#include <cio.h>
|
||||
#include <dwt.h>
|
||||
#include <fix.h>
|
||||
#include <int.h>
|
||||
#include <mct.h>
|
||||
#include <mqc.h>
|
||||
#include <pi.h>
|
||||
#include <raw.h>
|
||||
#include <t1.h>
|
||||
#include <t2.h>
|
||||
#include <tgt.h>
|
||||
// Codestream index box (superbox)
|
||||
int jpip_write_cidx(int offset, info_image_t img, j2k_cp_t *j2k_cp, int version);
|
||||
|
||||
// Index Finder Box
|
||||
void jpip_write_iptr(int offset, int length);
|
||||
|
||||
// File Index Box
|
||||
int jpip_write_fidx(int offset_jp2c, int length_jp2c, int offset_idx, int length_idx);
|
||||
|
||||
#endif
|
||||
465
indexer_JPIP/pi.c
Normal file
465
indexer_JPIP/pi.c
Normal file
@@ -0,0 +1,465 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003-2004, Yannick Verschueren
|
||||
* Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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 "pi.h"
|
||||
#include "int.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/* <summary> */
|
||||
/* Create a packet iterator. */
|
||||
/* </summary> */
|
||||
pi_iterator_t *pi_create(j2k_image_t * img, j2k_cp_t * cp, int tileno)
|
||||
{
|
||||
int p, q;
|
||||
int compno, resno, pino;
|
||||
int maxres = 0;
|
||||
pi_iterator_t *pi;
|
||||
j2k_tcp_t *tcp;
|
||||
j2k_tccp_t *tccp;
|
||||
|
||||
tcp = &cp->tcps[tileno];
|
||||
pi = (pi_iterator_t *) malloc((tcp->numpocs + 1) * sizeof(pi_iterator_t));
|
||||
|
||||
for (pino = 0; pino < tcp->numpocs + 1; pino++) { /* change */
|
||||
p = tileno % cp->tw;
|
||||
q = tileno / cp->tw;
|
||||
|
||||
pi[pino].tx0 = int_max(cp->tx0 + p * cp->tdx, img->x0);
|
||||
pi[pino].ty0 = int_max(cp->ty0 + q * cp->tdy, img->y0);
|
||||
pi[pino].tx1 = int_min(cp->tx0 + (p + 1) * cp->tdx, img->x1);
|
||||
pi[pino].ty1 = int_min(cp->ty0 + (q + 1) * cp->tdy, img->y1);
|
||||
pi[pino].numcomps = img->numcomps;
|
||||
pi[pino].comps = (pi_comp_t *) malloc(img->numcomps * sizeof(pi_comp_t));
|
||||
|
||||
for (compno = 0; compno < pi->numcomps; compno++) {
|
||||
int tcx0, tcy0, tcx1, tcy1;
|
||||
pi_comp_t *comp = &pi[pino].comps[compno];
|
||||
tccp = &tcp->tccps[compno];
|
||||
comp->dx = img->comps[compno].dx;
|
||||
comp->dy = img->comps[compno].dy;
|
||||
comp->numresolutions = tccp->numresolutions;
|
||||
comp->resolutions =
|
||||
(pi_resolution_t *) malloc(comp->numresolutions *
|
||||
sizeof(pi_resolution_t));
|
||||
tcx0 = int_ceildiv(pi->tx0, comp->dx);
|
||||
tcy0 = int_ceildiv(pi->ty0, comp->dy);
|
||||
tcx1 = int_ceildiv(pi->tx1, comp->dx);
|
||||
tcy1 = int_ceildiv(pi->ty1, comp->dy);
|
||||
if (comp->numresolutions > maxres) {
|
||||
maxres = comp->numresolutions;
|
||||
}
|
||||
for (resno = 0; resno < comp->numresolutions; resno++) {
|
||||
int levelno;
|
||||
int rx0, ry0, rx1, ry1;
|
||||
int px0, py0, px1, py1;
|
||||
pi_resolution_t *res = &comp->resolutions[resno];
|
||||
if (tccp->csty & J2K_CCP_CSTY_PRT) {
|
||||
res->pdx = tccp->prcw[resno];
|
||||
res->pdy = tccp->prch[resno];
|
||||
} else {
|
||||
res->pdx = 15;
|
||||
res->pdy = 15;
|
||||
}
|
||||
levelno = comp->numresolutions - 1 - resno;
|
||||
rx0 = int_ceildivpow2(tcx0, levelno);
|
||||
ry0 = int_ceildivpow2(tcy0, levelno);
|
||||
rx1 = int_ceildivpow2(tcx1, levelno);
|
||||
ry1 = int_ceildivpow2(tcy1, levelno);
|
||||
px0 = int_floordivpow2(rx0, res->pdx) << res->pdx;
|
||||
py0 = int_floordivpow2(ry0, res->pdy) << res->pdy;
|
||||
px1 = int_ceildivpow2(rx1, res->pdx) << res->pdx;
|
||||
py1 = int_ceildivpow2(ry1, res->pdy) << res->pdy;
|
||||
res->pw = (px1 - px0) >> res->pdx;
|
||||
res->ph = (py1 - py0) >> res->pdy;
|
||||
}
|
||||
}
|
||||
|
||||
tccp = &tcp->tccps[0];
|
||||
pi[pino].step_p=1;
|
||||
pi[pino].step_c=100*pi[pino].step_p;
|
||||
pi[pino].step_r=img->numcomps*pi[pino].step_c;
|
||||
pi[pino].step_l=maxres*pi[pino].step_r;
|
||||
|
||||
if (pino==0)
|
||||
pi[pino].include=(short int*)calloc(img->numcomps*maxres*tcp->numlayers*100,sizeof(short int));
|
||||
else
|
||||
pi[pino].include=pi[pino-1].include;
|
||||
|
||||
/*if (pino == tcp->numpocs) {*/
|
||||
if (tcp->POC == 0) {
|
||||
pi[pino].first = 1;
|
||||
pi[pino].poc.resno0 = 0;
|
||||
pi[pino].poc.compno0 = 0;
|
||||
pi[pino].poc.layno1 = tcp->numlayers;
|
||||
pi[pino].poc.resno1 = maxres;
|
||||
pi[pino].poc.compno1 = img->numcomps;
|
||||
pi[pino].poc.prg = tcp->prg;
|
||||
} else {
|
||||
pi[pino].first = 1;
|
||||
pi[pino].poc.resno0 = tcp->pocs[pino].resno0;
|
||||
pi[pino].poc.compno0 = tcp->pocs[pino].compno0;
|
||||
pi[pino].poc.layno1 = tcp->pocs[pino].layno1;
|
||||
pi[pino].poc.resno1 = tcp->pocs[pino].resno1;
|
||||
pi[pino].poc.compno1 = tcp->pocs[pino].compno1;
|
||||
pi[pino].poc.prg = tcp->pocs[pino].prg;
|
||||
}
|
||||
}
|
||||
return pi;
|
||||
}
|
||||
|
||||
/* <summary> */
|
||||
/* Get next packet in layer=resolution-component-precinct order. */
|
||||
/* </summary> */
|
||||
int pi_next_lrcp(pi_iterator_t * pi)
|
||||
{
|
||||
pi_comp_t *comp;
|
||||
pi_resolution_t *res;
|
||||
|
||||
if (!pi->first) {
|
||||
comp = &pi->comps[pi->compno];
|
||||
res = &comp->resolutions[pi->resno];
|
||||
goto skip;
|
||||
} else {
|
||||
pi->first = 0;
|
||||
}
|
||||
for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
|
||||
for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1;
|
||||
pi->resno++) {
|
||||
for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1;
|
||||
pi->compno++) {
|
||||
comp = &pi->comps[pi->compno];
|
||||
if (pi->resno >= comp->numresolutions) {
|
||||
|
||||
continue;
|
||||
}
|
||||
res = &comp->resolutions[pi->resno];
|
||||
for (pi->precno = 0; pi->precno < res->pw * res->ph; pi->precno++) {
|
||||
if (!pi->include[pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p]){
|
||||
pi->include[pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p] = 1;
|
||||
return 1;
|
||||
}
|
||||
skip:;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* <summary> */
|
||||
/* Get next packet in resolution-layer-component-precinct order. */
|
||||
/* </summary> */
|
||||
int pi_next_rlcp(pi_iterator_t * pi)
|
||||
{
|
||||
pi_comp_t *comp;
|
||||
pi_resolution_t *res;
|
||||
if (!pi->first) {
|
||||
comp = &pi->comps[pi->compno];
|
||||
res = &comp->resolutions[pi->resno];
|
||||
goto skip;
|
||||
} else {
|
||||
pi->first = 0;
|
||||
}
|
||||
for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
|
||||
for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
|
||||
for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1;
|
||||
pi->compno++) {
|
||||
comp = &pi->comps[pi->compno];
|
||||
if (pi->resno >= comp->numresolutions) {
|
||||
continue;
|
||||
}
|
||||
res = &comp->resolutions[pi->resno];
|
||||
for (pi->precno = 0; pi->precno < res->pw * res->ph; pi->precno++) {
|
||||
if (!pi->include[pi->layno*pi->step_l+pi->resno*pi->step_r+pi->compno*pi->step_c+pi->precno*pi->step_p]){
|
||||
pi->include[pi->layno*pi->step_l+pi->resno*pi->step_r+pi->compno*pi->step_c+pi->precno*pi->step_p] = 1;
|
||||
return 1;
|
||||
}
|
||||
skip:;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* <summary> */
|
||||
/* Get next packet in resolution-precinct-component-layer order. */
|
||||
/* </summary> */
|
||||
int pi_next_rpcl(pi_iterator_t * pi)
|
||||
{
|
||||
pi_comp_t *comp;
|
||||
pi_resolution_t *res;
|
||||
if (!pi->first) {
|
||||
goto skip;
|
||||
} else {
|
||||
int compno, resno;
|
||||
pi->first = 0;
|
||||
pi->dx = 0;
|
||||
pi->dy = 0;
|
||||
for (compno = 0; compno < pi->numcomps; compno++) {
|
||||
comp = &pi->comps[compno];
|
||||
for (resno = 0; resno < comp->numresolutions; resno++) {
|
||||
int dx, dy;
|
||||
res = &comp->resolutions[resno];
|
||||
dx =
|
||||
comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
|
||||
dy =
|
||||
comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
|
||||
pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
|
||||
pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1; pi->resno++) {
|
||||
for (pi->y = pi->ty0; pi->y < pi->ty1;
|
||||
pi->y += pi->dy - (pi->y % pi->dy)) {
|
||||
for (pi->x = pi->tx0; pi->x < pi->tx1;
|
||||
pi->x += pi->dx - (pi->x % pi->dx)) {
|
||||
for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1;
|
||||
pi->compno++) {
|
||||
int levelno;
|
||||
int trx0, try0;
|
||||
int rpx, rpy;
|
||||
int prci, prcj;
|
||||
comp = &pi->comps[pi->compno];
|
||||
if (pi->resno >= comp->numresolutions) {
|
||||
continue;
|
||||
}
|
||||
res = &comp->resolutions[pi->resno];
|
||||
levelno = comp->numresolutions - 1 - pi->resno;
|
||||
trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
|
||||
try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
|
||||
rpx = res->pdx + levelno;
|
||||
rpy = res->pdy + levelno;
|
||||
if (!
|
||||
(pi->x % (comp->dx << rpx) == 0
|
||||
|| (pi->x == pi->tx0 && (trx0 << levelno) % (1 << rpx)))) {
|
||||
continue;
|
||||
}
|
||||
if (!
|
||||
(pi->y % (comp->dy << rpy) == 0
|
||||
|| (pi->y == pi->ty0 && (try0 << levelno) % (1 << rpx)))) {
|
||||
continue;
|
||||
}
|
||||
prci =
|
||||
int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelno),
|
||||
res->pdx) - int_floordivpow2(trx0, res->pdx);
|
||||
prcj =
|
||||
int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelno),
|
||||
res->pdy) - int_floordivpow2(try0, res->pdy);
|
||||
pi->precno = prci + prcj * res->pw;
|
||||
for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
|
||||
if (!pi->include[pi->layno*pi->step_l+pi->resno*pi->step_r+pi->compno*pi->step_c+pi->precno*pi->step_p]){
|
||||
pi->include[pi->layno*pi->step_l+pi->resno*pi->step_r+pi->compno*pi->step_c+pi->precno*pi->step_p] = 1;
|
||||
return 1;
|
||||
}
|
||||
skip:;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* <summary> */
|
||||
/* Get next packet in precinct-component-resolution-layer order. */
|
||||
/* </summary> */
|
||||
int pi_next_pcrl(pi_iterator_t * pi)
|
||||
{
|
||||
pi_comp_t *comp;
|
||||
pi_resolution_t *res;
|
||||
if (!pi->first) {
|
||||
comp = &pi->comps[pi->compno];
|
||||
goto skip;
|
||||
} else {
|
||||
int compno, resno;
|
||||
pi->first = 0;
|
||||
pi->dx = 0;
|
||||
pi->dy = 0;
|
||||
for (compno = 0; compno < pi->numcomps; compno++) {
|
||||
comp = &pi->comps[compno];
|
||||
for (resno = 0; resno < comp->numresolutions; resno++) {
|
||||
int dx, dy;
|
||||
res = &comp->resolutions[resno];
|
||||
dx =
|
||||
comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
|
||||
dy =
|
||||
comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
|
||||
pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
|
||||
pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (pi->y = pi->ty0; pi->y < pi->ty1;
|
||||
pi->y += pi->dy - (pi->y % pi->dy)) {
|
||||
for (pi->x = pi->tx0; pi->x < pi->tx1;
|
||||
pi->x += pi->dx - (pi->x % pi->dx)) {
|
||||
for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1;
|
||||
pi->compno++) {
|
||||
comp = &pi->comps[pi->compno];
|
||||
for (pi->resno = pi->poc.resno0;
|
||||
pi->resno < int_min(pi->poc.resno1, comp->numresolutions);
|
||||
pi->resno++) {
|
||||
int levelno;
|
||||
int trx0, try0;
|
||||
int rpx, rpy;
|
||||
int prci, prcj;
|
||||
res = &comp->resolutions[pi->resno];
|
||||
levelno = comp->numresolutions - 1 - pi->resno;
|
||||
trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
|
||||
try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
|
||||
rpx = res->pdx + levelno;
|
||||
rpy = res->pdy + levelno;
|
||||
if (!
|
||||
(pi->x % (comp->dx << rpx) == 0
|
||||
|| (pi->x == pi->tx0 && (trx0 << levelno) % (1 << rpx)))) {
|
||||
continue;
|
||||
}
|
||||
if (!
|
||||
(pi->y % (comp->dy << rpy) == 0
|
||||
|| (pi->y == pi->ty0 && (try0 << levelno) % (1 << rpx)))) {
|
||||
continue;
|
||||
}
|
||||
prci =
|
||||
int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelno),
|
||||
res->pdx) - int_floordivpow2(trx0, res->pdx);
|
||||
prcj =
|
||||
int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelno),
|
||||
res->pdy) - int_floordivpow2(try0, res->pdy);
|
||||
pi->precno = prci + prcj * res->pw;
|
||||
for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
|
||||
if (! pi->include[pi->layno*pi->step_l+pi->resno*pi->step_r+pi->compno*pi->step_c+pi->precno*pi->step_p]){
|
||||
pi->include[pi->layno*pi->step_l+pi->resno*pi->step_r+pi->compno*pi->step_c+pi->precno*pi->step_p] = 1;
|
||||
return 1;
|
||||
}
|
||||
skip:;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* <summary> */
|
||||
/* Get next packet in component-precinct-resolution-layer order. */
|
||||
/* </summary> */
|
||||
int pi_next_cprl(pi_iterator_t * pi)
|
||||
{
|
||||
pi_comp_t *comp;
|
||||
pi_resolution_t *res;
|
||||
if (!pi->first) {
|
||||
comp = &pi->comps[pi->compno];
|
||||
goto skip;
|
||||
} else {
|
||||
pi->first = 0;
|
||||
}
|
||||
for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1;
|
||||
pi->compno++) {
|
||||
int resno;
|
||||
comp = &pi->comps[pi->compno];
|
||||
pi->dx = 0;
|
||||
pi->dy = 0;
|
||||
for (resno = 0; resno < comp->numresolutions; resno++) {
|
||||
int dx, dy;
|
||||
res = &comp->resolutions[resno];
|
||||
dx = comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
|
||||
dy = comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
|
||||
pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
|
||||
pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
|
||||
}
|
||||
for (pi->y = pi->ty0; pi->y < pi->ty1;
|
||||
pi->y += pi->dy - (pi->y % pi->dy)) {
|
||||
for (pi->x = pi->tx0; pi->x < pi->tx1;
|
||||
pi->x += pi->dx - (pi->x % pi->dx)) {
|
||||
for (pi->resno = pi->poc.resno0;
|
||||
pi->resno < int_min(pi->poc.resno1, comp->numresolutions);
|
||||
pi->resno++) {
|
||||
int levelno;
|
||||
int trx0, try0;
|
||||
int rpx, rpy;
|
||||
int prci, prcj;
|
||||
res = &comp->resolutions[pi->resno];
|
||||
levelno = comp->numresolutions - 1 - pi->resno;
|
||||
trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
|
||||
try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
|
||||
rpx = res->pdx + levelno;
|
||||
rpy = res->pdy + levelno;
|
||||
if (!
|
||||
(pi->x % (comp->dx << rpx) == 0
|
||||
|| (pi->x == pi->tx0 && (trx0 << levelno) % (1 << rpx)))) {
|
||||
continue;
|
||||
}
|
||||
if (!
|
||||
(pi->y % (comp->dy << rpy) == 0
|
||||
|| (pi->y == pi->ty0 && (try0 << levelno) % (1 << rpx)))) {
|
||||
continue;
|
||||
}
|
||||
prci =
|
||||
int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelno),
|
||||
res->pdx) - int_floordivpow2(trx0, res->pdx);
|
||||
prcj =
|
||||
int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelno),
|
||||
res->pdy) - int_floordivpow2(try0, res->pdy);
|
||||
pi->precno = prci + prcj * res->pw;
|
||||
for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
|
||||
if (! pi->include[pi->layno*pi->step_l+pi->resno*pi->step_r+pi->compno*pi->step_c+pi->precno*pi->step_p]){
|
||||
pi->include[pi->layno*pi->step_l+pi->resno*pi->step_r+pi->compno*pi->step_c+pi->precno*pi->step_p] = 1;
|
||||
return 1;
|
||||
}
|
||||
skip:;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* <summary> */
|
||||
/* Get next packet. */
|
||||
/* </summary> */
|
||||
int pi_next(pi_iterator_t * pi)
|
||||
{
|
||||
switch (pi->poc.prg) {
|
||||
case 0:
|
||||
return pi_next_lrcp(pi);
|
||||
case 1:
|
||||
return pi_next_rlcp(pi);
|
||||
case 2:
|
||||
return pi_next_rpcl(pi);
|
||||
case 3:
|
||||
return pi_next_pcrl(pi);
|
||||
case 4:
|
||||
return pi_next_cprl(pi);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -31,27 +31,27 @@
|
||||
#include "tcd.h"
|
||||
|
||||
typedef struct {
|
||||
int pdx, pdy;
|
||||
int pw, ph;
|
||||
int pdx, pdy;
|
||||
int pw, ph;
|
||||
} pi_resolution_t;
|
||||
|
||||
typedef struct {
|
||||
int dx, dy;
|
||||
int numresolutions;
|
||||
pi_resolution_t *resolutions;
|
||||
int dx, dy;
|
||||
int numresolutions;
|
||||
pi_resolution_t *resolutions;
|
||||
} pi_comp_t;
|
||||
|
||||
typedef struct {
|
||||
short int *include; /* precise if the packet has been already used (usefull for progression order change) */
|
||||
int step_l, step_r, step_c, step_p; /* different steps (layer, resolution, component, precinct) to localize the packet in the include vector */
|
||||
int compno, resno, precno, layno; /* component, resolution, precinct and layer that indentify the packet */
|
||||
int first; /* 0 if the first packet */
|
||||
j2k_poc_t poc;
|
||||
int numcomps;
|
||||
pi_comp_t *comps;
|
||||
int tx0, ty0, tx1, ty1;
|
||||
int x, y, dx, dy;
|
||||
} pi_iterator_t; /* packet iterator */
|
||||
short int *include;
|
||||
int step_l, step_r, step_c, step_p;
|
||||
int compno, resno, precno, layno; /* component, resolution, precinct and layer that indentify the packet */
|
||||
int first;
|
||||
j2k_poc_t poc;
|
||||
int numcomps;
|
||||
pi_comp_t *comps;
|
||||
int tx0, ty0, tx1, ty1;
|
||||
int x, y, dx, dy;
|
||||
} pi_iterator_t; /* packet iterator */
|
||||
|
||||
/*
|
||||
* Create a packet iterator
|
||||
389
indexer_JPIP/t2.c
Normal file
389
indexer_JPIP/t2.c
Normal file
@@ -0,0 +1,389 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003, Yannick Verschueren
|
||||
* Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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 "t2.h"
|
||||
#include "tcd.h"
|
||||
#include "bio.h"
|
||||
#include "j2k.h"
|
||||
#include "pi.h"
|
||||
#include "tgt.h"
|
||||
#include "int.h"
|
||||
#include "cio.h"
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define RESTART 0x04
|
||||
|
||||
extern jmp_buf j2k_error;
|
||||
|
||||
int t2_getcommacode() {
|
||||
int n;
|
||||
for (n=0; bio_read(1); n++) {}
|
||||
return n;
|
||||
}
|
||||
|
||||
int t2_getnumpasses()
|
||||
{
|
||||
int n;
|
||||
if (!bio_read(1)) return 1;
|
||||
if (!bio_read(1)) return 2;
|
||||
if ((n=bio_read(2))!=3) return 3+n;
|
||||
if ((n=bio_read(5))!=31) return 6+n;
|
||||
return 37+bio_read(7);
|
||||
}
|
||||
|
||||
void t2_init_seg(tcd_seg_t *seg, int cblksty) {
|
||||
seg->numpasses=0;
|
||||
seg->len=0;
|
||||
seg->maxpasses=cblksty&J2K_CCP_CBLKSTY_TERMALL?1:100;
|
||||
}
|
||||
|
||||
int t2_decode_packet(unsigned char *src, int len, tcd_tile_t *tile, j2k_cp_t * cp, j2k_tcp_t *tcp, int compno, int resno, int precno, int layno, info_layer_t *layer_Idx) {
|
||||
int bandno, cblkno;
|
||||
tcd_tilecomp_t *tilec = &tile->comps[compno];
|
||||
tcd_resolution_t *res = &tilec->resolutions[resno];
|
||||
unsigned char *c = src;
|
||||
unsigned char *d = c;
|
||||
int e;
|
||||
int present;
|
||||
|
||||
if (layno == 0) {
|
||||
for (bandno = 0; bandno < res->numbands; bandno++) {
|
||||
tcd_band_t *band = &res->bands[bandno];
|
||||
tcd_precinct_t *prc = &band->precincts[precno];
|
||||
tgt_reset(prc->incltree);
|
||||
tgt_reset(prc->imsbtree);
|
||||
for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
|
||||
tcd_cblk_t *cblk = &prc->cblks[cblkno];
|
||||
cblk->numsegs = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* INDEX */
|
||||
layer_Idx->len_header = 0;
|
||||
|
||||
/* When the marker PPT/PPM is used the packet header are store in PPT/PPM marker
|
||||
This part deal with this caracteristic
|
||||
step 1: Read packet header in the saved structure
|
||||
step 2: (futher) return to codestream for decoding */
|
||||
if (cp->ppm == 1) /* PPM */
|
||||
{
|
||||
c = cp->ppm_data;
|
||||
d = c;
|
||||
bio_init_dec(c, 1000);
|
||||
} else
|
||||
{
|
||||
if (tcp->ppt == 1) /* PPT */
|
||||
{
|
||||
c = tcp->ppt_data;
|
||||
d = c;
|
||||
bio_init_dec(c, 1000);
|
||||
} else /* Normal Case */
|
||||
{
|
||||
if (tcp->csty & J2K_CP_CSTY_SOP)
|
||||
{
|
||||
if ((*c) != 255 || (*(c+1) != 145)) {printf("Error : expected SOP marker [1]!!!\n");}
|
||||
c += 6;
|
||||
}
|
||||
bio_init_dec(c, src + len - c);
|
||||
layer_Idx->len_header = -6;
|
||||
}
|
||||
}
|
||||
|
||||
present = bio_read(1);
|
||||
|
||||
if (!present)
|
||||
{
|
||||
bio_inalign();
|
||||
/* Normal case */
|
||||
c += bio_numbytes();
|
||||
if (tcp->csty & J2K_CP_CSTY_EPH)
|
||||
{
|
||||
if ((*c) != 255 || (*(c+1) != 146)) {printf("Error : expected EPH marker [1]!!!\n");}
|
||||
c += 2;
|
||||
}
|
||||
/* INDEX */
|
||||
layer_Idx->len_header += (c-d);
|
||||
|
||||
/* PPT and PPM dealing */
|
||||
if (cp->ppm == 1) /* PPM */
|
||||
{
|
||||
cp->ppm_data = c;
|
||||
return 0;
|
||||
}
|
||||
if (tcp->ppt == 1) /* PPT */
|
||||
{
|
||||
tcp->ppt_data = c;
|
||||
return 0;
|
||||
}
|
||||
return c - src;
|
||||
}
|
||||
|
||||
for (bandno=0; bandno<res->numbands; bandno++) {
|
||||
tcd_band_t *band = &res->bands[bandno];
|
||||
tcd_precinct_t *prc = &band->precincts[precno];
|
||||
for (cblkno = 0; cblkno < prc->cw * prc->ch; cblkno++) {
|
||||
int included, increment, n;
|
||||
tcd_cblk_t *cblk = &prc->cblks[cblkno];
|
||||
tcd_seg_t *seg;
|
||||
if (!cblk->numsegs) {
|
||||
included = tgt_decode(prc->incltree, cblkno, layno+1);
|
||||
} else {
|
||||
included = bio_read(1);
|
||||
}
|
||||
if (!included) {
|
||||
cblk->numnewpasses = 0;
|
||||
continue;
|
||||
}
|
||||
if (!cblk->numsegs) {
|
||||
int i, numimsbs;
|
||||
for (i = 0; !tgt_decode(prc->imsbtree, cblkno, i); i++) {}
|
||||
numimsbs = i-1;
|
||||
cblk->numbps = band->numbps - numimsbs;
|
||||
cblk->numlenbits = 3;
|
||||
}
|
||||
cblk->numnewpasses = t2_getnumpasses();
|
||||
increment = t2_getcommacode();
|
||||
cblk->numlenbits += increment;
|
||||
if (!cblk->numsegs) {
|
||||
seg = &cblk->segs[0];
|
||||
t2_init_seg(seg, tcp->tccps[compno].cblksty);
|
||||
} else {
|
||||
seg = &cblk->segs[cblk->numsegs - 1];
|
||||
if (seg->numpasses == seg->maxpasses) {
|
||||
t2_init_seg(++seg, tcp->tccps[compno].cblksty);
|
||||
}
|
||||
}
|
||||
n = cblk->numnewpasses;
|
||||
do {
|
||||
seg->numnewpasses = int_min(seg->maxpasses-seg->numpasses, n);
|
||||
seg->newlen = bio_read(cblk->numlenbits + int_floorlog2(seg->numnewpasses));
|
||||
n -= seg->numnewpasses;
|
||||
if (n > 0) {
|
||||
t2_init_seg(++seg, tcp->tccps[compno].cblksty);
|
||||
}
|
||||
} while (n > 0);
|
||||
}
|
||||
}
|
||||
if(bio_inalign()) return -999;
|
||||
c += bio_numbytes();
|
||||
|
||||
if (tcp->csty & J2K_CP_CSTY_EPH) { /* EPH marker */
|
||||
if ((*c) != 255 || (*(c+1) != 146)) {printf("Error : expected EPH marker [2]!!!\n"); }
|
||||
c += 2;
|
||||
}
|
||||
|
||||
/* INDEX */
|
||||
layer_Idx->len_header += (c-d);
|
||||
|
||||
/* PPT Step 2 : see above for details */
|
||||
if (cp->ppm == 1)
|
||||
{
|
||||
cp->ppm_data = c; /* Update pointer */
|
||||
|
||||
/* INDEX */
|
||||
layer_Idx->len_header = c-d;
|
||||
|
||||
c = src;
|
||||
d = c;
|
||||
if (tcp->csty & J2K_CP_CSTY_SOP)
|
||||
{
|
||||
if ((*c) != 255 || (*(c+1) != 145)) {printf("Error : expected SOP marker [2] !!!\n"); }
|
||||
c += 6;
|
||||
}
|
||||
bio_init_dec(c, src + len - c);
|
||||
} else
|
||||
{
|
||||
if (tcp->ppt == 1)
|
||||
{
|
||||
tcp->ppt_data = c; /* Update pointer */
|
||||
/* INDEX */
|
||||
layer_Idx->len_header = c-d;
|
||||
|
||||
c = src;
|
||||
d = c;
|
||||
if (tcp->csty & J2K_CP_CSTY_SOP) /* SOP marker */
|
||||
{
|
||||
if ((*c) != 255 || (*(c+1) != 145)) {printf("Error : expected SOP marker [2] !!!\n"); }
|
||||
c += 6;
|
||||
}
|
||||
bio_init_dec(c, src + len - c);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for (bandno = 0; bandno < res->numbands; bandno++) {
|
||||
tcd_band_t *band = &res->bands[bandno];
|
||||
tcd_precinct_t *prc = &band->precincts[precno];
|
||||
for (cblkno = 0; cblkno < prc->cw*prc->ch; cblkno++) {
|
||||
tcd_cblk_t *cblk = &prc->cblks[cblkno];
|
||||
tcd_seg_t *seg;
|
||||
if (!cblk->numnewpasses) continue;
|
||||
if (!cblk->numsegs) {
|
||||
seg = &cblk->segs[cblk->numsegs++];
|
||||
cblk->len = 0;
|
||||
} else {
|
||||
seg = &cblk->segs[cblk->numsegs-1];
|
||||
if (seg->numpasses == seg->maxpasses) {
|
||||
seg++;
|
||||
cblk->numsegs++;
|
||||
}
|
||||
}
|
||||
do {
|
||||
if (c + seg->newlen > src + len) return -999;
|
||||
memcpy(cblk->data + cblk->len, c, seg->newlen);
|
||||
if (seg->numpasses == 0) {
|
||||
seg->data = cblk->data + cblk->len;
|
||||
}
|
||||
c += seg->newlen;
|
||||
cblk->len += seg->newlen;
|
||||
seg->len += seg->newlen;
|
||||
seg->numpasses += seg->numnewpasses;
|
||||
cblk->numnewpasses -= seg->numnewpasses;
|
||||
if (cblk->numnewpasses > 0) {
|
||||
seg++;
|
||||
cblk->numsegs++;
|
||||
}
|
||||
} while (cblk->numnewpasses > 0);
|
||||
}
|
||||
}
|
||||
/* <INDEX> */
|
||||
e = c-d;
|
||||
layer_Idx->len = e;
|
||||
/* </INDEX> */
|
||||
|
||||
return c-src;
|
||||
}
|
||||
|
||||
void t2_init_info_packets(info_image_t *img, j2k_cp_t *cp)
|
||||
{
|
||||
int compno, tileno, resno, precno, layno;
|
||||
|
||||
for(compno = 0; compno < img->Comp; compno++)
|
||||
{
|
||||
for(tileno = 0; tileno < img->tw*img->th; tileno++)
|
||||
{
|
||||
info_tile_t *tile_Idx = &img->tile[tileno];
|
||||
info_compo_t *compo_Idx = &tile_Idx->compo[compno];
|
||||
for(resno = 0; resno < img->Decomposition + 1 ; resno++)
|
||||
{
|
||||
info_reso_t *reso_Idx = &compo_Idx->reso[resno];
|
||||
for (precno = 0; precno < img->tile[tileno].pw * img->tile[tileno].ph; precno++)
|
||||
{
|
||||
info_prec_t *prec_Idx = &reso_Idx->prec[precno];
|
||||
for(layno = 0; layno < img->Layer ; layno++)
|
||||
{
|
||||
info_layer_t *layer_Idx = &prec_Idx->layer[layno];
|
||||
layer_Idx->offset = 0; /* start position */
|
||||
layer_Idx->len_header = 0; /* length */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int t2_decode_packets(unsigned char *src, int len, j2k_image_t *img, j2k_cp_t *cp, int tileno, tcd_tile_t *tile, info_image_t *imgg) {
|
||||
unsigned char *c = src;
|
||||
pi_iterator_t *pi;
|
||||
int pino, compno,e;
|
||||
int partno;
|
||||
info_tile_part_t *tile_part;
|
||||
int position;
|
||||
int length_read;
|
||||
info_tile_t *tile_Idx;
|
||||
info_compo_t *compo_Idx;
|
||||
info_reso_t *reso_Idx;
|
||||
info_prec_t *prec_Idx;
|
||||
info_layer_t *layer_Idx;
|
||||
|
||||
t2_init_info_packets(imgg, cp); /* Initialize the packets information : LEN and OFFSET to 0 */
|
||||
|
||||
tile_Idx = &imgg->tile[tileno];
|
||||
tile_Idx->num_packet = 0;
|
||||
pi = pi_create(img, cp, tileno);
|
||||
partno = 0;
|
||||
tile_part = &tile_Idx->tile_parts[partno];
|
||||
position = tile_part->end_header + 1;
|
||||
length_read = 0;
|
||||
|
||||
for (pino = 0; pino <= cp->tcps[tileno].numpocs; pino++)
|
||||
{
|
||||
while (pi_next(&pi[pino]))
|
||||
{
|
||||
compo_Idx = &tile_Idx->compo[pi[pino].compno];
|
||||
reso_Idx = &compo_Idx->reso[pi[pino].resno];
|
||||
prec_Idx = &reso_Idx->prec[pi[pino].precno];
|
||||
layer_Idx = &prec_Idx->layer[pi[pino].layno];
|
||||
|
||||
layer_Idx->offset = position;
|
||||
layer_Idx->offset_header = position;
|
||||
|
||||
e = t2_decode_packet(c, src+len-c, tile, cp, &cp->tcps[tileno], pi[pino].compno, pi[pino].resno, pi[pino].precno, pi[pino].layno,layer_Idx);
|
||||
if (e == -999)
|
||||
{
|
||||
break;
|
||||
} else
|
||||
c += e;
|
||||
position += e;
|
||||
|
||||
/* Update position in case of multiple tile-parts for a tile >> */
|
||||
length_read += e;
|
||||
if (length_read >= (tile_part->end_pos - tile_part->end_header))
|
||||
{
|
||||
partno++;
|
||||
tile_part = &tile_Idx->tile_parts[partno];
|
||||
position = tile_part->end_header + 1;
|
||||
length_read = 0;
|
||||
}
|
||||
/* << end_update */
|
||||
|
||||
tile_Idx->num_packet++;
|
||||
}
|
||||
|
||||
// FREE space memory taken by pi
|
||||
for (compno = 0; compno < pi[pino].numcomps; compno++)
|
||||
{
|
||||
free(pi[pino].comps[compno].resolutions);
|
||||
}
|
||||
free(pi[pino].comps);
|
||||
}
|
||||
|
||||
free(pi[0].include);
|
||||
free(pi);
|
||||
|
||||
if (e==-999)
|
||||
return e;
|
||||
else
|
||||
{
|
||||
imgg->num_packet_max=int_max(imgg->num_packet_max,tile_Idx->num_packet);
|
||||
return c-src;
|
||||
}
|
||||
}
|
||||
46
indexer_JPIP/t2.h
Normal file
46
indexer_JPIP/t2.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003, Yannick Verschueren
|
||||
* Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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 __T2_H
|
||||
#define __T2_H
|
||||
|
||||
#include "tcd.h"
|
||||
#include "j2k.h"
|
||||
|
||||
/*
|
||||
* Decode the packets of a tile from a source buffer
|
||||
* src: the source buffer
|
||||
* len: length of the source buffer
|
||||
* img: destination image
|
||||
* cp: image coding parameters
|
||||
* tileno: number that identifies the tile for which to decode the packets
|
||||
* tile: tile for which to decode the packets
|
||||
*/
|
||||
int t2_decode_packets(unsigned char *src, int len, j2k_image_t *img, j2k_cp_t *cp, int tileno, tcd_tile_t *tile, info_image_t *imgg);
|
||||
|
||||
#endif
|
||||
285
indexer_JPIP/tcd.c
Normal file
285
indexer_JPIP/tcd.c
Normal file
@@ -0,0 +1,285 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003, Yannick Verschueren
|
||||
* Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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 "tcd.h"
|
||||
#include "int.h"
|
||||
#include "t2.h"
|
||||
#include <setjmp.h>
|
||||
#include <float.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static tcd_image_t tcd_image;
|
||||
|
||||
static j2k_image_t *tcd_img;
|
||||
static j2k_cp_t *tcd_cp;
|
||||
|
||||
extern jmp_buf j2k_error;
|
||||
|
||||
void tcd_init(j2k_image_t *img, j2k_cp_t *cp, info_image_t *imgg) {
|
||||
int tileno, compno, resno, bandno, precno, cblkno;
|
||||
tcd_img=img;
|
||||
tcd_cp=cp;
|
||||
tcd_image.tw=cp->tw;
|
||||
tcd_image.th=cp->th;
|
||||
tcd_image.tiles=(tcd_tile_t*)malloc(cp->tw*cp->th*sizeof(tcd_tile_t));
|
||||
for (tileno=0; tileno<cp->tw*cp->th; tileno++) {
|
||||
j2k_tcp_t *tcp=&cp->tcps[tileno];
|
||||
tcd_tile_t *tile=&tcd_image.tiles[tileno];
|
||||
// cfr p59 ISO/IEC FDIS15444-1 : 2000 (18 august 2000)
|
||||
int p=tileno%cp->tw; // si numerotation matricielle ..
|
||||
int q=tileno/cp->tw; // .. coordonnees de la tile (q,p) q pour ligne et p pour colonne
|
||||
info_tile_t *tile_Idx=&imgg->tile[tileno]; // INDEX
|
||||
|
||||
// 4 borders of the tile rescale on the image if necessary
|
||||
tile->x0=int_max(cp->tx0+p*cp->tdx, img->x0);
|
||||
tile->y0=int_max(cp->ty0+q*cp->tdy, img->y0);
|
||||
tile->x1=int_min(cp->tx0+(p+1)*cp->tdx, img->x1);
|
||||
tile->y1=int_min(cp->ty0+(q+1)*cp->tdy, img->y1);
|
||||
|
||||
tile->numcomps=img->numcomps;
|
||||
tile->comps=(tcd_tilecomp_t*)malloc(img->numcomps*sizeof(tcd_tilecomp_t));
|
||||
tile_Idx->compo=(info_compo_t*)malloc(img->numcomps*sizeof(info_compo_t)); // INDEX
|
||||
for (compno=0; compno<tile->numcomps; compno++) {
|
||||
j2k_tccp_t *tccp=&tcp->tccps[compno];
|
||||
tcd_tilecomp_t *tilec=&tile->comps[compno];
|
||||
info_compo_t *compo_Idx=&tile_Idx->compo[compno]; // INDEX
|
||||
|
||||
// border of each tile component (global)
|
||||
tilec->x0=int_ceildiv(tile->x0, img->comps[compno].dx);
|
||||
tilec->y0=int_ceildiv(tile->y0, img->comps[compno].dy);
|
||||
tilec->x1=int_ceildiv(tile->x1, img->comps[compno].dx);
|
||||
tilec->y1=int_ceildiv(tile->y1, img->comps[compno].dy);
|
||||
|
||||
tilec->data=(int*)malloc(sizeof(int)*(tilec->x1-tilec->x0)*(tilec->y1-tilec->y0));
|
||||
tilec->numresolutions=tccp->numresolutions;
|
||||
tilec->resolutions=(tcd_resolution_t*)malloc(tilec->numresolutions*sizeof(tcd_resolution_t));
|
||||
compo_Idx->reso=(info_reso_t*)malloc(tilec->numresolutions*sizeof(info_reso_t)); // INDEX
|
||||
for (resno=0; resno<tilec->numresolutions; resno++) {
|
||||
int pdx, pdy;
|
||||
int levelno=tilec->numresolutions-1-resno;
|
||||
int tlprcxstart, tlprcystart, brprcxend, brprcyend;
|
||||
int tlcbgxstart, tlcbgystart, brcbgxend, brcbgyend;
|
||||
int cbgwidthexpn, cbgheightexpn;
|
||||
int cblkwidthexpn, cblkheightexpn;
|
||||
tcd_resolution_t *res=&tilec->resolutions[resno];
|
||||
info_reso_t *res_Idx=&compo_Idx->reso[resno]; // INDEX
|
||||
int precno_Idx; // INDEX
|
||||
|
||||
// border for each resolution level (global)
|
||||
res->x0=int_ceildivpow2(tilec->x0, levelno);
|
||||
res->y0=int_ceildivpow2(tilec->y0, levelno);
|
||||
res->x1=int_ceildivpow2(tilec->x1, levelno);
|
||||
res->y1=int_ceildivpow2(tilec->y1, levelno);
|
||||
|
||||
res->numbands=resno==0?1:3;
|
||||
// p. 35, table A-23, ISO/IEC FDIS154444-1 : 2000 (18 august 2000)
|
||||
if (tccp->csty&J2K_CCP_CSTY_PRT) {
|
||||
pdx=tccp->prcw[resno];
|
||||
pdy=tccp->prch[resno];
|
||||
} else {
|
||||
pdx=15;
|
||||
pdy=15;
|
||||
}
|
||||
// p. 64, B.6, ISO/IEC FDIS15444-1 : 2000 (18 august 2000)
|
||||
tlprcxstart=int_floordivpow2(res->x0, pdx)<<pdx;
|
||||
tlprcystart=int_floordivpow2(res->y0, pdy)<<pdy;
|
||||
brprcxend=int_ceildivpow2(res->x1, pdx)<<pdx;
|
||||
brprcyend=int_ceildivpow2(res->y1, pdy)<<pdy;
|
||||
res->pw=(brprcxend-tlprcxstart)>>pdx;
|
||||
res->ph=(brprcyend-tlprcystart)>>pdy;
|
||||
|
||||
// <INDEX>
|
||||
imgg->tile[tileno].pw=res->pw;
|
||||
imgg->tile[tileno].ph=res->ph;
|
||||
|
||||
res_Idx->prec=(info_prec_t*)malloc(res->pw*res->ph*sizeof(info_prec_t));
|
||||
for (precno_Idx=0;precno_Idx<res->pw*res->ph;precno_Idx++)
|
||||
{
|
||||
info_prec_t *prec_Idx = &res_Idx->prec[precno_Idx];
|
||||
prec_Idx->layer=(info_layer_t*)malloc(imgg->Layer*sizeof(info_layer_t));
|
||||
}
|
||||
|
||||
imgg->pw=res->pw; // old parser version
|
||||
imgg->ph=res->ph; // old parser version
|
||||
imgg->pdx=1<<pdx;
|
||||
imgg->pdy=1<<pdy;
|
||||
// </INDEX>
|
||||
|
||||
if (resno==0) {
|
||||
tlcbgxstart=tlprcxstart;
|
||||
tlcbgystart=tlprcystart;
|
||||
brcbgxend=brprcxend;
|
||||
brcbgyend=brprcyend;
|
||||
cbgwidthexpn=pdx;
|
||||
cbgheightexpn=pdy;
|
||||
} else {
|
||||
tlcbgxstart=int_ceildivpow2(tlprcxstart, 1);
|
||||
tlcbgystart=int_ceildivpow2(tlprcystart, 1);
|
||||
brcbgxend=int_ceildivpow2(brprcxend, 1);
|
||||
brcbgyend=int_ceildivpow2(brprcyend, 1);
|
||||
cbgwidthexpn=pdx-1;
|
||||
cbgheightexpn=pdy-1;
|
||||
}
|
||||
|
||||
cblkwidthexpn=int_min(tccp->cblkw, cbgwidthexpn);
|
||||
cblkheightexpn=int_min(tccp->cblkh, cbgheightexpn);
|
||||
|
||||
for (bandno=0; bandno<res->numbands; bandno++) {
|
||||
int x0b, y0b;
|
||||
tcd_band_t *band=&res->bands[bandno];
|
||||
band->bandno=resno==0?0:bandno+1;
|
||||
x0b=(band->bandno==1)||(band->bandno==3)?1:0;
|
||||
y0b=(band->bandno==2)||(band->bandno==3)?1:0;
|
||||
|
||||
if (band->bandno==0) {
|
||||
// band border (global)
|
||||
band->x0=int_ceildivpow2(tilec->x0, levelno);
|
||||
band->y0=int_ceildivpow2(tilec->y0, levelno);
|
||||
band->x1=int_ceildivpow2(tilec->x1, levelno);
|
||||
band->y1=int_ceildivpow2(tilec->y1, levelno);
|
||||
} else {
|
||||
// band border (global)
|
||||
band->x0=int_ceildivpow2(tilec->x0-(1<<levelno)*x0b, levelno+1);
|
||||
band->y0=int_ceildivpow2(tilec->y0-(1<<levelno)*y0b, levelno+1);
|
||||
band->x1=int_ceildivpow2(tilec->x1-(1<<levelno)*x0b, levelno+1);
|
||||
band->y1=int_ceildivpow2(tilec->y1-(1<<levelno)*y0b, levelno+1);
|
||||
}
|
||||
|
||||
band->precincts=(tcd_precinct_t*)malloc(res->pw*res->ph*sizeof(tcd_precinct_t));
|
||||
|
||||
for (precno=0; precno<res->pw*res->ph; precno++) {
|
||||
int tlcblkxstart, tlcblkystart, brcblkxend, brcblkyend;
|
||||
int cbgxstart=tlcbgxstart+(precno%res->pw)*(1<<cbgwidthexpn);
|
||||
int cbgystart=tlcbgystart+(precno/res->pw)*(1<<cbgheightexpn);
|
||||
int cbgxend=cbgxstart+(1<<cbgwidthexpn);
|
||||
int cbgyend=cbgystart+(1<<cbgheightexpn);
|
||||
tcd_precinct_t *prc=&band->precincts[precno];
|
||||
// precinct size (global)
|
||||
prc->x0=int_max(cbgxstart, band->x0);
|
||||
prc->y0=int_max(cbgystart, band->y0);
|
||||
prc->x1=int_min(cbgxend, band->x1);
|
||||
prc->y1=int_min(cbgyend, band->y1);
|
||||
|
||||
tlcblkxstart=int_floordivpow2(prc->x0, cblkwidthexpn)<<cblkwidthexpn;
|
||||
tlcblkystart=int_floordivpow2(prc->y0, cblkheightexpn)<<cblkheightexpn;
|
||||
brcblkxend=int_ceildivpow2(prc->x1, cblkwidthexpn)<<cblkwidthexpn;
|
||||
brcblkyend=int_ceildivpow2(prc->y1, cblkheightexpn)<<cblkheightexpn;
|
||||
prc->cw=(brcblkxend-tlcblkxstart)>>cblkwidthexpn;
|
||||
prc->ch=(brcblkyend-tlcblkystart)>>cblkheightexpn;
|
||||
|
||||
prc->cblks=(tcd_cblk_t*)malloc(prc->cw*prc->ch*sizeof(tcd_cblk_t));
|
||||
|
||||
prc->incltree=tgt_create(prc->cw, prc->ch);
|
||||
prc->imsbtree=tgt_create(prc->cw, prc->ch);
|
||||
|
||||
for (cblkno=0; cblkno<prc->cw*prc->ch; cblkno++) {
|
||||
int cblkxstart=tlcblkxstart+(cblkno%prc->cw)*(1<<cblkwidthexpn);
|
||||
int cblkystart=tlcblkystart+(cblkno/prc->cw)*(1<<cblkheightexpn);
|
||||
int cblkxend=cblkxstart+(1<<cblkwidthexpn);
|
||||
int cblkyend=cblkystart+(1<<cblkheightexpn);
|
||||
tcd_cblk_t *cblk=&prc->cblks[cblkno];
|
||||
// code-block size (global)
|
||||
cblk->x0=int_max(cblkxstart, prc->x0);
|
||||
cblk->y0=int_max(cblkystart, prc->y0);
|
||||
cblk->x1=int_min(cblkxend, prc->x1);
|
||||
cblk->y1=int_min(cblkyend, prc->y1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void tcd_free(j2k_image_t *img, j2k_cp_t *cp) {
|
||||
int tileno, compno, resno, bandno, precno;
|
||||
tcd_img=img;
|
||||
tcd_cp=cp;
|
||||
tcd_image.tw=cp->tw;
|
||||
tcd_image.th=cp->th;
|
||||
for (tileno=0; tileno<tcd_image.tw*tcd_image.th; tileno++)
|
||||
{
|
||||
// j2k_tcp_t *tcp=&cp->tcps[curtileno];
|
||||
tcd_tile_t *tile=&tcd_image.tiles[tileno];
|
||||
for (compno=0; compno<tile->numcomps; compno++)
|
||||
{
|
||||
tcd_tilecomp_t *tilec=&tile->comps[compno];
|
||||
for (resno=0; resno<tilec->numresolutions; resno++)
|
||||
{
|
||||
tcd_resolution_t *res=&tilec->resolutions[resno];
|
||||
for (bandno=0; bandno<res->numbands; bandno++)
|
||||
{
|
||||
tcd_band_t *band=&res->bands[bandno];
|
||||
for (precno=0; precno<res->pw*res->ph; precno++)
|
||||
{
|
||||
tcd_precinct_t *prc=&band->precincts[precno];
|
||||
|
||||
if (prc->incltree!=NULL)
|
||||
tgt_destroy(prc->incltree);
|
||||
if (prc->imsbtree!=NULL)
|
||||
tgt_destroy(prc->imsbtree);
|
||||
free(prc->cblks);
|
||||
} // for (precno
|
||||
free(band->precincts);
|
||||
} // for (bandno
|
||||
} // for (resno
|
||||
free(tilec->resolutions);
|
||||
} // for (compno
|
||||
free(tile->comps);
|
||||
} // for (tileno
|
||||
free(tcd_image.tiles);
|
||||
}
|
||||
|
||||
|
||||
int tcd_decode_tile(unsigned char *src, int len, int tileno, info_image_t *imgg) {
|
||||
int l;
|
||||
int eof=0;
|
||||
tcd_tile_t *tile;
|
||||
|
||||
tile = &tcd_image.tiles[tileno];
|
||||
|
||||
l = t2_decode_packets(src, len, tcd_img, tcd_cp, tileno, tile, imgg);
|
||||
|
||||
if (l==-999)
|
||||
{
|
||||
eof=1;
|
||||
fprintf(stderr, "tcd_decode: incomplete bistream\n");
|
||||
}
|
||||
|
||||
if (eof) {
|
||||
longjmp(j2k_error, 1);
|
||||
}
|
||||
|
||||
l=1;
|
||||
return l;
|
||||
}
|
||||
137
indexer_JPIP/tcd.h
Normal file
137
indexer_JPIP/tcd.h
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003, Yannick Verschueren
|
||||
* Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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 __TCD_H
|
||||
#define __TCD_H
|
||||
|
||||
#include "j2k.h"
|
||||
#include "tgt.h"
|
||||
|
||||
typedef struct {
|
||||
int numpasses;
|
||||
int len;
|
||||
unsigned char *data;
|
||||
int maxpasses;
|
||||
int numnewpasses;
|
||||
int newlen;
|
||||
} tcd_seg_t;
|
||||
|
||||
typedef struct {
|
||||
int rate;
|
||||
double distortiondec;
|
||||
} tcd_pass_t;
|
||||
|
||||
typedef struct {
|
||||
int numpasses;
|
||||
int len;
|
||||
unsigned char *data;
|
||||
} tcd_layer_t;
|
||||
|
||||
typedef struct {
|
||||
int x0, y0, x1, y1;
|
||||
int numbps;
|
||||
int numlenbits;
|
||||
int len;
|
||||
int numpasses;
|
||||
int numnewpasses;
|
||||
int numsegs;
|
||||
tcd_seg_t segs[100];
|
||||
unsigned char data[8192];
|
||||
int numpassesinlayers;
|
||||
tcd_layer_t layers[100];
|
||||
int totalpasses;
|
||||
tcd_pass_t passes[100];
|
||||
} tcd_cblk_t;
|
||||
|
||||
typedef struct {
|
||||
int x0, y0, x1, y1;
|
||||
int cw, ch;
|
||||
tcd_cblk_t *cblks;
|
||||
tgt_tree_t *incltree;
|
||||
tgt_tree_t *imsbtree;
|
||||
} tcd_precinct_t;
|
||||
|
||||
typedef struct {
|
||||
int x0, y0, x1, y1;
|
||||
int bandno;
|
||||
tcd_precinct_t *precincts;
|
||||
int numbps;
|
||||
int stepsize;
|
||||
} tcd_band_t;
|
||||
|
||||
typedef struct {
|
||||
int x0, y0, x1, y1;
|
||||
int previous_x0, previous_y0, previous_x1, previous_y1; // usefull for the DWT
|
||||
int cas_col, cas_row; // usefull for the DWT
|
||||
int pw, ph;
|
||||
int numbands;
|
||||
tcd_band_t bands[3];
|
||||
} tcd_resolution_t;
|
||||
|
||||
typedef struct {
|
||||
int x0, y0, x1, y1;
|
||||
int previous_row, previous_col; // usefull for the DWT
|
||||
int numresolutions;
|
||||
tcd_resolution_t *resolutions;
|
||||
int *data;
|
||||
} tcd_tilecomp_t;
|
||||
|
||||
typedef struct {
|
||||
int x0, y0, x1, y1;
|
||||
int numcomps;
|
||||
//int PPT;
|
||||
//int len_ppt;
|
||||
tcd_tilecomp_t *comps;
|
||||
} tcd_tile_t;
|
||||
|
||||
typedef struct {
|
||||
int tw, th;
|
||||
tcd_tile_t *tiles;
|
||||
} tcd_image_t;
|
||||
|
||||
/*
|
||||
* Initialize the tile coder/decoder
|
||||
* img: raw image
|
||||
* cp: coding parameters
|
||||
* imgg: creation of index file
|
||||
*/
|
||||
|
||||
void tcd_init(j2k_image_t *img, j2k_cp_t *cp, info_image_t *imgg);
|
||||
|
||||
void tcd_free(j2k_image_t *img, j2k_cp_t *cp);
|
||||
|
||||
/*
|
||||
* Decode a tile from a buffer into a raw image
|
||||
* src: source buffer
|
||||
* len: length of the source buffer
|
||||
* tileno: number that identifies the tile that will be decoded
|
||||
* imgg : Structure for index file
|
||||
*/
|
||||
int tcd_decode_tile(unsigned char *src, int len, int tileno, info_image_t *imgg);
|
||||
|
||||
#endif
|
||||
170
indexer_JPIP/tgt.c
Normal file
170
indexer_JPIP/tgt.c
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003, Yannick Verschueren
|
||||
* Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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 "tgt.h"
|
||||
#include "bio.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/// <summary>
|
||||
/// Reset tag-tree.
|
||||
/// </summary>
|
||||
void tgt_reset(tgt_tree_t *tree)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<tree->numnodes; i++) {
|
||||
tree->nodes[i].value=999;
|
||||
tree->nodes[i].low=0;
|
||||
tree->nodes[i].known=0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create tag-tree.
|
||||
/// </summary>
|
||||
tgt_tree_t *tgt_create(int numleafsh, int numleafsv)
|
||||
{
|
||||
int nplh[32];
|
||||
int nplv[32];
|
||||
tgt_node_t *node;
|
||||
tgt_node_t *parentnode;
|
||||
tgt_node_t *parentnode0;
|
||||
tgt_tree_t *tree;
|
||||
int i, j, k;
|
||||
int numlvls;
|
||||
int n;
|
||||
|
||||
tree=(tgt_tree_t*)malloc(sizeof(tgt_tree_t));
|
||||
tree->numleafsh=numleafsh;
|
||||
tree->numleafsv=numleafsv;
|
||||
|
||||
numlvls=0;
|
||||
nplh[0]=numleafsh;
|
||||
nplv[0]=numleafsv;
|
||||
tree->numnodes=0;
|
||||
do {
|
||||
n=nplh[numlvls]*nplv[numlvls];
|
||||
nplh[numlvls+1]=(nplh[numlvls]+1)/2;
|
||||
nplv[numlvls+1]=(nplv[numlvls]+1)/2;
|
||||
tree->numnodes+=n;
|
||||
++numlvls;
|
||||
} while (n>1);
|
||||
|
||||
tree->nodes=(tgt_node_t*)malloc(tree->numnodes*sizeof(tgt_node_t));
|
||||
|
||||
node=tree->nodes;
|
||||
parentnode=&tree->nodes[tree->numleafsh*tree->numleafsv];
|
||||
parentnode0=parentnode;
|
||||
|
||||
for (i=0; i<numlvls-1; ++i) {
|
||||
for (j=0; j<nplv[i]; ++j) {
|
||||
k=nplh[i];
|
||||
while (--k>=0) {
|
||||
node->parent=parentnode;
|
||||
++node;
|
||||
if (--k >= 0) {
|
||||
node->parent=parentnode;
|
||||
++node;
|
||||
}
|
||||
++parentnode;
|
||||
}
|
||||
if ((j&1)||j==nplv[i]-1) {
|
||||
parentnode0=parentnode;
|
||||
} else {
|
||||
parentnode=parentnode0;
|
||||
parentnode0+=nplh[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
node->parent=0;
|
||||
|
||||
tgt_reset(tree);
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Destroy tag-tree.
|
||||
/// </summary>
|
||||
void tgt_destroy(tgt_tree_t *t) {
|
||||
free(t->nodes);
|
||||
free(t);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the value of a leaf of the tag-tree.
|
||||
/// </summary>
|
||||
void tgt_setvalue(tgt_tree_t *tree, int leafno, int value) {
|
||||
tgt_node_t *node;
|
||||
node=&tree->nodes[leafno];
|
||||
while (node && node->value>value) {
|
||||
node->value=value;
|
||||
node=node->parent;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decode the value of a leaf of the tag-tree.
|
||||
/// </summary>
|
||||
int tgt_decode(tgt_tree_t *tree, int leafno, int threshold)
|
||||
{
|
||||
tgt_node_t *stk[31];
|
||||
tgt_node_t **stkptr;
|
||||
tgt_node_t *node;
|
||||
int low;
|
||||
|
||||
stkptr=stk;
|
||||
node=&tree->nodes[leafno];
|
||||
while (node->parent) {
|
||||
*stkptr++=node;
|
||||
node=node->parent;
|
||||
}
|
||||
|
||||
low=0;
|
||||
for (;;) {
|
||||
if (low>node->low) {
|
||||
node->low=low;
|
||||
} else {
|
||||
low=node->low;
|
||||
}
|
||||
while (low<threshold && low<node->value) {
|
||||
if (bio_read(1)) {
|
||||
node->value=low;
|
||||
} else {
|
||||
++low;
|
||||
}
|
||||
}
|
||||
node->low=low;
|
||||
if (stkptr==stk) {
|
||||
break;
|
||||
}
|
||||
node=*--stkptr;
|
||||
}
|
||||
|
||||
return (node->value<threshold)?1:0;
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2002, David Janssens
|
||||
* Copyright (c) 2003, Yannick Verschueren
|
||||
* Copyright (c) 2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -28,27 +30,19 @@
|
||||
#define __TGT_H
|
||||
|
||||
typedef struct tgt_node {
|
||||
struct tgt_node *parent;
|
||||
int value;
|
||||
int low;
|
||||
int known;
|
||||
struct tgt_node *parent;
|
||||
int value;
|
||||
int low;
|
||||
int known;
|
||||
} tgt_node_t;
|
||||
|
||||
typedef struct {
|
||||
int numleafsh;
|
||||
int numleafsv;
|
||||
int numnodes;
|
||||
tgt_node_t *nodes;
|
||||
int numleafsh;
|
||||
int numleafsv;
|
||||
int numnodes;
|
||||
tgt_node_t *nodes;
|
||||
} tgt_tree_t;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Reset a tag-tree (set all leaves to 0)
|
||||
* tree: tag-tree to reset
|
||||
*/
|
||||
void tgt_reset(tgt_tree_t * tree);
|
||||
|
||||
/*
|
||||
* Create a tag-tree
|
||||
* numleafsh: width of the array of leafs of the tree
|
||||
@@ -56,11 +50,17 @@ void tgt_reset(tgt_tree_t * tree);
|
||||
*/
|
||||
tgt_tree_t *tgt_create(int numleafsh, int numleafsv);
|
||||
|
||||
/*
|
||||
* Reset a tag-tree (set all leafs to 0)
|
||||
* tree: tag-tree to reset
|
||||
*/
|
||||
void tgt_reset(tgt_tree_t *tree);
|
||||
|
||||
/*
|
||||
* Destroy a tag-tree, liberating memory
|
||||
* tree: tag-tree to destroy
|
||||
*/
|
||||
void tgt_destroy(tgt_tree_t * tree);
|
||||
void tgt_destroy(tgt_tree_t *tree);
|
||||
|
||||
/*
|
||||
* Set the value of a leaf of a tag-tree
|
||||
@@ -68,20 +68,13 @@ void tgt_destroy(tgt_tree_t * tree);
|
||||
* leafno: number that identifies the leaf to modify
|
||||
* value: new value of the leaf
|
||||
*/
|
||||
void tgt_setvalue(tgt_tree_t * tree, int leafno, int value);
|
||||
|
||||
/*
|
||||
* Encode the value of a leaf of the tag-tree up to a given threshold
|
||||
* leafno: number that identifies the leaf to encode
|
||||
* threshold: threshold to use when encoding value of the leaf
|
||||
*/
|
||||
void tgt_encode(tgt_tree_t * tree, int leafno, int threshold);
|
||||
void tgt_setvalue(tgt_tree_t *tree, int leafno, int value);
|
||||
|
||||
/*
|
||||
* Decode the value of a leaf of the tag-tree up to a given threshold
|
||||
* leafno: number that identifies the leaf to decode
|
||||
* threshold: threshold to use when decoding value of the leaf
|
||||
*/
|
||||
int tgt_decode(tgt_tree_t * tree, int leafno, int threshold);
|
||||
int tgt_decode(tgt_tree_t *tree, int leafno, int threshold);
|
||||
|
||||
#endif
|
||||
35
j2kviewer/build.xml
Normal file
35
j2kviewer/build.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<project name="seb_j2kviewer" default="dist" basedir=".">
|
||||
<description>Seb's J2K viewer</description>
|
||||
<property name="src" location="src" />
|
||||
<property name="build" location="build"/>
|
||||
<property name="dist" location="dist" />
|
||||
|
||||
<target name="init">
|
||||
<tstamp/>
|
||||
<mkdir dir="${build}"/>
|
||||
</target>
|
||||
<target name="compile" depends="init">
|
||||
<javac srcdir="${src}" destdir="${build}"/>
|
||||
</target>
|
||||
<target name="dist" depends="compile">
|
||||
<mkdir dir="${dist}"/>
|
||||
<jar jarfile="${dist}/seb_j2kviewer-${DSTAMP}.jar"
|
||||
basedir="${build}" manifest="${dist}/manifest.txt"/>
|
||||
<exec dir="${dist}" executable="ln">
|
||||
<arg line="-sf seb_j2kviewer-${DSTAMP}.jar seb_j2kviewer.jar"/>
|
||||
</exec>
|
||||
</target>
|
||||
<target name="clean">
|
||||
<delete dir="${build}"/>
|
||||
<delete dir="${dist}"/>
|
||||
</target>
|
||||
<target name="test" depends="dist">
|
||||
<exec executable="appletviewer"><arg line="dist.html"/></exec>
|
||||
</target>
|
||||
<target name="build_test" depends="compile">
|
||||
<exec executable="appletviewer"><arg line="compile.html"/></exec>
|
||||
</target>
|
||||
<target name="build_testj" depends="compile">
|
||||
<exec executable="java"><arg line="-classpath build ImageViewer girl"/></exec>
|
||||
</target>
|
||||
</project>
|
||||
212
j2kviewer/src/Exec.java
Normal file
212
j2kviewer/src/Exec.java
Normal file
@@ -0,0 +1,212 @@
|
||||
import java.io.*;
|
||||
|
||||
// This appears in Core Web Programming from
|
||||
// Prentice Hall Publishers, and may be freely used
|
||||
// or adapted. 1997 Marty Hall, hall@apl.jhu.edu.
|
||||
|
||||
/** A class that eases the pain of running external
|
||||
* processes from applications.
|
||||
* Lets you run a program three ways:
|
||||
* <OL>
|
||||
* <LI><B>exec</B>: Execute the command, returning
|
||||
* immediately even if the command is still
|
||||
* running. This would be appropriate
|
||||
* for printing a file.
|
||||
* <LI><B>execWait</B>: Execute the command, but
|
||||
* don't return until the command finishes.
|
||||
* This would be appropriate for
|
||||
* sequential commands where the first depends
|
||||
* on the second having finished (e.g.
|
||||
* <CODE>javac</CODE> followed by
|
||||
* <CODE>java</CODE>).
|
||||
* <LI><B>execPrint</B>: Execute the command and
|
||||
* print the output. This would be appropriate
|
||||
* for the UNIX command <CODE>ls</CODE>.
|
||||
* </OL>
|
||||
* Note that the PATH is not taken into account,
|
||||
* so you must specify the <B>full</B> pathname to
|
||||
* the command, and shell builtin commands
|
||||
* will not work. For instance, on Unix the above
|
||||
* three examples might look like:
|
||||
* <OL>
|
||||
* <LI><PRE>Exec.exec("/usr/ucb/lpr Some-File");</PRE>
|
||||
* <LI><PRE>
|
||||
* Exec.execWait("/usr/local/bin/javac Foo.java");
|
||||
* Exec.execWait("/usr/local/bin/java Foo");
|
||||
* </PRE>
|
||||
* <LI><PRE>Exec.execPrint("/usr/bin/ls -al");</PRE>
|
||||
* </OL>
|
||||
*
|
||||
* @author Marty Hall
|
||||
* (<A HREF="mailto:hall@apl.jhu.edu">
|
||||
* hall@apl.jhu.edu</A>)
|
||||
* @version 1.0 1997
|
||||
*/
|
||||
|
||||
public class Exec {
|
||||
//----------------------------------------------------
|
||||
|
||||
private static boolean verbose = true;
|
||||
|
||||
/** Determines if the Exec class should print which
|
||||
* commands are being executed, and print error
|
||||
* messages if a problem is found. Default is true.
|
||||
*
|
||||
* @param verboseFlag true: print messages.
|
||||
* false: don't.
|
||||
*/
|
||||
|
||||
public static void setVerbose(boolean verboseFlag) {
|
||||
verbose = verboseFlag;
|
||||
}
|
||||
|
||||
/** Will Exec print status messages? */
|
||||
|
||||
public static boolean getVerbose() {
|
||||
return(verbose);
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
/** Starts a process to execute the command. Returns
|
||||
* immediately, even if the new process is still
|
||||
* running.
|
||||
*
|
||||
* @param command The <B>full</B> pathname of the
|
||||
* command to be executed. No shell builtins
|
||||
* (e.g. "cd") or shell meta-chars (e.g. ">")
|
||||
* allowed.
|
||||
* @return false if a problem is known to occur, but
|
||||
* since this returns immediately, problems
|
||||
* aren't usually found in time.
|
||||
* Returns true otherwise.
|
||||
*/
|
||||
|
||||
public static boolean exec(String command) {
|
||||
return(exec(command, false, false));
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
/** Starts a process to execute the command. Waits
|
||||
* for the process to finish before returning.
|
||||
*
|
||||
* @param command The <B>full</B> pathname of the
|
||||
* command to be executed. No shell builtins
|
||||
* or shell meta-chars allowed.
|
||||
* @return false if a problem is known to occur,
|
||||
* either due to an exception or from the
|
||||
* subprocess returning a non-zero value.
|
||||
* Returns true otherwise.
|
||||
*/
|
||||
|
||||
public static boolean execWait(String command) {
|
||||
return(exec(command, false, true));
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
/** Starts a process to execute the command. Prints
|
||||
* all output the command gives.
|
||||
*
|
||||
* @param command The <B>full</B> pathname of the
|
||||
* command to be executed. No shell builtins
|
||||
* or shell meta-chars allowed.
|
||||
* @return false if a problem is known to occur,
|
||||
* either due to an exception or from the
|
||||
* subprocess returning a non-zero value.
|
||||
* Returns true otherwise.
|
||||
*/
|
||||
|
||||
public static boolean execPrint(String command) {
|
||||
return(exec(command, true, false));
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
// This creates a Process object via
|
||||
// Runtime.getRuntime.exec(). Depending on the
|
||||
// flags, it may call waitFor on the process
|
||||
// to avoid continuing until the process terminates,
|
||||
// or open an input stream from the process to read
|
||||
// the results.
|
||||
|
||||
private static boolean exec(String command,
|
||||
boolean printResults,
|
||||
boolean wait) {
|
||||
if (verbose) {
|
||||
printSeparator();
|
||||
System.out.println("Executing '" + command + "'.");
|
||||
}
|
||||
try {
|
||||
// Start running command, returning immediately.
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
|
||||
// Print the output. Since we read until
|
||||
// there is no more input, this causes us
|
||||
// to wait until the process is completed
|
||||
if(printResults) {
|
||||
BufferedInputStream buffer =
|
||||
new BufferedInputStream(p.getInputStream());
|
||||
DataInputStream commandResult =
|
||||
new DataInputStream(buffer);
|
||||
String s = null;
|
||||
try {
|
||||
while ((s = commandResult.readLine()) != null)
|
||||
System.out.println("Output: " + s);
|
||||
commandResult.close();
|
||||
if (p.exitValue() != 0) {
|
||||
if (verbose)
|
||||
printError(command +
|
||||
" -- p.exitValue() != 0");
|
||||
return(false);
|
||||
}
|
||||
// Ignore read errors; they mean process is done
|
||||
} catch (Exception e) {}
|
||||
|
||||
// If you don't print the results, then you
|
||||
// need to call waitFor to stop until the process
|
||||
// is completed
|
||||
} else if (wait) {
|
||||
try {
|
||||
System.out.println(" ");
|
||||
int returnVal = p.waitFor();
|
||||
if (returnVal != 0) {
|
||||
if (verbose)
|
||||
printError(command);
|
||||
return(false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (verbose)
|
||||
printError(command, e);
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (verbose)
|
||||
printError(command, e);
|
||||
return(false);
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
private static void printError(String command,
|
||||
Exception e) {
|
||||
System.out.println("Error doing exec(" +
|
||||
command + "): " + e.getMessage());
|
||||
System.out.println("Did you specify the full " +
|
||||
"pathname?");
|
||||
}
|
||||
|
||||
private static void printError(String command) {
|
||||
System.out.println("Error executing '" +
|
||||
command + "'.");
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
private static void printSeparator() {
|
||||
System.out.println
|
||||
("==============================================");
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
}
|
||||
222
j2kviewer/src/ImageViewer.java
Normal file
222
j2kviewer/src/ImageViewer.java
Normal file
@@ -0,0 +1,222 @@
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.geom.*;
|
||||
import java.net.URL;
|
||||
import javax.swing.border.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
public class ImageViewer extends JApplet
|
||||
{
|
||||
private class zoomLevel {
|
||||
int x1, y1, x2, y2, zf;
|
||||
|
||||
zoomLevel() {}
|
||||
zoomLevel(zoomLevel zl)
|
||||
{
|
||||
x1 = zl.x1;
|
||||
y1 = zl.y1;
|
||||
x2 = zl.x2;
|
||||
y2 = zl.y2;
|
||||
zf = zl.zf;
|
||||
}
|
||||
}
|
||||
|
||||
private BufferedImage bi;
|
||||
private Graphics2D big;
|
||||
private MML myMML;
|
||||
private int iw, ih;
|
||||
private int selected = 0, imgId;
|
||||
private Image img;
|
||||
private PgmImage pgm = new PgmImage();
|
||||
private String cmdline = new String();
|
||||
private static String hostname;
|
||||
private static boolean isApplet = true;
|
||||
private boolean fullRefresh = false;
|
||||
private Point offset = new Point(0,0);
|
||||
private zoomLevel zl = new zoomLevel();
|
||||
private Rectangle rect = new Rectangle();
|
||||
private Stack zoomStack = new Stack();
|
||||
private static String j2kfilename;
|
||||
|
||||
public int getX() { return offset.x; }
|
||||
public int getY() { return offset.y; }
|
||||
public int getWidth() { return iw; }
|
||||
public int getHeight() { return ih; }
|
||||
|
||||
public void destroy()
|
||||
{
|
||||
}
|
||||
|
||||
public void zoomIn()
|
||||
{
|
||||
Dimension asz = this.getSize();
|
||||
int maxzf = 3;
|
||||
int coef = 1;
|
||||
int r;
|
||||
|
||||
cmdline =
|
||||
"/bin/sh get.sh " + j2kfilename + " " + iw
|
||||
+ " " + ih + " " + rect.x + " " + rect.y + " "
|
||||
+ rect.width + " " + rect.height;
|
||||
Exec.execPrint(cmdline);
|
||||
|
||||
rect.x = rect.y = rect.width = rect.height = 0;
|
||||
|
||||
img = pgm.open("out.pgm");
|
||||
|
||||
iw = img.getWidth(this);
|
||||
ih = img.getHeight(this);
|
||||
bi = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB);
|
||||
big = bi.createGraphics();
|
||||
selected = 0;
|
||||
fullRefresh = true;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void zoomOut()
|
||||
{
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
String str;
|
||||
int port;
|
||||
|
||||
imgId = 4;
|
||||
if (isApplet && (((hostname = this.getParameter("hostname")) == null)
|
||||
|| hostname.equals("")))
|
||||
hostname = "localhost";
|
||||
if (!isApplet || ((str = this.getParameter("cmdPort")) == null)) {
|
||||
port = 3000;
|
||||
} else {
|
||||
port = new Integer(str).intValue();
|
||||
}
|
||||
|
||||
this.setSize(512, 512);
|
||||
Dimension asz = this.getSize();
|
||||
zl.x2 = asz.width;
|
||||
zl.y2 = asz.height;
|
||||
|
||||
cmdline =
|
||||
"/bin/sh get.sh " + j2kfilename + " " + asz.width
|
||||
+ " " + asz.height + " " + zl.x1 + " " + zl.y1 + " "
|
||||
+ zl.x2 + " " + zl.y2;
|
||||
Exec.execPrint(cmdline);
|
||||
img = pgm.open("out.pgm");
|
||||
|
||||
iw = img.getWidth(this);
|
||||
ih = img.getHeight(this);
|
||||
|
||||
setBackground(Color.black);
|
||||
bi = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB);
|
||||
big = bi.createGraphics();
|
||||
myMML = new MML(this);
|
||||
addMouseListener(myMML);
|
||||
addMouseMotionListener(myMML);
|
||||
}
|
||||
|
||||
public void setSelected(int state)
|
||||
{
|
||||
if (state != selected) {
|
||||
selected = state;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInsideRect(int x, int y)
|
||||
{
|
||||
return rect.contains(x - offset.x, y - offset.y);
|
||||
}
|
||||
|
||||
public void setRGeom(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
rect.x = Math.min(x1,x2) - offset.x;
|
||||
rect.y = Math.min(y1,y2) - offset.y;
|
||||
rect.width = Math.abs(x2-x1);
|
||||
rect.height = Math.abs(y2-y1);
|
||||
}
|
||||
|
||||
public void paint(Graphics g)
|
||||
{
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
Dimension asz = this.getSize();
|
||||
|
||||
if (fullRefresh) {
|
||||
g2.clearRect(0, 0, asz.width, asz.height);
|
||||
fullRefresh = false;
|
||||
}
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_RENDERING,
|
||||
RenderingHints.VALUE_RENDER_QUALITY);
|
||||
big.setColor(Color.black);
|
||||
offset.x = (int) (asz.width - iw) / 2;
|
||||
offset.y = (int) (asz.height - ih) / 2;
|
||||
big.drawImage(img, 0, 0, this);
|
||||
big.setPaint(Color.red);
|
||||
if ((rect.width > 0) && (rect.height > 0))
|
||||
big.draw(rect);
|
||||
if (selected == 1)
|
||||
shadeExt(big, 0, 0, 0, 64);
|
||||
else if (selected == 2) {
|
||||
shadeExt(big, 0, 0, 0, 255);
|
||||
selected = 1;
|
||||
}
|
||||
g2.drawImage(bi, offset.x, offset.y, this);
|
||||
}
|
||||
|
||||
private void shadeRect(Graphics2D g2, int r, int g, int b, int a)
|
||||
{
|
||||
g2.setPaint(new Color(r, g, b, a));
|
||||
g2.fillRect(rect.x + 1, rect.y + 1, rect.width - 1, rect.height - 1);
|
||||
}
|
||||
|
||||
private void shadeExt(Graphics2D g2, int r, int g, int b, int a)
|
||||
{
|
||||
g2.setPaint(new Color(r, g, b, a));
|
||||
g2.fillRect(0, 0, iw, rect.y); /* _N_ */
|
||||
g2.fillRect(rect.x + rect.width + 1, rect.y,
|
||||
iw - rect.x - rect.width - 1, rect.height + 1); /* E */
|
||||
g2.fillRect(0, rect.y, rect.x, rect.height + 1); /* W */
|
||||
g2.fillRect(0, rect.y + rect.height + 1,
|
||||
iw, ih - rect.y - rect.height - 1); /* _S_ */
|
||||
}
|
||||
|
||||
protected URL getURL(String filename)
|
||||
{
|
||||
URL codeBase = this.getCodeBase();
|
||||
URL url = null;
|
||||
|
||||
try {
|
||||
url = new URL(codeBase, filename);
|
||||
} catch (java.net.MalformedURLException e) {
|
||||
System.out.println("Couldn't create image: badly specified URL");
|
||||
return null;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
public static void main(String s[])
|
||||
{
|
||||
if (s.length > 0)
|
||||
j2kfilename = s[0];
|
||||
else
|
||||
j2kfilename = "girl";
|
||||
System.out.println(j2kfilename);
|
||||
isApplet = false;
|
||||
JFrame f = new JFrame("ImageViewer");
|
||||
f.addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {System.exit(0);}
|
||||
});
|
||||
JApplet applet = new ImageViewer();
|
||||
f.getContentPane().add("Center", applet);
|
||||
applet.init();
|
||||
f.pack();
|
||||
f.setSize(new Dimension(550,550));
|
||||
f.show();
|
||||
}
|
||||
}
|
||||
85
j2kviewer/src/MML.java
Normal file
85
j2kviewer/src/MML.java
Normal file
@@ -0,0 +1,85 @@
|
||||
import java.awt.event.*;
|
||||
|
||||
class MML implements MouseMotionListener, MouseListener
|
||||
{
|
||||
public void mouseExited(MouseEvent e) {}
|
||||
public void mouseEntered(MouseEvent e) {}
|
||||
public void mouseClicked(MouseEvent e) {}
|
||||
|
||||
private ImageViewer applet;
|
||||
private int x1, y1, x2, y2, zf, btn;
|
||||
private boolean zoomrq;
|
||||
|
||||
public MML(ImageViewer iv)
|
||||
{
|
||||
x1 = y1 = -1;
|
||||
applet = iv;
|
||||
zoomrq = false;
|
||||
zf = 0;
|
||||
}
|
||||
|
||||
private boolean isInside(int x, int y)
|
||||
{
|
||||
x -= applet.getX();
|
||||
y -= applet.getY();
|
||||
return (x >= 0) && (x < applet.getWidth())
|
||||
&& (y >= 0) && (y < applet.getHeight());
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e)
|
||||
{
|
||||
btn = e.getButton();
|
||||
if (applet.isInsideRect(e.getX(), e.getY())) {
|
||||
applet.setSelected(2);
|
||||
applet.repaint();
|
||||
zoomrq = true;
|
||||
} else {
|
||||
applet.setRGeom(0, 0, 0, 0);
|
||||
applet.setSelected(0);
|
||||
applet.repaint();
|
||||
x1 = y1 = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e)
|
||||
{
|
||||
if (zoomrq && (e.getButton() == 1)) {
|
||||
applet.zoomIn();
|
||||
zoomrq = false;
|
||||
} else if (e.getButton() == 3) {
|
||||
applet.zoomOut();
|
||||
zoomrq = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseMoved(MouseEvent e)
|
||||
{
|
||||
applet.setSelected(applet.isInsideRect(e.getX(), e.getY()) ? 1 : 0);
|
||||
}
|
||||
|
||||
public void mouseDragged(MouseEvent e)
|
||||
{
|
||||
String str;
|
||||
|
||||
if (btn == 1) {
|
||||
x2 = e.getX();
|
||||
y2 = e.getY();
|
||||
|
||||
applet.setSelected(0);
|
||||
zoomrq = false;
|
||||
|
||||
if (isInside(x2, y2)) {
|
||||
str = "[IN ]";
|
||||
if (x1 == -1) {
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
} else {
|
||||
applet.setRGeom(x1, y1, x2, y2);
|
||||
applet.repaint();
|
||||
}
|
||||
} else {
|
||||
str = "[OUT]";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
93
j2kviewer/src/PgmImage.java
Normal file
93
j2kviewer/src/PgmImage.java
Normal file
@@ -0,0 +1,93 @@
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
class PgmImage extends Component
|
||||
{
|
||||
private Socket s;
|
||||
private BufferedReader in;
|
||||
private int x, y;
|
||||
|
||||
PgmImage()
|
||||
{
|
||||
}
|
||||
|
||||
private String read()
|
||||
{
|
||||
try { return in.readLine(); }
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Image open(String filename)
|
||||
{
|
||||
String str;
|
||||
Pattern pat;
|
||||
Matcher mat;
|
||||
int bytes, width, height, depth;
|
||||
FileInputStream fis;
|
||||
|
||||
try {
|
||||
in = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
fis = new FileInputStream(
|
||||
new File(filename))));
|
||||
|
||||
pat = Pattern.compile("^P5$");
|
||||
mat = pat.matcher(str = read());
|
||||
mat.matches();
|
||||
pat = Pattern.compile("^(\\d+) (\\d+)$");
|
||||
mat = pat.matcher(str = read());
|
||||
mat.matches();
|
||||
x = new Integer(mat.group(1)).intValue();
|
||||
y = new Integer(mat.group(2)).intValue();
|
||||
width = x;
|
||||
height = y;
|
||||
depth = 1;
|
||||
pat = Pattern.compile("^255$");
|
||||
mat = pat.matcher(str = read());
|
||||
mat.matches();
|
||||
bytes = x*y;
|
||||
char[] buf = new char[bytes];
|
||||
int r, offset = 0;
|
||||
while (bytes > 0) {
|
||||
try { r = in.read(buf, offset, bytes); offset += r; bytes -= r; }
|
||||
catch (IOException e) { e.printStackTrace(); }
|
||||
}
|
||||
int[] buf2 = new int[buf.length];
|
||||
if (depth == 3) {
|
||||
for (int i = 0; i < buf.length/3; ++i)
|
||||
buf2[i] = 0xFF << 24 | buf[3*i] << 16 | buf[3*i+1] << 8 | buf[3*i+2];
|
||||
} else {
|
||||
for (int i = 0; i < buf.length; ++i)
|
||||
buf2[i] = 0xFF << 24 | buf[i] << 16 | buf[i] << 8 | buf[i];
|
||||
}
|
||||
fis.close();
|
||||
return createImage(new MemoryImageSource(width, height, buf2, 0, width));
|
||||
} catch (IOException e) { e.printStackTrace(); }
|
||||
return null;
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
}
|
||||
|
||||
public boolean bye()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getXOffset()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getYOffset()
|
||||
{
|
||||
return y;
|
||||
}
|
||||
}
|
||||
273
jp3d/DllJp3dVM.dsp
Executable file
273
jp3d/DllJp3dVM.dsp
Executable file
@@ -0,0 +1,273 @@
|
||||
# Microsoft Developer Studio Project File - Name="DllOpenJPEG" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=DllOpenJPEG - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "DllOpenJPEG.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "DllOpenJPEG.mak" CFG="DllOpenJPEG - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "DllOpenJPEG - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "DllOpenJPEG - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "DllOpenJPEG - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DLLOPENJPEG_EXPORTS" /Yu"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OPJ_EXPORTS" /FD /c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40c /d "NDEBUG"
|
||||
# ADD RSC /l 0x40c /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release/OpenJPEG.dll"
|
||||
# Begin Special Build Tool
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Cmds=if not exist dist mkdir dist copy libopenjpeg\openjpeg.h dist copy Release\OpenJPEG.dll dist copy Release\OpenJPEG.lib dist
|
||||
# End Special Build Tool
|
||||
|
||||
!ELSEIF "$(CFG)" == "DllOpenJPEG - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DLLOPENJPEG_EXPORTS" /Yu"stdafx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OPJ_EXPORTS" /FD /GZ /c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40c /d "_DEBUG"
|
||||
# ADD RSC /l 0x40c /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Debug/OpenJPEGd.dll" /pdbtype:sept
|
||||
# Begin Special Build Tool
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Cmds=if not exist dist mkdir dist copy libopenjpeg\openjpeg.h dist copy Debug\OpenJPEGd.dll dist copy Debug\OpenJPEGd.lib dist
|
||||
# End Special Build Tool
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "DllOpenJPEG - Win32 Release"
|
||||
# Name "DllOpenJPEG - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\bio.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\cio.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\dwt.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\event.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\image.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\j2k.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\j2k_lib.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\jp2.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\jpt.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\mct.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\mqc.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\openjpeg.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\pi.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\raw.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\t1.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\t2.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\tcd.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\tgt.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\bio.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\cio.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\dwt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\event.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\fix.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\image.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\int.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\j2k.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\j2k_lib.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\jp2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\jpt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\mct.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\mqc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\openjpeg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\opj_includes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\pi.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\raw.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\t1.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\t2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\tcd.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libopenjpeg\tgt.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\OpenJPEG.rc
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
BIN
jp3d/DllJp3dVM.ncb
Executable file
BIN
jp3d/DllJp3dVM.ncb
Executable file
Binary file not shown.
42
jpwl/encoder/jpwlenc/image_to_j2k.sln → jp3d/DllJp3dVM.sln
Normal file → Executable file
42
jpwl/encoder/jpwlenc/image_to_j2k.sln → jp3d/DllJp3dVM.sln
Normal file → Executable file
@@ -1,21 +1,21 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "image_to_j2k", "image_to_j2k.vcproj", "{F67C0B66-E4AD-42E6-8D70-CF7F00BB31BE}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{F67C0B66-E4AD-42E6-8D70-CF7F00BB31BE}.Debug.ActiveCfg = Debug|Win32
|
||||
{F67C0B66-E4AD-42E6-8D70-CF7F00BB31BE}.Debug.Build.0 = Debug|Win32
|
||||
{F67C0B66-E4AD-42E6-8D70-CF7F00BB31BE}.Release.ActiveCfg = Release|Win32
|
||||
{F67C0B66-E4AD-42E6-8D70-CF7F00BB31BE}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DllOpenJPEG", "DllJp3dVM.vcproj", "{790A6CE5-CE92-4A59-ADF7-54A92760BD6C}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{790A6CE5-CE92-4A59-ADF7-54A92760BD6C}.Debug.ActiveCfg = Debug|Win32
|
||||
{790A6CE5-CE92-4A59-ADF7-54A92760BD6C}.Debug.Build.0 = Debug|Win32
|
||||
{790A6CE5-CE92-4A59-ADF7-54A92760BD6C}.Release.ActiveCfg = Release|Win32
|
||||
{790A6CE5-CE92-4A59-ADF7-54A92760BD6C}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
BIN
jp3d/DllJp3dVM.suo
Executable file
BIN
jp3d/DllJp3dVM.suo
Executable file
Binary file not shown.
558
jpwl/encoder/jpwlenc/image_to_j2k.vcproj → jp3d/DllJp3dVM.vcproj
Normal file → Executable file
558
jpwl/encoder/jpwlenc/image_to_j2k.vcproj → jp3d/DllJp3dVM.vcproj
Normal file → Executable file
@@ -1,280 +1,278 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="image_to_j2k"
|
||||
ProjectGUID="{F67C0B66-E4AD-42E6-8D70-CF7F00BB31BE}"
|
||||
SccProjectName=""
|
||||
SccLocalPath="">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../libopenjpeg"
|
||||
PreprocessorDefinitions="_DEBUG,DONT_HAVE_GETOPT,WIN32,_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\Debug/image_to_j2k.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
BrowseInformation="1"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/MACHINE:I386"
|
||||
AdditionalDependencies="odbc32.lib odbccp32.lib"
|
||||
OutputFile=".\Debug/image_to_j2k.exe"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\Debug/image_to_j2k.pdb"
|
||||
SubSystem="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/image_to_j2k.tlb"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="2060"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="../libopenjpeg"
|
||||
PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE,DONT_HAVE_GETOPT"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\Release/image_to_j2k.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/MACHINE:I386"
|
||||
AdditionalDependencies="odbc32.lib odbccp32.lib"
|
||||
OutputFile=".\Release/image_to_j2k.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\Release/image_to_j2k.pdb"
|
||||
SubSystem="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/image_to_j2k.tlb"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="2060"
|
||||
AdditionalIncludeDirectories="../libopenjpeg"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\bio.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\cio.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\convert.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\dwt.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\fix.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\compat\getopt.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\image_to_j2k.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\int.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\j2k.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\jp2.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\jpt.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\jpw.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\mct.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\mqc.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\pi.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\raw.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\rs.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\t1.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\t2.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\tcd.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\tgt.c">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl">
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\bio.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\cio.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\convert.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\dwt.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\fix.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\compat\getopt.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\int.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\j2k.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\jp2.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\jpt.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\jpw.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\mct.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\mqc.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\openjpeg.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\pi.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\raw.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\rs.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\t1.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\t2.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\tcd.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\libopenjpeg\tgt.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="DllOpenJP3D"
|
||||
ProjectGUID="{790A6CE5-CE92-4A59-ADF7-54A92760BD6C}"
|
||||
SccProjectName=""
|
||||
SccLocalPath="">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OPJ_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\Release/DllOpenJPEG.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="Release/OpenJP3D.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\Release/OpenJP3D.pdb"
|
||||
ImportLibrary=".\Release/OpenJP3D.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Release/DllOpenJPEG.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="if not exist bin mkdir bin
|
||||
copy libjp3dvm\openjpeg.h bin
|
||||
copy Release\OpenJP3D.dll bin
|
||||
copy Release\OpenJP3D.lib bin
|
||||
"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1036"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;OPJ_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
PrecompiledHeaderFile=".\Debug/DllOpenJPEG.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="Debug/OpenJP3D.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\Debug/OpenJP3D.pdb"
|
||||
ImportLibrary=".\Debug/OpenJP3D.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Debug/DllOpenJPEG.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="if not exist bin mkdir bin
|
||||
copy libjp3dvm\openjpeg.h bin
|
||||
copy Debug\OpenJP3D.dll bin
|
||||
"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1034"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\bio.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\cio.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\dwt.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\event.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\jp3d.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\jp3d_lib.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\mct.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\mqc.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\openjpeg.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\pi.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\raw.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\t1.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\t1_3d.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\t2.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\tcd.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\tgt.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\volume.c">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl">
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\bio.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\cio.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\dirent.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\dwt.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\event.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\fix.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\int.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\jp3d.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\jp3d_lib.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\mct.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\mqc.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\openjpeg.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\opj_includes.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\pi.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\raw.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\t1.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\t1_3d.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\t2.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\tcd.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\tgt.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\volume.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
69
jpwl/encoder_02/codec/convert.h → jp3d/LICENSE.txt
Normal file → Executable file
69
jpwl/encoder_02/codec/convert.h → jp3d/LICENSE.txt
Normal file → Executable file
@@ -1,39 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2002-2003, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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 "j2k.h"
|
||||
|
||||
int bmptoimage(char *filename, j2k_image_t * img, int subsampling_dx,
|
||||
int subsampling_dy, int Dim[2]);
|
||||
|
||||
int pgxtoimage(char *filename, j2k_image_t * img, int tdy,
|
||||
int subsampling_dx, int subsampling_dy, int Dim[2],
|
||||
j2k_cp_t cp);
|
||||
|
||||
int pnmtoimage(char *filename, j2k_image_t * img, int subsampling_dx,
|
||||
int subsampling_dy, int Dim[2]);
|
||||
/*
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
|
||||
* Copyright (c) 2005, HervŽ Drolon, FreeImage Team
|
||||
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* Copyright (c) 2006, Mónica Díez, Image Processing Laboratory (LPI) - University of Valladolid, Spain
|
||||
* 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.
|
||||
*/
|
||||
BIN
jp3d/LibJp3dVM.ncb
Executable file
BIN
jp3d/LibJp3dVM.ncb
Executable file
Binary file not shown.
42
jpwl/decoder/jpwldec/j2k_to_image.sln → jp3d/LibJp3dVM.sln
Normal file → Executable file
42
jpwl/decoder/jpwldec/j2k_to_image.sln → jp3d/LibJp3dVM.sln
Normal file → Executable file
@@ -1,21 +1,21 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "j2k_to_image", "j2k_to_image.vcproj", "{3C09E691-8555-47D1-B1E6-D411A6314AC8}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{3C09E691-8555-47D1-B1E6-D411A6314AC8}.Debug.ActiveCfg = Debug|Win32
|
||||
{3C09E691-8555-47D1-B1E6-D411A6314AC8}.Debug.Build.0 = Debug|Win32
|
||||
{3C09E691-8555-47D1-B1E6-D411A6314AC8}.Release.ActiveCfg = Release|Win32
|
||||
{3C09E691-8555-47D1-B1E6-D411A6314AC8}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibJp3dVM", "LibJp3dVM.vcproj", "{6F3FB035-8F4E-4794-B091-0F0A20223BE7}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Debug.ActiveCfg = Debug|Win32
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Debug.Build.0 = Debug|Win32
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Release.ActiveCfg = Release|Win32
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
BIN
jp3d/LibJp3dVM.suo
Executable file
BIN
jp3d/LibJp3dVM.suo
Executable file
Binary file not shown.
249
jp3d/LibJp3dVM.vcproj
Executable file
249
jp3d/LibJp3dVM.vcproj
Executable file
@@ -0,0 +1,249 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="LibJp3dVM"
|
||||
ProjectGUID="{6F3FB035-8F4E-4794-B091-0F0A20223BE7}"
|
||||
SccProjectName=""
|
||||
SccLocalPath="">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
InlineFunctionExpansion="0"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;OPJ_STATIC"
|
||||
StringPooling="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\Release/LibJp3dVM.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile=".\Release\LibJp3dVM.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="if not exist bin mkdir bin
|
||||
copy Release\LibJp3dVM.lib bin
|
||||
copy libjp3dvm\openjpeg.h bin
|
||||
"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1036"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;OPJ_STATIC"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
PrecompiledHeaderFile=".\Debug/LibJp3dVM.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile=".\Debug\LibJp3dVM.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="if not exist bin mkdir bin
|
||||
copy Debug\LibJp3dVM.lib bin
|
||||
copy libjp3dvm\openjpeg.h bin
|
||||
"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1036"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\bio.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\cio.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\dwt.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\event.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\jp3d.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\jp3d_lib.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\mct.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\mqc.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\openjpeg.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\pi.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\raw.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\t1.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\t1_3d.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\t2.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\tcd.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\tgt.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\volume.c">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl">
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\bio.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\cio.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\dirent.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\dwt.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\event.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\fix.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\int.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\jp3d.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\jp3d_lib.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\mct.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\mqc.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\openjpeg.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\opj_includes.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\pi.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\raw.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\t1.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\t1_3d.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\t2.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\tcd.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\tgt.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libjp3dvm\volume.h">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
72
jp3d/Makefile
Executable file
72
jp3d/Makefile
Executable file
@@ -0,0 +1,72 @@
|
||||
# Linux makefile for OpenJPEG
|
||||
|
||||
VER_MAJOR = 1
|
||||
VER_MINOR = 0.0
|
||||
|
||||
SRCS = ./libopenjpeg/bio.c ./libopenjpeg/cio.c ./libopenjpeg/dwt.c ./libopenjpeg/event.c ./libopenjpeg/image.c ./libopenjpeg/j2k.c ./libopenjpeg/j2k_lib.c ./libopenjpeg/jp2.c ./libopenjpeg/jpt.c ./libopenjpeg/mct.c ./libopenjpeg/mqc.c ./libopenjpeg/openjpeg.c ./libopenjpeg/pi.c ./libopenjpeg/raw.c ./libopenjpeg/t1.c ./libopenjpeg/t2.c ./libopenjpeg/tcd.c ./libopenjpeg/tgt.c
|
||||
INCLS = ./libopenjpeg/bio.h ./libopenjpeg/cio.h ./libopenjpeg/dwt.h ./libopenjpeg/event.h ./libopenjpeg/fix.h ./libopenjpeg/image.h ./libopenjpeg/int.h ./libopenjpeg/j2k.h ./libopenjpeg/j2k_lib.h ./libopenjpeg/jp2.h ./libopenjpeg/jpt.h ./libopenjpeg/mct.h ./libopenjpeg/mqc.h ./libopenjpeg/openjpeg.h ./libopenjpeg/pi.h ./libopenjpeg/raw.h ./libopenjpeg/t1.h ./libopenjpeg/t2.h ./libopenjpeg/tcd.h ./libopenjpeg/tgt.h ./libopenjpeg/opj_includes.h
|
||||
INCLUDE = -Ilibopenjpeg
|
||||
|
||||
# General configuration variables:
|
||||
CC = gcc
|
||||
AR = ar
|
||||
|
||||
INSTALLDIR = /usr/lib
|
||||
|
||||
# Converts cr/lf to just lf
|
||||
DOS2UNIX = dos2unix
|
||||
|
||||
COMPILERFLAGS = -O3
|
||||
LIBRARIES = -lstdc++
|
||||
|
||||
MODULES = $(SRCS:.c=.o)
|
||||
CFLAGS = $(COMPILERFLAGS) $(INCLUDE)
|
||||
|
||||
TARGET = openjpeg
|
||||
STATICLIB = lib$(TARGET).a
|
||||
SHAREDLIB = lib$(TARGET)-$(VER_MAJOR).$(VER_MINOR).so
|
||||
LIBNAME = lib$(TARGET).so.$(VER_MAJOR)
|
||||
|
||||
|
||||
|
||||
default: all
|
||||
|
||||
all: dist
|
||||
|
||||
dist: OpenJPEG
|
||||
mkdir dist
|
||||
cp *.a dist/
|
||||
cp *.so dist/
|
||||
cp libopenjpeg/openjpeg.h dist/
|
||||
|
||||
dos2unix:
|
||||
@$(DOS2UNIX) $(SRCS) $(INCLS)
|
||||
|
||||
OpenJPEG: $(STATICLIB) $(SHAREDLIB)
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(STATICLIB): $(MODULES)
|
||||
$(AR) r $@ $(MODULES)
|
||||
|
||||
$(SHAREDLIB): $(MODULES)
|
||||
$(CC) -s -shared -Wl,-soname,$(LIBNAME) -o $@ $(MODULES) $(LIBRARIES)
|
||||
|
||||
install:
|
||||
install -m 644 -o root -g root $(STATICLIB) $(INSTALLDIR)
|
||||
install -m 755 -o root -g root $(SHAREDLIB) $(INSTALLDIR)
|
||||
ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(LIBNAME)
|
||||
ldconfig
|
||||
|
||||
clean:
|
||||
rm -rf core dist/ u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB) $(LIBNAME)
|
||||
|
||||
osx:
|
||||
make -f Makefile.osx
|
||||
|
||||
osxinstall:
|
||||
make -f Makefile.osx install
|
||||
|
||||
osxclean:
|
||||
make -f Makefile.osx clean
|
||||
285
jp3d/README.txt
Executable file
285
jp3d/README.txt
Executable file
@@ -0,0 +1,285 @@
|
||||
===============================================================================
|
||||
JPEG2000 Part 10 (ISO/IEC 15444-10 JP3D) Verification Model
|
||||
|
||||
Version 1.1
|
||||
===============================================================================
|
||||
|
||||
|
||||
1. Scope
|
||||
================
|
||||
|
||||
This document describes the installation and the use of the JP3D VM decoder and encoder under several operating systems (Linux, Unix, Windows, ...). Version 1.1 contains a complete JPEG 2000 Part 10 encoder, as well as a decoder.
|
||||
The supported functionalities are compliant with the JPEG2000 part 10 algorithm as described in the WD 6.0.
|
||||
The provided encoder and the decoder are compatible also with the International standard IS 15444-1 (core coding system).
|
||||
This implementation has been developped from OpenJPEG implementation of JPEG2000 standard, and for this reason it is written in C language.
|
||||
|
||||
If you find some bugs or if you have problems using the encoder/decoder, please send an e-mail to jp3d@lpi.tel.uva.es
|
||||
|
||||
2. Installing the code
|
||||
======================================================
|
||||
|
||||
- After decompressing the zip file provided, you should find
|
||||
at least the following files in the created 'jp3d_vm' directory:
|
||||
|
||||
* libjp3dvm - This directory contains all library related code
|
||||
* codec - This directory contains all codec related code
|
||||
* tcltk - This directory contains the API scripts
|
||||
* README - The file you are reading
|
||||
* LICENCE - Copyright statement of the JP3D VM software
|
||||
|
||||
2.1. Compiling the source code in Windows
|
||||
-------------------------------------------
|
||||
|
||||
This version has been compiled with Visual Studio 2003 using
|
||||
the projects included in the distribution:
|
||||
|
||||
* LibJp3dVM.vcproj - Creates the library with all the JP3D functionalities
|
||||
* jp3d_vm_enc.vcproj - Test encoder
|
||||
* jp3d_vm_dec.vcproj - Test decoder
|
||||
|
||||
2.2. Compiling the source code in Unix-like systems
|
||||
-------------------------------------------
|
||||
|
||||
Library compilation
|
||||
------------------------
|
||||
This version of the library has been tested under the following OS:
|
||||
- Fedora Core
|
||||
|
||||
The installation process is as simple as this :
|
||||
1) Enter the 'jp3d_vm' directory
|
||||
2) Build the distribution :
|
||||
make
|
||||
make install
|
||||
3) Clean all files produced during the build process
|
||||
make clean
|
||||
|
||||
Codec compilation
|
||||
------------------------
|
||||
Once you've built the library, you should compile the JP3D codec.
|
||||
|
||||
1) Go to the 'codec' directory
|
||||
2) Build the encoder and decoder programs:
|
||||
|
||||
gcc convert.c volume_to_jp3d.c -o jp3d_vm_enc -I ../libjp3dvm/ -lm -ljp3dvm
|
||||
gcc convert.c jp3d_to_volume.c -o jp3d_vm_dec -I ../libjp3dvm/ -lm -ljp3dvm
|
||||
|
||||
Note: You should add '-L ../libjp3dvm/' to those lines if you
|
||||
did not use the 'install' target (and the 'clean' target neither...).
|
||||
|
||||
3. Running the JP3D VM
|
||||
====================================================
|
||||
|
||||
3.1. JP3D ENCODER
|
||||
====================================================
|
||||
|
||||
Required arguments
|
||||
------------------------
|
||||
|
||||
* Input file(s): -i Involume [*.bin, *.pgx]
|
||||
|
||||
Specifies the volume to compress. Accepted formats are *.BIN (raw binary data) or *.PGX files.
|
||||
Both formats need some particular settings:
|
||||
|
||||
a) BIN format. As it has no header, volume characteristics will be obtained from a .IMG file. Its location will be specified through the following argument:
|
||||
-m Involumeinfo.IMG
|
||||
This file shall have the following structure, with the appropiate value in each case (bit per voxel, color map, dimensions in X,Y,Z):
|
||||
o Bpp %d
|
||||
o Color Map %d
|
||||
o Dimensions %d %d %d
|
||||
|
||||
b) PGX format. Program will consider it as a volume slice. In order to denote a volume through a sequence of slices, you can define the input filename with the common pattern of the set of PGX files followed by a dash (as a wildcard character for the sequence numbers).
|
||||
|
||||
* Output file: -o Outfile [*.jp3d, *j2k]
|
||||
|
||||
Specifies the name of the file where the codestream will be saved.
|
||||
Part 1 compliant codestream will be created when an outfile has .j2k format.
|
||||
|
||||
Options
|
||||
--------
|
||||
|
||||
* Rate values : -r 20,10,5
|
||||
This option offers the possibility to define the compression rate to apply.
|
||||
Each value is a factor of compression (i.e. 20 : 1) and will generate a different quality layer. A lossless compression will be signified by the value 1.
|
||||
NOTE : The order used to define the different levels of compression is important and must be from left to right in descending order.
|
||||
|
||||
* Quality values : -q 30,35,40
|
||||
This option offers the possibility to define the quality level to achieve. Each value is a psnr, to be given in dB, and represents a quality layer.
|
||||
NOTE : The order used to define the different psnr-values is important and must be from left to right in ascending order.
|
||||
|
||||
|
||||
* Number of resolutions : -n 3,3,2
|
||||
This option offers the possibility to define the number of resolution levels computed for each dimension of the volume through the discret wavelet transform (DWT). Resolution in axial dimension can have a different value than in horizontal and vertical cases, but must be lower.
|
||||
DEFAULT VALUE : 3,3,1
|
||||
|
||||
|
||||
* Switch modes : -M 3
|
||||
This option offers the possibility to use a mode switch during the encoding process:
|
||||
o BYPASS(LAZY) [1]
|
||||
o RESET [2]
|
||||
o RESTART(TERMALL) [4]
|
||||
o VSC [8]
|
||||
o ERTERM(SEGTERM) [16]
|
||||
o SEGMARK(SEGSYM) [32]
|
||||
o 3D_CONTEXT [64]
|
||||
For several mode switch just sum corresponding values: i.e. -M 38 => RESTART(4) + RESET(2) + SEGMARK(32)
|
||||
DEFAULT VALUE: 0
|
||||
|
||||
|
||||
* Progression order : -p LRCP
|
||||
This option offers the possibility to specify the progression order. Possible progression orders are : LRCP, RLCP, RPCL, PCRL and CPRL.
|
||||
DEFAULT VALUE: LRCP.
|
||||
|
||||
|
||||
* Code-block size : -b 32,32,32
|
||||
This option offers the possibility to define the size of the code-block. The dimension must respect the constraint defined in the JPEG-2000 standard. The maximum value autorized is 64x64x64.
|
||||
DEFAULT VALUE: 64,64,64
|
||||
|
||||
|
||||
* Precinct size : -c [128,128,128],[128,128,128],...
|
||||
This option offers the possibility to define the size of the precincts at each resolution. Multiple records may be supplied, in which case the first record refers to the highest resolution level and subsequent records to lower resolution levels. The last specified record is right-shifted for each remaining lower resolution levels.
|
||||
NOTE : specified values must be power of 2.
|
||||
DEFAULT VALUE: 2^15 x 2^15 x 2^15
|
||||
|
||||
|
||||
* Tile size : -t 512,512,512
|
||||
This option offers the possibility to divide the volume in several tiles. The three values define the width, the heigth and the depth of the tile respectivily.
|
||||
DEFAULT VALUE: Volume dimensions (one tile)
|
||||
|
||||
|
||||
* Subsampling factor : -s 2,2,2
|
||||
This option offers the possibility to apply a subsampling factor for X, Y and Z axis. Value higher than 2 can be a source of error !
|
||||
DEFAULT VALUE: 1,1,1
|
||||
|
||||
|
||||
* SOP marker before each packet : -SOP
|
||||
This option offers the possibility to add a specific marker before each packet. It is the marker SOP (Start of packet). If the option is not used no SOP marker will be added.
|
||||
|
||||
|
||||
* EPH marker after each packet header : -EPH
|
||||
This option offers the possibility to add a specific marker at the head of each packet header. It is the marker EPH (End of packet Header). If the option is not used no EPH marker will be added.
|
||||
|
||||
|
||||
* Offset of the volume origin : -d 150,300,10
|
||||
This option offers the possibility to move the origine of the volume in X, Y and/or Z axis. The division in tile could be modified as the anchor point for tiling will be different than the volume origin.
|
||||
NOTE : the offset of the volume can not be higher than the tile dimension if the tile option is used.
|
||||
DEFAULT VALUE: 0,0,0
|
||||
|
||||
|
||||
* Offset of the tile origin : -T 100,75,5
|
||||
This option offers the possibility to move the anchor point of the volume in X, Y and/or Z axis.
|
||||
NOTE : the tile anchor point can not be on the volume area.
|
||||
DEFAULT VALUE: 0,0,0
|
||||
|
||||
|
||||
* Display the help menu : -help
|
||||
This option displays on screen the content of this page
|
||||
|
||||
Additional options
|
||||
----------------------------------
|
||||
|
||||
* Encoding information file: -x index_name.idx
|
||||
This option offers the possibility to create a text file with some structured information generated through the encoding. The name of the file must be specified, with .idx extension. The information structure is the following:
|
||||
o Volume size:
|
||||
+ VolW + VolH + VolD
|
||||
o Progression Order:
|
||||
+ Prog
|
||||
o Tile size:
|
||||
+ TileW + TileH + TileD
|
||||
o Number of components:
|
||||
+ NumComp
|
||||
o Number of layers:
|
||||
+ NumLayer
|
||||
o Number of decompositions (=(number of resolutions - 1)):
|
||||
+ NumDWTx + NumDWTy + NumDWTz
|
||||
o Precinct size:
|
||||
+ [Precinct_width(NumDWT),Precinct_height(NumDWT),Precinct_depth(NumDWT)]
|
||||
+ [Precinct_width(NumDWT-1),Precinct_height(NumDWT-1),Precinct_depth(NumDWT-1)]
|
||||
+ ...
|
||||
+ [Precinct_width(0),Precinct_height(0),Precinct_depth(0)]
|
||||
o Main Header end position:
|
||||
+ MH_EndPos
|
||||
o Codestream size:
|
||||
+ CSSize
|
||||
o Tile 0 information:
|
||||
+ TileNum (0)
|
||||
+ StartPos
|
||||
+ TileHeader_EndPos
|
||||
+ EndPos
|
||||
+ TotalDisto (this is the sum of the distortion reductions brought by each packet belonging to this tile)
|
||||
+ NumPix (this is the number of pixels in the tile)
|
||||
+ MaxMSE (=TotalDisto/NumPix)
|
||||
o Tile1 information:
|
||||
+ TileNum (1)
|
||||
+ ...
|
||||
o ...
|
||||
o Tile N information:
|
||||
+ TileNum (N)
|
||||
+ ...
|
||||
o Packet 0 from Tile 0 information:
|
||||
+ PackNum (0)
|
||||
+ TileNum (0)
|
||||
+ LayerNum
|
||||
+ ResNum
|
||||
+ CompNum
|
||||
+ PrecNum
|
||||
+ StartPos
|
||||
+ EndPos
|
||||
+ Disto (distortion reduction brought by this packet)
|
||||
o Packet 1 from Tile 0 information:
|
||||
+ PackNum (1)
|
||||
+ ...
|
||||
o ...
|
||||
o Packet M from Tile 0 information
|
||||
o Packet 0 from Tile 1 information
|
||||
o ...
|
||||
o Packet M from Tile N information
|
||||
o Maximum distortion reduction on the whole volume:
|
||||
+ MaxDisto
|
||||
o Total distortion on the whole volume (sum of the distortion reductions from all packets in the volume):
|
||||
+ TotalDisto
|
||||
|
||||
3.2. JP3D DECODER
|
||||
====================================================
|
||||
|
||||
Required arguments
|
||||
------------------------
|
||||
|
||||
* Infile : -i compressed file
|
||||
Currently accepts JP3D and J2K-files. The file type is identified based on its suffix (*.jp3d, *.j2k).
|
||||
|
||||
|
||||
* Outfile(s) : -o decompressed file(s)
|
||||
Currently accepts BIN-files and PGX-files. Binary data is written to the file (not ascii).
|
||||
If a BIN-file is defined, decoder will create automatically the volume characteristic file appending a .IMG extension to the provided output filename.
|
||||
If a PGX-file is defined, decoder will understand this as a file pattern, appending corresponding indice from 0 to the number of decoded slices.
|
||||
NOTE : There will be as many output files as there are components: an indice starting from 0 will then be appended to the output filename, just before the extension.
|
||||
|
||||
|
||||
Options available
|
||||
------------------------
|
||||
|
||||
* Reduce factor : -r 1,1,0
|
||||
Set the number of highest resolution levels to be discarded in each dimension. The decoded volume size is effectively divided by 2 to the power of the number of discarded levels.
|
||||
NOTE : The reduce factor is limited by the smallest total number of decomposition levels among tiles.
|
||||
|
||||
|
||||
* Layer number : -l 2
|
||||
Set the maximum number of quality layers to decode. If there are less quality layers than the specified number, all the quality layers are decoded.
|
||||
|
||||
|
||||
* Performance comparisons : -O original-file
|
||||
This option offers the possibility to compute some quality results for the decompressed volume, like the PSNR value achieved or the global SSIM value. Needs the original file in order to compare with the new one.
|
||||
NOTE: Only valid when -r option is 0,0,0 (both original and decompressed volumes have same resolutions)
|
||||
NOTE: If original file is .BIN file, the volume characteristics file shall be defined with the -m option.
|
||||
(i.e. -O original-BIN-file -m original-IMG-file)
|
||||
|
||||
|
||||
* Byte order (Big-endian / Little-endian) : -BE
|
||||
This option offers the possibility to save the decompressed volume with a predefined byte order.
|
||||
DEFAULT VALUE: Little-endian
|
||||
|
||||
|
||||
* Display the help menu : -help
|
||||
This option displays on screen the content of this page
|
||||
|
||||
|
||||
BIN
jp3d/bin/LibJp3dVM.lib
Executable file
BIN
jp3d/bin/LibJp3dVM.lib
Executable file
Binary file not shown.
BIN
jp3d/bin/OpenJP3D.dll
Executable file
BIN
jp3d/bin/OpenJP3D.dll
Executable file
Binary file not shown.
BIN
jp3d/bin/jp3d_vm_dec.exe
Executable file
BIN
jp3d/bin/jp3d_vm_dec.exe
Executable file
Binary file not shown.
BIN
jp3d/bin/jp3d_vm_enc.exe
Executable file
BIN
jp3d/bin/jp3d_vm_enc.exe
Executable file
Binary file not shown.
715
jp3d/bin/openjpeg.h
Executable file
715
jp3d/bin/openjpeg.h
Executable file
@@ -0,0 +1,715 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
|
||||
* Copyright (c) 2005, Herv<72> Drolon, FreeImage Team
|
||||
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* Copyright (c) 2006, M<>nica D<>ez Garc<72>a, Image Processing Laboratory, University of Valladolid, Spain
|
||||
* 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 OPENJPEG_H
|
||||
#define OPENJPEG_H
|
||||
|
||||
#define OPENJPEG_VERSION "1.0.0"
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
Compiler directives
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
#if defined(OPJ_STATIC) || !(defined(WIN32) || defined(__WIN32__))
|
||||
#define OPJ_API
|
||||
#define OPJ_CALLCONV
|
||||
#else
|
||||
#define OPJ_CALLCONV __stdcall
|
||||
/*
|
||||
The following ifdef block is the standard way of creating macros which make exporting
|
||||
from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
|
||||
symbol defined on the command line. this symbol should not be defined on any project
|
||||
that uses this DLL. This way any other project whose source files include this file see
|
||||
OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols
|
||||
defined with this macro as being exported.
|
||||
*/
|
||||
#ifdef OPJ_EXPORTS
|
||||
#define OPJ_API __declspec(dllexport)
|
||||
#else
|
||||
#define OPJ_API __declspec(dllimport)
|
||||
#endif /* OPJ_EXPORTS */
|
||||
#endif /* !OPJ_STATIC || !WIN32 */
|
||||
|
||||
#ifndef __cplusplus
|
||||
#if defined(HAVE_STDBOOL_H)
|
||||
/*
|
||||
The C language implementation does correctly provide the standard header
|
||||
file "stdbool.h".
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#else
|
||||
/*
|
||||
The C language implementation does not provide the standard header file
|
||||
"stdbool.h" as required by ISO/IEC 9899:1999. Try to compensate for this
|
||||
braindamage below.
|
||||
*/
|
||||
#if !defined(bool)
|
||||
#define bool int
|
||||
#endif
|
||||
#if !defined(true)
|
||||
#define true 1
|
||||
#endif
|
||||
#if !defined(false)
|
||||
#define false 0
|
||||
#endif
|
||||
#endif
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
Useful constant definitions
|
||||
==========================================================
|
||||
*/
|
||||
#ifndef MAX_SLICES
|
||||
#define MAX_SLICES 300 /**< Maximum allowed size for slices */
|
||||
#endif /* MAX_PATH */
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 260 /**< Maximum allowed size for filenames */
|
||||
#endif /* MAX_PATH */
|
||||
|
||||
#define J3D_MAXRLVLS 32 /**< Number of maximum resolution level authorized */
|
||||
#define J3D_MAXBANDS (7*J3D_MAXRLVLS + 1) /**< Number of maximum sub-band linked to number of resolution level */
|
||||
|
||||
#define TINY 1.0E-20
|
||||
/*
|
||||
==========================================================
|
||||
enum definitions
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
#define J2K_CFMT 0
|
||||
#define J3D_CFMT 1
|
||||
#define LSE_CFMT 2
|
||||
|
||||
#define BIN_DFMT 0
|
||||
#define PGX_DFMT 1
|
||||
#define IMG_DFMT 2
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
/** Progression order */
|
||||
typedef enum PROG_ORDER {
|
||||
/**< place-holder */
|
||||
PROG_UNKNOWN = -1,
|
||||
/**< layer-resolution-component-precinct order */
|
||||
LRCP = 0,
|
||||
/**< resolution-layer-component-precinct order */
|
||||
RLCP = 1,
|
||||
/**< resolution-precinct-component-layer order */
|
||||
RPCL = 2,
|
||||
/**< precinct-component-resolution-layer order */
|
||||
PCRL = 3,
|
||||
/**< component-precinct-resolution-layer order */
|
||||
CPRL = 4
|
||||
} OPJ_PROG_ORDER;
|
||||
|
||||
/**
|
||||
Supported volume color spaces
|
||||
*/
|
||||
typedef enum COLOR_SPACE {
|
||||
/**< place-holder */
|
||||
CLRSPC_UNKNOWN = -1,
|
||||
/**< sRGB */
|
||||
CLRSPC_SRGB = 1,
|
||||
/**< grayscale */
|
||||
CLRSPC_GRAY = 2,
|
||||
/**< YUV */
|
||||
CLRSPC_SYCC = 3
|
||||
} OPJ_COLOR_SPACE;
|
||||
|
||||
/**
|
||||
Supported codec
|
||||
*/
|
||||
typedef enum CODEC_FORMAT {
|
||||
/**< place-holder */
|
||||
CODEC_UNKNOWN = -1,
|
||||
/**< JPEG-2000 codestream : read/write */
|
||||
CODEC_J2K = 0,
|
||||
/**< JPEG-2000 Part 10 file format : read/write */
|
||||
CODEC_J3D = 1
|
||||
} OPJ_CODEC_FORMAT;
|
||||
|
||||
/**
|
||||
Supported entropy coding algorithms
|
||||
*/
|
||||
typedef enum ENTROPY_CODING {
|
||||
/**< place-holder */
|
||||
ENCOD_UNKNOWN = -1,
|
||||
/**< 2D EBCOT encoding */
|
||||
ENCOD_2EB = 0,
|
||||
/**< 3D EBCOT encoding */
|
||||
ENCOD_3EB = 1,
|
||||
/**< Golomb-Rice coding with 2D context */
|
||||
ENCOD_2GR = 2,
|
||||
/**< Golomb-Rice coding with 3D context */
|
||||
ENCOD_3GR = 3
|
||||
} OPJ_ENTROPY_CODING;
|
||||
|
||||
/**
|
||||
Supported transforms
|
||||
*/
|
||||
typedef enum TRANSFORM {
|
||||
/**< place-holder */
|
||||
TRF_UNKNOWN = -1,
|
||||
/**< 2D DWT, no transform in axial dim */
|
||||
TRF_2D_DWT = 0,
|
||||
/**< 3D DWT */
|
||||
TRF_3D_DWT = 1,
|
||||
/**< 3D prediction*/
|
||||
TRF_3D_RLS = 2,
|
||||
TRF_3D_LSE = 3
|
||||
} OPJ_TRANSFORM;
|
||||
/*
|
||||
==========================================================
|
||||
event manager typedef definitions
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
Callback function prototype for events
|
||||
@param msg Event message
|
||||
@param client_data
|
||||
*/
|
||||
typedef void (*opj_msg_callback) (const char *msg, void *client_data);
|
||||
|
||||
/**
|
||||
Message handler object
|
||||
used for
|
||||
<ul>
|
||||
<li>Error messages
|
||||
<li>Warning messages
|
||||
<li>Debugging messages
|
||||
</ul>
|
||||
*/
|
||||
typedef struct opj_event_mgr {
|
||||
/** Error message callback if available, NULL otherwise */
|
||||
opj_msg_callback error_handler;
|
||||
/** Warning message callback if available, NULL otherwise */
|
||||
opj_msg_callback warning_handler;
|
||||
/** Debug message callback if available, NULL otherwise */
|
||||
opj_msg_callback info_handler;
|
||||
} opj_event_mgr_t;
|
||||
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
codec typedef definitions
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
Progression order changes
|
||||
*/
|
||||
typedef struct opj_poc {
|
||||
int resno0, compno0;
|
||||
int layno1, resno1, compno1;
|
||||
OPJ_PROG_ORDER prg;
|
||||
int tile;
|
||||
char progorder[4];
|
||||
} opj_poc_t;
|
||||
|
||||
|
||||
/**
|
||||
Compression parameters
|
||||
*/
|
||||
typedef struct opj_cparameters {
|
||||
/** size of tile: tile_size_on = false (not in argument) or = true (in argument) */
|
||||
bool tile_size_on;
|
||||
/** XTOsiz */
|
||||
int cp_tx0;
|
||||
/** YTOsiz */
|
||||
int cp_ty0;
|
||||
/** ZTOsiz */
|
||||
int cp_tz0;
|
||||
|
||||
/** XTsiz */
|
||||
int cp_tdx;
|
||||
/** YTsiz */
|
||||
int cp_tdy;
|
||||
/** ZTsiz */
|
||||
int cp_tdz;
|
||||
|
||||
/** allocation by rate/distortion */
|
||||
int cp_disto_alloc;
|
||||
/** allocation by fixed layer */
|
||||
int cp_fixed_alloc;
|
||||
/** add fixed_quality */
|
||||
int cp_fixed_quality;
|
||||
/** fixed layer */
|
||||
int *cp_matrice;
|
||||
/** number of layers */
|
||||
int tcp_numlayers;
|
||||
/** rates for successive layers */
|
||||
float tcp_rates[100];
|
||||
/** psnr's for successive layers */
|
||||
float tcp_distoratio[100];
|
||||
/** comment for coding */
|
||||
char *cp_comment;
|
||||
/** csty : coding style */
|
||||
int csty;
|
||||
/** DC offset (DCO) */
|
||||
int dcoffset;
|
||||
/** progression order (default LRCP) */
|
||||
OPJ_PROG_ORDER prog_order;
|
||||
/** progression order changes */
|
||||
opj_poc_t POC[J3D_MAXRLVLS-1];
|
||||
/** number of progression order changes (POC), default to 0 */
|
||||
int numpocs;
|
||||
|
||||
/** number of resolutions */
|
||||
int numresolution[3];
|
||||
/** initial code block width, height and depth, default to 64 */
|
||||
int cblock_init[3];
|
||||
/** mode switch (1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL) 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)) */
|
||||
int mode;
|
||||
|
||||
/** 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default) */
|
||||
int irreversible;
|
||||
/** WT from ATK, default to 0 (false), no of atk used */
|
||||
int atk_wt[3];
|
||||
/** region of interest: affected component in [0..3], -1 means no ROI */
|
||||
int roi_compno;
|
||||
/** region of interest: upshift value */
|
||||
int roi_shift;
|
||||
|
||||
/* number of precinct size specifications */
|
||||
int res_spec;
|
||||
/** initial precinct width */
|
||||
int prct_init[3][J3D_MAXRLVLS];
|
||||
|
||||
/** transform format 0: 0: 2DWT, 1: 2D1P, 2: 3DWT, 3: 3RLS */
|
||||
OPJ_TRANSFORM transform_format;
|
||||
/** output file format 0: 2EB, 1: 3EB, 2: 2GR, 3: 3GR, 4: GRI */
|
||||
OPJ_ENTROPY_CODING encoding_format;
|
||||
|
||||
/**@name command line encoder parameters (not used inside the library) */
|
||||
/*@{*/
|
||||
char infile[MAX_PATH]; /** input file name */
|
||||
char outfile[MAX_PATH]; /** output file name */
|
||||
char imgfile[MAX_PATH]; /** IMG file name for BIN volumes*/
|
||||
int index_on; /** creation of an index file, default to 0 (false) */
|
||||
char index[MAX_PATH]; /** index file name */
|
||||
|
||||
int volume_offset_x0; /** subvolume encoding: origin volume offset in x, y and z direction */
|
||||
int volume_offset_y0;
|
||||
int volume_offset_z0;
|
||||
|
||||
int subsampling_dx; /** subsampling value for dx */
|
||||
int subsampling_dy;
|
||||
int subsampling_dz;
|
||||
|
||||
int decod_format; /** input file format 0: BIN, 1: PGX */
|
||||
int cod_format; /** output file format 0: JP3D */
|
||||
/*@}*/
|
||||
} opj_cparameters_t;
|
||||
|
||||
/**
|
||||
Decompression parameters
|
||||
*/
|
||||
typedef struct opj_dparameters {
|
||||
/** Set the number of highest resolution levels to be discarded. if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, volume is decoded to the full resolution */
|
||||
int cp_reduce[3];
|
||||
/** Set the maximum number of quality layers to decode. if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */
|
||||
int cp_layer;
|
||||
int bigendian;
|
||||
|
||||
/**@name command line encoder parameters (not used inside the library) */
|
||||
/*@{*/
|
||||
/** input file name */
|
||||
char infile[MAX_PATH];
|
||||
/** output file name */
|
||||
char outfile[MAX_PATH];
|
||||
/** IMG file name for BIN volumes*/
|
||||
char imgfile[MAX_PATH];
|
||||
/** Original file name for PSNR measures*/
|
||||
char original[MAX_PATH];
|
||||
/** input file format 0: J2K, 1: JP3D */
|
||||
int decod_format;
|
||||
/** input file format 0: BIN, 1: PGM */
|
||||
int cod_format;
|
||||
/** original file format 0: BIN, 1: PGM */
|
||||
int orig_format;
|
||||
/*@}*/
|
||||
} opj_dparameters_t;
|
||||
|
||||
/** Common fields between JPEG-2000 compression and decompression master structs. */
|
||||
#define opj_common_fields \
|
||||
opj_event_mgr_t *event_mgr; /**< pointer to the event manager */\
|
||||
void * client_data; /**< Available for use by application */\
|
||||
bool is_decompressor; /**< So common code can tell which is which */\
|
||||
OPJ_CODEC_FORMAT codec_format; /**< selected codec */\
|
||||
OPJ_ENTROPY_CODING encoding_format; /**< selected entropy coding */\
|
||||
OPJ_TRANSFORM transform_format; /**< selected transform */\
|
||||
void *j3d_handle /**< pointer to the J3D codec */
|
||||
|
||||
/* Routines that are to be used by both halves of the library are declared
|
||||
* to receive a pointer to this structure. There are no actual instances of
|
||||
* opj_common_struct_t, only of opj_cinfo_t and opj_dinfo_t.
|
||||
*/
|
||||
typedef struct opj_common_struct {
|
||||
opj_common_fields; /* Fields common to both master struct types */
|
||||
/* Additional fields follow in an actual opj_cinfo_t or
|
||||
* opj_dinfo_t. All three structs must agree on these
|
||||
* initial fields! (This would be a lot cleaner in C++.)
|
||||
*/
|
||||
} opj_common_struct_t;
|
||||
|
||||
typedef opj_common_struct_t * opj_common_ptr;
|
||||
|
||||
/**
|
||||
Compression context info
|
||||
*/
|
||||
typedef struct opj_cinfo {
|
||||
/** Fields shared with opj_dinfo_t */
|
||||
opj_common_fields;
|
||||
/* other specific fields go here */
|
||||
} opj_cinfo_t;
|
||||
|
||||
/**
|
||||
Decompression context info
|
||||
*/
|
||||
typedef struct opj_dinfo {
|
||||
/** Fields shared with opj_cinfo_t */
|
||||
opj_common_fields;
|
||||
/* other specific fields go here */
|
||||
} opj_dinfo_t;
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
I/O stream typedef definitions
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* Stream open flags.
|
||||
*/
|
||||
/** The stream was opened for reading. */
|
||||
#define OPJ_STREAM_READ 0x0001
|
||||
/** The stream was opened for writing. */
|
||||
#define OPJ_STREAM_WRITE 0x0002
|
||||
|
||||
/**
|
||||
Byte input-output stream (CIO)
|
||||
*/
|
||||
typedef struct opj_cio {
|
||||
/** codec context */
|
||||
opj_common_ptr cinfo;
|
||||
/** open mode (read/write) either OPJ_STREAM_READ or OPJ_STREAM_WRITE */
|
||||
int openmode;
|
||||
/** pointer to the start of the buffer */
|
||||
unsigned char *buffer;
|
||||
/** buffer size in bytes */
|
||||
int length;
|
||||
/** pointer to the start of the stream */
|
||||
unsigned char *start;
|
||||
/** pointer to the end of the stream */
|
||||
unsigned char *end;
|
||||
/** pointer to the current position */
|
||||
unsigned char *bp;
|
||||
} opj_cio_t;
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
volume typedef definitions
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
Defines a single volume component
|
||||
*/
|
||||
typedef struct opj_volume_comp {
|
||||
/** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
|
||||
int dx;
|
||||
/** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
|
||||
int dy;
|
||||
/** ZRsiz: vertical separation of a sample of ith component with respect to the reference grid */
|
||||
int dz;
|
||||
/** data width */
|
||||
int w;
|
||||
/** data height */
|
||||
int h;
|
||||
/** data length : no of slices */
|
||||
int l;
|
||||
/** x component offset compared to the whole volume */
|
||||
int x0;
|
||||
/** y component offset compared to the whole volume */
|
||||
int y0;
|
||||
/** z component offset compared to the whole volume */
|
||||
int z0;
|
||||
/** precision */
|
||||
int prec;
|
||||
/** volume depth in bits */
|
||||
int bpp;
|
||||
/** DC offset (15444-2) */
|
||||
int dcoffset;
|
||||
/** signed (1) / unsigned (0) */
|
||||
int sgnd;
|
||||
/** BE byte order (1) / LE byte order (0) */
|
||||
int bigendian;
|
||||
/** number of decoded resolution */
|
||||
int resno_decoded[3];
|
||||
/** number of division by 2 of the out volume compared to the original size of volume */
|
||||
int factor[3];
|
||||
/** volume component data */
|
||||
int *data;
|
||||
} opj_volume_comp_t;
|
||||
|
||||
/**
|
||||
Defines volume data and characteristics
|
||||
*/
|
||||
typedef struct opj_volume {
|
||||
/** XOsiz: horizontal offset from the origin of the reference grid to the left side of the volume area */
|
||||
int x0;
|
||||
/** YOsiz: vertical offset from the origin of the reference grid to the top side of the volume area */
|
||||
int y0;
|
||||
/** ZOsiz: vertical offset from the origin of the reference grid to the top side of the volume area */
|
||||
int z0;
|
||||
/** Xsiz: width of the reference grid */
|
||||
int x1;
|
||||
/** Ysiz: height of the reference grid */
|
||||
int y1;
|
||||
/** Zsiz: length of the reference grid */
|
||||
int z1;
|
||||
/** number of components in the volume */
|
||||
int numcomps;
|
||||
/** number of slices in the volume */
|
||||
int numslices;
|
||||
/** color space: sRGB, Greyscale or YUV */
|
||||
OPJ_COLOR_SPACE color_space;
|
||||
/** volume components */
|
||||
opj_volume_comp_t *comps;
|
||||
} opj_volume_t;
|
||||
|
||||
/**
|
||||
Component parameters structure used by the opj_volume_create function
|
||||
*/
|
||||
typedef struct opj_volume_comptparm {
|
||||
/** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
|
||||
int dx;
|
||||
/** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
|
||||
int dy;
|
||||
/** ZRsiz: axial separation of a sample of ith component with respect to the reference grid */
|
||||
int dz;
|
||||
/** data width */
|
||||
int w;
|
||||
/** data height */
|
||||
int h;
|
||||
/** data length */
|
||||
int l;
|
||||
/** x component offset compared to the whole volume */
|
||||
int x0;
|
||||
/** y component offset compared to the whole volume */
|
||||
int y0;
|
||||
/** z component offset compared to the whole volume */
|
||||
int z0;
|
||||
/** precision */
|
||||
int prec;
|
||||
/** volume depth in bits */
|
||||
int bpp;
|
||||
/** signed (1) / unsigned (0) */
|
||||
int sgnd;
|
||||
/** DC offset*/
|
||||
int dcoffset;
|
||||
/** BE byte order (1) / LE byte order (0) */
|
||||
int bigendian;
|
||||
} opj_volume_cmptparm_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
openjpeg version
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
OPJ_API const char * OPJ_CALLCONV opj_version();
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
volume functions definitions
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
Create an volume
|
||||
@param numcmpts number of components
|
||||
@param cmptparms components parameters
|
||||
@param clrspc volume color space
|
||||
@return returns a new volume structure if successful, returns NULL otherwise
|
||||
*/
|
||||
OPJ_API opj_volume_t* OPJ_CALLCONV opj_volume_create(int numcmpts, opj_volume_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
|
||||
|
||||
/**
|
||||
Deallocate any resources associated with an volume
|
||||
@param volume volume to be destroyed
|
||||
*/
|
||||
OPJ_API void OPJ_CALLCONV opj_volume_destroy(opj_volume_t *volume);
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
stream functions definitions
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
Open and allocate a memory stream for read / write.
|
||||
On reading, the user must provide a buffer containing encoded data. The buffer will be
|
||||
wrapped by the returned CIO handle.
|
||||
On writing, buffer parameters must be set to 0: a buffer will be allocated by the library
|
||||
to contain encoded data.
|
||||
@param cinfo Codec context info
|
||||
@param buffer Reading: buffer address. Writing: NULL
|
||||
@param length Reading: buffer length. Writing: 0
|
||||
@return Returns a CIO handle if successful, returns NULL otherwise
|
||||
*/
|
||||
OPJ_API opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length);
|
||||
|
||||
/**
|
||||
Close and free a CIO handle
|
||||
@param cio CIO handle to free
|
||||
*/
|
||||
OPJ_API void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio);
|
||||
|
||||
/**
|
||||
Get position in byte stream
|
||||
@param cio CIO handle
|
||||
@return Returns the position in bytes
|
||||
*/
|
||||
OPJ_API int OPJ_CALLCONV cio_tell(opj_cio_t *cio);
|
||||
/**
|
||||
Set position in byte stream
|
||||
@param cio CIO handle
|
||||
@param pos Position, in number of bytes, from the beginning of the stream
|
||||
*/
|
||||
OPJ_API void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos);
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
event manager functions definitions
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
OPJ_API opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context);
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
codec functions definitions
|
||||
==========================================================
|
||||
*/
|
||||
/**
|
||||
Creates a J3D decompression structure
|
||||
@param format Decoder to select
|
||||
@return Returns a handle to a decompressor if successful, returns NULL otherwise
|
||||
*/
|
||||
OPJ_API opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format);
|
||||
/**
|
||||
Destroy a decompressor handle
|
||||
@param dinfo decompressor handle to destroy
|
||||
*/
|
||||
OPJ_API void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo);
|
||||
/**
|
||||
Set decoding parameters to default values
|
||||
@param parameters Decompression parameters
|
||||
*/
|
||||
OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters);
|
||||
/**
|
||||
Setup the decoder decoding parameters using user parameters.
|
||||
Decoding parameters are returned in j3d->cp.
|
||||
@param dinfo decompressor handle
|
||||
@param parameters decompression parameters
|
||||
*/
|
||||
OPJ_API void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters);
|
||||
/**
|
||||
Decode an volume from a JPEG-2000 codestream
|
||||
@param dinfo decompressor handle
|
||||
@param cio Input buffer stream
|
||||
@return Returns a decoded volume if successful, returns NULL otherwise
|
||||
*/
|
||||
OPJ_API opj_volume_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio);
|
||||
/**
|
||||
Creates a J3D/JP2 compression structure
|
||||
@param format Coder to select
|
||||
@return Returns a handle to a compressor if successful, returns NULL otherwise
|
||||
*/
|
||||
OPJ_API opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
|
||||
/**
|
||||
Destroy a compressor handle
|
||||
@param cinfo compressor handle to destroy
|
||||
*/
|
||||
OPJ_API void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo);
|
||||
/**
|
||||
Set encoding parameters to default values, that means :
|
||||
<ul>
|
||||
<li>Lossless
|
||||
<li>1 tile
|
||||
<li>Size of precinct : 2^15 x 2^15 (means 1 precinct)
|
||||
<li>Size of code-block : 64 x 64
|
||||
<li>Number of resolutions: 6
|
||||
<li>No SOP marker in the codestream
|
||||
<li>No EPH marker in the codestream
|
||||
<li>No sub-sampling in x or y direction
|
||||
<li>No mode switch activated
|
||||
<li>Progression order: LRCP
|
||||
<li>No index file
|
||||
<li>No ROI upshifted
|
||||
<li>No offset of the origin of the volume
|
||||
<li>No offset of the origin of the tiles
|
||||
<li>Reversible DWT 5-3
|
||||
</ul>
|
||||
@param parameters Compression parameters
|
||||
*/
|
||||
OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
|
||||
/**
|
||||
Setup the encoder parameters using the current volume and using user parameters.
|
||||
@param cinfo compressor handle
|
||||
@param parameters compression parameters
|
||||
@param volume input filled volume
|
||||
*/
|
||||
OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_volume_t *volume);
|
||||
/**
|
||||
Encode an volume into a JPEG-2000 codestream
|
||||
@param cinfo compressor handle
|
||||
@param cio Output buffer stream
|
||||
@param volume Volume to encode
|
||||
@param index Name of the index file if required, NULL otherwise
|
||||
@return Returns true if successful, returns false otherwise
|
||||
*/
|
||||
OPJ_API bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_volume_t *volume, char *index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* OPENJPEG_H */
|
||||
997
jp3d/codec/convert.c
Executable file
997
jp3d/codec/convert.c
Executable file
@@ -0,0 +1,997 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
|
||||
* Copyright (c) 2005, Herv<72> Drolon, FreeImage Team
|
||||
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* Copyright (c) 2006, M<>nica D<>ez Garc<72>a, Image Processing Laboratory, University of Valladolid, Spain
|
||||
* 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 "openjpeg.h"
|
||||
#ifdef WIN32
|
||||
#include "dirent.h"
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
|
||||
|
||||
void dump_volume(FILE *fd, opj_volume_t * vol) {
|
||||
int compno;
|
||||
fprintf(fd, "volume {\n");
|
||||
fprintf(fd, " x0=%d, y0=%d, z0=%d, x1=%d, y1=%d, z1=%d\n", vol->x0, vol->y0, vol->z0,vol->x1, vol->y1, vol->z1);
|
||||
fprintf(fd, " numcomps=%d\n", vol->numcomps);
|
||||
for (compno = 0; compno < vol->numcomps; compno++) {
|
||||
opj_volume_comp_t *comp = &vol->comps[compno];
|
||||
fprintf(fd, " comp %d {\n", compno);
|
||||
fprintf(fd, " dx=%d, dy=%d, dz=%d\n", comp->dx, comp->dy, comp->dz);
|
||||
fprintf(fd, " prec=%d\n", comp->prec);
|
||||
fprintf(fd, " sgnd=%d\n", comp->sgnd);
|
||||
fprintf(fd, " }\n");
|
||||
}
|
||||
fprintf(fd, "}\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Get logarithm of an integer and round downwards.
|
||||
*
|
||||
* log2(a)
|
||||
*/
|
||||
static int int_floorlog2(int a) {
|
||||
int l;
|
||||
for (l = 0; a > 1; l++) {
|
||||
a >>= 1;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
/*
|
||||
* Divide an integer by a power of 2 and round upwards.
|
||||
*
|
||||
* a divided by 2^b
|
||||
*/
|
||||
static int int_ceildivpow2(int a, int b) {
|
||||
return (a + (1 << b) - 1) >> b;
|
||||
}
|
||||
|
||||
/*
|
||||
* Divide an integer and round upwards.
|
||||
*
|
||||
* a divided by b
|
||||
*/
|
||||
static int int_ceildiv(int a, int b) {
|
||||
return (a + b - 1) / b;
|
||||
}
|
||||
|
||||
|
||||
/* -->> -->> -->> -->>
|
||||
|
||||
PGX IMAGE FORMAT
|
||||
|
||||
<<-- <<-- <<-- <<-- */
|
||||
|
||||
|
||||
unsigned char readuchar(FILE * f)
|
||||
{
|
||||
unsigned char c1;
|
||||
fread(&c1, 1, 1, f);
|
||||
return c1;
|
||||
}
|
||||
|
||||
unsigned short readushort(FILE * f, int bigendian)
|
||||
{
|
||||
unsigned char c1, c2;
|
||||
fread(&c1, 1, 1, f);
|
||||
fread(&c2, 1, 1, f);
|
||||
if (bigendian)
|
||||
return (c1 << 8) + c2;
|
||||
else
|
||||
return (c2 << 8) + c1;
|
||||
}
|
||||
|
||||
unsigned int readuint(FILE * f, int bigendian)
|
||||
{
|
||||
unsigned char c1, c2, c3, c4;
|
||||
fread(&c1, 1, 1, f);
|
||||
fread(&c2, 1, 1, f);
|
||||
fread(&c3, 1, 1, f);
|
||||
fread(&c4, 1, 1, f);
|
||||
if (bigendian)
|
||||
return (c1 << 24) + (c2 << 16) + (c3 << 8) + c4;
|
||||
else
|
||||
return (c4 << 24) + (c3 << 16) + (c2 << 8) + c1;
|
||||
}
|
||||
/*****************************************/
|
||||
static unsigned short ShortSwap(unsigned short v)
|
||||
{
|
||||
unsigned char c1, c2;
|
||||
c1 = v & 0xff;
|
||||
c2 = (v >> 8) & 0xff;
|
||||
return (c1 << 8) + c2;
|
||||
}
|
||||
|
||||
static unsigned int LongSwap (unsigned int i)
|
||||
{
|
||||
unsigned char b1, b2, b3, b4;
|
||||
b1 = i & 255;
|
||||
b2 = ( i >> 8 ) & 255;
|
||||
b3 = ( i>>16 ) & 255;
|
||||
b4 = ( i>>24 ) & 255;
|
||||
return ((int)b1 << 24) + ((int)b2 << 16) + ((int)b3 << 8) + b4;
|
||||
}
|
||||
/*****************************************/
|
||||
|
||||
opj_volume_t* pgxtovolume(char *relpath, opj_cparameters_t *parameters) {
|
||||
|
||||
FILE *f = NULL;
|
||||
int w, h, prec;
|
||||
unsigned long offset;
|
||||
int i, s, numcomps, maxvalue, sliceno, slicepos, maxslice = 0;
|
||||
|
||||
OPJ_COLOR_SPACE color_space;
|
||||
opj_volume_cmptparm_t cmptparm; // maximum of 1 component
|
||||
opj_volume_t * volume = NULL;
|
||||
|
||||
char endian1,endian2,sign;
|
||||
char signtmp[32];
|
||||
char temp[32];
|
||||
opj_volume_comp_t *comp = NULL;
|
||||
|
||||
DIR *dirp;
|
||||
struct dirent *direntp;
|
||||
|
||||
char *tmp = NULL, *tmp2 = NULL,
|
||||
*point = NULL, *pgx = NULL;
|
||||
char tmpdirpath[MAX_PATH];
|
||||
char dirpath[MAX_PATH];
|
||||
char pattern[MAX_PATH];
|
||||
char pgxfiles[MAX_SLICES][MAX_PATH];
|
||||
int pgxslicepos[MAX_SLICES];
|
||||
char tmpno[3];
|
||||
|
||||
numcomps = 1;
|
||||
color_space = CLRSPC_GRAY;
|
||||
sliceno = 0;
|
||||
maxvalue = 0;
|
||||
memset(pgxfiles, 0, MAX_SLICES * MAX_PATH * sizeof(char));
|
||||
memset(&cmptparm, 0, sizeof(opj_volume_cmptparm_t));
|
||||
|
||||
/* Separaci<63>n del caso de un <20>nico slice frente al de muchos */
|
||||
if ((tmp = strrchr(relpath,'-')) == NULL){
|
||||
//fprintf(stdout,"[INFO] A volume of only one slice....\n");
|
||||
sliceno = 1;
|
||||
maxslice = 1;
|
||||
strcpy(pgxfiles[0],relpath);
|
||||
|
||||
} else {
|
||||
//Fetch only the path
|
||||
strcpy(tmpdirpath,relpath);
|
||||
if ((tmp = strrchr(tmpdirpath,'/')) != NULL){
|
||||
tmp++; *tmp='\0';
|
||||
strcpy(dirpath,tmpdirpath);
|
||||
} else {
|
||||
strcpy(dirpath,"./");
|
||||
}
|
||||
|
||||
//Fetch the pattern of the volume slices
|
||||
if ((tmp = strrchr (relpath,'/')) != NULL)
|
||||
tmp++;
|
||||
else
|
||||
tmp = relpath;
|
||||
if ((tmp2 = strrchr(tmp,'-')) != NULL)
|
||||
*tmp2='\0';
|
||||
else{
|
||||
fprintf(stdout, "[ERROR] tmp2 ha dado null. no ha encontrado el * %s %s",tmp,relpath);
|
||||
return NULL;
|
||||
}
|
||||
strcpy(pattern,tmp);
|
||||
|
||||
dirp = opendir( dirpath );
|
||||
if (dirp == NULL){
|
||||
fprintf(stdout, "[ERROR] Infile must be a .pgx file or a directory that contain pgx files");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*Read all .pgx files of directory */
|
||||
while ( (direntp = readdir( dirp )) != NULL )
|
||||
{
|
||||
/* Found a directory, but ignore . and .. */
|
||||
if(strcmp(".",direntp->d_name) == 0 || strcmp("..",direntp->d_name) == 0)
|
||||
continue;
|
||||
|
||||
if( ((pgx = strstr(direntp->d_name,pattern)) != NULL) && ((tmp2 = strstr(direntp->d_name,".pgx")) != NULL) ){
|
||||
|
||||
strcpy(tmp,dirpath);
|
||||
tmp = strcat(tmp,direntp->d_name);
|
||||
|
||||
//Obtenemos el index de la secuencia de slices
|
||||
if ((tmp2 = strpbrk (direntp->d_name, "0123456789")) == NULL)
|
||||
continue;
|
||||
i = 0;
|
||||
while (tmp2 != NULL) {
|
||||
tmpno[i++] = *tmp2;
|
||||
point = tmp2;
|
||||
tmp2 = strpbrk (tmp2+1,"0123456789");
|
||||
}tmpno[i]='\0';
|
||||
|
||||
//Comprobamos que no estamos leyendo algo raro como pattern.jp3d
|
||||
if ((point = strpbrk (point,".")) == NULL){
|
||||
break;
|
||||
}
|
||||
//Slicepos --> index de slice; Sliceno --> no de slices hasta el momento
|
||||
slicepos = atoi(tmpno);
|
||||
pgxslicepos[sliceno] = slicepos - 1;
|
||||
sliceno++;
|
||||
if (slicepos>maxslice)
|
||||
maxslice = slicepos;
|
||||
|
||||
//Colocamos el slices en su posicion correspondiente
|
||||
strcpy(pgxfiles[slicepos-1],tmp);
|
||||
}
|
||||
}
|
||||
|
||||
}/* else if pattern*.pgx */
|
||||
|
||||
if (!sliceno) {
|
||||
fprintf(stdout,"[ERROR] No slices with this pattern founded !! Please check input volume name\n");
|
||||
return NULL;
|
||||
}
|
||||
/*if ( maxslice != sliceno) {
|
||||
fprintf(stdout,"[ERROR] Slices are not sequentially numbered !! Please rename them accordingly\n");
|
||||
return NULL;
|
||||
}*/
|
||||
|
||||
for (s=0;s<sliceno;s++)
|
||||
{
|
||||
int pos = maxslice == sliceno ? s: pgxslicepos[s];
|
||||
f = fopen(pgxfiles[pos], "rb");
|
||||
if (!f) {
|
||||
fprintf(stdout, "[ERROR] Failed to open %s for reading !\n", pgxfiles[s]);
|
||||
return NULL;
|
||||
}
|
||||
fprintf(stdout, "[INFO] Loading %s \n",pgxfiles[pos]);
|
||||
|
||||
fseek(f, 0, SEEK_SET);
|
||||
fscanf(f, "PG%[ \t]%c%c%[ \t+-]%d%[ \t]%d%[ \t]%d",temp,&endian1,&endian2,signtmp,&prec,temp,&w,temp,&h);
|
||||
|
||||
i=0;
|
||||
sign='+';
|
||||
while (signtmp[i]!='\0') {
|
||||
if (signtmp[i]=='-') sign='-';
|
||||
i++;
|
||||
}
|
||||
|
||||
fgetc(f);
|
||||
if (endian1=='M' && endian2=='L') {
|
||||
cmptparm.bigendian = 1;
|
||||
} else if (endian2=='M' && endian1=='L') {
|
||||
cmptparm.bigendian = 0;
|
||||
} else {
|
||||
fprintf(stdout, "[ERROR] Bad pgx header, please check input file\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (s==0){
|
||||
/* initialize volume component */
|
||||
|
||||
cmptparm.x0 = parameters->volume_offset_x0;
|
||||
cmptparm.y0 = parameters->volume_offset_y0;
|
||||
cmptparm.z0 = parameters->volume_offset_z0;
|
||||
cmptparm.w = !cmptparm.x0 ? (w - 1) * parameters->subsampling_dx + 1 : cmptparm.x0 + (w - 1) * parameters->subsampling_dx + 1;
|
||||
cmptparm.h = !cmptparm.y0 ? (h - 1) * parameters->subsampling_dy + 1 : cmptparm.y0 + (h - 1) * parameters->subsampling_dy + 1;
|
||||
cmptparm.l = !cmptparm.z0 ? (sliceno - 1) * parameters->subsampling_dz + 1 : cmptparm.z0 + (sliceno - 1) * parameters->subsampling_dz + 1;
|
||||
|
||||
if (sign == '-') {
|
||||
cmptparm.sgnd = 1;
|
||||
} else {
|
||||
cmptparm.sgnd = 0;
|
||||
}
|
||||
cmptparm.prec = prec;
|
||||
cmptparm.bpp = prec;
|
||||
cmptparm.dcoffset = parameters->dcoffset;
|
||||
cmptparm.dx = parameters->subsampling_dx;
|
||||
cmptparm.dy = parameters->subsampling_dy;
|
||||
cmptparm.dz = parameters->subsampling_dz;
|
||||
|
||||
/* create the volume */
|
||||
volume = opj_volume_create(numcomps, &cmptparm, color_space);
|
||||
if(!volume) {
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
/* set volume offset and reference grid */
|
||||
volume->x0 = cmptparm.x0;
|
||||
volume->y0 = cmptparm.y0;
|
||||
volume->z0 = cmptparm.z0;
|
||||
volume->x1 = cmptparm.w;
|
||||
volume->y1 = cmptparm.h;
|
||||
volume->z1 = cmptparm.l;
|
||||
|
||||
/* set volume data :only one component, that is a volume*/
|
||||
comp = &volume->comps[0];
|
||||
|
||||
}//if sliceno==1
|
||||
|
||||
offset = w * h * s;
|
||||
|
||||
for (i = 0; i < w * h; i++) {
|
||||
int v;
|
||||
if (comp->prec <= 8) {
|
||||
if (!comp->sgnd) {
|
||||
v = readuchar(f);
|
||||
} else {
|
||||
v = (char) readuchar(f);
|
||||
}
|
||||
} else if (comp->prec <= 16) {
|
||||
if (!comp->sgnd) {
|
||||
v = readushort(f, cmptparm.bigendian);
|
||||
} else {
|
||||
v = (short) readushort(f, cmptparm.bigendian);
|
||||
}
|
||||
} else {
|
||||
if (!comp->sgnd) {
|
||||
v = readuint(f, cmptparm.bigendian);
|
||||
} else {
|
||||
v = (int) readuint(f, cmptparm.bigendian);
|
||||
}
|
||||
}
|
||||
if (v > maxvalue)
|
||||
maxvalue = v;
|
||||
comp->data[i + offset] = v;
|
||||
|
||||
}
|
||||
fclose(f);
|
||||
} // for s --> sliceno
|
||||
comp->bpp = int_floorlog2(maxvalue) + 1;
|
||||
if (sliceno != 1)
|
||||
closedir( dirp );
|
||||
//dump_volume(stdout, volume);
|
||||
return volume;
|
||||
}
|
||||
|
||||
|
||||
int volumetopgx(opj_volume_t * volume, char *outfile) {
|
||||
int w, wr, wrr, h, hr, hrr, l, lr, lrr;
|
||||
int i, j, compno, offset, sliceno;
|
||||
FILE *fdest = NULL;
|
||||
|
||||
for (compno = 0; compno < volume->numcomps; compno++) {
|
||||
opj_volume_comp_t *comp = &volume->comps[compno];
|
||||
char name[256];
|
||||
int nbytes = 0;
|
||||
char *tmp = outfile;
|
||||
while (*tmp) {
|
||||
tmp++;
|
||||
}
|
||||
while (*tmp!='.') {
|
||||
tmp--;
|
||||
}
|
||||
*tmp='\0';
|
||||
for(sliceno = 0; sliceno < volume->z1 - volume->z0; sliceno++) {
|
||||
|
||||
if (volume->numcomps > 1) {
|
||||
sprintf(name, "%s%d-%d.pgx", outfile, sliceno+1, compno);
|
||||
} else if ((volume->z1 - volume->z0) > 1) {
|
||||
sprintf(name, "%s%d.pgx", outfile, sliceno+1);
|
||||
} else {
|
||||
sprintf(name, "%s.pgx", outfile);
|
||||
}
|
||||
|
||||
fdest = fopen(name, "wb");
|
||||
if (!fdest) {
|
||||
fprintf(stdout, "[ERROR] Failed to open %s for writing \n", name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fprintf(stdout,"[INFO] Writing in %s (%s)\n",name,volume->comps[0].bigendian ? "Bigendian" : "Little-endian");
|
||||
|
||||
w = int_ceildiv(volume->x1 - volume->x0, volume->comps[compno].dx);
|
||||
wr = volume->comps[compno].w;
|
||||
wrr = int_ceildivpow2(volume->comps[compno].w, volume->comps[compno].factor[0]);
|
||||
|
||||
h = int_ceildiv(volume->y1 - volume->y0, volume->comps[compno].dy);
|
||||
hr = volume->comps[compno].h;
|
||||
hrr = int_ceildivpow2(volume->comps[compno].h, volume->comps[compno].factor[1]);
|
||||
|
||||
l = int_ceildiv(volume->z1 - volume->z0, volume->comps[compno].dz);
|
||||
lr = volume->comps[compno].l;
|
||||
lrr = int_ceildivpow2(volume->comps[compno].l, volume->comps[compno].factor[2]);
|
||||
|
||||
fprintf(fdest, "PG %c%c %c%d %d %d\n", comp->bigendian ? 'M':'L', comp->bigendian ? 'L':'M',comp->sgnd ? '-' : '+', comp->prec, wr, hr);
|
||||
if (comp->prec <= 8) {
|
||||
nbytes = 1;
|
||||
} else if (comp->prec <= 16) {
|
||||
nbytes = 2;
|
||||
} else {
|
||||
nbytes = 4;
|
||||
}
|
||||
|
||||
offset = (sliceno / lrr * l) + (sliceno % lrr);
|
||||
offset = wrr * hrr * offset;
|
||||
//fprintf(stdout,"%d %d %d %d\n",offset,wrr*hrr,wrr,w);
|
||||
for (i = 0; i < wrr * hrr; i++) {
|
||||
int v = volume->comps[0].data[(i / wrr * w) + (i % wrr) + offset];
|
||||
if (volume->comps[0].bigendian) {
|
||||
for (j = nbytes - 1; j >= 0; j--) {
|
||||
char byte = (char) ((v >> (j * 8)) & 0xff);
|
||||
fwrite(&byte, 1, 1, fdest);
|
||||
}
|
||||
} else {
|
||||
for (j = 0; j <= nbytes - 1; j++) {
|
||||
char byte = (char) ((v >> (j * 8)) & 0xff);
|
||||
fwrite(&byte, 1, 1, fdest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fdest);
|
||||
}//for sliceno
|
||||
}//for compno
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -->> -->> -->> -->>
|
||||
|
||||
BIN IMAGE FORMAT
|
||||
|
||||
<<-- <<-- <<-- <<-- */
|
||||
|
||||
opj_volume_t* bintovolume(char *filename, char *fileimg, opj_cparameters_t *parameters) {
|
||||
int subsampling_dx = parameters->subsampling_dx;
|
||||
int subsampling_dy = parameters->subsampling_dy;
|
||||
int subsampling_dz = parameters->subsampling_dz;
|
||||
|
||||
int i, compno, w, h, l, numcomps = 1;
|
||||
int prec, max = 0;
|
||||
|
||||
// char temp[32];
|
||||
char line[100];
|
||||
int bigendian;
|
||||
|
||||
FILE *f = NULL;
|
||||
FILE *fimg = NULL;
|
||||
OPJ_COLOR_SPACE color_space;
|
||||
opj_volume_cmptparm_t cmptparm; /* maximum of 1 component */
|
||||
opj_volume_t * volume = NULL;
|
||||
opj_volume_comp_t *comp = NULL;
|
||||
|
||||
bigendian = 0;
|
||||
color_space = CLRSPC_GRAY;
|
||||
|
||||
fimg = fopen(fileimg,"r");
|
||||
if (!fimg) {
|
||||
fprintf(stdout, "[ERROR] Failed to open %s for reading !!\n", fileimg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fseek(fimg, 0, SEEK_SET);
|
||||
while (!feof(fimg)) {
|
||||
fgets(line,100,fimg);
|
||||
//fprintf(stdout,"%s %d \n",line,feof(fimg));
|
||||
if (strncmp(line,"Bpp",3) == 0){
|
||||
sscanf(line,"%*s%*[ \t]%d",&prec);
|
||||
} else if (strncmp(line,"Color",5) == 0){
|
||||
sscanf(line, "%*s%*[ \t]%d",&color_space);
|
||||
} else if (strncmp(line,"Dim",3) == 0){
|
||||
sscanf(line, "%*s%*[ \t]%d%*[ \t]%d%*[ \t]%d",&w,&h,&l);
|
||||
}
|
||||
}
|
||||
//fscanf(fimg, "Bpp%[ \t]%d%[ \t\n]",temp,&prec,temp);
|
||||
//fscanf(fimg, "Color Map%[ \t]%d%[ \n\t]Dimensions%[ \t]%d%[ \t]%d%[ \t]%d%[ \n\t]",temp,&color_space,temp,temp,&w,temp,&h,temp,&l,temp);
|
||||
//fscanf(fimg, "Resolution(mm)%[ \t]%d%[ \t]%d%[ \t]%d%[ \n\t]",temp,&subsampling_dx,temp,&subsampling_dy,temp,&subsampling_dz,temp);
|
||||
|
||||
#ifdef VERBOSE
|
||||
fprintf(stdout, "[INFO] %d \t %d %d %d \t %3.2f %2.2f %2.2f \t %d \n",color_space,w,h,l,subsampling_dx,subsampling_dy,subsampling_dz,prec);
|
||||
#endif
|
||||
fclose(fimg);
|
||||
|
||||
/* initialize volume components */
|
||||
memset(&cmptparm, 0, sizeof(opj_volume_cmptparm_t));
|
||||
|
||||
cmptparm.prec = prec;
|
||||
cmptparm.bpp = prec;
|
||||
cmptparm.sgnd = 0;
|
||||
cmptparm.bigendian = bigendian;
|
||||
cmptparm.dcoffset = parameters->dcoffset;
|
||||
cmptparm.dx = subsampling_dx;
|
||||
cmptparm.dy = subsampling_dy;
|
||||
cmptparm.dz = subsampling_dz;
|
||||
cmptparm.w = w;
|
||||
cmptparm.h = h;
|
||||
cmptparm.l = l;
|
||||
|
||||
/* create the volume */
|
||||
volume = opj_volume_create(numcomps, &cmptparm, color_space);
|
||||
if(!volume) {
|
||||
fprintf(stdout,"[ERROR] Unable to create volume");
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* set volume offset and reference grid */
|
||||
volume->x0 = parameters->volume_offset_x0;
|
||||
volume->y0 = parameters->volume_offset_y0;
|
||||
volume->z0 = parameters->volume_offset_z0;
|
||||
volume->x1 = parameters->volume_offset_x0 + (w - 1) * subsampling_dx + 1;
|
||||
volume->y1 = parameters->volume_offset_y0 + (h - 1) * subsampling_dy + 1;
|
||||
volume->z1 = parameters->volume_offset_z0 + (l - 1) * subsampling_dz + 1;
|
||||
|
||||
/* set volume data */
|
||||
f = fopen(filename, "rb");
|
||||
if (!f) {
|
||||
fprintf(stdout, "[ERROR] Failed to open %s for reading !!\n", filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* BINARY */
|
||||
for (compno = 0; compno < volume->numcomps; compno++) {
|
||||
int whl = w * h * l;
|
||||
/* set volume data */
|
||||
comp = &volume->comps[compno];
|
||||
|
||||
/*if (comp->prec <= 8) {
|
||||
if (!comp->sgnd) {
|
||||
unsigned char *data = (unsigned char *) malloc(whl * sizeof(unsigned char));
|
||||
fread(data, 1, whl, f);
|
||||
for (i = 0; i < whl; i++) {
|
||||
comp->data[i] = data[i];
|
||||
if (comp->data[i] > max)
|
||||
max = comp->data[i];
|
||||
}
|
||||
free(data);
|
||||
} else {
|
||||
char *data = (char *) malloc(whl);
|
||||
fread(data, 1, whl, f);
|
||||
for (i = 0; i < whl; i++) {
|
||||
comp->data[i] = data[i];
|
||||
if (comp->data[i] > max)
|
||||
max = comp->data[i];
|
||||
}
|
||||
free(data);
|
||||
}
|
||||
} else if (comp->prec <= 16) {
|
||||
if (!comp->sgnd) {
|
||||
unsigned short *data = (unsigned short *) malloc(whl * sizeof(unsigned short));
|
||||
int leido = fread(data, 2, whl, f);
|
||||
if (!leido) {
|
||||
free(data); fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < whl; i++) {
|
||||
if (bigendian) //(c1 << 8) + c2;
|
||||
comp->data[i] = data[i];
|
||||
else{ //(c2 << 8) + c1;
|
||||
comp->data[i] = ShortSwap(data[i]);
|
||||
}
|
||||
if (comp->data[i] > max)
|
||||
max = comp->data[i];
|
||||
}
|
||||
free(data);
|
||||
} else {
|
||||
short *data = (short *) malloc(whl);
|
||||
int leido = fread(data, 2, whl, f);
|
||||
if (!leido) {
|
||||
free(data); fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < whl; i++) {
|
||||
if (bigendian){ //(c1 << 8) + c2;
|
||||
comp->data[i] = data[i];
|
||||
}else{ //(c2 << 8) + c1;
|
||||
comp->data[i] = (short) ShortSwap((unsigned short) data[i]);
|
||||
}
|
||||
if (comp->data[i] > max)
|
||||
max = comp->data[i];
|
||||
}
|
||||
free(data);
|
||||
}
|
||||
} else {
|
||||
if (!comp->sgnd) {
|
||||
unsigned int *data = (unsigned int *) malloc(whl * sizeof(unsigned int));
|
||||
int leido = fread(data, 4, whl, f);
|
||||
if (!leido) {
|
||||
free(data); fclose(f);
|
||||
return NULL;
|
||||
} for (i = 0; i < whl; i++) {
|
||||
if (!bigendian)
|
||||
comp->data[i] = LongSwap(data[i]);
|
||||
else
|
||||
comp->data[i] = data[i];
|
||||
if (comp->data[i] > max)
|
||||
max = comp->data[i];
|
||||
}
|
||||
free(data);
|
||||
} else {
|
||||
int leido = fread(comp->data, 4, whl, f);
|
||||
if (!leido) {
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < whl; i++) {
|
||||
if (!bigendian)
|
||||
comp->data[i] = (int) LongSwap((unsigned int) comp->data[i]);
|
||||
if (comp->data[i] > max)
|
||||
max = comp->data[i];
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
for (i = 0; i < whl; i++) {
|
||||
int v;
|
||||
if (comp->prec <= 8) {
|
||||
if (!comp->sgnd) {
|
||||
v = readuchar(f);
|
||||
} else {
|
||||
v = (char) readuchar(f);
|
||||
}
|
||||
} else if (comp->prec <= 16) {
|
||||
if (!comp->sgnd) {
|
||||
v = readushort(f, bigendian);
|
||||
} else {
|
||||
v = (short) readushort(f, bigendian);
|
||||
}
|
||||
} else {
|
||||
if (!comp->sgnd) {
|
||||
v = readuint(f, bigendian);
|
||||
} else {
|
||||
v = (int) readuint(f, bigendian);
|
||||
}
|
||||
}
|
||||
if (v > max)
|
||||
max = v;
|
||||
comp->data[i] = v;
|
||||
}
|
||||
comp->bpp = int_floorlog2(max) + 1;
|
||||
}
|
||||
fclose(f);
|
||||
return volume;
|
||||
}
|
||||
|
||||
int volumetobin(opj_volume_t * volume, char *outfile) {
|
||||
int w, wr, wrr, h, hr, hrr, l, lr, lrr, max;
|
||||
int i,j, compno, nbytes;
|
||||
int offset, sliceno;
|
||||
FILE *fdest = NULL;
|
||||
FILE *fimgdest = NULL;
|
||||
// char *imgtemp;
|
||||
char name[256];
|
||||
|
||||
for (compno = 0; compno < 1; compno++) { //Only one component
|
||||
|
||||
fdest = fopen(outfile, "wb");
|
||||
if (!fdest) {
|
||||
fprintf(stdout, "[ERROR] Failed to open %s for writing\n", outfile);
|
||||
return 1;
|
||||
}
|
||||
fprintf(stdout,"[INFO] Writing outfile %s (%s) \n",outfile, volume->comps[0].bigendian ? "Bigendian" : "Little-endian");
|
||||
|
||||
w = int_ceildiv(volume->x1 - volume->x0, volume->comps[compno].dx);
|
||||
wr = volume->comps[compno].w;
|
||||
wrr = int_ceildivpow2(volume->comps[compno].w, volume->comps[compno].factor[0]);
|
||||
|
||||
h = int_ceildiv(volume->y1 - volume->y0, volume->comps[compno].dy);
|
||||
hr = volume->comps[compno].h;
|
||||
hrr = int_ceildivpow2(volume->comps[compno].h, volume->comps[compno].factor[1]);
|
||||
|
||||
l = int_ceildiv(volume->z1 - volume->z0, volume->comps[compno].dz);
|
||||
lr = volume->comps[compno].l;
|
||||
lrr = int_ceildivpow2(volume->comps[compno].l, volume->comps[compno].factor[2]);
|
||||
|
||||
max = (volume->comps[compno].prec <= 8) ? 255 : (1 << volume->comps[compno].prec) - 1;
|
||||
|
||||
volume->comps[compno].x0 = int_ceildivpow2(volume->comps[compno].x0 - int_ceildiv(volume->x0, volume->comps[compno].dx), volume->comps[compno].factor[0]);
|
||||
volume->comps[compno].y0 = int_ceildivpow2(volume->comps[compno].y0 - int_ceildiv(volume->y0, volume->comps[compno].dy), volume->comps[compno].factor[1]);
|
||||
volume->comps[compno].z0 = int_ceildivpow2(volume->comps[compno].z0 - int_ceildiv(volume->z0, volume->comps[compno].dz), volume->comps[compno].factor[2]);
|
||||
|
||||
if (volume->comps[0].prec <= 8) {
|
||||
nbytes = 1;
|
||||
} else if (volume->comps[0].prec <= 16) {
|
||||
nbytes = 2;
|
||||
} else {
|
||||
nbytes = 4;
|
||||
}
|
||||
|
||||
//fprintf(stdout,"w %d wr %d wrr %d h %d hr %d hrr %d l %d lr %d lrr %d max %d nbytes %d\n Factor %d %d %d",w,wr,wrr,h,hr,hrr,l,lr,lrr,max,nbytes,volume->comps[compno].factor[0],volume->comps[compno].factor[1],volume->comps[compno].factor[2]);
|
||||
|
||||
for(sliceno = 0; sliceno < lrr; sliceno++) {
|
||||
offset = (sliceno / lrr * l) + (sliceno % lrr);
|
||||
offset = wrr * hrr * offset;
|
||||
for (i = 0; i < wrr * hrr; i++) {
|
||||
int v = volume->comps[0].data[(i / wrr * w) + (i % wrr) + offset];
|
||||
if (volume->comps[0].bigendian) {
|
||||
for (j = nbytes - 1; j >= 0; j--) {
|
||||
char byte = (char) ((v >> (j * 8)) & 0xff);
|
||||
fwrite(&byte, 1, 1, fdest);
|
||||
}
|
||||
} else {
|
||||
for (j = 0; j <= nbytes - 1; j++) {
|
||||
char byte = (char) ((v >> (j * 8)) & 0xff);
|
||||
fwrite(&byte, 1, 1, fdest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fclose(fdest);
|
||||
|
||||
sprintf(name,"%s.img",outfile);
|
||||
fimgdest = fopen(name, "w");
|
||||
if (!fimgdest) {
|
||||
fprintf(stdout, "[ERROR] Failed to open %s for writing\n", name);
|
||||
return 1;
|
||||
}
|
||||
fprintf(fimgdest, "Bpp\t%d\nColor Map\t2\nDimensions\t%d\t%d\t%d\nResolution(mm)\t%d\t%d\t%d\t\n",
|
||||
volume->comps[0].prec,wrr,hrr,lrr,volume->comps[0].dx,volume->comps[0].dy,volume->comps[0].dz);
|
||||
|
||||
fclose(fimgdest);
|
||||
return 0;
|
||||
}
|
||||
/* -->> -->> -->> -->>
|
||||
|
||||
IMG IMAGE FORMAT
|
||||
|
||||
<<-- <<-- <<-- <<-- */
|
||||
opj_volume_t* imgtovolume(char *fileimg, opj_cparameters_t *parameters) {
|
||||
int subsampling_dx = parameters->subsampling_dx;
|
||||
int subsampling_dy = parameters->subsampling_dy;
|
||||
int subsampling_dz = parameters->subsampling_dz;
|
||||
|
||||
int i, compno, w, h, l, numcomps = 1;
|
||||
int prec, max = 0, min = 0;
|
||||
float dx, dy, dz;
|
||||
char filename[100], tmpdirpath[100], dirpath[100], *tmp;
|
||||
char line[100], datatype[100];
|
||||
int bigendian;
|
||||
|
||||
FILE *f = NULL;
|
||||
FILE *fimg = NULL;
|
||||
OPJ_COLOR_SPACE color_space;
|
||||
opj_volume_cmptparm_t cmptparm; /* maximum of 1 component */
|
||||
opj_volume_t * volume = NULL;
|
||||
opj_volume_comp_t *comp = NULL;
|
||||
|
||||
bigendian = 0;
|
||||
color_space = CLRSPC_GRAY;
|
||||
|
||||
fimg = fopen(fileimg,"r");
|
||||
if (!fimg) {
|
||||
fprintf(stderr, "[ERROR] Failed to open %s for reading !!\n", fileimg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Fetch only the path
|
||||
strcpy(tmpdirpath,fileimg);
|
||||
if ((tmp = strrchr(tmpdirpath,'/')) != NULL){
|
||||
tmp++; *tmp='\0';
|
||||
strcpy(dirpath,tmpdirpath);
|
||||
} else {
|
||||
strcpy(dirpath,"./");
|
||||
}
|
||||
|
||||
fseek(fimg, 0, SEEK_SET);
|
||||
while (!feof(fimg)) {
|
||||
fgets(line,100,fimg);
|
||||
//fprintf(stdout,"%s %d \n",line,feof(fimg));
|
||||
if (strncmp(line,"Image",5) == 0){
|
||||
sscanf(line,"%*s%*[ \t]%s",datatype);
|
||||
} else if (strncmp(line,"File",4) == 0){
|
||||
sscanf(line,"%*s %*s%*[ \t]%s",filename);
|
||||
strcat(dirpath, filename);
|
||||
strcpy(filename,dirpath);
|
||||
} else if (strncmp(line,"Min",3) == 0){
|
||||
sscanf(line,"%*s %*s%*[ \t]%d%*[ \t]%d",&min,&max);
|
||||
prec = int_floorlog2(max - min + 1);
|
||||
} else if (strncmp(line,"Bpp",3) == 0){
|
||||
sscanf(line,"%*s%*[ \t]%d",&prec);
|
||||
} else if (strncmp(line,"Color",5) == 0){
|
||||
sscanf(line, "%*s %*s%*[ \t]%d",&color_space);
|
||||
} else if (strncmp(line,"Dim",3) == 0){
|
||||
sscanf(line, "%*s%*[ \t]%d%*[ \t]%d%*[ \t]%d",&w,&h,&l);
|
||||
} else if (strncmp(line,"Res",3) == 0){
|
||||
sscanf(line,"%*s%*[ \t]%f%*[ \t]%f%*[ \t]%f",&dx,&dy,&dz);
|
||||
}
|
||||
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
fprintf(stdout, "[INFO] %s %d \t %d %d %d \t %f %f %f \t %d %d %d \n",filename,color_space,w,h,l,dx,dy,dz,max,min,prec);
|
||||
#endif
|
||||
fclose(fimg);
|
||||
|
||||
/* error control */
|
||||
if ( !prec || !w || !h || !l ){
|
||||
fprintf(stderr,"[ERROR] Unable to read IMG file correctly. Found some null values.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* initialize volume components */
|
||||
memset(&cmptparm, 0, sizeof(opj_volume_cmptparm_t));
|
||||
|
||||
cmptparm.prec = prec;
|
||||
cmptparm.bpp = prec;
|
||||
cmptparm.sgnd = 0;
|
||||
cmptparm.bigendian = bigendian;
|
||||
cmptparm.dcoffset = parameters->dcoffset;
|
||||
cmptparm.dx = subsampling_dx;
|
||||
cmptparm.dy = subsampling_dy;
|
||||
cmptparm.dz = subsampling_dz;
|
||||
cmptparm.w = w;
|
||||
cmptparm.h = h;
|
||||
cmptparm.l = l;
|
||||
|
||||
/* create the volume */
|
||||
volume = opj_volume_create(numcomps, &cmptparm, color_space);
|
||||
if(!volume) {
|
||||
fprintf(stdout,"[ERROR] Unable to create volume");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* set volume offset and reference grid */
|
||||
volume->x0 = parameters->volume_offset_x0;
|
||||
volume->y0 = parameters->volume_offset_y0;
|
||||
volume->z0 = parameters->volume_offset_z0;
|
||||
volume->x1 = parameters->volume_offset_x0 + (w - 1) * subsampling_dx + 1;
|
||||
volume->y1 = parameters->volume_offset_y0 + (h - 1) * subsampling_dy + 1;
|
||||
volume->z1 = parameters->volume_offset_z0 + (l - 1) * subsampling_dz + 1;
|
||||
|
||||
max = 0;
|
||||
/* set volume data */
|
||||
f = fopen(filename, "rb");
|
||||
if (!f) {
|
||||
fprintf(stderr, "[ERROR] Failed to open %s for reading !!\n", filename);
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* BINARY */
|
||||
for (compno = 0; compno < volume->numcomps; compno++) {
|
||||
int whl = w * h * l;
|
||||
/* set volume data */
|
||||
comp = &volume->comps[compno];
|
||||
|
||||
/*if (comp->prec <= 8) {
|
||||
if (!comp->sgnd) {
|
||||
unsigned char *data = (unsigned char *) malloc(whl * sizeof(unsigned char));
|
||||
fread(data, 1, whl, f);
|
||||
for (i = 0; i < whl; i++) {
|
||||
comp->data[i] = data[i];
|
||||
if (comp->data[i] > max)
|
||||
max = comp->data[i];
|
||||
}
|
||||
free(data);
|
||||
} else {
|
||||
char *data = (char *) malloc(whl);
|
||||
fread(data, 1, whl, f);
|
||||
for (i = 0; i < whl; i++) {
|
||||
comp->data[i] = data[i];
|
||||
if (comp->data[i] > max)
|
||||
max = comp->data[i];
|
||||
}
|
||||
free(data);
|
||||
}
|
||||
} else if (comp->prec <= 16) {
|
||||
if (!comp->sgnd) {
|
||||
unsigned short *data = (unsigned short *) malloc(whl * sizeof(unsigned short));
|
||||
int leido = fread(data, 2, whl, f);
|
||||
if (!leido) {
|
||||
free(data); fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < whl; i++) {
|
||||
if (bigendian) //(c1 << 8) + c2;
|
||||
comp->data[i] = data[i];
|
||||
else{ //(c2 << 8) + c1;
|
||||
comp->data[i] = ShortSwap(data[i]);
|
||||
}
|
||||
if (comp->data[i] > max)
|
||||
max = comp->data[i];
|
||||
}
|
||||
free(data);
|
||||
} else {
|
||||
short *data = (short *) malloc(whl);
|
||||
int leido = fread(data, 2, whl, f);
|
||||
if (!leido) {
|
||||
free(data); fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < whl; i++) {
|
||||
if (bigendian){ //(c1 << 8) + c2;
|
||||
comp->data[i] = data[i];
|
||||
}else{ //(c2 << 8) + c1;
|
||||
comp->data[i] = (short) ShortSwap((unsigned short) data[i]);
|
||||
}
|
||||
if (comp->data[i] > max)
|
||||
max = comp->data[i];
|
||||
}
|
||||
free(data);
|
||||
}
|
||||
} else {
|
||||
if (!comp->sgnd) {
|
||||
unsigned int *data = (unsigned int *) malloc(whl * sizeof(unsigned int));
|
||||
int leido = fread(data, 4, whl, f);
|
||||
if (!leido) {
|
||||
free(data); fclose(f);
|
||||
return NULL;
|
||||
} for (i = 0; i < whl; i++) {
|
||||
if (!bigendian)
|
||||
comp->data[i] = LongSwap(data[i]);
|
||||
else
|
||||
comp->data[i] = data[i];
|
||||
if (comp->data[i] > max)
|
||||
max = comp->data[i];
|
||||
}
|
||||
free(data);
|
||||
} else {
|
||||
int leido = fread(comp->data, 4, whl, f);
|
||||
if (!leido) {
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < whl; i++) {
|
||||
if (!bigendian)
|
||||
comp->data[i] = (int) LongSwap((unsigned int) comp->data[i]);
|
||||
if (comp->data[i] > max)
|
||||
max = comp->data[i];
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
for (i = 0; i < whl; i++) {
|
||||
int v;
|
||||
if (comp->prec <= 8) {
|
||||
if (!comp->sgnd) {
|
||||
v = readuchar(f);
|
||||
} else {
|
||||
v = (char) readuchar(f);
|
||||
}
|
||||
} else if (comp->prec <= 16) {
|
||||
if (!comp->sgnd) {
|
||||
v = readushort(f, bigendian);
|
||||
} else {
|
||||
v = (short) readushort(f, bigendian);
|
||||
}
|
||||
} else {
|
||||
if (!comp->sgnd) {
|
||||
v = readuint(f, bigendian);
|
||||
} else {
|
||||
v = (int) readuint(f, bigendian);
|
||||
}
|
||||
}
|
||||
if (v > max)
|
||||
max = v;
|
||||
comp->data[i] = v;
|
||||
}
|
||||
comp->bpp = int_floorlog2(max) + 1;
|
||||
}
|
||||
fclose(f);
|
||||
return volume;
|
||||
}
|
||||
|
||||
51
jp3d/codec/convert.h
Executable file
51
jp3d/codec/convert.h
Executable file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
|
||||
* Copyright (c) 2005, Herv<72> Drolon, FreeImage Team
|
||||
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* Copyright (c) 2006, M<>nica D<>ez Garc<72>a, Image Processing Laboratory, University of Valladolid, Spain
|
||||
* 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 __JP3D_CONVERT_H
|
||||
#define __JP3D_CONVERT_H
|
||||
|
||||
/**
|
||||
Load a single volume component encoded in PGX file format
|
||||
@param filename Name of the PGX file to load
|
||||
@param parameters *List ?*
|
||||
@return Returns a greyscale volume if successful, returns NULL otherwise
|
||||
*/
|
||||
opj_volume_t* pgxtovolume(char *filename, opj_cparameters_t *parameters);
|
||||
|
||||
int volumetopgx(opj_volume_t *volume, char *outfile);
|
||||
|
||||
opj_volume_t* bintovolume(char *filename,char *fileimg, opj_cparameters_t *parameters);
|
||||
|
||||
int volumetobin(opj_volume_t *volume, char *outfile);
|
||||
|
||||
opj_volume_t* imgtovolume(char *fileimg, opj_cparameters_t *parameters);
|
||||
|
||||
#endif /* __J2K_CONVERT_H */
|
||||
|
||||
225
jpwl/encoder/jpwlenc/compat/getopt.c → jp3d/codec/getopt.c
Normal file → Executable file
225
jpwl/encoder/jpwlenc/compat/getopt.c → jp3d/codec/getopt.c
Normal file → Executable file
@@ -1,116 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1993, 1994
|
||||
* The Regents of the University of California. 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/* last review : october 29th, 2002 */
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int opterr = 1, /* if error message should be printed */
|
||||
optind = 1, /* index into parent argv vector */
|
||||
optopt, /* character checked for validity */
|
||||
optreset; /* reset getopt */
|
||||
char *optarg; /* argument associated with option */
|
||||
|
||||
#define BADCH (int)'?'
|
||||
#define BADARG (int)':'
|
||||
#define EMSG ""
|
||||
|
||||
/*
|
||||
* getopt --
|
||||
* Parse argc/argv argument vector.
|
||||
*/
|
||||
int getopt(nargc, nargv, ostr)
|
||||
int nargc;
|
||||
char *const *nargv;
|
||||
const char *ostr;
|
||||
{
|
||||
# define __progname nargv[0]
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
char *oli; /* option letter list index */
|
||||
|
||||
if (optreset || !*place) { /* update scanning pointer */
|
||||
optreset = 0;
|
||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
if (place[1] && *++place == '-') { /* found "--" */
|
||||
++optind;
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
} /* option letter okay? */
|
||||
if ((optopt = (int) *place++) == (int) ':' ||
|
||||
!(oli = strchr(ostr, optopt))) {
|
||||
/*
|
||||
* if the user didn't specify '-' as an option,
|
||||
* assume it means -1.
|
||||
*/
|
||||
if (optopt == (int) '-')
|
||||
return (-1);
|
||||
if (!*place)
|
||||
++optind;
|
||||
if (opterr && *ostr != ':')
|
||||
(void) fprintf(stderr,
|
||||
"%s: illegal option -- %c\n", __progname, optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
if (*++oli != ':') { /* don't need argument */
|
||||
optarg = NULL;
|
||||
if (!*place)
|
||||
++optind;
|
||||
} else { /* need an argument */
|
||||
if (*place) /* no white space */
|
||||
optarg = place;
|
||||
else if (nargc <= ++optind) { /* no arg */
|
||||
place = EMSG;
|
||||
if (*ostr == ':')
|
||||
return (BADARG);
|
||||
if (opterr)
|
||||
(void) fprintf(stderr,
|
||||
"%s: option requires an argument -- %c\n",
|
||||
__progname, optopt);
|
||||
return (BADCH);
|
||||
} else /* white space */
|
||||
optarg = nargv[optind];
|
||||
place = EMSG;
|
||||
++optind;
|
||||
}
|
||||
return (optopt); /* dump back option letter */
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 1987, 1993, 1994
|
||||
* The Regents of the University of California. 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/* last review : october 29th, 2002 */
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int opterr = 1, /* if error message should be printed */
|
||||
optind = 1, /* index into parent argv vector */
|
||||
optopt, /* character checked for validity */
|
||||
optreset; /* reset getopt */
|
||||
char *optarg; /* argument associated with option */
|
||||
|
||||
#define BADCH (int)'?'
|
||||
#define BADARG (int)':'
|
||||
#define EMSG ""
|
||||
|
||||
/*
|
||||
* getopt --
|
||||
* Parse argc/argv argument vector.
|
||||
*/
|
||||
int getopt(int nargc, char *const *nargv, const char *ostr) {
|
||||
|
||||
# define __progname nargv[0] /* program name */
|
||||
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
char *oli; /* option letter list index */
|
||||
|
||||
if (optreset || !*place) { /* update scanning pointer */
|
||||
optreset = 0;
|
||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
if (place[1] && *++place == '-') { /* found "--" */
|
||||
++optind;
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
} /* option letter okay? */
|
||||
|
||||
if ((optopt = (int) *place++) == (int) ':' || !(oli = strchr(ostr, optopt))) {
|
||||
/* if the user didn't specify '-' as an option, assume it means -1. */
|
||||
if (optopt == (int) '-')
|
||||
return (-1);
|
||||
if (!*place)
|
||||
++optind;
|
||||
if (opterr && *ostr != ':')
|
||||
(void) fprintf(stdout,"[ERROR] %s: illegal option -- %c\n", __progname, optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
|
||||
if (*++oli != ':') { /* don't need argument */
|
||||
optarg = NULL;
|
||||
if (!*place)
|
||||
++optind;
|
||||
} else { /* need an argument */
|
||||
if (*place) /* no white space */
|
||||
optarg = place;
|
||||
else if (nargc <= ++optind) { /* no arg */
|
||||
place = EMSG;
|
||||
if (*ostr == ':')
|
||||
return (BADARG);
|
||||
if (opterr)
|
||||
(void) fprintf(stdout, "[ERROR] %s: option requires an argument -- %c\n", __progname, optopt);
|
||||
return (BADCH);
|
||||
} else /* white space */
|
||||
optarg = nargv[optind];
|
||||
place = EMSG;
|
||||
++optind;
|
||||
}
|
||||
return (optopt); /* dump back option letter */
|
||||
}
|
||||
28
jpwl/decoder_02/jpwldec/compat/getopt.h → jp3d/codec/getopt.h
Normal file → Executable file
28
jpwl/decoder_02/jpwldec/compat/getopt.h → jp3d/codec/getopt.h
Normal file → Executable file
@@ -1,14 +1,14 @@
|
||||
/* last review : october 29th, 2002 */
|
||||
|
||||
#ifndef _GETOPT_H_
|
||||
#define _GETOPT_H_
|
||||
|
||||
extern int opterr;
|
||||
extern int optind;
|
||||
extern int optopt;
|
||||
extern int optreset;
|
||||
extern char *optarg;
|
||||
|
||||
extern int getopt(int nargc, char *const *nargv, const char *ostr);
|
||||
|
||||
#endif /* _GETOPT_H_ */
|
||||
/* last review : october 29th, 2002 */
|
||||
|
||||
#ifndef _GETOPT_H_
|
||||
#define _GETOPT_H_
|
||||
|
||||
extern int opterr;
|
||||
extern int optind;
|
||||
extern int optopt;
|
||||
extern int optreset;
|
||||
extern char *optarg;
|
||||
|
||||
extern int getopt(int nargc, char *const *nargv, const char *ostr);
|
||||
|
||||
#endif /* _GETOPT_H_ */
|
||||
535
jp3d/codec/jp3d_to_volume.c
Executable file
535
jp3d/codec/jp3d_to_volume.c
Executable file
@@ -0,0 +1,535 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
|
||||
* Copyright (c) 2005, Herv<72> Drolon, FreeImage Team
|
||||
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* Copyright (c) 2006, M<>nica D<>ez Garc<72>a, Image Processing Laboratory, University of Valladolid, Spain
|
||||
* 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 "openjpeg.h"
|
||||
#include "getopt.h"
|
||||
#include "convert.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#define stricmp strcasecmp
|
||||
#define strnicmp strncasecmp
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
static double calc_PSNR(opj_volume_t *original, opj_volume_t *decoded)
|
||||
{
|
||||
int max, i, k, compno = 0, size;
|
||||
double sum, total = 0;
|
||||
int global = 1;
|
||||
|
||||
max = (original->comps[compno].prec <= 8) ? 255 : (1 << original->comps[compno].prec) - 1;
|
||||
if (global) {
|
||||
size = (original->x1 - original->x0) * (original->y1 - original->y0) * (original->z1 - original->z0);
|
||||
|
||||
for (compno = 0; compno < original->numcomps; compno++) {
|
||||
for(sum = 0, i = 0; i < size; ++i) {
|
||||
if ((decoded->comps[compno].data[i] < 0) || (decoded->comps[compno].data[i] > max))
|
||||
fprintf(stdout,"[WARNING] Data out of range during PSNR computing...\n");
|
||||
else
|
||||
sum += (original->comps[compno].data[i] - decoded->comps[compno].data[i]) * (original->comps[compno].data[i] - decoded->comps[compno].data[i]);
|
||||
}
|
||||
}
|
||||
sum /= size;
|
||||
total = ((sum==0.0) ? 0.0 : 10 * log10(max * max / sum));
|
||||
} else {
|
||||
size = (original->x1 - original->x0) * (original->y1 - original->y0);
|
||||
|
||||
for (k = 0; k < original->z1 - original->z0; k++) {
|
||||
int offset = k * size;
|
||||
for (sum = 0, compno = 0; compno < original->numcomps; compno++) {
|
||||
for(i = 0; i < size; ++i) {
|
||||
if ((decoded->comps[compno].data[i + offset] < 0) || (decoded->comps[compno].data[i + offset] > max))
|
||||
fprintf(stdout,"[WARNING] Data out of range during PSNR computing...\n");
|
||||
else
|
||||
sum += (original->comps[compno].data[i + offset] - decoded->comps[compno].data[i + offset]) * (original->comps[compno].data[i + offset] - decoded->comps[compno].data[i + offset]);
|
||||
}
|
||||
}
|
||||
sum /= size;
|
||||
total = total + ((sum==0.0) ? 0.0 : 10 * log10(max * max / sum));
|
||||
}
|
||||
|
||||
}
|
||||
if(total == 0) /* perfect reconstruction, PSNR should return infinity */
|
||||
return -1.0;
|
||||
|
||||
return total;
|
||||
//return 20 * log10((max - 1) / sqrt(sum));
|
||||
}
|
||||
|
||||
static double calc_SSIM(opj_volume_t *original, opj_volume_t *decoded)
|
||||
{
|
||||
int max, i, compno = 0, size, sizeM;
|
||||
double sum;
|
||||
double mux = 0.0, muy = 0.0, sigmax = 0.0, sigmay = 0.0,
|
||||
sigmaxy = 0.0, structx = 0.0, structy = 0.0;
|
||||
double lcomp,ccomp,scomp;
|
||||
double C1,C2,C3;
|
||||
|
||||
max = (original->comps[compno].prec <= 8) ? 255 : (1 << original->comps[compno].prec) - 1;
|
||||
size = (original->x1 - original->x0) * (original->y1 - original->y0) * (original->z1 - original->z0);
|
||||
|
||||
//MSSIM
|
||||
|
||||
// sizeM = size / (original->z1 - original->z0);
|
||||
|
||||
sizeM = size;
|
||||
for(sum = 0, i = 0; i < sizeM; ++i) {
|
||||
// First, the luminance of each signal is compared.
|
||||
mux += original->comps[compno].data[i];
|
||||
muy += decoded->comps[compno].data[i];
|
||||
}
|
||||
mux /= sizeM;
|
||||
muy /= sizeM;
|
||||
|
||||
//We use the standard deviation (the square root of variance) as an estimate of the signal contrast.
|
||||
for(sum = 0, i = 0; i < sizeM; ++i) {
|
||||
// First, the luminance of each signal is compared.
|
||||
sigmax += (original->comps[compno].data[i] - mux) * (original->comps[compno].data[i] - mux);
|
||||
sigmay += (decoded->comps[compno].data[i] - muy) * (decoded->comps[compno].data[i] - muy);
|
||||
sigmaxy += (original->comps[compno].data[i] - mux) * (decoded->comps[compno].data[i] - muy);
|
||||
}
|
||||
sigmax /= sizeM - 1;
|
||||
sigmay /= sizeM - 1;
|
||||
sigmaxy /= sizeM - 1;
|
||||
|
||||
sigmax = sqrt(sigmax);
|
||||
sigmay = sqrt(sigmay);
|
||||
sigmaxy = sqrt(sigmaxy);
|
||||
|
||||
//Third, the signal is normalized (divided) by its own standard deviation,
|
||||
//so that the two signals being compared have unit standard deviation.
|
||||
|
||||
//Luminance comparison
|
||||
C1 = (0.01 * max) * (0.01 * max);
|
||||
lcomp = ((2 * mux * muy) + C1)/((mux*mux) + (muy*mux) + C1);
|
||||
//Constrast comparison
|
||||
C2 = (0.03 * max) * (0.03 * max);
|
||||
ccomp = ((2 * sigmax * sigmay) + C2)/((sigmax*sigmax) + (sigmay*sigmay) + C2);
|
||||
//Structure comparison
|
||||
C3 = C2 / 2;
|
||||
scomp = (sigmaxy + C3) / (sigmax * sigmay + C3);
|
||||
//Similarity measure
|
||||
|
||||
sum = lcomp * ccomp * scomp;
|
||||
return sum;
|
||||
}
|
||||
|
||||
void decode_help_display() {
|
||||
fprintf(stdout,"HELP\n----\n\n");
|
||||
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
|
||||
|
||||
fprintf(stdout,"List of parameters for the JPEG 2000 encoder:\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout," Required arguments \n");
|
||||
fprintf(stdout," ---------------------------- \n");
|
||||
fprintf(stdout," -i <compressed file> ( *.jp3d, *.j3d )\n");
|
||||
fprintf(stdout," Currently accepts J3D-files. The file type is identified based on its suffix.\n");
|
||||
fprintf(stdout," -o <decompressed file> ( *.pgx, *.bin )\n");
|
||||
fprintf(stdout," Currently accepts PGX-files and BIN-files. Binary data is written to the file (not ascii). \n");
|
||||
fprintf(stdout," If a PGX filename is given, there will be as many output files as slices; \n");
|
||||
fprintf(stdout," an indice starting from 0 will then be appended to the output filename,\n");
|
||||
fprintf(stdout," just before the \"pgx\" extension.\n");
|
||||
fprintf(stdout," -m <characteristics file> ( *.img ) \n");
|
||||
fprintf(stdout," Required only for BIN-files. Ascii data of volume characteristics is written. \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout," Optional \n");
|
||||
fprintf(stdout," ---------------------------- \n");
|
||||
fprintf(stdout," -h \n ");
|
||||
fprintf(stdout," Display the help information\n");
|
||||
fprintf(stdout," -r <RFx,RFy,RFz>\n");
|
||||
fprintf(stdout," Set the number of highest resolution levels to be discarded on each dimension. \n");
|
||||
fprintf(stdout," The volume 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");
|
||||
fprintf(stdout," -O original-file \n");
|
||||
fprintf(stdout," This option offers the possibility to compute some quality results \n");
|
||||
fprintf(stdout," for the decompressed volume, like the PSNR value achieved or the global SSIM value. \n");
|
||||
fprintf(stdout," Needs the original file in order to compare with the new one.\n");
|
||||
fprintf(stdout," NOTE: Only valid when -r option is 0,0,0 (both original and decompressed volumes have same resolutions) \n");
|
||||
fprintf(stdout," NOTE: If original file is .BIN file, the volume characteristics file shall be defined with the -m option. \n");
|
||||
fprintf(stdout," (i.e. -O original-BIN-file -m original-IMG-file) \n");
|
||||
fprintf(stdout," -BE \n");
|
||||
fprintf(stdout," Define that the recovered volume data will be saved with big endian byte order.\n");
|
||||
fprintf(stdout," By default, little endian byte order is used.\n");
|
||||
fprintf(stdout,"\n");
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int get_file_format(char *filename) {
|
||||
int i;
|
||||
static const char *extension[] = {"pgx", "bin", "j3d", "jp3d", "j2k", "img"};
|
||||
static const int format[] = { PGX_DFMT, BIN_DFMT, J3D_CFMT, J3D_CFMT, J2K_CFMT, IMG_DFMT};
|
||||
char * ext = strrchr(filename, '.') + 1;
|
||||
for(i = 0; i < sizeof(format); i++) {
|
||||
if(strnicmp(ext, extension[i], 3) == 0) {
|
||||
return format[i];
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters) {
|
||||
/* parse the command line */
|
||||
|
||||
while (1) {
|
||||
int c = getopt(argc, argv, "i:o:O:r:l:B:m:h");
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
case 'i': /* input file */
|
||||
{
|
||||
char *infile = optarg;
|
||||
parameters->decod_format = get_file_format(infile);
|
||||
switch(parameters->decod_format) {
|
||||
case J3D_CFMT:
|
||||
case J2K_CFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "[ERROR] Unknown format for infile %s [only *.j3d]!! \n", infile);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
strncpy(parameters->infile, infile, MAX_PATH);
|
||||
fprintf(stdout, "[INFO] Infile: %s \n", parameters->infile);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 'm': /* img file */
|
||||
{
|
||||
char *imgfile = optarg;
|
||||
int imgformat = get_file_format(imgfile);
|
||||
switch(imgformat) {
|
||||
case IMG_DFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "[ERROR] Unrecognized format for imgfile : %s [accept only *.img] !!\n\n", imgfile);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
strncpy(parameters->imgfile, imgfile, MAX_PATH);
|
||||
fprintf(stdout, "[INFO] Imgfile: %s Format: %d\n", parameters->imgfile, imgformat);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'o': /* output file */
|
||||
{
|
||||
char *outfile = optarg;
|
||||
parameters->cod_format = get_file_format(outfile);
|
||||
switch(parameters->cod_format) {
|
||||
case PGX_DFMT:
|
||||
case BIN_DFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "[ERROR] Unrecognized format for outfile : %s [accept only *.pgx or *.bin] !!\n\n", outfile);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
strncpy(parameters->outfile, outfile, MAX_PATH);
|
||||
fprintf(stdout, "[INFO] Outfile: %s \n", parameters->outfile);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'O': /* Original image for PSNR computing */
|
||||
{
|
||||
char *original = optarg;
|
||||
parameters->orig_format = get_file_format(original);
|
||||
switch(parameters->orig_format) {
|
||||
case PGX_DFMT:
|
||||
case BIN_DFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "[ERROR] Unrecognized format for original file : %s [accept only *.pgx or *.bin] !!\n\n", original);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
strncpy(parameters->original, original, MAX_PATH);
|
||||
fprintf(stdout, "[INFO] Original file: %s \n", parameters->original);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'r': /* reduce option */
|
||||
{
|
||||
//sscanf(optarg, "%d, %d, %d", ¶meters->cp_reduce[0], ¶meters->cp_reduce[1], ¶meters->cp_reduce[2]);
|
||||
int aux;
|
||||
aux = sscanf(optarg, "%d,%d,%d", ¶meters->cp_reduce[0], ¶meters->cp_reduce[1], ¶meters->cp_reduce[2]);
|
||||
if (aux == 2)
|
||||
parameters->cp_reduce[2] = 0;
|
||||
else if (aux == 1) {
|
||||
parameters->cp_reduce[1] = parameters->cp_reduce[0];
|
||||
parameters->cp_reduce[2] = 0;
|
||||
}else if (aux == 0){
|
||||
parameters->cp_reduce[0] = 0;
|
||||
parameters->cp_reduce[1] = 0;
|
||||
parameters->cp_reduce[2] = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'l': /* layering option */
|
||||
{
|
||||
sscanf(optarg, "%d", ¶meters->cp_layer);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'B': /* BIGENDIAN vs. LITTLEENDIAN */
|
||||
{
|
||||
parameters->bigendian = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'L': /* BIGENDIAN vs. LITTLEENDIAN */
|
||||
{
|
||||
parameters->decod_format = LSE_CFMT;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'h': /* display an help description */
|
||||
{
|
||||
decode_help_display();
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
default:
|
||||
fprintf(stdout,"[WARNING] This option is not valid \"-%c %s\"\n",c, optarg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* check for possible errors */
|
||||
|
||||
if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
|
||||
fprintf(stdout,"[ERROR] At least one required argument is missing\n Check jp3d_to_volume -help for usage information\n");
|
||||
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) {
|
||||
fprintf(stdout, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
opj_dparameters_t parameters; /* decompression parameters */
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
opj_volume_t *volume = NULL;
|
||||
|
||||
opj_volume_t *original = NULL;
|
||||
opj_cparameters_t cparameters; /* original parameters */
|
||||
|
||||
FILE *fsrc = NULL;
|
||||
unsigned char *src = NULL;
|
||||
int file_length;
|
||||
int decodeok;
|
||||
double psnr, ssim;
|
||||
|
||||
opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */
|
||||
opj_cio_t *cio = NULL;
|
||||
|
||||
/* 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);
|
||||
|
||||
/* parse input and get user decoding parameters */
|
||||
strcpy(parameters.original,"NULL");
|
||||
strcpy(parameters.imgfile,"NULL");
|
||||
if(parse_cmdline_decoder(argc, argv, ¶meters) == 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* read the input file and put it in memory */
|
||||
/* ---------------------------------------- */
|
||||
fprintf(stdout, "[INFO] Loading %s file \n",parameters.decod_format==J3D_CFMT ? ".jp3d" : ".j2k");
|
||||
fsrc = fopen(parameters.infile, "rb");
|
||||
if (!fsrc) {
|
||||
fprintf(stdout, "[ERROR] Failed to open %s for reading\n", parameters.infile);
|
||||
return 1;
|
||||
}
|
||||
fseek(fsrc, 0, SEEK_END);
|
||||
file_length = ftell(fsrc);
|
||||
fseek(fsrc, 0, SEEK_SET);
|
||||
src = (unsigned char *) malloc(file_length);
|
||||
fread(src, 1, file_length, fsrc);
|
||||
fclose(fsrc);
|
||||
|
||||
/* decode the code-stream */
|
||||
/* ---------------------- */
|
||||
if (parameters.decod_format == J3D_CFMT || parameters.decod_format == J2K_CFMT) {
|
||||
/* get a JP3D or J2K decoder handle */
|
||||
if (parameters.decod_format == J3D_CFMT)
|
||||
dinfo = opj_create_decompress(CODEC_J3D);
|
||||
else if (parameters.decod_format == J2K_CFMT)
|
||||
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 volume structure */
|
||||
volume = opj_decode(dinfo, cio);
|
||||
if(!volume) {
|
||||
fprintf(stdout, "[ERROR] jp3d_to_volume: failed to decode volume!\n");
|
||||
opj_destroy_decompress(dinfo);
|
||||
opj_cio_close(cio);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* close the byte stream */
|
||||
opj_cio_close(cio);
|
||||
}
|
||||
|
||||
/* free the memory containing the code-stream */
|
||||
free(src);
|
||||
src = NULL;
|
||||
|
||||
/* create output volume */
|
||||
/* ------------------- */
|
||||
|
||||
switch (parameters.cod_format) {
|
||||
case PGX_DFMT: /* PGX */
|
||||
decodeok = volumetopgx(volume, parameters.outfile);
|
||||
if (decodeok)
|
||||
fprintf(stdout,"[ERROR] Unable to write decoded volume into pgx files\n");
|
||||
break;
|
||||
|
||||
case BIN_DFMT: /* BMP */
|
||||
decodeok = volumetobin(volume, parameters.outfile);
|
||||
if (decodeok)
|
||||
fprintf(stdout,"[ERROR] Unable to write decoded volume into pgx files\n");
|
||||
break;
|
||||
}
|
||||
switch (parameters.orig_format) {
|
||||
case PGX_DFMT: /* PGX */
|
||||
if (strcmp("NULL",parameters.original) != 0){
|
||||
fprintf(stdout,"Loading original file %s \n",parameters.original);
|
||||
cparameters.subsampling_dx = 1; cparameters.subsampling_dy = 1; cparameters.subsampling_dz = 1;
|
||||
cparameters.volume_offset_x0 = 0;cparameters.volume_offset_y0 = 0;cparameters.volume_offset_z0 = 0;
|
||||
original = pgxtovolume(parameters.original,&cparameters);
|
||||
}
|
||||
break;
|
||||
|
||||
case BIN_DFMT: /* BMP */
|
||||
if (strcmp("NULL",parameters.original) != 0 && strcmp("NULL",parameters.imgfile) != 0){
|
||||
fprintf(stdout,"Loading original file %s %s\n",parameters.original,parameters.imgfile);
|
||||
cparameters.subsampling_dx = 1; cparameters.subsampling_dy = 1; cparameters.subsampling_dz = 1;
|
||||
cparameters.volume_offset_x0 = 0;cparameters.volume_offset_y0 = 0;cparameters.volume_offset_z0 = 0;
|
||||
original = bintovolume(parameters.original,parameters.imgfile,&cparameters);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf(stdout, "[RESULT] Volume: %d x %d x %d (x %d bpv)\n ",
|
||||
(volume->comps[0].w >> volume->comps[0].factor[0]),
|
||||
(volume->comps[0].h >> volume->comps[0].factor[1]),
|
||||
(volume->comps[0].l >> volume->comps[0].factor[2]),volume->comps[0].prec);
|
||||
|
||||
if(original){
|
||||
psnr = calc_PSNR(original,volume);
|
||||
ssim = calc_SSIM(original,volume);
|
||||
if (psnr < 0.0)
|
||||
fprintf(stdout, " PSNR: Inf , SSMI %f -- Perfect reconstruction!\n",ssim);
|
||||
else
|
||||
fprintf(stdout, " PSNR: %f , SSIM %f \n",psnr,ssim);
|
||||
}
|
||||
/* free remaining structures */
|
||||
if(dinfo) {
|
||||
opj_destroy_decompress(dinfo);
|
||||
}
|
||||
|
||||
/* free volume data structure */
|
||||
opj_volume_destroy(volume);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BIN
jp3d/codec/jp3d_vm_dec.ncb
Executable file
BIN
jp3d/codec/jp3d_vm_dec.ncb
Executable file
Binary file not shown.
30
jp3d/codec/jp3d_vm_dec.sln
Executable file
30
jp3d/codec/jp3d_vm_dec.sln
Executable file
@@ -0,0 +1,30 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jp3d_vm_dec", "jp3d_vm_dec.vcproj", "{E0C1B905-5B10-4C9A-AF55-2D8144D518AB}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7} = {6F3FB035-8F4E-4794-B091-0F0A20223BE7}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibJp3dVM", "..\LibJp3dVM.vcproj", "{6F3FB035-8F4E-4794-B091-0F0A20223BE7}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{E0C1B905-5B10-4C9A-AF55-2D8144D518AB}.Debug.ActiveCfg = Debug|Win32
|
||||
{E0C1B905-5B10-4C9A-AF55-2D8144D518AB}.Debug.Build.0 = Debug|Win32
|
||||
{E0C1B905-5B10-4C9A-AF55-2D8144D518AB}.Release.ActiveCfg = Release|Win32
|
||||
{E0C1B905-5B10-4C9A-AF55-2D8144D518AB}.Release.Build.0 = Release|Win32
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Debug.ActiveCfg = Debug|Win32
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Debug.Build.0 = Debug|Win32
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Release.ActiveCfg = Release|Win32
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
BIN
jp3d/codec/jp3d_vm_dec.suo
Executable file
BIN
jp3d/codec/jp3d_vm_dec.suo
Executable file
Binary file not shown.
157
jp3d/codec/jp3d_vm_dec.vcproj
Executable file
157
jp3d/codec/jp3d_vm_dec.vcproj
Executable file
@@ -0,0 +1,157 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="jp3d_vm_dec"
|
||||
ProjectGUID="{E0C1B905-5B10-4C9A-AF55-2D8144D518AB}"
|
||||
SccProjectName=""
|
||||
SccLocalPath="">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../libjp3dvm"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OPJ_STATIC"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\Debug/jp3d_vm_dec.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\Debug/jp3d_vm_dec.exe"
|
||||
LinkIncremental="0"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\Debug/jp3d_vm_dec.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/j2k_to_image.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="copy Debug\jp3d_vm_dec.exe ..\bin"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1036"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="../libjp3dvm"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OPJ_STATIC"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\Release/jp3d_vm_dec.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\Release/jp3d_vm_dec.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\Release/jp3d_vm_dec.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/j2k_to_image.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="copy Release\jp3d_vm_dec.exe ..\bin"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1036"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\convert.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\convert.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\getopt.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\getopt.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\jp3d_to_volume.c">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
BIN
jp3d/codec/jp3d_vm_enc.ncb
Executable file
BIN
jp3d/codec/jp3d_vm_enc.ncb
Executable file
Binary file not shown.
35
jp3d/codec/jp3d_vm_enc.sln
Executable file
35
jp3d/codec/jp3d_vm_enc.sln
Executable file
@@ -0,0 +1,35 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jp3d_vm_enc", "jp3d_vm_enc.vcproj", "{A9704A2E-3B93-4BAA-9229-02FC93D27201}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7} = {6F3FB035-8F4E-4794-B091-0F0A20223BE7}
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7} = {6F3FB035-8F4E-4794-B091-0F0A20223BE7}
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7} = {6F3FB035-8F4E-4794-B091-0F0A20223BE7}
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7} = {6F3FB035-8F4E-4794-B091-0F0A20223BE7}
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7} = {6F3FB035-8F4E-4794-B091-0F0A20223BE7}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibJp3dVM", "..\LibJp3dVM.vcproj", "{6F3FB035-8F4E-4794-B091-0F0A20223BE7}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7} = {6F3FB035-8F4E-4794-B091-0F0A20223BE7}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{A9704A2E-3B93-4BAA-9229-02FC93D27201}.Debug.ActiveCfg = Debug|Win32
|
||||
{A9704A2E-3B93-4BAA-9229-02FC93D27201}.Debug.Build.0 = Debug|Win32
|
||||
{A9704A2E-3B93-4BAA-9229-02FC93D27201}.Release.ActiveCfg = Release|Win32
|
||||
{A9704A2E-3B93-4BAA-9229-02FC93D27201}.Release.Build.0 = Release|Win32
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Debug.ActiveCfg = Debug|Win32
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Debug.Build.0 = Debug|Win32
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Release.ActiveCfg = Release|Win32
|
||||
{6F3FB035-8F4E-4794-B091-0F0A20223BE7}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
BIN
jp3d/codec/jp3d_vm_enc.suo
Executable file
BIN
jp3d/codec/jp3d_vm_enc.suo
Executable file
Binary file not shown.
157
jp3d/codec/jp3d_vm_enc.vcproj
Executable file
157
jp3d/codec/jp3d_vm_enc.vcproj
Executable file
@@ -0,0 +1,157 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="jp3d_vm_enc"
|
||||
ProjectGUID="{A9704A2E-3B93-4BAA-9229-02FC93D27201}"
|
||||
SccProjectName=""
|
||||
SccLocalPath="">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="../libjp3dvm"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;OPJ_STATIC"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\Release/jp3d_vm_enc.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\Release/jp3d_vm_enc.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\Release/jp3d_vm_enc.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/image_to_j2k.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="copy Release\jp3d_vm_enc.exe ..\bin"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1036"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../libjp3dvm"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OPJ_STATIC"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
PrecompiledHeaderFile=".\Debug/jp3d_vm_enc.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\Debug/jp3d_vm_enc.exe"
|
||||
LinkIncremental="0"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\Debug/jp3d_vm_enc.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/image_to_j2k.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="copy Debug\jp3d_vm_enc.exe ..\bin"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1036"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\convert.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\convert.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\getopt.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\getopt.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\volume_to_jp3d.c">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
903
jp3d/codec/volume_to_jp3d.c
Executable file
903
jp3d/codec/volume_to_jp3d.c
Executable file
@@ -0,0 +1,903 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
|
||||
* Copyright (c) 2005, Herv<72> Drolon, FreeImage Team
|
||||
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* Copyright (c) 2006, M<>nica D<>ez Garc<72>a, Image Processing Laboratory, University of Valladolid, Spain
|
||||
* 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 "openjpeg.h"
|
||||
#include "getopt.h"
|
||||
#include "convert.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#define stricmp strcasecmp
|
||||
#define strnicmp strncasecmp
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void encode_help_display() {
|
||||
fprintf(stdout,"List of parameters for the JPEG2000 Part 10 encoder:\n");
|
||||
fprintf(stdout,"------------\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"Required Parameters (except with -h):\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-i : source file (-i source.bin or source*.pgx) \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-m : source characteristics file (-m imgfile.img) \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-o : destination file (-o dest.jp3d) \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"Optional Parameters:\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-h : display the help information \n ");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-n : number of resolutions (-n 3,3,3) \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-I : use the irreversible transforms: ICT + DWT 9-7 (-I) \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-C : coding algorithm (-C 2EB) [2EB, 3EB] \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-r : different compression ratios for successive layers (-r 20,10,5)\n ");
|
||||
fprintf(stdout," - The rate specified for each quality level is the desired compression factor.\n");
|
||||
fprintf(stdout," - Rate 1 means lossless compression\n");
|
||||
fprintf(stdout," (options -r and -q cannot be used together)\n ");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-q : different psnr for successive layers (-q 30,40,50) \n ");
|
||||
fprintf(stdout," (options -r and -q cannot be used together)\n ");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-b : size of code block (-b 32,32,32) \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-c : size of precinct (-c 128,128,128) \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-t : size of tile (-t 512,512,512) \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-p : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-s : subsampling factor (-s 2,2,2) [-s X,Y,Z] \n");
|
||||
fprintf(stdout," - Remark: subsampling bigger than 2 can produce error\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-SOP : write SOP marker before each packet \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-EPH : write EPH marker after each header packet \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-M : code-block style (-M 0) [1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL)\n");
|
||||
fprintf(stdout," 8=VSC 16=PTERM 32=SEGSYM 64=3DCTXT] \n");
|
||||
fprintf(stdout," Indicate multiple modes by adding their values. \n");
|
||||
fprintf(stdout," ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-D : define DC offset (-D 12) \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-x : create an index file *.Idx (-x index_name.Idx) \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-ROI : c=%%d,U=%%d : quantization indices upshifted \n");
|
||||
fprintf(stdout," for component c=%%d [%%d = 0,1,2]\n");
|
||||
fprintf(stdout," with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI:c=0,U=25) \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-d : offset of the origin of the volume (-d 150,300,100) \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"-l : offset of the origin of the tiles (-l 100,75,25) \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"DEFAULT CODING:\n");
|
||||
fprintf(stdout,"------------\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout," * Lossless\n");
|
||||
fprintf(stdout," * 1 tile\n");
|
||||
fprintf(stdout," * Size of precinct : 2^15 x 2^15 x 2^15 (means 1 precinct)\n");
|
||||
fprintf(stdout," * Size of code-block : 64 x 64 x 64\n");
|
||||
fprintf(stdout," * Number of resolutions in x, y and z axis: 3\n");
|
||||
fprintf(stdout," * No SOP marker in the codestream\n");
|
||||
fprintf(stdout," * No EPH marker in the codestream\n");
|
||||
fprintf(stdout," * No sub-sampling in x, y or z direction\n");
|
||||
fprintf(stdout," * No mode switch activated\n");
|
||||
fprintf(stdout," * Progression order: LRCP\n");
|
||||
fprintf(stdout," * No index file\n");
|
||||
fprintf(stdout," * No ROI upshifted\n");
|
||||
fprintf(stdout," * No offset of the origin of the volume\n");
|
||||
fprintf(stdout," * No offset of the origin of the tiles\n");
|
||||
fprintf(stdout," * Reversible DWT 5-3 on each 2D slice\n");
|
||||
fprintf(stdout," * Coding algorithm: 2D-EBCOT \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"REMARKS:\n");
|
||||
fprintf(stdout,"---------\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"- The markers written to the main_header are : SOC SIZ COD QCD COM.\n");
|
||||
fprintf(stdout,"- COD and QCD markers will never appear in the tile_header.\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"- You need enough disk space memory (twice the original) to encode \n");
|
||||
fprintf(stdout,"the volume,i.e. for a 1.5 GB volume you need a minimum of 3GB of disk memory)\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"- When loading *.pgx files, a relative path to directory is needed for input argument \n");
|
||||
fprintf(stdout," followed by the common prefix of the slices and a '*' character representing sequential numeration.\n");
|
||||
fprintf(stdout,"( -i relativepath/slices*.pgx )\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout," - The index file has the structure below:\n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout,"\t Image_height Image_width Image_depth\n");
|
||||
fprintf(stdout,"\t Progression order: 0 (LRCP)\n");
|
||||
fprintf(stdout,"\t Tiles_size_X Tiles_size_Y Tiles_size_Z\n");
|
||||
fprintf(stdout,"\t Components_nb\n");
|
||||
fprintf(stdout,"\t Layers_nb\n");
|
||||
fprintf(stdout,"\t Decomposition_levels\n");
|
||||
fprintf(stdout,"\t [Precincts_size_X_res_Nr Precincts_size_Y_res_Nr Precincts_size_Z_res_Nr]\n\t ...\n");
|
||||
fprintf(stdout,"\t [Precincts_size_X_res_0 Precincts_size_Y_res_0 Precincts_size_Z_res_0]\n");
|
||||
fprintf(stdout,"\t Main_header_end_position\n");
|
||||
fprintf(stdout,"\t Codestream_size\n");
|
||||
fprintf(stdout,"\t Tile_0 [start_pos end_header end_pos TotalDisto NumPix MaxMSE]\n");
|
||||
fprintf(stdout,"\t ...\n");
|
||||
fprintf(stdout,"\t Tile_Nt [ '' '' '' '' '' '' ]\n");
|
||||
fprintf(stdout,"\t Tpacket_0 [Tile layer res. comp. prec. start_pos end_pos disto]\n");
|
||||
fprintf(stdout,"\t ...\n");
|
||||
fprintf(stdout,"\t Tpacket_Np ['' '' '' '' '' '' '' '' ]\n");
|
||||
fprintf(stdout,"\t MaxDisto\n");
|
||||
fprintf(stdout,"\t TotalDisto\n\n");
|
||||
fprintf(stdout,"\n");
|
||||
|
||||
}
|
||||
|
||||
OPJ_PROG_ORDER give_progression(char progression[4]) {
|
||||
if(strncmp(progression, "LRCP", 4) == 0) {
|
||||
return LRCP;
|
||||
}
|
||||
if(strncmp(progression, "RLCP", 4) == 0) {
|
||||
return RLCP;
|
||||
}
|
||||
if(strncmp(progression, "RPCL", 4) == 0) {
|
||||
return RPCL;
|
||||
}
|
||||
if(strncmp(progression, "PCRL", 4) == 0) {
|
||||
return PCRL;
|
||||
}
|
||||
if(strncmp(progression, "CPRL", 4) == 0) {
|
||||
return CPRL;
|
||||
}
|
||||
|
||||
return PROG_UNKNOWN;
|
||||
}
|
||||
|
||||
OPJ_TRANSFORM give_transform(char transform[4]) {
|
||||
if(strncmp(transform, "2DWT", 4) == 0) {
|
||||
return TRF_2D_DWT;
|
||||
}
|
||||
if(strncmp(transform, "3DWT", 4) == 0) {
|
||||
return TRF_3D_DWT;
|
||||
}
|
||||
return TRF_UNKNOWN;
|
||||
}
|
||||
|
||||
OPJ_ENTROPY_CODING give_coding(char coding[3]) {
|
||||
|
||||
if(strncmp(coding, "2EB", 3) == 0) {
|
||||
return ENCOD_2EB;
|
||||
}
|
||||
if(strncmp(coding, "3EB", 3) == 0) {
|
||||
return ENCOD_3EB;
|
||||
}
|
||||
/*if(strncmp(coding, "2GR", 3) == 0) {
|
||||
return ENCOD_2GR;
|
||||
}
|
||||
if(strncmp(coding, "3GR", 3) == 0) {
|
||||
return ENCOD_3GR;
|
||||
}*/
|
||||
|
||||
return ENCOD_UNKNOWN;
|
||||
}
|
||||
|
||||
int get_file_format(char *filename) {
|
||||
int i;
|
||||
static const char *extension[] = {"pgx", "bin", "img", "j3d", "jp3d", "j2k"};
|
||||
static const int format[] = { PGX_DFMT, BIN_DFMT, IMG_DFMT, J3D_CFMT, J3D_CFMT, J2K_CFMT};
|
||||
char * ext = strrchr(filename, '.') + 1;
|
||||
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_encoder(int argc, char **argv, opj_cparameters_t *parameters) {
|
||||
int i, value;
|
||||
|
||||
/* parse the command line */
|
||||
|
||||
while (1) {
|
||||
int c = getopt(argc, argv, "i:m:o:r:q:f:t:n:c:b:x:p:s:d:hP:S:E:M:D:R:l:T:C:A:I");
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
case 'i': /* input file */
|
||||
{
|
||||
char *infile = optarg;
|
||||
parameters->decod_format = get_file_format(infile);
|
||||
switch(parameters->decod_format) {
|
||||
case PGX_DFMT:
|
||||
case BIN_DFMT:
|
||||
case IMG_DFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "[ERROR] Unrecognized format for infile : %s [accept only *.pgx or *.bin] !!\n\n", infile);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
strncpy(parameters->infile, infile, MAX_PATH);
|
||||
fprintf(stdout, "[INFO] Infile: %s \n", parameters->infile);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'm': /* input IMG file */
|
||||
{
|
||||
char *imgfile = optarg;
|
||||
int imgformat = get_file_format(imgfile);
|
||||
switch(imgformat) {
|
||||
case IMG_DFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "[ERROR] Unrecognized format for imgfile : %s [accept only *.img] !!\n\n", imgfile);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
strncpy(parameters->imgfile, imgfile, MAX_PATH);
|
||||
fprintf(stdout, "[INFO] Imgfile: %s Format: %d\n", parameters->imgfile, imgformat);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'o': /* output file */
|
||||
{
|
||||
char *outfile = optarg;
|
||||
parameters->cod_format = get_file_format(outfile);
|
||||
switch(parameters->cod_format) {
|
||||
case J3D_CFMT:
|
||||
case J2K_CFMT:
|
||||
case LSE_CFMT:
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "[ERROR] Unknown output format volume %s [only *.j2k, *.lse3d or *.jp3d]!! \n", outfile);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
strncpy(parameters->outfile, outfile, MAX_PATH);
|
||||
fprintf(stdout, "[INFO] Outfile: %s \n", parameters->outfile);
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'r': /* define compression rates for each layer */
|
||||
{
|
||||
char *s = optarg;
|
||||
while (sscanf(s, "%f", ¶meters->tcp_rates[parameters->tcp_numlayers]) == 1) {
|
||||
parameters->tcp_numlayers++;
|
||||
while (*s && *s != ',') {
|
||||
s++;
|
||||
}
|
||||
if (!*s)
|
||||
break;
|
||||
s++;
|
||||
}
|
||||
parameters->cp_disto_alloc = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'q': /* define distorsion (PSNR) for each layer */
|
||||
{
|
||||
char *s = optarg;
|
||||
while (sscanf(s, "%f", ¶meters->tcp_distoratio[parameters->tcp_numlayers]) == 1) {
|
||||
parameters->tcp_numlayers++;
|
||||
while (*s && *s != ',') {
|
||||
s++;
|
||||
}
|
||||
if (!*s)
|
||||
break;
|
||||
s++;
|
||||
}
|
||||
parameters->cp_fixed_quality = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'f':
|
||||
{
|
||||
fprintf(stdout, "/---------------------------------------------------\\\n");
|
||||
fprintf(stdout, "| Fixed layer allocation option not implemented !! |\n");
|
||||
fprintf(stdout, "\\---------------------------------------------------/\n");
|
||||
/*int *row = NULL, *col = NULL;
|
||||
int numlayers = 0, matrix_width = 0;
|
||||
|
||||
char *s = optarg;
|
||||
sscanf(s, "%d", &numlayers);
|
||||
s++;
|
||||
if (numlayers > 9)
|
||||
s++;
|
||||
|
||||
parameters->tcp_numlayers = numlayers;
|
||||
matrix_width = parameters->numresolution[0] + parameters->numresolution[1] + parameters->numresolution[2];
|
||||
parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int));
|
||||
s = s + 2;
|
||||
|
||||
for (i = 0; i < numlayers; i++) {
|
||||
row = ¶meters->cp_matrice[i * matrix_width];
|
||||
col = row;
|
||||
parameters->tcp_rates[i] = 1;
|
||||
sscanf(s, "%d,", &col[0]);
|
||||
s += 2;
|
||||
if (col[0] > 9)
|
||||
s++;
|
||||
col[1] = 0;
|
||||
col[2] = 0;
|
||||
for (j = 1; j < matrix_width; j++) {
|
||||
col += 3; j+=2;
|
||||
sscanf(s, "%d,%d,%d", &col[0], &col[1], &col[2]);
|
||||
s += 6;
|
||||
if (col[0] > 9)
|
||||
s++;
|
||||
if (col[1] > 9)
|
||||
s++;
|
||||
if (col[2] > 9)
|
||||
s++;
|
||||
}
|
||||
if (i < numlayers - 1)
|
||||
s++;
|
||||
}
|
||||
parameters->cp_fixed_alloc = 1; */
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 't': /* tiles */
|
||||
{
|
||||
if (sscanf(optarg, "%d,%d,%d", ¶meters->cp_tdx, ¶meters->cp_tdy, ¶meters->cp_tdz) !=3) {
|
||||
fprintf(stdout, "[ERROR] '-t' 'dimensions of tiles' argument error ! [-t tdx,tdy,tdz]\n");
|
||||
return 1;
|
||||
}
|
||||
parameters->tile_size_on = true;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'n': /* resolution */
|
||||
{
|
||||
int aux;
|
||||
aux = sscanf(optarg, "%d,%d,%d", ¶meters->numresolution[0], ¶meters->numresolution[1], ¶meters->numresolution[2]);
|
||||
if (aux == 2)
|
||||
parameters->numresolution[2] = 1;
|
||||
else if (aux == 1) {
|
||||
parameters->numresolution[1] = parameters->numresolution[0];
|
||||
parameters->numresolution[2] = 1;
|
||||
}else if (aux == 0){
|
||||
parameters->numresolution[0] = 1;
|
||||
parameters->numresolution[1] = 1;
|
||||
parameters->numresolution[2] = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
case 'c': /* precinct dimension */
|
||||
{
|
||||
char sep;
|
||||
int res_spec = 0;
|
||||
int aux;
|
||||
char *s = optarg;
|
||||
do {
|
||||
sep = 0;
|
||||
aux = sscanf(s, "[%d,%d,%d]%c", ¶meters->prct_init[0][res_spec], ¶meters->prct_init[1][res_spec], ¶meters->prct_init[2][res_spec], &sep);
|
||||
if (sep == ',' && aux != 4) {
|
||||
fprintf(stdout, "[ERROR] '-c' 'dimensions of precincts' argument error ! [-c [prcx_res0,prcy_res0,prcz_res0],...,[prcx_resN,prcy_resN,prcz_resN]]\n");
|
||||
return 1;
|
||||
}
|
||||
parameters->csty |= 0x01;
|
||||
res_spec++;
|
||||
s = strpbrk(s, "]") + 2;
|
||||
}
|
||||
while (sep == ',');
|
||||
parameters->res_spec = res_spec; /* number of precinct size specifications */
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'b': /* code-block dimension */
|
||||
{
|
||||
int cblockw_init = 0, cblockh_init = 0, cblockl_init = 0;
|
||||
if (sscanf(optarg, "%d,%d,%d", &cblockw_init, &cblockh_init, &cblockl_init) != 3) {
|
||||
fprintf(stdout, "[ERROR] '-b' 'dimensions of codeblocks' argument error ! [-b cblkx,cblky,cblkz]\n");
|
||||
return 1;
|
||||
}
|
||||
if (cblockw_init * cblockh_init * cblockl_init > (1<<18) || cblockw_init > 1024 || cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4 || cblockl_init > 1024 || cblockl_init < 4) {
|
||||
fprintf(stdout,"[ERROR] Size of code_block error (option -b) !!\n\nRestriction :\n * width*height*length<=4096\n * 4<=width,height,length<= 1024\n\n");
|
||||
return 1;
|
||||
}
|
||||
parameters->cblock_init[0] = cblockw_init;
|
||||
parameters->cblock_init[1] = cblockh_init;
|
||||
parameters->cblock_init[2] = cblockl_init;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'x': /* creation of index file */
|
||||
{
|
||||
char *index = optarg;
|
||||
strncpy(parameters->index, index, MAX_PATH);
|
||||
parameters->index_on = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'p': /* progression order */
|
||||
{
|
||||
char progression[4];
|
||||
|
||||
strncpy(progression, optarg, 4);
|
||||
parameters->prog_order = give_progression(progression);
|
||||
if (parameters->prog_order == -1) {
|
||||
fprintf(stdout, "[ERROR] Unrecognized progression order [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 's': /* subsampling factor */
|
||||
{
|
||||
if (sscanf(optarg, "%d,%d,%d", ¶meters->subsampling_dx, ¶meters->subsampling_dy, ¶meters->subsampling_dz) != 2) {
|
||||
fprintf(stdout, "[ERROR] '-s' sub-sampling argument error ! [-s dx,dy,dz]\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'd': /* coordonnate of the reference grid */
|
||||
{
|
||||
if (sscanf(optarg, "%d,%d,%d", ¶meters->volume_offset_x0, ¶meters->volume_offset_y0, ¶meters->volume_offset_z0) != 3) {
|
||||
fprintf(stdout, "[ERROR] -d 'coordonnate of the reference grid' argument error !! [-d x0,y0,z0]\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'h': /* display an help description */
|
||||
{
|
||||
encode_help_display();
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
case 'P': /* POC */
|
||||
{
|
||||
int numpocs = 0; /* number of progression order change (POC) default 0 */
|
||||
opj_poc_t *POC = NULL; /* POC : used in case of Progression order change */
|
||||
|
||||
char *s = optarg;
|
||||
POC = parameters->POC;
|
||||
|
||||
fprintf(stdout, "/----------------------------------\\\n");
|
||||
fprintf(stdout, "| POC option not fully tested !! |\n");
|
||||
fprintf(stdout, "\\----------------------------------/\n");
|
||||
|
||||
while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%s", &POC[numpocs].tile,
|
||||
&POC[numpocs].resno0, &POC[numpocs].compno0,
|
||||
&POC[numpocs].layno1, &POC[numpocs].resno1,
|
||||
&POC[numpocs].compno1, POC[numpocs].progorder) == 7) {
|
||||
POC[numpocs].prg = give_progression(POC[numpocs].progorder);
|
||||
/* POC[numpocs].tile; */
|
||||
numpocs++;
|
||||
while (*s && *s != '/') {
|
||||
s++;
|
||||
}
|
||||
if (!*s) {
|
||||
break;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
parameters->numpocs = numpocs;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
case 'S': /* SOP marker */
|
||||
{
|
||||
parameters->csty |= 0x02;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
case 'E': /* EPH marker */
|
||||
{
|
||||
parameters->csty |= 0x04;
|
||||
}
|
||||
break;
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
case 'M': /* Codification mode switch */
|
||||
{
|
||||
fprintf(stdout, "[INFO] Mode switch option not fully tested !!\n");
|
||||
value = 0;
|
||||
if (sscanf(optarg, "%d", &value) == 1) {
|
||||
for (i = 0; i <= 6; i++) {
|
||||
int cache = value & (1 << i);
|
||||
if (cache)
|
||||
parameters->mode |= (1 << i);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
case 'D': /* DCO */
|
||||
{
|
||||
if (sscanf(optarg, "%d", ¶meters->dcoffset) != 1) {
|
||||
fprintf(stdout, "[ERROR] DC offset error !! [-D %d]\n",parameters->dcoffset);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
case 'R': /* ROI */
|
||||
{
|
||||
if (sscanf(optarg, "OI:c=%d,U=%d", ¶meters->roi_compno, ¶meters->roi_shift) != 2) {
|
||||
fprintf(stdout, "[ERROR] ROI error !! [-ROI:c='compno',U='shift']\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
case 'l': /* Tile offset */
|
||||
{
|
||||
if (sscanf(optarg, "%d,%d,%d", ¶meters->cp_tx0, ¶meters->cp_ty0, ¶meters->cp_tz0) != 3) {
|
||||
fprintf(stdout, "[ERROR] -l 'tile offset' argument error !! [-l X0,Y0,Z0]");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* ------------------------------------------------------
|
||||
|
||||
case 'T': // Tranformation of original data (2D-DWT/3D-DWT/3D-RLS/2D-DWT+1D-RLS)
|
||||
{
|
||||
char transform[4];
|
||||
|
||||
strncpy(transform, optarg, 4);
|
||||
parameters->transform_format = give_transform(transform);
|
||||
if (parameters->transform_format == -1) {
|
||||
fprintf(stdout, "[ERROR] -T 'Transform domain' argument error !! [-T 2DWT, 3DWT, 3RLS or 3LSE only]");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
------------------------------------------------------ */
|
||||
|
||||
case 'C': /* Coding of transformed data */
|
||||
{
|
||||
char coding[3];
|
||||
|
||||
strncpy(coding, optarg, 3);
|
||||
parameters->encoding_format = give_coding(coding);
|
||||
if (parameters->encoding_format == -1) {
|
||||
fprintf(stdout, "[ERROR] -C 'Coding algorithm' argument error !! [-C 2EB, 3EB, 2GR, 3GR or GRI only]");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
case 'I': /* reversible or not */
|
||||
{
|
||||
parameters->irreversible = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stdout, "[ERROR] This option is not valid \"-%c %s\"\n", c, optarg);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* check for possible errors */
|
||||
|
||||
if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
|
||||
fprintf(stdout, "usage: jp3d_vm_enc -i volume-file -o jp3d-file (+ options)\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if((parameters->decod_format == BIN_DFMT) && (parameters->imgfile[0] == 0)) {
|
||||
fprintf(stdout, "usage: jp3d_vm_enc -i bin-volume-file -m img-file -o jp3d-file (+ options)\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if((parameters->decod_format != BIN_DFMT) && (parameters->decod_format != PGX_DFMT) && (parameters->decod_format != IMG_DFMT)) {
|
||||
fprintf(stdout, "usage: jp3d_vm_enc -i input-volume-file [*.bin,*.pgx,*.img] -o jp3d-file [*.jp3d,*.j2k] (+ options)\n");
|
||||
return 1;
|
||||
}
|
||||
if((parameters->cod_format != J3D_CFMT) && (parameters->cod_format != J2K_CFMT)) {
|
||||
fprintf(stdout, "usage: jp3d_vm_enc -i input-volume-file [*.bin,*.pgx,*.img] -o jp3d-file [*.jp3d,*.j2k] (+ options)\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if((parameters->encoding_format == ENCOD_2GR || parameters->encoding_format == ENCOD_3GR) && parameters->transform_format != TRF_3D_LSE && parameters->transform_format != TRF_3D_RLS) {
|
||||
fprintf(stdout, "[ERROR] Entropy coding options -C [2GR,3GR] are only compatible with predictive-based transform algorithms: -T [3RLS,3LSE].\n");
|
||||
return 1;
|
||||
}
|
||||
if (parameters->encoding_format == ENCOD_3EB)
|
||||
parameters->mode |= (1 << 6);
|
||||
|
||||
if ((parameters->mode >> 6) & 1) {
|
||||
parameters->encoding_format = ENCOD_3EB;
|
||||
}
|
||||
|
||||
if((parameters->numresolution[2] == 0 || (parameters->numresolution[1] == 0) || (parameters->numresolution[0] == 0))) {
|
||||
fprintf(stdout, "[ERROR] -n 'resolution levels' argument error ! Resolutions must be greater than 1 in order to perform DWT.\n");
|
||||
return 1;
|
||||
}
|
||||
if (parameters->numresolution[1] != parameters->numresolution[0]) {
|
||||
fprintf(stdout, "[ERROR] -n 'resolution levels' argument error ! Resolutions in X and Y axis must be the same in this implementation.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (parameters->numresolution[2] > parameters->numresolution[0]) {
|
||||
fprintf(stdout, "[ERROR] -n 'resolution levels' argument error ! Resolutions in Z axis must be lower than in X-Y axis.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (parameters->dcoffset >= 128 && parameters->dcoffset <= -128) {
|
||||
fprintf(stdout, "[ERROR] -D 'DC offset' argument error ! Value must be -128<=DCO<=128.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(parameters->numresolution[2] != 1) {
|
||||
parameters->transform_format = TRF_3D_DWT;
|
||||
//fprintf(stdout, "[Warning] Resolution level in axial dim > 1 : 3D-DWT will be performed... \n");
|
||||
} else if (parameters->numresolution[2] == 1) {
|
||||
parameters->transform_format = TRF_2D_DWT;
|
||||
//fprintf(stdout, "[Warning] Resolution level in axial dim == 1 : 2D-DWT will be performed... \n");
|
||||
}
|
||||
|
||||
if ((parameters->cod_format == J2K_CFMT) && (parameters->transform_format != TRF_2D_DWT || parameters->encoding_format != ENCOD_2EB)) {
|
||||
fprintf(stdout, "[WARNING] Incompatible options -o *.j2k and defined transform or encoding algorithm. Latter will be ignored\n");
|
||||
parameters->transform_format = TRF_2D_DWT;
|
||||
parameters->encoding_format = ENCOD_2EB;
|
||||
}
|
||||
|
||||
if ((parameters->cp_disto_alloc || parameters->cp_fixed_alloc || parameters->cp_fixed_quality) && (!(parameters->cp_disto_alloc ^ parameters->cp_fixed_quality))) {
|
||||
fprintf(stdout, "[ERROR] Options -r and -q cannot be used together !!\n");
|
||||
return 1;
|
||||
} /* mod fixed_quality */
|
||||
|
||||
/* if no rate entered, lossless by default */
|
||||
if (parameters->tcp_numlayers == 0) {
|
||||
parameters->tcp_rates[0] = 0.0; /* MOD antonin : losslessbug */
|
||||
parameters->tcp_numlayers++;
|
||||
parameters->cp_disto_alloc = 1;
|
||||
}
|
||||
|
||||
if((parameters->cp_tx0 > parameters->volume_offset_x0) || (parameters->cp_ty0 > parameters->volume_offset_y0) || (parameters->cp_tz0 > parameters->volume_offset_z0)) {
|
||||
fprintf(stdout, "[ERROR] Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) TZO(%d)<=IMG_Z0(%d)\n",
|
||||
parameters->cp_tx0, parameters->volume_offset_x0, parameters->cp_ty0, parameters->volume_offset_y0,
|
||||
parameters->cp_tz0, parameters->volume_offset_z0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < parameters->numpocs; i++) {
|
||||
if (parameters->POC[i].prg == -1) {
|
||||
fprintf(stdout,"[ERROR] Unrecognized progression order in option -P (POC n %d) [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n",i + 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 a FILE* client object
|
||||
*/
|
||||
void info_callback(const char *msg, void *client_data) {
|
||||
FILE *stream = (FILE*)client_data;
|
||||
fprintf(stream, "[INFO] %s", msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
bool bSuccess;
|
||||
bool delete_comment = true;
|
||||
opj_cparameters_t parameters; /* compression parameters */
|
||||
opj_event_mgr_t event_mgr; /* event manager */
|
||||
opj_volume_t *volume = NULL;
|
||||
|
||||
/*
|
||||
configure the event callbacks (not required)
|
||||
setting of each callback is optionnal
|
||||
*/
|
||||
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
|
||||
event_mgr.error_handler = error_callback;
|
||||
event_mgr.warning_handler = warning_callback;
|
||||
event_mgr.info_handler = info_callback;
|
||||
|
||||
/* set encoding parameters to default values */
|
||||
opj_set_default_encoder_parameters(¶meters);
|
||||
|
||||
/* parse input and get user encoding parameters */
|
||||
if(parse_cmdline_encoder(argc, argv, ¶meters) == 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(parameters.cp_comment == NULL) {
|
||||
parameters.cp_comment = "Created by OpenJPEG version JP3D";
|
||||
/* no need to delete parameters.cp_comment on exit */
|
||||
delete_comment = false;
|
||||
}
|
||||
|
||||
/* encode the destination volume */
|
||||
/* ---------------------------- */
|
||||
if (parameters.cod_format == J3D_CFMT || parameters.cod_format == J2K_CFMT) {
|
||||
int codestream_length, pixels, bitsin;
|
||||
opj_cio_t *cio = NULL;
|
||||
FILE *f = NULL;
|
||||
opj_cinfo_t* cinfo = NULL;
|
||||
|
||||
/* decode the source volume */
|
||||
/* ----------------------- */
|
||||
switch (parameters.decod_format) {
|
||||
case PGX_DFMT:
|
||||
fprintf(stdout, "[INFO] Loading pgx file(s)\n");
|
||||
volume = pgxtovolume(parameters.infile, ¶meters);
|
||||
if (!volume) {
|
||||
fprintf(stdout, "[ERROR] Unable to load pgx files\n");
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case BIN_DFMT:
|
||||
fprintf(stdout, "[INFO] Loading bin file\n");
|
||||
volume = bintovolume(parameters.infile, parameters.imgfile, ¶meters);
|
||||
if (!volume) {
|
||||
fprintf(stdout, "[ERROR] Unable to load bin file\n");
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case IMG_DFMT:
|
||||
fprintf(stdout, "[INFO] Loading img file\n");
|
||||
volume = imgtovolume(parameters.infile, ¶meters);
|
||||
if (!volume) {
|
||||
fprintf(stderr, "[ERROR] Unable to load img file\n");
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* get a JP3D or J2K compressor handle */
|
||||
if (parameters.cod_format == J3D_CFMT)
|
||||
cinfo = opj_create_compress(CODEC_J3D);
|
||||
else if (parameters.cod_format == J2K_CFMT)
|
||||
cinfo = opj_create_compress(CODEC_J2K);
|
||||
|
||||
/* catch events using our callbacks and give a local context */
|
||||
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stdout);
|
||||
|
||||
/* setup the encoder parameters using the current volume and using user parameters */
|
||||
opj_setup_encoder(cinfo, ¶meters, volume);
|
||||
|
||||
/* open a byte stream for writing */
|
||||
/* allocate memory for all tiles */
|
||||
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
|
||||
|
||||
/* encode the volume */
|
||||
//fprintf(stdout, "[INFO] Encode the volume\n");
|
||||
bSuccess = opj_encode(cinfo, cio, volume, parameters.index);
|
||||
if (!bSuccess) {
|
||||
opj_cio_close(cio);
|
||||
fprintf(stdout, "[ERROR] Failed to encode volume\n");
|
||||
return 1;
|
||||
}
|
||||
codestream_length = cio_tell(cio);
|
||||
pixels =(volume->x1 - volume->x0) * (volume->y1 - volume->y0) * (volume->z1 - volume->z0);
|
||||
bitsin = pixels * volume->comps[0].prec;
|
||||
fprintf(stdout, "[RESULT] Volume: %d x %d x %d (x %d bpv)\n Codestream: %d B, Ratio: %5.3f bpv, (%5.3f : 1) \n",
|
||||
(volume->x1 - volume->x0),(volume->y1 - volume->y0),(volume->z1 - volume->z0),volume->comps[0].prec,
|
||||
codestream_length, ((double)codestream_length * 8.0/(double)pixels), ((double)bitsin/(8.0*(double)codestream_length)));
|
||||
|
||||
/* write the buffer to disk */
|
||||
f = fopen(parameters.outfile, "wb");
|
||||
if (!f) {
|
||||
fprintf(stdout, "[ERROR] Failed to open %s for writing\n", parameters.outfile);
|
||||
return 1;
|
||||
}
|
||||
fwrite(cio->buffer, 1, codestream_length, f);
|
||||
fclose(f);
|
||||
|
||||
/* close and free the byte stream */
|
||||
opj_cio_close(cio);
|
||||
|
||||
/* free remaining compression structures */
|
||||
opj_destroy_compress(cinfo);
|
||||
} else {
|
||||
fprintf(stdout, "[ERROR] Cod_format != JP3d !!! \n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* free user parameters structure */
|
||||
if(delete_comment) {
|
||||
if(parameters.cp_comment) free(parameters.cp_comment);
|
||||
}
|
||||
if(parameters.cp_matrice) free(parameters.cp_matrice);
|
||||
|
||||
/* free volume data */
|
||||
opj_volume_destroy(volume);
|
||||
|
||||
return 0;
|
||||
}
|
||||
189
jp3d/libjp3dvm/bio.c
Executable file
189
jp3d/libjp3dvm/bio.c
Executable file
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
|
||||
* Copyright (c) 2005, Herv<72> Drolon, FreeImage Team
|
||||
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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_includes.h"
|
||||
|
||||
/** @defgroup BIO BIO - Individual bit input-output stream */
|
||||
/*@{*/
|
||||
|
||||
/** @name Local static functions */
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
Write a bit
|
||||
@param bio BIO handle
|
||||
@param b Bit to write (0 or 1)
|
||||
*/
|
||||
static void bio_putbit(opj_bio_t *bio, int b);
|
||||
/**
|
||||
Read a bit
|
||||
@param bio BIO handle
|
||||
@return Returns the read bit
|
||||
*/
|
||||
static int bio_getbit(opj_bio_t *bio);
|
||||
/**
|
||||
Write a byte
|
||||
@param bio BIO handle
|
||||
@return Returns 0 if successful, returns 1 otherwise
|
||||
*/
|
||||
static int bio_byteout(opj_bio_t *bio);
|
||||
/**
|
||||
Read a byte
|
||||
@param bio BIO handle
|
||||
@return Returns 0 if successful, returns 1 otherwise
|
||||
*/
|
||||
static int bio_bytein(opj_bio_t *bio);
|
||||
|
||||
/*@}*/
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
local functions
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
static int bio_byteout(opj_bio_t *bio) {
|
||||
bio->buf = (bio->buf << 8) & 0xffff;
|
||||
bio->ct = bio->buf == 0xff00 ? 7 : 8;
|
||||
if (bio->bp >= bio->end) {
|
||||
return 1;
|
||||
}
|
||||
*bio->bp++ = bio->buf >> 8;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bio_bytein(opj_bio_t *bio) {
|
||||
bio->buf = (bio->buf << 8) & 0xffff;
|
||||
bio->ct = bio->buf == 0xff00 ? 7 : 8;
|
||||
if (bio->bp >= bio->end) {
|
||||
return 1;
|
||||
}
|
||||
bio->buf |= *bio->bp++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bio_putbit(opj_bio_t *bio, int b) {
|
||||
if (bio->ct == 0) {
|
||||
bio_byteout(bio);
|
||||
}
|
||||
bio->ct--;
|
||||
bio->buf |= b << bio->ct;
|
||||
}
|
||||
|
||||
/* MOD antonin */
|
||||
static int bio_getbit(opj_bio_t *bio) {
|
||||
/* DOM */
|
||||
if (bio->ct == 0) {
|
||||
bio_bytein(bio);
|
||||
}
|
||||
bio->ct--;
|
||||
return (bio->buf >> bio->ct) & 1;
|
||||
}
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
Bit Input/Output interface
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
opj_bio_t* bio_create() {
|
||||
opj_bio_t *bio = (opj_bio_t*)opj_malloc(sizeof(opj_bio_t));
|
||||
return bio;
|
||||
}
|
||||
|
||||
void bio_destroy(opj_bio_t *bio) {
|
||||
if(bio) {
|
||||
opj_free(bio);
|
||||
}
|
||||
}
|
||||
|
||||
int bio_numbytes(opj_bio_t *bio) {
|
||||
return (bio->bp - bio->start);
|
||||
}
|
||||
|
||||
void bio_init_enc(opj_bio_t *bio, unsigned char *bp, int len) {
|
||||
bio->start = bp;
|
||||
bio->end = bp + len;
|
||||
bio->bp = bp;
|
||||
bio->buf = 0;
|
||||
bio->ct = 8;
|
||||
}
|
||||
|
||||
void bio_init_dec(opj_bio_t *bio, unsigned char *bp, int len) {
|
||||
bio->start = bp;
|
||||
bio->end = bp + len;
|
||||
bio->bp = bp;
|
||||
bio->buf = 0;
|
||||
bio->ct = 0;
|
||||
}
|
||||
|
||||
void bio_write(opj_bio_t *bio, int v, int n) {
|
||||
int i;
|
||||
for (i = n - 1; i >= 0; i--) {
|
||||
bio_putbit(bio, (v >> i) & 1);
|
||||
}
|
||||
}
|
||||
|
||||
int bio_read(opj_bio_t *bio, int n) {
|
||||
int i, v;
|
||||
v = 0;
|
||||
for (i = n - 1; i >= 0; i--) {
|
||||
v += bio_getbit(bio) << i;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
int bio_flush(opj_bio_t *bio) {
|
||||
bio->ct = 0;
|
||||
if (bio_byteout(bio)) {
|
||||
return 1;
|
||||
}
|
||||
if (bio->ct == 7) {
|
||||
bio->ct = 0;
|
||||
if (bio_byteout(bio)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bio_inalign(opj_bio_t *bio) {
|
||||
bio->ct = 0;
|
||||
if ((bio->buf & 0xff) == 0xff) {
|
||||
if (bio_bytein(bio)) {
|
||||
return 1;
|
||||
}
|
||||
bio->ct = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
132
jp3d/libjp3dvm/bio.h
Executable file
132
jp3d/libjp3dvm/bio.h
Executable file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
|
||||
* Copyright (c) 2005, Herv<72> Drolon, FreeImage Team
|
||||
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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 __BIO_H
|
||||
#define __BIO_H
|
||||
/**
|
||||
@file bio.h
|
||||
@brief Implementation of an individual bit input-output (BIO)
|
||||
|
||||
The functions in BIO.C have for goal to realize an individual bit input - output.
|
||||
*/
|
||||
|
||||
/** @defgroup BIO BIO - Individual bit input-output stream */
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
Individual bit input-output stream (BIO)
|
||||
*/
|
||||
typedef struct opj_bio {
|
||||
/** pointer to the start of the buffer */
|
||||
unsigned char *start;
|
||||
/** pointer to the end of the buffer */
|
||||
unsigned char *end;
|
||||
/** pointer to the present position in the buffer */
|
||||
unsigned char *bp;
|
||||
/** temporary place where each byte is read or written */
|
||||
unsigned int buf;
|
||||
/** coder : number of bits free to write. decoder : number of bits read */
|
||||
int ct;
|
||||
} opj_bio_t;
|
||||
|
||||
/** @name Funciones generales */
|
||||
/*@{*/
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/**
|
||||
Create a new BIO handle
|
||||
@return Returns a new BIO handle if successful, returns NULL otherwise
|
||||
*/
|
||||
opj_bio_t* bio_create();
|
||||
/**
|
||||
Destroy a previously created BIO handle
|
||||
@param bio BIO handle to destroy
|
||||
*/
|
||||
void bio_destroy(opj_bio_t *bio);
|
||||
/**
|
||||
Number of bytes written.
|
||||
@param bio BIO handle
|
||||
@return Returns the number of bytes written
|
||||
*/
|
||||
int bio_numbytes(opj_bio_t *bio);
|
||||
/**
|
||||
Init encoder
|
||||
@param bio BIO handle
|
||||
@param bp Output buffer
|
||||
@param len Output buffer length
|
||||
*/
|
||||
void bio_init_enc(opj_bio_t *bio, unsigned char *bp, int len);
|
||||
/**
|
||||
Init decoder
|
||||
@param bio BIO handle
|
||||
@param bp Input buffer
|
||||
@param len Input buffer length
|
||||
*/
|
||||
void bio_init_dec(opj_bio_t *bio, unsigned char *bp, int len);
|
||||
/**
|
||||
Write bits
|
||||
@param bio BIO handle
|
||||
@param v Value of bits
|
||||
@param n Number of bits to write
|
||||
*/
|
||||
void bio_write(opj_bio_t *bio, int v, int n);
|
||||
/**
|
||||
Read bits
|
||||
@param bio BIO handle
|
||||
@param n Number of bits to read
|
||||
@return Returns the corresponding read number
|
||||
*/
|
||||
int bio_read(opj_bio_t *bio, int n);
|
||||
/**
|
||||
Flush bits
|
||||
@param bio BIO handle
|
||||
@return Returns 1 if successful, returns 0 otherwise
|
||||
*/
|
||||
int bio_flush(opj_bio_t *bio);
|
||||
/**
|
||||
Passes the ending bits (coming from flushing)
|
||||
@param bio BIO handle
|
||||
@return Returns 1 if successful, returns 0 otherwise
|
||||
*/
|
||||
int bio_inalign(opj_bio_t *bio);
|
||||
/**
|
||||
Read a bit
|
||||
@param bio BIO handle
|
||||
@return Returns the read bit
|
||||
*/
|
||||
/* MOD antonin */
|
||||
//int bio_getbit(opj_bio_t *bio);
|
||||
/* DOM */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/*@}*/
|
||||
|
||||
/*@}*/
|
||||
|
||||
#endif /* __BIO_H */
|
||||
|
||||
217
jp3d/libjp3dvm/cio.c
Executable file
217
jp3d/libjp3dvm/cio.c
Executable file
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
|
||||
* Copyright (c) 2005, Herv<72> Drolon, FreeImage Team
|
||||
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
|
||||
* 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_includes.h"
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length) {
|
||||
opj_cp_t *cp = NULL;
|
||||
opj_cio_t *cio = (opj_cio_t*)opj_malloc(sizeof(opj_cio_t));
|
||||
if(!cio) return NULL;
|
||||
cio->cinfo = cinfo;
|
||||
if(buffer && length) {
|
||||
/* wrap a user buffer containing the encoded image */
|
||||
cio->openmode = OPJ_STREAM_READ;
|
||||
cio->buffer = buffer;
|
||||
cio->length = length;
|
||||
}
|
||||
else if(!buffer && !length && cinfo) {
|
||||
/* allocate a buffer for the encoded image */
|
||||
cio->openmode = OPJ_STREAM_WRITE;
|
||||
switch(cinfo->codec_format) {
|
||||
case CODEC_J3D:
|
||||
case CODEC_J2K:
|
||||
cp = ((opj_j3d_t*)cinfo->j3d_handle)->cp;
|
||||
break;
|
||||
default:
|
||||
opj_free(cio);
|
||||
return NULL;
|
||||
}
|
||||
cio->length = cp->tdx * cp->tdy * cp->tdz * cp->tw * cp->th * cp->tl * 4;
|
||||
cio->buffer = (unsigned char *)opj_malloc(cio->length);
|
||||
if(!cio->buffer) {
|
||||
opj_free(cio);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
opj_free(cio);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Initialize byte IO */
|
||||
cio->start = cio->buffer;
|
||||
cio->end = cio->buffer + cio->length;
|
||||
cio->bp = cio->buffer;
|
||||
|
||||
return cio;
|
||||
}
|
||||
|
||||
void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio) {
|
||||
if(cio) {
|
||||
if(cio->openmode == OPJ_STREAM_WRITE) {
|
||||
/* destroy the allocated buffer */
|
||||
opj_free(cio->buffer);
|
||||
}
|
||||
/* destroy the cio */
|
||||
opj_free(cio);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Get position in byte stream.
|
||||
*/
|
||||
int OPJ_CALLCONV cio_tell(opj_cio_t *cio) {
|
||||
return cio->bp - cio->start;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set position in byte stream.
|
||||
*
|
||||
* pos : position, in number of bytes, from the beginning of the stream
|
||||
*/
|
||||
void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos) {
|
||||
cio->bp = cio->start + pos;
|
||||
}
|
||||
|
||||
/*
|
||||
* Number of bytes left before the end of the stream.
|
||||
*/
|
||||
int cio_numbytesleft(opj_cio_t *cio) {
|
||||
return cio->end - cio->bp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get pointer to the current position in the stream.
|
||||
*/
|
||||
unsigned char *cio_getbp(opj_cio_t *cio) {
|
||||
return cio->bp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a byte.
|
||||
*/
|
||||
bool cio_byteout(opj_cio_t *cio, unsigned char v) {
|
||||
if (cio->bp >= cio->end) {
|
||||
opj_event_msg(cio->cinfo, EVT_ERROR, "write error\n");
|
||||
return false;
|
||||
}
|
||||
*cio->bp++ = v;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a byte.
|
||||
*/
|
||||
unsigned char cio_bytein(opj_cio_t *cio) {
|
||||
if (cio->bp >= cio->end) {
|
||||
opj_event_msg(cio->cinfo, EVT_ERROR, "read error\n");
|
||||
return 0;
|
||||
}
|
||||
return *cio->bp++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write some bytes.
|
||||
*
|
||||
* v : value to write
|
||||
* n : number of bytes to write
|
||||
*/
|
||||
unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n) {
|
||||
int i;
|
||||
for (i = n - 1; i >= 0; i--) {
|
||||
if( !cio_byteout(cio, (unsigned char) ((v >> (i << 3)) & 0xff)) )
|
||||
return 0;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read some bytes.
|
||||
*
|
||||
* n : number of bytes to read
|
||||
*
|
||||
* return : value of the n bytes read
|
||||
*/
|
||||
unsigned int cio_read(opj_cio_t *cio, int n) {
|
||||
int i;
|
||||
unsigned int v;
|
||||
v = 0;
|
||||
for (i = n - 1; i >= 0; i--) {
|
||||
v += cio_bytein(cio) << (i << 3);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip some bytes.
|
||||
*
|
||||
* n : number of bytes to skip
|
||||
*/
|
||||
void cio_skip(opj_cio_t *cio, int n) {
|
||||
cio->bp += n;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write some bytes.
|
||||
*
|
||||
* v : value to write
|
||||
* n : number of bytes to write
|
||||
*/
|
||||
int cio_write_int(opj_cio_t *cio, int v, int n) {
|
||||
int i;
|
||||
for (i = n - 1; i >= 0; i--) {
|
||||
if( !cio_byteout(cio, (char) ((v >> (i << 3)) & 0xff)) )
|
||||
return 0;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read some bytes.
|
||||
*
|
||||
* n : number of bytes to read
|
||||
*
|
||||
* return : value of the n bytes read
|
||||
*/
|
||||
int cio_read_int(opj_cio_t *cio, int n) {
|
||||
int i;
|
||||
int v;
|
||||
v = 0;
|
||||
for (i = n - 1; i >= 0; i--) {
|
||||
v += cio_bytein(cio) << (i << 3);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user