Exemplo n.º 1
0
/* initialize a PT for export
 * lock and return pointers to the header and fut
 * make the tables for the specified export format
 */
PTErr_t
	initExport (	KpHandle_t		PTHdr,
					KpHandle_t		PTData,
					PTType_t		format,
					fut_hdr_p FAR*	futHdrP,
					fut_p FAR*		futP)
{
PTErr_t		errnum = KCP_SUCCESS;
fut_p		fut;
fut_hdr_p	futHdr;
KpInt32_t	status;

/* get fut pointer */
	fut = fut_lock_fut ((KpHandle_t)PTData);
	if ( ! IS_FUT(fut)) {
		errnum = KCP_PTERR_2;
		goto GetOut;
	}

/* get header pointer of checked in PT */
	futHdr = (fut_hdr_p) lockBuffer (PTHdr);
	if (futHdr == NULL) {
		errnum = KCP_MEM_LOCK_ERR;
		goto GetOut;
	}

	if (format == PTTYPE_FUTF) {	/* make fixed tables */
		status = makeFutTblDat (fut);
		if (status != 1) {
			fut_free_tbldat	(fut);
			errnum = KCP_INCON_PT;
		}
	}
	else {
		status = makeMftTblDat (fut);
		if (status != 1) {
			fut_free_mftdat	(fut);
			errnum = KCP_INCON_PT;
		}
	}
	

GetOut:
	if (errnum == KCP_SUCCESS) {
		*futP = fut;		/* return pointers to caller */
		*futHdrP = futHdr;
	}
	else {
		(void) unlockPT (PTHdr, fut);
		*futP = NULL;
		*futHdrP = NULL;
	}

	return errnum;
}
Exemplo n.º 2
0
/* TpFreeData frees all of the memory allocated for a fut.
 */
PTErr_t
	TpFreeData (	KpHandle_t	PTData)
{
PTErr_t errnum = KCP_PTERR_2;
fut_p fut;

	fut = fut_lock_fut ((KpHandle_t)PTData);
	if (IS_FUT(fut)) {
		fut_free (fut);
		errnum = KCP_SUCCESS;
	}

	return errnum;
}
Exemplo n.º 3
0
/* check the input and output data class of a PT
 * if a color space is known and the data class is not known,
 * set the data class to correspond to the color space
 */
void
	checkDataClass (PTRefNum_t	PTRefNum)
{
KpInt32_t		i1;
KpHandle_t		PTData;
fut_p			fut;
fut_chan_p		chan;
fut_otbl_p		otbl;
PTDataClass_t	iDataClass, oDataClass;

	iDataClass = getPTDataClass (PTRefNum, KCM_IN_SPACE);
	oDataClass = getPTDataClass (PTRefNum, KCM_OUT_SPACE);

	PTData = getPTData (PTRefNum);
	fut = fut_lock_fut (PTData);
	if ( ! IS_FUT(fut)) return;		/* bummer */

	checkInDataClass (iDataClass, fut->itbl);	/* check the data class of each shared input table */

	for (i1 = 0; i1 < FUT_NOCHAN; i1++) {
		chan = fut->chan[i1];

		if (IS_CHAN(chan)) {
			checkInDataClass (iDataClass, chan->itbl);	/* check the data class of each input table */

			if (oDataClass != KCP_UNKNOWN) {	/* check the data class of each output table */
				otbl = chan->otbl;
				if ((IS_OTBL(otbl)) && (otbl->dataClass == KCP_UNKNOWN)) {
					otbl->dataClass = oDataClass;
				}
			}
		}
	}
	
	fut_unlock_fut (fut);
}
Exemplo n.º 4
0
/* gridDimValid determines whether the grid table dimensions are valid
 * for the format specified.  If the dimensions are not valid then the
 * function attempts to create a
 * PT with the correct size grid tables.  If it is successful the
 * PTRefNum of the resized PT is returned in the location pointed to by
 * resizePTRefNumP.  If resizing is not required the value returned in 
 * the location pointed to by resizePTRefNumP is 0.
 *
 * NOTE:  	If this function creates a resized PT, that PT is checked in.  
 *			it is the responsibility of the calling function to check out
 *			that PT.
 */
static PTErr_t
	gridDimValid (	PTType_t	format,
					PTRefNum_t	PTRefNum,
					PTRefNum_p	resizePTRefNumP)
{
KpHandle_t	PTData;
KpInt32_t	inputChans, outputChans, LUTDimensions, dummy = 0;
fut_p	 	fut;
PTErr_t		retVal, error = KCP_SUCCESS;

	/*	Assume no resizing */
	if (NULL != resizePTRefNumP) {
		*resizePTRefNumP = 0;
	}

	/*	Convert the PTRefNum to a fut */
	PTData = getPTData (PTRefNum);
	fut = fut_lock_fut (PTData);
	if (fut == FUT_NULL) {
		return KCP_PTERR_2;
	}

	if ( ! IS_FUT (fut) ) {	/* check for valid fut */
		retVal = KCP_NOT_FUT;
		goto GetOut;
	}

	switch (format ) {

#if !defined KCP_ICC_ONLY
	case PTTYPE_FUTF:
		/* 	may want to check if any of the grid dimensions exceed the max 
			grid dimension, but for now accept any size						*/
		break;
#endif
	case PTTYPE_MAB1:
	case PTTYPE_MAB2:
	case PTTYPE_MBA1:
	case PTTYPE_MBA2:
		/* 	may want to check if any of the grid dimensions exceed the max 
			grid dimension, but for now accept any size						*/
		break;

	case PTTYPE_MFT1:
	case PTTYPE_MFT2:
	case PTTYPE_MFT2_VER_0:
		/*	The grid dimensions must all be the same.  If they are not then
			attempt to build a grid table where all the dimensions are the
			same.															*/
		retVal = (PTErr_t) fut_mfutInfo (fut, &LUTDimensions, &inputChans, &outputChans, format,
										&dummy, &dummy, &dummy);
		if (1 != retVal) {
			if (-2 != retVal) {
				retVal = KCP_INVAL_GRID_DIM;
				goto GetOut;
			}
			else {
				KpInt32_t	i1, newGridDims[FUT_NICHAN];
				fut_p		futresized;

				for (i1 = 0; i1 < FUT_NICHAN; i1++) {		/* define new grid sizes */
					newGridDims[i1] = LUTDimensions;
				}

				futresized = fut_resize (fut, newGridDims);	/* resize the fut */
				if (futresized == NULL) {
					retVal = KCP_NO_MEMORY;
					goto GetOut;
				}

				if (futresized == fut) {					/* should not happen, probably fut_mfutInfo() error */
					retVal = KCP_SYSERR_3;
					goto GetOut;
				}

				if (fut_to_mft (futresized) != 1) {			/* convert to reference tables */
					retVal = KCP_INCON_PT;
					goto GetOut;
				}

				retVal = fut2PT (&futresized, -1, -1, PTTYPE_CALCULATED, resizePTRefNumP);	/* make into PT */
				if (retVal == KCP_SUCCESS) {
					retVal = copyAllAttr (PTRefNum, *resizePTRefNumP);	/* Copy all attributes to new PT */
					if (retVal != KCP_SUCCESS) {
						PTCheckOut (*resizePTRefNumP);
						goto GetOut;
					}
				}
 			}
		}
		break;

	default:
		retVal = KCP_INVAL_PTTYPE;
	}

	retVal = KCP_SUCCESS;

GetOut:
	fut_unlock_fut (fut);
	return retVal;
}
Exemplo n.º 5
0
/* frees source fut on error */
PTErr_t
	fut2PT (fut_p		*futSrc,
			KpInt32_t	inSpace,
			KpInt32_t	outSpace,
			KpInt32_t	srcFormat,
			PTRefNum_p	PTRefNumNew)
{
PTErr_t		PTErr;
fut_hdr_p	PTHdr = NULL;
KpHandle_t	PTHdrH = NULL, PTDataH = NULL;
KpChar_t	colorSpaceAttr[20];

	*PTRefNumNew = 0;

	if ( ! IS_FUT(*futSrc)) goto ErrOut1;

	PTHdr = allocBufferPtr (sizeof(fut_hdr_t));	/* get buffer for resultant info header */
	if (PTHdr == NULL) {
		goto ErrOut4;
	}

	if (!fut_io_encode (*futSrc, PTHdr)) {	/* make the info header */
		goto ErrOut3;
	}

	PTHdr->srcFormat = srcFormat;

	PTDataH = fut_unlock_fut (*futSrc);
	if (PTDataH == NULL) {
		goto ErrOut2;
	}
	*futSrc = NULL;

	PTHdrH = unlockBufferPtr (PTHdr);		/* unlock the header buffer */
	if (PTHdrH == NULL) {
		goto ErrOut2;
	}
	PTHdr = NULL;

	PTErr = registerPT (PTHdrH, NULL, PTRefNumNew);	/* enter PT into list */
	if (PTErr != KCP_SUCCESS) {
		goto ErrOut0;
	}

	makeActive (*PTRefNumNew, PTDataH);		/* activate the new PT */

	if (inSpace != -1) {	/* set the input color space attribute */
		KpItoa (inSpace, colorSpaceAttr); 
		PTErr = PTSetAttribute (*PTRefNumNew, KCM_IN_SPACE, colorSpaceAttr);
	}

	if (outSpace != -1) {	/* set the output color space attribute */
		KpItoa (outSpace, colorSpaceAttr); 
		PTErr = PTSetAttribute (*PTRefNumNew, KCM_OUT_SPACE, colorSpaceAttr);
	}

	if (PTErr != KCP_SUCCESS) {
		goto ErrOut0;
	}

getOut:
	return PTErr;


ErrOut4:
	PTErr = KCP_NO_CHECKIN_MEM;	
	goto ErrOut0;

ErrOut3:
	PTErr = KCP_ENCODE_PTHDR_ERR;
	goto ErrOut0;

ErrOut2:
	PTErr = KCP_MEM_UNLOCK_ERR;
	goto ErrOut0;

ErrOut1:
	PTErr = KCP_BAD_ARG;

ErrOut0:
	if (PTDataH != NULL) {
		*futSrc = fut_lock_fut (PTDataH);
	}
	if (*futSrc != FUT_NULL) fut_free (*futSrc);

	if (PTHdr != NULL) freeBufferPtr (PTHdr);
	if (PTHdrH != NULL) freeBuffer (PTHdrH);
	if (*PTRefNumNew != 0) PTCheckOut (*PTRefNumNew);

	goto getOut;
}