📄 vopsedec.cpp
字号:
m_volmd.bNoUpdate = m_pbitstrmIn -> getBits (1);
m_volmd.bUpsampling = m_pbitstrmIn -> getBits (1);
if (!(m_volmd.bOpaque ||
m_volmd.bTransparent ||
m_volmd.bIntraCAE ||
m_volmd.bInterCAE ||
m_volmd.bNoUpdate ||
m_volmd.bUpsampling)) {
fatal_error("Shape complexity estimation is enabled,\nbut no correponding flag is enabled.");
}
}
else
m_volmd.bOpaque =
m_volmd.bTransparent =
m_volmd.bIntraCAE =
m_volmd.bInterCAE =
m_volmd.bNoUpdate =
m_volmd.bUpsampling = false;
m_volmd.bTextureComplexityEstimationSet1Disable = m_pbitstrmIn -> getBits (1);
if (! m_volmd.bTextureComplexityEstimationSet1Disable) {
m_volmd.bIntraBlocks = m_pbitstrmIn -> getBits (1);
m_volmd.bInterBlocks = m_pbitstrmIn -> getBits (1);
m_volmd.bInter4vBlocks = m_pbitstrmIn -> getBits (1);
m_volmd.bNotCodedBlocks = m_pbitstrmIn -> getBits (1);
if (!(m_volmd.bIntraBlocks ||
m_volmd.bInterBlocks ||
m_volmd.bInter4vBlocks ||
m_volmd.bNotCodedBlocks)) {
fatal_error("Texture complexity estimation set 1 is enabled,\nbut no correponding flag is enabled.");
}
}
else
m_volmd.bIntraBlocks =
m_volmd.bInterBlocks =
m_volmd.bInter4vBlocks =
m_volmd.bNotCodedBlocks = false;
uiMark = m_pbitstrmIn -> getBits (1);
assert (uiMark == 1);
m_volmd.bTextureComplexityEstimationSet2Disable = m_pbitstrmIn -> getBits (1);
if (! m_volmd.bTextureComplexityEstimationSet2Disable) {
m_volmd.bDCTCoefs = m_pbitstrmIn -> getBits (1);
m_volmd.bDCTLines = m_pbitstrmIn -> getBits (1);
m_volmd.bVLCSymbols = m_pbitstrmIn -> getBits (1);
m_volmd.bVLCBits = m_pbitstrmIn -> getBits (1);
if (!(m_volmd.bDCTCoefs ||
m_volmd.bDCTLines ||
m_volmd.bVLCSymbols ||
m_volmd.bVLCBits)) {
fatal_error("Texture complexity estimation set 2 is enabled,\nbut no correponding flag is enabled.");
}
}
else
m_volmd.bDCTCoefs =
m_volmd.bDCTLines =
m_volmd.bVLCSymbols =
m_volmd.bVLCBits = false;
m_volmd.bMotionCompensationComplexityDisable = m_pbitstrmIn -> getBits (1);
if (! m_volmd.bMotionCompensationComplexityDisable) {
m_volmd.bAPM = m_pbitstrmIn -> getBits (1);
m_volmd.bNPM = m_pbitstrmIn -> getBits (1);
m_volmd.bInterpolateMCQ = m_pbitstrmIn -> getBits (1);
m_volmd.bForwBackMCQ = m_pbitstrmIn -> getBits (1);
m_volmd.bHalfpel2 = m_pbitstrmIn -> getBits (1);
m_volmd.bHalfpel4 = m_pbitstrmIn -> getBits (1);
if (!(m_volmd.bAPM ||
m_volmd.bNPM ||
m_volmd.bInterpolateMCQ ||
m_volmd.bForwBackMCQ ||
m_volmd.bHalfpel2 ||
m_volmd.bHalfpel4)) {
fatal_error("Motion complexity estimation is enabled,\nbut no correponding flag is enabled.");
}
}
else
m_volmd.bAPM =
m_volmd.bNPM =
m_volmd.bInterpolateMCQ =
m_volmd.bForwBackMCQ =
m_volmd.bHalfpel2 =
m_volmd.bHalfpel4 = false;
uiMark = m_pbitstrmIn -> getBits (1);
assert (uiMark == 1);
}
// END: Complexity Estimation syntax support
/* UInt uiResyncMarkerDisable = wmay */m_pbitstrmIn -> getBits (1);
// Modified by Toshiba(1998-4-7)
m_volmd.bDataPartitioning = m_pbitstrmIn -> getBits (1);
if( m_volmd.bDataPartitioning )
m_volmd.bReversibleVlc = m_pbitstrmIn -> getBits (1);
else
m_volmd.bReversibleVlc = FALSE;
// End Toshiba
//wchen: wd changes
m_volmd.volType = (m_pbitstrmIn -> getBits (1) == 0) ? BASE_LAYER : ENHN_LAYER;
m_volmd.ihor_sampling_factor_n = 1;
m_volmd.ihor_sampling_factor_m = 1;
m_volmd.iver_sampling_factor_n = 1;
m_volmd.iver_sampling_factor_m = 1;
if (m_volmd.volType == ENHN_LAYER) {
//#ifdef _Scalable_SONY_
m_volmd.iHierarchyType = m_pbitstrmIn->getBits (1); //
if(m_volmd.iHierarchyType == 0)
fprintf(stdout,"Hierarchy_Type == 0 (Spatial scalability)\n");
else if(m_volmd.iHierarchyType == 1)
fprintf(stdout,"Hierarchy_type == 1 (Temporal scalability)\n");
//#endif _Scalable_SONY_
m_pbitstrmIn->getBits (4); // ref_layer_id
m_pbitstrmIn->getBits (1); // ref_layer_samping_director
m_volmd.ihor_sampling_factor_n = m_pbitstrmIn->getBits (5);
m_volmd.ihor_sampling_factor_m = m_pbitstrmIn->getBits (5);
m_volmd.iver_sampling_factor_n = m_pbitstrmIn->getBits (5);
m_volmd.iver_sampling_factor_m = m_pbitstrmIn->getBits (5);
m_volmd.iEnhnType = m_pbitstrmIn->getBits (1); //enhancement_type
}
m_volmd.bDeblockFilterDisable = TRUE; //no deblocking filter
}
Void CVideoObjectDecoder::FakeOutVOVOLHead (int h, int w, int fr, Bool *pbSpatialScalability)
{
m_volmd.iClockRate = fr;
Int iClockRate = m_volmd.iClockRate;
assert (iClockRate >= 1 && iClockRate < 65536);
for (m_iNumBitsTimeIncr = 1; m_iNumBitsTimeIncr < NUMBITS_TIME_RESOLUTION; m_iNumBitsTimeIncr++) {
if (iClockRate == 1)
break;
iClockRate = (iClockRate >> 1);
}
m_volmd.bShapeOnly = FALSE;
m_volmd.fAUsage = RECTANGLE;
m_ivolWidth = w;
m_ivolHeight = h;
m_vopmd.bInterlace = 0;
m_volmd.bAdvPredDisable = 1;
m_uiSprite = 0;
m_volmd.bNot8Bit = 0;
m_volmd.uiQuantPrecision = 5;
m_volmd.nBits = 8;
m_volmd.fQuantizer = Q_H263;
#if 0
m_volmd.bLoadIntraMatrix = 0;
memcpy (m_volmd.rgiIntraQuantizerMatrix, rgiDefaultIntraQMatrix, BLOCK_SQUARE_SIZE * sizeof (Int));
m_volmd.bLoadInterMatrix = 0;
memcpy (m_volmd.rgiInterQuantizerMatrix, rgiDefaultInterQMatrix, BLOCK_SQUARE_SIZE * sizeof (Int));
#endif
m_volmd.bComplexityEstimationDisable = 1; // huh ?
m_volmd.bDataPartitioning = 0;
m_volmd.bReversibleVlc = FALSE;
m_volmd.volType = BASE_LAYER;
m_volmd.ihor_sampling_factor_n = 1;
m_volmd.ihor_sampling_factor_m = 1;
m_volmd.iver_sampling_factor_n = 1;
m_volmd.iver_sampling_factor_m = 1;
m_volmd.bDeblockFilterDisable = TRUE;
postVO_VOLHeadInit(w, h, pbSpatialScalability);
}
Int BGComposition; // added by Sharp (98/3/24)
Bool CVideoObjectDecoder::decodeVOPHead ()
{
// Start code
UInt uiVopStartCode = m_pbitstrmIn -> getBits (NUMBITS_VOP_START_CODE);
while (uiVopStartCode == GOV_START_CODE ||
(uiVopStartCode >= 0 && uiVopStartCode <= 0x1f) ||
uiVopStartCode == SESSION_START_CODE ||
uiVopStartCode == VISUAL_OBJ_START_CODE ||
(uiVopStartCode >= 0x20 && uiVopStartCode <= 0x2f)) {
if (uiVopStartCode >= 0 && uiVopStartCode <= 0x1f) {
decodeVOBody();
} else if (uiVopStartCode >= 0x20 && uiVopStartCode <= 0x2f) {
decodeVOLBody();
} else
switch (uiVopStartCode) {
case GOV_START_CODE: {
/*Added by SONY (98/03/30)*/
m_bUseGOV = TRUE;
m_bLinkisBroken = FALSE;
/*Added by SONY (98/03/30) End */
Int timecode;
timecode = m_pbitstrmIn -> getBits (5) * 3600;
timecode += m_pbitstrmIn -> getBits (6) * 60;
m_pbitstrmIn -> getBits (1);
timecode += m_pbitstrmIn -> getBits (6);
m_tModuloBaseDecd = timecode;
m_tModuloBaseDisp = timecode;
#ifdef DEBUG_OUTPUT
cout << "GOV Header (t=" << timecode << ")\n\n";
#endif
Int closed_gov = m_pbitstrmIn -> getBits (1);
Int broken_link = m_pbitstrmIn -> getBits (1);
/*modified by SONY (98/03/30)*/
if ((closed_gov == 0)&&(broken_link == 1))
m_bLinkisBroken = TRUE;
}
break;
default:
break;
}
/*modified by SONY (98/03/30) End*/
Int err = findStartCode();
if (err == EOF) return FALSE;
uiVopStartCode = m_pbitstrmIn -> getBits (NUMBITS_VOP_START_CODE);
}
//980212
if (uiVopStartCode != VOP_START_CODE) {
printf("Illegal VOP start code %x found in header", uiVopStartCode);
}
assert(uiVopStartCode == VOP_START_CODE);
if (m_pbitstrmIn->peekBits(NUMBITS_START_CODE_PREFIX) == START_CODE_PREFIX) {
return decodeVOPHead();
}
m_vopmd.vopPredType = (VOPpredType) m_pbitstrmIn -> getBits (NUMBITS_VOP_PRED_TYPE);
// Time reference and VOP_pred_type
Int iModuloInc = 0;
while (m_pbitstrmIn -> getBits (1) != 0)
iModuloInc++;
Time tCurrSec = iModuloInc + ((m_vopmd.vopPredType != BVOP ||
(m_vopmd.vopPredType == BVOP && m_volmd.volType == ENHN_LAYER ))?
m_tModuloBaseDecd : m_tModuloBaseDisp);
// Added for error resilient mode by Toshiba(1997-11-14)
UInt uiMarker = m_pbitstrmIn -> getBits (1);
assert(uiMarker== 1);
// End Toshiba(1997-11-14)
Time tVopIncr = m_pbitstrmIn -> getBits (m_iNumBitsTimeIncr);
uiMarker = m_pbitstrmIn->getBits (1); // marker bit
assert(uiMarker ==1);
m_tOldModuloBaseDecd = m_tModuloBaseDecd;
m_tOldModuloBaseDisp = m_tModuloBaseDisp;
if (m_vopmd.vopPredType != BVOP ||
(m_vopmd.vopPredType == BVOP && m_volmd.volType == ENHN_LAYER ))
{
m_tModuloBaseDisp = m_tModuloBaseDecd; //update most recently displayed time base
m_tModuloBaseDecd = tCurrSec;
}
m_t = tCurrSec * m_volmd.iClockRate*m_iClockRateScale + tVopIncr*m_iClockRateScale;
if (m_pbitstrmIn->getBits (1) == 0) { //vop_coded == false
m_vopmd.bInterlace = FALSE; //wchen: temporary solution
return FALSE;
}
if (m_vopmd.vopPredType == PVOP && m_volmd.bShapeOnly==FALSE)
m_vopmd.iRoundingControl = m_pbitstrmIn->getBits (1); //"VOP_Rounding_Type"
else
m_vopmd.iRoundingControl = 0;
if (m_volmd.fAUsage != RECTANGLE) {
// Begin: modified by Hughes 4/9/98
if (!(m_uiSprite == 1 && m_vopmd.vopPredType == IVOP)) {
// End: modified by Hughes 4/9/98
Int width = m_pbitstrmIn -> getBits (NUMBITS_VOP_WIDTH);
// spt VOP assert (width % MB_SIZE == 0); // for sprite, may not be multiple of MB_SIZE
Int marker;
marker = m_pbitstrmIn -> getBits (1); // marker bit
assert(marker==1);
Int height = m_pbitstrmIn -> getBits (NUMBITS_VOP_HEIGHT);
// spt VOP assert (height % MB_SIZE == 0); // for sprite, may not be multiple of MB_SIZE
marker = m_pbitstrmIn -> getBits (1); // marker bit
assert(marker==1);
//wchen: cd changed to 2s complement
Int left = (m_pbitstrmIn -> getBits (1) == 0) ?
m_pbitstrmIn->getBits (NUMBITS_VOP_HORIZONTAL_SPA_REF - 1) :
((Int)m_pbitstrmIn->getBits (NUMBITS_VOP_HORIZONTAL_SPA_REF - 1) - (1 << (NUMBITS_VOP_HORIZONTAL_SPA_REF - 1)));
marker = m_pbitstrmIn -> getBits (1); // marker bit
assert(marker==1);
Int top = (m_pbitstrmIn -> getBits (1) == 0) ?
m_pbitstrmIn->getBits (NUMBITS_VOP_VERTICAL_SPA_REF - 1) :
((Int)m_pbitstrmIn->getBits (NUMBITS_VOP_VERTICAL_SPA_REF - 1) - (1 << (NUMBITS_VOP_VERTICAL_SPA_REF - 1)));
assert(((left | top)&1)==0); // must be even pix unit
m_rctCurrVOPY = CRct (left, top, left + width, top + height);
m_rctCurrVOPUV = m_rctCurrVOPY.downSampleBy2 ();
}
if ( m_volmd.volType == ENHN_LAYER && m_volmd.iEnhnType == 1 ){
BGComposition = m_pbitstrmIn -> getBits (1); // modified by Sharp (98/3/24)
// assert(BackgroundComposition==1); // modified by Sharp (98/3/24)
}
m_volmd.bNoCrChange = m_pbitstrmIn -> getBits (1); //VOP_CR_Change_Disable
Int iVopConstantAlpha = m_pbitstrmIn -> getBits (1);
if(iVopConstantAlpha==1)
m_vopmd.iVopConstantAlphaValue = m_pbitstrmIn -> getBits (8);
else
m_vopmd.iVopConstantAlphaValue = 255;
m_vopmd.bShapeCodingType = (m_vopmd.vopPredType == IVOP) ? 0 : 1; // Added error resilient mode by Toshiba(1998-1-16)
}
// START: Complexity Estimation syntax support - Marc Mongenet (EPFL) - 15 Jun 1998
if (! m_volmd.bComplexityEstimationDisable) {
if (m_volmd.iEstimationMethod != 0) {
fprintf (stderr, "ERROR: Unknown estimation method number %d.\n", m_volmd.iEstimationMethod);
exit (1);
}
if (m_vopmd.vopPredType == IVOP ||
m_vopmd.vopPredType == PVOP ||
m_vopmd.vopPredType == BVOP) {
if (m_volmd.bOpaque) {
printf ("dcecs_opaque = %d\n", m_vopmd.iOpaque = m_pbitstrmIn -> getBits (8));
if (m_vopmd.iOpaque == 0) {
fprintf (stderr, "ERROR: Illegal null value for 'opaque' complexity estimation.\n");
exit (1);
}
}
if (m_volmd.bTransparent) {
printf ("dcecs_transparent = %d\n", m_vopmd.iTransparent = m_pbitstrmIn -> getBits (8));
if (m_vopmd.iTransparent == 0) {
fprintf (stderr, "ERROR: Illegal null value for 'transparent' complexity estimation.\n");
exit (1);
}
}
if (m_volmd.bIntraCAE) {
printf ("dcecs_intra_cae = %d\n", m_vopmd.iIntraCAE = m_pbitstrmIn -> getBits (8));
if (m_vopmd.iIntraCAE == 0) {
fprintf (stderr, "ERROR: Illegal null value for 'intra_cae' complexity estimation.\n");
exit (1);
}
}
if (m_volmd.bInterCAE) {
printf ("dcecs_inter_cae = %d\n", m_vopmd.iInterCAE = m_pbitstrmIn -> getBits (8));
if (m_vopmd.iInterCAE == 0) {
fprintf (stderr, "ERROR: Illegal null value for 'inter_cae' complexity estimation.\n");
exit (1);
}
}
if (m_volmd.bNoUpdate) {
printf ("dcecs_no_update = %d\n", m_vopmd.iNoUpdate = m_pbitstrmIn -> getBits (8));
if (m_vopmd.iNoUpdate == 0) {
fprintf (stderr, "ERROR: Illegal null value for 'no_update' complexity estimation.\n");
exit (1);
}
}
if (m_volmd.bUpsampling) {
printf ("dcecs_upsampling = %d\n", m_vopmd.iUpsampling = m_pbitstrmIn -> getBits (8));
if (m_vopmd.iUpsampling == 0) {
fprintf (stderr, "ERROR: Illegal null value for 'upsampling' complexity estimation.\n");
exit (1);
}
}
}
if (m_volmd.bIntraBlocks) {
printf ("dcecs_intra_blocks = %d\n", m_vopmd.iIntraBlocks = m_pbitstrmIn -> getBits (8));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -