int main(int argc, char **argv) { int i, j; double u, v, t; int lut_ctxno_zc[1024]; int lut_ctxno_zc_opt[2048]; int lut_nmsedec_sig[1 << T1_NMSEDEC_BITS]; int lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS]; int lut_nmsedec_ref[1 << T1_NMSEDEC_BITS]; int lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS]; (void)argc; (void)argv; printf("/* This file was automatically generated by t1_generate_luts.c */\n\n"); /* lut_ctxno_zc */ for (j = 0; j < 4; ++j) { for (i = 0; i < 256; ++i) { 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); } } printf("static uint8_t lut_ctxno_zc[1024] = {\n "); for (i = 0; i < 1023; ++i) { printf("%i, ", lut_ctxno_zc[i]); if(!((i+1)&0x1f)) printf("\n "); } printf("%i\n};\n\n", lut_ctxno_zc[1023]); /* lut_ctxno_zc_opt */ for (j = 0; j < 4; ++j) { for (i = 0; i < 512; ++i) { int orient = j; if (orient == 2) { orient = 1; } else if (orient == 1) { orient = 2; } lut_ctxno_zc_opt[(orient << 9) | i] = t1_init_ctxno_zc_opt(i, j); } } printf("static uint8_t lut_ctxno_zc_opt[2048] = {\n "); for (i = 0; i < 2047; ++i) { printf("%i, ", lut_ctxno_zc_opt[i]); if (!((i + 1) & 0x1f)) printf("\n "); } printf("%i\n};\n\n", lut_ctxno_zc_opt[2047]); /* lut_ctxno_sc */ printf("static uint8_t lut_ctxno_sc[256] = {\n "); for (i = 0; i < 255; ++i) { printf("0x%x, ", t1_init_ctxno_sc(i << 4)); if(!((i+1)&0xf)) printf("\n "); } printf("0x%x\n};\n\n", t1_init_ctxno_sc(255 << 4)); /* lut_ctxno_sc_opt */ printf("static uint8_t lut_ctxno_sc_opt[256] = {\n "); for (i = 0; i < 255; ++i) { printf("0x%x, ", t1_init_ctxno_sc_opt(i)); if (!((i + 1) & 0xf)) printf("\n "); } printf("0x%x\n};\n\n", t1_init_ctxno_sc_opt(255)); /* lut_spb */ printf("static uint8_t lut_spb[256] = {\n "); for (i = 0; i < 255; ++i) { printf("%i, ", t1_init_spb(i << 4)); if(!((i+1)&0x1f)) printf("\n "); } printf("%i\n};\n\n", t1_init_spb(255 << 4)); /* lut_spb_opt */ printf("static uint8_t lut_spb_opt[256] = {\n "); for (i = 0; i < 255; ++i) { printf("%i, ", t1_init_spb_opt(i)); if (!((i + 1) & 0x1f)) printf("\n "); } printf("%i\n};\n\n", t1_init_spb_opt(255)); /* FIXME FIXME FIXME */ /* fprintf(stdout,"nmsedec luts:\n"); */ for (i = 0; i < (1 << T1_NMSEDEC_BITS); ++i) { t = i / pow(2, T1_NMSEDEC_FRACBITS); u = t; v = t - 1.5; lut_nmsedec_sig[i] = opj_int_max(0, (int) (floor((u * u - v * v) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0)); lut_nmsedec_sig0[i] = opj_int_max(0, (int) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0)); u = t - 1.0; if (i & (1 << (T1_NMSEDEC_BITS - 1))) { v = t - 1.5; } else { v = t - 0.5; } lut_nmsedec_ref[i] = opj_int_max(0, (int) (floor((u * u - v * v) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0)); lut_nmsedec_ref0[i] = opj_int_max(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 "); dump_array16(lut_nmsedec_sig, 1 << T1_NMSEDEC_BITS); printf("static int16_t lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {\n "); dump_array16(lut_nmsedec_sig0, 1 << T1_NMSEDEC_BITS); printf("static int16_t lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {\n "); dump_array16(lut_nmsedec_ref, 1 << T1_NMSEDEC_BITS); printf("static int16_t lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {\n "); dump_array16(lut_nmsedec_ref0, 1 << T1_NMSEDEC_BITS); return 0; }
S32 main(){ S32 i, j; F64 u, v, t; S32 lut_ctxno_zc[1024]; S32 lut_nmsedec_sig[1 << T1_NMSEDEC_BITS]; S32 lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS]; S32 lut_nmsedec_ref[1 << T1_NMSEDEC_BITS]; S32 lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS]; printf("/* This file was automatically generated by t1_generate_luts.c */\n\n"); // lut_ctxno_zc for (j = 0; j < 4; ++j) { for (i = 0; i < 256; ++i) { S32 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); } } printf("static char lut_ctxno_zc[1024] = {\n "); for (i = 0; i < 1023; ++i) { printf("%i, ", lut_ctxno_zc[i]); if(!((i+1)&0x1f)) printf("\n "); } printf("%i\n};\n\n", lut_ctxno_zc[1023]); // lut_ctxno_sc printf("static char lut_ctxno_sc[256] = {\n "); for (i = 0; i < 255; ++i) { printf("0x%x, ", t1_init_ctxno_sc(i << 4)); if(!((i+1)&0xf)) printf("\n "); } printf("0x%x\n};\n\n", t1_init_ctxno_sc(255 << 4)); // lut_spb printf("static char lut_spb[256] = {\n "); for (i = 0; i < 255; ++i) { printf("%i, ", t1_init_spb(i << 4)); if(!((i+1)&0x1f)) printf("\n "); } printf("%i\n};\n\n", t1_init_spb(255 << 4)); /* FIXME FIXME FIXME */ /* fprintf(stdout,"nmsedec luts:\n"); */ for (i = 0; i < (1 << T1_NMSEDEC_BITS); ++i) { t = i / pow(2, T1_NMSEDEC_FRACBITS); u = t; v = t - 1.5; lut_nmsedec_sig[i] = int_max(0, (S32) (floor((u * u - v * v) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0)); lut_nmsedec_sig0[i] = int_max(0, (S32) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0)); u = t - 1.0; if (i & (1 << (T1_NMSEDEC_BITS - 1))) { v = t - 1.5; } else { v = t - 0.5; } lut_nmsedec_ref[i] = int_max(0, (S32) (floor((u * u - v * v) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0)); lut_nmsedec_ref0[i] = int_max(0, (S32) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0)); } printf("static S16 lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {\n "); dump_array16(lut_nmsedec_sig, 1 << T1_NMSEDEC_BITS); printf("static S16 lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {\n "); dump_array16(lut_nmsedec_sig0, 1 << T1_NMSEDEC_BITS); printf("static S16 lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {\n "); dump_array16(lut_nmsedec_ref, 1 << T1_NMSEDEC_BITS); printf("static S16 lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {\n "); dump_array16(lut_nmsedec_ref0, 1 << T1_NMSEDEC_BITS); return 0; }