Changeset 41 in 3DVCSoftware for branches/0.3-poznan-univ/source/App/TAppEncoder
- Timestamp:
- 26 Mar 2012, 09:03:21 (13 years ago)
- Location:
- branches/0.3-poznan-univ/source/App/TAppEncoder
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncCfg.cpp
r28 r41 110 110 free (m_pchBitstreamFile) ; 111 111 112 #if FLEX_CODING_ORDER 113 if (m_pchMVCJointCodingOrder != NULL) 114 { 115 free(m_pchMVCJointCodingOrder) ; 116 } 117 #endif 118 112 119 for(Int i = 0; i< m_pchDepthReconFileList.size(); i++ ) 113 120 { … … 153 160 string cfg_ReconFile; 154 161 string cfg_dQPFile; 162 163 #if FLEX_CODING_ORDER 164 string cfg_JointCodingOrdering; 165 #endif 166 155 167 po::Options opts; 156 168 opts.addOptions() … … 191 203 ("NumberOfViews", m_iNumberOfViews, 0, "Number of views") 192 204 205 #if FLEX_CODING_ORDER 206 ("3DVFlexOrder", m_b3DVFlexOrder, false, "flexible coding order flag" ) 207 ("3DVCodingOrder", cfg_JointCodingOrdering, string(""), "The coding order for joint texture-depth coding") 208 #endif 193 209 194 210 /* Unit definition parameters */ … … 367 383 #endif 368 384 #if POZNAN_NONLINEAR_DEPTH 369 ("DepthPower,-dpow", m_fDepthPower, (Double)1.0, "Depth power value (for non-linear processing)") 385 ("NonlinearDepth", m_bUseNonlinearDepth, true, "usage of non-linear depth representation") 386 ("NonlinearDepthModel", m_aiNonlinearDepthModel, std::vector<Int>(0,0), "Nodes for definition of non-linear depth representation") 387 #if POZNAN_NONLINEAR_DEPTH_THRESHOLD 388 ("NonlinearDepthThreshold", m_iNonlinearDepthThreshold, 100, "Threshold for usage of Nonlinear depth representation") 389 #endif 370 390 #endif 371 391 … … 398 418 m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str()); 399 419 m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str()); 420 421 #if FLEX_CODING_ORDER && HHI_VSO 422 m_pchMVCJointCodingOrder = cfg_JointCodingOrdering.empty()?NULL:strdup(cfg_JointCodingOrdering.c_str()); 423 // If flexible order is enabled and if depth comes before the texture for a view, disable VSO 424 Bool depthComesFirst = false; 425 if ( m_b3DVFlexOrder ) 426 { 427 for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) 428 { 429 for ( Int ii=1; ii<12; ii+=2 ) 430 { 431 Int iViewIdxCfg = (Int)(m_pchMVCJointCodingOrder[ii]-'0'); 432 if ( iViewIdxCfg == iViewIdx ) 433 { 434 if ( m_pchMVCJointCodingOrder[ii-1]=='D' ) // depth comes first for this view 435 { 436 depthComesFirst = true; 437 break; 438 } 439 else 440 { 441 assert(m_pchMVCJointCodingOrder[ii-1]=='T'); 442 } 443 } 444 } 445 } 446 } 447 if (depthComesFirst) 448 { 449 m_bUseVSO = false; 450 } 451 #endif 400 452 401 453 … … 458 510 459 511 #if POZNAN_NONLINEAR_DEPTH 460 if (m_fDepthPower<=0) 461 { 462 Float fDepthQP = m_adQP[ m_adQP.size() < 2 ? 0 : 1]; 463 m_fDepthPower = (fDepthQP-30) *0.25/20.0 + 1.25; 464 if (m_fDepthPower<=1.0) m_fDepthPower = 1.0; 465 // QP = 30 = 1.25 466 // QP = 50 = 1.5 467 if (m_fDepthPower>=1.66) m_fDepthPower = 1.66; 468 }; 469 470 #if POZNAN_NONLINEAR_DEPTH_SEND_AS_BYTE 471 m_fDepthPower = dequantizeDepthPower(quantizeDepthPower((Float)m_fDepthPower)); 472 #endif 473 512 #if POZNAN_NONLINEAR_DEPTH_THRESHOLD 513 if(m_bUseNonlinearDepth && m_iNonlinearDepthThreshold>0) 514 { 515 FILE *base_depth_file; 516 unsigned char *depth_buf; 517 int histogram[256]; 518 int i, size; 519 float weighted_avg; 520 base_depth_file = fopen(m_pchDepthInputFileList[0], "rb"); 521 if (base_depth_file) 522 { 523 size = m_iSourceWidth*m_iSourceHeight; 524 depth_buf = (unsigned char *)malloc(size); 525 fread(depth_buf, 1, size, base_depth_file); 526 fclose(base_depth_file); 527 memset(histogram, 0, sizeof(histogram)); 528 for (i=0; i<size;++i) histogram[depth_buf[i]]++; 529 weighted_avg = 0; 530 for (i=0; i<256; ++i) weighted_avg += i*histogram[i]; 531 weighted_avg /= size; 532 533 if (weighted_avg<m_iNonlinearDepthThreshold) 534 { 535 m_bUseNonlinearDepth = 0; 536 printf ("\nWeighted average of depth histogram:%f < %d, turning NonlinearDepthRepresentation OFF\n", weighted_avg, m_iNonlinearDepthThreshold); 537 } 538 } 539 } 540 #endif 541 542 if(m_bUseNonlinearDepth) 543 { 544 m_cNonlinearDepthModel.m_iNum = (Int)m_aiNonlinearDepthModel.size(); 545 m_cNonlinearDepthModel.m_aiPoints[0]=0; 546 for (int i=0; i<m_cNonlinearDepthModel.m_iNum; ++i) 547 m_cNonlinearDepthModel.m_aiPoints[i+1] = m_aiNonlinearDepthModel[i]; 548 549 m_cNonlinearDepthModel.m_aiPoints[m_cNonlinearDepthModel.m_iNum+1]=0; 550 m_cNonlinearDepthModel.Init(); 551 } 474 552 #endif 475 553 … … 555 633 LOG2_DISP_PREC_LUT 556 634 #if POZNAN_NONLINEAR_DEPTH 557 , m_fDepthPower635 ,(m_bUseNonlinearDepth ? &m_cNonlinearDepthModel : NULL) 558 636 #endif 559 637 ); … … 572 650 LOG2_DISP_PREC_LUT 573 651 #if POZNAN_NONLINEAR_DEPTH 574 , m_fDepthPower652 ,(m_bUseNonlinearDepth ? &m_cNonlinearDepthModel : NULL) 575 653 #endif 576 654 ); … … 589 667 LOG2_DISP_PREC_LUT 590 668 #if POZNAN_NONLINEAR_DEPTH 591 , m_fDepthPower669 ,(m_bUseNonlinearDepth ? &m_cNonlinearDepthModel : NULL) 592 670 #endif 593 671 ); … … 605 683 LOG2_DISP_PREC_LUT 606 684 #if POZNAN_NONLINEAR_DEPTH 607 , m_fDepthPower685 ,(m_bUseNonlinearDepth ? &m_cNonlinearDepthModel : NULL) 608 686 #endif 609 687 ); … … 1064 1142 #endif 1065 1143 #if POZNAN_NONLINEAR_DEPTH 1066 printf(" DepthPower:%f ", m_fDepthPower);1144 printf("NLDR:%d ", m_bUseNonlinearDepth ? 1 : 0); 1067 1145 #endif 1068 1146 printf("\n"); -
branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncCfg.h
r28 r41 81 81 Bool m_bUsingDepthMaps ; 82 82 83 #if FLEX_CODING_ORDER 84 char* m_pchMVCJointCodingOrder; ///< texture-depth coding order 85 Bool m_b3DVFlexOrder; ///< flexible coding order flag 86 #endif 87 83 88 84 89 // coding structure … … 290 295 291 296 #if POZNAN_NONLINEAR_DEPTH 292 Double m_fDepthPower; ///< Depth power value 297 std::vector<Int> m_aiNonlinearDepthModel; 298 TComNonlinearDepthModel m_cNonlinearDepthModel; 299 Int m_iNonlinearDepthThreshold; 300 Bool m_bUseNonlinearDepth; 293 301 #endif 294 302 -
branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncTop.cpp
r30 r41 142 142 143 143 #if POZNAN_NONLINEAR_DEPTH 144 m_acTEncTopList[iViewIdx]->setDepthPower ( (Float)m_fDepthPower ); 144 m_acTEncTopList[iViewIdx]->setNonlinearDepthModel ( m_cNonlinearDepthModel ); 145 m_acTEncTopList[iViewIdx]->setUseNonlinearDepth ( m_bUseNonlinearDepth ); 145 146 #endif 146 147 … … 256 257 for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) 257 258 { 259 #if FLEX_CODING_ORDER 260 // Detect whether depth comes before than texture for this view 261 Bool isDepthFirst = false; 262 if ( m_b3DVFlexOrder ) 263 { 264 for ( Int ii=1; ii<12; ii+=2 ) 265 { 266 Int iViewIdxCfg = (Int)(m_pchMVCJointCodingOrder[ii]-'0'); 267 if ( iViewIdxCfg == iViewIdx ) 268 { 269 if ( m_pchMVCJointCodingOrder[ii-1]=='D' ) // depth comes first for this view 270 { 271 isDepthFirst = true; 272 } 273 else 274 { 275 assert(m_pchMVCJointCodingOrder[ii-1]=='T'); 276 } 277 break; 278 } 279 } 280 } 281 #endif 258 282 m_iDepthFrameRcvdVector.push_back(0) ; 259 283 m_acTEncDepthTopList.push_back(new TEncTop); … … 375 399 m_acTEncDepthTopList[iViewIdx]->setUseDMM( m_bUseDMM ); 376 400 #endif 401 #if FLEX_CODING_ORDER && HHI_DMM_PRED_TEX 402 m_acTEncDepthTopList[iViewIdx]->setUseDMM34( (m_b3DVFlexOrder && isDepthFirst) ? false : m_bUseDMM ); 403 #endif 377 404 #if CONSTRAINED_INTRA_PRED 378 405 m_acTEncDepthTopList[iViewIdx]->setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); … … 401 428 #endif 402 429 #if HHI_MPI 430 #if FLEX_CODING_ORDER 431 m_acTEncDepthTopList[iViewIdx]->setUseMVI( (m_b3DVFlexOrder && isDepthFirst) ? false : m_bUseMVI ); 432 #else 403 433 m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI ); 434 #endif 404 435 #endif 405 436 #if POZNAN_DBMP … … 407 438 #endif 408 439 #if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU 409 m_acTEncDepthTopList[iViewIdx]->setUseCUSkip 440 m_acTEncDepthTopList[iViewIdx]->setUseCUSkip ( m_uiUseCUSkip ); 410 441 #endif 411 442 #if POZNAN_NONLINEAR_DEPTH 412 m_acTEncDepthTopList[iViewIdx]->setDepthPower ( (Float)m_fDepthPower ); 443 m_acTEncDepthTopList[iViewIdx]->setNonlinearDepthModel ( m_cNonlinearDepthModel ); 444 m_acTEncDepthTopList[iViewIdx]->setUseNonlinearDepth ( m_bUseNonlinearDepth ); 413 445 #endif 414 446 … … 690 722 m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcPdmDepthOrg, m_aiPad, m_bUsingDepthMaps ); 691 723 #if POZNAN_NONLINEAR_DEPTH 692 pcPdmDepthOrg->nonlinearDepthForward(pcPdmDepthOrg, m_fDepthPower); 724 if( m_bUseNonlinearDepth ) 725 pcPdmDepthOrg->nonlinearDepthForward(pcPdmDepthOrg, m_cNonlinearDepthModel); 693 726 #endif 694 727 } … … 714 747 m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcDepthPicYuvOrg, m_aiPad ) ; 715 748 #if POZNAN_NONLINEAR_DEPTH 716 pcDepthPicYuvOrg->nonlinearDepthForward(pcDepthPicYuvOrg, m_fDepthPower); 749 if( m_bUseNonlinearDepth ) 750 pcDepthPicYuvOrg->nonlinearDepthForward(pcDepthPicYuvOrg, m_cNonlinearDepthModel); 717 751 #endif 718 752 bDepthEos[iViewIdx] = ( m_acTVideoIOYuvDepthInputFileList[iViewIdx]->isEof() == 1 ? true : false ); … … 744 778 #endif 745 779 780 #if FLEX_CODING_ORDER 781 if (m_b3DVFlexOrder) 782 { 783 Int i=0; 784 Int iViewIdx = 0; 785 bool bThisViewContinueReadingPics = false; 786 bool bThisViewContinueReadingDepthPics = false; 787 Int iNumberofDepthViews = m_bUsingDepthMaps?m_iNumberOfViews:0; 788 for(Int j=0; j < (m_iNumberOfViews+ iNumberofDepthViews); j++ ) // Start encoding 789 { 790 if (m_pchMVCJointCodingOrder[i]=='T') 791 { 792 i++; 793 assert(isdigit(m_pchMVCJointCodingOrder[i])); 794 iViewIdx = (Int)(m_pchMVCJointCodingOrder[i]-'0'); 795 bThisViewContinueReadingPics = bContinueReadingPics[iViewIdx]; 796 #if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH 797 // If no depth picture reconstruction for current view and current POC is available sythesize one 798 Int iCurrPoc = m_acTEncTopList[ 0 ]->getNextFrameId(); 799 Bool bCurrPicDepthRec = getPicFromView( iViewIdx, iCurrPoc, true ) != NULL && getPicFromView( iViewIdx, iCurrPoc, true )->getReconMark(); 800 if(m_bUseTexDqpAccordingToDepth && !bCurrPicDepthRec) 801 { 802 xStoreDepthSynthPicsInBuffer(iViewIdx); 803 } 804 #endif 805 m_acTEncTopList[iViewIdx]->encode( bEos[iViewIdx], m_cListPicYuvRecMap[iViewIdx], pcBitstream, bThisViewContinueReadingPics ); 806 bContinueReadingPics[iViewIdx]=bThisViewContinueReadingPics; 807 bAllContinueReadingPics = bAllContinueReadingPics||bContinueReadingPics[iViewIdx]; 808 809 if(pcBitstream->getNumberOfWrittenBits()!=0) 810 { 811 m_cTVideoIOBitsFile.writeBits( pcBitstream ); 812 } 813 pcBitstream->resetBits(); //GT: also done later in .... 814 pcBitstream->rewindStreamPacket( ); 815 // write bistream to file if necessary 816 xWriteOutput( iViewIdx ); //GT: Write Reconfiles (when gop is complete?) 817 i++; 818 } 819 else if ( m_pchMVCJointCodingOrder[i] == 'D') 820 { 821 i++; 822 if( m_bUsingDepthMaps ) 823 { 824 assert(isdigit(m_pchMVCJointCodingOrder[i])); 825 iViewIdx = (Int)(m_pchMVCJointCodingOrder[i]-'0'); 826 bThisViewContinueReadingDepthPics = bContinueReadingDepthPics[iViewIdx]; 827 m_acTEncDepthTopList[iViewIdx]->encode( bDepthEos[iViewIdx], m_cListPicYuvDepthRecMap[iViewIdx], pcBitstream, bThisViewContinueReadingDepthPics ); 828 bContinueReadingDepthPics[iViewIdx]=bThisViewContinueReadingDepthPics; 829 830 bAllContinueReadingDepthPics = bAllContinueReadingDepthPics||bContinueReadingDepthPics[iViewIdx]; 831 if(pcBitstream->getNumberOfWrittenBits()!=0) 832 { 833 m_cTVideoIOBitsFile.writeBits( pcBitstream ); 834 } 835 pcBitstream->resetBits(); 836 pcBitstream->rewindStreamPacket( ); 837 // write bistream to file if necessary 838 xWriteOutput( iViewIdx, true ); 839 i++; 840 } 841 } 842 } 843 } 844 else 845 { 846 #endif 746 847 //GT: Encode 747 848 for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) // Start encoding … … 755 856 //* 756 857 #if POZNAN_TEXTURE_TU_DELTA_QP_ACCORDING_TO_DEPTH 858 #if FLEX_CODING_ORDER 859 // If no depth picture reconstruction for current view and current POC is available sythesize one 860 Int iCurrPoc = m_acTEncTopList[ 0 ]->getNextFrameId(); 861 Bool bCurrPicDepthRec = getPicFromView( iViewIdx, iCurrPoc, true ) != NULL && getPicFromView( iViewIdx, iCurrPoc, true )->getReconMark(); 862 if(m_bUseTexDqpAccordingToDepth && !bCurrPicDepthRec) 863 #else 757 864 if(m_bUseTexDqpAccordingToDepth) 865 #endif 758 866 { 759 867 xStoreDepthSynthPicsInBuffer(iViewIdx); … … 798 906 } 799 907 } 800 908 #if FLEX_CODING_ORDER 909 } 910 #endif 801 911 // delete extra picture buffers 802 912 if( bCurrPocCoded ) … … 1004 1114 riNextPocToDump++; 1005 1115 #if POZNAN_NONLINEAR_DEPTH 1006 if(isDepth )1116 if(isDepth && m_bUseNonlinearDepth) 1007 1117 { 1008 1118 TComPicYuv *pcPicOrg = i->second; … … 1011 1121 pcPicPow->create( pcPicOrg->getWidth(), pcPicOrg->getHeight(), pcPicOrg->getMaxCuWidth(), pcPicOrg->getMaxCuHeight(), pcPicOrg->getMaxCuDepth() ); 1012 1122 //cPicPower.create(pcSPS->getWidth(), pcSPS->getHeight(), pcSPS->getMaxCUWidth(), pcSPS->getMaxCUHeight(), pcSPS->getMaxCUDepth() ); 1013 pcPicOrg->nonlinearDepthBackward(pcPicPow, m_ fDepthPower);1123 pcPicOrg->nonlinearDepthBackward(pcPicPow, m_cNonlinearDepthModel); 1014 1124 rpcTVideoIOYuvReconFile->write( pcPicPow, m_aiPad ); 1015 1125 // to do destroy pcPicow
Note: See TracChangeset for help on using the changeset viewer.