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)*(float)0x7FFFFFFF) 48 49 #define Qfmt15(x) (Int16)((x)*((Int32)1<<15) + ((x)>=0?0.5F:-0.5F)) 50 51 52 53 __attribute__((no_sanitize("integer"))) pv_abs(int32 a)54 __inline int32 pv_abs(int32 a) 55 { 56 int32 b = (a < 0) ? -a : a; 57 return b; 58 } 59 60 61 62 63 __attribute__((no_sanitize("integer"))) fxp_mul32_Q30(const Int32 a,const Int32 b)64 __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b) 65 { 66 return (Int32)(((int64)(a) * b) >> 30); 67 } 68 69 __attribute__((no_sanitize("integer"))) fxp_mac32_Q30(const Int32 a,const Int32 b,Int32 L_add)70 __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add) 71 { 72 return (L_add + (Int32)(((int64)(a) * b) >> 30)); 73 } 74 75 __attribute__((no_sanitize("integer"))) fxp_mul32_Q32(const Int32 a,const Int32 b)76 __inline Int32 fxp_mul32_Q32(const Int32 a, const Int32 b) 77 { 78 return (Int32)(((int64)(a) * b) >> 32); 79 } 80 81 82 __attribute__((no_sanitize("integer"))) fxp_mul32_Q28(const Int32 a,const Int32 b)83 __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b) 84 { 85 return (Int32)(((int64)(a) * b) >> 28); 86 } 87 88 __attribute__((no_sanitize("integer"))) fxp_mul32_Q27(const Int32 a,const Int32 b)89 __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b) 90 { 91 return (Int32)(((int64)(a) * b) >> 27); 92 } 93 94 __attribute__((no_sanitize("integer"))) fxp_mul32_Q26(const Int32 a,const Int32 b)95 __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b) 96 { 97 return (Int32)(((int64)(a) * b) >> 26); 98 } 99 100 101 __attribute__((no_sanitize("integer"))) fxp_mac32_Q32(Int32 L_add,const Int32 a,const Int32 b)102 __inline Int32 fxp_mac32_Q32(Int32 L_add, const Int32 a, const Int32 b) 103 { 104 return (L_add + (Int32)(((int64)(a) * b) >> 32)); 105 } 106 107 __attribute__((no_sanitize("integer"))) fxp_msb32_Q32(Int32 L_sub,const Int32 a,const Int32 b)108 __inline Int32 fxp_msb32_Q32(Int32 L_sub, const Int32 a, const Int32 b) 109 { 110 return (L_sub - ((Int32)(((int64)(a) * b) >> 32))); 111 } 112 113 114 __attribute__((no_sanitize("integer"))) fxp_mul32_Q29(const Int32 a,const Int32 b)115 __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b) 116 { 117 return (Int32)(((int64)(a) * b) >> 29); 118 } 119 120 121 122 123 124 125 #ifdef __cplusplus 126 } 127 #endif 128 129 130 #endif /* PV_MP3DEC_FXD_OP_C_EQUIVALENT */ 131 132 133 134