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

📄 umc_vc1_enc_planes.h

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

    public:

        inline bool AddFrame(Frame* frame)
        {
            if (frame->isReferenceFrame())
            {
               return AddReferenceFrame(frame);
            }
            else
            {
                return AddBFrame(frame);
            }
        }
        inline virtual UMC::Status Init(Ipp32u maxB)
        {
            Close();
            m_maxB = maxB;
            m_pFrames = new Frame* [m_maxB+2];
            if (!m_pFrames)
                return UMC::UMC_ERR_ALLOC;
            memset(m_pFrames,0,sizeof(Frame*)*(m_maxB+2));
            return UMC::UMC_OK;
        }

        inline virtual void Reset()
        {
            if (m_pFrames)
                   memset(m_pFrames,0,sizeof(Frame*)*(m_maxB+2));

            m_iCurr = 0;
            m_numBuffB = 0;
        };

        inline Frame* GetFrameForDecoding()
        {
            return m_pFrames[m_iCurr];
        }
        inline  virtual void ReleaseCurrentFrame()
        {
            if (!m_pFrames[m_iCurr])
                return;
            if (m_iCurr>1)
            {
                m_pFrames[m_iCurr]->ReleasePlane();
                m_pFrames[m_iCurr] = 0;
            }
            m_iCurr++;
            if (m_iCurr>=m_numBuffB+2)
            {
                NewGOP();
            }
        }
        inline  virtual void CloseGop()
        {
            if (m_pFrames[1]==0 && m_numBuffB>0)
            {
                m_pFrames[1]            = m_pFrames[2+m_numBuffB-1];
                m_pFrames[2 + m_numBuffB-1] = 0;
                m_numBuffB --;
                m_pFrames[1]->SetReferenceFrameType();
            }
        }
        inline Frame* GetReferenceFrame(bool bBackward = false)
        {
            return m_pFrames[bBackward];
        }

        inline virtual ePType GetPictureType(Ipp32u frameCount,Ipp32u GOPLength, Ipp32u BFrmLength)
        {
            Ipp32s      nFrameInGOP        =  (frameCount++) % GOPLength;

            if (nFrameInGOP)
            {
                if ( nFrameInGOP %(BFrmLength+1)==0)
                    return VC1_ENC_P_FRAME;
                else
                    return VC1_ENC_B_FRAME;
            }
            return VC1_ENC_I_FRAME;
        }


    };
    class GOPWithoutReordening : public GOP
    {
    public:

        inline virtual UMC::Status Init(Ipp32u maxB)
        {
            return GOP::Init(maxB>0);
        }

    protected:
        inline virtual bool AddBFrame(Frame* frame)
        {
            if (m_numBuffB < m_maxB && m_pFrames[0] != 0 && m_pFrames[1]!=0)
            {
                m_pFrames[m_numBuffB+2] = frame;
                return true;
            }
            return false;
        }
        inline virtual bool AddReferenceFrame(Frame* frame)
        {
            if (!GOP::AddReferenceFrame(frame))
            {
                NewGOP();
                return GOP::AddReferenceFrame(frame);
            }
            return true;
        }
    public:
        inline virtual ePType GetPictureType(Ipp32u frameCount,Ipp32u GOPLength, Ipp32u BFrmLength)
        {
            Ipp32s      nFrameInGOP        =  (frameCount) % GOPLength;

            if (nFrameInGOP)
            {
                if ( (nFrameInGOP-1) %(BFrmLength+2)==0)
                    return VC1_ENC_P_FRAME;
                else
                    return VC1_ENC_B_FRAME;
            }
            return VC1_ENC_I_FRAME;
        }



        inline virtual void ReleaseCurrentFrame()
        {
            if (!m_pFrames[m_iCurr])
                return;
            if (m_iCurr>1)
            {
                m_pFrames[m_iCurr]->ReleasePlane();
                m_pFrames[m_iCurr] = 0;
            }
            else
            {
                m_iCurr++;
            }

        }
        inline virtual void CloseGop()
        {
            return;
        }
     };

    class WaitingList
    {
    public:
        WaitingList():
            m_maxN(0),
            m_pFrame(0),
            m_curIndex(0),
            m_nFrames(0)
            {};
        ~WaitingList()
        {Close();}
        void Close()
        {
            if (m_pFrame)
            {
                delete m_pFrame;
                m_pFrame = 0;
            }
            m_maxN = 0;
            m_curIndex = 0;
            m_nFrames = 0;
        }

        UMC::Status Init(Ipp32u maxB)
        {
            Close();
            m_maxN = maxB+2;
            m_pFrame = new Frame* [ m_maxN];
            if (!m_pFrame)
                return UMC::UMC_ERR_ALLOC;
            memset (m_pFrame,0, sizeof(Frame*)* m_maxN);
            return UMC::UMC_OK;
        }

        void Reset()
        {
            Ipp32s i = 0;
            if(m_pFrame)
                memset (m_pFrame,0, sizeof(Frame*)* m_maxN);
            m_curIndex = 0;
            m_nFrames = 0;
            if(m_pFrame)
                for(i = 0; i < m_maxN; i++)
                {
                    if(m_pFrame[i])
                        m_pFrame[i]->ReleasePlane();
                }
        }

        bool AddFrame(Frame* frame)
        {
            if (m_nFrames < m_maxN)
            {
                Ipp32u ind = (m_curIndex + m_nFrames)%m_maxN;
                m_pFrame[ind] = frame;
                m_nFrames ++;
                return true;
            }
            return false;
        }
        Frame* GetCurrFrame()
        {
            Frame* frm = 0;
            if (m_nFrames>0)
            {
                frm = m_pFrame[m_curIndex];
            }
            return frm;
        }
        bool MoveOnNextFrame()
        {
            if (m_nFrames>0)
            {
                m_pFrame[m_curIndex] = 0;
                m_curIndex = (++m_curIndex)%m_maxN;
                m_nFrames--;
                return true;
            }
            return false;
        }

    private:
        Ipp32u  m_maxN;
        Frame** m_pFrame;
        Ipp32u  m_curIndex;
        Ipp32u  m_nFrames;

    };

    class BufferedFrames
    {

    public:
        BufferedFrames():
            m_pFrames(0),       //sequence of frames
            m_bufferSize (0),   //number of frames in sequence
            m_nBuffered (0),
            m_currFrameIndex (0),
            m_bClosed (false) // closed sequence (if the backward reference frame is present)
            {};

         virtual ~BufferedFrames()
         {
            Close();
         }
         UMC::Status    Init                (Ipp32u w, Ipp32u h, Ipp32u paddingSize, Ipp32u n);
         void           Close();
         UMC::Status    SaveFrame           (Ipp8u* pYPlane, Ipp32u stepY,
                                            Ipp8u* pUPlane, Ipp32u stepU,
                                            Ipp8u* pVPlane, Ipp32u stepV );

         UMC::Status    GetFrame            (Frame** currFrame);
         UMC::Status    GetReferenceFrame   (Frame** currFrame);

        UMC::Status     ReferenceFrame();

         inline bool isClosedSequence ()
         {
            return m_bClosed;
         }
         inline bool isBuffered()
         {
            return (m_nBuffered!=0);
         }
    private:
        Frame* m_pFrames;
        Ipp32u m_bufferSize;
        Ipp32u m_nBuffered;
        Ipp32u m_currFrameIndex;
        bool   m_bClosed; // closed sequence (if the backward reference frame is present)
    };
}
#endif
#endif //defined (UMC_ENABLE_VC1_VIDEO_ENCODER)

⌨️ 快捷键说明

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