Showing the changes to test/encoder/EncUT_EncoderMbAux.cpp (1 of 85 files). Show all
Unified · Split
| @@ -9,229 +9,230 @@ using namespace WelsSVCEnc; · 8 unmodified lines | |||
| 9 | 9 | ||
| 10 | #define ALLOC_MEMORY(type, name, num) type* name = (type*)cMemoryAlign.WelsMalloc(num*sizeof(type), #name); | 10 | #define ALLOC_MEMORY(type, name, num) type* name = (type*)cMemoryAlign.WelsMalloc(num*sizeof(type), #name); |
| 11 | #define FREE_MEMORY(name) cMemoryAlign.WelsFree(name, #name); | 11 | #define FREE_MEMORY(name) cMemoryAlign.WelsFree(name, #name); |
| 12 | TEST(EncodeMbAuxTest, TestScan_4x4_ac_c) { | 12 | TEST (EncodeMbAuxTest, TestScan_4x4_ac_c) { |
| 13 | CMemoryAlign cMemoryAlign(0); | 13 | CMemoryAlign cMemoryAlign (0); |
| 14 | ALLOC_MEMORY(int16_t, iLevel, 16); | 14 | ALLOC_MEMORY (int16_t, iLevel, 16); |
| 15 | ALLOC_MEMORY(int16_t, iDctA, 16); | 15 | ALLOC_MEMORY (int16_t, iDctA, 16); |
| 16 | ALLOC_MEMORY(int16_t, iDctB, 16); | 16 | ALLOC_MEMORY (int16_t, iDctB, 16); |
| 17 | srand((unsigned int)time(NULL)); | 17 | srand ((unsigned int)time (NULL)); |
| 18 | for(int i=0;i<16;i++) { | 18 | for (int i = 0; i < 16; i++) { |
| 19 | iDctA[i]=rand()%256+1; | 19 | iDctA[i] = rand() % 256 + 1; |
| 20 | iDctB[i]=iDctA[i]; | 20 | iDctB[i] = iDctA[i]; |
| 21 | } | 21 | } |
| 22 | WelsScan4x4Ac_c( iLevel, iDctA ); | 22 | WelsScan4x4Ac_c (iLevel, iDctA); |
| 23 | EXPECT_EQ(iLevel[0],iDctB[1]); | 23 | EXPECT_EQ (iLevel[0], iDctB[1]); |
| 24 | EXPECT_EQ(iLevel[1],iDctB[4]); | 24 | EXPECT_EQ (iLevel[1], iDctB[4]); |
| 25 | EXPECT_EQ(iLevel[2],iDctB[8]); | 25 | EXPECT_EQ (iLevel[2], iDctB[8]); |
| 26 | EXPECT_EQ(iLevel[3],iDctB[5]); | 26 | EXPECT_EQ (iLevel[3], iDctB[5]); |
| 27 | EXPECT_EQ(iLevel[4],iDctB[2]); | 27 | EXPECT_EQ (iLevel[4], iDctB[2]); |
| 28 | EXPECT_EQ(iLevel[5],iDctB[3]); | 28 | EXPECT_EQ (iLevel[5], iDctB[3]); |
| 29 | EXPECT_EQ(iLevel[6],iDctB[6]); | 29 | EXPECT_EQ (iLevel[6], iDctB[6]); |
| 30 | EXPECT_EQ(iLevel[7],iDctB[9]); | 30 | EXPECT_EQ (iLevel[7], iDctB[9]); |
| 31 | EXPECT_EQ(iLevel[8],iDctB[12]); | 31 | EXPECT_EQ (iLevel[8], iDctB[12]); |
| 32 | EXPECT_EQ(iLevel[9],iDctB[13]); | 32 | EXPECT_EQ (iLevel[9], iDctB[13]); |
| 33 | EXPECT_EQ(iLevel[10],iDctB[10]); | 33 | EXPECT_EQ (iLevel[10], iDctB[10]); |
| 34 | EXPECT_EQ(iLevel[11],iDctB[7]); | 34 | EXPECT_EQ (iLevel[11], iDctB[7]); |
| 35 | EXPECT_EQ(iLevel[12],iDctB[11]); | 35 | EXPECT_EQ (iLevel[12], iDctB[11]); |
| 36 | EXPECT_EQ(iLevel[13],iDctB[14]); | 36 | EXPECT_EQ (iLevel[13], iDctB[14]); |
| 37 | EXPECT_EQ(iLevel[14],iDctB[15]); | 37 | EXPECT_EQ (iLevel[14], iDctB[15]); |
| 38 | EXPECT_EQ(iLevel[15],0); | 38 | EXPECT_EQ (iLevel[15], 0); |
| 39 | FREE_MEMORY(iLevel); | 39 | FREE_MEMORY (iLevel); |
| 40 | FREE_MEMORY(iDctA); | 40 | FREE_MEMORY (iDctA); |
| 41 | FREE_MEMORY(iDctB); | 41 | FREE_MEMORY (iDctB); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | #ifdef X86_ASM | 44 | #ifdef X86_ASM |
| 45 | TEST(EncodeMbAuxTest, TestScan_4x4_ac_sse2) { | 45 | TEST (EncodeMbAuxTest, TestScan_4x4_ac_sse2) { |
| 46 | CMemoryAlign cMemoryAlign(0); | 46 | CMemoryAlign cMemoryAlign (0); |
| 47 | ALLOC_MEMORY(int16_t, iLevelA, 16); | 47 | ALLOC_MEMORY (int16_t, iLevelA, 16); |
| 48 | ALLOC_MEMORY(int16_t, iLevelB, 16); | 48 | ALLOC_MEMORY (int16_t, iLevelB, 16); |
| 49 | ALLOC_MEMORY(int16_t, iDct, 16); | 49 | ALLOC_MEMORY (int16_t, iDct, 16); |
| 50 | srand((unsigned int)time(NULL)); | 50 | srand ((unsigned int)time (NULL)); |
| 51 | for(int i=0;i<16;i++) { | 51 | for (int i = 0; i < 16; i++) { |
| 52 | iDct[i]=rand()%256+1; | 52 | iDct[i] = rand() % 256 + 1; |
| 53 | } | 53 | } |
| 54 | WelsScan4x4Ac_c( iLevelA, iDct ); | 54 | WelsScan4x4Ac_c (iLevelA, iDct); |
| 55 | WelsScan4x4Ac_sse2( iLevelB, iDct ); | 55 | WelsScan4x4Ac_sse2 (iLevelB, iDct); |
| 56 | for(int j=0; j<16;j++) | 56 | for (int j = 0; j < 16; j++) |
| 57 | EXPECT_EQ(iLevelA[j], iLevelB[j]); | 57 | EXPECT_EQ (iLevelA[j], iLevelB[j]); |
| 58 | FREE_MEMORY(iLevelA); | 58 | FREE_MEMORY (iLevelA); |
| 59 | FREE_MEMORY(iLevelB); | 59 | FREE_MEMORY (iLevelB); |
| 60 | FREE_MEMORY(iDct); | 60 | FREE_MEMORY (iDct); |
| 61 | } | 61 | } |
| 62 | TEST(EncodeMbAuxTest, WelsScan4x4DcAc_sse2) { | 62 | TEST (EncodeMbAuxTest, WelsScan4x4DcAc_sse2) { |
| 63 | CMemoryAlign cMemoryAlign(0); | 63 | CMemoryAlign cMemoryAlign (0); |
| 64 | ALLOC_MEMORY(int16_t, iLevelA, 32); | 64 | ALLOC_MEMORY (int16_t, iLevelA, 32); |
| 65 | ALLOC_MEMORY(int16_t, iLevelB, 32); | 65 | ALLOC_MEMORY (int16_t, iLevelB, 32); |
| 66 | ALLOC_MEMORY(int16_t, iDct, 32); | 66 | ALLOC_MEMORY (int16_t, iDct, 32); |
| 67 | srand((unsigned int)time(NULL)); | 67 | srand ((unsigned int)time (NULL)); |
| 68 | for(int i = 0; i < 32; i++) | 68 | for (int i = 0; i < 32; i++) |
| 69 | iDct[i] = (rand() & 32767) - 16384; | 69 | iDct[i] = (rand() & 32767) - 16384; |
| 70 | WelsScan4x4DcAc_sse2(iLevelA, iDct); | 70 | WelsScan4x4DcAc_sse2 (iLevelA, iDct); |
| 71 | WelsScan4x4DcAc_c(iLevelB, iDct); | 71 | WelsScan4x4DcAc_c (iLevelB, iDct); |
| 72 | for(int i = 0; i < 16; i++) | 72 | for (int i = 0; i < 16; i++) |
| 73 | EXPECT_EQ(iLevelA[i], iLevelB[i]); | 73 | EXPECT_EQ (iLevelA[i], iLevelB[i]); |
| 74 | FREE_MEMORY(iLevelA); | 74 | FREE_MEMORY (iLevelA); |
| 75 | FREE_MEMORY(iLevelB); | 75 | FREE_MEMORY (iLevelB); |
| 76 | FREE_MEMORY(iDct); | 76 | FREE_MEMORY (iDct); |
| 77 | } | 77 | } |
| 78 | #endif | 78 | #endif |
| 79 | TEST(EncodeMbAuxTest, TestScan_4x4_dcc) { | 79 | TEST (EncodeMbAuxTest, TestScan_4x4_dcc) { |
| 80 | CMemoryAlign cMemoryAlign(0); | 80 | CMemoryAlign cMemoryAlign (0); |
| 81 | ALLOC_MEMORY(int16_t, iLevel, 16); | 81 | ALLOC_MEMORY (int16_t, iLevel, 16); |
| 82 | ALLOC_MEMORY(int16_t, iDctA, 16); | 82 | ALLOC_MEMORY (int16_t, iDctA, 16); |
| 83 | ALLOC_MEMORY(int16_t, iDctB, 16); | 83 | ALLOC_MEMORY (int16_t, iDctB, 16); |
| 84 | srand((unsigned int)time(NULL)); | 84 | srand ((unsigned int)time (NULL)); |
| 85 | for(int i=0;i<16;i++) | 85 | for (int i = 0; i < 16; i++) |
| 86 | iDctA[i] = iDctB[i] = rand()%256+1; | 86 | iDctA[i] = iDctB[i] = rand() % 256 + 1; |
| 87 | WelsScan4x4Dc( iLevel, iDctA ); | 87 | WelsScan4x4Dc (iLevel, iDctA); |
| 88 | EXPECT_EQ(iLevel[0],iDctB[0]); | 88 | EXPECT_EQ (iLevel[0], iDctB[0]); |
| 89 | EXPECT_EQ(iLevel[1],iDctB[1]); | 89 | EXPECT_EQ (iLevel[1], iDctB[1]); |
| 90 | EXPECT_EQ(iLevel[2],iDctB[4]); | 90 | EXPECT_EQ (iLevel[2], iDctB[4]); |
| 91 | EXPECT_EQ(iLevel[3],iDctB[8]); | 91 | EXPECT_EQ (iLevel[3], iDctB[8]); |
| 92 | EXPECT_EQ(iLevel[4],iDctB[5]); | 92 | EXPECT_EQ (iLevel[4], iDctB[5]); |
| 93 | EXPECT_EQ(iLevel[5],iDctB[2]); | 93 | EXPECT_EQ (iLevel[5], iDctB[2]); |
| 94 | EXPECT_EQ(iLevel[6],iDctB[3]); | 94 | EXPECT_EQ (iLevel[6], iDctB[3]); |
| 95 | EXPECT_EQ(iLevel[7],iDctB[6]); | 95 | EXPECT_EQ (iLevel[7], iDctB[6]); |
| 96 | EXPECT_EQ(iLevel[8],iDctB[9]); | 96 | EXPECT_EQ (iLevel[8], iDctB[9]); |
| 97 | EXPECT_EQ(iLevel[9],iDctB[12]); | 97 | EXPECT_EQ (iLevel[9], iDctB[12]); |
| 98 | EXPECT_EQ(iLevel[10],iDctB[13]); | 98 | EXPECT_EQ (iLevel[10], iDctB[13]); |
| 99 | EXPECT_EQ(iLevel[11],iDctB[10]); | 99 | EXPECT_EQ (iLevel[11], iDctB[10]); |
| 100 | EXPECT_EQ(iLevel[12],iDctB[7]); | 100 | EXPECT_EQ (iLevel[12], iDctB[7]); |
| 101 | EXPECT_EQ(iLevel[13],iDctB[11]); | 101 | EXPECT_EQ (iLevel[13], iDctB[11]); |
| 102 | EXPECT_EQ(iLevel[14],iDctB[14]); | 102 | EXPECT_EQ (iLevel[14], iDctB[14]); |
| 103 | EXPECT_EQ(iLevel[15],iDctB[15]); | 103 | EXPECT_EQ (iLevel[15], iDctB[15]); |
| 104 | FREE_MEMORY(iLevel); | 104 | FREE_MEMORY (iLevel); |
| 105 | FREE_MEMORY(iDctA); | 105 | FREE_MEMORY (iDctA); |
| 106 | FREE_MEMORY(iDctB); | 106 | FREE_MEMORY (iDctB); |
| 107 | } | 107 | } |
| 108 | static inline void PixelSubWH( int16_t *iDiff, int iSize, uint8_t *pPix1, int iStride1, uint8_t *pPix2, int iStride2 ) { | 108 | static inline void PixelSubWH (int16_t* iDiff, int iSize, uint8_t* pPix1, int iStride1, uint8_t* pPix2, int iStride2) { |
| 109 | int y, x; | 109 | int y, x; |
| 110 | for( y = 0; y < iSize; y++ ) { | 110 | for (y = 0; y < iSize; y++) { |
| 111 | for( x = 0; x < iSize; x++ ) | 111 | for (x = 0; x < iSize; x++) |
| 112 | iDiff[x + y*iSize] = pPix1[x] - pPix2[x]; | 112 | iDiff[x + y * iSize] = pPix1[x] - pPix2[x]; |
| 113 | pPix1 += iStride1; | 113 | pPix1 += iStride1; |
| 114 | pPix2 += iStride2; | 114 | pPix2 += iStride2; |
| 115 | } | ||
| 116 | } | 115 | } |
| 116 | } | ||
| 117 | 117 | ||
| 118 | #define FENC_STRIDE 16 | 118 | #define FENC_STRIDE 16 |
| 119 | #define FDEC_STRIDE 32 | 119 | #define FDEC_STRIDE 32 |
| 120 | static void Sub4x4DctAnchor( int16_t iDct[4][4], uint8_t *pPix1, uint8_t *pPix2 ) { | 120 | static void Sub4x4DctAnchor (int16_t iDct[4][4], uint8_t* pPix1, uint8_t* pPix2) { |
| 121 | int16_t iDiff[4][4]; | 121 | int16_t iDiff[4][4]; |
| 122 | int16_t tmp[4][4]; | 122 | int16_t tmp[4][4]; |
| 123 | int i; | 123 | int i; |
| 124 | PixelSubWH( (int16_t*)iDiff, 4, pPix1, FENC_STRIDE, pPix2, FDEC_STRIDE ); | 124 | PixelSubWH ((int16_t*)iDiff, 4, pPix1, FENC_STRIDE, pPix2, FDEC_STRIDE); |
| 125 | for( i = 0; i < 4; i++ ) { | 125 | for (i = 0; i < 4; i++) { |
| 126 | const int a03 = iDiff[i][0] + iDiff[i][3]; | 126 | const int a03 = iDiff[i][0] + iDiff[i][3]; |
| 127 | const int a12 = iDiff[i][1] + iDiff[i][2]; | 127 | const int a12 = iDiff[i][1] + iDiff[i][2]; |
| 128 | const int s03 = iDiff[i][0] - iDiff[i][3]; | 128 | const int s03 = iDiff[i][0] - iDiff[i][3]; |
| 129 | const int s12 = iDiff[i][1] - iDiff[i][2]; | 129 | const int s12 = iDiff[i][1] - iDiff[i][2]; |
| 130 | tmp[0][i] = a03 + a12; | 130 | tmp[0][i] = a03 + a12; |
| 131 | tmp[1][i] = 2*s03 + s12; | 131 | tmp[1][i] = 2 * s03 + s12; |
| 132 | tmp[2][i] = a03 - a12; | 132 | tmp[2][i] = a03 - a12; |
| 133 | tmp[3][i] = s03 - 2*s12; | 133 | tmp[3][i] = s03 - 2 * s12; |
| 134 | } | 134 | } |
| 135 | for( i = 0; i < 4; i++ ) { | 135 | for (i = 0; i < 4; i++) { |
| 136 | const int a03 = tmp[i][0] + tmp[i][3]; | 136 | const int a03 = tmp[i][0] + tmp[i][3]; |
| 137 | const int a12 = tmp[i][1] + tmp[i][2]; | 137 | const int a12 = tmp[i][1] + tmp[i][2]; |
| 138 | const int s03 = tmp[i][0] - tmp[i][3]; | 138 | const int s03 = tmp[i][0] - tmp[i][3]; |
| 139 | const int s12 = tmp[i][1] - tmp[i][2]; | 139 | const int s12 = tmp[i][1] - tmp[i][2]; |
| 140 | iDct[i][0] = a03 + a12; | 140 | iDct[i][0] = a03 + a12; |
| 141 | iDct[i][1] = 2*s03 + s12; | 141 | iDct[i][1] = 2 * s03 + s12; |
| 142 | iDct[i][2] = a03 - a12; | 142 | iDct[i][2] = a03 - a12; |
| 143 | iDct[i][3] = s03 - 2*s12; | 143 | iDct[i][3] = s03 - 2 * s12; |
| 144 | } | 144 | } |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | static void Sub8x8DctAnchor( int16_t iDct[4][4][4], uint8_t *pPix1, uint8_t *pPix2 ) { | 147 | static void Sub8x8DctAnchor (int16_t iDct[4][4][4], uint8_t* pPix1, uint8_t* pPix2) { |
| 148 | Sub4x4DctAnchor( iDct[0], &pPix1[0], &pPix2[0] ); | 148 | Sub4x4DctAnchor (iDct[0], &pPix1[0], &pPix2[0]); |
| 149 | Sub4x4DctAnchor( iDct[1], &pPix1[4], &pPix2[4] ); | 149 | Sub4x4DctAnchor (iDct[1], &pPix1[4], &pPix2[4]); |
| 150 | Sub4x4DctAnchor( iDct[2], &pPix1[4*FENC_STRIDE+0], &pPix2[4*FDEC_STRIDE+0] ); | 150 | Sub4x4DctAnchor (iDct[2], &pPix1[4 * FENC_STRIDE + 0], &pPix2[4 * FDEC_STRIDE + 0]); |
| 151 | Sub4x4DctAnchor( iDct[3], &pPix1[4*FENC_STRIDE+4], &pPix2[4*FDEC_STRIDE+4] ); | 151 | Sub4x4DctAnchor (iDct[3], &pPix1[4 * FENC_STRIDE + 4], &pPix2[4 * FDEC_STRIDE + 4]); |
| 152 | } | 152 | } |
| 153 | TEST(EncodeMbAuxTest, WelsDctT4_c) { | 153 | TEST (EncodeMbAuxTest, WelsDctT4_c) { |
| 154 | int16_t iDctRef[4][4]; | 154 | int16_t iDctRef[4][4]; |
| 155 | uint8_t uiPix1[16*FENC_STRIDE], uiPix2[16*FDEC_STRIDE]; | 155 | uint8_t uiPix1[16 * FENC_STRIDE], uiPix2[16 * FDEC_STRIDE]; |
| 156 | int16_t iDct[16]; | 156 | int16_t iDct[16]; |
| 157 | srand((unsigned int)time(NULL)); | 157 | srand ((unsigned int)time (NULL)); |
| 158 | for(int i = 0; i < 4; i++) | 158 | for (int i = 0; i < 4; i++) |
| 159 | for(int j = 0; j < 4; j++) | 159 | for (int j = 0; j < 4; j++) |
| 160 | uiPix1[i*FENC_STRIDE+j] = uiPix2[i*FDEC_STRIDE+j] = rand() & 255; | 160 | uiPix1[i * FENC_STRIDE + j] = uiPix2[i * FDEC_STRIDE + j] = rand() & 255; |
| 161 | Sub4x4DctAnchor(iDctRef, uiPix1, uiPix2); | 161 | Sub4x4DctAnchor (iDctRef, uiPix1, uiPix2); |
| 162 | WelsDctT4_c(iDct, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE); | 162 | WelsDctT4_c (iDct, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE); |
| 163 | for(int i = 0; i < 4; i++) | 163 | for (int i = 0; i < 4; i++) |
| 164 | for(int j = 0; j < 4; j++) | 164 | for (int j = 0; j < 4; j++) |
| 165 | EXPECT_EQ(iDctRef[j][i], iDct[i*4+j]); | 165 | EXPECT_EQ (iDctRef[j][i], iDct[i * 4 + j]); |
| 166 | } | 166 | } |
| 167 | TEST(EncodeMbAuxTest, WelsDctFourT4_c) { | 167 | TEST (EncodeMbAuxTest, WelsDctFourT4_c) { |
| 168 | int16_t iDctRef[4][4][4]; uint8_t uiPix1[16*FENC_STRIDE], uiPix2[16*FDEC_STRIDE]; | 168 | int16_t iDctRef[4][4][4]; |
| 169 | int16_t iDct[16*4]; | 169 | uint8_t uiPix1[16 * FENC_STRIDE], uiPix2[16 * FDEC_STRIDE]; |
| 170 | srand((unsigned int)time(NULL)); | 170 | int16_t iDct[16 * 4]; |
| 171 | for(int i = 0; i < 8; i++) | 171 | srand ((unsigned int)time (NULL)); |
| 172 | for(int j = 0; j < 8; j++) | 172 | for (int i = 0; i < 8; i++) |
| 173 | uiPix1[i*FENC_STRIDE+j] = uiPix2[i*FDEC_STRIDE+j] = rand() & 255; | 173 | for (int j = 0; j < 8; j++) |
| 174 | Sub8x8DctAnchor(iDctRef, uiPix1, uiPix2); | 174 | uiPix1[i * FENC_STRIDE + j] = uiPix2[i * FDEC_STRIDE + j] = rand() & 255; |
| 175 | WelsDctFourT4_c(iDct, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE); | 175 | Sub8x8DctAnchor (iDctRef, uiPix1, uiPix2); |
| 176 | for(int k = 0; k < 4; k++) | 176 | WelsDctFourT4_c (iDct, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE); |
| 177 | for(int i = 0; i < 4; i++) | 177 | for (int k = 0; k < 4; k++) |
| 178 | for(int j = 0; j < 4; j++) | 178 | for (int i = 0; i < 4; i++) |
| 179 | EXPECT_EQ(iDctRef[k][j][i], iDct[k*16+i*4+j]); | 179 | for (int j = 0; j < 4; j++) |
| 180 | EXPECT_EQ (iDctRef[k][j][i], iDct[k * 16 + i * 4 + j]); | ||
| 180 | } | 181 | } |
| 181 | 182 | ||
| 182 | #ifdef X86_ASM | 183 | #ifdef X86_ASM |
| 183 | TEST(EncodeMbAuxTest, WelsDctT4_mmx) { | 184 | TEST (EncodeMbAuxTest, WelsDctT4_mmx) { |
| 184 | int16_t iDctC[16], iDctM[16]; | 185 | int16_t iDctC[16], iDctM[16]; |
| 185 | uint8_t uiPix1[16*FENC_STRIDE], uiPix2[16*FDEC_STRIDE]; | 186 | uint8_t uiPix1[16 * FENC_STRIDE], uiPix2[16 * FDEC_STRIDE]; |
| 186 | srand((unsigned int)time(NULL)); | 187 | srand ((unsigned int)time (NULL)); |
| 187 | for(int i = 0; i < 4; i++) | 188 | for (int i = 0; i < 4; i++) |
| 188 | for(int j = 0; j < 4; j++) | 189 | for (int j = 0; j < 4; j++) |
| 189 | uiPix1[i*FENC_STRIDE+j] = uiPix2[i*FDEC_STRIDE+j] = rand() & 255; | 190 | uiPix1[i * FENC_STRIDE + j] = uiPix2[i * FDEC_STRIDE + j] = rand() & 255; |
| 190 | WelsDctT4_c(iDctC, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE); | 191 | WelsDctT4_c (iDctC, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE); |
| 191 | WelsDctT4_mmx(iDctM, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE); | 192 | WelsDctT4_mmx (iDctM, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE); |
| 192 | for(int i = 0; i < 16; i++) | 193 | for (int i = 0; i < 16; i++) |
| 193 | EXPECT_EQ(iDctC[i], iDctM[i]); | 194 | EXPECT_EQ (iDctC[i], iDctM[i]); |
| 194 | } | 195 | } |
| 195 | 196 | ||
| 196 | TEST(EncodeMbAuxTest, WelsDctFourT4_sse2) { | 197 | TEST (EncodeMbAuxTest, WelsDctFourT4_sse2) { |
| 197 | CMemoryAlign cMemoryAlign(0); | 198 | CMemoryAlign cMemoryAlign (0); |
| 198 | ALLOC_MEMORY(uint8_t, uiPix1, 16*FENC_STRIDE); | 199 | ALLOC_MEMORY (uint8_t, uiPix1, 16 * FENC_STRIDE); |
| 199 | ALLOC_MEMORY(uint8_t, uiPix2, 16*FDEC_STRIDE); | 200 | ALLOC_MEMORY (uint8_t, uiPix2, 16 * FDEC_STRIDE); |
| 200 | ALLOC_MEMORY(int16_t, iDctC, 16*4); | 201 | ALLOC_MEMORY (int16_t, iDctC, 16 * 4); |
| 201 | ALLOC_MEMORY(int16_t, iDctS, 16*4); | 202 | ALLOC_MEMORY (int16_t, iDctS, 16 * 4); |
| 202 | srand((unsigned int)time(NULL)); | 203 | srand ((unsigned int)time (NULL)); |
| 203 | for(int i = 0; i < 8; i++) | 204 | for (int i = 0; i < 8; i++) |
| 204 | for(int j = 0; j < 8; j++) | 205 | for (int j = 0; j < 8; j++) |
| 205 | uiPix1[i*FENC_STRIDE+j] = uiPix2[i*FDEC_STRIDE+j] = rand() & 255; | 206 | uiPix1[i * FENC_STRIDE + j] = uiPix2[i * FDEC_STRIDE + j] = rand() & 255; |
| 206 | WelsDctFourT4_c(iDctC, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE); | 207 | WelsDctFourT4_c (iDctC, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE); |
| 207 | WelsDctFourT4_sse2(iDctS, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE); | 208 | WelsDctFourT4_sse2 (iDctS, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE); |
| 208 | for(int i = 0; i < 64; i++) | 209 | for (int i = 0; i < 64; i++) |
| 209 | EXPECT_EQ(iDctC[i], iDctS[i]); | 210 | EXPECT_EQ (iDctC[i], iDctS[i]); |
| 210 | FREE_MEMORY(uiPix1); | 211 | FREE_MEMORY (uiPix1); |
| 211 | FREE_MEMORY(uiPix2); | 212 | FREE_MEMORY (uiPix2); |
| 212 | FREE_MEMORY(iDctC); | 213 | FREE_MEMORY (iDctC); |
| 213 | FREE_MEMORY(iDctS); | 214 | FREE_MEMORY (iDctS); |
| 214 | } | 215 | } |
| 215 | 216 | ||
| 216 | TEST(EncodeMbAuxTest, WelsCalculateSingleCtr4x4_sse2) { | 217 | TEST (EncodeMbAuxTest, WelsCalculateSingleCtr4x4_sse2) { |
| 217 | CMemoryAlign cMemoryAlign(0); | 218 | CMemoryAlign cMemoryAlign (0); |
| 218 | ALLOC_MEMORY(int16_t, iDctC, 16); | 219 | ALLOC_MEMORY (int16_t, iDctC, 16); |
| 219 | ALLOC_MEMORY(int16_t, iDctS, 16); | 220 | ALLOC_MEMORY (int16_t, iDctS, 16); |
| 220 | srand((unsigned int)time(NULL)); | 221 | srand ((unsigned int)time (NULL)); |
| 221 | for(int i = 0; i < 16; i++) | 222 | for (int i = 0; i < 16; i++) |
| 222 | iDctC[i] = iDctS[i] = (rand() & 65535 ) - 32768; | 223 | iDctC[i] = iDctS[i] = (rand() & 65535) - 32768; |
| 223 | WelsCalculateSingleCtr4x4_c(iDctC); | 224 | WelsCalculateSingleCtr4x4_c (iDctC); |
| 224 | WelsCalculateSingleCtr4x4_sse2(iDctS); | 225 | WelsCalculateSingleCtr4x4_sse2 (iDctS); |
| 225 | for(int i = 0; i < 16; i++) | 226 | for (int i = 0; i < 16; i++) |
| 226 | EXPECT_EQ(iDctC[i], iDctS[i]); | 227 | EXPECT_EQ (iDctC[i], iDctS[i]); |
| 227 | FREE_MEMORY(iDctC); | 228 | FREE_MEMORY (iDctC); |
| 228 | FREE_MEMORY(iDctS); | 229 | FREE_MEMORY (iDctS); |
| 229 | } | 230 | } |
| 230 | #endif | 231 | #endif |
| 231 | 232 | ||
| 232 | void copy(uint8_t *pDst, int32_t iDStride, uint8_t *pSrc, int32_t iSStride, int32_t iWidth, int32_t iHeight) { | 233 | void copy (uint8_t* pDst, int32_t iDStride, uint8_t* pSrc, int32_t iSStride, int32_t iWidth, int32_t iHeight) { |
| 233 | for(int i = 0; i < iHeight; i++) | 234 | for (int i = 0; i < iHeight; i++) |
| 234 | memcpy(pDst+i*iDStride, pSrc+i*iSStride, iWidth); | 235 | memcpy (pDst + i * iDStride, pSrc + i * iSStride, iWidth); |
| 235 | } | 236 | } |
| 236 | 237 | ||
| 237 | #define GENERATE_UT_FOR_COPY(width, height, function) \ | 238 | #define GENERATE_UT_FOR_COPY(width, height, function) \ |
| @@ -253,112 +254,112 @@ TEST(EncodeMbAuxTest, function) { \ · 15 unmodified lines | |||
| 253 | EXPECT_EQ(ref_dst[i*iDStride+j], dst[i*iDStride+j]); \ | 254 | EXPECT_EQ(ref_dst[i*iDStride+j], dst[i*iDStride+j]); \ |
| 254 | } | 255 | } |
| 255 | 256 | ||
| 256 | GENERATE_UT_FOR_COPY(4,4, WelsCopy4x4); | 257 | GENERATE_UT_FOR_COPY (4, 4, WelsCopy4x4); |
| 257 | GENERATE_UT_FOR_COPY(8,8, WelsCopy8x8_c); | 258 | GENERATE_UT_FOR_COPY (8, 8, WelsCopy8x8_c); |
| 258 | GENERATE_UT_FOR_COPY(8, 16, WelsCopy8x16_c); | 259 | GENERATE_UT_FOR_COPY (8, 16, WelsCopy8x16_c); |
| 259 | GENERATE_UT_FOR_COPY(16, 8, WelsCopy16x8_c); | 260 | GENERATE_UT_FOR_COPY (16, 8, WelsCopy16x8_c); |
| 260 | GENERATE_UT_FOR_COPY(16, 16, WelsCopy16x16_c); | 261 | GENERATE_UT_FOR_COPY (16, 16, WelsCopy16x16_c); |
| 261 | #ifdef X86_ASM | 262 | #ifdef X86_ASM |
| 262 | GENERATE_UT_FOR_COPY(16, 8, WelsCopy16x8NotAligned_sse2); | 263 | GENERATE_UT_FOR_COPY (16, 8, WelsCopy16x8NotAligned_sse2); |
| 263 | GENERATE_UT_FOR_COPY(16, 16, WelsCopy16x16NotAligned_sse2); | 264 | GENERATE_UT_FOR_COPY (16, 16, WelsCopy16x16NotAligned_sse2); |
| 264 | GENERATE_UT_FOR_COPY(16, 16, WelsCopy16x16_sse2); | 265 | GENERATE_UT_FOR_COPY (16, 16, WelsCopy16x16_sse2); |
| 265 | #endif | 266 | #endif |
| 266 | TEST(EncodeMbAuxTest, WelsGetNoneZeroCount_c) { | 267 | TEST (EncodeMbAuxTest, WelsGetNoneZeroCount_c) { |
| 267 | int16_t _iLevel[32]; | 268 | int16_t _iLevel[32]; |
| 268 | int16_t *pLevel = (int16_t*) (((((uintptr_t)_iLevel) + 15) >> 4) << 4); | 269 | int16_t* pLevel = (int16_t*) (((((uintptr_t)_iLevel) + 15) >> 4) << 4); |
| 269 | srand((unsigned int)time(NULL)); | 270 | srand ((unsigned int)time (NULL)); |
| 270 | int32_t result = 0; | 271 | int32_t result = 0; |
| 271 | for(int i = 0; i < 16; i++) { | 272 | for (int i = 0; i < 16; i++) { |
| 272 | pLevel[i] = (rand() & 0x07) - 4; | 273 | pLevel[i] = (rand() & 0x07) - 4; |
| 273 | if(pLevel[i]) result ++; | 274 | if (pLevel[i]) result ++; |
| 274 | } | 275 | } |
| 275 | int32_t nnz = WelsGetNoneZeroCount_c(pLevel); | 276 | int32_t nnz = WelsGetNoneZeroCount_c (pLevel); |
| 276 | EXPECT_EQ(nnz, result); | 277 | EXPECT_EQ (nnz, result); |
| 277 | } | 278 | } |
| 278 | #ifdef X86_ASM | 279 | #ifdef X86_ASM |
| 279 | TEST(EncodeMbAuxTest, WelsGetNoneZeroCount_sse2) { | 280 | TEST (EncodeMbAuxTest, WelsGetNoneZeroCount_sse2) { |
| 280 | int16_t _iLevel[32]; | 281 | int16_t _iLevel[32]; |
| 281 | int16_t *pLevel = (int16_t*) (((((uintptr_t)_iLevel) + 15) >> 4) << 4); | 282 | int16_t* pLevel = (int16_t*) (((((uintptr_t)_iLevel) + 15) >> 4) << 4); |
| 282 | srand((unsigned int)time(NULL)); | 283 | srand ((unsigned int)time (NULL)); |
| 283 | int32_t result = 0; | 284 | int32_t result = 0; |
| 284 | for(int i = 0; i < 16; i++) { | 285 | for (int i = 0; i < 16; i++) { |
| 285 | pLevel[i] = (rand() & 0x07) - 4; | 286 | pLevel[i] = (rand() & 0x07) - 4; |
| 286 | if(pLevel[i]) result ++; | 287 | if (pLevel[i]) result ++; |
| 287 | } | 288 | } |
| 288 | int32_t nnz = WelsGetNoneZeroCount_sse2(pLevel); | 289 | int32_t nnz = WelsGetNoneZeroCount_sse2 (pLevel); |
| 289 | EXPECT_EQ(nnz, result); | 290 | EXPECT_EQ (nnz, result); |
| 290 | } | 291 | } |
| 291 | #endif | 292 | #endif |
| 292 | #define WELS_ABS_LC(a) ((sign ^ (int32_t)(a)) - sign) | 293 | #define WELS_ABS_LC(a) ((sign ^ (int32_t)(a)) - sign) |
| 293 | #define NEW_QUANT(pDct, ff, mf) (((ff)+ WELS_ABS_LC(pDct))*(mf)) >>16 | 294 | #define NEW_QUANT(pDct, ff, mf) (((ff)+ WELS_ABS_LC(pDct))*(mf)) >>16 |
| 294 | #define WELS_NEW_QUANT(pDct,ff,mf) WELS_ABS_LC(NEW_QUANT(pDct, ff, mf)) | 295 | #define WELS_NEW_QUANT(pDct,ff,mf) WELS_ABS_LC(NEW_QUANT(pDct, ff, mf)) |
| 295 | void WelsQuantFour4x4MaxAnchor(int16_t *pDct, int16_t* ff, int16_t *mf, int16_t *max) { | 296 | void WelsQuantFour4x4MaxAnchor (int16_t* pDct, int16_t* ff, int16_t* mf, int16_t* max) { |
| 296 | int32_t i, j, k, sign; | 297 | int32_t i, j, k, sign; |
| 297 | int16_t max_abs; | 298 | int16_t max_abs; |
| 298 | for( k = 0; k < 4; k++) { | 299 | for (k = 0; k < 4; k++) { |
| 299 | max_abs = 0; | 300 | max_abs = 0; |
| 300 | for( i = 0; i < 16; i++ ) { | 301 | for (i = 0; i < 16; i++) { |
| 301 | j = i & 0x07; | 302 | j = i & 0x07; |
| 302 | sign = WELS_SIGN(pDct[i]); | 303 | sign = WELS_SIGN (pDct[i]); |
| 303 | pDct[i] = NEW_QUANT(pDct[i], ff[j], mf[j]); | 304 | pDct[i] = NEW_QUANT (pDct[i], ff[j], mf[j]); |
| 304 | if( max_abs < pDct[i]) max_abs = pDct[i]; | 305 | if (max_abs < pDct[i]) max_abs = pDct[i]; |
| 305 | pDct[i] = WELS_ABS_LC(pDct[i]); | 306 | pDct[i] = WELS_ABS_LC (pDct[i]); |
| 306 | } | 307 | } |
| 307 | pDct += 16; | 308 | pDct += 16; |
| 308 | max[k] = max_abs; | 309 | max[k] = max_abs; |
| 309 | } | 310 | } |
| 310 | } | 311 | } |
| 311 | TEST(EncodeMbAuxTest, WelsQuantFour4x4Max_c) { | 312 | TEST (EncodeMbAuxTest, WelsQuantFour4x4Max_c) { |
| 312 | int16_t ff[8], mf[8]; | 313 | int16_t ff[8], mf[8]; |
| 313 | int16_t iDctA[64], iMaxA[16]; | 314 | int16_t iDctA[64], iMaxA[16]; |
| 314 | int16_t iDctC[64], iMaxC[16]; | 315 | int16_t iDctC[64], iMaxC[16]; |
| 315 | srand((unsigned int)time(NULL)); | 316 | srand ((unsigned int)time (NULL)); |
| 316 | for(int i = 0; i < 8; i++) { | 317 | for (int i = 0; i < 8; i++) { |
| 317 | ff[i] = rand() & 32767; | 318 | ff[i] = rand() & 32767; |
| 318 | mf[i] = rand() & 32767; | 319 | mf[i] = rand() & 32767; |
| 319 | } | 320 | } |
| 320 | for(int i = 0; i < 64; i++) | 321 | for (int i = 0; i < 64; i++) |
| 321 | iDctA[i] = iDctC[i] = (rand() & 65535) - 32767; | 322 | iDctA[i] = iDctC[i] = (rand() & 65535) - 32767; |
| 322 | WelsQuantFour4x4MaxAnchor(iDctA, ff, mf, iMaxA); | 323 | WelsQuantFour4x4MaxAnchor (iDctA, ff, mf, iMaxA); |
| 323 | WelsQuantFour4x4Max_c(iDctC, ff, mf, iMaxC); | 324 | WelsQuantFour4x4Max_c (iDctC, ff, mf, iMaxC); |
| 324 | for(int i = 0; i < 64; i++) | 325 | for (int i = 0; i < 64; i++) |
| 325 | EXPECT_EQ(iDctA[i],iDctC[i]); | 326 | EXPECT_EQ (iDctA[i], iDctC[i]); |
| 326 | for(int i = 0; i < 4; i++) | 327 | for (int i = 0; i < 4; i++) |
| 327 | EXPECT_EQ(iMaxA[i], iMaxC[i]); | 328 | EXPECT_EQ (iMaxA[i], iMaxC[i]); |
| 328 | } | 329 | } |
| 329 | #ifdef X86_ASM | 330 | #ifdef X86_ASM |
| 330 | TEST(EncodeMbAuxTest, WelsQuantFour4x4Max_sse2) { | 331 | TEST (EncodeMbAuxTest, WelsQuantFour4x4Max_sse2) { |
| 331 | CMemoryAlign cMemoryAlign(0); | 332 | CMemoryAlign cMemoryAlign (0); |
| 332 | ALLOC_MEMORY(int16_t, ff, 8); | 333 | ALLOC_MEMORY (int16_t, ff, 8); |
| 333 | ALLOC_MEMORY(int16_t, mf, 8); | 334 | ALLOC_MEMORY (int16_t, mf, 8); |
| 334 | ALLOC_MEMORY(int16_t, iDctC, 64); | 335 | ALLOC_MEMORY (int16_t, iDctC, 64); |
| 335 | ALLOC_MEMORY(int16_t, iDctS, 64); | 336 | ALLOC_MEMORY (int16_t, iDctS, 64); |
| 336 | ALLOC_MEMORY(int16_t, iMaxC, 16); | 337 | ALLOC_MEMORY (int16_t, iMaxC, 16); |
| 337 | ALLOC_MEMORY(int16_t, iMaxS, 16); | 338 | ALLOC_MEMORY (int16_t, iMaxS, 16); |
| 338 | srand((unsigned int)time(NULL)); | 339 | srand ((unsigned int)time (NULL)); |
| 339 | for(int i = 0; i < 8; i++) { | 340 | for (int i = 0; i < 8; i++) { |
| 340 | ff[i] = rand() & 32767; | 341 | ff[i] = rand() & 32767; |
| 341 | mf[i] = rand() & 32767; | 342 | mf[i] = rand() & 32767; |
| 342 | } | 343 | } |
| 343 | for(int i = 0; i < 64; i++) | 344 | for (int i = 0; i < 64; i++) |
| 344 | iDctC[i] = iDctS[i] = (rand() & 65535) - 32767; | 345 | iDctC[i] = iDctS[i] = (rand() & 65535) - 32767; |
| 345 | WelsQuantFour4x4Max_c(iDctC, ff, mf, iMaxC); | 346 | WelsQuantFour4x4Max_c (iDctC, ff, mf, iMaxC); |
| 346 | WelsQuantFour4x4Max_sse2(iDctS, ff, mf, iMaxS); | 347 | WelsQuantFour4x4Max_sse2 (iDctS, ff, mf, iMaxS); |
| 347 | for(int i = 0; i < 64; i++) | 348 | for (int i = 0; i < 64; i++) |
| 348 | EXPECT_EQ(iDctC[i], iDctS[i]); | 349 | EXPECT_EQ (iDctC[i], iDctS[i]); |
| 349 | for(int i = 0; i < 4; i++) | 350 | for (int i = 0; i < 4; i++) |
| 350 | EXPECT_EQ(iMaxC[i], iMaxS[i]); | 351 | EXPECT_EQ (iMaxC[i], iMaxS[i]); |
| 351 | FREE_MEMORY(ff); | 352 | FREE_MEMORY (ff); |
| 352 | FREE_MEMORY(mf); | 353 | FREE_MEMORY (mf); |
| 353 | FREE_MEMORY(iDctC); | 354 | FREE_MEMORY (iDctC); |
| 354 | FREE_MEMORY(iDctS); | 355 | FREE_MEMORY (iDctS); |
| 355 | FREE_MEMORY(iMaxC); | 356 | FREE_MEMORY (iMaxC); |
| 356 | FREE_MEMORY(iMaxS); | 357 | FREE_MEMORY (iMaxS); |
| 357 | } | 358 | } |
| 358 | #endif | 359 | #endif |
| 359 | int32_t WelsHadamardQuant2x2SkipAnchor(int16_t *rs, int16_t ff, int16_t mf) { | 360 | int32_t WelsHadamardQuant2x2SkipAnchor (int16_t* rs, int16_t ff, int16_t mf) { |
| 360 | int16_t pDct[4], s[4]; | 361 | int16_t pDct[4], s[4]; |
| 361 | int16_t threshold = ((1<<16)-1)/mf - ff; | 362 | int16_t threshold = ((1 << 16) - 1) / mf - ff; |
| 362 | s[0] = rs[0] + rs[32]; | 363 | s[0] = rs[0] + rs[32]; |
| 363 | s[1] = rs[0] - rs[32]; | 364 | s[1] = rs[0] - rs[32]; |
| 364 | s[2] = rs[16] + rs[48]; | 365 | s[2] = rs[16] + rs[48]; |
| @@ -367,21 +368,22 @@ int32_t WelsHadamardQuant2x2SkipAnchor(int16_t *rs, int16_t ff, int16_t mf) { · 2 unmodified lines | |||
| 367 | pDct[1] = s[0] - s[2]; | 368 | pDct[1] = s[0] - s[2]; |
| 368 | pDct[2] = s[1] + s[3]; | 369 | pDct[2] = s[1] + s[3]; |
| 369 | pDct[3] = s[1] - s[3]; | 370 | pDct[3] = s[1] - s[3]; |
| 370 | return ((WELS_ABS(pDct[0]) > threshold) || (WELS_ABS(pDct[1]) > threshold) || (WELS_ABS(pDct[2]) > threshold) || (WELS_ABS(pDct[3]) > threshold)); | 371 | return ((WELS_ABS (pDct[0]) > threshold) || (WELS_ABS (pDct[1]) > threshold) || (WELS_ABS (pDct[2]) > threshold) |
| 372 | || (WELS_ABS (pDct[3]) > threshold)); | ||
| 371 | } | 373 | } |
| 372 | 374 | ||
| 373 | TEST(EncodeMbAuxTest, WelsHadamardQuant2x2Skip_c) { | 375 | TEST (EncodeMbAuxTest, WelsHadamardQuant2x2Skip_c) { |
| 374 | int16_t iRS[64]; | 376 | int16_t iRS[64]; |
| 375 | int16_t ff, mf; | 377 | int16_t ff, mf; |
| 376 | srand((unsigned int)time(NULL)); | 378 | srand ((unsigned int)time (NULL)); |
| 377 | for(int i = 0; i < 64; i++) | 379 | for (int i = 0; i < 64; i++) |
| 378 | iRS[i] = (rand() & 32767) - 16384; | 380 | iRS[i] = (rand() & 32767) - 16384; |
| 379 | ff = rand() & 32767; | 381 | ff = rand() & 32767; |
| 380 | mf = rand() & 32767; | 382 | mf = rand() & 32767; |
| 381 | EXPECT_EQ(WelsHadamardQuant2x2Skip_c(iRS, ff, mf), WelsHadamardQuant2x2SkipAnchor(iRS, ff, mf)); | 383 | EXPECT_EQ (WelsHadamardQuant2x2Skip_c (iRS, ff, mf), WelsHadamardQuant2x2SkipAnchor (iRS, ff, mf)); |
| 382 | } | 384 | } |
| 383 | 385 | ||
| 384 | int32_t WelsHadamardQuant2x2Anchor(int16_t *rs, const int16_t ff, int16_t mf, int16_t * pDct, int16_t * block) { | 386 | int32_t WelsHadamardQuant2x2Anchor (int16_t* rs, const int16_t ff, int16_t mf, int16_t* pDct, int16_t* block) { |
| 385 | int16_t s[4]; | 387 | int16_t s[4]; |
| 386 | int32_t sign, i, dc_nzc = 0; | 388 | int32_t sign, i, dc_nzc = 0; |
| 387 | 389 | ||
| @@ -400,95 +402,95 @@ int32_t WelsHadamardQuant2x2Anchor(int16_t *rs, const int16_t ff, int16_t mf, in · 12 unmodified lines | |||
| 400 | pDct[2] = s[1] + s[3]; | 402 | pDct[2] = s[1] + s[3]; |
| 401 | pDct[3] = s[1] - s[3]; | 403 | pDct[3] = s[1] - s[3]; |
| 402 | 404 | ||
| 403 | sign = WELS_SIGN(pDct[0]); | 405 | sign = WELS_SIGN (pDct[0]); |
| 404 | pDct[0] = WELS_NEW_QUANT(pDct[0], ff, mf); | 406 | pDct[0] = WELS_NEW_QUANT (pDct[0], ff, mf); |
| 405 | sign = WELS_SIGN(pDct[1]); | 407 | sign = WELS_SIGN (pDct[1]); |
| 406 | pDct[1] = WELS_NEW_QUANT(pDct[1], ff, mf); | 408 | pDct[1] = WELS_NEW_QUANT (pDct[1], ff, mf); |
| 407 | sign = WELS_SIGN(pDct[2]); | 409 | sign = WELS_SIGN (pDct[2]); |
| 408 | pDct[2] = WELS_NEW_QUANT(pDct[2], ff, mf); | 410 | pDct[2] = WELS_NEW_QUANT (pDct[2], ff, mf); |
| 409 | sign = WELS_SIGN(pDct[3]); | 411 | sign = WELS_SIGN (pDct[3]); |
| 410 | pDct[3] = WELS_NEW_QUANT(pDct[3], ff, mf); | 412 | pDct[3] = WELS_NEW_QUANT (pDct[3], ff, mf); |
| 411 | ST64( block, LD64(pDct) ); | 413 | ST64 (block, LD64 (pDct)); |
| 412 | for(i=0; i<4; i++) | 414 | for (i = 0; i < 4; i++) |
| 413 | dc_nzc += (block[i] != 0); | 415 | dc_nzc += (block[i] != 0); |
| 414 | return dc_nzc; | 416 | return dc_nzc; |
| 415 | } | 417 | } |
| 416 | 418 | ||
| 417 | TEST(EncodeMbAuxTest, WelsHadamardQuant2x2_c) { | 419 | TEST (EncodeMbAuxTest, WelsHadamardQuant2x2_c) { |
| 418 | int16_t iRsC[64], iRsA[64]; | 420 | int16_t iRsC[64], iRsA[64]; |
| 419 | int16_t ff, mf; | 421 | int16_t ff, mf; |
| 420 | int16_t iBlockA[16], iBlockC[16], iDctA[4], iDctC[4]; | 422 | int16_t iBlockA[16], iBlockC[16], iDctA[4], iDctC[4]; |
| 421 | srand((unsigned int)time(NULL)); | 423 | srand ((unsigned int)time (NULL)); |
| 422 | for(int i = 0; i < 64; i++) | 424 | for (int i = 0; i < 64; i++) |
| 423 | iRsA[i] = iRsC[i] = (rand() & 32767) - 16384; | 425 | iRsA[i] = iRsC[i] = (rand() & 32767) - 16384; |
| 424 | for(int i = 0; i < 4; i++) | 426 | for (int i = 0; i < 4; i++) |
| 425 | iDctA[i] = iDctC[i] = (rand() & 32767) - 16384; | 427 | iDctA[i] = iDctC[i] = (rand() & 32767) - 16384; |
| 426 | ff = rand() & 32767; | 428 | ff = rand() & 32767; |
| 427 | mf = rand() & 32767; | 429 | mf = rand() & 32767; |
| 428 | 430 | ||
| 429 | int32_t iRetA = WelsHadamardQuant2x2Anchor(iRsA, ff, mf, iDctA, iBlockA); | 431 | int32_t iRetA = WelsHadamardQuant2x2Anchor (iRsA, ff, mf, iDctA, iBlockA); |
| 430 | int32_t iRetC = WelsHadamardQuant2x2_c(iRsC, ff, mf, iDctC, iBlockC); | 432 | int32_t iRetC = WelsHadamardQuant2x2_c (iRsC, ff, mf, iDctC, iBlockC); |
| 431 | EXPECT_EQ(iRetA, iRetC); | 433 | EXPECT_EQ (iRetA, iRetC); |
| 432 | for(int i = 0; i < 4; i++) | 434 | for (int i = 0; i < 4; i++) |
| 433 | EXPECT_EQ(iDctA[i], iDctC[i]); | 435 | EXPECT_EQ (iDctA[i], iDctC[i]); |
| 434 | } | 436 | } |
| 435 | 437 | ||
| 436 | void WelsHadamardT4DcAnchor( int16_t *pLumaDc, int16_t *pDct) { | 438 | void WelsHadamardT4DcAnchor (int16_t* pLumaDc, int16_t* pDct) { |
| 437 | int32_t p[16], s[4]; | 439 | int32_t p[16], s[4]; |
| 438 | int32_t i, iIdx; | 440 | int32_t i, iIdx; |
| 439 | for(i = 0 ; i < 16 ; i +=4) { | 441 | for (i = 0 ; i < 16 ; i += 4) { |
| 440 | iIdx = ((i&0x08) << 4) +((i&0x04) << 3); | 442 | iIdx = ((i & 0x08) << 4) + ((i & 0x04) << 3); |
| 441 | s[0] = pDct[iIdx ] + pDct[iIdx+80]; | 443 | s[0] = pDct[iIdx ] + pDct[iIdx + 80]; |
| 442 | s[3] = pDct[iIdx ] - pDct[iIdx+80]; | 444 | s[3] = pDct[iIdx ] - pDct[iIdx + 80]; |
| 443 | s[1] = pDct[iIdx+16] + pDct[iIdx+64]; | 445 | s[1] = pDct[iIdx + 16] + pDct[iIdx + 64]; |
| 444 | s[2] = pDct[iIdx+16] - pDct[iIdx+64]; | 446 | s[2] = pDct[iIdx + 16] - pDct[iIdx + 64]; |
| 445 | p[i ] = s[0] + s[1]; | 447 | p[i ] = s[0] + s[1]; |
| 446 | p[i+2] = s[0] - s[1]; | 448 | p[i + 2] = s[0] - s[1]; |
| 447 | p[i+1] = s[3] + s[2]; | 449 | p[i + 1] = s[3] + s[2]; |
| 448 | p[i+3] = s[3] - s[2]; | 450 | p[i + 3] = s[3] - s[2]; |
| 449 | } | 451 | } |
| 450 | for(i = 0 ; i < 4 ; i ++) { | 452 | for (i = 0 ; i < 4 ; i ++) { |
| 451 | s[0] = p[i ] + p[i+12]; | 453 | s[0] = p[i ] + p[i + 12]; |
| 452 | s[3] = p[i ] - p[i+12]; | 454 | s[3] = p[i ] - p[i + 12]; |
| 453 | s[1] = p[i+4] + p[i+ 8]; | 455 | s[1] = p[i + 4] + p[i + 8]; |
| 454 | s[2] = p[i+4] - p[i+ 8]; | 456 | s[2] = p[i + 4] - p[i + 8]; |
| 455 | pLumaDc[i ] = WELS_CLIP3((s[0] + s[1] + 1) >> 1, -32768, 32767); | 457 | pLumaDc[i ] = WELS_CLIP3 ((s[0] + s[1] + 1) >> 1, -32768, 32767); |
| 456 | pLumaDc[i+8 ] = WELS_CLIP3((s[0] - s[1] + 1) >> 1, -32768, 32767); | 458 | pLumaDc[i + 8 ] = WELS_CLIP3 ((s[0] - s[1] + 1) >> 1, -32768, 32767); |
| 457 | pLumaDc[i+4 ] = WELS_CLIP3((s[3] + s[2] + 1) >> 1, -32768, 32767); | 459 | pLumaDc[i + 4 ] = WELS_CLIP3 ((s[3] + s[2] + 1) >> 1, -32768, 32767); |
| 458 | pLumaDc[i+12] = WELS_CLIP3((s[3] - s[2] + 1) >> 1, -32768, 32767); | 460 | pLumaDc[i + 12] = WELS_CLIP3 ((s[3] - s[2] + 1) >> 1, -32768, 32767); |
| 459 | } | 461 | } |
| 460 | } | 462 | } |
| 461 | TEST(EncodeMbAuxTest, WelsHadamardT4Dc_c) { | 463 | TEST (EncodeMbAuxTest, WelsHadamardT4Dc_c) { |
| 462 | CMemoryAlign cMemoryAlign(0); | 464 | CMemoryAlign cMemoryAlign (0); |
| 463 | ALLOC_MEMORY(int16_t, iDct, 128*16); | 465 | ALLOC_MEMORY (int16_t, iDct, 128 * 16); |
| 464 | ALLOC_MEMORY(int16_t, iLumaDcR, 16); | 466 | ALLOC_MEMORY (int16_t, iLumaDcR, 16); |
| 465 | ALLOC_MEMORY(int16_t, iLumaDcC, 16); | 467 | ALLOC_MEMORY (int16_t, iLumaDcC, 16); |
| 466 | srand((unsigned int)time(NULL)); | 468 | srand ((unsigned int)time (NULL)); |
| 467 | for(int i = 0; i < 128*16; i++) | 469 | for (int i = 0; i < 128 * 16; i++) |
| 468 | iDct[i] = (rand() & 32767) - 16384; | 470 | iDct[i] = (rand() & 32767) - 16384; |
| 469 | WelsHadamardT4DcAnchor(iLumaDcR, iDct); | 471 | WelsHadamardT4DcAnchor (iLumaDcR, iDct); |
| 470 | WelsHadamardT4Dc_c(iLumaDcC, iDct); | 472 | WelsHadamardT4Dc_c (iLumaDcC, iDct); |
| 471 | for(int i = 0;i < 16; i++) | 473 | for (int i = 0; i < 16; i++) |
| 472 | EXPECT_EQ(iLumaDcR[i], iLumaDcC[i]); | 474 | EXPECT_EQ (iLumaDcR[i], iLumaDcC[i]); |
| 473 | FREE_MEMORY(iDct); | 475 | FREE_MEMORY (iDct); |
| 474 | FREE_MEMORY(iLumaDcR); | 476 | FREE_MEMORY (iLumaDcR); |
| 475 | FREE_MEMORY(iLumaDcC); | 477 | FREE_MEMORY (iLumaDcC); |
| 476 | } | 478 | } |
| 477 | #ifdef X86_ASM | 479 | #ifdef X86_ASM |
| 478 | TEST(EncodeMbAuxTest, WelsHadamardT4Dc_sse2) { | 480 | TEST (EncodeMbAuxTest, WelsHadamardT4Dc_sse2) { |
| 479 | CMemoryAlign cMemoryAlign(0); | 481 | CMemoryAlign cMemoryAlign (0); |
| 480 | ALLOC_MEMORY(int16_t, iDct, 128*16); | 482 | ALLOC_MEMORY (int16_t, iDct, 128 * 16); |
| 481 | ALLOC_MEMORY(int16_t, iLumaDcC, 16); | 483 | ALLOC_MEMORY (int16_t, iLumaDcC, 16); |
| 482 | ALLOC_MEMORY(int16_t, iLumaDcS, 16); | 484 | ALLOC_MEMORY (int16_t, iLumaDcS, 16); |
| 483 | srand((unsigned int)time(NULL)); | 485 | srand ((unsigned int)time (NULL)); |
| 484 | for(int i = 0; i < 128*16; i++) | 486 | for (int i = 0; i < 128 * 16; i++) |
| 485 | iDct[i] = (rand() & 32767) - 16384; | 487 | iDct[i] = (rand() & 32767) - 16384; |
| 486 | WelsHadamardT4Dc_c(iLumaDcC, iDct); | 488 | WelsHadamardT4Dc_c (iLumaDcC, iDct); |
| 487 | WelsHadamardT4Dc_sse2(iLumaDcS, iDct); | 489 | WelsHadamardT4Dc_sse2 (iLumaDcS, iDct); |
| 488 | for(int i = 0;i < 16; i++) | 490 | for (int i = 0; i < 16; i++) |
| 489 | EXPECT_EQ(iLumaDcC[i], iLumaDcS[i]); | 491 | EXPECT_EQ (iLumaDcC[i], iLumaDcS[i]); |
| 490 | FREE_MEMORY(iDct); | 492 | FREE_MEMORY (iDct); |
| 491 | FREE_MEMORY(iLumaDcC); | 493 | FREE_MEMORY (iLumaDcC); |
| 492 | FREE_MEMORY(iLumaDcS); | 494 | FREE_MEMORY (iLumaDcS); |
| 493 | } | 495 | } |
| 494 | #endif | 496 | #endif |