1250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber/* ------------------------------------------------------------------
2250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber * Copyright (C) 1998-2009 PacketVideo
3250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber *
4250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber * Licensed under the Apache License, Version 2.0 (the "License");
5250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber * you may not use this file except in compliance with the License.
6250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber * You may obtain a copy of the License at
7250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber *
8250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber *      http://www.apache.org/licenses/LICENSE-2.0
9250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber *
10250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber * Unless required by applicable law or agreed to in writing, software
11250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber * distributed under the License is distributed on an "AS IS" BASIS,
12250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber * express or implied.
14250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber * See the License for the specific language governing permissions
15250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber * and limitations under the License.
16250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber * -------------------------------------------------------------------
17250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber */
18250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber/*
19250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber------------------------------------------------------------------------------
20250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber   PacketVideo Corp.
21250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber   MP3 Decoder Library
22250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
23250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber   Pathname: ./cpp/include/pv_mp3dec_fxd_op_c_equivalent.h
24250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
25250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber     Date: 12/06/2005
26250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
27250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber------------------------------------------------------------------------------
28250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber REVISION HISTORY
29250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
30250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber Description:
31250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber------------------------------------------------------------------------------
32250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber INCLUDE DESCRIPTION
33250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
34250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber------------------------------------------------------------------------------
35250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber*/
36250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
37250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber#ifndef PV_MP3DEC_FXD_OP_C_EQUIVALENT
38250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber#define PV_MP3DEC_FXD_OP_C_EQUIVALENT
39250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
40250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
41250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber#ifdef __cplusplus
42250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huberextern "C"
43250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber{
44250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber#endif
45250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
46250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber#include "pvmp3_audio_type_defs.h"
47250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber#define Qfmt_31(a)   (Int32)((float)a*0x7FFFFFFF)
48250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
49250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber#define Qfmt15(x)   (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))
50250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
51250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
52250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
53250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    __inline int32 pv_abs(int32 a)
54250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    {
55250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber        int32 b = (a < 0) ? -a : a;
56250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber        return b;
57250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    }
58250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
59250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
60250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
61250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
62250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
63250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    {
64250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber        return (Int32)(((int64)(a) * b) >> 30);
65250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    }
66250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
67250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
68250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    {
69250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber        return (L_add + (Int32)(((int64)(a) * b) >> 30));
70250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    }
71250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
72250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    __inline Int32 fxp_mul32_Q32(const Int32 a, const Int32 b)
73250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    {
74250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber        return (Int32)(((int64)(a) * b) >> 32);
75250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    }
76250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
77250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
78250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
79250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    {
80250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber        return (Int32)(((int64)(a) * b) >> 28);
81250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    }
82250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
83250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
84250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    {
85250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber        return (Int32)(((int64)(a) * b) >> 27);
86250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    }
87250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
88250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
89250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    {
90250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber        return (Int32)(((int64)(a) * b) >> 26);
91250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    }
92250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
93250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
94250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    __inline Int32 fxp_mac32_Q32(Int32 L_add, const Int32 a, const Int32 b)
95250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    {
96250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber        return (L_add + (Int32)(((int64)(a) * b) >> 32));
97250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    }
98250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
99250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    __inline Int32 fxp_msb32_Q32(Int32 L_sub, const Int32 a, const Int32 b)
100250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    {
101250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber        return (L_sub - ((Int32)(((int64)(a) * b) >> 32)));
102250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    }
103250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
104250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
105250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
106250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    {
107250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber        return (Int32)(((int64)(a) * b) >> 29);
108250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber    }
109250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
110250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
111250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
112250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
113250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
114250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
115250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber#ifdef __cplusplus
116250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber}
117250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber#endif
118250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
119250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
120250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber#endif   /*  PV_MP3DEC_FXD_OP_C_EQUIVALENT  */
121250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
122250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
123250f2433c6e1cf2727a79971fdc6ce0f8677037aAndreas Huber
124