[4/8] windowscodecs: Add support for IFD_ASCII field type. Resend.

Dmitry Timoshkov dmitry at baikal.ru
Fri Jun 15 23:23:31 CDT 2012


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

diff --git a/dlls/windowscodecs/metadatahandler.c b/dlls/windowscodecs/metadatahandler.c
index ace602f..4080186 100644
--- a/dlls/windowscodecs/metadatahandler.c
+++ b/dlls/windowscodecs/metadatahandler.c
@@ -807,6 +807,33 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
         }
         FIXME("loading multiple rational fields is not implemented\n");
         break;
+    case IFD_ASCII:
+        item->value.u.pszVal = HeapAlloc(GetProcessHeap(), 0, count + 1);
+        if (!item->value.u.pszVal) return E_OUTOFMEMORY;
+
+        if (count <= 4)
+        {
+            const char *data = (const char *)&value;
+            memcpy(item->value.u.pszVal, data, count);
+            item->value.u.pszVal[count] = 0;
+            break;
+        }
+
+        pos.QuadPart = value;
+        hr = IStream_Seek(input, pos, SEEK_SET, NULL);
+        if (FAILED(hr))
+        {
+            HeapFree(GetProcessHeap(), 0, item->value.u.pszVal);
+            return hr;
+        }
+        hr = IStream_Read(input, item->value.u.pszVal, count, NULL);
+        if (FAILED(hr))
+        {
+            HeapFree(GetProcessHeap(), 0, item->value.u.pszVal);
+            return hr;
+        }
+        item->value.u.pszVal[count] = 0;
+        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 59940e1..c63f7ca 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 =
 {
-    19,
+    21,
     {
         { 0xfe,  IFD_SHORT, 1, 1 }, /* NEWSUBFILETYPE */
         { 0x100, IFD_LONG, 1, 222 }, /* IMAGEWIDTH */
@@ -97,6 +97,8 @@ static const struct
           sizeof(USHORT) + sizeof(struct IFD_entry) * 40 + sizeof(ULONG) },
         { 0xf009, IFD_SRATIONAL, 1,
           sizeof(USHORT) + sizeof(struct IFD_entry) * 40 + sizeof(ULONG) },
+        { 0xf00a, IFD_ASCII, 13,
+          sizeof(USHORT) + sizeof(struct IFD_entry) * 40 + sizeof(ULONG) + sizeof(struct IFD_rational) },
         { 0xf00b, IFD_BYTE, 13,
           sizeof(USHORT) + sizeof(struct IFD_entry) * 40 + sizeof(ULONG) + sizeof(struct IFD_rational) },
         { 0xf00c, IFD_SSHORT, 4,
@@ -105,6 +107,7 @@ static const struct
           sizeof(USHORT) + sizeof(struct IFD_entry) * 40 + sizeof(ULONG) },
         { 0xf00e, IFD_FLOAT, 2,
           sizeof(USHORT) + sizeof(struct IFD_entry) * 40 + sizeof(ULONG) },
+        { 0xf00f, IFD_ASCII, 4, 'a' | 'b' << 8 | 'c' << 16 | 'd' << 24 },
     },
     0,
     { 900, 3 },
@@ -382,7 +385,8 @@ static void test_metadata_IFD(void)
         ULONG type, id;
         int count; /* if VT_VECTOR */
         LONGLONG value[13];
-    } td[19] =
+        const char *string;
+    } td[21] =
     {
         { VT_UI2, 0xfe, 0, { 1 } },
         { VT_UI4, 0x100, 0, { 222 } },
@@ -399,10 +403,12 @@ static void test_metadata_IFD(void)
         { VT_R4, 0xf007, 0, { 0x11223344 } },
         { VT_R8, 0xf008, 0, { ((LONGLONG)3 << 32) | 900 } },
         { VT_I8, 0xf009, 0, { ((LONGLONG)3 << 32) | 900 } },
+        { VT_LPSTR, 0xf00a, 12, { 0 }, "Hello World!" },
         { VT_UI1|VT_VECTOR, 0xf00b, 13, { 'H','e','l','l','o',' ','W','o','r','l','d','!',0 } },
         { VT_I2|VT_VECTOR, 0xf00c, 4, { 900, 0, 3, 0 } },
         { VT_I4|VT_VECTOR, 0xf00d, 2, { 900, 3 } },
         { VT_R4|VT_VECTOR, 0xf00e, 2, { 900, 3 } },
+        { VT_LPSTR, 0xf00f, 4, { 0 }, "abcd" },
     };
     HRESULT hr;
     IWICMetadataReader *reader;
@@ -473,11 +479,25 @@ static void test_metadata_IFD(void)
                 for (j = 0; j < U(value).caul.cElems; j++)
                     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]);
                 break;
+            case VT_LPSTR:
+                ok(td[i].count == U(value).calpstr.cElems, "%u: expected cElems %d, got %d\n", i, td[i].count, U(value).caub.cElems);
+                for (j = 0; j < U(value).calpstr.cElems; j++)
+                    trace("%u: %s\n", j, U(value).calpstr.pElems[j]);
+                /* fall through to not handled message */
             default:
                 ok(0, "%u: array of type %d is not handled\n", i, value.vt & ~VT_VECTOR);
                 break;
             }
         }
+        else if (value.vt == VT_LPSTR)
+        {
+            ok(td[i].count == strlen(U(value).pszVal) ||
+               broken(td[i].count == strlen(U(value).pszVal) + 1), /* before Win7 */
+               "%u: expected count %d, got %d\n", i, td[i].count, strlen(U(value).pszVal));
+            if (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
             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