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