static int t1_init_spb_opt(int f) { int hc, vc, n; hc = opj_int_min(((f & (T1_LUT_SIG_E | T1_LUT_SGN_E)) == T1_LUT_SIG_E) + ((f & (T1_LUT_SIG_W | T1_LUT_SGN_W)) == T1_LUT_SIG_W), 1) - opj_int_min(((f & (T1_LUT_SIG_E | T1_LUT_SGN_E)) == (T1_LUT_SIG_E | T1_LUT_SGN_E)) + ((f & (T1_LUT_SIG_W | T1_LUT_SGN_W)) == (T1_LUT_SIG_W | T1_LUT_SGN_W)), 1); vc = opj_int_min(((f & (T1_LUT_SIG_N | T1_LUT_SGN_N)) == T1_LUT_SIG_N) + ((f & (T1_LUT_SIG_S | T1_LUT_SGN_S)) == T1_LUT_SIG_S), 1) - opj_int_min(((f & (T1_LUT_SIG_N | T1_LUT_SGN_N)) == (T1_LUT_SIG_N | T1_LUT_SGN_N)) + ((f & (T1_LUT_SIG_S | T1_LUT_SGN_S)) == (T1_LUT_SIG_S | T1_LUT_SGN_S)), 1); if (!hc && !vc) n = 0; else n = (!(hc > 0 || (!hc && vc > 0))); return n; }
opj_pt_t opj_tile_buf_get_interleaved_range(opj_tile_buf_component_t* comp, uint32_t resno, bool is_horizontal) { opj_pt_t rc; opj_pt_t even; opj_pt_t odd; opj_tile_buf_resolution_t* res = NULL; memset(&rc, 0, sizeof(opj_pt_t)); if (!comp) return rc; res = comp->resolutions[comp->resolutions.size()- 1 - resno]; if (!res) return rc; even = opj_tile_buf_get_uninterleaved_range(comp, resno, true, is_horizontal); odd = opj_tile_buf_get_uninterleaved_range(comp, resno, false, is_horizontal); rc.x = opj_int_min( (even.x <<1), (odd.x << 1) + 1 ); rc.y = opj_int_max( (even.y<< 1), (odd.y << 1) + 1); /* clip to resolution bounds */ rc.x = opj_int_max(0, rc.x); rc.y = opj_int_min(rc.y, is_horizontal ? res->bounds.x : res->bounds.y); return rc; }
/** * Updates the components characteristics of the image from the coding parameters. * * @param p_image_header the image header to update. * @param p_cp the coding parameters from which to update the image. */ void opj_image_comp_header_update(opj_image_t * p_image_header, const struct opj_cp * p_cp) { OPJ_UINT32 i, l_width, l_height; OPJ_INT32 l_x0, l_y0, l_x1, l_y1; OPJ_INT32 l_comp_x0, l_comp_y0, l_comp_x1, l_comp_y1; opj_image_comp_t* l_img_comp = NULL; l_x0 = opj_int_max((OPJ_INT32)p_cp->tx0 , (OPJ_INT32)p_image_header->x0); l_y0 = opj_int_max((OPJ_INT32)p_cp->ty0 , (OPJ_INT32)p_image_header->y0); l_x1 = opj_int_min((OPJ_INT32)(p_cp->tx0 + p_cp->tw * p_cp->tdx), (OPJ_INT32)p_image_header->x1); l_y1 = opj_int_min((OPJ_INT32)(p_cp->ty0 + p_cp->th * p_cp->tdy), (OPJ_INT32)p_image_header->y1); l_img_comp = p_image_header->comps; for (i = 0; i < p_image_header->numcomps; ++i) { l_comp_x0 = opj_int_ceildiv(l_x0, (OPJ_INT32)l_img_comp->dx); l_comp_y0 = opj_int_ceildiv(l_y0, (OPJ_INT32)l_img_comp->dy); l_comp_x1 = opj_int_ceildiv(l_x1, (OPJ_INT32)l_img_comp->dx); l_comp_y1 = opj_int_ceildiv(l_y1, (OPJ_INT32)l_img_comp->dy); l_width = (OPJ_UINT32)opj_int_ceildivpow2(l_comp_x1 - l_comp_x0, (OPJ_INT32)l_img_comp->factor); l_height = (OPJ_UINT32)opj_int_ceildivpow2(l_comp_y1 - l_comp_y0, (OPJ_INT32)l_img_comp->factor); l_img_comp->w = l_width; l_img_comp->h = l_height; l_img_comp->x0 = (OPJ_UINT32)l_comp_x0/*l_x0*/; l_img_comp->y0 = (OPJ_UINT32)l_comp_y0/*l_y0*/; ++l_img_comp; } }
opj_pt_t opj_tile_buf_get_uninterleaved_range(opj_tile_buf_component_t* comp, uint32_t resno, bool is_even, bool is_horizontal) { opj_pt_t rc; opj_tile_buf_resolution_t* res= NULL; opj_tile_buf_resolution_t* prev_res = NULL; opj_tile_buf_band_t *band= NULL; memset(&rc, 0, sizeof(opj_pt_t)); if (!comp) return rc; res = comp->resolutions[comp->resolutions.size() - 1 - resno]; if (!res) return rc; prev_res = comp->resolutions[comp->resolutions.size() - 1 - resno+1]; if (resno == 0) { band = res->band_region; } else { if (!is_even) { band = res->band_region + 2; } else { band = is_horizontal ? res->band_region + 1 : res->band_region; } } if (is_horizontal) { rc.x = band->dim.x0 - prev_res->origin.x; rc.y = band->dim.x1 - prev_res->origin.x; } else { rc.x = band->dim.y0 - prev_res->origin.y; rc.y = band->dim.y1 - prev_res->origin.y; } /* clip */ rc.x = opj_int_max(0, rc.x); /* if resno == 0, then prev_res is null */ if (resno == 0) { rc.y = opj_int_min(rc.y, is_horizontal ? res->bounds.x : res->bounds.y); } else { if (is_even) rc.y = opj_int_min(rc.y, is_horizontal ? prev_res->bounds.x : prev_res->bounds.y); else rc.y = opj_int_min(rc.y, is_horizontal ? res->bounds.x - prev_res->bounds.x : res->bounds.y - prev_res->bounds.y); } return rc; }
static int t1_init_ctxno_sc_opt(int f) { int hc, vc, n; n = 0; hc = opj_int_min(((f & (T1_LUT_SIG_E | T1_LUT_SGN_E)) == T1_LUT_SIG_E) + ((f & (T1_LUT_SIG_W | T1_LUT_SGN_W)) == T1_LUT_SIG_W), 1) - opj_int_min(((f & (T1_LUT_SIG_E | T1_LUT_SGN_E)) == (T1_LUT_SIG_E | T1_LUT_SGN_E)) + ((f & (T1_LUT_SIG_W | T1_LUT_SGN_W)) == (T1_LUT_SIG_W | T1_LUT_SGN_W)), 1); vc = opj_int_min(((f & (T1_LUT_SIG_N | T1_LUT_SGN_N)) == T1_LUT_SIG_N) + ((f & (T1_LUT_SIG_S | T1_LUT_SGN_S)) == T1_LUT_SIG_S), 1) - opj_int_min(((f & (T1_LUT_SIG_N | T1_LUT_SGN_N)) == (T1_LUT_SIG_N | T1_LUT_SGN_N)) + ((f & (T1_LUT_SIG_S | T1_LUT_SGN_S)) == (T1_LUT_SIG_S | T1_LUT_SGN_S)), 1); if (hc < 0) { hc = -hc; vc = -vc; } if (!hc) { if (vc == -1) n = 1; else if (!vc) n = 0; else n = 1; } else if (hc == 1) { if (vc == -1) n = 2; else if (!vc) n = 3; else n = 4; } return (T1_CTXNO_SC + n); }