Commit fe7885be authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

windowscodecs: Don't reorder gif extension blocks in GetReaderByIndex.

parent 9c22a5ea
...@@ -947,7 +947,10 @@ static HRESULT WINAPI GifFrameDecode_Block_GetReaderByIndex(IWICMetadataBlockRea ...@@ -947,7 +947,10 @@ static HRESULT WINAPI GifFrameDecode_Block_GetReaderByIndex(IWICMetadataBlockRea
UINT index, IWICMetadataReader **reader) UINT index, IWICMetadataReader **reader)
{ {
GifFrameDecode *This = frame_from_IWICMetadataBlockReader(iface); GifFrameDecode *This = frame_from_IWICMetadataBlockReader(iface);
int i, gce_index = -1, gce_skipped = 0; class_constructor constructor;
ExtensionBlock *ext;
const void *data;
int data_size;
TRACE("(%p,%u,%p)\n", iface, index, reader); TRACE("(%p,%u,%p)\n", iface, index, reader);
...@@ -959,40 +962,27 @@ static HRESULT WINAPI GifFrameDecode_Block_GetReaderByIndex(IWICMetadataBlockRea ...@@ -959,40 +962,27 @@ static HRESULT WINAPI GifFrameDecode_Block_GetReaderByIndex(IWICMetadataBlockRea
if (index >= This->frame->Extensions.ExtensionBlockCount + 1) if (index >= This->frame->Extensions.ExtensionBlockCount + 1)
return E_INVALIDARG; return E_INVALIDARG;
for (i = 0; i < This->frame->Extensions.ExtensionBlockCount; i++) ext = This->frame->Extensions.ExtensionBlocks + index - 1;
if (ext->Function == GRAPHICS_EXT_FUNC_CODE)
{ {
class_constructor constructor; constructor = GCEReader_CreateInstance;
const void *data; data = ext->Bytes + 3;
int data_size; data_size = ext->ByteCount - 4;
}
if (index != i + 1 - gce_skipped) continue; else if (ext->Function == COMMENT_EXT_FUNC_CODE)
{
if (This->frame->Extensions.ExtensionBlocks[i].Function == GRAPHICS_EXT_FUNC_CODE) constructor = GifCommentReader_CreateInstance;
{ data = ext->Bytes;
gce_index = i; data_size = ext->ByteCount;
gce_skipped = 1; }
continue; else
} {
else if (This->frame->Extensions.ExtensionBlocks[i].Function == COMMENT_EXT_FUNC_CODE) constructor = UnknownMetadataReader_CreateInstance;
{ data = ext->Bytes;
constructor = GifCommentReader_CreateInstance; data_size = ext->ByteCount;
data = This->frame->Extensions.ExtensionBlocks[i].Bytes;
data_size = This->frame->Extensions.ExtensionBlocks[i].ByteCount;
}
else
{
constructor = UnknownMetadataReader_CreateInstance;
data = This->frame->Extensions.ExtensionBlocks[i].Bytes;
data_size = This->frame->Extensions.ExtensionBlocks[i].ByteCount;
}
return create_metadata_reader(data, data_size, constructor, reader);
} }
if (gce_index == -1) return E_INVALIDARG; return create_metadata_reader(data, data_size, constructor, reader);
return create_metadata_reader(This->frame->Extensions.ExtensionBlocks[gce_index].Bytes + 3,
This->frame->Extensions.ExtensionBlocks[gce_index].ByteCount - 4,
GCEReader_CreateInstance, reader);
} }
static HRESULT WINAPI GifFrameDecode_Block_GetEnumerator(IWICMetadataBlockReader *iface, static HRESULT WINAPI GifFrameDecode_Block_GetEnumerator(IWICMetadataBlockReader *iface,
......
...@@ -188,10 +188,10 @@ static const char animatedgif[] = { ...@@ -188,10 +188,10 @@ static const char animatedgif[] = {
0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x81, 0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x81,
0xDE,0xDE,0xDE,0x00,0x00,0x00, 0xDE,0xDE,0xDE,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x4C,0x01,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x4C,0x01,0x00,
0x21,0xF9,0x04,0x01,0x0A,0x00,0x01,0x00,
0x21,0xFE,0x08,'i','m','a','g','e',' ','#','1',0x00, 0x21,0xFE,0x08,'i','m','a','g','e',' ','#','1',0x00,
0x21,0x01,0x0C,'p','l','a','i','n','t','e','x','t',' ','#','1',0x00, 0x21,0x01,0x0C,'p','l','a','i','n','t','e','x','t',' ','#','1',0x00,
0x21,0xF9,0x04,0x01,0x0A,0x00,0x01,0x00,0x2C, 0x2C,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x81,
0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x81,
0x4D,0x4D,0x4D,0x00,0x00,0x00, 0x4D,0x4D,0x4D,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x44,0x01,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x44,0x01,0x00,
0x21,0xFE,0x08,'i','m','a','g','e',' ','#','2',0x00, 0x21,0xFE,0x08,'i','m','a','g','e',' ','#','2',0x00,
...@@ -1517,15 +1517,14 @@ static void test_metadata_gif(void) ...@@ -1517,15 +1517,14 @@ static void test_metadata_gif(void)
{ {
hr = IWICMetadataReader_GetMetadataFormat(reader, &format); hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
ok(hr == S_OK, "GetMetadataFormat failed, hr=%#lx\n", hr); ok(hr == S_OK, "GetMetadataFormat failed, hr=%#lx\n", hr);
ok(IsEqualGUID(&format, &GUID_MetadataFormatGifComment), /* Comment Extension */ ok(IsEqualGUID(&format, &GUID_MetadataFormatGCE), /* Graphic Control Extension */
"wrong metadata format %s\n", wine_dbgstr_guid(&format)); "wrong metadata format %s\n", wine_dbgstr_guid(&format));
hr = IWICMetadataReader_GetCount(reader, &count); hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#lx\n", hr); ok(hr == S_OK, "GetCount error %#lx\n", hr);
ok(count == ARRAY_SIZE(animated_gif_comment_2), "unexpected count %u\n", count); ok(count == ARRAY_SIZE(animated_gif_GCE), "unexpected count %u\n", count);
if (count == 1) compare_metadata(reader, animated_gif_GCE, count);
compare_metadata(reader, animated_gif_comment_2, count);
IWICMetadataReader_Release(reader); IWICMetadataReader_Release(reader);
} }
...@@ -1537,14 +1536,15 @@ static void test_metadata_gif(void) ...@@ -1537,14 +1536,15 @@ static void test_metadata_gif(void)
{ {
hr = IWICMetadataReader_GetMetadataFormat(reader, &format); hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
ok(hr == S_OK, "GetMetadataFormat failed, hr=%#lx\n", hr); ok(hr == S_OK, "GetMetadataFormat failed, hr=%#lx\n", hr);
ok(IsEqualGUID(&format, &GUID_MetadataFormatUnknown), ok(IsEqualGUID(&format, &GUID_MetadataFormatGifComment), /* Comment Extension */
"wrong metadata format %s\n", wine_dbgstr_guid(&format)); "wrong metadata format %s\n", wine_dbgstr_guid(&format));
hr = IWICMetadataReader_GetCount(reader, &count); hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#lx\n", hr); ok(hr == S_OK, "GetCount error %#lx\n", hr);
ok(count == ARRAY_SIZE(animated_gif_plain_2), "unexpected count %u\n", count); ok(count == ARRAY_SIZE(animated_gif_comment_2), "unexpected count %u\n", count);
compare_metadata(reader, animated_gif_plain_2, count); if (count == 1)
compare_metadata(reader, animated_gif_comment_2, count);
IWICMetadataReader_Release(reader); IWICMetadataReader_Release(reader);
} }
...@@ -1556,14 +1556,14 @@ static void test_metadata_gif(void) ...@@ -1556,14 +1556,14 @@ static void test_metadata_gif(void)
{ {
hr = IWICMetadataReader_GetMetadataFormat(reader, &format); hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
ok(hr == S_OK, "GetMetadataFormat failed, hr=%#lx\n", hr); ok(hr == S_OK, "GetMetadataFormat failed, hr=%#lx\n", hr);
ok(IsEqualGUID(&format, &GUID_MetadataFormatGCE), /* Graphic Control Extension */ ok(IsEqualGUID(&format, &GUID_MetadataFormatUnknown),
"wrong metadata format %s\n", wine_dbgstr_guid(&format)); "wrong metadata format %s\n", wine_dbgstr_guid(&format));
hr = IWICMetadataReader_GetCount(reader, &count); hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#lx\n", hr); ok(hr == S_OK, "GetCount error %#lx\n", hr);
ok(count == ARRAY_SIZE(animated_gif_GCE), "unexpected count %u\n", count); ok(count == ARRAY_SIZE(animated_gif_plain_2), "unexpected count %u\n", count);
compare_metadata(reader, animated_gif_GCE, count); compare_metadata(reader, animated_gif_plain_2, count);
IWICMetadataReader_Release(reader); IWICMetadataReader_Release(reader);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment