windowscodecs: Create global metadata readers from GIF decoder data.

This commit is contained in:
Dmitry Timoshkov 2012-09-18 13:00:33 +09:00 committed by Alexandre Julliard
parent 4786472879
commit 609b9a4da8
2 changed files with 32 additions and 10 deletions

View File

@ -1285,15 +1285,18 @@ static HRESULT WINAPI GifDecoder_Block_GetContainerFormat(IWICMetadataBlockReade
static HRESULT WINAPI GifDecoder_Block_GetCount(IWICMetadataBlockReader *iface,
UINT *count)
{
GifDecoder *This = impl_from_IWICMetadataBlockReader(iface);
TRACE("%p,%p\n", iface, count);
if (!count) return E_INVALIDARG;
*count = 1;
*count = This->gif->Extensions.ExtensionBlockCount + 1;
return S_OK;
}
static HRESULT create_LSD_metadata_reader(GifDecoder *This, IWICMetadataReader **reader)
static HRESULT create_metadata_reader(const void *data, int data_size,
const CLSID *clsid, IWICMetadataReader **reader)
{
HRESULT hr;
IWICMetadataReader *metadata_reader;
@ -1302,7 +1305,7 @@ static HRESULT create_LSD_metadata_reader(GifDecoder *This, IWICMetadataReader *
/* FIXME: Use IWICComponentFactory_CreateMetadataReader once it's implemented */
hr = CoCreateInstance(&CLSID_WICLSDMetadataReader, NULL, CLSCTX_INPROC_SERVER,
hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER,
&IID_IWICMetadataReader, (void **)&metadata_reader);
if (FAILED(hr)) return hr;
@ -1313,7 +1316,7 @@ static HRESULT create_LSD_metadata_reader(GifDecoder *This, IWICMetadataReader *
return hr;
}
stream = create_stream(This->LSD_data, sizeof(This->LSD_data));
stream = create_stream(data, data_size);
IWICPersistStream_LoadEx(persist, stream, NULL, WICPersistOptionsDefault);
IStream_Release(stream);
@ -1327,12 +1330,35 @@ static HRESULT WINAPI GifDecoder_Block_GetReaderByIndex(IWICMetadataBlockReader
UINT index, IWICMetadataReader **reader)
{
GifDecoder *This = impl_from_IWICMetadataBlockReader(iface);
int i;
TRACE("(%p,%u,%p)\n", iface, index, reader);
if (!reader || index != 0) return E_INVALIDARG;
if (!reader) return E_INVALIDARG;
return create_LSD_metadata_reader(This, reader);
if (index == 0)
return create_metadata_reader(&This->LSD_data, sizeof(This->LSD_data),
&CLSID_WICLSDMetadataReader, reader);
for (i = 0; i < This->gif->Extensions.ExtensionBlockCount; i++)
{
const CLSID *clsid;
if (index != i + 1) continue;
if (This->gif->Extensions.ExtensionBlocks[i].Function == APPLICATION_EXT_FUNC_CODE)
clsid = &CLSID_WICAPEMetadataReader;
else if (This->gif->Extensions.ExtensionBlocks[i].Function == COMMENT_EXT_FUNC_CODE)
clsid = &CLSID_WICGifCommentMetadataReader;
else
clsid = &CLSID_WICUnknownMetadataReader;
return create_metadata_reader(This->gif->Extensions.ExtensionBlocks[i].Bytes,
This->gif->Extensions.ExtensionBlocks[i].ByteCount,
clsid, reader);
}
return E_INVALIDARG;
}
static HRESULT WINAPI GifDecoder_Block_GetEnumerator(IWICMetadataBlockReader *iface,

View File

@ -1204,7 +1204,6 @@ static void test_metadata_gif(void)
hr = IWICMetadataBlockReader_GetCount(blockreader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
todo_wine
ok(count == 4, "expected 4, got %u\n", count);
hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 0, &reader);
@ -1226,7 +1225,6 @@ todo_wine
}
hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 1, &reader);
todo_wine
ok(hr == S_OK, "GetReaderByIndex error %#x\n", hr);
if (SUCCEEDED(hr))
@ -1245,7 +1243,6 @@ todo_wine
}
hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 2, &reader);
todo_wine
ok(hr == S_OK, "GetReaderByIndex error %#x\n", hr);
if (SUCCEEDED(hr))
@ -1264,7 +1261,6 @@ todo_wine
}
hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 3, &reader);
todo_wine
ok(hr == S_OK, "GetReaderByIndex error %#x\n", hr);
if (SUCCEEDED(hr))