Asterisk - The Open Source Telephony Project
GIT-master-a63eec2
Toggle main menu visibility
Main Page
Related Pages
Topics
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
i
l
m
n
o
p
q
r
s
t
u
v
w
y
Functions
b
c
d
e
f
g
i
l
m
n
p
r
s
t
u
v
w
Variables
a
b
c
d
e
f
i
l
m
n
o
p
q
r
s
t
y
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
c
d
e
f
g
h
i
k
l
m
n
p
r
s
t
u
v
w
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerator
Properties
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
z
Enumerations
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Examples
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Macros
Modules
Pages
Loading...
Searching...
No Matches
codecs
ilbc
gainquant.c
Go to the documentation of this file.
1
2
/******************************************************************
3
4
iLBC Speech Coder ANSI-C Source Code
5
6
7
8
9
10
11
gainquant.c
12
13
Copyright (C) The Internet Society (2004).
14
All Rights Reserved.
15
16
******************************************************************/
17
18
#include <string.h>
19
#include <math.h>
20
#include "
constants.h
"
21
#include "
filter.h
"
22
23
/*----------------------------------------------------------------*
24
* quantizer for the gain in the gain-shape coding of residual
25
*---------------------------------------------------------------*/
26
27
float
gainquant
(
/* (o) quantized gain value */
28
float
in
,
/* (i) gain value */
29
float
maxIn,
/* (i) maximum of gain value */
30
int
cblen,
/* (i) number of quantization indices */
31
int
*index
/* (o) quantization index */
32
){
33
int
i, tindex;
34
float
minmeasure,measure, *cb, scale;
35
36
/* ensure a lower bound on the scaling factor */
37
38
scale=maxIn;
39
40
if
(scale<0.1) {
41
scale=(float)0.1;
42
}
43
44
/* select the quantization table */
45
46
if
(cblen == 8) {
47
cb =
gain_sq3Tbl
;
48
}
else
if
(cblen == 16) {
49
cb =
gain_sq4Tbl
;
50
}
else
{
51
cb =
gain_sq5Tbl
;
52
}
53
54
/* select the best index in the quantization table */
55
56
minmeasure=10000000.0;
57
tindex=0;
58
for
(i=0; i<cblen; i++) {
59
60
61
62
63
64
measure=(
in
-scale*cb[i])*(
in
-scale*cb[i]);
65
66
if
(measure<minmeasure) {
67
tindex=i;
68
minmeasure=measure;
69
}
70
}
71
*index=tindex;
72
73
/* return the quantized value */
74
75
return
scale*cb[tindex];
76
}
27
float
gainquant
(
/* (o) quantized gain value */
{
…
}
77
78
/*----------------------------------------------------------------*
79
* decoder for quantized gains in the gain-shape coding of
80
* residual
81
*---------------------------------------------------------------*/
82
83
float
gaindequant
(
/* (o) quantized gain value */
84
int
index,
/* (i) quantization index */
85
float
maxIn,
/* (i) maximum of unquantized gain */
86
int
cblen
/* (i) number of quantization indices */
87
){
88
float
scale;
89
90
/* obtain correct scale factor */
91
92
scale=(float)fabs(maxIn);
93
94
if
(scale<0.1) {
95
scale=(float)0.1;
96
}
97
98
/* select the quantization table and return the decoded value */
99
100
if
(cblen==8) {
101
return
scale*
gain_sq3Tbl
[index];
102
}
else
if
(cblen==16) {
103
return
scale*
gain_sq4Tbl
[index];
104
}
105
else
if
(cblen==32) {
106
return
scale*
gain_sq5Tbl
[index];
107
}
108
109
return
0.0;
110
}
83
float
gaindequant
(
/* (o) quantized gain value */
{
…
}
gain_sq4Tbl
float gain_sq4Tbl[16]
Definition
constants.c:160
gain_sq5Tbl
float gain_sq5Tbl[32]
Definition
constants.c:168
gain_sq3Tbl
float gain_sq3Tbl[8]
Definition
constants.c:150
constants.h
filter.h
gaindequant
float gaindequant(int index, float maxIn, int cblen)
Definition
gainquant.c:83
gainquant
float gainquant(float in, float maxIn, int cblen, int *index)
Definition
gainquant.c:27
in
FILE * in
Definition
utils/frame.c:33
Generated on Wed Oct 8 2025 20:04:16 for Asterisk - The Open Source Telephony Project by
1.9.8