WIP: update t1, t2, tcd to use same strut as in V2
This commit is contained in:
parent
1a5c59326a
commit
6561d70664
1
CHANGES
1
CHANGES
|
@ -6,6 +6,7 @@ What's New for OpenJPEG
|
|||
+ : added
|
||||
|
||||
September 19, 2011
|
||||
+ [mickael] WIP: update t1, t2, tcd to use same strut as in V2
|
||||
+ [mickael] WIP: begin to test opj_read_tile_header with V2 style
|
||||
+ [mickael] WIP: create a new framework to output file information
|
||||
+ [mickael] WIP: remove a piece of code copy by the merge op at the wrong place
|
||||
|
|
|
@ -123,6 +123,10 @@ static void dwt_decode_tile(opj_tcd_tilecomp_t* tilec, int i, DWT1DFN fn);
|
|||
#endif
|
||||
static opj_bool dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 i, DWT1DFN fn);
|
||||
|
||||
/**
|
||||
Inverse wavelet transform in 2-D.
|
||||
*/
|
||||
static opj_bool dwt_decode_tile_v2(opj_tcd_tilecomp_v2_t* tilec, OPJ_UINT32 i, DWT1DFN fn);
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
@ -395,6 +399,13 @@ opj_bool dwt_decode(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres) {
|
|||
return dwt_decode_tile(tilec, numres, &dwt_decode_1);
|
||||
}
|
||||
|
||||
/* <summary> */
|
||||
/* Inverse 5-3 wavelet transform in 2-D. */
|
||||
/* </summary> */
|
||||
opj_bool dwt_decode_v2(opj_tcd_tilecomp_v2_t* tilec, OPJ_UINT32 numres) {
|
||||
return dwt_decode_tile_v2(tilec, numres, &dwt_decode_1);
|
||||
}
|
||||
|
||||
|
||||
/* <summary> */
|
||||
/* Get gain of 5-3 wavelet transform. */
|
||||
|
@ -407,6 +418,17 @@ int dwt_getgain(int orient) {
|
|||
return 2;
|
||||
}
|
||||
|
||||
/* <summary> */
|
||||
/* Get gain of 5-3 wavelet transform. */
|
||||
/* </summary> */
|
||||
OPJ_UINT32 dwt_getgain_v2(OPJ_UINT32 orient) {
|
||||
if (orient == 0)
|
||||
return 0;
|
||||
if (orient == 1 || orient == 2)
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* <summary> */
|
||||
/* Get norm of 5-3 wavelet. */
|
||||
/* </summary> */
|
||||
|
@ -479,6 +501,14 @@ int dwt_getgain_real(int orient) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* <summary> */
|
||||
/* Get gain of 9-7 wavelet transform. */
|
||||
/* </summary> */
|
||||
OPJ_UINT32 dwt_getgain_real_v2(OPJ_UINT32 orient) {
|
||||
(void)orient;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* <summary> */
|
||||
/* Get norm of 9-7 wavelet. */
|
||||
/* </summary> */
|
||||
|
@ -540,6 +570,22 @@ static OPJ_UINT32 dwt_max_resolution(opj_tcd_resolution_t* restrict r, OPJ_UINT3
|
|||
return mr ;
|
||||
}
|
||||
|
||||
/* <summary> */
|
||||
/* Determine maximum computed resolution level for inverse wavelet transform */
|
||||
/* </summary> */
|
||||
static OPJ_UINT32 dwt_max_resolution_v2(opj_tcd_resolution_v2_t* restrict r, OPJ_UINT32 i) {
|
||||
OPJ_UINT32 mr = 0;
|
||||
OPJ_UINT32 w;
|
||||
while( --i ) {
|
||||
++r;
|
||||
if( mr < ( w = r->x1 - r->x0 ) )
|
||||
mr = w ;
|
||||
if( mr < ( w = r->y1 - r->y0 ) )
|
||||
mr = w ;
|
||||
}
|
||||
return mr ;
|
||||
}
|
||||
|
||||
#ifdef OPJ_V1
|
||||
/* <summary> */
|
||||
/* Inverse wavelet transform in 2-D. */
|
||||
|
@ -654,6 +700,66 @@ static opj_bool dwt_decode_tile(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres, DW
|
|||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
/* <summary> */
|
||||
/* Inverse wavelet transform in 2-D. */
|
||||
/* </summary> */
|
||||
static opj_bool dwt_decode_tile_v2(opj_tcd_tilecomp_v2_t* tilec, OPJ_UINT32 numres, DWT1DFN dwt_1D) {
|
||||
dwt_t h;
|
||||
dwt_t v;
|
||||
|
||||
opj_tcd_resolution_v2_t* tr = tilec->resolutions;
|
||||
|
||||
OPJ_UINT32 rw = tr->x1 - tr->x0; /* width of the resolution level computed */
|
||||
OPJ_UINT32 rh = tr->y1 - tr->y0; /* height of the resolution level computed */
|
||||
|
||||
OPJ_UINT32 w = tilec->x1 - tilec->x0;
|
||||
|
||||
h.mem = (OPJ_INT32*)
|
||||
opj_aligned_malloc(dwt_max_resolution_v2(tr, numres) * sizeof(OPJ_INT32));
|
||||
if
|
||||
(! h.mem)
|
||||
{
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
v.mem = h.mem;
|
||||
|
||||
while( --numres) {
|
||||
OPJ_INT32 * restrict tiledp = tilec->data;
|
||||
OPJ_UINT32 j;
|
||||
|
||||
++tr;
|
||||
h.sn = rw;
|
||||
v.sn = rh;
|
||||
|
||||
rw = tr->x1 - tr->x0;
|
||||
rh = tr->y1 - tr->y0;
|
||||
|
||||
h.dn = rw - h.sn;
|
||||
h.cas = tr->x0 % 2;
|
||||
|
||||
for(j = 0; j < rh; ++j) {
|
||||
dwt_interleave_h(&h, &tiledp[j*w]);
|
||||
(dwt_1D)(&h);
|
||||
memcpy(&tiledp[j*w], h.mem, rw * sizeof(OPJ_INT32));
|
||||
}
|
||||
|
||||
v.dn = rh - v.sn;
|
||||
v.cas = tr->y0 % 2;
|
||||
|
||||
for(j = 0; j < rw; ++j){
|
||||
OPJ_UINT32 k;
|
||||
dwt_interleave_v(&v, &tiledp[j], w);
|
||||
(dwt_1D)(&v);
|
||||
for(k = 0; k < rh; ++k) {
|
||||
tiledp[k * w + j] = v.mem[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
opj_aligned_free(h.mem);
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static void v4dwt_interleave_h(v4dwt_t* restrict w, float* restrict a, int x, int size){
|
||||
float* restrict bi = (float*) (w->wavelet + w->cas);
|
||||
int count = w->sn;
|
||||
|
@ -949,3 +1055,92 @@ opj_bool dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, int numres){
|
|||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* <summary> */
|
||||
/* Inverse 9-7 wavelet transform in 2-D. */
|
||||
/* </summary> */
|
||||
opj_bool dwt_decode_real_v2(opj_tcd_tilecomp_v2_t* restrict tilec, OPJ_UINT32 numres){
|
||||
v4dwt_t h;
|
||||
v4dwt_t v;
|
||||
|
||||
opj_tcd_resolution_v2_t* res = tilec->resolutions;
|
||||
|
||||
OPJ_UINT32 rw = res->x1 - res->x0; /* width of the resolution level computed */
|
||||
OPJ_UINT32 rh = res->y1 - res->y0; /* height of the resolution level computed */
|
||||
|
||||
OPJ_UINT32 w = tilec->x1 - tilec->x0;
|
||||
|
||||
h.wavelet = (v4*) opj_aligned_malloc((dwt_max_resolution_v2(res, numres)+5) * sizeof(v4));
|
||||
v.wavelet = h.wavelet;
|
||||
|
||||
while( --numres) {
|
||||
OPJ_FLOAT32 * restrict aj = (OPJ_FLOAT32*) tilec->data;
|
||||
OPJ_UINT32 bufsize = (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0);
|
||||
OPJ_INT32 j;
|
||||
|
||||
h.sn = rw;
|
||||
v.sn = rh;
|
||||
|
||||
++res;
|
||||
|
||||
rw = res->x1 - res->x0; /* width of the resolution level computed */
|
||||
rh = res->y1 - res->y0; /* height of the resolution level computed */
|
||||
|
||||
h.dn = rw - h.sn;
|
||||
h.cas = res->x0 & 1;
|
||||
|
||||
for(j = rh; j > 0; j -= 4) {
|
||||
v4dwt_interleave_h(&h, aj, w, bufsize);
|
||||
v4dwt_decode(&h);
|
||||
|
||||
if(j >= 4){
|
||||
OPJ_INT32 k = rw;
|
||||
|
||||
while (--k >= 0) {
|
||||
aj[k ] = h.wavelet[k].f[0];
|
||||
aj[k+w ] = h.wavelet[k].f[1];
|
||||
aj[k+w*2] = h.wavelet[k].f[2];
|
||||
aj[k+w*3] = h.wavelet[k].f[3];
|
||||
}
|
||||
}
|
||||
else {
|
||||
OPJ_INT32 k = rw;
|
||||
|
||||
while (--k >= 0) {
|
||||
switch(j) {
|
||||
case 3: aj[k+w*2] = h.wavelet[k].f[2];
|
||||
case 2: aj[k+w ] = h.wavelet[k].f[1];
|
||||
case 1: aj[k ] = h.wavelet[k].f[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aj += w*4;
|
||||
bufsize -= w*4;
|
||||
}
|
||||
|
||||
v.dn = rh - v.sn;
|
||||
v.cas = res->y0 % 2;
|
||||
|
||||
aj = (OPJ_FLOAT32*) tilec->data;
|
||||
for(j = rw; j > 0; j -= 4){
|
||||
v4dwt_interleave_v(&v, aj, w);
|
||||
v4dwt_decode(&v);
|
||||
if(j >= 4){
|
||||
OPJ_UINT32 k;
|
||||
for(k = 0; k < rh; ++k){
|
||||
memcpy(&aj[k*w], &v.wavelet[k], 4 * sizeof(OPJ_FLOAT32));
|
||||
}
|
||||
}else{
|
||||
OPJ_UINT32 k;
|
||||
for(k = 0; k < rh; ++k){
|
||||
memcpy(&aj[k*w], &v.wavelet[k], j * sizeof(OPJ_FLOAT32));
|
||||
}
|
||||
}
|
||||
aj += 4;
|
||||
}
|
||||
}
|
||||
|
||||
opj_aligned_free(h.wavelet);
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ void dwt_decode(opj_tcd_tilecomp_t* tilec, int numres);
|
|||
#endif
|
||||
opj_bool dwt_decode(opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres);
|
||||
|
||||
opj_bool dwt_decode_v2(opj_tcd_tilecomp_v2_t* tilec, OPJ_UINT32 numres);
|
||||
|
||||
/**
|
||||
Get the gain of a subband for the reversible 5-3 DWT.
|
||||
|
@ -71,6 +72,8 @@ Get the gain of a subband for the reversible 5-3 DWT.
|
|||
@return Returns 0 if orient = 0, returns 1 if orient = 1 or 2, returns 2 otherwise
|
||||
*/
|
||||
int dwt_getgain(int orient);
|
||||
|
||||
OPJ_UINT32 dwt_getgain_v2(OPJ_UINT32 orient) ;
|
||||
/**
|
||||
Get the norm of a wavelet function of a subband at a specified level for the reversible 5-3 DWT.
|
||||
@param level Level of the wavelet function
|
||||
|
@ -93,12 +96,16 @@ Apply an irreversible inverse DWT transform to a component of an image.
|
|||
*/
|
||||
// V1 void dwt_decode_real(opj_tcd_tilecomp_t* tilec, int numres);
|
||||
opj_bool dwt_decode_real(opj_tcd_tilecomp_t* tilec, int numres);
|
||||
|
||||
opj_bool dwt_decode_real_v2(opj_tcd_tilecomp_v2_t* restrict tilec, OPJ_UINT32 numres);
|
||||
|
||||
/**
|
||||
Get the gain of a subband for the irreversible 9-7 DWT.
|
||||
@param orient Number that identifies the subband (0->LL, 1->HL, 2->LH, 3->HH)
|
||||
@return Returns the gain of the 9-7 wavelet transform
|
||||
*/
|
||||
int dwt_getgain_real(int orient);
|
||||
OPJ_UINT32 dwt_getgain_real_v2(OPJ_UINT32 orient);
|
||||
/**
|
||||
Get the norm of a wavelet function of a subband at a specified level for the irreversible 9-7 DWT
|
||||
@param level Level of the wavelet function
|
||||
|
|
|
@ -2997,29 +2997,32 @@ static void j2k_read_ppt(opj_j2k_t *j2k) {
|
|||
* @param p_header_size the size of the data contained in the PPT marker.
|
||||
* @param p_manager the user event manager.
|
||||
*/
|
||||
opj_bool j2k_read_ppt_v2 (
|
||||
opj_j2k_v2_t *p_j2k,
|
||||
OPJ_BYTE * p_header_data,
|
||||
OPJ_UINT32 p_header_size,
|
||||
struct opj_event_mgr * p_manager
|
||||
)
|
||||
opj_bool j2k_read_ppt_v2 ( opj_j2k_v2_t *p_j2k,
|
||||
OPJ_BYTE * p_header_data,
|
||||
OPJ_UINT32 p_header_size,
|
||||
struct opj_event_mgr * p_manager )
|
||||
{
|
||||
|
||||
opj_cp_v2_t *l_cp = 00;
|
||||
opj_tcp_v2_t *l_tcp = 00;
|
||||
OPJ_UINT32 l_Z_ppt;
|
||||
|
||||
// preconditions
|
||||
/* preconditions */
|
||||
assert(p_header_data != 00);
|
||||
assert(p_j2k != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
/* We need to have the Z_ppt element at minimum */
|
||||
if (p_header_size < 1) {
|
||||
opj_event_msg_v2(p_manager, EVT_ERROR, "Error reading PPT marker\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
l_cp = &(p_j2k->m_cp);
|
||||
if (l_cp->ppm){
|
||||
opj_event_msg_v2(p_manager, EVT_ERROR, "Error reading PPT marker: packet header have been previously found in the main header (PPM marker).\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
l_tcp = &(l_cp->tcps[p_j2k->m_current_tile_number]);
|
||||
l_tcp->ppt = 1;
|
||||
|
||||
|
@ -3027,35 +3030,39 @@ opj_bool j2k_read_ppt_v2 (
|
|||
++p_header_data;
|
||||
--p_header_size;
|
||||
|
||||
// first PPT marker
|
||||
/* Allocate buffer to read the packet header */
|
||||
if (l_Z_ppt == 0) {
|
||||
/* First PPT marker */
|
||||
l_tcp->ppt_len = p_header_size;
|
||||
l_tcp->ppt_data_size = 0;
|
||||
l_tcp->ppt_buffer = (OPJ_BYTE *) opj_malloc(l_tcp->ppt_len);
|
||||
l_tcp->ppt_data = l_tcp->ppt_buffer;
|
||||
l_tcp->ppt_len = p_header_size;
|
||||
|
||||
l_tcp->ppt_buffer = (OPJ_BYTE *) opj_calloc(l_tcp->ppt_len, sizeof(OPJ_BYTE) );
|
||||
if (l_tcp->ppt_buffer == 00) {
|
||||
opj_event_msg_v2(p_manager, EVT_ERROR, "Not enough memory reading PPT marker\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
memset(l_tcp->ppt_buffer,0,l_tcp->ppt_len);
|
||||
l_tcp->ppt_data = l_tcp->ppt_buffer;
|
||||
|
||||
/* memset(l_tcp->ppt_buffer,0,l_tcp->ppt_len); */
|
||||
}
|
||||
else {
|
||||
l_tcp->ppt_len += p_header_size;
|
||||
l_tcp->ppt_buffer = (OPJ_BYTE *) opj_realloc(l_tcp->ppt_buffer,l_tcp->ppt_len);
|
||||
|
||||
l_tcp->ppt_buffer = (OPJ_BYTE *) opj_realloc(l_tcp->ppt_buffer,l_tcp->ppt_len);
|
||||
if (l_tcp->ppt_buffer == 00) {
|
||||
opj_event_msg_v2(p_manager, EVT_ERROR, "Not enough memory reading PPT marker\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
l_tcp->ppt_data = l_tcp->ppt_buffer;
|
||||
|
||||
memset(l_tcp->ppt_buffer+l_tcp->ppt_data_size,0,p_header_size);
|
||||
}
|
||||
|
||||
/* Read packet header from buffer */
|
||||
memcpy(l_tcp->ppt_buffer+l_tcp->ppt_data_size,p_header_data,p_header_size);
|
||||
|
||||
l_tcp->ppt_data_size += p_header_size;
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
|
@ -3253,11 +3260,12 @@ opj_bool j2k_read_sot_v2 (
|
|||
OPJ_UINT32 l_current_part;
|
||||
OPJ_UINT32 l_tile_x,l_tile_y;
|
||||
|
||||
// preconditions
|
||||
/* preconditions */
|
||||
assert(p_header_data != 00);
|
||||
assert(p_j2k != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
/* Size of this marker is fixed = 12 (we have already read marker and its size)*/
|
||||
if (p_header_size != 8) {
|
||||
opj_event_msg_v2(p_manager, EVT_ERROR, "Error reading SOT marker\n");
|
||||
return OPJ_FALSE;
|
||||
|
@ -3322,7 +3330,6 @@ opj_bool j2k_read_sot_v2 (
|
|||
"- setting Psot to %d => assuming it is the last tile\n",
|
||||
totlen);
|
||||
}
|
||||
|
||||
};
|
||||
#endif /* USE_JPWL */
|
||||
|
||||
|
@ -3337,18 +3344,22 @@ opj_bool j2k_read_sot_v2 (
|
|||
opj_read_bytes(p_header_data,&l_num_parts ,1); /* TNsot */
|
||||
++p_header_data;
|
||||
|
||||
if (l_num_parts != 0) {
|
||||
if (l_num_parts != 0) { /* Number of tile-part header is provided by this tile-part header */
|
||||
l_tcp->m_nb_tile_parts = l_num_parts;
|
||||
}
|
||||
|
||||
/* If know the number of tile part header we will check if we didn't read the last*/
|
||||
if (l_tcp->m_nb_tile_parts) {
|
||||
if (l_tcp->m_nb_tile_parts == (l_current_part + 1)) {
|
||||
p_j2k->m_specific_param.m_decoder.m_can_decode = 1;
|
||||
p_j2k->m_specific_param.m_decoder.m_can_decode = 1; /* Process the last tile-part header*/
|
||||
}
|
||||
}
|
||||
|
||||
p_j2k->m_specific_param.m_decoder.m_sot_length = l_tot_len - 12; // SOT_marker_size = 12
|
||||
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPH;// FIXME J2K_DEC_STATE_TPH;
|
||||
/* Keep the size of data to skip after this marker */
|
||||
p_j2k->m_specific_param.m_decoder.m_sot_length = l_tot_len - 12; /* SOT_marker_size = 12 */
|
||||
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPH;
|
||||
|
||||
/* Check if the current tile is outside the area we want decode (in tile index)*/
|
||||
p_j2k->m_specific_param.m_decoder.m_skip_data =
|
||||
(l_tile_x < p_j2k->m_specific_param.m_decoder.m_start_tile_x)
|
||||
|| (l_tile_x >= p_j2k->m_specific_param.m_decoder.m_end_tile_x)
|
||||
|
@ -3545,7 +3556,9 @@ opj_bool j2k_read_sod_v2 (
|
|||
}
|
||||
|
||||
l_cstr_info = p_j2k->cstr_info;
|
||||
|
||||
/* Index */
|
||||
#ifdef TODO_MSD
|
||||
if (l_cstr_info) {
|
||||
OPJ_SIZE_T l_current_pos = opj_stream_tell(p_stream)-1;
|
||||
l_cstr_info->tile[p_j2k->m_current_tile_number].tp[p_j2k->m_specific_param.m_encoder.m_current_tile_part_number].tp_end_header = l_current_pos;
|
||||
|
@ -3556,6 +3569,7 @@ opj_bool j2k_read_sod_v2 (
|
|||
|
||||
l_cstr_info->packno = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
l_current_read_size = opj_stream_read_data( p_stream,
|
||||
*l_current_data + *l_tile_len,
|
||||
|
@ -3563,10 +3577,10 @@ opj_bool j2k_read_sod_v2 (
|
|||
p_manager);
|
||||
|
||||
if (l_current_read_size != p_j2k->m_specific_param.m_decoder.m_sot_length) {
|
||||
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC; // FIXME J2K_DEC_STATE_NEOC;
|
||||
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
|
||||
}
|
||||
else {
|
||||
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT; // FIXME J2K_DEC_STATE_TPHSOT;
|
||||
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT;
|
||||
}
|
||||
|
||||
*l_tile_len += l_current_read_size;
|
||||
|
@ -5169,10 +5183,10 @@ opj_bool j2k_read_header_procedure( opj_j2k_v2_t *p_j2k,
|
|||
// Read 2 bytes as the new marker ID
|
||||
opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2);
|
||||
|
||||
// Try to read until the SOT is detected
|
||||
/* Try to read until the SOT is detected */
|
||||
while (l_current_marker != J2K_MS_SOT) {
|
||||
|
||||
// Check if the current marker ID is valid
|
||||
/* Check if the current marker ID is valid */
|
||||
if (l_current_marker < 0xff00) {
|
||||
opj_event_msg_v2(p_manager, EVT_ERROR, "We expected read a marker ID (0xff--) instead of %.8x\n", l_current_marker);
|
||||
return OPJ_FALSE;
|
||||
|
@ -5683,7 +5697,7 @@ opj_bool j2k_read_tile_header( opj_j2k_v2_t * p_j2k,
|
|||
OPJ_UINT32 l_current_marker = J2K_MS_SOT;
|
||||
OPJ_UINT32 l_marker_size;
|
||||
const opj_dec_memory_marker_handler_t * l_marker_handler = 00;
|
||||
opj_tcp_v2_t * l_tcp = 00;
|
||||
opj_tcp_v2_t * l_tcp = NULL;
|
||||
OPJ_UINT32 l_nb_tiles;
|
||||
|
||||
/* preconditions */
|
||||
|
@ -5691,97 +5705,120 @@ opj_bool j2k_read_tile_header( opj_j2k_v2_t * p_j2k,
|
|||
assert(p_j2k != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
if (p_j2k->m_specific_param.m_decoder.m_state == 0x0100){// FIXME J2K_DEC_STATE_EOC)
|
||||
/* Reach the End Of Codestream ?*/
|
||||
if (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_EOC){
|
||||
l_current_marker = J2K_MS_EOC;
|
||||
}
|
||||
else if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_TPHSOT){ // FIXME J2K_DEC_STATE_TPHSOT)
|
||||
/* We need to encounter a SOT marker (a new tile-part header) */
|
||||
else if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_TPHSOT){
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* Read into the codestream until reach the EOC or ! can_decode ??? FIXME */
|
||||
while (! p_j2k->m_specific_param.m_decoder.m_can_decode && l_current_marker != J2K_MS_EOC) {
|
||||
|
||||
/* Try to read until the Start Of Data is detected */
|
||||
while (l_current_marker != J2K_MS_SOD) {
|
||||
|
||||
/* Try to read 2 bytes (the marker size) from stream and copy them into the buffer */
|
||||
if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2) {
|
||||
opj_event_msg_v2(p_manager, EVT_ERROR, "Stream too short\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* Read 2 bytes from the buffer as the marker size */
|
||||
opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_marker_size,2);
|
||||
|
||||
if (p_j2k->m_specific_param.m_decoder.m_state & J2K_STATE_TPH){ // FIXME J2K_DEC_STATE_TPH)
|
||||
/* Why this condition? FIXME */
|
||||
if (p_j2k->m_specific_param.m_decoder.m_state & J2K_STATE_TPH){
|
||||
p_j2k->m_specific_param.m_decoder.m_sot_length -= (l_marker_size + 2);
|
||||
}
|
||||
l_marker_size -= 2;
|
||||
l_marker_size -= 2; /* Subtract the size of the marker ID already read */
|
||||
|
||||
/* Get the marker handler from the marker ID */
|
||||
l_marker_handler = j2k_get_marker_handler(l_current_marker);
|
||||
|
||||
/* Check if the marker is known */
|
||||
/* Check if the marker is known and if it is the right place to find it */
|
||||
if (! (p_j2k->m_specific_param.m_decoder.m_state & l_marker_handler->states) ) {
|
||||
opj_event_msg_v2(p_manager, EVT_ERROR, "Marker is not compliant with its position\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
/* FIXME manage case of unknown marker as in the main header ? */
|
||||
|
||||
/* Check if the marker size is compatible with the header data size */
|
||||
if (l_marker_size > p_j2k->m_specific_param.m_decoder.m_header_data_size) {
|
||||
p_j2k->m_specific_param.m_decoder.m_header_data = (OPJ_BYTE*)
|
||||
opj_realloc(p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size);
|
||||
if (p_j2k->m_specific_param.m_decoder.m_header_data == 00) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
p_j2k->m_specific_param.m_decoder.m_header_data_size = l_marker_size;
|
||||
}
|
||||
|
||||
/* Try to read the rest of the marker segment from stream and copy them into the buffer */
|
||||
if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size,p_manager) != l_marker_size) {
|
||||
opj_event_msg_v2(p_manager, EVT_ERROR, "Stream too short\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* Read the marker segment with the correct marker handler */
|
||||
if (! (*(l_marker_handler->handler))(p_j2k,p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size,p_manager)) {
|
||||
opj_event_msg_v2(p_manager, EVT_ERROR, "Marker is not compliant with its position\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
if (p_j2k->m_specific_param.m_decoder.m_skip_data) {
|
||||
/* Skip the rest of the tile part header*/
|
||||
if (opj_stream_skip(p_stream,p_j2k->m_specific_param.m_decoder.m_sot_length,p_manager) != p_j2k->m_specific_param.m_decoder.m_sot_length) {
|
||||
opj_event_msg_v2(p_manager, EVT_ERROR, "Stream too short\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
l_current_marker = J2K_MS_SOD;
|
||||
l_current_marker = J2K_MS_SOD; /* Normally we reached a SOD */
|
||||
}
|
||||
else {
|
||||
/* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer*/
|
||||
if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2) {
|
||||
opj_event_msg_v2(p_manager, EVT_ERROR, "Stream too short\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
/* Read 2 bytes from the buffer as the new marker ID */
|
||||
opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2);
|
||||
}
|
||||
}
|
||||
|
||||
/* If we didn't skip data before, we need to read the SOD marker*/
|
||||
if (! p_j2k->m_specific_param.m_decoder.m_skip_data) {
|
||||
if (! j2k_read_sod_v2(p_j2k,p_stream,p_manager)) {
|
||||
/* Try to read the SOD marker and skip data ? FIXME */
|
||||
if (! j2k_read_sod_v2(p_j2k, p_stream, p_manager)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Indicate we will try to read a new tile-part header*/
|
||||
p_j2k->m_specific_param.m_decoder.m_skip_data = 0;
|
||||
p_j2k->m_specific_param.m_decoder.m_can_decode = 0;
|
||||
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT; // FIXME J2K_DEC_STATE_TPHSOT;
|
||||
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT;
|
||||
|
||||
/* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer */
|
||||
if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2) {
|
||||
opj_event_msg_v2(p_manager, EVT_ERROR, "Stream too short\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
/* Read 2 bytes from buffer as the new marker ID */
|
||||
opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2);
|
||||
}
|
||||
}
|
||||
|
||||
/* Current marker is the EOC marker ?*/
|
||||
if (l_current_marker == J2K_MS_EOC) {
|
||||
if (p_j2k->m_specific_param.m_decoder.m_state != 0x0100 ){// FIXME J2K_DEC_STATE_EOC)
|
||||
if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_EOC ){
|
||||
p_j2k->m_current_tile_number = 0;
|
||||
p_j2k->m_specific_param.m_decoder.m_state = 0x0100;// FIXME J2K_DEC_STATE_EOC;
|
||||
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_EOC;
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME ???*/
|
||||
if ( ! p_j2k->m_specific_param.m_decoder.m_can_decode) {
|
||||
l_tcp = p_j2k->m_cp.tcps + p_j2k->m_current_tile_number;
|
||||
l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
|
||||
|
@ -5797,6 +5834,7 @@ opj_bool j2k_read_tile_header( opj_j2k_v2_t * p_j2k,
|
|||
}
|
||||
}
|
||||
|
||||
/*FIXME ???*/
|
||||
if (! tcd_init_decode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_number)) {
|
||||
opj_event_msg_v2(p_manager, EVT_ERROR, "Cannot decode tile, memory error\n");
|
||||
return OPJ_FALSE;
|
||||
|
@ -5919,10 +5957,10 @@ opj_bool j2k_set_decode_area( opj_j2k_v2_t *p_j2k,
|
|||
/* Check if the positions provided by the user are correct */
|
||||
|
||||
/* Left */
|
||||
if (p_start_x > l_cp->tw * l_cp->tdx) {
|
||||
if (p_start_x > l_cp->tx0 + l_cp->tw * l_cp->tdx) {
|
||||
opj_event_msg_v2(p_manager, EVT_ERROR,
|
||||
"Left position of the decoded area (ROI_x0=%d) is outside the tile area (nb_tw x XTsiz=%d).\n",
|
||||
p_start_x, l_cp->tw * l_cp->tdx);
|
||||
"Left position of the decoded area (ROI_x0=%d) is outside the tile area (XTOsiz + nb_tw x XTsiz=%d).\n",
|
||||
p_start_x, l_cp->tx0 + l_cp->tw * l_cp->tdx);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
else if (p_start_x < l_cp->tx0){
|
||||
|
@ -5935,10 +5973,10 @@ opj_bool j2k_set_decode_area( opj_j2k_v2_t *p_j2k,
|
|||
p_j2k->m_specific_param.m_decoder.m_start_tile_x = (p_start_x - l_cp->tx0) / l_cp->tdx;
|
||||
|
||||
/* Up */
|
||||
if (p_start_y > l_cp->th * l_cp->tdy){
|
||||
if (p_start_y > l_cp->ty0 + l_cp->th * l_cp->tdy){
|
||||
opj_event_msg_v2(p_manager, EVT_ERROR,
|
||||
"Up position of the decoded area (ROI_y0=%d) is outside the tile area (nb_th x YTsiz=%d).\n",
|
||||
p_start_y, l_cp->th * l_cp->tdy);
|
||||
"Up position of the decoded area (ROI_y0=%d) is outside the tile area (YTOsiz + nb_th x YTsiz=%d).\n",
|
||||
p_start_y, l_cp->ty0 + l_cp->th * l_cp->tdy);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
else if (p_start_y < l_cp->ty0){
|
||||
|
@ -5957,10 +5995,10 @@ opj_bool j2k_set_decode_area( opj_j2k_v2_t *p_j2k,
|
|||
p_end_x, l_cp->tx0);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
else if (p_end_x > l_cp->tw * l_cp->tdx) {
|
||||
else if (p_end_x > l_cp->tx0 + l_cp->tw * l_cp->tdx) {
|
||||
opj_event_msg_v2(p_manager, EVT_WARNING,
|
||||
"Right position of the decoded area (ROI_x1=%d) is outside the tile area (nb_tw x XTsiz=%d).\n",
|
||||
p_end_x, l_cp->tw * l_cp->tdx);
|
||||
"Right position of the decoded area (ROI_x1=%d) is outside the tile area (XTOsiz + nb_tw x XTsiz=%d).\n",
|
||||
p_end_x, l_cp->tx0 + l_cp->tw * l_cp->tdx);
|
||||
p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw; // FIXME (-1) ???
|
||||
}
|
||||
else
|
||||
|
@ -5973,10 +6011,10 @@ opj_bool j2k_set_decode_area( opj_j2k_v2_t *p_j2k,
|
|||
p_end_x, l_cp->ty0);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (p_end_y > l_cp->th * l_cp->tdy){
|
||||
if (p_end_y > l_cp->ty0 + l_cp->th * l_cp->tdy){
|
||||
opj_event_msg_v2(p_manager, EVT_WARNING,
|
||||
"Bottom position of the decoded area (ROI_y1=%d) is outside the tile area (nb_th x YTsiz=%d).\n",
|
||||
p_end_y, l_cp->th * l_cp->tdy);
|
||||
"Bottom position of the decoded area (ROI_y1=%d) is outside the tile area (YTOsiz + nb_th x YTsiz=%d).\n",
|
||||
p_end_y, l_cp->ty0 + l_cp->th * l_cp->tdy);
|
||||
p_j2k->m_specific_param.m_decoder.m_start_tile_y = l_cp->th; // FIXME (-1) ???
|
||||
}
|
||||
else
|
||||
|
|
|
@ -117,7 +117,9 @@ typedef enum J2K_STATUS {
|
|||
J2K_STATE_TPH = 0x0010, /**< the decoding process is in a tile part header */
|
||||
J2K_STATE_MT = 0x0020, /**< the EOC marker has just been read */
|
||||
J2K_STATE_NEOC = 0x0040, /**< the decoding process must not expect a EOC marker because the codestream is truncated */
|
||||
J2K_STATE_ERR = 0x0080 /**< the decoding process has encountered an error */
|
||||
|
||||
J2K_STATE_EOC = 0x0100, /**< the decoding process has encountered the EOC marker */
|
||||
J2K_STATE_ERR = 0x8000 /**< the decoding process has encountered an error (FIXME warning V1 = 0x0080)*/
|
||||
} J2K_STATUS;
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
|
328
libopenjpeg/t1.c
328
libopenjpeg/t1.c
|
@ -59,6 +59,18 @@ static void t1_enc_sigpass_step(
|
|||
int *nmsedec,
|
||||
char type,
|
||||
int vsc);
|
||||
|
||||
/**
|
||||
Decode significant pass
|
||||
*/
|
||||
static void t1_dec_sigpass_step(
|
||||
opj_t1_t *t1,
|
||||
flag_t *flagsp,
|
||||
OPJ_INT32 *datap,
|
||||
OPJ_UINT32 orient,
|
||||
OPJ_INT32 oneplushalf,
|
||||
OPJ_BYTE type,
|
||||
OPJ_UINT32 vsc);
|
||||
/**
|
||||
Decode significant pass
|
||||
*/
|
||||
|
@ -92,6 +104,17 @@ static void t1_enc_sigpass(
|
|||
int *nmsedec,
|
||||
char type,
|
||||
int cblksty);
|
||||
|
||||
/**
|
||||
Decode significant pass
|
||||
*/
|
||||
static void t1_dec_sigpass(
|
||||
opj_t1_t *t1,
|
||||
OPJ_INT32 bpno,
|
||||
OPJ_UINT32 orient,
|
||||
OPJ_BYTE type,
|
||||
OPJ_UINT32 cblksty);
|
||||
|
||||
/**
|
||||
Decode significant pass
|
||||
*/
|
||||
|
@ -153,6 +176,28 @@ static void t1_enc_refpass(
|
|||
int *nmsedec,
|
||||
char type,
|
||||
int cblksty);
|
||||
|
||||
/**
|
||||
Decode refinement pass
|
||||
*/
|
||||
static void t1_dec_refpass(
|
||||
opj_t1_t *t1,
|
||||
OPJ_INT32 bpno,
|
||||
OPJ_BYTE type,
|
||||
OPJ_UINT32 cblksty);
|
||||
|
||||
/**
|
||||
Decode refinement pass
|
||||
*/
|
||||
static void t1_dec_refpass_step(
|
||||
opj_t1_t *t1,
|
||||
flag_t *flagsp,
|
||||
OPJ_INT32 *datap,
|
||||
OPJ_INT32 poshalf,
|
||||
OPJ_INT32 neghalf,
|
||||
OPJ_BYTE type,
|
||||
OPJ_UINT32 vsc);
|
||||
|
||||
/**
|
||||
Decode refinement pass
|
||||
*/
|
||||
|
@ -1653,3 +1698,286 @@ void t1_destroy_v2(opj_t1_t *p_t1)
|
|||
}
|
||||
opj_free(p_t1);
|
||||
}
|
||||
|
||||
void t1_decode_cblks_v2(
|
||||
opj_t1_t* t1,
|
||||
opj_tcd_tilecomp_v2_t* tilec,
|
||||
opj_tccp_t* tccp)
|
||||
{
|
||||
OPJ_UINT32 resno, bandno, precno, cblkno;
|
||||
OPJ_UINT32 tile_w = tilec->x1 - tilec->x0;
|
||||
|
||||
for (resno = 0; resno < tilec->minimum_num_resolutions; ++resno) {
|
||||
opj_tcd_resolution_v2_t* res = &tilec->resolutions[resno];
|
||||
|
||||
for (bandno = 0; bandno < res->numbands; ++bandno) {
|
||||
opj_tcd_band_v2_t* restrict band = &res->bands[bandno];
|
||||
|
||||
for (precno = 0; precno < res->pw * res->ph; ++precno) {
|
||||
opj_tcd_precinct_v2_t* precinct = &band->precincts[precno];
|
||||
|
||||
for (cblkno = 0; cblkno < precinct->cw * precinct->ch; ++cblkno) {
|
||||
opj_tcd_cblk_dec_v2_t* cblk = &precinct->cblks.dec[cblkno];
|
||||
OPJ_INT32* restrict datap;
|
||||
void* restrict tiledp;
|
||||
OPJ_UINT32 cblk_w, cblk_h;
|
||||
OPJ_INT32 x, y;
|
||||
OPJ_UINT32 i, j;
|
||||
|
||||
t1_decode_cblk_v2(
|
||||
t1,
|
||||
cblk,
|
||||
band->bandno,
|
||||
tccp->roishift,
|
||||
tccp->cblksty);
|
||||
|
||||
x = cblk->x0 - band->x0;
|
||||
y = cblk->y0 - band->y0;
|
||||
if (band->bandno & 1) {
|
||||
opj_tcd_resolution_v2_t* pres = &tilec->resolutions[resno - 1];
|
||||
x += pres->x1 - pres->x0;
|
||||
}
|
||||
if (band->bandno & 2) {
|
||||
opj_tcd_resolution_v2_t* pres = &tilec->resolutions[resno - 1];
|
||||
y += pres->y1 - pres->y0;
|
||||
}
|
||||
|
||||
datap=t1->data;
|
||||
cblk_w = t1->w;
|
||||
cblk_h = t1->h;
|
||||
|
||||
if (tccp->roishift) {
|
||||
OPJ_INT32 thresh = 1 << tccp->roishift;
|
||||
for (j = 0; j < cblk_h; ++j) {
|
||||
for (i = 0; i < cblk_w; ++i) {
|
||||
OPJ_INT32 val = datap[(j * cblk_w) + i];
|
||||
OPJ_INT32 mag = abs(val);
|
||||
if (mag >= thresh) {
|
||||
mag >>= tccp->roishift;
|
||||
datap[(j * cblk_w) + i] = val < 0 ? -mag : mag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tiledp=(void*)&tilec->data[(y * tile_w) + x];
|
||||
if (tccp->qmfbid == 1) {
|
||||
for (j = 0; j < cblk_h; ++j) {
|
||||
for (i = 0; i < cblk_w; ++i) {
|
||||
OPJ_INT32 tmp = datap[(j * cblk_w) + i];
|
||||
((OPJ_INT32*)tiledp)[(j * tile_w) + i] = tmp / 2;
|
||||
}
|
||||
}
|
||||
} else { /* if (tccp->qmfbid == 0) */
|
||||
for (j = 0; j < cblk_h; ++j) {
|
||||
for (i = 0; i < cblk_w; ++i) {
|
||||
float tmp = datap[(j * cblk_w) + i] * band->stepsize;
|
||||
((float*)tiledp)[(j * tile_w) + i] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
//opj_free(cblk->segs);
|
||||
//cblk->segs = 00;
|
||||
} /* cblkno */
|
||||
} /* precno */
|
||||
} /* bandno */
|
||||
} /* resno */
|
||||
}
|
||||
|
||||
|
||||
static void t1_decode_cblk_v2(
|
||||
opj_t1_t *t1,
|
||||
opj_tcd_cblk_dec_v2_t* cblk,
|
||||
OPJ_UINT32 orient,
|
||||
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;
|
||||
OPJ_UINT32 passtype;
|
||||
OPJ_UINT32 segno, passno;
|
||||
OPJ_BYTE type = T1_TYPE_MQ; /* BYPASS mode */
|
||||
|
||||
if(!allocate_buffers(
|
||||
t1,
|
||||
cblk->x1 - cblk->x0,
|
||||
cblk->y1 - cblk->y0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bpno = roishift + cblk->numbps - 1;
|
||||
passtype = 2;
|
||||
|
||||
mqc_resetstates(mqc);
|
||||
mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
|
||||
mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
|
||||
mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
|
||||
|
||||
for (segno = 0; segno < cblk->real_num_segs; ++segno) {
|
||||
opj_tcd_seg_t *seg = &cblk->segs[segno];
|
||||
|
||||
/* BYPASS mode */
|
||||
type = ((bpno <= ((OPJ_INT32) (cblk->numbps) - 1) - 4) && (passtype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ;
|
||||
/* FIXME: slviewer gets here with a null pointer. Why? Partially downloaded and/or corrupt textures? */
|
||||
if(seg->data == 00){
|
||||
continue;
|
||||
}
|
||||
if (type == T1_TYPE_RAW) {
|
||||
raw_init_dec(raw, (*seg->data) + seg->dataindex, seg->len);
|
||||
} else {
|
||||
mqc_init_dec(mqc, (*seg->data) + seg->dataindex, seg->len);
|
||||
}
|
||||
|
||||
for (passno = 0; passno < seg->real_num_passes; ++passno) {
|
||||
switch (passtype) {
|
||||
case 0:
|
||||
t1_dec_sigpass(t1, bpno+1, orient, type, cblksty);
|
||||
break;
|
||||
case 1:
|
||||
t1_dec_refpass(t1, bpno+1, type, cblksty);
|
||||
break;
|
||||
case 2:
|
||||
t1_dec_clnpass(t1, bpno+1, orient, cblksty);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((cblksty & J2K_CCP_CBLKSTY_RESET) && type == T1_TYPE_MQ) {
|
||||
mqc_resetstates(mqc);
|
||||
mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46);
|
||||
mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3);
|
||||
mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4);
|
||||
}
|
||||
if (++passtype == 3) {
|
||||
passtype = 0;
|
||||
bpno--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void t1_dec_refpass(
|
||||
opj_t1_t *t1,
|
||||
OPJ_INT32 bpno,
|
||||
OPJ_BYTE type,
|
||||
OPJ_UINT32 cblksty)
|
||||
{
|
||||
OPJ_UINT32 i, j, k;
|
||||
OPJ_INT32 one, poshalf, neghalf;
|
||||
OPJ_UINT32 vsc;
|
||||
one = 1 << bpno;
|
||||
poshalf = one >> 1;
|
||||
neghalf = bpno > 0 ? -poshalf : -1;
|
||||
for (k = 0; k < t1->h; k += 4) {
|
||||
for (i = 0; i < t1->w; ++i) {
|
||||
for (j = k; j < k + 4 && j < t1->h; ++j) {
|
||||
vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
|
||||
t1_dec_refpass_step(
|
||||
t1,
|
||||
&t1->flags[((j+1) * t1->flags_stride) + i + 1],
|
||||
&t1->data[(j * t1->w) + i],
|
||||
poshalf,
|
||||
neghalf,
|
||||
type,
|
||||
vsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* VSC and BYPASS by Antonin */
|
||||
|
||||
|
||||
static void t1_dec_refpass_step(
|
||||
opj_t1_t *t1,
|
||||
flag_t *flagsp,
|
||||
OPJ_INT32 *datap,
|
||||
OPJ_INT32 poshalf,
|
||||
OPJ_INT32 neghalf,
|
||||
OPJ_BYTE type,
|
||||
OPJ_UINT32 vsc)
|
||||
{
|
||||
OPJ_INT32 t;
|
||||
OPJ_UINT32 v,flag;
|
||||
|
||||
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
||||
opj_raw_t *raw = t1->raw; /* RAW component */
|
||||
|
||||
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
|
||||
if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
|
||||
mqc_setcurctx(mqc, t1_getctxno_mag(flag)); /* ESSAI */
|
||||
if (type == T1_TYPE_RAW) {
|
||||
v = raw_decode(raw);
|
||||
} else {
|
||||
v = mqc_decode(mqc);
|
||||
}
|
||||
t = v ? poshalf : neghalf;
|
||||
*datap += *datap < 0 ? -t : t;
|
||||
*flagsp |= T1_REFINE;
|
||||
}
|
||||
} /* VSC and BYPASS by Antonin */
|
||||
|
||||
static void t1_dec_sigpass(
|
||||
opj_t1_t *t1,
|
||||
OPJ_INT32 bpno,
|
||||
OPJ_UINT32 orient,
|
||||
OPJ_BYTE type,
|
||||
OPJ_UINT32 cblksty)
|
||||
{
|
||||
OPJ_UINT32 i, j, k, vsc;
|
||||
OPJ_INT32 one, half, oneplushalf;
|
||||
one = 1 << bpno;
|
||||
half = one >> 1;
|
||||
oneplushalf = one | half;
|
||||
for (k = 0; k < t1->h; k += 4) {
|
||||
for (i = 0; i < t1->w; ++i) {
|
||||
for (j = k; j < k + 4 && j < t1->h; ++j) {
|
||||
vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0;
|
||||
t1_dec_sigpass_step(
|
||||
t1,
|
||||
&t1->flags[((j+1) * t1->flags_stride) + i + 1],
|
||||
&t1->data[(j * t1->w) + i],
|
||||
orient,
|
||||
oneplushalf,
|
||||
type,
|
||||
vsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* VSC and BYPASS by Antonin */
|
||||
|
||||
static void t1_dec_sigpass_step(
|
||||
opj_t1_t *t1,
|
||||
flag_t *flagsp,
|
||||
OPJ_INT32 *datap,
|
||||
OPJ_UINT32 orient,
|
||||
OPJ_INT32 oneplushalf,
|
||||
OPJ_BYTE type,
|
||||
OPJ_UINT32 vsc)
|
||||
{
|
||||
OPJ_UINT32 v, flag;
|
||||
|
||||
opj_raw_t *raw = t1->raw; /* RAW component */
|
||||
opj_mqc_t *mqc = t1->mqc; /* MQC component */
|
||||
|
||||
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
|
||||
if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
|
||||
if (type == T1_TYPE_RAW) {
|
||||
if (raw_decode(raw)) {
|
||||
v = raw_decode(raw); /* ESSAI */
|
||||
*datap = v ? -oneplushalf : oneplushalf;
|
||||
t1_updateflags(flagsp, v, t1->flags_stride);
|
||||
}
|
||||
} else {
|
||||
mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient));
|
||||
if (mqc_decode(mqc)) {
|
||||
mqc_setcurctx(mqc, t1_getctxno_sc(flag));
|
||||
v = mqc_decode(mqc) ^ t1_getspb(flag);
|
||||
*datap = v ? -oneplushalf : oneplushalf;
|
||||
t1_updateflags(flagsp, v, t1->flags_stride);
|
||||
}
|
||||
}
|
||||
*flagsp |= T1_VISIT;
|
||||
}
|
||||
} /* VSC and BYPASS by Antonin */
|
||||
|
||||
|
|
|
@ -141,6 +141,25 @@ Decode the code-blocks of a tile
|
|||
void t1_decode_cblks(opj_t1_t* t1, opj_tcd_tilecomp_t* tilec, opj_tccp_t* tccp);
|
||||
|
||||
|
||||
void t1_decode_cblks_v2(
|
||||
opj_t1_t* t1,
|
||||
opj_tcd_tilecomp_v2_t* tilec,
|
||||
opj_tccp_t* tccp);
|
||||
|
||||
/**
|
||||
Decode 1 code-block
|
||||
@param t1 T1 handle
|
||||
@param cblk Code-block coding parameters
|
||||
@param orient
|
||||
@param roishift Region of interest shifting value
|
||||
@param cblksty Code-block style
|
||||
*/
|
||||
static void t1_decode_cblk_v2(
|
||||
opj_t1_t *t1,
|
||||
opj_tcd_cblk_dec_v2_t* cblk,
|
||||
OPJ_UINT32 orient,
|
||||
OPJ_UINT32 roishift,
|
||||
OPJ_UINT32 cblksty);
|
||||
|
||||
/**
|
||||
* Creates a new Tier 1 handle
|
||||
|
|
331
libopenjpeg/t2.c
331
libopenjpeg/t2.c
|
@ -92,7 +92,7 @@ Decode a packet of a tile from a source buffer
|
|||
*/
|
||||
static opj_bool t2_decode_packet_v2(
|
||||
opj_t2_v2_t* p_t2,
|
||||
opj_tcd_tile_t *p_tile,
|
||||
opj_tcd_tile_v2_t *p_tile,
|
||||
opj_tcp_v2_t *p_tcp,
|
||||
opj_pi_iterator_t *p_pi,
|
||||
OPJ_BYTE *p_src,
|
||||
|
@ -102,7 +102,7 @@ static opj_bool t2_decode_packet_v2(
|
|||
|
||||
static opj_bool t2_skip_packet(
|
||||
opj_t2_v2_t* p_t2,
|
||||
opj_tcd_tile_t *p_tile,
|
||||
opj_tcd_tile_v2_t *p_tile,
|
||||
opj_tcp_v2_t *p_tcp,
|
||||
opj_pi_iterator_t *p_pi,
|
||||
OPJ_BYTE *p_src,
|
||||
|
@ -112,7 +112,7 @@ static opj_bool t2_skip_packet(
|
|||
|
||||
static opj_bool t2_read_packet_header(
|
||||
opj_t2_v2_t* p_t2,
|
||||
opj_tcd_tile_t *p_tile,
|
||||
opj_tcd_tile_v2_t *p_tile,
|
||||
opj_tcp_v2_t *p_tcp,
|
||||
opj_pi_iterator_t *p_pi,
|
||||
opj_bool * p_is_data_present,
|
||||
|
@ -123,7 +123,7 @@ static opj_bool t2_read_packet_header(
|
|||
|
||||
static opj_bool t2_read_packet_data(
|
||||
opj_t2_v2_t* p_t2,
|
||||
opj_tcd_tile_t *p_tile,
|
||||
opj_tcd_tile_v2_t *p_tile,
|
||||
opj_pi_iterator_t *p_pi,
|
||||
OPJ_BYTE *p_src_data,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
|
@ -132,7 +132,7 @@ static opj_bool t2_read_packet_data(
|
|||
|
||||
static opj_bool t2_skip_packet_data(
|
||||
opj_t2_v2_t* p_t2,
|
||||
opj_tcd_tile_t *p_tile,
|
||||
opj_tcd_tile_v2_t *p_tile,
|
||||
opj_pi_iterator_t *p_pi,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 p_max_length,
|
||||
|
@ -143,7 +143,10 @@ static opj_bool t2_skip_packet_data(
|
|||
@param cblksty
|
||||
@param first
|
||||
*/
|
||||
static opj_bool t2_init_seg_v2(opj_tcd_cblk_dec_t* cblk, OPJ_UINT32 index, OPJ_UINT32 cblksty, OPJ_UINT32 first);
|
||||
static opj_bool t2_init_seg_v2( opj_tcd_cblk_dec_v2_t* cblk,
|
||||
OPJ_UINT32 index,
|
||||
OPJ_UINT32 cblksty,
|
||||
OPJ_UINT32 first);
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
@ -837,7 +840,7 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj
|
|||
opj_bool t2_decode_packets_v2(
|
||||
opj_t2_v2_t *p_t2,
|
||||
OPJ_UINT32 p_tile_no,
|
||||
struct opj_tcd_tile *p_tile,
|
||||
struct opj_tcd_tile_v2 *p_tile,
|
||||
OPJ_BYTE *p_src,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 p_max_len,
|
||||
|
@ -986,7 +989,7 @@ void t2_destroy_v2(opj_t2_v2_t *t2) {
|
|||
|
||||
static opj_bool t2_decode_packet_v2(
|
||||
opj_t2_v2_t* p_t2,
|
||||
opj_tcd_tile_t *p_tile,
|
||||
opj_tcd_tile_v2_t *p_tile,
|
||||
opj_tcp_v2_t *p_tcp,
|
||||
opj_pi_iterator_t *p_pi,
|
||||
OPJ_BYTE *p_src,
|
||||
|
@ -1026,7 +1029,7 @@ static opj_bool t2_decode_packet_v2(
|
|||
|
||||
static opj_bool t2_skip_packet(
|
||||
opj_t2_v2_t* p_t2,
|
||||
opj_tcd_tile_t *p_tile,
|
||||
opj_tcd_tile_v2_t *p_tile,
|
||||
opj_tcp_v2_t *p_tcp,
|
||||
opj_pi_iterator_t *p_pi,
|
||||
OPJ_BYTE *p_src,
|
||||
|
@ -1040,27 +1043,26 @@ static opj_bool t2_skip_packet(
|
|||
|
||||
*p_data_read = 0;
|
||||
|
||||
if
|
||||
(! t2_read_packet_header(p_t2,p_tile,p_tcp,p_pi,&l_read_data,p_src,&l_nb_bytes_read,p_max_length,p_pack_info))
|
||||
{
|
||||
if (! t2_read_packet_header(p_t2,p_tile,p_tcp,p_pi,&l_read_data,p_src,&l_nb_bytes_read,p_max_length,p_pack_info)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
p_src += l_nb_bytes_read;
|
||||
l_nb_total_bytes_read += l_nb_bytes_read;
|
||||
p_max_length -= l_nb_bytes_read;
|
||||
|
||||
/* we should read data for the packet */
|
||||
if
|
||||
(l_read_data)
|
||||
{
|
||||
if (l_read_data) {
|
||||
l_nb_bytes_read = 0;
|
||||
if
|
||||
(! t2_skip_packet_data(p_t2,p_tile,p_pi,&l_nb_bytes_read,p_max_length,p_pack_info))
|
||||
{
|
||||
|
||||
if (! t2_skip_packet_data(p_t2,p_tile,p_pi,&l_nb_bytes_read,p_max_length,p_pack_info)) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
l_nb_total_bytes_read += l_nb_bytes_read;
|
||||
}
|
||||
*p_data_read = l_nb_total_bytes_read;
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1068,7 +1070,7 @@ static opj_bool t2_skip_packet(
|
|||
|
||||
static opj_bool t2_read_packet_header(
|
||||
opj_t2_v2_t* p_t2,
|
||||
opj_tcd_tile_t *p_tile,
|
||||
opj_tcd_tile_v2_t *p_tile,
|
||||
opj_tcp_v2_t *p_tcp,
|
||||
opj_pi_iterator_t *p_pi,
|
||||
opj_bool * p_is_data_present,
|
||||
|
@ -1086,40 +1088,35 @@ static opj_bool t2_read_packet_header(
|
|||
OPJ_BYTE *l_current_data = p_src_data;
|
||||
opj_cp_v2_t *l_cp = p_t2->cp;
|
||||
opj_bio_t *l_bio = 00; /* BIO component */
|
||||
opj_tcd_band_t *l_band = 00;
|
||||
opj_tcd_cblk_dec_t* l_cblk = 00;
|
||||
opj_tcd_resolution_t* l_res = &p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
|
||||
opj_tcd_band_v2_t *l_band = 00;
|
||||
opj_tcd_cblk_dec_v2_t* l_cblk = 00;
|
||||
opj_tcd_resolution_v2_t* l_res = &p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
|
||||
|
||||
OPJ_BYTE *l_header_data = 00;
|
||||
OPJ_BYTE **l_header_data_start = 00;
|
||||
|
||||
OPJ_UINT32 l_present;
|
||||
|
||||
if
|
||||
(p_pi->layno == 0)
|
||||
{
|
||||
if (p_pi->layno == 0) {
|
||||
l_band = l_res->bands;
|
||||
/* reset tagtrees */
|
||||
for
|
||||
(bandno = 0; bandno < l_res->numbands; ++bandno)
|
||||
{
|
||||
opj_tcd_precinct_t *l_prc = &l_band->precincts[p_pi->precno];
|
||||
|
||||
if (
|
||||
! ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0)))
|
||||
{
|
||||
/* reset tagtrees */
|
||||
for (bandno = 0; bandno < l_res->numbands; ++bandno) {
|
||||
opj_tcd_precinct_v2_t *l_prc = &l_band->precincts[p_pi->precno];
|
||||
|
||||
if ( ! ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0)) ) {
|
||||
tgt_reset(l_prc->incltree);
|
||||
tgt_reset(l_prc->imsbtree);
|
||||
l_cblk = l_prc->cblks.dec;
|
||||
|
||||
l_nb_code_blocks = l_prc->cw * l_prc->ch;
|
||||
for
|
||||
(cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno)
|
||||
{
|
||||
for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
|
||||
l_cblk->numsegs = 0;
|
||||
l_cblk->real_num_segs = 0;
|
||||
++l_cblk;
|
||||
}
|
||||
}
|
||||
|
||||
++l_band;
|
||||
}
|
||||
}
|
||||
|
@ -1144,42 +1141,36 @@ static opj_bool t2_read_packet_header(
|
|||
*/
|
||||
|
||||
l_bio = bio_create();
|
||||
if
|
||||
(! l_bio)
|
||||
{
|
||||
if (! l_bio) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
if
|
||||
(l_cp->ppm == 1)
|
||||
{ /* PPM */
|
||||
if (l_cp->ppm == 1) { /* PPM */
|
||||
l_header_data_start = &l_cp->ppm_data;
|
||||
l_header_data = *l_header_data_start;
|
||||
l_modified_length_ptr = &(l_cp->ppm_len);
|
||||
|
||||
}
|
||||
else if
|
||||
(p_tcp->ppt == 1)
|
||||
{ /* PPT */
|
||||
else if (p_tcp->ppt == 1) { /* PPT */
|
||||
l_header_data_start = &(p_tcp->ppt_data);
|
||||
l_header_data = *l_header_data_start;
|
||||
l_modified_length_ptr = &(p_tcp->ppt_len);
|
||||
}
|
||||
else
|
||||
{ /* Normal Case */
|
||||
else { /* Normal Case */
|
||||
l_header_data_start = &(l_current_data);
|
||||
l_header_data = *l_header_data_start;
|
||||
l_remaining_length = p_src_data+p_max_length-l_header_data;
|
||||
l_modified_length_ptr = &(l_remaining_length);
|
||||
}
|
||||
|
||||
bio_init_dec(l_bio, l_header_data,*l_modified_length_ptr);
|
||||
|
||||
l_present = bio_read(l_bio, 1);
|
||||
if
|
||||
(!l_present)
|
||||
{
|
||||
if (!l_present) {
|
||||
bio_inalign(l_bio);
|
||||
l_header_data += bio_numbytes(l_bio);
|
||||
bio_destroy(l_bio);
|
||||
|
||||
/* EPH markers */
|
||||
if (p_tcp->csty & J2K_CP_CSTY_EPH) {
|
||||
if ((*l_header_data) != 0xff || (*(l_header_data + 1) != 0x92)) {
|
||||
|
@ -1188,100 +1179,86 @@ static opj_bool t2_read_packet_header(
|
|||
l_header_data += 2;
|
||||
}
|
||||
}
|
||||
|
||||
l_header_length = (l_header_data - *l_header_data_start);
|
||||
*l_modified_length_ptr -= l_header_length;
|
||||
*l_header_data_start += l_header_length;
|
||||
|
||||
/* << INDEX */
|
||||
// End of packet header position. Currently only represents the distance to start of packet
|
||||
// Will be updated later by incrementing with packet start value
|
||||
if
|
||||
(p_pack_info)
|
||||
{
|
||||
if (p_pack_info) {
|
||||
p_pack_info->end_ph_pos = (OPJ_INT32)(l_current_data - p_src_data);
|
||||
}
|
||||
/* INDEX >> */
|
||||
|
||||
* p_is_data_present = OPJ_FALSE;
|
||||
*p_data_read = l_current_data - p_src_data;
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
l_band = l_res->bands;
|
||||
for
|
||||
(bandno = 0; bandno < l_res->numbands; ++bandno)
|
||||
{
|
||||
opj_tcd_precinct_t *l_prc = &(l_band->precincts[p_pi->precno]);
|
||||
for (bandno = 0; bandno < l_res->numbands; ++bandno) {
|
||||
opj_tcd_precinct_v2_t *l_prc = &(l_band->precincts[p_pi->precno]);
|
||||
|
||||
if ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0))
|
||||
{
|
||||
if ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0)) {
|
||||
++l_band;
|
||||
continue;
|
||||
}
|
||||
|
||||
l_nb_code_blocks = l_prc->cw * l_prc->ch;
|
||||
l_cblk = l_prc->cblks.dec;
|
||||
for
|
||||
(cblkno = 0; cblkno < l_nb_code_blocks; cblkno++)
|
||||
{
|
||||
for (cblkno = 0; cblkno < l_nb_code_blocks; cblkno++) {
|
||||
OPJ_UINT32 l_included,l_increment, l_segno;
|
||||
OPJ_INT32 n;
|
||||
|
||||
/* if cblk not yet included before --> inclusion tagtree */
|
||||
if
|
||||
(!l_cblk->numsegs)
|
||||
{
|
||||
if (!l_cblk->numsegs) {
|
||||
l_included = tgt_decode(l_bio, l_prc->incltree, cblkno, p_pi->layno + 1);
|
||||
/* else one bit */
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
l_included = bio_read(l_bio, 1);
|
||||
}
|
||||
|
||||
/* if cblk not included */
|
||||
if
|
||||
(!l_included)
|
||||
{
|
||||
if (!l_included) {
|
||||
l_cblk->numnewpasses = 0;
|
||||
++l_cblk;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* if cblk not yet included --> zero-bitplane tagtree */
|
||||
if
|
||||
(!l_cblk->numsegs)
|
||||
{
|
||||
if (!l_cblk->numsegs) {
|
||||
OPJ_UINT32 i = 0;
|
||||
while
|
||||
(!tgt_decode(l_bio, l_prc->imsbtree, cblkno, i))
|
||||
{
|
||||
|
||||
while (!tgt_decode(l_bio, l_prc->imsbtree, cblkno, i)) {
|
||||
++i;
|
||||
}
|
||||
|
||||
l_cblk->numbps = l_band->numbps + 1 - i;
|
||||
l_cblk->numlenbits = 3;
|
||||
}
|
||||
|
||||
/* number of coding passes */
|
||||
l_cblk->numnewpasses = t2_getnumpasses(l_bio);
|
||||
l_increment = t2_getcommacode(l_bio);
|
||||
|
||||
/* length indicator increment */
|
||||
l_cblk->numlenbits += l_increment;
|
||||
l_segno = 0;
|
||||
if
|
||||
(!l_cblk->numsegs)
|
||||
{
|
||||
if
|
||||
(! t2_init_seg_v2(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 1))
|
||||
{
|
||||
|
||||
if (!l_cblk->numsegs) {
|
||||
if (! t2_init_seg_v2(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 1)) {
|
||||
bio_destroy(l_bio);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
l_segno = l_cblk->numsegs - 1;
|
||||
if
|
||||
(l_cblk->segs[l_segno].numpasses == l_cblk->segs[l_segno].maxpasses)
|
||||
{
|
||||
if (l_cblk->segs[l_segno].numpasses == l_cblk->segs[l_segno].maxpasses) {
|
||||
++l_segno;
|
||||
if
|
||||
(! t2_init_seg_v2(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0))
|
||||
{
|
||||
if (! t2_init_seg_v2(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0)) {
|
||||
bio_destroy(l_bio);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
@ -1292,28 +1269,25 @@ static opj_bool t2_read_packet_header(
|
|||
do {
|
||||
l_cblk->segs[l_segno].numnewpasses = int_min(l_cblk->segs[l_segno].maxpasses - l_cblk->segs[l_segno].numpasses, n);
|
||||
l_cblk->segs[l_segno].newlen = bio_read(l_bio, l_cblk->numlenbits + uint_floorlog2(l_cblk->segs[l_segno].numnewpasses));
|
||||
|
||||
n -= l_cblk->segs[l_segno].numnewpasses;
|
||||
if
|
||||
(n > 0)
|
||||
{
|
||||
if (n > 0) {
|
||||
++l_segno;
|
||||
if
|
||||
(! t2_init_seg_v2(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0))
|
||||
{
|
||||
|
||||
if (! t2_init_seg_v2(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0)) {
|
||||
bio_destroy(l_bio);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (n > 0);
|
||||
} while (n > 0);
|
||||
|
||||
++l_cblk;
|
||||
}
|
||||
|
||||
++l_band;
|
||||
}
|
||||
|
||||
if
|
||||
(bio_inalign(l_bio))
|
||||
{
|
||||
if (bio_inalign(l_bio)) {
|
||||
bio_destroy(l_bio);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
@ -1330,27 +1304,27 @@ static opj_bool t2_read_packet_header(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
l_header_length = (l_header_data - *l_header_data_start);
|
||||
*l_modified_length_ptr -= l_header_length;
|
||||
*l_header_data_start += l_header_length;
|
||||
|
||||
/* << INDEX */
|
||||
// End of packet header position. Currently only represents the distance to start of packet
|
||||
// Will be updated later by incrementing with packet start value
|
||||
if
|
||||
(p_pack_info)
|
||||
{
|
||||
if (p_pack_info) {
|
||||
p_pack_info->end_ph_pos = (OPJ_INT32)(l_current_data - p_src_data);
|
||||
}
|
||||
/* INDEX >> */
|
||||
* p_is_data_present = OPJ_TRUE;
|
||||
|
||||
*p_is_data_present = OPJ_TRUE;
|
||||
*p_data_read = l_current_data - p_src_data;
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static opj_bool t2_read_packet_data(
|
||||
opj_t2_v2_t* p_t2,
|
||||
opj_tcd_tile_t *p_tile,
|
||||
opj_tcd_tile_v2_t *p_tile,
|
||||
opj_pi_iterator_t *p_pi,
|
||||
OPJ_BYTE *p_src_data,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
|
@ -1360,58 +1334,47 @@ static opj_bool t2_read_packet_data(
|
|||
OPJ_UINT32 bandno, cblkno;
|
||||
OPJ_UINT32 l_nb_code_blocks;
|
||||
OPJ_BYTE *l_current_data = p_src_data;
|
||||
opj_tcd_band_t *l_band = 00;
|
||||
opj_tcd_cblk_dec_t* l_cblk = 00;
|
||||
opj_tcd_resolution_t* l_res = &p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
|
||||
opj_tcd_band_v2_t *l_band = 00;
|
||||
opj_tcd_cblk_dec_v2_t* l_cblk = 00;
|
||||
opj_tcd_resolution_v2_t* l_res = &p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
|
||||
|
||||
l_band = l_res->bands;
|
||||
for
|
||||
(bandno = 0; bandno < l_res->numbands; ++bandno)
|
||||
{
|
||||
opj_tcd_precinct_t *l_prc = &l_band->precincts[p_pi->precno];
|
||||
for (bandno = 0; bandno < l_res->numbands; ++bandno) {
|
||||
opj_tcd_precinct_v2_t *l_prc = &l_band->precincts[p_pi->precno];
|
||||
|
||||
if
|
||||
((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0))
|
||||
{
|
||||
if ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0)) {
|
||||
++l_band;
|
||||
continue;
|
||||
}
|
||||
|
||||
l_nb_code_blocks = l_prc->cw * l_prc->ch;
|
||||
l_cblk = l_prc->cblks.dec;
|
||||
for
|
||||
(cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno)
|
||||
{
|
||||
|
||||
for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
|
||||
opj_tcd_seg_t *l_seg = 00;
|
||||
if
|
||||
(!l_cblk->numnewpasses)
|
||||
{
|
||||
|
||||
if (!l_cblk->numnewpasses) {
|
||||
/* nothing to do */
|
||||
++l_cblk;
|
||||
continue;
|
||||
}
|
||||
if
|
||||
(!l_cblk->numsegs)
|
||||
{
|
||||
|
||||
if (!l_cblk->numsegs) {
|
||||
l_seg = l_cblk->segs;
|
||||
++l_cblk->numsegs;
|
||||
l_cblk->len = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
l_seg = &l_cblk->segs[l_cblk->numsegs - 1];
|
||||
if
|
||||
(l_seg->numpasses == l_seg->maxpasses)
|
||||
{
|
||||
|
||||
if (l_seg->numpasses == l_seg->maxpasses) {
|
||||
++l_seg;
|
||||
++l_cblk->numsegs;
|
||||
}
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if
|
||||
(l_current_data + l_seg->newlen > p_src_data + p_max_length)
|
||||
{
|
||||
do {
|
||||
if (l_current_data + l_seg->newlen > p_src_data + p_max_length) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1436,12 +1399,12 @@ static opj_bool t2_read_packet_data(
|
|||
#endif /* USE_JPWL */
|
||||
|
||||
memcpy(l_cblk->data + l_cblk->len, l_current_data, l_seg->newlen);
|
||||
if
|
||||
(l_seg->numpasses == 0)
|
||||
{
|
||||
|
||||
if (l_seg->numpasses == 0) {
|
||||
l_seg->data = &l_cblk->data;
|
||||
l_seg->dataindex = l_cblk->len;
|
||||
}
|
||||
|
||||
l_current_data += l_seg->newlen;
|
||||
l_seg->numpasses += l_seg->numnewpasses;
|
||||
l_cblk->numnewpasses -= l_seg->numnewpasses;
|
||||
|
@ -1449,26 +1412,28 @@ static opj_bool t2_read_packet_data(
|
|||
l_seg->real_num_passes = l_seg->numpasses;
|
||||
l_cblk->len += l_seg->newlen;
|
||||
l_seg->len += l_seg->newlen;
|
||||
if
|
||||
(l_cblk->numnewpasses > 0)
|
||||
{
|
||||
|
||||
if (l_cblk->numnewpasses > 0) {
|
||||
++l_seg;
|
||||
++l_cblk->numsegs;
|
||||
}
|
||||
}
|
||||
while (l_cblk->numnewpasses > 0);
|
||||
} while (l_cblk->numnewpasses > 0);
|
||||
|
||||
l_cblk->real_num_segs = l_cblk->numsegs;
|
||||
++l_cblk;
|
||||
}
|
||||
|
||||
++l_band;
|
||||
}
|
||||
|
||||
*(p_data_read) = l_current_data - p_src_data;
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
static opj_bool t2_skip_packet_data(
|
||||
opj_t2_v2_t* p_t2,
|
||||
opj_tcd_tile_t *p_tile,
|
||||
opj_tcd_tile_v2_t *p_tile,
|
||||
opj_pi_iterator_t *p_pi,
|
||||
OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 p_max_length,
|
||||
|
@ -1476,60 +1441,49 @@ static opj_bool t2_skip_packet_data(
|
|||
{
|
||||
OPJ_UINT32 bandno, cblkno;
|
||||
OPJ_UINT32 l_nb_code_blocks;
|
||||
opj_tcd_band_t *l_band = 00;
|
||||
opj_tcd_cblk_dec_t* l_cblk = 00;
|
||||
|
||||
opj_tcd_resolution_t* l_res = &p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
|
||||
opj_tcd_band_v2_t *l_band = 00;
|
||||
opj_tcd_cblk_dec_v2_t* l_cblk = 00;
|
||||
opj_tcd_resolution_v2_t* l_res = &p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
|
||||
|
||||
*p_data_read = 0;
|
||||
l_band = l_res->bands;
|
||||
for
|
||||
(bandno = 0; bandno < l_res->numbands; ++bandno)
|
||||
{
|
||||
opj_tcd_precinct_t *l_prc = &l_band->precincts[p_pi->precno];
|
||||
|
||||
if
|
||||
((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0))
|
||||
{
|
||||
for (bandno = 0; bandno < l_res->numbands; ++bandno) {
|
||||
opj_tcd_precinct_v2_t *l_prc = &l_band->precincts[p_pi->precno];
|
||||
|
||||
if ((l_band->x1-l_band->x0 == 0)||(l_band->y1-l_band->y0 == 0)) {
|
||||
++l_band;
|
||||
continue;
|
||||
}
|
||||
|
||||
l_nb_code_blocks = l_prc->cw * l_prc->ch;
|
||||
l_cblk = l_prc->cblks.dec;
|
||||
for
|
||||
(cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno)
|
||||
{
|
||||
|
||||
for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
|
||||
opj_tcd_seg_t *l_seg = 00;
|
||||
if
|
||||
(!l_cblk->numnewpasses)
|
||||
{
|
||||
|
||||
if (!l_cblk->numnewpasses) {
|
||||
/* nothing to do */
|
||||
++l_cblk;
|
||||
continue;
|
||||
}
|
||||
if
|
||||
(!l_cblk->numsegs)
|
||||
{
|
||||
|
||||
if (!l_cblk->numsegs) {
|
||||
l_seg = l_cblk->segs;
|
||||
++l_cblk->numsegs;
|
||||
l_cblk->len = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
l_seg = &l_cblk->segs[l_cblk->numsegs - 1];
|
||||
if
|
||||
(l_seg->numpasses == l_seg->maxpasses)
|
||||
{
|
||||
|
||||
if (l_seg->numpasses == l_seg->maxpasses) {
|
||||
++l_seg;
|
||||
++l_cblk->numsegs;
|
||||
}
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if
|
||||
(* p_data_read + l_seg->newlen > p_max_length)
|
||||
{
|
||||
do {
|
||||
if (* p_data_read + l_seg->newlen > p_max_length) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1553,40 +1507,40 @@ static opj_bool t2_skip_packet_data(
|
|||
|
||||
#endif /* USE_JPWL */
|
||||
*(p_data_read) += l_seg->newlen;
|
||||
|
||||
l_seg->numpasses += l_seg->numnewpasses;
|
||||
l_cblk->numnewpasses -= l_seg->numnewpasses;
|
||||
if
|
||||
(l_cblk->numnewpasses > 0)
|
||||
if (l_cblk->numnewpasses > 0)
|
||||
{
|
||||
++l_seg;
|
||||
++l_cblk->numsegs;
|
||||
}
|
||||
}
|
||||
while (l_cblk->numnewpasses > 0);
|
||||
} while (l_cblk->numnewpasses > 0);
|
||||
|
||||
++l_cblk;
|
||||
}
|
||||
|
||||
++l_band;
|
||||
}
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static opj_bool t2_init_seg_v2(opj_tcd_cblk_dec_t* cblk, OPJ_UINT32 index, OPJ_UINT32 cblksty, OPJ_UINT32 first)
|
||||
static opj_bool t2_init_seg_v2(opj_tcd_cblk_dec_v2_t* cblk, OPJ_UINT32 index, OPJ_UINT32 cblksty, OPJ_UINT32 first)
|
||||
{
|
||||
opj_tcd_seg_t* seg = 00;
|
||||
OPJ_UINT32 l_nb_segs = index + 1;
|
||||
|
||||
if
|
||||
(l_nb_segs > cblk->m_current_max_segs)
|
||||
{
|
||||
if (l_nb_segs > cblk->m_current_max_segs) {
|
||||
cblk->m_current_max_segs += J2K_DEFAULT_NB_SEGS;
|
||||
cblk->segs = (opj_tcd_seg_t*) opj_realloc(cblk->segs, cblk->m_current_max_segs * sizeof(opj_tcd_seg_t));
|
||||
if
|
||||
(! cblk->segs)
|
||||
{
|
||||
|
||||
cblk->segs = (opj_tcd_seg_t*) opj_realloc(cblk->segs, cblk->m_current_max_segs * sizeof(opj_tcd_seg_t));
|
||||
if(! cblk->segs) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
seg = &cblk->segs[index];
|
||||
memset(seg,0,sizeof(opj_tcd_seg_t));
|
||||
|
||||
|
@ -1602,5 +1556,6 @@ static opj_bool t2_init_seg_v2(opj_tcd_cblk_dec_t* cblk, OPJ_UINT32 index, OPJ_U
|
|||
} else {
|
||||
seg->maxpasses = 109;
|
||||
}
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ Decode the packets of a tile from a source buffer
|
|||
*/
|
||||
opj_bool t2_decode_packets_v2( opj_t2_v2_t *t2,
|
||||
OPJ_UINT32 tileno,
|
||||
struct opj_tcd_tile *tile,
|
||||
struct opj_tcd_tile_v2 *tile,
|
||||
OPJ_BYTE *src, OPJ_UINT32 * p_data_read,
|
||||
OPJ_UINT32 len,
|
||||
struct opj_codestream_info_v2 *cstr_info);
|
||||
|
|
1081
libopenjpeg/tcd.c
1081
libopenjpeg/tcd.c
File diff suppressed because it is too large
Load Diff
|
@ -58,14 +58,14 @@ FIXME: documentation
|
|||
FIXME: documentation
|
||||
*/
|
||||
typedef struct opj_tcd_seg {
|
||||
OPJ_BYTE ** data;
|
||||
OPJ_UINT32 dataindex;
|
||||
OPJ_UINT32 numpasses;
|
||||
OPJ_UINT32 real_num_passes;
|
||||
OPJ_UINT32 len;
|
||||
OPJ_UINT32 maxpasses;
|
||||
OPJ_UINT32 numnewpasses;
|
||||
OPJ_UINT32 newlen;
|
||||
OPJ_BYTE ** data;
|
||||
OPJ_UINT32 dataindex;
|
||||
OPJ_UINT32 numpasses;
|
||||
OPJ_UINT32 real_num_passes;
|
||||
OPJ_UINT32 len;
|
||||
OPJ_UINT32 maxpasses;
|
||||
OPJ_UINT32 numnewpasses;
|
||||
OPJ_UINT32 newlen;
|
||||
} opj_tcd_seg_t;
|
||||
|
||||
/**
|
||||
|
@ -77,14 +77,21 @@ typedef struct opj_tcd_pass {
|
|||
int term, len;
|
||||
} opj_tcd_pass_t;
|
||||
|
||||
typedef struct opj_tcd_pass_v2 {
|
||||
OPJ_UINT32 rate;
|
||||
OPJ_FLOAT64 distortiondec;
|
||||
OPJ_UINT32 len;
|
||||
OPJ_UINT32 term : 1;
|
||||
} opj_tcd_pass_v2_t;
|
||||
|
||||
/**
|
||||
FIXME: documentation
|
||||
*/
|
||||
typedef struct opj_tcd_layer {
|
||||
int numpasses; /* Number of passes in the layer */
|
||||
int len; /* len of information */
|
||||
double disto; /* add for index (Cfr. Marcela) */
|
||||
unsigned char *data; /* data */
|
||||
OPJ_UINT32 numpasses; /* Number of passes in the layer */
|
||||
OPJ_UINT32 len; /* len of information */
|
||||
OPJ_FLOAT64 disto; /* add for index (Cfr. Marcela) */
|
||||
OPJ_BYTE *data; /* data */
|
||||
} opj_tcd_layer_t;
|
||||
|
||||
/**
|
||||
|
@ -102,77 +109,93 @@ typedef struct opj_tcd_cblk_enc {
|
|||
int totalpasses; /* total number of passes */
|
||||
} opj_tcd_cblk_enc_t;
|
||||
|
||||
//typedef struct opj_tcd_cblk_dec {
|
||||
// unsigned char* data; /* Data */
|
||||
// opj_tcd_seg_t* segs; /* segments informations */
|
||||
// int x0, y0, x1, y1; /* dimension of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
// int numbps;
|
||||
// int numlenbits;
|
||||
// int len; /* length */
|
||||
// int numnewpasses; /* number of pass added to the code-blocks */
|
||||
// int numsegs; /* number of segments */
|
||||
//} opj_tcd_cblk_dec_t;
|
||||
/**
|
||||
FIXME: documentation
|
||||
*/
|
||||
typedef struct opj_tcd_cblk_enc_v2 {
|
||||
OPJ_BYTE* data; /* Data */
|
||||
opj_tcd_layer_t* layers; /* layer information */
|
||||
opj_tcd_pass_v2_t* passes; /* information about the passes */
|
||||
OPJ_INT32 x0, y0, x1, y1; /* dimension of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
OPJ_UINT32 numbps;
|
||||
OPJ_UINT32 numlenbits;
|
||||
OPJ_UINT32 numpasses; /* number of pass already done for the code-blocks */
|
||||
OPJ_UINT32 numpassesinlayers; /* number of passes in the layer */
|
||||
OPJ_UINT32 totalpasses; /* total number of passes */
|
||||
} opj_tcd_cblk_enc_v2_t;
|
||||
|
||||
typedef struct opj_tcd_cblk_dec {
|
||||
OPJ_BYTE * data; /* Data */
|
||||
unsigned char* data; /* Data */
|
||||
opj_tcd_seg_t* segs; /* segments informations */
|
||||
OPJ_INT32 x0, y0, x1, y1; /* dimension 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 numnewpasses; /* number of pass added to the code-blocks */
|
||||
OPJ_UINT32 numsegs; /* number of segments */
|
||||
OPJ_UINT32 real_num_segs;
|
||||
OPJ_UINT32 m_current_max_segs;
|
||||
int x0, y0, x1, y1; /* dimension of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
int numbps;
|
||||
int numlenbits;
|
||||
int len; /* length */
|
||||
int numnewpasses; /* number of pass added to the code-blocks */
|
||||
int numsegs; /* number of segments */
|
||||
} opj_tcd_cblk_dec_t;
|
||||
|
||||
|
||||
typedef struct opj_tcd_cblk_dec_v2 {
|
||||
OPJ_BYTE * data; /* Data */
|
||||
opj_tcd_seg_t* segs; /* segments informations */
|
||||
OPJ_INT32 x0, y0, x1, y1; /* dimension 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 numnewpasses; /* number of pass added to the code-blocks */
|
||||
OPJ_UINT32 numsegs; /* number of segments */
|
||||
OPJ_UINT32 real_num_segs;
|
||||
OPJ_UINT32 m_current_max_segs;
|
||||
} opj_tcd_cblk_dec_v2_t;
|
||||
|
||||
/**
|
||||
FIXME: documentation
|
||||
*/
|
||||
//typedef struct opj_tcd_precinct {
|
||||
// int x0, y0, x1, y1; /* dimension of the precinct : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
// int cw, ch; /* number of precinct in width and heigth */
|
||||
// union{ /* code-blocks informations */
|
||||
// opj_tcd_cblk_enc_t* enc;
|
||||
// opj_tcd_cblk_dec_t* dec;
|
||||
// } cblks;
|
||||
// opj_tgt_tree_t *incltree; /* inclusion tree */
|
||||
// opj_tgt_tree_t *imsbtree; /* IMSB tree */
|
||||
//} opj_tcd_precinct_t;
|
||||
|
||||
|
||||
typedef struct opj_tcd_precinct {
|
||||
OPJ_INT32 x0, y0, x1, y1; /* dimension of the precinct : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
OPJ_UINT32 cw, ch; /* number of precinct in width and heigth */
|
||||
int x0, y0, x1, y1; /* dimension of the precinct : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
int cw, ch; /* number of precinct in width and heigth */
|
||||
union{ /* code-blocks informations */
|
||||
opj_tcd_cblk_enc_t* enc;
|
||||
opj_tcd_cblk_dec_t* dec;
|
||||
} cblks;
|
||||
OPJ_UINT32 block_size; /* size taken by cblks (in bytes) */
|
||||
struct opj_tgt_tree *incltree; /* inclusion tree */
|
||||
struct opj_tgt_tree *imsbtree; /* IMSB tree */
|
||||
opj_tgt_tree_t *incltree; /* inclusion tree */
|
||||
opj_tgt_tree_t *imsbtree; /* IMSB tree */
|
||||
} opj_tcd_precinct_t;
|
||||
|
||||
|
||||
typedef struct opj_tcd_precinct_v2 {
|
||||
OPJ_INT32 x0, y0, x1, y1; /* dimension of the precinct : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
OPJ_UINT32 cw, ch; /* number of precinct in width and heigth */
|
||||
union{ /* code-blocks informations */
|
||||
opj_tcd_cblk_enc_v2_t* enc;
|
||||
opj_tcd_cblk_dec_v2_t* dec;
|
||||
} cblks;
|
||||
OPJ_UINT32 block_size; /* size taken by cblks (in bytes) */
|
||||
struct opj_tgt_tree *incltree; /* inclusion tree */
|
||||
struct opj_tgt_tree *imsbtree; /* IMSB tree */
|
||||
} opj_tcd_precinct_v2_t;
|
||||
|
||||
/**
|
||||
FIXME: documentation
|
||||
*/
|
||||
//typedef struct opj_tcd_band {
|
||||
// int x0, y0, x1, y1; /* dimension of the subband : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
// int bandno;
|
||||
// opj_tcd_precinct_t *precincts; /* precinct information */
|
||||
// int numbps;
|
||||
// float stepsize;
|
||||
//} opj_tcd_band_t;
|
||||
|
||||
typedef struct opj_tcd_band {
|
||||
OPJ_INT32 x0, y0, x1, y1; /* dimension of the subband : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
OPJ_UINT32 bandno;
|
||||
int x0, y0, x1, y1; /* dimension of the subband : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
int bandno;
|
||||
opj_tcd_precinct_t *precincts; /* precinct information */
|
||||
OPJ_UINT32 precincts_data_size; /* size of data taken by precincts */
|
||||
OPJ_INT32 numbps;
|
||||
OPJ_FLOAT32 stepsize;
|
||||
int numbps;
|
||||
float stepsize;
|
||||
} opj_tcd_band_t;
|
||||
|
||||
typedef struct opj_tcd_band_v2 {
|
||||
OPJ_INT32 x0, y0, x1, y1; /* dimension of the subband : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
OPJ_UINT32 bandno;
|
||||
opj_tcd_precinct_v2_t *precincts; /* precinct information */
|
||||
OPJ_UINT32 precincts_data_size; /* size of data taken by precincts */
|
||||
OPJ_INT32 numbps;
|
||||
OPJ_FLOAT32 stepsize;
|
||||
} opj_tcd_band_v2_t;
|
||||
|
||||
/**
|
||||
FIXME: documentation
|
||||
*/
|
||||
|
@ -183,29 +206,36 @@ typedef struct opj_tcd_resolution {
|
|||
opj_tcd_band_t bands[3]; /* subband information */
|
||||
} opj_tcd_resolution_t;
|
||||
|
||||
typedef struct opj_tcd_resolution_v2 {
|
||||
OPJ_INT32 x0, y0, x1, y1; /* dimension of the resolution level : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
OPJ_UINT32 pw, ph;
|
||||
OPJ_UINT32 numbands; /* number sub-band for the resolution level */
|
||||
opj_tcd_band_v2_t bands[3]; /* subband information */
|
||||
} opj_tcd_resolution_v2_t;
|
||||
|
||||
/**
|
||||
FIXME: documentation
|
||||
*/
|
||||
//typedef struct opj_tcd_tilecomp {
|
||||
// int x0, y0, x1, y1; /* dimension of component : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
// int numresolutions; /* number of resolutions level */
|
||||
// opj_tcd_resolution_t *resolutions; /* resolutions information */
|
||||
// int *data; /* data of the component */
|
||||
// int numpix; /* add fixed_quality */
|
||||
//} opj_tcd_tilecomp_t;
|
||||
|
||||
typedef struct opj_tcd_tilecomp
|
||||
{
|
||||
OPJ_INT32 x0, y0, x1, y1; /* dimension of component : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
OPJ_UINT32 numresolutions; /* number of resolutions level */
|
||||
OPJ_UINT32 minimum_num_resolutions; /* number of resolutions level to decode (at max)*/
|
||||
typedef struct opj_tcd_tilecomp {
|
||||
int x0, y0, x1, y1; /* dimension of component : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
int numresolutions; /* number of resolutions level */
|
||||
opj_tcd_resolution_t *resolutions; /* resolutions information */
|
||||
OPJ_UINT32 resolutions_size; /* size of data for resolutions (in bytes) */
|
||||
OPJ_INT32 *data; /* data of the component */
|
||||
OPJ_UINT32 data_size; /* size of the data of the component */
|
||||
OPJ_INT32 numpix; /* add fixed_quality */
|
||||
int *data; /* data of the component */
|
||||
int numpix; /* add fixed_quality */
|
||||
} opj_tcd_tilecomp_t;
|
||||
|
||||
typedef struct opj_tcd_tilecomp_v2
|
||||
{
|
||||
OPJ_INT32 x0, y0, x1, y1; /* dimension of component : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
OPJ_UINT32 numresolutions; /* number of resolutions level */
|
||||
OPJ_UINT32 minimum_num_resolutions; /* number of resolutions level to decode (at max)*/
|
||||
opj_tcd_resolution_v2_t *resolutions; /* resolutions information */
|
||||
OPJ_UINT32 resolutions_size; /* size of data for resolutions (in bytes) */
|
||||
OPJ_INT32 *data; /* data of the component */
|
||||
OPJ_UINT32 data_size; /* size of the data of the component */
|
||||
OPJ_INT32 numpix; /* add fixed_quality */
|
||||
} opj_tcd_tilecomp_v2_t;
|
||||
|
||||
|
||||
/**
|
||||
FIXME: documentation
|
||||
|
@ -221,6 +251,17 @@ typedef struct opj_tcd_tile {
|
|||
int packno;
|
||||
} opj_tcd_tile_t;
|
||||
|
||||
typedef struct opj_tcd_tile_v2 {
|
||||
OPJ_INT32 x0, y0, x1, y1; /* dimension of the tile : left upper corner (x0, y0) right low corner (x1,y1) */
|
||||
OPJ_UINT32 numcomps; /* number of components in tile */
|
||||
opj_tcd_tilecomp_v2_t *comps; /* Components information */
|
||||
OPJ_INT32 numpix; /* add fixed_quality */
|
||||
OPJ_FLOAT64 distotile; /* add fixed_quality */
|
||||
OPJ_FLOAT64 distolayer[100]; /* add fixed_quality */
|
||||
/** packet number */
|
||||
OPJ_UINT32 packno;
|
||||
} opj_tcd_tile_v2_t;
|
||||
|
||||
/**
|
||||
FIXME: documentation
|
||||
*/
|
||||
|
@ -229,6 +270,12 @@ typedef struct opj_tcd_image {
|
|||
opj_tcd_tile_t *tiles; /* Tiles information */
|
||||
} opj_tcd_image_t;
|
||||
|
||||
typedef struct opj_tcd_image_v2
|
||||
{
|
||||
opj_tcd_tile_v2_t *tiles; /* Tiles information */
|
||||
}
|
||||
opj_tcd_image_v2_t;
|
||||
|
||||
/**
|
||||
Tile coder/decoder
|
||||
*/
|
||||
|
@ -282,7 +329,7 @@ typedef struct opj_tcd_v2
|
|||
/** Current Packet iterator number */
|
||||
OPJ_UINT32 cur_pino;
|
||||
/** info on each image tile */
|
||||
opj_tcd_image_t *tcd_image;
|
||||
opj_tcd_image_v2_t *tcd_image;
|
||||
/** image header */
|
||||
struct opj_image_header *image_header;
|
||||
/** coding parameters */
|
||||
|
|
Loading…
Reference in New Issue