From 07be749bf2a8a1ae27f31b24b2eb132f5537b665 Mon Sep 17 00:00:00 2001 From: Francois-Olivier Devaux Date: Tue, 21 Aug 2007 12:51:57 +0000 Subject: [PATCH] Moved the orient flipping into the ctxno_zc table. Thanks to Callum Lerwick who provided all these great patches ! --- ChangeLog | 1 + libopenjpeg/t1.c | 21 ++++----------------- libopenjpeg/t1_generate_luts.c | 8 +++++++- libopenjpeg/t1_luts.h | 16 ++++++++-------- 4 files changed, 20 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 23aa3d9f..d3e9760b 100644 --- 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 diff --git a/libopenjpeg/t1.c b/libopenjpeg/t1.c index 4341df8b..716f6b45 100644 --- a/libopenjpeg/t1.c +++ b/libopenjpeg/t1.c @@ -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); diff --git a/libopenjpeg/t1_generate_luts.c b/libopenjpeg/t1_generate_luts.c index af298133..1925b951 100644 --- a/libopenjpeg/t1_generate_luts.c +++ b/libopenjpeg/t1_generate_luts.c @@ -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); } } diff --git a/libopenjpeg/t1_luts.h b/libopenjpeg/t1_luts.h index 8aa88f7a..e5e33f66 100644 --- a/libopenjpeg/t1_luts.h +++ b/libopenjpeg/t1_luts.h @@ -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, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 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