Skip to content
Snippets Groups Projects
Commit aeb4467d authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

improved energy quantisation/prediction

parent 06311335
No related branches found
No related tags found
No related merge requests found
......@@ -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]);
for (j=B*eBands[i];j<B*eBands[i+1];j++)
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 {
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]);
for (j=B*eBands[i];j<B*eBands[i+1];j++)
norm[j] = X[j] * n;
//bits += 1+log2(qbank[i])+log2(ncwrs(B*(qbank[i+1]-qbank[i]), -q));
//noise_quant(X+B*qbank[i], B*(qbank[i+1]-qbank[i]), q, P+B*qbank[i]);
//bits += 1+log2(eBands[i])+log2(ncwrs(B*(eBands[i+1]-eBands[i]), -q));
}
}
//printf ("%f\n", bits);
......
......@@ -43,21 +43,23 @@ void quant_energy(CELTMode *m, float *eBands, float *oldEBands)
float q;
float res;
float x;
float pred = .9*oldEBands[i];
float pred = .7*oldEBands[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);
q = qi*res;
//printf("%f %f ", pred+prev+q, x);
//printf("%d ", qi);
//printf("%f ", x-pred-prev);
oldEBands[i] = pred+prev+q;
eBands[i] = pow(10, .05*oldEBands[i])-.3;
if (eBands[i] < 0)
eBands[i] = 0;
prev = .65*q;
prev = (prev + .5*q);
}
//printf ("\n");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment