H.264句法和语法总结(十四)CAVLC 残差句法

residual_block_cavlc( coeffLevel, maxNumCoeff ) {  C      Descriptor 
    for( i = 0; i < maxNumCoeff; i++ )           
        coeffLevel[ i ] = 0      
    // coeff_token      指明了非零系数的个数,拖尾系数的个数。       
    coeff_token  
    if( TotalCoeff( coeff_token ) > 0 ) {           
        if( TotalCoeff( coeff_token ) > 10    &&    TrailingOnes( coeff_token ) < 
3 ) 
            suffixLength = 1           
        else           
            suffixLength = 0           
        for( i = 0; i < TotalCoeff( coeff_token ); i++ )           
            if( i < TrailingOnes( coeff_token ) ) {            
                // trailing_ones_sign_flag  拖尾系数的符号 
                    -     如果trailing_ones_sign_flag = 0,  相应的拖尾系数是+1。 
                    -     否则,trailing_ones_sign_flag =1,相应的拖尾系数是-1。
  
                trailing_ones_sign_flag   
                level[ i ] = 1 – 2 * trailing_ones_sign_flag           
            } else {           
                // level_prefix and level_suffix  非零系数值的前缀和后缀。  
                level_prefix  
                levelCode = ( level_prefix << suffixLength )           
                if( suffixLength > 0    | |    level_prefix >= 14 ) {           
                    level_suffix   
                    levelCode += level_suffix           
                }           
                if( level_prefix    = =    15    &&    suffixLength    = =    0 )           
                    levelCode += 15           
                if( i    = =    TrailingOnes( coeff_token )    &&     
                      TrailingOnes( coeff_token ) < 3 ) 
                    levelCode += 2           
                if( levelCode % 2    = =    0 )           
                    level[ i ] = ( levelCode + 2 ) >> 1           
                else           
                    level[ i ] = ( –levelCode – 1 ) >> 1           
                if( suffixLength    = =    0 )           
                    suffixLength = 1           
                if( Abs( level[ i ] )    >    ( 3 << ( suffixLength – 1 ) )    &&     
                      suffixLength < 6 ) 
                    suffixLength++           
            }           
        if( TotalCoeff( coeff_token ) < maxNumCoeff ) {           
            // total_zeros    系数中 0 的总个数。 
            total_zeros    
            zerosLeft = total_zeros           
        } else           
            zerosLeft = 0           
        for( i = 0; i < TotalCoeff( coeff_token ) – 1; i++ ) {           
            if( zerosLeft > 0 ) {           
                
                run_before    
                run[ i ] = run_before           
            } else           
                run[ i ] = 0           
            zerosLeft = zerosLeft – run[ i ]           
        }           
        run[ TotalCoeff( coeff_token ) – 1 ] = zerosLeft           
        coeffNum = -1           
        for( i = TotalCoeff( coeff_token ) – 1; i >= 0; i-- ) {           
            coeffNum += run[ i ] + 1           
            coeffLevel[ coeffNum ] = level[ i ]             
        }           
    }           
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值