Changeset 56 in 3DVCSoftware for trunk/source/App


Ignore:
Timestamp:
11 May 2012, 21:20:17 (12 years ago)
Author:
hschwarz
Message:

updated trunk (move to HM6.1)

Location:
trunk/source/App
Files:
14 added
1 deleted
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/App/TAppDecoder/TAppDecCfg.cpp

    r5 r56  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license.
     4 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2011, ISO/IEC
     6 * Copyright (c) 2010-2012, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    1515 *    this list of conditions and the following disclaimer in the documentation
    1616 *    and/or other materials provided with the distribution.
    17  *  * Neither the name of the ISO/IEC nor the names of its contributors may
     17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    1818 *    be used to endorse or promote products derived from this software without
    1919 *    specific prior written permission.
     
    3232 */
    3333
    34 
    35 
    3634/** \file     TAppDecCfg.cpp
    3735    \brief    Decoder configuration class
     
    4240#include <string>
    4341#include "TAppDecCfg.h"
    44 #include "../../App/TAppCommon/program_options_lite.h"
     42#include "TAppCommon/program_options_lite.h"
    4543
    4644#ifdef WIN32
     
    5048using namespace std;
    5149namespace po = df::program_options_lite;
     50
     51//! \ingroup TAppDecoder
     52//! \{
    5253
    5354// ====================================================================================================================
     
    7273                                                     "YUV writing is skipped if omitted")
    7374  ("ScaleOffsetFile,p", cfg_ScaleOffsetFile, string(""), "file with coded scales and offsets")
    74 #if DCM_SKIP_DECODING_FRAMES
    7575  ("SkipFrames,s", m_iSkipFrame, 0, "number of frames to skip before random access")
    76 #endif
    7776  ("OutputBitDepth,d", m_outputBitDepth, 0u, "bit depth of YUV output file (use 0 for native depth)")
    78   ("SEIpictureDigest", m_pictureDigestEnabled, false, "Control handling of picture_digest SEI messages\n"
     77  ("MaxTemporalLayer,t", m_iMaxTemporalLayer, -1, "Maximum Temporal Layer to be decoded. -1 to decode all layers")
     78  ("SEIpictureDigest", m_pictureDigestEnabled, true, "Control handling of picture_digest SEI messages\n"
    7979                                              "\t1: check\n"
    8080                                              "\t0: ignore")
     
    9999  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
    100100  m_pchScaleOffsetFile = cfg_ScaleOffsetFile.empty() ? NULL : strdup(cfg_ScaleOffsetFile.c_str());
     101
    101102
    102103  if (!m_pchBitstreamFile)
     
    124125  rpchOutputFileName[iInLength+iAppendLength] = '\0';                           
    125126}
     127
     128//! \}
  • trunk/source/App/TAppDecoder/TAppDecCfg.h

    r5 r56  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license.
     4 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2011, ISO/IEC
     6 * Copyright (c) 2010-2012, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    1515 *    this list of conditions and the following disclaimer in the documentation
    1616 *    and/or other materials provided with the distribution.
    17  *  * Neither the name of the ISO/IEC nor the names of its contributors may
     17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    1818 *    be used to endorse or promote products derived from this software without
    1919 *    specific prior written permission.
     
    3232 */
    3333
    34 
    35 
    3634/** \file     TAppDecCfg.h
    3735    \brief    Decoder configuration class (header)
     
    4543#endif // _MSC_VER > 1000
    4644
    47 #include "../../Lib/TLibCommon/CommonDef.h"
     45#include "TLibCommon/CommonDef.h"
     46
     47//! \ingroup TAppDecoder
     48//! \{
    4849
    4950// ====================================================================================================================
     
    5859  char*         m_pchReconFile;                       ///< output reconstruction file name
    5960  char*         m_pchScaleOffsetFile;                 ///< output coded scale and offset parameters
    60 #if DCM_SKIP_DECODING_FRAMES
    6161  Int           m_iSkipFrame;                         ///< counter for frames prior to the random access point to skip
    62 #endif
    6362  UInt          m_outputBitDepth;                     ///< bit depth used for writing output
    6463
     64  Int           m_iMaxTemporalLayer;                  ///< maximum temporal layer to be decoded
    6565  bool m_pictureDigestEnabled; ///< enable(1)/disable(0) acting on SEI picture_digest message
    6666  Void xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char*& rpchOutputFileName); ///< create filenames
     
    7373};
    7474
     75//! \}
     76
    7577#endif
    7678
  • trunk/source/App/TAppDecoder/TAppDecTop.cpp

    r42 r56  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license.
     4 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2011, ISO/IEC
     6 * Copyright (c) 2010-2012, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    1515 *    this list of conditions and the following disclaimer in the documentation
    1616 *    and/or other materials provided with the distribution.
    17  *  * Neither the name of the ISO/IEC nor the names of its contributors may
     17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    1818 *    be used to endorse or promote products derived from this software without
    1919 *    specific prior written permission.
     
    3232 */
    3333
    34 
    35 
    3634/** \file     TAppDecTop.cpp
    3735    \brief    Decoder application class
     
    3937
    4038#include <list>
     39#include <vector>
    4140#include <stdio.h>
    4241#include <fcntl.h>
     
    4443
    4544#include "TAppDecTop.h"
    46 
    47 // ====================================================================================================================
    48 // Local constants
    49 // ====================================================================================================================
    50 
    51 /// initial bitstream buffer size
    52 /// should be large enough for parsing SPS
    53 /// resized as a function of picture size after parsing SPS
    54 #define BITS_BUF_SIZE 65536
     45#include "TLibDecoder/AnnexBread.h"
     46#include "TLibDecoder/NALread.h"
     47
     48//! \ingroup TAppDecoder
     49//! \{
    5550
    5651// ====================================================================================================================
     
    6156{
    6257  ::memset (m_abDecFlag, 0, sizeof (m_abDecFlag));
    63   m_bUsingDepth = false;
    64 //  m_iPOCLastDisplay  = -1;
    65   m_pScaleOffsetFile  = 0;
     58  m_useDepth = false;
    6659}
    6760
    6861Void TAppDecTop::create()
    6962{
    70   m_apcBitstream  = new TComBitstream;
    71  
    72   m_apcBitstream->create( BITS_BUF_SIZE );
    7363}
    7464
    7565Void TAppDecTop::destroy()
    7666{
    77   if ( m_apcBitstream )
    78   {
    79     m_apcBitstream->destroy();
    80     delete m_apcBitstream;
    81     m_apcBitstream = NULL;
    82   }
    83   if( m_pchBitstreamFile )
    84   {
    85     free(m_pchBitstreamFile);
    86   }
    87   if( m_pchReconFile )
    88   {
    89     free(m_pchReconFile);
    90   }
    9167}
    9268
     
    10581Void TAppDecTop::decode()
    10682{
    107   TComBitstream*      pcBitstream = m_apcBitstream;
    108   UInt                uiPOC;
    109   TComList<TComPic*>* pcListPic;
    110   Bool bFirstSliceDecoded = true;
    111 
    112   // create & initialize internal classes
    113   xCreateDecLib();
    114   xInitDecLib  ();
    115 #if DCM_SKIP_DECODING_FRAMES
    116 //  m_iPOCLastDisplay += m_iSkipFrame;      // set the last displayed POC correctly for skip forward.
    117 #endif
    118 
    119   // main decoder loop
    120   Bool  bEos        = false;
    121   Bool resizedBitstreamBuffer = false;
    122  
    123   Bool bIsDepth = false;
    124   Int iViewIdx = 0;
    125   TComSPS cComSPS ;
    126   NalUnitType eNalUnitType;
    127 
    128 #if FLEX_CODING_ORDER
    129   Int iDepthViewIdx = 0;
    130   Bool bCountDepthViewIdx = false;              // a flag which avoid repeating assign a value to iDepthViewIdx   
    131   Bool bNewPictureType =true;
    132   Bool bFirstDepth = false;
    133 #endif
    134  
    135   while ( !bEos )
    136   {
    137     streampos  lLocation = m_cTVideoIOBitstreamFile.getFileLocation();
    138     bEos                 = m_cTVideoIOBitstreamFile.readBits( pcBitstream );
    139     if (bEos)
    140     {
    141       //if (!bFirstSliceDecoded) m_cTDecTop.decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_iPOCLastDisplay);
    142       if( bIsDepth )
    143       {
    144 #if FLEX_CODING_ORDER
    145                   if (!bFirstSliceDecoded) m_acTDecDepthTopList[iDepthViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iDepthViewIdx] ,bNewPictureType);
    146                   m_acTDecDepthTopList[iDepthViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iDepthViewIdx]);
    147 
    148 #else
    149         if (!bFirstSliceDecoded) m_acTDecDepthTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iViewIdx] );
    150         m_acTDecDepthTopList[iViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iViewIdx]);
    151 #endif
    152       }
    153       else
    154       {
    155 #if FLEX_CODING_ORDER
    156                   if (!bFirstSliceDecoded) m_acTDecTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx], bNewPictureType);
    157 #else
    158         if (!bFirstSliceDecoded) m_acTDecTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx] );
    159 #endif
    160                 m_acTDecTopList[iViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx]);
    161       }
    162       if( pcListPic )
    163       {
    164         // write reconstuction to file
    165         xWriteOutput( pcListPic );
    166       }
    167       break;
    168     }
    169    
    170     // call actual decoding function
    171 #if DCM_SKIP_DECODING_FRAMES
    172     Bool bNewPicture;
    173     if( bIsDepth )
    174 #if FLEX_CODING_ORDER
    175                   bNewPicture = m_acTDecDepthTopList[iDepthViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iDepthViewIdx], bNewPictureType);
    176 #else
    177       bNewPicture = m_acTDecDepthTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iViewIdx] );
    178 #endif
    179     else
    180 #if FLEX_CODING_ORDER
    181                 bNewPicture = m_acTDecTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx], bNewPictureType );
    182 #else
    183       bNewPicture = m_acTDecTopList[iViewIdx]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx] );
    184 #endif
    185     bFirstSliceDecoded   = true;
    186 
    187 #if FLEX_CODING_ORDER
    188           if (eNalUnitType == NAL_UNIT_SPS)
    189           {
    190                   if( cComSPS.isDepth() && (m_bUsingDepth==false) )  // expected not using depth, but bitstream are using depth
    191                   {                                                     // know from sps
    192                           assert( cComSPS.getViewId() == 0 && iDepthViewIdx == 0 && !bIsDepth );
    193                           startUsingDepth() ;
    194                   }
    195                   if (cComSPS.isDepth())
    196                   {
    197                           if (cComSPS.getViewId() >= m_acTVideoIOYuvDepthReconFileList.size())
    198                           {
    199                                   assert( cComSPS.getViewId() == m_acTVideoIOYuvReconFileList.size() );
    200                                   increaseNumberOfViews(cComSPS.getViewId()+1);
    201                           }
    202                        
    203                           m_acTDecDepthTopList[cComSPS.getViewId()]->setSPS(cComSPS);
    204                   }
    205                   else
    206                   {
    207                           if (cComSPS.getViewId() >= m_acTVideoIOYuvReconFileList.size())
    208                           {
    209                                   assert( cComSPS.getViewId() == m_acTVideoIOYuvReconFileList.size() );
    210                                   increaseNumberOfViews(cComSPS.getViewId()+1);
    211                           }
    212                           m_acTDecTopList[cComSPS.getViewId()]->setSPS(cComSPS);
    213                   }
    214                   bEos = m_cTVideoIOBitstreamFile.readBits( pcBitstream );
    215                   assert( !bEos);
    216                   if( cComSPS.isDepth() )
    217                           m_acTDecDepthTopList[cComSPS.getViewId()]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[cComSPS.getViewId()], bNewPictureType); // decode PPS
    218                   else
    219                           m_acTDecTopList[cComSPS.getViewId()]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[cComSPS.getViewId()], bNewPictureType); // decode PPS
    220                   assert( eNalUnitType == NAL_UNIT_PPS );
    221           }
    222 #else
    223 
    224     if( eNalUnitType == NAL_UNIT_SPS )
    225     {
    226       if( cComSPS.isDepth() && (m_bUsingDepth==false) )  // expected not using depth, but bitstream are using depth
    227       {                                                     // know from sps
    228         assert( cComSPS.getViewId() == 0 && iViewIdx == 0 && !bIsDepth );
    229         startUsingDepth() ;
    230       }
    231       if( cComSPS.isDepth() && !bIsDepth )
    232       {
    233         assert( cComSPS.getViewId() == iViewIdx );
    234         m_acTDecDepthTopList[iViewIdx]->setSPS(cComSPS);
    235       }
    236       else if( cComSPS.getViewId() >= m_acTVideoIOYuvReconFileList.size() ) // expecting iViewIdx, but got cComSPS.getViewIdx()
    237       {
    238         assert( cComSPS.getViewId() == m_acTVideoIOYuvReconFileList.size() );
    239         assert( !cComSPS.isDepth() );
    240         increaseNumberOfViews(cComSPS.getViewId()+1);
    241         m_acTDecTopList[cComSPS.getViewId()]->setSPS(cComSPS);
    242       }
    243       bEos = m_cTVideoIOBitstreamFile.readBits( pcBitstream );
    244       assert( !bEos);
    245       if( cComSPS.isDepth() )
    246         m_acTDecDepthTopList[cComSPS.getViewId()]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiDepthPOCLastDisplayList[cComSPS.getViewId()]); // decode PPS
    247       else
    248         m_acTDecTopList[cComSPS.getViewId()]->decode( bEos, pcBitstream, uiPOC, pcListPic, eNalUnitType, cComSPS, m_iSkipFrame, m_aiPOCLastDisplayList[cComSPS.getViewId()]); // decode PPS
    249       assert( eNalUnitType == NAL_UNIT_PPS );
    250     }
    251 
    252 #endif
    253     assert( eNalUnitType != NAL_UNIT_SEI ); // not yet supported for MVC
    254     if (bNewPicture)
    255     {
    256       if( bIsDepth )
    257 #if FLEX_CODING_ORDER
    258         m_acTDecDepthTopList[iDepthViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iDepthViewIdx]);
    259 #else
    260         m_acTDecDepthTopList[iViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiDepthPOCLastDisplayList[iViewIdx]);
    261 #endif
    262       else
    263         m_acTDecTopList[iViewIdx]->executeDeblockAndAlf( bEos, pcBitstream, uiPOC, pcListPic, m_iSkipFrame, m_aiPOCLastDisplayList[iViewIdx]);
    264       if (!m_cTVideoIOBitstreamFile.good()) m_cTVideoIOBitstreamFile.clear();
    265       m_cTVideoIOBitstreamFile.setFileLocation( lLocation );
    266       bFirstSliceDecoded = false;
    267 
    268 #if FLEX_CODING_ORDER
    269       if (m_bUsingDepth)
    270       {
    271         bIsDepth = bNewPictureType;       
    272 
    273       }
    274       if (bCountDepthViewIdx == false )
    275       {
    276         bCountDepthViewIdx = true;
    277         if (bIsDepth == true)
    278         {
    279           bFirstDepth = true;
    280           bCountDepthViewIdx = true;
    281         }
    282         if (!bFirstDepth && !bIsDepth)
    283         {
    284           iViewIdx++;
    285           bCountDepthViewIdx = false;
    286         }
    287 
    288       }
    289       else
    290       {
    291         if (bIsDepth)
    292         {
    293           iDepthViewIdx++;
    294         }
    295         else
    296         {
    297           iViewIdx ++;
    298         }
    299 
    300         if (iViewIdx >= m_acTDecTopList.size() || iDepthViewIdx >= m_acTDecDepthTopList.size())
    301         {
    302           bFirstDepth = false;
    303           iViewIdx = 0;
    304           iDepthViewIdx = 0;
    305           bCountDepthViewIdx = false;
    306           // end of access unit: delete extra pic buffers
    307           Int iNumViews = (Int)m_acTVideoIOYuvReconFileList.size();
    308           for( Int iVId = 0; iVId < iNumViews; iVId++ )
    309           {
    310             if( iVId < (Int)m_acTDecTopList.size() &&  m_acTDecTopList[iVId] )
    311             {
    312               m_acTDecTopList[iVId]->deleteExtraPicBuffers( (Int)uiPOC );
    313             }
    314             if( iVId < (Int)m_acTDecDepthTopList.size() && m_acTDecDepthTopList[iVId] )
    315             {
    316               m_acTDecDepthTopList[iVId]->deleteExtraPicBuffers( (Int)uiPOC );
    317             }
    318           }
    319 
    320 #if AMVP_BUFFERCOMPRESS
    321           // compress motion for entire access unit
    322           for( Int iVId = 0; iVId < iNumViews; iVId++ )
    323           {
    324             if( iVId < (Int)m_acTDecTopList.size() &&  m_acTDecTopList[iVId] )
    325             {
    326               m_acTDecTopList[iVId]->compressMotion( (Int)uiPOC );
    327             }
    328             if( iVId < (Int)m_acTDecDepthTopList.size() && m_acTDecDepthTopList[iVId] )
    329             {
    330               m_acTDecDepthTopList[iVId]->compressMotion( (Int)uiPOC );
    331             }
    332           }
    333 #endif
    334         }
    335       }
    336          
    337 #else
    338 
    339       if( m_bUsingDepth && !bIsDepth )
    340       {
    341         bIsDepth = true;
    342       }
    343       else
    344       {
    345         bIsDepth = false;
    346         if( iViewIdx<m_acTDecTopList.size()-1)
    347         {
    348           iViewIdx++ ;
    349         }
    350         else
    351         {
    352           iViewIdx = 0;
    353 
    354           // end of access unit: delete extra pic buffers
    355           Int iNumViews = (Int)m_acTVideoIOYuvReconFileList.size();
    356           for( Int iVId = 0; iVId < iNumViews; iVId++ )
    357           {
    358             if( iVId < (Int)m_acTDecTopList.size() &&  m_acTDecTopList[iVId] )
    359             {
    360               m_acTDecTopList[iVId]->deleteExtraPicBuffers( (Int)uiPOC );
    361             }
    362             if( iVId < (Int)m_acTDecDepthTopList.size() && m_acTDecDepthTopList[iVId] )
    363             {
    364               m_acTDecDepthTopList[iVId]->deleteExtraPicBuffers( (Int)uiPOC );
    365             }
    366           }
    367 
    368 #if AMVP_BUFFERCOMPRESS
    369           // compress motion for entire access unit
    370           for( Int iVId = 0; iVId < iNumViews; iVId++ )
    371           {
    372             if( iVId < (Int)m_acTDecTopList.size() &&  m_acTDecTopList[iVId] )
    373             {
    374               m_acTDecTopList[iVId]->compressMotion( (Int)uiPOC );
    375             }
    376             if( iVId < (Int)m_acTDecDepthTopList.size() && m_acTDecDepthTopList[iVId] )
    377             {
    378               m_acTDecDepthTopList[iVId]->compressMotion( (Int)uiPOC );
    379             }
    380           }
    381 #endif
    382         }
    383           }
    384 #endif
    385     }
    386 #else
    387 #error
    388     m_cTDecTop.decode( bEos, pcBitstream, uiPOC, pcListPic );
    389 #endif
    390 
    391    
    392     if (!resizedBitstreamBuffer)
    393     {
    394       TComSPS *sps = m_acTDecTopList[0]->getSPS();
    395       if (sps)
    396       {
    397         pcBitstream->destroy();
    398         pcBitstream->create(sps->getWidth() * sps->getHeight() * 2);
    399         resizedBitstreamBuffer = true;
    400       }
    401     }
    402    
    403     if( pcListPic )
    404     {
    405       // write reconstuction to file
    406       xWriteOutput( pcListPic );
    407     }
    408   }
    409  
    410   // delete buffers
    411   for(Int i=0; i<m_acTDecTopList.size(); i++)
    412     m_acTDecTopList[i]->deletePicBuffer();
    413 
    414   if (m_bUsingDepth)
    415   {
    416     for(Int i=0; i<m_acTDecDepthTopList.size(); i++)
    417       m_acTDecDepthTopList[i]->deletePicBuffer();
    418   }
    419  
    420   // destroy internal classes
    421   xDestroyDecLib();
    422 }
    423 
    424 // ====================================================================================================================
    425 // Protected member functions
    426 // ====================================================================================================================
    427 
    428 Void TAppDecTop::xCreateDecLib()
    429 {
    430   // open bitstream file
    431   m_cTVideoIOBitstreamFile.openBits( m_pchBitstreamFile, false);  // read mode
    432 
    433   // create decoder class
    434 //  m_cTDecTop.create();
    435   m_acTDecTopList.push_back(new TDecTop) ;// at least one decoder
    436   m_acTDecTopList[0]->create() ;
    437 
    438   m_aiPOCLastDisplayList.push_back(-1+m_iSkipFrame) ;
     83  increaseNumberOfViews( 1 );
     84#if SONY_COLPIC_AVAILABILITY
     85  m_tDecTop[0]->setViewOrderIdx(0);
     86#endif
     87  Int                 viewDepthId = 0;
     88  Int                 previousViewDepthId  = 0;
     89  UInt                uiPOC[MAX_VIEW_NUM*2];
     90  TComList<TComPic*>* pcListPic[MAX_VIEW_NUM*2];
     91  Bool                newPicture[MAX_VIEW_NUM*2];
     92  Bool                previousPictureDecoded = false;
     93  for( Int i = 0; i < MAX_VIEW_NUM*2; i++ )
     94  {
     95    uiPOC[i] = 0;
     96    pcListPic[i] = NULL;
     97    newPicture[i] = false;
     98  }
     99
     100  ifstream bitstreamFile(m_pchBitstreamFile, ifstream::in | ifstream::binary);
     101  if (!bitstreamFile)
     102  {
     103    fprintf(stderr, "\nfailed to open bitstream file `%s' for reading\n", m_pchBitstreamFile);
     104    exit(EXIT_FAILURE);
     105  }
    439106
    440107  if( m_pchScaleOffsetFile )
     
    444111  }
    445112  m_cCamParsCollector.init( m_pScaleOffsetFile );
    446 }
     113
     114  InputByteStream bytestream(bitstreamFile);
     115
     116  while (!!bitstreamFile)
     117  {
     118    /* location serves to work around a design fault in the decoder, whereby
     119     * the process of reading a new slice that is the first slice of a new frame
     120     * requires the TDecTop::decode() method to be called again with the same
     121     * nal unit. */
     122    streampos location = bitstreamFile.tellg();
     123    AnnexBStats stats = AnnexBStats();
     124    vector<uint8_t> nalUnit;
     125    InputNALUnit nalu;
     126    byteStreamNALUnit(bytestream, nalUnit, stats);
     127
     128    // call actual decoding function
     129    if (nalUnit.empty())
     130    {
     131      /* this can happen if the following occur:
     132       *  - empty input file
     133       *  - two back-to-back start_code_prefixes
     134       *  - start_code_prefix immediately followed by EOF
     135       */
     136      fprintf(stderr, "Warning: Attempt to decode an empty NAL unit\n");
     137    }
     138    else
     139    {
     140      read(nalu, nalUnit);
     141      Int viewId = nalu.m_viewId;
     142      Int depth = nalu.m_isDepth ? 1 : 0;
     143      viewDepthId = viewId * 2 + depth;   // coding order T0D0T1D1T2D2
     144      newPicture[viewDepthId] = false;
     145      if( viewDepthId >= m_tDecTop.size() )     
     146      {
     147        increaseNumberOfViews( viewDepthId +1 );
     148      }
     149      if(m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer)
     150      {
     151        previousPictureDecoded = false;
     152      }
     153      if(m_tDecTop.size() > 1 && (viewDepthId != previousViewDepthId) && previousPictureDecoded )
     154      {
     155        m_tDecTop[previousViewDepthId]->executeDeblockAndAlf(uiPOC[previousViewDepthId], pcListPic[previousViewDepthId], m_iSkipFrame, m_pocLastDisplay[previousViewDepthId]);
     156      }
     157      if( ( viewDepthId == 0 && (viewDepthId != previousViewDepthId) ) || m_tDecTop.size() == 1 )
     158      {
     159#if HHI_INTER_VIEW_RESIDUAL_PRED
     160        for( Int i = 0; i < m_tDecTop.size(); i++ )
     161        {
     162          m_tDecTop[i]->deleteExtraPicBuffers( uiPOC[i] );
     163        }
     164#endif
     165        for( Int i = 0; i < m_tDecTop.size(); i++ )
     166        {
     167          m_tDecTop[i]->compressMotion( uiPOC[i] );
     168        }
     169      }   
     170      if( !(m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) )
     171      {
     172        newPicture[viewDepthId] = m_tDecTop[viewDepthId]->decode(nalu, m_iSkipFrame, m_pocLastDisplay[viewDepthId]);
     173        if (newPicture[viewDepthId])
     174        {
     175          bitstreamFile.clear();
     176          /* location points to the current nalunit payload[1] due to the
     177           * need for the annexB parser to read three extra bytes.
     178           * [1] except for the first NAL unit in the file
     179           *     (but bNewPicture doesn't happen then) */
     180          bitstreamFile.seekg(location-streamoff(3));
     181          bytestream.reset();
     182        }
     183        if( nalu.isSlice() )
     184        {
     185          previousPictureDecoded = true;
     186        }
     187      }
     188    }
     189    if( ( (newPicture[viewDepthId] || !bitstreamFile) && m_tDecTop.size() == 1) || (!bitstreamFile && previousPictureDecoded == true) ) 
     190    {
     191      m_tDecTop[viewDepthId]->executeDeblockAndAlf(uiPOC[viewDepthId], pcListPic[viewDepthId], m_iSkipFrame, m_pocLastDisplay[viewDepthId]);
     192    }
     193    if( pcListPic[viewDepthId] )
     194    {
     195      if( newPicture[viewDepthId] && (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR || (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDV && m_tDecTop[viewDepthId]->getNalUnitTypeBaseView() == NAL_UNIT_CODED_SLICE_IDR)) )
     196      {
     197        xFlushOutput( pcListPic[viewDepthId], viewDepthId );
     198      }
     199      // write reconstruction to file
     200      if(newPicture[viewDepthId])
     201      {
     202#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
     203        xWriteOutput( pcListPic[viewDepthId], viewDepthId, nalu.m_temporalId );
     204#else
     205        xWriteOutput( pcListPic[viewDepthId], viewDepthId );
     206#endif
     207      }
     208    }
     209    previousViewDepthId = viewDepthId;
     210  }
     211  // last frame
     212  for( Int viewDepthIdx = 0; viewDepthIdx < m_tDecTop.size(); viewDepthIdx++ )
     213  {
     214    xFlushOutput( pcListPic[viewDepthIdx], viewDepthIdx );
     215  } 
     216  xDestroyDecLib();
     217}
     218
     219// ====================================================================================================================
     220// Protected member functions
     221// ====================================================================================================================
    447222
    448223Void TAppDecTop::xDestroyDecLib()
    449224{
    450   // close bitstream file
    451   m_cTVideoIOBitstreamFile.closeBits();
    452 
    453   for(Int iViewIdx=0; iViewIdx<m_acTVideoIOYuvReconFileList.size() ; iViewIdx++)
    454   {
    455     m_acTVideoIOYuvReconFileList[iViewIdx]->close();
    456     delete m_acTVideoIOYuvReconFileList[iViewIdx]; m_acTVideoIOYuvReconFileList[iViewIdx] = NULL ;
    457   }
    458 
    459   // destroy decoder class
    460 //  m_cTDecTop.destroy();
    461   for(Int iViewIdx=0; iViewIdx<m_acTDecTopList.size() ; iViewIdx++)
    462   {
    463     m_acTDecTopList[iViewIdx]->destroy() ;
    464     delete m_acTDecTopList[iViewIdx] ; m_acTDecTopList[iViewIdx] = NULL ;
    465   }
    466 
    467   for(Int iViewIdx=0; iViewIdx<m_acTVideoIOYuvDepthReconFileList.size() ; iViewIdx++)
    468   {
    469     m_acTVideoIOYuvDepthReconFileList[iViewIdx]->close();
    470     delete m_acTVideoIOYuvDepthReconFileList[iViewIdx]; m_acTVideoIOYuvDepthReconFileList[iViewIdx] = NULL ;
    471   }
    472 
    473   for(Int iViewIdx=0; iViewIdx<m_acTDecDepthTopList.size() ; iViewIdx++)
    474   {
    475     m_acTDecDepthTopList[iViewIdx]->destroy() ;
    476     delete m_acTDecDepthTopList[iViewIdx] ; m_acTDecDepthTopList[iViewIdx] = NULL ;
    477   }
    478 
    479   m_cCamParsCollector.uninit();
    480   if( m_pScaleOffsetFile )
    481   {
    482     ::fclose( m_pScaleOffsetFile );
    483   }
    484 }
    485 
    486 Void TAppDecTop::xInitDecLib()
    487 {
    488   // initialize decoder class
    489   m_acTDecTopList[0]->init( this );
    490   m_acTDecTopList[0]->setViewIdx(0);
    491   m_acTDecTopList[0]->setPictureDigestEnabled(m_pictureDigestEnabled);
    492   m_acTDecTopList[0]->setCamParsCollector( &m_cCamParsCollector );
    493 #if SONY_COLPIC_AVAILABILITY
    494   m_acTDecTopList[0]->setViewOrderIdx(0);
    495 #endif
     225
     226  for(Int viewDepthIdx=0; viewDepthIdx<m_tVideoIOYuvReconFile.size() ; viewDepthIdx++)
     227  {
     228    if( m_tVideoIOYuvReconFile[viewDepthIdx] )
     229    {
     230      m_tVideoIOYuvReconFile[viewDepthIdx]->close();
     231      delete m_tVideoIOYuvReconFile[viewDepthIdx];
     232      m_tVideoIOYuvReconFile[viewDepthIdx] = NULL ;
     233    }
     234  }
     235
     236  for(Int viewDepthIdx=0; viewDepthIdx<m_tDecTop.size() ; viewDepthIdx++)
     237  {
     238    if( m_tDecTop[viewDepthIdx] )
     239    {
     240      if( !m_useDepth && (viewDepthIdx % 2 == 1) )
     241      {
     242      }
     243      else
     244      {
     245        m_tDecTop[viewDepthIdx]->deletePicBuffer();
     246        m_tDecTop[viewDepthIdx]->destroy() ;
     247      }
     248      delete m_tDecTop[viewDepthIdx] ;
     249      m_tDecTop[viewDepthIdx] = NULL ;
     250    }
     251  }
     252}
     253
     254#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
     255Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int viewDepthId, UInt tId )
     256#else
     257Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic, Int viewDepthId )
     258#endif
     259{
     260  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
     261  Int not_displayed = 0;
     262
     263  while (iterPic != pcListPic->end())
     264  {
     265    TComPic* pcPic = *(iterPic);
     266    if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[viewDepthId])
     267    {
     268       not_displayed++;
     269    }
     270    iterPic++;
     271  }
     272  iterPic   = pcListPic->begin();
     273 
     274  while (iterPic != pcListPic->end())
     275  {
     276    TComPic* pcPic = *(iterPic);
     277#if PIC_CROPPING
     278    TComSPS *sps = pcPic->getSlice(0)->getSPS();
     279#endif
     280   
     281#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
     282    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getSlice(0)->getSPS()->getNumReorderPics(tId) && pcPic->getPOC() > m_pocLastDisplay[viewDepthId]))
     283#else
     284    if ( pcPic->getOutputMark() && (not_displayed >  pcPic->getSlice(0)->getSPS()->getNumReorderFrames() && pcPic->getPOC() > m_pocLastDisplay[viewDepthId]))
     285#endif
     286    {
     287      // write to file
     288       not_displayed--;
     289      if ( m_pchReconFile )
     290      {
     291#if PIC_CROPPING
     292        m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() );
     293#else
     294        m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() );
     295#endif
     296      }
     297     
     298      // update POC of display order
     299      m_pocLastDisplay[viewDepthId] = pcPic->getPOC();
     300     
     301      // erase non-referenced picture in the reference picture list after display
     302      if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
     303      {
     304#if !DYN_REF_FREE
     305        pcPic->setReconMark(false);
     306       
     307        // mark it should be extended later
     308        pcPic->getPicYuvRec()->setBorderExtension( false );
     309       
     310#else
     311        pcPic->destroy();
     312        pcListPic->erase( iterPic );
     313        iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     314        continue;
     315#endif
     316      }
     317      pcPic->setOutputMark(false);
     318    }
     319   
     320    iterPic++;
     321  }
    496322}
    497323
    498324/** \param pcListPic list of pictures to be written to file
    499     \param bFirst    first picture?
    500325    \todo            DYN_REF_FREE should be revised
    501326 */
    502 Void TAppDecTop::xWriteOutput( TComList<TComPic*>* pcListPic )
    503 {
     327Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int viewDepthId )
     328{
     329  if(!pcListPic)
     330  {
     331    return;
     332  }
    504333  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
    505334
     335  iterPic   = pcListPic->begin();
     336 
    506337  while (iterPic != pcListPic->end())
    507338  {
    508339    TComPic* pcPic = *(iterPic);
    509     Int iViewIdx = pcPic->getViewIdx();
    510     Int bIsDepth = pcPic->getSlice(0)->getSPS()->isDepth() ;
    511 
    512     if (!bIsDepth)
    513     {
    514       if( m_acTVideoIOYuvReconFileList.size() < iViewIdx+1 )
    515             increaseNumberOfViews( iViewIdx+1 ) ;
    516 
    517       if ( pcPic->getReconMark() && pcPic->getPOC() == (m_aiPOCLastDisplayList[iViewIdx] + 1) )
    518       {
    519         // write to file
    520         if ( m_pchReconFile )
    521         {
    522           m_acTVideoIOYuvReconFileList[iViewIdx]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() );
    523         }
    524 
    525         // update POC of display order
    526         m_aiPOCLastDisplayList[iViewIdx] = pcPic->getPOC();
    527 
    528         // erase non-referenced picture in the reference picture list after display
    529         if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
    530         {
    531   #if !DYN_REF_FREE
    532           pcPic->setReconMark(false);
    533 
    534           // mark it should be extended later
    535           pcPic->getPicYuvRec()->setBorderExtension( false );
    536 
    537   #else
    538           pcPic->destroy();
    539           pcListPic->erase( iterPic );
    540           iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    541           continue;
    542   #endif
    543         }
    544       }
    545     } /// end !bIsDepth
    546     else
    547     {
    548       if( m_acTVideoIOYuvDepthReconFileList.size() < iViewIdx+1 )
    549              increaseNumberOfViews( iViewIdx+1 ) ;
    550 
    551       if ( pcPic->getReconMark() && pcPic->getPOC() == (m_aiDepthPOCLastDisplayList[iViewIdx] + 1) )
    552       {
    553         // write to file
    554         if ( m_pchReconFile )
    555         {
    556           m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() );
    557         }
    558 
    559         // update POC of display order
    560         m_aiDepthPOCLastDisplayList[iViewIdx] = pcPic->getPOC();
    561 
    562         // erase non-referenced picture in the reference picture list after display
    563         if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
    564         {
    565   #if !DYN_REF_FREE
    566           pcPic->setReconMark(false);
    567 
    568           // mark it should be extended later
    569           pcPic->getPicYuvRec()->setBorderExtension( false );
    570 
    571   #else
    572           pcPic->destroy();
    573           pcListPic->erase( iterPic );
    574           iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    575           continue;
    576   #endif
    577         }
    578       }
    579     } // end bIsDepth
    580 
     340#if PIC_CROPPING
     341    TComSPS *sps = pcPic->getSlice(0)->getSPS();
     342#endif
     343
     344    if ( pcPic->getOutputMark() )
     345    {
     346      // write to file
     347      if ( m_pchReconFile )
     348      {
     349#if PIC_CROPPING
     350        m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), sps->getPicCropLeftOffset(), sps->getPicCropRightOffset(), sps->getPicCropTopOffset(), sps->getPicCropBottomOffset() );
     351#else
     352        m_tVideoIOYuvReconFile[viewDepthId]->write( pcPic->getPicYuvRec(), pcPic->getSlice(0)->getSPS()->getPad() );
     353#endif
     354      }
     355     
     356      // update POC of display order
     357      m_pocLastDisplay[viewDepthId] = pcPic->getPOC();
     358     
     359      // erase non-referenced picture in the reference picture list after display
     360      if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
     361      {
     362#if !DYN_REF_FREE
     363        pcPic->setReconMark(false);
     364       
     365        // mark it should be extended later
     366        pcPic->getPicYuvRec()->setBorderExtension( false );
     367       
     368#else
     369        pcPic->destroy();
     370        pcListPic->erase( iterPic );
     371        iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     372        continue;
     373#endif
     374      }
     375      pcPic->setOutputMark(false);
     376    }
     377   
    581378    iterPic++;
    582379  }
    583 }
    584 
    585 Void TAppDecTop::startUsingDepth()
    586 {
    587   m_bUsingDepth = true ;
    588   increaseNumberOfViews( (Int)m_acTVideoIOYuvReconFileList.size() );
    589 }
    590 
    591 Void  TAppDecTop::increaseNumberOfViews  (Int iNewNumberOfViews)
    592 {
    593   while( m_acTVideoIOYuvReconFileList.size() < iNewNumberOfViews)
    594   {
    595     m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
    596 
    597 // GT FIX
    598     Char cBuffer[4]  ;
    599     sprintf(cBuffer,"_%i",(Int)m_acTVideoIOYuvReconFileList.size()-1 );
    600     Char* pchNextFilename;
    601     xAppendToFileNameEnd( m_pchReconFile, cBuffer, pchNextFilename);
    602 // GT FIX END
    603     if ( m_outputBitDepth == 0 )
    604       m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement;
    605     m_acTVideoIOYuvReconFileList.back()->open( pchNextFilename, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement );
    606     free (pchNextFilename);
    607   }
    608 
    609   while( m_aiPOCLastDisplayList.size() < iNewNumberOfViews )
    610     m_aiPOCLastDisplayList.push_back(-1+m_iSkipFrame) ;
    611 
    612   while( m_acTDecTopList.size() < iNewNumberOfViews)
    613   {
    614     m_acTDecTopList.push_back(new TDecTop) ;// at least one decoder
    615     m_acTDecTopList.back()->create() ;
    616     m_acTDecTopList.back()->init( this, false );
    617     m_acTDecTopList.back()->setViewIdx((Int)m_acTDecTopList.size()-1);
    618     m_acTDecTopList.back()->setPictureDigestEnabled(m_pictureDigestEnabled);
    619     m_acTDecTopList.back()->setCamParsCollector( &m_cCamParsCollector );
    620   }
    621   if( m_bUsingDepth )
    622   {
    623     while( m_acTVideoIOYuvDepthReconFileList.size() < iNewNumberOfViews  )
    624     {
    625       m_acTVideoIOYuvDepthReconFileList.push_back(new TVideoIOYuv);
    626 // GT FIX
     380  pcListPic->clear();
     381  m_pocLastDisplay[viewDepthId] = -MAX_INT;
     382}
     383
     384Void  TAppDecTop::increaseNumberOfViews  ( Int newNumberOfViewDepth )
     385{
     386  if ( m_outputBitDepth == 0 )
     387  {
     388    m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement;
     389  }
     390  Int viewId = (newNumberOfViewDepth-1)>>1;   // coding order T0D0T1D1T2D2
     391  Bool isDepth = ((newNumberOfViewDepth % 2) == 0);  // coding order T0D0T1D1T2D2
     392  if( isDepth )
     393    m_useDepth = true;
     394  while( m_tVideoIOYuvReconFile.size() < newNumberOfViewDepth)
     395  {
     396    m_tVideoIOYuvReconFile.push_back(new TVideoIOYuv);
     397    Char buffer[4];
     398    sprintf(buffer,"_%i", (Int)(m_tVideoIOYuvReconFile.size()-1) / 2 );
     399    Char* nextFilename = NULL;
     400    if( (m_tVideoIOYuvReconFile.size() % 2) == 0 )
     401    {
    627402      Char* pchTempFilename = NULL;
    628403      xAppendToFileNameEnd( m_pchReconFile, "_depth", pchTempFilename);
    629       Char cBuffer[4]  ;
    630       sprintf(cBuffer,"_%i",(Int)m_acTVideoIOYuvDepthReconFileList.size()-1 );
    631       Char* pchDepthFilename = NULL;
    632       xAppendToFileNameEnd( pchTempFilename, cBuffer, pchDepthFilename);
    633 // GT FIX END
    634       if ( m_outputBitDepth == 0 )
    635         m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement;
    636       m_acTVideoIOYuvDepthReconFileList.back()->open( pchDepthFilename, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement );
    637       free (pchTempFilename);
    638       free( pchDepthFilename );
    639     }
    640     while( m_aiDepthPOCLastDisplayList.size() < iNewNumberOfViews )
    641       m_aiDepthPOCLastDisplayList.push_back(-1+m_iSkipFrame) ;
    642     while( m_acTDecDepthTopList.size() < iNewNumberOfViews)
    643     {
    644       m_acTDecDepthTopList.push_back(new TDecTop) ;// at least one decoder
    645       m_acTDecDepthTopList.back()->create() ;
    646       m_acTDecDepthTopList.back()->init( this, false );
    647 #if FLEX_CODING_ORDER
    648       Int iNumofgen = (Int)m_acTDecDepthTopList.size();
    649       m_acTDecDepthTopList.back()->setViewIdx(iNumofgen-1);
    650 #else
    651           m_acTDecDepthTopList.back()->setViewIdx((Int)m_acTDecTopList.size()-1);
    652 #endif
    653 
    654       m_acTDecDepthTopList.back()->setPictureDigestEnabled(m_pictureDigestEnabled);
    655       m_acTDecDepthTopList.back()->setToDepth( true );
    656       m_acTDecDepthTopList.back()->setCamParsCollector( &m_cCamParsCollector );
    657     }
    658   }
    659 }
    660 
    661 
    662 // GT FIX
    663 std::vector<TComPic*> TAppDecTop::getSpatialRefPics( Int iViewIdx, Int iPoc, Bool bIsDepth ) // only for mvc functionality yet
    664 {
    665   std::vector<TComPic*> apcRefPics( iViewIdx, (TComPic*)NULL );
    666   for( int iRefViewIdx = 0; iRefViewIdx < iViewIdx; iRefViewIdx++ )
    667   {
    668     TComPic* pcRefPic = getPicFromView( iRefViewIdx, iPoc, bIsDepth );
     404      xAppendToFileNameEnd( pchTempFilename, buffer, nextFilename);
     405      free ( pchTempFilename );
     406    }
     407    else
     408    {
     409      xAppendToFileNameEnd( m_pchReconFile, buffer, nextFilename);
     410    }
     411    if( isDepth || ( !isDepth && (m_tVideoIOYuvReconFile.size() % 2) == 1 ) )
     412    {
     413      m_tVideoIOYuvReconFile.back()->open( nextFilename, true, m_outputBitDepth, g_uiBitDepth + g_uiBitIncrement );
     414    }
     415      free ( nextFilename );
     416  }
     417  while( m_pocLastDisplay.size() < newNumberOfViewDepth )
     418  {
     419    m_pocLastDisplay.push_back(-MAX_INT+m_iSkipFrame);
     420  }
     421  while( m_tDecTop.size() < newNumberOfViewDepth)
     422  {
     423    m_tDecTop.push_back(new TDecTop);
     424    if( isDepth || ( !isDepth && (m_tVideoIOYuvReconFile.size() % 2) == 1 ) )
     425    {
     426      m_tDecTop.back()->create();
     427      m_tDecTop.back()->init( this, newNumberOfViewDepth == 1);
     428      m_tDecTop.back()->setViewId( viewId );
     429      m_tDecTop.back()->setIsDepth( isDepth );
     430      m_tDecTop.back()->setPictureDigestEnabled(m_pictureDigestEnabled);
     431    }
     432  }
     433}
     434
     435TDecTop* TAppDecTop::getTDecTop( Int viewId, Bool isDepth )
     436{
     437  return m_tDecTop[(isDepth ? 1 : 0) + viewId * 2];  // coding order T0D0T1D1T2D2
     438}
     439
     440std::vector<TComPic*> TAppDecTop::getInterViewRefPics( Int viewId, Int poc, Bool isDepth, TComSPS* sps )
     441{
     442  std::vector<TComPic*> apcRefPics( sps->getNumberOfUsableInterViewRefs(), (TComPic*)NULL );
     443  for( Int k = 0; k < sps->getNumberOfUsableInterViewRefs(); k++ )
     444  {
     445    TComPic* pcRefPic = xGetPicFromView( sps->getUsableInterViewRef( k ) + viewId, poc, isDepth );
    669446    assert( pcRefPic != NULL );
    670     apcRefPics[iRefViewIdx] = pcRefPic;
     447    apcRefPics[k] = pcRefPic;
    671448  }
    672449  return apcRefPics;
    673450}
    674451
    675 TComPic* TAppDecTop::getPicFromView( Int iViewIdx, Int iPoc, bool bIsDepth )
    676 {
    677   TComList<TComPic*>* apcListPic = (bIsDepth ? m_acTDecDepthTopList[iViewIdx] : m_acTDecTopList[iViewIdx])->getListPic();
    678   TComPic* pcRefPic = NULL;
     452TComPic* TAppDecTop::xGetPicFromView( Int viewId, Int poc, Bool isDepth )
     453{
     454  assert( ( viewId >= 0 ) );
     455
     456  TComList<TComPic*>* apcListPic = getTDecTop( viewId, isDepth )->getListPic();
     457  TComPic* pcPic = NULL;
    679458  for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ )
    680459  {
    681     if( (*it)->getPOC() == iPoc )
    682     {
    683       pcRefPic = *it;
     460    if( (*it)->getPOC() == poc )
     461    {
     462      pcPic = *it;
    684463      break;
    685464    }
    686465  }
    687   return pcRefPic;
    688 }
     466  return pcPic;
     467}
     468//! \}
  • trunk/source/App/TAppDecoder/TAppDecTop.h

    r21 r56  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license.
     4 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2011, ISO/IEC
     6 * Copyright (c) 2010-2012, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    1515 *    this list of conditions and the following disclaimer in the documentation
    1616 *    and/or other materials provided with the distribution.
    17  *  * Neither the name of the ISO/IEC nor the names of its contributors may
     17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    1818 *    be used to endorse or promote products derived from this software without
    1919 *    specific prior written permission.
     
    3232 */
    3333
    34 
    35 
    3634/** \file     TAppDecTop.h
    3735    \brief    Decoder application class (header)
     
    4543#endif // _MSC_VER > 1000
    4644
    47 #include "../../Lib/TLibVideoIO/TVideoIOYuv.h"
    48 #include "../../Lib/TLibVideoIO/TVideoIOBits.h"
    49 #include "../../Lib/TLibCommon/TComList.h"
    50 #include "../../Lib/TLibCommon/TComPicYuv.h"
    51 #include "../../Lib/TLibCommon/TComBitStream.h"
    52 #include "../../Lib/TLibCommon/TComDepthMapGenerator.h"
    53 #include "../../Lib/TLibDecoder/TDecTop.h"
     45#include "TLibVideoIO/TVideoIOYuv.h"
     46#include "TLibCommon/TComList.h"
     47#include "TLibCommon/TComPicYuv.h"
     48#include "TLibCommon/TComDepthMapGenerator.h"
     49#include "TLibDecoder/TDecTop.h"
    5450#include "TAppDecCfg.h"
     51
     52//! \ingroup TAppDecoder
     53//! \{
    5554
    5655// ====================================================================================================================
     
    6362private:
    6463  // class interface
    65   std::vector<TDecTop*>           m_acTDecTopList;
    66   std::vector<TDecTop*>           m_acTDecDepthTopList;
    67   TComBitstream*                  m_apcBitstream;                 ///< bitstream class
    68   TVideoIOBitsStartCode           m_cTVideoIOBitstreamFile;       ///< file I/O class
    69   std::vector<TVideoIOYuv*>       m_acTVideoIOYuvReconFileList;
    70   std::vector<TVideoIOYuv*>       m_acTVideoIOYuvDepthReconFileList;
     64  std::vector<TDecTop*>           m_tDecTop;                      ///< decoder classes
    7165
    72   Bool m_bUsingDepth;
     66  std::vector<TVideoIOYuv*>       m_tVideoIOYuvReconFile;         ///< reconstruction YUV class
    7367
    7468  // for output control
    7569  Bool                            m_abDecFlag[ MAX_GOP ];         ///< decoded flag in one GOP
    76 //  Int                             m_iPOCLastDisplay;              ///< last POC in display order
    77 
    78   std::vector<Bool>               m_abDecFlagList;         ///< decoded flag in one GOP
    79   std::vector<Int>                m_aiPOCLastDisplayList;
    80   std::vector<Int>                m_aiDepthPOCLastDisplayList;
     70  std::vector<Int>                m_pocLastDisplay;               ///< last POC in display order
     71  Bool                            m_useDepth;
    8172
    8273  FILE*                           m_pScaleOffsetFile;
     
    9081  TAppDecTop();
    9182  virtual ~TAppDecTop() {}
    92 
     83 
    9384  Void  create            (); ///< create internal members
    9485  Void  destroy           (); ///< destroy internal members
    9586  Void  decode            (); ///< main decoding function
    96   Void  increaseNumberOfViews   (Int iNewNumberOfViews);
    97   Void  startUsingDepth() ;
     87  Void  increaseNumberOfViews   (Int newNumberOfViewDepth);
     88  TDecTop* getTDecTop     ( Int viewId, Bool isDepth );
    9889
    99 // GT FIX
    100   std::vector<TComPic*> getSpatialRefPics( Int iViewIdx, Int iPoc, Bool bIsDepth );
    101   TComPic* getPicFromView( Int iViewIdx, Int iPoc, bool bDepth );
    102 // GT FIX END
     90  std::vector<TComPic*> getInterViewRefPics( Int viewId, Int poc, Bool isDepth, TComSPS* sps );
     91  TComPic*              getPicFromView     ( Int viewId, Int poc, bool isDepth ) { return xGetPicFromView( viewId, poc, isDepth ); }
    10392
    10493#if DEPTH_MAP_GENERATION
    10594  TComSPSAccess*    getSPSAccess  () { return &m_cSPSAccess;   }
    10695  TComAUPicAccess*  getAUPicAccess() { return &m_cAUPicAccess; }
    107   TDecTop*          getDecTop0    () { return m_acTDecTopList[0]; }
     96  TDecTop*          getDecTop0    () { return m_tDecTop[0]; }
    10897#endif
    10998
    11099protected:
    111   Void  xCreateDecLib     (); ///< create internal classes
     100//  Void  xCreateDecLib     (); ///< create internal classes
    112101  Void  xDestroyDecLib    (); ///< destroy internal classes
    113   Void  xInitDecLib       (); ///< initialize decoder class
     102//  Void  xInitDecLib       (); ///< initialize decoder class
     103 
     104#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
     105  Void  xWriteOutput      ( TComList<TComPic*>* pcListPic, Int viewDepthId, UInt tId); ///< write YUV to file
     106#else
     107  Void  xWriteOutput      ( TComList<TComPic*>* pcListPic, Int viewDepthId ); ///< write YUV to file
     108#endif
     109  Void  xFlushOutput      ( TComList<TComPic*>* pcListPic, Int viewDepthId ); ///< flush all remaining decoded pictures to file
    114110
    115   Void  xWriteOutput      ( TComList<TComPic*>* pcListPic ); ///< write YUV to file
     111  TComPic* xGetPicFromView( Int viewId, Int poc, Bool isDepth );
    116112};
    117113
     114//! \}
    118115#endif
    119116
  • trunk/source/App/TAppDecoder/decmain.cpp

    r8 r56  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license.
     4 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2011, ISO/IEC
     6 * Copyright (c) 2010-2012, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    1515 *    this list of conditions and the following disclaimer in the documentation
    1616 *    and/or other materials provided with the distribution.
    17  *  * Neither the name of the ISO/IEC nor the names of its contributors may
     17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    1818 *    be used to endorse or promote products derived from this software without
    1919 *    specific prior written permission.
     
    3232 */
    3333
    34 
    35 
    3634/** \file     decmain.cpp
    3735    \brief    Decoder application main
     
    4240#include <time.h>
    4341#include "TAppDecTop.h"
     42
     43//! \ingroup TAppDecoder
     44//! \{
    4445
    4546bool g_md5_mismatch = false; ///< top level flag that indicates if there has been a decoding mismatch
     
    5556  // print information
    5657  fprintf( stdout, "\n" );
    57   fprintf( stdout, "HM %s based Multiview Video plus Depth coder: Decoder Version [%s]", HM_VERSION, NV_VERSION );
     58  fprintf( stdout, "3D-HTM Software: Decoder Version [%s] based on HM Version [%s]", NV_VERSION, HM_VERSION );
    5859  fprintf( stdout, NVM_ONOS );
    5960  fprintf( stdout, NVM_COMPILEDBY );
     
    9394}
    9495
    95 
     96//! \}
  • trunk/source/App/TAppEncoder/TAppEncCfg.cpp

    r42 r56  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license.
     4 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2011, ISO/IEC
     6 * Copyright (c) 2010-2012, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    1515 *    this list of conditions and the following disclaimer in the documentation
    1616 *    and/or other materials provided with the distribution.
    17  *  * Neither the name of the ISO/IEC nor the names of its contributors may
     17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    1818 *    be used to endorse or promote products derived from this software without
    1919 *    specific prior written permission.
     
    3232 */
    3333
    34 
    35 
    3634/** \file     TAppEncCfg.cpp
    3735    \brief    Handle encoder configuration parameters
     
    3937
    4038#include <stdlib.h>
    41 #include <math.h>
    4239#include <cassert>
    4340#include <cstring>
    4441#include <string>
     42#include "TLibCommon/TComRom.h"
    4543#include "TAppEncCfg.h"
    46 #include "../../App/TAppCommon/program_options_lite.h"
    47 
     44#include "TAppCommon/program_options_lite.h"
     45
     46#ifdef WIN32
     47#define strdup _strdup
     48#endif
    4849
    4950using namespace std;
    5051namespace po = df::program_options_lite;
     52
     53//! \ingroup TAppEncoder
     54//! \{
    5155
    5256/* configuration helper funcs */
     
    6266 */
    6367#define MAX_PAD_SIZE                16
    64 #define MAX_INPUT_VIEW_NUM          10
    65 #define MAX_ERREF_VIEW_NUM          15
    6668
    6769// ====================================================================================================================
     
    7274{
    7375  m_aidQP = NULL;
    74 #if HHI_VSO
    75   m_aaiERViewRefLutInd.resize( MAX_INPUT_VIEW_NUM );
    76 #endif
    7776}
    7877
     
    8887      free (m_pchInputFileList[i]);
    8988  }
    90 
    9189  for(Int i = 0; i< m_pchDepthInputFileList.size(); i++ )
    9290  {
     
    9492      free (m_pchDepthInputFileList[i]);
    9593  }
    96 
    9794  for(Int i = 0; i< m_pchReconFileList.size(); i++ )
    9895  {
     
    10097      free (m_pchReconFileList[i]);
    10198  }
    102 
    103   for(Int i = 0; i< m_pchERRefFileList.size(); i++ )
    104   {
    105     if ( m_pchERRefFileList[i] != NULL )
    106       free (m_pchERRefFileList[i]);
    107   }
    108 
     99  for(Int i = 0; i< m_pchDepthReconFileList.size(); i++ )
     100  {
     101    if ( m_pchDepthReconFileList[i] != NULL )
     102      free (m_pchDepthReconFileList[i]);
     103  }
    109104  if (m_pchBitstreamFile != NULL)
    110105    free (m_pchBitstreamFile) ;
    111 
    112 #if FLEX_CODING_ORDER
    113   if (m_pchMVCJointCodingOrder != NULL)
    114   {
    115           free(m_pchMVCJointCodingOrder) ;
    116   }
    117 #endif
    118   for(Int i = 0; i< m_pchDepthReconFileList.size(); i++ )
    119   {
    120     if ( m_pchDepthReconFileList[i] != NULL )
    121       free (m_pchDepthReconFileList[i]);
    122   }
    123 
    124   if (m_pchCameraParameterFile != NULL)
    125     free (m_pchCameraParameterFile);
    126 
    127   if (m_pchBaseViewCameraNumbers != NULL)
    128     free (m_pchBaseViewCameraNumbers);
    129 
    130106#if HHI_VSO
    131107  if (  m_pchVSOConfig != NULL)
     
    141117Void TAppEncCfg::destroy()
    142118{
     119}
     120
     121std::istringstream &operator>>( std::istringstream &in, GOPEntryMvc &entry )     //input
     122{
     123  in>>entry.m_sliceType;
     124  in>>entry.m_POC;
     125  in>>entry.m_QPOffset;
     126  in>>entry.m_QPFactor;
     127  in>>entry.m_temporalId;
     128  in>>entry.m_numRefPicsActive;
     129  in>>entry.m_refPic;
     130  in>>entry.m_numRefPics;
     131  for ( Int i = 0; i < entry.m_numRefPics; i++ )
     132  {
     133    in>>entry.m_referencePics[i];
     134  }
     135  in>>entry.m_interRPSPrediction;
     136  if (entry.m_interRPSPrediction)
     137  {
     138    in>>entry.m_deltaRIdxMinus1;
     139    in>>entry.m_deltaRPS;
     140    in>>entry.m_numRefIdc;
     141    for ( Int i = 0; i < entry.m_numRefIdc; i++ )
     142    {
     143      in>>entry.m_refIdc[i];
     144    }
     145  }
     146  in>>entry.m_numInterViewRefPics;
     147  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
     148  {
     149    in>>entry.m_interViewRefs[i];
     150  }
     151  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
     152  {
     153    in>>entry.m_interViewRefPosL0[i];
     154  }
     155  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
     156  {
     157    in>>entry.m_interViewRefPosL1[i];
     158  }
     159  return in;
    143160}
    144161
     
    154171{
    155172  bool do_help = false;
    156 
    157   string cfg_InputFile;
     173 
    158174  string cfg_BitstreamFile;
    159   string cfg_ReconFile;
    160175  string cfg_dQPFile;
    161 
    162 #if FLEX_CODING_ORDER
    163   string cfg_JointCodingOrdering;
    164 #endif
    165 
     176  string cfg_ColumnWidth;
     177  string cfg_RowHeight;
     178  string cfg_ScalingListFile;
    166179  po::Options opts;
    167180  opts.addOptions()
    168181  ("help", do_help, false, "this help text")
    169182  ("c", po::parseConfigFile, "configuration file name")
    170 
     183 
    171184  /* File, I/O and source parameters */
    172   ("InputFile_%d,i_%d",       m_pchInputFileList,       (char *) 0 , MAX_INPUT_VIEW_NUM , "original Yuv input file name %d")
    173   ("DepthInputFile_%d,di_%d", m_pchDepthInputFileList,  (char *) 0 , MAX_INPUT_VIEW_NUM , "original Yuv depth input file name %d")
    174   ("ReconFile_%d,o_%d",       m_pchReconFileList,       (char *) 0 , MAX_INPUT_VIEW_NUM , "reconstructed Yuv output file name %d")
    175   ("DepthReconFile_%d,do_%d", m_pchDepthReconFileList,  (char *) 0 , MAX_INPUT_VIEW_NUM , "reconstructed Yuv depth output file name %d")
     185  ("InputFile_%d,i_%d",       m_pchInputFileList,       (char *) 0 , MAX_VIEW_NUM , "original Yuv input file name %d")
     186  ("DepthInputFile_%d,di_%d", m_pchDepthInputFileList,  (char *) 0 , MAX_VIEW_NUM , "original Yuv depth input file name %d")
     187  ("ReconFile_%d,o_%d",       m_pchReconFileList,       (char *) 0 , MAX_VIEW_NUM , "reconstructed Yuv output file name %d")
     188  ("DepthReconFile_%d,do_%d", m_pchDepthReconFileList,  (char *) 0 , MAX_VIEW_NUM , "reconstructed Yuv depth output file name %d")
    176189  ("BitstreamFile,b", cfg_BitstreamFile, string(""), "bitstream output file name")
    177 
    178190  ("CodeDepthMaps",         m_bUsingDepthMaps, false, "Encode depth maps" )
    179191  ("CodedCamParsPrecision", m_iCodedCamParPrecision, STD_CAM_PARAMETERS_PRECISION, "precision for coding of camera parameters (in units of 2^(-x) luma samples)" )
    180 
    181 #ifdef WEIGHT_PRED
    182   ("weighted_pred_flag,-wpP",     m_bUseWeightPred, false, "weighted prediction flag (P-Slices)")
    183   ("weighted_bipred_idc,-wpBidc", m_uiBiPredIdc,    0u,    "weighted bipred idc (B-Slices)")
    184 #endif
     192  ("LambdaModifier0,-LM0", m_adLambdaModifier[ 0 ], ( double )1.0, "Lambda modifier for temporal layer 0")
     193  ("LambdaModifier1,-LM1", m_adLambdaModifier[ 1 ], ( double )1.0, "Lambda modifier for temporal layer 1")
     194  ("LambdaModifier2,-LM2", m_adLambdaModifier[ 2 ], ( double )1.0, "Lambda modifier for temporal layer 2")
     195  ("LambdaModifier3,-LM3", m_adLambdaModifier[ 3 ], ( double )1.0, "Lambda modifier for temporal layer 3")
    185196  ("SourceWidth,-wdt",      m_iSourceWidth,  0, "Source picture width")
    186197  ("SourceHeight,-hgt",     m_iSourceHeight, 0, "Source picture height")
     198#if PIC_CROPPING
     199  ("CroppingMode",          m_croppingMode,  0, "Cropping mode (0: no cropping, 1:automatic padding, 2: padding, 3:cropping")
     200  ("CropLeft",              m_cropLeft,      0, "Left cropping/padding for cropping mode 3")
     201  ("CropRight",             m_cropRight,     0, "Right cropping/padding for cropping mode 3")
     202  ("CropTop",               m_cropTop,       0, "Top cropping/padding for cropping mode 3")
     203  ("CropBottom",            m_cropBottom,    0, "Bottom cropping/padding for cropping mode 3")
     204  ("HorizontalPadding,-pdx",m_aiPad[0],      0, "horizontal source padding for cropping mode 2")
     205  ("VerticalPadding,-pdy",  m_aiPad[1],      0, "vertical source padding for cropping mode 2")
     206#endif
    187207  ("InputBitDepth",         m_uiInputBitDepth, 8u, "bit-depth of input file")
    188208  ("BitDepth",              m_uiInputBitDepth, 8u, "deprecated alias of InputBitDepth")
    189209  ("OutputBitDepth",        m_uiOutputBitDepth, 0u, "bit-depth of output file")
    190 #if ENABLE_IBDI
    191   ("BitIncrement",          m_uiBitIncrement, 0xffffffffu, "bit-depth increasement")
    192 #endif
    193210  ("InternalBitDepth",      m_uiInternalBitDepth, 0u, "Internal bit-depth (BitDepth+BitIncrement)")
     211#if !PIC_CROPPING
    194212  ("HorizontalPadding,-pdx",m_aiPad[0],      0, "horizontal source padding size")
    195213  ("VerticalPadding,-pdy",  m_aiPad[1],      0, "vertical source padding size")
    196214  ("PAD",                   m_bUsePAD,   false, "automatic source padding of multiple of 16" )
     215#endif
    197216  ("FrameRate,-fr",         m_iFrameRate,        0, "Frame rate")
    198217  ("FrameSkip,-fs",         m_FrameSkip,         0u, "Number of frames to skip at start of input YUV")
    199218  ("FramesToBeEncoded,f",   m_iFrameToBeEncoded, 0, "number of frames to be encoded (default=all)")
    200219  ("FrameToBeEncoded",      m_iFrameToBeEncoded, 0, "depricated alias of FramesToBeEncoded")
    201 
     220 
    202221  ("NumberOfViews",         m_iNumberOfViews,    0, "Number of views")
    203 
    204 #if FLEX_CODING_ORDER
    205   ("FCO",               m_b3DVFlexOrder,   false, "flexible coding order flag" )
    206   ("CodingOrder",               cfg_JointCodingOrdering,  string(""), "The coding order for joint texture-depth coding")
    207 #endif
    208 
    209222  /* Unit definition parameters */
    210223  ("MaxCUWidth",          m_uiMaxCUWidth,  64u)
     
    214227  ("MaxCUSize,s",         m_uiMaxCUHeight, 64u, "max CU size")
    215228  ("MaxPartitionDepth,h", m_uiMaxCUDepth,   4u, "CU depth")
    216 
     229 
    217230  ("QuadtreeTULog2MaxSize", m_uiQuadtreeTULog2MaxSize, 6u)
    218231  ("QuadtreeTULog2MinSize", m_uiQuadtreeTULog2MinSize, 2u)
    219 
     232 
    220233  ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u)
    221234  ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u)
    222 
     235 
    223236  /* Coding structure paramters */
    224   ("CodedPictureStoreSize,cpss",  m_uiCodedPictureStoreSize, 16u, "Size of coded picture Buffer")
    225 #if DCM_DECODING_REFRESH
    226   ("DecodingRefreshType,-dr",m_iDecodingRefreshType, 0, "intra refresh, (0:none 1:CDR 2:IDR)")
    227 #endif
     237  ("IntraPeriod,-ip",m_iIntraPeriod, -1, "intra period in frames, (-1: only first frame)")
     238  ("DecodingRefreshType,-dr",m_iDecodingRefreshType, 0, "intra refresh, (0:none 1:CRA 2:IDR)")
    228239  ("GOPSize,g",      m_iGOPSize,      1, "GOP size of temporal structure")
    229   ("RateGOPSize,-rg",m_iRateGOPSize, -1, "GOP size of hierarchical QP assignment (-1: implies inherit GOPSize value)")
    230 #if !HHI_NO_LowDelayCoding
    231   ("LowDelayCoding",         m_bUseLDC,             false, "low-delay mode")
    232 #endif
    233 #if DCM_COMB_LIST
    234   ("ListCombination, -lc", m_bUseLComb, true, "combined reference list for uni-prediction in B-slices")
     240#if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
     241  ("MaxNumberOfReorderPictures",   m_numReorderFrames,               -1, "Max. number of reorder pictures: -1: encoder determines value, >=0: set explicitly")
     242  ("MaxNumberOfReferencePictures", m_maxNumberOfReferencePictures, 6, "Max. number of reference pictures")
     243#endif
     244  ("ListCombination,-lc", m_bUseLComb, true, "combined reference list flag for uni-prediction in B-slices")
    235245  ("LCModification", m_bLCMod, false, "enables signalling of combined reference list derivation")
    236 #endif
    237 
    238   ("GOPFormatString,gfs", m_cInputFormatString,  string(""), "Group of pictures")
    239 
     246  ("DisableInter4x4", m_bDisInter4x4, true, "Disable Inter 4x4")
     247  ("NSQT", m_enableNSQT, true, "Enable non-square transforms")
     248  ("AMP", m_enableAMP, true, "Enable asymmetric motion partitions")
    240249  /* motion options */
    241250  ("FastSearch", m_iFastSearch, 1, "0:Full search  1:Diamond  2:PMVFAST")
     
    244253  ("HadamardME", m_bUseHADME, true, "hadamard ME for fractional-pel")
    245254  ("ASR", m_bUseASR, false, "adaptive motion search range")
    246 
     255 
    247256  /* Quantization parameters */
    248257  ("QP,q",          m_adQP,     std::vector<double>(1,32), "Qp value, if value is float, QP is switched once during encoding, if two values are given the second is used for depth")
    249258  ("DeltaQpRD,-dqr",m_uiDeltaQpRD,       0u, "max dQp offset for slice")
    250259  ("MaxDeltaQP,d",  m_iMaxDeltaQP,        0, "max dQp offset for block")
    251   ("dQPFile,m",     m_pchdQPFile , (char*) 0, "dQP file name")
     260  ("MaxCuDQPDepth,-dqd",  m_iMaxCuDQPDepth,        0, "max depth for a minimum CuDQP")
     261
     262    ("ChromaQpOffset,   -cqo",   m_iChromaQpOffset,           0, "ChromaQpOffset")
     263    ("ChromaQpOffset2nd,-cqo2",  m_iChromaQpOffset2nd,        0, "ChromaQpOffset2nd")
     264
     265#if ADAPTIVE_QP_SELECTION
     266    ("AdaptiveQpSelection,-aqps",   m_bUseAdaptQpSelect,           false, "AdaptiveQpSelection")
     267#endif
     268
     269  ("AdaptiveQP,-aq", m_bUseAdaptiveQP, false, "QP adaptation based on a psycho-visual model")
     270  ("MaxQPAdaptationRange,-aqr", m_iQPAdaptationRange, 6, "QP adaptation range")
     271  ("dQPFile,m",     cfg_dQPFile, string(""), "dQP file name")
    252272  ("RDOQ",          m_abUseRDOQ, std::vector<Bool>(1,true), "Enable RDOQ")
    253   ("TemporalLayerQPOffset_L0,-tq0", m_aiTLayerQPOffset[0], 0, "QP offset of temporal layer 0")
    254   ("TemporalLayerQPOffset_L1,-tq1", m_aiTLayerQPOffset[1], 0, "QP offset of temporal layer 1")
    255   ("TemporalLayerQPOffset_L2,-tq2", m_aiTLayerQPOffset[2], 0, "QP offset of temporal layer 2")
    256   ("TemporalLayerQPOffset_L3,-tq3", m_aiTLayerQPOffset[3], 0, "QP offset of temporal layer 3")
    257   ("TemporalLayerQPOffset_L4,-tq4", m_aiTLayerQPOffset[4], 0, "QP offset of temporal layer 3")
    258   ("TemporalLayerQPOffset_L5,-tq5", m_aiTLayerQPOffset[5], 0, "QP offset of temporal layer 3")
    259   ("TemporalLayerQPOffset_L6,-tq6", m_aiTLayerQPOffset[6], 0, "QP offset of temporal layer 3")
    260   ("TemporalLayerQPOffset_L7,-tq7", m_aiTLayerQPOffset[7], 0, "QP offset of temporal layer 3")
    261   ("TemporalLayerQPOffset_L8,-tq8", m_aiTLayerQPOffset[8], 0, "QP offset of temporal layer 3")
    262   ("TemporalLayerQPOffset_L9,-tq9", m_aiTLayerQPOffset[9], 0, "QP offset of temporal layer 3")
     273  ("TemporalLayerQPOffset_L0,-tq0", m_aiTLayerQPOffset[0], MAX_QP + 1, "QP offset of temporal layer 0")
     274  ("TemporalLayerQPOffset_L1,-tq1", m_aiTLayerQPOffset[1], MAX_QP + 1, "QP offset of temporal layer 1")
     275  ("TemporalLayerQPOffset_L2,-tq2", m_aiTLayerQPOffset[2], MAX_QP + 1, "QP offset of temporal layer 2")
     276  ("TemporalLayerQPOffset_L3,-tq3", m_aiTLayerQPOffset[3], MAX_QP + 1, "QP offset of temporal layer 3")
     277 
     278#if !H0566_TLA
     279  ("TLayeringBasedOnCodingStruct,-tl", m_bTLayering, false, "Temporal ID is set based on the hierarchical coding structure")
     280 
     281  ("TLayerSwitchingFlag_L0,-ts0", m_abTLayerSwitchingFlag[0], false, "Switching flag for temporal layer 0")
     282  ("TLayerSwitchingFlag_L1,-ts1", m_abTLayerSwitchingFlag[1], false, "Switching flag for temporal layer 1")
     283  ("TLayerSwitchingFlag_L2,-ts2", m_abTLayerSwitchingFlag[2], false, "Switching flag for temporal layer 2")
     284  ("TLayerSwitchingFlag_L3,-ts3", m_abTLayerSwitchingFlag[3], false, "Switching flag for temporal layer 3")
     285#endif
    263286
    264287  /* Entropy coding parameters */
    265   ("SymbolMode,-sym", m_iSymbolMode, 1, "symbol mode (0=VLC, 1=SBAC)")
    266288  ("SBACRD", m_bUseSBACRD, true, "SBAC based RD estimation")
    267 
     289 
    268290  /* Deblocking filter parameters */
    269291  ("LoopFilterDisable", m_abLoopFilterDisable, std::vector<Bool>(1,false), "Disables LoopFilter")
    270   ("LoopFilterAlphaC0Offset", m_iLoopFilterAlphaC0Offset, 0)
    271   ("LoopFilterBetaOffset", m_iLoopFilterBetaOffset, 0 )
     292
     293  ("LoopFilterOffsetInAPS", m_loopFilterOffsetInAPS, false)
     294  ("LoopFilterBetaOffset_div2", m_loopFilterBetaOffsetDiv2, 0 )
     295  ("LoopFilterTcOffset_div2", m_loopFilterTcOffsetDiv2, 0 )
     296#if DBL_CONTROL
     297  ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, false)
     298#endif
    272299
    273300  /* Camera Paremetes */
     
    275302  ("BaseViewCameraNumbers" ,  m_pchBaseViewCameraNumbers,  (Char *) 0, "Numbers of base views")
    276303
    277 
    278     /* View Synthesis Optimization */
     304  /* View Synthesis Optimization */
    279305
    280306#if HHI_VSO
     
    293319#endif
    294320
    295     ("NumberOfExternalRefs",            m_iNumberOfExternalRefs   , 0             , "Number of virtual external reference views")
    296     ("ERRefFile_%d,er_%d",              m_pchERRefFileList        , (char *) 0    , MAX_ERREF_VIEW_NUM , "virtual external reference view file name %d")
    297     ("VSERViewReferences_%d,evr_%d"  ,  m_aaiERViewRefInd         , vector<Int>() , MAX_INPUT_VIEW_NUM, "Numbers of external virtual reference views to be used for this view")
    298     ("VSBaseViewReferences_%d,bvr_%d",  m_aaiBaseViewRefInd       , vector<Int>() , MAX_INPUT_VIEW_NUM, "Numbers of external virtual reference views to be used for this view")
     321#endif
     322
     323#if DEPTH_MAP_GENERATION
     324  ("PredDepthMapGen",  m_uiPredDepthMapGeneration, (UInt)0, "generation of prediction depth maps for motion data prediction" )
     325#endif
     326#if HHI_INTER_VIEW_MOTION_PRED
     327  ("MultiviewMvPred",  m_uiMultiviewMvPredMode,    (UInt)0, "usage of predicted depth maps" )
     328  ("MultiviewMvRegMode",        m_uiMultiviewMvRegMode,         (UInt)0, "regularization mode for multiview motion vectors" )
     329  ("MultiviewMvRegLambdaScale", m_dMultiviewMvRegLambdaScale, (Double)0, "lambda scale for multiview motion vector regularization" )
     330#endif
     331#if HHI_INTER_VIEW_RESIDUAL_PRED
     332  ("MultiviewResPred", m_uiMultiviewResPredMode,   (UInt)0, "usage of inter-view residual prediction" )
    299333#endif
    300334
    301335  /* Coding tools */
    302   ("MRG", m_bUseMRG, true, "merging of motion partitions")
    303 
    304 #if LM_CHROMA
    305336  ("LMChroma", m_bUseLMChroma, true, "intra chroma prediction based on recontructed luma")
    306 #endif
    307337
    308338  ("ALF", m_abUseALF, std::vector<Bool>(1,true), "Enables ALF")
    309 #if MTK_SAO
    310339  ("SAO", m_abUseSAO, std::vector<Bool>(1, true), "SAO")
    311 #endif
    312 
    313 #if MQT_ALF_NPASS
     340#if SAO_UNIT_INTERLEAVING
     341  ("MaxNumOffsetsPerPic", m_maxNumOffsetsPerPic, 2048, "2048: default")   
     342  ("SAOInterleaving", m_saoInterleavingFlag, false, "0: SAO Picture Mode, 1: SAO Interleaving ")   
     343#endif
     344
    314345  ("ALFEncodePassReduction", m_iALFEncodePassReduction, 0, "0:Original 16-pass, 1: 1-pass, 2: 2-pass encoding")
    315 #endif
    316 #if HHI_RMP_SWITCH
    317   ("RMP", m_bUseRMP ,true, "Rectangular motion partition" )
    318 #endif
    319 #ifdef ROUNDING_CONTROL_BIPRED
    320   ("RoundingControlBipred", m_useRoundingControlBipred, false, "Rounding control for bi-prediction")
    321 #endif
     346
     347  ("ALFMaxNumFilter,-ALFMNF", m_iALFMaxNumberFilters, 16, "16: No Constrained, 1-15: Constrained max number of filter")
     348#if LCU_SYNTAX_ALF
     349  ("ALFParamInSlice", m_bALFParamInSlice, false, "ALF parameters in 0: APS, 1: slice header")
     350  ("ALFPicBasedEncode", m_bALFPicBasedEncode, true, "ALF picture-based encoding 0: false, 1: true")
     351#endif
     352
    322353    ("SliceMode",            m_iSliceMode,           0, "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes")
    323354    ("SliceArgument",        m_iSliceArgument,       0, "if SliceMode==1 SliceArgument represents max # of LCUs. if SliceMode==2 SliceArgument represents max # of bytes.")
    324355    ("EntropySliceMode",     m_iEntropySliceMode,    0, "0: Disable all entropy slice limits, 1: Enforce max # of LCUs, 2: Enforce constraint based entropy slices")
    325356    ("EntropySliceArgument", m_iEntropySliceArgument,0, "if EntropySliceMode==1 SliceArgument represents max # of LCUs. if EntropySliceMode==2 EntropySliceArgument represents max # of bins.")
    326 #if MTK_NONCROSS_INLOOP_FILTER
     357    ("SliceGranularity",     m_iSliceGranularity,    0, "0: Slices always end at LCU borders. 1-3: slices may end at a depth of 1-3 below LCU level.")
    327358    ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true)
    328 #endif
    329 #if CONSTRAINED_INTRA_PRED
    330   ("ConstrainedIntraPred", m_bUseConstrainedIntraPred, false, "Constrained Intra Prediction")
    331 #endif
     359
     360    ("ConstrainedIntraPred", m_bUseConstrainedIntraPred, false, "Constrained Intra Prediction")
     361    ("PCMEnabledFlag", m_usePCM         , false)
     362    ("PCMLog2MaxSize", m_pcmLog2MaxSize, 5u)
     363    ("PCMLog2MinSize", m_uiPCMLog2MinSize, 3u)
     364
     365    ("PCMInputBitDepthFlag", m_bPCMInputBitDepthFlag, true)
     366    ("PCMFilterDisableFlag", m_bPCMFilterDisableFlag, false)
     367#if LOSSLESS_CODING
     368    ("LosslessCuEnabled", m_useLossless, false)
     369#endif
     370    ("weighted_pred_flag,-wpP",     m_bUseWeightPred, false, "weighted prediction flag (P-Slices)")
     371    ("weighted_bipred_idc,-wpBidc", m_uiBiPredIdc,    0u,    "weighted bipred idc (B-Slices)")
     372    ("TileInfoPresentFlag",         m_iColumnRowInfoPresent,         1,          "0: tiles parameters are NOT present in the PPS. 1: tiles parameters are present in the PPS")
     373    ("UniformSpacingIdc",           m_iUniformSpacingIdr,            0,          "Indicates if the column and row boundaries are distributed uniformly")
     374#if !REMOVE_TILE_DEPENDENCE
     375    ("TileBoundaryIndependenceIdc", m_iTileBoundaryIndependenceIdr,  1,          "Indicates if the column and row boundaries break the prediction")
     376#endif
     377    ("NumTileColumnsMinus1",        m_iNumColumnsMinus1,             0,          "Number of columns in a picture minus 1")
     378    ("ColumnWidthArray",            cfg_ColumnWidth,                 string(""), "Array containing ColumnWidth values in units of LCU")
     379    ("NumTileRowsMinus1",           m_iNumRowsMinus1,                0,          "Number of rows in a picture minus 1")
     380    ("RowHeightArray",              cfg_RowHeight,                   string(""), "Array containing RowHeight values in units of LCU")
     381    ("TileLocationInSliceHeaderFlag", m_iTileLocationInSliceHeaderFlag, 0,       "0: Disable transmission of tile location in slice header. 1: Transmit tile locations in slice header.")
     382    ("TileMarkerFlag",                m_iTileMarkerFlag,                0,       "0: Disable transmission of lightweight tile marker. 1: Transmit light weight tile marker.")
     383    ("MaxTileMarkerEntryPoints",    m_iMaxTileMarkerEntryPoints,    4,       "Maximum number of uniformly-spaced tile entry points (using light weigh tile markers). Default=4. If number of tiles < MaxTileMarkerEntryPoints then all tiles have entry points.")
     384    ("TileControlPresentFlag",       m_iTileBehaviorControlPresentFlag,         1,          "0: tiles behavior control parameters are NOT present in the PPS. 1: tiles behavior control parameters are present in the PPS")
     385    ("LFCrossTileBoundaryFlag",      m_bLFCrossTileBoundaryFlag,             true,          "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering")
     386    ("WaveFrontSynchro",            m_iWaveFrontSynchro,             0,          "0: no synchro; 1 synchro with TR; 2 TRR etc")
     387    ("WaveFrontFlush",              m_iWaveFrontFlush,               0,          "Flush and terminate CABAC coding for each LCU line")
     388    ("WaveFrontSubstreams",         m_iWaveFrontSubstreams,          1,          "# coded substreams wanted; per tile if TileBoundaryIndependenceIdc is 1, otherwise per frame")
     389    ("ScalingList",                 m_useScalingListId,              0,          "0: no scaling list, 1: default scaling lists, 2: scaling lists specified in ScalingListFile")
     390    ("ScalingListFile",             cfg_ScalingListFile,             string(""), "Scaling list file name")
     391#if MULTIBITS_DATA_HIDING
     392    ("SignHideFlag,-SBH",                m_signHideFlag, 1)
     393    ("SignHideThreshold,-TSIG",          m_signHidingThreshold,         4)
     394#endif
     395#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
     396  ("DMM",                         m_bUseDMM,                       false,      "depth model modes flag")
     397#endif
     398
    332399  /* Misc. */
    333   ("SEIpictureDigest", m_pictureDigestEnabled, false, "Control generation of picture_digest SEI messages\n"
     400  ("SEIpictureDigest", m_pictureDigestEnabled, true, "Control generation of picture_digest SEI messages\n"
    334401                                              "\t1: use MD5\n"
    335402                                              "\t0: disable")
     403
     404  ("TMVP", m_enableTMVP, true, "Enable TMVP" )
     405
    336406  ("FEN", m_bUseFastEnc, false, "fast encoder setting")
    337 
    338 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    339   ("DMM", m_bUseDMM, false, "add depth modes intra")
    340 #endif
    341 #if HHI_MPI
    342   ("MVI", m_bUseMVI, false, "use motion vector inheritance for depth map coding")
    343 #endif
    344 
    345   /* Multiview tools */
    346 #if DEPTH_MAP_GENERATION
    347   ("PredDepthMapGen",  m_uiPredDepthMapGeneration, (UInt)0, "generation of prediction depth maps for motion data prediction" )
    348 #endif
    349 #if HHI_INTER_VIEW_MOTION_PRED
    350   ("MultiviewMvPred",  m_uiMultiviewMvPredMode,    (UInt)0, "usage of predicted depth maps" )
    351   ("MultiviewMvRegMode",        m_uiMultiviewMvRegMode,         (UInt)0, "regularization mode for multiview motion vectors" )
    352   ("MultiviewMvRegLambdaScale", m_dMultiviewMvRegLambdaScale, (Double)0, "lambda scale for multiview motion vector regularization" )
    353 #endif
    354 #if HHI_INTER_VIEW_RESIDUAL_PRED
    355   ("MultiviewResPred", m_uiMultiviewResPredMode,   (UInt)0, "usage of inter-view residual prediction" )
    356 #endif
    357 
    358   ("QpChangeFrame", m_iQpChangeFrame, PicOrderCnt(0), "start frame for QP change")
    359   ("QpChangeOffsetVideo", m_iQpChangeOffsetVideo, 0, "QP change offset for video")
    360   ("QpChangeOffsetDepth", m_iQpChangeOffsetDepth, 0, "QP change offset for depth")
     407  ("ECU", m_bUseEarlyCU, false, "Early CU setting")
     408#if FAST_DECISION_FOR_MRG_RD_COST
     409  ("FDM", m_useFastDecisionForMerge, true, "Fast decision for Merge RD Cost")
     410#endif
     411  ("CFM", m_bUseCbfFastMode, false, "Cbf fast mode setting")
    361412#if HHI_INTERVIEW_SKIP
    362   ("InterViewSkip",  m_uiInterViewSkip,    (UInt)0, "usage of interview skip" )
     413  ("InterViewSkip",  m_bInterViewSkip,    false, "usage of interview skip" )
    363414#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
    364415  ("InterViewSkipLambdaScale",  m_dInterViewSkipLambdaScale,    (Double)8, "lambda scale for interview skip" )
    365416#endif
    366417#endif
    367 
    368418  /* Compatability with old style -1 FOO or -0 FOO options. */
    369419  ("1", doOldStyleCmdlineOn, "turn option <name> on")
    370420  ("0", doOldStyleCmdlineOff, "turn option <name> off")
     421#if HHI_MPI
     422  ("MVI", m_bUseMVI, false, "use motion vector inheritance for depth map coding")
     423#endif
    371424  ;
     425 
     426  // parse coding structure
     427  for( Int k = 0; k < MAX_VIEW_NUM; k++ )
     428  {
     429    if( k == 0 )
     430    {
     431      for( Int i = 1; i < MAX_GOP + 1; i++ )
     432      {
     433        std::ostringstream cOSS;
     434        cOSS<<"Frame"<<i;
     435        opts.addOptions()( cOSS.str(), m_GOPListsMvc[k][i-1], GOPEntryMvc() );
     436      }
     437    }
     438    else
     439    {
     440      std::ostringstream cOSS1;
     441      cOSS1<<"FrameI"<<"_v"<<k;
     442      opts.addOptions()(cOSS1.str(), m_GOPListsMvc[k][MAX_GOP], GOPEntryMvc());
     443
     444      for( Int i = 1; i < MAX_GOP + 1; i++ )
     445      {
     446        std::ostringstream cOSS2;
     447        cOSS2<<"Frame"<<i<<"_v"<<k;
     448        opts.addOptions()(cOSS2.str(), m_GOPListsMvc[k][i-1], GOPEntryMvc());
     449      }
     450    }
     451  }
    372452
    373453  po::setDefaults(opts);
     
    378458    fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it);
    379459  }
    380 
     460 
    381461  if (argc == 1 || do_help)
    382462  {
     
    386466    return false;
    387467  }
    388 
     468 
    389469  /*
    390470   * Set any derived parameters
     
    393473  m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
    394474  m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
    395 
    396 
    397 #if FLEX_CODING_ORDER
    398   m_pchMVCJointCodingOrder      = cfg_JointCodingOrdering.empty()?NULL:strdup(cfg_JointCodingOrdering.c_str());
    399   // If flexible order is enabled and if depth comes before the texture for a view, disable VSO
    400 
    401 #if HHI_VSO && DISABLE_FCO_FOR_VSO
    402   Bool depthComesFirst = false;
    403   if ( m_b3DVFlexOrder )
    404   {
    405     for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    406     {
    407       for ( Int ii=1; ii<12; ii+=2 )
    408       {
    409         Int iViewIdxCfg = (Int)(m_pchMVCJointCodingOrder[ii]-'0');
    410         if ( iViewIdxCfg == iViewIdx )
    411         {
    412           if ( m_pchMVCJointCodingOrder[ii-1]=='D' ) // depth comes first for this view
    413           {
    414             depthComesFirst = true;
    415             break;
    416           }
    417           else
    418           {
    419             assert(m_pchMVCJointCodingOrder[ii-1]=='T');
    420           }
    421         }
    422       }
    423     }
    424   }
    425   if (depthComesFirst)
    426   {
    427     m_bUseVSO = false;         
    428   }
    429 #endif
    430 #endif
    431 
    432 // GT FIX
     475 
     476  m_pchColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str());
     477  m_pchRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
     478  m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str());
     479 
    433480  if ( m_bUsingDepthMaps )
    434481  {
     
    448495    };
    449496  }
    450 // GT FIX END
    451 
    452   if (m_iRateGOPSize == -1)
    453   {
    454     /* if rateGOPSize has not been specified, the default value is GOPSize */
    455     m_iRateGOPSize = m_iGOPSize;
    456   }
    457 
    458   // compute source padding size
    459   if ( m_bUsePAD )
    460   {
    461     if ( m_iSourceWidth%MAX_PAD_SIZE )
    462     {
    463       m_aiPad[0] = (m_iSourceWidth/MAX_PAD_SIZE+1)*MAX_PAD_SIZE - m_iSourceWidth;
    464     }
    465 
    466     if ( m_iSourceHeight%MAX_PAD_SIZE )
    467     {
    468       m_aiPad[1] = (m_iSourceHeight/MAX_PAD_SIZE+1)*MAX_PAD_SIZE - m_iSourceHeight;
    469     }
    470   }
    471   m_iSourceWidth  += m_aiPad[0];
    472   m_iSourceHeight += m_aiPad[1];
    473 
    474 //GT QP Depth
    475497  if ( m_adQP.size() < 2 )
    476498  {
     
    481503    m_aiQP.push_back( (Int)( m_adQP[uiK] ) );
    482504  }
    483 //GT QP Depth end
     505
     506#if PIC_CROPPING
     507  switch (m_croppingMode)
     508  {
     509  case 0:
     510    {
     511      // no cropping or padding
     512      m_cropLeft = m_cropRight = m_cropTop = m_cropBottom = 0;
     513      m_aiPad[1] = m_aiPad[0] = 0;
     514      break;
     515    }
     516  case 1:
     517    {
     518      // automatic padding to minimum CU size
     519      Int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1);
     520      if (m_iSourceWidth % minCuSize)
     521      {
     522        m_aiPad[0] = m_cropRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
     523        m_iSourceWidth  += m_cropRight;
     524      }
     525      if (m_iSourceHeight % minCuSize)
     526      {
     527        m_aiPad[1] = m_cropBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
     528        m_iSourceHeight += m_cropBottom;
     529      }
     530      break;
     531    }
     532  case 2:
     533    {
     534      //padding
     535      m_iSourceWidth  += m_aiPad[0];
     536      m_iSourceHeight += m_aiPad[1];
     537      m_cropRight  = m_aiPad[0];
     538      m_cropBottom = m_aiPad[1];
     539      break;
     540    }
     541  case 3:
     542    {
     543      // cropping
     544      if ((m_cropLeft == 0) && (m_cropRight == 0) && (m_cropTop == 0) && (m_cropBottom == 0))
     545      {
     546        fprintf(stderr, "Warning: Cropping enabled, but all cropping parameters set to zero\n");
     547      }
     548      if ((m_aiPad[1] != 0) || (m_aiPad[0]!=0))
     549      {
     550        fprintf(stderr, "Warning: Cropping enabled, padding parameters will be ignored\n");
     551      }
     552      m_aiPad[1] = m_aiPad[0] = 0;
     553      break;
     554    }
     555  }
     556#else
     557
     558  // compute source padding size
     559  if ( m_bUsePAD )
     560  {
     561    if ( m_iSourceWidth%MAX_PAD_SIZE )
     562    {
     563      m_aiPad[0] = (m_iSourceWidth/MAX_PAD_SIZE+1)*MAX_PAD_SIZE - m_iSourceWidth;
     564    }
     565   
     566    if ( m_iSourceHeight%MAX_PAD_SIZE )
     567    {
     568      m_aiPad[1] = (m_iSourceHeight/MAX_PAD_SIZE+1)*MAX_PAD_SIZE - m_iSourceHeight;
     569    }
     570  }
     571  m_iSourceWidth  += m_aiPad[0];
     572  m_iSourceHeight += m_aiPad[1];
     573#endif
     574 
     575  // allocate slice-based dQP values
     576  m_aidQP = new Int[ m_iFrameToBeEncoded + m_iGOPSize + 1 ];
     577  m_aidQPdepth =  new Int[ m_iFrameToBeEncoded + m_iGOPSize + 1 ];
     578  ::memset( m_aidQP, 0, sizeof(Int)*( m_iFrameToBeEncoded + m_iGOPSize + 1 ) );
     579  ::memset( m_aidQPdepth, 0, sizeof(Int)*( m_iFrameToBeEncoded + m_iGOPSize + 1 ) );
     580 
     581  // handling of floating-point QP values
     582  // if QP is not integer, sequence is split into two sections having QP and QP+1
     583  m_aiQP[0] = (Int)( m_adQP[0] );
     584  if ( m_aiQP[0] < m_adQP[0] )
     585  {
     586    Int iSwitchPOC = (Int)( m_iFrameToBeEncoded - (m_adQP[0] - m_aiQP[0])*m_iFrameToBeEncoded + 0.5 );
     587   
     588    iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize;
     589    for ( Int i=iSwitchPOC; i<m_iFrameToBeEncoded + m_iGOPSize + 1; i++ )
     590    {
     591      m_aidQP[i] = 1;
     592    }
     593  }
     594
     595  m_aiQP[1] = (Int)( m_adQP[1] );
     596  if ( m_aiQP[1] < m_adQP[1] )
     597  {
     598    Int iSwitchPOC = (Int)( m_iFrameToBeEncoded - (m_adQP[1] - m_aiQP[1])*m_iFrameToBeEncoded + 0.5 );
     599
     600    iSwitchPOC = (Int)( (Double)iSwitchPOC / m_iGOPSize + 0.5 )*m_iGOPSize;
     601    for ( Int i=iSwitchPOC; i<m_iFrameToBeEncoded + m_iGOPSize + 1; i++ )
     602    {
     603      m_aidQPdepth[i] = 1;
     604    }
     605  }
     606
     607  // reading external dQP description from file
     608  if ( m_pchdQPFile )
     609  {
     610    FILE* fpt=fopen( m_pchdQPFile, "r" );
     611    if ( fpt )
     612    {
     613      Int iValue;
     614      Int iPOC = 0;
     615      while ( iPOC < m_iFrameToBeEncoded )
     616      {
     617        if ( fscanf(fpt, "%d", &iValue ) == EOF ) break;
     618        m_aidQP[ iPOC ] = iValue;
     619        iPOC++;
     620      }
     621      fclose(fpt);
     622    }
     623  }
    484624
    485625#if HHI_VSO
     
    516656
    517657#if HHI_VSO
    518   if ( m_bUseVSO )
    519   {
    520     if ( m_iNumberOfExternalRefs != 0 )
    521     {
    522       xCleanUpVector( m_aaiERViewRefInd,    vector<Int>() );
    523       xCleanUpVector( m_aaiBaseViewRefInd,  vector<Int>() );
    524     }
    525     else
    526     {
    527       m_aaiERViewRefInd   .clear();
    528       m_aaiERViewRefInd   .resize( m_iNumberOfViews );
    529       m_aaiERViewRefLutInd.clear();
    530       m_aaiERViewRefLutInd.resize( m_iNumberOfViews );
    531       m_aaiBaseViewRefInd .clear();
    532       m_aaiBaseViewRefInd .resize( m_iNumberOfViews );
    533     }
    534   }
    535658
    536659#if HHI_VSO_LS_TABLE
     
    549672#endif
    550673
    551   // set global variables
     674 // set global variables
    552675  xSetGlobal();
    553676
     
    611734  xCheckParameter();
    612735  m_cCameraData.check( false, true );
    613 
     736 
    614737  // print-out parameters
    615738  xPrintParameter();
    616 
     739 
    617740  return true;
    618741}
     
    629752#define xConfirmPara(a,b) check_failed |= confirmPara(a,b)
    630753  // check range of parameters
    631 #if ENABLE_IBDI
    632   xConfirmPara( m_uiInternalBitDepth > 0 && (int)m_uiBitIncrement != -1,                    "InternalBitDepth and BitIncrement may not be specified simultaneously");
     754  xConfirmPara( m_uiInputBitDepth < 8,                                                      "InputBitDepth must be at least 8" );
     755  xConfirmPara( m_iFrameRate <= 0,                                                          "Frame rate must be more than 1" );
     756  xConfirmPara( m_iFrameToBeEncoded <= 0,                                                   "Total Number Of Frames encoded must be more than 0" );
     757  xConfirmPara( m_iGOPSize < 1 ,                                                            "GOP Size must be greater or equal to 1" );
     758  xConfirmPara( m_iGOPSize > 1 &&  m_iGOPSize % 2,                                          "GOP Size must be a multiple of 2, if GOP Size is greater than 1" );
     759  xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" );
     760  xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2,                   "Decoding Refresh Type must be equal to 0, 1 or 2" );
     761#if H0736_AVC_STYLE_QP_RANGE
     762  xConfirmPara( m_aiQP[0] < -6 * ((Int)m_uiInternalBitDepth - 8) || m_aiQP[0] > 51,         "QP exceeds supported range (-QpBDOffsety to 51)" );
     763  if ( m_aiQP.size() >= 2 )
     764  {
     765    xConfirmPara( m_aiQP[1] < -6 * ((Int)m_uiInternalBitDepth - 8) || m_aiQP[1] > 51,       "QP depth exceeds supported range (-QpBDOffsety to 51)" );
     766  }
    633767#else
    634   xConfirmPara( m_uiInputBitDepth < 8,                                                      "InputBitDepth must be at least 8" );
    635 #endif
    636   xConfirmPara( m_iFrameRate <= 0,                                                          "Frame rate must be more than 1" );
    637   xConfirmPara( m_iFrameToBeEncoded <= 0,                                                   "Total Number Of Frames encoded must be more than 1" );
    638   xConfirmPara( m_iGOPSize < 1 ,                                                            "GOP Size must be more than 1" );
    639 #if DCM_DECODING_REFRESH
    640   xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2,                   "Decoding Refresh Type must be equal to 0, 1 or 2" );
    641 #endif
    642 //GT QP Depth
    643768  xConfirmPara( m_aiQP[0] < 0 || m_aiQP[0] > 51,                                             "QP exceeds supported range (0 to 51)" );
    644769  if ( m_aiQP.size() >= 2 )
     
    646771    xConfirmPara( m_aiQP[1] < 0 || m_aiQP[1] > 51,                                           "QP Depth exceeds supported range (0 to 51)" );
    647772  }
    648 //GT QP Depth End
    649 #if MQT_ALF_NPASS
     773#endif
    650774  xConfirmPara( m_iALFEncodePassReduction < 0 || m_iALFEncodePassReduction > 2,             "ALFEncodePassReduction must be equal to 0, 1 or 2");
    651 #endif
    652   xConfirmPara( m_iLoopFilterAlphaC0Offset < -26 || m_iLoopFilterAlphaC0Offset > 26,        "Loop Filter Alpha Offset exceeds supported range (-26 to 26)" );
    653   xConfirmPara( m_iLoopFilterBetaOffset < -26 || m_iLoopFilterBetaOffset > 26,              "Loop Filter Beta Offset exceeds supported range (-26 to 26)");
     775#if LCU_SYNTAX_ALF
     776  xConfirmPara( m_iALFMaxNumberFilters < 1,                                                 "ALFMaxNumFilter should be larger than 1"); 
     777#else
     778  xConfirmPara( m_iALFMaxNumberFilters < 1 || m_iALFMaxNumberFilters > 16,                  "ALFMaxNumFilter exceeds supported range (1 to 16)"); 
     779#endif
     780  xConfirmPara( m_loopFilterBetaOffsetDiv2 < -13 || m_loopFilterBetaOffsetDiv2 > 13,          "Loop Filter Beta Offset div. 2 exceeds supported range (-13 to 13)");
     781  xConfirmPara( m_loopFilterTcOffsetDiv2 < -13 || m_loopFilterTcOffsetDiv2 > 13,              "Loop Filter Tc Offset div. 2 exceeds supported range (-13 to 13)");
    654782  xConfirmPara( m_iFastSearch < 0 || m_iFastSearch > 2,                                     "Fast Search Mode is not supported value (0:Full search  1:Diamond  2:PMVFAST)" );
    655783  xConfirmPara( m_iSearchRange < 0 ,                                                        "Search Range must be more than 0" );
    656784  xConfirmPara( m_bipredSearchRange < 0 ,                                                   "Search Range must be more than 0" );
    657785  xConfirmPara( m_iMaxDeltaQP > 7,                                                          "Absolute Delta QP exceeds supported range (0 to 7)" );
     786  xConfirmPara( m_iMaxCuDQPDepth > m_uiMaxCUDepth - 1,                                          "Absolute depth for a minimum CuDQP exceeds maximum coding unit depth" );
     787
     788  xConfirmPara( m_iChromaQpOffset    < -12,   "Min. Chroma Qp Offset is -12"     );
     789  xConfirmPara( m_iChromaQpOffset    >  12,   "Max. Chroma Qp Offset is  12"     );
     790  xConfirmPara( m_iChromaQpOffset2nd < -12,   "Min. Chroma Qp Offset 2nd is -12" );
     791  xConfirmPara( m_iChromaQpOffset2nd >  12,   "Max. Chroma Qp Offset 2nd is  12" );
     792
     793  xConfirmPara( m_iQPAdaptationRange <= 0,                                                  "QP Adaptation Range must be more than 0" );
     794  if (m_iDecodingRefreshType == 2)
     795  {
     796    xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
     797  }
    658798  xConfirmPara( (m_uiMaxCUWidth  >> m_uiMaxCUDepth) < 4,                                    "Minimum partition width size should be larger than or equal to 8");
    659799  xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4,                                    "Minimum partition height size should be larger than or equal to 8");
    660800  xConfirmPara( m_uiMaxCUWidth < 16,                                                        "Maximum partition width size should be larger than or equal to 16");
    661801  xConfirmPara( m_uiMaxCUHeight < 16,                                                       "Maximum partition height size should be larger than or equal to 16");
     802#if PIC_CROPPING
     803  xConfirmPara( (m_iSourceWidth  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame width must be a multiple of the minimum CU size");
     804  xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0,             "Resulting coded frame height must be a multiple of the minimum CU size");
     805#else
    662806  xConfirmPara( (m_iSourceWidth  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth-1)))!=0,             "Frame width should be multiple of minimum CU size");
    663807  xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0,             "Frame height should be multiple of minimum CU size");
    664 
     808#endif
     809 
    665810  xConfirmPara( m_uiQuadtreeTULog2MinSize < 2,                                        "QuadtreeTULog2MinSize must be 2 or greater.");
    666811  xConfirmPara( m_uiQuadtreeTULog2MinSize > 5,                                        "QuadtreeTULog2MinSize must be 5 or smaller.");
     
    677822  xConfirmPara( m_uiQuadtreeTUMaxDepthIntra > m_uiQuadtreeTULog2MaxSize - m_uiQuadtreeTULog2MinSize + 1, "QuadtreeTUMaxDepthIntra must be less than or equal to the difference between QuadtreeTULog2MaxSize and QuadtreeTULog2MinSize plus 1" );
    678823
    679   xConfirmPara( m_iSliceMode < 0 || m_iSliceMode > 2, "SliceMode exceeds supported range (0 to 2)" );
    680   if (m_iSliceMode!=0)
    681   {
    682     xConfirmPara( m_iSliceArgument < 1 ,         "SliceArgument should be larger than or equal to 1" );
    683   }
    684   xConfirmPara( m_iEntropySliceMode < 0 || m_iEntropySliceMode > 2, "EntropySliceMode exceeds supported range (0 to 2)" );
    685   if (m_iEntropySliceMode!=0)
    686   {
    687     xConfirmPara( m_iEntropySliceArgument < 1 ,         "EntropySliceArgument should be larger than or equal to 1" );
    688   }
    689 
    690   xConfirmPara( m_iSymbolMode < 0 || m_iSymbolMode > 1,                                     "SymbolMode must be equal to 0 or 1" );
    691 
    692   // Check MultiView stuff
    693   xConfirmPara    ( m_iNumberOfViews > MAX_INPUT_VIEW_NUM ,                           "NumberOfViews must be less than or equal to MAX_INPUT_VIEW_NUM");
     824  xConfirmPara( m_iNumberOfViews > MAX_VIEW_NUM ,                                     "NumberOfViews must be less than or equal to MAX_VIEW_NUM");
    694825  xConfirmPara    ( Int( m_pchInputFileList.size() ) < m_iNumberOfViews,              "Number of InputFiles must be greater than or equal to NumberOfViews" );
    695826  xConfirmPara    ( Int( m_pchReconFileList.size() ) < m_iNumberOfViews,              "Number of ReconFiles must be greater than or equal to NumberOfViews" );
    696 
    697827  xConfirmPara    ( m_iCodedCamParPrecision < 0 || m_iCodedCamParPrecision > 5,       "CodedCamParsPrecision must be in range of 0..5" );
     828#if HHI_INTERVIEW_SKIP
     829  xConfirmPara    ( m_bInterViewSkip && !m_bUsingDepthMaps,                       "RenderingSkipMode requires CodeDepthMaps = 1" );
     830#endif
    698831#if DEPTH_MAP_GENERATION
    699832  xConfirmPara    ( m_uiPredDepthMapGeneration > 2,                                   "PredDepthMapGen must be less than or equal to 2" );
     
    714847  xConfirmPara    ( m_uiMultiviewResPredMode > 0 && m_uiPredDepthMapGeneration == 0 , "MultiviewResPred > 0 requires PredDepthMapGen > 0" );
    715848#endif
    716 
    717 #if HHI_INTERVIEW_SKIP
    718   xConfirmPara    ( m_uiInterViewSkip > 1,                                        "RenderingSkipMode > 1 not supported" );
    719   xConfirmPara    ( m_uiInterViewSkip > 0 && !m_bUsingDepthMaps,                  "RenderingSkipMode > 0 requires CodeDepthMaps = 1" );
    720 #endif
    721849  if( m_bUsingDepthMaps )
    722850  {
     
    732860      xConfirmPara( m_iNumberOfViews != m_cCameraData.getBaseViewNumbers().size(),   "Number of Views in BaseViewCameraNumbers must be equal to NumberOfViews" );
    733861      xConfirmPara( m_uiVSOMode < 0 || m_uiVSOMode > 4 ,                             "VSO Mode must be greater than or equal to 0 and less than 5");
    734       xConfirmPara( m_iNumberOfExternalRefs               > MAX_ERREF_VIEW_NUM,      "NumberOfExternalRefs must be less than of equal to TAppMVEncCfg::MAX_ERREF_VIEW_NUM" );
    735       xConfirmPara( Int( m_pchERRefFileList .size() ) < m_iNumberOfExternalRefs,     "Number of ERRefFileFiles  must be greater than or equal to NumberOfExternalRefs" );
    736     }
    737 #endif
    738   }
    739 
    740 #if DCM_COMB_LIST
    741 #if !HHI_NO_LowDelayCoding
    742   xConfirmPara( m_bUseLComb==false && m_bUseLDC==false,         "LComb can only be 0 if LowDelayCoding is 1" );
    743 #else
    744   xConfirmPara( m_bUseLComb==false,                             "LComb can only be 0 if LowDelayCoding is 1" );
    745 #endif
     862    }
     863#endif
     864  }
     865#if ADAPTIVE_QP_SELECTION
     866#if H0736_AVC_STYLE_QP_RANGE
     867  xConfirmPara( m_bUseAdaptQpSelect == true && m_aiQP[0] < 0,                                              "AdaptiveQpSelection must be disabled when QP < 0.");
     868  xConfirmPara( m_bUseAdaptQpSelect == true && m_aiQP[1] < 0,                                              "AdaptiveQpSelection must be disabled when QP < 0.");
     869  xConfirmPara( m_bUseAdaptQpSelect == true && (m_iChromaQpOffset !=0 || m_iChromaQpOffset2nd != 0 ),  "AdaptiveQpSelection must be disabled when ChromaQpOffset is not equal to 0.");
     870#endif
     871#endif
     872
     873  if( m_usePCM)
     874  {
     875    xConfirmPara(  m_uiPCMLog2MinSize < 3,                                      "PCMLog2MinSize must be 3 or greater.");
     876    xConfirmPara(  m_uiPCMLog2MinSize > 5,                                      "PCMLog2MinSize must be 5 or smaller.");
     877    xConfirmPara(  m_pcmLog2MaxSize > 5,                                        "PCMLog2MaxSize must be 5 or smaller.");
     878    xConfirmPara(  m_pcmLog2MaxSize < m_uiPCMLog2MinSize,                       "PCMLog2MaxSize must be equal to or greater than m_uiPCMLog2MinSize.");
     879  }
     880
     881#if FIXED_NUMBER_OF_TILES_SLICE_MODE
     882  xConfirmPara( m_iSliceMode < 0 || m_iSliceMode > 3, "SliceMode exceeds supported range (0 to 3)" );
     883#endif
     884  if (m_iSliceMode!=0)
     885  {
     886    xConfirmPara( m_iSliceArgument < 1 ,         "SliceArgument should be larger than or equal to 1" );
     887  }
     888#if FIXED_NUMBER_OF_TILES_SLICE_MODE
     889  if (m_iSliceMode==3)
     890  {
     891    xConfirmPara( m_iSliceGranularity > 0 ,      "When SliceMode == 3 is chosen, the SliceGranularity must be 0" );
     892  }
     893#endif
     894  xConfirmPara( m_iEntropySliceMode < 0 || m_iEntropySliceMode > 2, "EntropySliceMode exceeds supported range (0 to 2)" );
     895  if (m_iEntropySliceMode!=0)
     896  {
     897    xConfirmPara( m_iEntropySliceArgument < 1 ,         "EntropySliceArgument should be larger than or equal to 1" );
     898  }
     899  xConfirmPara( m_iSliceGranularity >= m_uiMaxCUDepth, "SliceGranularity must be smaller than maximum cu depth");
     900  xConfirmPara( m_iSliceGranularity <0 || m_iSliceGranularity > 3, "SliceGranularity exceeds supported range (0 to 3)" );
     901  xConfirmPara( m_iSliceGranularity > m_iMaxCuDQPDepth, "SliceGranularity must be smaller smaller than or equal to maximum dqp depth" );
     902
     903#if NO_COMBINED_PARALLEL
     904  bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0 );
     905  xConfirmPara( tileFlag && m_iEntropySliceMode,            "Tile and Entropy Slice can not be applied together");
     906  xConfirmPara( tileFlag && m_iWaveFrontSynchro,            "Tile and Wavefront can not be applied together");
     907  xConfirmPara( m_iWaveFrontSynchro && m_iEntropySliceMode, "Wavefront and Entropy Slice can not be applied together"); 
    746908#endif
    747909
     
    761923      xConfirmPara( ui != 1 , "Height should be 2^n");
    762924  }
    763 
    764   // SBACRD is supported only for SBAC
    765   if ( m_iSymbolMode == 0 )
    766   {
    767     m_bUseSBACRD = false;
    768   }
     925 
     926  xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
     927  xConfirmPara( m_iWaveFrontFlush < 0, "WaveFrontFlush cannot be negative" );
     928  xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" );
     929  xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_iWaveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" );
    769930
    770931#undef xConfirmPara
    771932  if (check_failed)
     933  {
     934    exit(EXIT_FAILURE);
     935  }
     936
     937  xCheckCodingStructureMvc();
     938}
     939
     940Void TAppEncCfg::xCheckCodingStructureMvc()
     941{
     942  bool check_failed = false; /* abort if there is a fatal configuration problem */
     943#define xConfirmPara(a,b) check_failed |= confirmPara(a,b)
     944
     945  // validate that POC of same frame is identical across multiple views
     946  Bool bErrorMvePoc = false;
     947  if( m_iNumberOfViews > 1 )
     948  {
     949    for( Int k = 1; k < m_iNumberOfViews; k++ )
     950    {
     951      for( Int i = 0; i < MAX_GOP; i++ )
     952      {
     953        if( m_GOPListsMvc[k][i].m_POC != m_GOPListsMvc[0][i].m_POC )
     954        {
     955          printf( "\nError: Frame%d_v%d POC %d is not identical to Frame%d POC\n", i, k, m_GOPListsMvc[k][i].m_POC, i );
     956          bErrorMvePoc = true;
     957        }
     958      }
     959    }
     960  }
     961  xConfirmPara( bErrorMvePoc,  "Invalid inter-view POC structure given" );
     962
     963  // validate that baseview has no inter-view refs
     964  Bool bErrorIvpBase = false;
     965  for( Int i = 0; i < MAX_GOP; i++ )
     966  {
     967    if( m_GOPListsMvc[0][i].m_numInterViewRefPics != 0 )
     968    {
     969      printf( "\nError: Frame%d inter_view refs not available in view 0\n", i );
     970      bErrorIvpBase = true;
     971    }
     972  }
     973  xConfirmPara( bErrorIvpBase, "Inter-view refs not possible in base view" );
     974
     975  // validate inter-view refs
     976  Bool bErrorIvpEnhV = false;
     977  if( m_iNumberOfViews > 1 )
     978  {
     979    for( Int k = 1; k < m_iNumberOfViews; k++ )
     980    {
     981      for( Int i = 0; i < MAX_GOP+1; i++ )
     982      {
     983        for( Int j = 0; j < m_GOPListsMvc[k][i].m_numInterViewRefPics; j++ )
     984        {
     985          Int iAbsViewId = m_GOPListsMvc[k][i].m_interViewRefs[j] + k;
     986          if( iAbsViewId < 0 || iAbsViewId >= k )
     987          {
     988            printf( "\nError: inter-view ref pic %d is not available for Frame%d_v%d\n", m_GOPListsMvc[k][i].m_interViewRefs[j], i, k );
     989            bErrorIvpEnhV = true;
     990          }
     991          if( m_GOPListsMvc[k][i].m_interViewRefPosL0[j] < 0 || m_GOPListsMvc[k][i].m_interViewRefPosL0[j] > m_GOPListsMvc[k][i].m_numRefPicsActive )
     992          {
     993            printf( "\nError: inter-view ref pos %d on L0 is not available for Frame%d_v%d\n", m_GOPListsMvc[k][i].m_interViewRefPosL0[j], i, k );
     994            bErrorIvpEnhV = true;
     995          }
     996          if( m_GOPListsMvc[k][i].m_interViewRefPosL1[j] < 0 || m_GOPListsMvc[k][i].m_interViewRefPosL1[j] > m_GOPListsMvc[k][i].m_numRefPicsActive )
     997          {
     998            printf( "\nError: inter-view ref pos %d on L1 is not available for Frame%d_v%d\n", m_GOPListsMvc[k][i].m_interViewRefPosL1[j], i, k );
     999            bErrorIvpEnhV = true;
     1000          }
     1001        }
     1002        if( i == MAX_GOP ) // inter-view refs at I pic position in base view
     1003        {
     1004          if( m_GOPListsMvc[k][MAX_GOP].m_sliceType != 'B' && m_GOPListsMvc[k][MAX_GOP].m_sliceType != 'P' && m_GOPListsMvc[k][MAX_GOP].m_sliceType != 'I' )
     1005          {
     1006            printf( "\nError: slice type of FrameI_v%d must be equal to B or P or I\n", k );
     1007            bErrorIvpEnhV = true;
     1008          }
     1009
     1010          if( m_GOPListsMvc[k][MAX_GOP].m_POC != 0 )
     1011          {
     1012            printf( "\nError: POC %d not possible for FrameI_v%d, must be 0\n", m_GOPListsMvc[k][MAX_GOP].m_POC, k );
     1013            bErrorIvpEnhV = true;
     1014          }
     1015
     1016          if( m_GOPListsMvc[k][MAX_GOP].m_temporalId != 0 )
     1017          {
     1018            printf( "\nWarning: Temporal id of FrameI_v%d must be 0 (cp. I-frame in base view)\n", k );
     1019            m_GOPListsMvc[k][MAX_GOP].m_temporalId = 0;
     1020          }
     1021
     1022          if( !(m_GOPListsMvc[k][MAX_GOP].m_refPic) )
     1023          {
     1024            printf( "\nWarning: FrameI_v%d must be ref pic (cp. I-frame in base view)\n", k );
     1025            m_GOPListsMvc[k][MAX_GOP].m_refPic = true;
     1026          }
     1027
     1028          if( m_GOPListsMvc[k][MAX_GOP].m_numRefPics != 0 )
     1029          {
     1030            printf( "\nWarning: temporal references not possible for FrameI_v%d\n", k );
     1031            for( Int j = 0; j < m_GOPListsMvc[k][MAX_GOP].m_numRefPics; j++ )
     1032            {
     1033              m_GOPListsMvc[k][MAX_GOP].m_referencePics[j] = 0;
     1034            }
     1035            m_GOPListsMvc[k][MAX_GOP].m_numRefPics = 0;
     1036          }
     1037
     1038          if( m_GOPListsMvc[k][MAX_GOP].m_interRPSPrediction )
     1039          {
     1040            printf( "\nError: inter RPS prediction not possible for FrameI_v%d, must be 0\n", k );
     1041            bErrorIvpEnhV = true;
     1042          }
     1043
     1044          if( m_GOPListsMvc[k][MAX_GOP].m_sliceType == 'I' && m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics != 0 )
     1045          {
     1046            printf( "\nError: inter-view prediction not possible for FrameI_v%d with slice type I, #IV_ref_pics must be 0\n", k );
     1047            bErrorIvpEnhV = true;
     1048          }
     1049
     1050          if( m_GOPListsMvc[k][MAX_GOP].m_numRefPicsActive > m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics )
     1051          {
     1052            m_GOPListsMvc[k][MAX_GOP].m_numRefPicsActive = m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics;
     1053          }
     1054
     1055          if( m_GOPListsMvc[k][MAX_GOP].m_sliceType == 'P' )
     1056          {
     1057            if( m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics < 1 )
     1058            {
     1059              printf( "\nError: #IV_ref_pics must be at least one for FrameI_v%d with slice type P\n", k );
     1060              bErrorIvpEnhV = true;
     1061            }
     1062            else
     1063            {
     1064              for( Int j = 0; j < m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics; j++ )
     1065              {
     1066                if( m_GOPListsMvc[k][MAX_GOP].m_interViewRefPosL1[j] != 0 )
     1067                {
     1068                  printf( "\nError: inter-view ref pos %d on L1 not possible for FrameI_v%d with slice type P\n", m_GOPListsMvc[k][MAX_GOP].m_interViewRefPosL1[j], k );
     1069                  bErrorIvpEnhV = true;
     1070                }
     1071              }
     1072            }
     1073          }
     1074
     1075          if( m_GOPListsMvc[k][MAX_GOP].m_sliceType == 'B' && m_GOPListsMvc[k][MAX_GOP].m_numInterViewRefPics < 1 )
     1076          {
     1077            printf( "\nError: #IV_ref_pics must be at least one for FrameI_v%d with slice type B\n", k );
     1078            bErrorIvpEnhV = true;
     1079          }
     1080        }
     1081      }
     1082    }
     1083  }
     1084  xConfirmPara( bErrorIvpEnhV, "Invalid inter-view coding structure for enhancement views given" );
     1085
     1086  // validate temporal coding structure
     1087  if( !bErrorMvePoc && !bErrorIvpBase && !bErrorIvpEnhV )
     1088  {
     1089    for( Int viewId = 0; viewId < m_iNumberOfViews; viewId++ )
     1090    {
     1091      Bool verifiedGOP = false;
     1092      Bool errorGOP    = false;
     1093      Int  checkGOP    = 1;
     1094      Int  numRefs     = 1;
     1095      Int refList[MAX_NUM_REF_PICS+1];
     1096      refList[0] = 0;
     1097      Bool isOK[MAX_GOP];
     1098      for( Int i = 0; i < MAX_GOP; i++ ) { isOK[i] = false; }
     1099      Int numOK = 0;
     1100#if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
     1101      Int numReorderFramesRequired=0;
     1102      m_maxNumberOfReferencePictures=0;
     1103      Int lastDisp = -1;
     1104#endif
     1105      m_extraRPSs[viewId] = 0;
     1106      //start looping through frames in coding order until we can verify that the GOP structure is correct.
     1107      while( !verifiedGOP && !errorGOP )
     1108      {
     1109        Int curGOP = (checkGOP-1)%m_iGOPSize;
     1110        Int curPOC = ((checkGOP-1)/m_iGOPSize)*m_iGOPSize + m_GOPListsMvc[viewId][curGOP].m_POC;   
     1111        if( m_GOPListsMvc[viewId][curGOP].m_POC < 0 )
     1112        {
     1113          printf( "\nError: found fewer Reference Picture Sets than GOPSize for view %d\n", viewId );
     1114          errorGOP = true;
     1115        }
     1116        else
     1117        {
     1118          //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP.
     1119          Bool beforeI = false;
     1120          for( Int i = 0; i < m_GOPListsMvc[viewId][curGOP].m_numRefPics; i++ )
     1121          {
     1122            Int absPOC = curPOC + m_GOPListsMvc[viewId][curGOP].m_referencePics[i];
     1123            if( absPOC < 0 )
     1124            {
     1125              beforeI = true;
     1126            }
     1127            else
     1128            {
     1129              Bool found = false;
     1130              for( Int j = 0; j < numRefs; j++ )
     1131              {
     1132                if( refList[j] == absPOC )
     1133                {
     1134                  found = true;
     1135                  for( Int k = 0; k < m_iGOPSize; k++ )
     1136                  {
     1137                    if( absPOC%m_iGOPSize == m_GOPListsMvc[viewId][k].m_POC%m_iGOPSize )
     1138                    {
     1139                      m_GOPListsMvc[viewId][curGOP].m_usedByCurrPic[i] = (m_GOPListsMvc[viewId][k].m_temporalId <= m_GOPListsMvc[viewId][curGOP].m_temporalId);
     1140                    }
     1141                  }
     1142                }
     1143              }
     1144              if( !found )
     1145              {
     1146                printf("\nError: ref pic %d is not available for GOP frame %d of view %d\n", m_GOPListsMvc[viewId][curGOP].m_referencePics[i], curGOP+1, viewId );
     1147                errorGOP = true;
     1148              }
     1149            }
     1150          }
     1151          if( !beforeI && !errorGOP )
     1152          {
     1153            //all ref frames were present
     1154            if( !isOK[curGOP] )
     1155            {
     1156              numOK++;
     1157              isOK[curGOP] = true;
     1158              if( numOK == m_iGOPSize )
     1159              {
     1160                verifiedGOP = true;
     1161              }
     1162            }
     1163          }
     1164          else
     1165          {
     1166            //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0)
     1167            m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]] = m_GOPListsMvc[viewId][curGOP];
     1168            Int newRefs = 0;
     1169            for( Int i = 0; i < m_GOPListsMvc[viewId][curGOP].m_numRefPics; i++ )
     1170            {
     1171              Int absPOC = curPOC + m_GOPListsMvc[viewId][curGOP].m_referencePics[i];
     1172              if( absPOC >= 0 )
     1173              {
     1174                m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[newRefs] = m_GOPListsMvc[viewId][curGOP].m_referencePics[i];
     1175                m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_usedByCurrPic[newRefs] = m_GOPListsMvc[viewId][curGOP].m_usedByCurrPic[i];
     1176                newRefs++;
     1177              }
     1178            }
     1179            Int numPrefRefs = m_GOPListsMvc[viewId][curGOP].m_numRefPicsActive;
     1180
     1181            for( Int offset = -1; offset > -checkGOP; offset-- )
     1182            {
     1183              //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0.
     1184              Int offGOP =  (checkGOP - 1 + offset)%m_iGOPSize;
     1185              Int offPOC = ((checkGOP - 1 + offset)/m_iGOPSize) * m_iGOPSize + m_GOPListsMvc[viewId][offGOP].m_POC;
     1186              if( offPOC >= 0 && m_GOPListsMvc[viewId][offGOP].m_refPic && m_GOPListsMvc[viewId][offGOP].m_temporalId <= m_GOPListsMvc[viewId][curGOP].m_temporalId )
     1187              {
     1188                Bool newRef = false;
     1189                for( Int i = 0; i < numRefs; i++ )
     1190                {
     1191                  if( refList[i] == offPOC )
     1192                  {
     1193                    newRef = true;
     1194                  }
     1195                }
     1196                for( Int i = 0; i < newRefs; i++ )
     1197                {
     1198                  if( m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[i] == (offPOC - curPOC) )
     1199                  {
     1200                    newRef = false;
     1201                  }
     1202                }
     1203                if( newRef )
     1204                {
     1205                  Int insertPoint = newRefs;
     1206                  //this picture can be added, find appropriate place in list and insert it.
     1207                  for( Int j = 0; j < newRefs; j++ )
     1208                  {
     1209                    if( m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j] < (offPOC - curPOC) ||
     1210                        m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j] > 0 )
     1211                    {
     1212                      insertPoint = j;
     1213                      break;
     1214                    }
     1215                  }
     1216                  Int prev = offPOC - curPOC;
     1217                  Int prevUsed = (m_GOPListsMvc[viewId][offGOP].m_temporalId <= m_GOPListsMvc[viewId][curGOP].m_temporalId);
     1218                  for( Int j = insertPoint; j < newRefs+1; j++ )
     1219                  {
     1220                    Int newPrev = m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j];
     1221                    Int newUsed = m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_usedByCurrPic[j];
     1222                    m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j] = prev;
     1223                    m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_usedByCurrPic[j] = prevUsed;
     1224                    prevUsed = newUsed;
     1225                    prev = newPrev;
     1226                  }
     1227                  newRefs++;
     1228                }
     1229              }
     1230              if( newRefs >= numPrefRefs )
     1231              {
     1232                break;
     1233              }
     1234            }
     1235            m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_numRefPics = newRefs;
     1236            m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_POC = curPOC;
     1237            if( m_extraRPSs[viewId] == 0 )
     1238            {
     1239              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_interRPSPrediction = 0;
     1240              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_numRefIdc = 0;
     1241            }
     1242            else
     1243            {
     1244              Int rIdx =  m_iGOPSize + m_extraRPSs[viewId] - 1;
     1245              Int refPOC = m_GOPListsMvc[viewId][rIdx].m_POC;
     1246              Int refPics = m_GOPListsMvc[viewId][rIdx].m_numRefPics;
     1247              Int newIdc = 0;
     1248              for( Int i = 0; i <= refPics; i++ )
     1249              {
     1250                Int deltaPOC = ((i != refPics)? m_GOPListsMvc[viewId][rIdx].m_referencePics[i] : 0);  // check if the reference abs POC is >= 0
     1251                Int absPOCref = refPOC + deltaPOC;
     1252                Int refIdc = 0;
     1253                for( Int j = 0; j < m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_numRefPics; j++ )
     1254                {
     1255                  if( (absPOCref - curPOC) == m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_referencePics[j] )
     1256                  {
     1257                    if( m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_usedByCurrPic[j] )
     1258                    {
     1259                      refIdc = 1;
     1260                    }
     1261                    else
     1262                    {
     1263                      refIdc = 2;
     1264                    }
     1265                  }
     1266                }
     1267                m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_refIdc[newIdc] = refIdc;
     1268                newIdc++;
     1269              }
     1270              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_interRPSPrediction = 1; 
     1271              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_numRefIdc = newIdc;
     1272              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_deltaRPS = refPOC - m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_POC;
     1273              m_GOPListsMvc[viewId][m_iGOPSize+m_extraRPSs[viewId]].m_deltaRIdxMinus1 = 0;
     1274            }
     1275            curGOP = m_iGOPSize + m_extraRPSs[viewId];
     1276            m_extraRPSs[viewId]++;
     1277          }
     1278          numRefs = 0;
     1279          for( Int i = 0; i < m_GOPListsMvc[viewId][curGOP].m_numRefPics; i++ )
     1280          {
     1281            Int absPOC = curPOC + m_GOPListsMvc[viewId][curGOP].m_referencePics[i];
     1282            if( absPOC >= 0 )
     1283            {
     1284              refList[numRefs] = absPOC;
     1285              numRefs++;
     1286            }
     1287          }
     1288#if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
     1289          if(m_maxNumberOfReferencePictures<numRefs)
     1290          {
     1291            m_maxNumberOfReferencePictures=numRefs;
     1292          }
     1293#endif
     1294          refList[numRefs] = curPOC;
     1295          numRefs++;
     1296#if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
     1297          Int nonDisplayed=0;
     1298          for(Int i=0; i<numRefs; i++)
     1299          {
     1300            if(refList[i]==lastDisp+1)
     1301            {
     1302              lastDisp=refList[i];
     1303              i=0;
     1304            }
     1305          }
     1306          for(Int i=0; i<numRefs; i++)
     1307          {
     1308            if(refList[i]>lastDisp)
     1309            {
     1310              nonDisplayed++;
     1311            }
     1312          }
     1313          if(nonDisplayed>numReorderFramesRequired)
     1314          {
     1315            numReorderFramesRequired=nonDisplayed;
     1316          }
     1317#endif
     1318        }
     1319        checkGOP++;
     1320      }
     1321#if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
     1322      if (m_numReorderFrames == -1)
     1323      {
     1324        m_numReorderFrames = numReorderFramesRequired;
     1325      }
     1326#endif
     1327      xConfirmPara( errorGOP, "Invalid GOP structure given" );
     1328#if H0566_TLA
     1329      m_maxTempLayer[viewId] = 1;
     1330#endif
     1331      for( Int i = 0; i < m_iGOPSize; i++ )
     1332      {
     1333#if H0566_TLA
     1334        if( m_GOPListsMvc[viewId][i].m_temporalId >= m_maxTempLayer[viewId] )
     1335        {
     1336          m_maxTempLayer[viewId] = m_GOPListsMvc[viewId][i].m_temporalId + 1;
     1337        }
     1338#endif
     1339        xConfirmPara( m_GOPListsMvc[viewId][i].m_sliceType != 'B' && m_GOPListsMvc[viewId][i].m_sliceType != 'P', "Slice type must be equal to B or P" );
     1340      }
     1341
     1342#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
     1343      for( Int i = 0; i < MAX_TLAYER; i++ )
     1344      {
     1345        m_numReorderPics[viewId][i] = 0;
     1346        m_maxDecPicBuffering[viewId][i] = 0;
     1347      }
     1348      for( Int i = 0; i < m_iGOPSize; i++ )
     1349      {
     1350        if( m_GOPListsMvc[viewId][i].m_numRefPics > m_maxDecPicBuffering[viewId][m_GOPListsMvc[viewId][i].m_temporalId] )
     1351        {
     1352          m_maxDecPicBuffering[viewId][m_GOPListsMvc[viewId][i].m_temporalId] = m_GOPListsMvc[viewId][i].m_numRefPics;
     1353        }
     1354        Int highestDecodingNumberWithLowerPOC = 0;
     1355        for( Int j = 0; j < m_iGOPSize; j++ )
     1356        {
     1357          if( m_GOPListsMvc[viewId][j].m_POC <= m_GOPListsMvc[viewId][i].m_POC )
     1358          {
     1359            highestDecodingNumberWithLowerPOC = j;
     1360          }
     1361        }
     1362        Int numReorder = 0;
     1363        for( Int j = 0; j < highestDecodingNumberWithLowerPOC; j++ )
     1364        {
     1365          if( m_GOPListsMvc[viewId][j].m_temporalId <= m_GOPListsMvc[viewId][i].m_temporalId &&
     1366              m_GOPListsMvc[viewId][j].m_POC        >  m_GOPListsMvc[viewId][i].m_POC )
     1367          {
     1368            numReorder++;
     1369          }
     1370        }   
     1371        if( numReorder > m_numReorderPics[viewId][m_GOPListsMvc[viewId][i].m_temporalId] )
     1372        {
     1373          m_numReorderPics[viewId][m_GOPListsMvc[viewId][i].m_temporalId] = numReorder;
     1374        }
     1375      }
     1376      for( Int i = 0; i < MAX_TLAYER-1; i++ )
     1377      {
     1378        // a lower layer can not have higher value of m_numReorderPics than a higher layer
     1379        if( m_numReorderPics[viewId][i+1] < m_numReorderPics[viewId][i] )
     1380        {
     1381          m_numReorderPics[viewId][i+1] = m_numReorderPics[viewId][i];
     1382        }
     1383        // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
     1384        if( m_numReorderPics[viewId][i] > m_maxDecPicBuffering[viewId][i] )
     1385        {
     1386          m_maxDecPicBuffering[viewId][i] = m_numReorderPics[viewId][i];
     1387        }
     1388        // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer
     1389        if( m_maxDecPicBuffering[viewId][i+1] < m_maxDecPicBuffering[viewId][i] )
     1390        {
     1391          m_maxDecPicBuffering[viewId][i+1] = m_maxDecPicBuffering[viewId][i];
     1392        }
     1393      }
     1394      // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
     1395      if( m_numReorderPics[viewId][MAX_TLAYER-1] > m_maxDecPicBuffering[viewId][MAX_TLAYER-1] )
     1396      {
     1397        m_maxDecPicBuffering[viewId][MAX_TLAYER-1] = m_numReorderPics[viewId][MAX_TLAYER-1];
     1398      }
     1399#endif
     1400
     1401#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
     1402      xConfirmPara( m_bUseLComb == false && m_numReorderPics[viewId][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.
     1403#else
     1404      xConfirmPara( m_bUseLComb==false && m_numReorderFrames!=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.
     1405      xConfirmPara( m_numReorderFrames < numReorderFramesRequired, "For the used GOP the encoder requires more pictures for reordering than specified in MaxNumberOfReorderPictures" );
     1406#endif
     1407    }
     1408  }
     1409#undef xConfirmPara
     1410  if( check_failed )
    7721411  {
    7731412    exit(EXIT_FAILURE);
     
    8011440  xCleanUpVector( m_pchReconFileList,       (char*)0 );
    8021441  xCleanUpVector( m_pchDepthReconFileList,  (char*)0 );
    803 
    804 #if HHI_VSO
    805   if ( m_bUseVSO)
    806   {
    807     xCleanUpVector( m_pchERRefFileList,       (char*)0 );
    808   }
    809 #endif
    8101442}
    8111443
     
    8171449  g_uiMaxCUWidth  = m_uiMaxCUWidth;
    8181450  g_uiMaxCUHeight = m_uiMaxCUHeight;
    819 
     1451 
    8201452  // compute actual CU depth with respect to config depth and max transform size
    8211453  g_uiAddCUDepth  = 0;
    8221454  while( (m_uiMaxCUWidth>>m_uiMaxCUDepth) > ( 1 << ( m_uiQuadtreeTULog2MinSize + g_uiAddCUDepth )  ) ) g_uiAddCUDepth++;
    823 
     1455 
    8241456  m_uiMaxCUDepth += g_uiAddCUDepth;
    8251457  g_uiAddCUDepth++;
    8261458  g_uiMaxCUDepth = m_uiMaxCUDepth;
    827 
     1459 
    8281460  // set internal bit-depth and constants
    829 #if ENABLE_IBDI
    830   if ((int)m_uiBitIncrement != -1)
    831   {
    832     g_uiBitDepth = m_uiInputBitDepth;
    833     g_uiBitIncrement = m_uiBitIncrement;
    834     m_uiInternalBitDepth = g_uiBitDepth + g_uiBitIncrement;
    835   }
    836   else
    837   {
    838     g_uiBitDepth = min(8u, m_uiInputBitDepth);
    839     if (m_uiInternalBitDepth == 0) {
    840       /* default increement = 2 */
    841       m_uiInternalBitDepth = 2 + g_uiBitDepth;
    842     }
    843     g_uiBitIncrement = m_uiInternalBitDepth - g_uiBitDepth;
    844   }
    845 #else
    8461461#if FULL_NBIT
    8471462  g_uiBitDepth = m_uiInternalBitDepth;
     
    8511466  g_uiBitIncrement = m_uiInternalBitDepth - g_uiBitDepth;
    8521467#endif
    853 #endif
     1468
    8541469#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    855   g_dDeltaDCsQuantOffset = Double(g_uiBitIncrement) -  2.0;
     1470  g_iDeltaDCsQuantOffset = g_uiBitIncrement - 2;
    8561471#endif
    8571472
    8581473  g_uiBASE_MAX     = ((1<<(g_uiBitDepth))-1);
    859 
     1474 
    8601475#if IBDI_NOCLIP_RANGE
    8611476  g_uiIBDI_MAX     = g_uiBASE_MAX << g_uiBitIncrement;
     
    8631478  g_uiIBDI_MAX     = ((1<<(g_uiBitDepth+g_uiBitIncrement))-1);
    8641479#endif
    865 
     1480 
    8661481  if (m_uiOutputBitDepth == 0)
    8671482  {
    8681483    m_uiOutputBitDepth = m_uiInternalBitDepth;
    8691484  }
     1485
     1486  g_uiPCMBitDepthLuma = m_uiPCMBitDepthLuma = ((m_bPCMInputBitDepthFlag)? m_uiInputBitDepth : m_uiInternalBitDepth);
     1487  g_uiPCMBitDepthChroma = ((m_bPCMInputBitDepthFlag)? m_uiInputBitDepth : m_uiInternalBitDepth);
    8701488}
    8711489
     
    8731491{
    8741492  printf("\n");
    875   for( Int iCounter = 0; iCounter<m_iNumberOfViews; iCounter++)
    876   {
    877     printf("Input          File %i        : %s\n", iCounter, m_pchInputFileList[iCounter]);
    878   }
    879   for( Int iCounter = 0; iCounter < (Int)m_pchDepthInputFileList.size(); iCounter++)
    880   {
    881     printf("DepthInput     File %i        : %s\n", iCounter, m_pchDepthInputFileList[iCounter]);
    882   }
    883   printf("Bitstream      File          : %s\n", m_pchBitstreamFile      );
    884   for( Int iCounter = 0; iCounter<m_iNumberOfViews; iCounter++)
    885   {
    886     printf("Reconstruction File %i        : %s\n", iCounter, m_pchReconFileList[iCounter]);
    887   }
    888 
    889   for( Int iCounter = 0; iCounter<(Int)m_pchDepthReconFileList.size(); iCounter++)
    890   {
    891     printf("Reconstruction Depth File %i  : %s\n", iCounter, m_pchDepthReconFileList[iCounter]);
    892   }
     1493  for( Int iCounter = 0; iCounter< m_iNumberOfViews; iCounter++)
     1494  {
     1495    printf("Texture Input File %i            : %s\n", iCounter, m_pchInputFileList[iCounter]);
     1496  }
     1497  if( m_bUsingDepthMaps )
     1498  {
     1499    for( Int iCounter = 0; iCounter < m_iNumberOfViews; iCounter++)
     1500    {
     1501      printf("Depth Input File %i              : %s\n", iCounter, m_pchDepthInputFileList[iCounter]);
     1502    }
     1503  }
     1504  printf("Bitstream File                  : %s\n", m_pchBitstreamFile      );
     1505  for( Int iCounter = 0; iCounter< m_iNumberOfViews; iCounter++)
     1506  {
     1507    printf("Texture Reconstruction File %i   : %s\n", iCounter, m_pchReconFileList[iCounter]);
     1508  }
     1509  if( m_bUsingDepthMaps )
     1510  {
     1511    for( Int iCounter = 0; iCounter< m_iNumberOfViews; iCounter++)
     1512    {
     1513      printf("Depth Reconstruction File %i     : %s\n", iCounter, m_pchDepthReconFileList[iCounter]);
     1514    }
     1515  }
     1516#if PIC_CROPPING
     1517  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_cropLeft - m_cropRight, m_iSourceHeight - m_cropTop - m_cropBottom, m_iFrameRate );
     1518#else
    8931519  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_aiPad[0], m_iSourceHeight-m_aiPad[1], m_iFrameRate );
     1520#endif
    8941521  printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
    8951522  printf("Frame index                  : %u - %d (%d frames)\n", m_FrameSkip, m_FrameSkip+m_iFrameToBeEncoded-1, m_iFrameToBeEncoded );
     
    8981525  printf("Max RQT depth inter          : %d\n", m_uiQuadtreeTUMaxDepthInter);
    8991526  printf("Max RQT depth intra          : %d\n", m_uiQuadtreeTUMaxDepthIntra);
     1527  printf("Min PCM size                 : %d\n", 1 << m_uiPCMLog2MinSize);
    9001528  printf("Motion search range          : %d\n", m_iSearchRange );
    901 #if DCM_DECODING_REFRESH
     1529  printf("Intra period                 : %d\n", m_iIntraPeriod );
    9021530  printf("Decoding refresh type        : %d\n", m_iDecodingRefreshType );
    903 #endif
    904   printf("QP                           : %5.2f\n", m_adQP[0] );
    905   printf("QP Depth                     : %5.2f\n", m_adQP[ m_adQP.size()  < 2 ? 0 : 1] );
    906   printf("Coded Picture Store Size     : %d\n", m_uiCodedPictureStoreSize);
     1531  printf("QP Texture                   : %5.2f\n", m_adQP[0] );
     1532  if( m_bUsingDepthMaps )
     1533  {
     1534    printf("QP Depth                     : %5.2f\n", m_adQP[ m_adQP.size()  < 2 ? 0 : 1] );
     1535  }
     1536  printf("Max dQP signaling depth      : %d\n", m_iMaxCuDQPDepth);
     1537
     1538  printf("Chroma Qp Offset             : %d\n", m_iChromaQpOffset   );
     1539  printf("Chroma Qp Offset 2nd         : %d\n", m_iChromaQpOffset2nd);
     1540
     1541  printf("QP adaptation                : %d (range=%d)\n", m_bUseAdaptiveQP, (m_bUseAdaptiveQP ? m_iQPAdaptationRange : 0) );
    9071542  printf("GOP size                     : %d\n", m_iGOPSize );
    908   printf("Rate GOP size                : %d\n", m_iRateGOPSize );
    9091543  printf("Internal bit depth           : %d\n", m_uiInternalBitDepth );
    910 
    911   if ( m_iSymbolMode == 0 )
    912   {
    913     printf("Entropy coder                : VLC\n");
    914   }
    915   else if( m_iSymbolMode == 1 )
    916   {
    917     printf("Entropy coder                : CABAC\n");
    918   }
    919   else if( m_iSymbolMode == 2 )
    920   {
    921     printf("Entropy coder                : PIPE\n");
    922   }
    923   else
    924   {
    925     assert(0);
    926   }
    927 
    928   printf("GOP Format String            : %s\n", m_cInputFormatString.c_str() );
    929   printf("Loop Filter Disabled         : %d %d\n", m_abLoopFilterDisable[0] ? 1 : 0,  m_abLoopFilterDisable[1] ? 1 : 0 );
     1544  printf("PCM sample bit depth         : %d\n", m_uiPCMBitDepthLuma );
     1545  if((m_uiMaxCUWidth >> m_uiMaxCUDepth) == 4)
     1546  {
     1547    printf("DisableInter4x4              : %d\n", m_bDisInter4x4); 
     1548  }
     1549
     1550printf("Loop Filter Disabled         : %d %d\n", m_abLoopFilterDisable[0] ? 1 : 0,  m_abLoopFilterDisable[1] ? 1 : 0 );
    9301551  printf("Coded Camera Param. Precision: %d\n", m_iCodedCamParPrecision);
    9311552
     
    9431564  }
    9441565#endif
    945 
     1566#if HHI_INTERVIEW_SKIP
     1567    printf("InterView Skip:              : %d\n",    m_bInterViewSkip ? 1:0 );
     1568    printf("InterView Skip Lambda Scale  : %f\n",    m_dInterViewSkipLambdaScale );
     1569#endif
    9461570
    9471571  printf("\n");
    948 
    949   printf("TOOL CFG GENERAL: ");
     1572 
     1573  printf("TOOL CFG General: "); 
     1574#if LCU_SYNTAX_ALF
     1575  printf("ALFMNF:%d ", m_iALFMaxNumberFilters);
     1576  printf("ALFInSlice:%d ", m_bALFParamInSlice);
     1577  printf("ALFPicEnc:%d ", m_bALFPicBasedEncode);
     1578#endif
    9501579  printf("IBD:%d ", !!g_uiBitIncrement);
    9511580  printf("HAD:%d ", m_bUseHADME           );
     
    9531582  printf("SQP:%d ", m_uiDeltaQpRD         );
    9541583  printf("ASR:%d ", m_bUseASR             );
     1584#if !PIC_CROPPING
    9551585  printf("PAD:%d ", m_bUsePAD             );
    956   printf("LDC:%d ", m_bUseLDC             );
    957 #if DCM_COMB_LIST
     1586#endif
    9581587  printf("LComb:%d ", m_bUseLComb         );
    9591588  printf("LCMod:%d ", m_bLCMod         );
    960 #endif
    9611589  printf("FEN:%d ", m_bUseFastEnc         );
     1590  printf("ECU:%d ", m_bUseEarlyCU         );
     1591#if FAST_DECISION_FOR_MRG_RD_COST
     1592  printf("FDM:%d ", m_useFastDecisionForMerge );
     1593#endif
     1594  printf("CFM:%d ", m_bUseCbfFastMode         );
    9621595  printf("RQT:%d ", 1     );
    963   printf("MRG:%d ", m_bUseMRG             ); // SOPH: Merge Mode
    964 #if LM_CHROMA
    965   printf("LMC:%d ", m_bUseLMChroma        );
    966 #endif
    967 #if HHI_RMP_SWITCH
    968   printf("RMP:%d ", m_bUseRMP);
    969 #endif
    970   printf("Slice:%d ",m_iSliceMode);
     1596  printf("LMC:%d ", m_bUseLMChroma        );
     1597  printf("Slice: G=%d M=%d ", m_iSliceGranularity, m_iSliceMode);
    9711598  if (m_iSliceMode!=0)
    9721599  {
    973     printf("(%d) ", m_iSliceArgument);
    974   }
    975   printf("EntropySlice:%d ",m_iEntropySliceMode);
     1600    printf("A=%d ", m_iSliceArgument);
     1601  }
     1602  printf("EntropySlice: M=%d ",m_iEntropySliceMode);
    9761603  if (m_iEntropySliceMode!=0)
    9771604  {
    978     printf("(%d) ", m_iEntropySliceArgument);
    979   }
    980 #if CONSTRAINED_INTRA_PRED
     1605    printf("A=%d ", m_iEntropySliceArgument);
     1606  }
    9811607  printf("CIP:%d ", m_bUseConstrainedIntraPred);
    982 #endif
    983 #if MTK_SAO
     1608#if BURST_IPCM
     1609  printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0);
     1610#else
     1611  printf("PCM:%d ", ((1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0);
     1612#endif
     1613#if SAO_UNIT_INTERLEAVING
     1614  printf("SAOInterleaving:%d ", (m_saoInterleavingFlag)?(1):(0));
     1615#endif
     1616#if LOSSLESS_CODING
     1617  printf("LosslessCuEnabled:%d ", (m_useLossless)? 1:0 );
     1618#endif 
     1619  printf("WPP:%d ", (Int)m_bUseWeightPred);
     1620  printf("WPB:%d ", m_uiBiPredIdc);
     1621#if !REMOVE_TILE_DEPENDENCE
     1622  printf("TileBoundaryIndependence:%d ", m_iTileBoundaryIndependenceIdr );
     1623#endif
     1624  printf("TileLocationInSliceHdr:%d ", m_iTileLocationInSliceHeaderFlag);
     1625  printf("TileMarker:%d", m_iTileMarkerFlag);
     1626  if (m_iTileMarkerFlag)
     1627  {
     1628    printf("[%d] ", m_iMaxTileMarkerEntryPoints);
     1629  }
     1630  else
     1631  {
     1632    printf(" ");
     1633  }
     1634  printf(" WaveFrontSynchro:%d WaveFrontFlush:%d WaveFrontSubstreams:%d",
     1635          m_iWaveFrontSynchro, m_iWaveFrontFlush, m_iWaveFrontSubstreams);
     1636  printf(" ScalingList:%d ", m_useScalingListId );
     1637
     1638  printf("TMVP:%d ", m_enableTMVP     );
     1639
     1640#if ADAPTIVE_QP_SELECTION
     1641  printf("AQpS:%d", m_bUseAdaptQpSelect   );
     1642#endif
     1643
     1644#if MULTIBITS_DATA_HIDING
     1645  printf(" SignBitHidingFlag:%d SignBitHidingThreshold:%d", m_signHideFlag, m_signHidingThreshold);
    9841646#endif
    9851647  printf("\n");
     
    10031665  printf("MVI:%d ", m_bUseMVI ? 1 : 0 );
    10041666#endif
    1005   printf("\n");
    1006 
     1667  printf("\n\n");
     1668 
    10071669  fflush(stdout);
    10081670}
     
    10211683  printf( "                   PAD - automatic source padding of multiple of 16\n");
    10221684  printf( "                   ASR - adaptive motion search range\n");
    1023   printf( "                   FEN - fast encoder setting\n");
    1024   printf( "                   MRG - merging of motion partitions\n"); // SOPH: Merge Mode
    1025 
    1026 #if LM_CHROMA
     1685  printf( "                   FEN - fast encoder setting\n"); 
     1686  printf( "                   ECU - Early CU setting\n");
     1687  printf( "                   CFM - Cbf fast mode setting\n");
    10271688  printf( "                   LMC - intra chroma prediction based on luma\n");
    1028 #endif
    1029 
    10301689  printf( "\n" );
    10311690  printf( "  Example 1) TAppEncoder.exe -c test.cfg -q 32 -g 8 -f 9 -s 64 -h 4\n");
     
    10391698  if (!bflag)
    10401699    return false;
    1041 
     1700 
    10421701  printf("Error: %s\n",message);
    10431702  return true;
     
    11081767  rpchOutputFileName[iInLength+iAppendLength] = '\0';
    11091768}
     1769
     1770//! \}
  • trunk/source/App/TAppEncoder/TAppEncCfg.h

    r42 r56  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license.
     4 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2011, ISO/IEC
     6 * Copyright (c) 2010-2012, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    1515 *    this list of conditions and the following disclaimer in the documentation
    1616 *    and/or other materials provided with the distribution.
    17  *  * Neither the name of the ISO/IEC nor the names of its contributors may
     17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    1818 *    be used to endorse or promote products derived from this software without
    1919 *    specific prior written permission.
     
    3232 */
    3333
    34 
    35 
    3634/** \file     TAppEncCfg.h
    3735    \brief    Handle encoder configuration parameters (header)
     
    4139#define __TAPPENCCFG__
    4240
    43 #include "../../Lib/TLibCommon/CommonDef.h"
    44 #include "../../Lib/TLibCommon/TComMVDRefData.h"
    45 #include "../../App/TAppCommon/TAppComCamPara.h"
    46 #include "../../Lib/TLibRenderer/TRenTop.h"
    47 #include "../../Lib/TLibRenderer/TRenModel.h"
    48 #include "../../Lib/TLibRenderer/TRenModSetupStrParser.h"
    49 
    50 #include <string>
     41#include "TLibCommon/CommonDef.h"
     42
     43#include "TLibEncoder/TEncCfg.h"
     44#include "TAppCommon/TAppComCamPara.h"
     45#include "TLibRenderer/TRenTop.h"
     46#include "TLibRenderer/TRenModel.h"
     47#include "TLibRenderer/TRenModSetupStrParser.h"
     48
     49#include <sstream>
    5150#include <vector>
     51
     52//! \ingroup TAppEncoder
     53//! \{
    5254
    5355// ====================================================================================================================
     
    6062protected:
    6163  // file I/O
    62   char*     m_pchBitstreamFile;                               ///< output bitstream file
    63 
    6464  std::vector<char*>     m_pchInputFileList;                  ///< source file names
    6565  std::vector<char*>     m_pchDepthInputFileList;             ///< source depth file names
    6666  std::vector<char*>     m_pchReconFileList;                  ///< output reconstruction file names
    6767  std::vector<char*>     m_pchDepthReconFileList;             ///< output depth reconstruction file names
    68 
    69   std::vector<char*>     m_pchERRefFileList;                  ///< virtual external reference view files names
    70 
     68  char*     m_pchBitstreamFile;                               ///< output bitstream file
     69  Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
    7170  // source specification
    7271  Int       m_iFrameRate;                                     ///< source frame-rates (Hz)
     
    7473  Int       m_iSourceWidth;                                   ///< source width in pixel
    7574  Int       m_iSourceHeight;                                  ///< source height in pixel
     75#if PIC_CROPPING
     76  Int       m_croppingMode;
     77  Int       m_cropLeft;
     78  Int       m_cropRight;
     79  Int       m_cropTop;
     80  Int       m_cropBottom;
     81#endif
    7682  Int       m_iFrameToBeEncoded;                              ///< number of encoded frames
     83#if !PIC_CROPPING
    7784  Bool      m_bUsePAD;                                        ///< flag for using source padding
     85#endif
    7886  Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
    79 
    80   Int       m_iNumberOfViews;                                ///< number Views to Encode
    81   Bool      m_bUsingDepthMaps ;
    82 
    83 #if FLEX_CODING_ORDER
    84   char*         m_pchMVCJointCodingOrder;               ///<  texture-depth coding order
    85   Bool          m_b3DVFlexOrder;                ///<  flexible coding order flag
    86 #endif
    87 
    88 
     87 
     88  Int       m_iNumberOfViews;                                 ///< number Views to Encode
     89  Bool      m_bUsingDepthMaps;
    8990  // coding structure
    90 #if DCM_DECODING_REFRESH
     91  Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
    9192  Int       m_iDecodingRefreshType;                           ///< random access type
    92 #endif
    93   UInt      m_uiCodedPictureStoreSize ;
    9493  Int       m_iGOPSize;                                       ///< GOP size of hierarchical structure
    95   Int       m_iRateGOPSize;                                   ///< GOP size for QP variance
    96 #if !HHI_NO_LowDelayCoding
    97   Bool      m_bUseLDC;                                        ///< flag for using low-delay coding mode
    98 #endif
    99 #if DCM_COMB_LIST
     94  Int       m_extraRPSs[MAX_VIEW_NUM];
     95  GOPEntryMvc m_GOPListsMvc[MAX_VIEW_NUM][MAX_GOP+1];
     96#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
     97  Int       m_numReorderPics[MAX_VIEW_NUM][MAX_TLAYER];       ///< total number of reorder pictures
     98  Int       m_maxDecPicBuffering[MAX_VIEW_NUM][MAX_TLAYER];   ///< total number of reference pictures needed for decoding
     99#else
     100  Int       m_numReorderFrames;                               ///< total number of reorder pictures
     101  Int       m_maxNumberOfReferencePictures;                   ///< total number of reference pictures needed for decoding
     102#endif
    100103  Bool      m_bUseLComb;                                      ///< flag for using combined reference list for uni-prediction in B-slices (JCTVC-D421)
    101104  Bool      m_bLCMod;                                         ///< flag for specifying whether the combined reference list for uni-prediction in B-slices is uploaded explicitly
    102 #endif
    103   std::string     m_cInputFormatString ;                            // GOP string
     105  Bool      m_bDisInter4x4;
     106  Bool      m_enableNSQT;                                     ///< flag for enabling NSQT
     107  Bool      m_enableAMP;
    104108  // coding quality
    105 
    106109  std::vector<Double>  m_adQP;                                ///< QP value of key-picture (floating point) [0] video, [1] depth
    107   std::vector<Int>     m_aiQP;                                ///< QP value of key-picture (integer)
    108 
     110  std::vector<Int>     m_aiQP;                                ///< QP value of key-picture (integer) [0] video, [1] depth
    109111  Int       m_aiTLayerQPOffset[MAX_TLAYER];                   ///< QP offset corresponding to temporal layer depth
    110112  char*     m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
    111113  Int*      m_aidQP;                                          ///< array of slice QP values
     114  Int*      m_aidQPdepth;                                     ///< array of depth slice QP values
    112115  Int       m_iMaxDeltaQP;                                    ///< max. |delta QP|
    113116  UInt      m_uiDeltaQpRD;                                    ///< dQP range for multi-pass slice QP optimization
     117  Int       m_iMaxCuDQPDepth;                                 ///< Max. depth for a minimum CuDQPSize (0:default)
     118
     119  Int       m_iChromaQpOffset;                                 ///< ChromaQpOffset    (0:default)
     120  Int       m_iChromaQpOffset2nd;                              ///< ChromaQpOffset2nd (0:default)
     121
     122#if ADAPTIVE_QP_SELECTION
     123  Bool      m_bUseAdaptQpSelect;
     124#endif
     125
     126  Bool      m_bUseAdaptiveQP;                                 ///< Flag for enabling QP adaptation based on a psycho-visual model
     127  Int       m_iQPAdaptationRange;                             ///< dQP range by QP adaptation
     128 
     129#if H0566_TLA
     130  Int       m_maxTempLayer[MAX_VIEW_NUM];                     ///< Max temporal layer
     131#else
     132  Bool      m_bTLayering;                                     ///< indicates whether temporal IDs are set based on the hierarchical coding structure
     133  Bool      m_abTLayerSwitchingFlag[MAX_TLAYER];              ///< temporal layer switching flags corresponding to each temporal layer
     134#endif
    114135
    115136  // coding unit (CU) definition
     
    117138  UInt      m_uiMaxCUHeight;                                  ///< max. CU height in pixel
    118139  UInt      m_uiMaxCUDepth;                                   ///< max. CU depth
    119 
     140 
    120141  // transfom unit (TU) definition
    121142  UInt      m_uiQuadtreeTULog2MaxSize;
    122143  UInt      m_uiQuadtreeTULog2MinSize;
    123 
     144 
    124145  UInt      m_uiQuadtreeTUMaxDepthInter;
    125146  UInt      m_uiQuadtreeTUMaxDepthIntra;
    126 
     147 
    127148  // coding tools (bit-depth)
    128149  UInt      m_uiInputBitDepth;                                ///< bit-depth of input file
    129150  UInt      m_uiOutputBitDepth;                               ///< bit-depth of output file
    130 #ifdef ENABLE_IBDI
    131   UInt      m_uiBitIncrement;                                 ///< bit-depth increment
    132 #endif
    133151  UInt      m_uiInternalBitDepth;                             ///< Internal bit-depth (BitDepth+BitIncrement)
    134152
    135 #if MTK_SAO
     153  // coding tools (PCM bit-depth)
     154  Bool      m_bPCMInputBitDepthFlag;                          ///< 0: PCM bit-depth is internal bit-depth. 1: PCM bit-depth is input bit-depth.
     155  UInt      m_uiPCMBitDepthLuma;                              ///< PCM bit-depth for luma
     156
     157  // coding tool (lossless)
     158#if LOSSLESS_CODING
     159  Bool      m_useLossless;                                    ///< flag for using lossless coding
     160#endif
    136161  vector<Bool> m_abUseSAO;
    137 #endif
    138 
     162#if SAO_UNIT_INTERLEAVING
     163  Int       m_maxNumOffsetsPerPic;                            ///< SAO maximun number of offset per picture
     164  Bool      m_saoInterleavingFlag;                            ///< SAO interleaving flag
     165#endif
    139166  // coding tools (loop filter)
    140167  vector<Bool> m_abUseALF;                                    ///< flag for using adaptive loop filter [0] - video, [1] - depth
    141 #ifdef MQT_ALF_NPASS
    142   Int       m_iALFEncodePassReduction;                        ///< ALF encoding pass, 0 = original 16-pass, 1 = 1-pass, 2 = 2-pass
     168  Int       m_iALFEncodePassReduction;                        //!< ALF encoding pass, 0 = original 16-pass, 1 = 1-pass, 2 = 2-pass
     169 
     170  Int       m_iALFMaxNumberFilters;                           ///< ALF Max Number Filters in one picture
     171#if LCU_SYNTAX_ALF
     172  Bool      m_bALFParamInSlice;
     173  Bool      m_bALFPicBasedEncode;
    143174#endif
    144175
    145176  vector<Bool> m_abLoopFilterDisable;                         ///< flag for using deblocking filter filter [0] - video, [1] - depth
    146   Int       m_iLoopFilterAlphaC0Offset;                       ///< alpha offset for deblocking filter
    147   Int       m_iLoopFilterBetaOffset;                          ///< beta offset for deblocking filter
    148 
    149   // coding tools (entropy coder)
    150   Int       m_iSymbolMode;                                    ///< entropy coder mode, 0 = VLC, 1 = CABAC
    151 
    152   // coding tools (inter - merge motion partitions)
    153   Bool      m_bUseMRG;                                        ///< SOPH: flag for using motion partition Merge Mode
    154 
    155 #if LM_CHROMA
     177  Bool      m_loopFilterOffsetInAPS;                         ///< offset for deblocking filter in 0 = slice header, 1 = APS
     178  Int       m_loopFilterBetaOffsetDiv2;                     ///< beta offset for deblocking filter
     179  Int       m_loopFilterTcOffsetDiv2;                       ///< tc offset for deblocking filter
     180#if DBL_CONTROL
     181  Bool      m_DeblockingFilterControlPresent;                 ///< deblocking filter control present flag in PPS
     182#endif
     183 
    156184  Bool      m_bUseLMChroma;                                  ///< JL: Chroma intra prediction based on luma signal
    157 #endif
    158 
    159 #if HHI_RMP_SWITCH
    160   Bool      m_bUseRMP;
    161 #endif
     185
     186  // coding tools (PCM)
     187  Bool      m_usePCM;                                         ///< flag for using IPCM
     188  UInt      m_pcmLog2MaxSize;                                 ///< log2 of maximum PCM block size
     189  UInt      m_uiPCMLog2MinSize;                               ///< log2 of minimum PCM block size
     190  Bool      m_bPCMFilterDisableFlag;                          ///< PCM filter disable flag
    162191
    163192  // coding tools (encoder-only parameters)
     
    165194  Bool      m_bUseASR;                                        ///< flag for using adaptive motion search range
    166195  Bool      m_bUseHADME;                                      ///< flag for using HAD in sub-pel ME
    167   vector<Bool> m_abUseRDOQ;                                   ///< flag for using RD optimized quantization [0]-video, [1]-depth
     196vector<Bool> m_abUseRDOQ;                                   ///< flag for using RD optimized quantization [0]-video, [1]-depth
    168197  Int       m_iFastSearch;                                    ///< ME mode, 0 = full, 1 = diamond, 2 = PMVFAST
    169198  Int       m_iSearchRange;                                   ///< ME search range
    170199  Int       m_bipredSearchRange;                              ///< ME search range for bipred refinement
    171200  Bool      m_bUseFastEnc;                                    ///< flag for using fast encoder setting
     201#if HHI_INTERVIEW_SKIP
     202  Bool      m_bInterViewSkip;                            ///< usage of interview skip mode ( do not transmit residual)
     203#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
     204  Double    m_dInterViewSkipLambdaScale;                 ///< lambda scale for interview skip
     205#endif
     206#endif
     207  Bool      m_bUseEarlyCU;                                    ///< flag for using Early CU setting
    172208
    173209#if DEPTH_MAP_GENERATION
     
    183219#endif
    184220
    185 #if HHI_INTERVIEW_SKIP
    186   UInt      m_uiInterViewSkip;                            ///< usage of interview skip mode ( do not transmit residual)
    187 #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
    188   Double    m_dInterViewSkipLambdaScale;                 ///< lambda scale for interview skip
    189 #endif
    190 #endif
     221#if FAST_DECISION_FOR_MRG_RD_COST
     222  Bool      m_useFastDecisionForMerge;                        ///< flag for using Fast Decision Merge RD-Cost
     223#endif
     224  Bool      m_bUseCbfFastMode;                              ///< flag for using Cbf Fast PU Mode Decision
     225  Int       m_iSliceMode;           ///< 0: Disable all Recon slice limits, 1 : Maximum number of largest coding units per slice, 2: Maximum number of bytes in a slice
     226  Int       m_iSliceArgument;       ///< If m_iSliceMode==1, m_iSliceArgument=max. # of largest coding units. If m_iSliceMode==2, m_iSliceArgument=max. # of bytes.
     227  Int       m_iEntropySliceMode;    ///< 0: Disable all entropy slice limits, 1 : Maximum number of largest coding units per slice, 2: Constraint based entropy slice
     228  Int       m_iEntropySliceArgument;///< If m_iEntropySliceMode==1, m_iEntropySliceArgument=max. # of largest coding units. If m_iEntropySliceMode==2, m_iEntropySliceArgument=max. # of bins.
     229
     230  Int       m_iSliceGranularity;///< 0: Slices always end at LCU borders. 1-3: slices may end at a depth of 1-3 below LCU level.
     231  Bool m_bLFCrossSliceBoundaryFlag;  ///< 0: Cross-slice-boundary in-loop filtering 1: non-cross-slice-boundary in-loop filtering
     232  Int  m_iTileBehaviorControlPresentFlag; //!< 1: tile behavior control parameters are in PPS 0: tile behavior control parameters are not in PPS
     233  Bool m_bLFCrossTileBoundaryFlag;  //!< 1: Cross-tile-boundary in-loop filtering 0: non-cross-tile-boundary in-loop filtering
     234  Int       m_iColumnRowInfoPresent;
     235  Int       m_iUniformSpacingIdr;
     236#if !REMOVE_TILE_DEPENDENCE
     237  Int       m_iTileBoundaryIndependenceIdr;
     238#endif
     239  Int       m_iNumColumnsMinus1;
     240  char*     m_pchColumnWidth;
     241  Int       m_iNumRowsMinus1;
     242  char*     m_pchRowHeight;
     243  Int       m_iTileLocationInSliceHeaderFlag; //< enable(1)/disable(0) transmitssion of tile location in slice header
     244  Int       m_iTileMarkerFlag;              //< enable(1)/disable(0) transmitssion of light weight tile marker
     245  Int       m_iMaxTileMarkerEntryPoints;    //< maximum number of tile markers allowed in a slice (controls degree of parallelism)
     246  Double    m_dMaxTileMarkerOffset;         //< Calculated offset. Light weight tile markers will be transmitted for TileIdx= Offset, 2*Offset, 3*Offset ...
     247
     248  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.
     249  Int       m_iWaveFrontFlush; //< enable(1)/disable(0) the CABAC flush at the end of each line of LCUs.
     250  Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
     251
     252  Bool      m_bUseConstrainedIntraPred;                       ///< flag for using constrained intra prediction
     253 
     254  bool m_pictureDigestEnabled; ///< enable(1)/disable(0) md5 computation and SEI signalling
     255
     256  // weighted prediction
     257  Bool      m_bUseWeightPred;                                 ///< Use of explicit Weighting Prediction for P_SLICE
     258  UInt      m_uiBiPredIdc;                                    ///< Use of Bi-Directional Weighting Prediction (B_SLICE): explicit(1) or implicit(2)
     259
     260  Bool      m_enableTMVP;
     261#if MULTIBITS_DATA_HIDING
     262  Int       m_signHideFlag;
     263  Int       m_signHidingThreshold;
     264#endif
     265#if HHI_MPI
     266  Bool      m_bUseMVI;  ///< flag for using Motion Vector Inheritance for depth map coding
     267#endif
     268
     269  Int       m_useScalingListId;                               ///< using quantization matrix
     270  char*     m_scalingListFile;                                ///< quantization matrix file name
    191271
    192272  // camera parameter
     
    196276
    197277  Int       m_iCodedCamParPrecision;                          ///< precision for coding of camera parameters
    198 
    199 #if HHI_INTERVIEW_SKIP
    200   TRenTop  m_cUsedPelsRenderer;                               ///< renderer for used pels map
    201 #endif
    202278
    203279#if HHI_VSO
     
    211287  Bool      m_bAllowNegDist;                              ///< Allow negative distortion in VSO
    212288#endif
    213   UInt      m_uiVSOMode;                                  ///< Number of VSO Mode, 1 = , 2 = simple, org vs. ren, 3 = simple, ren vs. ren, 4 = full
    214   Int       m_iNumberOfExternalRefs;                      ///< number Virtual External Reference Views
    215   std::vector< std::vector<Int> > m_aaiBaseViewRefInd;    ///< View numbers of Base View References
    216   std::vector< std::vector<Int> > m_aaiERViewRefInd;      ///< View numbers of External ViewReferences
    217   std::vector< std::vector<Int> > m_aaiERViewRefLutInd;   ///< Indices of LUTs used for External View References
    218 #endif
    219 
    220   Int       m_iSliceMode;           ///< 0: Disable all Recon slice limits, 1 : Maximum number of largest coding units per slice, 2: Maximum number of bytes in a slice
    221   Int       m_iSliceArgument;       ///< If m_iSliceMode==1, m_iSliceArgument=max. # of largest coding units. If m_iSliceMode==2, m_iSliceArgument=max. # of bytes.
    222   Int       m_iEntropySliceMode;    ///< 0: Disable all entropy slice limits, 1 : Maximum number of largest coding units per slice, 2: Constraint based entropy slice
    223   Int       m_iEntropySliceArgument;///< If m_iEntropySliceMode==1, m_iEntropySliceArgument=max. # of largest coding units. If m_iEntropySliceMode==2, m_iEntropySliceArgument=max. # of bins.
    224 
    225 #if MTK_NONCROSS_INLOOP_FILTER
    226   Bool m_bLFCrossSliceBoundaryFlag;  ///< 0: Cross-slice-boundary in-loop filtering 1: non-cross-slice-boundary in-loop filtering
    227 #endif
    228 #ifdef ROUNDING_CONTROL_BIPRED
    229   Bool m_useRoundingControlBipred;
    230 #endif
    231 #if CONSTRAINED_INTRA_PRED
    232   Bool      m_bUseConstrainedIntraPred;                       ///< flag for using constrained intra prediction
    233 #endif
     289  UInt      m_uiVSOMode;                                  ///< Number of VSO Mode, 1 = , 2 = simple, org vs. ren, 3 = simple, ren vs. ren, 4 = full 
     290#endif
     291
     292  // coding tools (depth intra modes)
    234293#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    235   Bool      m_bUseDMM;
    236 #endif
    237 #if HHI_MPI
    238   Bool      m_bUseMVI;  ///< flag for using Motion Vector Inheritance for depth map coding
    239 #endif
    240 
    241   PicOrderCnt m_iQpChangeFrame;
    242   Int         m_iQpChangeOffsetVideo;
    243   Int         m_iQpChangeOffsetDepth;
    244 
    245   bool m_pictureDigestEnabled; ///< enable(1)/disable(0) md5 computation and SEI signalling
    246 
    247   //====== Weighted Prediction ========
    248 #ifdef WEIGHT_PRED
    249   Bool                    m_bUseWeightPred;                   ///< Use of explicit Weighting Prediction for P_SLICE
    250   UInt                    m_uiBiPredIdc;                      ///< Use of Bi-Directional Weighting Prediction (B_SLICE): explicit(1) or implicit(2)
     294  Bool      m_bUseDMM;                                        ///< flag for using DMM
    251295#endif
    252296
     
    256300  Void  xPrintParameter ();                                   ///< print configuration values
    257301  Void  xPrintUsage     ();                                   ///< print usage
    258 
     302 
    259303  Void  xCleanUpVectors ();                                   ///< clean up vector sizes
    260304  Void  xInitCameraPars ();                                   ///< init camera parameters
     
    265309  Void xGetShiftParameter( UInt uiSourceView, UInt uiTargetView, bool bExternal, double& rdScale, double& rdOffset ); ///< Get one Shift Parameters
    266310
    267   // util
    268311  Void  xAppendToFileNameEnd( Char* pchInputFileName, const Char* pchStringToAppend, Char* & rpchOutputFileName);
    269   Bool  xConfirmParameter(Bool bflag, const char* message);
    270 
     312
     313  Void  xCheckCodingStructureMvc();                           ///< validate and configure inter-view coding structure
    271314
    272315  template <class T> Void xCleanUpVector( std::vector<T>& rcVec, const T& rcInvalid );
    273 
    274316#if HHI_VSO
    275317  // Ren Model String
     
    277319#endif
    278320public:
    279 
    280321  TAppEncCfg();
    281322  virtual ~TAppEncCfg();
    282 
     323 
    283324public:
    284325  Void  create    ();                                         ///< create option handling class
    285326  Void  destroy   ();                                         ///< destroy option handling class
    286327  Bool  parseCfg  ( Int argc, Char* argv[] );                 ///< parse configuration file to fill member variables
    287 
     328 
    288329};// END CLASS DEFINITION TAppEncCfg
    289330
     331//! \}
     332
    290333#endif // __TAPPENCCFG__
    291334
  • trunk/source/App/TAppEncoder/TAppEncTop.cpp

    r42 r56  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license.
     4 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2011, ISO/IEC
     6 * Copyright (c) 2010-2012, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    1515 *    this list of conditions and the following disclaimer in the documentation
    1616 *    and/or other materials provided with the distribution.
    17  *  * Neither the name of the ISO/IEC nor the names of its contributors may
     17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    1818 *    be used to endorse or promote products derived from this software without
    1919 *    specific prior written permission.
     
    3232 */
    3333
    34 
    35 
    3634/** \file     TAppEncTop.cpp
    3735    \brief    Encoder application class
     
    3937
    4038#include <list>
     39#include <fstream>
     40#include <stdlib.h>
    4141#include <stdio.h>
    4242#include <fcntl.h>
     
    4444
    4545#include "TAppEncTop.h"
     46#include "TLibEncoder/AnnexBwrite.h"
     47
     48using namespace std;
     49
     50//! \ingroup TAppEncoder
     51//! \{
    4652
    4753// ====================================================================================================================
     
    5157TAppEncTop::TAppEncTop()
    5258{
    53 #if HHI_VSO
    54   m_iLastFramePutInERViewBuffer = -1;
    55 #endif
     59  m_totalBytes = 0;
     60  m_essentialBytes = 0;
    5661}
    5762
     
    6065}
    6166
    62 
    6367Void TAppEncTop::xInitLibCfg()
    6468{
    6569  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    6670  {
    67     m_iFrameRcvdVector.push_back(0) ;
    68     m_acTEncTopList.push_back(new TEncTop);
    69 
     71    m_frameRcvd.push_back(0);
     72    m_acTEncTopList.push_back(new TEncTop);
    7073    m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv);
    71 
    7274    m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
    73     m_cListPicYuvRecList.push_back(new TComList<TComPicYuv*>) ;
    74     m_aiNextPocToDump.push_back( 0 );
    75     m_cListPicYuvRecMap.push_back( std::map<PicOrderCnt,TComPicYuv*>() );
     75    m_picYuvRec.push_back(new TComList<TComPicYuv*>) ;
     76
    7677    m_acTEncTopList[iViewIdx]->setFrameRate                    ( m_iFrameRate );
    7778    m_acTEncTopList[iViewIdx]->setFrameSkip                    ( m_FrameSkip );
    7879    m_acTEncTopList[iViewIdx]->setSourceWidth                  ( m_iSourceWidth );
    7980    m_acTEncTopList[iViewIdx]->setSourceHeight                 ( m_iSourceHeight );
     81#if PIC_CROPPING
     82    m_acTEncTopList[iViewIdx]->setCroppingMode                 ( m_croppingMode );
     83    m_acTEncTopList[iViewIdx]->setCropLeft                     ( m_cropLeft );
     84    m_acTEncTopList[iViewIdx]->setCropRight                    ( m_cropRight );
     85    m_acTEncTopList[iViewIdx]->setCropTop                      ( m_cropTop );
     86    m_acTEncTopList[iViewIdx]->setCropBottom                   ( m_cropBottom );
     87#endif
    8088    m_acTEncTopList[iViewIdx]->setFrameToBeEncoded             ( m_iFrameToBeEncoded );
     89    m_acTEncTopList[iViewIdx]->setViewId                       ( iViewIdx );
     90    m_acTEncTopList[iViewIdx]->setIsDepth                      ( false );
     91    m_acTEncTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
     92    m_acTEncTopList[iViewIdx]->setCamParPrecision              ( m_cCameraData.getCamParsCodedPrecision  () );
     93    m_acTEncTopList[iViewIdx]->setCamParInSliceHeader          ( m_cCameraData.getVaryingCameraParameters() );
     94    m_acTEncTopList[iViewIdx]->setCodedScale                   ( m_cCameraData.getCodedScale             () );
     95    m_acTEncTopList[iViewIdx]->setCodedOffset                  ( m_cCameraData.getCodedOffset            () );
    8196
    8297  //====== Coding Structure ========
    83 #if DCM_DECODING_REFRESH
     98    m_acTEncTopList[iViewIdx]->setIntraPeriod                  ( m_iIntraPeriod );
    8499    m_acTEncTopList[iViewIdx]->setDecodingRefreshType          ( m_iDecodingRefreshType );
    85 #endif
    86     m_acTEncTopList[iViewIdx]->setCPSSize                      ( m_uiCodedPictureStoreSize );
    87100    m_acTEncTopList[iViewIdx]->setGOPSize                      ( m_iGOPSize );
    88     m_acTEncTopList[iViewIdx]->setRateGOPSize                  ( m_iRateGOPSize );
    89 
    90     m_acTEncTopList[iViewIdx]->setSeqStructure                              ( m_cInputFormatString );
    91 
     101    m_acTEncTopList[iViewIdx]->setGopList                      ( m_GOPListsMvc[iViewIdx] );
     102    m_acTEncTopList[iViewIdx]->setExtraRPSs                    ( m_extraRPSs[iViewIdx] );
     103#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
     104    for(Int i = 0; i < MAX_TLAYER; i++)
     105    {
     106      m_acTEncTopList[iViewIdx]->setNumReorderPics             ( m_numReorderPics[iViewIdx][i], i );
     107      m_acTEncTopList[iViewIdx]->setMaxDecPicBuffering         ( m_maxDecPicBuffering[iViewIdx][i], i );
     108    }
     109#else
     110    m_acTEncTopList[iViewIdx]->setNumReorderFrames             ( m_numReorderFrames );
     111    m_acTEncTopList[iViewIdx]->setMaxNumberOfReferencePictures ( m_maxNumberOfReferencePictures );
     112#endif
     113    for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
     114    {
     115      m_acTEncTopList[iViewIdx]->setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
     116    }
    92117    m_acTEncTopList[iViewIdx]->setQP                           ( m_aiQP[0] );
    93 
     118 
    94119    m_acTEncTopList[iViewIdx]->setTemporalLayerQPOffset        ( m_aiTLayerQPOffset );
    95120    m_acTEncTopList[iViewIdx]->setPad                          ( m_aiPad );
    96 
    97     //===== Slice ========
    98 
    99     //====== Entropy Coding ========
    100     m_acTEncTopList[iViewIdx]->setSymbolMode                   ( m_iSymbolMode );
    101 
    102     //====== Loop/Deblock Filter ========
    103     m_acTEncTopList[iViewIdx]->setLoopFilterDisable            ( m_abLoopFilterDisable[0]   );
    104     m_acTEncTopList[iViewIdx]->setLoopFilterAlphaC0Offset      ( m_iLoopFilterAlphaC0Offset );
    105     m_acTEncTopList[iViewIdx]->setLoopFilterBetaOffset         ( m_iLoopFilterBetaOffset    );
    106 
    107     //====== Motion search ========
     121   
     122#if H0566_TLA
     123    m_acTEncTopList[iViewIdx]->setMaxTempLayer                 ( m_maxTempLayer[iViewIdx] );
     124#else
     125    m_acTEncTopList[iViewIdx]->setTLayering                    ( m_bTLayering );
     126    m_acTEncTopList[iViewIdx]->setTLayerSwitchingFlag          ( m_abTLayerSwitchingFlag );
     127#endif
     128
     129    m_acTEncTopList[iViewIdx]->setDisInter4x4                  ( m_bDisInter4x4);
     130 
     131    m_acTEncTopList[iViewIdx]->setUseNSQT( m_enableNSQT );
     132    m_acTEncTopList[iViewIdx]->setUseAMP( m_enableAMP );
     133 
     134  //===== Slice ========
     135 
     136  //====== Loop/Deblock Filter ========
     137    m_acTEncTopList[iViewIdx]->setLoopFilterDisable            ( m_abLoopFilterDisable[0]       );
     138    m_acTEncTopList[iViewIdx]->setLoopFilterOffsetInAPS        ( m_loopFilterOffsetInAPS );
     139    m_acTEncTopList[iViewIdx]->setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
     140    m_acTEncTopList[iViewIdx]->setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
     141#if DBL_CONTROL
     142    m_acTEncTopList[iViewIdx]->setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
     143#endif
     144
     145  //====== Motion search ========
    108146    m_acTEncTopList[iViewIdx]->setFastSearch                   ( m_iFastSearch  );
    109147    m_acTEncTopList[iViewIdx]->setSearchRange                  ( m_iSearchRange );
    110148    m_acTEncTopList[iViewIdx]->setBipredSearchRange            ( m_bipredSearchRange );
     149
     150  //====== Quality control ========
    111151    m_acTEncTopList[iViewIdx]->setMaxDeltaQP                   ( m_iMaxDeltaQP  );
    112 
     152    m_acTEncTopList[iViewIdx]->setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
     153
     154    m_acTEncTopList[iViewIdx]->setChromaQpOffset               ( m_iChromaQpOffset     );
     155    m_acTEncTopList[iViewIdx]->setChromaQpOffset2nd            ( m_iChromaQpOffset2nd  );
     156
     157#if ADAPTIVE_QP_SELECTION
     158    m_acTEncTopList[iViewIdx]->setUseAdaptQpSelect             ( m_bUseAdaptQpSelect   );
     159#endif
     160
     161#if LOSSLESS_CODING
     162    Int lowestQP;
     163#if H0736_AVC_STYLE_QP_RANGE
     164    lowestQP =  - ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) );
     165#else
     166    lowestQP = 0;
     167#endif
     168    if ((m_iMaxDeltaQP == 0 ) && (m_aiQP[0] == lowestQP) && (m_useLossless == true))
     169    {
     170      m_bUseAdaptiveQP = false;
     171    }
     172#endif
     173
     174    m_acTEncTopList[iViewIdx]->setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
     175    m_acTEncTopList[iViewIdx]->setQPAdaptationRange            ( m_iQPAdaptationRange );
     176 
    113177#if HHI_VSO
    114178    //====== VSO =========
     
    116180    m_acTEncTopList[iViewIdx]->setLambdaScaleVSO               ( 1     );
    117181    m_acTEncTopList[iViewIdx]->setVSOMode                      ( 0     );
    118 #endif
    119 
    120     //====== Tool list ========
     182    m_acTEncTopList[iViewIdx]->setUseVSO                       ( false ); //GT: might be enabled later for VSO Mode 4
     183#endif
     184
     185#if DEPTH_MAP_GENERATION
     186    m_acTEncTopList[iViewIdx]->setPredDepthMapGeneration       ( m_uiPredDepthMapGeneration );
     187    m_acTEncTopList[iViewIdx]->setPdmPrecision                 ( (UInt)m_cCameraData.getPdmPrecision     () );
     188    m_acTEncTopList[iViewIdx]->setPdmScaleNomDelta             (       m_cCameraData.getPdmScaleNomDelta () );
     189    m_acTEncTopList[iViewIdx]->setPdmOffset                    (       m_cCameraData.getPdmOffset        () );
     190#endif
     191#if HHI_INTER_VIEW_MOTION_PRED
     192    m_acTEncTopList[iViewIdx]->setMultiviewMvPredMode          ( m_uiMultiviewMvPredMode );
     193    m_acTEncTopList[iViewIdx]->setMultiviewMvRegMode           ( iViewIdx ? m_uiMultiviewMvRegMode       : 0   );
     194    m_acTEncTopList[iViewIdx]->setMultiviewMvRegLambdaScale    ( iViewIdx ? m_dMultiviewMvRegLambdaScale : 0.0 );
     195#endif
     196#if HHI_INTER_VIEW_RESIDUAL_PRED
     197    m_acTEncTopList[iViewIdx]->setMultiviewResPredMode         ( m_uiMultiviewResPredMode );
     198#endif
     199
     200  //====== Tool list ========
    121201    m_acTEncTopList[iViewIdx]->setUseSBACRD                    ( m_bUseSBACRD   );
    122202    m_acTEncTopList[iViewIdx]->setDeltaQpRD                    ( m_uiDeltaQpRD  );
     
    124204    m_acTEncTopList[iViewIdx]->setUseHADME                     ( m_bUseHADME    );
    125205    m_acTEncTopList[iViewIdx]->setUseALF                       ( m_abUseALF[0]  );
    126 #if MQT_ALF_NPASS
    127206    m_acTEncTopList[iViewIdx]->setALFEncodePassReduction       ( m_iALFEncodePassReduction );
    128 #endif
    129 #if DCM_COMB_LIST
     207#if LOSSLESS_CODING
     208    m_acTEncTopList[iViewIdx]->setUseLossless                  ( m_useLossless );
     209#endif
     210    m_acTEncTopList[iViewIdx]->setALFMaxNumberFilters          ( m_iALFMaxNumberFilters ) ;
     211
    130212    m_acTEncTopList[iViewIdx]->setUseLComb                     ( m_bUseLComb    );
    131213    m_acTEncTopList[iViewIdx]->setLCMod                        ( m_bLCMod         );
    132 #endif
    133214    m_acTEncTopList[iViewIdx]->setdQPs                         ( m_aidQP        );
    134215    m_acTEncTopList[iViewIdx]->setUseRDOQ                      ( m_abUseRDOQ[0] );
    135     m_acTEncTopList[iViewIdx]->setUseLDC                       ( m_bUseLDC      );
     216#if !PIC_CROPPING
    136217    m_acTEncTopList[iViewIdx]->setUsePAD                       ( m_bUsePAD      );
     218#endif
    137219    m_acTEncTopList[iViewIdx]->setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
    138220    m_acTEncTopList[iViewIdx]->setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
     
    140222    m_acTEncTopList[iViewIdx]->setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
    141223    m_acTEncTopList[iViewIdx]->setUseFastEnc                   ( m_bUseFastEnc  );
    142 
    143 #if HHI_VSO
    144     m_acTEncTopList[iViewIdx]->setUseVSO                       ( false ); //GT: might be enabled later for VSO Mode 4
    145 #endif
    146 
    147 #if BITSTREAM_EXTRACTION
    148     m_acTEncTopList[iViewIdx]->setLayerId                      ( ( (UInt)iViewIdx ) << 1 );
    149 #endif
    150     m_acTEncTopList[iViewIdx]->setViewId                       ( (UInt)iViewIdx );
    151     m_acTEncTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
    152     m_acTEncTopList[iViewIdx]->setIsDepth                      ( false );
    153     m_acTEncTopList[iViewIdx]->setCamParPrecision              ( m_cCameraData.getCamParsCodedPrecision  () );
    154     m_acTEncTopList[iViewIdx]->setCamParInSliceHeader          ( m_cCameraData.getVaryingCameraParameters() );
    155     m_acTEncTopList[iViewIdx]->setCodedScale                   ( m_cCameraData.getCodedScale             () );
    156     m_acTEncTopList[iViewIdx]->setCodedOffset                  ( m_cCameraData.getCodedOffset            () );
    157 #if DEPTH_MAP_GENERATION
    158     m_acTEncTopList[iViewIdx]->setPredDepthMapGeneration       ( m_uiPredDepthMapGeneration );
    159     m_acTEncTopList[iViewIdx]->setPdmPrecision                 ( (UInt)m_cCameraData.getPdmPrecision     () );
    160     m_acTEncTopList[iViewIdx]->setPdmScaleNomDelta             (       m_cCameraData.getPdmScaleNomDelta () );
    161     m_acTEncTopList[iViewIdx]->setPdmOffset                    (       m_cCameraData.getPdmOffset        () );
    162 #endif
    163 #if HHI_INTER_VIEW_MOTION_PRED
    164     m_acTEncTopList[iViewIdx]->setMultiviewMvPredMode          ( m_uiMultiviewMvPredMode );
    165     m_acTEncTopList[iViewIdx]->setMultiviewMvRegMode           ( iViewIdx ? m_uiMultiviewMvRegMode       : 0   );
    166     m_acTEncTopList[iViewIdx]->setMultiviewMvRegLambdaScale    ( iViewIdx ? m_dMultiviewMvRegLambdaScale : 0.0 );
    167 #endif
    168 #if HHI_INTER_VIEW_RESIDUAL_PRED
    169     m_acTEncTopList[iViewIdx]->setMultiviewResPredMode         ( m_uiMultiviewResPredMode );
    170 #endif
    171 
    172 
     224    m_acTEncTopList[iViewIdx]->setUseEarlyCU                   ( m_bUseEarlyCU  );
     225#if FAST_DECISION_FOR_MRG_RD_COST
     226    m_acTEncTopList[iViewIdx]->setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
     227#endif
     228    m_acTEncTopList[iViewIdx]->setUseCbfFastMode               ( m_bUseCbfFastMode  );
    173229#if HHI_INTERVIEW_SKIP
    174     m_acTEncTopList[iViewIdx]->setInterViewSkip            ( iViewIdx ? m_uiInterViewSkip : 0 );
     230    m_acTEncTopList[iViewIdx]->setInterViewSkip            ( iViewIdx>0 ? m_bInterViewSkip : false );
    175231#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
    176     m_acTEncTopList[iViewIdx]->setInterViewSkipLambdaScale ( iViewIdx ? (Int)m_dInterViewSkipLambdaScale : 1 );
    177 #endif
    178 #endif
    179     m_acTEncTopList[iViewIdx]->setUseMRG                       ( m_bUseMRG      ); // SOPH:
    180 
    181 #if LM_CHROMA
     232    m_acTEncTopList[iViewIdx]->setInterViewSkipLambdaScale ( iViewIdx>0 ? (UInt)m_dInterViewSkipLambdaScale : 1 );
     233#endif
     234#endif
    182235    m_acTEncTopList[iViewIdx]->setUseLMChroma                  ( m_bUseLMChroma );
    183 #endif
    184 
    185 #if HHI_RMP_SWITCH
    186     m_acTEncTopList[iViewIdx]->setUseRMP                     ( m_bUseRMP );
    187 #endif
    188 #ifdef ROUNDING_CONTROL_BIPRED
    189     m_acTEncTopList[iViewIdx]->setUseRoundingControlBipred(m_useRoundingControlBipred);
    190 #endif
     236    m_acTEncTopList[iViewIdx]->setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
     237    m_acTEncTopList[iViewIdx]->setPCMLog2MinSize               ( m_uiPCMLog2MinSize);
     238    m_acTEncTopList[iViewIdx]->setUsePCM                       ( m_usePCM );
     239    m_acTEncTopList[iViewIdx]->setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
     240
     241  //====== Weighted Prediction ========
     242    m_acTEncTopList[iViewIdx]->setUseWP                        ( m_bUseWeightPred      );
     243    m_acTEncTopList[iViewIdx]->setWPBiPredIdc                  ( m_uiBiPredIdc         );
     244  //====== Slice ========
     245    m_acTEncTopList[iViewIdx]->setSliceMode                    ( m_iSliceMode                );
     246    m_acTEncTopList[iViewIdx]->setSliceArgument                ( m_iSliceArgument            );
     247
     248  //====== Entropy Slice ========
     249    m_acTEncTopList[iViewIdx]->setEntropySliceMode             ( m_iEntropySliceMode         );
     250    m_acTEncTopList[iViewIdx]->setEntropySliceArgument         ( m_iEntropySliceArgument     );
     251    int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
     252    if(m_iEntropySliceMode==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE)
     253    {
     254      m_acTEncTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
     255    }
     256    if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE)
     257    {
     258      m_acTEncTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
     259    }
     260#if FIXED_NUMBER_OF_TILES_SLICE_MODE
     261    if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE)
     262    {
     263      m_acTEncTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument );
     264    }
     265#endif
     266    m_acTEncTopList[iViewIdx]->setSliceGranularity        ( m_iSliceGranularity         );
     267    if(m_iSliceMode == 0 )
     268    {
     269      m_bLFCrossSliceBoundaryFlag = true;
     270    }
     271    m_acTEncTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
     272    m_acTEncTopList[iViewIdx]->setUseSAO               ( m_abUseSAO[0]     );
     273#if SAO_UNIT_INTERLEAVING
     274    m_acTEncTopList[iViewIdx]->setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
     275    m_acTEncTopList[iViewIdx]->setSaoInterleavingFlag (m_saoInterleavingFlag);
     276#endif
     277    m_acTEncTopList[iViewIdx]->setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag);
     278    m_acTEncTopList[iViewIdx]->setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag);
     279
     280    m_acTEncTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled);
     281
     282    m_acTEncTopList[iViewIdx]->setColumnRowInfoPresent       ( m_iColumnRowInfoPresent );
     283    m_acTEncTopList[iViewIdx]->setUniformSpacingIdr          ( m_iUniformSpacingIdr );
     284#if !REMOVE_TILE_DEPENDENCE
     285    m_acTEncTopList[iViewIdx]->setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr );
     286#endif
     287    m_acTEncTopList[iViewIdx]->setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
     288    m_acTEncTopList[iViewIdx]->setNumRowsMinus1              ( m_iNumRowsMinus1 );
     289    if(m_iUniformSpacingIdr==0)
     290    {
     291      m_acTEncTopList[iViewIdx]->setColumnWidth              ( m_pchColumnWidth );
     292      m_acTEncTopList[iViewIdx]->setRowHeight                ( m_pchRowHeight );
     293    }
     294    m_acTEncTopList[iViewIdx]->xCheckGSParameters();
     295    m_acTEncTopList[iViewIdx]->setTileLocationInSliceHeaderFlag ( m_iTileLocationInSliceHeaderFlag );
     296    m_acTEncTopList[iViewIdx]->setTileMarkerFlag              ( m_iTileMarkerFlag );
     297    m_acTEncTopList[iViewIdx]->setMaxTileMarkerEntryPoints    ( m_iMaxTileMarkerEntryPoints );
     298 
     299    Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
     300    m_dMaxTileMarkerOffset    = ((Double)uiTilesCount) / m_iMaxTileMarkerEntryPoints;
     301    m_acTEncTopList[iViewIdx]->setMaxTileMarkerOffset         ( m_dMaxTileMarkerOffset );
     302    m_acTEncTopList[iViewIdx]->setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag );
     303#if !REMOVE_TILE_DEPENDENCE
     304    if(m_iTileBoundaryIndependenceIdr == 0 || uiTilesCount == 1)
     305#else
     306    if(uiTilesCount == 1)
     307#endif
     308    {
     309      m_bLFCrossTileBoundaryFlag = true;
     310    }
     311    m_acTEncTopList[iViewIdx]->setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
     312    m_acTEncTopList[iViewIdx]->setWaveFrontSynchro           ( m_iWaveFrontSynchro );
     313    m_acTEncTopList[iViewIdx]->setWaveFrontFlush             ( m_iWaveFrontFlush );
     314    m_acTEncTopList[iViewIdx]->setWaveFrontSubstreams        ( m_iWaveFrontSubstreams );
     315    m_acTEncTopList[iViewIdx]->setEnableTMVP ( m_enableTMVP );
     316    m_acTEncTopList[iViewIdx]->setUseScalingListId           ( m_useScalingListId  );
     317    m_acTEncTopList[iViewIdx]->setScalingListFile            ( m_scalingListFile   );
     318#if MULTIBITS_DATA_HIDING
     319    m_acTEncTopList[iViewIdx]->setSignHideFlag(m_signHideFlag);
     320    m_acTEncTopList[iViewIdx]->setTSIG(m_signHidingThreshold);
     321#endif
     322
     323#if LCU_SYNTAX_ALF
     324    if(uiTilesCount > 1)
     325    {
     326      m_bALFParamInSlice = false;
     327      m_bALFPicBasedEncode = true;
     328    }
     329    m_acTEncTopList[iViewIdx]->setALFParamInSlice              ( m_bALFParamInSlice);
     330    m_acTEncTopList[iViewIdx]->setALFPicBasedEncode            ( m_bALFPicBasedEncode);
     331#endif
     332
     333    //====== Depth tools ========
    191334#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    192     m_acTEncTopList[iViewIdx]->setUseDMM( false );
    193 #endif
    194 #if CONSTRAINED_INTRA_PRED
    195     m_acTEncTopList[iViewIdx]->setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
    196 #endif
    197 #ifdef WEIGHT_PRED
    198     //====== Weighted Prediction ========
    199     m_acTEncTopList[iViewIdx]->setUseWP                         ( m_bUseWeightPred      );
    200     m_acTEncTopList[iViewIdx]->setWPBiPredIdc                   ( m_uiBiPredIdc         );
    201 #endif
    202     //====== Slice ========
    203     m_acTEncTopList[iViewIdx]->setSliceMode               ( m_iSliceMode                );
    204     m_acTEncTopList[iViewIdx]->setSliceArgument           ( m_iSliceArgument            );
    205 
    206     //====== Entropy Slice ========
    207     m_acTEncTopList[iViewIdx]->setEntropySliceMode        ( m_iEntropySliceMode         );
    208     m_acTEncTopList[iViewIdx]->setEntropySliceArgument    ( m_iEntropySliceArgument     );
    209 #if MTK_NONCROSS_INLOOP_FILTER
    210     if(m_iSliceMode == 0 )
    211     {
    212       m_bLFCrossSliceBoundaryFlag = true;
    213     }
    214     m_acTEncTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
    215 #endif
    216 #if MTK_SAO
    217     m_acTEncTopList[iViewIdx]->setUseSAO               ( m_abUseSAO[0]     );
     335    m_acTEncTopList[iViewIdx]->setUseDMM                     ( false );
    218336#endif
    219337#if HHI_MPI
    220338    m_acTEncTopList[iViewIdx]->setUseMVI( false );
    221339#endif
    222 
    223     m_acTEncTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled);
    224     m_acTEncTopList[iViewIdx]->setQpChangeFrame( m_iQpChangeFrame );
    225     m_acTEncTopList[iViewIdx]->setQpChangeOffsetVideo( m_iQpChangeOffsetVideo );
    226     m_acTEncTopList[iViewIdx]->setQpChangeOffsetDepth( m_iQpChangeOffsetDepth );
    227340  }
    228341  if( m_bUsingDepthMaps )
    229342  {
    230 
    231 #if HHI_VSO
    232     for (Int iViewIdx=0; iViewIdx<m_iNumberOfExternalRefs; iViewIdx++)
    233     {
    234         m_acTVideoIOYuvERFileList.push_back(new TVideoIOYuv);
    235     }
    236 #endif
    237 
    238343    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    239344    {
    240 #if FLEX_CODING_ORDER
    241       // Detect whether depth comes before than texture for this view
    242       Bool isDepthFirst = false;
    243       if ( m_b3DVFlexOrder )
    244       {
    245         for ( Int ii=1; ii<12; ii+=2 )
    246         {
    247           Int iViewIdxCfg = (Int)(m_pchMVCJointCodingOrder[ii]-'0');
    248           if ( iViewIdxCfg == iViewIdx )
    249           {
    250             if ( m_pchMVCJointCodingOrder[ii-1]=='D' ) // depth comes first for this view
    251             {
    252               isDepthFirst = true;
    253             }
    254             else
    255             {
    256               assert(m_pchMVCJointCodingOrder[ii-1]=='T');
    257             }
    258             break;
    259           }
    260         }
    261       }
    262 #endif
    263       m_iDepthFrameRcvdVector.push_back(0) ;
    264       m_acTEncDepthTopList.push_back(new TEncTop);
    265 
     345      m_depthFrameRcvd.push_back(0);
     346      m_acTEncDepthTopList.push_back(new TEncTop);
    266347      m_acTVideoIOYuvDepthInputFileList.push_back(new TVideoIOYuv);
    267 
    268348      m_acTVideoIOYuvDepthReconFileList.push_back(new TVideoIOYuv);
    269       m_cListPicYuvDepthRecList.push_back(new TComList<TComPicYuv*>) ;
    270       m_aiNextDepthPocToDump.push_back( 0 );
    271       m_cListPicYuvDepthRecMap.push_back( std::map<PicOrderCnt,TComPicYuv*>() );
     349      m_picYuvDepthRec.push_back(new TComList<TComPicYuv*>) ;
     350
    272351      m_acTEncDepthTopList[iViewIdx]->setFrameRate                    ( m_iFrameRate );
    273352      m_acTEncDepthTopList[iViewIdx]->setFrameSkip                    ( m_FrameSkip );
    274353      m_acTEncDepthTopList[iViewIdx]->setSourceWidth                  ( m_iSourceWidth );
    275354      m_acTEncDepthTopList[iViewIdx]->setSourceHeight                 ( m_iSourceHeight );
     355#if PIC_CROPPING
     356      m_acTEncDepthTopList[iViewIdx]->setCroppingMode                 ( m_croppingMode );
     357      m_acTEncDepthTopList[iViewIdx]->setCropLeft                     ( m_cropLeft );
     358      m_acTEncDepthTopList[iViewIdx]->setCropRight                    ( m_cropRight );
     359      m_acTEncDepthTopList[iViewIdx]->setCropTop                      ( m_cropTop );
     360      m_acTEncDepthTopList[iViewIdx]->setCropBottom                   ( m_cropBottom );
     361#endif
    276362      m_acTEncDepthTopList[iViewIdx]->setFrameToBeEncoded             ( m_iFrameToBeEncoded );
     363      m_acTEncDepthTopList[iViewIdx]->setViewId                       ( iViewIdx );
     364      m_acTEncDepthTopList[iViewIdx]->setIsDepth                      ( true );
     365      m_acTEncDepthTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
     366      m_acTEncDepthTopList[iViewIdx]->setCamParPrecision              ( 0 );
     367      m_acTEncDepthTopList[iViewIdx]->setCamParInSliceHeader          ( false );
     368      m_acTEncDepthTopList[iViewIdx]->setCodedScale                   ( 0 );
     369      m_acTEncDepthTopList[iViewIdx]->setCodedOffset                  ( 0 );
    277370
    278371      //====== Coding Structure ========
    279 #if DCM_DECODING_REFRESH
     372      m_acTEncDepthTopList[iViewIdx]->setIntraPeriod                  ( m_iIntraPeriod );
    280373      m_acTEncDepthTopList[iViewIdx]->setDecodingRefreshType          ( m_iDecodingRefreshType );
    281 #endif
    282       m_acTEncDepthTopList[iViewIdx]->setCPSSize                      ( m_uiCodedPictureStoreSize );
    283374      m_acTEncDepthTopList[iViewIdx]->setGOPSize                      ( m_iGOPSize );
    284       m_acTEncDepthTopList[iViewIdx]->setRateGOPSize                  ( m_iRateGOPSize );
    285 
    286       m_acTEncDepthTopList[iViewIdx]->setSeqStructure                              ( m_cInputFormatString );
    287 
     375      m_acTEncDepthTopList[iViewIdx]->setGopList                      ( m_GOPListsMvc[iViewIdx] );
     376      m_acTEncDepthTopList[iViewIdx]->setExtraRPSs                    ( m_extraRPSs[iViewIdx] );
     377#if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
     378      for(Int i = 0; i < MAX_TLAYER; i++)
     379      {
     380        m_acTEncDepthTopList[iViewIdx]->setNumReorderPics             ( m_numReorderPics[iViewIdx][i], i );
     381        m_acTEncDepthTopList[iViewIdx]->setMaxDecPicBuffering         ( m_maxDecPicBuffering[iViewIdx][i], i );
     382      }
     383#else
     384      m_acTEncDepthTopList[iViewIdx]->setNumReorderFrames             ( m_numReorderFrames );
     385      m_acTEncDepthTopList[iViewIdx]->setMaxNumberOfReferencePictures ( m_maxNumberOfReferencePictures );
     386#endif
     387      for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
     388      {
     389        m_acTEncDepthTopList[iViewIdx]->setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
     390      }
    288391      m_acTEncDepthTopList[iViewIdx]->setQP                           ( m_aiQP[1] );
    289392
     
    291394      m_acTEncDepthTopList[iViewIdx]->setPad                          ( m_aiPad );
    292395
     396#if H0566_TLA
     397      m_acTEncDepthTopList[iViewIdx]->setMaxTempLayer                 ( m_maxTempLayer[iViewIdx] );
     398#else
     399      m_acTEncDepthTopList[iViewIdx]->setTLayering                    ( m_bTLayering );
     400      m_acTEncDepthTopList[iViewIdx]->setTLayerSwitchingFlag          ( m_abTLayerSwitchingFlag );
     401#endif
     402
     403      m_acTEncDepthTopList[iViewIdx]->setDisInter4x4                  ( m_bDisInter4x4);
     404
     405      m_acTEncDepthTopList[iViewIdx]->setUseNSQT( m_enableNSQT );
     406      m_acTEncDepthTopList[iViewIdx]->setUseAMP( m_enableAMP );
     407
    293408      //===== Slice ========
    294 
    295       //====== Entropy Coding ========
    296       m_acTEncDepthTopList[iViewIdx]->setSymbolMode                   ( m_iSymbolMode );
    297409
    298410      //====== Loop/Deblock Filter ========
    299411      m_acTEncDepthTopList[iViewIdx]->setLoopFilterDisable            ( m_abLoopFilterDisable[1]   );
    300       m_acTEncDepthTopList[iViewIdx]->setLoopFilterAlphaC0Offset      ( m_iLoopFilterAlphaC0Offset );
    301       m_acTEncDepthTopList[iViewIdx]->setLoopFilterBetaOffset         ( m_iLoopFilterBetaOffset    );
     412      m_acTEncDepthTopList[iViewIdx]->setLoopFilterOffsetInAPS        ( m_loopFilterOffsetInAPS );
     413      m_acTEncDepthTopList[iViewIdx]->setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
     414      m_acTEncDepthTopList[iViewIdx]->setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
     415#if DBL_CONTROL
     416      m_acTEncDepthTopList[iViewIdx]->setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
     417#endif
    302418
    303419      //====== Motion search ========
     
    305421      m_acTEncDepthTopList[iViewIdx]->setSearchRange                  ( m_iSearchRange );
    306422      m_acTEncDepthTopList[iViewIdx]->setBipredSearchRange            ( m_bipredSearchRange );
     423
     424      //====== Quality control ========
    307425      m_acTEncDepthTopList[iViewIdx]->setMaxDeltaQP                   ( m_iMaxDeltaQP  );
     426      m_acTEncDepthTopList[iViewIdx]->setMaxCuDQPDepth                ( m_iMaxCuDQPDepth  );
     427
     428      m_acTEncDepthTopList[iViewIdx]->setChromaQpOffset               ( m_iChromaQpOffset     );
     429      m_acTEncDepthTopList[iViewIdx]->setChromaQpOffset2nd            ( m_iChromaQpOffset2nd  );
     430
     431#if ADAPTIVE_QP_SELECTION
     432      m_acTEncDepthTopList[iViewIdx]->setUseAdaptQpSelect             ( m_bUseAdaptQpSelect   );
     433#endif
     434
     435      m_acTEncDepthTopList[iViewIdx]->setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
     436      m_acTEncDepthTopList[iViewIdx]->setQPAdaptationRange            ( m_iQPAdaptationRange );
    308437
    309438      //====== Tool list ========
     
    313442      m_acTEncDepthTopList[iViewIdx]->setUseHADME                     ( m_bUseHADME    );
    314443      m_acTEncDepthTopList[iViewIdx]->setUseALF                       ( m_abUseALF[1]  );
    315 #if MQT_ALF_NPASS
    316444      m_acTEncDepthTopList[iViewIdx]->setALFEncodePassReduction       ( m_iALFEncodePassReduction );
    317 #endif
    318 #if DCM_COMB_LIST
     445#if LOSSLESS_CODING
     446      m_acTEncDepthTopList[iViewIdx]->setUseLossless                  ( m_useLossless );
     447#endif
     448      m_acTEncDepthTopList[iViewIdx]->setALFMaxNumberFilters          ( m_iALFMaxNumberFilters ) ;
     449
    319450      m_acTEncDepthTopList[iViewIdx]->setUseLComb                     ( m_bUseLComb    );
    320       m_acTEncDepthTopList[iViewIdx]->setLCMod                        ( m_bLCMod         );
    321 #endif
    322       m_acTEncDepthTopList[iViewIdx]->setdQPs                         ( m_aidQP        );
     451      m_acTEncDepthTopList[iViewIdx]->setLCMod                        ( m_bLCMod       );
     452      m_acTEncDepthTopList[iViewIdx]->setdQPs                         ( m_aidQPdepth   );
    323453      m_acTEncDepthTopList[iViewIdx]->setUseRDOQ                      ( m_abUseRDOQ[1] );
    324       m_acTEncDepthTopList[iViewIdx]->setUseLDC                       ( m_bUseLDC      );
     454#if !PIC_CROPPING
    325455      m_acTEncDepthTopList[iViewIdx]->setUsePAD                       ( m_bUsePAD      );
     456#endif
    326457      m_acTEncDepthTopList[iViewIdx]->setQuadtreeTULog2MaxSize        ( m_uiQuadtreeTULog2MaxSize );
    327458      m_acTEncDepthTopList[iViewIdx]->setQuadtreeTULog2MinSize        ( m_uiQuadtreeTULog2MinSize );
     
    329460      m_acTEncDepthTopList[iViewIdx]->setQuadtreeTUMaxDepthIntra      ( m_uiQuadtreeTUMaxDepthIntra );
    330461      m_acTEncDepthTopList[iViewIdx]->setUseFastEnc                   ( m_bUseFastEnc  );
    331 
     462      m_acTEncDepthTopList[iViewIdx]->setUseEarlyCU                   ( m_bUseEarlyCU  );
     463#if FAST_DECISION_FOR_MRG_RD_COST
     464      m_acTEncDepthTopList[iViewIdx]->setUseFastDecisionForMerge      ( m_useFastDecisionForMerge  );
     465#endif
     466      m_acTEncDepthTopList[iViewIdx]->setUseCbfFastMode               ( m_bUseCbfFastMode  );
     467#if HHI_INTERVIEW_SKIP
     468      m_acTEncDepthTopList[iViewIdx]->setInterViewSkip            ( 0 );
     469#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
     470      m_acTEncDepthTopList[iViewIdx]->setInterViewSkipLambdaScale ( 1 );
     471#endif
     472#endif
     473      m_acTEncDepthTopList[iViewIdx]->setUseLMChroma                  ( m_bUseLMChroma );
     474      m_acTEncDepthTopList[iViewIdx]->setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
     475      m_acTEncDepthTopList[iViewIdx]->setPCMLog2MinSize               ( m_uiPCMLog2MinSize);
     476      m_acTEncDepthTopList[iViewIdx]->setUsePCM                       ( m_usePCM );
     477      m_acTEncDepthTopList[iViewIdx]->setPCMLog2MaxSize               ( m_pcmLog2MaxSize);
     478      //====== VSO ========
    332479#if HHI_VSO
    333480      m_acTEncDepthTopList[iViewIdx]->setUseVSO                       ( m_bUseVSO      ); //GT: might be enabled/disabled later for VSO Mode 4
     
    340487#endif
    341488
    342 #if BITSTREAM_EXTRACTION
    343       m_acTEncDepthTopList[iViewIdx]->setLayerId                      ( ( ( (UInt)iViewIdx ) << 1 ) + 1 );
    344 #endif
    345       m_acTEncDepthTopList[iViewIdx]->setViewId                       ( (UInt)iViewIdx );
    346       m_acTEncDepthTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
    347       m_acTEncDepthTopList[iViewIdx]->setIsDepth                      ( true );
    348       m_acTEncDepthTopList[iViewIdx]->setCamParPrecision              ( 0 );
    349       m_acTEncDepthTopList[iViewIdx]->setCamParInSliceHeader          ( false );
    350       m_acTEncDepthTopList[iViewIdx]->setCodedScale                   ( 0 );
    351       m_acTEncDepthTopList[iViewIdx]->setCodedOffset                  ( 0 );
    352489#if DEPTH_MAP_GENERATION
    353490      m_acTEncDepthTopList[iViewIdx]->setPredDepthMapGeneration       ( 0 );
     
    362499#endif
    363500
    364 #if HHI_INTERVIEW_SKIP
    365       m_acTEncDepthTopList[iViewIdx]->setInterViewSkip            ( 0 );
    366 #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
    367       m_acTEncDepthTopList[iViewIdx]->setInterViewSkipLambdaScale ( 1 );
    368 #endif
    369 #endif
    370       m_acTEncDepthTopList[iViewIdx]->setUseMRG                       ( m_bUseMRG      ); // SOPH:
    371 
    372 #if LM_CHROMA
    373       m_acTEncDepthTopList[iViewIdx]->setUseLMChroma                  ( m_bUseLMChroma );
    374 #endif
    375 
    376 #if HHI_RMP_SWITCH
    377       m_acTEncDepthTopList[iViewIdx]->setUseRMP                     ( m_bUseRMP );
    378 #endif
    379 #ifdef ROUNDING_CONTROL_BIPRED
    380       m_acTEncDepthTopList[iViewIdx]->setUseRoundingControlBipred(m_useRoundingControlBipred);
    381 #endif
     501      //====== Weighted Prediction ========
     502      m_acTEncDepthTopList[iViewIdx]->setUseWP                        ( m_bUseWeightPred      );
     503      m_acTEncDepthTopList[iViewIdx]->setWPBiPredIdc                  ( m_uiBiPredIdc         );
     504      //====== Slice ========
     505      m_acTEncDepthTopList[iViewIdx]->setSliceMode                    ( m_iSliceMode                );
     506      m_acTEncDepthTopList[iViewIdx]->setSliceArgument                ( m_iSliceArgument            );
     507
     508      //====== Entropy Slice ========
     509      m_acTEncDepthTopList[iViewIdx]->setEntropySliceMode             ( m_iEntropySliceMode         );
     510      m_acTEncDepthTopList[iViewIdx]->setEntropySliceArgument         ( m_iEntropySliceArgument     );
     511      int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1);
     512      if(m_iEntropySliceMode==SHARP_FIXED_NUMBER_OF_LCU_IN_ENTROPY_SLICE)
     513      {
     514        m_acTEncDepthTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
     515      }
     516      if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_LCU_IN_SLICE)
     517      {
     518        m_acTEncDepthTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument * ( iNumPartInCU >> ( m_iSliceGranularity << 1 ) ) );
     519      }
     520#if FIXED_NUMBER_OF_TILES_SLICE_MODE
     521      if(m_iSliceMode==AD_HOC_SLICES_FIXED_NUMBER_OF_TILES_IN_SLICE)
     522      {
     523        m_acTEncDepthTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument );
     524      }
     525#endif
     526      m_acTEncDepthTopList[iViewIdx]->setSliceGranularity        ( m_iSliceGranularity         );
     527      if(m_iSliceMode == 0 )
     528      {
     529        m_bLFCrossSliceBoundaryFlag = true;
     530      }
     531      m_acTEncDepthTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
     532      m_acTEncDepthTopList[iViewIdx]->setUseSAO               ( m_abUseSAO[1]     );
     533#if SAO_UNIT_INTERLEAVING
     534      m_acTEncDepthTopList[iViewIdx]->setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic);
     535      m_acTEncDepthTopList[iViewIdx]->setSaoInterleavingFlag (m_saoInterleavingFlag);
     536#endif
     537      m_acTEncDepthTopList[iViewIdx]->setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag);
     538      m_acTEncDepthTopList[iViewIdx]->setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag);
     539
     540      m_acTEncDepthTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled);
     541
     542      m_acTEncDepthTopList[iViewIdx]->setColumnRowInfoPresent       ( m_iColumnRowInfoPresent );
     543      m_acTEncDepthTopList[iViewIdx]->setUniformSpacingIdr          ( m_iUniformSpacingIdr );
     544#if !REMOVE_TILE_DEPENDENCE
     545      m_acTEncDepthTopList[iViewIdx]->setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr );
     546#endif
     547      m_acTEncDepthTopList[iViewIdx]->setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
     548      m_acTEncDepthTopList[iViewIdx]->setNumRowsMinus1              ( m_iNumRowsMinus1 );
     549      if(m_iUniformSpacingIdr==0)
     550      {
     551        m_acTEncDepthTopList[iViewIdx]->setColumnWidth              ( m_pchColumnWidth );
     552        m_acTEncDepthTopList[iViewIdx]->setRowHeight                ( m_pchRowHeight );
     553      }
     554      m_acTEncDepthTopList[iViewIdx]->xCheckGSParameters();
     555      m_acTEncDepthTopList[iViewIdx]->setTileLocationInSliceHeaderFlag ( m_iTileLocationInSliceHeaderFlag );
     556      m_acTEncDepthTopList[iViewIdx]->setTileMarkerFlag              ( m_iTileMarkerFlag );
     557      m_acTEncDepthTopList[iViewIdx]->setMaxTileMarkerEntryPoints    ( m_iMaxTileMarkerEntryPoints );
     558
     559      Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
     560      m_dMaxTileMarkerOffset    = ((Double)uiTilesCount) / m_iMaxTileMarkerEntryPoints;
     561      m_acTEncDepthTopList[iViewIdx]->setMaxTileMarkerOffset         ( m_dMaxTileMarkerOffset );
     562      m_acTEncDepthTopList[iViewIdx]->setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag );
     563#if !REMOVE_TILE_DEPENDENCE
     564      if(m_iTileBoundaryIndependenceIdr == 0 || uiTilesCount == 1)
     565#else
     566      if(uiTilesCount == 1)
     567#endif
     568      {
     569        m_bLFCrossTileBoundaryFlag = true;
     570      }
     571      m_acTEncDepthTopList[iViewIdx]->setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
     572      m_acTEncDepthTopList[iViewIdx]->setWaveFrontSynchro           ( m_iWaveFrontSynchro );
     573      m_acTEncDepthTopList[iViewIdx]->setWaveFrontFlush             ( m_iWaveFrontFlush );
     574      m_acTEncDepthTopList[iViewIdx]->setWaveFrontSubstreams        ( m_iWaveFrontSubstreams );
     575      m_acTEncDepthTopList[iViewIdx]->setEnableTMVP ( m_enableTMVP );
     576      m_acTEncDepthTopList[iViewIdx]->setUseScalingListId           ( m_useScalingListId  );
     577      m_acTEncDepthTopList[iViewIdx]->setScalingListFile            ( m_scalingListFile   );
     578#if MULTIBITS_DATA_HIDING
     579      m_acTEncDepthTopList[iViewIdx]->setSignHideFlag(m_signHideFlag);
     580      m_acTEncDepthTopList[iViewIdx]->setTSIG(m_signHidingThreshold);
     581#endif
     582
     583#if LCU_SYNTAX_ALF
     584      if(uiTilesCount > 1)
     585      {
     586        m_bALFParamInSlice = false;
     587        m_bALFPicBasedEncode = true;
     588      }
     589      m_acTEncDepthTopList[iViewIdx]->setALFParamInSlice              ( m_bALFParamInSlice);
     590      m_acTEncDepthTopList[iViewIdx]->setALFPicBasedEncode            ( m_bALFPicBasedEncode);
     591#endif
     592
     593  //====== Depth tools ========
    382594#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    383       m_acTEncDepthTopList[iViewIdx]->setUseDMM( m_bUseDMM );
    384 #endif
    385 #if FLEX_CODING_ORDER && HHI_DMM_PRED_TEX
    386       m_acTEncDepthTopList[iViewIdx]->setUseDMM34( (m_b3DVFlexOrder && isDepthFirst) ? false : m_bUseDMM );
    387 #endif
    388 #if CONSTRAINED_INTRA_PRED
    389       m_acTEncDepthTopList[iViewIdx]->setUseConstrainedIntraPred      ( m_bUseConstrainedIntraPred );
    390 #endif
    391 #ifdef WEIGHT_PRED
    392     //====== Weighted Prediction ========
    393       m_acTEncDepthTopList[iViewIdx]->setUseWP                         ( m_bUseWeightPred      );
    394       m_acTEncDepthTopList[iViewIdx]->setWPBiPredIdc                   ( m_uiBiPredIdc         );
    395 #endif
    396       //====== Slice ========
    397       m_acTEncDepthTopList[iViewIdx]->setSliceMode               ( m_iSliceMode                );
    398       m_acTEncDepthTopList[iViewIdx]->setSliceArgument           ( m_iSliceArgument            );
    399 
    400       //====== Entropy Slice ========
    401       m_acTEncDepthTopList[iViewIdx]->setEntropySliceMode        ( m_iEntropySliceMode         );
    402       m_acTEncDepthTopList[iViewIdx]->setEntropySliceArgument    ( m_iEntropySliceArgument     );
    403 #if MTK_NONCROSS_INLOOP_FILTER
    404       if(m_iSliceMode == 0 )
    405       {
    406         m_bLFCrossSliceBoundaryFlag = true;
    407       }
    408       m_acTEncDepthTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag );
    409 #endif
    410 #if MTK_SAO
    411       m_acTEncDepthTopList[iViewIdx]->setUseSAO               ( m_abUseSAO[1]     );
     595    m_acTEncDepthTopList[iViewIdx]->setUseDMM                     ( m_bUseDMM );
    412596#endif
    413597#if HHI_MPI
    414 #if FLEX_CODING_ORDER
    415       m_acTEncDepthTopList[iViewIdx]->setUseMVI( (m_b3DVFlexOrder && isDepthFirst) ? false : m_bUseMVI );
    416 #else
    417       m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI );
    418 #endif
    419 #endif
    420      
    421       m_acTEncDepthTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled);
    422 
    423       m_acTEncDepthTopList[iViewIdx]->setQpChangeFrame( m_iQpChangeFrame );
    424       m_acTEncDepthTopList[iViewIdx]->setQpChangeOffsetVideo( m_iQpChangeOffsetVideo );
    425       m_acTEncDepthTopList[iViewIdx]->setQpChangeOffsetDepth( m_iQpChangeOffsetDepth );
    426     }
    427   }
     598     m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI );
     599#endif
     600    }
     601  }
     602
    428603#if HHI_INTER_VIEW_MOTION_PRED
    429604  else if( m_uiMultiviewMvRegMode )
     
    466641    else
    467642    {
    468       m_cRendererTop.init(m_iSourceWidth, m_iSourceHeight,true,0,0,true, 0,0,0,0,0,0,0,1,0,0 );  //GT: simplest configuration
     643      AOT(true);
    469644    }
    470645  }
     
    474649  m_cUsedPelsRenderer.init(m_iSourceWidth, m_iSourceHeight, true, 0, LOG2_DISP_PREC_LUT, true, 0, 0, 0, 0, 0, 6, 4, 1, 0, 6 );
    475650#endif
     651
    476652}
    477653
    478654Void TAppEncTop::xCreateLib()
    479655{
    480   // Video I/O
    481   m_cTVideoIOBitsFile.openBits( m_pchBitstreamFile, true  );  // write mode
    482 
    483656  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    484657  {
    485658    m_acTVideoIOYuvInputFileList[iViewIdx]->open( m_pchInputFileList[iViewIdx],     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
    486     m_acTVideoIOYuvInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth, m_iSourceHeight);
    487     m_acTVideoIOYuvReconFileList[iViewIdx]->open( m_pchReconFileList[iViewIdx],     true, m_uiOutputBitDepth, m_uiInternalBitDepth);  // write mode
    488 
    489     // Neo Decoder
     659    m_acTVideoIOYuvInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
     660
     661    if (m_pchReconFileList[iViewIdx])
     662      m_acTVideoIOYuvReconFileList[iViewIdx]->open(m_pchReconFileList[iViewIdx], true, m_uiOutputBitDepth, m_uiInternalBitDepth);  // write mode
    490663    m_acTEncTopList[iViewIdx]->create();
    491 
    492664    if( m_bUsingDepthMaps )
     665    {
     666      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx],     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
     667      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]);
     668
     669      if (m_pchDepthReconFileList[iViewIdx])
     670        m_acTVideoIOYuvDepthReconFileList[iViewIdx]->open(m_pchDepthReconFileList[iViewIdx], true, m_uiOutputBitDepth, m_uiInternalBitDepth);  // write mode
     671      m_acTEncDepthTopList[iViewIdx]->create();
     672    }
     673#if HHI_INTER_VIEW_MOTION_PRED
     674    else if( m_uiMultiviewMvRegMode )
    493675    {
    494676      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx],     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
    495677      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth, m_iSourceHeight);
    496 
    497       m_acTVideoIOYuvDepthReconFileList[iViewIdx]->open( m_pchDepthReconFileList[iViewIdx],     true, m_uiOutputBitDepth, m_uiInternalBitDepth);  // write mode
    498 
    499       // Neo Decoder
    500       m_acTEncDepthTopList[iViewIdx]->create();
    501     }
    502 #if HHI_INTER_VIEW_MOTION_PRED
    503     else if( m_uiMultiviewMvRegMode )
    504     {
    505       m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx],     false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
    506       m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth, m_iSourceHeight);
    507     }
    508 #endif
    509   }
    510 
    511 #if HHI_VSO
    512   for(Int iViewIdx=0; iViewIdx < m_iNumberOfExternalRefs; iViewIdx++)
    513   {
    514     m_acTVideoIOYuvERFileList[iViewIdx]->open( m_pchERRefFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth ); // read mode
    515   }
    516 #endif
     678    }
     679#endif
     680  }
    517681}
    518682
    519683Void TAppEncTop::xDestroyLib()
    520684{
    521 
    522   m_cTVideoIOBitsFile.closeBits();
    523 
    524 #if HHI_VSO
    525   for ( Int iViewIdx = 0; iViewIdx < m_iNumberOfExternalRefs; iViewIdx++ )
    526   {
    527     m_acTVideoIOYuvERFileList[iViewIdx]->close();
    528     delete m_acTVideoIOYuvERFileList[iViewIdx];
    529     m_acTVideoIOYuvERFileList[iViewIdx] = 0;
    530   };
    531 #endif
    532 
     685  // Video I/O
    533686  for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    534687  {
    535688    m_acTVideoIOYuvInputFileList[iViewIdx]->close();
    536689    m_acTVideoIOYuvReconFileList[iViewIdx]->close();
    537 
    538     delete m_acTVideoIOYuvInputFileList[iViewIdx] ; m_acTVideoIOYuvInputFileList[iViewIdx] = NULL;
    539     delete m_acTVideoIOYuvReconFileList[iViewIdx] ; m_acTVideoIOYuvReconFileList[iViewIdx] = NULL;
    540 
    541     delete m_cListPicYuvRecList[iViewIdx] ; m_cListPicYuvRecList[iViewIdx] = NULL;
    542 
     690    delete m_acTVideoIOYuvInputFileList[iViewIdx] ;
     691    m_acTVideoIOYuvInputFileList[iViewIdx] = NULL;
     692    delete m_acTVideoIOYuvReconFileList[iViewIdx] ;
     693    m_acTVideoIOYuvReconFileList[iViewIdx] = NULL;
     694    m_acTEncTopList[iViewIdx]->deletePicBuffer();
    543695    m_acTEncTopList[iViewIdx]->destroy();
    544     delete m_acTEncTopList[iViewIdx] ; m_acTEncTopList[iViewIdx] = NULL;
     696    delete m_acTEncTopList[iViewIdx] ;
     697    m_acTEncTopList[iViewIdx] = NULL;
     698    delete m_picYuvRec[iViewIdx] ;
     699    m_picYuvRec[iViewIdx] = NULL;
    545700
    546701    if( iViewIdx < Int( m_acTVideoIOYuvDepthInputFileList.size() ) && m_acTVideoIOYuvDepthInputFileList[iViewIdx] )
    547702    {
    548703      m_acTVideoIOYuvDepthInputFileList[iViewIdx]->close( );
    549       delete m_acTVideoIOYuvDepthInputFileList[iViewIdx] ;
     704      delete m_acTVideoIOYuvDepthInputFileList[iViewIdx];
     705      m_acTVideoIOYuvDepthInputFileList[iViewIdx] = NULL;
    550706    }
    551707    if( iViewIdx < Int( m_acTVideoIOYuvDepthReconFileList.size() ) && m_acTVideoIOYuvDepthReconFileList[iViewIdx] )
     
    553709      m_acTVideoIOYuvDepthReconFileList[iViewIdx]->close () ;
    554710      delete m_acTVideoIOYuvDepthReconFileList[iViewIdx];
     711      m_acTVideoIOYuvDepthReconFileList[iViewIdx] = NULL;
    555712    }
    556713    if( iViewIdx < Int( m_acTEncDepthTopList.size() ) && m_acTEncDepthTopList[iViewIdx] )
    557714    {
     715      m_acTEncDepthTopList[iViewIdx]->deletePicBuffer();
    558716      m_acTEncDepthTopList[iViewIdx]->destroy();
    559717      delete m_acTEncDepthTopList[iViewIdx];
    560     }
    561     if( iViewIdx < Int( m_cListPicYuvDepthRecList.size() ) && m_cListPicYuvDepthRecList[iViewIdx] )
    562     {
    563       delete m_cListPicYuvDepthRecList[iViewIdx ];
     718      m_acTEncDepthTopList[iViewIdx] = NULL;
     719    }
     720    if( iViewIdx < Int( m_picYuvDepthRec.size() ) && m_picYuvDepthRec[iViewIdx] )
     721    {
     722      delete m_picYuvDepthRec[iViewIdx] ;
     723      m_picYuvDepthRec[iViewIdx] = NULL;
    564724    }
    565725  }
     
    601761 .
    602762 */
    603 //GT PRE LOAD ENC BUFFER
    604763Void TAppEncTop::encode()
    605764{
    606   TComPicYuv*       pcPicYuvOrg      = new TComPicYuv;
     765  fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out);
     766  if (!bitstreamFile)
     767  {
     768    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile);
     769    exit(EXIT_FAILURE);
     770  }
     771
     772  TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
    607773  TComPicYuv*       pcDepthPicYuvOrg = new TComPicYuv;
    608774  TComPicYuv*       pcPdmDepthOrg    = new TComPicYuv;
    609   TComPicYuv*       pcPicYuvRec      = NULL;
    610   //TComPicYuv*       pcDepthPicYuvRec = NULL;
    611 
     775  TComPicYuv*       pcPicYuvRec = NULL;
     776  TComPicYuv*       pcDepthPicYuvRec = NULL;
     777 
    612778  // initialize internal class & member variables
    613779  xInitLibCfg();
    614780  xCreateLib();
    615781  xInitLib();
    616 
     782 
    617783  // main encoder loop
    618 
    619   //GT: setup and init Bools for Eos and Continue Reading
    620   Bool  bAllEos = false;
    621   Bool  bAllContinueReadingPics = false;
    622   std::vector<Bool>  bEos ;
    623   std::vector<Bool>  bContinueReadingPics ;
    624 
    625   Bool  bAllDepthEos = false;
    626   Bool  bAllContinueReadingDepthPics = false;
    627   std::vector<Bool>  bDepthEos ;
    628   std::vector<Bool>  bContinueReadingDepthPics ;
     784  Bool  allEos = false;
     785  std::vector<Bool>  eos ;
     786  std::vector<Bool>  depthEos ;
     787  Int maxGopSize = 0;
     788  Int gopSize = 1;
     789 
     790  list<AccessUnit> outputAccessUnits; ///< list of access units to write out.  is populated by the encoding process
     791  maxGopSize = (std::max)(maxGopSize, m_acTEncTopList[0]->getGOPSize());   
     792
    629793  for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
    630794  {
    631     bEos.push_back( false ) ;
    632     bContinueReadingPics.push_back( true );
    633     if( m_bUsingDepthMaps)
    634     {
    635       bDepthEos.push_back( false ) ;
    636       bContinueReadingDepthPics.push_back( true ) ;
    637     }
    638   }
     795    eos.push_back( false );
     796    depthEos.push_back( false );
     797  }
     798
    639799  // allocate original YUV buffer
    640800  pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    641   if( m_bUsingDepthMaps)
    642   {
    643     pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    644   }
     801  pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     802
    645803#if HHI_INTER_VIEW_MOTION_PRED
    646804  if( m_uiMultiviewMvRegMode )
     
    650808#endif
    651809
    652   TComBitstream*    pcBitstream = new TComBitstream;
    653   pcBitstream->create( (m_iSourceWidth * m_iSourceHeight * 3) >> 1 ) ; //GT: is size reasonable ??
    654 
    655   while ( !(bAllEos&& bAllContinueReadingPics) )
    656   {
    657     bAllContinueReadingPics = false;
    658     bAllContinueReadingDepthPics = false;
    659 
    660     //GT: Read all Buffers
    661     for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) //GT; store frames first
    662     {
    663       if (!bEos[iViewIdx] && bContinueReadingPics[iViewIdx] ) //GT: read frames to buffer
     810  while ( !allEos )
     811  {
     812    for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
     813    {
     814      Int frmCnt = 0;
     815      while ( !eos[iViewIdx] && !(frmCnt == gopSize))
    664816      {
    665817        // get buffers
    666         xGetBuffer( pcPicYuvRec, iViewIdx, m_cListPicYuvRecList ); // ringbuffer of size gopsize -> m_cListPicYuvRec, m_cListBitstream
     818        xGetBuffer(pcPicYuvRec, iViewIdx, false);
     819
    667820        // read input YUV file
    668         m_acTVideoIOYuvInputFileList[iViewIdx]->read( pcPicYuvOrg, m_aiPad  ) ;
    669         bEos[iViewIdx] = ( m_acTVideoIOYuvInputFileList[iViewIdx]->isEof() == 1 ?   true : false  );             //GT: End of File
    670         bEos[iViewIdx] = ( m_iFrameRcvdVector[iViewIdx] == (m_iFrameToBeEncoded - 1) ?    true : bEos[iViewIdx]   );   //GT: FramesToBeEncoded Reached
    671         bAllEos = bAllEos|bEos[iViewIdx] ;
    672 
     821        m_acTVideoIOYuvInputFileList[iViewIdx]->read( pcPicYuvOrg, m_aiPad );
     822     
    673823#if HHI_INTER_VIEW_MOTION_PRED
    674824        if( m_uiMultiviewMvRegMode && iViewIdx )
     
    678828#endif
    679829
     830#if HHI_INTER_VIEW_MOTION_PRED
     831        m_acTEncTopList[iViewIdx]->initNewPic( pcPicYuvOrg, ( m_uiMultiviewMvRegMode && iViewIdx ? pcPdmDepthOrg : 0 ) );
     832#else
     833        m_acTEncTopList[iViewIdx]->initNewPic( pcPicYuvOrg );
     834#endif
     835
    680836        // increase number of received frames
    681         m_iFrameRcvdVector[iViewIdx]++ ;
    682       }
    683 
    684 #if HHI_INTER_VIEW_MOTION_PRED
    685       m_acTEncTopList[iViewIdx]->receivePic( bEos[iViewIdx],  pcPicYuvOrg, m_cListPicYuvRecList[iViewIdx]->back(), ( m_uiMultiviewMvRegMode && iViewIdx ? pcPdmDepthOrg : 0 ) );
    686 #else
    687       m_acTEncTopList[iViewIdx]->receivePic( bEos[iViewIdx],  pcPicYuvOrg, m_cListPicYuvRecList[iViewIdx]->back(), 0 );
    688 #endif
    689 
     837        m_frameRcvd[iViewIdx]++;
     838        frmCnt++;
     839        // check end of file
     840        eos[iViewIdx] = ( m_acTVideoIOYuvInputFileList[iViewIdx]->isEof() == 1 ?   true : false  );
     841        eos[iViewIdx] = ( m_frameRcvd[iViewIdx] == m_iFrameToBeEncoded ?    true : eos[iViewIdx]   );
     842        allEos = allEos|eos[iViewIdx] ;
     843      }
    690844      if( m_bUsingDepthMaps )
    691845      {
    692         if (!bDepthEos[iViewIdx] && bContinueReadingDepthPics[iViewIdx] )
     846        Int frmCntDepth = 0;
     847        while ( !depthEos[iViewIdx] && !(frmCntDepth == gopSize))
    693848        {
    694849          // get buffers
    695           xGetBuffer( pcPicYuvRec, iViewIdx, m_cListPicYuvDepthRecList ); // ringbuffer of size gopsize -> m_cListPicYuvRec, m_cListBitstream
     850          xGetBuffer(pcDepthPicYuvRec, iViewIdx, true);
     851
    696852          // read input YUV file
    697           m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcDepthPicYuvOrg, m_aiPad  ) ;
    698           bDepthEos[iViewIdx] = ( m_acTVideoIOYuvDepthInputFileList[iViewIdx]->isEof() == 1 ?   true : false  );
    699           bDepthEos[iViewIdx] = ( m_iDepthFrameRcvdVector[iViewIdx] == (m_iFrameToBeEncoded - 1) ?    true : bDepthEos[iViewIdx]  );
    700           bAllDepthEos = bAllDepthEos|bDepthEos[iViewIdx] ;
     853          m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcDepthPicYuvOrg, m_aiPad );
     854
     855          m_acTEncDepthTopList[iViewIdx]->initNewPic( pcDepthPicYuvOrg );
     856
    701857          // increase number of received frames
    702           m_iDepthFrameRcvdVector[iViewIdx]++ ;
     858          m_depthFrameRcvd[iViewIdx]++;
     859          frmCntDepth++;
     860          // check end of file
     861          depthEos[iViewIdx] = ( m_acTVideoIOYuvDepthInputFileList[iViewIdx]->isEof() == 1 ?   true : false  );
     862          depthEos[iViewIdx] = ( m_depthFrameRcvd[iViewIdx] == m_iFrameToBeEncoded ?    true : depthEos[iViewIdx]   );
     863          allEos = allEos|depthEos[iViewIdx] ;
    703864        }
    704         m_acTEncDepthTopList[iViewIdx]->receivePic( bDepthEos[iViewIdx],  pcDepthPicYuvOrg, m_cListPicYuvDepthRecList[iViewIdx]->back() );
    705       }
    706     }
    707 
    708     //===== store current POC =====
    709     Bool  bCurrPocCoded = m_acTEncTopList[ 0 ]->currentPocWillBeCoded();
    710     Int   iCurrPoc      = m_acTEncTopList[ 0 ]->getNextFrameId();
    711 
    712     //===== update camera parameters =====
    713     if( bCurrPocCoded )
    714     {
    715       m_cCameraData.update( (UInt)iCurrPoc );
    716     }
    717 
    718 #if HHI_VSO   
    719     if ( m_bUseVSO && ( m_uiVSOMode != 4) )
    720     {
    721       //GT: Read external reference pics or render references
    722       xStoreVSORefPicsInBuffer();       //GT;
    723     }
    724 #endif
    725 
    726 #if FLEX_CODING_ORDER
    727     if (m_b3DVFlexOrder)
    728     {
    729       Int i=0;
    730       Int iViewIdx = 0;
    731       bool bThisViewContinueReadingPics = false;
    732       bool bThisViewContinueReadingDepthPics = false;
    733       Int iNumberofDepthViews = m_bUsingDepthMaps?m_iNumberOfViews:0;
    734       for(Int j=0; j < (m_iNumberOfViews+ iNumberofDepthViews); j++ )     // Start encoding
    735       {
    736         if (m_pchMVCJointCodingOrder[i]=='T')
     865      }
     866    }
     867    for ( Int gopId=0; gopId < gopSize; gopId++ )
     868    {
     869      Int  iNumEncoded = 0;
     870      UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId );
     871      if ( iNextPoc < m_iFrameToBeEncoded )
     872      {
     873      m_cCameraData.update( iNextPoc );
     874      }
     875      for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
     876      {
     877        iNumEncoded = 0;
     878        // call encoding function for one frame
     879        m_acTEncTopList[iViewIdx]->encode( eos[iViewIdx], pcPicYuvOrg, *m_picYuvRec[iViewIdx], outputAccessUnits, iNumEncoded, gopId );
     880        xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, iViewIdx, false);
     881        outputAccessUnits.clear();
     882        if( m_bUsingDepthMaps )
    737883        {
    738           i++;
    739           assert(isdigit(m_pchMVCJointCodingOrder[i]));
    740           iViewIdx = (Int)(m_pchMVCJointCodingOrder[i]-'0');
    741           bThisViewContinueReadingPics = bContinueReadingPics[iViewIdx];
    742           m_acTEncTopList[iViewIdx]->encode( bEos[iViewIdx], m_cListPicYuvRecMap[iViewIdx], pcBitstream, bThisViewContinueReadingPics );
    743           bContinueReadingPics[iViewIdx]=bThisViewContinueReadingPics;
    744           bAllContinueReadingPics = bAllContinueReadingPics||bContinueReadingPics[iViewIdx];
    745 
    746           if(pcBitstream->getNumberOfWrittenBits()!=0)
    747           {
    748             m_cTVideoIOBitsFile.writeBits( pcBitstream );
    749           }
    750           pcBitstream->resetBits(); //GT: also done later in ....
    751           pcBitstream->rewindStreamPacket( );
    752           // write bistream to file if necessary
    753           xWriteOutput( iViewIdx ); //GT: Write Reconfiles (when gop is complete?)
    754           i++;
     884          Int  iNumDepthEncoded = 0;
     885          // call encoding function for one depth frame
     886          m_acTEncDepthTopList[iViewIdx]->encode( depthEos[iViewIdx], pcDepthPicYuvOrg, *m_picYuvDepthRec[iViewIdx], outputAccessUnits, iNumDepthEncoded, gopId );
     887          xWriteOutput(bitstreamFile, iNumDepthEncoded, outputAccessUnits, iViewIdx, true);
     888          outputAccessUnits.clear();
    755889        }
    756         else if ( m_pchMVCJointCodingOrder[i] == 'D')
    757         {
    758           i++;
    759           if( m_bUsingDepthMaps )
    760           {
    761             assert(isdigit(m_pchMVCJointCodingOrder[i]));
    762             iViewIdx = (Int)(m_pchMVCJointCodingOrder[i]-'0');
    763             bThisViewContinueReadingDepthPics = bContinueReadingDepthPics[iViewIdx];
    764             m_acTEncDepthTopList[iViewIdx]->encode( bDepthEos[iViewIdx], m_cListPicYuvDepthRecMap[iViewIdx], pcBitstream, bThisViewContinueReadingDepthPics );
    765             bContinueReadingDepthPics[iViewIdx]=bThisViewContinueReadingDepthPics;
    766 
    767             bAllContinueReadingDepthPics = bAllContinueReadingDepthPics||bContinueReadingDepthPics[iViewIdx];
    768             if(pcBitstream->getNumberOfWrittenBits()!=0)
    769             {
    770               m_cTVideoIOBitsFile.writeBits( pcBitstream );
    771             }
    772             pcBitstream->resetBits();
    773             pcBitstream->rewindStreamPacket( );
    774             // write bistream to file if necessary
    775             xWriteOutput( iViewIdx, true );
    776             i++;
    777           }
    778         }
    779       }
    780     }
    781     else
    782     {
    783 #endif
    784     //GT: Encode
    785     for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )     // Start encoding
    786     {
    787       bool bThisViewContinueReadingPics = bContinueReadingPics[iViewIdx];
    788       m_acTEncTopList[iViewIdx]->encode( bEos[iViewIdx], m_cListPicYuvRecMap[iViewIdx], pcBitstream, bThisViewContinueReadingPics );
    789       bContinueReadingPics[iViewIdx]=bThisViewContinueReadingPics;
    790       bAllContinueReadingPics = bAllContinueReadingPics||bContinueReadingPics[iViewIdx];
    791 
    792       if(pcBitstream->getNumberOfWrittenBits()!=0)
    793       {
    794         m_cTVideoIOBitsFile.writeBits( pcBitstream );
    795       }
    796       pcBitstream->resetBits(); //GT: also done later in ....
    797       pcBitstream->rewindStreamPacket( );
    798       // write bistream to file if necessary
    799       xWriteOutput( iViewIdx ); //GT: Write Reconfiles (when gop is complete?)
    800 
    801       if( m_bUsingDepthMaps )
    802       {
    803         bool bThisViewContinueReadingDepthPics = bContinueReadingDepthPics[iViewIdx];
    804         m_acTEncDepthTopList[iViewIdx]->encode( bDepthEos[iViewIdx], m_cListPicYuvDepthRecMap[iViewIdx], pcBitstream, bThisViewContinueReadingDepthPics );
    805         bContinueReadingDepthPics[iViewIdx]=bThisViewContinueReadingDepthPics;
    806 
    807         bAllContinueReadingDepthPics = bAllContinueReadingDepthPics||bContinueReadingDepthPics[iViewIdx];
    808         if(pcBitstream->getNumberOfWrittenBits()!=0)
    809         {
    810           m_cTVideoIOBitsFile.writeBits( pcBitstream );
    811         }
    812         pcBitstream->resetBits();
    813         pcBitstream->rewindStreamPacket( );
    814         // write bistream to file if necessary
    815         xWriteOutput( iViewIdx, true );
    816       }
    817     }
    818 #if FLEX_CODING_ORDER
    819         }
    820 #endif
    821     // delete extra picture buffers
    822     if( bCurrPocCoded )
    823     {
     890      }
     891#if HHI_INTERVIEW_SKIP || HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED
    824892      for( Int iViewIdx = 0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
    825893      {
    826894        if( iViewIdx < (Int)m_acTEncTopList.size() && m_acTEncTopList[iViewIdx] )
    827895        {
    828           m_acTEncTopList[iViewIdx]->deleteExtraPicBuffers( iCurrPoc );
     896          m_acTEncTopList[iViewIdx]->deleteExtraPicBuffers( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() );
    829897        }
    830898        if( iViewIdx < (Int)m_acTEncDepthTopList.size() && m_acTEncDepthTopList[iViewIdx] )
    831899        {
    832           m_acTEncDepthTopList[iViewIdx]->deleteExtraPicBuffers( iCurrPoc );
     900          m_acTEncDepthTopList[iViewIdx]->deleteExtraPicBuffers( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() );
    833901        }
    834902      }
    835     }
    836 
    837 #if AMVP_BUFFERCOMPRESS
    838     // compress motion for entire access
    839     if( bCurrPocCoded )
    840     {
    841       for( Int iViewIdx = 0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
    842       {
    843         if( iViewIdx < (Int)m_acTEncTopList.size() && m_acTEncTopList[iViewIdx] )
     903#endif
     904      for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
     905      {
     906        m_acTEncTopList[iViewIdx]->compressMotion( m_acTEncTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() );
     907        if( m_bUsingDepthMaps )
    844908        {
    845           m_acTEncTopList[iViewIdx]->compressMotion( iCurrPoc );
     909          m_acTEncDepthTopList[iViewIdx]->compressMotion( m_acTEncDepthTopList[iViewIdx]->getGOPEncoder()->getPocLastCoded() );
    846910        }
    847         if( iViewIdx < (Int)m_acTEncDepthTopList.size() && m_acTEncDepthTopList[iViewIdx] )
    848         {
    849           m_acTEncDepthTopList[iViewIdx]->compressMotion( iCurrPoc );
    850         }
    851       }
    852     }
    853 #endif
    854   }
    855 
    856   // write output
    857   for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
    858   {
    859     m_acTEncTopList[iViewIdx]->printOutSummary(m_acTEncTopList[iViewIdx]->getNumAllPicCoded());
    860     if ( m_bUsingDepthMaps )
    861     {
    862       m_acTEncDepthTopList[iViewIdx]->printOutSummary(m_acTEncDepthTopList[iViewIdx]->getNumAllPicCoded());
    863     }
    864   }
    865 
     911      }
     912    }
     913    gopSize = maxGopSize;
     914  }
    866915  // delete original YUV buffer
    867916  pcPicYuvOrg->destroy();
    868917  delete pcPicYuvOrg;
    869918  pcPicYuvOrg = NULL;
    870 
    871   // valgrind
    872   if( m_bUsingDepthMaps)
    873   {
    874     pcDepthPicYuvOrg->destroy();
    875   }
    876   delete pcDepthPicYuvOrg ;
    877   pcDepthPicYuvOrg = NULL ;
    878 
    879   pcBitstream->destroy();
    880   delete pcBitstream;
    881   pcBitstream = NULL ;
    882 
    883 
    884   // delete used buffers in encoder class
    885   for(Int iViewIdx =0; iViewIdx < m_iNumberOfViews; iViewIdx++)
    886   {
    887     m_acTEncTopList[iViewIdx]->deletePicBuffer() ;
    888   }
    889 
    890   if( m_bUsingDepthMaps)
    891   {
    892     for(Int iViewIdx =0; iViewIdx < m_iNumberOfViews; iViewIdx++)
    893     {
    894       m_acTEncDepthTopList[iViewIdx]->deletePicBuffer() ;
    895     }
    896   }
    897 
    898   if ( pcPdmDepthOrg )
    899   {
    900     pcPdmDepthOrg->destroy();
    901     delete pcPdmDepthOrg;
    902     pcPdmDepthOrg = NULL;
     919  pcDepthPicYuvOrg->destroy();
     920  delete pcDepthPicYuvOrg;
     921  pcDepthPicYuvOrg = NULL;
     922 
     923  for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
     924  {
     925    m_acTEncTopList[iViewIdx]->printOutSummary(m_acTEncTopList[iViewIdx]->getNumAllPicCoded());
     926    if ( m_bUsingDepthMaps )
     927    {
     928      m_acTEncDepthTopList[iViewIdx]->printOutSummary(m_acTEncDepthTopList[iViewIdx]->getNumAllPicCoded());
     929    }
    903930  }
    904931
     
    906933  xDeleteBuffer();
    907934  xDestroyLib();
    908 }
     935
     936  return;
     937}
     938
     939TEncTop*  TAppEncTop::getTEncTop( Int viewId, Bool isDepth )   
     940{
     941  if ( isDepth ) 
     942  {
     943    return m_acTEncDepthTopList[viewId];
     944  }
     945  else
     946  {
     947    return m_acTEncTopList[viewId];
     948  }
     949}
     950
    909951
    910952// ====================================================================================================================
     
    918960 .
    919961 */
    920 Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, Int iViewIdx, std::vector< TComList<TComPicYuv*>*>& racBuffer )
    921 {
    922   if ( m_uiCodedPictureStoreSize   == 0 )
    923     {
    924       if (racBuffer[iViewIdx]->size() == 0)
    925       {
    926         rpcPicYuvRec = new TComPicYuv;
    927         rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    928 
    929         racBuffer[iViewIdx]->pushBack( rpcPicYuvRec );
    930       }
    931       rpcPicYuvRec = racBuffer[iViewIdx]->popFront(); //GT why? only one in list ?? A: only to get rpcPicYuvRec
    932       racBuffer[iViewIdx]->pushBack( rpcPicYuvRec );
    933       return;
    934     }
    935 
    936     // org. buffer
    937   if ( racBuffer[iViewIdx]->size() == (UInt)m_uiCodedPictureStoreSize )
    938     {
    939       rpcPicYuvRec = racBuffer[iViewIdx]->popFront();
     962Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, Int iViewIdx, Bool isDepth)
     963{
     964  assert( m_iGOPSize > 0 );
     965 
     966  if( !isDepth )
     967  {
     968    if ( m_picYuvRec[iViewIdx]->size() == (UInt)m_iGOPSize )
     969    {
     970      rpcPicYuvRec = m_picYuvRec[iViewIdx]->popFront();
    940971    }
    941972    else
    942973    {
    943       rpcPicYuvRec = new TComPicYuv;
     974      rpcPicYuvRec = new TComPicYuv; 
    944975      rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    945976    }
    946     racBuffer[iViewIdx]->pushBack( rpcPicYuvRec );
     977    m_picYuvRec[iViewIdx]->pushBack( rpcPicYuvRec );
     978  }
     979  else
     980  {
     981    if ( m_picYuvDepthRec[iViewIdx]->size() == (UInt)m_iGOPSize )
     982    {
     983      rpcPicYuvRec = m_picYuvDepthRec[iViewIdx]->popFront();
     984    }
     985    else
     986    {
     987      rpcPicYuvRec = new TComPicYuv;
     988      rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
     989    }
     990    m_picYuvDepthRec[iViewIdx]->pushBack( rpcPicYuvRec );
     991  }
    947992}
    948993
    949994Void TAppEncTop::xDeleteBuffer( )
    950995{
    951   TComList<TComBitstream*>::iterator iterBitstream = m_cListBitstream.begin();
    952 
    953   Int iSize = Int( m_cListBitstream.size() );
    954 
    955   for ( Int i = 0; i < iSize; i++ )
    956   {
    957     TComBitstream* pcBitstream = *(iterBitstream++);
    958 
    959     pcBitstream->destroy();
    960 
    961     delete pcBitstream; pcBitstream = NULL;
    962   }
    963 
    964   for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    965   {
    966     TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvRecList[iViewIdx]->begin();
    967 
    968     iSize = Int( m_cListPicYuvRecList[iViewIdx]->size() );
    969 
    970     for ( Int i = 0; i < iSize; i++ )
    971     {
     996  for(Int iViewIdx=0; iViewIdx<m_picYuvRec.size(); iViewIdx++)
     997  {
     998    if(m_picYuvRec[iViewIdx])
     999    {
     1000      TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_picYuvRec[iViewIdx]->begin();
     1001      Int iSize = Int( m_picYuvRec[iViewIdx]->size() );
     1002      for ( Int i = 0; i < iSize; i++ )
     1003      {
    9721004        TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
    973         pcPicYuvRec->destroy();
    974         delete pcPicYuvRec; pcPicYuvRec = NULL;
    975     }
    976   }
    977   if( m_bUsingDepthMaps)
    978   {
    979     for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
    980     {
    981       TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_cListPicYuvDepthRecList[iViewIdx]->begin();
    982 
    983       iSize = Int( m_cListPicYuvDepthRecList[iViewIdx]->size() );
    984 
     1005        if(pcPicYuvRec)
     1006        {
     1007          pcPicYuvRec->destroy();
     1008          delete pcPicYuvRec;
     1009          pcPicYuvRec = NULL;
     1010        }
     1011      }
     1012    }
     1013  }
     1014  for(Int iViewIdx=0; iViewIdx<m_picYuvDepthRec.size(); iViewIdx++)
     1015  {
     1016    if(m_picYuvDepthRec[iViewIdx])
     1017    {
     1018      TComList<TComPicYuv*>::iterator iterPicYuvRec  = m_picYuvDepthRec[iViewIdx]->begin();
     1019      Int iSize = Int( m_picYuvDepthRec[iViewIdx]->size() );
    9851020      for ( Int i = 0; i < iSize; i++ )
    9861021      {
    987           TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1022        TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1023        if(pcPicYuvRec)
     1024        {
    9881025          pcPicYuvRec->destroy();
    989           delete pcPicYuvRec; pcPicYuvRec = NULL;
    990       }
    991     }
    992   }
    993 
    994   // Delete ERFiles
    995 
    996 #if HHI_VSO
    997   std::map< Int,vector<TComPicYuv*> >::iterator iterMapPicExtRefView = m_cMapPicExtRefView.begin();
    998   while ( iterMapPicExtRefView != m_cMapPicExtRefView.end() )
    999   {
    1000     for ( UInt uiViewNumber = 0; uiViewNumber < iterMapPicExtRefView->second.size(); uiViewNumber++ )
    1001     {
    1002       if ( iterMapPicExtRefView->second[uiViewNumber] )
    1003       {
    1004         iterMapPicExtRefView->second[uiViewNumber]->destroy();
    1005         delete iterMapPicExtRefView->second[uiViewNumber];
    1006       }
    1007     }
    1008     iterMapPicExtRefView++;
    1009   }
    1010 #endif
     1026          delete pcPicYuvRec;
     1027          pcPicYuvRec = NULL;
     1028        }
     1029      }
     1030    }
     1031  }
    10111032}
    10121033
    10131034/** \param iNumEncoded  number of encoded frames
    10141035 */
    1015 Void TAppEncTop::xWriteOutput( Int iViewIdx, Bool isDepth )
    1016 {
    1017   std::map<PicOrderCnt, TComPicYuv*> &rcMap = ( isDepth ? m_cListPicYuvDepthRecMap          : m_cListPicYuvRecMap          )[iViewIdx];
    1018   PicOrderCnt  &riNextPocToDump             = ( isDepth ? m_aiNextDepthPocToDump            : m_aiNextPocToDump            )[iViewIdx];
    1019   TVideoIOYuv* &rpcTVideoIOYuvReconFile     = ( isDepth ? m_acTVideoIOYuvDepthReconFileList : m_acTVideoIOYuvReconFileList )[iViewIdx];
    1020   std::map<PicOrderCnt, TComPicYuv*>::iterator i;
    1021 
    1022   while( ! rcMap.empty() && ( i = rcMap.begin() )->first == riNextPocToDump )
    1023   {
    1024     riNextPocToDump++;
    1025     rpcTVideoIOYuvReconFile->write( i->second, m_aiPad );
    1026     rcMap.erase( i );
    1027   }
    1028 }
    1029 
    1030 // GT FIX
    1031 std::vector<TComPic*> TAppEncTop::getSpatialRefPics( Int iViewIdx, Int iPoc, Bool bIsDepthCoder )
    1032 {
    1033   std::vector<TComPic*> apcRefPics( iViewIdx, (TComPic*)NULL );
    1034   for( int iRefViewIdx = 0; iRefViewIdx < iViewIdx; iRefViewIdx++ )
    1035   {
    1036 // GT FIX
    1037     TComPic* pcRefPic = xGetPicFromView(iRefViewIdx, iPoc, bIsDepthCoder);
    1038 
    1039     assert( pcRefPic != NULL );
    1040     apcRefPics[iRefViewIdx] = pcRefPic;
    1041   }
    1042   return apcRefPics;
    1043 }
    1044 
    1045 
    1046 TComPic* TAppEncTop::xGetPicFromView( Int iViewIdx, Int iPoc, bool bDepth )
    1047 {
    1048   assert( ( iViewIdx >= 0) && ( iViewIdx < m_iNumberOfViews ) );
    1049 
    1050   TComPic* pcPic = 0;
    1051   TComList<TComPic*>* apcListPic;
    1052 
    1053   apcListPic = (bDepth ?  m_acTEncDepthTopList[iViewIdx] : m_acTEncTopList[iViewIdx])->getListPic() ;
    1054 
    1055   for(TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++)
    1056   {
    1057     if( (*it)->getPOC() == iPoc )
    1058     {
    1059       pcPic = *it ;
    1060       break ;
    1061     }
    1062   }
    1063 
    1064   return pcPic;
    1065 };
     1036Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, Int iViewIdx, Bool isDepth )
     1037{
     1038  Int i;
     1039 
     1040  if( iNumEncoded > 0 )
     1041  {
     1042    TComList<TComPicYuv*>::iterator iterPicYuvRec = !isDepth ? m_picYuvRec[iViewIdx]->end() : m_picYuvDepthRec[iViewIdx]->end();
     1043 
     1044    for ( i = 0; i < iNumEncoded; i++ )
     1045    {
     1046      --iterPicYuvRec;
     1047    }
     1048 
     1049    for ( i = 0; i < iNumEncoded; i++ )
     1050    {
     1051      TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
     1052      if( !isDepth )
     1053      {
     1054        if (m_pchReconFileList[iViewIdx])
     1055        {
     1056#if PIC_CROPPING
     1057          m_acTVideoIOYuvReconFileList[iViewIdx]->write( pcPicYuvRec, m_cropLeft, m_cropRight, m_cropTop, m_cropBottom );
     1058#else
     1059          m_acTVideoIOYuvReconFileList[iViewIdx]->write( pcPicYuvRec, m_aiPad );
     1060#endif
     1061        }
     1062      }
     1063      else
     1064      {
     1065        if (m_pchDepthReconFileList[iViewIdx])
     1066        {
     1067#if PIC_CROPPING
     1068          m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPicYuvRec, m_cropLeft, m_cropRight, m_cropTop, m_cropBottom );
     1069#else
     1070          m_acTVideoIOYuvDepthReconFileList[iViewIdx]->write( pcPicYuvRec, m_aiPad );
     1071#endif
     1072        }
     1073      }
     1074    }
     1075  }
     1076  if( ! accessUnits.empty() )
     1077  {
     1078    list<AccessUnit>::iterator aUIter;
     1079    for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ )
     1080    {
     1081      const vector<unsigned>& stats = writeAnnexB(bitstreamFile, *aUIter);
     1082      rateStatsAccum(*aUIter, stats);
     1083    }
     1084  }
     1085}
     1086
    10661087
    10671088TComPicYuv* TAppEncTop::xGetPicYuvFromView( Int iViewIdx, Int iPoc, Bool bDepth, Bool bRecon )
     
    10881109};
    10891110
    1090 #if HHI_VSO
    1091 Void TAppEncTop::xSetBasePicYuv( Int iViewIdx, Int iPoc, TComMVDRefData* pcRefInfo, InterViewReference eView, bool bDepth )
    1092 {
    1093 
    1094   if ( ( iViewIdx < 0) || ( iViewIdx >= m_iNumberOfViews ) )
    1095     return;
    1096 
    1097   if ( !m_bUsingDepthMaps && bDepth )
    1098     return;
    1099 
    1100   TComPic* pcPic = xGetPicFromView( iViewIdx, iPoc, bDepth);
    1101 
    1102   if (pcPic == 0)
    1103     return;
    1104 
    1105   pcRefInfo->setPicYuvBaseView(eView, bDepth, pcPic->getPicYuvOrg(),  pcPic->getReconMark() ? pcPic->getPicYuvRec() : NULL );
    1106 
    1107 };
    1108 
    1109 Void TAppEncTop::setMVDPic( Int iViewIdx, Int iPoc, TComMVDRefData* pcMVDRefData )
    1110 {
    1111   AOF( iViewIdx >= 0);
    1112   AOF( iViewIdx <  m_iNumberOfViews  );
    1113 
    1114   xSetBasePicYuv(iViewIdx - 1, iPoc, pcMVDRefData, PREVVIEW, false);
    1115   xSetBasePicYuv(iViewIdx    , iPoc, pcMVDRefData, CURRVIEW, false );
    1116   xSetBasePicYuv(iViewIdx + 1, iPoc, pcMVDRefData, NEXTVIEW, false );
    1117 
    1118   if ( m_bUsingDepthMaps )
    1119   {
    1120     xSetBasePicYuv(iViewIdx - 1, iPoc, pcMVDRefData, PREVVIEW, true );
    1121     xSetBasePicYuv(iViewIdx    , iPoc, pcMVDRefData, CURRVIEW, true );
    1122     xSetBasePicYuv(iViewIdx + 1, iPoc, pcMVDRefData, NEXTVIEW, true );
    1123   }
    1124 
    1125 
    1126   xSetBaseLUT       (iViewIdx, iViewIdx-1  , pcMVDRefData, PREVVIEW );
    1127   xSetBaseLUT       (iViewIdx, iViewIdx+1  , pcMVDRefData, NEXTVIEW );
    1128 
    1129 
    1130   if ( m_bUseVSO && m_uiVSOMode != 4)
    1131   {
    1132     xSetERPicYuvs               (iViewIdx, iPoc, pcMVDRefData);
    1133     pcMVDRefData->setShiftLUTsERView(m_cCameraData.getSynthViewShiftLUTD()[iViewIdx],  m_cCameraData.getSynthViewShiftLUTI()[iViewIdx] );
    1134     pcMVDRefData->setRefViewInd     (m_aaiBaseViewRefInd[iViewIdx], m_aaiERViewRefInd[iViewIdx], m_aaiERViewRefLutInd[iViewIdx]);
    1135   }
    1136 };
    1137 
    1138 
    1139 Void TAppEncTop::xSetBaseLUT( Int iViewIdxSource, Int iViewIdxTarget, TComMVDRefData* pcRefInfo, InterViewReference eView )
    1140 {
    1141   if ( ( iViewIdxSource < 0) || ( iViewIdxSource >= m_iNumberOfViews )||( iViewIdxTarget < 0) || ( iViewIdxTarget >= m_iNumberOfViews ) )
    1142     return;
    1143   assert( abs( iViewIdxTarget - iViewIdxSource ) <= 1 );  //GT; Not supported yet
    1144   pcRefInfo->setShiftLUTsBaseView(eView, m_cCameraData.getBaseViewShiftLUTD()[iViewIdxSource][iViewIdxTarget],m_cCameraData.getBaseViewShiftLUTI()[iViewIdxSource][iViewIdxTarget] );
    1145 };
    1146 
    1147 Void TAppEncTop::xSetERPicYuvs( Int iViewIdx, Int iPoc, TComMVDRefData* pcReferenceInfo )
    1148 {
    1149   std::vector<TComPicYuv*> apcExtRefViews;
    1150 
    1151   std::map< Int, vector<TComPicYuv*> >::iterator cMapIt;
    1152   cMapIt = m_cMapPicExtRefView.find(iPoc);
    1153 
    1154   assert(  cMapIt != m_cMapPicExtRefView.end() );
    1155 
    1156   pcReferenceInfo->setPicYuvERViews( cMapIt->second );
    1157 }
    1158 
    1159 Void TAppEncTop::xStoreVSORefPicsInBuffer()
    1160 {
    1161   // X-Check if all Encoders have received the same number of pics
    1162   Int iNumRcvd = m_iFrameRcvdVector[0];
    1163   for ( UInt uiViewNumber = 0; uiViewNumber < m_iNumberOfViews; uiViewNumber ++ )
    1164   {
    1165     assert( ( m_iFrameRcvdVector[uiViewNumber] == iNumRcvd ) && ( m_iDepthFrameRcvdVector[uiViewNumber] == iNumRcvd ) ); //GT; if assert here, the encoder instances are not synchronized any more, re-think this function and the ERView Buffer!!
    1166   };
    1167 
    1168   Int iCurPoc = iNumRcvd - 1;
    1169 
    1170   if ( iCurPoc <= m_iLastFramePutInERViewBuffer )
    1171   {
    1172     return;
    1173   }
    1174 
    1175   std::vector<TComPicYuv*> apcExtRefViewVec;
    1176 
    1177   Int iNumberOfReferenceViews = 0;
    1178   if (m_iNumberOfExternalRefs != 0)
    1179   {
    1180     m_aaiERViewRefLutInd = m_aaiERViewRefInd;
    1181     // Insert Rendered Views form File
    1182 
    1183     iNumberOfReferenceViews = m_iNumberOfExternalRefs;
    1184 
    1185     for ( UInt uiViewNumber = 0; uiViewNumber < iNumberOfReferenceViews; uiViewNumber++ )
    1186     {
    1187       TComPicYuv* pcPicYuvERView = new TComPicYuv;
    1188       pcPicYuvERView->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    1189 
    1190       m_acTVideoIOYuvERFileList[uiViewNumber]->read( pcPicYuvERView, m_aiPad  ) ;
    1191 
    1192       apcExtRefViewVec.push_back( pcPicYuvERView );
    1193     }
    1194   }
    1195   else
    1196   { //Render Views
    1197 
    1198     for ( UInt uiViewNumber = 0; uiViewNumber < m_iNumberOfViews; uiViewNumber++ )
    1199     {
    1200       m_aaiERViewRefInd   [uiViewNumber].clear();
    1201       m_aaiERViewRefLutInd[uiViewNumber].clear();
    1202     }
    1203 
    1204     iNumberOfReferenceViews = 0;
    1205     for ( UInt iSynthViewIdx = 0; iSynthViewIdx < m_cCameraData.getSynthViewNumbers().size(); iSynthViewIdx++ )
    1206     {
    1207       // Get Left and right view
    1208       Int  iLeftViewIdx  = -1;
    1209       Int  iRightViewIdx = -1;
    1210       Bool bIsBaseView;
    1211 
    1212       Int iRelDistToLeft;
    1213       m_cCameraData.getLeftRightBaseView( iSynthViewIdx, iLeftViewIdx, iRightViewIdx, iRelDistToLeft, bIsBaseView );
    1214 
    1215       if  ((iLeftViewIdx == -1) || (iRightViewIdx == -1))
    1216       {
    1217         std::cerr << "Left or right View not given." << endl;
    1218         exit(EXIT_FAILURE);
    1219       }
    1220 
    1221       m_cRendererTop.setShiftLUTs(
    1222         m_cCameraData.getSynthViewShiftLUTD()[iLeftViewIdx] [iSynthViewIdx],
    1223         m_cCameraData.getSynthViewShiftLUTI()[iLeftViewIdx] [iSynthViewIdx],
    1224         m_cCameraData.getBaseViewShiftLUTI ()[iLeftViewIdx] [iRightViewIdx],
    1225         m_cCameraData.getSynthViewShiftLUTD()[iRightViewIdx][iSynthViewIdx],
    1226         m_cCameraData.getSynthViewShiftLUTI()[iRightViewIdx][iSynthViewIdx],
    1227         m_cCameraData.getBaseViewShiftLUTI ()[iRightViewIdx][iLeftViewIdx],
    1228         iRelDistToLeft
    1229       );
    1230       if ( bIsBaseView ) continue;
    1231 
    1232       // Render from left
    1233       TComPicYuv* pcPicYuvERView = new TComPicYuv;
    1234       pcPicYuvERView->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    1235       m_cRendererTop.extrapolateView( xGetPicFromView( iLeftViewIdx, iCurPoc, false )->getPicYuvOrg(), xGetPicFromView( iLeftViewIdx, iCurPoc, true )->getPicYuvOrg(), pcPicYuvERView, true );
    1236 
    1237       apcExtRefViewVec.push_back( pcPicYuvERView );
    1238 
    1239       m_aaiERViewRefInd   [ iLeftViewIdx].push_back( iNumberOfReferenceViews );
    1240       m_aaiERViewRefLutInd[ iLeftViewIdx].push_back( iSynthViewIdx );
    1241       iNumberOfReferenceViews++;
    1242 
    1243       //Render from right
    1244       pcPicYuvERView = new TComPicYuv;
    1245       pcPicYuvERView->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
    1246 
    1247       m_cRendererTop.extrapolateView( xGetPicFromView( iRightViewIdx, iCurPoc, false )->getPicYuvOrg(), xGetPicFromView( iRightViewIdx, iCurPoc, true )->getPicYuvOrg(), pcPicYuvERView, false );
    1248       apcExtRefViewVec.push_back( pcPicYuvERView );
    1249 
    1250       m_aaiERViewRefInd   [ iRightViewIdx].push_back( iNumberOfReferenceViews );
    1251       m_aaiERViewRefLutInd[ iRightViewIdx].push_back( iSynthViewIdx );
    1252       iNumberOfReferenceViews++;
    1253     }
    1254   }
    1255 
    1256   m_iLastFramePutInERViewBuffer++;
    1257   m_cMapPicExtRefView.insert( std::make_pair( m_iLastFramePutInERViewBuffer, apcExtRefViewVec ) );
    1258 
    1259   if ( m_cMapPicExtRefView.size() >  (UInt)m_iGOPSize + 1 )
    1260   {
    1261     for ( UInt uiViewNumber = 0; uiViewNumber < (UInt) m_cMapPicExtRefView.begin()->second.size(); uiViewNumber++ )
    1262     {
    1263       if ( m_cMapPicExtRefView.begin()->second[uiViewNumber] )
    1264       {
    1265         m_cMapPicExtRefView.begin()->second[uiViewNumber]->destroy();
    1266         delete m_cMapPicExtRefView.begin()->second[uiViewNumber];
    1267       }
    1268     }
    1269     m_cMapPicExtRefView.erase ( m_cMapPicExtRefView.begin() );
    1270   }
    1271 }
    1272 #endif
     1111/**
     1112 *
     1113 */
     1114void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<unsigned>& annexBsizes)
     1115{
     1116  AccessUnit::const_iterator it_au = au.begin();
     1117  vector<unsigned>::const_iterator it_stats = annexBsizes.begin();
     1118
     1119  for (; it_au != au.end(); it_au++, it_stats++)
     1120  {
     1121    switch ((*it_au)->m_nalUnitType)
     1122    {
     1123    case NAL_UNIT_CODED_SLICE:
     1124#if H0566_TLA
     1125    case NAL_UNIT_CODED_SLICE_IDV:
     1126    case NAL_UNIT_CODED_SLICE_TLA:
     1127    case NAL_UNIT_CODED_SLICE_CRA:
     1128#else
     1129    case NAL_UNIT_CODED_SLICE_DATAPART_A:
     1130    case NAL_UNIT_CODED_SLICE_DATAPART_B:
     1131    case NAL_UNIT_CODED_SLICE_CDR:
     1132#endif
     1133    case NAL_UNIT_CODED_SLICE_IDR:
     1134    case NAL_UNIT_SPS:
     1135    case NAL_UNIT_PPS:
     1136      m_essentialBytes += *it_stats;
     1137      break;
     1138    default:
     1139      break;
     1140    }
     1141
     1142    m_totalBytes += *it_stats;
     1143  }
     1144}
    12731145
    12741146#if HHI_INTERVIEW_SKIP
     
    12771149  AOT( iViewIdx <= 0);
    12781150  AOT( iViewIdx >= m_iNumberOfViews );
    1279   AOF( m_uiInterViewSkip != 0 );
    12801151  AOF( m_cCameraData.getCurFrameId() == iPoc );
    1281 
    12821152  Int iViewSIdx      = m_cCameraData.getBaseId2SortedId()[iViewIdx];
    12831153  Int iFirstViewSIdx = m_cCameraData.getBaseId2SortedId()[0];
     
    12871157  Bool bFirstIsLeft = (iFirstViewSIdx < iViewSIdx);
    12881158
    1289     m_cUsedPelsRenderer.setShiftLUTs(
     1159  m_cUsedPelsRenderer.setShiftLUTs(
    12901160      m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx],
    12911161      m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx],
     
    12971167      );
    12981168
    1299 
    13001169  TComPicYuv* pcPicYuvDepth = xGetPicYuvFromView(0, iPoc, true, true );
    13011170  AOF( pcPicYuvDepth);
    13021171
    13031172  m_cUsedPelsRenderer.getUsedSamplesMap( pcPicYuvDepth, pcPicYuvUsedSplsMap, bFirstIsLeft );
    1304 
    1305 }
    1306 #endif
    1307 
     1173}
     1174#endif
    13081175#if HHI_VSO
    13091176Void TAppEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent )
     
    14031270#endif
    14041271
     1272
     1273
     1274/*
     1275void TAppEncTop::printRateSummary()
     1276{
     1277  double time = (double) m_iFrameRcvd / m_iFrameRate;
     1278  printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time);
     1279#if VERBOSE_RATE
     1280  printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time);
     1281#endif
     1282}
     1283*/
     1284
     1285std::vector<TComPic*> TAppEncTop::getInterViewRefPics( Int viewId, Int poc, Bool isDepth, TComSPS* sps )
     1286{
     1287  std::vector<TComPic*> apcRefPics( sps->getNumberOfUsableInterViewRefs(), (TComPic*)NULL );
     1288  for( Int k = 0; k < sps->getNumberOfUsableInterViewRefs(); k++ )
     1289  {
     1290    TComPic* pcRefPic = xGetPicFromView( sps->getUsableInterViewRef( k ) + viewId, poc, isDepth );
     1291    assert( pcRefPic != NULL );
     1292    apcRefPics[k] = pcRefPic;
     1293  }
     1294  return apcRefPics;
     1295}
     1296
     1297TComPic* TAppEncTop::xGetPicFromView( Int viewIdx, Int poc, Bool isDepth )
     1298{
     1299  assert( ( viewIdx >= 0 ) && ( viewIdx < m_iNumberOfViews ) );
     1300
     1301  TComList<TComPic*>* apcListPic = (isDepth ?  m_acTEncDepthTopList[viewIdx] : m_acTEncTopList[viewIdx])->getListPic() ;
     1302
     1303  TComPic* pcPic = NULL;
     1304  for(TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++)
     1305  {
     1306    if( (*it)->getPOC() == poc )
     1307    {
     1308      pcPic = *it ;
     1309      break ;
     1310    }
     1311  }
     1312
     1313  return pcPic;
     1314};
     1315
     1316//! \}
  • trunk/source/App/TAppEncoder/TAppEncTop.h

    r5 r56  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license.
     4 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2011, ISO/IEC
     6 * Copyright (c) 2010-2012, ITU/ISO/IEC