+
+ /* ----- */
+ /* Check if the positions provided by the user are correct */
+
+ /* Left */
+ if (p_start_x > 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);
+ return OPJ_FALSE;
+ }
+ else if (p_start_x < l_cp->tx0){
+ opj_event_msg_v2(p_manager, EVT_WARNING,
+ "Left position of the decoded area (ROI_x0=%d) is outside the tile area (XTOsiz=%d).\n",
+ p_start_x, l_cp->tx0);
+ p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0;
+ }
+ else
+ 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){
+ 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);
+ return OPJ_FALSE;
+ }
+ else if (p_start_y < l_cp->ty0){
+ opj_event_msg_v2(p_manager, EVT_WARNING,
+ "Up position of the decoded area (ROI_y0=%d) is outside the tile area (YTOsiz=%d).\n",
+ p_start_y, l_cp->ty0);
+ p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0;
+ }
+ else
+ p_j2k->m_specific_param.m_decoder.m_start_tile_y = (p_start_y - l_cp->ty0) / l_cp->tdy;
+
+ /* Right */
+ if (p_end_x < l_cp->tx0) {
+ opj_event_msg_v2(p_manager, EVT_ERROR,
+ "Right position of the decoded area (ROI_x1=%d) is outside the tile area (XTOsiz=%d).\n",
+ p_end_x, l_cp->tx0);
+ return OPJ_FALSE;
+ }
+ else if (p_end_x > 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);
+ p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw; // FIXME (-1) ???
+ }
+ else
+ p_j2k->m_specific_param.m_decoder.m_end_tile_x = int_ceildiv((p_end_x - l_cp->tx0), l_cp->tdx);
+
+ /* Bottom */
+ if (p_end_x < l_cp->ty0) {
+ opj_event_msg_v2(p_manager, EVT_ERROR,
+ "Right position of the decoded area (ROI_y1=%d) is outside the tile area (YTOsiz=%d).\n",
+ p_end_x, l_cp->ty0);
+ return OPJ_FALSE;
+ }
+ if (p_end_y > 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);
+ p_j2k->m_specific_param.m_decoder.m_start_tile_y = l_cp->th; // FIXME (-1) ???
+ }
+ else
+ p_j2k->m_specific_param.m_decoder.m_end_tile_y = int_ceildiv((p_end_y - l_cp->ty0), l_cp->tdy);
+ /* ----- */
+