感知音频编码的设计思想
由于人耳对于某些频率段的声音听觉效果不明显,则对于此部分音频可以不编码。
频域掩蔽效应
心理声学模型
码率分配的实现思路
噪掩比等于信掩比减去信噪比,最好降低噪掩比到0。对最高NMR的子带分配比特,使获益最大的子带的量化级别增加一级。重新计算分配了更多比特子带的NMR。循环上述步骤,直到所有NMR都降到0或者没有比特可供分配。
main函数代码解读
frame_info frame;//结构体包含头信息、比特分配表、声道数、子带数等内容
frame_header header;//头信息
char original_file_name[MAX_NAME_SIZE];//输入文件名
char encoded_file_name[MAX_NAME_SIZE];//编码后输出文件名
short **win_buf;
static short buffer[2][1152];
static unsigned int bit_alloc[2][SBLIMIT], scfsi[2][SBLIMIT];//存放2声道各个子带的比特分配表,SBLIMIT=32,也就是32个子带
static unsigned int scalar[2][3][SBLIMIT], j_scale[3][SBLIMIT];//存放2声道,3组,每组12个样值的各子带的比例因子
static double smr[2][SBLIMIT], lgmin[2][SBLIMIT], max_sc[2][SBLIMIT];
// FLOAT snr32[32];
short sam[2][1344]; /* was [1056]; */
int model, nch, error_protection;
static unsigned int crc;
int sb, ch, adb;
unsigned long frameBits, sentBits = 0;
unsigned long num_samples;
int lg_frame;
int i;
/* Used to keep the SNR values for the fast/quick psy models */
static FLOAT smrdef[2][32];
static int psycount = 0;
extern int minimum;
time_t start_time, end_time;
int total_time;
sb_sample = (SBS *) mem_alloc (sizeof (SBS), "sb_sample");
j_sample = (JSBS *) mem_alloc (sizeof (JSBS), "j_sample");
win_que = (IN *) mem_alloc (sizeof (IN), "Win_que");
subband = (SUB *) mem_alloc (sizeof (SUB), "subband");
win_buf = (short **) mem_alloc (sizeof (short *) * 2, "win_buf");
/* clear buffers */
memset ((char *) buffer, 0,