2 * Copyright 2020 Ziqing Hui
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/test.h"
27 /* 1x1 uncompressed(Alpha) DDS image */
28 static BYTE test_dds_alpha
[] = {
29 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00,
30 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
34 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
36 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40 /* 1x1 uncompressed(Luminance) DDS image */
41 static BYTE test_dds_luminance
[] = {
42 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00,
43 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
47 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
48 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
49 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53 /* 4x4 uncompressed(16bpp RGB565) DDS image */
54 static BYTE test_dds_rgb565
[] = {
55 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00,
56 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
60 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00,
61 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
62 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
63 0xF5, 0xA7, 0x08, 0x69, 0x4C, 0x7B, 0x08, 0x69, 0xF5, 0xA7, 0xF5, 0xA7, 0xF5, 0xA7, 0x4C, 0x7B,
64 0x4C, 0x7B, 0x4C, 0x7B, 0x4C, 0x7B, 0xB1, 0x95, 0x4C, 0x7B, 0x08, 0x69, 0x08, 0x69, 0x4C, 0x7B
67 /* 1x1 uncompressed(24bpp RGB) DDS image */
68 static BYTE test_dds_24bpp
[] = {
69 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00,
70 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
71 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
72 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
73 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
74 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00,
75 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
76 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
80 /* 1x1 uncompressed(32bpp XRGB) DDS image */
81 static BYTE test_dds_32bpp_xrgb
[] = {
82 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00,
83 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
84 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
85 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
86 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
87 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00,
88 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
89 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
90 0x70, 0x81, 0x83, 0x00
93 /* 1x1 uncompressed(32bpp ARGB) DDS image */
94 static BYTE test_dds_32bpp_argb
[] = {
95 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00,
96 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
97 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
98 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
99 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
100 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00,
101 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x10, 0x00, 0x00,
102 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
103 0x70, 0x81, 0x83, 0xFF
106 /* 1x1 uncompressed(64bpp ABGR) DDS image */
107 static BYTE test_dds_64bpp
[] = {
108 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x0F, 0x10, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00,
109 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
110 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
111 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
112 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
113 0x04, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
114 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
115 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
116 0x83, 0x83, 0x81, 0x81, 0x70, 0x70, 0xFF, 0xFF
119 /* 1x1 uncompressed(96bpp ABGR float) DDS image */
120 static BYTE test_dds_96bpp
[] = {
121 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x0F, 0x10, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00,
122 0x01, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
123 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
124 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
125 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
126 0x04, 0x00, 0x00, 0x00, 'D', 'X', '1', '0', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
127 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
128 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
129 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
130 0x00, 0x00, 0x00, 0x00, 0x84, 0x83, 0x03, 0x3F, 0x82, 0x81, 0x01, 0x3F, 0xE2, 0xE0, 0xE0, 0x3E
133 /* 1x1 uncompressed(128bpp ABGR float) DDS image */
134 static BYTE test_dds_128bpp
[] = {
135 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x0F, 0x10, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00,
136 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
137 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
138 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
139 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
140 0x04, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
141 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
142 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
143 0x84, 0x83, 0x03, 0x3F, 0x82, 0x81, 0x01, 0x3F, 0xE2, 0xE0, 0xE0, 0x3E, 0x00, 0x00, 0x80, 0x3F
146 /* 4x4 compressed(DXT1) DDS image */
147 static BYTE test_dds_dxt1
[] = {
148 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00,
149 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
150 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
151 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
152 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
153 0x04, 0x00, 0x00, 0x00, 'D', 'X', 'T', '1', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
154 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
155 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
156 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7
159 /* 4x4 compressed(DXT1) cube map, mipMapCount = 3 */
160 static BYTE test_dds_cube
[] = {
161 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x0A, 0x00, 0x04, 0x00, 0x00, 0x00,
162 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
163 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
164 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
165 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
166 0x04, 0x00, 0x00, 0x00, 'D', 'X', 'T', '1', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
167 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x40, 0x00,
168 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
169 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55,
170 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7,
171 0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00,
172 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55,
173 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7,
174 0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00,
175 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55,
176 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7,
177 0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00
180 /* 4x4 compressed(DXT1) cube map with extended header, mipMapCount=3 */
181 static BYTE test_dds_cube_dx10
[] = {
182 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x0A, 0x00, 0x04, 0x00, 0x00, 0x00,
183 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
184 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
185 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
186 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
187 0x04, 0x00, 0x00, 0x00, 'D', 'X', '1', '0', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
188 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x40, 0x00,
189 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
190 0x47, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
191 0x03, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B,
192 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69,
193 0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84,
194 0x00, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B,
195 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69,
196 0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84,
197 0x00, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B,
198 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69,
199 0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84,
200 0x00, 0x00, 0x00, 0x00
203 /* 4x4 compressed(DXT1) DDS image with mip maps, mipMapCount=3 */
204 static BYTE test_dds_mipmaps
[] = {
205 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x0A, 0x00, 0x04, 0x00, 0x00, 0x00,
206 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
210 0x04, 0x00, 0x00, 0x00, 'D', 'X', 'T', '1', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
211 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x40, 0x00,
212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
213 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7, 0xB1, 0x95, 0x6D, 0x7B, 0xFC, 0x55, 0x5D, 0x5D,
214 0x2E, 0x8C, 0x4E, 0x7C, 0xAA, 0xAB, 0xAB, 0xAB
217 /* 4x4 compressed(DXT1) volume texture, depth=4, mipMapCount=3 */
218 static BYTE test_dds_volume
[] = {
219 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x8A, 0x00, 0x04, 0x00, 0x00, 0x00,
220 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
221 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
222 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
223 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
224 0x04, 0x00, 0x00, 0x00, 'D', 'X', 'T', '1', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
225 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x40, 0x00,
226 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
227 0xD5, 0xA7, 0x2C, 0x7B, 0xE0, 0x00, 0x55, 0x55, 0xD5, 0xA7, 0x49, 0x69, 0x57, 0x00, 0xFF, 0x55,
228 0xD5, 0xA7, 0x48, 0x69, 0xFD, 0x80, 0xFF, 0x55, 0x30, 0x8D, 0x89, 0x71, 0x55, 0xA8, 0x00, 0xFF,
229 0x32, 0x96, 0x6D, 0x83, 0xA8, 0x55, 0x5D, 0x5D, 0x0E, 0x84, 0x6D, 0x7B, 0xA8, 0xA9, 0xAD, 0xAD,
230 0x2E, 0x8C, 0x2E, 0x7C, 0xAA, 0xAB, 0xAB, 0xAB
233 /* 4x4 compressed(DXT1) texture array, arraySize=3, mipMapCount=3 */
234 static BYTE test_dds_array
[] = {
235 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x0A, 0x00, 0x04, 0x00, 0x00, 0x00,
236 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
237 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
238 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
239 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
240 0x04, 0x00, 0x00, 0x00, 'D', 'X', '1', '0', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
241 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x40, 0x00,
242 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
243 0x47, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
244 0x00, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B,
245 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69,
246 0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B, 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84,
247 0x00, 0x00, 0x00, 0x00, 0xF5, 0xA7, 0x08, 0x69, 0x74, 0xC0, 0xBF, 0xD7, 0x32, 0x96, 0x0B, 0x7B,
248 0xCC, 0x55, 0xCC, 0x55, 0x0E, 0x84, 0x0E, 0x84, 0x00, 0x00, 0x00, 0x00
251 /* 12x12 compressed(DXT3) texture array, arraySize=2, mipMapCount=4 */
252 static BYTE test_dds_dxt3
[] = {
253 'D', 'D', 'S', ' ', 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x0A, 0x00, 0x0C, 0x00, 0x00, 0x00,
254 0x0C, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
255 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
256 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
257 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
258 0x04, 0x00, 0x00, 0x00, 'D', 'X', '1', '0', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
259 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x40, 0x00,
260 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
261 0x4A, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
262 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB5, 0xA7, 0xAD, 0x83,
263 0x60, 0x60, 0xE0, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x12, 0x96, 0x6B, 0x72,
264 0xD5, 0xD5, 0xAF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x8D, 0x89, 0x69,
265 0x57, 0x5F, 0x5E, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB4, 0xA7, 0xAD, 0x83,
266 0x00, 0xAA, 0xFF, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0x9E, 0x6D, 0x83,
267 0x00, 0x00, 0xAA, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x12, 0x96, 0xCD, 0x83,
268 0x5C, 0xF8, 0xAA, 0xAF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEC, 0x7A, 0xC9, 0x71,
269 0x80, 0x60, 0x60, 0x60, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x4A, 0x72, 0xA8, 0x68,
270 0x28, 0xBE, 0xD7, 0xD7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xAF, 0x8C, 0xEA, 0x71,
271 0x0B, 0xAB, 0xAD, 0xBD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x54, 0x9F, 0xCC, 0x7A,
272 0x5C, 0xA8, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x8D, 0x49, 0x69,
273 0x77, 0xEE, 0x88, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0C, 0x7B, 0x08, 0x69,
274 0xF8, 0x58, 0xF8, 0x58, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x4E, 0x84, 0x6B, 0x72,
275 0x33, 0x99, 0x33, 0x99, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x14, 0x9F, 0x0A, 0x72,
276 0xDC, 0xAA, 0x75, 0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0E, 0x84, 0x0E, 0x84,
277 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB5, 0xA7, 0xAD, 0x83,
278 0x60, 0x60, 0xE0, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x12, 0x96, 0x6B, 0x72,
279 0xD5, 0xD5, 0xAF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x8D, 0x89, 0x69,
280 0x57, 0x5F, 0x5E, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB4, 0xA7, 0xAD, 0x83,
281 0x00, 0xAA, 0xFF, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF3, 0x9E, 0x6D, 0x83,
282 0x00, 0x00, 0xAA, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x12, 0x96, 0xCD, 0x83,
283 0x5C, 0xF8, 0xAA, 0xAF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEC, 0x7A, 0xC9, 0x71,
284 0x80, 0x60, 0x60, 0x60, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x4A, 0x72, 0xA8, 0x68,
285 0x28, 0xBE, 0xD7, 0xD7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xAF, 0x8C, 0xEA, 0x71,
286 0x0B, 0xAB, 0xAD, 0xBD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x54, 0x9F, 0xCC, 0x7A,
287 0x5C, 0xA8, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x8D, 0x49, 0x69,
288 0x77, 0xEE, 0x88, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0C, 0x7B, 0x08, 0x69,
289 0xF8, 0x58, 0xF8, 0x58, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x4E, 0x84, 0x6B, 0x72,
290 0x33, 0x99, 0x33, 0x99, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x14, 0x9F, 0x0A, 0x72,
291 0xDC, 0xAA, 0x75, 0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0E, 0x84, 0x0E, 0x84,
292 0x00, 0x00, 0x00, 0x00
295 static BYTE test_dds_bad_magic
[sizeof(test_dds_dxt1
)];
296 static BYTE test_dds_bad_header
[sizeof(test_dds_dxt1
)];
297 static BYTE test_byte
[1] = { 0 };
298 static BYTE test_word
[2] = { 0 };
299 static BYTE test_dword
[4] = { 0 };
300 static BYTE test_qword_a
[8] = { 0 };
301 static BYTE test_qword_b
[8] = "DDS ";
303 static struct test_data
{
307 UINT expected_frame_count
;
308 UINT expected_bytes_per_block
;
309 const GUID
*expected_pixel_format
;
310 WICDdsParameters expected_parameters
;
313 { test_dds_alpha
, sizeof(test_dds_alpha
), WINCODEC_ERR_BADHEADER
, 1, 1, &GUID_WICPixelFormat32bppBGRA
,
314 { 1, 1, 1, 1, 1, DXGI_FORMAT_A8_UNORM
, WICDdsTexture2D
, WICDdsAlphaModeUnknown
}, TRUE
},
315 { test_dds_luminance
, sizeof(test_dds_luminance
), WINCODEC_ERR_BADHEADER
, 1, 1, &GUID_WICPixelFormat32bppBGRA
,
316 { 1, 1, 1, 1, 1, DXGI_FORMAT_R8_UNORM
, WICDdsTexture2D
, WICDdsAlphaModeUnknown
}, TRUE
},
317 { test_dds_rgb565
, sizeof(test_dds_rgb565
), WINCODEC_ERR_BADHEADER
, 1, 2, &GUID_WICPixelFormat32bppBGRA
,
318 { 4, 4, 1, 1, 1, DXGI_FORMAT_B5G6R5_UNORM
, WICDdsTexture2D
, WICDdsAlphaModeUnknown
}, TRUE
},
319 { test_dds_24bpp
, sizeof(test_dds_24bpp
), WINCODEC_ERR_BADHEADER
, 1, 3, &GUID_WICPixelFormat32bppBGRA
,
320 { 1, 1, 1, 1, 1, DXGI_FORMAT_UNKNOWN
, WICDdsTexture2D
, WICDdsAlphaModeUnknown
}, TRUE
},
321 { test_dds_32bpp_xrgb
, sizeof(test_dds_32bpp_xrgb
), WINCODEC_ERR_BADHEADER
, 1, 4, &GUID_WICPixelFormat32bppBGRA
,
322 { 1, 1, 1, 1, 1, DXGI_FORMAT_B8G8R8X8_UNORM
, WICDdsTexture2D
, WICDdsAlphaModeUnknown
}, TRUE
},
323 { test_dds_32bpp_argb
, sizeof(test_dds_32bpp_argb
), WINCODEC_ERR_BADHEADER
, 1, 4, &GUID_WICPixelFormat32bppBGRA
,
324 { 1, 1, 1, 1, 1, DXGI_FORMAT_B8G8R8A8_UNORM
, WICDdsTexture2D
, WICDdsAlphaModeUnknown
}, TRUE
},
325 { test_dds_64bpp
, sizeof(test_dds_64bpp
), WINCODEC_ERR_BADHEADER
, 1, 8, &GUID_WICPixelFormat32bppBGRA
,
326 { 1, 1, 1, 1, 1, DXGI_FORMAT_R16G16B16A16_UNORM
, WICDdsTexture2D
, WICDdsAlphaModeUnknown
}, TRUE
},
327 { test_dds_96bpp
, sizeof(test_dds_96bpp
), WINCODEC_ERR_BADHEADER
, 1, 12, &GUID_WICPixelFormat32bppBGRA
,
328 { 1, 1, 1, 1, 1, DXGI_FORMAT_R32G32B32_FLOAT
, WICDdsTexture2D
, WICDdsAlphaModeUnknown
}, TRUE
},
329 { test_dds_128bpp
, sizeof(test_dds_128bpp
), WINCODEC_ERR_BADHEADER
, 1, 16, &GUID_WICPixelFormat32bppBGRA
,
330 { 1, 1, 1, 1, 1, DXGI_FORMAT_R32G32B32A32_FLOAT
, WICDdsTexture2D
, WICDdsAlphaModeUnknown
}, TRUE
},
331 { test_dds_cube
, sizeof(test_dds_cube
), WINCODEC_ERR_BADHEADER
, 18, 8, &GUID_WICPixelFormat32bppPBGRA
,
332 { 4, 4, 1, 3, 1, DXGI_FORMAT_BC1_UNORM
, WICDdsTextureCube
, WICDdsAlphaModePremultiplied
}, TRUE
},
333 { test_dds_cube_dx10
, sizeof(test_dds_cube_dx10
), WINCODEC_ERR_BADHEADER
, 18, 8, &GUID_WICPixelFormat32bppBGRA
,
334 { 4, 4, 1, 3, 1, DXGI_FORMAT_BC1_UNORM
, WICDdsTextureCube
, WICDdsAlphaModeUnknown
}, TRUE
},
335 { test_dds_dxt1
, sizeof(test_dds_dxt1
), S_OK
, 1, 8, &GUID_WICPixelFormat32bppPBGRA
,
336 { 4, 4, 1, 1, 1, DXGI_FORMAT_BC1_UNORM
, WICDdsTexture2D
, WICDdsAlphaModePremultiplied
} },
337 { test_dds_mipmaps
, sizeof(test_dds_mipmaps
), S_OK
, 3, 8, &GUID_WICPixelFormat32bppPBGRA
,
338 { 4, 4, 1, 3, 1, DXGI_FORMAT_BC1_UNORM
, WICDdsTexture2D
, WICDdsAlphaModePremultiplied
} },
339 { test_dds_volume
, sizeof(test_dds_volume
), S_OK
, 7, 8, &GUID_WICPixelFormat32bppPBGRA
,
340 { 4, 4, 4, 3, 1, DXGI_FORMAT_BC1_UNORM
, WICDdsTexture3D
, WICDdsAlphaModePremultiplied
} },
341 { test_dds_array
, sizeof(test_dds_array
), S_OK
, 9, 8, &GUID_WICPixelFormat32bppBGRA
,
342 { 4, 4, 1, 3, 3, DXGI_FORMAT_BC1_UNORM
, WICDdsTexture2D
, WICDdsAlphaModeUnknown
} },
343 { test_dds_dxt3
, sizeof(test_dds_dxt3
), S_OK
, 8, 16, &GUID_WICPixelFormat32bppBGRA
,
344 { 12, 12, 1, 4, 2, DXGI_FORMAT_BC2_UNORM
, WICDdsTexture2D
, WICDdsAlphaModeUnknown
} },
345 { test_dds_bad_magic
, sizeof(test_dds_bad_magic
), WINCODEC_ERR_UNKNOWNIMAGEFORMAT
},
346 { test_dds_bad_header
, sizeof(test_dds_bad_header
), WINCODEC_ERR_BADHEADER
},
347 { test_byte
, sizeof(test_byte
), WINCODEC_ERR_STREAMREAD
},
348 { test_word
, sizeof(test_word
), WINCODEC_ERR_STREAMREAD
},
349 { test_dword
, sizeof(test_dword
), WINCODEC_ERR_UNKNOWNIMAGEFORMAT
},
350 { test_qword_a
, sizeof(test_qword_a
), WINCODEC_ERR_UNKNOWNIMAGEFORMAT
},
351 { test_qword_b
, sizeof(test_qword_b
), WINCODEC_ERR_STREAMREAD
},
354 static IWICImagingFactory
*factory
= NULL
;
356 static IWICStream
*create_stream(const void *image_data
, UINT image_size
)
359 IWICStream
*stream
= NULL
;
361 hr
= IWICImagingFactory_CreateStream(factory
, &stream
);
362 ok(hr
== S_OK
, "CreateStream failed, hr %#x\n", hr
);
363 if (hr
!= S_OK
) goto fail
;
365 hr
= IWICStream_InitializeFromMemory(stream
, (BYTE
*)image_data
, image_size
);
366 ok(hr
== S_OK
, "InitializeFromMemory failed, hr %#x\n", hr
);
367 if (hr
!= S_OK
) goto fail
;
372 if (stream
) IWICStream_Release(stream
);
376 static IWICBitmapDecoder
*create_decoder(void)
379 IWICBitmapDecoder
*decoder
= NULL
;
382 hr
= CoCreateInstance(&CLSID_WICDdsDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
383 &IID_IWICBitmapDecoder
, (void **)&decoder
);
385 win_skip("Dds decoder is not supported\n");
389 memset(&guidresult
, 0, sizeof(guidresult
));
390 hr
= IWICBitmapDecoder_GetContainerFormat(decoder
, &guidresult
);
391 ok(hr
== S_OK
, "GetContainerFormat failed, hr %#x\n", hr
);
392 ok(IsEqualGUID(&guidresult
, &GUID_ContainerFormatDds
),
393 "Got unexpected container format %s\n", debugstr_guid(&GUID_ContainerFormatDds
));
398 static HRESULT
init_decoder(IWICBitmapDecoder
*decoder
, IWICStream
*stream
, HRESULT expected
, int index
, BOOL wine_init
)
401 IWICWineDecoder
*wine_decoder
;
403 hr
= IWICBitmapDecoder_Initialize(decoder
, (IStream
*)stream
, WICDecodeMetadataCacheOnDemand
);
404 ok(hr
== expected
, "Test %u: Expected hr %#x, got %#x\n", index
, expected
, hr
);
406 if (hr
!= S_OK
&& wine_init
) {
407 hr
= IWICBitmapDecoder_QueryInterface(decoder
, &IID_IWICWineDecoder
, (void **)&wine_decoder
);
408 ok(hr
== S_OK
|| broken(hr
!= S_OK
), "Test %u: QueryInterface failed, hr %#x\n", index
, hr
);
411 hr
= IWICWineDecoder_Initialize(wine_decoder
, (IStream
*)stream
, WICDecodeMetadataCacheOnDemand
);
412 ok(hr
== S_OK
, "Test %u: Initialize failed, hr %#x\n", index
, hr
);
419 static BOOL
has_extended_header(const BYTE
*data
)
421 return data
[84] == 'D' && data
[85] == 'X' && data
[86] == '1' && data
[87] == '0';
424 static void test_dds_decoder_initialize(void)
428 memcpy(test_dds_bad_magic
, test_dds_dxt1
, sizeof(test_dds_dxt1
));
429 memcpy(test_dds_bad_header
, test_dds_dxt1
, sizeof(test_dds_dxt1
));
430 test_dds_bad_magic
[0] = 0;
431 test_dds_bad_header
[4] = 0;
433 for (i
= 0; i
< ARRAY_SIZE(test_data
); i
++)
435 IWICStream
*stream
= NULL
;
436 IWICBitmapDecoder
*decoder
= NULL
;
438 stream
= create_stream(test_data
[i
].data
, test_data
[i
].size
);
439 if (!stream
) goto next
;
441 decoder
= create_decoder();
442 if (!decoder
) goto next
;
444 init_decoder(decoder
, stream
, test_data
[i
].init_hr
, i
, test_data
[i
].wine_init
);
447 if (decoder
) IWICBitmapDecoder_Release(decoder
);
448 if (stream
) IWICStream_Release(stream
);
452 static void test_dds_decoder_global_properties(IWICBitmapDecoder
*decoder
)
455 IWICPalette
*palette
= NULL
;
456 IWICMetadataQueryReader
*metadata_reader
= NULL
;
457 IWICBitmapSource
*preview
= NULL
, *thumnail
= NULL
;
458 IWICColorContext
*color_context
= NULL
;
461 hr
= IWICImagingFactory_CreatePalette(factory
, &palette
);
462 ok(hr
== S_OK
, "CreatePalette failed, hr %#x\n", hr
);
464 hr
= IWICBitmapDecoder_CopyPalette(decoder
, palette
);
465 ok(hr
== WINCODEC_ERR_PALETTEUNAVAILABLE
, "CopyPalette got unexpected hr %#x\n", hr
);
466 hr
= IWICBitmapDecoder_CopyPalette(decoder
, NULL
);
467 ok(hr
== WINCODEC_ERR_PALETTEUNAVAILABLE
, "CopyPalette got unexpected hr %#x\n", hr
);
470 hr
= IWICBitmapDecoder_GetMetadataQueryReader(decoder
, &metadata_reader
);
471 todo_wine
ok (hr
== S_OK
, "GetMetadataQueryReader got unexpected hr %#x\n", hr
);
472 hr
= IWICBitmapDecoder_GetMetadataQueryReader(decoder
, NULL
);
473 ok(hr
== E_INVALIDARG
, "GetMetadataQueryReader got unexpected hr %#x\n", hr
);
475 hr
= IWICBitmapDecoder_GetPreview(decoder
, &preview
);
476 ok(hr
== WINCODEC_ERR_UNSUPPORTEDOPERATION
, "GetPreview got unexpected hr %#x\n", hr
);
477 hr
= IWICBitmapDecoder_GetPreview(decoder
, NULL
);
478 ok(hr
== WINCODEC_ERR_UNSUPPORTEDOPERATION
, "GetPreview got unexpected hr %#x\n", hr
);
480 hr
= IWICBitmapDecoder_GetColorContexts(decoder
, 1, &color_context
, &count
);
481 ok(hr
== WINCODEC_ERR_UNSUPPORTEDOPERATION
, "GetColorContexts got unexpected hr %#x\n", hr
);
482 hr
= IWICBitmapDecoder_GetColorContexts(decoder
, 1, NULL
, NULL
);
483 ok(hr
== WINCODEC_ERR_UNSUPPORTEDOPERATION
, "GetColorContexts got unexpected hr %#x\n", hr
);
485 hr
= IWICBitmapDecoder_GetThumbnail(decoder
, &thumnail
);
486 ok(hr
== WINCODEC_ERR_CODECNOTHUMBNAIL
, "GetThumbnail got unexpected hr %#x\n", hr
);
487 hr
= IWICBitmapDecoder_GetThumbnail(decoder
, NULL
);
488 ok(hr
== WINCODEC_ERR_CODECNOTHUMBNAIL
, "GetThumbnail got unexpected hr %#x\n", hr
);
490 if (palette
) IWICPalette_Release(palette
);
491 if (metadata_reader
) IWICMetadataQueryReader_Release(metadata_reader
);
492 if (preview
) IWICBitmapSource_Release(preview
);
493 if (color_context
) IWICColorContext_Release(color_context
);
494 if (thumnail
) IWICBitmapSource_Release(thumnail
);
497 static void test_dds_decoder_image_parameters(void)
501 WICDdsParameters parameters
;
503 for (i
= 0; i
< ARRAY_SIZE(test_data
); i
++)
506 IWICStream
*stream
= NULL
;
507 IWICBitmapDecoder
*decoder
= NULL
;
508 IWICDdsDecoder
*dds_decoder
= NULL
;
510 stream
= create_stream(test_data
[i
].data
, test_data
[i
].size
);
511 if (!stream
) goto next
;
513 decoder
= create_decoder();
514 if (!decoder
) goto next
;
516 hr
= IWICBitmapDecoder_QueryInterface(decoder
, &IID_IWICDdsDecoder
, (void **)&dds_decoder
);
517 ok(hr
== S_OK
, "QueryInterface failed, hr %#x\n", hr
);
518 if (hr
!= S_OK
) goto next
;
520 hr
= IWICBitmapDecoder_GetFrameCount(decoder
, &frame_count
);
521 ok(hr
== WINCODEC_ERR_WRONGSTATE
, "Test %u: GetFrameCount got unexpected hr %#x\n", i
, hr
);
522 hr
= IWICBitmapDecoder_GetFrameCount(decoder
, NULL
);
523 ok(hr
== E_INVALIDARG
, "Test %u: GetFrameCount got unexpected hr %#x\n", i
, hr
);
525 hr
= IWICDdsDecoder_GetParameters(dds_decoder
, ¶meters
);
526 ok(hr
== WINCODEC_ERR_WRONGSTATE
, "Test %u: GetParameters got unexpected hr %#x\n", i
, hr
);
527 hr
= IWICDdsDecoder_GetParameters(dds_decoder
, NULL
);
528 ok(hr
== E_INVALIDARG
, "Test %u: GetParameters got unexpected hr %#x\n", i
, hr
);
530 if (test_data
[i
].init_hr
!= S_OK
&& !test_data
[i
].wine_init
) continue;
532 hr
= init_decoder(decoder
, stream
, test_data
[i
].init_hr
, i
, test_data
[i
].wine_init
);
534 if (test_data
[i
].expected_parameters
.Dimension
== WICDdsTextureCube
) {
535 win_skip("Cube map is not supported\n");
537 win_skip("Uncompressed DDS image is not supported\n");
542 hr
= IWICBitmapDecoder_GetFrameCount(decoder
, &frame_count
);
543 ok(hr
== S_OK
, "Test %u: GetFrameCount failed, hr %#x\n", i
, hr
);
545 ok(frame_count
== test_data
[i
].expected_frame_count
, "Test %u: Expected frame count %u, got %u\n",
546 i
, test_data
[i
].expected_frame_count
, frame_count
);
548 hr
= IWICBitmapDecoder_GetFrameCount(decoder
, NULL
);
549 ok(hr
== E_INVALIDARG
, "Test %u: GetParameters got unexpected hr %#x\n", i
, hr
);
551 hr
= IWICDdsDecoder_GetParameters(dds_decoder
, ¶meters
);
552 ok(hr
== S_OK
, "Test %u: GetParameters failed, hr %#x\n", i
, hr
);
554 ok(parameters
.Width
== test_data
[i
].expected_parameters
.Width
,
555 "Test %u: Expected Width %u, got %u\n", i
, test_data
[i
].expected_parameters
.Width
, parameters
.Width
);
556 ok(parameters
.Height
== test_data
[i
].expected_parameters
.Height
,
557 "Test %u: Expected Height %u, got %u\n", i
, test_data
[i
].expected_parameters
.Height
, parameters
.Height
);
558 ok(parameters
.Depth
== test_data
[i
].expected_parameters
.Depth
,
559 "Test %u: Expected Depth %u, got %u\n", i
, test_data
[i
].expected_parameters
.Depth
, parameters
.Depth
);
560 ok(parameters
.MipLevels
== test_data
[i
].expected_parameters
.MipLevels
,
561 "Test %u: Expected MipLevels %u, got %u\n", i
, test_data
[i
].expected_parameters
.MipLevels
, parameters
.MipLevels
);
562 ok(parameters
.ArraySize
== test_data
[i
].expected_parameters
.ArraySize
,
563 "Test %u: Expected ArraySize %u, got %u\n", i
, test_data
[i
].expected_parameters
.ArraySize
, parameters
.ArraySize
);
564 ok(parameters
.DxgiFormat
== test_data
[i
].expected_parameters
.DxgiFormat
,
565 "Test %u: Expected DxgiFormat %#x, got %#x\n", i
, test_data
[i
].expected_parameters
.DxgiFormat
, parameters
.DxgiFormat
);
566 ok(parameters
.Dimension
== test_data
[i
].expected_parameters
.Dimension
,
567 "Test %u: Expected Dimension %#x, got %#x\n", i
, test_data
[i
].expected_parameters
.Dimension
, parameters
.Dimension
);
568 ok(parameters
.AlphaMode
== test_data
[i
].expected_parameters
.AlphaMode
,
569 "Test %u: Expected AlphaMode %#x, got %#x\n", i
, test_data
[i
].expected_parameters
.AlphaMode
, parameters
.AlphaMode
);
571 hr
= IWICDdsDecoder_GetParameters(dds_decoder
, NULL
);
572 ok(hr
== E_INVALIDARG
, "Test %u: GetParameters got unexpected hr %#x\n", i
, hr
);
575 if (decoder
) IWICBitmapDecoder_Release(decoder
);
576 if (stream
) IWICStream_Release(stream
);
577 if (dds_decoder
) IWICDdsDecoder_Release(dds_decoder
);
582 static void test_dds_decoder_frame_properties(IWICBitmapFrameDecode
*frame_decode
, IWICDdsFrameDecode
*dds_frame
,
583 UINT frame_count
, WICDdsParameters
*params
, int i
, int frame_index
)
586 UINT width
, height
,expected_width
, expected_height
, slice_index
, depth
;
587 UINT width_in_blocks
, height_in_blocks
, expected_width_in_blocks
, expected_height_in_blocks
;
588 UINT expected_block_width
, expected_block_height
;
589 WICDdsFormatInfo format_info
;
592 /* frame size tests */
594 hr
= IWICBitmapFrameDecode_GetSize(frame_decode
, NULL
, NULL
);
595 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: GetSize got unexpected hr %#x\n", i
, frame_index
, hr
);
596 hr
= IWICBitmapFrameDecode_GetSize(frame_decode
, NULL
, &height
);
597 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: GetSize got unexpected hr %#x\n", i
, frame_index
, hr
);
598 hr
= IWICBitmapFrameDecode_GetSize(frame_decode
, &width
, NULL
);
599 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: GetSize got unexpected hr %#x\n", i
, frame_index
, hr
);
600 hr
= IWICBitmapFrameDecode_GetSize(frame_decode
, &width
, &height
);
601 ok(hr
== S_OK
, "Test %u, frame %u: GetSize failed, hr %#x\n", i
, frame_index
, hr
);
602 if (hr
!= S_OK
) return;
604 depth
= params
->Depth
;
605 expected_width
= params
->Width
;
606 expected_height
= params
->Height
;
607 slice_index
= frame_index
% (frame_count
/ params
->ArraySize
);
608 while (slice_index
>= depth
)
610 if (expected_width
> 1) expected_width
/= 2;
611 if (expected_height
> 1) expected_height
/= 2;
612 slice_index
-= depth
;
613 if (depth
> 1) depth
/= 2;
615 ok(width
== expected_width
, "Test %u, frame %u: Expected width %u, got %u\n", i
, expected_width
, frame_index
, width
);
616 ok(height
== expected_height
, "Test %u, frame %u: Expected height %u, got %u\n", i
, expected_height
, frame_index
, height
);
618 /* frame format information tests */
620 if (test_data
[i
].expected_parameters
.DxgiFormat
!= DXGI_FORMAT_BC1_UNORM
&&
621 test_data
[i
].expected_parameters
.DxgiFormat
!= DXGI_FORMAT_BC2_UNORM
&&
622 test_data
[i
].expected_parameters
.DxgiFormat
!= DXGI_FORMAT_BC3_UNORM
&&
623 test_data
[i
].expected_parameters
.DxgiFormat
!= DXGI_FORMAT_BC4_UNORM
&&
624 test_data
[i
].expected_parameters
.DxgiFormat
!= DXGI_FORMAT_BC4_SNORM
&&
625 test_data
[i
].expected_parameters
.DxgiFormat
!= DXGI_FORMAT_BC5_UNORM
&&
626 test_data
[i
].expected_parameters
.DxgiFormat
!= DXGI_FORMAT_BC5_SNORM
) {
627 expected_block_width
= 1;
628 expected_block_height
= 1;
630 expected_block_width
= 4;
631 expected_block_height
= 4;
634 hr
= IWICDdsFrameDecode_GetFormatInfo(dds_frame
, NULL
);
635 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: GetFormatInfo got unexpected hr %#x\n", i
, frame_index
, hr
);
636 hr
= IWICDdsFrameDecode_GetFormatInfo(dds_frame
, &format_info
);
637 ok(hr
== S_OK
, "Test %u, frame %u: GetFormatInfo failed, hr %#x\n", i
, frame_index
, hr
);
638 if (hr
!= S_OK
) return;
640 ok(format_info
.DxgiFormat
== test_data
[i
].expected_parameters
.DxgiFormat
,
641 "Test %u, frame %u: Expected DXGI format %#x, got %#x\n",
642 i
, frame_index
, test_data
[i
].expected_parameters
.DxgiFormat
, format_info
.DxgiFormat
);
643 ok(format_info
.BytesPerBlock
== test_data
[i
].expected_bytes_per_block
,
644 "Test %u, frame %u: Expected bytes per block %u, got %u\n",
645 i
, frame_index
, test_data
[i
].expected_bytes_per_block
, format_info
.BytesPerBlock
);
646 ok(format_info
.BlockWidth
== expected_block_width
,
647 "Test %u, frame %u: Expected block width %u, got %u\n",
648 i
, frame_index
, expected_block_width
, format_info
.BlockWidth
);
649 ok(format_info
.BlockHeight
== expected_block_height
,
650 "Test %u, frame %u: Expected block height %u, got %u\n",
651 i
, frame_index
, expected_block_height
, format_info
.BlockHeight
);
654 /* size in blocks tests */
656 hr
= IWICDdsFrameDecode_GetSizeInBlocks(dds_frame
, NULL
, NULL
);
657 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: GetSizeInBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
658 hr
= IWICDdsFrameDecode_GetSizeInBlocks(dds_frame
, NULL
, &height_in_blocks
);
659 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: GetSizeInBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
660 hr
= IWICDdsFrameDecode_GetSizeInBlocks(dds_frame
, &width_in_blocks
, NULL
);
661 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: GetSizeInBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
662 hr
= IWICDdsFrameDecode_GetSizeInBlocks(dds_frame
, &width_in_blocks
, &height_in_blocks
);
663 ok(hr
== S_OK
, "Test %u, frame %u: GetSizeInBlocks failed, hr %#x\n", i
, frame_index
, hr
);
664 if (hr
!= S_OK
) return;
666 expected_width_in_blocks
= (expected_width
+ expected_block_width
- 1) / expected_block_width
;
667 expected_height_in_blocks
= (expected_height
+ expected_block_height
- 1) / expected_block_height
;
668 ok(width_in_blocks
== expected_width_in_blocks
,
669 "Test %u, frame %u: Expected width in blocks %u, got %u\n", i
, frame_index
, expected_width_in_blocks
, width_in_blocks
);
670 ok(height_in_blocks
== expected_height_in_blocks
,
671 "Test %u, frame %u: Expected height in blocks %u, got %u\n", i
, frame_index
, expected_height_in_blocks
, height_in_blocks
);
673 /* pixel format tests */
675 hr
= IWICBitmapFrameDecode_GetPixelFormat(frame_decode
, NULL
);
676 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: GetPixelFormat got unexpected hr %#x\n", i
, frame_index
, hr
);
677 hr
= IWICBitmapFrameDecode_GetPixelFormat(frame_decode
, &pixel_format
);
678 ok(hr
== S_OK
, "Test %u, frame %u: GetPixelFormat failed, hr %#x\n", i
, frame_index
, hr
);
679 if (hr
!= S_OK
) return;
680 ok(IsEqualGUID(&pixel_format
, test_data
[i
].expected_pixel_format
),
681 "Test %u, frame %u: Expected pixel format %s, got %s\n",
682 i
, frame_index
, debugstr_guid(test_data
[i
].expected_pixel_format
), debugstr_guid(&pixel_format
));
685 static void test_dds_decoder_frame_data(IWICDdsFrameDecode
*dds_frame
, UINT frame_count
, WICDdsParameters
*params
,
686 int i
, int frame_index
)
689 WICDdsFormatInfo format_info
;
690 WICRect rect
= { 0, 0, 1, 1 }, rect_test_a
= { 0, 0, 0, 0 }, rect_test_b
= { 0, 0, 0xdeadbeaf, 0xdeadbeaf };
691 WICRect rect_test_c
= { -0xdeadbeaf, -0xdeadbeaf, 1, 1 }, rect_test_d
= { 0xdeadbeaf, 0xdeadbeaf, 1, 1 };
693 UINT stride
, frame_stride
, frame_size
, width_in_blocks
, height_in_blocks
;
694 UINT width
, height
, depth
, array_index
;
698 hr
= IWICDdsFrameDecode_GetFormatInfo(dds_frame
, &format_info
);
699 ok(hr
== S_OK
, "Test %u, frame %u: GetFormatInfo failed, hr %#x\n", i
, frame_index
, hr
);
700 if (hr
!= S_OK
) return;
701 hr
= IWICDdsFrameDecode_GetSizeInBlocks(dds_frame
, &width_in_blocks
, &height_in_blocks
);
702 ok(hr
== S_OK
, "Test %u, frame %u: GetSizeInBlocks failed, hr %#x\n", i
, frame_index
, hr
);
703 if (hr
!= S_OK
) return;
704 stride
= rect
.Width
* format_info
.BytesPerBlock
;
705 frame_stride
= width_in_blocks
* format_info
.BytesPerBlock
;
706 frame_size
= frame_stride
* height_in_blocks
;
708 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, NULL
, 0, 0, NULL
);
709 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
711 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, &rect_test_a
, stride
, sizeof(buffer
), buffer
);
712 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
713 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, &rect_test_b
, stride
, sizeof(buffer
), buffer
);
714 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
715 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, &rect_test_c
, stride
, sizeof(buffer
), buffer
);
716 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
717 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, &rect_test_d
, stride
, sizeof(buffer
), buffer
);
718 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
720 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, NULL
, frame_stride
- 1, sizeof(buffer
), buffer
);
721 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
722 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, NULL
, frame_stride
* 2, sizeof(buffer
), buffer
);
723 ok(hr
== S_OK
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
724 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, NULL
, frame_stride
, sizeof(buffer
), buffer
);
725 ok(hr
== S_OK
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
726 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, NULL
, frame_stride
, frame_stride
* height_in_blocks
- 1, buffer
);
727 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
728 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, NULL
, frame_stride
, frame_stride
* height_in_blocks
, buffer
);
729 ok(hr
== S_OK
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
731 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, &rect
, 0, sizeof(buffer
), buffer
);
732 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
733 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, &rect
, stride
- 1, sizeof(buffer
), buffer
);
734 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
735 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, &rect
, stride
* 2, sizeof(buffer
), buffer
);
736 ok(hr
== S_OK
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
738 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, &rect
, stride
, 0, buffer
);
739 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
740 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, &rect
, stride
, 1, buffer
);
741 ok(hr
== E_INVALIDARG
|| (hr
== S_OK
&& test_data
[i
].expected_bytes_per_block
== 1),
742 "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
743 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, &rect
, stride
, stride
* rect
.Height
- 1, buffer
);
744 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
745 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, &rect
, stride
, stride
* rect
.Height
, buffer
);
746 ok(hr
== S_OK
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
748 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, &rect
, stride
, sizeof(buffer
), NULL
);
749 ok(hr
== E_INVALIDARG
, "Test %u, frame %u: CopyBlocks got unexpected hr %#x\n", i
, frame_index
, hr
);
751 block_offset
= 128; /* DDS magic and header */
752 if (has_extended_header(test_data
[i
].data
)) block_offset
+= 20; /* DDS extended header */
753 width
= params
->Width
;
754 height
= params
->Height
;
755 depth
= params
->Depth
;
756 slice_index
= frame_index
% (frame_count
/ params
->ArraySize
);
757 array_index
= frame_index
/ (frame_count
/ params
->ArraySize
);
758 block_offset
+= (test_data
[i
].size
- block_offset
) / params
->ArraySize
* array_index
;
759 while (slice_index
>= 0)
761 width_in_blocks
= (width
+ format_info
.BlockWidth
- 1) / format_info
.BlockWidth
;
762 height_in_blocks
= (width
+ format_info
.BlockWidth
- 1) / format_info
.BlockWidth
;
763 block_offset
+= (slice_index
>= depth
) ?
764 (width_in_blocks
* height_in_blocks
* format_info
.BytesPerBlock
* depth
) :
765 (width_in_blocks
* height_in_blocks
* format_info
.BytesPerBlock
* slice_index
);
766 if (width
> 1) width
/= 2;
767 if (height
> 1) height
/= 2;
768 slice_index
-= depth
;
769 if (depth
> 1) depth
/= 2;
772 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, &rect
, stride
, sizeof(buffer
), buffer
);
773 ok(hr
== S_OK
, "Test %u, frame %u: CopyBlocks failed, hr %#x\n", i
, frame_index
, hr
);
774 if (hr
!= S_OK
) return;
775 ok(!strncmp((const char *)test_data
[i
].data
+ block_offset
, (const char *)buffer
, format_info
.BytesPerBlock
),
776 "Test %u, frame %u: Block data mismatch\n", i
, frame_index
);
778 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, NULL
, frame_stride
, sizeof(buffer
), buffer
);
779 ok(hr
== S_OK
, "Test %u, frame %u: CopyBlocks failed, hr %#x\n", i
, frame_index
, hr
);
780 if (hr
!= S_OK
) return;
781 ok(!strncmp((const char *)test_data
[i
].data
+ block_offset
, (const char *)buffer
, frame_size
),
782 "Test %u, frame %u: Block data mismatch\n", i
, frame_index
);
784 hr
= IWICDdsFrameDecode_CopyBlocks(dds_frame
, NULL
, frame_stride
* 2, sizeof(buffer
), buffer
);
785 ok(hr
== S_OK
, "Test %u, frame %u: CopyBlocks failed, hr %#x\n", i
, frame_index
, hr
);
786 if (hr
!= S_OK
) return;
787 ok(!strncmp((const char *)test_data
[i
].data
+ block_offset
, (const char *)buffer
, frame_size
),
788 "Test %u, frame %u: Block data mismatch\n", i
, frame_index
);
791 static void test_dds_decoder_frame(IWICBitmapDecoder
*decoder
, int i
)
794 IWICDdsDecoder
*dds_decoder
= NULL
;
796 WICDdsParameters params
;
798 hr
= IWICBitmapDecoder_GetFrameCount(decoder
, &frame_count
);
799 ok(hr
== S_OK
, "Test %u: GetFrameCount failed, hr %#x\n", i
, hr
);
800 if (hr
!= S_OK
) return;
801 hr
= IWICBitmapDecoder_QueryInterface(decoder
, &IID_IWICDdsDecoder
, (void **)&dds_decoder
);
802 ok(hr
== S_OK
, "Test %u: QueryInterface failed, hr %#x\n", i
, hr
);
803 if (hr
!= S_OK
) goto end
;
804 hr
= IWICDdsDecoder_GetParameters(dds_decoder
, ¶ms
);
805 ok(hr
== S_OK
, "Test %u: GetParameters failed, hr %#x\n", i
, hr
);
806 if (hr
!= S_OK
) goto end
;
808 if (test_data
[i
].expected_parameters
.Dimension
== WICDdsTextureCube
) params
.ArraySize
*= 6;
810 for (j
= 0; j
< frame_count
; j
++)
812 IWICBitmapFrameDecode
*frame_decode
= NULL
;
813 IWICDdsFrameDecode
*dds_frame
= NULL
;
815 hr
= IWICBitmapDecoder_GetFrame(decoder
, j
, &frame_decode
);
816 ok(hr
== S_OK
, "Test %u, frame %u: GetFrame failed, hr %#x\n", i
, j
, hr
);
817 if (hr
!= S_OK
) goto next
;
818 hr
= IWICBitmapFrameDecode_QueryInterface(frame_decode
, &IID_IWICDdsFrameDecode
, (void **)&dds_frame
);
819 ok(hr
== S_OK
, "Test %u, frame %u: QueryInterface failed, hr %#x\n", i
, j
, hr
);
820 if (hr
!= S_OK
) goto next
;
822 test_dds_decoder_frame_properties(frame_decode
, dds_frame
, frame_count
, ¶ms
, i
, j
);
823 test_dds_decoder_frame_data(dds_frame
, frame_count
, ¶ms
, i
, j
);
826 if (frame_decode
) IWICBitmapFrameDecode_Release(frame_decode
);
827 if (dds_frame
) IWICDdsFrameDecode_Release(dds_frame
);
831 if (dds_decoder
) IWICDdsDecoder_Release(dds_decoder
);
834 static void test_dds_decoder(void)
839 test_dds_decoder_initialize();
840 test_dds_decoder_image_parameters();
842 for (i
= 0; i
< ARRAY_SIZE(test_data
); i
++)
844 IWICStream
*stream
= NULL
;
845 IWICBitmapDecoder
*decoder
= NULL
;
847 if (test_data
[i
].init_hr
!= S_OK
&& !test_data
[i
].wine_init
) continue;
849 stream
= create_stream(test_data
[i
].data
, test_data
[i
].size
);
850 if (!stream
) goto next
;
851 decoder
= create_decoder();
852 if (!decoder
) goto next
;
853 hr
= init_decoder(decoder
, stream
, test_data
[i
].init_hr
, i
, test_data
[i
].wine_init
);
855 if (test_data
[i
].expected_parameters
.Dimension
== WICDdsTextureCube
) {
856 win_skip("Cube map is not supported\n");
858 win_skip("Uncompressed DDS image is not supported\n");
863 test_dds_decoder_global_properties(decoder
);
864 test_dds_decoder_frame(decoder
, i
);
867 if (decoder
) IWICBitmapDecoder_Release(decoder
);
868 if (stream
) IWICStream_Release(stream
);
872 START_TEST(ddsformat
)
875 CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
877 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
878 &IID_IWICImagingFactory
, (void **)&factory
);
879 ok(hr
== S_OK
, "CoCreateInstance failed, hr %#x\n", hr
);
880 if (hr
!= S_OK
) goto end
;
885 if (factory
) IWICImagingFactory_Release(factory
);