Proper use of logN and logM for the offsets
This commit is contained in:
parent
c40d6f97a2
commit
aead79b133
3 changed files with 7 additions and 4 deletions
|
@ -639,7 +639,7 @@ void quant_bands_stereo(const CELTMode *m, int start, celt_norm *_X, const celt_
|
|||
if (b<0)
|
||||
b = 0;
|
||||
|
||||
qb = (b-2*(N-1)*(QTHETA_OFFSET-log2_frac(N,BITRES)))/(32*(N-1));
|
||||
qb = (b-2*(N-1)*(QTHETA_OFFSET-m->logN[i]-(LM<<BITRES)))/(32*(N-1));
|
||||
if (qb > (b>>BITRES)-1)
|
||||
qb = (b>>BITRES)-1;
|
||||
if (qb<0)
|
||||
|
@ -835,7 +835,7 @@ void unquant_bands_stereo(const CELTMode *m, int start, celt_norm *_X, const cel
|
|||
if (b<0)
|
||||
b = 0;
|
||||
|
||||
qb = (b-2*(N-1)*(QTHETA_OFFSET-log2_frac(N,BITRES)))/(32*(N-1));
|
||||
qb = (b-2*(N-1)*(QTHETA_OFFSET-m->logN[i]-(LM<<BITRES)))/(32*(N-1));
|
||||
if (qb > (b>>BITRES)-1)
|
||||
qb = (b>>BITRES)-1;
|
||||
if (qb>14)
|
||||
|
|
|
@ -379,7 +379,7 @@ CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error)
|
|||
goto failure;
|
||||
|
||||
for (i=0;i<mode->nbEBands;i++)
|
||||
logN[i] = log2_frac(mode->nbShortMdcts*(mode->eBands[i+1]-mode->eBands[i]), BITRES);
|
||||
logN[i] = log2_frac(mode->eBands[i+1]-mode->eBands[i], BITRES);
|
||||
mode->logN = logN;
|
||||
#endif /* !STATIC_MODES */
|
||||
|
||||
|
|
|
@ -107,8 +107,11 @@ static inline void interp_bits2pulses(const CELTMode *m, int start, int *bits1,
|
|||
int psum;
|
||||
int lo, hi;
|
||||
int j;
|
||||
int logM;
|
||||
const int C = CHANNELS(_C);
|
||||
SAVE_STACK;
|
||||
|
||||
logM = log2_frac(M, BITRES);
|
||||
lo = 0;
|
||||
hi = 1<<BITRES;
|
||||
while (hi-lo != 1)
|
||||
|
@ -148,7 +151,7 @@ static inline void interp_bits2pulses(const CELTMode *m, int start, int *bits1,
|
|||
N=M*(m->eBands[j+1]-m->eBands[j]);
|
||||
/* Compensate for the extra DoF in stereo */
|
||||
d=(C*N+ ((C==2 && N>2) ? 1 : 0))<<BITRES;
|
||||
offset = FINE_OFFSET - m->logN[j];
|
||||
offset = FINE_OFFSET - m->logN[j] - logM;
|
||||
/* Offset for the number of fine bits compared to their "fair share" of total/N */
|
||||
offset = bits[j]-offset*N*C;
|
||||
/* Compensate for the prediction gain in stereo */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue