Initialize Tizen 2.3
[external/opencore-amr.git] / opencore / codecs_v2 / audio / gsm_amr / amr_wb / dec / src / pvamrwb_math_op.h
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 Portions of this file are derived from the following 3GPP standard:
20
21     3GPP TS 26.173
22     ANSI-C code for the Adaptive Multi-Rate - Wideband (AMR-WB) speech codec
23     Available from http://www.3gpp.org
24
25 (C) 2007, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)
26 Permission to distribute, modify and use this file under the standard license
27 terms listed above has been obtained from the copyright holder.
28 ****************************************************************************************/
29 /*
30 ------------------------------------------------------------------------------
31
32
33
34  Pathname: ./src/pvamrwb_math_op.h
35
36 ------------------------------------------------------------------------------
37  INCLUDE DESCRIPTION
38
39 ------------------------------------------------------------------------------
40 */
41
42 #ifndef PVAMRWB_MATH_OP_H
43 #define PVAMRWB_MATH_OP_H
44
45
46 /*----------------------------------------------------------------------------
47 ; INCLUDES
48 ----------------------------------------------------------------------------*/
49
50 #include "pv_amr_wb_type_defs.h"
51
52 /*----------------------------------------------------------------------------
53 ; DEFINES
54 ----------------------------------------------------------------------------*/
55
56 /*----------------------------------------------------------------------------
57 ; MACROS
58 ; Define module specific macros here
59 ----------------------------------------------------------------------------*/
60
61 /*----------------------------------------------------------------------------
62 ; EXTERNAL VARIABLES REFERENCES
63 ----------------------------------------------------------------------------*/
64 #ifdef __cplusplus
65 extern "C"
66 {
67 #endif
68
69
70     int32 one_ov_sqrt(      /* (o) Q31 : output value (range: 0<=val<1)         */
71         int32 L_x          /* (i) Q0  : input value  (range: 0<=val<=7fffffff) */
72     );
73     void one_ov_sqrt_norm(
74         int32 * frac,      /* (i/o) Q31: normalized value (1.0 < frac <= 0.5) */
75         int16 * exp        /* (i/o)    : exponent (value = frac x 2^exponent) */
76     );
77     int32 power_of_2(       /* (o) Q0  : result       (range: 0<=val<=0x7fffffff) */
78         int16 exponant,    /* (i) Q0  : Integer part.      (range: 0<=val<=30)   */
79         int16 fraction     /* (i) Q15 : Fractionnal part.  (range: 0.0<=val<1.0) */
80     );
81     int32 Dot_product12(    /* (o) Q31: normalized result (1 < val <= -1) */
82         int16 x[],         /* (i) 12bits: x vector                       */
83         int16 y[],         /* (i) 12bits: y vector                       */
84         int16 lg,          /* (i)    : vector length                     */
85         int16 * exp        /* (o)    : exponent of result (0..+30)       */
86     );
87
88
89     void amrwb_log_2(
90         int32 L_x,        /* (i) : input value                                 */
91         int16 *exponent,  /* (o) : Integer part of Log2.   (range: 0<=val<=30) */
92         int16 *fraction   /* (o) : Fractional part of Log2. (range: 0<=val<1)*/
93     );
94
95     void Lg2_normalized(
96         int32 L_x,         /* (i) : input value (normalized)                    */
97         int16 exp,         /* (i) : norm_l (L_x)                                */
98         int16 *exponent,   /* (o) : Integer part of Log2.   (range: 0<=val<=30) */
99         int16 *fraction    /* (o) : Fractional part of Log2. (range: 0<=val<1)  */
100     );
101
102
103     int16 mult_int16_r(int16 var1, int16 var2);          /* Mult with round, 2 */
104     int16 shr_rnd(int16 var1, int16 var2);         /* Shift right with round, 2  */
105
106     int16 div_16by16(int16 var1, int16 var2);       /* Short division,       18  */
107
108
109     void int32_to_dpf(int32 L_32, int16 *hi, int16 *lo);
110     int32 mpy_dpf_32(int16 hi1, int16 lo1, int16 hi2, int16 lo2);
111
112
113 #define norm_s( x)    (normalize_amr_wb(  x) - 16)
114
115
116 #define extract_h( x)    (int16)(x>>16)
117 #define L_deposit_h( x)    (int32)(x<<16)
118
119
120 #ifdef __cplusplus
121 }
122 #endif
123
124
125 #endif /*  PVAMRWB_MATH_OP_H */
126