diff --git a/Base/include/Image.h b/Base/include/Image.h index 0d93ef6..ddd0428 100644 --- a/Base/include/Image.h +++ b/Base/include/Image.h @@ -95,10 +95,7 @@ namespace FasTC { } bool GetBlockStreamOrder() const { return m_bBlockStreamOrder; } - template - double ComputePSNR(Image *other) { - return FasTC::ComputePSNR(this, other); - } + double ComputePSNR(Image *other); // Function to allow derived classes to populate the pixel array. // This may involve decompressing a compressed image or otherwise diff --git a/Base/src/Image.cpp b/Base/src/Image.cpp index 43b21cd..1e8561c 100644 --- a/Base/src/Image.cpp +++ b/Base/src/Image.cpp @@ -166,28 +166,28 @@ const PixelType & Image::operator()(uint32 i, uint32 j) const { return m_Pixels[j * GetWidth() + i]; } -template -double ComputePSNR(Image *img1, Image *img2) { - if(!img1 || !img2) +template +double Image::ComputePSNR(Image *other) { + if(!other) return -1.0; - if(img1->GetWidth() != img2->GetWidth() || - img1->GetHeight() != img2->GetHeight()) { + if(GetWidth() != other->GetWidth() || + GetHeight() != other->GetHeight()) { return -1.0; } // Compute raw 8-bit RGBA data... - img1->ComputePixels(); - img2->ComputePixels(); + ComputePixels(); + other->ComputePixels(); - const PixelTypeOne *ourPixels = img1->GetPixels(); - const PixelTypeTwo *otherPixels = img2->GetPixels(); + const PixelType *ourPixels = GetPixels(); + const PixelType *otherPixels = other->GetPixels(); // const double w[3] = { 0.2126, 0.7152, 0.0722 }; const double w[3] = { 1.0, 1.0, 1.0 }; double mse = 0.0; - const uint32 imageSz = img1->GetNumPixels(); + const uint32 imageSz = GetNumPixels(); for(uint32 i = 0; i < imageSz; i++) { uint32 ourPixel = ourPixels[i].Pack(); @@ -211,15 +211,13 @@ double ComputePSNR(Image *img1, Image *img2) { } } - mse /= img1->GetWidth() * img1->GetHeight(); + mse /= GetWidth() * GetHeight(); const double C = 255.0 * 255.0; double maxi = (w[0]*w[0] + w[1]*w[1] + w[2]*w[2]) * C; return 10 * log10(maxi/mse); } -template double ComputePSNR(Image *, Image *); - // !FIXME! These won't work for non-RGBA8 data. template void Image::ConvertToBlockStreamOrder() {