Changeset 540 in SHVCSoftware for trunk/source/Lib/TLibEncoder/TEncRateCtrl.h
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/SHM-4.1-dev (added) merged: 501-539 /trunk merged: 499
- Property svn:mergeinfo changed
-
trunk/source
- Property svn:mergeinfo changed
/branches/SHM-4.1-dev/source (added) merged: 502-522,524-533,535,537-539
- Property svn:mergeinfo changed
-
trunk/source/Lib/TLibEncoder/TEncRateCtrl.h
r313 r540 55 55 //! \{ 56 56 57 #if RATE_CONTROL_LAMBDA_DOMAIN58 57 #include "../TLibEncoder/TEncCfg.h" 59 58 #include <list> … … 65 64 const Double g_RCWeightPicTargetBitInGOP = 0.9; 66 65 const Double g_RCWeightPicRargetBitInBuffer = 1.0 - g_RCWeightPicTargetBitInGOP; 67 #if M0036_RC_IMPROVEMENT68 66 const Int g_RCIterationNum = 20; 69 67 const Double g_RCWeightHistoryLambda = 0.5; … … 74 72 const Double g_RCBetaMinValue = -3.0; 75 73 const Double g_RCBetaMaxValue = -0.1; 76 #endif 77 78 #if RATE_CONTROL_INTRA 74 79 75 #define ALPHA 6.7542; 80 76 #define BETA1 1.2517 81 77 #define BETA2 1.7860 82 #endif83 78 84 79 struct TRCLCU … … 88 83 Int m_targetBits; 89 84 Double m_lambda; 90 #if M0036_RC_IMPROVEMENT91 85 Double m_bitWeight; 92 #else93 Double m_MAD;94 #endif95 86 Int m_numberOfPixel; 96 #if RATE_CONTROL_INTRA97 87 Double m_costIntra; 98 88 Int m_targetBitsLeft; 99 #endif100 89 }; 101 90 … … 113 102 114 103 public: 115 #if M0036_RC_IMPROVEMENT116 104 Void create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel, Int adaptiveBit ); 117 #else118 Void create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel );119 #endif120 105 Void destroy(); 121 106 Void initBitsRatio( Int bitsRatio[] ); … … 124 109 Void initLCUPara( TRCParameter** LCUPara = NULL ); // NULL to initial with default value 125 110 Void updateAfterPic ( Int bits ); 126 #if !RATE_CONTROL_INTRA127 Int getRefineBitsForIntra( Int orgBits );128 #endif129 #if M0036_RC_IMPROVEMENT130 111 Void setAllBitRatio( Double basicLambda, Double* equaCoeffA, Double* equaCoeffB ); 131 #endif132 112 133 113 public: … … 167 147 Double getBetaUpdate() { return m_betaUpdate; } 168 148 169 #if M0036_RC_IMPROVEMENT170 149 Int getAdaptiveBits() { return m_adaptiveBit; } 171 150 Double getLastLambda() { return m_lastLambda; } 172 151 Void setLastLambda( Double lamdba ) { m_lastLambda = lamdba; } 173 #endif174 152 175 153 private: … … 200 178 Bool m_useLCUSeparateModel; 201 179 202 #if M0036_RC_IMPROVEMENT203 180 Int m_adaptiveBit; 204 181 Double m_lastLambda; 205 #endif206 182 }; 207 183 … … 219 195 private: 220 196 Int xEstGOPTargetBits( TEncRCSeq* encRCSeq, Int GOPSize ); 221 #if M0036_RC_IMPROVEMENT222 197 Void xCalEquaCoeff( TEncRCSeq* encRCSeq, Double* lambdaRatio, Double* equaCoeffA, Double* equaCoeffB, Int GOPSize ); 223 198 Double xSolveEqua( Double targetBpp, Double* equaCoeffA, Double* equaCoeffB, Int GOPSize ); 224 #endif225 199 226 200 public: … … 251 225 Void destroy(); 252 226 253 #if !RATE_CONTROL_INTRA254 Double estimatePicLambda( list<TEncRCPic*>& listPreviousPictures );255 #endif256 227 Int estimatePicQP ( Double lambda, list<TEncRCPic*>& listPreviousPictures ); 257 #if RATE_CONTROL_INTRA258 228 Int getRefineBitsForIntra(Int orgBits); 259 229 Double calculateLambdaIntra(double alpha, double beta, double MADPerPixel, double bitsPerPixel); … … 264 234 Double getLCUTargetBpp(SliceType eSliceType); 265 235 Double getLCUEstLambdaAndQP(Double bpp, Int clipPicQP, Int *estQP); 266 #else267 Double getLCUTargetBpp();268 #endif269 236 Double getLCUEstLambda( Double bpp ); 270 237 Int getLCUEstQP( Double lambda, Int clipPicQP ); 271 238 272 239 Void updateAfterLCU( Int LCUIdx, Int bits, Int QP, Double lambda, Bool updateLCUParameter = true ); 273 #if M0036_RC_IMPROVEMENT274 #if RATE_CONTROL_INTRA275 240 Void updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda, SliceType eSliceType); 276 #else277 Void updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda );278 #endif279 #else280 Void updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda, Double effectivePercentage );281 #endif282 241 283 242 Void addToPictureLsit( list<TEncRCPic*>& listPreviousPictures ); 284 #if !M0036_RC_IMPROVEMENT285 Double getEffectivePercentage();286 #endif287 243 Double calAverageQP(); 288 244 Double calAverageLambda(); … … 300 256 Int getNumberOfLCU() { return m_numberOfLCU; } 301 257 Int getTargetBits() { return m_targetBits; } 302 #if !RATE_CONTROL_INTRA303 Void setTargetBits( Int bits ) { m_targetBits = bits; }304 #endif305 258 Int getEstHeaderBits() { return m_estHeaderBits; } 306 259 Int getLCULeft() { return m_LCULeft; } … … 312 265 TRCLCU& getLCU( Int LCUIdx ) { return m_LCUs[LCUIdx]; } 313 266 Int getPicActualHeaderBits() { return m_picActualHeaderBits; } 314 #if !M0036_RC_IMPROVEMENT315 Double getTotalMAD() { return m_totalMAD; }316 Void setTotalMAD( Double MAD ) { m_totalMAD = MAD; }317 #endif318 #if RATE_CONTROL_INTRA319 267 Void setTargetBits( Int bits ) { m_targetBits = bits; m_bitsLeft = bits;} 320 268 Void setTotalIntraCost(Double cost) { m_totalCostIntra = cost; } 321 269 Void getLCUInitTargetBits(); 322 #endif323 270 324 271 Int getPicActualBits() { return m_picActualBits; } … … 348 295 TRCLCU* m_LCUs; 349 296 Int m_picActualHeaderBits; // only SH and potential APS 350 #if !M0036_RC_IMPROVEMENT351 Double m_totalMAD;352 #endif353 #if RATE_CONTROL_INTRA354 297 Double m_totalCostIntra; 355 298 Double m_remainingCostIntra; 356 #endif357 299 Int m_picActualBits; // the whole picture, including header 358 300 Int m_picQP; // in integer form 359 301 Double m_picLambda; 360 #if !M0036_RC_IMPROVEMENT361 TEncRCPic* m_lastPicture;362 #endif363 302 }; 364 303 … … 370 309 371 310 public: 372 #if M0036_RC_IMPROVEMENT373 311 Void init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] ); 374 #else375 Void init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Bool keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] );376 #endif377 312 Void destroy(); 378 313 Void initRCPic( Int frameLevel ); … … 396 331 }; 397 332 398 #else399 400 // ====================================================================================================================401 // Class definition402 // ====================================================================================================================403 #define MAX_DELTA_QP 2404 #define MAX_CUDQP_DEPTH 0405 406 typedef struct FrameData407 {408 Bool m_isReferenced;409 Int m_qp;410 Int m_bits;411 Double m_costMAD;412 }FrameData;413 414 typedef struct LCUData415 {416 Int m_qp; ///< coded QP417 Int m_bits; ///< actually generated bits418 Int m_pixels; ///< number of pixels for a unit419 Int m_widthInPixel; ///< number of pixels for width420 Int m_heightInPixel; ///< number of pixels for height421 Double m_costMAD; ///< texture complexity for a unit422 }LCUData;423 424 class MADLinearModel425 {426 private:427 Bool m_activeOn;428 Double m_paramY1;429 Double m_paramY2;430 Double m_costMADs[3];431 432 public:433 MADLinearModel () {};434 ~MADLinearModel() {};435 436 Void initMADLinearModel ();437 Double getMAD ();438 Void updateMADLiearModel ();439 Void updateMADHistory (Double costMAD);440 Bool IsUpdateAvailable () { return m_activeOn; }441 };442 443 class PixelBaseURQQuadraticModel444 {445 private:446 Double m_paramHighX1;447 Double m_paramHighX2;448 Double m_paramLowX1;449 Double m_paramLowX2;450 public:451 PixelBaseURQQuadraticModel () {};452 ~PixelBaseURQQuadraticModel() {};453 454 Void initPixelBaseQuadraticModel ();455 Int getQP (Int qp, Int targetBits, Int numberOfPixels, Double costPredMAD);456 Void updatePixelBasedURQQuadraticModel (Int qp, Int bits, Int numberOfPixels, Double costMAD);457 Bool checkUpdateAvailable (Int qpReference );458 Double xConvertQP2QStep (Int qp );459 Int xConvertQStep2QP (Double qStep );460 };461 462 class TEncRateCtrl463 {464 private:465 Bool m_isLowdelay;466 Int m_prevBitrate;467 Int m_currBitrate;468 Int m_frameRate;469 Int m_refFrameNum;470 Int m_nonRefFrameNum;471 Int m_numOfPixels;472 Int m_sourceWidthInLCU;473 Int m_sourceHeightInLCU;474 Int m_sizeGOP;475 Int m_indexGOP;476 Int m_indexFrame;477 Int m_indexLCU;478 Int m_indexUnit;479 Int m_indexRefFrame;480 Int m_indexNonRefFrame;481 Int m_indexPOCInGOP;482 Int m_indexPrevPOCInGOP;483 Int m_occupancyVB;484 Int m_initialOVB;485 Int m_targetBufLevel;486 Int m_initialTBL;487 Int m_remainingBitsInGOP;488 Int m_remainingBitsInFrame;489 Int m_occupancyVBInFrame;490 Int m_targetBits;491 Int m_numUnitInFrame;492 Int m_codedPixels;493 Bool m_activeUnitLevelOn;494 Double m_costNonRefAvgWeighting;495 Double m_costRefAvgWeighting;496 Double m_costAvgbpp;497 498 FrameData* m_pcFrameData;499 LCUData* m_pcLCUData;500 501 MADLinearModel m_cMADLinearModel;502 PixelBaseURQQuadraticModel m_cPixelURQQuadraticModel;503 504 public:505 TEncRateCtrl () {};506 virtual ~TEncRateCtrl() {};507 508 Void create (Int sizeIntraPeriod, Int sizeGOP, Int frameRate, Int targetKbps, Int qp, Int numLCUInBasicUnit, Int sourceWidth, Int sourceHeight, Int maxCUWidth, Int maxCUHeight);509 Void destroy ();510 511 Void initFrameData (Int qp = 0);512 Void initUnitData (Int qp = 0);513 Int getFrameQP (Bool isReferenced, Int POC);514 Bool calculateUnitQP ();515 Int getUnitQP () { return m_pcLCUData[m_indexLCU].m_qp; }516 Void updateRCGOPStatus ();517 Void updataRCFrameStatus (Int frameBits, SliceType eSliceType);518 Void updataRCUnitStatus ();519 Void updateLCUData (TComDataCU* pcCU, UInt64 actualLCUBits, Int qp);520 Void updateFrameData (UInt64 actualFrameBits);521 Double xAdjustmentBits (Int& reductionBits, Int& compensationBits);522 Int getGOPId () { return m_indexFrame; }523 };524 333 #endif 525 334 526 #endif 527 528 335
Note: See TracChangeset for help on using the changeset viewer.