00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00065 #include "libavutil/common.h"
00066 #include "dsputil.h"
00067
00068 #define EIGHT_BIT_SAMPLES
00069
00070 #define DCTSIZE 8
00071 #define DCTSIZE2 64
00072
00073 #define GLOBAL
00074
00075 #define RIGHT_SHIFT(x, n) ((x) >> (n))
00076
00077 typedef DCTELEM DCTBLOCK[DCTSIZE2];
00078
00079 #define CONST_BITS 13
00080
00081
00082
00083
00084
00085 #if DCTSIZE != 8
00086 Sorry, this code only copes with 8x8 DCTs.
00087 #endif
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 #ifdef EIGHT_BIT_SAMPLES
00127 #define PASS1_BITS 2
00128 #else
00129 #define PASS1_BITS 1
00130 #endif
00131
00132 #define ONE ((int32_t) 1)
00133
00134 #define CONST_SCALE (ONE << CONST_BITS)
00135
00136
00137
00138
00139
00140
00141
00142
00143 #define FIX(x) ((int32_t) ((x) * CONST_SCALE + 0.5))
00144
00145
00146
00147
00148
00149
00150 #define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 #ifdef EIGHT_BIT_SAMPLES
00164 #ifdef SHORTxSHORT_32
00165 #define MULTIPLY(var,const) (((int16_t) (var)) * ((int16_t) (const)))
00166 #endif
00167 #ifdef SHORTxLCONST_32
00168 #define MULTIPLY(var,const) (((int16_t) (var)) * ((int32_t) (const)))
00169 #endif
00170 #endif
00171
00172 #ifndef MULTIPLY
00173 #define MULTIPLY(var,const) ((var) * (const))
00174 #endif
00175
00176
00177
00178
00179
00180
00181 #define FIX_0_211164243 1730
00182 #define FIX_0_275899380 2260
00183 #define FIX_0_298631336 2446
00184 #define FIX_0_390180644 3196
00185 #define FIX_0_509795579 4176
00186 #define FIX_0_541196100 4433
00187 #define FIX_0_601344887 4926
00188 #define FIX_0_765366865 6270
00189 #define FIX_0_785694958 6436
00190 #define FIX_0_899976223 7373
00191 #define FIX_1_061594337 8697
00192 #define FIX_1_111140466 9102
00193 #define FIX_1_175875602 9633
00194 #define FIX_1_306562965 10703
00195 #define FIX_1_387039845 11363
00196 #define FIX_1_451774981 11893
00197 #define FIX_1_501321110 12299
00198 #define FIX_1_662939225 13623
00199 #define FIX_1_847759065 15137
00200 #define FIX_1_961570560 16069
00201 #define FIX_2_053119869 16819
00202 #define FIX_2_172734803 17799
00203 #define FIX_2_562915447 20995
00204 #define FIX_3_072711026 25172
00205
00206
00207
00208
00209
00210 void j_rev_dct(DCTBLOCK data)
00211 {
00212 int32_t tmp0, tmp1, tmp2, tmp3;
00213 int32_t tmp10, tmp11, tmp12, tmp13;
00214 int32_t z1, z2, z3, z4, z5;
00215 int32_t d0, d1, d2, d3, d4, d5, d6, d7;
00216 register DCTELEM *dataptr;
00217 int rowctr;
00218
00219
00220
00221
00222
00223 dataptr = data;
00224
00225 for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235 register int *idataptr = (int*)dataptr;
00236
00237
00238
00239 d0 = dataptr[0];
00240 d2 = dataptr[1];
00241 d4 = dataptr[2];
00242 d6 = dataptr[3];
00243 d1 = dataptr[4];
00244 d3 = dataptr[5];
00245 d5 = dataptr[6];
00246 d7 = dataptr[7];
00247
00248 if ((d1 | d2 | d3 | d4 | d5 | d6 | d7) == 0) {
00249
00250 if (d0) {
00251
00252 DCTELEM dcval = (DCTELEM) (d0 << PASS1_BITS);
00253 register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000);
00254
00255 idataptr[0] = v;
00256 idataptr[1] = v;
00257 idataptr[2] = v;
00258 idataptr[3] = v;
00259 }
00260
00261 dataptr += DCTSIZE;
00262 continue;
00263 }
00264
00265
00266
00267 {
00268 if (d6) {
00269 if (d2) {
00270
00271 z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
00272 tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
00273 tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
00274
00275 tmp0 = (d0 + d4) << CONST_BITS;
00276 tmp1 = (d0 - d4) << CONST_BITS;
00277
00278 tmp10 = tmp0 + tmp3;
00279 tmp13 = tmp0 - tmp3;
00280 tmp11 = tmp1 + tmp2;
00281 tmp12 = tmp1 - tmp2;
00282 } else {
00283
00284 tmp2 = MULTIPLY(-d6, FIX_1_306562965);
00285 tmp3 = MULTIPLY(d6, FIX_0_541196100);
00286
00287 tmp0 = (d0 + d4) << CONST_BITS;
00288 tmp1 = (d0 - d4) << CONST_BITS;
00289
00290 tmp10 = tmp0 + tmp3;
00291 tmp13 = tmp0 - tmp3;
00292 tmp11 = tmp1 + tmp2;
00293 tmp12 = tmp1 - tmp2;
00294 }
00295 } else {
00296 if (d2) {
00297
00298 tmp2 = MULTIPLY(d2, FIX_0_541196100);
00299 tmp3 = MULTIPLY(d2, FIX_1_306562965);
00300
00301 tmp0 = (d0 + d4) << CONST_BITS;
00302 tmp1 = (d0 - d4) << CONST_BITS;
00303
00304 tmp10 = tmp0 + tmp3;
00305 tmp13 = tmp0 - tmp3;
00306 tmp11 = tmp1 + tmp2;
00307 tmp12 = tmp1 - tmp2;
00308 } else {
00309
00310 tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
00311 tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
00312 }
00313 }
00314
00315
00316
00317
00318
00319 if (d7) {
00320 if (d5) {
00321 if (d3) {
00322 if (d1) {
00323
00324 z1 = d7 + d1;
00325 z2 = d5 + d3;
00326 z3 = d7 + d3;
00327 z4 = d5 + d1;
00328 z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
00329
00330 tmp0 = MULTIPLY(d7, FIX_0_298631336);
00331 tmp1 = MULTIPLY(d5, FIX_2_053119869);
00332 tmp2 = MULTIPLY(d3, FIX_3_072711026);
00333 tmp3 = MULTIPLY(d1, FIX_1_501321110);
00334 z1 = MULTIPLY(-z1, FIX_0_899976223);
00335 z2 = MULTIPLY(-z2, FIX_2_562915447);
00336 z3 = MULTIPLY(-z3, FIX_1_961570560);
00337 z4 = MULTIPLY(-z4, FIX_0_390180644);
00338
00339 z3 += z5;
00340 z4 += z5;
00341
00342 tmp0 += z1 + z3;
00343 tmp1 += z2 + z4;
00344 tmp2 += z2 + z3;
00345 tmp3 += z1 + z4;
00346 } else {
00347
00348 z2 = d5 + d3;
00349 z3 = d7 + d3;
00350 z5 = MULTIPLY(z3 + d5, FIX_1_175875602);
00351
00352 tmp0 = MULTIPLY(d7, FIX_0_298631336);
00353 tmp1 = MULTIPLY(d5, FIX_2_053119869);
00354 tmp2 = MULTIPLY(d3, FIX_3_072711026);
00355 z1 = MULTIPLY(-d7, FIX_0_899976223);
00356 z2 = MULTIPLY(-z2, FIX_2_562915447);
00357 z3 = MULTIPLY(-z3, FIX_1_961570560);
00358 z4 = MULTIPLY(-d5, FIX_0_390180644);
00359
00360 z3 += z5;
00361 z4 += z5;
00362
00363 tmp0 += z1 + z3;
00364 tmp1 += z2 + z4;
00365 tmp2 += z2 + z3;
00366 tmp3 = z1 + z4;
00367 }
00368 } else {
00369 if (d1) {
00370
00371 z1 = d7 + d1;
00372 z4 = d5 + d1;
00373 z5 = MULTIPLY(d7 + z4, FIX_1_175875602);
00374
00375 tmp0 = MULTIPLY(d7, FIX_0_298631336);
00376 tmp1 = MULTIPLY(d5, FIX_2_053119869);
00377 tmp3 = MULTIPLY(d1, FIX_1_501321110);
00378 z1 = MULTIPLY(-z1, FIX_0_899976223);
00379 z2 = MULTIPLY(-d5, FIX_2_562915447);
00380 z3 = MULTIPLY(-d7, FIX_1_961570560);
00381 z4 = MULTIPLY(-z4, FIX_0_390180644);
00382
00383 z3 += z5;
00384 z4 += z5;
00385
00386 tmp0 += z1 + z3;
00387 tmp1 += z2 + z4;
00388 tmp2 = z2 + z3;
00389 tmp3 += z1 + z4;
00390 } else {
00391
00392 tmp0 = MULTIPLY(-d7, FIX_0_601344887);
00393 z1 = MULTIPLY(-d7, FIX_0_899976223);
00394 z3 = MULTIPLY(-d7, FIX_1_961570560);
00395 tmp1 = MULTIPLY(-d5, FIX_0_509795579);
00396 z2 = MULTIPLY(-d5, FIX_2_562915447);
00397 z4 = MULTIPLY(-d5, FIX_0_390180644);
00398 z5 = MULTIPLY(d5 + d7, FIX_1_175875602);
00399
00400 z3 += z5;
00401 z4 += z5;
00402
00403 tmp0 += z3;
00404 tmp1 += z4;
00405 tmp2 = z2 + z3;
00406 tmp3 = z1 + z4;
00407 }
00408 }
00409 } else {
00410 if (d3) {
00411 if (d1) {
00412
00413 z1 = d7 + d1;
00414 z3 = d7 + d3;
00415 z5 = MULTIPLY(z3 + d1, FIX_1_175875602);
00416
00417 tmp0 = MULTIPLY(d7, FIX_0_298631336);
00418 tmp2 = MULTIPLY(d3, FIX_3_072711026);
00419 tmp3 = MULTIPLY(d1, FIX_1_501321110);
00420 z1 = MULTIPLY(-z1, FIX_0_899976223);
00421 z2 = MULTIPLY(-d3, FIX_2_562915447);
00422 z3 = MULTIPLY(-z3, FIX_1_961570560);
00423 z4 = MULTIPLY(-d1, FIX_0_390180644);
00424
00425 z3 += z5;
00426 z4 += z5;
00427
00428 tmp0 += z1 + z3;
00429 tmp1 = z2 + z4;
00430 tmp2 += z2 + z3;
00431 tmp3 += z1 + z4;
00432 } else {
00433
00434 z3 = d7 + d3;
00435
00436 tmp0 = MULTIPLY(-d7, FIX_0_601344887);
00437 z1 = MULTIPLY(-d7, FIX_0_899976223);
00438 tmp2 = MULTIPLY(d3, FIX_0_509795579);
00439 z2 = MULTIPLY(-d3, FIX_2_562915447);
00440 z5 = MULTIPLY(z3, FIX_1_175875602);
00441 z3 = MULTIPLY(-z3, FIX_0_785694958);
00442
00443 tmp0 += z3;
00444 tmp1 = z2 + z5;
00445 tmp2 += z3;
00446 tmp3 = z1 + z5;
00447 }
00448 } else {
00449 if (d1) {
00450
00451 z1 = d7 + d1;
00452 z5 = MULTIPLY(z1, FIX_1_175875602);
00453
00454 z1 = MULTIPLY(z1, FIX_0_275899380);
00455 z3 = MULTIPLY(-d7, FIX_1_961570560);
00456 tmp0 = MULTIPLY(-d7, FIX_1_662939225);
00457 z4 = MULTIPLY(-d1, FIX_0_390180644);
00458 tmp3 = MULTIPLY(d1, FIX_1_111140466);
00459
00460 tmp0 += z1;
00461 tmp1 = z4 + z5;
00462 tmp2 = z3 + z5;
00463 tmp3 += z1;
00464 } else {
00465
00466 tmp0 = MULTIPLY(-d7, FIX_1_387039845);
00467 tmp1 = MULTIPLY(d7, FIX_1_175875602);
00468 tmp2 = MULTIPLY(-d7, FIX_0_785694958);
00469 tmp3 = MULTIPLY(d7, FIX_0_275899380);
00470 }
00471 }
00472 }
00473 } else {
00474 if (d5) {
00475 if (d3) {
00476 if (d1) {
00477
00478 z2 = d5 + d3;
00479 z4 = d5 + d1;
00480 z5 = MULTIPLY(d3 + z4, FIX_1_175875602);
00481
00482 tmp1 = MULTIPLY(d5, FIX_2_053119869);
00483 tmp2 = MULTIPLY(d3, FIX_3_072711026);
00484 tmp3 = MULTIPLY(d1, FIX_1_501321110);
00485 z1 = MULTIPLY(-d1, FIX_0_899976223);
00486 z2 = MULTIPLY(-z2, FIX_2_562915447);
00487 z3 = MULTIPLY(-d3, FIX_1_961570560);
00488 z4 = MULTIPLY(-z4, FIX_0_390180644);
00489
00490 z3 += z5;
00491 z4 += z5;
00492
00493 tmp0 = z1 + z3;
00494 tmp1 += z2 + z4;
00495 tmp2 += z2 + z3;
00496 tmp3 += z1 + z4;
00497 } else {
00498
00499 z2 = d5 + d3;
00500
00501 z5 = MULTIPLY(z2, FIX_1_175875602);
00502 tmp1 = MULTIPLY(d5, FIX_1_662939225);
00503 z4 = MULTIPLY(-d5, FIX_0_390180644);
00504 z2 = MULTIPLY(-z2, FIX_1_387039845);
00505 tmp2 = MULTIPLY(d3, FIX_1_111140466);
00506 z3 = MULTIPLY(-d3, FIX_1_961570560);
00507
00508 tmp0 = z3 + z5;
00509 tmp1 += z2;
00510 tmp2 += z2;
00511 tmp3 = z4 + z5;
00512 }
00513 } else {
00514 if (d1) {
00515
00516 z4 = d5 + d1;
00517
00518 z5 = MULTIPLY(z4, FIX_1_175875602);
00519 z1 = MULTIPLY(-d1, FIX_0_899976223);
00520 tmp3 = MULTIPLY(d1, FIX_0_601344887);
00521 tmp1 = MULTIPLY(-d5, FIX_0_509795579);
00522 z2 = MULTIPLY(-d5, FIX_2_562915447);
00523 z4 = MULTIPLY(z4, FIX_0_785694958);
00524
00525 tmp0 = z1 + z5;
00526 tmp1 += z4;
00527 tmp2 = z2 + z5;
00528 tmp3 += z4;
00529 } else {
00530
00531 tmp0 = MULTIPLY(d5, FIX_1_175875602);
00532 tmp1 = MULTIPLY(d5, FIX_0_275899380);
00533 tmp2 = MULTIPLY(-d5, FIX_1_387039845);
00534 tmp3 = MULTIPLY(d5, FIX_0_785694958);
00535 }
00536 }
00537 } else {
00538 if (d3) {
00539 if (d1) {
00540
00541 z5 = d1 + d3;
00542 tmp3 = MULTIPLY(d1, FIX_0_211164243);
00543 tmp2 = MULTIPLY(-d3, FIX_1_451774981);
00544 z1 = MULTIPLY(d1, FIX_1_061594337);
00545 z2 = MULTIPLY(-d3, FIX_2_172734803);
00546 z4 = MULTIPLY(z5, FIX_0_785694958);
00547 z5 = MULTIPLY(z5, FIX_1_175875602);
00548
00549 tmp0 = z1 - z4;
00550 tmp1 = z2 + z4;
00551 tmp2 += z5;
00552 tmp3 += z5;
00553 } else {
00554
00555 tmp0 = MULTIPLY(-d3, FIX_0_785694958);
00556 tmp1 = MULTIPLY(-d3, FIX_1_387039845);
00557 tmp2 = MULTIPLY(-d3, FIX_0_275899380);
00558 tmp3 = MULTIPLY(d3, FIX_1_175875602);
00559 }
00560 } else {
00561 if (d1) {
00562
00563 tmp0 = MULTIPLY(d1, FIX_0_275899380);
00564 tmp1 = MULTIPLY(d1, FIX_0_785694958);
00565 tmp2 = MULTIPLY(d1, FIX_1_175875602);
00566 tmp3 = MULTIPLY(d1, FIX_1_387039845);
00567 } else {
00568
00569 tmp0 = tmp1 = tmp2 = tmp3 = 0;
00570 }
00571 }
00572 }
00573 }
00574 }
00575
00576
00577 dataptr[0] = (DCTELEM) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS);
00578 dataptr[7] = (DCTELEM) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS);
00579 dataptr[1] = (DCTELEM) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS);
00580 dataptr[6] = (DCTELEM) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS);
00581 dataptr[2] = (DCTELEM) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS);
00582 dataptr[5] = (DCTELEM) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS);
00583 dataptr[3] = (DCTELEM) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS);
00584 dataptr[4] = (DCTELEM) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS);
00585
00586 dataptr += DCTSIZE;
00587 }
00588
00589
00590
00591
00592
00593 dataptr = data;
00594 for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
00595
00596
00597
00598
00599
00600
00601
00602
00603 d0 = dataptr[DCTSIZE*0];
00604 d1 = dataptr[DCTSIZE*1];
00605 d2 = dataptr[DCTSIZE*2];
00606 d3 = dataptr[DCTSIZE*3];
00607 d4 = dataptr[DCTSIZE*4];
00608 d5 = dataptr[DCTSIZE*5];
00609 d6 = dataptr[DCTSIZE*6];
00610 d7 = dataptr[DCTSIZE*7];
00611
00612
00613
00614 if (d6) {
00615 if (d2) {
00616
00617 z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
00618 tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
00619 tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
00620
00621 tmp0 = (d0 + d4) << CONST_BITS;
00622 tmp1 = (d0 - d4) << CONST_BITS;
00623
00624 tmp10 = tmp0 + tmp3;
00625 tmp13 = tmp0 - tmp3;
00626 tmp11 = tmp1 + tmp2;
00627 tmp12 = tmp1 - tmp2;
00628 } else {
00629
00630 tmp2 = MULTIPLY(-d6, FIX_1_306562965);
00631 tmp3 = MULTIPLY(d6, FIX_0_541196100);
00632
00633 tmp0 = (d0 + d4) << CONST_BITS;
00634 tmp1 = (d0 - d4) << CONST_BITS;
00635
00636 tmp10 = tmp0 + tmp3;
00637 tmp13 = tmp0 - tmp3;
00638 tmp11 = tmp1 + tmp2;
00639 tmp12 = tmp1 - tmp2;
00640 }
00641 } else {
00642 if (d2) {
00643
00644 tmp2 = MULTIPLY(d2, FIX_0_541196100);
00645 tmp3 = MULTIPLY(d2, FIX_1_306562965);
00646
00647 tmp0 = (d0 + d4) << CONST_BITS;
00648 tmp1 = (d0 - d4) << CONST_BITS;
00649
00650 tmp10 = tmp0 + tmp3;
00651 tmp13 = tmp0 - tmp3;
00652 tmp11 = tmp1 + tmp2;
00653 tmp12 = tmp1 - tmp2;
00654 } else {
00655
00656 tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
00657 tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
00658 }
00659 }
00660
00661
00662
00663
00664 if (d7) {
00665 if (d5) {
00666 if (d3) {
00667 if (d1) {
00668
00669 z1 = d7 + d1;
00670 z2 = d5 + d3;
00671 z3 = d7 + d3;
00672 z4 = d5 + d1;
00673 z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
00674
00675 tmp0 = MULTIPLY(d7, FIX_0_298631336);
00676 tmp1 = MULTIPLY(d5, FIX_2_053119869);
00677 tmp2 = MULTIPLY(d3, FIX_3_072711026);
00678 tmp3 = MULTIPLY(d1, FIX_1_501321110);
00679 z1 = MULTIPLY(-z1, FIX_0_899976223);
00680 z2 = MULTIPLY(-z2, FIX_2_562915447);
00681 z3 = MULTIPLY(-z3, FIX_1_961570560);
00682 z4 = MULTIPLY(-z4, FIX_0_390180644);
00683
00684 z3 += z5;
00685 z4 += z5;
00686
00687 tmp0 += z1 + z3;
00688 tmp1 += z2 + z4;
00689 tmp2 += z2 + z3;
00690 tmp3 += z1 + z4;
00691 } else {
00692
00693 z2 = d5 + d3;
00694 z3 = d7 + d3;
00695 z5 = MULTIPLY(z3 + d5, FIX_1_175875602);
00696
00697 tmp0 = MULTIPLY(d7, FIX_0_298631336);
00698 tmp1 = MULTIPLY(d5, FIX_2_053119869);
00699 tmp2 = MULTIPLY(d3, FIX_3_072711026);
00700 z1 = MULTIPLY(-d7, FIX_0_899976223);
00701 z2 = MULTIPLY(-z2, FIX_2_562915447);
00702 z3 = MULTIPLY(-z3, FIX_1_961570560);
00703 z4 = MULTIPLY(-d5, FIX_0_390180644);
00704
00705 z3 += z5;
00706 z4 += z5;
00707
00708 tmp0 += z1 + z3;
00709 tmp1 += z2 + z4;
00710 tmp2 += z2 + z3;
00711 tmp3 = z1 + z4;
00712 }
00713 } else {
00714 if (d1) {
00715
00716 z1 = d7 + d1;
00717 z3 = d7;
00718 z4 = d5 + d1;
00719 z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
00720
00721 tmp0 = MULTIPLY(d7, FIX_0_298631336);
00722 tmp1 = MULTIPLY(d5, FIX_2_053119869);
00723 tmp3 = MULTIPLY(d1, FIX_1_501321110);
00724 z1 = MULTIPLY(-z1, FIX_0_899976223);
00725 z2 = MULTIPLY(-d5, FIX_2_562915447);
00726 z3 = MULTIPLY(-d7, FIX_1_961570560);
00727 z4 = MULTIPLY(-z4, FIX_0_390180644);
00728
00729 z3 += z5;
00730 z4 += z5;
00731
00732 tmp0 += z1 + z3;
00733 tmp1 += z2 + z4;
00734 tmp2 = z2 + z3;
00735 tmp3 += z1 + z4;
00736 } else {
00737
00738 tmp0 = MULTIPLY(-d7, FIX_0_601344887);
00739 z1 = MULTIPLY(-d7, FIX_0_899976223);
00740 z3 = MULTIPLY(-d7, FIX_1_961570560);
00741 tmp1 = MULTIPLY(-d5, FIX_0_509795579);
00742 z2 = MULTIPLY(-d5, FIX_2_562915447);
00743 z4 = MULTIPLY(-d5, FIX_0_390180644);
00744 z5 = MULTIPLY(d5 + d7, FIX_1_175875602);
00745
00746 z3 += z5;
00747 z4 += z5;
00748
00749 tmp0 += z3;
00750 tmp1 += z4;
00751 tmp2 = z2 + z3;
00752 tmp3 = z1 + z4;
00753 }
00754 }
00755 } else {
00756 if (d3) {
00757 if (d1) {
00758
00759 z1 = d7 + d1;
00760 z3 = d7 + d3;
00761 z5 = MULTIPLY(z3 + d1, FIX_1_175875602);
00762
00763 tmp0 = MULTIPLY(d7, FIX_0_298631336);
00764 tmp2 = MULTIPLY(d3, FIX_3_072711026);
00765 tmp3 = MULTIPLY(d1, FIX_1_501321110);
00766 z1 = MULTIPLY(-z1, FIX_0_899976223);
00767 z2 = MULTIPLY(-d3, FIX_2_562915447);
00768 z3 = MULTIPLY(-z3, FIX_1_961570560);
00769 z4 = MULTIPLY(-d1, FIX_0_390180644);
00770
00771 z3 += z5;
00772 z4 += z5;
00773
00774 tmp0 += z1 + z3;
00775 tmp1 = z2 + z4;
00776 tmp2 += z2 + z3;
00777 tmp3 += z1 + z4;
00778 } else {
00779
00780 z3 = d7 + d3;
00781
00782 tmp0 = MULTIPLY(-d7, FIX_0_601344887);
00783 z1 = MULTIPLY(-d7, FIX_0_899976223);
00784 tmp2 = MULTIPLY(d3, FIX_0_509795579);
00785 z2 = MULTIPLY(-d3, FIX_2_562915447);
00786 z5 = MULTIPLY(z3, FIX_1_175875602);
00787 z3 = MULTIPLY(-z3, FIX_0_785694958);
00788
00789 tmp0 += z3;
00790 tmp1 = z2 + z5;
00791 tmp2 += z3;
00792 tmp3 = z1 + z5;
00793 }
00794 } else {
00795 if (d1) {
00796
00797 z1 = d7 + d1;
00798 z5 = MULTIPLY(z1, FIX_1_175875602);
00799
00800 z1 = MULTIPLY(z1, FIX_0_275899380);
00801 z3 = MULTIPLY(-d7, FIX_1_961570560);
00802 tmp0 = MULTIPLY(-d7, FIX_1_662939225);
00803 z4 = MULTIPLY(-d1, FIX_0_390180644);
00804 tmp3 = MULTIPLY(d1, FIX_1_111140466);
00805
00806 tmp0 += z1;
00807 tmp1 = z4 + z5;
00808 tmp2 = z3 + z5;
00809 tmp3 += z1;
00810 } else {
00811
00812 tmp0 = MULTIPLY(-d7, FIX_1_387039845);
00813 tmp1 = MULTIPLY(d7, FIX_1_175875602);
00814 tmp2 = MULTIPLY(-d7, FIX_0_785694958);
00815 tmp3 = MULTIPLY(d7, FIX_0_275899380);
00816 }
00817 }
00818 }
00819 } else {
00820 if (d5) {
00821 if (d3) {
00822 if (d1) {
00823
00824 z2 = d5 + d3;
00825 z4 = d5 + d1;
00826 z5 = MULTIPLY(d3 + z4, FIX_1_175875602);
00827
00828 tmp1 = MULTIPLY(d5, FIX_2_053119869);
00829 tmp2 = MULTIPLY(d3, FIX_3_072711026);
00830 tmp3 = MULTIPLY(d1, FIX_1_501321110);
00831 z1 = MULTIPLY(-d1, FIX_0_899976223);
00832 z2 = MULTIPLY(-z2, FIX_2_562915447);
00833 z3 = MULTIPLY(-d3, FIX_1_961570560);
00834 z4 = MULTIPLY(-z4, FIX_0_390180644);
00835
00836 z3 += z5;
00837 z4 += z5;
00838
00839 tmp0 = z1 + z3;
00840 tmp1 += z2 + z4;
00841 tmp2 += z2 + z3;
00842 tmp3 += z1 + z4;
00843 } else {
00844
00845 z2 = d5 + d3;
00846
00847 z5 = MULTIPLY(z2, FIX_1_175875602);
00848 tmp1 = MULTIPLY(d5, FIX_1_662939225);
00849 z4 = MULTIPLY(-d5, FIX_0_390180644);
00850 z2 = MULTIPLY(-z2, FIX_1_387039845);
00851 tmp2 = MULTIPLY(d3, FIX_1_111140466);
00852 z3 = MULTIPLY(-d3, FIX_1_961570560);
00853
00854 tmp0 = z3 + z5;
00855 tmp1 += z2;
00856 tmp2 += z2;
00857 tmp3 = z4 + z5;
00858 }
00859 } else {
00860 if (d1) {
00861
00862 z4 = d5 + d1;
00863
00864 z5 = MULTIPLY(z4, FIX_1_175875602);
00865 z1 = MULTIPLY(-d1, FIX_0_899976223);
00866 tmp3 = MULTIPLY(d1, FIX_0_601344887);
00867 tmp1 = MULTIPLY(-d5, FIX_0_509795579);
00868 z2 = MULTIPLY(-d5, FIX_2_562915447);
00869 z4 = MULTIPLY(z4, FIX_0_785694958);
00870
00871 tmp0 = z1 + z5;
00872 tmp1 += z4;
00873 tmp2 = z2 + z5;
00874 tmp3 += z4;
00875 } else {
00876
00877 tmp0 = MULTIPLY(d5, FIX_1_175875602);
00878 tmp1 = MULTIPLY(d5, FIX_0_275899380);
00879 tmp2 = MULTIPLY(-d5, FIX_1_387039845);
00880 tmp3 = MULTIPLY(d5, FIX_0_785694958);
00881 }
00882 }
00883 } else {
00884 if (d3) {
00885 if (d1) {
00886
00887 z5 = d1 + d3;
00888 tmp3 = MULTIPLY(d1, FIX_0_211164243);
00889 tmp2 = MULTIPLY(-d3, FIX_1_451774981);
00890 z1 = MULTIPLY(d1, FIX_1_061594337);
00891 z2 = MULTIPLY(-d3, FIX_2_172734803);
00892 z4 = MULTIPLY(z5, FIX_0_785694958);
00893 z5 = MULTIPLY(z5, FIX_1_175875602);
00894
00895 tmp0 = z1 - z4;
00896 tmp1 = z2 + z4;
00897 tmp2 += z5;
00898 tmp3 += z5;
00899 } else {
00900
00901 tmp0 = MULTIPLY(-d3, FIX_0_785694958);
00902 tmp1 = MULTIPLY(-d3, FIX_1_387039845);
00903 tmp2 = MULTIPLY(-d3, FIX_0_275899380);
00904 tmp3 = MULTIPLY(d3, FIX_1_175875602);
00905 }
00906 } else {
00907 if (d1) {
00908
00909 tmp0 = MULTIPLY(d1, FIX_0_275899380);
00910 tmp1 = MULTIPLY(d1, FIX_0_785694958);
00911 tmp2 = MULTIPLY(d1, FIX_1_175875602);
00912 tmp3 = MULTIPLY(d1, FIX_1_387039845);
00913 } else {
00914
00915 tmp0 = tmp1 = tmp2 = tmp3 = 0;
00916 }
00917 }
00918 }
00919 }
00920
00921
00922
00923 dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp3,
00924 CONST_BITS+PASS1_BITS+3);
00925 dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp10 - tmp3,
00926 CONST_BITS+PASS1_BITS+3);
00927 dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp11 + tmp2,
00928 CONST_BITS+PASS1_BITS+3);
00929 dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(tmp11 - tmp2,
00930 CONST_BITS+PASS1_BITS+3);
00931 dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(tmp12 + tmp1,
00932 CONST_BITS+PASS1_BITS+3);
00933 dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp12 - tmp1,
00934 CONST_BITS+PASS1_BITS+3);
00935 dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp13 + tmp0,
00936 CONST_BITS+PASS1_BITS+3);
00937 dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp13 - tmp0,
00938 CONST_BITS+PASS1_BITS+3);
00939
00940 dataptr++;
00941 }
00942 }
00943
00944 #undef DCTSIZE
00945 #define DCTSIZE 4
00946 #define DCTSTRIDE 8
00947
00948 void j_rev_dct4(DCTBLOCK data)
00949 {
00950 int32_t tmp0, tmp1, tmp2, tmp3;
00951 int32_t tmp10, tmp11, tmp12, tmp13;
00952 int32_t z1;
00953 int32_t d0, d2, d4, d6;
00954 register DCTELEM *dataptr;
00955 int rowctr;
00956
00957
00958
00959
00960
00961 data[0] += 4;
00962
00963 dataptr = data;
00964
00965 for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975 register int *idataptr = (int*)dataptr;
00976
00977 d0 = dataptr[0];
00978 d2 = dataptr[1];
00979 d4 = dataptr[2];
00980 d6 = dataptr[3];
00981
00982 if ((d2 | d4 | d6) == 0) {
00983
00984 if (d0) {
00985
00986 DCTELEM dcval = (DCTELEM) (d0 << PASS1_BITS);
00987 register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000);
00988
00989 idataptr[0] = v;
00990 idataptr[1] = v;
00991 }
00992
00993 dataptr += DCTSTRIDE;
00994 continue;
00995 }
00996
00997
00998
00999 if (d6) {
01000 if (d2) {
01001
01002 z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
01003 tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
01004 tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
01005
01006 tmp0 = (d0 + d4) << CONST_BITS;
01007 tmp1 = (d0 - d4) << CONST_BITS;
01008
01009 tmp10 = tmp0 + tmp3;
01010 tmp13 = tmp0 - tmp3;
01011 tmp11 = tmp1 + tmp2;
01012 tmp12 = tmp1 - tmp2;
01013 } else {
01014
01015 tmp2 = MULTIPLY(-d6, FIX_1_306562965);
01016 tmp3 = MULTIPLY(d6, FIX_0_541196100);
01017
01018 tmp0 = (d0 + d4) << CONST_BITS;
01019 tmp1 = (d0 - d4) << CONST_BITS;
01020
01021 tmp10 = tmp0 + tmp3;
01022 tmp13 = tmp0 - tmp3;
01023 tmp11 = tmp1 + tmp2;
01024 tmp12 = tmp1 - tmp2;
01025 }
01026 } else {
01027 if (d2) {
01028
01029 tmp2 = MULTIPLY(d2, FIX_0_541196100);
01030 tmp3 = MULTIPLY(d2, FIX_1_306562965);
01031
01032 tmp0 = (d0 + d4) << CONST_BITS;
01033 tmp1 = (d0 - d4) << CONST_BITS;
01034
01035 tmp10 = tmp0 + tmp3;
01036 tmp13 = tmp0 - tmp3;
01037 tmp11 = tmp1 + tmp2;
01038 tmp12 = tmp1 - tmp2;
01039 } else {
01040
01041 tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
01042 tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
01043 }
01044 }
01045
01046
01047
01048 dataptr[0] = (DCTELEM) DESCALE(tmp10, CONST_BITS-PASS1_BITS);
01049 dataptr[1] = (DCTELEM) DESCALE(tmp11, CONST_BITS-PASS1_BITS);
01050 dataptr[2] = (DCTELEM) DESCALE(tmp12, CONST_BITS-PASS1_BITS);
01051 dataptr[3] = (DCTELEM) DESCALE(tmp13, CONST_BITS-PASS1_BITS);
01052
01053 dataptr += DCTSTRIDE;
01054 }
01055
01056
01057
01058
01059
01060 dataptr = data;
01061 for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
01062
01063
01064
01065
01066
01067
01068
01069
01070 d0 = dataptr[DCTSTRIDE*0];
01071 d2 = dataptr[DCTSTRIDE*1];
01072 d4 = dataptr[DCTSTRIDE*2];
01073 d6 = dataptr[DCTSTRIDE*3];
01074
01075
01076
01077 if (d6) {
01078 if (d2) {
01079
01080 z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
01081 tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
01082 tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
01083
01084 tmp0 = (d0 + d4) << CONST_BITS;
01085 tmp1 = (d0 - d4) << CONST_BITS;
01086
01087 tmp10 = tmp0 + tmp3;
01088 tmp13 = tmp0 - tmp3;
01089 tmp11 = tmp1 + tmp2;
01090 tmp12 = tmp1 - tmp2;
01091 } else {
01092
01093 tmp2 = MULTIPLY(-d6, FIX_1_306562965);
01094 tmp3 = MULTIPLY(d6, FIX_0_541196100);
01095
01096 tmp0 = (d0 + d4) << CONST_BITS;
01097 tmp1 = (d0 - d4) << CONST_BITS;
01098
01099 tmp10 = tmp0 + tmp3;
01100 tmp13 = tmp0 - tmp3;
01101 tmp11 = tmp1 + tmp2;
01102 tmp12 = tmp1 - tmp2;
01103 }
01104 } else {
01105 if (d2) {
01106
01107 tmp2 = MULTIPLY(d2, FIX_0_541196100);
01108 tmp3 = MULTIPLY(d2, FIX_1_306562965);
01109
01110 tmp0 = (d0 + d4) << CONST_BITS;
01111 tmp1 = (d0 - d4) << CONST_BITS;
01112
01113 tmp10 = tmp0 + tmp3;
01114 tmp13 = tmp0 - tmp3;
01115 tmp11 = tmp1 + tmp2;
01116 tmp12 = tmp1 - tmp2;
01117 } else {
01118
01119 tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
01120 tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
01121 }
01122 }
01123
01124
01125
01126 dataptr[DCTSTRIDE*0] = tmp10 >> (CONST_BITS+PASS1_BITS+3);
01127 dataptr[DCTSTRIDE*1] = tmp11 >> (CONST_BITS+PASS1_BITS+3);
01128 dataptr[DCTSTRIDE*2] = tmp12 >> (CONST_BITS+PASS1_BITS+3);
01129 dataptr[DCTSTRIDE*3] = tmp13 >> (CONST_BITS+PASS1_BITS+3);
01130
01131 dataptr++;
01132 }
01133 }
01134
01135 void j_rev_dct2(DCTBLOCK data){
01136 int d00, d01, d10, d11;
01137
01138 data[0] += 4;
01139 d00 = data[0+0*DCTSTRIDE] + data[1+0*DCTSTRIDE];
01140 d01 = data[0+0*DCTSTRIDE] - data[1+0*DCTSTRIDE];
01141 d10 = data[0+1*DCTSTRIDE] + data[1+1*DCTSTRIDE];
01142 d11 = data[0+1*DCTSTRIDE] - data[1+1*DCTSTRIDE];
01143
01144 data[0+0*DCTSTRIDE]= (d00 + d10)>>3;
01145 data[1+0*DCTSTRIDE]= (d01 + d11)>>3;
01146 data[0+1*DCTSTRIDE]= (d00 - d10)>>3;
01147 data[1+1*DCTSTRIDE]= (d01 - d11)>>3;
01148 }
01149
01150 void j_rev_dct1(DCTBLOCK data){
01151 data[0] = (data[0] + 4)>>3;
01152 }
01153
01154 #undef FIX
01155 #undef CONST_BITS