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

📄 umc_vc1_dec_task_store.cpp

📁 audio-video-codecs.rar语音编解码器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            else
                return false;
        }
        *pTask = NULL;
        return true;
    }

    bool VC1TaskStore::GetNextTaskManyCPU_HD(VC1FrameDescriptor **pFrameDS, VC1Task** pTask, Ipp32u qID)
    {
        STATISTICS_START_TIME(m_timeStatistics->GetNextTask_StartTime);

        Ipp32u StartFrame = (m_iConsumerNumber <= 2)?0:1;
        Ipp32s frameCount = m_pPrefDS->m_iSelfID;


        Ipp32u i =0;
        // Get Task from First frame in Queue
        if (((qID<(m_iConsumerNumber>>1)))||(m_iConsumerNumber <= 2))
        {
                AutomaticMutex guard(*m_pGuardGet[frameCount]);
                if (m_pDescriptorQueue[frameCount]->m_bIsReadyToProcess)
                {
                    *pFrameDS = m_pDescriptorQueue[frameCount];
                    // find in main queue
                    for (i =0; i < m_pTasksInQueue[frameCount];i++ )
                    {
                        if (((*m_pCommonQueue[frameCount])[i]->m_bDone == false) &&
                            ((*m_pCommonQueue[frameCount])[i]->m_bInProgress == false)&&
                            ((*m_pCommonQueue[frameCount])[i]->m_bIsReady == true) )
                        {
                            *pTask = (*m_pCommonQueue[frameCount])[i];
                            (*m_pCommonQueue[frameCount])[i]->m_bInProgress = true;
                            (*m_pCommonQueue[frameCount])[i]->m_bIsReady = true;

STATISTIC_PARAL_ENTRY(pTask,pTask->m_eTasktype,VC1GetTask);
STATISTICS_END_TIME(m_timeStatistics->GetNextTask_StartTime,
                    m_timeStatistics->GetNextTask_EndTime,
                    m_timeStatistics->GetNextTask_TotalTime);
                            return true;

                        }
                    else
                        if (((*m_pAdditionalQueue[frameCount])[i]->m_bDone == false) &&
                            ((*m_pAdditionalQueue[frameCount])[i]->m_bInProgress == false)&&
                            ((*m_pAdditionalQueue[frameCount])[i]->m_bIsReady == true) )
                        {
                                *pTask = (*m_pAdditionalQueue[frameCount])[i];
                                (*m_pAdditionalQueue[frameCount])[i]->m_bInProgress = true;
                                (*m_pAdditionalQueue[frameCount])[i]->m_bIsReady = true;

STATISTIC_PARAL_ENTRY(pTask,pTask->m_eTasktype,VC1AddPerfomrd);
STATISTICS_END_TIME(m_timeStatistics->GetNextTask_StartTime,
                    m_timeStatistics->GetNextTask_EndTime,
                    m_timeStatistics->GetNextTask_TotalTime);
                            return true;
                        }
                    }


                    for (i =0; i < m_pTasksInQueue[frameCount];i++ )
                    {
                        if (((*m_pCommonQueue[frameCount])[i]->m_bDone == false)||
                            ((*m_pAdditionalQueue[frameCount])[i]->m_bDone == false) )
                            break;
                    }
                    if ((i == m_pTasksInQueue[frameCount])&&
                        (i>0) ) // to check skip frames
                    {
                        m_pDescriptorQueue[frameCount]->m_bIsReadyToProcess = false;
                        m_pDescriptorQueue[frameCount]->m_bIsReadyToDisplay = true;
                        *pTask = NULL;
STATISTICS_END_TIME(m_timeStatistics->GetNextTask_StartTime,
                    m_timeStatistics->GetNextTask_EndTime,
                    m_timeStatistics->GetNextTask_TotalTime);
                        return true;
                    }
                }
                guard.Unlock();
        }

        Ipp32u curFrame = qID;
        for (Ipp32u count = StartFrame; count < m_iNumFramesProcessing; count++) // for 2-core CPU
        {
            frameCount = m_pDSIndicate[count];
STATISTICS_START_TIME(m_timeStatistics->GetNextTask_StartTime);
            //if (curPriority == m_pDescriptorQueue[frameCount]->m_iPriority)
            {
            AutomaticMutex guard(*m_pGuardGet[frameCount]);

            //find in own queue
            if (m_pDescriptorQueue[frameCount]->m_bIsReadyToProcess)
            {
                *pFrameDS = m_pDescriptorQueue[frameCount];
                // find in main queue
                for (i =0; i < m_pTasksInQueue[frameCount];i++ )
                {
                    if (((*m_pCommonQueue[frameCount])[i]->m_bDone == false) &&
                        ((*m_pCommonQueue[frameCount])[i]->m_bInProgress == false)&&
                        ((*m_pCommonQueue[frameCount])[i]->m_bIsReady == true) )
                    {
                        *pTask = (*m_pCommonQueue[frameCount])[i];
                        (*m_pCommonQueue[frameCount])[i]->m_bInProgress = true;
                        (*m_pCommonQueue[frameCount])[i]->m_bIsReady = true;

 STATISTIC_PARAL_ENTRY(pTask,pTask->m_eTasktype,VC1GetTask);
STATISTICS_END_TIME(m_timeStatistics->GetNextTask_StartTime,
                    m_timeStatistics->GetNextTask_EndTime,
                    m_timeStatistics->GetNextTask_TotalTime);
                            return true;
                    } else
                    if (((*m_pAdditionalQueue[frameCount])[i]->m_bDone == false) &&
                        ((*m_pAdditionalQueue[frameCount])[i]->m_bInProgress == false)&&
                        ((*m_pAdditionalQueue[frameCount])[i]->m_bIsReady == true) )
                    {
                                *pTask = (*m_pAdditionalQueue[frameCount])[i];
                                (*m_pAdditionalQueue[frameCount])[i]->m_bInProgress = true;
                                (*m_pAdditionalQueue[frameCount])[i]->m_bIsReady = true;

STATISTIC_PARAL_ENTRY(pTask,pTask->m_eTasktype,VC1AddPerfomrd);
STATISTICS_END_TIME(m_timeStatistics->GetNextTask_StartTime,
                    m_timeStatistics->GetNextTask_EndTime,
                    m_timeStatistics->GetNextTask_TotalTime);
                        return true;
                        }
                    }
                for (i =0; i < m_pTasksInQueue[frameCount];i++ )
                {
                    if (((*m_pCommonQueue[frameCount])[i]->m_bDone == false)||
                        ((*m_pAdditionalQueue[frameCount])[i]->m_bDone == false) )
                        break;
                }
                if ((i == m_pTasksInQueue[frameCount])&&
                    (i>0) ) // to check skip frames
                {
                    m_pDescriptorQueue[frameCount]->m_bIsReadyToProcess = false;
                    m_pDescriptorQueue[frameCount]->m_bIsReadyToDisplay = true;
                    *pTask = NULL;
                    return true;
                }
            }
            guard.Unlock();
            }
            ++curFrame;
            if (curFrame > m_iNumFramesProcessing)
                curFrame = 0;

        }
        STATISTICS_END_TIME(m_timeStatistics->GetNextTask_StartTime,
                            m_timeStatistics->GetNextTask_EndTime,
                            m_timeStatistics->GetNextTask_TotalTime);

        //return false;
        if (0 != qID) // main thread should check ready FrameDS permanentley
        {
            if (m_bIsNeedToDecode)
            {
                m_eWaiting[qID]->Reset(); //!!!!!!
                m_eWaiting[qID]->Wait();
                *pTask = NULL;
                return true;
            }
            else
                return false;
        }
        *pTask = NULL;
        return true;
    }
    bool VC1TaskStore::GetNextTaskManyCPU_MD(VC1FrameDescriptor **pFrameDS, VC1Task** pTask, Ipp32u qID)
    {
        //same pipeline as for Dual case
        return GetNextTaskDualCPU(pFrameDS,pTask,qID);

    }
    bool VC1TaskStore::GetNextTaskMainThread(VC1FrameDescriptor **pFrameDS, VC1Task** pTask, Ipp32u qID)
    {
        if (IsPerfomedDS())
            return false;
        if(!GetNextTask(pFrameDS,pTask,qID))
            (*pTask)->m_bInProgress = false;
        return true;
    }
bool VC1TaskStore::AddPerfomedTask(VC1Task* pTask, VC1FrameDescriptor *pFrameDS)
    {
STATISTICS_START_TIME(m_timeStatistics->AddPerfomed_StartTime);
         Ipp32u qID = pFrameDS->m_iSelfID;
        //AutomaticMutex guard(*m_pGuardGet[qID]);

        // check error(s)
        if ((NULL == pTask) || (0 >= m_pTasksInQueue[qID])) //!!!!!!!!!!
            return false;
        VC1TaskTypes NextStateTypeofTask;
        Ipp32u i = pTask->m_iTaskID;

        if (pTask->m_eTasktype <= VC1Reconstruct)
        {

                    //AutomaticMutex guard(*m_pGuardGet[qID]);
                    AutomaticMutex guard(*m_pGuardGet[qID]);
                    NextStateTypeofTask = (*m_pCommonQueue[qID])[i]->switch_task();
                    switch (NextStateTypeofTask)
                    {
                    case VC1Reconstruct:
                        (*m_pCommonQueue[qID])[i]->m_bIsReady = true;
                        if ((i+1) < m_pTasksInQueue[qID])
                        {
                            if (!(*m_pCommonQueue[qID])[i+1]->m_pSlice->is_NewInSlice)
                            {
                                VM_ASSERT(!(*m_pCommonQueue[qID])[i+1]->m_bInProgress);
                                (*m_pCommonQueue[qID])[i+1]->m_pSlice->m_pstart = pTask->m_pSlice->m_pstart;
                                (*m_pCommonQueue[qID])[i+1]->m_pSlice->m_bitOffset = pTask->m_pSlice->m_bitOffset;
                                (*m_pCommonQueue[qID])[i+1]->m_pSlice->EscInfo = pTask->m_pSlice->EscInfo;
                                (*m_pCommonQueue[qID])[i+1]->m_bIsReady = true;
                            }
                        }
                        VM_ASSERT(!(*m_pAdditionalQueue[qID])[i]->m_bInProgress);
                        VM_ASSERT((*m_pAdditionalQueue[qID])[i]->m_eTasktype == VC1MC);

                        if ((m_pDescriptorQueue[qID]->m_bIsReferenceReady)&&
                            ((*m_pAdditionalQueue[qID])[i]->m_isFieldReady))
                        {
                            switch((*m_pAdditionalQueue[qID])[i]->m_pSlice->m_picLayerHeader->PTYPE)
                            {
                            case VC1_P_FRAME:
                                (*m_pAdditionalQueue[qID])[i]->m_bIsReady = true;
                                break;
                            case VC1_B_FRAME:
                                if (i > 0)
                                {
                                    if (((*m_pAdditionalQueue[qID])[i]->m_pSlice->is_NewInSlice)||
                                        ((*m_pAdditionalQueue[qID])[i-1]->m_eTasktype > VC1MVCalculate ))
                                        (*m_pAdditionalQueue[qID])[i]->m_bIsReady = true;
                                }
                                else
                                    (*m_pAdditionalQueue[qID])[i]->m_bIsReady = true;
                                break;
                            default:
                                break;
                            }
                        }
                        break;
                    case VC1Complete:
                        if ((*m_pAdditionalQueue[qID])[i]->m_eTasktype == VC1PreparePlane)
                        {
                            (*m_pAdditionalQueue[qID])[i]->m_pBlock = (*m_pCommonQueue[qID])[i]->m_pBlock;
                            if (i>0)
                            {
                                if (((*m_pAdditionalQueue[qID])[i-1]->m_eTasktype > VC1PreparePlane)||
                                    ((*m_pCommonQueue[qID])[i]->m_pSlice->is_NewInSlice))
                                    (*m_pAdditionalQueue[qID])[i]->m_bIsReady = true;
                            }
                            else
                                (*m_pAdditionalQueue[qID])[i]->m_bIsReady = true;

                        }
                        (*m_pCommonQueue[qID])[i]->m_bDone = true;
                        //printf("finish %d task \n", i);
                        break;
                    default:
                        VM_ASSERT(0);

                    }
                    //printf("complete %d task \n", i);
STATISTIC_PARAL_ENTRY(pTask,pTask->m_eTasktype,VC1AddPerfomrd);

                    (*m_pCommonQueue[qID])[i]->m_bInProgress = false;

STATISTICS_END_TIME(m_timeStatistics->AddPerfomed_StartTime,
                    m_timeStatistics->AddPerfomed_EndTime,
                    m_timeStatistics->AddPerfomed_TotalTime);
                    guard.Unlock();
                    WakeUP();
                    //pMainVC1Decoder->StartAllThreadDecoders();
                    return true;
        }
        else
        {
                    AutomaticMutex guard(*m_pGuardGet[qID]);
                    NextStateTypeofTask = (*m_pAdditionalQueue[qID])[i]->switch_task();
                    switch (NextStateTypeofTask)
                    {
                    case VC1MC:
                        (*m_pAdditionalQueue[qID])[i]->m_bIsReady = true;
                        if ((i+1) < m_pTasksInQueue[qID])
                        {
                            if ( ((*m_pCommonQueue[qID])[i+1]->m_eTasktype > VC1Decode)&&
                                 (!(*m_pCommonQueue[qID])[i+1]->m_pSlice->is_NewInSlice)&&
                                ((*m_pAdditionalQueue[qID])[i+1]->m_isFieldReady))
                               (*m_pAdditionalQueue[qID])[i+1]->m_bIsReady = true;
                        }

⌨️ 快捷键说明

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