Mercurial > libavcodec.hg
comparison simple_idct.c @ 719:2b7ff6dfee35 libavcodec
first version of IDCT248 for DV decoding support
| author | bellard |
|---|---|
| date | Thu, 03 Oct 2002 13:41:33 +0000 |
| parents | 4263629270c8 |
| children | ff90043f4a2d |
comparison
equal
deleted
inserted
replaced
| 718:16dab8296293 | 719:2b7ff6dfee35 |
|---|---|
| 657 idctSparseCol(block + i); | 657 idctSparseCol(block + i); |
| 658 } | 658 } |
| 659 | 659 |
| 660 #endif | 660 #endif |
| 661 | 661 |
| 662 #undef COL_SHIFT | 662 /* 2x4x8 idct */ |
| 663 | |
| 664 #define CN_SHIFT 12 | |
| 665 #define C_FIX(x) ((int)((x) * (1 << CN_SHIFT) + 0.5)) | |
| 666 #define C0 C_FIX(0.7071067811) | |
| 667 #define C1 C_FIX(0.9238795324) | |
| 668 #define C2 C_FIX(0.3826834324) | |
| 669 | |
| 670 /* row idct is multiple by 16 * sqrt(2.0), col idct4 is multiplied by | |
| 671 sqrt(2). An extra division by two is needed for the first butterfly | |
| 672 stage */ | |
| 673 #define C_SHIFT (4+1+12+1) | |
| 674 | |
| 675 static inline void idct4col(UINT8 *dest, int line_size, const INT16 *col) | |
| 676 { | |
| 677 int c0, c1, c2, c3, a0, a1, a2, a3; | |
| 678 const UINT8 *cm = cropTbl + MAX_NEG_CROP; | |
| 679 | |
| 680 a0 = col[8*0]; | |
| 681 a1 = col[8*2]; | |
| 682 a2 = col[8*4]; | |
| 683 a3 = col[8*6]; | |
| 684 c0 = (a0 + a2) * C0 + (1 << (C_SHIFT - 1)) + (128 << C_SHIFT); | |
| 685 c2 = (a0 - a2) * C0 + (1 << (C_SHIFT - 1)) + (128 << C_SHIFT); | |
| 686 c1 = a1 * C1 + a3 * C2; | |
| 687 c3 = a1 * C2 - a3 * C1; | |
| 688 dest[0] = cm[(c0 + c1) >> C_SHIFT]; | |
| 689 dest += line_size; | |
| 690 dest[0] = cm[(c2 + c3) >> C_SHIFT]; | |
| 691 dest += line_size; | |
| 692 dest[0] = cm[(c2 - c3) >> C_SHIFT]; | |
| 693 dest += line_size; | |
| 694 dest[0] = cm[(c0 - c1) >> C_SHIFT]; | |
| 695 } | |
| 696 | |
| 697 #define BF(k) \ | |
| 698 {\ | |
| 699 int a0, a1;\ | |
| 700 a0 = ptr[k];\ | |
| 701 a1 = ptr[8 + k];\ | |
| 702 ptr[k] = a0 + a1;\ | |
| 703 ptr[8 + k] = a0 - a1;\ | |
| 704 } | |
| 705 | |
| 706 /* only used by DV codec. The input must be interlaced. 128 is added | |
| 707 to the pixels before clamping to avoid systematic error | |
| 708 (1024*sqrt(2)) offset would be needed otherwise. */ | |
| 709 /* XXX: I think a 1.0/sqrt(2) normalization should be needed to | |
| 710 compensate the extra butterfly stage - I don't have the full DV | |
| 711 specification */ | |
| 712 void simple_idct248_put(UINT8 *dest, int line_size, INT16 *block) | |
| 713 { | |
| 714 int i; | |
| 715 INT16 *ptr; | |
| 716 | |
| 717 /* butterfly */ | |
| 718 ptr = block; | |
| 719 for(i=0;i<4;i++) { | |
| 720 BF(0); | |
| 721 BF(1); | |
| 722 BF(2); | |
| 723 BF(3); | |
| 724 BF(4); | |
| 725 BF(5); | |
| 726 BF(6); | |
| 727 BF(7); | |
| 728 ptr += 2 * 8; | |
| 729 } | |
| 730 | |
| 731 /* IDCT8 on each line */ | |
| 732 for(i=0; i<8; i++) { | |
| 733 idctRowCondDC(block + i*8); | |
| 734 } | |
| 735 | |
| 736 /* IDCT4 and store */ | |
| 737 for(i=0;i<8;i++) { | |
| 738 idct4col(dest + i, 2 * line_size, block + i); | |
| 739 idct4col(dest + line_size + i, 2 * line_size, block + 8 + i); | |
| 740 } | |
| 741 } |
