test_decode_area: fix to make it work with odd image dimensions

This commit is contained in:
Even Rouault 2017-08-18 12:30:11 +02:00
parent 5d12806091
commit 028c504a43
1 changed files with 17 additions and 15 deletions

View File

@ -367,24 +367,26 @@ int main(int argc, char** argv)
da_y0 = (OPJ_INT32)opj_uint_min(l_image->y1, (OPJ_UINT32)da_y0 + 1); da_y0 = (OPJ_INT32)opj_uint_min(l_image->y1, (OPJ_UINT32)da_y0 + 1);
da_y1 = (OPJ_INT32)opj_uint_min(l_image->y1, (OPJ_UINT32)da_y1 + 1); da_y1 = (OPJ_INT32)opj_uint_min(l_image->y1, (OPJ_UINT32)da_y1 + 1);
} }
l_sub_image = decode(quiet, input_file, da_x0, da_y0, da_x1, da_y1, if (da_x0 < (OPJ_INT32)l_image->x1 && da_y0 < (OPJ_INT32)l_image->y1) {
NULL, NULL, NULL, NULL); l_sub_image = decode(quiet, input_file, da_x0, da_y0, da_x1, da_y1,
if (!l_sub_image) { NULL, NULL, NULL, NULL);
fprintf(stderr, "decode failed for %d,%d,%d,%d\n", if (!l_sub_image) {
da_x0, da_y0, da_x1, da_y1); fprintf(stderr, "decode failed for %d,%d,%d,%d\n",
opj_image_destroy(l_sub_image); da_x0, da_y0, da_x1, da_y1);
opj_image_destroy(l_image); opj_image_destroy(l_sub_image);
return 1; opj_image_destroy(l_image);
} return 1;
}
if (!check_consistency(l_image, l_sub_image)) { if (!check_consistency(l_image, l_sub_image)) {
fprintf(stderr, "Consistency checked failed for %d,%d,%d,%d\n", fprintf(stderr, "Consistency checked failed for %d,%d,%d,%d\n",
da_x0, da_y0, da_x1, da_y1); da_x0, da_y0, da_x1, da_y1);
opj_image_destroy(l_sub_image);
opj_image_destroy(l_image);
return 1;
}
opj_image_destroy(l_sub_image); opj_image_destroy(l_sub_image);
opj_image_destroy(l_image);
return 1;
} }
opj_image_destroy(l_sub_image);
} }
} }
} }