[trunk] Revert r2597 for now, since it breaks a lot of tests

This commit is contained in:
Mathieu Malaterre 2014-03-06 17:25:08 +00:00
parent 445f696dc6
commit 6790587db8
1 changed files with 44 additions and 44 deletions

View File

@ -4901,12 +4901,12 @@ OPJ_BOOL opj_j2k_write_epc( opj_j2k_t *p_j2k,
l_cstr_index = p_j2k->cstr_index;
if (l_cstr_index) {
l_cstr_index->codestream_size = (OPJ_UINT64)opj_stream_tell(p_stream);
l_cstr_index->codestream_size = opj_stream_tell(p_stream);
/* UniPG>> */
/* The following adjustment is done to adjust the codestream size */
/* if SOD is not at 0 in the buffer. Useful in case of JP2, where */
/* the first bunch of bytes is not in the codestream */
l_cstr_index->codestream_size -= (OPJ_UINT64)l_cstr_index->main_head_start;
l_cstr_index->codestream_size -= l_cstr_index->main_head_start;
/* <<UniPG */
}
@ -5680,7 +5680,7 @@ OPJ_BOOL opj_j2k_add_mct(opj_tcp_t * p_tcp, opj_image_t * p_image, OPJ_UINT32 p_
l_current_offset_data = l_offset_data;
for (i=0;i<p_image->numcomps;++i) {
l_tccp->m_dc_level_shift = (OPJ_INT32)*(l_current_offset_data++);
l_tccp->m_dc_level_shift = *(l_current_offset_data++);
++l_tccp;
}
@ -5862,14 +5862,14 @@ int opj_j2k_initialise_4K_poc(opj_poc_t *POC, int numres){
POC[0].resno0 = 0;
POC[0].compno0 = 0;
POC[0].layno1 = 1;
POC[0].resno1 = (OPJ_UINT32)(numres-1);
POC[0].resno1 = numres-1;
POC[0].compno1 = 3;
POC[0].prg1 = OPJ_CPRL;
POC[1].tile = 1;
POC[1].resno0 = (OPJ_UINT32)(numres-1);
POC[1].resno0 = numres-1;
POC[1].compno0 = 0;
POC[1].layno1 = 1;
POC[1].resno1 = (OPJ_UINT32)numres;
POC[1].resno1 = numres;
POC[1].compno1 = 3;
POC[1].prg1 = OPJ_CPRL;
return 2;
@ -5985,7 +5985,7 @@ void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters, opj_image_t *i
/* Progression order changes for 4K, disallowed for 2K */
if (parameters->cp_cinema == OPJ_CINEMA4K_24) {
parameters->numpocs = (OPJ_UINT32)opj_j2k_initialise_4K_poc(parameters->POC,parameters->numresolution);
parameters->numpocs = opj_j2k_initialise_4K_poc(parameters->POC,parameters->numresolution);
} else {
parameters->numpocs = 0;
}
@ -6141,26 +6141,26 @@ void opj_j2k_setup_encoder( opj_j2k_t *p_j2k,
copy user encoding parameters
*/
cp->m_specific_param.m_enc.m_cinema = parameters->cp_cinema;
cp->m_specific_param.m_enc.m_max_comp_size = (OPJ_UINT32)parameters->max_comp_size;
cp->m_specific_param.m_enc.m_max_comp_size = parameters->max_comp_size;
cp->rsiz = parameters->cp_rsiz;
cp->m_specific_param.m_enc.m_disto_alloc = (OPJ_UINT32)parameters->cp_disto_alloc & 1u;
cp->m_specific_param.m_enc.m_fixed_alloc = (OPJ_UINT32)parameters->cp_fixed_alloc & 1u;
cp->m_specific_param.m_enc.m_fixed_quality = (OPJ_UINT32)parameters->cp_fixed_quality & 1u;
cp->m_specific_param.m_enc.m_disto_alloc = parameters->cp_disto_alloc & 1u;
cp->m_specific_param.m_enc.m_fixed_alloc = parameters->cp_fixed_alloc & 1u;
cp->m_specific_param.m_enc.m_fixed_quality = parameters->cp_fixed_quality & 1u;
/* mod fixed_quality */
if (parameters->cp_fixed_alloc && parameters->cp_matrice) {
size_t array_size = (size_t)parameters->tcp_numlayers * (size_t)parameters->numresolution * 3 * sizeof(OPJ_INT32);
size_t array_size = parameters->tcp_numlayers * parameters->numresolution * 3 * sizeof(OPJ_INT32);
cp->m_specific_param.m_enc.m_matrice = (OPJ_INT32 *) opj_malloc(array_size);
memcpy(cp->m_specific_param.m_enc.m_matrice, parameters->cp_matrice, array_size);
}
/* tiles */
cp->tdx = (OPJ_UINT32)parameters->cp_tdx;
cp->tdy = (OPJ_UINT32)parameters->cp_tdy;
cp->tdx = parameters->cp_tdx;
cp->tdy = parameters->cp_tdy;
/* tile offset */
cp->tx0 = (OPJ_UINT32)parameters->cp_tx0;
cp->ty0 = (OPJ_UINT32)parameters->cp_ty0;
cp->tx0 = parameters->cp_tx0;
cp->ty0 = parameters->cp_ty0;
/* comment string */
if(parameters->cp_comment) {
@ -6175,15 +6175,15 @@ void opj_j2k_setup_encoder( opj_j2k_t *p_j2k,
*/
if (parameters->tile_size_on) {
cp->tw = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->x1 - cp->tx0), (OPJ_INT32)cp->tdx);
cp->th = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->y1 - cp->ty0), (OPJ_INT32)cp->tdy);
cp->tw = opj_int_ceildiv(image->x1 - cp->tx0, cp->tdx);
cp->th = opj_int_ceildiv(image->y1 - cp->ty0, cp->tdy);
} else {
cp->tdx = image->x1 - cp->tx0;
cp->tdy = image->y1 - cp->ty0;
}
if (parameters->tp_on) {
cp->m_specific_param.m_enc.m_tp_flag = (OPJ_BYTE)parameters->tp_flag;
cp->m_specific_param.m_enc.m_tp_flag = parameters->tp_flag;
cp->m_specific_param.m_enc.m_tp_on = 1;
}
@ -6248,13 +6248,13 @@ void opj_j2k_setup_encoder( opj_j2k_t *p_j2k,
cp->tcps = (opj_tcp_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tcp_t));
if (parameters->numpocs) {
/* initialisation of POC */
opj_j2k_check_poc_val(parameters->POC,parameters->numpocs, (OPJ_UINT32)parameters->numresolution, image->numcomps, (OPJ_UINT32)parameters->tcp_numlayers, p_manager);
opj_j2k_check_poc_val(parameters->POC,parameters->numpocs, parameters->numresolution, image->numcomps, parameters->tcp_numlayers, p_manager);
/* TODO MSD use the return value*/
}
for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
opj_tcp_t *tcp = &cp->tcps[tileno];
tcp->numlayers = (OPJ_UINT32)parameters->tcp_numlayers;
tcp->numlayers = parameters->tcp_numlayers;
for (j = 0; j < tcp->numlayers; j++) {
if(cp->m_specific_param.m_enc.m_cinema){
@ -6271,9 +6271,9 @@ void opj_j2k_setup_encoder( opj_j2k_t *p_j2k,
}
}
tcp->csty = (OPJ_UINT32)parameters->csty;
tcp->csty = parameters->csty;
tcp->prg = parameters->prog_order;
tcp->mct = (OPJ_UINT32)parameters->tcp_mct;
tcp->mct = parameters->tcp_mct;
numpocs_tile = 0;
tcp->POC = 0;
@ -6346,10 +6346,10 @@ void opj_j2k_setup_encoder( opj_j2k_t *p_j2k,
opj_tccp_t *tccp = &tcp->tccps[i];
tccp->csty = parameters->csty & 0x01; /* 0 => one precinct || 1 => custom precinct */
tccp->numresolutions = (OPJ_UINT32)parameters->numresolution;
tccp->cblkw = (OPJ_UINT32)opj_int_floorlog2(parameters->cblockw_init);
tccp->cblkh = (OPJ_UINT32)opj_int_floorlog2(parameters->cblockh_init);
tccp->cblksty = (OPJ_UINT32)parameters->mode;
tccp->numresolutions = parameters->numresolution;
tccp->cblkw = opj_int_floorlog2(parameters->cblockw_init);
tccp->cblkh = opj_int_floorlog2(parameters->cblockh_init);
tccp->cblksty = parameters->mode;
tccp->qmfbid = parameters->irreversible ? 0 : 1;
tccp->qntsty = parameters->irreversible ? J2K_CCP_QNTSTY_SEQNT : J2K_CCP_QNTSTY_NOQNT;
tccp->numgbits = 2;
@ -6363,19 +6363,19 @@ void opj_j2k_setup_encoder( opj_j2k_t *p_j2k,
if (parameters->csty & J2K_CCP_CSTY_PRT) {
OPJ_INT32 p = 0, it_res;
assert( tccp->numresolutions > 0 );
for (it_res = (OPJ_INT32)tccp->numresolutions - 1; it_res >= 0; it_res--) {
for (it_res = tccp->numresolutions - 1; it_res >= 0; it_res--) {
if (p < parameters->res_spec) {
if (parameters->prcw_init[p] < 1) {
tccp->prcw[it_res] = 1;
} else {
tccp->prcw[it_res] = (OPJ_UINT32)opj_int_floorlog2(parameters->prcw_init[p]);
tccp->prcw[it_res] = opj_int_floorlog2(parameters->prcw_init[p]);
}
if (parameters->prch_init[p] < 1) {
tccp->prch[it_res] = 1;
}else {
tccp->prch[it_res] = (OPJ_UINT32)opj_int_floorlog2(parameters->prch_init[p]);
tccp->prch[it_res] = opj_int_floorlog2(parameters->prch_init[p]);
}
} else {
@ -6391,13 +6391,13 @@ void opj_j2k_setup_encoder( opj_j2k_t *p_j2k,
if (size_prcw < 1) {
tccp->prcw[it_res] = 1;
} else {
tccp->prcw[it_res] = (OPJ_UINT32)opj_int_floorlog2(size_prcw);
tccp->prcw[it_res] = opj_int_floorlog2(size_prcw);
}
if (size_prch < 1) {
tccp->prch[it_res] = 1;
} else {
tccp->prch[it_res] = (OPJ_UINT32)opj_int_floorlog2(size_prch);
tccp->prch[it_res] = opj_int_floorlog2(size_prch);
}
}
p++;
@ -6427,7 +6427,7 @@ static OPJ_BOOL opj_j2k_add_mhmarker(opj_codestream_index_t *cstr_index, OPJ_UIN
/* expand the list? */
if ((cstr_index->marknum + 1) > cstr_index->maxmarknum) {
opj_marker_info_t *new_marker;
cstr_index->maxmarknum = (OPJ_UINT32)(100 + (OPJ_INT32) ((OPJ_FLOAT32) cstr_index->maxmarknum * 1.0F));
cstr_index->maxmarknum = 100 + (OPJ_INT32) ((OPJ_FLOAT32) cstr_index->maxmarknum * 1.0F);
new_marker = (opj_marker_info_t *) opj_realloc(cstr_index->marker, cstr_index->maxmarknum *sizeof(opj_marker_info_t));
if (! new_marker) {
opj_free(cstr_index->marker);
@ -6456,7 +6456,7 @@ static OPJ_BOOL opj_j2k_add_tlmarker(OPJ_UINT32 tileno, opj_codestream_index_t *
/* expand the list? */
if ((cstr_index->tile_index[tileno].marknum + 1) > cstr_index->tile_index[tileno].maxmarknum) {
opj_marker_info_t *new_marker;
cstr_index->tile_index[tileno].maxmarknum = (OPJ_UINT32)(100 + (OPJ_INT32) ((OPJ_FLOAT32) cstr_index->tile_index[tileno].maxmarknum * 1.0F));
cstr_index->tile_index[tileno].maxmarknum = 100 + (OPJ_INT32) ((OPJ_FLOAT32) cstr_index->tile_index[tileno].maxmarknum * 1.0F);
new_marker = (opj_marker_info_t *) opj_realloc(
cstr_index->tile_index[tileno].marker,
cstr_index->tile_index[tileno].maxmarknum *sizeof(opj_marker_info_t));
@ -7727,12 +7727,12 @@ OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data, opj_im
l_res->x0, l_res->x1, l_res->y0, l_res->y1);
}*/
l_width_src = (OPJ_UINT8)(l_res->x1 - l_res->x0);
l_height_src = (OPJ_UINT32)(l_res->y1 - l_res->y0);
l_width_src = (l_res->x1 - l_res->x0);
l_height_src = (l_res->y1 - l_res->y0);
/* Border of the current output component*/
l_x0_dest = (OPJ_UINT32)opj_int_ceildivpow2((OPJ_INT32)l_img_comp_dest->x0, (OPJ_INT32)l_img_comp_dest->factor);
l_y0_dest = (OPJ_UINT32)opj_int_ceildivpow2((OPJ_INT32)l_img_comp_dest->y0, (OPJ_INT32)l_img_comp_dest->factor);
l_x0_dest = opj_int_ceildivpow2(l_img_comp_dest->x0, l_img_comp_dest->factor);
l_y0_dest = opj_int_ceildivpow2(l_img_comp_dest->y0, l_img_comp_dest->factor);
l_x1_dest = l_x0_dest + l_img_comp_dest->w;
l_y1_dest = l_y0_dest + l_img_comp_dest->h;
@ -7751,7 +7751,7 @@ OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data, opj_im
assert( l_res->x0 >= 0);
assert( l_res->x1 >= 0);
if ( l_x0_dest < (OPJ_UINT32)l_res->x0 ) {
l_start_x_dest = (OPJ_UINT32)l_res->x0 - l_x0_dest;
l_start_x_dest = l_res->x0 - l_x0_dest;
l_offset_x0_src = 0;
if ( l_x1_dest >= (OPJ_UINT32)l_res->x1 ) {
@ -7759,21 +7759,21 @@ OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data, opj_im
l_offset_x1_src = 0;
}
else {
l_width_dest = l_x1_dest - (OPJ_UINT32)l_res->x0 ;
l_offset_x1_src = (OPJ_INT32)(l_width_src - l_width_dest);
l_width_dest = l_x1_dest - l_res->x0 ;
l_offset_x1_src = l_width_src - l_width_dest;
}
}
else {
l_start_x_dest = 0 ;
l_offset_x0_src = (OPJ_INT32)l_x0_dest - l_res->x0;
l_offset_x0_src = l_x0_dest - l_res->x0;
if ( l_x1_dest >= (OPJ_UINT32)l_res->x1 ) {
l_width_dest = l_width_src - (OPJ_UINT32)l_offset_x0_src;
l_width_dest = l_width_src - l_offset_x0_src;
l_offset_x1_src = 0;
}
else {
l_width_dest = l_img_comp_dest->w ;
l_offset_x1_src = l_res->x1 - (OPJ_INT32)l_x1_dest;
l_offset_x1_src = l_res->x1 - l_x1_dest;
}
}