]> granicus.if.org Git - openjpeg/commitdiff
Fixed an historical bug in t1.c that leaded to the inclusion of useless 0xFF in the...
authorFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>
Wed, 28 Mar 2007 08:44:21 +0000 (08:44 +0000)
committerFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>
Wed, 28 Mar 2007 08:44:21 +0000 (08:44 +0000)
ChangeLog
libopenjpeg/t1.c

index e92da0bd8e0aa215b12cf0d529d958faf13ddb60..1980d550edf39aa2b85af19cd55605cd2e505b44 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,9 @@ What's New for OpenJPEG
 ! : changed
 + : added
 
+March 28, 2007
+* [FOD] Fixed an historical bug in t1.c that leaded to the inclusion of useless 0xFF in the codestream. Thanks to Sylvain, Pascal and Parvatha !
+
 March 27, 2007
 + [GB] Improved parsing in OPJViewer, as well some minor aesthetic modifications; support for image rendering with bit depths lower than 8 bits; can display an arbitrary frame of an MJ2 file (only in B/W, though); can reload a file; better resizing capabilities
 * [GB] Following to HervĂ©'s suggestions, all the exit() calls, added by JPWL strict checking in t2.c and j2k.c, have been substituted with (object free'ing + opj_evt_message(EVT_ERROR) + return)
index da93834a7f433e191d78141533279baed27e4c94..85e5bbcf74605dde617098e7a9e879b794d8e9fb 100644 (file)
@@ -626,7 +626,6 @@ static void t1_encode_cblk(opj_t1_t *t1, opj_tcd_cblk_t * cblk, int orient, int
                
                pass->distortiondec = cumwmsedec;
                pass->rate = mqc_numbytes(mqc) + correction;    /* FIXME */
-               pass->len = pass->rate - (passno == 0 ? 0 : cblk->passes[passno - 1].rate);
                
                /* Code-switch "RESET" */
                if (cblksty & J2K_CCP_CBLKSTY_RESET)
@@ -640,6 +639,17 @@ static void t1_encode_cblk(opj_t1_t *t1, opj_tcd_cblk_t * cblk, int orient, int
                mqc_flush(mqc);
        
        cblk->totalpasses = passno;
+
+       for (passno = 0; passno<cblk->totalpasses; passno++) {
+               opj_tcd_pass_t *pass = &cblk->passes[passno];
+               if (pass->rate > mqc_numbytes(mqc))
+                       pass->rate = mqc_numbytes(mqc);
+               /*Preventing generation of FF as last data byte of a pass*/
+               if((pass->rate>1) && (cblk->data[pass->rate - 1] == 0xFF)){
+                       pass->rate--;
+               }
+               pass->len = pass->rate - (passno == 0 ? 0 : cblk->passes[passno - 1].rate);             
+       }
 }
 
 static void t1_decode_cblk(opj_t1_t *t1, opj_tcd_cblk_t * cblk, int orient, int roishift, int cblksty) {
@@ -1078,3 +1088,4 @@ void t1_decode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp) {
        } /* compno */
 }
 
+