MQC/RAW decoder: use an artificial 0xFF 0xFF terminating marker.

This saves comparing the current pointer with the end of buffer pointer.
This results at least in tiny speed improvement for raw decoding, and
smaller code size for MQC as well.

This kills the remains of the raw.h/.c files that were only used for
decoding. Encoding using the mqc structure already.
This commit is contained in:
Even Rouault 2017-06-02 16:49:26 +02:00
parent 9b39fc4bcc
commit 532243f1fd
13 changed files with 173 additions and 233 deletions

View File

@ -38,8 +38,6 @@ set(OPENJPEG_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/opj_clock.h
${CMAKE_CURRENT_SOURCE_DIR}/pi.c
${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.h
${CMAKE_CURRENT_SOURCE_DIR}/t2.c

View File

@ -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_SEQNT 2
#define OPJ_J2K_DEFAULT_CBLK_DATA_SIZE 8192
/* ----------------------------------------------------------------------- */
#define J2K_MS_SOC 0xff4f /**< SOC marker value */

View File

@ -38,6 +38,8 @@
#include "opj_includes.h"
#include <assert.h>
/** @defgroup MQC MQC - Implementation of an MQ-Coder */
/*@{*/
@ -423,17 +425,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) */
/* Note: alternate "J.1 - Initialization of the software-conventions */
/* decoder" has been tried, but does */
/* not bring any improvement. */
/* See https://github.com/uclouvain/openjpeg/issues/921 */
opj_mqc_init_dec_common(mqc, bp, len, extra_writable_bytes);
opj_mqc_setcurctx(mqc, 0);
mqc->start = bp;
mqc->end = bp + len;
mqc->bp = bp;
if (len == 0) {
mqc->c = 0xff << 16;
} else {
@ -444,7 +464,22 @@ OPJ_BOOL opj_mqc_init_dec(opj_mqc_t *mqc, OPJ_BYTE *bp, OPJ_UINT32 len)
mqc->c <<= 7;
mqc->ct -= 7;
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)

View File

@ -38,6 +38,9 @@
#ifndef __MQC_H
#define __MQC_H
#include "opj_common.h"
/**
@file mqc.h
@brief Implementation of an MQ-Coder (MQC)
@ -69,16 +72,26 @@ typedef struct opj_mqc_state {
MQ coder
*/
typedef struct opj_mqc {
/** temporary buffer where bits are coded or decoded */
OPJ_UINT32 c;
/** only used by MQ decoder */
OPJ_UINT32 a;
/** number of bits already read or free to write */
OPJ_UINT32 ct;
/** 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;
/** Array of contexts */
opj_mqc_state_t *ctxs[MQC_NUMCTXS];
/** Active context */
opj_mqc_state_t **curctx;
/* 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;
#include "mqc_inl.h"
@ -179,13 +192,60 @@ SEGMARK mode switch (SEGSYM)
@param mqc MQC handle
*/
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 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.
*/
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
@param mqc MQC handle

View File

@ -65,15 +65,46 @@
} \
}
/**
Decode a symbol using raw-decoder. Cfr p.506 TAUBMAN
@param mqc MQC handle
@return Returns the decoded symbol (0 or 1)
*/
static INLINE OPJ_UINT32 opj_mqc_raw_decode(opj_mqc_t *mqc)
{
OPJ_UINT32 d;
if (mqc->ct == 0) {
/* Given opj_mqc_raw_init_dec() we know that at some point we will */
/* have a 0xFF 0xFF artificial marker */
if (mqc->c == 0xff) {
if (*mqc->bp > 0x8f) {
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;
}
#define opj_mqc_bytein_macro(mqc, c, ct) \
{ \
if (mqc->bp != mqc->end) { \
OPJ_UINT32 l_c; \
if (mqc->bp + 1 != mqc->end) { \
l_c = *(mqc->bp + 1); \
} else { \
l_c = 0xff; \
} \
/* 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; \
@ -88,10 +119,6 @@
c += l_c << 8; \
ct = 8; \
} \
} else { \
c += 0xff00; \
ct = 8; \
} \
}
/* For internal use of opj_mqc_decode_macro() */

View File

@ -4,11 +4,7 @@
* 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
* Copyright (c) 2017, IntoPIX SA <support@intopix.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -32,29 +28,15 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef OPJ_COMMMON_H
#define OPJ_COMMMON_H
/**
Decode a symbol using raw-decoder. Cfr p.506 TAUBMAN
@param raw RAW handle
@return Returns the decoded symbol (0 or 1)
/*
==========================================================
Common constants shared among several modules
==========================================================
*/
static INLINE 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;
#define OPJ_COMMON_DEFAULT_CBLK_DATA_SIZE 8192
#define OPJ_COMMON_CBLK_DATA_EXTRA 2 /**< Margin for a fake FFFF marker */
return d;
}
#endif /* OPJ_COMMMON_H */

View File

@ -207,7 +207,6 @@ typedef unsigned int OPJ_BITFIELD;
#include "jp2.h"
#include "mqc.h"
#include "raw.h"
#include "bio.h"
#include "pi.h"

View File

@ -1,65 +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.
*/
#include "opj_includes.h"
/*
==========================================================
local functions
==========================================================
*/
/*
==========================================================
RAW encoding interface
==========================================================
*/
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;
}

View File

@ -1,99 +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;
#include "raw_inl.h"
/** @name Exported functions */
/*@{*/
/* ----------------------------------------------------------------------- */
/**
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)
*/
static INLINE OPJ_UINT32 opj_raw_decode(opj_raw_t *raw);
/* ----------------------------------------------------------------------- */
/*@}*/
/*@}*/
#endif /* __RAW_H */

View File

@ -376,14 +376,14 @@ static INLINE void opj_t1_dec_sigpass_step_raw(
OPJ_UINT32 ci)
{
OPJ_UINT32 v;
opj_raw_t *raw = &(t1->raw); /* RAW component */
opj_mqc_t *mqc = &(t1->mqc); /* RAW component */
OPJ_UINT32 const flags = *flagsp;
if ((flags & ((T1_SIGMA_THIS | T1_PI_THIS) << (ci * 3U))) == 0U &&
(flags & (T1_SIGMA_NEIGHBOURS << (ci * 3U))) != 0U) {
if (opj_raw_decode(raw)) {
v = opj_raw_decode(raw);
if (opj_mqc_raw_decode(mqc)) {
v = opj_mqc_raw_decode(mqc);
*datap = v ? -oneplushalf : oneplushalf;
opj_t1_update_flags(flagsp, ci, v, t1->w + 2, vsc);
}
@ -747,11 +747,11 @@ static INLINE void opj_t1_dec_refpass_step_raw(
{
OPJ_UINT32 v;
opj_raw_t *raw = &(t1->raw); /* RAW component */
opj_mqc_t *mqc = &(t1->mqc); /* RAW component */
if ((*flagsp & ((T1_SIGMA_THIS | T1_PI_THIS) << (ci * 3U))) ==
(T1_SIGMA_THIS << (ci * 3U))) {
v = opj_raw_decode(raw);
v = opj_mqc_raw_decode(mqc);
*datap += (v ^ (*datap < 0)) ? poshalf : -poshalf;
*flagsp |= T1_MU_THIS << (ci * 3U);
}
@ -1793,7 +1793,6 @@ static OPJ_BOOL opj_t1_decode_cblk(opj_t1_t *t1,
OPJ_UINT32 roishift,
OPJ_UINT32 cblksty)
{
opj_raw_t *raw = &(t1->raw); /* RAW component */
opj_mqc_t *mqc = &(t1->mqc); /* MQC component */
OPJ_INT32 bpno_plus_one;
@ -1829,12 +1828,11 @@ static OPJ_BOOL opj_t1_decode_cblk(opj_t1_t *t1,
continue;
}
if (type == T1_TYPE_RAW) {
opj_raw_init_dec(raw, (*seg->data) + seg->dataindex, seg->len);
opj_mqc_raw_init_dec(mqc, (*seg->data) + seg->dataindex, seg->len,
OPJ_COMMON_CBLK_DATA_EXTRA);
} else {
if (OPJ_FALSE == opj_mqc_init_dec(mqc, (*seg->data) + seg->dataindex,
seg->len)) {
return OPJ_FALSE;
}
opj_mqc_init_dec(mqc, (*seg->data) + seg->dataindex, seg->len,
OPJ_COMMON_CBLK_DATA_EXTRA);
}
for (passno = 0; (passno < seg->real_num_passes) &&
@ -1870,7 +1868,10 @@ static OPJ_BOOL opj_t1_decode_cblk(opj_t1_t *t1,
bpno_plus_one--;
}
}
opq_mqc_finish_dec(mqc);
}
return OPJ_TRUE;
}

View File

@ -185,8 +185,6 @@ typedef struct opj_t1 {
/** MQC component */
opj_mqc_t mqc;
/** RAW component */
opj_raw_t raw;
OPJ_INT32 *data;
/** Flags used by decoder and encoder.

View File

@ -38,6 +38,8 @@
*/
#include "opj_includes.h"
#include "opj_common.h"
/** @defgroup T2 T2 - Implementation of a tier-2 coding */
/*@{*/
@ -1233,7 +1235,8 @@ static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
#endif /* USE_JPWL */
/* 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,
"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,
@ -1241,9 +1244,10 @@ static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
return OPJ_FALSE;
}
/* 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,
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) {
opj_free(l_cblk->data);
l_cblk->data = NULL;
@ -1251,7 +1255,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"); */
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;
}

View File

@ -39,6 +39,7 @@
*/
#include "opj_includes.h"
#include "opj_common.h"
/* ----------------------------------------------------------------------- */
@ -1185,11 +1186,11 @@ static OPJ_BOOL opj_tcd_code_block_dec_allocate(opj_tcd_cblk_dec_t *
{
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) {
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");*/
p_code_block->segs = (opj_tcd_seg_t *) opj_calloc(OPJ_J2K_DEFAULT_NB_SEGS,