ErrVal MbCoder::encode( MbDataAccess& rcMbDataAccess, MbDataAccess* pcMbDataAccessBase, Int iSpatialScalabilityType, Bool bTerminateSlice ) { ROF( m_bInitDone ); //===== skip flag ===== Bool bIsCoded = ! rcMbDataAccess.isSkippedMb(); RNOK( m_pcMbSymbolWriteIf->skipFlag( rcMbDataAccess, false ) ); if( bIsCoded ) { //===== base layer mode flag and base layer refinement flag ===== if( rcMbDataAccess.getSH().getBaseLayerId() != MSYS_UINT_MAX ) { if ( pcMbDataAccessBase->getMbData().getInCropWindowFlag() == true )// TMM_ESS { if( rcMbDataAccess.getSH().getAdaptivePredictionFlag() ) { RNOK ( m_pcMbSymbolWriteIf->BLSkipFlag( rcMbDataAccess ) ); } else { ROF( rcMbDataAccess.getMbData().getBLSkipFlag () ); } // TMM_ESS { } else // of if ( rcMbDataAccess.getMbData().getInCropWindowFlag() == true ) { ROT ( rcMbDataAccess.getMbData().getBLSkipFlag () ); } // TMM_ESS } } else { ROT ( rcMbDataAccess.getMbData().getBLSkipFlag () ); } //===== macroblock mode ===== if( ! rcMbDataAccess.getMbData().getBLSkipFlag() ) { MbMode eMbModeOrg = rcMbDataAccess.getMbData().getMbMode(); MbMode eMbModeSet = ( eMbModeOrg == INTRA_BL ? INTRA_4X4 : eMbModeOrg ); rcMbDataAccess.getMbData().setMbMode( eMbModeSet ); RNOK( m_pcMbSymbolWriteIf->mbMode( rcMbDataAccess ) ); rcMbDataAccess.getMbData().setMbMode( eMbModeOrg ); } //--- reset motion pred flags --- if( rcMbDataAccess.getMbData().getBLSkipFlag() || rcMbDataAccess.getMbData().isIntra() || rcMbDataAccess.getMbData().getMbMode() == MODE_SKIP ) { rcMbDataAccess.getMbMotionData( LIST_0 ).setMotPredFlag( false ); rcMbDataAccess.getMbMotionData( LIST_1 ).setMotPredFlag( false ); } else if( rcMbDataAccess.getSH().isInterB() ) { for( B8x8Idx c8x8Idx; c8x8Idx.isLegal(); c8x8Idx++ ) { if( BLK_SKIP == rcMbDataAccess.getMbData().getBlkMode ( c8x8Idx.b8x8Index() ) || !rcMbDataAccess .getMbData().isBlockFwdBwd( c8x8Idx.b8x8Index(), LIST_0 ) ) { rcMbDataAccess.getMbMotionData( LIST_0 ).setMotPredFlag( false, c8x8Idx ); } if( BLK_SKIP == rcMbDataAccess.getMbData().getBlkMode ( c8x8Idx.b8x8Index() ) || !rcMbDataAccess .getMbData().isBlockFwdBwd( c8x8Idx.b8x8Index(), LIST_1 ) ) { rcMbDataAccess.getMbMotionData( LIST_1 ).setMotPredFlag( false, c8x8Idx ); } } } //===== prediction info ===== if( ! rcMbDataAccess.getMbData().getBLSkipFlag() ) { //===== BLOCK MODES ===== if( rcMbDataAccess.getMbData().isInter8x8() ) { RNOK( m_pcMbSymbolWriteIf->blockModes( rcMbDataAccess ) ); } if( rcMbDataAccess.getMbData().isPCM() ) { //===== PCM SAMPLES ===== RNOK( m_pcMbSymbolWriteIf->samplesPCM( rcMbDataAccess ) ); } else if( rcMbDataAccess.getMbData().isIntra() ) { //===== INTRA PREDICTION MODES ===== RNOK( xWriteIntraPredModes( rcMbDataAccess ) ); } else { //===== MOTION INFORMATION ===== MbMode eMbMode = rcMbDataAccess.getMbData().getMbMode(); if( rcMbDataAccess.getSH().isInterB() ) { RNOK( xWriteMotionPredFlags( rcMbDataAccess, eMbMode, LIST_0 ) ); RNOK( xWriteMotionPredFlags( rcMbDataAccess, eMbMode, LIST_1 ) ); RNOK( xWriteReferenceFrames( rcMbDataAccess, eMbMode, LIST_0 ) ); RNOK( xWriteReferenceFrames( rcMbDataAccess, eMbMode, LIST_1 ) ); RNOK( xWriteMotionVectors ( rcMbDataAccess, eMbMode, LIST_0 ) ); RNOK( xWriteMotionVectors ( rcMbDataAccess, eMbMode, LIST_1 ) ); } else { RNOK( xWriteMotionPredFlags( rcMbDataAccess, eMbMode, LIST_0 ) ); RNOK( xWriteReferenceFrames( rcMbDataAccess, eMbMode, LIST_0 ) ); RNOK( xWriteMotionVectors ( rcMbDataAccess, eMbMode, LIST_0 ) ); } } } //===== TEXTURE ===== if( ! rcMbDataAccess.getMbData().isPCM() ) { Bool bTrafo8x8Flag = ( rcMbDataAccess.getSH().getPPS().getTransform8x8ModeFlag() && ( rcMbDataAccess.getMbData().getBLSkipFlag() || ( rcMbDataAccess.getMbData().is8x8TrafoFlagPresent() && !rcMbDataAccess.getMbData().isIntra4x4() ) ) ); //-- JVT-R091 RNOK( xWriteTextureInfo( rcMbDataAccess, pcMbDataAccessBase, rcMbDataAccess.getMbTCoeffs(), bTrafo8x8Flag ) ); //-- } } //--- write terminating bit --- RNOK( m_pcMbSymbolWriteIf->terminatingBit ( bTerminateSlice ? 1:0 ) ); if( bTerminateSlice ) { RNOK( m_pcMbSymbolWriteIf->finishSlice() ); } return Err::m_nOK; }
ErrVal MbCoder::xWriteMotionPredFlags_FGS( MbDataAccess& rcMbDataAccess, MbDataAccess* pcMbDataAccessBase, MbMode eMbMode, ListIdx eLstIdx ) { AOT_DBG( rcMbDataAccess.getMbData().isIntra() ); ROFRS ( rcMbDataAccess.getSH().getAdaptivePredictionFlag (), Err::m_nOK ); ROF ( pcMbDataAccessBase ); switch( eMbMode ) { case MODE_SKIP: { break; } case MODE_16x16: { if( rcMbDataAccess .getMbData().isBlockFwdBwd( B_8x8_0, eLstIdx) && pcMbDataAccessBase->getMbData().isBlockFwdBwd( B_8x8_0, eLstIdx) ) { RNOK( m_pcMbSymbolWriteIf->motionPredFlag( rcMbDataAccess, eLstIdx ) ); } break; } case MODE_16x8: { if( rcMbDataAccess .getMbData().isBlockFwdBwd( B_8x8_0, eLstIdx) && pcMbDataAccessBase->getMbData().isBlockFwdBwd( B_8x8_0, eLstIdx) ) { RNOK( m_pcMbSymbolWriteIf->motionPredFlag( rcMbDataAccess, eLstIdx, PART_16x8_0 ) ); } if( rcMbDataAccess .getMbData().isBlockFwdBwd( B_8x8_2, eLstIdx) && pcMbDataAccessBase->getMbData().isBlockFwdBwd( B_8x8_2, eLstIdx) ) { RNOK( m_pcMbSymbolWriteIf->motionPredFlag( rcMbDataAccess, eLstIdx, PART_16x8_1 ) ); } break; } case MODE_8x16: { if( rcMbDataAccess .getMbData().isBlockFwdBwd( B_8x8_0, eLstIdx) && pcMbDataAccessBase->getMbData().isBlockFwdBwd( B_8x8_0, eLstIdx) ) { RNOK( m_pcMbSymbolWriteIf->motionPredFlag( rcMbDataAccess, eLstIdx, PART_8x16_0 ) ); } if( rcMbDataAccess .getMbData().isBlockFwdBwd( B_8x8_1, eLstIdx) && pcMbDataAccessBase->getMbData().isBlockFwdBwd( B_8x8_1, eLstIdx) ) { RNOK( m_pcMbSymbolWriteIf->motionPredFlag( rcMbDataAccess, eLstIdx, PART_8x16_1 ) ); } break; } case MODE_8x8: case MODE_8x8ref0: { for( B8x8Idx c8x8Idx; c8x8Idx.isLegal(); c8x8Idx++ ) { if( BLK_SKIP != rcMbDataAccess.getMbData().getBlkMode ( c8x8Idx.b8x8Index() ) && rcMbDataAccess .getMbData().isBlockFwdBwd( c8x8Idx.b8x8Index(), eLstIdx) && pcMbDataAccessBase ->getMbData().isBlockFwdBwd( c8x8Idx.b8x8Index(), eLstIdx) ) { RNOK( m_pcMbSymbolWriteIf->motionPredFlag( rcMbDataAccess, eLstIdx, c8x8Idx.b8x8() ) ); } } break; } default: { AF(); return Err::m_nERR; } } return Err::m_nOK; }
ErrVal MbParser::xReadTextureInfo( MbDataAccess& rcMbDataAccess, Bool bTrafo8x8Flag, Bool bBaseLayerAvailable, UInt uiStart, UInt uiStop ) { Bool bReadDQp = ( uiStart < uiStop ); if( !rcMbDataAccess.getSH().isIntraSlice() && rcMbDataAccess.getMbData().getInCropWindowFlag() && ( rcMbDataAccess.getMbData().getBLSkipFlag() || !rcMbDataAccess.getMbData().isIntra() ) ) { if( rcMbDataAccess.getSH().getAdaptiveResidualPredictionFlag() ) { DECRNOK( m_pcMbSymbolReadIf->resPredFlag( rcMbDataAccess ) ); } else { rcMbDataAccess.getMbData().setResidualPredFlag( rcMbDataAccess.getSH().getDefaultResidualPredictionFlag() ); } } else { rcMbDataAccess.getMbData().setResidualPredFlag( false ); } if( rcMbDataAccess.getMbData().getBLSkipFlag() || !rcMbDataAccess.getMbData().isIntra16x16() ) { if( uiStart >= uiStop ) { rcMbDataAccess.getMbData().setMbCbp( 0 ); } else { DECRNOK( m_pcMbSymbolReadIf->cbp( rcMbDataAccess, uiStart, uiStop ) ); } bReadDQp = rcMbDataAccess.getMbData().getMbCbp() != 0; } if( bTrafo8x8Flag && ( rcMbDataAccess.getMbData().getMbCbp() & 0x0F ) ) { DECRNOK( m_pcMbSymbolReadIf->transformSize8x8Flag( rcMbDataAccess ) ); } if( bReadDQp ) { DECRNOK( m_pcMbSymbolReadIf->deltaQp( rcMbDataAccess ) ); } else { rcMbDataAccess.resetQp(); } Bool bIntra16x16 = ( !rcMbDataAccess.getMbData().getBLSkipFlag() && rcMbDataAccess.getMbData().isIntra16x16 () ); if( bIntra16x16 ) { UInt uiDummy = 0; if( uiStart == 0 && uiStop != 0 ) { DECRNOK( m_pcMbSymbolReadIf->residualBlock( rcMbDataAccess, B4x4Idx(0), LUMA_I16_DC, uiDummy, uiStart, uiStop ) ); } if( rcMbDataAccess.getMbData().isAcCoded() && uiStop > 1 ) { for( S4x4Idx cIdx; cIdx.isLegal(); cIdx++ ) { DECRNOK( m_pcMbSymbolReadIf->residualBlock( rcMbDataAccess, cIdx, LUMA_I16_AC, uiDummy, uiStart, uiStop ) ); } rcMbDataAccess.getMbData().setMbCbp( 0xf + ( rcMbDataAccess.getMbData().getCbpChroma16x16() << 4) ); } else { rcMbDataAccess.getMbData().setMbCbp( 0x0 + ( rcMbDataAccess.getMbData().getCbpChroma16x16() << 4) ); } DECRNOK( xScanChromaBlocks( rcMbDataAccess, rcMbDataAccess.getMbData().getCbpChroma16x16(), uiStart, uiStop ) ); return Err::m_nOK; } UInt uiMbExtCbp = rcMbDataAccess.getMbData().getMbExtCbp(); if( rcMbDataAccess.getMbData().isTransformSize8x8() ) { for( B8x8Idx c8x8Idx; c8x8Idx.isLegal(); c8x8Idx++ ) { if( uiMbExtCbp & ( 1 << c8x8Idx.b4x4() ) ) { DECRNOK( m_pcMbSymbolReadIf->residualBlock8x8( rcMbDataAccess, c8x8Idx, uiStart, uiStop ) ); } } } else { for( B8x8Idx c8x8Idx; c8x8Idx.isLegal(); c8x8Idx++ ) { if( uiMbExtCbp & ( 1 << c8x8Idx.b4x4() ) ) { for( S4x4Idx cIdx( c8x8Idx ); cIdx.isLegal( c8x8Idx ); cIdx++ ) { DECRNOK( m_pcMbSymbolReadIf->residualBlock( rcMbDataAccess, cIdx , LUMA_SCAN, uiMbExtCbp, uiStart, uiStop ) ); } } } } rcMbDataAccess.getMbData().setMbExtCbp( uiMbExtCbp ); DECRNOK( xScanChromaBlocks ( rcMbDataAccess, rcMbDataAccess.getMbData().getCbpChroma4x4(), uiStart, uiStop ) ); return Err::m_nOK; }
ErrVal MbParser::read( MbDataAccess& rcMbDataAccess, UInt uiNumMbRead, Bool& rbEndOfSlice, UInt& ruiNextSkippedVLC ) { const CommonMainH264* pcMainH264 = CommonMain::getMainH264(); // FIXME: if (pcMainH264->getCurrentPictureId() == 1 && pcMainH264->getCurrentLayerId() == 16 && rcMbDataAccess.getMbData().getMbAddr() == 76) { int a = 0; } ROF( m_bInitDone ); ROTRS( xCheckSkipSliceMb( rcMbDataAccess, uiNumMbRead, rbEndOfSlice ), Err::m_nOK ); Bool bIsCoded = true; if( m_pcMbSymbolReadIf->isMbSkipped( rcMbDataAccess, ruiNextSkippedVLC ) ) { bIsCoded = false; rcMbDataAccess.getMbTCoeffs().clear(); rcMbDataAccess.getMbData().clearIntraPredictionModes( true ); RNOK( xSkipMb( rcMbDataAccess ) ); rcMbDataAccess.getMbData().setBLSkipFlag( false ); rcMbDataAccess.getMbData().setResidualPredFlag( rcMbDataAccess.getMbData().getInCropWindowFlag() ? rcMbDataAccess.getSH().getDefaultResidualPredictionFlag() : false ); if( rcMbDataAccess.getSH().isBSlice() ) { rcMbDataAccess.getMbData().setFwdBwd( 0x3333 ); rcMbDataAccess.getMbMotionData( LIST_0 ).clear( RefIdxValues(1) ); rcMbDataAccess.getMbMvdData ( LIST_0 ).clear(); rcMbDataAccess.getMbMotionData( LIST_1 ).clear( RefIdxValues(1) ); rcMbDataAccess.getMbMvdData ( LIST_1 ).clear(); } else { rcMbDataAccess.getMbData().setFwdBwd( 0x1111 ); rcMbDataAccess.getMbMotionData( LIST_0 ).clear( RefIdxValues(1) ); rcMbDataAccess.getMbMvdData ( LIST_0 ).clear(); } rcMbDataAccess.resetQp(); // set QP to that of the last macroblock } if( bIsCoded ) { if( rcMbDataAccess.getSH().isMbaffFrame() && ( rcMbDataAccess.isTopMb() || m_bPrevIsSkipped ) ) { RNOK( m_pcMbSymbolReadIf->fieldFlag( rcMbDataAccess) ); } Bool bBaseLayerAvailable = ! rcMbDataAccess.getSH().getNoInterLayerPredFlag(); //===== base layer mode flag and base layer refinement flag ===== if( bBaseLayerAvailable ) { if ( rcMbDataAccess.getMbData().getInCropWindowFlag() == true ) { if( rcMbDataAccess.getSH().getAdaptiveBaseModeFlag() ) { m_pcMbSymbolReadIf->isBLSkipped( rcMbDataAccess ); } else { rcMbDataAccess.getMbData().setBLSkipFlag( rcMbDataAccess.getSH().getDefaultBaseModeFlag() ); } } else { rcMbDataAccess.getMbData().setBLSkipFlag( false ); } } else { rcMbDataAccess.getMbData().setBLSkipFlag( false ); } if( rcMbDataAccess.getSH().getStoreRefBasePicFlag() && rcMbDataAccess.getSH().getQualityId() > 0 && rcMbDataAccess.getMbData().getBLSkipFlag() == false ) { printf("Conformance Issue: base_mode_flag = 0 in enhancement layer MGS key picture\n"); } //===== macroblock mode ===== if( ! rcMbDataAccess.getMbData().getBLSkipFlag() ) { DECRNOK( m_pcMbSymbolReadIf->mbMode( rcMbDataAccess ) ); } if( rcMbDataAccess.getMbData().getBLSkipFlag() ) { //===== copy motion data from base layer ====== rcMbDataAccess.getMbMvdData( LIST_0 ).clear(); rcMbDataAccess.getMbMvdData( LIST_1 ).clear(); rcMbDataAccess.getMbData().setBLSkipFlag( true ); } else { //===== BLOCK MODES ===== if( rcMbDataAccess.getMbData().isInter8x8() ) { DECRNOK( m_pcMbSymbolReadIf->blockModes( rcMbDataAccess ) ); //===== set motion data for skip block mode ===== UInt uiFwdBwd = 0; for( B8x8Idx c8x8Idx; c8x8Idx.isLegal(); c8x8Idx++ ) { UInt uiBlkFwdBwd = rcMbDataAccess.getMbData().getBlockFwdBwd( c8x8Idx.b8x8Index() ); if( rcMbDataAccess.getMbData().getBlkMode( c8x8Idx.b8x8Index() ) == BLK_SKIP ) { uiBlkFwdBwd = 3; rcMbDataAccess.getMbMotionData( LIST_0 ).setRefIdx( 1, c8x8Idx.b8x8() ); rcMbDataAccess.getMbMotionData( LIST_1 ).setRefIdx( 1, c8x8Idx.b8x8() ); rcMbDataAccess.getMbMvdData ( LIST_0 ).setAllMv ( Mv::ZeroMv(), c8x8Idx.b8x8() ); rcMbDataAccess.getMbMvdData ( LIST_1 ).setAllMv ( Mv::ZeroMv(), c8x8Idx.b8x8() ); } uiFwdBwd |= ( uiBlkFwdBwd << ( c8x8Idx.b8x8Index() * 4 ) ); } rcMbDataAccess.getMbData().setFwdBwd( uiFwdBwd ); } rcMbDataAccess.resetQp(); // set QP to that of the last macroblock //===== MOTION DATA ===== MbMode eMbMode = rcMbDataAccess.getMbData().getMbMode(); if( rcMbDataAccess.getMbData().isIntra() ) { //===== clear mtoion data for intra blocks ===== rcMbDataAccess.getMbMotionData( LIST_0 ).clear( BLOCK_NOT_PREDICTED ); rcMbDataAccess.getMbMvdData ( LIST_0 ).clear(); if( rcMbDataAccess.getSH().isBSlice() ) { rcMbDataAccess.getMbMotionData( LIST_1 ).clear( BLOCK_NOT_PREDICTED ); rcMbDataAccess.getMbMvdData ( LIST_1 ).clear(); } } else if( eMbMode == MODE_SKIP ) { if( rcMbDataAccess.getSH().isBSlice() ) { rcMbDataAccess.getMbData().setFwdBwd( 0x3333 ); rcMbDataAccess.getMbMotionData( LIST_0 ).clear( RefIdxValues(1) ); rcMbDataAccess.getMbMvdData ( LIST_0 ).clear(); rcMbDataAccess.getMbMotionData( LIST_1 ).clear( RefIdxValues(1) ); rcMbDataAccess.getMbMvdData ( LIST_1 ).clear(); } else { rcMbDataAccess.getMbData().setFwdBwd( 0x1111 ); rcMbDataAccess.getMbMotionData( LIST_0 ).clear( RefIdxValues(1) ); rcMbDataAccess.getMbMvdData ( LIST_0 ).clear(); rcMbDataAccess.getMbMotionData( LIST_1 ).clear( BLOCK_NOT_PREDICTED ); rcMbDataAccess.getMbMvdData ( LIST_1 ).clear(); } } else { if( rcMbDataAccess.getSH().isBSlice() ) { DECRNOK( xReadMotionPredFlags ( rcMbDataAccess, eMbMode, LIST_0 ) ); DECRNOK( xReadMotionPredFlags ( rcMbDataAccess, eMbMode, LIST_1 ) ); DECRNOK( xReadReferenceIndices ( rcMbDataAccess, eMbMode, LIST_0 ) ); DECRNOK( xReadReferenceIndices ( rcMbDataAccess, eMbMode, LIST_1 ) ); DECRNOK( xReadMotionVectors ( rcMbDataAccess, eMbMode, LIST_0 ) ); DECRNOK( xReadMotionVectors ( rcMbDataAccess, eMbMode, LIST_1 ) ); } else { DECRNOK( xReadMotionPredFlags ( rcMbDataAccess, eMbMode, LIST_0 ) ); DECRNOK( xReadReferenceIndices ( rcMbDataAccess, eMbMode, LIST_0 ) ); DECRNOK( xReadMotionVectors ( rcMbDataAccess, eMbMode, LIST_0 ) ); } } } //===== TEXTURE INFO ===== if( rcMbDataAccess.getMbData().isPCM() ) { DECRNOK( m_pcMbSymbolReadIf->samplesPCM( rcMbDataAccess ) ); } else { if( ! rcMbDataAccess.getMbData().getBLSkipFlag() ) { DECRNOK( xReadIntraPredModes( rcMbDataAccess ) ); } Bool bTrafo8x8Flag = ( rcMbDataAccess.getSH().getPPS().getTransform8x8ModeFlag() && ( rcMbDataAccess.getMbData().getBLSkipFlag() || ( rcMbDataAccess.getMbData().is8x8TrafoFlagPresent( rcMbDataAccess.getSH().getSPS().getDirect8x8InferenceFlag() ) && !rcMbDataAccess.getMbData().isIntra4x4() ) ) ); bBaseLayerAvailable = ! rcMbDataAccess.getSH().getNoInterLayerPredFlag(); DECRNOK( xReadTextureInfo( rcMbDataAccess, bTrafo8x8Flag, bBaseLayerAvailable, rcMbDataAccess.getSH().getScanIdxStart(), rcMbDataAccess.getSH().getScanIdxStop() ) ); } } m_bPrevIsSkipped = ! bIsCoded; if( rcMbDataAccess.getSH().isMbaffFrame() && ( rcMbDataAccess.isTopMb() ) ) { rbEndOfSlice = false; return Err::m_nOK; } //===== terminating bits ===== rbEndOfSlice = m_pcMbSymbolReadIf->isEndOfSlice(); return Err::m_nOK; }
ErrVal MbParser::xReadMotionPredFlags( MbDataAccess& rcMbDataAccess, MbMode eMbMode, ListIdx eLstIdx ) { ROTRS( rcMbDataAccess.getSH ().getNoInterLayerPredFlag(), Err::m_nOK ); ROFRS( rcMbDataAccess.getMbData ().getInCropWindowFlag(), Err::m_nOK ); MbMotionData& rcMbMotionData = rcMbDataAccess.getMbMotionData( eLstIdx ); rcMbMotionData.setMotPredFlag( rcMbDataAccess.getSH().getDefaultMotionPredictionFlag() ); ROFRS ( rcMbDataAccess.getSH().getAdaptiveMotionPredictionFlag(), Err::m_nOK ); //--- clear --- rcMbMotionData.setMotPredFlag( false ); if( rcMbDataAccess.getMbData().isIntra() ) { return Err::m_nOK; } switch( eMbMode ) { case MODE_SKIP: { break; } case MODE_16x16: { if( rcMbDataAccess.getMbData().isBlockFwdBwd( B_8x8_0, eLstIdx ) ) { DECRNOK( m_pcMbSymbolReadIf->motionPredFlag( rcMbDataAccess, eLstIdx ) ); } break; } case MODE_16x8: { if( rcMbDataAccess.getMbData().isBlockFwdBwd( B_8x8_0, eLstIdx ) ) { DECRNOK( m_pcMbSymbolReadIf->motionPredFlag( rcMbDataAccess, eLstIdx, PART_16x8_0 ) ); } if( rcMbDataAccess.getMbData().isBlockFwdBwd( B_8x8_2, eLstIdx ) ) { DECRNOK( m_pcMbSymbolReadIf->motionPredFlag( rcMbDataAccess, eLstIdx, PART_16x8_1 ) ); } break; } case MODE_8x16: { if( rcMbDataAccess.getMbData().isBlockFwdBwd( B_8x8_0, eLstIdx ) ) { DECRNOK( m_pcMbSymbolReadIf->motionPredFlag( rcMbDataAccess, eLstIdx, PART_8x16_0 ) ); } if( rcMbDataAccess.getMbData().isBlockFwdBwd( B_8x8_1, eLstIdx ) ) { DECRNOK( m_pcMbSymbolReadIf->motionPredFlag( rcMbDataAccess, eLstIdx, PART_8x16_1 ) ); } break; } case MODE_8x8: case MODE_8x8ref0: { for( B8x8Idx c8x8Idx; c8x8Idx.isLegal(); c8x8Idx++ ) { if( BLK_SKIP != rcMbDataAccess.getMbData().getBlkMode ( c8x8Idx.b8x8Index() ) && rcMbDataAccess .getMbData().isBlockFwdBwd( c8x8Idx.b8x8Index(), eLstIdx ) ) { DECRNOK( m_pcMbSymbolReadIf->motionPredFlag( rcMbDataAccess, eLstIdx, c8x8Idx.b8x8() ) ); } } break; } default: { AF(); return Err::m_nERR; } } return Err::m_nOK; }
ErrVal SliceEncoder::xAddTCoeffs2( MbDataAccess& rcMbDataAccess, MbDataAccess& rcMbDataAccessBase ) { if( rcMbDataAccess.getMbData().isPCM() ) { TCoeff* pSrc = rcMbDataAccessBase.getMbTCoeffs().getTCoeffBuffer(); TCoeff* pDes = rcMbDataAccess .getMbTCoeffs().getTCoeffBuffer(); for( UInt ui = 0; ui < 384; ui++, pSrc++, pDes++ ) { ROT( pDes->getLevel() ); pDes->setLevel( pSrc->getLevel() ); } ROT( rcMbDataAccess.getMbData().getMbExtCbp() ); return Err::m_nOK; } UInt uiBCBP = 0; UInt uiCoded = 0; Bool bCoded = false; Bool bChromaAC = false; Bool bChromaDC = false; // Add the luma coefficients and track the new BCBP if( rcMbDataAccess.getMbData().isTransformSize8x8() ) { for( B8x8Idx c8x8Idx; c8x8Idx.isLegal(); c8x8Idx++ ) { bCoded = false; m_pcTransform->addPrediction8x8Blk( rcMbDataAccess.getMbTCoeffs().get8x8( c8x8Idx ), rcMbDataAccessBase.getMbTCoeffs().get8x8( c8x8Idx ), rcMbDataAccess.getMbData().getQp(), rcMbDataAccessBase.getMbData().getQp(), bCoded ); if( rcMbDataAccess.getMbData().isIntra16x16() ) AOT(1); if( bCoded ) uiBCBP |= (0x33 << c8x8Idx.b4x4()); } } else { for( B4x4Idx cIdx; cIdx.isLegal(); cIdx++ ) { uiCoded = 0; m_pcTransform->addPrediction4x4Blk( rcMbDataAccess.getMbTCoeffs().get( cIdx ), rcMbDataAccessBase.getMbTCoeffs().get( cIdx ), rcMbDataAccess.getMbData().getQp(), rcMbDataAccessBase.getMbData().getQp(), uiCoded ); if( rcMbDataAccess.getMbData().isIntra16x16() ) { if( *(rcMbDataAccess.getMbTCoeffs().get( cIdx )) ) uiCoded--; } if( uiCoded ) uiBCBP |= 1<<cIdx; } if( rcMbDataAccess.getMbData().isIntra16x16() ) { uiBCBP = uiBCBP?((1<<16)-1):0; } } // Add the chroma coefficients and update the BCBP m_pcTransform->addPredictionChromaBlocks( rcMbDataAccess.getMbTCoeffs().get( CIdx(0) ), rcMbDataAccessBase.getMbTCoeffs().get( CIdx(0) ), rcMbDataAccess.getSH().getCbQp( rcMbDataAccess.getMbData().getQp() ), rcMbDataAccess.getSH().getBaseSliceHeader()->getCbQp( rcMbDataAccessBase.getMbData().getQp() ), bChromaDC, bChromaAC ); m_pcTransform->addPredictionChromaBlocks( rcMbDataAccess.getMbTCoeffs().get( CIdx(4) ), rcMbDataAccessBase.getMbTCoeffs().get( CIdx(4) ), rcMbDataAccess.getSH().getCrQp( rcMbDataAccess.getMbData().getQp() ), rcMbDataAccess.getSH().getBaseSliceHeader()->getCrQp( rcMbDataAccessBase.getMbData().getQp() ), bChromaDC, bChromaAC ); uiBCBP |= (bChromaAC?2:(bChromaDC?1:0))<<16; // Update the CBP rcMbDataAccess.getMbData().setAndConvertMbExtCbp( uiBCBP ); // Update the Intra16x16 mode if( rcMbDataAccess.getMbData().isIntra16x16() ) { UInt uiMbType = INTRA_4X4 + 1; UInt uiPredMode = rcMbDataAccess.getMbData().intraPredMode(); UInt uiChromaCbp = uiBCBP>>16; Bool bACcoded = (uiBCBP && ((1<<16)-1)); uiMbType += uiPredMode; uiMbType += ( bACcoded ) ? 12 : 0; uiMbType += uiChromaCbp << 2; rcMbDataAccess.getMbData().setMbMode( MbMode(uiMbType) ); // Sanity checks if( rcMbDataAccess.getMbData().intraPredMode() != uiPredMode ) AOT(1); if( rcMbDataAccess.getMbData().getCbpChroma16x16() != uiChromaCbp ) AOT(1); if( rcMbDataAccess.getMbData().isAcCoded() != bACcoded ) AOT(1); }
// JVT-V035 ErrVal SliceEncoder::updatePictureAVCRewrite( ControlData& rcControlData, UInt uiMbInRow ) { ROF( m_bInitDone ); SliceHeader& rcSliceHeader = *rcControlData.getSliceHeader(); FMO& rcFMO = *rcSliceHeader.getFMO(); MbDataCtrl* pcMbDataCtrl = rcControlData.getMbDataCtrl(); MbDataCtrl* pcBaseLayerCtrl = rcControlData.getBaseLayerCtrl(); //====== initialization ====== RNOK( pcMbDataCtrl->initSlice( rcSliceHeader, DECODE_PROCESS, false, NULL ) ); if( rcSliceHeader.getTCoeffLevelPredictionFlag() == true ) { // Update the macroblock state // Must be done after the bit-stream has been constructed for( Int iSliceGroupId = rcFMO.getFirstSliceGroupId(); ! rcFMO.SliceGroupCompletelyCoded( iSliceGroupId ); iSliceGroupId = rcFMO.getNextSliceGroupId( iSliceGroupId ) ) { UInt uiFirstMbInSliceGroup = rcFMO.getFirstMBOfSliceGroup( iSliceGroupId ); UInt uiLastMbInSliceGroup = rcFMO.getLastMBInSliceGroup ( iSliceGroupId ); for( UInt uiMbAddress = uiFirstMbInSliceGroup; uiMbAddress <= uiLastMbInSliceGroup; uiMbAddress = rcFMO.getNextMBNr( uiMbAddress ) ) { UInt uiMbY = 0; UInt uiMbX = 0; MbDataAccess* pcMbDataAccess = 0; MbDataAccess* pcMbDataAccessBase = 0; rcSliceHeader.getMbPositionFromAddress( uiMbY, uiMbX, uiMbAddress ); RNOK( pcMbDataCtrl->initMb( pcMbDataAccess, uiMbY, uiMbX ) ); if( pcBaseLayerCtrl ) { RNOK( pcBaseLayerCtrl ->initMb( pcMbDataAccessBase, uiMbY, uiMbX ) ); pcMbDataAccess->setMbDataAccessBase( pcMbDataAccessBase ); } // modify QP values (as specified in G.8.1.5.1.2) if( pcMbDataAccess->getMbData().getMbCbp() == 0 && ( pcMbDataAccess->getMbData().getMbMode() == INTRA_BL || pcMbDataAccess->getMbData().getResidualPredFlag() ) ) { pcMbDataAccess->getMbData().setQp( pcMbDataAccessBase->getMbData().getQp() ); } if( pcMbDataAccess->isTCoeffPred() ) { if( pcMbDataAccess->getMbData().getMbMode() == INTRA_BL ) { // We're going to use the BL skip flag to correctly decode the intra prediction mode AOT( pcMbDataAccess->getMbData().getBLSkipFlag() == false ); // Inherit the mode of the base block pcMbDataAccess->getMbData().setMbMode( pcMbDataAccessBase->getMbData().getMbMode() ); // Inherit intra prediction modes for( B4x4Idx cIdx; cIdx.isLegal(); cIdx++ ) pcMbDataAccess->getMbData().intraPredMode(cIdx) = pcMbDataAccessBase->getMbData().intraPredMode(cIdx); pcMbDataAccess->getMbData().setChromaPredMode( pcMbDataAccessBase->getMbData().getChromaPredMode() ); } // The 8x8 transform flag is present in the bit-stream unless transform coefficients // are not transmitted at the enhancement layer. In this case, inherit the base layer // transform type. This makes intra predition work correctly, etc. if( ( pcMbDataAccess->getMbData().getMbCbp() & 0x0F ) == 0 ) { pcMbDataAccess->getMbData().setTransformSize8x8( pcMbDataAccessBase->getMbData().isTransformSize8x8() ); } xAddTCoeffs2( *pcMbDataAccess, *pcMbDataAccessBase ); } if( pcMbDataAccess->getMbAddress() != uiFirstMbInSliceGroup && pcMbDataAccess->getSH().getTCoeffLevelPredictionFlag() && !pcMbDataAccess->getSH().getNoInterLayerPredFlag() && !pcMbDataAccess->getMbData().isIntra16x16() && pcMbDataAccess->getMbData().getMbExtCbp() == 0 ) { pcMbDataAccess->getMbData().setQp4LF( pcMbDataAccess->getLastQp4LF() ); } else { pcMbDataAccess->getMbData().setQp4LF( pcMbDataAccess->getMbData().getQp() ); } } } } return Err::m_nOK; }