📄 pbframe.cpp
字号:
#include "stdafx.h"
#include "color.h"
#include "DBitstream.h"
#include "sactable.h"
#include "sad.h"
#include "Dh263class.h"
#include "commonvar.h"
int DH263Picture::DecodePBPicture(YUVData CurLoss,YUVData PrevLoss,YUVData BLoss,DBitStream *DecodeStream)
{ int i,j;
int GN=0;
BOOL GOBFlag=TRUE;
YUVData PrevInter,EdgeRec;
SAD *SADeco;
if (PictureInfo.SACMode)
SADeco=new SAD(DecodeStream);
if (PictureInfo.UMVMode)
{PrevInter.hImage=GlobalAlloc(GHND,6*(Height+32)*(Width+32)+8);
PrevInter.Image=(BYTE *)GlobalLock(PrevInter.hImage);
if ((int)PrevInter.Image%8)
PrevInter.Image+=(8-(int)PrevInter.Image%8);
PrevInter.Y=PrevInter.Image;
PrevInter.U=PrevInter.Image+4*(Width+32)*(Height+32);
PrevInter.V=PrevInter.Image+5*(Width+32)*(Height+32);
EdgeRec.hImage=GlobalAlloc(GHND,(Height+32)*(Width+32)+(Height+32)*(Width+32)/2+8);
EdgeRec.Image=(BYTE *)GlobalLock(EdgeRec.hImage);
if ((int)EdgeRec.Image%8)
EdgeRec.Image+=(8-(int)EdgeRec.Image%8);
EdgeRec.Y=EdgeRec.Image;
EdgeRec.U=EdgeRec.Image+(Width+32)*(Height+32);
EdgeRec.V=EdgeRec.Image+(Width+32)*(Height+32)+(Width+32)*(Height+32)/4;
MakeEdgeData(PrevLoss,EdgeRec,Width,Height,16);
InterpolateImage(EdgeRec,PrevInter,Width+32,Height+32);
PrevInter.Y=PrevInter.Image+16*(Width+32)+16;
PrevInter.U=PrevInter.Image+4*(Width+32)*(Height+32)+8*(Width/2+16)+8;
PrevInter.V=PrevInter.Image+5*(Width+32)*(Height+32)+8*(Width/2+16)+8;
StrPrevInt.LumIntPel=EdgeRec.Y+16*(Width+32)+16;
StrPrevInt.CBIntPel=EdgeRec.U+8*(Width/2+16)+8;
StrPrevInt.CRIntPel=EdgeRec.V+8*(Width/2+16)+8;
}
else
{PrevInter.hImage=GlobalAlloc(GHND,6*ImageSize+8);
PrevInter.Image=(BYTE *)GlobalLock(PrevInter.hImage);
if ((int)PrevInter.Image%8)
PrevInter.Image+=(8-(int)PrevInter.Image%8);
PrevInter.Y=PrevInter.Image;
PrevInter.U=PrevInter.Image+4*ImageSize;
PrevInter.V=PrevInter.Image+5*ImageSize;
InterpolateImage(PrevLoss,PrevInter,Width,Height);
}
MB->MBBits.CBPBBits=6;
MB->MBBits.DQUANTBits=2;
memset(MB->QCoeff,0,384*sizeof(short));
memset(MB->BQCoeff,0,384*sizeof(short));
MB->QP=PictureInfo.PQUANT;
for (i=0;i<HMB;i++)
{if (i&&GOBFlag)
{GN=Group->DecodeGOBHeader(PictureInfo.CPM,DecodeStream);
MB->QP=Group->GOBInfo.GQUANT;
}
if (GN!=i)
{GOBFlag=FALSE;
continue;
}
else
GOBFlag=TRUE;
if (PictureInfo.SACMode)
SADeco->DecodeReset();
for (j=0;j<WMB;j++)
{MB->CBP=0;
MB->MBInfo.CBPB=0;
if (!PictureInfo.SACMode)
MB->DecodeMBHeader(DecodeStream,j,i);
else
MB->SACDecodeMBHeader(SADeco,j,i);
if (MB->CBP==0&&(MB->Mode==MODE_INTER||MB->Mode == MODE_INTER_Q||MB->Mode==MODE_INTER4V))
{memset(MB->MBData.lum,0,sizeof(short)*MB_SIZE*MB_SIZE);
memset(MB->MBData.CB,0,sizeof(short)*MB_SIZE*MB_SIZE/4);
memset(MB->MBData.CR,0,sizeof(short)*MB_SIZE*MB_SIZE/4);
}
else
{if (!PictureInfo.SACMode)
MB->DecodeCoeff(DecodeStream);
else
MB->SACDecodeCoeff(SADeco);
MB->DecodeMBData();
memset(MB->QCoeff,0,384*sizeof(short));
}
if (MB->Mode==MODE_INTER4V)
MB->MB_Recon_P4V(CurLoss,PrevInter,j*MB_SIZE,i*MB_SIZE);
else if (MB->Mode==MODE_INTRA||MB->Mode==MODE_INTRA_Q)
MB->FillRecon(CurLoss,i*MB_SIZE,j*MB_SIZE);
else
MB->MB_Recon_P(CurLoss,PrevInter,j*MB_SIZE,i*MB_SIZE);
if (PictureInfo.PBMode)
{if (MB->MBInfo.CBPB==0)
{memset(MB->BData.lum,0,sizeof(short)*MB_SIZE*MB_SIZE);
memset(MB->BData.CB,0,sizeof(short)*MB_SIZE*MB_SIZE/4);
memset(MB->BData.CR,0,sizeof(short)*MB_SIZE*MB_SIZE/4);
}
else
{if (MB->QP== 0)
MB->QP_B = 0;// (QP = 0 means no quantization)
else
MB->QP_B = max(1,min(31,bquant[PictureInfo.DBQUANT]*MB->QP/4));
if (!PictureInfo.SACMode)
MB->DecodeBCoeff(DecodeStream);
else
MB->SACDecodeBCoeff(SADeco);
MB->DecodeBData();
memset(MB->BQCoeff,0,384*sizeof(short));
}
if (MB->Mode==MODE_INTER4V)
MB->MB_Recon_B4V(BLoss,PrevInter,CurLoss,
j*MB_SIZE,i*MB_SIZE,2,PictureInfo.TRB);
else
MB->MB_Recon_B(BLoss,PrevInter,CurLoss,
j*MB_SIZE,i*MB_SIZE,2,PictureInfo.TRB);
}
}
}
DecodeStream->FlushBits(PictureBits.EOSBits);
if (PictureInfo.SACMode)
delete SADeco;
GlobalUnlock(PrevInter.hImage);
GlobalFree(PrevInter.hImage);
if (PictureInfo.UMVMode)
{GlobalUnlock(EdgeRec.hImage);
GlobalFree(EdgeRec.hImage);
}
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -