[1.5] This fixes issues seen on PDF files

Fixes issue 156
This commit is contained in:
Mathieu Malaterre 2012-07-11 14:54:48 +00:00
parent abce31e706
commit 8b5f815925
2 changed files with 17 additions and 6 deletions

View File

@ -1602,7 +1602,7 @@ static void j2k_write_eoc(opj_j2k_t *j2k) {
static void j2k_read_eoc(opj_j2k_t *j2k) { static void j2k_read_eoc(opj_j2k_t *j2k) {
int i, tileno; int i, tileno;
opj_bool success; opj_bool success = false;
/* if packets should be decoded */ /* if packets should be decoded */
if (j2k->cp->limit_decoding != DECODE_ALL_BUT_PACKETS) { if (j2k->cp->limit_decoding != DECODE_ALL_BUT_PACKETS) {
@ -1610,11 +1610,16 @@ static void j2k_read_eoc(opj_j2k_t *j2k) {
tcd_malloc_decode(tcd, j2k->image, j2k->cp); tcd_malloc_decode(tcd, j2k->image, j2k->cp);
for (i = 0; i < j2k->cp->tileno_size; i++) { for (i = 0; i < j2k->cp->tileno_size; i++) {
tcd_malloc_decode_tile(tcd, j2k->image, j2k->cp, i, j2k->cstr_info); tcd_malloc_decode_tile(tcd, j2k->image, j2k->cp, i, j2k->cstr_info);
if (j2k->cp->tileno[i] != -1)
{
tileno = j2k->cp->tileno[i]; tileno = j2k->cp->tileno[i];
success = tcd_decode_tile(tcd, j2k->tile_data[tileno], j2k->tile_len[tileno], tileno, j2k->cstr_info); success = tcd_decode_tile(tcd, j2k->tile_data[tileno], j2k->tile_len[tileno], tileno, j2k->cstr_info);
opj_free(j2k->tile_data[tileno]); opj_free(j2k->tile_data[tileno]);
j2k->tile_data[tileno] = NULL; j2k->tile_data[tileno] = NULL;
tcd_free_decode_tile(tcd, i); tcd_free_decode_tile(tcd, i);
}
else
success = false;
if (success == OPJ_FALSE) { if (success == OPJ_FALSE) {
j2k->state |= J2K_STATE_ERR; j2k->state |= J2K_STATE_ERR;
break; break;

View File

@ -695,6 +695,12 @@ void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp,
opj_tccp_t *tccp = &tcp->tccps[compno]; opj_tccp_t *tccp = &tcp->tccps[compno];
opj_tcd_tilecomp_t *tilec = &tile->comps[compno]; opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
if (tccp->numresolutions <= 0)
{
cp->tileno[tileno] = -1;
return;
}
/* border of each tile component (global) */ /* border of each tile component (global) */
tilec->x0 = int_ceildiv(tile->x0, image->comps[compno].dx); tilec->x0 = int_ceildiv(tile->x0, image->comps[compno].dx);
tilec->y0 = int_ceildiv(tile->y0, image->comps[compno].dy); tilec->y0 = int_ceildiv(tile->y0, image->comps[compno].dy);