OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 virtual void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) = 0; | 95 virtual void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) = 0; |
96 | 96 |
97 virtual void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) = 0; | 97 virtual void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) = 0; |
98 | 98 |
99 void RunAccuracyCheck(int limit) { | 99 void RunAccuracyCheck(int limit) { |
100 ACMRandom rnd(ACMRandom::DeterministicSeed()); | 100 ACMRandom rnd(ACMRandom::DeterministicSeed()); |
101 uint32_t max_error = 0; | 101 uint32_t max_error = 0; |
102 int64_t total_error = 0; | 102 int64_t total_error = 0; |
103 const int count_test_block = 10000; | 103 const int count_test_block = 10000; |
104 for (int i = 0; i < count_test_block; ++i) { | 104 for (int i = 0; i < count_test_block; ++i) { |
105 DECLARE_ALIGNED_ARRAY(16, int16_t, test_input_block, kNumCoeffs); | 105 DECLARE_ALIGNED(16, int16_t, test_input_block[kNumCoeffs]); |
106 DECLARE_ALIGNED_ARRAY(16, tran_low_t, test_temp_block, kNumCoeffs); | 106 DECLARE_ALIGNED(16, tran_low_t, test_temp_block[kNumCoeffs]); |
107 DECLARE_ALIGNED_ARRAY(16, uint8_t, dst, kNumCoeffs); | 107 DECLARE_ALIGNED(16, uint8_t, dst[kNumCoeffs]); |
108 DECLARE_ALIGNED_ARRAY(16, uint8_t, src, kNumCoeffs); | 108 DECLARE_ALIGNED(16, uint8_t, src[kNumCoeffs]); |
109 #if CONFIG_VP9_HIGHBITDEPTH | 109 #if CONFIG_VP9_HIGHBITDEPTH |
110 DECLARE_ALIGNED_ARRAY(16, uint16_t, dst16, kNumCoeffs); | 110 DECLARE_ALIGNED(16, uint16_t, dst16[kNumCoeffs]); |
111 DECLARE_ALIGNED_ARRAY(16, uint16_t, src16, kNumCoeffs); | 111 DECLARE_ALIGNED(16, uint16_t, src16[kNumCoeffs]); |
112 #endif | 112 #endif |
113 | 113 |
114 // Initialize a test block with input range [-255, 255]. | 114 // Initialize a test block with input range [-255, 255]. |
115 for (int j = 0; j < kNumCoeffs; ++j) { | 115 for (int j = 0; j < kNumCoeffs; ++j) { |
116 if (bit_depth_ == VPX_BITS_8) { | 116 if (bit_depth_ == VPX_BITS_8) { |
117 src[j] = rnd.Rand8(); | 117 src[j] = rnd.Rand8(); |
118 dst[j] = rnd.Rand8(); | 118 dst[j] = rnd.Rand8(); |
119 test_input_block[j] = src[j] - dst[j]; | 119 test_input_block[j] = src[j] - dst[j]; |
120 #if CONFIG_VP9_HIGHBITDEPTH | 120 #if CONFIG_VP9_HIGHBITDEPTH |
121 } else { | 121 } else { |
(...skipping 13 matching lines...) Expand all Loading... |
135 ASM_REGISTER_STATE_CHECK(RunInvTxfm(test_temp_block, | 135 ASM_REGISTER_STATE_CHECK(RunInvTxfm(test_temp_block, |
136 CONVERT_TO_BYTEPTR(dst16), pitch_)); | 136 CONVERT_TO_BYTEPTR(dst16), pitch_)); |
137 #endif | 137 #endif |
138 } | 138 } |
139 | 139 |
140 for (int j = 0; j < kNumCoeffs; ++j) { | 140 for (int j = 0; j < kNumCoeffs; ++j) { |
141 #if CONFIG_VP9_HIGHBITDEPTH | 141 #if CONFIG_VP9_HIGHBITDEPTH |
142 const uint32_t diff = | 142 const uint32_t diff = |
143 bit_depth_ == VPX_BITS_8 ? dst[j] - src[j] : dst16[j] - src16[j]; | 143 bit_depth_ == VPX_BITS_8 ? dst[j] - src[j] : dst16[j] - src16[j]; |
144 #else | 144 #else |
| 145 ASSERT_EQ(VPX_BITS_8, bit_depth_); |
145 const uint32_t diff = dst[j] - src[j]; | 146 const uint32_t diff = dst[j] - src[j]; |
146 #endif | 147 #endif |
147 const uint32_t error = diff * diff; | 148 const uint32_t error = diff * diff; |
148 if (max_error < error) | 149 if (max_error < error) |
149 max_error = error; | 150 max_error = error; |
150 total_error += error; | 151 total_error += error; |
151 } | 152 } |
152 } | 153 } |
153 | 154 |
154 EXPECT_GE(static_cast<uint32_t>(limit), max_error) | 155 EXPECT_GE(static_cast<uint32_t>(limit), max_error) |
155 << "Error: 4x4 FHT/IHT has an individual round trip error > " | 156 << "Error: 4x4 FHT/IHT has an individual round trip error > " |
156 << limit; | 157 << limit; |
157 | 158 |
158 EXPECT_GE(count_test_block * limit, total_error) | 159 EXPECT_GE(count_test_block * limit, total_error) |
159 << "Error: 4x4 FHT/IHT has average round trip error > " << limit | 160 << "Error: 4x4 FHT/IHT has average round trip error > " << limit |
160 << " per block"; | 161 << " per block"; |
161 } | 162 } |
162 | 163 |
163 void RunCoeffCheck() { | 164 void RunCoeffCheck() { |
164 ACMRandom rnd(ACMRandom::DeterministicSeed()); | 165 ACMRandom rnd(ACMRandom::DeterministicSeed()); |
165 const int count_test_block = 5000; | 166 const int count_test_block = 5000; |
166 DECLARE_ALIGNED_ARRAY(16, int16_t, input_block, kNumCoeffs); | 167 DECLARE_ALIGNED(16, int16_t, input_block[kNumCoeffs]); |
167 DECLARE_ALIGNED_ARRAY(16, tran_low_t, output_ref_block, kNumCoeffs); | 168 DECLARE_ALIGNED(16, tran_low_t, output_ref_block[kNumCoeffs]); |
168 DECLARE_ALIGNED_ARRAY(16, tran_low_t, output_block, kNumCoeffs); | 169 DECLARE_ALIGNED(16, tran_low_t, output_block[kNumCoeffs]); |
169 | 170 |
170 for (int i = 0; i < count_test_block; ++i) { | 171 for (int i = 0; i < count_test_block; ++i) { |
171 // Initialize a test block with input range [-mask_, mask_]. | 172 // Initialize a test block with input range [-mask_, mask_]. |
172 for (int j = 0; j < kNumCoeffs; ++j) | 173 for (int j = 0; j < kNumCoeffs; ++j) |
173 input_block[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_); | 174 input_block[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_); |
174 | 175 |
175 fwd_txfm_ref(input_block, output_ref_block, pitch_, tx_type_); | 176 fwd_txfm_ref(input_block, output_ref_block, pitch_, tx_type_); |
176 ASM_REGISTER_STATE_CHECK(RunFwdTxfm(input_block, output_block, pitch_)); | 177 ASM_REGISTER_STATE_CHECK(RunFwdTxfm(input_block, output_block, pitch_)); |
177 | 178 |
178 // The minimum quant value is 4. | 179 // The minimum quant value is 4. |
179 for (int j = 0; j < kNumCoeffs; ++j) | 180 for (int j = 0; j < kNumCoeffs; ++j) |
180 EXPECT_EQ(output_block[j], output_ref_block[j]); | 181 EXPECT_EQ(output_block[j], output_ref_block[j]); |
181 } | 182 } |
182 } | 183 } |
183 | 184 |
184 void RunMemCheck() { | 185 void RunMemCheck() { |
185 ACMRandom rnd(ACMRandom::DeterministicSeed()); | 186 ACMRandom rnd(ACMRandom::DeterministicSeed()); |
186 const int count_test_block = 5000; | 187 const int count_test_block = 5000; |
187 DECLARE_ALIGNED_ARRAY(16, int16_t, input_block, kNumCoeffs); | 188 DECLARE_ALIGNED(16, int16_t, input_extreme_block[kNumCoeffs]); |
188 DECLARE_ALIGNED_ARRAY(16, int16_t, input_extreme_block, kNumCoeffs); | 189 DECLARE_ALIGNED(16, tran_low_t, output_ref_block[kNumCoeffs]); |
189 DECLARE_ALIGNED_ARRAY(16, tran_low_t, output_ref_block, kNumCoeffs); | 190 DECLARE_ALIGNED(16, tran_low_t, output_block[kNumCoeffs]); |
190 DECLARE_ALIGNED_ARRAY(16, tran_low_t, output_block, kNumCoeffs); | |
191 | 191 |
192 for (int i = 0; i < count_test_block; ++i) { | 192 for (int i = 0; i < count_test_block; ++i) { |
193 // Initialize a test block with input range [-mask_, mask_]. | 193 // Initialize a test block with input range [-mask_, mask_]. |
194 for (int j = 0; j < kNumCoeffs; ++j) { | 194 for (int j = 0; j < kNumCoeffs; ++j) { |
195 input_block[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_); | |
196 input_extreme_block[j] = rnd.Rand8() % 2 ? mask_ : -mask_; | 195 input_extreme_block[j] = rnd.Rand8() % 2 ? mask_ : -mask_; |
197 } | 196 } |
198 if (i == 0) { | 197 if (i == 0) { |
199 for (int j = 0; j < kNumCoeffs; ++j) | 198 for (int j = 0; j < kNumCoeffs; ++j) |
200 input_extreme_block[j] = mask_; | 199 input_extreme_block[j] = mask_; |
201 } else if (i == 1) { | 200 } else if (i == 1) { |
202 for (int j = 0; j < kNumCoeffs; ++j) | 201 for (int j = 0; j < kNumCoeffs; ++j) |
203 input_extreme_block[j] = -mask_; | 202 input_extreme_block[j] = -mask_; |
204 } | 203 } |
205 | 204 |
206 fwd_txfm_ref(input_extreme_block, output_ref_block, pitch_, tx_type_); | 205 fwd_txfm_ref(input_extreme_block, output_ref_block, pitch_, tx_type_); |
207 ASM_REGISTER_STATE_CHECK(RunFwdTxfm(input_extreme_block, | 206 ASM_REGISTER_STATE_CHECK(RunFwdTxfm(input_extreme_block, |
208 output_block, pitch_)); | 207 output_block, pitch_)); |
209 | 208 |
210 // The minimum quant value is 4. | 209 // The minimum quant value is 4. |
211 for (int j = 0; j < kNumCoeffs; ++j) { | 210 for (int j = 0; j < kNumCoeffs; ++j) { |
212 EXPECT_EQ(output_block[j], output_ref_block[j]); | 211 EXPECT_EQ(output_block[j], output_ref_block[j]); |
213 EXPECT_GE(4 * DCT_MAX_VALUE << (bit_depth_ - 8), abs(output_block[j])) | 212 EXPECT_GE(4 * DCT_MAX_VALUE << (bit_depth_ - 8), abs(output_block[j])) |
214 << "Error: 4x4 FDCT has coefficient larger than 4*DCT_MAX_VALUE"; | 213 << "Error: 4x4 FDCT has coefficient larger than 4*DCT_MAX_VALUE"; |
215 } | 214 } |
216 } | 215 } |
217 } | 216 } |
218 | 217 |
219 void RunInvAccuracyCheck(int limit) { | 218 void RunInvAccuracyCheck(int limit) { |
220 ACMRandom rnd(ACMRandom::DeterministicSeed()); | 219 ACMRandom rnd(ACMRandom::DeterministicSeed()); |
221 const int count_test_block = 1000; | 220 const int count_test_block = 1000; |
222 DECLARE_ALIGNED_ARRAY(16, int16_t, in, kNumCoeffs); | 221 DECLARE_ALIGNED(16, int16_t, in[kNumCoeffs]); |
223 DECLARE_ALIGNED_ARRAY(16, tran_low_t, coeff, kNumCoeffs); | 222 DECLARE_ALIGNED(16, tran_low_t, coeff[kNumCoeffs]); |
224 DECLARE_ALIGNED_ARRAY(16, uint8_t, dst, kNumCoeffs); | 223 DECLARE_ALIGNED(16, uint8_t, dst[kNumCoeffs]); |
225 DECLARE_ALIGNED_ARRAY(16, uint8_t, src, kNumCoeffs); | 224 DECLARE_ALIGNED(16, uint8_t, src[kNumCoeffs]); |
226 #if CONFIG_VP9_HIGHBITDEPTH | 225 #if CONFIG_VP9_HIGHBITDEPTH |
227 DECLARE_ALIGNED_ARRAY(16, uint16_t, dst16, kNumCoeffs); | 226 DECLARE_ALIGNED(16, uint16_t, dst16[kNumCoeffs]); |
228 DECLARE_ALIGNED_ARRAY(16, uint16_t, src16, kNumCoeffs); | 227 DECLARE_ALIGNED(16, uint16_t, src16[kNumCoeffs]); |
229 #endif | 228 #endif |
230 | 229 |
231 for (int i = 0; i < count_test_block; ++i) { | 230 for (int i = 0; i < count_test_block; ++i) { |
232 // Initialize a test block with input range [-mask_, mask_]. | 231 // Initialize a test block with input range [-mask_, mask_]. |
233 for (int j = 0; j < kNumCoeffs; ++j) { | 232 for (int j = 0; j < kNumCoeffs; ++j) { |
234 if (bit_depth_ == VPX_BITS_8) { | 233 if (bit_depth_ == VPX_BITS_8) { |
235 src[j] = rnd.Rand8(); | 234 src[j] = rnd.Rand8(); |
236 dst[j] = rnd.Rand8(); | 235 dst[j] = rnd.Rand8(); |
237 in[j] = src[j] - dst[j]; | 236 in[j] = src[j] - dst[j]; |
238 #if CONFIG_VP9_HIGHBITDEPTH | 237 #if CONFIG_VP9_HIGHBITDEPTH |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 make_tuple(&vp9_highbd_fht4x4_sse2, &iht4x4_12, 0, VPX_BITS_12), | 529 make_tuple(&vp9_highbd_fht4x4_sse2, &iht4x4_12, 0, VPX_BITS_12), |
531 make_tuple(&vp9_highbd_fht4x4_sse2, &iht4x4_12, 1, VPX_BITS_12), | 530 make_tuple(&vp9_highbd_fht4x4_sse2, &iht4x4_12, 1, VPX_BITS_12), |
532 make_tuple(&vp9_highbd_fht4x4_sse2, &iht4x4_12, 2, VPX_BITS_12), | 531 make_tuple(&vp9_highbd_fht4x4_sse2, &iht4x4_12, 2, VPX_BITS_12), |
533 make_tuple(&vp9_highbd_fht4x4_sse2, &iht4x4_12, 3, VPX_BITS_12), | 532 make_tuple(&vp9_highbd_fht4x4_sse2, &iht4x4_12, 3, VPX_BITS_12), |
534 make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_c, 0, VPX_BITS_8), | 533 make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_c, 0, VPX_BITS_8), |
535 make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_c, 1, VPX_BITS_8), | 534 make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_c, 1, VPX_BITS_8), |
536 make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_c, 2, VPX_BITS_8), | 535 make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_c, 2, VPX_BITS_8), |
537 make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_c, 3, VPX_BITS_8))); | 536 make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_c, 3, VPX_BITS_8))); |
538 #endif // HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE | 537 #endif // HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE |
539 } // namespace | 538 } // namespace |
OLD | NEW |