Skip to content

Commit

Permalink
Merge branch 'hotfix1-2.0.19' of git://github.com/osamu620/jasper
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Aug 1, 2020
2 parents e4fca80 + 55562ce commit 80fd248
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.0.19 (not yet released)
=========================

* fixed several ISO/IEC 15444-4 conformance bugs

2.0.19 (2020-07-11)
===================

Expand Down
23 changes: 16 additions & 7 deletions src/libjasper/jpc/jpc_dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,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 (ccp->qmfbid == JPC_COX_INS) {
jas_matrix_asl(band->data, JPC_FIX_FRACBITS);
jpc_dequantize(band->data, band->absstepsize);
}
Expand Down Expand Up @@ -1169,9 +1169,10 @@ 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) {
ccp = &tile->cp->ccps[compno];
if (ccp->qmfbid == JPC_COX_INS) {
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 Expand Up @@ -1231,7 +1232,8 @@ static int jpc_dec_process_eoc(jpc_dec_t *dec, jpc_ms_t *ms)

for (tileno = 0, tile = dec->tiles; tileno < dec->numtiles; ++tileno,
++tile) {
if (tile->state == JPC_TILE_ACTIVE) {
if (tile->state == JPC_TILE_ACTIVE ||
tile->state == JPC_TILE_ACTIVELAST) {
if (jpc_dec_tiledecode(dec, tile)) {
return -1;
}
Expand Down Expand Up @@ -1751,14 +1753,18 @@ static int calcstepsizes(uint_fast16_t refstepsize, int numrlvls,
{
int bandno;
int numbands;
int r;
int nb;
uint_fast16_t expn;
uint_fast16_t mant;
expn = JPC_QCX_GETEXPN(refstepsize);
mant = JPC_QCX_GETMANT(refstepsize);
numbands = 3 * numrlvls - 2;
for (bandno = 0; bandno < numbands; ++bandno) {
//jas_eprintf("DEBUG %d %d %d %d %d\n", bandno, expn, numrlvls, bandno, ((numrlvls - 1) - (numrlvls - 1 - ((bandno > 0) ? ((bandno + 2) / 3) : (0)))));
uint_fast16_t e = expn + (bandno + 2) / 3;
r = (bandno + 2) / 3;
nb = (r == 0) ? (numrlvls - 1) - r : (numrlvls - 1) - r + 1;
uint_fast16_t e = expn - (numrlvls - 1) + nb;
if (e >= 0x20)
return -1;
stepsizes[bandno] = JPC_QCX_MANT(mant) | JPC_QCX_EXPN(e);
Expand Down Expand Up @@ -1940,6 +1946,9 @@ static jpc_fix_t jpc_calcabsstepsize(int stepsize, int numbits)

static void jpc_dequantize(jas_matrix_t *x, jpc_fix_t absstepsize)
{
// a reconstruction parameter defined in E 1.1.2 of the ISO/IEC 15444-1
jpc_fix_t recparam = JPC_FIX_HALF;

assert(absstepsize >= 0);
if (absstepsize == jpc_inttofix(1)) {
return;
Expand All @@ -1949,9 +1958,9 @@ static void jpc_dequantize(jas_matrix_t *x, jpc_fix_t absstepsize)
for (jas_matind_t j = 0; j < jas_matrix_numcols(x); ++j) {
jas_seqent_t t = jas_matrix_get(x, i, j);
if (t) {
// mid-point reconstruction
t = (t > 0) ? jpc_fix_add(t, recparam) : jpc_fix_sub(t, recparam);
t = jpc_fix_mul(t, absstepsize);
} else {
t = 0;
}
jas_matrix_set(x, i, j, t);
}
Expand Down
4 changes: 2 additions & 2 deletions src/libjasper/jpc/jpc_t2cod.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ static int jpc_pi_nextrpcl(register jpc_pi_t *pi)
try0 = JPC_CEILDIV(pi->ystart, pi->picomp->vsamp << r);
if (((pi->x == pi->xstart &&
((trx0 << r) % (JAS_CAST(uint_fast32_t, 1) << rpx)))
|| !(pi->x % (JAS_CAST(uint_fast32_t, 1) << rpx))) &&
|| !(pi->x % (pi->picomp->hsamp << rpx))) &&
((pi->y == pi->ystart &&
((try0 << r) % (JAS_CAST(uint_fast32_t, 1) << rpy)))
|| !(pi->y % (JAS_CAST(uint_fast32_t, 1) << rpy)))) {
|| !(pi->y % (pi->picomp->vsamp << rpy)))) {
prchind = JPC_FLOORDIVPOW2(JPC_CEILDIV(pi->x,
pi->picomp->hsamp << r), pi->pirlvl->prcwidthexpn) -
JPC_FLOORDIVPOW2(trx0, pi->pirlvl->prcwidthexpn);
Expand Down

0 comments on commit 80fd248

Please sign in to comment.