OpenCores
URL https://opencores.org/ocsvn/mb-jpeg/mb-jpeg/trunk

Subversion Repositories mb-jpeg

[/] [mb-jpeg/] [tags/] [STEP2_2b/] [mb-bmp2jpg/] [dct.c] - Blame information for rev 68

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 56 quickwayne
#include "ejpgl.h"
2
 
3
extern signed int weights[512];
4
signed short dctresult[MATRIX_SIZE][MATRIX_SIZE];
5
 
6
int dct_init_start() {
7
 
8
        return 0;
9
 
10
}
11
 
12
int     dct_stop_done() {
13
 
14
        return 0;
15
 
16
}
17
 
18
/*
19
        Function Name: dct
20
 
21
        Operation: Find the 8x8 DCT of an array using separable DCT
22
        First, finds 1-d DCT along rows, storing the result in inter[][]
23
        Then, 1-d DCT along columns of inter[][] is found
24
 
25
        Input: pixels is the 8x8 input array
26
 
27
        Output: dct is the 8x8 output array
28
*/
29
 
30
void dct(signed char pixels[8][8], int color)
31
{
32
        int inr, inc;           /* rows and columns of input image */
33
        int intr, intc;         /* rows and columns of intermediate image */
34
        int outr, outc;         /* rows and columns of dct */
35
        int f_val;              /* cumulative sum */
36
        int inter[8][8];        /* stores intermediate result */
37
        int i,j,k;
38
        k=0;
39
 
40
        for (intr=0; intr<8; intr++)
41
                for (intc=0; intc<8; intc++) {
42
                        for (i=0,f_val=0; i<8; i++) {
43
                                f_val += (pixels[intr][i]* weights[k]);//cos((double)(2*i+1)*(double)intc*PI/16);
44
                            k++;
45
                        }
46
                     if (intc!=0) inter[intr][intc] =  f_val>>15;
47
                     else inter[intr][intc] =  (11585*(f_val>>14))>>15;
48
 
49
                }
50
 
51
        /* find 1-d dct along columns */
52
 
53
        for (outc=0, k=0; outc<8; outc++)
54
                for (outr=0; outr<8; outr++) {
55
                        for (i=0,f_val=0; i<8; i++) {
56
                                f_val += (inter[i][outc] *weights[k]);
57
                            k++;
58
                        }
59
                     if (outr!=0) dctresult[outr][outc] = f_val>>15;
60
                     else dctresult[outr][outc] = (11585*(f_val>>14)>>15);
61
                }
62
 
63
        zzq_encode(dctresult, color);
64
        return;
65
 
66
}
67
 
68
 
69
signed int weights[512] = {
70
16384,
71
16384,
72
16384,
73
16384,
74
16384,
75
16384,
76
16384,
77
16384,
78
16069,
79
13623,
80
9102,
81
3196,
82
-3196,
83
-9102,
84
-13623,
85
-16069,
86
15137,
87
6270,
88
-6270,
89
-15137,
90
-15137,
91
-6270,
92
6270,
93
15137,
94
13623,
95
-3196,
96
-16069,
97
-9103,
98
9102,
99
16069,
100
3196,
101
-13623,
102
11585,
103
-11585,
104
-11585,
105
11585,
106
11585,
107
-11585,
108
-11585,
109
11585,
110
9102,
111
-16069,
112
3196,
113
13623,
114
-13623,
115
-3197,
116
16069,
117
-9102,
118
6270,
119
-15137,
120
15137,
121
-6270,
122
-6270,
123
15137,
124
-15137,
125
6270,
126
3196,
127
-9103,
128
13623,
129
-16069,
130
16069,
131
-13623,
132
9102,
133
-3196,
134
16384,
135
16384,
136
16384,
137
16384,
138
16384,
139
16384,
140
16384,
141
16384,
142
16069,
143
13623,
144
9102,
145
3196,
146
-3196,
147
-9102,
148
-13623,
149
-16069,
150
15137,
151
6270,
152
-6270,
153
-15137,
154
-15137,
155
-6270,
156
6270,
157
15137,
158
13623,
159
-3196,
160
-16069,
161
-9103,
162
9102,
163
16069,
164
3196,
165
-13623,
166
11585,
167
-11585,
168
-11585,
169
11585,
170
11585,
171
-11585,
172
-11585,
173
11585,
174
9102,
175
-16069,
176
3196,
177
13623,
178
-13623,
179
-3197,
180
16069,
181
-9102,
182
6270,
183
-15137,
184
15137,
185
-6270,
186
-6270,
187
15137,
188
-15137,
189
6270,
190
3196,
191
-9103,
192
13623,
193
-16069,
194
16069,
195
-13623,
196
9102,
197
-3196,
198
16384,
199
16384,
200
16384,
201
16384,
202
16384,
203
16384,
204
16384,
205
16384,
206
16069,
207
13623,
208
9102,
209
3196,
210
-3196,
211
-9102,
212
-13623,
213
-16069,
214
15137,
215
6270,
216
-6270,
217
-15137,
218
-15137,
219
-6270,
220
6270,
221
15137,
222
13623,
223
-3196,
224
-16069,
225
-9103,
226
9102,
227
16069,
228
3196,
229
-13623,
230
11585,
231
-11585,
232
-11585,
233
11585,
234
11585,
235
-11585,
236
-11585,
237
11585,
238
9102,
239
-16069,
240
3196,
241
13623,
242
-13623,
243
-3197,
244
16069,
245
-9102,
246
6270,
247
-15137,
248
15137,
249
-6270,
250
-6270,
251
15137,
252
-15137,
253
6270,
254
3196,
255
-9103,
256
13623,
257
-16069,
258
16069,
259
-13623,
260
9102,
261
-3196,
262
16384,
263
16384,
264
16384,
265
16384,
266
16384,
267
16384,
268
16384,
269
16384,
270
16069,
271
13623,
272
9102,
273
3196,
274
-3196,
275
-9102,
276
-13623,
277
-16069,
278
15137,
279
6270,
280
-6270,
281
-15137,
282
-15137,
283
-6270,
284
6270,
285
15137,
286
13623,
287
-3196,
288
-16069,
289
-9103,
290
9102,
291
16069,
292
3196,
293
-13623,
294
11585,
295
-11585,
296
-11585,
297
11585,
298
11585,
299
-11585,
300
-11585,
301
11585,
302
9102,
303
-16069,
304
3196,
305
13623,
306
-13623,
307
-3197,
308
16069,
309
-9102,
310
6270,
311
-15137,
312
15137,
313
-6270,
314
-6270,
315
15137,
316
-15137,
317
6270,
318
3196,
319
-9103,
320
13623,
321
-16069,
322
16069,
323
-13623,
324
9102,
325
-3196,
326
16384,
327
16384,
328
16384,
329
16384,
330
16384,
331
16384,
332
16384,
333
16384,
334
16069,
335
13623,
336
9102,
337
3196,
338
-3196,
339
-9102,
340
-13623,
341
-16069,
342
15137,
343
6270,
344
-6270,
345
-15137,
346
-15137,
347
-6270,
348
6270,
349
15137,
350
13623,
351
-3196,
352
-16069,
353
-9103,
354
9102,
355
16069,
356
3196,
357
-13623,
358
11585,
359
-11585,
360
-11585,
361
11585,
362
11585,
363
-11585,
364
-11585,
365
11585,
366
9102,
367
-16069,
368
3196,
369
13623,
370
-13623,
371
-3197,
372
16069,
373
-9102,
374
6270,
375
-15137,
376
15137,
377
-6270,
378
-6270,
379
15137,
380
-15137,
381
6270,
382
3196,
383
-9103,
384
13623,
385
-16069,
386
16069,
387
-13623,
388
9102,
389
-3196,
390
16384,
391
16384,
392
16384,
393
16384,
394
16384,
395
16384,
396
16384,
397
16384,
398
16069,
399
13623,
400
9102,
401
3196,
402
-3196,
403
-9102,
404
-13623,
405
-16069,
406
15137,
407
6270,
408
-6270,
409
-15137,
410
-15137,
411
-6270,
412
6270,
413
15137,
414
13623,
415
-3196,
416
-16069,
417
-9103,
418
9102,
419
16069,
420
3196,
421
-13623,
422
11585,
423
-11585,
424
-11585,
425
11585,
426
11585,
427
-11585,
428
-11585,
429
11585,
430
9102,
431
-16069,
432
3196,
433
13623,
434
-13623,
435
-3197,
436
16069,
437
-9102,
438
6270,
439
-15137,
440
15137,
441
-6270,
442
-6270,
443
15137,
444
-15137,
445
6270,
446
3196,
447
-9103,
448
13623,
449
-16069,
450
16069,
451
-13623,
452
9102,
453
-3196,
454
16384,
455
16384,
456
16384,
457
16384,
458
16384,
459
16384,
460
16384,
461
16384,
462
16069,
463
13623,
464
9102,
465
3196,
466
-3196,
467
-9102,
468
-13623,
469
-16069,
470
15137,
471
6270,
472
-6270,
473
-15137,
474
-15137,
475
-6270,
476
6270,
477
15137,
478
13623,
479
-3196,
480
-16069,
481
-9103,
482
9102,
483
16069,
484
3196,
485
-13623,
486
11585,
487
-11585,
488
-11585,
489
11585,
490
11585,
491
-11585,
492
-11585,
493
11585,
494
9102,
495
-16069,
496
3196,
497
13623,
498
-13623,
499
-3197,
500
16069,
501
-9102,
502
6270,
503
-15137,
504
15137,
505
-6270,
506
-6270,
507
15137,
508
-15137,
509
6270,
510
3196,
511
-9103,
512
13623,
513
-16069,
514
16069,
515
-13623,
516
9102,
517
-3196,
518
16384,
519
16384,
520
16384,
521
16384,
522
16384,
523
16384,
524
16384,
525
16384,
526
16069,
527
13623,
528
9102,
529
3196,
530
-3196,
531
-9102,
532
-13623,
533
-16069,
534
15137,
535
6270,
536
-6270,
537
-15137,
538
-15137,
539
-6270,
540
6270,
541
15137,
542
13623,
543
-3196,
544
-16069,
545
-9103,
546
9102,
547
16069,
548
3196,
549
-13623,
550
11585,
551
-11585,
552
-11585,
553
11585,
554
11585,
555
-11585,
556
-11585,
557
11585,
558
9102,
559
-16069,
560
3196,
561
13623,
562
-13623,
563
-3197,
564
16069,
565
-9102,
566
6270,
567
-15137,
568
15137,
569
-6270,
570
-6270,
571
15137,
572
-15137,
573
6270,
574
3196,
575
-9103,
576
13623,
577
-16069,
578
16069,
579
-13623,
580
9102,
581
-3196
582
};
583
 
584
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.