Alien-FreeImage
view release on metacpan or search on metacpan
src/Source/LibOpenJPEG/tcd.c view on Meta::CPAN
if (resno == 0) { \
l_band->bandno = 0 ; \
l_band->x0 = opj_int_ceildivpow2(l_tilec->x0, (OPJ_INT32)l_level_no); \
l_band->y0 = opj_int_ceildivpow2(l_tilec->y0, (OPJ_INT32)l_level_no); \
l_band->x1 = opj_int_ceildivpow2(l_tilec->x1, (OPJ_INT32)l_level_no); \
l_band->y1 = opj_int_ceildivpow2(l_tilec->y1, (OPJ_INT32)l_level_no); \
} \
else { \
l_band->bandno = bandno + 1; \
/* x0b = 1 if bandno = 1 or 3 */ \
l_x0b = l_band->bandno&1; \
/* y0b = 1 if bandno = 2 or 3 */ \
l_y0b = (OPJ_INT32)((l_band->bandno)>>1); \
/* l_band border (global) */ \
l_band->x0 = opj_int_ceildivpow2(l_tilec->x0 - (1 << l_level_no) * l_x0b, (OPJ_INT32)(l_level_no + 1)); \
l_band->y0 = opj_int_ceildivpow2(l_tilec->y0 - (1 << l_level_no) * l_y0b, (OPJ_INT32)(l_level_no + 1)); \
l_band->x1 = opj_int_ceildivpow2(l_tilec->x1 - (1 << l_level_no) * l_x0b, (OPJ_INT32)(l_level_no + 1)); \
l_band->y1 = opj_int_ceildivpow2(l_tilec->y1 - (1 << l_level_no) * l_y0b, (OPJ_INT32)(l_level_no + 1)); \
} \
\
/** avoid an if with storing function pointer */ \
l_gain = (*l_gain_ptr) (l_band->bandno); \
numbps = (OPJ_INT32)(l_image_comp->prec + l_gain); \
l_band->stepsize = (OPJ_FLOAT32)(((1.0 + l_step_size->mant / 2048.0) * pow(2.0, (OPJ_INT32) (numbps - l_step_size->expn)))) * FRACTION; \
l_band->numbps = l_step_size->expn + (OPJ_INT32)l_tccp->numgbits - 1; /* WHY -1 ? */ \
\
if (! l_band->precincts) { \
l_band->precincts = (opj_tcd_precinct_t *) opj_malloc( /*3 * */ l_nb_precinct_size); \
if (! l_band->precincts) { \
return OPJ_FALSE; \
} \
/*fprintf(stderr, "\t\t\t\tAllocate precincts of a band (opj_tcd_precinct_t): %d\n",l_nb_precinct_size); */ \
memset(l_band->precincts,0,l_nb_precinct_size); \
l_band->precincts_data_size = l_nb_precinct_size; \
} \
else if (l_band->precincts_data_size < l_nb_precinct_size) { \
\
opj_tcd_precinct_t * new_precincts = (opj_tcd_precinct_t *) opj_realloc(l_band->precincts,/*3 * */ l_nb_precinct_size); \
if (! new_precincts) { \
/* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to handle band precints\n"); */ \
fprintf(stderr, "Not enough memory to handle band precints\n"); \
opj_free(l_band->precincts); \
l_band->precincts = NULL; \
l_band->precincts_data_size = 0; \
return OPJ_FALSE; \
} \
l_band->precincts = new_precincts; \
/*fprintf(stderr, "\t\t\t\tReallocate precincts of a band (opj_tcd_precinct_t): from %d to %d\n",l_band->precincts_data_size, l_nb_precinct_size);*/ \
memset(((OPJ_BYTE *) l_band->precincts) + l_band->precincts_data_size,0,l_nb_precinct_size - l_band->precincts_data_size); \
l_band->precincts_data_size = l_nb_precinct_size; \
} \
\
l_current_precinct = l_band->precincts; \
for (precno = 0; precno < l_nb_precincts; ++precno) { \
OPJ_INT32 tlcblkxstart, tlcblkystart, brcblkxend, brcblkyend; \
OPJ_INT32 cbgxstart = tlcbgxstart + (OPJ_INT32)(precno % l_res->pw) * (1 << cbgwidthexpn); \
OPJ_INT32 cbgystart = tlcbgystart + (OPJ_INT32)(precno / l_res->pw) * (1 << cbgheightexpn); \
OPJ_INT32 cbgxend = cbgxstart + (1 << cbgwidthexpn); \
OPJ_INT32 cbgyend = cbgystart + (1 << cbgheightexpn); \
/*fprintf(stderr, "\t precno=%d; bandno=%d, resno=%d; compno=%d\n", precno, bandno , resno, compno);*/ \
/*fprintf(stderr, "\t tlcbgxstart(=%d) + (precno(=%d) percent res->pw(=%d)) * (1 << cbgwidthexpn(=%d)) \n",tlcbgxstart,precno,l_res->pw,cbgwidthexpn);*/ \
\
/* precinct size (global) */ \
/*fprintf(stderr, "\t cbgxstart=%d, l_band->x0 = %d \n",cbgxstart, l_band->x0);*/ \
\
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 = opj_int_floordivpow2(l_current_precinct->x0, (OPJ_INT32)cblkwidthexpn) << cblkwidthexpn; \
/*fprintf(stderr, "\t tlcblkxstart =%d\n",tlcblkxstart );*/ \
tlcblkystart = opj_int_floordivpow2(l_current_precinct->y0, (OPJ_INT32)cblkheightexpn) << cblkheightexpn; \
/*fprintf(stderr, "\t tlcblkystart =%d\n",tlcblkystart );*/ \
brcblkxend = opj_int_ceildivpow2(l_current_precinct->x1, (OPJ_INT32)cblkwidthexpn) << cblkwidthexpn; \
/*fprintf(stderr, "\t brcblkxend =%d\n",brcblkxend );*/ \
brcblkyend = opj_int_ceildivpow2(l_current_precinct->y1, (OPJ_INT32)cblkheightexpn) << cblkheightexpn; \
/*fprintf(stderr, "\t brcblkyend =%d\n",brcblkyend );*/ \
l_current_precinct->cw = (OPJ_UINT32)((brcblkxend - tlcblkxstart) >> cblkwidthexpn); \
l_current_precinct->ch = (OPJ_UINT32)((brcblkyend - tlcblkystart) >> cblkheightexpn); \
\
l_nb_code_blocks = l_current_precinct->cw * l_current_precinct->ch; \
/*fprintf(stderr, "\t\t\t\t precinct_cw = %d x recinct_ch = %d\n",l_current_precinct->cw, l_current_precinct->ch); */ \
l_nb_code_blocks_size = l_nb_code_blocks * (OPJ_UINT32)sizeof(TYPE); \
\
if (! l_current_precinct->cblks.ELEMENT) { \
l_current_precinct->cblks.ELEMENT = (TYPE*) opj_malloc(l_nb_code_blocks_size); \
if (! l_current_precinct->cblks.ELEMENT ) { \
return OPJ_FALSE; \
} \
/*fprintf(stderr, "\t\t\t\tAllocate cblks of a precinct (opj_tcd_cblk_dec_t): %d\n",l_nb_code_blocks_size);*/ \
\
memset(l_current_precinct->cblks.ELEMENT,0,l_nb_code_blocks_size); \
\
l_current_precinct->block_size = l_nb_code_blocks_size; \
} \
else if (l_nb_code_blocks_size > l_current_precinct->block_size) { \
TYPE *new_ELEMENT = (TYPE*) opj_realloc(l_current_precinct->cblks.ELEMENT, l_nb_code_blocks_size); \
if (! new_ELEMENT) { \
opj_free(l_current_precinct->cblks.ELEMENT); \
l_current_precinct->cblks.ELEMENT = NULL; \
l_current_precinct->block_size = 0; \
/* opj_event_msg(p_manager, EVT_ERROR, "Not enough memory for current precinct codeblock element\n"); */ \
fprintf(stderr, "Not enough memory for current precinct codeblock element\n"); \
return OPJ_FALSE; \
} \
l_current_precinct->cblks.ELEMENT = new_ELEMENT; \
/*fprintf(stderr, "\t\t\t\tReallocate cblks of a precinct (opj_tcd_cblk_dec_t): from %d to %d\n",l_current_precinct->block_size, l_nb_code_blocks_size); */\
\
memset(((OPJ_BYTE *) l_current_precinct->cblks.ELEMENT) + l_current_precinct->block_size \
,0 \
,l_nb_code_blocks_size - l_current_precinct->block_size); \
\
l_current_precinct->block_size = l_nb_code_blocks_size; \
} \
\
if (! l_current_precinct->incltree) { \
l_current_precinct->incltree = opj_tgt_create(l_current_precinct->cw, \
l_current_precinct->ch); \
} \
( run in 0.467 second using v1.01-cache-2.11-cpan-411bb0df24b )