summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>2007-03-28 08:44:21 +0000
committerFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>2007-03-28 08:44:21 +0000
commit5a3c1ffe7d5b4269d073fa826cba94591c0c3ed5 (patch)
tree6f32d96511d0b8dd161a4e88767aa9efceadbb8a
parent144e1ff4e6b2105c3ab5023d90a487509ee3bc02 (diff)
Fixed an historical bug in t1.c that leaded to the inclusion of useless 0xFF in the codestream. Thanks to Sylvain, Pascal and Parvatha !
-rw-r--r--ChangeLog3
-rw-r--r--libopenjpeg/t1.c13
2 files changed, 15 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index e92da0bd..1980d550 100644
--- 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)
diff --git a/libopenjpeg/t1.c b/libopenjpeg/t1.c
index da93834a..85e5bbcf 100644
--- a/libopenjpeg/t1.c
+++ b/libopenjpeg/t1.c
@@ -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 */
}
+