-
1. 读 32bit 的帧头,头处理的主处理流程
Header.read_header(Bitstream, Crc16[] crcp) [javazoom.jl.decoder]
int headerstring; // 帧头的32位对应的32位整数
int channel_bitrate; // 比特率
boolean sync = false; // 同步判断do {
headerstring = stream.syncHeader(syncmode);// 同步并获取帧头的32位整数
_headerstring = headerstring;if (syncmode==Bitstream.INITIAL_SYNC) { // 如果是初始化同步
h_version = ((headerstring >>> 19) & 1); // 求取第 19 位的版本号
if (((headerstring >>> 20) & 1) == 0) // 第 20 位为: MPEG2.5 detection
if (h_version == MPEG2_LSF)
h_version = MPEG25_LSF;
else
throw stream.newBitstreamException(Bitstream.UNKNOWN_ERROR);
// 第 10-11 位为采样率
if ((h_sample_frequency = ((headerstring >>> 10) & 3)) == 3)
throw stream.newBitstreamException(Bitstream.UNKNOWN_ERROR);
}h_layer = 4 - (headerstring >>> 17) & 3; // 第 17-18 位为层号 Layer I/II/III
h_protection_bit = (headerstring >>> 16) & 1; // 第 16 位为保护位 Protect
h_bitrate_index = (headerstring >>> 12) & 0xF; // 第 12-15 位为比特率
h_padding_bit = (headerstring >>> 9) & 1; // 第 9 位为补齐位
h_mode = ((headerstring >>> 6) & 3); // 第 6-7 位为模式位
h_mode_extension = (headerstring >>> 4) & 3; // 第 4-5 位为模式扩展位
if (h_mode==JOINT_STEREO) h_intensity_stereo_bound = (h_mode_extension << 2) + 4;
else h_intensity_stereo_bound = 0; // 用不到
if (((headerstring >>> 3) & 1)==1) h_copyright = true; // 第 3 位版权等信息
if (((headerstring >>> 2) & 1)==1) h_original = true; // 第 2 位为 Home 信息if (h_layer==1) h_number_of_subbands = 32; // 计算子带数(subbands),Layer I 有 32 个子带
else {
channel_bitrate = h_bitrate_index; // 计算每个信道的比特率
if (h_mode != SINGLE_CHANNEL)
if (channel_bitrate == 4) channel_bitrate = 1;
else channel_bitrate -= 4;if ((channel_bitrate
MP3解码算法分析
最新推荐文章于 2024-09-12 09:41:24 发布