static ilError _ilDecompG3Init( ilDecompG3G4PrivPtr pPriv, ilImageInfo *pSrcImage, ilImageInfo *pDstImage ) { /* Allocate space for Reference line, needed for 2 dimensional coding */ pPriv->gpRefLine = (ilPtr)IL_MALLOC(pPriv->nDstLineBytes ); if (!pPriv->gpRefLine) return IL_ERROR_MALLOC; return IL_OK; }
/* Realloc (or alloc the first time) the pixel buffer for plane "plane" of the compressed image "*pImage", so that its "bufferSize" is a minimum of "minNewSize" bytes in size. */ IL_PRIVATE ilBool _ilReallocCompressedBuffer ( ilImageInfo *pImage, unsigned int plane, unsigned long minNewSize ) { register ilImagePlaneInfo *pPlane; pPlane = &pImage->plane[plane]; pPlane->bufferSize = minNewSize + 10000; /* A GUESS - DO SOMETHING SMARTER !!!!! */ if (!pPlane->pPixels) pPlane->pPixels = (ilPtr)IL_MALLOC (pPlane->bufferSize); else pPlane->pPixels = (ilPtr)IL_REALLOC (pPlane->pPixels, pPlane->bufferSize); if (!pPlane->pPixels) { pPlane->bufferSize = 0; return FALSE; } return TRUE; }
/* Execute() function for ilInsertCompressedCopyFilter() to copy compressed images. Copies one strip of compressed data. */ static ilError ilCopyCompressedExecute ( register ilExecuteData *pData, long dstLine, long *pNLines ) { register ilImagePlaneInfo *pSrcPlane, *pDstPlane; long nBytes, dstOffset, requiredBufferSize; nBytes = pData->compressed.nBytesToRead; /* # of bytes to write */ pSrcPlane = &pData->pSrcImage->plane[0]; if (!pSrcPlane->pPixels || (nBytes <= 0)) /* nothing to copy; exit */ return IL_OK; dstOffset = *pData->compressed.pDstOffset; /* byte offset into dst buffer */ pDstPlane = &pData->pDstImage->plane[0]; requiredBufferSize = nBytes + dstOffset; /* # bytes needed in dst buffer */ /* Check for space in output buffer; realloc/malloc if not enough */ if (requiredBufferSize > pDstPlane->bufferSize) { pDstPlane->pPixels = (pDstPlane->pPixels) ? (ilPtr)IL_REALLOC (pDstPlane->pPixels, requiredBufferSize) : (ilPtr)IL_MALLOC (requiredBufferSize); if (!pDstPlane->pPixels) { pDstPlane->bufferSize = 0; return IL_ERROR_MALLOC; } pDstPlane->bufferSize = requiredBufferSize; } /* Copy nBytes from src to dst buffer, using offsets from *pData */ bcopy ((char *)(pSrcPlane->pPixels + pData->compressed.srcOffset), (char *)(pDstPlane->pPixels + dstOffset), nBytes); *pData->compressed.pNBytesWritten = nBytes; return IL_OK; }