diff options
| author | Antonin Descampe <antonin@gmail.com> | 2005-10-27 07:49:29 +0000 |
|---|---|---|
| committer | Antonin Descampe <antonin@gmail.com> | 2005-10-27 07:49:29 +0000 |
| commit | 7ee36c3a4c37d9c8cee30ac19fd5532a3863285b (patch) | |
| tree | 77a7f1ec3e1b356a3ac4f2cb666e21af37a70728 /codec | |
| parent | 7f8f47566fc1e98ce1aad3ff1a1621bf8b454527 (diff) | |
1) quantization stepsizes stored as float instead of shifted integers -> fixes a pb of precision when using very small stepsizes. 2) bug fixed when decoding until bitplane 0 -> r-value (1/2) added to the coefficient.
Diffstat (limited to 'codec')
| -rw-r--r-- | codec/image_to_j2k.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/codec/image_to_j2k.c b/codec/image_to_j2k.c index 9be55998..b73941fa 100644 --- a/codec/image_to_j2k.c +++ b/codec/image_to_j2k.c @@ -250,12 +250,13 @@ int floorlog2(int a) return l; } -void encode_stepsize(int stepsize, int numbps, int *expn, int *mant) +void encode_stepsize(float stepsize, int numbps, int *expn, int *mant) { - int p, n; - p = floorlog2(stepsize) - 13; - n = 11 - floorlog2(stepsize); - *mant = (n < 0 ? stepsize >> -n : stepsize << n) & 0x7ff; + int p, n, stepsizeTMP; + stepsizeTMP=(int) floor(stepsize * 8192.0); + p = floorlog2(stepsizeTMP) - 13; + n = 11 - floorlog2(stepsizeTMP); + *mant = (n < 0 ? stepsizeTMP >> -n : stepsizeTMP << n) & 0x7ff; *expn = numbps - p; } @@ -264,7 +265,7 @@ void calc_explicit_stepsizes(j2k_tccp_t * tccp, int prec) int numbands, bandno; numbands = 3 * tccp->numresolutions - 2; for (bandno = 0; bandno < numbands; bandno++) { - double stepsize; + float stepsize; int resno, level, orient, gain; resno = bandno == 0 ? 0 : (bandno - 1) / 3 + 1; @@ -280,7 +281,7 @@ void calc_explicit_stepsizes(j2k_tccp_t * tccp, int prec) double norm = dwt_norms_97[orient][level]; stepsize = (1 << (gain + 1)) / norm; } - encode_stepsize((int) floor(stepsize * 8192.0), prec + gain, + encode_stepsize(stepsize, prec + gain, &tccp->stepsizes[bandno].expn, &tccp->stepsizes[bandno].mant); } |
