[5/9] windowscodecs: GIF decoder should add header and trailer to extension blocks.
Dmitry Timoshkov
dmitry at baikal.ru
Mon Sep 17 22:59:50 CDT 2012
Metadata readers now have access to complete and correctly formatted data
stream.
---
dlls/windowscodecs/gifformat.c | 4 ++--
dlls/windowscodecs/ungif.c | 19 ++++++++++++-------
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/dlls/windowscodecs/gifformat.c b/dlls/windowscodecs/gifformat.c
index 05bf2db..7b88735 100644
--- a/dlls/windowscodecs/gifformat.c
+++ b/dlls/windowscodecs/gifformat.c
@@ -857,8 +857,8 @@ static const void *get_GCE_data(GifFrameDecode *This)
for (i = 0; i < This->frame->Extensions.ExtensionBlockCount; i++)
{
if (This->frame->Extensions.ExtensionBlocks[i].Function == GRAPHICS_EXT_FUNC_CODE &&
- This->frame->Extensions.ExtensionBlocks[i].ByteCount == 4)
- return This->frame->Extensions.ExtensionBlocks[i].Bytes;
+ This->frame->Extensions.ExtensionBlocks[i].ByteCount == 8)
+ return This->frame->Extensions.ExtensionBlocks[i].Bytes + 3;
}
return NULL;
}
diff --git a/dlls/windowscodecs/ungif.c b/dlls/windowscodecs/ungif.c
index 2330192..0f55242 100644
--- a/dlls/windowscodecs/ungif.c
+++ b/dlls/windowscodecs/ungif.c
@@ -209,13 +209,18 @@ AddExtensionBlock(Extensions *New,
ep = &New->ExtensionBlocks[New->ExtensionBlockCount++];
- ep->ByteCount=Len;
- ep->Bytes = ungif_alloc(ep->ByteCount);
+ ep->ByteCount=Len + 3;
+ ep->Bytes = ungif_alloc(ep->ByteCount + 3);
if (ep->Bytes == NULL)
return (GIF_ERROR);
+ /* Extension Header */
+ ep->Bytes[0] = 0x21;
+ ep->Bytes[1] = New->Function;
+ ep->Bytes[2] = Len;
+
if (ExtData) {
- memcpy(ep->Bytes, ExtData, Len);
+ memcpy(ep->Bytes + 3, ExtData, Len);
ep->Function = New->Function;
}
@@ -238,12 +243,12 @@ AppendExtensionBlock(Extensions *New,
if (ep->Bytes == NULL)
return (GIF_ERROR);
+ ep->Bytes[ep->ByteCount] = Len;
+
if (ExtData)
- {
- ep->Bytes[ep->ByteCount] = Len;
memcpy(ep->Bytes + ep->ByteCount + 1, ExtData, Len);
- ep->ByteCount += Len + 1;
- }
+
+ ep->ByteCount += Len + 1;
return (GIF_OK);
}
--
1.7.11.6
More information about the wine-patches
mailing list