Author: akhaldi Date: Mon May 11 12:49:42 2015 New Revision: 67655
URL: http://svn.reactos.org/svn/reactos?rev=67655&view=rev Log: [WINDOWSCODECS] Sync with Wine Staging 1.7.37. CORE-9246
Modified: trunk/reactos/dll/win32/windowscodecs/imgfactory.c trunk/reactos/dll/win32/windowscodecs/info.c trunk/reactos/dll/win32/windowscodecs/pngformat.c trunk/reactos/dll/win32/windowscodecs/regsvr.c trunk/reactos/dll/win32/windowscodecs/tgaformat.c trunk/reactos/dll/win32/windowscodecs/tiffformat.c trunk/reactos/media/doc/README.WINE
Modified: trunk/reactos/dll/win32/windowscodecs/imgfactory.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/img... ============================================================================== --- trunk/reactos/dll/win32/windowscodecs/imgfactory.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/imgfactory.c [iso-8859-1] Mon May 11 12:49:42 2015 @@ -938,9 +938,129 @@ static HRESULT WINAPI ComponentFactory_CreateMetadataReaderFromContainer(IWICComponentFactory *iface, REFGUID format, const GUID *vendor, DWORD options, IStream *stream, IWICMetadataReader **reader) { - FIXME("%p,%s,%s,%x,%p,%p: stub\n", iface, debugstr_guid(format), debugstr_guid(vendor), + HRESULT hr; + IEnumUnknown *enumreaders; + IUnknown *unkreaderinfo; + IWICMetadataReaderInfo *readerinfo; + IWICPersistStream *wicpersiststream; + ULONG num_fetched; + GUID decoder_vendor; + BOOL matches; + LARGE_INTEGER zero; + + TRACE("%p,%s,%s,%x,%p,%p\n", iface, debugstr_guid(format), debugstr_guid(vendor), options, stream, reader); - return E_NOTIMPL; + + if (!format || !stream || !reader) + return E_INVALIDARG; + + zero.QuadPart = 0; + + hr = CreateComponentEnumerator(WICMetadataReader, WICComponentEnumerateDefault, &enumreaders); + if (FAILED(hr)) return hr; + + *reader = NULL; + +start: + while (!*reader) + { + hr = IEnumUnknown_Next(enumreaders, 1, &unkreaderinfo, &num_fetched); + + if (hr == S_OK) + { + hr = IUnknown_QueryInterface(unkreaderinfo, &IID_IWICMetadataReaderInfo, (void**)&readerinfo); + + if (SUCCEEDED(hr)) + { + if (vendor) + { + hr = IWICMetadataReaderInfo_GetVendorGUID(readerinfo, &decoder_vendor); + + if (FAILED(hr) || !IsEqualIID(vendor, &decoder_vendor)) + { + IWICMetadataReaderInfo_Release(readerinfo); + IUnknown_Release(unkreaderinfo); + continue; + } + } + + hr = IWICMetadataReaderInfo_MatchesPattern(readerinfo, format, stream, &matches); + + if (SUCCEEDED(hr) && matches) + { + hr = IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL); + + if (SUCCEEDED(hr)) + hr = IWICMetadataReaderInfo_CreateInstance(readerinfo, reader); + + if (SUCCEEDED(hr)) + { + hr = IWICMetadataReader_QueryInterface(*reader, &IID_IWICPersistStream, (void**)&wicpersiststream); + + if (SUCCEEDED(hr)) + { + hr = IWICPersistStream_LoadEx(wicpersiststream, + stream, vendor, options & WICPersistOptionsMask); + + IWICPersistStream_Release(wicpersiststream); + } + + if (FAILED(hr)) + { + IWICMetadataReader_Release(*reader); + *reader = NULL; + } + } + } + + IUnknown_Release(readerinfo); + } + + IUnknown_Release(unkreaderinfo); + } + else + break; + } + + if (!*reader && vendor) + { + vendor = NULL; + IEnumUnknown_Reset(enumreaders); + goto start; + } + + IEnumUnknown_Release(enumreaders); + + if (!*reader && !(options & WICMetadataCreationFailUnknown)) + { + hr = IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL); + + if (SUCCEEDED(hr)) + hr = UnknownMetadataReader_CreateInstance(&IID_IWICMetadataReader, (void**)reader); + + if (SUCCEEDED(hr)) + { + hr = IWICMetadataReader_QueryInterface(*reader, &IID_IWICPersistStream, (void**)&wicpersiststream); + + if (SUCCEEDED(hr)) + { + hr = IWICPersistStream_LoadEx(wicpersiststream, stream, NULL, options & WICPersistOptionsMask); + + IWICPersistStream_Release(wicpersiststream); + } + + if (FAILED(hr)) + { + IWICMetadataReader_Release(*reader); + *reader = NULL; + } + } + } + + if (*reader) + return S_OK; + else + return WINCODEC_ERR_COMPONENTNOTFOUND; }
static HRESULT WINAPI ComponentFactory_CreateMetadataWriter(IWICComponentFactory *iface,
Modified: trunk/reactos/dll/win32/windowscodecs/info.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/inf... ============================================================================== --- trunk/reactos/dll/win32/windowscodecs/info.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/info.c [iso-8859-1] Mon May 11 12:49:42 2015 @@ -39,6 +39,7 @@ static const WCHAR requiresfullstream_valuename[] = {'R','e','q','u','i','r','e','s','F','u','l','l','S','t','r','e','a','m',0}; static const WCHAR supportspadding_valuename[] = {'S','u','p','p','o','r','t','s','P','a','d','d','i','n','g',0}; static const WCHAR fileextensions_valuename[] = {'F','i','l','e','E','x','t','e','n','s','i','o','n','s',0}; +static const WCHAR containers_keyname[] = {'C','o','n','t','a','i','n','e','r','s',0};
static HRESULT ComponentInfo_GetStringValue(HKEY classkey, LPCWSTR value, UINT buffer_size, WCHAR *buffer, UINT *actual_size) @@ -134,7 +135,12 @@ return E_INVALIDARG;
ret = RegOpenKeyExW(classkey, subkeyname, 0, KEY_READ, &subkey); - if (ret != ERROR_SUCCESS) return HRESULT_FROM_WIN32(ret); + if (ret == ERROR_FILE_NOT_FOUND) + { + *actual_size = 0; + return S_OK; + } + else if (ret != ERROR_SUCCESS) return HRESULT_FROM_WIN32(ret);
if (buffer) { @@ -1613,10 +1619,11 @@ static HRESULT WINAPI MetadataReaderInfo_GetContainerFormats(IWICMetadataReaderInfo *iface, UINT length, GUID *formats, UINT *actual_length) { - if (!actual_length) return E_INVALIDARG; - - FIXME("(%p,%u,%p,%p): stub\n", iface, length, formats, actual_length); - return E_NOTIMPL; + MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface); + TRACE("(%p,%u,%p,%p)\n", iface, length, formats, actual_length); + + return ComponentInfo_GetGuidList(This->classkey, containers_keyname, length, + formats, actual_length); }
static HRESULT WINAPI MetadataReaderInfo_GetDeviceManufacturer(IWICMetadataReaderInfo *iface, @@ -1657,19 +1664,187 @@ }
static HRESULT WINAPI MetadataReaderInfo_GetPatterns(IWICMetadataReaderInfo *iface, - REFGUID container, UINT length, WICMetadataPattern *pattern, UINT *count, UINT *actual_length) -{ - if (!actual_length) return E_INVALIDARG; - - FIXME("(%p,%s,%u,%p,%p,%p): stub\n", iface, debugstr_guid(container), length, pattern, count, actual_length); - return E_NOTIMPL; + REFGUID container, UINT length, WICMetadataPattern *patterns, UINT *count, UINT *actual_length) +{ + MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface); + HRESULT hr=S_OK; + LONG res; + UINT pattern_count=0, patterns_size=0; + DWORD valuesize, patternsize; + BYTE *bPatterns=(BYTE*)patterns; + HKEY containers_key, guid_key, pattern_key; + WCHAR subkeyname[11]; + WCHAR guidkeyname[39]; + int i; + static const WCHAR uintformatW[] = {'%','u',0}; + static const WCHAR patternW[] = {'P','a','t','t','e','r','n',0}; + static const WCHAR positionW[] = {'P','o','s','i','t','i','o','n',0}; + static const WCHAR maskW[] = {'M','a','s','k',0}; + static const WCHAR dataoffsetW[] = {'D','a','t','a','O','f','f','s','e','t',0}; + + TRACE("(%p,%s,%u,%p,%p,%p)\n", iface, debugstr_guid(container), length, patterns, count, actual_length); + + if (!actual_length || !container) return E_INVALIDARG; + + res = RegOpenKeyExW(This->classkey, containers_keyname, 0, KEY_READ, &containers_key); + if (res == ERROR_SUCCESS) + { + StringFromGUID2(container, guidkeyname, 39); + + res = RegOpenKeyExW(containers_key, guidkeyname, 0, KEY_READ, &guid_key); + if (res == ERROR_FILE_NOT_FOUND) hr = WINCODEC_ERR_COMPONENTNOTFOUND; + else if (res != ERROR_SUCCESS) hr = HRESULT_FROM_WIN32(res); + + RegCloseKey(containers_key); + } + else if (res == ERROR_FILE_NOT_FOUND) hr = WINCODEC_ERR_COMPONENTNOTFOUND; + else hr = HRESULT_FROM_WIN32(res); + + if (SUCCEEDED(hr)) + { + res = RegQueryInfoKeyW(guid_key, NULL, NULL, NULL, &pattern_count, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + if (res != ERROR_SUCCESS) hr = HRESULT_FROM_WIN32(res); + + if (SUCCEEDED(hr)) + { + patterns_size = pattern_count * sizeof(WICMetadataPattern); + + for (i=0; i<pattern_count; i++) + { + snprintfW(subkeyname, 11, uintformatW, i); + res = RegOpenKeyExW(guid_key, subkeyname, 0, KEY_READ, &pattern_key); + if (res == ERROR_SUCCESS) + { + res = RegGetValueW(pattern_key, NULL, patternW, RRF_RT_REG_BINARY, NULL, + NULL, &patternsize); + patterns_size += patternsize*2; + + if ((length >= patterns_size) && (res == ERROR_SUCCESS)) + { + patterns[i].Length = patternsize; + + patterns[i].DataOffset.QuadPart = 0; + valuesize = sizeof(ULARGE_INTEGER); + RegGetValueW(pattern_key, NULL, dataoffsetW, RRF_RT_DWORD|RRF_RT_QWORD, NULL, + &patterns[i].DataOffset, &valuesize); + + patterns[i].Position.QuadPart = 0; + valuesize = sizeof(ULARGE_INTEGER); + res = RegGetValueW(pattern_key, NULL, positionW, RRF_RT_DWORD|RRF_RT_QWORD, NULL, + &patterns[i].Position, &valuesize); + + if (res == ERROR_SUCCESS) + { + patterns[i].Pattern = bPatterns+patterns_size-patternsize*2; + valuesize = patternsize; + res = RegGetValueW(pattern_key, NULL, patternW, RRF_RT_REG_BINARY, NULL, + patterns[i].Pattern, &valuesize); + } + + if (res == ERROR_SUCCESS) + { + patterns[i].Mask = bPatterns+patterns_size-patternsize; + valuesize = patternsize; + res = RegGetValueW(pattern_key, NULL, maskW, RRF_RT_REG_BINARY, NULL, + patterns[i].Mask, &valuesize); + } + } + + RegCloseKey(pattern_key); + } + if (res != ERROR_SUCCESS) + { + hr = HRESULT_FROM_WIN32(res); + break; + } + } + } + + RegCloseKey(guid_key); + } + + if (hr == S_OK) + { + *count = pattern_count; + *actual_length = patterns_size; + if (patterns && length < patterns_size) + hr = WINCODEC_ERR_INSUFFICIENTBUFFER; + } + + return hr; }
static HRESULT WINAPI MetadataReaderInfo_MatchesPattern(IWICMetadataReaderInfo *iface, REFGUID container, IStream *stream, BOOL *matches) { - FIXME("(%p,%s,%p,%p): stub\n", iface, debugstr_guid(container), stream, matches); - return E_NOTIMPL; + HRESULT hr; + WICMetadataPattern *patterns; + UINT pattern_count=0, patterns_size=0; + ULONG datasize=0; + BYTE *data=NULL; + ULONG bytesread; + UINT i; + LARGE_INTEGER seekpos; + ULONG pos; + + TRACE("(%p,%s,%p,%p)\n", iface, debugstr_guid(container), stream, matches); + + hr = MetadataReaderInfo_GetPatterns(iface, container, 0, NULL, &pattern_count, &patterns_size); + if (FAILED(hr)) return hr; + + patterns = HeapAlloc(GetProcessHeap(), 0, patterns_size); + if (!patterns) return E_OUTOFMEMORY; + + hr = MetadataReaderInfo_GetPatterns(iface, container, patterns_size, patterns, &pattern_count, &patterns_size); + if (FAILED(hr)) goto end; + + for (i=0; i<pattern_count; i++) + { + if (datasize < patterns[i].Length) + { + HeapFree(GetProcessHeap(), 0, data); + datasize = patterns[i].Length; + data = HeapAlloc(GetProcessHeap(), 0, patterns[i].Length); + if (!data) + { + hr = E_OUTOFMEMORY; + break; + } + } + + seekpos.QuadPart = patterns[i].Position.QuadPart; + hr = IStream_Seek(stream, seekpos, STREAM_SEEK_SET, NULL); + if (FAILED(hr)) break; + + hr = IStream_Read(stream, data, patterns[i].Length, &bytesread); + if (hr == S_FALSE || (hr == S_OK && bytesread != patterns[i].Length)) /* past end of stream */ + continue; + if (FAILED(hr)) break; + + for (pos=0; pos<patterns[i].Length; pos++) + { + if ((data[pos] & patterns[i].Mask[pos]) != patterns[i].Pattern[pos]) + break; + } + if (pos == patterns[i].Length) /* matches pattern */ + { + hr = S_OK; + *matches = TRUE; + break; + } + } + + if (i == pattern_count) /* does not match any pattern */ + { + hr = S_OK; + *matches = FALSE; + } + +end: + HeapFree(GetProcessHeap(), 0, patterns); + HeapFree(GetProcessHeap(), 0, data); + + return hr; }
static HRESULT WINAPI MetadataReaderInfo_CreateInstance(IWICMetadataReaderInfo *iface,
Modified: trunk/reactos/dll/win32/windowscodecs/pngformat.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/png... ============================================================================== --- trunk/reactos/dll/win32/windowscodecs/pngformat.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/pngformat.c [iso-8859-1] Mon May 11 12:49:42 2015 @@ -181,13 +181,28 @@ MAKE_FUNCPTR(png_write_rows); #undef MAKE_FUNCPTR
+static CRITICAL_SECTION init_png_cs; +static CRITICAL_SECTION_DEBUG init_png_cs_debug = +{ + 0, 0, &init_png_cs, + { &init_png_cs_debug.ProcessLocksList, + &init_png_cs_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": init_png_cs") } +}; +static CRITICAL_SECTION init_png_cs = { &init_png_cs_debug, -1, 0, 0, 0, 0 }; + static void *load_libpng(void) { - if((libpng_handle = wine_dlopen(SONAME_LIBPNG, RTLD_NOW, NULL, 0)) != NULL) { + void *result; + + EnterCriticalSection(&init_png_cs); + + if(!libpng_handle && (libpng_handle = wine_dlopen(SONAME_LIBPNG, RTLD_NOW, NULL, 0)) != NULL) {
#define LOAD_FUNCPTR(f) \ if((p##f = wine_dlsym(libpng_handle, #f, NULL, 0)) == NULL) { \ libpng_handle = NULL; \ + LeaveCriticalSection(&init_png_cs); \ return NULL; \ } LOAD_FUNCPTR(png_create_read_struct); @@ -232,7 +247,12 @@
#undef LOAD_FUNCPTR } - return libpng_handle; + + result = libpng_handle; + + LeaveCriticalSection(&init_png_cs); + + return result; }
static void user_error_fn(png_structp png_ptr, png_const_charp error_message) @@ -978,7 +998,7 @@
*ppv = NULL;
- if (!libpng_handle && !load_libpng()) + if (!load_libpng()) { ERR("Failed reading PNG because unable to find %s\n",SONAME_LIBPNG); return E_FAIL; @@ -1707,7 +1727,7 @@
*ppv = NULL;
- if (!libpng_handle && !load_libpng()) + if (!load_libpng()) { ERR("Failed writing PNG because unable to find %s\n",SONAME_LIBPNG); return E_FAIL;
Modified: trunk/reactos/dll/win32/windowscodecs/regsvr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/reg... ============================================================================== --- trunk/reactos/dll/win32/windowscodecs/regsvr.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/regsvr.c [iso-8859-1] Mon May 11 12:49:42 2015 @@ -133,21 +133,6 @@ */ static const WCHAR clsid_keyname[] = { 'C', 'L', 'S', 'I', 'D', 0 }; -static const WCHAR curver_keyname[] = { - 'C', 'u', 'r', 'V', 'e', 'r', 0 }; -static const WCHAR ips_keyname[] = { - 'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r', - 0 }; -static const WCHAR ips32_keyname[] = { - 'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r', - '3', '2', 0 }; -static const WCHAR progid_keyname[] = { - 'P', 'r', 'o', 'g', 'I', 'D', 0 }; -static const WCHAR viprogid_keyname[] = { - 'V', 'e', 'r', 's', 'i', 'o', 'n', 'I', 'n', 'd', 'e', 'p', - 'e', 'n', 'd', 'e', 'n', 't', 'P', 'r', 'o', 'g', 'I', 'D', - 0 }; -static const char tmodel_valuename[] = "ThreadingModel"; static const char author_valuename[] = "Author"; static const char friendlyname_valuename[] = "FriendlyName"; static const WCHAR vendor_valuename[] = {'V','e','n','d','o','r',0};
Modified: trunk/reactos/dll/win32/windowscodecs/tgaformat.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/tga... ============================================================================== --- trunk/reactos/dll/win32/windowscodecs/tgaformat.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/tgaformat.c [iso-8859-1] Mon May 11 12:49:42 2015 @@ -275,7 +275,7 @@ This->image_offset = This->colormap_offset + This->colormap_length;
/* Read footer if there is one */ - seek.QuadPart = -sizeof(tga_footer); + seek.QuadPart = -(LONGLONG)sizeof(tga_footer); hr = IStream_Seek(pIStream, seek, STREAM_SEEK_END, NULL);
if (SUCCEEDED(hr)) {
Modified: trunk/reactos/dll/win32/windowscodecs/tiffformat.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/tif... ============================================================================== --- trunk/reactos/dll/win32/windowscodecs/tiffformat.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/tiffformat.c [iso-8859-1] Mon May 11 12:49:42 2015 @@ -309,7 +309,19 @@ decode_info->invert_grayscale = 1; /* fall through */ case 1: /* BlackIsZero */ - if (samples != 1) + if (samples == 2) + { + ret = pTIFFGetField(tiff, TIFFTAG_EXTRASAMPLES, &extra_sample_count, &extra_samples); + if (!ret) + { + extra_sample_count = 1; + extra_sample = 0; + extra_samples = &extra_sample; + } + else + FIXME("ignoring extra alpha %u/%u bps %u\n", extra_sample_count, extra_samples[0], bps); + } + else if (samples != 1) { FIXME("unhandled grayscale sample count %u\n", samples); return E_FAIL;
Modified: trunk/reactos/media/doc/README.WINE URL: http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=6... ============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Mon May 11 12:49:42 2015 @@ -202,7 +202,7 @@ reactos/dll/win32/version # Synced to WineStaging-1.7.37 reactos/dll/win32/wbemdisp # Synced to WineStaging-1.7.37 reactos/dll/win32/wbemprox # Synced to WineStaging-1.7.37 -reactos/dll/win32/windowscodecs # Synced to Wine-1.7.27 +reactos/dll/win32/windowscodecs # Synced to WineStaging-1.7.37 reactos/dll/win32/windowscodecsext # Synced to Wine-1.7.27 reactos/dll/win32/winemp3.acm # Synced to Wine-1.7.27 reactos/dll/win32/wing32 # Out of sync