mirror of
https://github.com/microsoft/DirectXTex
synced 2025-01-14 19:40:18 +00:00
DirectxTex: ComputeMSE flags for X2 bias
This commit is contained in:
parent
8bfc1b7de3
commit
d062ae2097
@ -549,6 +549,10 @@ namespace DirectX
|
||||
CMSE_IGNORE_BLUE = 0x40,
|
||||
CMSE_IGNORE_ALPHA = 0x80,
|
||||
// Ignore the channel when computing MSE
|
||||
|
||||
CMSE_IMAGE1_X2_BIAS = 0x100,
|
||||
CMSE_IMAGE2_X2_BIAS = 0x200,
|
||||
// Indicates that image should be scaled and biased before comparison (i.e. UNORM -> SNORM)
|
||||
};
|
||||
|
||||
HRESULT ComputeMSE( _In_ const Image& image1, _In_ const Image& image2, _Out_ float& mse, _Out_writes_opt_(4) float* mseV, _In_ DWORD flags = 0 );
|
||||
|
@ -84,6 +84,7 @@ static HRESULT _ComputeMSE( _In_ const Image& image1, _In_ const Image& image2,
|
||||
const size_t rowPitch2 = image2.rowPitch;
|
||||
|
||||
XMVECTOR acc = g_XMZero;
|
||||
static XMVECTORF32 two = { 2.0f, 2.0f, 2.0f, 2.0f };
|
||||
|
||||
for( size_t h = 0; h < image1.height; ++h )
|
||||
{
|
||||
@ -102,12 +103,20 @@ static HRESULT _ComputeMSE( _In_ const Image& image1, _In_ const Image& image2,
|
||||
{
|
||||
v1 = XMVectorPow( v1, g_Gamma22 );
|
||||
}
|
||||
if ( flags & CMSE_IMAGE1_X2_BIAS )
|
||||
{
|
||||
v1 = XMVectorMultiplyAdd( v1, two, g_XMNegativeOne );
|
||||
}
|
||||
|
||||
XMVECTOR v2 = *(ptr2++);
|
||||
if ( flags & CMSE_IMAGE2_SRGB )
|
||||
{
|
||||
v2 = XMVectorPow( v2, g_Gamma22 );
|
||||
}
|
||||
if ( flags & CMSE_IMAGE2_X2_BIAS )
|
||||
{
|
||||
v1 = XMVectorMultiplyAdd( v2, two, g_XMNegativeOne );
|
||||
}
|
||||
|
||||
// sum[ (I1 - I2)^2 ]
|
||||
XMVECTOR v = XMVectorSubtract( v1, v2 );
|
||||
|
Loading…
Reference in New Issue
Block a user