Changeset 1433 in SHVCSoftware
- Timestamp:
- 11 Aug 2015, 20:22:28 (9 years ago)
- Location:
- branches/SHM-dev/source
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp
r1424 r1433 399 399 }; 400 400 401 #if U0132_TARGET_BITS_SATURATION 402 UInt g_uiMaxCpbSize[2][21] = 403 { 404 // LEVEL1, LEVEL2,LEVEL2_1, LEVEL3, LEVEL3_1, LEVEL4, LEVEL4_1, LEVEL5, LEVEL5_1, LEVEL5_2, LEVEL6, LEVEL6_1, LEVEL6_2 405 { 0, 0, 0, 350000, 0, 0, 1500000, 3000000, 0, 6000000, 10000000, 0, 12000000, 20000000, 0, 25000000, 40000000, 60000000, 60000000, 120000000, 240000000 }, 406 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30000000, 50000000, 0, 100000000, 160000000, 240000000, 240000000, 480000000, 800000000 } 407 }; 408 #endif 409 401 410 static const struct MapStrToCostMode 402 411 { … … 826 835 Int* cfg_RCInitialQP [MAX_LAYERS]; 827 836 Bool* cfg_RCForceIntraQP [MAX_LAYERS]; 837 838 #if U0132_TARGET_BITS_SATURATION 839 Bool* cfg_RCCpbSaturationEnabled[MAX_LAYERS]; 840 UInt* cfg_RCCpbSize [MAX_LAYERS]; 841 Double* cfg_RCInitialCpbFullness [MAX_LAYERS]; 842 #endif 828 843 #endif 829 844 … … 916 931 cfg_RCInitialQP[layer] = &m_apcLayerCfg[layer]->m_RCInitialQP; 917 932 cfg_RCForceIntraQP[layer] = &m_apcLayerCfg[layer]->m_RCForceIntraQP; 933 934 #if U0132_TARGET_BITS_SATURATION 935 cfg_RCCpbSaturationEnabled[layer] = &m_apcLayerCfg[layer]->m_RCCpbSaturationEnabled; 936 cfg_RCCpbSize[layer] = &m_apcLayerCfg[layer]->m_RCCpbSize; 937 cfg_RCInitialCpbFullness[layer] = &m_apcLayerCfg[layer]->m_RCInitialCpbFullness; 938 #endif 918 939 #endif 919 940 … … 1248 1269 ("Profile", extendedProfile, NONE, "Profile name to use for encoding. Use main (for main), main10 (for main10), main-still-picture, main-RExt (for Range Extensions profile), any of the RExt specific profile names, or none") 1249 1270 ("Level", m_level, Level::NONE, "Level limit to be used, eg 5.1, or none") 1250 ("Tier", m_levelTier, Level::MAIN, "Tier to use for interpretation of --Level (main or high only)") 1251 1271 ("Tier", m_levelTier, Level::MAIN, "Tier to use for interpretation of --Level (main or high only)") 1252 1272 ("MaxBitDepthConstraint", m_bitDepthConstraint, 0u, "Bit depth to use for profile-constraint for RExt profiles. 0=automatically choose based upon other parameters") 1253 1273 ("MaxChromaFormatConstraint", tmpConstraintChromaFormat, 0, "Chroma-format to use for the profile-constraint for RExt profiles. 0=automatically choose based upon other parameters") … … 1449 1469 ("InitialQP%d", cfg_RCInitialQP, 0, m_numLayers, "Rate control: initial QP") 1450 1470 ("RCForceIntraQP%d", cfg_RCForceIntraQP, false, m_numLayers, "Rate control: force intra QP to be equal to initial QP") 1471 #if U0132_TARGET_BITS_SATURATION 1472 ( "RCCpbSaturation%d", cfg_RCCpbSaturationEnabled, false, m_numLayers, "Rate control: enable target bits saturation to avoid CPB overflow and underflow" ) 1473 ( "RCCpbSize%d", cfg_RCCpbSize, 0u, m_numLayers, "Rate control: CPB size" ) 1474 ( "RCInitialCpbFullness%d", cfg_RCInitialCpbFullness, 0.9, m_numLayers, "Rate control: initial CPB fullness" ) 1475 #endif 1451 1476 #else 1452 1477 ( "RateControl", m_RCEnableRateControl, false, "Rate control: enable rate control" ) … … 1457 1482 ( "InitialQP", m_RCInitialQP, 0, "Rate control: initial QP" ) 1458 1483 ( "RCForceIntraQP", m_RCForceIntraQP, false, "Rate control: force intra QP to be equal to initial QP" ) 1484 #if U0132_TARGET_BITS_SATURATION 1485 ( "RCCpbSaturation", m_RCCpbSaturationEnabled, false, "Rate control: enable target bits saturation to avoid CPB overflow and underflow" ) 1486 ( "RCCpbSize", m_RCCpbSize, 0u, "Rate control: CPB size" ) 1487 ( "RCInitialCpbFullness", m_RCInitialCpbFullness, 0.9, "Rate control: initial CPB fullness" ) 1488 #endif 1459 1489 #endif 1460 1490 … … 4199 4229 } 4200 4230 } 4201 } 4202 xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" ); 4231 xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" ); 4232 #if U0132_TARGET_BITS_SATURATION 4233 Int layerPTLIdx = m_apcLayerCfg[layerIdx]->m_layerPTLIdx; 4234 4235 if( m_apcLayerCfg[layerIdx]->m_RCCpbSaturationEnabled && m_levelList[layerPTLIdx]!=Level::NONE && m_profileList[layerPTLIdx]!=Profile::NONE ) 4236 { 4237 UInt uiLevelIdx = (m_levelList[layerPTLIdx] / 10) + (UInt)((m_levelList[layerPTLIdx] % 10) / 3); // (m_level / 30)*3 + ((m_level % 10) / 3); 4238 xConfirmPara( m_apcLayerCfg[layerIdx]->m_RCCpbSize > g_uiMaxCpbSize[m_levelTierList[layerPTLIdx]][uiLevelIdx], "RCCpbSize should be smaller than or equal to Max CPB size according to tier and level"); 4239 xConfirmPara( m_apcLayerCfg[layerIdx]->m_RCInitialCpbFullness > 1, "RCInitialCpbFullness should be smaller than or equal to 1"); 4240 } 4241 #endif 4242 } 4243 #if U0132_TARGET_BITS_SATURATION 4244 else 4245 { 4246 xConfirmPara( m_apcLayerCfg[layerIdx]->m_RCCpbSaturationEnabled != 0, "Target bits saturation cannot be processed without Rate control" ); 4247 } 4248 #endif 4203 4249 #else 4204 4250 if ( m_RCEnableRateControl ) … … 4213 4259 } 4214 4260 xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" ); 4215 } 4261 #if U0132_TARGET_BITS_SATURATION 4262 if ((m_RCCpbSaturationEnabled) && (m_level!=Level::NONE) && (m_profile!=Profile::NONE)) 4263 { 4264 UInt uiLevelIdx = (m_level / 10) + (UInt)((m_level % 10) / 3); // (m_level / 30)*3 + ((m_level % 10) / 3); 4265 xConfirmPara(m_RCCpbSize > g_uiMaxCpbSize[m_levelTier][uiLevelIdx], "RCCpbSize should be smaller than or equal to Max CPB size according to tier and level"); 4266 xConfirmPara(m_RCInitialCpbFullness > 1, "RCInitialCpbFullness should be smaller than or equal to 1"); 4267 } 4268 #endif 4269 } 4270 #if U0132_TARGET_BITS_SATURATION 4271 else 4272 { 4273 xConfirmPara( m_RCCpbSaturationEnabled != 0, "Target bits saturation cannot be processed without Rate control" ); 4274 } 4275 #endif 4216 4276 #endif 4217 4277 … … 4504 4564 printf("InitialQP : %d\n", m_RCInitialQP ); 4505 4565 printf("ForceIntraQP : %d\n", m_RCForceIntraQP ); 4566 #if U0132_TARGET_BITS_SATURATION 4567 printf("CpbSaturation : %d\n", m_RCCpbSaturationEnabled ); 4568 if (m_RCCpbSaturationEnabled) 4569 { 4570 printf("CpbSize : %d\n", m_RCCpbSize); 4571 printf("InitalCpbFullness : %.2f\n", m_RCInitialCpbFullness); 4572 } 4573 #endif 4506 4574 } 4507 4575 #endif … … 4571 4639 4572 4640 printf(" SignBitHidingFlag:%d ", m_signHideFlag); 4573 printf("RecalQP:%d 4641 printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 ); 4574 4642 4575 4643 #if SVC_EXTENSION -
branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h
r1424 r1433 407 407 Int m_RCInitialQP; ///< inital QP for rate control 408 408 Bool m_RCForceIntraQP; ///< force all intra picture to use initial QP or not 409 #if U0132_TARGET_BITS_SATURATION 410 Bool m_RCCpbSaturationEnabled; ///< enable target bits saturation to avoid CPB overflow and underflow 411 UInt m_RCCpbSize; ///< CPB size 412 Double m_RCInitialCpbFullness; ///< initial CPB fullness 413 #endif 409 414 #endif 410 415 #if !SVC_EXTENSION -
branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.cpp
r1381 r1433 266 266 printf("InitialQP : %d\n", m_RCInitialQP ); 267 267 printf("ForceIntraQP : %d\n", m_RCForceIntraQP ); 268 #if U0132_TARGET_BITS_SATURATION 269 printf("CpbSaturation : %d\n", m_RCCpbSaturationEnabled ); 270 if (m_RCCpbSaturationEnabled) 271 { 272 printf("CpbSize : %d\n", m_RCCpbSize); 273 printf("InitalCpbFullness : %.2f\n", m_RCInitialCpbFullness); 274 } 275 #endif 268 276 } 269 277 #endif -
branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.h
r1381 r1433 85 85 Int m_RCInitialQP; ///< inital QP for rate control 86 86 Bool m_RCForceIntraQP; ///< force all intra picture to use initial QP or not 87 #if U0132_TARGET_BITS_SATURATION 88 Bool m_RCCpbSaturationEnabled; ///< enable target bits saturation to avoid CPB overflow and underflow 89 UInt m_RCCpbSize; ///< CPB size 90 Double m_RCInitialCpbFullness; ///< initial CPB fullness 91 #endif 87 92 #endif 88 93 -
branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp
r1432 r1433 493 493 Int m_RCInitialQP = m_apcLayerCfg[layer]->getRCInitialQP(); 494 494 Bool m_RCForceIntraQP = m_apcLayerCfg[layer]->getRCForceIntraQP(); 495 496 #if U0132_TARGET_BITS_SATURATION 497 Bool m_RCCpbSaturationEnabled = m_apcLayerCfg[layer]->m_RCCpbSaturationEnabled; 498 UInt m_RCCpbSize = m_apcLayerCfg[layer]->m_RCCpbSize; 499 Double m_RCInitialCpbFullness = m_apcLayerCfg[layer]->m_RCInitialCpbFullness; 500 #endif 495 501 496 502 ScalingListMode m_useScalingListId = m_apcLayerCfg[layer]->m_useScalingListId; … … 789 795 m_cTEncTop.setInitialQP ( m_RCInitialQP ); 790 796 m_cTEncTop.setForceIntraQP ( m_RCForceIntraQP ); 797 #if U0132_TARGET_BITS_SATURATION 798 m_cTEncTop.setCpbSaturationEnabled ( m_RCCpbSaturationEnabled ); 799 m_cTEncTop.setCpbSize ( m_RCCpbSize ); 800 m_cTEncTop.setInitialCpbFullness ( m_RCInitialCpbFullness ); 801 #endif 791 802 m_cTEncTop.setTransquantBypassEnableFlag ( m_TransquantBypassEnableFlag ); 792 803 m_cTEncTop.setCUTransquantBypassFlagForceValue ( m_CUTransquantBypassFlagForce ); -
branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
r1407 r1433 200 200 #endif 201 201 202 #define U0132_TARGET_BITS_SATURATION 1 ///< Rate control with target bits saturation method 202 203 203 204 // ==================================================================================================================== -
branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
r1432 r1433 3575 3575 READ_UVLC( uiChromaInputBitDepthM8 , "cm_input_chroma_bit_depth_minus8" ); 3576 3576 READ_UVLC( uiOutputBitDepthM8, "cm_output_luma_bit_depth_minus8" ); 3577 READ_UVLC( uiChromaOutputBitDepthM8 "cm_output_chroma_bit_depth_minus8" );3577 READ_UVLC( uiChromaOutputBitDepthM8, "cm_output_chroma_bit_depth_minus8" ); 3578 3578 READ_CODE( 2, uiResQaunBit, "cm_res_quant_bit" ); 3579 3579 … … 3681 3681 for( Int nVertexIdx = 0; nVertexIdx < 4; nVertexIdx++ ) 3682 3682 { 3683 pc3DAsymLUT->setCuboidVertexResTree( yIdx + y, uIdx + 3683 pc3DAsymLUT->setCuboidVertexResTree( yIdx + y, uIdx + u, vIdx + v, nVertexIdx, 0, 0, 0 ); 3684 3684 #if R0164_CGS_LUT_BUGFIX_CHECK 3685 3685 pc3DAsymLUT->xSetFilled( yIdx + y, uIdx + u, vIdx + v ); -
branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h
r1432 r1433 339 339 Int m_RCInitialQP; 340 340 Bool m_RCForceIntraQP; 341 #if U0132_TARGET_BITS_SATURATION 342 Bool m_RCCpbSaturationEnabled; 343 UInt m_RCCpbSize; 344 Double m_RCInitialCpbFullness; 345 #endif 341 346 Bool m_TransquantBypassEnableFlag; ///< transquant_bypass_enable_flag setting in PPS. 342 347 Bool m_CUTransquantBypassFlagForce; ///< if transquant_bypass_enable_flag, then, if true, all CU transquant bypass flags will be set to true. … … 936 941 Bool getForceIntraQP () { return m_RCForceIntraQP; } 937 942 Void setForceIntraQP ( Bool b ) { m_RCForceIntraQP = b; } 943 #if U0132_TARGET_BITS_SATURATION 944 Bool getCpbSaturationEnabled() { return m_RCCpbSaturationEnabled;} 945 Void setCpbSaturationEnabled( Bool b ) { m_RCCpbSaturationEnabled = b; } 946 UInt getCpbSize () { return m_RCCpbSize;} 947 Void setCpbSize ( UInt ui ) { m_RCCpbSize = ui; } 948 Double getInitialCpbFullness () { return m_RCInitialCpbFullness; } 949 Void setInitialCpbFullness (Double f) { m_RCInitialCpbFullness = f; } 950 #endif 938 951 Bool getTransquantBypassEnableFlag() { return m_TransquantBypassEnableFlag; } 939 952 Void setTransquantBypassEnableFlag(Bool flag) { m_TransquantBypassEnableFlag = flag; } -
branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
r1432 r1433 2432 2432 estimatedBits = m_pcRateCtrl->getRCPic()->getTargetBits(); 2433 2433 2434 #if U0132_TARGET_BITS_SATURATION 2435 if (m_pcRateCtrl->getCpbSaturationEnabled() && frameLevel != 0) 2436 { 2437 Int estimatedCpbFullness = m_pcRateCtrl->getCpbState() + m_pcRateCtrl->getBufferingRate(); 2438 2439 // prevent overflow 2440 if (estimatedCpbFullness - estimatedBits > (Int)(m_pcRateCtrl->getCpbSize()*0.9f)) 2441 { 2442 estimatedBits = estimatedCpbFullness - (Int)(m_pcRateCtrl->getCpbSize()*0.9f); 2443 } 2444 2445 estimatedCpbFullness -= m_pcRateCtrl->getBufferingRate(); 2446 // prevent underflow 2447 if (estimatedCpbFullness - estimatedBits < (Int)(m_pcRateCtrl->getCpbSize()*0.1f)) 2448 { 2449 estimatedBits = max(200, estimatedCpbFullness - (Int)(m_pcRateCtrl->getCpbSize()*0.1f)); 2450 } 2451 2452 m_pcRateCtrl->getRCPic()->setTargetBits(estimatedBits); 2453 } 2454 #endif 2455 2434 2456 Int sliceQP = m_pcCfg->getInitialQP(); 2435 2457 #if SVC_EXTENSION … … 2455 2477 Int bits = m_pcRateCtrl->getRCSeq()->getLeftAverageBits(); 2456 2478 bits = m_pcRateCtrl->getRCPic()->getRefineBitsForIntra( bits ); 2479 2480 #if U0132_TARGET_BITS_SATURATION 2481 if (m_pcRateCtrl->getCpbSaturationEnabled() ) 2482 { 2483 Int estimatedCpbFullness = m_pcRateCtrl->getCpbState() + m_pcRateCtrl->getBufferingRate(); 2484 2485 // prevent overflow 2486 if (estimatedCpbFullness - bits > (Int)(m_pcRateCtrl->getCpbSize()*0.9f)) 2487 { 2488 bits = estimatedCpbFullness - (Int)(m_pcRateCtrl->getCpbSize()*0.9f); 2489 } 2490 2491 estimatedCpbFullness -= m_pcRateCtrl->getBufferingRate(); 2492 // prevent underflow 2493 if (estimatedCpbFullness - bits < (Int)(m_pcRateCtrl->getCpbSize()*0.1f)) 2494 { 2495 bits = estimatedCpbFullness - (Int)(m_pcRateCtrl->getCpbSize()*0.1f); 2496 } 2497 } 2498 #endif 2499 2457 2500 if ( bits < 200 ) 2458 2501 { … … 2846 2889 m_pcRateCtrl->getRCGOP()->updateAfterPicture( estimatedBits ); 2847 2890 } 2891 #if U0132_TARGET_BITS_SATURATION 2892 if (m_pcRateCtrl->getCpbSaturationEnabled()) 2893 { 2894 m_pcRateCtrl->updateCpbState(actualTotalBits); 2895 printf(" [CPB %6d bits]", m_pcRateCtrl->getCpbState()); 2896 } 2897 #endif 2848 2898 } 2849 2899 … … 4256 4306 #endif 4257 4307 #endif 4258 Void TEncGOP::xFilterImg( Pel *src, Int iSrcStride, Pel *dst, Int iDstStride, Int height 1, Int width1, BitDepths& bitDepth, ComponentID comp )4308 Void TEncGOP::xFilterImg( Pel *src, Int iSrcStride, Pel *dst, Int iDstStride, Int height, Int width, BitDepths& bitDepth, ComponentID comp ) 4259 4309 { 4260 4310 Int height2, width2; … … 4264 4314 Int length = m_cgsFilterLength; 4265 4315 Int shift = bitDepth.recon[CHANNEL_TYPE_LUMA] - bitDepth.recon[CHANNEL_TYPE_CHROMA]; 4266 Int shift2 = 2*7 +shift;4316 Int shift2 = 2*7 + shift; 4267 4317 Int roundingOffset = (1 << (shift2 - 1)); 4268 4318 Int maxVal = (1<<(bitDepth.recon[toChannelType(comp)]-shift))-1; 4269 height2 = (height 1* m_cgsFilterPhases) / m_iN;4270 width2 = (width 1* m_cgsFilterPhases) / m_iN;4319 height2 = (height * m_cgsFilterPhases) / m_iN; 4320 width2 = (width * m_cgsFilterPhases) / m_iN; 4271 4321 4272 4322 m_phaseFilter = comp == COMPONENT_Y ? m_phaseFilterLuma : m_phaseFilterChroma; 4273 4323 4274 4324 // horizontal filtering 4275 for( Int j1 = 0; j1 < height 1; j1++ )4325 for( Int j1 = 0; j1 < height; j1++ ) 4276 4326 { 4277 4327 Int i0 = -m_iN; … … 4302 4352 } 4303 4353 4304 for( Int k = height 1; k < (height1+ (length>>1)); k++)4354 for( Int k = height; k < (height + (length>>1)); k++) 4305 4355 { 4306 4356 memcpy(m_temp[k], m_temp[k-1], (width2) * sizeof(Int)); -
branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.h
r1432 r1433 292 292 inline Short xClip( Short x, Int bitdepth ); 293 293 Void xInitDs( const Int iWidth, const Int iHeight, const Bool allIntra, const Int posScalingFactorX); 294 Void xFilterImg( Pel *src, Int iSrcStride, Pel *dst, Int iDstStride, Int height 1, Int width1, BitDepths& bitDepth, ComponentID comp );294 Void xFilterImg( Pel *src, Int iSrcStride, Pel *dst, Int iDstStride, Int height, Int width, BitDepths& bitDepth, ComponentID comp ); 295 295 296 296 Int xCreate2DArray(Int ***array2D, Int dim0, Int dim1, Int iPadY, Int iPadX); -
branches/SHM-dev/source/Lib/TLibEncoder/TEncRateCtrl.cpp
r1259 r1433 1379 1379 m_encRCSeq->initLCUPara(); 1380 1380 } 1381 #if U0132_TARGET_BITS_SATURATION 1382 m_CpbSaturationEnabled = false; 1383 m_cpbSize = targetBitrate; 1384 m_cpbState = (UInt)(m_cpbSize*0.5f); 1385 m_bufferingRate = (Int)(targetBitrate / frameRate); 1386 #endif 1381 1387 1382 1388 delete[] bitsRatio; … … 1396 1402 } 1397 1403 1404 #if U0132_TARGET_BITS_SATURATION 1405 Int TEncRateCtrl::updateCpbState(Int actualBits) 1406 { 1407 Int cpbState = 1; 1408 1409 m_cpbState -= actualBits; 1410 if (m_cpbState < 0) 1411 { 1412 cpbState = -1; 1413 } 1414 1415 m_cpbState += m_bufferingRate; 1416 if (m_cpbState > m_cpbSize) 1417 { 1418 cpbState = 0; 1419 } 1420 1421 return cpbState; 1422 } 1423 1424 Void TEncRateCtrl::initHrdParam(const TComHRD* pcHrd, Int iFrameRate, Double fInitialCpbFullness) 1425 { 1426 m_CpbSaturationEnabled = true; 1427 m_cpbSize = (pcHrd->getCpbSizeValueMinus1(0, 0, 0) + 1) << (4 + pcHrd->getCpbSizeScale()); 1428 m_cpbState = (UInt)(m_cpbSize*fInitialCpbFullness); 1429 m_bufferingRate = (UInt)(((pcHrd->getBitRateValueMinus1(0, 0, 0) + 1) << (6 + pcHrd->getBitRateScale())) / iFrameRate); 1430 printf("\nHRD - [Initial CPB state %6d] [CPB Size %6d] [Buffering Rate %6d]\n", m_cpbState, m_cpbSize, m_bufferingRate); 1431 } 1432 #endif 1433 1398 1434 Void TEncRateCtrl::destroyRCGOP() 1399 1435 { -
branches/SHM-dev/source/Lib/TLibEncoder/TEncRateCtrl.h
r1259 r1433 265 265 TRCLCU& getLCU( Int LCUIdx ) { return m_LCUs[LCUIdx]; } 266 266 Int getPicActualHeaderBits() { return m_picActualHeaderBits; } 267 #if U0132_TARGET_BITS_SATURATION 268 Void setBitLeft(Int bits) { m_bitsLeft = bits; } 269 #endif 267 270 Void setTargetBits( Int bits ) { m_targetBits = bits; m_bitsLeft = bits;} 268 271 Void setTotalIntraCost(Double cost) { m_totalCostIntra = cost; } … … 322 325 TEncRCPic* getRCPic() { assert ( m_encRCPic != NULL ); return m_encRCPic; } 323 326 list<TEncRCPic*>& getPicList() { return m_listRCPictures; } 327 #if U0132_TARGET_BITS_SATURATION 328 Bool getCpbSaturationEnabled() { return m_CpbSaturationEnabled; } 329 UInt getCpbState() { return m_cpbState; } 330 UInt getCpbSize() { return m_cpbSize; } 331 UInt getBufferingRate() { return m_bufferingRate; } 332 Int updateCpbState(Int actualBits); 333 Void initHrdParam(const TComHRD* pcHrd, Int iFrameRate, Double fInitialCpbFullness); 334 #endif 324 335 325 336 private: … … 329 340 list<TEncRCPic*> m_listRCPictures; 330 341 Int m_RCQP; 331 }; 332 342 #if U0132_TARGET_BITS_SATURATION 343 Bool m_CpbSaturationEnabled; // Enable target bits saturation to avoid CPB overflow and underflow 344 Int m_cpbState; // CPB State 345 UInt m_cpbSize; // CPB size 346 UInt m_bufferingRate; // Buffering rate 333 347 #endif 334 335 348 }; 349 350 #endif 351 352 -
branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp
r1406 r1433 228 228 xInitVPS(); 229 229 230 #if U0132_TARGET_BITS_SATURATION 231 if (m_RCCpbSaturationEnabled) 232 { 233 m_cRateCtrl.initHrdParam(m_cSPS.getVuiParameters()->getHrdParameters(), m_iFrameRate, m_RCInitialCpbFullness); 234 } 235 #endif 230 236 m_cRdCost.setCostMode(m_costMode); 231 237 … … 1002 1008 m_cSPS.setUsedByCurrPicLtSPSFlag(k, 0); 1003 1009 } 1010 1011 #if U0132_TARGET_BITS_SATURATION 1012 if( getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() || getCpbSaturationEnabled() ) 1013 #else 1004 1014 if( getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() ) 1015 #endif 1005 1016 { 1006 1017 xInitHrdParameters(); … … 1025 1036 } 1026 1037 1038 #if U0132_TARGET_BITS_SATURATION 1039 // calculate scale value of bitrate and initial delay 1040 Int calcScale(Int x) 1041 { 1042 UInt iMask = 0xffffffff; 1043 Int ScaleValue = 32; 1044 1045 while ((x&iMask) != 0) 1046 { 1047 ScaleValue--; 1048 iMask = (iMask >> 1); 1049 } 1050 1051 return ScaleValue; 1052 } 1053 #endif 1027 1054 Void TEncTop::xInitHrdParameters() 1028 1055 { … … 1030 1057 Int bitRate = getTargetBitrate(); 1031 1058 Bool isRandomAccess = getIntraPeriod() > 0; 1032 1059 # if U0132_TARGET_BITS_SATURATION 1060 Int cpbSize = getCpbSize(); 1061 1062 if( !getVuiParametersPresentFlag() && !getCpbSaturationEnabled() ) 1063 #else 1033 1064 if( !getVuiParametersPresentFlag() ) 1065 #endif 1034 1066 { 1035 1067 return; … … 1075 1107 hrd->setNalHrdParametersPresentFlag( rateCnt ); 1076 1108 hrd->setVclHrdParametersPresentFlag( rateCnt ); 1077 1078 1109 hrd->setSubPicCpbParamsPresentFlag( useSubCpbParams ); 1079 1110 … … 1090 1121 } 1091 1122 1123 #if U0132_TARGET_BITS_SATURATION 1124 if (calcScale(bitRate) <= 6) 1125 { 1126 hrd->setBitRateScale(0); 1127 } 1128 else 1129 { 1130 hrd->setBitRateScale(calcScale(bitRate) - 6); 1131 } 1132 1133 if (calcScale(cpbSize) <= 4) 1134 { 1135 hrd->setCpbSizeScale(0); 1136 } 1137 else 1138 { 1139 hrd->setCpbSizeScale(calcScale(cpbSize) - 4); 1140 } 1141 #else 1092 1142 hrd->setBitRateScale( 4 ); // in units of 2^( 6 + 4 ) = 1,024 bps 1093 1143 hrd->setCpbSizeScale( 6 ); // in units of 2^( 4 + 6 ) = 1,024 bit 1144 #endif 1145 1094 1146 hrd->setDuCpbSizeScale( 6 ); // in units of 2^( 4 + 6 ) = 1,024 bit 1095 1147 … … 1123 1175 bitrateValue = bitRate / (1 << (6 + hrd->getBitRateScale()) ); // bitRate is in bits, so it needs to be scaled down 1124 1176 // CpbSize[ i ] = ( cpb_size_value_minus1[ i ] + 1 ) * 2^( 4 + cpb_size_scale ) 1177 #if U0132_TARGET_BITS_SATURATION 1178 cpbSizeValue = cpbSize / (1 << (4 + hrd->getCpbSizeScale()) ); // using bitRate results in 1 second CPB size 1179 #else 1125 1180 cpbSizeValue = bitRate / (1 << (4 + hrd->getCpbSizeScale()) ); // using bitRate results in 1 second CPB size 1181 #endif 1182 1126 1183 1127 1184 // DU CPB size could be smaller (i.e. bitrateValue / number of DUs), but we don't know
Note: See TracChangeset for help on using the changeset viewer.