📄 tmdlmbs2_support.c
字号:
if (pTaskDescr->taskFlags & tmdlMbsFlagSlicingEn) { sliceWidth = pTask->dlTaskDescr.sliceRect.lr.x - pTask->dlTaskDescr.sliceRect.ul.x; // sub runin/out before internal slicing to // ensure that the decision whether to slice // or not allows room for runin/out // in this case we sub 2 times but that's OK if (dstWidth != sliceWidth) limitX -= MBS_MAX_RUNIN + MBS_MAX_RUNOUT; srcWidth = sliceWidth * srcWidth / dstWidth; dstWidth = sliceWidth; sliceHeight = pTask->dlTaskDescr.sliceRect.lr.y - pTask->dlTaskDescr.sliceRect.ul.y; srcHeight = sliceHeight * srcHeight / dstHeight; dstHeight = sliceHeight; } MBS2_ERR_CHECK( srcWidth < MBS_MAX_STRIDE , TMDL_ERR_BAD_PARAM, "MbsSliceTask: Invalid Source Rect"); MBS2_ERR_CHECK( dstWidth < MBS_MAX_STRIDE , TMDL_ERR_BAD_PARAM, "MbsSliceTask: Invalid Dest Rect"); horizSliced = (srcWidth > limitX && dstWidth > limitX); limitX -= MBS_MAX_RUNIN + MBS_MAX_RUNOUT; if ( horizSliced ) { limitY = pMbsInst->maxInternalSliceVerticalSize; } else { limitY = MBS_MAX_VERTICAL_RESOLUTION; } vertSliced = (srcHeight > limitY || dstHeight > limitY); if (horizSliced || vertSliced) { nrOfVertSlices = dstHeight / limitY; nrOfVertSlices += (dstHeight != (nrOfVertSlices * limitY)); nrOfHorzSlices = (dstWidth / limitX); nrOfHorzSlices += (dstWidth != (nrOfHorzSlices * limitX)); *pNrOfSlices = nrOfVertSlices * nrOfHorzSlices; DBG_ASSERT2 ( *pNrOfSlices <= pMbsInst->nrOfSlicedTasks, ("Insufficient number of tasks. Check max resolution in instance setup")); if ((pTask->updateFlags & (tmdlMbsUpdateScaling | tmdlMbsUpdateBuffers))) { // TODO: slice at 00 if (pTaskDescr->taskFlags & tmdlMbsFlagSlicingEn) { prevSliceEnd.y = pTaskDescr->sliceRect.ul.y; } else { prevSliceEnd.y = 0; } maxHeight = dstHeight; pCurrSliceTask = &(pMbsInst->pTaskInfo [0]); // reverse numbering here so tasks are // executed right to left, top to bottom for ( j = nrOfVertSlices - 1; j >= 0; j -- ) { if (pTaskDescr->taskFlags & tmdlMbsFlagSlicingEn) { prevSliceEnd.x = pTaskDescr->sliceRect.ul.x; } else { prevSliceEnd.x = 0; } sliceHeight = MIN(maxHeight,limitY); if (maxHeight - sliceHeight > 0 && maxHeight - sliceHeight <= MBS_RECT_MIN_HEIGHT) { sliceHeight -= MBS_RECT_MIN_HEIGHT; } for (i = 0; i < nrOfHorzSlices; i++) { pCurrSliceTask = &(pMbsInst->pTaskInfo [taskIndex + (j * nrOfHorzSlices) + i]); if ( i != 0 || j != 0 ) { tmdlMbsTaskCopy ( (tmInstance_t)pMbsInst, taskIndex + (j * nrOfHorzSlices) + i + 1, taskIndex + 1, tmdlMbsTaskCopyFlagsNone); } pCurrSliceTaskDescr = &(pCurrSliceTask->dlTaskDescr); pCurrSliceTask->internalSliceRect.ul.x = prevSliceEnd.x; pCurrSliceTask->internalSliceRect.ul.y = prevSliceEnd.y; pCurrSliceTask->internallySliced = True; sliceWidth = MIN(dstWidth,limitX); if (dstWidth - sliceWidth > 0 && dstWidth - sliceWidth <= MBS_RECT_MIN_WIDTH) { sliceWidth -= MBS_RECT_MIN_WIDTH; } pCurrSliceTask->internalSliceRect.lr.x = pCurrSliceTask->internalSliceRect.ul.x + sliceWidth; pCurrSliceTask->internalSliceRect.lr.y = pCurrSliceTask->internalSliceRect.ul.y + sliceHeight; prevSliceEnd.x = pCurrSliceTask->internalSliceRect.lr.x; dstWidth -= sliceWidth; status = MbsValidateBufferRects (pMbsInst, pCurrSliceTask); DBG_ASSERT(status == TM_OK); pCurrSliceTask->updateFlags |= tmdlMbsUpdateBuffers; } prevSliceEnd.y = pCurrSliceTask->internalSliceRect.lr.y; maxHeight -= sliceHeight; dstWidth = pTaskDescr->outputBuffer.rect.lr.x - pTaskDescr->outputBuffer.rect.ul.x; if (pTaskDescr->taskFlags & tmdlMbsFlagSlicingEn) { dstWidth = pTask->dlTaskDescr.sliceRect.lr.x - pTask->dlTaskDescr.sliceRect.ul.x; } } } else { for (i = 0; i < *pNrOfSlices; i++) { pCurrSliceTask = &(pMbsInst->pTaskInfo [taskIndex + i]); pCurrSliceTask->internallySliced = True; pCurrSliceTask->updateFlags = pTask->updateFlags; pCurrSliceTaskDescr = &(pCurrSliceTask->dlTaskDescr); pCurrSliceTaskDescr->inputBuffer.memBuf1 = pTaskDescr->inputBuffer.memBuf1; pCurrSliceTaskDescr->inputBuffer.memBuf2 = pTaskDescr->inputBuffer.memBuf2; pCurrSliceTaskDescr->inputBuffer.memBuf3 = pTaskDescr->inputBuffer.memBuf3; pCurrSliceTaskDescr->outputBuffer.memBuf1 = pTaskDescr->outputBuffer.memBuf1; pCurrSliceTaskDescr->outputBuffer.memBuf2 = pTaskDescr->outputBuffer.memBuf2; } } } else { *pNrOfSlices = 1; pTask->internallySliced = False; }} // MbsSliceTask#if (TMFL_OS_IS_CE && (TMFL_CPU == TMFL_CPU_R3940))#pragma optimize( "", off )#endif//-----------------------------------------------------------------------------//UInt32MbsCalcSliceDtoOffset ( UInt32 dst, UInt32 dtoOffset, UInt32 zoom, UInt32 nrOfTaps, Bool bTransposedPolyphase ){ double dto; UInt32 phase; // if at the left edge of the dst rect, use standard dtoOffset UInt32 newOffset = dtoOffset; if (dst != 0) { if (bTransposedPolyphase) { // transpose polyphase mode // new_offset = (((left(x) * zoom) >> 6) + dtoOffset) MOD 0x400 newOffset = (((MbsCalcSliceSrc (dst, dtoOffset, zoom, nrOfTaps, True, True) * zoom) / 0x40) + dtoOffset) % 0x400; } else { // normal polyphase // new_offset = (nrOfTaps - 1) * 0x400 + ((dto(x) >> 6) MOD 0x400) // (dtoOffset << 6) + (x * zoom) dto = (((double) dtoOffset * 0x40) + (double) dst * (double) zoom); // ((dto(x) >> 6) MOD 0x400) phase = ((UInt32) (dto / 0x40)) % 0x400; newOffset = (nrOfTaps - 1) * 0x400 + phase; } } return newOffset;} // MbsCalcSliceDtoOffset//-----------------------------------------------------------------------------// FUNCTION: MbsCalcSliceDtoOffsetVert://// DESCRIPTION: Given the destination coordinate, calculate the new dtoOffset.//// RETURN: dtoOffset//// NOTES: None//-----------------------------------------------------------------------------//UInt32MbsCalcSliceDtoOffsetVert ( UInt32 dst, UInt32 dtoOffset, UInt32 zoom, UInt32 nrOfTaps, tmdlMbsPhaseCorrType_t phaseCorrReqd, Bool bTransposedPolyphase ){ double dto; UInt32 phase; // if at the left edge of the dst rect, use standard dtoOffset UInt32 newOffset = dtoOffset; if (dst != 0) { if (bTransposedPolyphase) { // transpose polyphase mode // new_offset = (((left(x) * zoom) >> 6) + dtoOffset) MOD 0x400 newOffset = (((MbsCalcSliceSrc (dst, dtoOffset, zoom, nrOfTaps, True, True) * zoom) / 0x40) + dtoOffset) % 0x400; } else { // normal polyphase // new_offset = (nrOfTaps - 1) * 0x400 + ((dto(x) >> 6) MOD 0x400) // (dtoOffset << 6) + (x * zoom) dto = (((double) dtoOffset * 0x40) + (double) dst * (double) zoom); // ((dto(x) >> 6) MOD 0x400) phase = ((UInt32) (dto / 0x40)) % 0x400; newOffset = (nrOfTaps - 1) * 0x400 + phase; } } if (!bTransposedPolyphase) { if (phaseCorrReqd == mbsEvenToEvenPhaseCorrection) { newOffset = newOffset + ((zoom >> 7) - 0x200); } if (phaseCorrReqd == mbsFrameToEvenPhaseCorrection) { newOffset = newOffset + (zoom >> 7); } if (phaseCorrReqd == mbsOddToFramePhaseCorrection) { newOffset = newOffset + 0x200; } } return newOffset;} // MbsCalcSliceDtoOffsetVert#if (TMFL_OS_IS_CE && (TMFL_CPU == TMFL_CPU_R3940))#pragma optimize( "", on )#endif//-----------------------------------------------------------------------------// FUNCTION: MbsCalcSliceSrc://// DESCRIPTION: Given the destination coordinate, calculate the required source// coordinate for the slice.//// RETURN: src coordinate//// NOTES: None//-----------------------------------------------------------------------------//Int32MbsCalcSliceSrc ( Int32 dst, // destination slice x value UInt32 dtoOffset, // initial dstOffset value UInt32 zoom, // zoom register value UInt32 nrOfTaps, // # of taps being used Bool bTransposedPolyphase, // TRUE if transpose polyphase filter Bool bLeftEdge // TRUE if calc left edge of src slice ){ // if dst == 0, src must be = 0 Int32 srcX = dst; double tempX; if ((zoom != 0) && (dst != 0)) { if (bTransposedPolyphase) { if (bLeftEdge) { // left(x) = ((x << 16) + (dtoOffset << 6) + zoom - 1) / zoom srcX = ( ((dst * 0x10000) + (dtoOffset * 0x40) + zoom - 1) / zoom ); } else { // right(x) = left(x+6) - 1 dst += 6; // add an additional (zoom - 1) to round up to make sure we // supply enough source data srcX = (Int32)((((UInt32)dst * 0x10000 + (dtoOffset * 0x40)// + zoom - 1 + zoom - 1) / zoom) - 1); + zoom + zoom - 2) / zoom) - 1); } } else { // normal polyphase mode // right(x) = ((dtoOffset << 6) + x * zoom) >> 16 tempX = (((double)dtoOffset * 0x40) + (double)dst * (double)zoom); if (bLeftEdge) { // left(x) = right(x) - (nrOfTaps - 1) srcX = (Int32)(tempX / 0x10000) - (Int32)(nrOfTaps - 1); } else // right edge { // round up to make sure we supply enough data srcX = (Int32)((tempX + 0xFFFF) / 0x10000); } } } return srcX;} // MbsCalcSliceSrc//-----------------------------------------------------------------------------// FUNCTION: MbsCheckStalledTask://// DESCRIPTION: Check if the MBS has stalled.//// RETURN: TM_OK//// NOTES: If the task remains in the InFifo state, we will force the// ISR handler to be called, to allow it's stall code to be// executed.//-----------------------------------------------------------------------------//voidMbsCheckStalledTask ( tmUnitSelect_t mbsUnit, // I: MBS unit number ptmdlMbsTaskInfo_t pTask // I: ptr to task to remove ){ union _mbsIntSet intSet; if (!MBS_Q_IS_EMPTY(fifoQ [mbsUnit])) { if (pTask->taskStatus == tmdlMbsTaskInFifo) { // force ISR handler to be called intSet.u32 = 0; intSet.bits.taskProcError = 1; gpRegs [mbsUnit]->event.intSet.u32 = intSet.u32; } }} // MbsCheckStalledTask//-----------------------------------------------------------------------------// FUNCTION: MbsChromaOffset2ProgVal://// DESCRIPTION: Converts the chroma dto Offset to the actual programmed register
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -