📄 tmdlmbs2.c
字号:
// different for normal polyphase and transposed polyphase filters.//// scaling// (src:dst) normal polyphase transposed polyphase// =========================================================// 2:1 (downscale) 0x20000 ~ 0x08000 **// 1:1 (no scaling) 0x10000// 1:2 (upscale) 0x08000 not supported//// ** varies with src and dst size//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsGetScaleFactor ( UInt32 srcSize, // I: src size (width or height) UInt32 dstSize, // I: dst size tmdlMbsFilterType_t filter, // I: filter type tmdlMbsPhaseMode_t phaseMode, // I: phase mode Bool dynamicZoom, // I: True if dynamic zoom enabled pUInt32 pScaleFactor // O: receives scale factor ) {
Int32 left = 0, right = 0, phase = 0; // Use the version in tmdlMbs2_Support.c, that has better support for transposed filtering. // As this version is used only for direct filtering scale factors, it does not matter that // we provide the srcSize as the image size. return tmdlMbsGetScaleFactor2( srcSize, dstSize, srcSize, filter, phaseMode, dynamicZoom, pScaleFactor, &left, &right, &phase ); }
//-----------------------------------------------------------------------------// TASK CONTROL FUNCTIONS://-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// FUNCTION: tmdlMbsCreateClutModule://// DESCRIPTION: Creates a color look up table (CLUT) module//// RETURN: Resulting error condition//// NOTES: The lookup table entries are copied to local memory and can be// changed and/or destroyed after this call.//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsCreateClutModule ( tmInstance_t instance, // I: instance ptmColor4_t pColorTable, // I: ptr to CLUT UInt32 nrOfEntries, // I: nr of table entries ptmdlMbsModuleHandle_t pModuleHandle // O: module handle ){ tmErrorCode_t status; ptmdlMbsInstance_t pMbsInst = (ptmdlMbsInstance_t) instance; ptmColor4_t pSrc, pDst; UInt32 index; // make sure we have a valid instance DBG_ASSERT2( instance != 0, ("tmdlMbsCreateClutModule: Instance = 0") ); DBG_ASSERT2( pMbsInst->key == MBS_INSTANCE_KEY, ("tmdlMbsCreateClutModule: key 0x%X != 0x%X", pMbsInst->key, MBS_INSTANCE_KEY) ); DBG_ASSERT2( pMbsInst->setupDone == True, ("tmdlMbsCreateClutModule: Setup not done") ); MBS2_ERR_CHECK((pModuleHandle != Null), TMDL_ERR_MBS_NULL_PARAMETER, "tmdlMbsCreateClutModule:"); MBS2_ERR_CHECK((pColorTable != Null), TMDL_ERR_MBS_NULL_PARAMETER, "tmdlMbsCreateClutModule:");
MBS2_ERR_CHECK((nrOfEntries <= 256), TMDL_ERR_MBS_NULL_PARAMETER, "tmdlMbsCreateClutModule:");
*pModuleHandle = MBS_DEFAULT_MODULE; // in case of and error status = TMDL_ERR_MBS_NO_RESOURCES; index = 0; while ((status != TM_OK) && (index < pMbsInst->setup.nrOfClutModules)) { if (pMbsInst->pClutInfo [index].empty == True) { // return the module handle *pModuleHandle = index + 1; pMbsInst->pClutInfo [index].empty = False; // save the CLUT information/values pMbsInst->pClutInfo [index].nrOfEntries = nrOfEntries; pSrc = pColorTable; pDst = pMbsInst->pClutInfo [index].colorTable; for ( ; nrOfEntries != 0; nrOfEntries--) { *pDst++ = *pSrc++; } status = TM_OK; } else { ++index; } } return status;}//-----------------------------------------------------------------------------// FUNCTION: tmdlMbsDestroyClutModule://// DESCRIPTION: Destroy color look up table module.//// RETURN: Resulting error condition//// NOTES: Frees allocated resources//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsDestroyClutModule ( tmInstance_t instance, // I: instance tmdlMbsModuleHandle_t moduleHandle // I: module handle ){ ptmdlMbsInstance_t pMbsInst = (ptmdlMbsInstance_t) instance; UInt32 index; // make sure we have a valid instance DBG_ASSERT2( instance != 0, ("tmdlMbsDestroyClutModule: Instance = 0") ); DBG_ASSERT2( pMbsInst->key == MBS_INSTANCE_KEY, ("tmdlMbsDestroyClutModule: key 0x%X != 0x%X", pMbsInst->key, MBS_INSTANCE_KEY) ); index = (UInt32) moduleHandle - 1; MBS2_ERR_CHECK((index < pMbsInst->setup.nrOfClutModules), TMDL_ERR_MBS_BAD_PARAMETER, "tmdlMbsDestroyClutModule: Bad moduleHandle"); pMbsInst->pClutInfo [index].empty = True; return TM_OK;} // tmdlMbsDestroyClutModule//-----------------------------------------------------------------------------// FUNCTION: tmdlMbsTaskCreate://// DESCRIPTION: Creates a scaling task with the specified settings. The device// library uses the task descriptor to store all the information// the dispatcher needs to schedule and execute the task. After// the task has been created the task descriptor can be modified// by applications without affecting the task. The function// returns a task handle that is used for future operations on// the task (dispatching, destroying ...).//// RETURN: Resulting error condition//// NOTES: Video measurements and EDDI are disabled after this call. Use// tmdlMbsTaskUpdateMeas to initialize video measurements. Use// tmdlMbsTaskUpdateEddi to initialize EDDI.//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsTaskCreate ( tmInstance_t instance, // I: instance ptmdlMbsTaskDescriptor_t pTaskDescriptor, // I: ptr to task descriptor ptmdlMbsTaskHandle_t pTaskHandle // O: ptr to recv task handle ){ UInt32 i; UInt32 j; tmErrorCode_t status; ptmdlMbsInstance_t pMbsInst = (ptmdlMbsInstance_t) instance; ptmdlMbsTaskInfo_t pTask; // make sure we have a valid instance and valid parameters DBG_ASSERT2( instance != 0, ("tmdlMbsTaskCreate: Instance = 0") ); DBG_ASSERT2( pMbsInst->key == MBS_INSTANCE_KEY, ("tmdlMbsTaskCreate: key 0x%X != 0x%X", pMbsInst->key, MBS_INSTANCE_KEY) ); DBG_ASSERT2( pMbsInst->setupDone == True, ("tmdlMbsTaskCreate: Setup not done") ); DBG_ASSERT2( pTaskDescriptor != Null, ("tmdlMbsTaskCreate: Invalid pTaskDescriptor") ); DBG_ASSERT2( pTaskDescriptor->size == sizeof(tmdlMbsTaskDescriptor_t), ("tmdlMbsTaskCreate: Invalid pTaskDescriptor size %d != %d", pTaskDescriptor->size, sizeof(tmdlMbsTaskDescriptor_t) ) ); DBG_ASSERT2( (pTaskDescriptor->inputBuffer.bufFormat.imageStride % gMbsCaps[pMbsInst->unit].bufferStrideMult) == 0, ("tmdlMbsTaskCreate: Invalid Y stride: 0x%X [Input buffer]", pTaskDescriptor->inputBuffer.bufFormat.imageStride) ); DBG_ASSERT2( (pTaskDescriptor->outputBuffer.bufFormat.imageStride % gMbsCaps[pMbsInst->unit].bufferStrideMult) == 0, ("tmdlMbsTaskCreate: Invalid Y stride: 0x%X [Output buffer]", pTaskDescriptor->outputBuffer.bufFormat.imageStride) ); /* UV stride will be checked later, since there its known if they are requited or not */
{ // invalidate the handle in case we fail *pTaskHandle = 0; status = TMDL_ERR_MBS_NO_RESOURCES; i = 0; do { if (pMbsInst->pTaskInfo[i].empty == True) { for ( j = 0; j < pMbsInst->nrOfSlicedTasks; j++) {// DBG_ASSERT (pMbsInst->pTaskInfo[i+j].empty == True) pTask = &(pMbsInst->pTaskInfo [i+j]); // save task information pTask->dlTaskDescr = *pTaskDescriptor; status = MbsTaskPrepare (pMbsInst, pTask); if (status == TM_OK) { DBG_ASSERT2( (pTask->srcFormatInfo.bits.planes == 1) | ((pTaskDescriptor->inputBuffer.bufFormat.imageUVStride % gMbsCaps[pMbsInst->unit].bufferStrideMult) == 0), ("tmdlMbsTaskCreate: Invalid UV stride: 0x%X [Input buffer]", pTaskDescriptor->inputBuffer.bufFormat.imageUVStride) ); DBG_ASSERT2( (pTask->dstFormatInfo.bits.planes == 1) | ((pTaskDescriptor->outputBuffer.bufFormat.imageUVStride % gMbsCaps[pMbsInst->unit].bufferStrideMult) == 0), ("tmdlMbsTaskCreate: Invalid UV stride: 0x%X [Output buffer]", pTaskDescriptor->outputBuffer.bufFormat.imageUVStride) );
pTask->empty = False; if ( j == 0 ) { *pTaskHandle = pTask->taskHandle; } pTask->vidMeasInstance = pMbsInst->vidMeasInstance; } } i = pMbsInst->totalNrOfTasks; // indicate we are done } else { i += pMbsInst->nrOfSlicedTasks; } } while (i < pMbsInst->totalNrOfTasks); } return status;} // tmdlMbsTaskCreate//-----------------------------------------------------------------------------// FUNCTION: tmdlMbsTaskDestroy://// DESCRIPTION: Destroys a task and frees the allocated resources.//// RETURN: Resulting error condition// TMDL_ERR_MBS_BUSY task is still pending execution//// NOTES: If a task is pending or in the FIFO, the caller should wait,// and call tmdlMbsTaskDestroy again.//-----------------------------------------------------------------------------//tmErrorCode_ttmdlMbsTaskDestroy ( tmInstance_t instance, // I: instance tmdlMbsTaskHandle_t taskHandle // I: task handle ){ ptmdlMbsInstance_t pMbsInst = (ptmdlMbsInstance_t) instance; UInt32 taskIndex = (UInt32) taskHandle - 1; tmErrorCode_t status = TM_OK; ptmdlMbsTaskInfo_t pTask; // make sure we have a valid instance DBG_ASSERT2( instance != 0, ("tmdlMbsTaskDestroy: Instance = 0") ); DBG_ASSERT2( pMbsInst->key == MBS_INSTANCE_KEY, ("tmdlMbsTaskDestroy: key 0x%X != 0x%X", pMbsInst->key, MBS_INSTANCE_KEY) ); DBG_ASSERT2( taskIndex < pMbsInst->totalNrOfTasks, ("tmdlMbsTaskDestroy: Invalid task idx %d >= %d", taskIndex, pMbsInst->totalNrOfTasks) ); if (pMbsInst->pTaskInfo[taskIndex].empty != True) { pTask = &(pMbsInst->pTaskInfo [taskIndex]); switch (pTask->taskStatus) { case tmdlMbsTaskPending: pTask->abortTask = True; status = TMDL_ERR_MBS_BUSY; break; case tmdlMbsTaskInFifo: MbsCheckStalledTask (pMbsInst->unit, &(pMbsInst->pTaskInfo [taskIndex])); status = TMDL_ERR_MBS_BUSY; break; default: pMbsInst->pTaskInfo[taskIndex].empty = True; status = TM_OK; break; } } return status;} // tmdlMbsTaskDestroy//-----------------------------------------------------------------------------// FUNCTION: tmdlMbsTaskDispatch://// DESCRIPTION: Schedule tasks for execution. If the buffer pointers// are not Null, the new buffer addresses will be set before// dispatching the tasks. Buffer overwrite can be used to reuse a// scaling task if only the buffer address changes (which is a very// typical case for video streaming applications).//// RETURN: tmErrorCode_t = resulting error condition or TM_OK//// NOTES: DO NOT call tmdlMbsTaskDispatch to reuse a task until the task// status has changed to tmdlMbsTaskCompleted.//// If taskCount > 1, only one callback is made when the group of// tasks is completed. The returned taskHandle will be for the// first task in the pTaskDisp array.//// If measurement information is required, it will only be provided// for a single task, or the last task in the task array.//-----------------------------------------------------------------------------//#define MBS_DISPATCH_UPDATE_NONE 0#define MBS_DISPATCH_UPDATE_INBUF 1#define MBS_DISPATCH_UPDATE_OUTBUF 2tmErrorCode_ttmdlMbsTaskDispatch ( tmInstance_t instance, // I: instance UInt32 taskCount, // I: number of tasks in pTaskDisp ptmdlMbsTaskDispatch_t pTaskDisp // I: ptr to array of task info ){ tmErrorCode_t status = TM_OK; Int32 index; ptmdlMbsInstance_t pMbsInst = (ptmdlMbsInstance_t) instance; UInt32 taskIndex; UInt32 updates; ptmdlMbsTaskDescriptor_t pTaskDescr; ptmdlMbsTaskInfo_t pTask; ptmdlMbsTaskInfo_t pUpdateTask, pPrevUpdateTask; ptmdlMbsTaskInfo_t pDispatchTask, pPrevDispatchTask, pFirstDispatchTask; UInt32 i, nrOfSlices; // make sure we have a valid instance
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -