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

📄 umc_h264_segment_decoder_deblocking_prepare.cpp

📁 audio-video-codecs.rar语音编解码器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            for (idx = 0;idx < 4;idx += 1)
            {
                Ipp32s blkQ, blkP;

                blkQ = EXTERNAL_BLOCK_MASK[dir][CURRENT_BLOCK][idx];
                blkP = EXTERNAL_BLOCK_MASK[dir][NEIGHBOUR_BLOCK][idx];

                // when one of couple of blocks has coeffs
                if ((cbp4x4_luma & blkQ) ||
                    (pNeighbour->cbp4x4_luma & blkP))
                {
                    pStrength[idx] = 2;
                    *pDeblockingFlag = 1;
                }
                // compare motion vectors & reference indexes
                else
                {
                    Ipp32s nBlock, nNeighbourBlock;
                    Ipp32s iRefQ, iRefP;
                    Ipp32s nVectorDiffLimit = pParams->nMaxMVector;

                    // calc block and neighbour block number
                    if (VERTICAL_DEBLOCKING == dir)
                    {
                        nBlock = idx * 4;
                        nNeighbourBlock = idx * 4 + 3;
                    }
                    else
                    {
                        nBlock = idx;
                        nNeighbourBlock = idx + 12;
                    }

                    // field coded image
                    if (FRM_STRUCTURE > m_pCurrentFrame->m_PictureStructureForDec)
                    {
                        H264DecoderFrame **pRefPicList;
                        Ipp32s index;
                        ReferenceFlags *pFields;

                        // select reference index for current block
                        index = m_gmbinfo->RefIdxs[0][MBAddr].RefIdxs[nBlock];
                        if (0 <= index)
                        {
                            pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 0)->m_RefPicList;
                            // select reference fields number array
                            pFields = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 0)->m_Flags;
                            iRefQ = pRefPicList[index]->DeblockPicID(pRefPicList[index]->GetNumberByParity(GetReferenceField(pFields, index)));
                        }
                        else
                            iRefQ = -1;

                        // select reference index for previous block
                        index = m_gmbinfo->RefIdxs[0][nNeighbour].RefIdxs[nNeighbourBlock];
                        if (0 <= index)
                        {
                            pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + nNeighbour)->slice_id, 0)->m_RefPicList;
                            // select reference fields number array
                            pFields = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + nNeighbour)->slice_id, 0)->m_Flags;
                            iRefP = pRefPicList[index]->DeblockPicID(pRefPicList[index]->GetNumberByParity(GetReferenceField(pFields, index)));
                        }
                        else
                            iRefP = -1;
                    }
                    // frame coded image
                    else
                    {
                        H264DecoderFrame **pRefPicList;
                        Ipp32s index;

                        // select reference index for current block
                        index = m_gmbinfo->RefIdxs[0][MBAddr].RefIdxs[nBlock];
                        if (0 <= index)
                        {
                            pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 0)->m_RefPicList;
                            iRefQ = pRefPicList[index]->DeblockPicID(0);
                        }
                        else
                            iRefQ = -1;

                        // select reference index for previous block
                        index = m_gmbinfo->RefIdxs[0][nNeighbour].RefIdxs[nNeighbourBlock];
                        if (0 <= index)
                        {
                            pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + nNeighbour)->slice_id, 0)->m_RefPicList;
                            iRefP = pRefPicList[index]->DeblockPicID(0);
                        }
                        else
                            iRefP = -1;
                    }

                    VM_ASSERT((iRefP != -1) || (iRefQ != -1));

                    // when reference indexes are equal
                    if (iRefQ == iRefP)
                    {
                        H264DecoderMotionVector *pVectorQ, *pVectorP;

                        pVectorQ = m_gmbinfo->MV[0][MBAddr].MotionVectors + nBlock;
                        pVectorP = m_gmbinfo->MV[0][nNeighbour].MotionVectors + nNeighbourBlock;

                        // compare motion vectors
                        if ((4 <= abs(pVectorQ->mvx - pVectorP->mvx)) ||
                            (nVectorDiffLimit <= abs(pVectorQ->mvy - pVectorP->mvy)))
                        {
                            pStrength[idx] = 1;
                            *pDeblockingFlag = 1;
                        }
                        else
                            pStrength[idx] = 0;
                    }
                    // when reference indexes are different
                    else
                    {
                        pStrength[idx] = 1;
                        *pDeblockingFlag = 1;
                    }
                }
            }
        }
        // external edge required in strong filtering
        else
        {
            if ((HORIZONTAL_DEBLOCKING == dir) &&
                (pParams->MBFieldCoded))
                SetEdgeStrength(pStrength + 0, 3);
            else
                SetEdgeStrength(pStrength + 0, 4);
            *pDeblockingFlag = 1;
        }
    }

    //
    // internal edge(s)
    //
    {
        Ipp32s idx;

        // cicle of edge(s)
        // we do all edges in one cicle
        for (idx = 4;idx < 16;idx += 1)
        {
            Ipp32s blkQ;

            blkQ = INTERNAL_BLOCKS_MASK[dir][idx - 4];

            if (cbp4x4_luma & blkQ)
            {
                pStrength[idx] = 2;
                *pDeblockingFlag = 1;
            }
            // compare motion vectors & reference indexes
            else
            {
                Ipp32s nBlock, nNeighbourBlock;
                Ipp32s iRefQ, iRefP;
                Ipp32s nVectorDiffLimit = pParams->nMaxMVector;

                // calc block and neighbour block number
                if (VERTICAL_DEBLOCKING == dir)
                {
                    nBlock = (idx & 3) * 4 + (idx >> 2);
                    nNeighbourBlock = nBlock - 1;
                }
                else
                {
                    nBlock = idx;
                    nNeighbourBlock = idx - 4;
                }

                VM_ASSERT(-1 == m_gmbinfo->RefIdxs[1][MBAddr].RefIdxs[nBlock]);
                VM_ASSERT(-1 == m_gmbinfo->RefIdxs[1][MBAddr].RefIdxs[nNeighbourBlock]);

                // field coded image
                if (FRM_STRUCTURE > m_pCurrentFrame->m_PictureStructureForDec)
                {
                    H264DecoderFrame **pRefPicList;
                    Ipp32s index;
                    ReferenceFlags *pFields;

                    pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 0)->m_RefPicList;

                    // select reference fields number array
                    pFields = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 0)->m_Flags;

                    // select reference field for current block
                    index = m_gmbinfo->RefIdxs[0][MBAddr].RefIdxs[nBlock];
                    iRefQ = (index < 0) ?
                            (-1) :
                            pRefPicList[index]->DeblockPicID(pRefPicList[index]->GetNumberByParity(GetReferenceField(pFields, index)));

                    // select reference field for previous block
                    index = m_gmbinfo->RefIdxs[0][MBAddr].RefIdxs[nNeighbourBlock];
                    iRefP = (index < 0) ?
                            (-1) :
                            pRefPicList[index]->DeblockPicID(pRefPicList[index]->GetNumberByParity(GetReferenceField(pFields, index)));
                }
                // frame coded image
                else
                {
                    H264DecoderFrame **pRefPicList;
                    Ipp32s index;

                    pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 0)->m_RefPicList;

                    // select reference index for current block
                    index = m_gmbinfo->RefIdxs[0][MBAddr].RefIdxs[nBlock];
                    iRefQ = (index < 0) ?
                            (-1) :
                            (pRefPicList[index]->DeblockPicID(0));

                    // select reference index for previous block
                    index = m_gmbinfo->RefIdxs[0][MBAddr].RefIdxs[nNeighbourBlock];
                    iRefP = (index < 0) ?
                            (-1) :
                            pRefPicList[index]->DeblockPicID(0);
                }

                VM_ASSERT((iRefP != -1) || (iRefQ != -1));

                // when reference indexes are equal
                if (iRefQ == iRefP)
                {
                    H264DecoderMotionVector *pVectorQ, *pVectorP;

                    pVectorQ = m_gmbinfo->MV[0][MBAddr].MotionVectors + nBlock;
                    pVectorP = m_gmbinfo->MV[0][MBAddr].MotionVectors + nNeighbourBlock;

                    // compare motion vectors
                    if ((4 <= abs(pVectorQ->mvx - pVectorP->mvx)) ||
                        (nVectorDiffLimit <= abs(pVectorQ->mvy - pVectorP->mvy)))
                    {
                        pStrength[idx] = 1;
                        *pDeblockingFlag = 1;
                    }
                    else
                        pStrength[idx] = 0;
                }
                // when reference indexes are different
                else
                {
                    pStrength[idx] = 1;
                    *pDeblockingFlag = 1;
                }
            }
        }
    }

} // void H264SegmentDecoder::PrepareDeblockingParametersPSlice4(Ipp32u dir, DeblockingParameters *pParams)

#define SET_DEBLOCKING_STRENGTH_P_SLICE_VERTICAL(block_num0, block_num1) \
{ \
    Ipp32s refPrev = GetReferencePSlice(nNeighbour, block_num0 * 4 + 3); \
    if (refCur == refPrev) \
    { \
        if (0 == (VERTICAL_OUTER_EDGE_BLOCK_##block_num0 & uMask)) \
        { \
            if (IsVectorDifferenceBig(mvCur, pMVPrev[block_num0 * 4 + 3], pParams->nMaxMVector)) \
            { \
                pStrength[block_num0] = 1; \
                iDeblockingFlag = 1; \
            } \
            else \
                pStrength[block_num0] = 0; \
        } \
        else \
        { \
            pStrength[block_num0] = 2; \
            iDeblockingFlag = 1; \
        } \
        if (0 == (VERTICAL_OUTER_EDGE_BLOCK_##block_num1 & uMask)) \
        { \
            if (IsVectorDifferenceBig(mvCur, pMVPrev[block_num1 * 4 + 3], pParams->nMaxMVector)) \
            { \
                pStrength[block_num1] = 1; \
                iDeblockingFlag = 1; \
            } \
            else \
                pStrength[block_num1] = 0; \
        } \
        else \
        { \
            pStrength[block_num1] = 2; \
            iDeblockingFlag = 1; \
        } \
    } \
    else \
    { \
        pStrength[block_num0] = (Ipp8u) (1 + ((VERTICAL_OUTER_EDGE_BLOCK_##block_num0 & uMask) ? (1) : (0))); \
        pStrength[block_num1] = (Ipp8u) (1 + ((VERTICAL_OUTER_EDGE_BLOCK_##block_num1 & uMask) ? (1) : (0))); \
        iDeblockingFlag = 1; \
    } \
}

#define SET_DEBLOCKING_STRENGTH_P_SLICE_HORIZONTAL(block_num0, block_num1) \
{ \
    Ipp32s refPrev = GetReferencePSlice(nNeighbour, block_num0 + 12); \
    if (refCur == refPrev) \
    { \
        if (0 == (HORIZONTAL_OUTER_EDGE_BLOCK_##block_num0 & uMask)) \
        { \
            if (IsVectorDifferenceBig(mvCur, pMVPrev[block_num0 + 12], pParams->nMaxMVector)) \
            { \
                pStrength[block_num0] = 1; \
                iDeblockingFlag = 1; \
            } \
            else \
                pStrength[block_num0] = 0; \
        } \
        else \
        { \
            pStrength[block_num0] = 2; \
            iDeblockingFlag = 1; \
        } \
        if (0 == (HORIZONTAL_OUTER_EDGE_BLOCK_##block_num1 & uMask)) \
        { \
            if (IsVectorDifferenceBig(mvCur, pMVPrev[block_num1 + 12], pParams->nMaxMVector)) \
            { \
                pStrength[block_num1] = 1; \
                iDeblockingFlag = 1; \
            } \

⌨️ 快捷键说明

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