Moved the orient flipping into the ctxno_zc table.
authorFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>
Tue, 21 Aug 2007 12:51:57 +0000 (12:51 +0000)
committerFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>
Tue, 21 Aug 2007 12:51:57 +0000 (12:51 +0000)
Thanks to Callum Lerwick who provided all these great patches !

ChangeLog
libopenjpeg/t1.c
libopenjpeg/t1_generate_luts.c
libopenjpeg/t1_luts.h

index 23aa3d9f5f5f056ea2393eb175df607959cb8daf..d3e9760b89df3c604f9b1f047e950f903bd80d55 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,7 @@ August 21, 2007
 * [Callum Lerwick] Consolidated some calls to mqc_setcurctx.
 * [Callum Lerwick] Cleaned up t1_generate_luts to output the proper types.
 * [Callum Lerwick] Replaced the large ctxno_mag lookup table with a small bit of inline-able branchless code
+* [Callum Lerwick] Moved the orient flipping into the ctxno_zc table.
 
 August 20, 2007
 + [FOD] Added support for the TGA file format in the codec
index 4341df8bd6661854697cdfc1fd9596bf75a66b6c..716f6b45bc79560795d6b39512ad50b4822ccc5c 100644 (file)
@@ -39,7 +39,7 @@
 /** @name Local static functions */
 /*@{*/
 
-static char t1_getctxno_zc(int f, int orient);
+static INLINE char t1_getctxno_zc(int f, int orient);
 static char t1_getctxno_sc(int f);
 static INLINE int t1_getctxno_mag(int f);
 static char t1_getspb(int f);
@@ -1044,7 +1044,7 @@ void t1_encode_cblks(
                                        opj_tcd_precinct_t *prc = &band->precincts[precno];
 
                                        for (cblkno = 0; cblkno < prc->cw * prc->ch; ++cblkno) {
-                                               int x, y, w, i, j, orient;
+                                               int x, y, w, i, j;
                                                opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
 
                                                x = cblk->x0 - band->x0;
@@ -1084,17 +1084,11 @@ void t1_encode_cblks(
                                                                }
                                                        }
                                                }
-                                               orient = band->bandno;  /* FIXME */
-                                               if (orient == 2) {
-                                                       orient = 1;
-                                               } else if (orient == 1) {
-                                                       orient = 2;
-                                               }
 
                                                t1_encode_cblk(
                                                                t1,
                                                                cblk,
-                                                               orient,
+                                                               band->bandno,
                                                                compno,
                                                                tilec->numresolutions - 1 - resno,
                                                                tcp->tccps[compno].qmfbid,
@@ -1133,17 +1127,10 @@ void t1_decode_cblks(
                                                int x, y, w, i, j, orient, cblk_w, cblk_h;
                                                opj_tcd_cblk_t *cblk = &prc->cblks[cblkno];
 
-                                               orient = band->bandno;  /* FIXME */
-                                               if (orient == 2) {
-                                                       orient = 1;
-                                               } else if (orient == 1) {
-                                                       orient = 2;
-                                               }
-                                               
                                                t1_decode_cblk(
                                                                t1,
                                                                cblk,
-                                                               orient,
+                                                               band->bandno,
                                                                tcp->tccps[compno].roishift,
                                                                tcp->tccps[compno].cblksty);
 
index af298133d1c530a0a4c68a468c2c5fc9646d17c3..1925b951f1beb8b252b6ad504bedd806ed1b106c 100644 (file)
@@ -197,7 +197,13 @@ int main(){
        // lut_ctxno_zc
        for (j = 0; j < 4; ++j) {
                for (i = 0; i < 256; ++i) {
-                       lut_ctxno_zc[(j << 8) | i] = t1_init_ctxno_zc(i, j);
+                       int orient = j;
+                       if (orient == 2) {
+                               orient = 1;
+                       } else if (orient == 1) {
+                               orient = 2;
+                       }
+                       lut_ctxno_zc[(orient << 8) | i] = t1_init_ctxno_zc(i, j);
                }
        }
 
index 8aa88f7a011885d7b9a1bfa5efed3708461f7982..e5e33f6656ad9bd3d6e773568cbc49ecc97c73d4 100644 (file)
@@ -1,14 +1,6 @@
 /* This file was automatically generated by t1_generate_luts.c */
 
 static char lut_ctxno_zc[1024] = {
-  0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
-  5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 
-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