[09/11] windowscodecs: Add support for IFD_UNDEFINED field type.

Dmitry Timoshkov dmitry at baikal.ru
Tue Jun 12 23:39:24 CDT 2012


---
 dlls/windowscodecs/metadatahandler.c |   27 +++++++++++++++++++++++++++
 dlls/windowscodecs/tests/metadata.c  |   14 +++++++++++---
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/dlls/windowscodecs/metadatahandler.c b/dlls/windowscodecs/metadatahandler.c
index 46f5a8f..21504db 100644
--- a/dlls/windowscodecs/metadatahandler.c
+++ b/dlls/windowscodecs/metadatahandler.c
@@ -834,6 +834,33 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
         }
         item->value.u.pszVal[count - 1] = 0;
         break;
+    case IFD_UNDEFINED:
+        item->value.u.blob.pBlobData = HeapAlloc(GetProcessHeap(), 0, count);
+        if (!item->value.u.blob.pBlobData) return E_OUTOFMEMORY;
+
+        item->value.u.blob.cbSize = count;
+
+        if (count <= 4)
+        {
+            const char *data = (const char *)&value;
+            memcpy(item->value.u.blob.pBlobData, data, count);
+            break;
+        }
+
+        pos.QuadPart = value;
+        hr = IStream_Seek(input, pos, SEEK_SET, NULL);
+        if (FAILED(hr))
+        {
+            HeapFree(GetProcessHeap(), 0, item->value.u.blob.pBlobData);
+            return hr;
+        }
+        hr = IStream_Read(input, item->value.u.blob.pBlobData, count, NULL);
+        if (FAILED(hr))
+        {
+            HeapFree(GetProcessHeap(), 0, item->value.u.blob.pBlobData);
+            return hr;
+        }
+        break;
     default:
         FIXME("loading field of type %d, count %u is not implemented\n", type, count);
         break;
diff --git a/dlls/windowscodecs/tests/metadata.c b/dlls/windowscodecs/tests/metadata.c
index de46185..a72ad22 100644
--- a/dlls/windowscodecs/tests/metadata.c
+++ b/dlls/windowscodecs/tests/metadata.c
@@ -77,7 +77,7 @@ static const struct
     char string[13];
 } IFD_data =
 {
-    21,
+    22,
     {
         { 0xfe,  IFD_SHORT, 1, 1 }, /* NEWSUBFILETYPE */
         { 0x100, IFD_LONG, 1, 222 }, /* IMAGEWIDTH */
@@ -108,6 +108,8 @@ static const struct
         { 0xf00e, IFD_FLOAT, 2,
           sizeof(USHORT) + sizeof(struct IFD_entry) * 40 + sizeof(ULONG) },
         { 0xf00f, IFD_ASCII, 4, 'a' | 'b' << 8 | 'c' << 16 | 'd' << 24  },
+        { 0xf010, IFD_UNDEFINED, 13,
+          sizeof(USHORT) + sizeof(struct IFD_entry) * 40 + sizeof(ULONG) + sizeof(struct IFD_rational) },
     },
     0,
     { 900, 3 },
@@ -386,7 +388,7 @@ static void test_metadata_IFD(void)
         int count; /* if VT_VECTOR */
         LONGLONG value[13];
         const char *string;
-    } td[21] =
+    } td[22] =
     {
         { VT_UI2, 0xfe, 0, { 1 } },
         { VT_UI4, 0x100, 0, { 222 } },
@@ -409,6 +411,7 @@ static void test_metadata_IFD(void)
         { VT_I4|VT_VECTOR, 0xf00d, 2, { 900, 3 } },
         { VT_R4|VT_VECTOR, 0xf00e, 2, { 900, 3 } },
         { VT_LPSTR, 0xf00f, 3, { 0 }, "abc" },
+        { VT_BLOB, 0xf010, 13, { 0 }, "Hello World!" },
     };
     HRESULT hr;
     IWICMetadataReader *reader;
@@ -437,7 +440,7 @@ static void test_metadata_IFD(void)
 
     hr = IWICMetadataReader_GetCount(reader, &count);
     ok(hr == S_OK, "GetCount error %#x\n", hr);
-    ok(count == 21, "unexpected count %u\n", count);
+    ok(count == 22, "unexpected count %u\n", count);
 
     hr = IWICMetadataReader_GetEnumerator(reader, NULL);
     ok(hr == E_INVALIDARG, "GetEnumerator error %#x\n", hr);
@@ -494,6 +497,11 @@ static void test_metadata_IFD(void)
             ok(td[i].count == strlen(U(value).pszVal), "%u: expected count %d, got %d\n", i, td[i].count, strlen(U(value).pszVal));
             ok(!strcmp(td[i].string, U(value).pszVal), "%u: expected %s, got %s\n", i, td[i].string, U(value).pszVal);
         }
+        else if (value.vt == VT_BLOB)
+        {
+            ok(td[i].count == U(value).blob.cbSize, "%u: expected count %d, got %d\n", i, td[i].count, U(value).blob.cbSize);
+            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);
+        }
         else
             ok(U(value).uhVal.QuadPart == td[i].value[0], "%u: unexpected value: %d/%d\n", i, U(value).uhVal.u.LowPart, U(value).uhVal.u.HighPart);
 
-- 
1.7.10.1




More information about the wine-patches mailing list