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

📄 umc_h264_enc_cpb.h

📁 audio-video-codecs.rar语音编解码器
💻 H
📖 第 1 页 / 共 2 页
字号:
    {
        if (m_PictureStructureForRef>=FRM_STRUCTURE)
            m_isShortTermRef[0] = m_isShortTermRef[1] = true;
        else
            m_isShortTermRef[WhichField] = true;
    }

    Ipp32s PicOrderCnt(Ipp32s index,Ipp32s force=0)
    {
        if ((m_PictureStructureForRef>=FRM_STRUCTURE && force==0) || force==3)
        {
            return MIN(m_PicOrderCnt[0],m_PicOrderCnt[1]);
        }
        else if (force==2)
        {
            if (isShortTermRef(0) && isShortTermRef(1)) return MIN(m_PicOrderCnt[0],m_PicOrderCnt[1]);
            else if (isShortTermRef(0)) return m_PicOrderCnt[0];
            else return m_PicOrderCnt[1];
        }
        return m_PicOrderCnt[index];
    }

    Ipp32s DeblockPicID(Ipp32s index)
    {
#if 0
        //the constants are subject to change
        return PicOrderCnt(index,force)*2+FrameNumWrap()*534+FrameNum()*878+PicNum(index,force)*14
            +RefPicListResetCount(index,force);
#else
        size_t ret = (size_t)this;
        return (Ipp32s)(ret + index);

#endif
    }

    void setPicOrderCnt(Ipp32s PicOrderCnt, Ipp32s index) {m_PicOrderCnt[index] = PicOrderCnt;};

    bool isLongTermRef(Ipp32s WhichField)
    {
        if (m_PictureStructureForRef>=FRM_STRUCTURE)
            return m_isLongTermRef[0] && m_isLongTermRef[1];
        else
            return m_isLongTermRef[WhichField];
    }

    Ipp8u isLongTermRef()
    {
        return m_isLongTermRef[0] + m_isLongTermRef[1]*2;
    }

    void SetisLongTermRef(Ipp32s WhichField)
    {
        if (m_PictureStructureForRef>=FRM_STRUCTURE)
            m_isLongTermRef[0] = m_isLongTermRef[1] = true;
        else
            m_isLongTermRef[WhichField] = true;
    }

    void unSetisShortTermRef(Ipp32s WhichField)
    {
        if (m_PictureStructureForRef>=FRM_STRUCTURE){
            m_isShortTermRef[0] = m_isShortTermRef[1] = false;
        }else
            m_isShortTermRef[WhichField] = false;
    }

    void unSetisLongTermRef(Ipp32s WhichField)
    {
        if (m_PictureStructureForRef>=FRM_STRUCTURE){
            m_isLongTermRef[0] = m_isLongTermRef[1] = false;
        }else
            m_isLongTermRef[WhichField] = false;
    }

    Ipp32s LongTermPicNum(Ipp32s f,Ipp32s force=0)
    {
        if ((m_PictureStructureForRef>=FRM_STRUCTURE && force==0) || force==3){
            return MIN(m_LongTermPicNum[0],m_LongTermPicNum[1]);
        }else if (force==2){
            if (isLongTermRef(0) && isLongTermRef(1)) return MIN(m_LongTermPicNum[0],m_LongTermPicNum[1]);
            else if (isShortTermRef(0)) return m_LongTermPicNum[0];
            else return m_LongTermPicNum[0];
        }
        return m_LongTermPicNum[f];
    }

    void setLongTermPicNum(Ipp32s LongTermPicNum, Ipp32s f) {m_LongTermPicNum[f] = LongTermPicNum;}
    void UpdateLongTermPicNum(Ipp32s CurrPicStruct);

    void IncreaseRefPicListResetCount(Ipp32s f)
    {
        /*if (m_PictureStructureForRef>=FRM_STRUCTURE)
        {
        m_RefPicListResetCount[0]++;
        m_RefPicListResetCount[1]++;
        }
        else*/
        m_RefPicListResetCount[f]++;
    }

    void InitRefPicListResetCount(Ipp32s f)
    {
        if (m_PictureStructureForRef>=FRM_STRUCTURE) {
            // Should reconsider keeping this branch.
            m_RefPicListResetCount[0]=m_RefPicListResetCount[1]=0;
        }
        else
            m_RefPicListResetCount[f]=0;
    }

    Ipp32s RefPicListResetCount(Ipp32s f, Ipp32s force=0)
    {
        if ((m_PictureStructureForRef>=FRM_STRUCTURE && force==0)|| force==3)
            return MAX(m_RefPicListResetCount[0],m_RefPicListResetCount[1]);
        else
            return m_RefPicListResetCount[f];
    }

    Ipp32s GetNumberByParity(Ipp32s parity)
    {
        if (parity==-1) return -1;
        if (m_bottom_field_flag[0]==parity) return 0;
        if (m_bottom_field_flag[1]==parity) return 1;
        VM_ASSERT(m_PictureStructureForRef>=FRM_STRUCTURE);
        return 0;
    }

    bool   m_bIsIDRPic;
    Ipp32s numMBs;
    Ipp32s numIntraMBs;
    // Read from slice NAL unit of current picture. True indicates the
    // picture contains only I or SI slice types.

    EncoderRefPicList<PixType> *m_pRefPicList;

    //////////////////////////////////////////////////////////////////////////////
    // GetRefPicList
    // Returns pointer to start of specified ref pic list.
    //////////////////////////////////////////////////////////////////////////////
    EncoderRefPicListStruct<PixType>* GetRefPicList(Ipp32s SliceNum, Ipp32s List)
    {
        EncoderRefPicListStruct<PixType> *pList;

        if (List == LIST_0)
            pList = &m_pRefPicList[SliceNum].m_RefPicListL0;
        else
            pList = &m_pRefPicList[SliceNum].m_RefPicListL1;

        return pList;

    }    // RefPicList

    //////////////////////////////////////////////////////////////////////////////
    // GetRefPicList
    // Returns pointer to ref pic lists struct.
    //////////////////////////////////////////////////////////////////////////////
    EncoderRefPicList<PixType>* GetRefPicLists(Ipp32s SliceNum) // Returns pointer to start of specified ref pic list.
    {
        return &m_pRefPicList[SliceNum];
    }    // RefPicLists

    IppiSize m_paddedParsedFrameDataSize;
    Status allocateParsedFrameData(const IppiSize&, Ipp32s);
    void deallocateParsedFrameData();
    const IppiSize& macroBlockSize() { return m_macroBlockSize; }

#if defined ALPHA_BLENDING_H264
    Ipp32s alpha_plane; // Is there alpha plane (>=0) and its number
    Ipp32s isAux(){ return m_isAuxiliary; }
    void useAux();
    void usePrimary();
#endif

private:
    Ipp32s m_NumSlices;   // Number of slices.
    IppiSize m_macroBlockSize;

#if defined ALPHA_BLENDING_H264
    Ipp32s m_isAuxiliary;    //Do we compress auxiliary channel?
#endif
};

template <class PixType> class H264EncoderFrameList
{
private:
    // m_pHead points to the first element in the list, and m_pTail
    // points to the last.  m_pHead->previous() and m_pTail->future()
    // are both NULL.
    H264EncoderFrame<PixType> *m_pHead;
    H264EncoderFrame<PixType> *m_pTail;
    H264EncoderFrame<PixType> *m_pCurrent;
    MemoryAllocator* memAlloc;

public:

    H264EncoderFrameList(MemoryAllocator *pMemAlloc);
    virtual ~H264EncoderFrameList();
    void Init(MemoryAllocator *pMemAlloc){ memAlloc = pMemAlloc; }

    H264EncoderFrame<PixType> *head() { return m_pHead; }
    H264EncoderFrame<PixType> *tail() { return m_pTail; }

    bool isEmpty() { return !m_pHead; }

    H264EncoderFrame<PixType> *detachHead();    // Detach the first frame and return a pointer to it,
    void RemoveFrame(H264EncoderFrame<PixType>*);    // Removes selected frame from list
    // or return NULL if the list is empty.

    void append(H264EncoderFrame<PixType> *pFrame);
    H264EncoderFrame<PixType>* InsertFrame(VideoData* rFrame,
                                           EnumPicCodType   ePictureType,
                                           Ipp32s           isRef,
                                           Ipp32s           num_slices,
                                           const IppiSize & padded_size
#if defined ALPHA_BLENDING_H264
                                           , Ipp32s alpha
#endif
                                           );

    // Append the given frame to our tail

    void insertList(H264EncoderFrameList<PixType> &src);
    // Move the given list to the beginning of our list.

    H264EncoderFrame<PixType> *findNextDisposable();   // Search through the list for the next disposable frame to decode into
    H264EncoderFrame<PixType> *findOldestDisposable(); // Search through the list for the oldest disposable frame to decode into
    void insertAtCurrent(H264EncoderFrame<PixType> *pFrame); // Inserts a frame immediately after the position pointed to by m_pCurrent
    void resetCurrent(void) { m_pCurrent = m_pTail; } // Resets the position of the current to the tail. This allows us to start "before" the head when we wrap around.
    void setCurrent(H264EncoderFrame<PixType> *pFrame) { m_pCurrent = pFrame; } // Set the position of the current to pFrame
    void removeAllRef();    // Mark all frames as not used as reference frames.
    void IncreaseRefPicListResetCount(H264EncoderFrame<PixType> *ExcludeFrame); // Mark all frames as not used as reference frames.
    void freeOldestShortTermRef();    // Mark the oldest short-term reference frame as not used.
    void freeShortTermRef(Ipp32s PicNum);    // Mark the short-term reference frame with specified PicNum as not used
    void freeLongTermRef(Ipp32s LongTermPicNum);    // Mark the long-term reference frame with specified LongTermPicNum  as not used
    void freeLongTermRefIdx(Ipp32s LongTermFrameIdx);    // Mark the long-term reference frame with specified LongTermFrameIdx as not used
    void freeOldLongTermRef(Ipp32s MaxLongTermFrameIdx);    // Mark any long-term reference frame with LongTermFrameIdx greater than MaxLongTermFrameIdx as not used.
    void changeSTtoLTRef(Ipp32s PicNum, Ipp32s LongTermFrameIdx);    // Mark the short-term reference frame with specified PicNum as long-term with specified long term idx.
    void countActiveRefs(Ipp32u &NumShortTerm, Ipp32u &NumLongTerm);
    void countL1Refs(Ipp32u &NumRefs, Ipp32s curPOC); // Return number of active short and long term reference frames.
    H264EncoderFrame<PixType> *findOldestToEncode(H264EncoderFrameList<PixType>* dpb,Ipp32u min_L1_refs, Ipp32s use_B_as_refs);    // Search through the list for the oldest displayable frame.
    H264EncoderFrame<PixType> *findNewestToEncode();    // Search through the list for the newest displayable frame.
    Ipp32s countNumToEncode();

/*
#if defined ALPHA_BLENDING_H264
    void switchToPrimary();
    void switchToAuxiliary();
#endif
*/
#if defined ALPHA_BLENDING_H264
    void switchToPrimary()
    {
        H264EncoderFrame<PixType>* frm = head();
        for(;frm;frm = frm->future()) frm->usePrimary();
    }

    void switchToAuxiliary()
    {
        H264EncoderFrame<PixType>* frm = head();
        for(;frm;frm = frm->future()) frm->useAux();
    }
#endif
};

} //namespace UMC_H264_ENCODER
#endif // __UMC_H264_ENC_CPB_H__

⌨️ 快捷键说明

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