~cosme/ubuntu/precise/freeimage/freeimage-3.15.1

« back to all changes in this revision

Viewing changes to Source/LibOpenJPEG/t1_generate_luts.c

  • Committer: Stefano Rivera
  • Date: 2010-07-24 15:35:51 UTC
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: stefanor@ubuntu.com-20100724153551-6s3fth1653huk31a
Tags: upstream-3.13.1
ImportĀ upstreamĀ versionĀ 3.31.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
146
146
        return (T1_CTXNO_SC + n);
147
147
}
148
148
 
149
 
static int t1_init_ctxno_mag(int f) {
150
 
        int n;
151
 
        if (!(f & T1_REFINE))
152
 
                n = (f & (T1_SIG_OTH)) ? 1 : 0;
153
 
        else
154
 
                n = 2;
155
 
 
156
 
        return (T1_CTXNO_MAG + n);
157
 
}
158
 
 
159
149
static int t1_init_spb(int f) {
160
150
        int hc, vc, n;
161
151
 
197
187
        double u, v, t;
198
188
 
199
189
        int lut_ctxno_zc[1024];
200
 
        int lut_ctxno_mag[4096];
201
190
        int lut_nmsedec_sig[1 << T1_NMSEDEC_BITS];
202
191
        int lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS];
203
192
        int lut_nmsedec_ref[1 << T1_NMSEDEC_BITS];
208
197
        // lut_ctxno_zc
209
198
        for (j = 0; j < 4; ++j) {
210
199
                for (i = 0; i < 256; ++i) {
211
 
                        lut_ctxno_zc[(j << 8) | i] = t1_init_ctxno_zc(i, j);
 
200
                        int orient = j;
 
201
                        if (orient == 2) {
 
202
                                orient = 1;
 
203
                        } else if (orient == 1) {
 
204
                                orient = 2;
 
205
                        }
 
206
                        lut_ctxno_zc[(orient << 8) | i] = t1_init_ctxno_zc(i, j);
212
207
                }
213
208
        }
214
209
 
215
 
        printf("static int8_t lut_ctxno_zc[1024] = {\n  ");
 
210
        printf("static char lut_ctxno_zc[1024] = {\n  ");
216
211
        for (i = 0; i < 1023; ++i) {
217
212
                printf("%i, ", lut_ctxno_zc[i]);
218
213
                if(!((i+1)&0x1f))
221
216
        printf("%i\n};\n\n", lut_ctxno_zc[1023]);
222
217
 
223
218
        // lut_ctxno_sc
224
 
        printf("static int8_t lut_ctxno_sc[256] = {\n  ");
 
219
        printf("static char lut_ctxno_sc[256] = {\n  ");
225
220
        for (i = 0; i < 255; ++i) {
226
221
                printf("0x%x, ", t1_init_ctxno_sc(i << 4));
227
222
                if(!((i+1)&0xf))
229
224
        }
230
225
        printf("0x%x\n};\n\n", t1_init_ctxno_sc(255 << 4));
231
226
 
232
 
        // lut_ctxno_mag
233
 
        for (j = 0; j < 2; ++j) {
234
 
                for (i = 0; i < 2048; ++i) {
235
 
                        lut_ctxno_mag[(j << 11) + i] = t1_init_ctxno_mag((j ? T1_REFINE : 0) | i);
236
 
                }
237
 
        }
238
 
 
239
 
        printf("static int8_t lut_ctxno_mag[4096] = {\n  ");
240
 
        for (i = 0; i < 4095; ++i) {
241
 
                printf("%i, ", lut_ctxno_mag[i]);
242
 
                if(!((i+1)&0xf))
243
 
                        printf("\n  ");
244
 
        }
245
 
        printf("%i\n};\n\n", lut_ctxno_mag[4095]);
246
 
 
247
227
        // lut_spb
248
 
        printf("static int8_t lut_spb[256] = {\n  ");
 
228
        printf("static char lut_spb[256] = {\n  ");
249
229
        for (i = 0; i < 255; ++i) {
250
230
                printf("%i, ", t1_init_spb(i << 4));
251
231
                if(!((i+1)&0x1f))
279
259
                                        (int) (floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2, T1_NMSEDEC_FRACBITS) * 8192.0));
280
260
        }
281
261
 
282
 
        printf("static int16_t lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {\n  ");
283
 
        dump_array16(&lut_nmsedec_sig, 1 << T1_NMSEDEC_BITS);
284
 
 
285
 
        printf("static int16_t lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {\n  ");
286
 
        dump_array16(&lut_nmsedec_sig0, 1 << T1_NMSEDEC_BITS);
287
 
 
288
 
        printf("static int16_t lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {\n  ");
289
 
        dump_array16(&lut_nmsedec_ref, 1 << T1_NMSEDEC_BITS);
290
 
 
291
 
        printf("static int16_t lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {\n  ");
292
 
        dump_array16(&lut_nmsedec_ref0, 1 << T1_NMSEDEC_BITS);
 
262
        printf("static short lut_nmsedec_sig[1 << T1_NMSEDEC_BITS] = {\n  ");
 
263
        dump_array16(lut_nmsedec_sig, 1 << T1_NMSEDEC_BITS);
 
264
 
 
265
        printf("static short lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS] = {\n  ");
 
266
        dump_array16(lut_nmsedec_sig0, 1 << T1_NMSEDEC_BITS);
 
267
 
 
268
        printf("static short lut_nmsedec_ref[1 << T1_NMSEDEC_BITS] = {\n  ");
 
269
        dump_array16(lut_nmsedec_ref, 1 << T1_NMSEDEC_BITS);
 
270
 
 
271
        printf("static short lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS] = {\n  ");
 
272
        dump_array16(lut_nmsedec_ref0, 1 << T1_NMSEDEC_BITS);
293
273
 
294
274
        return 0;
295
275
}