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

This commit is contained in:
Dmitry Timoshkov 2012-09-18 12:56:34 +09:00 committed by Alexandre Julliard
parent 8e87b9233a
commit 629e7f44cb
3 changed files with 35 additions and 31 deletions

View File

@ -699,8 +699,8 @@ static HRESULT WINAPI GifFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface,
}
/* look for the transparent color extension */
for (i = 0; i < This->frame->ExtensionBlockCount; ++i) {
eb = This->frame->ExtensionBlocks + i;
for (i = 0; i < This->frame->Extensions.ExtensionBlockCount; ++i) {
eb = This->frame->Extensions.ExtensionBlocks + i;
if (eb->Function == 0xF9 && eb->ByteCount == 4) {
if ((eb->Bytes[0] & 1) == 1) {
trans = (unsigned char)eb->Bytes[3];
@ -854,11 +854,11 @@ static const void *get_GCE_data(GifFrameDecode *This)
{
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 &&
This->frame->ExtensionBlocks[i].ByteCount == 4)
return This->frame->ExtensionBlocks[i].Bytes;
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;
}
return NULL;
}

View File

@ -191,7 +191,7 @@ FreeMapObject(ColorMapObject * Object) {
}
static int
AddExtensionBlock(SavedImage * New,
AddExtensionBlock(Extensions *New,
int Len,
const unsigned char ExtData[]) {
@ -223,18 +223,18 @@ AddExtensionBlock(SavedImage * New,
}
static void
FreeExtension(SavedImage * Image)
FreeExtension(Extensions *Extensions)
{
ExtensionBlock *ep;
if ((Image == NULL) || (Image->ExtensionBlocks == NULL)) {
if ((Extensions == NULL) || (Extensions->ExtensionBlocks == NULL)) {
return;
}
for (ep = Image->ExtensionBlocks;
ep < (Image->ExtensionBlocks + Image->ExtensionBlockCount); ep++)
for (ep = Extensions->ExtensionBlocks;
ep < (Extensions->ExtensionBlocks + Extensions->ExtensionBlockCount); ep++)
ungif_free(ep->Bytes);
ungif_free(Image->ExtensionBlocks);
Image->ExtensionBlocks = NULL;
ungif_free(Extensions->ExtensionBlocks);
Extensions->ExtensionBlocks = NULL;
}
/******************************************************************************
@ -258,8 +258,8 @@ FreeSavedImages(GifFileType * GifFile) {
ungif_free(sp->RasterBits);
if (sp->ExtensionBlocks)
FreeExtension(sp);
if (sp->Extensions.ExtensionBlocks)
FreeExtension(&sp->Extensions);
}
ungif_free(GifFile->SavedImages);
GifFile->SavedImages=NULL;
@ -424,8 +424,8 @@ DGifGetImageDesc(GifFileType * GifFile) {
sp->ImageDesc.ColorMap->SortFlag = GifFile->Image.ColorMap->SortFlag;
}
sp->RasterBits = NULL;
sp->ExtensionBlockCount = 0;
sp->ExtensionBlocks = NULL;
sp->Extensions.ExtensionBlockCount = 0;
sp->Extensions.ExtensionBlocks = NULL;
GifFile->ImageCount++;
@ -845,7 +845,7 @@ DGifSlurp(GifFileType * GifFile) {
GifRecordType RecordType;
SavedImage *sp;
GifByteType *ExtData;
SavedImage temp_save;
Extensions temp_save;
temp_save.ExtensionBlocks = NULL;
temp_save.ExtensionBlockCount = 0;
@ -870,8 +870,8 @@ DGifSlurp(GifFileType * GifFile) {
GIF_ERROR)
return (GIF_ERROR);
if (temp_save.ExtensionBlocks) {
sp->ExtensionBlocks = temp_save.ExtensionBlocks;
sp->ExtensionBlockCount = temp_save.ExtensionBlockCount;
sp->Extensions.ExtensionBlocks = temp_save.ExtensionBlocks;
sp->Extensions.ExtensionBlockCount = temp_save.ExtensionBlockCount;
temp_save.ExtensionBlocks = NULL;
temp_save.ExtensionBlockCount = 0;
@ -879,7 +879,7 @@ DGifSlurp(GifFileType * GifFile) {
/* FIXME: The following is wrong. It is left in only for
* backwards compatibility. Someday it should go away. Use
* the sp->ExtensionBlocks->Function variable instead. */
sp->Function = sp->ExtensionBlocks[0].Function;
sp->Extensions.Function = sp->Extensions.ExtensionBlocks[0].Function;
}
break;

View File

@ -98,6 +98,19 @@ typedef struct GifImageDesc {
ColorMapObject *ColorMap; /* The local color map */
} 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 {
GifWord SWidth, SHeight, /* Screen dimensions. */
SColorResolution, /* How many colors can we generate? */
@ -152,20 +165,11 @@ int DGifCloseFile(GifFileType * GifFile) DECLSPEC_HIDDEN;
* 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 */
typedef struct SavedImage {
GifImageDesc ImageDesc;
unsigned char *RasterBits;
int Function; /* DEPRECATED: Use ExtensionBlocks[x].Function instead */
int ExtensionBlockCount;
ExtensionBlock *ExtensionBlocks;
Extensions Extensions;
} SavedImage;
#endif /* _UNGIF_H_ */