?? mc.cpp
字號:
/*************************************************************************
This software module was originally developed by
Ming-Chieh Lee (mingcl@microsoft.com), Microsoft Corporation
Bruce Lin (blin@microsoft.com), Microsoft Corporation
Simon Winder (swinder@microsoft.com), Microsoft Corporation
(date: June, 1997)
and edited by
Wei Wu (weiwu@stallion.risc.rockwell.com) Rockwell Science Center
and also edited by
Mathias Wien (wien@ient.rwth-aachen.de) RWTH Aachen / Robert BOSCH GmbH
and also edited by
Yoshinori Suzuki (Hitachi, Ltd.)
and also edited by
Hideaki Kimata (NTT)
and also edited by
Fujitsu Laboratories Ltd. (contact: Eishi Morimatsu)
Sehoon Son (shson@unitel.co.kr) Samsung AIT
in the course of development of the MPEG-4 Video (ISO/IEC 14496-2).
This software module is an implementation of a part of one or more MPEG-4 Video tools
as specified by the MPEG-4 Video.
ISO/IEC gives users of the MPEG-4 Video free license to this software module or modifications
thereof for use in hardware or software products claiming conformance to the MPEG-4 Video.
Those intending to use this software module in hardware or software products are advised that its use may infringe existing patents.
The original developer of this software module and his/her company,
the subsequent editors and their companies,
and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation.
Copyright is not released for non MPEG-4 Video conforming products.
Microsoft retains full right to use the code for his/her own purpose,
assign or donate the code to a third party and to inhibit third parties from using the code for non <MPEG standard> conforming products.
This copyright notice must be included in all copies or derivative works.
Copyright (c) 1996, 1997.
Module Name:
mc.cpp
Abstract:
Motion compensation routines (common for encoder and decoder).
Revision History:
December 20, 1997 Interlaced tools added by NextLevel Systems (GI)
X. Chen (xchen@nlvl.com) B. Eifrig (beifrig@nlvl.com)
Feb.16 1999 add Quarter Sample
Mathias Wien (wien@ient.rwth-aachen.de)
Feb.23 1999 GMC added by Yoshinori Suzuki (Hitachi, Ltd.)
Aug.24, 1999 : NEWPRED added by Hideaki Kimata (NTT)
Sep.06 1999 : RRV added by Eishi Morimatsu (Fujitsu Laboratories Ltd.)
*************************************************************************/
#include <stdio.h>
#include "typeapi.h"
#include "codehead.h"
#include "mode.hpp"
#include "vopses.hpp"
#include "global.hpp"
// NEWPRED
//#include "entropy/bitstrm.hpp"
#include "newpred.hpp"
// ~NEWPRED
// RRV insertion
#include "rrv.hpp"
// ~RRV
#ifdef __MFC_
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
#define new DEBUG_NEW
#endif // __MFC_
Void CVideoObject::limitMVRangeToExtendedBBFullPel (CoordI &x,CoordI &y,CRct *prct,Int iBlkSize)
{
if(prct==NULL)
return;
if(x < prct->left)
x=prct->left;
else if(x > (prct->right-iBlkSize))
x=(prct->right-iBlkSize);
if(y < prct->top)
y=prct->top;
else if(y > (prct->bottom-iBlkSize))
y=(prct->bottom-iBlkSize);
}
Void CVideoObject::limitMVRangeToExtendedBBHalfPel (CoordI &x,CoordI &y,CRct *prct,Int iBlkSize)
{
if(prct==NULL)
return;
if(x < prct->left*2)
x=prct->left*2;
else if(x > (prct->right-iBlkSize)*2)
x=(prct->right-iBlkSize)*2;
if(y < prct->top*2)
y=prct->top*2;
else if(y > (prct->bottom-iBlkSize)*2)
y=(prct->bottom-iBlkSize)*2;
}
// Quarter sample
Void CVideoObject::limitMVRangeToExtendedBBQuarterPel (CoordI &x,CoordI &y,CRct *prct,Int iBlkSize)
{
if(prct==NULL)
return;
Int iBlkSizeX, iBlkSizeY;
if (iBlkSize == 0) {
iBlkSizeX = MB_SIZE;
iBlkSizeY = MB_SIZE; // Field vectors are given in frame coordinates
}
else {
iBlkSizeX = iBlkSize;
iBlkSizeY = iBlkSize;
}
if( x < (prct->left + EXPANDY_REFVOP - iBlkSizeX)*4)
x = (prct->left + EXPANDY_REFVOP - iBlkSizeX)*4;
else if (x > (prct->right - EXPANDY_REFVOP)*4)
x = (prct->right - EXPANDY_REFVOP)*4;
if( y < (prct->top + EXPANDY_REFVOP - iBlkSizeY)*4)
y = (prct->top + EXPANDY_REFVOP - iBlkSizeY)*4;
else if (y > (prct->bottom - EXPANDY_REFVOP)*4)
y = (prct->bottom - EXPANDY_REFVOP)*4;
}
// ~Quarter sample
Void CVideoObject::motionCompMB (
PixelC* ppxlcPredMB,
const PixelC* ppxlcRefLeftTop,
const CMotionVector* pmv, const CMBMode* pmbmd,
Int imbX, Int imbY,
CoordI x, CoordI y,
Bool bSkipNonOBMC,
Bool bAlphaMB,
CRct *prctMVLimit
)
{
// RRV insertion
PixelC *pc_block16x16;
if(m_vopmd.RRVmode.iRRVOnOff == 1)
{
pc_block16x16= new PixelC[256];
}
// ~RRV
if (!bAlphaMB && !m_volmd.bAdvPredDisable && !pmbmd->m_bFieldMV && !pmbmd->m_bMCSEL) { // GMC
motionCompOverLap (
ppxlcPredMB, ppxlcRefLeftTop,
pmv, pmbmd,
imbX, imbY,
x, y,
prctMVLimit
);
}
else {
if (bSkipNonOBMC && !pmbmd -> m_bMCSEL) // GMC
return;
if (!pmbmd -> m_bhas4MVForward && !pmbmd -> m_bFieldMV && !pmbmd -> m_bMCSEL) // GMC
if (m_volmd.bQuarterSample) // Quarter sample
motionCompQuarterSample (ppxlcPredMB, ppxlcRefLeftTop, MB_SIZE,
x * 4 + pmv->trueMVHalfPel ().x,
y * 4 + pmv->trueMVHalfPel ().y,
m_vopmd.iRoundingControl, prctMVLimit);
else
// RRV modification
if(m_vopmd.RRVmode.iRRVOnOff == 1)
{
motionComp(ppxlcPredMB, ppxlcRefLeftTop,
(MB_SIZE *2),
x * 2 + pmv->trueMVHalfPel_x2 ().x,
y * 2 + pmv->trueMVHalfPel_x2 ().y,
m_vopmd.iRoundingControl,
prctMVLimit);
}
else
{
motionComp(ppxlcPredMB, ppxlcRefLeftTop,
MB_SIZE,
x * 2 + pmv->trueMVHalfPel ().x,
y * 2 + pmv->trueMVHalfPel ().y ,
m_vopmd.iRoundingControl,
prctMVLimit);
}
// motionComp (
// ppxlcPredMB, ppxlcRefLeftTop,
// MB_SIZE,
// x * 2 + pmv->trueMVHalfPel ().x,
// y * 2 + pmv->trueMVHalfPel ().y ,
// m_vopmd.iRoundingControl,
// prctMVLimit
// );
// ~RRV
else if (pmbmd -> m_bFieldMV) {
const CMotionVector* pmv16x8 = pmv+5;
if(pmbmd->m_bForwardTop) {
pmv16x8++;
if (m_volmd.bQuarterSample) // Quarter sample
motionCompQuarterSample (
ppxlcPredMB,
ppxlcRefLeftTop+m_iFrameWidthY,
0,
x * 4 + pmv16x8->trueMVHalfPel ().x,
y * 4 + pmv16x8->trueMVHalfPel ().y,
m_vopmd.iRoundingControl, prctMVLimit
);
else
motionCompYField (
ppxlcPredMB,
ppxlcRefLeftTop+m_iFrameWidthY,
x * 2 + pmv16x8->trueMVHalfPel ().x,
y * 2 + pmv16x8->trueMVHalfPel ().y,
prctMVLimit); // added by Y.Suzuki for the extended bounding box support
pmv16x8++;
}
else {
if (m_volmd.bQuarterSample) // Quarter sample
motionCompQuarterSample (
ppxlcPredMB,
ppxlcRefLeftTop,
0,
x * 4 + pmv16x8->trueMVHalfPel ().x,
y * 4 + pmv16x8->trueMVHalfPel ().y,
m_vopmd.iRoundingControl, prctMVLimit
);
else
motionCompYField (
ppxlcPredMB,
ppxlcRefLeftTop,
x * 2 + pmv16x8->trueMVHalfPel ().x,
y * 2 + pmv16x8->trueMVHalfPel ().y,
prctMVLimit); // added by Y.Suzuki for the extended bounding box support
pmv16x8++;
pmv16x8++;
}
if(pmbmd->m_bForwardBottom) {
pmv16x8++;
if (m_volmd.bQuarterSample) // Quarter sample
motionCompQuarterSample (
ppxlcPredMB+MB_SIZE,
ppxlcRefLeftTop+m_iFrameWidthY,
0,
x * 4 + pmv16x8->trueMVHalfPel ().x,
y * 4 + pmv16x8->trueMVHalfPel ().y,
m_vopmd.iRoundingControl, prctMVLimit
);
else
motionCompYField (
ppxlcPredMB+MB_SIZE,
ppxlcRefLeftTop+m_iFrameWidthY,
x * 2 + pmv16x8->trueMVHalfPel ().x,
y * 2 + pmv16x8->trueMVHalfPel ().y,
prctMVLimit); // added by Y.Suzuki for the extended bounding box support
}
else {
if (m_volmd.bQuarterSample) // Quarter sample
motionCompQuarterSample (
ppxlcPredMB+MB_SIZE,
ppxlcRefLeftTop,
0,
x * 4 + pmv16x8->trueMVHalfPel ().x,
y * 4 + pmv16x8->trueMVHalfPel ().y,
m_vopmd.iRoundingControl, prctMVLimit
);
else
motionCompYField (
ppxlcPredMB+MB_SIZE,
ppxlcRefLeftTop,
x * 2 + pmv16x8->trueMVHalfPel ().x,
y * 2 + pmv16x8->trueMVHalfPel ().y,
prctMVLimit); // added by Y.Suzuki for the extended bounding box support
}
}
// GMC
else if(pmbmd -> m_bMCSEL){
FindGlobalPredForGMC (x,y,ppxlcPredMB,ppxlcRefLeftTop);
}
// ~GMC
else {
const CMotionVector* pmv8 = pmv;
pmv8++;
// RRV modification
CoordI blkX, blkY;
if(m_vopmd.RRVmode.iRRVOnOff == 1)
{
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -