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 Pathname: ./cpp/include/pv_mp3dec_fxd_op_c_equivalent.h 24 25 Date: 12/06/2005 26 27 ------------------------------------------------------------------------------ 28 REVISION HISTORY 29 30 Description: 31 ------------------------------------------------------------------------------ 32 INCLUDE DESCRIPTION 33 34 ------------------------------------------------------------------------------ 35 */ 36 37 #ifndef PV_MP3DEC_FXD_OP_C_EQUIVALENT 38 #define PV_MP3DEC_FXD_OP_C_EQUIVALENT 39 40 41 #ifdef __cplusplus 42 extern "C" 43 { 44 #endif 45 46 #include "pvmp3_audio_type_defs.h" 47 #define Qfmt_31(a) (Int32)((float)a*0x7FFFFFFF) 48 49 #define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) 50 51 52 53 __inline int32 pv_abs(int32 a) 54 { 55 int32 b = (a < 0) ? -a : a; 56 return b; 57 } 58 59 60 61 62 __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b) 63 { 64 return (Int32)(((int64)(a) * b) >> 30); 65 } 66 67 __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add) 68 { 69 return (L_add + (Int32)(((int64)(a) * b) >> 30)); 70 } 71 72 __inline Int32 fxp_mul32_Q32(const Int32 a, const Int32 b) 73 { 74 return (Int32)(((int64)(a) * b) >> 32); 75 } 76 77 78 __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b) 79 { 80 return (Int32)(((int64)(a) * b) >> 28); 81 } 82 83 __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b) 84 { 85 return (Int32)(((int64)(a) * b) >> 27); 86 } 87 88 __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b) 89 { 90 return (Int32)(((int64)(a) * b) >> 26); 91 } 92 93 94 __inline Int32 fxp_mac32_Q32(Int32 L_add, const Int32 a, const Int32 b) 95 { 96 return (L_add + (Int32)(((int64)(a) * b) >> 32)); 97 } 98 99 __inline Int32 fxp_msb32_Q32(Int32 L_sub, const Int32 a, const Int32 b) 100 { 101 return (L_sub - ((Int32)(((int64)(a) * b) >> 32))); 102 } 103 104 105 __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b) 106 { 107 return (Int32)(((int64)(a) * b) >> 29); 108 } 109 110 111 112 113 114 115 #ifdef __cplusplus 116 } 117 #endif 118 119 120 #endif /* PV_MP3DEC_FXD_OP_C_EQUIVALENT */ 121 122 123 124