找回密码
 注册
搜索
查看: 1399|回复: 5

[音频编解码] 请教MPEG1 layer 3中的若干问题

[复制链接]
发表于 2006-9-16 11:09:00 | 显示全部楼层 |阅读模式
在写MP3 解码程序的时候,偶一直在看iso11172-3,里面有很多东东反复看了很多次也没有看明白,还请大家指教:
1。scalefactor,这个鬼东西很重要,但是看不懂到底是什么意思?
2。intensity stereo和ms stereo到底原理如何,偶只是看到,他们分别用来处理bigvalue*2+count1*4部分和zero 部分,但具体如果实现,感觉很模糊。
偶在版面上下载了一个mp3 decoder的具体程序,正在准备把他移植到我的arm的程序中,但是偶在想,如果具体的看不懂,直接移植过来,到时候调试出了问题都不知道在哪出的,所以先仔细研读iso11172-3和代码,搞清楚了再移植,不知道我的方法是否有问题,还请大家多多指教。
发表于 2007-9-18 10:08:00 | 显示全部楼层
hammeryu,现在你的MP3解码作得怎么样了?
有没有做编码?
有没有经验可以共享一下啊?
谢谢![em02]
点评回复

使用道具 举报

发表于 2007-9-25 14:46:00 | 显示全部楼层
我前一段时间刚刚做过编码器设计,你问的这几个问题很基本,如果搞不懂对下来的工作做起来也会很费力,这也是直接作解码器设计的人存在的通病,只是在做,并不知道其中一些参数的意义。
所以,建议有时间的话,可以先看一些编码原理方面的资料看一下。
1。scf用来调整某一个scf band内数据幅值的一个数据,在编码时量化时产生。
2。在网上很容易找到MS和IS的原理,自己找找。
点评回复

使用道具 举报

发表于 2007-10-29 10:02:00 | 显示全部楼层
1。scalefactor,这个鬼东西很重要,但是看不懂到底是什么意思?[52RD.com]
2。intensity stereo和ms stereo到底原理如何,偶只是看到,他们分别用来处理bigvalue*2+count1*4部分和zero 部分,但具体如果实现,感觉很模糊

-----------------------------------------------------------------------------------------------------------------------------
scalefactor叫量化因子或者缩放因子, 在压缩MP3的时候, 时域信号会经过MDCT这个环节转换为频域信号ix, ix具有576个样本.
ix是有规律的频域信号, ix[0]---ix[a]是属于big_value区段, ix[a+1]--ix属于count1区段, ix[b+1]--ix[575]是属于zero区段, 至于这三个区段怎么划分,请参考相关代码。 我这里有,仅供参考
/**
* Function: Calculation of rzero, count1, big_values
* (Partitions ix into big values, quadruples and zeros).
*
* 量化后的频谱系数在被编码前会分成三个区 zero, count1, big_value
*
* gr_info结构会记录住这三个区段, 以便解码时使用. gr_info并不会真的
* 位置三个区的数据, 而是记录count1区的元素个数(cod_info->count1*4)和
* big_value区的元素个数(cod_info->big_values*2)
*/
void calc_runlen( int ix[samp_per_frame2], gr_info *cod_info )
{
    int         i;
    int         rzero = 0;        // 记录zero区段的元素个数.
   
    /*
     * i到了 zero 的地盘了!
     * zero区段是由最高频系数ix(575)开始往低频算起, 以两个频谱系数为一组.
     * 如果两个频谱系数都为0, 就属于zero段.
     */
    for ( i=samp_per_frame2; i>1; i-=2 )
    {
            if ( !ix[i-1] && !ix[i-2] )        rzero++;
            else                                                break;
    }
       
        /*
         * i到了 count1 的地盘了!
         * count1段则是继zero段后, 继续往低频以四个频谱系数为一组,
         * 当四个频谱系数的值都为1/-1/0的话, 就属于count1段
         */
        cod_info->count1 = 0 ;
        for ( ; i>3; i-=4 )
        {
                if ( abs(ix[i-1])<=1 && abs(ix[i-2])<=1        && abs(ix[i-3])<=1 && abs(ix[i-4])<=1 )
                        cod_info->count1 ++;        // 解码的时候cod_info->count1应该是需要乘以4的.
                else
                        break;
        }
       
        /*
         * 剩下的就是big_value区段了!
         */
        cod_info->big_values = i>>1;
}

那么现在你已经得到了频域信号ix了, 前面已经讲过ix会被划分成3个区间big_value, count1, rezero
这三个区间对人的耳朵起到的感知作用是不同的 rezero部分是高频部分,对人耳朵基本不起什么作用, big_value是人的耳朵感知最强的低频部分, count1次之。
那么就需要利用 scalefactor来对这三个部分进行调节, 比如说:我们可以把big_value部分放大个几倍, 把count1部分保持不变, 把rezero部分丢掉.
至于scalefactor是怎么计算出来,以及如何调节,请参看 非均匀量化 这个知识点。
OK, 那么在解码的时候我们需要的就是逆过程, scalefactor是需要被利用的, 要不然怎么回复到没有量化之前的状态呢?


第2个问题, intensity stereo和ms stereo 这两个名词我没听过。
我们再来谈编码, 分割成big_value, count1, rezero三个部分后,量化工作也做好了。
那么就需要进行编码, 对前2个区间选择合适的huffman table来进行压缩(实际上big_value会被再细分为region0,region1,region2三个小区间进行编码的)
big_value区间会每次提出2个样本来作为一组,去huffman table查找对应的码值, count1部分是每次提4个样本。

整个过程比我说的好复杂很多很多, 请注意查看l3loop这个知识点。
点评回复

使用道具 举报

发表于 2007-10-29 12:10:00 | 显示全部楼层
个人理解,MS/Intensity的区别是采取不同的运算方式,处理左右声道。
参照如下:见ISO11172-3

MS_stereo mode
This mode switch (found in the header: mode_extension) allows switching from 'independent stereo' to MS_stereo. The upper bound of the scalefactor bands decoded in ms stereo is derived from the "zero_part" of the difference (right) channel. Above this bound intensity stereo can be applied if enabled in the header.
The "zero_part" of the difference channel is the part of the spectrum from "bigvalues*2+count1*4" (see clause 2.4.2.7) to the Nyquist rate.

- MS matrix

In MS stereo mode the values of the normalized middle/side channels Mi/Si are transmitted instead of the left/right channel values Li/Ri. Thus Li/Ri are reconstructed using

                 

The values Mi are transmitted in the left, values Si are transmitted in the right channel


Intensity stereo mode
This mode switch (found in the header: mode_extension) allows switching from 'normal stereo' to intensity stereo. The lower bound of the scalefactor bands decoded in intensity stereo is derived from the "zero_part" of the right channel. Above this bound decoding of intensity stereo is applied using the scalefactors of the right channel as intensity stereo positions. An intensity stereo position of 7 in one scalefactor band indicates that this scalefactor band is NOT decoded as intensity stereo.

Scalefactor bands :
|        |        |        |        |        |        |        |        |        |  . . .        |    |
|<--- nonzero_part of spectrum (left chan) --->|<----- zero_part of spectrum ------>|
|<------- m/s or l/r stereo coded part ---------->|<- intensity stereo coded part ->|

For each scalefactor band sb coded in intensity stereo the following steps are executed:

        -  the intensity stereo position is_possb is read from the scalefactor of the right channel

        -  if (is_possb == 7)  do not perform the following steps (illegal is_pos)

        -  is_ratio = tan( is_possb * p/12 )
点评回复

使用道具 举报

发表于 2007-10-29 12:14:00 | 显示全部楼层
MS公式:
[upload=jpg]UploadFile/2007-10/071029@52RD_MS.JPG[/upload]

Intensity公式:
  
[upload=jpg]UploadFile/2007-10/071029@52RD_Intensity.JPG[/upload]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
点评回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

Archiver|手机版|小黑屋|52RD我爱研发网 ( 沪ICP备2022007804号-2 )

GMT+8, 2025-2-24 08:44 , Processed in 0.049147 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表