Changeset 41 in 3DVCSoftware for branches/0.3-poznan-univ/source/App/TAppEncoder


Ignore:
Timestamp:
26 Mar 2012, 09:03:21 (13 years ago)
Author:
poznan-univ
Message:

Adjustment for FlexCO, and high-level syntax improvement.

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  
    110110    free (m_pchBitstreamFile) ;
    111111
     112#if FLEX_CODING_ORDER
     113  if (m_pchMVCJointCodingOrder != NULL)
     114  {
     115    free(m_pchMVCJointCodingOrder) ;
     116  }
     117#endif
     118
    112119  for(Int i = 0; i< m_pchDepthReconFileList.size(); i++ )
    113120  {
     
    153160  string cfg_ReconFile;
    154161  string cfg_dQPFile;
     162
     163#if FLEX_CODING_ORDER
     164  string cfg_JointCodingOrdering;
     165#endif
     166
    155167  po::Options opts;
    156168  opts.addOptions()
     
    191203  ("NumberOfViews",         m_iNumberOfViews,    0, "Number of views")
    192204
     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
    193209
    194210  /* Unit definition parameters */
     
    367383#endif
    368384#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
    370390#endif
    371391
     
    398418  m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
    399419  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
    400452
    401453
     
    458510
    459511#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  }
    474552#endif
    475553
     
    555633                                      LOG2_DISP_PREC_LUT
    556634#if POZNAN_NONLINEAR_DEPTH                                     
    557                                       ,m_fDepthPower
     635                                      ,(m_bUseNonlinearDepth ? &m_cNonlinearDepthModel : NULL)
    558636#endif
    559637                                      );
     
    572650                                      LOG2_DISP_PREC_LUT
    573651#if POZNAN_NONLINEAR_DEPTH                                     
    574                                       ,m_fDepthPower
     652                                      ,(m_bUseNonlinearDepth ? &m_cNonlinearDepthModel : NULL)
    575653#endif                                     
    576654                                      );
     
    589667    LOG2_DISP_PREC_LUT
    590668#if POZNAN_NONLINEAR_DEPTH                                     
    591     ,m_fDepthPower
     669    ,(m_bUseNonlinearDepth ? &m_cNonlinearDepthModel : NULL)
    592670#endif   
    593671    );
     
    605683    LOG2_DISP_PREC_LUT
    606684#if POZNAN_NONLINEAR_DEPTH                                     
    607     ,m_fDepthPower
     685    ,(m_bUseNonlinearDepth ? &m_cNonlinearDepthModel : NULL)
    608686#endif   
    609687    );
     
    10641142#endif
    10651143#if POZNAN_NONLINEAR_DEPTH
    1066   printf("DepthPower:%f ", m_fDepthPower);
     1144  printf("NLDR:%d ", m_bUseNonlinearDepth ? 1 : 0);
    10671145#endif
    10681146  printf("\n");
  • branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncCfg.h

    r28 r41  
    8181  Bool      m_bUsingDepthMaps ;
    8282
     83#if FLEX_CODING_ORDER
     84  char*         m_pchMVCJointCodingOrder;               ///<  texture-depth coding order
     85  Bool          m_b3DVFlexOrder;                ///<  flexible coding order flag
     86#endif
     87
    8388
    8489  // coding structure
     
    290295
    291296#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;
    293301#endif
    294302
  • branches/0.3-poznan-univ/source/App/TAppEncoder/TAppEncTop.cpp

    r30 r41  
    142142
    143143#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 );
    145146#endif
    146147
     
    256257    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    257258    {
     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
    258282      m_iDepthFrameRcvdVector.push_back(0) ;
    259283      m_acTEncDepthTopList.push_back(new TEncTop);
     
    375399      m_acTEncDepthTopList[iViewIdx]->setUseDMM( m_bUseDMM );
    376400#endif
     401#if FLEX_CODING_ORDER && HHI_DMM_PRED_TEX
     402      m_acTEncDepthTopList[iViewIdx]->setUseDMM34( (m_b3DVFlexOrder && isDepthFirst) ? false : m_bUseDMM );
     403#endif
    377404#if CONSTRAINED_INTRA_PRED
    378405      m_acTEncDepthTopList[iViewIdx]->setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
     
    401428#endif
    402429#if HHI_MPI
     430#if FLEX_CODING_ORDER
     431      m_acTEncDepthTopList[iViewIdx]->setUseMVI( (m_b3DVFlexOrder && isDepthFirst) ? false : m_bUseMVI );
     432#else
    403433      m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI );
     434#endif
    404435#endif
    405436#if POZNAN_DBMP
     
    407438#endif
    408439#if POZNAN_ENCODE_ONLY_DISOCCLUDED_CU
    409             m_acTEncDepthTopList[iViewIdx]->setUseCUSkip                      ( m_uiUseCUSkip );
     440            m_acTEncDepthTopList[iViewIdx]->setUseCUSkip                   ( m_uiUseCUSkip );
    410441#endif
    411442#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 );
    413445#endif
    414446
     
    690722          m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcPdmDepthOrg, m_aiPad, m_bUsingDepthMaps );
    691723#if POZNAN_NONLINEAR_DEPTH
    692                       pcPdmDepthOrg->nonlinearDepthForward(pcPdmDepthOrg, m_fDepthPower);                 
     724          if( m_bUseNonlinearDepth )
     725            pcPdmDepthOrg->nonlinearDepthForward(pcPdmDepthOrg, m_cNonlinearDepthModel);                 
    693726#endif
    694727        }
     
    714747          m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcDepthPicYuvOrg, m_aiPad  ) ;
    715748#if POZNAN_NONLINEAR_DEPTH
    716                       pcDepthPicYuvOrg->nonlinearDepthForward(pcDepthPicYuvOrg, m_fDepthPower);           
     749          if( m_bUseNonlinearDepth )
     750            pcDepthPicYuvOrg->nonlinearDepthForward(pcDepthPicYuvOrg, m_cNonlinearDepthModel);           
    717751#endif
    718752          bDepthEos[iViewIdx] = ( m_acTVideoIOYuvDepthInputFileList[iViewIdx]->isEof() == 1 ?   true : false  );
     
    744778#endif
    745779
     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
    746847    //GT: Encode
    747848    for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )     // Start encoding
     
    755856            //*
    756857#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
    757864      if(m_bUseTexDqpAccordingToDepth)
     865#endif
    758866      {
    759867        xStoreDepthSynthPicsInBuffer(iViewIdx);
     
    798906      }
    799907    }
    800 
     908#if FLEX_CODING_ORDER
     909    }
     910#endif
    801911    // delete extra picture buffers
    802912    if( bCurrPocCoded )
     
    10041114    riNextPocToDump++;
    10051115#if POZNAN_NONLINEAR_DEPTH
    1006     if(isDepth)
     1116    if(isDepth && m_bUseNonlinearDepth)
    10071117    {
    10081118      TComPicYuv *pcPicOrg = i->second;
     
    10111121      pcPicPow->create( pcPicOrg->getWidth(), pcPicOrg->getHeight(), pcPicOrg->getMaxCuWidth(), pcPicOrg->getMaxCuHeight(), pcPicOrg->getMaxCuDepth() );
    10121122      //cPicPower.create(pcSPS->getWidth(), pcSPS->getHeight(), pcSPS->getMaxCUWidth(), pcSPS->getMaxCUHeight(), pcSPS->getMaxCUDepth() );
    1013       pcPicOrg->nonlinearDepthBackward(pcPicPow, m_fDepthPower);               
     1123      pcPicOrg->nonlinearDepthBackward(pcPicPow, m_cNonlinearDepthModel);               
    10141124      rpcTVideoIOYuvReconFile->write( pcPicPow, m_aiPad );
    10151125// to do destroy pcPicow
Note: See TracChangeset for help on using the changeset viewer.