improved energy quantisation/prediction
This commit is contained in:
parent
06311335b5
commit
aeb4467d7f
2 changed files with 7 additions and 6 deletions
|
@ -163,14 +163,13 @@ void quant_bands(const CELTMode *m, float *X, float *P)
|
||||||
alg_quant2(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, P+B*eBands[i]);
|
alg_quant2(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, P+B*eBands[i]);
|
||||||
for (j=B*eBands[i];j<B*eBands[i+1];j++)
|
for (j=B*eBands[i];j<B*eBands[i+1];j++)
|
||||||
norm[j] = X[j] * n;
|
norm[j] = X[j] * n;
|
||||||
//bits += log2(ncwrs(B*(qbank[i+1]-qbank[i]), q));
|
//bits += log2(ncwrs(B*(eBands[i+1]-eBands[i]), q));
|
||||||
} else {
|
} else {
|
||||||
float n = sqrt(B*(eBands[i+1]-eBands[i]));
|
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]);
|
||||||
for (j=B*eBands[i];j<B*eBands[i+1];j++)
|
for (j=B*eBands[i];j<B*eBands[i+1];j++)
|
||||||
norm[j] = X[j] * n;
|
norm[j] = X[j] * n;
|
||||||
//bits += 1+log2(qbank[i])+log2(ncwrs(B*(qbank[i+1]-qbank[i]), -q));
|
//bits += 1+log2(eBands[i])+log2(ncwrs(B*(eBands[i+1]-eBands[i]), -q));
|
||||||
//noise_quant(X+B*qbank[i], B*(qbank[i+1]-qbank[i]), q, P+B*qbank[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//printf ("%f\n", bits);
|
//printf ("%f\n", bits);
|
||||||
|
|
|
@ -43,21 +43,23 @@ void quant_energy(CELTMode *m, float *eBands, float *oldEBands)
|
||||||
float q;
|
float q;
|
||||||
float res;
|
float res;
|
||||||
float x;
|
float x;
|
||||||
float pred = .9*oldEBands[i];
|
float pred = .7*oldEBands[i];
|
||||||
|
|
||||||
x = 20*log10(.3+eBands[i]);
|
x = 20*log10(.3+eBands[i]);
|
||||||
res = 1.0f;
|
res = .25f*(i+3.f);
|
||||||
|
//res = 1;
|
||||||
qi = (int)floor(.5+(x-pred-prev)/res);
|
qi = (int)floor(.5+(x-pred-prev)/res);
|
||||||
q = qi*res;
|
q = qi*res;
|
||||||
|
|
||||||
//printf("%f %f ", pred+prev+q, x);
|
//printf("%f %f ", pred+prev+q, x);
|
||||||
//printf("%d ", qi);
|
//printf("%d ", qi);
|
||||||
|
//printf("%f ", x-pred-prev);
|
||||||
|
|
||||||
oldEBands[i] = pred+prev+q;
|
oldEBands[i] = pred+prev+q;
|
||||||
eBands[i] = pow(10, .05*oldEBands[i])-.3;
|
eBands[i] = pow(10, .05*oldEBands[i])-.3;
|
||||||
if (eBands[i] < 0)
|
if (eBands[i] < 0)
|
||||||
eBands[i] = 0;
|
eBands[i] = 0;
|
||||||
prev = .65*q;
|
prev = (prev + .5*q);
|
||||||
}
|
}
|
||||||
//printf ("\n");
|
//printf ("\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue