Const'ify lut arrays so they are in the read-only data section

This commit is contained in:
Even Rouault 2016-05-22 00:54:06 +02:00
parent ba1edf6cd4
commit 31882ad7f4
2 changed files with 14 additions and 14 deletions

View File

@ -216,7 +216,7 @@ int main(int argc, char **argv)
} }
} }
printf("static OPJ_BYTE lut_ctxno_zc[1024] = {\n "); printf("static const OPJ_BYTE 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))
@ -225,7 +225,7 @@ int main(int argc, char **argv)
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 OPJ_BYTE lut_ctxno_sc[256] = {\n "); printf("static const OPJ_BYTE 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))
@ -234,7 +234,7 @@ int main(int argc, char **argv)
printf("0x%x\n};\n\n", t1_init_ctxno_sc(255 << 4)); printf("0x%x\n};\n\n", t1_init_ctxno_sc(255 << 4));
/* lut_spb */ /* lut_spb */
printf("static OPJ_BYTE lut_spb[256] = {\n "); printf("static const OPJ_BYTE 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))
@ -268,16 +268,16 @@ int main(int argc, char **argv)
(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 OPJ_INT16 lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {\n "); printf("static const OPJ_INT16 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 OPJ_INT16 lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {\n "); printf("static const OPJ_INT16 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 OPJ_INT16 lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {\n "); printf("static const OPJ_INT16 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 OPJ_INT16 lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {\n "); printf("static const OPJ_INT16 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;

View File

@ -1,6 +1,6 @@
/* This file was automatically generated by t1_generate_luts.c */ /* This file was automatically generated by t1_generate_luts.c */
static OPJ_BYTE lut_ctxno_zc[1024] = { static const OPJ_BYTE 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, 0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 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E lut_spb[256] = {
0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
}; };
static OPJ_INT16 lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = { static const OPJ_INT16 lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@ -84,7 +84,7 @@ static OPJ_INT16 lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {
0x6c00, 0x6d80, 0x6f00, 0x7080, 0x7200, 0x7380, 0x7500, 0x7680 0x6c00, 0x6d80, 0x6f00, 0x7080, 0x7200, 0x7380, 0x7500, 0x7680
}; };
static OPJ_INT16 lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = { static const OPJ_INT16 lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0080, 0x0080, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0080, 0x0080,
0x0080, 0x0080, 0x0100, 0x0100, 0x0100, 0x0180, 0x0180, 0x0200, 0x0080, 0x0080, 0x0100, 0x0100, 0x0100, 0x0180, 0x0180, 0x0200,
0x0200, 0x0280, 0x0280, 0x0300, 0x0300, 0x0380, 0x0400, 0x0400, 0x0200, 0x0280, 0x0280, 0x0300, 0x0300, 0x0380, 0x0400, 0x0400,
@ -103,7 +103,7 @@ static OPJ_INT16 lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {
0x7080, 0x7280, 0x7480, 0x7600, 0x7800, 0x7a00, 0x7c00, 0x7e00 0x7080, 0x7280, 0x7480, 0x7600, 0x7800, 0x7a00, 0x7c00, 0x7e00
}; };
static OPJ_INT16 lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = { static const OPJ_INT16 lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {
0x1800, 0x1780, 0x1700, 0x1680, 0x1600, 0x1580, 0x1500, 0x1480, 0x1800, 0x1780, 0x1700, 0x1680, 0x1600, 0x1580, 0x1500, 0x1480,
0x1400, 0x1380, 0x1300, 0x1280, 0x1200, 0x1180, 0x1100, 0x1080, 0x1400, 0x1380, 0x1300, 0x1280, 0x1200, 0x1180, 0x1100, 0x1080,
0x1000, 0x0f80, 0x0f00, 0x0e80, 0x0e00, 0x0d80, 0x0d00, 0x0c80, 0x1000, 0x0f80, 0x0f00, 0x0e80, 0x0e00, 0x0d80, 0x0d00, 0x0c80,
@ -122,7 +122,7 @@ static OPJ_INT16 lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {
0x1400, 0x1480, 0x1500, 0x1580, 0x1600, 0x1680, 0x1700, 0x1780 0x1400, 0x1480, 0x1500, 0x1580, 0x1600, 0x1680, 0x1700, 0x1780
}; };
static OPJ_INT16 lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = { static const OPJ_INT16 lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {
0x2000, 0x1f00, 0x1e00, 0x1d00, 0x1c00, 0x1b00, 0x1a80, 0x1980, 0x2000, 0x1f00, 0x1e00, 0x1d00, 0x1c00, 0x1b00, 0x1a80, 0x1980,
0x1880, 0x1780, 0x1700, 0x1600, 0x1500, 0x1480, 0x1380, 0x1300, 0x1880, 0x1780, 0x1700, 0x1600, 0x1500, 0x1480, 0x1380, 0x1300,
0x1200, 0x1180, 0x1080, 0x1000, 0x0f00, 0x0e80, 0x0e00, 0x0d00, 0x1200, 0x1180, 0x1080, 0x1000, 0x0f00, 0x0e80, 0x0e00, 0x0d00,