📄 vopses.cpp
字号:
m_ppxlcCurrMBBYDown4 = new PixelC [8 * 8];
m_ppxlcCurrMBBYDown2 = new PixelC [12 * 12];
m_ppxlcPredBABDown4 = new PixelC [6*6];
m_ppxlcPredBABDown2 = new PixelC [10*10];
}
// m_ppxlcPredMBA = new
// m_ppxliErrorMBA = new
// m_ppxlcPredMBBackA = new
}
Void CVideoObject::computeVOLConstMembers ()
{
m_iOffsetForPadY = m_rctRefFrameY.offset (m_rctCurrVOPY.left, m_rctCurrVOPY.top);
m_iOffsetForPadUV = m_rctRefFrameUV.offset (m_rctCurrVOPUV.left, m_rctCurrVOPUV.top);
m_rctPrevNoExpandY = m_rctCurrVOPY;
m_rctPrevNoExpandUV = m_rctCurrVOPUV;
m_iVOPWidthY = m_rctCurrVOPY.width;
m_iVOPWidthUV = m_rctCurrVOPUV.width;
m_iNumMBX = m_iNumMBXRef = m_iVOPWidthY / MB_SIZE;
m_iNumMBY = m_iNumMBYRef = m_rctCurrVOPY.height () / MB_SIZE;
m_iNumMB = m_iNumMBRef = m_iNumMBX * m_iNumMBY;
m_iNumOfTotalMVPerRow = PVOP_MV_PER_REF_PER_MB * m_iNumMBX;
setRefStartingPointers ();
m_pvopcCurrQ->setBoundRct (m_rctCurrVOPY);
m_pvopcRefQ0->setBoundRct (m_rctRefVOPY0);
m_pvopcRefQ1->setBoundRct (m_rctRefVOPY1);
Int iMB, iBlk;
Int nBlk = (m_volmd.fAUsage == EIGHT_BIT) ? 6+m_volmd.iAuxCompCount*4 : 6;
m_rgblkmCurrMB = new BlockMemory [nBlk];
m_rgpmbmAbove = new MacroBlockMemory* [m_iNumMBX];
m_rgpmbmCurr = new MacroBlockMemory* [m_iNumMBX];
for (iMB = 0; iMB < m_iNumMBX; iMB++) {
m_rgpmbmAbove [iMB] = new MacroBlockMemory;
m_rgpmbmAbove [iMB]->rgblkm = new BlockMemory [nBlk];
m_rgpmbmCurr [iMB] = new MacroBlockMemory;
m_rgpmbmCurr [iMB]->rgblkm = new BlockMemory [nBlk];
for (iBlk = 0; iBlk < nBlk; iBlk++) {
(m_rgpmbmAbove [iMB]->rgblkm) [iBlk] = new Int [(BLOCK_SIZE << 1) - 1];
(m_rgpmbmCurr [iMB]->rgblkm) [iBlk] = new Int [(BLOCK_SIZE << 1) - 1];
}
}
}
Void CVideoObject::computeVOPMembers ()
{
m_iVOPWidthY = m_rctCurrVOPY.width;
m_iVOPWidthUV = m_rctCurrVOPUV.width;
m_iNumMBX = m_iVOPWidthY / MB_SIZE;
m_iNumMBY = m_rctCurrVOPY.height () / MB_SIZE;
m_iNumMB = m_iNumMBX * m_iNumMBY;
m_iNumOfTotalMVPerRow = PVOP_MV_PER_REF_PER_MB * m_iNumMBX;
Int iMB, iBlk;
Int nBlk = (m_volmd.fAUsage == EIGHT_BIT) ? 6+m_volmd.iAuxCompCount*4 : 6;
m_rgblkmCurrMB = new BlockMemory [nBlk];
m_rgpmbmAbove = new MacroBlockMemory* [m_iNumMBX];
m_rgpmbmCurr = new MacroBlockMemory* [m_iNumMBX];
for (iMB = 0; iMB < m_iNumMBX; iMB++) {
m_rgpmbmAbove [iMB] = new MacroBlockMemory;
m_rgpmbmAbove [iMB]->rgblkm = new BlockMemory [nBlk];
m_rgpmbmCurr [iMB] = new MacroBlockMemory;
m_rgpmbmCurr [iMB]->rgblkm = new BlockMemory [nBlk];
for (iBlk = 0; iBlk < nBlk; iBlk++) {
// BLOCK_SIZE*2-1 is 15 Ints for dc/ac prediction of coefficients
(m_rgpmbmAbove [iMB]->rgblkm) [iBlk] = new Int [(BLOCK_SIZE << 1) - 1];
(m_rgpmbmCurr [iMB]->rgblkm) [iBlk] = new Int [(BLOCK_SIZE << 1) - 1];
}
}
}
Void CVideoObject::repeatPadYOrA (PixelC* ppxlcOldLeft, CVOPU8YUVBA* pvopcRef)
{
// RRV insertion
Int iScale = (m_vopmd.RRVmode.iOnOff == 1) ? (2) : (1);
// ~RRV
// RRV modification
PixelC* ppxlcLeftTop = ppxlcOldLeft - (EXPANDY_REFVOP *iScale) * m_iFrameWidthY - (EXPANDY_REFVOP *iScale);
// PixelC* ppxlcLeftTop = ppxlcOldLeft - EXPANDY_REFVOP * m_iFrameWidthY - EXPANDY_REFVOP;
// ~RRV
// point to the left top of the expanded bounding box (+- EXPANDY_REFVOP)
const PixelC* ppxlcOldRight = ppxlcOldLeft + ((m_volmd.fAUsage == RECTANGLE)?m_ivolWidth:m_rctPrevNoExpandY.width) - 1; // modified by Sharp (99/1/14)
// point to the right-top of the bounding box
// RRV modification
const PixelC* ppxlcOldTopLn = ppxlcOldLeft - (EXPANDY_REFVOP *iScale);
// const PixelC* ppxlcOldTopLn = ppxlcOldLeft - EXPANDY_REFVOP;
// ~RRV
// point to the (left, top) - EXPANDY_REFVOP
PixelC* ppxlcNewLeft = (PixelC*) ppxlcOldTopLn;
PixelC* ppxlcNewRight = (PixelC*) ppxlcOldRight + 1;
CoordI y;
// begin: modified by Sharp (99/1/14)
Int PrevNoExpandY_height = (m_volmd.fAUsage == RECTANGLE)?m_ivolHeight:m_rctPrevNoExpandY.height ();
for (y = 0; y < PrevNoExpandY_height; y++) { // x-direction interpolation
// end: modified by Sharp
// RRV modification
for (Int i=0; i<(EXPANDY_REFVOP *iScale); i++) {
// for (Int i=0; i<EXPANDY_REFVOP; i++) {
// ~RRV
ppxlcNewLeft[i] = *ppxlcOldLeft;
ppxlcNewRight[i] = *ppxlcOldRight;
}
ppxlcNewLeft += pvopcRef->whereY ().width;
ppxlcNewRight += pvopcRef->whereY ().width;
ppxlcOldLeft += pvopcRef->whereY ().width;
ppxlcOldRight += pvopcRef->whereY ().width;
}
const PixelC* ppxlcOldBotLn = ppxlcNewLeft - pvopcRef->whereY ().width;
// RRV modification
for (y = 0; y < (EXPANDY_REFVOP *iScale); y++) {
memcpy (ppxlcLeftTop, ppxlcOldTopLn, (m_rctPrevNoExpandY.width + 2 * (EXPANDY_REFVOP *iScale))*sizeof(PixelC));
memcpy (ppxlcNewLeft, ppxlcOldBotLn, (m_rctPrevNoExpandY.width + 2 * (EXPANDY_REFVOP *iScale))*sizeof(PixelC));
// for (y = 0; y < EXPANDY_REFVOP; y++) {
// memcpy (ppxlcLeftTop, ppxlcOldTopLn, (m_rctPrevNoExpandY.width + 2 * EXPANDY_REFVOP)*sizeof(PixelC));
// memcpy (ppxlcNewLeft, ppxlcOldBotLn, (m_rctPrevNoExpandY.width + 2 * EXPANDY_REFVOP)*sizeof(PixelC));
// ~RRV
ppxlcNewLeft += pvopcRef->whereY ().width;
ppxlcLeftTop += pvopcRef->whereY ().width;
}
}
Void CVideoObject::repeatPadUV (CVOPU8YUVBA* pvopcRef)
{
// RRV insertion
Int iScale = (m_vopmd.RRVmode.iOnOff == 1) ? (2) : (1);
// ~RRV
const PixelC* ppxlcOldLeftU = pvopcRef->pixelsU () + m_iOffsetForPadUV; // point to the left-top of bounding box
const PixelC* ppxlcOldLeftV = pvopcRef->pixelsV () + m_iOffsetForPadUV; // point to the left-top of bounding box
// RRV modification
PixelC* ppxlcLeftTopU = (PixelC*) ppxlcOldLeftU - (EXPANDUV_REFVOP *iScale) * m_iFrameWidthUV - (EXPANDUV_REFVOP *iScale);
PixelC* ppxlcLeftTopV = (PixelC*) ppxlcOldLeftV - (EXPANDUV_REFVOP *iScale) * m_iFrameWidthUV - (EXPANDUV_REFVOP *iScale);
// PixelC* ppxlcLeftTopU = (PixelC*) ppxlcOldLeftU - EXPANDUV_REFVOP * m_iFrameWidthUV - EXPANDUV_REFVOP;
// PixelC* ppxlcLeftTopV = (PixelC*) ppxlcOldLeftV - EXPANDUV_REFVOP * m_iFrameWidthUV - EXPANDUV_REFVOP;
// ~RRV
// point to the left top of the expanded bounding box (+- EXPANDY_REFVOP)
const PixelC* ppxlcOldRightU = ppxlcOldLeftU + ((m_volmd.fAUsage == RECTANGLE)?m_ivolWidth/2:m_rctPrevNoExpandUV.width) - 1; // modified by Sharp (99/1/14)
const PixelC* ppxlcOldRightV = ppxlcOldLeftV + ((m_volmd.fAUsage == RECTANGLE)?m_ivolWidth/2:m_rctPrevNoExpandUV.width) - 1; // modified by Sharp (99/1/14)
// point to the right-top of the bounding box
// RRV modification
const PixelC* ppxlcOldTopLnU = ppxlcOldLeftU - (EXPANDUV_REFVOP *iScale);
const PixelC* ppxlcOldTopLnV = ppxlcOldLeftV - (EXPANDUV_REFVOP *iScale);
// const PixelC* ppxlcOldTopLnU = ppxlcOldLeftU - EXPANDUV_REFVOP;
// const PixelC* ppxlcOldTopLnV = ppxlcOldLeftV - EXPANDUV_REFVOP;
// ~RRV
// point to the (left, top) - EXPANDY_REFVOP
PixelC* ppxlcNewLeftU = (PixelC*) ppxlcOldTopLnU;
PixelC* ppxlcNewLeftV = (PixelC*) ppxlcOldTopLnV;
PixelC* ppxlcNewRightU = (PixelC*) ppxlcOldRightU + 1;
PixelC* ppxlcNewRightV = (PixelC*) ppxlcOldRightV + 1;
CoordI y;
// begin: modified by Sharp (99/1/14)
Int PrevNoExpandUV_height = (m_volmd.fAUsage == RECTANGLE)?m_ivolHeight/2:m_rctPrevNoExpandUV.height ();
for (y = 0; y < PrevNoExpandUV_height; y++) { // x-direction interpolation
// end: modified by Sharp (99/1/14)
// RRV modification
for (Int i=0; i<(EXPANDUV_REFVOP *iScale); i++) {
// for (Int i=0; i<EXPANDUV_REFVOP; i++) {
// ~RRV
ppxlcNewLeftU[i] = *ppxlcOldLeftU;
ppxlcNewLeftV[i] = *ppxlcOldLeftV;
ppxlcNewRightU[i] = *ppxlcOldRightU;
ppxlcNewRightV[i] = *ppxlcOldRightV;
}
ppxlcNewLeftU += pvopcRef->whereUV ().width;
ppxlcNewLeftV += pvopcRef->whereUV ().width;
ppxlcNewRightU += pvopcRef->whereUV ().width;
ppxlcNewRightV += pvopcRef->whereUV ().width;
ppxlcOldLeftU += pvopcRef->whereUV ().width;
ppxlcOldLeftV += pvopcRef->whereUV ().width;
ppxlcOldRightU += pvopcRef->whereUV ().width;
ppxlcOldRightV += pvopcRef->whereUV ().width;
}
const PixelC* ppxlcOldBotLnU = ppxlcNewLeftU - pvopcRef->whereUV ().width;
const PixelC* ppxlcOldBotLnV = ppxlcNewLeftV - pvopcRef->whereUV ().width;
// RRV modification
for (y = 0; y < (EXPANDUV_REFVOP *iScale); y++) {
memcpy (ppxlcLeftTopU, ppxlcOldTopLnU, (m_rctPrevNoExpandUV.width + 2 * (EXPANDUV_REFVOP *iScale))*sizeof(PixelC));
memcpy (ppxlcLeftTopV, ppxlcOldTopLnV, (m_rctPrevNoExpandUV.width + 2 * (EXPANDUV_REFVOP *iScale))*sizeof(PixelC));
memcpy (ppxlcNewLeftU, ppxlcOldBotLnU, (m_rctPrevNoExpandUV.width + 2 * (EXPANDUV_REFVOP *iScale))*sizeof(PixelC));
memcpy (ppxlcNewLeftV, ppxlcOldBotLnV, (m_rctPrevNoExpandUV.width + 2 * (EXPANDUV_REFVOP *iScale))*sizeof(PixelC));
// for (y = 0; y < EXPANDUV_REFVOP; y++) {
// memcpy (ppxlcLeftTopU, ppxlcOldTopLnU, (m_rctPrevNoExpandUV.width + 2 * EXPANDUV_REFVOP)*sizeof(PixelC));
// memcpy (ppxlcLeftTopV, ppxlcOldTopLnV, (m_rctPrevNoExpandUV.width + 2 * EXPANDUV_REFVOP)*sizeof(PixelC));
// memcpy (ppxlcNewLeftU, ppxlcOldBotLnU, (m_rctPrevNoExpandUV.width + 2 * EXPANDUV_REFVOP)*sizeof(PixelC));
// memcpy (ppxlcNewLeftV, ppxlcOldBotLnV, (m_rctPrevNoExpandUV.width + 2 * EXPANDUV_REFVOP)*sizeof(PixelC));
// ~RRV
ppxlcNewLeftU += pvopcRef->whereUV ().width;
ppxlcNewLeftV += pvopcRef->whereUV ().width;
ppxlcLeftTopU += pvopcRef->whereUV ().width;
ppxlcLeftTopV += pvopcRef->whereUV ().width;
}
}
Void CVideoObject::saveShapeMode()
{
// called after reference frame encode/decode
if(m_rgshpmd == NULL)
{
// first time
m_iRefShpNumMBX = m_iNumMBX;
m_iRefShpNumMBY = m_iNumMBY;
m_rgshpmd = new ShapeMode [m_iNumMB];
}
else
{
// update if changed
if(m_iRefShpNumMBX!=m_iNumMBXRef || m_iRefShpNumMBY != m_iNumMBYRef)
{
delete [] m_rgshpmd;
m_rgshpmd = new ShapeMode [m_iNumMBRef];
m_iRefShpNumMBX = m_iNumMBXRef;
m_iRefShpNumMBY = m_iNumMBYRef;
}
// copy shape mode from previous ref to save
Int i;
for (i=0; i<m_iNumMBRef; i++ )
m_rgshpmd[i] = m_rgmbmdRef[i].m_shpmd;
}
}
//OBSS_SAIT_991015
Void CVideoObject::saveBaseShapeMode()
{
// called after reference frame encode/decode
if(m_rgBaseshpmd == NULL){
// first time
m_iNumMBBaseXRef = m_iNumMBX;
m_iNumMBBaseYRef = m_iNumMBY;
// save current shape mode for enhancement layer shape mode coding
if(m_volmd.volType == BASE_LAYER) {
m_rgBaseshpmd = new ShapeMode [m_iNumMB];
// first time
m_iRefShpNumMBX = m_iNumMBX;
m_iRefShpNumMBY = m_iNumMBY;
Int i;
Int iMBX, iMBY;
for (iMBY=0, i=0; iMBY<m_iNumMBY; iMBY++ ) {
for (iMBX=0; iMBX<m_iNumMBX; iMBX++ ) {
m_rgBaseshpmd[i] = m_rgmbmd[i].m_shpmd;
i++;
}
}
}
} else {
// update if changed
if(m_volmd.volType == BASE_LAYER) {
//for save lower layer shape mode
if(m_iNumMBBaseXRef!=m_iNumMBX || m_iNumMBBaseYRef != m_iNumMBY){
delete [] m_rgBaseshpmd;
m_rgBaseshpmd = new ShapeMode [m_iNumMB];
m_iNumMBBaseXRef = m_iNumMBX;
m_iNumMBBaseYRef = m_iNumMBY;
}
Int i=0;
Int iMBX, iMBY;
for (iMBY=0, i=0; iMBY<m_iNumMBY; iMBY++ ){
for (iMBX=0; iMBX<m_iNumMBX; iMBX++ ){
m_rgBaseshpmd[i] = m_rgmbmd[i].m_shpmd;
i++;
}
}
m_iNumMBBaseXRef = m_iNumMBX;
m_iNumMBBaseYRef = m_iNumMBY;
//for save lawer layer shape mode
}
}
}
//~OBSS_SAIT_991015
Void CVideoObject::resetBYPlane ()
{
if (m_vopmd.vopPredType == PVOP || m_vopmd.vopPredType == IVOP || (m_uiSprite == 2 && m_vopmd.vopPredType == SPRITE)) { // GMC
PixelC* ppxlcBY = (PixelC*) m_pvopcRefQ1->pixelsBY ();
memset (ppxlcBY, 0, m_pvopcRefQ1->whereY().area() * sizeof(PixelC));
}
else {
PixelC* ppxlcBY = (PixelC*) m_pvopcCurrQ->pixelsBY ();
memset (ppxlcBY, 0, m_pvopcCurrQ->whereY().area() * sizeof(PixelC));
}
}
Void CVideoObject::updateAllRefVOPs ()
// perform this after VOP prediction type decided and before encoding
{
if (m_vopmd.vopPredType != BVOP) {
m_rctRefVOPY0 = m_rctRefVOPY1;
swapVOPU8Pointers (m_pvopcRefQ0, m_pvopcRefQ1);
}
}
// for spatial scalability
Void CVideoObject::updateAllRefVOPs (const CVOPU8YUVBA* pvopcRefBaseLayer)
{
CVOPU8YUVBA *pvopcUpSampled = NULL;
Int fEnhancementLayer = 0;
assert (m_volmd.volType == ENHN_LAYER);
//OBSS_SAIT_991015
pvopcUpSampled = pvopcRefBaseLayer->upsampleForSpatialScalability (
m_volmd.iver_sampling_factor_m,
m_volmd.iver_sampling_factor_n,
m_volmd.ihor_sampling_factor_m,
m_volmd.ihor_sampling_factor_n,
m_volmd.iver_sampling_factor_m_shape,
m_volmd.iver_sampling_factor_n_shape,
m_volmd.ihor_sampling_factor_m_shape,
m_volmd.ihor_sampling_factor_n_shape,
m_volmd.iFrmWidth_SS,
m_volmd.iFrmHeight_SS,
m_volmd.bShapeOnly,
EXPANDY_REF_FRAME,
EXPANDUV_REF_FRAME);
//~OBSS_SAIT_991015
if(m_vopmd.vopPredType == PVOP || (m_uiSprite == 2 && m_vopmd.vopPredType == SPRITE)) { // GMC
//OBSS_SAIT_991015
if(m_volmd.fAUsage == RECTANGLE) {
m_rctRefVOPY0 = m_rctRefVOPY1;
}
//OBSSFIX__000323
else if(m_volmd.bSpatialScalability && m_volmd.iHierarchyType == 0 && m_volmd.iEnhnType != 0 && m_volmd.iuseRefShape == 1){
// m_rctRefVOPY0 = m_rctRefVOPY1;
if(pvopcUpSampled->fAUsage() == RECTANGLE)
m_rctRefVOPY0 = pvopcUpSampled->whereY();
else{
CRct tmp;
tmp = m_rctBase;
tmp.left = (int)((tmp.left) * (m_volmd.ihor_sampling_factor_n_shape)/(m_volmd.ihor_sampling_factor_m_shape));
tmp.right = (int)((tmp.right) * (m_volmd.ihor_sampling_factor_n_shape)/(m_volmd.ihor_sampling_factor_m_shape));
tmp.top = (int)((tmp.top) * (m_volmd.iver_sampling_factor_n_shape)/(m_volmd.iver_sampling_factor_m_shape));
tmp.bottom = (int)((tmp.bottom) * (m_volmd.iver_sampling_factor_n_shape)/(m_volmd.iver_sampling_factor_m_shape));
tmp.width = tmp.right - tmp.left ;
tmp.left -= 32; tmp.right += 32;
tmp.top -= 32; tmp.bottom += 32;
tmp.width += 64;
m_rctRefVOPY0 = tmp; // m_rctBase : BASE_LAYER RECT SIZE
}
}
//~OBSSFIX__000323
else if(m_volmd.fAUsage == ONE_BIT) {
CRct tmp;
tmp = m_rctBase;
tmp.left = (int)((tmp.left) * (m_volmd.ihor_sampling_factor_n_shape)/(m_volmd.ihor_sampling_factor_m_shape));
tmp.right = (int)((tmp.right) * (m_volmd.ihor_sampling_factor_n_shape)/(m_volmd.ihor_sampling_factor_m_shape));
tmp.top = (int)((tmp.top) * (m_volmd.iver_sampling_factor_n_shape)/(m_volmd.iver_sampling_factor_m_shape));
tmp.bottom = (int)((tmp.bottom) * (m_volmd.iver_sampling_factor_n_shape)/(m_volmd.iver_sampling_factor_m_shape));
tmp.width = tmp.right - tmp.left ;
tmp.left -= 32; tmp.right += 32;
tmp.top -= 32; tmp.bottom += 32;
tmp.width += 64;
m_rctRefVOPY0 = tmp; // m_rctBase : BASE_LAYER RECT SIZE
}
//~OBSS_SAIT_991015
swapVOPU8Pointers (m_pvopcRefQ0,pvopcUpSampled);
m_pvopcRefQ0->setBoundRct(m_rctRefVOPY0);
delete pvopcUpSampled;
}
else if(m_vopmd.vopPredType == BVOP){
CRct tmp;
//OBSS_SAIT_991015
if(m_volmd.fAUsage == RECTANGLE) {
tmp = m_rctRefVOPY0;
}
//OBSSFIX_MODE3_02
else if(m_volmd.bSpatialScalability && m_volmd.iHierarchyType == 0 && m_volmd.iEnhnType != 0 && m_volmd.iuseRefShape == 1){
// tmp = pvopcUpSampled->whereY();
if(pvopcUpSampled->fAUsage()==RECTANGLE)
tmp = pvopcUpSampled->whereY();
else{
tmp = m_rctBase;
tmp.left = (int)((tmp.left) * (m_volmd.ihor_sampling_factor_n_shape)/(m_volmd.ihor_sampling_factor_m_shape));
tmp.right = (int)((tmp.right) * (m_volmd.ihor_sampling_factor_n_shape)/(m_volmd.ihor_sampling_factor_m_shape));
tmp.top = (int)((tmp.top) * (m_volmd.iver_sampling_factor_n_shape)/(m_volmd.iver_sampling_factor_m_shape));
tmp.bottom = (int)((tmp.bottom) * (m_volmd.iver_sampling_factor_n_shape)/(m_volmd.iver_sampling_factor_m_shape));
tmp.width = tmp.right - tmp.left ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -