
#ifndef RATE_H
#define RATE_H

#define MAX_PSEUDO 40
#define LOG_MAX_PSEUDO 6
#define MAX_PULSES 128
#define MAX_FINE_BITS 8
#define FINE_OFFSET 21
#define QTHETA_OFFSET 4
#define QTHETA_OFFSET_TWOPHASE 16



#include "config.h"
#include "ssc_modes.h"
#include "entcode.h"



#ifndef HW_24BIT
short num_pulses(short i);
#else
short num_pulses(short i,short N);
#endif


//short bits2pulses(const unsigned short *cache ,short bits);



short calculate_bitalloc(const SpeechMode *m, short end, short *offsets,  const short *cap, short alloc_trim, 
	short total, short *balance, short *pulses, short *ebits, short *fine_priority, ec_ctx *ec, short prev);



void compute_offset(short *oldBandE, short *offsets);



/* Mean energy in each band quantized in Q4 */
//const char eMeans[16] = {103,100, 92, 85, 81, 77, 72, 70, 78, 75, 73, 71, 78, 74, 69, 72};
//const short _cap[16] = {249, 249, 249, 249, 249, 249, 249, 249, 249, 249, 514, 514, 514, 1028, 1028, 1482};
//const unsigned char trim_icdf[11] = {126, 124, 119, 109, 87, 41, 19, 9, 4, 2, 0};

extern const char eMeans[16];
extern const short _cap[16];
extern const unsigned char trim_icdf[11];


#endif


