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

📄 umc_h264_segment_decoder.h

📁 audio-video-codecs.rar语音编解码器
💻 H
📖 第 1 页 / 共 2 页
字号:
/*
//
//              INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license  agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in  accordance  with the terms of that agreement.
//    Copyright (c) 2003-2007 Intel Corporation. All Rights Reserved.
//
//
*/
#include "umc_defs.h"
#if defined (UMC_ENABLE_H264_VIDEO_DECODER)

#ifndef __UMC_H264_SEGMENT_DECODER_H
#define __UMC_H264_SEGMENT_DECODER_H

#include "umc_h264_dec.h"
#include "umc_h264_slice_decoding.h"
#include "umc_h264_dec_tables.h"

#include "umc_h264_thread.h"
#include "umc_h264_frame.h"

using namespace UMC_H264_DECODER;

namespace UMC
{

struct DeblockingParameters;
struct DeblockingParametersMBAFF;
struct H264SliceHeader;
class TaskBroker;


//
// Class to incapsulate functions, implementing common decoding functional.
//

STRUCT_DECLSPEC_ALIGN class H264SegmentDecoder : public H264Thread
{
public:
    ReferenceFlags *(m_pFields[2]);
    H264DecoderFrame **(m_pRefPicList[2]);

    bool m_IsUseConstrainedIntra;
    bool m_IsUseDirect8x8Inference;
    bool m_IsBSlice;

    bool m_isMBAFF;
    Ipp32u m_uPitchLuma;
    Ipp32u m_uPitchChroma;

    Ipp8u *m_pYPlane;
    Ipp8u *m_pUPlane;
    Ipp8u *m_pVPlane;

    Ipp32s m_MBSkipCount;
    Ipp32s m_QuantPrev;

    bool m_IsUseSpatialDirectMode;
    Ipp32s m_MVDistortion[2];
    Ipp32s original_mb_type;

public:
    // Default constructor
    H264SegmentDecoder(TaskBroker * pTaskBroker);
    // Destructor
    virtual
    ~H264SegmentDecoder(void);

    // Initialize object
    virtual
    Status Init(Ipp32s iNumber);

    // Decode slice's segment
    virtual
    Status ProcessSegment(void) = 0;

    virtual Status ProcessSlice(Ipp32s nCurMBNumber, Ipp32s &nMBToProcess) = 0;
    Status DeblockSlice(Ipp32s nCurMBNumber, Ipp32s &nMBToDeblock);

//protected:
    // Release object
    void Release(void);

    // Update info about current MB
    void UpdateCurrentMBInfo();
    void AdjustIndex(Ipp32s ref_mb_is_bottom, Ipp32s ref_mb_is_field, Ipp8s &RefIdx);
    // Update neighbour's addresses
    inline void UpdateNeighbouringAddresses(Ipp32s IgnoreSliceEdges = 0);

    inline
    void UpdateNeighbouringAddressesField(void);

    inline void UpdateNeighbouringBlocksBMEH(Ipp32s DeblockCalls = 0);
    inline void UpdateNeighbouringBlocksH2(Ipp32s DeblockCalls = 0);
    inline void UpdateNeighbouringBlocksH4(Ipp32s DeblockCalls = 0);

    void DecodeEdgeType();
    void ReconstructEdgeType(Ipp8u &edge_type_2t, Ipp8u &edge_type_2b, Ipp32s &special_MBAFF_case);

    // Get context functions
    inline
    Ipp32u GetDCBlocksLumaContext();

    // an universal function for an every case of the live
    inline
    Ipp32u GetBlocksLumaContext(Ipp32s x,Ipp32s y);

    // a function for the first luma block in a macroblock
    inline
    Ipp32s GetBlocksLumaContextExternal(void);

    // a function for a block on the upper edge of a macroblock,
    // but not for the first block
    inline
    Ipp32s GetBlocksLumaContextTop(Ipp32s x, Ipp32s left_coeffs);

    // a function for a block on the left edge of a macroblock,
    // but not for the first block
    inline
    Ipp32u GetBlocksLumaContextLeft(Ipp32s y, Ipp32s above_coeffs);

    // a function for any internal block of a macroblock
    inline
    Ipp32u GetBlocksLumaContextInternal(Ipp32s x, Ipp32s y, Ipp8u *pNumCoeffsArray);

    // an universal function for an every case of the live
    inline
    Ipp32u GetBlocksChromaContextBMEH(Ipp32s x,Ipp32s y,Ipp32s component);

    // a function for the first block in a macroblock
    inline
    Ipp32s GetBlocksChromaContextBMEHExternal(Ipp32s iComponent);

    // a function for a block on the upper edge of a macroblock,
    // but not for the first block
    inline
    Ipp32s GetBlocksChromaContextBMEHTop(Ipp32s x, Ipp32s left_coeffs, Ipp32s iComponent);

    // a function for a block on the left edge of a macroblock,
    // but not for the first block
    inline
    Ipp32s GetBlocksChromaContextBMEHLeft(Ipp32s y, Ipp32s above_coeffs, Ipp32s iComponent);

    // a function for any internal block of a macroblock
    inline
    Ipp32s GetBlocksChromaContextBMEHInternal(Ipp32s x, Ipp32s y, Ipp8u *pNumCoeffsArray);

    inline
    Ipp32u GetBlocksChromaContextH2(Ipp32s x,Ipp32s y,Ipp32s component);

    inline
    Ipp32u GetBlocksChromaContextH4(Ipp32s x,Ipp32s y,Ipp32s component);

    // Decode macroblock type
    void DecodeMacroBlockType(IntraType *pMBIntraTypes, Ipp32s *MBSkipCount, Ipp32s *PassFDFDecode);
    void DecodeMBTypeISlice_CABAC(void);
    void DecodeMBTypeISlice_CAVLC(void);
    void DecodeMBTypePSlice_CABAC(void);
    void DecodeMBTypePSlice_CAVLC(void);
    void DecodeMBTypeBSlice_CABAC(void);
    void DecodeMBTypeBSlice_CAVLC(void);
    void DecodeMBFieldDecodingFlag_CABAC(void);
    void DecodeMBFieldDecodingFlag_CAVLC(void);
    void DecodeMBFieldDecodingFlag(void);

    // Decode intra block types
    void DecodeIntraTypes4x4_CAVLC(IntraType *pMBIntraTypes, bool bUseConstrainedIntra);
    void DecodeIntraTypes8x8_CAVLC(IntraType *pMBIntraTypes, bool bUseConstrainedIntra);
    void DecodeIntraTypes4x4_CABAC(IntraType *pMBIntraTypes, bool bUseConstrainedIntra);
    void DecodeIntraTypes8x8_CABAC(IntraType *pMBIntraTypes, bool bUseConstrainedIntra);
    void DecodeIntraPredChromaMode_CABAC(void);

    void DecodeMBQPDelta_CABAC(void);
    void DecodeMBQPDelta_CAVLC(void);

    // Get colocated location
    Ipp32s GetColocatedLocation(H264DecoderFrame *pRefFrame, Ipp32s Field, Ipp32s &block, Ipp32s *scale = NULL);
    // Decode motion vectors
    void DecodeDirectMotionVectorsTemporal(bool is_direct_mb);

    // Decode motion vectors
    void DecodeDirectMotionVectorsTemporal_8x8Inference();
    // Compute  direct spatial reference indexes
    void ComputeDirectSpatialRefIdx(Ipp32s *pRefIndexL0, Ipp32s *pRefIndexL1);
    void GetRefIdx4x4_CABAC(const Ipp32u nActive,
                              const Ipp8u* pBlkIdx,
                              const Ipp8u*  pCodRIx,
                              Ipp32u ListNum);
    void GetRefIdx4x4_CABAC(const Ipp32u nActive,
                              const Ipp8u  pCodRIx,
                              Ipp32u ListNum);
    void GetRefIdx4x4_16x8_CABAC(const Ipp32u nActive,
                                const Ipp8u*  pCodRIx,
                                Ipp32u ListNum);
    void GetRefIdx4x4_8x16_CABAC(const Ipp32u nActive,
                                const Ipp8u*  pCodRIx,
                                Ipp32u ListNum);

    Ipp32s GetSE_RefIdx_CABAC(Ipp32u ListNum, Ipp32u BlockNum);

    H264DecoderMotionVector GetSE_MVD_CABAC(Ipp32u ListNum, Ipp32u BlockNum);

    // Get direct motion vectors
    void GetDirectTemporalMV(Ipp32s MBCol,
                             Ipp32u ipos,
                             H264DecoderMotionVector *& MVL0, // return colocated MV here
                             Ipp8s &RefIndexL0); // return ref index here
    void GetDirectTemporalMVFLD(Ipp32s MBCol,
                                Ipp32u ipos,
                                H264DecoderMotionVector *& MVL0, // return colocated MV here
                                Ipp8s &RefIndexL0); // return ref index here
    void GetDirectTemporalMVMBAFF(Ipp32s MBCol,
                                  Ipp32u ipos,
                                  H264DecoderMotionVector *& MVL0, // return colocated MV here
                                  Ipp8s &RefIndexL0); // return ref index here
    // Decode and return the coded block pattern.
    // Return 255 is there is an error in the CBP.
    Ipp32u DecodeCBP_CAVLC(Ipp32u color_format);
    Ipp32u DecodeCBP_CABAC(Ipp32u color_format);

    // Decode motion vector predictors
    void ComputeMotionVectorPredictors(Ipp8u ListNum,
                                       Ipp8s RefIndex, // reference index for this part
                                       Ipp32s block, // block or subblock number, depending on mbtype
                                       Ipp32s *pMVx, // resulting MV predictors
                                       Ipp32s *pMVy);
    // Decode slipped MB
    Ipp32u DecodeMBSkipFlag_CABAC(Ipp32s ctxIdx);
    Ipp32u DecodeMBSkipRun_CAVLC(void);

    // Get location functions
    void GetLeftLocationForCurrentMBLumaMBAFF(H264DecoderBlockLocation *Block,Ipp32s AdditionalDecrement=0);
    void GetTopLocationForCurrentMBLumaMBAFF(H264DecoderBlockLocation *Block,Ipp32s DeblockCalls);
    void GetTopLeftLocationForCurrentMBLumaMBAFF(H264DecoderBlockLocation *Block);
    void GetTopRightLocationForCurrentMBLumaMBAFF(H264DecoderBlockLocation *Block);
    void GetLeftLocationForCurrentMBLumaNonMBAFF(H264DecoderBlockLocation *Block);

⌨️ 快捷键说明

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