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   PacketVideo Corp.
21   MP3 Decoder Library
22
23   Filename: pvmp3_normalize.h
24
25   Date: 10/02/2007
26
27------------------------------------------------------------------------------
28 REVISION HISTORY
29
30 Description:
31------------------------------------------------------------------------------
32 INCLUDE DESCRIPTION
33
34------------------------------------------------------------------------------
35*/
36
37#ifndef PVMP3_NORMALIZE_H
38#define PVMP3_NORMALIZE_H
39
40
41/*----------------------------------------------------------------------------
42; INCLUDES
43----------------------------------------------------------------------------*/
44
45#include "pvmp3_audio_type_defs.h"
46
47/*----------------------------------------------------------------------------
48; MACROS
49; Define module specific macros here
50----------------------------------------------------------------------------*/
51
52/*----------------------------------------------------------------------------
53; EXTERNAL VARIABLES REFERENCES
54----------------------------------------------------------------------------*/
55
56/*----------------------------------------------------------------------------
57; DEFINES AND SIMPLE TYPEDEF'S
58----------------------------------------------------------------------------*/
59
60#if (defined(PV_ARM_V5)||defined(PV_ARM_V4))
61
62__inline int32 pvmp3_normalize(int32 x)
63{
64    int32 y;
65    __asm
66    {
67        clz y, x;
68        sub y, y, #1
69    }
70    return (y);
71}
72
73
74#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
75
76__inline int32 pvmp3_normalize(int32 x)
77{
78    register int32 y;
79    register int32 ra = x;
80
81
82    asm volatile(
83        "clz %0, %1\n\t"
84        "sub %0, %0, #1"
85    : "=&r*i"(y)
86                : "r"(ra));
87    return (y);
88
89}
90
91#else
92
93#ifdef __cplusplus
94extern "C"
95{
96#endif
97
98    int32 pvmp3_normalize(int32 x);
99
100#ifdef __cplusplus
101}
102#endif
103
104#endif
105
106
107
108#endif  /* PV_NORMALIZE_H */
109