Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mark Harris
Opus
Commits
9cace64e
Commit
9cace64e
authored
Dec 06, 2007
by
Jean-Marc Valin
Browse files
Fixed codebook entirely quantised
parent
e8376605
Changes
3
Hide whitespace changes
Inline
Side-by-side
libcelt/bands.c
View file @
9cace64e
...
...
@@ -160,17 +160,16 @@ void quant_bands(const CELTMode *m, float *X, float *P, ec_enc *enc)
q
=
m
->
nbPulses
[
i
];
if
(
q
>
0
)
{
float
n
=
sqrt
(
B
*
(
eBands
[
i
+
1
]
-
eBands
[
i
]));
id
=
alg_quant2
(
X
+
B
*
eBands
[
i
],
B
*
(
eBands
[
i
+
1
]
-
eBands
[
i
]),
q
,
P
+
B
*
eBands
[
i
]);
ec_enc_uint
(
enc
,
id
,
ncwrs
(
B
*
(
eBands
[
i
+
1
]
-
eBands
[
i
]),
q
));
alg_quant2
(
X
+
B
*
eBands
[
i
],
B
*
(
eBands
[
i
+
1
]
-
eBands
[
i
]),
q
,
P
+
B
*
eBands
[
i
],
enc
);
for
(
j
=
B
*
eBands
[
i
];
j
<
B
*
eBands
[
i
+
1
];
j
++
)
norm
[
j
]
=
X
[
j
]
*
n
;
//bits += log2(ncwrs(B*(eBands[i+1]-eBands[i]), q));
}
else
{
float
n
=
sqrt
(
B
*
(
eBands
[
i
+
1
]
-
eBands
[
i
]));
copy_quant
(
X
+
B
*
eBands
[
i
],
B
*
(
eBands
[
i
+
1
]
-
eBands
[
i
]),
-
q
,
norm
,
B
,
eBands
[
i
]);
copy_quant
(
X
+
B
*
eBands
[
i
],
B
*
(
eBands
[
i
+
1
]
-
eBands
[
i
]),
-
q
,
norm
,
B
,
eBands
[
i
]
,
enc
);
for
(
j
=
B
*
eBands
[
i
];
j
<
B
*
eBands
[
i
+
1
];
j
++
)
norm
[
j
]
=
X
[
j
]
*
n
;
//bits += 1+log2(eBands[i])+log2(ncwrs(B*(eBands[i+1]-eBands[i]), -q));
//bits += 1+log2(eBands[i]
-(eBands[i+1]-eBands[i])
)+log2(ncwrs(B*(eBands[i+1]-eBands[i]), -q));
}
}
//printf ("%f\n", bits);
...
...
libcelt/vq.c
View file @
9cace64e
...
...
@@ -32,6 +32,7 @@
#include <math.h>
#include <stdlib.h>
#include "cwrs.h"
#include "vq.h"
/* Algebraic pulse-base quantiser. The signal x is replaced by the sum of the pitch
a combination of pulses such that its norm is still equal to 1 */
...
...
@@ -95,7 +96,7 @@ void alg_quant(float *x, int N, int K, float *p)
/* Improved algebraic pulse-base quantiser. The signal x is replaced by the sum of the pitch
a combination of pulses such that its norm is still equal to 1. The only difference with
the quantiser above is that the search is more complete. */
int
alg_quant2
(
float
*
x
,
int
N
,
int
K
,
float
*
p
)
void
alg_quant2
(
float
*
x
,
int
N
,
int
K
,
float
*
p
,
ec_enc
*
enc
)
{
int
L
=
5
;
//float tata[200];
...
...
@@ -240,7 +241,7 @@ int alg_quant2(float *x, int N, int K, float *p)
int
comb
[
K
];
int
signs
[
K
];
pulse2comb
(
N
,
K
,
comb
,
signs
,
iy
[
0
]);
return
icwrs
(
N
,
K
,
comb
,
signs
);
ec_enc_uint
(
enc
,
icwrs
(
N
,
K
,
comb
,
signs
)
,
ncwrs
(
N
,
K
))
;
}
/* Just replace the band with noise of unit energy */
...
...
@@ -263,7 +264,7 @@ void noise_quant(float *x, int N, int K, float *p)
static
const
float
pg
[
5
]
=
{
1
.
f
,
.
82
f
,
.
75
f
,
0
.
7
f
,
0
.
6
f
};
/* Finds the right offset into Y and copy it */
void
copy_quant
(
float
*
x
,
int
N
,
int
K
,
float
*
Y
,
int
B
,
int
N0
)
void
copy_quant
(
float
*
x
,
int
N
,
int
K
,
float
*
Y
,
int
B
,
int
N0
,
ec_enc
*
enc
)
{
int
i
,
j
;
int
best
=
0
;
...
...
@@ -291,6 +292,7 @@ void copy_quant(float *x, int N, int K, float *Y, int B, int N0)
s
=
-
1
;
}
}
ec_enc_uint
(
enc
,
best
/
B
,
N0
-
N
/
B
);
//printf ("%d %f\n", best, best_score);
if
(
K
==
0
)
{
...
...
@@ -319,6 +321,6 @@ void copy_quant(float *x, int N, int K, float *Y, int B, int N0)
E
=
.
8
/
sqrt
(
E
);
for
(
j
=
0
;
j
<
N
;
j
++
)
P
[
j
]
*=
E
;
alg_quant2
(
x
,
N
,
K
,
P
);
alg_quant2
(
x
,
N
,
K
,
P
,
enc
);
}
}
libcelt/vq.h
View file @
9cace64e
...
...
@@ -32,6 +32,8 @@
#ifndef VQ_H
#define VQ_H
#include "entenc.h"
/* Algebraic pulse-base quantiser. The signal x is replaced by the sum of the pitch
a combination of pulses such that its norm is still equal to 1 */
void
alg_quant
(
float
*
x
,
int
N
,
int
K
,
float
*
p
);
...
...
@@ -39,12 +41,12 @@ void alg_quant(float *x, int N, int K, float *p);
/* Improved algebraic pulse-base quantiser. The signal x is replaced by the sum of the pitch
a combination of pulses such that its norm is still equal to 1. The only difference with
the quantiser above is that the search is more complete. */
int
alg_quant2
(
float
*
x
,
int
N
,
int
K
,
float
*
p
);
void
alg_quant2
(
float
*
x
,
int
N
,
int
K
,
float
*
p
,
ec_enc
*
enc
);
/* Just replace the band with noise of unit energy */
void
noise_quant
(
float
*
x
,
int
N
,
int
K
,
float
*
p
);
/* Finds the right offset into Y and copy it */
void
copy_quant
(
float
*
x
,
int
N
,
int
K
,
float
*
Y
,
int
B
,
int
N0
);
void
copy_quant
(
float
*
x
,
int
N
,
int
K
,
float
*
Y
,
int
B
,
int
N0
,
ec_enc
*
enc
);
#endif
/* VQ_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment