Ticket #832: crc_bug.patch

File crc_bug.patch, 1.4 KB (added by bheng, 11 years ago)
  • source/Lib/TLibCommon/TComPicYuvMD5.cpp

     
    8585
    8686static void compCRC(Int bitdepth, const Pel* plane, UInt width, UInt height, UInt stride, UChar digest[16])
    8787{
    88   UInt dataMsbIdx = bitdepth - 1;
    8988  UInt crcMsb;
    9089  UInt bitVal;
    9190  UInt crcVal = 0xffff;
     
    9392  for (UInt y = 0; y < height; y++)
    9493  {
    9594    for (UInt x = 0; x < width; x++)
    96     {     
    97       for(bitIdx=0; bitIdx<bitdepth; bitIdx++)
     95    {
     96      // take CRC of first pictureData byte
     97      for(bitIdx=0; bitIdx<8; bitIdx++)
    9898      {
    9999        crcMsb = (crcVal >> 15) & 1;
    100         bitVal = (plane[y*stride+x]>> (dataMsbIdx - (bitIdx&dataMsbIdx))) & 1;
     100        bitVal = (plane[y*stride+x] >> (7 - bitIdx)) & 1;
    101101        crcVal = (((crcVal << 1) + bitVal) & 0xffff) ^ (crcMsb * 0x1021);
    102102      }
     103      // take CRC of second pictureData byte if bit depth is greater than 8-bits
     104      if(bitdepth > 8)
     105      {
     106        for(bitIdx=0; bitIdx<8; bitIdx++)
     107        {
     108          crcMsb = (crcVal >> 15) & 1;
     109          bitVal = (plane[y*stride+x] >> (15 - bitIdx)) & 1;
     110          crcVal = (((crcVal << 1) + bitVal) & 0xffff) ^ (crcMsb * 0x1021);
     111        }
     112      }
    103113    }
    104114  }
    105115  for(bitIdx=0; bitIdx<16; bitIdx++)