Merge branch 't1_flag_optimizations'
This commit is contained in:
commit
9cbc9903c3
|
@ -38,8 +38,6 @@ set(OPENJPEG_SRCS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/opj_clock.h
|
${CMAKE_CURRENT_SOURCE_DIR}/opj_clock.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/pi.c
|
${CMAKE_CURRENT_SOURCE_DIR}/pi.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/pi.h
|
${CMAKE_CURRENT_SOURCE_DIR}/pi.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/raw.c
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/raw.h
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/t1.c
|
${CMAKE_CURRENT_SOURCE_DIR}/t1.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/t1.h
|
${CMAKE_CURRENT_SOURCE_DIR}/t1.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/t2.c
|
${CMAKE_CURRENT_SOURCE_DIR}/t2.c
|
||||||
|
|
|
@ -65,8 +65,6 @@ The functions in J2K.C have for goal to read/write the several parts of the code
|
||||||
#define J2K_CCP_QNTSTY_SIQNT 1
|
#define J2K_CCP_QNTSTY_SIQNT 1
|
||||||
#define J2K_CCP_QNTSTY_SEQNT 2
|
#define J2K_CCP_QNTSTY_SEQNT 2
|
||||||
|
|
||||||
#define OPJ_J2K_DEFAULT_CBLK_DATA_SIZE 8192
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
#define J2K_MS_SOC 0xff4f /**< SOC marker value */
|
#define J2K_MS_SOC 0xff4f /**< SOC marker value */
|
||||||
|
|
|
@ -38,6 +38,8 @@
|
||||||
|
|
||||||
#include "opj_includes.h"
|
#include "opj_includes.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
/** @defgroup MQC MQC - Implementation of an MQ-Coder */
|
/** @defgroup MQC MQC - Implementation of an MQ-Coder */
|
||||||
/*@{*/
|
/*@{*/
|
||||||
|
|
||||||
|
@ -269,19 +271,6 @@ static void opj_mqc_setbits(opj_mqc_t *mqc)
|
||||||
==========================================================
|
==========================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
opj_mqc_t* opj_mqc_create(void)
|
|
||||||
{
|
|
||||||
opj_mqc_t *mqc = (opj_mqc_t*)opj_malloc(sizeof(opj_mqc_t));
|
|
||||||
return mqc;
|
|
||||||
}
|
|
||||||
|
|
||||||
void opj_mqc_destroy(opj_mqc_t *mqc)
|
|
||||||
{
|
|
||||||
if (mqc) {
|
|
||||||
opj_free(mqc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OPJ_UINT32 opj_mqc_numbytes(opj_mqc_t *mqc)
|
OPJ_UINT32 opj_mqc_numbytes(opj_mqc_t *mqc)
|
||||||
{
|
{
|
||||||
const ptrdiff_t diff = mqc->bp - mqc->start;
|
const ptrdiff_t diff = mqc->bp - mqc->start;
|
||||||
|
@ -495,17 +484,35 @@ void opj_mqc_segmark_enc(opj_mqc_t *mqc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OPJ_BOOL opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len)
|
static void opj_mqc_init_dec_common(opj_mqc_t *mqc,
|
||||||
|
OPJ_BYTE *bp,
|
||||||
|
OPJ_UINT32 len,
|
||||||
|
OPJ_UINT32 extra_writable_bytes)
|
||||||
|
{
|
||||||
|
(void)extra_writable_bytes;
|
||||||
|
|
||||||
|
assert(extra_writable_bytes >= OPJ_COMMON_CBLK_DATA_EXTRA);
|
||||||
|
mqc->start = bp;
|
||||||
|
mqc->end = bp + len;
|
||||||
|
/* Insert an artificial 0xFF 0xFF marker at end of the code block */
|
||||||
|
/* data so that the bytein routines stop on it. This saves us comparing */
|
||||||
|
/* the bp and end pointers */
|
||||||
|
/* But before inserting it, backup th bytes we will overwrite */
|
||||||
|
memcpy(mqc->backup, mqc->end, OPJ_COMMON_CBLK_DATA_EXTRA);
|
||||||
|
mqc->end[0] = 0xFF;
|
||||||
|
mqc->end[1] = 0xFF;
|
||||||
|
mqc->bp = bp;
|
||||||
|
}
|
||||||
|
void opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len,
|
||||||
|
OPJ_UINT32 extra_writable_bytes)
|
||||||
{
|
{
|
||||||
/* Implements ISO 15444-1 C.3.5 Initialization of the decoder (INITDEC) */
|
/* Implements ISO 15444-1 C.3.5 Initialization of the decoder (INITDEC) */
|
||||||
/* Note: alternate "J.1 - Initialization of the software-conventions */
|
/* Note: alternate "J.1 - Initialization of the software-conventions */
|
||||||
/* decoder" has been tried, but does */
|
/* decoder" has been tried, but does */
|
||||||
/* not bring any improvement. */
|
/* not bring any improvement. */
|
||||||
/* See https://github.com/uclouvain/openjpeg/issues/921 */
|
/* See https://github.com/uclouvain/openjpeg/issues/921 */
|
||||||
|
opj_mqc_init_dec_common(mqc, bp, len, extra_writable_bytes);
|
||||||
opj_mqc_setcurctx(mqc, 0);
|
opj_mqc_setcurctx(mqc, 0);
|
||||||
mqc->start = bp;
|
|
||||||
mqc->end = bp + len;
|
|
||||||
mqc->bp = bp;
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
mqc->c = 0xff << 16;
|
mqc->c = 0xff << 16;
|
||||||
} else {
|
} else {
|
||||||
|
@ -516,7 +523,22 @@ OPJ_BOOL opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len)
|
||||||
mqc->c <<= 7;
|
mqc->c <<= 7;
|
||||||
mqc->ct -= 7;
|
mqc->ct -= 7;
|
||||||
mqc->a = 0x8000;
|
mqc->a = 0x8000;
|
||||||
return OPJ_TRUE;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void opj_mqc_raw_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len,
|
||||||
|
OPJ_UINT32 extra_writable_bytes)
|
||||||
|
{
|
||||||
|
opj_mqc_init_dec_common(mqc, bp, len, extra_writable_bytes);
|
||||||
|
mqc->c = 0;
|
||||||
|
mqc->ct = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void opq_mqc_finish_dec(opj_mqc_t *mqc)
|
||||||
|
{
|
||||||
|
/* Restore the bytes overwritten by opj_mqc_init_dec_common() */
|
||||||
|
memcpy(mqc->end, mqc->backup, OPJ_COMMON_CBLK_DATA_EXTRA);
|
||||||
}
|
}
|
||||||
|
|
||||||
void opj_mqc_resetstates(opj_mqc_t *mqc)
|
void opj_mqc_resetstates(opj_mqc_t *mqc)
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
|
|
||||||
#ifndef __MQC_H
|
#ifndef __MQC_H
|
||||||
#define __MQC_H
|
#define __MQC_H
|
||||||
|
|
||||||
|
#include "opj_common.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@file mqc.h
|
@file mqc.h
|
||||||
@brief Implementation of an MQ-Coder (MQC)
|
@brief Implementation of an MQ-Coder (MQC)
|
||||||
|
@ -69,15 +72,26 @@ typedef struct opj_mqc_state {
|
||||||
MQ coder
|
MQ coder
|
||||||
*/
|
*/
|
||||||
typedef struct opj_mqc {
|
typedef struct opj_mqc {
|
||||||
|
/** temporary buffer where bits are coded or decoded */
|
||||||
OPJ_UINT32 c;
|
OPJ_UINT32 c;
|
||||||
|
/** only used by MQ decoder */
|
||||||
OPJ_UINT32 a;
|
OPJ_UINT32 a;
|
||||||
|
/** number of bits already read or free to write */
|
||||||
OPJ_UINT32 ct;
|
OPJ_UINT32 ct;
|
||||||
|
/** pointer to the current position in the buffer */
|
||||||
OPJ_BYTE *bp;
|
OPJ_BYTE *bp;
|
||||||
|
/** pointer to the start of the buffer */
|
||||||
OPJ_BYTE *start;
|
OPJ_BYTE *start;
|
||||||
|
/** pointer to the end of the buffer */
|
||||||
OPJ_BYTE *end;
|
OPJ_BYTE *end;
|
||||||
|
/** Array of contexts */
|
||||||
opj_mqc_state_t *ctxs[MQC_NUMCTXS];
|
opj_mqc_state_t *ctxs[MQC_NUMCTXS];
|
||||||
|
/** Active context */
|
||||||
opj_mqc_state_t **curctx;
|
opj_mqc_state_t **curctx;
|
||||||
const OPJ_BYTE *lut_ctxno_zc_orient; /* lut_ctxno_zc shifted by 256 * bandno */
|
/* lut_ctxno_zc shifted by (1 << 9) * bandno */
|
||||||
|
const OPJ_BYTE* lut_ctxno_zc_orient;
|
||||||
|
/** Original value of the 2 bytes at end[0] and end[1] */
|
||||||
|
OPJ_BYTE backup[OPJ_COMMON_CBLK_DATA_EXTRA];
|
||||||
} opj_mqc_t;
|
} opj_mqc_t;
|
||||||
|
|
||||||
#include "mqc_inl.h"
|
#include "mqc_inl.h"
|
||||||
|
@ -85,16 +99,7 @@ typedef struct opj_mqc {
|
||||||
/** @name Exported functions */
|
/** @name Exported functions */
|
||||||
/*@{*/
|
/*@{*/
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/**
|
|
||||||
Create a new MQC handle
|
|
||||||
@return Returns a new MQC handle if successful, returns NULL otherwise
|
|
||||||
*/
|
|
||||||
opj_mqc_t* opj_mqc_create(void);
|
|
||||||
/**
|
|
||||||
Destroy a previously created MQC handle
|
|
||||||
@param mqc MQC handle to destroy
|
|
||||||
*/
|
|
||||||
void opj_mqc_destroy(opj_mqc_t *mqc);
|
|
||||||
/**
|
/**
|
||||||
Return the number of bytes written/read since initialisation
|
Return the number of bytes written/read since initialisation
|
||||||
@param mqc MQC handle
|
@param mqc MQC handle
|
||||||
|
@ -196,19 +201,66 @@ SEGMARK mode switch (SEGSYM)
|
||||||
@param mqc MQC handle
|
@param mqc MQC handle
|
||||||
*/
|
*/
|
||||||
void opj_mqc_segmark_enc(opj_mqc_t *mqc);
|
void opj_mqc_segmark_enc(opj_mqc_t *mqc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize the decoder
|
Initialize the decoder for MQ decoding.
|
||||||
|
|
||||||
|
opj_mqc_finish_dec() must be absolutely called after finishing the decoding
|
||||||
|
passes, so as to restore the bytes temporarily overwritten.
|
||||||
|
|
||||||
@param mqc MQC handle
|
@param mqc MQC handle
|
||||||
@param bp Pointer to the start of the buffer from which the bytes will be read
|
@param bp Pointer to the start of the buffer from which the bytes will be read
|
||||||
|
Note that OPJ_COMMON_CBLK_DATA_EXTRA bytes at the end of the buffer
|
||||||
|
will be temporarily overwritten with an artificial 0xFF 0xFF marker.
|
||||||
|
(they will be backuped in the mqc structure to be restored later)
|
||||||
|
So bp must be at least len + OPJ_COMMON_CBLK_DATA_EXTRA large, and
|
||||||
|
writable.
|
||||||
@param len Length of the input buffer
|
@param len Length of the input buffer
|
||||||
|
@param extra_writable_bytes Indicate how many bytes after len are writable.
|
||||||
|
This is to indicate your consent that bp must be
|
||||||
|
large enough.
|
||||||
*/
|
*/
|
||||||
OPJ_BOOL opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len);
|
void opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len,
|
||||||
|
OPJ_UINT32 extra_writable_bytes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initialize the decoder for RAW decoding.
|
||||||
|
|
||||||
|
opj_mqc_finish_dec() must be absolutely called after finishing the decoding
|
||||||
|
passes, so as to restore the bytes temporarily overwritten.
|
||||||
|
|
||||||
|
@param mqc MQC handle
|
||||||
|
@param bp Pointer to the start of the buffer from which the bytes will be read
|
||||||
|
Note that OPJ_COMMON_CBLK_DATA_EXTRA bytes at the end of the buffer
|
||||||
|
will be temporarily overwritten with an artificial 0xFF 0xFF marker.
|
||||||
|
(they will be backuped in the mqc structure to be restored later)
|
||||||
|
So bp must be at least len + OPJ_COMMON_CBLK_DATA_EXTRA large, and
|
||||||
|
writable.
|
||||||
|
@param len Length of the input buffer
|
||||||
|
@param extra_writable_bytes Indicate how many bytes after len are writable.
|
||||||
|
This is to indicate your consent that bp must be
|
||||||
|
large enough.
|
||||||
|
*/
|
||||||
|
void opj_mqc_raw_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len,
|
||||||
|
OPJ_UINT32 extra_writable_bytes);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Terminate RAW/MQC decoding
|
||||||
|
|
||||||
|
This restores the bytes temporarily overwritten by opj_mqc_init_dec()/
|
||||||
|
opj_mqc_raw_init_dec()
|
||||||
|
|
||||||
|
@param mqc MQC handle
|
||||||
|
*/
|
||||||
|
void opq_mqc_finish_dec(opj_mqc_t *mqc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Decode a symbol
|
Decode a symbol
|
||||||
@param mqc MQC handle
|
@param mqc MQC handle
|
||||||
@return Returns the decoded symbol (0 or 1)
|
@return Returns the decoded symbol (0 or 1)
|
||||||
*/
|
*/
|
||||||
static INLINE OPJ_INT32 opj_mqc_decode(opj_mqc_t * const mqc);
|
/*static INLINE OPJ_UINT32 opj_mqc_decode(opj_mqc_t * const mqc);*/
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
|
|
|
@ -38,126 +38,158 @@
|
||||||
|
|
||||||
#ifndef __MQC_INL_H
|
#ifndef __MQC_INL_H
|
||||||
#define __MQC_INL_H
|
#define __MQC_INL_H
|
||||||
|
|
||||||
|
/* For internal use of opj_mqc_decode_macro() */
|
||||||
|
#define opj_mqc_mpsexchange_macro(d, curctx, a) \
|
||||||
|
{ \
|
||||||
|
if (a < (*curctx)->qeval) { \
|
||||||
|
d = !((*curctx)->mps); \
|
||||||
|
*curctx = (*curctx)->nlps; \
|
||||||
|
} else { \
|
||||||
|
d = (*curctx)->mps; \
|
||||||
|
*curctx = (*curctx)->nmps; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/* For internal use of opj_mqc_decode_macro() */
|
||||||
|
#define opj_mqc_lpsexchange_macro(d, curctx, a) \
|
||||||
|
{ \
|
||||||
|
if (a < (*curctx)->qeval) { \
|
||||||
|
a = (*curctx)->qeval; \
|
||||||
|
d = (*curctx)->mps; \
|
||||||
|
*curctx = (*curctx)->nmps; \
|
||||||
|
} else { \
|
||||||
|
a = (*curctx)->qeval; \
|
||||||
|
d = !((*curctx)->mps); \
|
||||||
|
*curctx = (*curctx)->nlps; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
FIXME DOC
|
Decode a symbol using raw-decoder. Cfr p.506 TAUBMAN
|
||||||
@param mqc MQC handle
|
@param mqc MQC handle
|
||||||
@return
|
@return Returns the decoded symbol (0 or 1)
|
||||||
*/
|
*/
|
||||||
static INLINE OPJ_INT32 opj_mqc_mpsexchange(opj_mqc_t *const mqc)
|
static INLINE OPJ_UINT32 opj_mqc_raw_decode(opj_mqc_t *mqc)
|
||||||
{
|
{
|
||||||
OPJ_INT32 d;
|
OPJ_UINT32 d;
|
||||||
if (mqc->a < (*mqc->curctx)->qeval) {
|
if (mqc->ct == 0) {
|
||||||
d = (OPJ_INT32)(1 - (*mqc->curctx)->mps);
|
/* Given opj_mqc_raw_init_dec() we know that at some point we will */
|
||||||
*mqc->curctx = (*mqc->curctx)->nlps;
|
/* have a 0xFF 0xFF artificial marker */
|
||||||
} else {
|
if (mqc->c == 0xff) {
|
||||||
d = (OPJ_INT32)(*mqc->curctx)->mps;
|
if (*mqc->bp > 0x8f) {
|
||||||
*mqc->curctx = (*mqc->curctx)->nmps;
|
mqc->c = 0xff;
|
||||||
|
mqc->ct = 8;
|
||||||
|
} else {
|
||||||
|
mqc->c = *mqc->bp;
|
||||||
|
mqc->bp ++;
|
||||||
|
mqc->ct = 7;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mqc->c = *mqc->bp;
|
||||||
|
mqc->bp ++;
|
||||||
|
mqc->ct = 8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
mqc->ct--;
|
||||||
|
d = ((OPJ_UINT32)mqc->c >> mqc->ct) & 0x01U;
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
FIXME DOC
|
|
||||||
@param mqc MQC handle
|
|
||||||
@return
|
|
||||||
*/
|
|
||||||
static INLINE OPJ_INT32 opj_mqc_lpsexchange(opj_mqc_t *const mqc)
|
|
||||||
{
|
|
||||||
OPJ_INT32 d;
|
|
||||||
if (mqc->a < (*mqc->curctx)->qeval) {
|
|
||||||
mqc->a = (*mqc->curctx)->qeval;
|
|
||||||
d = (OPJ_INT32)(*mqc->curctx)->mps;
|
|
||||||
*mqc->curctx = (*mqc->curctx)->nmps;
|
|
||||||
} else {
|
|
||||||
mqc->a = (*mqc->curctx)->qeval;
|
|
||||||
d = (OPJ_INT32)(1 - (*mqc->curctx)->mps);
|
|
||||||
*mqc->curctx = (*mqc->curctx)->nlps;
|
|
||||||
}
|
|
||||||
|
|
||||||
return d;
|
#define opj_mqc_bytein_macro(mqc, c, ct) \
|
||||||
|
{ \
|
||||||
|
OPJ_UINT32 l_c; \
|
||||||
|
/* Given opj_mqc_init_dec() we know that at some point we will */ \
|
||||||
|
/* have a 0xFF 0xFF artificial marker */ \
|
||||||
|
l_c = *(mqc->bp + 1); \
|
||||||
|
if (*mqc->bp == 0xff) { \
|
||||||
|
if (l_c > 0x8f) { \
|
||||||
|
c += 0xff00; \
|
||||||
|
ct = 8; \
|
||||||
|
} else { \
|
||||||
|
mqc->bp++; \
|
||||||
|
c += l_c << 9; \
|
||||||
|
ct = 7; \
|
||||||
|
} \
|
||||||
|
} else { \
|
||||||
|
mqc->bp++; \
|
||||||
|
c += l_c << 8; \
|
||||||
|
ct = 8; \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* For internal use of opj_mqc_decode_macro() */
|
||||||
|
#define opj_mqc_renormd_macro(mqc, a, c, ct) \
|
||||||
|
{ \
|
||||||
|
do { \
|
||||||
|
if (ct == 0) { \
|
||||||
|
opj_mqc_bytein_macro(mqc, c, ct); \
|
||||||
|
} \
|
||||||
|
a <<= 1; \
|
||||||
|
c <<= 1; \
|
||||||
|
ct--; \
|
||||||
|
} while (a < 0x8000); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define opj_mqc_decode_macro(d, mqc, curctx, a, c, ct) \
|
||||||
|
{ \
|
||||||
|
/* Implements ISO 15444-1 C.3.2 Decoding a decision (DECODE) */ \
|
||||||
|
/* Note: alternate "J.2 - Decoding an MPS or an LPS in the */ \
|
||||||
|
/* software-conventions decoder" has been tried, but does not bring any */ \
|
||||||
|
/* improvement. See https://github.com/uclouvain/openjpeg/issues/921 */ \
|
||||||
|
a -= (*curctx)->qeval; \
|
||||||
|
if ((c >> 16) < (*curctx)->qeval) { \
|
||||||
|
opj_mqc_lpsexchange_macro(d, curctx, a); \
|
||||||
|
opj_mqc_renormd_macro(mqc, a, c, ct); \
|
||||||
|
} else { \
|
||||||
|
c -= (*curctx)->qeval << 16; \
|
||||||
|
if ((a & 0x8000) == 0) { \
|
||||||
|
opj_mqc_mpsexchange_macro(d, curctx, a); \
|
||||||
|
opj_mqc_renormd_macro(mqc, a, c, ct); \
|
||||||
|
} else { \
|
||||||
|
d = (*curctx)->mps; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DOWNLOAD_MQC_VARIABLES(mqc, curctx, c, a, ct) \
|
||||||
|
register opj_mqc_state_t **curctx = mqc->curctx; \
|
||||||
|
register OPJ_UINT32 c = mqc->c; \
|
||||||
|
register OPJ_UINT32 a = mqc->a; \
|
||||||
|
register OPJ_UINT32 ct = mqc->ct
|
||||||
|
|
||||||
|
#define UPLOAD_MQC_VARIABLES(mqc, curctx, c, a, ct) \
|
||||||
|
mqc->curctx = curctx; \
|
||||||
|
mqc->c = c; \
|
||||||
|
mqc->a = a; \
|
||||||
|
mqc->ct = ct;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Input a byte
|
Input a byte
|
||||||
@param mqc MQC handle
|
@param mqc MQC handle
|
||||||
*/
|
*/
|
||||||
static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc)
|
static INLINE void opj_mqc_bytein(opj_mqc_t *const mqc)
|
||||||
{
|
{
|
||||||
/* Implements ISO 15444-1 C.3.4 Compressed image data input (BYTEIN) */
|
opj_mqc_bytein_macro(mqc, mqc->c, mqc->ct);
|
||||||
/* Note: alternate "J.3 - Inserting a new byte into the C register in the */
|
|
||||||
/* software-conventions decoder" has been tried, but does not bring any */
|
|
||||||
/* improvement. See https://github.com/uclouvain/openjpeg/issues/921 */
|
|
||||||
if (mqc->bp != mqc->end) {
|
|
||||||
OPJ_UINT32 c;
|
|
||||||
if (mqc->bp + 1 != mqc->end) {
|
|
||||||
c = *(mqc->bp + 1);
|
|
||||||
} else {
|
|
||||||
c = 0xff;
|
|
||||||
}
|
|
||||||
if (*mqc->bp == 0xff) {
|
|
||||||
if (c > 0x8f) {
|
|
||||||
mqc->c += 0xff00;
|
|
||||||
mqc->ct = 8;
|
|
||||||
} else {
|
|
||||||
mqc->bp++;
|
|
||||||
mqc->c += c << 9;
|
|
||||||
mqc->ct = 7;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mqc->bp++;
|
|
||||||
mqc->c += c << 8;
|
|
||||||
mqc->ct = 8;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mqc->c += 0xff00;
|
|
||||||
mqc->ct = 8;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Renormalize mqc->a and mqc->c while decoding
|
Renormalize mqc->a and mqc->c while decoding
|
||||||
@param mqc MQC handle
|
@param mqc MQC handle
|
||||||
*/
|
*/
|
||||||
static INLINE void opj_mqc_renormd(opj_mqc_t *const mqc)
|
#define opj_mqc_renormd(mqc) \
|
||||||
{
|
opj_mqc_renormd_macro(mqc, mqc->a, mqc->c, mqc->ct)
|
||||||
do {
|
|
||||||
if (mqc->ct == 0) {
|
|
||||||
opj_mqc_bytein(mqc);
|
|
||||||
}
|
|
||||||
mqc->a <<= 1;
|
|
||||||
mqc->c <<= 1;
|
|
||||||
mqc->ct--;
|
|
||||||
} while (mqc->a < 0x8000);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Decode a symbol
|
Decode a symbol
|
||||||
|
@param d OPJ_UINT32 value where to store the decoded symbol
|
||||||
@param mqc MQC handle
|
@param mqc MQC handle
|
||||||
@return Returns the decoded symbol (0 or 1)
|
@return Returns the decoded symbol (0 or 1) in d
|
||||||
*/
|
*/
|
||||||
static INLINE OPJ_INT32 opj_mqc_decode(opj_mqc_t *const mqc)
|
#define opj_mqc_decode(d, mqc) \
|
||||||
{
|
opj_mqc_decode_macro(d, mqc, mqc->curctx, mqc->a, mqc->c, mqc->ct)
|
||||||
/* Implements ISO 15444-1 C.3.2 Decoding a decision (DECODE) */
|
|
||||||
/* Note: alternate "J.2 - Decoding an MPS or an LPS in the */
|
|
||||||
/* software-conventions decoder" has been tried, but does not bring any */
|
|
||||||
/* improvement. See https://github.com/uclouvain/openjpeg/issues/921 */
|
|
||||||
OPJ_INT32 d;
|
|
||||||
mqc->a -= (*mqc->curctx)->qeval;
|
|
||||||
if ((mqc->c >> 16) < (*mqc->curctx)->qeval) {
|
|
||||||
d = opj_mqc_lpsexchange(mqc);
|
|
||||||
opj_mqc_renormd(mqc);
|
|
||||||
} else {
|
|
||||||
mqc->c -= (*mqc->curctx)->qeval << 16;
|
|
||||||
if ((mqc->a & 0x8000) == 0) {
|
|
||||||
d = opj_mqc_mpsexchange(mqc);
|
|
||||||
opj_mqc_renormd(mqc);
|
|
||||||
} else {
|
|
||||||
d = (OPJ_INT32)(*mqc->curctx)->mps;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* __MQC_INL_H */
|
#endif /* __MQC_INL_H */
|
||||||
|
|
|
@ -4,11 +4,7 @@
|
||||||
* party and contributor rights, including patent rights, and no such rights
|
* party and contributor rights, including patent rights, and no such rights
|
||||||
* are granted under this license.
|
* are granted under this license.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
* Copyright (c) 2017, IntoPIX SA <support@intopix.com>
|
||||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
|
||||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
|
||||||
* Copyright (c) 2003-2014, Antonin Descampe
|
|
||||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -32,69 +28,15 @@
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
#ifndef OPJ_COMMMON_H
|
||||||
#include "opj_includes.h"
|
#define OPJ_COMMMON_H
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==========================================================
|
==========================================================
|
||||||
local functions
|
Common constants shared among several modules
|
||||||
==========================================================
|
==========================================================
|
||||||
*/
|
*/
|
||||||
|
#define OPJ_COMMON_DEFAULT_CBLK_DATA_SIZE 8192
|
||||||
|
#define OPJ_COMMON_CBLK_DATA_EXTRA 2 /**< Margin for a fake FFFF marker */
|
||||||
|
|
||||||
|
#endif /* OPJ_COMMMON_H */
|
||||||
/*
|
|
||||||
==========================================================
|
|
||||||
RAW encoding interface
|
|
||||||
==========================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
opj_raw_t* opj_raw_create(void)
|
|
||||||
{
|
|
||||||
opj_raw_t *raw = (opj_raw_t*)opj_malloc(sizeof(opj_raw_t));
|
|
||||||
return raw;
|
|
||||||
}
|
|
||||||
|
|
||||||
void opj_raw_destroy(opj_raw_t *raw)
|
|
||||||
{
|
|
||||||
if (raw) {
|
|
||||||
opj_free(raw);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OPJ_UINT32 opj_raw_numbytes(opj_raw_t *raw)
|
|
||||||
{
|
|
||||||
const ptrdiff_t diff = raw->bp - raw->start;
|
|
||||||
assert(diff <= (ptrdiff_t)0xffffffff && diff >= 0); /* UINT32_MAX */
|
|
||||||
return (OPJ_UINT32)diff;
|
|
||||||
}
|
|
||||||
|
|
||||||
void opj_raw_init_dec(opj_raw_t *raw, OPJ_BYTE *bp, OPJ_UINT32 len)
|
|
||||||
{
|
|
||||||
raw->start = bp;
|
|
||||||
raw->lenmax = len;
|
|
||||||
raw->len = 0;
|
|
||||||
raw->c = 0;
|
|
||||||
raw->ct = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
OPJ_UINT32 opj_raw_decode(opj_raw_t *raw)
|
|
||||||
{
|
|
||||||
OPJ_UINT32 d;
|
|
||||||
if (raw->ct == 0) {
|
|
||||||
raw->ct = 8;
|
|
||||||
if (raw->len == raw->lenmax) {
|
|
||||||
raw->c = 0xff;
|
|
||||||
} else {
|
|
||||||
if (raw->c == 0xff) {
|
|
||||||
raw->ct = 7;
|
|
||||||
}
|
|
||||||
raw->c = *(raw->start + raw->len);
|
|
||||||
raw->len++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
raw->ct--;
|
|
||||||
d = ((OPJ_UINT32)raw->c >> raw->ct) & 0x01U;
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
|
@ -207,7 +207,6 @@ typedef unsigned int OPJ_BITFIELD;
|
||||||
#include "jp2.h"
|
#include "jp2.h"
|
||||||
|
|
||||||
#include "mqc.h"
|
#include "mqc.h"
|
||||||
#include "raw.h"
|
|
||||||
#include "bio.h"
|
#include "bio.h"
|
||||||
|
|
||||||
#include "pi.h"
|
#include "pi.h"
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
/*
|
|
||||||
* The copyright in this software is being made available under the 2-clauses
|
|
||||||
* BSD License, included below. This software may be subject to other third
|
|
||||||
* party and contributor rights, including patent rights, and no such rights
|
|
||||||
* are granted under this license.
|
|
||||||
*
|
|
||||||
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
|
|
||||||
* Copyright (c) 2002-2014, Professor Benoit Macq
|
|
||||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
|
||||||
* Copyright (c) 2003-2014, Antonin Descampe
|
|
||||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __RAW_H
|
|
||||||
#define __RAW_H
|
|
||||||
/**
|
|
||||||
@file raw.h
|
|
||||||
@brief Implementation of operations for raw encoding (RAW)
|
|
||||||
|
|
||||||
The functions in RAW.C have for goal to realize the operation of raw encoding linked
|
|
||||||
with the corresponding mode switch.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup RAW RAW - Implementation of operations for raw encoding */
|
|
||||||
/*@{*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
RAW encoding operations
|
|
||||||
*/
|
|
||||||
typedef struct opj_raw {
|
|
||||||
/** temporary buffer where bits are coded or decoded */
|
|
||||||
OPJ_BYTE c;
|
|
||||||
/** number of bits already read or free to write */
|
|
||||||
OPJ_UINT32 ct;
|
|
||||||
/** maximum length to decode */
|
|
||||||
OPJ_UINT32 lenmax;
|
|
||||||
/** length decoded */
|
|
||||||
OPJ_UINT32 len;
|
|
||||||
/** pointer to the current position in the buffer */
|
|
||||||
OPJ_BYTE *bp;
|
|
||||||
/** pointer to the start of the buffer */
|
|
||||||
OPJ_BYTE *start;
|
|
||||||
/** pointer to the end of the buffer */
|
|
||||||
OPJ_BYTE *end;
|
|
||||||
} opj_raw_t;
|
|
||||||
|
|
||||||
/** @name Exported functions */
|
|
||||||
/*@{*/
|
|
||||||
/* ----------------------------------------------------------------------- */
|
|
||||||
/**
|
|
||||||
Create a new RAW handle
|
|
||||||
@return Returns a new RAW handle if successful, returns NULL otherwise
|
|
||||||
*/
|
|
||||||
opj_raw_t* opj_raw_create(void);
|
|
||||||
/**
|
|
||||||
Destroy a previously created RAW handle
|
|
||||||
@param raw RAW handle to destroy
|
|
||||||
*/
|
|
||||||
void opj_raw_destroy(opj_raw_t *raw);
|
|
||||||
/**
|
|
||||||
Return the number of bytes written/read since initialisation
|
|
||||||
@param raw RAW handle to destroy
|
|
||||||
@return Returns the number of bytes already encoded
|
|
||||||
*/
|
|
||||||
OPJ_UINT32 opj_raw_numbytes(opj_raw_t *raw);
|
|
||||||
/**
|
|
||||||
Initialize the decoder
|
|
||||||
@param raw RAW handle
|
|
||||||
@param bp Pointer to the start of the buffer from which the bytes will be read
|
|
||||||
@param len Length of the input buffer
|
|
||||||
*/
|
|
||||||
void opj_raw_init_dec(opj_raw_t *raw, OPJ_BYTE *bp, OPJ_UINT32 len);
|
|
||||||
/**
|
|
||||||
Decode a symbol using raw-decoder. Cfr p.506 TAUBMAN
|
|
||||||
@param raw RAW handle
|
|
||||||
@return Returns the decoded symbol (0 or 1)
|
|
||||||
*/
|
|
||||||
OPJ_UINT32 opj_raw_decode(opj_raw_t *raw);
|
|
||||||
/* ----------------------------------------------------------------------- */
|
|
||||||
/*@}*/
|
|
||||||
|
|
||||||
/*@}*/
|
|
||||||
|
|
||||||
#endif /* __RAW_H */
|
|
2189
src/lib/openjp2/t1.c
2189
src/lib/openjp2/t1.c
File diff suppressed because it is too large
Load Diff
|
@ -11,6 +11,8 @@
|
||||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux
|
||||||
* Copyright (c) 2003-2014, Antonin Descampe
|
* Copyright (c) 2003-2014, Antonin Descampe
|
||||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* Copyright (c) 2012, Carl Hetherington
|
||||||
|
* Copyright (c) 2017, IntoPIX SA <support@intopix.com>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -50,31 +52,6 @@ in T1.C are used by some function in TCD.C.
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
#define T1_NMSEDEC_BITS 7
|
#define T1_NMSEDEC_BITS 7
|
||||||
|
|
||||||
/* CAUTION: the value of those constants must not be changed, otherwise the */
|
|
||||||
/* optimization of opj_t1_updateflags() will break! */
|
|
||||||
/* BEGINNING of flags that apply to opj_flag_t */
|
|
||||||
#define T1_SIG_NE 0x0001U /**< Context orientation : North-East direction */
|
|
||||||
#define T1_SIG_SE 0x0002U /**< Context orientation : South-East direction */
|
|
||||||
#define T1_SIG_SW 0x0004U /**< Context orientation : South-West direction */
|
|
||||||
#define T1_SIG_NW 0x0008U /**< Context orientation : North-West direction */
|
|
||||||
#define T1_SIG_N 0x0010U /**< Context orientation : North direction */
|
|
||||||
#define T1_SIG_E 0x0020U /**< Context orientation : East direction */
|
|
||||||
#define T1_SIG_S 0x0040U /**< Context orientation : South direction */
|
|
||||||
#define T1_SIG_W 0x0080U /**< Context orientation : West direction */
|
|
||||||
#define T1_SIG_OTH (T1_SIG_N|T1_SIG_NE|T1_SIG_E|T1_SIG_SE|T1_SIG_S|T1_SIG_SW|T1_SIG_W|T1_SIG_NW)
|
|
||||||
#define T1_SIG_PRIM (T1_SIG_N|T1_SIG_E|T1_SIG_S|T1_SIG_W)
|
|
||||||
|
|
||||||
#define T1_SGN_N 0x0100U
|
|
||||||
#define T1_SGN_E 0x0200U
|
|
||||||
#define T1_SGN_S 0x0400U
|
|
||||||
#define T1_SGN_W 0x0800U
|
|
||||||
#define T1_SGN (T1_SGN_N|T1_SGN_E|T1_SGN_S|T1_SGN_W)
|
|
||||||
|
|
||||||
#define T1_SIG 0x1000U /**< No longer used by decoder */
|
|
||||||
#define T1_REFINE 0x2000U /**< No longer used by decoder */
|
|
||||||
#define T1_VISIT 0x4000U /**< No longer used by decoder */
|
|
||||||
/* END of flags that apply to opj_flag_t */
|
|
||||||
|
|
||||||
#define T1_NUMCTXS_ZC 9
|
#define T1_NUMCTXS_ZC 9
|
||||||
#define T1_NUMCTXS_SC 5
|
#define T1_NUMCTXS_SC 5
|
||||||
#define T1_NUMCTXS_MAG 3
|
#define T1_NUMCTXS_MAG 3
|
||||||
|
@ -93,31 +70,113 @@ in T1.C are used by some function in TCD.C.
|
||||||
#define T1_TYPE_MQ 0 /**< Normal coding using entropy coder */
|
#define T1_TYPE_MQ 0 /**< Normal coding using entropy coder */
|
||||||
#define T1_TYPE_RAW 1 /**< No encoding the information is store under raw format in codestream (mode switch RAW)*/
|
#define T1_TYPE_RAW 1 /**< No encoding the information is store under raw format in codestream (mode switch RAW)*/
|
||||||
|
|
||||||
/* Those flags are used by opj_colflag_t */
|
/* BEGINNING of flags that apply to opj_flag_t */
|
||||||
#define T1_COLFLAG_RBS 4U /* RBS = Row Bit Shift */
|
/** We hold the state of individual data points for the T1 encoder using
|
||||||
#define T1_COLFLAG_SIG_OTHER_ROW_0 (1U << 0U) /**< This sample has at least one significant neighbour */
|
* a single 32-bit flags word to hold the state of 4 data points. This corresponds
|
||||||
#define T1_COLFLAG_SIG_ROW_0 (1U << 1U) /**< This sample is significant */
|
* to the 4-point-high columns that the data is processed in.
|
||||||
#define T1_COLFLAG_VISIT_ROW_0 (1U << 2U) /**< This sample has been visited */
|
*
|
||||||
#define T1_COLFLAG_REFINE_ROW_0 (1U << 3U) /**< This sample has been refined */
|
* These #defines declare the layout of a 32-bit flags word.
|
||||||
#define T1_COLFLAG_SIG_OTHER_ROW_1 (T1_COLFLAG_SIG_OTHER_ROW_0 << (1U * T1_COLFLAG_RBS))
|
*
|
||||||
#define T1_COLFLAG_SIG_ROW_1 (T1_COLFLAG_SIG_ROW_0 << (1U * T1_COLFLAG_RBS))
|
* This is currently done for encoding only.
|
||||||
#define T1_COLFLAG_VISIT_ROW_1 (T1_COLFLAG_VISIT_ROW_0 << (1U * T1_COLFLAG_RBS))
|
* The values must NOT be changed, otherwise this is going to break a lot of
|
||||||
#define T1_COLFLAG_REFINE_ROW_1 (T1_COLFLAG_REFINE_ROW_0 << (1U * T1_COLFLAG_RBS))
|
* assumptions.
|
||||||
#define T1_COLFLAG_SIG_OTHER_ROW_2 (T1_COLFLAG_SIG_OTHER_ROW_0 << (2U * T1_COLFLAG_RBS))
|
*/
|
||||||
#define T1_COLFLAG_SIG_ROW_2 (T1_COLFLAG_SIG_ROW_0 << (2U * T1_COLFLAG_RBS))
|
|
||||||
#define T1_COLFLAG_VISIT_ROW_2 (T1_COLFLAG_VISIT_ROW_0 << (2U * T1_COLFLAG_RBS))
|
/* SIGMA: significance state (3 cols x 6 rows)
|
||||||
#define T1_COLFLAG_REFINE_ROW_2 (T1_COLFLAG_REFINE_ROW_0 << (2U * T1_COLFLAG_RBS))
|
* CHI: state for negative sample value (1 col x 6 rows)
|
||||||
#define T1_COLFLAG_SIG_OTHER_ROW_3 (T1_COLFLAG_SIG_OTHER_ROW_0 << (3U * T1_COLFLAG_RBS))
|
* MU: state for visited in refinement pass (1 col x 4 rows)
|
||||||
#define T1_COLFLAG_SIG_ROW_3 (T1_COLFLAG_SIG_ROW_0 << (3U * T1_COLFLAG_RBS))
|
* PI: state for visited in significance pass (1 col * 4 rows)
|
||||||
#define T1_COLFLAG_VISIT_ROW_3 (T1_COLFLAG_VISIT_ROW_0 << (3U * T1_COLFLAG_RBS))
|
*/
|
||||||
#define T1_COLFLAG_REFINE_ROW_3 (T1_COLFLAG_REFINE_ROW_0 << (3U * T1_COLFLAG_RBS))
|
|
||||||
|
#define T1_SIGMA_0 (1U << 0)
|
||||||
|
#define T1_SIGMA_1 (1U << 1)
|
||||||
|
#define T1_SIGMA_2 (1U << 2)
|
||||||
|
#define T1_SIGMA_3 (1U << 3)
|
||||||
|
#define T1_SIGMA_4 (1U << 4)
|
||||||
|
#define T1_SIGMA_5 (1U << 5)
|
||||||
|
#define T1_SIGMA_6 (1U << 6)
|
||||||
|
#define T1_SIGMA_7 (1U << 7)
|
||||||
|
#define T1_SIGMA_8 (1U << 8)
|
||||||
|
#define T1_SIGMA_9 (1U << 9)
|
||||||
|
#define T1_SIGMA_10 (1U << 10)
|
||||||
|
#define T1_SIGMA_11 (1U << 11)
|
||||||
|
#define T1_SIGMA_12 (1U << 12)
|
||||||
|
#define T1_SIGMA_13 (1U << 13)
|
||||||
|
#define T1_SIGMA_14 (1U << 14)
|
||||||
|
#define T1_SIGMA_15 (1U << 15)
|
||||||
|
#define T1_SIGMA_16 (1U << 16)
|
||||||
|
#define T1_SIGMA_17 (1U << 17)
|
||||||
|
|
||||||
|
#define T1_CHI_0 (1U << 18)
|
||||||
|
#define T1_CHI_0_I 18
|
||||||
|
#define T1_CHI_1 (1U << 19)
|
||||||
|
#define T1_CHI_1_I 19
|
||||||
|
#define T1_MU_0 (1U << 20)
|
||||||
|
#define T1_PI_0 (1U << 21)
|
||||||
|
#define T1_CHI_2 (1U << 22)
|
||||||
|
#define T1_CHI_2_I 22
|
||||||
|
#define T1_MU_1 (1U << 23)
|
||||||
|
#define T1_PI_1 (1U << 24)
|
||||||
|
#define T1_CHI_3 (1U << 25)
|
||||||
|
#define T1_MU_2 (1U << 26)
|
||||||
|
#define T1_PI_2 (1U << 27)
|
||||||
|
#define T1_CHI_4 (1U << 28)
|
||||||
|
#define T1_MU_3 (1U << 29)
|
||||||
|
#define T1_PI_3 (1U << 30)
|
||||||
|
#define T1_CHI_5 (1U << 31)
|
||||||
|
#define T1_CHI_5_I 31
|
||||||
|
|
||||||
|
/** As an example, the bits T1_SIGMA_3, T1_SIGMA_4 and T1_SIGMA_5
|
||||||
|
* indicate the significance state of the west neighbour of data point zero
|
||||||
|
* of our four, the point itself, and its east neighbour respectively.
|
||||||
|
* Many of the bits are arranged so that given a flags word, you can
|
||||||
|
* look at the values for the data point 0, then shift the flags
|
||||||
|
* word right by 3 bits and look at the same bit positions to see the
|
||||||
|
* values for data point 1.
|
||||||
|
*
|
||||||
|
* The #defines below help a bit with this; say you have a flags word
|
||||||
|
* f, you can do things like
|
||||||
|
*
|
||||||
|
* (f & T1_SIGMA_THIS)
|
||||||
|
*
|
||||||
|
* to see the significance bit of data point 0, then do
|
||||||
|
*
|
||||||
|
* ((f >> 3) & T1_SIGMA_THIS)
|
||||||
|
*
|
||||||
|
* to see the significance bit of data point 1.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define T1_SIGMA_NW T1_SIGMA_0
|
||||||
|
#define T1_SIGMA_N T1_SIGMA_1
|
||||||
|
#define T1_SIGMA_NE T1_SIGMA_2
|
||||||
|
#define T1_SIGMA_W T1_SIGMA_3
|
||||||
|
#define T1_SIGMA_THIS T1_SIGMA_4
|
||||||
|
#define T1_SIGMA_E T1_SIGMA_5
|
||||||
|
#define T1_SIGMA_SW T1_SIGMA_6
|
||||||
|
#define T1_SIGMA_S T1_SIGMA_7
|
||||||
|
#define T1_SIGMA_SE T1_SIGMA_8
|
||||||
|
#define T1_SIGMA_NEIGHBOURS (T1_SIGMA_NW | T1_SIGMA_N | T1_SIGMA_NE | T1_SIGMA_W | T1_SIGMA_E | T1_SIGMA_SW | T1_SIGMA_S | T1_SIGMA_SE)
|
||||||
|
|
||||||
|
#define T1_CHI_THIS T1_CHI_1
|
||||||
|
#define T1_CHI_THIS_I T1_CHI_1_I
|
||||||
|
#define T1_MU_THIS T1_MU_0
|
||||||
|
#define T1_PI_THIS T1_PI_0
|
||||||
|
#define T1_CHI_S T1_CHI_2
|
||||||
|
|
||||||
|
#define T1_LUT_SGN_W (1U << 0)
|
||||||
|
#define T1_LUT_SIG_N (1U << 1)
|
||||||
|
#define T1_LUT_SGN_E (1U << 2)
|
||||||
|
#define T1_LUT_SIG_W (1U << 3)
|
||||||
|
#define T1_LUT_SGN_N (1U << 4)
|
||||||
|
#define T1_LUT_SIG_E (1U << 5)
|
||||||
|
#define T1_LUT_SGN_S (1U << 6)
|
||||||
|
#define T1_LUT_SIG_S (1U << 7)
|
||||||
|
/* END of flags that apply to opj_flag_t */
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
typedef OPJ_UINT16 opj_flag_t;
|
|
||||||
|
|
||||||
/** Flags for 4 consecutive rows of a column */
|
/** Flags for 4 consecutive rows of a column */
|
||||||
typedef OPJ_UINT16 opj_colflag_t;
|
typedef OPJ_UINT32 opj_flag_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Tier-1 coding (coding of code-block coefficients)
|
Tier-1 coding (coding of code-block coefficients)
|
||||||
|
@ -125,29 +184,24 @@ Tier-1 coding (coding of code-block coefficients)
|
||||||
typedef struct opj_t1 {
|
typedef struct opj_t1 {
|
||||||
|
|
||||||
/** MQC component */
|
/** MQC component */
|
||||||
opj_mqc_t *mqc;
|
opj_mqc_t mqc;
|
||||||
/** RAW component */
|
|
||||||
opj_raw_t *raw;
|
|
||||||
|
|
||||||
OPJ_INT32 *data;
|
OPJ_INT32 *data;
|
||||||
opj_flag_t *flags;
|
/** Flags used by decoder and encoder.
|
||||||
/** Addition flag array such that colflags[1+0] is for state of col=0,row=0..3,
|
* Such that flags[1+0] is for state of col=0,row=0..3,
|
||||||
colflags[1+1] for col=1, row=0..3, colflags[1+flags_stride] for col=0,row=4..7, ...
|
flags[1+1] for col=1, row=0..3, flags[1+flags_stride] for col=0,row=4..7, ...
|
||||||
This array avoids too much cache trashing when processing by 4 vertical samples
|
This array avoids too much cache trashing when processing by 4 vertical samples
|
||||||
as done in the various decoding steps. */
|
as done in the various decoding steps. */
|
||||||
opj_colflag_t* colflags;
|
opj_flag_t *flags;
|
||||||
|
|
||||||
OPJ_UINT32 w;
|
OPJ_UINT32 w;
|
||||||
OPJ_UINT32 h;
|
OPJ_UINT32 h;
|
||||||
OPJ_UINT32 datasize;
|
OPJ_UINT32 datasize;
|
||||||
OPJ_UINT32 flagssize;
|
OPJ_UINT32 flagssize;
|
||||||
OPJ_UINT32 flags_stride;
|
|
||||||
OPJ_UINT32 colflags_size;
|
|
||||||
OPJ_UINT32 data_stride;
|
OPJ_UINT32 data_stride;
|
||||||
OPJ_BOOL encoder;
|
OPJ_BOOL encoder;
|
||||||
} opj_t1_t;
|
} opj_t1_t;
|
||||||
|
|
||||||
#define MACRO_t1_flags(x,y) t1->flags[((x)*(t1->flags_stride))+(y)]
|
|
||||||
|
|
||||||
/** @name Exported functions */
|
/** @name Exported functions */
|
||||||
/*@{*/
|
/*@{*/
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
@ -168,7 +222,8 @@ OPJ_BOOL opj_t1_encode_cblks(opj_t1_t *t1,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Decode the code-blocks of a tile
|
Decode the code-blocks of a tile
|
||||||
@param t1 T1 handle
|
@param tp Thread pool
|
||||||
|
@param pret Pointer to return value
|
||||||
@param tilec The tile to decode
|
@param tilec The tile to decode
|
||||||
@param tccp Tile coding parameters
|
@param tccp Tile coding parameters
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
* Copyright (c) 2003-2014, Antonin Descampe
|
* Copyright (c) 2003-2014, Antonin Descampe
|
||||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
* Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
|
* Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
|
||||||
|
* Copyright (c) 2012, Carl Hetherington
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -38,23 +39,20 @@
|
||||||
|
|
||||||
#include "opj_includes.h"
|
#include "opj_includes.h"
|
||||||
|
|
||||||
static int t1_init_ctxno_zc(unsigned int f, unsigned int orient)
|
static int t1_init_ctxno_zc(OPJ_UINT32 f, OPJ_UINT32 orient)
|
||||||
{
|
{
|
||||||
int h, v, d, n, t, hv;
|
int h, v, d, n, t, hv;
|
||||||
h = ((f & T1_SIG_W) != 0) + ((f & T1_SIG_E) != 0);
|
|
||||||
v = ((f & T1_SIG_N) != 0) + ((f & T1_SIG_S) != 0);
|
|
||||||
d = ((f & T1_SIG_NW) != 0) + ((f & T1_SIG_NE) != 0) + ((
|
|
||||||
f & T1_SIG_SE) != 0) + ((f & T1_SIG_SW) != 0);
|
|
||||||
n = 0;
|
n = 0;
|
||||||
t = 0;
|
h = ((f & T1_SIGMA_3) != 0) + ((f & T1_SIGMA_5) != 0);
|
||||||
hv = 0;
|
v = ((f & T1_SIGMA_1) != 0) + ((f & T1_SIGMA_7) != 0);
|
||||||
|
d = ((f & T1_SIGMA_0) != 0) + ((f & T1_SIGMA_2) != 0) + ((
|
||||||
|
f & T1_SIGMA_8) != 0) + ((f & T1_SIGMA_6) != 0);
|
||||||
|
|
||||||
switch (orient) {
|
switch (orient) {
|
||||||
case 2:
|
case 2:
|
||||||
t = h;
|
t = h;
|
||||||
h = v;
|
h = v;
|
||||||
v = t;
|
v = t;
|
||||||
/* fall through */
|
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
if (!h) {
|
if (!h) {
|
||||||
|
@ -118,24 +116,24 @@ static int t1_init_ctxno_zc(unsigned int f, unsigned int orient)
|
||||||
return (T1_CTXNO_ZC + n);
|
return (T1_CTXNO_ZC + n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int t1_init_ctxno_sc(unsigned int f)
|
static int t1_init_ctxno_sc(OPJ_UINT32 f)
|
||||||
{
|
{
|
||||||
int hc, vc, n;
|
int hc, vc, n;
|
||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
hc = opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
|
hc = opj_int_min(((f & (T1_LUT_SIG_E | T1_LUT_SGN_E)) ==
|
||||||
T1_SIG_E) + ((f & (T1_SIG_W | T1_SGN_W)) == T1_SIG_W),
|
T1_LUT_SIG_E) + ((f & (T1_LUT_SIG_W | T1_LUT_SGN_W)) == T1_LUT_SIG_W),
|
||||||
1) - opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
|
1) - opj_int_min(((f & (T1_LUT_SIG_E | T1_LUT_SGN_E)) ==
|
||||||
(T1_SIG_E | T1_SGN_E)) +
|
(T1_LUT_SIG_E | T1_LUT_SGN_E)) +
|
||||||
((f & (T1_SIG_W | T1_SGN_W)) ==
|
((f & (T1_LUT_SIG_W | T1_LUT_SGN_W)) ==
|
||||||
(T1_SIG_W | T1_SGN_W)), 1);
|
(T1_LUT_SIG_W | T1_LUT_SGN_W)), 1);
|
||||||
|
|
||||||
vc = opj_int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
|
vc = opj_int_min(((f & (T1_LUT_SIG_N | T1_LUT_SGN_N)) ==
|
||||||
T1_SIG_N) + ((f & (T1_SIG_S | T1_SGN_S)) == T1_SIG_S),
|
T1_LUT_SIG_N) + ((f & (T1_LUT_SIG_S | T1_LUT_SGN_S)) == T1_LUT_SIG_S),
|
||||||
1) - opj_int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
|
1) - opj_int_min(((f & (T1_LUT_SIG_N | T1_LUT_SGN_N)) ==
|
||||||
(T1_SIG_N | T1_SGN_N)) +
|
(T1_LUT_SIG_N | T1_LUT_SGN_N)) +
|
||||||
((f & (T1_SIG_S | T1_SGN_S)) ==
|
((f & (T1_LUT_SIG_S | T1_LUT_SGN_S)) ==
|
||||||
(T1_SIG_S | T1_SGN_S)), 1);
|
(T1_LUT_SIG_S | T1_LUT_SGN_S)), 1);
|
||||||
|
|
||||||
if (hc < 0) {
|
if (hc < 0) {
|
||||||
hc = -hc;
|
hc = -hc;
|
||||||
|
@ -162,23 +160,23 @@ static int t1_init_ctxno_sc(unsigned int f)
|
||||||
return (T1_CTXNO_SC + n);
|
return (T1_CTXNO_SC + n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int t1_init_spb(unsigned int f)
|
static int t1_init_spb(OPJ_UINT32 f)
|
||||||
{
|
{
|
||||||
int hc, vc, n;
|
int hc, vc, n;
|
||||||
|
|
||||||
hc = opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
|
hc = opj_int_min(((f & (T1_LUT_SIG_E | T1_LUT_SGN_E)) ==
|
||||||
T1_SIG_E) + ((f & (T1_SIG_W | T1_SGN_W)) == T1_SIG_W),
|
T1_LUT_SIG_E) + ((f & (T1_LUT_SIG_W | T1_LUT_SGN_W)) == T1_LUT_SIG_W),
|
||||||
1) - opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
|
1) - opj_int_min(((f & (T1_LUT_SIG_E | T1_LUT_SGN_E)) ==
|
||||||
(T1_SIG_E | T1_SGN_E)) +
|
(T1_LUT_SIG_E | T1_LUT_SGN_E)) +
|
||||||
((f & (T1_SIG_W | T1_SGN_W)) ==
|
((f & (T1_LUT_SIG_W | T1_LUT_SGN_W)) ==
|
||||||
(T1_SIG_W | T1_SGN_W)), 1);
|
(T1_LUT_SIG_W | T1_LUT_SGN_W)), 1);
|
||||||
|
|
||||||
vc = opj_int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
|
vc = opj_int_min(((f & (T1_LUT_SIG_N | T1_LUT_SGN_N)) ==
|
||||||
T1_SIG_N) + ((f & (T1_SIG_S | T1_SGN_S)) == T1_SIG_S),
|
T1_LUT_SIG_N) + ((f & (T1_LUT_SIG_S | T1_LUT_SGN_S)) == T1_LUT_SIG_S),
|
||||||
1) - opj_int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
|
1) - opj_int_min(((f & (T1_LUT_SIG_N | T1_LUT_SGN_N)) ==
|
||||||
(T1_SIG_N | T1_SGN_N)) +
|
(T1_LUT_SIG_N | T1_LUT_SGN_N)) +
|
||||||
((f & (T1_SIG_S | T1_SGN_S)) ==
|
((f & (T1_LUT_SIG_S | T1_LUT_SGN_S)) ==
|
||||||
(T1_SIG_S | T1_SGN_S)), 1);
|
(T1_LUT_SIG_S | T1_LUT_SGN_S)), 1);
|
||||||
|
|
||||||
if (!hc && !vc) {
|
if (!hc && !vc) {
|
||||||
n = 0;
|
n = 0;
|
||||||
|
@ -194,9 +192,11 @@ static void dump_array16(int array[], int size)
|
||||||
int i;
|
int i;
|
||||||
--size;
|
--size;
|
||||||
for (i = 0; i < size; ++i) {
|
for (i = 0; i < size; ++i) {
|
||||||
printf("0x%04x, ", array[i]);
|
printf("0x%04x,", array[i]);
|
||||||
if (!((i + 1) & 0x7)) {
|
if (!((i + 1) & 0x7)) {
|
||||||
printf("\n ");
|
printf("\n ");
|
||||||
|
} else {
|
||||||
|
printf(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("0x%04x\n};\n\n", array[size]);
|
printf("0x%04x\n};\n\n", array[size]);
|
||||||
|
@ -207,7 +207,7 @@ int main(int argc, char **argv)
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
double u, v, t;
|
double u, v, t;
|
||||||
|
|
||||||
int lut_ctxno_zc[1024];
|
int lut_ctxno_zc[2048];
|
||||||
int lut_nmsedec_sig[1 << T1_NMSEDEC_BITS];
|
int lut_nmsedec_sig[1 << T1_NMSEDEC_BITS];
|
||||||
int lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS];
|
int lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS];
|
||||||
int lut_nmsedec_ref[1 << T1_NMSEDEC_BITS];
|
int lut_nmsedec_ref[1 << T1_NMSEDEC_BITS];
|
||||||
|
@ -218,46 +218,52 @@ int main(int argc, char **argv)
|
||||||
printf("/* This file was automatically generated by t1_generate_luts.c */\n\n");
|
printf("/* This file was automatically generated by t1_generate_luts.c */\n\n");
|
||||||
|
|
||||||
/* lut_ctxno_zc */
|
/* lut_ctxno_zc */
|
||||||
for (j = 0U; j < 4U; ++j) {
|
for (j = 0; j < 4; ++j) {
|
||||||
for (i = 0U; i < 256U; ++i) {
|
for (i = 0; i < 512; ++i) {
|
||||||
unsigned int orient = j;
|
OPJ_UINT32 orient = j;
|
||||||
if (orient == 2U) {
|
if (orient == 2) {
|
||||||
orient = 1U;
|
orient = 1;
|
||||||
} else if (orient == 1U) {
|
} else if (orient == 1) {
|
||||||
orient = 2U;
|
orient = 2;
|
||||||
}
|
}
|
||||||
lut_ctxno_zc[(orient << 8) | i] = t1_init_ctxno_zc(i, j);
|
lut_ctxno_zc[(orient << 9) | i] = t1_init_ctxno_zc(i, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("static const OPJ_BYTE lut_ctxno_zc[1024] = {\n ");
|
printf("static const OPJ_BYTE lut_ctxno_zc[2048] = {\n ");
|
||||||
for (i = 0U; i < 1023U; ++i) {
|
for (i = 0; i < 2047; ++i) {
|
||||||
printf("%i, ", lut_ctxno_zc[i]);
|
printf("%i,", lut_ctxno_zc[i]);
|
||||||
if (!((i + 1U) & 0x1fU)) {
|
if (!((i + 1) & 0x1f)) {
|
||||||
printf("\n ");
|
printf("\n ");
|
||||||
|
} else {
|
||||||
|
printf(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("%i\n};\n\n", lut_ctxno_zc[1023]);
|
printf("%i\n};\n\n", lut_ctxno_zc[2047]);
|
||||||
|
|
||||||
/* lut_ctxno_sc */
|
/* lut_ctxno_sc */
|
||||||
printf("static const OPJ_BYTE lut_ctxno_sc[256] = {\n ");
|
printf("static const OPJ_BYTE lut_ctxno_sc[256] = {\n ");
|
||||||
for (i = 0U; i < 255U; ++i) {
|
for (i = 0; i < 255; ++i) {
|
||||||
printf("0x%x, ", t1_init_ctxno_sc(i << 4));
|
printf("0x%x,", t1_init_ctxno_sc(i));
|
||||||
if (!((i + 1U) & 0xfU)) {
|
if (!((i + 1) & 0xf)) {
|
||||||
printf("\n ");
|
printf("\n ");
|
||||||
|
} else {
|
||||||
|
printf(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("0x%x\n};\n\n", t1_init_ctxno_sc(255U << 4));
|
printf("0x%x\n};\n\n", t1_init_ctxno_sc(255));
|
||||||
|
|
||||||
/* lut_spb */
|
/* lut_spb */
|
||||||
printf("static const OPJ_BYTE lut_spb[256] = {\n ");
|
printf("static const OPJ_BYTE lut_spb[256] = {\n ");
|
||||||
for (i = 0U; i < 255U; ++i) {
|
for (i = 0; i < 255; ++i) {
|
||||||
printf("%i, ", t1_init_spb(i << 4));
|
printf("%i,", t1_init_spb(i));
|
||||||
if (!((i + 1U) & 0x1fU)) {
|
if (!((i + 1) & 0x1f)) {
|
||||||
printf("\n ");
|
printf("\n ");
|
||||||
|
} else {
|
||||||
|
printf(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("%i\n};\n\n", t1_init_spb(255U << 4));
|
printf("%i\n};\n\n", t1_init_spb(255));
|
||||||
|
|
||||||
/* FIXME FIXME FIXME */
|
/* FIXME FIXME FIXME */
|
||||||
/* fprintf(stdout,"nmsedec luts:\n"); */
|
/* fprintf(stdout,"nmsedec luts:\n"); */
|
||||||
|
@ -289,16 +295,16 @@ int main(int argc, char **argv)
|
||||||
T1_NMSEDEC_FRACBITS) * 8192.0));
|
T1_NMSEDEC_FRACBITS) * 8192.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("static const OPJ_INT16 lut_nmsedec_sig[1U << T1_NMSEDEC_BITS] = {\n ");
|
printf("static const OPJ_INT16 lut_nmsedec_sig[1U << T1_NMSEDEC_BITS] = {\n ");
|
||||||
dump_array16(lut_nmsedec_sig, 1U << T1_NMSEDEC_BITS);
|
dump_array16(lut_nmsedec_sig, 1U << T1_NMSEDEC_BITS);
|
||||||
|
|
||||||
printf("static const OPJ_INT16 lut_nmsedec_sig0[1U << T1_NMSEDEC_BITS] = {\n ");
|
printf("static const OPJ_INT16 lut_nmsedec_sig0[1U << T1_NMSEDEC_BITS] = {\n ");
|
||||||
dump_array16(lut_nmsedec_sig0, 1U << T1_NMSEDEC_BITS);
|
dump_array16(lut_nmsedec_sig0, 1U << T1_NMSEDEC_BITS);
|
||||||
|
|
||||||
printf("static const OPJ_INT16 lut_nmsedec_ref[1U << T1_NMSEDEC_BITS] = {\n ");
|
printf("static const OPJ_INT16 lut_nmsedec_ref[1U << T1_NMSEDEC_BITS] = {\n ");
|
||||||
dump_array16(lut_nmsedec_ref, 1U << T1_NMSEDEC_BITS);
|
dump_array16(lut_nmsedec_ref, 1U << T1_NMSEDEC_BITS);
|
||||||
|
|
||||||
printf("static const OPJ_INT16 lut_nmsedec_ref0[1U << T1_NMSEDEC_BITS] = {\n ");
|
printf("static const OPJ_INT16 lut_nmsedec_ref0[1U << T1_NMSEDEC_BITS] = {\n ");
|
||||||
dump_array16(lut_nmsedec_ref0, 1U << T1_NMSEDEC_BITS);
|
dump_array16(lut_nmsedec_ref0, 1U << T1_NMSEDEC_BITS);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1,68 +1,100 @@
|
||||||
/* This file was automatically generated by t1_generate_luts.c */
|
/* This file was automatically generated by t1_generate_luts.c */
|
||||||
|
|
||||||
static const OPJ_BYTE lut_ctxno_zc[1024] = {
|
static const OPJ_BYTE lut_ctxno_zc[2048] = {
|
||||||
0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
0, 1, 3, 3, 1, 2, 3, 3, 5, 6, 7, 7, 6, 6, 7, 7, 0, 1, 3, 3, 1, 2, 3, 3, 5, 6, 7, 7, 6, 6, 7, 7,
|
||||||
5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
5, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 5, 6, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||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, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1,
|
||||||
0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1,
|
1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1,
|
||||||
0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
|
0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1
|
||||||
};
|
};
|
||||||
|
|
||||||
static const OPJ_INT16 lut_nmsedec_sig[1U << T1_NMSEDEC_BITS] = {
|
static const OPJ_INT16 lut_nmsedec_sig[1U << T1_NMSEDEC_BITS] = {
|
||||||
|
|
|
@ -38,6 +38,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "opj_includes.h"
|
#include "opj_includes.h"
|
||||||
|
#include "opj_common.h"
|
||||||
|
|
||||||
|
|
||||||
/** @defgroup T2 T2 - Implementation of a tier-2 coding */
|
/** @defgroup T2 T2 - Implementation of a tier-2 coding */
|
||||||
/*@{*/
|
/*@{*/
|
||||||
|
@ -1276,7 +1278,8 @@ static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
|
||||||
|
|
||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
/* Check possible overflow on size */
|
/* Check possible overflow on size */
|
||||||
if ((l_cblk->data_current_size + l_seg->newlen) < l_cblk->data_current_size) {
|
if ((l_cblk->data_current_size + l_seg->newlen + OPJ_COMMON_CBLK_DATA_EXTRA) <
|
||||||
|
l_cblk->data_current_size) {
|
||||||
opj_event_msg(p_manager, EVT_ERROR,
|
opj_event_msg(p_manager, EVT_ERROR,
|
||||||
"read: segment too long (%d) with current size (%d > %d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
|
"read: segment too long (%d) with current size (%d > %d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
|
||||||
l_seg->newlen, l_cblk->data_current_size, 0xFFFFFFFF - l_seg->newlen, cblkno,
|
l_seg->newlen, l_cblk->data_current_size, 0xFFFFFFFF - l_seg->newlen, cblkno,
|
||||||
|
@ -1284,9 +1287,10 @@ static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
/* Check if the cblk->data have allocated enough memory */
|
/* Check if the cblk->data have allocated enough memory */
|
||||||
if ((l_cblk->data_current_size + l_seg->newlen) > l_cblk->data_max_size) {
|
if ((l_cblk->data_current_size + l_seg->newlen + OPJ_COMMON_CBLK_DATA_EXTRA) >
|
||||||
|
l_cblk->data_max_size) {
|
||||||
OPJ_BYTE* new_cblk_data = (OPJ_BYTE*) opj_realloc(l_cblk->data,
|
OPJ_BYTE* new_cblk_data = (OPJ_BYTE*) opj_realloc(l_cblk->data,
|
||||||
l_cblk->data_current_size + l_seg->newlen);
|
l_cblk->data_current_size + l_seg->newlen + OPJ_COMMON_CBLK_DATA_EXTRA);
|
||||||
if (! new_cblk_data) {
|
if (! new_cblk_data) {
|
||||||
opj_free(l_cblk->data);
|
opj_free(l_cblk->data);
|
||||||
l_cblk->data = NULL;
|
l_cblk->data = NULL;
|
||||||
|
@ -1294,7 +1298,8 @@ static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
|
||||||
/* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to realloc code block cata!\n"); */
|
/* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to realloc code block cata!\n"); */
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
l_cblk->data_max_size = l_cblk->data_current_size + l_seg->newlen;
|
l_cblk->data_max_size = l_cblk->data_current_size + l_seg->newlen +
|
||||||
|
OPJ_COMMON_CBLK_DATA_EXTRA;
|
||||||
l_cblk->data = new_cblk_data;
|
l_cblk->data = new_cblk_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "opj_includes.h"
|
#include "opj_includes.h"
|
||||||
|
#include "opj_common.h"
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
@ -1213,11 +1214,11 @@ static OPJ_BOOL opj_tcd_code_block_dec_allocate(opj_tcd_cblk_dec_t *
|
||||||
{
|
{
|
||||||
if (! p_code_block->data) {
|
if (! p_code_block->data) {
|
||||||
|
|
||||||
p_code_block->data = (OPJ_BYTE*) opj_malloc(OPJ_J2K_DEFAULT_CBLK_DATA_SIZE);
|
p_code_block->data = (OPJ_BYTE*) opj_malloc(OPJ_COMMON_DEFAULT_CBLK_DATA_SIZE);
|
||||||
if (! p_code_block->data) {
|
if (! p_code_block->data) {
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
p_code_block->data_max_size = OPJ_J2K_DEFAULT_CBLK_DATA_SIZE;
|
p_code_block->data_max_size = OPJ_COMMON_DEFAULT_CBLK_DATA_SIZE;
|
||||||
/*fprintf(stderr, "Allocate 8192 elements of code_block->data\n");*/
|
/*fprintf(stderr, "Allocate 8192 elements of code_block->data\n");*/
|
||||||
|
|
||||||
p_code_block->segs = (opj_tcd_seg_t *) opj_calloc(OPJ_J2K_DEFAULT_NB_SEGS,
|
p_code_block->segs = (opj_tcd_seg_t *) opj_calloc(OPJ_J2K_DEFAULT_NB_SEGS,
|
||||||
|
|
Loading…
Reference in New Issue