24 static void Weighting_filter P2((e, x),
37 register longword L_result;
54 for (k = 0; k <= 39; k++) {
65 #define STEP( i, H ) (e[ k + i ] * (longword)H)
72 #ifdef STUPID_COMPILER
73 L_result += STEP( 0, -134 ) ;
74 L_result += STEP( 1, -374 ) ;
76 L_result += STEP( 3, 2054 ) ;
77 L_result += STEP( 4, 5741 ) ;
78 L_result += STEP( 5, 8192 ) ;
79 L_result += STEP( 6, 5741 ) ;
80 L_result += STEP( 7, 2054 ) ;
82 L_result += STEP( 9, -374 ) ;
83 L_result += STEP( 10, -134 ) ;
110 L_result = SASR( L_result, 13 );
111 x[k] = (word)( L_result < MIN_WORD ? MIN_WORD
112 : (L_result > MAX_WORD ? MAX_WORD : L_result ));
119 static void RPE_grid_selection P3((x,xM,Mc_out),
131 register longword L_result, L_temp;
135 longword L_common_0_3;
162 #define STEP( m, i ) L_temp = SASR( x[m + 3 * i], 2 ); \
163 L_result += L_temp * L_temp;
168 STEP( 0, 1 ); STEP( 0, 2 ); STEP( 0, 3 ); STEP( 0, 4 );
169 STEP( 0, 5 ); STEP( 0, 6 ); STEP( 0, 7 ); STEP( 0, 8 );
170 STEP( 0, 9 ); STEP( 0, 10); STEP( 0, 11); STEP( 0, 12);
171 L_common_0_3 = L_result;
183 STEP( 1, 1 ); STEP( 1, 2 ); STEP( 1, 3 ); STEP( 1, 4 );
184 STEP( 1, 5 ); STEP( 1, 6 ); STEP( 1, 7 ); STEP( 1, 8 );
185 STEP( 1, 9 ); STEP( 1, 10); STEP( 1, 11); STEP( 1, 12);
196 STEP( 2, 1 ); STEP( 2, 2 ); STEP( 2, 3 ); STEP( 2, 4 );
197 STEP( 2, 5 ); STEP( 2, 6 ); STEP( 2, 7 ); STEP( 2, 8 );
198 STEP( 2, 9 ); STEP( 2, 10); STEP( 2, 11); STEP( 2, 12);
207 L_result = L_common_0_3;
220 for (i = 0; i <= 12; i ++) xM[i] = x[Mc + 3*i];
226 static void APCM_quantization_xmaxc_to_exp_mant P3((xmaxc,exp_out,mant_out),
237 if (xmaxc > 15) exp = SASR(xmaxc, 3) - 1;
238 mant = xmaxc - (exp << 3);
246 mant = mant << 1 | 1;
252 assert( exp >= -4 && exp <= 6 );
253 assert( mant >= 0 && mant <= 7 );
259 static void APCM_quantization P5((xM,xMc,mant_out,exp_out,xmaxc_out),
270 word xmax, xmaxc, temp, temp1, temp2;
278 for (i = 0; i <= 12; i++) {
280 temp = GSM_ABS(temp);
281 if (temp > xmax) xmax = temp;
288 temp = SASR( xmax, 9 );
291 for (i = 0; i <= 5; i++) {
293 itest |= (temp <= 0);
294 temp = SASR( temp, 1 );
297 if (itest == 0) exp++;
300 assert(exp <= 6 && exp >= 0);
303 assert(temp <= 11 && temp >= 0);
304 xmaxc = gsm_add( SASR(xmax, temp), exp << 3 );
310 APCM_quantization_xmaxc_to_exp_mant( xmaxc, &exp, &mant );
326 assert( exp <= 4096 && exp >= -4096);
327 assert( mant >= 0 && mant <= 7 );
330 temp2 = gsm_NRFAC[ mant ];
332 for (i = 0; i <= 12; i++) {
334 assert(temp1 >= 0 && temp1 < 16);
336 temp = xM[i] << temp1;
337 temp = (word)GSM_MULT( temp, temp2 );
338 temp = SASR(temp, 12);
352 static void APCM_inverse_quantization P4((xMc,mant,exp,xMp),
364 word temp, temp1, temp2, temp3;
366 assert( mant >= 0 && mant <= 7 );
368 temp1 = gsm_FAC[ mant ];
369 temp2 = gsm_sub( 6, exp );
370 temp3 = gsm_asl( 1, gsm_sub( temp2, 1 ));
374 assert( *xMc <= 7 && *xMc >= 0 );
377 temp = (*xMc++ << 1) - 7;
378 assert( temp <= 7 && temp >= -7 );
381 temp = (word)GSM_MULT_R( temp1, temp );
382 temp = GSM_ADD( temp, temp3 );
383 *xMp++ = gsm_asr( temp, temp2 );
389 static void RPE_grid_positioning P3((Mc,xMp,ep),
404 assert(0 <= Mc && Mc <= 3);
411 case 0: *ep++ = *xMp++;
414 while (++Mc < 4) *ep++ = 0;
436 void Gsm_Update_of_reconstructed_short_time_residual_signal P3((dpp, ep, dp),
443 for (k = 0; k <= 79; k++)
444 dp[ -120 + k ] = dp[ -80 + k ];
446 for (k = 0; k <= 39; k++)
447 dp[ -40 + k ] = gsm_add( ep[k], dpp[k] );
451 void Gsm_RPE_Encoding P5((S,e,xmaxc,Mc,xMc),
461 word xM[13], xMp[13];
464 Weighting_filter(e, x);
465 RPE_grid_selection(x, xM, Mc);
467 APCM_quantization( xM, xMc, &mant, &exp, xmaxc);
468 APCM_inverse_quantization( xMc, mant, exp, xMp);
470 RPE_grid_positioning( *Mc, xMp, e );
474 void Gsm_RPE_Decoding P5((S, xmaxcr, Mcr, xMcr, erp),
486 APCM_quantization_xmaxc_to_exp_mant( xmaxcr, &exp, &mant );
487 APCM_inverse_quantization( xMcr, mant, exp, xMp );
488 RPE_grid_positioning( Mcr, xMp, erp );