Asterisk - The Open Source Telephony Project GIT-master-f36a736
Functions
preprocess.c File Reference
#include <stdio.h>
#include <assert.h>
#include "private.h"
#include "gsm.h"
#include "proto.h"
Include dependency graph for preprocess.c:

Go to the source code of this file.

Functions

void Gsm_Preprocess P3 ((S, s, so), struct gsm_state *S, word *s, word *so)
 

Function Documentation

◆ P3()

void Gsm_Preprocess P3 ( (S, s, so)  ,
struct gsm_state S,
word s,
word so 
)

Definition at line 34 of file preprocess.c.

38{
39 word z1 = S->z1;
40 longword L_z2 = S->L_z2;
41 word mp = S->mp;
42 word s1;
43 word SO;
44 ulongword utmp; /* for L_ADD */
45 register int k = 160;
46
47 (void) utmp;
48
49 while (k--) {
50
51 /* 4.2.1 Downscaling of the input signal
52 */
53 /* SO = SASR( *s, 3 ) << 2;*/
54 SO = SASR( *s, 1 ) & ~3;
55 s++;
56
57 assert (SO >= -0x4000); /* downscaled by */
58 assert (SO <= 0x3FFC); /* previous routine. */
59
60
61 /* 4.2.2 Offset compensation
62 *
63 * This part implements a high-pass filter and requires extended
64 * arithmetic precision for the recursive part of this filter.
65 * The input of this procedure is the array so[0...159] and the
66 * output the array sof[ 0...159 ].
67 */
68 /* Compute the non-recursive part
69 */
70
71 s1 = SO - z1; /* s1 = gsm_sub( *so, z1 ); */
72 z1 = SO;
73
74 assert(s1 != MIN_WORD);
75
76 /* SJB Remark: float might be faster than the mess that follows */
77
78 /* Compute the recursive part
79 */
80
81 /* Execution of a 31 bv 16 bits multiplication
82 */
83 {
84 word msp;
85#ifndef __GNUC__
86 word lsp;
87#endif
88 longword L_s2;
89 longword L_temp;
90
91 L_s2 = s1;
92 L_s2 <<= 15;
93#ifndef __GNUC__
94 msp = (word)SASR( L_z2, 15 );
95 lsp = (word)(L_z2 & 0x7fff); /* gsm_L_sub(L_z2,(msp<<15)); */
96
97 L_s2 += GSM_MULT_R( lsp, 32735 );
98 L_temp = (longword)msp * 32735; /* GSM_L_MULT(msp,32735) >> 1;*/
99 L_z2 = GSM_L_ADD( L_temp, L_s2 );
100 /* above does L_z2 = L_z2 * 0x7fd5/0x8000 + L_s2 */
101#else
102 L_z2 = ((long long)L_z2*32735 + 0x4000)>>15;
103 /* alternate (ansi) version of above line does slightly different rounding:
104 * L_temp = L_z2 >> 9;
105 * L_temp += L_temp >> 5;
106 * L_temp = (++L_temp) >> 1;
107 * L_z2 = L_z2 - L_temp;
108 */
109 L_z2 = GSM_L_ADD(L_z2,L_s2);
110#endif
111 /* Compute sof[k] with rounding
112 */
113 L_temp = GSM_L_ADD( L_z2, 16384 );
114
115 /* 4.2.3 Preemphasis
116 */
117
118 msp = (word)GSM_MULT_R( mp, -28180 );
119 mp = (word)SASR( L_temp, 15 );
120 *so++ = GSM_ADD( mp, msp );
121 }
122 }
123
124 S->z1 = z1;
125 S->L_z2 = L_z2;
126 S->mp = mp;
127}
#define S(e)
short word
#define MIN_WORD
#define SASR(x, by)
unsigned long ulongword
#define GSM_MULT_R(a, b)
#define GSM_L_ADD(a, b)
static word GSM_ADD(longword a, longword b)
long longword

References GSM_ADD(), GSM_L_ADD, GSM_MULT_R, MIN_WORD, S, and SASR.