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

📄 umc_h264_segment_decoder_mt.cpp

📁 audio-video-codecs.rar语音编解码器
💻 CPP
📖 第 1 页 / 共 5 页
字号:

    Ipp32s type = m_cur_mb.GlobalMacroblockInfo->mbtype - MBTYPE_FORWARD;
    if(type >= 0)
    {
        if (m_cur_mb.LocalMacroblockInfo->sbdir[0] > D_DIR_BIDIR) // direct or skip MB
        {
            memset(m_cur_mb.MVs[LIST_0 + MV_DELTAS_OFFSET], 0, sizeof(H264DecoderMacroblockMVs));
            memset(m_cur_mb.MVs[LIST_1 + MV_DELTAS_OFFSET], 0, sizeof(H264DecoderMacroblockMVs));
            return;
        }

        // get all ref_idx_L0
        GetRefIdx4x4_CABAC(
                    m_pSliceHeader->num_ref_idx_l0_active<<curmb_fdf,
                    pCodFBD[type][0],
                    0);
        // get all ref_idx_L1
        GetRefIdx4x4_CABAC(
                    m_pSliceHeader->num_ref_idx_l1_active<<curmb_fdf,
                    pCodFBD[type][1],
                    1);
        // get all mvd_L0
        GetMVD4x4_CABAC(
                    pCodFBD[type][2],
                    0);
        // get all mvd_L1
        GetMVD4x4_CABAC(
                    pCodFBD[type][3],
                    1);
    }
    else
    {
        Ipp32u i, j;
        const Ipp8u *pRIxL0, *pRIxL1, *pMVdL0, *pMVdL1;

#ifdef __ICL
        __declspec(align(16))Ipp8u pCodRIxL0[16];
        __declspec(align(16))Ipp8u pCodRIxL1[16];
        __declspec(align(16))Ipp8u pCodMVdL0[16];
        __declspec(align(16))Ipp8u pCodMVdL1[16];
#else
        Ipp8u pCodRIxL0[16];
        Ipp8u pCodRIxL1[16];
        Ipp8u pCodMVdL0[16];
        Ipp8u pCodMVdL1[16];
#endif
        pRIxL0 = pCodRIxL0;
        pRIxL1 = pCodRIxL1;
        pMVdL0 = pCodMVdL0;
        pMVdL1 = pCodMVdL1;

        Ipp8u cL0;
        Ipp8u cL1;
        switch (m_cur_mb.GlobalMacroblockInfo->mbtype)
        {
        case MBTYPE_INTER_16x8:
                cL0 = (m_cur_mb.LocalMacroblockInfo->sbdir[0] == D_DIR_BWD) ? CodNone : CodInBS;
                cL1 = (m_cur_mb.LocalMacroblockInfo->sbdir[0] == D_DIR_FWD) ? CodNone : CodInBS;
                pCodRIxL0[0] = cL0;
                pCodRIxL1[0] = cL1;
                cL0 = (m_cur_mb.LocalMacroblockInfo->sbdir[1] == D_DIR_BWD) ? CodNone : CodInBS;
                cL1 = (m_cur_mb.LocalMacroblockInfo->sbdir[1] == D_DIR_FWD) ? CodNone : CodInBS;
                pCodRIxL0[8] = cL0;
                pCodRIxL1[8] = cL1;

                // get all ref_idx_L0
                GetRefIdx4x4_16x8_CABAC(
                            m_pSliceHeader->num_ref_idx_l0_active<<curmb_fdf,
                            pRIxL0,
                            0);

                // get all ref_idx_L1
                GetRefIdx4x4_16x8_CABAC(
                            m_pSliceHeader->num_ref_idx_l1_active<<curmb_fdf,
                            pRIxL1,
                            1);

                // get all mvd_L0
                GetMVD4x4_16x8_CABAC(
                            pRIxL0,
                            0);

                // get all mvd_L1
                GetMVD4x4_16x8_CABAC(
                            pRIxL1,
                            1);
                break;
            case MBTYPE_INTER_8x16:
                cL0 = (m_cur_mb.LocalMacroblockInfo->sbdir[0] == D_DIR_BWD) ? CodNone : CodInBS;
                cL1 = (m_cur_mb.LocalMacroblockInfo->sbdir[0] == D_DIR_FWD) ? CodNone : CodInBS;
                pCodRIxL0[0] = cL0;
                pCodRIxL1[0] = cL1;
                cL0 = (m_cur_mb.LocalMacroblockInfo->sbdir[1] == D_DIR_BWD) ? CodNone : CodInBS;
                cL1 = (m_cur_mb.LocalMacroblockInfo->sbdir[1] == D_DIR_FWD) ? CodNone : CodInBS;
                pCodRIxL0[2] = cL0;
                pCodRIxL1[2] = cL1;

                GetRefIdx4x4_8x16_CABAC(
                            m_pSliceHeader->num_ref_idx_l0_active<<curmb_fdf,
                            pRIxL0,
                            0);

                // get all ref_idx_L1
                GetRefIdx4x4_8x16_CABAC(
                            m_pSliceHeader->num_ref_idx_l1_active<<curmb_fdf,
                            pRIxL1,
                            1);

                // get all mvd_L0
                GetMVD4x4_8x16_CABAC(
                            pRIxL0,
                            0);

                // get all mvd_L1
                GetMVD4x4_8x16_CABAC(
                            pRIxL1,
                            1);
                break;
            case MBTYPE_INTER_8x8:
            case MBTYPE_INTER_8x8_REF0:
                memcpy(pCodRIxL0, pCodTemplate, sizeof(pCodTemplate[0])*16);
                memcpy(pCodRIxL1, pCodTemplate, sizeof(pCodTemplate[0])*16);
                memcpy(pCodMVdL0, pCodTemplate, sizeof(pCodTemplate[0])*16);
                memcpy(pCodMVdL1, pCodTemplate, sizeof(pCodTemplate[0])*16);
                {
                for (i = 0; i < 4; i ++)
                {
                    j = subblock_block_mapping[i];

                    if (m_cur_mb.LocalMacroblockInfo->sbdir[i] > D_DIR_BIDIR)
                    {
                        cL0 = (m_cur_mb.LocalMacroblockInfo->sbdir[i] == D_DIR_DIRECT_SPATIAL_BWD) ? CodNone : CodSkip;
                        cL1 = (m_cur_mb.LocalMacroblockInfo->sbdir[i] == D_DIR_DIRECT_SPATIAL_FWD) ? CodNone : CodSkip;
                        pCodRIxL0[j] = pCodRIxL0[j + 1] = pCodRIxL0[j + 4] = pCodRIxL0[j + 5] = cL0;
                        pCodRIxL1[j] = pCodRIxL1[j + 1] = pCodRIxL1[j + 4] = pCodRIxL1[j + 5] = cL1;
                        pCodMVdL0[j] = pCodMVdL0[j + 1] = pCodMVdL0[j + 4] = pCodMVdL0[j + 5] = cL0;
                        pCodMVdL1[j] = pCodMVdL1[j + 1] = pCodMVdL1[j + 4] = pCodMVdL1[j + 5] = cL1;
                        continue;
                    }

                    switch (m_cur_mb.GlobalMacroblockInfo->sbtype[i])
                    {
                    case SBTYPE_8x8:
                        cL0 = (m_cur_mb.LocalMacroblockInfo->sbdir[i] == D_DIR_BWD) ? CodNone : CodInBS;
                        cL1 = (m_cur_mb.LocalMacroblockInfo->sbdir[i] == D_DIR_FWD) ? CodNone : CodInBS;
                        pCodRIxL0[j] = cL0;
                        pCodRIxL1[j] = cL1;
                        pCodMVdL0[j] = cL0;
                        pCodMVdL1[j] = cL1;
                        pCodRIxL0[j + 4] = CodAbov;
                        pCodRIxL1[j + 4] = CodAbov;
                        pCodMVdL0[j + 4] = CodAbov;
                        pCodMVdL1[j + 4] = CodAbov;
                        break;
                    case SBTYPE_8x4:
                        cL0 = (m_cur_mb.LocalMacroblockInfo->sbdir[i] == D_DIR_BWD) ? CodNone : CodInBS;
                        cL1 = (m_cur_mb.LocalMacroblockInfo->sbdir[i] == D_DIR_FWD) ? CodNone : CodInBS;
                        pCodRIxL0[j] = cL0;
                        pCodRIxL1[j] = cL1;
                        pCodMVdL0[j] = cL0;
                        pCodMVdL1[j] = cL1;
                        pCodRIxL0[j + 4] = CodAbov;
                        pCodRIxL1[j + 4] = CodAbov;
                        pCodMVdL0[j + 4] = cL0;
                        pCodMVdL1[j + 4] = cL1;
                        break;
                    case SBTYPE_4x8:
                        cL0 = (m_cur_mb.LocalMacroblockInfo->sbdir[i] == D_DIR_BWD) ? CodNone : CodInBS;
                        cL1 = (m_cur_mb.LocalMacroblockInfo->sbdir[i] == D_DIR_FWD) ? CodNone : CodInBS;
                        pCodRIxL0[j] = cL0;
                        pCodRIxL1[j] = cL1;
                        pCodMVdL0[j] = cL0;
                        pCodMVdL1[j] = cL1;
                        pCodMVdL0[j + 1] = cL0;
                        pCodMVdL1[j + 1] = cL1;
                        pCodRIxL0[j + 4] = CodAbov;
                        pCodRIxL1[j + 4] = CodAbov;
                        pCodMVdL0[j + 4] = pCodMVdL0[j + 5] = CodAbov;
                        pCodMVdL1[j + 4] = pCodMVdL1[j + 5] = CodAbov;
                        break;
                    case SBTYPE_4x4:
                        cL0 = (m_cur_mb.LocalMacroblockInfo->sbdir[i] == D_DIR_BWD) ? CodNone : CodInBS;
                        cL1 = (m_cur_mb.LocalMacroblockInfo->sbdir[i] == D_DIR_FWD) ? CodNone : CodInBS;
                        pCodRIxL0[j] = cL0;
                        pCodRIxL1[j] = cL1;
                        pCodRIxL0[j + 4] = CodAbov;
                        pCodRIxL1[j + 4] = CodAbov;
                        pCodMVdL0[j] = pCodMVdL0[j + 1] = pCodMVdL0[j + 4] = pCodMVdL0[j + 5] = cL0;
                        pCodMVdL1[j] = pCodMVdL1[j + 1] = pCodMVdL1[j + 4] = pCodMVdL1[j + 5] = cL1;
                        break;
                    case SBTYPE_DIRECT:
                        cL0 = (m_cur_mb.LocalMacroblockInfo->sbdir[i] == D_DIR_DIRECT_SPATIAL_BWD) ? CodNone : CodSkip;
                        cL1 = (m_cur_mb.LocalMacroblockInfo->sbdir[i] == D_DIR_DIRECT_SPATIAL_FWD) ? CodNone : CodSkip;
                        pCodRIxL0[j] = pCodRIxL0[j + 1] = pCodRIxL0[j + 4] = pCodRIxL0[j + 5] = cL0;
                        pCodRIxL1[j] = pCodRIxL1[j + 1] = pCodRIxL1[j + 4] = pCodRIxL1[j + 5] = cL1;
                        pCodMVdL0[j] = pCodMVdL0[j + 1] = pCodMVdL0[j + 4] = pCodMVdL0[j + 5] = cL0;
                        pCodMVdL1[j] = pCodMVdL1[j + 1] = pCodMVdL1[j + 4] = pCodMVdL1[j + 5] = cL1;
                        break;
                    default:
                        throw h264_exception(UMC_ERR_INVALID_STREAM);
                    }
                }
                // get all ref_idx_L0
                GetRefIdx4x4_CABAC(
                            m_pSliceHeader->num_ref_idx_l0_active<<curmb_fdf,
                            BlkOrder,
                            pRIxL0,
                            0);

                // get all ref_idx_L1
                GetRefIdx4x4_CABAC(
                            m_pSliceHeader->num_ref_idx_l1_active<<curmb_fdf,
                            BlkOrder,
                            pRIxL1,
                            1);

                // get all mvd_L0
                GetMVD4x4_CABAC(
                            BlkOrder,
                            pMVdL0,
                            0);

                // get all mvd_L1
                GetMVD4x4_CABAC(
                            BlkOrder,
                            pMVdL1,
                            1);
                break;
                }
            default:
                throw h264_exception(UMC_ERR_INVALID_STREAM);
        }    // switch

    }

    ReconstructMotionVectors();

} // void H264SegmentDecoderMultiThreaded::DecodeMotionVectors_CABAC(void)

#define RECONSTRUCT_MOTION_VECTORS(sub_block_num, vector_offset, position) \
    switch (pSBDir[sub_block_num]) \
    { \
    case D_DIR_FWD: \
        ReconstructMVs##position(0); \
        ResetMVs8x8(1, vector_offset); \
        break; \
    case D_DIR_BIDIR: \
        ReconstructMVs##position(0); \
        ReconstructMVs##position(1); \
        break; \
    case D_DIR_BWD: \
        ResetMVs8x8(0, vector_offset); \
        ReconstructMVs##position(1); \
        break; \
    case D_DIR_DIRECT_SPATIAL_FWD: \
        ResetMVs8x8(1, vector_offset); \
        break; \
    case D_DIR_DIRECT_SPATIAL_BWD: \
        ResetMVs8x8(0, vector_offset); \
        break; \
    default: \
        break; \
    }

void H264SegmentDecoderMultiThreaded::ReconstructMotionVectors(void)
{
    /* DEBUG : temporary put off MBAFF */
    if (0 == m_pSliceHeader->MbaffFrameFlag)
    {
        switch (m_cur_mb.GlobalMacroblockInfo->mbtype)
        {
            // forward predicted macroblock
        case MBTYPE_FORWARD:
            if (m_cur_mb.LocalMacroblockInfo->sbdir[0] <= D_DIR_BIDIR)
            {
                // set forward vectors
                ReconstructMVs16x16(0);

                // set backward vectors
                ResetMVs16x16(1);
            }
            break;

            // backward predicted macroblock
        case MBTYPE_BACKWARD:
            if (m_cur_mb.LocalMacroblockInfo->sbdir[0] <= D_DIR_BIDIR)
            {
                // set forward vectors
                ResetMVs16x16(0);

                // set backward vectors
                ReconstructMVs16x16(1);
            }
            break;

            // bi-directional predicted macroblock
        case MBTYPE_BIDIR:
            if (m_cur_mb.LocalMacroblockInfo->sbdir[0] <= D_DIR_BIDIR)
            {
                // set forward vectors
                ReconstructMVs16x16(0);

                // set backward vectors
                ReconstructMVs16x16(1);
            }
            break;

        case MBTYPE_INTER_16x8:
            {
                // set forward vectors for the first sub-block
                if (m_cur_mb.LocalMacroblockInfo->sbdir[0] == D_DIR_BWD)
                    ResetMVs16x8(0, 0);
                else
                    ReconstructMVs16x8(0, 0);

                // set backward vectors for the first sub-block
                if (m_cur_mb.LocalMacroblockInfo->sbdir[0] == D_DIR_FWD)
                    ResetMVs16x8(1, 0);
                else
                    ReconstructMVs16x8(1, 0);

                // set forward vectors for the second sub-block
                if (m_cur_mb.LocalMacroblockInfo->sbdir[1] == D_DIR_BWD)
                    ResetMVs16x8(0, 8);
                else
                    ReconstructMVs16x8(0, 1);

                // set backward vectors for the second sub-block
                if (m_cur_mb.LocalMacroblockInfo->sbdir[1] == D_DIR_FWD)
                    ResetMVs16x8(1, 8);
                else
                    ReconstructMVs16x8(1, 1);
            }
            break;

        case MBTYPE_INTER_8x16:
            {
                // set forward vectors for the first sub-block
                if (m_cur_mb.LocalMacroblockInfo->sbdir[0] == D_DIR_BWD)
                    ResetMVs8x16(0, 0);
                else
                    ReconstructMVs8x16(0, 0);

                // set backward vectors for the first sub-block
                if (m_cur_mb.LocalMacroblockInfo->sbdir[0] == D_DIR_FWD)
                    ResetMVs8x16(1, 0);
                else
                    ReconstructMVs8x16(1, 0);

                // set forward vectors for the second sub-block
                if (m_cur_mb.LocalMacroblockInfo->sbdir[1] == D_DIR_BWD)
                    ResetMVs8x16(0, 2);
                else
                    ReconstructMVs8x16(0, 1);

                // set backward vectors for the second sub-block
                if (m_cur_mb.LocalMacroblockInfo->sbdir[1] == D_DIR_FWD)
                    ResetMVs8x16(1, 2);
                else
                    ReconstructMVs8x16(1, 1);

                CopyMVs8x16(0);
                CopyMVs8x16(1);
            }
            break;

        case MBTYPE_INTER_8x8:

⌨️ 快捷键说明

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