minor optimisation+tuning of vq search
This commit is contained in:
parent
636f5c86ab
commit
ac1e03d78e
2 changed files with 21 additions and 5 deletions
|
@ -237,7 +237,8 @@ void quant_bands(const CELTMode *m, float *X, float *P, float *W, struct alloc_d
|
|||
float norm[B*eBands[m->nbEBands+1]];
|
||||
int pulses[m->nbEBands];
|
||||
int offsets[m->nbEBands];
|
||||
|
||||
float alpha = .7;
|
||||
|
||||
for (i=0;i<m->nbEBands;i++)
|
||||
offsets[i] = 0;
|
||||
/* Use a single-bit margin to guard against overrunning (make sure it's enough) */
|
||||
|
@ -262,17 +263,20 @@ void quant_bands(const CELTMode *m, float *X, float *P, float *W, struct alloc_d
|
|||
if (eBands[i] >= m->pitchEnd || q<=0)
|
||||
{
|
||||
q -= 1;
|
||||
alpha = 0;
|
||||
if (q<0)
|
||||
intra_fold(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, norm, P+B*eBands[i], B, eBands[i]);
|
||||
else
|
||||
intra_prediction(X+B*eBands[i], W+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, norm, P+B*eBands[i], B, eBands[i], enc);
|
||||
} else {
|
||||
alpha = .7;
|
||||
}
|
||||
|
||||
if (q > 0)
|
||||
{
|
||||
exp_rotation(P+B*eBands[i], B*(eBands[i+1]-eBands[i]), theta, -1, B, 8);
|
||||
exp_rotation(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), theta, -1, B, 8);
|
||||
alg_quant(X+B*eBands[i], W+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, P+B*eBands[i], 0.7, enc);
|
||||
alg_quant(X+B*eBands[i], W+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, P+B*eBands[i], alpha, enc);
|
||||
exp_rotation(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), theta, 1, B, 8);
|
||||
}
|
||||
for (j=B*eBands[i];j<B*eBands[i+1];j++)
|
||||
|
@ -294,7 +298,8 @@ void unquant_bands(const CELTMode *m, float *X, float *P, struct alloc_data *all
|
|||
float norm[B*eBands[m->nbEBands+1]];
|
||||
int pulses[m->nbEBands];
|
||||
int offsets[m->nbEBands];
|
||||
|
||||
float alpha = .7;
|
||||
|
||||
for (i=0;i<m->nbEBands;i++)
|
||||
offsets[i] = 0;
|
||||
/* Use a single-bit margin to guard against overrunning (make sure it's enough) */
|
||||
|
@ -314,16 +319,19 @@ void unquant_bands(const CELTMode *m, float *X, float *P, struct alloc_data *all
|
|||
if (eBands[i] >= m->pitchEnd || q<=0)
|
||||
{
|
||||
q -= 1;
|
||||
alpha = 0;
|
||||
if (q<0)
|
||||
intra_fold(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, norm, P+B*eBands[i], B, eBands[i]);
|
||||
else
|
||||
intra_unquant(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, norm, P+B*eBands[i], B, eBands[i], dec);
|
||||
} else {
|
||||
alpha = .7;
|
||||
}
|
||||
|
||||
if (q > 0)
|
||||
{
|
||||
exp_rotation(P+B*eBands[i], B*(eBands[i+1]-eBands[i]), theta, -1, B, 8);
|
||||
alg_unquant(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, P+B*eBands[i], 0.7, dec);
|
||||
alg_unquant(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, P+B*eBands[i], alpha, dec);
|
||||
exp_rotation(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), theta, 1, B, 8);
|
||||
}
|
||||
for (j=B*eBands[i];j<B*eBands[i+1];j++)
|
||||
|
|
10
libcelt/vq.c
10
libcelt/vq.c
|
@ -115,10 +115,11 @@ void alg_quant(float *x, float *W, int N, int K, float *p, float alpha, ec_enc *
|
|||
for (j=0;j<N;j++)
|
||||
{
|
||||
int sign;
|
||||
//if (x[j]>0) sign=1; else sign=-1;
|
||||
for (sign=-1;sign<=1;sign+=2)
|
||||
{
|
||||
/* All pulses at one location must have the same size */
|
||||
if (iy[m][j]*sign < 0)
|
||||
if (iy[m][j]*sign < 0 || (x[j]*sign<0 && pulsesLeft>((K+1)>>1)))
|
||||
continue;
|
||||
//fprintf (stderr, "%d/%d %d/%d %d/%d\n", i, K, m, L2, j, N);
|
||||
float tmp_xy, tmp_yy, tmp_yp;
|
||||
|
@ -200,6 +201,13 @@ void alg_quant(float *x, float *W, int N, int K, float *p, float alpha, ec_enc *
|
|||
pulsesLeft -= pulsesAtOnce;
|
||||
}
|
||||
|
||||
if (0) {
|
||||
float err=0;
|
||||
for (i=0;i<N;i++)
|
||||
err += (x[i]-gain[0]*y[0][i])*(x[i]-gain[0]*y[0][i]);
|
||||
//if (N<=10)
|
||||
//printf ("%f %d %d\n", err, K, N);
|
||||
}
|
||||
for (i=0;i<N;i++)
|
||||
x[i] = p[i]+gain[0]*y[0][i];
|
||||
if (0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue