Changeset 442 in SHVCSoftware for trunk/source/App/TAppEncoder


Ignore:
Timestamp:
21 Oct 2013, 13:41:29 (11 years ago)
Author:
seregin
Message:

reintegrate SHM-3.1-dev branch

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/source

  • trunk/source/App/TAppEncoder/TAppEncCfg.cpp

    r345 r442  
    6969, m_avcBaseLayerFlag(0)
    7070#endif
     71#if N0120_MAX_TID_REF_CFG
     72, m_maxTidRefPresentFlag(1)
     73#endif
    7174, m_pColumnWidth()
    7275, m_pRowHeight()
    7376, m_scalingListFile()
    74 #if REF_IDX_FRAMEWORK
    7577, m_elRapSliceBEnabled(0)
    76 #endif
    7778{
    7879  for(UInt layer=0; layer<MAX_LAYERS; layer++)
     
    217218    {
    218219      in>>entry.m_refIdc[i];
     220    }
     221  }
     222#endif
     223#if EXTERNAL_USEDBYCURR_N0082
     224  if(entry.m_numRefPics>0){
     225    in>>entry.m_UseExtusedByCurrPic;
     226    if(entry.m_UseExtusedByCurrPic)
     227    {
     228      for ( Int i = 0; i < entry.m_numRefPics; i++ )
     229      {
     230        in>>entry.m_ExtusedByCurrPic[i];
     231      }
    219232    }
    220233  }
     
    335348 
    336349#if SVC_EXTENSION
    337   string  cfg_LayerCfgFile  [MAX_LAYERS];
     350  string  cfg_LayerCfgFile   [MAX_LAYERS];
    338351  string  cfg_BitstreamFile;
    339   string* cfg_InputFile     [MAX_LAYERS];
    340   string* cfg_ReconFile     [MAX_LAYERS];
    341   Double* cfg_fQP           [MAX_LAYERS];
    342 
     352  string* cfg_InputFile      [MAX_LAYERS];
     353  string* cfg_ReconFile      [MAX_LAYERS];
     354  Double* cfg_fQP            [MAX_LAYERS];
     355
     356#if REPN_FORMAT_IN_VPS
     357  Int*    cfg_repFormatIdx  [MAX_LAYERS];
     358#endif
    343359  Int*    cfg_SourceWidth   [MAX_LAYERS];
    344360  Int*    cfg_SourceHeight  [MAX_LAYERS];
     
    384400  Bool*   cfg_RCForceIntraQP       [MAX_LAYERS];
    385401#endif
     402#if N0120_MAX_TID_REF_CFG
     403  Int*    cfg_maxTidIlRefPicsPlus1[MAX_LAYERS];
     404#endif
    386405  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
    387406  {
     
    389408    cfg_ReconFile[layer]    = &m_acLayerCfg[layer].m_cReconFile;
    390409    cfg_fQP[layer]          = &m_acLayerCfg[layer].m_fQP;
     410#if REPN_FORMAT_IN_VPS
     411    cfg_repFormatIdx[layer] = &m_acLayerCfg[layer].m_repFormatIdx;
     412#endif
    391413    cfg_SourceWidth[layer]  = &m_acLayerCfg[layer].m_iSourceWidth;
    392414    cfg_SourceHeight[layer] = &m_acLayerCfg[layer].m_iSourceHeight;
     
    426448    cfg_RCForceIntraQP[layer]        = &m_acLayerCfg[layer].m_RCForceIntraQP;
    427449#endif
     450#if N0120_MAX_TID_REF_CFG
     451    cfg_maxTidIlRefPicsPlus1[layer] = &m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1;
     452#endif
    428453  }
    429454#if AVC_BASE
     
    432457#if AVC_SYNTAX
    433458  string  cfg_BLSyntaxFile;
     459#endif
     460#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     461  string  cfg_tileSets;
    434462#endif
    435463#else
     
    459487  ("FrameRate%d,-fr%d",       cfg_FrameRate,  0, MAX_LAYERS, "Frame rate for layer %d")
    460488  ("LambdaModifier%d,-LM%d",  m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d")
     489#if REPN_FORMAT_IN_VPS
     490  ("RepFormatIdx%d",          cfg_repFormatIdx, -1, MAX_LAYERS, "Index to the representation format structure used from the VPS")
     491#endif
    461492#if VPS_EXTN_DIRECT_REF_LAYERS
    462493#if M0457_PREDICTION_INDICATIONS
     
    474505  ("NumLayers",               m_numLayers, 1, "Number of layers to code")
    475506  ("ConformanceMode%d",       cfg_conformanceMode,0, MAX_LAYERS, "Window conformance mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
     507#if SCALABILITY_MASK_E0104
     508  ("ScalabilityMask1",        m_scalabilityMask[1], 0, "scalability_mask[1] (multiview)")
     509  ("ScalabilityMask2",        m_scalabilityMask[2], 1, "scalability_mask[2] (scalable)" )
     510#else
    476511  ("ScalabilityMask0",        m_scalabilityMask[0], 0, "scalability_mask[0] (multiview)")
    477512  ("ScalabilityMask1",        m_scalabilityMask[1], 1, "scalability_mask[1] (scalable)" )
     513#endif
    478514  ("BitstreamFile,b",         cfg_BitstreamFile, string(""), "Bitstream output file name")
    479515  ("InputBitDepth",           m_inputBitDepthY,    8, "Bit-depth of input file")
     
    495531                                                                 " bottom-right luma sample of the EL picture, in units of two luma samples")
    496532#endif
     533#if N0120_MAX_TID_REF_CFG
     534  ("MaxTidRefPresentFlag", m_maxTidRefPresentFlag, true, "max_tid_ref_present_flag (0: not present, 1: present(default)) " )
     535  ("MaxTidIlRefPicsPlus1%d", cfg_maxTidIlRefPicsPlus1, 1, MAX_LAYERS, "allowed maximum temporal_id for inter-layer prediction")
     536#endif
    497537#if AVC_BASE
    498538  ("AvcBase,-avc",            m_avcBaseLayerFlag,     0, "avc_base_layer_flag")
     
    502542#endif
    503543#endif
    504 #if REF_IDX_FRAMEWORK
    505544  ("EnableElRapB,-use-rap-b",  m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture)")
    506 #endif 
    507545#if M0457_IL_SAMPLE_PRED_ONLY_FLAG
    508546  ("IlSampleOnlyPred%d",       m_ilSampleOnlyPred, 0, MAX_LAYERS, "Set inter_layer_sample_pred_only_flag for all slices")
    509547#endif
    510 #else 
     548#else
    511549  ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
    512550  ("BitstreamFile,b",       cfg_BitstreamFile, string(""), "Bitstream output file name")
     
    530568  ("FrameRate,-fr",         m_iFrameRate,          0, "Frame rate")
    531569#endif
     570
     571  //Field coding parameters
     572  ("FieldCoding", m_isField, false, "Signals if it's a field based coding")
     573  ("TopFieldFirst, Tff", m_isTopFieldFirst, false, "In case of field based coding, signals whether if it's a top field first or not")
    532574  ("FrameSkip,-fs",         m_FrameSkip,          0u, "Number of frames to skip at start of input YUV")
    533575  ("FramesToBeEncoded,f",   m_framesToBeEncoded,   0, "Number of frames to be encoded (default=all)")
     
    810852  ("AdaptiveResolutionChange",     m_adaptiveResolutionChange, 0, "Adaptive resolution change frame number. Should coincide with EL RAP picture. (0: disable)")
    811853#endif
     854#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     855  ("SEIInterLayerConstrainedTileSets", m_interLayerConstrainedTileSetsSEIEnabled, false, "Control generation of inter layer constrained tile sets SEI message")
     856  ("IlNumSetsInMessage",               m_ilNumSetsInMessage,                         0u, "Number of inter layer constrained tile sets")
     857  ("TileSetsArray",                    cfg_tileSets,                         string(""), "Array containing tile sets params (TopLeftTileIndex, BottonRightTileIndex and ilcIdc for each set) ")
     858#endif
    812859  ;
    813860 
     
    827874  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
    828875
     876  if(m_isField)
     877  {
     878#if SVC_EXTENSION
     879    for(Int layer = 0; layer < MAX_LAYERS; layer++)
     880    {
     881      //Frame height
     882      m_acLayerCfg[layer].m_iSourceHeightOrg = m_acLayerCfg[layer].m_iSourceHeight;
     883      //Field height
     884      m_acLayerCfg[layer].m_iSourceHeight = m_acLayerCfg[layer].m_iSourceHeight >> 1;
     885    }
     886#else
     887    //Frame height
     888    m_iSourceHeightOrg = m_iSourceHeight;
     889    //Field height
     890    m_iSourceHeight = m_iSourceHeight >> 1;
     891#endif
     892    //number of fields to encode
     893    m_framesToBeEncoded *= 2;
     894  }
     895 
    829896  for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
    830897  {
     
    11191186#endif
    11201187  m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str());
    1121  
     1188
     1189#if REPN_FORMAT_IN_VPS_123
     1190  for(Int layer = 0; layer < MAX_LAYERS; layer++)
     1191  {
     1192    m_acLayerCfg[layer].setSourceHeight( m_repFormatCfg[ m_acLayerCfg[layer].getRepFormatIdx() ].m_picHeightInLumaSamples);
     1193    m_acLayerCfg[layer].setSourceWidth ( m_repFormatCfg[ m_acLayerCfg[layer].getRepFormatIdx() ].m_picWidthInLumaSamples );
     1194  }
     1195#endif
    11221196  /* rules for input, output and internal bitdepths as per help text */
    11231197  if (!m_internalBitDepthY) { m_internalBitDepthY = m_inputBitDepthY; }
     
    11511225        m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
    11521226        m_iSourceHeight += m_confBottom;
     1227        if ( m_isField )
     1228        {
     1229          m_iSourceHeightOrg += m_confBottom << 1;
     1230          m_aiPad[1] = m_confBottom << 1;
     1231        }
    11531232      }
    11541233      if (m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0)
     
    12841363    }
    12851364  }
     1365#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     1366  if (m_interLayerConstrainedTileSetsSEIEnabled)
     1367  {
     1368    if (m_iNumColumnsMinus1 == 0 && m_iNumRowsMinus1 == 0)
     1369    {
     1370      printf( "Tiles are not defined (needed for inter-layer comnstrained tile sets SEI).\n" );
     1371      exit( EXIT_FAILURE );
     1372    }
     1373    Char* pTileSets = cfg_tileSets.empty() ? NULL : strdup(cfg_tileSets.c_str());
     1374    int i = 0;
     1375    char *topLeftTileIndex = strtok(pTileSets, " ,");
     1376    while(topLeftTileIndex != NULL)
     1377    {
     1378      if( i >= m_ilNumSetsInMessage )
     1379      {
     1380        printf( "The number of tile sets is larger than defined by IlNumSetsInMessage.\n" );
     1381        exit( EXIT_FAILURE );
     1382      }
     1383      *( m_topLeftTileIndex + i ) = atoi( topLeftTileIndex );
     1384      char *bottonRightTileIndex = strtok(NULL, " ,");
     1385      if( bottonRightTileIndex == NULL )
     1386      {
     1387        printf( "BottonRightTileIndex is missing in the tile sets.\n" );
     1388        exit( EXIT_FAILURE );
     1389      }
     1390      *( m_bottomRightTileIndex + i ) = atoi( bottonRightTileIndex );
     1391      char *ilcIdc = strtok(NULL, " ,");
     1392      if( ilcIdc == NULL )
     1393      {
     1394        printf( "IlcIdc is missing in the tile sets.\n" );
     1395        exit( EXIT_FAILURE );
     1396      }
     1397      *( m_ilcIdc + i ) = atoi( ilcIdc );
     1398      topLeftTileIndex = strtok(NULL, " ,");
     1399      i++;
     1400    }
     1401    if( i < m_ilNumSetsInMessage )
     1402    {
     1403      printf( "The number of tile sets is smaller than defined by IlNumSetsInMessage.\n" );
     1404      exit( EXIT_FAILURE );
     1405    }
     1406    m_skippedTileSetPresentFlag = false;
     1407  }
     1408#endif
    12861409  // check validity of input parameters
    12871410  xCheckParameter();
     
    14671590#endif
    14681591 
    1469 #if !FINAL_RPL_CHANGE_N0082
     1592#if EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082
    14701593  Bool verifiedGOP=false;
    14711594#endif
    14721595  Bool errorGOP=false;
    1473 #if !FINAL_RPL_CHANGE_N0082
     1596#if  EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082
    14741597  Int checkGOP=1;
    1475   Int numRefs = 1;
     1598  Int numRefs = m_isField ? 2 : 1;
    14761599#endif
    14771600  Int refList[MAX_NUM_REF_PICS+1];
    14781601  refList[0]=0;
     1602  if(m_isField)
     1603  {
     1604    refList[1] = 1;
     1605  }
    14791606  Bool isOK[MAX_GOP];
    14801607  for(Int i=0; i<MAX_GOP; i++)
     
    14821609    isOK[i]=false;
    14831610  }
    1484 #if !FINAL_RPL_CHANGE_N0082
     1611#if  EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082
    14851612  Int numOK=0;
    14861613#endif
     
    15041631  for(UInt layer=0; layer<m_numLayers; layer++)
    15051632  {
    1506     if(m_acLayerCfg[layer].xCheckParameter())
     1633    if(m_acLayerCfg[layer].xCheckParameter(m_isField))
    15071634    {
    15081635      printf("\nError: invalid configuration parameter found in layer %d \n", layer);
     
    15301657  for(UInt layer=0; layer<m_numLayers; layer++)
    15311658  {
    1532     if (m_acLayerCfg[layer].m_GOPListLayer[0].m_POC<0){
     1659    if (m_acLayerCfg[layer].m_GOPListLayer[0].m_POC<0)
     1660    {
    15331661      memcpy( m_acLayerCfg[layer].m_GOPListLayer, m_GOPList, sizeof(GOPEntry)*MAX_GOP );
    15341662    }
     
    15361664    xConfirmPara(errorGOP,"Invalid GOP structure given");
    15371665  }
     1666#if TEMP_SCALABILITY_FIX
     1667  if( m_acLayerCfg[1].m_GOPListLayer[5].m_POC == 6  && m_acLayerCfg[1].m_GOPListLayer[7].m_POC == 7  &&
     1668    m_acLayerCfg[1].m_GOPListLayer[5].m_temporalId == 0 && m_acLayerCfg[1].m_GOPListLayer[7].m_temporalId == 0)
     1669#else
    15381670  //tentative for encoder
    1539   if( m_acLayerCfg[1].m_GOPListLayer[5].m_POC == 6  && m_acLayerCfg[1].m_GOPListLayer[7].m_POC == 7 ){
     1671  if( m_acLayerCfg[1].m_GOPListLayer[5].m_POC == 6  && m_acLayerCfg[1].m_GOPListLayer[7].m_POC == 7 )
     1672#endif
     1673  {
    15401674    //RA, POC5
    15411675    m_acLayerCfg[1].m_GOPListLayer[5].m_usedByCurrPic[2] = 0;
     
    15451679    m_acLayerCfg[1].m_GOPListLayer[7].m_refIdc[2] = 0;
    15461680  }
    1547 #else
     1681#endif
     1682#if  EXTERNAL_USEDBYCURR_N0082|| !FINAL_RPL_CHANGE_N0082
    15481683  m_extraRPSs=0;
    15491684  //start looping through frames in coding order until we can verify that the GOP structure is correct.
     
    17421877  xConfirmPara(errorGOP,"Invalid GOP structure given");
    17431878#endif
     1879#if EXTERNAL_USEDBYCURR_N0082
     1880  for(UInt layer=0; layer<m_numLayers; layer++)
     1881  {
     1882    for (Int i=0; i< m_iGOPSize; i++){
     1883      if (m_acLayerCfg[layer].m_GOPListLayer[i].m_UseExtusedByCurrPic == 1 )
     1884      {
     1885        for(Int j=0; j<m_acLayerCfg[layer].m_GOPListLayer[i].m_numRefPics; j++ )
     1886        {
     1887          m_acLayerCfg[layer].m_GOPListLayer[i].m_usedByCurrPic[j] = m_acLayerCfg[layer].m_GOPListLayer[i].m_ExtusedByCurrPic[j];
     1888          m_acLayerCfg[layer].m_GOPListLayer[i].m_refIdc[j] = m_acLayerCfg[layer].m_GOPListLayer[i].m_ExtusedByCurrPic[j];
     1889        }
     1890      }
     1891    }
     1892  }
     1893#endif
    17441894  m_maxTempLayer = 1;
    17451895  for(Int i=0; i<m_iGOPSize; i++)
     
    20452195  }
    20462196#endif
     2197#if N0120_MAX_TID_REF_CFG
     2198  for (UInt layer=0; layer < MAX_LAYERS-1; layer++)
     2199  {
     2200    xConfirmPara(m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1 < 0 || m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1 > 7, "MaxTidIlRefPicsPlus1 must be in range 0 to 7");
     2201  }
     2202#endif
    20472203#undef xConfirmPara
    20482204  if (check_failed)
     
    20812237#if SVC_EXTENSION 
    20822238  printf("Total number of layers        : %d\n", m_numLayers       );
     2239#if SCALABILITY_MASK_E0104
     2240  printf("Multiview                     : %d\n", m_scalabilityMask[1] );
     2241  printf("Scalable                      : %d\n", m_scalabilityMask[2] );
     2242#else
    20832243  printf("Multiview                     : %d\n", m_scalabilityMask[0] );
    20842244  printf("Scalable                      : %d\n", m_scalabilityMask[1] );
     2245#endif
    20852246#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    20862247  printf("Adaptive Resolution Change    : %d\n", m_adaptiveResolutionChange );
     
    21052266  printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
    21062267#endif
    2107   printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
     2268  if (m_isField)
     2269  {
     2270    printf("Frame/Field          : Field based coding\n");
     2271    printf("Field index          : %u - %d (%d fields)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
     2272    if (m_isTopFieldFirst)
     2273    {
     2274      printf("Field Order            : Top field first\n");
     2275    }
     2276    else
     2277    {
     2278      printf("Field Order            : Bottom field first\n");
     2279    }
     2280  }
     2281  else
     2282  {
     2283    printf("Frame/Field                  : Frame based coding\n");
     2284    printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_framesToBeEncoded-1, m_framesToBeEncoded );
     2285  }
    21082286  printf("CU size / depth              : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth );
    21092287  printf("RQT trans. size (min / max)  : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize );
     
    22092387  printf("AvcBase:%d ", 0);
    22102388#endif
    2211 #if REF_IDX_FRAMEWORK
    2212   printf("REF_IDX_FRAMEWORK:%d ", REF_IDX_FRAMEWORK);
    22132389  printf("EL_RAP_SliceType: %d ", m_elRapSliceBEnabled);
    22142390  printf("REF_IDX_ME_ZEROMV: %d ", REF_IDX_ME_ZEROMV);
    22152391  printf("ENCODER_FAST_MODE: %d ", ENCODER_FAST_MODE);
    22162392  printf("REF_IDX_MFM: %d ", REF_IDX_MFM);
    2217 #endif
    22182393#else
    22192394  printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 );
  • trunk/source/App/TAppEncoder/TAppEncCfg.h

    r345 r442  
    5959  // file I/O
    6060#if SVC_EXTENSION
    61   TAppEncLayerCfg m_acLayerCfg [MAX_LAYERS]; 
     61  TAppEncLayerCfg m_acLayerCfg [MAX_LAYERS];
    6262  Int       m_numLayers;                                      ///< number of layers
    6363  Int       m_scalabilityMask[MAX_VPS_NUM_SCALABILITY_TYPES]; ///< scalability_mask
     
    6868  Int       m_framesToBeEncoded;                              ///< number of encoded frames
    6969#if AVC_BASE
    70   Int       m_avcBaseLayerFlag;                               ///< AVC_BASElayer_flag
     70  Int       m_avcBaseLayerFlag;                               ///< avc_baselayer_flag
    7171#endif
    7272#if AVC_SYNTAX
     
    7676  Int       m_ilSampleOnlyPred[ MAX_LAYERS ];
    7777#endif
     78#if N0120_MAX_TID_REF_CFG
     79  Bool      m_maxTidRefPresentFlag;
     80#endif
    7881#else
    7982  Char*     m_pchInputFile;                                   ///< source file name
     
    8588  UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
    8689  Int       m_iSourceWidth;                                   ///< source width in pixel
    87   Int       m_iSourceHeight;                                  ///< source height in pixel
     90  Int       m_iSourceHeight;                                  ///< source height in pixel (when interlaced = field height)
     91 
     92  Int       m_iSourceHeightOrg;                               ///< original source height in pixel (when interlaced = frame height)
     93 
     94 
    8895  Int       m_conformanceMode;
    8996  Int       m_confLeft;
     
    94101  Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
    95102#endif 
     103
     104  Bool      m_isField;                                        ///< enable field coding
     105  Bool      m_isTopFieldFirst;
    96106
    97107  // profile/level
     
    340350  Int       m_log2MaxMvLengthVertical;                        ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units
    341351
    342 #if REF_IDX_FRAMEWORK
     352#if SVC_EXTENSION
    343353  Int       m_elRapSliceBEnabled;
    344354#endif
     
    353363#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    354364  Int       m_adaptiveResolutionChange;                       ///< Indicate adaptive resolution change frame
     365#endif
     366#if REPN_FORMAT_IN_VPS
     367  RepFormatCfg m_repFormatCfg[16];                            ///< Rep_format structures
     368#endif
     369#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     370  Bool      m_interLayerConstrainedTileSetsSEIEnabled;
     371  UInt      m_ilNumSetsInMessage;
     372  Bool      m_skippedTileSetPresentFlag;
     373  UInt      m_topLeftTileIndex[1024];
     374  UInt      m_bottomRightTileIndex[1024];
     375  UInt      m_ilcIdc[1024];
    355376#endif
    356377public:
     
    381402  Void cfgStringToArray(Int **arr, string cfgString, Int numEntries, const char* logString);
    382403#endif
     404#if REPN_FORMAT_IN_VPS
     405  RepFormatCfg* getRepFormatCfg(Int i)  { return &m_repFormatCfg[i]; }
     406#endif
    383407#endif
    384408};// END CLASS DEFINITION TAppEncCfg
  • trunk/source/App/TAppEncoder/TAppEncLayerCfg.cpp

    r313 r442  
    3232  m_conformanceMode( 0 ),
    3333  m_aidQP(NULL)
     34#if REPN_FORMAT_IN_VPS
     35, m_repFormatIdx (-1)
     36#endif
    3437{
    3538  m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
     
    158161Bool confirmPara(Bool bflag, const char* message);
    159162
    160 Bool TAppEncLayerCfg::xCheckParameter()
     163Bool TAppEncLayerCfg::xCheckParameter( Bool isField )
    161164{
    162165  switch (m_conformanceMode)
     
    182185        m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
    183186        m_iSourceHeight += m_confBottom;
     187        if ( isField )
     188        {
     189          m_iSourceHeightOrg += m_confBottom << 1;
     190          m_aiPad[1] = m_confBottom << 1;
     191        }
    184192      }
    185193      break;
  • trunk/source/App/TAppEncoder/TAppEncLayerCfg.h

    r345 r442  
    3333  Int       m_iFrameRate;                                     ///< source frame-rates (Hz)
    3434  Int       m_iSourceWidth;                                   ///< source width in pixel
    35   Int       m_iSourceHeight;                                  ///< source height in pixel
     35  Int       m_iSourceHeight;                                  ///< source height in pixel (when interlaced = field height)
     36  Int       m_iSourceHeightOrg;                               ///< original source height in pixel (when interlaced = frame height)
    3637  Int       m_conformanceMode;
    3738  Int       m_confLeft;
     
    6667#endif
    6768
     69#if N0120_MAX_TID_REF_CFG
     70  Int       m_maxTidIlRefPicsPlus1;
     71#endif
    6872#if SVC_EXTENSION
    6973  Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
     
    8488  GOPEntry  m_GOPListLayer[MAX_GOP];                            ///< for layer
    8589#endif
     90#if REPN_FORMAT_IN_VPS
     91  Int       m_repFormatIdx;
     92#endif
    8693public:
    8794  TAppEncLayerCfg();
     
    98105  Void  xPrintParameter();
    99106#endif
    100   Bool  xCheckParameter();
     107  Bool  xCheckParameter( Bool isField );
    101108
    102109  Void    setAppEncCfg(TAppEncCfg* p) {m_cAppEncCfg = p;          }
     
    107114  Int     getSourceWidth()            {return m_iSourceWidth;     }
    108115  Int     getSourceHeight()           {return m_iSourceHeight;    }
     116  Int     getSourceHeightOrg()        {return m_iSourceHeightOrg; }
    109117  Int     getConformanceMode()        { return m_conformanceMode; }
    110118  Int*    getPad()                    {return m_aiPad;            }
     
    147155  GOPEntry getGOPEntry(Int i )        {return m_GOPListLayer[i];  }
    148156#endif
     157#if REPN_FORMAT_IN_VPS
     158  Int     getRepFormatIdx()           { return m_repFormatIdx;  }
     159  Void    setRepFormatIdx(Int x)      { m_repFormatIdx = x;     }
     160  Void    setSourceWidth(Int x)       { m_iSourceWidth = x;     }
     161  Void    setSourceHeight(Int x)      { m_iSourceHeight = x;    }
     162#endif
     163#if N0120_MAX_TID_REF_CFG
     164  Int     getMaxTidIlRefPicsPlus1()   { return m_maxTidIlRefPicsPlus1; }
     165#endif
    149166}; // END CLASS DEFINITION TAppEncLayerCfg
    150167
  • trunk/source/App/TAppEncoder/TAppEncTop.cpp

    r345 r442  
    9090    vps->setMaxDecPicBuffering             ( m_maxDecPicBuffering[i], i );
    9191  }
    92 
     92#if REPN_FORMAT_IN_VPS
     93  vps->setRepFormatIdxPresentFlag( true );   // Could be disabled to optimize in some cases.
     94  Int maxRepFormatIdx = -1;
     95  Int formatIdx = -1;
     96  for(UInt layer=0; layer < m_numLayers; layer++)
     97  {
     98    // Auto generation of the format index
     99    if( m_acLayerCfg[layer].getRepFormatIdx() == -1 )
     100    {
     101      // Currently only picture width and height are considred. It has to be updated if different chroma format and bit-depth will are used.
     102      Bool found = false;
     103      for( UInt idx = 0; idx < layer; idx++ )
     104      {
     105        if( m_acLayerCfg[layer].getSourceWidth() == m_acLayerCfg[idx].getSourceWidth() && m_acLayerCfg[layer].getSourceHeight() == m_acLayerCfg[idx].getSourceHeight() )
     106        {
     107          found = true;
     108          break;
     109        }
     110      }
     111      if( !found )
     112      {
     113        formatIdx++;
     114      }
     115
     116      m_acLayerCfg[layer].setRepFormatIdx( formatIdx );
     117    }
     118
     119    assert( m_acLayerCfg[layer].getRepFormatIdx() != -1 && "RepFormatIdx not assigned for a layer" );   
     120    vps->setVpsRepFormatIdx( layer, m_acLayerCfg[layer].getRepFormatIdx() );
     121    maxRepFormatIdx = std::max( m_acLayerCfg[layer].getRepFormatIdx(), maxRepFormatIdx );
     122  }
     123  assert( vps->getVpsRepFormatIdx( 0 ) == 0 );  // Base layer should point to the first one.
     124  Int* mapIdxToLayer = new Int[maxRepFormatIdx + 1];
     125  // Check that all the indices from 0 to maxRepFormatIdx are used in the VPS
     126  for(Int i = 0; i <= maxRepFormatIdx; i++)
     127  {
     128    mapIdxToLayer[i] = -1;
     129    UInt layer;
     130    for(layer=0; layer < m_numLayers; layer++)
     131    {
     132      if( vps->getVpsRepFormatIdx(layer) == i )
     133      {
     134        mapIdxToLayer[i] = layer;
     135        break;
     136      }
     137    }
     138    assert( layer != m_numLayers );   // One of the VPS Rep format indices not set
     139  }
     140  vps->setVpsNumRepFormats( maxRepFormatIdx + 1 );
     141  for(UInt idx=0; idx < vps->getVpsNumRepFormats(); idx++)
     142  {
     143    RepFormat *repFormat = vps->getVpsRepFormat( idx );   
     144    repFormat->setPicWidthVpsInLumaSamples  ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceWidth()   );
     145    repFormat->setPicHeightVpsInLumaSamples ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceHeight()  );
     146    repFormat->setChromaFormatVpsIdc        ( 1                                             );  // Need modification to change for each layer - corresponds to 420
     147    repFormat->setSeparateColourPlaneVpsFlag( 0                                             );  // Need modification to change for each layer
     148    repFormat->setBitDepthVpsLuma           ( getInternalBitDepthY()                        );  // Need modification to change for each layer
     149    repFormat->setBitDepthVpsChroma         ( getInternalBitDepthC()                        );  // Need modification to change for each layer
     150  }
     151  delete [] mapIdxToLayer;
     152#endif
    93153  for(UInt layer=0; layer<m_numLayers; layer++)
    94154  {
     
    157217    m_acTEncTop[layer].setMaxTempLayer                 ( m_maxTempLayer );
    158218    m_acTEncTop[layer].setUseAMP( m_enableAMP );
     219#if N0120_MAX_TID_REF_CFG
     220    if (layer<m_numLayers-1)
     221    {
     222       m_acTEncTop[layer].setMaxTidIlRefPicsPlus1 ( m_acLayerCfg[layer].getMaxTidIlRefPicsPlus1());
     223    }
     224#endif
    159225#if VPS_EXTN_DIRECT_REF_LAYERS
    160226    if(layer)
     
    195261        {
    196262          m_acTEncTop[layer].setMotionPredRefLayerId   ( i, m_acLayerCfg[layer].getMotionPredRefLayerId(i));
    197           m_acTEncTop[layer].setMotionPredEnabledFlag  (m_acLayerCfg[layer].getSamplePredRefLayerId(i), true);
     263          m_acTEncTop[layer].setMotionPredEnabledFlag  (m_acLayerCfg[layer].getMotionPredRefLayerId(i), true);
    198264        }       
    199265      }
     
    397463    m_acTEncTop[layer].setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
    398464    m_acTEncTop[layer].setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
     465#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     466    m_acTEncTop[layer].setInterLayerConstrainedTileSetsSEIEnabled( m_interLayerConstrainedTileSetsSEIEnabled );
     467    m_acTEncTop[layer].setIlNumSetsInMessage( m_ilNumSetsInMessage );
     468    m_acTEncTop[layer].setSkippedTileSetPresentFlag( m_skippedTileSetPresentFlag );
     469    m_acTEncTop[layer].setTopLeftTileIndex( m_topLeftTileIndex );
     470    m_acTEncTop[layer].setBottomRightTileIndex( m_bottomRightTileIndex );
     471    m_acTEncTop[layer].setIlcIdc( m_ilcIdc );
     472#endif
    399473    m_acTEncTop[layer].setUniformSpacingIdr          ( m_iUniformSpacingIdr );
    400474    m_acTEncTop[layer].setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
     
    475549    m_acTEncTop[layer].setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal );
    476550    m_acTEncTop[layer].setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical );
    477 #if REF_IDX_FRAMEWORK
    478551    m_acTEncTop[layer].setElRapSliceTypeB(layer == 0? 0 : m_elRapSliceBEnabled);
    479 #endif
    480552#if SCALED_REF_LAYER_OFFSETS
    481553    if( layer > 0 )
     
    824896}
    825897
    826 Void TAppEncTop::xInitLib()
     898Void TAppEncTop::xInitLib(Bool isFieldCoding)
    827899{
    828900#if SVC_EXTENSION
    829901  for(UInt layer=0; layer<m_numLayers; layer++)
    830902  {
    831     m_acTEncTop[layer].init();
     903    m_acTEncTop[layer].init(isFieldCoding);
    832904  }
    833905#if VPS_RENAME
     
    889961#endif
    890962#if N0120_MAX_TID_REF_PRESENT_FLAG
    891   vps->setMaxTidIlRefPicsPlus1PresentFlag(true);
    892   if (vps->getMaxTidIlRefPicsPlus1PresentFlag())
     963#if N0120_MAX_TID_REF_CFG
     964  vps->setMaxTidRefPresentFlag(m_maxTidRefPresentFlag);
     965#else
     966  vps->setMaxTidRefPresentFlag(true);
     967#endif
     968  if (vps->getMaxTidRefPresentFlag())
    893969  {
    894970    for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
    895971    {
    896       vps->setMaxSublayerForIlpPlus1(i, vps->getMaxTLayers()+1);
     972#if N0120_MAX_TID_REF_CFG
     973      vps->setMaxTidIlRefPicsPlus1(i, m_acTEncTop[i].getMaxTidIlRefPicsPlus1());
     974#else
     975      vps->setMaxTidIlRefPicsPlus1(i, vps->getMaxTLayers()+1);
     976#endif
    897977    }
    898978  }
     
    901981    for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
    902982    {
    903       vps->setMaxSublayerForIlpPlus1(i, 7);
     983      vps->setMaxTidIlRefPicsPlus1(i, 7);
    904984    }
    905985  }
     
    9831063#endif
    9841064  }
     1065#if IL_SL_SIGNALLING_N0371
     1066  for(i = 1; i < vps->getMaxLayers(); i++)
     1067  {
     1068    for(Int j = 0; j < i; j++)
     1069    {
     1070      vps->setScalingListLayerDependency( i, j, vps->checkLayerDependency( i,j ) );
     1071    }
     1072  }
     1073#endif
    9851074#endif
    9861075#if JCTVC_M0458_INTERLAYER_RPS_SIG       
    9871076    vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true);
    9881077#endif
     1078#if N0147_IRAP_ALIGN_FLAG   
     1079    vps->setCrossLayerIrapAlignFlag(true);
     1080    for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     1081    {
     1082      for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
     1083      {
     1084        if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr))
     1085        {         
     1086          if(m_acTEncTop[layerCtr].getIntraPeriod() !=  m_acTEncTop[refLayerCtr].getIntraPeriod())
     1087          {
     1088            vps->setCrossLayerIrapAlignFlag(false);
     1089            break;
     1090          }
     1091        }
     1092      }
     1093    }
     1094
     1095    if( vps->getAvcBaseLayerFlag() )
     1096    {
     1097      vps->setCrossLayerIrapAlignFlag(false);
     1098    }
     1099#endif
    9891100#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    9901101  vps->setSingleLayerForNonIrapFlag(m_adaptiveResolutionChange > 0 ? true : false);
    9911102#endif
    992 #else
    993   m_cTEncTop.init();
    994 #endif
     1103#if VPS_EXTN_OFFSET
     1104  // to be updated according to the current semantics
     1105  vps->setExtensionOffset( 0xffff );
     1106#endif
     1107#else //SVC_EXTENSION
     1108  m_cTEncTop.init(isFieldCoding);
     1109#endif //SVC_EXTENSION
    9951110}
    9961111
     
    10231138  xInitLibCfg();
    10241139  xCreateLib();
    1025   xInitLib();
     1140  xInitLib(m_isField);
    10261141
    10271142  // main encoder loop
     
    10351150    // allocate original YUV buffer
    10361151    pcPicYuvOrg[layer] = new TComPicYuv;
     1152    if( m_isField )
     1153    {
    10371154#if SVC_UPSAMPLING
    1038     pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
    1039 #else
    1040     pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    1041 #endif
     1155      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     1156#else
     1157      pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1158#endif
     1159    }
     1160    else
     1161    {
     1162#if SVC_UPSAMPLING
     1163      pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL );
     1164#else
     1165      pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1166#endif
     1167    }
    10421168  }
    10431169
     
    10811207          m_iFrameRcvd++;
    10821208          // check end of file
    1083           bEos = (m_iFrameRcvd == m_framesToBeEncoded);
     1209          bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) );
    10841210        }
    10851211
    1086         m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] );
     1212        if ( m_isField )
     1213        {
     1214          m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer], m_isTopFieldFirst );
     1215        }
     1216        else
     1217        {
     1218          m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] );
     1219        }
    10871220      }
    10881221
     
    11311264      {
    11321265        // call encoding function for one frame
    1133         m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP );
     1266        if ( m_isField )
     1267        {
     1268          m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP, m_isTopFieldFirst );
     1269        }
     1270        else
     1271        {
     1272          m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP );
     1273        }
    11341274      }
    11351275    }
     
    11681308    if (bEos)
    11691309    {
    1170       printOutSummary();
     1310      printOutSummary(m_isTopFieldFirst);
    11711311    }
    11721312
     
    12001340}
    12011341
    1202 Void TAppEncTop::printOutSummary()
     1342Void TAppEncTop::printOutSummary(Bool isField)
    12031343{
    12041344  UInt layer;
     
    12071347  for(layer = 0; layer < m_numLayers; layer++)
    12081348  {
    1209     m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate());
    1210     m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
    1211     m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
    1212     m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     1349    if(isField)
     1350    {
     1351      m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2);
     1352      m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 );
     1353      m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 );
     1354      m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 );
     1355    }
     1356    else
     1357    {
     1358      m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate());
     1359      m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     1360      m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     1361      m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() );
     1362    }
    12131363  }
    12141364
     
    12411391    m_gcAnalyzeB[layer].printOut('b', layer);
    12421392  }
     1393
     1394  if(isField)
     1395  {
     1396    for(layer = 0; layer < m_numLayers; layer++)
     1397    {
     1398      //-- interlaced summary
     1399      m_gcAnalyzeAll_in.setFrmRate( m_acLayerCfg[layer].getFrameRate());
     1400      printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" );
     1401      m_gcAnalyzeAll_in.printOutInterlaced('a',  m_gcAnalyzeAll[layer].getBits());
     1402
     1403#if _SUMMARY_OUT_
     1404      m_gcAnalyzeAll_in.printSummaryOutInterlaced();
     1405#endif
     1406    }
     1407  }
    12431408}
    12441409
     
    12591424  xInitLibCfg();
    12601425  xCreateLib();
    1261   xInitLib();
     1426  xInitLib(m_isField);
    12621427
    12631428  // main encoder loop
     
    12681433
    12691434  // allocate original YUV buffer
    1270   pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1435  if( m_isField )
     1436  {
     1437    pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeightOrg, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1438  }
     1439  else
     1440  {
     1441    pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     1442  }
    12711443
    12721444  while ( !bEos )
     
    12811453    m_iFrameRcvd++;
    12821454
    1283     bEos = (m_iFrameRcvd == m_framesToBeEncoded);
    1284 
     1455    bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) );
    12851456    Bool flush = 0;
    12861457    // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
     
    12941465
    12951466    // call encoding function for one frame
     1467    if ( m_isField )
     1468    {
     1469      m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst);
     1470    }
     1471    else
     1472    {
    12961473    m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
     1474    }
    12971475
    12981476    // write bistream to file if necessary
     
    13041482  }
    13051483
    1306   m_cTEncTop.printSummary();
     1484  m_cTEncTop.printSummary(m_isField);
    13071485
    13081486  // delete original YUV buffer
     
    13781556Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded)
    13791557{
    1380   Int i;
    1381 
    1382   TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end();
    1383 
    1384   for ( i = 0; i < iNumEncoded; i++ )
    1385   {
    1386     --iterPicYuvRec;
    1387   }
    1388 
    1389   for ( i = 0; i < iNumEncoded; i++ )
    1390   {
    1391     TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1558  if (m_isField)
     1559  {
     1560    //Reinterlace fields
     1561    Int i;
     1562    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end();
     1563
     1564    for ( i = 0; i < iNumEncoded; i++ )
     1565    {
     1566      --iterPicYuvRec;
     1567    }
     1568
     1569    for ( i = 0; i < iNumEncoded/2; i++ )
     1570    {
     1571      TComPicYuv*  pcPicYuvRecTop  = *(iterPicYuvRec++);
     1572      TComPicYuv*  pcPicYuvRecBottom  = *(iterPicYuvRec++);
     1573
    13921574#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    1393     if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRec->isReconstructed())
    1394 #else
    1395     if (!m_acLayerCfg[layer].getReconFile().empty())
    1396 #endif
    1397     {
    1398       m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(),
    1399         m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() );
     1575      if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRecTop->isReconstructed() && pcPicYuvRecBottom->isReconstructed())
     1576#else
     1577      if (!m_acLayerCfg[layer].getReconFile().empty())
     1578#endif
     1579      {
     1580        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom(), m_isTopFieldFirst );
     1581      }
     1582    }
     1583  }
     1584  else
     1585  {
     1586    Int i;
     1587
     1588    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end();
     1589
     1590    for ( i = 0; i < iNumEncoded; i++ )
     1591    {
     1592      --iterPicYuvRec;
     1593    }
     1594
     1595    for ( i = 0; i < iNumEncoded; i++ )
     1596    {
     1597      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1598#if M0040_ADAPTIVE_RESOLUTION_CHANGE
     1599      if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRec->isReconstructed())
     1600#else
     1601      if (!m_acLayerCfg[layer].getReconFile().empty())
     1602#endif
     1603      {
     1604        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(),
     1605          m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() );
     1606      }
    14001607    }
    14011608  }
     
    14041611Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
    14051612{
    1406   Int i;
    1407 
    1408   list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1613  if (m_isField)
     1614  {
     1615    //Reinterlace fields
     1616    Int i;
     1617    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
    14091618
    14101619#if M0040_ADAPTIVE_RESOLUTION_CHANGE
    1411   for ( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ )
    1412 #else
    1413   for ( i = 0; i < iNumEncoded; i++ )
    1414 #endif
    1415   {
    1416     const AccessUnit& au = *(iterBitstream++);
    1417     const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
    1418     rateStatsAccum(au, stats);
     1620    for ( i = 0; i < iNumEncoded/2 && iterBitstream != accessUnits.end(); i++ )
     1621#else
     1622    for ( i = 0; i < iNumEncoded/2; i++ )
     1623#endif
     1624    {     
     1625      const AccessUnit& auTop = *(iterBitstream++);
     1626      const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop);
     1627      rateStatsAccum(auTop, statsTop);
     1628
     1629      const AccessUnit& auBottom = *(iterBitstream++);
     1630      const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom);
     1631      rateStatsAccum(auBottom, statsBottom);
     1632    }
     1633  }
     1634  else
     1635  {
     1636    Int i;
     1637
     1638    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1639
     1640#if M0040_ADAPTIVE_RESOLUTION_CHANGE
     1641    for ( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ )
     1642#else
     1643    for ( i = 0; i < iNumEncoded; i++ )
     1644#endif
     1645    {
     1646      const AccessUnit& au = *(iterBitstream++);
     1647      const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
     1648      rateStatsAccum(au, stats);
     1649    }
    14191650  }
    14201651}
     
    14601691Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
    14611692{
    1462   Int i;
    1463 
    1464   TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
    1465   list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
    1466 
    1467   for ( i = 0; i < iNumEncoded; i++ )
    1468   {
    1469     --iterPicYuvRec;
    1470   }
    1471 
    1472   for ( i = 0; i < iNumEncoded; i++ )
    1473   {
    1474     TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
    1475     if (m_pchReconFile)
    1476     {
    1477 #if SYNTAX_OUTPUT && ILP_DECODED_PICTURE
    1478       m_cTVideoIOYuvReconFile.write( pcPicYuvRec );
    1479 #else
    1480       m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
    1481 #endif
    1482     }
    1483 
    1484     const AccessUnit& au = *(iterBitstream++);
    1485     const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
    1486     rateStatsAccum(au, stats);
     1693  if (m_isField)
     1694  {
     1695    //Reinterlace fields
     1696    Int i;
     1697    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
     1698    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1699
     1700    for ( i = 0; i < iNumEncoded; i++ )
     1701    {
     1702      --iterPicYuvRec;
     1703    }
     1704
     1705    for ( i = 0; i < iNumEncoded/2; i++ )
     1706    {
     1707      TComPicYuv*  pcPicYuvRecTop  = *(iterPicYuvRec++);
     1708      TComPicYuv*  pcPicYuvRecBottom  = *(iterPicYuvRec++);
     1709
     1710      if (m_pchReconFile)
     1711      {
     1712        m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst );
     1713      }
     1714
     1715      const AccessUnit& auTop = *(iterBitstream++);
     1716      const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop);
     1717      rateStatsAccum(auTop, statsTop);
     1718
     1719      const AccessUnit& auBottom = *(iterBitstream++);
     1720      const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom);
     1721      rateStatsAccum(auBottom, statsBottom);
     1722    }
     1723  }
     1724  else
     1725  {
     1726    Int i;
     1727
     1728    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
     1729    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     1730
     1731    for ( i = 0; i < iNumEncoded; i++ )
     1732    {
     1733      --iterPicYuvRec;
     1734    }
     1735
     1736    for ( i = 0; i < iNumEncoded; i++ )
     1737    {
     1738      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1739      if (m_pchReconFile)
     1740      {
     1741#if SYNTAX_OUTPUT
     1742        m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
     1743#endif
     1744      }
     1745
     1746      const AccessUnit& au = *(iterBitstream++);
     1747      const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
     1748      rateStatsAccum(au, stats);
     1749    }
    14871750  }
    14881751}
  • trunk/source/App/TAppEncoder/TAppEncTop.h

    r313 r442  
    8282  Void  xCreateLib        ();                               ///< create files & encoder class
    8383  Void  xInitLibCfg       ();                               ///< initialize internal variables
    84   Void  xInitLib          ();                               ///< initialize encoder class
     84  Void  xInitLib          (Bool isFieldCoding);             ///< initialize encoder class
    8585  Void  xDestroyLib       ();                               ///< destroy encoder class
    8686 
     
    9999  Void xWriteRecon(UInt layer, Int iNumEncoded);
    100100  Void xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits);
    101   Void printOutSummary();
     101  Void printOutSummary(Bool isField);
    102102#else
    103103  Void xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits); ///< write bitstream to file
Note: See TracChangeset for help on using the changeset viewer.