fixed a bug in j2k.c (j2k_write_sod) that allowed to get negative rates, thanks zhong...
authorAntonin Descampe <antonin@gmail.com>
Thu, 22 May 2008 16:39:40 +0000 (16:39 +0000)
committerAntonin Descampe <antonin@gmail.com>
Thu, 22 May 2008 16:39:40 +0000 (16:39 +0000)
ChangeLog
libopenjpeg/j2k.c

index f7004f2fe8aae6f00219552c08c5cd72c1caaf64..92341ad50854575c7a40cebca71087a8cb67e99a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,9 @@ What's New for OpenJPEG
 ! : changed
 + : added
 
+May 22, 2008
+* [antonin] fixed a bug in j2k.c (j2k_write_sod) that allowed to get negative rates, thanks zhong1985624 for pointing this.
+
 May 22, 2008
 * [antonin] additional test to avoid crash due to invalid image size, patch by Christopher Layne
 
index bd4a1bd6bb916b70e91fa6e138b9592b3eccebc3..563efd68cc4d6dfc69a7e4d4f5acfbfdb4c817d0 100644 (file)
@@ -1438,7 +1438,11 @@ static void j2k_write_sod(opj_j2k_t *j2k, void *tile_coder) {
        
        tcp = &cp->tcps[j2k->curtileno];
        for (layno = 0; layno < tcp->numlayers; layno++) {
-               tcp->rates[layno] -= tcp->rates[layno] ? (j2k->sod_start / (cp->th * cp->tw)) : 0;
+               if (tcp->rates[layno]>(j2k->sod_start / (cp->th * cp->tw))) {
+                       tcp->rates[layno]-=(j2k->sod_start / (cp->th * cp->tw));
+               } else if (tcp->rates[layno]) {
+                       tcp->rates[layno]=1;
+               }
        }
        if(j2k->cur_tp_num == 0){
                tcd->tcd_image->tiles->packno = 0;