comparison simple_idct.c @ 633:e7b72c1dfa1b libavcodec

dct-test update test simple-idct and ijg int DCT too do tests with random & sparse matrixes print systematic error matrixes
author michaelni
date Sun, 01 Sep 2002 09:33:05 +0000
parents 2bf17a142cf4
children 4263629270c8
comparison
equal deleted inserted replaced
632:f5e68f32069f 633:e7b72c1dfa1b
23 */ 23 */
24 #include "avcodec.h" 24 #include "avcodec.h"
25 #include "dsputil.h" 25 #include "dsputil.h"
26 #include "simple_idct.h" 26 #include "simple_idct.h"
27 27
28 //#define ARCH_ALPHA
29
28 #if 0 30 #if 0
29 #define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */ 31 #define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */
30 #define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */ 32 #define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */
31 #define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */ 33 #define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */
32 #define W4 2048 /* 2048*sqrt (2)*cos (4*pi/16) */ 34 #define W4 2048 /* 2048*sqrt (2)*cos (4*pi/16) */
81 if (lrow[1] == 0) { 83 if (lrow[1] == 0) {
82 if (lrow[0] == 0) 84 if (lrow[0] == 0)
83 return 0; 85 return 0;
84 if ((lrow[0] & ~0xffffULL) == 0) { 86 if ((lrow[0] & ~0xffffULL) == 0) {
85 uint64_t v; 87 uint64_t v;
86 88 #if 1 //is ok if |a0| < 1024 than theres an +-1 error (for the *W4 case for W4=16383 !!!)
89 a0 = row[0]<<3;
90 #else
87 a0 = W4 * row[0]; 91 a0 = W4 * row[0];
88 a0 += 1 << (ROW_SHIFT - 1); 92 a0 += 1 << (ROW_SHIFT - 1);
89 a0 >>= ROW_SHIFT; 93 a0 >>= ROW_SHIFT;
94 #endif
90 v = (uint16_t) a0; 95 v = (uint16_t) a0;
91 v += v << 16; 96 v += v << 16;
92 v += v << 32; 97 v += v << 32;
93 lrow[0] = v; 98 lrow[0] = v;
94 lrow[1] = v; 99 lrow[1] = v;
476 dest[0] = cm[dest[0] + ((a1 - b1) >> COL_SHIFT)]; 481 dest[0] = cm[dest[0] + ((a1 - b1) >> COL_SHIFT)];
477 dest += line_size; 482 dest += line_size;
478 dest[0] = cm[dest[0] + ((a0 - b0) >> COL_SHIFT)]; 483 dest[0] = cm[dest[0] + ((a0 - b0) >> COL_SHIFT)];
479 } 484 }
480 485
486 static inline void idctSparseCol (int16_t * col)
487 {
488 int a0, a1, a2, a3, b0, b1, b2, b3;
489 UINT8 *cm = cropTbl + MAX_NEG_CROP;
490
491 /* XXX: I did that only to give same values as previous code */
492 a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
493 a1 = a0;
494 a2 = a0;
495 a3 = a0;
496
497 a0 += + W2*col[8*2];
498 a1 += + W6*col[8*2];
499 a2 += - W6*col[8*2];
500 a3 += - W2*col[8*2];
501
502 MUL16(b0, W1, col[8*1]);
503 MUL16(b1, W3, col[8*1]);
504 MUL16(b2, W5, col[8*1]);
505 MUL16(b3, W7, col[8*1]);
506
507 MAC16(b0, + W3, col[8*3]);
508 MAC16(b1, - W7, col[8*3]);
509 MAC16(b2, - W1, col[8*3]);
510 MAC16(b3, - W5, col[8*3]);
511
512 if(col[8*4]){
513 a0 += + W4*col[8*4];
514 a1 += - W4*col[8*4];
515 a2 += - W4*col[8*4];
516 a3 += + W4*col[8*4];
517 }
518
519 if (col[8*5]) {
520 MAC16(b0, + W5, col[8*5]);
521 MAC16(b1, - W1, col[8*5]);
522 MAC16(b2, + W7, col[8*5]);
523 MAC16(b3, + W3, col[8*5]);
524 }
525
526 if(col[8*6]){
527 a0 += + W6*col[8*6];
528 a1 += - W2*col[8*6];
529 a2 += + W2*col[8*6];
530 a3 += - W6*col[8*6];
531 }
532
533 if (col[8*7]) {
534 MAC16(b0, + W7, col[8*7]);
535 MAC16(b1, - W5, col[8*7]);
536 MAC16(b2, + W3, col[8*7]);
537 MAC16(b3, - W1, col[8*7]);
538 }
539
540 col[0 ] = ((a0 + b0) >> COL_SHIFT);
541 col[8 ] = ((a1 + b1) >> COL_SHIFT);
542 col[16] = ((a2 + b2) >> COL_SHIFT);
543 col[24] = ((a3 + b3) >> COL_SHIFT);
544 col[32] = ((a3 - b3) >> COL_SHIFT);
545 col[40] = ((a2 - b2) >> COL_SHIFT);
546 col[48] = ((a1 - b1) >> COL_SHIFT);
547 col[56] = ((a0 - b0) >> COL_SHIFT);
548 }
549
550
481 #ifdef ARCH_ALPHA 551 #ifdef ARCH_ALPHA
482 /* If all rows but the first one are zero after row transformation, 552 /* If all rows but the first one are zero after row transformation,
483 all rows will be identical after column transformation. */ 553 all rows will be identical after column transformation. */
484 static inline void idctCol2(int16_t *col) 554 static inline void idctCol2(int16_t *col)
485 { 555 {
576 646
577 for(i=0; i<8; i++) 647 for(i=0; i<8; i++)
578 idctSparseColAdd(dest + i, line_size, block + i); 648 idctSparseColAdd(dest + i, line_size, block + i);
579 } 649 }
580 650
651 void simple_idct(INT16 *block)
652 {
653 int i;
654 for(i=0; i<8; i++)
655 idctRowCondDC(block + i*8);
656
657 for(i=0; i<8; i++)
658 idctSparseCol(block + i);
659 }
660
581 #endif 661 #endif
582 662
583 #undef COL_SHIFT 663 #undef COL_SHIFT