From 34546ecb9b586f34e04f6e133a247ffe1f50046e Mon Sep 17 00:00:00 2001 From: giraffedata Date: Thu, 28 Sep 2023 02:40:42 +0000 Subject: Release 1.04.00 git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4700 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/other/jpeg2000/libjasper/jpc/jpc_bs.c | 528 +++---- converter/other/jpeg2000/libjasper/jpc/jpc_bs.h | 100 +- converter/other/jpeg2000/libjasper/jpc/jpc_cod.h | 28 +- converter/other/jpeg2000/libjasper/jpc/jpc_cs.c | 26 +- converter/other/jpeg2000/libjasper/jpc/jpc_cs.h | 544 +++---- converter/other/jpeg2000/libjasper/jpc/jpc_dec.c | 28 +- converter/other/jpeg2000/libjasper/jpc/jpc_dec.h | 694 ++++----- converter/other/jpeg2000/libjasper/jpc/jpc_enc.c | 26 +- converter/other/jpeg2000/libjasper/jpc/jpc_enc.h | 684 ++++----- converter/other/jpeg2000/libjasper/jpc/jpc_fix.h | 94 +- converter/other/jpeg2000/libjasper/jpc/jpc_flt.h | 26 +- converter/other/jpeg2000/libjasper/jpc/jpc_math.c | 72 +- converter/other/jpeg2000/libjasper/jpc/jpc_math.h | 46 +- converter/other/jpeg2000/libjasper/jpc/jpc_mct.c | 368 ++--- converter/other/jpeg2000/libjasper/jpc/jpc_mct.h | 32 +- converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.c | 214 +-- converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.h | 50 +- converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.c | 266 ++-- converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.h | 214 +-- converter/other/jpeg2000/libjasper/jpc/jpc_mqenc.h | 110 +- converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.c | 1578 ++++++++++---------- converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.h | 76 +- converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.c | 636 ++++---- converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.h | 204 +-- converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.c | 26 +- converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.h | 26 +- converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c | 28 +- converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.h | 26 +- converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.c | 1052 ++++++------- converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.h | 200 +-- converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.c | 886 +++++------ converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.h | 26 +- converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.c | 1070 ++++++------- converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.h | 26 +- .../other/jpeg2000/libjasper/jpc/jpc_tagtree.c | 466 +++--- .../other/jpeg2000/libjasper/jpc/jpc_tagtree.h | 60 +- converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.c | 852 +++++------ converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.h | 100 +- converter/other/jpeg2000/libjasper/jpc/jpc_util.c | 176 +-- converter/other/jpeg2000/libjasper/jpc/jpc_util.h | 26 +- 40 files changed, 5845 insertions(+), 5845 deletions(-) (limited to 'converter/other/jpeg2000/libjasper/jpc') diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_bs.c b/converter/other/jpeg2000/libjasper/jpc/jpc_bs.c index c66fcd99..3f693fff 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_bs.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_bs.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -137,66 +137,66 @@ /* Allocate a new bit stream. */ static jpc_bitstream_t *jpc_bitstream_alloc() { - jpc_bitstream_t *bitstream; - - /* Allocate memory for the new bit stream object. */ - if (!(bitstream = jas_malloc(sizeof(jpc_bitstream_t)))) { - return 0; - } - /* Initialize all of the data members. */ - bitstream->stream_ = 0; - bitstream->cnt_ = 0; - bitstream->flags_ = 0; - bitstream->openmode_ = 0; - - return bitstream; + jpc_bitstream_t *bitstream; + + /* Allocate memory for the new bit stream object. */ + if (!(bitstream = jas_malloc(sizeof(jpc_bitstream_t)))) { + return 0; + } + /* Initialize all of the data members. */ + bitstream->stream_ = 0; + bitstream->cnt_ = 0; + bitstream->flags_ = 0; + bitstream->openmode_ = 0; + + return bitstream; } /* Open a bit stream from a stream. */ jpc_bitstream_t *jpc_bitstream_sopen(jas_stream_t *stream, const char *mode) { - jpc_bitstream_t *bitstream; + jpc_bitstream_t *bitstream; - if (!(bitstream = jpc_bitstream_alloc())) { - return 0; - } + if (!(bitstream = jpc_bitstream_alloc())) { + return 0; + } - /* By default, do not close the underlying (character) stream, upon - the close of the bit stream. */ - bitstream->flags_ = JPC_BITSTREAM_NOCLOSE; + /* By default, do not close the underlying (character) stream, upon + the close of the bit stream. */ + bitstream->flags_ = JPC_BITSTREAM_NOCLOSE; - bitstream->stream_ = stream; - bitstream->openmode_ = (mode[0] == 'w') ? JPC_BITSTREAM_WRITE : - JPC_BITSTREAM_READ; + bitstream->stream_ = stream; + bitstream->openmode_ = (mode[0] == 'w') ? JPC_BITSTREAM_WRITE : + JPC_BITSTREAM_READ; - /* Mark the data buffer as empty. */ - bitstream->cnt_ = (bitstream->openmode_ == JPC_BITSTREAM_READ) ? 0 : 8; - bitstream->buf_ = 0; + /* Mark the data buffer as empty. */ + bitstream->cnt_ = (bitstream->openmode_ == JPC_BITSTREAM_READ) ? 0 : 8; + bitstream->buf_ = 0; - return bitstream; + return bitstream; } /* Close a bit stream. */ int jpc_bitstream_close(jpc_bitstream_t *bitstream) { - int ret = 0; - - /* Align to the next byte boundary while considering the effects of - bit stuffing. */ - if (jpc_bitstream_align(bitstream)) { - ret = -1; - } - - /* If necessary, close the underlying (character) stream. */ - if (!(bitstream->flags_ & JPC_BITSTREAM_NOCLOSE) && bitstream->stream_) { - if (jas_stream_close(bitstream->stream_)) { - ret = -1; - } - bitstream->stream_ = 0; - } - - jas_free(bitstream); - return ret; + int ret = 0; + + /* Align to the next byte boundary while considering the effects of + bit stuffing. */ + if (jpc_bitstream_align(bitstream)) { + ret = -1; + } + + /* If necessary, close the underlying (character) stream. */ + if (!(bitstream->flags_ & JPC_BITSTREAM_NOCLOSE) && bitstream->stream_) { + if (jas_stream_close(bitstream->stream_)) { + ret = -1; + } + bitstream->stream_ = 0; + } + + jas_free(bitstream); + return ret; } /******************************************************************************\ @@ -206,64 +206,64 @@ int jpc_bitstream_close(jpc_bitstream_t *bitstream) /* Get a bit from a bit stream. */ int jpc_bitstream_getbit_func(jpc_bitstream_t *bitstream) { - int ret; - JAS_DBGLOG(1000, ("jpc_bitstream_getbit_func(%p)\n", bitstream)); - ret = jpc_bitstream_getbit_macro(bitstream); - JAS_DBGLOG(1000, ("jpc_bitstream_getbit_func -> %d\n", ret)); - return ret; + int ret; + JAS_DBGLOG(1000, ("jpc_bitstream_getbit_func(%p)\n", bitstream)); + ret = jpc_bitstream_getbit_macro(bitstream); + JAS_DBGLOG(1000, ("jpc_bitstream_getbit_func -> %d\n", ret)); + return ret; } /* Put a bit to a bit stream. */ int jpc_bitstream_putbit_func(jpc_bitstream_t *bitstream, int b) { - int ret; - JAS_DBGLOG(1000, ("jpc_bitstream_putbit_func(%p, %d)\n", bitstream, b)); - ret = jpc_bitstream_putbit_macro(bitstream, b); - JAS_DBGLOG(1000, ("jpc_bitstream_putbit_func() -> %d\n", ret)); - return ret; + int ret; + JAS_DBGLOG(1000, ("jpc_bitstream_putbit_func(%p, %d)\n", bitstream, b)); + ret = jpc_bitstream_putbit_macro(bitstream, b); + JAS_DBGLOG(1000, ("jpc_bitstream_putbit_func() -> %d\n", ret)); + return ret; } /* Get one or more bits from a bit stream. */ long jpc_bitstream_getbits(jpc_bitstream_t *bitstream, int n) { - long v; - int u; - - /* We can reliably get at most 31 bits since ISO/IEC 9899 only - guarantees that a long can represent values up to 2^31-1. */ - assert(n >= 0 && n < 32); - - /* Get the number of bits requested from the specified bit stream. */ - v = 0; - while (--n >= 0) { - if ((u = jpc_bitstream_getbit(bitstream)) < 0) { - return -1; - } - v = (v << 1) | u; - } - return v; + long v; + int u; + + /* We can reliably get at most 31 bits since ISO/IEC 9899 only + guarantees that a long can represent values up to 2^31-1. */ + assert(n >= 0 && n < 32); + + /* Get the number of bits requested from the specified bit stream. */ + v = 0; + while (--n >= 0) { + if ((u = jpc_bitstream_getbit(bitstream)) < 0) { + return -1; + } + v = (v << 1) | u; + } + return v; } /* Put one or more bits to a bit stream. */ int jpc_bitstream_putbits(jpc_bitstream_t *bitstream, int n, long v) { - int m; - - /* We can reliably put at most 31 bits since ISO/IEC 9899 only - guarantees that a long can represent values up to 2^31-1. */ - assert(n >= 0 && n < 32); - /* Ensure that only the bits to be output are nonzero. */ - assert(!(v & (~JAS_ONES(n)))); - - /* Put the desired number of bits to the specified bit stream. */ - m = n - 1; - while (--n >= 0) { - if (jpc_bitstream_putbit(bitstream, (v >> m) & 1) == EOF) { - return EOF; - } - v <<= 1; - } - return 0; + int m; + + /* We can reliably put at most 31 bits since ISO/IEC 9899 only + guarantees that a long can represent values up to 2^31-1. */ + assert(n >= 0 && n < 32); + /* Ensure that only the bits to be output are nonzero. */ + assert(!(v & (~JAS_ONES(n)))); + + /* Put the desired number of bits to the specified bit stream. */ + m = n - 1; + while (--n >= 0) { + if (jpc_bitstream_putbit(bitstream, (v >> m) & 1) == EOF) { + return EOF; + } + v <<= 1; + } + return 0; } /******************************************************************************\ @@ -273,30 +273,30 @@ int jpc_bitstream_putbits(jpc_bitstream_t *bitstream, int n, long v) /* Fill the buffer for a bit stream. */ int jpc_bitstream_fillbuf(jpc_bitstream_t *bitstream) { - int c; - /* Note: The count has already been decremented by the caller. */ - assert(bitstream->openmode_ & JPC_BITSTREAM_READ); - assert(bitstream->cnt_ <= 0); - - if (bitstream->flags_ & JPC_BITSTREAM_ERR) { - bitstream->cnt_ = 0; - return -1; - } - - if (bitstream->flags_ & JPC_BITSTREAM_EOF) { - bitstream->buf_ = 0x7f; - bitstream->cnt_ = 7; - return 1; - } - - bitstream->buf_ = (bitstream->buf_ << 8) & 0xffff; - if ((c = jas_stream_getc((bitstream)->stream_)) == EOF) { - bitstream->flags_ |= JPC_BITSTREAM_EOF; - return 1; - } - bitstream->cnt_ = (bitstream->buf_ == 0xff00) ? 6 : 7; - bitstream->buf_ |= c & ((1 << (bitstream->cnt_ + 1)) - 1); - return (bitstream->buf_ >> bitstream->cnt_) & 1; + int c; + /* Note: The count has already been decremented by the caller. */ + assert(bitstream->openmode_ & JPC_BITSTREAM_READ); + assert(bitstream->cnt_ <= 0); + + if (bitstream->flags_ & JPC_BITSTREAM_ERR) { + bitstream->cnt_ = 0; + return -1; + } + + if (bitstream->flags_ & JPC_BITSTREAM_EOF) { + bitstream->buf_ = 0x7f; + bitstream->cnt_ = 7; + return 1; + } + + bitstream->buf_ = (bitstream->buf_ << 8) & 0xffff; + if ((c = jas_stream_getc((bitstream)->stream_)) == EOF) { + bitstream->flags_ |= JPC_BITSTREAM_EOF; + return 1; + } + bitstream->cnt_ = (bitstream->buf_ == 0xff00) ? 6 : 7; + bitstream->buf_ |= c & ((1 << (bitstream->cnt_ + 1)) - 1); + return (bitstream->buf_ >> bitstream->cnt_) & 1; } @@ -308,167 +308,167 @@ int jpc_bitstream_fillbuf(jpc_bitstream_t *bitstream) the effects of bit stuffing)? */ int jpc_bitstream_needalign(jpc_bitstream_t *bitstream) { - if (bitstream->openmode_ & JPC_BITSTREAM_READ) { - /* The bit stream is open for reading. */ - /* If there are any bits buffered for reading, or the - previous byte forced a stuffed bit, alignment is - required. */ - if ((bitstream->cnt_ < 8 && bitstream->cnt_ > 0) || - ((bitstream->buf_ >> 8) & 0xff) == 0xff) { - return 1; - } - } else if (bitstream->openmode_ & JPC_BITSTREAM_WRITE) { - /* The bit stream is open for writing. */ - /* If there are any bits buffered for writing, or the - previous byte forced a stuffed bit, alignment is - required. */ - if ((bitstream->cnt_ < 8 && bitstream->cnt_ >= 0) || - ((bitstream->buf_ >> 8) & 0xff) == 0xff) { - return 1; - } - } else { - /* This should not happen. Famous last words, eh? :-) */ - assert(0); - return -1; - } - return 0; + if (bitstream->openmode_ & JPC_BITSTREAM_READ) { + /* The bit stream is open for reading. */ + /* If there are any bits buffered for reading, or the + previous byte forced a stuffed bit, alignment is + required. */ + if ((bitstream->cnt_ < 8 && bitstream->cnt_ > 0) || + ((bitstream->buf_ >> 8) & 0xff) == 0xff) { + return 1; + } + } else if (bitstream->openmode_ & JPC_BITSTREAM_WRITE) { + /* The bit stream is open for writing. */ + /* If there are any bits buffered for writing, or the + previous byte forced a stuffed bit, alignment is + required. */ + if ((bitstream->cnt_ < 8 && bitstream->cnt_ >= 0) || + ((bitstream->buf_ >> 8) & 0xff) == 0xff) { + return 1; + } + } else { + /* This should not happen. Famous last words, eh? :-) */ + assert(0); + return -1; + } + return 0; } /* How many additional bytes would be output if we align the bit stream? */ int jpc_bitstream_pending(jpc_bitstream_t *bitstream) { - if (bitstream->openmode_ & JPC_BITSTREAM_WRITE) { - /* The bit stream is being used for writing. */ + if (bitstream->openmode_ & JPC_BITSTREAM_WRITE) { + /* The bit stream is being used for writing. */ #if 1 - /* XXX - Is this really correct? Check someday... */ - if (bitstream->cnt_ < 8) { - return 1; - } + /* XXX - Is this really correct? Check someday... */ + if (bitstream->cnt_ < 8) { + return 1; + } #else - if (bitstream->cnt_ < 8) { - if (((bitstream->buf_ >> 8) & 0xff) == 0xff) { - return 2; - } - return 1; - } + if (bitstream->cnt_ < 8) { + if (((bitstream->buf_ >> 8) & 0xff) == 0xff) { + return 2; + } + return 1; + } #endif - return 0; - } else { - /* This operation should not be invoked on a bit stream that - is being used for reading. */ - return -1; - } + return 0; + } else { + /* This operation should not be invoked on a bit stream that + is being used for reading. */ + return -1; + } } /* Align the bit stream to a byte boundary. */ int jpc_bitstream_align(jpc_bitstream_t *bitstream) { - int ret; - if (bitstream->openmode_ & JPC_BITSTREAM_READ) { - ret = jpc_bitstream_inalign(bitstream, 0, 0); - } else if (bitstream->openmode_ & JPC_BITSTREAM_WRITE) { - ret = jpc_bitstream_outalign(bitstream, 0); - } - return ret; + int ret; + if (bitstream->openmode_ & JPC_BITSTREAM_READ) { + ret = jpc_bitstream_inalign(bitstream, 0, 0); + } else if (bitstream->openmode_ & JPC_BITSTREAM_WRITE) { + ret = jpc_bitstream_outalign(bitstream, 0); + } + return ret; } /* Align a bit stream in the input case. */ int jpc_bitstream_inalign(jpc_bitstream_t *bitstream, int fillmask, int filldata) { - int n; - int v; - int u; - int numfill; - int m; - - numfill = 7; - m = 0; - v = 0; - if (bitstream->cnt_ > 0) { - n = bitstream->cnt_; - } else if (!bitstream->cnt_) { - n = ((bitstream->buf_ & 0xff) == 0xff) ? 7 : 0; - } else { - n = 0; - } - if (n > 0) { - if ((u = jpc_bitstream_getbits(bitstream, n)) < 0) { - return -1; - } - m += n; - v = (v << n) | u; - } - if ((bitstream->buf_ & 0xff) == 0xff) { - if ((u = jpc_bitstream_getbits(bitstream, 7)) < 0) { - return -1; - } - v = (v << 7) | u; - m += 7; - } - if (m > numfill) { - v >>= m - numfill; - } else { - filldata >>= numfill - m; - fillmask >>= numfill - m; - } - if (((~(v ^ filldata)) & fillmask) != fillmask) { - /* The actual fill pattern does not match the expected one. */ - return 1; - } - - return 0; + int n; + int v; + int u; + int numfill; + int m; + + numfill = 7; + m = 0; + v = 0; + if (bitstream->cnt_ > 0) { + n = bitstream->cnt_; + } else if (!bitstream->cnt_) { + n = ((bitstream->buf_ & 0xff) == 0xff) ? 7 : 0; + } else { + n = 0; + } + if (n > 0) { + if ((u = jpc_bitstream_getbits(bitstream, n)) < 0) { + return -1; + } + m += n; + v = (v << n) | u; + } + if ((bitstream->buf_ & 0xff) == 0xff) { + if ((u = jpc_bitstream_getbits(bitstream, 7)) < 0) { + return -1; + } + v = (v << 7) | u; + m += 7; + } + if (m > numfill) { + v >>= m - numfill; + } else { + filldata >>= numfill - m; + fillmask >>= numfill - m; + } + if (((~(v ^ filldata)) & fillmask) != fillmask) { + /* The actual fill pattern does not match the expected one. */ + return 1; + } + + return 0; } /* Align a bit stream in the output case. */ int jpc_bitstream_outalign(jpc_bitstream_t *bitstream, int filldata) { - int n; - int v; - - /* Ensure that this bit stream is open for writing. */ - assert(bitstream->openmode_ & JPC_BITSTREAM_WRITE); - - /* Ensure that the first bit of fill data is zero. */ - /* Note: The first bit of fill data must be zero. If this were not - the case, the fill data itself could cause further bit stuffing to - be required (which would cause numerous complications). */ - assert(!(filldata & (~0x3f))); - - if (!bitstream->cnt_) { - if ((bitstream->buf_ & 0xff) == 0xff) { - n = 7; - v = filldata; - } else { - n = 0; - v = 0; - } - } else if (bitstream->cnt_ > 0 && bitstream->cnt_ < 8) { - n = bitstream->cnt_; - v = filldata >> (7 - n); - } else { - n = 0; - v = 0; - return 0; - } - - /* Write the appropriate fill data to the bit stream. */ - if (n > 0) { - if (jpc_bitstream_putbits(bitstream, n, v)) { - return -1; - } - } - if (bitstream->cnt_ < 8) { - assert(bitstream->cnt_ >= 0 && bitstream->cnt_ < 8); - assert((bitstream->buf_ & 0xff) != 0xff); - /* Force the pending byte of output to be written to the - underlying (character) stream. */ - if (jas_stream_putc(bitstream->stream_, bitstream->buf_ & 0xff) == EOF) { - return -1; - } - bitstream->cnt_ = 8; - bitstream->buf_ = (bitstream->buf_ << 8) & 0xffff; - } - - return 0; + int n; + int v; + + /* Ensure that this bit stream is open for writing. */ + assert(bitstream->openmode_ & JPC_BITSTREAM_WRITE); + + /* Ensure that the first bit of fill data is zero. */ + /* Note: The first bit of fill data must be zero. If this were not + the case, the fill data itself could cause further bit stuffing to + be required (which would cause numerous complications). */ + assert(!(filldata & (~0x3f))); + + if (!bitstream->cnt_) { + if ((bitstream->buf_ & 0xff) == 0xff) { + n = 7; + v = filldata; + } else { + n = 0; + v = 0; + } + } else if (bitstream->cnt_ > 0 && bitstream->cnt_ < 8) { + n = bitstream->cnt_; + v = filldata >> (7 - n); + } else { + n = 0; + v = 0; + return 0; + } + + /* Write the appropriate fill data to the bit stream. */ + if (n > 0) { + if (jpc_bitstream_putbits(bitstream, n, v)) { + return -1; + } + } + if (bitstream->cnt_ < 8) { + assert(bitstream->cnt_ >= 0 && bitstream->cnt_ < 8); + assert((bitstream->buf_ & 0xff) != 0xff); + /* Force the pending byte of output to be written to the + underlying (character) stream. */ + if (jas_stream_putc(bitstream->stream_, bitstream->buf_ & 0xff) == EOF) { + return -1; + } + bitstream->cnt_ = 8; + bitstream->buf_ = (bitstream->buf_ << 8) & 0xffff; + } + + return 0; } diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_bs.h b/converter/other/jpeg2000/libjasper/jpc/jpc_bs.h index edb0a2df..2137a435 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_bs.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_bs.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -137,20 +137,20 @@ */ /* Bit stream open for reading. */ -#define JPC_BITSTREAM_READ 0x01 +#define JPC_BITSTREAM_READ 0x01 /* Bit stream open for writing. */ -#define JPC_BITSTREAM_WRITE 0x02 +#define JPC_BITSTREAM_WRITE 0x02 /* * Bit stream flags. */ /* Do not close underlying character stream. */ -#define JPC_BITSTREAM_NOCLOSE 0x01 +#define JPC_BITSTREAM_NOCLOSE 0x01 /* End of file has been reached while reading. */ -#define JPC_BITSTREAM_EOF 0x02 +#define JPC_BITSTREAM_EOF 0x02 /* An I/O error has occurred. */ -#define JPC_BITSTREAM_ERR 0x04 +#define JPC_BITSTREAM_ERR 0x04 /******************************************************************************\ * Types. @@ -160,20 +160,20 @@ typedef struct { - /* Some miscellaneous flags. */ - int flags_; + /* Some miscellaneous flags. */ + int flags_; - /* The input/output buffer. */ - uint_fast16_t buf_; + /* The input/output buffer. */ + uint_fast16_t buf_; - /* The number of bits remaining in the byte being read/written. */ - int cnt_; + /* The number of bits remaining in the byte being read/written. */ + int cnt_; - /* The underlying stream associated with this bit stream. */ - jas_stream_t *stream_; + /* The underlying stream associated with this bit stream. */ + jas_stream_t *stream_; - /* The mode in which this bit stream was opened. */ - int openmode_; + /* The mode in which this bit stream was opened. */ + int openmode_; } jpc_bitstream_t; @@ -193,20 +193,20 @@ int jpc_bitstream_close(jpc_bitstream_t *bitstream); /* Read a bit from a bit stream. */ #if defined(DEBUG) -#define jpc_bitstream_getbit(bitstream) \ - jpc_bitstream_getbit_func(bitstream) +#define jpc_bitstream_getbit(bitstream) \ + jpc_bitstream_getbit_func(bitstream) #else #define jpc_bitstream_getbit(bitstream) \ - jpc_bitstream_getbit_macro(bitstream) + jpc_bitstream_getbit_macro(bitstream) #endif /* Write a bit to a bit stream. */ #if defined(DEBUG) -#define jpc_bitstream_putbit(bitstream, v) \ - jpc_bitstream_putbit_func(bitstream, v) +#define jpc_bitstream_putbit(bitstream, v) \ + jpc_bitstream_putbit_func(bitstream, v) #else -#define jpc_bitstream_putbit(bitstream, v) \ - jpc_bitstream_putbit_macro(bitstream, v) +#define jpc_bitstream_putbit(bitstream, v) \ + jpc_bitstream_putbit_macro(bitstream, v) #endif /* Read one or more bits from a bit stream. */ @@ -245,7 +245,7 @@ int jpc_bitstream_pending(jpc_bitstream_t *bitstream); /* Has EOF been encountered on a bit stream? */ #define jpc_bitstream_eof(bitstream) \ - ((bitstream)->flags_ & JPC_BITSTREAM_EOF) + ((bitstream)->flags_ & JPC_BITSTREAM_EOF) /******************************************************************************\ * Internals. @@ -260,21 +260,21 @@ int jpc_bitstream_putbit_func(jpc_bitstream_t *bitstream, int v); int jpc_bitstream_fillbuf(jpc_bitstream_t *bitstream); -#define jpc_bitstream_getbit_macro(bitstream) \ - (assert((bitstream)->openmode_ & JPC_BITSTREAM_READ), \ - (--(bitstream)->cnt_ >= 0) ? \ - (((bitstream)->buf_ >> (bitstream)->cnt_) & 1) : \ - jpc_bitstream_fillbuf(bitstream)) +#define jpc_bitstream_getbit_macro(bitstream) \ + (assert((bitstream)->openmode_ & JPC_BITSTREAM_READ), \ + (--(bitstream)->cnt_ >= 0) ? \ + (((bitstream)->buf_ >> (bitstream)->cnt_) & 1) : \ + jpc_bitstream_fillbuf(bitstream)) #define jpc_bitstream_putbit_macro(bitstream, bit) \ - (assert((bitstream)->openmode_ & JPC_BITSTREAM_WRITE), \ - (--(bitstream)->cnt_ < 0) ? \ - ((bitstream)->buf_ = ((bitstream)->buf_ << 8) & 0xffff, \ - (bitstream)->cnt_ = ((bitstream)->buf_ == 0xff00) ? 6 : 7, \ - (bitstream)->buf_ |= ((bit) & 1) << (bitstream)->cnt_, \ - (jas_stream_putc((bitstream)->stream_, (bitstream)->buf_ >> 8) == EOF) \ - ? (EOF) : ((bit) & 1)) : \ - ((bitstream)->buf_ |= ((bit) & 1) << (bitstream)->cnt_, \ - (bit) & 1)) + (assert((bitstream)->openmode_ & JPC_BITSTREAM_WRITE), \ + (--(bitstream)->cnt_ < 0) ? \ + ((bitstream)->buf_ = ((bitstream)->buf_ << 8) & 0xffff, \ + (bitstream)->cnt_ = ((bitstream)->buf_ == 0xff00) ? 6 : 7, \ + (bitstream)->buf_ |= ((bit) & 1) << (bitstream)->cnt_, \ + (jas_stream_putc((bitstream)->stream_, (bitstream)->buf_ >> 8) == EOF) \ + ? (EOF) : ((bit) & 1)) : \ + ((bitstream)->buf_ |= ((bit) & 1) << (bitstream)->cnt_, \ + (bit) & 1)) #endif diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_cod.h b/converter/other/jpeg2000/libjasper/jpc/jpc_cod.h index 9b3ddbee..cff7e72b 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_cod.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_cod.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -122,6 +122,6 @@ \******************************************************************************/ /* The nominal word size used by this implementation. */ -#define JPC_PREC 32 +#define JPC_PREC 32 #endif diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_cs.c b/converter/other/jpeg2000/libjasper/jpc/jpc_cs.c index 559f36cf..441f8995 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_cs.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_cs.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_cs.h b/converter/other/jpeg2000/libjasper/jpc/jpc_cs.h index 4bff677c..13787d40 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_cs.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_cs.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -133,13 +133,13 @@ \******************************************************************************/ /* The maximum number of resolution levels. */ -#define JPC_MAXRLVLS 33 +#define JPC_MAXRLVLS 33 /* The maximum number of bands. */ -#define JPC_MAXBANDS (3 * JPC_MAXRLVLS + 1) +#define JPC_MAXBANDS (3 * JPC_MAXRLVLS + 1) /* The maximum number of layers. */ -#define JPC_MAXLYRS 16384 +#define JPC_MAXLYRS 16384 /**************************************\ * Code stream. @@ -150,15 +150,15 @@ */ /* Initial. */ -#define JPC_CS_INIT 0 +#define JPC_CS_INIT 0 /* Main header. */ -#define JPC_CS_MHDR 1 +#define JPC_CS_MHDR 1 /* Tile-part header. */ -#define JPC_CS_THDR 2 +#define JPC_CS_THDR 2 /* Main trailer. */ -#define JPC_CS_MTLR 3 +#define JPC_CS_MTLR 3 /* Tile-part data. */ -#define JPC_CS_TDATA 4 +#define JPC_CS_TDATA 4 /* * Unfortunately, the code stream syntax was not designed in such a way that @@ -174,8 +174,8 @@ typedef struct { - /* The number of components. */ - int numcomps; + /* The number of components. */ + int numcomps; } jpc_cstate_t; @@ -185,18 +185,18 @@ typedef struct { typedef struct { - /* The tile number. */ - uint_fast16_t tileno; + /* The tile number. */ + uint_fast16_t tileno; - /* The combined length of the marker segment and its auxiliary data - (i.e., packet data). */ - uint_fast32_t len; + /* The combined length of the marker segment and its auxiliary data + (i.e., packet data). */ + uint_fast32_t len; - /* The tile-part instance. */ - uint_fast8_t partno; + /* The tile-part instance. */ + uint_fast8_t partno; - /* The number of tile-parts. */ - uint_fast8_t numparts; + /* The number of tile-parts. */ + uint_fast8_t numparts; } jpc_sot_t; @@ -208,19 +208,19 @@ typedef struct { typedef struct { - /* The precision of the samples. */ - uint_fast8_t prec; + /* The precision of the samples. */ + uint_fast8_t prec; - /* The signedness of the samples. */ - uint_fast8_t sgnd; + /* The signedness of the samples. */ + uint_fast8_t sgnd; - /* The horizontal separation of samples with respect to the reference - grid. */ - uint_fast8_t hsamp; + /* The horizontal separation of samples with respect to the reference + grid. */ + uint_fast8_t hsamp; - /* The vertical separation of samples with respect to the reference - grid. */ - uint_fast8_t vsamp; + /* The vertical separation of samples with respect to the reference + grid. */ + uint_fast8_t vsamp; } jpc_sizcomp_t; @@ -228,42 +228,42 @@ typedef struct { typedef struct { - /* The code stream capabilities. */ - uint_fast16_t caps; + /* The code stream capabilities. */ + uint_fast16_t caps; - /* The width of the image in units of the reference grid. */ - uint_fast32_t width; + /* The width of the image in units of the reference grid. */ + uint_fast32_t width; - /* The height of the image in units of the reference grid. */ - uint_fast32_t height; + /* The height of the image in units of the reference grid. */ + uint_fast32_t height; - /* The horizontal offset from the origin of the reference grid to the - left side of the image area. */ - uint_fast32_t xoff; + /* The horizontal offset from the origin of the reference grid to the + left side of the image area. */ + uint_fast32_t xoff; - /* The vertical offset from the origin of the reference grid to the - top side of the image area. */ - uint_fast32_t yoff; + /* The vertical offset from the origin of the reference grid to the + top side of the image area. */ + uint_fast32_t yoff; - /* The nominal width of a tile in units of the reference grid. */ - uint_fast32_t tilewidth; + /* The nominal width of a tile in units of the reference grid. */ + uint_fast32_t tilewidth; - /* The nominal height of a tile in units of the reference grid. */ - uint_fast32_t tileheight; + /* The nominal height of a tile in units of the reference grid. */ + uint_fast32_t tileheight; - /* The horizontal offset from the origin of the reference grid to the - left side of the first tile. */ - uint_fast32_t tilexoff; + /* The horizontal offset from the origin of the reference grid to the + left side of the first tile. */ + uint_fast32_t tilexoff; - /* The vertical offset from the origin of the reference grid to the - top side of the first tile. */ - uint_fast32_t tileyoff; + /* The vertical offset from the origin of the reference grid to the + top side of the first tile. */ + uint_fast32_t tileyoff; - /* The number of components. */ - uint_fast16_t numcomps; + /* The number of components. */ + uint_fast16_t numcomps; - /* The per-component information. */ - jpc_sizcomp_t *comps; + /* The per-component information. */ + jpc_sizcomp_t *comps; } jpc_siz_t; @@ -276,11 +276,11 @@ typedef struct { */ /* Precincts may be used. */ -#define JPC_COX_PRT 0x01 +#define JPC_COX_PRT 0x01 /* SOP marker segments may be used. */ -#define JPC_COD_SOP 0x02 +#define JPC_COD_SOP 0x02 /* EPH marker segments may be used. */ -#define JPC_COD_EPH 0x04 +#define JPC_COD_EPH 0x04 /* * Progression order constants. @@ -288,50 +288,50 @@ typedef struct { /* Layer-resolution-component-precinct progressive (i.e., progressive by fidelity). */ -#define JPC_COD_LRCPPRG 0 +#define JPC_COD_LRCPPRG 0 /* Resolution-layer-component-precinct progressive (i.e., progressive by resolution). */ -#define JPC_COD_RLCPPRG 1 +#define JPC_COD_RLCPPRG 1 /* Resolution-precinct-component-layer progressive. */ -#define JPC_COD_RPCLPRG 2 +#define JPC_COD_RPCLPRG 2 /* Precinct-component-resolution-layer progressive. */ -#define JPC_COD_PCRLPRG 3 +#define JPC_COD_PCRLPRG 3 /* Component-position-resolution-layer progressive. */ -#define JPC_COD_CPRLPRG 4 +#define JPC_COD_CPRLPRG 4 /* * Code block style constants. */ -#define JPC_COX_LAZY 0x01 /* Selective arithmetic coding bypass. */ -#define JPC_COX_RESET 0x02 /* Reset context probabilities. */ -#define JPC_COX_TERMALL 0x04 /* Terminate all coding passes. */ -#define JPC_COX_VSC 0x08 /* Vertical stripe causal context formation. */ -#define JPC_COX_PTERM 0x10 /* Predictable termination. */ -#define JPC_COX_SEGSYM 0x20 /* Use segmentation symbols. */ +#define JPC_COX_LAZY 0x01 /* Selective arithmetic coding bypass. */ +#define JPC_COX_RESET 0x02 /* Reset context probabilities. */ +#define JPC_COX_TERMALL 0x04 /* Terminate all coding passes. */ +#define JPC_COX_VSC 0x08 /* Vertical stripe causal context formation. */ +#define JPC_COX_PTERM 0x10 /* Predictable termination. */ +#define JPC_COX_SEGSYM 0x20 /* Use segmentation symbols. */ /* Transform constants. */ -#define JPC_COX_INS 0x00 /* Irreversible 9/7. */ -#define JPC_COX_RFT 0x01 /* Reversible 5/3. */ +#define JPC_COX_INS 0x00 /* Irreversible 9/7. */ +#define JPC_COX_RFT 0x01 /* Reversible 5/3. */ /* Multicomponent transform constants. */ -#define JPC_COD_NOMCT 0x00 /* No multicomponent transform. */ -#define JPC_COD_MCT 0x01 /* Multicomponent transform. */ +#define JPC_COD_NOMCT 0x00 /* No multicomponent transform. */ +#define JPC_COD_MCT 0x01 /* Multicomponent transform. */ /* Get the code block size value from the code block size exponent. */ -#define JPC_COX_CBLKSIZEEXPN(x) ((x) - 2) +#define JPC_COX_CBLKSIZEEXPN(x) ((x) - 2) /* Get the code block size exponent from the code block size value. */ -#define JPC_COX_GETCBLKSIZEEXPN(x) ((x) + 2) +#define JPC_COX_GETCBLKSIZEEXPN(x) ((x) + 2) /* Per resolution-level information. */ typedef struct { - /* The packet partition width. */ - uint_fast8_t parwidthval; + /* The packet partition width. */ + uint_fast8_t parwidthval; - /* The packet partition height. */ - uint_fast8_t parheightval; + /* The packet partition height. */ + uint_fast8_t parheightval; } jpc_coxrlvl_t; @@ -339,29 +339,29 @@ typedef struct { typedef struct { - /* The coding style. */ - uint_fast8_t csty; + /* The coding style. */ + uint_fast8_t csty; - /* The number of decomposition levels. */ - uint_fast8_t numdlvls; + /* The number of decomposition levels. */ + uint_fast8_t numdlvls; - /* The nominal code block width specifier. */ - uint_fast8_t cblkwidthval; + /* The nominal code block width specifier. */ + uint_fast8_t cblkwidthval; - /* The nominal code block height specifier. */ - uint_fast8_t cblkheightval; + /* The nominal code block height specifier. */ + uint_fast8_t cblkheightval; - /* The style of coding passes. */ - uint_fast8_t cblksty; + /* The style of coding passes. */ + uint_fast8_t cblksty; - /* The QMFB employed. */ - uint_fast8_t qmfbid; + /* The QMFB employed. */ + uint_fast8_t qmfbid; - /* The number of resolution levels. */ - int numrlvls; + /* The number of resolution levels. */ + int numrlvls; - /* The per-resolution-level information. */ - jpc_coxrlvl_t rlvls[JPC_MAXRLVLS]; + /* The per-resolution-level information. */ + jpc_coxrlvl_t rlvls[JPC_MAXRLVLS]; } jpc_coxcp_t; @@ -369,20 +369,20 @@ typedef struct { typedef struct { - /* The general coding style. */ - uint_fast8_t csty; + /* The general coding style. */ + uint_fast8_t csty; - /* The progression order. */ - uint_fast8_t prg; + /* The progression order. */ + uint_fast8_t prg; - /* The number of layers. */ - uint_fast16_t numlyrs; + /* The number of layers. */ + uint_fast16_t numlyrs; - /* The multicomponent transform. */ - uint_fast8_t mctrans; + /* The multicomponent transform. */ + uint_fast8_t mctrans; - /* Component-related parameters. */ - jpc_coxcp_t compparms; + /* Component-related parameters. */ + jpc_coxcp_t compparms; } jpc_cod_t; @@ -390,11 +390,11 @@ typedef struct { typedef struct { - /* The component number. */ - uint_fast16_t compno; + /* The component number. */ + uint_fast16_t compno; - /* Component-related parameters. */ - jpc_coxcp_t compparms; + /* Component-related parameters. */ + jpc_coxcp_t compparms; } jpc_coc_t; @@ -403,18 +403,18 @@ typedef struct { \**************************************/ /* The maxshift ROI style. */ -#define JPC_RGN_MAXSHIFT 0x00 +#define JPC_RGN_MAXSHIFT 0x00 typedef struct { - /* The component to which the marker applies. */ - uint_fast16_t compno; + /* The component to which the marker applies. */ + uint_fast16_t compno; - /* The ROI style. */ - uint_fast8_t roisty; + /* The ROI style. */ + uint_fast8_t roisty; - /* The ROI shift value. */ - uint_fast8_t roishift; + /* The ROI shift value. */ + uint_fast8_t roishift; } jpc_rgn_t; @@ -426,34 +426,34 @@ typedef struct { * Quantization style constants. */ -#define JPC_QCX_NOQNT 0 /* No quantization. */ -#define JPC_QCX_SIQNT 1 /* Scalar quantization, implicit. */ -#define JPC_QCX_SEQNT 2 /* Scalar quantization, explicit. */ +#define JPC_QCX_NOQNT 0 /* No quantization. */ +#define JPC_QCX_SIQNT 1 /* Scalar quantization, implicit. */ +#define JPC_QCX_SEQNT 2 /* Scalar quantization, explicit. */ /* * Stepsize manipulation macros. */ -#define JPC_QCX_GETEXPN(x) ((x) >> 11) -#define JPC_QCX_GETMANT(x) ((x) & 0x07ff) -#define JPC_QCX_EXPN(x) (assert(!((x) & (~0x1f))), (((x) & 0x1f) << 11)) -#define JPC_QCX_MANT(x) (assert(!((x) & (~0x7ff))), ((x) & 0x7ff)) +#define JPC_QCX_GETEXPN(x) ((x) >> 11) +#define JPC_QCX_GETMANT(x) ((x) & 0x07ff) +#define JPC_QCX_EXPN(x) (assert(!((x) & (~0x1f))), (((x) & 0x1f) << 11)) +#define JPC_QCX_MANT(x) (assert(!((x) & (~0x7ff))), ((x) & 0x7ff)) /* Per component information. */ typedef struct { - /* The quantization style. */ - uint_fast8_t qntsty; + /* The quantization style. */ + uint_fast8_t qntsty; - /* The number of step sizes. */ - int numstepsizes; + /* The number of step sizes. */ + int numstepsizes; - /* The step sizes. */ - uint_fast16_t *stepsizes; + /* The step sizes. */ + uint_fast16_t *stepsizes; - /* The number of guard bits. */ - uint_fast8_t numguard; + /* The number of guard bits. */ + uint_fast8_t numguard; } jpc_qcxcp_t; @@ -461,11 +461,11 @@ typedef struct { typedef struct { - /* The component associated with this marker segment. */ - uint_fast16_t compno; + /* The component associated with this marker segment. */ + uint_fast16_t compno; - /* The parameters. */ - jpc_qcxcp_t compparms; + /* The parameters. */ + jpc_qcxcp_t compparms; } jpc_qcc_t; @@ -473,8 +473,8 @@ typedef struct { typedef struct { - /* The parameters. */ - jpc_qcxcp_t compparms; + /* The parameters. */ + jpc_qcxcp_t compparms; } jpc_qcd_t; @@ -484,28 +484,28 @@ typedef struct { typedef struct { - /* The progression order. */ - uint_fast8_t prgord; + /* The progression order. */ + uint_fast8_t prgord; - /* The lower bound (inclusive) on the resolution level for the - progression order volume. */ - uint_fast8_t rlvlnostart; + /* The lower bound (inclusive) on the resolution level for the + progression order volume. */ + uint_fast8_t rlvlnostart; - /* The upper bound (exclusive) on the resolution level for the - progression order volume. */ - uint_fast8_t rlvlnoend; + /* The upper bound (exclusive) on the resolution level for the + progression order volume. */ + uint_fast8_t rlvlnoend; - /* The lower bound (inclusive) on the component for the progression - order volume. */ - uint_fast16_t compnostart; + /* The lower bound (inclusive) on the component for the progression + order volume. */ + uint_fast16_t compnostart; - /* The upper bound (exclusive) on the component for the progression - order volume. */ - uint_fast16_t compnoend; + /* The upper bound (exclusive) on the component for the progression + order volume. */ + uint_fast16_t compnoend; - /* The upper bound (exclusive) on the layer for the progression - order volume. */ - uint_fast16_t lyrnoend; + /* The upper bound (exclusive) on the layer for the progression + order volume. */ + uint_fast16_t lyrnoend; } jpc_pocpchg_t; @@ -516,11 +516,11 @@ typedef jpc_pocpchg_t jpc_pchg_t; typedef struct { - /* The number of progression order changes. */ - int numpchgs; + /* The number of progression order changes. */ + int numpchgs; - /* The per-progression-order-change information. */ - jpc_pocpchg_t *pchgs; + /* The per-progression-order-change information. */ + jpc_pocpchg_t *pchgs; } jpc_poc_t; @@ -532,14 +532,14 @@ typedef struct { typedef struct { - /* The index. */ - uint_fast8_t ind; + /* The index. */ + uint_fast8_t ind; - /* The length. */ - uint_fast16_t len; + /* The length. */ + uint_fast16_t len; - /* The data. */ - unsigned char *data; + /* The data. */ + unsigned char *data; } jpc_ppm_t; @@ -547,14 +547,14 @@ typedef struct { typedef struct { - /* The index. */ - uint_fast8_t ind; + /* The index. */ + uint_fast8_t ind; - /* The length. */ - uint_fast32_t len; + /* The length. */ + uint_fast32_t len; - /* The data. */ - unsigned char *data; + /* The data. */ + unsigned char *data; } jpc_ppt_t; @@ -566,19 +566,19 @@ typedef struct { * Registration IDs. */ -#define JPC_COM_BIN 0x00 -#define JPC_COM_LATIN 0x01 +#define JPC_COM_BIN 0x00 +#define JPC_COM_LATIN 0x01 typedef struct { - /* The registration ID. */ - uint_fast16_t regid; + /* The registration ID. */ + uint_fast16_t regid; - /* The length of the data in bytes. */ - uint_fast16_t len; + /* The length of the data in bytes. */ + uint_fast16_t len; - /* The data. */ - unsigned char *data; + /* The data. */ + unsigned char *data; } jpc_com_t; @@ -588,8 +588,8 @@ typedef struct { typedef struct { - /* The sequence number. */ - uint_fast16_t seqno; + /* The sequence number. */ + uint_fast16_t seqno; } jpc_sop_t; @@ -601,21 +601,21 @@ typedef struct { typedef struct { - /* The horizontal offset. */ - uint_fast16_t hoff; + /* The horizontal offset. */ + uint_fast16_t hoff; - /* The vertical offset. */ - uint_fast16_t voff; + /* The vertical offset. */ + uint_fast16_t voff; } jpc_crgcomp_t; typedef struct { - /* The number of components. */ - int numcomps; + /* The number of components. */ + int numcomps; - /* Per component information. */ - jpc_crgcomp_t *comps; + /* Per component information. */ + jpc_crgcomp_t *comps; } jpc_crg_t; @@ -625,11 +625,11 @@ typedef struct { typedef struct { - /* The data. */ - unsigned char *data; + /* The data. */ + unsigned char *data; - /* The length. */ - uint_fast16_t len; + /* The length. */ + uint_fast16_t len; } jpc_unk_t; @@ -638,26 +638,26 @@ typedef struct { \**************************************/ typedef union { - int soc; /* unused */ - jpc_sot_t sot; - int sod; /* unused */ - int eoc; /* unused */ - jpc_siz_t siz; - jpc_cod_t cod; - jpc_coc_t coc; - jpc_rgn_t rgn; - jpc_qcd_t qcd; - jpc_qcc_t qcc; - jpc_poc_t poc; - /* jpc_plm_t plm; */ - /* jpc_plt_t plt; */ - jpc_ppm_t ppm; - jpc_ppt_t ppt; - jpc_sop_t sop; - int eph; /* unused */ - jpc_com_t com; - jpc_crg_t crg; - jpc_unk_t unk; + int soc; /* unused */ + jpc_sot_t sot; + int sod; /* unused */ + int eoc; /* unused */ + jpc_siz_t siz; + jpc_cod_t cod; + jpc_coc_t coc; + jpc_rgn_t rgn; + jpc_qcd_t qcd; + jpc_qcc_t qcc; + jpc_poc_t poc; + /* jpc_plm_t plm; */ + /* jpc_plt_t plt; */ + jpc_ppm_t ppm; + jpc_ppt_t ppt; + jpc_sop_t sop; + int eph; /* unused */ + jpc_com_t com; + jpc_crg_t crg; + jpc_unk_t unk; } jpc_msparms_t; /**************************************\ @@ -667,47 +667,47 @@ typedef union { /* Marker segment IDs. */ /* The smallest valid marker value. */ -#define JPC_MS_MIN 0xff00 +#define JPC_MS_MIN 0xff00 /* The largest valid marker value. */ -#define JPC_MS_MAX 0xffff +#define JPC_MS_MAX 0xffff /* The minimum marker value that cannot occur within packet data. */ -#define JPC_MS_INMIN 0xff80 +#define JPC_MS_INMIN 0xff80 /* The maximum marker value that cannot occur within packet data. */ -#define JPC_MS_INMAX 0xffff +#define JPC_MS_INMAX 0xffff /* Delimiting marker segments. */ -#define JPC_MS_SOC 0xff4f /* Start of code stream (SOC). */ -#define JPC_MS_SOT 0xff90 /* Start of tile-part (SOT). */ -#define JPC_MS_SOD 0xff93 /* Start of data (SOD). */ -#define JPC_MS_EOC 0xffd9 /* End of code stream (EOC). */ +#define JPC_MS_SOC 0xff4f /* Start of code stream (SOC). */ +#define JPC_MS_SOT 0xff90 /* Start of tile-part (SOT). */ +#define JPC_MS_SOD 0xff93 /* Start of data (SOD). */ +#define JPC_MS_EOC 0xffd9 /* End of code stream (EOC). */ /* Fixed information marker segments. */ -#define JPC_MS_SIZ 0xff51 /* Image and tile size (SIZ). */ +#define JPC_MS_SIZ 0xff51 /* Image and tile size (SIZ). */ /* Functional marker segments. */ -#define JPC_MS_COD 0xff52 /* Coding style default (COD). */ -#define JPC_MS_COC 0xff53 /* Coding style component (COC). */ -#define JPC_MS_RGN 0xff5e /* Region of interest (RGN). */ -#define JPC_MS_QCD 0xff5c /* Quantization default (QCD). */ -#define JPC_MS_QCC 0xff5d /* Quantization component (QCC). */ -#define JPC_MS_POC 0xff5f /* Progression order default (POC). */ +#define JPC_MS_COD 0xff52 /* Coding style default (COD). */ +#define JPC_MS_COC 0xff53 /* Coding style component (COC). */ +#define JPC_MS_RGN 0xff5e /* Region of interest (RGN). */ +#define JPC_MS_QCD 0xff5c /* Quantization default (QCD). */ +#define JPC_MS_QCC 0xff5d /* Quantization component (QCC). */ +#define JPC_MS_POC 0xff5f /* Progression order default (POC). */ /* Pointer marker segments. */ -#define JPC_MS_TLM 0xff55 /* Tile-part lengths, main header (TLM). */ -#define JPC_MS_PLM 0xff57 /* Packet length, main header (PLM). */ -#define JPC_MS_PLT 0xff58 /* Packet length, tile-part header (PLT). */ -#define JPC_MS_PPM 0xff60 /* Packed packet headers, main header (PPM). */ -#define JPC_MS_PPT 0xff61 /* Packet packet headers, tile-part header (PPT). */ +#define JPC_MS_TLM 0xff55 /* Tile-part lengths, main header (TLM). */ +#define JPC_MS_PLM 0xff57 /* Packet length, main header (PLM). */ +#define JPC_MS_PLT 0xff58 /* Packet length, tile-part header (PLT). */ +#define JPC_MS_PPM 0xff60 /* Packed packet headers, main header (PPM). */ +#define JPC_MS_PPT 0xff61 /* Packet packet headers, tile-part header (PPT). */ /* In bit stream marker segments. */ -#define JPC_MS_SOP 0xff91 /* Start of packet (SOP). */ -#define JPC_MS_EPH 0xff92 /* End of packet header (EPH). */ +#define JPC_MS_SOP 0xff91 /* Start of packet (SOP). */ +#define JPC_MS_EPH 0xff92 /* End of packet header (EPH). */ /* Informational marker segments. */ -#define JPC_MS_CRG 0xff63 /* Component registration (CRG). */ -#define JPC_MS_COM 0xff64 /* Comment (COM). */ +#define JPC_MS_CRG 0xff63 /* Component registration (CRG). */ +#define JPC_MS_COM 0xff64 /* Comment (COM). */ /* Forward declaration. */ struct jpc_msops_s; @@ -716,20 +716,20 @@ struct jpc_msops_s; typedef struct { - /* The type of marker segment. */ - uint_fast16_t id; + /* The type of marker segment. */ + uint_fast16_t id; - /* The length of the marker segment. */ - uint_fast16_t len; + /* The length of the marker segment. */ + uint_fast16_t len; - /* The starting offset within the stream. */ - uint_fast32_t off; + /* The starting offset within the stream. */ + uint_fast32_t off; - /* The parameters of the marker segment. */ - jpc_msparms_t parms; + /* The parameters of the marker segment. */ + jpc_msparms_t parms; - /* The marker segment operations. */ - struct jpc_msops_s *ops; + /* The marker segment operations. */ + struct jpc_msops_s *ops; } jpc_ms_t; @@ -737,17 +737,17 @@ typedef struct { typedef struct jpc_msops_s { - /* Destroy the marker segment parameters. */ - void (*destroyparms)(jpc_ms_t *ms); + /* Destroy the marker segment parameters. */ + void (*destroyparms)(jpc_ms_t *ms); - /* Get the marker segment parameters from a stream. */ - int (*getparms)(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in); + /* Get the marker segment parameters from a stream. */ + int (*getparms)(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in); - /* Put the marker segment parameters to a stream. */ - int (*putparms)(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *out); + /* Put the marker segment parameters to a stream. */ + int (*putparms)(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *out); - /* Dump the marker segment parameters (for debugging). */ - int (*dumpparms)(jpc_ms_t *ms, FILE *out); + /* Dump the marker segment parameters (for debugging). */ + int (*dumpparms)(jpc_ms_t *ms, FILE *out); } jpc_msops_t; @@ -768,13 +768,13 @@ jpc_ms_t *jpc_ms_create(int type); void jpc_ms_destroy(jpc_ms_t *ms); /* Does a marker segment have parameters? */ -#define JPC_MS_HASPARMS(x) \ - (!((x) == JPC_MS_SOC || (x) == JPC_MS_SOD || (x) == JPC_MS_EOC || \ - (x) == JPC_MS_EPH || ((x) >= 0xff30 && (x) <= 0xff3f))) +#define JPC_MS_HASPARMS(x) \ + (!((x) == JPC_MS_SOC || (x) == JPC_MS_SOD || (x) == JPC_MS_EOC || \ + (x) == JPC_MS_EPH || ((x) >= 0xff30 && (x) <= 0xff3f))) /* Get the marker segment type. */ -#define jpc_ms_gettype(ms) \ - ((ms)->id) +#define jpc_ms_gettype(ms) \ + ((ms)->id) /* Read a marker segment from a stream. */ jpc_ms_t *jpc_getms(jas_stream_t *in, jpc_cstate_t *cstate); diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c index 140169ec..1cca46b7 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -793,7 +793,7 @@ rlvl->bands = 0; rlvl->numhprcs = 0; rlvl->numvprcs = 0; continue; - } + } if (!rlvlno) { tlcbgxstart = tlprcxstart; tlcbgystart = tlprcystart; diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.h b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.h index fe0e9616..11fceb36 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -141,14 +141,14 @@ typedef struct { - /* The index for this entry. */ - uint_fast16_t ind; + /* The index for this entry. */ + uint_fast16_t ind; - /* The data length. */ - uint_fast32_t len; + /* The data length. */ + uint_fast32_t len; - /* The data. */ - unsigned char *data; + /* The data. */ + unsigned char *data; } jpc_ppxstabent_t; @@ -156,15 +156,15 @@ typedef struct { typedef struct { - /* The number of entries. */ - int numents; + /* The number of entries. */ + int numents; - /* The maximum number of entries (i.e., the allocated size of the array - below). */ - int maxents; + /* The maximum number of entries (i.e., the allocated size of the array + below). */ + int maxents; - /* The table entries. */ - jpc_ppxstabent_t **ents; + /* The table entries. */ + jpc_ppxstabent_t **ents; } jpc_ppxstab_t; @@ -172,15 +172,15 @@ typedef struct { typedef struct { - /* The number of streams in this list. */ - int numstreams; + /* The number of streams in this list. */ + int numstreams; - /* The maximum number of streams that can be accommodated without - growing the streams array. */ - int maxstreams; + /* The maximum number of streams that can be accommodated without + growing the streams array. */ + int maxstreams; - /* The streams. */ - jas_stream_t **streams; + /* The streams. */ + jas_stream_t **streams; } jpc_streamlist_t; @@ -192,47 +192,47 @@ typedef struct { typedef struct { - /* How were various coding parameters set? */ - int flags; + /* How were various coding parameters set? */ + int flags; - /* Per-component coding style parameters (e.g., explicit precinct sizes) */ - uint_fast8_t csty; + /* Per-component coding style parameters (e.g., explicit precinct sizes) */ + uint_fast8_t csty; - /* The number of resolution levels. */ - uint_fast8_t numrlvls; + /* The number of resolution levels. */ + uint_fast8_t numrlvls; - /* The code block width exponent. */ - uint_fast8_t cblkwidthexpn; + /* The code block width exponent. */ + uint_fast8_t cblkwidthexpn; - /* The code block height exponent. */ - uint_fast8_t cblkheightexpn; + /* The code block height exponent. */ + uint_fast8_t cblkheightexpn; - /* The QMFB ID. */ - uint_fast8_t qmfbid; + /* The QMFB ID. */ + uint_fast8_t qmfbid; - /* The quantization style. */ - uint_fast8_t qsty; + /* The quantization style. */ + uint_fast8_t qsty; - /* The number of quantizer step sizes. */ - uint_fast16_t numstepsizes; + /* The number of quantizer step sizes. */ + uint_fast16_t numstepsizes; - /* The step sizes. */ - uint_fast16_t stepsizes[3 * JPC_MAXRLVLS + 1]; + /* The step sizes. */ + uint_fast16_t stepsizes[3 * JPC_MAXRLVLS + 1]; - /* The number of guard bits. */ - uint_fast8_t numguardbits; + /* The number of guard bits. */ + uint_fast8_t numguardbits; - /* The ROI shift value. */ - uint_fast8_t roishift; + /* The ROI shift value. */ + uint_fast8_t roishift; - /* The code block parameters. */ - uint_fast8_t cblkctx; + /* The code block parameters. */ + uint_fast8_t cblkctx; - /* The precinct width exponents. */ - uint_fast8_t prcwidthexpns[JPC_MAXRLVLS]; + /* The precinct width exponents. */ + uint_fast8_t prcwidthexpns[JPC_MAXRLVLS]; - /* The precinct height exponents. */ - uint_fast8_t prcheightexpns[JPC_MAXRLVLS]; + /* The precinct height exponents. */ + uint_fast8_t prcheightexpns[JPC_MAXRLVLS]; } jpc_dec_ccp_t; @@ -240,29 +240,29 @@ typedef struct { typedef struct { - /* How were these coding parameters set? */ - int flags; + /* How were these coding parameters set? */ + int flags; - /* Progression change list. */ - jpc_pchglist_t *pchglist; + /* Progression change list. */ + jpc_pchglist_t *pchglist; - /* Progression order. */ - uint_fast8_t prgord; + /* Progression order. */ + uint_fast8_t prgord; - /* The number of layers. */ - uint_fast16_t numlyrs; + /* The number of layers. */ + uint_fast16_t numlyrs; - /* The MCT ID. */ - uint_fast8_t mctid; + /* The MCT ID. */ + uint_fast8_t mctid; - /* The coding style parameters (e.g., SOP, EPH). */ - uint_fast8_t csty; + /* The coding style parameters (e.g., SOP, EPH). */ + uint_fast8_t csty; - /* The number of components. */ - uint_fast16_t numcomps; + /* The number of components. */ + uint_fast16_t numcomps; - /* The per-component coding parameters. */ - jpc_dec_ccp_t *ccps; + /* The per-component coding parameters. */ + jpc_dec_ccp_t *ccps; } jpc_dec_cp_t; @@ -274,38 +274,38 @@ typedef struct { typedef struct jpc_dec_seg_s { - /* The next segment in the list. */ - struct jpc_dec_seg_s *next; + /* The next segment in the list. */ + struct jpc_dec_seg_s *next; - /* The previous segment in the list. */ - struct jpc_dec_seg_s *prev; + /* The previous segment in the list. */ + struct jpc_dec_seg_s *prev; - /* The starting pass number for this segment. */ - int passno; + /* The starting pass number for this segment. */ + int passno; - /* The number of passes in this segment. */ - int numpasses; + /* The number of passes in this segment. */ + int numpasses; - /* The maximum number of passes in this segment. */ - int maxpasses; + /* The maximum number of passes in this segment. */ + int maxpasses; - /* The type of data in this segment (i.e., MQ or raw). */ - int type; + /* The type of data in this segment (i.e., MQ or raw). */ + int type; - /* A stream containing the data for this segment. */ - jas_stream_t *stream; + /* A stream containing the data for this segment. */ + jas_stream_t *stream; - /* The number of bytes destined for this segment from the packet - currently being decoded. */ - int cnt; + /* The number of bytes destined for this segment from the packet + currently being decoded. */ + int cnt; - /* A flag indicating if this segment has been terminated. */ - int complete; + /* A flag indicating if this segment has been terminated. */ + int complete; - /* The layer number to which this segment belongs. */ - /* If the segment spans multiple layers, then the largest layer number - spanned by the segment is used. */ - int lyrno; + /* The layer number to which this segment belongs. */ + /* If the segment spans multiple layers, then the largest layer number + spanned by the segment is used. */ + int lyrno; } jpc_dec_seg_t; @@ -313,11 +313,11 @@ typedef struct jpc_dec_seg_s { typedef struct { - /* The first entry in the list. */ - jpc_dec_seg_t *head; + /* The first entry in the list. */ + jpc_dec_seg_t *head; - /* The last entry in the list. */ - jpc_dec_seg_t *tail; + /* The last entry in the list. */ + jpc_dec_seg_t *tail; } jpc_dec_seglist_t; @@ -325,35 +325,35 @@ typedef struct { typedef struct { - /* The number of passes. */ - int numpasses; + /* The number of passes. */ + int numpasses; - /* A list of segments that still need to be decoded. */ - jpc_dec_seglist_t segs; + /* A list of segments that still need to be decoded. */ + jpc_dec_seglist_t segs; - /* The first incomplete/partial segment. */ - jpc_dec_seg_t *curseg; + /* The first incomplete/partial segment. */ + jpc_dec_seg_t *curseg; - /* The number of leading insignificant bit planes for this code block. */ - int numimsbs; + /* The number of leading insignificant bit planes for this code block. */ + int numimsbs; - /* The number of bits used to encode pass data lengths. */ - int numlenbits; + /* The number of bits used to encode pass data lengths. */ + int numlenbits; - /* The first pass number containing data for this code block. */ - int firstpassno; + /* The first pass number containing data for this code block. */ + int firstpassno; - /* The MQ decoder. */ - jpc_mqdec_t *mqdec; + /* The MQ decoder. */ + jpc_mqdec_t *mqdec; - /* The raw bit stream decoder. */ - jpc_bitstream_t *nulldec; + /* The raw bit stream decoder. */ + jpc_bitstream_t *nulldec; - /* The per-sample state information for this code block. */ - jas_matrix_t *flags; + /* The per-sample state information for this code block. */ + jas_matrix_t *flags; - /* The sample data associated with this code block. */ - jas_matrix_t *data; + /* The sample data associated with this code block. */ + jas_matrix_t *data; } jpc_dec_cblk_t; @@ -361,39 +361,39 @@ typedef struct { typedef struct { - /* The x-coordinate of the top-left corner of the precinct. */ - uint_fast32_t xstart; + /* The x-coordinate of the top-left corner of the precinct. */ + uint_fast32_t xstart; - /* The y-coordinate of the top-left corner of the precinct. */ - uint_fast32_t ystart; + /* The y-coordinate of the top-left corner of the precinct. */ + uint_fast32_t ystart; - /* The x-coordinate of the bottom-right corner of the precinct - (plus one). */ - uint_fast32_t xend; + /* The x-coordinate of the bottom-right corner of the precinct + (plus one). */ + uint_fast32_t xend; - /* The y-coordinate of the bottom-right corner of the precinct - (plus one). */ - uint_fast32_t yend; + /* The y-coordinate of the bottom-right corner of the precinct + (plus one). */ + uint_fast32_t yend; - /* The number of code blocks spanning this precinct in the horizontal - direction. */ - int numhcblks; + /* The number of code blocks spanning this precinct in the horizontal + direction. */ + int numhcblks; - /* The number of code blocks spanning this precinct in the vertical - direction. */ - int numvcblks; + /* The number of code blocks spanning this precinct in the vertical + direction. */ + int numvcblks; - /* The total number of code blocks in this precinct. */ - int numcblks; + /* The total number of code blocks in this precinct. */ + int numcblks; - /* The per code block information. */ - jpc_dec_cblk_t *cblks; + /* The per code block information. */ + jpc_dec_cblk_t *cblks; - /* The inclusion tag tree. */ - jpc_tagtree_t *incltagtree; + /* The inclusion tag tree. */ + jpc_tagtree_t *incltagtree; - /* The insignificant MSBs tag tree. */ - jpc_tagtree_t *numimsbstagtree; + /* The insignificant MSBs tag tree. */ + jpc_tagtree_t *numimsbstagtree; } jpc_dec_prc_t; @@ -401,29 +401,29 @@ typedef struct { typedef struct { - /* The per-code-block-group state information. */ - jpc_dec_prc_t *prcs; + /* The per-code-block-group state information. */ + jpc_dec_prc_t *prcs; - /* The sample data associated with this band. */ - jas_matrix_t *data; + /* The sample data associated with this band. */ + jas_matrix_t *data; - /* The orientation of this band (i.e., LL, LH, HL, or HH). */ - int orient; + /* The orientation of this band (i.e., LL, LH, HL, or HH). */ + int orient; - /* The encoded quantizer step size. */ - int stepsize; + /* The encoded quantizer step size. */ + int stepsize; - /* The absolute quantizer step size. */ - jpc_fix_t absstepsize; + /* The absolute quantizer step size. */ + jpc_fix_t absstepsize; - /* The number of bit planes for this band. */ - int numbps; + /* The number of bit planes for this band. */ + int numbps; - /* The analysis gain associated with this band. */ - int analgain; + /* The analysis gain associated with this band. */ + int analgain; - /* The ROI shift value for this band. */ - int roishift; + /* The ROI shift value for this band. */ + int roishift; } jpc_dec_band_t; @@ -431,60 +431,60 @@ typedef struct { typedef struct { - /* The number of bands associated with this resolution level. */ - int numbands; + /* The number of bands associated with this resolution level. */ + int numbands; - /* The per-band information. */ - jpc_dec_band_t *bands; + /* The per-band information. */ + jpc_dec_band_t *bands; - /* The x-coordinate of the top-left corner of the tile-component - at this resolution. */ - uint_fast32_t xstart; + /* The x-coordinate of the top-left corner of the tile-component + at this resolution. */ + uint_fast32_t xstart; - /* The y-coordinate of the top-left corner of the tile-component - at this resolution. */ - uint_fast32_t ystart; + /* The y-coordinate of the top-left corner of the tile-component + at this resolution. */ + uint_fast32_t ystart; - /* The x-coordinate of the bottom-right corner of the tile-component - at this resolution (plus one). */ - uint_fast32_t xend; + /* The x-coordinate of the bottom-right corner of the tile-component + at this resolution (plus one). */ + uint_fast32_t xend; - /* The y-coordinate of the bottom-right corner of the tile-component - at this resolution (plus one). */ - uint_fast32_t yend; + /* The y-coordinate of the bottom-right corner of the tile-component + at this resolution (plus one). */ + uint_fast32_t yend; - /* The exponent value for the nominal precinct width measured - relative to the associated LL band. */ - int prcwidthexpn; + /* The exponent value for the nominal precinct width measured + relative to the associated LL band. */ + int prcwidthexpn; - /* The exponent value for the nominal precinct height measured - relative to the associated LL band. */ - int prcheightexpn; + /* The exponent value for the nominal precinct height measured + relative to the associated LL band. */ + int prcheightexpn; - /* The number of precincts in the horizontal direction. */ - int numhprcs; + /* The number of precincts in the horizontal direction. */ + int numhprcs; - /* The number of precincts in the vertical direction. */ - int numvprcs; + /* The number of precincts in the vertical direction. */ + int numvprcs; - /* The total number of precincts. */ - int numprcs; + /* The total number of precincts. */ + int numprcs; - /* The exponent value for the nominal code block group width. - This quantity is associated with the next lower resolution level - (assuming that there is one). */ - int cbgwidthexpn; + /* The exponent value for the nominal code block group width. + This quantity is associated with the next lower resolution level + (assuming that there is one). */ + int cbgwidthexpn; - /* The exponent value for the nominal code block group height - This quantity is associated with the next lower resolution level - (assuming that there is one). */ - int cbgheightexpn; + /* The exponent value for the nominal code block group height + This quantity is associated with the next lower resolution level + (assuming that there is one). */ + int cbgheightexpn; - /* The exponent value for the code block width. */ - uint_fast16_t cblkwidthexpn; + /* The exponent value for the code block width. */ + uint_fast16_t cblkwidthexpn; - /* The exponent value for the code block height. */ - uint_fast16_t cblkheightexpn; + /* The exponent value for the code block height. */ + uint_fast16_t cblkheightexpn; } jpc_dec_rlvl_t; @@ -492,33 +492,33 @@ typedef struct { typedef struct { - /* The x-coordinate of the top-left corner of the tile-component - in the coordinate system of the tile-component. */ - uint_fast32_t xstart; + /* The x-coordinate of the top-left corner of the tile-component + in the coordinate system of the tile-component. */ + uint_fast32_t xstart; - /* The y-coordinate of the top-left corner of the tile-component - in the coordinate system of the tile-component. */ - uint_fast32_t ystart; + /* The y-coordinate of the top-left corner of the tile-component + in the coordinate system of the tile-component. */ + uint_fast32_t ystart; - /* The x-coordinate of the bottom-right corner of the tile-component - in the coordinate system of the tile-component (plus one). */ - uint_fast32_t xend; + /* The x-coordinate of the bottom-right corner of the tile-component + in the coordinate system of the tile-component (plus one). */ + uint_fast32_t xend; - /* The y-coordinate of the bottom-right corner of the tile-component - in the coordinate system of the tile-component (plus one). */ - uint_fast32_t yend; + /* The y-coordinate of the bottom-right corner of the tile-component + in the coordinate system of the tile-component (plus one). */ + uint_fast32_t yend; - /* The component data for the current tile. */ - jas_matrix_t *data; + /* The component data for the current tile. */ + jas_matrix_t *data; - /* The number of resolution levels. */ - uint_fast16_t numrlvls; + /* The number of resolution levels. */ + uint_fast16_t numrlvls; - /* The per resolution level information. */ - jpc_dec_rlvl_t *rlvls; + /* The per resolution level information. */ + jpc_dec_rlvl_t *rlvls; - /* The TSFB. */ - jpc_tsfb_t *tsfb; + /* The TSFB. */ + jpc_tsfb_t *tsfb; } jpc_dec_tcomp_t; @@ -526,60 +526,60 @@ typedef struct { * Tile states. */ -#define JPC_TILE_INIT 0 -#define JPC_TILE_ACTIVE 1 -#define JPC_TILE_ACTIVELAST 2 -#define JPC_TILE_DONE 3 +#define JPC_TILE_INIT 0 +#define JPC_TILE_ACTIVE 1 +#define JPC_TILE_ACTIVELAST 2 +#define JPC_TILE_DONE 3 /* Decoder per-tile state information. */ typedef struct { - /* The processing state for this tile. */ - int state; + /* The processing state for this tile. */ + int state; - /* The x-coordinate of the top-left corner of the tile on the reference - grid. */ - uint_fast32_t xstart; + /* The x-coordinate of the top-left corner of the tile on the reference + grid. */ + uint_fast32_t xstart; - /* The y-coordinate of the top-left corner of the tile on the reference - grid. */ - uint_fast32_t ystart; + /* The y-coordinate of the top-left corner of the tile on the reference + grid. */ + uint_fast32_t ystart; - /* The x-coordinate of the bottom-right corner of the tile on the - reference grid (plus one). */ - uint_fast32_t xend; + /* The x-coordinate of the bottom-right corner of the tile on the + reference grid (plus one). */ + uint_fast32_t xend; - /* The y-coordinate of the bottom-right corner of the tile on the - reference grid (plus one). */ - uint_fast32_t yend; + /* The y-coordinate of the bottom-right corner of the tile on the + reference grid (plus one). */ + uint_fast32_t yend; - /* The packed packet header data for this tile. */ - jpc_ppxstab_t *pptstab; + /* The packed packet header data for this tile. */ + jpc_ppxstab_t *pptstab; - /* A stream containing the packed packet header data for this tile. */ - jas_stream_t *pkthdrstream; + /* A stream containing the packed packet header data for this tile. */ + jas_stream_t *pkthdrstream; - /* The current position within the packed packet header stream. */ - long pkthdrstreampos; + /* The current position within the packed packet header stream. */ + long pkthdrstreampos; - /* The coding parameters for this tile. */ - jpc_dec_cp_t *cp; + /* The coding parameters for this tile. */ + jpc_dec_cp_t *cp; - /* The per tile-component information. */ - jpc_dec_tcomp_t *tcomps; + /* The per tile-component information. */ + jpc_dec_tcomp_t *tcomps; - /* The next expected tile-part number. */ - int partno; + /* The next expected tile-part number. */ + int partno; - /* The number of tile-parts. */ - int numparts; + /* The number of tile-parts. */ + int numparts; - /* The coding mode. */ - int realmode; + /* The coding mode. */ + int realmode; - /* The packet iterator for this tile. */ - jpc_pi_t *pi; + /* The packet iterator for this tile. */ + jpc_pi_t *pi; } jpc_dec_tile_t; @@ -587,29 +587,29 @@ typedef struct { typedef struct { - /* The horizontal sampling period. */ - uint_fast32_t hstep; + /* The horizontal sampling period. */ + uint_fast32_t hstep; - /* The vertical sampling period. */ - uint_fast32_t vstep; + /* The vertical sampling period. */ + uint_fast32_t vstep; - /* The number of samples in the horizontal direction. */ - uint_fast32_t width; + /* The number of samples in the horizontal direction. */ + uint_fast32_t width; - /* The number of samples in the vertical direction. */ - uint_fast32_t height; + /* The number of samples in the vertical direction. */ + uint_fast32_t height; - /* The precision of the sample data. */ - uint_fast16_t prec; + /* The precision of the sample data. */ + uint_fast16_t prec; - /* The signedness of the sample data. */ - bool sgnd; + /* The signedness of the sample data. */ + bool sgnd; - /* The sample alignment horizontal offset. */ - uint_fast32_t hsubstep; - - /* The sample alignment vertical offset. */ - uint_fast32_t vsubstep; + /* The sample alignment horizontal offset. */ + uint_fast32_t hsubstep; + + /* The sample alignment vertical offset. */ + uint_fast32_t vsubstep; } jpc_dec_cmpt_t; @@ -617,96 +617,96 @@ typedef struct { typedef struct { - /* The decoded image. */ - jas_image_t *image; + /* The decoded image. */ + jas_image_t *image; - /* The x-coordinate of the top-left corner of the image area on - the reference grid. */ - uint_fast32_t xstart; + /* The x-coordinate of the top-left corner of the image area on + the reference grid. */ + uint_fast32_t xstart; - /* The y-coordinate of the top-left corner of the image area on - the reference grid. */ - uint_fast32_t ystart; + /* The y-coordinate of the top-left corner of the image area on + the reference grid. */ + uint_fast32_t ystart; - /* The x-coordinate of the bottom-right corner of the image area on - the reference grid (plus one). */ - uint_fast32_t xend; + /* The x-coordinate of the bottom-right corner of the image area on + the reference grid (plus one). */ + uint_fast32_t xend; - /* The y-coordinate of the bottom-right corner of the image area on - the reference grid (plus one). */ - uint_fast32_t yend; + /* The y-coordinate of the bottom-right corner of the image area on + the reference grid (plus one). */ + uint_fast32_t yend; - /* The nominal tile width in units of the image reference grid. */ - uint_fast32_t tilewidth; + /* The nominal tile width in units of the image reference grid. */ + uint_fast32_t tilewidth; - /* The nominal tile height in units of the image reference grid. */ - uint_fast32_t tileheight; + /* The nominal tile height in units of the image reference grid. */ + uint_fast32_t tileheight; - /* The horizontal offset from the origin of the reference grid to the - left side of the first tile. */ - uint_fast32_t tilexoff; + /* The horizontal offset from the origin of the reference grid to the + left side of the first tile. */ + uint_fast32_t tilexoff; - /* The vertical offset from the origin of the reference grid to the - top side of the first tile. */ - uint_fast32_t tileyoff; + /* The vertical offset from the origin of the reference grid to the + top side of the first tile. */ + uint_fast32_t tileyoff; - /* The number of tiles spanning the image area in the vertical - direction. */ - int numhtiles; + /* The number of tiles spanning the image area in the vertical + direction. */ + int numhtiles; - /* The number of tiles spanning the image area in the horizontal - direction. */ - int numvtiles; + /* The number of tiles spanning the image area in the horizontal + direction. */ + int numvtiles; - /* The total number of tiles. */ - int numtiles; + /* The total number of tiles. */ + int numtiles; - /* The per-tile information. */ - jpc_dec_tile_t *tiles; + /* The per-tile information. */ + jpc_dec_tile_t *tiles; - /* The tile currently being processed. */ - jpc_dec_tile_t *curtile; + /* The tile currently being processed. */ + jpc_dec_tile_t *curtile; - /* The number of components. */ - int numcomps; + /* The number of components. */ + int numcomps; - /* The stream containing the input JPEG-2000 code stream data. */ - jas_stream_t *in; + /* The stream containing the input JPEG-2000 code stream data. */ + jas_stream_t *in; - /* The default coding parameters for all tiles. */ - jpc_dec_cp_t *cp; + /* The default coding parameters for all tiles. */ + jpc_dec_cp_t *cp; - /* The maximum number of layers that may be decoded. */ - int maxlyrs; + /* The maximum number of layers that may be decoded. */ + int maxlyrs; - /* The maximum number of packets that may be decoded. */ - int maxpkts; + /* The maximum number of packets that may be decoded. */ + int maxpkts; - /* The number of packets decoded so far in the processing of the entire - code stream. */ - int numpkts; + /* The number of packets decoded so far in the processing of the entire + code stream. */ + int numpkts; - /* The next expected PPM marker segment sequence number. */ - int ppmseqno; + /* The next expected PPM marker segment sequence number. */ + int ppmseqno; - /* The current state for code stream processing. */ - int state; + /* The current state for code stream processing. */ + int state; - /* The per-component information. */ - jpc_dec_cmpt_t *cmpts; + /* The per-component information. */ + jpc_dec_cmpt_t *cmpts; - /* The information from PPM marker segments. */ - jpc_ppxstab_t *ppmstab; + /* The information from PPM marker segments. */ + jpc_ppxstab_t *ppmstab; - /* A list of streams containing packet header data from PPM marker - segments. */ - jpc_streamlist_t *pkthdrstreams; + /* A list of streams containing packet header data from PPM marker + segments. */ + jpc_streamlist_t *pkthdrstreams; - /* The expected ending offset for a tile-part. */ - long curtileendoff; + /* The expected ending offset for a tile-part. */ + long curtileendoff; - /* This is required by the tier-2 decoder. */ - jpc_cstate_t *cstate; + /* This is required by the tier-2 decoder. */ + jpc_cstate_t *cstate; } jpc_dec_t; @@ -714,14 +714,14 @@ typedef struct { typedef struct { - /* The debug level for the decoder. */ - int debug; + /* The debug level for the decoder. */ + int debug; - /* The maximum number of layers to decode. */ - int maxlyrs; + /* The maximum number of layers to decode. */ + int maxlyrs; - /* The maximum number of packets to decode. */ - int maxpkts; + /* The maximum number of packets to decode. */ + int maxpkts; } jpc_dec_importopts_t; diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c index 0c77a94e..c964eeff 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c @@ -2835,14 +2835,14 @@ jpc_enc_dump(jpc_enc_t *enc) { */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -2850,22 +2850,22 @@ jpc_enc_dump(jpc_enc_t *enc) { * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -2885,17 +2885,17 @@ jpc_enc_dump(jpc_enc_t *enc) { * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -2935,7 +2935,7 @@ jpc_enc_dump(jpc_enc_t *enc) { * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.h b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.h index 86a8e59c..1e3887aa 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -136,10 +136,10 @@ \******************************************************************************/ /* The number of bits used in various lookup tables. */ -#define JPC_NUMEXTRABITS JPC_NMSEDEC_FRACBITS +#define JPC_NUMEXTRABITS JPC_NMSEDEC_FRACBITS /* An invalid R-D slope value. */ -#define JPC_BADRDSLOPE (-1) +#define JPC_BADRDSLOPE (-1) /******************************************************************************\ * Coding parameters types. @@ -149,29 +149,29 @@ typedef struct { - /* The horizontal sampling period. */ - uint_fast8_t sampgrdstepx; + /* The horizontal sampling period. */ + uint_fast8_t sampgrdstepx; - /* The vertical sampling period. */ - uint_fast8_t sampgrdstepy; + /* The vertical sampling period. */ + uint_fast8_t sampgrdstepy; - /* The sample alignment horizontal offset. */ - uint_fast8_t sampgrdsubstepx; + /* The sample alignment horizontal offset. */ + uint_fast8_t sampgrdsubstepx; - /* The sample alignment vertical offset. */ - uint_fast8_t sampgrdsubstepy; + /* The sample alignment vertical offset. */ + uint_fast8_t sampgrdsubstepy; - /* The precision of the samples. */ - uint_fast8_t prec; + /* The precision of the samples. */ + uint_fast8_t prec; - /* The signedness of the samples. */ - bool sgnd; + /* The signedness of the samples. */ + bool sgnd; - /* The number of step sizes. */ - uint_fast16_t numstepsizes; + /* The number of step sizes. */ + uint_fast16_t numstepsizes; - /* The quantizer step sizes. */ - uint_fast16_t stepsizes[JPC_MAXBANDS]; + /* The quantizer step sizes. */ + uint_fast16_t stepsizes[JPC_MAXBANDS]; } jpc_enc_ccp_t; @@ -179,24 +179,24 @@ typedef struct { typedef struct { - /* The coding mode. */ - bool intmode; + /* The coding mode. */ + bool intmode; - /* The coding style (i.e., SOP, EPH). */ - uint_fast8_t csty; + /* The coding style (i.e., SOP, EPH). */ + uint_fast8_t csty; - /* The progression order. */ - uint_fast8_t prg; + /* The progression order. */ + uint_fast8_t prg; - /* The multicomponent transform. */ - uint_fast8_t mctid; + /* The multicomponent transform. */ + uint_fast8_t mctid; - /* The number of layers. */ - uint_fast16_t numlyrs; + /* The number of layers. */ + uint_fast16_t numlyrs; - /* The normalized bit rates associated with the various - intermediate layers. */ - jpc_fix_t *ilyrrates; + /* The normalized bit rates associated with the various + intermediate layers. */ + jpc_fix_t *ilyrrates; } jpc_enc_tcp_t; @@ -204,33 +204,33 @@ typedef struct { typedef struct { - /* The coding style (i.e., explicit precinct sizes). */ - uint_fast8_t csty; + /* The coding style (i.e., explicit precinct sizes). */ + uint_fast8_t csty; - /* The maximum number of resolution levels allowed. */ - uint_fast8_t maxrlvls; + /* The maximum number of resolution levels allowed. */ + uint_fast8_t maxrlvls; - /* The exponent for the nominal code block width. */ - uint_fast16_t cblkwidthexpn; + /* The exponent for the nominal code block width. */ + uint_fast16_t cblkwidthexpn; - /* The exponent for the nominal code block height. */ - uint_fast16_t cblkheightexpn; + /* The exponent for the nominal code block height. */ + uint_fast16_t cblkheightexpn; - /* The code block style parameters (e.g., lazy, terminate all, - segmentation symbols, causal, reset probability models). */ - uint_fast8_t cblksty; + /* The code block style parameters (e.g., lazy, terminate all, + segmentation symbols, causal, reset probability models). */ + uint_fast8_t cblksty; - /* The QMFB. */ - uint_fast8_t qmfbid; + /* The QMFB. */ + uint_fast8_t qmfbid; - /* The precinct width values. */ - uint_fast16_t prcwidthexpns[JPC_MAXRLVLS]; + /* The precinct width values. */ + uint_fast16_t prcwidthexpns[JPC_MAXRLVLS]; - /* The precinct height values. */ - uint_fast16_t prcheightexpns[JPC_MAXRLVLS]; + /* The precinct height values. */ + uint_fast16_t prcheightexpns[JPC_MAXRLVLS]; - /* The number of guard bits. */ - uint_fast8_t numgbits; + /* The number of guard bits. */ + uint_fast8_t numgbits; } jpc_enc_tccp_t; @@ -238,67 +238,67 @@ typedef struct { typedef struct { - /* The debug level. */ - int debug; + /* The debug level. */ + int debug; - /* The horizontal offset from the origin of the reference grid to the - left edge of the image area. */ - uint_fast32_t imgareatlx; + /* The horizontal offset from the origin of the reference grid to the + left edge of the image area. */ + uint_fast32_t imgareatlx; - /* The vertical offset from the origin of the reference grid to the - top edge of the image area. */ - uint_fast32_t imgareatly; + /* The vertical offset from the origin of the reference grid to the + top edge of the image area. */ + uint_fast32_t imgareatly; - /* The horizontal offset from the origin of the reference grid to the - right edge of the image area (plus one). */ - uint_fast32_t refgrdwidth; + /* The horizontal offset from the origin of the reference grid to the + right edge of the image area (plus one). */ + uint_fast32_t refgrdwidth; - /* The vertical offset from the origin of the reference grid to the - bottom edge of the image area (plus one). */ - uint_fast32_t refgrdheight; + /* The vertical offset from the origin of the reference grid to the + bottom edge of the image area (plus one). */ + uint_fast32_t refgrdheight; - /* The horizontal offset from the origin of the tile grid to the - origin of the reference grid. */ - uint_fast32_t tilegrdoffx; + /* The horizontal offset from the origin of the tile grid to the + origin of the reference grid. */ + uint_fast32_t tilegrdoffx; - /* The vertical offset from the origin of the tile grid to the - origin of the reference grid. */ - uint_fast32_t tilegrdoffy; + /* The vertical offset from the origin of the tile grid to the + origin of the reference grid. */ + uint_fast32_t tilegrdoffy; - /* The nominal tile width in units of the image reference grid. */ - uint_fast32_t tilewidth; + /* The nominal tile width in units of the image reference grid. */ + uint_fast32_t tilewidth; - /* The nominal tile height in units of the image reference grid. */ - uint_fast32_t tileheight; + /* The nominal tile height in units of the image reference grid. */ + uint_fast32_t tileheight; - /* The number of tiles spanning the image area in the horizontal - direction. */ - uint_fast32_t numhtiles; + /* The number of tiles spanning the image area in the horizontal + direction. */ + uint_fast32_t numhtiles; - /* The number of tiles spanning the image area in the vertical - direction. */ - uint_fast32_t numvtiles; + /* The number of tiles spanning the image area in the vertical + direction. */ + uint_fast32_t numvtiles; - /* The number of tiles. */ - uint_fast32_t numtiles; + /* The number of tiles. */ + uint_fast32_t numtiles; - /* The number of components. */ - uint_fast16_t numcmpts; + /* The number of components. */ + uint_fast16_t numcmpts; - /* The per-component coding parameters. */ - jpc_enc_ccp_t *ccps; + /* The per-component coding parameters. */ + jpc_enc_ccp_t *ccps; - /* The per-tile coding parameters. */ - jpc_enc_tcp_t tcp; + /* The per-tile coding parameters. */ + jpc_enc_tcp_t tcp; - /* The per-tile-component coding parameters. */ - jpc_enc_tccp_t tccp; + /* The per-tile-component coding parameters. */ + jpc_enc_tccp_t tccp; - /* The target code stream length in bytes. */ - uint_fast32_t totalsize; + /* The target code stream length in bytes. */ + uint_fast32_t totalsize; - /* The raw (i.e., uncompressed) size of the image in bytes. */ - uint_fast32_t rawsize; + /* The raw (i.e., uncompressed) size of the image in bytes. */ + uint_fast32_t rawsize; } jpc_enc_cp_t; @@ -310,35 +310,35 @@ typedef struct { typedef struct { - /* The starting offset for this pass. */ - int start; + /* The starting offset for this pass. */ + int start; - /* The ending offset for this pass. */ - int end; + /* The ending offset for this pass. */ + int end; - /* The type of data in this pass (i.e., MQ or raw). */ - int type; + /* The type of data in this pass (i.e., MQ or raw). */ + int type; - /* Flag indicating that this pass is terminated. */ - int term; + /* Flag indicating that this pass is terminated. */ + int term; - /* The entropy coder state after coding this pass. */ - jpc_mqencstate_t mqencstate; + /* The entropy coder state after coding this pass. */ + jpc_mqencstate_t mqencstate; - /* The layer to which this pass has been assigned. */ - int lyrno; + /* The layer to which this pass has been assigned. */ + int lyrno; - /* The R-D slope for this pass. */ - jpc_flt_t rdslope; + /* The R-D slope for this pass. */ + jpc_flt_t rdslope; - /* The weighted MSE reduction associated with this pass. */ - jpc_flt_t wmsedec; + /* The weighted MSE reduction associated with this pass. */ + jpc_flt_t wmsedec; - /* The cumulative weighted MSE reduction. */ - jpc_flt_t cumwmsedec; + /* The cumulative weighted MSE reduction. */ + jpc_flt_t cumwmsedec; - /* The normalized MSE reduction. */ - long nmsedec; + /* The normalized MSE reduction. */ + long nmsedec; } jpc_enc_pass_t; @@ -346,53 +346,53 @@ typedef struct { typedef struct { - /* The number of passes. */ - int numpasses; + /* The number of passes. */ + int numpasses; - /* The per-pass information. */ - jpc_enc_pass_t *passes; + /* The per-pass information. */ + jpc_enc_pass_t *passes; - /* The number of passes encoded so far. */ - int numencpasses; + /* The number of passes encoded so far. */ + int numencpasses; - /* The number of insignificant MSBs. */ - int numimsbs; + /* The number of insignificant MSBs. */ + int numimsbs; - /* The number of bits used to encode pass data lengths. */ - int numlenbits; + /* The number of bits used to encode pass data lengths. */ + int numlenbits; - /* The byte stream for this code block. */ - jas_stream_t *stream; + /* The byte stream for this code block. */ + jas_stream_t *stream; - /* The entropy encoder. */ - jpc_mqenc_t *mqenc; + /* The entropy encoder. */ + jpc_mqenc_t *mqenc; - /* The data for this code block. */ - jas_matrix_t *data; + /* The data for this code block. */ + jas_matrix_t *data; - /* The state for this code block. */ - jas_matrix_t *flags; + /* The state for this code block. */ + jas_matrix_t *flags; - /* The number of bit planes required for this code block. */ - int numbps; + /* The number of bit planes required for this code block. */ + int numbps; - /* The next pass to be encoded. */ - jpc_enc_pass_t *curpass; + /* The next pass to be encoded. */ + jpc_enc_pass_t *curpass; - /* The per-code-block-group state information. */ - struct jpc_enc_prc_s *prc; + /* The per-code-block-group state information. */ + struct jpc_enc_prc_s *prc; - /* The saved current pass. */ - /* This is used by the rate control code. */ - jpc_enc_pass_t *savedcurpass; + /* The saved current pass. */ + /* This is used by the rate control code. */ + jpc_enc_pass_t *savedcurpass; - /* The saved length indicator size. */ - /* This is used by the rate control code. */ - int savednumlenbits; + /* The saved length indicator size. */ + /* This is used by the rate control code. */ + int savednumlenbits; - /* The saved number of encoded passes. */ - /* This is used by the rate control code. */ - int savednumencpasses; + /* The saved number of encoded passes. */ + /* This is used by the rate control code. */ + int savednumencpasses; } jpc_enc_cblk_t; @@ -400,50 +400,50 @@ typedef struct { typedef struct jpc_enc_prc_s { - /* The x-coordinate of the top-left corner of the precinct. */ - uint_fast32_t tlx; + /* The x-coordinate of the top-left corner of the precinct. */ + uint_fast32_t tlx; - /* The y-coordinate of the top-left corner of the precinct. */ - uint_fast32_t tly; + /* The y-coordinate of the top-left corner of the precinct. */ + uint_fast32_t tly; - /* The x-coordinate of the bottom-right corner of the precinct - (plus one). */ - uint_fast32_t brx; + /* The x-coordinate of the bottom-right corner of the precinct + (plus one). */ + uint_fast32_t brx; - /* The y-coordinate of the bottom-right corner of the precinct - (plus one). */ - uint_fast32_t bry; + /* The y-coordinate of the bottom-right corner of the precinct + (plus one). */ + uint_fast32_t bry; - /* The number of code blocks spanning the precinct in the horizontal - direction. */ - int numhcblks; + /* The number of code blocks spanning the precinct in the horizontal + direction. */ + int numhcblks; - /* The number of code blocks spanning the precinct in the vertical - direction. */ - int numvcblks; + /* The number of code blocks spanning the precinct in the vertical + direction. */ + int numvcblks; - /* The total number of code blocks. */ - int numcblks; + /* The total number of code blocks. */ + int numcblks; - /* The per-code-block information. */ - jpc_enc_cblk_t *cblks; + /* The per-code-block information. */ + jpc_enc_cblk_t *cblks; - /* The inclusion tag tree. */ - jpc_tagtree_t *incltree; + /* The inclusion tag tree. */ + jpc_tagtree_t *incltree; - /* The insignifcant MSBs tag tree. */ - jpc_tagtree_t *nlibtree; + /* The insignifcant MSBs tag tree. */ + jpc_tagtree_t *nlibtree; - /* The per-band information. */ - struct jpc_enc_band_s *band; + /* The per-band information. */ + struct jpc_enc_band_s *band; - /* The saved inclusion tag tree. */ - /* This is used by rate control. */ - jpc_tagtree_t *savincltree; + /* The saved inclusion tag tree. */ + /* This is used by rate control. */ + jpc_tagtree_t *savincltree; - /* The saved leading-insignificant-bit-planes tag tree. */ - /* This is used by rate control. */ - jpc_tagtree_t *savnlibtree; + /* The saved leading-insignificant-bit-planes tag tree. */ + /* This is used by rate control. */ + jpc_tagtree_t *savnlibtree; } jpc_enc_prc_t; @@ -451,33 +451,33 @@ typedef struct jpc_enc_prc_s { typedef struct jpc_enc_band_s { - /* The per precinct information. */ - jpc_enc_prc_t *prcs; + /* The per precinct information. */ + jpc_enc_prc_t *prcs; - /* The coefficient data for this band. */ - jas_matrix_t *data; + /* The coefficient data for this band. */ + jas_matrix_t *data; - /* The orientation of this band (i.e., LL, LH, HL, or HH). */ - int orient; + /* The orientation of this band (i.e., LL, LH, HL, or HH). */ + int orient; - /* The number of bit planes associated with this band. */ - int numbps; + /* The number of bit planes associated with this band. */ + int numbps; - /* The quantizer step size. */ - jpc_fix_t absstepsize; + /* The quantizer step size. */ + jpc_fix_t absstepsize; - /* The encoded quantizer step size. */ - int stepsize; + /* The encoded quantizer step size. */ + int stepsize; - /* The L2 norm of the synthesis basis functions associated with - this band. (The MCT is not considered in this value.) */ - jpc_fix_t synweight; + /* The L2 norm of the synthesis basis functions associated with + this band. (The MCT is not considered in this value.) */ + jpc_fix_t synweight; - /* The analysis gain for this band. */ - int analgain; + /* The analysis gain for this band. */ + int analgain; - /* The per-resolution-level information. */ - struct jpc_enc_rlvl_s *rlvl; + /* The per-resolution-level information. */ + struct jpc_enc_rlvl_s *rlvl; } jpc_enc_band_t; @@ -485,65 +485,65 @@ typedef struct jpc_enc_band_s { typedef struct jpc_enc_rlvl_s { - /* The x-coordinate of the top-left corner of the tile-component - at this resolution. */ - uint_fast32_t tlx; + /* The x-coordinate of the top-left corner of the tile-component + at this resolution. */ + uint_fast32_t tlx; - /* The y-coordinate of the top-left corner of the tile-component - at this resolution. */ - uint_fast32_t tly; + /* The y-coordinate of the top-left corner of the tile-component + at this resolution. */ + uint_fast32_t tly; - /* The x-coordinate of the bottom-right corner of the tile-component - at this resolution (plus one). */ - uint_fast32_t brx; + /* The x-coordinate of the bottom-right corner of the tile-component + at this resolution (plus one). */ + uint_fast32_t brx; - /* The y-coordinate of the bottom-right corner of the tile-component - at this resolution (plus one). */ - uint_fast32_t bry; + /* The y-coordinate of the bottom-right corner of the tile-component + at this resolution (plus one). */ + uint_fast32_t bry; - /* The exponent value for the nominal precinct width measured - relative to the associated LL band. */ - int prcwidthexpn; + /* The exponent value for the nominal precinct width measured + relative to the associated LL band. */ + int prcwidthexpn; - /* The exponent value for the nominal precinct height measured - relative to the associated LL band. */ - int prcheightexpn; + /* The exponent value for the nominal precinct height measured + relative to the associated LL band. */ + int prcheightexpn; - /* The number of precincts spanning the resolution level in the - horizontal direction. */ - int numhprcs; + /* The number of precincts spanning the resolution level in the + horizontal direction. */ + int numhprcs; - /* The number of precincts spanning the resolution level in the - vertical direction. */ - int numvprcs; + /* The number of precincts spanning the resolution level in the + vertical direction. */ + int numvprcs; - /* The total number of precincts. */ - int numprcs; + /* The total number of precincts. */ + int numprcs; - /* The exponent value for the nominal code block group width. - This quantity is associated with the next lower resolution level - (assuming that there is one). */ - int cbgwidthexpn; + /* The exponent value for the nominal code block group width. + This quantity is associated with the next lower resolution level + (assuming that there is one). */ + int cbgwidthexpn; - /* The exponent value for the nominal code block group height. - This quantity is associated with the next lower resolution level - (assuming that there is one). */ - int cbgheightexpn; + /* The exponent value for the nominal code block group height. + This quantity is associated with the next lower resolution level + (assuming that there is one). */ + int cbgheightexpn; - /* The exponent value for the code block width. */ - uint_fast16_t cblkwidthexpn; + /* The exponent value for the code block width. */ + uint_fast16_t cblkwidthexpn; - /* The exponent value for the code block height. */ - uint_fast16_t cblkheightexpn; + /* The exponent value for the code block height. */ + uint_fast16_t cblkheightexpn; - /* The number of bands associated with this resolution level. */ - int numbands; + /* The number of bands associated with this resolution level. */ + int numbands; - /* The per-band information. */ - jpc_enc_band_t *bands; + /* The per-band information. */ + jpc_enc_band_t *bands; - /* The parent tile-component. */ - struct jpc_enc_tcmpt_s *tcmpt; + /* The parent tile-component. */ + struct jpc_enc_tcmpt_s *tcmpt; } jpc_enc_rlvl_t; @@ -551,53 +551,53 @@ typedef struct jpc_enc_rlvl_s { typedef struct jpc_enc_tcmpt_s { - /* The number of resolution levels. */ - uint_fast16_t numrlvls; + /* The number of resolution levels. */ + uint_fast16_t numrlvls; - /* The per-resolution-level information. */ - jpc_enc_rlvl_t *rlvls; + /* The per-resolution-level information. */ + jpc_enc_rlvl_t *rlvls; - /* The tile-component data. */ - jas_matrix_t *data; + /* The tile-component data. */ + jas_matrix_t *data; - /* The QMFB. */ - int qmfbid; + /* The QMFB. */ + int qmfbid; - /* The number of bands. */ - int numbands; + /* The number of bands. */ + int numbands; - /* The TSFB. */ - jpc_tsfb_t *tsfb; + /* The TSFB. */ + jpc_tsfb_t *tsfb; - /* The synthesis energy weight (for the MCT). */ - jpc_fix_t synweight; + /* The synthesis energy weight (for the MCT). */ + jpc_fix_t synweight; - /* The precinct width exponents. */ - int prcwidthexpns[JPC_MAXRLVLS]; + /* The precinct width exponents. */ + int prcwidthexpns[JPC_MAXRLVLS]; - /* The precinct height exponents. */ - int prcheightexpns[JPC_MAXRLVLS]; + /* The precinct height exponents. */ + int prcheightexpns[JPC_MAXRLVLS]; - /* The code block width exponent. */ - int cblkwidthexpn; + /* The code block width exponent. */ + int cblkwidthexpn; - /* The code block height exponent. */ - int cblkheightexpn; + /* The code block height exponent. */ + int cblkheightexpn; - /* Coding style (i.e., explicit precinct sizes). */ - int csty; + /* Coding style (i.e., explicit precinct sizes). */ + int csty; - /* Code block style. */ - int cblksty; + /* Code block style. */ + int cblksty; - /* The number of quantizer step sizes. */ - uint_fast16_t numstepsizes; + /* The number of quantizer step sizes. */ + uint_fast16_t numstepsizes; - /* The encoded quantizer step sizes. */ - uint_fast16_t stepsizes[JPC_MAXBANDS]; + /* The encoded quantizer step sizes. */ + uint_fast16_t stepsizes[JPC_MAXBANDS]; - /* The parent tile. */ - struct jpc_enc_tile_s *tile; + /* The parent tile. */ + struct jpc_enc_tile_s *tile; } jpc_enc_tcmpt_t; @@ -605,55 +605,55 @@ typedef struct jpc_enc_tcmpt_s { typedef struct jpc_enc_tile_s { - /* The tile number. */ - uint_fast32_t tileno; + /* The tile number. */ + uint_fast32_t tileno; - /* The x-coordinate of the top-left corner of the tile measured with - respect to the reference grid. */ - uint_fast32_t tlx; + /* The x-coordinate of the top-left corner of the tile measured with + respect to the reference grid. */ + uint_fast32_t tlx; - /* The y-coordinate of the top-left corner of the tile measured with - respect to the reference grid. */ - uint_fast32_t tly; + /* The y-coordinate of the top-left corner of the tile measured with + respect to the reference grid. */ + uint_fast32_t tly; - /* The x-coordinate of the bottom-right corner of the tile measured - with respect to the reference grid (plus one). */ - uint_fast32_t brx; + /* The x-coordinate of the bottom-right corner of the tile measured + with respect to the reference grid (plus one). */ + uint_fast32_t brx; - /* The y-coordinate of the bottom-right corner of the tile measured - with respect to the reference grid (plus one). */ - uint_fast32_t bry; + /* The y-coordinate of the bottom-right corner of the tile measured + with respect to the reference grid (plus one). */ + uint_fast32_t bry; - /* The coding style. */ - uint_fast8_t csty; + /* The coding style. */ + uint_fast8_t csty; - /* The progression order. */ - uint_fast8_t prg; + /* The progression order. */ + uint_fast8_t prg; - /* The number of layers. */ - uint_fast16_t numlyrs; + /* The number of layers. */ + uint_fast16_t numlyrs; - /* The MCT to employ (if any). */ - uint_fast8_t mctid; + /* The MCT to employ (if any). */ + uint_fast8_t mctid; - /* The packet iterator (used to determine the order of packet - generation). */ - jpc_pi_t *pi; + /* The packet iterator (used to determine the order of packet + generation). */ + jpc_pi_t *pi; - /* The coding mode (i.e., integer or real). */ - bool intmode; + /* The coding mode (i.e., integer or real). */ + bool intmode; - /* The number of bytes to allocate to the various layers. */ - uint_fast32_t *lyrsizes; + /* The number of bytes to allocate to the various layers. */ + uint_fast32_t *lyrsizes; - /* The number of tile-components. */ - int numtcmpts; + /* The number of tile-components. */ + int numtcmpts; - /* The per tile-component information. */ - jpc_enc_tcmpt_t *tcmpts; + /* The per tile-component information. */ + jpc_enc_tcmpt_t *tcmpts; - /* The raw (i.e., uncompressed) size of this tile. */ - uint_fast32_t rawsize; + /* The raw (i.e., uncompressed) size of this tile. */ + uint_fast32_t rawsize; } jpc_enc_tile_t; @@ -661,34 +661,34 @@ typedef struct jpc_enc_tile_s { typedef struct jpc_enc_s { - /* The image being encoded. */ - jas_image_t *image; + /* The image being encoded. */ + jas_image_t *image; - /* The output stream. */ - jas_stream_t *out; + /* The output stream. */ + jas_stream_t *out; - /* The coding parameters. */ - jpc_enc_cp_t *cp; + /* The coding parameters. */ + jpc_enc_cp_t *cp; - /* The tile currently being processed. */ - jpc_enc_tile_t *curtile; + /* The tile currently being processed. */ + jpc_enc_tile_t *curtile; - /* The code stream state. */ - jpc_cstate_t *cstate; + /* The code stream state. */ + jpc_cstate_t *cstate; - /* The number of bytes output so far. */ - uint_fast32_t len; + /* The number of bytes output so far. */ + uint_fast32_t len; - /* The number of bytes available for the main body of the code stream. */ - /* This is used for rate allocation purposes. */ - uint_fast32_t mainbodysize; + /* The number of bytes available for the main body of the code stream. */ + /* This is used for rate allocation purposes. */ + uint_fast32_t mainbodysize; - /* The marker segment currently being processed. */ - /* This member is a convenience for making cleanup easier. */ - jpc_ms_t *mrk; + /* The marker segment currently being processed. */ + /* This member is a convenience for making cleanup easier. */ + jpc_ms_t *mrk; - /* The stream used to temporarily hold tile-part data. */ - jas_stream_t *tmpstream; + /* The stream used to temporarily hold tile-part data. */ + jas_stream_t *tmpstream; } jpc_enc_t; diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_fix.h b/converter/other/jpeg2000/libjasper/jpc/jpc_fix.h index 5ff0c9f8..2083cdc6 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_fix.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_fix.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -141,7 +141,7 @@ typedef int_fast32_t jpc_fix_t; typedef int_fast64_t jpc_fix_big_t; /* The number of bits used for the fractional part of a fixed-point number. */ -#define JPC_FIX_FRACBITS 13 +#define JPC_FIX_FRACBITS 13 /******************************************************************************\ * Instantiations of the generic fixed-point number macros for the @@ -150,44 +150,44 @@ typedef int_fast64_t jpc_fix_big_t; * corresponding macros in the jasper/jas_fix.h header file. \******************************************************************************/ -#define JPC_FIX_ZERO JAS_FIX_ZERO(jpc_fix_t, JPC_FIX_FRACBITS) -#define JPC_FIX_ONE JAS_FIX_ONE(jpc_fix_t, JPC_FIX_FRACBITS) -#define JPC_FIX_HALF JAS_FIX_HALF(jpc_fix_t, JPC_FIX_FRACBITS) - -#define jpc_inttofix(x) JAS_INTTOFIX(jpc_fix_t, JPC_FIX_FRACBITS, x) -#define jpc_fixtoint(x) JAS_FIXTOINT(jpc_fix_t, JPC_FIX_FRACBITS, x) -#define jpc_fixtodbl(x) JAS_FIXTODBL(jpc_fix_t, JPC_FIX_FRACBITS, x) -#define jpc_dbltofix(x) JAS_DBLTOFIX(jpc_fix_t, JPC_FIX_FRACBITS, x) - -#define jpc_fix_add(x, y) JAS_FIX_ADD(jpc_fix_t, JPC_FIX_FRACBITS, x, y) -#define jpc_fix_sub(x, y) JAS_FIX_SUB(jpc_fix_t, JPC_FIX_FRACBITS, x, y) -#define jpc_fix_mul(x, y) \ - JAS_FIX_MUL(jpc_fix_t, JPC_FIX_FRACBITS, jpc_fix_big_t, x, y) -#define jpc_fix_mulbyint(x, y) \ - JAS_FIX_MULBYINT(jpc_fix_t, JPC_FIX_FRACBITS, x, y) -#define jpc_fix_div(x, y) \ - JAS_FIX_DIV(jpc_fix_t, JPC_FIX_FRACBITS, jpc_fix_big_t, x, y) -#define jpc_fix_neg(x) JAS_FIX_NEG(jpc_fix_t, JPC_FIX_FRACBITS, x) -#define jpc_fix_asl(x, n) JAS_FIX_ASL(jpc_fix_t, JPC_FIX_FRACBITS, x, n) -#define jpc_fix_asr(x, n) JAS_FIX_ASR(jpc_fix_t, JPC_FIX_FRACBITS, x, n) - -#define jpc_fix_pluseq(x, y) JAS_FIX_PLUSEQ(jpc_fix_t, JPC_FIX_FRACBITS, x, y) -#define jpc_fix_minuseq(x, y) JAS_FIX_MINUSEQ(jpc_fix_t, JPC_FIX_FRACBITS, x, y) -#define jpc_fix_muleq(x, y) \ - JAS_FIX_MULEQ(jpc_fix_t, JPC_FIX_FRACBITS, jpc_fix_big_t, x, y) - -#define jpc_fix_abs(x) JAS_FIX_ABS(jpc_fix_t, JPC_FIX_FRACBITS, x) -#define jpc_fix_isint(x) JAS_FIX_ISINT(jpc_fix_t, JPC_FIX_FRACBITS, x) -#define jpc_fix_sgn(x) JAS_FIX_SGN(jpc_fix_t, JPC_FIX_FRACBITS, x) -#define jpc_fix_round(x) JAS_FIX_ROUND(jpc_fix_t, JPC_FIX_FRACBITS, x) -#define jpc_fix_floor(x) JAS_FIX_FLOOR(jpc_fix_t, JPC_FIX_FRACBITS, x) -#define jpc_fix_trunc(x) JAS_FIX_TRUNC(jpc_fix_t, JPC_FIX_FRACBITS, x) +#define JPC_FIX_ZERO JAS_FIX_ZERO(jpc_fix_t, JPC_FIX_FRACBITS) +#define JPC_FIX_ONE JAS_FIX_ONE(jpc_fix_t, JPC_FIX_FRACBITS) +#define JPC_FIX_HALF JAS_FIX_HALF(jpc_fix_t, JPC_FIX_FRACBITS) + +#define jpc_inttofix(x) JAS_INTTOFIX(jpc_fix_t, JPC_FIX_FRACBITS, x) +#define jpc_fixtoint(x) JAS_FIXTOINT(jpc_fix_t, JPC_FIX_FRACBITS, x) +#define jpc_fixtodbl(x) JAS_FIXTODBL(jpc_fix_t, JPC_FIX_FRACBITS, x) +#define jpc_dbltofix(x) JAS_DBLTOFIX(jpc_fix_t, JPC_FIX_FRACBITS, x) + +#define jpc_fix_add(x, y) JAS_FIX_ADD(jpc_fix_t, JPC_FIX_FRACBITS, x, y) +#define jpc_fix_sub(x, y) JAS_FIX_SUB(jpc_fix_t, JPC_FIX_FRACBITS, x, y) +#define jpc_fix_mul(x, y) \ + JAS_FIX_MUL(jpc_fix_t, JPC_FIX_FRACBITS, jpc_fix_big_t, x, y) +#define jpc_fix_mulbyint(x, y) \ + JAS_FIX_MULBYINT(jpc_fix_t, JPC_FIX_FRACBITS, x, y) +#define jpc_fix_div(x, y) \ + JAS_FIX_DIV(jpc_fix_t, JPC_FIX_FRACBITS, jpc_fix_big_t, x, y) +#define jpc_fix_neg(x) JAS_FIX_NEG(jpc_fix_t, JPC_FIX_FRACBITS, x) +#define jpc_fix_asl(x, n) JAS_FIX_ASL(jpc_fix_t, JPC_FIX_FRACBITS, x, n) +#define jpc_fix_asr(x, n) JAS_FIX_ASR(jpc_fix_t, JPC_FIX_FRACBITS, x, n) + +#define jpc_fix_pluseq(x, y) JAS_FIX_PLUSEQ(jpc_fix_t, JPC_FIX_FRACBITS, x, y) +#define jpc_fix_minuseq(x, y) JAS_FIX_MINUSEQ(jpc_fix_t, JPC_FIX_FRACBITS, x, y) +#define jpc_fix_muleq(x, y) \ + JAS_FIX_MULEQ(jpc_fix_t, JPC_FIX_FRACBITS, jpc_fix_big_t, x, y) + +#define jpc_fix_abs(x) JAS_FIX_ABS(jpc_fix_t, JPC_FIX_FRACBITS, x) +#define jpc_fix_isint(x) JAS_FIX_ISINT(jpc_fix_t, JPC_FIX_FRACBITS, x) +#define jpc_fix_sgn(x) JAS_FIX_SGN(jpc_fix_t, JPC_FIX_FRACBITS, x) +#define jpc_fix_round(x) JAS_FIX_ROUND(jpc_fix_t, JPC_FIX_FRACBITS, x) +#define jpc_fix_floor(x) JAS_FIX_FLOOR(jpc_fix_t, JPC_FIX_FRACBITS, x) +#define jpc_fix_trunc(x) JAS_FIX_TRUNC(jpc_fix_t, JPC_FIX_FRACBITS, x) /******************************************************************************\ * Extra macros for convenience. \******************************************************************************/ /* Compute the sum of three fixed-point numbers. */ -#define jpc_fix_add3(x, y, z) jpc_fix_add(jpc_fix_add(x, y), z) +#define jpc_fix_add3(x, y, z) jpc_fix_add(jpc_fix_add(x, y), z) #endif diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_flt.h b/converter/other/jpeg2000/libjasper/jpc/jpc_flt.h index 088eb00c..dc1950e3 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_flt.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_flt.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_math.c b/converter/other/jpeg2000/libjasper/jpc/jpc_math.c index a884ed4d..420e0857 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_math.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_math.c @@ -14,18 +14,18 @@ int jpc_floorlog2(int_fast32_t const arg) { - int y; + int y; int x; - assert(arg > 0); + assert(arg > 0); - y = 0; + y = 0; x = arg; - while (x > 1) { - x >>= 1; - ++y; - } - return y; + while (x > 1) { + x >>= 1; + ++y; + } + return y; } @@ -34,12 +34,12 @@ jpc_floorlog2(int_fast32_t const arg) { jpc_floorlog2() and jpc_firstone() do the same thing. The only difference is how input 0 is handled. -n : 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 -ceil(log2(n)) : x 0 1 2 2 3 3 3 3 4 4 4 4 4 4 4 4 5 5 5 -floor(log2(n)) : x 0 1 1 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 -31-__builtin_clz(n): x 0 1 1 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 -jpc_floorlog2(n) : x 0 1 1 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 -jpc_firstone(n) :-1 0 1 1 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 +n : 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 +ceil(log2(n)) : x 0 1 2 2 3 3 3 3 4 4 4 4 4 4 4 4 5 5 5 +floor(log2(n)) : x 0 1 1 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 +31-__builtin_clz(n): x 0 1 1 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 +jpc_floorlog2(n) : x 0 1 1 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 +jpc_firstone(n) :-1 0 1 1 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 */ @@ -47,24 +47,24 @@ jpc_firstone(n) :-1 0 1 1 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 int jpc_firstone(int_fast32_t const arg) { -/*---------------------------------------------------------------------------- +/*---------------------------------------------------------------------------- Calculate the bit position of the first leading one in a nonnegative integer. LSB is bit position 0. Iff there are no ones, return -1. -----------------------------------------------------------------------------*/ - int n; + int n; int x; - assert(arg >= 0); + assert(arg >= 0); - n = -1; + n = -1; x = arg; - while (x > 0) { - x >>= 1; - ++n; - } - return n; + while (x > 0) { + x >>= 1; + ++n; + } + return n; } @@ -77,14 +77,14 @@ jpc_firstone(int_fast32_t const arg) { */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -92,22 +92,22 @@ jpc_firstone(int_fast32_t const arg) { * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -127,17 +127,17 @@ jpc_firstone(int_fast32_t const arg) { * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -177,6 +177,6 @@ jpc_firstone(int_fast32_t const arg) { * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_math.h b/converter/other/jpeg2000/libjasper/jpc/jpc_math.h index cd24c6a6..e08db334 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_math.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_math.h @@ -4,14 +4,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -19,22 +19,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -54,17 +54,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -104,12 +104,12 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ -#ifndef JPC_MATH_H -#define JPC_MATH_H +#ifndef JPC_MATH_H +#define JPC_MATH_H /******************************************************************************\ * Includes @@ -123,23 +123,23 @@ \******************************************************************************/ /* Compute the floor of the quotient of two integers. */ -#define JPC_FLOORDIV(x, y) (assert(x >= 0 && y > 0), (x) / (y)) +#define JPC_FLOORDIV(x, y) (assert(x >= 0 && y > 0), (x) / (y)) /* Compute the ceiling of the quotient of two integers. */ -#define JPC_CEILDIV(x, y) (assert(x >= 0 && y > 0), ((x) + (y) - 1) / (y)) +#define JPC_CEILDIV(x, y) (assert(x >= 0 && y > 0), ((x) + (y) - 1) / (y)) /* Compute the floor of (x / 2^y). */ -#define JPC_FLOORDIVPOW2(x, y) \ - (assert(x >= 0 && y > 0), (x) >> (y)) +#define JPC_FLOORDIVPOW2(x, y) \ + (assert(x >= 0 && y > 0), (x) >> (y)) /* Compute the ceiling of (x / 2^y). */ -#define JPC_CEILDIVPOW2(x, y) \ - (assert(x >= 0 && y >= 0), ((x) + (1 << (y)) - 1) >> (y)) +#define JPC_CEILDIVPOW2(x, y) \ + (assert(x >= 0 && y >= 0), ((x) + (1 << (y)) - 1) >> (y)) /* JPC_CEILDIVPOW2U is for unsigned arguments (JPC_CEILDIVPOW2 would generate compiler warnings because of its superfluous >= 0 check) */ -#define JPC_CEILDIVPOW2U(x, y) \ - (((x) + (1 << (y)) - 1) >> (y)) +#define JPC_CEILDIVPOW2U(x, y) \ + (((x) + (1 << (y)) - 1) >> (y)) /******************************************************************************\ * Functions. diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_mct.c b/converter/other/jpeg2000/libjasper/jpc/jpc_mct.c index 7c16c3e5..2d7ea47c 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_mct.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_mct.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -135,203 +135,203 @@ void jpc_rct(jas_matrix_t *c0, jas_matrix_t *c1, jas_matrix_t *c2) { - int numrows; - int numcols; - int i; - int j; - jpc_fix_t *c0p; - jpc_fix_t *c1p; - jpc_fix_t *c2p; + int numrows; + int numcols; + int i; + int j; + jpc_fix_t *c0p; + jpc_fix_t *c1p; + jpc_fix_t *c2p; - numrows = jas_matrix_numrows(c0); - numcols = jas_matrix_numcols(c0); + numrows = jas_matrix_numrows(c0); + numcols = jas_matrix_numcols(c0); - /* All three matrices must have the same dimensions. */ - assert(jas_matrix_numrows(c1) == numrows && jas_matrix_numcols(c1) == numcols - && jas_matrix_numrows(c2) == numrows && jas_matrix_numcols(c2) == numcols); + /* All three matrices must have the same dimensions. */ + assert(jas_matrix_numrows(c1) == numrows && jas_matrix_numcols(c1) == numcols + && jas_matrix_numrows(c2) == numrows && jas_matrix_numcols(c2) == numcols); - for (i = 0; i < numrows; i++) { - c0p = jas_matrix_getref(c0, i, 0); - c1p = jas_matrix_getref(c1, i, 0); - c2p = jas_matrix_getref(c2, i, 0); - for (j = numcols; j > 0; --j) { - int r; - int g; - int b; - int y; - int u; - int v; - r = *c0p; - g = *c1p; - b = *c2p; - y = (r + (g << 1) + b) >> 2; - u = b - g; - v = r - g; - *c0p++ = y; - *c1p++ = u; - *c2p++ = v; - } - } + for (i = 0; i < numrows; i++) { + c0p = jas_matrix_getref(c0, i, 0); + c1p = jas_matrix_getref(c1, i, 0); + c2p = jas_matrix_getref(c2, i, 0); + for (j = numcols; j > 0; --j) { + int r; + int g; + int b; + int y; + int u; + int v; + r = *c0p; + g = *c1p; + b = *c2p; + y = (r + (g << 1) + b) >> 2; + u = b - g; + v = r - g; + *c0p++ = y; + *c1p++ = u; + *c2p++ = v; + } + } } /* Compute the inverse RCT. */ void jpc_irct(jas_matrix_t *c0, jas_matrix_t *c1, jas_matrix_t *c2) { - int numrows; - int numcols; - int i; - int j; - jpc_fix_t *c0p; - jpc_fix_t *c1p; - jpc_fix_t *c2p; + int numrows; + int numcols; + int i; + int j; + jpc_fix_t *c0p; + jpc_fix_t *c1p; + jpc_fix_t *c2p; - numrows = jas_matrix_numrows(c0); - numcols = jas_matrix_numcols(c0); + numrows = jas_matrix_numrows(c0); + numcols = jas_matrix_numcols(c0); - /* All three matrices must have the same dimensions. */ - assert(jas_matrix_numrows(c1) == numrows && jas_matrix_numcols(c1) == numcols - && jas_matrix_numrows(c2) == numrows && jas_matrix_numcols(c2) == numcols); + /* All three matrices must have the same dimensions. */ + assert(jas_matrix_numrows(c1) == numrows && jas_matrix_numcols(c1) == numcols + && jas_matrix_numrows(c2) == numrows && jas_matrix_numcols(c2) == numcols); - for (i = 0; i < numrows; i++) { - c0p = jas_matrix_getref(c0, i, 0); - c1p = jas_matrix_getref(c1, i, 0); - c2p = jas_matrix_getref(c2, i, 0); - for (j = numcols; j > 0; --j) { - int r; - int g; - int b; - int y; - int u; - int v; - y = *c0p; - u = *c1p; - v = *c2p; - g = y - ((u + v) >> 2); - r = v + g; - b = u + g; - *c0p++ = r; - *c1p++ = g; - *c2p++ = b; - } - } + for (i = 0; i < numrows; i++) { + c0p = jas_matrix_getref(c0, i, 0); + c1p = jas_matrix_getref(c1, i, 0); + c2p = jas_matrix_getref(c2, i, 0); + for (j = numcols; j > 0; --j) { + int r; + int g; + int b; + int y; + int u; + int v; + y = *c0p; + u = *c1p; + v = *c2p; + g = y - ((u + v) >> 2); + r = v + g; + b = u + g; + *c0p++ = r; + *c1p++ = g; + *c2p++ = b; + } + } } void jpc_ict(jas_matrix_t *c0, jas_matrix_t *c1, jas_matrix_t *c2) { - int numrows; - int numcols; - int i; - int j; - jpc_fix_t r; - jpc_fix_t g; - jpc_fix_t b; - jpc_fix_t y; - jpc_fix_t u; - jpc_fix_t v; - jpc_fix_t *c0p; - jpc_fix_t *c1p; - jpc_fix_t *c2p; + int numrows; + int numcols; + int i; + int j; + jpc_fix_t r; + jpc_fix_t g; + jpc_fix_t b; + jpc_fix_t y; + jpc_fix_t u; + jpc_fix_t v; + jpc_fix_t *c0p; + jpc_fix_t *c1p; + jpc_fix_t *c2p; - numrows = jas_matrix_numrows(c0); - assert(jas_matrix_numrows(c1) == numrows && jas_matrix_numrows(c2) == numrows); - numcols = jas_matrix_numcols(c0); - assert(jas_matrix_numcols(c1) == numcols && jas_matrix_numcols(c2) == numcols); - for (i = 0; i < numrows; ++i) { - c0p = jas_matrix_getref(c0, i, 0); - c1p = jas_matrix_getref(c1, i, 0); - c2p = jas_matrix_getref(c2, i, 0); - for (j = numcols; j > 0; --j) { - r = *c0p; - g = *c1p; - b = *c2p; - y = jpc_fix_add3(jpc_fix_mul(jpc_dbltofix(0.299), r), jpc_fix_mul(jpc_dbltofix(0.587), g), - jpc_fix_mul(jpc_dbltofix(0.114), b)); - u = jpc_fix_add3(jpc_fix_mul(jpc_dbltofix(-0.16875), r), jpc_fix_mul(jpc_dbltofix(-0.33126), g), - jpc_fix_mul(jpc_dbltofix(0.5), b)); - v = jpc_fix_add3(jpc_fix_mul(jpc_dbltofix(0.5), r), jpc_fix_mul(jpc_dbltofix(-0.41869), g), - jpc_fix_mul(jpc_dbltofix(-0.08131), b)); - *c0p++ = y; - *c1p++ = u; - *c2p++ = v; - } - } + numrows = jas_matrix_numrows(c0); + assert(jas_matrix_numrows(c1) == numrows && jas_matrix_numrows(c2) == numrows); + numcols = jas_matrix_numcols(c0); + assert(jas_matrix_numcols(c1) == numcols && jas_matrix_numcols(c2) == numcols); + for (i = 0; i < numrows; ++i) { + c0p = jas_matrix_getref(c0, i, 0); + c1p = jas_matrix_getref(c1, i, 0); + c2p = jas_matrix_getref(c2, i, 0); + for (j = numcols; j > 0; --j) { + r = *c0p; + g = *c1p; + b = *c2p; + y = jpc_fix_add3(jpc_fix_mul(jpc_dbltofix(0.299), r), jpc_fix_mul(jpc_dbltofix(0.587), g), + jpc_fix_mul(jpc_dbltofix(0.114), b)); + u = jpc_fix_add3(jpc_fix_mul(jpc_dbltofix(-0.16875), r), jpc_fix_mul(jpc_dbltofix(-0.33126), g), + jpc_fix_mul(jpc_dbltofix(0.5), b)); + v = jpc_fix_add3(jpc_fix_mul(jpc_dbltofix(0.5), r), jpc_fix_mul(jpc_dbltofix(-0.41869), g), + jpc_fix_mul(jpc_dbltofix(-0.08131), b)); + *c0p++ = y; + *c1p++ = u; + *c2p++ = v; + } + } } void jpc_iict(jas_matrix_t *c0, jas_matrix_t *c1, jas_matrix_t *c2) { - int numrows; - int numcols; - int i; - int j; - jpc_fix_t r; - jpc_fix_t g; - jpc_fix_t b; - jpc_fix_t y; - jpc_fix_t u; - jpc_fix_t v; - jpc_fix_t *c0p; - jpc_fix_t *c1p; - jpc_fix_t *c2p; + int numrows; + int numcols; + int i; + int j; + jpc_fix_t r; + jpc_fix_t g; + jpc_fix_t b; + jpc_fix_t y; + jpc_fix_t u; + jpc_fix_t v; + jpc_fix_t *c0p; + jpc_fix_t *c1p; + jpc_fix_t *c2p; - numrows = jas_matrix_numrows(c0); - assert(jas_matrix_numrows(c1) == numrows && jas_matrix_numrows(c2) == numrows); - numcols = jas_matrix_numcols(c0); - assert(jas_matrix_numcols(c1) == numcols && jas_matrix_numcols(c2) == numcols); - for (i = 0; i < numrows; ++i) { - c0p = jas_matrix_getref(c0, i, 0); - c1p = jas_matrix_getref(c1, i, 0); - c2p = jas_matrix_getref(c2, i, 0); - for (j = numcols; j > 0; --j) { - y = *c0p; - u = *c1p; - v = *c2p; - r = jpc_fix_add(y, jpc_fix_mul(jpc_dbltofix(1.402), v)); - g = jpc_fix_add3(y, jpc_fix_mul(jpc_dbltofix(-0.34413), u), - jpc_fix_mul(jpc_dbltofix(-0.71414), v)); - b = jpc_fix_add(y, jpc_fix_mul(jpc_dbltofix(1.772), u)); - *c0p++ = r; - *c1p++ = g; - *c2p++ = b; - } - } + numrows = jas_matrix_numrows(c0); + assert(jas_matrix_numrows(c1) == numrows && jas_matrix_numrows(c2) == numrows); + numcols = jas_matrix_numcols(c0); + assert(jas_matrix_numcols(c1) == numcols && jas_matrix_numcols(c2) == numcols); + for (i = 0; i < numrows; ++i) { + c0p = jas_matrix_getref(c0, i, 0); + c1p = jas_matrix_getref(c1, i, 0); + c2p = jas_matrix_getref(c2, i, 0); + for (j = numcols; j > 0; --j) { + y = *c0p; + u = *c1p; + v = *c2p; + r = jpc_fix_add(y, jpc_fix_mul(jpc_dbltofix(1.402), v)); + g = jpc_fix_add3(y, jpc_fix_mul(jpc_dbltofix(-0.34413), u), + jpc_fix_mul(jpc_dbltofix(-0.71414), v)); + b = jpc_fix_add(y, jpc_fix_mul(jpc_dbltofix(1.772), u)); + *c0p++ = r; + *c1p++ = g; + *c2p++ = b; + } + } } jpc_fix_t jpc_mct_getsynweight(int mctid, int cmptno) { - jpc_fix_t synweight; + jpc_fix_t synweight; - switch (mctid) { - case JPC_MCT_RCT: - switch (cmptno) { - case 0: - synweight = jpc_dbltofix(sqrt(3.0)); - break; - case 1: - synweight = jpc_dbltofix(sqrt(0.6875)); - break; - case 2: - synweight = jpc_dbltofix(sqrt(0.6875)); - break; - } - break; - case JPC_MCT_ICT: - switch (cmptno) { - case 0: - synweight = jpc_dbltofix(sqrt(3.0000)); - break; - case 1: - synweight = jpc_dbltofix(sqrt(3.2584)); - break; - case 2: - synweight = jpc_dbltofix(sqrt(2.4755)); - break; - } - break; - default: - synweight = JPC_FIX_ONE; - break; - } + switch (mctid) { + case JPC_MCT_RCT: + switch (cmptno) { + case 0: + synweight = jpc_dbltofix(sqrt(3.0)); + break; + case 1: + synweight = jpc_dbltofix(sqrt(0.6875)); + break; + case 2: + synweight = jpc_dbltofix(sqrt(0.6875)); + break; + } + break; + case JPC_MCT_ICT: + switch (cmptno) { + case 0: + synweight = jpc_dbltofix(sqrt(3.0000)); + break; + case 1: + synweight = jpc_dbltofix(sqrt(3.2584)); + break; + case 2: + synweight = jpc_dbltofix(sqrt(2.4755)); + break; + } + break; + default: + synweight = JPC_FIX_ONE; + break; + } - return synweight; + return synweight; } diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_mct.h b/converter/other/jpeg2000/libjasper/jpc/jpc_mct.h index d03d6ce1..bb424900 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_mct.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_mct.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -134,9 +134,9 @@ * Multicomponent transform IDs. */ -#define JPC_MCT_NONE 0 -#define JPC_MCT_ICT 1 -#define JPC_MCT_RCT 2 +#define JPC_MCT_NONE 0 +#define JPC_MCT_ICT 1 +#define JPC_MCT_RCT 2 /******************************************************************************\ * Functions. diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.c b/converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.c index 535eaa2d..e19f94ad 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -131,98 +131,98 @@ /* MQ coder per-state information. */ jpc_mqstate_t jpc_mqstates[47 * 2] = { - {0x5601, 0, &jpc_mqstates[ 2], &jpc_mqstates[ 3]}, - {0x5601, 1, &jpc_mqstates[ 3], &jpc_mqstates[ 2]}, - {0x3401, 0, &jpc_mqstates[ 4], &jpc_mqstates[12]}, - {0x3401, 1, &jpc_mqstates[ 5], &jpc_mqstates[13]}, - {0x1801, 0, &jpc_mqstates[ 6], &jpc_mqstates[18]}, - {0x1801, 1, &jpc_mqstates[ 7], &jpc_mqstates[19]}, - {0x0ac1, 0, &jpc_mqstates[ 8], &jpc_mqstates[24]}, - {0x0ac1, 1, &jpc_mqstates[ 9], &jpc_mqstates[25]}, - {0x0521, 0, &jpc_mqstates[10], &jpc_mqstates[58]}, - {0x0521, 1, &jpc_mqstates[11], &jpc_mqstates[59]}, - {0x0221, 0, &jpc_mqstates[76], &jpc_mqstates[66]}, - {0x0221, 1, &jpc_mqstates[77], &jpc_mqstates[67]}, - {0x5601, 0, &jpc_mqstates[14], &jpc_mqstates[13]}, - {0x5601, 1, &jpc_mqstates[15], &jpc_mqstates[12]}, - {0x5401, 0, &jpc_mqstates[16], &jpc_mqstates[28]}, - {0x5401, 1, &jpc_mqstates[17], &jpc_mqstates[29]}, - {0x4801, 0, &jpc_mqstates[18], &jpc_mqstates[28]}, - {0x4801, 1, &jpc_mqstates[19], &jpc_mqstates[29]}, - {0x3801, 0, &jpc_mqstates[20], &jpc_mqstates[28]}, - {0x3801, 1, &jpc_mqstates[21], &jpc_mqstates[29]}, - {0x3001, 0, &jpc_mqstates[22], &jpc_mqstates[34]}, - {0x3001, 1, &jpc_mqstates[23], &jpc_mqstates[35]}, - {0x2401, 0, &jpc_mqstates[24], &jpc_mqstates[36]}, - {0x2401, 1, &jpc_mqstates[25], &jpc_mqstates[37]}, - {0x1c01, 0, &jpc_mqstates[26], &jpc_mqstates[40]}, - {0x1c01, 1, &jpc_mqstates[27], &jpc_mqstates[41]}, - {0x1601, 0, &jpc_mqstates[58], &jpc_mqstates[42]}, - {0x1601, 1, &jpc_mqstates[59], &jpc_mqstates[43]}, - {0x5601, 0, &jpc_mqstates[30], &jpc_mqstates[29]}, - {0x5601, 1, &jpc_mqstates[31], &jpc_mqstates[28]}, - {0x5401, 0, &jpc_mqstates[32], &jpc_mqstates[28]}, - {0x5401, 1, &jpc_mqstates[33], &jpc_mqstates[29]}, - {0x5101, 0, &jpc_mqstates[34], &jpc_mqstates[30]}, - {0x5101, 1, &jpc_mqstates[35], &jpc_mqstates[31]}, - {0x4801, 0, &jpc_mqstates[36], &jpc_mqstates[32]}, - {0x4801, 1, &jpc_mqstates[37], &jpc_mqstates[33]}, - {0x3801, 0, &jpc_mqstates[38], &jpc_mqstates[34]}, - {0x3801, 1, &jpc_mqstates[39], &jpc_mqstates[35]}, - {0x3401, 0, &jpc_mqstates[40], &jpc_mqstates[36]}, - {0x3401, 1, &jpc_mqstates[41], &jpc_mqstates[37]}, - {0x3001, 0, &jpc_mqstates[42], &jpc_mqstates[38]}, - {0x3001, 1, &jpc_mqstates[43], &jpc_mqstates[39]}, - {0x2801, 0, &jpc_mqstates[44], &jpc_mqstates[38]}, - {0x2801, 1, &jpc_mqstates[45], &jpc_mqstates[39]}, - {0x2401, 0, &jpc_mqstates[46], &jpc_mqstates[40]}, - {0x2401, 1, &jpc_mqstates[47], &jpc_mqstates[41]}, - {0x2201, 0, &jpc_mqstates[48], &jpc_mqstates[42]}, - {0x2201, 1, &jpc_mqstates[49], &jpc_mqstates[43]}, - {0x1c01, 0, &jpc_mqstates[50], &jpc_mqstates[44]}, - {0x1c01, 1, &jpc_mqstates[51], &jpc_mqstates[45]}, - {0x1801, 0, &jpc_mqstates[52], &jpc_mqstates[46]}, - {0x1801, 1, &jpc_mqstates[53], &jpc_mqstates[47]}, - {0x1601, 0, &jpc_mqstates[54], &jpc_mqstates[48]}, - {0x1601, 1, &jpc_mqstates[55], &jpc_mqstates[49]}, - {0x1401, 0, &jpc_mqstates[56], &jpc_mqstates[50]}, - {0x1401, 1, &jpc_mqstates[57], &jpc_mqstates[51]}, - {0x1201, 0, &jpc_mqstates[58], &jpc_mqstates[52]}, - {0x1201, 1, &jpc_mqstates[59], &jpc_mqstates[53]}, - {0x1101, 0, &jpc_mqstates[60], &jpc_mqstates[54]}, - {0x1101, 1, &jpc_mqstates[61], &jpc_mqstates[55]}, - {0x0ac1, 0, &jpc_mqstates[62], &jpc_mqstates[56]}, - {0x0ac1, 1, &jpc_mqstates[63], &jpc_mqstates[57]}, - {0x09c1, 0, &jpc_mqstates[64], &jpc_mqstates[58]}, - {0x09c1, 1, &jpc_mqstates[65], &jpc_mqstates[59]}, - {0x08a1, 0, &jpc_mqstates[66], &jpc_mqstates[60]}, - {0x08a1, 1, &jpc_mqstates[67], &jpc_mqstates[61]}, - {0x0521, 0, &jpc_mqstates[68], &jpc_mqstates[62]}, - {0x0521, 1, &jpc_mqstates[69], &jpc_mqstates[63]}, - {0x0441, 0, &jpc_mqstates[70], &jpc_mqstates[64]}, - {0x0441, 1, &jpc_mqstates[71], &jpc_mqstates[65]}, - {0x02a1, 0, &jpc_mqstates[72], &jpc_mqstates[66]}, - {0x02a1, 1, &jpc_mqstates[73], &jpc_mqstates[67]}, - {0x0221, 0, &jpc_mqstates[74], &jpc_mqstates[68]}, - {0x0221, 1, &jpc_mqstates[75], &jpc_mqstates[69]}, - {0x0141, 0, &jpc_mqstates[76], &jpc_mqstates[70]}, - {0x0141, 1, &jpc_mqstates[77], &jpc_mqstates[71]}, - {0x0111, 0, &jpc_mqstates[78], &jpc_mqstates[72]}, - {0x0111, 1, &jpc_mqstates[79], &jpc_mqstates[73]}, - {0x0085, 0, &jpc_mqstates[80], &jpc_mqstates[74]}, - {0x0085, 1, &jpc_mqstates[81], &jpc_mqstates[75]}, - {0x0049, 0, &jpc_mqstates[82], &jpc_mqstates[76]}, - {0x0049, 1, &jpc_mqstates[83], &jpc_mqstates[77]}, - {0x0025, 0, &jpc_mqstates[84], &jpc_mqstates[78]}, - {0x0025, 1, &jpc_mqstates[85], &jpc_mqstates[79]}, - {0x0015, 0, &jpc_mqstates[86], &jpc_mqstates[80]}, - {0x0015, 1, &jpc_mqstates[87], &jpc_mqstates[81]}, - {0x0009, 0, &jpc_mqstates[88], &jpc_mqstates[82]}, - {0x0009, 1, &jpc_mqstates[89], &jpc_mqstates[83]}, - {0x0005, 0, &jpc_mqstates[90], &jpc_mqstates[84]}, - {0x0005, 1, &jpc_mqstates[91], &jpc_mqstates[85]}, - {0x0001, 0, &jpc_mqstates[90], &jpc_mqstates[86]}, - {0x0001, 1, &jpc_mqstates[91], &jpc_mqstates[87]}, - {0x5601, 0, &jpc_mqstates[92], &jpc_mqstates[92]}, - {0x5601, 1, &jpc_mqstates[93], &jpc_mqstates[93]}, + {0x5601, 0, &jpc_mqstates[ 2], &jpc_mqstates[ 3]}, + {0x5601, 1, &jpc_mqstates[ 3], &jpc_mqstates[ 2]}, + {0x3401, 0, &jpc_mqstates[ 4], &jpc_mqstates[12]}, + {0x3401, 1, &jpc_mqstates[ 5], &jpc_mqstates[13]}, + {0x1801, 0, &jpc_mqstates[ 6], &jpc_mqstates[18]}, + {0x1801, 1, &jpc_mqstates[ 7], &jpc_mqstates[19]}, + {0x0ac1, 0, &jpc_mqstates[ 8], &jpc_mqstates[24]}, + {0x0ac1, 1, &jpc_mqstates[ 9], &jpc_mqstates[25]}, + {0x0521, 0, &jpc_mqstates[10], &jpc_mqstates[58]}, + {0x0521, 1, &jpc_mqstates[11], &jpc_mqstates[59]}, + {0x0221, 0, &jpc_mqstates[76], &jpc_mqstates[66]}, + {0x0221, 1, &jpc_mqstates[77], &jpc_mqstates[67]}, + {0x5601, 0, &jpc_mqstates[14], &jpc_mqstates[13]}, + {0x5601, 1, &jpc_mqstates[15], &jpc_mqstates[12]}, + {0x5401, 0, &jpc_mqstates[16], &jpc_mqstates[28]}, + {0x5401, 1, &jpc_mqstates[17], &jpc_mqstates[29]}, + {0x4801, 0, &jpc_mqstates[18], &jpc_mqstates[28]}, + {0x4801, 1, &jpc_mqstates[19], &jpc_mqstates[29]}, + {0x3801, 0, &jpc_mqstates[20], &jpc_mqstates[28]}, + {0x3801, 1, &jpc_mqstates[21], &jpc_mqstates[29]}, + {0x3001, 0, &jpc_mqstates[22], &jpc_mqstates[34]}, + {0x3001, 1, &jpc_mqstates[23], &jpc_mqstates[35]}, + {0x2401, 0, &jpc_mqstates[24], &jpc_mqstates[36]}, + {0x2401, 1, &jpc_mqstates[25], &jpc_mqstates[37]}, + {0x1c01, 0, &jpc_mqstates[26], &jpc_mqstates[40]}, + {0x1c01, 1, &jpc_mqstates[27], &jpc_mqstates[41]}, + {0x1601, 0, &jpc_mqstates[58], &jpc_mqstates[42]}, + {0x1601, 1, &jpc_mqstates[59], &jpc_mqstates[43]}, + {0x5601, 0, &jpc_mqstates[30], &jpc_mqstates[29]}, + {0x5601, 1, &jpc_mqstates[31], &jpc_mqstates[28]}, + {0x5401, 0, &jpc_mqstates[32], &jpc_mqstates[28]}, + {0x5401, 1, &jpc_mqstates[33], &jpc_mqstates[29]}, + {0x5101, 0, &jpc_mqstates[34], &jpc_mqstates[30]}, + {0x5101, 1, &jpc_mqstates[35], &jpc_mqstates[31]}, + {0x4801, 0, &jpc_mqstates[36], &jpc_mqstates[32]}, + {0x4801, 1, &jpc_mqstates[37], &jpc_mqstates[33]}, + {0x3801, 0, &jpc_mqstates[38], &jpc_mqstates[34]}, + {0x3801, 1, &jpc_mqstates[39], &jpc_mqstates[35]}, + {0x3401, 0, &jpc_mqstates[40], &jpc_mqstates[36]}, + {0x3401, 1, &jpc_mqstates[41], &jpc_mqstates[37]}, + {0x3001, 0, &jpc_mqstates[42], &jpc_mqstates[38]}, + {0x3001, 1, &jpc_mqstates[43], &jpc_mqstates[39]}, + {0x2801, 0, &jpc_mqstates[44], &jpc_mqstates[38]}, + {0x2801, 1, &jpc_mqstates[45], &jpc_mqstates[39]}, + {0x2401, 0, &jpc_mqstates[46], &jpc_mqstates[40]}, + {0x2401, 1, &jpc_mqstates[47], &jpc_mqstates[41]}, + {0x2201, 0, &jpc_mqstates[48], &jpc_mqstates[42]}, + {0x2201, 1, &jpc_mqstates[49], &jpc_mqstates[43]}, + {0x1c01, 0, &jpc_mqstates[50], &jpc_mqstates[44]}, + {0x1c01, 1, &jpc_mqstates[51], &jpc_mqstates[45]}, + {0x1801, 0, &jpc_mqstates[52], &jpc_mqstates[46]}, + {0x1801, 1, &jpc_mqstates[53], &jpc_mqstates[47]}, + {0x1601, 0, &jpc_mqstates[54], &jpc_mqstates[48]}, + {0x1601, 1, &jpc_mqstates[55], &jpc_mqstates[49]}, + {0x1401, 0, &jpc_mqstates[56], &jpc_mqstates[50]}, + {0x1401, 1, &jpc_mqstates[57], &jpc_mqstates[51]}, + {0x1201, 0, &jpc_mqstates[58], &jpc_mqstates[52]}, + {0x1201, 1, &jpc_mqstates[59], &jpc_mqstates[53]}, + {0x1101, 0, &jpc_mqstates[60], &jpc_mqstates[54]}, + {0x1101, 1, &jpc_mqstates[61], &jpc_mqstates[55]}, + {0x0ac1, 0, &jpc_mqstates[62], &jpc_mqstates[56]}, + {0x0ac1, 1, &jpc_mqstates[63], &jpc_mqstates[57]}, + {0x09c1, 0, &jpc_mqstates[64], &jpc_mqstates[58]}, + {0x09c1, 1, &jpc_mqstates[65], &jpc_mqstates[59]}, + {0x08a1, 0, &jpc_mqstates[66], &jpc_mqstates[60]}, + {0x08a1, 1, &jpc_mqstates[67], &jpc_mqstates[61]}, + {0x0521, 0, &jpc_mqstates[68], &jpc_mqstates[62]}, + {0x0521, 1, &jpc_mqstates[69], &jpc_mqstates[63]}, + {0x0441, 0, &jpc_mqstates[70], &jpc_mqstates[64]}, + {0x0441, 1, &jpc_mqstates[71], &jpc_mqstates[65]}, + {0x02a1, 0, &jpc_mqstates[72], &jpc_mqstates[66]}, + {0x02a1, 1, &jpc_mqstates[73], &jpc_mqstates[67]}, + {0x0221, 0, &jpc_mqstates[74], &jpc_mqstates[68]}, + {0x0221, 1, &jpc_mqstates[75], &jpc_mqstates[69]}, + {0x0141, 0, &jpc_mqstates[76], &jpc_mqstates[70]}, + {0x0141, 1, &jpc_mqstates[77], &jpc_mqstates[71]}, + {0x0111, 0, &jpc_mqstates[78], &jpc_mqstates[72]}, + {0x0111, 1, &jpc_mqstates[79], &jpc_mqstates[73]}, + {0x0085, 0, &jpc_mqstates[80], &jpc_mqstates[74]}, + {0x0085, 1, &jpc_mqstates[81], &jpc_mqstates[75]}, + {0x0049, 0, &jpc_mqstates[82], &jpc_mqstates[76]}, + {0x0049, 1, &jpc_mqstates[83], &jpc_mqstates[77]}, + {0x0025, 0, &jpc_mqstates[84], &jpc_mqstates[78]}, + {0x0025, 1, &jpc_mqstates[85], &jpc_mqstates[79]}, + {0x0015, 0, &jpc_mqstates[86], &jpc_mqstates[80]}, + {0x0015, 1, &jpc_mqstates[87], &jpc_mqstates[81]}, + {0x0009, 0, &jpc_mqstates[88], &jpc_mqstates[82]}, + {0x0009, 1, &jpc_mqstates[89], &jpc_mqstates[83]}, + {0x0005, 0, &jpc_mqstates[90], &jpc_mqstates[84]}, + {0x0005, 1, &jpc_mqstates[91], &jpc_mqstates[85]}, + {0x0001, 0, &jpc_mqstates[90], &jpc_mqstates[86]}, + {0x0001, 1, &jpc_mqstates[91], &jpc_mqstates[87]}, + {0x5601, 0, &jpc_mqstates[92], &jpc_mqstates[92]}, + {0x5601, 1, &jpc_mqstates[93], &jpc_mqstates[93]}, }; diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.h b/converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.h index 5f99e021..f32fc7fc 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_mqcod.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -136,11 +136,11 @@ typedef struct { - /* The most probable symbol (MPS). */ - bool mps; + /* The most probable symbol (MPS). */ + bool mps; - /* The state index. */ - int_fast16_t ind; + /* The state index. */ + int_fast16_t ind; } jpc_mqctx_t; @@ -150,17 +150,17 @@ typedef struct { typedef struct jpc_mqstate_s { - /* The Qe value. */ - uint_fast16_t qeval; + /* The Qe value. */ + uint_fast16_t qeval; - /* The MPS. */ - uint_fast16_t mps; + /* The MPS. */ + uint_fast16_t mps; - /* The NMPS state. */ - struct jpc_mqstate_s *nmps; + /* The NMPS state. */ + struct jpc_mqstate_s *nmps; - /* The NLPS state. */ - struct jpc_mqstate_s *nlps; + /* The NLPS state. */ + struct jpc_mqstate_s *nlps; } jpc_mqstate_t; diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.c b/converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.c index f58a1c7d..2d419522 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -136,10 +136,10 @@ \******************************************************************************/ #if defined(DEBUG) -#define MQDEC_CALL(n, x) \ - ((jas_getdbglevel() >= (n)) ? ((void)(x)) : ((void)0)) +#define MQDEC_CALL(n, x) \ + ((jas_getdbglevel() >= (n)) ? ((void)(x)) : ((void)0)) #else -#define MQDEC_CALL(n, x) +#define MQDEC_CALL(n, x) #endif /******************************************************************************\ @@ -155,49 +155,49 @@ static void jpc_mqdec_bytein(jpc_mqdec_t *mqdec); /* Create a MQ decoder. */ jpc_mqdec_t *jpc_mqdec_create(int maxctxs, jas_stream_t *in) { - jpc_mqdec_t *mqdec; - - /* There must be at least one context. */ - assert(maxctxs > 0); - - /* Allocate memory for the MQ decoder. */ - if (!(mqdec = jas_malloc(sizeof(jpc_mqdec_t)))) { - goto error; - } - mqdec->in = in; - mqdec->maxctxs = maxctxs; - /* Allocate memory for the per-context state information. */ - if (!(mqdec->ctxs = jas_malloc(mqdec->maxctxs * sizeof(jpc_mqstate_t *)))) { - goto error; - } - /* Set the current context to the first context. */ - mqdec->curctx = mqdec->ctxs; - - /* If an input stream has been associated with the MQ decoder, - initialize the decoder state from the stream. */ - if (mqdec->in) { - jpc_mqdec_init(mqdec); - } - /* Initialize the per-context state information. */ - jpc_mqdec_setctxs(mqdec, 0, 0); - - return mqdec; + jpc_mqdec_t *mqdec; + + /* There must be at least one context. */ + assert(maxctxs > 0); + + /* Allocate memory for the MQ decoder. */ + if (!(mqdec = jas_malloc(sizeof(jpc_mqdec_t)))) { + goto error; + } + mqdec->in = in; + mqdec->maxctxs = maxctxs; + /* Allocate memory for the per-context state information. */ + if (!(mqdec->ctxs = jas_malloc(mqdec->maxctxs * sizeof(jpc_mqstate_t *)))) { + goto error; + } + /* Set the current context to the first context. */ + mqdec->curctx = mqdec->ctxs; + + /* If an input stream has been associated with the MQ decoder, + initialize the decoder state from the stream. */ + if (mqdec->in) { + jpc_mqdec_init(mqdec); + } + /* Initialize the per-context state information. */ + jpc_mqdec_setctxs(mqdec, 0, 0); + + return mqdec; error: - /* Oops... Something has gone wrong. */ - if (mqdec) { - jpc_mqdec_destroy(mqdec); - } - return 0; + /* Oops... Something has gone wrong. */ + if (mqdec) { + jpc_mqdec_destroy(mqdec); + } + return 0; } /* Destroy a MQ decoder. */ void jpc_mqdec_destroy(jpc_mqdec_t *mqdec) { - if (mqdec->ctxs) { - jas_free(mqdec->ctxs); - } - jas_free(mqdec); + if (mqdec->ctxs) { + jas_free(mqdec->ctxs); + } + jas_free(mqdec); } /******************************************************************************\ @@ -208,59 +208,59 @@ void jpc_mqdec_destroy(jpc_mqdec_t *mqdec) void jpc_mqdec_init(jpc_mqdec_t *mqdec) { - int c; - - mqdec->eof = 0; - mqdec->creg = 0; - /* Get the next byte from the input stream. */ - if ((c = jas_stream_getc(mqdec->in)) == EOF) { - /* We have encountered an I/O error or EOF. */ - c = 0xff; - mqdec->eof = 1; - } - mqdec->inbuffer = c; - mqdec->creg += mqdec->inbuffer << 16; - jpc_mqdec_bytein(mqdec); - mqdec->creg <<= 7; - mqdec->ctreg -= 7; - mqdec->areg = 0x8000; + int c; + + mqdec->eof = 0; + mqdec->creg = 0; + /* Get the next byte from the input stream. */ + if ((c = jas_stream_getc(mqdec->in)) == EOF) { + /* We have encountered an I/O error or EOF. */ + c = 0xff; + mqdec->eof = 1; + } + mqdec->inbuffer = c; + mqdec->creg += mqdec->inbuffer << 16; + jpc_mqdec_bytein(mqdec); + mqdec->creg <<= 7; + mqdec->ctreg -= 7; + mqdec->areg = 0x8000; } /* Set the input stream for a MQ decoder. */ void jpc_mqdec_setinput(jpc_mqdec_t *mqdec, jas_stream_t *in) { - mqdec->in = in; + mqdec->in = in; } /* Initialize one or more contexts. */ void jpc_mqdec_setctxs(jpc_mqdec_t *mqdec, int numctxs, jpc_mqctx_t *ctxs) { - jpc_mqstate_t **ctx; - int n; - - ctx = mqdec->ctxs; - n = JAS_MIN(mqdec->maxctxs, numctxs); - while (--n >= 0) { - *ctx = &jpc_mqstates[2 * ctxs->ind + ctxs->mps]; - ++ctx; - ++ctxs; - } - n = mqdec->maxctxs - numctxs; - while (--n >= 0) { - *ctx = &jpc_mqstates[0]; - ++ctx; - } + jpc_mqstate_t **ctx; + int n; + + ctx = mqdec->ctxs; + n = JAS_MIN(mqdec->maxctxs, numctxs); + while (--n >= 0) { + *ctx = &jpc_mqstates[2 * ctxs->ind + ctxs->mps]; + ++ctx; + ++ctxs; + } + n = mqdec->maxctxs - numctxs; + while (--n >= 0) { + *ctx = &jpc_mqstates[0]; + ++ctx; + } } /* Initialize a context. */ void jpc_mqdec_setctx(jpc_mqdec_t *mqdec, int ctxno, jpc_mqctx_t *ctx) { - jpc_mqstate_t **ctxi; - ctxi = &mqdec->ctxs[ctxno]; - *ctxi = &jpc_mqstates[2 * ctx->ind + ctx->mps]; + jpc_mqstate_t **ctxi; + ctxi = &mqdec->ctxs[ctxno]; + *ctxi = &jpc_mqstates[2 * ctx->ind + ctx->mps]; } /******************************************************************************\ @@ -271,36 +271,36 @@ void jpc_mqdec_setctx(jpc_mqdec_t *mqdec, int ctxno, jpc_mqctx_t *ctx) int jpc_mqdec_getbit_func(register jpc_mqdec_t *mqdec) { - int bit; - JAS_DBGLOG(100, ("jpc_mqdec_getbit_func(%p)\n", mqdec)); - MQDEC_CALL(100, jpc_mqdec_dump(mqdec, stderr)); - bit = jpc_mqdec_getbit_macro(mqdec); - MQDEC_CALL(100, jpc_mqdec_dump(mqdec, stderr)); - JAS_DBGLOG(100, ("ctx = %d, decoded %d\n", mqdec->curctx - - mqdec->ctxs, bit)); - return bit; + int bit; + JAS_DBGLOG(100, ("jpc_mqdec_getbit_func(%p)\n", mqdec)); + MQDEC_CALL(100, jpc_mqdec_dump(mqdec, stderr)); + bit = jpc_mqdec_getbit_macro(mqdec); + MQDEC_CALL(100, jpc_mqdec_dump(mqdec, stderr)); + JAS_DBGLOG(100, ("ctx = %d, decoded %d\n", mqdec->curctx - + mqdec->ctxs, bit)); + return bit; } /* Apply MPS_EXCHANGE algorithm (with RENORMD). */ int jpc_mqdec_mpsexchrenormd(register jpc_mqdec_t *mqdec) { - int ret; - register jpc_mqstate_t *state = *mqdec->curctx; - jpc_mqdec_mpsexchange(mqdec->areg, state->qeval, mqdec->curctx, ret); - jpc_mqdec_renormd(mqdec->areg, mqdec->creg, mqdec->ctreg, mqdec->in, - mqdec->eof, mqdec->inbuffer); - return ret; + int ret; + register jpc_mqstate_t *state = *mqdec->curctx; + jpc_mqdec_mpsexchange(mqdec->areg, state->qeval, mqdec->curctx, ret); + jpc_mqdec_renormd(mqdec->areg, mqdec->creg, mqdec->ctreg, mqdec->in, + mqdec->eof, mqdec->inbuffer); + return ret; } /* Apply LPS_EXCHANGE algorithm (with RENORMD). */ int jpc_mqdec_lpsexchrenormd(register jpc_mqdec_t *mqdec) { - int ret; - register jpc_mqstate_t *state = *mqdec->curctx; - jpc_mqdec_lpsexchange(mqdec->areg, state->qeval, mqdec->curctx, ret); - jpc_mqdec_renormd(mqdec->areg, mqdec->creg, mqdec->ctreg, mqdec->in, - mqdec->eof, mqdec->inbuffer); - return ret; + int ret; + register jpc_mqstate_t *state = *mqdec->curctx; + jpc_mqdec_lpsexchange(mqdec->areg, state->qeval, mqdec->curctx, ret); + jpc_mqdec_renormd(mqdec->areg, mqdec->creg, mqdec->ctreg, mqdec->in, + mqdec->eof, mqdec->inbuffer); + return ret; } /******************************************************************************\ @@ -310,30 +310,30 @@ int jpc_mqdec_lpsexchrenormd(register jpc_mqdec_t *mqdec) /* Apply the BYTEIN algorithm. */ static void jpc_mqdec_bytein(jpc_mqdec_t *mqdec) { - int c; - unsigned char prevbuf; - - if (!mqdec->eof) { - if ((c = jas_stream_getc(mqdec->in)) == EOF) { - mqdec->eof = 1; - c = 0xff; - } - prevbuf = mqdec->inbuffer; - mqdec->inbuffer = c; - if (prevbuf == 0xff) { - if (c > 0x8f) { - mqdec->creg += 0xff00; - mqdec->ctreg = 8; - } else { - mqdec->creg += c << 9; - mqdec->ctreg = 7; - } - } else { - mqdec->creg += c << 8; - mqdec->ctreg = 8; - } - } else { - mqdec->creg += 0xff00; - mqdec->ctreg = 8; - } + int c; + unsigned char prevbuf; + + if (!mqdec->eof) { + if ((c = jas_stream_getc(mqdec->in)) == EOF) { + mqdec->eof = 1; + c = 0xff; + } + prevbuf = mqdec->inbuffer; + mqdec->inbuffer = c; + if (prevbuf == 0xff) { + if (c > 0x8f) { + mqdec->creg += 0xff00; + mqdec->ctreg = 8; + } else { + mqdec->creg += c << 9; + mqdec->ctreg = 7; + } + } else { + mqdec->creg += c << 8; + mqdec->ctreg = 8; + } + } else { + mqdec->creg += 0xff00; + mqdec->ctreg = 8; + } } diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.h b/converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.h index 30185506..b207c92b 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_mqdec.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -136,32 +136,32 @@ typedef struct { - /* The C register. */ - uint_fast32_t creg; + /* The C register. */ + uint_fast32_t creg; - /* The A register. */ - uint_fast32_t areg; + /* The A register. */ + uint_fast32_t areg; - /* The CT register. */ - uint_fast32_t ctreg; + /* The CT register. */ + uint_fast32_t ctreg; - /* The current context. */ - jpc_mqstate_t **curctx; + /* The current context. */ + jpc_mqstate_t **curctx; - /* The per-context information. */ - jpc_mqstate_t **ctxs; + /* The per-context information. */ + jpc_mqstate_t **ctxs; - /* The maximum number of contexts. */ - int maxctxs; + /* The maximum number of contexts. */ + int maxctxs; - /* The stream from which to read data. */ - jas_stream_t *in; + /* The stream from which to read data. */ + jas_stream_t *in; - /* The last character read. */ - unsigned char inbuffer; + /* The last character read. */ + unsigned char inbuffer; - /* The EOF indicator. */ - int eof; + /* The EOF indicator. */ + int eof; } jpc_mqdec_t; @@ -190,8 +190,8 @@ void jpc_mqdec_init(jpc_mqdec_t *dec); \******************************************************************************/ /* Set the current context for a MQ decoder. */ -#define jpc_mqdec_setcurctx(dec, ctxno) \ - ((mqdec)->curctx = &(mqdec)->ctxs[ctxno]); +#define jpc_mqdec_setcurctx(dec, ctxno) \ + ((mqdec)->curctx = &(mqdec)->ctxs[ctxno]); /* Set the state information for a particular context of a MQ decoder. */ void jpc_mqdec_setctx(jpc_mqdec_t *dec, int ctxno, jpc_mqctx_t *ctx); @@ -205,20 +205,20 @@ void jpc_mqdec_setctxs(jpc_mqdec_t *dec, int numctxs, jpc_mqctx_t *ctxs); /* Decode a symbol. */ #if !defined(DEBUG) -#define jpc_mqdec_getbit(dec) \ - jpc_mqdec_getbit_macro(dec) +#define jpc_mqdec_getbit(dec) \ + jpc_mqdec_getbit_macro(dec) #else -#define jpc_mqdec_getbit(dec) \ - jpc_mqdec_getbit_func(dec) +#define jpc_mqdec_getbit(dec) \ + jpc_mqdec_getbit_func(dec) #endif /* Decode a symbol (assuming an unskewed probability distribution). */ #if !defined(DEBUG) -#define jpc_mqdec_getbitnoskew(dec) \ - jpc_mqdec_getbit_macro(dec) +#define jpc_mqdec_getbitnoskew(dec) \ + jpc_mqdec_getbit_macro(dec) #else -#define jpc_mqdec_getbitnoskew(dec) \ - jpc_mqdec_getbit_func(dec) +#define jpc_mqdec_getbitnoskew(dec) \ + jpc_mqdec_getbit_func(dec) #endif /******************************************************************************\ @@ -234,83 +234,83 @@ void mqdec_dump(jpc_mqdec_t *dec, FILE *out); * GIVEN BELOW. \******************************************************************************/ -#define jpc_mqdec_getbit_macro(dec) \ - ((((dec)->areg -= (*(dec)->curctx)->qeval), \ - (dec)->creg >> 16 >= (*(dec)->curctx)->qeval) ? \ - ((((dec)->creg -= (*(dec)->curctx)->qeval << 16), \ - (dec)->areg & 0x8000) ? (*(dec)->curctx)->mps : \ - jpc_mqdec_mpsexchrenormd(dec)) : \ - jpc_mqdec_lpsexchrenormd(dec)) +#define jpc_mqdec_getbit_macro(dec) \ + ((((dec)->areg -= (*(dec)->curctx)->qeval), \ + (dec)->creg >> 16 >= (*(dec)->curctx)->qeval) ? \ + ((((dec)->creg -= (*(dec)->curctx)->qeval << 16), \ + (dec)->areg & 0x8000) ? (*(dec)->curctx)->mps : \ + jpc_mqdec_mpsexchrenormd(dec)) : \ + jpc_mqdec_lpsexchrenormd(dec)) -#define jpc_mqdec_mpsexchange(areg, delta, curctx, bit) \ +#define jpc_mqdec_mpsexchange(areg, delta, curctx, bit) \ { \ - if ((areg) < (delta)) { \ - register jpc_mqstate_t *state = *(curctx); \ - /* LPS decoded. */ \ - (bit) = state->mps ^ 1; \ - *(curctx) = state->nlps; \ - } else { \ - register jpc_mqstate_t *state = *(curctx); \ - /* MPS decoded. */ \ - (bit) = state->mps; \ - *(curctx) = state->nmps; \ - } \ + if ((areg) < (delta)) { \ + register jpc_mqstate_t *state = *(curctx); \ + /* LPS decoded. */ \ + (bit) = state->mps ^ 1; \ + *(curctx) = state->nlps; \ + } else { \ + register jpc_mqstate_t *state = *(curctx); \ + /* MPS decoded. */ \ + (bit) = state->mps; \ + *(curctx) = state->nmps; \ + } \ } -#define jpc_mqdec_lpsexchange(areg, delta, curctx, bit) \ +#define jpc_mqdec_lpsexchange(areg, delta, curctx, bit) \ { \ - if ((areg) >= (delta)) { \ - register jpc_mqstate_t *state = *(curctx); \ - (areg) = (delta); \ - (bit) = state->mps ^ 1; \ - *(curctx) = state->nlps; \ - } else { \ - register jpc_mqstate_t *state = *(curctx); \ - (areg) = (delta); \ - (bit) = state->mps; \ - *(curctx) = state->nmps; \ - } \ + if ((areg) >= (delta)) { \ + register jpc_mqstate_t *state = *(curctx); \ + (areg) = (delta); \ + (bit) = state->mps ^ 1; \ + *(curctx) = state->nlps; \ + } else { \ + register jpc_mqstate_t *state = *(curctx); \ + (areg) = (delta); \ + (bit) = state->mps; \ + *(curctx) = state->nmps; \ + } \ } -#define jpc_mqdec_renormd(areg, creg, ctreg, in, eof, inbuf) \ +#define jpc_mqdec_renormd(areg, creg, ctreg, in, eof, inbuf) \ { \ - do { \ - if (!(ctreg)) { \ - jpc_mqdec_bytein2(creg, ctreg, in, eof, inbuf); \ - } \ - (areg) <<= 1; \ - (creg) <<= 1; \ - --(ctreg); \ - } while (!((areg) & 0x8000)); \ + do { \ + if (!(ctreg)) { \ + jpc_mqdec_bytein2(creg, ctreg, in, eof, inbuf); \ + } \ + (areg) <<= 1; \ + (creg) <<= 1; \ + --(ctreg); \ + } while (!((areg) & 0x8000)); \ } -#define jpc_mqdec_bytein2(creg, ctreg, in, eof, inbuf) \ +#define jpc_mqdec_bytein2(creg, ctreg, in, eof, inbuf) \ { \ - int c; \ - unsigned char prevbuf; \ - if (!(eof)) { \ - if ((c = jas_stream_getc(in)) == EOF) { \ - (eof) = 1; \ - c = 0xff; \ - } \ - prevbuf = (inbuf); \ - (inbuf) = c; \ - if (prevbuf == 0xff) { \ - if (c > 0x8f) { \ - (creg) += 0xff00; \ - (ctreg) = 8; \ - } else { \ - (creg) += c << 9; \ - (ctreg) = 7; \ - } \ - } else { \ - (creg) += c << 8; \ - (ctreg) = 8; \ - } \ - } else { \ - (creg) += 0xff00; \ - (ctreg) = 8; \ - } \ + int c; \ + unsigned char prevbuf; \ + if (!(eof)) { \ + if ((c = jas_stream_getc(in)) == EOF) { \ + (eof) = 1; \ + c = 0xff; \ + } \ + prevbuf = (inbuf); \ + (inbuf) = c; \ + if (prevbuf == 0xff) { \ + if (c > 0x8f) { \ + (creg) += 0xff00; \ + (ctreg) = 8; \ + } else { \ + (creg) += c << 9; \ + (ctreg) = 7; \ + } \ + } else { \ + (creg) += c << 8; \ + (ctreg) = 8; \ + } \ + } else { \ + (creg) += 0xff00; \ + (ctreg) = 8; \ + } \ } int jpc_mqdec_getbit_func(jpc_mqdec_t *dec); diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_mqenc.h b/converter/other/jpeg2000/libjasper/jpc/jpc_mqenc.h index 1421ae4d..4a1be355 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_mqenc.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_mqenc.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -136,8 +136,8 @@ * Termination modes. */ -#define JPC_MQENC_DEFTERM 0 /* default termination */ -#define JPC_MQENC_PTERM 1 /* predictable termination */ +#define JPC_MQENC_DEFTERM 0 /* default termination */ +#define JPC_MQENC_PTERM 1 /* predictable termination */ /******************************************************************************\ * Types. @@ -147,53 +147,53 @@ typedef struct { - /* The C register. */ - uint_fast32_t creg; + /* The C register. */ + uint_fast32_t creg; - /* The A register. */ - uint_fast32_t areg; + /* The A register. */ + uint_fast32_t areg; - /* The CT register. */ - uint_fast32_t ctreg; + /* The CT register. */ + uint_fast32_t ctreg; - /* The maximum number of contexts. */ - int maxctxs; + /* The maximum number of contexts. */ + int maxctxs; - /* The per-context information. */ - jpc_mqstate_t **ctxs; + /* The per-context information. */ + jpc_mqstate_t **ctxs; - /* The current context. */ - jpc_mqstate_t **curctx; + /* The current context. */ + jpc_mqstate_t **curctx; - /* The stream for encoder output. */ - jas_stream_t *out; + /* The stream for encoder output. */ + jas_stream_t *out; - /* The byte buffer (i.e., the B variable in the standard). */ - int_fast16_t outbuf; + /* The byte buffer (i.e., the B variable in the standard). */ + int_fast16_t outbuf; - /* The last byte output. */ - int_fast16_t lastbyte; + /* The last byte output. */ + int_fast16_t lastbyte; - /* The error indicator. */ - int err; - + /* The error indicator. */ + int err; + } jpc_mqenc_t; /* MQ arithmetic encoder state information. */ typedef struct { - /* The A register. */ - unsigned areg; + /* The A register. */ + unsigned areg; - /* The C register. */ - unsigned creg; + /* The C register. */ + unsigned creg; - /* The CT register. */ - unsigned ctreg; + /* The CT register. */ + unsigned ctreg; - /* The last byte output by the encoder. */ - int lastbyte; + /* The last byte output by the encoder. */ + int lastbyte; } jpc_mqencstate_t; @@ -219,7 +219,7 @@ void jpc_mqenc_init(jpc_mqenc_t *enc); \******************************************************************************/ /* Set the current context. */ -#define jpc_mqenc_setcurctx(enc, ctxno) \ +#define jpc_mqenc_setcurctx(enc, ctxno) \ ((enc)->curctx = &(enc)->ctxs[ctxno]); /* Set the state information for a particular context. */ @@ -233,8 +233,8 @@ void jpc_mqenc_setctxs(jpc_mqenc_t *enc, int numctxs, jpc_mqctx_t *ctxs); \******************************************************************************/ /* Get the error state of a MQ encoder. */ -#define jpc_mqenc_error(enc) \ - ((enc)->err) +#define jpc_mqenc_error(enc) \ + ((enc)->err) /* Get the current encoder state. */ void jpc_mqenc_getstate(jpc_mqenc_t *enc, jpc_mqencstate_t *state); @@ -248,9 +248,9 @@ int jpc_mqenc_flush(jpc_mqenc_t *enc, int termmode); /* Encode a bit. */ #if !defined(DEBUG) -#define jpc_mqenc_putbit(enc, bit) jpc_mqenc_putbit_macro(enc, bit) +#define jpc_mqenc_putbit(enc, bit) jpc_mqenc_putbit_macro(enc, bit) #else -#define jpc_mqenc_putbit(enc, bit) jpc_mqenc_putbit_func(enc, bit) +#define jpc_mqenc_putbit(enc, bit) jpc_mqenc_putbit_func(enc, bit) #endif /******************************************************************************\ @@ -265,12 +265,12 @@ int jpc_mqenc_dump(jpc_mqenc_t *mqenc, FILE *out); /* Note: This macro is included only to satisfy the needs of the mqenc_putbit macro. */ -#define jpc_mqenc_putbit_macro(enc, bit) \ - (((*((enc)->curctx))->mps == (bit)) ? \ - (((enc)->areg -= (*(enc)->curctx)->qeval), \ - ((!((enc)->areg & 0x8000)) ? (jpc_mqenc_codemps2(enc)) : \ - ((enc)->creg += (*(enc)->curctx)->qeval))) : \ - jpc_mqenc_codelps(enc)) +#define jpc_mqenc_putbit_macro(enc, bit) \ + (((*((enc)->curctx))->mps == (bit)) ? \ + (((enc)->areg -= (*(enc)->curctx)->qeval), \ + ((!((enc)->areg & 0x8000)) ? (jpc_mqenc_codemps2(enc)) : \ + ((enc)->creg += (*(enc)->curctx)->qeval))) : \ + jpc_mqenc_codelps(enc)) /* Note: These function prototypes are included only to satisfy the needs of the mqenc_putbit_macro macro. Do not call any of these diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.c b/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.c index 80bc5aa5..3962f5ad 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -153,19 +153,19 @@ static void jpc_ns_synthesize(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x); \******************************************************************************/ jpc_qmfb1dops_t jpc_ft_ops = { - jpc_ft_getnumchans, - jpc_ft_getanalfilters, - jpc_ft_getsynfilters, - jpc_ft_analyze, - jpc_ft_synthesize + jpc_ft_getnumchans, + jpc_ft_getanalfilters, + jpc_ft_getsynfilters, + jpc_ft_analyze, + jpc_ft_synthesize }; jpc_qmfb1dops_t jpc_ns_ops = { - jpc_ns_getnumchans, - jpc_ns_getanalfilters, - jpc_ns_getsynfilters, - jpc_ns_analyze, - jpc_ns_synthesize + jpc_ns_getnumchans, + jpc_ns_getanalfilters, + jpc_ns_getsynfilters, + jpc_ns_analyze, + jpc_ns_synthesize }; /******************************************************************************\ @@ -176,12 +176,12 @@ static void jpc_qmfb1d_setup(jpc_fix_t *startptr, int startind, int endind, int intrastep, jpc_fix_t **lstartptr, int *lstartind, int *lendind, jpc_fix_t **hstartptr, int *hstartind, int *hendind) { - *lstartind = JPC_CEILDIVPOW2(startind, 1); - *lendind = JPC_CEILDIVPOW2(endind, 1); - *hstartind = JPC_FLOORDIVPOW2(startind, 1); - *hendind = JPC_FLOORDIVPOW2(endind, 1); - *lstartptr = startptr; - *hstartptr = &startptr[(*lendind - *lstartind) * intrastep]; + *lstartind = JPC_CEILDIVPOW2(startind, 1); + *lendind = JPC_CEILDIVPOW2(endind, 1); + *hstartind = JPC_FLOORDIVPOW2(startind, 1); + *hendind = JPC_FLOORDIVPOW2(endind, 1); + *lstartptr = startptr; + *hstartptr = &startptr[(*lendind - *lstartind) * intrastep]; } static void jpc_qmfb1d_split(jpc_fix_t *startptr, int startind, int endind, @@ -189,204 +189,204 @@ static void jpc_qmfb1d_split(jpc_fix_t *startptr, int startind, int endind, jpc_fix_t *hstartptr, int hstartind, int hendind) { #define QMFB_SPLITBUFSIZE 4096 - jpc_fix_t splitbuf[QMFB_SPLITBUFSIZE]; - jpc_fix_t *buf = splitbuf; - int llen; - int hlen; - int twostep; - jpc_fix_t *tmpptr; - register jpc_fix_t *ptr; - register jpc_fix_t *hptr; - register jpc_fix_t *lptr; - register int n; - int state; - - twostep = step << 1; - llen = lendind - lstartind; - hlen = hendind - hstartind; - - if (hstartind < lstartind) { - /* The first sample in the input signal is to appear - in the highpass subband signal. */ - /* Copy the appropriate samples into the lowpass subband - signal, saving any samples destined for the highpass subband - signal as they are overwritten. */ - tmpptr = buf; - ptr = &startptr[step]; - lptr = lstartptr; - n = llen; - state = 1; - while (n-- > 0) { - if (state) { - *tmpptr = *lptr; - ++tmpptr; - } - *lptr = *ptr; - ptr += twostep; - lptr += step; - state ^= 1; - } - /* Copy the appropriate samples into the highpass subband - signal. */ - /* Handle the nonoverwritten samples. */ - hptr = &hstartptr[(hlen - 1) * step]; - ptr = &startptr[(((llen + hlen - 1) >> 1) << 1) * step]; - n = hlen - (tmpptr - buf); - while (n-- > 0) { - *hptr = *ptr; - hptr -= step; - ptr -= twostep; - } - /* Handle the overwritten samples. */ - n = tmpptr - buf; - while (n-- > 0) { - --tmpptr; - *hptr = *tmpptr; - hptr -= step; - } - } else { - /* The first sample in the input signal is to appear - in the lowpass subband signal. */ - /* Copy the appropriate samples into the lowpass subband - signal, saving any samples for the highpass subband - signal as they are overwritten. */ - state = 0; - ptr = startptr; - lptr = lstartptr; - tmpptr = buf; - n = llen; - while (n-- > 0) { - if (state) { - *tmpptr = *lptr; - ++tmpptr; - } - *lptr = *ptr; - ptr += twostep; - lptr += step; - state ^= 1; - } - /* Copy the appropriate samples into the highpass subband - signal. */ - /* Handle the nonoverwritten samples. */ - ptr = &startptr[((((llen + hlen) >> 1) << 1) - 1) * step]; - hptr = &hstartptr[(hlen - 1) * step]; - n = hlen - (tmpptr - buf); - while (n-- > 0) { - *hptr = *ptr; - ptr -= twostep; - hptr -= step; - } - /* Handle the overwritten samples. */ - n = tmpptr - buf; - while (n-- > 0) { - --tmpptr; - *hptr = *tmpptr; - hptr -= step; - } - } + jpc_fix_t splitbuf[QMFB_SPLITBUFSIZE]; + jpc_fix_t *buf = splitbuf; + int llen; + int hlen; + int twostep; + jpc_fix_t *tmpptr; + register jpc_fix_t *ptr; + register jpc_fix_t *hptr; + register jpc_fix_t *lptr; + register int n; + int state; + + twostep = step << 1; + llen = lendind - lstartind; + hlen = hendind - hstartind; + + if (hstartind < lstartind) { + /* The first sample in the input signal is to appear + in the highpass subband signal. */ + /* Copy the appropriate samples into the lowpass subband + signal, saving any samples destined for the highpass subband + signal as they are overwritten. */ + tmpptr = buf; + ptr = &startptr[step]; + lptr = lstartptr; + n = llen; + state = 1; + while (n-- > 0) { + if (state) { + *tmpptr = *lptr; + ++tmpptr; + } + *lptr = *ptr; + ptr += twostep; + lptr += step; + state ^= 1; + } + /* Copy the appropriate samples into the highpass subband + signal. */ + /* Handle the nonoverwritten samples. */ + hptr = &hstartptr[(hlen - 1) * step]; + ptr = &startptr[(((llen + hlen - 1) >> 1) << 1) * step]; + n = hlen - (tmpptr - buf); + while (n-- > 0) { + *hptr = *ptr; + hptr -= step; + ptr -= twostep; + } + /* Handle the overwritten samples. */ + n = tmpptr - buf; + while (n-- > 0) { + --tmpptr; + *hptr = *tmpptr; + hptr -= step; + } + } else { + /* The first sample in the input signal is to appear + in the lowpass subband signal. */ + /* Copy the appropriate samples into the lowpass subband + signal, saving any samples for the highpass subband + signal as they are overwritten. */ + state = 0; + ptr = startptr; + lptr = lstartptr; + tmpptr = buf; + n = llen; + while (n-- > 0) { + if (state) { + *tmpptr = *lptr; + ++tmpptr; + } + *lptr = *ptr; + ptr += twostep; + lptr += step; + state ^= 1; + } + /* Copy the appropriate samples into the highpass subband + signal. */ + /* Handle the nonoverwritten samples. */ + ptr = &startptr[((((llen + hlen) >> 1) << 1) - 1) * step]; + hptr = &hstartptr[(hlen - 1) * step]; + n = hlen - (tmpptr - buf); + while (n-- > 0) { + *hptr = *ptr; + ptr -= twostep; + hptr -= step; + } + /* Handle the overwritten samples. */ + n = tmpptr - buf; + while (n-- > 0) { + --tmpptr; + *hptr = *tmpptr; + hptr -= step; + } + } } static void jpc_qmfb1d_join(jpc_fix_t *startptr, int startind, int endind, register int step, jpc_fix_t *lstartptr, int lstartind, int lendind, jpc_fix_t *hstartptr, int hstartind, int hendind) { -#define QMFB_JOINBUFSIZE 4096 - jpc_fix_t joinbuf[QMFB_JOINBUFSIZE]; - jpc_fix_t *buf = joinbuf; - int llen; - int hlen; - int twostep; - jpc_fix_t *tmpptr; - register jpc_fix_t *ptr; - register jpc_fix_t *hptr; - register jpc_fix_t *lptr; - register int n; - int state; - - twostep = step << 1; - llen = lendind - lstartind; - hlen = hendind - hstartind; - - if (hstartind < lstartind) { - /* The first sample in the highpass subband signal is to - appear first in the output signal. */ - /* Copy the appropriate samples into the first phase of the - output signal. */ - tmpptr = buf; - hptr = hstartptr; - ptr = startptr; - n = (llen + 1) >> 1; - while (n-- > 0) { - *tmpptr = *ptr; - *ptr = *hptr; - ++tmpptr; - ptr += twostep; - hptr += step; - } - n = hlen - ((llen + 1) >> 1); - while (n-- > 0) { - *ptr = *hptr; - ptr += twostep; - hptr += step; - } - /* Copy the appropriate samples into the second phase of - the output signal. */ - ptr -= (lendind > hendind) ? (step) : (step + twostep); - state = !((llen - 1) & 1); - lptr = &lstartptr[(llen - 1) * step]; - n = llen; - while (n-- > 0) { - if (state) { - --tmpptr; - *ptr = *tmpptr; - } else { - *ptr = *lptr; - } - lptr -= step; - ptr -= twostep; - state ^= 1; - } - } else { - /* The first sample in the lowpass subband signal is to - appear first in the output signal. */ - /* Copy the appropriate samples into the first phase of the - output signal (corresponding to even indexed samples). */ - lptr = &lstartptr[(llen - 1) * step]; - ptr = &startptr[((llen - 1) << 1) * step]; - n = llen >> 1; - tmpptr = buf; - while (n-- > 0) { - *tmpptr = *ptr; - *ptr = *lptr; - ++tmpptr; - ptr -= twostep; - lptr -= step; - } - n = llen - (llen >> 1); - while (n-- > 0) { - *ptr = *lptr; - ptr -= twostep; - lptr -= step; - } - /* Copy the appropriate samples into the second phase of - the output signal (corresponding to odd indexed - samples). */ - ptr = &startptr[step]; - hptr = hstartptr; - state = !(llen & 1); - n = hlen; - while (n-- > 0) { - if (state) { - --tmpptr; - *ptr = *tmpptr; - } else { - *ptr = *hptr; - } - hptr += step; - ptr += twostep; - state ^= 1; - } - } +#define QMFB_JOINBUFSIZE 4096 + jpc_fix_t joinbuf[QMFB_JOINBUFSIZE]; + jpc_fix_t *buf = joinbuf; + int llen; + int hlen; + int twostep; + jpc_fix_t *tmpptr; + register jpc_fix_t *ptr; + register jpc_fix_t *hptr; + register jpc_fix_t *lptr; + register int n; + int state; + + twostep = step << 1; + llen = lendind - lstartind; + hlen = hendind - hstartind; + + if (hstartind < lstartind) { + /* The first sample in the highpass subband signal is to + appear first in the output signal. */ + /* Copy the appropriate samples into the first phase of the + output signal. */ + tmpptr = buf; + hptr = hstartptr; + ptr = startptr; + n = (llen + 1) >> 1; + while (n-- > 0) { + *tmpptr = *ptr; + *ptr = *hptr; + ++tmpptr; + ptr += twostep; + hptr += step; + } + n = hlen - ((llen + 1) >> 1); + while (n-- > 0) { + *ptr = *hptr; + ptr += twostep; + hptr += step; + } + /* Copy the appropriate samples into the second phase of + the output signal. */ + ptr -= (lendind > hendind) ? (step) : (step + twostep); + state = !((llen - 1) & 1); + lptr = &lstartptr[(llen - 1) * step]; + n = llen; + while (n-- > 0) { + if (state) { + --tmpptr; + *ptr = *tmpptr; + } else { + *ptr = *lptr; + } + lptr -= step; + ptr -= twostep; + state ^= 1; + } + } else { + /* The first sample in the lowpass subband signal is to + appear first in the output signal. */ + /* Copy the appropriate samples into the first phase of the + output signal (corresponding to even indexed samples). */ + lptr = &lstartptr[(llen - 1) * step]; + ptr = &startptr[((llen - 1) << 1) * step]; + n = llen >> 1; + tmpptr = buf; + while (n-- > 0) { + *tmpptr = *ptr; + *ptr = *lptr; + ++tmpptr; + ptr -= twostep; + lptr -= step; + } + n = llen - (llen >> 1); + while (n-- > 0) { + *ptr = *lptr; + ptr -= twostep; + lptr -= step; + } + /* Copy the appropriate samples into the second phase of + the output signal (corresponding to odd indexed + samples). */ + ptr = &startptr[step]; + hptr = hstartptr; + state = !(llen & 1); + n = hlen; + while (n-- > 0) { + if (state) { + --tmpptr; + *ptr = *tmpptr; + } else { + *ptr = *hptr; + } + hptr += step; + ptr += twostep; + state ^= 1; + } + } } /******************************************************************************\ @@ -395,310 +395,310 @@ static void jpc_qmfb1d_join(jpc_fix_t *startptr, int startind, int endind, static int jpc_ft_getnumchans(jpc_qmfb1d_t *qmfb) { - return 2; + return 2; } static int jpc_ft_getanalfilters(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters) { - abort(); - return -1; + abort(); + return -1; } static int jpc_ft_getsynfilters(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters) { - jas_seq_t *lf; - jas_seq_t *hf; - - lf = 0; - hf = 0; - - if (len > 1 || (!len)) { - if (!(lf = jas_seq_create(-1, 2))) { - goto error; - } - jas_seq_set(lf, -1, jpc_dbltofix(0.5)); - jas_seq_set(lf, 0, jpc_dbltofix(1.0)); - jas_seq_set(lf, 1, jpc_dbltofix(0.5)); - if (!(hf = jas_seq_create(-1, 4))) { - goto error; - } - jas_seq_set(hf, -1, jpc_dbltofix(-0.125)); - jas_seq_set(hf, 0, jpc_dbltofix(-0.25)); - jas_seq_set(hf, 1, jpc_dbltofix(0.75)); - jas_seq_set(hf, 2, jpc_dbltofix(-0.25)); - jas_seq_set(hf, 3, jpc_dbltofix(-0.125)); - } else if (len == 1) { - if (!(lf = jas_seq_create(0, 1))) { - goto error; - } - jas_seq_set(lf, 0, jpc_dbltofix(1.0)); - if (!(hf = jas_seq_create(0, 1))) { - goto error; - } - jas_seq_set(hf, 0, jpc_dbltofix(2.0)); - } else { - abort(); - } - - filters[0] = lf; - filters[1] = hf; - - return 0; + jas_seq_t *lf; + jas_seq_t *hf; + + lf = 0; + hf = 0; + + if (len > 1 || (!len)) { + if (!(lf = jas_seq_create(-1, 2))) { + goto error; + } + jas_seq_set(lf, -1, jpc_dbltofix(0.5)); + jas_seq_set(lf, 0, jpc_dbltofix(1.0)); + jas_seq_set(lf, 1, jpc_dbltofix(0.5)); + if (!(hf = jas_seq_create(-1, 4))) { + goto error; + } + jas_seq_set(hf, -1, jpc_dbltofix(-0.125)); + jas_seq_set(hf, 0, jpc_dbltofix(-0.25)); + jas_seq_set(hf, 1, jpc_dbltofix(0.75)); + jas_seq_set(hf, 2, jpc_dbltofix(-0.25)); + jas_seq_set(hf, 3, jpc_dbltofix(-0.125)); + } else if (len == 1) { + if (!(lf = jas_seq_create(0, 1))) { + goto error; + } + jas_seq_set(lf, 0, jpc_dbltofix(1.0)); + if (!(hf = jas_seq_create(0, 1))) { + goto error; + } + jas_seq_set(hf, 0, jpc_dbltofix(2.0)); + } else { + abort(); + } + + filters[0] = lf; + filters[1] = hf; + + return 0; error: - if (lf) { - jas_seq_destroy(lf); - } - if (hf) { - jas_seq_destroy(hf); - } - return -1; + if (lf) { + jas_seq_destroy(lf); + } + if (hf) { + jas_seq_destroy(hf); + } + return -1; } -#define NFT_LIFT0(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, pluseq) \ +#define NFT_LIFT0(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, pluseq) \ { \ - register jpc_fix_t *lptr = (lstartptr); \ - register jpc_fix_t *hptr = (hstartptr); \ - register int n = (hendind) - (hstartind); \ - if ((hstartind) < (lstartind)) { \ - pluseq(*hptr, *lptr); \ - hptr += (step); \ - --n; \ - } \ - if ((hendind) >= (lendind)) { \ - --n; \ - } \ - while (n-- > 0) { \ - pluseq(*hptr, jpc_fix_asr(jpc_fix_add(*lptr, lptr[(step)]), 1)); \ - hptr += (step); \ - lptr += (step); \ - } \ - if ((hendind) >= (lendind)) { \ - pluseq(*hptr, *lptr); \ - } \ + register jpc_fix_t *lptr = (lstartptr); \ + register jpc_fix_t *hptr = (hstartptr); \ + register int n = (hendind) - (hstartind); \ + if ((hstartind) < (lstartind)) { \ + pluseq(*hptr, *lptr); \ + hptr += (step); \ + --n; \ + } \ + if ((hendind) >= (lendind)) { \ + --n; \ + } \ + while (n-- > 0) { \ + pluseq(*hptr, jpc_fix_asr(jpc_fix_add(*lptr, lptr[(step)]), 1)); \ + hptr += (step); \ + lptr += (step); \ + } \ + if ((hendind) >= (lendind)) { \ + pluseq(*hptr, *lptr); \ + } \ } -#define NFT_LIFT1(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, pluseq) \ +#define NFT_LIFT1(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, pluseq) \ { \ - register jpc_fix_t *lptr = (lstartptr); \ - register jpc_fix_t *hptr = (hstartptr); \ - register int n = (lendind) - (lstartind); \ - if ((hstartind) >= (lstartind)) { \ - pluseq(*lptr, *hptr); \ - lptr += (step); \ - --n; \ - } \ - if ((lendind) > (hendind)) { \ - --n; \ - } \ - while (n-- > 0) { \ - pluseq(*lptr, jpc_fix_asr(jpc_fix_add(*hptr, hptr[(step)]), 2)); \ - lptr += (step); \ - hptr += (step); \ - } \ - if ((lendind) > (hendind)) { \ - pluseq(*lptr, *hptr); \ - } \ + register jpc_fix_t *lptr = (lstartptr); \ + register jpc_fix_t *hptr = (hstartptr); \ + register int n = (lendind) - (lstartind); \ + if ((hstartind) >= (lstartind)) { \ + pluseq(*lptr, *hptr); \ + lptr += (step); \ + --n; \ + } \ + if ((lendind) > (hendind)) { \ + --n; \ + } \ + while (n-- > 0) { \ + pluseq(*lptr, jpc_fix_asr(jpc_fix_add(*hptr, hptr[(step)]), 2)); \ + lptr += (step); \ + hptr += (step); \ + } \ + if ((lendind) > (hendind)) { \ + pluseq(*lptr, *hptr); \ + } \ } -#define RFT_LIFT0(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, pmeqop) \ +#define RFT_LIFT0(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, pmeqop) \ { \ - register jpc_fix_t *lptr = (lstartptr); \ - register jpc_fix_t *hptr = (hstartptr); \ - register int n = (hendind) - (hstartind); \ - if ((hstartind) < (lstartind)) { \ - *hptr pmeqop *lptr; \ - hptr += (step); \ - --n; \ - } \ - if ((hendind) >= (lendind)) { \ - --n; \ - } \ - while (n-- > 0) { \ - *hptr pmeqop (*lptr + lptr[(step)]) >> 1; \ - hptr += (step); \ - lptr += (step); \ - } \ - if ((hendind) >= (lendind)) { \ - *hptr pmeqop *lptr; \ - } \ + register jpc_fix_t *lptr = (lstartptr); \ + register jpc_fix_t *hptr = (hstartptr); \ + register int n = (hendind) - (hstartind); \ + if ((hstartind) < (lstartind)) { \ + *hptr pmeqop *lptr; \ + hptr += (step); \ + --n; \ + } \ + if ((hendind) >= (lendind)) { \ + --n; \ + } \ + while (n-- > 0) { \ + *hptr pmeqop (*lptr + lptr[(step)]) >> 1; \ + hptr += (step); \ + lptr += (step); \ + } \ + if ((hendind) >= (lendind)) { \ + *hptr pmeqop *lptr; \ + } \ } -#define RFT_LIFT1(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, pmeqop) \ +#define RFT_LIFT1(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, pmeqop) \ { \ - register jpc_fix_t *lptr = (lstartptr); \ - register jpc_fix_t *hptr = (hstartptr); \ - register int n = (lendind) - (lstartind); \ - if ((hstartind) >= (lstartind)) { \ - *lptr pmeqop ((*hptr << 1) + 2) >> 2; \ - lptr += (step); \ - --n; \ - } \ - if ((lendind) > (hendind)) { \ - --n; \ - } \ - while (n-- > 0) { \ - *lptr pmeqop ((*hptr + hptr[(step)]) + 2) >> 2; \ - lptr += (step); \ - hptr += (step); \ - } \ - if ((lendind) > (hendind)) { \ - *lptr pmeqop ((*hptr << 1) + 2) >> 2; \ - } \ + register jpc_fix_t *lptr = (lstartptr); \ + register jpc_fix_t *hptr = (hstartptr); \ + register int n = (lendind) - (lstartind); \ + if ((hstartind) >= (lstartind)) { \ + *lptr pmeqop ((*hptr << 1) + 2) >> 2; \ + lptr += (step); \ + --n; \ + } \ + if ((lendind) > (hendind)) { \ + --n; \ + } \ + while (n-- > 0) { \ + *lptr pmeqop ((*hptr + hptr[(step)]) + 2) >> 2; \ + lptr += (step); \ + hptr += (step); \ + } \ + if ((lendind) > (hendind)) { \ + *lptr pmeqop ((*hptr << 1) + 2) >> 2; \ + } \ } static void jpc_ft_analyze(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x) { - jpc_fix_t *startptr; - int startind; - int endind; - jpc_fix_t * lstartptr; - int lstartind; - int lendind; - jpc_fix_t * hstartptr; - int hstartind; - int hendind; - int interstep; - int intrastep; - int numseq; - - if (flags & JPC_QMFB1D_VERT) { - interstep = 1; - intrastep = jas_seq2d_rowstep(x); - numseq = jas_seq2d_width(x); - startind = jas_seq2d_ystart(x); - endind = jas_seq2d_yend(x); - } else { - interstep = jas_seq2d_rowstep(x); - intrastep = 1; - numseq = jas_seq2d_height(x); - startind = jas_seq2d_xstart(x); - endind = jas_seq2d_xend(x); - } - - assert(startind < endind); - - startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x)); - if (flags & JPC_QMFB1D_RITIMODE) { - while (numseq-- > 0) { - jpc_qmfb1d_setup(startptr, startind, endind, intrastep, - &lstartptr, &lstartind, &lendind, &hstartptr, - &hstartind, &hendind); - if (endind - startind > 1) { - jpc_qmfb1d_split(startptr, startind, endind, - intrastep, lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind); - RFT_LIFT0(lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind, intrastep, -=); - RFT_LIFT1(lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind, intrastep, +=); - } else { - if (lstartind == lendind) { - *startptr <<= 1; - } - } - startptr += interstep; - } - } else { - while (numseq-- > 0) { - jpc_qmfb1d_setup(startptr, startind, endind, intrastep, - &lstartptr, &lstartind, &lendind, &hstartptr, - &hstartind, &hendind); - if (endind - startind > 1) { - jpc_qmfb1d_split(startptr, startind, endind, - intrastep, lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind); - NFT_LIFT0(lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind, intrastep, - jpc_fix_minuseq); - NFT_LIFT1(lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind, intrastep, - jpc_fix_pluseq); - } else { - if (lstartind == lendind) { - *startptr = jpc_fix_asl(*startptr, 1); - } - } - startptr += interstep; - } - } + jpc_fix_t *startptr; + int startind; + int endind; + jpc_fix_t * lstartptr; + int lstartind; + int lendind; + jpc_fix_t * hstartptr; + int hstartind; + int hendind; + int interstep; + int intrastep; + int numseq; + + if (flags & JPC_QMFB1D_VERT) { + interstep = 1; + intrastep = jas_seq2d_rowstep(x); + numseq = jas_seq2d_width(x); + startind = jas_seq2d_ystart(x); + endind = jas_seq2d_yend(x); + } else { + interstep = jas_seq2d_rowstep(x); + intrastep = 1; + numseq = jas_seq2d_height(x); + startind = jas_seq2d_xstart(x); + endind = jas_seq2d_xend(x); + } + + assert(startind < endind); + + startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x)); + if (flags & JPC_QMFB1D_RITIMODE) { + while (numseq-- > 0) { + jpc_qmfb1d_setup(startptr, startind, endind, intrastep, + &lstartptr, &lstartind, &lendind, &hstartptr, + &hstartind, &hendind); + if (endind - startind > 1) { + jpc_qmfb1d_split(startptr, startind, endind, + intrastep, lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind); + RFT_LIFT0(lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind, intrastep, -=); + RFT_LIFT1(lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind, intrastep, +=); + } else { + if (lstartind == lendind) { + *startptr <<= 1; + } + } + startptr += interstep; + } + } else { + while (numseq-- > 0) { + jpc_qmfb1d_setup(startptr, startind, endind, intrastep, + &lstartptr, &lstartind, &lendind, &hstartptr, + &hstartind, &hendind); + if (endind - startind > 1) { + jpc_qmfb1d_split(startptr, startind, endind, + intrastep, lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind); + NFT_LIFT0(lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind, intrastep, + jpc_fix_minuseq); + NFT_LIFT1(lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind, intrastep, + jpc_fix_pluseq); + } else { + if (lstartind == lendind) { + *startptr = jpc_fix_asl(*startptr, 1); + } + } + startptr += interstep; + } + } } static void jpc_ft_synthesize(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x) { - jpc_fix_t *startptr; - int startind; - int endind; - jpc_fix_t *lstartptr; - int lstartind; - int lendind; - jpc_fix_t *hstartptr; - int hstartind; - int hendind; - int interstep; - int intrastep; - int numseq; - - if (flags & JPC_QMFB1D_VERT) { - interstep = 1; - intrastep = jas_seq2d_rowstep(x); - numseq = jas_seq2d_width(x); - startind = jas_seq2d_ystart(x); - endind = jas_seq2d_yend(x); - } else { - interstep = jas_seq2d_rowstep(x); - intrastep = 1; - numseq = jas_seq2d_height(x); - startind = jas_seq2d_xstart(x); - endind = jas_seq2d_xend(x); - } - - assert(startind < endind); - - startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x)); - if (flags & JPC_QMFB1D_RITIMODE) { - while (numseq-- > 0) { - jpc_qmfb1d_setup(startptr, startind, endind, intrastep, - &lstartptr, &lstartind, &lendind, &hstartptr, - &hstartind, &hendind); - if (endind - startind > 1) { - RFT_LIFT1(lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind, intrastep, -=); - RFT_LIFT0(lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind, intrastep, +=); - jpc_qmfb1d_join(startptr, startind, endind, - intrastep, lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind); - } else { - if (lstartind == lendind) { - *startptr >>= 1; - } - } - startptr += interstep; - } - } else { - while (numseq-- > 0) { - jpc_qmfb1d_setup(startptr, startind, endind, intrastep, - &lstartptr, &lstartind, &lendind, &hstartptr, - &hstartind, &hendind); - if (endind - startind > 1) { - NFT_LIFT1(lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind, intrastep, - jpc_fix_minuseq); - NFT_LIFT0(lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind, intrastep, - jpc_fix_pluseq); - jpc_qmfb1d_join(startptr, startind, endind, - intrastep, lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind); - } else { - if (lstartind == lendind) { - *startptr = jpc_fix_asr(*startptr, 1); - } - } - startptr += interstep; - } - } + jpc_fix_t *startptr; + int startind; + int endind; + jpc_fix_t *lstartptr; + int lstartind; + int lendind; + jpc_fix_t *hstartptr; + int hstartind; + int hendind; + int interstep; + int intrastep; + int numseq; + + if (flags & JPC_QMFB1D_VERT) { + interstep = 1; + intrastep = jas_seq2d_rowstep(x); + numseq = jas_seq2d_width(x); + startind = jas_seq2d_ystart(x); + endind = jas_seq2d_yend(x); + } else { + interstep = jas_seq2d_rowstep(x); + intrastep = 1; + numseq = jas_seq2d_height(x); + startind = jas_seq2d_xstart(x); + endind = jas_seq2d_xend(x); + } + + assert(startind < endind); + + startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x)); + if (flags & JPC_QMFB1D_RITIMODE) { + while (numseq-- > 0) { + jpc_qmfb1d_setup(startptr, startind, endind, intrastep, + &lstartptr, &lstartind, &lendind, &hstartptr, + &hstartind, &hendind); + if (endind - startind > 1) { + RFT_LIFT1(lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind, intrastep, -=); + RFT_LIFT0(lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind, intrastep, +=); + jpc_qmfb1d_join(startptr, startind, endind, + intrastep, lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind); + } else { + if (lstartind == lendind) { + *startptr >>= 1; + } + } + startptr += interstep; + } + } else { + while (numseq-- > 0) { + jpc_qmfb1d_setup(startptr, startind, endind, intrastep, + &lstartptr, &lstartind, &lendind, &hstartptr, + &hstartind, &hendind); + if (endind - startind > 1) { + NFT_LIFT1(lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind, intrastep, + jpc_fix_minuseq); + NFT_LIFT0(lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind, intrastep, + jpc_fix_pluseq); + jpc_qmfb1d_join(startptr, startind, endind, + intrastep, lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind); + } else { + if (lstartind == lendind) { + *startptr = jpc_fix_asr(*startptr, 1); + } + } + startptr += interstep; + } + } } /******************************************************************************\ @@ -707,276 +707,276 @@ static void jpc_ft_synthesize(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x) static int jpc_ns_getnumchans(jpc_qmfb1d_t *qmfb) { - return 2; + return 2; } static int jpc_ns_getanalfilters(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters) { - abort(); - return -1; + abort(); + return -1; } static int jpc_ns_getsynfilters(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters) { - jas_seq_t *lf; - jas_seq_t *hf; - - lf = 0; - hf = 0; - - if (len > 1 || (!len)) { - if (!(lf = jas_seq_create(-3, 4))) { - goto error; - } - jas_seq_set(lf, -3, jpc_dbltofix(-0.09127176311424948)); - jas_seq_set(lf, -2, jpc_dbltofix(-0.05754352622849957)); - jas_seq_set(lf, -1, jpc_dbltofix(0.5912717631142470)); - jas_seq_set(lf, 0, jpc_dbltofix(1.115087052456994)); - jas_seq_set(lf, 1, jpc_dbltofix(0.5912717631142470)); - jas_seq_set(lf, 2, jpc_dbltofix(-0.05754352622849957)); - jas_seq_set(lf, 3, jpc_dbltofix(-0.09127176311424948)); - if (!(hf = jas_seq_create(-3, 6))) { - goto error; - } - jas_seq_set(hf, -3, jpc_dbltofix(-0.02674875741080976 * 2.0)); - jas_seq_set(hf, -2, jpc_dbltofix(-0.01686411844287495 * 2.0)); - jas_seq_set(hf, -1, jpc_dbltofix(0.07822326652898785 * 2.0)); - jas_seq_set(hf, 0, jpc_dbltofix(0.2668641184428723 * 2.0)); - jas_seq_set(hf, 1, jpc_dbltofix(-0.6029490182363579 * 2.0)); - jas_seq_set(hf, 2, jpc_dbltofix(0.2668641184428723 * 2.0)); - jas_seq_set(hf, 3, jpc_dbltofix(0.07822326652898785 * 2.0)); - jas_seq_set(hf, 4, jpc_dbltofix(-0.01686411844287495 * 2.0)); - jas_seq_set(hf, 5, jpc_dbltofix(-0.02674875741080976 * 2.0)); - } else if (len == 1) { - if (!(lf = jas_seq_create(0, 1))) { - goto error; - } - jas_seq_set(lf, 0, jpc_dbltofix(1.0)); - if (!(hf = jas_seq_create(0, 1))) { - goto error; - } - jas_seq_set(hf, 0, jpc_dbltofix(2.0)); - } else { - abort(); - } - - filters[0] = lf; - filters[1] = hf; - - return 0; + jas_seq_t *lf; + jas_seq_t *hf; + + lf = 0; + hf = 0; + + if (len > 1 || (!len)) { + if (!(lf = jas_seq_create(-3, 4))) { + goto error; + } + jas_seq_set(lf, -3, jpc_dbltofix(-0.09127176311424948)); + jas_seq_set(lf, -2, jpc_dbltofix(-0.05754352622849957)); + jas_seq_set(lf, -1, jpc_dbltofix(0.5912717631142470)); + jas_seq_set(lf, 0, jpc_dbltofix(1.115087052456994)); + jas_seq_set(lf, 1, jpc_dbltofix(0.5912717631142470)); + jas_seq_set(lf, 2, jpc_dbltofix(-0.05754352622849957)); + jas_seq_set(lf, 3, jpc_dbltofix(-0.09127176311424948)); + if (!(hf = jas_seq_create(-3, 6))) { + goto error; + } + jas_seq_set(hf, -3, jpc_dbltofix(-0.02674875741080976 * 2.0)); + jas_seq_set(hf, -2, jpc_dbltofix(-0.01686411844287495 * 2.0)); + jas_seq_set(hf, -1, jpc_dbltofix(0.07822326652898785 * 2.0)); + jas_seq_set(hf, 0, jpc_dbltofix(0.2668641184428723 * 2.0)); + jas_seq_set(hf, 1, jpc_dbltofix(-0.6029490182363579 * 2.0)); + jas_seq_set(hf, 2, jpc_dbltofix(0.2668641184428723 * 2.0)); + jas_seq_set(hf, 3, jpc_dbltofix(0.07822326652898785 * 2.0)); + jas_seq_set(hf, 4, jpc_dbltofix(-0.01686411844287495 * 2.0)); + jas_seq_set(hf, 5, jpc_dbltofix(-0.02674875741080976 * 2.0)); + } else if (len == 1) { + if (!(lf = jas_seq_create(0, 1))) { + goto error; + } + jas_seq_set(lf, 0, jpc_dbltofix(1.0)); + if (!(hf = jas_seq_create(0, 1))) { + goto error; + } + jas_seq_set(hf, 0, jpc_dbltofix(2.0)); + } else { + abort(); + } + + filters[0] = lf; + filters[1] = hf; + + return 0; error: - if (lf) { - jas_seq_destroy(lf); - } - if (hf) { - jas_seq_destroy(hf); - } - return -1; + if (lf) { + jas_seq_destroy(lf); + } + if (hf) { + jas_seq_destroy(hf); + } + return -1; } -#define NNS_LIFT0(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, alpha) \ +#define NNS_LIFT0(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, alpha) \ { \ - register jpc_fix_t *lptr = (lstartptr); \ - register jpc_fix_t *hptr = (hstartptr); \ - register int n = (hendind) - (hstartind); \ - jpc_fix_t twoalpha = jpc_fix_mulbyint(alpha, 2); \ - if ((hstartind) < (lstartind)) { \ - jpc_fix_pluseq(*hptr, jpc_fix_mul(*lptr, (twoalpha))); \ - hptr += (step); \ - --n; \ - } \ - if ((hendind) >= (lendind)) { \ - --n; \ - } \ - while (n-- > 0) { \ - jpc_fix_pluseq(*hptr, jpc_fix_mul(jpc_fix_add(*lptr, lptr[(step)]), (alpha))); \ - hptr += (step); \ - lptr += (step); \ - } \ - if ((hendind) >= (lendind)) { \ - jpc_fix_pluseq(*hptr, jpc_fix_mul(*lptr, (twoalpha))); \ - } \ + register jpc_fix_t *lptr = (lstartptr); \ + register jpc_fix_t *hptr = (hstartptr); \ + register int n = (hendind) - (hstartind); \ + jpc_fix_t twoalpha = jpc_fix_mulbyint(alpha, 2); \ + if ((hstartind) < (lstartind)) { \ + jpc_fix_pluseq(*hptr, jpc_fix_mul(*lptr, (twoalpha))); \ + hptr += (step); \ + --n; \ + } \ + if ((hendind) >= (lendind)) { \ + --n; \ + } \ + while (n-- > 0) { \ + jpc_fix_pluseq(*hptr, jpc_fix_mul(jpc_fix_add(*lptr, lptr[(step)]), (alpha))); \ + hptr += (step); \ + lptr += (step); \ + } \ + if ((hendind) >= (lendind)) { \ + jpc_fix_pluseq(*hptr, jpc_fix_mul(*lptr, (twoalpha))); \ + } \ } -#define NNS_LIFT1(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, alpha) \ +#define NNS_LIFT1(lstartptr, lstartind, lendind, hstartptr, hstartind, hendind, step, alpha) \ { \ - register jpc_fix_t *lptr = (lstartptr); \ - register jpc_fix_t *hptr = (hstartptr); \ - register int n = (lendind) - (lstartind); \ - int twoalpha = jpc_fix_mulbyint(alpha, 2); \ - if ((hstartind) >= (lstartind)) { \ - jpc_fix_pluseq(*lptr, jpc_fix_mul(*hptr, (twoalpha))); \ - lptr += (step); \ - --n; \ - } \ - if ((lendind) > (hendind)) { \ - --n; \ - } \ - while (n-- > 0) { \ - jpc_fix_pluseq(*lptr, jpc_fix_mul(jpc_fix_add(*hptr, hptr[(step)]), (alpha))); \ - lptr += (step); \ - hptr += (step); \ - } \ - if ((lendind) > (hendind)) { \ - jpc_fix_pluseq(*lptr, jpc_fix_mul(*hptr, (twoalpha))); \ - } \ + register jpc_fix_t *lptr = (lstartptr); \ + register jpc_fix_t *hptr = (hstartptr); \ + register int n = (lendind) - (lstartind); \ + int twoalpha = jpc_fix_mulbyint(alpha, 2); \ + if ((hstartind) >= (lstartind)) { \ + jpc_fix_pluseq(*lptr, jpc_fix_mul(*hptr, (twoalpha))); \ + lptr += (step); \ + --n; \ + } \ + if ((lendind) > (hendind)) { \ + --n; \ + } \ + while (n-- > 0) { \ + jpc_fix_pluseq(*lptr, jpc_fix_mul(jpc_fix_add(*hptr, hptr[(step)]), (alpha))); \ + lptr += (step); \ + hptr += (step); \ + } \ + if ((lendind) > (hendind)) { \ + jpc_fix_pluseq(*lptr, jpc_fix_mul(*hptr, (twoalpha))); \ + } \ } -#define NNS_SCALE(startptr, startind, endind, step, alpha) \ +#define NNS_SCALE(startptr, startind, endind, step, alpha) \ { \ - register jpc_fix_t *ptr = (startptr); \ - register int n = (endind) - (startind); \ - while (n-- > 0) { \ - jpc_fix_muleq(*ptr, alpha); \ - ptr += (step); \ - } \ + register jpc_fix_t *ptr = (startptr); \ + register int n = (endind) - (startind); \ + while (n-- > 0) { \ + jpc_fix_muleq(*ptr, alpha); \ + ptr += (step); \ + } \ } static void jpc_ns_analyze(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x) { - jpc_fix_t *startptr; - int startind; - int endind; - jpc_fix_t *lstartptr; - int lstartind; - int lendind; - jpc_fix_t *hstartptr; - int hstartind; - int hendind; - int interstep; - int intrastep; - int numseq; - - if (flags & JPC_QMFB1D_VERT) { - interstep = 1; - intrastep = jas_seq2d_rowstep(x); - numseq = jas_seq2d_width(x); - startind = jas_seq2d_ystart(x); - endind = jas_seq2d_yend(x); - } else { - interstep = jas_seq2d_rowstep(x); - intrastep = 1; - numseq = jas_seq2d_height(x); - startind = jas_seq2d_xstart(x); - endind = jas_seq2d_xend(x); - } - - assert(startind < endind); - - startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x)); - if (!(flags & JPC_QMFB1D_RITIMODE)) { - while (numseq-- > 0) { - jpc_qmfb1d_setup(startptr, startind, endind, intrastep, - &lstartptr, &lstartind, &lendind, &hstartptr, - &hstartind, &hendind); - if (endind - startind > 1) { - jpc_qmfb1d_split(startptr, startind, endind, - intrastep, lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind); - NNS_LIFT0(lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind, intrastep, - jpc_dbltofix(-1.586134342)); - NNS_LIFT1(lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind, intrastep, - jpc_dbltofix(-0.052980118)); - NNS_LIFT0(lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind, intrastep, - jpc_dbltofix(0.882911075)); - NNS_LIFT1(lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind, intrastep, - jpc_dbltofix(0.443506852)); - NNS_SCALE(lstartptr, lstartind, lendind, - intrastep, jpc_dbltofix(1.0/1.23017410558578)); - NNS_SCALE(hstartptr, hstartind, hendind, - intrastep, jpc_dbltofix(1.0/1.62578613134411)); - } else { + jpc_fix_t *startptr; + int startind; + int endind; + jpc_fix_t *lstartptr; + int lstartind; + int lendind; + jpc_fix_t *hstartptr; + int hstartind; + int hendind; + int interstep; + int intrastep; + int numseq; + + if (flags & JPC_QMFB1D_VERT) { + interstep = 1; + intrastep = jas_seq2d_rowstep(x); + numseq = jas_seq2d_width(x); + startind = jas_seq2d_ystart(x); + endind = jas_seq2d_yend(x); + } else { + interstep = jas_seq2d_rowstep(x); + intrastep = 1; + numseq = jas_seq2d_height(x); + startind = jas_seq2d_xstart(x); + endind = jas_seq2d_xend(x); + } + + assert(startind < endind); + + startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x)); + if (!(flags & JPC_QMFB1D_RITIMODE)) { + while (numseq-- > 0) { + jpc_qmfb1d_setup(startptr, startind, endind, intrastep, + &lstartptr, &lstartind, &lendind, &hstartptr, + &hstartind, &hendind); + if (endind - startind > 1) { + jpc_qmfb1d_split(startptr, startind, endind, + intrastep, lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind); + NNS_LIFT0(lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind, intrastep, + jpc_dbltofix(-1.586134342)); + NNS_LIFT1(lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind, intrastep, + jpc_dbltofix(-0.052980118)); + NNS_LIFT0(lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind, intrastep, + jpc_dbltofix(0.882911075)); + NNS_LIFT1(lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind, intrastep, + jpc_dbltofix(0.443506852)); + NNS_SCALE(lstartptr, lstartind, lendind, + intrastep, jpc_dbltofix(1.0/1.23017410558578)); + NNS_SCALE(hstartptr, hstartind, hendind, + intrastep, jpc_dbltofix(1.0/1.62578613134411)); + } else { #if 0 - if (lstartind == lendind) { - *startptr = jpc_fix_asl(*startptr, 1); - } + if (lstartind == lendind) { + *startptr = jpc_fix_asl(*startptr, 1); + } #endif - } - startptr += interstep; - } - } else { - /* The reversible integer-to-integer mode is not valid for this - transform. */ - abort(); - } + } + startptr += interstep; + } + } else { + /* The reversible integer-to-integer mode is not valid for this + transform. */ + abort(); + } } static void jpc_ns_synthesize(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x) { - jpc_fix_t *startptr; - int startind; - int endind; - jpc_fix_t *lstartptr; - int lstartind; - int lendind; - jpc_fix_t *hstartptr; - int hstartind; - int hendind; - int interstep; - int intrastep; - int numseq; - - if (flags & JPC_QMFB1D_VERT) { - interstep = 1; - intrastep = jas_seq2d_rowstep(x); - numseq = jas_seq2d_width(x); - startind = jas_seq2d_ystart(x); - endind = jas_seq2d_yend(x); - } else { - interstep = jas_seq2d_rowstep(x); - intrastep = 1; - numseq = jas_seq2d_height(x); - startind = jas_seq2d_xstart(x); - endind = jas_seq2d_xend(x); - } - - assert(startind < endind); - - startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x)); - if (!(flags & JPC_QMFB1D_RITIMODE)) { - while (numseq-- > 0) { - jpc_qmfb1d_setup(startptr, startind, endind, intrastep, - &lstartptr, &lstartind, &lendind, &hstartptr, - &hstartind, &hendind); - if (endind - startind > 1) { - NNS_SCALE(lstartptr, lstartind, lendind, - intrastep, jpc_dbltofix(1.23017410558578)); - NNS_SCALE(hstartptr, hstartind, hendind, - intrastep, jpc_dbltofix(1.62578613134411)); - NNS_LIFT1(lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind, intrastep, - jpc_dbltofix(-0.443506852)); - NNS_LIFT0(lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind, intrastep, - jpc_dbltofix(-0.882911075)); - NNS_LIFT1(lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind, intrastep, - jpc_dbltofix(0.052980118)); - NNS_LIFT0(lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind, intrastep, - jpc_dbltofix(1.586134342)); - jpc_qmfb1d_join(startptr, startind, endind, - intrastep, lstartptr, lstartind, lendind, - hstartptr, hstartind, hendind); - } else { + jpc_fix_t *startptr; + int startind; + int endind; + jpc_fix_t *lstartptr; + int lstartind; + int lendind; + jpc_fix_t *hstartptr; + int hstartind; + int hendind; + int interstep; + int intrastep; + int numseq; + + if (flags & JPC_QMFB1D_VERT) { + interstep = 1; + intrastep = jas_seq2d_rowstep(x); + numseq = jas_seq2d_width(x); + startind = jas_seq2d_ystart(x); + endind = jas_seq2d_yend(x); + } else { + interstep = jas_seq2d_rowstep(x); + intrastep = 1; + numseq = jas_seq2d_height(x); + startind = jas_seq2d_xstart(x); + endind = jas_seq2d_xend(x); + } + + assert(startind < endind); + + startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x)); + if (!(flags & JPC_QMFB1D_RITIMODE)) { + while (numseq-- > 0) { + jpc_qmfb1d_setup(startptr, startind, endind, intrastep, + &lstartptr, &lstartind, &lendind, &hstartptr, + &hstartind, &hendind); + if (endind - startind > 1) { + NNS_SCALE(lstartptr, lstartind, lendind, + intrastep, jpc_dbltofix(1.23017410558578)); + NNS_SCALE(hstartptr, hstartind, hendind, + intrastep, jpc_dbltofix(1.62578613134411)); + NNS_LIFT1(lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind, intrastep, + jpc_dbltofix(-0.443506852)); + NNS_LIFT0(lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind, intrastep, + jpc_dbltofix(-0.882911075)); + NNS_LIFT1(lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind, intrastep, + jpc_dbltofix(0.052980118)); + NNS_LIFT0(lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind, intrastep, + jpc_dbltofix(1.586134342)); + jpc_qmfb1d_join(startptr, startind, endind, + intrastep, lstartptr, lstartind, lendind, + hstartptr, hstartind, hendind); + } else { #if 0 - if (lstartind == lendind) { - *startptr = jpc_fix_asr(*startptr, 1); - } + if (lstartind == lendind) { + *startptr = jpc_fix_asr(*startptr, 1); + } #endif - } - startptr += interstep; - } - } else { - /* The reversible integer-to-integer mode is not valid + } + startptr += interstep; + } + } else { + /* The reversible integer-to-integer mode is not valid for this transform. */ - abort(); - } + abort(); + } } /******************************************************************************\ @@ -985,49 +985,49 @@ static void jpc_ns_synthesize(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x) jpc_qmfb1d_t *jpc_qmfb1d_make(int qmfbid) { - jpc_qmfb1d_t *qmfb; - if (!(qmfb = jpc_qmfb1d_create())) { - return 0; - } - switch (qmfbid) { - case JPC_QMFB1D_FT: - qmfb->ops = &jpc_ft_ops; - break; - case JPC_QMFB1D_NS: - qmfb->ops = &jpc_ns_ops; - break; - default: - jpc_qmfb1d_destroy(qmfb); - return 0; - break; - } - return qmfb; + jpc_qmfb1d_t *qmfb; + if (!(qmfb = jpc_qmfb1d_create())) { + return 0; + } + switch (qmfbid) { + case JPC_QMFB1D_FT: + qmfb->ops = &jpc_ft_ops; + break; + case JPC_QMFB1D_NS: + qmfb->ops = &jpc_ns_ops; + break; + default: + jpc_qmfb1d_destroy(qmfb); + return 0; + break; + } + return qmfb; } static jpc_qmfb1d_t *jpc_qmfb1d_create() { - jpc_qmfb1d_t *qmfb; - if (!(qmfb = jas_malloc(sizeof(jpc_qmfb1d_t)))) { - return 0; - } - qmfb->ops = 0; - return qmfb; + jpc_qmfb1d_t *qmfb; + if (!(qmfb = jas_malloc(sizeof(jpc_qmfb1d_t)))) { + return 0; + } + qmfb->ops = 0; + return qmfb; } jpc_qmfb1d_t *jpc_qmfb1d_copy(jpc_qmfb1d_t *qmfb) { - jpc_qmfb1d_t *newqmfb; + jpc_qmfb1d_t *newqmfb; - if (!(newqmfb = jpc_qmfb1d_create())) { - return 0; - } - newqmfb->ops = qmfb->ops; - return newqmfb; + if (!(newqmfb = jpc_qmfb1d_create())) { + return 0; + } + newqmfb->ops = qmfb->ops; + return newqmfb; } void jpc_qmfb1d_destroy(jpc_qmfb1d_t *qmfb) { - jas_free(qmfb); + jas_free(qmfb); } /******************************************************************************\ @@ -1038,27 +1038,27 @@ void jpc_qmfb1d_getbands(jpc_qmfb1d_t *qmfb, int flags, uint_fast32_t xstart, uint_fast32_t ystart, uint_fast32_t xend, uint_fast32_t yend, int maxbands, int *numbandsptr, jpc_qmfb1dband_t *bands) { - int start; - int end; - if (flags & JPC_QMFB1D_VERT) { - start = ystart; - end = yend; - } else { - start = xstart; - end = xend; - } - assert(jpc_qmfb1d_getnumchans(qmfb) == 2); - assert(start <= end); - bands[0].start = JPC_CEILDIVPOW2(start, 1); - bands[0].end = JPC_CEILDIVPOW2(end, 1); - bands[0].locstart = start; - bands[0].locend = start + bands[0].end - bands[0].start; - bands[1].start = JPC_FLOORDIVPOW2(start, 1); - bands[1].end = JPC_FLOORDIVPOW2(end, 1); - bands[1].locstart = bands[0].locend; - bands[1].locend = bands[1].locstart + bands[1].end - bands[1].start; - assert(bands[1].locend == end); - *numbandsptr = 2; + int start; + int end; + if (flags & JPC_QMFB1D_VERT) { + start = ystart; + end = yend; + } else { + start = xstart; + end = xend; + } + assert(jpc_qmfb1d_getnumchans(qmfb) == 2); + assert(start <= end); + bands[0].start = JPC_CEILDIVPOW2(start, 1); + bands[0].end = JPC_CEILDIVPOW2(end, 1); + bands[0].locstart = start; + bands[0].locend = start + bands[0].end - bands[0].start; + bands[1].start = JPC_FLOORDIVPOW2(start, 1); + bands[1].end = JPC_FLOORDIVPOW2(end, 1); + bands[1].locstart = bands[0].locend; + bands[1].locend = bands[1].locstart + bands[1].end - bands[1].start; + assert(bands[1].locend == end); + *numbandsptr = 2; } /******************************************************************************\ @@ -1067,25 +1067,25 @@ void jpc_qmfb1d_getbands(jpc_qmfb1d_t *qmfb, int flags, uint_fast32_t xstart, int jpc_qmfb1d_getnumchans(jpc_qmfb1d_t *qmfb) { - return (*qmfb->ops->getnumchans)(qmfb); + return (*qmfb->ops->getnumchans)(qmfb); } int jpc_qmfb1d_getanalfilters(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters) { - return (*qmfb->ops->getanalfilters)(qmfb, len, filters); + return (*qmfb->ops->getanalfilters)(qmfb, len, filters); } int jpc_qmfb1d_getsynfilters(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters) { - return (*qmfb->ops->getsynfilters)(qmfb, len, filters); + return (*qmfb->ops->getsynfilters)(qmfb, len, filters); } void jpc_qmfb1d_analyze(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x) { - (*qmfb->ops->analyze)(qmfb, flags, x); + (*qmfb->ops->analyze)(qmfb, flags, x); } void jpc_qmfb1d_synthesize(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x) { - (*qmfb->ops->synthesize)(qmfb, flags, x); + (*qmfb->ops->synthesize)(qmfb, flags, x); } diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.h b/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.h index e10b6c13..fb46965b 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_qmfb.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -130,17 +130,17 @@ \******************************************************************************/ /* The maximum number of channels for a QMF bank. */ -#define JPC_QMFB1D_MAXCHANS 2 +#define JPC_QMFB1D_MAXCHANS 2 /* Select reversible integer-to-integer mode. */ -#define JPC_QMFB1D_RITIMODE 1 +#define JPC_QMFB1D_RITIMODE 1 /* Vertical filtering. */ -#define JPC_QMFB1D_VERT 0x10000 +#define JPC_QMFB1D_VERT 0x10000 /* QMFB IDs. */ -#define JPC_QMFB1D_FT 1 /* 5/3 */ -#define JPC_QMFB1D_NS 2 /* 9/7 */ +#define JPC_QMFB1D_FT 1 /* 5/3 */ +#define JPC_QMFB1D_NS 2 /* 9/7 */ /******************************************************************************\ * Types. @@ -153,17 +153,17 @@ struct jpc_qmfb1dops_s; typedef struct { - /* The starting index for the band in the downsampled domain. */ - int start; + /* The starting index for the band in the downsampled domain. */ + int start; - /* The ending index for the band in the downsampled domain. */ - int end; + /* The ending index for the band in the downsampled domain. */ + int end; - /* The location of the start of the band. */ - int locstart; + /* The location of the start of the band. */ + int locstart; - /* The location of the end of the band. */ - int locend; + /* The location of the end of the band. */ + int locend; } jpc_qmfb1dband_t; @@ -171,8 +171,8 @@ typedef struct { typedef struct { - /* The operations for this QMFB. */ - struct jpc_qmfb1dops_s *ops; + /* The operations for this QMFB. */ + struct jpc_qmfb1dops_s *ops; } jpc_qmfb1d_t; @@ -180,20 +180,20 @@ typedef struct { typedef struct jpc_qmfb1dops_s { - /* The number of channels in the QMFB. */ - int (*getnumchans)(jpc_qmfb1d_t *qmfb); + /* The number of channels in the QMFB. */ + int (*getnumchans)(jpc_qmfb1d_t *qmfb); - /* Get the analysis filters for this QMFB. */ - int (*getanalfilters)(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters); + /* Get the analysis filters for this QMFB. */ + int (*getanalfilters)(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters); - /* Get the synthesis filters for this QMFB. */ - int (*getsynfilters)(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters); + /* Get the synthesis filters for this QMFB. */ + int (*getsynfilters)(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters); - /* Do analysis. */ - void (*analyze)(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x); + /* Do analysis. */ + void (*analyze)(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x); - /* Do synthesis. */ - void (*synthesize)(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x); + /* Do synthesis. */ + void (*synthesize)(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x); } jpc_qmfb1dops_t; diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.c index 650cb854..ed188154 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -157,46 +157,46 @@ jpc_mqctx_t jpc_mqctxs[JPC_NUMCTXS]; int JPC_PASSTYPE(int passno) { - int passtype; - switch (passno % 3) { - case 0: - passtype = JPC_CLNPASS; - break; - case 1: - passtype = JPC_SIGPASS; - break; - case 2: - passtype = JPC_REFPASS; - break; - default: - passtype = -1; - assert(0); - break; - } - return passtype; + int passtype; + switch (passno % 3) { + case 0: + passtype = JPC_CLNPASS; + break; + case 1: + passtype = JPC_SIGPASS; + break; + case 2: + passtype = JPC_REFPASS; + break; + default: + passtype = -1; + assert(0); + break; + } + return passtype; } int JPC_NOMINALGAIN(int qmfbid, int numlvls, int lvlno, int orient) { if (qmfbid == JPC_COX_INS) { - return 0; + return 0; } - assert(qmfbid == JPC_COX_RFT); - if (lvlno == 0) { - assert(orient == JPC_TSFB_LL); - return 0; - } else { - switch (orient) { - case JPC_TSFB_LH: - case JPC_TSFB_HL: - return 1; - break; - case JPC_TSFB_HH: - return 2; - break; - } - } - abort(); + assert(qmfbid == JPC_COX_RFT); + if (lvlno == 0) { + assert(orient == JPC_TSFB_LL); + return 0; + } else { + switch (orient) { + case JPC_TSFB_LH: + case JPC_TSFB_HL: + return 1; + break; + case JPC_TSFB_HH: + return 2; + break; + } + } + abort(); } /******************************************************************************\ @@ -205,66 +205,66 @@ if (qmfbid == JPC_COX_INS) { int JPC_SEGTYPE(int passno, int firstpassno, int bypass) { - int passtype; - if (bypass) { - passtype = JPC_PASSTYPE(passno); - if (passtype == JPC_CLNPASS) { - return JPC_SEG_MQ; - } - return ((passno < firstpassno + 10) ? JPC_SEG_MQ : JPC_SEG_RAW); - } else { - return JPC_SEG_MQ; - } + int passtype; + if (bypass) { + passtype = JPC_PASSTYPE(passno); + if (passtype == JPC_CLNPASS) { + return JPC_SEG_MQ; + } + return ((passno < firstpassno + 10) ? JPC_SEG_MQ : JPC_SEG_RAW); + } else { + return JPC_SEG_MQ; + } } int JPC_SEGPASSCNT(int passno, int firstpassno, int numpasses, int bypass, int termall) { - int ret; - int passtype; - - if (termall) { - ret = 1; - } else if (bypass) { - if (passno < firstpassno + 10) { - ret = 10 - (passno - firstpassno); - } else { - passtype = JPC_PASSTYPE(passno); - switch (passtype) { - case JPC_SIGPASS: - ret = 2; - break; - case JPC_REFPASS: - ret = 1; - break; - case JPC_CLNPASS: - ret = 1; - break; - default: - ret = -1; - assert(0); - break; - } - } - } else { - ret = JPC_PREC * 3 - 2; - } - ret = JAS_MIN(ret, numpasses - passno); - return ret; + int ret; + int passtype; + + if (termall) { + ret = 1; + } else if (bypass) { + if (passno < firstpassno + 10) { + ret = 10 - (passno - firstpassno); + } else { + passtype = JPC_PASSTYPE(passno); + switch (passtype) { + case JPC_SIGPASS: + ret = 2; + break; + case JPC_REFPASS: + ret = 1; + break; + case JPC_CLNPASS: + ret = 1; + break; + default: + ret = -1; + assert(0); + break; + } + } + } else { + ret = JPC_PREC * 3 - 2; + } + ret = JAS_MIN(ret, numpasses - passno); + return ret; } int JPC_ISTERMINATED(int passno, int firstpassno, int numpasses, int termall, int lazy) { - int ret; - int n; - if (passno - firstpassno == numpasses - 1) { - ret = 1; - } else { - n = JPC_SEGPASSCNT(passno, firstpassno, numpasses, lazy, termall); - ret = (n <= 1) ? 1 : 0; - } - - return ret; + int ret; + int n; + if (passno - firstpassno == numpasses - 1) { + ret = 1; + } else { + n = JPC_SEGPASSCNT(passno, firstpassno, numpasses, lazy, termall); + ret = (n <= 1) ? 1 : 0; + } + + return ret; } /******************************************************************************\ @@ -273,265 +273,265 @@ int JPC_ISTERMINATED(int passno, int firstpassno, int numpasses, int termall, static void jpc_initmqctxs(void) { - jpc_initctxs(jpc_mqctxs); + jpc_initctxs(jpc_mqctxs); } void jpc_initluts() { - int i; - int orient; - int refine; - float u; - float v; - float t; + int i; + int orient; + int refine; + float u; + float v; + float t; /* XXX - hack */ jpc_initmqctxs(); - for (orient = 0; orient < 4; ++orient) { - for (i = 0; i < 256; ++i) { - jpc_zcctxnolut[(orient << 8) | i] = jpc_getzcctxno(i, orient); - } - } - - for (i = 0; i < 256; ++i) { - jpc_spblut[i] = jpc_getspb(i << 4); - } - - for (i = 0; i < 256; ++i) { - jpc_scctxnolut[i] = jpc_getscctxno(i << 4); - } - - for (refine = 0; refine < 2; ++refine) { - for (i = 0; i < 2048; ++i) { - jpc_magctxnolut[(refine << 11) + i] = jpc_getmagctxno((refine ? JPC_REFINE : 0) | i); - } - } - - for (i = 0; i < (1 << JPC_NMSEDEC_BITS); ++i) { - t = i * jpc_pow2i(-JPC_NMSEDEC_FRACBITS); - u = t; - v = t - 1.5; - jpc_signmsedec[i] = jpc_dbltofix(floor((u * u - v * v) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS)); + for (orient = 0; orient < 4; ++orient) { + for (i = 0; i < 256; ++i) { + jpc_zcctxnolut[(orient << 8) | i] = jpc_getzcctxno(i, orient); + } + } + + for (i = 0; i < 256; ++i) { + jpc_spblut[i] = jpc_getspb(i << 4); + } + + for (i = 0; i < 256; ++i) { + jpc_scctxnolut[i] = jpc_getscctxno(i << 4); + } + + for (refine = 0; refine < 2; ++refine) { + for (i = 0; i < 2048; ++i) { + jpc_magctxnolut[(refine << 11) + i] = jpc_getmagctxno((refine ? JPC_REFINE : 0) | i); + } + } + + for (i = 0; i < (1 << JPC_NMSEDEC_BITS); ++i) { + t = i * jpc_pow2i(-JPC_NMSEDEC_FRACBITS); + u = t; + v = t - 1.5; + jpc_signmsedec[i] = jpc_dbltofix(floor((u * u - v * v) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS)); /* XXX - this calc is not correct */ - jpc_signmsedec0[i] = jpc_dbltofix(floor((u * u) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS)); - u = t - 1.0; - if (i & (1 << (JPC_NMSEDEC_BITS - 1))) { - v = t - 1.5; - } else { - v = t - 0.5; - } - jpc_refnmsedec[i] = jpc_dbltofix(floor((u * u - v * v) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS)); + jpc_signmsedec0[i] = jpc_dbltofix(floor((u * u) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS)); + u = t - 1.0; + if (i & (1 << (JPC_NMSEDEC_BITS - 1))) { + v = t - 1.5; + } else { + v = t - 0.5; + } + jpc_refnmsedec[i] = jpc_dbltofix(floor((u * u - v * v) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS)); /* XXX - this calc is not correct */ - jpc_refnmsedec0[i] = jpc_dbltofix(floor((u * u) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS)); - } + jpc_refnmsedec0[i] = jpc_dbltofix(floor((u * u) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS)); + } } jpc_fix_t jpc_getsignmsedec_func(jpc_fix_t x, int bitpos) { - jpc_fix_t y; - assert(!(x & (~JAS_ONES(bitpos + 1)))); - y = jpc_getsignmsedec_macro(x, bitpos); - return y; + jpc_fix_t y; + assert(!(x & (~JAS_ONES(bitpos + 1)))); + y = jpc_getsignmsedec_macro(x, bitpos); + return y; } int jpc_getzcctxno(int f, int orient) { - int h; - int v; - int d; - int n; - int t; - int hv; - - /* Avoid compiler warning. */ - n = 0; - - h = ((f & JPC_WSIG) != 0) + ((f & JPC_ESIG) != 0); - v = ((f & JPC_NSIG) != 0) + ((f & JPC_SSIG) != 0); - d = ((f & JPC_NWSIG) != 0) + ((f & JPC_NESIG) != 0) + ((f & JPC_SESIG) != 0) + ((f & JPC_SWSIG) != 0); - switch (orient) { - case JPC_TSFB_HL: - t = h; - h = v; - v = t; - case JPC_TSFB_LL: - case JPC_TSFB_LH: - if (!h) { - if (!v) { - if (!d) { - n = 0; - } else if (d == 1) { - n = 1; - } else { - n = 2; - } - } else if (v == 1) { - n = 3; - } else { - n = 4; - } - } else if (h == 1) { - if (!v) { - if (!d) { - n = 5; - } else { - n = 6; - } - } else { - n = 7; - } - } else { - n = 8; - } - break; - case JPC_TSFB_HH: - hv = h + v; - if (!d) { - if (!hv) { - n = 0; - } else if (hv == 1) { - n = 1; - } else { - n = 2; - } - } else if (d == 1) { - if (!hv) { - n = 3; - } else if (hv == 1) { - n = 4; - } else { - n = 5; - } - } else if (d == 2) { - if (!hv) { - n = 6; - } else { - n = 7; - } - } else { - n = 8; - } - break; - } - assert(n < JPC_NUMZCCTXS); - return JPC_ZCCTXNO + n; + int h; + int v; + int d; + int n; + int t; + int hv; + + /* Avoid compiler warning. */ + n = 0; + + h = ((f & JPC_WSIG) != 0) + ((f & JPC_ESIG) != 0); + v = ((f & JPC_NSIG) != 0) + ((f & JPC_SSIG) != 0); + d = ((f & JPC_NWSIG) != 0) + ((f & JPC_NESIG) != 0) + ((f & JPC_SESIG) != 0) + ((f & JPC_SWSIG) != 0); + switch (orient) { + case JPC_TSFB_HL: + t = h; + h = v; + v = t; + case JPC_TSFB_LL: + case JPC_TSFB_LH: + if (!h) { + if (!v) { + if (!d) { + n = 0; + } else if (d == 1) { + n = 1; + } else { + n = 2; + } + } else if (v == 1) { + n = 3; + } else { + n = 4; + } + } else if (h == 1) { + if (!v) { + if (!d) { + n = 5; + } else { + n = 6; + } + } else { + n = 7; + } + } else { + n = 8; + } + break; + case JPC_TSFB_HH: + hv = h + v; + if (!d) { + if (!hv) { + n = 0; + } else if (hv == 1) { + n = 1; + } else { + n = 2; + } + } else if (d == 1) { + if (!hv) { + n = 3; + } else if (hv == 1) { + n = 4; + } else { + n = 5; + } + } else if (d == 2) { + if (!hv) { + n = 6; + } else { + n = 7; + } + } else { + n = 8; + } + break; + } + assert(n < JPC_NUMZCCTXS); + return JPC_ZCCTXNO + n; } int jpc_getspb(int f) { - int hc; - int vc; - int n; - - hc = JAS_MIN(((f & (JPC_ESIG | JPC_ESGN)) == JPC_ESIG) + ((f & (JPC_WSIG | JPC_WSGN)) == JPC_WSIG), 1) - - JAS_MIN(((f & (JPC_ESIG | JPC_ESGN)) == (JPC_ESIG | JPC_ESGN)) + ((f & (JPC_WSIG | JPC_WSGN)) == (JPC_WSIG | JPC_WSGN)), 1); - vc = JAS_MIN(((f & (JPC_NSIG | JPC_NSGN)) == JPC_NSIG) + ((f & (JPC_SSIG | JPC_SSGN)) == JPC_SSIG), 1) - - JAS_MIN(((f & (JPC_NSIG | JPC_NSGN)) == (JPC_NSIG | JPC_NSGN)) + ((f & (JPC_SSIG | JPC_SSGN)) == (JPC_SSIG | JPC_SSGN)), 1); - if (!hc && !vc) { - n = 0; - } else { - n = (!(hc > 0 || (!hc && vc > 0))); - } - return n; + int hc; + int vc; + int n; + + hc = JAS_MIN(((f & (JPC_ESIG | JPC_ESGN)) == JPC_ESIG) + ((f & (JPC_WSIG | JPC_WSGN)) == JPC_WSIG), 1) - + JAS_MIN(((f & (JPC_ESIG | JPC_ESGN)) == (JPC_ESIG | JPC_ESGN)) + ((f & (JPC_WSIG | JPC_WSGN)) == (JPC_WSIG | JPC_WSGN)), 1); + vc = JAS_MIN(((f & (JPC_NSIG | JPC_NSGN)) == JPC_NSIG) + ((f & (JPC_SSIG | JPC_SSGN)) == JPC_SSIG), 1) - + JAS_MIN(((f & (JPC_NSIG | JPC_NSGN)) == (JPC_NSIG | JPC_NSGN)) + ((f & (JPC_SSIG | JPC_SSGN)) == (JPC_SSIG | JPC_SSGN)), 1); + if (!hc && !vc) { + n = 0; + } else { + n = (!(hc > 0 || (!hc && vc > 0))); + } + return n; } int jpc_getscctxno(int f) { - int hc; - int vc; - int n; - - /* Avoid compiler warning. */ - n = 0; - - hc = JAS_MIN(((f & (JPC_ESIG | JPC_ESGN)) == JPC_ESIG) + ((f & (JPC_WSIG | JPC_WSGN)) == JPC_WSIG), - 1) - JAS_MIN(((f & (JPC_ESIG | JPC_ESGN)) == (JPC_ESIG | JPC_ESGN)) + - ((f & (JPC_WSIG | JPC_WSGN)) == (JPC_WSIG | JPC_WSGN)), 1); - vc = JAS_MIN(((f & (JPC_NSIG | JPC_NSGN)) == JPC_NSIG) + ((f & (JPC_SSIG | JPC_SSGN)) == JPC_SSIG), - 1) - JAS_MIN(((f & (JPC_NSIG | JPC_NSGN)) == (JPC_NSIG | JPC_NSGN)) + - ((f & (JPC_SSIG | JPC_SSGN)) == (JPC_SSIG | JPC_SSGN)), 1); - assert(hc >= -1 && hc <= 1 && vc >= -1 && vc <= 1); - if (hc < 0) { - hc = -hc; - vc = -vc; - } - if (!hc) { - if (vc == -1) { - n = 1; - } else if (!vc) { - n = 0; - } else { - n = 1; - } - } else if (hc == 1) { - if (vc == -1) { - n = 2; - } else if (!vc) { - n = 3; - } else { - n = 4; - } - } - assert(n < JPC_NUMSCCTXS); - return JPC_SCCTXNO + n; + int hc; + int vc; + int n; + + /* Avoid compiler warning. */ + n = 0; + + hc = JAS_MIN(((f & (JPC_ESIG | JPC_ESGN)) == JPC_ESIG) + ((f & (JPC_WSIG | JPC_WSGN)) == JPC_WSIG), + 1) - JAS_MIN(((f & (JPC_ESIG | JPC_ESGN)) == (JPC_ESIG | JPC_ESGN)) + + ((f & (JPC_WSIG | JPC_WSGN)) == (JPC_WSIG | JPC_WSGN)), 1); + vc = JAS_MIN(((f & (JPC_NSIG | JPC_NSGN)) == JPC_NSIG) + ((f & (JPC_SSIG | JPC_SSGN)) == JPC_SSIG), + 1) - JAS_MIN(((f & (JPC_NSIG | JPC_NSGN)) == (JPC_NSIG | JPC_NSGN)) + + ((f & (JPC_SSIG | JPC_SSGN)) == (JPC_SSIG | JPC_SSGN)), 1); + assert(hc >= -1 && hc <= 1 && vc >= -1 && vc <= 1); + if (hc < 0) { + hc = -hc; + vc = -vc; + } + if (!hc) { + if (vc == -1) { + n = 1; + } else if (!vc) { + n = 0; + } else { + n = 1; + } + } else if (hc == 1) { + if (vc == -1) { + n = 2; + } else if (!vc) { + n = 3; + } else { + n = 4; + } + } + assert(n < JPC_NUMSCCTXS); + return JPC_SCCTXNO + n; } int jpc_getmagctxno(int f) { - int n; + int n; - if (!(f & JPC_REFINE)) { - n = (f & (JPC_OTHSIGMSK)) ? 1 : 0; - } else { - n = 2; - } + if (!(f & JPC_REFINE)) { + n = (f & (JPC_OTHSIGMSK)) ? 1 : 0; + } else { + n = 2; + } - assert(n < JPC_NUMMAGCTXS); - return JPC_MAGCTXNO + n; + assert(n < JPC_NUMMAGCTXS); + return JPC_MAGCTXNO + n; } void jpc_initctxs(jpc_mqctx_t *ctxs) { - jpc_mqctx_t *ctx; - int i; - - ctx = ctxs; - for (i = 0; i < JPC_NUMCTXS; ++i) { - ctx->mps = 0; - switch (i) { - case JPC_UCTXNO: - ctx->ind = 46; - break; - case JPC_ZCCTXNO: - ctx->ind = 4; - break; - case JPC_AGGCTXNO: - ctx->ind = 3; - break; - default: - ctx->ind = 0; - break; - } - ++ctx; - } + jpc_mqctx_t *ctx; + int i; + + ctx = ctxs; + for (i = 0; i < JPC_NUMCTXS; ++i) { + ctx->mps = 0; + switch (i) { + case JPC_UCTXNO: + ctx->ind = 46; + break; + case JPC_ZCCTXNO: + ctx->ind = 4; + break; + case JPC_AGGCTXNO: + ctx->ind = 3; + break; + default: + ctx->ind = 0; + break; + } + ++ctx; + } } /* Calculate the real quantity exp2(n), where x is an integer. */ double jpc_pow2i(int n) { - double x; - double a; - - x = 1.0; - if (n < 0) { - a = 0.5; - n = -n; - } else { - a = 2.0; - } - while (--n >= 0) { - x *= a; - } - return x; + double x; + double a; + + x = 1.0; + if (n < 0) { + a = 0.5; + n = -n; + } else { + a = 2.0; + } + while (--n >= 0) { + x *= a; + } + return x; } diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.h b/converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.h index 3e061d20..771464ec 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t1cod.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -132,95 +132,95 @@ \******************************************************************************/ /* The number of bits used to index into various lookup tables. */ -#define JPC_NMSEDEC_BITS 7 -#define JPC_NMSEDEC_FRACBITS (JPC_NMSEDEC_BITS - 1) +#define JPC_NMSEDEC_BITS 7 +#define JPC_NMSEDEC_FRACBITS (JPC_NMSEDEC_BITS - 1) /* * Segment types. */ /* Invalid. */ -#define JPC_SEG_INVALID 0 +#define JPC_SEG_INVALID 0 /* MQ. */ -#define JPC_SEG_MQ 1 +#define JPC_SEG_MQ 1 /* Raw. */ -#define JPC_SEG_RAW 2 +#define JPC_SEG_RAW 2 /* The nominal word size. */ -#define JPC_PREC 32 +#define JPC_PREC 32 /* Tier-1 coding pass types. */ -#define JPC_SIGPASS 0 /* significance */ -#define JPC_REFPASS 1 /* refinement */ -#define JPC_CLNPASS 2 /* cleanup */ +#define JPC_SIGPASS 0 /* significance */ +#define JPC_REFPASS 1 /* refinement */ +#define JPC_CLNPASS 2 /* cleanup */ /* * Per-sample state information for tier-1 coding. */ /* The northeast neighbour has been found to be significant. */ -#define JPC_NESIG 0x0001 +#define JPC_NESIG 0x0001 /* The southeast neighbour has been found to be significant. */ -#define JPC_SESIG 0x0002 +#define JPC_SESIG 0x0002 /* The southwest neighbour has been found to be significant. */ -#define JPC_SWSIG 0x0004 +#define JPC_SWSIG 0x0004 /* The northwest neighbour has been found to be significant. */ -#define JPC_NWSIG 0x0008 +#define JPC_NWSIG 0x0008 /* The north neighbour has been found to be significant. */ -#define JPC_NSIG 0x0010 +#define JPC_NSIG 0x0010 /* The east neighbour has been found to be significant. */ -#define JPC_ESIG 0x0020 +#define JPC_ESIG 0x0020 /* The south neighbour has been found to be significant. */ -#define JPC_SSIG 0x0040 +#define JPC_SSIG 0x0040 /* The west neighbour has been found to be significant. */ -#define JPC_WSIG 0x0080 +#define JPC_WSIG 0x0080 /* The significance mask for 8-connected neighbours. */ -#define JPC_OTHSIGMSK \ - (JPC_NSIG | JPC_NESIG | JPC_ESIG | JPC_SESIG | JPC_SSIG | JPC_SWSIG | JPC_WSIG | JPC_NWSIG) +#define JPC_OTHSIGMSK \ + (JPC_NSIG | JPC_NESIG | JPC_ESIG | JPC_SESIG | JPC_SSIG | JPC_SWSIG | JPC_WSIG | JPC_NWSIG) /* The significance mask for 4-connected neighbours. */ -#define JPC_PRIMSIGMSK (JPC_NSIG | JPC_ESIG | JPC_SSIG | JPC_WSIG) +#define JPC_PRIMSIGMSK (JPC_NSIG | JPC_ESIG | JPC_SSIG | JPC_WSIG) /* The north neighbour is negative in value. */ -#define JPC_NSGN 0x0100 +#define JPC_NSGN 0x0100 /* The east neighbour is negative in value. */ -#define JPC_ESGN 0x0200 +#define JPC_ESGN 0x0200 /* The south neighbour is negative in value. */ -#define JPC_SSGN 0x0400 +#define JPC_SSGN 0x0400 /* The west neighbour is negative in value. */ -#define JPC_WSGN 0x0800 +#define JPC_WSGN 0x0800 /* The sign mask for 4-connected neighbours. */ -#define JPC_SGNMSK (JPC_NSGN | JPC_ESGN | JPC_SSGN | JPC_WSGN) +#define JPC_SGNMSK (JPC_NSGN | JPC_ESGN | JPC_SSGN | JPC_WSGN) /* This sample has been found to be significant. */ -#define JPC_SIG 0x1000 +#define JPC_SIG 0x1000 /* The sample has been refined. */ -#define JPC_REFINE 0x2000 +#define JPC_REFINE 0x2000 /* This sample has been processed during the significance pass. */ -#define JPC_VISIT 0x4000 +#define JPC_VISIT 0x4000 /* The number of aggregation contexts. */ -#define JPC_NUMAGGCTXS 1 +#define JPC_NUMAGGCTXS 1 /* The number of zero coding contexts. */ -#define JPC_NUMZCCTXS 9 +#define JPC_NUMZCCTXS 9 /* The number of magnitude contexts. */ -#define JPC_NUMMAGCTXS 3 +#define JPC_NUMMAGCTXS 3 /* The number of sign coding contexts. */ -#define JPC_NUMSCCTXS 5 +#define JPC_NUMSCCTXS 5 /* The number of uniform contexts. */ -#define JPC_NUMUCTXS 1 +#define JPC_NUMUCTXS 1 /* The context ID for the first aggregation context. */ -#define JPC_AGGCTXNO 0 +#define JPC_AGGCTXNO 0 /* The context ID for the first zero coding context. */ -#define JPC_ZCCTXNO (JPC_AGGCTXNO + JPC_NUMAGGCTXS) +#define JPC_ZCCTXNO (JPC_AGGCTXNO + JPC_NUMAGGCTXS) /* The context ID for the first magnitude context. */ -#define JPC_MAGCTXNO (JPC_ZCCTXNO + JPC_NUMZCCTXS) +#define JPC_MAGCTXNO (JPC_ZCCTXNO + JPC_NUMZCCTXS) /* The context ID for the first sign coding context. */ -#define JPC_SCCTXNO (JPC_MAGCTXNO + JPC_NUMMAGCTXS) +#define JPC_SCCTXNO (JPC_MAGCTXNO + JPC_NUMMAGCTXS) /* The context ID for the first uniform context. */ -#define JPC_UCTXNO (JPC_SCCTXNO + JPC_NUMSCCTXS) +#define JPC_UCTXNO (JPC_SCCTXNO + JPC_NUMSCCTXS) /* The total number of contexts. */ -#define JPC_NUMCTXS (JPC_UCTXNO + JPC_NUMUCTXS) +#define JPC_NUMCTXS (JPC_UCTXNO + JPC_NUMUCTXS) /******************************************************************************\ * External data. @@ -249,76 +249,76 @@ void jpc_initctxs(jpc_mqctx_t *ctxs); /* Get the zero coding context. */ int jpc_getzcctxno(int f, int orient); -#define JPC_GETZCCTXNO(f, orient) \ - (jpc_zcctxnolut[((orient) << 8) | ((f) & JPC_OTHSIGMSK)]) +#define JPC_GETZCCTXNO(f, orient) \ + (jpc_zcctxnolut[((orient) << 8) | ((f) & JPC_OTHSIGMSK)]) /* Get the sign prediction bit. */ int jpc_getspb(int f); -#define JPC_GETSPB(f) \ - (jpc_spblut[((f) & (JPC_PRIMSIGMSK | JPC_SGNMSK)) >> 4]) +#define JPC_GETSPB(f) \ + (jpc_spblut[((f) & (JPC_PRIMSIGMSK | JPC_SGNMSK)) >> 4]) /* Get the sign coding context. */ int jpc_getscctxno(int f); -#define JPC_GETSCCTXNO(f) \ - (jpc_scctxnolut[((f) & (JPC_PRIMSIGMSK | JPC_SGNMSK)) >> 4]) +#define JPC_GETSCCTXNO(f) \ + (jpc_scctxnolut[((f) & (JPC_PRIMSIGMSK | JPC_SGNMSK)) >> 4]) /* Get the magnitude context. */ int jpc_getmagctxno(int f); -#define JPC_GETMAGCTXNO(f) \ - (jpc_magctxnolut[((f) & JPC_OTHSIGMSK) | ((((f) & JPC_REFINE) != 0) << 11)]) +#define JPC_GETMAGCTXNO(f) \ + (jpc_magctxnolut[((f) & JPC_OTHSIGMSK) | ((((f) & JPC_REFINE) != 0) << 11)]) /* Get the normalized MSE reduction for significance passes. */ -#define JPC_GETSIGNMSEDEC(x, bitpos) jpc_getsignmsedec_macro(x, bitpos) +#define JPC_GETSIGNMSEDEC(x, bitpos) jpc_getsignmsedec_macro(x, bitpos) jpc_fix_t jpc_getsignmsedec_func(jpc_fix_t x, int bitpos); -#define jpc_getsignmsedec_macro(x, bitpos) \ - ((bitpos > JPC_NMSEDEC_FRACBITS) ? jpc_signmsedec[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)] : \ - (jpc_signmsedec0[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)])) +#define jpc_getsignmsedec_macro(x, bitpos) \ + ((bitpos > JPC_NMSEDEC_FRACBITS) ? jpc_signmsedec[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)] : \ + (jpc_signmsedec0[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)])) /* Get the normalized MSE reduction for refinement passes. */ -#define JPC_GETREFNMSEDEC(x, bitpos) jpc_getrefnmsedec_macro(x, bitpos) +#define JPC_GETREFNMSEDEC(x, bitpos) jpc_getrefnmsedec_macro(x, bitpos) jpc_fix_t jpc_refsignmsedec_func(jpc_fix_t x, int bitpos); -#define jpc_getrefnmsedec_macro(x, bitpos) \ - ((bitpos > JPC_NMSEDEC_FRACBITS) ? jpc_refnmsedec[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)] : \ - (jpc_refnmsedec0[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)])) +#define jpc_getrefnmsedec_macro(x, bitpos) \ + ((bitpos > JPC_NMSEDEC_FRACBITS) ? jpc_refnmsedec[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)] : \ + (jpc_refnmsedec0[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)])) /* Arithmetic shift right (with ability to shift left also). */ -#define JPC_ASR(x, n) \ - (((n) >= 0) ? ((x) >> (n)) : ((x) << (-(n)))) +#define JPC_ASR(x, n) \ + (((n) >= 0) ? ((x) >> (n)) : ((x) << (-(n)))) /* Update the per-sample state information. */ -#define JPC_UPDATEFLAGS4(fp, rowstep, s, vcausalflag) \ +#define JPC_UPDATEFLAGS4(fp, rowstep, s, vcausalflag) \ { \ - register jpc_fix_t *np = (fp) - (rowstep); \ - register jpc_fix_t *sp = (fp) + (rowstep); \ - if ((vcausalflag)) { \ - sp[-1] |= JPC_NESIG; \ - sp[1] |= JPC_NWSIG; \ - if (s) { \ - *sp |= JPC_NSIG | JPC_NSGN; \ - (fp)[-1] |= JPC_ESIG | JPC_ESGN; \ - (fp)[1] |= JPC_WSIG | JPC_WSGN; \ - } else { \ - *sp |= JPC_NSIG; \ - (fp)[-1] |= JPC_ESIG; \ - (fp)[1] |= JPC_WSIG; \ - } \ - } else { \ - np[-1] |= JPC_SESIG; \ - np[1] |= JPC_SWSIG; \ - sp[-1] |= JPC_NESIG; \ - sp[1] |= JPC_NWSIG; \ - if (s) { \ - *np |= JPC_SSIG | JPC_SSGN; \ - *sp |= JPC_NSIG | JPC_NSGN; \ - (fp)[-1] |= JPC_ESIG | JPC_ESGN; \ - (fp)[1] |= JPC_WSIG | JPC_WSGN; \ - } else { \ - *np |= JPC_SSIG; \ - *sp |= JPC_NSIG; \ - (fp)[-1] |= JPC_ESIG; \ - (fp)[1] |= JPC_WSIG; \ - } \ - } \ + register jpc_fix_t *np = (fp) - (rowstep); \ + register jpc_fix_t *sp = (fp) + (rowstep); \ + if ((vcausalflag)) { \ + sp[-1] |= JPC_NESIG; \ + sp[1] |= JPC_NWSIG; \ + if (s) { \ + *sp |= JPC_NSIG | JPC_NSGN; \ + (fp)[-1] |= JPC_ESIG | JPC_ESGN; \ + (fp)[1] |= JPC_WSIG | JPC_WSGN; \ + } else { \ + *sp |= JPC_NSIG; \ + (fp)[-1] |= JPC_ESIG; \ + (fp)[1] |= JPC_WSIG; \ + } \ + } else { \ + np[-1] |= JPC_SESIG; \ + np[1] |= JPC_SWSIG; \ + sp[-1] |= JPC_NESIG; \ + sp[1] |= JPC_NWSIG; \ + if (s) { \ + *np |= JPC_SSIG | JPC_SSGN; \ + *sp |= JPC_NSIG | JPC_NSGN; \ + (fp)[-1] |= JPC_ESIG | JPC_ESGN; \ + (fp)[1] |= JPC_WSIG | JPC_WSGN; \ + } else { \ + *np |= JPC_SSIG; \ + *sp |= JPC_NSIG; \ + (fp)[-1] |= JPC_ESIG; \ + (fp)[1] |= JPC_WSIG; \ + } \ + } \ } /* Initialize the lookup tables used by the codec. */ diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.c index b6c5e14f..437e9dd6 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.h b/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.h index f8b3b342..35ff549a 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t1dec.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c index 34b9738c..e9ec12d4 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -433,7 +433,7 @@ assert(jas_stream_tell(cblk->stream) == jas_stream_getrwcount(cblk->stream)); #if 0 /* XXX - This assertion fails sometimes when various coding modes are used. This seems to be harmless, but why does it happen at all? */ - assert(jas_stream_tell(cblk->stream) == + assert(jas_stream_tell(cblk->stream) == jas_stream_getrwcount(cblk->stream)); #endif diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.h b/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.h index 9ce5ed27..08b4811f 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.c index a9ca0dc1..9a635285 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -132,602 +132,602 @@ static int jpc_pi_nextcprl(jpc_pi_t *pi); int jpc_pi_next(jpc_pi_t *pi) { - jpc_pchg_t *pchg; - int ret; - - - for (;;) { - - pi->valid = false; - - if (!pi->pchg) { - ++pi->pchgno; - pi->compno = 0; - pi->rlvlno = 0; - pi->prcno = 0; - pi->lyrno = 0; - pi->prgvolfirst = true; - if (pi->pchgno < jpc_pchglist_numpchgs(pi->pchglist)) { - pi->pchg = jpc_pchglist_get(pi->pchglist, pi->pchgno); - } else if (pi->pchgno == jpc_pchglist_numpchgs(pi->pchglist)) { - pi->pchg = &pi->defaultpchg; - } else { - return 1; - } - } - - pchg = pi->pchg; - switch (pchg->prgord) { - case JPC_COD_LRCPPRG: - ret = jpc_pi_nextlrcp(pi); - break; - case JPC_COD_RLCPPRG: - ret = jpc_pi_nextrlcp(pi); - break; - case JPC_COD_RPCLPRG: - ret = jpc_pi_nextrpcl(pi); - break; - case JPC_COD_PCRLPRG: - ret = jpc_pi_nextpcrl(pi); - break; - case JPC_COD_CPRLPRG: - ret = jpc_pi_nextcprl(pi); - break; - default: - ret = -1; - break; - } - if (!ret) { - pi->valid = true; - ++pi->pktno; - return 0; - } - pi->pchg = 0; - } + jpc_pchg_t *pchg; + int ret; + + + for (;;) { + + pi->valid = false; + + if (!pi->pchg) { + ++pi->pchgno; + pi->compno = 0; + pi->rlvlno = 0; + pi->prcno = 0; + pi->lyrno = 0; + pi->prgvolfirst = true; + if (pi->pchgno < jpc_pchglist_numpchgs(pi->pchglist)) { + pi->pchg = jpc_pchglist_get(pi->pchglist, pi->pchgno); + } else if (pi->pchgno == jpc_pchglist_numpchgs(pi->pchglist)) { + pi->pchg = &pi->defaultpchg; + } else { + return 1; + } + } + + pchg = pi->pchg; + switch (pchg->prgord) { + case JPC_COD_LRCPPRG: + ret = jpc_pi_nextlrcp(pi); + break; + case JPC_COD_RLCPPRG: + ret = jpc_pi_nextrlcp(pi); + break; + case JPC_COD_RPCLPRG: + ret = jpc_pi_nextrpcl(pi); + break; + case JPC_COD_PCRLPRG: + ret = jpc_pi_nextpcrl(pi); + break; + case JPC_COD_CPRLPRG: + ret = jpc_pi_nextcprl(pi); + break; + default: + ret = -1; + break; + } + if (!ret) { + pi->valid = true; + ++pi->pktno; + return 0; + } + pi->pchg = 0; + } } static int jpc_pi_nextlrcp(register jpc_pi_t *pi) { - jpc_pchg_t *pchg; - int *prclyrno; - - pchg = pi->pchg; - if (!pi->prgvolfirst) { - prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; - goto skip; - } else { - pi->prgvolfirst = false; - } - - for (pi->lyrno = 0; pi->lyrno < pi->numlyrs && pi->lyrno < - pchg->lyrnoend; ++pi->lyrno) { - for (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pi->maxrlvls && - pi->rlvlno < pchg->rlvlnoend; ++pi->rlvlno) { - for (pi->compno = pchg->compnostart, pi->picomp = - &pi->picomps[pi->compno]; pi->compno < pi->numcomps - && pi->compno < pchg->compnoend; ++pi->compno, - ++pi->picomp) { - if (pi->rlvlno >= pi->picomp->numrlvls) { - continue; - } - pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno]; - for (pi->prcno = 0, prclyrno = - pi->pirlvl->prclyrnos; pi->prcno < - pi->pirlvl->numprcs; ++pi->prcno, - ++prclyrno) { - if (pi->lyrno >= *prclyrno) { - *prclyrno = pi->lyrno; - ++(*prclyrno); - return 0; - } + jpc_pchg_t *pchg; + int *prclyrno; + + pchg = pi->pchg; + if (!pi->prgvolfirst) { + prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; + goto skip; + } else { + pi->prgvolfirst = false; + } + + for (pi->lyrno = 0; pi->lyrno < pi->numlyrs && pi->lyrno < + pchg->lyrnoend; ++pi->lyrno) { + for (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pi->maxrlvls && + pi->rlvlno < pchg->rlvlnoend; ++pi->rlvlno) { + for (pi->compno = pchg->compnostart, pi->picomp = + &pi->picomps[pi->compno]; pi->compno < pi->numcomps + && pi->compno < pchg->compnoend; ++pi->compno, + ++pi->picomp) { + if (pi->rlvlno >= pi->picomp->numrlvls) { + continue; + } + pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno]; + for (pi->prcno = 0, prclyrno = + pi->pirlvl->prclyrnos; pi->prcno < + pi->pirlvl->numprcs; ++pi->prcno, + ++prclyrno) { + if (pi->lyrno >= *prclyrno) { + *prclyrno = pi->lyrno; + ++(*prclyrno); + return 0; + } skip: - ; - } - } - } - } - return 1; + ; + } + } + } + } + return 1; } static int jpc_pi_nextrlcp(register jpc_pi_t *pi) { - jpc_pchg_t *pchg; - int *prclyrno; - - pchg = pi->pchg; - if (!pi->prgvolfirst) { - assert(pi->prcno < pi->pirlvl->numprcs); - prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; - goto skip; - } else { - pi->prgvolfirst = 0; - } - - for (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pi->maxrlvls && - pi->rlvlno < pchg->rlvlnoend; ++pi->rlvlno) { - for (pi->lyrno = 0; pi->lyrno < pi->numlyrs && pi->lyrno < - pchg->lyrnoend; ++pi->lyrno) { - for (pi->compno = pchg->compnostart, pi->picomp = - &pi->picomps[pi->compno]; pi->compno < pi->numcomps && - pi->compno < pchg->compnoend; ++pi->compno, ++pi->picomp) { - if (pi->rlvlno >= pi->picomp->numrlvls) { - continue; - } - pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno]; - for (pi->prcno = 0, prclyrno = pi->pirlvl->prclyrnos; - pi->prcno < pi->pirlvl->numprcs; ++pi->prcno, ++prclyrno) { - if (pi->lyrno >= *prclyrno) { - *prclyrno = pi->lyrno; - ++(*prclyrno); - return 0; - } + jpc_pchg_t *pchg; + int *prclyrno; + + pchg = pi->pchg; + if (!pi->prgvolfirst) { + assert(pi->prcno < pi->pirlvl->numprcs); + prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; + goto skip; + } else { + pi->prgvolfirst = 0; + } + + for (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pi->maxrlvls && + pi->rlvlno < pchg->rlvlnoend; ++pi->rlvlno) { + for (pi->lyrno = 0; pi->lyrno < pi->numlyrs && pi->lyrno < + pchg->lyrnoend; ++pi->lyrno) { + for (pi->compno = pchg->compnostart, pi->picomp = + &pi->picomps[pi->compno]; pi->compno < pi->numcomps && + pi->compno < pchg->compnoend; ++pi->compno, ++pi->picomp) { + if (pi->rlvlno >= pi->picomp->numrlvls) { + continue; + } + pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno]; + for (pi->prcno = 0, prclyrno = pi->pirlvl->prclyrnos; + pi->prcno < pi->pirlvl->numprcs; ++pi->prcno, ++prclyrno) { + if (pi->lyrno >= *prclyrno) { + *prclyrno = pi->lyrno; + ++(*prclyrno); + return 0; + } skip: - ; - } - } - } - } - return 1; + ; + } + } + } + } + return 1; } static int jpc_pi_nextrpcl(register jpc_pi_t *pi) { - int rlvlno; - jpc_pirlvl_t *pirlvl; - jpc_pchg_t *pchg; - int prchind; - int prcvind; - int *prclyrno; - int compno; - jpc_picomp_t *picomp; - int xstep; - int ystep; - uint_fast32_t r; - uint_fast32_t rpx; - uint_fast32_t rpy; - uint_fast32_t trx0; - uint_fast32_t try0; - - pchg = pi->pchg; - if (!pi->prgvolfirst) { - goto skip; - } else { - pi->xstep = 0; - pi->ystep = 0; - for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; - ++compno, ++picomp) { - for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < - picomp->numrlvls; ++rlvlno, ++pirlvl) { - xstep = picomp->hsamp * (1 << (pirlvl->prcwidthexpn + - picomp->numrlvls - rlvlno - 1)); - ystep = picomp->vsamp * (1 << (pirlvl->prcheightexpn + - picomp->numrlvls - rlvlno - 1)); - pi->xstep = (!pi->xstep) ? xstep : JAS_MIN(pi->xstep, xstep); - pi->ystep = (!pi->ystep) ? ystep : JAS_MIN(pi->ystep, ystep); - } - } - pi->prgvolfirst = 0; - } - - for (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pchg->rlvlnoend && - pi->rlvlno < pi->maxrlvls; ++pi->rlvlno) { - for (pi->y = pi->ystart; pi->y < pi->yend; pi->y += - pi->ystep - (pi->y % pi->ystep)) { - for (pi->x = pi->xstart; pi->x < pi->xend; pi->x += - pi->xstep - (pi->x % pi->xstep)) { - for (pi->compno = pchg->compnostart, - pi->picomp = &pi->picomps[pi->compno]; - pi->compno < pchg->compnoend && pi->compno < - pi->numcomps; ++pi->compno, ++pi->picomp) { - if (pi->rlvlno >= pi->picomp->numrlvls) { - continue; - } - pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno]; - if (pi->pirlvl->numprcs == 0) { - continue; - } - r = pi->picomp->numrlvls - 1 - pi->rlvlno; - rpx = r + pi->pirlvl->prcwidthexpn; - rpy = r + pi->pirlvl->prcheightexpn; - trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r); - try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r); - if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) - || !(pi->x % (1 << rpx))) && - ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) - || !(pi->y % (1 << rpy)))) { - prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp - << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0, - pi->pirlvl->prcwidthexpn); - prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp - << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0, - pi->pirlvl->prcheightexpn); - pi->prcno = prcvind * pi->pirlvl->numhprcs + prchind; - - assert(pi->prcno < pi->pirlvl->numprcs); - for (pi->lyrno = 0; pi->lyrno < - pi->numlyrs && pi->lyrno < pchg->lyrnoend; ++pi->lyrno) { - prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; - if (pi->lyrno >= *prclyrno) { - ++(*prclyrno); - return 0; - } + int rlvlno; + jpc_pirlvl_t *pirlvl; + jpc_pchg_t *pchg; + int prchind; + int prcvind; + int *prclyrno; + int compno; + jpc_picomp_t *picomp; + int xstep; + int ystep; + uint_fast32_t r; + uint_fast32_t rpx; + uint_fast32_t rpy; + uint_fast32_t trx0; + uint_fast32_t try0; + + pchg = pi->pchg; + if (!pi->prgvolfirst) { + goto skip; + } else { + pi->xstep = 0; + pi->ystep = 0; + for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; + ++compno, ++picomp) { + for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < + picomp->numrlvls; ++rlvlno, ++pirlvl) { + xstep = picomp->hsamp * (1 << (pirlvl->prcwidthexpn + + picomp->numrlvls - rlvlno - 1)); + ystep = picomp->vsamp * (1 << (pirlvl->prcheightexpn + + picomp->numrlvls - rlvlno - 1)); + pi->xstep = (!pi->xstep) ? xstep : JAS_MIN(pi->xstep, xstep); + pi->ystep = (!pi->ystep) ? ystep : JAS_MIN(pi->ystep, ystep); + } + } + pi->prgvolfirst = 0; + } + + for (pi->rlvlno = pchg->rlvlnostart; pi->rlvlno < pchg->rlvlnoend && + pi->rlvlno < pi->maxrlvls; ++pi->rlvlno) { + for (pi->y = pi->ystart; pi->y < pi->yend; pi->y += + pi->ystep - (pi->y % pi->ystep)) { + for (pi->x = pi->xstart; pi->x < pi->xend; pi->x += + pi->xstep - (pi->x % pi->xstep)) { + for (pi->compno = pchg->compnostart, + pi->picomp = &pi->picomps[pi->compno]; + pi->compno < pchg->compnoend && pi->compno < + pi->numcomps; ++pi->compno, ++pi->picomp) { + if (pi->rlvlno >= pi->picomp->numrlvls) { + continue; + } + pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno]; + if (pi->pirlvl->numprcs == 0) { + continue; + } + r = pi->picomp->numrlvls - 1 - pi->rlvlno; + rpx = r + pi->pirlvl->prcwidthexpn; + rpy = r + pi->pirlvl->prcheightexpn; + trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r); + try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r); + if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) + || !(pi->x % (1 << rpx))) && + ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) + || !(pi->y % (1 << rpy)))) { + prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp + << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0, + pi->pirlvl->prcwidthexpn); + prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp + << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0, + pi->pirlvl->prcheightexpn); + pi->prcno = prcvind * pi->pirlvl->numhprcs + prchind; + + assert(pi->prcno < pi->pirlvl->numprcs); + for (pi->lyrno = 0; pi->lyrno < + pi->numlyrs && pi->lyrno < pchg->lyrnoend; ++pi->lyrno) { + prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; + if (pi->lyrno >= *prclyrno) { + ++(*prclyrno); + return 0; + } skip: - ; - } - } - } - } - } - } - return 1; + ; + } + } + } + } + } + } + return 1; } static int jpc_pi_nextpcrl(register jpc_pi_t *pi) { - int rlvlno; - jpc_pirlvl_t *pirlvl; - jpc_pchg_t *pchg; - int prchind; - int prcvind; - int *prclyrno; - int compno; - jpc_picomp_t *picomp; - int xstep; - int ystep; - uint_fast32_t trx0; - uint_fast32_t try0; - uint_fast32_t r; - uint_fast32_t rpx; - uint_fast32_t rpy; - - pchg = pi->pchg; - if (!pi->prgvolfirst) { - goto skip; - } else { - pi->xstep = 0; - pi->ystep = 0; - for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; - ++compno, ++picomp) { - for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < - picomp->numrlvls; ++rlvlno, ++pirlvl) { - xstep = picomp->hsamp * (1 << - (pirlvl->prcwidthexpn + picomp->numrlvls - - rlvlno - 1)); - ystep = picomp->vsamp * (1 << - (pirlvl->prcheightexpn + picomp->numrlvls - - rlvlno - 1)); - pi->xstep = (!pi->xstep) ? xstep : - JAS_MIN(pi->xstep, xstep); - pi->ystep = (!pi->ystep) ? ystep : - JAS_MIN(pi->ystep, ystep); - } - } - pi->prgvolfirst = 0; - } - - for (pi->y = pi->ystart; pi->y < pi->yend; pi->y += pi->ystep - - (pi->y % pi->ystep)) { - for (pi->x = pi->xstart; pi->x < pi->xend; pi->x += pi->xstep - - (pi->x % pi->xstep)) { - for (pi->compno = pchg->compnostart, pi->picomp = - &pi->picomps[pi->compno]; pi->compno < pi->numcomps - && pi->compno < pchg->compnoend; ++pi->compno, - ++pi->picomp) { - for (pi->rlvlno = pchg->rlvlnostart, - pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno]; - pi->rlvlno < pi->picomp->numrlvls && - pi->rlvlno < pchg->rlvlnoend; ++pi->rlvlno, - ++pi->pirlvl) { - if (pi->pirlvl->numprcs == 0) { - continue; - } - r = pi->picomp->numrlvls - 1 - pi->rlvlno; - trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r); - try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r); - rpx = r + pi->pirlvl->prcwidthexpn; - rpy = r + pi->pirlvl->prcheightexpn; - if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) || - !(pi->x % (pi->picomp->hsamp << rpx))) && - ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) || - !(pi->y % (pi->picomp->vsamp << rpy)))) { - prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp - << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0, - pi->pirlvl->prcwidthexpn); - prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp - << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0, - pi->pirlvl->prcheightexpn); - pi->prcno = prcvind * pi->pirlvl->numhprcs + prchind; - assert(pi->prcno < pi->pirlvl->numprcs); - for (pi->lyrno = 0; pi->lyrno < pi->numlyrs && - pi->lyrno < pchg->lyrnoend; ++pi->lyrno) { - prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; - if (pi->lyrno >= *prclyrno) { - ++(*prclyrno); - return 0; - } + int rlvlno; + jpc_pirlvl_t *pirlvl; + jpc_pchg_t *pchg; + int prchind; + int prcvind; + int *prclyrno; + int compno; + jpc_picomp_t *picomp; + int xstep; + int ystep; + uint_fast32_t trx0; + uint_fast32_t try0; + uint_fast32_t r; + uint_fast32_t rpx; + uint_fast32_t rpy; + + pchg = pi->pchg; + if (!pi->prgvolfirst) { + goto skip; + } else { + pi->xstep = 0; + pi->ystep = 0; + for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; + ++compno, ++picomp) { + for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < + picomp->numrlvls; ++rlvlno, ++pirlvl) { + xstep = picomp->hsamp * (1 << + (pirlvl->prcwidthexpn + picomp->numrlvls - + rlvlno - 1)); + ystep = picomp->vsamp * (1 << + (pirlvl->prcheightexpn + picomp->numrlvls - + rlvlno - 1)); + pi->xstep = (!pi->xstep) ? xstep : + JAS_MIN(pi->xstep, xstep); + pi->ystep = (!pi->ystep) ? ystep : + JAS_MIN(pi->ystep, ystep); + } + } + pi->prgvolfirst = 0; + } + + for (pi->y = pi->ystart; pi->y < pi->yend; pi->y += pi->ystep - + (pi->y % pi->ystep)) { + for (pi->x = pi->xstart; pi->x < pi->xend; pi->x += pi->xstep - + (pi->x % pi->xstep)) { + for (pi->compno = pchg->compnostart, pi->picomp = + &pi->picomps[pi->compno]; pi->compno < pi->numcomps + && pi->compno < pchg->compnoend; ++pi->compno, + ++pi->picomp) { + for (pi->rlvlno = pchg->rlvlnostart, + pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno]; + pi->rlvlno < pi->picomp->numrlvls && + pi->rlvlno < pchg->rlvlnoend; ++pi->rlvlno, + ++pi->pirlvl) { + if (pi->pirlvl->numprcs == 0) { + continue; + } + r = pi->picomp->numrlvls - 1 - pi->rlvlno; + trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r); + try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r); + rpx = r + pi->pirlvl->prcwidthexpn; + rpy = r + pi->pirlvl->prcheightexpn; + if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) || + !(pi->x % (pi->picomp->hsamp << rpx))) && + ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) || + !(pi->y % (pi->picomp->vsamp << rpy)))) { + prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp + << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0, + pi->pirlvl->prcwidthexpn); + prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp + << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0, + pi->pirlvl->prcheightexpn); + pi->prcno = prcvind * pi->pirlvl->numhprcs + prchind; + assert(pi->prcno < pi->pirlvl->numprcs); + for (pi->lyrno = 0; pi->lyrno < pi->numlyrs && + pi->lyrno < pchg->lyrnoend; ++pi->lyrno) { + prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; + if (pi->lyrno >= *prclyrno) { + ++(*prclyrno); + return 0; + } skip: - ; - } - } - } - } - } - } - return 1; + ; + } + } + } + } + } + } + return 1; } static int jpc_pi_nextcprl(register jpc_pi_t *pi) { - int rlvlno; - jpc_pirlvl_t *pirlvl; - jpc_pchg_t *pchg; - int prchind; - int prcvind; - int *prclyrno; - uint_fast32_t trx0; - uint_fast32_t try0; - uint_fast32_t r; - uint_fast32_t rpx; - uint_fast32_t rpy; - - pchg = pi->pchg; - if (!pi->prgvolfirst) { - goto skip; - } else { - pi->prgvolfirst = 0; - } - - for (pi->compno = pchg->compnostart, pi->picomp = - &pi->picomps[pi->compno]; pi->compno < pchg->compnoend; ++pi->compno, - ++pi->picomp) { - pirlvl = pi->picomp->pirlvls; - pi->xstep = pi->picomp->hsamp * (1 << (pirlvl->prcwidthexpn + - pi->picomp->numrlvls - 1)); - pi->ystep = pi->picomp->vsamp * (1 << (pirlvl->prcheightexpn + - pi->picomp->numrlvls - 1)); - for (rlvlno = 1, pirlvl = &pi->picomp->pirlvls[1]; - rlvlno < pi->picomp->numrlvls; ++rlvlno, ++pirlvl) { - pi->xstep = JAS_MIN(pi->xstep, pi->picomp->hsamp * (1 << - (pirlvl->prcwidthexpn + pi->picomp->numrlvls - - rlvlno - 1))); - pi->ystep = JAS_MIN(pi->ystep, pi->picomp->vsamp * (1 << - (pirlvl->prcheightexpn + pi->picomp->numrlvls - - rlvlno - 1))); - } - for (pi->y = pi->ystart; pi->y < pi->yend; - pi->y += pi->ystep - (pi->y % pi->ystep)) { - for (pi->x = pi->xstart; pi->x < pi->xend; - pi->x += pi->xstep - (pi->x % pi->xstep)) { - for (pi->rlvlno = pchg->rlvlnostart, - pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno]; - pi->rlvlno < pi->picomp->numrlvls && pi->rlvlno < - pchg->rlvlnoend; ++pi->rlvlno, ++pi->pirlvl) { - if (pi->pirlvl->numprcs == 0) { - continue; - } - r = pi->picomp->numrlvls - 1 - pi->rlvlno; - trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r); - try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r); - rpx = r + pi->pirlvl->prcwidthexpn; - rpy = r + pi->pirlvl->prcheightexpn; - if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) || - !(pi->x % (pi->picomp->hsamp << rpx))) && - ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) || - !(pi->y % (pi->picomp->vsamp << rpy)))) { - prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp - << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0, - pi->pirlvl->prcwidthexpn); - prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp - << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0, - pi->pirlvl->prcheightexpn); - pi->prcno = prcvind * - pi->pirlvl->numhprcs + - prchind; - assert(pi->prcno < - pi->pirlvl->numprcs); - for (pi->lyrno = 0; pi->lyrno < - pi->numlyrs && pi->lyrno < pchg->lyrnoend; ++pi->lyrno) { - prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; - if (pi->lyrno >= *prclyrno) { - ++(*prclyrno); - return 0; - } + int rlvlno; + jpc_pirlvl_t *pirlvl; + jpc_pchg_t *pchg; + int prchind; + int prcvind; + int *prclyrno; + uint_fast32_t trx0; + uint_fast32_t try0; + uint_fast32_t r; + uint_fast32_t rpx; + uint_fast32_t rpy; + + pchg = pi->pchg; + if (!pi->prgvolfirst) { + goto skip; + } else { + pi->prgvolfirst = 0; + } + + for (pi->compno = pchg->compnostart, pi->picomp = + &pi->picomps[pi->compno]; pi->compno < pchg->compnoend; ++pi->compno, + ++pi->picomp) { + pirlvl = pi->picomp->pirlvls; + pi->xstep = pi->picomp->hsamp * (1 << (pirlvl->prcwidthexpn + + pi->picomp->numrlvls - 1)); + pi->ystep = pi->picomp->vsamp * (1 << (pirlvl->prcheightexpn + + pi->picomp->numrlvls - 1)); + for (rlvlno = 1, pirlvl = &pi->picomp->pirlvls[1]; + rlvlno < pi->picomp->numrlvls; ++rlvlno, ++pirlvl) { + pi->xstep = JAS_MIN(pi->xstep, pi->picomp->hsamp * (1 << + (pirlvl->prcwidthexpn + pi->picomp->numrlvls - + rlvlno - 1))); + pi->ystep = JAS_MIN(pi->ystep, pi->picomp->vsamp * (1 << + (pirlvl->prcheightexpn + pi->picomp->numrlvls - + rlvlno - 1))); + } + for (pi->y = pi->ystart; pi->y < pi->yend; + pi->y += pi->ystep - (pi->y % pi->ystep)) { + for (pi->x = pi->xstart; pi->x < pi->xend; + pi->x += pi->xstep - (pi->x % pi->xstep)) { + for (pi->rlvlno = pchg->rlvlnostart, + pi->pirlvl = &pi->picomp->pirlvls[pi->rlvlno]; + pi->rlvlno < pi->picomp->numrlvls && pi->rlvlno < + pchg->rlvlnoend; ++pi->rlvlno, ++pi->pirlvl) { + if (pi->pirlvl->numprcs == 0) { + continue; + } + r = pi->picomp->numrlvls - 1 - pi->rlvlno; + trx0 = JPC_CEILDIV(pi->xstart, pi->picomp->hsamp << r); + try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r); + rpx = r + pi->pirlvl->prcwidthexpn; + rpy = r + pi->pirlvl->prcheightexpn; + if (((pi->x == pi->xstart && ((trx0 << r) % (1 << rpx))) || + !(pi->x % (pi->picomp->hsamp << rpx))) && + ((pi->y == pi->ystart && ((try0 << r) % (1 << rpy))) || + !(pi->y % (pi->picomp->vsamp << rpy)))) { + prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x, pi->picomp->hsamp + << r), pi->pirlvl->prcwidthexpn) - JPC_FLOORDIVPOW2(trx0, + pi->pirlvl->prcwidthexpn); + prcvind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->y, pi->picomp->vsamp + << r), pi->pirlvl->prcheightexpn) - JPC_FLOORDIVPOW2(try0, + pi->pirlvl->prcheightexpn); + pi->prcno = prcvind * + pi->pirlvl->numhprcs + + prchind; + assert(pi->prcno < + pi->pirlvl->numprcs); + for (pi->lyrno = 0; pi->lyrno < + pi->numlyrs && pi->lyrno < pchg->lyrnoend; ++pi->lyrno) { + prclyrno = &pi->pirlvl->prclyrnos[pi->prcno]; + if (pi->lyrno >= *prclyrno) { + ++(*prclyrno); + return 0; + } skip: - ; - } - } - } - } - } - } - return 1; + ; + } + } + } + } + } + } + return 1; } static void pirlvl_destroy(jpc_pirlvl_t *rlvl) { - if (rlvl->prclyrnos) { - jas_free(rlvl->prclyrnos); - } + if (rlvl->prclyrnos) { + jas_free(rlvl->prclyrnos); + } } static void jpc_picomp_destroy(jpc_picomp_t *picomp) { - int rlvlno; - jpc_pirlvl_t *pirlvl; - if (picomp->pirlvls) { - for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < - picomp->numrlvls; ++rlvlno, ++pirlvl) { - pirlvl_destroy(pirlvl); - } - jas_free(picomp->pirlvls); - } + int rlvlno; + jpc_pirlvl_t *pirlvl; + if (picomp->pirlvls) { + for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < + picomp->numrlvls; ++rlvlno, ++pirlvl) { + pirlvl_destroy(pirlvl); + } + jas_free(picomp->pirlvls); + } } void jpc_pi_destroy(jpc_pi_t *pi) { - jpc_picomp_t *picomp; - int compno; - if (pi->picomps) { - for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; - ++compno, ++picomp) { - jpc_picomp_destroy(picomp); - } - jas_free(pi->picomps); - } - if (pi->pchglist) { - jpc_pchglist_destroy(pi->pchglist); - } - jas_free(pi); + jpc_picomp_t *picomp; + int compno; + if (pi->picomps) { + for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; + ++compno, ++picomp) { + jpc_picomp_destroy(picomp); + } + jas_free(pi->picomps); + } + if (pi->pchglist) { + jpc_pchglist_destroy(pi->pchglist); + } + jas_free(pi); } jpc_pi_t *jpc_pi_create0(void) { - jpc_pi_t *pi; - if (!(pi = jas_malloc(sizeof(jpc_pi_t)))) { - return 0; - } - pi->picomps = 0; - pi->pchgno = 0; - if (!(pi->pchglist = jpc_pchglist_create())) { - jas_free(pi); - return 0; - } - return pi; + jpc_pi_t *pi; + if (!(pi = jas_malloc(sizeof(jpc_pi_t)))) { + return 0; + } + pi->picomps = 0; + pi->pchgno = 0; + if (!(pi->pchglist = jpc_pchglist_create())) { + jas_free(pi); + return 0; + } + return pi; } int jpc_pi_addpchg(jpc_pi_t *pi, jpc_pocpchg_t *pchg) { - return jpc_pchglist_insert(pi->pchglist, -1, pchg); + return jpc_pchglist_insert(pi->pchglist, -1, pchg); } jpc_pchglist_t *jpc_pchglist_create(void) { - jpc_pchglist_t *pchglist; - if (!(pchglist = jas_malloc(sizeof(jpc_pchglist_t)))) { - return 0; - } - pchglist->numpchgs = 0; - pchglist->maxpchgs = 0; - pchglist->pchgs = 0; - return pchglist; + jpc_pchglist_t *pchglist; + if (!(pchglist = jas_malloc(sizeof(jpc_pchglist_t)))) { + return 0; + } + pchglist->numpchgs = 0; + pchglist->maxpchgs = 0; + pchglist->pchgs = 0; + return pchglist; } int jpc_pchglist_insert(jpc_pchglist_t *pchglist, int pchgno, jpc_pchg_t *pchg) { - int i; - int newmaxpchgs; - jpc_pchg_t **newpchgs; - if (pchgno < 0) { - pchgno = pchglist->numpchgs; - } - if (pchglist->numpchgs >= pchglist->maxpchgs) { - newmaxpchgs = pchglist->maxpchgs + 128; - if (!(newpchgs = jas_realloc(pchglist->pchgs, newmaxpchgs * sizeof(jpc_pchg_t *)))) { - return -1; - } - pchglist->maxpchgs = newmaxpchgs; - pchglist->pchgs = newpchgs; - } - for (i = pchglist->numpchgs; i > pchgno; --i) { - pchglist->pchgs[i] = pchglist->pchgs[i - 1]; - } - pchglist->pchgs[pchgno] = pchg; - ++pchglist->numpchgs; - return 0; + int i; + int newmaxpchgs; + jpc_pchg_t **newpchgs; + if (pchgno < 0) { + pchgno = pchglist->numpchgs; + } + if (pchglist->numpchgs >= pchglist->maxpchgs) { + newmaxpchgs = pchglist->maxpchgs + 128; + if (!(newpchgs = jas_realloc(pchglist->pchgs, newmaxpchgs * sizeof(jpc_pchg_t *)))) { + return -1; + } + pchglist->maxpchgs = newmaxpchgs; + pchglist->pchgs = newpchgs; + } + for (i = pchglist->numpchgs; i > pchgno; --i) { + pchglist->pchgs[i] = pchglist->pchgs[i - 1]; + } + pchglist->pchgs[pchgno] = pchg; + ++pchglist->numpchgs; + return 0; } jpc_pchg_t *jpc_pchglist_remove(jpc_pchglist_t *pchglist, int pchgno) { - int i; - jpc_pchg_t *pchg; - assert(pchgno < pchglist->numpchgs); - pchg = pchglist->pchgs[pchgno]; - for (i = pchgno + 1; i < pchglist->numpchgs; ++i) { - pchglist->pchgs[i - 1] = pchglist->pchgs[i]; - } - --pchglist->numpchgs; - return pchg; + int i; + jpc_pchg_t *pchg; + assert(pchgno < pchglist->numpchgs); + pchg = pchglist->pchgs[pchgno]; + for (i = pchgno + 1; i < pchglist->numpchgs; ++i) { + pchglist->pchgs[i - 1] = pchglist->pchgs[i]; + } + --pchglist->numpchgs; + return pchg; } jpc_pchg_t *jpc_pchg_copy(jpc_pchg_t *pchg) { - jpc_pchg_t *newpchg; - if (!(newpchg = jas_malloc(sizeof(jpc_pchg_t)))) { - return 0; - } - *newpchg = *pchg; - return newpchg; + jpc_pchg_t *newpchg; + if (!(newpchg = jas_malloc(sizeof(jpc_pchg_t)))) { + return 0; + } + *newpchg = *pchg; + return newpchg; } jpc_pchglist_t *jpc_pchglist_copy(jpc_pchglist_t *pchglist) { - jpc_pchglist_t *newpchglist; - jpc_pchg_t *newpchg; - int pchgno; - if (!(newpchglist = jpc_pchglist_create())) { - return 0; - } - for (pchgno = 0; pchgno < pchglist->numpchgs; ++pchgno) { - if (!(newpchg = jpc_pchg_copy(pchglist->pchgs[pchgno])) || - jpc_pchglist_insert(newpchglist, -1, newpchg)) { - jpc_pchglist_destroy(newpchglist); - return 0; - } - } - return newpchglist; + jpc_pchglist_t *newpchglist; + jpc_pchg_t *newpchg; + int pchgno; + if (!(newpchglist = jpc_pchglist_create())) { + return 0; + } + for (pchgno = 0; pchgno < pchglist->numpchgs; ++pchgno) { + if (!(newpchg = jpc_pchg_copy(pchglist->pchgs[pchgno])) || + jpc_pchglist_insert(newpchglist, -1, newpchg)) { + jpc_pchglist_destroy(newpchglist); + return 0; + } + } + return newpchglist; } void jpc_pchglist_destroy(jpc_pchglist_t *pchglist) { - int pchgno; - if (pchglist->pchgs) { - for (pchgno = 0; pchgno < pchglist->numpchgs; ++pchgno) { - jpc_pchg_destroy(pchglist->pchgs[pchgno]); - } - jas_free(pchglist->pchgs); - } - jas_free(pchglist); + int pchgno; + if (pchglist->pchgs) { + for (pchgno = 0; pchgno < pchglist->numpchgs; ++pchgno) { + jpc_pchg_destroy(pchglist->pchgs[pchgno]); + } + jas_free(pchglist->pchgs); + } + jas_free(pchglist); } void jpc_pchg_destroy(jpc_pchg_t *pchg) { - jas_free(pchg); + jas_free(pchg); } jpc_pchg_t *jpc_pchglist_get(jpc_pchglist_t *pchglist, int pchgno) { - return pchglist->pchgs[pchgno]; + return pchglist->pchgs[pchgno]; } int jpc_pchglist_numpchgs(jpc_pchglist_t *pchglist) { - return pchglist->numpchgs; + return pchglist->numpchgs; } int jpc_pi_init(jpc_pi_t *pi) { - int compno; - int rlvlno; - int prcno; - jpc_picomp_t *picomp; - jpc_pirlvl_t *pirlvl; - int *prclyrno; - - pi->prgvolfirst = 0; - pi->valid = 0; - pi->pktno = -1; - pi->pchgno = -1; - pi->pchg = 0; - - for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; - ++compno, ++picomp) { - for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < - picomp->numrlvls; ++rlvlno, ++pirlvl) { - for (prcno = 0, prclyrno = pirlvl->prclyrnos; - prcno < pirlvl->numprcs; ++prcno, ++prclyrno) { - *prclyrno = 0; - } - } - } - return 0; + int compno; + int rlvlno; + int prcno; + jpc_picomp_t *picomp; + jpc_pirlvl_t *pirlvl; + int *prclyrno; + + pi->prgvolfirst = 0; + pi->valid = 0; + pi->pktno = -1; + pi->pchgno = -1; + pi->pchg = 0; + + for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; + ++compno, ++picomp) { + for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < + picomp->numrlvls; ++rlvlno, ++pirlvl) { + for (prcno = 0, prclyrno = pirlvl->prclyrnos; + prcno < pirlvl->numprcs; ++prcno, ++prclyrno) { + *prclyrno = 0; + } + } + } + return 0; } diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.h b/converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.h index 82dafcce..8e9b6b15 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t2cod.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -117,7 +117,7 @@ */ #ifndef JPC_T2COD_H -#define JPC_T2COD_H +#define JPC_T2COD_H /******************************************************************************\ * Includes. @@ -133,15 +133,15 @@ typedef struct { - /* The number of progression changes. */ - int numpchgs; + /* The number of progression changes. */ + int numpchgs; - /* The maximum number of progression changes that can be accommodated - without growing the progression change array. */ - int maxpchgs; + /* The maximum number of progression changes that can be accommodated + without growing the progression change array. */ + int maxpchgs; - /* The progression changes. */ - jpc_pchg_t **pchgs; + /* The progression changes. */ + jpc_pchg_t **pchgs; } jpc_pchglist_t; @@ -149,21 +149,21 @@ typedef struct { typedef struct { - /* The number of precincts. */ - int numprcs; + /* The number of precincts. */ + int numprcs; - /* The last layer processed for each precinct. */ - int *prclyrnos; + /* The last layer processed for each precinct. */ + int *prclyrnos; - /* The precinct width exponent. */ - int prcwidthexpn; + /* The precinct width exponent. */ + int prcwidthexpn; - /* The precinct height exponent. */ - int prcheightexpn; + /* The precinct height exponent. */ + int prcheightexpn; - /* The number of precincts spanning the resolution level in the horizontal - direction. */ - int numhprcs; + /* The number of precincts spanning the resolution level in the horizontal + direction. */ + int numhprcs; } jpc_pirlvl_t; @@ -171,17 +171,17 @@ typedef struct { typedef struct { - /* The number of resolution levels. */ - int numrlvls; + /* The number of resolution levels. */ + int numrlvls; - /* The per-resolution-level information. */ - jpc_pirlvl_t *pirlvls; + /* The per-resolution-level information. */ + jpc_pirlvl_t *pirlvls; - /* The horizontal sampling period. */ - int hsamp; + /* The horizontal sampling period. */ + int hsamp; - /* The vertical sampling period. */ - int vsamp; + /* The vertical sampling period. */ + int vsamp; } jpc_picomp_t; @@ -189,84 +189,84 @@ typedef struct { typedef struct { - /* The number of layers. */ - int numlyrs; + /* The number of layers. */ + int numlyrs; - /* The number of resolution levels. */ - int maxrlvls; + /* The number of resolution levels. */ + int maxrlvls; - /* The number of components. */ - int numcomps; + /* The number of components. */ + int numcomps; - /* The per-component information. */ - jpc_picomp_t *picomps; + /* The per-component information. */ + jpc_picomp_t *picomps; - /* The current component. */ - jpc_picomp_t *picomp; + /* The current component. */ + jpc_picomp_t *picomp; - /* The current resolution level. */ - jpc_pirlvl_t *pirlvl; + /* The current resolution level. */ + jpc_pirlvl_t *pirlvl; - /* The number of the current component. */ - int compno; + /* The number of the current component. */ + int compno; - /* The number of the current resolution level. */ - int rlvlno; + /* The number of the current resolution level. */ + int rlvlno; - /* The number of the current precinct. */ - int prcno; + /* The number of the current precinct. */ + int prcno; - /* The number of the current layer. */ - int lyrno; + /* The number of the current layer. */ + int lyrno; - /* The x-coordinate of the current position. */ - int x; + /* The x-coordinate of the current position. */ + int x; - /* The y-coordinate of the current position. */ - int y; + /* The y-coordinate of the current position. */ + int y; - /* The horizontal step size. */ - int xstep; + /* The horizontal step size. */ + int xstep; - /* The vertical step size. */ - int ystep; + /* The vertical step size. */ + int ystep; - /* The x-coordinate of the top-left corner of the tile on the reference - grid. */ - int xstart; + /* The x-coordinate of the top-left corner of the tile on the reference + grid. */ + int xstart; - /* The y-coordinate of the top-left corner of the tile on the reference - grid. */ - int ystart; + /* The y-coordinate of the top-left corner of the tile on the reference + grid. */ + int ystart; - /* The x-coordinate of the bottom-right corner of the tile on the - reference grid (plus one). */ - int xend; + /* The x-coordinate of the bottom-right corner of the tile on the + reference grid (plus one). */ + int xend; - /* The y-coordinate of the bottom-right corner of the tile on the - reference grid (plus one). */ - int yend; + /* The y-coordinate of the bottom-right corner of the tile on the + reference grid (plus one). */ + int yend; - /* The current progression change. */ - jpc_pchg_t *pchg; + /* The current progression change. */ + jpc_pchg_t *pchg; - /* The progression change list. */ - jpc_pchglist_t *pchglist; + /* The progression change list. */ + jpc_pchglist_t *pchglist; - /* The progression to use in the absence of explicit specification. */ - jpc_pchg_t defaultpchg; + /* The progression to use in the absence of explicit specification. */ + jpc_pchg_t defaultpchg; - /* The current progression change number. */ - int pchgno; + /* The current progression change number. */ + int pchgno; - /* Is this the first time in the current progression volume? */ - bool prgvolfirst; + /* Is this the first time in the current progression volume? */ + bool prgvolfirst; - /* Is the current iterator value valid? */ - bool valid; + /* Is the current iterator value valid? */ + bool valid; - /* The current packet number. */ - int pktno; + /* The current packet number. */ + int pktno; } jpc_pi_t; @@ -293,22 +293,22 @@ int jpc_pi_begin(jpc_pi_t *pi); int jpc_pi_next(jpc_pi_t *pi); /* Get the index of the current packet. */ -#define jpc_pi_getind(pi) ((pi)->pktno) +#define jpc_pi_getind(pi) ((pi)->pktno) /* Get the component number of the current packet. */ -#define jpc_pi_cmptno(pi) (assert(pi->valid), (pi)->compno) +#define jpc_pi_cmptno(pi) (assert(pi->valid), (pi)->compno) /* Get the resolution level of the current packet. */ -#define jpc_pi_rlvlno(pi) (assert(pi->valid), (pi)->rlvlno) +#define jpc_pi_rlvlno(pi) (assert(pi->valid), (pi)->rlvlno) /* Get the layer number of the current packet. */ -#define jpc_pi_lyrno(pi) (assert(pi->valid), (pi)->lyrno) +#define jpc_pi_lyrno(pi) (assert(pi->valid), (pi)->lyrno) /* Get the precinct number of the current packet. */ -#define jpc_pi_prcno(pi) (assert(pi->valid), (pi)->prcno) +#define jpc_pi_prcno(pi) (assert(pi->valid), (pi)->prcno) /* Get the progression order for the current packet. */ -#define jpc_pi_prg(pi) (assert(pi->valid), (pi)->pchg->prgord) +#define jpc_pi_prg(pi) (assert(pi->valid), (pi)->pchg->prgord) /******************************************************************************\ * Functions/macros for progression change lists. diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.c index 9aaaa55c..a05e1c10 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -155,305 +155,305 @@ static int jpc_dec_decodepkt(jpc_dec_t *dec, jas_stream_t *pkthdrstream, jas_str static int jpc_getcommacode(jpc_bitstream_t *in) { - int n; - int v; - - n = 0; - for (;;) { - if ((v = jpc_bitstream_getbit(in)) < 0) { - return -1; - } - if (jpc_bitstream_eof(in)) { - return -1; - } - if (!v) { - break; - } - ++n; - } - - return n; + int n; + int v; + + n = 0; + for (;;) { + if ((v = jpc_bitstream_getbit(in)) < 0) { + return -1; + } + if (jpc_bitstream_eof(in)) { + return -1; + } + if (!v) { + break; + } + ++n; + } + + return n; } static int jpc_getnumnewpasses(jpc_bitstream_t *in) { - int n; - - if ((n = jpc_bitstream_getbit(in)) > 0) { - if ((n = jpc_bitstream_getbit(in)) > 0) { - if ((n = jpc_bitstream_getbits(in, 2)) == 3) { - if ((n = jpc_bitstream_getbits(in, 5)) == 31) { - if ((n = jpc_bitstream_getbits(in, 7)) >= 0) { - n += 36 + 1; - } - } else if (n >= 0) { - n += 5 + 1; - } - } else if (n >= 0) { - n += 2 + 1; - } - } else if (!n) { - n += 2; - } - } else if (!n) { - ++n; - } - - return n; + int n; + + if ((n = jpc_bitstream_getbit(in)) > 0) { + if ((n = jpc_bitstream_getbit(in)) > 0) { + if ((n = jpc_bitstream_getbits(in, 2)) == 3) { + if ((n = jpc_bitstream_getbits(in, 5)) == 31) { + if ((n = jpc_bitstream_getbits(in, 7)) >= 0) { + n += 36 + 1; + } + } else if (n >= 0) { + n += 5 + 1; + } + } else if (n >= 0) { + n += 2 + 1; + } + } else if (!n) { + n += 2; + } + } else if (!n) { + ++n; + } + + return n; } static int jpc_dec_decodepkt(jpc_dec_t *dec, jas_stream_t *pkthdrstream, jas_stream_t *in, int compno, int rlvlno, int prcno, int lyrno) { - jpc_bitstream_t *inb; - jpc_dec_tcomp_t *tcomp; - jpc_dec_rlvl_t *rlvl; - jpc_dec_band_t *band; - jpc_dec_cblk_t *cblk; - int n; - int m; - int i; - jpc_tagtreenode_t *leaf; - int included; - int ret; - int numnewpasses; - jpc_dec_seg_t *seg; - int len; - int present; - int savenumnewpasses; - int mycounter; - jpc_ms_t *ms; - jpc_dec_tile_t *tile; - jpc_dec_ccp_t *ccp; - jpc_dec_cp_t *cp; - int bandno; - jpc_dec_prc_t *prc; - int usedcblkcnt; - int cblkno; - uint_fast32_t bodylen; - bool discard; - int passno; - int maxpasses; - int hdrlen; - int hdroffstart; - int hdroffend; - - discard = (lyrno >= dec->maxlyrs); - - tile = dec->curtile; - cp = tile->cp; - ccp = &cp->ccps[compno]; - - /* - * Decode the packet header. - */ - - /* Decode the SOP marker segment if present. */ - if (cp->csty & JPC_COD_SOP) { - if (jpc_dec_lookahead(in) == JPC_MS_SOP) { - if (!(ms = jpc_getms(in, dec->cstate))) { - return -1; - } - if (jpc_ms_gettype(ms) != JPC_MS_SOP) { - jpc_ms_destroy(ms); - fprintf(stderr, "missing SOP marker segment\n"); - return -1; - } - jpc_ms_destroy(ms); - } - } + jpc_bitstream_t *inb; + jpc_dec_tcomp_t *tcomp; + jpc_dec_rlvl_t *rlvl; + jpc_dec_band_t *band; + jpc_dec_cblk_t *cblk; + int n; + int m; + int i; + jpc_tagtreenode_t *leaf; + int included; + int ret; + int numnewpasses; + jpc_dec_seg_t *seg; + int len; + int present; + int savenumnewpasses; + int mycounter; + jpc_ms_t *ms; + jpc_dec_tile_t *tile; + jpc_dec_ccp_t *ccp; + jpc_dec_cp_t *cp; + int bandno; + jpc_dec_prc_t *prc; + int usedcblkcnt; + int cblkno; + uint_fast32_t bodylen; + bool discard; + int passno; + int maxpasses; + int hdrlen; + int hdroffstart; + int hdroffend; + + discard = (lyrno >= dec->maxlyrs); + + tile = dec->curtile; + cp = tile->cp; + ccp = &cp->ccps[compno]; + + /* + * Decode the packet header. + */ + + /* Decode the SOP marker segment if present. */ + if (cp->csty & JPC_COD_SOP) { + if (jpc_dec_lookahead(in) == JPC_MS_SOP) { + if (!(ms = jpc_getms(in, dec->cstate))) { + return -1; + } + if (jpc_ms_gettype(ms) != JPC_MS_SOP) { + jpc_ms_destroy(ms); + fprintf(stderr, "missing SOP marker segment\n"); + return -1; + } + jpc_ms_destroy(ms); + } + } hdroffstart = jas_stream_getrwcount(pkthdrstream); - if (!(inb = jpc_bitstream_sopen(pkthdrstream, "r"))) { - return -1; - } - - if ((present = jpc_bitstream_getbit(inb)) < 0) { - return 1; - } - JAS_DBGLOG(10, ("\n", present)); - JAS_DBGLOG(10, ("present=%d ", present)); - - /* Is the packet non-empty? */ - if (present) { - /* The packet is non-empty. */ - tcomp = &tile->tcomps[compno]; - rlvl = &tcomp->rlvls[rlvlno]; - bodylen = 0; - for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands; - ++bandno, ++band) { - if (!band->data) { - continue; - } - prc = &band->prcs[prcno]; - if (!prc->cblks) { - continue; - } - usedcblkcnt = 0; - for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks; - ++cblkno, ++cblk) { - ++usedcblkcnt; - if (!cblk->numpasses) { - leaf = jpc_tagtree_getleaf(prc->incltagtree, usedcblkcnt - 1); - if ((included = jpc_tagtree_decode(prc->incltagtree, leaf, lyrno + 1, inb)) < 0) { - return -1; - } - } else { - if ((included = jpc_bitstream_getbit(inb)) < 0) { - return -1; - } - } - JAS_DBGLOG(10, ("\n")); - JAS_DBGLOG(10, ("included=%d ", included)); - if (!included) { - continue; - } - if (!cblk->numpasses) { - i = 1; - leaf = jpc_tagtree_getleaf(prc->numimsbstagtree, usedcblkcnt - 1); - for (;;) { - if ((ret = jpc_tagtree_decode(prc->numimsbstagtree, leaf, i, inb)) < 0) { - return -1; - } - if (ret) { - break; - } - ++i; - } - cblk->numimsbs = i - 1; - cblk->firstpassno = cblk->numimsbs * 3; - } - if ((numnewpasses = jpc_getnumnewpasses(inb)) < 0) { - return -1; - } - JAS_DBGLOG(10, ("numnewpasses=%d ", numnewpasses)); - seg = cblk->curseg; - savenumnewpasses = numnewpasses; - mycounter = 0; - if (numnewpasses > 0) { - if ((m = jpc_getcommacode(inb)) < 0) { - return -1; - } - cblk->numlenbits += m; - JAS_DBGLOG(10, ("increment=%d ", m)); - while (numnewpasses > 0) { - passno = cblk->firstpassno + cblk->numpasses + mycounter; - /* XXX - the maxpasses is not set precisely but this doesn't matter... */ - maxpasses = JPC_SEGPASSCNT(passno, cblk->firstpassno, 10000, (ccp->cblkctx & JPC_COX_LAZY) != 0, (ccp->cblkctx & JPC_COX_TERMALL) != 0); - if (!discard && !seg) { - if (!(seg = jpc_seg_alloc())) { - return -1; - } - jpc_seglist_insert(&cblk->segs, cblk->segs.tail, seg); - if (!cblk->curseg) { - cblk->curseg = seg; - } - seg->passno = passno; - seg->type = JPC_SEGTYPE(seg->passno, cblk->firstpassno, (ccp->cblkctx & JPC_COX_LAZY) != 0); - seg->maxpasses = maxpasses; - } - n = JAS_MIN(numnewpasses, maxpasses); - mycounter += n; - numnewpasses -= n; - if ((len = jpc_bitstream_getbits(inb, cblk->numlenbits + jpc_floorlog2(n))) < 0) { - return -1; - } - JAS_DBGLOG(10, ("len=%d ", len)); - if (!discard) { - seg->lyrno = lyrno; - seg->numpasses += n; - seg->cnt = len; - seg = seg->next; - } - bodylen += len; - } - } - cblk->numpasses += savenumnewpasses; - } - } - - jpc_bitstream_inalign(inb, 0, 0); - - } else { - if (jpc_bitstream_inalign(inb, 0x7f, 0)) { - fprintf(stderr, "alignment failed\n"); - return -1; - } - } - jpc_bitstream_close(inb); - - hdroffend = jas_stream_getrwcount(pkthdrstream); - hdrlen = hdroffend - hdroffstart; - if (jas_getdbglevel() >= 5) { - fprintf(stderr, "hdrlen=%lu bodylen=%lu \n", (unsigned long) hdrlen, - (unsigned long) bodylen); - } - - if (cp->csty & JPC_COD_EPH) { - if (jpc_dec_lookahead(pkthdrstream) == JPC_MS_EPH) { - if (!(ms = jpc_getms(pkthdrstream, dec->cstate))) { - fprintf(stderr, "cannot get (EPH) marker segment\n"); - return -1; - } - if (jpc_ms_gettype(ms) != JPC_MS_EPH) { - jpc_ms_destroy(ms); - fprintf(stderr, "missing EPH marker segment\n"); - return -1; - } - jpc_ms_destroy(ms); - } - } - - /* decode the packet body. */ - - if (jas_getdbglevel() >= 1) { - fprintf(stderr, "packet body offset=%06ld\n", (long) jas_stream_getrwcount(in)); - } - - if (!discard) { - tcomp = &tile->tcomps[compno]; - rlvl = &tcomp->rlvls[rlvlno]; - for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands; - ++bandno, ++band) { - if (!band->data) { - continue; - } - prc = &band->prcs[prcno]; - if (!prc->cblks) { - continue; - } - for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks; - ++cblkno, ++cblk) { - seg = cblk->curseg; - while (seg) { - if (!seg->stream) { - if (!(seg->stream = jas_stream_memopen(0, 0))) { - return -1; - } - } + if (!(inb = jpc_bitstream_sopen(pkthdrstream, "r"))) { + return -1; + } + + if ((present = jpc_bitstream_getbit(inb)) < 0) { + return 1; + } + JAS_DBGLOG(10, ("\n", present)); + JAS_DBGLOG(10, ("present=%d ", present)); + + /* Is the packet non-empty? */ + if (present) { + /* The packet is non-empty. */ + tcomp = &tile->tcomps[compno]; + rlvl = &tcomp->rlvls[rlvlno]; + bodylen = 0; + for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands; + ++bandno, ++band) { + if (!band->data) { + continue; + } + prc = &band->prcs[prcno]; + if (!prc->cblks) { + continue; + } + usedcblkcnt = 0; + for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks; + ++cblkno, ++cblk) { + ++usedcblkcnt; + if (!cblk->numpasses) { + leaf = jpc_tagtree_getleaf(prc->incltagtree, usedcblkcnt - 1); + if ((included = jpc_tagtree_decode(prc->incltagtree, leaf, lyrno + 1, inb)) < 0) { + return -1; + } + } else { + if ((included = jpc_bitstream_getbit(inb)) < 0) { + return -1; + } + } + JAS_DBGLOG(10, ("\n")); + JAS_DBGLOG(10, ("included=%d ", included)); + if (!included) { + continue; + } + if (!cblk->numpasses) { + i = 1; + leaf = jpc_tagtree_getleaf(prc->numimsbstagtree, usedcblkcnt - 1); + for (;;) { + if ((ret = jpc_tagtree_decode(prc->numimsbstagtree, leaf, i, inb)) < 0) { + return -1; + } + if (ret) { + break; + } + ++i; + } + cblk->numimsbs = i - 1; + cblk->firstpassno = cblk->numimsbs * 3; + } + if ((numnewpasses = jpc_getnumnewpasses(inb)) < 0) { + return -1; + } + JAS_DBGLOG(10, ("numnewpasses=%d ", numnewpasses)); + seg = cblk->curseg; + savenumnewpasses = numnewpasses; + mycounter = 0; + if (numnewpasses > 0) { + if ((m = jpc_getcommacode(inb)) < 0) { + return -1; + } + cblk->numlenbits += m; + JAS_DBGLOG(10, ("increment=%d ", m)); + while (numnewpasses > 0) { + passno = cblk->firstpassno + cblk->numpasses + mycounter; + /* XXX - the maxpasses is not set precisely but this doesn't matter... */ + maxpasses = JPC_SEGPASSCNT(passno, cblk->firstpassno, 10000, (ccp->cblkctx & JPC_COX_LAZY) != 0, (ccp->cblkctx & JPC_COX_TERMALL) != 0); + if (!discard && !seg) { + if (!(seg = jpc_seg_alloc())) { + return -1; + } + jpc_seglist_insert(&cblk->segs, cblk->segs.tail, seg); + if (!cblk->curseg) { + cblk->curseg = seg; + } + seg->passno = passno; + seg->type = JPC_SEGTYPE(seg->passno, cblk->firstpassno, (ccp->cblkctx & JPC_COX_LAZY) != 0); + seg->maxpasses = maxpasses; + } + n = JAS_MIN(numnewpasses, maxpasses); + mycounter += n; + numnewpasses -= n; + if ((len = jpc_bitstream_getbits(inb, cblk->numlenbits + jpc_floorlog2(n))) < 0) { + return -1; + } + JAS_DBGLOG(10, ("len=%d ", len)); + if (!discard) { + seg->lyrno = lyrno; + seg->numpasses += n; + seg->cnt = len; + seg = seg->next; + } + bodylen += len; + } + } + cblk->numpasses += savenumnewpasses; + } + } + + jpc_bitstream_inalign(inb, 0, 0); + + } else { + if (jpc_bitstream_inalign(inb, 0x7f, 0)) { + fprintf(stderr, "alignment failed\n"); + return -1; + } + } + jpc_bitstream_close(inb); + + hdroffend = jas_stream_getrwcount(pkthdrstream); + hdrlen = hdroffend - hdroffstart; + if (jas_getdbglevel() >= 5) { + fprintf(stderr, "hdrlen=%lu bodylen=%lu \n", (unsigned long) hdrlen, + (unsigned long) bodylen); + } + + if (cp->csty & JPC_COD_EPH) { + if (jpc_dec_lookahead(pkthdrstream) == JPC_MS_EPH) { + if (!(ms = jpc_getms(pkthdrstream, dec->cstate))) { + fprintf(stderr, "cannot get (EPH) marker segment\n"); + return -1; + } + if (jpc_ms_gettype(ms) != JPC_MS_EPH) { + jpc_ms_destroy(ms); + fprintf(stderr, "missing EPH marker segment\n"); + return -1; + } + jpc_ms_destroy(ms); + } + } + + /* decode the packet body. */ + + if (jas_getdbglevel() >= 1) { + fprintf(stderr, "packet body offset=%06ld\n", (long) jas_stream_getrwcount(in)); + } + + if (!discard) { + tcomp = &tile->tcomps[compno]; + rlvl = &tcomp->rlvls[rlvlno]; + for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands; + ++bandno, ++band) { + if (!band->data) { + continue; + } + prc = &band->prcs[prcno]; + if (!prc->cblks) { + continue; + } + for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks; + ++cblkno, ++cblk) { + seg = cblk->curseg; + while (seg) { + if (!seg->stream) { + if (!(seg->stream = jas_stream_memopen(0, 0))) { + return -1; + } + } #if 0 fprintf(stderr, "lyrno=%02d, compno=%02d, lvlno=%02d, prcno=%02d, bandno=%02d, cblkno=%02d, passno=%02d numpasses=%02d cnt=%d numbps=%d, numimsbs=%d\n", lyrno, compno, rlvlno, prcno, band - rlvl->bands, cblk - prc->cblks, seg->passno, seg->numpasses, seg->cnt, band->numbps, cblk->numimsbs); #endif - if (seg->cnt > 0) { - if (jpc_getdata(in, seg->stream, seg->cnt) < 0) { - return -1; - } - seg->cnt = 0; - } - if (seg->numpasses >= seg->maxpasses) { - cblk->curseg = seg->next; - } - seg = seg->next; - } - } - } - } else { - if (jas_stream_gobble(in, bodylen) != bodylen) { - return -1; - } - } - return 0; + if (seg->cnt > 0) { + if (jpc_getdata(in, seg->stream, seg->cnt) < 0) { + return -1; + } + seg->cnt = 0; + } + if (seg->numpasses >= seg->maxpasses) { + cblk->curseg = seg->next; + } + seg = seg->next; + } + } + } + } else { + if (jas_stream_gobble(in, bodylen) != bodylen) { + return -1; + } + } + return 0; } /********************************************************************************************/ @@ -461,166 +461,166 @@ fprintf(stderr, "lyrno=%02d, compno=%02d, lvlno=%02d, prcno=%02d, bandno=%02d, c int jpc_dec_decodepkts(jpc_dec_t *dec, jas_stream_t *pkthdrstream, jas_stream_t *in) { - jpc_dec_tile_t *tile; - jpc_pi_t *pi; - int ret; + jpc_dec_tile_t *tile; + jpc_pi_t *pi; + int ret; - tile = dec->curtile; - pi = tile->pi; - for (;;) { + tile = dec->curtile; + pi = tile->pi; + for (;;) { if (!tile->pkthdrstream || jas_stream_peekc(tile->pkthdrstream) == EOF) { - switch (jpc_dec_lookahead(in)) { - case JPC_MS_EOC: - case JPC_MS_SOT: - return 0; - break; - case JPC_MS_SOP: - case JPC_MS_EPH: - case 0: - break; - default: - return -1; - break; - } + switch (jpc_dec_lookahead(in)) { + case JPC_MS_EOC: + case JPC_MS_SOT: + return 0; + break; + case JPC_MS_SOP: + case JPC_MS_EPH: + case 0: + break; + default: + return -1; + break; + } } - if ((ret = jpc_pi_next(pi))) { - return ret; - } + if ((ret = jpc_pi_next(pi))) { + return ret; + } if (dec->maxpkts >= 0 && dec->numpkts >= dec->maxpkts) { - fprintf(stderr, "warning: stopping decode prematurely as requested\n"); - return 0; + fprintf(stderr, "warning: stopping decode prematurely as requested\n"); + return 0; } - if (jas_getdbglevel() >= 1) { - fprintf(stderr, "packet offset=%08ld prg=%d cmptno=%02d " - "rlvlno=%02d prcno=%03d lyrno=%02d\n", (long) - jas_stream_getrwcount(in), jpc_pi_prg(pi), jpc_pi_cmptno(pi), - jpc_pi_rlvlno(pi), jpc_pi_prcno(pi), jpc_pi_lyrno(pi)); - } - if (jpc_dec_decodepkt(dec, pkthdrstream, in, jpc_pi_cmptno(pi), jpc_pi_rlvlno(pi), - jpc_pi_prcno(pi), jpc_pi_lyrno(pi))) { - return -1; - } + if (jas_getdbglevel() >= 1) { + fprintf(stderr, "packet offset=%08ld prg=%d cmptno=%02d " + "rlvlno=%02d prcno=%03d lyrno=%02d\n", (long) + jas_stream_getrwcount(in), jpc_pi_prg(pi), jpc_pi_cmptno(pi), + jpc_pi_rlvlno(pi), jpc_pi_prcno(pi), jpc_pi_lyrno(pi)); + } + if (jpc_dec_decodepkt(dec, pkthdrstream, in, jpc_pi_cmptno(pi), jpc_pi_rlvlno(pi), + jpc_pi_prcno(pi), jpc_pi_lyrno(pi))) { + return -1; + } ++dec->numpkts; - } + } - return 0; + return 0; } jpc_pi_t *jpc_dec_pi_create(jpc_dec_t *dec, jpc_dec_tile_t *tile) { - jpc_pi_t *pi; - int compno; - jpc_picomp_t *picomp; - jpc_pirlvl_t *pirlvl; - jpc_dec_tcomp_t *tcomp; - int rlvlno; - jpc_dec_rlvl_t *rlvl; - int prcno; - int *prclyrno; - jpc_dec_cmpt_t *cmpt; - - if (!(pi = jpc_pi_create0())) { - return 0; - } - pi->numcomps = dec->numcomps; - if (!(pi->picomps = jas_malloc(pi->numcomps * sizeof(jpc_picomp_t)))) { - jpc_pi_destroy(pi); - return 0; - } - for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; ++compno, - ++picomp) { - picomp->pirlvls = 0; - } - - for (compno = 0, tcomp = tile->tcomps, picomp = pi->picomps; - compno < pi->numcomps; ++compno, ++tcomp, ++picomp) { - picomp->numrlvls = tcomp->numrlvls; - if (!(picomp->pirlvls = jas_malloc(picomp->numrlvls * - sizeof(jpc_pirlvl_t)))) { - jpc_pi_destroy(pi); - return 0; - } - for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < - picomp->numrlvls; ++rlvlno, ++pirlvl) { - pirlvl->prclyrnos = 0; - } - for (rlvlno = 0, pirlvl = picomp->pirlvls, rlvl = tcomp->rlvls; - rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) { + jpc_pi_t *pi; + int compno; + jpc_picomp_t *picomp; + jpc_pirlvl_t *pirlvl; + jpc_dec_tcomp_t *tcomp; + int rlvlno; + jpc_dec_rlvl_t *rlvl; + int prcno; + int *prclyrno; + jpc_dec_cmpt_t *cmpt; + + if (!(pi = jpc_pi_create0())) { + return 0; + } + pi->numcomps = dec->numcomps; + if (!(pi->picomps = jas_malloc(pi->numcomps * sizeof(jpc_picomp_t)))) { + jpc_pi_destroy(pi); + return 0; + } + for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; ++compno, + ++picomp) { + picomp->pirlvls = 0; + } + + for (compno = 0, tcomp = tile->tcomps, picomp = pi->picomps; + compno < pi->numcomps; ++compno, ++tcomp, ++picomp) { + picomp->numrlvls = tcomp->numrlvls; + if (!(picomp->pirlvls = jas_malloc(picomp->numrlvls * + sizeof(jpc_pirlvl_t)))) { + jpc_pi_destroy(pi); + return 0; + } + for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < + picomp->numrlvls; ++rlvlno, ++pirlvl) { + pirlvl->prclyrnos = 0; + } + for (rlvlno = 0, pirlvl = picomp->pirlvls, rlvl = tcomp->rlvls; + rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) { /* XXX sizeof(long) should be sizeof different type */ - pirlvl->numprcs = rlvl->numprcs; - if (!(pirlvl->prclyrnos = jas_malloc(pirlvl->numprcs * - sizeof(long)))) { - jpc_pi_destroy(pi); - return 0; - } - } - } - - pi->maxrlvls = 0; - for (compno = 0, tcomp = tile->tcomps, picomp = pi->picomps, cmpt = - dec->cmpts; compno < pi->numcomps; ++compno, ++tcomp, ++picomp, - ++cmpt) { - picomp->hsamp = cmpt->hstep; - picomp->vsamp = cmpt->vstep; - for (rlvlno = 0, pirlvl = picomp->pirlvls, rlvl = tcomp->rlvls; - rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) { - pirlvl->prcwidthexpn = rlvl->prcwidthexpn; - pirlvl->prcheightexpn = rlvl->prcheightexpn; - for (prcno = 0, prclyrno = pirlvl->prclyrnos; - prcno < pirlvl->numprcs; ++prcno, ++prclyrno) { - *prclyrno = 0; - } - pirlvl->numhprcs = rlvl->numhprcs; - } - if (pi->maxrlvls < tcomp->numrlvls) { - pi->maxrlvls = tcomp->numrlvls; - } - } - - pi->numlyrs = tile->cp->numlyrs; - pi->xstart = tile->xstart; - pi->ystart = tile->ystart; - pi->xend = tile->xend; - pi->yend = tile->yend; - - pi->picomp = 0; - pi->pirlvl = 0; - pi->x = 0; - pi->y = 0; - pi->compno = 0; - pi->rlvlno = 0; - pi->prcno = 0; - pi->lyrno = 0; - pi->xstep = 0; - pi->ystep = 0; - - pi->pchgno = -1; - - pi->defaultpchg.prgord = tile->cp->prgord; - pi->defaultpchg.compnostart = 0; - pi->defaultpchg.compnoend = pi->numcomps; - pi->defaultpchg.rlvlnostart = 0; - pi->defaultpchg.rlvlnoend = pi->maxrlvls; - pi->defaultpchg.lyrnoend = pi->numlyrs; - pi->pchg = 0; - - pi->valid = 0; - - return pi; + pirlvl->numprcs = rlvl->numprcs; + if (!(pirlvl->prclyrnos = jas_malloc(pirlvl->numprcs * + sizeof(long)))) { + jpc_pi_destroy(pi); + return 0; + } + } + } + + pi->maxrlvls = 0; + for (compno = 0, tcomp = tile->tcomps, picomp = pi->picomps, cmpt = + dec->cmpts; compno < pi->numcomps; ++compno, ++tcomp, ++picomp, + ++cmpt) { + picomp->hsamp = cmpt->hstep; + picomp->vsamp = cmpt->vstep; + for (rlvlno = 0, pirlvl = picomp->pirlvls, rlvl = tcomp->rlvls; + rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) { + pirlvl->prcwidthexpn = rlvl->prcwidthexpn; + pirlvl->prcheightexpn = rlvl->prcheightexpn; + for (prcno = 0, prclyrno = pirlvl->prclyrnos; + prcno < pirlvl->numprcs; ++prcno, ++prclyrno) { + *prclyrno = 0; + } + pirlvl->numhprcs = rlvl->numhprcs; + } + if (pi->maxrlvls < tcomp->numrlvls) { + pi->maxrlvls = tcomp->numrlvls; + } + } + + pi->numlyrs = tile->cp->numlyrs; + pi->xstart = tile->xstart; + pi->ystart = tile->ystart; + pi->xend = tile->xend; + pi->yend = tile->yend; + + pi->picomp = 0; + pi->pirlvl = 0; + pi->x = 0; + pi->y = 0; + pi->compno = 0; + pi->rlvlno = 0; + pi->prcno = 0; + pi->lyrno = 0; + pi->xstep = 0; + pi->ystep = 0; + + pi->pchgno = -1; + + pi->defaultpchg.prgord = tile->cp->prgord; + pi->defaultpchg.compnostart = 0; + pi->defaultpchg.compnoend = pi->numcomps; + pi->defaultpchg.rlvlnostart = 0; + pi->defaultpchg.rlvlnoend = pi->maxrlvls; + pi->defaultpchg.lyrnoend = pi->numlyrs; + pi->pchg = 0; + + pi->valid = 0; + + return pi; } long jpc_dec_lookahead(jas_stream_t *in) { - uint_fast16_t x; - if (jpc_getuint16(in, &x)) { - return -1; - } - if (jas_stream_ungetc(in, x & 0xff) == EOF || - jas_stream_ungetc(in, x >> 8) == EOF) { - return -1; - } - if (x >= JPC_MS_INMIN && x <= JPC_MS_INMAX) { - return x; - } - return 0; + uint_fast16_t x; + if (jpc_getuint16(in, &x)) { + return -1; + } + if (jas_stream_ungetc(in, x & 0xff) == EOF || + jas_stream_ungetc(in, x >> 8) == EOF) { + return -1; + } + if (x >= JPC_MS_INMIN && x <= JPC_MS_INMAX) { + return x; + } + return 0; } diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.h b/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.h index 923d7c1a..8e94232a 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t2dec.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.c index 1444dc7b..2d03cb29 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -142,563 +142,563 @@ static int jpc_putcommacode(jpc_bitstream_t *out, int n) { - assert(n >= 0); - - while (--n >= 0) { - if (jpc_bitstream_putbit(out, 1) == EOF) { - return -1; - } - } - if (jpc_bitstream_putbit(out, 0) == EOF) { - return -1; - } - return 0; + assert(n >= 0); + + while (--n >= 0) { + if (jpc_bitstream_putbit(out, 1) == EOF) { + return -1; + } + } + if (jpc_bitstream_putbit(out, 0) == EOF) { + return -1; + } + return 0; } static int jpc_putnumnewpasses(jpc_bitstream_t *out, int n) { - int ret; - - if (n <= 0) { - return -1; - } else if (n == 1) { - ret = jpc_bitstream_putbit(out, 0); - } else if (n == 2) { - ret = jpc_bitstream_putbits(out, 2, 2); - } else if (n <= 5) { - ret = jpc_bitstream_putbits(out, 4, 0xc | (n - 3)); - } else if (n <= 36) { - ret = jpc_bitstream_putbits(out, 9, 0x1e0 | (n - 6)); - } else if (n <= 164) { - ret = jpc_bitstream_putbits(out, 16, 0xff80 | (n - 37)); - } else { - /* The standard has no provision for encoding a larger value. - In practice, however, it is highly unlikely that this - limitation will ever be encountered. */ - return -1; - } - - return (ret != EOF) ? 0 : (-1); + int ret; + + if (n <= 0) { + return -1; + } else if (n == 1) { + ret = jpc_bitstream_putbit(out, 0); + } else if (n == 2) { + ret = jpc_bitstream_putbits(out, 2, 2); + } else if (n <= 5) { + ret = jpc_bitstream_putbits(out, 4, 0xc | (n - 3)); + } else if (n <= 36) { + ret = jpc_bitstream_putbits(out, 9, 0x1e0 | (n - 6)); + } else if (n <= 164) { + ret = jpc_bitstream_putbits(out, 16, 0xff80 | (n - 37)); + } else { + /* The standard has no provision for encoding a larger value. + In practice, however, it is highly unlikely that this + limitation will ever be encountered. */ + return -1; + } + + return (ret != EOF) ? 0 : (-1); } int jpc_enc_encpkts(jpc_enc_t *enc, jas_stream_t *out) { - jpc_enc_tile_t *tile; - jpc_pi_t *pi; - - tile = enc->curtile; - - jpc_init_t2state(enc, 0); - pi = tile->pi; - jpc_pi_init(pi); - - if (!jpc_pi_next(pi)) { - for (;;) { - if (jpc_enc_encpkt(enc, out, jpc_pi_cmptno(pi), jpc_pi_rlvlno(pi), - jpc_pi_prcno(pi), jpc_pi_lyrno(pi))) { - return -1; - } - if (jpc_pi_next(pi)) { - break; - } - } - } - - return 0; + jpc_enc_tile_t *tile; + jpc_pi_t *pi; + + tile = enc->curtile; + + jpc_init_t2state(enc, 0); + pi = tile->pi; + jpc_pi_init(pi); + + if (!jpc_pi_next(pi)) { + for (;;) { + if (jpc_enc_encpkt(enc, out, jpc_pi_cmptno(pi), jpc_pi_rlvlno(pi), + jpc_pi_prcno(pi), jpc_pi_lyrno(pi))) { + return -1; + } + if (jpc_pi_next(pi)) { + break; + } + } + } + + return 0; } int jpc_enc_encpkt(jpc_enc_t *enc, jas_stream_t *out, int compno, int lvlno, int prcno, int lyrno) { - jpc_enc_tcmpt_t *comp; - jpc_enc_rlvl_t *lvl; - jpc_enc_band_t *band; - jpc_enc_band_t *endbands; - jpc_enc_cblk_t *cblk; - jpc_enc_cblk_t *endcblks; - jpc_bitstream_t *outb; - jpc_enc_pass_t *pass; - jpc_enc_pass_t *startpass; - jpc_enc_pass_t *lastpass; - jpc_enc_pass_t *endpass; - jpc_enc_pass_t *endpasses; - int i; - int included; - int ret; - jpc_tagtreenode_t *leaf; - int n; - int t1; - int t2; - int adjust; - int maxadjust; - int datalen; - int numnewpasses; - int passcount; - jpc_enc_tile_t *tile; - jpc_enc_prc_t *prc; - jpc_enc_cp_t *cp; - jpc_ms_t *ms; - - tile = enc->curtile; - cp = enc->cp; - - if (cp->tcp.csty & JPC_COD_SOP) { - if (!(ms = jpc_ms_create(JPC_MS_SOP))) { - return -1; - } - ms->parms.sop.seqno = jpc_pi_getind(tile->pi); - if (jpc_putms(out, enc->cstate, ms)) { - return -1; - } - jpc_ms_destroy(ms); - } - - outb = jpc_bitstream_sopen(out, "w+"); - assert(outb); - - if (jpc_bitstream_putbit(outb, 1) == EOF) { - return -1; - } - JAS_DBGLOG(10, ("\n")); - JAS_DBGLOG(10, ("present. ")); - - comp = &tile->tcmpts[compno]; - lvl = &comp->rlvls[lvlno]; - endbands = &lvl->bands[lvl->numbands]; - for (band = lvl->bands; band != endbands; ++band) { - if (!band->data) { - continue; - } - prc = &band->prcs[prcno]; - if (!prc->cblks) { - continue; - } - - endcblks = &prc->cblks[prc->numcblks]; - for (cblk = prc->cblks; cblk != endcblks; ++cblk) { - if (!lyrno) { - leaf = jpc_tagtree_getleaf(prc->nlibtree, cblk - prc->cblks); - jpc_tagtree_setvalue(prc->nlibtree, leaf, cblk->numimsbs); - } - pass = cblk->curpass; - included = (pass && pass->lyrno == lyrno); - if (included && (!cblk->numencpasses)) { - assert(pass->lyrno == lyrno); - leaf = jpc_tagtree_getleaf(prc->incltree, - cblk - prc->cblks); - jpc_tagtree_setvalue(prc->incltree, leaf, pass->lyrno); - } - } - - endcblks = &prc->cblks[prc->numcblks]; - for (cblk = prc->cblks; cblk != endcblks; ++cblk) { - pass = cblk->curpass; - included = (pass && pass->lyrno == lyrno); - if (!cblk->numencpasses) { - leaf = jpc_tagtree_getleaf(prc->incltree, - cblk - prc->cblks); - if (jpc_tagtree_encode(prc->incltree, leaf, lyrno - + 1, outb) < 0) { - return -1; - } - } else { - if (jpc_bitstream_putbit(outb, included) == EOF) { - return -1; - } - } - JAS_DBGLOG(10, ("included=%d ", included)); - if (!included) { - continue; - } - if (!cblk->numencpasses) { - i = 1; - leaf = jpc_tagtree_getleaf(prc->nlibtree, cblk - prc->cblks); - for (;;) { - if ((ret = jpc_tagtree_encode(prc->nlibtree, leaf, i, outb)) < 0) { - return -1; - } - if (ret) { - break; - } - ++i; - } - assert(leaf->known_ && i == leaf->value_ + 1); - } - - endpasses = &cblk->passes[cblk->numpasses]; - startpass = pass; - endpass = startpass; - while (endpass != endpasses && endpass->lyrno == lyrno){ - ++endpass; - } - numnewpasses = endpass - startpass; - if (jpc_putnumnewpasses(outb, numnewpasses)) { - return -1; - } - JAS_DBGLOG(10, ("numnewpasses=%d ", numnewpasses)); - - lastpass = endpass - 1; - n = startpass->start; - passcount = 1; - maxadjust = 0; - for (pass = startpass; pass != endpass; ++pass) { - if (pass->term || pass == lastpass) { - datalen = pass->end - n; - t1 = jpc_firstone(datalen) + 1; - t2 = cblk->numlenbits + jpc_floorlog2(passcount); - adjust = JAS_MAX(t1 - t2, 0); - maxadjust = JAS_MAX(adjust, maxadjust); - n += datalen; - passcount = 1; - } else { - ++passcount; - } - } - if (jpc_putcommacode(outb, maxadjust)) { - return -1; - } - cblk->numlenbits += maxadjust; - - lastpass = endpass - 1; - n = startpass->start; - passcount = 1; - for (pass = startpass; pass != endpass; ++pass) { - if (pass->term || pass == lastpass) { - datalen = pass->end - n; + jpc_enc_tcmpt_t *comp; + jpc_enc_rlvl_t *lvl; + jpc_enc_band_t *band; + jpc_enc_band_t *endbands; + jpc_enc_cblk_t *cblk; + jpc_enc_cblk_t *endcblks; + jpc_bitstream_t *outb; + jpc_enc_pass_t *pass; + jpc_enc_pass_t *startpass; + jpc_enc_pass_t *lastpass; + jpc_enc_pass_t *endpass; + jpc_enc_pass_t *endpasses; + int i; + int included; + int ret; + jpc_tagtreenode_t *leaf; + int n; + int t1; + int t2; + int adjust; + int maxadjust; + int datalen; + int numnewpasses; + int passcount; + jpc_enc_tile_t *tile; + jpc_enc_prc_t *prc; + jpc_enc_cp_t *cp; + jpc_ms_t *ms; + + tile = enc->curtile; + cp = enc->cp; + + if (cp->tcp.csty & JPC_COD_SOP) { + if (!(ms = jpc_ms_create(JPC_MS_SOP))) { + return -1; + } + ms->parms.sop.seqno = jpc_pi_getind(tile->pi); + if (jpc_putms(out, enc->cstate, ms)) { + return -1; + } + jpc_ms_destroy(ms); + } + + outb = jpc_bitstream_sopen(out, "w+"); + assert(outb); + + if (jpc_bitstream_putbit(outb, 1) == EOF) { + return -1; + } + JAS_DBGLOG(10, ("\n")); + JAS_DBGLOG(10, ("present. ")); + + comp = &tile->tcmpts[compno]; + lvl = &comp->rlvls[lvlno]; + endbands = &lvl->bands[lvl->numbands]; + for (band = lvl->bands; band != endbands; ++band) { + if (!band->data) { + continue; + } + prc = &band->prcs[prcno]; + if (!prc->cblks) { + continue; + } + + endcblks = &prc->cblks[prc->numcblks]; + for (cblk = prc->cblks; cblk != endcblks; ++cblk) { + if (!lyrno) { + leaf = jpc_tagtree_getleaf(prc->nlibtree, cblk - prc->cblks); + jpc_tagtree_setvalue(prc->nlibtree, leaf, cblk->numimsbs); + } + pass = cblk->curpass; + included = (pass && pass->lyrno == lyrno); + if (included && (!cblk->numencpasses)) { + assert(pass->lyrno == lyrno); + leaf = jpc_tagtree_getleaf(prc->incltree, + cblk - prc->cblks); + jpc_tagtree_setvalue(prc->incltree, leaf, pass->lyrno); + } + } + + endcblks = &prc->cblks[prc->numcblks]; + for (cblk = prc->cblks; cblk != endcblks; ++cblk) { + pass = cblk->curpass; + included = (pass && pass->lyrno == lyrno); + if (!cblk->numencpasses) { + leaf = jpc_tagtree_getleaf(prc->incltree, + cblk - prc->cblks); + if (jpc_tagtree_encode(prc->incltree, leaf, lyrno + + 1, outb) < 0) { + return -1; + } + } else { + if (jpc_bitstream_putbit(outb, included) == EOF) { + return -1; + } + } + JAS_DBGLOG(10, ("included=%d ", included)); + if (!included) { + continue; + } + if (!cblk->numencpasses) { + i = 1; + leaf = jpc_tagtree_getleaf(prc->nlibtree, cblk - prc->cblks); + for (;;) { + if ((ret = jpc_tagtree_encode(prc->nlibtree, leaf, i, outb)) < 0) { + return -1; + } + if (ret) { + break; + } + ++i; + } + assert(leaf->known_ && i == leaf->value_ + 1); + } + + endpasses = &cblk->passes[cblk->numpasses]; + startpass = pass; + endpass = startpass; + while (endpass != endpasses && endpass->lyrno == lyrno){ + ++endpass; + } + numnewpasses = endpass - startpass; + if (jpc_putnumnewpasses(outb, numnewpasses)) { + return -1; + } + JAS_DBGLOG(10, ("numnewpasses=%d ", numnewpasses)); + + lastpass = endpass - 1; + n = startpass->start; + passcount = 1; + maxadjust = 0; + for (pass = startpass; pass != endpass; ++pass) { + if (pass->term || pass == lastpass) { + datalen = pass->end - n; + t1 = jpc_firstone(datalen) + 1; + t2 = cblk->numlenbits + jpc_floorlog2(passcount); + adjust = JAS_MAX(t1 - t2, 0); + maxadjust = JAS_MAX(adjust, maxadjust); + n += datalen; + passcount = 1; + } else { + ++passcount; + } + } + if (jpc_putcommacode(outb, maxadjust)) { + return -1; + } + cblk->numlenbits += maxadjust; + + lastpass = endpass - 1; + n = startpass->start; + passcount = 1; + for (pass = startpass; pass != endpass; ++pass) { + if (pass->term || pass == lastpass) { + datalen = pass->end - n; assert(jpc_firstone(datalen) < cblk->numlenbits + jpc_floorlog2(passcount)); - if (jpc_bitstream_putbits(outb, cblk->numlenbits + jpc_floorlog2(passcount), datalen) == EOF) { - return -1; - } - n += datalen; - passcount = 1; - } else { - ++passcount; - } - } - } - } - - jpc_bitstream_outalign(outb, 0); - jpc_bitstream_close(outb); - - if (cp->tcp.csty & JPC_COD_EPH) { - if (!(ms = jpc_ms_create(JPC_MS_EPH))) { - return -1; - } - jpc_putms(out, enc->cstate, ms); - jpc_ms_destroy(ms); - } - - comp = &tile->tcmpts[compno]; - lvl = &comp->rlvls[lvlno]; - endbands = &lvl->bands[lvl->numbands]; - for (band = lvl->bands; band != endbands; ++band) { - if (!band->data) { - continue; - } - prc = &band->prcs[prcno]; - if (!prc->cblks) { - continue; - } - endcblks = &prc->cblks[prc->numcblks]; - for (cblk = prc->cblks; cblk != endcblks; ++cblk) { - pass = cblk->curpass; - - if (!pass) { - continue; - } - if (pass->lyrno != lyrno) { - assert(pass->lyrno < 0 || pass->lyrno > lyrno); - continue; - } - - endpasses = &cblk->passes[cblk->numpasses]; - startpass = pass; - endpass = startpass; - while (endpass != endpasses && endpass->lyrno == lyrno){ - ++endpass; - } - lastpass = endpass - 1; - numnewpasses = endpass - startpass; - - jas_stream_seek(cblk->stream, startpass->start, SEEK_SET); - assert(jas_stream_tell(cblk->stream) == startpass->start); - if (jas_stream_copy(out, cblk->stream, lastpass->end - startpass->start)) { - return -1; - } - cblk->curpass = (endpass != endpasses) ? endpass : 0; - cblk->numencpasses += numnewpasses; - - } - } - - return 0; + if (jpc_bitstream_putbits(outb, cblk->numlenbits + jpc_floorlog2(passcount), datalen) == EOF) { + return -1; + } + n += datalen; + passcount = 1; + } else { + ++passcount; + } + } + } + } + + jpc_bitstream_outalign(outb, 0); + jpc_bitstream_close(outb); + + if (cp->tcp.csty & JPC_COD_EPH) { + if (!(ms = jpc_ms_create(JPC_MS_EPH))) { + return -1; + } + jpc_putms(out, enc->cstate, ms); + jpc_ms_destroy(ms); + } + + comp = &tile->tcmpts[compno]; + lvl = &comp->rlvls[lvlno]; + endbands = &lvl->bands[lvl->numbands]; + for (band = lvl->bands; band != endbands; ++band) { + if (!band->data) { + continue; + } + prc = &band->prcs[prcno]; + if (!prc->cblks) { + continue; + } + endcblks = &prc->cblks[prc->numcblks]; + for (cblk = prc->cblks; cblk != endcblks; ++cblk) { + pass = cblk->curpass; + + if (!pass) { + continue; + } + if (pass->lyrno != lyrno) { + assert(pass->lyrno < 0 || pass->lyrno > lyrno); + continue; + } + + endpasses = &cblk->passes[cblk->numpasses]; + startpass = pass; + endpass = startpass; + while (endpass != endpasses && endpass->lyrno == lyrno){ + ++endpass; + } + lastpass = endpass - 1; + numnewpasses = endpass - startpass; + + jas_stream_seek(cblk->stream, startpass->start, SEEK_SET); + assert(jas_stream_tell(cblk->stream) == startpass->start); + if (jas_stream_copy(out, cblk->stream, lastpass->end - startpass->start)) { + return -1; + } + cblk->curpass = (endpass != endpasses) ? endpass : 0; + cblk->numencpasses += numnewpasses; + + } + } + + return 0; } void jpc_save_t2state(jpc_enc_t *enc) { /* stream pos in embedded T1 stream may be wrong since not saved/restored! */ - jpc_enc_tcmpt_t *comp; - jpc_enc_tcmpt_t *endcomps; - jpc_enc_rlvl_t *lvl; - jpc_enc_rlvl_t *endlvls; - jpc_enc_band_t *band; - jpc_enc_band_t *endbands; - jpc_enc_cblk_t *cblk; - jpc_enc_cblk_t *endcblks; - jpc_enc_tile_t *tile; - uint_fast32_t prcno; - jpc_enc_prc_t *prc; - - tile = enc->curtile; - - endcomps = &tile->tcmpts[tile->numtcmpts]; - for (comp = tile->tcmpts; comp != endcomps; ++comp) { - endlvls = &comp->rlvls[comp->numrlvls]; - for (lvl = comp->rlvls; lvl != endlvls; ++lvl) { - if (!lvl->bands) { - continue; - } - endbands = &lvl->bands[lvl->numbands]; - for (band = lvl->bands; band != endbands; ++band) { - if (!band->data) { - continue; - } - for (prcno = 0, prc = band->prcs; prcno < lvl->numprcs; ++prcno, ++prc) { - if (!prc->cblks) { - continue; - } - jpc_tagtree_copy(prc->savincltree, prc->incltree); - jpc_tagtree_copy(prc->savnlibtree, prc->nlibtree); - endcblks = &prc->cblks[prc->numcblks]; - for (cblk = prc->cblks; cblk != endcblks; ++cblk) { - cblk->savedcurpass = cblk->curpass; - cblk->savednumencpasses = cblk->numencpasses; - cblk->savednumlenbits = cblk->numlenbits; - } - } - } - } - } + jpc_enc_tcmpt_t *comp; + jpc_enc_tcmpt_t *endcomps; + jpc_enc_rlvl_t *lvl; + jpc_enc_rlvl_t *endlvls; + jpc_enc_band_t *band; + jpc_enc_band_t *endbands; + jpc_enc_cblk_t *cblk; + jpc_enc_cblk_t *endcblks; + jpc_enc_tile_t *tile; + uint_fast32_t prcno; + jpc_enc_prc_t *prc; + + tile = enc->curtile; + + endcomps = &tile->tcmpts[tile->numtcmpts]; + for (comp = tile->tcmpts; comp != endcomps; ++comp) { + endlvls = &comp->rlvls[comp->numrlvls]; + for (lvl = comp->rlvls; lvl != endlvls; ++lvl) { + if (!lvl->bands) { + continue; + } + endbands = &lvl->bands[lvl->numbands]; + for (band = lvl->bands; band != endbands; ++band) { + if (!band->data) { + continue; + } + for (prcno = 0, prc = band->prcs; prcno < lvl->numprcs; ++prcno, ++prc) { + if (!prc->cblks) { + continue; + } + jpc_tagtree_copy(prc->savincltree, prc->incltree); + jpc_tagtree_copy(prc->savnlibtree, prc->nlibtree); + endcblks = &prc->cblks[prc->numcblks]; + for (cblk = prc->cblks; cblk != endcblks; ++cblk) { + cblk->savedcurpass = cblk->curpass; + cblk->savednumencpasses = cblk->numencpasses; + cblk->savednumlenbits = cblk->numlenbits; + } + } + } + } + } } void jpc_restore_t2state(jpc_enc_t *enc) { - jpc_enc_tcmpt_t *comp; - jpc_enc_tcmpt_t *endcomps; - jpc_enc_rlvl_t *lvl; - jpc_enc_rlvl_t *endlvls; - jpc_enc_band_t *band; - jpc_enc_band_t *endbands; - jpc_enc_cblk_t *cblk; - jpc_enc_cblk_t *endcblks; - jpc_enc_tile_t *tile; - uint_fast32_t prcno; - jpc_enc_prc_t *prc; - - tile = enc->curtile; - - endcomps = &tile->tcmpts[tile->numtcmpts]; - for (comp = tile->tcmpts; comp != endcomps; ++comp) { - endlvls = &comp->rlvls[comp->numrlvls]; - for (lvl = comp->rlvls; lvl != endlvls; ++lvl) { - if (!lvl->bands) { - continue; - } - endbands = &lvl->bands[lvl->numbands]; - for (band = lvl->bands; band != endbands; ++band) { - if (!band->data) { - continue; - } - for (prcno = 0, prc = band->prcs; prcno < lvl->numprcs; ++prcno, ++prc) { - if (!prc->cblks) { - continue; - } - jpc_tagtree_copy(prc->incltree, prc->savincltree); - jpc_tagtree_copy(prc->nlibtree, prc->savnlibtree); - endcblks = &prc->cblks[prc->numcblks]; - for (cblk = prc->cblks; cblk != endcblks; ++cblk) { - cblk->curpass = cblk->savedcurpass; - cblk->numencpasses = cblk->savednumencpasses; - cblk->numlenbits = cblk->savednumlenbits; - } - } - } - } - } + jpc_enc_tcmpt_t *comp; + jpc_enc_tcmpt_t *endcomps; + jpc_enc_rlvl_t *lvl; + jpc_enc_rlvl_t *endlvls; + jpc_enc_band_t *band; + jpc_enc_band_t *endbands; + jpc_enc_cblk_t *cblk; + jpc_enc_cblk_t *endcblks; + jpc_enc_tile_t *tile; + uint_fast32_t prcno; + jpc_enc_prc_t *prc; + + tile = enc->curtile; + + endcomps = &tile->tcmpts[tile->numtcmpts]; + for (comp = tile->tcmpts; comp != endcomps; ++comp) { + endlvls = &comp->rlvls[comp->numrlvls]; + for (lvl = comp->rlvls; lvl != endlvls; ++lvl) { + if (!lvl->bands) { + continue; + } + endbands = &lvl->bands[lvl->numbands]; + for (band = lvl->bands; band != endbands; ++band) { + if (!band->data) { + continue; + } + for (prcno = 0, prc = band->prcs; prcno < lvl->numprcs; ++prcno, ++prc) { + if (!prc->cblks) { + continue; + } + jpc_tagtree_copy(prc->incltree, prc->savincltree); + jpc_tagtree_copy(prc->nlibtree, prc->savnlibtree); + endcblks = &prc->cblks[prc->numcblks]; + for (cblk = prc->cblks; cblk != endcblks; ++cblk) { + cblk->curpass = cblk->savedcurpass; + cblk->numencpasses = cblk->savednumencpasses; + cblk->numlenbits = cblk->savednumlenbits; + } + } + } + } + } } void jpc_init_t2state(jpc_enc_t *enc, int raflag) { /* It is assumed that band->numbps and cblk->numbps precomputed */ - jpc_enc_tcmpt_t *comp; - jpc_enc_tcmpt_t *endcomps; - jpc_enc_rlvl_t *lvl; - jpc_enc_rlvl_t *endlvls; - jpc_enc_band_t *band; - jpc_enc_band_t *endbands; - jpc_enc_cblk_t *cblk; - jpc_enc_cblk_t *endcblks; - jpc_enc_pass_t *pass; - jpc_enc_pass_t *endpasses; - jpc_tagtreenode_t *leaf; - jpc_enc_tile_t *tile; - uint_fast32_t prcno; - jpc_enc_prc_t *prc; - - tile = enc->curtile; - - endcomps = &tile->tcmpts[tile->numtcmpts]; - for (comp = tile->tcmpts; comp != endcomps; ++comp) { - endlvls = &comp->rlvls[comp->numrlvls]; - for (lvl = comp->rlvls; lvl != endlvls; ++lvl) { - if (!lvl->bands) { - continue; - } - endbands = &lvl->bands[lvl->numbands]; - for (band = lvl->bands; band != endbands; ++band) { - if (!band->data) { - continue; - } - for (prcno = 0, prc = band->prcs; prcno < lvl->numprcs; ++prcno, ++prc) { - if (!prc->cblks) { - continue; - } - jpc_tagtree_reset(prc->incltree); - jpc_tagtree_reset(prc->nlibtree); - endcblks = &prc->cblks[prc->numcblks]; - for (cblk = prc->cblks; cblk != endcblks; ++cblk) { - if (jas_stream_rewind(cblk->stream)) { - assert(0); - } - cblk->curpass = (cblk->numpasses > 0) ? cblk->passes : 0; - cblk->numencpasses = 0; - cblk->numlenbits = 3; - cblk->numimsbs = band->numbps - cblk->numbps; - assert(cblk->numimsbs >= 0); - leaf = jpc_tagtree_getleaf(prc->nlibtree, cblk - prc->cblks); - jpc_tagtree_setvalue(prc->nlibtree, leaf, cblk->numimsbs); - - if (raflag) { - endpasses = &cblk->passes[cblk->numpasses]; - for (pass = cblk->passes; pass != endpasses; ++pass) { - pass->lyrno = -1; - pass->lyrno = 0; - } - } - } - } - } - } - } + jpc_enc_tcmpt_t *comp; + jpc_enc_tcmpt_t *endcomps; + jpc_enc_rlvl_t *lvl; + jpc_enc_rlvl_t *endlvls; + jpc_enc_band_t *band; + jpc_enc_band_t *endbands; + jpc_enc_cblk_t *cblk; + jpc_enc_cblk_t *endcblks; + jpc_enc_pass_t *pass; + jpc_enc_pass_t *endpasses; + jpc_tagtreenode_t *leaf; + jpc_enc_tile_t *tile; + uint_fast32_t prcno; + jpc_enc_prc_t *prc; + + tile = enc->curtile; + + endcomps = &tile->tcmpts[tile->numtcmpts]; + for (comp = tile->tcmpts; comp != endcomps; ++comp) { + endlvls = &comp->rlvls[comp->numrlvls]; + for (lvl = comp->rlvls; lvl != endlvls; ++lvl) { + if (!lvl->bands) { + continue; + } + endbands = &lvl->bands[lvl->numbands]; + for (band = lvl->bands; band != endbands; ++band) { + if (!band->data) { + continue; + } + for (prcno = 0, prc = band->prcs; prcno < lvl->numprcs; ++prcno, ++prc) { + if (!prc->cblks) { + continue; + } + jpc_tagtree_reset(prc->incltree); + jpc_tagtree_reset(prc->nlibtree); + endcblks = &prc->cblks[prc->numcblks]; + for (cblk = prc->cblks; cblk != endcblks; ++cblk) { + if (jas_stream_rewind(cblk->stream)) { + assert(0); + } + cblk->curpass = (cblk->numpasses > 0) ? cblk->passes : 0; + cblk->numencpasses = 0; + cblk->numlenbits = 3; + cblk->numimsbs = band->numbps - cblk->numbps; + assert(cblk->numimsbs >= 0); + leaf = jpc_tagtree_getleaf(prc->nlibtree, cblk - prc->cblks); + jpc_tagtree_setvalue(prc->nlibtree, leaf, cblk->numimsbs); + + if (raflag) { + endpasses = &cblk->passes[cblk->numpasses]; + for (pass = cblk->passes; pass != endpasses; ++pass) { + pass->lyrno = -1; + pass->lyrno = 0; + } + } + } + } + } + } + } } jpc_pi_t *jpc_enc_pi_create(jpc_enc_cp_t *cp, jpc_enc_tile_t *tile) { - jpc_pi_t *pi; - int compno; - jpc_picomp_t *picomp; - jpc_pirlvl_t *pirlvl; - jpc_enc_tcmpt_t *tcomp; - int rlvlno; - jpc_enc_rlvl_t *rlvl; - int prcno; - int *prclyrno; - - if (!(pi = jpc_pi_create0())) { - return 0; - } - pi->pktno = -1; - pi->numcomps = cp->numcmpts; - if (!(pi->picomps = jas_malloc(pi->numcomps * sizeof(jpc_picomp_t)))) { - jpc_pi_destroy(pi); - return 0; - } - for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; ++compno, - ++picomp) { - picomp->pirlvls = 0; - } - - for (compno = 0, tcomp = tile->tcmpts, picomp = pi->picomps; - compno < pi->numcomps; ++compno, ++tcomp, ++picomp) { - picomp->numrlvls = tcomp->numrlvls; - if (!(picomp->pirlvls = jas_malloc(picomp->numrlvls * - sizeof(jpc_pirlvl_t)))) { - jpc_pi_destroy(pi); - return 0; - } - for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < - picomp->numrlvls; ++rlvlno, ++pirlvl) { - pirlvl->prclyrnos = 0; - } - for (rlvlno = 0, pirlvl = picomp->pirlvls, rlvl = tcomp->rlvls; - rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) { + jpc_pi_t *pi; + int compno; + jpc_picomp_t *picomp; + jpc_pirlvl_t *pirlvl; + jpc_enc_tcmpt_t *tcomp; + int rlvlno; + jpc_enc_rlvl_t *rlvl; + int prcno; + int *prclyrno; + + if (!(pi = jpc_pi_create0())) { + return 0; + } + pi->pktno = -1; + pi->numcomps = cp->numcmpts; + if (!(pi->picomps = jas_malloc(pi->numcomps * sizeof(jpc_picomp_t)))) { + jpc_pi_destroy(pi); + return 0; + } + for (compno = 0, picomp = pi->picomps; compno < pi->numcomps; ++compno, + ++picomp) { + picomp->pirlvls = 0; + } + + for (compno = 0, tcomp = tile->tcmpts, picomp = pi->picomps; + compno < pi->numcomps; ++compno, ++tcomp, ++picomp) { + picomp->numrlvls = tcomp->numrlvls; + if (!(picomp->pirlvls = jas_malloc(picomp->numrlvls * + sizeof(jpc_pirlvl_t)))) { + jpc_pi_destroy(pi); + return 0; + } + for (rlvlno = 0, pirlvl = picomp->pirlvls; rlvlno < + picomp->numrlvls; ++rlvlno, ++pirlvl) { + pirlvl->prclyrnos = 0; + } + for (rlvlno = 0, pirlvl = picomp->pirlvls, rlvl = tcomp->rlvls; + rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) { /* XXX sizeof(long) should be sizeof different type */ - pirlvl->numprcs = rlvl->numprcs; - if (rlvl->numprcs) { - if (!(pirlvl->prclyrnos = jas_malloc(pirlvl->numprcs * - sizeof(long)))) { - jpc_pi_destroy(pi); - return 0; - } - } else { - pirlvl->prclyrnos = 0; - } - } - } - - pi->maxrlvls = 0; - for (compno = 0, tcomp = tile->tcmpts, picomp = pi->picomps; - compno < pi->numcomps; ++compno, ++tcomp, ++picomp) { - picomp->hsamp = cp->ccps[compno].sampgrdstepx; - picomp->vsamp = cp->ccps[compno].sampgrdstepy; - for (rlvlno = 0, pirlvl = picomp->pirlvls, rlvl = tcomp->rlvls; - rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) { - pirlvl->prcwidthexpn = rlvl->prcwidthexpn; - pirlvl->prcheightexpn = rlvl->prcheightexpn; - for (prcno = 0, prclyrno = pirlvl->prclyrnos; - prcno < pirlvl->numprcs; ++prcno, ++prclyrno) { - *prclyrno = 0; - } - pirlvl->numhprcs = rlvl->numhprcs; - } - if (pi->maxrlvls < tcomp->numrlvls) { - pi->maxrlvls = tcomp->numrlvls; - } - } - - pi->numlyrs = tile->numlyrs; - pi->xstart = tile->tlx; - pi->ystart = tile->tly; - pi->xend = tile->brx; - pi->yend = tile->bry; - - pi->picomp = 0; - pi->pirlvl = 0; - pi->x = 0; - pi->y = 0; - pi->compno = 0; - pi->rlvlno = 0; - pi->prcno = 0; - pi->lyrno = 0; - pi->xstep = 0; - pi->ystep = 0; - - pi->pchgno = -1; - - pi->defaultpchg.prgord = tile->prg; - pi->defaultpchg.compnostart = 0; - pi->defaultpchg.compnoend = pi->numcomps; - pi->defaultpchg.rlvlnostart = 0; - pi->defaultpchg.rlvlnoend = pi->maxrlvls; - pi->defaultpchg.lyrnoend = pi->numlyrs; - pi->pchg = 0; - - pi->valid = 0; - - return pi; + pirlvl->numprcs = rlvl->numprcs; + if (rlvl->numprcs) { + if (!(pirlvl->prclyrnos = jas_malloc(pirlvl->numprcs * + sizeof(long)))) { + jpc_pi_destroy(pi); + return 0; + } + } else { + pirlvl->prclyrnos = 0; + } + } + } + + pi->maxrlvls = 0; + for (compno = 0, tcomp = tile->tcmpts, picomp = pi->picomps; + compno < pi->numcomps; ++compno, ++tcomp, ++picomp) { + picomp->hsamp = cp->ccps[compno].sampgrdstepx; + picomp->vsamp = cp->ccps[compno].sampgrdstepy; + for (rlvlno = 0, pirlvl = picomp->pirlvls, rlvl = tcomp->rlvls; + rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) { + pirlvl->prcwidthexpn = rlvl->prcwidthexpn; + pirlvl->prcheightexpn = rlvl->prcheightexpn; + for (prcno = 0, prclyrno = pirlvl->prclyrnos; + prcno < pirlvl->numprcs; ++prcno, ++prclyrno) { + *prclyrno = 0; + } + pirlvl->numhprcs = rlvl->numhprcs; + } + if (pi->maxrlvls < tcomp->numrlvls) { + pi->maxrlvls = tcomp->numrlvls; + } + } + + pi->numlyrs = tile->numlyrs; + pi->xstart = tile->tlx; + pi->ystart = tile->tly; + pi->xend = tile->brx; + pi->yend = tile->bry; + + pi->picomp = 0; + pi->pirlvl = 0; + pi->x = 0; + pi->y = 0; + pi->compno = 0; + pi->rlvlno = 0; + pi->prcno = 0; + pi->lyrno = 0; + pi->xstep = 0; + pi->ystep = 0; + + pi->pchgno = -1; + + pi->defaultpchg.prgord = tile->prg; + pi->defaultpchg.compnostart = 0; + pi->defaultpchg.compnoend = pi->numcomps; + pi->defaultpchg.rlvlnostart = 0; + pi->defaultpchg.rlvlnoend = pi->maxrlvls; + pi->defaultpchg.lyrnoend = pi->numlyrs; + pi->pchg = 0; + + pi->valid = 0; + + return pi; } diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.h b/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.h index e97f8c06..8b5979de 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t2enc.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.c b/converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.c index 2b13fcf1..1d026b85 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -135,101 +135,101 @@ static jpc_tagtree_t *jpc_tagtree_alloc(void) { - jpc_tagtree_t *tree; + jpc_tagtree_t *tree; - if (!(tree = jas_malloc(sizeof(jpc_tagtree_t)))) { - return 0; - } - tree->numleafsh_ = 0; - tree->numleafsv_ = 0; - tree->numnodes_ = 0; - tree->nodes_ = 0; + if (!(tree = jas_malloc(sizeof(jpc_tagtree_t)))) { + return 0; + } + tree->numleafsh_ = 0; + tree->numleafsv_ = 0; + tree->numnodes_ = 0; + tree->nodes_ = 0; - return tree; + return tree; } /* Create a tag tree. */ jpc_tagtree_t *jpc_tagtree_create(int numleafsh, int numleafsv) { - int nplh[JPC_TAGTREE_MAXDEPTH]; - int nplv[JPC_TAGTREE_MAXDEPTH]; - jpc_tagtreenode_t *node; - jpc_tagtreenode_t *parentnode; - jpc_tagtreenode_t *parentnode0; - jpc_tagtree_t *tree; - int i; - int j; - int k; - int numlvls; - int n; - - assert(numleafsh > 0 && numleafsv > 0); - - if (!(tree = jpc_tagtree_alloc())) { - return 0; - } - tree->numleafsh_ = numleafsh; - tree->numleafsv_ = numleafsv; - - numlvls = 0; - nplh[0] = numleafsh; - nplv[0] = numleafsv; - do { - n = nplh[numlvls] * nplv[numlvls]; - nplh[numlvls + 1] = (nplh[numlvls] + 1) / 2; - nplv[numlvls + 1] = (nplv[numlvls] + 1) / 2; - tree->numnodes_ += n; - ++numlvls; - } while (n > 1); - - if (!(tree->nodes_ = jas_malloc(tree->numnodes_ * sizeof(jpc_tagtreenode_t)))) { - return 0; - } - - /* Initialize the parent links for all nodes in the tree. */ - - node = tree->nodes_; - parentnode = &tree->nodes_[tree->numleafsh_ * tree->numleafsv_]; - parentnode0 = parentnode; - - for (i = 0; i < numlvls - 1; ++i) { - for (j = 0; j < nplv[i]; ++j) { - k = nplh[i]; - while (--k >= 0) { - node->parent_ = parentnode; - ++node; - if (--k >= 0) { - node->parent_ = parentnode; - ++node; - } - ++parentnode; - } - if ((j & 1) || j == nplv[i] - 1) { - parentnode0 = parentnode; - } else { - parentnode = parentnode0; - parentnode0 += nplh[i]; - } - } - } - node->parent_ = 0; - - /* Initialize the data values to something sane. */ - - jpc_tagtree_reset(tree); - - return tree; + int nplh[JPC_TAGTREE_MAXDEPTH]; + int nplv[JPC_TAGTREE_MAXDEPTH]; + jpc_tagtreenode_t *node; + jpc_tagtreenode_t *parentnode; + jpc_tagtreenode_t *parentnode0; + jpc_tagtree_t *tree; + int i; + int j; + int k; + int numlvls; + int n; + + assert(numleafsh > 0 && numleafsv > 0); + + if (!(tree = jpc_tagtree_alloc())) { + return 0; + } + tree->numleafsh_ = numleafsh; + tree->numleafsv_ = numleafsv; + + numlvls = 0; + nplh[0] = numleafsh; + nplv[0] = numleafsv; + do { + n = nplh[numlvls] * nplv[numlvls]; + nplh[numlvls + 1] = (nplh[numlvls] + 1) / 2; + nplv[numlvls + 1] = (nplv[numlvls] + 1) / 2; + tree->numnodes_ += n; + ++numlvls; + } while (n > 1); + + if (!(tree->nodes_ = jas_malloc(tree->numnodes_ * sizeof(jpc_tagtreenode_t)))) { + return 0; + } + + /* Initialize the parent links for all nodes in the tree. */ + + node = tree->nodes_; + parentnode = &tree->nodes_[tree->numleafsh_ * tree->numleafsv_]; + parentnode0 = parentnode; + + for (i = 0; i < numlvls - 1; ++i) { + for (j = 0; j < nplv[i]; ++j) { + k = nplh[i]; + while (--k >= 0) { + node->parent_ = parentnode; + ++node; + if (--k >= 0) { + node->parent_ = parentnode; + ++node; + } + ++parentnode; + } + if ((j & 1) || j == nplv[i] - 1) { + parentnode0 = parentnode; + } else { + parentnode = parentnode0; + parentnode0 += nplh[i]; + } + } + } + node->parent_ = 0; + + /* Initialize the data values to something sane. */ + + jpc_tagtree_reset(tree); + + return tree; } /* Destroy a tag tree. */ void jpc_tagtree_destroy(jpc_tagtree_t *tree) { - if (tree->nodes_) { - jas_free(tree->nodes_); - } - jas_free(tree); + if (tree->nodes_) { + jas_free(tree->nodes_); + } + jas_free(tree); } /******************************************************************************\ @@ -240,42 +240,42 @@ void jpc_tagtree_destroy(jpc_tagtree_t *tree) void jpc_tagtree_copy(jpc_tagtree_t *dsttree, jpc_tagtree_t *srctree) { - int n; - jpc_tagtreenode_t *srcnode; - jpc_tagtreenode_t *dstnode; - - /* The two tag trees must have similar sizes. */ - assert(srctree->numleafsh_ == dsttree->numleafsh_ && - srctree->numleafsv_ == dsttree->numleafsv_); - - n = srctree->numnodes_; - srcnode = srctree->nodes_; - dstnode = dsttree->nodes_; - while (--n >= 0) { - dstnode->value_ = srcnode->value_; - dstnode->low_ = srcnode->low_; - dstnode->known_ = srcnode->known_; - ++dstnode; - ++srcnode; - } + int n; + jpc_tagtreenode_t *srcnode; + jpc_tagtreenode_t *dstnode; + + /* The two tag trees must have similar sizes. */ + assert(srctree->numleafsh_ == dsttree->numleafsh_ && + srctree->numleafsv_ == dsttree->numleafsv_); + + n = srctree->numnodes_; + srcnode = srctree->nodes_; + dstnode = dsttree->nodes_; + while (--n >= 0) { + dstnode->value_ = srcnode->value_; + dstnode->low_ = srcnode->low_; + dstnode->known_ = srcnode->known_; + ++dstnode; + ++srcnode; + } } /* Reset all of the state information associated with a tag tree. */ void jpc_tagtree_reset(jpc_tagtree_t *tree) { - int n; - jpc_tagtreenode_t *node; - - n = tree->numnodes_; - node = tree->nodes_; - - while (--n >= 0) { - node->value_ = INT_MAX; - node->low_ = 0; - node->known_ = 0; - ++node; - } + int n; + jpc_tagtreenode_t *node; + + n = tree->numnodes_; + node = tree->nodes_; + + while (--n >= 0) { + node->value_ = INT_MAX; + node->low_ = 0; + node->known_ = 0; + ++node; + } } /* Set the value associated with the specified leaf node, updating @@ -283,22 +283,22 @@ the other nodes as necessary. */ void jpc_tagtree_setvalue(jpc_tagtree_t *tree, jpc_tagtreenode_t *leaf, int value) { - jpc_tagtreenode_t *node; + jpc_tagtreenode_t *node; - assert(value >= 0); + assert(value >= 0); - node = leaf; - while (node && node->value_ > value) { - node->value_ = value; - node = node->parent_; - } + node = leaf; + while (node && node->value_ > value) { + node->value_ = value; + node = node->parent_; + } } /* Get a particular leaf node. */ jpc_tagtreenode_t *jpc_tagtree_getleaf(jpc_tagtree_t *tree, int n) { - return &tree->nodes_[n]; + return &tree->nodes_[n]; } /* Invoke the tag tree encoding procedure. */ @@ -306,55 +306,55 @@ jpc_tagtreenode_t *jpc_tagtree_getleaf(jpc_tagtree_t *tree, int n) int jpc_tagtree_encode(jpc_tagtree_t *tree, jpc_tagtreenode_t *leaf, int threshold, jpc_bitstream_t *out) { - jpc_tagtreenode_t *stk[JPC_TAGTREE_MAXDEPTH - 1]; - jpc_tagtreenode_t **stkptr; - jpc_tagtreenode_t *node; - int low; - - assert(leaf); - assert(threshold >= 0); - - /* Traverse to the root of the tree, recording the path taken. */ - stkptr = stk; - node = leaf; - while (node->parent_) { - *stkptr++ = node; - node = node->parent_; - } - - low = 0; - for (;;) { - if (low > node->low_) { - /* Deferred propagation of the lower bound downward in - the tree. */ - node->low_ = low; - } else { - low = node->low_; - } - - while (low < threshold) { - if (low >= node->value_) { - if (!node->known_) { - if (jpc_bitstream_putbit(out, 1) == EOF) { - return -1; - } - node->known_ = 1; - } - break; - } - if (jpc_bitstream_putbit(out, 0) == EOF) { - return -1; - } - ++low; - } - node->low_ = low; - if (stkptr == stk) { - break; - } - node = *--stkptr; - - } - return (leaf->low_ < threshold) ? 1 : 0; + jpc_tagtreenode_t *stk[JPC_TAGTREE_MAXDEPTH - 1]; + jpc_tagtreenode_t **stkptr; + jpc_tagtreenode_t *node; + int low; + + assert(leaf); + assert(threshold >= 0); + + /* Traverse to the root of the tree, recording the path taken. */ + stkptr = stk; + node = leaf; + while (node->parent_) { + *stkptr++ = node; + node = node->parent_; + } + + low = 0; + for (;;) { + if (low > node->low_) { + /* Deferred propagation of the lower bound downward in + the tree. */ + node->low_ = low; + } else { + low = node->low_; + } + + while (low < threshold) { + if (low >= node->value_) { + if (!node->known_) { + if (jpc_bitstream_putbit(out, 1) == EOF) { + return -1; + } + node->known_ = 1; + } + break; + } + if (jpc_bitstream_putbit(out, 0) == EOF) { + return -1; + } + ++low; + } + node->low_ = low; + if (stkptr == stk) { + break; + } + node = *--stkptr; + + } + return (leaf->low_ < threshold) ? 1 : 0; } @@ -363,47 +363,47 @@ int jpc_tagtree_encode(jpc_tagtree_t *tree, jpc_tagtreenode_t *leaf, int thresho int jpc_tagtree_decode(jpc_tagtree_t *tree, jpc_tagtreenode_t *leaf, int threshold, jpc_bitstream_t *in) { - jpc_tagtreenode_t *stk[JPC_TAGTREE_MAXDEPTH - 1]; - jpc_tagtreenode_t **stkptr; - jpc_tagtreenode_t *node; - int low; - int ret; - - assert(threshold >= 0); - - /* Traverse to the root of the tree, recording the path taken. */ - stkptr = stk; - node = leaf; - while (node->parent_) { - *stkptr++ = node; - node = node->parent_; - } - - low = 0; - for (;;) { - if (low > node->low_) { - node->low_ = low; - } else { - low = node->low_; - } - while (low < threshold && low < node->value_) { - if ((ret = jpc_bitstream_getbit(in)) < 0) { - return -1; - } - if (ret) { - node->value_ = low; - } else { - ++low; - } - } - node->low_ = low; - if (stkptr == stk) { - break; - } - node = *--stkptr; - } - - return (node->value_ < threshold) ? 1 : 0; + jpc_tagtreenode_t *stk[JPC_TAGTREE_MAXDEPTH - 1]; + jpc_tagtreenode_t **stkptr; + jpc_tagtreenode_t *node; + int low; + int ret; + + assert(threshold >= 0); + + /* Traverse to the root of the tree, recording the path taken. */ + stkptr = stk; + node = leaf; + while (node->parent_) { + *stkptr++ = node; + node = node->parent_; + } + + low = 0; + for (;;) { + if (low > node->low_) { + node->low_ = low; + } else { + low = node->low_; + } + while (low < threshold && low < node->value_) { + if ((ret = jpc_bitstream_getbit(in)) < 0) { + return -1; + } + if (ret) { + node->value_ = low; + } else { + ++low; + } + } + node->low_ = low; + if (stkptr == stk) { + break; + } + node = *--stkptr; + } + + return (node->value_ < threshold) ? 1 : 0; } /******************************************************************************\ @@ -412,15 +412,15 @@ int jpc_tagtree_decode(jpc_tagtree_t *tree, jpc_tagtreenode_t *leaf, int thresho void jpc_tagtree_dump(jpc_tagtree_t *tree, FILE *out) { - jpc_tagtreenode_t *node; - int n; - - node = tree->nodes_; - n = tree->numnodes_; - while (--n >= 0) { - fprintf(out, "node %p, parent %p, value %d, lower %d, known %d\n", - (void *) node, (void *) node->parent_, node->value_, node->low_, - node->known_); - ++node; - } + jpc_tagtreenode_t *node; + int n; + + node = tree->nodes_; + n = tree->numnodes_; + while (--n >= 0) { + fprintf(out, "node %p, parent %p, value %d, lower %d, known %d\n", + (void *) node, (void *) node->parent_, node->value_, node->low_, + node->known_); + ++node; + } } diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.h b/converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.h index 1892b13f..cf1dc652 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_tagtree.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -133,7 +133,7 @@ \******************************************************************************/ /* The maximum allowable depth for a tag tree. */ -#define JPC_TAGTREE_MAXDEPTH 32 +#define JPC_TAGTREE_MAXDEPTH 32 /******************************************************************************\ * Types @@ -145,17 +145,17 @@ typedef struct jpc_tagtreenode_ { - /* The parent of this node. */ - struct jpc_tagtreenode_ *parent_; + /* The parent of this node. */ + struct jpc_tagtreenode_ *parent_; - /* The value associated with this node. */ - int value_; + /* The value associated with this node. */ + int value_; - /* The lower bound on the value associated with this node. */ - int low_; + /* The lower bound on the value associated with this node. */ + int low_; - /* A flag indicating if the value is known exactly. */ - int known_; + /* A flag indicating if the value is known exactly. */ + int known_; } jpc_tagtreenode_t; @@ -165,17 +165,17 @@ typedef struct jpc_tagtreenode_ { typedef struct { - /* The number of leaves in the horizontal direction. */ - int numleafsh_; + /* The number of leaves in the horizontal direction. */ + int numleafsh_; - /* The number of leaves in the vertical direction. */ - int numleafsv_; + /* The number of leaves in the vertical direction. */ + int numleafsv_; - /* The total number of nodes in the tree. */ - int numnodes_; + /* The total number of nodes in the tree. */ + int numnodes_; - /* The nodes. */ - jpc_tagtreenode_t *nodes_; + /* The nodes. */ + jpc_tagtreenode_t *nodes_; } jpc_tagtree_t; diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.c b/converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.c index f7d66b57..a5772c53 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -134,8 +134,8 @@ * \******************************************************************************/ -#define bandnotovind(tsfbnode, x) ((x) / (tsfbnode)->numhchans) -#define bandnotohind(tsfbnode, x) ((x) % (tsfbnode)->numhchans) +#define bandnotovind(tsfbnode, x) ((x) / (tsfbnode)->numhchans) +#define bandnotohind(tsfbnode, x) ((x) % (tsfbnode)->numhchans) static jpc_tsfb_t *jpc_tsfb_create(void); static jpc_tsfbnode_t *jpc_tsfbnode_create(void); @@ -158,74 +158,74 @@ static int jpc_tsfbnode_getequivfilters(jpc_tsfbnode_t *tsfbnode, int cldind, jpc_tsfb_t *jpc_tsfb_wavelet(jpc_qmfb1d_t *hqmfb, jpc_qmfb1d_t *vqmfb, int numdlvls) { - jpc_tsfb_t *tsfb; - int dlvlno; - jpc_tsfbnode_t *curnode; - jpc_tsfbnode_t *prevnode; - int childno; - if (!(tsfb = jpc_tsfb_create())) { - return 0; - } - prevnode = 0; - for (dlvlno = 0; dlvlno < numdlvls; ++dlvlno) { - if (!(curnode = jpc_tsfbnode_create())) { - jpc_tsfb_destroy(tsfb); - return 0; - } - if (prevnode) { - prevnode->children[0] = curnode; - ++prevnode->numchildren; - curnode->parent = prevnode; - } else { - tsfb->root = curnode; - curnode->parent = 0; - } - if (hqmfb) { - curnode->numhchans = jpc_qmfb1d_getnumchans(hqmfb); - if (!(curnode->hqmfb = jpc_qmfb1d_copy(hqmfb))) { - jpc_tsfb_destroy(tsfb); - return 0; - } - } else { - curnode->hqmfb = 0; - curnode->numhchans = 1; - } - if (vqmfb) { - curnode->numvchans = jpc_qmfb1d_getnumchans(vqmfb); - if (!(curnode->vqmfb = jpc_qmfb1d_copy(vqmfb))) { - jpc_tsfb_destroy(tsfb); - return 0; - } - } else { - curnode->vqmfb = 0; - curnode->numvchans = 1; - } - curnode->maxchildren = curnode->numhchans * curnode->numvchans; - for (childno = 0; childno < curnode->maxchildren; - ++childno) { - curnode->children[childno] = 0; - } - prevnode = curnode; - } - return tsfb; + jpc_tsfb_t *tsfb; + int dlvlno; + jpc_tsfbnode_t *curnode; + jpc_tsfbnode_t *prevnode; + int childno; + if (!(tsfb = jpc_tsfb_create())) { + return 0; + } + prevnode = 0; + for (dlvlno = 0; dlvlno < numdlvls; ++dlvlno) { + if (!(curnode = jpc_tsfbnode_create())) { + jpc_tsfb_destroy(tsfb); + return 0; + } + if (prevnode) { + prevnode->children[0] = curnode; + ++prevnode->numchildren; + curnode->parent = prevnode; + } else { + tsfb->root = curnode; + curnode->parent = 0; + } + if (hqmfb) { + curnode->numhchans = jpc_qmfb1d_getnumchans(hqmfb); + if (!(curnode->hqmfb = jpc_qmfb1d_copy(hqmfb))) { + jpc_tsfb_destroy(tsfb); + return 0; + } + } else { + curnode->hqmfb = 0; + curnode->numhchans = 1; + } + if (vqmfb) { + curnode->numvchans = jpc_qmfb1d_getnumchans(vqmfb); + if (!(curnode->vqmfb = jpc_qmfb1d_copy(vqmfb))) { + jpc_tsfb_destroy(tsfb); + return 0; + } + } else { + curnode->vqmfb = 0; + curnode->numvchans = 1; + } + curnode->maxchildren = curnode->numhchans * curnode->numvchans; + for (childno = 0; childno < curnode->maxchildren; + ++childno) { + curnode->children[childno] = 0; + } + prevnode = curnode; + } + return tsfb; } static jpc_tsfb_t *jpc_tsfb_create() { - jpc_tsfb_t *tsfb; - if (!(tsfb = jas_malloc(sizeof(jpc_tsfb_t)))) { - return 0; - } - tsfb->root = 0; - return tsfb; + jpc_tsfb_t *tsfb; + if (!(tsfb = jas_malloc(sizeof(jpc_tsfb_t)))) { + return 0; + } + tsfb->root = 0; + return tsfb; } void jpc_tsfb_destroy(jpc_tsfb_t *tsfb) { - if (tsfb->root) { - jpc_tsfbnode_destroy(tsfb->root); - } - jas_free(tsfb); + if (tsfb->root) { + jpc_tsfbnode_destroy(tsfb->root); + } + jas_free(tsfb); } /******************************************************************************\ @@ -234,83 +234,83 @@ void jpc_tsfb_destroy(jpc_tsfb_t *tsfb) void jpc_tsfb_analyze(jpc_tsfb_t *tsfb, int flags, jas_seq2d_t *x) { - if (tsfb->root) { - jpc_tsfbnode_analyze(tsfb->root, flags, x); - } + if (tsfb->root) { + jpc_tsfbnode_analyze(tsfb->root, flags, x); + } } static void jpc_tsfbnode_analyze(jpc_tsfbnode_t *node, int flags, jas_seq2d_t *x) { - jpc_tsfbnodeband_t nodebands[JPC_TSFB_MAXBANDSPERNODE]; - int numbands; - jas_seq2d_t *y; - int bandno; - jpc_tsfbnodeband_t *band; - - if (node->vqmfb) { - jpc_qmfb1d_analyze(node->vqmfb, flags | JPC_QMFB1D_VERT, x); - } - if (node->hqmfb) { - jpc_qmfb1d_analyze(node->hqmfb, flags, x); - } - if (node->numchildren > 0) { - qmfb2d_getbands(node->hqmfb, node->vqmfb, jas_seq2d_xstart(x), - jas_seq2d_ystart(x), jas_seq2d_xend(x), jas_seq2d_yend(x), - JPC_TSFB_MAXBANDSPERNODE, &numbands, nodebands); - y = jas_seq2d_create(0, 0, 0, 0); - assert(y); - for (bandno = 0, band = nodebands; bandno < numbands; ++bandno, ++band) { - if (node->children[bandno]) { - if (band->xstart != band->xend && band->ystart != band->yend) { - jas_seq2d_bindsub(y, x, band->locxstart, band->locystart, - band->locxend, band->locyend); - jas_seq2d_setshift(y, band->xstart, band->ystart); - jpc_tsfbnode_analyze(node->children[bandno], flags, y); - } - } - } - jas_matrix_destroy(y); - } + jpc_tsfbnodeband_t nodebands[JPC_TSFB_MAXBANDSPERNODE]; + int numbands; + jas_seq2d_t *y; + int bandno; + jpc_tsfbnodeband_t *band; + + if (node->vqmfb) { + jpc_qmfb1d_analyze(node->vqmfb, flags | JPC_QMFB1D_VERT, x); + } + if (node->hqmfb) { + jpc_qmfb1d_analyze(node->hqmfb, flags, x); + } + if (node->numchildren > 0) { + qmfb2d_getbands(node->hqmfb, node->vqmfb, jas_seq2d_xstart(x), + jas_seq2d_ystart(x), jas_seq2d_xend(x), jas_seq2d_yend(x), + JPC_TSFB_MAXBANDSPERNODE, &numbands, nodebands); + y = jas_seq2d_create(0, 0, 0, 0); + assert(y); + for (bandno = 0, band = nodebands; bandno < numbands; ++bandno, ++band) { + if (node->children[bandno]) { + if (band->xstart != band->xend && band->ystart != band->yend) { + jas_seq2d_bindsub(y, x, band->locxstart, band->locystart, + band->locxend, band->locyend); + jas_seq2d_setshift(y, band->xstart, band->ystart); + jpc_tsfbnode_analyze(node->children[bandno], flags, y); + } + } + } + jas_matrix_destroy(y); + } } void jpc_tsfb_synthesize(jpc_tsfb_t *tsfb, int flags, jas_seq2d_t *x) { - if (tsfb->root) { - jpc_tsfbnode_synthesize(tsfb->root, flags, x); - } + if (tsfb->root) { + jpc_tsfbnode_synthesize(tsfb->root, flags, x); + } } static void jpc_tsfbnode_synthesize(jpc_tsfbnode_t *node, int flags, jas_seq2d_t *x) { - jpc_tsfbnodeband_t nodebands[JPC_TSFB_MAXBANDSPERNODE]; - int numbands; - jas_seq2d_t *y; - int bandno; - jpc_tsfbnodeband_t *band; - - if (node->numchildren > 0) { - qmfb2d_getbands(node->hqmfb, node->vqmfb, jas_seq2d_xstart(x), - jas_seq2d_ystart(x), jas_seq2d_xend(x), jas_seq2d_yend(x), - JPC_TSFB_MAXBANDSPERNODE, &numbands, nodebands); - y = jas_seq2d_create(0, 0, 0, 0); - for (bandno = 0, band = nodebands; bandno < numbands; ++bandno, ++band) { - if (node->children[bandno]) { - if (band->xstart != band->xend && band->ystart != band->yend) { - jas_seq2d_bindsub(y, x, band->locxstart, band->locystart, - band->locxend, band->locyend); - jas_seq2d_setshift(y, band->xstart, band->ystart); - jpc_tsfbnode_synthesize(node->children[bandno], flags, y); - } - } - } - jas_seq2d_destroy(y); - } - if (node->hqmfb) { - jpc_qmfb1d_synthesize(node->hqmfb, flags, x); - } - if (node->vqmfb) { - jpc_qmfb1d_synthesize(node->vqmfb, flags | JPC_QMFB1D_VERT, x); - } + jpc_tsfbnodeband_t nodebands[JPC_TSFB_MAXBANDSPERNODE]; + int numbands; + jas_seq2d_t *y; + int bandno; + jpc_tsfbnodeband_t *band; + + if (node->numchildren > 0) { + qmfb2d_getbands(node->hqmfb, node->vqmfb, jas_seq2d_xstart(x), + jas_seq2d_ystart(x), jas_seq2d_xend(x), jas_seq2d_yend(x), + JPC_TSFB_MAXBANDSPERNODE, &numbands, nodebands); + y = jas_seq2d_create(0, 0, 0, 0); + for (bandno = 0, band = nodebands; bandno < numbands; ++bandno, ++band) { + if (node->children[bandno]) { + if (band->xstart != band->xend && band->ystart != band->yend) { + jas_seq2d_bindsub(y, x, band->locxstart, band->locystart, + band->locxend, band->locyend); + jas_seq2d_setshift(y, band->xstart, band->ystart); + jpc_tsfbnode_synthesize(node->children[bandno], flags, y); + } + } + } + jas_seq2d_destroy(y); + } + if (node->hqmfb) { + jpc_qmfb1d_synthesize(node->hqmfb, flags, x); + } + if (node->vqmfb) { + jpc_qmfb1d_synthesize(node->vqmfb, flags | JPC_QMFB1D_VERT, x); + } } /******************************************************************************\ @@ -321,114 +321,114 @@ static void jpc_tsfbnode_synthesize(jpc_tsfbnode_t *node, int flags, jas_seq2d_t int jpc_tsfb_getbands(jpc_tsfb_t *tsfb, uint_fast32_t xstart, uint_fast32_t ystart, uint_fast32_t xend, uint_fast32_t yend, jpc_tsfb_band_t *bands) { - jpc_tsfb_band_t *savbands; - savbands = bands; - if (!tsfb->root) { - bands[0].xstart = xstart; - bands[0].ystart = ystart; - bands[0].xend = xend; - bands[0].yend = yend; - bands[0].locxstart = xstart; - bands[0].locystart = ystart; - bands[0].locxend = xend; - bands[0].locyend = yend; - bands[0].orient = JPC_TSFB_LL; - bands[0].synenergywt = JPC_FIX_ONE; - ++bands; - } else { - jpc_tsfbnode_getbandstree(tsfb->root, xstart, ystart, - xstart, ystart, xend, yend, &bands); - } - return bands - savbands; + jpc_tsfb_band_t *savbands; + savbands = bands; + if (!tsfb->root) { + bands[0].xstart = xstart; + bands[0].ystart = ystart; + bands[0].xend = xend; + bands[0].yend = yend; + bands[0].locxstart = xstart; + bands[0].locystart = ystart; + bands[0].locxend = xend; + bands[0].locyend = yend; + bands[0].orient = JPC_TSFB_LL; + bands[0].synenergywt = JPC_FIX_ONE; + ++bands; + } else { + jpc_tsfbnode_getbandstree(tsfb->root, xstart, ystart, + xstart, ystart, xend, yend, &bands); + } + return bands - savbands; } static void jpc_tsfbnode_getbandstree(jpc_tsfbnode_t *node, uint_fast32_t posxstart, uint_fast32_t posystart, uint_fast32_t xstart, uint_fast32_t ystart, uint_fast32_t xend, uint_fast32_t yend, jpc_tsfb_band_t **bands) { - jpc_tsfbnodeband_t nodebands[JPC_TSFB_MAXBANDSPERNODE]; - jpc_tsfbnodeband_t *nodeband; - int nodebandno; - int numnodebands; - jpc_tsfb_band_t *band; - jas_seq_t *hfilter; - jas_seq_t *vfilter; - - qmfb2d_getbands(node->hqmfb, node->vqmfb, xstart, ystart, xend, yend, - JPC_TSFB_MAXBANDSPERNODE, &numnodebands, nodebands); - if (node->numchildren > 0) { - for (nodebandno = 0, nodeband = nodebands; - nodebandno < numnodebands; ++nodebandno, ++nodeband) { - if (node->children[nodebandno]) { - jpc_tsfbnode_getbandstree(node->children[ - nodebandno], posxstart + - nodeband->locxstart - xstart, posystart + - nodeband->locystart - ystart, nodeband->xstart, - nodeband->ystart, nodeband->xend, - nodeband->yend, bands); - - } - } - } + jpc_tsfbnodeband_t nodebands[JPC_TSFB_MAXBANDSPERNODE]; + jpc_tsfbnodeband_t *nodeband; + int nodebandno; + int numnodebands; + jpc_tsfb_band_t *band; + jas_seq_t *hfilter; + jas_seq_t *vfilter; + + qmfb2d_getbands(node->hqmfb, node->vqmfb, xstart, ystart, xend, yend, + JPC_TSFB_MAXBANDSPERNODE, &numnodebands, nodebands); + if (node->numchildren > 0) { + for (nodebandno = 0, nodeband = nodebands; + nodebandno < numnodebands; ++nodebandno, ++nodeband) { + if (node->children[nodebandno]) { + jpc_tsfbnode_getbandstree(node->children[ + nodebandno], posxstart + + nodeband->locxstart - xstart, posystart + + nodeband->locystart - ystart, nodeband->xstart, + nodeband->ystart, nodeband->xend, + nodeband->yend, bands); + + } + } + } assert(numnodebands == 4 || numnodebands == 3); - for (nodebandno = 0, nodeband = nodebands; nodebandno < numnodebands; - ++nodebandno, ++nodeband) { - if (!node->children[nodebandno]) { - band = *bands; - band->xstart = nodeband->xstart; - band->ystart = nodeband->ystart; - band->xend = nodeband->xend; - band->yend = nodeband->yend; - band->locxstart = posxstart + nodeband->locxstart - - xstart; - band->locystart = posystart + nodeband->locystart - - ystart; - band->locxend = band->locxstart + band->xend - - band->xstart; - band->locyend = band->locystart + band->yend - - band->ystart; - if (numnodebands == 4) { - switch (nodebandno) { - case 0: - band->orient = JPC_TSFB_LL; - break; - case 1: - band->orient = JPC_TSFB_HL; - break; - case 2: - band->orient = JPC_TSFB_LH; - break; - case 3: - band->orient = JPC_TSFB_HH; - break; - default: - abort(); - break; - } - } else { - switch (nodebandno) { - case 0: - band->orient = JPC_TSFB_HL; - break; - case 1: - band->orient = JPC_TSFB_LH; - break; - case 2: - band->orient = JPC_TSFB_HH; - break; - default: - abort(); - break; - } - } - jpc_tsfbnode_getequivfilters(node, nodebandno, band->xend - band->xstart, band->yend - band->ystart, &hfilter, &vfilter); - band->synenergywt = jpc_fix_mul(jpc_seq_norm(hfilter), - jpc_seq_norm(vfilter)); - jas_seq_destroy(hfilter); - jas_seq_destroy(vfilter); - ++(*bands); - } - } + for (nodebandno = 0, nodeband = nodebands; nodebandno < numnodebands; + ++nodebandno, ++nodeband) { + if (!node->children[nodebandno]) { + band = *bands; + band->xstart = nodeband->xstart; + band->ystart = nodeband->ystart; + band->xend = nodeband->xend; + band->yend = nodeband->yend; + band->locxstart = posxstart + nodeband->locxstart - + xstart; + band->locystart = posystart + nodeband->locystart - + ystart; + band->locxend = band->locxstart + band->xend - + band->xstart; + band->locyend = band->locystart + band->yend - + band->ystart; + if (numnodebands == 4) { + switch (nodebandno) { + case 0: + band->orient = JPC_TSFB_LL; + break; + case 1: + band->orient = JPC_TSFB_HL; + break; + case 2: + band->orient = JPC_TSFB_LH; + break; + case 3: + band->orient = JPC_TSFB_HH; + break; + default: + abort(); + break; + } + } else { + switch (nodebandno) { + case 0: + band->orient = JPC_TSFB_HL; + break; + case 1: + band->orient = JPC_TSFB_LH; + break; + case 2: + band->orient = JPC_TSFB_HH; + break; + default: + abort(); + break; + } + } + jpc_tsfbnode_getequivfilters(node, nodebandno, band->xend - band->xstart, band->yend - band->ystart, &hfilter, &vfilter); + band->synenergywt = jpc_fix_mul(jpc_seq_norm(hfilter), + jpc_seq_norm(vfilter)); + jas_seq_destroy(hfilter); + jas_seq_destroy(vfilter); + ++(*bands); + } + } } /******************************************************************************\ @@ -437,37 +437,37 @@ assert(numnodebands == 4 || numnodebands == 3); static jpc_tsfbnode_t *jpc_tsfbnode_create() { - jpc_tsfbnode_t *node; - if (!(node = jas_malloc(sizeof(jpc_tsfbnode_t)))) { - return 0; - } - node->numhchans = 0; - node->numvchans = 0; - node->numchildren = 0; - node->maxchildren = 0; - node->hqmfb = 0; - node->vqmfb = 0; - node->parent = 0; - return node; + jpc_tsfbnode_t *node; + if (!(node = jas_malloc(sizeof(jpc_tsfbnode_t)))) { + return 0; + } + node->numhchans = 0; + node->numvchans = 0; + node->numchildren = 0; + node->maxchildren = 0; + node->hqmfb = 0; + node->vqmfb = 0; + node->parent = 0; + return node; } static void jpc_tsfbnode_destroy(jpc_tsfbnode_t *node) { - jpc_tsfbnode_t **child; - int childno; - for (childno = 0, child = node->children; childno < node->maxchildren; - ++childno, ++child) { - if (*child) { - jpc_tsfbnode_destroy(*child); - } - } - if (node->hqmfb) { - jpc_qmfb1d_destroy(node->hqmfb); - } - if (node->vqmfb) { - jpc_qmfb1d_destroy(node->vqmfb); - } - jas_free(node); + jpc_tsfbnode_t **child; + int childno; + for (childno = 0, child = node->children; childno < node->maxchildren; + ++childno, ++child) { + if (*child) { + jpc_tsfbnode_destroy(*child); + } + } + if (node->hqmfb) { + jpc_qmfb1d_destroy(node->hqmfb); + } + if (node->vqmfb) { + jpc_qmfb1d_destroy(node->vqmfb); + } + jas_free(node); } @@ -481,182 +481,182 @@ static void qmfb2d_getbands(jpc_qmfb1d_t *hqmfb, jpc_qmfb1d_t *vqmfb, uint_fast32_t xstart, uint_fast32_t ystart, uint_fast32_t xend, uint_fast32_t yend, int maxbands, int *numbandsptr, jpc_tsfbnodeband_t *bands) { - jpc_qmfb1dband_t hbands[JPC_QMFB1D_MAXCHANS]; - jpc_qmfb1dband_t vbands[JPC_QMFB1D_MAXCHANS]; - int numhbands; - int numvbands; - int numbands; - int bandno; - int hbandno; - int vbandno; - jpc_tsfbnodeband_t *band; - - if (hqmfb) { - jpc_qmfb1d_getbands(hqmfb, 0, xstart, ystart, xend, yend, - JPC_QMFB1D_MAXCHANS, &numhbands, hbands); - } else { - numhbands = 1; - hbands[0].start = xstart; - hbands[0].end = xend; - hbands[0].locstart = xstart; - hbands[0].locend = xend; - } - if (vqmfb) { - jpc_qmfb1d_getbands(vqmfb, JPC_QMFB1D_VERT, xstart, ystart, xend, - yend, JPC_QMFB1D_MAXCHANS, &numvbands, vbands); - } else { - numvbands = 1; - vbands[0].start = ystart; - vbands[0].end = yend; - vbands[0].locstart = ystart; - vbands[0].locend = yend; - } - numbands = numhbands * numvbands; - *numbandsptr = numbands; - for (bandno = 0, band = bands; bandno < numbands; ++bandno, ++band) { - hbandno = bandno % numhbands; - vbandno = bandno / numhbands; - band->xstart = hbands[hbandno].start; - band->ystart = vbands[vbandno].start; - band->xend = hbands[hbandno].end; - band->yend = vbands[vbandno].end; - band->locxstart = hbands[hbandno].locstart; - band->locystart = vbands[vbandno].locstart; - band->locxend = hbands[hbandno].locend; - band->locyend = vbands[vbandno].locend; - assert(band->xstart <= band->xend && - band->ystart <= band->yend); - if (band->xstart == band->xend) { - band->yend = band->ystart; - band->locyend = band->locystart; - } else if (band->ystart == band->yend) { - band->xend = band->xstart; - band->locxend = band->locxstart; - } - } + jpc_qmfb1dband_t hbands[JPC_QMFB1D_MAXCHANS]; + jpc_qmfb1dband_t vbands[JPC_QMFB1D_MAXCHANS]; + int numhbands; + int numvbands; + int numbands; + int bandno; + int hbandno; + int vbandno; + jpc_tsfbnodeband_t *band; + + if (hqmfb) { + jpc_qmfb1d_getbands(hqmfb, 0, xstart, ystart, xend, yend, + JPC_QMFB1D_MAXCHANS, &numhbands, hbands); + } else { + numhbands = 1; + hbands[0].start = xstart; + hbands[0].end = xend; + hbands[0].locstart = xstart; + hbands[0].locend = xend; + } + if (vqmfb) { + jpc_qmfb1d_getbands(vqmfb, JPC_QMFB1D_VERT, xstart, ystart, xend, + yend, JPC_QMFB1D_MAXCHANS, &numvbands, vbands); + } else { + numvbands = 1; + vbands[0].start = ystart; + vbands[0].end = yend; + vbands[0].locstart = ystart; + vbands[0].locend = yend; + } + numbands = numhbands * numvbands; + *numbandsptr = numbands; + for (bandno = 0, band = bands; bandno < numbands; ++bandno, ++band) { + hbandno = bandno % numhbands; + vbandno = bandno / numhbands; + band->xstart = hbands[hbandno].start; + band->ystart = vbands[vbandno].start; + band->xend = hbands[hbandno].end; + band->yend = vbands[vbandno].end; + band->locxstart = hbands[hbandno].locstart; + band->locystart = vbands[vbandno].locstart; + band->locxend = hbands[hbandno].locend; + band->locyend = vbands[vbandno].locend; + assert(band->xstart <= band->xend && + band->ystart <= band->yend); + if (band->xstart == band->xend) { + band->yend = band->ystart; + band->locyend = band->locystart; + } else if (band->ystart == band->yend) { + band->xend = band->xstart; + band->locxend = band->locxstart; + } + } } static int jpc_tsfbnode_getequivfilters(jpc_tsfbnode_t *tsfbnode, int cldind, int width, int height, jas_seq_t **hfilter, jas_seq_t **vfilter) { - jas_seq_t *hseq; - jas_seq_t *vseq; - jpc_tsfbnode_t *node; - jas_seq2d_t *hfilters[JPC_QMFB1D_MAXCHANS]; - jas_seq2d_t *vfilters[JPC_QMFB1D_MAXCHANS]; - int numhchans; - int numvchans; - jas_seq_t *tmpseq; - - hseq = 0; - vseq = 0; - - if (!(hseq = jas_seq_create(0, 1))) { - goto error; - } - jas_seq_set(hseq, 0, jpc_inttofix(1)); - if (!(vseq = jas_seq_create(0, 1))) { - goto error; - } - jas_seq_set(vseq, 0, jpc_inttofix(1)); - - node = tsfbnode; - while (node) { - if (node->hqmfb) { - numhchans = jpc_qmfb1d_getnumchans(node->hqmfb); - if (jpc_qmfb1d_getsynfilters(node->hqmfb, width, hfilters)) { - goto error; - } - if (!(tmpseq = jpc_seq_upsample(hseq, numhchans))) { - goto error; - } - jas_seq_destroy(hseq); - hseq = tmpseq; - if (!(tmpseq = jpc_seq_conv(hseq, hfilters[bandnotohind(node, cldind)]))) { - goto error; - } - jas_seq_destroy(hfilters[0]); - jas_seq_destroy(hfilters[1]); - jas_seq_destroy(hseq); - hseq = tmpseq; - } - if (node->vqmfb) { - numvchans = jpc_qmfb1d_getnumchans(node->vqmfb); - if (jpc_qmfb1d_getsynfilters(node->vqmfb, height, vfilters)) { - abort(); - } - if (!(tmpseq = jpc_seq_upsample(vseq, numvchans))) { - goto error; - } - jas_seq_destroy(vseq); - vseq = tmpseq; - if (!(tmpseq = jpc_seq_conv(vseq, vfilters[bandnotovind(node, cldind)]))) { - goto error; - } - jas_seq_destroy(vfilters[0]); - jas_seq_destroy(vfilters[1]); - jas_seq_destroy(vseq); - vseq = tmpseq; - } - if (node->parent) { - cldind = jpc_tsfbnode_findchild(node->parent, node); - } - node = node->parent; - } - - *hfilter = hseq; - *vfilter = vseq; - - return 0; + jas_seq_t *hseq; + jas_seq_t *vseq; + jpc_tsfbnode_t *node; + jas_seq2d_t *hfilters[JPC_QMFB1D_MAXCHANS]; + jas_seq2d_t *vfilters[JPC_QMFB1D_MAXCHANS]; + int numhchans; + int numvchans; + jas_seq_t *tmpseq; + + hseq = 0; + vseq = 0; + + if (!(hseq = jas_seq_create(0, 1))) { + goto error; + } + jas_seq_set(hseq, 0, jpc_inttofix(1)); + if (!(vseq = jas_seq_create(0, 1))) { + goto error; + } + jas_seq_set(vseq, 0, jpc_inttofix(1)); + + node = tsfbnode; + while (node) { + if (node->hqmfb) { + numhchans = jpc_qmfb1d_getnumchans(node->hqmfb); + if (jpc_qmfb1d_getsynfilters(node->hqmfb, width, hfilters)) { + goto error; + } + if (!(tmpseq = jpc_seq_upsample(hseq, numhchans))) { + goto error; + } + jas_seq_destroy(hseq); + hseq = tmpseq; + if (!(tmpseq = jpc_seq_conv(hseq, hfilters[bandnotohind(node, cldind)]))) { + goto error; + } + jas_seq_destroy(hfilters[0]); + jas_seq_destroy(hfilters[1]); + jas_seq_destroy(hseq); + hseq = tmpseq; + } + if (node->vqmfb) { + numvchans = jpc_qmfb1d_getnumchans(node->vqmfb); + if (jpc_qmfb1d_getsynfilters(node->vqmfb, height, vfilters)) { + abort(); + } + if (!(tmpseq = jpc_seq_upsample(vseq, numvchans))) { + goto error; + } + jas_seq_destroy(vseq); + vseq = tmpseq; + if (!(tmpseq = jpc_seq_conv(vseq, vfilters[bandnotovind(node, cldind)]))) { + goto error; + } + jas_seq_destroy(vfilters[0]); + jas_seq_destroy(vfilters[1]); + jas_seq_destroy(vseq); + vseq = tmpseq; + } + if (node->parent) { + cldind = jpc_tsfbnode_findchild(node->parent, node); + } + node = node->parent; + } + + *hfilter = hseq; + *vfilter = vseq; + + return 0; error: - if (hseq) { - jas_seq_destroy(hseq); - } - if (vseq) { - jas_seq_destroy(vseq); - } - return -1; + if (hseq) { + jas_seq_destroy(hseq); + } + if (vseq) { + jas_seq_destroy(vseq); + } + return -1; } static int jpc_tsfbnode_findchild(jpc_tsfbnode_t *parnode, jpc_tsfbnode_t *cldnode) { - int i; - - for (i = 0; i < parnode->maxchildren; i++) { - if (parnode->children[i] == cldnode) - return i; - } - assert(0); - return -1; + int i; + + for (i = 0; i < parnode->maxchildren; i++) { + if (parnode->children[i] == cldnode) + return i; + } + assert(0); + return -1; } jpc_tsfb_t *jpc_cod_gettsfb(int qmfbid, int numlevels) { - jpc_tsfb_t *tsfb; - - switch (qmfbid) { - case JPC_COX_RFT: - qmfbid = JPC_QMFB1D_FT; - break; - case JPC_COX_INS: - qmfbid = JPC_QMFB1D_NS; - break; - default: - assert(0); - qmfbid = 10; - break; - } + jpc_tsfb_t *tsfb; + + switch (qmfbid) { + case JPC_COX_RFT: + qmfbid = JPC_QMFB1D_FT; + break; + case JPC_COX_INS: + qmfbid = JPC_QMFB1D_NS; + break; + default: + assert(0); + qmfbid = 10; + break; + } { - jpc_qmfb1d_t *hqmfb; - hqmfb = jpc_qmfb1d_make(qmfbid); - assert(hqmfb); - tsfb = jpc_tsfb_wavelet(hqmfb, hqmfb, numlevels); - assert(tsfb); - jpc_qmfb1d_destroy(hqmfb); + jpc_qmfb1d_t *hqmfb; + hqmfb = jpc_qmfb1d_make(qmfbid); + assert(hqmfb); + tsfb = jpc_tsfb_wavelet(hqmfb, hqmfb, numlevels); + assert(tsfb); + jpc_qmfb1d_destroy(hqmfb); } - return tsfb; + return tsfb; } diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.h b/converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.h index 8670c22e..3558cadb 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_tsfb.h @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -132,19 +132,19 @@ * Constants. \******************************************************************************/ -#define JPC_TSFB_MAXBANDS (JPC_TSFB_MAXDEPTH * 3 + 1) -#define JPC_TSFB_MAXDEPTH 32 -#define JPC_TSFB_RITIMODE JPC_QMFB1D_RITIMODE +#define JPC_TSFB_MAXBANDS (JPC_TSFB_MAXDEPTH * 3 + 1) +#define JPC_TSFB_MAXDEPTH 32 +#define JPC_TSFB_RITIMODE JPC_QMFB1D_RITIMODE -#define JPC_TSFB_MAXBANDSPERNODE (JPC_QMFB1D_MAXCHANS * JPC_QMFB1D_MAXCHANS) +#define JPC_TSFB_MAXBANDSPERNODE (JPC_QMFB1D_MAXCHANS * JPC_QMFB1D_MAXCHANS) -#define JPC_TSFB_PRUNEVERT 0x01 -#define JPC_TSFB_PRUNEHORZ 0x02 +#define JPC_TSFB_PRUNEVERT 0x01 +#define JPC_TSFB_PRUNEHORZ 0x02 -#define JPC_TSFB_LL 0 -#define JPC_TSFB_LH 1 -#define JPC_TSFB_HL 2 -#define JPC_TSFB_HH 3 +#define JPC_TSFB_LL 0 +#define JPC_TSFB_LH 1 +#define JPC_TSFB_HL 2 +#define JPC_TSFB_HH 3 /******************************************************************************\ * Types. @@ -152,45 +152,45 @@ typedef struct { - int xstart; - int ystart; - int xend; - int yend; - int locxstart; - int locystart; - int locxend; - int locyend; + int xstart; + int ystart; + int xend; + int yend; + int locxstart; + int locystart; + int locxend; + int locyend; } jpc_tsfbnodeband_t; typedef struct jpc_tsfbnode_s { - int numhchans; - int numvchans; - jpc_qmfb1d_t *hqmfb; - jpc_qmfb1d_t *vqmfb; - int maxchildren; - int numchildren; - struct jpc_tsfbnode_s *children[JPC_TSFB_MAXBANDSPERNODE]; - struct jpc_tsfbnode_s *parent; + int numhchans; + int numvchans; + jpc_qmfb1d_t *hqmfb; + jpc_qmfb1d_t *vqmfb; + int maxchildren; + int numchildren; + struct jpc_tsfbnode_s *children[JPC_TSFB_MAXBANDSPERNODE]; + struct jpc_tsfbnode_s *parent; } jpc_tsfbnode_t; typedef struct { - jpc_tsfbnode_t *root; + jpc_tsfbnode_t *root; } jpc_tsfb_t; typedef struct { - int xstart; - int ystart; - int xend; - int yend; - int orient; - int locxstart; - int locystart; - int locxend; - int locyend; - jpc_fix_t synenergywt; + int xstart; + int ystart; + int xend; + int yend; + int orient; + int locxstart; + int locystart; + int locxend; + int locyend; + jpc_fix_t synenergywt; } jpc_tsfb_band_t; /******************************************************************************\ diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_util.c b/converter/other/jpeg2000/libjasper/jpc/jpc_util.c index e6e3942a..12a41c3f 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_util.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_util.c @@ -139,32 +139,32 @@ static unsigned int countOfTokens(const char * const s, - const char * const delim) { + const char * const delim) { - unsigned int n; - char buf[4096]; - const char * cp; + unsigned int n; + char buf[4096]; + const char * cp; - strncpy(buf, s, sizeof(buf)); - buf[sizeof(buf) - 1] = '\0'; - n = 0; /* initial value */ - if ((cp = strtok(buf, delim))) { - ++n; - while ((cp = strtok(0, delim))) { - if (cp[0] != '\0') { - ++n; - } - } - } - return n; + strncpy(buf, s, sizeof(buf)); + buf[sizeof(buf) - 1] = '\0'; + n = 0; /* initial value */ + if ((cp = strtok(buf, delim))) { + ++n; + while ((cp = strtok(0, delim))) { + if (cp[0] != '\0') { + ++n; + } + } + } + return n; } int jpc_atoaf(const char * const s, - int * const numvaluesP, - double ** const valuesP) { + int * const numvaluesP, + double ** const valuesP) { /*---------------------------------------------------------------------------- Parse a string like "3.2,9,-5". Return as *numvaluesP the number of values in the string and as *valuesP a malloced array of the values. @@ -173,96 +173,96 @@ jpc_atoaf(const char * const s, Delimiters can be comma as in the example or space, tab, or newline. -----------------------------------------------------------------------------*/ - char const delim[] = ", \t\n"; + char const delim[] = ", \t\n"; - unsigned int const valueCt = countOfTokens(s, delim); + unsigned int const valueCt = countOfTokens(s, delim); - if (valueCt > 0) { - unsigned int i; - double * vs; - const char * cp; - char buf[4096]; + if (valueCt > 0) { + unsigned int i; + double * vs; + const char * cp; + char buf[4096]; - if (!(vs = jas_malloc(valueCt * sizeof(double)))) { - return -1; - } + if (!(vs = jas_malloc(valueCt * sizeof(double)))) { + return -1; + } - strncpy(buf, s, sizeof(buf)); - buf[sizeof(buf) - 1] = '\0'; - i = 0; - if ((cp = strtok(buf, delim))) { - vs[i] = atof(cp); - ++i; - while ((cp = strtok(0, delim))) { - if (cp[0] != '\0') { - vs[i] = atof(cp); - ++i; - } - } - } - assert(i == valueCt); - *numvaluesP = valueCt; - *valuesP = vs; - } else { - *valuesP = NULL; - *numvaluesP = 0; - } - return 0; + strncpy(buf, s, sizeof(buf)); + buf[sizeof(buf) - 1] = '\0'; + i = 0; + if ((cp = strtok(buf, delim))) { + vs[i] = atof(cp); + ++i; + while ((cp = strtok(0, delim))) { + if (cp[0] != '\0') { + vs[i] = atof(cp); + ++i; + } + } + } + assert(i == valueCt); + *numvaluesP = valueCt; + *valuesP = vs; + } else { + *valuesP = NULL; + *numvaluesP = 0; + } + return 0; } jas_seq_t *jpc_seq_upsample(jas_seq_t *x, int m) { - jas_seq_t *z; - int i; + jas_seq_t *z; + int i; - if (!(z = jas_seq_create(jas_seq_start(x) * m, (jas_seq_end(x) - 1) * m + 1))) - return 0; - for (i = jas_seq_start(z); i < jas_seq_end(z); i++) { - *jas_seq_getref(z, i) = (!JAS_MOD(i, m)) ? jas_seq_get(x, i / m) : - jpc_inttofix(0); - } + if (!(z = jas_seq_create(jas_seq_start(x) * m, (jas_seq_end(x) - 1) * m + 1))) + return 0; + for (i = jas_seq_start(z); i < jas_seq_end(z); i++) { + *jas_seq_getref(z, i) = (!JAS_MOD(i, m)) ? jas_seq_get(x, i / m) : + jpc_inttofix(0); + } - return z; + return z; } jpc_fix_t jpc_seq_norm(jas_seq_t *x) { - jpc_fix_t s; - int i; + jpc_fix_t s; + int i; - s = jpc_inttofix(0); - for (i = jas_seq_start(x); i < jas_seq_end(x); i++) { - s = jpc_fix_add(s, jpc_fix_mul(jas_seq_get(x, i), jas_seq_get(x, i))); - } + s = jpc_inttofix(0); + for (i = jas_seq_start(x); i < jas_seq_end(x); i++) { + s = jpc_fix_add(s, jpc_fix_mul(jas_seq_get(x, i), jas_seq_get(x, i))); + } - return jpc_dbltofix(sqrt(jpc_fixtodbl(s))); + return jpc_dbltofix(sqrt(jpc_fixtodbl(s))); } jas_seq_t *jpc_seq_conv(jas_seq_t *x, jas_seq_t *y) { - int i; - int j; - int k; - jas_seq_t *z; - jpc_fix_t s; - jpc_fix_t v; + int i; + int j; + int k; + jas_seq_t *z; + jpc_fix_t s; + jpc_fix_t v; - z = jas_seq_create(jas_seq_start(x) + jas_seq_start(y), - jas_seq_end(x) + jas_seq_end(y) - 1); - assert(z); - for (i = jas_seq_start(z); i < jas_seq_end(z); i++) { - s = jpc_inttofix(0); - for (j = jas_seq_start(y); j < jas_seq_end(y); j++) { - k = i - j; - if (k < jas_seq_start(x) || k >= jas_seq_end(x)) { - v = JPC_FIX_ZERO; - } else { - v = jas_seq_get(x, k); - } - s = jpc_fix_add(s, jpc_fix_mul(jas_seq_get(y, j), v)); - } - *jas_seq_getref(z, i) = s; - } + z = jas_seq_create(jas_seq_start(x) + jas_seq_start(y), + jas_seq_end(x) + jas_seq_end(y) - 1); + assert(z); + for (i = jas_seq_start(z); i < jas_seq_end(z); i++) { + s = jpc_inttofix(0); + for (j = jas_seq_start(y); j < jas_seq_end(y); j++) { + k = i - j; + if (k < jas_seq_start(x) || k >= jas_seq_end(x)) { + v = JPC_FIX_ZERO; + } else { + v = jas_seq_get(x, k); + } + s = jpc_fix_add(s, jpc_fix_mul(jas_seq_get(y, j), v)); + } + *jas_seq_getref(z, i) = s; + } - return z; + return z; } diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_util.h b/converter/other/jpeg2000/libjasper/jpc/jpc_util.h index c23fc33b..f1d90385 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_util.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_util.h @@ -4,14 +4,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -19,22 +19,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -54,17 +54,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -104,7 +104,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ -- cgit 1.4.1