From 8d9ec27a3641457f18f860f644b745cf3c8368a9 Mon Sep 17 00:00:00 2001 From: "tor%cs.brown.edu" Date: Thu, 29 Jun 2000 12:32:04 +0000 Subject: [PATCH] Update libmng snapshot. Not in default build. --- modules/libimg/mng/changes.readme | 18 ++++++++++++-- modules/libimg/mng/mng_display.c | 10 ++++---- modules/libimg/mng/mng_hlapi.c | 22 ++++++++++++----- modules/libimg/mng/mng_pixels.c | 29 ++++++++++++++++++++++ modules/libimg/mng/mng_types.h | 33 +++++++++++++++++++++----- modules/libimg/mngcom/nsMNGDecoder.cpp | 6 ++--- 6 files changed, 97 insertions(+), 21 deletions(-) diff --git a/modules/libimg/mng/changes.readme b/modules/libimg/mng/changes.readme index ceefa000c6cb..e7af7db0f45d 100644 --- a/modules/libimg/mng/changes.readme +++ b/modules/libimg/mng/changes.readme @@ -7,13 +7,21 @@ in short: This is a working version only; the next release will be 0.9.0 (first Beta!) +There are a few incompatible changes with previous versions. The userdata +variable has been changed from mng_uint32 to mng_ptr to accomodate 64-bit +systems. For the same reason memory allocation size parameters have been +changed to a mng_size_t type which is a typedef of size_t. + +Thanks to Aleks Jakulin for helping to iron out some 64-bit platform issues! + - implemented the update-region parameters of the refresh callback - added support for most common delta-image options - added an animation-speed modifier - added an image-level parameter for the processtext callback - updated mngplg to 0.3.0 (supports JNG & full color-correction!) - fixed a lot of small things -- added support for PPLT chunk +- added support for PPLT chunk +- fixed to support 64-bit platforms ------------------- @@ -51,7 +59,7 @@ core: - added administration of imagelevel parameter - added support for PPLT chunk - added trace-codes & -strings for PPLT chunk processing -- fixed problem with incorrect gamma-correction +- fixed problem with incorrect gamma-correction - fixed inclusion of IJG read/write code - fixed problem with 16-bit GA format - fixed problem with cheap transparency for 4-bit gray @@ -60,6 +68,11 @@ core: - changed userdata variable to mng_ptr - added typedef for mng_size_t - changed size parameter for memory allocation to mng_size_t +- fixed compiler-warning for non-initialized iB variable +- changed definition for 32-bit ints (64-bit platforms) +- changed definition for mng_handle (64-bit platforms) +- swapped refresh parameters +- fixed initialization routine for new mng_handle type samples: @@ -70,6 +83,7 @@ doc: makefiles: - changed makefile.linux to reflect versionnr for shared-lib +- changed makefile.linux to depend on mng_conf.h & mng_types.h ----------------------------------------------------------- diff --git a/modules/libimg/mng/mng_display.c b/modules/libimg/mng/mng_display.c index 644d3d45e234..9b93d8ee425c 100644 --- a/modules/libimg/mng/mng_display.c +++ b/modules/libimg/mng/mng_display.c @@ -64,6 +64,8 @@ /* * - added speed-modifier to timing routine * */ /* * 0.5.3 - 06/22/2000 - G.Juyn * */ /* * - added support for PPLT chunk processing * */ +/* * 0.5.3 - 06/29/2000 - G.Juyn * */ +/* * - swapped refresh parameters * */ /* * * */ /* ************************************************************************** */ @@ -105,8 +107,8 @@ mng_retcode display_progressive_refresh (mng_datap pData, if ((pData->iUpdatetop < pData->iUpdatebottom) && (pData->iUpdateleft < pData->iUpdateright)) { if (!pData->fRefresh (((mng_handle)pData), - pData->iUpdatetop, pData->iUpdateleft, - pData->iUpdatebottom, pData->iUpdateright)) + pData->iUpdateleft, pData->iUpdatetop, + pData->iUpdateright, pData->iUpdatebottom)) MNG_ERROR (pData, MNG_APPMISCERROR) pData->iUpdateleft = 0; /* reset update-region */ @@ -153,8 +155,8 @@ mng_retcode interframe_delay (mng_datap pData) { if ((pData->iUpdatetop < pData->iUpdatebottom) && (pData->iUpdateleft < pData->iUpdateright)) if (!pData->fRefresh (((mng_handle)pData), - pData->iUpdatetop, pData->iUpdateleft, - pData->iUpdatebottom, pData->iUpdateright)) + pData->iUpdateleft, pData->iUpdatetop, + pData->iUpdateright, pData->iUpdatebottom)) MNG_ERROR (pData, MNG_APPMISCERROR) pData->iUpdateleft = 0; /* reset update-region */ diff --git a/modules/libimg/mng/mng_hlapi.c b/modules/libimg/mng/mng_hlapi.c index dc4769b444bc..035dc11be1ab 100644 --- a/modules/libimg/mng/mng_hlapi.c +++ b/modules/libimg/mng/mng_hlapi.c @@ -60,6 +60,8 @@ /* * - added initialization of Imagelevel * */ /* * 0.5.3 - 06/26/2000 - G.Juyn * */ /* * - changed userdata variable to mng_ptr * */ +/* * 0.5.3 - 06/29/2000 - G.Juyn * */ +/* * - fixed initialization routine for new mng_handle type * */ /* * * */ /* ************************************************************************** */ @@ -286,13 +288,13 @@ mng_handle MNG_DECL mng_initialize (mng_ptr pUserdata, #endif #ifdef MNG_INTERNAL_MEMMNGMT /* allocate the main datastruc */ - pData = calloc (1, sizeof (mng_data)); + pData = (mng_datap)calloc (1, sizeof (mng_data)); #else pData = (mng_datap)fMemalloc (sizeof (mng_data)); #endif if (!pData) - return 0; /* error: out of memory?? */ + return MNG_NULL; /* error: out of memory?? */ /* validate the structure */ pData->iMagic = MNG_MAGIC; /* save userdata field */ @@ -301,7 +303,11 @@ mng_handle MNG_DECL mng_initialize (mng_ptr pUserdata, pData->fTraceproc = fTraceproc; #ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INITIALIZE, MNG_LC_INITIALIZE) + if (mng_trace (pData, MNG_FN_INITIALIZE, MNG_LC_INITIALIZE)) + { + MNG_FREEX (pData, pData, sizeof (mng_data)) + return MNG_NULL; + } #endif /* default canvas styles are 8-bit RGB */ pData->iCanvasstyle = MNG_CANVAS_RGB8; @@ -369,10 +375,10 @@ mng_handle MNG_DECL mng_initialize (mng_ptr pUserdata, if (iRetcode) /* on error drop out */ { MNG_FREEX (pData, pData, sizeof (mng_data)) - return 0; + return MNG_NULL; } - pData->pObjzero = pImage; + pData->pObjzero = pImage; #endif #if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_INCLUDE_LCMS) @@ -404,7 +410,11 @@ mng_handle MNG_DECL mng_initialize (mng_ptr pUserdata, mng_reset ((mng_handle)pData); #ifdef MNG_SUPPORT_TRACE - MNG_TRACE (pData, MNG_FN_INITIALIZE, MNG_LC_END) + if (mng_trace (pData, MNG_FN_INITIALIZE, MNG_LC_END)) + { + MNG_FREEX (pData, pData, sizeof (mng_data)) + return MNG_NULL; + } #endif return (mng_handle)pData; /* if we get here, we're in business */ diff --git a/modules/libimg/mng/mng_pixels.c b/modules/libimg/mng/mng_pixels.c index 1676f7d0e573..117feec2baef 100644 --- a/modules/libimg/mng/mng_pixels.c +++ b/modules/libimg/mng/mng_pixels.c @@ -54,6 +54,8 @@ /* * 0.5.3 - 06/25/2000 - G.Juyn * */ /* * - fixed problem with cheap transparency for 4-bit gray * */ /* * - fixed display_xxxx routines for interlaced images * */ +/* * 0.5.3 - 06/28/2000 - G.Juyn * */ +/* * - fixed compiler-warning for non-initialized iB variable * */ /* * * */ /* ************************************************************************** */ @@ -2084,6 +2086,7 @@ mng_retcode store_g1 (mng_datap pData) pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + (pData->iCol * pBuf->iSamplesize); iM = 0; /* start at pixel 0 */ + iB = 0; for (iX = 0; iX < pData->iRowsamples; iX++) { @@ -2130,6 +2133,7 @@ mng_retcode store_g2 (mng_datap pData) pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + (pData->iCol * pBuf->iSamplesize); iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; for (iX = 0; iX < pData->iRowsamples; iX++) @@ -2183,6 +2187,7 @@ mng_retcode store_g4 (mng_datap pData) pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + (pData->iCol * pBuf->iSamplesize); iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; for (iX = 0; iX < pData->iRowsamples; iX++) @@ -2361,6 +2366,7 @@ mng_retcode store_idx1 (mng_datap pData) pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + (pData->iCol * pBuf->iSamplesize); iM = 0; /* start at pixel 0 */ + iB = 0; for (iX = 0; iX < pData->iRowsamples; iX++) { @@ -2407,6 +2413,7 @@ mng_retcode store_idx2 (mng_datap pData) pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + (pData->iCol * pBuf->iSamplesize); iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; for (iX = 0; iX < pData->iRowsamples; iX++) @@ -2453,6 +2460,7 @@ mng_retcode store_idx4 (mng_datap pData) pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + (pData->iCol * pBuf->iSamplesize); iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; for (iX = 0; iX < pData->iRowsamples; iX++) @@ -2783,6 +2791,7 @@ mng_retcode store_jpeg_g8_a1 (mng_datap pData) pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + (pData->iCol * pBuf->iSamplesize) + 1; iM = 0; /* start at pixel 0 */ + iB = 0; for (iX = 0; iX < pData->iRowsamples; iX++) { @@ -2829,6 +2838,7 @@ mng_retcode store_jpeg_g8_a2 (mng_datap pData) pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + (pData->iCol * pBuf->iSamplesize) + 1; iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; for (iX = 0; iX < pData->iRowsamples; iX++) @@ -2882,6 +2892,7 @@ mng_retcode store_jpeg_g8_a4 (mng_datap pData) pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + (pData->iCol * pBuf->iSamplesize) + 1; iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; for (iX = 0; iX < pData->iRowsamples; iX++) @@ -2994,6 +3005,7 @@ mng_retcode store_jpeg_rgb8_a1 (mng_datap pData) pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + (pData->iCol * pBuf->iSamplesize) + 3; iM = 0; /* start at pixel 0 */ + iB = 0; for (iX = 0; iX < pData->iRowsamples; iX++) { @@ -3040,6 +3052,7 @@ mng_retcode store_jpeg_rgb8_a2 (mng_datap pData) pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + (pData->iCol * pBuf->iSamplesize) + 3; iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; for (iX = 0; iX < pData->iRowsamples; iX++) @@ -3093,6 +3106,7 @@ mng_retcode store_jpeg_rgb8_a4 (mng_datap pData) pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + (pData->iCol * pBuf->iSamplesize) + 3; iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; for (iX = 0; iX < pData->iRowsamples; iX++) @@ -3205,6 +3219,7 @@ mng_retcode store_jpeg_g12_a1 (mng_datap pData) pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + (pData->iCol * pBuf->iSamplesize) + 2; iM = 0; /* start at pixel 0 */ + iB = 0; for (iX = 0; iX < pData->iRowsamples; iX++) { @@ -3251,6 +3266,7 @@ mng_retcode store_jpeg_g12_a2 (mng_datap pData) pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + (pData->iCol * pBuf->iSamplesize) + 2; iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; for (iX = 0; iX < pData->iRowsamples; iX++) @@ -3304,6 +3320,7 @@ mng_retcode store_jpeg_g12_a4 (mng_datap pData) pOutrow = pBuf->pImgdata + (pData->iRow * pBuf->iRowsize ) + (pData->iCol * pBuf->iSamplesize) + 2; iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; for (iX = 0; iX < pData->iRowsamples; iX++) @@ -3432,6 +3449,7 @@ mng_retcode delta_g1 (mng_datap pData) (pData->iCol * pBuf->iSamplesize) + (pData->iDeltaBlockx * pBuf->iSamplesize); iM = 0; /* start at pixel 0 */ + iB = 0; /* pixel replace ? */ if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) { @@ -3501,6 +3519,7 @@ mng_retcode delta_g2 (mng_datap pData) (pData->iCol * pBuf->iSamplesize) + (pData->iDeltaBlockx * pBuf->iSamplesize); iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; /* pixel replace ? */ if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) @@ -3584,6 +3603,7 @@ mng_retcode delta_g4 (mng_datap pData) (pData->iCol * pBuf->iSamplesize) + (pData->iDeltaBlockx * pBuf->iSamplesize); iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; /* pixel replace ? */ if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) @@ -3865,6 +3885,7 @@ mng_retcode delta_idx1 (mng_datap pData) (pData->iCol * pBuf->iSamplesize) + (pData->iDeltaBlockx * pBuf->iSamplesize); iM = 0; /* start at pixel 0 */ + iB = 0; /* pixel replace ? */ if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) { @@ -3934,6 +3955,7 @@ mng_retcode delta_idx2 (mng_datap pData) (pData->iCol * pBuf->iSamplesize) + (pData->iDeltaBlockx * pBuf->iSamplesize); iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; /* pixel replace ? */ if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) @@ -4004,6 +4026,7 @@ mng_retcode delta_idx4 (mng_datap pData) (pData->iCol * pBuf->iSamplesize) + (pData->iDeltaBlockx * pBuf->iSamplesize); iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; /* pixel replace ? */ if (pData->iDeltatype == MNG_DELTATYPE_BLOCKPIXELREPLACE) @@ -4335,6 +4358,7 @@ mng_retcode process_g1 (mng_datap pData) pWorkrow = pData->pWorkrow + 1; /* temporary work pointers */ pRGBArow = pData->pRGBArow; iM = 0; /* start at pixel 0 */ + iB = 0; if (pBuf->bHasTRNS) /* tRNS encountered ? */ { @@ -4437,6 +4461,7 @@ mng_retcode process_g2 (mng_datap pData) pWorkrow = pData->pWorkrow + 1; /* temporary work pointers */ pRGBArow = pData->pRGBArow; iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; if (pBuf->bHasTRNS) /* tRNS encountered ? */ @@ -4531,6 +4556,7 @@ mng_retcode process_g4 (mng_datap pData) pWorkrow = pData->pWorkrow + 1; /* temporary work pointers */ pRGBArow = pData->pRGBArow; iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; if (pBuf->bHasTRNS) /* tRNS encountered ? */ @@ -4919,6 +4945,7 @@ mng_retcode process_idx1 (mng_datap pData) pWorkrow = pData->pWorkrow + 1; /* temporary work pointers */ pRGBArow = pData->pRGBArow; iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; if (pBuf->bHasTRNS) /* tRNS encountered ? */ @@ -5018,6 +5045,7 @@ mng_retcode process_idx2 (mng_datap pData) pWorkrow = pData->pWorkrow + 1; /* temporary work pointers */ pRGBArow = pData->pRGBArow; iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; if (pBuf->bHasTRNS) /* tRNS encountered ? */ @@ -5117,6 +5145,7 @@ mng_retcode process_idx4 (mng_datap pData) pWorkrow = pData->pWorkrow + 1; /* temporary work pointers */ pRGBArow = pData->pRGBArow; iM = 0; /* start at pixel 0 */ + iB = 0; iS = 0; if (pBuf->bHasTRNS) /* tRNS encountered ? */ diff --git a/modules/libimg/mng/mng_types.h b/modules/libimg/mng/mng_types.h index 45a9ddfdaae4..e3f0c49c6e52 100644 --- a/modules/libimg/mng/mng_types.h +++ b/modules/libimg/mng/mng_types.h @@ -51,6 +51,12 @@ /* * - added typedef for mng_size_t * */ /* * - changed size parameter for memory callbacks to * */ /* * mng_size_t * */ +/* * 0.5.3 - 06/28/2000 - G.Juyn * */ +/* * - changed definition of 32-bit ints (64-bit platforms) * */ +/* * - changed definition of mng_handle (64-bit platforms) * */ +/* * 0.5.3 - 06/29/2000 - G.Juyn * */ +/* * - changed definition of mng_handle (again) * */ +/* * - swapped refresh parameters * */ /* * * */ /* ************************************************************************** */ @@ -104,6 +110,8 @@ #include /* "calloc" & "free" */ #endif +#include /* get proper integer widths */ + #ifdef WIN32 /* B003 */ #if defined __BORLANDC__ @@ -162,9 +170,20 @@ /* ************************************************************************** */ -typedef signed long mng_int32; /* basic integers */ +#if USHRT_MAX == 0xffffffff /* get the proper 32-bit width !!! */ +typedef unsigned short mng_uint32; +typedef signed short mng_int32; +#elif UINT_MAX == 0xffffffff +typedef unsigned int mng_uint32; +typedef signed int mng_int32; +#elif ULONG_MAX == 0xffffffff typedef unsigned long mng_uint32; -typedef signed short mng_int16; +typedef signed long mng_int32; +#else +#error Sorry, I can't find any 32-bit integers on this platform. +#endif + +typedef signed short mng_int16; /* other basic integers */ typedef unsigned short mng_uint16; typedef signed char mng_int8; typedef unsigned char mng_uint8; @@ -189,7 +208,9 @@ typedef mng_uint8 * mng_uint8p; /* pointer to unsigned bytes */ typedef mng_int8 mng_bool; /* booleans */ -typedef mng_int32 mng_handle; /* generic handle */ +struct mng_data_struct; +typedef struct mng_data_struct * mng_handle; /* generic handle */ + typedef mng_int32 mng_retcode; /* generic return code */ typedef mng_int32 mng_chunkid; /* 4-byte chunkname identifier */ typedef mng_ptr mng_chunkp; /* pointer to a chunk-structure */ @@ -335,10 +356,10 @@ typedef mng_ptr MNG_DECL (*mng_getbkgdline) (mng_handle hHandle, typedef mng_ptr MNG_DECL (*mng_getalphaline) (mng_handle hHandle, mng_uint32 iLinenr); typedef mng_bool MNG_DECL (*mng_refresh) (mng_handle hHandle, - mng_uint32 iTop, mng_uint32 iLeft, - mng_uint32 iBottom, - mng_uint32 iRight); + mng_uint32 iTop, + mng_uint32 iRight, + mng_uint32 iBottom); /* timer management callbacks */ typedef mng_uint32 MNG_DECL (*mng_gettickcount) (mng_handle hHandle); diff --git a/modules/libimg/mngcom/nsMNGDecoder.cpp b/modules/libimg/mngcom/nsMNGDecoder.cpp index a9bb992a6c5f..cdc80521109b 100644 --- a/modules/libimg/mngcom/nsMNGDecoder.cpp +++ b/modules/libimg/mngcom/nsMNGDecoder.cpp @@ -163,15 +163,15 @@ il_mng_getcanvasline(mng_handle handle, mng_uint32 iLinenr) static mng_bool il_mng_refresh(mng_handle handle, - mng_uint32 top, mng_uint32 left, - mng_uint32 bottom, mng_uint32 right) + mng_uint32 left, mng_uint32 top, + mng_uint32 right, mng_uint32 bottom) { // dprintf((stderr, "=== refresh(top=%d left=%d bottom=%d right=%d)\n", // top, left, bottom, right)); EXTRACT_STRUCTS; - for (int y=top; yrowbuf, imng_p->image+y*CHANNELS*imng_p->width, CHANNELS*imng_p->width);