comparison chipsetsw/layer1/cfile/l1_ctl.c @ 83:43dd68d8d891

l1_ctl.c: new functions moved and made static to facilitate diffing
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Wed, 30 Mar 2016 06:28:32 +0000
parents ef6cf21cf9d6
children 1cda9bc89011
comparison
equal deleted inserted replaced
82:ef6cf21cf9d6 83:43dd68d8d891
150 #define L1_WORD16_POS_MAX (32767) 150 #define L1_WORD16_POS_MAX (32767)
151 #define L1_WORD16_NEG_MAX (-32768) 151 #define L1_WORD16_NEG_MAX (-32768)
152 #define L1_WORD32_POS_MAX ((unsigned long)(1<<31)-1) 152 #define L1_WORD32_POS_MAX ((unsigned long)(1<<31)-1)
153 #define L1_WORD32_NEG_MAX (-(unsigned long)(1<<31)) 153 #define L1_WORD32_NEG_MAX (-(unsigned long)(1<<31))
154 154
155 INLINE WORD16 Add_Sat_sign_16b(WORD16 val1, WORD16 val2) 155 /*
156 { 156 * FreeCalypso TCS211 reconstruction: the following 3 functions
157 WORD32 temp; 157 * are new with the LoCosto version of this module. Their bodies
158 WORD16 result; 158 * used to be here (prefixed with INLINE for conditional inlining
159 159 * like Add_40b() and friends), but we have made the following
160 temp = (WORD32)((WORD32)val1 + (WORD32)val2); 160 * changes:
161 if(temp > L1_WORD16_POS_MAX) 161 *
162 { 162 * moved the function bodies to the end
163 temp = L1_WORD16_POS_MAX; 163 * made the functions static
164 } 164 * added forward declarations below
165 if(temp < L1_WORD16_NEG_MAX) 165 *
166 { 166 * These changes have been made in order to aid the diffing
167 temp = L1_WORD16_NEG_MAX; 167 * of compiled objects.
168 } 168 */
169 result = (WORD16)((temp)&(0x0000FFFF)); 169
170 return(result); 170 static WORD16 Add_Sat_sign_16b(WORD16 val1, WORD16 val2);
171 } 171 static WORD32 Add_Sat_sign_32b(WORD32 val1, WORD32 val2);
172 172 static WORD32 Sat_Mult_20sign_16unsign(WORD32 val1, UWORD32 val2);
173 INLINE WORD32 Add_Sat_sign_32b(WORD32 val1, WORD32 val2)
174 {
175 WORD32 temp_high_high;
176 UWORD32 temp_low_low;
177 UWORD16 carry;
178 WORD32 result;
179 WORD16 high_val1, high_val2;
180 UWORD16 low_val1, low_val2;
181
182 high_val1 = (WORD16)(val1>>16);
183 high_val2 = (WORD16)(val2>>16);
184 low_val1 = (UWORD16)(val1&0x0000FFFF);
185 low_val2 = (UWORD16)(val2&0x0000FFFF);
186
187 temp_high_high = (WORD32)high_val1 + (WORD32)high_val2;
188 temp_low_low = (UWORD32)low_val1 + (UWORD32)low_val2;
189 carry = (UWORD16)(temp_low_low >> 16);
190 temp_high_high = temp_high_high + (UWORD32)(carry);
191
192
193 result = val1 + val2;
194 if(temp_high_high > L1_WORD16_POS_MAX)
195 {
196 result = L1_WORD32_POS_MAX;
197 }
198 if(temp_high_high < L1_WORD16_NEG_MAX)
199 {
200 result = L1_WORD32_NEG_MAX;
201 }
202
203 return(result);
204 }
205
206 INLINE WORD32 Sat_Mult_20sign_16unsign(WORD32 val1, UWORD32 val2)
207 {
208 WORD32 result;
209
210 result = val1 * val2;
211 if(val1>0) /* val2 is > 0*/
212 {
213 if(result < 0) /* overflow */
214 {
215 result = L1_WORD32_POS_MAX;
216 }
217 }
218 if(val1<0) /* val2 is > 0*/
219 {
220 if(result > 0) /* overflow */
221 {
222 result = L1_WORD32_NEG_MAX;
223 }
224 }
225 return(result);
226 }
227
228 173
229 INLINE WORD32 Add_40b( WORD32 guard1guard2, WORD32 lvar1, WORD32 lvar2, WORD16 *guardout ) 174 INLINE WORD32 Add_40b( WORD32 guard1guard2, WORD32 lvar1, WORD32 lvar2, WORD16 *guardout )
230 { 175 {
231 WORD32 result, temp, carry, Lvar1, Lvar2; 176 WORD32 result, temp, carry, Lvar1, Lvar2;
232 WORD16 guard1,guard2; 177 WORD16 guard1,guard2;
3163 { 3108 {
3164 l1a_l1s_com.Scell_info.buff_beacon[i] = l1_config.params.il_min; 3109 l1a_l1s_com.Scell_info.buff_beacon[i] = l1_config.params.il_min;
3165 } 3110 }
3166 } 3111 }
3167 #endif /* #if (FF_L1_FAST_DECODING == 1) */ 3112 #endif /* #if (FF_L1_FAST_DECODING == 1) */
3113
3114 /*
3115 * FreeCalypso TCS211 reconstruction: these functions used to be
3116 * at the beginning of the module; we have moved them here in order
3117 * to aid the diffing of compiled objects.
3118 */
3119
3120 static WORD16 Add_Sat_sign_16b(WORD16 val1, WORD16 val2)
3121 {
3122 WORD32 temp;
3123 WORD16 result;
3124
3125 temp = (WORD32)((WORD32)val1 + (WORD32)val2);
3126 if(temp > L1_WORD16_POS_MAX)
3127 {
3128 temp = L1_WORD16_POS_MAX;
3129 }
3130 if(temp < L1_WORD16_NEG_MAX)
3131 {
3132 temp = L1_WORD16_NEG_MAX;
3133 }
3134 result = (WORD16)((temp)&(0x0000FFFF));
3135 return(result);
3136 }
3137
3138 static WORD32 Add_Sat_sign_32b(WORD32 val1, WORD32 val2)
3139 {
3140 WORD32 temp_high_high;
3141 UWORD32 temp_low_low;
3142 UWORD16 carry;
3143 WORD32 result;
3144 WORD16 high_val1, high_val2;
3145 UWORD16 low_val1, low_val2;
3146
3147 high_val1 = (WORD16)(val1>>16);
3148 high_val2 = (WORD16)(val2>>16);
3149 low_val1 = (UWORD16)(val1&0x0000FFFF);
3150 low_val2 = (UWORD16)(val2&0x0000FFFF);
3151
3152 temp_high_high = (WORD32)high_val1 + (WORD32)high_val2;
3153 temp_low_low = (UWORD32)low_val1 + (UWORD32)low_val2;
3154 carry = (UWORD16)(temp_low_low >> 16);
3155 temp_high_high = temp_high_high + (UWORD32)(carry);
3156
3157
3158 result = val1 + val2;
3159 if(temp_high_high > L1_WORD16_POS_MAX)
3160 {
3161 result = L1_WORD32_POS_MAX;
3162 }
3163 if(temp_high_high < L1_WORD16_NEG_MAX)
3164 {
3165 result = L1_WORD32_NEG_MAX;
3166 }
3167
3168 return(result);
3169 }
3170
3171 static WORD32 Sat_Mult_20sign_16unsign(WORD32 val1, UWORD32 val2)
3172 {
3173 WORD32 result;
3174
3175 result = val1 * val2;
3176 if(val1>0) /* val2 is > 0*/
3177 {
3178 if(result < 0) /* overflow */
3179 {
3180 result = L1_WORD32_POS_MAX;
3181 }
3182 }
3183 if(val1<0) /* val2 is > 0*/
3184 {
3185 if(result > 0) /* overflow */
3186 {
3187 result = L1_WORD32_NEG_MAX;
3188 }
3189 }
3190 return(result);
3191 }