[b2.x.x] backport into 2.x.x the rev 2266 and 2285 of trunk
This commit is contained in:
parent
10a994bbf8
commit
eaf1f4429b
|
@ -59,6 +59,8 @@ 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 */
|
||||
|
|
|
@ -524,7 +524,7 @@ OPJ_BOOL opj_t2_encode_packet( OPJ_UINT32 tileno,
|
|||
opj_codestream_info_t *cstr_info)
|
||||
{
|
||||
OPJ_UINT32 bandno, cblkno;
|
||||
OPJ_BYTE *c = dest;
|
||||
OPJ_BYTE* c = dest;
|
||||
OPJ_UINT32 l_nb_bytes;
|
||||
OPJ_UINT32 compno = pi->compno; /* component value */
|
||||
OPJ_UINT32 resno = pi->resno; /* resolution level value */
|
||||
|
@ -1076,7 +1076,7 @@ OPJ_BOOL opj_t2_read_packet_data( opj_t2_t* p_t2,
|
|||
if (!l_cblk->numsegs) {
|
||||
l_seg = l_cblk->segs;
|
||||
++l_cblk->numsegs;
|
||||
l_cblk->len = 0;
|
||||
l_cblk->data_current_size = 0;
|
||||
}
|
||||
else {
|
||||
l_seg = &l_cblk->segs[l_cblk->numsegs - 1];
|
||||
|
@ -1111,16 +1111,24 @@ OPJ_BOOL opj_t2_read_packet_data( opj_t2_t* p_t2,
|
|||
};
|
||||
|
||||
#endif /* USE_JPWL */
|
||||
|
||||
if ((l_cblk->len + l_seg->newlen) > 8192) {
|
||||
/* Check if the cblk->data have allocated enough memory */
|
||||
if ((l_cblk->data_current_size + l_seg->newlen) > 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);
|
||||
if(! new_cblk_data) {
|
||||
opj_free(l_cblk->data);
|
||||
l_cblk->data_max_size = 0;
|
||||
/* 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 = new_cblk_data;
|
||||
}
|
||||
|
||||
memcpy(l_cblk->data + l_cblk->len, l_current_data, l_seg->newlen);
|
||||
memcpy(l_cblk->data + l_cblk->data_current_size, l_current_data, l_seg->newlen);
|
||||
|
||||
if (l_seg->numpasses == 0) {
|
||||
l_seg->data = &l_cblk->data;
|
||||
l_seg->dataindex = l_cblk->len;
|
||||
l_seg->dataindex = l_cblk->data_current_size;
|
||||
}
|
||||
|
||||
l_current_data += l_seg->newlen;
|
||||
|
@ -1128,7 +1136,7 @@ OPJ_BOOL opj_t2_read_packet_data( opj_t2_t* p_t2,
|
|||
l_cblk->numnewpasses -= l_seg->numnewpasses;
|
||||
|
||||
l_seg->real_num_passes = l_seg->numpasses;
|
||||
l_cblk->len += l_seg->newlen;
|
||||
l_cblk->data_current_size += l_seg->newlen;
|
||||
l_seg->len += l_seg->newlen;
|
||||
|
||||
if (l_cblk->numnewpasses > 0) {
|
||||
|
@ -1139,7 +1147,7 @@ OPJ_BOOL opj_t2_read_packet_data( opj_t2_t* p_t2,
|
|||
|
||||
l_cblk->real_num_segs = l_cblk->numsegs;
|
||||
++l_cblk;
|
||||
}
|
||||
} /* next code_block */
|
||||
|
||||
++l_band;
|
||||
}
|
||||
|
@ -1191,7 +1199,7 @@ OPJ_BOOL opj_t2_skip_packet_data( opj_t2_t* p_t2,
|
|||
if (!l_cblk->numsegs) {
|
||||
l_seg = l_cblk->segs;
|
||||
++l_cblk->numsegs;
|
||||
l_cblk->len = 0;
|
||||
l_cblk->data_current_size = 0;
|
||||
}
|
||||
else {
|
||||
l_seg = &l_cblk->segs[l_cblk->numsegs - 1];
|
||||
|
|
|
@ -1001,7 +1001,7 @@ OPJ_BOOL opj_tcd_code_block_enc_allocate (opj_tcd_cblk_enc_t * p_code_block)
|
|||
{
|
||||
if (! p_code_block->data) {
|
||||
|
||||
p_code_block->data = (OPJ_BYTE*) opj_malloc(8192+1);
|
||||
p_code_block->data = (OPJ_BYTE*) opj_malloc(OPJ_J2K_DEFAULT_CBLK_DATA_SIZE); //why +1 ?
|
||||
if(! p_code_block->data) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
@ -1036,10 +1036,11 @@ OPJ_BOOL opj_tcd_code_block_dec_allocate (opj_tcd_cblk_dec_t * p_code_block)
|
|||
|
||||
if (! p_code_block->data) {
|
||||
|
||||
p_code_block->data = (OPJ_BYTE*) opj_malloc(8192);
|
||||
p_code_block->data = (OPJ_BYTE*) opj_malloc(OPJ_J2K_DEFAULT_CBLK_DATA_SIZE);
|
||||
if (! p_code_block->data) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
p_code_block->data_max_size = OPJ_J2K_DEFAULT_CBLK_DATA_SIZE;
|
||||
/*fprintf(stderr, "Allocate 8192 elements of code_block->data\n");*/
|
||||
|
||||
l_seg_size = OPJ_J2K_DEFAULT_NB_SEGS * sizeof(opj_tcd_seg_t);
|
||||
|
@ -1213,8 +1214,7 @@ OPJ_BOOL opj_tcd_decode_tile( opj_tcd_t *p_tcd,
|
|||
/*--------------TIER2------------------*/
|
||||
/* FIXME _ProfStart(PGROUP_T2); */
|
||||
l_data_read = 0;
|
||||
if
|
||||
(! opj_tcd_t2_decode(p_tcd, p_src, &l_data_read, p_max_length, p_cstr_index))
|
||||
if (! opj_tcd_t2_decode(p_tcd, p_src, &l_data_read, p_max_length, p_cstr_index))
|
||||
{
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
@ -1746,7 +1746,7 @@ void opj_tcd_code_block_enc_deallocate (opj_tcd_precinct_t * p_precinct)
|
|||
|
||||
for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
|
||||
if (l_code_block->data) {
|
||||
opj_free(l_code_block->data-1);
|
||||
opj_free(l_code_block->data - 1);
|
||||
l_code_block->data = 00;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,10 +96,11 @@ typedef struct opj_tcd_cblk_enc {
|
|||
typedef struct opj_tcd_cblk_dec {
|
||||
OPJ_BYTE * data; /* Data */
|
||||
opj_tcd_seg_t* segs; /* segments information */
|
||||
OPJ_INT32 x0, y0, x1, y1; /* dimension of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
OPJ_INT32 x0, y0, x1, y1; /* position of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
OPJ_UINT32 numbps;
|
||||
OPJ_UINT32 numlenbits;
|
||||
OPJ_UINT32 len; /* length */
|
||||
OPJ_UINT32 data_max_size; /* Size of allocated data buffer */
|
||||
OPJ_UINT32 data_current_size; /* Size of used data buffer */
|
||||
OPJ_UINT32 numnewpasses; /* number of pass added to the code-blocks */
|
||||
OPJ_UINT32 numsegs; /* number of segments */
|
||||
OPJ_UINT32 real_num_segs;
|
||||
|
|
|
@ -27,6 +27,10 @@ opj_compress -i @INPUT_NR_PATH@/Bretagne2.ppm -o @TEMP_PATH@/Bretagne2_4.j2k -d
|
|||
opj_compress -i @INPUT_NR_PATH@/Cevennes1.bmp -o @TEMP_PATH@/Cevennes1.j2k -r 10
|
||||
opj_compress -i @INPUT_NR_PATH@/Cevennes2.ppm -o @TEMP_PATH@/Cevennes2.jp2 -r 50
|
||||
opj_compress -i @INPUT_NR_PATH@/Rome.bmp -o @TEMP_PATH@/Rome.jp2 -q 30,35,50 -p LRCP -n 3
|
||||
# related to issue 5
|
||||
opj_compress -i @INPUT_NR_PATH@/random.tif -o @TEMP_PATH@/random.tif.j2k
|
||||
# related to issue 62
|
||||
opj_compress -i @INPUT_NR_PATH@/tmp.raw -o @TEMP_PATH@/tmp.raw.j2k -F 512,512,1,16,u
|
||||
opj_compress -i @INPUT_NR_PATH@/X_4_2K_24_185_CBR_WB_000.tif -o @TEMP_PATH@/X_4_2K_24_185_CBR_WB_000.j2k -cinema2K 24
|
||||
opj_compress -i @INPUT_NR_PATH@/X_5_2K_24_235_CBR_STEM24_000.tif -o @TEMP_PATH@/X_5_2K_24_235_CBR_STEM24_000.j2k -cinema2K 24
|
||||
opj_compress -i @INPUT_NR_PATH@/X_6_2K_24_FULL_CBR_CIRCLE_000.tif -o @TEMP_PATH@/X_6_2K_24_FULL_CBR_CIRCLE_000.j2k -cinema2K 24
|
||||
|
|
Loading…
Reference in New Issue