+ if (!opj_tcd_is_subband_area_of_interest(tcd,
+ tilec->compno,
+ resno,
+ band->bandno,
+ (OPJ_UINT32)cblk->x0,
+ (OPJ_UINT32)cblk->y0,
+ (OPJ_UINT32)cblk->x1,
+ (OPJ_UINT32)cblk->y1)) {
+ if (cblk->decoded_data) {
+#ifdef DEBUG_VERBOSE
+ printf("Discarding codeblock %d,%d at resno=%d, bandno=%d\n",
+ cblk->x0, cblk->y0, resno, bandno);
+#endif
+ opj_free(cblk->decoded_data);
+ cblk->decoded_data = NULL;
+ }
+ continue;
+ }
+
+ if (!tcd->whole_tile_decoding) {
+ OPJ_UINT32 cblk_w = (OPJ_UINT32)(cblk->x1 - cblk->x0);
+ OPJ_UINT32 cblk_h = (OPJ_UINT32)(cblk->y1 - cblk->y0);
+ if (cblk->decoded_data != NULL) {
+#ifdef DEBUG_VERBOSE
+ printf("Reusing codeblock %d,%d at resno=%d, bandno=%d\n",
+ cblk->x0, cblk->y0, resno, bandno);
+#endif
+ continue;
+ }
+ if (cblk_w == 0 || cblk_h == 0) {
+ continue;
+ }
+#ifdef DEBUG_VERBOSE
+ printf("Decoding codeblock %d,%d at resno=%d, bandno=%d\n",
+ cblk->x0, cblk->y0, resno, bandno);
+#endif
+ /* Zero-init required */
+ cblk->decoded_data = opj_calloc(1, cblk_w * cblk_h * sizeof(OPJ_INT32));
+ if (cblk->decoded_data == NULL) {
+ if (p_manager_mutex) {
+ opj_mutex_lock(p_manager_mutex);
+ }
+ opj_event_msg(p_manager, EVT_ERROR,
+ "Cannot allocate cblk->decoded_data\n");
+ if (p_manager_mutex) {
+ opj_mutex_unlock(p_manager_mutex);
+ }
+ *pret = OPJ_FALSE;
+ return;
+ }
+ } else if (cblk->decoded_data) {
+ /* Not sure if that code path can happen, but better be */
+ /* safe than sorry */
+ opj_free(cblk->decoded_data);
+ cblk->decoded_data = NULL;
+ }
+