Changeset 54 in SHVCSoftware for branches/HM-10.0-dev-SHM/source/App/TAppEncoder


Ignore:
Timestamp:
2 Mar 2013, 09:25:00 (12 years ago)
Author:
seregin
Message:

port simulcast

Location:
branches/HM-10.0-dev-SHM/source/App/TAppEncoder
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/HM-10.0-dev-SHM/source/App/TAppEncoder/TAppEncCfg.cpp

    r51 r54  
    6363// ====================================================================================================================
    6464
     65#if SVC_EXTENSION
     66TAppEncCfg::TAppEncCfg()
     67: m_pBitstreamFile()
     68, m_pColumnWidth()
     69, m_pRowHeight()
     70, m_scalingListFile()
     71#if REF_IDX_FRAMEWORK
     72, m_elRapSliceBEnabled(0)
     73#endif
     74{
     75  for(UInt layer=0; layer<MAX_LAYERS; layer++)
     76  {
     77    m_acLayerCfg[layer].setAppEncCfg(this);
     78  }
     79}
     80#else
    6581TAppEncCfg::TAppEncCfg()
    6682: m_pchInputFile()
     
    7490  m_aidQP = NULL;
    7591}
     92#endif
    7693
    7794TAppEncCfg::~TAppEncCfg()
    7895{
     96#if !SVC_EXTENSION
    7997  if ( m_aidQP )
    8098  {
     
    82100  }
    83101  free(m_pchInputFile);
    84   free(m_pchBitstreamFile);
     102#endif
     103  free(m_pBitstreamFile);
     104#if !SVC_EXTENSION 
    85105  free(m_pchReconFile);
    86106  free(m_pchdQPFile);
     107#endif
    87108  free(m_pColumnWidth);
    88109  free(m_pRowHeight);
     
    141162  return in;
    142163}
     164
     165#if SVC_EXTENSION
     166void TAppEncCfg::getDirFilename(string& filename, string& dir, const string path)
     167{
     168  size_t pos = path.find_last_of("\\");
     169  if(pos != std::string::npos)
     170  {
     171    filename.assign(path.begin() + pos + 1, path.end());
     172    dir.assign(path.begin(), path.begin() + pos + 1);
     173  }
     174  else
     175  {
     176    pos = path.find_last_of("/");
     177    if(pos != std::string::npos)
     178    {
     179      filename.assign(path.begin() + pos + 1, path.end());
     180      dir.assign(path.begin(), path.begin() + pos + 1);
     181    }
     182    else
     183    {
     184      filename = path;
     185      dir.assign("");
     186    }
     187  }
     188}
     189#endif
    143190
    144191static const struct MapStrToProfile {
     
    231278  Bool do_help = false;
    232279 
     280#if SVC_EXTENSION
     281  string  cfg_LayerCfgFile  [MAX_LAYERS];
     282  string  cfg_BitstreamFile;
     283  string* cfg_InputFile     [MAX_LAYERS];
     284  string* cfg_ReconFile     [MAX_LAYERS];
     285  Double* cfg_fQP           [MAX_LAYERS];
     286
     287  Int*    cfg_SourceWidth   [MAX_LAYERS];
     288  Int*    cfg_SourceHeight  [MAX_LAYERS];
     289  Int*    cfg_FrameRate     [MAX_LAYERS];
     290  Int*    cfg_IntraPeriod   [MAX_LAYERS];
     291  Int*    cfg_conformanceMode  [MAX_LAYERS];
     292  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
     293  {
     294    cfg_InputFile[layer]    = &m_acLayerCfg[layer].m_cInputFile;
     295    cfg_ReconFile[layer]    = &m_acLayerCfg[layer].m_cReconFile;
     296    cfg_fQP[layer]          = &m_acLayerCfg[layer].m_fQP;
     297    cfg_SourceWidth[layer]  = &m_acLayerCfg[layer].m_iSourceWidth;
     298    cfg_SourceHeight[layer] = &m_acLayerCfg[layer].m_iSourceHeight;
     299    cfg_FrameRate[layer]    = &m_acLayerCfg[layer].m_iFrameRate;
     300    cfg_IntraPeriod[layer]  = &m_acLayerCfg[layer].m_iIntraPeriod;
     301    cfg_conformanceMode[layer] = &m_acLayerCfg[layer].m_conformanceMode;
     302  }
     303#if AVC_SYNTAX
     304  string  cfg_BLSyntaxFile;
     305#endif
     306#else
    233307  string cfg_InputFile;
    234308  string cfg_BitstreamFile;
    235309  string cfg_ReconFile;
    236310  string cfg_dQPFile;
     311#endif
    237312  string cfg_ColumnWidth;
    238313  string cfg_RowHeight;
     
    252327 
    253328  // File, I/O and source parameters
     329#if SVC_EXTENSION
     330  ("InputFile%d,-i%d",        cfg_InputFile,  string(""), MAX_LAYERS, "original YUV input file name for layer %d")
     331  ("ReconFile%d,-o%d",        cfg_ReconFile,  string(""), MAX_LAYERS, "reconstruction YUV input file name for layer %d")
     332  ("LayerConfig%d,-lc%d",     cfg_LayerCfgFile, string(""), MAX_LAYERS, "layer %d configuration file name")
     333  ("SourceWidth%d,-wdt%d",    cfg_SourceWidth, 0, MAX_LAYERS, "Source picture width for layer %d")
     334  ("SourceHeight%d,-hgt%d",   cfg_SourceHeight, 0, MAX_LAYERS, "Source picture height for layer %d")
     335  ("FrameRate%d,-fr%d",       cfg_FrameRate,  0, MAX_LAYERS, "Frame rate for layer %d")
     336  ("LambdaModifier%d,-LM%d",  m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d")
     337  ("NumLayers",               m_numLayers, 1, "Number of layers to code")
     338  ("ConformanceMode%d",       cfg_conformanceMode,0, MAX_LAYERS, "Window conformance mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
     339
     340  ("BitstreamFile,b",       cfg_BitstreamFile, string(""), "Bitstream output file name")
     341  ("InputBitDepth",         m_inputBitDepthY,    8, "Bit-depth of input file")
     342  ("OutputBitDepth",        m_outputBitDepthY,   0, "Bit-depth of output file (default:InternalBitDepth)")
     343  ("InternalBitDepth",      m_internalBitDepthY, 0, "Bit-depth the codec operates at. (default:InputBitDepth)"
     344                                                       "If different to InputBitDepth, source data will be converted")
     345  ("InputBitDepthC",        m_inputBitDepthC,    0, "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
     346  ("OutputBitDepthC",       m_outputBitDepthC,   0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
     347  ("InternalBitDepthC",     m_internalBitDepthC, 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)")
     348
     349#if AVC_BASE
     350  ("InputBLFile,-ibl",        *cfg_InputFile[0],     string(""), "Base layer rec YUV input file name")
     351#if AVC_SYNTAX
     352  ("InputBLSyntaxFile,-ibs",  cfg_BLSyntaxFile,     string(""), "Base layer syntax input file name")
     353#endif
     354#endif
     355#if REF_IDX_FRAMEWORK
     356  ("EnableElRapB,-use-rap-b",  m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture_")
     357#endif 
     358#else 
    254359  ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
    255360  ("BitstreamFile,b",       cfg_BitstreamFile, string(""), "Bitstream output file name")
     
    272377  ("ConfBottom",            m_confBottom,          0, "Bottom offset for window conformance mode 3")
    273378  ("FrameRate,-fr",         m_iFrameRate,          0, "Frame rate")
     379#endif
    274380  ("FrameSkip,-fs",         m_FrameSkip,          0u, "Number of frames to skip at start of input YUV")
    275381  ("FramesToBeEncoded,f",   m_framesToBeEncoded,   0, "Number of frames to be encoded (default=all)")
     
    286392  ("FrameOnly",         m_frameOnlyConstraintFlag, false, "Indicate that the bitstream contains only frames")
    287393#endif
    288  
     394
    289395  // Unit definition parameters
    290396  ("MaxCUWidth",              m_uiMaxCUWidth,             64u)
     
    302408 
    303409  // Coding structure paramters
     410#if SVC_EXTENSION
     411  ("IntraPeriod%d,-ip%d",  cfg_IntraPeriod, -1, MAX_LAYERS, "intra period in frames for layer %d, (-1: only first frame)")
     412#else
    304413  ("IntraPeriod,-ip",         m_iIntraPeriod,              -1, "Intra period in frames, (-1: only first frame)")
     414#endif
    305415  ("DecodingRefreshType,-dr", m_iDecodingRefreshType,       0, "Intra refresh type (0:none 1:CRA 2:IDR)")
    306416  ("GOPSize,g",               m_iGOPSize,                   1, "GOP size of temporal structure")
     
    313423  ("ASR",                     m_bUseASR,                false, "Adaptive motion search range")
    314424
     425#if SVC_EXTENSION
     426  ("LambdaModifier%d,-LM%d",  m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d")
     427#else
    315428  // Mode decision parameters
    316429  ("LambdaModifier0,-LM0", m_adLambdaModifier[ 0 ], ( Double )1.0, "Lambda modifier for temporal layer 0")
     
    322435  ("LambdaModifier6,-LM6", m_adLambdaModifier[ 6 ], ( Double )1.0, "Lambda modifier for temporal layer 6")
    323436  ("LambdaModifier7,-LM7", m_adLambdaModifier[ 7 ], ( Double )1.0, "Lambda modifier for temporal layer 7")
     437#endif
    324438
    325439  /* Quantization parameters */
     440#if SVC_EXTENSION
     441  ("QP%d,-q%d",     cfg_fQP,  30.0, MAX_LAYERS, "Qp value for layer %d, if value is float, QP is switched once during encoding")
     442#else
    326443  ("QP,q",          m_fQP,             30.0, "Qp value, if value is float, QP is switched once during encoding")
     444#endif
    327445  ("DeltaQpRD,-dqr",m_uiDeltaQpRD,       0u, "max dQp offset for slice")
    328446  ("MaxDeltaQP,d",  m_iMaxDeltaQP,        0, "max dQp offset for block")
     
    338456  ("AdaptiveQP,-aq",                m_bUseAdaptiveQP,           false, "QP adaptation based on a psycho-visual model")
    339457  ("MaxQPAdaptationRange,-aqr",     m_iQPAdaptationRange,           6, "QP adaptation range")
     458#if !SVC_EXTENSION
    340459  ("dQPFile,m",                     cfg_dQPFile,           string(""), "dQP file name")
     460#endif
    341461  ("RDOQ",                          m_useRDOQ,                  true )
    342462  ("RDOQTS",                        m_useRDOQTS,                true )
     
    526646   */
    527647  /* convert std::string to c string for compatability */
     648#if SVC_EXTENSION
     649  m_pBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
     650#if AVC_SYNTAX
     651  m_BLSyntaxFile = cfg_BLSyntaxFile.empty() ? NULL : strdup(cfg_BLSyntaxFile.c_str());
     652#endif
     653#else
    528654  m_pchInputFile = cfg_InputFile.empty() ? NULL : strdup(cfg_InputFile.c_str());
    529   m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
     655  m_phBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
    530656  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
    531657  m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
    532  
     658#endif 
     659
    533660  Char* pColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str());
    534661  Char* pRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
     
    605732  if (!m_outputBitDepthC) { m_outputBitDepthC = m_internalBitDepthC; }
    606733
     734#if !SVC_EXTENSION
    607735  // TODO:ChromaFmt assumes 4:2:0 below
    608736  switch (m_conformanceMode)
     
    702830  }
    703831  m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
    704 
     832#endif
    705833  // check validity of input parameters
    706834  xCheckParameter();
     
    800928  xConfirmPara( m_inputBitDepthY < 8,                                                     "InputBitDepth must be at least 8" );
    801929  xConfirmPara( m_inputBitDepthC < 8,                                                     "InputBitDepthC must be at least 8" );
     930#if !SVC_EXTENSION 
    802931  xConfirmPara( m_iFrameRate <= 0,                                                          "Frame rate must be more than 1" );
     932#endif
    803933  xConfirmPara( m_framesToBeEncoded <= 0,                                                   "Total Number Of Frames encoded must be more than 0" );
    804934  xConfirmPara( m_iGOPSize < 1 ,                                                            "GOP Size must be greater or equal to 1" );
    805935  xConfirmPara( m_iGOPSize > 1 &&  m_iGOPSize % 2,                                          "GOP Size must be a multiple of 2, if GOP Size is greater than 1" );
     936#if !SVC_EXTENSION
    806937  xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" );
     938#endif
    807939  xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2,                   "Decoding Refresh Type must be equal to 0, 1 or 2" );
     940#if !SVC_EXTENSION
    808941  xConfirmPara( m_iQP <  -6 * (m_internalBitDepthY - 8) || m_iQP > 51,                    "QP exceeds supported range (-QpBDOffsety to 51)" );
     942#endif
    809943  xConfirmPara( m_loopFilterBetaOffsetDiv2 < -13 || m_loopFilterBetaOffsetDiv2 > 13,          "Loop Filter Beta Offset div. 2 exceeds supported range (-13 to 13)");
    810944  xConfirmPara( m_loopFilterTcOffsetDiv2 < -13 || m_loopFilterTcOffsetDiv2 > 13,              "Loop Filter Tc Offset div. 2 exceeds supported range (-13 to 13)");
     
    821955
    822956  xConfirmPara( m_iQPAdaptationRange <= 0,                                                  "QP Adaptation Range must be more than 0" );
     957#if !SVC_EXTENSION
    823958  if (m_iDecodingRefreshType == 2)
    824959  {
    825960    xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
    826961  }
     962#endif
    827963  xConfirmPara( (m_uiMaxCUWidth  >> m_uiMaxCUDepth) < 4,                                    "Minimum partition width size should be larger than or equal to 8");
    828964  xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4,                                    "Minimum partition height size should be larger than or equal to 8");
    829965  xConfirmPara( m_uiMaxCUWidth < 16,                                                        "Maximum partition width size should be larger than or equal to 16");
    830966  xConfirmPara( m_uiMaxCUHeight < 16,                                                       "Maximum partition height size should be larger than or equal to 16");
     967#if !SVC_EXTENSION
    831968  xConfirmPara( (m_iSourceWidth  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame width must be a multiple of the minimum CU size");
    832969  xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame height must be a multiple of the minimum CU size");
     970#endif
    833971 
    834972  xConfirmPara( m_uiQuadtreeTULog2MinSize < 2,                                        "QuadtreeTULog2MinSize must be 2 or greater.");
     
    849987  xConfirmPara(  m_maxNumMergeCand > 5,  "MaxNumMergeCand must be 5 or smaller.");
    850988
     989#if !SVC_EXTENSION
    851990#if ADAPTIVE_QP_SELECTION
    852991  xConfirmPara( m_bUseAdaptQpSelect == true && m_iQP < 0,                                              "AdaptiveQpSelection must be disabled when QP < 0.");
    853992  xConfirmPara( m_bUseAdaptQpSelect == true && (m_cbQpOffset !=0 || m_crQpOffset != 0 ),               "AdaptiveQpSelection must be disabled when ChromaQpOffset is not equal to 0.");
     993#endif
    854994#endif
    855995
     
    8771017
    8781018  //TODO:ChromaFmt assumes 4:2:0 below
     1019#if !SVC_EXTENSION
    8791020  xConfirmPara( m_iSourceWidth  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
    8801021  xConfirmPara( m_iSourceHeight % TComSPS::getWinUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
     
    8871028  xConfirmPara( m_confTop    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
    8881029  xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
    889 
     1030#endif
     1031
     1032#if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV
     1033  xConfirmPara( REF_IDX_ME_AROUND_ZEROMV && REF_IDX_ME_ZEROMV, "REF_IDX_ME_AROUND_ZEROMV and REF_IDX_ME_ZEROMV cannot be enabled simultaneously");
     1034#endif
    8901035  // max CU width and height should be power of 2
    8911036  UInt ui = m_uiMaxCUWidth;
     
    9041049  }
    9051050
     1051
    9061052  /* if this is an intra-only sequence, ie IntraPeriod=1, don't verify the GOP structure
    9071053   * This permits the ability to omit a GOP structure specification */
     1054#if SVC_EXTENSION
     1055  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
     1056  {
     1057    Int m_iIntraPeriod = m_acLayerCfg[layer].m_iIntraPeriod;
     1058#endif
    9081059  if (m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1) {
    9091060    m_GOPList[0] = GOPEntry();
     
    9141065    m_GOPList[0].m_numRefPicsActive = 4;
    9151066  }
     1067#if SVC_EXTENSION
     1068  }
     1069#endif
    9161070 
    9171071  Bool verifiedGOP=false;
     
    9271081  }
    9281082  Int numOK=0;
     1083#if !SVC_EXTENSION
    9291084  xConfirmPara( m_iIntraPeriod >=0&&(m_iIntraPeriod%m_iGOPSize!=0), "Intra period must be a multiple of GOPSize, or -1" );
     1085#endif
    9301086
    9311087  for(Int i=0; i<m_iGOPSize; i++)
     
    9361092    }
    9371093  }
    938  
     1094
     1095#if SVC_EXTENSION
     1096  // verify layer configuration parameters
     1097  for(UInt layer=0; layer<m_numLayers; layer++)
     1098  {
     1099    if(m_acLayerCfg[layer].xCheckParameter())
     1100    {
     1101      printf("\nError: invalid configuration parameter found in layer %d \n", layer);
     1102      check_failed = true;
     1103    }
     1104  }
     1105#endif 
     1106
     1107#if SVC_EXTENSION
     1108  // verify layer configuration parameters
     1109  for(UInt layer=0; layer<m_numLayers; layer++)
     1110  {
     1111    Int m_iIntraPeriod = m_acLayerCfg[layer].m_iIntraPeriod;
     1112#endif
    9391113  if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable) )
    9401114  {
     
    9451119    }
    9461120  }
     1121#if SVC_EXTENSION
     1122  }
     1123#endif
     1124
    9471125  m_extraRPSs=0;
    9481126  //start looping through frames in coding order until we can verify that the GOP structure is correct.
     
    12061384  }
    12071385
     1386#if SVC_EXTENSION // ToDo: it should be checked for the case when parameters are different for the layers
     1387  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
     1388  {
     1389    Int m_iSourceWidth = m_acLayerCfg[layer].m_iSourceWidth;
     1390    Int m_iSourceHeight = m_acLayerCfg[layer].m_iSourceHeight;
     1391#endif
    12081392  if(m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag)
    12091393  {
     
    12791463    }
    12801464  }
     1465#if SVC_EXTENSION
     1466  }
     1467#endif
     1468
    12811469  xConfirmPara( m_bUseLComb==false && m_numReorderPics[MAX_TLAYER-1]!=0, "ListCombination can only be 0 in low delay coding (more precisely when L0 and L1 are identical)" );  // Note however this is not the full necessary condition as ref_pic_list_combination_flag can only be 0 if L0 == L1.
    12821470  xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
     1471#if !SVC_EXTENSION
    12831472  xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" );
    12841473  xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_iWaveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" );
     1474#endif
    12851475
    12861476  xConfirmPara( m_decodedPictureHashSEIEnabled<0 || m_decodedPictureHashSEIEnabled>3, "this hash type is not correct!\n");
     
    13571547{
    13581548  printf("\n");
     1549#if SVC_EXTENSION 
     1550  printf("Total number of layers        : %d\n", m_numLayers            );
     1551  for(UInt layer=0; layer<m_numLayers; layer++)
     1552  {
     1553    printf("=== Layer %d settings === \n", layer);
     1554    m_acLayerCfg[layer].xPrintParameter();
     1555    printf("\n");
     1556  }
     1557  printf("=== Common configuration settings === \n");
     1558  printf("Bitstream      File          : %s\n", m_pBitstreamFile      );
     1559#else
    13591560  printf("Input          File          : %s\n", m_pchInputFile          );
    13601561  printf("Bitstream      File          : %s\n", m_pchBitstreamFile      );
     
    13621563  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
    13631564  printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
     1565#endif
    13641566  printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
    13651567  printf("CU size / depth              : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth );
     
    13691571  printf("Min PCM size                 : %d\n", 1 << m_uiPCMLog2MinSize);
    13701572  printf("Motion search range          : %d\n", m_iSearchRange );
     1573#if !SVC_EXTENSION
    13711574  printf("Intra period                 : %d\n", m_iIntraPeriod );
     1575#endif
    13721576  printf("Decoding refresh type        : %d\n", m_iDecodingRefreshType );
     1577#if !SVC_EXTENSION
    13731578  printf("QP                           : %5.2f\n", m_fQP );
     1579#endif
    13741580  printf("Max dQP signaling depth      : %d\n", m_iMaxCuDQPDepth);
    13751581
     
    14421648  printf("WPB:%d ", (Int)m_useWeightedBiPred);
    14431649  printf("PME:%d ", m_log2ParallelMergeLevel);
     1650#if !SVC_EXTENSION
    14441651  printf(" WaveFrontSynchro:%d WaveFrontSubstreams:%d",
    14451652          m_iWaveFrontSynchro, m_iWaveFrontSubstreams);
     1653#endif
    14461654  printf(" ScalingList:%d ", m_useScalingListId );
    14471655  printf("TMVPMode:%d ", m_TMVPModeId     );
     
    14511659
    14521660  printf(" SignBitHidingFlag:%d ", m_signHideFlag);
     1661#if SVC_EXTENSION
     1662  printf("RecalQP:%d ", m_recalculateQPAccordingToLambda ? 1 : 0 );
     1663  printf("AVC_BASE:%d ", AVC_BASE);
     1664#if REF_IDX_FRAMEWORK
     1665  printf("REF_IDX_FRAMEWORK:%d ", REF_IDX_FRAMEWORK);
     1666  printf("EL_RAP_SliceType: %d ", m_elRapSliceBEnabled);
     1667  printf("REF_IDX_ME_AROUND_ZEROMV:%d ", REF_IDX_ME_AROUND_ZEROMV);
     1668  printf("REF_IDX_ME_ZEROMV: %d", REF_IDX_ME_ZEROMV);
     1669#elif INTRA_BL
     1670  printf("INTRA_BL:%d ", INTRA_BL);
     1671#if !AVC_BASE
     1672  printf("SVC_MVP:%d ", SVC_MVP );
     1673  printf("SVC_BL_CAND_INTRA:%d", SVC_BL_CAND_INTRA );
     1674#endif
     1675#endif
     1676#else
    14531677  printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 );
     1678#endif
    14541679  printf("\n\n");
    14551680 
  • branches/HM-10.0-dev-SHM/source/App/TAppEncoder/TAppEncCfg.h

    r51 r54  
    4242
    4343#include "TLibEncoder/TEncCfg.h"
     44#if SVC_EXTENSION
     45#include "TAppEncLayerCfg.h"
     46#endif
    4447#include <sstream>
    4548//! \ingroup TAppEncoder
     
    5558protected:
    5659  // file I/O
     60#if SVC_EXTENSION
     61  TAppEncLayerCfg m_acLayerCfg [MAX_LAYERS];
     62  Int       m_numLayers;                                     ///< number of layers
     63
     64  Char*     m_pBitstreamFile;                                 ///< output bitstream file
     65  Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
     66  // source specification
     67  UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
     68  Int       m_framesToBeEncoded;                              ///< number of encoded frames
     69#if AVC_SYNTAX
     70  char*     m_BLSyntaxFile;                                   ///< input syntax file
     71#endif
     72#else
    5773  Char*     m_pchInputFile;                                   ///< source file name
    5874  Char*     m_pchBitstreamFile;                               ///< output bitstream file
     
    7187  Int       m_framesToBeEncoded;                              ///< number of encoded frames
    7288  Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
    73  
     89#endif 
     90
    7491  // profile/level
    7592  Profile::Name m_profile;
     
    84101 
    85102  // coding structure
     103#if !SVC_EXTENSION
    86104  Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
     105#endif
    87106  Int       m_iDecodingRefreshType;                           ///< random access type
    88107  Int       m_iGOPSize;                                       ///< GOP size of hierarchical structure
     
    96115  Bool      m_enableAMP;
    97116  // coding quality
     117#if !SVC_EXTENSION
    98118  Double    m_fQP;                                            ///< QP value of key-picture (floating point)
    99119  Int       m_iQP;                                            ///< QP value of key-picture (integer)
    100120  Char*     m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
    101121  Int*      m_aidQP;                                          ///< array of slice QP values
     122#endif
    102123  Int       m_iMaxDeltaQP;                                    ///< max. |delta QP|
    103124  UInt      m_uiDeltaQpRD;                                    ///< dQP range for multi-pass slice QP optimization
     
    192213  UInt*     m_pRowHeight;
    193214  Int       m_iWaveFrontSynchro; //< 0: no WPP. >= 1: WPP is enabled, the "Top right" from which inheritance occurs is this LCU offset in the line above the current.
     215#if !SVC_EXTENSION
    194216  Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
     217#endif
    195218
    196219  Bool      m_bUseConstrainedIntraPred;                       ///< flag for using constrained intra prediction
     
    276299  Int       m_log2MaxMvLengthVertical;                        ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units
    277300
     301#if REF_IDX_FRAMEWORK
     302  Int       m_elRapSliceBEnabled;
     303#endif
    278304  // internal member functions
    279305  Void  xSetGlobal      ();                                   ///< set global variables
     
    300326  Bool  parseCfg  ( Int argc, Char* argv[] );                 ///< parse configuration file to fill member variables
    301327 
     328#if SVC_EXTENSION
     329  Int  getNumFrameToBeEncoded()    {return m_framesToBeEncoded; }
     330  Int  getNumLayer()               {return m_numLayers;        }
     331  Int  getGOPSize()                {return m_iGOPSize;          }
     332  UInt getInternalBitDepthY()      {return m_internalBitDepthY; }
     333  UInt getInternalBitDepthC()      {return m_internalBitDepthC; }
     334  UInt getMaxCUWidth()             {return m_uiMaxCUWidth;      }
     335  UInt getMaxCUHeight()            {return m_uiMaxCUHeight;     }
     336  UInt getMaxCUDepth()             {return m_uiMaxCUDepth;      }
     337  Int  getDecodingRefreshType()    {return m_iDecodingRefreshType; }
     338  Int  getWaveFrontSynchro()        { return m_iWaveFrontSynchro; }
     339  Void getDirFilename(string& filename, string& dir, const string path);
     340#if AVC_SYNTAX
     341  Char* getBLSyntaxFile()           { return m_BLSyntaxFile;      }
     342#endif
     343#endif
    302344};// END CLASS DEFINITION TAppEncCfg
    303345
  • branches/HM-10.0-dev-SHM/source/App/TAppEncoder/TAppEncTop.cpp

    r51 r54  
    11/* The copyright in this software is being made available under the BSD
    2  * License, included below. This software may be subject to other third party
    3  * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
    5  *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
    7  * All rights reserved.
    8  *
    9  * Redistribution and use in source and binary forms, with or without
    10  * modification, are permitted provided that the following conditions are met:
    11  *
    12  *  * Redistributions of source code must retain the above copyright notice,
    13  *    this list of conditions and the following disclaimer.
    14  *  * Redistributions in binary form must reproduce the above copyright notice,
    15  *    this list of conditions and the following disclaimer in the documentation
    16  *    and/or other materials provided with the distribution.
    17  *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    18  *    be used to endorse or promote products derived from this software without
    19  *    specific prior written permission.
    20  *
    21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
    25  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
    31  * THE POSSIBILITY OF SUCH DAMAGE.
    32  */
     2* License, included below. This software may be subject to other third party
     3* and contributor rights, including patent rights, and no such rights are
     4* granted under this license. 
     5*
     6* Copyright (c) 2010-2013, ITU/ISO/IEC
     7* All rights reserved.
     8*
     9* Redistribution and use in source and binary forms, with or without
     10* modification, are permitted provided that the following conditions are met:
     11*
     12*  * Redistributions of source code must retain the above copyright notice,
     13*    this list of conditions and the following disclaimer.
     14*  * Redistributions in binary form must reproduce the above copyright notice,
     15*    this list of conditions and the following disclaimer in the documentation
     16*    and/or other materials provided with the distribution.
     17*  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
     18*    be used to endorse or promote products derived from this software without
     19*    specific prior written permission.
     20*
     21* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     22* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
     25* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     31* THE POSSIBILITY OF SUCH DAMAGE.
     32*/
    3333
    3434/** \file     TAppEncTop.cpp
    35     \brief    Encoder application class
     35\brief    Encoder application class
    3636*/
    3737
     
    6060  m_totalBytes = 0;
    6161  m_essentialBytes = 0;
     62#if SVC_EXTENSION
     63  for(UInt layer=0; layer < MAX_LAYERS; layer++)
     64  {
     65    m_apcTEncTop[layer] = &m_acTEncTop[layer];
     66  }
     67#endif
    6268}
    6369
     
    6672}
    6773
     74#if SVC_EXTENSION
    6875Void TAppEncTop::xInitLibCfg()
    6976{
     77  for(UInt layer=0; layer<m_numLayers; layer++)
     78  {
     79    TComVPS vps;
     80
     81    vps.setMaxTLayers                       ( m_maxTempLayer );
     82    if (m_maxTempLayer == 1)
     83    {
     84      vps.setTemporalNestingFlag(true);
     85    }
     86    vps.setMaxLayers                        ( 1 );
     87    for(Int i = 0; i < MAX_TLAYER; i++)
     88    {
     89      vps.setNumReorderPics                 ( m_numReorderPics[i], i );
     90      vps.setMaxDecPicBuffering             ( m_maxDecPicBuffering[i], i );
     91    }
     92    m_acTEncTop[layer].setVPS(&vps);
     93    m_acTEncTop[layer].setFrameRate                    ( m_acLayerCfg[layer].getFrameRate() );
     94    m_acTEncTop[layer].setFrameSkip                    ( m_FrameSkip );
     95    m_acTEncTop[layer].setSourceWidth                  ( m_acLayerCfg[layer].getSourceWidth() );
     96    m_acTEncTop[layer].setSourceHeight                 ( m_acLayerCfg[layer].getSourceHeight() );
     97    m_acTEncTop[layer].setConformanceMode              ( m_acLayerCfg[layer].getConformanceMode() );
     98    m_acTEncTop[layer].setConformanceWindow            ( m_acLayerCfg[layer].m_confLeft, m_acLayerCfg[layer].m_confRight, m_acLayerCfg[layer].m_confTop, m_acLayerCfg[layer].m_confBottom );
     99    m_acTEncTop[layer].setFramesToBeEncoded            ( m_framesToBeEncoded );
     100
     101    m_acTEncTop[layer].setProfile(m_profile);
     102    m_acTEncTop[layer].setLevel(m_levelTier, m_level);
     103#if L0046_CONSTRAINT_FLAGS
     104    m_acTEncTop[layer].setProgressiveSourceFlag(m_progressiveSourceFlag);
     105    m_acTEncTop[layer].setInterlacedSourceFlag(m_interlacedSourceFlag);
     106    m_acTEncTop[layer].setNonPackedConstraintFlag(m_nonPackedConstraintFlag);
     107    m_acTEncTop[layer].setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
     108#endif
     109
     110#if REF_IDX_MFM
     111    if(layer == 0)
     112    {
     113      m_acTEncTop[layer].setMFMEnabledFlag(false);
     114    }
     115    else
     116    {
     117      m_acTEncTop[layer].setMFMEnabledFlag(true);
     118    }
     119#endif
     120    // set layer ID
     121    m_acTEncTop[layer].setLayerId ( layer );
     122    m_acTEncTop[layer].setNumLayer ( m_numLayers );
     123    m_acTEncTop[layer].setLayerEnc(m_apcTEncTop);
     124
     125    //====== Coding Structure ========
     126    m_acTEncTop[layer].setIntraPeriod                  ( m_acLayerCfg[layer].m_iIntraPeriod );
     127    m_acTEncTop[layer].setDecodingRefreshType          ( m_iDecodingRefreshType );
     128    m_acTEncTop[layer].setGOPSize                      ( m_iGOPSize );
     129    m_acTEncTop[layer].setGopList                      ( m_GOPList );
     130    m_acTEncTop[layer].setExtraRPSs                    ( m_extraRPSs );
     131    for(Int i = 0; i < MAX_TLAYER; i++)
     132    {
     133      m_acTEncTop[layer].setNumReorderPics             ( m_numReorderPics[i], i );
     134      m_acTEncTop[layer].setMaxDecPicBuffering         ( m_maxDecPicBuffering[i], i );
     135    }
     136    for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
     137    {
     138      m_acTEncTop[layer].setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
     139    }
     140    m_acTEncTop[layer].setQP                           ( m_acLayerCfg[layer].getIntQP() );
     141
     142    m_acTEncTop[layer].setPad                          ( m_acLayerCfg[layer].getPad() );
     143
     144    m_acTEncTop[layer].setMaxTempLayer                 ( m_maxTempLayer );
     145    m_acTEncTop[layer].setUseAMP( m_enableAMP );
     146
     147    //===== Slice ========
     148
     149    //====== Loop/Deblock Filter ========
     150    m_acTEncTop[layer].setLoopFilterDisable            ( m_bLoopFilterDisable       );
     151    m_acTEncTop[layer].setLoopFilterOffsetInPPS        ( m_loopFilterOffsetInPPS );
     152    m_acTEncTop[layer].setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
     153    m_acTEncTop[layer].setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
     154    m_acTEncTop[layer].setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
     155
     156    //====== Motion search ========
     157    m_acTEncTop[layer].setFastSearch                   ( m_iFastSearch  );
     158    m_acTEncTop[layer].setSearchRange                  ( m_iSearchRange );
     159    m_acTEncTop[layer].setBipredSearchRange            ( m_bipredSearchRange );
     160
     161    //====== Quality control ========
     162    m_acTEncTop[layer].setMaxDeltaQP                   ( m_iMaxDeltaQP  );
     163    m_acTEncTop[layer].setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
     164
     165    m_acTEncTop[layer].setChromaCbQpOffset             ( m_cbQpOffset     );
     166    m_acTEncTop[layer].setChromaCrQpOffset             ( m_crQpOffset  );
     167
     168#if ADAPTIVE_QP_SELECTION
     169    m_acTEncTop[layer].setUseAdaptQpSelect             ( m_bUseAdaptQpSelect   );
     170#endif
     171
     172    Int lowestQP;
     173    lowestQP =  - 6*(g_bitDepthY - 8); // XXX: check
     174
     175    if ((m_iMaxDeltaQP == 0 ) && (m_acLayerCfg[layer].getIntQP() == lowestQP) && (m_useLossless == true))
     176    {
     177      m_bUseAdaptiveQP = false;
     178    }
     179    m_acTEncTop[layer].setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
     180    m_acTEncTop[layer].setQPAdaptationRange            ( m_iQPAdaptationRange );
     181
     182    //====== Tool list ========
     183    m_acTEncTop[layer].setUseSBACRD                    ( m_bUseSBACRD   );
     184    m_acTEncTop[layer].setDeltaQpRD                    ( m_uiDeltaQpRD  );
     185    m_acTEncTop[layer].setUseASR                       ( m_bUseASR      );
     186    m_acTEncTop[layer].setUseHADME                     ( m_bUseHADME    );
     187    m_acTEncTop[layer].setUseLossless                  ( m_useLossless );
     188    m_acTEncTop[layer].setUseLComb                     ( m_bUseLComb    );
     189    m_acTEncTop[layer].setdQPs                         ( m_acLayerCfg[layer].getdQPs() );
     190    m_acTEncTop[layer].setUseRDOQ                      ( m_useRDOQ     );
     191    m_acTEncTop[layer].setUseRDOQTS                    ( m_useRDOQTS   );
     192#if L0232_RD_PENALTY
     193    m_acTEncTop[layer].setRDpenalty                    ( m_rdPenalty );
     194#endif
     195    m_acTEncTop[layer].setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
     196    m_acTEncTop[layer].setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
     197    m_acTEncTop[layer].setQuadtreeTUMaxDepthInter      ( m_uiQuadtreeTUMaxDepthInter );
     198    m_acTEncTop[layer].setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
     199    m_acTEncTop[layer].setUseFastEnc                   ( m_bUseFastEnc  );
     200    m_acTEncTop[layer].setUseEarlyCU                   ( m_bUseEarlyCU  );
     201    m_acTEncTop[layer].setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
     202    m_acTEncTop[layer].setUseCbfFastMode               ( m_bUseCbfFastMode  );
     203    m_acTEncTop[layer].setUseEarlySkipDetection        ( m_useEarlySkipDetection );
     204
     205    m_acTEncTop[layer].setUseTransformSkip             ( m_useTransformSkip      );
     206    m_acTEncTop[layer].setUseTransformSkipFast         ( m_useTransformSkipFast  );
     207    m_acTEncTop[layer].setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
     208    m_acTEncTop[layer].setPCMLog2MinSize               ( m_uiPCMLog2MinSize);
     209    m_acTEncTop[layer].setUsePCM                       ( m_usePCM );
     210    m_acTEncTop[layer].setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
     211    m_acTEncTop[layer].setMaxNumMergeCand              ( m_maxNumMergeCand );
     212
     213
     214    //====== Weighted Prediction ========
     215    m_acTEncTop[layer].setUseWP                   ( m_useWeightedPred      );
     216    m_acTEncTop[layer].setWPBiPred                ( m_useWeightedBiPred   );
     217    //====== Parallel Merge Estimation ========
     218    m_acTEncTop[layer].setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 );
     219
     220    //====== Slice ========
     221    m_acTEncTop[layer].setSliceMode               ( m_sliceMode                );
     222    m_acTEncTop[layer].setSliceArgument           ( m_sliceArgument            );
     223
     224    //====== Dependent Slice ========
     225    m_acTEncTop[layer].setSliceSegmentMode        ( m_sliceSegmentMode         );
     226    m_acTEncTop[layer].setSliceSegmentArgument    ( m_sliceSegmentArgument     );
     227    Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
     228    if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU)
     229    {
     230      m_acTEncTop[layer].setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU );
     231    }
     232    if(m_sliceMode==FIXED_NUMBER_OF_LCU)
     233    {
     234      m_acTEncTop[layer].setSliceArgument ( m_sliceArgument * iNumPartInCU );
     235    }
     236    if(m_sliceMode==FIXED_NUMBER_OF_TILES)
     237    {
     238      m_acTEncTop[layer].setSliceArgument ( m_sliceArgument );
     239    }
     240
     241    if(m_sliceMode == 0 )
     242    {
     243      m_bLFCrossSliceBoundaryFlag = true;
     244    }
     245    m_acTEncTop[layer].setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
     246    m_acTEncTop[layer].setUseSAO ( m_bUseSAO );
     247    m_acTEncTop[layer].setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
     248
     249    m_acTEncTop[layer].setSaoLcuBoundary (m_saoLcuBoundary);
     250    m_acTEncTop[layer].setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
     251    m_acTEncTop[layer].setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag);
     252    m_acTEncTop[layer].setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag);
     253
     254    m_acTEncTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     255    m_acTEncTop[layer].setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled );
     256    m_acTEncTop[layer].setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled );
     257    m_acTEncTop[layer].setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled );
     258    m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
     259    m_acTEncTop[layer].setFramePackingArrangementSEIType( m_framePackingSEIType );
     260    m_acTEncTop[layer].setFramePackingArrangementSEIId( m_framePackingSEIId );
     261    m_acTEncTop[layer].setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx );
     262    m_acTEncTop[layer].setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation );
     263    m_acTEncTop[layer].setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle );
     264    m_acTEncTop[layer].setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled );
     265    m_acTEncTop[layer].setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled );
     266    m_acTEncTop[layer].setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled );
     267    m_acTEncTop[layer].setUniformSpacingIdr          ( m_iUniformSpacingIdr );
     268    m_acTEncTop[layer].setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
     269    m_acTEncTop[layer].setNumRowsMinus1              ( m_iNumRowsMinus1 );
     270    if(m_iUniformSpacingIdr==0)
     271    {
     272      m_acTEncTop[layer].setColumnWidth              ( m_pColumnWidth );
     273      m_acTEncTop[layer].setRowHeight                ( m_pRowHeight );
     274    }
     275    m_acTEncTop[layer].xCheckGSParameters();
     276    Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
     277    if(uiTilesCount == 1)
     278    {
     279      m_bLFCrossTileBoundaryFlag = true;
     280    }
     281    m_acTEncTop[layer].setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
     282    m_acTEncTop[layer].setWaveFrontSynchro           ( m_iWaveFrontSynchro );
     283    m_acTEncTop[layer].setWaveFrontSubstreams        ( m_acLayerCfg[layer].m_iWaveFrontSubstreams );
     284    m_acTEncTop[layer].setTMVPModeId ( m_TMVPModeId );
     285    m_acTEncTop[layer].setUseScalingListId           ( m_useScalingListId  );
     286    m_acTEncTop[layer].setScalingListFile            ( m_scalingListFile   );
     287    m_acTEncTop[layer].setSignHideFlag(m_signHideFlag);
     288#if RATE_CONTROL_LAMBDA_DOMAIN
     289    m_acTEncTop[layer].setUseRateCtrl         ( m_RCEnableRateControl );
     290    m_acTEncTop[layer].setTargetBitrate       ( m_RCTargetBitrate );
     291    m_acTEncTop[layer].setKeepHierBit         ( m_RCKeepHierarchicalBit );
     292    m_acTEncTop[layer].setLCULevelRC          ( m_RCLCULevelRC );
     293    m_acTEncTop[layer].setUseLCUSeparateModel ( m_RCUseLCUSeparateModel );
     294    m_acTEncTop[layer].setInitialQP           ( m_RCInitialQP );
     295    m_acTEncTop[layer].setForceIntraQP        ( m_RCForceIntraQP );
     296#else
     297    m_acTEncTop[layer].setUseRateCtrl     ( m_enableRateCtrl);
     298    m_acTEncTop[layer].setTargetBitrate   ( m_targetBitrate);
     299    m_acTEncTop[layer].setNumLCUInUnit    ( m_numLCUInUnit);
     300#endif
     301    m_acTEncTop[layer].setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
     302    m_acTEncTop[layer].setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue);
     303    m_acTEncTop[layer].setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda );
     304    m_acTEncTop[layer].setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
     305    m_acTEncTop[layer].setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled );
     306    m_acTEncTop[layer].setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
     307    m_acTEncTop[layer].setAspectRatioIdc( m_aspectRatioIdc );
     308    m_acTEncTop[layer].setSarWidth( m_sarWidth );
     309    m_acTEncTop[layer].setSarHeight( m_sarHeight );
     310    m_acTEncTop[layer].setOverscanInfoPresentFlag( m_overscanInfoPresentFlag );
     311    m_acTEncTop[layer].setOverscanAppropriateFlag( m_overscanAppropriateFlag );
     312    m_acTEncTop[layer].setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag );
     313    m_acTEncTop[layer].setVideoFormat( m_videoFormat );
     314    m_acTEncTop[layer].setVideoFullRangeFlag( m_videoFullRangeFlag );
     315    m_acTEncTop[layer].setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag );
     316    m_acTEncTop[layer].setColourPrimaries( m_colourPrimaries );
     317    m_acTEncTop[layer].setTransferCharacteristics( m_transferCharacteristics );
     318    m_acTEncTop[layer].setMatrixCoefficients( m_matrixCoefficients );
     319    m_acTEncTop[layer].setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag );
     320    m_acTEncTop[layer].setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField );
     321    m_acTEncTop[layer].setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField );
     322    m_acTEncTop[layer].setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag );
     323    m_acTEncTop[layer].setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset );
     324    m_acTEncTop[layer].setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag );
     325    m_acTEncTop[layer].setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag );
     326    m_acTEncTop[layer].setNumTicksPocDiffOneMinus1   ( m_numTicksPocDiffOneMinus1    );
     327    m_acTEncTop[layer].setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag );
     328    m_acTEncTop[layer].setTilesFixedStructureFlag( m_tilesFixedStructureFlag );
     329    m_acTEncTop[layer].setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag );
     330    m_acTEncTop[layer].setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc );
     331    m_acTEncTop[layer].setMaxBytesPerPicDenom( m_maxBytesPerPicDenom );
     332    m_acTEncTop[layer].setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom );
     333    m_acTEncTop[layer].setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal );
     334    m_acTEncTop[layer].setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
     335#if SIGNAL_BITRATE_PICRATE_IN_VPS
     336    TComBitRatePicRateInfo *bitRatePicRateInfo = m_cTEncTop[layer].getVPS()->getBitratePicrateInfo();
     337    // The number of bit rate/pic rate have to equal to number of sub-layers.
     338    if(m_bitRatePicRateMaxTLayers)
     339    {
     340      assert(m_bitRatePicRateMaxTLayers == m_cTEncTop[layer].getVPS()->getMaxTLayers());
     341    }
     342    for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
     343    {
     344      bitRatePicRateInfo->setBitRateInfoPresentFlag( i, m_bitRateInfoPresentFlag[i] );
     345      if( bitRatePicRateInfo->getBitRateInfoPresentFlag(i) )
     346      {
     347        bitRatePicRateInfo->setAvgBitRate(i, m_avgBitRate[i]);
     348        bitRatePicRateInfo->setMaxBitRate(i, m_maxBitRate[i]);
     349      }
     350    }
     351    for(Int i = 0; i < m_bitRatePicRateMaxTLayers; i++)
     352    {
     353      bitRatePicRateInfo->setPicRateInfoPresentFlag( i, m_picRateInfoPresentFlag[i] );
     354      if( bitRatePicRateInfo->getPicRateInfoPresentFlag(i) )
     355      {
     356        bitRatePicRateInfo->setAvgPicRate     (i, m_avgPicRate[i]);
     357        bitRatePicRateInfo->setConstantPicRateIdc(i, m_constantPicRateIdc[i]);
     358      }
     359    }
     360#endif
     361#if REF_IDX_FRAMEWORK
     362    m_acTEncTop[layer].setElRapSliceTypeB(layer == 0? 0 : m_elRapSliceBEnabled);
     363#endif
     364  }
     365}
     366#else
     367Void TAppEncTop::xInitLibCfg()
     368{
    70369  TComVPS vps;
    71  
     370
    72371  vps.setMaxTLayers                       ( m_maxTempLayer );
    73372  if (m_maxTempLayer == 1)
     
    91390  m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag);
    92391#endif
    93  
     392
    94393  m_cTEncTop.setFrameRate                    ( m_iFrameRate );
    95394  m_cTEncTop.setFrameSkip                    ( m_FrameSkip );
     
    98397  m_cTEncTop.setConformanceWindow            ( m_confLeft, m_confRight, m_confTop, m_confBottom );
    99398  m_cTEncTop.setFramesToBeEncoded            ( m_framesToBeEncoded );
    100  
     399
    101400  //====== Coding Structure ========
    102401  m_cTEncTop.setIntraPeriod                  ( m_iIntraPeriod );
     
    115414  }
    116415  m_cTEncTop.setQP                           ( m_iQP );
    117  
     416
    118417  m_cTEncTop.setPad                          ( m_aiPad );
    119    
     418
    120419  m_cTEncTop.setMaxTempLayer                 ( m_maxTempLayer );
    121420  m_cTEncTop.setUseAMP( m_enableAMP );
    122  
     421
    123422  //===== Slice ========
    124  
     423
    125424  //====== Loop/Deblock Filter ========
    126425  m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable       );
     
    155454  m_cTEncTop.setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
    156455  m_cTEncTop.setQPAdaptationRange            ( m_iQPAdaptationRange );
    157  
     456
    158457  //====== Tool list ========
    159458  m_cTEncTop.setUseSBACRD                    ( m_bUseSBACRD   );
     
    186485  m_cTEncTop.setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
    187486  m_cTEncTop.setMaxNumMergeCand              ( m_maxNumMergeCand );
    188  
     487
    189488
    190489  //====== Weighted Prediction ========
     
    214513    m_cTEncTop.setSliceArgument ( m_sliceArgument );
    215514  }
    216  
     515
    217516  if(m_sliceMode == 0 )
    218517  {
     
    336635#endif
    337636}
     637#endif
    338638
    339639Void TAppEncTop::xCreateLib()
    340640{
    341641  // Video I/O
     642#if SVC_EXTENSION
     643  // initialize global variables
     644  initROM();
     645
     646  for(UInt layer=0; layer<m_numLayers; layer++)
     647  {
     648    m_acTVideoIOYuvInputFile[layer].open( (Char *)m_acLayerCfg[layer].getInputFile().c_str(),  false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
     649    m_acTVideoIOYuvInputFile[layer].skipFrames(m_FrameSkip, m_acLayerCfg[layer].getSourceWidth() - m_acLayerCfg[layer].getPad()[0], m_acLayerCfg[layer].getSourceHeight() - m_acLayerCfg[layer].getPad()[1]);
     650
     651    if (!m_acLayerCfg[layer].getReconFile().empty())
     652    {
     653      m_acTVideoIOYuvReconFile[layer].open((Char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // write mode
     654    }
     655
     656    m_acTEncTop[layer].create();
     657  }
     658#else
    342659  m_cTVideoIOYuvInputFile.open( m_pchInputFile,     false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC );  // read  mode
    343660  m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
     
    345662  if (m_pchReconFile)
    346663    m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC);  // write mode
    347  
     664
    348665  // Neo Decoder
    349666  m_cTEncTop.create();
     667#endif
    350668}
    351669
     
    353671{
    354672  // Video I/O
     673#if SVC_EXTENSION
     674  // destroy ROM
     675  destroyROM();
     676
     677  for(UInt layer=0; layer<m_numLayers; layer++)
     678  {
     679    m_acTVideoIOYuvInputFile[layer].close();
     680    m_acTVideoIOYuvReconFile[layer].close();
     681
     682    m_acTEncTop[layer].destroy();
     683  }
     684#else
    355685  m_cTVideoIOYuvInputFile.close();
    356686  m_cTVideoIOYuvReconFile.close();
    357  
     687
    358688  // Neo Decoder
    359689  m_cTEncTop.destroy();
     690#endif
    360691}
    361692
    362693Void TAppEncTop::xInitLib()
    363694{
     695#if SVC_EXTENSION
     696  for(UInt layer=0; layer<m_numLayers; layer++)
     697  {
     698    m_acTEncTop[layer].init();
     699  }
     700#else
    364701  m_cTEncTop.init();
     702#endif
    365703}
    366704
     
    370708
    371709/**
    372  - create internal class
    373  - initialize internal variable
    374  - until the end of input YUV file, call encoding function in TEncTop class
    375  - delete allocated buffers
    376  - destroy internal class
    377  .
    378  */
     710- create internal class
     711- initialize internal variable
     712- until the end of input YUV file, call encoding function in TEncTop class
     713- delete allocated buffers
     714- destroy internal class
     715.
     716*/
     717#if SVC_EXTENSION
    379718Void TAppEncTop::encode()
    380719{
    381   fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out);
     720  fstream bitstreamFile(m_pBitstreamFile, fstream::binary | fstream::out);
    382721  if (!bitstreamFile)
    383722  {
    384     fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile);
     723    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pBitstreamFile);
    385724    exit(EXIT_FAILURE);
    386725  }
    387726
    388   TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
     727  TComPicYuv*       pcPicYuvOrg [MAX_LAYERS];
    389728  TComPicYuv*       pcPicYuvRec = NULL;
    390  
     729
    391730  // initialize internal class & member variables
    392731  xInitLibCfg();
    393732  xCreateLib();
    394733  xInitLib();
    395  
     734
     735  // main encoder loop
     736  Int   iNumEncoded = 0, iTotalNumEncoded = 0;
     737  Bool  bEos = false;
     738
     739  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
     740
     741  for(UInt layer=0; layer<m_numLayers; layer++)
     742  {
     743    // allocate original YUV buffer
     744    pcPicYuvOrg[layer] = new TComPicYuv;
     745#if SVC_UPSAMPLING
     746    pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     747#else
     748    pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     749#endif
     750  }
     751
     752#if AVC_SYNTAX
     753  if( !m_BLSyntaxFile )
     754  {
     755    printf( "Wrong base layer syntax input file\n" );
     756    exit(EXIT_FAILURE);
     757  }
     758  fstream streamSyntaxFile( m_BLSyntaxFile, fstream::in | fstream::binary );
     759  if( !streamSyntaxFile.good() )
     760  {
     761    printf( "Base layer syntax input reading error\n" );
     762    exit(EXIT_FAILURE);
     763  }
     764  m_acTEncTop[0].setBLSyntaxFile( &streamSyntaxFile );
     765#endif
     766
     767  Bool bFirstFrame = true;
     768  while ( !bEos )
     769  {
     770    // Read enough frames
     771    Bool bFramesReadyToCode = false;
     772    while(!bFramesReadyToCode)
     773    {
     774      for(UInt layer=0; layer<m_numLayers; layer++)
     775      {
     776        // get buffers
     777        xGetBuffer(pcPicYuvRec, layer);
     778
     779        // read input YUV file
     780        m_acTVideoIOYuvInputFile[layer].read( pcPicYuvOrg[layer], m_acLayerCfg[layer].getPad() );
     781
     782        if(layer == m_numLayers-1)
     783        {
     784          // increase number of received frames
     785          m_iFrameRcvd++;
     786          // check end of file
     787          bEos = (m_iFrameRcvd == m_framesToBeEncoded);
     788        }
     789
     790        m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] );
     791      }
     792
     793      bFramesReadyToCode = !(!bFirstFrame && ( m_acTEncTop[m_numLayers-1].getNumPicRcvd() != m_iGOPSize && m_iGOPSize ) && !bEos );
     794    }
     795    Bool flush = 0;
     796    // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
     797    if (m_acTVideoIOYuvInputFile[m_numLayers-1].isEof())
     798    {
     799      flush = true;
     800      bEos = true;
     801      m_iFrameRcvd--;
     802      m_acTEncTop[m_numLayers-1].setFramesToBeEncoded(m_iFrameRcvd);
     803    }
     804
     805    // loop through frames in one GOP
     806    for ( UInt iPicIdInGOP=0; iPicIdInGOP < (bFirstFrame? 1:m_iGOPSize); iPicIdInGOP++ )
     807    {
     808      // layer by layer for each frame
     809      for(UInt layer=0; layer<m_numLayers; layer++)
     810      {
     811        // call encoding function for one frame
     812        m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP );
     813      }
     814    }
     815
     816    iTotalNumEncoded = 0;
     817    for(UInt layer=0; layer<m_numLayers; layer++)
     818    {
     819      // write bistream to file if necessary
     820      iNumEncoded = m_acTEncTop[layer].getNumPicRcvd();
     821      if ( iNumEncoded > 0 )
     822      {
     823        xWriteRecon(layer, iNumEncoded);
     824        iTotalNumEncoded += iNumEncoded;
     825      }
     826      m_acTEncTop[layer].setNumPicRcvd( 0 );
     827    }
     828
     829    // write bitstream out
     830    if(iTotalNumEncoded)
     831    {
     832      xWriteStream(bitstreamFile, iTotalNumEncoded, outputAccessUnits);
     833      outputAccessUnits.clear();
     834    }
     835
     836    // print out summary
     837    if (bEos)
     838    {
     839      printOutSummary();
     840    }
     841
     842    bFirstFrame = false;
     843  }
     844  // delete original YUV buffer
     845  for(UInt layer=0; layer<m_numLayers; layer++)
     846  {
     847    pcPicYuvOrg[layer]->destroy();
     848    delete pcPicYuvOrg[layer];
     849    pcPicYuvOrg[layer] = NULL;
     850
     851    // delete used buffers in encoder class
     852    m_acTEncTop[layer].deletePicBuffer();
     853  }
     854
     855#if AVC_SYNTAX
     856  if( streamSyntaxFile.is_open() )
     857  {
     858    streamSyntaxFile.close();
     859  }
     860#endif
     861
     862  // delete buffers & classes
     863  xDeleteBuffer();
     864  xDestroyLib();
     865
     866  printRateSummary();
     867
     868  return;
     869}
     870
     871Void TAppEncTop::printOutSummary()
     872{
     873  UInt layer;
     874
     875  // set frame rate
     876  for(layer = 0; layer < m_numLayers; layer++)
     877  {
     878    m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate());
     879    m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     880    m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     881    m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     882  }
     883
     884  //-- all
     885  printf( "\n\nSUMMARY --------------------------------------------------------\n" );
     886  printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
     887  for(layer = 0; layer < m_numLayers; layer++)
     888  {
     889    m_gcAnalyzeAll[layer].printOut('a', layer);
     890  }
     891
     892  printf( "\n\nI Slices--------------------------------------------------------\n" );
     893  printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
     894  for(layer = 0; layer < m_numLayers; layer++)
     895  {
     896    m_gcAnalyzeI[layer].printOut('i', layer);
     897  }
     898
     899  printf( "\n\nP Slices--------------------------------------------------------\n" );
     900  printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
     901  for(layer = 0; layer < m_numLayers; layer++)
     902  {
     903    m_gcAnalyzeP[layer].printOut('p', layer);
     904  }
     905
     906  printf( "\n\nB Slices--------------------------------------------------------\n" );
     907  printf( "\tTotal Frames |  "   "Bitrate    "  "Y-PSNR    "  "U-PSNR    "  "V-PSNR \n" );
     908  for(layer = 0; layer < m_numLayers; layer++)
     909  {
     910    m_gcAnalyzeB[layer].printOut('b', layer);
     911  }
     912}
     913
     914#else
     915Void TAppEncTop::encode()
     916{
     917  fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out);
     918  if (!bitstreamFile)
     919  {
     920    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile);
     921    exit(EXIT_FAILURE);
     922  }
     923
     924  TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
     925  TComPicYuv*       pcPicYuvRec = NULL;
     926
     927  // initialize internal class & member variables
     928  xInitLibCfg();
     929  xCreateLib();
     930  xInitLib();
     931
    396932  // main encoder loop
    397933  Int   iNumEncoded = 0;
    398934  Bool  bEos = false;
    399  
     935
    400936  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
    401937
    402938  // allocate original YUV buffer
    403939  pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    404  
     940
    405941  while ( !bEos )
    406942  {
     
    410946    // read input YUV file
    411947    m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad );
    412    
     948
    413949    // increase number of received frames
    414950    m_iFrameRcvd++;
    415    
     951
    416952    bEos = (m_iFrameRcvd == m_framesToBeEncoded);
    417953
     
    428964    // call encoding function for one frame
    429965    m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
    430    
     966
    431967    // write bistream to file if necessary
    432968    if ( iNumEncoded > 0 )
     
    443979  delete pcPicYuvOrg;
    444980  pcPicYuvOrg = NULL;
    445  
     981
    446982  // delete used buffers in encoder class
    447983  m_cTEncTop.deletePicBuffer();
    448  
     984
    449985  // delete buffers & classes
    450986  xDeleteBuffer();
    451987  xDestroyLib();
    452  
     988
    453989  printRateSummary();
    454990
    455991  return;
    456992}
     993#endif
    457994
    458995// ====================================================================================================================
     
    461998
    462999/**
    463  - application has picture buffer list with size of GOP
    464  - picture buffer list acts as ring buffer
    465  - end of the list has the latest picture
    466  .
    467  */
     1000- application has picture buffer list with size of GOP
     1001- picture buffer list acts as ring buffer
     1002- end of the list has the latest picture
     1003.
     1004*/
     1005#if SVC_EXTENSION
     1006Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer)
     1007{
     1008  assert( m_iGOPSize > 0 );
     1009
     1010  // org. buffer
     1011  if ( m_acListPicYuvRec[layer].size() == (UInt)m_iGOPSize )
     1012  {
     1013    rpcPicYuvRec = m_acListPicYuvRec[layer].popFront();
     1014
     1015  }
     1016  else
     1017  {
     1018    rpcPicYuvRec = new TComPicYuv;
     1019
     1020#if SVC_UPSAMPLING
     1021    rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     1022#else
     1023    rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1024#endif
     1025
     1026  }
     1027  m_acListPicYuvRec[layer].pushBack( rpcPicYuvRec );
     1028}
     1029
     1030Void TAppEncTop::xDeleteBuffer( )
     1031{
     1032  for(UInt layer=0; layer<m_numLayers; layer++)
     1033  {
     1034    TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_acListPicYuvRec[layer].begin();
     1035
     1036    Int iSize = Int( m_acListPicYuvRec[layer].size() );
     1037
     1038    for ( Int i = 0; i < iSize; i++ )
     1039    {
     1040      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1041      pcPicYuvRec->destroy();
     1042      delete pcPicYuvRec; pcPicYuvRec = NULL;
     1043    }
     1044  } 
     1045}
     1046
     1047Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded)
     1048{
     1049  Int i;
     1050
     1051  TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end();
     1052
     1053  for ( i = 0; i < iNumEncoded; i++ )
     1054  {
     1055    --iterPicYuvRec;
     1056  }
     1057
     1058  for ( i = 0; i < iNumEncoded; i++ )
     1059  {
     1060    TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1061    if (!m_acLayerCfg[layer].getReconFile().empty())
     1062    {
     1063      m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(),
     1064        m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() );
     1065    }
     1066  }
     1067}
     1068
     1069Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
     1070{
     1071  Int i;
     1072
     1073  list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1074
     1075  for ( i = 0; i < iNumEncoded; i++ )
     1076  {
     1077    const AccessUnit& au = *(iterBitstream++);
     1078    const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
     1079    rateStatsAccum(au, stats);
     1080  }
     1081}
     1082
     1083#else // SVC_EXTENSION
    4681084Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec)
    4691085{
    4701086  assert( m_iGOPSize > 0 );
    471  
     1087
    4721088  // org. buffer
    4731089  if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize )
     
    4791095  {
    4801096    rpcPicYuvRec = new TComPicYuv;
    481    
     1097
    4821098    rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    4831099
     
    4891105{
    4901106  TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvRec.begin();
    491  
     1107
    4921108  Int iSize = Int( m_cListPicYuvRec.size() );
    493  
     1109
    4941110  for ( Int i = 0; i < iSize; i++ )
    4951111  {
     
    4981114    delete pcPicYuvRec; pcPicYuvRec = NULL;
    4991115  }
    500  
     1116
    5011117}
    5021118
    5031119/** \param iNumEncoded  number of encoded frames
    504  */
     1120*/
    5051121Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
    5061122{
    5071123  Int i;
    508  
     1124
    5091125  TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
    5101126  list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
    511  
     1127
    5121128  for ( i = 0; i < iNumEncoded; i++ )
    5131129  {
    5141130    --iterPicYuvRec;
    5151131  }
    516  
     1132
    5171133  for ( i = 0; i < iNumEncoded; i++ )
    5181134  {
     
    5281144  }
    5291145}
     1146#endif
    5301147
    5311148/**
    532  *
    533  */
     1149*
     1150*/
    5341151void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes)
    5351152{
     
    5721189void TAppEncTop::printRateSummary()
    5731190{
     1191#if SVC_EXTENSION
     1192  Double time = (Double) m_iFrameRcvd / m_acLayerCfg[m_numLayers-1].getFrameRate();
     1193#else
    5741194  Double time = (Double) m_iFrameRcvd / m_iFrameRate;
     1195#endif
    5751196  printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time);
    5761197#if VERBOSE_RATE
  • branches/HM-10.0-dev-SHM/source/App/TAppEncoder/TAppEncTop.h

    r51 r54  
    5959private:
    6060  // class interface
     61#if SVC_EXTENSION
     62  TEncTop                    m_acTEncTop [MAX_LAYERS];                    ///< encoder class
     63  TEncTop*                   m_apcTEncTop [MAX_LAYERS];                   ///< encoder pointer class
     64  TVideoIOYuv                m_acTVideoIOYuvInputFile [MAX_LAYERS];       ///< input YUV file
     65  TVideoIOYuv                m_acTVideoIOYuvReconFile [MAX_LAYERS];       ///< output reconstruction file
     66
     67  TComList<TComPicYuv*>      m_acListPicYuvRec [MAX_LAYERS];              ///< list of reconstruction YUV files
     68#else
    6169  TEncTop                    m_cTEncTop;                    ///< encoder class
    6270  TVideoIOYuv                m_cTVideoIOYuvInputFile;       ///< input YUV file
     
    6472 
    6573  TComList<TComPicYuv*>      m_cListPicYuvRec;              ///< list of reconstruction YUV files
     74#endif
    6675 
    6776  Int                        m_iFrameRcvd;                  ///< number of received frames
     
    7786 
    7887  /// obtain required buffers
     88#if SVC_EXTENSION
     89  Void xGetBuffer(TComPicYuv*& rpcPicYuvRec, UInt layer);
     90#else
    7991  Void xGetBuffer(TComPicYuv*& rpcPicYuvRec);
     92#endif
    8093 
    8194  /// delete allocated buffers
     
    8396 
    8497  // file I/O
     98#if SVC_EXTENSION
     99  Void xWriteRecon(UInt layer, Int iNumEncoded);
     100  Void xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits);
     101  Void printOutSummary();
     102#else
    85103  Void xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits); ///< write bitstream to file
     104#endif
    86105  void rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& stats);
    87106  void printRateSummary();
     
    92111 
    93112  Void        encode      ();                               ///< main encoding function
     113#if SVC_EXTENSION
     114  TEncTop&    getTEncTop  (UInt layer)   { return  m_acTEncTop[layer]; }      ///< return encoder class pointer reference
     115#else
    94116  TEncTop&    getTEncTop  ()   { return  m_cTEncTop; }      ///< return encoder class pointer reference
     117#endif
    95118};// END CLASS DEFINITION TAppEncTop
    96119
  • branches/HM-10.0-dev-SHM/source/App/TAppEncoder/encmain.cpp

    r51 r54  
    5757  // print information
    5858  fprintf( stdout, "\n" );
    59   fprintf( stdout, "HM software: Encoder Version [%s]", NV_VERSION );
     59  fprintf( stdout, "SHM software: Encoder Version [%s]", NV_VERSION );
    6060  fprintf( stdout, NVM_ONOS );
    6161  fprintf( stdout, NVM_COMPILEDBY );
Note: See TracChangeset for help on using the changeset viewer.