33 #define LOG_MAX_PSEUDO 6
35 #define CELT_MAX_PULSES 128
37 #define MAX_FINE_BITS 8
39 #define FINE_OFFSET 21
40 #define QTHETA_OFFSET 4
41 #define QTHETA_OFFSET_TWOPHASE 16
46 void compute_pulse_cache(CELTMode *m,
int LM);
48 static OPUS_INLINE
int get_pulses(
int i)
50 return i<8 ? i : (8 + (i&7)) << ((i>>3)-1);
53 static OPUS_INLINE
int bits2pulses(
const CELTMode *m,
int band,
int LM,
int bits)
57 const unsigned char *cache;
60 cache = m->cache.bits + m->cache.index[LM*m->nbEBands+band];
65 for (i=0;i<LOG_MAX_PSEUDO;i++)
67 int mid = (lo+hi+1)>>1;
69 if ((
int)cache[mid] >= bits)
74 if (bits- (lo == 0 ? -1 : (
int)cache[lo]) <= (int)cache[hi]-bits)
80 static OPUS_INLINE
int pulses2bits(
const CELTMode *m,
int band,
int LM,
int pulses)
82 const unsigned char *cache;
85 cache = m->cache.bits + m->cache.index[LM*m->nbEBands+band];
86 return pulses == 0 ? 0 : cache[pulses]+1;
98 int compute_allocation(
const CELTMode *m,
int start,
int end,
const int *offsets,
const int *cap,
int alloc_trim,
int *intensity,
int *dual_stero,
99 opus_int32 total, opus_int32 *balance,
int *pulses,
int *ebits,
int *fine_priority,
int C,
int LM, ec_ctx *ec,
int encode,
int prev,
int signalBandwidth);