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

📄 umc_h264_core_enc.h

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

            bool ComputeDirectSpatialMV(H264EncoderThreadPrivateSlice<PixType, CoeffsType> *curr_slice,
                                        Ipp32u uMB,
                                        H264MacroblockRefIdxs  ref_direct[2],
                                        H264MacroblockMVs      mvs_direct[2]);     // MVs used returned here.

            bool ComputeDirectTemporalMV(H264EncoderThreadPrivateSlice<PixType, CoeffsType> *curr_slice,
                                         Ipp32u                uMB,
                                         H264MacroblockRefIdxs ref_direct[2],
                                         H264MacroblockMVs     mvs_direct[2]);     // MVs used returned here.

            void  CDirectBOneMB_worker(H264EncoderThreadPrivateSlice<PixType, CoeffsType> *curr_slice,
                                       const Ipp32u       uMB,
                                       Ipp32u             *puMBSAD,    // return best total MB SAD here
                                       H264MacroblockRefIdxs ref_direct[2],
                                       H264MacroblockMVs  mvs_direct[2]);     // MVs used returned here.

            void  CBiPredOneMB_worker(H264EncoderThreadPrivateSlice<PixType, CoeffsType> *curr_slice,
                                      const Ipp32u        uMB,
                                      Ipp32u              uWidth,
                                      Ipp32u              uHeight,
                                      Ipp32u              uBlock,     // which 4x4 Block (UL Corner, Raster Order),
                                      Ipp32u*             puMBSAD,    // return best total MB SAD here
                                      const H264EncoderFrame<PixType> *pRefFramePrev,
                                      const H264EncoderFrame<PixType> *pRefFrameFutr,
                                      const Ipp8s         FieldPrev,
                                      const Ipp8s         FieldFutr,
                                      Ipp32s              DistScaleFactor,
                                      H264MotionVector    *MVFwd,     // MVs used returned here.
                                      H264MotionVector    *MVBwd);    // MVs used returned here.

            void  CDirectBOneMB_Interp(H264EncoderThreadPrivateSlice<PixType, CoeffsType> *curr_slice,
                                       const Ipp32u          uMB,            // Current MB
                                       const Ipp32u          uBlkIndex,      // first block index
                                       H264MacroblockRefIdxs ref_direct[2],
                                       H264MacroblockMVs     mvs_direct[2]); // MVs used returned here.
                                          // pointer to future frame buffer

            bool  CDirectBOneMB_Interp_Cr(H264EncoderThreadPrivateSlice<PixType, CoeffsType> *curr_slice,
                                          const Ipp32u uMB,             // macroblock number
                                          Ipp32s pitchPixels,           // pitch of source data in pixels
                                          const H264MotionVector *pMVL0,// Fwd motion vectors in subpel units
                                          const H264MotionVector *pMVL1,// Bwd motion vectors in subpel units
                                          Ipp8s *pFields0,              //
                                          Ipp8s *pFields1,              //
                                          PixType* pDst,                // put the resulting block here with pitch of 16
                                          PixType* tempBuff,            // the pointer to the working buffer
                                          bool   is_v_plane,
                                          Ipp32s offset,
                                          IppiSize size);

            void Interpolate(const Ipp32s mb_decoding_flag, const PixType * src, Ipp32s srcPitchPixels,
                             PixType* dst, Ipp32s dstPitchPixels, Ipp32s xh, Ipp32s yh, IppiSize sz,
                             Ipp32s mvy, Ipp32s mb_y_pos, Ipp32s sb_y_pos);
            void Interpolate_Cr(const Ipp32s mb_decoding_flag, const PixType * src, Ipp32s srcPitchPixels,
                                PixType* dst, Ipp32s dstPitchPixels, Ipp32s xh, Ipp32s yh, IppiSize sz,
                                Ipp32s mvy, Ipp32s mb_y_pos, Ipp32s sb_y_pos);

    public:
        Ipp8s GetReferenceField(Ipp8s *pFields,Ipp8s RefIndex);
        EncoderRefPicListStruct<PixType>* GetRefPicList(H264EncoderThreadPrivateSlice<PixType, CoeffsType> *curr_slice, Ipp32u List,Ipp32s mb_cod_type,Ipp32s is_bottom_mb);

    private:
        ///////////////////////////////////////////////////////////////////////
        // Data
        ///////////////////////////////////////////////////////////////////////

        CH264pBs<PixType,CoeffsType>               **m_pbitstreams; // Array of bitstreams for threads.

        // Which CPU-specific flavor of algorithm to use.
        EnumPicClass            m_PicClass;
        H264SliceHeader         m_SliceHeader;
        H264SeqParamSet         m_SeqParamSet;
        H264PicParamSet         m_PicParamSet;
        EnumPicCodType          m_PicType;
        Ipp32u                  m_FrameNum;
        Ipp32s                  m_FrameNumGap;
        Ipp32s                  m_PicOrderCnt_Accu; // Accumulator to compensate POC resets on IDR frames.
        Ipp32u                  m_PicOrderCnt;
        Ipp32u                  m_PicOrderCntMsb;
        Ipp32u                  m_PicOrderCntLsb;
        Ipp32s                  m_FrameNumOffset;
        Ipp32u                  m_TopFieldPOC;
        Ipp32u                  m_BottomFieldPOC;

        bool use_implicit_weighted_bipred;

        Ipp16u uNumSlices;                  // Number of Slices in the Frame

        Ipp32u m_slice_length;                // Number of Macroblocks in each slice
        // Except the last slice which may have
        // more macroblocks.

        Ipp32u m_uSliceRemainder;         // Number of extra macroblocks in last slice.
    public:
        // ***************************************************************************
        // deblocking filter structs and functions
        // ***************************************************************************

        // Forward declaration of internal type(s)
        //template <class PixType> class DeblockingParameters;
        //template <class PixType> class DeblockingParametersMBAFF;

        // Perform deblocking on whole frame.
        // It is possible only for Baseline profile.
        void DeblockFrame(H264EncoderThreadPrivateSlice<PixType, CoeffsType> *curr_slice, Ipp32u uFirstMB,Ipp32u uNumMBs);
        // Perform deblocking on single slice
        void DeblockSlice(H264EncoderThreadPrivateSlice<PixType, CoeffsType> *curr_slice, Ipp32u uFirstMB, Ipp32u uNumMBs,
                          bool bLastSlice = false);
        // Non-optimized deblocking function
        void DeblockMacroblockCommon(Ipp32u MBAddr);

        //
        // Optimized deblocking functions
        //

        // Reset deblocking variables
        void ResetDeblockingVariables(DeblockingParameters<PixType> *pParams);
        void ResetDeblockingVariablesMBAFF(DeblockingParametersMBAFF<PixType> *pParams);
        // Function to do luma deblocking
        void DeblockLuma(Ipp32u dir, DeblockingParameters<PixType> *pParams);
        void DeblockLumaVerticalMBAFF(DeblockingParametersMBAFF<PixType> *pParams);
        void DeblockLumaHorizontalMBAFF(DeblockingParametersMBAFF<PixType> *pParams);
        // Function to do chroma deblocking
        void DeblockChroma(Ipp32u dir, DeblockingParameters<PixType> *pParams);
        void DeblockChromaVerticalMBAFF(DeblockingParametersMBAFF<PixType> *pParams);
        void DeblockChromaHorizontalMBAFF(DeblockingParametersMBAFF<PixType> *pParams);
        // Function to prepare deblocking parameters for mixed MB types
        void DeblockMacroblockMSlice(Ipp32u MBAddr);

        //
        // Function to do deblocking on I slices
        //

        void DeblockMacroblockISlice(Ipp32u MBAddr);
        void PrepareDeblockingParametersISlice(DeblockingParameters<PixType> *pParams);
        void DeblockMacroblockISliceMBAFF(Ipp32u MBAddr);
        void PrepareDeblockingParametersISliceMBAFF(DeblockingParametersMBAFF<PixType> *pParams);

        //
        // Function to do deblocking on P slices
        //

        void DeblockMacroblockPSlice(Ipp32u MBAddr);
        void DeblockMacroblockPSliceMBAFF(Ipp32u MBAddr);
        void PrepareDeblockingParametersPSlice(DeblockingParameters<PixType> *pParams);
        void PrepareDeblockingParametersPSliceMBAFF(DeblockingParametersMBAFF<PixType> *pParams);
        // Prepare deblocking parameters for macroblocks from P slice
        // MbPart is 16, MbPart of opposite direction is 16
        void PrepareDeblockingParametersPSlice16(Ipp32u dir, DeblockingParameters<PixType> *pParams);
        // Prepare deblocking parameters for macroblocks from P slice
        // MbPart is 8, MbPart of opposite direction is 16
        void PrepareDeblockingParametersPSlice8x16(Ipp32u dir, DeblockingParameters<PixType> *pParams);
        // Prepare deblocking parameters for macroblocks from P slice
        // MbPart is 16, MbPart of opposite direction is 8
        void PrepareDeblockingParametersPSlice16x8(Ipp32u dir, DeblockingParameters<PixType> *pParams);
        // Prepare deblocking parameters for macroblocks from P slice
        // MbParts of both directions are 4
        void PrepareDeblockingParametersPSlice4(Ipp32u dir, DeblockingParameters<PixType> *pParams);
        void PrepareDeblockingParametersPSlice4MBAFFField(Ipp32u dir, DeblockingParameters<PixType> *pParams);
        // Prepare deblocking parameters for macroblock from P slice,
        // which coded in frame mode, but above macroblock is coded in field mode
        void PrepareDeblockingParametersPSlice4MBAFFMixedExternalEdge(DeblockingParameters<PixType> *pParams);
        // Prepare deblocking parameters for macroblock from P slice,
        // which coded in frame mode, but left macroblock is coded in field mode
        void PrepareDeblockingParametersPSlice4MBAFFComplexFrameExternalEdge(DeblockingParametersMBAFF<PixType> *pParams);
        // Prepare deblocking parameters for macroblock from P slice,
        // which coded in field mode, but left macroblock is coded in frame mode
        void PrepareDeblockingParametersPSlice4MBAFFComplexFieldExternalEdge(DeblockingParametersMBAFF<PixType> *pParams);

        //
        // Function to do deblocking on B slices
        //

        void DeblockMacroblockBSlice(Ipp32u MBAddr);
        void DeblockMacroblockBSliceMBAFF(Ipp32u MBAddr);
        void PrepareDeblockingParametersBSlice(DeblockingParameters<PixType> *pParams);
        void PrepareDeblockingParametersBSliceMBAFF(DeblockingParametersMBAFF<PixType> *pParams);
        // Prepare deblocking parameters for macroblocks from B slice
        // MbPart is 16, MbPart of opposite direction is 16
        void PrepareDeblockingParametersBSlice16(Ipp32u dir, DeblockingParameters<PixType> *pParams);
        // Prepare deblocking parameters for macroblocks from B slice
        // MbPart is 8, MbPart of opposite direction is 16
        void PrepareDeblockingParametersBSlice8x16(Ipp32u dir, DeblockingParameters<PixType> *pParams);
        // Prepare deblocking parameters for macroblocks from B slice
        // MbPart is 16, MbPart of opposite direction is 8
        void PrepareDeblockingParametersBSlice16x8(Ipp32u dir, DeblockingParameters<PixType> *pParams);
        // Prepare deblocking parameters for macroblocks from B slice
        // MbParts of both directions are 4
        void PrepareDeblockingParametersBSlice4(Ipp32u dir, DeblockingParameters<PixType> *pParams);
        void PrepareDeblockingParametersBSlice4MBAFFField(Ipp32u dir, DeblockingParameters<PixType> *pParams);

        // forward declaration of internal types
        typedef void (H264CoreEncoder<PixType, CoeffsType>::*DeblockingFunction)(Ipp32u nMBAddr);

        // Update limited slice info array
        Status UpdateLimitedSliceInfo(H264EncoderThreadPrivateSlice<PixType, CoeffsType> *curr_slice);
        Ipp32u m_nAllocatedLimitedSliceInfo;
        H264LimitedSliceHeader *m_pLimitedSliceInfo;

        Ipp32u *m_EmptyThreshold; // empty block threshold table.
        Ipp32u *m_DirectBSkipMEThres;
        Ipp32u *m_PSkipMEThres;
        Ipp32s *m_BestOf5EarlyExitThres;

        // ***************************************************************************
        // Rate control related fields.
        // ***************************************************************************

        Ipp64f  FrameRate;
        Ipp32s  BitRate;
        Ipp32s  qscale[3];             // qscale codes for 3 frame types (Ipp32s!)
        Ipp32s  m_DirectTypeStat[2];
//f
        H264_AVBR avbr;
#ifdef H264_STAT
        H264FramesStat hstats;
#endif
    };

#if (!(defined(__GNUC__) && defined(__APPLE__) && !defined(__ICC)))
template<class PixType, class CoeffsType>
inline Ipp8s H264CoreEncoder<PixType,CoeffsType>::GetReferenceField(Ipp8s *pFields,Ipp8s RefIndex)
{
    if (RefIndex<0) return -1;
    else{
                VM_ASSERT(pFields[RefIndex]>=0);
                return pFields[RefIndex];
    }
}

//////////////////////////////////////////////////////////////////////////////
// GetRefPicList
// Returns pointer to ref pic lists struct.
//////////////////////////////////////////////////////////////////////////////
template<class PixType, class CoeffsType>
inline EncoderRefPicListStruct<PixType>* H264CoreEncoder<PixType, CoeffsType>::GetRefPicList(H264EncoderThreadPrivateSlice<PixType, CoeffsType> *curr_slice, Ipp32u List,Ipp32s mb_cod_type,Ipp32s is_bottom_mb)
{
    EncoderRefPicListStruct<PixType> *pList;
    if (List == LIST_0)
        pList = &curr_slice->m_TempRefPicList[mb_cod_type][is_bottom_mb].m_RefPicListL0;
    else
        pList = &curr_slice->m_TempRefPicList[mb_cod_type][is_bottom_mb].m_RefPicListL1;
    return pList;
}    // RefPicLists
#endif

} // namespace UMC_H264_ENCODER

#endif // UMC_H264_CORE_ENC_H__

⌨️ 快捷键说明

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