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; }
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; }