Changeset 1391 in SHVCSoftware for branches/SHM-dev
- Timestamp:
- 4 Aug 2015, 03:15:00 (9 years ago)
- Location:
- branches/SHM-dev/source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp
r1381 r1391 504 504 { 505 505 const T minValIncl; 506 const T maxValIncl; // Use 0 for unlimited506 const T maxValIncl; 507 507 const std::size_t minNumValuesIncl; 508 508 const std::size_t maxNumValuesIncl; // Use 0 for unlimited … … 516 516 SMultiValueInput<T> &operator=(const std::vector<T> &userValues) { values=userValues; return *this; } 517 517 SMultiValueInput<T> &operator=(const SMultiValueInput<T> &userValues) { values=userValues.values; return *this; } 518 519 T readValue(const Char *&pStr, Bool &bSuccess); 520 521 istream& readValues(std::istream &in); 518 522 }; 519 523 520 static inline istream& operator >> (istream &in, SMultiValueInput<UInt> &values) 521 { 522 values.values.clear(); 524 template <class T> 525 static inline istream& operator >> (std::istream &in, SMultiValueInput<T> &values) 526 { 527 return values.readValues(in); 528 } 529 530 template<> 531 UInt SMultiValueInput<UInt>::readValue(const Char *&pStr, Bool &bSuccess) 532 { 533 Char *eptr; 534 UInt val=strtoul(pStr, &eptr, 0); 535 pStr=eptr; 536 bSuccess=!(*eptr!=0 && !isspace(*eptr) && *eptr!=',') && !(val<minValIncl || val>maxValIncl); 537 return val; 538 } 539 540 template<> 541 Int SMultiValueInput<Int>::readValue(const Char *&pStr, Bool &bSuccess) 542 { 543 Char *eptr; 544 Int val=strtol(pStr, &eptr, 0); 545 pStr=eptr; 546 bSuccess=!(*eptr!=0 && !isspace(*eptr) && *eptr!=',') && !(val<minValIncl || val>maxValIncl); 547 return val; 548 } 549 550 template<> 551 Double SMultiValueInput<Double>::readValue(const Char *&pStr, Bool &bSuccess) 552 { 553 Char *eptr; 554 Double val=strtod(pStr, &eptr); 555 pStr=eptr; 556 bSuccess=!(*eptr!=0 && !isspace(*eptr) && *eptr!=',') && !(val<minValIncl || val>maxValIncl); 557 return val; 558 } 559 560 template<> 561 Bool SMultiValueInput<Bool>::readValue(const Char *&pStr, Bool &bSuccess) 562 { 563 Char *eptr; 564 Int val=strtol(pStr, &eptr, 0); 565 pStr=eptr; 566 bSuccess=!(*eptr!=0 && !isspace(*eptr) && *eptr!=',') && !(val<Int(minValIncl) || val>Int(maxValIncl)); 567 return val!=0; 568 } 569 570 template <class T> 571 istream& SMultiValueInput<T>::readValues(std::istream &in) 572 { 573 values.clear(); 523 574 string str; 524 575 while (!in.eof()) … … 534 585 while (*pStr != 0) 535 586 { 536 Char *eptr;537 UInt val=strtoul(pStr, &eptr, 0);538 if ( *eptr!=0 && !isspace(*eptr) && *eptr!=',')587 Bool bSuccess=true; 588 T val=readValue(pStr, bSuccess); 589 if (!bSuccess) 539 590 { 540 591 in.setstate(ios::failbit); 541 592 break; 542 593 } 543 if (val<values.minValIncl || val>values.maxValIncl) 594 595 if (maxNumValuesIncl != 0 && values.size() >= maxNumValuesIncl) 544 596 { 545 597 in.setstate(ios::failbit); 546 598 break; 547 599 } 548 549 if (values.maxNumValuesIncl != 0 && values.values.size() >= values.maxNumValuesIncl) 550 { 551 in.setstate(ios::failbit); 552 break; 553 } 554 values.values.push_back(val); 600 values.push_back(val); 555 601 // soak up any whitespace and up to 1 comma. 556 pStr=eptr;557 602 for(;isspace(*pStr);pStr++); 558 603 if (*pStr == ',') … … 563 608 } 564 609 } 565 if (values.values.size() < values.minNumValuesIncl) 566 { 567 in.setstate(ios::failbit); 568 } 569 return in; 570 } 571 572 static inline istream& operator >> (istream &in, SMultiValueInput<Int> &values) 573 { 574 values.values.clear(); 575 string str; 576 while (!in.eof()) 577 { 578 string tmp; in >> tmp; str+=" " + tmp; 579 } 580 if (!str.empty()) 581 { 582 const Char *pStr=str.c_str(); 583 // soak up any whitespace 584 for(;isspace(*pStr);pStr++); 585 586 while (*pStr != 0) 587 { 588 Char *eptr; 589 Int val=strtol(pStr, &eptr, 0); 590 if (*eptr!=0 && !isspace(*eptr) && *eptr!=',') 591 { 592 in.setstate(ios::failbit); 593 break; 594 } 595 if (val<values.minValIncl || val>values.maxValIncl) 596 { 597 in.setstate(ios::failbit); 598 break; 599 } 600 601 if (values.maxNumValuesIncl != 0 && values.values.size() >= values.maxNumValuesIncl) 602 { 603 in.setstate(ios::failbit); 604 break; 605 } 606 values.values.push_back(val); 607 // soak up any whitespace and up to 1 comma. 608 pStr=eptr; 609 for(;isspace(*pStr);pStr++); 610 if (*pStr == ',') 611 { 612 pStr++; 613 } 614 for(;isspace(*pStr);pStr++); 615 } 616 } 617 if (values.values.size() < values.minNumValuesIncl) 618 { 619 in.setstate(ios::failbit); 620 } 621 return in; 622 } 623 624 static inline istream& operator >> (istream &in, SMultiValueInput<Bool> &values) 625 { 626 values.values.clear(); 627 string str; 628 while (!in.eof()) 629 { 630 string tmp; in >> tmp; str+=" " + tmp; 631 } 632 if (!str.empty()) 633 { 634 const Char *pStr=str.c_str(); 635 // soak up any whitespace 636 for(;isspace(*pStr);pStr++); 637 638 while (*pStr != 0) 639 { 640 Char *eptr; 641 Int val=strtol(pStr, &eptr, 0); 642 if (*eptr!=0 && !isspace(*eptr) && *eptr!=',') 643 { 644 in.setstate(ios::failbit); 645 break; 646 } 647 if (val<Int(values.minValIncl) || val>Int(values.maxValIncl)) 648 { 649 in.setstate(ios::failbit); 650 break; 651 } 652 653 if (values.maxNumValuesIncl != 0 && values.values.size() >= values.maxNumValuesIncl) 654 { 655 in.setstate(ios::failbit); 656 break; 657 } 658 values.values.push_back(val!=0); 659 // soak up any whitespace and up to 1 comma. 660 pStr=eptr; 661 for(;isspace(*pStr);pStr++); 662 if (*pStr == ',') 663 { 664 pStr++; 665 } 666 for(;isspace(*pStr);pStr++); 667 } 668 } 669 if (values.values.size() < values.minNumValuesIncl) 610 if (values.size() < minNumValuesIncl) 670 611 { 671 612 in.setstate(ios::failbit); … … 1051 992 SMultiValueInput<Int> cfg_codedPivotValue (std::numeric_limits<Int>::min(), std::numeric_limits<Int>::max(), 0, 1<<16); 1052 993 SMultiValueInput<Int> cfg_targetPivotValue (std::numeric_limits<Int>::min(), std::numeric_limits<Int>::max(), 0, 1<<16); 994 995 SMultiValueInput<Double> cfg_adIntraLambdaModifier (0, std::numeric_limits<Double>::max(), 0, MAX_TLAYER); ///< Lambda modifier for Intra pictures, one for each temporal layer. If size>temporalLayer, then use [temporalLayer], else if size>0, use [size()-1], else use m_adLambdaModifier. 996 1053 997 1054 998 const UInt defaultInputKneeCodes[3] = { 600, 800, 900 }; … … 1359 1303 ("LambdaModifier6,-LM6", m_adLambdaModifier[ 6 ], ( Double )1.0, "Lambda modifier for temporal layer 6") 1360 1304 #endif 1305 ("LambdaModifierI,-LMI", cfg_adIntraLambdaModifier, cfg_adIntraLambdaModifier, "Lambda modifiers for Intra pictures, comma separated, up to one the number of temporal layer. If entry for temporalLayer exists, then use it, else if some are specified, use the last, else use the standard LambdaModifiers.") 1306 ("IQPFactor,-IQF", m_dIntraQpFactor, -1.0, "Intra QP Factor for Lambda Computation. If negative, use the default equation: 0.57*(1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? (GopSize-1)/2 : GopSize-1) ))") 1361 1307 1362 1308 /* Quantization parameters */ … … 1831 1777 1832 1778 1779 m_adIntraLambdaModifier = cfg_adIntraLambdaModifier.values; 1833 1780 if(m_isField) 1834 1781 { -
branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h
r1381 r1391 88 88 Char* m_pchReconFile; ///< output reconstruction file 89 89 #endif 90 // Lambda modifiers 90 91 Double m_adLambdaModifier[ MAX_TLAYER ]; ///< Lambda modifier array for each temporal layer 92 std::vector<Double> m_adIntraLambdaModifier; ///< Lambda modifier for Intra pictures, one for each temporal layer. If size>temporalLayer, then use [temporalLayer], else if size>0, use [size()-1], else use m_adLambdaModifier. 93 Double m_dIntraQpFactor; ///< Intra Q Factor. If negative, use a default equation: 0.57*(1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? (GopSize-1)/2 : GopSize-1) )) 94 91 95 // source specification 92 96 #if !SVC_EXTENSION -
branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp
r1381 r1391 537 537 m_cTEncTop.setLambdaModifier ( uiLoop, m_adLambdaModifier[ uiLoop ] ); 538 538 } 539 m_cTEncTop.setIntraLambdaModifier ( m_adIntraLambdaModifier ); 540 m_cTEncTop.setIntraQpFactor ( m_dIntraQpFactor ); 541 539 542 m_cTEncTop.setQP ( m_iQP ); 540 543 -
branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h
r1369 r1391 108 108 Int m_framesToBeEncoded; 109 109 Double m_adLambdaModifier[ MAX_TLAYER ]; 110 std::vector<Double> m_adIntraLambdaModifier; 111 Double m_dIntraQpFactor; ///< Intra Q Factor. If negative, use a default equation: 0.57*(1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? (GopSize-1)/2 : GopSize-1) )) 110 112 111 113 Bool m_printMSEBasedSequencePSNR; … … 597 599 Int getSourceHeight () { return m_iSourceHeight; } 598 600 Int getFramesToBeEncoded () { return m_framesToBeEncoded; } 599 Void setLambdaModifier ( UInt uiIndex, Double dValue ) { m_adLambdaModifier[ uiIndex ] = dValue; } 600 Double getLambdaModifier ( UInt uiIndex ) const { return m_adLambdaModifier[ uiIndex ]; } 601 602 //====== Lambda Modifiers ======== 603 Void setLambdaModifier ( UInt uiIndex, Double dValue ) { m_adLambdaModifier[ uiIndex ] = dValue; } 604 Double getLambdaModifier ( UInt uiIndex ) const { return m_adLambdaModifier[ uiIndex ]; } 605 Void setIntraLambdaModifier ( const std::vector<Double> &dValue ) { m_adIntraLambdaModifier = dValue; } 606 const std::vector<Double>& getIntraLambdaModifier() const { return m_adIntraLambdaModifier; } 607 Void setIntraQpFactor ( Double dValue ) { m_dIntraQpFactor = dValue; } 608 Double getIntraQpFactor () const { return m_dIntraQpFactor; } 601 609 602 610 //==== Coding Structure ======== -
branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.cpp
r1390 r1391 236 236 */ 237 237 238 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iGOPid, TComSlice*& rpcSlice,Bool isField )238 Void TEncSlice::initEncSlice( TComPic* pcPic, const Int pocLast, const Int pocCurr, const Int iGOPid, TComSlice*& rpcSlice, const Bool isField ) 239 239 { 240 240 Double dQP; … … 377 377 Int SHIFT_QP = 12; 378 378 379 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? NumberBFrames/2 : NumberBFrames) );380 381 379 #if FULL_NBIT 382 380 #if SVC_EXTENSION … … 396 394 if ( eSliceType==I_SLICE ) 397 395 { 398 dQPFactor=0.57*dLambda_scale; 399 } 396 if (m_pcCfg->getIntraQpFactor()>=0.0 && m_pcCfg->getGOPEntry(iGOPid).m_sliceType != I_SLICE) 397 { 398 dQPFactor=m_pcCfg->getIntraQpFactor(); 399 } 400 else 401 { 402 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? NumberBFrames/2 : NumberBFrames) ); 403 404 dQPFactor=0.57*dLambda_scale; 405 } 406 } 407 400 408 dLambda = dQPFactor*pow( 2.0, qp_temp/3.0 ); 401 409 … … 431 439 iQP = m_piRdPicQp [0]; 432 440 433 if( rpcSlice->getSliceType( ) != I_SLICE ) 434 { 435 dLambda *= m_pcCfg->getLambdaModifier( m_pcCfg->getGOPEntry(iGOPid).m_temporalId ); 436 } 441 const Int temporalId=m_pcCfg->getGOPEntry(iGOPid).m_temporalId; 442 const std::vector<Double> &intraLambdaModifiers=m_pcCfg->getIntraLambdaModifier(); 443 444 Double lambdaModifier; 445 if( rpcSlice->getSliceType( ) != I_SLICE || intraLambdaModifiers.empty()) 446 { 447 lambdaModifier = m_pcCfg->getLambdaModifier( temporalId ); 448 } 449 else 450 { 451 lambdaModifier = intraLambdaModifiers[ (temporalId < intraLambdaModifiers.size()) ? temporalId : (intraLambdaModifiers.size()-1) ]; 452 } 453 454 dLambda *= lambdaModifier; 437 455 438 456 #if JCTVC_M0259_LAMBDAREFINEMENT … … 524 542 rpcSlice->setDepth ( depth ); 525 543 526 pcPic->setTLayer( m_pcCfg->getGOPEntry(iGOPid).m_temporalId );544 pcPic->setTLayer( temporalId ); 527 545 if(eSliceType==I_SLICE) 528 546 { -
branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.h
r1389 r1391 120 120 121 121 /// preparation of slice encoding (reference marking, QP and lambda) 122 Void initEncSlice ( TComPic* pcPic, Int pocLast, Int pocCurr,123 Int iGOPid, TComSlice*& rpcSlice,Bool isField );122 Void initEncSlice ( TComPic* pcPic, const Int pocLast, const Int pocCurr, 123 const Int iGOPid, TComSlice*& rpcSlice, const Bool isField ); 124 124 Void resetQP ( TComPic* pic, Int sliceQP, Double lambda ); 125 125 // compress and encode slice
Note: See TracChangeset for help on using the changeset viewer.