windowscodecs/tests: Add more RGB images for DDS tests.

Signed-off-by: Ziqing Hui <zhui@codeweavers.com>
Signed-off-by: Esme Povirk <esme@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ziqing Hui 2020-07-18 11:14:22 +08:00 committed by Alexandre Julliard
parent a9151e2e2b
commit c801bde2f0
1 changed files with 92 additions and 44 deletions

View File

@ -24,20 +24,7 @@
#include "wincodec.h" #include "wincodec.h"
#include "wine/test.h" #include "wine/test.h"
/* 4x4 compressed(DXT1) DDS image */ /* 4x4 uncompressed(16bpp BGR565) DDS image */
static BYTE test_dds_image[] = {
'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 'D', 'X', 'T', '1', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7
};
/* 4x4 uncompressed(BGR565) DDS image */
static BYTE test_dds_bgr565[] = { static BYTE test_dds_bgr565[] = {
'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00, 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -51,18 +38,56 @@ static BYTE test_dds_bgr565[] = {
0x4C, 0x7B, 0x4C, 0x7B, 0x4C, 0x7B, 0xB1, 0x95, 0x4C, 0x7B, 0x08, 0x69, 0x08, 0x69, 0x4C, 0x7B 0x4C, 0x7B, 0x4C, 0x7B, 0x4C, 0x7B, 0xB1, 0x95, 0x4C, 0x7B, 0x08, 0x69, 0x08, 0x69, 0x4C, 0x7B
}; };
/* 4x4 compressed(DXT1) DDS image with mip maps, mipMapCount=3 */ /* 1x1 uncompressed(24bpp RGB) DDS image */
static BYTE test_dds_mipmaps[] = { static BYTE test_dds_24bpp[] = {
'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x0A, 0x00, 0x04, 0x00, 0x00, 0x00, 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00,
0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x70, 0x81, 0x83
};
/* 1x1 uncompressed(32bpp XRGB) DDS image */
static BYTE test_dds_32bpp_xrgb[] = {
'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00,
0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x70, 0x81, 0x83, 0x00
};
/* 1x1 uncompressed(32bpp ARGB) DDS image */
static BYTE test_dds_32bpp_argb[] = {
'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00,
0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x70, 0x81, 0x83, 0xFF
};
/* 4x4 compressed(DXT1) DDS image */
static BYTE test_dds_dxt1[] = {
'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 'D', 'X', 'T', '1', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 'D', 'X', 'T', '1', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7, 0xB1, 0x95, 0x6D, 0x7B, 0xFC, 0x55, 0x5D, 0x5D, 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7
0x2E, 0x8C, 0x4E, 0x7C, 0xAA, 0xAB, 0xAB, 0xAB
}; };
/* 4x4 compressed(DXT1) cube map */ /* 4x4 compressed(DXT1) cube map */
@ -86,6 +111,20 @@ static BYTE test_dds_cube[] = {
0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00 0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00
}; };
/* 4x4 compressed(DXT1) DDS image with mip maps, mipMapCount=3 */
static BYTE test_dds_mipmaps[] = {
'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x0A, 0x00, 0x04, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 'D', 'X', 'T', '1', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x40, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7, 0xB1, 0x95, 0x6D, 0x7B, 0xFC, 0x55, 0x5D, 0x5D,
0x2E, 0x8C, 0x4E, 0x7C, 0xAA, 0xAB, 0xAB, 0xAB
};
/* 4x4 compressed(DXT1) volume texture, depth=4, mipMapCount=3 */ /* 4x4 compressed(DXT1) volume texture, depth=4, mipMapCount=3 */
static BYTE test_dds_volume[] = { static BYTE test_dds_volume[] = {
'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x8A, 0x00, 0x04, 0x00, 0x00, 0x00, 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x8A, 0x00, 0x04, 0x00, 0x00, 0x00,
@ -173,18 +212,24 @@ static struct test_data {
WICDdsParameters expected_parameters; WICDdsParameters expected_parameters;
BOOL wine_init; BOOL wine_init;
} test_data[] = { } test_data[] = {
{ test_dds_bgr565, sizeof(test_dds_bgr565), 1, 2, &GUID_WICPixelFormat32bppBGRA, { test_dds_bgr565, sizeof(test_dds_bgr565), 1, 2, &GUID_WICPixelFormat32bppBGRA,
{ 4, 4, 1, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, WICDdsTexture2D, WICDdsAlphaModeUnknown }, TRUE }, { 4, 4, 1, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, WICDdsTexture2D, WICDdsAlphaModeUnknown }, TRUE },
{ test_dds_image, sizeof(test_dds_image), 1, 8, &GUID_WICPixelFormat32bppPBGRA, { test_dds_24bpp, sizeof(test_dds_24bpp), 1, 3, &GUID_WICPixelFormat32bppBGRA,
{ 4, 4, 1, 1, 1, DXGI_FORMAT_BC1_UNORM, WICDdsTexture2D, WICDdsAlphaModePremultiplied } }, { 1, 1, 1, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, WICDdsTexture2D, WICDdsAlphaModeUnknown }, TRUE },
{ test_dds_mipmaps, sizeof(test_dds_mipmaps), 3, 8, &GUID_WICPixelFormat32bppPBGRA, { test_dds_32bpp_xrgb, sizeof(test_dds_32bpp_xrgb), 1, 4, &GUID_WICPixelFormat32bppBGRA,
{ 4, 4, 1, 3, 1, DXGI_FORMAT_BC1_UNORM, WICDdsTexture2D, WICDdsAlphaModePremultiplied } }, { 1, 1, 1, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, WICDdsTexture2D, WICDdsAlphaModeUnknown }, TRUE },
{ test_dds_volume, sizeof(test_dds_volume), 7, 8, &GUID_WICPixelFormat32bppPBGRA, { test_dds_32bpp_argb, sizeof(test_dds_32bpp_argb), 1, 4, &GUID_WICPixelFormat32bppBGRA,
{ 4, 4, 4, 3, 1, DXGI_FORMAT_BC1_UNORM, WICDdsTexture3D, WICDdsAlphaModePremultiplied } }, { 1, 1, 1, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, WICDdsTexture2D, WICDdsAlphaModeUnknown }, TRUE },
{ test_dds_array, sizeof(test_dds_array), 9, 8, &GUID_WICPixelFormat32bppBGRA, { test_dds_dxt1, sizeof(test_dds_dxt1), 1, 8, &GUID_WICPixelFormat32bppPBGRA,
{ 4, 4, 1, 3, 3, DXGI_FORMAT_BC1_UNORM, WICDdsTexture2D, WICDdsAlphaModeUnknown } }, { 4, 4, 1, 1, 1, DXGI_FORMAT_BC1_UNORM, WICDdsTexture2D, WICDdsAlphaModePremultiplied } },
{ test_dds_dxt3, sizeof(test_dds_dxt3), 8, 16, &GUID_WICPixelFormat32bppBGRA, { test_dds_mipmaps, sizeof(test_dds_mipmaps), 3, 8, &GUID_WICPixelFormat32bppPBGRA,
{ 12, 12, 1, 4, 2, DXGI_FORMAT_BC2_UNORM, WICDdsTexture2D, WICDdsAlphaModeUnknown } }, { 4, 4, 1, 3, 1, DXGI_FORMAT_BC1_UNORM, WICDdsTexture2D, WICDdsAlphaModePremultiplied } },
{ test_dds_volume, sizeof(test_dds_volume), 7, 8, &GUID_WICPixelFormat32bppPBGRA,
{ 4, 4, 4, 3, 1, DXGI_FORMAT_BC1_UNORM, WICDdsTexture3D, WICDdsAlphaModePremultiplied } },
{ test_dds_array, sizeof(test_dds_array), 9, 8, &GUID_WICPixelFormat32bppBGRA,
{ 4, 4, 1, 3, 3, DXGI_FORMAT_BC1_UNORM, WICDdsTexture2D, WICDdsAlphaModeUnknown } },
{ test_dds_dxt3, sizeof(test_dds_dxt3), 8, 16, &GUID_WICPixelFormat32bppBGRA,
{ 12, 12, 1, 4, 2, DXGI_FORMAT_BC2_UNORM, WICDdsTexture2D, WICDdsAlphaModeUnknown } }
}; };
static IWICImagingFactory *factory = NULL; static IWICImagingFactory *factory = NULL;
@ -271,8 +316,8 @@ static BOOL has_extended_header(const BYTE *data)
static void test_dds_decoder_initialize(void) static void test_dds_decoder_initialize(void)
{ {
static BYTE test_dds_bad_magic[sizeof(test_dds_image)]; static BYTE test_dds_bad_magic[sizeof(test_dds_dxt1)];
static BYTE test_dds_bad_header[sizeof(test_dds_image)]; static BYTE test_dds_bad_header[sizeof(test_dds_dxt1)];
static BYTE byte = 0; static BYTE byte = 0;
static DWORD dword = 0; static DWORD dword = 0;
static BYTE qword1[8] = { 0 }; static BYTE qword1[8] = { 0 };
@ -284,13 +329,16 @@ static void test_dds_decoder_initialize(void)
HRESULT expected; HRESULT expected;
BOOL wine_init; BOOL wine_init;
} test_data[] = { } test_data[] = {
{ test_dds_image, sizeof(test_dds_image), S_OK }, { test_dds_dxt1 , sizeof(test_dds_dxt1), S_OK },
{ test_dds_mipmaps, sizeof(test_dds_mipmaps), S_OK }, { test_dds_mipmaps, sizeof(test_dds_mipmaps), S_OK },
{ test_dds_volume, sizeof(test_dds_volume), S_OK }, { test_dds_volume, sizeof(test_dds_volume), S_OK },
{ test_dds_array, sizeof(test_dds_array), S_OK }, { test_dds_array, sizeof(test_dds_array), S_OK },
{ test_dds_dxt3, sizeof(test_dds_dxt3), S_OK }, { test_dds_dxt3, sizeof(test_dds_dxt3), S_OK },
{ test_dds_bgr565, sizeof(test_dds_bgr565), WINCODEC_ERR_BADHEADER, TRUE }, { test_dds_bgr565, sizeof(test_dds_bgr565), WINCODEC_ERR_BADHEADER, TRUE },
{ test_dds_cube, sizeof(test_dds_cube), WINCODEC_ERR_BADHEADER, TRUE }, { test_dds_24bpp, sizeof(test_dds_24bpp), WINCODEC_ERR_BADHEADER, TRUE },
{ test_dds_32bpp_xrgb, sizeof(test_dds_32bpp_xrgb), WINCODEC_ERR_BADHEADER, TRUE },
{ test_dds_32bpp_argb, sizeof(test_dds_32bpp_argb), WINCODEC_ERR_BADHEADER, TRUE },
{ test_dds_cube, sizeof(test_dds_cube), WINCODEC_ERR_BADHEADER, TRUE },
{ test_dds_bad_magic, sizeof(test_dds_bad_magic), WINCODEC_ERR_UNKNOWNIMAGEFORMAT }, { test_dds_bad_magic, sizeof(test_dds_bad_magic), WINCODEC_ERR_UNKNOWNIMAGEFORMAT },
{ test_dds_bad_header, sizeof(test_dds_bad_header), WINCODEC_ERR_BADHEADER }, { test_dds_bad_header, sizeof(test_dds_bad_header), WINCODEC_ERR_BADHEADER },
{ &byte, sizeof(byte), WINCODEC_ERR_STREAMREAD }, { &byte, sizeof(byte), WINCODEC_ERR_STREAMREAD },
@ -301,8 +349,8 @@ static void test_dds_decoder_initialize(void)
int i; int i;
memcpy(test_dds_bad_magic, test_dds_image, sizeof(test_dds_image)); memcpy(test_dds_bad_magic, test_dds_dxt1, sizeof(test_dds_dxt1));
memcpy(test_dds_bad_header, test_dds_image, sizeof(test_dds_image)); memcpy(test_dds_bad_header, test_dds_dxt1, sizeof(test_dds_dxt1));
test_dds_bad_magic[0] = 0; test_dds_bad_magic[0] = 0;
test_dds_bad_header[4] = 0; test_dds_bad_header[4] = 0;