[07/17] windowscodecs: Implement WICMapGuidToShortName.

Dmitry Timoshkov dmitry at baikal.ru
Mon Jun 19 23:37:10 CDT 2017


Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
 dlls/windowscodecs/metadataquery.c    | 129 ++++++++++++++++++++++++++++++++++
 dlls/windowscodecs/tests/metadata.c   |  60 +++++++++++++++-
 dlls/windowscodecs/windowscodecs.spec |   2 +-
 include/wincodec.idl                  |   2 +
 include/wincodecsdk.idl               |  23 ++++++
 5 files changed, 214 insertions(+), 2 deletions(-)

diff --git a/dlls/windowscodecs/metadataquery.c b/dlls/windowscodecs/metadataquery.c
index 10bf295b65..7a5e451a42 100644
--- a/dlls/windowscodecs/metadataquery.c
+++ b/dlls/windowscodecs/metadataquery.c
@@ -1,5 +1,6 @@
 /*
  * Copyright 2016 Andrew Eikum for CodeWeavers
+ * Copyright 2017 Dmitry Timoshkov
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -148,3 +149,131 @@ HRESULT MetadataQueryReader_CreateInstance(IWICMetadataBlockReader *mbr, IWICMet
 
     return S_OK;
 }
+
+static const WCHAR bmpW[] = { 'b','m','p',0 };
+static const WCHAR pngW[] = { 'p','n','g',0 };
+static const WCHAR icoW[] = { 'i','c','o',0 };
+static const WCHAR jpgW[] = { 'j','p','g',0 };
+static const WCHAR tiffW[] = { 't','i','f','f',0 };
+static const WCHAR gifW[] = { 'g','i','f',0 };
+static const WCHAR wmphotoW[] = { 'w','m','p','h','o','t','o',0 };
+static const WCHAR unknownW[] = { 'u','n','k','n','o','w','n',0 };
+static const WCHAR ifdW[] = { 'i','f','d',0 };
+static const WCHAR subW[] = { 's','u','b',0 };
+static const WCHAR exifW[] = { 'e','x','i','f',0 };
+static const WCHAR gpsW[] = { 'g','p','s',0 };
+static const WCHAR interopW[] = { 'i','n','t','e','r','o','p',0 };
+static const WCHAR app0W[] = { 'a','p','p','0',0 };
+static const WCHAR app1W[] = { 'a','p','p','1',0 };
+static const WCHAR app13W[] = { 'a','p','p','1','3',0 };
+static const WCHAR iptcW[] = { 'i','p','t','c',0 };
+static const WCHAR irbW[] = { 'i','r','b',0 };
+static const WCHAR _8bimiptcW[] = { '8','b','i','m','i','p','t','c',0 };
+static const WCHAR _8bimResInfoW[] = { '8','b','i','m','R','e','s','I','n','f','o',0 };
+static const WCHAR _8bimiptcdigestW[] = { '8','b','i','m','i','p','t','c','d','i','g','e','s','t',0 };
+static const WCHAR xmpW[] = { 'x','m','p',0 };
+static const WCHAR thumbW[] = { 't','h','u','m','b',0 };
+static const WCHAR tEXtW[] = { 't','E','X','t',0 };
+static const WCHAR xmpstructW[] = { 'x','m','p','s','t','r','u','c','t',0 };
+static const WCHAR xmpbagW[] = { 'x','m','p','b','a','g',0 };
+static const WCHAR xmpseqW[] = { 'x','m','p','s','e','q',0 };
+static const WCHAR xmpaltW[] = { 'x','m','p','a','l','t',0 };
+static const WCHAR logscrdescW[] = { 'l','o','g','s','c','r','d','e','s','c',0 };
+static const WCHAR imgdescW[] = { 'i','m','g','d','e','s','c',0 };
+static const WCHAR grctlextW[] = { 'g','r','c','t','l','e','x','t',0 };
+static const WCHAR appextW[] = { 'a','p','p','e','x','t',0 };
+static const WCHAR chrominanceW[] = { 'c','h','r','o','m','i','n','a','n','c','e',0 };
+static const WCHAR luminanceW[] = { 'l','u','m','i','n','a','n','c','e',0 };
+static const WCHAR comW[] = { 'c','o','m',0 };
+static const WCHAR commentextW[] = { 'c','o','m','m','e','n','t','e','x','t',0 };
+static const WCHAR gAMAW[] = { 'g','A','M','A',0 };
+static const WCHAR bKGDW[] = { 'b','K','G','D',0 };
+static const WCHAR iTXtW[] = { 'i','T','X','t',0 };
+static const WCHAR cHRMW[] = { 'c','H','R','M',0 };
+static const WCHAR hISTW[] = { 'h','I','S','T',0 };
+static const WCHAR iCCPW[] = { 'i','C','C','P',0 };
+static const WCHAR sRGBW[] = { 's','R','G','B',0 };
+static const WCHAR tIMEW[] = { 't','I','M','E',0 };
+
+static const struct
+{
+    const GUID *guid;
+    const WCHAR *name;
+} guid2name[] =
+{
+    { &GUID_ContainerFormatBmp, bmpW },
+    { &GUID_ContainerFormatPng, pngW },
+    { &GUID_ContainerFormatIco, icoW },
+    { &GUID_ContainerFormatJpeg, jpgW },
+    { &GUID_ContainerFormatTiff, tiffW },
+    { &GUID_ContainerFormatGif, gifW },
+    { &GUID_ContainerFormatWmp, wmphotoW },
+    { &GUID_MetadataFormatUnknown, unknownW },
+    { &GUID_MetadataFormatIfd, ifdW },
+    { &GUID_MetadataFormatSubIfd, subW },
+    { &GUID_MetadataFormatExif, exifW },
+    { &GUID_MetadataFormatGps, gpsW },
+    { &GUID_MetadataFormatInterop, interopW },
+    { &GUID_MetadataFormatApp0, app0W },
+    { &GUID_MetadataFormatApp1, app1W },
+    { &GUID_MetadataFormatApp13, app13W },
+    { &GUID_MetadataFormatIPTC, iptcW },
+    { &GUID_MetadataFormatIRB, irbW },
+    { &GUID_MetadataFormat8BIMIPTC, _8bimiptcW },
+    { &GUID_MetadataFormat8BIMResolutionInfo, _8bimResInfoW },
+    { &GUID_MetadataFormat8BIMIPTCDigest, _8bimiptcdigestW },
+    { &GUID_MetadataFormatXMP, xmpW },
+    { &GUID_MetadataFormatThumbnail, thumbW },
+    { &GUID_MetadataFormatChunktEXt, tEXtW },
+    { &GUID_MetadataFormatXMPStruct, xmpstructW },
+    { &GUID_MetadataFormatXMPBag, xmpbagW },
+    { &GUID_MetadataFormatXMPSeq, xmpseqW },
+    { &GUID_MetadataFormatXMPAlt, xmpaltW },
+    { &GUID_MetadataFormatLSD, logscrdescW },
+    { &GUID_MetadataFormatIMD, imgdescW },
+    { &GUID_MetadataFormatGCE, grctlextW },
+    { &GUID_MetadataFormatAPE, appextW },
+    { &GUID_MetadataFormatJpegChrominance, chrominanceW },
+    { &GUID_MetadataFormatJpegLuminance, luminanceW },
+    { &GUID_MetadataFormatJpegComment, comW },
+    { &GUID_MetadataFormatGifComment, commentextW },
+    { &GUID_MetadataFormatChunkgAMA, gAMAW },
+    { &GUID_MetadataFormatChunkbKGD, bKGDW },
+    { &GUID_MetadataFormatChunkiTXt, iTXtW },
+    { &GUID_MetadataFormatChunkcHRM, cHRMW },
+    { &GUID_MetadataFormatChunkhIST, hISTW },
+    { &GUID_MetadataFormatChunkiCCP, iCCPW },
+    { &GUID_MetadataFormatChunksRGB, sRGBW },
+    { &GUID_MetadataFormatChunktIME, tIMEW }
+};
+
+HRESULT WINAPI WICMapGuidToShortName(REFGUID guid, UINT len, WCHAR *name, UINT *ret_len)
+{
+    UINT i;
+
+    TRACE("%s,%u,%p,%p\n", wine_dbgstr_guid(guid), len, name, ret_len);
+
+    if (!guid) return E_INVALIDARG;
+
+    for (i = 0; i < sizeof(guid2name)/sizeof(guid2name[0]); i++)
+    {
+        if (IsEqualGUID(guid, guid2name[i].guid))
+        {
+            if (name)
+            {
+                if (!len) return E_INVALIDARG;
+
+                len = min(len - 1, lstrlenW(guid2name[i].name));
+                memcpy(name, guid2name[i].name, len * sizeof(WCHAR));
+                name[len] = 0;
+
+                if (len < strlenW(guid2name[i].name))
+                    return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
+            }
+            if (ret_len) *ret_len = lstrlenW(guid2name[i].name) + 1;
+            return S_OK;
+        }
+    }
+
+    return WINCODEC_ERR_PROPERTYNOTFOUND;
+}
diff --git a/dlls/windowscodecs/tests/metadata.c b/dlls/windowscodecs/tests/metadata.c
index aafc47dd1a..4e9d691b34 100644
--- a/dlls/windowscodecs/tests/metadata.c
+++ b/dlls/windowscodecs/tests/metadata.c
@@ -1,6 +1,6 @@
 /*
  * Copyright 2011 Vincent Povirk for CodeWeavers
- * Copyright 2012 Dmitry Timoshkov
+ * Copyright 2012,2017 Dmitry Timoshkov
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -1960,10 +1960,68 @@ static void test_metadata_GIF_comment(void)
     IStream_Release(stream);
 }
 
+static void test_WICMapGuidToShortName(void)
+{
+    static const WCHAR unkW[] = { 'u','n','k',0 };
+    static const WCHAR unknownW[] = { 'u','n','k','n','o','w','n',0 };
+    HRESULT hr;
+    UINT len;
+    WCHAR name[16];
+
+    name[0] = 0;
+    len = 0xdeadbeef;
+    hr = WICMapGuidToShortName(&GUID_MetadataFormatUnknown, 8, name, &len);
+    ok(hr == S_OK, "got %#x\n", hr);
+    ok(len == 8, "got %u\n", len);
+    ok(!lstrcmpW(name, unknownW), "got %s\n", wine_dbgstr_w(name));
+
+    name[0] = 0;
+    hr = WICMapGuidToShortName(&GUID_MetadataFormatUnknown, 8, name, NULL);
+    ok(hr == S_OK, "got %#x\n", hr);
+    ok(!lstrcmpW(name, unknownW), "got %s\n", wine_dbgstr_w(name));
+
+    len = 0xdeadbeef;
+    hr = WICMapGuidToShortName(&GUID_MetadataFormatUnknown, 8, NULL, &len);
+    ok(hr == S_OK, "got %#x\n", hr);
+    ok(len == 8, "got %u\n", len);
+
+    len = 0xdeadbeef;
+    hr = WICMapGuidToShortName(&GUID_MetadataFormatUnknown, 0, NULL, &len);
+    ok(hr == S_OK, "got %#x\n", hr);
+    ok(len == 8, "got %u\n", len);
+
+    hr = WICMapGuidToShortName(&GUID_MetadataFormatUnknown, 0, NULL, NULL);
+    ok(hr == S_OK, "got %#x\n", hr);
+
+    hr = WICMapGuidToShortName(&GUID_MetadataFormatUnknown, 8, NULL, NULL);
+    ok(hr == S_OK, "got %#x\n", hr);
+
+    hr = WICMapGuidToShortName(&GUID_NULL, 0, NULL, NULL);
+    ok(hr == WINCODEC_ERR_PROPERTYNOTFOUND, "got %#x\n", hr);
+
+    name[0] = 0;
+    len = 0xdeadbeef;
+    hr = WICMapGuidToShortName(&GUID_MetadataFormatUnknown, 4, name, &len);
+    ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "got %#x\n", hr);
+    ok(len == 0xdeadbeef, "got %u\n", len);
+    ok(!lstrcmpW(name, unkW), "got %s\n", wine_dbgstr_w(name));
+
+    name[0] = 0;
+    len = 0xdeadbeef;
+    hr = WICMapGuidToShortName(&GUID_MetadataFormatUnknown, 0, name, &len);
+    ok(hr == E_INVALIDARG, "got %#x\n", hr);
+    ok(len == 0xdeadbeef, "got %u\n", len);
+    ok(!name[0], "got %s\n", wine_dbgstr_w(name));
+
+    hr = WICMapGuidToShortName(NULL, 8, name, NULL);
+    ok(hr == E_INVALIDARG, "got %#x\n", hr);
+}
+
 START_TEST(metadata)
 {
     CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
 
+    test_WICMapGuidToShortName();
     test_metadata_unknown();
     test_metadata_tEXt();
     test_metadata_gAMA();
diff --git a/dlls/windowscodecs/windowscodecs.spec b/dlls/windowscodecs/windowscodecs.spec
index 37a3a67d88..0972aedc04 100644
--- a/dlls/windowscodecs/windowscodecs.spec
+++ b/dlls/windowscodecs/windowscodecs.spec
@@ -109,7 +109,7 @@
 @ stdcall WICCreateColorContext_Proxy(ptr ptr)
 @ stdcall WICCreateImagingFactory_Proxy(long ptr)
 @ stub WICGetMetadataContentSize
-@ stub WICMapGuidToShortName
+@ stdcall WICMapGuidToShortName(ptr long ptr ptr)
 @ stub WICMapSchemaToName
 @ stub WICMapShortNameToGuid
 @ stub WICMatchMetadataContent
diff --git a/include/wincodec.idl b/include/wincodec.idl
index 2a8087661a..5c46aedac8 100644
--- a/include/wincodec.idl
+++ b/include/wincodec.idl
@@ -1051,6 +1051,8 @@ interface IWICEnumMetadataItem : IUnknown
 
 cpp_quote("HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitmapSource *pISrc, IWICBitmapSource **ppIDst);")
 
+cpp_quote("HRESULT WINAPI WICMapGuidToShortName(REFGUID,UINT,WCHAR *,UINT *);")
+
 cpp_quote("DEFINE_GUID(CLSID_WICBmpDecoder, 0x6b462062,0x7cbf,0x400d,0x9f,0xdb,0x81,0x3d,0xd1,0x0f,0x27,0x78);")
 cpp_quote("DEFINE_GUID(CLSID_WICPngDecoder, 0x389ea17b,0x5078,0x4cde,0xb6,0xef,0x25,0xc1,0x51,0x75,0xc7,0x51);")
 cpp_quote("DEFINE_GUID(CLSID_WICIcoDecoder, 0xc61bfcdf,0x2e0f,0x4aad,0xa8,0xd7,0xe0,0x6b,0xaf,0xeb,0xcd,0xfe);")
diff --git a/include/wincodecsdk.idl b/include/wincodecsdk.idl
index 69500ede9c..75492774f3 100644
--- a/include/wincodecsdk.idl
+++ b/include/wincodecsdk.idl
@@ -50,6 +50,29 @@ cpp_quote("DEFINE_GUID(GUID_MetadataFormatLSD, 0xe256031e,0x6299,0x4929,0xb9,0x8
 cpp_quote("DEFINE_GUID(GUID_MetadataFormatGCE, 0x2a25cad8,0xdeeb,0x4c69,0xa7,0x88,0x0e,0xc2,0x26,0x6d,0xca,0xfd);")
 cpp_quote("DEFINE_GUID(GUID_MetadataFormatAPE, 0x2e043dc2,0xc967,0x4e05,0x87,0x5e,0x61,0x8b,0xf6,0x7e,0x85,0xc3);")
 cpp_quote("DEFINE_GUID(GUID_MetadataFormatGifComment, 0xc4b6e0e0,0xcfb4,0x4ad3,0xab,0x33,0x9a,0xad,0x23,0x55,0xa3,0x4a);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatSubIfd, 0x58a2e128,0x2db9,0x4e57,0xbb,0x14,0x51,0x77,0x89,0x1e,0xd3,0x31);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatGps, 0x7134ab8a,0x9351,0x44ad,0xaf,0x62,0x44,0x8d,0xb6,0xb5,0x02,0xec);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatInterop, 0xed686f8e,0x681f,0x4c8b,0xbd,0x41,0xa8,0xad,0xdb,0xf6,0xb3,0xfc);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatApp0, 0x79007028,0x268d,0x45d6,0xa3,0xc2,0x35,0x4e,0x6a,0x50,0x4b,0xc9);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatApp1, 0x8fd3dfc3,0xf951,0x492b,0x81,0x7f,0x69,0xc2,0xe6,0xd9,0xa5,0xb0);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatApp13, 0x326556a2,0xf502,0x4354,0x9c,0xc0,0x8e,0x3f,0x48,0xea,0xf6,0xb5);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatIPTC, 0x4fab0914,0xe129,0x4087,0xa1,0xd1,0xbc,0x81,0x2d,0x45,0xa7,0xb5);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatIRB, 0x16100d66,0x8570,0x4bb9,0xb9,0x2d,0xfd,0xa4,0xb2,0x3e,0xce,0x67);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormat8BIMIPTC, 0x0010568c,0x0852,0x4e6a,0xb1,0x91,0x5c,0x33,0xac,0x5b,0x04,0x30);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormat8BIMResolutionInfo, 0x739f305d,0x81db,0x43cb,0xac,0x5e,0x55,0x01,0x3e,0xf9,0xf0,0x03);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormat8BIMIPTCDigest, 0x1ca32285,0x9ccd,0x4786,0x8b,0xd8,0x79,0x53,0x9d,0xb6,0xa0,0x06);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatThumbnail, 0x243dcee9,0x8703,0x40ee,0x8e,0xf0,0x22,0xa6,0x0,0xb8,0x5,0x8c);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatXMPBag, 0x833cca5f,0xdcb7,0x4516,0x80,0x6f,0x65,0x96,0xab,0x26,0xdc,0xe4);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatXMPSeq, 0x63e8df02,0xeb6c,0x456c,0xa2,0x24,0xb2,0x5e,0x79,0x4f,0xd6,0x48);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatXMPAlt, 0x7b08a675,0x91aa,0x481b,0xa7,0x98,0x4d,0xa9,0x49,0x08,0x61,0x3b);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatJpegChrominance, 0xf73d0dcf,0xcec6,0x4f85,0x9b,0x0e,0x1c,0x39,0x56,0xb1,0xbe,0xf7);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatJpegLuminance, 0x86908007,0xedfc,0x4860,0x8d,0x4b,0x4e,0xe6,0xe8,0x3e,0x60,0x58);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatJpegComment, 0x220e5f33,0xafd3,0x474e,0x9d,0x31,0x7d,0x4f,0xe7,0x30,0xf5,0x57);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunkbKGD, 0xe14d3571,0x6b47,0x4dea,0xb6,0xa,0x87,0xce,0xa,0x78,0xdf,0xb7);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunkiTXt, 0xc2bec729,0xb68,0x4b77,0xaa,0xe,0x62,0x95,0xa6,0xac,0x18,0x14);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunkhIST, 0xc59a82da,0xdb74,0x48a4,0xbd,0x6a,0xb6,0x9c,0x49,0x31,0xef,0x95);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunkiCCP, 0xeb4349ab,0xb685,0x450f,0x91,0xb5,0xe8,0x2,0xe8,0x92,0x53,0x6c);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunksRGB, 0xc115fd36,0xcc6f,0x4e3f,0x83,0x63,0x52,0x4b,0x87,0xc6,0xb0,0xd9);")
 
 cpp_quote("DEFINE_GUID(CLSID_WICUnknownMetadataReader, 0x699745c2,0x5066,0x4b82,0xa8,0xe3,0xd4,0x04,0x78,0xdb,0xec,0x8c);")
 cpp_quote("DEFINE_GUID(CLSID_WICUnknownMetadataWriter, 0xa09cca86,0x27ba,0x4f39,0x90,0x53,0x12,0x1f,0xa4,0xdc,0x08,0xfc);")
-- 
2.13.1




More information about the wine-patches mailing list