📄 h264avcdecoder.cpp
字号:
if ( m_pcNalUnitParser->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR || m_uiNextLayerId == 0)
{
UInt uiMaxFrameNum = 1 << m_pcSliceHeader->getSPS().getLog2MaxFrameNum();
m_uiNextFrameNum = m_pauiFrameNumInGOP[m_uiNextLayerId][m_uiFrameIdx[m_uiNextLayerId] % uiGopSize] % uiMaxFrameNum;
m_uiNextPoc = m_pauiPocInGOP[m_uiNextLayerId][m_uiFrameIdx[m_uiNextLayerId] % uiGopSize];
m_uiNextTempLevel = m_pauiTempLevelInGOP[m_uiNextLayerId][m_uiFrameIdx[m_uiNextLayerId] % uiGopSize];
m_pauiFrameNumInGOP[m_uiNextLayerId][m_uiFrameIdx[m_uiNextLayerId] % uiGopSize] += uiGopSize >> 1;
m_pauiPocInGOP[m_uiNextLayerId][m_uiFrameIdx[m_uiNextLayerId] % uiGopSize] += uiMaxGopSize;
m_uiFrameIdx[m_uiNextLayerId]++;
}
else
{
m_uiNextFrameNum = 0;
m_uiNextPoc = 0;
}
}
//TMM_EC }}
m_pcSliceHeader->setFGSCodingMode( m_bFGSCodingMode );
m_pcSliceHeader->setGroupingSize ( m_uiGroupingSize );
UInt ui;
for( ui = 0; ui < 16; ui++ )
{
m_pcSliceHeader->setPosVect( ui, m_uiPosVect[ui] );
}
}
else
{
//JVT-P031
getDecodedResolution(m_uiDecodedLayer);
if(m_pcNalUnitParser->getLayerId() < m_uiDecodedLayer && m_pcNalUnitParser->getDiscardableFlag())
bDiscardable = true;
else
bDiscardable = false;
RNOK( xStartSlice(bPreParseHeader,bLastFragment, bDiscardable, UnitAVCFlag) ); //FRAG_FIX //TMM_EC //JVT-S036
if(bDiscardable)
ruiEndPos = 0;
else
ruiEndPos = pcBinDataAccessor->size();
uiHeaderBits = uiBitsLeft - m_pcNalUnitParser->getBitsLeft();
if( (bDiscardable) || !bLastFragment) //FRAG_FIX
ruiStartPos = 0;
else
{
//JVT-S036 start
// if(m_pcNalUnitParser->getExtensionFlag())
//{
// ruiStartPos += (uiHeaderBits+3*8+7)>>3;//(uiHeaderBits+7)>>3; //BUG_FIX_FT_01_2006_2
//3*8 is used to take into account the nal header which has already been read
//uiHeaderBits only contains the remaining bits of the slice header read
//}
// else
// {
ruiStartPos += (uiHeaderBits+3*8+7)>>3;//BUG_FIX_FT_01_2006_2
// }
//JVT-S036 end
}
if(m_pcSliceHeader && (m_pcSliceHeader->getFragmentedFlag() && !bLastFragment ))
{ //FIX_FRAG_CAVLC
if(bPreParseHeader)
{
ruiEndPos -= uiNumBytesRemoved;
}//~FIX_FRAG_CAVLC
ruiEndPos -= 2;
}//FIX_FRAG_CAVLC
if(!bDiscardable)
//~JVT-P031
RNOK( m_pcControlMng ->initSlice0(m_pcSliceHeader) );
if(m_pcSliceHeader) //JVT-P031
m_pcSliceHeader->setKeyPictureFlag (KeyPicFlag);
//JVT-P031
bFragmented = (!m_pcSliceHeader ? false : m_pcSliceHeader->getFragmentedFlag());
if( (bLastFragment) || (!bFragmented) ||
( bFragmented && m_pcSliceHeader->getFragmentOrder()+1 == m_uiNumberOfFragment[m_pcSliceHeader->getLayerId() ]))
rbStartDecoding = true;
//~JVT-P031
//TMM_EC {{
if ( !m_bNotSupport && !bPreParseHeader && m_pcNalUnitParser->getQualityLevel() == 0)
{
UInt uiMaxGopSize = m_uiMaxGopSize;
UInt uiGopSize;
m_uiNextLayerId = m_pcSliceHeader->getLayerId();
do
{
m_uiNextLayerId = (m_uiNextLayerId + 1) % m_uiNumLayers;
uiGopSize = 1 << m_uiDecompositionStages[m_uiNextLayerId];
if (m_uiFrameIdx[m_uiNextLayerId] % uiMaxGopSize < m_uiGopSize[m_uiNextLayerId])
break;
m_uiFrameIdx[m_uiNextLayerId]++;
}
while( true);
if ( m_pcNalUnitParser->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR || m_uiNextLayerId == 0)
{
UInt uiMaxFrameNum = 1 << m_pcSliceHeader->getSPS().getLog2MaxFrameNum();
m_uiNextFrameNum = m_pauiFrameNumInGOP[m_uiNextLayerId][m_uiFrameIdx[m_uiNextLayerId] % uiGopSize] % uiMaxFrameNum;
m_uiNextPoc = m_pauiPocInGOP[m_uiNextLayerId][m_uiFrameIdx[m_uiNextLayerId] % uiGopSize];
m_uiNextTempLevel = m_pauiTempLevelInGOP[m_uiNextLayerId][m_uiFrameIdx[m_uiNextLayerId] % uiGopSize];
m_pauiFrameNumInGOP[m_uiNextLayerId][m_uiFrameIdx[m_uiNextLayerId] % uiGopSize] += uiGopSize >> 1;
m_pauiPocInGOP[m_uiNextLayerId][m_uiFrameIdx[m_uiNextLayerId] % uiGopSize] += uiMaxGopSize;
m_uiFrameIdx[m_uiNextLayerId]++;
}
else
{
m_uiNextFrameNum = 0;
m_uiNextPoc = 0;
}
}
//TMM_EC }}
if(m_pcSliceHeader)
{
m_pcSliceHeader->setFGSCodingMode( m_bFGSCodingMode );
m_pcSliceHeader->setGroupingSize ( m_uiGroupingSize );
UInt ui;
for(ui = 0; ui < 16; ui++)
{
m_pcSliceHeader->setPosVect( ui, m_uiPosVect[ui] );
}
}
}
}
break;
case NAL_UNIT_SEI:
{
//===== just for trace file =====
SEI::MessageList cMessageList;
UInt i;
//RNOK( SEI::read( m_pcHeaderSymbolReadIf, cMessageList ) );
RNOK( SEI::read( m_pcHeaderSymbolReadIf, cMessageList ) );
while( ! cMessageList.empty() )
{
SEI::SEIMessage* pcSEIMessage = cMessageList.popBack();
if(pcSEIMessage->getMessageType() == SEI::NON_REQUIRED_SEI)
{
m_pcNonRequiredSei = (SEI::NonRequiredSei*) pcSEIMessage;
m_uiNonRequiredSeiReadFlag = 1;
}
//JVT-W080
else if( pcSEIMessage->getMessageType() == SEI::PARALLEL_DEC_SEI )
{
printf("\n Parallel SEI message received. \tParallel Decoding Enable.\n\n");
delete pcSEIMessage;
}
//~JVT-W080
else
{
if ( pcSEIMessage->getMessageType() == SEI::SCALABLE_SEI)
{
// trick
m_uiNumLayers = ((SEI::ScalableSei*)pcSEIMessage)->getDependencyId( ((SEI::ScalableSei*)pcSEIMessage)->getNumLayersMinus1()) + 1;
for ( uiLayerId=0; uiLayerId<((SEI::ScalableSei*)pcSEIMessage)->getNumLayersMinus1()+1; uiLayerId++)
{
if ( ((SEI::ScalableSei*)pcSEIMessage)->getDependencyId( uiLayerId) != 0)
break;
}
uiLayerId--;
m_uiDecompositionStages[0] = ((SEI::ScalableSei*)pcSEIMessage)->getTemporalLevel( uiLayerId);
m_uiDecompositionStages[m_uiNumLayers-1] = ((SEI::ScalableSei*)pcSEIMessage)->getTemporalLevel( ((SEI::ScalableSei*)pcSEIMessage)->getNumLayersMinus1());
m_uiMaxDecompositionStages = m_uiDecompositionStages[m_uiNumLayers-1];
m_uiMaxGopSize = 1 << m_uiMaxDecompositionStages;
for ( i=0; i< m_uiNumLayers; i++)
m_uiGopSize[i] = 1 << m_uiDecompositionStages[i];
}
//SEI {
else if( pcSEIMessage->getMessageType() == SEI::SCALABLE_NESTING_SEI )
{
m_uiScalableNestingSeiFlag = 1;
m_bAllPicturesInAuFlag = ((SEI::ScalableNestingSei*)pcSEIMessage)->getAllPicturesInAuFlag();
if( m_bAllPicturesInAuFlag == 0 )
{
m_uiNumPicturesMinus1 = ((SEI::ScalableNestingSei*)pcSEIMessage)->getNumPicturesMinus1();
for( UInt index = 0; index <= m_uiNumPicturesMinus1; index++ )
m_uiPicId[index] = ((SEI::ScalableNestingSei*)pcSEIMessage)->getPicId(index);
m_uiTemporalId = ((SEI::ScalableNestingSei*)pcSEIMessage)->getTemporalId();
}
SEI::SEIMessage* pcSEIMessage1 = ((SEI::ScalableNestingSei*)pcSEIMessage)->getSEIMessage();
if( pcSEIMessage1->getMessageType() == SEI::FULLFRAME_SNAPSHOT_SEI )
{
//for snap shot sei
m_uiSnapShotId = ((SEI::FullframeSnapshotSei*)pcSEIMessage1)->getSnapShotId();
m_uiSnapshotSeiFlag = 1;
}
}
else if( pcSEIMessage->getMessageType() == SEI::ACTIVE_VIEWINFO_SEI )
{
//active view information sei message
m_uiActiveViewInfoSeiFlag = 1;
m_bOpPresentFlag = ((SEI::ActiveViewInfoSei*)pcSEIMessage)->getOpPresentFlag();
if( m_bOpPresentFlag )
{
m_uiOperationPointId = ((SEI::ActiveViewInfoSei*)pcSEIMessage)->getOperationPointId();
m_uiNumActiveViews = m_uiNumViews[m_uiOperationPointId];
for(UInt uiView = 0; uiView < m_uiNumActiveViews; uiView++ )
m_uiViewId[uiView] = m_OpViewId[m_uiOperationPointId][uiView];
m_bOpPresentFlag = false;
}
else
{
m_uiNumActiveViews = ((SEI::ActiveViewInfoSei*)pcSEIMessage)->getNumActiveViewsMinus1()+1;
for( UInt index = 0; index < m_uiNumActiveViews; index++ )
m_uiViewId[index] = ((SEI::ActiveViewInfoSei*)pcSEIMessage)->getViewId(index);
}
m_uiNumDecodeViews = m_uiNumActiveViews;
UInt uiView;
for( uiView = 0; uiView < m_uiNumDecodeViews; uiView++ )
m_uiDecodeView[uiView] = m_uiViewId[uiView];
SequenceParameterSet* pcSPS = NULL;
m_pcParameterSetMng->get( pcSPS, 0 );
for( uiView = 0; uiView < m_uiNumDecodeViews; uiView++ )
{
UInt uiId = m_uiDecodeView[uiView];
// for anchor pictures
UInt uiNumRefL0 = pcSPS->SpsMVC->getNumAnchorRefsForListX( uiId, LIST_0 );
UInt uiNumRefL1 = pcSPS->SpsMVC->getNumAnchorRefsForListX( uiId, LIST_1 );
UInt uiL0;
UInt uiL1;
for( uiL0 = 0; uiL0 < uiNumRefL0; uiL0++ )
{
UInt uiIdL0 = pcSPS->SpsMVC->getAnchorRefForListX( uiId, uiL0, LIST_0 );
UInt uiOrig;
for( uiOrig = 0; uiOrig < m_uiNumDecodeViews; uiOrig++ )
if( m_uiDecodeView[uiOrig] == uiIdL0 )
break;
if(uiOrig >= m_uiNumDecodeViews)
{
m_uiDecodeView[m_uiNumDecodeViews] = uiIdL0;
m_uiNumDecodeViews++;
}
}
for( uiL1 = 0; uiL1 < uiNumRefL1; uiL1++ )
{
UInt uiIdL1 = pcSPS->SpsMVC->getAnchorRefForListX( uiId, uiL1, LIST_1 );
UInt uiOrig;
for( uiOrig = 0; uiOrig < m_uiNumDecodeViews; uiOrig++ )
if( m_uiDecodeView[uiOrig] == uiIdL1 )
break;
if(uiOrig >= m_uiNumDecodeViews)
{
m_uiDecodeView[m_uiNumDecodeViews] = uiIdL1;
m_uiNumDecodeViews++;
}
}
//for non anchor picture
uiNumRefL0 = pcSPS->SpsMVC->getNumNonAnchorRefsForListX( uiId, LIST_0 );
uiNumRefL1 = pcSPS->SpsMVC->getNumNonAnchorRefsForListX( uiId, LIST_1 );
for( uiL0 = 0; uiL0 < uiNumRefL0; uiL0++ )
{
UInt uiIdL0 = pcSPS->SpsMVC->getNonAnchorRefForListX( uiId, uiL0, LIST_0 );
UInt uiOrig;
for( uiOrig = 0; uiOrig < m_uiNumDecodeViews; uiOrig++ )
if( m_uiDecodeView[uiOrig] == uiIdL0 )
break;
if(uiOrig >= m_uiNumDecodeViews)
{
m_uiDecodeView[m_uiNumDecodeViews] = uiIdL0;
m_uiNumDecodeViews++;
}
}
for( uiL1 = 0; uiL1 < uiNumRefL1; uiL1++ )
{
UInt uiIdL1 = pcSPS->SpsMVC->getNonAnchorRefForListX( uiId, uiL1, LIST_1 );
UInt uiOrig;
for( uiOrig = 0; uiOrig < m_uiNumDecodeViews; uiOrig++ )
if( m_uiDecodeView[uiOrig] == uiIdL1 )
break;
if(uiOrig >= m_uiNumDecodeViews)
{
m_uiDecodeView[m_uiNumDecodeViews] = uiIdL1;
m_uiNumDecodeViews++;
}
}
}
}
else if( pcSEIMessage->getMessageType() == SEI::VIEW_SCALABILITY_INFO_SEI )
{
m_uiNumOpMinus1 = ((SEI::ViewScalabilityInfoSei*)pcSEIMessage)->getNumOperationPointsMinus1();
for( UInt uiOp = 0; uiOp <= m_uiNumOpMinus1; uiOp++ )
{
m_uiNumViews[uiOp] = ((SEI::ViewScalabilityInfoSei*)pcSEIMessage)->getNumActiveViewsMinus1(uiOp)+1;
m_OpViewId[uiOp] = (UInt*)malloc(m_uiNumViews[uiOp]*sizeof(UInt));
for(UInt uiView = 0; uiView < m_uiNumViews[uiOp]; uiView++ )
m_OpViewId[uiOp][uiView] = ((SEI::ViewScalabilityInfoSei*)pcSEIMessage)->getViewId(uiOp, uiView);
}
printf("\n View Scalability Info SEI message received. \n");
}
//SEI }
else if( pcSEIMessage->getMessageType() == SEI::MULTIVIEW_SCENE_INFO_SEI ) // SEI JVT-W060
{
m_uiMultiviewSceneInfoSeiFlag = 1;
m_uiMaxDisparity = ((SEI::MultiviewSceneInfoSei*)pcSEIMessage)->getMaxDisparity();
printf("\n Multiview Scene Info SEI message received. \tMaxDisparity=%d\n",m_uiMaxDisparity);
}
else if ( pcSEIMessage->getMessageType() == SEI::MULTIVIEW_ACQUISITION_INFO_SEI) // SEI JVT-W060
{
printf("\n Multiview Acquisition Info SEI message received\n");
m_uiMultiviewAcquisitionInfoSeiFlag = 1;
UInt uiIndex;
int i,j;
UInt NumViewMinus1 = (UInt) ((SEI::MultiviewAcquisitionInfoSei*)pcSEIMessage)->getNumViewMinus1();
Bool m_bIntrinsicParamFlag=(Bool)((SEI::MultiviewAcquisitionInfoSei*)pcSEIMessage)->getIntrinsicParamFlag();
printf("NumViewMunis1= %d\n", NumViewMinus1);
printf("IntrinsicParamFlag= %d\n", m_bIntrinsicParamFlag);
if (m_bIntrinsicParamFlag)
{
Bool m_bIntrinsicParamsEqual=(Bool)((SEI::MultiviewAcquisitionInfoSei*)pcSEIMessage)->getIntrinsicParamsEqual();
printf("IntrinsicParamsEqual = %d\n",m_bIntrinsicParamsEqual );
UInt m_uiPrecFocalLength= (UInt)((SEI::MultiviewAcquisitionInfoSei*)pcSEIMessage)->getPrecFocalLength();
printf("PrecFocalLength = %d\n",m_uiPrecFocalLength );
UInt m_uiPrecPrincipalPoint= (UInt)((SEI::MultiviewAcquisitionInfoSei*)pcSEIMessage)->getPrecPrincipalPoint();
printf("PrecPrincipalPoint = %d\n",m_uiPrecPrincipalPoint );
UInt m_uiPrecRadialDistortion= (UInt)((SEI::MultiviewAcquisitionInfoSei*)pcSEIMessage)->getPrecRadialDistortion();
printf("PrecRadialDistortion = %d\n",m_uiPrecRadialDistortion );
UInt sign_dec,exp_dec,mant_dec,var_length;
double reconst=0.0;
for( uiIndex = 0; uiIndex <= NumViewMinus1; uiIndex++ )
{
printf("SignFocalLengthX[%d]=%d\n",uiIndex,sign_dec=(UInt)((SEI::MultiviewAcquisitionInfoSei*)pcSEIMessage)->getSignFocalLengthX(uiIndex));
printf("ExponentFocalLengthX[%d]=%d\n",uiIndex,exp_dec=(UInt)((SEI::MultiviewAcquisitionInfoSei*)pcSEIMessage)->getExponentFocalLengthX(uiIndex));
printf("MantissaFocalLengthX[%d]=%d\n",uiIndex,mant_dec=(UInt)((SEI::MultiviewAcquisitionInfoSei*)pcSEIMessage)->getMantissaFocalLengthX(uiIndex));
var_length = (UInt)((SEI::MultiviewAcquisitionInfoSei*)pcSEIMessage)->getVarLength(exp_dec,m_uiPrecFocalLength);
if (!(UInt)((SEI::MultiviewAcquisitionInfoSei*)pcSEIMessage)->getReconstSceneAcqSEI(exp_dec, sign_dec, mant_dec, var_length, &reconst))
printf("Reconstructed FocalLengthX[%d]=%f\n",uiIndex,reconst);
else
printf("Invalid FocalLengthX[%d]\n",uiIndex);
printf("SignFocalLengthY[%d]=%d\n",uiIndex,sign_dec=((SEI::MultiviewAcquisitionInfoSei*)pcSEIMessage)->getSignFocalLengthY(uiIndex));
printf("ExponentFocalLengthY[%d]=%d\n",uiIndex,exp_dec=((SEI::MultiviewAcquisitionInfoSei*)pcSEIMessage)->getExponentFocalLengthY(uiIndex));
printf("MantissaFocalLengthY[%d]=%d\n",uiIndex,mant_dec=((SEI::MultiviewAcquisitionInfoSei*)pcSEIMessage)->getMantissaFocalLengthY(uiIndex));
var_l
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -