X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fopenjp2%2Ft1_generate_luts.c;h=1e6e7b066c094f184db9f84cfc6e011bfcf6d59c;hb=956c31d5a6e4530a92b6dd6099bdbf071144f6f1;hp=ffeff03e1b332ce566ea03676d8752d7d67ceb66;hpb=d518970039a19a2a9b6d2bdd592cc88a43897bbb;p=openjpeg.git diff --git a/src/lib/openjp2/t1_generate_luts.c b/src/lib/openjp2/t1_generate_luts.c index ffeff03e..1e6e7b06 100644 --- a/src/lib/openjp2/t1_generate_luts.c +++ b/src/lib/openjp2/t1_generate_luts.c @@ -1,9 +1,15 @@ /* - * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium - * Copyright (c) 2002-2007, Professor Benoit Macq + * The copyright in this software is being made available under the 2-clauses + * BSD License, included below. This software may be subject to other third + * party and contributor rights, including patent rights, and no such rights + * are granted under this license. + * + * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium + * Copyright (c) 2002-2014, Professor Benoit Macq * Copyright (c) 2001-2003, David Janssens * Copyright (c) 2002-2003, Yannick Verschueren - * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe + * Copyright (c) 2003-2007, Francois-Olivier Devaux + * Copyright (c) 2003-2014, Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2007, Callum Lerwick * All rights reserved. @@ -34,10 +40,12 @@ static int t1_init_ctxno_zc(int f, int orient) { int h, v, d, n, t, hv; - n = 0; h = ((f & T1_SIG_W) != 0) + ((f & T1_SIG_E) != 0); v = ((f & T1_SIG_N) != 0) + ((f & T1_SIG_S) != 0); d = ((f & T1_SIG_NW) != 0) + ((f & T1_SIG_NE) != 0) + ((f & T1_SIG_SE) != 0) + ((f & T1_SIG_SW) != 0); + n = 0; + t = 0; + hv = 0; switch (orient) { case 2: @@ -108,16 +116,16 @@ static int t1_init_ctxno_sc(int f) { int hc, vc, n; n = 0; - hc = int_min(((f & (T1_SIG_E | T1_SGN_E)) == + hc = opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) == T1_SIG_E) + ((f & (T1_SIG_W | T1_SGN_W)) == T1_SIG_W), - 1) - int_min(((f & (T1_SIG_E | T1_SGN_E)) == + 1) - opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) == (T1_SIG_E | T1_SGN_E)) + ((f & (T1_SIG_W | T1_SGN_W)) == (T1_SIG_W | T1_SGN_W)), 1); - vc = int_min(((f & (T1_SIG_N | T1_SGN_N)) == + vc = opj_int_min(((f & (T1_SIG_N | T1_SGN_N)) == T1_SIG_N) + ((f & (T1_SIG_S | T1_SGN_S)) == T1_SIG_S), - 1) - int_min(((f & (T1_SIG_N | T1_SGN_N)) == + 1) - opj_int_min(((f & (T1_SIG_N | T1_SGN_N)) == (T1_SIG_N | T1_SGN_N)) + ((f & (T1_SIG_S | T1_SGN_S)) == (T1_SIG_S | T1_SGN_S)), 1); @@ -148,16 +156,16 @@ static int t1_init_ctxno_sc(int f) { static int t1_init_spb(int f) { int hc, vc, n; - hc = int_min(((f & (T1_SIG_E | T1_SGN_E)) == + hc = opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) == T1_SIG_E) + ((f & (T1_SIG_W | T1_SGN_W)) == T1_SIG_W), - 1) - int_min(((f & (T1_SIG_E | T1_SGN_E)) == + 1) - opj_int_min(((f & (T1_SIG_E | T1_SGN_E)) == (T1_SIG_E | T1_SGN_E)) + ((f & (T1_SIG_W | T1_SGN_W)) == (T1_SIG_W | T1_SGN_W)), 1); - vc = int_min(((f & (T1_SIG_N | T1_SGN_N)) == + vc = opj_int_min(((f & (T1_SIG_N | T1_SGN_N)) == T1_SIG_N) + ((f & (T1_SIG_S | T1_SGN_S)) == T1_SIG_S), - 1) - int_min(((f & (T1_SIG_N | T1_SGN_N)) == + 1) - opj_int_min(((f & (T1_SIG_N | T1_SGN_N)) == (T1_SIG_N | T1_SGN_N)) + ((f & (T1_SIG_S | T1_SGN_S)) == (T1_SIG_S | T1_SGN_S)), 1); @@ -170,7 +178,7 @@ static int t1_init_spb(int f) { return n; } -void dump_array16(int array[],int size){ +static void dump_array16(int array[],int size){ int i; --size; for (i = 0; i < size; ++i) { @@ -181,7 +189,8 @@ void dump_array16(int array[],int size){ printf("0x%04x\n};\n\n", array[size]); } -int main(){ +int main(int argc, char **argv) +{ int i, j; double u, v, t; @@ -190,10 +199,11 @@ int main(){ 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 + /* lut_ctxno_zc */ for (j = 0; j < 4; ++j) { for (i = 0; i < 256; ++i) { int orient = j; @@ -206,7 +216,7 @@ int main(){ } } - printf("static char lut_ctxno_zc[1024] = {\n "); + printf("static const OPJ_BYTE lut_ctxno_zc[1024] = {\n "); for (i = 0; i < 1023; ++i) { printf("%i, ", lut_ctxno_zc[i]); if(!((i+1)&0x1f)) @@ -214,8 +224,8 @@ int main(){ } printf("%i\n};\n\n", lut_ctxno_zc[1023]); - // lut_ctxno_sc - printf("static char lut_ctxno_sc[256] = {\n "); + /* lut_ctxno_sc */ + printf("static const OPJ_BYTE lut_ctxno_sc[256] = {\n "); for (i = 0; i < 255; ++i) { printf("0x%x, ", t1_init_ctxno_sc(i << 4)); if(!((i+1)&0xf)) @@ -223,8 +233,8 @@ int main(){ } printf("0x%x\n};\n\n", t1_init_ctxno_sc(255 << 4)); - // lut_spb - printf("static char lut_spb[256] = {\n "); + /* lut_spb */ + printf("static const OPJ_BYTE lut_spb[256] = {\n "); for (i = 0; i < 255; ++i) { printf("%i, ", t1_init_spb(i << 4)); if(!((i+1)&0x1f)) @@ -239,10 +249,10 @@ int main(){ u = t; v = t - 1.5; lut_nmsedec_sig[i] = - int_max(0, + 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] = - int_max(0, + 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))) { @@ -251,23 +261,23 @@ int main(){ v = t - 0.5; } lut_nmsedec_ref[i] = - int_max(0, + 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] = - int_max(0, + opj_int_max(0, (int) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0)); } - printf("static short 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); - printf("static short 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); - printf("static short 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); - printf("static short 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); return 0;