[trunk] JP3D: convert from DOS to UNIX eol

This commit is contained in:
Mathieu Malaterre 2013-01-02 18:19:56 +00:00
parent df47fae287
commit caaec3bb05
32 changed files with 12650 additions and 12650 deletions

View File

@ -1,189 +1,189 @@
/* /*
* Copyright (c) 2001-2003, David Janssens * Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "opj_includes.h" #include "opj_includes.h"
/** @defgroup BIO BIO - Individual bit input-output stream */ /** @defgroup BIO BIO - Individual bit input-output stream */
/*@{*/ /*@{*/
/** @name Local static functions */ /** @name Local static functions */
/*@{*/ /*@{*/
/** /**
Write a bit Write a bit
@param bio BIO handle @param bio BIO handle
@param b Bit to write (0 or 1) @param b Bit to write (0 or 1)
*/ */
static void bio_putbit(opj_bio_t *bio, int b); static void bio_putbit(opj_bio_t *bio, int b);
/** /**
Read a bit Read a bit
@param bio BIO handle @param bio BIO handle
@return Returns the read bit @return Returns the read bit
*/ */
static int bio_getbit(opj_bio_t *bio); static int bio_getbit(opj_bio_t *bio);
/** /**
Write a byte Write a byte
@param bio BIO handle @param bio BIO handle
@return Returns 0 if successful, returns 1 otherwise @return Returns 0 if successful, returns 1 otherwise
*/ */
static int bio_byteout(opj_bio_t *bio); static int bio_byteout(opj_bio_t *bio);
/** /**
Read a byte Read a byte
@param bio BIO handle @param bio BIO handle
@return Returns 0 if successful, returns 1 otherwise @return Returns 0 if successful, returns 1 otherwise
*/ */
static int bio_bytein(opj_bio_t *bio); static int bio_bytein(opj_bio_t *bio);
/*@}*/ /*@}*/
/*@}*/ /*@}*/
/* /*
========================================================== ==========================================================
local functions local functions
========================================================== ==========================================================
*/ */
static int bio_byteout(opj_bio_t *bio) { static int bio_byteout(opj_bio_t *bio) {
bio->buf = (bio->buf << 8) & 0xffff; bio->buf = (bio->buf << 8) & 0xffff;
bio->ct = bio->buf == 0xff00 ? 7 : 8; bio->ct = bio->buf == 0xff00 ? 7 : 8;
if (bio->bp >= bio->end) { if (bio->bp >= bio->end) {
return 1; return 1;
} }
*bio->bp++ = bio->buf >> 8; *bio->bp++ = bio->buf >> 8;
return 0; return 0;
} }
static int bio_bytein(opj_bio_t *bio) { static int bio_bytein(opj_bio_t *bio) {
bio->buf = (bio->buf << 8) & 0xffff; bio->buf = (bio->buf << 8) & 0xffff;
bio->ct = bio->buf == 0xff00 ? 7 : 8; bio->ct = bio->buf == 0xff00 ? 7 : 8;
if (bio->bp >= bio->end) { if (bio->bp >= bio->end) {
return 1; return 1;
} }
bio->buf |= *bio->bp++; bio->buf |= *bio->bp++;
return 0; return 0;
} }
static void bio_putbit(opj_bio_t *bio, int b) { static void bio_putbit(opj_bio_t *bio, int b) {
if (bio->ct == 0) { if (bio->ct == 0) {
bio_byteout(bio); bio_byteout(bio);
} }
bio->ct--; bio->ct--;
bio->buf |= b << bio->ct; bio->buf |= b << bio->ct;
} }
/* MOD antonin */ /* MOD antonin */
static int bio_getbit(opj_bio_t *bio) { static int bio_getbit(opj_bio_t *bio) {
/* DOM */ /* DOM */
if (bio->ct == 0) { if (bio->ct == 0) {
bio_bytein(bio); bio_bytein(bio);
} }
bio->ct--; bio->ct--;
return (bio->buf >> bio->ct) & 1; return (bio->buf >> bio->ct) & 1;
} }
/* /*
========================================================== ==========================================================
Bit Input/Output interface Bit Input/Output interface
========================================================== ==========================================================
*/ */
opj_bio_t* bio_create() { opj_bio_t* bio_create() {
opj_bio_t *bio = (opj_bio_t*)opj_malloc(sizeof(opj_bio_t)); opj_bio_t *bio = (opj_bio_t*)opj_malloc(sizeof(opj_bio_t));
return bio; return bio;
} }
void bio_destroy(opj_bio_t *bio) { void bio_destroy(opj_bio_t *bio) {
if(bio) { if(bio) {
opj_free(bio); opj_free(bio);
} }
} }
int bio_numbytes(opj_bio_t *bio) { int bio_numbytes(opj_bio_t *bio) {
return (bio->bp - bio->start); return (bio->bp - bio->start);
} }
void bio_init_enc(opj_bio_t *bio, unsigned char *bp, int len) { void bio_init_enc(opj_bio_t *bio, unsigned char *bp, int len) {
bio->start = bp; bio->start = bp;
bio->end = bp + len; bio->end = bp + len;
bio->bp = bp; bio->bp = bp;
bio->buf = 0; bio->buf = 0;
bio->ct = 8; bio->ct = 8;
} }
void bio_init_dec(opj_bio_t *bio, unsigned char *bp, int len) { void bio_init_dec(opj_bio_t *bio, unsigned char *bp, int len) {
bio->start = bp; bio->start = bp;
bio->end = bp + len; bio->end = bp + len;
bio->bp = bp; bio->bp = bp;
bio->buf = 0; bio->buf = 0;
bio->ct = 0; bio->ct = 0;
} }
void bio_write(opj_bio_t *bio, int v, int n) { void bio_write(opj_bio_t *bio, int v, int n) {
int i; int i;
for (i = n - 1; i >= 0; i--) { for (i = n - 1; i >= 0; i--) {
bio_putbit(bio, (v >> i) & 1); bio_putbit(bio, (v >> i) & 1);
} }
} }
int bio_read(opj_bio_t *bio, int n) { int bio_read(opj_bio_t *bio, int n) {
int i, v; int i, v;
v = 0; v = 0;
for (i = n - 1; i >= 0; i--) { for (i = n - 1; i >= 0; i--) {
v += bio_getbit(bio) << i; v += bio_getbit(bio) << i;
} }
return v; return v;
} }
int bio_flush(opj_bio_t *bio) { int bio_flush(opj_bio_t *bio) {
bio->ct = 0; bio->ct = 0;
if (bio_byteout(bio)) { if (bio_byteout(bio)) {
return 1; return 1;
} }
if (bio->ct == 7) { if (bio->ct == 7) {
bio->ct = 0; bio->ct = 0;
if (bio_byteout(bio)) { if (bio_byteout(bio)) {
return 1; return 1;
} }
} }
return 0; return 0;
} }
int bio_inalign(opj_bio_t *bio) { int bio_inalign(opj_bio_t *bio) {
bio->ct = 0; bio->ct = 0;
if ((bio->buf & 0xff) == 0xff) { if ((bio->buf & 0xff) == 0xff) {
if (bio_bytein(bio)) { if (bio_bytein(bio)) {
return 1; return 1;
} }
bio->ct = 0; bio->ct = 0;
} }
return 0; return 0;
} }

View File

@ -1,132 +1,132 @@
/* /*
* Copyright (c) 2001-2003, David Janssens * Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __BIO_H #ifndef __BIO_H
#define __BIO_H #define __BIO_H
/** /**
@file bio.h @file bio.h
@brief Implementation of an individual bit input-output (BIO) @brief Implementation of an individual bit input-output (BIO)
The functions in BIO.C have for goal to realize an individual bit input - output. The functions in BIO.C have for goal to realize an individual bit input - output.
*/ */
/** @defgroup BIO BIO - Individual bit input-output stream */ /** @defgroup BIO BIO - Individual bit input-output stream */
/*@{*/ /*@{*/
/** /**
Individual bit input-output stream (BIO) Individual bit input-output stream (BIO)
*/ */
typedef struct opj_bio { typedef struct opj_bio {
/** pointer to the start of the buffer */ /** pointer to the start of the buffer */
unsigned char *start; unsigned char *start;
/** pointer to the end of the buffer */ /** pointer to the end of the buffer */
unsigned char *end; unsigned char *end;
/** pointer to the present position in the buffer */ /** pointer to the present position in the buffer */
unsigned char *bp; unsigned char *bp;
/** temporary place where each byte is read or written */ /** temporary place where each byte is read or written */
unsigned int buf; unsigned int buf;
/** coder : number of bits free to write. decoder : number of bits read */ /** coder : number of bits free to write. decoder : number of bits read */
int ct; int ct;
} opj_bio_t; } opj_bio_t;
/** @name Funciones generales */ /** @name Funciones generales */
/*@{*/ /*@{*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Create a new BIO handle Create a new BIO handle
@return Returns a new BIO handle if successful, returns NULL otherwise @return Returns a new BIO handle if successful, returns NULL otherwise
*/ */
opj_bio_t* bio_create(void); opj_bio_t* bio_create(void);
/** /**
Destroy a previously created BIO handle Destroy a previously created BIO handle
@param bio BIO handle to destroy @param bio BIO handle to destroy
*/ */
void bio_destroy(opj_bio_t *bio); void bio_destroy(opj_bio_t *bio);
/** /**
Number of bytes written. Number of bytes written.
@param bio BIO handle @param bio BIO handle
@return Returns the number of bytes written @return Returns the number of bytes written
*/ */
int bio_numbytes(opj_bio_t *bio); int bio_numbytes(opj_bio_t *bio);
/** /**
Init encoder Init encoder
@param bio BIO handle @param bio BIO handle
@param bp Output buffer @param bp Output buffer
@param len Output buffer length @param len Output buffer length
*/ */
void bio_init_enc(opj_bio_t *bio, unsigned char *bp, int len); void bio_init_enc(opj_bio_t *bio, unsigned char *bp, int len);
/** /**
Init decoder Init decoder
@param bio BIO handle @param bio BIO handle
@param bp Input buffer @param bp Input buffer
@param len Input buffer length @param len Input buffer length
*/ */
void bio_init_dec(opj_bio_t *bio, unsigned char *bp, int len); void bio_init_dec(opj_bio_t *bio, unsigned char *bp, int len);
/** /**
Write bits Write bits
@param bio BIO handle @param bio BIO handle
@param v Value of bits @param v Value of bits
@param n Number of bits to write @param n Number of bits to write
*/ */
void bio_write(opj_bio_t *bio, int v, int n); void bio_write(opj_bio_t *bio, int v, int n);
/** /**
Read bits Read bits
@param bio BIO handle @param bio BIO handle
@param n Number of bits to read @param n Number of bits to read
@return Returns the corresponding read number @return Returns the corresponding read number
*/ */
int bio_read(opj_bio_t *bio, int n); int bio_read(opj_bio_t *bio, int n);
/** /**
Flush bits Flush bits
@param bio BIO handle @param bio BIO handle
@return Returns 1 if successful, returns 0 otherwise @return Returns 1 if successful, returns 0 otherwise
*/ */
int bio_flush(opj_bio_t *bio); int bio_flush(opj_bio_t *bio);
/** /**
Passes the ending bits (coming from flushing) Passes the ending bits (coming from flushing)
@param bio BIO handle @param bio BIO handle
@return Returns 1 if successful, returns 0 otherwise @return Returns 1 if successful, returns 0 otherwise
*/ */
int bio_inalign(opj_bio_t *bio); int bio_inalign(opj_bio_t *bio);
/** /**
Read a bit Read a bit
@param bio BIO handle @param bio BIO handle
@return Returns the read bit @return Returns the read bit
*/ */
/* MOD antonin */ /* MOD antonin */
/*int bio_getbit(opj_bio_t *bio);*/ /*int bio_getbit(opj_bio_t *bio);*/
/* DOM */ /* DOM */
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/*@}*/ /*@}*/
/*@}*/ /*@}*/
#endif /* __BIO_H */ #endif /* __BIO_H */

View File

@ -1,217 +1,217 @@
/* /*
* Copyright (c) 2001-2003, David Janssens * Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "opj_includes.h" #include "opj_includes.h"
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length) { opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length) {
opj_cp_t *cp = NULL; opj_cp_t *cp = NULL;
opj_cio_t *cio = (opj_cio_t*)opj_malloc(sizeof(opj_cio_t)); opj_cio_t *cio = (opj_cio_t*)opj_malloc(sizeof(opj_cio_t));
if(!cio) return NULL; if(!cio) return NULL;
cio->cinfo = cinfo; cio->cinfo = cinfo;
if(buffer && length) { if(buffer && length) {
/* wrap a user buffer containing the encoded image */ /* wrap a user buffer containing the encoded image */
cio->openmode = OPJ_STREAM_READ; cio->openmode = OPJ_STREAM_READ;
cio->buffer = buffer; cio->buffer = buffer;
cio->length = length; cio->length = length;
} }
else if(!buffer && !length && cinfo) { else if(!buffer && !length && cinfo) {
/* allocate a buffer for the encoded image */ /* allocate a buffer for the encoded image */
cio->openmode = OPJ_STREAM_WRITE; cio->openmode = OPJ_STREAM_WRITE;
switch(cinfo->codec_format) { switch(cinfo->codec_format) {
case CODEC_J3D: case CODEC_J3D:
case CODEC_J2K: case CODEC_J2K:
cp = ((opj_j3d_t*)cinfo->j3d_handle)->cp; cp = ((opj_j3d_t*)cinfo->j3d_handle)->cp;
break; break;
default: default:
opj_free(cio); opj_free(cio);
return NULL; return NULL;
} }
cio->length = cp->tdx * cp->tdy * cp->tdz * cp->tw * cp->th * cp->tl * 4; cio->length = cp->tdx * cp->tdy * cp->tdz * cp->tw * cp->th * cp->tl * 4;
cio->buffer = (unsigned char *)opj_malloc(cio->length); cio->buffer = (unsigned char *)opj_malloc(cio->length);
if(!cio->buffer) { if(!cio->buffer) {
opj_free(cio); opj_free(cio);
return NULL; return NULL;
} }
} }
else { else {
opj_free(cio); opj_free(cio);
return NULL; return NULL;
} }
/* Initialize byte IO */ /* Initialize byte IO */
cio->start = cio->buffer; cio->start = cio->buffer;
cio->end = cio->buffer + cio->length; cio->end = cio->buffer + cio->length;
cio->bp = cio->buffer; cio->bp = cio->buffer;
return cio; return cio;
} }
void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio) { void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio) {
if(cio) { if(cio) {
if(cio->openmode == OPJ_STREAM_WRITE) { if(cio->openmode == OPJ_STREAM_WRITE) {
/* destroy the allocated buffer */ /* destroy the allocated buffer */
opj_free(cio->buffer); opj_free(cio->buffer);
} }
/* destroy the cio */ /* destroy the cio */
opj_free(cio); opj_free(cio);
} }
} }
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/* /*
* Get position in byte stream. * Get position in byte stream.
*/ */
int OPJ_CALLCONV cio_tell(opj_cio_t *cio) { int OPJ_CALLCONV cio_tell(opj_cio_t *cio) {
return cio->bp - cio->start; return cio->bp - cio->start;
} }
/* /*
* Set position in byte stream. * Set position in byte stream.
* *
* pos : position, in number of bytes, from the beginning of the stream * pos : position, in number of bytes, from the beginning of the stream
*/ */
void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos) { void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos) {
cio->bp = cio->start + pos; cio->bp = cio->start + pos;
} }
/* /*
* Number of bytes left before the end of the stream. * Number of bytes left before the end of the stream.
*/ */
int cio_numbytesleft(opj_cio_t *cio) { int cio_numbytesleft(opj_cio_t *cio) {
return cio->end - cio->bp; return cio->end - cio->bp;
} }
/* /*
* Get pointer to the current position in the stream. * Get pointer to the current position in the stream.
*/ */
unsigned char *cio_getbp(opj_cio_t *cio) { unsigned char *cio_getbp(opj_cio_t *cio) {
return cio->bp; return cio->bp;
} }
/* /*
* Write a byte. * Write a byte.
*/ */
static bool cio_byteout(opj_cio_t *cio, unsigned char v) { static bool cio_byteout(opj_cio_t *cio, unsigned char v) {
if (cio->bp >= cio->end) { if (cio->bp >= cio->end) {
opj_event_msg(cio->cinfo, EVT_ERROR, "write error\n"); opj_event_msg(cio->cinfo, EVT_ERROR, "write error\n");
return false; return false;
} }
*cio->bp++ = v; *cio->bp++ = v;
return true; return true;
} }
/* /*
* Read a byte. * Read a byte.
*/ */
static unsigned char cio_bytein(opj_cio_t *cio) { static unsigned char cio_bytein(opj_cio_t *cio) {
if (cio->bp >= cio->end) { if (cio->bp >= cio->end) {
opj_event_msg(cio->cinfo, EVT_ERROR, "read error\n"); opj_event_msg(cio->cinfo, EVT_ERROR, "read error\n");
return 0; return 0;
} }
return *cio->bp++; return *cio->bp++;
} }
/* /*
* Write some bytes. * Write some bytes.
* *
* v : value to write * v : value to write
* n : number of bytes to write * n : number of bytes to write
*/ */
unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n) { unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n) {
int i; int i;
for (i = n - 1; i >= 0; i--) { for (i = n - 1; i >= 0; i--) {
if( !cio_byteout(cio, (unsigned char) ((v >> (i << 3)) & 0xff)) ) if( !cio_byteout(cio, (unsigned char) ((v >> (i << 3)) & 0xff)) )
return 0; return 0;
} }
return n; return n;
} }
/* /*
* Read some bytes. * Read some bytes.
* *
* n : number of bytes to read * n : number of bytes to read
* *
* return : value of the n bytes read * return : value of the n bytes read
*/ */
unsigned int cio_read(opj_cio_t *cio, int n) { unsigned int cio_read(opj_cio_t *cio, int n) {
int i; int i;
unsigned int v; unsigned int v;
v = 0; v = 0;
for (i = n - 1; i >= 0; i--) { for (i = n - 1; i >= 0; i--) {
v += cio_bytein(cio) << (i << 3); v += cio_bytein(cio) << (i << 3);
} }
return v; return v;
} }
/* /*
* Skip some bytes. * Skip some bytes.
* *
* n : number of bytes to skip * n : number of bytes to skip
*/ */
void cio_skip(opj_cio_t *cio, int n) { void cio_skip(opj_cio_t *cio, int n) {
cio->bp += n; cio->bp += n;
} }
/* /*
* Write some bytes. * Write some bytes.
* *
* v : value to write * v : value to write
* n : number of bytes to write * n : number of bytes to write
*/ */
int cio_write_int(opj_cio_t *cio, int v, int n) { int cio_write_int(opj_cio_t *cio, int v, int n) {
int i; int i;
for (i = n - 1; i >= 0; i--) { for (i = n - 1; i >= 0; i--) {
if( !cio_byteout(cio, (char) ((v >> (i << 3)) & 0xff)) ) if( !cio_byteout(cio, (char) ((v >> (i << 3)) & 0xff)) )
return 0; return 0;
} }
return n; return n;
} }
/* /*
* Read some bytes. * Read some bytes.
* *
* n : number of bytes to read * n : number of bytes to read
* *
* return : value of the n bytes read * return : value of the n bytes read
*/ */
int cio_read_int(opj_cio_t *cio, int n) { int cio_read_int(opj_cio_t *cio, int n) {
int i; int i;
int v; int v;
v = 0; v = 0;
for (i = n - 1; i >= 0; i--) { for (i = n - 1; i >= 0; i--) {
v += cio_bytein(cio) << (i << 3); v += cio_bytein(cio) << (i << 3);
} }
return v; return v;
} }

View File

@ -1,100 +1,100 @@
/* /*
* Copyright (c) 2001-2003, David Janssens * Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __CIO_H #ifndef __CIO_H
#define __CIO_H #define __CIO_H
/** /**
@file cio.h @file cio.h
@brief Implementation of a byte input-output process (CIO) @brief Implementation of a byte input-output process (CIO)
The functions in CIO.C have for goal to realize a byte input / output process. The functions in CIO.C have for goal to realize a byte input / output process.
*/ */
/** @defgroup CIO CIO - byte input-output stream */ /** @defgroup CIO CIO - byte input-output stream */
/*@{*/ /*@{*/
/** @name Funciones generales (see also openjp3d.h) */ /** @name Funciones generales (see also openjp3d.h) */
/*@{*/ /*@{*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Number of bytes left before the end of the stream Number of bytes left before the end of the stream
@param cio CIO handle @param cio CIO handle
@return Returns the number of bytes before the end of the stream @return Returns the number of bytes before the end of the stream
*/ */
int cio_numbytesleft(opj_cio_t *cio); int cio_numbytesleft(opj_cio_t *cio);
/** /**
Get pointer to the current position in the stream Get pointer to the current position in the stream
@param cio CIO handle @param cio CIO handle
@return Returns a pointer to the current position @return Returns a pointer to the current position
*/ */
unsigned char *cio_getbp(opj_cio_t *cio); unsigned char *cio_getbp(opj_cio_t *cio);
/** /**
Write some bytes Write some bytes
@param cio CIO handle @param cio CIO handle
@param v Value to write @param v Value to write
@param n Number of bytes to write @param n Number of bytes to write
@return Returns the number of bytes written or 0 if an error occured @return Returns the number of bytes written or 0 if an error occured
*/ */
unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n); unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n);
/** /**
Read some bytes Read some bytes
@param cio CIO handle @param cio CIO handle
@param n Number of bytes to read @param n Number of bytes to read
@return Returns the value of the n bytes read @return Returns the value of the n bytes read
*/ */
unsigned int cio_read(opj_cio_t *cio, int n); unsigned int cio_read(opj_cio_t *cio, int n);
/** /**
Skip some bytes Skip some bytes
@param cio CIO handle @param cio CIO handle
@param n Number of bytes to skip @param n Number of bytes to skip
*/ */
void cio_skip(opj_cio_t *cio, int n); void cio_skip(opj_cio_t *cio, int n);
/** /**
Write some bytes Write some bytes
@param cio CIO handle @param cio CIO handle
@param v Signed integer value to write @param v Signed integer value to write
@param n Number of bytes to write @param n Number of bytes to write
@return Returns the number of bytes written or 0 if an error occured @return Returns the number of bytes written or 0 if an error occured
*/ */
int cio_write_int(opj_cio_t *cio, int v, int n); int cio_write_int(opj_cio_t *cio, int v, int n);
/** /**
Read some bytes Read some bytes
@param cio CIO handle @param cio CIO handle
@param n Number of bytes to read @param n Number of bytes to read
@return Returns the value of the n bytes read @return Returns the value of the n bytes read
*/ */
int cio_read_int(opj_cio_t *cio, int n); int cio_read_int(opj_cio_t *cio, int n);
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/*@}*/ /*@}*/
/*@}*/ /*@}*/
#endif /* __CIO_H */ #endif /* __CIO_H */

View File

@ -1,101 +1,101 @@
/* /*
* Copyright (c) 2001-2003, David Janssens * Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
* Copyrigth (c) 2006, Mónica Díez, LPI-UVA, Spain * Copyrigth (c) 2006, Mónica Díez, LPI-UVA, Spain
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __DWT_H #ifndef __DWT_H
#define __DWT_H #define __DWT_H
/** /**
@file dwt.h @file dwt.h
@brief Implementation of a discrete wavelet transform (DWT) @brief Implementation of a discrete wavelet transform (DWT)
The functions in DWT.C have for goal to realize forward and inverse discret wavelet The functions in DWT.C have for goal to realize forward and inverse discret wavelet
transform with filter 5-3 (reversible) and filter 9-7 (irreversible). The functions in transform with filter 5-3 (reversible) and filter 9-7 (irreversible). The functions in
DWT.C are used by some function in TCD.C. DWT.C are used by some function in TCD.C.
*/ */
/** @defgroup DWT DWT - Implementation of a discrete wavelet transform */ /** @defgroup DWT DWT - Implementation of a discrete wavelet transform */
/*@{*/ /*@{*/
/** /**
DCCS-LIWT properties DCCS-LIWT properties
*/ */
typedef struct opj_wtfilt { typedef struct opj_wtfilt {
double *LPS; double *LPS;
int lenLPS; int lenLPS;
double *HPS; double *HPS;
int lenHPS; int lenHPS;
} opj_wtfilt_t; } opj_wtfilt_t;
/** @name Funciones generales */ /** @name Funciones generales */
/*@{*/ /*@{*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Forward 5-3 wavelet tranform in 3-D. Forward 5-3 wavelet tranform in 3-D.
Apply a reversible DWT transform to a component of an volume. Apply a reversible DWT transform to a component of an volume.
@param tilec Tile component information (current tile) @param tilec Tile component information (current tile)
@param dwtid Number of identification of wavelet kernel(s) used in DWT in each direction @param dwtid Number of identification of wavelet kernel(s) used in DWT in each direction
*/ */
void dwt_encode(opj_tcd_tilecomp_t * tilec, int dwtid[3]); void dwt_encode(opj_tcd_tilecomp_t * tilec, int dwtid[3]);
/** /**
Inverse 5-3 wavelet tranform in 3-D. Inverse 5-3 wavelet tranform in 3-D.
Apply a reversible inverse DWT transform to a component of an volume. Apply a reversible inverse DWT transform to a component of an volume.
@param tilec Tile component information (current tile) @param tilec Tile component information (current tile)
@param stops Number of decoded resolution levels in each dimension @param stops Number of decoded resolution levels in each dimension
@param dwtid Number of identification of wavelet kernel(s) used in DWT in each dimension @param dwtid Number of identification of wavelet kernel(s) used in DWT in each dimension
*/ */
void dwt_decode(opj_tcd_tilecomp_t * tilec, int stops[3], int dwtid[3]); void dwt_decode(opj_tcd_tilecomp_t * tilec, int stops[3], int dwtid[3]);
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Get the gain of a subband for the reversible 3-D DWT. Get the gain of a subband for the reversible 3-D DWT.
@param orient Number that identifies the subband (0->LLL, 1->HLL, 2->LHL, 3->HHL, 4->LLH, 5->HLH, 6->LHH, 7->HHH) @param orient Number that identifies the subband (0->LLL, 1->HLL, 2->LHL, 3->HHL, 4->LLH, 5->HLH, 6->LHH, 7->HHH)
@param reversible Wavelet transformation type @param reversible Wavelet transformation type
@return Returns 0 if orient = 0, returns 1 if orient = 1,2 or 4, returns 2 if orient = 3,5 or 6, returns 3 otherwise @return Returns 0 if orient = 0, returns 1 if orient = 1,2 or 4, returns 2 if orient = 3,5 or 6, returns 3 otherwise
*/ */
int dwt_getgain(int orient, int reversible); int dwt_getgain(int orient, int reversible);
/** /**
Get the norm of a wavelet function of a subband at a specified level for the reversible 5-3 DWT or irreversible 9-7 in 3-D. Get the norm of a wavelet function of a subband at a specified level for the reversible 5-3 DWT or irreversible 9-7 in 3-D.
@param orient Band of the wavelet function @param orient Band of the wavelet function
@param level Levels of the wavelet function in X,Y,Z axis @param level Levels of the wavelet function in X,Y,Z axis
@param dwtid Wavelet transformation identifier @param dwtid Wavelet transformation identifier
@return Returns the norm of the wavelet function @return Returns the norm of the wavelet function
*/ */
double dwt_getnorm(int orient, int level[3], int dwtid[3]); double dwt_getnorm(int orient, int level[3], int dwtid[3]);
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Calcula el valor del escalón de cuantificación correspondiente a cada subbanda. Calcula el valor del escalón de cuantificación correspondiente a cada subbanda.
@param tccp Tile component coding parameters @param tccp Tile component coding parameters
@param prec Precision of data @param prec Precision of data
*/ */
void dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, int prec); void dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, int prec);
/*@}*/ /*@}*/
/*@}*/ /*@}*/
#endif /* __DWT_H */ #endif /* __DWT_H */

View File

@ -1,181 +1,181 @@
/* /*
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "opj_includes.h" #include "opj_includes.h"
/* ========================================================== /* ==========================================================
// Utility functions // Utility functions
// ==========================================================*/ // ==========================================================*/
#ifndef _WIN32 #ifndef _WIN32
static char* static char*
i2a(unsigned i, char *a, unsigned r) { i2a(unsigned i, char *a, unsigned r) {
if (i/r > 0) a = i2a(i/r,a,r); if (i/r > 0) a = i2a(i/r,a,r);
*a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i%r]; *a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i%r];
return a+1; return a+1;
} }
/** /**
Transforms integer i into an ascii string and stores the result in a; Transforms integer i into an ascii string and stores the result in a;
string is encoded in the base indicated by r. string is encoded in the base indicated by r.
@param i Number to be converted @param i Number to be converted
@param a String result @param a String result
@param r Base of value; must be in the range 2 - 36 @param r Base of value; must be in the range 2 - 36
@return Returns a @return Returns a
*/ */
static char * static char *
_itoa(int i, char *a, int r) { _itoa(int i, char *a, int r) {
r = ((r < 2) || (r > 36)) ? 10 : r; r = ((r < 2) || (r > 36)) ? 10 : r;
if(i < 0) { if(i < 0) {
*a = '-'; *a = '-';
*i2a(-i, a+1, r) = 0; *i2a(-i, a+1, r) = 0;
} }
else *i2a(i, a, r) = 0; else *i2a(i, a, r) = 0;
return a; return a;
} }
#endif /* !_WIN32 */ #endif /* !_WIN32 */
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context) { opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context) {
if(cinfo) { if(cinfo) {
opj_event_mgr_t *previous = cinfo->event_mgr; opj_event_mgr_t *previous = cinfo->event_mgr;
cinfo->event_mgr = event_mgr; cinfo->event_mgr = event_mgr;
cinfo->client_data = context; cinfo->client_data = context;
return previous; return previous;
} }
return NULL; return NULL;
} }
bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) { bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
#define MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */ #define MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */
opj_msg_callback msg_handler = NULL; opj_msg_callback msg_handler = NULL;
opj_event_mgr_t *event_mgr = cinfo->event_mgr; opj_event_mgr_t *event_mgr = cinfo->event_mgr;
if(event_mgr != NULL) { if(event_mgr != NULL) {
switch(event_type) { switch(event_type) {
case EVT_ERROR: case EVT_ERROR:
msg_handler = event_mgr->error_handler; msg_handler = event_mgr->error_handler;
break; break;
case EVT_WARNING: case EVT_WARNING:
msg_handler = event_mgr->warning_handler; msg_handler = event_mgr->warning_handler;
break; break;
case EVT_INFO: case EVT_INFO:
msg_handler = event_mgr->info_handler; msg_handler = event_mgr->info_handler;
break; break;
default: default:
break; break;
} }
if(msg_handler == NULL) { if(msg_handler == NULL) {
return false; return false;
} }
} else { } else {
return false; return false;
} }
if ((fmt != NULL) && (event_mgr != NULL)) { if ((fmt != NULL) && (event_mgr != NULL)) {
va_list arg; va_list arg;
int str_length, i, j; int str_length, i, j;
char message[MSG_SIZE]; char message[MSG_SIZE];
memset(message, 0, MSG_SIZE); memset(message, 0, MSG_SIZE);
/* initialize the optional parameter list */ /* initialize the optional parameter list */
va_start(arg, fmt); va_start(arg, fmt);
/* check the length of the format string */ /* check the length of the format string */
str_length = (strlen(fmt) > MSG_SIZE) ? MSG_SIZE : strlen(fmt); str_length = (strlen(fmt) > MSG_SIZE) ? MSG_SIZE : strlen(fmt);
/* parse the format string and put the result in 'message' */ /* parse the format string and put the result in 'message' */
for (i = 0, j = 0; i < str_length; ++i) { for (i = 0, j = 0; i < str_length; ++i) {
if (fmt[i] == '%') { if (fmt[i] == '%') {
if (i + 1 < str_length) { if (i + 1 < str_length) {
switch(tolower(fmt[i + 1])) { switch(tolower(fmt[i + 1])) {
case '%' : case '%' :
message[j++] = '%'; message[j++] = '%';
break; break;
case 'o' : /* octal numbers */ case 'o' : /* octal numbers */
{ {
char tmp[16]; char tmp[16];
_itoa(va_arg(arg, int), tmp, 8); _itoa(va_arg(arg, int), tmp, 8);
strcat(message, tmp); strcat(message, tmp);
j += strlen(tmp); j += strlen(tmp);
++i; ++i;
break; break;
} }
case 'i' : /* decimal numbers */ case 'i' : /* decimal numbers */
case 'd' : case 'd' :
{ {
char tmp[16]; char tmp[16];
_itoa(va_arg(arg, int), tmp, 10); _itoa(va_arg(arg, int), tmp, 10);
strcat(message, tmp); strcat(message, tmp);
j += strlen(tmp); j += strlen(tmp);
++i; ++i;
break; break;
} }
case 'x' : /* hexadecimal numbers */ case 'x' : /* hexadecimal numbers */
{ {
char tmp[16]; char tmp[16];
_itoa(va_arg(arg, int), tmp, 16); _itoa(va_arg(arg, int), tmp, 16);
strcat(message, tmp); strcat(message, tmp);
j += strlen(tmp); j += strlen(tmp);
++i; ++i;
break; break;
} }
case 's' : /* strings */ case 's' : /* strings */
{ {
char *tmp = va_arg(arg, char*); char *tmp = va_arg(arg, char*);
strcat(message, tmp); strcat(message, tmp);
j += strlen(tmp); j += strlen(tmp);
++i; ++i;
break; break;
} }
case 'f' : /* floats */ case 'f' : /* floats */
{ {
char tmp[16]; char tmp[16];
double value = va_arg(arg, double); double value = va_arg(arg, double);
sprintf(tmp, "%f", value); sprintf(tmp, "%f", value);
strcat(message, tmp); strcat(message, tmp);
j += strlen(tmp); j += strlen(tmp);
++i; ++i;
break; break;
} }
}; };
} else { } else {
message[j++] = fmt[i]; message[j++] = fmt[i];
} }
} else { } else {
message[j++] = fmt[i]; message[j++] = fmt[i];
}; };
} }
/* deinitialize the optional parameter list */ /* deinitialize the optional parameter list */
va_end(arg); va_end(arg);
/* output the message to the user program */ /* output the message to the user program */
msg_handler(message, cinfo->client_data); msg_handler(message, cinfo->client_data);
} }
return true; return true;
} }

View File

@ -1,58 +1,58 @@
/* /*
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __EVENT_H #ifndef __EVENT_H
#define __EVENT_H #define __EVENT_H
/** /**
@file event.h @file event.h
@brief Implementation of a event callback system @brief Implementation of a event callback system
The functions in EVENT.C have for goal to send output messages (errors, warnings, debug) to the user. The functions in EVENT.C have for goal to send output messages (errors, warnings, debug) to the user.
*/ */
#define EVT_ERROR 1 /**< Error event type */ #define EVT_ERROR 1 /**< Error event type */
#define EVT_WARNING 2 /**< Warning event type */ #define EVT_WARNING 2 /**< Warning event type */
#define EVT_INFO 4 /**< Debug event type */ #define EVT_INFO 4 /**< Debug event type */
/** @defgroup EVENT EVENT - Implementation of a event callback system */ /** @defgroup EVENT EVENT - Implementation of a event callback system */
/*@{*/ /*@{*/
/** @name Funciones generales (see also openjp3d.h) */ /** @name Funciones generales (see also openjp3d.h) */
/*@{*/ /*@{*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Write formatted data to a string and send the string to a user callback. Write formatted data to a string and send the string to a user callback.
@param cinfo Codec context info @param cinfo Codec context info
@param event_type Event type or callback to use to send the message @param event_type Event type or callback to use to send the message
@param fmt Format-control string (plus optionnal arguments) @param fmt Format-control string (plus optionnal arguments)
@return Returns true if successful, returns false otherwise @return Returns true if successful, returns false otherwise
*/ */
bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...); bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...);
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/*@}*/ /*@}*/
/*@}*/ /*@}*/
#endif /* __EVENT_H */ #endif /* __EVENT_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,76 +1,76 @@
/* /*
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#else #else
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/times.h> #include <sys/times.h>
#endif /* _WIN32 */ #endif /* _WIN32 */
#include "opj_includes.h" #include "opj_includes.h"
double opj_clock() { double opj_clock() {
#ifdef _WIN32 #ifdef _WIN32
/* WIN32: use QueryPerformance (very accurate) */ /* WIN32: use QueryPerformance (very accurate) */
LARGE_INTEGER freq , t ; LARGE_INTEGER freq , t ;
/* freq is the clock speed of the CPU */ /* freq is the clock speed of the CPU */
QueryPerformanceFrequency(&freq) ; QueryPerformanceFrequency(&freq) ;
/* cout << "freq = " << ((double) freq.QuadPart) << endl; */ /* cout << "freq = " << ((double) freq.QuadPart) << endl; */
/* t is the high resolution performance counter (see MSDN) */ /* t is the high resolution performance counter (see MSDN) */
QueryPerformanceCounter ( & t ) ; QueryPerformanceCounter ( & t ) ;
return ( t.QuadPart /(double) freq.QuadPart ) ; return ( t.QuadPart /(double) freq.QuadPart ) ;
#else #else
/* Unix or Linux: use resource usage */ /* Unix or Linux: use resource usage */
struct rusage t; struct rusage t;
double procTime; double procTime;
/* (1) Get the rusage data structure at this moment (man getrusage) */ /* (1) Get the rusage data structure at this moment (man getrusage) */
getrusage(0,&t); getrusage(0,&t);
/* (2) What is the elapsed time ? - CPU time = User time + System time */ /* (2) What is the elapsed time ? - CPU time = User time + System time */
/* (2a) Get the seconds */ /* (2a) Get the seconds */
procTime = t.ru_utime.tv_sec + t.ru_stime.tv_sec; procTime = t.ru_utime.tv_sec + t.ru_stime.tv_sec;
/* (2b) More precisely! Get the microseconds part ! */ /* (2b) More precisely! Get the microseconds part ! */
return ( procTime + (t.ru_utime.tv_usec + t.ru_stime.tv_usec) * 1e-6 ) ; return ( procTime + (t.ru_utime.tv_usec + t.ru_stime.tv_usec) * 1e-6 ) ;
#endif /* _WIN32 */ #endif /* _WIN32 */
} }
void* opj_malloc( size_t size ) { void* opj_malloc( size_t size ) {
void *memblock = malloc(size); void *memblock = malloc(size);
if(memblock) { if(memblock) {
memset(memblock, 0, size); memset(memblock, 0, size);
} }
return memblock; return memblock;
} }
void* opj_realloc( void *memblock, size_t size ) { void* opj_realloc( void *memblock, size_t size ) {
return realloc(memblock, size); return realloc(memblock, size);
} }
void opj_free( void *memblock ) { void opj_free( void *memblock ) {
free(memblock); free(memblock);
} }

View File

@ -1,75 +1,75 @@
/* /*
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __J3D_LIB_H #ifndef __J3D_LIB_H
#define __J3D_LIB_H #define __J3D_LIB_H
/** /**
@file jp3d_lib.h @file jp3d_lib.h
@brief Internal functions @brief Internal functions
The functions in JP3D_LIB.C are internal utilities mainly used for memory management. The functions in JP3D_LIB.C are internal utilities mainly used for memory management.
*/ */
/** @defgroup MISC MISC - Miscellaneous internal functions */ /** @defgroup MISC MISC - Miscellaneous internal functions */
/*@{*/ /*@{*/
/** @name Funciones generales */ /** @name Funciones generales */
/*@{*/ /*@{*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Difference in successive opj_clock() calls tells you the elapsed time Difference in successive opj_clock() calls tells you the elapsed time
@return Returns time in seconds @return Returns time in seconds
*/ */
double opj_clock(void); double opj_clock(void);
/** /**
Allocate a memory block with elements initialized to 0 Allocate a memory block with elements initialized to 0
@param size Bytes to allocate @param size Bytes to allocate
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available @return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
*/ */
void* opj_malloc( size_t size ); void* opj_malloc( size_t size );
/** /**
Reallocate memory blocks. Reallocate memory blocks.
@param memblock Pointer to previously allocated memory block @param memblock Pointer to previously allocated memory block
@param size New size in bytes @param size New size in bytes
@return Returns a void pointer to the reallocated (and possibly moved) memory block @return Returns a void pointer to the reallocated (and possibly moved) memory block
*/ */
void* opj_realloc( void *memblock, size_t size ); void* opj_realloc( void *memblock, size_t size );
/** /**
Deallocates or frees a memory block. Deallocates or frees a memory block.
@param memblock Previously allocated memory block to be freed @param memblock Previously allocated memory block to be freed
*/ */
void opj_free( void *memblock ); void opj_free( void *memblock );
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/*@}*/ /*@}*/
/*@}*/ /*@}*/
#endif /* __J3D_LIB_H */ #endif /* __J3D_LIB_H */

View File

@ -1,131 +1,131 @@
/* /*
* Copyright (c) 2001-2003, David Janssens * Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "opj_includes.h" #include "opj_includes.h"
/* <summary> */ /* <summary> */
/* This table contains the norms of the basis function of the reversible MCT. */ /* This table contains the norms of the basis function of the reversible MCT. */
/* </summary> */ /* </summary> */
static const double mct_norms[3] = { 1.732, .8292, .8292 }; static const double mct_norms[3] = { 1.732, .8292, .8292 };
/* <summary> */ /* <summary> */
/* This table contains the norms of the basis function of the irreversible MCT. */ /* This table contains the norms of the basis function of the irreversible MCT. */
/* </summary> */ /* </summary> */
static const double mct_norms_real[3] = { 1.732, 1.805, 1.573 }; static const double mct_norms_real[3] = { 1.732, 1.805, 1.573 };
/* <summary> */ /* <summary> */
/* Foward reversible MCT. */ /* Foward reversible MCT. */
/* </summary> */ /* </summary> */
void mct_encode(int *c0, int *c1, int *c2, int n) { void mct_encode(int *c0, int *c1, int *c2, int n) {
int i; int i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
int r, g, b, y, u, v; int r, g, b, y, u, v;
r = c0[i]; r = c0[i];
g = c1[i]; g = c1[i];
b = c2[i]; b = c2[i];
y = (r + (g << 1) + b) >> 2; y = (r + (g << 1) + b) >> 2;
u = b - g; u = b - g;
v = r - g; v = r - g;
c0[i] = y; c0[i] = y;
c1[i] = u; c1[i] = u;
c2[i] = v; c2[i] = v;
} }
} }
/* <summary> */ /* <summary> */
/* Inverse reversible MCT. */ /* Inverse reversible MCT. */
/* </summary> */ /* </summary> */
void mct_decode(int *c0, int *c1, int *c2, int n) { void mct_decode(int *c0, int *c1, int *c2, int n) {
int i; int i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
int y, u, v, r, g, b; int y, u, v, r, g, b;
y = c0[i]; y = c0[i];
u = c1[i]; u = c1[i];
v = c2[i]; v = c2[i];
g = y - ((u + v) >> 2); g = y - ((u + v) >> 2);
r = v + g; r = v + g;
b = u + g; b = u + g;
c0[i] = r; c0[i] = r;
c1[i] = g; c1[i] = g;
c2[i] = b; c2[i] = b;
} }
} }
/* <summary> */ /* <summary> */
/* Get norm of basis function of reversible MCT. */ /* Get norm of basis function of reversible MCT. */
/* </summary> */ /* </summary> */
double mct_getnorm(int compno) { double mct_getnorm(int compno) {
return mct_norms[compno]; return mct_norms[compno];
} }
/* <summary> */ /* <summary> */
/* Foward irreversible MCT. */ /* Foward irreversible MCT. */
/* </summary> */ /* </summary> */
void mct_encode_real(int *c0, int *c1, int *c2, int n) { void mct_encode_real(int *c0, int *c1, int *c2, int n) {
int i; int i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
int r, g, b, y, u, v; int r, g, b, y, u, v;
r = c0[i]; r = c0[i];
g = c1[i]; g = c1[i];
b = c2[i]; b = c2[i];
y = fix_mul(r, 2449) + fix_mul(g, 4809) + fix_mul(b, 934); y = fix_mul(r, 2449) + fix_mul(g, 4809) + fix_mul(b, 934);
u = -fix_mul(r, 1382) - fix_mul(g, 2714) + fix_mul(b, 4096); u = -fix_mul(r, 1382) - fix_mul(g, 2714) + fix_mul(b, 4096);
v = fix_mul(r, 4096) - fix_mul(g, 3430) - fix_mul(b, 666); v = fix_mul(r, 4096) - fix_mul(g, 3430) - fix_mul(b, 666);
c0[i] = y; c0[i] = y;
c1[i] = u; c1[i] = u;
c2[i] = v; c2[i] = v;
} }
} }
/* <summary> */ /* <summary> */
/* Inverse irreversible MCT. */ /* Inverse irreversible MCT. */
/* </summary> */ /* </summary> */
void mct_decode_real(int *c0, int *c1, int *c2, int n) { void mct_decode_real(int *c0, int *c1, int *c2, int n) {
int i; int i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
int y, u, v, r, g, b; int y, u, v, r, g, b;
y = c0[i]; y = c0[i];
u = c1[i]; u = c1[i];
v = c2[i]; v = c2[i];
r = y + fix_mul(v, 11485); r = y + fix_mul(v, 11485);
g = y - fix_mul(u, 2819) - fix_mul(v, 5850); g = y - fix_mul(u, 2819) - fix_mul(v, 5850);
b = y + fix_mul(u, 14516); b = y + fix_mul(u, 14516);
c0[i] = r; c0[i] = r;
c1[i] = g; c1[i] = g;
c2[i] = b; c2[i] = b;
} }
} }
/* <summary> */ /* <summary> */
/* Get norm of basis function of irreversible MCT. */ /* Get norm of basis function of irreversible MCT. */
/* </summary> */ /* </summary> */
double mct_getnorm_real(int compno) { double mct_getnorm_real(int compno) {
return mct_norms_real[compno]; return mct_norms_real[compno];
} }

View File

@ -1,97 +1,97 @@
/* /*
* Copyright (c) 2001-2003, David Janssens * Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __MCT_H #ifndef __MCT_H
#define __MCT_H #define __MCT_H
/** /**
@file mct.h @file mct.h
@brief Implementation of a multi-component transforms (MCT) @brief Implementation of a multi-component transforms (MCT)
The functions in MCT.C have for goal to realize reversible and irreversible multicomponent The functions in MCT.C have for goal to realize reversible and irreversible multicomponent
transform. The functions in MCT.C are used by some function in TCD.C. transform. The functions in MCT.C are used by some function in TCD.C.
*/ */
/** @defgroup MCT MCT - Implementation of a multi-component transform */ /** @defgroup MCT MCT - Implementation of a multi-component transform */
/*@{*/ /*@{*/
/** @name Funciones generales */ /** @name Funciones generales */
/*@{*/ /*@{*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Apply a reversible multi-component transform to an image Apply a reversible multi-component transform to an image
@param c0 Samples for red component @param c0 Samples for red component
@param c1 Samples for green component @param c1 Samples for green component
@param c2 Samples blue component @param c2 Samples blue component
@param n Number of samples for each component @param n Number of samples for each component
*/ */
void mct_encode(int *c0, int *c1, int *c2, int n); void mct_encode(int *c0, int *c1, int *c2, int n);
/** /**
Apply a reversible multi-component inverse transform to an image Apply a reversible multi-component inverse transform to an image
@param c0 Samples for luminance component @param c0 Samples for luminance component
@param c1 Samples for red chrominance component @param c1 Samples for red chrominance component
@param c2 Samples for blue chrominance component @param c2 Samples for blue chrominance component
@param n Number of samples for each component @param n Number of samples for each component
*/ */
void mct_decode(int *c0, int *c1, int *c2, int n); void mct_decode(int *c0, int *c1, int *c2, int n);
/** /**
Get norm of the basis function used for the reversible multi-component transform Get norm of the basis function used for the reversible multi-component transform
@param compno Number of the component (0->Y, 1->U, 2->V) @param compno Number of the component (0->Y, 1->U, 2->V)
@return @return
*/ */
double mct_getnorm(int compno); double mct_getnorm(int compno);
/** /**
Apply an irreversible multi-component transform to an image Apply an irreversible multi-component transform to an image
@param c0 Samples for red component @param c0 Samples for red component
@param c1 Samples for green component @param c1 Samples for green component
@param c2 Samples blue component @param c2 Samples blue component
@param n Number of samples for each component @param n Number of samples for each component
*/ */
void mct_encode_real(int *c0, int *c1, int *c2, int n); void mct_encode_real(int *c0, int *c1, int *c2, int n);
/** /**
Apply an irreversible multi-component inverse transform to an image Apply an irreversible multi-component inverse transform to an image
@param c0 Samples for luminance component @param c0 Samples for luminance component
@param c1 Samples for red chrominance component @param c1 Samples for red chrominance component
@param c2 Samples for blue chrominance component @param c2 Samples for blue chrominance component
@param n Number of samples for each component @param n Number of samples for each component
*/ */
void mct_decode_real(int *c0, int *c1, int *c2, int n); void mct_decode_real(int *c0, int *c1, int *c2, int n);
/** /**
Get norm of the basis function used for the irreversible multi-component transform Get norm of the basis function used for the irreversible multi-component transform
@param compno Number of the component (0->Y, 1->U, 2->V) @param compno Number of the component (0->Y, 1->U, 2->V)
@return @return
*/ */
double mct_getnorm_real(int compno); double mct_getnorm_real(int compno);
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/*@}*/ /*@}*/
/*@}*/ /*@}*/
#endif /* __MCT_H */ #endif /* __MCT_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,201 +1,201 @@
/* /*
* Copyright (c) 2001-2003, David Janssens * Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __MQC_H #ifndef __MQC_H
#define __MQC_H #define __MQC_H
/** /**
@file mqc.h @file mqc.h
@brief Implementation of an MQ-Coder (MQC) @brief Implementation of an MQ-Coder (MQC)
The functions in MQC.C have for goal to realize the MQ-coder operations. The functions The functions in MQC.C have for goal to realize the MQ-coder operations. The functions
in MQC.C are used by some function in T1.C. in MQC.C are used by some function in T1.C.
*/ */
/** @defgroup MQC MQC - Implementation of an MQ-Coder */ /** @defgroup MQC MQC - Implementation of an MQ-Coder */
/*@{*/ /*@{*/
/** /**
This struct defines the state of a context. This struct defines the state of a context.
*/ */
typedef struct opj_mqc_state { typedef struct opj_mqc_state {
/** the probability of the Least Probable Symbol (0.75->0x8000, 1.5->0xffff) */ /** the probability of the Least Probable Symbol (0.75->0x8000, 1.5->0xffff) */
unsigned int qeval; unsigned int qeval;
/** the Most Probable Symbol (0 or 1) */ /** the Most Probable Symbol (0 or 1) */
int mps; int mps;
/** next state if the next encoded symbol is the MPS */ /** next state if the next encoded symbol is the MPS */
struct opj_mqc_state *nmps; struct opj_mqc_state *nmps;
/** next state if the next encoded symbol is the LPS */ /** next state if the next encoded symbol is the LPS */
struct opj_mqc_state *nlps; struct opj_mqc_state *nlps;
} opj_mqc_state_t; } opj_mqc_state_t;
#define MQC_NUMCTXS 32 #define MQC_NUMCTXS 32
/** /**
MQ coder MQ coder
*/ */
typedef struct opj_mqc { typedef struct opj_mqc {
unsigned int c; unsigned int c;
unsigned int a; unsigned int a;
unsigned int ct; unsigned int ct;
unsigned char *bp; unsigned char *bp;
unsigned char *start; unsigned char *start;
unsigned char *end; unsigned char *end;
opj_mqc_state_t *ctxs[MQC_NUMCTXS]; opj_mqc_state_t *ctxs[MQC_NUMCTXS];
opj_mqc_state_t **curctx; opj_mqc_state_t **curctx;
} opj_mqc_t; } opj_mqc_t;
/** @name Exported functions */ /** @name Exported functions */
/*@{*/ /*@{*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Create a new MQC handle Create a new MQC handle
@return Returns a new MQC handle if successful, returns NULL otherwise @return Returns a new MQC handle if successful, returns NULL otherwise
*/ */
opj_mqc_t* mqc_create(void); opj_mqc_t* mqc_create(void);
/** /**
Destroy a previously created MQC handle Destroy a previously created MQC handle
@param mqc MQC handle to destroy @param mqc MQC handle to destroy
*/ */
void mqc_destroy(opj_mqc_t *mqc); void mqc_destroy(opj_mqc_t *mqc);
/** /**
Return the number of bytes written/read since initialisation Return the number of bytes written/read since initialisation
@param mqc MQC handle @param mqc MQC handle
@return Returns the number of bytes already encoded @return Returns the number of bytes already encoded
*/ */
int mqc_numbytes(opj_mqc_t *mqc); int mqc_numbytes(opj_mqc_t *mqc);
/** /**
Reset the states of all the context of the coder/decoder Reset the states of all the context of the coder/decoder
(each context is set to a state where 0 and 1 are more or less equiprobable) (each context is set to a state where 0 and 1 are more or less equiprobable)
@param mqc MQC handle @param mqc MQC handle
*/ */
void mqc_resetstates(opj_mqc_t *mqc); void mqc_resetstates(opj_mqc_t *mqc);
/** /**
Set the state of a particular context Set the state of a particular context
@param mqc MQC handle @param mqc MQC handle
@param ctxno Number that identifies the context @param ctxno Number that identifies the context
@param msb The MSB of the new state of the context @param msb The MSB of the new state of the context
@param prob Number that identifies the probability of the symbols for the new state of the context @param prob Number that identifies the probability of the symbols for the new state of the context
*/ */
void mqc_setstate(opj_mqc_t *mqc, int ctxno, int msb, int prob); void mqc_setstate(opj_mqc_t *mqc, int ctxno, int msb, int prob);
/** /**
Initialize the encoder Initialize the encoder
@param mqc MQC handle @param mqc MQC handle
@param bp Pointer to the start of the buffer where the bytes will be written @param bp Pointer to the start of the buffer where the bytes will be written
*/ */
void mqc_init_enc(opj_mqc_t *mqc, unsigned char *bp); void mqc_init_enc(opj_mqc_t *mqc, unsigned char *bp);
/** /**
Set the current context used for coding/decoding Set the current context used for coding/decoding
@param mqc MQC handle @param mqc MQC handle
@param ctxno Number that identifies the context @param ctxno Number that identifies the context
*/ */
void mqc_setcurctx(opj_mqc_t *mqc, int ctxno); void mqc_setcurctx(opj_mqc_t *mqc, int ctxno);
/** /**
Encode a symbol using the MQ-coder Encode a symbol using the MQ-coder
@param mqc MQC handle @param mqc MQC handle
@param d The symbol to be encoded (0 or 1) @param d The symbol to be encoded (0 or 1)
*/ */
void mqc_encode(opj_mqc_t *mqc, int d); void mqc_encode(opj_mqc_t *mqc, int d);
/** /**
Flush the encoder, so that all remaining data is written Flush the encoder, so that all remaining data is written
@param mqc MQC handle @param mqc MQC handle
*/ */
void mqc_flush(opj_mqc_t *mqc); void mqc_flush(opj_mqc_t *mqc);
/** /**
BYPASS mode switch, initialization operation. BYPASS mode switch, initialization operation.
JPEG 2000 p 505. JPEG 2000 p 505.
<h2>Not fully implemented and tested !!</h2> <h2>Not fully implemented and tested !!</h2>
@param mqc MQC handle @param mqc MQC handle
*/ */
void mqc_bypass_init_enc(opj_mqc_t *mqc); void mqc_bypass_init_enc(opj_mqc_t *mqc);
/** /**
BYPASS mode switch, coding operation. BYPASS mode switch, coding operation.
JPEG 2000 p 505. JPEG 2000 p 505.
<h2>Not fully implemented and tested !!</h2> <h2>Not fully implemented and tested !!</h2>
@param mqc MQC handle @param mqc MQC handle
@param d The symbol to be encoded (0 or 1) @param d The symbol to be encoded (0 or 1)
*/ */
void mqc_bypass_enc(opj_mqc_t *mqc, int d); void mqc_bypass_enc(opj_mqc_t *mqc, int d);
/** /**
BYPASS mode switch, flush operation BYPASS mode switch, flush operation
<h2>Not fully implemented and tested !!</h2> <h2>Not fully implemented and tested !!</h2>
@param mqc MQC handle @param mqc MQC handle
@return Returns 1 (always) @return Returns 1 (always)
*/ */
int mqc_bypass_flush_enc(opj_mqc_t *mqc); int mqc_bypass_flush_enc(opj_mqc_t *mqc);
/** /**
RESET mode switch RESET mode switch
@param mqc MQC handle @param mqc MQC handle
*/ */
void mqc_reset_enc(opj_mqc_t *mqc); void mqc_reset_enc(opj_mqc_t *mqc);
/** /**
RESET mode switch RESET mode switch
@param mqc MQC handle @param mqc MQC handle
*/ */
void mqc_reset_enc_3(opj_mqc_t *mqc); void mqc_reset_enc_3(opj_mqc_t *mqc);
/** /**
RESTART mode switch (TERMALL) RESTART mode switch (TERMALL)
@param mqc MQC handle @param mqc MQC handle
@return Returns 1 (always) @return Returns 1 (always)
*/ */
int mqc_restart_enc(opj_mqc_t *mqc); int mqc_restart_enc(opj_mqc_t *mqc);
/** /**
RESTART mode switch (TERMALL) reinitialisation RESTART mode switch (TERMALL) reinitialisation
@param mqc MQC handle @param mqc MQC handle
*/ */
void mqc_restart_init_enc(opj_mqc_t *mqc); void mqc_restart_init_enc(opj_mqc_t *mqc);
/** /**
ERTERM mode switch (PTERM) ERTERM mode switch (PTERM)
@param mqc MQC handle @param mqc MQC handle
*/ */
void mqc_erterm_enc(opj_mqc_t *mqc); void mqc_erterm_enc(opj_mqc_t *mqc);
/** /**
SEGMARK mode switch (SEGSYM) SEGMARK mode switch (SEGSYM)
@param mqc MQC handle @param mqc MQC handle
*/ */
void mqc_segmark_enc(opj_mqc_t *mqc); void mqc_segmark_enc(opj_mqc_t *mqc);
/** /**
Initialize the decoder Initialize the decoder
@param mqc MQC handle @param mqc MQC handle
@param bp Pointer to the start of the buffer from which the bytes will be read @param bp Pointer to the start of the buffer from which the bytes will be read
@param len Length of the input buffer @param len Length of the input buffer
*/ */
void mqc_init_dec(opj_mqc_t *mqc, unsigned char *bp, int len); void mqc_init_dec(opj_mqc_t *mqc, unsigned char *bp, int len);
/** /**
Decode a symbol Decode a symbol
@param mqc MQC handle @param mqc MQC handle
@return Returns the decoded symbol (0 or 1) @return Returns the decoded symbol (0 or 1)
*/ */
int mqc_decode(opj_mqc_t *mqc); int mqc_decode(opj_mqc_t *mqc);
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/*@}*/ /*@}*/
/*@}*/ /*@}*/
#endif /* __MQC_H */ #endif /* __MQC_H */

View File

@ -1,208 +1,208 @@
/* /*
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2006, Mónica Díez García, Image Processing Laboratory, University of Valladolid, Spain * Copyright (c) 2006, Mónica Díez García, Image Processing Laboratory, University of Valladolid, Spain
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#endif /* _WIN32 */ #endif /* _WIN32 */
#include "opj_includes.h" #include "opj_includes.h"
#include "openjp3d.h" #include "openjp3d.h"
#define JP3D_VERSION "1.3.0" #define JP3D_VERSION "1.3.0"
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
#ifdef _WIN32 #ifdef _WIN32
#ifndef OPJ_STATIC #ifndef OPJ_STATIC
BOOL APIENTRY BOOL APIENTRY
DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
switch (ul_reason_for_call) { switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH : case DLL_PROCESS_ATTACH :
break; break;
case DLL_PROCESS_DETACH : case DLL_PROCESS_DETACH :
break; break;
case DLL_THREAD_ATTACH : case DLL_THREAD_ATTACH :
case DLL_THREAD_DETACH : case DLL_THREAD_DETACH :
break; break;
} }
return TRUE; return TRUE;
} }
#endif /* OPJ_STATIC */ #endif /* OPJ_STATIC */
#endif /* _WIN32 */ #endif /* _WIN32 */
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
const char* OPJ_CALLCONV opj_version() { const char* OPJ_CALLCONV opj_version() {
return JP3D_VERSION; return JP3D_VERSION;
} }
opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) { opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) {
opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_malloc(sizeof(opj_dinfo_t)); opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_malloc(sizeof(opj_dinfo_t));
if(!dinfo) return NULL; if(!dinfo) return NULL;
dinfo->is_decompressor = true; dinfo->is_decompressor = true;
switch(format) { switch(format) {
case CODEC_J3D: case CODEC_J3D:
case CODEC_J2K: case CODEC_J2K:
/* get a J3D decoder handle */ /* get a J3D decoder handle */
dinfo->j3d_handle = (void*)j3d_create_decompress((opj_common_ptr)dinfo); dinfo->j3d_handle = (void*)j3d_create_decompress((opj_common_ptr)dinfo);
if(!dinfo->j3d_handle) { if(!dinfo->j3d_handle) {
opj_free(dinfo); opj_free(dinfo);
return NULL; return NULL;
} }
break; break;
default: default:
opj_free(dinfo); opj_free(dinfo);
return NULL; return NULL;
} }
dinfo->codec_format = format; dinfo->codec_format = format;
return dinfo; return dinfo;
} }
void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo) { void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo) {
if(dinfo) { if(dinfo) {
/* destroy the codec */ /* destroy the codec */
if(dinfo->codec_format != CODEC_UNKNOWN) { if(dinfo->codec_format != CODEC_UNKNOWN) {
j3d_destroy_decompress((opj_j3d_t*)dinfo->j3d_handle); j3d_destroy_decompress((opj_j3d_t*)dinfo->j3d_handle);
} }
/* destroy the decompressor */ /* destroy the decompressor */
opj_free(dinfo); opj_free(dinfo);
} }
} }
void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters) { void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters) {
if(parameters) { if(parameters) {
memset(parameters, 0, sizeof(opj_dparameters_t)); memset(parameters, 0, sizeof(opj_dparameters_t));
/* default decoding parameters */ /* default decoding parameters */
parameters->cp_layer = 0; parameters->cp_layer = 0;
parameters->cp_reduce[0] = 0; parameters->cp_reduce[0] = 0;
parameters->cp_reduce[1] = 0; parameters->cp_reduce[1] = 0;
parameters->cp_reduce[2] = 0; parameters->cp_reduce[2] = 0;
parameters->bigendian = 0; parameters->bigendian = 0;
parameters->decod_format = -1; parameters->decod_format = -1;
parameters->cod_format = -1; parameters->cod_format = -1;
} }
} }
void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters) { void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters) {
if(dinfo && parameters) { if(dinfo && parameters) {
if (dinfo->codec_format != CODEC_UNKNOWN) { if (dinfo->codec_format != CODEC_UNKNOWN) {
j3d_setup_decoder((opj_j3d_t*)dinfo->j3d_handle, parameters); j3d_setup_decoder((opj_j3d_t*)dinfo->j3d_handle, parameters);
} }
} }
} }
opj_volume_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio) { opj_volume_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio) {
if(dinfo && cio) { if(dinfo && cio) {
if (dinfo->codec_format != CODEC_UNKNOWN) { if (dinfo->codec_format != CODEC_UNKNOWN) {
return j3d_decode((opj_j3d_t*)dinfo->j3d_handle, cio); return j3d_decode((opj_j3d_t*)dinfo->j3d_handle, cio);
} }
} }
return NULL; return NULL;
} }
opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) { opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) {
opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_malloc(sizeof(opj_cinfo_t)); opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_malloc(sizeof(opj_cinfo_t));
if(!cinfo) return NULL; if(!cinfo) return NULL;
cinfo->is_decompressor = false; cinfo->is_decompressor = false;
switch(format) { switch(format) {
case CODEC_J3D: case CODEC_J3D:
case CODEC_J2K: case CODEC_J2K:
/* get a J3D coder handle */ /* get a J3D coder handle */
cinfo->j3d_handle = (void*)j3d_create_compress((opj_common_ptr)cinfo); cinfo->j3d_handle = (void*)j3d_create_compress((opj_common_ptr)cinfo);
if(!cinfo->j3d_handle) { if(!cinfo->j3d_handle) {
opj_free(cinfo); opj_free(cinfo);
return NULL; return NULL;
} }
break; break;
default: default:
opj_free(cinfo); opj_free(cinfo);
return NULL; return NULL;
} }
cinfo->codec_format = format; cinfo->codec_format = format;
return cinfo; return cinfo;
} }
void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo) { void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo) {
if(cinfo) { if(cinfo) {
/* destroy the codec */ /* destroy the codec */
if (cinfo->codec_format != CODEC_UNKNOWN) { if (cinfo->codec_format != CODEC_UNKNOWN) {
j3d_destroy_compress((opj_j3d_t*)cinfo->j3d_handle); j3d_destroy_compress((opj_j3d_t*)cinfo->j3d_handle);
} }
/* destroy the decompressor */ /* destroy the decompressor */
opj_free(cinfo); opj_free(cinfo);
} }
} }
void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters) { void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters) {
if(parameters) { if(parameters) {
memset(parameters, 0, sizeof(opj_cparameters_t)); memset(parameters, 0, sizeof(opj_cparameters_t));
/* default coding parameters */ /* default coding parameters */
parameters->numresolution[0] = 3; parameters->numresolution[0] = 3;
parameters->numresolution[1] = 3; parameters->numresolution[1] = 3;
parameters->numresolution[2] = 1; parameters->numresolution[2] = 1;
parameters->cblock_init[0] = 64; parameters->cblock_init[0] = 64;
parameters->cblock_init[1] = 64; parameters->cblock_init[1] = 64;
parameters->cblock_init[2] = 64; parameters->cblock_init[2] = 64;
parameters->prog_order = LRCP; parameters->prog_order = LRCP;
parameters->roi_compno = -1; /* no ROI */ parameters->roi_compno = -1; /* no ROI */
parameters->atk_wt[0] = 1; /* 5-3 WT */ parameters->atk_wt[0] = 1; /* 5-3 WT */
parameters->atk_wt[1] = 1; /* 5-3 WT */ parameters->atk_wt[1] = 1; /* 5-3 WT */
parameters->atk_wt[2] = 1; /* 5-3 WT */ parameters->atk_wt[2] = 1; /* 5-3 WT */
parameters->irreversible = 0; parameters->irreversible = 0;
parameters->subsampling_dx = 1; parameters->subsampling_dx = 1;
parameters->subsampling_dy = 1; parameters->subsampling_dy = 1;
parameters->subsampling_dz = 1; parameters->subsampling_dz = 1;
parameters->decod_format = -1; parameters->decod_format = -1;
parameters->cod_format = -1; parameters->cod_format = -1;
parameters->encoding_format = ENCOD_2EB; parameters->encoding_format = ENCOD_2EB;
parameters->transform_format = TRF_2D_DWT; parameters->transform_format = TRF_2D_DWT;
} }
} }
void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_volume_t *volume) { void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_volume_t *volume) {
if(cinfo && parameters && volume) { if(cinfo && parameters && volume) {
if (cinfo->codec_format != CODEC_UNKNOWN) { if (cinfo->codec_format != CODEC_UNKNOWN) {
j3d_setup_encoder((opj_j3d_t*)cinfo->j3d_handle, parameters, volume); j3d_setup_encoder((opj_j3d_t*)cinfo->j3d_handle, parameters, volume);
} }
} }
} }
bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_volume_t *volume, char *index) { bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_volume_t *volume, char *index) {
if(cinfo && cio && volume) { if(cinfo && cio && volume) {
if (cinfo->codec_format != CODEC_UNKNOWN) { if (cinfo->codec_format != CODEC_UNKNOWN) {
return j3d_encode((opj_j3d_t*)cinfo->j3d_handle, cio, volume, index); return j3d_encode((opj_j3d_t*)cinfo->j3d_handle, cio, volume, index);
} }
} }
return false; return false;
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,145 +1,145 @@
/* /*
* Copyright (c) 2001-2003, David Janssens * Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
* Copyright (c) 2006, Mónica Díez García, Image Processing Laboratory, University of Valladolid, Spain * Copyright (c) 2006, Mónica Díez García, Image Processing Laboratory, University of Valladolid, Spain
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __PI_H #ifndef __PI_H
#define __PI_H #define __PI_H
/** /**
@file pi.h @file pi.h
@brief Implementation of a packet iterator (PI) @brief Implementation of a packet iterator (PI)
The functions in PI.C have for goal to realize a packet iterator that permits to get the next The functions in PI.C have for goal to realize a packet iterator that permits to get the next
packet following the progression order and change of it. The functions in PI.C are used packet following the progression order and change of it. The functions in PI.C are used
by some function in T2.C. by some function in T2.C.
*/ */
/** @defgroup PI PI - Implementation of a packet iterator */ /** @defgroup PI PI - Implementation of a packet iterator */
/*@{*/ /*@{*/
/** /**
Packet iterator : resolution level information Packet iterator : resolution level information
*/ */
typedef struct opj_pi_resolution { typedef struct opj_pi_resolution {
/** Size of precints in horizontal axis */ /** Size of precints in horizontal axis */
int pdx; int pdx;
/** Size of precints in vertical axis */ /** Size of precints in vertical axis */
int pdy; int pdy;
/** Size of precints in axial axis */ /** Size of precints in axial axis */
int pdz; int pdz;
/** Number of precints in each axis */ /** Number of precints in each axis */
int prctno[3]; int prctno[3];
} opj_pi_resolution_t; } opj_pi_resolution_t;
/** /**
Packet iterator : component information Packet iterator : component information
*/ */
typedef struct opj_pi_comp { typedef struct opj_pi_comp {
/** Size in horizontal axis */ /** Size in horizontal axis */
int dx; int dx;
/** Size in vertical axis */ /** Size in vertical axis */
int dy; int dy;
/** Size in axial axis */ /** Size in axial axis */
int dz; int dz;
/** Number of resolution levels */ /** Number of resolution levels */
int numresolution[3]; int numresolution[3];
/** Packet iterator : resolution level information */ /** Packet iterator : resolution level information */
opj_pi_resolution_t *resolutions; opj_pi_resolution_t *resolutions;
} opj_pi_comp_t; } opj_pi_comp_t;
/** /**
Packet iterator Packet iterator
*/ */
typedef struct opj_pi_iterator { typedef struct opj_pi_iterator {
/** precise if the packet has been already used (usefull for progression order change) */ /** precise if the packet has been already used (usefull for progression order change) */
short int *include; short int *include;
/** layer step used to localize the packet in the include vector */ /** layer step used to localize the packet in the include vector */
int step_l; int step_l;
/** resolution step used to localize the packet in the include vector */ /** resolution step used to localize the packet in the include vector */
int step_r; int step_r;
/** component step used to localize the packet in the include vector */ /** component step used to localize the packet in the include vector */
int step_c; int step_c;
/** precinct step used to localize the packet in the include vector */ /** precinct step used to localize the packet in the include vector */
int step_p; int step_p;
/** component that identify the packet */ /** component that identify the packet */
int compno; int compno;
/** resolution that identify the packet */ /** resolution that identify the packet */
int resno; int resno;
/** precinct that identify the packet */ /** precinct that identify the packet */
int precno; int precno;
/** layer that identify the packet */ /** layer that identify the packet */
int layno; int layno;
/** 0 if the first packet */ /** 0 if the first packet */
int first; int first;
/** progression order change information */ /** progression order change information */
opj_poc_t poc; opj_poc_t poc;
/** Packet iterator : component information */ /** Packet iterator : component information */
opj_pi_comp_t *comps; opj_pi_comp_t *comps;
int numcomps; int numcomps;
int tx0, ty0, tz0; int tx0, ty0, tz0;
int tx1, ty1, tz1; int tx1, ty1, tz1;
int x, y, z; int x, y, z;
int dx, dy, dz; int dx, dy, dz;
} opj_pi_iterator_t; } opj_pi_iterator_t;
/** @name Funciones generales */ /** @name Funciones generales */
/*@{*/ /*@{*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Create a packet iterator Create a packet iterator
@param volume Raw volume for which the packets will be listed @param volume Raw volume for which the packets will be listed
@param cp Coding parameters @param cp Coding parameters
@param tileno Number that identifies the tile for which to list the packets @param tileno Number that identifies the tile for which to list the packets
@return Returns a packet iterator that points to the first packet of the tile @return Returns a packet iterator that points to the first packet of the tile
@see pi_destroy @see pi_destroy
*/ */
opj_pi_iterator_t *pi_create(opj_volume_t * volume, opj_cp_t * cp, int tileno); opj_pi_iterator_t *pi_create(opj_volume_t * volume, opj_cp_t * cp, int tileno);
/** /**
Destroy a packet iterator Destroy a packet iterator
@param pi Previously created packet iterator @param pi Previously created packet iterator
@param cp Coding parameters @param cp Coding parameters
@param tileno Number that identifies the tile for which the packets were listed @param tileno Number that identifies the tile for which the packets were listed
@see pi_create @see pi_create
*/ */
void pi_destroy(opj_pi_iterator_t *pi, opj_cp_t *cp, int tileno); void pi_destroy(opj_pi_iterator_t *pi, opj_cp_t *cp, int tileno);
/** /**
Modify the packet iterator to point to the next packet Modify the packet iterator to point to the next packet
@param pi Packet iterator to modify @param pi Packet iterator to modify
@return Returns false if pi pointed to the last packet or else returns true @return Returns false if pi pointed to the last packet or else returns true
*/ */
bool pi_next(opj_pi_iterator_t * pi); bool pi_next(opj_pi_iterator_t * pi);
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/*@}*/ /*@}*/
/*@}*/ /*@}*/
#endif /* __PI_H */ #endif /* __PI_H */

View File

@ -1,86 +1,86 @@
/* /*
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "opj_includes.h" #include "opj_includes.h"
/* /*
========================================================== ==========================================================
local functions local functions
========================================================== ==========================================================
*/ */
/* /*
========================================================== ==========================================================
RAW encoding interface RAW encoding interface
========================================================== ==========================================================
*/ */
opj_raw_t* raw_create() { opj_raw_t* raw_create() {
opj_raw_t *raw = (opj_raw_t*)opj_malloc(sizeof(opj_raw_t)); opj_raw_t *raw = (opj_raw_t*)opj_malloc(sizeof(opj_raw_t));
return raw; return raw;
} }
void raw_destroy(opj_raw_t *raw) { void raw_destroy(opj_raw_t *raw) {
if(raw) { if(raw) {
opj_free(raw); opj_free(raw);
} }
} }
int raw_numbytes(opj_raw_t *raw) { int raw_numbytes(opj_raw_t *raw) {
return raw->bp - raw->start; return raw->bp - raw->start;
} }
void raw_init_dec(opj_raw_t *raw, unsigned char *bp, int len) { void raw_init_dec(opj_raw_t *raw, unsigned char *bp, int len) {
raw->start = bp; raw->start = bp;
raw->lenmax = len; raw->lenmax = len;
raw->len = 0; raw->len = 0;
raw->c = 0; raw->c = 0;
raw->ct = 0; raw->ct = 0;
} }
int raw_decode(opj_raw_t *raw) { int raw_decode(opj_raw_t *raw) {
int d; int d;
if (raw->ct == 0) { if (raw->ct == 0) {
raw->ct = 8; raw->ct = 8;
if (raw->len == raw->lenmax) { if (raw->len == raw->lenmax) {
raw->c = 0xff; raw->c = 0xff;
} else { } else {
if (raw->c == 0xff) { if (raw->c == 0xff) {
raw->ct = 7; raw->ct = 7;
} }
raw->c = *(raw->start + raw->len); raw->c = *(raw->start + raw->len);
raw->len++; raw->len++;
} }
} }
raw->ct--; raw->ct--;
d = (raw->c >> raw->ct) & 0x01; d = (raw->c >> raw->ct) & 0x01;
return d; return d;
} }

View File

@ -1,99 +1,99 @@
/* /*
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __RAW_H #ifndef __RAW_H
#define __RAW_H #define __RAW_H
/** /**
@file raw.h @file raw.h
@brief Implementation of operations for raw encoding (RAW) @brief Implementation of operations for raw encoding (RAW)
The functions in RAW.C have for goal to realize the operation of raw encoding linked The functions in RAW.C have for goal to realize the operation of raw encoding linked
with the corresponding mode switch. with the corresponding mode switch.
*/ */
/** @defgroup RAW RAW - Implementation of operations for raw encoding */ /** @defgroup RAW RAW - Implementation of operations for raw encoding */
/*@{*/ /*@{*/
/** /**
RAW encoding operations RAW encoding operations
*/ */
typedef struct opj_raw { typedef struct opj_raw {
/** Temporary buffer where bits are coded or decoded */ /** Temporary buffer where bits are coded or decoded */
unsigned char c; unsigned char c;
/** Number of bits already read or free to write */ /** Number of bits already read or free to write */
unsigned int ct; unsigned int ct;
/** Maximum length to decode */ /** Maximum length to decode */
unsigned int lenmax; unsigned int lenmax;
/** Length decoded */ /** Length decoded */
unsigned int len; unsigned int len;
/** Pointer to the current position in the buffer */ /** Pointer to the current position in the buffer */
unsigned char *bp; unsigned char *bp;
/** Pointer to the start of the buffer */ /** Pointer to the start of the buffer */
unsigned char *start; unsigned char *start;
/** Pointer to the end of the buffer */ /** Pointer to the end of the buffer */
unsigned char *end; unsigned char *end;
} opj_raw_t; } opj_raw_t;
/** @name Funciones generales */ /** @name Funciones generales */
/*@{*/ /*@{*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Create a new RAW handle Create a new RAW handle
@return Returns a new RAW handle if successful, returns NULL otherwise @return Returns a new RAW handle if successful, returns NULL otherwise
*/ */
opj_raw_t* raw_create(void); opj_raw_t* raw_create(void);
/** /**
Destroy a previously created RAW handle Destroy a previously created RAW handle
@param raw RAW handle to destroy @param raw RAW handle to destroy
*/ */
void raw_destroy(opj_raw_t *raw); void raw_destroy(opj_raw_t *raw);
/** /**
Return the number of bytes written/read since initialisation Return the number of bytes written/read since initialisation
@param raw RAW handle to destroy @param raw RAW handle to destroy
@return Returns the number of bytes already encoded @return Returns the number of bytes already encoded
*/ */
int raw_numbytes(opj_raw_t *raw); int raw_numbytes(opj_raw_t *raw);
/** /**
Initialize the decoder Initialize the decoder
@param raw RAW handle @param raw RAW handle
@param bp Pointer to the start of the buffer from which the bytes will be read @param bp Pointer to the start of the buffer from which the bytes will be read
@param len Length of the input buffer @param len Length of the input buffer
*/ */
void raw_init_dec(opj_raw_t *raw, unsigned char *bp, int len); void raw_init_dec(opj_raw_t *raw, unsigned char *bp, int len);
/** /**
Decode a symbol using raw-decoder. Cfr p.506 TAUBMAN Decode a symbol using raw-decoder. Cfr p.506 TAUBMAN
@param raw RAW handle @param raw RAW handle
@return Returns the decoded symbol (0 or 1) @return Returns the decoded symbol (0 or 1)
*/ */
int raw_decode(opj_raw_t *raw); int raw_decode(opj_raw_t *raw);
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/*@}*/ /*@}*/
/*@}*/ /*@}*/
#endif /* __RAW_H */ #endif /* __RAW_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,173 +1,173 @@
/* /*
* Copyright (c) 2001-2003, David Janssens * Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __T1_H #ifndef __T1_H
#define __T1_H #define __T1_H
/** /**
@file t1.h @file t1.h
@brief Implementation of the tier-1 coding (coding of code-block coefficients) (T1) @brief Implementation of the tier-1 coding (coding of code-block coefficients) (T1)
The functions in T1.C have for goal to realize the tier-1 coding operation. The functions The functions in T1.C have for goal to realize the tier-1 coding operation. The functions
in T1.C are used by some function in TCD.C. in T1.C are used by some function in TCD.C.
*/ */
/** @defgroup T1 T1 - Implementation of the tier-1 coding */ /** @defgroup T1 T1 - Implementation of the tier-1 coding */
/*@{*/ /*@{*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
#define T1_NMSEDEC_BITS 7 #define T1_NMSEDEC_BITS 7
#define T1_MAXCBLKW 256 /*< Maximum size of code-block (width) */ #define T1_MAXCBLKW 256 /*< Maximum size of code-block (width) */
#define T1_MAXCBLKH 256 /*< Maximum size of code-block (heigth) */ #define T1_MAXCBLKH 256 /*< Maximum size of code-block (heigth) */
#define T1_MAXCBLKD 256 /*< Maximum size of code-block (depth) */ #define T1_MAXCBLKD 256 /*< Maximum size of code-block (depth) */
#define T1_MINCBLKW 4 /*< Minimum size of code-block (width) */ #define T1_MINCBLKW 4 /*< Minimum size of code-block (width) */
#define T1_MINCBLKH 4 /*< Minimum size of code-block (heigth) */ #define T1_MINCBLKH 4 /*< Minimum size of code-block (heigth) */
#define T1_MINCBLKD 4 /*< Minimum size of code-block (depth) */ #define T1_MINCBLKD 4 /*< Minimum size of code-block (depth) */
#define T1_MAXWHD 18 #define T1_MAXWHD 18
#define T1_CBLKW 256 #define T1_CBLKW 256
#define T1_CBLKH 256 #define T1_CBLKH 256
#define T1_CBLKD 256 #define T1_CBLKD 256
#define T1_SIG_NE 0x0001 /*< Context orientation : North-East direction */ #define T1_SIG_NE 0x0001 /*< Context orientation : North-East direction */
#define T1_SIG_SE 0x0002 /*< Context orientation : South-East direction */ #define T1_SIG_SE 0x0002 /*< Context orientation : South-East direction */
#define T1_SIG_SW 0x0004 /*< Context orientation : South-West direction */ #define T1_SIG_SW 0x0004 /*< Context orientation : South-West direction */
#define T1_SIG_NW 0x0008 /*< Context orientation : North-West direction */ #define T1_SIG_NW 0x0008 /*< Context orientation : North-West direction */
#define T1_SIG_N 0x0010 /*< Context orientation : North direction */ #define T1_SIG_N 0x0010 /*< Context orientation : North direction */
#define T1_SIG_E 0x0020 /*< Context orientation : East direction */ #define T1_SIG_E 0x0020 /*< Context orientation : East direction */
#define T1_SIG_S 0x0040 /*< Context orientation : South direction */ #define T1_SIG_S 0x0040 /*< Context orientation : South direction */
#define T1_SIG_W 0x0080 /*< Context orientation : West direction */ #define T1_SIG_W 0x0080 /*< Context orientation : West direction */
#define T1_SIG_OTH (T1_SIG_N|T1_SIG_NE|T1_SIG_E|T1_SIG_SE|T1_SIG_S|T1_SIG_SW|T1_SIG_W|T1_SIG_NW) #define T1_SIG_OTH (T1_SIG_N|T1_SIG_NE|T1_SIG_E|T1_SIG_SE|T1_SIG_S|T1_SIG_SW|T1_SIG_W|T1_SIG_NW)
#define T1_SIG_PRIM (T1_SIG_N|T1_SIG_E|T1_SIG_S|T1_SIG_W) #define T1_SIG_PRIM (T1_SIG_N|T1_SIG_E|T1_SIG_S|T1_SIG_W)
#define T1_SGN_N 0x0100 #define T1_SGN_N 0x0100
#define T1_SGN_E 0x0200 #define T1_SGN_E 0x0200
#define T1_SGN_S 0x0400 #define T1_SGN_S 0x0400
#define T1_SGN_W 0x0800 #define T1_SGN_W 0x0800
#define T1_SGN (T1_SGN_N|T1_SGN_E|T1_SGN_S|T1_SGN_W) #define T1_SGN (T1_SGN_N|T1_SGN_E|T1_SGN_S|T1_SGN_W)
#define T1_SIG 0x1000 #define T1_SIG 0x1000
#define T1_REFINE 0x2000 #define T1_REFINE 0x2000
#define T1_VISIT 0x4000 #define T1_VISIT 0x4000
#define T1_NUMCTXS_AGG 1 #define T1_NUMCTXS_AGG 1
#define T1_NUMCTXS_ZC 9 #define T1_NUMCTXS_ZC 9
#define T1_NUMCTXS_MAG 3 #define T1_NUMCTXS_MAG 3
#define T1_NUMCTXS_SC 5 #define T1_NUMCTXS_SC 5
#define T1_NUMCTXS_UNI 1 #define T1_NUMCTXS_UNI 1
#define T1_CTXNO_AGG 0 #define T1_CTXNO_AGG 0
#define T1_CTXNO_ZC (T1_CTXNO_AGG+T1_NUMCTXS_AGG) #define T1_CTXNO_ZC (T1_CTXNO_AGG+T1_NUMCTXS_AGG)
#define T1_CTXNO_MAG (T1_CTXNO_ZC+T1_NUMCTXS_ZC) #define T1_CTXNO_MAG (T1_CTXNO_ZC+T1_NUMCTXS_ZC)
#define T1_CTXNO_SC (T1_CTXNO_MAG+T1_NUMCTXS_MAG) #define T1_CTXNO_SC (T1_CTXNO_MAG+T1_NUMCTXS_MAG)
#define T1_CTXNO_UNI (T1_CTXNO_SC+T1_NUMCTXS_SC) #define T1_CTXNO_UNI (T1_CTXNO_SC+T1_NUMCTXS_SC)
#define T1_NUMCTXS (T1_CTXNO_UNI+T1_NUMCTXS_UNI) #define T1_NUMCTXS (T1_CTXNO_UNI+T1_NUMCTXS_UNI)
#define T1_NMSEDEC_FRACBITS (T1_NMSEDEC_BITS-1) #define T1_NMSEDEC_FRACBITS (T1_NMSEDEC_BITS-1)
#define T1_TYPE_MQ 0 /*< Normal coding using entropy coder */ #define T1_TYPE_MQ 0 /*< Normal coding using entropy coder */
#define T1_TYPE_RAW 1 /*< No encoding the information is store under raw format in codestream (mode switch RAW)*/ #define T1_TYPE_RAW 1 /*< No encoding the information is store under raw format in codestream (mode switch RAW)*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Tier-1 coding (coding of code-block coefficients) Tier-1 coding (coding of code-block coefficients)
*/ */
typedef struct opj_t1 { typedef struct opj_t1 {
/** codec context */ /** codec context */
opj_common_ptr cinfo; opj_common_ptr cinfo;
/** MQC component */ /** MQC component */
opj_mqc_t *mqc; opj_mqc_t *mqc;
/** RAW component */ /** RAW component */
opj_raw_t *raw; opj_raw_t *raw;
/** LUTs for context-based coding */ /** LUTs for context-based coding */
int lut_ctxno_zc[1024]; int lut_ctxno_zc[1024];
int lut_ctxno_sc[256]; int lut_ctxno_sc[256];
int lut_ctxno_mag[4096]; int lut_ctxno_mag[4096];
int lut_spb[256]; int lut_spb[256];
/** LUTs for decoding normalised MSE */ /** LUTs for decoding normalised MSE */
int lut_nmsedec_sig[1 << T1_NMSEDEC_BITS]; int lut_nmsedec_sig[1 << T1_NMSEDEC_BITS];
int lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS]; int lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS];
int lut_nmsedec_ref[1 << T1_NMSEDEC_BITS]; int lut_nmsedec_ref[1 << T1_NMSEDEC_BITS];
int lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS]; int lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS];
/** Codeblock data */ /** Codeblock data */
int data[T1_CBLKD][T1_CBLKH][T1_CBLKW];/*int ***data;*/ int data[T1_CBLKD][T1_CBLKH][T1_CBLKW];/*int ***data;*/
/** Context information for each voxel in codeblock */ /** Context information for each voxel in codeblock */
int flags[T1_CBLKD + 2][T1_CBLKH + 2][T1_CBLKH + 2];/*int ***flags;*/ int flags[T1_CBLKD + 2][T1_CBLKH + 2][T1_CBLKH + 2];/*int ***flags;*/
} opj_t1_t; } opj_t1_t;
/** @name Exported functions */ /** @name Exported functions */
/*@{*/ /*@{*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Create a new T1 handle Create a new T1 handle
and initialize the look-up tables of the Tier-1 coder/decoder and initialize the look-up tables of the Tier-1 coder/decoder
@return Returns a new T1 handle if successful, returns NULL otherwise @return Returns a new T1 handle if successful, returns NULL otherwise
@see t1_init_luts @see t1_init_luts
*/ */
opj_t1_t* t1_create(opj_common_ptr cinfo); opj_t1_t* t1_create(opj_common_ptr cinfo);
/** /**
Destroy a previously created T1 handle Destroy a previously created T1 handle
@param t1 T1 handle to destroy @param t1 T1 handle to destroy
*/ */
void t1_destroy(opj_t1_t *t1); void t1_destroy(opj_t1_t *t1);
/** /**
Encode the code-blocks of a tile Encode the code-blocks of a tile
@param t1 T1 handle @param t1 T1 handle
@param tile The tile to encode @param tile The tile to encode
@param tcp Tile coding parameters @param tcp Tile coding parameters
*/ */
void t1_encode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp); void t1_encode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp);
/** /**
Decode the code-blocks of a tile Decode the code-blocks of a tile
@param t1 T1 handle @param t1 T1 handle
@param tile The tile to decode @param tile The tile to decode
@param tcp Tile coding parameters @param tcp Tile coding parameters
*/ */
void t1_decode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp); void t1_decode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp);
/** /**
Get weigths of MSE decoding Get weigths of MSE decoding
@param nmsedec The normalized MSE reduction @param nmsedec The normalized MSE reduction
@param compno @param compno
@param level @param level
@param orient @param orient
@param bpno @param bpno
@param stepsize @param stepsize
@param numcomps @param numcomps
@param dwtid @param dwtid
returns MSE associated to decoding pass returns MSE associated to decoding pass
*/ */
double t1_getwmsedec(int nmsedec, int compno, int level[3], int orient, int bpno, double stepsize, int numcomps, int dwtid[3]); double t1_getwmsedec(int nmsedec, int compno, int level[3], int orient, int bpno, double stepsize, int numcomps, int dwtid[3]);
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/*@}*/ /*@}*/
/*@}*/ /*@}*/
#endif /* __T1_H */ #endif /* __T1_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,173 +1,173 @@
/* /*
* Copyrigth (c) 2006, Mónica Díez, LPI-UVA, Spain * Copyrigth (c) 2006, Mónica Díez, LPI-UVA, Spain
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __T1_3D_H #ifndef __T1_3D_H
#define __T1_3D_H #define __T1_3D_H
/** /**
@file t1_3d.h @file t1_3d.h
@brief Implementation of the tier-1 coding (coding of code-block coefficients) (T1) @brief Implementation of the tier-1 coding (coding of code-block coefficients) (T1)
The functions in T1_3D.C have for goal to realize the tier-1 coding operation of 3D-EBCOT. The functions in T1_3D.C have for goal to realize the tier-1 coding operation of 3D-EBCOT.
The functions in T1_3D.C are used by some function in TCD.C. The functions in T1_3D.C are used by some function in TCD.C.
*/ */
/** @defgroup T1_3D T1_3D - Implementation of the tier-1 coding */ /** @defgroup T1_3D T1_3D - Implementation of the tier-1 coding */
/*@{*/ /*@{*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/* Neighbourhood of 3D EBCOT (Significance context)*/ /* Neighbourhood of 3D EBCOT (Significance context)*/
#define T1_3D_SIG_NE 0x00000001 /*< Context orientation : North-East direction */ #define T1_3D_SIG_NE 0x00000001 /*< Context orientation : North-East direction */
#define T1_3D_SIG_SE 0x00000002 /*< Context orientation : South-East direction */ #define T1_3D_SIG_SE 0x00000002 /*< Context orientation : South-East direction */
#define T1_3D_SIG_SW 0x00000004 /*< Context orientation : South-West direction */ #define T1_3D_SIG_SW 0x00000004 /*< Context orientation : South-West direction */
#define T1_3D_SIG_NW 0x00000008 /* Context orientation : North-West direction */ #define T1_3D_SIG_NW 0x00000008 /* Context orientation : North-West direction */
#define T1_3D_SIG_N 0x00000010 /*< Context orientation : North direction */ #define T1_3D_SIG_N 0x00000010 /*< Context orientation : North direction */
#define T1_3D_SIG_E 0x00000020 /*< Context orientation : East direction */ #define T1_3D_SIG_E 0x00000020 /*< Context orientation : East direction */
#define T1_3D_SIG_S 0x00000040 /*< Context orientation : South direction */ #define T1_3D_SIG_S 0x00000040 /*< Context orientation : South direction */
#define T1_3D_SIG_W 0x00000080 /*< Context orientation : West direction */ #define T1_3D_SIG_W 0x00000080 /*< Context orientation : West direction */
#define T1_3D_SIG_FC 0x00000100 /*< Context orientation : Forward Central direction */ #define T1_3D_SIG_FC 0x00000100 /*< Context orientation : Forward Central direction */
#define T1_3D_SIG_BC 0x00000200 /*< Context orientation : Backward Central direction */ #define T1_3D_SIG_BC 0x00000200 /*< Context orientation : Backward Central direction */
#define T1_3D_SIG_FNE 0x00000400 /*< Context orientation : Forward North-East direction */ #define T1_3D_SIG_FNE 0x00000400 /*< Context orientation : Forward North-East direction */
#define T1_3D_SIG_FSE 0x00000800 /*< Context orientation : Forward South-East direction */ #define T1_3D_SIG_FSE 0x00000800 /*< Context orientation : Forward South-East direction */
#define T1_3D_SIG_FSW 0x00001000 /*< Context orientation : Forward South-West direction */ #define T1_3D_SIG_FSW 0x00001000 /*< Context orientation : Forward South-West direction */
#define T1_3D_SIG_FNW 0x00002000 /*< Context orientation : Forward North-West direction */ #define T1_3D_SIG_FNW 0x00002000 /*< Context orientation : Forward North-West direction */
#define T1_3D_SIG_FN 0x00004000 /*< Context orientation : Forward North direction */ #define T1_3D_SIG_FN 0x00004000 /*< Context orientation : Forward North direction */
#define T1_3D_SIG_FE 0x00008000 /*< Context orientation : Forward East direction */ #define T1_3D_SIG_FE 0x00008000 /*< Context orientation : Forward East direction */
#define T1_3D_SIG_FS 0x00010000 /*< Context orientation : Forward South direction */ #define T1_3D_SIG_FS 0x00010000 /*< Context orientation : Forward South direction */
#define T1_3D_SIG_FW 0x00020000 /*< Context orientation : Forward West direction */ #define T1_3D_SIG_FW 0x00020000 /*< Context orientation : Forward West direction */
#define T1_3D_SIG_BNE 0x00040000 /*< Context orientation : Backward North-East direction */ #define T1_3D_SIG_BNE 0x00040000 /*< Context orientation : Backward North-East direction */
#define T1_3D_SIG_BSE 0x00080000 /*< Context orientation : Backward South-East direction */ #define T1_3D_SIG_BSE 0x00080000 /*< Context orientation : Backward South-East direction */
#define T1_3D_SIG_BSW 0x00100000 /*< Context orientation : Backward South-West direction */ #define T1_3D_SIG_BSW 0x00100000 /*< Context orientation : Backward South-West direction */
#define T1_3D_SIG_BNW 0x00200000 /*< Context orientation : Backward North-West direction */ #define T1_3D_SIG_BNW 0x00200000 /*< Context orientation : Backward North-West direction */
#define T1_3D_SIG_BN 0x00400000 /*< Context orientation : Backward North direction */ #define T1_3D_SIG_BN 0x00400000 /*< Context orientation : Backward North direction */
#define T1_3D_SIG_BE 0x00800000 /*< Context orientation : Backward East direction */ #define T1_3D_SIG_BE 0x00800000 /*< Context orientation : Backward East direction */
#define T1_3D_SIG_BS 0x01000000 /*< Context orientation : Backward South direction */ #define T1_3D_SIG_BS 0x01000000 /*< Context orientation : Backward South direction */
#define T1_3D_SIG_BW 0x02000000 /*< Context orientation : Backward West direction */ #define T1_3D_SIG_BW 0x02000000 /*< Context orientation : Backward West direction */
#define T1_3D_SIG_COTH (T1_3D_SIG_N|T1_3D_SIG_NE|T1_3D_SIG_E|T1_3D_SIG_SE|T1_3D_SIG_S|T1_3D_SIG_SW|T1_3D_SIG_W|T1_3D_SIG_NW) #define T1_3D_SIG_COTH (T1_3D_SIG_N|T1_3D_SIG_NE|T1_3D_SIG_E|T1_3D_SIG_SE|T1_3D_SIG_S|T1_3D_SIG_SW|T1_3D_SIG_W|T1_3D_SIG_NW)
#define T1_3D_SIG_BOTH (T1_3D_SIG_BN|T1_3D_SIG_BNE|T1_3D_SIG_BE|T1_3D_SIG_BSE|T1_3D_SIG_BS|T1_3D_SIG_BSW|T1_3D_SIG_BW|T1_3D_SIG_BNW|T1_3D_SIG_BC) #define T1_3D_SIG_BOTH (T1_3D_SIG_BN|T1_3D_SIG_BNE|T1_3D_SIG_BE|T1_3D_SIG_BSE|T1_3D_SIG_BS|T1_3D_SIG_BSW|T1_3D_SIG_BW|T1_3D_SIG_BNW|T1_3D_SIG_BC)
#define T1_3D_SIG_FOTH (T1_3D_SIG_FN|T1_3D_SIG_FNE|T1_3D_SIG_FE|T1_3D_SIG_FSE|T1_3D_SIG_FS|T1_3D_SIG_FSW|T1_3D_SIG_FW|T1_3D_SIG_FNW|T1_3D_SIG_FC) #define T1_3D_SIG_FOTH (T1_3D_SIG_FN|T1_3D_SIG_FNE|T1_3D_SIG_FE|T1_3D_SIG_FSE|T1_3D_SIG_FS|T1_3D_SIG_FSW|T1_3D_SIG_FW|T1_3D_SIG_FNW|T1_3D_SIG_FC)
#define T1_3D_SIG_OTH (T1_3D_SIG_FOTH|T1_3D_SIG_BOTH|T1_3D_SIG_COTH) #define T1_3D_SIG_OTH (T1_3D_SIG_FOTH|T1_3D_SIG_BOTH|T1_3D_SIG_COTH)
#define T1_3D_SIG_PRIM (T1_3D_SIG_N|T1_3D_SIG_E|T1_3D_SIG_S|T1_3D_SIG_W|T1_3D_SIG_FC|T1_3D_SIG_BC) #define T1_3D_SIG_PRIM (T1_3D_SIG_N|T1_3D_SIG_E|T1_3D_SIG_S|T1_3D_SIG_W|T1_3D_SIG_FC|T1_3D_SIG_BC)
#define T1_3D_SGN_N 0x0400 #define T1_3D_SGN_N 0x0400
#define T1_3D_SGN_E 0x0800 #define T1_3D_SGN_E 0x0800
#define T1_3D_SGN_S 0x1000 #define T1_3D_SGN_S 0x1000
#define T1_3D_SGN_W 0x2000 #define T1_3D_SGN_W 0x2000
#define T1_3D_SGN_F 0x4000 #define T1_3D_SGN_F 0x4000
#define T1_3D_SGN_B 0x8000 #define T1_3D_SGN_B 0x8000
#define T1_3D_SGN (T1_3D_SGN_N|T1_3D_SGN_E|T1_3D_SGN_S|T1_3D_SGN_W|T1_3D_SGN_F|T1_3D_SGN_B) #define T1_3D_SGN (T1_3D_SGN_N|T1_3D_SGN_E|T1_3D_SGN_S|T1_3D_SGN_W|T1_3D_SGN_F|T1_3D_SGN_B)
#define T1_3D_SIG 0x0001 /*Significance state*/ #define T1_3D_SIG 0x0001 /*Significance state*/
#define T1_3D_REFINE 0x0002 /*Delayed significance*/ #define T1_3D_REFINE 0x0002 /*Delayed significance*/
#define T1_3D_VISIT 0x0004 /*First-pass membership*/ #define T1_3D_VISIT 0x0004 /*First-pass membership*/
#define T1_3D_NUMCTXS_AGG 1 #define T1_3D_NUMCTXS_AGG 1
#define T1_3D_NUMCTXS_ZC 16 #define T1_3D_NUMCTXS_ZC 16
#define T1_3D_NUMCTXS_MAG 3 #define T1_3D_NUMCTXS_MAG 3
#define T1_3D_NUMCTXS_SC 6 #define T1_3D_NUMCTXS_SC 6
#define T1_3D_NUMCTXS_UNI 1 #define T1_3D_NUMCTXS_UNI 1
#define T1_3D_CTXNO_AGG 0 #define T1_3D_CTXNO_AGG 0
#define T1_3D_CTXNO_ZC (T1_3D_CTXNO_AGG+T1_3D_NUMCTXS_AGG) /*1*/ #define T1_3D_CTXNO_ZC (T1_3D_CTXNO_AGG+T1_3D_NUMCTXS_AGG) /*1*/
#define T1_3D_CTXNO_MAG (T1_3D_CTXNO_ZC+T1_3D_NUMCTXS_ZC) /*17*/ #define T1_3D_CTXNO_MAG (T1_3D_CTXNO_ZC+T1_3D_NUMCTXS_ZC) /*17*/
#define T1_3D_CTXNO_SC (T1_3D_CTXNO_MAG+T1_3D_NUMCTXS_MAG) /*20*/ #define T1_3D_CTXNO_SC (T1_3D_CTXNO_MAG+T1_3D_NUMCTXS_MAG) /*20*/
#define T1_3D_CTXNO_UNI (T1_3D_CTXNO_SC+T1_3D_NUMCTXS_SC) /*26*/ #define T1_3D_CTXNO_UNI (T1_3D_CTXNO_SC+T1_3D_NUMCTXS_SC) /*26*/
#define T1_3D_NUMCTXS (T1_3D_CTXNO_UNI+T1_3D_NUMCTXS_UNI) /*27*/ #define T1_3D_NUMCTXS (T1_3D_CTXNO_UNI+T1_3D_NUMCTXS_UNI) /*27*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Tier-1 coding (coding of code-block coefficients) Tier-1 coding (coding of code-block coefficients)
*/ */
typedef struct opj_t1_3d { typedef struct opj_t1_3d {
/** Codec context */ /** Codec context */
opj_common_ptr cinfo; opj_common_ptr cinfo;
/** MQC component */ /** MQC component */
opj_mqc_t *mqc; opj_mqc_t *mqc;
/** RAW component */ /** RAW component */
opj_raw_t *raw; opj_raw_t *raw;
/** LUTs for decoding normalised MSE */ /** LUTs for decoding normalised MSE */
int lut_nmsedec_sig[1 << T1_NMSEDEC_BITS]; int lut_nmsedec_sig[1 << T1_NMSEDEC_BITS];
int lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS]; int lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS];
int lut_nmsedec_ref[1 << T1_NMSEDEC_BITS]; int lut_nmsedec_ref[1 << T1_NMSEDEC_BITS];
int lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS]; int lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS];
/** Codeblock data */ /** Codeblock data */
int data[T1_CBLKD][T1_CBLKH][T1_CBLKW]; int data[T1_CBLKD][T1_CBLKH][T1_CBLKW];
/** Context information for each voxel in codeblock */ /** Context information for each voxel in codeblock */
unsigned int flags[T1_CBLKD + 2][T1_CBLKH + 2][T1_CBLKH + 2]; unsigned int flags[T1_CBLKD + 2][T1_CBLKH + 2][T1_CBLKH + 2];
/** Voxel information (significance/visited/refined) */ /** Voxel information (significance/visited/refined) */
int flagSVR[T1_CBLKD + 2][T1_CBLKH + 2][T1_CBLKH + 2]; int flagSVR[T1_CBLKD + 2][T1_CBLKH + 2][T1_CBLKH + 2];
} opj_t1_3d_t; } opj_t1_3d_t;
/** @name Exported functions */ /** @name Exported functions */
/*@{*/ /*@{*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Create a new T1_3D handle Create a new T1_3D handle
and initialize the look-up tables of the Tier-1 coder/decoder and initialize the look-up tables of the Tier-1 coder/decoder
@return Returns a new T1 handle if successful, returns NULL otherwise @return Returns a new T1 handle if successful, returns NULL otherwise
@see t1_init_luts @see t1_init_luts
*/ */
opj_t1_3d_t* t1_3d_create(opj_common_ptr cinfo); opj_t1_3d_t* t1_3d_create(opj_common_ptr cinfo);
/** /**
Destroy a previously created T1_3D handle Destroy a previously created T1_3D handle
@param t1 T1_3D handle to destroy @param t1 T1_3D handle to destroy
*/ */
void t1_3d_destroy(opj_t1_3d_t *t1); void t1_3d_destroy(opj_t1_3d_t *t1);
/** /**
Encode the code-blocks of a tile Encode the code-blocks of a tile
@param t1 T1_3D handle @param t1 T1_3D handle
@param tile The tile to encode @param tile The tile to encode
@param tcp Tile coding parameters @param tcp Tile coding parameters
*/ */
void t1_3d_encode_cblks(opj_t1_3d_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp); void t1_3d_encode_cblks(opj_t1_3d_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp);
/** /**
Decode the code-blocks of a tile Decode the code-blocks of a tile
@param t1 T1_3D handle @param t1 T1_3D handle
@param tile The tile to decode @param tile The tile to decode
@param tcp Tile coding parameters @param tcp Tile coding parameters
*/ */
void t1_3d_decode_cblks(opj_t1_3d_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp); void t1_3d_decode_cblks(opj_t1_3d_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp);
/** /**
Get weigths of MSE decoding Get weigths of MSE decoding
@param nmsedec The normalized MSE reduction @param nmsedec The normalized MSE reduction
@param compno @param compno
@param level @param level
@param orient @param orient
@param bpno @param bpno
@param reversible @param reversible
@param stepsize @param stepsize
@param numcomps @param numcomps
@param dwtid @param dwtid
returns MSE associated to decoding pass returns MSE associated to decoding pass
double t1_3d_getwmsedec(int nmsedec, int compno, int levelxy, int levelz, int orient, int bpno, int reversible, double stepsize, int numcomps, int dwtid); double t1_3d_getwmsedec(int nmsedec, int compno, int levelxy, int levelz, int orient, int bpno, int reversible, double stepsize, int numcomps, int dwtid);
*/ */
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/*@}*/ /*@}*/
/*@}*/ /*@}*/
#endif /* __T1_H */ #endif /* __T1_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,101 +1,101 @@
/* /*
* Copyright (c) 2001-2003, David Janssens * Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
* Copyright (c) 2006, Mónica Díez García, Image Processing Laboratory, University of Valladolid, Spain * Copyright (c) 2006, Mónica Díez García, Image Processing Laboratory, University of Valladolid, Spain
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __T2_H #ifndef __T2_H
#define __T2_H #define __T2_H
/** /**
@file t2.h @file t2.h
@brief Implementation of a tier-2 coding (packetization of code-block data) (T2) @brief Implementation of a tier-2 coding (packetization of code-block data) (T2)
*/ */
/** @defgroup T2 T2 - Implementation of a tier-2 coding */ /** @defgroup T2 T2 - Implementation of a tier-2 coding */
/*@{*/ /*@{*/
/** /**
Tier-2 coding Tier-2 coding
*/ */
typedef struct opj_t2 { typedef struct opj_t2 {
/** Codec context */ /** Codec context */
opj_common_ptr cinfo; opj_common_ptr cinfo;
/** Encoding: pointer to the src volume. Decoding: pointer to the dst volume. */ /** Encoding: pointer to the src volume. Decoding: pointer to the dst volume. */
opj_volume_t *volume; opj_volume_t *volume;
/** Pointer to the volume coding parameters */ /** Pointer to the volume coding parameters */
opj_cp_t *cp; opj_cp_t *cp;
} opj_t2_t; } opj_t2_t;
/** @name Funciones generales */ /** @name Funciones generales */
/*@{*/ /*@{*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Encode the packets of a tile to a destination buffer Encode the packets of a tile to a destination buffer
@param t2 T2 handle @param t2 T2 handle
@param tileno number of the tile encoded @param tileno number of the tile encoded
@param tile the tile for which to write the packets @param tile the tile for which to write the packets
@param maxlayers maximum number of layers @param maxlayers maximum number of layers
@param dest the destination buffer @param dest the destination buffer
@param len the length of the destination buffer @param len the length of the destination buffer
@param volume_info structure to create an index file @param volume_info structure to create an index file
@return Number of bytes written from packets @return Number of bytes written from packets
*/ */
int t2_encode_packets(opj_t2_t* t2, int tileno, opj_tcd_tile_t *tile, int maxlayers, unsigned char *dest, int len, opj_volume_info_t *volume_info); int t2_encode_packets(opj_t2_t* t2, int tileno, opj_tcd_tile_t *tile, int maxlayers, unsigned char *dest, int len, opj_volume_info_t *volume_info);
/** /**
Decode the packets of a tile from a source buffer Decode the packets of a tile from a source buffer
@param t2 T2 handle @param t2 T2 handle
@param src the source buffer @param src the source buffer
@param len length of the source buffer @param len length of the source buffer
@param tileno number that identifies the tile for which to decode the packets @param tileno number that identifies the tile for which to decode the packets
@param tile tile for which to decode the packets @param tile tile for which to decode the packets
@return Number of bytes read from packets @return Number of bytes read from packets
*/ */
int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj_tcd_tile_t *tile); int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj_tcd_tile_t *tile);
/** /**
Create a T2 handle Create a T2 handle
@param cinfo Codec context info @param cinfo Codec context info
@param volume Source or destination volume @param volume Source or destination volume
@param cp Volume coding parameters @param cp Volume coding parameters
@return Returns a new T2 handle if successful, returns NULL otherwise @return Returns a new T2 handle if successful, returns NULL otherwise
*/ */
opj_t2_t* t2_create(opj_common_ptr cinfo, opj_volume_t *volume, opj_cp_t *cp); opj_t2_t* t2_create(opj_common_ptr cinfo, opj_volume_t *volume, opj_cp_t *cp);
/** /**
Destroy a T2 handle Destroy a T2 handle
@param t2 T2 handle to destroy @param t2 T2 handle to destroy
*/ */
void t2_destroy(opj_t2_t *t2); void t2_destroy(opj_t2_t *t2);
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/*@}*/ /*@}*/
/*@}*/ /*@}*/
#endif /* __T2_H */ #endif /* __T2_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,251 +1,251 @@
/* /*
* Copyright (c) 2001-2003, David Janssens * Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "opj_includes.h" #include "opj_includes.h"
/* /*
========================================================== ==========================================================
Tag-tree coder interface Tag-tree coder interface
========================================================== ==========================================================
*/ */
void tgt_tree_dump (FILE *fd, opj_tgt_tree_t * tree){ void tgt_tree_dump (FILE *fd, opj_tgt_tree_t * tree){
int nodesno; int nodesno;
fprintf(fd, "TGT_TREE {\n"); fprintf(fd, "TGT_TREE {\n");
fprintf(fd, " numnodes: %d \n", tree->numnodes); fprintf(fd, " numnodes: %d \n", tree->numnodes);
fprintf(fd, " numleafsh: %d, numleafsv: %d, numleafsz: %d,\n", tree->numleafsh, tree->numleafsv, tree->numleafsz); fprintf(fd, " numleafsh: %d, numleafsv: %d, numleafsz: %d,\n", tree->numleafsh, tree->numleafsv, tree->numleafsz);
for (nodesno = 0; nodesno < tree->numnodes; nodesno++) { for (nodesno = 0; nodesno < tree->numnodes; nodesno++) {
fprintf(fd, "tgt_node %d {\n", nodesno); fprintf(fd, "tgt_node %d {\n", nodesno);
fprintf(fd, " value: %d \n", tree->nodes[nodesno].value); fprintf(fd, " value: %d \n", tree->nodes[nodesno].value);
fprintf(fd, " low: %d \n", tree->nodes[nodesno].low); fprintf(fd, " low: %d \n", tree->nodes[nodesno].low);
fprintf(fd, " known: %d \n", tree->nodes[nodesno].known); fprintf(fd, " known: %d \n", tree->nodes[nodesno].known);
if (tree->nodes[nodesno].parent) { if (tree->nodes[nodesno].parent) {
fprintf(fd, " parent.value: %d \n", tree->nodes[nodesno].parent->value); fprintf(fd, " parent.value: %d \n", tree->nodes[nodesno].parent->value);
fprintf(fd, " parent.low: %d \n", tree->nodes[nodesno].parent->low); fprintf(fd, " parent.low: %d \n", tree->nodes[nodesno].parent->low);
fprintf(fd, " parent.known: %d \n", tree->nodes[nodesno].parent->known); fprintf(fd, " parent.known: %d \n", tree->nodes[nodesno].parent->known);
} }
fprintf(fd, "}\n"); fprintf(fd, "}\n");
} }
fprintf(fd, "}\n"); fprintf(fd, "}\n");
} }
opj_tgt_tree_t *tgt_create(int numleafsh, int numleafsv, int numleafsz) { opj_tgt_tree_t *tgt_create(int numleafsh, int numleafsv, int numleafsz) {
int nplh[32]; int nplh[32];
int nplv[32]; int nplv[32];
int nplz[32]; int nplz[32];
opj_tgt_node_t *node = NULL; opj_tgt_node_t *node = NULL;
opj_tgt_node_t *parentnode = NULL; opj_tgt_node_t *parentnode = NULL;
opj_tgt_node_t *parentnode0 = NULL; opj_tgt_node_t *parentnode0 = NULL;
opj_tgt_node_t *parentnode1 = NULL; opj_tgt_node_t *parentnode1 = NULL;
opj_tgt_tree_t *tree = NULL; opj_tgt_tree_t *tree = NULL;
int i, j, k, p, p0; int i, j, k, p, p0;
int numlvls; int numlvls;
int n, z = 0; int n, z = 0;
tree = (opj_tgt_tree_t *) opj_malloc(sizeof(opj_tgt_tree_t)); tree = (opj_tgt_tree_t *) opj_malloc(sizeof(opj_tgt_tree_t));
if(!tree) if(!tree)
return NULL; return NULL;
tree->numleafsh = numleafsh; tree->numleafsh = numleafsh;
tree->numleafsv = numleafsv; tree->numleafsv = numleafsv;
tree->numleafsz = numleafsz; tree->numleafsz = numleafsz;
numlvls = 0; numlvls = 0;
nplh[0] = numleafsh; nplh[0] = numleafsh;
nplv[0] = numleafsv; nplv[0] = numleafsv;
nplz[0] = numleafsz; nplz[0] = numleafsz;
tree->numnodes = 0; tree->numnodes = 0;
do { do {
n = nplh[numlvls] * nplv[numlvls] * nplz[numlvls]; n = nplh[numlvls] * nplv[numlvls] * nplz[numlvls];
nplh[numlvls + 1] = (nplh[numlvls] + 1) / 2; nplh[numlvls + 1] = (nplh[numlvls] + 1) / 2;
nplv[numlvls + 1] = (nplv[numlvls] + 1) / 2; nplv[numlvls + 1] = (nplv[numlvls] + 1) / 2;
nplz[numlvls + 1] = (nplz[numlvls] + 1) / 2; nplz[numlvls + 1] = (nplz[numlvls] + 1) / 2;
tree->numnodes += n; tree->numnodes += n;
++numlvls; ++numlvls;
} while (n > 1); } while (n > 1);
if (tree->numnodes == 0) { if (tree->numnodes == 0) {
opj_free(tree); opj_free(tree);
return NULL; return NULL;
} }
tree->nodes = (opj_tgt_node_t *) opj_malloc(tree->numnodes * sizeof(opj_tgt_node_t)); tree->nodes = (opj_tgt_node_t *) opj_malloc(tree->numnodes * sizeof(opj_tgt_node_t));
if(!tree->nodes) { if(!tree->nodes) {
opj_free(tree); opj_free(tree);
return NULL; return NULL;
} }
node = tree->nodes; node = tree->nodes;
parentnode = &tree->nodes[tree->numleafsh * tree->numleafsv * tree->numleafsz]; parentnode = &tree->nodes[tree->numleafsh * tree->numleafsv * tree->numleafsz];
parentnode0 = parentnode; parentnode0 = parentnode;
parentnode1 = parentnode; parentnode1 = parentnode;
/*fprintf(stdout,"\nH %d V %d Z %d numlvls %d nodes %d\n",tree->numleafsh,tree->numleafsv,tree->numleafsz,numlvls,tree->numnodes);*/ /*fprintf(stdout,"\nH %d V %d Z %d numlvls %d nodes %d\n",tree->numleafsh,tree->numleafsv,tree->numleafsz,numlvls,tree->numnodes);*/
for (i = 0; i < numlvls - 1; ++i) { for (i = 0; i < numlvls - 1; ++i) {
for (z = 0; z < nplz[i]; ++z) { for (z = 0; z < nplz[i]; ++z) {
for (j = 0; j < nplv[i]; ++j) { for (j = 0; j < nplv[i]; ++j) {
k = nplh[i]; k = nplh[i];
while(--k >= 0) { while(--k >= 0) {
node->parent = parentnode; /*fprintf(stdout,"node[%d].parent = node[%d]\n",n,p);*/ node->parent = parentnode; /*fprintf(stdout,"node[%d].parent = node[%d]\n",n,p);*/
++node; ++node;
if(--k >= 0) { if(--k >= 0) {
node->parent = parentnode; /*fprintf(stdout,"node[%d].parent = node[%d]\n",n,p);*/ node->parent = parentnode; /*fprintf(stdout,"node[%d].parent = node[%d]\n",n,p);*/
++node; ++node;
} }
++parentnode; ++parentnode;
} }
if((j & 1) || j == nplv[i] - 1) { if((j & 1) || j == nplv[i] - 1) {
parentnode0 = parentnode; parentnode0 = parentnode;
} else { } else {
parentnode = parentnode0; parentnode = parentnode0;
} }
} }
if ((z & 1) || z == nplz[i] - 1) { if ((z & 1) || z == nplz[i] - 1) {
parentnode1 = parentnode; parentnode1 = parentnode;
} else { } else {
parentnode0 = parentnode1; parentnode0 = parentnode1;
parentnode = parentnode1; parentnode = parentnode1;
} }
} }
} }
node->parent = 0; node->parent = 0;
tgt_reset(tree); tgt_reset(tree);
return tree; return tree;
} }
void tgt_destroy(opj_tgt_tree_t *tree) { void tgt_destroy(opj_tgt_tree_t *tree) {
opj_free(tree->nodes); opj_free(tree->nodes);
opj_free(tree); opj_free(tree);
} }
void tgt_reset(opj_tgt_tree_t *tree) { void tgt_reset(opj_tgt_tree_t *tree) {
int i; int i;
if (NULL == tree) if (NULL == tree)
return; return;
for (i = 0; i < tree->numnodes; i++) { for (i = 0; i < tree->numnodes; i++) {
tree->nodes[i].value = 999; tree->nodes[i].value = 999;
tree->nodes[i].low = 0; tree->nodes[i].low = 0;
tree->nodes[i].known = 0; tree->nodes[i].known = 0;
} }
} }
void tgt_setvalue(opj_tgt_tree_t *tree, int leafno, int value) { void tgt_setvalue(opj_tgt_tree_t *tree, int leafno, int value) {
opj_tgt_node_t *node; opj_tgt_node_t *node;
node = &tree->nodes[leafno]; node = &tree->nodes[leafno];
while (node && node->value > value) { while (node && node->value > value) {
node->value = value; node->value = value;
node = node->parent; node = node->parent;
} }
} }
void tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold) { void tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold) {
opj_tgt_node_t *stk[31]; opj_tgt_node_t *stk[31];
opj_tgt_node_t **stkptr; opj_tgt_node_t **stkptr;
opj_tgt_node_t *node; opj_tgt_node_t *node;
int low; int low;
stkptr = stk; stkptr = stk;
node = &tree->nodes[leafno]; node = &tree->nodes[leafno];
while (node->parent) { while (node->parent) {
*stkptr++ = node; *stkptr++ = node;
node = node->parent; node = node->parent;
} }
low = 0; low = 0;
for (;;) { for (;;) {
if (low > node->low) { if (low > node->low) {
node->low = low; node->low = low;
} else { } else {
low = node->low; low = node->low;
} }
while (low < threshold) { while (low < threshold) {
if (low >= node->value) { if (low >= node->value) {
if (!node->known) { if (!node->known) {
bio_write(bio, 1, 1); bio_write(bio, 1, 1);
node->known = 1; node->known = 1;
} }
break; break;
} }
bio_write(bio, 0, 1); bio_write(bio, 0, 1);
++low; ++low;
} }
node->low = low; node->low = low;
if (stkptr == stk) if (stkptr == stk)
break; break;
node = *--stkptr; node = *--stkptr;
} }
} }
int tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold) { int tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold) {
opj_tgt_node_t *stk[31]; opj_tgt_node_t *stk[31];
opj_tgt_node_t **stkptr; opj_tgt_node_t **stkptr;
opj_tgt_node_t *node; opj_tgt_node_t *node;
int low; int low;
stkptr = stk; stkptr = stk;
node = &tree->nodes[leafno]; node = &tree->nodes[leafno];
while (node->parent) { while (node->parent) {
*stkptr++ = node; *stkptr++ = node;
node = node->parent; node = node->parent;
} }
low = 0; low = 0;
for (;;) { for (;;) {
if (low > node->low) { if (low > node->low) {
node->low = low; node->low = low;
} else { } else {
low = node->low; low = node->low;
} }
while (low < threshold && low < node->value) { while (low < threshold && low < node->value) {
if (bio_read(bio, 1)) { if (bio_read(bio, 1)) {
node->value = low; node->value = low;
} else { } else {
++low; ++low;
} }
} }
node->low = low; node->low = low;
if (stkptr == stk) { if (stkptr == stk) {
break; break;
} }
node = *--stkptr; node = *--stkptr;
} }
return (node->value < threshold) ? 1 : 0; return (node->value < threshold) ? 1 : 0;
} }

View File

@ -1,125 +1,125 @@
/* /*
* Copyright (c) 2001-2003, David Janssens * Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __TGT_H #ifndef __TGT_H
#define __TGT_H #define __TGT_H
/** /**
@file tgt.h @file tgt.h
@brief Implementation of a tag-tree coder (TGT) @brief Implementation of a tag-tree coder (TGT)
The functions in TGT.C have for goal to realize a tag-tree coder. The functions in TGT.C The functions in TGT.C have for goal to realize a tag-tree coder. The functions in TGT.C
are used by some function in T2.C. are used by some function in T2.C.
*/ */
/** @defgroup TGT TGT - Implementation of a tag-tree coder */ /** @defgroup TGT TGT - Implementation of a tag-tree coder */
/*@{*/ /*@{*/
/** /**
Tag node Tag node
*/ */
typedef struct opj_tgt_node { typedef struct opj_tgt_node {
/** Node parent reference */ /** Node parent reference */
struct opj_tgt_node *parent; struct opj_tgt_node *parent;
/** */ /** */
int value; int value;
/** */ /** */
int low; int low;
/** */ /** */
int known; int known;
} opj_tgt_node_t; } opj_tgt_node_t;
/** /**
Tag tree Tag tree
*/ */
typedef struct opj_tgt_tree { typedef struct opj_tgt_tree {
/** Number of leaves from horizontal axis */ /** Number of leaves from horizontal axis */
int numleafsh; int numleafsh;
/** Number of leaves from vertical axis */ /** Number of leaves from vertical axis */
int numleafsv; int numleafsv;
/** Number of leaves from axial axis */ /** Number of leaves from axial axis */
int numleafsz; int numleafsz;
/** Number of nodes */ /** Number of nodes */
int numnodes; int numnodes;
/** Reference to each node instance */ /** Reference to each node instance */
opj_tgt_node_t *nodes; opj_tgt_node_t *nodes;
} opj_tgt_tree_t; } opj_tgt_tree_t;
/** @name Funciones generales */ /** @name Funciones generales */
/*@{*/ /*@{*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/** /**
Create a tag-tree Create a tag-tree
@param numleafsh Width of the array of leafs of the tree @param numleafsh Width of the array of leafs of the tree
@param numleafsv Height of the array of leafs of the tree @param numleafsv Height of the array of leafs of the tree
@param numleafsz Depth of the array of leafs of the tree @param numleafsz Depth of the array of leafs of the tree
@return Returns a new tag-tree if successful, returns NULL otherwise @return Returns a new tag-tree if successful, returns NULL otherwise
*/ */
opj_tgt_tree_t *tgt_create(int numleafsh, int numleafsv, int numleafsz); opj_tgt_tree_t *tgt_create(int numleafsh, int numleafsv, int numleafsz);
/** /**
Destroy a tag-tree, liberating memory Destroy a tag-tree, liberating memory
@param tree Tag-tree to destroy @param tree Tag-tree to destroy
*/ */
void tgt_destroy(opj_tgt_tree_t *tree); void tgt_destroy(opj_tgt_tree_t *tree);
/** /**
Reset a tag-tree (set all leaves to 0) Reset a tag-tree (set all leaves to 0)
@param tree Tag-tree to reset @param tree Tag-tree to reset
*/ */
void tgt_reset(opj_tgt_tree_t *tree); void tgt_reset(opj_tgt_tree_t *tree);
/** /**
Set the value of a leaf of a tag-tree Set the value of a leaf of a tag-tree
@param tree Tag-tree to modify @param tree Tag-tree to modify
@param leafno Number that identifies the leaf to modify @param leafno Number that identifies the leaf to modify
@param value New value of the leaf @param value New value of the leaf
*/ */
void tgt_setvalue(opj_tgt_tree_t *tree, int leafno, int value); void tgt_setvalue(opj_tgt_tree_t *tree, int leafno, int value);
/** /**
Encode the value of a leaf of the tag-tree up to a given threshold Encode the value of a leaf of the tag-tree up to a given threshold
@param bio Pointer to a BIO handle @param bio Pointer to a BIO handle
@param tree Tag-tree to modify @param tree Tag-tree to modify
@param leafno Number that identifies the leaf to encode @param leafno Number that identifies the leaf to encode
@param threshold Threshold to use when encoding value of the leaf @param threshold Threshold to use when encoding value of the leaf
*/ */
void tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold); void tgt_encode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold);
/** /**
Decode the value of a leaf of the tag-tree up to a given threshold Decode the value of a leaf of the tag-tree up to a given threshold
@param bio Pointer to a BIO handle @param bio Pointer to a BIO handle
@param tree Tag-tree to decode @param tree Tag-tree to decode
@param leafno Number that identifies the leaf to decode @param leafno Number that identifies the leaf to decode
@param threshold Threshold to use when decoding value of the leaf @param threshold Threshold to use when decoding value of the leaf
@return Returns 1 if the node's value < threshold, returns 0 otherwise @return Returns 1 if the node's value < threshold, returns 0 otherwise
*/ */
int tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold); int tgt_decode(opj_bio_t *bio, opj_tgt_tree_t *tree, int leafno, int threshold);
/*@}*/ /*@}*/
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
void tgt_tree_dump (FILE *fd, opj_tgt_tree_t * tree); void tgt_tree_dump (FILE *fd, opj_tgt_tree_t * tree);
/*@}*/ /*@}*/
#endif /* __TGT_H */ #endif /* __TGT_H */

View File

@ -1,91 +1,91 @@
/* /*
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "opj_includes.h" #include "opj_includes.h"
#include "volume.h" #include "volume.h"
#include "openjp3d.h" #include "openjp3d.h"
opj_volume_t* OPJ_CALLCONV opj_volume_create(int numcmpts, opj_volume_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) { opj_volume_t* OPJ_CALLCONV opj_volume_create(int numcmpts, opj_volume_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) {
int compno; int compno;
opj_volume_t *volume = NULL; opj_volume_t *volume = NULL;
volume = (opj_volume_t*)opj_malloc(sizeof(opj_volume_t)); volume = (opj_volume_t*)opj_malloc(sizeof(opj_volume_t));
if(volume) { if(volume) {
volume->color_space = clrspc; volume->color_space = clrspc;
volume->numcomps = numcmpts; volume->numcomps = numcmpts;
/* allocate memory for the per-component information */ /* allocate memory for the per-component information */
volume->comps = (opj_volume_comp_t*)opj_malloc(volume->numcomps * sizeof(opj_volume_comp_t)); volume->comps = (opj_volume_comp_t*)opj_malloc(volume->numcomps * sizeof(opj_volume_comp_t));
if(!volume->comps) { if(!volume->comps) {
opj_volume_destroy(volume); opj_volume_destroy(volume);
return NULL; return NULL;
} }
/* create the individual volume components */ /* create the individual volume components */
for(compno = 0; compno < numcmpts; compno++) { for(compno = 0; compno < numcmpts; compno++) {
opj_volume_comp_t *comp = &volume->comps[compno]; opj_volume_comp_t *comp = &volume->comps[compno];
comp->dx = cmptparms[compno].dx; comp->dx = cmptparms[compno].dx;
comp->dy = cmptparms[compno].dy; comp->dy = cmptparms[compno].dy;
comp->dz = cmptparms[compno].dz; comp->dz = cmptparms[compno].dz;
comp->w = cmptparms[compno].w; comp->w = cmptparms[compno].w;
comp->h = cmptparms[compno].h; comp->h = cmptparms[compno].h;
comp->l = cmptparms[compno].l; comp->l = cmptparms[compno].l;
comp->x0 = cmptparms[compno].x0; comp->x0 = cmptparms[compno].x0;
comp->y0 = cmptparms[compno].y0; comp->y0 = cmptparms[compno].y0;
comp->z0 = cmptparms[compno].z0; comp->z0 = cmptparms[compno].z0;
comp->prec = cmptparms[compno].prec; comp->prec = cmptparms[compno].prec;
comp->bpp = cmptparms[compno].bpp; comp->bpp = cmptparms[compno].bpp;
comp->sgnd = cmptparms[compno].sgnd; comp->sgnd = cmptparms[compno].sgnd;
comp->bigendian = cmptparms[compno].bigendian; comp->bigendian = cmptparms[compno].bigendian;
comp->dcoffset = cmptparms[compno].dcoffset; comp->dcoffset = cmptparms[compno].dcoffset;
comp->data = (int*)opj_malloc(comp->w * comp->h * comp->l * sizeof(int)); comp->data = (int*)opj_malloc(comp->w * comp->h * comp->l * sizeof(int));
if(!comp->data) { if(!comp->data) {
fprintf(stdout,"Unable to malloc comp->data (%d x %d x %d x bytes)",comp->w,comp->h,comp->l); fprintf(stdout,"Unable to malloc comp->data (%d x %d x %d x bytes)",comp->w,comp->h,comp->l);
opj_volume_destroy(volume); opj_volume_destroy(volume);
return NULL; return NULL;
} }
/*fprintf(stdout,"%d %d %d %d %d %d %d %d %d", comp->w,comp->h, comp->l, comp->dx, comp->dy, comp->dz, comp->prec, comp->bpp, comp->sgnd);*/ /*fprintf(stdout,"%d %d %d %d %d %d %d %d %d", comp->w,comp->h, comp->l, comp->dx, comp->dy, comp->dz, comp->prec, comp->bpp, comp->sgnd);*/
} }
} }
return volume; return volume;
} }
void OPJ_CALLCONV opj_volume_destroy(opj_volume_t *volume) { void OPJ_CALLCONV opj_volume_destroy(opj_volume_t *volume) {
int i; int i;
if(volume) { if(volume) {
if(volume->comps) { if(volume->comps) {
/* volume components */ /* volume components */
for(i = 0; i < volume->numcomps; i++) { for(i = 0; i < volume->numcomps; i++) {
opj_volume_comp_t *volume_comp = &volume->comps[i]; opj_volume_comp_t *volume_comp = &volume->comps[i];
if(volume_comp->data) { if(volume_comp->data) {
opj_free(volume_comp->data); opj_free(volume_comp->data);
} }
} }
opj_free(volume->comps); opj_free(volume->comps);
} }
opj_free(volume); opj_free(volume);
} }
} }

View File

@ -1,43 +1,43 @@
/* /*
* Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2006, Mónica Díez García, Image Processing Laboratory, University of Valladolid, Spain * Copyright (c) 2006, Mónica Díez García, Image Processing Laboratory, University of Valladolid, Spain
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __VOLUME_H #ifndef __VOLUME_H
#define __VOLUME_H #define __VOLUME_H
/** /**
@file volume.h @file volume.h
@brief Implementation of operations on volumes (VOLUME) @brief Implementation of operations on volumes (VOLUME)
The functions in VOLUME.C have for goal to realize operations on volumes. The functions in VOLUME.C have for goal to realize operations on volumes.
*/ */
/** @defgroup VOLUME VOLUME - Implementation of operations on volumes */ /** @defgroup VOLUME VOLUME - Implementation of operations on volumes */
/*@{*/ /*@{*/
/*@}*/ /*@}*/
#endif /* __VOLUME_H */ #endif /* __VOLUME_H */