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

📄 umc_h264_pack.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            // Sub MB Type            if (m_PicParamSet.entropy_coding_mode)                m_pbitstream->SubTypeInfo_CABAC(m_SliceHeader.slice_type,N);            else                length = m_pbitstream->PutVLCCode(N);        }    }}   // Encode_BiPred_Type// Encodes ref_idx_lX of a list num.void H264VideoEncoder::Encode_ref_idx(int ref_idx_val,                                      int ref_idx_ctxIdxInc,                                      int listNum){    if(m_PicParamSet.entropy_coding_mode) {        // CABAC        bool curr_bit = (ref_idx_val != 0);        m_pbitstream->EncodeSingleBin_CABAC(ctxIdxOffset[listNum] + ref_idx_ctxIdxInc,  curr_bit);        ref_idx_ctxIdxInc = 3;        while(curr_bit) {            ref_idx_val--;            ref_idx_ctxIdxInc = (ref_idx_ctxIdxInc < 5)? ref_idx_ctxIdxInc + 1: ref_idx_ctxIdxInc;            curr_bit = (ref_idx_val != 0);            m_pbitstream->EncodeSingleBin_CABAC(ctxIdxOffset[listNum] + ref_idx_ctxIdxInc, curr_bit);        }        return;    }    else {        // CAVLC        int num_ref_idx_active = (listNum == REF_IDX_L0)?                                 m_SliceHeader.num_ref_idx_l0_active                               : m_SliceHeader.num_ref_idx_l1_active;        if(num_ref_idx_active > 2) {            m_pbitstream->PutVLCCode(ref_idx_val);        }        else {            // range == [0; 1]            m_pbitstream->PutBits(1 - ref_idx_val, 1);        }    }    return;} // Encode_ref_idx//////////////////////////////////////////////////////////////////////////////////// Encode_MB_Vectors//////////////////////////////////////////////////////////////////////////////////void H264VideoEncoder::Encode_MB_Vectors(Ipp32u uMB){    int length, num_vectors, ref0_vectors = 0;    MB_Type         uMBType = m_pCurrentFrame->pMBData[uMB].uMBType;    T_ECORE_MV      mv[32];             // for the up to 16 predictors for the MB in each direction    T_ECORE_BIGMV   mvd[32];            // for the up to 16 deltas for the MB in each direction    int             block_index[32];    // for the up to 16 indexes for the blocks in each direction    Ipp32u uBlock;              // Block counter for 8x8 mode    const Ipp32u blockpos[4] = {0, 2, 8, 10};    int num_ref_idx_l0 = 0; // Number of MB parts which need ref_idx_l0.    int num_ref_idx_l1 = 0; // Number of MB parts which need ref_idx_l1.    int Top_Block_Availability[32] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};    int Left_Block_Availability[32]= {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};    Ipp32s uMVOffset = m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex;    T_RefIdx *pRefIdxL0 = &m_pCurrentFrame->pRefIdxL0[uMVOffset];    T_RefIdx *pRefIdxL1 = &m_pCurrentFrame->pRefIdxL1[uMVOffset];    T_RefIdx    ref_idx_l0[4];    T_RefIdx    ref_idx_l1[4];    int         ref_idx_l0_ctxIdxInc[4];    int         ref_idx_l1_ctxIdxInc[4];    // Intra MB Types don't make it here...    // Get the MV predictors and deltas for the MB. The arrays will be filled    // only with the number of predictors and deltas for this MB's type; the    // remainder will be undefined.    // IMPORTANT! fistly we write L0 vectors then L1    switch (uMBType)    {    case MBTYPE_INTER:    case MBTYPE_FORWARD:        ref0_vectors = 1;        num_vectors = 1;        num_ref_idx_l0 = 1;        block_index[0] = m_pCurrentFrame->block_positions[0];        ref_idx_l0[0] = pRefIdxL0[block_index[0]];        Calc_One_MV_Predictor(uMB, 0, 0, 4, 4, mv, mvd, &ref_idx_l0_ctxIdxInc[0]);        if(!IS_Top_Available(uMB))            Top_Block_Availability[0] = 0;        if(!IS_Left_Available(uMB))            Left_Block_Availability[0] = 0;        Multiply_DMV(&m_pCurrentFrame->pDMVL0[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex+m_pCurrentFrame->block_positions[0]],0,4,1,0,4,1,mvd[0]);        break;    case MBTYPE_BACKWARD:        ref0_vectors = 0;        num_vectors = 1;        num_ref_idx_l1 = 1;        block_index[0] = m_pCurrentFrame->block_positions[0];        ref_idx_l1[0] = pRefIdxL1[block_index[0]];        Calc_One_MV_Predictor(uMB, 0, 1, 4, 4, mv, mvd, &ref_idx_l1_ctxIdxInc[0]);        if(!IS_Top_Available(uMB))            Top_Block_Availability[0] = 0;        if(!IS_Left_Available(uMB))            Left_Block_Availability[0] = 0;        Multiply_DMV(&m_pCurrentFrame->pDMVL1[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex+m_pCurrentFrame->block_positions[0]],0,4,1,0,4,1,mvd[0]);        break;    case MBTYPE_INTER_16x8:        ref0_vectors = 2;        num_vectors = 2;        num_ref_idx_l0 = 2;        block_index[0] = m_pCurrentFrame->block_positions[0];        block_index[1] = m_pCurrentFrame->block_positions[8];        ref_idx_l0[0] = pRefIdxL0[block_index[0]];        ref_idx_l0[1] = pRefIdxL0[block_index[1]];        Calc_One_MV_Predictor(uMB, 0, 0, 4, 2, mv, mvd, &ref_idx_l0_ctxIdxInc[0]);        Calc_One_MV_Predictor(uMB, 8, 0, 4, 2, mv+1, mvd+1, &ref_idx_l0_ctxIdxInc[1]);        if(!IS_Top_Available(uMB))        {            Top_Block_Availability[0] = 0;        }        if(!IS_Left_Available(uMB))        {            Left_Block_Availability[0] = 0;            Left_Block_Availability[1] = 0;        }        Multiply_DMV(&m_pCurrentFrame->pDMVL0[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex+m_pCurrentFrame->block_positions[0]],0,4,1,0,2,1,mvd[0]);        Multiply_DMV(&m_pCurrentFrame->pDMVL0[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex+m_pCurrentFrame->block_positions[8]],0,4,1,0,2,1,mvd[1]);        break;    case MBTYPE_INTER_8x16:        ref0_vectors = 2;        num_vectors = 2;        num_ref_idx_l0 = 2;        block_index[0]=m_pCurrentFrame->block_positions[0];        block_index[1]=m_pCurrentFrame->block_positions[2];        ref_idx_l0[0] = pRefIdxL0[block_index[0]];        ref_idx_l0[1] = pRefIdxL0[block_index[1]];        Calc_One_MV_Predictor(uMB, 0, 0, 2, 4, mv, mvd, &ref_idx_l0_ctxIdxInc[0]);        Calc_One_MV_Predictor(uMB, 2, 0, 2, 4, mv+1, mvd+1, &ref_idx_l0_ctxIdxInc[1]);        if(!IS_Top_Available(uMB))        {            Top_Block_Availability[0] = 0;            Top_Block_Availability[1] = 0;        }        if(!IS_Left_Available(uMB))        {            Left_Block_Availability[0] = 0;        }        Multiply_DMV(&m_pCurrentFrame->pDMVL0[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex+m_pCurrentFrame->block_positions[0]],0,2,1,0,4,1,mvd[0]);        Multiply_DMV(&m_pCurrentFrame->pDMVL0[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex+m_pCurrentFrame->block_positions[2]],0,2,1,0,4,1,mvd[1]);        break;    case MBTYPE_FWD_FWD_16x8:        ref0_vectors = 2;        num_vectors = 2;        num_ref_idx_l0 = 2;        block_index[0]=m_pCurrentFrame->block_positions[0];        block_index[1]=m_pCurrentFrame->block_positions[8];        ref_idx_l0[0] = pRefIdxL0[block_index[0]];        ref_idx_l0[1] = pRefIdxL0[block_index[1]];        Calc_One_MV_Predictor(uMB, 0, 0, 4, 2, mv, mvd, &ref_idx_l0_ctxIdxInc[0]);        Calc_One_MV_Predictor(uMB, 8, 0, 4, 2, mv+1, mvd+1, &ref_idx_l0_ctxIdxInc[1]);        if(!IS_Top_Available(uMB))        {            Top_Block_Availability[0] = 0;        }        if(!IS_Left_Available(uMB))        {            Left_Block_Availability[0] = 0;            Left_Block_Availability[1] = 0;        }        Multiply_DMV(&m_pCurrentFrame->pDMVL0[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex+m_pCurrentFrame->block_positions[0]],0,4,1,0,2,1,mvd[0]);        Multiply_DMV(&m_pCurrentFrame->pDMVL0[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex+m_pCurrentFrame->block_positions[8]],0,4,1,0,2,1,mvd[1]);        break;    case MBTYPE_FWD_FWD_8x16:        ref0_vectors = 2;        num_vectors = 2;        num_ref_idx_l0 = 2;        block_index[0]=m_pCurrentFrame->block_positions[0];        block_index[1]=m_pCurrentFrame->block_positions[2];        ref_idx_l0[0] = pRefIdxL0[block_index[0]];        ref_idx_l0[1] = pRefIdxL0[block_index[1]];        Calc_One_MV_Predictor(uMB, 0, 0, 2, 4, mv, mvd, &ref_idx_l0_ctxIdxInc[0]);        Calc_One_MV_Predictor(uMB, 2, 0, 2, 4, mv+1, mvd+1, &ref_idx_l0_ctxIdxInc[1]);        if(!IS_Top_Available(uMB))        {            Top_Block_Availability[0] = 0;            Top_Block_Availability[1] = 0;        }        if(!IS_Left_Available(uMB))        {            Left_Block_Availability[0] = 0;        }        Multiply_DMV(&m_pCurrentFrame->pDMVL0[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex+m_pCurrentFrame->block_positions[0]],0,2,1,0,4,1,mvd[0]);        Multiply_DMV(&m_pCurrentFrame->pDMVL0[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex+m_pCurrentFrame->block_positions[2]],0,2,1,0,4,1,mvd[1]);        break;    case MBTYPE_BWD_BWD_16x8:        ref0_vectors = 0;        num_vectors = 2;        num_ref_idx_l1 = 2;        block_index[0]=m_pCurrentFrame->block_positions[0];        block_index[1]=m_pCurrentFrame->block_positions[8];        ref_idx_l1[0] = pRefIdxL1[block_index[0]];        ref_idx_l1[1] = pRefIdxL1[block_index[1]];        Calc_One_MV_Predictor(uMB, 0, 1, 4, 2, mv, mvd, &ref_idx_l1_ctxIdxInc[0]);        Calc_One_MV_Predictor(uMB, 8, 1, 4, 2, mv+1, mvd+1, &ref_idx_l1_ctxIdxInc[1]);        if(!IS_Top_Available(uMB))        {            Top_Block_Availability[0] = 0;        }        if(!IS_Left_Available(uMB))        {            Left_Block_Availability[0] = 0;            Left_Block_Availability[1] = 0;        }        Multiply_DMV(&m_pCurrentFrame->pDMVL1[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex+m_pCurrentFrame->block_positions[0]],0,4,1,0,2,1,mvd[0]);        Multiply_DMV(&m_pCurrentFrame->pDMVL1[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex+m_pCurrentFrame->block_positions[8]],0,4,1,0,2,1,mvd[1]);        break;    case MBTYPE_BWD_BWD_8x16:        ref0_vectors = 0;        num_vectors = 2;        num_ref_idx_l1 = 2;        block_index[0]=m_pCurrentFrame->block_positions[0];        block_index[1]=m_pCurrentFrame->block_positions[2];        ref_idx_l1[0] = pRefIdxL1[block_index[0]];        ref_idx_l1[1] = pRefIdxL1[block_index[1]];        Calc_One_MV_Predictor(uMB, 0, 1, 2, 4, mv, mvd, &ref_idx_l1_ctxIdxInc[0]);        Calc_One_MV_Predictor(uMB, 2, 1, 2, 4, mv+1, mvd+1, &ref_idx_l1_ctxIdxInc[1]);        if(!IS_Top_Available(uMB))        {            Top_Block_Availability[0] = 0;            Top_Block_Availability[1] = 0;        }        if(!IS_Left_Available(uMB))        {            Left_Block_Availability[0] = 0;        }        Multiply_DMV(&m_pCurrentFrame->pDMVL1[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex+m_pCurrentFrame->block_positions[0]],0,2,1,0,4,1,mvd[0]);        Multiply_DMV(&m_pCurrentFrame->pDMVL1[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex+m_pCurrentFrame->block_positions[2]],0,2,1,0,4,1,mvd[1]);        break;    case MBTYPE_FWD_BWD_16x8:        ref0_vectors = 1;        num_vectors = 2;        num_ref_idx_l0 = 1;        num_ref_idx_l1 = 1;        block_index[0]=m_pCurrentFrame->block_positions[0];        block_index[1]=m_pCurrentFrame->block_positions[8];        ref_idx_l0[0] = pRefIdxL0[block_index[0]];        ref_idx_l1[0] = pRefIdxL1[block_index[1]];        Calc_One_MV_Predictor(uMB, 0, 0, 4, 2, mv, mvd, &ref_idx_l0_ctxIdxInc[0]);        Calc_One_MV_Predictor(uMB, 8, 1, 4, 2, mv+1, mvd+1, &ref_idx_l1_ctxIdxInc[0]);        if(!IS_Top_Available(uMB))        {            Top_Block_Availability[0] = 0;        }        if(!IS_Left_Available(uMB))        {            Left_Block_Availability[0] = 0;            Left_Block_Availability[1] = 0;        }        Multiply_DMV(&m_pCurrentFrame->pDMVL0[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex+m_pCurrentFrame->block_positions[0]],0,4,1,0,2,1,mvd[0]);        Multiply_DMV(&m_pCurrentFrame->pDMVL1[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex+m_pCurrentFrame->block_positions[8]],0,4,1,0,2,1,mvd[1]);        break;    case MBTYPE_FWD_BWD_8x16:        ref0_vectors = 1;        num_vectors = 2;        num_ref_idx_l0 = 1;        num_ref_idx_l1 = 1;        block_index[0]=m_pCurrentFrame->block_positions[0];        block_index[1]=m_pCurrentFrame->block_positions[2];        ref_idx_l0[0] = pRefIdxL0[block_index[0]];        ref_idx_l1[0] = pRefIdxL1[block_index[1]];        Calc_One_MV_Predictor(uMB, 0, 0, 2, 4, mv, mvd, &ref_idx_l0_ctxIdxInc[0]);        Calc_One_MV_Predictor(uMB, 2, 1, 2, 4, mv+1, mvd+1, &ref_idx_l1_ctxIdxInc[0]);        if(!IS_Top_Available(uMB))        {            Top_Block_Availability[0] = 0;            Top_Block_Availability[1] = 0;        }        if(!IS_Left_Available(uMB))        {            Left_Block_Availability[0] = 0;        }

⌨️ 快捷键说明

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