diff options
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/intern/allocimbuf.c | 159 | ||||
-rw-r--r-- | source/blender/imbuf/intern/amiga.c | 118 |
2 files changed, 3 insertions, 274 deletions
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 2a6b8f3cf6a..008300fc67a 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -32,15 +32,6 @@ * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ -/** - * \file allocimbuf.c - * \ingroup imbuf - * \brief Handles de/allocating memory for ImBuf struct variables. - * - * This file uses free() and MEM_mallocN() to allocate and deallocate memory - * to the members of the ImBuf struct. It also zeroes out pointers and - * tracks buffer sizes. - */ /* It's become a bit messy... Basically, only the IMB_ prefixed files * should remain. */ @@ -57,9 +48,6 @@ #include <config.h> #endif -/** - * Default cmap. Used to initialize the ImBuf->cmap variable. - */ static unsigned int dfltcmap[16] = { 0x00000000, 0xffffffff, 0x777777ff, 0xccccccff, 0xcc3344ff, 0xdd8844ff, 0xccdd44ff, 0x888833ff, @@ -67,13 +55,6 @@ static unsigned int dfltcmap[16] = { 0x8888ddff, 0x4433ccff, 0xcc33ccff, 0xcc88ddff }; -/** - * \brief Clears memory associated to the ImBuf* ibuf->planes - * - * This function uses free() to de-allocate the memory associated with - * the planes member of the ImBuf struct, and sets the pointer to 0. - * The ibuf->mall also gets the IB_planes bit unset. - */ void imb_freeplanesImBuf(struct ImBuf * ibuf) { if (ibuf==0) return; @@ -85,13 +66,6 @@ void imb_freeplanesImBuf(struct ImBuf * ibuf) } -/** - * \brief Clears memory associated to the ImBuf* ibuf->rect - * - * This function uses free() to de-allocate the memory associated with - * the rect member of the ImBuf struct, and sets the pointer to 0. - * The ibuf->mall also gets the IB_rect bit unset. - */ void imb_freerectImBuf(struct ImBuf * ibuf) { if (ibuf==0) return; @@ -102,19 +76,6 @@ void imb_freerectImBuf(struct ImBuf * ibuf) ibuf->mall &= ~IB_rect; } -/** - * \brief Clears memory associated to the ImBuf* ibuf->encodedbuffer - * - * This function uses free() to de-allocate the memory associated with - * the encodedbuffer member of the ImBuf struct, and sets the following - * variables to 0: - * - * encodedbuffer - * encodedbuffersize - * encodedsize - * - * The ibuf->mall also gets the IB_mem bit unset. - */ static void freeencodedbufferImBuf(struct ImBuf * ibuf) { if (ibuf==0) return; @@ -127,13 +88,6 @@ static void freeencodedbufferImBuf(struct ImBuf * ibuf) ibuf->mall &= ~IB_mem; } -/** - * \brief Clears memory associated to the ImBuf* ibuf->zbuf - * - * This function uses free() to de-allocate the memory associated with - * the zbuf member of the ImBuf struct, and sets the pointer to 0. - * The ibuf->mall also gets the IB_zbuf bit unset. - */ void IMB_freezbufImBuf(struct ImBuf * ibuf) { if (ibuf==0) return; @@ -144,13 +98,6 @@ void IMB_freezbufImBuf(struct ImBuf * ibuf) ibuf->mall &= ~IB_zbuf; } -/** - * \brief Clears memory associated to the ImBuf* ibuf->cmap - * - * This function uses free() to de-allocate the memory associated with - * the cmap member of the ImBuf struct, and sets the pointer to 0. - * The ibuf->mall also gets the IB_cmap bit unset. - */ void IMB_freecmapImBuf(struct ImBuf * ibuf) { if (ibuf == 0) return; @@ -162,13 +109,6 @@ void IMB_freecmapImBuf(struct ImBuf * ibuf) } -/** - * \brief Clears memory associated to the ImBuf ibuf - * - * This function uses the imb_free*ImBuf() functions to free the - * memory associated to the ibuf argument, and then frees the ibuf - * pointer using free() - */ void IMB_freeImBuf(struct ImBuf * ibuf) { if (ibuf){ @@ -181,18 +121,6 @@ void IMB_freeImBuf(struct ImBuf * ibuf) } } - -/** - * \brief Allocates memory to the zbuf member of the ImBuf struct. - * - * This function uses MEM_mallocN(int,char *) to allocate memory to - * the zbuf member of the ImBuf struct. Any memory associated to the - * zbuf member is overwritten. - * - * The IB_zbuf bit of the ibuf->mall variable is set. - * \return Returns FALSE if ibuf==0 or if MEM_mallocN() fails, otherwise - * returns TRUE - */ static short addzbufImBuf(struct ImBuf * ibuf) { int size; @@ -210,21 +138,6 @@ static short addzbufImBuf(struct ImBuf * ibuf) } -/** - * \brief Allocates memory to the encodedbuffer member of the ImBuf struct. - * - * This function uses MEM_mallocN(int,char *) to allocate memory to - * the encodedbuffer member of the ImBuf struct. Any memory associated to the - * encodedbuffer member is overwritten. - * - * The ibuf->encodedbuffersize is set to 10000 if it was previously 0. - * - * The ibuf->encodedsize is set to 0. - * - * The IB_mem bit of the ibuf->mall variable is set. - * \return Returns FALSE if ibuf==0 or if MEM_mallocN() fails, otherwise - * returns TRUE - */ short imb_addencodedbufferImBuf(struct ImBuf * ibuf) { if (ibuf==0) return(FALSE); @@ -245,19 +158,6 @@ short imb_addencodedbufferImBuf(struct ImBuf * ibuf) } -/** - * \brief Adds memory to ibuf->encodedbuffer - * - * This function doubles the size of encodedbuffer if it is less than 10000, - * otherwise sets encodedbuffersize to 10000. - * - * The ibuf members encodedbuffersize and encoded size also get set. - * \return Returns FALSE if: - * - ibuf==0 - * - ibuf->encodedbuffersize < ibuf->encodedsize - * - MEM_mallocN() fails (returns NULL) - * otherwise, returns TRUE - */ short imb_enlargeencodedbufferImBuf(struct ImBuf * ibuf) { unsigned int newsize, encodedsize; @@ -294,17 +194,6 @@ short imb_enlargeencodedbufferImBuf(struct ImBuf * ibuf) return (TRUE); } -/** - * \brief Allocates memory to the rect member of the ImBuf struct. - * - * This function uses MEM_mallocN(int,char *) to allocate memory to - * the rect member of the ImBuf struct. Any memory associated to the - * rect member is overwritten. - * - * The IB_rect bit of the ibuf->mall variable is set. - * \return Returns FALSE if ibuf==0 or if MEM_mallocN() fails, otherwise - * returns TRUE - */ short imb_addrectImBuf(struct ImBuf * ibuf) { @@ -324,19 +213,6 @@ short imb_addrectImBuf(struct ImBuf * ibuf) } -/** - * \brief Allocates memory to the cmap member of the ImBuf struct. - * - * This function uses MEM_mallocN(int,char *) to allocate memory to - * the cmap member of the ImBuf struct. Any memory associated to the - * cmap member is overwritten. - * - * The memory is initialized to the value of the dfltcmap variable. - * - * The IB_cmap bit of the ibuf->mall variable is set. - * \return Returns FALSE if ibuf==0 or if MEM_mallocN() fails, otherwise - * returns TRUE - */ short imb_addcmapImBuf(struct ImBuf *ibuf) { int min; @@ -359,19 +235,6 @@ short imb_addcmapImBuf(struct ImBuf *ibuf) } -/** - * \brief Adds memory to the planes member of ibuf. - * - * This function adds ibuf->depth number of planes to ibuf. - * - * Sets: - * - ibuf->skipx - * - IB_planes bit of ibuf->mall - * \return Returns FALSE if: - * - ibuf==0 - * - MEM_mallocN() fails (returns 0) - * Otherwise, returns TRUE - */ short imb_addplanesImBuf(struct ImBuf *ibuf) { int size; @@ -404,21 +267,7 @@ short imb_addplanesImBuf(struct ImBuf *ibuf) return (TRUE); } -/** - * \brief This functions allocates memory to an ImBuf struct. - * - * This function allocates memory for an ImBuf struct and returns a pointer - * to the struct. The MEM_callocN() function us used to allocate the memory. - * - * The x and y parameters define the resolution of the image, the d parameter - * defines the (bit?) depth, the flags parameter defines whether the rect, zbuf or - * planes members should exist. The bitmap flag will set the IB_planes bit in the - * flags variable. - * - * \return Returns 0 if any of the imb_add*ImBuf() functions return FALSE. If the - * memory for ibuf is not allocated, the return also should be 0. Otherwise, returns - * a pointer to an ImBuf struct. - */ + struct ImBuf *IMB_allocImBuf(short x,short y,uchar d,unsigned int flags,uchar bitmap) { struct ImBuf *ibuf; @@ -456,12 +305,6 @@ struct ImBuf *IMB_allocImBuf(short x,short y,uchar d,unsigned int flags,uchar bi return (ibuf); } -/** - * \brief Returns a pointer to a new imbuf which is a duplicate of the ibuf1 parameter. - * - * \return Returns 0 if any memory allocation fails (except for the cmap allocation. Is - * this right?), otherwise returns a copy of ibuf1. - */ struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1) { struct ImBuf *ibuf2, tbuf; diff --git a/source/blender/imbuf/intern/amiga.c b/source/blender/imbuf/intern/amiga.c index 2abc2b8c375..fd753ec683d 100644 --- a/source/blender/imbuf/intern/amiga.c +++ b/source/blender/imbuf/intern/amiga.c @@ -31,14 +31,6 @@ * * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ -/** - * \file amiga.c - * \brief This file handles loading and saving of amiga files. - * \ingroup imbuf - * \warning This file contains endian code. Some way should be found to move - * this code out of here. - * \help Endian #defines are in multiple files! - */ #include "imbuf.h" #include "imbuf_patch.h" @@ -56,23 +48,9 @@ #endif /* actually hard coded endianness */ -/** - * \brief Makes a 4 bit id for a 32 bit value: Big-endian - * \todo How is this used? - */ #define GET_BIG_LONG(x) (((uchar *) (x))[0] << 24 | ((uchar *) (x))[1] << 16 | ((uchar *) (x))[2] << 8 | ((uchar *) (x))[3]) -/** - * \brief Makes a 4 bit id for a 16? bit value: Little-endian - * \todo How is this used? - */ #define GET_LITTLE_LONG(x) (((uchar *) (x))[3] << 24 | ((uchar *) (x))[2] << 16 | ((uchar *) (x))[1] << 8 | ((uchar *) (x))[0]) -/** - * \brief Converts between little and big endian: 32 bit values - */ #define SWAP_L(x) (((x << 24) & 0xff000000) | ((x << 8) & 0xff0000) | ((x >> 8) & 0xff00) | ((x >> 24) & 0xff)) -/** - * \brief Converts between little and big endian: 16 bit values - */ #define SWAP_S(x) (((x << 8) & 0xff00) | ((x >> 8) & 0xff)) /* more endianness... should move to a separate file... */ @@ -412,16 +390,6 @@ static uchar *readbody(struct ImBuf *ibuf, uchar *body) return body; } -/** - * \brief Loads an amiga (.ami) image. - * \ingroup imbuf - * \param iffmem A pointer to a memory location. - * \param flags A set of bit flags determining what parts of the image to load. - * \return Returns 0 if loading the image fails, otherwise returns a pointer to an ImBuf. - * - * I am fairly certain of what is going on in this function, so if I am - * wrong, please let me know, so I can update the docs! - */ struct ImBuf *imb_loadamiga(int *iffmem,int flags) { int chunk,totlen,len,*cmap=0,cmaplen,*mem,ftype=0; @@ -429,45 +397,16 @@ struct ImBuf *imb_loadamiga(int *iffmem,int flags) struct BitMapHeader bmhd; struct ImBuf *ibuf=0; - /** - * \internal The memory address to the data is copiend into mem. - */ mem = iffmem; - /** - * \internal The w member of the BitMapHeader is initialized to 0 because - * it will be tested to see if it has been set later. - */ bmhd.w = 0; - /** - * \internal The first three chunks must have the form: FORMxxxxILBM - * else the function returns with 0; - * FORM and ILBM are defined in imbuf_patch.h - */ if (GET_ID(mem) != FORM) return (0); if (GET_ID(mem+2) != ILBM) return (0); - /** - * \internal The second chunk is the total size of the image. - */ totlen= (GET_BIG_LONG(mem+1) + 1) & ~1; - /** - * \internal mem is incremented to skip the first three chunks. - */ mem += 3; - /** - * \internal Anyone know why the total length is decreased by four here? - */ totlen -= 4; - /** - * \internal The while loop retrieves at most four blocks of memory: - * - bmhd: the bit map header - * - body: which is the image data - * - cmap: the color map - * - ftype: the file type (what does CAMG stand for?) - * The body and the bitmap header are required. - */ while(totlen > 0){ chunk = GET_ID(mem); len= (GET_BIG_LONG(mem+1) + 1) & ~1; @@ -500,36 +439,18 @@ struct ImBuf *imb_loadamiga(int *iffmem,int flags) break; } mem = (int *)((uchar *)mem +len); - /** - * \intern Anything after the first BODY ID is discarded. - */ if (body) break; } - /** - * \internal After the while loop, the existance of body and bmhd are detected. - */ if (bmhd.w == 0) return (0); if (body == 0) return (0); - /** - * \internal if the IB_test bit is set in flags, don't do masking. - * (I'm not too sure about this) In any case, allocate the memory - * for the imbuf, and return 0 if this fails. - */ if (flags & IB_test) ibuf = IMB_allocImBuf(bmhd.w, bmhd.h, bmhd.nPlanes, 0, 0); else ibuf = IMB_allocImBuf(bmhd.w, bmhd.h, bmhd.nPlanes + (bmhd.masking & 1),0,1); if (ibuf == 0) return (0); - /** - * \internal Set the AMI bit in ftype. - */ ibuf->ftype = (ftype | AMI); - /** - * \internal If there was a cmap chunk in the data, add the cmap - * to the ImBuf and copy the data there. - */ if (cmap){ ibuf->mincol = 0; ibuf->maxcol = cmaplen; @@ -540,21 +461,11 @@ struct ImBuf *imb_loadamiga(int *iffmem,int flags) imb_makecolarray(ibuf, cmap, 0); } - /** - * \internal If the IB_test bit of flags was set, we're done: - * If the IB_freem bit is set, free the data pointed to by iffmem. - * Return the data. - */ if (flags & IB_test){ if (flags & IB_freem) free(iffmem); return(ibuf); } - /** - * \internal Check the bitmap header to see if there is any - * compression. 0 is no, 1 is horizontal, 2 is vertical. - * Load the data according to the type of compression. - */ switch (bmhd.compression){ case 0: body= readbody(ibuf, body); @@ -568,42 +479,23 @@ struct ImBuf *imb_loadamiga(int *iffmem,int flags) break; } - /** - * \internal If the IB_freem bit is set, free the data pointed to by iffmem. - */ if (flags & IB_freem) free(iffmem); - /** - * \internal If there was some problem loading the body - * data, free the memory already allocated in ibuf and - * return 0. - */ if (body == 0){ free (ibuf); return(0); } - /** - * \internal Set the bit depth to the number of planes in bmhd. - * This discards the "stencil" data (What is the stencil? Alpha channel?) - */ /* forget stencil */ ibuf->depth = bmhd.nPlanes; - /** - * \internal If the IB_rect bit is set in flags, add the rect and - * get rid of the planes. - */ if (flags & IB_rect){ imb_addrectImBuf(ibuf); imb_bptolong(ibuf); imb_freeplanesImBuf(ibuf); - /** - * \internal If the image has a color map, apply it. - */ if (ibuf->cmap){ if ((flags & IB_cmap) == 0) IMB_applycmap(ibuf); - } else if (ibuf->depth == 18){ /** \internal No color map, and the bit depths is 18, convert to 24-bit */ + } else if (ibuf->depth == 18){ int i,col; unsigned int *rect; @@ -615,7 +507,7 @@ struct ImBuf *imb_loadamiga(int *iffmem,int flags) *rect++ = col; } ibuf->depth = 24; - } else if (ibuf->depth <= 8) { /** \internal No colormap and no 24 bits, so it's b&w */ + } else if (ibuf->depth <= 8) { /* no colormap and no 24 bits: b&w */ uchar *rect; int size, shift; @@ -637,14 +529,8 @@ struct ImBuf *imb_loadamiga(int *iffmem,int flags) } } - /** - * \internal Anyone know what IB_ttob is? What does IMB_flipy do? - */ if ((flags & IB_ttob) == 0) IMB_flipy(ibuf); - /** - * \internal Last thing to do before returning is to flip the bits from rgba to abgr. - */ if (ibuf) { if (ibuf->rect) IMB_convert_rgba_to_abgr(ibuf->x*ibuf->y, ibuf->rect); |