|
1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 #ifdef HAVE_CONFIG_H |
|
19 #include "config.h" |
|
20 #endif |
|
21 |
|
22 #include <liboil/liboil.h> |
|
23 #include <liboil/liboilfunction.h> |
|
24 #include <stdio.h> |
|
25 #include <string.h> |
|
26 #include <globals.h> |
|
27 |
|
28 #define LOG_FILE "c:\\logs\\testsuite_diff_log.txt" |
|
29 #include "std_log_result.h" |
|
30 #include "utils.h" |
|
31 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
|
32 |
|
33 #define RES_SIZE 1 |
|
34 #define MAX_SIZE 64 |
|
35 #define MAX_SIZE1 10 |
|
36 #define MAX_SIZE2 15 |
|
37 |
|
38 |
|
39 void create_xml(int result) |
|
40 { |
|
41 if(result) |
|
42 assert_failed = 1; |
|
43 |
|
44 testResultXml("testsuite_diff"); |
|
45 close_log_file(); |
|
46 } |
|
47 |
|
48 |
|
49 void test_average_s16_u8(void) |
|
50 { |
|
51 int i; |
|
52 int16_t dest[MAX_SIZE]; |
|
53 uint8_t src1[MAX_SIZE],src2[MAX_SIZE], src3[MAX_SIZE]; |
|
54 int16_t check[MAX_SIZE] = {0,2,3,5,6,8,9,11,5,6,8,9,11,12,14,15,9,11,12,14,15,17,18,20,14,15,17,18,20,21,23,24,18,20,21,23,24,26,27,29,23,24,26,27,29,30,32,33,27,29,30,32,33,35,36,38,32,33,35,36,38,39,41,42}; |
|
55 for(i=0;i<MAX_SIZE;i++) |
|
56 { |
|
57 dest[i]=0; |
|
58 src1[i]=i*3; |
|
59 src2[i]=i; |
|
60 src3[i]=i*2; |
|
61 std_log(LOG_FILENAME_LINE,"src1[%d] = %d, src2[%d] = %d, src3[%d]=%d ", i,src1[i],i,src2[i],i,src3[i]); |
|
62 } |
|
63 |
|
64 oil_diff8x8_average_s16_u8 (dest,src1,2,src2,1,src3,1); |
|
65 |
|
66 for(i=0;i<MAX_SIZE;i++) |
|
67 { |
|
68 if(dest[i] == check[i]) |
|
69 { |
|
70 std_log(LOG_FILENAME_LINE,"oil_diff8x8_average_s16_u8 successful, dest[%d]=%d",i,dest[i]); |
|
71 } |
|
72 else |
|
73 { |
|
74 assert_failed=1; |
|
75 std_log(LOG_FILENAME_LINE,"oil_diff8x8_average_s16_u8 unsuccessful,Expected =%d,Obtained =%d",check[i],dest[i]); |
|
76 } |
|
77 } |
|
78 } |
|
79 |
|
80 |
|
81 |
|
82 void test_diff_const128_s16_u8() |
|
83 { |
|
84 int i; |
|
85 int16_t dest[MAX_SIZE]; |
|
86 uint8_t src1[MAX_SIZE]; |
|
87 int16_t check[MAX_SIZE]= {-28,-18,-8,2,12,22,32,42,-18,-8,2,12,22,32,42,52,-8,2,12,22,32,42,52,62,2,12,22,32,42,52,62,72,12,22,32,42,52,62,72,82,22,32,42,52,62,72,82,92,32,42,52,62,72,82,92,102,42,52,62,72,82,92,102,112}; |
|
88 for(i=0;i<MAX_SIZE;i++) |
|
89 { |
|
90 dest[i]=0; |
|
91 src1[i]=(i+10)*10; |
|
92 std_log(LOG_FILENAME_LINE,"src1[%d] = %d", i,src1[i]); |
|
93 } |
|
94 |
|
95 oil_diff8x8_const128_s16_u8(dest,src1,1); |
|
96 |
|
97 for(i=0;i<MAX_SIZE;i++) |
|
98 { |
|
99 if(dest[i]== check[i]) |
|
100 { |
|
101 std_log(LOG_FILENAME_LINE,"oil_diff8x8_const128_s16_u8 successful,dest[%d]=%d",i,dest[i]); |
|
102 } |
|
103 else |
|
104 { |
|
105 assert_failed=1; |
|
106 std_log(LOG_FILENAME_LINE,"oil_diff8x8_const128_s16_u8 unsuccessful,Expected =%d,Obtained =%d",check[i],dest[i]); |
|
107 } |
|
108 } |
|
109 } |
|
110 |
|
111 |
|
112 void test_diff8x8_s16_u8() |
|
113 { |
|
114 int i; |
|
115 uint8_t src1[MAX_SIZE], src2[MAX_SIZE]; |
|
116 int16_t dest[MAX_SIZE],check[MAX_SIZE]= {3,4,5,6,7,8,9,10,7,8,9,10,11,12,13,14,11,12,13,14,15,16,17,18,15,16,17,18,19,20,21,22,19,20,21,22,23,24,25,26,23,24,25,26,27,28,29,30,27,28,29,30,31,32,33,34,31,32,33,34,35,36,37,38}; |
|
117 for(i=0;i<MAX_SIZE;i++) |
|
118 { |
|
119 dest[i]=0; |
|
120 src1[i]=(i+1)*3; |
|
121 src2[i]=i*2; |
|
122 std_log(LOG_FILENAME_LINE,"src1[%d]=%d, src2[%d]=%d", i,src1[i],i,src2[i]); |
|
123 } |
|
124 |
|
125 oil_diff8x8_s16_u8(dest,src1,2,src2,1); |
|
126 |
|
127 for(i=0;i<MAX_SIZE;i++) |
|
128 { |
|
129 if(dest[i]== check[i]) |
|
130 { |
|
131 std_log(LOG_FILENAME_LINE,"oil_diff8x8_s16_u8 successful, dest[%d]=%d", i,dest[i]); |
|
132 } |
|
133 else |
|
134 { |
|
135 assert_failed=1; |
|
136 std_log(LOG_FILENAME_LINE,"oil_diff8x8_s16_u8 unsuccessful,Expected =%d,Obtained =%d",check[i],dest[i]); |
|
137 } |
|
138 } |
|
139 } |
|
140 |
|
141 void test_squaresum_f32() |
|
142 { |
|
143 int i; |
|
144 float fsrc1[MAX_SIZE1]; |
|
145 float fdest[RES_SIZE]={0},fcheck[RES_SIZE]= {1140.00000000000000}; |
|
146 |
|
147 for(i=0;i<MAX_SIZE1;i++) |
|
148 { |
|
149 fsrc1[i]= i*2; |
|
150 std_log(LOG_FILENAME_LINE,"fsrc1[%d]=%15.14f", i,fsrc1[i]); |
|
151 } |
|
152 |
|
153 oil_squaresum_f32(fdest,fsrc1,MAX_SIZE1); |
|
154 |
|
155 if(comparefloats(fdest[0],fcheck[0])==0) |
|
156 { |
|
157 std_log(LOG_FILENAME_LINE,"oil_squaresum_f32 successful, fdest = %15.14f", fdest[0]); |
|
158 } |
|
159 else |
|
160 { |
|
161 assert_failed=1; |
|
162 std_log(LOG_FILENAME_LINE,"oil_squaresum_f32 unsuccessful,Expected =%15.14f,Obtained =%15.14f",fcheck[0],fdest[0]); |
|
163 } |
|
164 } |
|
165 |
|
166 |
|
167 void test_diff_squaresum_f32() |
|
168 { |
|
169 int i; |
|
170 float fsrc1[MAX_SIZE1], fsrc2[MAX_SIZE1]; |
|
171 float fdest[RES_SIZE]={0},fcheck[RES_SIZE]= {930.00000000000000}; |
|
172 |
|
173 for(i=0;i<MAX_SIZE1;i++) |
|
174 { |
|
175 fsrc1[i]= i*2; |
|
176 fsrc2[i]=i; |
|
177 std_log(LOG_FILENAME_LINE,"fsrc1[%d]=%15.14f, fsrc2[%d]=%15.14f", i,fsrc1[i],i,fsrc2[i]); |
|
178 } |
|
179 |
|
180 oil_diffsquaresum_f32(fdest,fsrc1,4,fsrc2,2,MAX_SIZE1); |
|
181 |
|
182 if(comparefloats(fdest[0],fcheck[0])==0) |
|
183 { |
|
184 std_log(LOG_FILENAME_LINE,"oil_diffsquaresum_f32 successful, fdest= %15.14f", fdest[0]); |
|
185 } |
|
186 else |
|
187 { |
|
188 assert_failed=1; |
|
189 std_log(LOG_FILENAME_LINE,"oil_diffsquaresum_f32 unsuccessful,Expected =%15.14f,Obtained =%15.14f",fcheck[0],fdest[0]); |
|
190 } |
|
191 } |
|
192 |
|
193 |
|
194 void test_squaresum_f64() |
|
195 { |
|
196 int i; |
|
197 double dsrc1[MAX_SIZE1]; |
|
198 double ddest[RES_SIZE]={0},dcheck[RES_SIZE]={19668.00000000000000}; |
|
199 |
|
200 for(i=0;i<MAX_SIZE1;i++) |
|
201 { |
|
202 dsrc1[i]= i*(i+1); |
|
203 std_log(LOG_FILENAME_LINE,"dsrc1[%d]=%15.14f", i,dsrc1[i]); |
|
204 } |
|
205 |
|
206 oil_squaresum_f64(ddest,dsrc1,MAX_SIZE1); |
|
207 |
|
208 if(comparefloats(ddest[0],dcheck[0])==0) |
|
209 { |
|
210 std_log(LOG_FILENAME_LINE,"oil_squaresum_f64 successful, ddest=%15.14f", ddest[0]); |
|
211 } |
|
212 else |
|
213 { |
|
214 assert_failed=1; |
|
215 std_log(LOG_FILENAME_LINE,"oil_squaresum_f64 unsuccessful,Expected =%15.14f,Obtained =%15.14f",dcheck[0],ddest[0]); |
|
216 } |
|
217 } |
|
218 |
|
219 |
|
220 void test_diff_squaresum_f64() |
|
221 { |
|
222 int i; |
|
223 double dsrc1[MAX_SIZE1], dsrc2[MAX_SIZE1]; |
|
224 double ddest[RES_SIZE]={0},dcheck[RES_SIZE]= {539.25000000000000}; |
|
225 |
|
226 for(i=0;i<MAX_SIZE1;i++) |
|
227 { |
|
228 dsrc1[i]= i*(i+1); |
|
229 dsrc2[i]=i*(0.5); |
|
230 std_log(LOG_FILENAME_LINE,"dsrc1[%d]=%15.14f, dsrc2[%d]=%15.14f", i,dsrc1[i],i,dsrc2[i]); |
|
231 } |
|
232 |
|
233 oil_diffsquaresum_f64(ddest,dsrc1,4,dsrc2,2,MAX_SIZE1); |
|
234 |
|
235 if(comparefloats(ddest[0],dcheck[0])==0) |
|
236 { |
|
237 std_log(LOG_FILENAME_LINE,"oil_diffsquaresum_f64 successful, ddest= %15.14f", ddest[0]); |
|
238 } |
|
239 else |
|
240 { |
|
241 assert_failed=1; |
|
242 std_log(LOG_FILENAME_LINE,"oil_diffsquaresum_f64 unsuccessful,Expected =%15.14f,Obtained =%15.14f",dcheck[0],ddest[0]); |
|
243 } |
|
244 } |
|
245 |
|
246 void test_squaresum_shifted_s16() |
|
247 { |
|
248 int16_t arr1[MAX_SIZE2]; |
|
249 uint32_t res[RES_SIZE]={0},check[RES_SIZE]={526}; |
|
250 int i; |
|
251 |
|
252 for(i=0;i<MAX_SIZE2;i++) |
|
253 { |
|
254 arr1[i]=(i+100)*10; |
|
255 } |
|
256 |
|
257 oil_squaresum_shifted_s16(res,arr1,MAX_SIZE2); |
|
258 |
|
259 if(res[0]==check[0]) |
|
260 { |
|
261 std_log(LOG_FILENAME_LINE,"oil_squaresum_shifted_s16 successful, res= %d",res[0]); |
|
262 } |
|
263 else |
|
264 { |
|
265 assert_failed=1; |
|
266 std_log(LOG_FILENAME_LINE,"oil_squaresum_shifted_s16 unsuccessful,Expected =%d,Obtained =%d",check[0],res[0]); |
|
267 } |
|
268 } |
|
269 |
|
270 |
|
271 void test_sum_f64() |
|
272 { |
|
273 double arr[MAX_SIZE2]; |
|
274 double res[RES_SIZE]={0},check[RES_SIZE]={40.0}; |
|
275 int i; |
|
276 |
|
277 for(i=0;i<MAX_SIZE2;i++) |
|
278 arr[i]=(i+3.5)*2; |
|
279 |
|
280 oil_sum_f64(res,arr,2,MAX_SIZE2); |
|
281 |
|
282 if(comparefloats(res[0],check[0])==0) |
|
283 { |
|
284 std_log(LOG_FILENAME_LINE,"oil_sum_f64 successful, res= %15.14f",res[0]); |
|
285 } |
|
286 else |
|
287 { |
|
288 assert_failed=1; |
|
289 std_log(LOG_FILENAME_LINE,"oil_sum_f64 unsuccessful,Expected =%15.14f,Obtained =%15.14f",check[0],res[0]); |
|
290 } |
|
291 } |
|
292 |
|
293 void test_addc_s16() |
|
294 { |
|
295 int16_t arr1[MAX_SIZE2], arr2[MAX_SIZE2],sum[MAX_SIZE2]; |
|
296 int res[MAX_SIZE2]={0,4,8,12,16,20,24,28,32,36,40,44,48,52,56}; |
|
297 int i; |
|
298 |
|
299 for(i=0;i<MAX_SIZE2;i++) |
|
300 { |
|
301 sum[i]=0; |
|
302 arr1[i]=i*4; |
|
303 arr2[i]=i*3; |
|
304 } |
|
305 |
|
306 oil_addc_s16(sum,arr1,arr2,MAX_SIZE2); |
|
307 |
|
308 for(i=0;i<MAX_SIZE2;i++) |
|
309 { |
|
310 if(sum[i] == res[i]) |
|
311 { |
|
312 std_log(LOG_FILENAME_LINE,"oil_addc_s16 successful,sum[%d]=%d",i,sum[i]); |
|
313 } |
|
314 else |
|
315 { |
|
316 assert_failed = 1; |
|
317 std_log(LOG_FILENAME_LINE,"oil_addc_s16 unsuccessful,Expected =%d,Obtained =%d",res[i],sum[i]); |
|
318 } |
|
319 } |
|
320 } |
|
321 |
|
322 |
|
323 void test_addc_rshift_s16() |
|
324 { |
|
325 int16_t arr1[MAX_SIZE2],arr2[MAX_SIZE2],sum[MAX_SIZE2]; |
|
326 int res[MAX_SIZE2]={0,0,1,1,2,2,3,3,4,4,5,5,6,6,7}; |
|
327 int i; |
|
328 |
|
329 for(i=0;i<MAX_SIZE2;i++) |
|
330 { |
|
331 sum[i]=0; |
|
332 arr1[i]=i*4; |
|
333 arr2[i]=i*3; |
|
334 } |
|
335 |
|
336 oil_addc_rshift_s16(sum,arr1,arr2,MAX_SIZE2); |
|
337 |
|
338 for(i=0;i<MAX_SIZE2;i++) |
|
339 { |
|
340 if(sum[i] == res[i]) |
|
341 { |
|
342 std_log(LOG_FILENAME_LINE,"oil_addc_rshift_s16 successful,sum[%d]=%d", sum[i]); |
|
343 } |
|
344 else |
|
345 { |
|
346 assert_failed = 1; |
|
347 std_log(LOG_FILENAME_LINE,"oil_addc_rshift_s16 unsuccessful,Expected =%d,Obtained =%d",res[i],sum[i]); |
|
348 } |
|
349 } |
|
350 } |
|
351 |
|
352 |
|
353 int main () |
|
354 { |
|
355 std_log(LOG_FILENAME_LINE,"Test started testsuite_diff"); |
|
356 oil_init (); |
|
357 |
|
358 std_log(LOG_FILENAME_LINE,"AVERAGE TEST"); |
|
359 test_average_s16_u8(); |
|
360 |
|
361 std_log(LOG_FILENAME_LINE,"DIFF8X8 TEST"); |
|
362 test_diff8x8_s16_u8(); |
|
363 |
|
364 std_log(LOG_FILENAME_LINE,"DIFF_CONST128 TEST"); |
|
365 test_diff_const128_s16_u8(); |
|
366 |
|
367 std_log(LOG_FILENAME_LINE,"SQUARESUM_F32 TEST"); |
|
368 test_squaresum_f32(); |
|
369 |
|
370 std_log(LOG_FILENAME_LINE,"DIFF_SQUARESUM32 TEST"); |
|
371 test_diff_squaresum_f32(); |
|
372 |
|
373 std_log(LOG_FILENAME_LINE,"SQUARESUM_F64 TEST"); |
|
374 test_squaresum_f64(); |
|
375 |
|
376 std_log(LOG_FILENAME_LINE,"DIFF_SQUARESUM64 TEST"); |
|
377 test_diff_squaresum_f64(); |
|
378 |
|
379 std_log(LOG_FILENAME_LINE,"SHIFT_SQUARESUM TEST"); |
|
380 test_squaresum_shifted_s16(); |
|
381 |
|
382 std_log(LOG_FILENAME_LINE,"SUM_F64 TEST"); |
|
383 test_sum_f64(); |
|
384 |
|
385 std_log(LOG_FILENAME_LINE,"ADDC_16 TEST"); |
|
386 test_addc_s16(); |
|
387 |
|
388 std_log(LOG_FILENAME_LINE,"ADDC_16_RSHIFT TEST"); |
|
389 test_addc_rshift_s16(); |
|
390 |
|
391 if(assert_failed) |
|
392 std_log(LOG_FILENAME_LINE,"Test Fail"); |
|
393 else |
|
394 std_log(LOG_FILENAME_LINE,"Test Successful"); |
|
395 |
|
396 create_xml(0); |
|
397 return 0; |
|
398 } |
|
399 |