📄 huffman.c
字号:
/***********************************************
copyright by Haia Tech
www.haia2004.com
************************************************/
/* MPEG Audio Layer-3 decoder */
/* Bjorn Wesen 1997 */
/* */
/* Huffman decoder */
#include "huffman.h"
#include "common.h"
extern unsigned int frameNum;
/* lots of tables */
/* code implementing the Huffman decoder for layer-3 */
/* decode the Huffman coded energies of a Granule */
#define BITS_USED ((((datapos - (totpos >> 3)) * 8) % BITSTREAM_BUFSIZE) - \
dataword_len - (totpos & 7))
static int t_linbits[32] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,6,8,
10,13,4,5,6,7,8,9,11,13 };
static unsigned int offset;
static unsigned int buf_bit_idx=8;
unsigned int buf_byte_idx;
extern unsigned int totpos;
extern unsigned char buf[BITSTREAM_BUFSIZE];
static unsigned int dataword;
int dataword_len;
int datapos;
extern struct BandIndex sfBandIndex[3];
extern frame_params fr_ps;
int HuffmanTable_decode(int tbl,
int *x, int *y, int *v, int *w);
void III_hufman_decode(struct Granule *gr,int part2_start,
int freqline[SBLIMIT][SSLIMIT])
{
unsigned int reg1, reg2,i;
unsigned int part3_length = part2_start + gr->part2_3_length;
unsigned used;
int h,*f=&freqline[0][0];
if(gr->window_switching_flag &&
gr->block_type == 2)
{
/* short block regions */
reg1 = 36;
reg2 = 576;
}
else
{
/* long block regions */
reg1 = sfBandIndex[fr_ps.header->sampling_frequency].l[gr->region0_count + 1];
reg2 = sfBandIndex[fr_ps.header->sampling_frequency].l[gr->region0_count + gr->region1_count + 2];
}
/* fill up dataword, end at a bytealign in the buffer */
{
int bitpos = totpos & 7; //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -