From ca9d03a7ac6bb599e50aa05ea5ec99d5cf096e2a Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 2 Apr 2018 20:49:40 +0200 Subject: [PATCH] windowscodecs: Directly use patterns stored in component info object in IWICMetadataReaderInfo::MatchesPattern implementation. Signed-off-by: Jacek Caban Signed-off-by: Vincent Povirk Signed-off-by: Alexandre Julliard --- dlls/windowscodecs/info.c | 42 ++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/dlls/windowscodecs/info.c b/dlls/windowscodecs/info.c index 4d7c7b901a2..6652ee3eed9 100644 --- a/dlls/windowscodecs/info.c +++ b/dlls/windowscodecs/info.c @@ -1758,11 +1758,11 @@ static HRESULT WINAPI MetadataReaderInfo_GetPatterns(IWICMetadataReaderInfo *ifa } static HRESULT WINAPI MetadataReaderInfo_MatchesPattern(IWICMetadataReaderInfo *iface, - REFGUID container, IStream *stream, BOOL *matches) + REFGUID container_guid, IStream *stream, BOOL *matches) { + MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface); + struct metadata_container *container; HRESULT hr; - WICMetadataPattern *patterns; - UINT pattern_count=0, patterns_size=0; ULONG datasize=0; BYTE *data=NULL; ULONG bytesread; @@ -1770,24 +1770,18 @@ static HRESULT WINAPI MetadataReaderInfo_MatchesPattern(IWICMetadataReaderInfo * LARGE_INTEGER seekpos; ULONG pos; - TRACE("(%p,%s,%p,%p)\n", iface, debugstr_guid(container), stream, matches); + TRACE("(%p,%s,%p,%p)\n", iface, debugstr_guid(container_guid), stream, matches); - hr = MetadataReaderInfo_GetPatterns(iface, container, 0, NULL, &pattern_count, &patterns_size); - if (FAILED(hr)) return hr; + if (!(container = get_metadata_container(This, container_guid))) + return WINCODEC_ERR_COMPONENTNOTFOUND; - 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; ipattern_count; i++) { - if (datasize < patterns[i].Length) + if (datasize < container->patterns[i].Length) { HeapFree(GetProcessHeap(), 0, data); - datasize = patterns[i].Length; - data = HeapAlloc(GetProcessHeap(), 0, patterns[i].Length); + datasize = container->patterns[i].Length; + data = HeapAlloc(GetProcessHeap(), 0, container->patterns[i].Length); if (!data) { hr = E_OUTOFMEMORY; @@ -1795,21 +1789,21 @@ static HRESULT WINAPI MetadataReaderInfo_MatchesPattern(IWICMetadataReaderInfo * } } - seekpos.QuadPart = patterns[i].Position.QuadPart; + seekpos.QuadPart = container->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 */ + hr = IStream_Read(stream, data, container->patterns[i].Length, &bytesread); + if (hr == S_FALSE || (hr == S_OK && bytesread != container->patterns[i].Length)) /* past end of stream */ continue; if (FAILED(hr)) break; - for (pos=0; pospatterns[i].Length; pos++) { - if ((data[pos] & patterns[i].Mask[pos]) != patterns[i].Pattern[pos]) + if ((data[pos] & container->patterns[i].Mask[pos]) != container->patterns[i].Pattern[pos]) break; } - if (pos == patterns[i].Length) /* matches pattern */ + if (pos == container->patterns[i].Length) /* matches pattern */ { hr = S_OK; *matches = TRUE; @@ -1817,14 +1811,12 @@ static HRESULT WINAPI MetadataReaderInfo_MatchesPattern(IWICMetadataReaderInfo * } } - if (i == pattern_count) /* does not match any pattern */ + if (i == container->pattern_count) /* does not match any pattern */ { hr = S_OK; *matches = FALSE; } -end: - HeapFree(GetProcessHeap(), 0, patterns); HeapFree(GetProcessHeap(), 0, data); return hr;