}
static OPJ_BOOL opj_dwt_is_whole_tile_decoding(opj_tcd_t *p_tcd,
- opj_tcd_tilecomp_t* tilec)
+ opj_tcd_tilecomp_t* tilec, OPJ_UINT32 numres)
{
opj_image_comp_t* image_comp = &(p_tcd->image->comps[tilec->compno]);
/* Compute the intersection of the area of interest, expressed in tile coordinates */
OPJ_UINT32 tcy1 = opj_uint_min(
(OPJ_UINT32)tilec->y1,
opj_uint_ceildiv(p_tcd->decoded_y1, image_comp->dy));
- return (tcx0 == (OPJ_UINT32)tilec->x0 &&
- tcy0 == (OPJ_UINT32)tilec->y0 &&
- tcx1 == (OPJ_UINT32)tilec->x1 &&
- tcy1 == (OPJ_UINT32)tilec->y1);
+
+ OPJ_UINT32 shift = tilec->numresolutions - numres;
+
+ /* Tolerate small margin within the reduced resolution factor to consider if */
+ /* the whole tile path must be taken */
+ return (tcx0 >= (OPJ_UINT32)tilec->x0 &&
+ ((tcx0 - (OPJ_UINT32)tilec->x0) >> shift) == 0 &&
+ tcy0 >= (OPJ_UINT32)tilec->y0 &&
+ ((tcy0 - (OPJ_UINT32)tilec->y0) >> shift) == 0 &&
+ tcx1 <= (OPJ_UINT32)tilec->x1 &&
+ (((OPJ_UINT32)tilec->x1 - tcx1) >> shift) == 0 &&
+ tcy1 <= (OPJ_UINT32)tilec->y1 &&
+ (((OPJ_UINT32)tilec->y1 - tcy1) >> shift) == 0);
}
/* <summary> */
OPJ_BOOL opj_dwt_decode(opj_tcd_t *p_tcd, opj_tcd_tilecomp_t* tilec,
OPJ_UINT32 numres)
{
- if (opj_dwt_is_whole_tile_decoding(p_tcd, tilec)) {
+ if (opj_dwt_is_whole_tile_decoding(p_tcd, tilec, numres)) {
return opj_dwt_decode_tile(p_tcd->thread_pool, tilec, numres);
} else {
return opj_dwt_decode_partial_tile(p_tcd, tilec, numres);
opj_tcd_tilecomp_t* OPJ_RESTRICT tilec,
OPJ_UINT32 numres)
{
- if (opj_dwt_is_whole_tile_decoding(p_tcd, tilec)) {
+ if (opj_dwt_is_whole_tile_decoding(p_tcd, tilec, numres)) {
return opj_dwt_decode_tile_97(tilec, numres);
} else {
return opj_dwt_decode_partial_97(p_tcd, tilec, numres);