x265代码分析-nonPsyRdoQuant CG编码为0的开销

template<int log2TrSize>
static void nonPsyRdoQuant_c(
    int16_t *m_resiDctCoeff, int64_t *costUncoded, int64_t *totalUncodedCost, int64_t *totalRdCost, uint32_t blkPos)
    /*
    参数说明:
    1 残差dct变换后的因子,
    2 costUncoded当前系数全部编码为0的 distortion cost衡量,数组,衡量每一个系数
    3 总的cg 编码为0开销
    4 当前这个cg编码为0的开销。
    5 当前的cg在TB中的位置。
    */
{
    const int transformShift = MAX_TR_DYNAMIC_RANGE - S265_DEPTH - log2TrSize; /* Represents scaling through forward transform */
    const int scaleBits = SCALE_BITS - 2 * transformShift;
    const uint32_t trSize = 1 << log2TrSize;

    for (int y = 0; y < MLS_CG_SIZE; y++)
    {
        for (int x = 0; x < MLS_CG_SIZE; x++)
        {
             int64_t signCoef = m_resiDctCoeff[blkPos + x];            /* pre-quantization DCT coeff */
             costUncoded[blkPos + x] = static_cast<int64_t>((double)((signCoef * signCoef) << scaleBits));
             //这里本来是需要 d * d <<scaleBits + bitcosts * lambda, 编码为0,bitcost没有了。distortion 就是因子的值
             *totalUncodedCost += costUncoded[blkPos + x];//总的cg编码为0,付出的代价。
             *totalRdCost += costUncoded[blkPos + x]; //当前cg把所有因子编码为0的cost加起来
        }
        blkPos += trSize;
    }
}

这个地方计算开销的时候,直接signCoeff * signCoeff <<scaleBits。

#define DELTARDCOST(d0, d, deltabits) ((((int64_t)d * d - d0) << scaleBits) + ((lambda2 * (int64_t)(deltabits)) >> 8))

正常应该按照上面的方式计算,这里少了 lambda * deltabits ,因为没有编码bits了。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值