Exemplo n.º 1
0
/* fut_new_otbl creates a new output table for one channel of a fut.
 * Ofun must be a pointer to a function accepting a fut_gtbldat_t in the
 * range (0,FUT_GRD_MAXVAL) and returning a fut_otbldat_t in the same
 * interval.	A pointer to the newly allocated table is returned.
 * (If ofun is NULL, table is not intialized!).
 */
fut_otbl_p
	fut_new_otblEx (	PTTableType_t	tableType,
						PTDataClass_t	oClass,
						fut_ofunc_t		ofun,
						fut_calcData_p	data)
{
fut_otbl_p	otbl;

					/* allocate output table structure */
	otbl = fut_alloc_otbl();
	if ( otbl == FUT_NULL_OTBL ) {
		DIAG("fut_new_otbl: can't alloc output table struct.\n", 0);
		return (FUT_NULL_OTBL);
	}

	otbl->dataClass = oClass;

					/* allocate the table */
	if (tableType == KCP_PT_TABLES) {
		otbl->tbl = fut_alloc_otbldat (otbl);
		if ( otbl->tbl == NULL ) {
			DIAG("fut_new_otbl: can't alloc output table array.\n", 0);
			fut_free_otbl (otbl);
			return (FUT_NULL_OTBL);
		}
	} else {
		otbl->refTbl = fut_alloc_omftdat (otbl, FUT_OUTTBL_ENT);
		if ( otbl->refTbl == NULL ) {
			DIAG("fut_new_otbl: can't alloc output table array.\n", 0);
			fut_free_otbl (otbl);
			return (FUT_NULL_OTBL);
		}
	}

					/* compute the output table entries */
	if ( ! fut_calc_otblEx (otbl, ofun, data) ) {
		fut_free_otbl (otbl);
		return (FUT_NULL_OTBL);
	}

	return (otbl);
}
Exemplo n.º 2
0
PTErr_t
	makeInverseXformMono (	ResponseRecord_p	grayTRC,
							fut_p				theFut)
{
PTErr_t			PTErr = KCP_FAILURE;
fut_otbldat_p	otblDat;
ResponseRecord_t rrt;
KpInt32_t		futReturn;
fut_calcData_t	data;
double			gamma;
KpUInt16_t		rrpData[2] = { 0, RRECORD_DATA_SIZE -1 };

	/* compute new grid table entries */
	data.chan = 0;
	if (!fut_calc_gtblEx (theFut->chan[0]->gtbl, fut_grampEx, &data)) {
		goto ErrOut0;
	}

	/* compute new output table entries */
	if (!fut_calc_otblEx (theFut->chan[0]->otbl, otblFunc, NULL)) {
		goto ErrOut0;
	}

	/* get address of the first output table */
	futReturn = fut_get_otbl (theFut, 0, &otblDat);
	if ((futReturn != 1) || (otblDat == (fut_otbldat_p)NULL)) {
		goto ErrOut0;
	}

	/* setup the output table */
	switch (grayTRC->count) {
	case 0:
		/* setup the responseRecord struct */
		rrt.count = 2;
		rrt.data = rrpData;

		/* make the output table */
		PTErr = calcOtblLN (otblDat, &rrt);
		break;

	case 1:
		gamma = (double)grayTRC->data[0] / SCALEDOT8;
		if (gamma <= 0.0) {
			goto ErrOut0;
		}

		/* make the output table */
		PTErr = calcOtblL1 (otblDat, gamma);
		break;

	default:
		/* make the output table */
		makeInverseMonotonic (grayTRC->count, grayTRC->data);

		PTErr = calcOtblLN (otblDat, grayTRC);
	}

GetOut:
	return (PTErr);


ErrOut0:
	PTErr = KCP_SYSERR_0;
	goto GetOut;
}
Exemplo n.º 3
0
PTErr_t
	makeForwardXformMono (	ResponseRecord_p	grayTRC,
							fut_p				theFut)
{
PTErr_t			PTErr = KCP_FAILURE;
KpInt32_t		futReturn, i1;
fut_otbldat_p	otblDat;
double			gamma;
fut_calcData_t	calcData;
KpUInt16_t		rrpData[2] = { 0, RRECORD_DATA_SIZE -1 };
ResponseRecord_t	rrt;
KpUInt16_t		*pCurveData = NULL;

	/* compute new table entries */
	calcData.chan = 0;				/* always uses 1st input chan */

	for (i1 = 0; i1 < FWD_MONO_OCHANS; i1++) {
		if (( ! IS_CHAN(theFut->chan[i1])) ||
			!fut_calc_gtblEx (theFut->chan[i1]->gtbl, fut_grampEx, &calcData) ||
			!fut_calc_otblEx (theFut->chan[i1]->otbl, otblFunc, NULL)) {
			goto ErrOut0;
		}
	}

	/* get address of the first output table */
	futReturn = fut_get_otbl (theFut, 0, &otblDat);
	if ((futReturn != 1) || (otblDat == (fut_otbldat_p)NULL)) {
		goto ErrOut0;
	}

	if (PARA_TYPE_SIG == grayTRC->TagSig)
	{
		pCurveData = (KpUInt16_p) allocBufferPtr (MFV_CURVE_TBL_ENT);	/* get memory for curve data */
		if (NULL == pCurveData) {
			return KCP_NO_MEMORY;
		}
		makeCurveFromPara (grayTRC->ParaFunction, grayTRC->ParaParams, pCurveData, MFV_CURVE_TBL_ENT);
		grayTRC->CurveCount = MFV_CURVE_TBL_ENT;
		grayTRC->CurveData = pCurveData;
	}
	/* setup the output table */
	switch (grayTRC->CurveCount)
	{
	case 0:
		/* setup the responseRecord struct */
		rrt.CurveCount = 2;
		rrt.CurveData = rrpData;

		/* make the output table */
		PTErr = calcOtblLSN (otblDat, &rrt);
		break;

	case 1:
		gamma = (double)grayTRC->CurveData[0] / SCALEDOT8;
		if (gamma <= 0.0) {
			goto ErrOut0;
		}

		/* make the output table */
		PTErr = calcOtblLS1 (otblDat, gamma);
		break;

	default:
		/* make the output table */
		makeMonotonic (grayTRC->CurveCount, grayTRC->CurveData);
		PTErr = calcOtblLSN (otblDat, grayTRC);
	}

GetOut:
	if (NULL != pCurveData) {
		freeBufferPtr (pCurveData);
	}
	return PTErr;


ErrOut0:
	PTErr = KCP_SYSERR_0;
	goto GetOut;
}