mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
windowscodecs: Directly use patterns stored in component info object in IWICMetadataReaderInfo::MatchesPattern implementation.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Vincent Povirk <vincent@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
8be7a1057e
commit
ca9d03a7ac
1 changed files with 17 additions and 25 deletions
|
@ -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; i<pattern_count; i++)
|
||||
for (i=0; i < container->pattern_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; pos<patterns[i].Length; pos++)
|
||||
for (pos=0; pos < container->patterns[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;
|
||||
|
|
Loading…
Reference in a new issue