if (!cas) {
if ((dn > 0) || (sn > 1)) { /* NEW : CASE ONE ELEMENT */
for (i = 0; i < dn; i++)
- D(i) -= fix_mul(S_(i) + S_(i + 1), 12993);
+ D(i) -= opj_int_fix_mul(S_(i) + S_(i + 1), 12993);
for (i = 0; i < sn; i++)
- S(i) -= fix_mul(D_(i - 1) + D_(i), 434);
+ S(i) -= opj_int_fix_mul(D_(i - 1) + D_(i), 434);
for (i = 0; i < dn; i++)
- D(i) += fix_mul(S_(i) + S_(i + 1), 7233);
+ D(i) += opj_int_fix_mul(S_(i) + S_(i + 1), 7233);
for (i = 0; i < sn; i++)
- S(i) += fix_mul(D_(i - 1) + D_(i), 3633);
+ S(i) += opj_int_fix_mul(D_(i - 1) + D_(i), 3633);
for (i = 0; i < dn; i++)
- D(i) = fix_mul(D(i), 5038); /*5038 */
+ D(i) = opj_int_fix_mul(D(i), 5038); /*5038 */
for (i = 0; i < sn; i++)
- S(i) = fix_mul(S(i), 6659); /*6660 */
+ S(i) = opj_int_fix_mul(S(i), 6659); /*6660 */
}
} else {
if ((sn > 0) || (dn > 1)) { /* NEW : CASE ONE ELEMENT */
for (i = 0; i < dn; i++)
- S(i) -= fix_mul(DD_(i) + DD_(i - 1), 12993);
+ S(i) -= opj_int_fix_mul(DD_(i) + DD_(i - 1), 12993);
for (i = 0; i < sn; i++)
- D(i) -= fix_mul(SS_(i) + SS_(i + 1), 434);
+ D(i) -= opj_int_fix_mul(SS_(i) + SS_(i + 1), 434);
for (i = 0; i < dn; i++)
- S(i) += fix_mul(DD_(i) + DD_(i - 1), 7233);
+ S(i) += opj_int_fix_mul(DD_(i) + DD_(i - 1), 7233);
for (i = 0; i < sn; i++)
- D(i) += fix_mul(SS_(i) + SS_(i + 1), 3633);
+ D(i) += opj_int_fix_mul(SS_(i) + SS_(i + 1), 3633);
for (i = 0; i < dn; i++)
- S(i) = fix_mul(S(i), 5038); /*5038 */
+ S(i) = opj_int_fix_mul(S(i), 5038); /*5038 */
for (i = 0; i < sn; i++)
- D(i) = fix_mul(D(i), 6659); /*6660 */
+ D(i) = opj_int_fix_mul(D(i), 6659); /*6660 */
}
}
}
void opj_dwt_encode_stepsize(OPJ_INT32 stepsize, OPJ_INT32 numbps, opj_stepsize_t *bandno_stepsize) {
OPJ_INT32 p, n;
- p = int_floorlog2(stepsize) - 13;
- n = 11 - int_floorlog2(stepsize);
+ p = opj_int_floorlog2(stepsize) - 13;
+ n = 11 - opj_int_floorlog2(stepsize);
bandno_stepsize->mant = (n < 0 ? stepsize >> -n : stepsize << n) & 0x7ff;
bandno_stepsize->expn = numbps - p;
}
#ifdef __SSE__
opj_v4dwt_decode_step1_sse(dwt->wavelet+a, dwt->sn, _mm_set1_ps(opj_K));
opj_v4dwt_decode_step1_sse(dwt->wavelet+b, dwt->dn, _mm_set1_ps(opj_c13318));
- opj_v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(opj_dwt_delta));
- opj_v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(opj_dwt_gamma));
- opj_v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(opj_dwt_beta));
- opj_v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(opj_dwt_alpha));
+ opj_v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, opj_int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(opj_dwt_delta));
+ opj_v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, opj_int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(opj_dwt_gamma));
+ opj_v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, opj_int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(opj_dwt_beta));
+ opj_v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, opj_int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(opj_dwt_alpha));
#else
opj_v4dwt_decode_step1(dwt->wavelet+a, dwt->sn, opj_K);
opj_v4dwt_decode_step1(dwt->wavelet+b, dwt->dn, opj_c13318);
- opj_v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), opj_dwt_delta);
- opj_v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), opj_dwt_gamma);
- opj_v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), opj_dwt_beta);
- opj_v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), opj_dwt_alpha);
+ opj_v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, opj_int_min(dwt->sn, dwt->dn-a), opj_dwt_delta);
+ opj_v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, opj_int_min(dwt->dn, dwt->sn-b), opj_dwt_gamma);
+ opj_v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, opj_int_min(dwt->sn, dwt->dn-a), opj_dwt_beta);
+ opj_v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, opj_int_min(dwt->dn, dwt->sn-b), opj_dwt_alpha);
#endif
}
OPJ_INT32 l_comp_x0, l_comp_y0, l_comp_x1, l_comp_y1;
opj_image_comp_t* l_img_comp = NULL;
- l_x0 = int_max(p_cp->tx0 , p_image_header->x0);
- l_y0 = int_max(p_cp->ty0 , p_image_header->y0);
- l_x1 = int_min(p_cp->tx0 + p_cp->tw * p_cp->tdx, p_image_header->x1);
- l_y1 = int_min(p_cp->ty0 + p_cp->th * p_cp->tdy, p_image_header->y1);
+ l_x0 = opj_int_max(p_cp->tx0 , p_image_header->x0);
+ l_y0 = opj_int_max(p_cp->ty0 , p_image_header->y0);
+ l_x1 = opj_int_min(p_cp->tx0 + p_cp->tw * p_cp->tdx, p_image_header->x1);
+ l_y1 = opj_int_min(p_cp->ty0 + p_cp->th * p_cp->tdy, p_image_header->y1);
l_img_comp = p_image_header->comps;
for (i = 0; i < p_image_header->numcomps; ++i) {
- l_comp_x0 = int_ceildiv(l_x0, l_img_comp->dx);
- l_comp_y0 = int_ceildiv(l_y0, l_img_comp->dy);
- l_comp_x1 = int_ceildiv(l_x1, l_img_comp->dx);
- l_comp_y1 = int_ceildiv(l_y1, l_img_comp->dy);
- l_width = int_ceildivpow2(l_comp_x1 - l_comp_x0, l_img_comp->factor);
- l_height = int_ceildivpow2(l_comp_y1 - l_comp_y0, l_img_comp->factor);
+ l_comp_x0 = opj_int_ceildiv(l_x0, l_img_comp->dx);
+ l_comp_y0 = opj_int_ceildiv(l_y0, l_img_comp->dy);
+ l_comp_x1 = opj_int_ceildiv(l_x1, l_img_comp->dx);
+ l_comp_y1 = opj_int_ceildiv(l_y1, l_img_comp->dy);
+ l_width = opj_int_ceildivpow2(l_comp_x1 - l_comp_x0, l_img_comp->factor);
+ l_height = opj_int_ceildivpow2(l_comp_y1 - l_comp_y0, l_img_comp->factor);
l_img_comp->w = l_width;
l_img_comp->h = l_height;
l_img_comp->x0 = l_comp_x0/*l_x0*/;
}
/* Compute the number of tiles */
- l_cp->tw = int_ceildiv(l_image->x1 - l_cp->tx0, l_cp->tdx);
- l_cp->th = int_ceildiv(l_image->y1 - l_cp->ty0, l_cp->tdy);
+ l_cp->tw = opj_int_ceildiv(l_image->x1 - l_cp->tx0, l_cp->tdx);
+ l_cp->th = opj_int_ceildiv(l_image->y1 - l_cp->ty0, l_cp->tdy);
l_nb_tiles = l_cp->tw * l_cp->th;
/* Define the tiles which will be decoded */
if (p_j2k->m_specific_param.m_decoder.m_discard_tiles) {
p_j2k->m_specific_param.m_decoder.m_start_tile_x = (p_j2k->m_specific_param.m_decoder.m_start_tile_x - l_cp->tx0) / l_cp->tdx;
p_j2k->m_specific_param.m_decoder.m_start_tile_y = (p_j2k->m_specific_param.m_decoder.m_start_tile_y - l_cp->ty0) / l_cp->tdy;
- p_j2k->m_specific_param.m_decoder.m_end_tile_x = int_ceildiv((p_j2k->m_specific_param.m_decoder.m_end_tile_x - l_cp->tx0), l_cp->tdx);
- p_j2k->m_specific_param.m_decoder.m_end_tile_y = int_ceildiv((p_j2k->m_specific_param.m_decoder.m_end_tile_y - l_cp->ty0), l_cp->tdy);
+ p_j2k->m_specific_param.m_decoder.m_end_tile_x = opj_int_ceildiv((p_j2k->m_specific_param.m_decoder.m_end_tile_x - l_cp->tx0), l_cp->tdx);
+ p_j2k->m_specific_param.m_decoder.m_end_tile_y = opj_int_ceildiv((p_j2k->m_specific_param.m_decoder.m_end_tile_y - l_cp->ty0), l_cp->tdy);
}
else {
p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0;
for (i=0;i<l_nb_tiles;++i) {
for (j=0;j<l_nb_comp;++j) {
- l_max = uint_max(l_max,opj_j2k_get_SPCod_SPCoc_size(p_j2k,i,j));
+ l_max = opj_uint_max(l_max,opj_j2k_get_SPCod_SPCoc_size(p_j2k,i,j));
}
}
++l_current_data;
/* change the value of the max layer according to the actual number of layers in the file, components and resolutions*/
- l_current_poc->layno1 = int_min(l_current_poc->layno1, l_tcp->numlayers);
- l_current_poc->resno1 = int_min(l_current_poc->resno1, l_tccp->numresolutions);
- l_current_poc->compno1 = int_min(l_current_poc->compno1, l_nb_comp);
+ l_current_poc->layno1 = opj_int_min(l_current_poc->layno1, l_tcp->numlayers);
+ l_current_poc->resno1 = opj_int_min(l_current_poc->resno1, l_tccp->numresolutions);
+ l_current_poc->compno1 = opj_int_min(l_current_poc->compno1, l_nb_comp);
++l_current_poc;
}
l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
for (i=0;i<l_nb_tiles;++i) {
- l_max_poc = uint_max(l_max_poc,l_tcp->numpocs);
+ l_max_poc = opj_uint_max(l_max_poc,l_tcp->numpocs);
++l_tcp;
}
l_nb_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th ;
for (i=0;i<l_nb_tiles;++i) {
- l_max = uint_max(l_max,l_tcp->m_nb_tile_parts);
+ l_max = opj_uint_max(l_max,l_tcp->m_nb_tile_parts);
++l_tcp;
}
++p_header_data;
l_current_poc->prg = (OPJ_PROG_ORDER) l_tmp;
/* make sure comp is in acceptable bounds */
- l_current_poc->compno1 = uint_min(l_current_poc->compno1, l_nb_comp);
+ l_current_poc->compno1 = opj_uint_min(l_current_poc->compno1, l_nb_comp);
++l_current_poc;
}
OPJ_FLOAT32 l_offset = ((*l_tp_stride_func)(l_tcp)) / l_tcp->numlayers;
/* 4 borders of the tile rescale on the image if necessary */
- l_x0 = int_max(l_cp->tx0 + j * l_cp->tdx, l_image->x0);
- l_y0 = int_max(l_cp->ty0 + i * l_cp->tdy, l_image->y0);
- l_x1 = int_min(l_cp->tx0 + (j + 1) * l_cp->tdx, l_image->x1);
- l_y1 = int_min(l_cp->ty0 + (i + 1) * l_cp->tdy, l_image->y1);
+ l_x0 = opj_int_max(l_cp->tx0 + j * l_cp->tdx, l_image->x0);
+ l_y0 = opj_int_max(l_cp->ty0 + i * l_cp->tdy, l_image->y0);
+ l_x1 = opj_int_min(l_cp->tx0 + (j + 1) * l_cp->tdx, l_image->x1);
+ l_y1 = opj_int_min(l_cp->ty0 + (i + 1) * l_cp->tdy, l_image->y1);
l_rates = l_tcp->rates;
l_tile_size = 0;
for (i=0;i<l_image->numcomps;++i) {
- l_tile_size += ( uint_ceildiv(l_cp->tdx,l_img_comp->dx)
+ l_tile_size += ( opj_uint_ceildiv(l_cp->tdx,l_img_comp->dx)
*
- uint_ceildiv(l_cp->tdy,l_img_comp->dy)
+ opj_uint_ceildiv(l_cp->tdy,l_img_comp->dy)
*
l_img_comp->prec
);
*/
if (parameters->tile_size_on) {
- cp->tw = int_ceildiv(image->x1 - cp->tx0, cp->tdx);
- cp->th = int_ceildiv(image->y1 - cp->ty0, 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;
tccp->csty = parameters->csty & 0x01; /* 0 => one precinct || 1 => custom precinct */
tccp->numresolutions = parameters->numresolution;
- tccp->cblkw = int_floorlog2(parameters->cblockw_init);
- tccp->cblkh = int_floorlog2(parameters->cblockh_init);
+ 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;
if (parameters->prcw_init[p] < 1) {
tccp->prcw[it_res] = 1;
} else {
- tccp->prcw[it_res] = 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] = int_floorlog2(parameters->prch_init[p]);
+ tccp->prch[it_res] = opj_int_floorlog2(parameters->prch_init[p]);
}
} else {
if (size_prcw < 1) {
tccp->prcw[it_res] = 1;
} else {
- tccp->prcw[it_res] = 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] = int_floorlog2(size_prch);
+ tccp->prch[it_res] = opj_int_floorlog2(size_prch);
}
}
p++;
l_height_src = (l_res->y1 - l_res->y0);
/* Border of the current output component*/
- l_x0_dest = int_ceildivpow2(l_img_comp_dest->x0, l_img_comp_dest->factor);
- l_y0_dest = int_ceildivpow2(l_img_comp_dest->y0, 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;
p_image->x1 = l_image->x1;
}
else {
- p_j2k->m_specific_param.m_decoder.m_end_tile_x = int_ceildiv((p_end_x - l_cp->tx0), l_cp->tdx);
+ p_j2k->m_specific_param.m_decoder.m_end_tile_x = opj_int_ceildiv((p_end_x - l_cp->tx0), l_cp->tdx);
p_image->x1 = p_end_x;
}
p_image->y1 = l_image->y1;
}
else{
- p_j2k->m_specific_param.m_decoder.m_end_tile_y = int_ceildiv((p_end_y - l_cp->ty0), l_cp->tdy);
+ p_j2k->m_specific_param.m_decoder.m_end_tile_y = opj_int_ceildiv((p_end_y - l_cp->ty0), l_cp->tdy);
p_image->y1 = p_end_y;
}
/* ----- */
{
OPJ_INT32 l_h,l_w;
- l_img_comp->x0 = int_ceildiv(p_image->x0, l_img_comp->dx);
- l_img_comp->y0 = int_ceildiv(p_image->y0, l_img_comp->dy);
- l_comp_x1 = int_ceildiv(p_image->x1, l_img_comp->dx);
- l_comp_y1 = int_ceildiv(p_image->y1, l_img_comp->dy);
+ l_img_comp->x0 = opj_int_ceildiv(p_image->x0, l_img_comp->dx);
+ l_img_comp->y0 = opj_int_ceildiv(p_image->y0, l_img_comp->dy);
+ l_comp_x1 = opj_int_ceildiv(p_image->x1, l_img_comp->dx);
+ l_comp_y1 = opj_int_ceildiv(p_image->y1, l_img_comp->dy);
- l_w = int_ceildivpow2(l_comp_x1, l_img_comp->factor)
- - int_ceildivpow2(l_img_comp->x0, l_img_comp->factor);
+ l_w = opj_int_ceildivpow2(l_comp_x1, l_img_comp->factor)
+ - opj_int_ceildivpow2(l_img_comp->x0, l_img_comp->factor);
if (l_w < 0){
opj_event_msg_v2(p_manager, EVT_ERROR,
"Size x of the decoded component image is incorrect (comp[%d].w=%d).\n",
}
l_img_comp->w = l_w;
- l_h = int_ceildivpow2(l_comp_y1, l_img_comp->factor)
- - int_ceildivpow2(l_img_comp->y0, l_img_comp->factor);
+ l_h = opj_int_ceildivpow2(l_comp_y1, l_img_comp->factor)
+ - opj_int_ceildivpow2(l_img_comp->y0, l_img_comp->factor);
if (l_h < 0){
opj_event_msg_v2(p_manager, EVT_ERROR,
"Size y of the decoded component image is incorrect (comp[%d].h=%d).\n",
l_img_comp->factor = p_j2k->m_private_image->comps[compno].factor;
- l_img_comp->x0 = int_ceildiv(p_image->x0, l_img_comp->dx);
- l_img_comp->y0 = int_ceildiv(p_image->y0, l_img_comp->dy);
- l_comp_x1 = int_ceildiv(p_image->x1, l_img_comp->dx);
- l_comp_y1 = int_ceildiv(p_image->y1, l_img_comp->dy);
+ l_img_comp->x0 = opj_int_ceildiv(p_image->x0, l_img_comp->dx);
+ l_img_comp->y0 = opj_int_ceildiv(p_image->y0, l_img_comp->dy);
+ l_comp_x1 = opj_int_ceildiv(p_image->x1, l_img_comp->dx);
+ l_comp_y1 = opj_int_ceildiv(p_image->y1, l_img_comp->dy);
- l_img_comp->w = int_ceildivpow2(l_comp_x1, l_img_comp->factor) - int_ceildivpow2(l_img_comp->x0, l_img_comp->factor);
- l_img_comp->h = int_ceildivpow2(l_comp_y1, l_img_comp->factor) - int_ceildivpow2(l_img_comp->y0, l_img_comp->factor);
+ l_img_comp->w = opj_int_ceildivpow2(l_comp_x1, l_img_comp->factor) - opj_int_ceildivpow2(l_img_comp->x0, l_img_comp->factor);
+ l_img_comp->h = opj_int_ceildivpow2(l_comp_y1, l_img_comp->factor) - opj_int_ceildivpow2(l_img_comp->y0, l_img_comp->factor);
l_img_comp++;
}
l_width = (l_tilec->x1 - l_tilec->x0);
l_height = (l_tilec->y1 - l_tilec->y0);
- l_offset_x = int_ceildiv(l_image->x0, l_img_comp->dx);
- l_offset_y = int_ceildiv(l_image->y0, l_img_comp->dy);
- l_image_width = int_ceildiv(l_image->x1 - l_image->x0, l_img_comp->dx);
+ l_offset_x = opj_int_ceildiv(l_image->x0, l_img_comp->dx);
+ l_offset_y = opj_int_ceildiv(l_image->y0, l_img_comp->dy);
+ l_image_width = opj_int_ceildiv(l_image->x1 - l_image->x0, l_img_comp->dx);
l_stride = l_image_width - l_width;
l_src_ptr = l_img_comp->data + (l_tilec->x0 - l_offset_x) + (l_tilec->y0 - l_offset_y) * l_image_width;
OPJ_INT32 r = c0[i];
OPJ_INT32 g = c1[i];
OPJ_INT32 b = c2[i];
- OPJ_INT32 y = fix_mul(r, 2449) + fix_mul(g, 4809) + fix_mul(b, 934);
- OPJ_INT32 u = -fix_mul(r, 1382) - fix_mul(g, 2714) + fix_mul(b, 4096);
- OPJ_INT32 v = fix_mul(r, 4096) - fix_mul(g, 3430) - fix_mul(b, 666);
+ OPJ_INT32 y = opj_int_fix_mul(r, 2449) + opj_int_fix_mul(g, 4809) + opj_int_fix_mul(b, 934);
+ OPJ_INT32 u = -opj_int_fix_mul(r, 1382) - opj_int_fix_mul(g, 2714) + opj_int_fix_mul(b, 4096);
+ OPJ_INT32 v = opj_int_fix_mul(r, 4096) - opj_int_fix_mul(g, 3430) - opj_int_fix_mul(b, 666);
c0[i] = y;
c1[i] = u;
c2[i] = v;
for (j=0;j<pNbComp;++j) {
*(lData[j]) = 0;
for (k=0;k<pNbComp;++k) {
- *(lData[j]) += fix_mul(*lMctPtr, lCurrentData[k]);
+ *(lData[j]) += opj_int_fix_mul(*lMctPtr, lCurrentData[k]);
++lMctPtr;
}
#include "dwt.h"
#include "t2.h"
#include "mct.h"
-#include "int.h"
+#include "opj_intmath.h"
#include "cidx_manager.h"
#include "indexbox_manager.h"
#ifndef __INT_H
#define __INT_H
/**
-@file int.h
+@file opj_intmath.h
@brief Implementation of operations on integers (INT)
-The functions in INT.H have for goal to realize operations on integers.
+The functions in OPJ_INTMATH.H have for goal to realize operations on integers.
*/
-/** @defgroup INT INT - Implementation of operations on integers */
+/** @defgroup OPJ_INTMATH OPJ_INTMATH - Implementation of operations on integers */
/*@{*/
/** @name Exported functions (see also openjpeg.h) */
Get the minimum of two integers
@return Returns a if a < b else b
*/
-static INLINE OPJ_INT32 int_min(OPJ_INT32 a, OPJ_INT32 b) {
+static INLINE OPJ_INT32 opj_int_min(OPJ_INT32 a, OPJ_INT32 b) {
return a < b ? a : b;
}
Get the minimum of two integers
@return Returns a if a < b else b
*/
-static INLINE OPJ_UINT32 uint_min(OPJ_UINT32 a, OPJ_UINT32 b) {
+static INLINE OPJ_UINT32 opj_uint_min(OPJ_UINT32 a, OPJ_UINT32 b) {
return a < b ? a : b;
}
Get the maximum of two integers
@return Returns a if a > b else b
*/
-static INLINE OPJ_INT32 int_max(OPJ_INT32 a, OPJ_INT32 b) {
+static INLINE OPJ_INT32 opj_int_max(OPJ_INT32 a, OPJ_INT32 b) {
return (a > b) ? a : b;
}
Get the maximum of two integers
@return Returns a if a > b else b
*/
-static INLINE OPJ_UINT32 uint_max(OPJ_UINT32 a, OPJ_UINT32 b) {
+static INLINE OPJ_UINT32 opj_uint_max(OPJ_UINT32 a, OPJ_UINT32 b) {
return (a > b) ? a : b;
}
<li>Returns min if (a < min)
</ul>
*/
-static INLINE OPJ_INT32 int_clamp(OPJ_INT32 a, OPJ_INT32 min, OPJ_INT32 max) {
+static INLINE OPJ_INT32 opj_int_clamp(OPJ_INT32 a, OPJ_INT32 min, OPJ_INT32 max) {
if (a < min)
return min;
if (a > max)
/**
@return Get absolute value of integer
*/
-static INLINE OPJ_INT32 int_abs(OPJ_INT32 a) {
+static INLINE OPJ_INT32 opj_int_abs(OPJ_INT32 a) {
return a < 0 ? -a : a;
}
/**
Divide an integer and round upwards
@return Returns a divided by b
*/
-static INLINE OPJ_INT32 int_ceildiv(OPJ_INT32 a, OPJ_INT32 b) {
+static INLINE OPJ_INT32 opj_int_ceildiv(OPJ_INT32 a, OPJ_INT32 b) {
return (a + b - 1) / b;
}
Divide an integer and round upwards
@return Returns a divided by b
*/
-static INLINE OPJ_UINT32 uint_ceildiv(OPJ_UINT32 a, OPJ_UINT32 b) {
+static INLINE OPJ_UINT32 opj_uint_ceildiv(OPJ_UINT32 a, OPJ_UINT32 b) {
return (a + b - 1) / b;
}
Divide an integer by a power of 2 and round upwards
@return Returns a divided by 2^b
*/
-static INLINE OPJ_INT32 int_ceildivpow2(OPJ_INT32 a, OPJ_INT32 b) {
+static INLINE OPJ_INT32 opj_int_ceildivpow2(OPJ_INT32 a, OPJ_INT32 b) {
return (a + (1 << b) - 1) >> b;
}
/**
Divide an integer by a power of 2 and round downwards
@return Returns a divided by 2^b
*/
-static INLINE OPJ_INT32 int_floordivpow2(OPJ_INT32 a, OPJ_INT32 b) {
+static INLINE OPJ_INT32 opj_int_floordivpow2(OPJ_INT32 a, OPJ_INT32 b) {
return a >> b;
}
/**
Get logarithm of an integer and round downwards
@return Returns log2(a)
*/
-static INLINE OPJ_INT32 int_floorlog2(OPJ_INT32 a) {
+static INLINE OPJ_INT32 opj_int_floorlog2(OPJ_INT32 a) {
OPJ_INT32 l;
for (l = 0; a > 1; l++) {
a >>= 1;
Get logarithm of an integer and round downwards
@return Returns log2(a)
*/
-static INLINE OPJ_UINT32 uint_floorlog2(OPJ_UINT32 a) {
+static INLINE OPJ_UINT32 opj_uint_floorlog2(OPJ_UINT32 a) {
OPJ_UINT32 l;
for (l = 0; a > 1; ++l)
{
@param b
@return Returns a * b
*/
-static INLINE OPJ_INT32 fix_mul(OPJ_INT32 a, OPJ_INT32 b) {
+static INLINE OPJ_INT32 opj_int_fix_mul(OPJ_INT32 a, OPJ_INT32 b) {
OPJ_INT64 temp = (OPJ_INT64) a * (OPJ_INT64) b ;
temp += temp & 4096;
- return (int) (temp >> 13) ;
+ return (OPJ_INT32) (temp >> 13) ;
}
/* ----------------------------------------------------------------------- */
res = &comp->resolutions[resno];
dx = comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
dy = comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
- pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
- pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
+ pi->dx = !pi->dx ? dx : opj_int_min(pi->dx, dx);
+ pi->dy = !pi->dy ? dy : opj_int_min(pi->dy, dy);
}
}
}
}
res = &comp->resolutions[pi->resno];
levelno = comp->numresolutions - 1 - pi->resno;
- trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
- try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
- trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);
- try1 = int_ceildiv(pi->ty1, comp->dy << levelno);
+ trx0 = opj_int_ceildiv(pi->tx0, comp->dx << levelno);
+ try0 = opj_int_ceildiv(pi->ty0, comp->dy << levelno);
+ trx1 = opj_int_ceildiv(pi->tx1, comp->dx << levelno);
+ try1 = opj_int_ceildiv(pi->ty1, comp->dy << levelno);
rpx = res->pdx + levelno;
rpy = res->pdy + levelno;
if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){
if ((trx0==trx1)||(try0==try1)) continue;
- prci = int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelno), res->pdx)
- - int_floordivpow2(trx0, res->pdx);
- prcj = int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelno), res->pdy)
- - int_floordivpow2(try0, res->pdy);
+ prci = opj_int_floordivpow2(opj_int_ceildiv(pi->x, comp->dx << levelno), res->pdx)
+ - opj_int_floordivpow2(trx0, res->pdx);
+ prcj = opj_int_floordivpow2(opj_int_ceildiv(pi->y, comp->dy << levelno), res->pdy)
+ - opj_int_floordivpow2(try0, res->pdy);
pi->precno = prci + prcj * res->pw;
for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
res = &comp->resolutions[resno];
dx = comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
dy = comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
- pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
- pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
+ pi->dx = !pi->dx ? dx : opj_int_min(pi->dx, dx);
+ pi->dy = !pi->dy ? dy : opj_int_min(pi->dy, dy);
}
}
}
for (pi->x = pi->poc.tx0; pi->x < pi->poc.tx1; pi->x += pi->dx - (pi->x % pi->dx)) {
for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
comp = &pi->comps[pi->compno];
- for (pi->resno = pi->poc.resno0; pi->resno < uint_min(pi->poc.resno1, comp->numresolutions); pi->resno++) {
+ for (pi->resno = pi->poc.resno0; pi->resno < opj_uint_min(pi->poc.resno1, comp->numresolutions); pi->resno++) {
OPJ_UINT32 levelno;
OPJ_INT32 trx0, try0;
OPJ_INT32 trx1, try1;
OPJ_INT32 prci, prcj;
res = &comp->resolutions[pi->resno];
levelno = comp->numresolutions - 1 - pi->resno;
- trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
- try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
- trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);
- try1 = int_ceildiv(pi->ty1, comp->dy << levelno);
+ trx0 = opj_int_ceildiv(pi->tx0, comp->dx << levelno);
+ try0 = opj_int_ceildiv(pi->ty0, comp->dy << levelno);
+ trx1 = opj_int_ceildiv(pi->tx1, comp->dx << levelno);
+ try1 = opj_int_ceildiv(pi->ty1, comp->dy << levelno);
rpx = res->pdx + levelno;
rpy = res->pdy + levelno;
if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){
if ((trx0==trx1)||(try0==try1)) continue;
- prci = int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelno), res->pdx)
- - int_floordivpow2(trx0, res->pdx);
- prcj = int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelno), res->pdy)
- - int_floordivpow2(try0, res->pdy);
+ prci = opj_int_floordivpow2(opj_int_ceildiv(pi->x, comp->dx << levelno), res->pdx)
+ - opj_int_floordivpow2(trx0, res->pdx);
+ prcj = opj_int_floordivpow2(opj_int_ceildiv(pi->y, comp->dy << levelno), res->pdy)
+ - opj_int_floordivpow2(try0, res->pdy);
pi->precno = prci + prcj * res->pw;
for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
res = &comp->resolutions[resno];
dx = comp->dx * (1 << (res->pdx + comp->numresolutions - 1 - resno));
dy = comp->dy * (1 << (res->pdy + comp->numresolutions - 1 - resno));
- pi->dx = !pi->dx ? dx : int_min(pi->dx, dx);
- pi->dy = !pi->dy ? dy : int_min(pi->dy, dy);
+ pi->dx = !pi->dx ? dx : opj_int_min(pi->dx, dx);
+ pi->dy = !pi->dy ? dy : opj_int_min(pi->dy, dy);
}
if (!pi->tp_on){
pi->poc.ty0 = pi->ty0;
}
for (pi->y = pi->poc.ty0; pi->y < pi->poc.ty1; pi->y += pi->dy - (pi->y % pi->dy)) {
for (pi->x = pi->poc.tx0; pi->x < pi->poc.tx1; pi->x += pi->dx - (pi->x % pi->dx)) {
- for (pi->resno = pi->poc.resno0; pi->resno < uint_min(pi->poc.resno1, comp->numresolutions); pi->resno++) {
+ for (pi->resno = pi->poc.resno0; pi->resno < opj_uint_min(pi->poc.resno1, comp->numresolutions); pi->resno++) {
OPJ_UINT32 levelno;
OPJ_INT32 trx0, try0;
OPJ_INT32 trx1, try1;
OPJ_INT32 prci, prcj;
res = &comp->resolutions[pi->resno];
levelno = comp->numresolutions - 1 - pi->resno;
- trx0 = int_ceildiv(pi->tx0, comp->dx << levelno);
- try0 = int_ceildiv(pi->ty0, comp->dy << levelno);
- trx1 = int_ceildiv(pi->tx1, comp->dx << levelno);
- try1 = int_ceildiv(pi->ty1, comp->dy << levelno);
+ trx0 = opj_int_ceildiv(pi->tx0, comp->dx << levelno);
+ try0 = opj_int_ceildiv(pi->ty0, comp->dy << levelno);
+ trx1 = opj_int_ceildiv(pi->tx1, comp->dx << levelno);
+ try1 = opj_int_ceildiv(pi->ty1, comp->dy << levelno);
rpx = res->pdx + levelno;
rpy = res->pdy + levelno;
if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){
if ((trx0==trx1)||(try0==try1)) continue;
- prci = int_floordivpow2(int_ceildiv(pi->x, comp->dx << levelno), res->pdx)
- - int_floordivpow2(trx0, res->pdx);
- prcj = int_floordivpow2(int_ceildiv(pi->y, comp->dy << levelno), res->pdy)
- - int_floordivpow2(try0, res->pdy);
+ prci = opj_int_floordivpow2(opj_int_ceildiv(pi->x, comp->dx << levelno), res->pdx)
+ - opj_int_floordivpow2(trx0, res->pdx);
+ prcj = opj_int_floordivpow2(opj_int_ceildiv(pi->y, comp->dy << levelno), res->pdy)
+ - opj_int_floordivpow2(try0, res->pdy);
pi->precno = prci + prcj * res->pw;
for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
q = p_tileno / p_cp->tw;
/* find extent of tile */
- *p_tx0 = int_max(p_cp->tx0 + p * p_cp->tdx, p_image->x0);
- *p_tx1 = int_min(p_cp->tx0 + (p + 1) * p_cp->tdx, p_image->x1);
- *p_ty0 = int_max(p_cp->ty0 + q * p_cp->tdy, p_image->y0);
- *p_ty1 = int_min(p_cp->ty0 + (q + 1) * p_cp->tdy, p_image->y1);
+ *p_tx0 = opj_int_max(p_cp->tx0 + p * p_cp->tdx, p_image->x0);
+ *p_tx1 = opj_int_min(p_cp->tx0 + (p + 1) * p_cp->tdx, p_image->x1);
+ *p_ty0 = opj_int_max(p_cp->ty0 + q * p_cp->tdy, p_image->y0);
+ *p_ty1 = opj_int_min(p_cp->ty0 + (q + 1) * p_cp->tdy, p_image->y1);
/* max precision is 0 (can only grow) */
*p_max_prec = 0;
OPJ_UINT32 l_product;
OPJ_INT32 l_tcx0, l_tcy0, l_tcx1, l_tcy1;
- l_tcx0 = int_ceildiv(*p_tx0, l_img_comp->dx);
- l_tcy0 = int_ceildiv(*p_ty0, l_img_comp->dy);
- l_tcx1 = int_ceildiv(*p_tx1, l_img_comp->dx);
- l_tcy1 = int_ceildiv(*p_ty1, l_img_comp->dy);
+ l_tcx0 = opj_int_ceildiv(*p_tx0, l_img_comp->dx);
+ l_tcy0 = opj_int_ceildiv(*p_ty0, l_img_comp->dy);
+ l_tcx1 = opj_int_ceildiv(*p_tx1, l_img_comp->dx);
+ l_tcy1 = opj_int_ceildiv(*p_ty1, l_img_comp->dy);
if (l_tccp->numresolutions > *p_max_res) {
*p_max_res = l_tccp->numresolutions;
l_dy = l_img_comp->dy * (1 << (l_pdy + l_tccp->numresolutions - 1 - resno));
/* take the minimum size for dx for each comp and resolution */
- *p_dx_min = uint_min(*p_dx_min, l_dx);
- *p_dy_min = uint_min(*p_dy_min, l_dy);
+ *p_dx_min = opj_uint_min(*p_dx_min, l_dx);
+ *p_dy_min = opj_uint_min(*p_dy_min, l_dy);
/* various calculations of extents */
l_level_no = l_tccp->numresolutions - 1 - resno;
- l_rx0 = int_ceildivpow2(l_tcx0, l_level_no);
- l_ry0 = int_ceildivpow2(l_tcy0, l_level_no);
- l_rx1 = int_ceildivpow2(l_tcx1, l_level_no);
- l_ry1 = int_ceildivpow2(l_tcy1, l_level_no);
+ l_rx0 = opj_int_ceildivpow2(l_tcx0, l_level_no);
+ l_ry0 = opj_int_ceildivpow2(l_tcy0, l_level_no);
+ l_rx1 = opj_int_ceildivpow2(l_tcx1, l_level_no);
+ l_ry1 = opj_int_ceildivpow2(l_tcy1, l_level_no);
- l_px0 = int_floordivpow2(l_rx0, l_pdx) << l_pdx;
- l_py0 = int_floordivpow2(l_ry0, l_pdy) << l_pdy;
- l_px1 = int_ceildivpow2(l_rx1, l_pdx) << l_pdx;
+ l_px0 = opj_int_floordivpow2(l_rx0, l_pdx) << l_pdx;
+ l_py0 = opj_int_floordivpow2(l_ry0, l_pdy) << l_pdy;
+ l_px1 = opj_int_ceildivpow2(l_rx1, l_pdx) << l_pdx;
- py1 = int_ceildivpow2(l_ry1, l_pdy) << l_pdy;
+ py1 = opj_int_ceildivpow2(l_ry1, l_pdy) << l_pdy;
l_pw = (l_rx0==l_rx1)?0:((l_px1 - l_px0) >> l_pdx);
l_ph = (l_ry0==l_ry1)?0:((py1 - l_py0) >> l_pdy);
q = tileno / p_cp->tw;
/* here calculation of tx0, tx1, ty0, ty1, maxprec, l_dx and l_dy */
- *p_tx0 = int_max(p_cp->tx0 + p * p_cp->tdx, p_image->x0);
- *p_tx1 = int_min(p_cp->tx0 + (p + 1) * p_cp->tdx, p_image->x1);
- *p_ty0 = int_max(p_cp->ty0 + q * p_cp->tdy, p_image->y0);
- *p_ty1 = int_min(p_cp->ty0 + (q + 1) * p_cp->tdy, p_image->y1);
+ *p_tx0 = opj_int_max(p_cp->tx0 + p * p_cp->tdx, p_image->x0);
+ *p_tx1 = opj_int_min(p_cp->tx0 + (p + 1) * p_cp->tdx, p_image->x1);
+ *p_ty0 = opj_int_max(p_cp->ty0 + q * p_cp->tdy, p_image->y0);
+ *p_ty1 = opj_int_min(p_cp->ty0 + (q + 1) * p_cp->tdy, p_image->y1);
/* max precision and resolution is 0 (can only grow)*/
*p_max_prec = 0;
lResolutionPtr = p_resolutions[compno];
- l_tcx0 = int_ceildiv(*p_tx0, l_img_comp->dx);
- l_tcy0 = int_ceildiv(*p_ty0, l_img_comp->dy);
- l_tcx1 = int_ceildiv(*p_tx1, l_img_comp->dx);
- l_tcy1 = int_ceildiv(*p_ty1, l_img_comp->dy);
+ l_tcx0 = opj_int_ceildiv(*p_tx0, l_img_comp->dx);
+ l_tcy0 = opj_int_ceildiv(*p_ty0, l_img_comp->dy);
+ l_tcx1 = opj_int_ceildiv(*p_tx1, l_img_comp->dx);
+ l_tcy1 = opj_int_ceildiv(*p_ty1, l_img_comp->dy);
if (l_tccp->numresolutions > *p_max_res) {
*p_max_res = l_tccp->numresolutions;
l_dx = l_img_comp->dx * (1 << (l_pdx + l_level_no));
l_dy = l_img_comp->dy * (1 << (l_pdy + l_level_no));
/* take the minimum size for l_dx for each comp and resolution*/
- *p_dx_min = int_min(*p_dx_min, l_dx);
- *p_dy_min = int_min(*p_dy_min, l_dy);
+ *p_dx_min = opj_int_min(*p_dx_min, l_dx);
+ *p_dy_min = opj_int_min(*p_dy_min, l_dy);
/* various calculations of extents*/
- l_rx0 = int_ceildivpow2(l_tcx0, l_level_no);
- l_ry0 = int_ceildivpow2(l_tcy0, l_level_no);
- l_rx1 = int_ceildivpow2(l_tcx1, l_level_no);
- l_ry1 = int_ceildivpow2(l_tcy1, l_level_no);
- l_px0 = int_floordivpow2(l_rx0, l_pdx) << l_pdx;
- l_py0 = int_floordivpow2(l_ry0, l_pdy) << l_pdy;
- l_px1 = int_ceildivpow2(l_rx1, l_pdx) << l_pdx;
- py1 = int_ceildivpow2(l_ry1, l_pdy) << l_pdy;
+ l_rx0 = opj_int_ceildivpow2(l_tcx0, l_level_no);
+ l_ry0 = opj_int_ceildivpow2(l_tcy0, l_level_no);
+ l_rx1 = opj_int_ceildivpow2(l_tcx1, l_level_no);
+ l_ry1 = opj_int_ceildivpow2(l_tcy1, l_level_no);
+ l_px0 = opj_int_floordivpow2(l_rx0, l_pdx) << l_pdx;
+ l_py0 = opj_int_floordivpow2(l_ry0, l_pdy) << l_pdy;
+ l_px1 = opj_int_ceildivpow2(l_rx1, l_pdx) << l_pdx;
+ py1 = opj_int_ceildivpow2(l_ry1, l_pdy) << l_pdy;
l_pw = (l_rx0==l_rx1)?0:((l_px1 - l_px0) >> l_pdx);
l_ph = (l_ry0==l_ry1)?0:((py1 - l_py0) >> l_pdy);
*lResolutionPtr++ = l_pw;
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))) {
- v = int_abs(*datap) & one ? 1 : 0;
+ v = opj_int_abs(*datap) & one ? 1 : 0;
opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient)); /* ESSAI */
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
opj_mqc_bypass_enc(mqc, v);
}
if (v) {
v = *datap < 0 ? 1 : 0;
- *nmsedec += opj_t1_getnmsedec_sig(int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
+ *nmsedec += opj_t1_getnmsedec_sig(opj_int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag)); /* ESSAI */
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
opj_mqc_bypass_enc(mqc, v);
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
- *nmsedec += opj_t1_getnmsedec_ref(int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
- v = int_abs(*datap) & one ? 1 : 0;
+ *nmsedec += opj_t1_getnmsedec_ref(opj_int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
+ v = opj_int_abs(*datap) & one ? 1 : 0;
opj_mqc_setcurctx(mqc, opj_t1_getctxno_mag(flag)); /* ESSAI */
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
opj_mqc_bypass_enc(mqc, v);
}
if (!(*flagsp & (T1_SIG | T1_VISIT))) {
opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient));
- v = int_abs(*datap) & one ? 1 : 0;
+ v = opj_int_abs(*datap) & one ? 1 : 0;
opj_mqc_encode(mqc, v);
if (v) {
LABEL_PARTIAL:
- *nmsedec += opj_t1_getnmsedec_sig(int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
+ *nmsedec += opj_t1_getnmsedec_sig(opj_int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag));
v = *datap < 0 ? 1 : 0;
opj_mqc_encode(mqc, v ^ opj_t1_getspb(flag));
}
if (agg) {
for (runlen = 0; runlen < 4; ++runlen) {
- if (int_abs(t1->data[((k + runlen)*t1->w) + i]) & one)
+ if (opj_int_abs(t1->data[((k + runlen)*t1->w) + i]) & one)
break;
}
opj_mqc_setcurctx(mqc, T1_CTXNO_AGG);
for (i = 0; i < cblk_w; ++i) {
OPJ_INT32 tmp = tiledp[(j * tile_w) + i];
datap[(j * cblk_w) + i] =
- fix_mul(
+ opj_int_fix_mul(
tmp,
bandconst) >> (11 - T1_NMSEDEC_FRACBITS);
}
max = 0;
for (i = 0; i < t1->w * t1->h; ++i) {
OPJ_INT32 tmp = abs(t1->data[i]);
- max = int_max(max, tmp);
+ max = opj_int_max(max, tmp);
}
- cblk->numbps = max ? (int_floorlog2(max) + 1) - T1_NMSEDEC_FRACBITS : 0;
+ cblk->numbps = max ? (opj_int_floorlog2(max) + 1) - T1_NMSEDEC_FRACBITS : 0;
bpno = cblk->numbps - 1;
passtype = 2;
int hc, vc, n;
n = 0;
- hc = int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
+ hc = opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
T1_SIG_E) + ((f & (T1_SIG_W | T1_SGN_W)) == T1_SIG_W),
- 1) - int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
+ 1) - opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
(T1_SIG_E | T1_SGN_E)) +
((f & (T1_SIG_W | T1_SGN_W)) ==
(T1_SIG_W | T1_SGN_W)), 1);
- vc = int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
+ vc = opj_int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
T1_SIG_N) + ((f & (T1_SIG_S | T1_SGN_S)) == T1_SIG_S),
- 1) - int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
+ 1) - opj_int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
(T1_SIG_N | T1_SGN_N)) +
((f & (T1_SIG_S | T1_SGN_S)) ==
(T1_SIG_S | T1_SGN_S)), 1);
static int t1_init_spb(int f) {
int hc, vc, n;
- hc = int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
+ hc = opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
T1_SIG_E) + ((f & (T1_SIG_W | T1_SGN_W)) == T1_SIG_W),
- 1) - int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
+ 1) - opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) ==
(T1_SIG_E | T1_SGN_E)) +
((f & (T1_SIG_W | T1_SGN_W)) ==
(T1_SIG_W | T1_SGN_W)), 1);
- vc = int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
+ vc = opj_int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
T1_SIG_N) + ((f & (T1_SIG_S | T1_SGN_S)) == T1_SIG_S),
- 1) - int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
+ 1) - opj_int_min(((f & (T1_SIG_N | T1_SGN_N)) ==
(T1_SIG_N | T1_SGN_N)) +
((f & (T1_SIG_S | T1_SGN_S)) ==
(T1_SIG_S | T1_SGN_S)), 1);
u = t;
v = t - 1.5;
lut_nmsedec_sig[i] =
- int_max(0,
+ opj_int_max(0,
(int) (floor((u * u - v * v) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
lut_nmsedec_sig0[i] =
- int_max(0,
+ opj_int_max(0,
(int) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
u = t - 1.0;
if (i & (1 << (T1_NMSEDEC_BITS - 1))) {
v = t - 0.5;
}
lut_nmsedec_ref[i] =
- int_max(0,
+ opj_int_max(0,
(int) (floor((u * u - v * v) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
lut_nmsedec_ref0[i] =
- int_max(0,
+ opj_int_max(0,
(int) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
}
}
l_img_comp = &(l_image->comps[l_current_pi->compno]);
- l_img_comp->resno_decoded = uint_max(l_current_pi->resno, l_img_comp->resno_decoded);
+ l_img_comp->resno_decoded = opj_uint_max(l_current_pi->resno, l_img_comp->resno_decoded);
}
else {
l_nb_bytes_read = 0;
len += pass->len;
if (pass->term || passno == (cblk->numpasses + layer->numpasses) - 1) {
- increment = int_max(increment, int_floorlog2(len) + 1 - (cblk->numlenbits + int_floorlog2(nump)));
+ increment = opj_int_max(increment, opj_int_floorlog2(len) + 1 - (cblk->numlenbits + opj_int_floorlog2(nump)));
len = 0;
nump = 0;
}
len += pass->len;
if (pass->term || passno == (cblk->numpasses + layer->numpasses) - 1) {
- opj_bio_write(bio, len, cblk->numlenbits + int_floorlog2(nump));
+ opj_bio_write(bio, len, cblk->numlenbits + opj_int_floorlog2(nump));
len = 0;
nump = 0;
}
n = l_cblk->numnewpasses;
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 = opj_bio_read(l_bio, l_cblk->numlenbits + uint_floorlog2(l_cblk->segs[l_segno].numnewpasses));
+ l_cblk->segs[l_segno].numnewpasses = opj_int_min(l_cblk->segs[l_segno].maxpasses - l_cblk->segs[l_segno].numpasses, n);
+ l_cblk->segs[l_segno].newlen = opj_bio_read(l_bio, l_cblk->numlenbits + opj_uint_floorlog2(l_cblk->segs[l_segno].numnewpasses));
n -= l_cblk->segs[l_segno].numnewpasses;
if (n > 0) {
OPJ_FLOAT64 lo = min;
OPJ_FLOAT64 hi = max;
opj_bool success = OPJ_FALSE;
- OPJ_UINT32 maxlen = tcd_tcp->rates[layno] ? uint_min(((OPJ_UINT32) ceil(tcd_tcp->rates[layno])), len) : len;
+ OPJ_UINT32 maxlen = tcd_tcp->rates[layno] ? opj_uint_min(((OPJ_UINT32) ceil(tcd_tcp->rates[layno])), len) : len;
OPJ_FLOAT64 goodthresh = 0;
OPJ_FLOAT64 stable_thresh = 0;
OPJ_UINT32 i;
/*fprintf(stderr, "Tile coordinate = %d,%d\n", p, q);*/ \
\
/* 4 borders of the tile rescale on the image if necessary */ \
- l_tile->x0 = int_max(l_cp->tx0 + p * l_cp->tdx, l_image->x0); \
- l_tile->y0 = int_max(l_cp->ty0 + q * l_cp->tdy, l_image->y0); \
- l_tile->x1 = int_min(l_cp->tx0 + (p + 1) * l_cp->tdx, l_image->x1); \
- l_tile->y1 = int_min(l_cp->ty0 + (q + 1) * l_cp->tdy, l_image->y1); \
+ l_tile->x0 = opj_int_max(l_cp->tx0 + p * l_cp->tdx, l_image->x0); \
+ l_tile->y0 = opj_int_max(l_cp->ty0 + q * l_cp->tdy, l_image->y0); \
+ l_tile->x1 = opj_int_min(l_cp->tx0 + (p + 1) * l_cp->tdx, l_image->x1); \
+ l_tile->y1 = opj_int_min(l_cp->ty0 + (q + 1) * l_cp->tdy, l_image->y1); \
/*fprintf(stderr, "Tile border = %d,%d,%d,%d\n", l_tile->x0, l_tile->y0,l_tile->x1,l_tile->y1);*/ \
\
/*tile->numcomps = image->numcomps; */ \
/*fprintf(stderr, "compno = %d/%d\n", compno, l_tile->numcomps);*/ \
\
/* border of each l_tile component (global) */ \
- l_tilec->x0 = int_ceildiv(l_tile->x0, l_image_comp->dx); \
- l_tilec->y0 = int_ceildiv(l_tile->y0, l_image_comp->dy); \
- l_tilec->x1 = int_ceildiv(l_tile->x1, l_image_comp->dx); \
- l_tilec->y1 = int_ceildiv(l_tile->y1, l_image_comp->dy); \
+ l_tilec->x0 = opj_int_ceildiv(l_tile->x0, l_image_comp->dx); \
+ l_tilec->y0 = opj_int_ceildiv(l_tile->y0, l_image_comp->dy); \
+ l_tilec->x1 = opj_int_ceildiv(l_tile->x1, l_image_comp->dx); \
+ l_tilec->y1 = opj_int_ceildiv(l_tile->y1, l_image_comp->dy); \
/*fprintf(stderr, "\tTile compo border = %d,%d,%d,%d\n", l_tilec->x0, l_tilec->y0,l_tilec->x1,l_tilec->y1);*/ \
\
l_data_size = (l_tilec->x1 - l_tilec->x0) \
OPJ_UINT32 cblkwidthexpn, cblkheightexpn; \
\
/* border for each resolution level (global) */ \
- l_res->x0 = int_ceildivpow2(l_tilec->x0, l_level_no); \
- l_res->y0 = int_ceildivpow2(l_tilec->y0, l_level_no); \
- l_res->x1 = int_ceildivpow2(l_tilec->x1, l_level_no); \
- l_res->y1 = int_ceildivpow2(l_tilec->y1, l_level_no); \
+ l_res->x0 = opj_int_ceildivpow2(l_tilec->x0, l_level_no); \
+ l_res->y0 = opj_int_ceildivpow2(l_tilec->y0, l_level_no); \
+ l_res->x1 = opj_int_ceildivpow2(l_tilec->x1, l_level_no); \
+ l_res->y1 = opj_int_ceildivpow2(l_tilec->y1, l_level_no); \
/*fprintf(stderr, "\t\t\tres_x0= %d, res_y0 =%d, res_x1=%d, res_y1=%d\n", l_res->x0, l_res->y0, l_res->x1, l_res->y1);*/ \
/* p. 35, table A-23, ISO/IEC FDIS154444-1 : 2000 (18 august 2000) */ \
l_pdx = l_tccp->prcw[resno]; \
l_pdy = l_tccp->prch[resno]; \
/*fprintf(stderr, "\t\t\tpdx=%d, pdy=%d\n", l_pdx, l_pdy);*/ \
/* p. 64, B.6, ISO/IEC FDIS15444-1 : 2000 (18 august 2000) */ \
- l_tl_prc_x_start = int_floordivpow2(l_res->x0, l_pdx) << l_pdx; \
- l_tl_prc_y_start = int_floordivpow2(l_res->y0, l_pdy) << l_pdy; \
- l_br_prc_x_end = int_ceildivpow2(l_res->x1, l_pdx) << l_pdx; \
- l_br_prc_y_end = int_ceildivpow2(l_res->y1, l_pdy) << l_pdy; \
+ l_tl_prc_x_start = opj_int_floordivpow2(l_res->x0, l_pdx) << l_pdx; \
+ l_tl_prc_y_start = opj_int_floordivpow2(l_res->y0, l_pdy) << l_pdy; \
+ l_br_prc_x_end = opj_int_ceildivpow2(l_res->x1, l_pdx) << l_pdx; \
+ l_br_prc_y_end = opj_int_ceildivpow2(l_res->y1, l_pdy) << l_pdy; \
/*fprintf(stderr, "\t\t\tprc_x_start=%d, prc_y_start=%d, br_prc_x_end=%d, br_prc_y_end=%d \n", l_tl_prc_x_start, l_tl_prc_y_start, l_br_prc_x_end ,l_br_prc_y_end );*/ \
\
l_res->pw = (l_res->x0 == l_res->x1) ? 0 : ((l_br_prc_x_end - l_tl_prc_x_start) >> l_pdx); \
l_res->numbands = 1; \
} \
else { \
- tlcbgxstart = int_ceildivpow2(l_tl_prc_x_start, 1); \
- tlcbgystart = int_ceildivpow2(l_tl_prc_y_start, 1); \
- brcbgxend = int_ceildivpow2(l_br_prc_x_end, 1); \
- brcbgyend = int_ceildivpow2(l_br_prc_y_end, 1); \
+ tlcbgxstart = opj_int_ceildivpow2(l_tl_prc_x_start, 1); \
+ tlcbgystart = opj_int_ceildivpow2(l_tl_prc_y_start, 1); \
+ brcbgxend = opj_int_ceildivpow2(l_br_prc_x_end, 1); \
+ brcbgyend = opj_int_ceildivpow2(l_br_prc_y_end, 1); \
cbgwidthexpn = l_pdx - 1; \
cbgheightexpn = l_pdy - 1; \
l_res->numbands = 3; \
} \
\
- cblkwidthexpn = uint_min(l_tccp->cblkw, cbgwidthexpn); \
- cblkheightexpn = uint_min(l_tccp->cblkh, cbgheightexpn); \
+ cblkwidthexpn = opj_uint_min(l_tccp->cblkw, cbgwidthexpn); \
+ cblkheightexpn = opj_uint_min(l_tccp->cblkh, cbgheightexpn); \
l_band = l_res->bands; \
\
for (bandno = 0; bandno < l_res->numbands; ++bandno) { \
\
if (resno == 0) { \
l_band->bandno = 0 ; \
- l_band->x0 = int_ceildivpow2(l_tilec->x0, l_level_no); \
- l_band->y0 = int_ceildivpow2(l_tilec->y0, l_level_no); \
- l_band->x1 = int_ceildivpow2(l_tilec->x1, l_level_no); \
- l_band->y1 = int_ceildivpow2(l_tilec->y1, l_level_no); \
+ l_band->x0 = opj_int_ceildivpow2(l_tilec->x0, l_level_no); \
+ l_band->y0 = opj_int_ceildivpow2(l_tilec->y0, l_level_no); \
+ l_band->x1 = opj_int_ceildivpow2(l_tilec->x1, l_level_no); \
+ l_band->y1 = opj_int_ceildivpow2(l_tilec->y1, l_level_no); \
} \
else { \
l_band->bandno = bandno + 1; \
/* y0b = 1 if bandno = 2 or 3 */ \
l_y0b = (l_band->bandno)>>1; \
/* l_band border (global) */ \
- l_band->x0 = int_ceildivpow2(l_tilec->x0 - (1 << l_level_no) * l_x0b, l_level_no + 1); \
- l_band->y0 = int_ceildivpow2(l_tilec->y0 - (1 << l_level_no) * l_y0b, l_level_no + 1); \
- l_band->x1 = int_ceildivpow2(l_tilec->x1 - (1 << l_level_no) * l_x0b, l_level_no + 1); \
- l_band->y1 = int_ceildivpow2(l_tilec->y1 - (1 << l_level_no) * l_y0b, l_level_no + 1); \
+ l_band->x0 = opj_int_ceildivpow2(l_tilec->x0 - (1 << l_level_no) * l_x0b, l_level_no + 1); \
+ l_band->y0 = opj_int_ceildivpow2(l_tilec->y0 - (1 << l_level_no) * l_y0b, l_level_no + 1); \
+ l_band->x1 = opj_int_ceildivpow2(l_tilec->x1 - (1 << l_level_no) * l_x0b, l_level_no + 1); \
+ l_band->y1 = opj_int_ceildivpow2(l_tilec->y1 - (1 << l_level_no) * l_y0b, l_level_no + 1); \
} \
\
/** avoid an if with storing function pointer */ \
/* precinct size (global) */ \
/*fprintf(stderr, "\t cbgxstart=%d, l_band->x0 = %d \n",cbgxstart, l_band->x0);*/ \
\
- l_current_precinct->x0 = int_max(cbgxstart, l_band->x0); \
- l_current_precinct->y0 = int_max(cbgystart, l_band->y0); \
- l_current_precinct->x1 = int_min(cbgxend, l_band->x1); \
- l_current_precinct->y1 = int_min(cbgyend, l_band->y1); \
+ l_current_precinct->x0 = opj_int_max(cbgxstart, l_band->x0); \
+ l_current_precinct->y0 = opj_int_max(cbgystart, l_band->y0); \
+ l_current_precinct->x1 = opj_int_min(cbgxend, l_band->x1); \
+ l_current_precinct->y1 = opj_int_min(cbgyend, l_band->y1); \
/*fprintf(stderr, "\t prc_x0=%d; prc_y0=%d, prc_x1=%d; prc_y1=%d\n",l_current_precinct->x0, l_current_precinct->y0 ,l_current_precinct->x1, l_current_precinct->y1);*/ \
\
- tlcblkxstart = int_floordivpow2(l_current_precinct->x0, cblkwidthexpn) << cblkwidthexpn; \
+ tlcblkxstart = opj_int_floordivpow2(l_current_precinct->x0, cblkwidthexpn) << cblkwidthexpn; \
/*fprintf(stderr, "\t tlcblkxstart =%d\n",tlcblkxstart );*/ \
- tlcblkystart = int_floordivpow2(l_current_precinct->y0, cblkheightexpn) << cblkheightexpn; \
+ tlcblkystart = opj_int_floordivpow2(l_current_precinct->y0, cblkheightexpn) << cblkheightexpn; \
/*fprintf(stderr, "\t tlcblkystart =%d\n",tlcblkystart );*/ \
- brcblkxend = int_ceildivpow2(l_current_precinct->x1, cblkwidthexpn) << cblkwidthexpn; \
+ brcblkxend = opj_int_ceildivpow2(l_current_precinct->x1, cblkwidthexpn) << cblkwidthexpn; \
/*fprintf(stderr, "\t brcblkxend =%d\n",brcblkxend );*/ \
- brcblkyend = int_ceildivpow2(l_current_precinct->y1, cblkheightexpn) << cblkheightexpn; \
+ brcblkyend = opj_int_ceildivpow2(l_current_precinct->y1, cblkheightexpn) << cblkheightexpn; \
/*fprintf(stderr, "\t brcblkyend =%d\n",brcblkyend );*/ \
l_current_precinct->cw = (brcblkxend - tlcblkxstart) >> cblkwidthexpn; \
l_current_precinct->ch = (brcblkyend - tlcblkystart) >> cblkheightexpn; \
OPJ_INT32 cblkyend = cblkystart + (1 << cblkheightexpn); \
\
/* code-block size (global) */ \
- l_code_block->x0 = int_max(cblkxstart, l_current_precinct->x0); \
- l_code_block->y0 = int_max(cblkystart, l_current_precinct->y0); \
- l_code_block->x1 = int_min(cblkxend, l_current_precinct->x1); \
- l_code_block->y1 = int_min(cblkyend, l_current_precinct->y1); \
+ l_code_block->x0 = opj_int_max(cblkxstart, l_current_precinct->x0); \
+ l_code_block->y0 = opj_int_max(cblkystart, l_current_precinct->y0); \
+ l_code_block->x1 = opj_int_min(cblkxend, l_current_precinct->x1); \
+ l_code_block->y1 = opj_int_min(cblkyend, l_current_precinct->y1); \
\
if (! FUNCTION_ELEMENT(l_code_block)) { \
return OPJ_FALSE; \
if (l_tccp->qmfbid == 1) {
for (j=0;j<l_height;++j) {
for (i = 0; i < l_width; ++i) {
- *l_current_ptr = int_clamp(*l_current_ptr + l_tccp->m_dc_level_shift, l_min, l_max);
+ *l_current_ptr = opj_int_clamp(*l_current_ptr + l_tccp->m_dc_level_shift, l_min, l_max);
++l_current_ptr;
}
l_current_ptr += l_stride;
for (j=0;j<l_height;++j) {
for (i = 0; i < l_width; ++i) {
OPJ_FLOAT32 l_value = *((OPJ_FLOAT32 *) l_current_ptr);
- *l_current_ptr = int_clamp(lrintf(l_value) + l_tccp->m_dc_level_shift, l_min, l_max); ;
+ *l_current_ptr = opj_int_clamp(lrintf(l_value) + l_tccp->m_dc_level_shift, l_min, l_max); ;
++l_current_ptr;
}
l_current_ptr += l_stride;