Skip to content

Commit

Permalink
Fix incorrect propagation of a COC parameter (DWT transform)
Browse files Browse the repository at this point in the history
  • Loading branch information
osamu620 committed Jul 29, 2020
1 parent 50555b4 commit e45a7fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/libjasper/jpc/jpc_dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,10 @@ static int jpc_dec_tileinit(jpc_dec_t *dec, jpc_dec_tile_t *tile)
dec->numcomps; ++compno, ++tcomp, ++cmpt) {
ccp = &tile->cp->ccps[compno];
if (ccp->qmfbid == JPC_COX_INS) {
tcomp->coc_transformation = 0;
tile->realmode = 1;
} else {
tcomp->coc_transformation = 1;
}
tcomp->numrlvls = ccp->numrlvls;
if (!(tcomp->rlvls = jas_alloc2(tcomp->numrlvls,
Expand Down Expand Up @@ -1123,7 +1126,7 @@ static int jpc_dec_tiledecode(jpc_dec_t *dec, jpc_dec_tile_t *tile)
}
jpc_undo_roi(band->data, band->roishift, ccp->roishift -
band->roishift, band->numbps);
if (tile->realmode) {
if (tcomp->coc_transformation == 0) {
jas_matrix_asl(band->data, JPC_FIX_FRACBITS);
jpc_dequantize(band->data, band->absstepsize);
}
Expand Down Expand Up @@ -1169,9 +1172,9 @@ static int jpc_dec_tiledecode(jpc_dec_t *dec, jpc_dec_tile_t *tile)
}

/* Perform rounding and convert to integer values. */
if (tile->realmode) {
for (compno = 0, tcomp = tile->tcomps; compno < dec->numcomps;
for (compno = 0, tcomp = tile->tcomps; compno < dec->numcomps;
++compno, ++tcomp) {
if (tcomp->coc_transformation == 0) {
for (jas_matind_t i = 0; i < jas_matrix_numrows(tcomp->data); ++i) {
for (jas_matind_t j = 0; j < jas_matrix_numcols(tcomp->data); ++j) {
v = jas_matrix_get(tcomp->data, i, j);
Expand Down
3 changes: 3 additions & 0 deletions src/libjasper/jpc/jpc_dec.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,9 @@ typedef struct {
/* The TSFB. */
jpc_tsfb_t *tsfb;

/* COC param of transformation for each component */
int coc_transformation;

This comment has been minimized.

Copy link
@MaxKellermann

MaxKellermann Jul 29, 2020

Contributor

What does this mean, what are legal values and why is this variable signed?

The rest of this commit looks like only 0 and 1 are allowed - should this be a bool?

This comment has been minimized.

Copy link
@osamu620

osamu620 Jul 30, 2020

Author Contributor

I found that this newly introduced parameter is just a copy of ccp->qmfbid which is uint_fast8_t. It is not signed (My bad.) I'll modify the code, then we should see much concise shape.

The JPEG 2000 standard has its extension as Part 2. Currently, JasPer supports only Part 1 (core coding system). Little number of JPEG 2000 software packages support Part 2, however, this value may be greater than 1 in Part 2. Although I don't think JasPer needs to support Part 2 functionalities, we should let this value be uint_fast8_t for future development by this community.

This comment has been minimized.

Copy link
@MaxKellermann

MaxKellermann Jul 30, 2020

Contributor

When you find out about such things, it would be very helpful to submit another commit adding a comment with the explanation. This will help the next guy save the time while understanding the code. Any explanatory comments you add to the source code will be very valuable. You know much more about the standard than I do (nearly nothing).


} jpc_dec_tcomp_t;

/*
Expand Down

0 comments on commit e45a7fe

Please sign in to comment.