⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 umc_vc1_dec_job.cpp

📁 audio-video-codecs.rar语音编解码器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
                pContext->m_pSingleMB->m_currMBXpos++;
            }

            pContext->m_pSingleMB->m_currMBXpos = 0;
            ++pContext->m_pSingleMB->m_currMBYpos;
            ++pContext->m_pSingleMB->slice_currMBYpos;
        }
    STATISTICS_END_TIME(m_timeStatistics->mc_StartTime,
                        m_timeStatistics->mc_EndTime,
                        m_timeStatistics->mc_TotalTime);
    STATISTICS_START_TIME(m_timeStatistics->smoothing_StartTime);
    pContext->m_pSingleMB->m_currMBXpos = 0;
    pContext->m_pSingleMB->m_currMBYpos = pTask->m_pSlice->MBStartRow;
    pContext->m_pBlock = pTask->m_pBlock;
    pContext->m_pCurrMB = &pContext->m_MBs[pTask->m_pSlice->MBStartRow*pContext->m_seqLayerHeader->widthMB];

    if ((pContext->m_picLayerHeader->PTYPE !=VC1_B_FRAME)&&(m_pStore->IsNeedPostProcFrame(pTask->m_pSlice->m_picLayerHeader->PTYPE)))
    {
       MBSmooth_tbl[pContext->m_seqLayerHeader->PROFILE*4 + pContext->m_picLayerHeader->PTYPE](pContext,pTask->m_pSlice->MBRowsToDecode);
    }
    STATISTICS_END_TIME(m_timeStatistics->smoothing_StartTime,
            m_timeStatistics->smoothing_EndTime,
            m_timeStatistics->smoothing_TotalTime);

    if ((pContext->m_picLayerHeader->PTYPE !=VC1_B_FRAME) &&
        (!pContext->m_seqLayerHeader->LOOPFILTER))
    {
        if (pContext->m_seqLayerHeader->PROFILE != VC1_PROFILE_ADVANCED)
        {

           Ipp32s StartMBRow = pTask->m_pSlice->MBStartRow;
           Ipp32s HeightMB = pTask->m_pSlice->MBRowsToDecode;
           if (pTask->m_pSlice->MBStartRow != 0)
               --StartMBRow;
           else
               --HeightMB;
           if (pTask->m_pSlice->MBEndRow == pContext->m_seqLayerHeader->heightMB)
               ++HeightMB;

           pContext->m_pCurrMB = &pContext->m_MBs[StartMBRow*pContext->m_seqLayerHeader->widthMB];
           ExpandMBRowSM(pContext,StartMBRow,HeightMB);
        }
    }
#ifdef VC1_DEBUG_ON
    pContext->m_pSingleMB->m_currMBXpos = 0;
    pContext->m_pSingleMB->m_currMBYpos = pTask->m_pSlice->MBStartRow;
    pContext->m_pBlock = pTask->m_pBlock;
    pContext->m_pPredBlock = pTask->m_pPredBlock;
    pContext->m_pCurrMB = &pContext->m_MBs[pTask->m_pSlice->MBStartRow*m_pContext->m_seqLayerHeader->widthMB];

    for (Ipp32s i=0;   i < pTask->m_pSlice->MBRowsToDecode;i++)
    {
        for (Ipp32s j = 0; j < pContext->m_pSingleMB->widthMB; j++)
        {
            if (VC1_DEBUG&VC1_SMOOTHINT)
                VM_Debug::GetInstance(VC1DebugRoutine)._print_macroblocks(pContext);

            ++pContext->m_pSingleMB->m_currMBXpos;
            pContext->m_pBlock += 8*8*6;
            pContext->m_pPredBlock += 8*8*6;
            ++pContext->m_pCurrMB;
        }

        pContext->m_pSingleMB->m_currMBXpos = 0;
        ++pContext->m_pSingleMB->m_currMBYpos;
        ++pContext->m_pSingleMB->slice_currMBYpos;
    }
#endif

    return VC1_OK;
}


VC1Status VC1TaskProcessor::VC1Deblocking (VC1Context* pContext, VC1Task* pTask)
{
    if (m_pStore->IsNeedPostProcFrame(pTask->m_pSlice->m_picLayerHeader->PTYPE))
    {
        pContext->DeblockInfo.is_last_deblock = 0;
        pContext->DeblockInfo.HeightMB = pTask->m_pSlice->MBRowsToDecode;
        pContext->DeblockInfo.start_pos = pTask->m_pSlice->MBStartRow;
        Deblock* pDeblock = Deblock_tbl_Adv;
        Ipp32s MBHeight = 0;

        if (pContext->m_seqLayerHeader->PROFILE != VC1_PROFILE_ADVANCED)
            pDeblock = Deblock_tbl;

        if (VC1_IS_NO_TOP_MB(pContext->m_pCurrMB->LeftTopRightPositionFlag))
        {
            pContext->DeblockInfo.HeightMB +=1;
            pContext->DeblockInfo.start_pos -=1;
            pContext->m_pCurrMB -= pContext->m_pSingleMB->widthMB;
        }
        pContext->iPrevDblkStartPos = pContext->DeblockInfo.start_pos - pTask->m_pSlice->iPrevDblkStartPos;
        MBHeight = pContext->DeblockInfo.HeightMB - 1;

        if (pTask->m_pSlice->is_LastInSlice)
        {
            pContext->DeblockInfo.is_last_deblock = 1;
            ++MBHeight;
        }

STATISTICS_START_TIME(m_timeStatistics->deblocking_StartTime);

        pDeblock[pContext->m_picLayerHeader->PTYPE*3 + pContext->m_picLayerHeader->FCM](pContext);

STATISTICS_END_TIME(m_timeStatistics->deblocking_StartTime,
                    m_timeStatistics->deblocking_EndTime,
                    m_timeStatistics->deblocking_TotalTime);


        if ((pContext->m_picLayerHeader->PTYPE !=VC1_B_FRAME)&&
            (pContext->m_seqLayerHeader->PROFILE != VC1_PROFILE_ADVANCED))
        {
            pContext->m_pCurrMB = &pContext->m_MBs[pContext->DeblockInfo.start_pos*pContext->m_seqLayerHeader->widthMB];
            ExpandMBRowSM(pContext,pContext->DeblockInfo.start_pos,MBHeight);
        }
    }
    return VC1_OK;
}

Status VC1TaskProcessor::Init(void *p, Ipp32s iNumber, VC1TaskStore*      pStore) //need to chande concer base class model
{
    VC1Context* pContext = static_cast<VC1Context*>(p);
    if (p == NULL)
        return UMC_ERR_INIT;

    m_iNumber = iNumber;
    pContext->iNumber = iNumber;

    m_pStore = pStore;

    m_pContext = (VC1Context*)ippsMalloc_8u(sizeof(VC1Context));
    if(!m_pContext)
    {
        return UMC_ERR_ALLOC;
    }
    memset(m_pContext, 0, sizeof(VC1Context));



    m_pContext->savedMV = pContext->savedMV;
    m_pContext->savedMVSamePolarity = pContext->savedMVSamePolarity;

    m_pSingleMB = (VC1SingletonMB*)ippsMalloc_8u(sizeof(VC1SingletonMB));
    if(NULL == m_pSingleMB)
        return UMC_ERR_ALLOC;
    memset(m_pSingleMB, 0, sizeof(VC1SingletonMB));

    m_pSingleMB->heightMB = pContext->m_seqLayerHeader->heightMB;
    m_pSingleMB->widthMB = pContext->m_seqLayerHeader->widthMB;

    return UMC_OK;
}

Status VC1TaskProcessor::InitPicParamJob()
{
    return UMC_OK;
}
Status VC1TaskProcessor::process()
{
    VC1FrameDescriptor*    pFrameDS;
    VC1Task* task;


    //VC1TaskStore* pStore = VC1TaskStore::GetInstance(VC1Routine);
#ifdef  VC1_THREAD_STATISTIC
    task->pJob = this;
#endif

    // Routine task

    while (m_pStore->GetNextTask(&pFrameDS, &task,m_iNumber))
    {
        if (task)
        {
            *m_pContext = *pFrameDS->m_pContext;
            m_pContext->m_pPredBlock = pFrameDS->getPredMem();//m_pStore->getMemForPred(m_iNumber,m_pContext);
            // we don't copy this field from pFrameDS
            m_pContext->m_pSingleMB =  m_pSingleMB;

            m_pContext->m_pSingleMB->currYPitch = m_pContext->m_frmBuff.m_pFrames[m_pContext->m_frmBuff.m_iCurrIndex].m_iYPitch;
            m_pContext->m_pSingleMB->currUPitch = m_pContext->m_frmBuff.m_pFrames[m_pContext->m_frmBuff.m_iCurrIndex].m_iUPitch;
            m_pContext->m_pSingleMB->currVPitch = m_pContext->m_frmBuff.m_pFrames[m_pContext->m_frmBuff.m_iCurrIndex].m_iVPitch;

            m_pContext->m_pSingleMB->currYPlane = m_pContext->m_frmBuff.m_pFrames[m_pContext->m_frmBuff.m_iCurrIndex].m_pY;
            m_pContext->m_pSingleMB->currUPlane = m_pContext->m_frmBuff.m_pFrames[m_pContext->m_frmBuff.m_iCurrIndex].m_pU;
            m_pContext->m_pSingleMB->currVPlane = m_pContext->m_frmBuff.m_pFrames[m_pContext->m_frmBuff.m_iCurrIndex].m_pV;


            m_pContext->interp_params_luma.roundControl = m_pContext->m_picLayerHeader->RNDCTRL;
            m_pContext->interp_params_chroma.roundControl = m_pContext->m_picLayerHeader->RNDCTRL;



            m_pContext->m_pCurrMB = &m_pContext->m_MBs[task->m_pSlice->MBStartRow*m_pContext->m_seqLayerHeader->widthMB];
            m_pContext->CurrDC = &m_pContext->DCACParams[task->m_pSlice->MBStartRow*m_pContext->m_seqLayerHeader->widthMB];
            m_pContext->m_pSingleMB->m_currMBXpos = 0;
            m_pContext->m_picLayerHeader = task->m_pSlice->m_picLayerHeader;
            m_pContext->m_pSingleMB->m_currMBYpos = task->m_pSlice->MBStartRow;//m_pCurrSlice->MBStartRow;
            m_pContext->m_pSingleMB->slice_currMBYpos = task->m_pSlice->MBStartRow;
            m_pContext->m_pSingleMB->EscInfo = task->m_pSlice->EscInfo;


            if ((m_pContext->m_picLayerHeader->CurrField)&&(m_pContext->m_pSingleMB->slice_currMBYpos))
                m_pContext->m_pSingleMB->slice_currMBYpos -= m_pContext->m_seqLayerHeader->heightMB/2;


            m_pContext->m_pBlock = task->m_pBlock;
            m_pContext->m_pPredBlock = task->m_pPredBlock;


            m_pContext->m_bitstream.pBitstream = task->m_pSlice->m_pstart;
            m_pContext->m_bitstream.bitOffset = task->m_pSlice->m_bitOffset;

            try
            {
                (this->*(task->pMulti))(m_pContext,task);

            task->m_pSlice->m_pstart = m_pContext->m_bitstream.pBitstream;
            task->m_pSlice->m_bitOffset = m_pContext->m_bitstream.bitOffset;
            task->m_pSlice->EscInfo = m_pContext->m_pSingleMB->EscInfo;
            m_pStore->AddPerfomedTask(task,pFrameDS);
            }
            catch (vc1_exception ex)
            {
                exception_type e_type = ex.get_exception_type();;
                if (e_type != vld)
                {
                    m_pStore->AddInvalidPerformedDS(pFrameDS);
                }
                else
                {
                    //VLD exception. FrameLevel
                    DecodeSkippicture(pFrameDS->m_pContext);
                    // need to stop all threads
                    m_pStore->AddPerformedDS(pFrameDS);
                }
            }


        }
    }
    return UMC_OK;

}



Status VC1TaskProcessor::processMainThread()
{
    VC1Task* task;
    VC1FrameDescriptor*    pFrameDS;
    //VC1TaskStore* pStore = VC1TaskStore::GetInstance(VC1Routine);
#ifdef  VC1_THREAD_STATISTIC
    task->pJob = this;
#endif

    // Routine task

    while (m_pStore->GetNextTaskMainThread(&pFrameDS,&task,m_iNumber))
    {
        if (task)
        {
            *m_pContext = *pFrameDS->m_pContext;
            m_pContext->m_pPredBlock = pFrameDS->getPredMem();//m_pStore->getMemForPred(m_iNumber,m_pContext);
            // we don't copy this field from pFrameDS
            m_pContext->m_pSingleMB =  m_pSingleMB;

            m_pContext->m_pSingleMB->currYPitch = m_pContext->m_frmBuff.m_pFrames[m_pContext->m_frmBuff.m_iCurrIndex].m_iYPitch;
            m_pContext->m_pSingleMB->currUPitch = m_pContext->m_frmBuff.m_pFrames[m_pContext->m_frmBuff.m_iCurrIndex].m_iUPitch;
            m_pContext->m_pSingleMB->currVPitch = m_pContext->m_frmBuff.m_pFrames[m_pContext->m_frmBuff.m_iCurrIndex].m_iVPitch;

            m_pContext->m_pSingleMB->currYPlane = m_pContext->m_frmBuff.m_pFrames[m_pContext->m_frmBuff.m_iCurrIndex].m_pY;
            m_pContext->m_pSingleMB->currUPlane = m_pContext->m_frmBuff.m_pFrames[m_pContext->m_frmBuff.m_iCurrIndex].m_pU;
            m_pContext->m_pSingleMB->currVPlane = m_pContext->m_frmBuff.m_pFrames[m_pContext->m_frmBuff.m_iCurrIndex].m_pV;


            m_pContext->interp_params_luma.roundControl = m_pContext->m_picLayerHeader->RNDCTRL;
            m_pContext->interp_params_chroma.roundControl = m_pContext->m_picLayerHeader->RNDCTRL;



            m_pContext->m_pCurrMB = &m_pContext->m_MBs[task->m_pSlice->MBStartRow*m_pContext->m_seqLayerHeader->widthMB];
            m_pContext->CurrDC = &m_pContext->DCACParams[task->m_pSlice->MBStartRow*m_pContext->m_seqLayerHeader->widthMB];
            m_pContext->m_pSingleMB->m_currMBXpos = 0;
            m_pContext->m_picLayerHeader = task->m_pSlice->m_picLayerHeader;
            m_pContext->m_pSingleMB->m_currMBYpos = task->m_pSlice->MBStartRow;//m_pCurrSlice->MBStartRow;
            m_pContext->m_pSingleMB->slice_currMBYpos = task->m_pSlice->MBStartRow;
            m_pContext->m_pSingleMB->EscInfo = task->m_pSlice->EscInfo;


            if ((m_pContext->m_picLayerHeader->CurrField)&&(m_pContext->m_pSingleMB->slice_currMBYpos))
                m_pContext->m_pSingleMB->slice_currMBYpos -= m_pContext->m_seqLayerHeader->heightMB/2;



            m_pContext->m_pBlock = task->m_pBlock;
            m_pContext->m_pPredBlock = task->m_pPredBlock;


            m_pContext->m_bitstream.pBitstream = task->m_pSlice->m_pstart;
            m_pContext->m_bitstream.bitOffset = task->m_pSlice->m_bitOffset;

            try
            {
                (this->*(task->pMulti))(m_pContext,task);

                task->m_pSlice->m_pstart = m_pContext->m_bitstream.pBitstream;
                task->m_pSlice->m_bitOffset = m_pContext->m_bitstream.bitOffset;
                task->m_pSlice->EscInfo = m_pContext->m_pSingleMB->EscInfo;
                m_pStore->AddPerfomedTask(task,pFrameDS);
            }
            catch (vc1_exception ex)
            {
                exception_type e_type = ex.get_exception_type();;
                if (e_type != vld)
                {
                    m_pStore->AddInvalidPerformedDS(pFrameDS);
                }
                else
                {
                    //VLD exception. FrameLevel
                    DecodeSkippicture(pFrameDS->m_pContext);
                    // need to stop all threads
                    m_pStore->AddPerformedDS(pFrameDS);
                }
            }
        }
    }
    return UMC_OK;
}
void VC1TaskProcessor::Release() // free mem
{

    if(m_pSingleMB)
    {
        ippsFree(m_pSingleMB );
        m_pSingleMB  = NULL;
    }
    if(m_pContext)
    {
        ippsFree(m_pContext);
        m_pContext = NULL;
    }

}
void VC1TaskProcessor::ProcessSmartException (SmartLevel exLevel, VC1Context* pContext, VC1Task* pTask, VC1MB* pCurrMB)
{
    if (VC1_IS_PRED(pContext->m_picLayerHeader->PTYPE))
    {
        if (exLevel == mbOneLevel)
        {

            // we should replace MB with reference
            pCurrMB->mbType = VC1_MB_1MV_INTER;
            pCurrMB->m_pBlocks[0].mv[0][0] = 0;
            pCurrMB->m_pBlocks[0].mv[0][1] = 0;
            pCurrMB->m_pBlocks[0].mv_bottom[0][0] = 0;
            pCurrMB->m_pBlocks[0].mv_bottom[0][1] = 0;
            pCurrMB->IntraFlag = 0;
        }
        else if (exLevel == mbGroupLevel)
        {
            VC1MB* pStartMB = &m_pContext->m_MBs[pTask->m_pSlice->MBStartRow*m_pContext->m_seqLayerHeader->widthMB];
            Ipp32u numOfMarkMB = pTask->m_pSlice->MBRowsToDecode*m_pContext->m_seqLayerHeader->widthMB;
            for (Ipp32u i = 0; i < numOfMarkMB; i++)
            {
                pStartMB->mbType = VC1_MB_1MV_INTER;
                pStartMB->m_pBlocks[0].mv[0][0] = 0;
                pStartMB->m_pBlocks[0].mv[0][1] = 0;
                pStartMB->m_pBlocks[0].mv_bottom[0][0] = 0;
                pStartMB->m_pBlocks[0].mv_bottom[0][1] = 0;
                pStartMB->IntraFlag = 0;
                ++pStartMB;
            }

        }
    }
}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -