Changeset 1209 in 3DVCSoftware for branches/HTM-14.1-update-dev1-HHI/source/Lib/TLibEncoder/TEncSbac.cpp
- Timestamp:
- 13 May 2015, 15:16:14 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-14.1-update-dev1-HHI/source/Lib/TLibEncoder/TEncSbac.cpp
r1200 r1209 101 101 , m_ChromaQpAdjFlagSCModel ( 1, 1, NUM_CHROMA_QP_ADJ_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 102 102 , m_ChromaQpAdjIdcSCModel ( 1, 1, NUM_CHROMA_QP_ADJ_IDC_CTX , m_contextModels + m_numContextModels, m_numContextModels) 103 #if H_3D_DIM 104 , m_cDepthIntraModeSCModel ( 1, 1, NUM_DEPTH_INTRA_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) 105 , m_cDdcFlagSCModel ( 1, 1, NUM_DDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 103 104 #if NH_3D_DMM 105 , m_cNotDmmFlagSCModel ( 1, 1, NUM_NOTDMM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 106 , m_cDmmModeSCModel ( 1, 1, NUM_DMM_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) 107 #endif 108 #if NH_3D_DMM || NH_3D_SDC 106 109 , m_cDdcDataSCModel ( 1, 1, NUM_DDC_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 107 , m_cAngleFlagSCModel ( 1, 1, NUM_ANGLE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 110 #endif 108 111 #if H_3D_DIM_SDC 109 112 , m_cSDCResidualFlagSCModel ( 1, 1, SDC_NUM_RESIDUAL_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 110 113 , m_cSDCResidualSCModel ( 1, 1, SDC_NUM_RESIDUAL_CTX , m_contextModels + m_numContextModels, m_numContextModels) 111 #endif112 #endif113 #if H_3D_DIM_SDC114 114 , m_cSDCFlagSCModel ( 1, 1, NUM_SDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 115 , m_cDdcFlagSCModel ( 1, 1, NUM_DDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 115 116 #endif 116 117 #if H_3D_DBBP … … 181 182 m_ChromaQpAdjFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CHROMA_QP_ADJ_FLAG ); 182 183 m_ChromaQpAdjIdcSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CHROMA_QP_ADJ_IDC ); 183 #if H_3D_DIM 184 m_cDepthIntraModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DEPTH_INTRA_MODE ); 185 m_cDdcFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG ); 184 185 #if NH_3D_DMM 186 m_cNotDmmFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_NOTDMM_FLAG ); 187 m_cDmmModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM_MODE ); 188 #endif 189 #if NH_3D_DMM || NH_3D_SDC 186 190 m_cDdcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_DATA ); 187 m_cAngleFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ANGLE_FLAG ); 191 #endif 188 192 #if H_3D_DIM_SDC 189 193 m_cSDCResidualFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG ); 190 194 m_cSDCResidualSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL ); 191 #endif192 #endif193 #if H_3D_DIM_SDC194 195 m_cSDCFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG ); 196 m_cDdcFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG ); 195 197 #endif 196 198 #if H_3D_DBBP … … 274 276 curCost += m_ChromaQpAdjFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_CHROMA_QP_ADJ_FLAG ); 275 277 curCost += m_ChromaQpAdjIdcSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_CHROMA_QP_ADJ_IDC ); 276 #if H_3D_DIM 277 if( m_pcSlice->getIntraSdcWedgeFlag() || m_pcSlice->getIntraContourFlag() ) 278 { 279 curCost += m_cDepthIntraModeSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DEPTH_INTRA_MODE ); 280 curCost += m_cDdcFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DDC_FLAG ); 281 curCost += m_cDdcDataSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DDC_DATA ); 282 curCost += m_cAngleFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_ANGLE_FLAG ); 283 } 278 #if NH_3D_DMM 279 curCost += m_cNotDmmFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_NOTDMM_FLAG ); 280 curCost += m_cDmmModeSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DMM_MODE ); 281 #endif 282 #if NH_3D_DMM || NH_3D_SDC 283 curCost += m_cDdcDataSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DDC_DATA ); 284 284 #endif 285 285 … … 308 308 m_cCUICFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_IC_FLAG ); 309 309 #endif 310 #if H_3D_DIM311 m_cDepthIntraModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DEPTH_INTRA_MODE );312 m_cDdcFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG );313 m_cDdcDataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_DATA );314 m_cAngleFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ANGLE_FLAG );315 310 #if H_3D_DIM_SDC 316 311 m_cSDCResidualFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG ); 317 312 m_cSDCResidualSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL ); 318 #endif319 #endif320 #if H_3D_DIM_SDC321 313 m_cSDCFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG ); 314 m_cDdcFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG ); 322 315 #endif 323 316 #if H_3D_DBBP … … 530 523 } 531 524 } 532 #if H_3D_DIM533 Void TEncSbac::xWriteExGolombLevel( UInt uiSymbol, ContextModel& rcSCModel )534 {535 if( uiSymbol )536 {537 m_pcBinIf->encodeBin( 1, rcSCModel );538 UInt uiCount = 0;539 Bool bNoExGo = ( uiSymbol < 3 );540 541 while( --uiSymbol && ++uiCount < 3 )542 {543 m_pcBinIf->encodeBin( 1, rcSCModel );544 }545 if( bNoExGo )546 {547 m_pcBinIf->encodeBin( 0, rcSCModel );548 }549 else550 {551 xWriteEpExGolomb( uiSymbol, 0 );552 }553 }554 else555 {556 m_pcBinIf->encodeBin( 0, rcSCModel );557 }558 559 return;560 }561 562 Void TEncSbac::xCodeDimDeltaDC( Pel valDeltaDC, UInt uiNumSeg )563 {564 xWriteExGolombLevel( UInt( abs( valDeltaDC ) - ( uiNumSeg > 1 ? 0 : 1 ) ), m_cDdcDataSCModel.get(0, 0, 0) );565 if( valDeltaDC != 0 )566 {567 UInt uiSign = valDeltaDC > 0 ? 0 : 1;568 m_pcBinIf->encodeBinEP( uiSign );569 }570 }571 572 #if H_3D_DIM_DMM573 Void TEncSbac::xCodeDmm1WedgeIdx( UInt uiTabIdx, Int iNumBit )574 {575 for ( Int i = 0; i < iNumBit; i++ )576 {577 m_pcBinIf->encodeBinEP( ( uiTabIdx >> i ) & 1 );578 }579 }580 581 #endif582 #endif583 584 525 // SBAC RD 585 526 Void TEncSbac::load ( const TEncSbac* pSrc) … … 601 542 } 602 543 603 #if H_3D_DIM604 Void TEncSbac::loadIntraDepth Mode( TEncSbac* pSrc)544 #if NH_3D_DMM 545 Void TEncSbac::loadIntraDepthDmm( const TEncSbac* pSrc ) 605 546 { 606 547 m_pcBinIf->copyState( pSrc->m_pcBinIf ); 607 608 this->m_cDepthIntraModeSCModel .copyFrom( &pSrc->m_cDepthIntraModeSCModel ); 609 this->m_cDdcFlagSCModel .copyFrom( &pSrc->m_cDdcFlagSCModel ); 610 this->m_cAngleFlagSCModel .copyFrom( &pSrc->m_cAngleFlagSCModel ); 548 this->m_cNotDmmFlagSCModel.copyFrom( &pSrc->m_cNotDmmFlagSCModel ); 549 this->m_cDmmModeSCModel .copyFrom( &pSrc->m_cDmmModeSCModel ); 611 550 } 612 551 #endif … … 1098 1037 { 1099 1038 dir[j] = pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx+partOffset*j ); 1100 #if H_3D_DIM1039 #if NH_3D_DMM 1101 1040 if( pcCU->getSlice()->getIntraSdcWedgeFlag() || pcCU->getSlice()->getIntraContourFlag() ) 1102 1041 { 1103 codeIntraDepth( pcCU, absPartIdx+partOffset*j ); 1104 } 1105 if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) 1042 xCodeIntraDepthMode( pcCU, absPartIdx+partOffset*j ); 1043 xCodeDmmData ( pcCU, absPartIdx+partOffset*j ); 1044 } 1045 if( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) 1106 1046 { 1107 1047 #endif … … 1118 1058 DTRACE_CU("prev_intra_luma_pred_flag", (predIdx[j] != -1)? 1 : 0); 1119 1059 #endif 1120 #if H_3D_DIM1060 #if NH_3D_DMM 1121 1061 } 1122 1062 #endif … … 1125 1065 for (j=0;j<partNum;j++) 1126 1066 { 1127 #if H_3D_DIM1128 if( pcCU->get LumaIntraDir(absPartIdx+partOffset*j ) < NUM_INTRA_MODE )1067 #if NH_3D_DMM 1068 if( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx+partOffset*j ) < NUM_INTRA_MODE ) 1129 1069 { 1130 1070 #endif … … 1163 1103 #endif 1164 1104 } 1165 #if H_3D_DIM1105 #if NH_3D_DMM 1166 1106 } 1167 1107 #endif … … 1206 1146 return; 1207 1147 } 1208 1209 #if H_3D_DIM1210 Void TEncSbac::codeIntraDepth( TComDataCU* pcCU, UInt absPartIdx )1211 {1212 codeIntraDepthMode( pcCU, absPartIdx );1213 1214 UInt dir = pcCU->getLumaIntraDir( absPartIdx );1215 UInt dimType = getDimType( dir );1216 1217 switch( dimType )1218 {1219 #if H_3D_DIM_DMM1220 case( DMM1_IDX ):1221 {1222 xCodeDmm1WedgeIdx( pcCU->getDmmWedgeTabIdx( dimType, absPartIdx ), g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] );1223 } break;1224 case( DMM4_IDX ): break;1225 #endif1226 default: break;1227 }1228 }1229 1230 Void TEncSbac::codeIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx )1231 {1232 UInt dir = pcCU->getLumaIntraDir( absPartIdx );1233 1234 if( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() >> pcCU->getDepth( absPartIdx ) ) < 64 ) //DMM and HEVC intra modes are both allowed1235 {1236 m_pcBinIf->encodeBin( isDimMode( dir ) ? 0 : 1, m_cAngleFlagSCModel.get( 0, 0, 0 ) );1237 }1238 if( isDimMode( dir ) )1239 {1240 UInt uiCodeIdx = 0;1241 1242 switch( getDimType( dir ) )1243 {1244 case DMM1_IDX: uiCodeIdx = 0; break;1245 case DMM4_IDX: uiCodeIdx = 1; break;1246 default: break;1247 }1248 //mode coding1249 if( pcCU->getSlice()->getIntraSdcWedgeFlag() && pcCU->getSlice()->getIntraContourFlag())1250 {1251 m_pcBinIf->encodeBin( uiCodeIdx == 0 ? 0 : 1, m_cDepthIntraModeSCModel.get( 0, 0, 0 ) );1252 }1253 }1254 }1255 #endif1256 1148 1257 1149 Void TEncSbac::codeInterDir( TComDataCU* pcCU, UInt uiAbsPartIdx ) … … 2595 2487 } 2596 2488 2489 #if NH_3D_DMM || H_3D_DIM_SDC || H_3D_INTER_SDC 2490 Void TEncSbac::codeDeltaDC( TComDataCU* pcCU, UInt absPartIdx ) 2491 { 2492 #if H_3D_DIM_SDC || H_3D_INTER_SDC 2493 if( !(pcCU->getSDCFlag( absPartIdx )) ) 2494 #endif 2495 #if NH_3D_DMM 2496 if( !(pcCU->isIntra( absPartIdx ) && isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx ) )) ) 2497 #endif 2498 assert( 0 ); 2499 2500 UInt uiNumSegments = 1; 2501 #if NH_3D_DMM 2502 uiNumSegments = isDmmMode( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx ) ) ? 2 : 1; 2503 #endif 2504 2505 UInt hasDeltaDC = 1; 2506 #if H_3D_DIM_SDC 2507 if( pcCU->isIntra( absPartIdx ) && pcCU->getSDCFlag( absPartIdx )) 2508 { 2509 if( uiNumSegments == 1 ) 2510 { 2511 hasDeltaDC = pcCU->getSDCSegmentDCOffset( 0, absPartIdx ) ? 1 : 0; 2512 } 2513 else 2514 { 2515 hasDeltaDC = ( pcCU->getSDCSegmentDCOffset( 0, absPartIdx ) || pcCU->getSDCSegmentDCOffset( 1, absPartIdx ) ) ? 1 : 0; 2516 } 2517 m_pcBinIf->encodeBin( hasDeltaDC, m_cDdcFlagSCModel.get( 0, 0, 0 ) ); 2518 } 2519 #endif 2520 2521 if( hasDeltaDC ) 2522 { 2523 for( UInt segment = 0; segment < uiNumSegments; segment++ ) 2524 { 2525 Pel deltaDC = 0; 2526 if( pcCU->isIntra( absPartIdx ) ) 2527 { 2528 #if H_3D_DIM_SDC 2529 if( pcCU->getSDCFlag( absPartIdx ) ) 2530 { 2531 deltaDC = pcCU->getSDCSegmentDCOffset( segment, absPartIdx ); 2532 } 2533 else 2534 { 2535 #endif 2536 #if NH_3D_DMM 2537 deltaDC = pcCU->getDmmDeltaDC( getDmmType( pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx ) ), segment, absPartIdx ); 2538 #endif 2539 #if H_3D_DIM_SDC 2540 } 2541 #endif 2542 } 2597 2543 #if H_3D_INTER_SDC 2598 Void TEncSbac::codeDeltaDC( TComDataCU* pcCU, UInt absPartIdx )2599 {2600 if( !( pcCU->getSDCFlag( absPartIdx ) || ( pcCU->isIntra( absPartIdx ) && getDimType( pcCU->getLumaIntraDir( absPartIdx ) ) < DIM_NUM_TYPE ) ) )2601 {2602 assert( 0 );2603 }2604 2605 UInt uiNumSegments = isDimMode( pcCU->getLumaIntraDir( absPartIdx ) ) ? 2 : 1;2606 UInt dimDeltaDC = 1;2607 2608 if( pcCU->isIntra( absPartIdx ) && pcCU->getSDCFlag( absPartIdx ))2609 {2610 if( uiNumSegments == 1 )2611 {2612 dimDeltaDC = pcCU->getSDCSegmentDCOffset( 0, absPartIdx ) ? 1 : 0;2613 }2614 2544 else 2615 2545 { 2616 dimDeltaDC = ( pcCU->getSDCSegmentDCOffset( 0, absPartIdx ) || pcCU->getSDCSegmentDCOffset( 1, absPartIdx ) ) ? 1 : 0;2617 }2618 m_pcBinIf->encodeBin( dimDeltaDC, m_cDdcFlagSCModel.get( 0, 0, 0 ) );2619 }2620 2621 if( dimDeltaDC )2622 {2623 for( UInt segment = 0; segment < uiNumSegments; segment++ )2624 {2625 Pel deltaDC = 0;2626 2627 if( pcCU->isIntra( absPartIdx ) )2628 {2629 UInt dir = pcCU->getLumaIntraDir( absPartIdx );2630 deltaDC = pcCU->getSDCFlag( absPartIdx ) ? pcCU->getSDCSegmentDCOffset( segment, absPartIdx ) : pcCU->getDimDeltaDC( getDimType( dir ), segment, absPartIdx );2631 }2632 else2633 {2634 2546 deltaDC = pcCU->getSDCSegmentDCOffset( segment, absPartIdx ); 2635 2547 } 2636 2637 xCodeDimDeltaDC( deltaDC, uiNumSegments ); 2638 } 2639 } 2640 } 2641 2548 #endif 2549 xCodeDeltaDC( deltaDC, uiNumSegments ); 2550 } 2551 } 2552 } 2553 2554 Void TEncSbac::xCodeDeltaDC( Pel valDeltaDC, UInt uiNumSeg ) 2555 { 2556 xWriteExGolombLevelDdc( UInt( abs( valDeltaDC ) - ( uiNumSeg > 1 ? 0 : 1 ) ) ); 2557 if( valDeltaDC != 0 ) 2558 { 2559 UInt uiSign = valDeltaDC > 0 ? 0 : 1; 2560 m_pcBinIf->encodeBinEP( uiSign ); 2561 } 2562 } 2563 2564 Void TEncSbac::xWriteExGolombLevelDdc( UInt uiSymbol ) 2565 { 2566 if( uiSymbol ) 2567 { 2568 m_pcBinIf->encodeBin( 1, m_cDdcDataSCModel.get(0, 0, 0) ); 2569 UInt uiCount = 0; 2570 Bool bNoExGo = ( uiSymbol < 3 ); 2571 2572 while( --uiSymbol && ++uiCount < 3 ) 2573 { 2574 m_pcBinIf->encodeBin( 1, m_cDdcDataSCModel.get(0, 0, 0) ); 2575 } 2576 if( bNoExGo ) 2577 { 2578 m_pcBinIf->encodeBin( 0, m_cDdcDataSCModel.get(0, 0, 0) ); 2579 } 2580 else 2581 { 2582 xWriteEpExGolomb( uiSymbol, 0 ); 2583 } 2584 } 2585 else 2586 { 2587 m_pcBinIf->encodeBin( 0, m_cDdcDataSCModel.get(0, 0, 0) ); 2588 } 2589 2590 return; 2591 } 2592 #endif 2593 2594 #if NH_3D_DMM 2595 Void TEncSbac::xCodeIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx ) 2596 { 2597 UInt dir = pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx ); 2598 2599 if( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() >> pcCU->getDepth( absPartIdx ) ) < 64 ) //DMM and HEVC intra modes are both allowed 2600 { 2601 m_pcBinIf->encodeBin( isDmmMode( dir ) ? 0 : 1, m_cNotDmmFlagSCModel.get( 0, 0, 0 ) ); 2602 } 2603 if( isDmmMode( dir ) ) 2604 { 2605 UInt uiCodeIdx = 0; 2606 2607 switch( getDmmType( dir ) ) 2608 { 2609 case DMM1_IDX: uiCodeIdx = 0; break; 2610 case DMM4_IDX: uiCodeIdx = 1; break; 2611 default: break; 2612 } 2613 //mode coding 2614 if( pcCU->getSlice()->getIntraSdcWedgeFlag() && pcCU->getSlice()->getIntraContourFlag()) 2615 { 2616 m_pcBinIf->encodeBin( uiCodeIdx == 0 ? 0 : 1, m_cDmmModeSCModel.get( 0, 0, 0 ) ); 2617 } 2618 } 2619 } 2620 2621 Void TEncSbac::xCodeDmmData( TComDataCU* pcCU, UInt absPartIdx ) 2622 { 2623 UInt dir = pcCU->getIntraDir( CHANNEL_TYPE_LUMA, absPartIdx ); 2624 switch( getDmmType( dir ) ) 2625 { 2626 case( DMM1_IDX ): { xCodeDmm1WedgeIdx( pcCU->getDmm1WedgeTabIdx( absPartIdx ), g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] ); } break; 2627 case( DMM4_IDX ): break; 2628 default: break; 2629 } 2630 } 2631 2632 Void TEncSbac::xCodeDmm1WedgeIdx( UInt uiTabIdx, Int iNumBit ) 2633 { 2634 for ( Int i = 0; i < iNumBit; i++ ) 2635 { 2636 m_pcBinIf->encodeBinEP( ( uiTabIdx >> i ) & 1 ); 2637 } 2638 } 2639 #endif 2640 2641 #if H_3D_INTER_SDC 2642 2642 Void TEncSbac::codeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2643 2643 {
Note: See TracChangeset for help on using the changeset viewer.