LZ77算法基本过程http://jpkc.zust.edu.cn/2007/dmt/course/MMT03_05_2.htm
输入待字典编码的CU,
CopyCuFromPicYuv444(pcPic,m_pCuBuf, cuIdx,bEncOrg);
待编码的输入64*64,重排序后的YUV (*(m_matchFinderBase.stream)).data
void CDictEncoder::WriteStrMapResult(int len, int pos,const UChar * pCurBuf)
//写入编码的结果,32位数的iDst编码结果push_banck到m_pStrMapBufList,m_uCurrPackSize为list大小。
{
…
if (len == 1 && pos == (UInt)-1)//没有匹配的
{
if (numCoded>=3)
{
litFlag = (pCurBuf[0]-pCurBuf[-3])<0;
c = (UInt)ABS_DIFF(pCurBuf[0],pCurBuf[-3]);
}
else
c = (UInt)pCurBuf[0];
WriteBits(iDst,0,1,1);
WriteBits(iDst,litFlag,1,2);//因为排列顺序是YUVYUV,所以编的是与pCurBuf[-3]的差值,litFlag表示差值的正负
WriteBits(iDst,c,8,3);
}
else
{
WriteBits(iDst,1,1,1); //第1个bit占一位,指示有匹配,第2bit开始的9位表示匹配长度len,第11bit开始的22位表示偏移pos
WriteBits(iDst,len,9,2);
WriteBits(iDst,pos,22,11);
}
}
void CDictEncoder::DictCodeOneBlock()
{
…
for (;;)
{
len = GetOptimumFast(&pos);//返回最佳的匹配,len长度,pos偏移
…
pCurBuf = MatchFinder_GetPointerToCurrentPos(&m_matchFinderBase) - m_uAdditionalOffset;
//(m_matchFinderBase).buffer匹配的结束位置,即m_uAdditionalOffset=len,向前len为匹配的开始位置pCurBuf,len>8 时匹配串在pCurBuf-(pos-8)-1, pos<8时,在pC