Skip to content

Commit

Permalink
Dequantization using the mid-point reconstruction
Browse files Browse the repository at this point in the history
Why: In the JPEG 2000 spec, the reconstruction parameter is introduced in the Annex E (Quantization). This reconstruction parameter can be arbitrarily chosen by the decoder, however, it is important to produce the best visual or objective quality for reconstruction. Generally, values for this parameter fall in the range [0, 1) and a common value is 0.5.
How: Added new variable as the reconstruction parameter in jpc_dequantize() and set the value to 0.5.
  • Loading branch information
osamu620 committed Jul 30, 2020
1 parent 36211a1 commit bcfab02
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/libjasper/jpc/jpc_dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1948,6 +1948,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 @@ -1957,9 +1960,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

0 comments on commit bcfab02

Please sign in to comment.