1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13 * express or implied.
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
17 */
18 /*
19
20 Pathname: pv_normalize.h
21
22
23 ------------------------------------------------------------------------------
24 REVISION HISTORY
25
26 Who: Date:
27 Description:
28 ------------------------------------------------------------------------------
29 INCLUDE DESCRIPTION
30
31 ------------------------------------------------------------------------------
32 */
33
34 #ifndef PV_NORMALIZE_H
35 #define PV_NORMALIZE_H
36
37
38 /*----------------------------------------------------------------------------
39 ; INCLUDES
40 ----------------------------------------------------------------------------*/
41
42 #include "pv_audio_type_defs.h"
43
44 /*----------------------------------------------------------------------------
45 ; MACROS
46 ; Define module specific macros here
47 ----------------------------------------------------------------------------*/
48
49 /*----------------------------------------------------------------------------
50 ; EXTERNAL VARIABLES REFERENCES
51 ----------------------------------------------------------------------------*/
52
53 /*----------------------------------------------------------------------------
54 ; DEFINES AND SIMPLE TYPEDEF'S
55 ----------------------------------------------------------------------------*/
56
57 #if defined(_ARM)
58
pv_normalize(Int32 x)59 __inline Int pv_normalize(Int32 x)
60 {
61 Int32 y;
62 __asm
63 {
64 clz y, x;
65 sub y, y, #1
66 }
67 return (y);
68 }
69
70
71 #elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
72
pv_normalize(Int32 x)73 __inline Int pv_normalize(Int32 x)
74 {
75 register Int32 y;
76 register Int32 ra = x;
77
78
79 asm volatile(
80 "clz %0, %1\n\t"
81 "sub %0, %0, #1"
82 : "=&r*i"(y)
83 : "r"(ra));
84 return (y);
85
86 }
87
88 #else
89
90 #ifdef __cplusplus
91 extern "C"
92 {
93 #endif
94
95 Int pv_normalize(Int32 x);
96
97 #ifdef __cplusplus
98 }
99 #endif
100
101 #endif
102
103
104
105 #endif /* PV_NORMALIZE_H */
106