From 4c7f6f68b9c5a94879d22f264926478aa1194341 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Thu, 21 Jun 2012 11:21:26 +0900 Subject: [PATCH] windowscodecs: Add support for loading of multiple 8-byte IFD fields. --- dlls/windowscodecs/metadatahandler.c | 32 +++++++++++++++++++++++++++++++- dlls/windowscodecs/tests/metadata.c | 11 +++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/dlls/windowscodecs/metadatahandler.c b/dlls/windowscodecs/metadatahandler.c index 83b5c88ccdd..a3eea1f63b6 100644 --- a/dlls/windowscodecs/metadatahandler.c +++ b/dlls/windowscodecs/metadatahandler.c @@ -865,7 +865,37 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry, } break; } - FIXME("loading multiple rational fields is not implemented\n"); + else + { + item->value.vt |= VT_VECTOR; + item->value.u.cauh.cElems = count; + item->value.u.cauh.pElems = HeapAlloc(GetProcessHeap(), 0, count * 8); + if (!item->value.u.cauh.pElems) return E_OUTOFMEMORY; + + pos.QuadPart = value; + hr = IStream_Seek(input, pos, SEEK_SET, NULL); + if (FAILED(hr)) + { + HeapFree(GetProcessHeap(), 0, item->value.u.cauh.pElems); + return hr; + } + hr = IStream_Read(input, item->value.u.cauh.pElems, count * 8, NULL); + if (FAILED(hr)) + { + HeapFree(GetProcessHeap(), 0, item->value.u.cauh.pElems); + return hr; + } + for (i = 0; i < count; i++) + { + if (type == IFD_DOUBLE) + SWAP_ULONGLONG(item->value.u.cauh.pElems[i].QuadPart); + else + { + SWAP_ULONG(item->value.u.cauh.pElems[i].u.LowPart); + SWAP_ULONG(item->value.u.cauh.pElems[i].u.HighPart); + } + } + } break; case IFD_ASCII: item->value.u.pszVal = HeapAlloc(GetProcessHeap(), 0, count + 1); diff --git a/dlls/windowscodecs/tests/metadata.c b/dlls/windowscodecs/tests/metadata.c index f8215133b86..76fd241bca8 100644 --- a/dlls/windowscodecs/tests/metadata.c +++ b/dlls/windowscodecs/tests/metadata.c @@ -81,9 +81,10 @@ static const struct ifd_data SHORT short_val[4]; LONG long_val[2]; FLOAT float_val[2]; + struct IFD_rational rational[3]; } IFD_data = { - 27, + 28, { { 0xfe, IFD_SHORT, 1, 1 }, /* NEWSUBFILETYPE */ { 0x100, IFD_LONG, 1, 222 }, /* IMAGEWIDTH */ @@ -112,6 +113,7 @@ static const struct ifd_data { 0xf013, IFD_SHORT, 0, 0x11223344 }, { 0xf014, IFD_LONG, 0, 0x11223344 }, { 0xf015, IFD_FLOAT, 0, 0x11223344 }, + { 0xf016, IFD_SRATIONAL, 3, FIELD_OFFSET(struct ifd_data, rational) }, }, 0, { 900, 3 }, @@ -121,6 +123,7 @@ static const struct ifd_data { 0x0101, 0x0202, 0x0303, 0x0404 }, { 0x11223344, 0x55667788 }, { (FLOAT)1234.5678, (FLOAT)8765.4321 }, + { { 0x01020304, 0x05060708 }, { 0x10203040, 0x50607080 }, { 0x11223344, 0x55667788 } }, }; #include "poppack.h" @@ -603,7 +606,7 @@ static void compare_ifd_metadata(IWICMetadataReader *reader, const struct test_d static void test_metadata_IFD(void) { - static const struct test_data td[27] = + static const struct test_data td[28] = { { VT_UI2, 0xfe, 0, { 1 } }, { VT_UI4, 0x100, 0, { 222 } }, @@ -632,6 +635,10 @@ static void test_metadata_IFD(void) { VT_UI2, 0xf013, 0, { 0x3344 } }, { VT_UI4, 0xf014, 0, { 0x11223344 } }, { VT_R4, 0xf015, 0, { 0x11223344 } }, + { VT_I8|VT_VECTOR, 0xf016, 3, + { ((LONGLONG)0x05060708 << 32) | 0x01020304, + ((LONGLONG)0x50607080 << 32) | 0x10203040, + ((LONGLONG)0x55667788 << 32) | 0x11223344 } }, }; HRESULT hr; IWICMetadataReader *reader; -- 2.11.4.GIT