This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
util.c
98 lines (79 loc) · 2.88 KB
/
util.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
ITU-T G.729A Speech Coder with Annex B ANSI-C Source Code
*/
/*
----------------------------------------------------------------------
COPYRIGHT NOTICE
----------------------------------------------------------------------
ITU-T G.729 Annex C ANSI C source code
Copyright (C) 1998, AT&T, France Telecom, NTT, University of
Sherbrooke. All rights reserved.
----------------------------------------------------------------------
*/
/*****************************************************************************/
/* auxiliary functions */
/*****************************************************************************/
#include "typedef.h"
#include "ld8a.h"
#if 0
/*-------------------------------------------------------------------*
* Function set zero() *
* ~~~~~~~~~~ *
* Set vector x[] to zero *
*-------------------------------------------------------------------*/
void set_zero(
FLOAT x[], /* (o) : vector to clear */
int L /* (i) : length of vector */
)
{
int i;
for (i = 0; i < L; i++)
x[i] = (F)0.0;
return;
}
/*-------------------------------------------------------------------*
* Function copy: *
* ~~~~~ *
* Copy vector x[] to y[] *
*-------------------------------------------------------------------*/
void copy(
FLOAT x[], /* (i) : input vector */
FLOAT y[], /* (o) : output vector */
int L /* (i) : vector length */
)
{
int i;
for (i = 0; i < L; i++)
y[i] = x[i];
return;
}
#endif
/* Random generator */
INT16 random_g729(INT16 *seed)
{
*seed = (INT16) (*seed * 31821L + 13849L);
return(*seed);
}
/*****************************************************************************/
/* Functions used by VAD.C */
/*****************************************************************************/
void dvsub(FLOAT *in1, FLOAT *in2, FLOAT *out, int npts)
{
while (npts--) *(out++) = *(in1++) - *(in2++);
}
FLOAT dvdot(FLOAT *in1, FLOAT *in2, int npts)
{
FLOAT accum;
accum = (F)0.0;
while (npts--) accum += *(in1++) * *(in2++);
return(accum);
}
void dvwadd(FLOAT *in1, FLOAT scalar1, FLOAT *in2, FLOAT scalar2,
FLOAT *out, int npts)
{
while (npts--) *(out++) = *(in1++) * scalar1 + *(in2++) * scalar2;
}
void dvsmul(FLOAT *in, FLOAT scalar, FLOAT *out, int npts)
{
while (npts--) *(out++) = *(in++) * scalar;
}