/src/libhevc/encoder/ia_basic_ops32.h
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Copyright (C) 2018 The Android Open Source Project |
4 | | * |
5 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | | * you may not use this file except in compliance with the License. |
7 | | * You may obtain a copy of the License at: |
8 | | * |
9 | | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | * |
17 | | ***************************************************************************** |
18 | | * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore |
19 | | */ |
20 | | |
21 | | /*****************************************************************************/ |
22 | | /* */ |
23 | | /* File name : ia_basic_ops32.h */ |
24 | | /* */ |
25 | | /* Description : this file has 32bit basic operations */ |
26 | | /* */ |
27 | | /* List of functions: 1. min32 */ |
28 | | /* 2. max32 */ |
29 | | /* 3. mult16x16in32 */ |
30 | | /* 4. mult16x16in32_shl */ |
31 | | /* 5. mult16x16in32_shl_sat */ |
32 | | /* 6. shl32 */ |
33 | | /* 7. shl32_sat */ |
34 | | /* 8. shl32_dir */ |
35 | | /* 9. shl32_dir_sat */ |
36 | | /* 10. shr32 */ |
37 | | /* 11. shr32_dir */ |
38 | | /* 12. shr32_dir_sat */ |
39 | | /* 13. add32 */ |
40 | | /* 14. sub32 */ |
41 | | /* 15. add32_sat */ |
42 | | /* 16. sub32_sat */ |
43 | | /* 17. norm32 */ |
44 | | /* 18. bin_expo32 */ |
45 | | /* 19. abs32 */ |
46 | | /* 20. abs32_sat */ |
47 | | /* 21. negate32 */ |
48 | | /* 22. negate32_sat */ |
49 | | /* 23. div32 */ |
50 | | /* 24. mac16x16in32 */ |
51 | | /* 25. mac16x16in32_shl */ |
52 | | /* 26. mac16x16in32_shl_sat */ |
53 | | /* 27. msu16x16in32 */ |
54 | | /* 28. msu16x16in32_shl */ |
55 | | /* 29. msu16x16in32_shl_sat */ |
56 | | /* 30. add32_shr */ |
57 | | /* 31. sub32_shr */ |
58 | | /* */ |
59 | | /* Issues / problems: none */ |
60 | | /* */ |
61 | | /* Revision history : */ |
62 | | /* */ |
63 | | /* DD MM YYYY author changes */ |
64 | | /* 20 11 2003 aadithya kamath created */ |
65 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
66 | | /* */ |
67 | | /*****************************************************************************/ |
68 | | |
69 | | /*****************************************************************************/ |
70 | | /* File includes */ |
71 | | /* ia_type_def.h */ |
72 | | /* ia_constants.h */ |
73 | | /*****************************************************************************/ |
74 | | |
75 | | #ifndef __IA_BASIC_OPS32_H__ |
76 | | #define __IA_BASIC_OPS32_H__ |
77 | | |
78 | | /*****************************************************************************/ |
79 | | /* */ |
80 | | /* Function name : min32 */ |
81 | | /* */ |
82 | | /* Description : returns the minima of 2 32 bit variables */ |
83 | | /* */ |
84 | | /* Inputs : WORD32 a, WORD32 b */ |
85 | | /* */ |
86 | | /* Globals : none */ |
87 | | /* */ |
88 | | /* Processing : minimum of 2 inputs */ |
89 | | /* */ |
90 | | /* Outputs : none */ |
91 | | /* */ |
92 | | /* Returns : WORD32 min_val - 32 bit signed value */ |
93 | | /* */ |
94 | | /* Issues : none */ |
95 | | /* */ |
96 | | /* Revision history : */ |
97 | | /* */ |
98 | | /* DD MM YYYY author changes */ |
99 | | /* 20 11 2003 aadithya kamath created */ |
100 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
101 | | /* */ |
102 | | /*****************************************************************************/ |
103 | | |
104 | | static PLATFORM_INLINE WORD32 min32(WORD32 a, WORD32 b) |
105 | 0 | { |
106 | 0 | WORD32 min_val; |
107 | 0 |
|
108 | 0 | min_val = (a < b) ? a : b; |
109 | 0 |
|
110 | 0 | return min_val; |
111 | 0 | } Unexecuted instantiation: var_q_operator.c:min32 Unexecuted instantiation: sqrt_interp.c:min32 |
112 | | |
113 | | /*****************************************************************************/ |
114 | | /* */ |
115 | | /* Function name : max32 */ |
116 | | /* */ |
117 | | /* Description : returns the maxima of 2 32 bit variables */ |
118 | | /* */ |
119 | | /* Inputs : WORD32 a, WORD32 b */ |
120 | | /* */ |
121 | | /* Globals : none */ |
122 | | /* */ |
123 | | /* Processing : maximum of 2 inputs */ |
124 | | /* */ |
125 | | /* Outputs : none */ |
126 | | /* */ |
127 | | /* Returns : WORD32 max_val - 32 bit signed value */ |
128 | | /* */ |
129 | | /* Issues : none */ |
130 | | /* */ |
131 | | /* Revision history : */ |
132 | | /* */ |
133 | | /* DD MM YYYY author changes */ |
134 | | /* 20 11 2003 aadithya kamath created */ |
135 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
136 | | /* */ |
137 | | /*****************************************************************************/ |
138 | | |
139 | | static PLATFORM_INLINE WORD32 max32(WORD32 a, WORD32 b) |
140 | 0 | { |
141 | 0 | WORD32 max_val; |
142 | 0 |
|
143 | 0 | max_val = (a > b) ? a : b; |
144 | 0 |
|
145 | 0 | return max_val; |
146 | 0 | } Unexecuted instantiation: var_q_operator.c:max32 Unexecuted instantiation: sqrt_interp.c:max32 |
147 | | |
148 | | /*****************************************************************************/ |
149 | | /* */ |
150 | | /* Function name : shl32 */ |
151 | | /* */ |
152 | | /* Description : shifts a 32-bit value left by specificed bits */ |
153 | | /* */ |
154 | | /* Inputs : WORD32 a, WORD b */ |
155 | | /* */ |
156 | | /* Globals : none */ |
157 | | /* */ |
158 | | /* Processing : shift a by b */ |
159 | | /* */ |
160 | | /* Outputs : none */ |
161 | | /* */ |
162 | | /* Returns : WORD32 out_val - 32 bit signed value */ |
163 | | /* */ |
164 | | /* assumptions : 0 <= b <= 31 */ |
165 | | /* */ |
166 | | /* Issues : none */ |
167 | | /* */ |
168 | | /* Revision history : */ |
169 | | /* */ |
170 | | /* DD MM YYYY author changes */ |
171 | | /* 20 11 2003 aadithya kamath created */ |
172 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
173 | | /* */ |
174 | | /*****************************************************************************/ |
175 | | static PLATFORM_INLINE WORD32 shl32(WORD32 a, WORD b) |
176 | 638M | { |
177 | 638M | WORD32 out_val; |
178 | | |
179 | 638M | if(b > 31) |
180 | 0 | out_val = 0; |
181 | 638M | else |
182 | 638M | out_val = (WORD32)a << b; |
183 | | |
184 | 638M | return out_val; |
185 | 638M | } Line | Count | Source | 176 | 637M | { | 177 | 637M | WORD32 out_val; | 178 | | | 179 | 637M | if(b > 31) | 180 | 0 | out_val = 0; | 181 | 637M | else | 182 | 637M | out_val = (WORD32)a << b; | 183 | | | 184 | 637M | return out_val; | 185 | 637M | } |
Line | Count | Source | 176 | 329k | { | 177 | 329k | WORD32 out_val; | 178 | | | 179 | 329k | if(b > 31) | 180 | 0 | out_val = 0; | 181 | 329k | else | 182 | 329k | out_val = (WORD32)a << b; | 183 | | | 184 | 329k | return out_val; | 185 | 329k | } |
|
186 | | /*****************************************************************************/ |
187 | | /* */ |
188 | | /* Function name : shr32 */ |
189 | | /* */ |
190 | | /* Description : shifts a 32-bit value right by specificed bits */ |
191 | | /* */ |
192 | | /* Inputs : WORD32 a, WORD b */ |
193 | | /* */ |
194 | | /* Globals : none */ |
195 | | /* */ |
196 | | /* Processing : shift right a by b */ |
197 | | /* */ |
198 | | /* Outputs : none */ |
199 | | /* */ |
200 | | /* Returns : WORD32 out_val - 32 bit signed value */ |
201 | | /* */ |
202 | | /* assumptions : 0 <= b <= 31 */ |
203 | | /* */ |
204 | | /* Issues : none */ |
205 | | /* */ |
206 | | /* Revision history : */ |
207 | | /* */ |
208 | | /* DD MM YYYY author changes */ |
209 | | /* 20 11 2003 aadithya kamath created */ |
210 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
211 | | /* */ |
212 | | /*****************************************************************************/ |
213 | | |
214 | | static PLATFORM_INLINE WORD32 shr32(WORD32 a, WORD b) |
215 | 24.4M | { |
216 | 24.4M | WORD32 out_val; |
217 | | |
218 | 24.4M | if(b > 31) |
219 | 121k | { |
220 | 121k | if(a < 0) |
221 | 0 | out_val = -1; |
222 | 121k | else |
223 | 121k | out_val = 0; |
224 | 121k | } |
225 | 24.3M | else |
226 | 24.3M | { |
227 | 24.3M | out_val = (WORD32)a >> b; |
228 | 24.3M | } |
229 | | |
230 | 24.4M | return out_val; |
231 | 24.4M | } Line | Count | Source | 215 | 24.3M | { | 216 | 24.3M | WORD32 out_val; | 217 | | | 218 | 24.3M | if(b > 31) | 219 | 121k | { | 220 | 121k | if(a < 0) | 221 | 0 | out_val = -1; | 222 | 121k | else | 223 | 121k | out_val = 0; | 224 | 121k | } | 225 | 24.2M | else | 226 | 24.2M | { | 227 | 24.2M | out_val = (WORD32)a >> b; | 228 | 24.2M | } | 229 | | | 230 | 24.3M | return out_val; | 231 | 24.3M | } |
|
232 | | |
233 | | /*****************************************************************************/ |
234 | | /* */ |
235 | | /* Function name : shl32_sat */ |
236 | | /* */ |
237 | | /* Description : shifts a 32-bit value left by specificed bits and */ |
238 | | /* saturates it to 32 bits */ |
239 | | /* */ |
240 | | /* Inputs : WORD32 a, WORD b */ |
241 | | /* */ |
242 | | /* Globals : none */ |
243 | | /* */ |
244 | | /* Processing : shift a by 1 b times if crosses 32_bits saturate */ |
245 | | /* */ |
246 | | /* Outputs : none */ |
247 | | /* */ |
248 | | /* Returns : WORD32 out_val - 32 bit signed value */ |
249 | | /* */ |
250 | | /* assumptions : 0 <= b <= 31 */ |
251 | | /* */ |
252 | | /* Issues : none */ |
253 | | /* */ |
254 | | /* Revision history : */ |
255 | | /* */ |
256 | | /* DD MM YYYY author changes */ |
257 | | /* 20 11 2003 aadithya kamath created */ |
258 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
259 | | /* */ |
260 | | /*****************************************************************************/ |
261 | | |
262 | | static PLATFORM_INLINE WORD32 shl32_sat(WORD32 a, WORD b) |
263 | 59.5M | { |
264 | 59.5M | WORD32 out_val = a; |
265 | | /*clip the max shift value to avoid unnecessary looping*/ |
266 | 59.5M | if(b > (WORD)((sizeof(WORD32) * 8))) |
267 | 0 | b = (sizeof(WORD32) * 8); |
268 | 697M | for(; b > 0; b--) |
269 | 637M | { |
270 | 637M | if(a > (WORD32)0X3fffffffL) |
271 | 0 | { |
272 | 0 | out_val = MAX_32; |
273 | 0 | break; |
274 | 0 | } |
275 | 637M | else if(a < (WORD32)0xc0000000L) |
276 | 0 | { |
277 | 0 | out_val = MIN_32; |
278 | 0 | break; |
279 | 0 | } |
280 | | |
281 | 637M | a = shl32(a, 1); |
282 | 637M | out_val = a; |
283 | 637M | } |
284 | 59.5M | return (out_val); |
285 | 59.5M | } var_q_operator.c:shl32_sat Line | Count | Source | 263 | 59.5M | { | 264 | 59.5M | WORD32 out_val = a; | 265 | | /*clip the max shift value to avoid unnecessary looping*/ | 266 | 59.5M | if(b > (WORD)((sizeof(WORD32) * 8))) | 267 | 0 | b = (sizeof(WORD32) * 8); | 268 | 697M | for(; b > 0; b--) | 269 | 637M | { | 270 | 637M | if(a > (WORD32)0X3fffffffL) | 271 | 0 | { | 272 | 0 | out_val = MAX_32; | 273 | 0 | break; | 274 | 0 | } | 275 | 637M | else if(a < (WORD32)0xc0000000L) | 276 | 0 | { | 277 | 0 | out_val = MIN_32; | 278 | 0 | break; | 279 | 0 | } | 280 | | | 281 | 637M | a = shl32(a, 1); | 282 | 637M | out_val = a; | 283 | 637M | } | 284 | 59.5M | return (out_val); | 285 | 59.5M | } |
Unexecuted instantiation: sqrt_interp.c:shl32_sat |
286 | | |
287 | | /*****************************************************************************/ |
288 | | /* */ |
289 | | /* Function name : shl32_dir */ |
290 | | /* */ |
291 | | /* Description : shifts a 32-bit value left by specificed bits, shifts */ |
292 | | /* it right if specified no. of bits is negative */ |
293 | | /* */ |
294 | | /* Inputs : WORD32 a, WORD b */ |
295 | | /* */ |
296 | | /* Globals : none */ |
297 | | /* */ |
298 | | /* Processing : if b -ve shift right else shift left */ |
299 | | /* */ |
300 | | /* Outputs : none */ |
301 | | /* */ |
302 | | /* Returns : WORD32 out_val - 32 bit signed value */ |
303 | | /* */ |
304 | | /* assumptions : -31 <= b <= 31 */ |
305 | | /* */ |
306 | | /* Issues : none */ |
307 | | /* */ |
308 | | /* Revision history : */ |
309 | | /* */ |
310 | | /* DD MM YYYY author changes */ |
311 | | /* 20 11 2003 aadithya kamath created */ |
312 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
313 | | /* */ |
314 | | /*****************************************************************************/ |
315 | | |
316 | | static PLATFORM_INLINE WORD32 shl32_dir(WORD32 a, WORD b) |
317 | 0 | { |
318 | 0 | WORD32 out_val; |
319 | 0 |
|
320 | 0 | if(b < 0) |
321 | 0 | { |
322 | 0 | out_val = shr32(a, -b); |
323 | 0 | } |
324 | 0 | else |
325 | 0 | { |
326 | 0 | out_val = shl32(a, b); |
327 | 0 | } |
328 | 0 |
|
329 | 0 | return out_val; |
330 | 0 | } Unexecuted instantiation: var_q_operator.c:shl32_dir Unexecuted instantiation: sqrt_interp.c:shl32_dir |
331 | | |
332 | | /*****************************************************************************/ |
333 | | /* */ |
334 | | /* Function name : shl32_dir_sat */ |
335 | | /* */ |
336 | | /* Description : shifts a 32-bit value left by specificed bits with sat, */ |
337 | | /* shifts it right if specified no. of bits is negative */ |
338 | | /* */ |
339 | | /* Inputs : WORD32 a, WORD b */ |
340 | | /* */ |
341 | | /* Globals : none */ |
342 | | /* */ |
343 | | /* Processing : if b -ve shift right else shift left with sat */ |
344 | | /* */ |
345 | | /* Outputs : none */ |
346 | | /* */ |
347 | | /* Returns : WORD32 out_val - 32 bit signed value */ |
348 | | /* */ |
349 | | /* assumptions : -31 <= b <= 31 */ |
350 | | /* */ |
351 | | /* Issues : none */ |
352 | | /* */ |
353 | | /* Revision history : */ |
354 | | /* */ |
355 | | /* DD MM YYYY author changes */ |
356 | | /* 20 11 2003 aadithya kamath created */ |
357 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
358 | | /* */ |
359 | | /*****************************************************************************/ |
360 | | |
361 | | static PLATFORM_INLINE WORD32 shl32_dir_sat(WORD32 a, WORD b) |
362 | 24.4M | { |
363 | 24.4M | WORD32 out_val; |
364 | | |
365 | 24.4M | if(b < 0) |
366 | 1.54M | { |
367 | 1.54M | out_val = shr32(a, -b); |
368 | 1.54M | } |
369 | 22.9M | else |
370 | 22.9M | { |
371 | 22.9M | out_val = shl32_sat(a, b); |
372 | 22.9M | } |
373 | | |
374 | 24.4M | return out_val; |
375 | 24.4M | } var_q_operator.c:shl32_dir_sat Line | Count | Source | 362 | 24.4M | { | 363 | 24.4M | WORD32 out_val; | 364 | | | 365 | 24.4M | if(b < 0) | 366 | 1.54M | { | 367 | 1.54M | out_val = shr32(a, -b); | 368 | 1.54M | } | 369 | 22.9M | else | 370 | 22.9M | { | 371 | 22.9M | out_val = shl32_sat(a, b); | 372 | 22.9M | } | 373 | | | 374 | 24.4M | return out_val; | 375 | 24.4M | } |
Unexecuted instantiation: sqrt_interp.c:shl32_dir_sat |
376 | | |
377 | | /*****************************************************************************/ |
378 | | /* */ |
379 | | /* Function name : shr32_dir */ |
380 | | /* */ |
381 | | /* Description : shifts a 32-bit value right by specificed bits, shifts */ |
382 | | /* it left if specified no. of bits is negative */ |
383 | | /* */ |
384 | | /* Inputs : WORD32 a, WORD b */ |
385 | | /* */ |
386 | | /* Globals : none */ |
387 | | /* */ |
388 | | /* Processing : if b +ve shift right else shift left */ |
389 | | /* */ |
390 | | /* Outputs : none */ |
391 | | /* */ |
392 | | /* Returns : WORD32 out_val - 32 bit signed value */ |
393 | | /* */ |
394 | | /* assumptions : -31 <= b <= 31 */ |
395 | | /* */ |
396 | | /* Issues : none */ |
397 | | /* */ |
398 | | /* Revision history : */ |
399 | | /* */ |
400 | | /* DD MM YYYY author changes */ |
401 | | /* 20 11 2003 aadithya kamath created */ |
402 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
403 | | /* */ |
404 | | /*****************************************************************************/ |
405 | | |
406 | | static PLATFORM_INLINE WORD32 shr32_dir(WORD32 a, WORD b) |
407 | 0 | { |
408 | 0 | WORD32 out_val; |
409 | 0 |
|
410 | 0 | if(b < 0) |
411 | 0 | { |
412 | 0 | out_val = shl32(a, -b); |
413 | 0 | } |
414 | 0 | else |
415 | 0 | { |
416 | 0 | out_val = shr32(a, b); |
417 | 0 | } |
418 | 0 |
|
419 | 0 | return out_val; |
420 | 0 | } Unexecuted instantiation: var_q_operator.c:shr32_dir Unexecuted instantiation: sqrt_interp.c:shr32_dir |
421 | | |
422 | | /*****************************************************************************/ |
423 | | /* */ |
424 | | /* Function name : shr32_dir_sat */ |
425 | | /* */ |
426 | | /* Description : shifts a 32-bit value right by specificed bits, shifts */ |
427 | | /* it left with sat if specified no. of bits is negative */ |
428 | | /* */ |
429 | | /* Inputs : WORD32 a, WORD b */ |
430 | | /* */ |
431 | | /* Globals : none */ |
432 | | /* */ |
433 | | /* Processing : if b +ve shift right else shift left with sat */ |
434 | | /* */ |
435 | | /* Outputs : none */ |
436 | | /* */ |
437 | | /* Returns : WORD32 out_val - 32 bit signed value */ |
438 | | /* */ |
439 | | /* assumptions : -31 <= b <= 31 */ |
440 | | /* */ |
441 | | /* Issues : none */ |
442 | | /* */ |
443 | | /* Revision history : */ |
444 | | /* */ |
445 | | /* DD MM YYYY author changes */ |
446 | | /* 20 11 2003 aadithya kamath created */ |
447 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
448 | | /* */ |
449 | | /*****************************************************************************/ |
450 | | |
451 | | static PLATFORM_INLINE WORD32 shr32_dir_sat(WORD32 a, WORD b) |
452 | 39.1M | { |
453 | 39.1M | WORD32 out_val; |
454 | | |
455 | 39.1M | if(b < 0) |
456 | 16.3M | { |
457 | 16.3M | out_val = shl32_sat(a, -b); |
458 | 16.3M | } |
459 | 22.8M | else |
460 | 22.8M | { |
461 | 22.8M | out_val = shr32(a, b); |
462 | 22.8M | } |
463 | | |
464 | 39.1M | return out_val; |
465 | 39.1M | } var_q_operator.c:shr32_dir_sat Line | Count | Source | 452 | 39.1M | { | 453 | 39.1M | WORD32 out_val; | 454 | | | 455 | 39.1M | if(b < 0) | 456 | 16.3M | { | 457 | 16.3M | out_val = shl32_sat(a, -b); | 458 | 16.3M | } | 459 | 22.8M | else | 460 | 22.8M | { | 461 | 22.8M | out_val = shr32(a, b); | 462 | 22.8M | } | 463 | | | 464 | 39.1M | return out_val; | 465 | 39.1M | } |
Unexecuted instantiation: sqrt_interp.c:shr32_dir_sat |
466 | | |
467 | | /*****************************************************************************/ |
468 | | /* */ |
469 | | /* Function name : mult16x16in32 */ |
470 | | /* */ |
471 | | /* Description : multiplies two 16 bit numbers and returns their 32-bit */ |
472 | | /* result */ |
473 | | /* */ |
474 | | /* Inputs : WORD16 a, WORD16 b */ |
475 | | /* */ |
476 | | /* Globals : none */ |
477 | | /* */ |
478 | | /* Processing : multiply 2 inputs */ |
479 | | /* */ |
480 | | /* Outputs : none */ |
481 | | /* */ |
482 | | /* Returns : WORD32 product - 32 bit signed value */ |
483 | | /* */ |
484 | | /* Issues : none */ |
485 | | /* */ |
486 | | /* Revision history : */ |
487 | | /* */ |
488 | | /* DD MM YYYY author changes */ |
489 | | /* 20 11 2003 aadithya kamath created */ |
490 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
491 | | /* */ |
492 | | /*****************************************************************************/ |
493 | | |
494 | | static PLATFORM_INLINE WORD32 mult16x16in32(WORD16 a, WORD16 b) |
495 | 0 | { |
496 | 0 | WORD32 product; |
497 | 0 |
|
498 | 0 | product = (WORD32)a * (WORD32)b; |
499 | 0 |
|
500 | 0 | return product; |
501 | 0 | } Unexecuted instantiation: var_q_operator.c:mult16x16in32 Unexecuted instantiation: sqrt_interp.c:mult16x16in32 |
502 | | |
503 | | /*****************************************************************************/ |
504 | | /* */ |
505 | | /* Function name : mult16x16in32_shl */ |
506 | | /* */ |
507 | | /* Description : multiplies two 16 bit numbers and returns their 32-bit */ |
508 | | /* result after removing 1 redundant sign bit. no sat */ |
509 | | /* */ |
510 | | /* Inputs : WORD16 a, WORD16 b */ |
511 | | /* */ |
512 | | /* Globals : none */ |
513 | | /* */ |
514 | | /* Processing : multiply 2 inputs, shift left by 1 */ |
515 | | /* */ |
516 | | /* Outputs : none */ |
517 | | /* */ |
518 | | /* Returns : WORD32 product - 32 bit signed value */ |
519 | | /* */ |
520 | | /* Issues : none */ |
521 | | /* */ |
522 | | /* Revision history : */ |
523 | | /* */ |
524 | | /* DD MM YYYY author changes */ |
525 | | /* 20 11 2003 aadithya kamath created */ |
526 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
527 | | /* */ |
528 | | /*****************************************************************************/ |
529 | | |
530 | | static PLATFORM_INLINE WORD32 mult16x16in32_shl(WORD16 a, WORD16 b) |
531 | 0 | { |
532 | 0 | WORD32 product; |
533 | 0 |
|
534 | 0 | product = shl32(mult16x16in32(a, b), 1); |
535 | 0 |
|
536 | 0 | return product; |
537 | 0 | } Unexecuted instantiation: var_q_operator.c:mult16x16in32_shl Unexecuted instantiation: sqrt_interp.c:mult16x16in32_shl |
538 | | |
539 | | /*****************************************************************************/ |
540 | | /* */ |
541 | | /* Function name : mult16x16in32_shl_sat */ |
542 | | /* */ |
543 | | /* Description : multiplies two 16 bit numbers and returns their 32-bit */ |
544 | | /* result after removing 1 redundant sign bit with sat */ |
545 | | /* */ |
546 | | /* Inputs : WORD16 a, WORD16 b */ |
547 | | /* */ |
548 | | /* Globals : none */ |
549 | | /* */ |
550 | | /* Processing : if inputs mi_ns return MAX32 else */ |
551 | | /* multiply 2 inputs shift left by 1 */ |
552 | | /* */ |
553 | | /* Outputs : none */ |
554 | | /* */ |
555 | | /* Returns : WORD32 product - 32 bit signed value */ |
556 | | /* */ |
557 | | /* Issues : none */ |
558 | | /* */ |
559 | | /* Revision history : */ |
560 | | /* */ |
561 | | /* DD MM YYYY author changes */ |
562 | | /* 20 11 2003 aadithya kamath created */ |
563 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
564 | | /* */ |
565 | | /*****************************************************************************/ |
566 | | |
567 | | static PLATFORM_INLINE WORD32 mult16x16in32_shl_sat(WORD16 a, WORD16 b) |
568 | 0 | { |
569 | 0 | WORD32 product; |
570 | 0 | product = (WORD32)a * (WORD32)b; |
571 | 0 | if(product != (WORD32)0x40000000L) |
572 | 0 | { |
573 | 0 | product = shl32(product, 1); |
574 | 0 | } |
575 | 0 | else |
576 | 0 | { |
577 | 0 | product = MAX_32; |
578 | 0 | } |
579 | 0 | return product; |
580 | 0 | } Unexecuted instantiation: var_q_operator.c:mult16x16in32_shl_sat Unexecuted instantiation: sqrt_interp.c:mult16x16in32_shl_sat |
581 | | |
582 | | /*****************************************************************************/ |
583 | | /* */ |
584 | | /* Function name : add32 */ |
585 | | /* */ |
586 | | /* Description : adds 2 32 bit variables without sat */ |
587 | | /* */ |
588 | | /* Inputs : WORD32 a, WORD32 b */ |
589 | | /* */ |
590 | | /* Globals : none */ |
591 | | /* */ |
592 | | /* Processing : add 2 inputs */ |
593 | | /* */ |
594 | | /* Outputs : none */ |
595 | | /* */ |
596 | | /* Returns : WORD32 sum - 32 bit signed value */ |
597 | | /* */ |
598 | | /* Issues : none */ |
599 | | /* */ |
600 | | /* Revision history : */ |
601 | | /* */ |
602 | | /* DD MM YYYY author changes */ |
603 | | /* 20 11 2003 aadithya kamath created */ |
604 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
605 | | /* */ |
606 | | /*****************************************************************************/ |
607 | | |
608 | | static PLATFORM_INLINE WORD32 add32(WORD32 a, WORD32 b) |
609 | 19.6M | { |
610 | 19.6M | WORD32 sum; |
611 | | |
612 | 19.6M | sum = (WORD32)a + (WORD32)b; |
613 | | |
614 | 19.6M | return sum; |
615 | 19.6M | } Line | Count | Source | 609 | 19.5M | { | 610 | 19.5M | WORD32 sum; | 611 | | | 612 | 19.5M | sum = (WORD32)a + (WORD32)b; | 613 | | | 614 | 19.5M | return sum; | 615 | 19.5M | } |
Line | Count | Source | 609 | 82.3k | { | 610 | 82.3k | WORD32 sum; | 611 | | | 612 | 82.3k | sum = (WORD32)a + (WORD32)b; | 613 | | | 614 | 82.3k | return sum; | 615 | 82.3k | } |
|
616 | | |
617 | | /*****************************************************************************/ |
618 | | /* */ |
619 | | /* Function name : sub32 */ |
620 | | /* */ |
621 | | /* Description : subs 2 32 bit variables without sat */ |
622 | | /* */ |
623 | | /* Inputs : WORD32 a, WORD32 b */ |
624 | | /* */ |
625 | | /* Globals : none */ |
626 | | /* */ |
627 | | /* Processing : sub 2 inputs */ |
628 | | /* */ |
629 | | /* Outputs : none */ |
630 | | /* */ |
631 | | /* Returns : WORD32 diff - 32 bit signed value */ |
632 | | /* */ |
633 | | /* Issues : none */ |
634 | | /* */ |
635 | | /* Revision history : */ |
636 | | /* */ |
637 | | /* DD MM YYYY author changes */ |
638 | | /* 20 11 2003 aadithya kamath created */ |
639 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
640 | | /* */ |
641 | | /*****************************************************************************/ |
642 | | |
643 | | static PLATFORM_INLINE WORD32 sub32(WORD32 a, WORD32 b) |
644 | 3.78M | { |
645 | 3.78M | WORD32 diff; |
646 | | |
647 | 3.78M | diff = (WORD32)a - (WORD32)b; |
648 | | |
649 | 3.78M | return diff; |
650 | 3.78M | } Line | Count | Source | 644 | 3.70M | { | 645 | 3.70M | WORD32 diff; | 646 | | | 647 | 3.70M | diff = (WORD32)a - (WORD32)b; | 648 | | | 649 | 3.70M | return diff; | 650 | 3.70M | } |
Line | Count | Source | 644 | 82.3k | { | 645 | 82.3k | WORD32 diff; | 646 | | | 647 | 82.3k | diff = (WORD32)a - (WORD32)b; | 648 | | | 649 | 82.3k | return diff; | 650 | 82.3k | } |
|
651 | | |
652 | | /*****************************************************************************/ |
653 | | /* */ |
654 | | /* Function name : add32_sat */ |
655 | | /* */ |
656 | | /* Description : adds 2 32 bit variables with sat */ |
657 | | /* */ |
658 | | /* Inputs : WORD32 a, WORD32 b */ |
659 | | /* */ |
660 | | /* Globals : none */ |
661 | | /* */ |
662 | | /* Processing : add 2 inputs if overflow saturate */ |
663 | | /* */ |
664 | | /* Outputs : none */ |
665 | | /* */ |
666 | | /* Returns : WORD32 sum - 32 bit signed value */ |
667 | | /* */ |
668 | | /* Issues : none */ |
669 | | /* */ |
670 | | /* Revision history : */ |
671 | | /* */ |
672 | | /* DD MM YYYY author changes */ |
673 | | /* 20 11 2003 aadithya kamath created */ |
674 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
675 | | /* */ |
676 | | /*****************************************************************************/ |
677 | | |
678 | | static PLATFORM_INLINE WORD32 add32_sat(WORD32 a, WORD32 b) |
679 | 0 | { |
680 | 0 | WORD32 sum; |
681 | 0 |
|
682 | 0 | sum = add32(a, b); |
683 | 0 |
|
684 | 0 | if((((WORD32)a ^ (WORD32)b) & (WORD32)MIN_32) == 0) |
685 | 0 | { |
686 | 0 | if(((WORD32)sum ^ (WORD32)a) & (WORD32)MIN_32) |
687 | 0 | { |
688 | 0 | sum = (a < 0) ? MIN_32 : MAX_32; |
689 | 0 | } |
690 | 0 | } |
691 | 0 |
|
692 | 0 | return sum; |
693 | 0 | } Unexecuted instantiation: var_q_operator.c:add32_sat Unexecuted instantiation: sqrt_interp.c:add32_sat |
694 | | |
695 | | /*****************************************************************************/ |
696 | | /* */ |
697 | | /* Function name : sub32_sat */ |
698 | | /* */ |
699 | | /* Description : subs 2 32 bit variables with sat */ |
700 | | /* */ |
701 | | /* Inputs : WORD32 a, WORD32 b */ |
702 | | /* */ |
703 | | /* Globals : none */ |
704 | | /* */ |
705 | | /* Processing : sub 2 inputs, if overflow saturate */ |
706 | | /* */ |
707 | | /* Outputs : none */ |
708 | | /* */ |
709 | | /* Returns : WORD32 diff - 32 bit signed value */ |
710 | | /* */ |
711 | | /* Issues : none */ |
712 | | /* */ |
713 | | /* Revision history : */ |
714 | | /* */ |
715 | | /* DD MM YYYY author changes */ |
716 | | /* 20 11 2003 aadithya kamath created */ |
717 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
718 | | /* */ |
719 | | /*****************************************************************************/ |
720 | | |
721 | | static PLATFORM_INLINE WORD32 sub32_sat(WORD32 a, WORD32 b) |
722 | 0 | { |
723 | 0 | WORD32 diff; |
724 | 0 |
|
725 | 0 | diff = sub32(a, b); |
726 | 0 |
|
727 | 0 | if((((WORD32)a ^ (WORD32)b) & (WORD32)MIN_32) != 0) |
728 | 0 | { |
729 | 0 | if(((WORD32)diff ^ (WORD32)a) & (WORD32)MIN_32) |
730 | 0 | { |
731 | 0 | diff = (a < 0L) ? MIN_32 : MAX_32; |
732 | 0 | } |
733 | 0 | } |
734 | 0 |
|
735 | 0 | return (diff); |
736 | 0 | } Unexecuted instantiation: var_q_operator.c:sub32_sat Unexecuted instantiation: sqrt_interp.c:sub32_sat |
737 | | |
738 | | /*****************************************************************************/ |
739 | | /* */ |
740 | | /* Function name : norm32 */ |
741 | | /* */ |
742 | | /* Description : returns number of redundant sign bits in a */ |
743 | | /* 32-bit value. for a value of 0, returns 0 */ |
744 | | /* */ |
745 | | /* Inputs : WORD32 a */ |
746 | | /* */ |
747 | | /* Globals : none */ |
748 | | /* */ |
749 | | /* Processing : abs input, left shift till reaches 0x40000000 */ |
750 | | /* return no. of left shifts */ |
751 | | /* */ |
752 | | /* Outputs : none */ |
753 | | /* */ |
754 | | /* Returns : WORD norm_val - 0 <= norm_val < 32 */ |
755 | | /* */ |
756 | | /* Issues : none */ |
757 | | /* */ |
758 | | /* Revision history : */ |
759 | | /* */ |
760 | | /* DD MM YYYY author changes */ |
761 | | /* 20 11 2003 aadithya kamath created */ |
762 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
763 | | /* */ |
764 | | /*****************************************************************************/ |
765 | | |
766 | | static PLATFORM_INLINE WORD norm32(WORD32 a) |
767 | 84.7M | { |
768 | 84.7M | WORD norm_val; |
769 | | |
770 | 84.7M | if(a == 0) |
771 | 3.14M | { |
772 | 3.14M | norm_val = 31; |
773 | 3.14M | } |
774 | 81.6M | else |
775 | 81.6M | { |
776 | 81.6M | if(a == (WORD32)0xffffffffL) |
777 | 8 | { |
778 | 8 | norm_val = 31; |
779 | 8 | } |
780 | 81.6M | else |
781 | 81.6M | { |
782 | 81.6M | if(a < 0) |
783 | 1.36M | { |
784 | 1.36M | a = ~a; |
785 | 1.36M | } |
786 | 985M | for(norm_val = 0; a < (WORD32)0x40000000L; norm_val++) |
787 | 903M | { |
788 | 903M | a <<= 1; |
789 | 903M | } |
790 | 81.6M | } |
791 | 81.6M | } |
792 | | |
793 | 84.7M | return norm_val; |
794 | 84.7M | } Line | Count | Source | 767 | 84.6M | { | 768 | 84.6M | WORD norm_val; | 769 | | | 770 | 84.6M | if(a == 0) | 771 | 3.14M | { | 772 | 3.14M | norm_val = 31; | 773 | 3.14M | } | 774 | 81.5M | else | 775 | 81.5M | { | 776 | 81.5M | if(a == (WORD32)0xffffffffL) | 777 | 8 | { | 778 | 8 | norm_val = 31; | 779 | 8 | } | 780 | 81.5M | else | 781 | 81.5M | { | 782 | 81.5M | if(a < 0) | 783 | 1.36M | { | 784 | 1.36M | a = ~a; | 785 | 1.36M | } | 786 | 984M | for(norm_val = 0; a < (WORD32)0x40000000L; norm_val++) | 787 | 903M | { | 788 | 903M | a <<= 1; | 789 | 903M | } | 790 | 81.5M | } | 791 | 81.5M | } | 792 | | | 793 | 84.6M | return norm_val; | 794 | 84.6M | } |
|
795 | | |
796 | | /*****************************************************************************/ |
797 | | /* */ |
798 | | /* Function name : bin_expo32 */ |
799 | | /* */ |
800 | | /* Description : returns the position of the most significant bit. */ |
801 | | /* for negative numbers, it ignores leading zeros to */ |
802 | | /* determine the position of most significant bit. */ |
803 | | /* note: for a value of zero returns 31 */ |
804 | | /* */ |
805 | | /* Inputs : WORD32 a */ |
806 | | /* */ |
807 | | /* Globals : none */ |
808 | | /* */ |
809 | | /* Processing : substract 31 from norm_val */ |
810 | | /* */ |
811 | | /* Outputs : none */ |
812 | | /* */ |
813 | | /* Returns : WORD bin_expo_val - 0 <= val < 32 */ |
814 | | /* */ |
815 | | /* Issues : none */ |
816 | | /* */ |
817 | | /* Revision history : */ |
818 | | /* */ |
819 | | /* DD MM YYYY author changes */ |
820 | | /* 20 11 2003 aadithya kamath created */ |
821 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
822 | | /* */ |
823 | | /*****************************************************************************/ |
824 | | |
825 | | static PLATFORM_INLINE WORD bin_expo32(WORD32 a) |
826 | 0 | { |
827 | 0 | WORD bin_expo_val; |
828 | 0 |
|
829 | 0 | bin_expo_val = 31 - norm32(a); |
830 | 0 |
|
831 | 0 | return bin_expo_val; |
832 | 0 | } Unexecuted instantiation: var_q_operator.c:bin_expo32 Unexecuted instantiation: sqrt_interp.c:bin_expo32 |
833 | | |
834 | | /*****************************************************************************/ |
835 | | /* */ |
836 | | /* Function name : abs32 */ |
837 | | /* */ |
838 | | /* Description : returns the value of 32-bit number without sat. */ |
839 | | /* */ |
840 | | /* Inputs : WORD32 a */ |
841 | | /* */ |
842 | | /* Globals : none */ |
843 | | /* */ |
844 | | /* Processing : if -ve then negate */ |
845 | | /* */ |
846 | | /* Outputs : none */ |
847 | | /* */ |
848 | | /* Returns : WORD32 abs_val - 32 bit signed value */ |
849 | | /* */ |
850 | | /* Issues : none */ |
851 | | /* */ |
852 | | /* Revision history : */ |
853 | | /* */ |
854 | | /* DD MM YYYY author changes */ |
855 | | /* 20 11 2003 aadithya kamath created */ |
856 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
857 | | /* */ |
858 | | /*****************************************************************************/ |
859 | | |
860 | | static PLATFORM_INLINE WORD32 abs32(WORD32 a) |
861 | 0 | { |
862 | 0 | WORD32 abs_val; |
863 | 0 |
|
864 | 0 | abs_val = a; |
865 | 0 |
|
866 | 0 | if(a < 0) |
867 | 0 | { |
868 | 0 | abs_val = -a; |
869 | 0 | } |
870 | 0 |
|
871 | 0 | return abs_val; |
872 | 0 | } Unexecuted instantiation: var_q_operator.c:abs32 Unexecuted instantiation: sqrt_interp.c:abs32 |
873 | | |
874 | | /*****************************************************************************/ |
875 | | /* */ |
876 | | /* Function name : abs32_sat */ |
877 | | /* */ |
878 | | /* Description : returns the value of 32-bit number with sat. */ |
879 | | /* */ |
880 | | /* Inputs : WORD32 a */ |
881 | | /* */ |
882 | | /* Globals : none */ |
883 | | /* */ |
884 | | /* Processing : if -ve then negate, abs(-32768) is 32767 */ |
885 | | /* */ |
886 | | /* Outputs : none */ |
887 | | /* */ |
888 | | /* Returns : WORD32 abs_val - 32 bit signed value */ |
889 | | /* */ |
890 | | /* Issues : none */ |
891 | | /* */ |
892 | | /* Revision history : */ |
893 | | /* */ |
894 | | /* DD MM YYYY author changes */ |
895 | | /* 20 11 2003 aadithya kamath created */ |
896 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
897 | | /* */ |
898 | | /*****************************************************************************/ |
899 | | |
900 | | static PLATFORM_INLINE WORD32 abs32_sat(WORD32 a) |
901 | 0 | { |
902 | 0 | WORD32 abs_val; |
903 | 0 |
|
904 | 0 | abs_val = a; |
905 | 0 |
|
906 | 0 | if(a == (WORD32)MIN_32) |
907 | 0 | { |
908 | 0 | abs_val = MAX_32; |
909 | 0 | } |
910 | 0 | else if(a < 0) |
911 | 0 | { |
912 | 0 | abs_val = -a; |
913 | 0 | } |
914 | 0 |
|
915 | 0 | return abs_val; |
916 | 0 | } Unexecuted instantiation: var_q_operator.c:abs32_sat Unexecuted instantiation: sqrt_interp.c:abs32_sat |
917 | | |
918 | | /*****************************************************************************/ |
919 | | /* */ |
920 | | /* Function name : negate32 */ |
921 | | /* */ |
922 | | /* Description : returns the negated value of 32-bit number without sat. */ |
923 | | /* */ |
924 | | /* Inputs : WORD32 a */ |
925 | | /* */ |
926 | | /* Globals : none */ |
927 | | /* */ |
928 | | /* Processing : negate input */ |
929 | | /* */ |
930 | | /* Outputs : none */ |
931 | | /* */ |
932 | | /* Returns : WORD32 neg_val - 32 bit signed value */ |
933 | | /* */ |
934 | | /* Issues : none */ |
935 | | /* */ |
936 | | /* Revision history : */ |
937 | | /* */ |
938 | | /* DD MM YYYY author changes */ |
939 | | /* 20 11 2003 aadithya kamath created */ |
940 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
941 | | /* */ |
942 | | /*****************************************************************************/ |
943 | | |
944 | | static PLATFORM_INLINE WORD32 negate32(WORD32 a) |
945 | 0 | { |
946 | 0 | WORD32 neg_val; |
947 | 0 |
|
948 | 0 | neg_val = -a; |
949 | 0 |
|
950 | 0 | return neg_val; |
951 | 0 | } Unexecuted instantiation: var_q_operator.c:negate32 Unexecuted instantiation: sqrt_interp.c:negate32 |
952 | | |
953 | | /*****************************************************************************/ |
954 | | /* */ |
955 | | /* Function name : negate32 */ |
956 | | /* */ |
957 | | /* Description : returns the negated value of 32-bit number with sat. */ |
958 | | /* */ |
959 | | /* Inputs : WORD32 a */ |
960 | | /* */ |
961 | | /* Globals : none */ |
962 | | /* */ |
963 | | /* Processing : negate input, if -32768 then 32767 */ |
964 | | /* */ |
965 | | /* Outputs : none */ |
966 | | /* */ |
967 | | /* Returns : WORD32 neg_val - 32 bit signed value */ |
968 | | /* */ |
969 | | /* Issues : none */ |
970 | | /* */ |
971 | | /* Revision history : */ |
972 | | /* */ |
973 | | /* DD MM YYYY author changes */ |
974 | | /* 20 11 2003 aadithya kamath created */ |
975 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
976 | | /* */ |
977 | | /*****************************************************************************/ |
978 | | |
979 | | static PLATFORM_INLINE WORD32 negate32_sat(WORD32 a) |
980 | 0 | { |
981 | 0 | WORD32 neg_val; |
982 | 0 |
|
983 | 0 | neg_val = -a; |
984 | 0 | if(a == (WORD32)MIN_32) |
985 | 0 | { |
986 | 0 | neg_val = MAX_32; |
987 | 0 | } |
988 | 0 |
|
989 | 0 | return neg_val; |
990 | 0 | } Unexecuted instantiation: var_q_operator.c:negate32_sat Unexecuted instantiation: sqrt_interp.c:negate32_sat |
991 | | /*****************************************************************************/ |
992 | | /* */ |
993 | | /* Function name : subc_32 */ |
994 | | /* */ |
995 | | /* Description : implemnets the subc operation c64x . */ |
996 | | /* */ |
997 | | /* Inputs : WORD32 a, WORD32 b */ |
998 | | /* */ |
999 | | /* Globals : none */ |
1000 | | /* */ |
1001 | | /* Processing : implemnets the subc operation c64x */ |
1002 | | /* */ |
1003 | | /* Outputs : none */ |
1004 | | /* */ |
1005 | | /* Returns : WORD32 neg_val - 32 bit signed value */ |
1006 | | /* */ |
1007 | | /* Issues : none */ |
1008 | | /* */ |
1009 | | /* Revision history : */ |
1010 | | /* */ |
1011 | | /* DD MM YYYY author changes */ |
1012 | | /* 20 11 2003 Mudit Mehrotra created */ |
1013 | | /* */ |
1014 | | /*****************************************************************************/ |
1015 | | static PLATFORM_INLINE UWORD32 subc_32(UWORD32 nr, UWORD32 dr) |
1016 | 275M | { |
1017 | 275M | UWORD32 result; |
1018 | 275M | if(nr >= dr) |
1019 | 133M | { |
1020 | 133M | result = (((nr - dr) << 1) + 1); |
1021 | 133M | } |
1022 | 142M | else |
1023 | 142M | { |
1024 | 142M | result = (UWORD32)nr << 1; |
1025 | 142M | } |
1026 | 275M | return (result); |
1027 | 275M | } Unexecuted instantiation: sqrt_interp.c:subc_32 |
1028 | | |
1029 | | /*****************************************************************************/ |
1030 | | /* */ |
1031 | | /* Function name : div32 */ |
1032 | | /* */ |
1033 | | /* Description : divides 2 32 bit variables and returns the quotient */ |
1034 | | /* the q-format of the result is modified */ |
1035 | | /* ( a/b to Q30 precision) */ |
1036 | | /* */ |
1037 | | /* Inputs : WORD32 a, WORD32 b, WORD16 *q_format */ |
1038 | | /* */ |
1039 | | /* Globals : none */ |
1040 | | /* */ |
1041 | | /* Processing : non-restoration algo(shift & substract) */ |
1042 | | /* */ |
1043 | | /* Outputs : none */ |
1044 | | /* */ |
1045 | | /* Returns : WORD32 quotient - 32 bit signed value */ |
1046 | | /* */ |
1047 | | /* Issues : none */ |
1048 | | /* */ |
1049 | | /* Revision history : */ |
1050 | | /* */ |
1051 | | /* DD MM YYYY author changes */ |
1052 | | /* 20 11 2003 aadithya kamath created */ |
1053 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
1054 | | /* */ |
1055 | | /*****************************************************************************/ |
1056 | | static PLATFORM_INLINE WORD32 div32(WORD32 a, WORD32 b, WORD *q_format) |
1057 | 8.89M | { |
1058 | 8.89M | WORD32 quotient; |
1059 | 8.89M | UWORD32 mantissa_nr, mantissa_dr; |
1060 | 8.89M | WORD sign = 0; |
1061 | | |
1062 | 8.89M | LOOPINDEX i; |
1063 | 8.89M | WORD q_nr, q_dr; |
1064 | | |
1065 | 8.89M | mantissa_nr = a; |
1066 | 8.89M | mantissa_dr = b; |
1067 | 8.89M | quotient = 0; |
1068 | | |
1069 | 8.89M | if((a < 0) && (0 != b)) |
1070 | 39.2k | { |
1071 | 39.2k | a = -a; |
1072 | 39.2k | sign = (WORD)(sign ^ -1); |
1073 | 39.2k | } |
1074 | | |
1075 | 8.89M | if(b < 0) |
1076 | 48.1k | { |
1077 | 48.1k | b = -b; |
1078 | 48.1k | sign = (WORD)(sign ^ -1); |
1079 | 48.1k | } |
1080 | | |
1081 | 8.89M | if(0 == b) |
1082 | 0 | { |
1083 | 0 | *q_format = 0; |
1084 | 0 | return (a); |
1085 | 0 | } |
1086 | | |
1087 | 8.89M | quotient = 0; |
1088 | | |
1089 | 8.89M | q_nr = norm32(a); |
1090 | 8.89M | mantissa_nr = (UWORD32)a << (q_nr); |
1091 | 8.89M | q_dr = norm32(b); |
1092 | 8.89M | mantissa_dr = (UWORD32)b << (q_dr); |
1093 | 8.89M | *q_format = (WORD)(30 + q_nr - q_dr); |
1094 | | |
1095 | 284M | for(i = 0; i < 31; i++) |
1096 | 275M | { |
1097 | | /* quotient = quotient << 1; */ |
1098 | 275M | WORD32 bit; |
1099 | | |
1100 | | /*if(mantissa_nr >= mantissa_dr) |
1101 | | { |
1102 | | |
1103 | | mantissa_nr = (((mantissa_nr - mantissa_dr) << 1) + 1); |
1104 | | } |
1105 | | else |
1106 | | { |
1107 | | mantissa_nr = (UWORD32)mantissa_nr << 1; |
1108 | | } |
1109 | | */ |
1110 | 275M | mantissa_nr = subc_32(mantissa_nr, mantissa_dr); |
1111 | 275M | bit = (mantissa_nr & 0x00000001); |
1112 | 275M | mantissa_nr = mantissa_nr & 0xfffffffe; |
1113 | 275M | quotient = (quotient << 1) + bit; |
1114 | 275M | } |
1115 | | |
1116 | 8.89M | if(sign < 0) |
1117 | 35.8k | { |
1118 | 35.8k | quotient = -quotient; |
1119 | 35.8k | } |
1120 | | |
1121 | 8.89M | return quotient; |
1122 | 8.89M | } Line | Count | Source | 1057 | 8.89M | { | 1058 | 8.89M | WORD32 quotient; | 1059 | 8.89M | UWORD32 mantissa_nr, mantissa_dr; | 1060 | 8.89M | WORD sign = 0; | 1061 | | | 1062 | 8.89M | LOOPINDEX i; | 1063 | 8.89M | WORD q_nr, q_dr; | 1064 | | | 1065 | 8.89M | mantissa_nr = a; | 1066 | 8.89M | mantissa_dr = b; | 1067 | 8.89M | quotient = 0; | 1068 | | | 1069 | 8.89M | if((a < 0) && (0 != b)) | 1070 | 39.2k | { | 1071 | 39.2k | a = -a; | 1072 | 39.2k | sign = (WORD)(sign ^ -1); | 1073 | 39.2k | } | 1074 | | | 1075 | 8.89M | if(b < 0) | 1076 | 48.1k | { | 1077 | 48.1k | b = -b; | 1078 | 48.1k | sign = (WORD)(sign ^ -1); | 1079 | 48.1k | } | 1080 | | | 1081 | 8.89M | if(0 == b) | 1082 | 0 | { | 1083 | 0 | *q_format = 0; | 1084 | 0 | return (a); | 1085 | 0 | } | 1086 | | | 1087 | 8.89M | quotient = 0; | 1088 | | | 1089 | 8.89M | q_nr = norm32(a); | 1090 | 8.89M | mantissa_nr = (UWORD32)a << (q_nr); | 1091 | 8.89M | q_dr = norm32(b); | 1092 | 8.89M | mantissa_dr = (UWORD32)b << (q_dr); | 1093 | 8.89M | *q_format = (WORD)(30 + q_nr - q_dr); | 1094 | | | 1095 | 284M | for(i = 0; i < 31; i++) | 1096 | 275M | { | 1097 | | /* quotient = quotient << 1; */ | 1098 | 275M | WORD32 bit; | 1099 | | | 1100 | | /*if(mantissa_nr >= mantissa_dr) | 1101 | | { | 1102 | | | 1103 | | mantissa_nr = (((mantissa_nr - mantissa_dr) << 1) + 1); | 1104 | | } | 1105 | | else | 1106 | | { | 1107 | | mantissa_nr = (UWORD32)mantissa_nr << 1; | 1108 | | } | 1109 | | */ | 1110 | 275M | mantissa_nr = subc_32(mantissa_nr, mantissa_dr); | 1111 | 275M | bit = (mantissa_nr & 0x00000001); | 1112 | 275M | mantissa_nr = mantissa_nr & 0xfffffffe; | 1113 | 275M | quotient = (quotient << 1) + bit; | 1114 | 275M | } | 1115 | | | 1116 | 8.89M | if(sign < 0) | 1117 | 35.8k | { | 1118 | 35.8k | quotient = -quotient; | 1119 | 35.8k | } | 1120 | | | 1121 | 8.89M | return quotient; | 1122 | 8.89M | } |
Unexecuted instantiation: sqrt_interp.c:div32 |
1123 | | |
1124 | | /*****************************************************************************/ |
1125 | | /* */ |
1126 | | /* Function name : mac16x16in32 */ |
1127 | | /* */ |
1128 | | /* Description : multiplies two 16 bit numbers and accumulates their */ |
1129 | | /* result in a 32 bit variable without sat */ |
1130 | | /* */ |
1131 | | /* Inputs : WORD32 a, WORD32 b, WORD16 c */ |
1132 | | /* */ |
1133 | | /* Globals : none */ |
1134 | | /* */ |
1135 | | /* Processing : multiply & add */ |
1136 | | /* */ |
1137 | | /* Outputs : none */ |
1138 | | /* */ |
1139 | | /* Returns : WORD32 acc - 32 bit signed value */ |
1140 | | /* */ |
1141 | | /* Issues : none */ |
1142 | | /* */ |
1143 | | /* Revision history : */ |
1144 | | /* */ |
1145 | | /* DD MM YYYY author changes */ |
1146 | | /* 20 11 2003 aadithya kamath created */ |
1147 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
1148 | | /* */ |
1149 | | /*****************************************************************************/ |
1150 | | |
1151 | | static PLATFORM_INLINE WORD32 mac16x16in32(WORD32 a, WORD16 b, WORD16 c) |
1152 | 0 | { |
1153 | 0 | WORD32 acc; |
1154 | 0 |
|
1155 | 0 | acc = mult16x16in32(b, c); |
1156 | 0 |
|
1157 | 0 | acc = add32(a, acc); |
1158 | 0 |
|
1159 | 0 | return acc; |
1160 | 0 | } Unexecuted instantiation: var_q_operator.c:mac16x16in32 Unexecuted instantiation: sqrt_interp.c:mac16x16in32 |
1161 | | |
1162 | | /*****************************************************************************/ |
1163 | | /* */ |
1164 | | /* Function name : mac16x16in32_shl */ |
1165 | | /* */ |
1166 | | /* Description : multiplies two 16 bit numbers and accumulates their */ |
1167 | | /* result in a 32 bit variable without sat */ |
1168 | | /* after removing a redundant sign bit in the product */ |
1169 | | /* */ |
1170 | | /* Inputs : WORD32 a, WORD16 b, WORD16 c */ |
1171 | | /* */ |
1172 | | /* Globals : none */ |
1173 | | /* */ |
1174 | | /* Processing : multiply, shift left by 1 & add */ |
1175 | | /* */ |
1176 | | /* Outputs : none */ |
1177 | | /* */ |
1178 | | /* Returns : WORD32 acc - 32 bit signed value */ |
1179 | | /* */ |
1180 | | /* Issues : none */ |
1181 | | /* */ |
1182 | | /* Revision history : */ |
1183 | | /* */ |
1184 | | /* DD MM YYYY author changes */ |
1185 | | /* 20 11 2003 aadithya kamath created */ |
1186 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
1187 | | /* */ |
1188 | | /*****************************************************************************/ |
1189 | | |
1190 | | static PLATFORM_INLINE WORD32 mac16x16in32_shl(WORD32 a, WORD16 b, WORD16 c) |
1191 | 0 | { |
1192 | 0 | WORD32 acc; |
1193 | 0 |
|
1194 | 0 | acc = mult16x16in32_shl(b, c); |
1195 | 0 |
|
1196 | 0 | acc = add32(a, acc); |
1197 | 0 |
|
1198 | 0 | return acc; |
1199 | 0 | } Unexecuted instantiation: var_q_operator.c:mac16x16in32_shl Unexecuted instantiation: sqrt_interp.c:mac16x16in32_shl |
1200 | | |
1201 | | /*****************************************************************************/ |
1202 | | /* */ |
1203 | | /* Function name : mac16x16in32_shlsat */ |
1204 | | /* */ |
1205 | | /* Description : multiplies two 16 bit numbers and accumulates their */ |
1206 | | /* result in a 32 bit variable with sat */ |
1207 | | /* after removing a redundant sign bit in the product */ |
1208 | | /* */ |
1209 | | /* Inputs : WORD32 a, WORD16 b, WORD16 c */ |
1210 | | /* */ |
1211 | | /* Globals : none */ |
1212 | | /* */ |
1213 | | /* Processing : multiply, shift left by 1 & add with sat */ |
1214 | | /* */ |
1215 | | /* Outputs : none */ |
1216 | | /* */ |
1217 | | /* Returns : WORD32 acc - 32 bit signed value */ |
1218 | | /* */ |
1219 | | /* Issues : none */ |
1220 | | /* */ |
1221 | | /* Revision history : */ |
1222 | | /* */ |
1223 | | /* DD MM YYYY author changes */ |
1224 | | /* 20 11 2003 aadithya kamath created */ |
1225 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
1226 | | /* */ |
1227 | | /*****************************************************************************/ |
1228 | | |
1229 | | static PLATFORM_INLINE WORD32 mac16x16in32_shl_sat(WORD32 a, WORD16 b, WORD16 c) |
1230 | 0 | { |
1231 | 0 | WORD32 acc; |
1232 | 0 |
|
1233 | 0 | acc = mult16x16in32_shl_sat(b, c); |
1234 | 0 |
|
1235 | 0 | acc = add32_sat(a, acc); |
1236 | 0 |
|
1237 | 0 | return acc; |
1238 | 0 | } Unexecuted instantiation: var_q_operator.c:mac16x16in32_shl_sat Unexecuted instantiation: sqrt_interp.c:mac16x16in32_shl_sat |
1239 | | |
1240 | | /*****************************************************************************/ |
1241 | | /* */ |
1242 | | /* Function name : msu16x16in32 */ |
1243 | | /* */ |
1244 | | /* Description : multiplies two 16 bit numbers and substracts their */ |
1245 | | /* result from a 32 bit variable without sat */ |
1246 | | /* */ |
1247 | | /* Inputs : WORD32 a, WORD32 b, WORD16 c */ |
1248 | | /* */ |
1249 | | /* Globals : none */ |
1250 | | /* */ |
1251 | | /* Processing : multiply & sub */ |
1252 | | /* */ |
1253 | | /* Outputs : none */ |
1254 | | /* */ |
1255 | | /* Returns : WORD32 acc - 32 bit signed value */ |
1256 | | /* */ |
1257 | | /* Issues : none */ |
1258 | | /* */ |
1259 | | /* Revision history : */ |
1260 | | /* */ |
1261 | | /* DD MM YYYY author changes */ |
1262 | | /* 20 11 2003 aadithya kamath created */ |
1263 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
1264 | | /* */ |
1265 | | /*****************************************************************************/ |
1266 | | |
1267 | | static PLATFORM_INLINE WORD32 msu16x16in32(WORD32 a, WORD16 b, WORD16 c) |
1268 | 0 | { |
1269 | 0 | WORD32 acc; |
1270 | 0 |
|
1271 | 0 | acc = mult16x16in32(b, c); |
1272 | 0 |
|
1273 | 0 | acc = sub32(a, acc); |
1274 | 0 |
|
1275 | 0 | return acc; |
1276 | 0 | } Unexecuted instantiation: var_q_operator.c:msu16x16in32 Unexecuted instantiation: sqrt_interp.c:msu16x16in32 |
1277 | | |
1278 | | /*****************************************************************************/ |
1279 | | /* */ |
1280 | | /* Function name : msu16x16in32_shl */ |
1281 | | /* */ |
1282 | | /* Description : multiplies two 16 bit numbers and substracts their */ |
1283 | | /* result from a 32 bit variable without sat */ |
1284 | | /* after removing a redundant sign bit in the product */ |
1285 | | /* */ |
1286 | | /* Inputs : WORD32 a, WORD16 b, WORD16 c */ |
1287 | | /* */ |
1288 | | /* Globals : none */ |
1289 | | /* */ |
1290 | | /* Processing : multiply, shift left by 1 & sub */ |
1291 | | /* */ |
1292 | | /* Outputs : none */ |
1293 | | /* */ |
1294 | | /* Returns : WORD32 acc - 32 bit signed value */ |
1295 | | /* */ |
1296 | | /* Issues : none */ |
1297 | | /* */ |
1298 | | /* Revision history : */ |
1299 | | /* */ |
1300 | | /* DD MM YYYY author changes */ |
1301 | | /* 20 11 2003 aadithya kamath created */ |
1302 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
1303 | | /* */ |
1304 | | /*****************************************************************************/ |
1305 | | |
1306 | | static PLATFORM_INLINE WORD32 msu16x16in32_shl(WORD32 a, WORD16 b, WORD16 c) |
1307 | 0 | { |
1308 | 0 | WORD32 acc; |
1309 | 0 |
|
1310 | 0 | acc = mult16x16in32_shl(b, c); |
1311 | 0 |
|
1312 | 0 | acc = sub32(a, acc); |
1313 | 0 |
|
1314 | 0 | return acc; |
1315 | 0 | } Unexecuted instantiation: var_q_operator.c:msu16x16in32_shl Unexecuted instantiation: sqrt_interp.c:msu16x16in32_shl |
1316 | | |
1317 | | /*****************************************************************************/ |
1318 | | /* */ |
1319 | | /* Function name : msu16x16in32_shlsat */ |
1320 | | /* */ |
1321 | | /* Description : multiplies two 16 bit numbers and substracts their */ |
1322 | | /* result from a 32 bit variable with sat */ |
1323 | | /* after removing a redundant sign bit in the product */ |
1324 | | /* */ |
1325 | | /* Inputs : WORD32 a, WORD16 b, WORD16 c */ |
1326 | | /* */ |
1327 | | /* Globals : none */ |
1328 | | /* */ |
1329 | | /* Processing : multiply, shift left by 1 & sub with sat */ |
1330 | | /* */ |
1331 | | /* Outputs : none */ |
1332 | | /* */ |
1333 | | /* Returns : WORD32 acc - 32 bit signed value */ |
1334 | | /* */ |
1335 | | /* Issues : none */ |
1336 | | /* */ |
1337 | | /* Revision history : */ |
1338 | | /* */ |
1339 | | /* DD MM YYYY author changes */ |
1340 | | /* 20 11 2003 aadithya kamath created */ |
1341 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
1342 | | /* */ |
1343 | | /*****************************************************************************/ |
1344 | | |
1345 | | static PLATFORM_INLINE WORD32 msu16x16in32_shl_sat(WORD32 a, WORD16 b, WORD16 c) |
1346 | 0 | { |
1347 | 0 | WORD32 acc; |
1348 | 0 |
|
1349 | 0 | acc = mult16x16in32_shl_sat(b, c); |
1350 | 0 |
|
1351 | 0 | acc = sub32_sat(a, acc); |
1352 | 0 |
|
1353 | 0 | return acc; |
1354 | 0 | } Unexecuted instantiation: var_q_operator.c:msu16x16in32_shl_sat Unexecuted instantiation: sqrt_interp.c:msu16x16in32_shl_sat |
1355 | | |
1356 | | /*****************************************************************************/ |
1357 | | /* */ |
1358 | | /* Function name : add32_shr */ |
1359 | | /* */ |
1360 | | /* Description : adding two 32 bit numbers and taking care of overflow */ |
1361 | | /* by downshifting both numbers before addition */ |
1362 | | /* */ |
1363 | | /* Inputs : WORD32 a, WORD16 b, WORD16 c */ |
1364 | | /* */ |
1365 | | /* Globals : none */ |
1366 | | /* */ |
1367 | | /* Processing : shift right inputs by 1 & add */ |
1368 | | /* */ |
1369 | | /* Outputs : none */ |
1370 | | /* */ |
1371 | | /* Returns : WORD32 sum 32 bit signed value */ |
1372 | | /* */ |
1373 | | /* Issues : none */ |
1374 | | /* */ |
1375 | | /* Revision history : */ |
1376 | | /* */ |
1377 | | /* DD MM YYYY author changes */ |
1378 | | /* 20 11 2003 aadithya kamath created */ |
1379 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
1380 | | /* */ |
1381 | | /*****************************************************************************/ |
1382 | | |
1383 | | static PLATFORM_INLINE WORD32 add32_shr(WORD32 a, WORD32 b) |
1384 | 0 | { |
1385 | 0 | WORD32 sum; |
1386 | 0 |
|
1387 | 0 | a = shr32(a, 1); |
1388 | 0 | b = shr32(b, 1); |
1389 | 0 |
|
1390 | 0 | sum = add32(a, b); |
1391 | 0 |
|
1392 | 0 | return sum; |
1393 | 0 | } Unexecuted instantiation: var_q_operator.c:add32_shr Unexecuted instantiation: sqrt_interp.c:add32_shr |
1394 | | |
1395 | | /*****************************************************************************/ |
1396 | | /* */ |
1397 | | /* Function name : sub32_shr */ |
1398 | | /* */ |
1399 | | /* Description : substracting two 32 bit numbers and taking care of */ |
1400 | | /* overflow by downshifting both numbers before addition */ |
1401 | | /* */ |
1402 | | /* Inputs : WORD32 a, WORD16 b, WORD16 c */ |
1403 | | /* */ |
1404 | | /* Globals : none */ |
1405 | | /* */ |
1406 | | /* Processing : shift right inputs by 1 & sub */ |
1407 | | /* */ |
1408 | | /* Outputs : none */ |
1409 | | /* */ |
1410 | | /* Returns : WORD32 diff - 32 bit signed value */ |
1411 | | /* */ |
1412 | | /* Issues : none */ |
1413 | | /* */ |
1414 | | /* Revision history : */ |
1415 | | /* */ |
1416 | | /* DD MM YYYY author changes */ |
1417 | | /* 20 11 2003 aadithya kamath created */ |
1418 | | /* 15 11 2004 tejaswi/vishal modified(bug fixes/cleanup) */ |
1419 | | /* */ |
1420 | | /*****************************************************************************/ |
1421 | | |
1422 | | static PLATFORM_INLINE WORD32 sub32_shr(WORD32 a, WORD32 b) |
1423 | 0 | { |
1424 | 0 | WORD32 diff; |
1425 | 0 |
|
1426 | 0 | a = shr32(a, 1); |
1427 | 0 | b = shr32(b, 1); |
1428 | 0 |
|
1429 | 0 | diff = sub32(a, b); |
1430 | 0 |
|
1431 | 0 | return diff; |
1432 | 0 | } Unexecuted instantiation: var_q_operator.c:sub32_shr Unexecuted instantiation: sqrt_interp.c:sub32_shr |
1433 | | #endif /* __IA_BASIC_OPS32_H__ */ |