📄 mbdataaccess.h
字号:
/*
********************************************************************************
NOTE - One of the two copyright statements below may be chosen
that applies for the software.
********************************************************************************
This software module was originally developed by
Heiko Schwarz (Fraunhofer HHI),
Tobias Hinz (Fraunhofer HHI),
Karsten Suehring (Fraunhofer HHI)
in the course of development of the ISO/IEC 14496-10:2005 Amd.1 (Scalable Video
Coding) for reference purposes and its performance may not have been optimized.
This software module is an implementation of one or more tools as specified by
the ISO/IEC 14496-10:2005 Amd.1 (Scalable Video Coding).
Those intending to use this software module in products are advised that its
use may infringe existing patents. ISO/IEC have no liability for use of this
software module or modifications thereof.
Assurance that the originally developed software module can be used
(1) in the ISO/IEC 14496-10:2005 Amd.1 (Scalable Video Coding) once the
ISO/IEC 14496-10:2005 Amd.1 (Scalable Video Coding) has been adopted; and
(2) to develop the ISO/IEC 14496-10:2005 Amd.1 (Scalable Video Coding):
To the extent that Fraunhofer HHI owns patent rights that would be required to
make, use, or sell the originally developed software module or portions thereof
included in the ISO/IEC 14496-10:2005 Amd.1 (Scalable Video Coding) in a
conforming product, Fraunhofer HHI will assure the ISO/IEC that it is willing
to negotiate licenses under reasonable and non-discriminatory terms and
conditions with applicants throughout the world.
Fraunhofer HHI retains full right to modify and use the code for its own
purpose, assign or donate the code to a third party and to inhibit third
parties from using the code for products that do not conform to MPEG-related
ITU Recommendations and/or ISO/IEC International Standards.
This copyright notice must be included in all copies or derivative works.
Copyright (c) ISO/IEC 2005.
********************************************************************************
COPYRIGHT AND WARRANTY INFORMATION
Copyright 2005, International Telecommunications Union, Geneva
The Fraunhofer HHI hereby donate this source code to the ITU, with the following
understanding:
1. Fraunhofer HHI retain the right to do whatever they wish with the
contributed source code, without limit.
2. Fraunhofer HHI retain full patent rights (if any exist) in the technical
content of techniques and algorithms herein.
3. The ITU shall make this code available to anyone, free of license or
royalty fees.
DISCLAIMER OF WARRANTY
These software programs are available to the user without any license fee or
royalty on an "as is" basis. The ITU disclaims any and all warranties, whether
express, implied, or statutory, including any implied warranties of
merchantability or of fitness for a particular purpose. In no event shall the
contributor or the ITU be liable for any incidental, punitive, or consequential
damages of any kind whatsoever arising from the use of these programs.
This disclaimer of warranty extends to the user of these programs and user's
customers, employees, agents, transferees, successors, and assigns.
The ITU does not represent or warrant that the programs furnished hereunder are
free of infringement of any third-party patents. Commercial implementations of
ITU-T Recommendations, including shareware, may be subject to royalty fees to
patent holders. Information regarding the ITU-T patent policy is available from
the ITU Web site at http://www.itu.int.
THIS IS NOT A GRANT OF PATENT RIGHTS - SEE THE ITU-T PATENT POLICY.
********************************************************************************
*/
#if !defined(AFX_MBDATAACCESS_H__710205A4_CFE9_496D_A469_C47EC8D2FBD2__INCLUDED_)
#define AFX_MBDATAACCESS_H__710205A4_CFE9_496D_A469_C47EC8D2FBD2__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "H264AVCCommonLib/SliceHeader.h"
#include "H264AVCCommonLib/MbData.h"
#include "H264AVCCommonLib/Tables.h"
H264AVC_NAMESPACE_BEGIN
class H264AVCCOMMONLIB_API MbDataAccess
{
private:
enum PredictionType
{
PRED_A,
PRED_B,
PRED_C,
MEDIAN
};
public:
Void *operator new( size_t stAllocateBlock, Void* pv )
{
return ( NULL == pv ) ? (::operator new( stAllocateBlock )) : pv;
}
MbDataAccess( MbDataAccess& rcMbDataAccess, MbData& rcMbData ) :
m_rcMbCurr( rcMbData ),
m_rcMbLeft( rcMbDataAccess.m_rcMbLeft ),
m_rcMbAbove( rcMbDataAccess.m_rcMbAbove ),
m_rcMbAboveLeft( rcMbDataAccess.m_rcMbAboveLeft ),
m_rcMbAboveRight( rcMbDataAccess.m_rcMbAboveRight ),
m_rcMbUnavailable( rcMbDataAccess.m_rcMbUnavailable ),
m_rcMbColocated( rcMbDataAccess.m_rcMbColocated ),
m_rcSliceHeader( rcMbDataAccess.m_rcSliceHeader ),
m_rcDFP( rcMbDataAccess.m_rcDFP ),
m_cMv3D_A( rcMbDataAccess.m_cMv3D_A ),
m_cMv3D_B( rcMbDataAccess.m_cMv3D_B ),
m_cMv3D_C( rcMbDataAccess.m_cMv3D_C ),
m_uiAvailable( rcMbDataAccess.m_uiAvailable ),
m_uiPosX( rcMbDataAccess.m_uiPosX ),
m_uiPosY( rcMbDataAccess.m_uiPosY ),
m_ucLastMbQp( rcMbDataAccess.m_ucLastMbQp ),
m_pcMbDataAccessBase( rcMbDataAccess.m_pcMbDataAccessBase )
{
m_rcMbCurr.copyFrom( rcMbDataAccess.getMbData() );
}
MbDataAccess( MbData& rcMbCurr,
const MbData& rcMbLeft,
const MbData& rcMbAbove,
const MbData& rcMbAboveLeft,
const MbData& rcMbAboveRight,
const MbData& rcMbUnavailable,
const MbData& rcMbColocated,
SliceHeader& rcSliceHeader,
const DFP& rcDFP,
UInt uiPosX,
UInt uiPosY,
SChar ucLastMbQp )
: m_rcMbCurr ( rcMbCurr ),
m_rcMbLeft ( rcMbLeft ),
m_rcMbAbove ( rcMbAbove ),
m_rcMbAboveLeft ( rcMbAboveLeft ),
m_rcMbAboveRight ( rcMbAboveRight ),
m_rcMbUnavailable ( rcMbUnavailable ),
m_rcMbColocated ( rcMbColocated ),
m_rcSliceHeader ( rcSliceHeader ),
m_rcDFP ( rcDFP ),
m_cMv3D_A ( 0, 0, 0 ),
m_cMv3D_B ( 0, 0, 0 ),
m_cMv3D_C ( 0, 0, 0 ),
m_uiAvailable ( 0 ),
m_uiPosX ( uiPosX ),
m_uiPosY ( uiPosY ),
m_ucLastMbQp ( ucLastMbQp ),
m_pcMbDataAccessBase ( NULL )
{
xSetAvailableMask();
}
~MbDataAccess()
{
}
public:
const MbData& getMbData () const { return m_rcMbCurr; }
MbData& getMbData () { return m_rcMbCurr; }
const MbData& getMbDataCurr () const { return m_rcMbCurr; }
const MbData& getMbDataLeft () const { return m_rcMbLeft; }
const MbData& getMbDataAbove () const { return m_rcMbAbove; }
const MbData& getMbDataAboveLeft () const { return m_rcMbAboveLeft; }
UInt getNumActiveRef ( ListIdx eListIdx) const
{
return m_rcSliceHeader.getNumRefIdxActive( eListIdx );
}
UInt getConvertBlkMode ( Par8x8 ePar8x8 );
ErrVal setConvertBlkMode ( Par8x8 ePar8x8, UInt uiBlockMode );
UInt getConvertMbType ();
ErrVal setConvertMbType ( UInt uiMbType );
Bool isSkippedMb () const
{
ROTRS( m_rcSliceHeader.isIntra(), false );
if( m_rcSliceHeader.isInterB() )
{
return (m_rcMbCurr.getMbMode() == MODE_SKIP) &&
(m_rcMbCurr.getMbCbp () == 0) &&
#if JMVM_ONLY // JVT-W081
(m_rcMbCurr.getMotionSkipFlag() == false) &&
#endif // JVT-W081
#if JMVM_ONLY
//JVT-W031
( !m_rcSliceHeader.getIcEnable() || (m_rcSliceHeader.getIcEnable() && m_rcMbCurr.getSkipFlagTmp()) ) &&
#endif
!(m_rcMbCurr.getResidualPredFlag(PART_16x16));
}
return
#if JMVM_ONLY // JVT-W081
m_rcMbCurr.getMotionSkipFlag() == false &&
#endif // JVT-W081
m_rcMbCurr.getMbMode() == MODE_SKIP;
}
Void setLastQp ( Int iQp ) { m_ucLastMbQp = (UChar)iQp; }
Void addDeltaQp ( Int iDQp ) { m_rcMbCurr.setQp( (m_ucLastMbQp + iDQp+(MAX_QP+1)) % (MAX_QP+1) ); }
Void resetQp () { m_rcMbCurr.setQp( m_ucLastMbQp ); }
Int getDeltaQp () { return (m_rcMbCurr.getQp() - m_ucLastMbQp); }
UChar getLastQp () const { return m_ucLastMbQp; }
const SliceHeader& getSH () const { return m_rcSliceHeader;}
SliceHeader& getSH () { return m_rcSliceHeader;}
const MbTransformCoeffs& getMbTCoeffs () const { return m_rcMbCurr.getMbTCoeffs (); }
const MbMvData& getMbMvdData ( ListIdx eListIdx ) const { return m_rcMbCurr.getMbMvdData ( eListIdx ); }
const MbMotionData& getMbMotionData ( ListIdx eListIdx ) const { return m_rcMbCurr.getMbMotionData ( eListIdx ); }
MbTransformCoeffs& getMbTCoeffs () { return m_rcMbCurr.getMbTCoeffs (); }
MbMvData& getMbMvdData ( ListIdx eListIdx ) { return m_rcMbCurr.getMbMvdData ( eListIdx ); }
MbMotionData& getMbMotionData ( ListIdx eListIdx ) { return m_rcMbCurr.getMbMotionData ( eListIdx ); }
Int mostProbableIntraPredMode ( LumaIdx cIdx );
Int encodeIntraPredMode ( LumaIdx cIdx );
Int decodeIntraPredMode ( LumaIdx cIdx );
UInt getAvailableMask () const { return m_uiAvailable; }
Bool isAvailableLeft () const { return xIsAvailable( m_rcMbLeft ); }
Bool isAvailableAbove () const { B4x4Idx cIdx; return xIsAvailable( xGetBlockAbove( cIdx ) ); }
Bool isLeftMbExisting () const { return m_uiPosX != 0; }
Bool isAboveMbExisting () const { return ( ! ( m_uiPosY == 0 ) ); }
Bool isConstrainedInterLayerPred( )
{
return getSH().getBaseLayerUsesConstrainedIntraPred();
}
UInt getCtxChromaPredMode () const;
UInt getCtxCoeffCount ( LumaIdx cIdx ) const;
UInt getCtxCoeffCount ( ChromaIdx cIdx ) const;
UInt getCtxMbSkipped () const;
UInt getCtxBLSkipFlag () const;
#if JMVM_ONLY // JVT-W081
UInt getCtxMotionSkipFlag () const;
// JVT-W081
//JVT-Z021
UInt getCtxMotionSkipListXFlag() const;
Int getMbImsmListXFlagPred () const;
Void getMbImsmOffsetPred (Mv& iOffsetPred, ListIdx eListIdx) const;
Void getOffsetAbove (Mv& cMv, ListIdx eListIdx) const;
Void getOffsetLeft (Mv& cMv, ListIdx eListIdx) const;
ErrVal getOrgMbMotionInfo(FILE *fFwdMv,
FILE *fBwdMv,
GDV disparityL0,
GDV disparityL1,
UInt uiCodedFrames,
Bool bIsViewLevel1,
UInt uiMbInRow,
long sizeofMB,
long sizeofFrame);
ErrVal getOrgMbMotionInfo(GDV disparityL0, GDV disparityL1);
ErrVal getNewMbMotionInfo(GDV disparityL0, GDV disparityL1, Mv &cCenterL0, Mv &cCenterL1);
ErrVal GDVtoOrg(GDV disparity, Mv &cCenter);
ErrVal getCombinedMotionInfo(int iMode,const MBMotion *FMb,MBMotion &FMb_final);
ErrVal getNewMbMotionInfo(int iMode,const MBMotion *FMb,MBMotion &FMb_final, Bool bIsViewLevel1, ListIdx eListIdx);
ErrVal getPartMv(const MBMotion Org, MBMotion &Des,int NumOrg, int NumDes);
ErrVal MbMotionCopy(const MBMotion Src, MBMotion &Rst);
ErrVal MergeLR(const MBMotion SrcL, const MBMotion SrcR, MBMotion &Rst);
ErrVal MergeUB(const MBMotion SrcU, const MBMotion SrcB, MBMotion &Rst);
ErrVal Merge4Corner(const MBMotion SrcUL, const MBMotion SrcUR, const MBMotion SrcBL, const MBMotion SrcBR, MBMotion &Rst);
ErrVal getSingleMbMotionInfo(const MBMotion *FMb_RD_in, MBMotion& FMb, int i, int j, ListIdx eListIdx, Bool bIsViewLevel1);
#endif //JVT-W081, JVT-Z021
UInt getCtxDirectMbWoCoeff() const;
UInt getCtxCodedBlockBit ( UInt uiBitPos ) const;
UInt getCtxRefIdx ( ListIdx eLstIdx, ParIdx8x8 eParIdx ) const;
UInt getCtxMbIntra4x4 () const;
UInt getCtxMbType () const;
UInt getCtx8x8Flag () const;
UInt getLeftLumaCbp ( LumaIdx cIdx ) const;
UInt getAboveLumaCbp ( LumaIdx cIdx ) const;
UInt getLeftChromaCbp () const;
UInt getAboveChromaCbp () const;
UInt getAutoCbp () const;
UInt getLeftLumaCbpFGS ( LumaIdx cIdx ) const;
UInt getAboveLumaCbpFGS ( LumaIdx cIdx ) const;
UInt getLeftChromaCbpFGS () const;
UInt getAboveChromaCbpFGS () const;
Void getMvdLeft ( Mv& rcMv, ListIdx eListIdx, LumaIdx cIdx ) const;
Void getMvdAbove ( Mv& rcMv, ListIdx eListIdx, LumaIdx cIdx ) const;
Void getMvPredictor( Mv& rcMv, SChar scRef, ListIdx eListIdx );
Void getMvPredictor( Mv& rcMv, SChar scRef, ListIdx eListIdx, ParIdx16x8 eParIdx );
Void getMvPredictor( Mv& rcMv, SChar scRef, ListIdx eListIdx, ParIdx8x16 eParIdx );
Void getMvPredictor( Mv& rcMv, SChar scRef, ListIdx eListIdx, ParIdx8x8 eParIdx );
Void getMvPredictor( Mv& rcMv, SChar scRef, ListIdx eListIdx, ParIdx8x8 eParIdx, SParIdx8x4 eSParIdx );
Void getMvPredictor( Mv& rcMv, SChar scRef, ListIdx eListIdx, ParIdx8x8 eParIdx, SParIdx4x8 eSParIdx );
Void getMvPredictor( Mv& rcMv, SChar scRef, ListIdx eListIdx, ParIdx8x8 eParIdx, SParIdx4x4 eSParIdx );
Void setMvPredictorsBL( const Mv& rcMvBL, ListIdx eListIdx );
Void setMvPredictorsBL( const Mv& rcMvBL, ListIdx eListIdx, ParIdx16x8 eParIdx );
Void setMvPredictorsBL( const Mv& rcMvBL, ListIdx eListIdx, ParIdx8x16 eParIdx );
Void setMvPredictorsBL( const Mv& rcMvBL, ListIdx eListIdx, ParIdx8x8 eParIdx );
Void setMvPredictorsBL( const Mv& rcMvBL, ListIdx eListIdx, ParIdx8x8 eParIdx, SParIdx8x4 eSParIdx );
Void setMvPredictorsBL( const Mv& rcMvBL, ListIdx eListIdx, ParIdx8x8 eParIdx, SParIdx4x8 eSParIdx );
Void setMvPredictorsBL( const Mv& rcMvBL, ListIdx eListIdx, ParIdx8x8 eParIdx, SParIdx4x4 eSParIdx );
Void getMvPredictors ( Mv* pcMv ) const;
Void getMvPredictorSkipMode();
Void getMvPredictorSkipMode( Mv& cMvPred );
Bool getMvPredictorDirect ( ParIdx8x8 eParIdx, Bool& rbOneMv, Bool bFaultTolerant );
// TMM_EC {{
Bool getMvPredictorDirectVirtual ( ParIdx8x8 eParIdx, Bool& rbOneMv, Bool bFaultTolerant, RefFrameList& rcRefFrameListL0, RefFrameList& rcRefFrameListL1 );
// TMM_EC }}
#if JMVM_ONLY // JVT-U052
Void getIcpPredictor( Icp& rcIcp, ListIdx eListIdx, SChar scRefIdx );
Void getIcpPredictor( Icp& rcIcp, SChar scRefIdx0, SChar scRefIdx1 );
#endif
#if JMVM_ONLY // JVT-W081
Bool getMvPredictorMotionSkip( ParIdx8x8 eParIdx, RefFrameList& rcList0, RefFrameList& rcList1, MBMotion* FEView);
ErrVal deriveDisparity( MbDataAccess& rcMbDataAccess, GDV& disparity, GDV& gdv );
ErrVal xReadMbInfoFile ( FILE *MvRecon, class MBMotion* rMotionInfo, Mv disparity);
ErrVal xWriteMbInfoFile (MbDataAccess& rcMbDataAccess, RefFrameList* rcList0, RefFrameList* rcList1);
ErrVal xSaveNeighborMotion(MbDataAccess& rcMbDataAccess, MBMotion* FDView );
#endif // JVT-W081
const DFP& getDeblockingFilterParameter() const { return m_rcDFP; }
Void getMvSkipMode( Mv& rcMv )
{
xGetMvPredictor( rcMv, 1, LIST_0, MEDIAN, B4x4Idx(0), B4x4Idx(3) );
if( ( m_cMv3D_A.getRef()==BLOCK_NOT_AVAILABLE ||
m_cMv3D_B.getRef()==BLOCK_NOT_AVAILABLE ) ||
( m_cMv3D_A.getHor()==0 && m_cMv3D_A.getVer()==0 && m_cMv3D_A.getRef()==1 ) ||
( m_cMv3D_B.getHor()==0 && m_cMv3D_B.getVer()==0 && m_cMv3D_B.getRef()==1 ) )
{
rcMv.setZero();
}
}
MbDataAccess* getMbDataAccessBase() const { return m_pcMbDataAccessBase; }
Void setMbDataAccessBase( MbDataAccess* p ) { m_pcMbDataAccessBase = p; }
UInt getMbX() const { return m_uiPosX; }
UInt getMbY() const { return m_uiPosY; }
protected:
Void xSetMvPredictorsBL ( const Mv& rcMvPredBL, ListIdx eListIdx, LumaIdx cIdx, LumaIdx cIdxEnd );
Void xGetMvPredictor ( Mv& rcMvPred, SChar scRef, ListIdx eListIdx, PredictionType ePredType, LumaIdx cIdx, LumaIdx cIdxEnd );
Void xSetNeighboursMvPredictor ( ListIdx eListIdx, LumaIdx cIdx, LumaIdx cIdxEnd );
Void xGetMvPredictorUseNeighbours( Mv& rcMvPred, SChar scRef, PredictionType ePredType );
Void xSetAvailableMask ();
__inline const MbData& xGetMbLeft () const;
__inline const MbData& xGetMbAbove () const;
#if JMVM_ONLY // JVT-U052
__inline const MbData& xGetMbAboveRight () const;
__inline const MbData& xGetMbAboveLeft () const;
#endif
__inline const MbData& xGetBlockLeft ( LumaIdx& rcIdx ) const;
__inline const MbData& xGetBlockAbove ( LumaIdx& rcIdx ) const;
__inline const MbData& xGetBlockAboveLeft ( LumaIdx& cIdx ) const;
__inline const MbData& xGetBlockAboveRight ( LumaIdx& cIdx ) const;
__inline UInt xGetLeftCodedBlockBit ( UInt uiBit ) const;
__inline UInt xGetAboveCodedBlockBit ( UInt uiBit ) const;
__inline SChar xGetRefIdxLeft ( ListIdx eListIdx, ParIdx8x8 eParIdx ) const;
__inline SChar xGetRefIdxAbove( ListIdx eListIdx, ParIdx8x8 eParIdx ) const;
__inline Void xGetColocatedMvRefIdx ( Mv& rcMv, SChar& rscRefIdx, LumaIdx cIdx ) const;
__inline const RefPic& xGetColocatedMvRefPic ( Mv& rcMv, SChar& rscRefIdx, LumaIdx cIdx ) const;
__inline Void xGetColocatedMvsRefIdxNonInterlaced( Mv acMv[], SChar& rscRefIdx, ParIdx8x8 eParIdx ) const;
__inline const RefPic& xGetColocatedMvsRefPicNonInterlaced( Mv acMv[], SChar& rscRefIdx, ParIdx8x8 eParIdx ) const;
Void xSpatialDirectMode ( ParIdx8x8 eParIdx, Bool b8x8 );
Bool xTemporalDirectMode( ParIdx8x8 eParIdx, Bool b8x8, Bool bFaultTolerant );
Bool xTemporalDirectModeMvRef( Mv acMv[], SChar ascRefIdx[], LumaIdx cIdx, Bool bFaultTolerant );
Bool xTemporalDirectModeMvsRefNonInterlaced( Mv aacMv[][4], SChar ascRefIdx[], ParIdx8x8 eParIdx, Bool bFaultTolerant );
// TMM_EC {{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -