TESTING -- override pthreads to fix gstreamer v5
[wine/multimedia.git] / dlls / windowscodecs / tests / metadata.c
blob6c2d6b7792ab13555afcf3e1f5ce402bdd023aed
1 /*
2 * Copyright 2011 Vincent Povirk for CodeWeavers
3 * Copyright 2012 Dmitry Timoshkov
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdio.h>
21 #include <stdarg.h>
22 #include <math.h>
23 #include <assert.h>
25 #define COBJMACROS
27 #include "windef.h"
28 #include "objbase.h"
29 #include "wincodec.h"
30 #include "wincodecsdk.h"
31 #include "wine/test.h"
33 #define expect_blob(propvar, data, length) do { \
34 ok((propvar).vt == VT_BLOB, "unexpected vt: %i\n", (propvar).vt); \
35 if ((propvar).vt == VT_BLOB) { \
36 ok(U(propvar).blob.cbSize == (length), "expected size %u, got %u\n", (ULONG)(length), U(propvar).blob.cbSize); \
37 if (U(propvar).blob.cbSize == (length)) { \
38 ok(!memcmp(U(propvar).blob.pBlobData, (data), (length)), "unexpected data\n"); \
39 } \
40 } \
41 } while (0)
43 #define IFD_BYTE 1
44 #define IFD_ASCII 2
45 #define IFD_SHORT 3
46 #define IFD_LONG 4
47 #define IFD_RATIONAL 5
48 #define IFD_SBYTE 6
49 #define IFD_UNDEFINED 7
50 #define IFD_SSHORT 8
51 #define IFD_SLONG 9
52 #define IFD_SRATIONAL 10
53 #define IFD_FLOAT 11
54 #define IFD_DOUBLE 12
55 #define IFD_IFD 13
57 #include "pshpack2.h"
58 struct IFD_entry
60 SHORT id;
61 SHORT type;
62 ULONG count;
63 LONG value;
66 struct IFD_rational
68 LONG numerator;
69 LONG denominator;
72 static const struct ifd_data
74 USHORT number_of_entries;
75 struct IFD_entry entry[40];
76 ULONG next_IFD;
77 struct IFD_rational xres;
78 DOUBLE double_val;
79 struct IFD_rational srational_val;
80 char string[14];
81 SHORT short_val[4];
82 LONG long_val[2];
83 FLOAT float_val[2];
84 struct IFD_rational rational[3];
85 } IFD_data =
87 28,
89 { 0xfe, IFD_SHORT, 1, 1 }, /* NEWSUBFILETYPE */
90 { 0x100, IFD_LONG, 1, 222 }, /* IMAGEWIDTH */
91 { 0x101, IFD_LONG, 1, 333 }, /* IMAGELENGTH */
92 { 0x102, IFD_SHORT, 1, 24 }, /* BITSPERSAMPLE */
93 { 0x103, IFD_LONG, 1, 32773 }, /* COMPRESSION: packbits */
94 { 0x11a, IFD_RATIONAL, 1, FIELD_OFFSET(struct ifd_data, xres) },
95 { 0xf001, IFD_BYTE, 1, 0x11223344 },
96 { 0xf002, IFD_BYTE, 4, 0x11223344 },
97 { 0xf003, IFD_SBYTE, 1, 0x11223344 },
98 { 0xf004, IFD_SSHORT, 1, 0x11223344 },
99 { 0xf005, IFD_SSHORT, 2, 0x11223344 },
100 { 0xf006, IFD_SLONG, 1, 0x11223344 },
101 { 0xf007, IFD_FLOAT, 1, 0x11223344 },
102 { 0xf008, IFD_DOUBLE, 1, FIELD_OFFSET(struct ifd_data, double_val) },
103 { 0xf009, IFD_SRATIONAL, 1, FIELD_OFFSET(struct ifd_data, srational_val) },
104 { 0xf00a, IFD_BYTE, 13, FIELD_OFFSET(struct ifd_data, string) },
105 { 0xf00b, IFD_SSHORT, 4, FIELD_OFFSET(struct ifd_data, short_val) },
106 { 0xf00c, IFD_SLONG, 2, FIELD_OFFSET(struct ifd_data, long_val) },
107 { 0xf00d, IFD_FLOAT, 2, FIELD_OFFSET(struct ifd_data, float_val) },
108 { 0xf00e, IFD_ASCII, 13, FIELD_OFFSET(struct ifd_data, string) },
109 { 0xf00f, IFD_ASCII, 4, 'a' | 'b' << 8 | 'c' << 16 | 'd' << 24 },
110 { 0xf010, IFD_UNDEFINED, 13, FIELD_OFFSET(struct ifd_data, string) },
111 { 0xf011, IFD_UNDEFINED, 4, 'a' | 'b' << 8 | 'c' << 16 | 'd' << 24 },
112 { 0xf012, IFD_BYTE, 0, 0x11223344 },
113 { 0xf013, IFD_SHORT, 0, 0x11223344 },
114 { 0xf014, IFD_LONG, 0, 0x11223344 },
115 { 0xf015, IFD_FLOAT, 0, 0x11223344 },
116 { 0xf016, IFD_SRATIONAL, 3, FIELD_OFFSET(struct ifd_data, rational) },
119 { 900, 3 },
120 1234567890.0987654321,
121 { 0x1a2b3c4d, 0x5a6b7c8d },
122 "Hello World!",
123 { 0x0101, 0x0202, 0x0303, 0x0404 },
124 { 0x11223344, 0x55667788 },
125 { (FLOAT)1234.5678, (FLOAT)8765.4321 },
126 { { 0x01020304, 0x05060708 }, { 0x10203040, 0x50607080 }, { 0x11223344, 0x55667788 } },
128 #include "poppack.h"
130 static const char metadata_unknown[] = "lalala";
132 static const char metadata_tEXt[] = {
133 0,0,0,14, /* chunk length */
134 't','E','X','t', /* chunk type */
135 'w','i','n','e','t','e','s','t',0, /* keyword */
136 'v','a','l','u','e', /* text */
137 0x3f,0x64,0x19,0xf3 /* chunk CRC */
140 static const char metadata_gAMA[] = {
141 0,0,0,4, /* chunk length */
142 'g','A','M','A', /* chunk type */
143 0,0,130,53, /* gamma */
144 0xff,0xff,0xff,0xff /* chunk CRC */
147 static const char pngimage[285] = {
148 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
149 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x02,0x00,0x00,0x00,0x90,0x77,0x53,
150 0xde,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,0x00,0x00,0x0b,0x13,0x00,0x00,0x0b,
151 0x13,0x01,0x00,0x9a,0x9c,0x18,0x00,0x00,0x00,0x07,0x74,0x49,0x4d,0x45,0x07,0xd5,
152 0x06,0x03,0x0f,0x07,0x2d,0x12,0x10,0xf0,0xfd,0x00,0x00,0x00,0x0c,0x49,0x44,0x41,
153 0x54,0x08,0xd7,0x63,0xf8,0xff,0xff,0x3f,0x00,0x05,0xfe,0x02,0xfe,0xdc,0xcc,0x59,
154 0xe7,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
157 /* 1x1 pixel gif */
158 static const char gifimage[35] = {
159 0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x00,0xff,0xff,0xff,
160 0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44,
161 0x01,0x00,0x3b
164 /* 1x1 pixel gif, 2 frames; first frame is white, second is black */
165 static const char animatedgif[] = {
166 'G','I','F','8','9','a',0x01,0x00,0x01,0x00,0xA1,0x00,0x00,
167 0x6F,0x6F,0x6F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
168 /*0x21,0xFF,0x0B,'N','E','T','S','C','A','P','E','2','.','0',*/
169 0x21,0xFF,0x0B,'A','N','I','M','E','X','T','S','1','.','0',
170 0x03,0x01,0x05,0x00,0x00,
171 0x21,0xFE,0x0C,'H','e','l','l','o',' ','W','o','r','l','d','!',0x00,
172 0x21,0x01,0x0D,'a','n','i','m','a','t','i','o','n','.','g','i','f',0x00,
173 0x21,0xF9,0x04,0x00,0x0A,0x00,0xFF,0x00,0x2C,
174 0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x81,
175 0xDE,0xDE,0xDE,0x00,0x00,0x00,
176 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x4C,0x01,0x00,
177 0x21,0xFE,0x08,'i','m','a','g','e',' ','#','1',0x00,
178 0x21,0x01,0x0C,'p','l','a','i','n','t','e','x','t',' ','#','1',0x00,
179 0x21,0xF9,0x04,0x01,0x0A,0x00,0x01,0x00,0x2C,
180 0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x81,
181 0x4D,0x4D,0x4D,0x00,0x00,0x00,
182 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x44,0x01,0x00,
183 0x21,0xFE,0x08,'i','m','a','g','e',' ','#','2',0x00,
184 0x21,0x01,0x0C,'p','l','a','i','n','t','e','x','t',' ','#','2',0x00,0x3B
187 static IStream *create_stream(const char *data, int data_size)
189 HRESULT hr;
190 IStream *stream;
191 HGLOBAL hdata;
192 void *locked_data;
194 hdata = GlobalAlloc(GMEM_MOVEABLE, data_size);
195 ok(hdata != 0, "GlobalAlloc failed\n");
196 if (!hdata) return NULL;
198 locked_data = GlobalLock(hdata);
199 memcpy(locked_data, data, data_size);
200 GlobalUnlock(hdata);
202 hr = CreateStreamOnHGlobal(hdata, TRUE, &stream);
203 ok(hr == S_OK, "CreateStreamOnHGlobal failed, hr=%x\n", hr);
205 return stream;
208 static void load_stream(IUnknown *reader, const char *data, int data_size, DWORD persist_options)
210 HRESULT hr;
211 IWICPersistStream *persist;
212 IStream *stream;
213 LARGE_INTEGER pos;
214 ULARGE_INTEGER cur_pos;
216 stream = create_stream(data, data_size);
217 if (!stream)
218 return;
220 hr = IUnknown_QueryInterface(reader, &IID_IWICPersistStream, (void**)&persist);
221 ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
223 if (SUCCEEDED(hr))
225 hr = IWICPersistStream_LoadEx(persist, stream, NULL, persist_options);
226 ok(hr == S_OK, "LoadEx failed, hr=%x\n", hr);
228 IWICPersistStream_Release(persist);
231 pos.QuadPart = 0;
232 hr = IStream_Seek(stream, pos, SEEK_CUR, &cur_pos);
233 ok(hr == S_OK, "IStream_Seek error %#x\n", hr);
234 /* IFD metadata reader doesn't rewind the stream to the start */
235 ok(cur_pos.QuadPart == 0 || cur_pos.QuadPart <= data_size,
236 "current stream pos is at %x/%x, data size %x\n", cur_pos.u.LowPart, cur_pos.u.HighPart, data_size);
238 IStream_Release(stream);
241 static void test_metadata_unknown(void)
243 HRESULT hr;
244 IWICMetadataReader *reader;
245 IWICEnumMetadataItem *enumerator;
246 IWICMetadataBlockReader *blockreader;
247 PROPVARIANT schema, id, value;
248 ULONG items_returned;
250 hr = CoCreateInstance(&CLSID_WICUnknownMetadataReader, NULL, CLSCTX_INPROC_SERVER,
251 &IID_IWICMetadataReader, (void**)&reader);
252 ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
253 if (FAILED(hr)) return;
255 load_stream((IUnknown*)reader, metadata_unknown, sizeof(metadata_unknown), WICPersistOptionsDefault);
257 hr = IWICMetadataReader_GetEnumerator(reader, &enumerator);
258 ok(hr == S_OK, "GetEnumerator failed, hr=%x\n", hr);
260 if (SUCCEEDED(hr))
262 PropVariantInit(&schema);
263 PropVariantInit(&id);
264 PropVariantInit(&value);
266 hr = IWICEnumMetadataItem_Next(enumerator, 1, &schema, &id, &value, &items_returned);
267 ok(hr == S_OK, "Next failed, hr=%x\n", hr);
268 ok(items_returned == 1, "unexpected item count %i\n", items_returned);
270 if (hr == S_OK && items_returned == 1)
272 ok(schema.vt == VT_EMPTY, "unexpected vt: %i\n", schema.vt);
273 ok(id.vt == VT_EMPTY, "unexpected vt: %i\n", id.vt);
274 expect_blob(value, metadata_unknown, sizeof(metadata_unknown));
276 PropVariantClear(&schema);
277 PropVariantClear(&id);
278 PropVariantClear(&value);
281 hr = IWICEnumMetadataItem_Next(enumerator, 1, &schema, &id, &value, &items_returned);
282 ok(hr == S_FALSE, "Next failed, hr=%x\n", hr);
283 ok(items_returned == 0, "unexpected item count %i\n", items_returned);
285 IWICEnumMetadataItem_Release(enumerator);
288 hr = IWICMetadataReader_QueryInterface(reader, &IID_IWICMetadataBlockReader, (void**)&blockreader);
289 ok(hr == E_NOINTERFACE, "QueryInterface failed, hr=%x\n", hr);
291 if (SUCCEEDED(hr))
292 IWICMetadataBlockReader_Release(blockreader);
294 IWICMetadataReader_Release(reader);
297 static void test_metadata_tEXt(void)
299 HRESULT hr;
300 IWICMetadataReader *reader;
301 IWICEnumMetadataItem *enumerator;
302 PROPVARIANT schema, id, value;
303 ULONG items_returned, count;
304 GUID format;
306 PropVariantInit(&schema);
307 PropVariantInit(&id);
308 PropVariantInit(&value);
310 hr = CoCreateInstance(&CLSID_WICPngTextMetadataReader, NULL, CLSCTX_INPROC_SERVER,
311 &IID_IWICMetadataReader, (void**)&reader);
312 ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
313 if (FAILED(hr)) return;
315 hr = IWICMetadataReader_GetCount(reader, NULL);
316 ok(hr == E_INVALIDARG, "GetCount failed, hr=%x\n", hr);
318 hr = IWICMetadataReader_GetCount(reader, &count);
319 ok(hr == S_OK, "GetCount failed, hr=%x\n", hr);
320 ok(count == 0, "unexpected count %i\n", count);
322 load_stream((IUnknown*)reader, metadata_tEXt, sizeof(metadata_tEXt), WICPersistOptionsDefault);
324 hr = IWICMetadataReader_GetCount(reader, &count);
325 ok(hr == S_OK, "GetCount failed, hr=%x\n", hr);
326 ok(count == 1, "unexpected count %i\n", count);
328 hr = IWICMetadataReader_GetEnumerator(reader, NULL);
329 ok(hr == E_INVALIDARG, "GetEnumerator failed, hr=%x\n", hr);
331 hr = IWICMetadataReader_GetEnumerator(reader, &enumerator);
332 ok(hr == S_OK, "GetEnumerator failed, hr=%x\n", hr);
334 if (SUCCEEDED(hr))
336 hr = IWICEnumMetadataItem_Next(enumerator, 1, &schema, &id, &value, &items_returned);
337 ok(hr == S_OK, "Next failed, hr=%x\n", hr);
338 ok(items_returned == 1, "unexpected item count %i\n", items_returned);
340 if (hr == S_OK && items_returned == 1)
342 ok(schema.vt == VT_EMPTY, "unexpected vt: %i\n", schema.vt);
343 ok(id.vt == VT_LPSTR, "unexpected vt: %i\n", id.vt);
344 ok(!strcmp(U(id).pszVal, "winetest"), "unexpected id: %s\n", U(id).pszVal);
345 ok(value.vt == VT_LPSTR, "unexpected vt: %i\n", value.vt);
346 ok(!strcmp(U(value).pszVal, "value"), "unexpected value: %s\n", U(value).pszVal);
348 PropVariantClear(&schema);
349 PropVariantClear(&id);
350 PropVariantClear(&value);
353 hr = IWICEnumMetadataItem_Next(enumerator, 1, &schema, &id, &value, &items_returned);
354 ok(hr == S_FALSE, "Next failed, hr=%x\n", hr);
355 ok(items_returned == 0, "unexpected item count %i\n", items_returned);
357 IWICEnumMetadataItem_Release(enumerator);
360 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
361 ok(hr == S_OK, "GetMetadataFormat failed, hr=%x\n", hr);
362 ok(IsEqualGUID(&format, &GUID_MetadataFormatChunktEXt), "unexpected format %s\n", wine_dbgstr_guid(&format));
364 hr = IWICMetadataReader_GetMetadataFormat(reader, NULL);
365 ok(hr == E_INVALIDARG, "GetMetadataFormat failed, hr=%x\n", hr);
367 id.vt = VT_LPSTR;
368 U(id).pszVal = CoTaskMemAlloc(strlen("winetest") + 1);
369 strcpy(U(id).pszVal, "winetest");
371 hr = IWICMetadataReader_GetValue(reader, NULL, &id, NULL);
372 ok(hr == S_OK, "GetValue failed, hr=%x\n", hr);
374 hr = IWICMetadataReader_GetValue(reader, &schema, NULL, &value);
375 ok(hr == E_INVALIDARG, "GetValue failed, hr=%x\n", hr);
377 hr = IWICMetadataReader_GetValue(reader, &schema, &id, &value);
378 ok(hr == S_OK, "GetValue failed, hr=%x\n", hr);
379 ok(value.vt == VT_LPSTR, "unexpected vt: %i\n", id.vt);
380 ok(!strcmp(U(value).pszVal, "value"), "unexpected value: %s\n", U(value).pszVal);
381 PropVariantClear(&value);
383 strcpy(U(id).pszVal, "test");
385 hr = IWICMetadataReader_GetValue(reader, &schema, &id, &value);
386 ok(hr == WINCODEC_ERR_PROPERTYNOTFOUND, "GetValue failed, hr=%x\n", hr);
388 PropVariantClear(&id);
390 hr = IWICMetadataReader_GetValueByIndex(reader, 0, NULL, NULL, NULL);
391 ok(hr == S_OK, "GetValueByIndex failed, hr=%x\n", hr);
393 hr = IWICMetadataReader_GetValueByIndex(reader, 0, &schema, NULL, NULL);
394 ok(hr == S_OK, "GetValueByIndex failed, hr=%x\n", hr);
395 ok(schema.vt == VT_EMPTY, "unexpected vt: %i\n", schema.vt);
397 hr = IWICMetadataReader_GetValueByIndex(reader, 0, NULL, &id, NULL);
398 ok(hr == S_OK, "GetValueByIndex failed, hr=%x\n", hr);
399 ok(id.vt == VT_LPSTR, "unexpected vt: %i\n", id.vt);
400 ok(!strcmp(U(id).pszVal, "winetest"), "unexpected id: %s\n", U(id).pszVal);
401 PropVariantClear(&id);
403 hr = IWICMetadataReader_GetValueByIndex(reader, 0, NULL, NULL, &value);
404 ok(hr == S_OK, "GetValueByIndex failed, hr=%x\n", hr);
405 ok(value.vt == VT_LPSTR, "unexpected vt: %i\n", value.vt);
406 ok(!strcmp(U(value).pszVal, "value"), "unexpected value: %s\n", U(value).pszVal);
407 PropVariantClear(&value);
409 hr = IWICMetadataReader_GetValueByIndex(reader, 1, NULL, NULL, NULL);
410 ok(hr == E_INVALIDARG, "GetValueByIndex failed, hr=%x\n", hr);
412 IWICMetadataReader_Release(reader);
415 static void test_metadata_gAMA(void)
417 HRESULT hr;
418 IWICMetadataReader *reader;
419 PROPVARIANT schema, id, value;
420 ULONG count;
421 GUID format;
422 static const WCHAR ImageGamma[] = {'I','m','a','g','e','G','a','m','m','a',0};
424 PropVariantInit(&schema);
425 PropVariantInit(&id);
426 PropVariantInit(&value);
428 hr = CoCreateInstance(&CLSID_WICPngGamaMetadataReader, NULL, CLSCTX_INPROC_SERVER,
429 &IID_IWICMetadataReader, (void**)&reader);
430 ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG) /*winxp*/, "CoCreateInstance failed, hr=%x\n", hr);
431 if (FAILED(hr)) return;
433 load_stream((IUnknown*)reader, metadata_gAMA, sizeof(metadata_gAMA), WICPersistOptionsDefault);
435 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
436 ok(hr == S_OK, "GetMetadataFormat failed, hr=%x\n", hr);
437 ok(IsEqualGUID(&format, &GUID_MetadataFormatChunkgAMA), "unexpected format %s\n", wine_dbgstr_guid(&format));
439 hr = IWICMetadataReader_GetCount(reader, &count);
440 ok(hr == S_OK, "GetCount failed, hr=%x\n", hr);
441 ok(count == 1, "unexpected count %i\n", count);
443 hr = IWICMetadataReader_GetValueByIndex(reader, 0, &schema, &id, &value);
444 ok(hr == S_OK, "GetValue failed, hr=%x\n", hr);
446 ok(schema.vt == VT_EMPTY, "unexpected vt: %i\n", schema.vt);
447 PropVariantClear(&schema);
449 ok(id.vt == VT_LPWSTR, "unexpected vt: %i\n", id.vt);
450 ok(!lstrcmpW(U(id).pwszVal, ImageGamma), "unexpected value: %s\n", wine_dbgstr_w(U(id).pwszVal));
451 PropVariantClear(&id);
453 ok(value.vt == VT_UI4, "unexpected vt: %i\n", value.vt);
454 ok(U(value).ulVal == 33333, "unexpected value: %u\n", U(value).ulVal);
455 PropVariantClear(&value);
457 IWICMetadataReader_Release(reader);
460 static inline USHORT ushort_bswap(USHORT s)
462 return (s >> 8) | (s << 8);
465 static inline ULONG ulong_bswap(ULONG l)
467 return ((ULONG)ushort_bswap((USHORT)l) << 16) | ushort_bswap((USHORT)(l >> 16));
470 static inline ULONGLONG ulonglong_bswap(ULONGLONG ll)
472 return ((ULONGLONG)ulong_bswap((ULONG)ll) << 32) | ulong_bswap((ULONG)(ll >> 32));
475 static void byte_swap_ifd_data(char *data)
477 USHORT number_of_entries, i;
478 struct IFD_entry *entry;
479 char *data_start = data;
481 number_of_entries = *(USHORT *)data;
482 *(USHORT *)data = ushort_bswap(*(USHORT *)data);
483 data += sizeof(USHORT);
485 for (i = 0; i < number_of_entries; i++)
487 entry = (struct IFD_entry *)data;
489 switch (entry->type)
491 case IFD_BYTE:
492 case IFD_SBYTE:
493 case IFD_ASCII:
494 case IFD_UNDEFINED:
495 if (entry->count > 4)
496 entry->value = ulong_bswap(entry->value);
497 break;
499 case IFD_SHORT:
500 case IFD_SSHORT:
501 if (entry->count > 2)
503 ULONG j, count = entry->count;
504 USHORT *us = (USHORT *)(data_start + entry->value);
505 if (!count) count = 1;
506 for (j = 0; j < count; j++)
507 us[j] = ushort_bswap(us[j]);
509 entry->value = ulong_bswap(entry->value);
511 else
513 ULONG j, count = entry->count;
514 USHORT *us = (USHORT *)&entry->value;
515 if (!count) count = 1;
516 for (j = 0; j < count; j++)
517 us[j] = ushort_bswap(us[j]);
519 break;
521 case IFD_LONG:
522 case IFD_SLONG:
523 case IFD_FLOAT:
524 if (entry->count > 1)
526 ULONG j, count = entry->count;
527 ULONG *ul = (ULONG *)(data_start + entry->value);
528 if (!count) count = 1;
529 for (j = 0; j < count; j++)
530 ul[j] = ulong_bswap(ul[j]);
532 entry->value = ulong_bswap(entry->value);
533 break;
535 case IFD_RATIONAL:
536 case IFD_SRATIONAL:
538 ULONG j;
539 ULONG *ul = (ULONG *)(data_start + entry->value);
540 for (j = 0; j < entry->count * 2; j++)
541 ul[j] = ulong_bswap(ul[j]);
543 entry->value = ulong_bswap(entry->value);
544 break;
546 case IFD_DOUBLE:
548 ULONG j;
549 ULONGLONG *ull = (ULONGLONG *)(data_start + entry->value);
550 for (j = 0; j < entry->count; j++)
551 ull[j] = ulonglong_bswap(ull[j]);
553 entry->value = ulong_bswap(entry->value);
554 break;
556 default:
557 assert(0);
558 break;
561 entry->id = ushort_bswap(entry->id);
562 entry->type = ushort_bswap(entry->type);
563 entry->count = ulong_bswap(entry->count);
564 data += sizeof(*entry);
568 struct test_data
570 ULONG type, id;
571 int count; /* if VT_VECTOR */
572 LONGLONG value[13];
573 const char *string;
574 const WCHAR id_string[32];
577 static void compare_metadata(IWICMetadataReader *reader, const struct test_data *td, ULONG count)
579 HRESULT hr;
580 IWICEnumMetadataItem *enumerator;
581 PROPVARIANT schema, id, value;
582 ULONG items_returned, i;
584 hr = IWICMetadataReader_GetEnumerator(reader, NULL);
585 ok(hr == E_INVALIDARG, "GetEnumerator error %#x\n", hr);
587 hr = IWICMetadataReader_GetEnumerator(reader, &enumerator);
588 ok(hr == S_OK, "GetEnumerator error %#x\n", hr);
590 PropVariantInit(&schema);
591 PropVariantInit(&id);
592 PropVariantInit(&value);
594 for (i = 0; i < count; i++)
596 hr = IWICEnumMetadataItem_Next(enumerator, 1, &schema, &id, &value, &items_returned);
597 ok(hr == S_OK, "Next error %#x\n", hr);
598 ok(items_returned == 1, "unexpected item count %u\n", items_returned);
600 ok(schema.vt == VT_EMPTY, "%u: unexpected vt: %u\n", i, schema.vt);
601 ok(id.vt == VT_UI2 || id.vt == VT_LPWSTR || id.vt == VT_EMPTY, "%u: unexpected vt: %u\n", i, id.vt);
602 if (id.vt == VT_UI2)
603 ok(U(id).uiVal == td[i].id, "%u: expected id %#x, got %#x\n", i, td[i].id, U(id).uiVal);
604 else if (id.vt == VT_LPWSTR)
605 ok(!lstrcmpW(td[i].id_string, U(id).pwszVal),
606 "%u: expected %s, got %s\n", i, wine_dbgstr_w(td[i].id_string), wine_dbgstr_w(U(id).pwszVal));
608 ok(value.vt == td[i].type, "%u: expected vt %#x, got %#x\n", i, td[i].type, value.vt);
609 if (value.vt & VT_VECTOR)
611 ULONG j;
612 switch (value.vt & ~VT_VECTOR)
614 case VT_I1:
615 case VT_UI1:
616 ok(td[i].count == U(value).caub.cElems, "%u: expected cElems %d, got %d\n", i, td[i].count, U(value).caub.cElems);
617 for (j = 0; j < U(value).caub.cElems; j++)
618 ok(td[i].value[j] == U(value).caub.pElems[j], "%u: expected value[%d] %#x/%#x, got %#x\n", i, j, (ULONG)td[i].value[j], (ULONG)(td[i].value[j] >> 32), U(value).caub.pElems[j]);
619 break;
620 case VT_I2:
621 case VT_UI2:
622 ok(td[i].count == U(value).caui.cElems, "%u: expected cElems %d, got %d\n", i, td[i].count, U(value).caui.cElems);
623 for (j = 0; j < U(value).caui.cElems; j++)
624 ok(td[i].value[j] == U(value).caui.pElems[j], "%u: expected value[%d] %#x/%#x, got %#x\n", i, j, (ULONG)td[i].value[j], (ULONG)(td[i].value[j] >> 32), U(value).caui.pElems[j]);
625 break;
626 case VT_I4:
627 case VT_UI4:
628 case VT_R4:
629 ok(td[i].count == U(value).caul.cElems, "%u: expected cElems %d, got %d\n", i, td[i].count, U(value).caul.cElems);
630 for (j = 0; j < U(value).caul.cElems; j++)
631 ok(td[i].value[j] == U(value).caul.pElems[j], "%u: expected value[%d] %#x/%#x, got %#x\n", i, j, (ULONG)td[i].value[j], (ULONG)(td[i].value[j] >> 32), U(value).caul.pElems[j]);
632 break;
633 case VT_I8:
634 case VT_UI8:
635 case VT_R8:
636 ok(td[i].count == U(value).cauh.cElems, "%u: expected cElems %d, got %d\n", i, td[i].count, U(value).cauh.cElems);
637 for (j = 0; j < U(value).cauh.cElems; j++)
638 ok(td[i].value[j] == U(value).cauh.pElems[j].QuadPart, "%u: expected value[%d] %08x/%08x, got %08x/%08x\n", i, j, (ULONG)td[i].value[j], (ULONG)(td[i].value[j] >> 32), U(value).cauh.pElems[j].u.LowPart, U(value).cauh.pElems[j].u.HighPart);
639 break;
640 case VT_LPSTR:
641 ok(td[i].count == U(value).calpstr.cElems, "%u: expected cElems %d, got %d\n", i, td[i].count, U(value).caub.cElems);
642 for (j = 0; j < U(value).calpstr.cElems; j++)
643 trace("%u: %s\n", j, U(value).calpstr.pElems[j]);
644 /* fall through to not handled message */
645 default:
646 ok(0, "%u: array of type %d is not handled\n", i, value.vt & ~VT_VECTOR);
647 break;
650 else if (value.vt == VT_LPSTR)
652 ok(td[i].count == strlen(U(value).pszVal) ||
653 broken(td[i].count == strlen(U(value).pszVal) + 1), /* before Win7 */
654 "%u: expected count %d, got %d\n", i, td[i].count, lstrlenA(U(value).pszVal));
655 if (td[i].count == strlen(U(value).pszVal))
656 ok(!strcmp(td[i].string, U(value).pszVal),
657 "%u: expected %s, got %s\n", i, td[i].string, U(value).pszVal);
659 else if (value.vt == VT_BLOB)
661 ok(td[i].count == U(value).blob.cbSize, "%u: expected count %d, got %d\n", i, td[i].count, U(value).blob.cbSize);
662 ok(!memcmp(td[i].string, U(value).blob.pBlobData, td[i].count), "%u: expected %s, got %s\n", i, td[i].string, U(value).blob.pBlobData);
664 else
665 ok(U(value).uhVal.QuadPart == td[i].value[0], "%u: expected value %#x/%#x got %#x/%#x\n",
666 i, (UINT)td[i].value[0], (UINT)(td[i].value[0] >> 32), U(value).uhVal.u.LowPart, U(value).uhVal.u.HighPart);
668 PropVariantClear(&schema);
669 PropVariantClear(&id);
670 PropVariantClear(&value);
673 hr = IWICEnumMetadataItem_Next(enumerator, 1, &schema, &id, &value, &items_returned);
674 ok(hr == S_FALSE, "Next should fail\n");
675 ok(items_returned == 0, "unexpected item count %u\n", items_returned);
677 IWICEnumMetadataItem_Release(enumerator);
680 static void test_metadata_IFD(void)
682 static const struct test_data td[28] =
684 { VT_UI2, 0xfe, 0, { 1 } },
685 { VT_UI4, 0x100, 0, { 222 } },
686 { VT_UI4, 0x101, 0, { 333 } },
687 { VT_UI2, 0x102, 0, { 24 } },
688 { VT_UI4, 0x103, 0, { 32773 } },
689 { VT_UI8, 0x11a, 0, { ((LONGLONG)3 << 32) | 900 } },
690 { VT_UI1, 0xf001, 0, { 0x44 } },
691 { VT_UI1|VT_VECTOR, 0xf002, 4, { 0x44, 0x33, 0x22, 0x11 } },
692 { VT_I1, 0xf003, 0, { 0x44 } },
693 { VT_I2, 0xf004, 0, { 0x3344 } },
694 { VT_I2|VT_VECTOR, 0xf005, 2, { 0x3344, 0x1122 } },
695 { VT_I4, 0xf006, 0, { 0x11223344 } },
696 { VT_R4, 0xf007, 0, { 0x11223344 } },
697 { VT_R8, 0xf008, 0, { ((LONGLONG)0x41d26580 << 32) | 0xb486522c } },
698 { VT_I8, 0xf009, 0, { ((LONGLONG)0x5a6b7c8d << 32) | 0x1a2b3c4d } },
699 { VT_UI1|VT_VECTOR, 0xf00a, 13, { 'H','e','l','l','o',' ','W','o','r','l','d','!',0 } },
700 { VT_I2|VT_VECTOR, 0xf00b, 4, { 0x0101, 0x0202, 0x0303, 0x0404 } },
701 { VT_I4|VT_VECTOR, 0xf00c, 2, { 0x11223344, 0x55667788 } },
702 { VT_R4|VT_VECTOR, 0xf00d, 2, { 0x449a522b, 0x4608f5ba } },
703 { VT_LPSTR, 0xf00e, 12, { 0 }, "Hello World!" },
704 { VT_LPSTR, 0xf00f, 4, { 0 }, "abcd" },
705 { VT_BLOB, 0xf010, 13, { 0 }, "Hello World!" },
706 { VT_BLOB, 0xf011, 4, { 0 }, "abcd" },
707 { VT_UI1, 0xf012, 0, { 0x44 } },
708 { VT_UI2, 0xf013, 0, { 0x3344 } },
709 { VT_UI4, 0xf014, 0, { 0x11223344 } },
710 { VT_R4, 0xf015, 0, { 0x11223344 } },
711 { VT_I8|VT_VECTOR, 0xf016, 3,
712 { ((LONGLONG)0x05060708 << 32) | 0x01020304,
713 ((LONGLONG)0x50607080 << 32) | 0x10203040,
714 ((LONGLONG)0x55667788 << 32) | 0x11223344 } },
716 HRESULT hr;
717 IWICMetadataReader *reader;
718 IWICMetadataBlockReader *blockreader;
719 PROPVARIANT schema, id, value;
720 ULONG count;
721 GUID format;
722 char *IFD_data_swapped;
723 #ifdef WORDS_BIGENDIAN
724 DWORD persist_options = WICPersistOptionsBigEndian;
725 #else
726 DWORD persist_options = WICPersistOptionsLittleEndian;
727 #endif
729 hr = CoCreateInstance(&CLSID_WICIfdMetadataReader, NULL, CLSCTX_INPROC_SERVER,
730 &IID_IWICMetadataReader, (void**)&reader);
731 ok(hr == S_OK, "CoCreateInstance error %#x\n", hr);
733 hr = IWICMetadataReader_GetCount(reader, NULL);
734 ok(hr == E_INVALIDARG, "GetCount error %#x\n", hr);
736 hr = IWICMetadataReader_GetCount(reader, &count);
737 ok(hr == S_OK, "GetCount error %#x\n", hr);
738 ok(count == 0, "unexpected count %u\n", count);
740 load_stream((IUnknown*)reader, (const char *)&IFD_data, sizeof(IFD_data), persist_options);
742 hr = IWICMetadataReader_GetCount(reader, &count);
743 ok(hr == S_OK, "GetCount error %#x\n", hr);
744 ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
746 compare_metadata(reader, td, count);
748 /* test IFD data with different endianness */
749 if (persist_options == WICPersistOptionsLittleEndian)
750 persist_options = WICPersistOptionsBigEndian;
751 else
752 persist_options = WICPersistOptionsLittleEndian;
754 IFD_data_swapped = HeapAlloc(GetProcessHeap(), 0, sizeof(IFD_data));
755 memcpy(IFD_data_swapped, &IFD_data, sizeof(IFD_data));
756 byte_swap_ifd_data(IFD_data_swapped);
757 load_stream((IUnknown *)reader, IFD_data_swapped, sizeof(IFD_data), persist_options);
758 hr = IWICMetadataReader_GetCount(reader, &count);
759 ok(hr == S_OK, "GetCount error %#x\n", hr);
760 ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
761 compare_metadata(reader, td, count);
762 HeapFree(GetProcessHeap(), 0, IFD_data_swapped);
764 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
765 ok(hr == S_OK, "GetMetadataFormat error %#x\n", hr);
766 ok(IsEqualGUID(&format, &GUID_MetadataFormatIfd), "unexpected format %s\n", wine_dbgstr_guid(&format));
768 hr = IWICMetadataReader_GetMetadataFormat(reader, NULL);
769 ok(hr == E_INVALIDARG, "GetMetadataFormat should fail\n");
771 hr = IWICMetadataReader_GetValueByIndex(reader, 0, NULL, NULL, NULL);
772 ok(hr == S_OK, "GetValueByIndex error %#x\n", hr);
774 PropVariantInit(&schema);
775 PropVariantInit(&id);
776 PropVariantInit(&value);
778 hr = IWICMetadataReader_GetValueByIndex(reader, count - 1, NULL, NULL, NULL);
779 ok(hr == S_OK, "GetValueByIndex error %#x\n", hr);
781 hr = IWICMetadataReader_GetValueByIndex(reader, 0, &schema, NULL, NULL);
782 ok(hr == S_OK, "GetValueByIndex error %#x\n", hr);
783 ok(schema.vt == VT_EMPTY, "unexpected vt: %u\n", schema.vt);
785 hr = IWICMetadataReader_GetValueByIndex(reader, count - 1, &schema, NULL, NULL);
786 ok(hr == S_OK, "GetValueByIndex error %#x\n", hr);
787 ok(schema.vt == VT_EMPTY, "unexpected vt: %u\n", schema.vt);
789 hr = IWICMetadataReader_GetValueByIndex(reader, 0, NULL, &id, NULL);
790 ok(hr == S_OK, "GetValueByIndex error %#x\n", hr);
791 ok(id.vt == VT_UI2, "unexpected vt: %u\n", id.vt);
792 ok(U(id).uiVal == 0xfe, "unexpected id: %#x\n", U(id).uiVal);
793 PropVariantClear(&id);
795 hr = IWICMetadataReader_GetValueByIndex(reader, 0, NULL, NULL, &value);
796 ok(hr == S_OK, "GetValueByIndex error %#x\n", hr);
797 ok(value.vt == VT_UI2, "unexpected vt: %u\n", value.vt);
798 ok(U(value).uiVal == 1, "unexpected id: %#x\n", U(value).uiVal);
799 PropVariantClear(&value);
801 hr = IWICMetadataReader_GetValueByIndex(reader, count, &schema, NULL, NULL);
802 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
804 PropVariantInit(&schema);
805 PropVariantInit(&id);
806 PropVariantInit(&value);
808 hr = IWICMetadataReader_GetValue(reader, &schema, &id, &value);
809 ok(hr == WINCODEC_ERR_PROPERTYNOTFOUND, "expected WINCODEC_ERR_PROPERTYNOTFOUND, got %#x\n", hr);
811 hr = IWICMetadataReader_GetValue(reader, NULL, &id, NULL);
812 ok(hr == WINCODEC_ERR_PROPERTYNOTFOUND, "expected WINCODEC_ERR_PROPERTYNOTFOUND, got %#x\n", hr);
814 hr = IWICMetadataReader_GetValue(reader, &schema, NULL, NULL);
815 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
817 hr = IWICMetadataReader_GetValue(reader, &schema, &id, NULL);
818 ok(hr == WINCODEC_ERR_PROPERTYNOTFOUND, "expected WINCODEC_ERR_PROPERTYNOTFOUND, got %#x\n", hr);
820 hr = IWICMetadataReader_GetValue(reader, &schema, NULL, &value);
821 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
823 id.vt = VT_UI2;
824 U(id).uiVal = 0xf00e;
825 hr = IWICMetadataReader_GetValue(reader, NULL, &id, NULL);
826 ok(hr == S_OK, "GetValue error %#x\n", hr);
828 /* schema is ignored by Ifd metadata reader */
829 schema.vt = VT_UI4;
830 U(schema).ulVal = 0xdeadbeef;
831 hr = IWICMetadataReader_GetValue(reader, &schema, &id, &value);
832 ok(hr == S_OK, "GetValue error %#x\n", hr);
833 ok(value.vt == VT_LPSTR, "unexpected vt: %i\n", id.vt);
834 ok(!strcmp(U(value).pszVal, "Hello World!"), "unexpected value: %s\n", U(value).pszVal);
835 PropVariantClear(&value);
837 hr = IWICMetadataReader_GetValue(reader, NULL, &id, &value);
838 ok(hr == S_OK, "GetValue error %#x\n", hr);
839 ok(value.vt == VT_LPSTR, "unexpected vt: %i\n", id.vt);
840 ok(!strcmp(U(value).pszVal, "Hello World!"), "unexpected value: %s\n", U(value).pszVal);
841 PropVariantClear(&value);
843 hr = IWICMetadataReader_QueryInterface(reader, &IID_IWICMetadataBlockReader, (void**)&blockreader);
844 ok(hr == E_NOINTERFACE, "QueryInterface failed, hr=%x\n", hr);
846 if (SUCCEEDED(hr))
847 IWICMetadataBlockReader_Release(blockreader);
849 IWICMetadataReader_Release(reader);
852 static void test_metadata_Exif(void)
854 HRESULT hr;
855 IWICMetadataReader *reader;
856 IWICMetadataBlockReader *blockreader;
857 UINT count=0;
859 hr = CoCreateInstance(&CLSID_WICExifMetadataReader, NULL, CLSCTX_INPROC_SERVER,
860 &IID_IWICMetadataReader, (void**)&reader);
861 todo_wine ok(hr == S_OK, "CoCreateInstance error %#x\n", hr);
862 if (FAILED(hr)) return;
864 hr = IWICMetadataReader_GetCount(reader, NULL);
865 ok(hr == E_INVALIDARG, "GetCount error %#x\n", hr);
867 hr = IWICMetadataReader_GetCount(reader, &count);
868 ok(hr == S_OK, "GetCount error %#x\n", hr);
869 ok(count == 0, "unexpected count %u\n", count);
871 hr = IWICMetadataReader_QueryInterface(reader, &IID_IWICMetadataBlockReader, (void**)&blockreader);
872 ok(hr == E_NOINTERFACE, "QueryInterface failed, hr=%x\n", hr);
874 if (SUCCEEDED(hr))
875 IWICMetadataBlockReader_Release(blockreader);
877 IWICMetadataReader_Release(reader);
880 static void test_create_reader(void)
882 HRESULT hr;
883 IWICComponentFactory *factory;
884 IStream *stream;
885 IWICMetadataReader *reader;
886 UINT count=0;
887 GUID format;
889 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
890 &IID_IWICComponentFactory, (void**)&factory);
891 ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
893 stream = create_stream(metadata_tEXt, sizeof(metadata_tEXt));
895 hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
896 NULL, NULL, WICPersistOptionsDefault,
897 stream, &reader);
898 ok(hr == E_INVALIDARG, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
900 hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
901 &GUID_ContainerFormatPng, NULL, WICPersistOptionsDefault,
902 NULL, &reader);
903 ok(hr == E_INVALIDARG, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
905 hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
906 &GUID_ContainerFormatPng, NULL, WICPersistOptionsDefault,
907 stream, NULL);
908 ok(hr == E_INVALIDARG, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
910 hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
911 &GUID_ContainerFormatPng, NULL, WICPersistOptionsDefault,
912 stream, &reader);
913 ok(hr == S_OK, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
915 if (SUCCEEDED(hr))
917 hr = IWICMetadataReader_GetCount(reader, &count);
918 ok(hr == S_OK, "GetCount failed, hr=%x\n", hr);
919 ok(count == 1, "unexpected count %i\n", count);
921 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
922 ok(hr == S_OK, "GetMetadataFormat failed, hr=%x\n", hr);
923 ok(IsEqualGUID(&format, &GUID_MetadataFormatChunktEXt), "unexpected format %s\n", wine_dbgstr_guid(&format));
925 IWICMetadataReader_Release(reader);
928 hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
929 &GUID_ContainerFormatWmp, NULL, WICPersistOptionsDefault,
930 stream, &reader);
931 ok(hr == S_OK, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr);
933 if (SUCCEEDED(hr))
935 hr = IWICMetadataReader_GetCount(reader, &count);
936 ok(hr == S_OK, "GetCount failed, hr=%x\n", hr);
937 ok(count == 1, "unexpected count %i\n", count);
939 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
940 ok(hr == S_OK, "GetMetadataFormat failed, hr=%x\n", hr);
941 ok(IsEqualGUID(&format, &GUID_MetadataFormatUnknown), "unexpected format %s\n", wine_dbgstr_guid(&format));
943 IWICMetadataReader_Release(reader);
946 IStream_Release(stream);
948 IWICComponentFactory_Release(factory);
951 static void test_metadata_png(void)
953 static const struct test_data td[6] =
955 { VT_UI2, 0, 0, { 2005 }, NULL, { 'Y','e','a','r',0 } },
956 { VT_UI1, 0, 0, { 6 }, NULL, { 'M','o','n','t','h',0 } },
957 { VT_UI1, 0, 0, { 3 }, NULL, { 'D','a','y',0 } },
958 { VT_UI1, 0, 0, { 15 }, NULL, { 'H','o','u','r',0 } },
959 { VT_UI1, 0, 0, { 7 }, NULL, { 'M','i','n','u','t','e',0 } },
960 { VT_UI1, 0, 0, { 45 }, NULL, { 'S','e','c','o','n','d',0 } }
962 IStream *stream;
963 IWICBitmapDecoder *decoder;
964 IWICBitmapFrameDecode *frame;
965 IWICMetadataBlockReader *blockreader;
966 IWICMetadataReader *reader;
967 GUID containerformat;
968 HRESULT hr;
969 UINT count=0xdeadbeef;
971 hr = CoCreateInstance(&CLSID_WICPngDecoder, NULL, CLSCTX_INPROC_SERVER,
972 &IID_IWICBitmapDecoder, (void**)&decoder);
973 ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
975 if (FAILED(hr)) return;
977 stream = create_stream(pngimage, sizeof(pngimage));
979 hr = IWICBitmapDecoder_Initialize(decoder, stream, WICDecodeMetadataCacheOnLoad);
980 ok(hr == S_OK, "Initialize failed, hr=%x\n", hr);
982 hr = IWICBitmapDecoder_QueryInterface(decoder, &IID_IWICMetadataBlockReader, (void**)&blockreader);
983 ok(hr == E_NOINTERFACE, "QueryInterface failed, hr=%x\n", hr);
985 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
986 ok(hr == S_OK, "GetFrame failed, hr=%x\n", hr);
988 hr = IWICBitmapFrameDecode_QueryInterface(frame, &IID_IWICMetadataBlockReader, (void**)&blockreader);
989 ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
991 if (SUCCEEDED(hr))
993 hr = IWICMetadataBlockReader_GetContainerFormat(blockreader, NULL);
994 ok(hr == E_INVALIDARG, "GetContainerFormat failed, hr=%x\n", hr);
996 hr = IWICMetadataBlockReader_GetContainerFormat(blockreader, &containerformat);
997 ok(hr == S_OK, "GetContainerFormat failed, hr=%x\n", hr);
998 ok(IsEqualGUID(&containerformat, &GUID_ContainerFormatPng), "unexpected container format\n");
1000 hr = IWICMetadataBlockReader_GetCount(blockreader, NULL);
1001 ok(hr == E_INVALIDARG, "GetCount failed, hr=%x\n", hr);
1003 hr = IWICMetadataBlockReader_GetCount(blockreader, &count);
1004 ok(hr == S_OK, "GetCount failed, hr=%x\n", hr);
1005 ok(count == 1, "unexpected count %d\n", count);
1007 if (0)
1009 /* Crashes on Windows XP */
1010 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 0, NULL);
1011 ok(hr == E_INVALIDARG, "GetReaderByIndex failed, hr=%x\n", hr);
1014 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 0, &reader);
1015 ok(hr == S_OK, "GetReaderByIndex failed, hr=%x\n", hr);
1017 if (SUCCEEDED(hr))
1019 hr = IWICMetadataReader_GetMetadataFormat(reader, &containerformat);
1020 ok(hr == S_OK, "GetMetadataFormat failed, hr=%#x\n", hr);
1021 todo_wine ok(IsEqualGUID(&containerformat, &GUID_MetadataFormatChunktIME) ||
1022 broken(IsEqualGUID(&containerformat, &GUID_MetadataFormatUnknown)) /* Windows XP */,
1023 "unexpected container format\n");
1025 hr = IWICMetadataReader_GetCount(reader, &count);
1026 ok(hr == S_OK, "GetCount error %#x\n", hr);
1027 todo_wine ok(count == 6 || broken(count == 1) /* XP */, "expected 6, got %u\n", count);
1028 if (count == 6)
1029 compare_metadata(reader, td, count);
1031 IWICMetadataReader_Release(reader);
1034 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 1, &reader);
1035 todo_wine ok(hr == WINCODEC_ERR_VALUEOUTOFRANGE, "GetReaderByIndex failed, hr=%x\n", hr);
1037 IWICMetadataBlockReader_Release(blockreader);
1040 IWICBitmapFrameDecode_Release(frame);
1042 IWICBitmapDecoder_Release(decoder);
1044 IStream_Release(stream);
1047 static void test_metadata_gif(void)
1049 static const struct test_data gif_LSD[9] =
1051 { VT_UI1|VT_VECTOR, 0, 6, {'G','I','F','8','7','a'}, NULL, { 'S','i','g','n','a','t','u','r','e',0 } },
1052 { VT_UI2, 0, 0, { 1 }, NULL, { 'W','i','d','t','h',0 } },
1053 { VT_UI2, 0, 0, { 1 }, NULL, { 'H','e','i','g','h','t',0 } },
1054 { VT_BOOL, 0, 0, { 1 }, NULL, { 'G','l','o','b','a','l','C','o','l','o','r','T','a','b','l','e','F','l','a','g',0 } },
1055 { VT_UI1, 0, 0, { 0 }, NULL, { 'C','o','l','o','r','R','e','s','o','l','u','t','i','o','n',0 } },
1056 { VT_BOOL, 0, 0, { 0 }, NULL, { 'S','o','r','t','F','l','a','g',0 } },
1057 { VT_UI1, 0, 0, { 0 }, NULL, { 'G','l','o','b','a','l','C','o','l','o','r','T','a','b','l','e','S','i','z','e',0 } },
1058 { VT_UI1, 0, 0, { 0 }, NULL, { 'B','a','c','k','g','r','o','u','n','d','C','o','l','o','r','I','n','d','e','x',0 } },
1059 { VT_UI1, 0, 0, { 0 }, NULL, { 'P','i','x','e','l','A','s','p','e','c','t','R','a','t','i','o',0 } }
1061 static const struct test_data gif_IMD[8] =
1063 { VT_UI2, 0, 0, { 0 }, NULL, { 'L','e','f','t',0 } },
1064 { VT_UI2, 0, 0, { 0 }, NULL, { 'T','o','p',0 } },
1065 { VT_UI2, 0, 0, { 1 }, NULL, { 'W','i','d','t','h',0 } },
1066 { VT_UI2, 0, 0, { 1 }, NULL, { 'H','e','i','g','h','t',0 } },
1067 { VT_BOOL, 0, 0, { 0 }, NULL, { 'L','o','c','a','l','C','o','l','o','r','T','a','b','l','e','F','l','a','g',0 } },
1068 { VT_BOOL, 0, 0, { 0 }, NULL, { 'I','n','t','e','r','l','a','c','e','F','l','a','g',0 } },
1069 { VT_BOOL, 0, 0, { 0 }, NULL, { 'S','o','r','t','F','l','a','g',0 } },
1070 { VT_UI1, 0, 0, { 0 }, NULL, { 'L','o','c','a','l','C','o','l','o','r','T','a','b','l','e','S','i','z','e',0 } }
1072 static const struct test_data animated_gif_LSD[9] =
1074 { VT_UI1|VT_VECTOR, 0, 6, {'G','I','F','8','9','a'}, NULL, { 'S','i','g','n','a','t','u','r','e',0 } },
1075 { VT_UI2, 0, 0, { 1 }, NULL, { 'W','i','d','t','h',0 } },
1076 { VT_UI2, 0, 0, { 1 }, NULL, { 'H','e','i','g','h','t',0 } },
1077 { VT_BOOL, 0, 0, { 1 }, NULL, { 'G','l','o','b','a','l','C','o','l','o','r','T','a','b','l','e','F','l','a','g',0 } },
1078 { VT_UI1, 0, 0, { 2 }, NULL, { 'C','o','l','o','r','R','e','s','o','l','u','t','i','o','n',0 } },
1079 { VT_BOOL, 0, 0, { 0 }, NULL, { 'S','o','r','t','F','l','a','g',0 } },
1080 { VT_UI1, 0, 0, { 1 }, NULL, { 'G','l','o','b','a','l','C','o','l','o','r','T','a','b','l','e','S','i','z','e',0 } },
1081 { VT_UI1, 0, 0, { 0 }, NULL, { 'B','a','c','k','g','r','o','u','n','d','C','o','l','o','r','I','n','d','e','x',0 } },
1082 { VT_UI1, 0, 0, { 0 }, NULL, { 'P','i','x','e','l','A','s','p','e','c','t','R','a','t','i','o',0 } }
1084 static const struct test_data animated_gif_IMD[8] =
1086 { VT_UI2, 0, 0, { 0 }, NULL, { 'L','e','f','t',0 } },
1087 { VT_UI2, 0, 0, { 0 }, NULL, { 'T','o','p',0 } },
1088 { VT_UI2, 0, 0, { 1 }, NULL, { 'W','i','d','t','h',0 } },
1089 { VT_UI2, 0, 0, { 1 }, NULL, { 'H','e','i','g','h','t',0 } },
1090 { VT_BOOL, 0, 0, { 1 }, NULL, { 'L','o','c','a','l','C','o','l','o','r','T','a','b','l','e','F','l','a','g',0 } },
1091 { VT_BOOL, 0, 0, { 0 }, NULL, { 'I','n','t','e','r','l','a','c','e','F','l','a','g',0 } },
1092 { VT_BOOL, 0, 0, { 0 }, NULL, { 'S','o','r','t','F','l','a','g',0 } },
1093 { VT_UI1, 0, 0, { 1 }, NULL, { 'L','o','c','a','l','C','o','l','o','r','T','a','b','l','e','S','i','z','e',0 } }
1095 static const struct test_data animated_gif_GCE[5] =
1097 { VT_UI1, 0, 0, { 0 }, NULL, { 'D','i','s','p','o','s','a','l',0 } },
1098 { VT_BOOL, 0, 0, { 0 }, NULL, { 'U','s','e','r','I','n','p','u','t','F','l','a','g',0 } },
1099 { VT_BOOL, 0, 0, { 1 }, NULL, { 'T','r','a','n','s','p','a','r','e','n','c','y','F','l','a','g',0 } },
1100 { VT_UI2, 0, 0, { 10 }, NULL, { 'D','e','l','a','y',0 } },
1101 { VT_UI1, 0, 0, { 1 }, NULL, { 'T','r','a','n','s','p','a','r','e','n','t','C','o','l','o','r','I','n','d','e','x',0 } }
1103 static const struct test_data animated_gif_APE[2] =
1105 { VT_UI1|VT_VECTOR, 0, 11, { 'A','N','I','M','E','X','T','S','1','.','0' }, NULL, { 'A','p','p','l','i','c','a','t','i','o','n',0 } },
1106 { VT_UI1|VT_VECTOR, 0, 4, { 0x03,0x01,0x05,0x00 }, NULL, { 'D','a','t','a',0 } }
1108 static const struct test_data animated_gif_comment_1[1] =
1110 { VT_LPSTR, 0, 12, { 0 }, "Hello World!", { 'T','e','x','t','E','n','t','r','y',0 } }
1112 static const struct test_data animated_gif_comment_2[1] =
1114 { VT_LPSTR, 0, 8, { 0 }, "image #1", { 'T','e','x','t','E','n','t','r','y',0 } }
1116 static const struct test_data animated_gif_plain_1[1] =
1118 { VT_BLOB, 0, 17, { 0 }, "\x21\x01\x0d\x61nimation.gif" }
1120 static const struct test_data animated_gif_plain_2[1] =
1122 { VT_BLOB, 0, 16, { 0 }, "\x21\x01\x0cplaintext #1" }
1124 IStream *stream;
1125 IWICBitmapDecoder *decoder;
1126 IWICBitmapFrameDecode *frame;
1127 IWICMetadataBlockReader *blockreader;
1128 IWICMetadataReader *reader;
1129 GUID format;
1130 HRESULT hr;
1131 UINT count;
1133 /* 1x1 pixel gif */
1134 stream = create_stream(gifimage, sizeof(gifimage));
1136 hr = CoCreateInstance(&CLSID_WICGifDecoder, NULL, CLSCTX_INPROC_SERVER,
1137 &IID_IWICBitmapDecoder, (void **)&decoder);
1138 ok(hr == S_OK, "CoCreateInstance error %#x\n", hr);
1139 hr = IWICBitmapDecoder_Initialize(decoder, stream, WICDecodeMetadataCacheOnLoad);
1140 ok(hr == S_OK, "Initialize error %#x\n", hr);
1142 IStream_Release(stream);
1144 /* global metadata block */
1145 hr = IWICBitmapDecoder_QueryInterface(decoder, &IID_IWICMetadataBlockReader, (void **)&blockreader);
1146 ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* before Win7 */, "QueryInterface error %#x\n", hr);
1148 if (SUCCEEDED(hr))
1150 hr = IWICMetadataBlockReader_GetContainerFormat(blockreader, &format);
1151 ok(hr == S_OK, "GetContainerFormat error %#x\n", hr);
1152 ok(IsEqualGUID(&format, &GUID_ContainerFormatGif),
1153 "wrong container format %s\n", wine_dbgstr_guid(&format));
1155 hr = IWICMetadataBlockReader_GetCount(blockreader, &count);
1156 ok(hr == S_OK, "GetCount error %#x\n", hr);
1157 ok(count == 1, "expected 1, got %u\n", count);
1159 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 0, &reader);
1160 ok(hr == S_OK, "GetReaderByIndex error %#x\n", hr);
1162 if (SUCCEEDED(hr))
1164 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
1165 ok(hr == S_OK, "GetMetadataFormat failed, hr=%#x\n", hr);
1166 ok(IsEqualGUID(&format, &GUID_MetadataFormatLSD), /* Logical Screen Descriptor */
1167 "wrong metadata format %s\n", wine_dbgstr_guid(&format));
1169 hr = IWICMetadataReader_GetCount(reader, &count);
1170 ok(hr == S_OK, "GetCount error %#x\n", hr);
1171 ok(count == sizeof(gif_LSD)/sizeof(gif_LSD[0]), "unexpected count %u\n", count);
1173 compare_metadata(reader, gif_LSD, count);
1175 IWICMetadataReader_Release(reader);
1178 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 1, &reader);
1179 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
1181 IWICMetadataBlockReader_Release(blockreader);
1184 /* frame metadata block */
1185 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
1186 ok(hr == S_OK, "GetFrame error %#x\n", hr);
1188 hr = IWICBitmapFrameDecode_QueryInterface(frame, &IID_IWICMetadataBlockReader, (void **)&blockreader);
1189 ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* before Win7 */, "QueryInterface error %#x\n", hr);
1191 if (SUCCEEDED(hr))
1193 hr = IWICMetadataBlockReader_GetContainerFormat(blockreader, NULL);
1194 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
1196 hr = IWICMetadataBlockReader_GetContainerFormat(blockreader, &format);
1197 ok(hr == S_OK, "GetContainerFormat error %#x\n", hr);
1198 ok(IsEqualGUID(&format, &GUID_ContainerFormatGif),
1199 "wrong container format %s\n", wine_dbgstr_guid(&format));
1201 hr = IWICMetadataBlockReader_GetCount(blockreader, NULL);
1202 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
1204 hr = IWICMetadataBlockReader_GetCount(blockreader, &count);
1205 ok(hr == S_OK, "GetCount error %#x\n", hr);
1206 ok(count == 1, "expected 1, got %u\n", count);
1208 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 0, &reader);
1209 ok(hr == S_OK, "GetReaderByIndex error %#x\n", hr);
1211 if (SUCCEEDED(hr))
1213 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
1214 ok(hr == S_OK, "GetMetadataFormat failed, hr=%#x\n", hr);
1215 ok(IsEqualGUID(&format, &GUID_MetadataFormatIMD), /* Image Descriptor */
1216 "wrong metadata format %s\n", wine_dbgstr_guid(&format));
1218 hr = IWICMetadataReader_GetCount(reader, &count);
1219 ok(hr == S_OK, "GetCount error %#x\n", hr);
1220 ok(count == sizeof(gif_IMD)/sizeof(gif_IMD[0]), "unexpected count %u\n", count);
1222 compare_metadata(reader, gif_IMD, count);
1224 IWICMetadataReader_Release(reader);
1227 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 1, &reader);
1228 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
1230 IWICMetadataBlockReader_Release(blockreader);
1233 IWICBitmapFrameDecode_Release(frame);
1234 IWICBitmapDecoder_Release(decoder);
1236 /* 1x1 pixel gif, 2 frames */
1237 stream = create_stream(animatedgif, sizeof(animatedgif));
1239 hr = CoCreateInstance(&CLSID_WICGifDecoder, NULL, CLSCTX_INPROC_SERVER,
1240 &IID_IWICBitmapDecoder, (void **)&decoder);
1241 ok(hr == S_OK, "CoCreateInstance error %#x\n", hr);
1242 hr = IWICBitmapDecoder_Initialize(decoder, stream, WICDecodeMetadataCacheOnLoad);
1243 ok(hr == S_OK, "Initialize error %#x\n", hr);
1245 IStream_Release(stream);
1247 /* global metadata block */
1248 hr = IWICBitmapDecoder_QueryInterface(decoder, &IID_IWICMetadataBlockReader, (void **)&blockreader);
1249 ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* before Win7 */, "QueryInterface error %#x\n", hr);
1251 if (SUCCEEDED(hr))
1253 hr = IWICMetadataBlockReader_GetContainerFormat(blockreader, &format);
1254 ok(hr == S_OK, "GetContainerFormat error %#x\n", hr);
1255 ok(IsEqualGUID(&format, &GUID_ContainerFormatGif),
1256 "wrong container format %s\n", wine_dbgstr_guid(&format));
1258 hr = IWICMetadataBlockReader_GetCount(blockreader, &count);
1259 ok(hr == S_OK, "GetCount error %#x\n", hr);
1260 ok(count == 4, "expected 4, got %u\n", count);
1262 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 0, &reader);
1263 ok(hr == S_OK, "GetReaderByIndex error %#x\n", hr);
1265 if (SUCCEEDED(hr))
1267 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
1268 ok(hr == S_OK, "GetMetadataFormat failed, hr=%#x\n", hr);
1269 ok(IsEqualGUID(&format, &GUID_MetadataFormatLSD), /* Logical Screen Descriptor */
1270 "wrong metadata format %s\n", wine_dbgstr_guid(&format));
1272 hr = IWICMetadataReader_GetCount(reader, &count);
1273 ok(hr == S_OK, "GetCount error %#x\n", hr);
1274 ok(count == sizeof(animated_gif_LSD)/sizeof(animated_gif_LSD[0]), "unexpected count %u\n", count);
1276 compare_metadata(reader, animated_gif_LSD, count);
1278 IWICMetadataReader_Release(reader);
1281 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 1, &reader);
1282 ok(hr == S_OK, "GetReaderByIndex error %#x\n", hr);
1284 if (SUCCEEDED(hr))
1286 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
1287 ok(hr == S_OK, "GetMetadataFormat failed, hr=%#x\n", hr);
1288 ok(IsEqualGUID(&format, &GUID_MetadataFormatAPE), /* Application Extension */
1289 "wrong metadata format %s\n", wine_dbgstr_guid(&format));
1291 hr = IWICMetadataReader_GetCount(reader, &count);
1292 ok(hr == S_OK, "GetCount error %#x\n", hr);
1293 ok(count == sizeof(animated_gif_APE)/sizeof(animated_gif_APE[0]), "unexpected count %u\n", count);
1295 compare_metadata(reader, animated_gif_APE, count);
1297 IWICMetadataReader_Release(reader);
1300 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 2, &reader);
1301 ok(hr == S_OK, "GetReaderByIndex error %#x\n", hr);
1303 if (SUCCEEDED(hr))
1305 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
1306 ok(hr == S_OK, "GetMetadataFormat failed, hr=%#x\n", hr);
1307 ok(IsEqualGUID(&format, &GUID_MetadataFormatGifComment), /* Comment Extension */
1308 "wrong metadata format %s\n", wine_dbgstr_guid(&format));
1310 hr = IWICMetadataReader_GetCount(reader, &count);
1311 ok(hr == S_OK, "GetCount error %#x\n", hr);
1312 ok(count == sizeof(animated_gif_comment_1)/sizeof(animated_gif_comment_1[0]), "unexpected count %u\n", count);
1314 compare_metadata(reader, animated_gif_comment_1, count);
1316 IWICMetadataReader_Release(reader);
1319 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 3, &reader);
1320 ok(hr == S_OK, "GetReaderByIndex error %#x\n", hr);
1322 if (SUCCEEDED(hr))
1324 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
1325 ok(hr == S_OK, "GetMetadataFormat failed, hr=%#x\n", hr);
1326 ok(IsEqualGUID(&format, &GUID_MetadataFormatUnknown),
1327 "wrong metadata format %s\n", wine_dbgstr_guid(&format));
1329 hr = IWICMetadataReader_GetCount(reader, &count);
1330 ok(hr == S_OK, "GetCount error %#x\n", hr);
1331 ok(count == sizeof(animated_gif_plain_1)/sizeof(animated_gif_plain_1[0]), "unexpected count %u\n", count);
1333 compare_metadata(reader, animated_gif_plain_1, count);
1335 IWICMetadataReader_Release(reader);
1338 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 4, &reader);
1339 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
1341 IWICMetadataBlockReader_Release(blockreader);
1344 /* frame metadata block */
1345 hr = IWICBitmapDecoder_GetFrame(decoder, 1, &frame);
1346 ok(hr == S_OK, "GetFrame error %#x\n", hr);
1348 hr = IWICBitmapFrameDecode_QueryInterface(frame, &IID_IWICMetadataBlockReader, (void **)&blockreader);
1349 ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* before Win7 */, "QueryInterface error %#x\n", hr);
1351 if (SUCCEEDED(hr))
1353 hr = IWICMetadataBlockReader_GetContainerFormat(blockreader, NULL);
1354 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
1356 hr = IWICMetadataBlockReader_GetContainerFormat(blockreader, &format);
1357 ok(hr == S_OK, "GetContainerFormat error %#x\n", hr);
1358 ok(IsEqualGUID(&format, &GUID_ContainerFormatGif),
1359 "wrong container format %s\n", wine_dbgstr_guid(&format));
1361 hr = IWICMetadataBlockReader_GetCount(blockreader, NULL);
1362 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
1364 hr = IWICMetadataBlockReader_GetCount(blockreader, &count);
1365 ok(hr == S_OK, "GetCount error %#x\n", hr);
1366 ok(count == 4, "expected 4, got %u\n", count);
1368 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 0, &reader);
1369 ok(hr == S_OK, "GetReaderByIndex error %#x\n", hr);
1371 if (SUCCEEDED(hr))
1373 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
1374 ok(hr == S_OK, "GetMetadataFormat failed, hr=%#x\n", hr);
1375 ok(IsEqualGUID(&format, &GUID_MetadataFormatIMD), /* Image Descriptor */
1376 "wrong metadata format %s\n", wine_dbgstr_guid(&format));
1378 hr = IWICMetadataReader_GetCount(reader, &count);
1379 ok(hr == S_OK, "GetCount error %#x\n", hr);
1380 ok(count == sizeof(animated_gif_IMD)/sizeof(animated_gif_IMD[0]), "unexpected count %u\n", count);
1382 compare_metadata(reader, animated_gif_IMD, count);
1384 IWICMetadataReader_Release(reader);
1387 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 1, &reader);
1388 ok(hr == S_OK, "GetReaderByIndex error %#x\n", hr);
1390 if (SUCCEEDED(hr))
1392 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
1393 ok(hr == S_OK, "GetMetadataFormat failed, hr=%#x\n", hr);
1394 ok(IsEqualGUID(&format, &GUID_MetadataFormatGifComment), /* Comment Extension */
1395 "wrong metadata format %s\n", wine_dbgstr_guid(&format));
1397 hr = IWICMetadataReader_GetCount(reader, &count);
1398 ok(hr == S_OK, "GetCount error %#x\n", hr);
1399 ok(count == sizeof(animated_gif_comment_2)/sizeof(animated_gif_comment_2[0]), "unexpected count %u\n", count);
1401 if (count == 1)
1402 compare_metadata(reader, animated_gif_comment_2, count);
1404 IWICMetadataReader_Release(reader);
1407 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 2, &reader);
1408 ok(hr == S_OK, "GetReaderByIndex error %#x\n", hr);
1410 if (SUCCEEDED(hr))
1412 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
1413 ok(hr == S_OK, "GetMetadataFormat failed, hr=%#x\n", hr);
1414 ok(IsEqualGUID(&format, &GUID_MetadataFormatUnknown),
1415 "wrong metadata format %s\n", wine_dbgstr_guid(&format));
1417 hr = IWICMetadataReader_GetCount(reader, &count);
1418 ok(hr == S_OK, "GetCount error %#x\n", hr);
1419 ok(count == sizeof(animated_gif_plain_2)/sizeof(animated_gif_plain_2[0]), "unexpected count %u\n", count);
1421 compare_metadata(reader, animated_gif_plain_2, count);
1423 IWICMetadataReader_Release(reader);
1426 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 3, &reader);
1427 ok(hr == S_OK, "GetReaderByIndex error %#x\n", hr);
1429 if (SUCCEEDED(hr))
1431 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
1432 ok(hr == S_OK, "GetMetadataFormat failed, hr=%#x\n", hr);
1433 ok(IsEqualGUID(&format, &GUID_MetadataFormatGCE), /* Graphic Control Extension */
1434 "wrong metadata format %s\n", wine_dbgstr_guid(&format));
1436 hr = IWICMetadataReader_GetCount(reader, &count);
1437 ok(hr == S_OK, "GetCount error %#x\n", hr);
1438 ok(count == sizeof(animated_gif_GCE)/sizeof(animated_gif_GCE[0]), "unexpected count %u\n", count);
1440 compare_metadata(reader, animated_gif_GCE, count);
1442 IWICMetadataReader_Release(reader);
1445 hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 4, &reader);
1446 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
1448 IWICMetadataBlockReader_Release(blockreader);
1451 IWICBitmapFrameDecode_Release(frame);
1452 IWICBitmapDecoder_Release(decoder);
1455 static void test_metadata_LSD(void)
1457 static const WCHAR LSD_name[] = {'L','o','g','i','c','a','l',' ','S','c','r','e','e','n',' ','D','e','s','c','r','i','p','t','o','r',' ','R','e','a','d','e','r',0};
1458 static const char LSD_data[] = "hello world!\x1\x2\x3\x4\xab\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf";
1459 static const struct test_data td[9] =
1461 { VT_UI1|VT_VECTOR, 0, 6, {'w','o','r','l','d','!'}, NULL, { 'S','i','g','n','a','t','u','r','e',0 } },
1462 { VT_UI2, 0, 0, { 0x201 }, NULL, { 'W','i','d','t','h',0 } },
1463 { VT_UI2, 0, 0, { 0x403 }, NULL, { 'H','e','i','g','h','t',0 } },
1464 { VT_BOOL, 0, 0, { 1 }, NULL, { 'G','l','o','b','a','l','C','o','l','o','r','T','a','b','l','e','F','l','a','g',0 } },
1465 { VT_UI1, 0, 0, { 2 }, NULL, { 'C','o','l','o','r','R','e','s','o','l','u','t','i','o','n',0 } },
1466 { VT_BOOL, 0, 0, { 1 }, NULL, { 'S','o','r','t','F','l','a','g',0 } },
1467 { VT_UI1, 0, 0, { 3 }, NULL, { 'G','l','o','b','a','l','C','o','l','o','r','T','a','b','l','e','S','i','z','e',0 } },
1468 { VT_UI1, 0, 0, { 6 }, NULL, { 'B','a','c','k','g','r','o','u','n','d','C','o','l','o','r','I','n','d','e','x',0 } },
1469 { VT_UI1, 0, 0, { 7 }, NULL, { 'P','i','x','e','l','A','s','p','e','c','t','R','a','t','i','o',0 } }
1471 LARGE_INTEGER pos;
1472 HRESULT hr;
1473 IStream *stream;
1474 IWICPersistStream *persist;
1475 IWICMetadataReader *reader;
1476 IWICMetadataHandlerInfo *info;
1477 WCHAR name[64];
1478 UINT count, dummy;
1479 GUID format;
1480 CLSID id;
1482 hr = CoCreateInstance(&CLSID_WICLSDMetadataReader, NULL, CLSCTX_INPROC_SERVER,
1483 &IID_IWICMetadataReader, (void **)&reader);
1484 ok(hr == S_OK || broken(hr == E_NOINTERFACE || hr == REGDB_E_CLASSNOTREG) /* before Win7 */,
1485 "CoCreateInstance error %#x\n", hr);
1487 stream = create_stream(LSD_data, sizeof(LSD_data));
1489 if (SUCCEEDED(hr))
1491 pos.QuadPart = 6;
1492 hr = IStream_Seek(stream, pos, SEEK_SET, NULL);
1493 ok(hr == S_OK, "IStream_Seek error %#x\n", hr);
1495 hr = IUnknown_QueryInterface(reader, &IID_IWICPersistStream, (void **)&persist);
1496 ok(hr == S_OK, "QueryInterface error %#x\n", hr);
1498 hr = IWICPersistStream_Load(persist, stream);
1499 ok(hr == S_OK, "Load error %#x\n", hr);
1501 IWICPersistStream_Release(persist);
1504 if (SUCCEEDED(hr))
1506 hr = IWICMetadataReader_GetCount(reader, &count);
1507 ok(hr == S_OK, "GetCount error %#x\n", hr);
1508 ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
1510 compare_metadata(reader, td, count);
1512 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
1513 ok(hr == S_OK, "GetMetadataFormat error %#x\n", hr);
1514 ok(IsEqualGUID(&format, &GUID_MetadataFormatLSD), "wrong format %s\n", wine_dbgstr_guid(&format));
1516 hr = IWICMetadataReader_GetMetadataHandlerInfo(reader, &info);
1517 ok(hr == S_OK, "GetMetadataHandlerInfo error %#x\n", hr);
1519 hr = IWICMetadataHandlerInfo_GetCLSID(info, &id);
1520 ok(hr == S_OK, "GetCLSID error %#x\n", hr);
1521 ok(IsEqualGUID(&id, &CLSID_WICLSDMetadataReader), "wrong CLSID %s\n", wine_dbgstr_guid(&id));
1523 hr = IWICMetadataHandlerInfo_GetFriendlyName(info, 64, name, &dummy);
1524 ok(hr == S_OK, "GetFriendlyName error %#x\n", hr);
1525 ok(lstrcmpW(name, LSD_name) == 0, "wrong LSD reader name %s\n", wine_dbgstr_w(name));
1527 IWICMetadataHandlerInfo_Release(info);
1528 IWICMetadataReader_Release(reader);
1531 IStream_Release(stream);
1534 static void test_metadata_IMD(void)
1536 static const WCHAR IMD_name[] = {'I','m','a','g','e',' ','D','e','s','c','r','i','p','t','o','r',' ','R','e','a','d','e','r',0};
1537 static const char IMD_data[] = "hello world!\x1\x2\x3\x4\x5\x6\x7\x8\xed\xa\xb\xc\xd\xe\xf";
1538 static const struct test_data td[8] =
1540 { VT_UI2, 0, 0, { 0x201 }, NULL, { 'L','e','f','t',0 } },
1541 { VT_UI2, 0, 0, { 0x403 }, NULL, { 'T','o','p',0 } },
1542 { VT_UI2, 0, 0, { 0x605 }, NULL, { 'W','i','d','t','h',0 } },
1543 { VT_UI2, 0, 0, { 0x807 }, NULL, { 'H','e','i','g','h','t',0 } },
1544 { VT_BOOL, 0, 0, { 1 }, NULL, { 'L','o','c','a','l','C','o','l','o','r','T','a','b','l','e','F','l','a','g',0 } },
1545 { VT_BOOL, 0, 0, { 1 }, NULL, { 'I','n','t','e','r','l','a','c','e','F','l','a','g',0 } },
1546 { VT_BOOL, 0, 0, { 1 }, NULL, { 'S','o','r','t','F','l','a','g',0 } },
1547 { VT_UI1, 0, 0, { 5 }, NULL, { 'L','o','c','a','l','C','o','l','o','r','T','a','b','l','e','S','i','z','e',0 } }
1549 LARGE_INTEGER pos;
1550 HRESULT hr;
1551 IStream *stream;
1552 IWICPersistStream *persist;
1553 IWICMetadataReader *reader;
1554 IWICMetadataHandlerInfo *info;
1555 WCHAR name[64];
1556 UINT count, dummy;
1557 GUID format;
1558 CLSID id;
1560 hr = CoCreateInstance(&CLSID_WICIMDMetadataReader, NULL, CLSCTX_INPROC_SERVER,
1561 &IID_IWICMetadataReader, (void **)&reader);
1562 ok(hr == S_OK || broken(hr == E_NOINTERFACE || hr == REGDB_E_CLASSNOTREG) /* before Win7 */,
1563 "CoCreateInstance error %#x\n", hr);
1565 stream = create_stream(IMD_data, sizeof(IMD_data));
1567 if (SUCCEEDED(hr))
1569 pos.QuadPart = 12;
1570 hr = IStream_Seek(stream, pos, SEEK_SET, NULL);
1571 ok(hr == S_OK, "IStream_Seek error %#x\n", hr);
1573 hr = IUnknown_QueryInterface(reader, &IID_IWICPersistStream, (void **)&persist);
1574 ok(hr == S_OK, "QueryInterface error %#x\n", hr);
1576 hr = IWICPersistStream_Load(persist, stream);
1577 ok(hr == S_OK, "Load error %#x\n", hr);
1579 IWICPersistStream_Release(persist);
1582 if (SUCCEEDED(hr))
1584 hr = IWICMetadataReader_GetCount(reader, &count);
1585 ok(hr == S_OK, "GetCount error %#x\n", hr);
1586 ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
1588 compare_metadata(reader, td, count);
1590 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
1591 ok(hr == S_OK, "GetMetadataFormat error %#x\n", hr);
1592 ok(IsEqualGUID(&format, &GUID_MetadataFormatIMD), "wrong format %s\n", wine_dbgstr_guid(&format));
1594 hr = IWICMetadataReader_GetMetadataHandlerInfo(reader, &info);
1595 ok(hr == S_OK, "GetMetadataHandlerInfo error %#x\n", hr);
1597 hr = IWICMetadataHandlerInfo_GetCLSID(info, &id);
1598 ok(hr == S_OK, "GetCLSID error %#x\n", hr);
1599 ok(IsEqualGUID(&id, &CLSID_WICIMDMetadataReader), "wrong CLSID %s\n", wine_dbgstr_guid(&id));
1601 hr = IWICMetadataHandlerInfo_GetFriendlyName(info, 64, name, &dummy);
1602 ok(hr == S_OK, "GetFriendlyName error %#x\n", hr);
1603 ok(lstrcmpW(name, IMD_name) == 0, "wrong IMD reader name %s\n", wine_dbgstr_w(name));
1605 IWICMetadataHandlerInfo_Release(info);
1606 IWICMetadataReader_Release(reader);
1609 IStream_Release(stream);
1612 static void test_metadata_GCE(void)
1614 static const WCHAR GCE_name[] = {'G','r','a','p','h','i','c',' ','C','o','n','t','r','o','l',' ','E','x','t','e','n','s','i','o','n',' ','R','e','a','d','e','r',0};
1615 static const char GCE_data[] = "hello world!\xa\x2\x3\x4\x5\x6\x7\x8\xed\xa\xb\xc\xd\xe\xf";
1616 static const struct test_data td[5] =
1618 { VT_UI1, 0, 0, { 2 }, NULL, { 'D','i','s','p','o','s','a','l',0 } },
1619 { VT_BOOL, 0, 0, { 1 }, NULL, { 'U','s','e','r','I','n','p','u','t','F','l','a','g',0 } },
1620 { VT_BOOL, 0, 0, { 0 }, NULL, { 'T','r','a','n','s','p','a','r','e','n','c','y','F','l','a','g',0 } },
1621 { VT_UI2, 0, 0, { 0x302 }, NULL, { 'D','e','l','a','y',0 } },
1622 { VT_UI1, 0, 0, { 4 }, NULL, { 'T','r','a','n','s','p','a','r','e','n','t','C','o','l','o','r','I','n','d','e','x',0 } }
1624 LARGE_INTEGER pos;
1625 HRESULT hr;
1626 IStream *stream;
1627 IWICPersistStream *persist;
1628 IWICMetadataReader *reader;
1629 IWICMetadataHandlerInfo *info;
1630 WCHAR name[64];
1631 UINT count, dummy;
1632 GUID format;
1633 CLSID id;
1635 hr = CoCreateInstance(&CLSID_WICGCEMetadataReader, NULL, CLSCTX_INPROC_SERVER,
1636 &IID_IWICMetadataReader, (void **)&reader);
1637 ok(hr == S_OK || broken(hr == E_NOINTERFACE || hr == REGDB_E_CLASSNOTREG) /* before Win7 */,
1638 "CoCreateInstance error %#x\n", hr);
1640 stream = create_stream(GCE_data, sizeof(GCE_data));
1642 if (SUCCEEDED(hr))
1644 pos.QuadPart = 12;
1645 hr = IStream_Seek(stream, pos, SEEK_SET, NULL);
1646 ok(hr == S_OK, "IStream_Seek error %#x\n", hr);
1648 hr = IUnknown_QueryInterface(reader, &IID_IWICPersistStream, (void **)&persist);
1649 ok(hr == S_OK, "QueryInterface error %#x\n", hr);
1651 hr = IWICPersistStream_Load(persist, stream);
1652 ok(hr == S_OK, "Load error %#x\n", hr);
1654 IWICPersistStream_Release(persist);
1657 if (SUCCEEDED(hr))
1659 hr = IWICMetadataReader_GetCount(reader, &count);
1660 ok(hr == S_OK, "GetCount error %#x\n", hr);
1661 ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
1663 compare_metadata(reader, td, count);
1665 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
1666 ok(hr == S_OK, "GetMetadataFormat error %#x\n", hr);
1667 ok(IsEqualGUID(&format, &GUID_MetadataFormatGCE), "wrong format %s\n", wine_dbgstr_guid(&format));
1669 hr = IWICMetadataReader_GetMetadataHandlerInfo(reader, &info);
1670 ok(hr == S_OK, "GetMetadataHandlerInfo error %#x\n", hr);
1672 hr = IWICMetadataHandlerInfo_GetCLSID(info, &id);
1673 ok(hr == S_OK, "GetCLSID error %#x\n", hr);
1674 ok(IsEqualGUID(&id, &CLSID_WICGCEMetadataReader), "wrong CLSID %s\n", wine_dbgstr_guid(&id));
1676 hr = IWICMetadataHandlerInfo_GetFriendlyName(info, 64, name, &dummy);
1677 ok(hr == S_OK, "GetFriendlyName error %#x\n", hr);
1678 ok(lstrcmpW(name, GCE_name) == 0, "wrong GCE reader name %s\n", wine_dbgstr_w(name));
1680 IWICMetadataHandlerInfo_Release(info);
1681 IWICMetadataReader_Release(reader);
1684 IStream_Release(stream);
1687 static void test_metadata_APE(void)
1689 static const WCHAR APE_name[] = {'A','p','p','l','i','c','a','t','i','o','n',' ','E','x','t','e','n','s','i','o','n',' ','R','e','a','d','e','r',0};
1690 static const char APE_data[] = { 0x21,0xff,0x0b,'H','e','l','l','o',' ','W','o','r','l','d',
1691 /*sub-block*/1,0x11,
1692 /*sub-block*/2,0x22,0x33,
1693 /*sub-block*/4,0x44,0x55,0x66,0x77,
1694 /*terminator*/0 };
1695 static const struct test_data td[2] =
1697 { VT_UI1|VT_VECTOR, 0, 11, { 'H','e','l','l','o',' ','W','o','r','l','d' }, NULL, { 'A','p','p','l','i','c','a','t','i','o','n',0 } },
1698 { VT_UI1|VT_VECTOR, 0, 10, { 1,0x11,2,0x22,0x33,4,0x44,0x55,0x66,0x77 }, NULL, { 'D','a','t','a',0 } }
1700 WCHAR dataW[] = { 'd','a','t','a',0 };
1701 HRESULT hr;
1702 IStream *stream;
1703 IWICPersistStream *persist;
1704 IWICMetadataReader *reader;
1705 IWICMetadataHandlerInfo *info;
1706 WCHAR name[64];
1707 UINT count, dummy, i;
1708 GUID format;
1709 CLSID clsid;
1710 PROPVARIANT id, value;
1712 hr = CoCreateInstance(&CLSID_WICAPEMetadataReader, NULL, CLSCTX_INPROC_SERVER,
1713 &IID_IWICMetadataReader, (void **)&reader);
1714 ok(hr == S_OK || broken(hr == E_NOINTERFACE || hr == REGDB_E_CLASSNOTREG) /* before Win7 */,
1715 "CoCreateInstance error %#x\n", hr);
1717 stream = create_stream(APE_data, sizeof(APE_data));
1719 if (SUCCEEDED(hr))
1721 hr = IUnknown_QueryInterface(reader, &IID_IWICPersistStream, (void **)&persist);
1722 ok(hr == S_OK, "QueryInterface error %#x\n", hr);
1724 hr = IWICPersistStream_Load(persist, stream);
1725 ok(hr == S_OK, "Load error %#x\n", hr);
1727 IWICPersistStream_Release(persist);
1730 if (SUCCEEDED(hr))
1732 hr = IWICMetadataReader_GetCount(reader, &count);
1733 ok(hr == S_OK, "GetCount error %#x\n", hr);
1734 ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
1736 compare_metadata(reader, td, count);
1738 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
1739 ok(hr == S_OK, "GetMetadataFormat error %#x\n", hr);
1740 ok(IsEqualGUID(&format, &GUID_MetadataFormatAPE), "wrong format %s\n", wine_dbgstr_guid(&format));
1742 PropVariantInit(&value);
1743 id.vt = VT_LPWSTR;
1744 U(id).pwszVal = dataW;
1746 hr = IWICMetadataReader_GetValue(reader, NULL, &id, &value);
1747 ok(hr == S_OK, "GetValue error %#x\n", hr);
1748 ok(value.vt == (VT_UI1|VT_VECTOR), "unexpected vt: %i\n", id.vt);
1749 ok(td[1].count == U(value).caub.cElems, "expected cElems %d, got %d\n", td[1].count, U(value).caub.cElems);
1750 for (i = 0; i < U(value).caub.cElems; i++)
1751 ok(td[1].value[i] == U(value).caub.pElems[i], "%u: expected value %#x/%#x, got %#x\n", i, (ULONG)td[1].value[i], (ULONG)(td[1].value[i] >> 32), U(value).caub.pElems[i]);
1752 PropVariantClear(&value);
1754 hr = IWICMetadataReader_GetMetadataHandlerInfo(reader, &info);
1755 ok(hr == S_OK, "GetMetadataHandlerInfo error %#x\n", hr);
1757 hr = IWICMetadataHandlerInfo_GetCLSID(info, &clsid);
1758 ok(hr == S_OK, "GetCLSID error %#x\n", hr);
1759 ok(IsEqualGUID(&clsid, &CLSID_WICAPEMetadataReader), "wrong CLSID %s\n", wine_dbgstr_guid(&clsid));
1761 hr = IWICMetadataHandlerInfo_GetFriendlyName(info, 64, name, &dummy);
1762 ok(hr == S_OK, "GetFriendlyName error %#x\n", hr);
1763 ok(lstrcmpW(name, APE_name) == 0, "wrong APE reader name %s\n", wine_dbgstr_w(name));
1765 IWICMetadataHandlerInfo_Release(info);
1766 IWICMetadataReader_Release(reader);
1769 IStream_Release(stream);
1772 static void test_metadata_GIF_comment(void)
1774 static const WCHAR GIF_comment_name[] = {'C','o','m','m','e','n','t',' ','E','x','t','e','n','s','i','o','n',' ','R','e','a','d','e','r',0};
1775 static const char GIF_comment_data[] = { 0x21,0xfe,
1776 /*sub-block*/5,'H','e','l','l','o',
1777 /*sub-block*/1,' ',
1778 /*sub-block*/6,'W','o','r','l','d','!',
1779 /*terminator*/0 };
1780 static const struct test_data td[1] =
1782 { VT_LPSTR, 0, 12, { 0 }, "Hello World!", { 'T','e','x','t','E','n','t','r','y',0 } }
1784 WCHAR text_entryW[] = { 'T','E','X','T','E','N','T','R','Y',0 };
1785 HRESULT hr;
1786 IStream *stream;
1787 IWICPersistStream *persist;
1788 IWICMetadataReader *reader;
1789 IWICMetadataHandlerInfo *info;
1790 WCHAR name[64];
1791 UINT count, dummy;
1792 GUID format;
1793 CLSID clsid;
1794 PROPVARIANT id, value;
1796 hr = CoCreateInstance(&CLSID_WICGifCommentMetadataReader, NULL, CLSCTX_INPROC_SERVER,
1797 &IID_IWICMetadataReader, (void **)&reader);
1798 ok(hr == S_OK || broken(hr == E_NOINTERFACE || hr == REGDB_E_CLASSNOTREG) /* before Win7 */,
1799 "CoCreateInstance error %#x\n", hr);
1801 stream = create_stream(GIF_comment_data, sizeof(GIF_comment_data));
1803 if (SUCCEEDED(hr))
1805 hr = IUnknown_QueryInterface(reader, &IID_IWICPersistStream, (void **)&persist);
1806 ok(hr == S_OK, "QueryInterface error %#x\n", hr);
1808 hr = IWICPersistStream_Load(persist, stream);
1809 ok(hr == S_OK, "Load error %#x\n", hr);
1811 IWICPersistStream_Release(persist);
1814 if (SUCCEEDED(hr))
1816 hr = IWICMetadataReader_GetCount(reader, &count);
1817 ok(hr == S_OK, "GetCount error %#x\n", hr);
1818 ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
1820 compare_metadata(reader, td, count);
1822 hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
1823 ok(hr == S_OK, "GetMetadataFormat error %#x\n", hr);
1824 ok(IsEqualGUID(&format, &GUID_MetadataFormatGifComment), "wrong format %s\n", wine_dbgstr_guid(&format));
1826 PropVariantInit(&value);
1827 id.vt = VT_LPWSTR;
1828 U(id).pwszVal = text_entryW;
1830 hr = IWICMetadataReader_GetValue(reader, NULL, &id, &value);
1831 ok(hr == S_OK, "GetValue error %#x\n", hr);
1832 ok(value.vt == VT_LPSTR, "unexpected vt: %i\n", id.vt);
1833 ok(!strcmp(U(value).pszVal, "Hello World!"), "unexpected value: %s\n", U(value).pszVal);
1834 PropVariantClear(&value);
1836 hr = IWICMetadataReader_GetMetadataHandlerInfo(reader, &info);
1837 ok(hr == S_OK, "GetMetadataHandlerInfo error %#x\n", hr);
1839 hr = IWICMetadataHandlerInfo_GetCLSID(info, &clsid);
1840 ok(hr == S_OK, "GetCLSID error %#x\n", hr);
1841 ok(IsEqualGUID(&clsid, &CLSID_WICGifCommentMetadataReader), "wrong CLSID %s\n", wine_dbgstr_guid(&clsid));
1843 hr = IWICMetadataHandlerInfo_GetFriendlyName(info, 64, name, &dummy);
1844 ok(hr == S_OK, "GetFriendlyName error %#x\n", hr);
1845 ok(lstrcmpW(name, GIF_comment_name) == 0, "wrong APE reader name %s\n", wine_dbgstr_w(name));
1847 IWICMetadataHandlerInfo_Release(info);
1848 IWICMetadataReader_Release(reader);
1851 IStream_Release(stream);
1854 START_TEST(metadata)
1856 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
1858 test_metadata_unknown();
1859 test_metadata_tEXt();
1860 test_metadata_gAMA();
1861 test_metadata_IFD();
1862 test_metadata_Exif();
1863 test_create_reader();
1864 test_metadata_png();
1865 test_metadata_gif();
1866 test_metadata_LSD();
1867 test_metadata_IMD();
1868 test_metadata_GCE();
1869 test_metadata_APE();
1870 test_metadata_GIF_comment();
1872 CoUninitialize();