Corrected allocation to take into account the EOC marker
authorFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>
Tue, 21 Aug 2007 09:06:13 +0000 (09:06 +0000)
committerFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>
Tue, 21 Aug 2007 09:06:13 +0000 (09:06 +0000)
libopenjpeg/tcd.c

index 003d521e90c06b3d0642da58ae0871c7f30786c1..4c9f0c937946fa3f92243e81b64685671eb63ad6 100644 (file)
@@ -172,6 +172,10 @@ void tcd_malloc_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int c
                                        if (!j && tcp->rates[j] < 30)
                                                tcp->rates[j] = 30;
                                }
+                               
+                               if(j == (tcp->numlayers-1)){
+                                       tcp->rates[j] = tcp->rates[j]- 2;
+                               }
                        }
                }
                /* << Modification of the RATE */
@@ -1055,8 +1059,7 @@ bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_image_in
                double lo = min;
                double hi = max;
                int success = 0;
-               /* TODO: remove maxlen */
-               int maxlen = tcd_tcp->rates[layno] ? int_min(((int) ceil(tcd_tcp->rates[layno]- 2)), len) : len;
+               int maxlen = tcd_tcp->rates[layno] ? int_min(((int) ceil(tcd_tcp->rates[layno])), len) : len;
                double goodthresh = 0;
                double stable_thresh = 0;
                int i;
@@ -1444,3 +1447,4 @@ void tcd_free_decode_tile(opj_tcd_t *tcd, int tileno) {
 
 
 
+