Commit 629e7f44 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

windowscodecs: Store GIF frame extensions in a dedicated Extensions structure.

parent 8e87b923
...@@ -699,8 +699,8 @@ static HRESULT WINAPI GifFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface, ...@@ -699,8 +699,8 @@ static HRESULT WINAPI GifFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface,
} }
/* look for the transparent color extension */ /* look for the transparent color extension */
for (i = 0; i < This->frame->ExtensionBlockCount; ++i) { for (i = 0; i < This->frame->Extensions.ExtensionBlockCount; ++i) {
eb = This->frame->ExtensionBlocks + i; eb = This->frame->Extensions.ExtensionBlocks + i;
if (eb->Function == 0xF9 && eb->ByteCount == 4) { if (eb->Function == 0xF9 && eb->ByteCount == 4) {
if ((eb->Bytes[0] & 1) == 1) { if ((eb->Bytes[0] & 1) == 1) {
trans = (unsigned char)eb->Bytes[3]; trans = (unsigned char)eb->Bytes[3];
...@@ -854,11 +854,11 @@ static const void *get_GCE_data(GifFrameDecode *This) ...@@ -854,11 +854,11 @@ static const void *get_GCE_data(GifFrameDecode *This)
{ {
int i; int i;
for (i = 0; i < This->frame->ExtensionBlockCount; i++) for (i = 0; i < This->frame->Extensions.ExtensionBlockCount; i++)
{ {
if (This->frame->ExtensionBlocks[i].Function == GRAPHICS_EXT_FUNC_CODE && if (This->frame->Extensions.ExtensionBlocks[i].Function == GRAPHICS_EXT_FUNC_CODE &&
This->frame->ExtensionBlocks[i].ByteCount == 4) This->frame->Extensions.ExtensionBlocks[i].ByteCount == 4)
return This->frame->ExtensionBlocks[i].Bytes; return This->frame->Extensions.ExtensionBlocks[i].Bytes;
} }
return NULL; return NULL;
} }
......
...@@ -191,7 +191,7 @@ FreeMapObject(ColorMapObject * Object) { ...@@ -191,7 +191,7 @@ FreeMapObject(ColorMapObject * Object) {
} }
static int static int
AddExtensionBlock(SavedImage * New, AddExtensionBlock(Extensions *New,
int Len, int Len,
const unsigned char ExtData[]) { const unsigned char ExtData[]) {
...@@ -223,18 +223,18 @@ AddExtensionBlock(SavedImage * New, ...@@ -223,18 +223,18 @@ AddExtensionBlock(SavedImage * New,
} }
static void static void
FreeExtension(SavedImage * Image) FreeExtension(Extensions *Extensions)
{ {
ExtensionBlock *ep; ExtensionBlock *ep;
if ((Image == NULL) || (Image->ExtensionBlocks == NULL)) { if ((Extensions == NULL) || (Extensions->ExtensionBlocks == NULL)) {
return; return;
} }
for (ep = Image->ExtensionBlocks; for (ep = Extensions->ExtensionBlocks;
ep < (Image->ExtensionBlocks + Image->ExtensionBlockCount); ep++) ep < (Extensions->ExtensionBlocks + Extensions->ExtensionBlockCount); ep++)
ungif_free(ep->Bytes); ungif_free(ep->Bytes);
ungif_free(Image->ExtensionBlocks); ungif_free(Extensions->ExtensionBlocks);
Image->ExtensionBlocks = NULL; Extensions->ExtensionBlocks = NULL;
} }
/****************************************************************************** /******************************************************************************
...@@ -258,8 +258,8 @@ FreeSavedImages(GifFileType * GifFile) { ...@@ -258,8 +258,8 @@ FreeSavedImages(GifFileType * GifFile) {
ungif_free(sp->RasterBits); ungif_free(sp->RasterBits);
if (sp->ExtensionBlocks) if (sp->Extensions.ExtensionBlocks)
FreeExtension(sp); FreeExtension(&sp->Extensions);
} }
ungif_free(GifFile->SavedImages); ungif_free(GifFile->SavedImages);
GifFile->SavedImages=NULL; GifFile->SavedImages=NULL;
...@@ -424,8 +424,8 @@ DGifGetImageDesc(GifFileType * GifFile) { ...@@ -424,8 +424,8 @@ DGifGetImageDesc(GifFileType * GifFile) {
sp->ImageDesc.ColorMap->SortFlag = GifFile->Image.ColorMap->SortFlag; sp->ImageDesc.ColorMap->SortFlag = GifFile->Image.ColorMap->SortFlag;
} }
sp->RasterBits = NULL; sp->RasterBits = NULL;
sp->ExtensionBlockCount = 0; sp->Extensions.ExtensionBlockCount = 0;
sp->ExtensionBlocks = NULL; sp->Extensions.ExtensionBlocks = NULL;
GifFile->ImageCount++; GifFile->ImageCount++;
...@@ -845,7 +845,7 @@ DGifSlurp(GifFileType * GifFile) { ...@@ -845,7 +845,7 @@ DGifSlurp(GifFileType * GifFile) {
GifRecordType RecordType; GifRecordType RecordType;
SavedImage *sp; SavedImage *sp;
GifByteType *ExtData; GifByteType *ExtData;
SavedImage temp_save; Extensions temp_save;
temp_save.ExtensionBlocks = NULL; temp_save.ExtensionBlocks = NULL;
temp_save.ExtensionBlockCount = 0; temp_save.ExtensionBlockCount = 0;
...@@ -870,8 +870,8 @@ DGifSlurp(GifFileType * GifFile) { ...@@ -870,8 +870,8 @@ DGifSlurp(GifFileType * GifFile) {
GIF_ERROR) GIF_ERROR)
return (GIF_ERROR); return (GIF_ERROR);
if (temp_save.ExtensionBlocks) { if (temp_save.ExtensionBlocks) {
sp->ExtensionBlocks = temp_save.ExtensionBlocks; sp->Extensions.ExtensionBlocks = temp_save.ExtensionBlocks;
sp->ExtensionBlockCount = temp_save.ExtensionBlockCount; sp->Extensions.ExtensionBlockCount = temp_save.ExtensionBlockCount;
temp_save.ExtensionBlocks = NULL; temp_save.ExtensionBlocks = NULL;
temp_save.ExtensionBlockCount = 0; temp_save.ExtensionBlockCount = 0;
...@@ -879,7 +879,7 @@ DGifSlurp(GifFileType * GifFile) { ...@@ -879,7 +879,7 @@ DGifSlurp(GifFileType * GifFile) {
/* FIXME: The following is wrong. It is left in only for /* FIXME: The following is wrong. It is left in only for
* backwards compatibility. Someday it should go away. Use * backwards compatibility. Someday it should go away. Use
* the sp->ExtensionBlocks->Function variable instead. */ * the sp->ExtensionBlocks->Function variable instead. */
sp->Function = sp->ExtensionBlocks[0].Function; sp->Extensions.Function = sp->Extensions.ExtensionBlocks[0].Function;
} }
break; break;
......
...@@ -98,6 +98,19 @@ typedef struct GifImageDesc { ...@@ -98,6 +98,19 @@ typedef struct GifImageDesc {
ColorMapObject *ColorMap; /* The local color map */ ColorMapObject *ColorMap; /* The local color map */
} GifImageDesc; } GifImageDesc;
/* This is the in-core version of an extension record */
typedef struct {
int Function; /* Holds the type of the Extension block. */
int ByteCount;
char *Bytes;
} ExtensionBlock;
typedef struct {
int Function; /* DEPRECATED: Use ExtensionBlocks[x].Function instead */
int ExtensionBlockCount;
ExtensionBlock *ExtensionBlocks;
} Extensions;
typedef struct GifFileType { typedef struct GifFileType {
GifWord SWidth, SHeight, /* Screen dimensions. */ GifWord SWidth, SHeight, /* Screen dimensions. */
SColorResolution, /* How many colors can we generate? */ SColorResolution, /* How many colors can we generate? */
...@@ -152,20 +165,11 @@ int DGifCloseFile(GifFileType * GifFile) DECLSPEC_HIDDEN; ...@@ -152,20 +165,11 @@ int DGifCloseFile(GifFileType * GifFile) DECLSPEC_HIDDEN;
* Support for the in-core structures allocation (slurp mode). * Support for the in-core structures allocation (slurp mode).
*****************************************************************************/ *****************************************************************************/
/* This is the in-core version of an extension record */
typedef struct {
int ByteCount;
char *Bytes;
int Function; /* Holds the type of the Extension block. */
} ExtensionBlock;
/* This holds an image header, its unpacked raster bits, and extensions */ /* This holds an image header, its unpacked raster bits, and extensions */
typedef struct SavedImage { typedef struct SavedImage {
GifImageDesc ImageDesc; GifImageDesc ImageDesc;
unsigned char *RasterBits; unsigned char *RasterBits;
int Function; /* DEPRECATED: Use ExtensionBlocks[x].Function instead */ Extensions Extensions;
int ExtensionBlockCount;
ExtensionBlock *ExtensionBlocks;
} SavedImage; } SavedImage;
#endif /* _UNGIF_H_ */ #endif /* _UNGIF_H_ */
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