ref: 360342824fb726831e1a1d94c796472ae9167e32
parent: 39ffbeec9a168d271087a3e8eb449292708d6a50
author: Jean-Marc Valin <[email protected]>
date: Fri Aug 6 10:42:43 EDT 2010
Adaptive fine offset value
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -154,13 +154,22 @@
}
for (j=start;j<end;j++)
{
- int N, d;
+ int N0, N, d;
int offset;
-
- N=M*(m->eBands[j+1]-m->eBands[j]);
+ int fine_offset;
+ N0 = m->eBands[j+1]-m->eBands[j];
+ N=M*N0;
/* Compensate for the extra DoF in stereo */
- d=(C*N+ ((C==2 && N>2) ? 1 : 0))<<BITRES;
- offset = FINE_OFFSET - ((m->logN[j] + logM)>>1);
+ d=(C*N+ ((C==2 && N>2) ? 1 : 0))<<BITRES;
+
+ if (N0==1)
+ fine_offset = 19;
+ else if (N0<=4)
+ fine_offset = 14;
+ else
+ fine_offset = 12;
+
+ offset = fine_offset - ((m->logN[j] + logM)>>1);
/* 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 */
--- a/libcelt/rate.h
+++ b/libcelt/rate.h
@@ -40,7 +40,6 @@
#define LOG_MAX_PULSES 7
#define BITRES 3
-#define FINE_OFFSET 14
#define QTHETA_OFFSET 6
#define QTHETA_OFFSET_STEREO 4