MP3解码算法分析

  • 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

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值