Compare commits

...

4 Commits

250 changed files with 52140 additions and 5418 deletions

View File

@ -1,13 +0,0 @@
# 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 '#'

View File

@ -1,15 +0,0 @@
# 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".

View File

@ -1,14 +0,0 @@
# 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

View File

@ -1,23 +0,0 @@
# 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'

View File

@ -1,21 +0,0 @@
# 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.

View File

@ -1,26 +0,0 @@
# 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

View File

@ -1,26 +0,0 @@
# 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.

View File

@ -1,12 +0,0 @@
# 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"

View File

@ -1,13 +0,0 @@
# 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".

View File

@ -1,20 +0,0 @@
# 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".

View File

@ -1,21 +0,0 @@
# 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.

View File

@ -1,23 +0,0 @@
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.*

View File

@ -1,125 +0,0 @@
/*
* 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;
}

View File

@ -1,129 +0,0 @@
/*
* 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;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,89 +0,0 @@
/*
* 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.
*/
/// <summary>
/// Get the minimum of two integers.
/// </summary>
int int_min(int a, int b) {
return a<b?a:b;
}
/// <summary>
/// Get the maximum of two integers.
/// </summary>
int int_max(int a, int b) {
return a>b?a:b;
}
/// <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;
}
/// <summary>
/// Get absolute value of integer.
/// </summary>
int int_abs(int a) {
return a<0?-a:a;
}
/// <summary>
/// Divide an integer and round upwards.
/// </summary>
int int_ceildiv(int a, int b) {
return (a+b-1)/b;
}
/// <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;
}
/// <summary>
/// Divide an integer by a power of 2 and round downwards.
/// </summary>
int int_floordivpow2(int a, int b) {
return a>>b;
}
/// <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;
}

View File

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

View File

@ -1,301 +0,0 @@
/*
* 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;
}

View File

@ -1,768 +0,0 @@
/*
* 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;
}

View File

@ -1,465 +0,0 @@
/*
* 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;
}

View File

@ -1,389 +0,0 @@
/*
* 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;
}
}

View File

@ -1,285 +0,0 @@
/*
* 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;
}

View File

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

View File

@ -1,170 +0,0 @@
/*
* 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;
}

View File

@ -1,35 +0,0 @@
<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>

View File

@ -1,212 +0,0 @@
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
("==============================================");
}
//----------------------------------------------------
}

View File

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

View File

@ -1,85 +0,0 @@
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]";
}
}
}
}

View File

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

View File

@ -0,0 +1,20 @@
Version ****JPWLcorrect****
This version realizes a JPWL decoder based on OpenJPEG library.
Realized decoder accepts an input JPWL codestream, corrects errors sgnalling eventual
residual errors and finally outputs the corrected JPWL codestream. This codestream shall
be used by a JPEG2000 Part-1 decoder to decode the image.
How to use decoder from prompt line:
"jpwl_correct input.j2k o.bmp"
where,
- "input.j2k" is the input corrupted JPWL codestream
- "o.bmp" this file is necessary as parameter but the decoder doesn't create
that as output.
Decoder create output file "output.j2c", that is the corrected JPWL codestream.
Note that .j2c is the extension accepted by "kakadu" decoder.

View File

@ -0,0 +1 @@
Microsoft C/C++ MSF 7.00

View File

@ -0,0 +1,254 @@
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="image_to_j2k"
ProjectGUID="{7CB555D4-C2D9-40B9-B666-E8E1236E5699}"
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="VCWebDeploymentTool"/>
</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="VCWebDeploymentTool"/>
</Configuration>
</Configurations>
<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\mct.c">
</File>
<File
RelativePath="..\libopenjpeg\mqc.c">
</File>
<File
RelativePath="..\libopenjpeg\pi.c">
</File>
<File
RelativePath="..\libopenjpeg\raw.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\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\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>

View File

@ -0,0 +1,561 @@
/* Copyright (c) 2001 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 <openjpeg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern int cslen; // Aggiunta in JPWL (per gestire l'inserimento di RED nella CS!)
int ceildiv(int a, int b)
{
return (a + b - 1) / b;
}
int main(int argc, char **argv)
{
FILE *f;
char *src, *src_name;
char *dest, S1, S2, S3;
int len;
j2k_image_t img;
j2k_cp_t cp;
int w, wr, wrr, h, hr, hrr, max;
int i, image_type = -1, compno, pad, j;
int adjust;
jp2_struct_t *jp2_struct;
if (argc < 3) {
fprintf(stderr,
"usage: %s j2k-file image-file [-reduce n]\n", argv[0]);
return 1;
}
f = fopen(argv[1], "rb");
if (!f) {
fprintf(stderr, "failed to open %s for reading\n", argv[1]);
return 1;
}
dest = argv[2];
cp.reduce_on = 0;
cp.reduce_value = 0;
/* OPTION REDUCE IS ACTIVE */
if (argc == 5) {
if (strcmp(argv[3], "-reduce")) {
fprintf(stderr,
"usage: options " "-reduce n"
" where n is the factor of reduction [%s]\n", argv[3]);
return 1;
}
cp.reduce_on = 1;
sscanf(argv[4], "%d", &cp.reduce_value);
}
while (*dest) {
dest++;
}
dest--;
S3 = *dest;
dest--;
S2 = *dest;
dest--;
S1 = *dest;
if ((S1 == 'p' && S2 == 'g' && S3 == 'x')
|| (S1 == 'P' && S2 == 'G' && S3 == 'X')) {
image_type = 0;
dest--;
*dest = '\0';
}
if ((S1 == 'p' && S2 == 'n' && S3 == 'm')
|| (S1 == 'P' && S2 == 'N' && S3 == 'M') || (S1 == 'p' && S2 == 'g'
&& S3 == 'm')
|| (S1 == 'P' && S2 == 'G' && S3 == 'M') || (S1 == 'P' && S2 == 'P'
&& S3 == 'M')
|| (S1 == 'p' && S2 == 'p' && S3 == 'm')) {
image_type = 1;
}
if ((S1 == 'b' && S2 == 'm' && S3 == 'p')
|| (S1 == 'B' && S2 == 'M' && S3 == 'P')) {
image_type = 2;
}
if (image_type == -1) {
fprintf(stderr,
"!! Unrecognized format for infile : %c%c%c [accept only *.pnm, *.pgm, *.ppm, *.pgx or *.bmp] !!\n\n",
S1, S2, S3);
return 1;
}
fseek(f, 0, SEEK_END);
len = ftell(f);
fseek(f, 0, SEEK_SET);
src = (char *) malloc(len);
fread(src, 1, len, f);
fclose(f);
src_name = argv[1];
while (*src_name) {
src_name++;
}
src_name--;
S3 = *src_name;
src_name--;
S2 = *src_name;
src_name--;
S1 = *src_name;
/* J2K format */
if ((S1 == 'j' && S2 == '2' && S3 == 'k')
|| (S1 == 'J' && S2 == '2' && S3 == 'K') || (S1 == 'j' && S2 == '2'
&& S3 == 'c')
|| (S1 == 'J' && S2 == '2' && S3 == 'C')) {
if (!j2k_decode(src, len, &img, &cp)) {
fprintf(stderr, "j2k_to_image: failed to decode image!\n");
return 1;
}
}
/* JP2 format */
else if ((S1 == 'j' && S2 == 'p' && S3 == '2')
|| (S1 == 'J' && S2 == 'P' && S3 == '2')) {
jp2_struct = (jp2_struct_t *) malloc(sizeof(jp2_struct_t));
jp2_struct->image = &img;
if (jp2_decode(src, len, jp2_struct, &cp)) {
fprintf(stderr, "j2k_to_image: failed to decode image!\n");
return 1;
}
/* Insert code here if you want to create actions on jp2_struct before deleting it */
free(jp2_struct);
}
/* JPT format */
else if ((S1 == 'j' && S2 == 'p' && S3 == 't')
|| (S1 == 'J' && S2 == 'P' && S3 == 'T')) {
if (!j2k_decode_jpt_stream(src, len, &img, &cp)) {
fprintf(stderr, "j2k_to_image: failed to decode image!\n");
return 1;
}
}
/* otherwise : error */
else {
fprintf(stderr,
"j2k_to_image : Unknown format image *.%c%c%c [only *.j2k, *.jp2, *.jpc or *.jpt]!! \n",
S1, S2, S3);
return 1;
}
src = realloc(src, cslen); // Aggiunta in JPWL per evitare errori di free a causa
// della modifica di CS in caso di aggiunta RED!
free(src);
/* ------------------ CREATE OUT IMAGE WITH THE RIGHT FORMAT ----------------------- */
/* ---------------------------- / */
/* / / */
/* / FORMAT : PNM, PGM or PPM / */
/* / / */
/* ---------------------------- / */
switch (image_type) {
case 1: /* PNM PGM PPM */
if (img.numcomps == 3 && img.comps[0].dx == img.comps[1].dx
&& img.comps[1].dx == img.comps[2].dx
&& img.comps[0].dy == img.comps[1].dy
&& img.comps[1].dy == img.comps[2].dy
&& img.comps[0].prec == img.comps[1].prec
&& img.comps[1].prec == img.comps[2].prec) {
f = fopen(argv[2], "wb");
w = ceildiv(img.x1 - img.x0, img.comps[0].dx);
// wr = ceildiv(int_ceildivpow2(img.x1 - img.x0,img.factor),img.comps[0].dx);
wr = img.comps[0].w;
wrr = int_ceildivpow2(img.comps[0].w, img.comps[0].factor);
h = ceildiv(img.y1 - img.y0, img.comps[0].dy);
// hr = ceildiv(int_ceildivpow2(img.y1 - img.y0,img.factor), img.comps[0].dy);
hr = img.comps[0].h;
hrr = int_ceildivpow2(img.comps[0].h, img.comps[0].factor);
max = img.comps[0].prec > 8 ? 255 : (1 << img.comps[0].prec) - 1;
img.comps[0].x0 =
int_ceildivpow2(img.comps[0].x0 -
int_ceildiv(img.x0, img.comps[0].dx),
img.comps[0].factor);
img.comps[0].y0 =
int_ceildivpow2(img.comps[0].y0 -
int_ceildiv(img.y0, img.comps[0].dy),
img.comps[0].factor);
fprintf(f, "P6\n# %d %d %d %d %d\n%d %d\n%d\n",
cp.tcps[cp.tileno[0]].tccps[0].numresolutions, w, h,
img.comps[0].x0, img.comps[0].y0, wrr, hrr, max);
adjust = img.comps[0].prec > 8 ? img.comps[0].prec - 8 : 0;
for (i = 0; i < wrr * hrr; i++) {
char r, g, b;
r = img.comps[0].data[i / wrr * wr + i % wrr];
r += (img.comps[0].sgnd ? 1 << (img.comps[0].prec - 1) : 0);
r = r >> adjust;
g = img.comps[1].data[i / wrr * wr + i % wrr];
g += (img.comps[1].sgnd ? 1 << (img.comps[1].prec - 1) : 0);
g = g >> adjust;
b = img.comps[2].data[i / wrr * wr + i % wrr];
b += (img.comps[2].sgnd ? 1 << (img.comps[2].prec - 1) : 0);
b = b >> adjust;
fprintf(f, "%c%c%c", r, g, b);
}
free(img.comps[0].data);
free(img.comps[1].data);
free(img.comps[2].data);
fclose(f);
} else {
for (compno = 0; compno < img.numcomps; compno++) {
char name[256];
if (img.numcomps > 1) {
sprintf(name, "%d.%s", compno, argv[2]);
} else {
sprintf(name, "%s", argv[2]);
}
f = fopen(name, "wb");
w = ceildiv(img.x1 - img.x0, img.comps[compno].dx);
// wr = ceildiv(int_ceildivpow2(img.x1 - img.x0,img.factor),img.comps[compno].dx);
wr = img.comps[compno].w;
wrr =
int_ceildivpow2(img.comps[compno].w, img.comps[compno].factor);
h = ceildiv(img.y1 - img.y0, img.comps[compno].dy);
// hr = ceildiv(int_ceildivpow2(img.y1 - img.y0,img.factor), img.comps[compno].dy);
hr = img.comps[compno].h;
hrr =
int_ceildivpow2(img.comps[compno].h, img.comps[compno].factor);
max =
img.comps[compno].prec >
8 ? 255 : (1 << img.comps[compno].prec) - 1;
img.comps[compno].x0 =
int_ceildivpow2(img.comps[compno].x0 -
int_ceildiv(img.x0,
img.comps[compno].dx),
img.comps[compno].factor);
img.comps[compno].y0 =
int_ceildivpow2(img.comps[compno].y0 -
int_ceildiv(img.y0,
img.comps[compno].dy),
img.comps[compno].factor);
fprintf(f, "P5\n# %d %d %d %d %d\n%d %d\n%d\n",
cp.tcps[cp.tileno[0]].tccps[compno].
numresolutions, w, h, img.comps[compno].x0,
img.comps[compno].y0, wrr, hrr, max);
adjust =
img.comps[compno].prec > 8 ? img.comps[compno].prec - 8 : 0;
for (i = 0; i < wrr * hrr; i++) {
char l;
l = img.comps[compno].data[i / wrr * wr + i % wrr];
l += (img.comps[compno].
sgnd ? 1 << (img.comps[compno].prec - 1) : 0);
l = l >> adjust;
fprintf(f, "%c", l);
}
fclose(f);
free(img.comps[compno].data);
}
}
break;
/* ------------------------ / */
/* / / */
/* / FORMAT : PGX / */
/* / / */
/* /----------------------- / */
case 0: /* PGX */
for (compno = 0; compno < img.numcomps; compno++) {
j2k_comp_t *comp = &img.comps[compno];
char name[256];
int nbytes = 0;
//if (img.numcomps > 1)
sprintf(name, "%s-%d.pgx", argv[2], compno);
//else
//sprintf(name, "%s.pgx", argv[2]);
f = fopen(name, "wb");
// w = ceildiv(img.x1 - img.x0, comp->dx);
// wr = ceildiv(int_ceildivpow2(img.x1 - img.x0,img.factor), comp->dx);
w = img.comps[compno].w;
wr = int_ceildivpow2(img.comps[compno].w, img.comps[compno].factor);
// h = ceildiv(img.y1 - img.y0, comp->dy);
// hr = ceildiv(int_ceildivpow2(img.y1 - img.y0,img.factor), comp->dy);
h = img.comps[compno].h;
hr = int_ceildivpow2(img.comps[compno].h, img.comps[compno].factor);
fprintf(f, "PG ML %c %d %d %d\n", comp->sgnd ? '-' : '+',
comp->prec, wr, hr);
if (comp->prec <= 8)
nbytes = 1;
else if (comp->prec <= 16)
nbytes = 2;
else
nbytes = 4;
for (i = 0; i < wr * hr; i++) {
int v = img.comps[compno].data[i / wr * w + i % wr];
for (j = nbytes - 1; j >= 0; j--) {
char byte = (char) (v >> (j * 8));
fwrite(&byte, 1, 1, f);
}
}
free(img.comps[compno].data);
fclose(f);
}
break;
/* ------------------------ / */
/* / / */
/* / FORMAT : BMP / */
/* / / */
/* /----------------------- / */
case 2: /* BMP */
if (img.numcomps == 3 && img.comps[0].dx == img.comps[1].dx
&& img.comps[1].dx == img.comps[2].dx
&& img.comps[0].dy == img.comps[1].dy
&& img.comps[1].dy == img.comps[2].dy
&& img.comps[0].prec == img.comps[1].prec
&& img.comps[1].prec == img.comps[2].prec) {
/* -->> -->> -->> -->>
24 bits color
<<-- <<-- <<-- <<-- */
f = fopen(argv[2], "wb");
// w = ceildiv(img.x1 - img.x0, img.comps[0].dx);
// wr = ceildiv(int_ceildivpow2(img.x1 - img.x0,img.factor), img.comps[0].dx);
w = img.comps[0].w;
wr = int_ceildivpow2(img.comps[0].w, img.comps[0].factor);
// h = ceildiv(img.y1 - img.y0, img.comps[0].dy);
// hr = ceildiv(int_ceildivpow2(img.y1 - img.y0,img.factor), img.comps[0].dy);
h = img.comps[0].h;
hr = int_ceildivpow2(img.comps[0].h, img.comps[0].factor);
fprintf(f, "BM");
/* FILE HEADER */
/* ------------- */
fprintf(f, "%c%c%c%c",
(unsigned char) (hr * wr * 3 + 3 * hr * (wr % 2) +
54) & 0xff,
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
>> 8) & 0xff,
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
>> 16) & 0xff,
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
>> 24) & 0xff);
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (54) & 0xff, ((54) >> 8) & 0xff,
((54) >> 16) & 0xff, ((54) >> 24) & 0xff);
/* INFO HEADER */
/* ------------- */
fprintf(f, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff,
((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (unsigned char) ((wr) & 0xff),
(unsigned char) ((wr) >> 8) & 0xff,
(unsigned char) ((wr) >> 16) & 0xff,
(unsigned char) ((wr) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (unsigned char) ((hr) & 0xff),
(unsigned char) ((hr) >> 8) & 0xff,
(unsigned char) ((hr) >> 16) & 0xff,
(unsigned char) ((hr) >> 24) & 0xff);
fprintf(f, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
fprintf(f, "%c%c", (24) & 0xff, ((24) >> 8) & 0xff);
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
fprintf(f, "%c%c%c%c",
(unsigned char) (3 * hr * wr +
3 * hr * (wr % 2)) & 0xff,
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
8) & 0xff,
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
16) & 0xff,
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
24) & 0xff);
fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
for (i = 0; i < wr * hr; i++) {
unsigned char R, G, B;
/* a modifier */
// R = img.comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
R = img.comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
// G = img.comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
G = img.comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
// B = img.comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
B = img.comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
fprintf(f, "%c%c%c", B, G, R);
if ((i + 1) % wr == 0) {
for (pad = (3 * wr) % 4 ? 4 - (3 * wr) % 4 : 0; pad > 0; pad--) /* ADD */
fprintf(f, "%c", 0);
}
}
fclose(f);
free(img.comps[1].data);
free(img.comps[2].data);
} else { /* Gray-scale */
/* -->> -->> -->> -->>
8 bits non code (Gray scale)
<<-- <<-- <<-- <<-- */
f = fopen(argv[2], "wb");
// w = ceildiv(img.x1 - img.x0, img.comps[0].dx);
// wr = ceildiv(int_ceildivpow2(img.x1 - img.x0,img.factor), img.comps[0].dx);
w = img.comps[0].w;
wr = int_ceildivpow2(img.comps[0].w, img.comps[0].factor);
// h = ceildiv(img.y1 - img.y0, img.comps[0].dy);
// hr = ceildiv(int_ceildivpow2(img.y1 - img.y0,img.factor), img.comps[0].dy);
h = img.comps[0].h;
hr = int_ceildivpow2(img.comps[0].h, img.comps[0].factor);
fprintf(f, "BM");
/* FILE HEADER */
/* ------------- */
fprintf(f, "%c%c%c%c",
(unsigned char) (hr * wr + 54 + 1024 +
hr * (wr % 2)) & 0xff,
(unsigned char) ((hr * wr + 54 + 1024 + hr * (wr % 2))
>> 8) & 0xff,
(unsigned char) ((hr * wr + 54 + 1024 + hr * (wr % 2))
>> 16) & 0xff,
(unsigned char) ((hr * wr + 54 + 1024 + wr * (wr % 2))
>> 24) & 0xff);
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (54 + 1024) & 0xff,
((54 + 1024) >> 8) & 0xff, ((54 + 1024) >> 16) & 0xff,
((54 + 1024) >> 24) & 0xff);
/* INFO HEADER */
/* ------------- */
fprintf(f, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff,
((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (unsigned char) ((wr) & 0xff),
(unsigned char) ((wr) >> 8) & 0xff,
(unsigned char) ((wr) >> 16) & 0xff,
(unsigned char) ((wr) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (unsigned char) ((hr) & 0xff),
(unsigned char) ((hr) >> 8) & 0xff,
(unsigned char) ((hr) >> 16) & 0xff,
(unsigned char) ((hr) >> 24) & 0xff);
fprintf(f, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
fprintf(f, "%c%c", (8) & 0xff, ((8) >> 8) & 0xff);
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
fprintf(f, "%c%c%c%c",
(unsigned char) (hr * wr + hr * (wr % 2)) & 0xff,
(unsigned char) ((hr * wr + hr * (wr % 2)) >> 8) &
0xff,
(unsigned char) ((hr * wr + hr * (wr % 2)) >> 16) &
0xff,
(unsigned char) ((hr * wr + hr * (wr % 2)) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff,
((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff,
((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
}
for (i = 0; i < 256; i++) {
fprintf(f, "%c%c%c%c", i, i, i, 0);
}
for (i = 0; i < wr * hr; i++) {
/* a modifier !! */
// fprintf(f, "%c", img.comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)]);
fprintf(f, "%c",
img.comps[0].data[w * hr - ((i) / (wr) + 1) * w +
(i) % (wr)]);
/*if (((i + 1) % w == 0 && w % 2))
fprintf(f, "%c", 0); */
if ((i + 1) % wr == 0) {
for (pad = wr % 4 ? 4 - wr % 4 : 0; pad > 0; pad--) /* ADD */
fprintf(f, "%c", 0);
}
}
fclose(f);
free(img.comps[0].data);
break;
default:
break;
}
return 0;
}

View File

@ -0,0 +1,244 @@
# 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 Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "../libopenjpeg" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "DONT_HAVE_GETOPT" /YX /FD /c
# ADD BASE RSC /l 0x80c /d "NDEBUG"
# ADD RSC /l 0x80c /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 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /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 "j2k_to_image___Win32_Debug"
# PROP BASE Intermediate_Dir "j2k_to_image___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "j2k_to_image___Win32_Debug"
# PROP Intermediate_Dir "j2k_to_image___Win32_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 /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "DONT_HAVE_GETOPT" /YX /FD /GZ /c
# ADD BASE RSC /l 0x80c /d "_DEBUG"
# ADD RSC /l 0x80c /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 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 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 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\fix.c
# End Source File
# Begin Source File
SOURCE=.\compat\getopt.c
# End Source File
# Begin Source File
SOURCE=..\libopenjpeg\int.c
# End Source File
# Begin Source File
SOURCE=..\libopenjpeg\j2k.c
# End Source File
# Begin Source File
SOURCE=.\j2k_to_image.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\jpw.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\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\fix.h
# End Source File
# Begin Source File
SOURCE=.\compat\getopt.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\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\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"
# End Group
# End Target
# End Project

View File

@ -0,0 +1 @@
Microsoft C/C++ MSF 7.00

View File

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

View File

@ -0,0 +1 @@
ÐÏࡱ

View File

@ -0,0 +1,266 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="j2k_to_image"
ProjectGUID="{3C09E691-8555-47D1-B1E6-D411A6314AC8}"
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"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="../libopenjpeg"
PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE,DONT_HAVE_GETOPT"
StringPooling="TRUE"
RuntimeLibrary="4"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/j2k_to_image.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/j2k_to_image.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ProgramDatabaseFile=".\Release/j2k_to_image.pdb"
SubSystem="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Release/j2k_to_image.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="2060"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\j2k_to_image___Win32_Debug"
IntermediateDirectory=".\j2k_to_image___Win32_Debug"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../libopenjpeg"
PreprocessorDefinitions="_DEBUG,WIN32,_CONSOLE,DONT_HAVE_GETOPT"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\j2k_to_image___Win32_Debug/j2k_to_image.pch"
AssemblerListingLocation=".\j2k_to_image___Win32_Debug/"
ObjectFile=".\j2k_to_image___Win32_Debug/"
ProgramDataBaseFileName=".\j2k_to_image___Win32_Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="odbc32.lib odbccp32.lib"
OutputFile=".\j2k_to_image___Win32_Debug/j2k_to_image.exe"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\j2k_to_image___Win32_Debug/j2k_to_image.pdb"
SubSystem="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\j2k_to_image___Win32_Debug/j2k_to_image.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>
</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="..\libopenjpeg\dwt.c">
</File>
<File
RelativePath="..\libopenjpeg\fix.c">
</File>
<File
RelativePath=".\compat\getopt.c">
</File>
<File
RelativePath="..\libopenjpeg\int.c">
</File>
<File
RelativePath="..\libopenjpeg\j2k.c">
</File>
<File
RelativePath=".\j2k_to_image.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\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="..\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\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>

File diff suppressed because it is too large Load Diff

View File

@ -193,9 +193,13 @@ typedef struct {
* len: length of destination buffer * len: length of destination buffer
* index : index file name * index : index file name
*/ */
void j2k_read_jpwlms();
LIBJ2K_API int j2k_encode(j2k_image_t * i, j2k_cp_t * cp, char *output, LIBJ2K_API int j2k_encode(j2k_image_t * i, j2k_cp_t * cp, char *output,
int len, char *index); int len, char *index);
void jpwl_read_esd();
/* LIBJ2K_API int j2k_encode(j2k_image_t *i, j2k_cp_t *cp,unsigned char *dest, int len); */ /* LIBJ2K_API int j2k_encode(j2k_image_t *i, j2k_cp_t *cp,unsigned char *dest, int len); */
/* /*
* Decode an image from a JPEG-2000 codestream * Decode an image from a JPEG-2000 codestream

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,46 @@
#ifndef __JPW_H
#define __JPW_H
int decode_JPWL(unsigned char *src, int len);
int read_EPC();
int read_EPB_2(int *j2k_state);
int read_EPB(int next,int *j2k_state);
//void read_EPB(int *j2k_state);
int read_EPB_PM(int *j2k_state);
void insert_RED(int pos, int lred, int redlenok);
void write_buff(unsigned char *buff,int pos,long cl);
void read_buff(unsigned char *buff,int pos,long cl);
void ResetCRC();
void UpdateCRC16(char x);
void UpdateCRC32(char x);
char reflectByte(char inbyte);
void reflectCRC32();
void generate_gf(int nn, int kk);
void gen_poly(int nn, int kk);
void encode_rs(int nn, int kk, int tt);
void decode_rs(int nn, int kk, int tt);
#endif

View File

@ -536,7 +536,10 @@ void mqc_init_dec(unsigned char *bp, int len)
mqc_start = bp; mqc_start = bp;
mqc_end = bp + len; mqc_end = bp + len;
mqc_bp = bp; mqc_bp = bp;
mqc_c = *mqc_bp << 16; //add antonin initbug1
if (len==0) mqc_c = 0xff << 16;
else mqc_c = *mqc_bp << 16;
//dda
mqc_bytein(); mqc_bytein();
mqc_c <<= 7; mqc_c <<= 7;
mqc_ct -= 7; mqc_ct -= 7;

View File

@ -269,6 +269,7 @@ int pi_next_rpcl(pi_iterator_t * pi)
pi->compno < pi->poc.compno1; pi->compno++) { pi->compno < pi->poc.compno1; pi->compno++) {
int levelno; int levelno;
int trx0, try0; int trx0, try0;
int trx1, try1;// Add antonin pcrl
int rpx, rpy; int rpx, rpy;
int prci, prcj; int prci, prcj;
comp = &pi->comps[pi->compno]; comp = &pi->comps[pi->compno];
@ -279,6 +280,8 @@ int pi_next_rpcl(pi_iterator_t * pi)
levelno = comp->numresolutions - 1 - pi->resno; levelno = comp->numresolutions - 1 - pi->resno;
trx0 = int_ceildiv(pi->tx0, comp->dx << levelno); trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
try0 = int_ceildiv(pi->ty0, comp->dy << levelno); try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);// Add antonin pcrl
try1 = int_ceildiv(pi->ty1, comp->dy << levelno);// Add antonin pcrl
rpx = res->pdx + levelno; rpx = res->pdx + levelno;
rpy = res->pdy + levelno; rpy = res->pdy + levelno;
if (! if (!
@ -296,6 +299,10 @@ int pi_next_rpcl(pi_iterator_t * pi)
if ((res->pw==0)||(res->pw==0)) continue; if ((res->pw==0)||(res->pw==0)) continue;
//ddA //ddA
//Add Antonin : pcrl
if ((trx0==trx1)||(try0==try1)) continue;
//ddA
prci = prci =
int_floordivpow2(int_ceildiv int_floordivpow2(int_ceildiv
(pi->x, comp->dx << levelno), (pi->x, comp->dx << levelno),
@ -358,33 +365,36 @@ int pi_next_pcrl(pi_iterator_t * pi)
} }
} }
for (pi->y = pi->ty0; pi->y < pi->ty1; for (pi->y = pi->ty0; pi->y < pi->ty1;
pi->y += pi->dy - (pi->y % pi->dy)) { pi->y += pi->dy - (pi->y % pi->dy)) {
for (pi->x = pi->tx0; pi->x < pi->tx1; for (pi->x = pi->tx0; pi->x < pi->tx1;
pi->x += pi->dx - (pi->x % pi->dx)) { pi->x += pi->dx - (pi->x % pi->dx)) {
for (pi->compno = pi->poc.compno0; for (pi->compno = pi->poc.compno0;
pi->compno < pi->poc.compno1; pi->compno++) { pi->compno < pi->poc.compno1; pi->compno++) {
comp = &pi->comps[pi->compno]; comp = &pi->comps[pi->compno];
for (pi->resno = pi->poc.resno0; for (pi->resno = pi->poc.resno0;
pi->resno < int_min(pi->poc.resno1, pi->resno < int_min(pi->poc.resno1,
comp->numresolutions); pi->resno++) { comp->numresolutions); pi->resno++) {
int levelno; int levelno;
int trx0, try0; int trx0, try0;
int trx1, try1;// Add antonin pcrl
int rpx, rpy; int rpx, rpy;
int prci, prcj; int prci, prcj;
res = &comp->resolutions[pi->resno]; res = &comp->resolutions[pi->resno];
levelno = comp->numresolutions - 1 - pi->resno; levelno = comp->numresolutions - 1 - pi->resno;
trx0 = int_ceildiv(pi->tx0, comp->dx << levelno); trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
try0 = int_ceildiv(pi->ty0, comp->dy << levelno); try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);// Add antonin pcrl
try1 = int_ceildiv(pi->ty1, comp->dy << levelno);// Add antonin pcrl
rpx = res->pdx + levelno; rpx = res->pdx + levelno;
rpy = res->pdy + levelno; rpy = res->pdy + levelno;
if (! if (!
(pi->x % (comp->dx << rpx) == 0 (pi->x % (comp->dx << rpx) == 0
|| (pi->x == pi->tx0 && (trx0 << levelno) % (1 << rpx)))) { || (pi->x == pi->tx0 && (trx0 << levelno) % (1 << rpx)))) {
continue; continue;
} }
if (! if (!
(pi->y % (comp->dy << rpy) == 0 (pi->y % (comp->dy << rpy) == 0
|| (pi->y == pi->ty0 && (try0 << levelno) % (1 << rpx)))) { || (pi->y == pi->ty0 && (try0 << levelno) % (1 << rpx)))) {
continue; continue;
} }
@ -392,28 +402,32 @@ int pi_next_pcrl(pi_iterator_t * pi)
if ((res->pw==0)||(res->pw==0)) continue; if ((res->pw==0)||(res->pw==0)) continue;
//ddA //ddA
//Add Antonin : pcrl
if ((trx0==trx1)||(try0==try1)) continue;
//ddA
prci = prci =
int_floordivpow2(int_ceildiv int_floordivpow2(int_ceildiv
(pi->x, comp->dx << levelno), (pi->x, comp->dx << levelno),
res->pdx) - int_floordivpow2(trx0, res->pdx); res->pdx) - int_floordivpow2(trx0, res->pdx);
prcj = prcj =
int_floordivpow2(int_ceildiv int_floordivpow2(int_ceildiv
(pi->y, comp->dy << levelno), (pi->y, comp->dy << levelno),
res->pdy) - int_floordivpow2(try0, res->pdy); res->pdy) - int_floordivpow2(try0, res->pdy);
pi->precno = prci + prcj * res->pw; pi->precno = prci + prcj * res->pw;
for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) { for (pi->layno = 0; pi->layno < pi->poc.layno1; pi->layno++) {
if (!pi-> if (!pi->
include[pi->layno * pi->step_l + include[pi->layno * pi->step_l +
pi->resno * pi->step_r + pi->resno * pi->step_r +
pi->compno * pi->step_c + pi->compno * pi->step_c +
pi->precno * pi->step_p]) { pi->precno * pi->step_p]) {
pi->include[pi->layno * pi->step_l + pi->include[pi->layno * pi->step_l +
pi->resno * pi->step_r + pi->resno * pi->step_r +
pi->compno * pi->step_c + pi->compno * pi->step_c +
pi->precno * pi->step_p] = 1; pi->precno * pi->step_p] = 1;
return 1; return 1;
} }
skip:; skip:;
} }
} }
} }
@ -460,12 +474,15 @@ int pi_next_cprl(pi_iterator_t * pi)
comp->numresolutions); pi->resno++) { comp->numresolutions); pi->resno++) {
int levelno; int levelno;
int trx0, try0; int trx0, try0;
int trx1, try1;// Add antonin pcrl
int rpx, rpy; int rpx, rpy;
int prci, prcj; int prci, prcj;
res = &comp->resolutions[pi->resno]; res = &comp->resolutions[pi->resno];
levelno = comp->numresolutions - 1 - pi->resno; levelno = comp->numresolutions - 1 - pi->resno;
trx0 = int_ceildiv(pi->tx0, comp->dx << levelno); trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
try0 = int_ceildiv(pi->ty0, comp->dy << levelno); try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);// Add antonin pcrl
try1 = int_ceildiv(pi->ty1, comp->dy << levelno);// Add antonin pcrl
rpx = res->pdx + levelno; rpx = res->pdx + levelno;
rpy = res->pdy + levelno; rpy = res->pdy + levelno;
if (! if (!
@ -483,6 +500,10 @@ int pi_next_cprl(pi_iterator_t * pi)
if ((res->pw==0)||(res->pw==0)) continue; if ((res->pw==0)||(res->pw==0)) continue;
//ddA //ddA
//Add Antonin : pcrl
if ((trx0==trx1)||(try0==try1)) continue;
//ddA
prci = prci =
int_floordivpow2(int_ceildiv int_floordivpow2(int_ceildiv
(pi->x, comp->dx << levelno), (pi->x, comp->dx << levelno),

View File

@ -64,8 +64,8 @@ void tcd_dump(tcd_image_t * img, int curtileno)
fprintf(stderr, "image {\n"); fprintf(stderr, "image {\n");
fprintf(stderr, " tw=%d, th=%d x0=%d x1=%d y0=%d y1=%d\n", img->tw, img->th, fprintf(stderr, " tw=%d, th=%d x0=%d x1=%d y0=%d y1=%d\n", img->tw, img->th,
tcd_img->x0, tcd_img->x1, tcd_img->y0, tcd_img->y1); tcd_img->x0, tcd_img->x1, tcd_img->y0, tcd_img->y1);
for (tileno = 0; tileno < 1; tileno++) { for (tileno = 0; tileno < img->th*img->tw; tileno++) {
tcd_tile_t *tile = &tcd_image.tiles[curtileno]; tcd_tile_t *tile = &tcd_image.tiles[tileno];
fprintf(stderr, " tile {\n"); fprintf(stderr, " tile {\n");
fprintf(stderr, " x0=%d, y0=%d, x1=%d, y1=%d, numcomps=%d\n", tile->x0, tile->y0, tile->x1, tile->y1, tile->numcomps); fprintf(stderr, " x0=%d, y0=%d, x1=%d, y1=%d, numcomps=%d\n", tile->x0, tile->y0, tile->x1, tile->y1, tile->numcomps);
for (compno = 0; compno < tile->numcomps; compno++) { for (compno = 0; compno < tile->numcomps; compno++) {

View File

@ -0,0 +1,6 @@
obj
obj.w32
bin
bin.w32
lib
lib.w32

View File

@ -0,0 +1,94 @@
# $Id$
#
# makefile for OpenJPEG codec
OPENJPEG_DIR = ../libopenjpeg
ifndef DEBUG
LDFLAGS = -s -lm
else
LDFLAGS = -lm
endif
CFLAGS = -Wall -O3 -fno-strength-reduce -fomit-frame-pointer -I$(OPENJPEG_DIR)
OBJ_DIR_W32 = obj.w32
BIN_DIR_W32 = bin.w32
LIB_DIR_W32 = $(OPENJPEG_DIR)/lib.w32
ifdef MINGW32
CC = i386-mingw32-gcc
CFLAGS += -DDONT_HAVE_GETOPT
OBJ_DIR = $(OBJ_DIR_W32)
BIN_DIR = $(BIN_DIR_W32)
LIB_DIR = lib.w32
all: $(BIN_DIR) $(OBJ_DIR) $(LIB_DIR) \
$(addprefix $(BIN_DIR)/,j2k_to_image.exe image_to_j2k.exe)
else
CC = gcc
OBJ_DIR = obj
BIN_DIR = bin
LIB_DIR = lib
all: $(BIN_DIR) $(OBJ_DIR) $(LIB_DIR) \
$(addprefix $(BIN_DIR)/,j2k_to_image image_to_j2k)
endif
ifdef DYNAMIC
ifdef MINGW32
LIB_OPENJPEG = $(LIB_DIR)/libopenjpeg.dll
LDFLAGS += -L$(LIB_DIR) -lopenjpeg
else
LIB_OPENJPEG = $(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.so
LDFLAGS += -L$(OPENJPEG_DIR)/$(LIB_DIR) -lopenjpeg
endif
else
LIB_OPENJPEG = $(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.a
LDFLAGS += $(LIB_OPENJPEG)
endif
$(BIN_DIR):
mkdir $(BIN_DIR)
$(OBJ_DIR):
mkdir $(OBJ_DIR)
$(LIB_DIR):
mkdir $(LIB_DIR)
$(LIB_DIR)/libopenjpeg.dll: $(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.dll
ln -sf ../$< $@
$(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.dll:
cd $(OPENJPEG_DIR) && \
$(MAKE) $(OBJ_DIR) $(LIB_DIR) $(LIB_DIR)/libopenjpeg.dll
$(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.a:
cd $(OPENJPEG_DIR) && \
$(MAKE) $(OBJ_DIR) $(LIB_DIR) $(LIB_DIR)/libopenjpeg.a
$(OPENJPEG_DIR)/$(LIB_DIR)/libopenjpeg.so:
cd $(OPENJPEG_DIR) && \
$(MAKE) $(LIB_DIR) $(LIB_DIR)/libopenjpeg.so
$(OBJ_DIR)/%.o:
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
$(OBJ_DIR)/getopt.o: compat/getopt.c
$(OBJ_DIR)/convert.o: convert.c
$(OBJ_DIR)/j2k_to_image.o: j2k_to_image.c
$(OBJ_DIR)/image_to_j2k.o: image_to_j2k.c convert.h
J2I_OBJS = $(addprefix $(OBJ_DIR)/,j2k_to_image.o)
I2J_OBJS = $(addprefix $(OBJ_DIR)/,image_to_j2k.o convert.o)
$(BIN_DIR)/j2k_to_image: $(J2I_OBJS) $(LIB_OPENJPEG)
${CC} -o $@ $(J2I_OBJS) ${LDFLAGS}
$(BIN_DIR)/image_to_j2k: $(I2J_OBJS) $(LIB_OPENJPEG)
${CC} -o $@ $(I2J_OBJS) ${LDFLAGS}
$(BIN_DIR)/j2k_to_image.exe: $(J2I_OBJS) $(LIB_OPENJPEG)
${CC} -o $@ $(J2I_OBJS) ${LDFLAGS}
$(BIN_DIR)/image_to_j2k.exe: $(I2J_OBJS) $(LIB_OPENJPEG) $(OBJ_DIR)/getopt.o
${CC} -o $@ $(I2J_OBJS) ${LDFLAGS} $(OBJ_DIR)/getopt.o
clean:
rm -f $(BIN_DIR_W32)/* $(BIN_DIR)/* $(OBJ_DIR_W32)/* $(OBJ_DIR)/*

View File

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

View File

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

View File

@ -0,0 +1,913 @@
/*
* 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 <openjpeg.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
/* -->> -->> -->> -->>
BMP IMAGE FORMAT
<<-- <<-- <<-- <<-- */
/* UINT2 defines a two byte word */
typedef unsigned short int UINT2;
/* UINT4 defines a four byte word */
typedef unsigned long int UINT4;
typedef struct {
UINT2 bfType; /* 'BM' for Bitmap (19776) */
UINT4 bfSize; /* Size of the file */
UINT2 bfReserved1; /* Reserved : 0 */
UINT2 bfReserved2; /* Reserved : 0 */
UINT4 bfOffBits; /* Offset */
} BITMAPFILEHEADER_t;
typedef struct {
UINT4 biSize; /* Size of the structure in bytes */
UINT4 biWidth; /* Width of the image in pixels */
UINT4 biHeight; /* Heigth of the image in pixels */
UINT2 biPlanes; /* 1 */
UINT2 biBitCount; /* Number of color bits by pixels */
UINT4 biCompression; /* Type of encoding 0: none 1: RLE8 2: RLE4 */
UINT4 biSizeImage; /* Size of the image in bytes */
UINT4 biXpelsPerMeter; /* Horizontal (X) resolution in pixels/meter */
UINT4 biYpelsPerMeter; /* Vertical (Y) resolution in pixels/meter */
UINT4 biClrUsed; /* Number of color used in the image (0: ALL) */
UINT4 biClrImportant; /* Number of important color (0: ALL) */
} BITMAPINFOHEADER_t;
int bmptoimage(char *filename, j2k_image_t * img, int subsampling_dx,
int subsampling_dy, int Dim[2])
{
FILE *IN;
FILE *Compo0 = NULL, *Compo1 = NULL, *Compo2 = NULL;
BITMAPFILEHEADER_t File_h;
BITMAPINFOHEADER_t Info_h;
unsigned char *RGB;
unsigned char *table_R, *table_G, *table_B;
unsigned int j, w, h, PAD, type = 0;
int i;
int gray_scale = 1, not_end_file = 1;
unsigned int line = 0, col = 0;
unsigned char v, v2;
UINT4 W, H;
IN = fopen(filename, "rb");
if (!IN) {
fprintf(stderr,
"\033[0;33mFailed to open %s for reading !!\033[0;39m\n",
filename);
return 0;
}
File_h.bfType = getc(IN);
File_h.bfType = (getc(IN) << 8) + File_h.bfType;
if (File_h.bfType != 19778) {
printf("Error, not a BMP file!\n");
return 0;
} else {
/* FILE HEADER */
/* ------------- */
File_h.bfSize = getc(IN);
File_h.bfSize = (getc(IN) << 8) + File_h.bfSize;
File_h.bfSize = (getc(IN) << 16) + File_h.bfSize;
File_h.bfSize = (getc(IN) << 24) + File_h.bfSize;
File_h.bfReserved1 = getc(IN);
File_h.bfReserved1 = (getc(IN) << 8) + File_h.bfReserved1;
File_h.bfReserved2 = getc(IN);
File_h.bfReserved2 = (getc(IN) << 8) + File_h.bfReserved2;
File_h.bfOffBits = getc(IN);
File_h.bfOffBits = (getc(IN) << 8) + File_h.bfOffBits;
File_h.bfOffBits = (getc(IN) << 16) + File_h.bfOffBits;
File_h.bfOffBits = (getc(IN) << 24) + File_h.bfOffBits;
/* INFO HEADER */
/* ------------- */
Info_h.biSize = getc(IN);
Info_h.biSize = (getc(IN) << 8) + Info_h.biSize;
Info_h.biSize = (getc(IN) << 16) + Info_h.biSize;
Info_h.biSize = (getc(IN) << 24) + Info_h.biSize;
Info_h.biWidth = getc(IN);
Info_h.biWidth = (getc(IN) << 8) + Info_h.biWidth;
Info_h.biWidth = (getc(IN) << 16) + Info_h.biWidth;
Info_h.biWidth = (getc(IN) << 24) + Info_h.biWidth;
w = Info_h.biWidth;
Info_h.biHeight = getc(IN);
Info_h.biHeight = (getc(IN) << 8) + Info_h.biHeight;
Info_h.biHeight = (getc(IN) << 16) + Info_h.biHeight;
Info_h.biHeight = (getc(IN) << 24) + Info_h.biHeight;
h = Info_h.biHeight;
Info_h.biPlanes = getc(IN);
Info_h.biPlanes = (getc(IN) << 8) + Info_h.biPlanes;
Info_h.biBitCount = getc(IN);
Info_h.biBitCount = (getc(IN) << 8) + Info_h.biBitCount;
Info_h.biCompression = getc(IN);
Info_h.biCompression = (getc(IN) << 8) + Info_h.biCompression;
Info_h.biCompression = (getc(IN) << 16) + Info_h.biCompression;
Info_h.biCompression = (getc(IN) << 24) + Info_h.biCompression;
Info_h.biSizeImage = getc(IN);
Info_h.biSizeImage = (getc(IN) << 8) + Info_h.biSizeImage;
Info_h.biSizeImage = (getc(IN) << 16) + Info_h.biSizeImage;
Info_h.biSizeImage = (getc(IN) << 24) + Info_h.biSizeImage;
Info_h.biXpelsPerMeter = getc(IN);
Info_h.biXpelsPerMeter = (getc(IN) << 8) + Info_h.biXpelsPerMeter;
Info_h.biXpelsPerMeter = (getc(IN) << 16) + Info_h.biXpelsPerMeter;
Info_h.biXpelsPerMeter = (getc(IN) << 24) + Info_h.biXpelsPerMeter;
Info_h.biYpelsPerMeter = getc(IN);
Info_h.biYpelsPerMeter = (getc(IN) << 8) + Info_h.biYpelsPerMeter;
Info_h.biYpelsPerMeter = (getc(IN) << 16) + Info_h.biYpelsPerMeter;
Info_h.biYpelsPerMeter = (getc(IN) << 24) + Info_h.biYpelsPerMeter;
Info_h.biClrUsed = getc(IN);
Info_h.biClrUsed = (getc(IN) << 8) + Info_h.biClrUsed;
Info_h.biClrUsed = (getc(IN) << 16) + Info_h.biClrUsed;
Info_h.biClrUsed = (getc(IN) << 24) + Info_h.biClrUsed;
Info_h.biClrImportant = getc(IN);
Info_h.biClrImportant = (getc(IN) << 8) + Info_h.biClrImportant;
Info_h.biClrImportant = (getc(IN) << 16) + Info_h.biClrImportant;
Info_h.biClrImportant = (getc(IN) << 24) + Info_h.biClrImportant;
/* Read the data and store them in the OUT file */
if (Info_h.biBitCount == 24) {
img->x0 = Dim[0];
img->y0 = Dim[1];
img->x1 =
!Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
1) *
subsampling_dx + 1;
img->y1 =
!Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
1) *
subsampling_dy + 1;
img->numcomps = 3;
img->color_space = 1;
img->comps =
(j2k_comp_t *) malloc(img->numcomps * sizeof(j2k_comp_t));
for (i = 0; i < img->numcomps; i++) {
img->comps[i].prec = 8;
img->comps[i].bpp = 8;
img->comps[i].sgnd = 0;
img->comps[i].dx = subsampling_dx;
img->comps[i].dy = subsampling_dy;
}
Compo0 = fopen("Compo0", "wb");
if (!Compo0) {
fprintf(stderr,
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
}
Compo1 = fopen("Compo1", "wb");
if (!Compo1) {
fprintf(stderr,
"\033[0;33mFailed to open Compo1 for writing !\033[0;39m\n");
}
Compo2 = fopen("Compo2", "wb");
if (!Compo2) {
fprintf(stderr,
"\033[0;33mFailed to open Compo2 for writing !\033[0;39m\n");
}
/* Place the cursor at the beginning of the image information */
fseek(IN, 0, SEEK_SET);
fseek(IN, File_h.bfOffBits, SEEK_SET);
W = Info_h.biWidth;
H = Info_h.biHeight;
// PAD = 4 - (3 * W) % 4;
// PAD = (PAD == 4) ? 0 : PAD;
PAD = (3 * W) % 4 ? 4 - (3 * W) % 4 : 0;
RGB =
(unsigned char *) malloc((3 * W + PAD) * H *
sizeof(unsigned char));
fread(RGB, sizeof(unsigned char), (3 * W + PAD) * H, IN);
for (j = 0; j < (3 * W + PAD) * H; j++) {
unsigned char elmt;
int Wp = 3 * W + PAD;
elmt = RGB[(H - (j / Wp + 1)) * Wp + j % Wp];
if ((j % Wp) < (3 * W)) {
switch (type) {
case 0:
fprintf(Compo2, "%c", elmt);
type = 1;
break;
case 1:
fprintf(Compo1, "%c", elmt);
type = 2;
break;
case 2:
fprintf(Compo0, "%c", elmt);
type = 0;
break;
}
}
}
fclose(Compo0);
fclose(Compo1);
fclose(Compo2);
free(RGB);
} else if (Info_h.biBitCount == 8 && Info_h.biCompression == 0) {
img->x0 = Dim[0];
img->y0 = Dim[1];
img->x1 =
!Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
1) *
subsampling_dx + 1;
img->y1 =
!Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
1) *
subsampling_dy + 1;
table_R = (unsigned char *) malloc(256 * sizeof(unsigned char));
table_G = (unsigned char *) malloc(256 * sizeof(unsigned char));
table_B = (unsigned char *) malloc(256 * sizeof(unsigned char));
for (j = 0; j < Info_h.biClrUsed; j++) {
table_B[j] = getc(IN);
table_G[j] = getc(IN);
table_R[j] = getc(IN);
getc(IN);
if (table_R[j] != table_G[j] && table_R[j] != table_B[j]
&& table_G[j] != table_B[j])
gray_scale = 0;
}
/* Place the cursor at the beginning of the image information */
fseek(IN, 0, SEEK_SET);
fseek(IN, File_h.bfOffBits, SEEK_SET);
W = Info_h.biWidth;
H = Info_h.biHeight;
if (Info_h.biWidth % 2)
W++;
RGB = (unsigned char *) malloc(W * H * sizeof(unsigned char));
fread(RGB, sizeof(unsigned char), W * H, IN);
if (gray_scale) {
img->numcomps = 1;
img->comps =
(j2k_comp_t *) malloc(img->numcomps * sizeof(j2k_comp_t));
img->comps[0].prec = 8;
img->comps[0].bpp = 8;
img->comps[0].sgnd = 0;
img->comps[0].dx = subsampling_dx;
img->comps[0].dy = subsampling_dy;
Compo0 = fopen("Compo0", "wb");
if (!Compo0) {
fprintf(stderr,
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
}
for (j = 0; j < W * H; j++) {
if ((j % W < W - 1 && Info_h.biWidth % 2)
|| !(Info_h.biWidth % 2))
fprintf(Compo0, "%c",
table_R[RGB[W * H - ((j) / (W) + 1) * W + (j) % (W)]]);
}
fclose(Compo0);
} else {
img->numcomps = 3;
img->comps =
(j2k_comp_t *) malloc(img->numcomps * sizeof(j2k_comp_t));
for (i = 0; i < img->numcomps; i++) {
img->comps[i].prec = 8;
img->comps[i].bpp = 8;
img->comps[i].sgnd = 0;
img->comps[i].dx = subsampling_dx;
img->comps[i].dy = subsampling_dy;
}
Compo0 = fopen("Compo0", "wb");
if (!Compo0) {
fprintf(stderr,
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
}
Compo1 = fopen("Compo1", "wb");
if (!Compo1) {
fprintf(stderr,
"\033[0;33mFailed to open Compo1 for writing !\033[0;39m\n");
}
Compo2 = fopen("Compo2", "wb");
if (!Compo2) {
fprintf(stderr,
"\033[0;33mFailed to open Compo2 for writing !\033[0;39m\n");
}
for (j = 0; j < W * H; j++) {
if ((j % W < W - 1 && Info_h.biWidth % 2)
|| !(Info_h.biWidth % 2)) {
fprintf(Compo0, "%c",
table_R[RGB[W * H - ((j) / (W) + 1) * W + (j) % (W)]]);
fprintf(Compo1, "%c",
table_G[RGB[W * H - ((j) / (W) + 1) * W + (j) % (W)]]);
fprintf(Compo2, "%c",
table_B[RGB[W * H - ((j) / (W) + 1) * W + (j) % (W)]]);
}
}
fclose(Compo0);
fclose(Compo1);
fclose(Compo2);
}
free(RGB);
} else if (Info_h.biBitCount == 8 && Info_h.biCompression == 1) {
img->x0 = Dim[0];
img->y0 = Dim[1];
img->x1 =
!Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
1) *
subsampling_dx + 1;
img->y1 =
!Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
1) *
subsampling_dy + 1;
table_R = (unsigned char *) malloc(256 * sizeof(unsigned char));
table_G = (unsigned char *) malloc(256 * sizeof(unsigned char));
table_B = (unsigned char *) malloc(256 * sizeof(unsigned char));
for (j = 0; j < Info_h.biClrUsed; j++) {
table_B[j] = getc(IN);
table_G[j] = getc(IN);
table_R[j] = getc(IN);
getc(IN);
if (table_R[j] != table_G[j] && table_R[j] != table_B[j]
&& table_G[j] != table_B[j])
gray_scale = 0;
}
/* Place the cursor at the beginning of the image information */
fseek(IN, 0, SEEK_SET);
fseek(IN, File_h.bfOffBits, SEEK_SET);
if (gray_scale) {
img->numcomps = 1;
img->comps = (j2k_comp_t *) malloc(sizeof(j2k_comp_t));
img->comps[0].prec = 8;
img->comps[0].bpp = 8;
img->comps[0].sgnd = 0;
img->comps[0].dx = subsampling_dx;
img->comps[0].dy = subsampling_dy;
Compo0 = fopen("Compo0", "wb");
if (!Compo0) {
fprintf(stderr,
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
}
} else {
img->numcomps = 3;
img->comps =
(j2k_comp_t *) malloc(img->numcomps * sizeof(j2k_comp_t));
for (i = 0; i < img->numcomps; i++) {
img->comps[i].prec = 8;
img->comps[i].bpp = 8;
img->comps[i].sgnd = 0;
img->comps[i].dx = subsampling_dx;
img->comps[i].dy = subsampling_dy;
}
Compo0 = fopen("Compo0", "wb");
if (!Compo0) {
fprintf(stderr,
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
}
Compo1 = fopen("Compo1", "wb");
if (!Compo1) {
fprintf(stderr,
"\033[0;33mFailed to open Compo1 for writing !\033[0;39m\n");
}
Compo2 = fopen("Compo2", "wb");
if (!Compo2) {
fprintf(stderr,
"\033[0;33mFailed to open Compo2 for writing !\033[0;39m\n");
}
}
RGB =
(unsigned char *) malloc(Info_h.biWidth * Info_h.biHeight *
sizeof(unsigned char));
while (not_end_file) {
v = getc(IN);
if (v) {
v2 = getc(IN);
for (i = 0; i < (int) v; i++) {
RGB[line * Info_h.biWidth + col] = v2;
col++;
}
} else {
v = getc(IN);
switch (v) {
case 0:
col = 0;
line++;
break;
case 1:
line++;
not_end_file = 0;
break;
case 2:
printf("No Delta supported\n");
return 1;
break;
default:
for (i = 0; i < v; i++) {
v2 = getc(IN);
RGB[line * Info_h.biWidth + col] = v2;
col++;
}
if (v % 2)
v2 = getc(IN);
}
}
}
if (gray_scale) {
for (line = 0; line < Info_h.biHeight; line++)
for (col = 0; col < Info_h.biWidth; col++)
fprintf(Compo0, "%c", table_R[(int)
RGB[(Info_h.biHeight - line -
1) * Info_h.biWidth +
col]]);
fclose(Compo0);
} else {
for (line = 0; line < Info_h.biHeight; line++)
for (col = 0; col < Info_h.biWidth; col++) {
fprintf(Compo0, "%c", table_R[(int)
RGB[(Info_h.biHeight - line -
1) * Info_h.biWidth +
col]]);
fprintf(Compo1, "%c", table_G[(int)
RGB[(Info_h.biHeight - line -
1) * Info_h.biWidth +
col]]);
fprintf(Compo2, "%c", table_B[(int)
RGB[(Info_h.biHeight - line -
1) * Info_h.biWidth +
col]]);
}
fclose(Compo0);
fclose(Compo1);
fclose(Compo2);
}
free(RGB);
} else
fprintf(stderr,
"Other system than 24 bits/pixels or 8 bits (no RLE coding) is not yet implemented [%d]\n",
Info_h.biBitCount);
fclose(IN);
return 1;
}
}
/* -->> -->> -->> -->>
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;
}
int pgxtoimage(char *filename, j2k_image_t * img, int tdy,
int subsampling_dx, int subsampling_dy, int Dim[2],
j2k_cp_t cp)
{
FILE *f;
int w, h, prec;
int i, compno, bandno;
char str[256], endian[16];
char sign;
int bigendian;
j2k_comp_t *comp;
img->numcomps = 1;
img->color_space = 2;
img->comps = (j2k_comp_t *) malloc(img->numcomps * sizeof(j2k_comp_t));
for (compno = 0; compno < img->numcomps; compno++) {
FILE *src;
char tmp[16];
int max = 0;
int Y1;
comp = &img->comps[compno];
sprintf(str, "%s", filename);
f = fopen(str, "rb");
if (!f) {
fprintf(stderr, "Failed to open %s for reading !\n", str);
return 0;
}
if (fscanf(f, "PG %s %c %d %d %d", endian, &sign, &prec, &w, &h) == 5) {
fgetc(f);
if (!strcmp(endian, "ML"))
bigendian = 1;
else
bigendian = 0;
if (compno == 0) {
img->x0 = Dim[0];
img->y0 = Dim[1];
img->x1 =
!Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
1) *
subsampling_dx + 1;
img->y1 =
!Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
1) *
subsampling_dy + 1;
} else {
if (w != img->x1 || h != img->y1)
return 0;
}
if (sign == '-') {
comp->sgnd = 1;
} else {
comp->sgnd = 0;
}
comp->prec = prec;
comp->dx = subsampling_dx;
comp->dy = subsampling_dy;
bandno = 1;
Y1 = cp.ty0 + bandno * cp.tdy <
img->y1 ? cp.ty0 + bandno * cp.tdy : img->y1;
Y1 -= img->y0;
sprintf(tmp, "bandtile%d", bandno); /* bandtile file */
src = fopen(tmp, "wb");
if (!src) {
fprintf(stderr, "failed to open %s for writing !\n", tmp);
}
for (i = 0; i < w * h; i++) {
int v;
if (i == Y1 * w / subsampling_dy && tdy != -1) { /* bandtile is full */
fclose(src);
bandno++;
sprintf(tmp, "bandtile%d", bandno);
src = fopen(tmp, "wb");
if (!src) {
fprintf(stderr, "failed to open %s for writing !\n", tmp);
}
Y1 = cp.ty0 + bandno * cp.tdy <
img->y1 ? cp.ty0 + bandno * cp.tdy : img->y1;
Y1 -= img->y0;
}
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;
fprintf(src, "%d ", v);
}
} else {
return 0;
}
fclose(f);
fclose(src);
comp->bpp = int_floorlog2(max) + 1;
}
return 1;
}
/* -->> -->> -->> -->>
PNM IMAGE FORMAT
<<-- <<-- <<-- <<-- */
int pnmtoimage(char *filename, j2k_image_t * img, int subsampling_dx,
int subsampling_dy, int Dim[2])
{
FILE *f;
FILE *Compo0, *Compo1, *Compo2;
int w, h;
int i;
char value;
char comment[256];
f = fopen(filename, "rb");
if (!f) {
fprintf(stderr,
"\033[0;33mFailed to open %s for reading !!\033[0;39m\n",
filename);
return 0;
}
if (fgetc(f) != 'P')
return 0;
value = fgetc(f);
if (value == '2') {
fgetc(f);
if (fgetc(f) == '#') {
fseek(f, 0, SEEK_SET);
fscanf(f, "P2\n");
fgets(comment, 256, f);
fscanf(f, "%d %d\n255", &w, &h);
} else {
fseek(f, 0, SEEK_SET);
fscanf(f, "P2\n%d %d\n255", &w, &h);
}
fgetc(f);
img->x0 = Dim[0];
img->y0 = Dim[1];
img->x1 =
!Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
1) *
subsampling_dx + 1;
img->y1 =
!Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
1) *
subsampling_dy + 1;
img->numcomps = 1;
img->color_space = 2;
img->comps = (j2k_comp_t *) malloc(sizeof(j2k_comp_t));
img->comps[0].prec = 8;
img->comps[0].bpp = 8;
img->comps[0].sgnd = 0;
img->comps[0].dx = subsampling_dx;
img->comps[0].dy = subsampling_dy;
Compo0 = fopen("Compo0", "wb");
if (!Compo0) {
fprintf(stderr,
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
}
for (i = 0; i < w * h; i++) {
unsigned int l;
fscanf(f, "%d", &l);
fprintf(Compo0, "%c", l);
}
fclose(Compo0);
} else if (value == '5') {
fgetc(f);
if (fgetc(f) == '#') {
fseek(f, 0, SEEK_SET);
fscanf(f, "P5\n");
fgets(comment, 256, f);
fscanf(f, "%d %d\n255", &w, &h);
} else {
fseek(f, 0, SEEK_SET);
fscanf(f, "P5\n%d %d\n255", &w, &h);
}
fgetc(f);
img->x0 = Dim[0];
img->y0 = Dim[1];
img->x1 =
!Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
1) *
subsampling_dx + 1;
img->y1 =
!Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
1) *
subsampling_dy + 1;
img->numcomps = 1;
img->color_space = 2;
img->comps = (j2k_comp_t *) malloc(sizeof(j2k_comp_t));
img->comps[0].prec = 8;
img->comps[0].bpp = 8;
img->comps[0].sgnd = 0;
img->comps[0].dx = subsampling_dx;
img->comps[0].dy = subsampling_dy;
Compo0 = fopen("Compo0", "wb");
if (!Compo0) {
fprintf(stderr,
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
}
for (i = 0; i < w * h; i++) {
unsigned char l;
fread(&l, 1, 1, f);
fwrite(&l, 1, 1, Compo0);
}
fclose(Compo0);
} else if (value == '3') {
fgetc(f);
if (fgetc(f) == '#') {
fseek(f, 0, SEEK_SET);
fscanf(f, "P3\n");
fgets(comment, 256, f);
fscanf(f, "%d %d\n255", &w, &h);
} else {
fseek(f, 0, SEEK_SET);
fscanf(f, "P3\n%d %d\n255", &w, &h);
}
fgetc(f);
img->x0 = Dim[0];
img->y0 = Dim[1];
img->x1 =
!Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
1) *
subsampling_dx + 1;
img->y1 =
!Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
1) *
subsampling_dy + 1;
img->numcomps = 3;
img->color_space = 1;
img->comps = (j2k_comp_t *) malloc(img->numcomps * sizeof(j2k_comp_t));
for (i = 0; i < img->numcomps; i++) {
img->comps[i].prec = 8;
img->comps[i].bpp = 8;
img->comps[i].sgnd = 0;
img->comps[i].dx = subsampling_dx;
img->comps[i].dy = subsampling_dy;
}
Compo0 = fopen("Compo0", "wb");
if (!Compo0) {
fprintf(stderr,
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
}
Compo1 = fopen("Compo1", "wb");
if (!Compo1) {
fprintf(stderr,
"\033[0;33mFailed to open Compo1 for writing !\033[0;39m\n");
}
Compo2 = fopen("Compo2", "wb");
if (!Compo2) {
fprintf(stderr,
"\033[0;33mFailed to open Compo2 for writing !\033[0;39m\n");
}
for (i = 0; i < w * h; i++) {
unsigned int r, g, b;
fscanf(f, "%d", &r);
fscanf(f, "%d", &g);
fscanf(f, "%d", &b);
fprintf(Compo0, "%c", r);
fprintf(Compo1, "%c", g);
fprintf(Compo2, "%c", b);
}
fclose(Compo0);
fclose(Compo1);
fclose(Compo2);
} else if (value == '6') {
fgetc(f);
if (fgetc(f) == '#') {
fseek(f, 0, SEEK_SET);
fscanf(f, "P6\n");
fgets(comment, 256, f);
fscanf(f, "%d %d\n255", &w, &h);
} else {
fseek(f, 0, SEEK_SET);
fscanf(f, "P6\n%d %d\n255", &w, &h);
}
fgetc(f);
img->x0 = Dim[0];
img->y0 = Dim[1];
img->x1 =
!Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
1) *
subsampling_dx + 1;
img->y1 =
!Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
1) *
subsampling_dy + 1;
img->numcomps = 3;
img->color_space = 1;
img->comps = (j2k_comp_t *) malloc(img->numcomps * sizeof(j2k_comp_t));
for (i = 0; i < img->numcomps; i++) {
img->comps[i].prec = 8;
img->comps[i].bpp = 8;
img->comps[i].sgnd = 0;
img->comps[i].dx = subsampling_dx;
img->comps[i].dy = subsampling_dy;
}
Compo0 = fopen("Compo0", "wb");
if (!Compo0) {
fprintf(stderr,
"\033[0;33mFailed to open Compo0 for writing !\033[0;39m\n");
}
Compo1 = fopen("Compo1", "wb");
if (!Compo1) {
fprintf(stderr,
"\033[0;33mFailed to open Compo1 for writing !\033[0;39m\n");
}
Compo2 = fopen("Compo2", "wb");
if (!Compo2) {
fprintf(stderr,
"\033[0;33mFailed to open Compo2 for writing !\033[0;39m\n");
}
for (i = 0; i < w * h; i++) {
unsigned char r, g, b;
fread(&r, 1, 1, f);
fread(&g, 1, 1, f);
fread(&b, 1, 1, f);
fwrite(&r, 1, 1, Compo0);
fwrite(&g, 1, 1, Compo1);
fwrite(&b, 1, 1, Compo2);
}
fclose(Compo0);
fclose(Compo1);
fclose(Compo2);
} else {
return 0;
}
fclose(f);
return 1;
}

View File

@ -0,0 +1,39 @@
/*
* 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]);

View File

@ -0,0 +1,887 @@
/*
* 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 <openjpeg.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#ifndef DONT_HAVE_GETOPT
#include <getopt.h>
#else
#include "compat/getopt.h"
#endif
#include "convert.h"
void help_display()
{
printf("HELP\n----\n\n");
printf("- the option -help displays the readme.txt file on screen\n\n");
printf("List of parameters for the coder JPEG 2000 :\n");
printf("\n");
printf
("- The markers COD and QCD are writed both of two in the main_header and never appear in the tile_header. The markers in the main header are : SOC SIZ COD QCD COM.\n");
printf("\n");
printf
("- This coder can encode mega image, a test was made on a 24000x24000 pixels color image. You need enough disk space memory (twice the original) to encode the image. (i.e. for a 1.5 Gb image you need a minimum of 3Gb of disk memory)\n");
printf("\n");
printf("REMARKS :\n");
printf("---------\n");
printf("\n");
printf
("* the value of rate enter in the code line is the compression factor !\n");
printf("exemple :\n");
printf("\n");
printf
("-r 20,10,1 means quality 1 : compress 20x, quality 2 : compress 10x and quality 3 : compress 1x = lossless\n");
printf("\n");
printf("By default :\n");
printf("------------\n");
printf("\n");
printf(" * lossless\n");
printf(" * 1 tile\n");
printf(" * size of precinct 2^15 x 2^15 (means 1 precinct)\n");
printf(" * size of code-block 64 x 64\n");
printf(" * Number of resolution : 6\n");
printf(" * No SOP marker in the codestream\n");
printf(" * No EPH marker in the codestream\n");
printf(" * No sub-sampling in x and y direction\n");
printf(" * No mode switch activated\n");
printf(" * progression order : LRCP\n");
printf(" * No index file\n");
printf(" * No ROI upshifted\n");
printf(" * No offset of the origin of the image\n");
printf(" * No offset of the origin of the tiles\n");
printf(" * Reversible DWT 5-3\n");
printf("\n");
printf("Parameters :\n");
printf("------------\n");
printf("\n");
printf
("-i : source file (-i source.pnm also *.pgm, *.ppm) required\n");
printf("\n");
printf("-o : destination file (-o dest.j2k or .jp2) required\n");
printf("\n");
printf("-help : Display the help information optional\n ");
printf("\n");
printf("-r : different rates (-r 20,10,5) optional\n ");
printf("\n");
printf("-n : Number of resolution (-n 3) optional\n");
printf("\n");
printf("-b : size of code block (-b 32,32) optional\n");
printf("\n");
printf("-c : size of precinct (-c 128,128) optional\n");
printf("\n");
printf("-t : size of tile (-t 512,512) optional\n");
printf("\n");
printf
("-p : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] optional\n");
printf("\n");
printf
("-s : subsampling factor (-s 2,2) [-s X,Y] optional\n");
printf("\n");
printf
("-SOP : write SOP marker before each packet optional\n");
printf("\n");
printf
("-EPH : write EPH marker after each header packet optional\n");
printf("\n");
printf
("-M : mode switch (-M 3) [1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL) 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)] optional\n");
printf
(" for several mode switch you have to add the value of each mode you want\n");
printf
(" ex : RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
printf("\n");
printf
("-x : Create an index file *.Idx (-x index_name.Idx) optional\n");
printf("\n");
printf
("-ROI:c=%%d,U=%%d : quantization indices upshifted for component c=%%d [%%d = 0,1,2]\n");
printf
(" with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI:c=0,U=25) optional\n");
printf("\n");
printf
("-d : offset of the origin of the image (-d 150,300) optional\n");
printf("\n");
printf
("-T : offset of the origin of the tiles (-T 100,75) optional\n");
printf("\n");
printf("-I : Use the irreversible DWT 9-7 (-I) optional\n");
printf("\n");
printf("IMPORTANT :\n");
printf("-----------\n");
printf("\n");
printf("* subsampling bigger than 2 can produce error\n");
printf("\n");
printf("The index file respect the structure below :\n");
printf("---------------------------------------------\n");
printf("\n");
printf("Image_height Image_width\n");
printf("progression order\n");
printf("Tiles_size_X Tiles_size_Y\n");
printf("Components_nb\n");
printf("Layers_nb\n");
printf("decomposition_levels\n");
printf("Precincts_size_X Precincts_size_Y\n");
printf("Main_header_end_position\n");
printf("Codestream_size\n");
printf("Tile0 start_pos end_Theader end_pos\n");
printf("Tile1 '' '' ''\n");
printf("...\n");
printf("TileN '' '' ''\n");
printf("Tpacket_0 Tile layer res. comp. prec. start_pos end_pos\n");
printf("...\n");
printf("Tpacket_M '' '' '' '' '' '' ''\n");
}
int give_progression(char progression[4])
{
if (progression[0] == 'L' && progression[1] == 'R'
&& progression[2] == 'C' && progression[3] == 'P') {
return 0;
} else {
if (progression[0] == 'R' && progression[1] == 'L'
&& progression[2] == 'C' && progression[3] == 'P') {
return 1;
} else {
if (progression[0] == 'R' && progression[1] == 'P'
&& progression[2] == 'C' && progression[3] == 'L') {
return 2;
} else {
if (progression[0] == 'P' && progression[1] == 'C'
&& progression[2] == 'R' && progression[3] == 'L') {
return 3;
} else {
if (progression[0] == 'C' && progression[1] == 'P'
&& progression[2] == 'R' && progression[3] == 'L') {
return 4;
} else {
return -1;
}
}
}
}
}
}
double dwt_norms_97[4][10] = {
{1.000, 1.965, 4.177, 8.403, 16.90, 33.84, 67.69, 135.3, 270.6, 540.9},
{2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
{2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
{2.080, 3.865, 8.307, 17.18, 34.71, 69.59, 139.3, 278.6, 557.2}
};
int floorlog2(int a)
{
int l;
for (l = 0; a > 1; l++) {
a >>= 1;
}
return l;
}
void encode_stepsize(int stepsize, int numbps, int *expn, int *mant)
{
int p, n;
p = floorlog2(stepsize) - 13;
n = 11 - floorlog2(stepsize);
*mant = (n < 0 ? stepsize >> -n : stepsize << n) & 0x7ff;
*expn = numbps - p;
}
void calc_explicit_stepsizes(j2k_tccp_t * tccp, int prec)
{
int numbands, bandno;
numbands = 3 * tccp->numresolutions - 2;
for (bandno = 0; bandno < numbands; bandno++) {
double stepsize;
int resno, level, orient, gain;
resno = bandno == 0 ? 0 : (bandno - 1) / 3 + 1;
orient = bandno == 0 ? 0 : (bandno - 1) % 3 + 1;
level = tccp->numresolutions - 1 - resno;
gain =
tccp->qmfbid == 0 ? 0 : (orient ==
0 ? 0 : (orient == 1
|| orient == 2 ? 1 : 2));
if (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
stepsize = 1.0;
} else {
double norm = dwt_norms_97[orient][level];
stepsize = (1 << (gain + 1)) / norm;
}
encode_stepsize((int) floor(stepsize * 8192.0), prec + gain,
&tccp->stepsizes[bandno].expn,
&tccp->stepsizes[bandno].mant);
}
}
int main(int argc, char **argv)
{
int len;
int NumResolution, numD_min; /* NumResolution : number of resolution */
int Tile_arg; /* Tile_arg = 0 (not in argument) ou = 1 (in argument) */
int CSty; /* CSty : coding style */
int Prog_order; /* progression order (default LRCP) */
char progression[4];
int numpocs, numpocs_tile; /* Number of progression order change (POC) default 0 */
int prcw_init[J2K_MAXRLVLS]; /* Initialisation Precinct width */
int prch_init[J2K_MAXRLVLS]; /* Initialisation Precinct height */
//int prcw_init, prch_init; /* Initialisation precincts' size */
int cblockw_init, cblockh_init; /* Initialisation codeblocks' size */
int mode, value; /* Mode switch (cblk_style) */
int subsampling_dx, subsampling_dy; /* subsampling value for dx and dy */
int ROI_compno, ROI_shift; /* region of interrest */
int Dim[2]; /* portion of the image coded */
int TX0, TY0; /* tile off-set */
j2k_image_t img;
j2k_cp_t cp, cp_init; /* cp_init is used to initialise in multiple tiles */
j2k_tcp_t *tcp, *tcp_init; /* tcp_init is used to initialise in multiple tile */
j2k_poc_t POC[32]; /* POC : used in case of Progression order change */
j2k_poc_t *tcp_poc;
j2k_tccp_t *tccp;
int i, tileno, j;
char *infile = 0;
char *outfile = 0;
char *index = 0;
char *s, S1, S2, S3;
int ir = 0;
int res_spec = 0; /* For various precinct sizes specification */
char sep;
char *outbuf;
FILE *f;
/* default value */
/* ------------- */
NumResolution = 6;
CSty = 0;
cblockw_init = 64;
cblockh_init = 64;
cp.tw = 1;
cp.th = 1;
cp.index_on = 0;
Prog_order = 0;
numpocs = 0;
mode = 0;
subsampling_dx = 1;
subsampling_dy = 1;
ROI_compno = -1; /* no ROI */
ROI_shift = 0;
Dim[0] = 0;
Dim[1] = 0;
TX0 = 0;
TY0 = 0;
cp.comment = "Created by OpenJPEG version 0.9";
cp.disto_alloc = 0;
cp.fixed_alloc = 0;
cp.fixed_quality = 0; //add fixed_quality
/* img.PPT=0; */
Tile_arg = 0;
cp_init.tcps = (j2k_tcp_t *) malloc(sizeof(j2k_tcp_t)); /* initialisation if only one tile */
tcp_init = &cp_init.tcps[0];
tcp_init->numlayers = 0;
cp.intermed_file=1;
while (1) {
int c = getopt(argc, argv,
"i:o:r:q:f:t:n:c:b:x:p:s:d:h:P:S:E:M:R:T:C:I");
if (c == -1)
break;
switch (c) {
case 'i': /* IN fill */
infile = optarg;
s = optarg;
while (*s) {
s++;
}
s--;
S3 = *s;
s--;
S2 = *s;
s--;
S1 = *s;
if ((S1 == 'p' && S2 == 'g' && S3 == 'x')
|| (S1 == 'P' && S2 == 'G' && S3 == 'X')) {
cp.image_type = 0;
break;
}
if ((S1 == 'p' && S2 == 'n' && S3 == 'm')
|| (S1 == 'P' && S2 == 'N' && S3 == 'M')
|| (S1 == 'p' && S2 == 'g' && S3 == 'm') || (S1 == 'P'
&& S2 == 'G'
&& S3 == 'M')
|| (S1 == 'P' && S2 == 'P' && S3 == 'M') || (S1 == 'p'
&& S2 == 'p'
&& S3 == 'm')) {
cp.image_type = 1;
break;
}
if ((S1 == 'b' && S2 == 'm' && S3 == 'p')
|| (S1 == 'B' && S2 == 'M' && S3 == 'P')) {
cp.image_type = 2;
break;
}
fprintf(stderr,
"!! Unrecognized format for infile : %c%c%c [accept only *.pnm, *.pgm, *.ppm, *.pgx or *.bmp] !!\n\n",
S1, S2, S3);
return 1;
break;
/* ----------------------------------------------------- */
case 'o': /* OUT fill */
outfile = optarg;
while (*outfile) {
outfile++;
}
outfile--;
S3 = *outfile;
outfile--;
S2 = *outfile;
outfile--;
S1 = *outfile;
outfile = optarg;
if ((S1 == 'j' && S2 == '2' && S3 == 'k') || (S1 == 'J' && S2 == '2' && S3 == 'K'))
cp.JPEG2000_format=0;
else if ((S1 == 'j' && S2 == 'p' && S3 == '2') || (S1 == 'J' && S2 == 'P' && S3 == '2'))
cp.JPEG2000_format=1;
else {
fprintf(stderr,"Unknown output format image *.%c%c%c [only *.j2k, *.jp2]!! \n",S1,S2,S3);
return 1;
}
break;
/* ----------------------------------------------------- */
case 'r': /* rates rates/distorsion */
s = optarg;
while (sscanf(s, "%d", &tcp_init->rates[tcp_init->numlayers])
== 1) {
tcp_init->numlayers++;
while (*s && *s != ',') {
s++;
}
if (!*s)
break;
s++;
}
cp.disto_alloc = 1;
cp.matrice = NULL;
break;
/* ----------------------------------------------------- */
case 'q': /* add fixed_quality */
s = optarg;
while (sscanf(s, "%f", &tcp_init->distoratio[tcp_init->numlayers]) ==
1) {
tcp_init->numlayers++;
while (*s && *s != ',') {
s++;
}
if (!*s)
break;
s++;
}
cp.fixed_quality = 1;
cp.matrice = NULL;
break;
/* dda */
/* ----------------------------------------------------- */
case 'f': /* mod fixed_quality (before : -q) */
s = optarg;
sscanf(s, "%d", &tcp_init->numlayers);
s++;
if (tcp_init->numlayers > 9)
s++;
cp.matrice =
(int *) malloc(tcp_init->numlayers * NumResolution * 3 *
sizeof(int));
s = s + 2;
for (i = 0; i < tcp_init->numlayers; i++) {
tcp_init->rates[i] = 1;
sscanf(s, "%d,", &cp.matrice[i * NumResolution * 3]);
s += 2;
if (cp.matrice[i * NumResolution * 3] > 9)
s++;
cp.matrice[i * NumResolution * 3 + 1] = 0;
cp.matrice[i * NumResolution * 3 + 2] = 0;
for (j = 1; j < NumResolution; j++) {
sscanf(s, "%d,%d,%d",
&cp.matrice[i * NumResolution * 3 + j * 3 + 0],
&cp.matrice[i * NumResolution * 3 + j * 3 + 1],
&cp.matrice[i * NumResolution * 3 + j * 3 + 2]);
s += 6;
if (cp.matrice[i * NumResolution * 3 + j * 3] > 9)
s++;
if (cp.matrice[i * NumResolution * 3 + j * 3 + 1] > 9)
s++;
if (cp.matrice[i * NumResolution * 3 + j * 3 + 2] > 9)
s++;
}
if (i < tcp_init->numlayers - 1)
s++;
}
cp.fixed_alloc = 1;
break;
/* ----------------------------------------------------- */
case 't': /* tiles */
sscanf(optarg, "%d,%d", &cp.tdx, &cp.tdy);
Tile_arg = 1;
break;
/* ----------------------------------------------------- */
case 'n': /* resolution */
sscanf(optarg, "%d", &NumResolution);
break;
/* ----------------------------------------------------- */
case 'c': /* precinct dimension */
s = optarg;
do {
sep = 0;
sscanf(s, "[%d,%d]%c", &prcw_init[res_spec],
&prch_init[res_spec], &sep);
CSty |= 0x01;
res_spec++;
s = strpbrk(s, "]") + 2;
} while (sep == ',');
break;
/* ----------------------------------------------------- */
case 'b': /* code-block dimension */
sscanf(optarg, "%d,%d", &cblockw_init, &cblockh_init);
if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
|| cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
fprintf(stderr,
"!! Size of code_block error (option -b) !!\n\nRestriction :\n * width*height<=4096\n * 4<=width,height<= 1024\n\n");
return 1;
}
break;
/* ----------------------------------------------------- */
case 'x': /* creation of index file */
index = optarg;
cp.index_on = 1;
break;
/* ----------------------------------------------------- */
case 'p': /* progression order */
s = optarg;
for (i = 0; i < 4; i++) {
progression[i] = *s;
s++;
}
Prog_order = give_progression(progression);
if (Prog_order == -1) {
fprintf(stderr,
"Unrecognized progression order [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n");
return 1;
}
break;
/* ----------------------------------------------------- */
case 's': /* subsampling factor */
if (sscanf(optarg, "%d,%d", &subsampling_dx, &subsampling_dy)
!= 2) {
fprintf(stderr,
"'-s' sub-sampling argument error ! [-s dx,dy]\n");
return 1;
}
break;
/* ----------------------------------------------------- */
case 'd': /* coordonnate of the reference grid */
if (sscanf(optarg, "%d,%d", &Dim[0], &Dim[1]) != 2) {
fprintf(stderr,
"-d 'coordonnate of the reference grid' argument error !! [-d x0,y0]\n");
return 1;
}
break;
/* ----------------------------------------------------- */
case 'h': /* Display an help description */
help_display();
return 0;
break;
/* ----------------------------------------------------- */
case 'P': /* POC */
fprintf(stderr, "/----------------------------------\\\n");
fprintf(stderr, "| POC option not fully tested !! |\n");
fprintf(stderr, "\\----------------------------------/\n");
s = optarg;
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++;
}
break;
/* ------------------------------------------------------ */
case 'S': /* SOP marker */
CSty |= 0x02;
break;
/* ------------------------------------------------------ */
case 'E': /* EPH marker */
CSty |= 0x04;
break;
/* ------------------------------------------------------ */
case 'M': /* Mode switch pas tous au point !! */
if (sscanf(optarg, "%d", &value) == 1) {
for (i = 0; i <= 5; i++) {
int cache = value & (1 << i);
if (cache)
mode |= (1 << i);
}
}
break;
/* ------------------------------------------------------ */
case 'R': /* ROI */
if (sscanf(optarg, "OI:c=%d,U=%d", &ROI_compno, &ROI_shift) != 2) {
fprintf(stderr, "ROI error !! [-ROI:c='compno',U='shift']\n");
return 1;
}
break;
/* ------------------------------------------------------ */
case 'T': /* Tile offset */
if (sscanf(optarg, "%d,%d", &TX0, &TY0) != 2) {
fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
return 1;
}
break;
/* ------------------------------------------------------ */
case 'C': /* Add a comment */
cp.comment = optarg;
break;
/* ------------------------------------------------------ */
case 'I': /* reversible or not */
ir = 1;
break;
/* ------------------------------------------------------ */
default:
return 1;
}
}
cp.tx0 = TX0;
cp.ty0 = TY0;
/* Error messages */
/* -------------- */
if (!infile || !outfile) {
fprintf(stderr,
"usage: image_to_j2k -i image-file -o j2k/jp2-file (+ options)\n");
return 1;
}
if ((cp.disto_alloc || cp.fixed_alloc || cp.fixed_quality)&&(!(cp.disto_alloc ^ cp.fixed_alloc ^ cp.fixed_quality))) {
fprintf(stderr,
"Error: options -r -q and -f can not be used together !!\n");
return 1;
} // mod fixed_quality
/* if no rate entered, lossless by default */
if (tcp_init->numlayers == 0) {
tcp_init->rates[tcp_init->numlayers] = 1;
tcp_init->numlayers++;
cp.disto_alloc = 1;
}
if (TX0 > Dim[0] || TY0 > Dim[1]) {
fprintf(stderr,
"Error: Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) \n",
TX0, Dim[0], TY0, Dim[1]);
return 1;
}
for (i = 0; i < numpocs; i++) {
if (POC[i].prg == -1) {
fprintf(stderr,
"Unrecognized progression order in option -P (POC n %d) [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n",
i + 1);
}
}
switch (cp.image_type) {
case 0:
if (Tile_arg) {
if (!pgxtoimage
(infile, &img, cp.tdy, subsampling_dx, subsampling_dy, Dim,
cp)) {
fprintf(stderr, "not a pgx file\n");
return 1;
}
} else {
if (!pgxtoimage
(infile, &img, -1, subsampling_dx, subsampling_dy, Dim, cp)) {
fprintf(stderr, " not a pgx file\n");
return 1;
}
}
break;
case 1:
if (!pnmtoimage(infile, &img, subsampling_dx, subsampling_dy, Dim)) {
fprintf(stderr, " not a pnm file\n");
return 1;
}
break;
case 2:
if (!bmptoimage(infile, &img, subsampling_dx, subsampling_dy, Dim)) {
fprintf(stderr, " not a bmp file\n");
return 1;
}
break;
}
/* to respect profile - 0 */
/* ---------------------- */
numD_min = 0;
/* while (int_ceildiv(img.x1,(1<<numD_min))-int_ceildiv(img.x0,(1<<numD_min))>120 || int_ceildiv(img.y1,(1<<numD_min))-int_ceildiv(img.y0,(1<<numD_min))>160) numD_min++;
if ((numD_min+1)>NumResolution)
{
fprintf(stderr,"\n********************************************************************************\n\n");
fprintf(stderr, "In view to respect Profile-0, the number of resolution used is %d in place of %d\n\n",numD_min+1,NumResolution);
fprintf(stderr, "********************************************************************************\n\n");
NumResolution=numD_min+1;
} */
if (Tile_arg == 1) {
cp.tw = int_ceildiv(img.x1 - cp.tx0, cp.tdx);
cp.th = int_ceildiv(img.y1 - cp.ty0, cp.tdy);
} else {
cp.tdx = img.x1 - cp.tx0;
cp.tdy = img.y1 - cp.ty0;
}
/* Initialization for PPM marker */
cp.ppm = 0;
cp.ppm_data = NULL;
cp.ppm_previous = 0;
cp.ppm_store = 0;
/* Init the mutiple tiles */
/* ---------------------- */
cp.tcps = (j2k_tcp_t *) malloc(cp.tw * cp.th * sizeof(j2k_tcp_t));
for (tileno = 0; tileno < cp.tw * cp.th; tileno++) {
tcp = &cp.tcps[tileno];
tcp->numlayers = tcp_init->numlayers;
for (j = 0; j < tcp->numlayers; j++) {
if (cp.fixed_quality) // add fixed_quality
tcp->distoratio[j] = tcp_init->distoratio[j];
else
tcp->rates[j] = tcp_init->rates[j];
}
tcp->csty = CSty;
tcp->prg = Prog_order;
tcp->mct = img.numcomps == 3 ? 1 : 0;
tcp->ppt = 0;
tcp->ppt_data = NULL;
tcp->ppt_store = 0;
numpocs_tile = 0;
tcp->POC = 0;
if (numpocs) {
/* intialisation of POC */
tcp->POC = 1;
for (i = 0; i < numpocs; i++) {
if (tileno == POC[i].tile - 1 || POC[i].tile == -1) {
tcp_poc = &tcp->pocs[numpocs_tile];
tcp_poc->resno0 = POC[numpocs_tile].resno0;
tcp_poc->compno0 = POC[numpocs_tile].compno0;
tcp_poc->layno1 = POC[numpocs_tile].layno1;
tcp_poc->resno1 = POC[numpocs_tile].resno1;
tcp_poc->compno1 = POC[numpocs_tile].compno1;
tcp_poc->prg = POC[numpocs_tile].prg;
tcp_poc->tile = POC[numpocs_tile].tile;
numpocs_tile++;
}
}
}
tcp->numpocs = numpocs_tile;
tcp->tccps = (j2k_tccp_t *) malloc(img.numcomps * sizeof(j2k_tccp_t));
for (i = 0; i < img.numcomps; i++) {
tccp = &tcp->tccps[i];
tccp->csty = CSty & 0x01; /* 0 => one precinct || 1 => custom precinct */
tccp->numresolutions = NumResolution;
tccp->cblkw = int_floorlog2(cblockw_init);
tccp->cblkh = int_floorlog2(cblockh_init);
tccp->cblksty = mode;
tccp->qmfbid = ir ? 0 : 1;
tccp->qntsty = ir ? J2K_CCP_QNTSTY_SEQNT : J2K_CCP_QNTSTY_NOQNT;
tccp->numgbits = 2;
if (i == ROI_compno)
tccp->roishift = ROI_shift;
else
tccp->roishift = 0;
if (CSty & J2K_CCP_CSTY_PRT) {
int p = 0;
for (j = tccp->numresolutions - 1; j >= 0; j--) {
if (p < res_spec) {
if (prcw_init[p] < 1)
tccp->prcw[j] = 1;
else
tccp->prcw[j] = int_floorlog2(prcw_init[p]);
if (prch_init[p] < 1)
tccp->prch[j] = 1;
else
tccp->prch[j] = int_floorlog2(prch_init[p]);
} else {
int size_prcw, size_prch;
size_prcw = prcw_init[res_spec - 1] >> (p - (res_spec - 1));
size_prch = prch_init[res_spec - 1] >> (p - (res_spec - 1));
if (size_prcw < 1)
tccp->prcw[j] = 1;
else
tccp->prcw[j] = int_floorlog2(size_prcw);
if (size_prch < 1)
tccp->prch[j] = 1;
else
tccp->prch[j] = int_floorlog2(size_prch);
}
p++;
/*printf("\nsize precinct pour level %d : %d,%d\n", j,
tccp->prcw[j], tccp->prch[j]);*/
}
} else {
for (j = 0; j < tccp->numresolutions; j++) {
tccp->prcw[j] = 15;
tccp->prch[j] = 15;
}
}
calc_explicit_stepsizes(tccp, img.comps[i].prec);
}
}
if (cp.JPEG2000_format==0) { /* J2K format output */
if (cp.intermed_file==1) { /* After the encoding of each tile, j2k_encode
stores the data in the file*/
len = j2k_encode(&img, &cp, outfile, cp.tdx * cp.tdy * 2, index);
if (len == 0) {
fprintf(stderr, "failed to encode image\n");
return 1;
}
}
else {
outbuf = (char *) malloc( cp.tdx * cp.tdy * cp.tw * cp.th * 2); /* Allocate memory for all tiles */
cio_init(outbuf, cp.tdx * cp.tdy * cp.tw * cp.th * 2);
len = j2k_encode(&img, &cp, outbuf, cp.tdx * cp.tdy * cp.tw * cp.th * 2, index);
if (len == 0) {
fprintf(stderr, "failed to encode image\n");
return 1;
}
f = fopen(outfile, "wb");
if (!f) {
fprintf(stderr, "failed to open %s for writing\n", outfile);
return 1;
}
fwrite(outbuf, 1, len, f);
free(outbuf);
fclose(f);
}
}
else /* JP2 format output */
{
jp2_struct_t * jp2_struct;
jp2_struct = (jp2_struct_t *) malloc(sizeof(jp2_struct_t));
jp2_struct->image = &img;
/* Initialising the standard JP2 box content*/
/* If you wish to modify those boxes, you have to modify the jp2_struct content*/
if (jp2_init_stdjp2(jp2_struct, &img))
{
fprintf(stderr,"Error with jp2 initialization");
return 1;
};
if (cp.intermed_file==1) {
/*For the moment, JP2 format does not use intermediary files for each tile*/
cp.intermed_file=0;
}
outbuf = (char *) malloc( cp.tdx * cp.tdy * cp.tw * cp.th * 2);
cio_init(outbuf, cp.tdx * cp.tdy * cp.tw * cp.th * 2);
len = jp2_encode(jp2_struct, &cp, outbuf, index);
if (len == 0) {
fprintf(stderr, "failed to encode image\n");
return 1;
}
f = fopen(outfile, "wb");
if (!f) {
fprintf(stderr, "failed to open %s for writing\n", outfile);
return 1;
}
fwrite(outbuf, 1, len, f);
free(outbuf);
fclose(f);
}
/* Remove the temporary files */
/* -------------------------- */
if (cp.image_type) { /* PNM PGM PPM */
for (i = 0; i < img.numcomps; i++) {
char tmp;
sprintf(&tmp, "Compo%d", i);
if (remove(&tmp) == -1) {
fprintf(stderr, "failed to kill %s file !\n", &tmp);
}
}
} else { /* PGX */
for (i = 0; i < cp.th; i++) {
char tmp;
sprintf(&tmp, "bandtile%d", i + 1);
if (remove(&tmp) == -1) {
fprintf(stderr, "failed to kill %s file !\n", &tmp);
}
}
}
/* Free memory */
free(img.comps);
free(cp_init.tcps);
if (tcp_init->numlayers > 9) free(cp.matrice);
for (tileno = 0; tileno < cp.tw * cp.th; tileno++)
free(cp.tcps[tileno].tccps);
free(cp.tcps);
system("pause");
return 0;
}

View File

@ -0,0 +1,561 @@
/* Copyright (c) 2001 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 <openjpeg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern int cslen; // Aggiunta in JPWL (per gestire l'inserimento di RED nella CS!)
int ceildiv(int a, int b)
{
return (a + b - 1) / b;
}
int main(int argc, char **argv)
{
FILE *f;
char *src, *src_name;
char *dest, S1, S2, S3;
int len;
j2k_image_t img;
j2k_cp_t cp;
int w, wr, wrr, h, hr, hrr, max;
int i, image_type = -1, compno, pad, j;
int adjust;
jp2_struct_t *jp2_struct;
if (argc < 3) {
fprintf(stderr,
"usage: %s j2k-file image-file [-reduce n]\n", argv[0]);
return 1;
}
f = fopen(argv[1], "rb");
if (!f) {
fprintf(stderr, "failed to open %s for reading\n", argv[1]);
return 1;
}
dest = argv[2];
cp.reduce_on = 0;
cp.reduce_value = 0;
/* OPTION REDUCE IS ACTIVE */
if (argc == 5) {
if (strcmp(argv[3], "-reduce")) {
fprintf(stderr,
"usage: options " "-reduce n"
" where n is the factor of reduction [%s]\n", argv[3]);
return 1;
}
cp.reduce_on = 1;
sscanf(argv[4], "%d", &cp.reduce_value);
}
while (*dest) {
dest++;
}
dest--;
S3 = *dest;
dest--;
S2 = *dest;
dest--;
S1 = *dest;
if ((S1 == 'p' && S2 == 'g' && S3 == 'x')
|| (S1 == 'P' && S2 == 'G' && S3 == 'X')) {
image_type = 0;
dest--;
*dest = '\0';
}
if ((S1 == 'p' && S2 == 'n' && S3 == 'm')
|| (S1 == 'P' && S2 == 'N' && S3 == 'M') || (S1 == 'p' && S2 == 'g'
&& S3 == 'm')
|| (S1 == 'P' && S2 == 'G' && S3 == 'M') || (S1 == 'P' && S2 == 'P'
&& S3 == 'M')
|| (S1 == 'p' && S2 == 'p' && S3 == 'm')) {
image_type = 1;
}
if ((S1 == 'b' && S2 == 'm' && S3 == 'p')
|| (S1 == 'B' && S2 == 'M' && S3 == 'P')) {
image_type = 2;
}
if (image_type == -1) {
fprintf(stderr,
"!! Unrecognized format for infile : %c%c%c [accept only *.pnm, *.pgm, *.ppm, *.pgx or *.bmp] !!\n\n",
S1, S2, S3);
return 1;
}
fseek(f, 0, SEEK_END);
len = ftell(f);
fseek(f, 0, SEEK_SET);
src = (char *) malloc(len);
fread(src, 1, len, f);
fclose(f);
src_name = argv[1];
while (*src_name) {
src_name++;
}
src_name--;
S3 = *src_name;
src_name--;
S2 = *src_name;
src_name--;
S1 = *src_name;
/* J2K format */
if ((S1 == 'j' && S2 == '2' && S3 == 'k')
|| (S1 == 'J' && S2 == '2' && S3 == 'K') || (S1 == 'j' && S2 == '2'
&& S3 == 'c')
|| (S1 == 'J' && S2 == '2' && S3 == 'C')) {
if (!j2k_decode(src, len, &img, &cp)) {
fprintf(stderr, "j2k_to_image: failed to decode image!\n");
return 1;
}
}
/* JP2 format */
else if ((S1 == 'j' && S2 == 'p' && S3 == '2')
|| (S1 == 'J' && S2 == 'P' && S3 == '2')) {
jp2_struct = (jp2_struct_t *) malloc(sizeof(jp2_struct_t));
jp2_struct->image = &img;
if (jp2_decode(src, len, jp2_struct, &cp)) {
fprintf(stderr, "j2k_to_image: failed to decode image!\n");
return 1;
}
/* Insert code here if you want to create actions on jp2_struct before deleting it */
free(jp2_struct);
}
/* JPT format */
else if ((S1 == 'j' && S2 == 'p' && S3 == 't')
|| (S1 == 'J' && S2 == 'P' && S3 == 'T')) {
if (!j2k_decode_jpt_stream(src, len, &img, &cp)) {
fprintf(stderr, "j2k_to_image: failed to decode image!\n");
return 1;
}
}
/* otherwise : error */
else {
fprintf(stderr,
"j2k_to_image : Unknown format image *.%c%c%c [only *.j2k, *.jp2, *.jpc or *.jpt]!! \n",
S1, S2, S3);
return 1;
}
src = realloc(src, cslen); // Aggiunta in JPWL per evitare errori di free a causa
// della modifica di CS in caso di aggiunta RED!
free(src);
/* ------------------ CREATE OUT IMAGE WITH THE RIGHT FORMAT ----------------------- */
/* ---------------------------- / */
/* / / */
/* / FORMAT : PNM, PGM or PPM / */
/* / / */
/* ---------------------------- / */
switch (image_type) {
case 1: /* PNM PGM PPM */
if (img.numcomps == 3 && img.comps[0].dx == img.comps[1].dx
&& img.comps[1].dx == img.comps[2].dx
&& img.comps[0].dy == img.comps[1].dy
&& img.comps[1].dy == img.comps[2].dy
&& img.comps[0].prec == img.comps[1].prec
&& img.comps[1].prec == img.comps[2].prec) {
f = fopen(argv[2], "wb");
w = ceildiv(img.x1 - img.x0, img.comps[0].dx);
// wr = ceildiv(int_ceildivpow2(img.x1 - img.x0,img.factor),img.comps[0].dx);
wr = img.comps[0].w;
wrr = int_ceildivpow2(img.comps[0].w, img.comps[0].factor);
h = ceildiv(img.y1 - img.y0, img.comps[0].dy);
// hr = ceildiv(int_ceildivpow2(img.y1 - img.y0,img.factor), img.comps[0].dy);
hr = img.comps[0].h;
hrr = int_ceildivpow2(img.comps[0].h, img.comps[0].factor);
max = img.comps[0].prec > 8 ? 255 : (1 << img.comps[0].prec) - 1;
img.comps[0].x0 =
int_ceildivpow2(img.comps[0].x0 -
int_ceildiv(img.x0, img.comps[0].dx),
img.comps[0].factor);
img.comps[0].y0 =
int_ceildivpow2(img.comps[0].y0 -
int_ceildiv(img.y0, img.comps[0].dy),
img.comps[0].factor);
fprintf(f, "P6\n# %d %d %d %d %d\n%d %d\n%d\n",
cp.tcps[cp.tileno[0]].tccps[0].numresolutions, w, h,
img.comps[0].x0, img.comps[0].y0, wrr, hrr, max);
adjust = img.comps[0].prec > 8 ? img.comps[0].prec - 8 : 0;
for (i = 0; i < wrr * hrr; i++) {
char r, g, b;
r = img.comps[0].data[i / wrr * wr + i % wrr];
r += (img.comps[0].sgnd ? 1 << (img.comps[0].prec - 1) : 0);
r = r >> adjust;
g = img.comps[1].data[i / wrr * wr + i % wrr];
g += (img.comps[1].sgnd ? 1 << (img.comps[1].prec - 1) : 0);
g = g >> adjust;
b = img.comps[2].data[i / wrr * wr + i % wrr];
b += (img.comps[2].sgnd ? 1 << (img.comps[2].prec - 1) : 0);
b = b >> adjust;
fprintf(f, "%c%c%c", r, g, b);
}
free(img.comps[0].data);
free(img.comps[1].data);
free(img.comps[2].data);
fclose(f);
} else {
for (compno = 0; compno < img.numcomps; compno++) {
char name[256];
if (img.numcomps > 1) {
sprintf(name, "%d.%s", compno, argv[2]);
} else {
sprintf(name, "%s", argv[2]);
}
f = fopen(name, "wb");
w = ceildiv(img.x1 - img.x0, img.comps[compno].dx);
// wr = ceildiv(int_ceildivpow2(img.x1 - img.x0,img.factor),img.comps[compno].dx);
wr = img.comps[compno].w;
wrr =
int_ceildivpow2(img.comps[compno].w, img.comps[compno].factor);
h = ceildiv(img.y1 - img.y0, img.comps[compno].dy);
// hr = ceildiv(int_ceildivpow2(img.y1 - img.y0,img.factor), img.comps[compno].dy);
hr = img.comps[compno].h;
hrr =
int_ceildivpow2(img.comps[compno].h, img.comps[compno].factor);
max =
img.comps[compno].prec >
8 ? 255 : (1 << img.comps[compno].prec) - 1;
img.comps[compno].x0 =
int_ceildivpow2(img.comps[compno].x0 -
int_ceildiv(img.x0,
img.comps[compno].dx),
img.comps[compno].factor);
img.comps[compno].y0 =
int_ceildivpow2(img.comps[compno].y0 -
int_ceildiv(img.y0,
img.comps[compno].dy),
img.comps[compno].factor);
fprintf(f, "P5\n# %d %d %d %d %d\n%d %d\n%d\n",
cp.tcps[cp.tileno[0]].tccps[compno].
numresolutions, w, h, img.comps[compno].x0,
img.comps[compno].y0, wrr, hrr, max);
adjust =
img.comps[compno].prec > 8 ? img.comps[compno].prec - 8 : 0;
for (i = 0; i < wrr * hrr; i++) {
char l;
l = img.comps[compno].data[i / wrr * wr + i % wrr];
l += (img.comps[compno].
sgnd ? 1 << (img.comps[compno].prec - 1) : 0);
l = l >> adjust;
fprintf(f, "%c", l);
}
fclose(f);
free(img.comps[compno].data);
}
}
break;
/* ------------------------ / */
/* / / */
/* / FORMAT : PGX / */
/* / / */
/* /----------------------- / */
case 0: /* PGX */
for (compno = 0; compno < img.numcomps; compno++) {
j2k_comp_t *comp = &img.comps[compno];
char name[256];
int nbytes = 0;
//if (img.numcomps > 1)
sprintf(name, "%s-%d.pgx", argv[2], compno);
//else
//sprintf(name, "%s.pgx", argv[2]);
f = fopen(name, "wb");
// w = ceildiv(img.x1 - img.x0, comp->dx);
// wr = ceildiv(int_ceildivpow2(img.x1 - img.x0,img.factor), comp->dx);
w = img.comps[compno].w;
wr = int_ceildivpow2(img.comps[compno].w, img.comps[compno].factor);
// h = ceildiv(img.y1 - img.y0, comp->dy);
// hr = ceildiv(int_ceildivpow2(img.y1 - img.y0,img.factor), comp->dy);
h = img.comps[compno].h;
hr = int_ceildivpow2(img.comps[compno].h, img.comps[compno].factor);
fprintf(f, "PG ML %c %d %d %d\n", comp->sgnd ? '-' : '+',
comp->prec, wr, hr);
if (comp->prec <= 8)
nbytes = 1;
else if (comp->prec <= 16)
nbytes = 2;
else
nbytes = 4;
for (i = 0; i < wr * hr; i++) {
int v = img.comps[compno].data[i / wr * w + i % wr];
for (j = nbytes - 1; j >= 0; j--) {
char byte = (char) (v >> (j * 8));
fwrite(&byte, 1, 1, f);
}
}
free(img.comps[compno].data);
fclose(f);
}
break;
/* ------------------------ / */
/* / / */
/* / FORMAT : BMP / */
/* / / */
/* /----------------------- / */
case 2: /* BMP */
if (img.numcomps == 3 && img.comps[0].dx == img.comps[1].dx
&& img.comps[1].dx == img.comps[2].dx
&& img.comps[0].dy == img.comps[1].dy
&& img.comps[1].dy == img.comps[2].dy
&& img.comps[0].prec == img.comps[1].prec
&& img.comps[1].prec == img.comps[2].prec) {
/* -->> -->> -->> -->>
24 bits color
<<-- <<-- <<-- <<-- */
f = fopen(argv[2], "wb");
// w = ceildiv(img.x1 - img.x0, img.comps[0].dx);
// wr = ceildiv(int_ceildivpow2(img.x1 - img.x0,img.factor), img.comps[0].dx);
w = img.comps[0].w;
wr = int_ceildivpow2(img.comps[0].w, img.comps[0].factor);
// h = ceildiv(img.y1 - img.y0, img.comps[0].dy);
// hr = ceildiv(int_ceildivpow2(img.y1 - img.y0,img.factor), img.comps[0].dy);
h = img.comps[0].h;
hr = int_ceildivpow2(img.comps[0].h, img.comps[0].factor);
fprintf(f, "BM");
/* FILE HEADER */
/* ------------- */
fprintf(f, "%c%c%c%c",
(unsigned char) (hr * wr * 3 + 3 * hr * (wr % 2) +
54) & 0xff,
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
>> 8) & 0xff,
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
>> 16) & 0xff,
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2) + 54)
>> 24) & 0xff);
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (54) & 0xff, ((54) >> 8) & 0xff,
((54) >> 16) & 0xff, ((54) >> 24) & 0xff);
/* INFO HEADER */
/* ------------- */
fprintf(f, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff,
((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (unsigned char) ((wr) & 0xff),
(unsigned char) ((wr) >> 8) & 0xff,
(unsigned char) ((wr) >> 16) & 0xff,
(unsigned char) ((wr) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (unsigned char) ((hr) & 0xff),
(unsigned char) ((hr) >> 8) & 0xff,
(unsigned char) ((hr) >> 16) & 0xff,
(unsigned char) ((hr) >> 24) & 0xff);
fprintf(f, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
fprintf(f, "%c%c", (24) & 0xff, ((24) >> 8) & 0xff);
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
fprintf(f, "%c%c%c%c",
(unsigned char) (3 * hr * wr +
3 * hr * (wr % 2)) & 0xff,
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
8) & 0xff,
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
16) & 0xff,
(unsigned char) ((hr * wr * 3 + 3 * hr * (wr % 2)) >>
24) & 0xff);
fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
for (i = 0; i < wr * hr; i++) {
unsigned char R, G, B;
/* a modifier */
// R = img.comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
R = img.comps[0].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
// G = img.comps[1].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
G = img.comps[1].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
// B = img.comps[2].data[w * h - ((i) / (w) + 1) * w + (i) % (w)];
B = img.comps[2].data[w * hr - ((i) / (wr) + 1) * w + (i) % (wr)];
fprintf(f, "%c%c%c", B, G, R);
if ((i + 1) % wr == 0) {
for (pad = (3 * wr) % 4 ? 4 - (3 * wr) % 4 : 0; pad > 0; pad--) /* ADD */
fprintf(f, "%c", 0);
}
}
fclose(f);
free(img.comps[1].data);
free(img.comps[2].data);
} else { /* Gray-scale */
/* -->> -->> -->> -->>
8 bits non code (Gray scale)
<<-- <<-- <<-- <<-- */
f = fopen(argv[2], "wb");
// w = ceildiv(img.x1 - img.x0, img.comps[0].dx);
// wr = ceildiv(int_ceildivpow2(img.x1 - img.x0,img.factor), img.comps[0].dx);
w = img.comps[0].w;
wr = int_ceildivpow2(img.comps[0].w, img.comps[0].factor);
// h = ceildiv(img.y1 - img.y0, img.comps[0].dy);
// hr = ceildiv(int_ceildivpow2(img.y1 - img.y0,img.factor), img.comps[0].dy);
h = img.comps[0].h;
hr = int_ceildivpow2(img.comps[0].h, img.comps[0].factor);
fprintf(f, "BM");
/* FILE HEADER */
/* ------------- */
fprintf(f, "%c%c%c%c",
(unsigned char) (hr * wr + 54 + 1024 +
hr * (wr % 2)) & 0xff,
(unsigned char) ((hr * wr + 54 + 1024 + hr * (wr % 2))
>> 8) & 0xff,
(unsigned char) ((hr * wr + 54 + 1024 + hr * (wr % 2))
>> 16) & 0xff,
(unsigned char) ((hr * wr + 54 + 1024 + wr * (wr % 2))
>> 24) & 0xff);
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (54 + 1024) & 0xff,
((54 + 1024) >> 8) & 0xff, ((54 + 1024) >> 16) & 0xff,
((54 + 1024) >> 24) & 0xff);
/* INFO HEADER */
/* ------------- */
fprintf(f, "%c%c%c%c", (40) & 0xff, ((40) >> 8) & 0xff,
((40) >> 16) & 0xff, ((40) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (unsigned char) ((wr) & 0xff),
(unsigned char) ((wr) >> 8) & 0xff,
(unsigned char) ((wr) >> 16) & 0xff,
(unsigned char) ((wr) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (unsigned char) ((hr) & 0xff),
(unsigned char) ((hr) >> 8) & 0xff,
(unsigned char) ((hr) >> 16) & 0xff,
(unsigned char) ((hr) >> 24) & 0xff);
fprintf(f, "%c%c", (1) & 0xff, ((1) >> 8) & 0xff);
fprintf(f, "%c%c", (8) & 0xff, ((8) >> 8) & 0xff);
fprintf(f, "%c%c%c%c", (0) & 0xff, ((0) >> 8) & 0xff,
((0) >> 16) & 0xff, ((0) >> 24) & 0xff);
fprintf(f, "%c%c%c%c",
(unsigned char) (hr * wr + hr * (wr % 2)) & 0xff,
(unsigned char) ((hr * wr + hr * (wr % 2)) >> 8) &
0xff,
(unsigned char) ((hr * wr + hr * (wr % 2)) >> 16) &
0xff,
(unsigned char) ((hr * wr + hr * (wr % 2)) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (7834) & 0xff, ((7834) >> 8) & 0xff,
((7834) >> 16) & 0xff, ((7834) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff,
((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
fprintf(f, "%c%c%c%c", (256) & 0xff, ((256) >> 8) & 0xff,
((256) >> 16) & 0xff, ((256) >> 24) & 0xff);
}
for (i = 0; i < 256; i++) {
fprintf(f, "%c%c%c%c", i, i, i, 0);
}
for (i = 0; i < wr * hr; i++) {
/* a modifier !! */
// fprintf(f, "%c", img.comps[0].data[w * h - ((i) / (w) + 1) * w + (i) % (w)]);
fprintf(f, "%c",
img.comps[0].data[w * hr - ((i) / (wr) + 1) * w +
(i) % (wr)]);
/*if (((i + 1) % w == 0 && w % 2))
fprintf(f, "%c", 0); */
if ((i + 1) % wr == 0) {
for (pad = wr % 4 ? 4 - wr % 4 : 0; pad > 0; pad--) /* ADD */
fprintf(f, "%c", 0);
}
}
fclose(f);
free(img.comps[0].data);
break;
default:
break;
}
return 0;
}

View File

@ -0,0 +1,246 @@
# 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 /W3 /GX /O2 /I "../libopenjpeg" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "DONT_HAVE_GETOPT" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x80c /d "NDEBUG"
# ADD RSC /l 0x80c /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 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /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 "j2k_to_image___Win32_Debug"
# PROP BASE Intermediate_Dir "j2k_to_image___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "j2k_to_image___Win32_Debug"
# PROP Intermediate_Dir "j2k_to_image___Win32_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 /W3 /Gm /GX /ZI /Od /I "../libopenjpeg" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "DONT_HAVE_GETOPT" /YX /FD /GZ /c
# ADD BASE RSC /l 0x80c /d "_DEBUG"
# ADD RSC /l 0x80c /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 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 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 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\fix.c
# End Source File
# Begin Source File
SOURCE=.\compat\getopt.c
# End Source File
# Begin Source File
SOURCE=..\libopenjpeg\int.c
# End Source File
# Begin Source File
SOURCE=..\libopenjpeg\j2k.c
# End Source File
# Begin Source File
SOURCE=.\j2k_to_image.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\jpw.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\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\fix.h
# End Source File
# Begin Source File
SOURCE=.\compat\getopt.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\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\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"
# End Group
# End Target
# End Project

View File

@ -0,0 +1,29 @@
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>
{{{
}}}
###############################################################################

View File

@ -0,0 +1 @@
Microsoft C/C++ program database 2.00

View File

@ -0,0 +1 @@
ÐÏࡱ

View File

@ -0,0 +1,85 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: j2k_to_image - Win32 Release--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\baruffa\IMPOST~1\Temp\RSP77.tmp" with contents
[
/nologo /ML /W3 /GX /O2 /I "../libopenjpeg" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "DONT_HAVE_GETOPT" /Fo"Release/" /Fd"Release/" /FD /c
"C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c"
]
Creating command line "cl.exe @C:\DOCUME~1\baruffa\IMPOST~1\Temp\RSP77.tmp"
Creating temporary file "C:\DOCUME~1\baruffa\IMPOST~1\Temp\RSP78.tmp" with contents
[
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /pdb:"Release/j2k_to_image.pdb" /machine:I386 /out:"Release/j2k_to_image.exe"
".\Release\bio.obj"
".\Release\cio.obj"
".\Release\dwt.obj"
".\Release\fix.obj"
".\Release\getopt.obj"
".\Release\int.obj"
".\Release\j2k.obj"
".\Release\j2k_to_image.obj"
".\Release\jp2.obj"
".\Release\jpt.obj"
".\Release\jpw.obj"
".\Release\mct.obj"
".\Release\mqc.obj"
".\Release\pi.obj"
".\Release\raw.obj"
".\Release\t1.obj"
".\Release\t2.obj"
".\Release\tcd.obj"
".\Release\tgt.obj"
]
Creating command line "link.exe @C:\DOCUME~1\baruffa\IMPOST~1\Temp\RSP78.tmp"
<h3>Output Window</h3>
Compiling...
jpw.c
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(635) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(683) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(692) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(696) : warning C4018: '==' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(833) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(940) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(1077) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(1092) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(1197) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(1301) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(1389) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(1444) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(1628) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(1658) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(1732) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(1810) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(1987) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2094) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2214) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2220) : warning C4018: '==' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2228) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2232) : warning C4018: '==' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2314) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2417) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(1864) : warning C4101: 'prova' : unreferenced local variable
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2582) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2628) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2788) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2808) : warning C4018: '==' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2818) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2830) : warning C4018: '==' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2888) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2962) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2499) : warning C4101: 'ldpepb' : unreferenced local variable
C:\Documents and Settings\baruffa\Desktop\DecoderJPWL\libopenjpeg\jpw.c(2499) : warning C4101: 'pepb' : unreferenced local variable
Linking...
<h3>Results</h3>
j2k_to_image.exe - 0 error(s), 35 warning(s)
</pre>
</body>
</html>

View File

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 7.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "j2k_to_image", "j2k_to_image.vcproj", "{3C09E691-8555-47D1-B1E6-D411A6314AC8}"
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug
ConfigName.1 = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
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

View File

@ -0,0 +1 @@
ÐÏࡱ

View File

@ -0,0 +1,252 @@
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="j2k_to_image"
ProjectGUID="{3C09E691-8555-47D1-B1E6-D411A6314AC8}"
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"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="../libopenjpeg"
PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE,DONT_HAVE_GETOPT"
StringPooling="TRUE"
RuntimeLibrary="4"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/j2k_to_image.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/j2k_to_image.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ProgramDatabaseFile=".\Release/j2k_to_image.pdb"
SubSystem="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Release/j2k_to_image.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="2060"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\j2k_to_image___Win32_Debug"
IntermediateDirectory=".\j2k_to_image___Win32_Debug"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../libopenjpeg"
PreprocessorDefinitions="_DEBUG,WIN32,_CONSOLE,DONT_HAVE_GETOPT"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\j2k_to_image___Win32_Debug/j2k_to_image.pch"
AssemblerListingLocation=".\j2k_to_image___Win32_Debug/"
ObjectFile=".\j2k_to_image___Win32_Debug/"
ProgramDataBaseFileName=".\j2k_to_image___Win32_Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="odbc32.lib odbccp32.lib"
OutputFile=".\j2k_to_image___Win32_Debug/j2k_to_image.exe"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\j2k_to_image___Win32_Debug/j2k_to_image.pdb"
SubSystem="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\j2k_to_image___Win32_Debug/j2k_to_image.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="2060"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
</Configurations>
<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="..\libopenjpeg\dwt.c">
</File>
<File
RelativePath="..\libopenjpeg\fix.c">
</File>
<File
RelativePath=".\compat\getopt.c">
</File>
<File
RelativePath="..\libopenjpeg\int.c">
</File>
<File
RelativePath="..\libopenjpeg\j2k.c">
</File>
<File
RelativePath=".\j2k_to_image.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\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="..\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\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>

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