Consolidated some calls to mqc_setcurctx. Cleaned up t1_generate_luts to output the proper types.

This commit is contained in:
Francois-Olivier Devaux 2007-08-21 12:36:05 +00:00
parent d4d23c7eb5
commit 1cfbdcc9ce
4 changed files with 15 additions and 17 deletions

View File

@ -14,6 +14,8 @@ August 21, 2007
* [Callum Lerwick] Memory leaks fixed * [Callum Lerwick] Memory leaks fixed
* [Callum Lerwick] Reworks of t1_updateflags to get rid of the shift operation * [Callum Lerwick] Reworks of t1_updateflags to get rid of the shift operation
* [Callum Lerwick] mqc_setcurctx moved to the header to allow it to be inlined into the t1. * [Callum Lerwick] mqc_setcurctx moved to the header to allow it to be inlined into the t1.
* [Callum Lerwick] Consolidated some calls to mqc_setcurctx.
* [Callum Lerwick] Cleaned up t1_generate_luts to output the proper types.
August 20, 2007 August 20, 2007
+ [FOD] Added support for the TGA file format in the codec + [FOD] Added support for the TGA file format in the codec

View File

@ -3,7 +3,7 @@
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8,00" Version="8,00"
Name="LibOpenJPEG" Name="LibOpenJPEG"
ProjectGUID="{4F27AA53-4181-4A1A-8238-3931B0A41048}" ProjectGUID="{BDB8C37B-824E-4617-827C-B13E2F015EFE}"
> >
<Platforms> <Platforms>
<Platform <Platform

View File

@ -298,21 +298,19 @@ static void t1_enc_sigpass_step(
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp); flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) { if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
v = int_abs(*datap) & one ? 1 : 0; v = int_abs(*datap) & one ? 1 : 0;
mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient)); /* ESSAI */
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */ if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient)); /* ESSAI */
mqc_bypass_enc(mqc, v); mqc_bypass_enc(mqc, v);
} else { } else {
mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient));
mqc_encode(mqc, v); mqc_encode(mqc, v);
} }
if (v) { if (v) {
v = *datap < 0 ? 1 : 0; v = *datap < 0 ? 1 : 0;
*nmsedec += t1_getnmsedec_sig(int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS); *nmsedec += t1_getnmsedec_sig(int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
mqc_setcurctx(mqc, t1_getctxno_sc(flag)); /* ESSAI */
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */ if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
mqc_setcurctx(mqc, t1_getctxno_sc(flag)); /* ESSAI */
mqc_bypass_enc(mqc, v); mqc_bypass_enc(mqc, v);
} else { } else {
mqc_setcurctx(mqc, t1_getctxno_sc(flag));
mqc_encode(mqc, v ^ t1_getspb(flag)); mqc_encode(mqc, v ^ t1_getspb(flag));
} }
t1_updateflags(flagsp, v, t1->flags_stride); t1_updateflags(flagsp, v, t1->flags_stride);
@ -432,11 +430,10 @@ static void t1_enc_refpass_step(
if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) { if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
*nmsedec += t1_getnmsedec_ref(int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS); *nmsedec += t1_getnmsedec_ref(int_abs(*datap), bpno + T1_NMSEDEC_FRACBITS);
v = int_abs(*datap) & one ? 1 : 0; v = int_abs(*datap) & one ? 1 : 0;
mqc_setcurctx(mqc, t1_getctxno_mag(flag)); /* ESSAI */
if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */ if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */
mqc_setcurctx(mqc, t1_getctxno_mag(flag)); /* ESSAI */
mqc_bypass_enc(mqc, v); mqc_bypass_enc(mqc, v);
} else { } else {
mqc_setcurctx(mqc, t1_getctxno_mag(flag));
mqc_encode(mqc, v); mqc_encode(mqc, v);
} }
*flagsp |= T1_REFINE; *flagsp |= T1_REFINE;
@ -459,11 +456,10 @@ static void t1_dec_refpass_step(
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp); flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) { if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) {
mqc_setcurctx(mqc, t1_getctxno_mag(flag)); /* ESSAI */
if (type == T1_TYPE_RAW) { if (type == T1_TYPE_RAW) {
mqc_setcurctx(mqc, t1_getctxno_mag(flag)); /* ESSAI */
v = raw_decode(raw); v = raw_decode(raw);
} else { } else {
mqc_setcurctx(mqc, t1_getctxno_mag(flag));
v = mqc_decode(mqc); v = mqc_decode(mqc);
} }
t = v ? poshalf : neghalf; t = v ? poshalf : neghalf;

View File

@ -212,7 +212,7 @@ int main(){
} }
} }
printf("static int8_t lut_ctxno_zc[1024] = {\n "); printf("static char lut_ctxno_zc[1024] = {\n ");
for (i = 0; i < 1023; ++i) { for (i = 0; i < 1023; ++i) {
printf("%i, ", lut_ctxno_zc[i]); printf("%i, ", lut_ctxno_zc[i]);
if(!((i+1)&0x1f)) if(!((i+1)&0x1f))
@ -221,7 +221,7 @@ int main(){
printf("%i\n};\n\n", lut_ctxno_zc[1023]); printf("%i\n};\n\n", lut_ctxno_zc[1023]);
// lut_ctxno_sc // lut_ctxno_sc
printf("static int8_t lut_ctxno_sc[256] = {\n "); printf("static char lut_ctxno_sc[256] = {\n ");
for (i = 0; i < 255; ++i) { for (i = 0; i < 255; ++i) {
printf("0x%x, ", t1_init_ctxno_sc(i << 4)); printf("0x%x, ", t1_init_ctxno_sc(i << 4));
if(!((i+1)&0xf)) if(!((i+1)&0xf))
@ -236,7 +236,7 @@ int main(){
} }
} }
printf("static int8_t lut_ctxno_mag[4096] = {\n "); printf("static char lut_ctxno_mag[4096] = {\n ");
for (i = 0; i < 4095; ++i) { for (i = 0; i < 4095; ++i) {
printf("%i, ", lut_ctxno_mag[i]); printf("%i, ", lut_ctxno_mag[i]);
if(!((i+1)&0xf)) if(!((i+1)&0xf))
@ -245,7 +245,7 @@ int main(){
printf("%i\n};\n\n", lut_ctxno_mag[4095]); printf("%i\n};\n\n", lut_ctxno_mag[4095]);
// lut_spb // lut_spb
printf("static int8_t lut_spb[256] = {\n "); printf("static char lut_spb[256] = {\n ");
for (i = 0; i < 255; ++i) { for (i = 0; i < 255; ++i) {
printf("%i, ", t1_init_spb(i << 4)); printf("%i, ", t1_init_spb(i << 4));
if(!((i+1)&0x1f)) if(!((i+1)&0x1f))
@ -279,16 +279,16 @@ int main(){
(int) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0)); (int) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
} }
printf("static int16_t lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {\n "); printf("static short lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {\n ");
dump_array16(&lut_nmsedec_sig, 1 << T1_NMSEDEC_BITS); dump_array16(&lut_nmsedec_sig, 1 << T1_NMSEDEC_BITS);
printf("static int16_t lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {\n "); printf("static short lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {\n ");
dump_array16(&lut_nmsedec_sig0, 1 << T1_NMSEDEC_BITS); dump_array16(&lut_nmsedec_sig0, 1 << T1_NMSEDEC_BITS);
printf("static int16_t lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {\n "); printf("static short lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {\n ");
dump_array16(&lut_nmsedec_ref, 1 << T1_NMSEDEC_BITS); dump_array16(&lut_nmsedec_ref, 1 << T1_NMSEDEC_BITS);
printf("static int16_t lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {\n "); printf("static short lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {\n ");
dump_array16(&lut_nmsedec_ref0, 1 << T1_NMSEDEC_BITS); dump_array16(&lut_nmsedec_ref0, 1 << T1_NMSEDEC_BITS);
return 0; return 0;