Skip to content
Snippets Groups Projects
Commit 7bb3a8ae authored by Frank Bossen's avatar Frank Bossen
Browse files

Write MD5 and size of cropped picture into output log file

parent 0fc71163
No related branches found
No related tags found
No related merge requests found
......@@ -337,12 +337,22 @@ void DecApp::writeLineToOutputLog(Picture * pcPic)
{
if (m_oplFileStream.is_open() && m_oplFileStream.good())
{
const SPS* sps = pcPic->cs->sps;
PictureHash recon_digest;
auto numChar = calcMD5(((const Picture*)pcPic)->getRecoBuf(), recon_digest, sps->getBitDepths());
m_oplFileStream << std::setw(8) << pcPic->getPOC() << "," << std::setw(5) << pcPic->Y().width << "," << std::setw(5) << pcPic->Y().height << "," << hashToString(recon_digest, numChar) << "\n";
const SPS * sps = pcPic->cs->sps;
ChromaFormat chromaFormatIDC = sps->getChromaFormatIdc();
const Window &conf = pcPic->getConformanceWindow();
const int leftOffset = conf.getWindowLeftOffset() * SPS::getWinUnitX(chromaFormatIDC);
const int rightOffset = conf.getWindowRightOffset() * SPS::getWinUnitX(chromaFormatIDC);
const int topOffset = conf.getWindowTopOffset() * SPS::getWinUnitY(chromaFormatIDC);
const int bottomOffset = conf.getWindowBottomOffset() * SPS::getWinUnitY(chromaFormatIDC);
PictureHash recon_digest;
auto numChar = calcMD5WithCropping(((const Picture *) pcPic)->getRecoBuf(), recon_digest, sps->getBitDepths(),
leftOffset, rightOffset, topOffset, bottomOffset);
const int croppedWidth = pcPic->Y().width - leftOffset - rightOffset;
const int croppedHeight = pcPic->Y().height - topOffset - bottomOffset;
m_oplFileStream << std::setw(8) << pcPic->getPOC() << "," << std::setw(5) << croppedWidth << "," << std::setw(5)
<< croppedHeight << "," << hashToString(recon_digest, numChar) << "\n";
}
}
......
......@@ -186,6 +186,12 @@ uint32_t calcChecksum(const CPelUnitBuf& pic, PictureHash &digest, const BitDept
* uses little-endian two byte words; 8bit data uses single byte words.
*/
uint32_t calcMD5(const CPelUnitBuf& pic, PictureHash &digest, const BitDepths &bitDepths)
{
return calcMD5WithCropping(pic, digest, bitDepths, 0, 0, 0, 0);
}
uint32_t calcMD5WithCropping(const CPelUnitBuf &pic, PictureHash &digest, const BitDepths &bitDepths,
const int leftOffset, const int rightOffset, const int topOffset, const int bottomOffset)
{
/* choose an md5_plane packing function based on the system bitdepth */
typedef void (*MD5PlaneFunc)(MD5&, const Pel*, uint32_t, uint32_t, uint32_t);
......@@ -197,17 +203,26 @@ uint32_t calcMD5(const CPelUnitBuf& pic, PictureHash &digest, const BitDepths &b
for (uint32_t chan = 0; chan< (uint32_t)pic.bufs.size(); chan++)
{
const ComponentID compID=ComponentID(chan);
const CPelBuf area = pic.get(compID);
const ComponentID compID = ComponentID(chan);
const CPelBuf area = pic.get(compID);
const int chromaScaleX = getComponentScaleX(compID, pic.chromaFormat);
const int chromaScaleY = getComponentScaleY(compID, pic.chromaFormat);
const int compLeftOffset = leftOffset >> chromaScaleX;
const int compRightOffset = rightOffset >> chromaScaleX;
const int compTopOffset = topOffset >> chromaScaleY;
const int compBottomOffset = bottomOffset >> chromaScaleY;
md5_plane_func = bitDepths.recon[toChannelType(compID)] <= 8 ? (MD5PlaneFunc)md5_plane<1> : (MD5PlaneFunc)md5_plane<2>;
uint8_t tmp_digest[MD5_DIGEST_STRING_LENGTH];
md5_plane_func(md5[compID], area.bufAt(0, 0), area.width, area.height, area.stride );
md5_plane_func(md5[compID], area.bufAt(compLeftOffset, compTopOffset),
area.width - compRightOffset - compLeftOffset, area.height - compTopOffset - compBottomOffset,
area.stride);
md5[compID].finalize(tmp_digest);
for(uint32_t i=0; i<MD5_DIGEST_STRING_LENGTH; i++)
for (uint32_t i = 0; i < MD5_DIGEST_STRING_LENGTH; i++)
{
digest.hash.push_back(tmp_digest[i]);
}
}
return 16;
}
......
......@@ -353,6 +353,9 @@ public:
int calcAndPrintHashStatus(const CPelUnitBuf& pic, const class SEIDecodedPictureHash* pictureHashSEI, const BitDepths &bitDepths, const MsgLevel msgl);
uint32_t calcMD5(const CPelUnitBuf& pic, PictureHash &digest, const BitDepths &bitDepths);
uint32_t calcMD5WithCropping(const CPelUnitBuf &pic, PictureHash &digest, const BitDepths &bitDepths,
const int leftOffset, const int rightOffset, const int topOffset, const int bottomOffset);
std::string hashToString(const PictureHash &digest, int numChar);
typedef std::list<Picture*> PicList;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment