44 template<UInt OUTPUT_BITDEPTH_DIV8>
48 UChar buf[64/OUTPUT_BITDEPTH_DIV8][OUTPUT_BITDEPTH_DIV8];
49 for (
UInt i = 0; i < n; i++)
53 for (
UInt d = 0; d < OUTPUT_BITDEPTH_DIV8; d++)
55 buf[i][d] = pel >> (d*8);
65 template<UInt OUTPUT_BITDEPTH_DIV8>
71 UInt width_modN = width % N;
72 UInt width_less_modN = width - width_modN;
74 for (
UInt y = 0; y < height; y++)
78 for (
UInt x = 0; x < width_less_modN; x += N)
80 md5_block<OUTPUT_BITDEPTH_DIV8>(md5, &plane[y*stride + x], N);
84 md5_block<OUTPUT_BITDEPTH_DIV8>(md5, &plane[y*stride + width_less_modN], width_modN);
95 for (
UInt y = 0; y < height; y++)
97 for (
UInt x = 0; x < width; x++)
100 for(bitIdx=0; bitIdx<8; bitIdx++)
102 crcMsb = (crcVal >> 15) & 1;
103 bitVal = (plane[y*stride+x] >> (7 - bitIdx)) & 1;
104 crcVal = (((crcVal << 1) + bitVal) & 0xffff) ^ (crcMsb * 0x1021);
109 for(bitIdx=0; bitIdx<8; bitIdx++)
111 crcMsb = (crcVal >> 15) & 1;
112 bitVal = (plane[y*stride+x] >> (15 - bitIdx)) & 1;
113 crcVal = (((crcVal << 1) + bitVal) & 0xffff) ^ (crcMsb * 0x1021);
118 for(bitIdx=0; bitIdx<16; bitIdx++)
120 crcMsb = (crcVal >> 15) & 1;
121 crcVal = ((crcVal << 1) & 0xffff) ^ (crcMsb * 0x1021);
124 digest.
hash.push_back((crcVal>>8) & 0xff);
125 digest.
hash.push_back( crcVal & 0xff);
146 for (
UInt y = 0; y < height; y++)
148 for (
UInt x = 0; x < width; x++)
150 xor_mask = (x & 0xff) ^ (y & 0xff) ^ (x >> 8) ^ (y >> 8);
151 checksum = (checksum + ((plane[y*stride+x] & 0xff) ^ xor_mask)) & 0xffffffff;
155 checksum = (checksum + ((plane[y*stride+x]>>8) ^ xor_mask)) & 0xffffffff;
160 digest.
hash.push_back((checksum>>24) & 0xff);
161 digest.
hash.push_back((checksum>>16) & 0xff);
162 digest.
hash.push_back((checksum>>8) & 0xff);
163 digest.
hash.push_back( checksum & 0xff);
189 MD5PlaneFunc md5_plane_func;
197 md5_plane_func = bitDepths.
recon[
toChannelType(compID)] <= 8 ? (MD5PlaneFunc)md5_plane<1> : (MD5PlaneFunc)md5_plane<2>;
203 digest.
hash.push_back(tmp_digest[i]);
211 static const TChar* hex =
"0123456789abcdef";
214 for(
Int pos=0; pos<
Int(digest.
hash.size()); pos++)
216 if ((pos % numChar) == 0 && pos!=0 )
220 result += hex[digest.
hash[pos] >> 4];
221 result += hex[digest.
hash[pos] & 0xf];
UInt calcChecksum(const TComPicYuv &pic, TComPictureHash &digest, const BitDepths &bitDepths)
Int getStride(const ComponentID id) const
Int getHeight(const ComponentID id) const
UInt compChecksum(Int bitdepth, const Pel *plane, UInt width, UInt height, UInt stride, TComPictureHash &digest, const BitDepths &)
UInt compCRC(Int bitdepth, const Pel *plane, UInt width, UInt height, UInt stride, TComPictureHash &digest)
void update(unsigned char *buf, unsigned len)
static Void md5_block(MD5 &md5, const Pel *plane, UInt n)
Int recon[MAX_NUM_CHANNEL_TYPE]
the bit depth as indicated in the SPS
static const UInt MD5_DIGEST_STRING_LENGTH
UInt calcMD5(const TComPicYuv &pic, TComPictureHash &digest, const BitDepths &bitDepths)
Int getWidth(const ComponentID id) const
picture YUV buffer class (header)
UInt getNumberValidComponents() const
std::vector< UChar > hash
Pel * getAddr(const ComponentID ch)
static Void md5_plane(MD5 &md5, const Pel *plane, UInt width, UInt height, UInt stride)
void finalize(unsigned char digest[MD5_DIGEST_STRING_LENGTH])
std::string hashToString(const TComPictureHash &digest, Int numChar)
UInt calcCRC(const TComPicYuv &pic, TComPictureHash &digest, const BitDepths &bitDepths)