📄 vopsedec.cpp
字号:
short_video_header=*p_short_video_header;
postVO_VOLHeadInit(iDisplayWidth, iDisplayHeight, pbSpatialScalability);
}
void CVideoObjectDecoder::postVO_VOLHeadInit (Int iDisplayWidth,
Int iDisplayHeight,
Bool *pbSpatialScalability)
{
/* (98/03/30 added by SONY)*/
m_bLinkisBroken = FALSE;
m_bUseGOV = FALSE;
/* (98/03/30 added by SONY)*/
// Added for error resilient mode by Toshiba(1997-11-14): Moved (1998-1-16)
g_iMaxHeading = MAXHEADING_ERR;
g_iMaxMiddle = MAXMIDDLE_ERR;
g_iMaxTrailing = MAXTRAILING_ERR;
// End Toshiba(1997-11-14)
setClipTab(); // NBIT
if(m_volmd.volType == ENHN_LAYER){ // check scalability type
if(pbSpatialScalability != NULL)
if(m_volmd.iHierarchyType == 0)
*pbSpatialScalability = TRUE;
else
*pbSpatialScalability = FALSE;
}
if (m_volmd.fAUsage == RECTANGLE) {
if (m_volmd.volType == ENHN_LAYER &&
(m_volmd.ihor_sampling_factor_n != m_volmd.ihor_sampling_factor_m ||
m_volmd.iver_sampling_factor_n != m_volmd.iver_sampling_factor_m )){
iDisplayWidth = m_ivolWidth;
iDisplayHeight= m_ivolHeight;
}
else if (iDisplayWidth == -1 && iDisplayHeight == -1) {
iDisplayWidth = m_ivolWidth;
iDisplayHeight = m_ivolHeight;
}
else if (iDisplayWidth != m_ivolWidth || iDisplayHeight != m_ivolHeight){
fprintf(stderr, "\nDecode aborted! This rectangular VOP stream requires display\nwidth and height to be set to %dx%d.\n",
m_ivolWidth, m_ivolHeight);
exit(1);
}
}
m_rctDisplayWindow = CRct (0, 0, iDisplayWidth, iDisplayHeight); //same as m_rctOrg? will fixe later
/*
if (m_volmd.fAUsage == RECTANGLE) {
if (m_volmd.volType == ENHN_LAYER &&
(m_volmd.ihor_sampling_factor_n/m_volmd.ihor_sampling_factor_m != 1||
m_volmd.iver_sampling_factor_n/m_volmd.iver_sampling_factor_m != 1)){
iDisplayWidth = m_ivolWidth;
iDisplayHeight= m_ivolHeight;
if(pbSpatialScalability!=NULL)
*pbSpatialScalability = TRUE;
fprintf(stderr,"display size %d %d \n",iDisplayWidth, iDisplayHeight);
}
else if (iDisplayWidth != m_ivolWidth || iDisplayHeight != m_ivolHeight){
fprintf(stderr, "\nDecode aborted! This rectangular VOP stream requires display\nwidth and height to be set to %dx%d.\n",
m_ivolWidth, m_ivolHeight);
exit(1);
}
else if(pbSpatialScalability!=NULL)
*pbSpatialScalability = FALSE;
}
m_rctDisplayWindow = CRct (0, 0, iDisplayWidth, iDisplayHeight); //same as m_rctOrg? will fixe later
*/
if (m_uiSprite == 1) { // change iDisplay size in order to get the first sprite piece
iDisplayWidth = (Int) m_rctSpt.width;
iDisplayHeight = (Int) m_rctSpt.height ();
}
Int iMod = iDisplayWidth % MB_SIZE;
Int iDisplayWidthRound = (iMod > 0) ? iDisplayWidth + MB_SIZE - iMod : iDisplayWidth;
iMod = iDisplayHeight % MB_SIZE;
Int iDisplayHeightRound = (iMod > 0) ? iDisplayHeight + MB_SIZE - iMod : iDisplayHeight;
m_rctRefFrameY = CRct (
-EXPANDY_REF_FRAME, -EXPANDY_REF_FRAME,
EXPANDY_REF_FRAME + iDisplayWidthRound, EXPANDY_REF_FRAME + iDisplayHeightRound
);
m_rctRefFrameUV = m_rctRefFrameY.downSampleBy2 ();
allocateVOLMembers (iDisplayWidth, iDisplayHeight);
if (m_volmd.fAUsage == RECTANGLE) {
//wchen: if sprite; set it according to the initial piece instead
m_rctCurrVOPY = (m_uiSprite == 0) ? CRct (0, 0, iDisplayWidthRound, iDisplayHeightRound) : m_rctSpt;
m_rctCurrVOPUV = m_rctCurrVOPY.downSampleBy2 ();
m_rctRefVOPY0 = m_rctCurrVOPY;
m_rctRefVOPY0.expand (EXPANDY_REFVOP);
m_rctRefVOPUV0 = m_rctRefVOPY0.downSampleBy2 ();
m_rctRefVOPY1 = m_rctRefVOPY0;
m_rctRefVOPUV1 = m_rctRefVOPUV0;
computeVOLConstMembers (); // these VOP members are the same for all frames
}
// buffer for shape decoding
m_pvopcRightMB = new CVOPU8YUVBA (m_volmd.fAUsage, CRct (0, 0, MB_SIZE, MB_SIZE));
m_ppxlcRightMBBY = (PixelC*) m_pvopcRightMB->pixelsBY ();
m_ppxlcRightMBBUV = (PixelC*) m_pvopcRightMB->pixelsBUV ();
// buffers for Temporal Scalabe Decoding Added by Sharp(1998-02-10)
if (m_volmd.volType == ENHN_LAYER) {
m_pBuffP1 = new CEnhcBufferDecoder (m_rctRefFrameY.width, m_rctRefFrameY.height ());
m_pBuffP2 = new CEnhcBufferDecoder (m_rctRefFrameY.width, m_rctRefFrameY.height ());
m_pBuffB1 = new CEnhcBufferDecoder (m_rctRefFrameY.width, m_rctRefFrameY.height ());
m_pBuffB2 = new CEnhcBufferDecoder (m_rctRefFrameY.width, m_rctRefFrameY.height ());
m_pBuffE = new CEnhcBufferDecoder (m_rctRefFrameY.width, m_rctRefFrameY.height ());
}
// buffers for Temporal Scalabe Decoding End Sharp(1998-02-10)
m_iClockRateScale = 1; // added by Sharp (98/6/26)
// Set sprite_transmit_mode to STOP for the duration of VOL if (fSptUsage () == 0),
// and later set to PIECE by decode_init_sprite () if (fSptUsage () == 1)
m_vopmd.SpriteXmitMode = STOP;
}
// for back/forward shape Added by Sharp(1998-02-10)
CVideoObjectDecoder::CVideoObjectDecoder (
Int iDisplayWidth, Int iDisplayHeight
) : CVideoObject ()
{
m_pistrm = -1;
m_pbitstrmIn = NULL;
m_pentrdecSet = NULL;
m_uiVOId = 0;
Void set_modes(VOLMode* volmd, VOPMode* vopmd);
set_modes(&m_volmd, &m_vopmd); // set VOL modes, VOP modes
m_vopmd.iVopConstantAlphaValue = 255;
Int iMod = iDisplayWidth % MB_SIZE;
Int iDisplayWidthRound = (iMod > 0) ? iDisplayWidth + MB_SIZE - iMod : iDisplayWidth;
iMod = iDisplayHeight % MB_SIZE;
Int iDisplayHeightRound = (iMod > 0) ? iDisplayHeight + MB_SIZE - iMod : iDisplayHeight;
m_rctRefFrameY = CRct (
-EXPANDY_REF_FRAME, -EXPANDY_REF_FRAME,
EXPANDY_REF_FRAME + iDisplayWidthRound, EXPANDY_REF_FRAME + iDisplayHeightRound
);
m_rctRefFrameUV = m_rctRefFrameY.downSampleBy2 ();
allocateVOLMembers (iDisplayWidth, iDisplayHeight);
// buffer for shape decoding
m_pvopcRightMB = new CVOPU8YUVBA (m_volmd.fAUsage, CRct (0, 0, MB_SIZE, MB_SIZE));
m_ppxlcRightMBBY = (PixelC*) m_pvopcRightMB->pixelsBY ();
m_ppxlcRightMBBUV = (PixelC*) m_pvopcRightMB->pixelsBUV ();
}
// for back/forward shape End Sharp(1998-02-10)
Int CVideoObjectDecoder::decode (const CVOPU8YUVBA* pvopcBVOPQuant, /*strstreambuf* pistrm, */ Bool waitForI, Bool drop)
{
#if 0
if (pistrm != NULL) {
delete (istream *)m_pistrm;
delete m_pbytestrmIn;
delete m_pbitstrmIn;
delete m_pentrdecSet;
m_pistrm = (ifstream *)new istream (pistrm);
m_pbytestrmIn = new CInByteStreamFile(*m_pistrm);
m_pbitstrmIn = new CInBitStream (m_pbytestrmIn);
m_pentrdecSet = new CEntropyDecoderSet (*m_pbitstrmIn);
}
#endif
//sprite piece should not come here
assert ((m_vopmd.SpriteXmitMode == STOP) || ( m_vopmd.SpriteXmitMode == PAUSE));
if (findStartCode () == EOF)
return EOF;
Bool bCoded = decodeVOPHead (); // set the bounding box here
if (waitForI &&
!(m_vopmd.vopPredType == IVOP)) {
#ifdef DEBUG_OUTPUT
cout << "\tFrame is not IVOP " << m_vopmd.vopPredType << "\n";
cout.flush();
#endif
return -1;
}
if (drop && m_vopmd.vopPredType == BVOP) {
return -1;
}
#ifdef DEBUG_OUTPUT
cout << "\t" << "Time..." << m_t << " (" << m_t / (double)m_volmd.iClockRate << " sec)\n";
if(bCoded == FALSE)
cout << "\tNot coded.\n";
cout.flush ();
#endif
Bool bPrevRefVopWasCoded = m_bCodedFutureRef;
if(m_vopmd.vopPredType==IVOP || m_vopmd.vopPredType==PVOP)
m_bCodedFutureRef = bCoded; // flag used by bvop prediction
if (m_vopmd.vopPredType == SPRITE) {
decodeSpt ();
return TRUE;
}
// set time stamps for Base/Temporal-Enhc/Spatial-Enhc Layer Modified by Sharp(1998-02-10)
if(m_volmd.volType == BASE_LAYER) {
if(m_vopmd.vopPredType==IVOP || m_vopmd.vopPredType==PVOP) {
if(bPrevRefVopWasCoded)
m_tPastRef = m_tFutureRef;
m_tFutureRef = m_t;
m_iBCount = 0;
}
// count B-VOPs
if(m_vopmd.vopPredType==BVOP)
m_iBCount++;
}
else if (pvopcBVOPQuant != NULL) { // Spatial Scalability Enhancement Layer
/* (98/03/30) modified by SONY */
if(m_vopmd.vopPredType == BVOP && m_vopmd.iRefSelectCode == 0) {
if(bPrevRefVopWasCoded)
m_tPastRef = m_tFutureRef;
m_tFutureRef = m_t;
m_iBCount = 0;
} if(m_vopmd.vopPredType == PVOP && m_vopmd.iRefSelectCode == 3) {
m_tPastRef = m_t;
m_tFutureRef = m_t;
m_iBCount = 0;
}
/* (98/03/30) modified by SONY */
// count B-VOPs
if(m_vopmd.vopPredType==BVOP)
m_iBCount++;
}
// set time stamps for Base/Temporal-Enhc/Spatial-Enhc Layer End Sharp(1998-02-10)
// select reference frames for Base/Temporal-Enhc/Spatial-Enhc Layer Modified by Sharp(1998-02-10)
if(bPrevRefVopWasCoded)
{
if(m_volmd.volType == BASE_LAYER) {
updateAllRefVOPs (); // update all reconstructed VOP's
}
else {
if (pvopcBVOPQuant == NULL) // Temporal Scalability Enhancement Layer
updateRefVOPsEnhc ();
else { // Spatial Scalability Enhancement Layer
updateAllRefVOPs (pvopcBVOPQuant);
}
}
}
// select reference frames for Base/Temporal-Enhc/Spatial-Enhc Layer End Sharp(1998-02-10)
switch(m_vopmd.vopPredType)
{
case IVOP:
#ifdef DEBUG_OUTPUT
cout << "\tIVOP";
#endif
/*Added by SONY (98/03/30)*/
if(m_bLinkisBroken == TRUE && m_bUseGOV == TRUE) m_bLinkisBroken = FALSE;
/*Added by SONY (98/03/30) END*/
break;
case PVOP:
#ifdef DEBUG_OUTPUT
cout << "\tPVOP (reference: t=" << m_tPastRef <<")";
#endif
break;
case BVOP:
#ifdef DEBUG_OUTPUT
cout << "\tBVOP (past ref: t=" << m_tPastRef
<< ", future ref: t=" << m_tFutureRef <<")";
#endif
break;
default:
break;
}
#ifdef DEBUG_OUTPUT
cout << "\n";
cout.flush ();
#endif
/* Added by SONY (98/03/30)*/
if(m_bLinkisBroken == TRUE && m_bUseGOV == TRUE)
fprintf(stderr,"WARNING: broken_link = 1 --- Output image must be broken.\n");
/*Added by SONY (98/03/30) End*/
if(bCoded==FALSE)
{
if (m_vopmd.vopPredType != BVOP
&& m_volmd.fAUsage != RECTANGLE && bPrevRefVopWasCoded)
{
// give the current object a dummy size
m_iNumMBX = m_iNumMBY = m_iNumMB = 1;
saveShapeMode(); // save the previous reference vop shape mode
}
return FALSE;
}
if (m_volmd.fAUsage != RECTANGLE)
resetBYPlane ();
if (m_volmd.fAUsage != RECTANGLE) {
setRefStartingPointers ();
computeVOPMembers ();
}
decodeVOP ();
//wchen: added by sony-probably not the best way
if(m_volmd.volType == ENHN_LAYER &&
(m_vopmd.vopPredType == BVOP && m_vopmd.iRefSelectCode == 0))
swapVOPU8Pointers(m_pvopcCurrQ,m_pvopcRefQ1);
// store the direct mode data
if (m_vopmd.vopPredType != BVOP ||
(m_volmd.volType == ENHN_LAYER && m_vopmd.vopPredType == BVOP && m_vopmd.iRefSelectCode == 0)) {
if(m_volmd.fAUsage != RECTANGLE && bPrevRefVopWasCoded)
saveShapeMode();
CMBMode* pmbmdTmp = m_rgmbmd;
m_rgmbmd = m_rgmbmdRef;
m_rgmbmdRef = pmbmdTmp;
CMotionVector* pmvTmp = m_rgmv;
m_rgmv = m_rgmvRef;
m_rgmvRef = pmvTmp;
m_rgmvBackward = m_rgmv + BVOP_MV_PER_REF_PER_MB * m_iSessNumMB;
}
if (m_volmd.fAUsage != RECTANGLE) {
if (m_vopmd.vopPredType != BVOP ||
(m_volmd.volType == ENHN_LAYER && m_vopmd.vopPredType == BVOP && m_vopmd.iRefSelectCode == 0)) {
m_iNumMBRef = m_iNumMB;
m_iNumMBXRef = m_iNumMBX;
m_iNumMBYRef = m_iNumMBY;
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_rctRefVOPY1 = m_rctCurrVOPY;
m_rctRefVOPY1.expand (EXPANDY_REFVOP);
m_rctRefVOPUV1 = m_rctCurrVOPUV;
m_rctRefVOPUV1.expand (EXPANDUV_REFVOP);
m_pvopcRefQ1->setBoundRct (m_rctRefVOPY1);
}
else { // For Temporal Scalability Added by Sharp(1998-02-10)
m_iBVOPOffsetForPadY = m_rctRefFrameY.offset (m_rctCurrVOPY.left, m_rctCurrVOPY.top);
m_iBVOPOffsetForPadUV = m_rctRefFrameUV.offset (m_rctCurrVOPUV.left, m_rctCurrVOPUV.top);
m_rctBVOPPrevNoExpandY = m_rctCurrVOPY;
m_rctBVOPPrevNoExpandUV = m_rctCurrVOPUV;
m_rctBVOPRefVOPY1 = m_rctCurrVOPY;
m_rctBVOPRefVOPY1.expand (EXPANDY_REFVOP);
m_rctBVOPRefVOPUV1 = m_rctCurrVOPUV;
m_rctBVOPRefVOPUV1.expand (EXPANDUV_REFVOP);
} // For Temporal Scalability End Sharp(1998-02-10)
//give a comment that this is ac/dc pred stuff
Int nBlk = (m_volmd.fAUsage == EIGHT_BIT) ? 10 : 6;
delete [] m_rgblkmCurrMB;
for (Int iMB = 0; iMB < m_iNumMBX; iMB++) {
for (Int iBlk = 0; iBlk < nBlk; iBlk++) {
delete [] (m_rgpmbmAbove [iMB]->rgblkm) [iBlk];
delete [] (m_rgpmbmCurr [iMB]->rgblkm) [iBlk];
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -