Changeset 713 in SHVCSoftware


Ignore:
Timestamp:
21 Apr 2014, 04:44:16 (11 years ago)
Author:
seregin
Message:

merge with SHM-6-dev

Location:
trunk
Files:
77 edited
14 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/build/linux/lib/TLibCommon/makefile

    r125 r713  
    5858                        $(OBJ_DIR)/TComRdCostWeightPrediction.o \
    5959                        $(OBJ_DIR)/TComUpsampleFilter.o \
     60                        $(OBJ_DIR)/TCom3DAsymLUT.o \
    6061
    6162LIBS                            = -lpthread
  • trunk/build/linux/lib/TLibEncoder/makefile

    r125 r713  
    5252                        $(OBJ_DIR)/WeightPredAnalysis.o \
    5353                        $(OBJ_DIR)/TEncRateCtrl.o \
     54                        $(OBJ_DIR)/TEnc3DAsymLUT.o \
    5455
    5556LIBS                            = -lpthread
  • trunk/build/vc10/TAppDownConvert/TAppDownConvert.vcxproj

    r540 r713  
    8282      <WarningLevel>Level3</WarningLevel>
    8383      <Optimization>Disabled</Optimization>
     84      <PreprocessorDefinitions>_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    8485    </ClCompile>
    8586    <Link>
     
    102103      <FunctionLevelLinking>true</FunctionLevelLinking>
    103104      <IntrinsicFunctions>true</IntrinsicFunctions>
     105      <PreprocessorDefinitions>_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    104106    </ClCompile>
    105107    <Link>
  • trunk/build/vc10/TLibCommon_vc10.vcxproj

    r125 r713  
    148148    <ClCompile Include="..\..\source\Lib\libmd5\libmd5.c" />
    149149    <ClCompile Include="..\..\source\Lib\TLibCommon\SEI.cpp" />
     150    <ClCompile Include="..\..\source\Lib\TLibCommon\TCom3DAsymLUT.cpp" />
    150151    <ClCompile Include="..\..\source\Lib\TLibCommon\TComBitStream.cpp" />
    151152    <ClCompile Include="..\..\source\Lib\TLibCommon\TComCABACTables.cpp" />
     
    180181    <ClInclude Include="..\..\source\Lib\TLibCommon\NAL.h" />
    181182    <ClInclude Include="..\..\source\Lib\TLibCommon\SEI.h" />
     183    <ClInclude Include="..\..\source\Lib\TLibCommon\TCom3DAsymLUT.h" />
    182184    <ClInclude Include="..\..\source\Lib\TLibCommon\TComBitCounter.h" />
    183185    <ClInclude Include="..\..\source\Lib\TLibCommon\TComBitStream.h" />
  • trunk/build/vc10/TLibEncoder_vc10.vcxproj

    r125 r713  
    147147    <ClCompile Include="..\..\source\Lib\TLibEncoder\SEIwrite.cpp" />
    148148    <ClCompile Include="..\..\source\Lib\TLibEncoder\SyntaxElementWriter.cpp" />
     149    <ClCompile Include="..\..\source\Lib\TLibEncoder\TEnc3DAsymLUT.cpp" />
    149150    <ClCompile Include="..\..\source\Lib\TLibEncoder\TEncAnalyze.cpp" />
    150151    <ClCompile Include="..\..\source\Lib\TLibEncoder\TEncBinCoderCABAC.cpp" />
     
    169170    <ClInclude Include="..\..\source\Lib\TLibEncoder\SEIwrite.h" />
    170171    <ClInclude Include="..\..\source\Lib\TLibEncoder\SyntaxElementWriter.h" />
     172    <ClInclude Include="..\..\source\Lib\TLibEncoder\TEnc3DAsymLUT.h" />
    171173    <ClInclude Include="..\..\source\Lib\TLibEncoder\TEncAnalyze.h" />
    172174    <ClInclude Include="..\..\source\Lib\TLibEncoder\TEncBinCoder.h" />
  • trunk/build/vc9/TLibCommon_vc9.vcproj

    r313 r713  
    300300                        </File>
    301301                        <File
     302                                RelativePath="..\..\source\Lib\TLibCommon\TCom3DAsymLUT.cpp"
     303                                >
     304                        </File>
     305                        <File
    302306                                RelativePath="..\..\source\Lib\TLibCommon\TComBitStream.cpp"
    303307                                >
     
    426430                        </File>
    427431                        <File
     432                                RelativePath="..\..\source\Lib\TLibCommon\TCom3DAsymLUT.h"
     433                                >
     434                        </File>
     435                        <File
    428436                                RelativePath="..\..\source\Lib\TLibCommon\TComBitCounter.h"
    429437                                >
  • trunk/build/vc9/TLibEncoder_vc9.vcproj

    r313 r713  
    295295                        </File>
    296296                        <File
     297                                RelativePath="..\..\source\Lib\TLibEncoder\TEnc3DAsymLUT.cpp"
     298                                >
     299                        </File>
     300                        <File
    297301                                RelativePath="..\..\source\Lib\TLibEncoder\TEncAnalyze.cpp"
    298302                                >
     
    377381                        <File
    378382                                RelativePath="..\..\source\Lib\TLibEncoder\SyntaxElementWriter.h"
     383                                >
     384                        </File>
     385                        <File
     386                                RelativePath="..\..\source\Lib\TLibEncoder\TEnc3DAsymLUT.h"
    379387                                >
    380388                        </File>
  • trunk/cfg

  • trunk/cfg/layers.cfg

    r595 r713  
    99CrossLayerPictureTypeAlignFlag: 1           # Picture type alignment across layers
    1010CrossLayerIrapAlignFlag       : 1           # Align IRAP across layers
    11 InterLayerWeightedPred        : 0           # enable IL WP parameters estimation at encoder
    1211SEIpictureDigest              : 1
    1312
     
    1514QP0                           : 22
    1615MaxTidIlRefPicsPlus10         : 1           # max_tid_il_ref_pics_plus1 for layer0
    17 InternalBitDepth0             : 8           # codec operating bit-depth for layer 0
    1816#============ Rate Control ==============
    1917RateControl0                  : 0           # Rate control: enable rate control for layer 0
     
    2826#============= LAYER 1 ==================
    2927QP1                           : 20
    30 InternalBitDepth1             : 8           # codec operating bit-depth for layer 1
    3128NumSamplePredRefLayers1       : 1           # number of sample pred reference layers
    3229SamplePredRefLayerIds1        : 0           # reference layer id
  • trunk/cfg/layers_avcbase.cfg

    r595 r713  
    66CrossLayerPictureTypeAlignFlag: 0           # Picture type alignment across layers
    77CrossLayerIrapAlignFlag       : 0           # Align IRAP across layers
    8 InterLayerWeightedPred        : 0           # enable IL WP parameters estimation at encoder
    98SEIpictureDigest              : 1
    109
    1110#============= LAYER 0 ==================
    1211QP0                           : 22
    13 InternalBitDepth0             : 8           # codec operating bit-depth for layer 0
    1412
    1513#============ Rate Control ==============
     
    2523#============= LAYER 1 ==================
    2624QP1                           : 20
    27 InternalBitDepth1             : 8           # codec operating bit-depth for layer 1
    2825NumSamplePredRefLayers1       : 1           # number of sample pred reference layers
    2926SamplePredRefLayerIds1        : 0           # reference layer id
  • trunk/cfg/per-sequence-svc-avcbase/BQTerrace-2x.cfg

    r595 r713  
    2222IntraPeriod1                  : 64          # Period of I-Frame ( -1 = only first)
    2323ConformanceMode1              : 1           # conformance mode
    24 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    2524ScaledRefLayerId1             : 0           # Scaled reference layer ID
    26 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
    2725QP1                           : 20
  • trunk/cfg/per-sequence-svc-avcbase/BasketballDrive-2x.cfg

    r595 r713  
    2222IntraPeriod1                  : 48          # Period of I-Frame ( -1 = only first)
    2323ConformanceMode1              : 1           # conformance mode
    24 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    2524ScaledRefLayerId1             : 0           # Scaled reference layer ID
    26 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
    2725QP1                           : 20
  • trunk/cfg/per-sequence-svc-avcbase/Cactus-2x.cfg

    r595 r713  
    2222IntraPeriod1                  : 48          # Period of I-Frame ( -1 = only first)
    2323ConformanceMode1              : 1           # conformance mode
    24 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    2524ScaledRefLayerId1             : 0           # Scaled reference layer ID
    26 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
    2725QP1                           : 20
  • trunk/cfg/per-sequence-svc-avcbase/Kimono-2x.cfg

    r595 r713  
    2222IntraPeriod1                  : 24          # Period of I-Frame ( -1 = only first)
    2323ConformanceMode1              : 1           # conformance mode
    24 NumScaledRefLayerOffsets1     : 1                             # Number of scaled entry offsets for this layer
    2524ScaledRefLayerId1             : 0           # Scaled reference layer ID
    26 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
    2725QP1                           : 20
  • trunk/cfg/per-sequence-svc-avcbase/ParkScene-2x.cfg

    r595 r713  
    2222IntraPeriod1                  : 24          # Period of I-Frame ( -1 = only first)
    2323ConformanceMode1              : 1           # conformance mode
    24 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    2524ScaledRefLayerId1             : 0           # Scaled reference layer ID
    26 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
    2725QP1                           : 20
  • trunk/cfg/per-sequence-svc/BQTerrace-2x.cfg

    r595 r713  
    2323IntraPeriod1                  : 64          # Period of I-Frame ( -1 = only first)
    2424ConformanceMode1              : 1           # conformance mode
    25 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    26 ScaledRefLayerId1             : 0           # Scaled reference layer ID
    27 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
    2825QP1                           : 20
  • trunk/cfg/per-sequence-svc/BasketballDrive-2x.cfg

    r595 r713  
    2323IntraPeriod1                  : 48          # Period of I-Frame ( -1 = only first)
    2424ConformanceMode1              : 1           # conformance mode
    25 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    26 ScaledRefLayerId1             : 0           # Scaled reference layer ID
    27 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
    2825QP1                           : 20
  • trunk/cfg/per-sequence-svc/Cactus-2x.cfg

    r595 r713  
    2323IntraPeriod1                  : 48          # Period of I-Frame ( -1 = only first)
    2424ConformanceMode1              : 1           # conformance mode
    25 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    26 ScaledRefLayerId1             : 0           # Scaled reference layer ID
    27 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
    2825QP1                           : 20
  • trunk/cfg/per-sequence-svc/Kimono-2x.cfg

    r595 r713  
    2323IntraPeriod1                  : 24          # Period of I-Frame ( -1 = only first)
    2424ConformanceMode1              : 1           # conformance mode
    25 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    26 ScaledRefLayerId1             : 0           # Scaled reference layer ID
    27 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
    2825QP1                           : 20
  • trunk/cfg/per-sequence-svc/ParkScene-2x.cfg

    r595 r713  
    2323IntraPeriod1                  : 24          # Period of I-Frame ( -1 = only first)
    2424ConformanceMode1              : 1           # conformance mode
    25 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    26 ScaledRefLayerId1             : 0           # Scaled reference layer ID
    27 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
    2825QP1                           : 20
  • trunk/doc/readme.txt

    r2 r713  
    1 TAppEncoder -c cfg/encoder_randomaccess_main.cfg -c cfg/per-sequence-svc/BasketballDrive-2x.cfg -q0 22 -q1 22 -b str/BasketballDrive.bin -o0 rec/BasketballDrive_l0_rec.yuv -o1 rec/BasketballDrive_l1_rec.yuv
     1TAppEncoder -c cfg/encoder_randomaccess_main.cfg -c cfg/per-sequence-svc/BasketballDrive-2x.cfg -c cfg/layers.cfg -q0 22 -q1 22 -b str/BasketballDrive.bin -o0 rec/BasketballDrive_l0_rec.yuv -o1 rec/BasketballDrive_l1_rec.yuv
    22
    33TAppDecoder -b str/BasketballDrive.bin -ls 2 -o0 rec/BasketballDrive_l0_drec.yuv -o1 rec/BasketballDrive_l1_drec.yuv
    44
    5 For AVC_BASE tests the following additionally should be used.
    6 
    7 In the encoder config file for the layer0 ONLY new line should be added. Strictly after InputFile. InputBLFile indicates the path to the BL yuv. Example:
    8 InputFile                     : O:\BasketballDrive_1280x720_50_zerophase_0.9pi.yuv
    9 InputBLFile                 : O:\BasketballDrive_l0_rec.yuv
    10 
    11 For decoder, new command line parameters additionally should be used as following
    12 -ibl “BLrecon.yuv” –wdt BLwidth –hgt BLheight
     5For AVC base layer tests the following should be used:
     6 cfg/layers_avcbase.cfg configuration file
     7 -ibl <BLrecon.yuv> option to specify the reconstructed base layer input
  • trunk/source

  • trunk/source/App/TAppDecoder/TAppDecCfg.cpp

    r595 r713  
    9292#if AVC_BASE
    9393  ("BLReconFile,-ibl",    cfg_BLReconFile,  string(""), "BL reconstructed YUV input file name")
     94#if !REPN_FORMAT_IN_VPS
    9495  ("BLSourceWidth,-wdt",    m_iBLSourceWidth,        0, "BL source picture width")
    9596  ("BLSourceHeight,-hgt",   m_iBLSourceHeight,       0, "BL source picture height")
     97#endif
    9698#if AVC_SYNTAX
    9799  ("BLSyntaxFile,-ibs",    cfg_BLSyntaxFile,  string(""), "BL syntax input file name") 
  • trunk/source/App/TAppDecoder/TAppDecCfg.h

    r595 r713  
    7474#if AVC_BASE
    7575  Char*         m_pchBLReconFile;                     ///< input BL reconstruction file name
     76#if !REPN_FORMAT_IN_VPS
    7677  Int           m_iBLSourceWidth;
    7778  Int           m_iBLSourceHeight;
     79#endif
    7880#if AVC_SYNTAX
    7981  Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name 
     
    8486#if SYNTAX_OUTPUT
    8587  Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name
     88#if !REPN_FORMAT_IN_VPS
    8689  Int           m_iBLSourceWidth;
    8790  Int           m_iBLSourceHeight;
     91#endif
    8892  Int           m_iBLFrames;
    8993#endif
     
    108112#if SVC_EXTENSION
    109113  , m_tgtLayerId(0)
    110 #if AVC_BASE
     114#if AVC_BASE && !REPN_FORMAT_IN_VPS
    111115  , m_iBLSourceWidth(0)
    112116  , m_iBLSourceHeight(0)
  • trunk/source/App/TAppDecoder/TAppDecTop.cpp

    r644 r713  
    163163  }
    164164  TComList<TComPic*> *cListPic = m_acTDecTop[0].getListPic();
     165#if AVC_SYNTAX || !REPN_FORMAT_IN_VPS
    165166  m_acTDecTop[0].setBLsize( m_iBLSourceWidth, m_iBLSourceHeight );
     167#endif
    166168  m_acTDecTop[0].setBLReconFile( &streamYUV );
    167169  pcBLPic.setLayerId( 0 );
     
    257259      Bool outputPicturesFlag = true; 
    258260#if NO_OUTPUT_OF_PRIOR_PICS
    259       if( m_acTDecTop[nalu.m_layerId].getNoOutputOfPriorPicsFlags() )
     261      if( m_acTDecTop[nalu.m_layerId].getNoOutputPriorPicsFlag() )
    260262      {
    261263        outputPicturesFlag = false;
     
    449451      loopFiltered = (nalu.m_nalUnitType == NAL_UNIT_EOS);
    450452    }
     453#if !FIX_WRITING_OUTPUT
     454#if SETTING_NO_OUT_PIC_PRIOR
     455    if (bNewPicture && m_cTDecTop.getNoOutputPriorPicsFlag())
     456    {
     457      m_cTDecTop.checkNoOutputPriorPics( pcListPic );
     458    }
     459#endif
     460#endif
    451461
    452462    if( pcListPic )
     
    460470        openedReconFile = true;
    461471      }
     472#if FIX_WRITING_OUTPUT
     473      // write reconstruction to file
     474      if( bNewPicture )
     475      {
     476        xWriteOutput( pcListPic, nalu.m_temporalId );
     477      }
     478#if SETTING_NO_OUT_PIC_PRIOR
     479      if ( (bNewPicture || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA) && m_cTDecTop.getNoOutputPriorPicsFlag() )
     480      {
     481        m_cTDecTop.checkNoOutputPriorPics( pcListPic );
     482        m_cTDecTop.setNoOutputPriorPicsFlag (false);
     483      }
     484#endif
     485#endif
    462486      if ( bNewPicture &&
    463487           (   nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
     
    471495      if (nalu.m_nalUnitType == NAL_UNIT_EOS)
    472496      {
     497#if FIX_OUTPUT_EOS
     498        xWriteOutput( pcListPic, nalu.m_temporalId );
     499#else
    473500        xFlushOutput( pcListPic );       
    474       }
    475       // write reconstruction to file
     501#endif
     502      }
     503      // write reconstruction to file -- for additional bumping as defined in C.5.2.3
     504#if FIX_WRITING_OUTPUT
     505      if(!bNewPicture && nalu.m_nalUnitType >= NAL_UNIT_CODED_SLICE_TRAIL_N && nalu.m_nalUnitType <= NAL_UNIT_RESERVED_VCL31)
     506#else
    476507      if(bNewPicture)
     508#endif
    477509      {
    478510        xWriteOutput( pcListPic, nalu.m_temporalId );
     
    586618  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
    587619  Int numPicsNotYetDisplayed = 0;
     620  Int dpbFullness = 0;
     621#if SVC_EXTENSION
     622TComSPS* activeSPS = m_acTDecTop[layerId].getActiveSPS();
     623#else
     624  TComSPS* activeSPS = m_cTDecTop.getActiveSPS();
     625#endif
     626  UInt numReorderPicsHighestTid;
     627  UInt maxDecPicBufferingHighestTid;
     628  UInt maxNrSublayers = activeSPS->getMaxTLayers();
     629
     630  if(m_iMaxTemporalLayer == -1 || m_iMaxTemporalLayer >= maxNrSublayers)
     631  {
     632    numReorderPicsHighestTid = activeSPS->getNumReorderPics(maxNrSublayers-1);
     633    maxDecPicBufferingHighestTid =  activeSPS->getMaxDecPicBuffering(maxNrSublayers-1);
     634  }
     635  else
     636  {
     637    numReorderPicsHighestTid = activeSPS->getNumReorderPics(m_iMaxTemporalLayer);
     638    maxDecPicBufferingHighestTid = activeSPS->getMaxDecPicBuffering(m_iMaxTemporalLayer);
     639  }
    588640
    589641  while (iterPic != pcListPic->end())
     
    597649    {
    598650      numPicsNotYetDisplayed++;
     651      dpbFullness++;
     652    }
     653    else if(pcPic->getSlice( 0 )->isReferenced())
     654    {
     655      dpbFullness++;
    599656    }
    600657    iterPic++;
     
    619676
    620677#if SVC_EXTENSION
    621       if ( pcPicTop->getOutputMark() && (numPicsNotYetDisplayed >  pcPicTop->getNumReorderPics(tId) && !(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1)
    622         && pcPicBottom->getOutputMark() && (numPicsNotYetDisplayed >  pcPicBottom->getNumReorderPics(tId) && (pcPicTop->getPOC() == m_aiPOCLastDisplay[layerId]+1 || m_aiPOCLastDisplay[layerId]<0)))
    623 #else
    624       if ( pcPicTop->getOutputMark() && (numPicsNotYetDisplayed >  pcPicTop->getNumReorderPics(tId) && !(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1)
    625         && pcPicBottom->getOutputMark() && (numPicsNotYetDisplayed >  pcPicBottom->getNumReorderPics(tId) && (pcPicTop->getPOC() == m_iPOCLastDisplay+1 || m_iPOCLastDisplay<0)))
     678      if( pcPicTop->getOutputMark() && pcPicBottom->getOutputMark() &&
     679        (numPicsNotYetDisplayed >  numReorderPicsHighestTid || dpbFullness > maxDecPicBufferingHighestTid) &&
     680        (!(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1) &&       
     681        (pcPicTop->getPOC() == m_aiPOCLastDisplay[layerId]+1 || m_aiPOCLastDisplay[layerId]<0) )
     682#else
     683      if ( pcPicTop->getOutputMark() && pcPicBottom->getOutputMark() &&
     684          (numPicsNotYetDisplayed >  numReorderPicsHighestTid || dpbFullness > maxDecPicBufferingHighestTid) &&
     685          (!(pcPicTop->getPOC()%2) && pcPicBottom->getPOC() == pcPicTop->getPOC()+1) &&
     686          (pcPicTop->getPOC() == m_iPOCLastDisplay+1 || m_iPOCLastDisplay < 0))
    626687#endif
    627688      {
     
    634695          const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
    635696          const Bool isTff = pcPicTop->isTopField();
     697          TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
     698          TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
     699#if Q0074_SEI_COLOR_MAPPING
     700          if( m_acTDecTop[layerId].m_ColorMapping->getColorMappingFlag() )
     701          {
     702            pPicCYuvRecTop = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRecTop, 0, layerId );
     703            pPicCYuvRecBot = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRecBot, 1, layerId );
     704          }
     705#endif
    636706#if REPN_FORMAT_IN_VPS
    637707          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
    638708          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
    639           m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     709
     710          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRecTop, pPicCYuvRecBot,
    640711            conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
    641712            conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
    642713            conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
    643714            conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset(), isTff );
    644 
    645 #else
    646 #if O0194_DIFFERENT_BITDEPTH_EL_BL
    647           // Compile time bug-fix
    648           m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
    649 #else
    650           m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
    651 #endif
     715#else
     716          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRecTop, pPicCYuvRecBot,
     717            conf.getWindowLeftOffset()   + defDisp.getWindowLeftOffset(),
     718            conf.getWindowRightOffset()  + defDisp.getWindowRightOffset(),
     719            conf.getWindowTopOffset()    + defDisp.getWindowTopOffset(),
     720            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
     721#endif
     722        }
     723
     724        // update POC of display order
     725        m_aiPOCLastDisplay[layerId] = pcPicBottom->getPOC();
     726#else
     727        if ( m_pchReconFile )
     728        {
     729          const Window &conf = pcPicTop->getConformanceWindow();
     730          const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
     731          const Bool isTff = pcPicTop->isTopField();
     732          TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
     733          TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
     734#if Q0074_SEI_COLOR_MAPPING
     735          if ( m_cTDecTop.m_ColorMapping->getColorMappingFlag() )
     736          {
     737            pPicCYuvRecTop = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRecTop, 0 );
     738            pPicCYuvRecBot = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRecBot, 1 );
     739          }
     740#endif
     741          m_cTVideoIOYuvReconFile.write( pPicCYuvRecTop, pPicCYuvRecBot,
    652742            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    653743            conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    654744            conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    655745            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
    656 #endif
    657746        }
    658747
    659748        // update POC of display order
    660         m_aiPOCLastDisplay[layerId] = pcPicBottom->getPOC();
     749        m_iPOCLastDisplay = pcPicBottom->getPOC();
     750#endif
     751
     752        // erase non-referenced picture in the reference picture list after display
     753        if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true )
     754        {
     755#if !DYN_REF_FREE
     756          pcPicTop->setReconMark(false);
     757
     758          // mark it should be extended later
     759          pcPicTop->getPicYuvRec()->setBorderExtension( false );
     760
     761#else
     762          pcPicTop->destroy();
     763          pcListPic->erase( iterPic );
     764          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     765          continue;
     766#endif
     767        }
     768        if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true )
     769        {
     770#if !DYN_REF_FREE
     771          pcPicBottom->setReconMark(false);
     772
     773          // mark it should be extended later
     774          pcPicBottom->getPicYuvRec()->setBorderExtension( false );
     775
     776#else
     777          pcPicBottom->destroy();
     778          pcListPic->erase( iterPic );
     779          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     780          continue;
     781#endif
     782        }
     783        pcPicTop->setOutputMark(false);
     784        pcPicBottom->setOutputMark(false);
     785      }
     786    }
     787  }
     788  else if (!pcPic->isField()) //Frame Decoding
     789  {
     790    iterPic = pcListPic->begin();
     791    while (iterPic != pcListPic->end())
     792    {
     793      pcPic = *(iterPic);
     794
     795#if SVC_EXTENSION
     796      if( pcPic->getOutputMark() && pcPic->getPOC() > m_aiPOCLastDisplay[layerId] &&
     797        (numPicsNotYetDisplayed >  numReorderPicsHighestTid || dpbFullness > maxDecPicBufferingHighestTid) )
     798#else
     799      if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay &&
     800        (numPicsNotYetDisplayed >  numReorderPicsHighestTid || dpbFullness > maxDecPicBufferingHighestTid))
     801#endif
     802      {
     803        // write to file
     804        numPicsNotYetDisplayed--;
     805        if(pcPic->getSlice(0)->isReferenced() == false)
     806        {
     807          dpbFullness--;
     808        }
     809#if SVC_EXTENSION
     810        if( m_pchReconFile[layerId] )
     811        {
     812          const Window &conf = pcPic->getConformanceWindow();
     813          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     814          TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
     815#if Q0074_SEI_COLOR_MAPPING
     816          if ( m_acTDecTop[layerId].m_ColorMapping->getColorMappingFlag() )
     817          {
     818            pPicCYuvRec = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRec, 0, layerId );
     819          }
     820#endif
     821
     822#if REPN_FORMAT_IN_VPS
     823          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
     824          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
     825
     826          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRec,
     827            conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
     828            conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
     829            conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
     830            conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
     831#else
     832          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRec,
     833            conf.getWindowLeftOffset()   + defDisp.getWindowLeftOffset(),
     834            conf.getWindowRightOffset()  + defDisp.getWindowRightOffset(),
     835            conf.getWindowTopOffset()    + defDisp.getWindowTopOffset(),
     836            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
     837#endif
     838        }
     839
     840        // update POC of display order
     841        m_aiPOCLastDisplay[layerId] = pcPic->getPOC();
    661842#else
    662843        if ( m_pchReconFile )
     844        {
     845#if SYNTAX_OUTPUT
     846          TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
     847#if Q0074_SEI_COLOR_MAPPING
     848          if( m_acTDecTop[layerIdx].m_ColorMapping->getColorMappingFlag() )
     849          {
     850            pPicCYuvRec = m_acTDecTop[layerIdx].m_ColorMapping->getColorMapping( pPicCYuvRec, 0, layerIdx );
     851          }
     852#endif
     853          const Window &conf = pcPic->getConformanceWindow();
     854          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     855          m_cTVideoIOYuvReconFile.write( pPicCYuvRec,
     856            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     857            conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     858            conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     859            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
     860#endif
     861        }
     862
     863        // update POC of display order
     864        m_iPOCLastDisplay = pcPic->getPOC();
     865#endif
     866
     867        // erase non-referenced picture in the reference picture list after display
     868        if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
     869        {
     870#if !DYN_REF_FREE
     871          pcPic->setReconMark(false);
     872
     873          // mark it should be extended later
     874          pcPic->getPicYuvRec()->setBorderExtension( false );
     875
     876#else
     877          pcPic->destroy();
     878          pcListPic->erase( iterPic );
     879          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
     880          continue;
     881#endif
     882        }
     883        pcPic->setOutputMark(false);
     884      }
     885
     886      iterPic++;
     887    }
     888  }
     889}
     890
     891/** \param pcListPic list of pictures to be written to file
     892    \todo            DYN_REF_FREE should be revised
     893 */
     894#if SVC_EXTENSION
     895Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, UInt layerId )
     896#else
     897Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic )
     898#endif
     899{
     900  if(!pcListPic || pcListPic->empty())
     901  {
     902    return;
     903  }
     904  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
     905
     906  iterPic   = pcListPic->begin();
     907  TComPic* pcPic = *(iterPic);
     908
     909  if (pcPic->isField()) //Field Decoding
     910  {
     911    TComList<TComPic*>::iterator endPic   = pcListPic->end();
     912    endPic--;
     913    TComPic *pcPicTop, *pcPicBottom = NULL;
     914    while (iterPic != endPic)
     915    {
     916      pcPicTop = *(iterPic);
     917      iterPic++;
     918      pcPicBottom = *(iterPic);
     919
     920      if ( pcPicTop->getOutputMark() && pcPicBottom->getOutputMark() && !(pcPicTop->getPOC()%2) && (pcPicBottom->getPOC() == pcPicTop->getPOC()+1) )
     921      {
     922        // write to file
     923#if SVC_EXTENSION
     924        if ( m_pchReconFile[layerId] )
    663925        {
    664926          const Window &conf = pcPicTop->getConformanceWindow();
    665927          const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
    666928          const Bool isTff = pcPicTop->isTopField();
    667           m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
     929          TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
     930          TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
     931#if Q0074_SEI_COLOR_MAPPING
     932          if( m_acTDecTop[layerId].m_ColorMapping->getColorMappingFlag() )
     933          {
     934            pPicCYuvRecTop = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRecTop, 0, layerId );
     935            pPicCYuvRecBot = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRecBot, 1, layerId );
     936          }
     937#endif
     938#if REPN_FORMAT_IN_VPS
     939          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
     940          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
     941
     942          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRecTop, pPicCYuvRecBot,
     943            conf.getWindowLeftOffset()  *xScal + defDisp.getWindowLeftOffset(),
     944            conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(),
     945            conf.getWindowTopOffset()   *yScal + defDisp.getWindowTopOffset(),
     946            conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset(), isTff );
     947#else
     948          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRecTop, pPicCYuvRecBot,
     949            conf.getWindowLeftOffset()   + defDisp.getWindowLeftOffset(),
     950            conf.getWindowRightOffset()  + defDisp.getWindowRightOffset(),
     951            conf.getWindowTopOffset()    + defDisp.getWindowTopOffset(),
     952            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
     953#endif
     954        }
     955
     956        // update POC of display order
     957        m_aiPOCLastDisplay[layerId] = pcPicBottom->getPOC();
     958#else
     959        if ( m_pchReconFile )
     960        {
     961          const Window &conf = pcPicTop->getConformanceWindow();
     962          const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
     963          const Bool isTff = pcPicTop->isTopField();
     964          TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
     965          TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
     966#if Q0074_SEI_COLOR_MAPPING
     967          if( m_cTDecTop.m_ColorMapping->getColorMappingFlag() )
     968          {
     969            pPicCYuvRecTop = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRecTop, 0 );
     970            pPicCYuvRecBot = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRecBot, 1 );
     971          }
     972#endif
     973          m_cTVideoIOYuvReconFile.write( pPicCYuvRecTop, pPicCYuvRecBot,
    668974            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    669975            conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     
    7091015        pcPicTop->setOutputMark(false);
    7101016        pcPicBottom->setOutputMark(false);
    711       }
    712     }
    713   }
    714   else if (!pcPic->isField()) //Frame Decoding
    715   {
    716     iterPic = pcListPic->begin();
     1017
     1018#if !DYN_REF_FREE
     1019        if(pcPicTop)
     1020        {
     1021          pcPicTop->destroy();
     1022          delete pcPicTop;
     1023          pcPicTop = NULL;
     1024        }
     1025#endif
     1026      }
     1027    }
     1028    if(pcPicBottom)
     1029    {
     1030      pcPicBottom->destroy();
     1031      delete pcPicBottom;
     1032      pcPicBottom = NULL;
     1033    }
     1034  }
     1035  else //Frame decoding
     1036  {
    7171037    while (iterPic != pcListPic->end())
    7181038    {
    7191039      pcPic = *(iterPic);
    7201040
    721 #if SVC_EXTENSION
    722       if ( pcPic->getOutputMark() && (numPicsNotYetDisplayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_aiPOCLastDisplay[layerId]))
    723 #else
    724       if ( pcPic->getOutputMark() && (numPicsNotYetDisplayed >  pcPic->getNumReorderPics(tId) && pcPic->getPOC() > m_iPOCLastDisplay))
    725 #endif
     1041      if ( pcPic->getOutputMark() )
    7261042      {
    7271043        // write to file
    728         numPicsNotYetDisplayed--;
    7291044#if SVC_EXTENSION
    7301045        if ( m_pchReconFile[layerId] )
     
    7321047          const Window &conf = pcPic->getConformanceWindow();
    7331048          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
     1049          TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
     1050#if Q0074_SEI_COLOR_MAPPING
     1051          if( m_acTDecTop[layerId].m_ColorMapping->getColorMappingFlag() )
     1052          {
     1053            pPicCYuvRec = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRec, 0, layerId );
     1054          }
     1055#endif
    7341056#if REPN_FORMAT_IN_VPS
    7351057          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
    7361058          Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
    737           m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
    738             conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
    739             conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
    740             conf.getWindowTopOffset()   * yScal + defDisp.getWindowTopOffset(),
    741             conf.getWindowBottomOffset()* yScal + defDisp.getWindowBottomOffset() );
    742 
    743 #else
    744           m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
    745             conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    746             conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    747             conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    748             conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    749 #endif
    750         }
    751 
    752         // update POC of display order
    753         m_aiPOCLastDisplay[layerId] = pcPic->getPOC();
    754 #else
    755         if ( m_pchReconFile )
    756         {
    757 #if SYNTAX_OUTPUT
    758           const Window &conf = pcPic->getConformanceWindow();
    759           const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    760           m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
    761             conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    762             conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    763             conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    764             conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    765 #endif
    766         }
    767 
    768         // update POC of display order
    769         m_iPOCLastDisplay = pcPic->getPOC();
    770 #endif
    771 
    772         // erase non-referenced picture in the reference picture list after display
    773         if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
    774         {
    775 #if !DYN_REF_FREE
    776           pcPic->setReconMark(false);
    777 
    778           // mark it should be extended later
    779           pcPic->getPicYuvRec()->setBorderExtension( false );
    780 
    781 #else
    782           pcPic->destroy();
    783           pcListPic->erase( iterPic );
    784           iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    785           continue;
    786 #endif
    787         }
    788         pcPic->setOutputMark(false);
    789       }
    790 
    791       iterPic++;
    792     }
    793   }
    794 }
    795 
    796 /** \param pcListPic list of pictures to be written to file
    797     \todo            DYN_REF_FREE should be revised
    798  */
    799 #if SVC_EXTENSION
    800 Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, UInt layerId )
    801 #else
    802 Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic )
    803 #endif
    804 {
    805   if(!pcListPic || pcListPic->empty())
    806   {
    807     return;
    808   }
    809   TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
    810 
    811   iterPic   = pcListPic->begin();
    812   TComPic* pcPic = *(iterPic);
    813 
    814   if (pcPic->isField()) //Field Decoding
    815   {
    816     TComList<TComPic*>::iterator endPic   = pcListPic->end();
    817     endPic--;
    818     TComPic *pcPicTop, *pcPicBottom = NULL;
    819     while (iterPic != endPic)
    820     {
    821       pcPicTop = *(iterPic);
    822       iterPic++;
    823       pcPicBottom = *(iterPic);
    824 
    825       if ( pcPicTop->getOutputMark() && pcPicBottom->getOutputMark() && !(pcPicTop->getPOC()%2) && (pcPicBottom->getPOC() == pcPicTop->getPOC()+1) )
    826       {
    827         // write to file
    828 #if SVC_EXTENSION
    829         if ( m_pchReconFile[layerId] )
    830         {
    831           const Window &conf = pcPicTop->getConformanceWindow();
    832           const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
    833           const Bool isTff = pcPicTop->isTopField();
    834 #if REPN_FORMAT_IN_VPS
    835           UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
    836           Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
    837           m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
    838             conf.getWindowLeftOffset()  *xScal + defDisp.getWindowLeftOffset(),
    839             conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(),
    840             conf.getWindowTopOffset()   *yScal + defDisp.getWindowTopOffset(),
    841             conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset(), isTff );
    842 
    843 #else
    844 #if O0194_DIFFERENT_BITDEPTH_EL_BL
    845           // Compile time bug-fix
    846           m_acTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
    847 #else
    848           m_cTVideoIOYuvReconFile[layerId].write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
    849 #endif
    850             conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    851             conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    852             conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    853             conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
    854 #endif
    855         }
    856 
    857         // update POC of display order
    858         m_aiPOCLastDisplay[layerId] = pcPicBottom->getPOC();
    859 #else
    860         if ( m_pchReconFile )
    861         {
    862           const Window &conf = pcPicTop->getConformanceWindow();
    863           const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
    864           const Bool isTff = pcPicTop->isTopField();
    865           m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
    866             conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    867             conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    868             conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    869             conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
    870         }
    871 
    872         // update POC of display order
    873         m_iPOCLastDisplay = pcPicBottom->getPOC();
    874 #endif
    875 
    876         // erase non-referenced picture in the reference picture list after display
    877         if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true )
    878         {
    879 #if !DYN_REF_FREE
    880           pcPicTop->setReconMark(false);
    881 
    882           // mark it should be extended later
    883           pcPicTop->getPicYuvRec()->setBorderExtension( false );
    884 
    885 #else
    886           pcPicTop->destroy();
    887           pcListPic->erase( iterPic );
    888           iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    889           continue;
    890 #endif
    891         }
    892         if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true )
    893         {
    894 #if !DYN_REF_FREE
    895           pcPicBottom->setReconMark(false);
    896 
    897           // mark it should be extended later
    898           pcPicBottom->getPicYuvRec()->setBorderExtension( false );
    899 
    900 #else
    901           pcPicBottom->destroy();
    902           pcListPic->erase( iterPic );
    903           iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
    904           continue;
    905 #endif
    906         }
    907         pcPicTop->setOutputMark(false);
    908         pcPicBottom->setOutputMark(false);
    909 
    910 #if !DYN_REF_FREE
    911         if(pcPicTop)
    912         {
    913           pcPicTop->destroy();
    914           delete pcPicTop;
    915           pcPicTop = NULL;
    916         }
    917 #endif
    918       }
    919     }
    920     if(pcPicBottom)
    921     {
    922       pcPicBottom->destroy();
    923       delete pcPicBottom;
    924       pcPicBottom = NULL;
    925     }
    926   }
    927   else //Frame decoding
    928   {
    929     while (iterPic != pcListPic->end())
    930     {
    931       pcPic = *(iterPic);
    932 
    933       if ( pcPic->getOutputMark() )
    934       {
    935         // write to file
    936 #if SVC_EXTENSION
    937         if ( m_pchReconFile[layerId] )
    938         {
    939           const Window &conf = pcPic->getConformanceWindow();
    940           const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    941 #if REPN_FORMAT_IN_VPS
    942           UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
    943           Int xScal =  TComSPS::getWinUnitX( chromaFormatIdc ), yScal = TComSPS::getWinUnitY( chromaFormatIdc );
    944           m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
     1059
     1060          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRec,
    9451061            conf.getWindowLeftOffset()  *xScal + defDisp.getWindowLeftOffset(),
    9461062            conf.getWindowRightOffset() *xScal + defDisp.getWindowRightOffset(),
    9471063            conf.getWindowTopOffset()   *yScal + defDisp.getWindowTopOffset(),
    9481064            conf.getWindowBottomOffset()*yScal + defDisp.getWindowBottomOffset() );
    949 
    950 #else
    951           m_acTVideoIOYuvReconFile[layerId].write( pcPic->getPicYuvRec(),
    952             conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    953             conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    954             conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     1065#else
     1066          m_acTVideoIOYuvReconFile[layerId].write( pPicCYuvRec,
     1067            conf.getWindowLeftOffset()   + defDisp.getWindowLeftOffset(),
     1068            conf.getWindowRightOffset()  + defDisp.getWindowRightOffset(),
     1069            conf.getWindowTopOffset()    + defDisp.getWindowTopOffset(),
    9551070            conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    9561071#endif
     
    9641079          const Window &conf = pcPic->getConformanceWindow();
    9651080          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    966           m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
     1081          TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
     1082#if Q0074_SEI_COLOR_MAPPING
     1083          if( m_cTDecTop.m_ColorMapping->getColorMappingFlag() )
     1084          {
     1085            pPicCYuvRec = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRec );
     1086          }
     1087#endif
     1088          m_cTVideoIOYuvReconFile.write( pPicCYuvRec,
    9671089            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    9681090            conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     
    10451167    yScal = TComSPS::getWinUnitY( chromaFormatIdc );
    10461168#endif
    1047     m_acTVideoIOYuvReconFile[layerIdx].write( pic->getPicYuvRec(),
     1169    TComPicYuv* pPicCYuvRec = pic->getPicYuvRec();
     1170#if Q0074_SEI_COLOR_MAPPING
     1171    pPicCYuvRec = m_acTDecTop[layerIdx].m_ColorMapping->getColorMapping( pPicCYuvRec, 0, layerIdx );
     1172#endif
     1173    m_acTVideoIOYuvReconFile[layerIdx].write( pPicCYuvRec,
    10481174      conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
    10491175      conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
  • trunk/source/App/TAppEncoder/TAppEncCfg.cpp

    r649 r713  
    339339  string* cfg_ReconFile      [MAX_LAYERS];
    340340  Double* cfg_fQP            [MAX_LAYERS];
     341#if Q0074_SEI_COLOR_MAPPING
     342  string* cfg_seiColorMappingFile[MAX_LAYERS];
     343#endif
    341344
    342345#if REPN_FORMAT_IN_VPS
     
    433436    cfg_IntraPeriod[layer]  = &m_acLayerCfg[layer].m_iIntraPeriod;
    434437    cfg_conformanceMode[layer] = &m_acLayerCfg[layer].m_conformanceMode;
     438#if Q0074_SEI_COLOR_MAPPING
     439    cfg_seiColorMappingFile[layer] = &m_acLayerCfg[layer].m_cSeiColorMappingFile;
     440#endif
    435441#if LAYER_CTB
    436442    // coding unit (CU) definition
     
    616622#endif
    617623  ("EnableElRapB,-use-rap-b",  m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture)")
     624#if Q0074_SEI_COLOR_MAPPING
     625  ("SEIColorMappingFile%d", cfg_seiColorMappingFile, string(""), MAX_LAYERS, "File Containing SEI Color Mapping data")
     626#endif
    618627#else //SVC_EXTENSION
    619628  ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
     
    710719  ("IntraPeriod,-ip",         m_iIntraPeriod,              -1, "Intra period in frames, (-1: only first frame)")
    711720#endif
     721#if ALLOW_RECOVERY_POINT_AS_RAP
     722  ("DecodingRefreshType,-dr", m_iDecodingRefreshType,       0, "Intra refresh type (0:none 1:CRA 2:IDR 3:RecPointSEI)")
     723#else
    712724  ("DecodingRefreshType,-dr", m_iDecodingRefreshType,       0, "Intra refresh type (0:none 1:CRA 2:IDR)")
     725#endif
    713726  ("GOPSize,g",               m_iGOPSize,                   1, "GOP size of temporal structure")
    714727  // motion options
     
    905918  ("SEIToneMapCameraIsoSpeedIdc",                     m_cameraIsoSpeedIdc,                        0, "Indicates the camera ISO speed for daylight illumination")
    906919  ("SEIToneMapCameraIsoSpeedValue",                   m_cameraIsoSpeedValue,                    400, "Specifies the camera ISO speed for daylight illumination of Extended_ISO")
     920  ("SEIToneMapExposureIndexIdc",                      m_exposureIndexIdc,                         0, "Indicates the exposure index setting of the camera")
     921  ("SEIToneMapExposureIndexValue",                    m_exposureIndexValue,                     400, "Specifies the exposure index setting of the cameran of Extended_ISO")
    907922  ("SEIToneMapExposureCompensationValueSignFlag",     m_exposureCompensationValueSignFlag,        0, "Specifies the sign of ExposureCompensationValue")
    908923  ("SEIToneMapExposureCompensationValueNumerator",    m_exposureCompensationValueNumerator,       0, "Specifies the numerator of ExposureCompensationValue")
     
    955970  ("CrossLayerBLAFlag",                m_crossLayerBLAFlag,                       false, "Specifies the value of cross_layer_bla_flag in VPS")
    956971#endif
     972#if Q0048_CGS_3D_ASYMLUT
     973  ("CGS",     m_nCGSFlag , 0, "whether CGS is enabled")
     974  ("CGSMaxOctantDepth", m_nCGSMaxOctantDepth , 1, "max octant depth")
     975  ("CGSMaxYPartNumLog",  m_nCGSMaxYPartNumLog2 , 2, "max Y part number ")
     976  ("CGSLUTBit",     m_nCGSLUTBit , 12, "bit depth of CGS LUT")
     977#endif
    957978  ;
    958979 
     
    12021223        if( i >= m_acLayerCfg[layer].m_numSamplePredRefLayers )
    12031224        {
    1204           printf( "NumSamplePredRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" );
     1225          printf( "NumSamplePredRefLayers%d: The number of columns whose width are defined is larger than the allowed number of columns.\n", layer );
    12051226          exit( EXIT_FAILURE );
    12061227        }
     
    12111232      if( i < m_acLayerCfg[layer].m_numSamplePredRefLayers )
    12121233      {
    1213         printf( "NumSamplePredRefLayers: The width of some columns is not defined.\n" );
     1234        printf( "NumSamplePredRefLayers%d: The width of some columns is not defined.\n", layer );
    12141235        exit( EXIT_FAILURE );
    12151236      }
     
    12331254        if( i >= m_acLayerCfg[layer].m_numMotionPredRefLayers )
    12341255        {
    1235           printf( "NumMotionPredRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" );
     1256          printf( "NumMotionPredRefLayers%d: The number of columns whose width are defined is larger than the allowed number of columns.\n", layer );
    12361257          exit( EXIT_FAILURE );
    12371258        }
     
    12421263      if( i < m_acLayerCfg[layer].m_numMotionPredRefLayers )
    12431264      {
    1244         printf( "NumMotionPredRefLayers: The width of some columns is not defined.\n" );
     1265        printf( "NumMotionPredRefLayers%d: The width of some columns is not defined.\n", layer );
    12451266        exit( EXIT_FAILURE );
    12461267      }
     
    12721293        if( i >= m_acLayerCfg[layer].m_numActiveRefLayers )
    12731294        {
    1274           printf( "NumActiveRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" );
     1295          printf( "NumActiveRefLayers%d: The number of columns whose width are defined is larger than the allowed number of columns.\n", layer );
    12751296          exit( EXIT_FAILURE );
    12761297        }
     
    12811302      if( i < m_acLayerCfg[layer].m_numActiveRefLayers )
    12821303      {
    1283         printf( "NumActiveRefLayers: The width of some columns is not defined.\n" );
     1304        printf( "NumActiveRefLayers%d: The width of some columns is not defined.\n", layer );
    12841305        exit( EXIT_FAILURE );
    12851306      }
     
    14741495    }
    14751496  }
     1497
    14761498#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    14771499  if (m_interLayerConstrainedTileSetsSEIEnabled)
     
    15871609  xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" );
    15881610#endif
     1611#if ALLOW_RECOVERY_POINT_AS_RAP
     1612  xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 3,                   "Decoding Refresh Type must be comprised between 0 and 3 included" );
     1613  if(m_iDecodingRefreshType == 3)
     1614  {
     1615    xConfirmPara( !m_recoveryPointSEIEnabled,                                               "When using RecoveryPointSEI messages as RA points, recoveryPointSEI must be enabled" );
     1616  }
     1617#else
    15891618  xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2,                   "Decoding Refresh Type must be equal to 0, 1 or 2" );
     1619#endif
    15901620#if !SVC_EXTENSION
    15911621  xConfirmPara( m_iQP <  -6 * (m_internalBitDepthY - 8) || m_iQP > 51,                    "QP exceeds supported range (-QpBDOffsety to 51)" );
     
    21602190    xConfirmPara( m_toneMapModelId < 0 || m_toneMapModelId > 4 , "SEIToneMapModelId must be in rage 0 to 4");
    21612191    xConfirmPara( m_cameraIsoSpeedValue == 0, "SEIToneMapCameraIsoSpeedValue shall not be equal to 0");
     2192    xConfirmPara( m_exposureIndexValue  == 0, "SEIToneMapExposureIndexValue shall not be equal to 0");
    21622193    xConfirmPara( m_extendedRangeWhiteLevel < 100, "SEIToneMapExtendedRangeWhiteLevel should be greater than or equal to 100");
    21632194    xConfirmPara( m_nominalBlackLevelLumaCodeValue >= m_nominalWhiteLevelLumaCodeValue, "SEIToneMapNominalWhiteLevelLumaCodeValue shall be greater than SEIToneMapNominalBlackLevelLumaCodeValue");
     
    22862317  }
    22872318#endif
     2319#if Q0048_CGS_3D_ASYMLUT
     2320  xConfirmPara( m_nCGSFlag < 0 || m_nCGSFlag > 1 , "0<=CGS<=1" );
     2321#endif
    22882322#undef xConfirmPara
    22892323  if (check_failed)
     
    25452579  printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0 );
    25462580#endif
     2581#if Q0048_CGS_3D_ASYMLUT
     2582  printf("CGS: %d CGSMaxOctantDepth: %d CGSMaxYPartNumLog2: %d CGSLUTBit:%d " , m_nCGSFlag , m_nCGSMaxOctantDepth , m_nCGSMaxYPartNumLog2 , m_nCGSLUTBit );
     2583#endif
    25472584  printf("\n\n");
    25482585 
  • trunk/source/App/TAppEncoder/TAppEncCfg.h

    r644 r713  
    255255  Int       m_cameraIsoSpeedIdc;
    256256  Int       m_cameraIsoSpeedValue;
     257  Int       m_exposureIndexIdc;
     258  Int       m_exposureIndexValue;
    257259  Int       m_exposureCompensationValueSignFlag;
    258260  Int       m_exposureCompensationValueNumerator;
     
    266268  Int*      m_codedPivotValue;
    267269  Int*      m_targetPivotValue;
     270#if Q0074_SEI_COLOR_MAPPING
     271  Char*     m_pchSEIColorMappingFile;             ///< SEI Color Mapping File (initialized from external file)
     272#endif
    268273  Int       m_framePackingSEIEnabled;
    269274  Int       m_framePackingSEIType;
     
    393398  Bool      m_useInterLayerWeightedPred;
    394399#endif
     400#if Q0048_CGS_3D_ASYMLUT
     401  Int  m_nCGSFlag;
     402  Int  m_nCGSMaxOctantDepth;
     403  Int  m_nCGSMaxYPartNumLog2;
     404  Int  m_nCGSLUTBit;
     405#endif
    395406public:
    396407  TAppEncCfg();
  • trunk/source/App/TAppEncoder/TAppEncLayerCfg.cpp

    r644 r713  
    171171  }
    172172#endif
     173#if REPN_FORMAT_IN_VPS
     174  printf("Real     Format               : %dx%d %dHz\n", m_iSourceWidth - ( m_confLeft + m_confRight ) * TComSPS::getWinUnitX( m_chromaFormatIDC ), m_iSourceHeight - ( m_confTop + m_confBottom ) * TComSPS::getWinUnitY( m_chromaFormatIDC ), m_iFrameRate );
     175#else
    173176  printf("Real     Format               : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
     177#endif
    174178  printf("Internal Format               : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
    175179#if O0194_DIFFERENT_BITDEPTH_EL_BL
     
    229233        m_aiPad[0] = m_confRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
    230234        m_iSourceWidth  += m_confRight;
     235#if REPN_FORMAT_IN_VPS
     236        m_confRight /= TComSPS::getWinUnitX( m_chromaFormatIDC );
     237#endif
    231238      }
    232239      if (m_iSourceHeight % minCuSize)
     
    239246          m_aiPad[1] = m_confBottom << 1;
    240247        }
     248#if REPN_FORMAT_IN_VPS
     249        m_confBottom /= TComSPS::getWinUnitY( m_chromaFormatIDC );
     250#endif
    241251      }
    242252      break;
     
    249259      m_confRight  = m_aiPad[0];
    250260      m_confBottom = m_aiPad[1];
     261#if REPN_FORMAT_IN_VPS
     262      m_confRight /= TComSPS::getWinUnitX( m_chromaFormatIDC );
     263      m_confBottom /= TComSPS::getWinUnitY( m_chromaFormatIDC );
     264#endif
    251265      break;
    252266    }
     
    331345  xConfirmPara( m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
    332346
     347#if !REPN_FORMAT_IN_VPS
    333348  xConfirmPara( m_confLeft   % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
    334349  xConfirmPara( m_confRight  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
    335350  xConfirmPara( m_confTop    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
    336351  xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
     352#endif
    337353
    338354#if LAYER_CTB 
  • trunk/source/App/TAppEncoder/TAppEncLayerCfg.h

    r644 r713  
    5454  Int       *m_predLayerIds;
    5555  Int       m_numActiveRefLayers;
     56#endif
     57#if Q0074_SEI_COLOR_MAPPING
     58  string    m_cSeiColorMappingFile;
    5659#endif
    5760
  • trunk/source/App/TAppEncoder/TAppEncTop.cpp

    r649 r713  
    9191  }
    9292
    93 #if REPN_FORMAT_IN_VPS
    94   vps->setRepFormatIdxPresentFlag( true );   // Could be disabled to optimize in some cases.
     93#if REPN_FORMAT_IN_VPS 
    9594  Int maxRepFormatIdx = -1;
    9695  Int formatIdx = -1;
     
    125124
    126125    assert( m_acLayerCfg[layer].getRepFormatIdx() != -1 && "RepFormatIdx not assigned for a layer" );
     126
    127127    vps->setVpsRepFormatIdx( layer, m_acLayerCfg[layer].getRepFormatIdx() );
     128
    128129    maxRepFormatIdx = std::max( m_acLayerCfg[layer].getRepFormatIdx(), maxRepFormatIdx );
    129130  }
     131
    130132  assert( vps->getVpsRepFormatIdx( 0 ) == 0 );  // Base layer should point to the first one.
     133
    131134  Int* mapIdxToLayer = new Int[maxRepFormatIdx + 1];
     135
    132136  // Check that all the indices from 0 to maxRepFormatIdx are used in the VPS
    133137  for(Int i = 0; i <= maxRepFormatIdx; i++)
     
    145149    assert( layer != m_numLayers );   // One of the VPS Rep format indices not set
    146150  }
     151
    147152  vps->setVpsNumRepFormats( maxRepFormatIdx + 1 );
     153
     154#if Q0195_REP_FORMAT_CLEANUP
     155  // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0
     156  vps->setRepFormatIdxPresentFlag( vps->getVpsNumRepFormats() > 1 ? true : false );
     157#else
     158  vps->setRepFormatIdxPresentFlag( true );
     159#endif
     160
    148161  for(UInt idx=0; idx < vps->getVpsNumRepFormats(); idx++)
    149162  {
     
    467480    m_acTEncTop[layer].setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
    468481    m_acTEncTop[layer].setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
     482#if Q0074_SEI_COLOR_MAPPING
     483    m_acTEncTop[layer].setColorMappingInfoSEIFile                   ( m_acLayerCfg[layer].m_cSeiColorMappingFile.empty() ? NULL : const_cast<Char *>(m_acLayerCfg[layer].m_cSeiColorMappingFile.c_str()) );
     484#endif
    469485    m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
    470486    m_acTEncTop[layer].setFramePackingArrangementSEIType( m_framePackingSEIType );
     
    592608    m_acTEncTop[layer].setCrossLayerBLAFlag( m_crossLayerBLAFlag );
    593609#endif
     610#if Q0048_CGS_3D_ASYMLUT
     611    m_acTEncTop[layer].setCGSFlag( layer == 0 ? 0 : m_nCGSFlag );
     612    m_acTEncTop[layer].setCGSMaxOctantDepth( m_nCGSMaxOctantDepth );
     613    m_acTEncTop[layer].setCGSMaxYPartNumLog2( m_nCGSMaxYPartNumLog2 );
     614    m_acTEncTop[layer].setCGSLUTBit( m_nCGSLUTBit );
     615#endif
    594616  }
    595617}
     
    767789  m_cTEncTop.setTMISEICameraIsoSpeedIdc                   ( m_cameraIsoSpeedIdc );
    768790  m_cTEncTop.setTMISEICameraIsoSpeedValue                 ( m_cameraIsoSpeedValue );
     791  m_cTEncTop.setTMISEIExposureIndexIdc                    ( m_exposureIndexIdc );
     792  m_cTEncTop.setTMISEIExposureIndexValue                  ( m_exposureIndexValue );
    769793  m_cTEncTop.setTMISEIExposureCompensationValueSignFlag   ( m_exposureCompensationValueSignFlag );
    770794  m_cTEncTop.setTMISEIExposureCompensationValueNumerator  ( m_exposureCompensationValueNumerator );
     
    775799  m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue      ( m_nominalWhiteLevelLumaCodeValue );
    776800  m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue     ( m_extendedWhiteLevelLumaCodeValue );
     801#if Q0074_SEI_COLOR_MAPPING
     802  m_cTEncTop.setColorMappingInfoSEIFile                   ( m_pchSEIColorMappingFile );
     803#endif
    777804  m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
    778805  m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType );
     
    9741001  vps->setMaxLayerId(m_numLayers - 1);    // Set max-layer ID
    9751002
     1003  vps->setVpsExtensionFlag( m_numLayers > 1 ? true : false );
     1004
    9761005  vps->setNumLayerSets(m_numLayers);
    9771006  for(Int setId = 1; setId < vps->getNumLayerSets(); setId++)
     
    10681097#if VPS_TSLAYERS
    10691098    vps->setMaxTSLayersPresentFlag(true);
    1070     for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
    1071     {
    1072         vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1);
     1099    for( i = 0; i < vps->getMaxLayers(); i++ )
     1100    {
     1101      vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1);
    10731102    }
    10741103#endif
     
    10811110  if (vps->getMaxTidRefPresentFlag())
    10821111  {
    1083     for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
     1112    for( i = 0; i < vps->getMaxLayers() - 1; i++ )
    10841113    {
    10851114#if N0120_MAX_TID_REF_CFG
    10861115#if O0225_MAX_TID_FOR_REF_LAYERS
    1087       for( Int j = i+1; j <= MAX_VPS_LAYER_ID_PLUS1 - 1; j++)
     1116      for( Int j = i+1; j < vps->getMaxLayers(); j++)
    10881117      {
    10891118        vps->setMaxTidIlRefPicsPlus1(i, j, m_acTEncTop[i].getMaxTidIlRefPicsPlus1());
     
    10941123#else
    10951124#if O0225_MAX_TID_FOR_REF_LAYERS
    1096       for( Int j = i+1; j <= MAX_VPS_LAYER_ID_PLUS1 - 1; j++)
     1125      for( Int j = i+1; j < vps->getMaxLayers(); j++)
    10971126      {
    10981127        vps->setMaxTidIlRefPicsPlus1(i, j, vps->getMaxTLayers()+1);
     
    11061135  else
    11071136  {
    1108     for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
     1137    for( i = 0; i < vps->getMaxLayers() - 1; i++ )
    11091138    {
    11101139#if O0225_MAX_TID_FOR_REF_LAYERS
    1111       for( Int j = i+1; j <= MAX_VPS_LAYER_ID_PLUS1 - 1; j++)
     1140      for( Int j = i+1; j < vps->getMaxLayers(); j++)
    11121141      {
    11131142        vps->setMaxTidIlRefPicsPlus1(i, j, 7);
     
    12971326  if(vps->getMaxLayers() > MAX_REF_LAYERS)
    12981327  {
    1299     for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     1328    for(UInt layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
    13001329    {
    13011330      assert( vps->getNumRefLayers(vps->getLayerIdInNuh(layerCtr)) <= MAX_REF_LAYERS);
     
    14001429      Int iPicWidth         = pcCfgLayer->getSourceWidth();
    14011430      Int iPicHeight        = pcCfgLayer->getSourceHeight();
     1431#if LAYER_CTB
     1432      UInt uiWidthInCU       = ( iPicWidth  % m_acLayerCfg[layerId].m_uiMaxCUWidth  ) ? iPicWidth  / m_acLayerCfg[layerId].m_uiMaxCUWidth  + 1 : iPicWidth  / m_acLayerCfg[layerId].m_uiMaxCUWidth;
     1433      UInt uiHeightInCU      = ( iPicHeight % m_acLayerCfg[layerId].m_uiMaxCUHeight ) ? iPicHeight / m_acLayerCfg[layerId].m_uiMaxCUHeight + 1 : iPicHeight / m_acLayerCfg[layerId].m_uiMaxCUHeight;
     1434#else
    14021435      UInt uiWidthInCU       = ( iPicWidth %m_uiMaxCUWidth  ) ? iPicWidth /m_uiMaxCUWidth  + 1 : iPicWidth /m_uiMaxCUWidth;
    14031436      UInt uiHeightInCU      = ( iPicHeight%m_uiMaxCUHeight ) ? iPicHeight/m_uiMaxCUHeight + 1 : iPicHeight/m_uiMaxCUHeight;
     1437#endif
    14041438      UInt uiNumCUsInFrame   = uiWidthInCU * uiHeightInCU;
    14051439
     1440#if LAYER_CTB
     1441      UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_acLayerCfg[layerId].m_uiMaxCUDepth << 1);
     1442#else
    14061443      UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_uiMaxCUDepth << 1);
     1444#endif
    14071445      UInt numDU = ( pcCfgLayer->getSliceMode() == 1 ) ? ( uiNumCUsInFrame / maxCU ) : ( 0 );
    14081446      if( uiNumCUsInFrame % maxCU != 0 || numDU == 0 )
  • trunk/source/Lib/TLibCommon/CommonDef.h

    r644 r713  
    5858#if SVC_EXTENSION
    5959#include <vector>
    60 #define NV_VERSION        "5.1 (HM-13.0)"                 ///< Current software version
     60#define NV_VERSION        "6.0 (HM-14.0)"                 ///< Current software version
    6161#else
    62 #define NV_VERSION        "13.0"                ///< Current software version
     62#define NV_VERSION        "14.0"                ///< Current software version
    6363#endif
    6464
  • trunk/source/Lib/TLibCommon/SEI.h

    r644 r713  
    7979#endif
    8080#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    81     INTER_LAYER_CONSTRAINED_TILE_SETS    = 138
     81    INTER_LAYER_CONSTRAINED_TILE_SETS    = 138,
    8282#endif
    8383#if SUB_BITSTREAM_PROPERTY_SEI
    84    ,SUB_BITSTREAM_PROPERTY               = 139    // Final PayloadType to be defined after finalization
     84    SUB_BITSTREAM_PROPERTY               = 139,    // Final PayloadType to be defined after finalization
    8585#endif
    8686#if O0164_MULTI_LAYER_HRD
    87    ,BSP_NESTING                          = 140
    88    ,BSP_INITIAL_ARRIVAL_TIME             = 141
    89    ,BSP_HRD                              = 142
     87    BSP_NESTING                          = 140,
     88    BSP_INITIAL_ARRIVAL_TIME             = 141,
     89    BSP_HRD                              = 142,
     90#endif
     91#if Q0074_SEI_COLOR_MAPPING
     92    COLOR_MAPPING_INFO                   = 143,
    9093#endif
    9194  };
     
    142145  SEIActiveParameterSets()
    143146    : activeVPSId            (0)
    144     , m_fullRandomAccessFlag (false)
    145     , m_noParamSetUpdateFlag (false)
     147    , m_selfContainedCvsFlag (false)
     148    , m_noParameterSetUpdateFlag (false)
    146149    , numSpsIdsMinus1        (0)
    147150  {}
     
    149152
    150153  Int activeVPSId;
    151   Bool m_fullRandomAccessFlag;
    152   Bool m_noParamSetUpdateFlag;
     154  Bool m_selfContainedCvsFlag;
     155  Bool m_noParameterSetUpdateFlag;
    153156  Int numSpsIdsMinus1;
    154   std::vector<Int> activeSeqParamSetId;
     157  std::vector<Int> activeSeqParameterSetId;
    155158};
    156159
     
    393396  Int    m_cameraIsoSpeedIdc;
    394397  Int    m_cameraIsoSpeedValue;
     398  Int    m_exposureIndexIdc;
     399  Int    m_exposureIndexValue;
    395400  Int    m_exposureCompensationValueSignFlag;
    396401  Int    m_exposureCompensationValueNumerator;
     
    402407  Int    m_extendedWhiteLevelLumaCodeValue;
    403408};
     409
     410#if Q0074_SEI_COLOR_MAPPING
     411class SEIColorMappingInfo : public SEI
     412{
     413public:
     414  PayloadType payloadType() const { return COLOR_MAPPING_INFO; }
     415  SEIColorMappingInfo() {
     416  }
     417  virtual ~SEIColorMappingInfo() {}
     418
     419  Int   m_colorMapId;
     420  Bool  m_colorMapCancelFlag;
     421  Bool  m_colorMapPersistenceFlag;
     422  Bool  m_colorMap_video_signal_type_present_flag;
     423  Bool  m_colorMap_video_full_range_flag;
     424  Int   m_colorMap_primaries;
     425  Int   m_colorMap_transfer_characteristics;
     426  Int   m_colorMap_matrix_coeffs;
     427  Int   m_colorMapModelId;
     428
     429  Int   m_colour_map_coded_data_bit_depth;
     430  Int   m_colour_map_target_bit_depth;
     431
     432  Int   m_num_input_pivots[3];
     433  Int*  m_coded_input_pivot_value[3];
     434  Int*  m_target_input_pivot_value[3];
     435 
     436  Bool  m_matrix_flag;
     437  Int   m_log2_matrix_denom;
     438  Int   m_matrix_coef[3][3];
     439
     440  Int   m_num_output_pivots[3];
     441  Int*  m_coded_output_pivot_value[3];
     442  Int*  m_target_output_pivot_value[3];
     443};
     444#endif
    404445
    405446#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
  • trunk/source/Lib/TLibCommon/TComDataCU.cpp

    r595 r713  
    172172    memset( m_pcTrCoeffCb, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) );
    173173    memset( m_pcTrCoeffCr, 0,uiWidth*uiHeight/4 * sizeof( TCoeff ) );
    174 #if ADAPTIVE_QP_SELECTION   
     174#if ADAPTIVE_QP_SELECTION
    175175    if( bGlobalRMARLBuffer )
    176176    {
    177177      if( m_pcGlbArlCoeffY == NULL )
    178178      {
     179#if LAYER_CTB
     180        m_pcGlbArlCoeffY   = (Int*)xMalloc(Int, MAX_CU_SIZE * MAX_CU_SIZE);
     181        m_pcGlbArlCoeffCb  = (Int*)xMalloc(Int, MAX_CU_SIZE * MAX_CU_SIZE/4);
     182        m_pcGlbArlCoeffCr  = (Int*)xMalloc(Int, MAX_CU_SIZE * MAX_CU_SIZE/4);
     183#else
    179184        m_pcGlbArlCoeffY   = (Int*)xMalloc(Int, uiWidth*uiHeight);
    180185        m_pcGlbArlCoeffCb  = (Int*)xMalloc(Int, uiWidth*uiHeight/4);
    181186        m_pcGlbArlCoeffCr  = (Int*)xMalloc(Int, uiWidth*uiHeight/4);
     187#endif
    182188      }
    183189      m_pcArlCoeffY        = m_pcGlbArlCoeffY;
     
    16901696}
    16911697
    1692 
    1693 #if FAST_INTRA_SHVC
    1694 /** generate limited set of remaining modes
    1695 *\param   uiAbsPartIdx
    1696 *\param   uiIntraDirPred  pointer to the array for MPM storage
    1697 *\returns Number of intra coding modes (nb of remaining modes + 3 MPMs)
    1698 */
    1699 Int TComDataCU::reduceSetOfIntraModes( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int &fullSetOfModes )
    1700 {
    1701   // check BL mode
    1702   UInt          uiCUAddrBase = 0, uiAbsPartAddrBase = 0;
    1703   // the right reference layerIdc should be specified, currently it is set to m_layerId-1
    1704   TComDataCU*   pcTempCU = getBaseColCU(m_layerId - 1, uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase, 0 );
    1705 
    1706   if( pcTempCU->getPredictionMode( uiAbsPartAddrBase ) != MODE_INTRA )
    1707   {
    1708     return( NUM_INTRA_MODE-1 );
    1709   }
    1710 
    1711   // compute set of enabled modes g_reducedSetIntraModes[...]
    1712   Int authorizedMode[NUM_INTRA_MODE-1]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
    1713   Int nbModes;
    1714   for (nbModes=0; nbModes<3; nbModes++)  // add 3 MPMs 1st
    1715   {
    1716     g_reducedSetIntraModes[nbModes] = uiIntraDirPred[nbModes];
    1717     authorizedMode[ uiIntraDirPred[nbModes] ] = 0;
    1718   }
    1719 
    1720   Int iColBaseDir = pcTempCU->getLumaIntraDir( uiAbsPartAddrBase );
    1721   if ( authorizedMode[iColBaseDir] )  //possibly add BL mode
    1722   {
    1723     g_reducedSetIntraModes[nbModes++] = iColBaseDir;
    1724     authorizedMode[ iColBaseDir ] = 0;
    1725   }
    1726 
    1727   Int iRefMode = ( iColBaseDir > 1 ) ? iColBaseDir : uiIntraDirPred[0];
    1728   if ( iRefMode > 1 )    //add neighboring modes of refMode
    1729   {
    1730     UInt Left  = iRefMode;
    1731     UInt Right = iRefMode;
    1732     while ( nbModes < NB_REMAIN_MODES+3 )
    1733     {
    1734       Left = ((Left + 29) % 32) + 2;
    1735       Right = ((Right - 1 ) % 32) + 2;
    1736       if ( authorizedMode[Left] )   g_reducedSetIntraModes[nbModes++] = Left;
    1737       if ( authorizedMode[Right] )  g_reducedSetIntraModes[nbModes++] = Right;
    1738     }
    1739   }
    1740   else      //add pre-defined modes
    1741   {
    1742     Int  idx = 0;
    1743     while ( nbModes < NB_REMAIN_MODES+3 )
    1744     {
    1745       UInt mode = g_predefSetIntraModes[idx++];
    1746       if ( authorizedMode[mode] )   g_reducedSetIntraModes[nbModes++] = mode;
    1747     }
    1748   }
    1749 
    1750   fullSetOfModes = 0;
    1751   return ( nbModes );
    1752 }
    1753 #endif
    1754 
    1755 
    17561698UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth )
    17571699{
     
    18091751  return log2MinTUSizeInCU;
    18101752}
    1811 
    1812 #if REF_IDX_ME_ZEROMV
    1813 Bool TComDataCU::xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1)
    1814 {
    1815   Bool checkZeroMVILR = true;
    1816 
    1817   if(uhInterDir&0x1)  //list0
    1818   {
    1819     Int refIdxL0 = cMvFieldL0.getRefIdx();
    1820     if(getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->isILR(m_layerId))
    1821     {
    1822       checkZeroMVILR &= (cMvFieldL0.getHor() == 0 && cMvFieldL0.getVer() == 0);
    1823     }
    1824   }
    1825   if(uhInterDir&0x2)  //list1
    1826   {
    1827     Int refIdxL1  = cMvFieldL1.getRefIdx();
    1828     if(getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->isILR(m_layerId))
    1829     {
    1830       checkZeroMVILR &= (cMvFieldL1.getHor() == 0 && cMvFieldL1.getVer() == 0);
    1831     }
    1832   }
    1833 
    1834   return checkZeroMVILR;
    1835 }
    1836 
    1837 Bool TComDataCU::xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx)
    1838 {
    1839   RefPicList eRefPicList = iRefList > 0? REF_PIC_LIST_1: REF_PIC_LIST_0;
    1840   assert(eRefPicList == REF_PIC_LIST_1);
    1841 
    1842   Bool checkZeroMVILR = true;
    1843 
    1844   if(getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR(m_layerId))
    1845   {
    1846     AMVPInfo* pcAMVPInfo = getCUMvField(eRefPicList)->getAMVPInfo();
    1847     TComMv    cMv        = pcAMVPInfo->m_acMvCand[MvpIdx];
    1848     checkZeroMVILR &= (cMv.getHor() == 0 && cMv.getVer() == 0);
    1849   }
    1850 
    1851   return checkZeroMVILR;
    1852 }
    1853 #endif
    1854 
    1855 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    1856 Bool TComDataCU::isInterLayerReference(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1)
    1857 {
    1858   Bool checkILR = false;
    1859 
    1860   if(uhInterDir&0x1)  //list0
    1861   {
    1862     Int refIdxL0 = cMvFieldL0.getRefIdx();
    1863     checkILR = getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->isILR(m_layerId);
    1864   }
    1865   if(uhInterDir&0x2)  //list1
    1866   {
    1867     Int refIdxL1  = cMvFieldL1.getRefIdx();
    1868     checkILR = checkILR || getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->isILR(m_layerId);
    1869   }
    1870 
    1871   return checkILR;
    1872 }
    1873 #endif
    18741753
    18751754UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx )
     
    21682047}
    21692048
    2170 UChar TComDataCU::getNumPartInter()
     2049UChar TComDataCU::getNumPartitions()
    21712050{
    21722051  UChar iNumPart = 0;
     
    36123491TComDataCU*  TComDataCU::getBaseColCU( UInt refLayerIdc, UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int iMotionMapping )
    36133492{
    3614   TComPic* cBaseColPic = m_pcSlice->getBaseColPic(refLayerIdc);
     3493  TComPic* baseColPic = m_pcSlice->getBaseColPic(refLayerIdc);
    36153494
    36163495  uiPelX = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getWidth() - 1, uiPelX);
     
    36223501
    36233502#if O0098_SCALED_REF_LAYER_ID
    3624   Int leftStartL = getSlice()->getSPS()->getScaledRefLayerWindowForLayer(getSlice()->getVPS()->getRefLayerId(getSlice()->getLayerId(), refLayerIdc)).getWindowLeftOffset();
    3625   Int topStartL  = getSlice()->getSPS()->getScaledRefLayerWindowForLayer(getSlice()->getVPS()->getRefLayerId(getSlice()->getLayerId(), refLayerIdc)).getWindowTopOffset();
     3503  Int leftStartL = baseColPic->getSlice(0)->getSPS()->getScaledRefLayerWindowForLayer(baseColPic->getSlice(0)->getVPS()->getRefLayerId(getSlice()->getLayerId(), refLayerIdc)).getWindowLeftOffset();
     3504  Int topStartL  = baseColPic->getSlice(0)->getSPS()->getScaledRefLayerWindowForLayer(baseColPic->getSlice(0)->getVPS()->getRefLayerId(getSlice()->getLayerId(), refLayerIdc)).getWindowTopOffset();
    36263505#else
    3627   Int leftStartL = this->getSlice()->getSPS()->getScaledRefLayerWindow(refLayerIdc).getWindowLeftOffset();
    3628   Int topStartL  = this->getSlice()->getSPS()->getScaledRefLayerWindow(refLayerIdc).getWindowTopOffset();
    3629 #endif
     3506  Int leftStartL = baseColPic->getSlice(0)->getSPS()->getScaledRefLayerWindow(refLayerIdc).getWindowLeftOffset();
     3507  Int topStartL  = baseColPic->getSlice(0)->getSPS()->getScaledRefLayerWindow(refLayerIdc).getWindowTopOffset();
     3508#endif
     3509
     3510#if Q0200_CONFORMANCE_BL_SIZE
     3511  Int chromaFormatIdc = baseColPic->getSlice(0)->getChromaFormatIdc();
     3512  Int iBX = (((uiPelX - leftStartL)*g_posScalingFactor[refLayerIdc][0] + (1<<15)) >> 16) + baseColPic->getConformanceWindow().getWindowLeftOffset() * TComSPS::getWinUnitX( chromaFormatIdc );
     3513  Int iBY = (((uiPelY - topStartL )*g_posScalingFactor[refLayerIdc][1] + (1<<15)) >> 16) + baseColPic->getConformanceWindow().getWindowTopOffset() * TComSPS::getWinUnitY( chromaFormatIdc );
     3514#else
    36303515  Int iBX = ((uiPelX - leftStartL)*g_posScalingFactor[refLayerIdc][0] + (1<<15)) >> 16;
    36313516  Int iBY = ((uiPelY - topStartL )*g_posScalingFactor[refLayerIdc][1] + (1<<15)) >> 16;
     3517#endif
    36323518
    36333519#if N0139_POSITION_ROUNDING_OFFSET
    36343520  if( iMotionMapping == 1 )
    36353521  {
    3636     iBX += 4;
    3637     iBY += 4;
    3638   }
    3639 #endif
    3640 
    3641   if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight() ||
    3642        iBX < 0                                        || iBY < 0                                          )
     3522    // actually, motion field compression is performed in the Void TComPic::compressMotion() function, but with (+4) the rounding may have effect on the picture boundary check.
     3523    iBX = ( ( iBX + 4 ) >> 4 ) << 4;
     3524    iBY = ( ( iBY + 4 ) >> 4 ) << 4;
     3525  }
     3526#endif
     3527
     3528  if ( iBX < 0 || iBX >= baseColPic->getPicYuvRec()->getWidth() || iBY < 0 || iBY >= baseColPic->getPicYuvRec()->getHeight() )
    36433529  {
    36443530    return NULL;
     
    36463532
    36473533#if LAYER_CTB
    3648   UInt baseMaxCUHeight = cBaseColPic->getPicSym()->getMaxCUHeight();
    3649   UInt baseMaxCUWidth  = cBaseColPic->getPicSym()->getMaxCUWidth();
    3650   UInt baseMinUnitSize = cBaseColPic->getMinCUWidth();
    3651  
    3652   uiCUAddrBase = ( iBY / cBaseColPic->getPicSym()->getMaxCUHeight() ) * cBaseColPic->getFrameWidthInCU() + ( iBX / cBaseColPic->getPicSym()->getMaxCUWidth() );
     3534  UInt baseMaxCUHeight = baseColPic->getPicSym()->getMaxCUHeight();
     3535  UInt baseMaxCUWidth  = baseColPic->getPicSym()->getMaxCUWidth();
     3536  UInt baseMinUnitSize = baseColPic->getMinCUWidth();
     3537 
     3538  uiCUAddrBase = ( iBY / baseMaxCUHeight ) * baseColPic->getFrameWidthInCU() + ( iBX / baseMaxCUWidth );
    36533539#else
    3654   uiCUAddrBase = (iBY/g_uiMaxCUHeight)*cBaseColPic->getFrameWidthInCU() + (iBX/g_uiMaxCUWidth);
    3655 #endif
    3656 
    3657   assert(uiCUAddrBase < cBaseColPic->getNumCUsInFrame());
     3540  uiCUAddrBase = (iBY/g_uiMaxCUHeight)*baseColPic->getFrameWidthInCU() + (iBX/g_uiMaxCUWidth);
     3541#endif
     3542
     3543  assert(uiCUAddrBase < baseColPic->getNumCUsInFrame());
    36583544
    36593545#if LAYER_CTB
    3660   UInt uiRasterAddrBase = ( iBY - (iBY/baseMaxCUHeight)*baseMaxCUHeight ) / baseMinUnitSize * cBaseColPic->getNumPartInWidth() + ( iBX - (iBX/baseMaxCUWidth)*baseMaxCUWidth ) / baseMinUnitSize;
    3661  
    3662   uiAbsPartIdxBase = g_auiLayerRasterToZscan[cBaseColPic->getLayerId()][uiRasterAddrBase];
     3546  UInt uiRasterAddrBase = ( iBY - (iBY/baseMaxCUHeight)*baseMaxCUHeight ) / baseMinUnitSize * baseColPic->getNumPartInWidth() + ( iBX - (iBX/baseMaxCUWidth)*baseMaxCUWidth ) / baseMinUnitSize;
     3547 
     3548  uiAbsPartIdxBase = g_auiLayerRasterToZscan[baseColPic->getLayerId()][uiRasterAddrBase];
    36633549#else
    3664   UInt uiRasterAddrBase = (iBY - (iBY/g_uiMaxCUHeight)*g_uiMaxCUHeight)/uiMinUnitSize*cBaseColPic->getNumPartInWidth()
     3550  UInt uiRasterAddrBase = (iBY - (iBY/g_uiMaxCUHeight)*g_uiMaxCUHeight)/uiMinUnitSize*baseColPic->getNumPartInWidth()
    36653551    + (iBX - (iBX/g_uiMaxCUWidth)*g_uiMaxCUWidth)/uiMinUnitSize;
    36663552
     
    36683554#endif
    36693555
    3670   return cBaseColPic->getCU(uiCUAddrBase);
     3556  return baseColPic->getCU(uiCUAddrBase);
    36713557}
    36723558
     
    36803566  rcMvFieldEnhance.setMvField( cMv, rcMvFieldBase.getRefIdx() );
    36813567}
     3568
     3569#if FAST_INTRA_SHVC
     3570/** generate limited set of remaining modes
     3571*\param   uiAbsPartIdx
     3572*\param   uiIntraDirPred  pointer to the array for MPM storage
     3573*\returns Number of intra coding modes (nb of remaining modes + 3 MPMs)
     3574*/
     3575Int TComDataCU::reduceSetOfIntraModes( UInt uiAbsPartIdx, Int* uiIntraDirPred, Int &fullSetOfModes )
     3576{
     3577  // check BL mode
     3578  UInt          uiCUAddrBase = 0, uiAbsPartAddrBase = 0;
     3579  // the right reference layerIdc should be specified, currently it is set to m_layerId-1
     3580  TComDataCU*   pcTempCU = getBaseColCU(m_layerId - 1, uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase, 0 );
     3581
     3582  if( pcTempCU->getPredictionMode( uiAbsPartAddrBase ) != MODE_INTRA )
     3583  {
     3584    return( NUM_INTRA_MODE-1 );
     3585  }
     3586
     3587  // compute set of enabled modes g_reducedSetIntraModes[...]
     3588  Int authorizedMode[NUM_INTRA_MODE-1]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
     3589  Int nbModes;
     3590  for (nbModes=0; nbModes<3; nbModes++)  // add 3 MPMs 1st
     3591  {
     3592    g_reducedSetIntraModes[nbModes] = uiIntraDirPred[nbModes];
     3593    authorizedMode[ uiIntraDirPred[nbModes] ] = 0;
     3594  }
     3595
     3596  Int iColBaseDir = pcTempCU->getLumaIntraDir( uiAbsPartAddrBase );
     3597  if ( authorizedMode[iColBaseDir] )  //possibly add BL mode
     3598  {
     3599    g_reducedSetIntraModes[nbModes++] = iColBaseDir;
     3600    authorizedMode[ iColBaseDir ] = 0;
     3601  }
     3602
     3603  Int iRefMode = ( iColBaseDir > 1 ) ? iColBaseDir : uiIntraDirPred[0];
     3604  if ( iRefMode > 1 )    //add neighboring modes of refMode
     3605  {
     3606    UInt Left  = iRefMode;
     3607    UInt Right = iRefMode;
     3608    while ( nbModes < NB_REMAIN_MODES+3 )
     3609    {
     3610      Left = ((Left + 29) % 32) + 2;
     3611      Right = ((Right - 1 ) % 32) + 2;
     3612      if ( authorizedMode[Left] )   g_reducedSetIntraModes[nbModes++] = Left;
     3613      if ( authorizedMode[Right] )  g_reducedSetIntraModes[nbModes++] = Right;
     3614    }
     3615  }
     3616  else      //add pre-defined modes
     3617  {
     3618    Int  idx = 0;
     3619    while ( nbModes < NB_REMAIN_MODES+3 )
     3620    {
     3621      UInt mode = g_predefSetIntraModes[idx++];
     3622      if ( authorizedMode[mode] )   g_reducedSetIntraModes[nbModes++] = mode;
     3623    }
     3624  }
     3625
     3626  fullSetOfModes = 0;
     3627  return ( nbModes );
     3628}
     3629#endif
     3630
     3631#if REF_IDX_ME_ZEROMV
     3632Bool TComDataCU::xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1)
     3633{
     3634  Bool checkZeroMVILR = true;
     3635
     3636  if(uhInterDir&0x1)  //list0
     3637  {
     3638    Int refIdxL0 = cMvFieldL0.getRefIdx();
     3639    if(getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->isILR(m_layerId))
     3640    {
     3641      checkZeroMVILR &= (cMvFieldL0.getHor() == 0 && cMvFieldL0.getVer() == 0);
     3642    }
     3643  }
     3644  if(uhInterDir&0x2)  //list1
     3645  {
     3646    Int refIdxL1  = cMvFieldL1.getRefIdx();
     3647    if(getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->isILR(m_layerId))
     3648    {
     3649      checkZeroMVILR &= (cMvFieldL1.getHor() == 0 && cMvFieldL1.getVer() == 0);
     3650    }
     3651  }
     3652
     3653  return checkZeroMVILR;
     3654}
     3655
     3656Bool TComDataCU::xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx)
     3657{
     3658  RefPicList eRefPicList = iRefList > 0? REF_PIC_LIST_1: REF_PIC_LIST_0;
     3659  assert(eRefPicList == REF_PIC_LIST_1);
     3660
     3661  Bool checkZeroMVILR = true;
     3662
     3663  if(getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR(m_layerId))
     3664  {
     3665    AMVPInfo* pcAMVPInfo = getCUMvField(eRefPicList)->getAMVPInfo();
     3666    TComMv    cMv        = pcAMVPInfo->m_acMvCand[MvpIdx];
     3667    checkZeroMVILR &= (cMv.getHor() == 0 && cMv.getVer() == 0);
     3668  }
     3669
     3670  return checkZeroMVILR;
     3671}
     3672#endif
     3673
     3674#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     3675Bool TComDataCU::isInterLayerReference(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1)
     3676{
     3677  Bool checkILR = false;
     3678
     3679  if(uhInterDir&0x1)  //list0
     3680  {
     3681    Int refIdxL0 = cMvFieldL0.getRefIdx();
     3682    checkILR = getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->isILR(m_layerId);
     3683  }
     3684  if(uhInterDir&0x2)  //list1
     3685  {
     3686    Int refIdxL1  = cMvFieldL1.getRefIdx();
     3687    checkILR = checkILR || getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->isILR(m_layerId);
     3688  }
     3689
     3690  return checkILR;
     3691}
     3692#endif
     3693
    36823694#endif //SVC_EXTENSION
    36833695//! \}
  • trunk/source/Lib/TLibCommon/TComDataCU.h

    r595 r713  
    352352 
    353353  Void          getPartIndexAndSize   ( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight );
    354   UChar         getNumPartInter       ();
     354  UChar         getNumPartitions       ();
    355355  Bool          isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth);
    356356 
  • trunk/source/Lib/TLibCommon/TComMotionInfo.h

    r595 r713  
    141141  Void    setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
    142142
    143 #if AVC_SYNTAX
    144   Void           setMv    (TComMv cMv,  Int iIdx )         { m_pcMv    [iIdx] = cMv; }
    145   Void           setRefIdx(Int iRefIdx, Int iIdx   )       { m_piRefIdx[iIdx] =  iRefIdx; }
    146 #endif
    147 
    148143  Void setNumPartition( Int iNumPart )
    149144  {
     
    159154 
    160155  Void compress(Char* pePredMode, Int scale);
     156
     157#if AVC_SYNTAX
     158  Void           setMv    (TComMv cMv,  Int iIdx )         { m_pcMv    [iIdx] = cMv; }
     159  Void           setRefIdx(Int iRefIdx, Int iIdx   )       { m_piRefIdx[iIdx] =  iRefIdx; }
     160#endif
    161161
    162162#if REF_IDX_MFM
  • trunk/source/Lib/TLibCommon/TComPic.h

    r595 r713  
    8989  TComPicYuv*           m_pcFullPelBaseRec[MAX_LAYERS];    // upsampled base layer recontruction for difference domain inter prediction
    9090#endif
     91#if Q0048_CGS_3D_ASYMLUT
     92  Int                   m_nFrameBit;
     93#endif
    9194
    9295public:
     
    115118  UInt          getTLayer()                { return m_uiTLayer;   }
    116119  Void          setTLayer( UInt uiTLayer ) { m_uiTLayer = uiTLayer; }
     120
    117121  Bool          getUsedByCurr()             { return m_bUsedByCurr; }
    118122  Void          setUsedByCurr( Bool bUsed ) { m_bUsedByCurr = bUsed; }
     
    219223#endif
    220224
     225#if Q0048_CGS_3D_ASYMLUT
     226  Void  setFrameBit( Int n )  { m_nFrameBit = n;    }
     227  Int   getFrameBit()         { return m_nFrameBit; }
     228#endif
    221229};// END CLASS DEFINITION TComPic
    222230
  • trunk/source/Lib/TLibCommon/TComPicYuv.cpp

    r595 r713  
    174174  Int numCuInHeight = m_iPicHeight / m_iCuHeight + (m_iPicHeight % m_iCuHeight != 0);
    175175 
     176#if LAYER_CTB
     177  m_iLumaMarginX    = uiMaxCUWidth  + 16; // for 16-byte alignment
     178  m_iLumaMarginY    = uiMaxCUHeight + 16;  // margin for 8-tap filter and infinite padding
     179#else
    176180  m_iLumaMarginX    = g_uiMaxCUWidth  + 16; // for 16-byte alignment
    177181  m_iLumaMarginY    = g_uiMaxCUHeight + 16;  // margin for 8-tap filter and infinite padding
     182#endif
    178183 
    179184  m_apiPicBufY      = (Pel*)xMalloc( Pel, ( m_iPicWidth       + (m_iLumaMarginX  <<1)) * ( m_iPicHeight       + (m_iLumaMarginY  <<1)));
  • trunk/source/Lib/TLibCommon/TComPrediction.cpp

    r644 r713  
    447447  }
    448448
    449   for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartInter(); iPartIdx++ )
     449  for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartitions(); iPartIdx++ )
    450450  {
    451451    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
     
    768768#if O0215_PHASE_ALIGNMENT
    769769#if O0194_JOINT_US_BITSHIFT
    770 Void TComPrediction::upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window, Bool phaseAlignFlag )
    771 {
    772   m_cUsf.upsampleBasePic( currSlice, refLayerIdc, pcUsPic, pcBasePic, pcTempPic, window, phaseAlignFlag );
     770Void TComPrediction::upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, Bool phaseAlignFlag )
     771{
     772  m_cUsf.upsampleBasePic( currSlice, refLayerIdc, pcUsPic, pcBasePic, pcTempPic, phaseAlignFlag );
    773773}
    774774#else
  • trunk/source/Lib/TLibCommon/TComPrediction.h

    r644 r713  
    121121#if O0215_PHASE_ALIGNMENT
    122122#if O0194_JOINT_US_BITSHIFT
    123   Void upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window, Bool phaseAlignFlag );
     123  Void upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, Bool phaseAlignFlag );
    124124#else
    125125  Void upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window, Bool phaseAlignFlag );
  • trunk/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp

    r644 r713  
    112112    m_offsetClipTable[compIdx] = NULL;
    113113  }
     114#if !SAO_SGN_FUNC
    114115  m_signTable = NULL;
    115 
     116#endif
    116117 
    117118  m_lineBufWidth = 0;
     
    169170  }
    170171
     172#if !SAO_SGN_FUNC
    171173  //look-up table for clipping
     174  Int overallMaxSampleValue=0;
     175#endif
    172176  for(Int compIdx =0; compIdx < NUM_SAO_COMPONENTS; compIdx++)
    173177  {
     
    179183    Int maxOffsetValue = (g_saoMaxOffsetQVal[compIdx] << m_offsetStepLog2[compIdx]);
    180184#endif
     185#if !SAO_SGN_FUNC
     186    if (maxSampleValue>overallMaxSampleValue) overallMaxSampleValue=maxSampleValue;
     187#endif
    181188
    182189    m_offsetClipTable[compIdx] = new Int[(maxSampleValue + maxOffsetValue -1)+ (maxOffsetValue)+1 ]; //positive & negative range plus 0
     
    194201      *(offsetClipPtr -k -1 )              = 0;
    195202    }
    196     if(compIdx == SAO_Y) //g_bitDepthY is always larger than or equal to g_bitDepthC
    197     {
    198       m_signTable = new Short[ 2*(maxSampleValue-1) + 1 ];
    199       m_sign = &(m_signTable[maxSampleValue-1]);
    200 
    201       m_sign[0] = 0;
    202       for(Int k=1; k< maxSampleValue; k++)
    203       {
    204         m_sign[k] = 1;
    205         m_sign[-k]= -1;
    206       }
    207     }
    208   } 
    209 
     203  }
     204
     205#if !SAO_SGN_FUNC
     206  m_signTable = new Short[ 2*(overallMaxSampleValue-1) + 1 ];
     207  m_sign = &(m_signTable[overallMaxSampleValue-1]);
     208
     209  m_sign[0] = 0;
     210  for(Int k=1; k< overallMaxSampleValue; k++)
     211  {
     212    m_sign[k] = 1;
     213    m_sign[-k]= -1;
     214  }
     215#endif
    210216}
    211217
     
    226232    }
    227233  }
     234#if !SAO_SGN_FUNC
    228235  if( m_signTable )
    229236  {
    230237    delete[] m_signTable; m_signTable = NULL;
    231238  }
     239#endif
    232240}
    233241
     
    406414      for (y=0; y< height; y++)
    407415      {
     416#if SAO_SGN_FUNC
     417        signLeft = (Char)sgn(srcLine[startX] - srcLine[startX-1]);
     418#else
    408419        signLeft = (Char)m_sign[srcLine[startX] - srcLine[startX-1]];
     420#endif
    409421        for (x=startX; x< endX; x++)
    410422        {
     423#if SAO_SGN_FUNC
     424          signRight = (Char)sgn(srcLine[x] - srcLine[x+1]);
     425#else
    411426          signRight = (Char)m_sign[srcLine[x] - srcLine[x+1]];
     427#endif
    412428          edgeType =  signRight + signLeft;
    413429          signLeft  = -signRight;
     
    437453      for (x=0; x< width; x++)
    438454      {
     455#if SAO_SGN_FUNC
     456        signUpLine[x] = (Char)sgn(srcLine[x] - srcLineAbove[x]);
     457#else
    439458        signUpLine[x] = (Char)m_sign[srcLine[x] - srcLineAbove[x]];
     459#endif
    440460      }
    441461
     
    447467        for (x=0; x< width; x++)
    448468        {
     469#if SAO_SGN_FUNC
     470          signDown  = (Char)sgn(srcLine[x] - srcLineBelow[x]);
     471#else
    449472          signDown  = (Char)m_sign[srcLine[x] - srcLineBelow[x]];
     473#endif
    450474          edgeType = signDown + signUpLine[x];
    451475          signUpLine[x]= -signDown;
     
    474498      for (x=startX; x< endX+1; x++)
    475499      {
     500#if SAO_SGN_FUNC
     501        signUpLine[x] = (Char)sgn(srcLineBelow[x] - srcLine[x- 1]);
     502#else
    476503        signUpLine[x] = (Char)m_sign[srcLineBelow[x] - srcLine[x- 1]];
     504#endif
    477505      }
    478506
     
    483511      for(x= firstLineStartX; x< firstLineEndX; x++)
    484512      {
     513#if SAO_SGN_FUNC
     514        edgeType  =  sgn(srcLine[x] - srcLineAbove[x- 1]) - signUpLine[x+1];
     515#else
    485516        edgeType  =  m_sign[srcLine[x] - srcLineAbove[x- 1]] - signUpLine[x+1];
     517#endif
    486518        resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
    487519      }
     
    497529        for (x=startX; x<endX; x++)
    498530        {
     531#if SAO_SGN_FUNC
     532          signDown =  (Char)sgn(srcLine[x] - srcLineBelow[x+ 1]);
     533#else
    499534          signDown =  (Char)m_sign[srcLine[x] - srcLineBelow[x+ 1]] ;
     535#endif
    500536          edgeType =  signDown + signUpLine[x];
    501537          resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
     
    503539          signDownLine[x+1] = -signDown;
    504540        }
     541#if SAO_SGN_FUNC
     542        signDownLine[startX] = (Char)sgn(srcLineBelow[startX] - srcLine[startX-1]);
     543#else
    505544        signDownLine[startX] = (Char)m_sign[srcLineBelow[startX] - srcLine[startX-1]];
     545#endif
    506546
    507547        signTmpLine  = signUpLine;
     
    519559      for(x= lastLineStartX; x< lastLineEndX; x++)
    520560      {
     561#if SAO_SGN_FUNC
     562        edgeType =  sgn(srcLine[x] - srcLineBelow[x+ 1]) + signUpLine[x];
     563#else
    521564        edgeType =  m_sign[srcLine[x] - srcLineBelow[x+ 1]] + signUpLine[x];
     565#endif
    522566        resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
    523567
     
    537581      for (x=startX-1; x< endX; x++)
    538582      {
     583#if SAO_SGN_FUNC
     584        signUpLine[x] = (Char)sgn(srcLineBelow[x] - srcLine[x+1]);
     585#else
    539586        signUpLine[x] = (Char)m_sign[srcLineBelow[x] - srcLine[x+1]];
     587#endif
    540588      }
    541589
     
    547595      for(x= firstLineStartX; x< firstLineEndX; x++)
    548596      {
     597#if SAO_SGN_FUNC
     598        edgeType = sgn(srcLine[x] - srcLineAbove[x+1]) -signUpLine[x-1];
     599#else
    549600        edgeType = m_sign[srcLine[x] - srcLineAbove[x+1]] -signUpLine[x-1];
     601#endif
    550602        resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
    551603      }
     
    560612        for(x= startX; x< endX; x++)
    561613        {
     614#if SAO_SGN_FUNC
     615          signDown =  (Char)sgn(srcLine[x] - srcLineBelow[x-1]);
     616#else
    562617          signDown =  (Char)m_sign[srcLine[x] - srcLineBelow[x-1]] ;
     618#endif
    563619          edgeType =  signDown + signUpLine[x];
    564620          resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
    565621          signUpLine[x-1] = -signDown;
    566622        }
     623#if SAO_SGN_FUNC
     624        signUpLine[endX-1] = (Char)sgn(srcLineBelow[endX-1] - srcLine[endX]);
     625#else
    567626        signUpLine[endX-1] = (Char)m_sign[srcLineBelow[endX-1] - srcLine[endX]];
     627#endif
    568628        srcLine  += srcStride;
    569629        resLine += resStride;
     
    576636      for(x= lastLineStartX; x< lastLineEndX; x++)
    577637      {
     638#if SAO_SGN_FUNC
     639        edgeType = sgn(srcLine[x] - srcLineBelow[x-1]) + signUpLine[x];
     640#else
    578641        edgeType = m_sign[srcLine[x] - srcLineBelow[x-1]] + signUpLine[x];
     642#endif
    579643        resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
    580644
  • trunk/source/Lib/TLibCommon/TComSampleAdaptiveOffset.h

    r644 r713  
    5656extern UInt g_saoMaxOffsetQVal[NUM_SAO_COMPONENTS];
    5757#endif
     58#if SAO_SGN_FUNC
     59template <typename T> int sgn(T val)
     60{
     61  return (T(0) < val) - (val < T(0));
     62}
     63#endif
    5864
    5965class TComSampleAdaptiveOffset
     
    8894  UInt m_offsetStepLog2[NUM_SAO_COMPONENTS]; //offset step 
    8995  Int* m_offsetClip[NUM_SAO_COMPONENTS]; //clip table for fast operation
     96#if !SAO_SGN_FUNC
    9097  Short* m_sign; //sign table for fast operation
     98#endif
    9199  TComPicYuv*   m_tempPicYuv; //temporary buffer
    92100  Int m_picWidth;
     
    105113  Bool m_picSAOEnabled[NUM_SAO_COMPONENTS];
    106114  Int*   m_offsetClipTable[NUM_SAO_COMPONENTS];
     115#if !SAO_SGN_FUNC
    107116  Short* m_signTable;
     117#endif
    108118#if SVC_EXTENSION
    109119  UInt m_saoMaxOffsetQVal[NUM_SAO_COMPONENTS];
  • trunk/source/Lib/TLibCommon/TComSlice.cpp

    r644 r713  
    7575, m_pcPic                         ( NULL )
    7676, m_colFromL0Flag                 ( 1 )
     77#if SETTING_NO_OUT_PIC_PRIOR
     78, m_noOutputPriorPicsFlag         ( false )
     79, m_noRaslOutputFlag              ( false )
     80, m_handleCraAsBlaFlag            ( false )
     81#endif
    7782, m_colRefIdx                     ( 0 )
    7883, m_uiTLayer                      ( 0 )
     
    111116, m_bCrossLayerBLAFlag            ( false )
    112117#endif
    113 #if NO_OUTPUT_OF_PRIOR_PICS
    114 , m_noOutputOfPriorPicsFlag       ( false )
    115 , m_noRaslOutputFlag              ( false )
    116 , m_handleCraAsBlaFlag            ( false )
    117 #endif
    118118#if POC_RESET_IDC_SIGNALLING
    119119, m_pocResetIdc                   ( 0 )
     
    536536      {
    537537        UInt refLayerIdc = m_interLayerPredLayerIdc[i];
     538        UInt refLayerId = m_pcVPS->getRefLayerId( m_layerId, refLayerIdc );
    538539#if RESAMPLING_CONSTRAINT_BUG_FIX
    539540#if O0098_SCALED_REF_LAYER_ID
    540         const Window &scalEL = getSPS()->getScaledRefLayerWindowForLayer(m_pcVPS->getRefLayerId( m_layerId, m_interLayerPredLayerIdc[i] ));
     541        const Window &scalEL = getSPS()->getScaledRefLayerWindowForLayer(refLayerId);
    541542#else
    542543        const Window &scalEL = getSPS()->getScaledRefLayerWindow(m_interLayerPredLayerIdc[i]);
     
    548549                            );
    549550#endif
     551#if O0194_DIFFERENT_BITDEPTH_EL_BL
     552        Int sameBitDepth = g_bitDepthYLayer[m_layerId] - g_bitDepthYLayer[refLayerId] + g_bitDepthCLayer[m_layerId] - g_bitDepthCLayer[refLayerId];
     553
     554        if( !( g_posScalingFactor[refLayerIdc][0] == 65536 && g_posScalingFactor[refLayerIdc][1] == 65536 ) || !scalingOffset || !sameBitDepth
     555#if Q0048_CGS_3D_ASYMLUT
     556          || getPPS()->getCGSFlag()
     557#endif
     558          ) // ratio 1x
     559#else
    550560        if(!( g_posScalingFactor[refLayerIdc][0] == 65536 && g_posScalingFactor[refLayerIdc][1] == 65536 ) || (!scalingOffset)) // ratio 1x
     561#endif
    551562        {
    552563#if MOTION_RESAMPLING_CONSTRAINT
    553           UInt predType = m_pcVPS->getDirectDependencyType( m_layerId, m_pcVPS->getRefLayerId( m_layerId, refLayerIdc ) ) + 1;
     564          UInt predType = m_pcVPS->getDirectDependencyType( m_layerId, refLayerId ) + 1;
    554565
    555566          if( predType & 0x1 )
     
    596607    // The variable NumPocTotalCurr is derived as specified in subclause 7.4.7.2. It is a requirement of bitstream conformance that the following applies to the value of NumPocTotalCurr:
    597608#if SVC_EXTENSION    // inter-layer prediction is allowed for BLA, CRA pictures of nuh_layer_id>0
    598     // If the current picture is a BLA or CRA picture with nuh_layer_id equal to 0, the value of NumPocTotalCurr shall be equal to 0.
    599     // Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
     609    // - If the current picture is a BLA or CRA picture with nuh_layer_id equal to 0, the value of NumPocTotalCurr shall be equal to 0.
     610    // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
    600611    if (getRapPicFlag() && getLayerId()==0)
    601612#else
    602     // If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
    603     // Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
     613    // - If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
     614    // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
    604615    if (getRapPicFlag())
    605616#endif
     
    10081019 */
    10091020#if NO_CLRAS_OUTPUT_FLAG
     1021Void TComSlice::decodingRefreshMarking( TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag )
     1022{
     1023  if( !isIRAP() )
     1024  {
     1025    return;
     1026  }
     1027
     1028  Int pocCurr = getPOC();
     1029  TComPic* rpcPic = NULL;
     1030
     1031  // When the current picture is an IRAP picture with nuh_layer_id equal to 0 and NoClrasOutputFlag is equal to 1,
     1032  // all reference pictures with any value of nuh_layer_id currently in the DPB (if any) are marked as "unused for reference".
     1033  if( m_layerId == 0 && noClrasOutputFlag )
     1034  {
     1035    // mark all pictures for all layers as not used for reference
     1036    TComList<TComPic*>::iterator iterPic = rcListPic.begin();
     1037    while( iterPic != rcListPic.end() )
     1038    {
     1039      rpcPic = *(iterPic);
     1040      if( rpcPic->getPOC() != pocCurr )
     1041      {
     1042        rpcPic->getSlice(0)->setReferenced(false);
     1043      }
     1044      iterPic++;
     1045    }
     1046  }
     1047
     1048  // When the current picture is an IRAP picture with NoRaslOutputFlag equal to 1,
     1049  // all reference pictures with nuh_layer_id equal to currPicLayerId currently in the DPB (if any) are marked as "unused for reference".
     1050  if( m_noRaslOutputFlag )
     1051  {
     1052    // mark all pictures of a current layer as not used for reference
     1053    TComList<TComPic*>::iterator iterPic = rcListPic.begin();
     1054    while( iterPic != rcListPic.end() )
     1055    {
     1056      rpcPic = *(iterPic);
     1057      if( rpcPic->getPOC() != pocCurr && rpcPic->getLayerId() == m_layerId )
     1058      {
     1059        rpcPic->getSlice(0)->setReferenced(false);
     1060      }
     1061      iterPic++;
     1062    }
     1063  }
     1064}
     1065
    10101066Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag)
    10111067#else
     
    10511107      pocCRA = pocCurr;
    10521108    }
     1109#if EFFICIENT_FIELD_IRAP
     1110    bRefreshPending = true;
     1111#endif
    10531112  }
    10541113  else // CRA or No DR
    10551114  {
     1115#if EFFICIENT_FIELD_IRAP
     1116    if(getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL)
     1117    {
     1118      if (bRefreshPending==true && pocCurr > m_iLastIDR) // IDR reference marking pending
     1119      {
     1120        TComList<TComPic*>::iterator        iterPic       = rcListPic.begin();
     1121        while (iterPic != rcListPic.end())
     1122        {
     1123          rpcPic = *(iterPic);
     1124          if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != m_iLastIDR)
     1125          {
     1126            rpcPic->getSlice(0)->setReferenced(false);
     1127          }
     1128          iterPic++;
     1129        }
     1130        bRefreshPending = false;
     1131      }
     1132    }
     1133    else
     1134    {
     1135#endif
    10561136    if (bRefreshPending==true && pocCurr > pocCRA) // CRA reference marking pending
    10571137    {
     
    10681148      bRefreshPending = false;
    10691149    }
     1150#if EFFICIENT_FIELD_IRAP
     1151    }
     1152#endif
    10701153    if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found
    10711154    {
     
    13231406    // in decoding order shall precede the IRAP picture in output order.
    13241407    // (Note that any picture following in output order would be present in the DPB)
     1408#if !SETTING_NO_OUT_PIC_PRIOR
    13251409    if(rpcPic->getSlice(0)->getPicOutputFlag() == 1)
     1410#else
     1411    if(rpcPic->getSlice(0)->getPicOutputFlag() == 1 && !this->getNoOutputPriorPicsFlag())
     1412#endif
    13261413    {
    13271414      if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP    ||
     
    15021589/** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet.
    15031590*/
     1591#if ALLOW_RECOVERY_POINT_AS_RAP
     1592Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess, Bool bUseRecoveryPoint)
     1593#else
    15041594Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess)
    1505 {
     1595#endif
     1596{
     1597#if ALLOW_RECOVERY_POINT_AS_RAP
     1598  Int atLeastOneUnabledByRecoveryPoint = 0;
     1599  Int atLeastOneFlushedByPreviousIDR = 0;
     1600#endif
    15061601  TComPic* rpcPic;
    15071602  Int i, isAvailable;
     
    15241619        if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced())
    15251620        {
     1621#if ALLOW_RECOVERY_POINT_AS_RAP
     1622          if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess)
     1623          {
     1624            isAvailable = 0;
     1625          }
     1626          else
     1627          {
    15261628          isAvailable = 1;
     1629        }
     1630#else
     1631          isAvailable = 1;
     1632#endif
    15271633        }
    15281634      }
     
    15341640        if(rpcPic->getIsLongTerm() && curPoc == refPoc && rpcPic->getSlice(0)->isReferenced())
    15351641        {
     1642#if ALLOW_RECOVERY_POINT_AS_RAP
     1643          if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess)
     1644          {
     1645            isAvailable = 0;
     1646          }
     1647          else
     1648          {
    15361649          isAvailable = 1;
     1650        }
     1651#else
     1652          isAvailable = 1;
     1653#endif
    15371654        }
    15381655      }
     
    15571674        if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc)
    15581675        {
     1676#if ALLOW_RECOVERY_POINT_AS_RAP
     1677          if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess)
     1678          {
     1679            isAvailable = 0;
     1680          }
     1681          else
     1682          {
    15591683          isAvailable = 1;
    15601684          rpcPic->setIsLongTerm(1);
    15611685          break;
     1686        }
     1687#else
     1688          isAvailable = 1;
     1689          rpcPic->setIsLongTerm(1);
     1690          break;
     1691#endif
    15621692        }
    15631693      }
     
    15871717        }
    15881718      }
     1719#if ALLOW_RECOVERY_POINT_AS_RAP
     1720      else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess)
     1721      {
     1722        atLeastOneUnabledByRecoveryPoint = 1;
     1723      }
     1724      else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL))
     1725      {
     1726        atLeastOneFlushedByPreviousIDR = 1;
     1727      }
     1728#endif
    15891729    }
    15901730  } 
     
    16021742      if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced())
    16031743      {
     1744#if ALLOW_RECOVERY_POINT_AS_RAP
     1745        if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess)
     1746        {
     1747          isAvailable = 0;
     1748        }
     1749        else
     1750        {
    16041751        isAvailable = 1;
     1752      }
     1753#else
     1754        isAvailable = 1;
     1755#endif
    16051756      }
    16061757    }
     
    16291780        }
    16301781      }
    1631     }
     1782#if ALLOW_RECOVERY_POINT_AS_RAP
     1783      else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess)
     1784      {
     1785        atLeastOneUnabledByRecoveryPoint = 1;
     1786      }
     1787      else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL))
     1788      {
     1789        atLeastOneFlushedByPreviousIDR = 1;
     1790      }
     1791#endif
     1792    }
     1793    }
     1794#if ALLOW_RECOVERY_POINT_AS_RAP
     1795  if(atLeastOneUnabledByRecoveryPoint || atLeastOneFlushedByPreviousIDR)
     1796  {
     1797    return -1;
    16321798  }   
     1799#endif
    16331800  if(atLeastOneLost)
    16341801  {
     
    16471814/** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set
    16481815*/
     1816#if ALLOW_RECOVERY_POINT_AS_RAP
     1817Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess, Bool bUseRecoveryPoint)
     1818#else
    16491819Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP)
     1820#endif
    16501821{
    16511822  TComPic* rpcPic;
     
    16731844        pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i));
    16741845        pcRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP));
     1846#if ALLOW_RECOVERY_POINT_AS_RAP
     1847        pcRPS->setUsed(k, pcRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) );
     1848#endif
    16751849        if(pcRPS->getDeltaPOC(k) < 0)
    16761850        {
     
    16851859    }
    16861860  }
     1861#if EFFICIENT_FIELD_IRAP
     1862  Bool useNewRPS = false;
     1863  // if current picture is complimentary field associated to IRAP, add the IRAP to its RPS.
     1864  if(m_pcPic->isField())
     1865  {
     1866    TComList<TComPic*>::iterator iterPic = rcListPic.begin();
     1867    while ( iterPic != rcListPic.end())
     1868    {
     1869      rpcPic = *(iterPic++);
     1870      if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1)
     1871      {
     1872        pcRPS->setDeltaPOC(k, 1);
     1873        pcRPS->setUsed(k, true);
     1874        nrOfPositivePictures++;
     1875        k ++;
     1876        useNewRPS = true;
     1877      }
     1878    }
     1879  }
     1880#endif
    16871881  pcRPS->setNumberOfNegativePictures(nrOfNegativePictures);
    16881882  pcRPS->setNumberOfPositivePictures(nrOfPositivePictures);
     
    16911885  // inter RPS prediction with.  Here we just use the reference used by pReferencePictureSet.
    16921886  // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled.
    1693   if (!pReferencePictureSet->getInterRPSPrediction())
     1887  if (!pReferencePictureSet->getInterRPSPrediction()
     1888#if EFFICIENT_FIELD_IRAP
     1889    || useNewRPS
     1890#endif
     1891    )
    16941892  {
    16951893    pcRPS->setInterRPSPrediction(false);
     
    18882086  if( layerId == 0 )
    18892087  {
    1890     retVal = sps->getChromaFormatIdc();
     2088    if( vps->getAvcBaseLayerFlag() )
     2089    {
     2090      retVal = vps->getVpsRepFormat(layerId)->getChromaFormatVpsIdc();
     2091    }
     2092    else
     2093    {
     2094      retVal = sps->getChromaFormatIdc();
     2095    }
    18912096  }
    18922097  else
     
    20342239#endif
    20352240#if REPN_FORMAT_IN_VPS
     2241#if Q0195_REP_FORMAT_CLEANUP
     2242, m_repFormatIdxPresentFlag   (false)
     2243#else
    20362244, m_repFormatIdxPresentFlag   (true)
     2245#endif
    20372246, m_vpsNumRepFormats          (1)
    20382247#endif
     
    23062515Void TComVPS::setRefLayersFlags(Int currLayerId)
    23072516{
    2308   for (Int i = 0; i < getNumDirectRefLayers(currLayerId); i++)
     2517  for (Int i = 0; i < m_numDirectRefLayers[currLayerId]; i++)
    23092518  {
    23102519    UInt refLayerId = getRefLayerId(currLayerId, i);
    2311     setRecursiveRefLayerFlag(currLayerId, refLayerId, true);
     2520    m_recursiveRefLayerFlag[currLayerId][refLayerId] = true;
    23122521    for (Int k = 0; k < MAX_NUM_LAYER_IDS; k++)
    23132522    {
    2314       setRecursiveRefLayerFlag(currLayerId, k, (getRecursiveRefLayerFlag(currLayerId, k) | getRecursiveRefLayerFlag(refLayerId, k)));
     2523      m_recursiveRefLayerFlag[currLayerId][k] = m_recursiveRefLayerFlag[currLayerId][k] | m_recursiveRefLayerFlag[refLayerId][k];
    23152524    }
    23162525  }
     
    23192528Void TComVPS::setNumRefLayers(Int currLayerId)
    23202529{
    2321   for (Int i = 0; i <= getMaxLayers(); i++)
    2322   {
    2323     UInt iNuhLId = getLayerIdInNuh(i);
     2530  for (Int i = 0; i < m_uiMaxLayers; i++)
     2531  {
     2532    UInt iNuhLId = m_layerIdInNuh[i];
    23242533    setRefLayersFlags(iNuhLId);
    23252534    for (UInt j = 0; j < MAX_NUM_LAYER_IDS; j++)
    23262535    {
    2327       m_numberRefLayers[iNuhLId] += (getRecursiveRefLayerFlag(iNuhLId, j) == true ? 1 : 0);
     2536      m_numberRefLayers[iNuhLId] += (m_recursiveRefLayerFlag[iNuhLId][j] == true ? 1 : 0);
    23282537    }
    23292538  }
     
    35263735
    35273736    TComPic* pcRefPicBL = pcRefPicRL[refLayerIdc];
     3737
    35283738    //set reference picture POC of each ILP reference
    35293739    Int thePoc = ilpPic[refLayerIdc]->getPOC();
     
    35323742    ilpPic[refLayerIdc]->getSlice(0)->setBaseColPic( refLayerIdc, pcRefPicBL );
    35333743
    3534     //copy reference pictures marking from the reference layer
    3535     ilpPic[refLayerIdc]->getSlice(0)->copySliceInfo(pcRefPicBL->getSlice(0));
     3744    //copy layer id from the reference layer   
     3745    ilpPic[refLayerIdc]->setLayerId( pcRefPicBL->getLayerId() );
     3746
     3747    //copy slice type from the reference layer
     3748    ilpPic[refLayerIdc]->getSlice(0)->setSliceType( pcRefPicBL->getSlice(0)->getSliceType() );
     3749
     3750    //copy "used for reference"
     3751    ilpPic[refLayerIdc]->getSlice(0)->setReferenced( pcRefPicBL->getSlice(0)->isReferenced() );
    35363752
    35373753    for( Int refList = 0; refList < 2; refList++ )
     
    35553771        ilpPic[refLayerIdc]->getSlice(0)->setRefPOC(0, refPicList, refIdx);
    35563772        ilpPic[refLayerIdc]->getSlice(0)->setRefPic(NULL, refPicList, refIdx);
     3773      }
     3774
     3775      //copy reference pictures' marking from the reference layer
     3776      for(Int j = 0; j < MAX_NUM_REF + 1; j++)
     3777      {
     3778        ilpPic[refLayerIdc]->getSlice(0)->setIsUsedAsLongTerm(refList, j, pcRefPicBL->getSlice(0)->getIsUsedAsLongTerm(refList, j));
    35573779      }
    35583780    }
  • trunk/source/Lib/TLibCommon/TComSlice.h

    r644 r713  
    231231{
    232232  ProfileTierLevel m_generalPTL;
    233   ProfileTierLevel m_subLayerPTL    [MAX_TLAYER-1];      // max. value of max_sub_layers_minus1 is MAX_TLAYER-1 ( = 6 )
     233  ProfileTierLevel m_subLayerPTL    [MAX_TLAYER-1];      // max. value of max_sub_layers_minus1 is MAX_TLAYER-1 (= 6)
    234234  Bool m_subLayerProfilePresentFlag [MAX_TLAYER-1];
    235235  Bool m_subLayerLevelPresentFlag   [MAX_TLAYER-1];
     
    581581#if VPS_TSLAYERS
    582582  Bool       m_maxTSLayersPresentFlag;
    583   UInt       m_maxTSLayerMinus1[MAX_VPS_LAYER_ID_PLUS1 - 1];
     583  UInt       m_maxTSLayerMinus1[MAX_LAYERS];
    584584#endif
    585585#if M0040_ADAPTIVE_RESOLUTION_CHANGE
     
    684684  Bool       m_vpsVuiPresentFlag;
    685685#endif
     686  Bool       m_vpsExtensionFlag;
    686687
    687688#if O0164_MULTI_LAYER_HRD
     
    11311132
    11321133#if O0109_MOVE_VPS_VUI_FLAG
    1133   Bool   getVpsVuiPresentFlag()                                 { return m_vpsVuiPresentFlag; }
    1134   Void   setVpsVuiPresentFlag(Bool x)                           { m_vpsVuiPresentFlag = x; }
    1135 #endif
     1134  Bool   getVpsVuiPresentFlag()                        { return m_vpsVuiPresentFlag; }
     1135  Void   setVpsVuiPresentFlag(Bool x)                  { m_vpsVuiPresentFlag = x;    }
     1136#endif
     1137  Bool   getVpsExtensionFlag()                         { return m_vpsExtensionFlag;  }
     1138  Void   setVpsExtensionFlag(Bool x)                   { m_vpsExtensionFlag = x;     }
    11361139
    11371140#if !P0307_REMOVE_VPS_VUI_OFFSET
     
    17411744  Bool     m_pocResetInfoPresentFlag;
    17421745#endif
     1746#if Q0048_CGS_3D_ASYMLUT
     1747  Int      m_nCGSFlag;
     1748  Int      m_nCGSOutputBitDepthY; // not for syntax
     1749  Int      m_nCGSOutputBitDepthC; // not for syntax
     1750#endif
    17431751#endif
    17441752
     
    18811889  Bool getPocResetInfoPresentFlag   ()                    { return m_pocResetInfoPresentFlag; }
    18821890  Void setPocResetInfoPresentFlag   (const Bool val)      { m_pocResetInfoPresentFlag = val; }
     1891#endif
     1892#if Q0048_CGS_3D_ASYMLUT
     1893  Int     getCGSFlag()                { return m_nCGSFlag;  }
     1894  Void    setCGSFlag(Int n)           { m_nCGSFlag = n;     }
     1895  Int     getCGSOutputBitDepthY()     { return m_nCGSOutputBitDepthY;  }
     1896  Void    setCGSOutputBitDepthY(Int n){ m_nCGSOutputBitDepthY = n;     }
     1897  Int     getCGSOutputBitDepthC()     { return m_nCGSOutputBitDepthC;  }
     1898  Void    setCGSOutputBitDepthC(Int n){ m_nCGSOutputBitDepthC = n;     }
    18831899#endif
    18841900};
     
    19631979  UInt        m_colFromL0Flag;  // collocated picture from List0 flag
    19641980 
     1981#if SETTING_NO_OUT_PIC_PRIOR
     1982  Bool        m_noOutputPriorPicsFlag;
     1983  Bool        m_noRaslOutputFlag;
     1984  Bool        m_handleCraAsBlaFlag;
     1985#endif
     1986 
    19651987  UInt        m_colRefIdx;
    19661988  UInt        m_maxNumMergeCand;
     
    20302052  Bool        m_bCrossLayerBLAFlag;
    20312053#endif
    2032 #if NO_OUTPUT_OF_PRIOR_PICS
    2033   Bool        m_noOutputOfPriorPicsFlag;
    2034   Bool        m_noRaslOutputFlag;
    2035   Bool        m_handleCraAsBlaFlag;
    2036 #endif
    20372054#if POC_RESET_IDC_SIGNALLING
    20382055  Int         m_pocResetIdc;
     
    20432060  Bool        m_pocMsbValRequiredFlag;
    20442061  Bool        m_pocMsbValPresentFlag;
     2062#endif
     2063#if Q0048_CGS_3D_ASYMLUT
     2064  Int        m_nCGSOverWritePPS;  // for optimization, not output to bitstream
    20452065#endif
    20462066#endif //SVC_EXTENSION
     
    21302150  NalUnitType getNalUnitType    () const                        { return m_eNalUnitType;        }
    21312151  Bool      getRapPicFlag       (); 
    2132 #if NO_OUTPUT_OF_PRIOR_PICS
    2133   Bool      getBlaPicFlag       ();
    2134   Bool      getCraPicFlag       ();
    2135 #endif
    21362152  Bool      getIdrPicFlag       ()                              { return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP; }
    21372153  Bool      isIRAP              () const                        { return (getNalUnitType() >= 16) && (getNalUnitType() <= 23); } 
    21382154  Void      checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic);
    21392155#if NO_CLRAS_OUTPUT_FLAG
     2156  Void      decodingRefreshMarking( TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag );
    21402157  Void      decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag);
    21412158#else
     
    21632180#if SVC_EXTENSION
    21642181  Void      setRefPicList       ( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr = false, TComPic** ilpPic = NULL );
     2182#if Q0048_CGS_3D_ASYMLUT
     2183  Int       getCGSOverWritePPS()              { return m_nCGSOverWritePPS;    }
     2184  Void      setCGSOverWritePPS(Int n)         { m_nCGSOverWritePPS = n;       }
     2185#endif
    21652186#else
    21662187  Void      setRefPicList       ( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr = false );
     
    22032224  Bool isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic );
    22042225  Bool isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic );
    2205   Int       checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess = 0);
    2206   Void      createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP);
     2226#if ALLOW_RECOVERY_POINT_AS_RAP
     2227  Int  checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess = 0, Bool bUseRecoveryPoint = false);
     2228  Void createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess = 0, Bool bUseRecoveryPoint = false);
     2229#else
     2230  Int  checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess = 0);
     2231  Void createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP);
     2232#endif
    22072233
    22082234  Void setMaxNumMergeCand               (UInt val )         { m_maxNumMergeCand = val;                    }
    22092235  UInt getMaxNumMergeCand               ()                  { return m_maxNumMergeCand;                   }
     2236
     2237#if SETTING_NO_OUT_PIC_PRIOR
     2238  Void setNoOutputPriorPicsFlag         ( Bool val )        { m_noOutputPriorPicsFlag = val;                    }
     2239  Bool getNoOutputPriorPicsFlag         ()                  { return m_noOutputPriorPicsFlag;                   }
     2240
     2241  Void setNoRaslOutputFlag              ( Bool val )        { m_noRaslOutputFlag = val;                    }
     2242  Bool getNoRaslOutputFlag              ()                  { return m_noRaslOutputFlag;                   }
     2243
     2244  Void setHandleCraAsBlaFlag            ( Bool val )        { m_handleCraAsBlaFlag = val;                    }
     2245  Bool getHandleCraAsBlaFlag            ()                  { return m_handleCraAsBlaFlag;                   }
     2246#endif
    22102247
    22112248  Void setSliceMode                     ( UInt uiMode )     { m_sliceMode = uiMode;                     }
     
    23602397
    23612398  Void setILRPic(TComPic **pcIlpPic);
    2362 #if NO_OUTPUT_OF_PRIOR_PICS
    2363   Void setNoOutputOfPriorPicsFlag(const Bool x)   { m_noOutputOfPriorPicsFlag = x;    }
    2364   Bool getNoOutputOfPriorPicsFlag()               { return m_noOutputOfPriorPicsFlag; }
    2365 
    2366   Void setNoRaslOutputFlag    ( const Bool val )   { m_noRaslOutputFlag = val;  }
    2367   Bool getNoRaslOutputFlag    ()                   { return m_noRaslOutputFlag; }
    2368 
    2369   Void setHandleCraAsBlaFlag  ( const Bool val )   { m_handleCraAsBlaFlag = val;  }
    2370   Bool getHandleCraAsBlaFlag  ()                   { return m_handleCraAsBlaFlag; }
    2371 
    2372 #endif
    23732399#if POC_RESET_IDC_SIGNALLING
    23742400  Int       getPocResetIdc       ()                              { return m_pocResetIdc;       }
     
    23882414#endif
    23892415
     2416#if NO_OUTPUT_OF_PRIOR_PICS
     2417  Bool      getBlaPicFlag       ();
     2418  Bool      getCraPicFlag       ();
     2419#endif
     2420
    23902421#endif //SVC_EXTENSION
    23912422protected:
  • trunk/source/Lib/TLibCommon/TComUpsampleFilter.cpp

    r644 r713  
    9999#if O0215_PHASE_ALIGNMENT
    100100#if O0194_JOINT_US_BITSHIFT
    101 Void TComUpsampleFilter::upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window, bool phaseAlignFlag )
    102 #else
    103 Void TComUpsampleFilter::upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window, bool phaseAlignFlag )
     101Void TComUpsampleFilter::upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, Bool phaseAlignFlag )
     102#else
     103Void TComUpsampleFilter::upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window, Bool phaseAlignFlag )
    104104#endif
    105105#else
     
    116116  Int i, j;
    117117
     118#if O0194_JOINT_US_BITSHIFT
     119  UInt currLayerId = currSlice->getLayerId();
     120  UInt refLayerId  = currSlice->getVPS()->getRefLayerId( currLayerId, refLayerIdc );
     121#endif
     122
     123#if O0098_SCALED_REF_LAYER_ID
     124  const Window &scalEL = currSlice->getSPS()->getScaledRefLayerWindowForLayer(refLayerId);
     125#else
     126  const Window &scalEL = currSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc);
     127#endif
     128
    118129  //========== Y component upsampling ===========
    119   const Window &scalEL = window;
    120 
    121130  Int widthBL   = pcBasePic->getWidth ();
    122131  Int heightBL  = pcBasePic->getHeight();
     
    127136  Int strideEL  = pcUsPic->getStride();
    128137
     138#if Q0200_CONFORMANCE_BL_SIZE
     139  Int chromaFormatIdc = currSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getChromaFormatIdc();
     140  const Window &confBL = currSlice->getBaseColPic(refLayerIdc)->getConformanceWindow();
     141  Int xScal = TComSPS::getWinUnitX( chromaFormatIdc );
     142  Int yScal = TComSPS::getWinUnitY( chromaFormatIdc );
     143#endif
    129144#if P0312_VERT_PHASE_ADJ
    130145  Bool vertPhasePositionEnableFlag = scalEL.getVertPhasePositionEnableFlag();
     
    159174  Int scaleY = g_posScalingFactor[refLayerIdc][1];
    160175
    161 #if O0194_JOINT_US_BITSHIFT
    162   UInt currLayerId = currSlice->getLayerId();
    163   UInt refLayerId  = currSlice->getVPS()->getRefLayerId( currLayerId, refLayerIdc );
    164 #endif
    165 
    166176  // non-normative software optimization for certain simple resampling cases
    167177  if( scaleX == 65536 && scaleY == 65536 ) // ratio 1x
     
    172182#if O0194_JOINT_US_BITSHIFT
    173183    Int shift = g_bitDepthYLayer[currLayerId] - g_bitDepthYLayer[refLayerId];
     184#if Q0048_CGS_3D_ASYMLUT
     185    if( currSlice->getPPS()->getCGSFlag() )
     186    {
     187      shift = g_bitDepthYLayer[currLayerId] - currSlice->getPPS()->getCGSOutputBitDepthY();
     188    }
     189    assert( shift >= 0 );
     190#endif
    174191#endif
    175192
     
    205222#if O0194_JOINT_US_BITSHIFT
    206223    shift = g_bitDepthCLayer[currLayerId] - g_bitDepthCLayer[refLayerId];
     224#if Q0048_CGS_3D_ASYMLUT
     225    if( currSlice->getPPS()->getCGSFlag() )
     226    {
     227      shift = g_bitDepthCLayer[currLayerId] - currSlice->getPPS()->getCGSOutputBitDepthC();
     228    }
     229#endif
    207230#endif
    208231
     
    254277    Int   phaseX = 2*phaseAlignFlag;
    255278#if P0312_VERT_PHASE_ADJ
     279#if Q0120_PHASE_CALCULATION
     280    Int   phaseY = 2*phaseAlignFlag;
     281#else
    256282    Int   phaseY = vertPhasePositionEnableFlag ? ( vertPhasePositionFlag * 4 ) : ( 2 * phaseAlignFlag );
     283#endif
    257284#else
    258285    Int   phaseY = 2*phaseAlignFlag;
     
    261288    Int   phaseX = 0;
    262289#if P0312_VERT_PHASE_ADJ
     290#if Q0120_PHASE_CALCULATION
     291    Int   phaseY = 0;
     292#else
    263293    Int   phaseY = (vertPhasePositionEnableFlag?(vertPhasePositionFlag *4):(0));
     294#endif
    264295#else
    265296    Int   phaseY = 0;
    266297#endif
    267298#endif
    268 
     299 
    269300#if ROUNDING_OFFSET
    270301    Int   addX = ( ( phaseX * scaleX + 2 ) >> 2 ) + ( 1 << ( shiftX - 5 ) );
    271302    Int   addY = ( ( phaseY * scaleY + 2 ) >> 2 ) + ( 1 << ( shiftY - 5 ) );
    272303#else
    273     Int   addX       = ( ( ( widthBL * phaseX ) << ( shiftX - 2 ) ) + ( widthEL >> 1 ) ) / widthEL + ( 1 << ( shiftX - 5 ) );
    274     Int   addY       = ( ( ( heightBL * phaseY ) << ( shiftY - 2 ) ) + ( heightEL >> 1 ) ) / heightEL+ ( 1 << ( shiftY - 5 ) );
    275 #endif
    276 
    277     Int   deltaX     = 4 * phaseX;
    278     Int   deltaY     = 4 * phaseY;
     304    Int   addX = ( ( ( widthBL * phaseX ) << ( shiftX - 2 ) ) + ( widthEL >> 1 ) ) / widthEL + ( 1 << ( shiftX - 5 ) );
     305    Int   addY = ( ( ( heightBL * phaseY ) << ( shiftY - 2 ) ) + ( heightEL >> 1 ) ) / heightEL+ ( 1 << ( shiftY - 5 ) );
     306#endif
     307
     308#if Q0120_PHASE_CALCULATION
     309    Int   deltaX = (Int)phaseAlignFlag <<3;
     310    Int   deltaY = (((Int)phaseAlignFlag <<3)>>(Int)vertPhasePositionEnableFlag) + ((Int)vertPhasePositionFlag<<3);
     311#else
     312    Int   deltaX = 4 * phaseX;
     313    Int   deltaY = 4 * phaseY;
     314#endif
     315
     316#if Q0200_CONFORMANCE_BL_SIZE
     317    deltaX -= ( confBL.getWindowLeftOffset() * xScal ) << 4;
     318    deltaY -= ( confBL.getWindowTopOffset() * yScal ) << 4;
     319#endif
    279320
    280321    Int shiftXM4 = shiftX - 4;
    281322    Int shiftYM4 = shiftY - 4;
    282323
    283     widthEL   = pcUsPic->getWidth ();
    284     heightEL  = pcUsPic->getHeight();
    285 
    286     widthBL   = pcBasePic->getWidth ();
    287     heightBL  = min<Int>( pcBasePic->getHeight(), heightEL );
     324    widthEL  = pcUsPic->getWidth ();
     325    heightEL = pcUsPic->getHeight();
     326
     327    widthBL  = pcBasePic->getWidth ();
     328    heightBL = min<Int>( pcBasePic->getHeight(), heightEL );
    288329
    289330    Int leftStartL = scalEL.getWindowLeftOffset();
     
    292333    Int bottomEndL = pcUsPic->getHeight() - scalEL.getWindowBottomOffset();
    293334    Int leftOffset = leftStartL > 0 ? leftStartL : 0;
    294 
    295335#if N0214_INTERMEDIATE_BUFFER_16BITS
    296336#if O0194_JOINT_US_BITSHIFT
    297337    // g_bitDepthY was set to EL bit-depth, but shift1 should be calculated using BL bit-depth
    298338    Int shift1 = g_bitDepthYLayer[refLayerId] - 8;
     339#if Q0048_CGS_3D_ASYMLUT
     340    if( currSlice->getPPS()->getCGSFlag() )
     341    {
     342      shift1 = currSlice->getPPS()->getCGSOutputBitDepthY() - 8;
     343    }
     344#endif
    299345#else
    300346    Int shift1 = g_bitDepthY - 8;
     
    380426    widthBL   = pcBasePic->getWidth ();
    381427    heightBL  = pcBasePic->getHeight();
    382 
    383428    widthEL   = pcUsPic->getWidth () - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
    384429    heightEL  = pcUsPic->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     
    400445    Int bottomEndC = (pcUsPic->getHeight() >> 1) - (scalEL.getWindowBottomOffset() >> 1);
    401446    leftOffset = leftStartC > 0 ? leftStartC : 0;
    402 
    403447    shiftX = 16;
    404448    shiftY = 16;
     
    407451    Int phaseXC = phaseAlignFlag;
    408452#if P0312_VERT_PHASE_ADJ
     453#if Q0120_PHASE_CALCULATION
     454    Int phaseYC = phaseAlignFlag + 1;
     455#else
    409456    Int phaseYC = vertPhasePositionEnableFlag ? ( vertPhasePositionFlag * 4 ) : ( phaseAlignFlag + 1 );
     457#endif
    410458#else
    411459    Int phaseYC = phaseAlignFlag + 1;
     
    414462    Int phaseXC = 0;
    415463#if P0312_VERT_PHASE_ADJ
     464#if Q0120_PHASE_CALCULATION
     465    Int phaseYC = 1;
     466#else
    416467    Int phaseYC = vertPhasePositionEnableFlag ? (vertPhasePositionFlag * 4): 1;
     468#endif
    417469#else
    418470    Int phaseYC = 1;
     
    428480#endif
    429481
     482#if Q0120_PHASE_CALCULATION
     483    deltaX     = (Int)phaseAlignFlag << 2;
     484    deltaY     = ((( (Int)phaseAlignFlag +1)<<2)>>(Int)vertPhasePositionEnableFlag)+((Int)vertPhasePositionFlag<<3);
     485#else
    430486    deltaX     = 4 * phaseXC;
    431487    deltaY     = 4 * phaseYC;
     488#endif
     489
     490#if Q0200_CONFORMANCE_BL_SIZE
     491    deltaX -= ( ( confBL.getWindowLeftOffset() * xScal ) >> 1 ) << 4;
     492    deltaY  -= ( ( confBL.getWindowTopOffset() * yScal ) >> 1 ) << 4;
     493#endif
    432494
    433495    shiftXM4 = shiftX - 4;
     
    444506    // g_bitDepthC was set to EL bit-depth, but shift1 should be calculated using BL bit-depth
    445507    shift1 = g_bitDepthCLayer[refLayerId] - 8;
     508#if Q0048_CGS_3D_ASYMLUT
     509    if( currSlice->getPPS()->getCGSFlag() )
     510    {
     511      shift1 = currSlice->getPPS()->getCGSOutputBitDepthC() - 8;
     512    }
     513#endif
    446514#else
    447515    shift1 = g_bitDepthC - 8;
  • trunk/source/Lib/TLibCommon/TComUpsampleFilter.h

    r644 r713  
    4545#if O0215_PHASE_ALIGNMENT
    4646#if O0194_JOINT_US_BITSHIFT
    47   Void upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window, Bool phaseAlignFlag );
     47  Void upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, Bool phaseAlignFlag );
    4848#else
    4949  Void upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window, Bool phaseAlignFlag );
  • trunk/source/Lib/TLibCommon/TypeDef.h

    r644 r713  
    4242
    4343#define SYNTAX_BYTES                     10      ///< number of bytes taken by syntaxes per 4x4 block [RefIdxL0(1byte), RefIdxL1(1byte), MVxL0(2bytes), MVyL0(2bytes), MVxL1(2bytes), MVyL1(2bytes)]
    44 
    4544#if SVC_EXTENSION
    4645#define MAX_LAYERS                       8      ///< max number of layers the codec is supposed to handle
     
    5049#define O0137_MAX_LAYERID                1      ///< JCTVC-O0137, JCTVC-O0200, JCTVC-O0223: restrict nuh_layer_id and vps_max_layers_minus1
    5150
     51#define Q0200_CONFORMANCE_BL_SIZE        1       ///< JCTVC-Q0200; use conformance picture size in re-sampling processs
    5252#define P0312_VERT_PHASE_ADJ             1      ///< JCTVC-P0312: vertical phase adjustment in re-sampling process (BoG report)
     53#if P0312_VERT_PHASE_ADJ
     54#define Q0120_PHASE_CALCULATION          1      ///< JCTVC-Q0120 phase offset derivation for combination of spatial scalibility and field coding.
     55#endif
    5356#define P0130_EOB                        1      ///< JCTVC-P0130, set layer Id of EOB NALU to be fixed to 0
    5457#define P0307_REMOVE_VPS_VUI_OFFSET      1      ///< JCTVC-P0307, remove implementation related to VPS VUI offset signalling
     
    8184
    8285#define O0164_MULTI_LAYER_HRD            1      ///< JCTVC-O0164: Multi-layer HRD operation
     86#define Q0074_SEI_COLOR_MAPPING          1      ///< JCTVC-Q0074, SEI Color Mapping
    8387
    8488#define O0194_DIFFERENT_BITDEPTH_EL_BL   1      ///< JCTVC-O0194: Support for different bitdepth values for BL and EL, add required configuration parameters (and Some bugfixes when REPN_FORMAT_IN_VPS (JCTVC-N0092) is enabled)
     
    8690#define O0194_JOINT_US_BITSHIFT          1      ///< JCTVC-O0194: Joint Upsampling and bit-shift
    8791#endif
     92#define Q0048_CGS_3D_ASYMLUT             1      ///< JCTVC-Q0048: Colour gamut scalability with look-up table
     93#if Q0048_CGS_3D_ASYMLUT
     94#define O0194_WEIGHTED_PREDICTION_CGS    0
     95#else
    8896#define O0194_WEIGHTED_PREDICTION_CGS    1      ///< JCTVC-O0194: Weighted prediciton for color gamut scalability
     97#endif
    8998#define MFM_ENCCONSTRAINT                1      ///< JCTVC-O0216: Encoder constraint for motion field mapping
    9099#define VPS_NUH_LAYER_ID                 1      ///< JCTVC-N0085: Assert that the nuh_layer_id of VPS NAL unit should be 0
     
    185194#define TSLAYERS_IL_RPS                  1      ///< JCTVC-O0120 IL RPS based on max temporal sub-layers
    186195#define P0079_DERIVE_NUMACTIVE_REF_PICS  1      ///< JCTVC-P0079 Modification of derivation of variable NumActiveRefLayerPics
     196#define Q0060_MAX_TID_REF_EQUAL_TO_ZERO  1      ///< JCTVC-Q0060 handling the case max_tid_il_ref_pics_plus1 is equal to 0.
    187197#if REF_IDX_MFM
    188198#define N0139_POSITION_ROUNDING_OFFSET   1      ///< JCTVC-N0139: offset for collocated block in motion mapping
     
    226236#define O0096_DEFAULT_DEPENDENCY_TYPE    1      ///< JCTVC-O0096: specify default dependency type for all direct reference layers
    227237
     238#define Q0195_REP_FORMAT_CLEANUP         1      ///< JCTVC-Q0195: restructureing of rep_format() signaling
     239#define REP_FORMAT_FIX                   1      ///< update_rep_format_flag should be inferred to be equal to 0
     240
    228241#define RESAMPLING_CONSTRAINT_BUG_FIX    1
    229242#define O0098_SCALED_REF_LAYER_ID        1      ///< JCTVC-O0098: signal scaled reference id
     
    231244#define O0153_ALT_OUTPUT_LAYER_FLAG      1      ///< JCTVC-O0153: alt output layer flag
    232245#define P0300_ALT_OUTPUT_LAYER_FLAG      1      ///< JCTVC-P0300: alt output layer flag
     246
     247#define Q0165_OUTPUT_LAYER_SET           1      ///< JCTVC-Q0165: add a constraint to disallow an empty output layer set
     248#define Q0165_NUM_ADD_OUTPUT_LAYER_SETS  1      ///< JCTVC-Q0165: signal num_add_output_layer_set and default_target_output_layer_idc when vps_num_layer_sets_minus1 is greater than 0
    233249
    234250#define VPS_DPB_SIZE_TABLE               1      ///< JCTVC-O0217: DPB operations: signaling DPB-related parameters
     
    264280//! \ingroup TLibCommon
    265281//! \{
     282#define HARMONIZE_GOP_FIRST_FIELD_COUPLE  1
     283#define FIX_FIELD_DEPTH                 1
     284#define EFFICIENT_FIELD_IRAP            1
     285#define ALLOW_RECOVERY_POINT_AS_RAP     1
    266286#define BUGFIX_INTRAPERIOD 1
    267287#define SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1
    268288
     289#define SAO_SGN_FUNC 1
     290
    269291#define FIX1172 1 ///< fix ticket #1172
     292
     293#define SETTING_PIC_OUTPUT_MARK     1
     294#define SETTING_NO_OUT_PIC_PRIOR    1
     295#define FIX_EMPTY_PAYLOAD_NAL       1
     296#define FIX_WRITING_OUTPUT          1
     297#define FIX_OUTPUT_EOS              1
     298
     299#define FIX_POC_CRA_NORASL_OUTPUT   1
    270300
    271301#define MAX_NUM_PICS_IN_SOP           1024
  • trunk/source/Lib/TLibDecoder/AnnexBread.h

    r595 r713  
    6565  , m_Input(istream)
    6666  {
    67     istream.exceptions(std::istream::eofbit);
     67    istream.exceptions(std::istream::eofbit | std::istream::badbit);
    6868  }
    6969
  • trunk/source/Lib/TLibDecoder/SEIread.cpp

    r644 r713  
    9393    fprintf( g_hTrace, "===========Tone Mapping Info SEI message ===========\n");
    9494    break;
     95#if Q0074_SEI_COLOR_MAPPING
     96  case SEI::COLOR_MAPPING_INFO:
     97    fprintf( g_hTrace, "===========Color Mapping Info SEI message ===========\n");
     98    break;
     99#endif
    95100  case SEI::SOP_DESCRIPTION:
    96101    fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");
     
    280285      xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize);
    281286      break;
     287#if Q0074_SEI_COLOR_MAPPING
     288    case SEI::COLOR_MAPPING_INFO:
     289      sei = new SEIColorMappingInfo;
     290      xParseSEIColorMappingInfo((SEIColorMappingInfo&) *sei, payloadSize);
     291      break;
     292#endif
    282293    case SEI::SOP_DESCRIPTION:
    283294      sei = new SEISOPDescription;
     
    518529{
    519530  UInt val;
    520   READ_CODE(4, val, "active_vps_id");      sei.activeVPSId = val;
    521   READ_FLAG( val, "full_random_access_flag");  sei.m_fullRandomAccessFlag = val ? true : false;
    522   READ_FLAG( val, "no_param_set_update_flag"); sei.m_noParamSetUpdateFlag = val ? true : false;
     531  READ_CODE(4, val, "active_video_parameter_set_id");   sei.activeVPSId = val;
     532  READ_FLAG(   val, "self_contained_cvs_flag");         sei.m_selfContainedCvsFlag = val ? true : false;
     533  READ_FLAG(   val, "no_parameter_set_update_flag");    sei.m_noParameterSetUpdateFlag = val ? true : false;
    523534  READ_UVLC(   val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val;
    524535
    525   sei.activeSeqParamSetId.resize(sei.numSpsIdsMinus1 + 1);
     536  sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1);
    526537  for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++)
    527538  {
    528     READ_UVLC(val, "active_seq_param_set_id");  sei.activeSeqParamSetId[i] = val;
    529   }
    530 
    531   UInt uibits = m_pcBitstream->getNumBitsUntilByteAligned();
    532  
    533   while(uibits--)
    534   {
    535     READ_FLAG(val, "alignment_bit");
    536   }
     539    READ_UVLC(val, "active_seq_parameter_set_id");      sei.activeSeqParameterSetId[i] = val;
     540  }
     541
     542  xParseByteAlign();
    537543}
    538544
     
    812818    case 4:
    813819      {
    814         READ_CODE( 8, val, "camera_iso_speed_idc" );                     sei.m_cameraIsoSpeedValue = val;
    815         if( sei.m_cameraIsoSpeedValue == 255) //Extended_ISO
     820        READ_CODE( 8, val, "camera_iso_speed_idc" );                     sei.m_cameraIsoSpeedIdc = val;
     821        if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO
    816822        {
    817823          READ_CODE( 32,   val,   "camera_iso_speed_value" );            sei.m_cameraIsoSpeedValue = val;
     824        }
     825        READ_CODE( 8, val, "exposure_index_idc" );                       sei.m_exposureIndexIdc = val;
     826        if( sei.m_exposureIndexIdc == 255) //Extended_ISO
     827        {
     828          READ_CODE( 32,   val,   "exposure_index_value" );              sei.m_exposureIndexValue = val;
    818829        }
    819830        READ_FLAG( val, "exposure_compensation_value_sign_flag" );       sei.m_exposureCompensationValueSignFlag = val;
     
    837848  xParseByteAlign();
    838849}
     850
     851#if Q0074_SEI_COLOR_MAPPING
     852Void SEIReader::xParseSEIColorMappingInfo(SEIColorMappingInfo& sei, UInt /*payloadSize*/)
     853{
     854  UInt  uiVal;
     855  Int   iVal;
     856
     857  READ_UVLC( uiVal, "colour_map_id" );          sei.m_colorMapId = uiVal;
     858  READ_FLAG( uiVal, "colour_map_cancel_flag" ); sei.m_colorMapCancelFlag = uiVal;
     859  if( !sei.m_colorMapCancelFlag )
     860  {
     861    READ_FLAG( uiVal, "colour_map_persistence_flag" );                sei.m_colorMapPersistenceFlag = uiVal;
     862    READ_FLAG( uiVal, "colour_map_video_signal_type_present_flag" );  sei.m_colorMap_video_signal_type_present_flag = uiVal;
     863    if ( sei.m_colorMap_video_signal_type_present_flag ) {
     864      READ_FLAG( uiVal,     "colour_map_video_full_range_flag" );     sei.m_colorMap_video_full_range_flag = uiVal;
     865      READ_CODE( 8, uiVal,  "colour_map_primaries" );                 sei.m_colorMap_primaries = uiVal;
     866      READ_CODE( 8, uiVal,  "colour_map_transfer_characteristics" );  sei.m_colorMap_transfer_characteristics = uiVal;
     867      READ_CODE( 8, uiVal,  "colour_map_matrix_coeffs" );             sei.m_colorMap_matrix_coeffs = uiVal;
     868    }
     869  }
     870
     871  READ_CODE( 5, uiVal,  "colour_map_coded_data_bit_depth" );  sei.m_colour_map_coded_data_bit_depth = uiVal;
     872  READ_CODE( 5, uiVal,  "colour_map_target_bit_depth" );      sei.m_colour_map_target_bit_depth = uiVal;
     873  READ_UVLC( uiVal, "colour_map_model_id" );                  sei.m_colorMapModelId = uiVal;
     874
     875  assert( sei.m_colorMapModelId == 0 );
     876 
     877  for( Int i=0 ; i<3 ; i++ )
     878  {
     879    READ_CODE( 8, uiVal, "num_input_pivots_minus1[i]" ); sei.m_num_input_pivots[i] = (uiVal==0) ? 2 : (uiVal + 1) ;
     880    sei.m_coded_input_pivot_value[i]   = new Int[ sei.m_num_input_pivots[i] ];
     881    sei.m_target_input_pivot_value[i]  = new Int[ sei.m_num_input_pivots[i] ];
     882    if( uiVal > 0 )
     883    {
     884      for ( Int j=0 ; j<sei.m_num_input_pivots[i] ; j++ )
     885      {
     886        READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "coded_input_pivot_value[i][j]" );  sei.m_coded_input_pivot_value[i][j] = uiVal;
     887        READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "target_input_pivot_value[i][j]" ); sei.m_target_input_pivot_value[i][j] = uiVal;
     888      }
     889    }
     890    else
     891    {
     892      sei.m_coded_input_pivot_value[i][0]  = 0;
     893      sei.m_target_input_pivot_value[i][0] = 0;
     894      sei.m_coded_input_pivot_value[i][1]  = (1 << sei.m_colour_map_coded_data_bit_depth) - 1 ;
     895      sei.m_target_input_pivot_value[i][1] = (1 << sei.m_colour_map_target_bit_depth) - 1 ;
     896    }
     897  }
     898
     899  READ_FLAG( uiVal,           "matrix_flag" ); sei.m_matrix_flag = uiVal;
     900  if( sei.m_matrix_flag )
     901  {
     902    READ_CODE( 4, uiVal,         "log2_matrix_denom" ); sei.m_log2_matrix_denom = uiVal;
     903    for ( Int i=0 ; i<3 ; i++ )
     904    {
     905      for ( Int j=0 ; j<3 ; j++ )
     906      {
     907        READ_SVLC( iVal,        "matrix_coef[i][j]" ); sei.m_matrix_coef[i][j] = iVal;
     908      }
     909    }
     910  }
     911
     912  for ( Int i=0 ; i<3 ; i++ )
     913  {
     914    READ_CODE( 8, uiVal, "num_output_pivots_minus1[i]" ); sei.m_num_output_pivots[i] = (uiVal==0) ? 2 : (uiVal + 1) ;
     915    sei.m_coded_output_pivot_value[i]   = new Int[ sei.m_num_output_pivots[i] ];
     916    sei.m_target_output_pivot_value[i]  = new Int[ sei.m_num_output_pivots[i] ];
     917    if( uiVal > 0 )
     918    {
     919      for ( Int j=0 ; j<sei.m_num_output_pivots[i] ; j++ )
     920      {
     921        READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "coded_output_pivot_value[i][j]" );  sei.m_coded_output_pivot_value[i][j] = uiVal;
     922        READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "target_output_pivot_value[i][j]" ); sei.m_target_output_pivot_value[i][j] = uiVal;
     923      }
     924    }
     925    else
     926    {
     927      sei.m_coded_output_pivot_value[i][0]  = 0;
     928      sei.m_target_output_pivot_value[i][0] = 0;
     929      sei.m_coded_output_pivot_value[i][1]  = (1 << sei.m_colour_map_coded_data_bit_depth) - 1 ;
     930      sei.m_target_output_pivot_value[i][1] = (1 << sei.m_colour_map_target_bit_depth) - 1 ;
     931    }
     932  }
     933
     934  xParseByteAlign();
     935}
     936#endif
    839937
    840938Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize)
  • trunk/source/Lib/TLibDecoder/SEIread.h

    r644 r713  
    9090  Void xParseSEIGradualDecodingRefreshInfo (SEIGradualDecodingRefreshInfo &sei, UInt payloadSize);
    9191  Void xParseSEIToneMappingInfo       (SEIToneMappingInfo& sei, UInt payloadSize);
     92#if Q0074_SEI_COLOR_MAPPING
     93  Void xParseSEIColorMappingInfo      (SEIColorMappingInfo& sei, UInt payloadSize);
     94#endif
    9295  Void xParseSEISOPDescription        (SEISOPDescription &sei, UInt payloadSize);
    9396#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
  • trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r649 r713  
    3939#include "SEIread.h"
    4040#include "TDecSlice.h"
     41#if Q0048_CGS_3D_ASYMLUT
     42#include "../TLibCommon/TCom3DAsymLUT.h"
     43#endif
    4144
    4245//! \ingroup TLibDecoder
     
    175178}
    176179
    177 Void TDecCavlc::parsePPS(TComPPS* pcPPS)
     180Void TDecCavlc::parsePPS(TComPPS* pcPPS
     181#if Q0048_CGS_3D_ASYMLUT
     182  , TCom3DAsymLUT * pc3DAsymLUT , Int nLayerID
     183#endif
     184  )
    178185{
    179186#if ENC_DEC_TRACE
     
    348355      READ_FLAG( uiCode, "poc_reset_info_present_flag" );
    349356      pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false);
     357#if Q0048_CGS_3D_ASYMLUT
     358      READ_FLAG( uiCode , "colour_mapping_enabled_flag" );
     359      pcPPS->setCGSFlag( uiCode );
     360      if( pcPPS->getCGSFlag() )
     361      {
     362        xParse3DAsymLUT( pc3DAsymLUT );
     363        pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() );
     364        pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() );
     365      }
     366#endif
    350367#endif
    351368    }
     
    599616  else
    600617  {
     618#if REP_FORMAT_FIX
     619    pcSPS->setUpdateRepFormatFlag( false );
     620#else
    601621    pcSPS->setUpdateRepFormatFlag( true );
     622#endif
    602623  }
    603624#if O0096_REP_FORMAT_INDEX
     
    681702    for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
    682703    {
    683       READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1");
     704      READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]");
    684705      pcSPS->setMaxDecPicBuffering( uiCode + 1, i);
    685       READ_UVLC ( uiCode, "sps_num_reorder_pics" );
     706      READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" );
    686707      pcSPS->setNumReorderPics(uiCode, i);
    687       READ_UVLC ( uiCode, "sps_max_latency_increase_plus1");
     708      READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]");
    688709      pcSPS->setMaxLatencyIncrease( uiCode, i );
    689710
     
    887908  READ_CODE( 6,  uiCode,  "vps_reserved_zero_6bits" );            assert(uiCode == 0);
    888909#endif
    889   READ_CODE( 3,  uiCode,  "vps_max_sub_layers_minus1" );          pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode <= 6);
     910  READ_CODE( 3,  uiCode,  "vps_max_sub_layers_minus1" );          pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER);
    890911  READ_FLAG(     uiCode,  "vps_temporal_id_nesting_flag" );       pcVPS->setTemporalNestingFlag( uiCode ? true:false );
    891912  assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag());
     
    973994    }
    974995  }
    975   READ_FLAG( uiCode,  "vps_extension_flag" );
    976   if (uiCode)
    977   {
     996
    978997#if VPS_EXTNS
     998  READ_FLAG( uiCode,  "vps_extension_flag" );      pcVPS->setVpsExtensionFlag( uiCode ? true : false );
     999
     1000  // When MaxLayersMinus1 is greater than 0, vps_extension_flag shall be equal to 1.
     1001  if( pcVPS->getMaxLayers() > 1 )
     1002  {
     1003    assert( pcVPS->getVpsExtensionFlag() == true );
     1004  }
     1005
     1006  if( pcVPS->getVpsExtensionFlag()  )
     1007  {
    9791008    while ( m_pcBitstream->getNumBitsRead() % 8 != 0 )
    9801009    {
     
    9901019      }
    9911020    }
    992 #else
     1021  }
     1022  else
     1023  {
     1024    // set default parameters when syntax elements are not present
     1025    defaultVPSExtension(pcVPS);   
     1026  }
     1027#else
     1028  READ_FLAG( uiCode,  "vps_extension_flag" );
     1029  if (uiCode)
     1030  {
    9931031    while ( xMoreRbspData() )
    9941032    {
    9951033      READ_FLAG( uiCode, "vps_extension_data_flag");
    9961034    }
    997 #endif
    998   }
     1035  }
     1036#endif
    9991037
    10001038  return;
     
    11291167#endif
    11301168#if VPS_TSLAYERS
    1131     READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag"); vps->setMaxTSLayersPresentFlag(uiCode ? true : false);
    1132     if (vps->getMaxTSLayersPresentFlag())
    1133     {
    1134         for(i = 0; i < vps->getMaxLayers(); i++)
    1135         {
    1136             READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1[i]" ); vps->setMaxTSLayersMinus1(i, uiCode);
    1137         }
    1138     }
    1139     else
    1140     {
    1141         for( i = 0; i < vps->getMaxLayers(); i++)
    1142         {
    1143             vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1);
    1144         }
    1145     }
     1169  READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag"); vps->setMaxTSLayersPresentFlag(uiCode ? true : false);
     1170
     1171  if (vps->getMaxTSLayersPresentFlag())
     1172  {
     1173    for(i = 0; i < vps->getMaxLayers(); i++)
     1174    {
     1175      READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1[i]" ); vps->setMaxTSLayersMinus1(i, uiCode);
     1176    }
     1177  }
     1178  else
     1179  {
     1180    for( i = 0; i < vps->getMaxLayers(); i++)
     1181    {
     1182      vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1);
     1183    }
     1184  }
    11461185#endif
    11471186#if N0120_MAX_TID_REF_PRESENT_FLAG
     
    12501289  }
    12511290#else
     1291
     1292#if Q0165_NUM_ADD_OUTPUT_LAYER_SETS
     1293  if( vps->getNumLayerSets() > 1 )
     1294  {
     1295    READ_UVLC( uiCode, "num_add_output_layer_sets" );            vps->setNumAddOutputLayerSets( uiCode );
     1296    READ_CODE( 2, uiCode, "default_target_output_layer_idc" );   vps->setDefaultTargetOutputLayerIdc( uiCode );
     1297  }
     1298  else
     1299  {
     1300    vps->setNumAddOutputLayerSets( 0 );
     1301  }
     1302#else
    12521303  READ_UVLC( uiCode, "num_add_output_layer_sets" );          vps->setNumAddOutputLayerSets( uiCode );
     1304#endif
     1305
     1306  // The value of num_add_output_layer_sets shall be in the range of 0 to 1023, inclusive.
     1307  assert( vps->getNumAddOutputLayerSets() >= 0 && vps->getNumAddOutputLayerSets() < 1024 );
     1308
    12531309  Int numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets();
    12541310#endif
    12551311
    12561312#if P0295_DEFAULT_OUT_LAYER_IDC
     1313#if !Q0165_NUM_ADD_OUTPUT_LAYER_SETS
    12571314  if( numOutputLayerSets > 1 )
    12581315  {
    12591316    READ_CODE( 2, uiCode, "default_target_output_layer_idc" );   vps->setDefaultTargetOutputLayerIdc( uiCode );
    12601317  }
     1318#endif
    12611319  vps->setNumOutputLayerSets( numOutputLayerSets );
    12621320
     
    13301388      vps->setAltOuputLayerFlag(i, uiCode ? true : false);
    13311389    }
     1390#if Q0165_OUTPUT_LAYER_SET
     1391    assert( NumOutputLayersInOutputLayerSet[i]>0 );
     1392#endif
     1393
    13321394#endif
    13331395  }
     
    14311493
    14321494#if REPN_FORMAT_IN_VPS
     1495#if Q0195_REP_FORMAT_CLEANUP
     1496  READ_UVLC( uiCode, "vps_num_rep_formats_minus1" );
     1497  vps->setVpsNumRepFormats( uiCode + 1 );
     1498
     1499  // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive.
     1500  assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 );
     1501
     1502  for(i = 0; i < vps->getVpsNumRepFormats(); i++)
     1503  {
     1504    // Read rep_format_structures
     1505    parseRepFormat( vps->getVpsRepFormat(i), i > 0 ? vps->getVpsRepFormat(i-1) : 0 );
     1506  }
     1507
     1508  // Default assignment for layer 0
     1509  vps->setVpsRepFormatIdx( 0, 0 );
     1510
     1511  if( vps->getVpsNumRepFormats() > 1 )
     1512  {
     1513    READ_FLAG( uiCode, "rep_format_idx_present_flag");
     1514    vps->setRepFormatIdxPresentFlag( uiCode ? true : false );
     1515  }
     1516  else
     1517  {
     1518    // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0
     1519    vps->setRepFormatIdxPresentFlag( false );
     1520  }
     1521
     1522  if( vps->getRepFormatIdxPresentFlag() )
     1523  {
     1524    for(i = 1; i < vps->getMaxLayers(); i++)
     1525    {
     1526      Int numBits = 1;
     1527      while ((1 << numBits) < (vps->getVpsNumRepFormats()))
     1528      {
     1529        numBits++;
     1530      }
     1531      READ_CODE( numBits, uiCode, "vps_rep_format_idx[i]" );
     1532      vps->setVpsRepFormatIdx( i, uiCode );
     1533    }
     1534  }
     1535  else
     1536  {
     1537    // When not present, the value of vps_rep_format_idx[ i ] is inferred to be equal to Min (i, vps_num_rep_formats_minus1)
     1538    for(i = 1; i < vps->getMaxLayers(); i++)
     1539    {
     1540      vps->setVpsRepFormatIdx( i, min( (Int)i, vps->getVpsNumRepFormats()-1 ) );
     1541    }
     1542  }
     1543#else
    14331544  READ_FLAG( uiCode, "rep_format_idx_present_flag");
    14341545  vps->setRepFormatIdxPresentFlag( uiCode ? true : false );
     
    14531564    vps->setVpsNumRepFormats( vps->getMaxLayers() );
    14541565  }
     1566
     1567  // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive.
     1568  assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 );
     1569
    14551570  for(i = 0; i < vps->getVpsNumRepFormats(); i++)
    14561571  {
    14571572    // Read rep_format_structures
    1458     parseRepFormat( vps->getVpsRepFormat(i) );
     1573    parseRepFormat( vps->getVpsRepFormat(i), i > 0 ? vps->getVpsRepFormat(i-1) : 0 );
    14591574  }
    14601575
     
    14981613    }
    14991614  }
     1615#endif
    15001616#endif
    15011617#if RESOLUTION_BASED_DPB
     
    15781694#if P0307_VPS_NON_VUI_EXTENSION
    15791695  READ_UVLC( uiCode,           "vps_non_vui_extension_length"); vps->setVpsNonVuiExtLength((Int)uiCode);
     1696
     1697  // The value of vps_non_vui_extension_length shall be in the range of 0 to 4096, inclusive.
     1698  assert( vps->getVpsNonVuiExtLength() >= 0 && vps->getVpsNonVuiExtLength() <= 4096 );
     1699
    15801700#if P0307_VPS_NON_VUI_EXT_UPDATE
    15811701  Int nonVuiExtByte = uiCode;
     
    16201740#endif
    16211741  }
    1622 }
    1623 #endif
     1742  else
     1743  {
     1744    // set default values for VPS VUI
     1745    defaultVPSVUI( vps );
     1746  }
     1747}
     1748
     1749Void TDecCavlc::defaultVPSExtension( TComVPS* vps )
     1750{
     1751  // set default parameters when they are not present
     1752  Int i, j;
     1753
     1754  // When layer_id_in_nuh[ i ] is not present, the value is inferred to be equal to i.
     1755  for(i = 0; i < vps->getMaxLayers(); i++)
     1756  {
     1757    vps->setLayerIdInNuh(i, i);
     1758    vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i);
     1759  }
     1760
     1761  // When not present, sub_layers_vps_max_minus1[ i ] is inferred to be equal to vps_max_sub_layers_minus1.
     1762  for( i = 0; i < vps->getMaxLayers(); i++)
     1763  {
     1764    vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1);
     1765  }
     1766
     1767  // When not present, max_tid_il_ref_pics_plus1[ i ][ j ] is inferred to be equal to 7.
     1768  for( i = 0; i < vps->getMaxLayers() - 1; i++ )
     1769  {
     1770#if O0225_MAX_TID_FOR_REF_LAYERS
     1771    for( j = i + 1; j < vps->getMaxLayers(); j++ )
     1772    {
     1773      vps->setMaxTidIlRefPicsPlus1(i, j, 7);
     1774    }
     1775#else
     1776    vps->setMaxTidIlRefPicsPlus1(i, 7);
     1777#endif
     1778  }
     1779 
     1780  // When not present, the value of num_add_output_layer_sets is inferred to be equal to 0.
     1781  // NumOutputLayerSets = num_add_output_layer_sets + vps_num_layer_sets_minus1 + 1
     1782  vps->setNumOutputLayerSets( vps->getNumLayerSets() );
     1783
     1784  // For i in the range of 0 to NumOutputLayerSets-1, inclusive, the variable LayerSetIdxForOutputLayerSet[ i ] is derived as specified in the following:
     1785  // LayerSetIdxForOutputLayerSet[ i ] = ( i <= vps_number_layer_sets_minus1 ) ? i : output_layer_set_idx_minus1[ i ] + 1
     1786  for( i = 1; i < vps->getNumOutputLayerSets(); i++ )
     1787  {
     1788    vps->setOutputLayerSetIdx( i, i );
     1789    Int lsIdx = vps->getOutputLayerSetIdx(i);
     1790
     1791    for( j = 0; j < vps->getNumLayersInIdList(lsIdx); j++ )
     1792    {
     1793    vps->setOutputLayerFlag(i, j, 1);
     1794    }
     1795  }
     1796
     1797  // The value of sub_layer_dpb_info_present_flag[ i ][ 0 ] for any possible value of i is inferred to be equal to 1
     1798  // When not present, the value of sub_layer_dpb_info_present_flag[ i ][ j ] for j greater than 0 and any possible value of i, is inferred to be equal to be equal to 0.
     1799  for( i = 1; i < vps->getNumOutputLayerSets(); i++ )
     1800  {
     1801    vps->setSubLayerDpbInfoPresentFlag( i, 0, true );
     1802  }
     1803 
     1804  // When not present, the value of vps_num_rep_formats_minus1 is inferred to be equal to MaxLayersMinus1.
     1805  vps->setVpsNumRepFormats( vps->getMaxLayers() );
     1806
     1807  // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0
     1808  vps->setRepFormatIdxPresentFlag( false );
     1809
     1810  if( !vps->getRepFormatIdxPresentFlag() )
     1811  {
     1812    // When not present, the value of vps_rep_format_idx[ i ] is inferred to be equal to Min(i, vps_num_rep_formats_minus1).
     1813    for(i = 1; i < vps->getMaxLayers(); i++)
     1814    {
     1815      vps->setVpsRepFormatIdx( i, min( (Int)i, vps->getVpsNumRepFormats() - 1 ) );
     1816    }
     1817  }
     1818
     1819  // vps_poc_lsb_aligned_flag
     1820  // When not present, vps_poc_lsb_aligned_flag is inferred to be equal to 0.
     1821 
     1822#if O0062_POC_LSB_NOT_PRESENT_FLAG
     1823  // When not present, poc_lsb_not_present_flag[ i ] is inferred to be equal to 0.
     1824  for(i = 1; i< vps->getMaxLayers(); i++)
     1825  {
     1826    vps->setPocLsbNotPresentFlag(i, 0);
     1827  }
     1828#endif
     1829
     1830  // set default values for VPS VUI
     1831  defaultVPSVUI( vps );
     1832}
     1833
     1834Void TDecCavlc::defaultVPSVUI( TComVPS* vps )
     1835{
     1836#if N0147_IRAP_ALIGN_FLAG
     1837  // When not present, the value of all_layers_idr_aligned_flag is inferred to be equal to 0.
     1838  vps->setCrossLayerIrapAlignFlag( false );
     1839#endif
     1840
     1841#if M0040_ADAPTIVE_RESOLUTION_CHANGE
     1842  // When single_layer_for_non_irap_flag is not present, it is inferred to be equal to 0.
     1843  vps->setSingleLayerForNonIrapFlag( false );
     1844#endif
     1845
     1846#if HIGHER_LAYER_IRAP_SKIP_FLAG
     1847  // When higher_layer_irap_skip_flag is not present it is inferred to be equal to 0
     1848  vps->setHigherLayerIrapSkipFlag( false );
     1849#endif
     1850}
     1851#endif
     1852
    16241853#if REPN_FORMAT_IN_VPS
    1625 Void  TDecCavlc::parseRepFormat      ( RepFormat *repFormat )
     1854Void  TDecCavlc::parseRepFormat( RepFormat *repFormat, RepFormat *repFormatPrev )
    16261855{
    16271856  UInt uiCode;
    1628 #if REPN_FORMAT_CONTROL_FLAG
    1629   READ_FLAG ( uiCode, "chroma_and_bit_depth_vps_present_flag");   repFormat->setChromaAndBitDepthVpsPresentFlag(uiCode ? true : false);
    1630   READ_CODE ( 16, uiCode, "pic_width_in_luma_samples" );          repFormat->setPicWidthVpsInLumaSamples ( uiCode );
    1631   READ_CODE ( 16, uiCode, "pic_height_in_luma_samples" );         repFormat->setPicHeightVpsInLumaSamples( uiCode );
     1857#if REPN_FORMAT_CONTROL_FLAG 
     1858  READ_CODE( 16, uiCode, "pic_width_vps_in_luma_samples" );        repFormat->setPicWidthVpsInLumaSamples ( uiCode );
     1859  READ_CODE( 16, uiCode, "pic_height_vps_in_luma_samples" );       repFormat->setPicHeightVpsInLumaSamples( uiCode );
     1860  READ_FLAG( uiCode, "chroma_and_bit_depth_vps_present_flag" );    repFormat->setChromaAndBitDepthVpsPresentFlag( uiCode ? true : false );
     1861
     1862  if( !repFormatPrev )
     1863  {
     1864    // The value of chroma_and_bit_depth_vps_present_flag of the first rep_format( ) syntax structure in the VPS shall be equal to 1
     1865    assert( repFormat->getChromaAndBitDepthVpsPresentFlag() );
     1866  }
    16321867
    16331868  if( repFormat->getChromaAndBitDepthVpsPresentFlag() )
    16341869  {
     1870    READ_CODE( 2, uiCode, "chroma_format_vps_idc" );
    16351871#if AUXILIARY_PICTURES
    1636     READ_CODE( 2, uiCode, "chroma_format_idc" );               repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) );
    1637 #else
    1638     READ_CODE( 2, uiCode, "chroma_format_idc" );               repFormat->setChromaFormatVpsIdc( uiCode );
     1872    repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) );
     1873#else
     1874    repFormat->setChromaFormatVpsIdc( uiCode );
    16391875#endif
    16401876
    16411877    if( repFormat->getChromaFormatVpsIdc() == 3 )
    16421878    {
    1643       READ_FLAG( uiCode, "separate_colour_plane_flag");        repFormat->setSeparateColourPlaneVpsFlag(uiCode ? true : false);
    1644     }
    1645 
    1646 
    1647     READ_CODE( 4, uiCode, "bit_depth_luma_minus8" );           repFormat->setBitDepthVpsLuma  ( uiCode + 8 );
    1648     READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" );         repFormat->setBitDepthVpsChroma( uiCode + 8 );
     1879      READ_FLAG( uiCode, "separate_colour_plane_vps_flag" );       repFormat->setSeparateColourPlaneVpsFlag( uiCode ? true : false );
     1880    }
     1881
     1882    READ_CODE( 4, uiCode, "bit_depth_vps_luma_minus8" );           repFormat->setBitDepthVpsLuma  ( uiCode + 8 );
     1883    READ_CODE( 4, uiCode, "bit_depth_vps_chroma_minus8" );         repFormat->setBitDepthVpsChroma( uiCode + 8 );
     1884  }
     1885  else if( repFormatPrev )
     1886  {
     1887    // chroma_and_bit_depth_vps_present_flag equal to 0 specifies that the syntax elements, chroma_format_vps_idc, separate_colour_plane_vps_flag, bit_depth_vps_luma_minus8, and
     1888    // bit_depth_vps_chroma_minus8 are not present and inferred from the previous rep_format( ) syntax structure in the VPS.
     1889
     1890    repFormat->setChromaFormatVpsIdc        ( repFormatPrev->getChromaFormatVpsIdc() );
     1891    repFormat->setSeparateColourPlaneVpsFlag( repFormatPrev->getSeparateColourPlaneVpsFlag() );
     1892    repFormat->setBitDepthVpsLuma           ( repFormatPrev->getBitDepthVpsLuma() );
     1893    repFormat->setBitDepthVpsChroma         ( repFormatPrev->getBitDepthVpsChroma() );
    16491894  }
    16501895#else
     
    17001945    READ_FLAG( uiCode, "sub_layer_flag_info_present_flag[i]");  vps->setSubLayerFlagInfoPresentFlag( i, uiCode ? true : false );
    17011946#if DPB_PARAMS_MAXTLAYERS
    1702       for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ i ]; j++)
     1947    for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ i ]; j++)
    17031948#else
    17041949    for(Int j = 0; j <= vps->getMaxTLayers(); j++)
     
    18202065        if( parseFlag && vps->getBitRatePresentVpsFlag() )
    18212066        {
    1822           READ_FLAG( uiCode,        "bit_rate_present_vps_flag[i][j]" );  vps->setBitRatePresentFlag( i, j, uiCode ? true : false );
     2067          READ_FLAG( uiCode,        "bit_rate_present_flag[i][j]" );  vps->setBitRatePresentFlag( i, j, uiCode ? true : false );
    18232068        }
    18242069        else
     
    18282073        if( parseFlag && vps->getPicRatePresentVpsFlag() )
    18292074        {
    1830           READ_FLAG( uiCode,        "pic_rate_present_vps_flag[i][j]" );  vps->setPicRatePresentFlag( i, j, uiCode ? true : false );
     2075          READ_FLAG( uiCode,        "pic_rate_present_flag[i][j]" );  vps->setPicRatePresentFlag( i, j, uiCode ? true : false );
    18312076        }
    18322077        else
     
    18682113    vps->setNumVideoSignalInfo(vps->getMaxLayers());
    18692114  }
    1870 
    18712115
    18722116  for(i = 0; i < vps->getNumVideoSignalInfo(); i++)
     
    19542198#if HIGHER_LAYER_IRAP_SKIP_FLAG
    19552199  READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false);
     2200
     2201  // When single_layer_for_non_irap_flag is equal to 0, higher_layer_irap_skip_flag shall be equal to 0
     2202  if( !vps->getSingleLayerForNonIrapFlag() )
     2203  {
     2204    assert( !vps->getHigherLayerIrapSkipFlag() );
     2205  }
    19562206#endif
    19572207#endif
     
    21022352  if( rpcSlice->getRapPicFlag())
    21032353  {
    2104 #if !NO_OUTPUT_OF_PRIOR_PICS
    2105     READ_FLAG( uiCode, "no_output_of_prior_pics_flag" );  //ignored
    2106 #else
    2107     READ_FLAG( uiCode, "no_output_of_prior_pics_flag" );  rpcSlice->setNoOutputOfPriorPicsFlag( uiCode ? true : false );
     2354    READ_FLAG( uiCode, "no_output_of_prior_pics_flag" );  //ignored -- updated already
     2355#if SETTING_NO_OUT_PIC_PRIOR
     2356    rpcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false);
     2357#else
     2358    rpcSlice->setNoOutputPicPrior( false );
    21082359#endif
    21092360  }
     
    23052556        else
    23062557        {
    2307           uiCode = 0;
     2558          uiCode = 0;       
    23082559        }
    23092560        *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode));
     
    24532704            for( Int i = 0; i < rpcSlice->getNumILRRefIdx(); i++ )
    24542705            {
     2706#if Q0060_MAX_TID_REF_EQUAL_TO_ZERO
     2707              if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) &&
     2708                (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
     2709#else
    24552710              if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() &&
    24562711                (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
     2712#endif
    24572713              {         
    24582714                rpcSlice->setActiveNumILRRefIdx(1);
     
    24872743        {
    24882744#if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS
     2745#if Q0060_MAX_TID_REF_EQUAL_TO_ZERO
     2746          if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) >  rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) &&
     2747            (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >=  rpcSlice->getTLayer()) )
     2748#else
    24892749          if( (rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) >  rpcSlice->getTLayer()) &&
    24902750             (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >=  rpcSlice->getTLayer()) )
     2751#endif
    24912752        {
    24922753#endif
     
    25142775      for(i = 0, numRefLayerPics = 0;  i < rpcSlice->getNumILRRefIdx(); i++ )
    25152776      {
     2777#if Q0060_MAX_TID_REF_EQUAL_TO_ZERO
     2778        if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) &&
     2779          (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
     2780#else
    25162781        if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() &&
    25172782           (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
     2783#endif
    25182784        {         
    25192785          refLayerPicIdc[ numRefLayerPics++ ] = i;
     
    25602826      {
    25612827        format = rpcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc();
     2828#if Q0195_REP_FORMAT_CLEANUP
     2829         assert( (sps->getUpdateRepFormatFlag()==false && rpcSlice->getVPS()->getVpsNumRepFormats()==1) || rpcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check
     2830#endif
    25622831      }
    25632832#else
     
    34683737}
    34693738
     3739#if Q0048_CGS_3D_ASYMLUT
     3740Void TDecCavlc::xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT )
     3741{
     3742  UInt uiCurOctantDepth , uiCurPartNumLog2 , uiInputBitDepthM8 , uiOutputBitDepthM8 , uiResQaunBit;
     3743  READ_CODE( 2 , uiCurOctantDepth , "cm_octant_depth" );
     3744  READ_CODE( 2 , uiCurPartNumLog2 , "cm_y_part_num_log2" );     
     3745  READ_CODE( 3 , uiInputBitDepthM8 , "cm_input_bit_depth_minus8" );
     3746  Int iInputBitDepthCDelta;
     3747  READ_SVLC(iInputBitDepthCDelta, "cm_input_bit_depth_chroma delta");
     3748  READ_CODE( 3 , uiOutputBitDepthM8 , "cm_output_bit_depth_minus8" );
     3749  Int iOutputBitDepthCDelta;
     3750  READ_SVLC(iOutputBitDepthCDelta, "cm_output_bit_depth_chroma_delta");
     3751  READ_CODE( 2 , uiResQaunBit , "cm_res_quant_bit" );
     3752  pc3DAsymLUT->destroy();
     3753  pc3DAsymLUT->create( uiCurOctantDepth , uiInputBitDepthM8 + 8 ,  uiInputBitDepthM8 + 8 + iInputBitDepthCDelta, uiOutputBitDepthM8 + 8 , uiOutputBitDepthM8 + 8 + iOutputBitDepthCDelta ,uiCurPartNumLog2 );
     3754  pc3DAsymLUT->setResQuantBit( uiResQaunBit );
     3755
     3756  xParse3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() );
     3757}
     3758
     3759Void TDecCavlc::xParse3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength )
     3760{
     3761  UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth();
     3762  if( nDepth < pc3DAsymLUT->getCurOctantDepth() )
     3763    READ_FLAG( uiOctantSplit , "split_octant_flag" );
     3764  Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2();
     3765  if( uiOctantSplit )
     3766  {
     3767    Int nHalfLength = nLength >> 1;
     3768    for( Int l = 0 ; l < 2 ; l++ )
     3769    {
     3770      for( Int m = 0 ; m < 2 ; m++ )
     3771      {
     3772        for( Int n = 0 ; n < 2 ; n++ )
     3773        {
     3774          xParse3DAsymLUTOctant( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength );
     3775        }
     3776      }
     3777    }
     3778  }
     3779  else
     3780  {
     3781    for( Int l = 0 ; l < nYPartNum ; l++ )
     3782    {
     3783      for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
     3784      {
     3785        UInt uiCodeVertex = 0;
     3786        Int deltaY = 0 , deltaU = 0 , deltaV = 0;
     3787        READ_FLAG( uiCodeVertex , "coded_vertex_flag" );
     3788        if( uiCodeVertex )
     3789        {
     3790          READ_SVLC( deltaY , "resY" );
     3791          READ_SVLC( deltaU , "resU" );
     3792          READ_SVLC( deltaV , "resV" );
     3793        }
     3794        pc3DAsymLUT->setCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV );
     3795      }
     3796    }
     3797  }
     3798}
     3799#endif
    34703800//! \}
    34713801
  • trunk/source/Lib/TLibDecoder/TDecCAVLC.h

    r644 r713  
    4646#include "SyntaxElementParser.h"
    4747
     48#if Q0048_CGS_3D_ASYMLUT
     49class TCom3DAsymLUT;
     50#endif
    4851//! \ingroup TLibDecoder
    4952//! \{
     
    7578#if VPS_EXTNS
    7679  Void  parseVPSExtension   ( TComVPS* pcVPS );
     80  Void  defaultVPSExtension ( TComVPS* pcVPS );
    7781#endif
    7882
    7983#if VPS_VUI
    8084  Void  parseVPSVUI   ( TComVPS* pcVPS );
     85  Void  defaultVPSVUI ( TComVPS* pcVPS );
    8186#endif
    8287#if REPN_FORMAT_IN_VPS
    83   Void  parseRepFormat      ( RepFormat *repFormat );
     88  Void  parseRepFormat      ( RepFormat *repFormat, RepFormat *repFormatPrev );
    8489#endif
    8590#if VPS_DPB_SIZE_TABLE
     
    95100  Void  parseSPS            ( TComSPS* pcSPS );
    96101#endif //SVC_EXTENSION
    97   Void  parsePPS            ( TComPPS* pcPPS);
     102  Void  parsePPS            ( TComPPS* pcPPS
     103#if Q0048_CGS_3D_ASYMLUT
     104    , TCom3DAsymLUT * pc3DAsymLUT , Int nLayerID
     105#endif
     106    );
    98107  Void  parseVUI            ( TComVUI* pcVUI, TComSPS* pcSPS );
    99108  Void  parseSEI            ( SEIMessages& );
     
    135144protected:
    136145  Bool  xMoreRbspData();
     146
     147#if Q0048_CGS_3D_ASYMLUT
     148  Void xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT );
     149  Void xParse3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength );
     150#endif
    137151};
    138152
  • trunk/source/Lib/TLibDecoder/TDecCu.cpp

    r595 r713  
    7373    m_ppcCU     [ui]->setLayerId(layerId);
    7474  }
     75 
     76#if LAYER_CTB
     77  memcpy(g_auiLayerZscanToRaster[m_layerId], g_auiZscanToRaster, sizeof( g_auiZscanToRaster ) );
     78  memcpy(g_auiLayerRasterToZscan[m_layerId], g_auiRasterToZscan, sizeof( g_auiRasterToZscan ) );
     79  memcpy(g_auiLayerRasterToPelX[m_layerId],  g_auiRasterToPelX,  sizeof( g_auiRasterToPelX ) );
     80  memcpy(g_auiLayerRasterToPelY[m_layerId],  g_auiRasterToPelY,  sizeof( g_auiRasterToPelY ) );
     81#endif
    7582}
    7683#else
     
    715722{
    716723  UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
    717   UInt  uiNumPart     = pcCU->getNumPartInter();
     724  UInt  uiNumPart     = pcCU->getNumPartitions();
    718725  UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
    719726 
  • trunk/source/Lib/TLibDecoder/TDecEntropy.h

    r644 r713  
    4949class TDecCavlc;
    5050class ParameterSetManagerDecoder;
     51#if Q0048_CGS_3D_ASYMLUT
     52class TCom3DAsymLUT;
     53#endif
    5154
    5255//! \ingroup TLibDecoder
     
    7174  virtual Void  parseSPS                  ( TComSPS* pcSPS )                                      = 0;
    7275#endif
    73   virtual Void  parsePPS                  ( TComPPS* pcPPS )                                      = 0;
     76  virtual Void  parsePPS                  ( TComPPS* pcPPS
     77#if Q0048_CGS_3D_ASYMLUT
     78    , TCom3DAsymLUT * pc3DAsymLUT , Int nLayerID
     79#endif
     80    )                                      = 0;
    7481
    7582  virtual Void parseSliceHeader          ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager)       = 0;
     
    138145  Void    decodeSPS                   ( TComSPS* pcSPS     )    { m_pcEntropyDecoderIf->parseSPS(pcSPS);                    }
    139146#endif
    140   Void    decodePPS                   ( TComPPS* pcPPS )    { m_pcEntropyDecoderIf->parsePPS(pcPPS);                    }
     147
     148#if Q0048_CGS_3D_ASYMLUT
     149  Void    decodePPS                   ( TComPPS* pcPPS, TCom3DAsymLUT * pc3DAsymLUT, Int nLayerID )    { m_pcEntropyDecoderIf->parsePPS(pcPPS, pc3DAsymLUT , nLayerID );                     }
     150#else
     151  Void    decodePPS                   ( TComPPS* pcPPS )    { m_pcEntropyDecoderIf->parsePPS(pcPPS );  }
     152#endif
    141153  Void    decodeSliceHeader           ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager)  { m_pcEntropyDecoderIf->parseSliceHeader(rpcSlice, parameterSetManager);         }
    142154
  • trunk/source/Lib/TLibDecoder/TDecGop.cpp

    r595 r713  
    248248  }
    249249
     250#if SETTING_PIC_OUTPUT_MARK
     251  rpcPic->setOutputMark(rpcPic->getSlice(0)->getPicOutputFlag() ? true : false);
     252#else
    250253  rpcPic->setOutputMark(true);
     254#endif
    251255  rpcPic->setReconMark(true);
    252256}
  • trunk/source/Lib/TLibDecoder/TDecSbac.h

    r644 r713  
    8181  Void  parseSPS                  ( TComSPS* /*pcSPS*/ ) {}
    8282#endif
    83   Void  parsePPS                  ( TComPPS* /*pcPPS*/ ) {}
     83  Void  parsePPS                  ( TComPPS* /*pcPPS*/
     84#if Q0048_CGS_3D_ASYMLUT
     85    , TCom3DAsymLUT * /*pc3DAsymLUT*/ , Int /*nLayerID*/
     86#endif
     87    ) {}
    8488
    8589  Void  parseSliceHeader          ( TComSlice*& /*rpcSlice*/, ParameterSetManagerDecoder* /*parameterSetManager*/) {}
  • trunk/source/Lib/TLibDecoder/TDecTop.cpp

    r644 r713  
    7979  m_prevSliceSkipped = false;
    8080  m_skippedPOC = 0;
     81#if SETTING_NO_OUT_PIC_PRIOR
     82  m_bFirstSliceInBitstream  = true;
     83  m_lastPOCNoOutputPriorPics = -1;
     84  m_craNoRaslOutputFlag = false;
     85  m_isNoOutputPriorPics = false;
     86#endif
    8187#if NO_CLRAS_OUTPUT_FLAG
    8288  m_noClrasOutputFlag          = false;
    8389  m_layerInitializedFlag       = false;
    84   m_firstPicInLayerDecodedFlag = false;
    85   m_noOutputOfPriorPicsFlags   = false;
    86   m_bRefreshPending            = false;
     90  m_firstPicInLayerDecodedFlag = false; 
    8791#endif
    8892#if RESOLUTION_BASED_DPB
    8993  m_subDpbIdx = -1;
    9094#endif
     95#if Q0048_CGS_3D_ASYMLUT
     96  m_pColorMappedPic = NULL;
     97#endif
     98
     99#if Q0074_SEI_COLOR_MAPPING
     100  m_ColorMapping = new TDecColorMapping();
     101#endif
    91102}
    92103
     
    95106#if ENC_DEC_TRACE
    96107  fclose( g_hTrace );
     108#endif
     109#if Q0048_CGS_3D_ASYMLUT
     110  if(m_pColorMappedPic)
     111  {
     112    m_pColorMappedPic->destroy();
     113    delete m_pColorMappedPic;
     114    m_pColorMappedPic = NULL;
     115  }
     116#endif
     117#if Q0074_SEI_COLOR_MAPPING
     118  if ( m_ColorMapping )  delete m_ColorMapping;
    97119#endif
    98120}
     
    353375        Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );
    354376
    355         if( pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets || !sameBitDepths )
     377        if( pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets || !sameBitDepths
     378#if Q0048_CGS_3D_ASYMLUT
     379          || pcSlice->getPPS()->getCGSFlag() > 0
     380#endif
     381#if LAYER_CTB
     382          || pcTDecTopBase->getActiveSPS()->getMaxCUWidth() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUWidth() || pcTDecTopBase->getActiveSPS()->getMaxCUHeight() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUHeight() || pcTDecTopBase->getActiveSPS()->getMaxCUDepth() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUDepth()
     383#endif
     384          )
    356385#else
    357386        if(pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets )
     
    503532
    504533  // Execute Deblock + Cleanup
    505 
    506534  m_cGopDecoder.filterPicture(pcPic);
    507535
     
    517545  return;
    518546}
     547
     548#if SETTING_NO_OUT_PIC_PRIOR
     549Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic)
     550{
     551  if (!rpcListPic || !m_isNoOutputPriorPics) return;
     552
     553  TComList<TComPic*>::iterator  iterPic   = rpcListPic->begin();
     554
     555  while (iterPic != rpcListPic->end())
     556  {
     557    TComPic*& pcPicTmp = *(iterPic++);
     558    if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC())
     559    {
     560      pcPicTmp->setOutputMark(false);
     561    }
     562  }
     563}
     564#endif
    519565
    520566#if EARLY_REF_PIC_MARKING
     
    733779#endif
    734780
     781#if AVC_BASE
     782  if( activeVPS->getAvcBaseLayerFlag() )
     783  {
     784    TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
     785    if( m_layerId == 1 && pBLPic->getPicYuvRec() == NULL )
     786    {
     787      UInt refLayerId = 0;
     788      RepFormat* repFormat = activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(refLayerId) );
     789
     790      Int  numReorderPics[MAX_TLAYER];
     791      Window conformanceWindow;
     792      Window defaultDisplayWindow;
     793
     794#if AUXILIARY_PICTURES
     795#if SVC_UPSAMPLING
     796#if AVC_SYNTAX
     797      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, activeSPS, true);
     798#else
     799      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
     800#endif
     801#else
     802      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, true);
     803#endif
     804#else
     805#if SVC_UPSAMPLING
     806#if AVC_SYNTAX
     807      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, activeSPS, true);
     808#else
     809      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
     810#endif
     811#else
     812      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), onformanceWindow, defaultDisplayWindow, numReorderPics, true);
     813#endif
     814#endif
     815      // it is needed where the VPS is accessed through the slice
     816      pBLPic->getSlice(0)->setVPS( activeVPS );
     817
     818#if O0194_DIFFERENT_BITDEPTH_EL_BL
     819      g_bitDepthYLayer[0] = repFormat->getBitDepthVpsLuma();
     820      g_bitDepthCLayer[0] = repFormat->getBitDepthVpsChroma();
     821#endif
     822    }
     823  }
     824#endif
     825
    735826#if P0312_VERT_PHASE_ADJ
    736827  if( activeVPS->getVpsVuiVertPhaseInUseFlag() == 0 )
     
    808899  g_uiAddCUDepth  = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() );
    809900
     901#if Q0074_SEI_COLOR_MAPPING
     902  for(Int compID=0; compID<3; compID++)
     903  {
     904    m_ColorMapping->setColorMapping( compID ? g_bitDepthC : g_bitDepthY, compID );
     905  }
     906#endif
     907
    810908  for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++)
    811909  {
     
    843941  TComPic*&   pcPic         = m_pcPic;
    844942#if SVC_EXTENSION
    845 #if !NO_OUTPUT_OF_PRIOR_PICS
    846 #if NO_CLRAS_OUTPUT_FLAG
    847   Bool bFirstSliceInSeq;
    848 #endif
    849 #endif
    850943  m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder.getPrefetchedVPS(0) );
    851944#if OUTPUT_LAYER_SET_INDEX
     
    900993  m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType);
    901994
    902 #if NO_OUTPUT_OF_PRIOR_PICS
    903   // Infer the value of NoOutputOfPriorPicsFlag
    904   if( m_apcSlicePilot->getRapPicFlag() )
    905   {
    906     if ( m_apcSlicePilot->getBlaPicFlag() || m_apcSlicePilot->getIdrPicFlag()  ||
    907         (m_apcSlicePilot->getCraPicFlag() && m_bFirstSliceInSequence) ||
    908         (m_apcSlicePilot->getCraPicFlag() && m_apcSlicePilot->getHandleCraAsBlaFlag()))
    909     {
    910       m_apcSlicePilot->setNoRaslOutputFlag( true );
     995#if SETTING_NO_OUT_PIC_PRIOR
     996  //For inference of NoOutputOfPriorPicsFlag
     997  if (m_apcSlicePilot->getRapPicFlag())
     998  {
     999    if ((m_apcSlicePilot->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_apcSlicePilot->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) ||
     1000        (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_bFirstSliceInSequence) ||
     1001        (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getHandleCraAsBlaFlag()))
     1002    {
     1003      m_apcSlicePilot->setNoRaslOutputFlag(true);
     1004    }
     1005    //the inference for NoOutputPriorPicsFlag
     1006    if (!m_bFirstSliceInBitstream && m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag())
     1007    {
     1008      if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)
     1009      {
     1010        m_apcSlicePilot->setNoOutputPriorPicsFlag(true);
     1011      }
    9111012    }
    9121013    else
    9131014    {
    914       m_apcSlicePilot->setNoRaslOutputFlag( false );
    915     }
     1015      m_apcSlicePilot->setNoOutputPriorPicsFlag(false);
     1016    }
     1017
     1018    if(m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)
     1019    {
     1020      m_craNoRaslOutputFlag = m_apcSlicePilot->getNoRaslOutputFlag();
     1021    }
     1022  }
     1023  if (m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoOutputPriorPicsFlag())
     1024  {
     1025    m_lastPOCNoOutputPriorPics = m_apcSlicePilot->getPOC();
     1026    m_isNoOutputPriorPics = true;
     1027  }
     1028  else
     1029  {
     1030    m_isNoOutputPriorPics = false;
     1031  }
     1032
     1033  //For inference of PicOutputFlag
     1034  if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R)
     1035  {
     1036    if ( m_craNoRaslOutputFlag )
     1037    {
     1038      m_apcSlicePilot->setPicOutputFlag(false);
     1039    }
     1040  }
     1041#endif
     1042
     1043#if FIX_POC_CRA_NORASL_OUTPUT
     1044  if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1
     1045  {
     1046    Int iMaxPOClsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC();
     1047    m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) );
    9161048  }
    9171049#endif
     
    9671099  }
    9681100
    969   m_apcSlicePilot->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, m_cListPic, getNoClrasOutputFlag());
     1101  m_apcSlicePilot->decodingRefreshMarking( m_cListPic, m_noClrasOutputFlag );
    9701102#endif
    9711103
     
    9751107    if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getNoRaslOutputFlag() )
    9761108    {
    977       this->setNoOutputOfPriorPicsFlags( true );
     1109      this->setNoOutputPriorPicsFlag( true );
    9781110    }
    9791111    else if( m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag() )
    9801112    {
    981       this->setNoOutputOfPriorPicsFlags( m_apcSlicePilot->getNoOutputOfPriorPicsFlag() );
     1113      this->setNoOutputPriorPicsFlag( m_apcSlicePilot->getNoOutputPriorPicsFlag() );
    9821114    }
    9831115    else
     
    9851117      if( this->m_ppcTDecTop[0]->getNoClrasOutputFlag() )
    9861118      {
    987         this->setNoOutputOfPriorPicsFlags( true );
     1119        this->setNoOutputPriorPicsFlag( true );
    9881120      }
    9891121    }
     
    10061138#else
    10071139  //we should only get a different poc for a new picture (with CTU address==0)
    1008   if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (!m_apcSlicePilot->getSliceCurStartCUAddr()==0))
     1140  if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCUAddr()!=0))
    10091141  {
    10101142    printf ("Warning, the first slice of a picture might have been lost!\n");
     
    10501182#endif
    10511183  }
    1052 #if !NO_OUTPUT_OF_PRIOR_PICS
    1053 #if NO_CLRAS_OUTPUT_FLAG
    1054   bFirstSliceInSeq = m_bFirstSliceInSequence;
    1055 #endif
    1056 #endif
    10571184  m_bFirstSliceInSequence = false;
     1185#if SETTING_NO_OUT_PIC_PRIOR 
     1186  m_bFirstSliceInBitstream  = false;
     1187#endif
    10581188#if POC_RESET_FLAG
    10591189  // This operation would do the following:
     
    12161346#endif
    12171347
    1218 #if !NO_OUTPUT_OF_PRIOR_PICS
    1219 #if NO_CLRAS_OUTPUT_FLAG
    1220     if (m_layerId == 0 &&
    1221         (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
    1222       || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    1223       || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
    1224       || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL
    1225       || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP
    1226       || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA))
    1227     {
    1228       if (bFirstSliceInSeq)
    1229       {
    1230         setNoClrasOutputFlag(true);
    1231       }
    1232       else if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
    1233             || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    1234             || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP)
    1235       {
    1236         setNoClrasOutputFlag(true);
    1237       }
    1238 #if O0149_CROSS_LAYER_BLA_FLAG
    1239       else if ((m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP) &&
    1240                m_apcSlicePilot->getCrossLayerBLAFlag())
    1241       {
    1242         setNoClrasOutputFlag(true);
    1243       }
    1244 #endif
    1245       else
    1246       {
    1247         setNoClrasOutputFlag(false);
    1248       }
    1249       if (getNoClrasOutputFlag())
    1250       {
    1251         for (UInt i = 0; i < m_apcSlicePilot->getVPS()->getMaxLayers(); i++)
    1252         {
    1253           m_ppcTDecTop[i]->setLayerInitializedFlag(false);
    1254           m_ppcTDecTop[i]->setFirstPicInLayerDecodedFlag(false);
    1255         }
    1256       }
    1257     }
    1258 #endif
    1259 
    1260 #if NO_CLRAS_OUTPUT_FLAG
    1261     m_apcSlicePilot->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, m_cListPic, getNoClrasOutputFlag());
    1262 #endif
    1263 #else
     1348#if NO_OUTPUT_OF_PRIOR_PICS
    12641349    if ( m_layerId == 0 && m_apcSlicePilot->getRapPicFlag() && getNoClrasOutputFlag() )
    12651350    {
     
    12731358    // Buffer initialize for prediction.
    12741359    m_cPrediction.initTempBuff();
    1275 #if !ALIGNED_BUMPING
     1360#if ALIGNED_BUMPING
     1361    m_apcSlicePilot->checkLeadingPictureRestrictions(m_cListPic);
     1362#else
    12761363    m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS());
    1277 #else
    1278     m_apcSlicePilot->checkLeadingPictureRestrictions(m_cListPic);
    12791364#endif
    12801365    //  Get a new picture buffer
     
    15151600        Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth();
    15161601        Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight();
    1517 
     1602#if Q0200_CONFORMANCE_BL_SIZE
     1603        Int chromaFormatIdc = pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getChromaFormatIdc();
     1604        const Window &confBL = pcSlice->getBaseColPic(refLayerIdc)->getConformanceWindow();
     1605        widthBL  -= ( confBL.getWindowLeftOffset() + confBL.getWindowRightOffset() ) * TComSPS::getWinUnitX( chromaFormatIdc );
     1606        heightBL -= ( confBL.getWindowTopOffset() + confBL.getWindowBottomOffset() ) * TComSPS::getWinUnitY( chromaFormatIdc );
     1607#endif
    15181608        Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
    15191609        Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     
    15251615        g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;
    15261616
     1617#if Q0048_CGS_3D_ASYMLUT
     1618        TComPicYuv* pBaseColRec = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec();
     1619        if( pcSlice->getPPS()->getCGSFlag() )
     1620        {
     1621          if(!m_pColorMappedPic)
     1622          {
     1623            initAsymLut(pcSlice->getBaseColPic(refLayerIdc)->getSlice(0));
     1624          }
     1625          m_c3DAsymLUTPPS.colorMapping( pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(),  m_pColorMappedPic );
     1626          pBaseColRec = m_pColorMappedPic;
     1627        }
     1628#endif
    15271629#if SVC_UPSAMPLING
    15281630        if( pcPic->isSpatialEnhLayer(refLayerIdc) )
    15291631        {   
    1530 /*#if O0098_SCALED_REF_LAYER_ID
    1531           Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc));
    1532 #else
    1533           Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc);
    1534 #endif*/
    15351632#if O0215_PHASE_ALIGNMENT
    15361633#if O0194_JOINT_US_BITSHIFT
    1537           m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
     1634#if Q0048_CGS_3D_ASYMLUT
     1635          m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
     1636#else
     1637          m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
     1638#endif
     1639#else
     1640#if Q0048_CGS_3D_ASYMLUT
     1641          m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );
    15381642#else
    15391643          m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
    15401644#endif
     1645#endif
    15411646#else
    15421647#if O0194_JOINT_US_BITSHIFT
     1648#if Q0048_CGS_3D_ASYMLUT
     1649          m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
     1650#else
    15431651          m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
     1652#endif
     1653#else
     1654#if Q0048_CGS_3D_ASYMLUT
     1655          m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
    15441656#else
    15451657          m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
     1658#endif
    15461659#endif
    15471660#endif
     
    17551868}
    17561869
    1757 Void TDecTop::xDecodePPS()
     1870Void TDecTop::xDecodePPS(
     1871#if Q0048_CGS_3D_ASYMLUT
     1872  TCom3DAsymLUT * pc3DAsymLUT
     1873#endif
     1874  )
    17581875{
    17591876  TComPPS* pps = new TComPPS();
     
    17631880#endif
    17641881
    1765   m_cEntropyDecoder.decodePPS( pps );
     1882  m_cEntropyDecoder.decodePPS( pps
     1883#if Q0048_CGS_3D_ASYMLUT
     1884    , pc3DAsymLUT , m_layerId
     1885#endif
     1886    );
    17661887  m_parameterSetManagerDecoder.storePrefetchedPPS( pps );
    17671888
     
    18091930      SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin());
    18101931      m_parameterSetManagerDecoder.applyPrefetchedPS();
    1811       assert(seiAps->activeSeqParamSetId.size()>0);
    1812       if( !m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParamSetId[0] ) )
     1932      assert(seiAps->activeSeqParameterSetId.size()>0);
     1933      if( !m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[0] ) )
    18131934      {
    18141935        printf ("Warning SPS activation with Active parameter set SEI failed");
    18151936      }
    18161937    }
     1938#if Q0074_SEI_COLOR_MAPPING
     1939    m_ColorMapping->setColorMapping( m_SEIs );
     1940#endif
    18171941  }
    18181942#else
     
    18371961      SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin());
    18381962      m_parameterSetManagerDecoder.applyPrefetchedPS();
    1839       assert(seiAps->activeSeqParamSetId.size()>0);
    1840       if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0] ))
     1963      assert(seiAps->activeSeqParameterSetId.size()>0);
     1964      if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParameterSetId[0] ))
    18411965      {
    18421966        printf ("Warning SPS activation with Active parameter set SEI failed");
     
    18972021    case NAL_UNIT_SPS:
    18982022      xDecodeSPS();
    1899 #if AVC_BASE
    1900       if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
    1901       {
    1902         TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
    1903         if( nalu.m_layerId == 1 && pBLPic->getPicYuvRec() == NULL )
    1904         {
    1905           // using EL SPS with spsId = 1
    1906           TComSPS* sps = m_parameterSetManagerDecoder.getPrefetchedSPS(1);
    1907           Int  numReorderPics[MAX_TLAYER];
    1908           Window &conformanceWindow = sps->getConformanceWindow();
    1909           Window defaultDisplayWindow = sps->getVuiParametersPresentFlag() ? sps->getVuiParameters()->getDefaultDisplayWindow() : Window();
    1910 #if AUXILIARY_PICTURES
    1911 #if SVC_UPSAMPLING
    1912 #if AVC_SYNTAX
    1913           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, sps, true);
    1914 #else
    1915           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
    1916 #endif
    1917 #else
    1918           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), onformanceWindow, defaultDisplayWindow, numReorderPics, true);
    1919 #endif
    1920 #else
    1921 #if SVC_UPSAMPLING
    1922 #if AVC_SYNTAX
    1923           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, sps, true);
    1924 #else
    1925           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
    1926 #endif
    1927 #else
    1928           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), onformanceWindow, defaultDisplayWindow, numReorderPics, true);
    1929 #endif
    1930 #endif
    1931 
    1932 #if O0194_DIFFERENT_BITDEPTH_EL_BL
    1933           // set AVC BL bit depth, can be an input parameter from the command line
    1934           g_bitDepthYLayer[0] = 8;
    1935           g_bitDepthCLayer[0] = 8;
    1936 #endif
    1937         }
    1938       }
    1939 #endif
    19402023      return false;
    19412024
    19422025    case NAL_UNIT_PPS:
    1943       xDecodePPS();
     2026      xDecodePPS(
     2027#if Q0048_CGS_3D_ASYMLUT
     2028        &m_c3DAsymLUTPPS
     2029#endif
     2030        );
    19442031      return false;
    19452032     
     
    19972084      return false;
    19982085     
     2086    case NAL_UNIT_FILLER_DATA:
     2087      return false;
    19992088     
    20002089    case NAL_UNIT_RESERVED_VCL_N10:
     
    20172106    case NAL_UNIT_RESERVED_VCL31:
    20182107     
    2019     case NAL_UNIT_FILLER_DATA:
    20202108    case NAL_UNIT_RESERVED_NVCL41:
    20212109    case NAL_UNIT_RESERVED_NVCL42:
     
    23042392}
    23052393#endif
     2394
     2395#if Q0048_CGS_3D_ASYMLUT
     2396Void TDecTop::initAsymLut(TComSlice *pcSlice)
     2397{
     2398  if(m_layerId>0)
     2399  {
     2400    if(!m_pColorMappedPic)
     2401    {
     2402      Int picWidth    = pcSlice->getPicWidthInLumaSamples();
     2403      Int picHeight   = pcSlice->getPicHeightInLumaSamples();
     2404      m_pColorMappedPic = new TComPicYuv;
     2405      m_pColorMappedPic->create( picWidth, picHeight, pcSlice->getChromaFormatIdc()/*CHROMA_420*/, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL );
     2406    }
     2407  }
     2408}
     2409#endif
     2410
    23062411#endif //SVC_EXTENSION
     2412
     2413#if Q0074_SEI_COLOR_MAPPING
     2414TDecColorMapping::TDecColorMapping()
     2415{
     2416  m_pcColorMappingPic[0]   = NULL;
     2417  m_pcColorMappingPic[1]   = NULL;
     2418
     2419  m_colorMapCancelFlag  = true;
     2420
     2421  for( Int i=0 ; i<3 ; i++ )
     2422  {
     2423    m_lut1d_computed[i]             = false;
     2424    m_lut1d_input[i]                = NULL;
     2425    m_coded_input_pivot_value[i]    = NULL;
     2426    m_target_input_pivot_value[i]   = NULL;
     2427  }
     2428  for( Int i=0 ; i<3 ; i++ )
     2429  {
     2430    m_lut1d_output[i]               = NULL;
     2431    m_coded_output_pivot_value[i]   = NULL;
     2432    m_target_output_pivot_value[i]  = NULL;
     2433  }
     2434}
     2435
     2436TDecColorMapping::~TDecColorMapping()
     2437{
     2438  if ( m_pcColorMappingPic[0] )  delete m_pcColorMappingPic[0];
     2439  if ( m_pcColorMappingPic[1] )  delete m_pcColorMappingPic[1];
     2440
     2441  for( Int i=0 ; i<3 ; i++ )
     2442  {
     2443    if ( m_lut1d_input[i] )               delete  m_lut1d_input[i];
     2444    if ( m_coded_input_pivot_value[i] )   delete  m_coded_input_pivot_value[i];
     2445    if ( m_target_input_pivot_value[i] )  delete  m_target_input_pivot_value[i];
     2446  }
     2447  for( Int i=0 ; i<3 ; i++ )
     2448  {
     2449    if ( m_lut1d_output[i] )               delete  m_lut1d_output[i];
     2450    if ( m_coded_output_pivot_value[i] )   delete  m_coded_output_pivot_value[i];
     2451    if ( m_target_output_pivot_value[i] )  delete  m_target_output_pivot_value[i];
     2452  }
     2453}
     2454
     2455Void  TDecColorMapping::setColorMapping( SEIMessages m_SEIs )
     2456{
     2457  SEIMessages colorMappingInfo = getSeisByType(m_SEIs, SEI::COLOR_MAPPING_INFO) ;
     2458  SEIColorMappingInfo *seiColorMappingInfo = NULL;
     2459  if (colorMappingInfo.size() !=0)
     2460  {
     2461    seiColorMappingInfo = (SEIColorMappingInfo*)(*colorMappingInfo.begin());
     2462
     2463    m_colorMapId                              = seiColorMappingInfo->m_colorMapId;
     2464    m_colorMapCancelFlag                      = seiColorMappingInfo->m_colorMapCancelFlag;
     2465    if( !m_colorMapCancelFlag )
     2466    {
     2467      m_colorMapPersistenceFlag                 = seiColorMappingInfo->m_colorMapPersistenceFlag;
     2468      m_colorMap_video_signal_type_present_flag = seiColorMappingInfo->m_colorMap_video_signal_type_present_flag;
     2469      m_colorMap_video_full_range_flag          = seiColorMappingInfo->m_colorMap_video_full_range_flag;
     2470      m_colorMap_primaries                      = seiColorMappingInfo->m_colorMap_primaries;
     2471      m_colorMap_transfer_characteristics       = seiColorMappingInfo->m_colorMap_transfer_characteristics;
     2472      m_colorMap_matrix_coeffs                  = seiColorMappingInfo->m_colorMap_matrix_coeffs;
     2473      m_colorMapModelId                         = seiColorMappingInfo->m_colorMapModelId;
     2474
     2475      m_colour_map_coded_data_bit_depth         = seiColorMappingInfo->m_colour_map_coded_data_bit_depth;
     2476      m_colour_map_target_bit_depth             = seiColorMappingInfo->m_colour_map_target_bit_depth;
     2477
     2478      for( Int i=0 ; i<3 ; i++ )
     2479      {
     2480        m_num_input_pivots[i]                 = seiColorMappingInfo->m_num_input_pivots[i];
     2481        if ( m_coded_input_pivot_value[i] )   delete  m_coded_input_pivot_value[i];
     2482        if ( m_target_input_pivot_value[i] )  delete  m_target_input_pivot_value[i];
     2483        m_coded_input_pivot_value[i]          = new Int[ m_num_input_pivots[i] ];
     2484        m_target_input_pivot_value[i]         = new Int[ m_num_input_pivots[i] ];
     2485        for( Int j=0 ; j<m_num_input_pivots[i] ; j++ )
     2486        {
     2487          m_coded_input_pivot_value[i][j]     = seiColorMappingInfo->m_coded_input_pivot_value[i][j];
     2488          m_target_input_pivot_value[i][j]    = seiColorMappingInfo->m_target_input_pivot_value[i][j];
     2489        }
     2490      }
     2491
     2492      m_matrix_flag       = seiColorMappingInfo->m_matrix_flag;
     2493      m_log2_matrix_denom = m_matrix_flag ? (seiColorMappingInfo->m_log2_matrix_denom) : (0) ;
     2494      for( Int i=0 ; i<3 ; i++ )
     2495      {
     2496        for( Int j=0 ; j<3 ; j++ )
     2497        {
     2498          m_matrix_coef[i][j]  = seiColorMappingInfo->m_matrix_coef[i][j];
     2499        }
     2500      }
     2501
     2502      for( Int i=0 ; i<3 ; i++ )
     2503      {
     2504        m_num_output_pivots[i]                 = seiColorMappingInfo->m_num_output_pivots[i];
     2505        if ( m_coded_output_pivot_value[i] )   delete  m_coded_output_pivot_value[i];
     2506        if ( m_target_output_pivot_value[i] )  delete  m_target_output_pivot_value[i];
     2507        m_coded_output_pivot_value[i]          = new Int[ m_num_output_pivots[i] ];
     2508        m_target_output_pivot_value[i]         = new Int[ m_num_output_pivots[i] ];
     2509        for( Int j=0 ; j<m_num_output_pivots[i] ; j++ )
     2510        {
     2511          m_coded_output_pivot_value[i][j]     = seiColorMappingInfo->m_coded_output_pivot_value[i][j];
     2512          m_target_output_pivot_value[i][j]    = seiColorMappingInfo->m_target_output_pivot_value[i][j];
     2513        }
     2514      }
     2515
     2516      memset( m_lut1d_computed, 0, sizeof( m_lut1d_computed ) );
     2517    }
     2518  }
     2519
     2520}
     2521
     2522Void  TDecColorMapping::setColorMapping( Int bitDepth, Int iComp )
     2523{
     2524  if( !m_colorMapCancelFlag && !m_lut1d_computed[iComp] )
     2525  {
     2526
     2527    if ( m_lut1d_input[iComp] )   delete m_lut1d_input[iComp];
     2528    if ( m_lut1d_output[iComp] )  delete m_lut1d_output[iComp];
     2529
     2530    m_lut1d_input[iComp]  = new Int[ 1 << bitDepth ];
     2531    m_lut1d_output[iComp] = new Int[ 1 << bitDepth ];
     2532
     2533    Int iShift      = (m_colour_map_coded_data_bit_depth >= bitDepth) ? (m_colour_map_coded_data_bit_depth - bitDepth) : (0);
     2534    Int iShiftPivot = (m_colour_map_coded_data_bit_depth >= bitDepth) ? (0) : (bitDepth - m_colour_map_coded_data_bit_depth);
     2535
     2536    for( Int k=0 ; k<(1<<bitDepth) ; k++ )
     2537    {
     2538      Int iSample = k << iShift ;
     2539      if( m_num_input_pivots[iComp] > 1 )
     2540      {
     2541        for( Int iPivot=0 ; iPivot<m_num_input_pivots[iComp] ; iPivot++ )
     2542        {
     2543          Int iCodedPrev  = m_coded_input_pivot_value[iComp][iPivot]     << iShiftPivot;
     2544          Int iCodedNext  = m_coded_input_pivot_value[iComp][iPivot+1]   << iShiftPivot;
     2545          Int iTargetPrev = m_target_input_pivot_value[iComp][iPivot]    << iShiftPivot;
     2546          Int iTargetNext = m_target_input_pivot_value[iComp][iPivot+1]  << iShiftPivot;
     2547          if ( iCodedPrev <= iSample && iSample < iCodedNext )
     2548          {
     2549            Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) / (Float)(iCodedNext - iCodedPrev) ;
     2550            m_lut1d_input[iComp][k]  = (Int)( 0.5 + fInterpol );
     2551            iPivot = m_num_input_pivots[iComp]; // stop
     2552          }
     2553        }
     2554      }
     2555      else
     2556      {
     2557        m_lut1d_input[iComp][k]  = k;
     2558      }
     2559    }
     2560
     2561    iShift      = ( (m_colour_map_coded_data_bit_depth >= bitDepth) ? (m_colour_map_coded_data_bit_depth - bitDepth) : (0) );
     2562    Int iOffset = iShift ? (1 << (iShift - 1)) : (0) ;
     2563    iShiftPivot = (m_colour_map_target_bit_depth >= bitDepth) ? (0) : (bitDepth - m_colour_map_target_bit_depth) ;
     2564    for( Int k=0 ; k<(1<<bitDepth) ; k++ )
     2565    {
     2566      Int iSample = k << iShift;
     2567      if ( m_num_output_pivots[iComp]>1 )
     2568      {
     2569        for( Int iPivot=0 ; iPivot<m_num_output_pivots[iComp] ; iPivot++ )
     2570        {
     2571          Int iCodedPrev  = m_coded_output_pivot_value[iComp][iPivot]     << iShiftPivot;
     2572          Int iCodedNext  = m_coded_output_pivot_value[iComp][iPivot+1]   << iShiftPivot;
     2573          Int iTargetPrev = m_target_output_pivot_value[iComp][iPivot]    << iShiftPivot;
     2574          Int iTargetNext = m_target_output_pivot_value[iComp][iPivot+1]  << iShiftPivot;
     2575          if ( iCodedPrev <= iSample && iSample < iCodedNext )
     2576          {
     2577            Float fInterpol =  (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) / (Float)(iCodedNext - iCodedPrev) ;
     2578            m_lut1d_output[iComp][k]  = ( (Int)(0.5 + fInterpol) + iOffset ) >> iShift ;
     2579            iPivot = m_num_output_pivots[iComp]; // stop
     2580          }
     2581        }
     2582      }
     2583      else
     2584      {
     2585        m_lut1d_output[iComp][k]  = k;
     2586      }
     2587    }
     2588
     2589    m_lut1d_computed[iComp] = true;
     2590  }
     2591
     2592}
     2593
     2594TComPicYuv* TDecColorMapping::getColorMapping( TComPicYuv* pPicYuvRec, Int iTop, Int curlayerId )
     2595{
     2596  if( !m_colorMapCancelFlag )
     2597  {
     2598    if( !m_pcColorMappingPic[iTop] )
     2599    {
     2600      m_pcColorMappingPic[iTop] = new TComPicYuv;
     2601#if SVC_EXTENSION
     2602      m_pcColorMappingPic[iTop]->create( pPicYuvRec->getWidth(), pPicYuvRec->getHeight(), pPicYuvRec->getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
     2603#else
     2604      m_pcColorMappingPic[iTop]->create( pPicYuvRec->getWidth(), pPicYuvRec->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
     2605#endif
     2606    }
     2607
     2608    Int iHeight   = pPicYuvRec->getHeight();
     2609    Int iWidth    = pPicYuvRec->getWidth();
     2610    Int iStride   = pPicYuvRec->getStride();
     2611    Int iCStride  = pPicYuvRec->getCStride();
     2612
     2613    Pel* Lum0   = pPicYuvRec->getLumaAddr();
     2614    Pel* Cb0    = pPicYuvRec->getCbAddr();
     2615    Pel* Cr0    = pPicYuvRec->getCrAddr();
     2616    Pel* Lum1   = m_pcColorMappingPic[iTop]->getLumaAddr();
     2617    Pel* Cb1    = m_pcColorMappingPic[iTop]->getCbAddr();
     2618    Pel* Cr1    = m_pcColorMappingPic[iTop]->getCrAddr();
     2619
     2620#if SVC_EXTENSION
     2621    Int bitDepthY = g_bitDepthYLayer[curlayerId];
     2622    Int bitDepthC = g_bitDepthCLayer[curlayerId];
     2623
     2624    assert( g_bitDepthY == bitDepthY );
     2625    assert( g_bitDepthC == bitDepthC );
     2626#else
     2627    Int bitDepthY = g_bitDepthY;
     2628    Int bitDepthC = g_bitDepthC;
     2629#endif
     2630
     2631    Int iYShift = (m_colour_map_target_bit_depth >= bitDepthY) ? (m_colour_map_target_bit_depth - bitDepthY) : (0) ;
     2632    Int iCShift = (m_colour_map_target_bit_depth >= bitDepthC) ? (m_colour_map_target_bit_depth - bitDepthC) : (0) ;
     2633    Int offsetY = (1 << (m_log2_matrix_denom+iYShift - 1));
     2634    Int offsetC = (1 << (m_log2_matrix_denom+iCShift - 1));
     2635
     2636    Int   cShift  = 1 ;
     2637
     2638    //Pel*  LumPrev0 = Lum0;
     2639    for( Int y = 0; y < iHeight ; y++ )
     2640    {
     2641      Bool  bDoChroma = (y % 2);
     2642      for( Int x = 0; x < iWidth ; x++ )
     2643      {
     2644        Int s1Y = m_lut1d_input[0][ Lum0[x]   ];
     2645        Int s1U = m_lut1d_input[1][ Cb0[x>>1] ];
     2646        Int s1V = m_lut1d_input[2][ Cr0[x>>1] ];
     2647
     2648        Int s2Y, s2U, s2V;
     2649        if( m_matrix_flag )
     2650        {
     2651          s2Y = ( m_matrix_coef[0][0]*s1Y + m_matrix_coef[0][1]*s1U + m_matrix_coef[0][2]*s1V + offsetY ) >> ( m_log2_matrix_denom + iYShift );
     2652          //s2Y = ClipBD( s2Y , bitDepthY );
     2653          s2Y = ClipY( s2Y );
     2654          Lum1[x]   = m_lut1d_output[0][ s2Y ];
     2655        }
     2656        else
     2657        {
     2658          s1Y       = ( s1Y + offsetY ) >> iYShift ;
     2659          //s1Y = ClipBD( s1Y , bitDepthY );
     2660          s1Y = ClipY( s1Y );
     2661          Lum1[x]   = m_lut1d_output[0][ s1Y ];
     2662        }
     2663
     2664        if( bDoChroma && (x%2) )
     2665        {
     2666          if( m_matrix_flag )
     2667          {
     2668            //s1Y = ( m_lut1d_input[0][ Lum0[x] ] + m_lut1d_input[0][ Lum0[x+1] ] + m_lut1d_input[0][ LumPrev0[x] ] + m_lut1d_input[0][ LumPrev0[x+1] ] + 2 ) >> 2 ;
     2669            //s1Y = m_lut1d_input[0][ (Lum0[x] + Lum0[x+1] + LumPrev0[x] + LumPrev0[x+1] + 2)>>2 ] ;
     2670            s1Y = m_lut1d_input[0][ Lum0[x] ];
     2671
     2672            s2U = ( m_matrix_coef[1][0]*s1Y + m_matrix_coef[1][1]*s1U + m_matrix_coef[1][2]*s1V + offsetC ) >> ( m_log2_matrix_denom + iCShift ) ;
     2673            s2V = ( m_matrix_coef[2][0]*s1Y + m_matrix_coef[2][1]*s1U + m_matrix_coef[2][2]*s1V + offsetC ) >> ( m_log2_matrix_denom + iCShift ) ;
     2674            //s2U = ClipBD( s2U , bitDepthC );
     2675            //s2V = ClipBD( s2V , bitDepthC );
     2676            s2U = ClipC( s2U );
     2677            s2V = ClipC( s2V );
     2678            Cb1[x>>cShift] = m_lut1d_output[1][ s2U ];
     2679            Cr1[x>>cShift] = m_lut1d_output[2][ s2V ];
     2680          }
     2681          else
     2682          {
     2683            s1U       = ( s1U + offsetC ) >> iCShift ;
     2684            s1V       = ( s1V + offsetC ) >> iCShift ;
     2685            //s1U = ClipBD( s1U , bitDepthC );
     2686            //s1V = ClipBD( s1V , bitDepthC );
     2687            s1U = ClipC( s1U );
     2688            s1V = ClipC( s1V );
     2689            Cb1[x>>cShift] = m_lut1d_output[1][ s1U ];
     2690            Cr1[x>>cShift] = m_lut1d_output[2][ s1V ];
     2691          }
     2692        }
     2693
     2694      }
     2695
     2696      //LumPrev0 = Lum0;
     2697      Lum0  += iStride;
     2698      Lum1  += iStride;
     2699      if( bDoChroma )
     2700      {
     2701        Cb0 += iCStride;
     2702        Cr0 += iCStride;
     2703        Cb1 += iCStride;
     2704        Cr1 += iCStride;
     2705      }
     2706    }
     2707
     2708    return m_pcColorMappingPic[iTop];
     2709  }
     2710
     2711  return pPicYuvRec;
     2712}
     2713#endif
     2714
    23072715//! \}
  • trunk/source/Lib/TLibDecoder/TDecTop.h

    r644 r713  
    4545#include "TLibCommon/TComTrQuant.h"
    4646#include "TLibCommon/SEI.h"
     47#if Q0048_CGS_3D_ASYMLUT
     48#include "TLibCommon/TCom3DAsymLUT.h"
     49#endif
    4750
    4851#include "TDecGop.h"
     
    6164// ====================================================================================================================
    6265
     66#if Q0074_SEI_COLOR_MAPPING
     67class TDecColorMapping
     68{
     69  Int   m_colorMapId;
     70  Bool  m_colorMapCancelFlag;
     71  Bool  m_colorMapPersistenceFlag;
     72  Bool  m_colorMap_video_signal_type_present_flag;
     73  Bool  m_colorMap_video_full_range_flag;
     74  Int   m_colorMap_primaries;
     75  Int   m_colorMap_transfer_characteristics;
     76  Int   m_colorMap_matrix_coeffs;
     77  Int   m_colorMapModelId;
     78
     79  Int   m_colour_map_coded_data_bit_depth;
     80  Int   m_colour_map_target_bit_depth;
     81
     82  Int   m_num_input_pivots[3];
     83  Int*  m_coded_input_pivot_value[3];
     84  Int*  m_target_input_pivot_value[3];
     85 
     86  Bool  m_matrix_flag;
     87  Int   m_log2_matrix_denom;
     88  Int   m_matrix_coef[3][3];
     89
     90  Int   m_num_output_pivots[3];
     91  Int*  m_coded_output_pivot_value[3];
     92  Int*  m_target_output_pivot_value[3];
     93
     94  Bool  m_lut1d_computed[3];
     95  Int*  m_lut1d_input[3];
     96  Int*  m_lut1d_output[3];
     97  TComPicYuv* m_pcColorMappingPic[2];
     98
     99public:
     100  TDecColorMapping();
     101  ~TDecColorMapping();
     102
     103  Bool        getColorMappingFlag()                     { return(!m_colorMapCancelFlag);};
     104
     105  Void        setColorMapping( SEIMessages m_SEIs );
     106  Void        setColorMapping( Int bitDepthY, Int bitDepthC );
     107  TComPicYuv* getColorMapping( TComPicYuv* pPicYuvRec, Int iTop=0, Int curlayerId=0 );
     108};// END CLASS DEFINITION TDecColorMapping
     109#endif
     110
    63111/// decoder class
    64112class TDecTop
     
    79127  // functional classes
    80128  TComPrediction          m_cPrediction;
     129#if Q0048_CGS_3D_ASYMLUT
     130  TCom3DAsymLUT           m_c3DAsymLUTPPS;
     131  TComPicYuv*             m_pColorMappedPic;
     132#endif
    81133  TComTrQuant             m_cTrQuant;
    82134  TDecGop                 m_cGopDecoder;
     
    104156  Bool                    m_prevSliceSkipped;
    105157  Int                     m_skippedPOC;
     158#if SETTING_NO_OUT_PIC_PRIOR 
     159  Bool                    m_bFirstSliceInBitstream;
     160  Int                     m_lastPOCNoOutputPriorPics;
     161  Bool                    m_isNoOutputPriorPics;
     162  Bool                    m_craNoRaslOutputFlag;    //value of variable NoRaslOutputFlag of the last CRA pic
     163#endif
    106164
    107165#if SVC_EXTENSION
     
    114172#if AVC_BASE
    115173  fstream*                m_pBLReconFile;
     174#if !REPN_FORMAT_IN_VPS
    116175  Int                     m_iBLSourceWidth;
    117   Int                     m_iBLSourceHeight; 
     176  Int                     m_iBLSourceHeight;
     177#endif
    118178#endif
    119179#if VPS_EXTN_DIRECT_REF_LAYERS
     
    136196#endif
    137197
    138 #if NO_CLRAS_OUTPUT_FLAG
     198#if NO_CLRAS_OUTPUT_FLAG 
    139199  Bool                    m_noClrasOutputFlag;
    140200  Bool                    m_layerInitializedFlag;
    141201  Bool                    m_firstPicInLayerDecodedFlag;
    142   Bool                    m_noOutputOfPriorPicsFlags;
    143 
    144   Bool                   m_bRefreshPending;
    145202#endif
    146203#if RESOLUTION_BASED_DPB
    147   Int                    m_subDpbIdx;     // Index to the sub-DPB that the layer belongs to.
    148                                           // When new VPS is activated, this should be re-initialized to -1
     204  Int                     m_subDpbIdx;     // Index to the sub-DPB that the layer belongs to.
     205                                           // When new VPS is activated, this should be re-initialized to -1
    149206#endif
    150207public:
     208#if Q0074_SEI_COLOR_MAPPING
     209  TDecColorMapping* m_ColorMapping;
     210#endif
     211
    151212  TDecTop();
    152213  virtual ~TDecTop();
     
    166227  Void  deletePicBuffer();
    167228
     229 
     230  TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS(); }
     231
     232
    168233  Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
     234#if SETTING_NO_OUT_PIC_PRIOR 
     235  Void  checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic);
     236  Bool  getNoOutputPriorPicsFlag ()         { return m_isNoOutputPriorPics; }
     237  Void  setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; }
     238#endif
     239
    169240#if SVC_EXTENSION
    170241#if EARLY_REF_PIC_MARKING
     
    212283  Void      setBLReconFile( fstream* pFile ) { m_pBLReconFile = pFile; }
    213284  fstream*  getBLReconFile() { return m_pBLReconFile; }
     285#if !REPN_FORMAT_IN_VPS
    214286  Void      setBLsize( Int iWidth, Int iHeight ) { m_iBLSourceWidth = iWidth; m_iBLSourceHeight = iHeight; }
    215287  Int       getBLWidth() { return  m_iBLSourceWidth; }
    216288  Int       getBLHeight() { return  m_iBLSourceHeight; }
     289#endif
    217290#endif
    218291#if REPN_FORMAT_IN_VPS
     
    238311  Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
    239312  fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; }
    240 #endif
    241 #if NO_OUTPUT_OF_PRIOR_PICS
    242 #if NO_CLRAS_OUTPUT_FLAG
    243   Bool getNoOutputOfPriorPicsFlags()         { return m_noOutputOfPriorPicsFlags;}
    244   Void setNoOutputOfPriorPicsFlags(Bool x)   { m_noOutputOfPriorPicsFlags = x;   }
    245 #endif
    246313#endif
    247314protected:
     
    261328  Void      xDecodeVPS();
    262329  Void      xDecodeSPS();
    263   Void      xDecodePPS();
     330  Void      xDecodePPS(
     331#if Q0048_CGS_3D_ASYMLUT
     332    TCom3DAsymLUT * pc3DAsymLUT
     333#endif
     334    );
    264335  Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
    265336
     
    271342  Int  getFirstPicInLayerDecodedFlag()       { return m_firstPicInLayerDecodedFlag;}
    272343  Void setFirstPicInLayerDecodedFlag(Bool x) { m_firstPicInLayerDecodedFlag = x;   }
    273 #if !NO_OUTPUT_OF_PRIOR_PICS
    274   Int  getNoOutputOfPriorPicsFlags()         { return m_noOutputOfPriorPicsFlags;}
    275   Void setNoOutputOfPriorPicsFlags(Bool x)   { m_noOutputOfPriorPicsFlags = x;   }
    276 #endif
     344#endif
     345#if Q0048_CGS_3D_ASYMLUT
     346  Void initAsymLut(TComSlice *pcSlice);
    277347#endif
    278348};// END CLASS DEFINITION TDecTop
  • trunk/source/Lib/TLibEncoder/AnnexBwrite.h

    r595 r713  
    5858
    5959    static const Char start_code_prefix[] = {0,0,0,1};
    60     if (it == au.begin() || nalu.m_nalUnitType == NAL_UNIT_SPS || nalu.m_nalUnitType == NAL_UNIT_PPS)
     60    if (it == au.begin() || nalu.m_nalUnitType == NAL_UNIT_VPS || nalu.m_nalUnitType == NAL_UNIT_SPS || nalu.m_nalUnitType == NAL_UNIT_PPS)
    6161    {
    6262      /* From AVC, When any of the following conditions are fulfilled, the
  • trunk/source/Lib/TLibEncoder/NALwrite.cpp

    r595 r713  
    9191  vector<uint8_t>& rbsp   = nalu.m_Bitstream.getFIFO();
    9292
    93 #if P0130_EOB
    94   if (rbsp.size() == 0) return;
    95 #endif
     93  if (rbsp.size() == 0)
     94  {
     95    return;
     96  }
    9697
    9798  for (vector<uint8_t>::iterator it = rbsp.begin(); it != rbsp.end();)
  • trunk/source/Lib/TLibEncoder/SEIwrite.cpp

    r644 r713  
    8787    fprintf( g_hTrace, "=========== Tone Mapping Info SEI message ===========\n");
    8888    break;
     89#if Q0074_SEI_COLOR_MAPPING
     90  case SEI::COLOR_MAPPING_INFO:
     91    fprintf( g_hTrace, "=========== Color Mapping Info SEI message ===========\n");
     92    break;
     93#endif
    8994  case SEI::SOP_DESCRIPTION:
    9095    fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");
     
    172177    xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei));
    173178    break;
     179#if Q0074_SEI_COLOR_MAPPING
     180  case SEI::COLOR_MAPPING_INFO:
     181    xWriteSEIColorMappingInfo(*static_cast<const SEIColorMappingInfo*>(&sei));
     182    break;
     183#endif
    174184  case SEI::SOP_DESCRIPTION:
    175185    xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei));
     
    333343Void SEIWriter::xWriteSEIActiveParameterSets(const SEIActiveParameterSets& sei)
    334344{
    335   WRITE_CODE(sei.activeVPSId,     4, "active_vps_id");
    336   WRITE_FLAG(sei.m_fullRandomAccessFlag, "full_random_access_flag");
    337   WRITE_FLAG(sei.m_noParamSetUpdateFlag, "no_param_set_update_flag");
     345  WRITE_CODE(sei.activeVPSId,     4,         "active_video_parameter_set_id");
     346  WRITE_FLAG(sei.m_selfContainedCvsFlag,     "self_contained_cvs_flag");
     347  WRITE_FLAG(sei.m_noParameterSetUpdateFlag, "no_parameter_set_update_flag");
    338348  WRITE_UVLC(sei.numSpsIdsMinus1,    "num_sps_ids_minus1");
    339349
    340   assert (sei.activeSeqParamSetId.size() == (sei.numSpsIdsMinus1 + 1));
    341 
    342   for (Int i = 0; i < sei.activeSeqParamSetId.size(); i++)
    343   {
    344     WRITE_UVLC(sei.activeSeqParamSetId[i], "active_seq_param_set_id");
    345   }
    346 
    347   UInt uiBits = m_pcBitIf->getNumberOfWrittenBits();
    348   UInt uiAlignedBits = ( 8 - (uiBits&7) ) % 8; 
    349   if(uiAlignedBits)
    350   {
    351     WRITE_FLAG(1, "alignment_bit" );
    352     uiAlignedBits--;
    353     while(uiAlignedBits--)
    354     {
    355       WRITE_FLAG(0, "alignment_bit" );
    356     }
    357   }
     350  assert (sei.activeSeqParameterSetId.size() == (sei.numSpsIdsMinus1 + 1));
     351
     352  for (Int i = 0; i < sei.activeSeqParameterSetId.size(); i++)
     353  {
     354    WRITE_UVLC(sei.activeSeqParameterSetId[i], "active_seq_parameter_set_id");
     355  }
     356  xWriteByteAlign();
    358357}
    359358
     
    550549        {
    551550          WRITE_CODE( sei.m_cameraIsoSpeedValue,    32,    "camera_iso_speed_value" );
     551        }
     552        WRITE_CODE( sei.m_exposureIndexIdc,     8,    "exposure_index_idc" );
     553        if( sei.m_exposureIndexIdc == 255) //Extended_ISO
     554        {
     555          WRITE_CODE( sei.m_exposureIndexValue,     32,    "exposure_index_value" );
    552556        }
    553557        WRITE_FLAG( sei.m_exposureCompensationValueSignFlag,           "exposure_compensation_value_sign_flag" );
     
    572576}
    573577
     578#if Q0074_SEI_COLOR_MAPPING
     579Void SEIWriter::xWriteSEIColorMappingInfo(const SEIColorMappingInfo& sei)
     580{
     581  WRITE_UVLC( sei.m_colorMapId,                    "colour_map_id" );
     582  WRITE_FLAG( sei.m_colorMapCancelFlag,            "colour_map_cancel_flag" );
     583  if( !sei.m_colorMapCancelFlag )
     584  {
     585    WRITE_FLAG( sei.m_colorMapPersistenceFlag,            "colour_map_persistence_flag" );
     586    WRITE_FLAG( sei.m_colorMap_video_signal_type_present_flag,            "colour_map_video_signal_type_present_flag" );
     587    if ( sei.m_colorMap_video_signal_type_present_flag )
     588    {
     589      WRITE_FLAG( sei.m_colorMap_video_full_range_flag,       "colour_map_video_full_range_flag" );
     590      WRITE_CODE( sei.m_colorMap_primaries,                 8,      "colour_map_primaries" );
     591      WRITE_CODE( sei.m_colorMap_transfer_characteristics,  8,      "colour_map_transfer_characteristics" );
     592      WRITE_CODE( sei.m_colorMap_matrix_coeffs,             8,      "colour_map_matrix_coeffs" );
     593    }
     594  }
     595
     596  WRITE_CODE( sei.m_colour_map_coded_data_bit_depth,  5,  "colour_map_coded_data_bit_depth" );
     597  WRITE_CODE( sei.m_colour_map_target_bit_depth,  5,      "colour_map_target_bit_depth" );
     598  WRITE_UVLC( sei.m_colorMapModelId,                      "colour_map_model_id" );
     599
     600  assert( sei.m_colorMapModelId == 0 );
     601 
     602  for( Int i=0 ; i<3 ; i++ )
     603  {
     604    WRITE_CODE( sei.m_num_input_pivots[i] - 1,         8,      "num_input_pivots_minus1[i]" );
     605    for( Int j=0 ; j<sei.m_num_input_pivots[i] ; j++ )
     606    {
     607      WRITE_CODE( sei.m_coded_input_pivot_value[i][j],  (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "coded_input_pivot_value[i][j]" );
     608      WRITE_CODE( sei.m_target_input_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "target_input_pivot_value[i][j]" );
     609    }
     610  }
     611
     612  WRITE_FLAG( sei.m_matrix_flag,            "matrix_flag" );
     613  if( sei.m_matrix_flag )
     614  {
     615    WRITE_CODE( sei.m_log2_matrix_denom, 4, "log2_matrix_denom" );
     616    for( Int i=0 ; i<3 ; i++ )
     617    {
     618      for( Int j=0 ; j<3 ; j++ )
     619      {
     620        WRITE_SVLC( sei.m_matrix_coef[i][j],  "matrix_coef[i][j]" );
     621      }
     622    }
     623  }
     624
     625  for( Int i=0 ; i<3 ; i++ )
     626  {
     627    WRITE_CODE( sei.m_num_output_pivots[i] - 1,         8,      "num_output_pivots_minus1[i]" );
     628    for( Int j=0 ; j<sei.m_num_output_pivots[i] ; j++ )
     629    {
     630      WRITE_CODE( sei.m_coded_output_pivot_value[i][j],  (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "coded_output_pivot_value[i][j]" );
     631      WRITE_CODE( sei.m_target_output_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "target_output_pivot_value[i][j]" );
     632    }
     633  }
     634
     635  xWriteByteAlign();
     636}
     637#endif
     638
    574639Void SEIWriter::xWriteSEIDisplayOrientation(const SEIDisplayOrientation &sei)
    575640{
     
    633698    for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++)
    634699    {
     700      WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" );
    635701      WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3,  "nesting_max_temporal_id"       );
    636702      WRITE_UVLC( sei.m_nestingOpIdx[i],                  "nesting_op_idx"                );
  • trunk/source/Lib/TLibEncoder/SEIwrite.h

    r644 r713  
    7272  Void xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei);
    7373  Void xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei);
     74#if Q0074_SEI_COLOR_MAPPING
     75  Void xWriteSEIColorMappingInfo(const SEIColorMappingInfo& sei);
     76#endif
    7477  Void xWriteSEISOPDescription(const SEISOPDescription& sei);
    7578#if O0164_MULTI_LAYER_HRD
  • trunk/source/Lib/TLibEncoder/TEncCavlc.cpp

    r649 r713  
    154154
    155155
    156 Void TEncCavlc::codePPS( TComPPS* pcPPS )
     156Void TEncCavlc::codePPS( TComPPS* pcPPS
     157#if Q0048_CGS_3D_ASYMLUT
     158  , TEnc3DAsymLUT * pc3DAsymLUT
     159#endif
     160  )
    157161{
    158162#if ENC_DEC_TRACE 
     
    268272    {
    269273      WRITE_FLAG( pcPPS->getPocResetInfoPresentFlag() ? 1 : 0, "poc_reset_info_present_flag" );
     274#if Q0048_CGS_3D_ASYMLUT
     275      UInt uiPos = getNumberOfWrittenBits();
     276      WRITE_FLAG( pcPPS->getCGSFlag() , "colour_mapping_enabled_flag" );
     277      if( pcPPS->getCGSFlag() )
     278      {
     279        assert( pc3DAsymLUT != NULL );
     280        xCode3DAsymLUT( pc3DAsymLUT );
     281      }
     282      pc3DAsymLUT->setPPSBit( getNumberOfWrittenBits() - uiPos );
     283#endif
    270284#endif
    271285    }
     
    495509  if (conf.getWindowEnabledFlag())
    496510  {
     511#if REPN_FORMAT_IN_VPS
     512    WRITE_UVLC( conf.getWindowLeftOffset(),   "conf_win_left_offset"   );
     513    WRITE_UVLC( conf.getWindowRightOffset(),  "conf_win_right_offset"  );
     514    WRITE_UVLC( conf.getWindowTopOffset(),    "conf_win_top_offset"    );
     515    WRITE_UVLC( conf.getWindowBottomOffset(), "conf_win_bottom_offset" );
     516#else
    497517    WRITE_UVLC( conf.getWindowLeftOffset()   / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_left_offset" );
    498518    WRITE_UVLC( conf.getWindowRightOffset()  / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_right_offset" );
    499519    WRITE_UVLC( conf.getWindowTopOffset()    / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_top_offset" );
    500520    WRITE_UVLC( conf.getWindowBottomOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_bottom_offset" );
     521#endif
    501522  }
    502523
     
    777798    }
    778799  }
    779 #if !VPS_EXTNS
    780   WRITE_FLAG( 0,                     "vps_extension_flag" );
    781 #else
    782   WRITE_FLAG( 1,                     "vps_extension_flag" );
    783   if(1) // Should be conditioned on the value of vps_extension_flag
     800#if VPS_EXTNS
     801  // When MaxLayersMinus1 is greater than 0, vps_extension_flag shall be equal to 1.
     802  if( pcVPS->getMaxLayers() > 1 )
     803  {
     804    assert( pcVPS->getVpsExtensionFlag() == true );
     805  }
     806
     807  WRITE_FLAG( pcVPS->getVpsExtensionFlag() ? 1 : 0,                     "vps_extension_flag" );
     808
     809  if( pcVPS->getVpsExtensionFlag() )
    784810  {
    785811    while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
     
    797823    WRITE_FLAG( 0,                     "vps_extension2_flag" );   // Flag value of 1 reserved
    798824  }
     825#else
     826  WRITE_FLAG( 0,                     "vps_extension_flag" );
    799827#endif 
    800828  //future extensions here..
     
    9961024  }
    9971025#else
    998   Int numOutputLayerSets = vps->getNumOutputLayerSets() ;
    999   assert( numOutputLayerSets - (Int)vps->getNumLayerSets() >= 0 );
     1026  Int numOutputLayerSets = vps->getNumOutputLayerSets();
     1027  Int numAddOutputLayerSets = numOutputLayerSets - (Int)vps->getNumLayerSets();
     1028
     1029  // The value of num_add_output_layer_sets shall be in the range of 0 to 1023, inclusive.
     1030  assert( numAddOutputLayerSets >= 0 && numAddOutputLayerSets < 1024 );
     1031
     1032#if Q0165_NUM_ADD_OUTPUT_LAYER_SETS
     1033  if( vps->getNumLayerSets() > 1 )
     1034  {
     1035    WRITE_UVLC( numAddOutputLayerSets, "num_add_output_layer_sets" );
     1036    WRITE_CODE( vps->getDefaultTargetOutputLayerIdc(), 2, "default_target_output_layer_idc" );
     1037  }
     1038#else
    10001039  WRITE_UVLC( numOutputLayerSets - vps->getNumLayerSets(), "num_add_output_layer_sets" );
    10011040#endif
     1041#endif
     1042
     1043#if !Q0165_NUM_ADD_OUTPUT_LAYER_SETS
    10021044  if( numOutputLayerSets > 1 )
    10031045  {
     
    10121054#endif
    10131055  }
     1056#endif
    10141057
    10151058  for(i = 1; i < numOutputLayerSets; i++)
     
    10591102      WRITE_FLAG(vps->getAltOuputLayerFlag(i), "alt_output_layer_flag[i]");
    10601103    }
     1104
     1105#if Q0165_OUTPUT_LAYER_SET
     1106    assert( NumOutputLayersInOutputLayerSet[i]>0 );
     1107#endif
     1108
    10611109#endif
    10621110  }
     
    10721120
    10731121#if REPN_FORMAT_IN_VPS
     1122#if Q0195_REP_FORMAT_CLEANUP 
     1123  // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive.
     1124  assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 );
     1125 
     1126  WRITE_UVLC( vps->getVpsNumRepFormats() - 1, "vps_num_rep_formats_minus1" );
     1127
     1128  for(i = 0; i < vps->getVpsNumRepFormats(); i++)
     1129  {
     1130    // Write rep_format_structures
     1131    codeRepFormat( vps->getVpsRepFormat(i) );
     1132  }
     1133
     1134  if( vps->getVpsNumRepFormats() > 1 )
     1135  {
     1136    WRITE_FLAG( vps->getRepFormatIdxPresentFlag(), "rep_format_idx_present_flag");
     1137  }
     1138  else
     1139  {
     1140    // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0
     1141    assert( !vps->getRepFormatIdxPresentFlag() );
     1142  }
     1143
     1144  if( vps->getRepFormatIdxPresentFlag() )
     1145  {
     1146    for(i = 1; i < vps->getMaxLayers(); i++)
     1147    {
     1148      Int numBits = 1;
     1149      while ((1 << numBits) < (vps->getVpsNumRepFormats()))
     1150      {
     1151        numBits++;
     1152      }
     1153      WRITE_CODE( vps->getVpsRepFormatIdx(i), numBits, "vps_rep_format_idx[i]" );
     1154    }
     1155  }
     1156#else
    10741157  WRITE_FLAG( vps->getRepFormatIdxPresentFlag(), "rep_format_idx_present_flag");
    10751158
    10761159  if( vps->getRepFormatIdxPresentFlag() )
    10771160  {
     1161    // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive.
     1162    assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 );
     1163
    10781164#if O0096_REP_FORMAT_INDEX
    10791165#if !VPS_EXTN_UEV_CODING
     
    11151201    }
    11161202  }
     1203#endif
    11171204#endif
    11181205
     
    11811268
    11821269#if P0307_VPS_NON_VUI_EXTENSION
     1270  // The value of vps_non_vui_extension_length shall be in the range of 0 to 4096, inclusive.
     1271  assert( vps->getVpsNonVuiExtLength() >= 0 && vps->getVpsNonVuiExtLength() <= 4096 );
     1272
    11831273  WRITE_UVLC( vps->getVpsNonVuiExtLength(), "vps_non_vui_extension_length" );
    11841274#if P0307_VPS_NON_VUI_EXT_UPDATE
     
    12161306#else
    12171307#if P0307_REMOVE_VPS_VUI_OFFSET
    1218   WRITE_FLAG( 1,                     "vps_vui_present_flag" );
    12191308  vps->setVpsVuiPresentFlag(true);
     1309  WRITE_FLAG( vps->getVpsVuiPresentFlag() ? 1 : 0,                     "vps_vui_present_flag" );
    12201310#endif
    12211311  if(vps->getVpsVuiPresentFlag())   // Should be conditioned on the value of vps_vui_present_flag
     
    12381328#endif
    12391329#if REPN_FORMAT_IN_VPS
    1240 Void  TEncCavlc::codeRepFormat      ( RepFormat *repFormat )
     1330Void  TEncCavlc::codeRepFormat( RepFormat *repFormat )
    12411331{
    12421332#if REPN_FORMAT_CONTROL_FLAG
    1243    WRITE_FLAG ( repFormat->getChromaAndBitDepthVpsPresentFlag(), "chroma_and_bit_depth_vps_presenet_flag");
    1244 
    1245    WRITE_CODE ( repFormat->getPicWidthVpsInLumaSamples (), 16, "pic_width_in_luma_samples" );   
    1246    WRITE_CODE ( repFormat->getPicHeightVpsInLumaSamples(), 16, "pic_height_in_luma_samples" ); 
    1247 
    1248    if ( repFormat->getChromaAndBitDepthVpsPresentFlag() )
    1249    {
    1250      WRITE_CODE( repFormat->getChromaFormatVpsIdc(), 2, "chroma_format_idc" );   
    1251 
    1252      if( repFormat->getChromaFormatVpsIdc() == 3 )
    1253      {
    1254        WRITE_FLAG( repFormat->getSeparateColourPlaneVpsFlag(), "separate_colour_plane_flag");     
    1255      }
    1256 
    1257      assert( repFormat->getBitDepthVpsLuma() >= 8 );
    1258      assert( repFormat->getBitDepthVpsChroma() >= 8 );
    1259      WRITE_CODE( repFormat->getBitDepthVpsLuma() - 8,   4, "bit_depth_luma_minus8" );           
    1260      WRITE_CODE( repFormat->getBitDepthVpsChroma() - 8, 4, "bit_depth_chroma_minus8" );
    1261    }
     1333  WRITE_CODE( repFormat->getPicWidthVpsInLumaSamples (), 16, "pic_width_vps_in_luma_samples" );   
     1334  WRITE_CODE( repFormat->getPicHeightVpsInLumaSamples(), 16, "pic_height_vps_in_luma_samples" ); 
     1335  WRITE_FLAG( repFormat->getChromaAndBitDepthVpsPresentFlag(), "chroma_and_bit_depth_vps_present_flag" );
     1336
     1337  if( repFormat->getChromaAndBitDepthVpsPresentFlag() )
     1338  {
     1339    WRITE_CODE( repFormat->getChromaFormatVpsIdc(), 2, "chroma_format_vps_idc" );   
     1340
     1341    if( repFormat->getChromaFormatVpsIdc() == 3 )
     1342    {
     1343      WRITE_FLAG( repFormat->getSeparateColourPlaneVpsFlag(), "separate_colour_plane_vps_flag" );     
     1344    }
     1345
     1346    assert( repFormat->getBitDepthVpsLuma() >= 8 );
     1347    assert( repFormat->getBitDepthVpsChroma() >= 8 );
     1348    WRITE_CODE( repFormat->getBitDepthVpsLuma() - 8,   4, "bit_depth_vps_luma_minus8" );           
     1349    WRITE_CODE( repFormat->getBitDepthVpsChroma() - 8, 4, "bit_depth_vps_chroma_minus8" );
     1350  }
    12621351#else
    12631352  WRITE_CODE( repFormat->getChromaFormatVpsIdc(), 2, "chroma_format_idc" );   
     
    12751364  WRITE_CODE( repFormat->getBitDepthVpsLuma() - 8,   4, "bit_depth_luma_minus8" );           
    12761365  WRITE_CODE( repFormat->getBitDepthVpsChroma() - 8, 4, "bit_depth_chroma_minus8" );
    1277 #endif
    1278 
     1366#endif
    12791367}
    12801368#endif
     
    13751463        if( vps->getBitRatePresentVpsFlag() )
    13761464        {
    1377           WRITE_FLAG( vps->getBitRatePresentFlag( i, j),        "bit_rate_present_vps_flag[i][j]" );
     1465          WRITE_FLAG( vps->getBitRatePresentFlag( i, j),        "bit_rate_present_flag[i][j]" );
    13781466        }
    13791467        if( vps->getPicRatePresentVpsFlag() )
    13801468        {
    1381           WRITE_FLAG( vps->getPicRatePresentFlag( i, j),        "pic_rate_present_vps_flag[i][j]" );
     1469          WRITE_FLAG( vps->getPicRatePresentFlag( i, j),        "pic_rate_present_flag[i][j]" );
    13821470        }
    13831471        if( vps->getBitRatePresentFlag(i, j) )
     
    14661554#endif
    14671555#if HIGHER_LAYER_IRAP_SKIP_FLAG
     1556  // When single_layer_for_non_irap_flag is equal to 0, higher_layer_irap_skip_flag shall be equal to 0
     1557  if( !vps->getSingleLayerForNonIrapFlag() )
     1558  {
     1559    assert( !vps->getHigherLayerIrapSkipFlag() );
     1560  }
     1561
    14681562  WRITE_FLAG(vps->getHigherLayerIrapSkipFlag(), "higher_layer_irap_skip_flag" );
    14691563#endif
     
    15641658    for(i = 1; i < vps->getMaxLayers(); i++)
    15651659    {
    1566       if(vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0)
    1567       {
    1568         if ((vps->getSPSId(i) == 0) && (vps->getPPSId(i) == 0))
     1660      if( vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0 )
     1661      {
     1662        if( (vps->getSPSId(i) == 0) && (vps->getPPSId(i) == 0) )
    15691663        {
    15701664          vps->setBaseLayerPSCompatibilityFlag(i, 1);
    1571           WRITE_FLAG(vps->getBaseLayerPSCompatibilityFlag(i), "base_layer_parameter_set_compatibility_flag" );
    15721665        }
    15731666        else
     
    15751668          vps->setBaseLayerPSCompatibilityFlag(i, 0);
    15761669        }
     1670        WRITE_FLAG(vps->getBaseLayerPSCompatibilityFlag(i), "base_layer_parameter_set_compatibility_flag" );
    15771671      }
    15781672    }
     
    16121706  if ( pcSlice->getRapPicFlag() )
    16131707  {
    1614 #if NO_OUTPUT_OF_PRIOR_PICS
    1615     WRITE_FLAG( pcSlice->getNoOutputOfPriorPicsFlag(), "no_output_of_prior_pics_flag" );
     1708#if SETTING_NO_OUT_PIC_PRIOR
     1709    WRITE_FLAG( pcSlice->getNoOutputPriorPicsFlag() ? 1 : 0, "no_output_of_prior_pics_flag" );
    16161710#else
    16171711    WRITE_FLAG( 0, "no_output_of_prior_pics_flag" );
     
    26162710  return true;
    26172711}
     2712
     2713#if Q0048_CGS_3D_ASYMLUT
     2714Void TEncCavlc::xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT )
     2715{
     2716  assert( pc3DAsymLUT->getCurOctantDepth() < 4 );
     2717  WRITE_CODE( pc3DAsymLUT->getCurOctantDepth() , 2 , "cm_octant_depth" );
     2718  assert( pc3DAsymLUT->getCurYPartNumLog2() < 4 );
     2719  WRITE_CODE( pc3DAsymLUT->getCurYPartNumLog2() , 2 , "cm_y_part_num_log2" );
     2720  assert( pc3DAsymLUT->getInputBitDepthY() < 16 );
     2721  WRITE_CODE( pc3DAsymLUT->getInputBitDepthY() - 8 , 3 , "cm_input_bit_depth_minus8" );
     2722  WRITE_SVLC(pc3DAsymLUT->getInputBitDepthC()-pc3DAsymLUT->getInputBitDepthY(), "cm_input_bit_depth_chroma delta");
     2723  assert( pc3DAsymLUT->getOutputBitDepthY() < 16 );
     2724  WRITE_CODE( pc3DAsymLUT->getOutputBitDepthY() - 8 , 3 , "cm_output_bit_depth_minus8" );
     2725  WRITE_SVLC(pc3DAsymLUT->getOutputBitDepthC()-pc3DAsymLUT->getOutputBitDepthY(), "cm_output_bit_depth_chroma_delta");
     2726  assert( pc3DAsymLUT->getResQuantBit() < 4 );
     2727  WRITE_CODE( pc3DAsymLUT->getResQuantBit() , 2 , "cm_res_quant_bit" );
     2728
     2729  xCode3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() );
     2730}
     2731
     2732Void TEncCavlc::xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength )
     2733{
     2734  UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth();
     2735  if( nDepth < pc3DAsymLUT->getCurOctantDepth() )
     2736    WRITE_FLAG( uiOctantSplit , "split_octant_flag" );
     2737  Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2();
     2738  if( uiOctantSplit )
     2739  {
     2740    Int nHalfLength = nLength >> 1;
     2741    for( Int l = 0 ; l < 2 ; l++ )
     2742    {
     2743      for( Int m = 0 ; m < 2 ; m++ )
     2744      {
     2745        for( Int n = 0 ; n < 2 ; n++ )
     2746        {
     2747          xCode3DAsymLUTOctant( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength );
     2748        }
     2749      }
     2750    }
     2751  }
     2752  else
     2753  {
     2754    for( Int l = 0 ; l < nYPartNum ; l++ )
     2755    {
     2756      for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
     2757      {
     2758        SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx );
     2759        UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0;
     2760        WRITE_FLAG( uiCodeVertex , "coded_vertex_flag" );
     2761        if( uiCodeVertex )
     2762        {
     2763          WRITE_SVLC( sRes.Y , "resY" );
     2764          WRITE_SVLC( sRes.U , "resU" );
     2765          WRITE_SVLC( sRes.V , "resV" );
     2766        }
     2767      }
     2768    }
     2769  }
     2770}
     2771#endif
    26182772//! \}
  • trunk/source/Lib/TLibEncoder/TEncCavlc.h

    r644 r713  
    4848#include "TEncEntropy.h"
    4949#include "SyntaxElementWriter.h"
     50#if Q0048_CGS_3D_ASYMLUT
     51#include "../TLibCommon/TCom3DAsymLUT.h"
     52#include "TEnc3DAsymLUT.h"
     53#endif
    5054
    5155//! \ingroup TLibEncoder
     
    5357
    5458class TEncTop;
     59#if Q0048_CGS_3D_ASYMLUT
     60class TCom3DAsymLUT;
     61#endif
    5562
    5663// ====================================================================================================================
     
    9097  Void  codeVUI                 ( TComVUI *pcVUI, TComSPS* pcSPS );
    9198  Void  codeSPS                 ( TComSPS* pcSPS );
    92   Void  codePPS                 ( TComPPS* pcPPS );
     99  Void  codePPS                 ( TComPPS* pcPPS
     100#if Q0048_CGS_3D_ASYMLUT
     101    , TEnc3DAsymLUT * pc3DAsymLUT
     102#endif
     103    );
    93104  Void  codeSliceHeader         ( TComSlice* pcSlice );
    94105  Void  codePTL                 ( TComPTL* pcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1);
     
    162173  Void  codeVpsDpbSizeTable      (TComVPS *vps);
    163174#endif
     175#if Q0048_CGS_3D_ASYMLUT
     176protected:
     177  Void xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT );
     178  Void xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength );
     179#endif
    164180#endif //SVC_EXTENSION
    165181
  • trunk/source/Lib/TLibEncoder/TEncCfg.h

    r644 r713  
    235235  Int       m_cameraIsoSpeedIdc;
    236236  Int       m_cameraIsoSpeedValue;
     237  Int       m_exposureIndexIdc;
     238  Int       m_exposureIndexValue;
    237239  Int       m_exposureCompensationValueSignFlag;
    238240  Int       m_exposureCompensationValueNumerator;
     
    246248  Int*      m_codedPivotValue;
    247249  Int*      m_targetPivotValue;
     250#if Q0074_SEI_COLOR_MAPPING
     251  Char*     m_seiColorMappingFile;
     252#endif
    248253  Int       m_framePackingSEIEnabled;
    249254  Int       m_framePackingSEIType;
     
    362367  UInt      m_bottomRightTileIndex[1024];
    363368  UInt      m_ilcIdc[1024];
     369#endif
     370#if Q0048_CGS_3D_ASYMLUT
     371  Int  m_nCGSFlag;
     372  Int  m_nCGSMaxOctantDepth;
     373  Int  m_nCGSMaxYPartNumLog2;
     374  Int  m_nCGSLUTBit;
    364375#endif
    365376#endif //SVC_EXTENSION
     
    639650  Void  setTMISEICameraIsoSpeedValue(Int b)                  {  m_cameraIsoSpeedValue = b;  }
    640651  Int   getTMISEICameraIsoSpeedValue()                       {  return m_cameraIsoSpeedValue;  }
     652  Void  setTMISEIExposureIndexIdc(Int b)                     {  m_exposureIndexIdc = b;  }
     653  Int   getTMISEIExposurIndexIdc()                           {  return m_exposureIndexIdc;  }
     654  Void  setTMISEIExposureIndexValue(Int b)                   {  m_exposureIndexValue = b;  }
     655  Int   getTMISEIExposurIndexValue()                         {  return m_exposureIndexValue;  }
    641656  Void  setTMISEIExposureCompensationValueSignFlag(Int b)    {  m_exposureCompensationValueSignFlag = b;  }
    642657  Int   getTMISEIExposureCompensationValueSignFlag()         {  return m_exposureCompensationValueSignFlag;  }
     
    655670  Void  setTMISEIExtendedWhiteLevelLumaCodeValue(Int b)      {  m_extendedWhiteLevelLumaCodeValue =b;  }
    656671  Int   getTMISEIExtendedWhiteLevelLumaCodeValue()           {  return m_extendedWhiteLevelLumaCodeValue;  }
     672#if Q0074_SEI_COLOR_MAPPING
     673  Void  setColorMappingInfoSEIFile( Char* nameFile )         {  m_seiColorMappingFile = nameFile; }
     674  Char* getColorMappingInfoSEIFile()                         {  return m_seiColorMappingFile; }
     675#endif
    657676  Void  setFramePackingArrangementSEIEnabled(Int b)      { m_framePackingSEIEnabled = b; }
    658677  Int   getFramePackingArrangementSEIEnabled()           { return m_framePackingSEIEnabled; }
     
    898917  UInt  getIlcIdc(UInt b)                                  { return m_ilcIdc[b]; }
    899918#endif
     919#if Q0048_CGS_3D_ASYMLUT
     920  Void      setCGSFlag(Int n)             { m_nCGSFlag = n;    }
     921  Int       getCGSFlag()                  { return m_nCGSFlag; }
     922  Void      setCGSMaxOctantDepth(Int n)   { m_nCGSMaxOctantDepth = n;    }
     923  Int       getCGSMaxOctantDepth()        { return m_nCGSMaxOctantDepth; }
     924  Void      setCGSMaxYPartNumLog2(Int n)  { m_nCGSMaxYPartNumLog2 = n;    }
     925  Int       getCGSMaxYPartNumLog2()       { return m_nCGSMaxYPartNumLog2; }
     926  Void      setCGSLUTBit(Int n)           { m_nCGSLUTBit = n;    }
     927  Int       getCGSLUTBit()                { return m_nCGSLUTBit; }
     928#endif
    900929#endif
    901930};
  • trunk/source/Lib/TLibEncoder/TEncEntropy.cpp

    r644 r713  
    7979}
    8080
     81#if Q0048_CGS_3D_ASYMLUT
     82Void TEncEntropy::encodePPS( TComPPS* pcPPS, TEnc3DAsymLUT * pc3DAsymLUT  )
     83{
     84  m_pcEntropyCoderIf->codePPS( pcPPS, pc3DAsymLUT );
     85  return;
     86}
     87#else
    8188Void TEncEntropy::encodePPS( TComPPS* pcPPS )
    8289{
     
    8491  return;
    8592}
     93#endif
    8694
    8795Void TEncEntropy::encodeSPS( TComSPS* pcSPS )
  • trunk/source/Lib/TLibEncoder/TEncEntropy.h

    r644 r713  
    5050class TEncCavlc;
    5151class SEI;
     52#if Q0048_CGS_3D_ASYMLUT
     53class TEnc3DAsymLUT;
     54#endif
    5255
    5356// ====================================================================================================================
     
    7073  virtual Void  codeVPS                 ( TComVPS* pcVPS )                                      = 0;
    7174  virtual Void  codeSPS                 ( TComSPS* pcSPS )                                      = 0;
    72   virtual Void  codePPS                 ( TComPPS* pcPPS )                                      = 0;
     75  virtual Void  codePPS                 ( TComPPS* pcPPS
     76#if Q0048_CGS_3D_ASYMLUT
     77    , TEnc3DAsymLUT * pc3DAsymLUT
     78#endif
     79    )                                      = 0;
    7380  virtual Void  codeSliceHeader         ( TComSlice* pcSlice )                                  = 0;
    7481
     
    156163  // SPS
    157164  Void encodeSPS               ( TComSPS* pcSPS );
    158   Void encodePPS               ( TComPPS* pcPPS );
     165  Void encodePPS               ( TComPPS* pcPPS
     166#if Q0048_CGS_3D_ASYMLUT
     167    , TEnc3DAsymLUT * pc3DAsymLUT
     168#endif
     169    );
    159170  Void encodeSplitFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
    160171  Void encodeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
  • trunk/source/Lib/TLibEncoder/TEncGOP.cpp

    r644 r713  
    7575  m_iNumPicCoded        = 0; //Niko
    7676  m_bFirst              = true;
     77#if ALLOW_RECOVERY_POINT_AS_RAP
     78  m_iLastRecoveryPicPOC = 0;
     79#endif
    7780 
    7881  m_pcCfg               = NULL;
     
    103106  m_pcPredSearch        = NULL;
    104107#endif
     108#if Q0048_CGS_3D_ASYMLUT
     109  m_temp = NULL;
     110  m_pColorMappedPic = NULL;
     111#endif
    105112  return;
    106113}
     
    108115TEncGOP::~TEncGOP()
    109116{
     117#if Q0048_CGS_3D_ASYMLUT
     118  if(m_pColorMappedPic)
     119  {
     120    m_pColorMappedPic->destroy();
     121    delete m_pColorMappedPic;
     122    m_pColorMappedPic = NULL;               
     123  }
     124  if(m_temp)
     125  {
     126    free_mem2DintWithPad(m_temp, m_iTap>>1, 0);
     127    m_temp = NULL;
     128  }
     129#endif
    110130}
    111131
     
    157177  m_pcPredSearch         = pcTEncTop->getPredSearch();                       ///< encoder search class
    158178#endif
     179#if Q0048_CGS_3D_ASYMLUT
     180  if( pcTEncTop->getLayerId() )
     181  {
     182    m_Enc3DAsymLUTPicUpdate.create( m_pcCfg->getCGSMaxOctantDepth() , g_bitDepthYLayer[pcTEncTop->getLayerId()-1] , g_bitDepthCLayer[pcTEncTop->getLayerId()-1] , g_bitDepthYLayer[pcTEncTop->getLayerId()] , g_bitDepthCLayer[pcTEncTop->getLayerId()] , m_pcCfg->getCGSMaxYPartNumLog2() /*, m_pcCfg->getCGSPhaseAlignment()*/ );
     183    m_Enc3DAsymLUTPPS.create(   m_pcCfg->getCGSMaxOctantDepth() , g_bitDepthYLayer[pcTEncTop->getLayerId()-1] , g_bitDepthCLayer[pcTEncTop->getLayerId()-1] , g_bitDepthYLayer[pcTEncTop->getLayerId()] , g_bitDepthCLayer[pcTEncTop->getLayerId()] , m_pcCfg->getCGSMaxYPartNumLog2() /*, m_pcCfg->getCGSPhaseAlignment()*/ );
     184    if(!m_pColorMappedPic)
     185    {
     186      m_pColorMappedPic = new TComPicYuv;
     187      m_pColorMappedPic->create( m_ppcTEncTop[0]->getSourceWidth(), m_ppcTEncTop[0]->getSourceHeight(), CHROMA_420, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL );
     188    }
     189  }
     190#endif
    159191}
    160192
     
    163195  SEIActiveParameterSets *seiActiveParameterSets = new SEIActiveParameterSets();
    164196  seiActiveParameterSets->activeVPSId = m_pcCfg->getVPS()->getVPSId();
    165   seiActiveParameterSets->m_fullRandomAccessFlag = false;
    166   seiActiveParameterSets->m_noParamSetUpdateFlag = false;
     197  seiActiveParameterSets->m_selfContainedCvsFlag = false;
     198  seiActiveParameterSets->m_noParameterSetUpdateFlag = false;
    167199  seiActiveParameterSets->numSpsIdsMinus1 = 0;
    168   seiActiveParameterSets->activeSeqParamSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1);
    169   seiActiveParameterSets->activeSeqParamSetId[0] = sps->getSPSId();
     200  seiActiveParameterSets->activeSeqParameterSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1);
     201  seiActiveParameterSets->activeSeqParameterSetId[0] = sps->getSPSId();
    170202  return seiActiveParameterSets;
    171203}
    172 
    173204
    174205SEIFramePacking* TEncGOP::xCreateSEIFramePacking()
     
    271302       seiToneMappingInfo->m_cameraIsoSpeedValue = m_pcCfg->getTMISEICameraIsoSpeedValue();
    272303       assert( seiToneMappingInfo->m_cameraIsoSpeedValue !=0 );
     304       seiToneMappingInfo->m_exposureIndexIdc = m_pcCfg->getTMISEIExposurIndexIdc();
     305       seiToneMappingInfo->m_exposureIndexValue = m_pcCfg->getTMISEIExposurIndexValue();
     306       assert( seiToneMappingInfo->m_exposureIndexValue !=0 );
    273307       seiToneMappingInfo->m_exposureCompensationValueSignFlag = m_pcCfg->getTMISEIExposureCompensationValueSignFlag();
    274308       seiToneMappingInfo->m_exposureCompensationValueNumerator = m_pcCfg->getTMISEIExposureCompensationValueNumerator();
     
    293327}
    294328
     329#if Q0074_SEI_COLOR_MAPPING
     330SEIColorMappingInfo*  TEncGOP::xCreateSEIColorMappingInfo( Char* file )
     331{
     332  SEIColorMappingInfo *seiColorMappingInfo = new SEIColorMappingInfo();
     333
     334  FILE* fic = fopen( file, "r" );
     335
     336  Int iVal, retval;
     337
     338  retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMapId );
     339  retval = fscanf( fic, "%d", &iVal );
     340  seiColorMappingInfo->m_colorMapCancelFlag = iVal;
     341  if( !seiColorMappingInfo->m_colorMapCancelFlag )
     342  {
     343    retval = fscanf( fic, "%d", &iVal );
     344    seiColorMappingInfo->m_colorMapPersistenceFlag = iVal;
     345    retval = fscanf( fic, "%d", &iVal );
     346    seiColorMappingInfo->m_colorMap_video_signal_type_present_flag = iVal;
     347    if( seiColorMappingInfo->m_colorMap_video_signal_type_present_flag )
     348    {
     349      retval = fscanf( fic, "%d", &iVal );
     350      seiColorMappingInfo->m_colorMap_video_full_range_flag = iVal;
     351      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_primaries );
     352      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_transfer_characteristics );
     353      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_matrix_coeffs );
     354    }
     355  }
     356
     357  retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colour_map_coded_data_bit_depth );
     358  retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colour_map_target_bit_depth );
     359  retval = fscanf( fic, "%d", &iVal );
     360  seiColorMappingInfo->m_colorMapModelId = iVal;
     361
     362  assert( seiColorMappingInfo->m_colorMapModelId == 0 );
     363 
     364  for( Int i=0 ; i<3 ; i++ )
     365  {
     366    retval = fscanf( fic, "%d", &seiColorMappingInfo->m_num_input_pivots[i] );
     367    seiColorMappingInfo->m_coded_input_pivot_value[i]   = new Int[ seiColorMappingInfo->m_num_input_pivots[i] ];
     368    seiColorMappingInfo->m_target_input_pivot_value[i]  = new Int[ seiColorMappingInfo->m_num_input_pivots[i] ];
     369    for( Int j=0 ; j<seiColorMappingInfo->m_num_input_pivots[i] ; j++ )
     370    {
     371      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_coded_input_pivot_value[i][j] );
     372      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_target_input_pivot_value[i][j] );
     373    }
     374  }
     375
     376  retval = fscanf( fic, "%d", &iVal );
     377  seiColorMappingInfo->m_matrix_flag = iVal;
     378  if( seiColorMappingInfo->m_matrix_flag )
     379  {
     380    retval = fscanf( fic, "%d", &seiColorMappingInfo->m_log2_matrix_denom );
     381    for( Int i=0 ; i<3 ; i++ )
     382    {
     383      for( Int j=0 ; j<3 ; j++ )
     384      {
     385        retval = fscanf( fic, "%d", &seiColorMappingInfo->m_matrix_coef[i][j] );
     386      }
     387    }
     388  }
     389
     390  for( Int i=0 ; i<3 ; i++ )
     391  {
     392    retval = fscanf( fic, "%d", &seiColorMappingInfo->m_num_output_pivots[i] );
     393    seiColorMappingInfo->m_coded_output_pivot_value[i]   = new Int[ seiColorMappingInfo->m_num_output_pivots[i] ];
     394    seiColorMappingInfo->m_target_output_pivot_value[i]  = new Int[ seiColorMappingInfo->m_num_output_pivots[i] ];
     395    for( Int j=0 ; j<seiColorMappingInfo->m_num_output_pivots[i] ; j++ )
     396    {
     397      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_coded_output_pivot_value[i][j] );
     398      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_target_output_pivot_value[i][j] );
     399    }
     400  }
     401
     402  fclose( fic );
     403
     404  if( retval != 1 )
     405  {
     406    printf("Error: can't read color mapping information\n");
     407  }
     408
     409  return seiColorMappingInfo;
     410}
     411#endif
     412
    295413Void TEncGOP::xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps)
    296414{
     
    359477    delete sei;
    360478  }
     479#if Q0074_SEI_COLOR_MAPPING
     480  if(m_pcCfg->getColorMappingInfoSEIFile())
     481  {
     482    SEIColorMappingInfo *sei = xCreateSEIColorMappingInfo( m_pcCfg->getColorMappingInfoSEIFile() );
     483     
     484#if SVC_EXTENSION
     485    nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, m_layerId);  // temporalId = 0 ?
     486#else
     487    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
     488#endif
     489    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     490#if O0164_MULTI_LAYER_HRD
     491    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
     492#else
     493    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     494#endif
     495    writeRBSPTrailingBits(nalu.m_Bitstream);
     496    accessUnit.push_back(new NALUnitEBSP(nalu));
     497    delete sei;
     498  }
     499#endif
    361500
    362501#if SVC_EXTENSION
     
    435574  UInt *accumNalsDU = NULL;
    436575  SEIDecodingUnitInfo decodingUnitInfoSEI;
     576#if EFFICIENT_FIELD_IRAP
     577  Int IRAPGOPid = -1;
     578  Bool IRAPtoReorder = false;
     579  Bool swapIRAPForward = false;
     580  if(isField)
     581  {
     582    Int pocCurr;
     583#if SVC_EXTENSION
     584    for ( Int iGOPid=iPicIdInGOP; iGOPid < iPicIdInGOP+1; iGOPid++ )
     585#else
     586    for ( Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ )
     587#endif   
     588    {
     589      // determine actual POC
     590      if(iPOCLast == 0) //case first frame or first top field
     591      {
     592        pocCurr=0;
     593      }
     594      else if(iPOCLast == 1 && isField) //case first bottom field, just like the first frame, the poc computation is not right anymore, we set the right value
     595      {
     596        pocCurr = 1;
     597      }
     598      else
     599      {
     600        pocCurr = iPOCLast - iNumPicRcvd + m_pcCfg->getGOPEntry(iGOPid).m_POC - isField;
     601      }
     602
     603      // check if POC corresponds to IRAP
     604      NalUnitType tmpUnitType = getNalUnitType(pocCurr, m_iLastIDR, isField);
     605      if(tmpUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && tmpUnitType <= NAL_UNIT_CODED_SLICE_CRA) // if picture is an IRAP
     606      {
     607        if(pocCurr%2 == 0 && iGOPid < m_iGopSize-1 && m_pcCfg->getGOPEntry(iGOPid).m_POC == m_pcCfg->getGOPEntry(iGOPid+1).m_POC-1)
     608        { // if top field and following picture in enc order is associated bottom field
     609          IRAPGOPid = iGOPid;
     610          IRAPtoReorder = true;
     611          swapIRAPForward = true;
     612          break;
     613        }
     614        if(pocCurr%2 != 0 && iGOPid > 0 && m_pcCfg->getGOPEntry(iGOPid).m_POC == m_pcCfg->getGOPEntry(iGOPid-1).m_POC+1)
     615        {
     616          // if picture is an IRAP remember to process it first
     617          IRAPGOPid = iGOPid;
     618          IRAPtoReorder = true;
     619          swapIRAPForward = false;
     620          break;
     621        }
     622      }
     623    }
     624  }
     625#endif
    437626#if SVC_EXTENSION
    438627  for ( Int iGOPid=iPicIdInGOP; iGOPid < iPicIdInGOP+1; iGOPid++ )
     
    441630#endif
    442631  {
     632#if EFFICIENT_FIELD_IRAP
     633    if(IRAPtoReorder)
     634    {
     635      if(swapIRAPForward)
     636      {
     637        if(iGOPid == IRAPGOPid)
     638        {
     639          iGOPid = IRAPGOPid +1;
     640        }
     641        else if(iGOPid == IRAPGOPid +1)
     642        {
     643          iGOPid = IRAPGOPid;
     644        }
     645      }
     646      else
     647      {
     648        if(iGOPid == IRAPGOPid -1)
     649        {
     650          iGOPid = IRAPGOPid;
     651        }
     652        else if(iGOPid == IRAPGOPid)
     653        {
     654          iGOPid = IRAPGOPid -1;
     655        }
     656      }
     657    }
     658#endif
    443659    UInt uiColDir = 1;
    444660    //-- For time output for each slice
     
    510726    if(pocCurr>=m_pcCfg->getFramesToBeEncoded())
    511727    {
     728#if EFFICIENT_FIELD_IRAP
     729      if(IRAPtoReorder)
     730      {
     731        if(swapIRAPForward)
     732        {
     733          if(iGOPid == IRAPGOPid)
     734          {
     735            iGOPid = IRAPGOPid +1;
     736            IRAPtoReorder = false;
     737          }
     738          else if(iGOPid == IRAPGOPid +1)
     739          {
     740            iGOPid --;
     741          }
     742        }
     743        else
     744        {
     745          if(iGOPid == IRAPGOPid)
     746          {
     747            iGOPid = IRAPGOPid -1;
     748          }
     749          else if(iGOPid == IRAPGOPid -1)
     750          {
     751            iGOPid = IRAPGOPid;
     752            IRAPtoReorder = false;
     753          }
     754        }
     755      }
     756#endif
    512757      continue;
    513758    }
     
    8031048        Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth();
    8041049        Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight();
    805 
     1050#if Q0200_CONFORMANCE_BL_SIZE
     1051        Int chromaFormatIdc = pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getChromaFormatIdc();
     1052        const Window &confBL = pcSlice->getBaseColPic(refLayerIdc)->getConformanceWindow();
     1053        widthBL  -= ( confBL.getWindowLeftOffset() + confBL.getWindowRightOffset() ) * TComSPS::getWinUnitX( chromaFormatIdc );
     1054        heightBL -= ( confBL.getWindowTopOffset() + confBL.getWindowBottomOffset() ) * TComSPS::getWinUnitY( chromaFormatIdc );
     1055#endif
    8061056        Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
    8071057        Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     
    8131063        g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;
    8141064
     1065#if Q0048_CGS_3D_ASYMLUT
     1066        TComPicYuv* pBaseColRec = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec();
     1067        if( pcSlice->getPPS()->getCGSFlag() )
     1068        {
     1069          if(g_posScalingFactor[refLayerIdc][0] < (1<<16) || g_posScalingFactor[refLayerIdc][1] < (1<<16)) //if(pcPic->isSpatialEnhLayer(refLayerIdc))
     1070          {
     1071            //downsampling;
     1072            downScalePic(pcPic->getPicYuvOrg(), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg());
     1073            //pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg()->dump("ds.yuv", true, true);
     1074            m_Enc3DAsymLUTPPS.setDsOrigPic(pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg());
     1075            m_Enc3DAsymLUTPicUpdate.setDsOrigPic(pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg());
     1076          }
     1077          else
     1078          {
     1079            m_Enc3DAsymLUTPPS.setDsOrigPic(pcPic->getPicYuvOrg());
     1080            m_Enc3DAsymLUTPicUpdate.setDsOrigPic(pcPic->getPicYuvOrg());
     1081          }
     1082
     1083          Bool bSignalPPS = m_bSeqFirst;
     1084          bSignalPPS |= m_pcCfg->getGOPSize() > 1 ? pocCurr % m_pcCfg->getIntraPeriod() == 0 : pocCurr % m_pcCfg->getFrameRate() == 0;
     1085          xDetermin3DAsymLUT( pcSlice , pcPic , refLayerIdc , m_pcCfg , bSignalPPS );
     1086          m_Enc3DAsymLUTPPS.colorMapping( pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(),  m_pColorMappedPic );
     1087          pBaseColRec = m_pColorMappedPic;
     1088        }
     1089#endif
    8151090#if SVC_UPSAMPLING
    8161091        if( pcPic->isSpatialEnhLayer(refLayerIdc))
    8171092        {
    818 /*#if O0098_SCALED_REF_LAYER_ID
    819           Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc));
    820 #else
    821           Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc);
    822 #endif*/
    8231093#if P0312_VERT_PHASE_ADJ
    8241094          //when PhasePositionEnableFlag is equal to 1, set vertPhasePositionFlag to 0 if BL is top field and 1 if bottom
     
    8301100#if O0215_PHASE_ALIGNMENT
    8311101#if O0194_JOINT_US_BITSHIFT
    832           m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
     1102#if Q0048_CGS_3D_ASYMLUT
     1103          m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
     1104#else
     1105          m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
     1106#endif
     1107#else
     1108#if Q0048_CGS_3D_ASYMLUT
     1109          m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
    8331110#else
    8341111          m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
    8351112#endif
     1113#endif
    8361114#else
    8371115#if O0194_JOINT_US_BITSHIFT
     1116#if Q0048_CGS_3D_ASYMLUT
     1117          m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
     1118#else
    8381119          m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
     1120#endif
     1121#else
     1122#if Q0048_CGS_3D_ASYMLUT
     1123          m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
    8391124#else
    8401125          m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
    8411126#endif
    8421127#endif
     1128#endif
    8431129        }
    8441130        else
    8451131        {
     1132#if Q0048_CGS_3D_ASYMLUT
     1133          pcPic->setFullPelBaseRec( refLayerIdc, pBaseColRec );
     1134#else
    8461135          pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() );
     1136#endif
    8471137        }
    8481138        pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) );
     
    8561146      }
    8571147
    858 #if !O0225_TID_BASED_IL_RPS_DERIV
     1148#if !O0225_TID_BASED_IL_RPS_DERIV || Q0060_MAX_TID_REF_EQUAL_TO_ZERO
    8591149      pcSlice->setActiveNumILRRefIdx( activeNumILRRefIdxTmp );
    8601150#endif
     
    9321222    }
    9331223
    934     // Do decoding refresh marking if any
    935 #if NO_CLRAS_OUTPUT_FLAG
    936     pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic, m_pcEncTop->getNoClrasOutputFlag());
    937 #else
    938     pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic);
    939 #endif
    940     m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid);
    941     pcSlice->getRPS()->setNumberOfLongtermPictures(0);
     1224#if EFFICIENT_FIELD_IRAP
    9421225#if FIX1172
    9431226    if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     
    9541237    pcSlice->setAssociatedIRAPPOC(m_associatedIRAPPOC);
    9551238#endif
    956 
     1239#endif
     1240    // Do decoding refresh marking if any
     1241#if NO_CLRAS_OUTPUT_FLAG
     1242    pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic, m_pcEncTop->getNoClrasOutputFlag());
     1243#else
     1244    pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic);
     1245#endif
     1246    m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid);
     1247    pcSlice->getRPS()->setNumberOfLongtermPictures(0);
     1248#if EFFICIENT_FIELD_IRAP
     1249#else
     1250#if FIX1172
     1251    if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     1252      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     1253      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
     1254      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL
     1255      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP
     1256      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA )  // IRAP picture
     1257    {
     1258      m_associatedIRAPType = pcSlice->getNalUnitType();
     1259      m_associatedIRAPPOC = pocCurr;
     1260    }
     1261    pcSlice->setAssociatedIRAPType(m_associatedIRAPType);
     1262    pcSlice->setAssociatedIRAPPOC(m_associatedIRAPPOC);
     1263#endif
     1264#endif
     1265
     1266#if ALLOW_RECOVERY_POINT_AS_RAP
     1267    if ((pcSlice->checkThatAllRefPicsAreAvailable(rcListPic, pcSlice->getRPS(), false, m_iLastRecoveryPicPOC, m_pcCfg->getDecodingRefreshType() == 3) != 0) || (pcSlice->isIRAP())
     1268#if EFFICIENT_FIELD_IRAP
     1269      || (isField && pcSlice->getAssociatedIRAPType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getAssociatedIRAPType() <= NAL_UNIT_CODED_SLICE_CRA && pcSlice->getAssociatedIRAPPOC() == pcSlice->getPOC()+1)
     1270#endif
     1271      )
     1272    {
     1273      pcSlice->createExplicitReferencePictureSetFromReference(rcListPic, pcSlice->getRPS(), pcSlice->isIRAP(), m_iLastRecoveryPicPOC, m_pcCfg->getDecodingRefreshType() == 3);
     1274    }
     1275#else
    9571276    if ((pcSlice->checkThatAllRefPicsAreAvailable(rcListPic, pcSlice->getRPS(), false) != 0) || (pcSlice->isIRAP()))
    9581277    {
    9591278      pcSlice->createExplicitReferencePictureSetFromReference(rcListPic, pcSlice->getRPS(), pcSlice->isIRAP());
    9601279    }
     1280#endif
    9611281#if ALIGNED_BUMPING
    9621282    pcSlice->checkLeadingPictureRestrictions(rcListPic);
     
    17432063      assert( pcSlice->getPPS()->getPPSId() == 0 || pcSlice->getPPS()->getPPSId() == m_layerId || m_pcEncTop->getVPS()->getRecursiveRefLayerFlag(m_layerId, pcSlice->getPPS()->getPPSId()) );
    17442064#endif
    1745       m_pcEntropyCoder->encodePPS(pcSlice->getPPS());
     2065      m_pcEntropyCoder->encodePPS(pcSlice->getPPS()
     2066#if Q0048_CGS_3D_ASYMLUT
     2067        , & m_Enc3DAsymLUTPPS
     2068#endif
     2069        );
    17462070      writeRBSPTrailingBits(nalu.m_Bitstream);
    17472071      accessUnit.push_back(new NALUnitEBSP(nalu));
     
    17762100      m_bSeqFirst = false;
    17772101    }
     2102#if Q0048_CGS_3D_ASYMLUT
     2103    else if( m_pcCfg->getCGSFlag() && pcSlice->getLayerId() && pcSlice->getCGSOverWritePPS() )
     2104    {
     2105#if SVC_EXTENSION
     2106      OutputNALUnit nalu(NAL_UNIT_PPS, 0, m_layerId);
     2107#endif
     2108
     2109      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     2110      m_pcEntropyCoder->encodePPS(pcSlice->getPPS() , &m_Enc3DAsymLUTPPS );
     2111      writeRBSPTrailingBits(nalu.m_Bitstream);
     2112      accessUnit.push_back(new NALUnitEBSP(nalu));
     2113    }
     2114#endif
    17782115
    17792116    if (writeSOP) // write SOP description SEI (if enabled) at the beginning of GOP
     
    18492186      pictureTimingSEI.m_auCpbRemovalDelay = std::min<Int>(std::max<Int>(1, m_totalCoded - m_lastBPSEI), static_cast<Int>(pow(2, static_cast<double>(pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getCpbRemovalDelayLengthMinus1()+1)))); // Syntax element signalled as minus, hence the .
    18502187#if POC_RESET_FLAG
    1851       pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(0) + pocCurr - m_totalCoded;
    1852 #else
    1853       pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(0) + pcSlice->getPOC() - m_totalCoded;
     2188      pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(pcSlice->getSPS()->getMaxTLayers()-1) + pocCurr - m_totalCoded;
     2189#else
     2190      pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(pcSlice->getSPS()->getMaxTLayers()-1) + pcSlice->getPOC() - m_totalCoded;
     2191#endif
     2192#if EFFICIENT_FIELD_IRAP
     2193      if(IRAPGOPid > 0 && IRAPGOPid < m_iGopSize)
     2194      {
     2195        // if pictures have been swapped there is likely one more picture delay on their tid. Very rough approximation
     2196        pictureTimingSEI.m_picDpbOutputDelay ++;
     2197      }
    18542198#endif
    18552199      Int factor = pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2;
     
    19752319#endif
    19762320      sei_recovery_point.m_brokenLinkFlag    = false;
     2321#if ALLOW_RECOVERY_POINT_AS_RAP
     2322      if(m_pcCfg->getDecodingRefreshType() == 3)
     2323      {
     2324        m_iLastRecoveryPicPOC = pocCurr;
     2325      }
     2326#endif
    19772327
    19782328#if O0164_MULTI_LAYER_HRD
     
    21102460          }
    21112461          m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     2462
     2463#if SETTING_NO_OUT_PIC_PRIOR
     2464          if (pcSlice->isIRAP())
     2465          {
     2466            if (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP)
     2467            {
     2468              pcSlice->setNoRaslOutputFlag(true);
     2469            }
     2470            //the inference for NoOutputPriorPicsFlag
     2471            if (!m_bFirst && pcSlice->isIRAP() && pcSlice->getNoRaslOutputFlag())
     2472            {
     2473              if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)
     2474              {
     2475                pcSlice->setNoOutputPriorPicsFlag(true);
     2476              }
     2477            }
     2478          }
     2479#endif
     2480
    21122481          tmpBitsBeforeWriting = m_pcEntropyCoder->getNumberOfWrittenBits();
    21132482          m_pcEntropyCoder->encodeSliceHeader(pcSlice);
     
    26573026
    26583027      delete[] pcSubstreamsOut;
     3028
     3029#if EFFICIENT_FIELD_IRAP
     3030    if(IRAPtoReorder)
     3031    {
     3032      if(swapIRAPForward)
     3033      {
     3034        if(iGOPid == IRAPGOPid)
     3035        {
     3036          iGOPid = IRAPGOPid +1;
     3037          IRAPtoReorder = false;
     3038        }
     3039        else if(iGOPid == IRAPGOPid +1)
     3040        {
     3041          iGOPid --;
     3042        }
     3043      }
     3044      else
     3045      {
     3046        if(iGOPid == IRAPGOPid)
     3047        {
     3048          iGOPid = IRAPGOPid -1;
     3049        }
     3050        else if(iGOPid == IRAPGOPid -1)
     3051        {
     3052          iGOPid = IRAPGOPid;
     3053          IRAPtoReorder = false;
     3054        }
     3055      }
     3056    }
     3057#endif
    26593058  }
    26603059  delete pcBitstreamRedirect;
     
    29183317    case NAL_UNIT_CODED_SLICE_CRA:        return "CRA";
    29193318    case NAL_UNIT_CODED_SLICE_RADL_R:     return "RADL_R";
     3319    case NAL_UNIT_CODED_SLICE_RADL_N:     return "RADL_N";
    29203320    case NAL_UNIT_CODED_SLICE_RASL_R:     return "RASL_R";
     3321    case NAL_UNIT_CODED_SLICE_RASL_N:     return "RASL_N";
    29213322    case NAL_UNIT_VPS:                    return "VPS";
    29223323    case NAL_UNIT_SPS:                    return "SPS";
     
    30803481         pcSlice->getTLayer(),
    30813482         c,
    3082          NaluToStr( pcSlice->getNalUnitType() ).data().
     3483         NaluToStr( pcSlice->getNalUnitType() ).data(),
    30833484         pcSlice->getSliceQp(),
    30843485         uibits );
     
    31343535    printf("]");
    31353536  }
     3537#if Q0048_CGS_3D_ASYMLUT
     3538  pcPic->setFrameBit( (Int)uibits );
     3539  if( m_layerId && pcSlice->getPPS()->getCGSFlag() )
     3540  {
     3541    m_Enc3DAsymLUTPicUpdate.updatePicCGSBits( pcSlice , m_Enc3DAsymLUTPPS.getPPSBit() );
     3542  }
     3543#endif
    31363544}
    31373545
     
    33163724    return NAL_UNIT_CODED_SLICE_IDR_W_RADL;
    33173725  }
     3726#if EFFICIENT_FIELD_IRAP
     3727  if(isField && pocCurr == 1)
     3728  {
     3729    // to avoid the picture becoming an IRAP
     3730    return NAL_UNIT_CODED_SLICE_TRAIL_R;
     3731  }
     3732#endif
     3733
     3734#if ALLOW_RECOVERY_POINT_AS_RAP
     3735  if(m_pcCfg->getDecodingRefreshType() != 3 && (pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0)
     3736#else
    33183737  if ((pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0)
     3738#endif
    33193739  {
    33203740    if (m_pcCfg->getDecodingRefreshType() == 1)
     
    38284248#endif
    38294249
     4250#if Q0048_CGS_3D_ASYMLUT
     4251Void TEncGOP::xDetermin3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS )
     4252{
     4253  Int nCGSFlag = pSlice->getPPS()->getCGSFlag();
     4254  m_Enc3DAsymLUTPPS.setPPSBit( 0 );
     4255  Double dErrorUpdatedPPS = 0 , dErrorPPS = 0;
     4256  dErrorUpdatedPPS = m_Enc3DAsymLUTPicUpdate.derive3DAsymLUT( pSlice , pCurPic , refLayerIdc , pCfg , bSignalPPS , m_pcEncTop->getElRapSliceTypeB() );
     4257  if( bSignalPPS )
     4258  {
     4259    m_Enc3DAsymLUTPPS.copy3DAsymLUT( &m_Enc3DAsymLUTPicUpdate );
     4260    pSlice->setCGSOverWritePPS( 1 ); // regular PPS update
     4261  }
     4262  else if( nCGSFlag )
     4263  {
     4264    dErrorPPS = m_Enc3DAsymLUTPPS.estimateDistWithCur3DAsymLUT( pCurPic , refLayerIdc );
     4265    Double dFactor = pCfg->getIntraPeriod() == 1 ? 0.99 : 0.9;
     4266    pSlice->setCGSOverWritePPS( dErrorUpdatedPPS < dFactor * dErrorPPS );
     4267    if( pSlice->getCGSOverWritePPS() )
     4268    {
     4269      m_Enc3DAsymLUTPPS.copy3DAsymLUT( &m_Enc3DAsymLUTPicUpdate );
     4270    }
     4271  }
     4272  pSlice->getPPS()->setCGSOutputBitDepthY( m_Enc3DAsymLUTPPS.getOutputBitDepthY() );
     4273  pSlice->getPPS()->setCGSOutputBitDepthC( m_Enc3DAsymLUTPPS.getOutputBitDepthC() );
     4274}
     4275
     4276Void TEncGOP::downScalePic( TComPicYuv* pcYuvSrc, TComPicYuv* pcYuvDest)
     4277{
     4278  Int inputBitDepth = g_bitDepthYLayer[m_layerId];
     4279  Int outputBitDepth = g_bitDepthYLayer[m_layerId];
     4280  {
     4281    pcYuvSrc->setBorderExtension(false);
     4282    pcYuvSrc->extendPicBorder   (); // extend the border.
     4283    pcYuvSrc->setBorderExtension(false);
     4284
     4285    Int iWidth = pcYuvSrc->getWidth();
     4286    Int iHeight =pcYuvSrc->getHeight();
     4287
     4288    if(!m_temp)
     4289      initDs(iWidth, iHeight, m_pcCfg->getIntraPeriod()>1);
     4290
     4291    filterImg(pcYuvSrc->getLumaAddr(), pcYuvSrc->getStride(), pcYuvDest->getLumaAddr(), pcYuvDest->getStride(), iHeight, iWidth,  inputBitDepth-outputBitDepth, 0);
     4292    filterImg(pcYuvSrc->getCbAddr(), pcYuvSrc->getCStride(), pcYuvDest->getCbAddr(), pcYuvDest->getCStride(), iHeight>>1, iWidth>>1, inputBitDepth-outputBitDepth, 1);
     4293    filterImg(pcYuvSrc->getCrAddr(), pcYuvSrc->getCStride(), pcYuvDest->getCrAddr(), pcYuvDest->getCStride(), iHeight>>1, iWidth>>1, inputBitDepth-outputBitDepth, 2); 
     4294  }
     4295}
     4296const int TEncGOP::m_phase_filter_0_t0[4][13]={
     4297  {0,  2,  -3,  -9,   6,  39,  58,  39,   6,  -9,  -3,  2,  0}, 
     4298  {0, 0,  0,  -2,  8,-20, 116, 34, -10,  2,  0, 0,  0},                      //{0,  1,  -1,  -8,  -1,  31,  57,  47,  13,  -7,  -5,  1,  0},  //
     4299  {0,  1,   0,  -7,  -5,  22,  53,  53,  22,  -5,  -7,  0,  1}, 
     4300  {0,  0,   1,  -5,  -7,  13,  47,  57,  31,  -1,  -8,-1,  1} 
     4301};
     4302
     4303const int TEncGOP::m_phase_filter_0_t1[4][13]={
     4304  {0,  4,  0,  -12, 0,  40,  64,  40, 0, -12,  0,  4,  0},
     4305  {0, 0,  0,  -2,  8,-20, 116,34,-10,  2,  0, 0,  0},                      //{0,  1,  -1,  -8,  -1,  31,  57,  47,  13,  -7,  -5,  1,  0},  //
     4306  {0,  1,   0,  -7,  -5,  22,  53,  53,  22,  -5,  -7,  0,  1}, 
     4307  {0,  0,   1,  -5,  -7,  13,  47,  57,  31,  -1,  -8,-1,  1} 
     4308};
     4309const int TEncGOP::m_phase_filter_0_t1_chroma[4][13]={
     4310  {0,  0,  0,   0,  0,   0,  128, 0,  0,  0,  0,  0,  0},
     4311  {0, 0,  0,  -2,  8,-20, 116,34,-10,  2,  0, 0,  0},                      //{0,  1,  -1,  -8,  -1,  31,  57,  47,  13,  -7,  -5,  1,  0},  //
     4312  {0,  1,   0,  -7,  -5,  22,  53,  53,  22,  -5,  -7,  0,  1}, 
     4313  {0,  0,   1,  -5,  -7,  13,  47,  57,  31,  -1,  -8,-1,  1} 
     4314};
     4315
     4316const int TEncGOP::m_phase_filter_1[8][13]={
     4317  {0,   0,  5,  -6,  -10,37,  76,  37,-10,   -6, 5,  0,   0},   
     4318  {0,  -1,  5,  -3,  -12,29,  75,  45,  -7,   -8, 5,  0,   0},   
     4319  {0,  -1,  4,  -1,  -13,22,  73,  52,  -3,  -10, 4,  1,   0},   
     4320  {0,  -1,  4,   1,  -13,14,  70,  59,   2,  -12, 3,  2,  -1}, 
     4321  {0,  -1,  3,   2,  -13, 8,  65,  65,   8,  -13, 2,  3,  -1},   
     4322  {0,  -1,  2,   3,  -12, 2,  59,  70,  14,  -13, 1,  4,  -1},   
     4323  {0,   0,  1,   4,  -10,-3,  52,  73,  22,  -13,-1,  4,  -1},   
     4324  {0,   0,  0,   5,   -8,-7,  45,  75,  29,  -12,-3,  5,  -1}   
     4325};
     4326
     4327Void TEncGOP::filterImg(
     4328    Pel           *src,
     4329    Int           iSrcStride,
     4330    Pel           *dst,
     4331    Int           iDstStride,
     4332    Int           height1, 
     4333    Int           width1, 
     4334    Int           shift,
     4335    Int           plane)
     4336{
     4337  Int length = m_iTap;
     4338  Int height2,width2;
     4339  Int k,iSum;
     4340  Int i0, div_i0, i1;
     4341  Int j0, div_j0, j1;
     4342  const Int *p_filter;
     4343  Pel *p_src, *p_dst;
     4344  Pel *p_src_line, *p_dst_line;
     4345  Int **p_temp, *p_tmp;
     4346  Int shift2 = 2*7+shift;
     4347  Int shift_round = (1 << (shift2 - 1));
     4348  Int iMax = (1<<(g_bitDepthY-shift))-1;
     4349  height2 = (height1 * m_iM) / m_iN;
     4350  width2  = (width1  * m_iM) / m_iN;
     4351
     4352  m_phase_filter = plane? m_phase_filter_chroma : m_phase_filter_luma;
     4353
     4354  // horizontal filtering
     4355  p_src_line = src;
     4356  for(j1 = 0; j1 < height1; j1++)
     4357  {
     4358    i0=-m_iN;
     4359    p_tmp = m_temp[j1];
     4360   
     4361    for(i1 = 0; i1 < width2; i1++)
     4362    {
     4363      i0      += m_iN;
     4364      div_i0   = (i0 / m_iM);
     4365      p_src    =  p_src_line + ( div_i0 - (length >> 1));
     4366      p_filter = m_phase_filter[i0 - div_i0 * m_iM]; // phase_filter[i0 % M]
     4367      iSum     = 0;
     4368      for(k = 0; k < length; k++)
     4369      {
     4370        iSum += (*p_src++) * (*p_filter++);
     4371      }
     4372      *p_tmp++ = iSum;
     4373    }
     4374    p_src_line +=  iSrcStride;
     4375  }
     4376
     4377  // pad temp (vertical)
     4378  for (k=-(length>>1); k<0; k++)
     4379    memcpy(m_temp[k], m_temp[0], width2*sizeof(int));
     4380  for (k=height1; k<(height1+(length>>1)); k++)
     4381    memcpy(m_temp[k], m_temp[k-1], (width2)* sizeof(int));
     4382
     4383  // vertical filtering
     4384  j0 = (plane == 0) ? -m_iN : -(m_iN-1);
     4385 
     4386  p_dst_line = dst;
     4387  for(j1 = 0; j1 < height2; j1++)
     4388  {
     4389    j0      += m_iN;
     4390    div_j0   = (j0 / m_iM);
     4391    p_dst = p_dst_line;
     4392    p_temp   = &m_temp[div_j0 - (length>>1)];
     4393    p_filter = m_phase_filter[j0 - div_j0 * m_iM]; // phase_filter[j0 % M]
     4394    for(i1 = 0; i1 < width2;i1++)
     4395    {
     4396      iSum=0;
     4397      for(k = 0; k < length; k++)
     4398      {
     4399        iSum += p_temp[k][i1] * p_filter[k];
     4400      }
     4401      iSum=((iSum + shift_round) >> shift2);
     4402      *p_dst++ = (short)(iSum > iMax ? iMax : (iSum < 0 ? 0 : iSum));
     4403    }
     4404    p_dst_line += iDstStride;
     4405  }
     4406}
     4407
     4408Void TEncGOP::initDs(Int iWidth, Int iHeight, Int iType)
     4409{
     4410  m_iTap = 13;
     4411  if(g_posScalingFactor[0][0] == (1<<15))
     4412  {
     4413    m_iM = 4;
     4414    m_iN = 8;
     4415    m_phase_filter_luma = iType? m_phase_filter_0_t1 : m_phase_filter_0_t0;
     4416    m_phase_filter_chroma = m_phase_filter_0_t1_chroma;
     4417  }
     4418  else
     4419  {
     4420    m_iM = 8;
     4421    m_iN = 12;
     4422    m_phase_filter_luma = m_phase_filter_chroma =  m_phase_filter_1;
     4423    m_phase_filter = m_phase_filter_1;
     4424  }
     4425
     4426  get_mem2DintWithPad (&m_temp, iHeight, iWidth*m_iM/m_iN,   m_iTap>>1, 0);
     4427}
     4428
     4429Int TEncGOP::get_mem2DintWithPad(Int ***array2D, Int dim0, Int dim1, Int iPadY, Int iPadX)
     4430{
     4431  Int i;
     4432  Int *curr = NULL;
     4433  Int iHeight, iWidth;
     4434
     4435  iHeight = dim0+2*iPadY;
     4436  iWidth = dim1+2*iPadX;
     4437  (*array2D) = (Int**)malloc(iHeight*sizeof(Int*));
     4438  *(*array2D) = (Int* )xMalloc(Int, iHeight*iWidth);
     4439
     4440  (*array2D)[0] += iPadX;
     4441  curr = (*array2D)[0];
     4442  for(i = 1 ; i < iHeight; i++)
     4443  {
     4444    curr += iWidth;
     4445    (*array2D)[i] = curr;
     4446  }
     4447  (*array2D) = &((*array2D)[iPadY]);
     4448
     4449  return 0;
     4450}
     4451
     4452Void TEncGOP::free_mem2DintWithPad(Int **array2D, Int iPadY, Int iPadX)
     4453{
     4454  if (array2D)
     4455  {
     4456    if (*array2D)
     4457      xFree(array2D[-iPadY]-iPadX);
     4458    else
     4459      printf("free_mem2DintWithPad: trying to free unused memory\r\nPress Any Key\r\n");
     4460
     4461    free (&array2D[-iPadY]);
     4462  }
     4463  else
     4464  {
     4465    printf("free_mem2DintWithPad: trying to free unused memory\r\nPress Any Key\r\n");
     4466  }
     4467}
     4468#endif
    38304469#endif //SVC_EXTENSION
    38314470
  • trunk/source/Lib/TLibEncoder/TEncGOP.h

    r644 r713  
    5454#include "TEncSbac.h"
    5555#include "SEIwrite.h"
     56#if Q0048_CGS_3D_ASYMLUT
     57#include "TEnc3DAsymLUT.h"
     58#endif
    5659
    5760#include "TEncAnalyze.h"
     
    8285  Int                     m_iNumPicCoded;
    8386  Bool                    m_bFirst;
     87#if ALLOW_RECOVERY_POINT_AS_RAP
     88  Int                     m_iLastRecoveryPicPOC;
     89#endif
    8490 
    8591  //  Access channel
     
    132138  TEncSearch*             m_pcPredSearch;                       ///< encoder search class
    133139#endif 
     140#if Q0048_CGS_3D_ASYMLUT
     141  TEnc3DAsymLUT           m_Enc3DAsymLUTPicUpdate;
     142  TEnc3DAsymLUT           m_Enc3DAsymLUTPPS;
     143  TComPicYuv*             m_pColorMappedPic;
     144
     145  Int m_iTap;
     146  const Int (*m_phase_filter)[13];
     147  const Int (*m_phase_filter_luma)[13];
     148  const Int (*m_phase_filter_chroma)[13];
     149  Int m_iM, m_iN;
     150  static const Int m_phase_filter_0_t0[4][13];
     151  static const Int m_phase_filter_0_t1[4][13];
     152  static const Int m_phase_filter_0_t1_chroma[4][13];
     153  static const Int m_phase_filter_1[8][13];
     154  Int   **m_temp;
     155#endif
    134156#endif
    135157 
     
    187209
    188210  SEIToneMappingInfo*     xCreateSEIToneMappingInfo();
     211#if Q0074_SEI_COLOR_MAPPING
     212  SEIColorMappingInfo*    xCreateSEIColorMappingInfo( Char* file );
     213#endif
    189214
    190215  Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps);
     
    214239  SEIScalableNesting* xCreateBspNestingSEI(TComSlice *pcSlice);
    215240#endif
     241#if Q0048_CGS_3D_ASYMLUT
     242  Void xDetermin3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS );
     243  Void downScalePic( TComPicYuv* pcYuvSrc, TComPicYuv* pcYuvDest);
     244  Void downScaleComponent2x2( const Pel* pSrc, Pel* pDest, const Int iSrcStride, const Int iDestStride, const Int iSrcWidth, const Int iSrcHeight, const Int inputBitDepth, const Int outputBitDepth );
     245  inline Short  xClip( Short x , Int bitdepth );
     246  Void initDs(Int iWidth, Int iHeight, Int iType);
     247  Void filterImg(
     248    Pel           *src,
     249    Int           iSrcStride,
     250    Pel           *dst,
     251    Int           iDstStride,
     252    Int           height1, 
     253    Int           width1, 
     254    Int           shift,
     255    Int           plane);
     256
     257  Int get_mem2DintWithPad(Int ***array2D, Int dim0, Int dim1, Int iPadY, Int iPadX);
     258  Void free_mem2DintWithPad(Int **array2D, Int iPadY, Int iPadX);
     259#endif
    216260#endif //SVC_EXTENSION
    217261};// END CLASS DEFINITION TEncGOP
  • trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp

    r644 r713  
    952952        for (y=0; y<endY; y++)
    953953        {
     954#if SAO_SGN_FUNC
     955          signLeft = (Char)sgn(srcLine[startX] - srcLine[startX-1]);
     956#else
    954957          signLeft = (Char)m_sign[srcLine[startX] - srcLine[startX-1]];
     958#endif
    955959          for (x=startX; x<endX; x++)
    956960          {
     961#if SAO_SGN_FUNC
     962            signRight =  (Char)sgn(srcLine[x] - srcLine[x+1]);
     963#else
    957964            signRight =  (Char)m_sign[srcLine[x] - srcLine[x+1]];
     965#endif
    958966            edgeType  =  signRight + signLeft;
    959967            signLeft  = -signRight;
     
    975983            for(y=0; y<skipLinesB[typeIdx]; y++)
    976984            {
     985#if SAO_SGN_FUNC
     986              signLeft = (Char)sgn(srcLine[startX] - srcLine[startX-1]);
     987#else
    977988              signLeft = (Char)m_sign[srcLine[startX] - srcLine[startX-1]];
     989#endif
    978990              for (x=startX; x<endX; x++)
    979991              {
     992#if SAO_SGN_FUNC
     993                signRight =  (Char)sgn(srcLine[x] - srcLine[x+1]);
     994#else
    980995                signRight =  (Char)m_sign[srcLine[x] - srcLine[x+1]];
     996#endif
    981997                edgeType  =  signRight + signLeft;
    982998                signLeft  = -signRight;
     
    10261042#endif
    10271043        {
     1044#if SAO_SGN_FUNC
     1045          signUpLine[x] = (Char)sgn(srcLine[x] - srcLineAbove[x]);
     1046#else
    10281047          signUpLine[x] = (Char)m_sign[srcLine[x] - srcLineAbove[x]];
     1048#endif
    10291049        }
    10301050
     
    10401060#endif
    10411061          {
     1062#if SAO_SGN_FUNC
     1063            signDown  = (Char)sgn(srcLine[x] - srcLineBelow[x]);
     1064#else
    10421065            signDown  = (Char)m_sign[srcLine[x] - srcLineBelow[x]];
     1066#endif
    10431067            edgeType  = signDown + signUpLine[x];
    10441068            signUpLine[x]= -signDown;
     
    10651089              for (x=startX; x<endX; x++)
    10661090              {
     1091#if SAO_SGN_FUNC
     1092                edgeType = sgn(srcLine[x] - srcLineBelow[x]) + sgn(srcLine[x] - srcLineAbove[x]);
     1093#else
    10671094                edgeType = m_sign[srcLine[x] - srcLineBelow[x]] + m_sign[srcLine[x] - srcLineAbove[x]];
     1095#endif
    10681096                diff [edgeType] += (orgLine[x] - srcLine[x]);
    10691097                count[edgeType] ++;
     
    11081136        for (x=startX; x<endX+1; x++)
    11091137        {
     1138#if SAO_SGN_FUNC
     1139          signUpLine[x] = (Char)sgn(srcLineBelow[x] - srcLine[x-1]);
     1140#else
    11101141          signUpLine[x] = (Char)m_sign[srcLineBelow[x] - srcLine[x-1]];
     1142#endif
    11111143        }
    11121144
     
    11221154        for(x=firstLineStartX; x<firstLineEndX; x++)
    11231155        {
     1156#if SAO_SGN_FUNC
     1157          edgeType = sgn(srcLine[x] - srcLineAbove[x-1]) - signUpLine[x+1];
     1158#else
    11241159          edgeType = m_sign[srcLine[x] - srcLineAbove[x-1]] - signUpLine[x+1];
     1160#endif
    11251161          diff [edgeType] += (orgLine[x] - srcLine[x]);
    11261162          count[edgeType] ++;
     
    11371173          for (x=startX; x<endX; x++)
    11381174          {
     1175#if SAO_SGN_FUNC
     1176            signDown = (Char)sgn(srcLine[x] - srcLineBelow[x+1]);
     1177#else
    11391178            signDown = (Char)m_sign[srcLine[x] - srcLineBelow[x+1]] ;
     1179#endif
    11401180            edgeType = signDown + signUpLine[x];
    11411181            diff [edgeType] += (orgLine[x] - srcLine[x]);
     
    11441184            signDownLine[x+1] = -signDown;
    11451185          }
     1186#if SAO_SGN_FUNC
     1187          signDownLine[startX] = (Char)sgn(srcLineBelow[startX] - srcLine[startX-1]);
     1188#else
    11461189          signDownLine[startX] = (Char)m_sign[srcLineBelow[startX] - srcLine[startX-1]];
     1190#endif
    11471191
    11481192          signTmpLine  = signUpLine;
     
    11681212              for (x=startX; x< endX; x++)
    11691213              {
     1214#if SAO_SGN_FUNC
     1215                edgeType = sgn(srcLine[x] - srcLineBelow[x+1]) + sgn(srcLine[x] - srcLineAbove[x-1]);
     1216#else
    11701217                edgeType = m_sign[srcLine[x] - srcLineBelow[x+1]] + m_sign[srcLine[x] - srcLineAbove[x-1]];
     1218#endif
    11711219                diff [edgeType] += (orgLine[x] - srcLine[x]);
    11721220                count[edgeType] ++;
     
    12061254        for (x=startX-1; x<endX; x++)
    12071255        {
     1256#if SAO_SGN_FUNC
     1257          signUpLine[x] = (Char)sgn(srcLineBelow[x] - srcLine[x+1]);
     1258#else
    12081259          signUpLine[x] = (Char)m_sign[srcLineBelow[x] - srcLine[x+1]];
     1260#endif
    12091261        }
    12101262
     
    12251277        for(x=firstLineStartX; x<firstLineEndX; x++)
    12261278        {
     1279#if SAO_SGN_FUNC
     1280          edgeType = sgn(srcLine[x] - srcLineAbove[x+1]) - signUpLine[x-1];
     1281#else
    12271282          edgeType = m_sign[srcLine[x] - srcLineAbove[x+1]] - signUpLine[x-1];
     1283#endif
    12281284          diff [edgeType] += (orgLine[x] - srcLine[x]);
    12291285          count[edgeType] ++;
     
    12401296          for(x=startX; x<endX; x++)
    12411297          {
     1298#if SAO_SGN_FUNC
     1299            signDown = (Char)sgn(srcLine[x] - srcLineBelow[x-1]);
     1300#else
    12421301            signDown = (Char)m_sign[srcLine[x] - srcLineBelow[x-1]] ;
     1302#endif
    12431303            edgeType = signDown + signUpLine[x];
    12441304
     
    12481308            signUpLine[x-1] = -signDown;
    12491309          }
     1310#if SAO_SGN_FUNC
     1311          signUpLine[endX-1] = (Char)sgn(srcLineBelow[endX-1] - srcLine[endX]);
     1312#else
    12501313          signUpLine[endX-1] = (Char)m_sign[srcLineBelow[endX-1] - srcLine[endX]];
     1314#endif
    12511315          srcLine  += srcStride;
    12521316          orgLine  += orgStride;
     
    12671331              for (x=startX; x<endX; x++)
    12681332              {
     1333#if SAO_SGN_FUNC
     1334                edgeType = sgn(srcLine[x] - srcLineBelow[x-1]) + sgn(srcLine[x] - srcLineAbove[x+1]);
     1335#else
    12691336                edgeType = m_sign[srcLine[x] - srcLineBelow[x-1]] + m_sign[srcLine[x] - srcLineAbove[x+1]];
     1337#endif
    12701338                diff [edgeType] += (orgLine[x] - srcLine[x]);
    12711339                count[edgeType] ++;
  • trunk/source/Lib/TLibEncoder/TEncSbac.cpp

    r644 r713  
    248248}
    249249
    250 Void TEncSbac::codePPS( TComPPS* pcPPS )
     250Void TEncSbac::codePPS( TComPPS* pcPPS
     251#if Q0048_CGS_3D_ASYMLUT
     252  , TEnc3DAsymLUT * pc3DAsymLUT
     253#endif
     254  )
    251255{
    252256  assert (0);
  • trunk/source/Lib/TLibEncoder/TEncSbac.h

    r644 r713  
    9292  Void  codeVPS                 ( TComVPS* pcVPS );
    9393  Void  codeSPS                 ( TComSPS* pcSPS     );
    94   Void  codePPS                 ( TComPPS* pcPPS     );
     94  Void  codePPS                 ( TComPPS* pcPPS     
     95#if Q0048_CGS_3D_ASYMLUT
     96    , TEnc3DAsymLUT * pc3DAsymLUT
     97#endif
     98    );
    9599  Void  codeSliceHeader         ( TComSlice* pcSlice );
    96100  Void  codeTilesWPPEntryPoint( TComSlice* pSlice );
    97 #if POC_RESET_IDC_SIGNALLING
    98   Void  codeSliceHeaderExtn     ( TComSlice* pSlice, Int shBitsWrittenTillNow );
    99 #endif
    100101  Void  codeTerminatingBit      ( UInt uilsLast      );
    101102  Void  codeSliceFinish         ();
     
    108109
    109110#if SVC_EXTENSION
     111#if POC_RESET_IDC_SIGNALLING
     112  Void  codeSliceHeaderExtn     ( TComSlice* pSlice, Int shBitsWrittenTillNow );
     113#endif
    110114  Void codeSAOOffsetParam(Int compIdx, SAOOffset& ctbParam, Bool sliceEnabled, UInt* saoMaxOffsetQVal);
    111115  Void codeSAOBlkParam(SAOBlkParam& saoBlkParam
  • trunk/source/Lib/TLibEncoder/TEncSearch.cpp

    r595 r713  
    23982398{
    23992399  UInt    uiDepth        = pcCU->getDepth(0);
    2400   UInt    uiNumPU        = pcCU->getNumPartInter();
     2400  UInt    uiNumPU        = pcCU->getNumPartitions();
    24012401  UInt    uiInitTrDepth  = pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1;
    24022402  UInt    uiWidth        = pcCU->getWidth (0) >> uiInitTrDepth;
     
    31303130  TComMv        cMvTemp[2][33];
    31313131 
    3132   Int           iNumPart    = pcCU->getNumPartInter();
     3132  Int           iNumPart    = pcCU->getNumPartitions();
    31333133  Int           iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2;
    31343134 
     
    46124612   
    46134613    m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST] );
    4614 #if 0 // check
    4615     {
    4616       m_pcEntropyCoder->resetBits();
    4617       m_pcEntropyCoder->encodeCoeff( pcCU, 0, pcCU->getDepth(0), pcCU->getWidth(0), pcCU->getHeight(0) );
    4618       const UInt uiBitsForCoeff = m_pcEntropyCoder->getNumberOfWrittenBits();
    4619       m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST] );
    4620       if( uiBitsForCoeff != uiBits )
    4621         assert( 0 );
    4622     }
    4623 #endif
     4614   
    46244615    uiBits = 0;
    46254616    {
  • trunk/source/Lib/TLibEncoder/TEncSlice.cpp

    r644 r713  
    225225  Int depth;
    226226  {
     227#if FIX_FIELD_DEPTH   
     228    Int poc = rpcSlice->getPOC();
     229    if(isField)
     230    {
     231      poc = (poc/2)%(m_pcCfg->getGOPSize()/2);
     232    }
     233    else
     234    {
     235      poc = poc%m_pcCfg->getGOPSize();   
     236    }
     237#else
    227238    Int poc = rpcSlice->getPOC()%m_pcCfg->getGOPSize();
     239#endif
    228240    if ( poc == 0 )
    229241    {
     
    248260      }
    249261    }
     262#if FIX_FIELD_DEPTH 
     263#if HARMONIZE_GOP_FIRST_FIELD_COUPLE
     264    if(poc != 0)
     265    {
     266#endif
     267    if(isField && rpcSlice->getPOC()%2 == 1)
     268    {
     269      depth ++;
     270    }
     271#if HARMONIZE_GOP_FIRST_FIELD_COUPLE
     272  }
     273#endif
     274#endif
    250275  }
    251276
     
    254279
    255280  eSliceType=B_SLICE;
     281#if EFFICIENT_FIELD_IRAP
     282  if(!(isField && pocLast == 1))
     283  {
     284#endif // EFFICIENT_FIELD_IRAP
     285#if ALLOW_RECOVERY_POINT_AS_RAP
     286  if(m_pcCfg->getDecodingRefreshType() == 3)
     287  {
     288    eSliceType = (pocLast == 0 || pocCurr % m_pcCfg->getIntraPeriod() == 0             || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
     289  }
     290  else
     291  {
    256292  eSliceType = (pocLast == 0 || (pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
     293  }
     294#else
     295  eSliceType = (pocLast == 0 || (pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
     296#endif
     297#if EFFICIENT_FIELD_IRAP
     298  }
     299#endif
    257300
    258301  rpcSlice->setSliceType    ( eSliceType );
     
    423466#if HB_LAMBDA_FOR_LDC
    424467  // restore original slice type
     468 
     469#if EFFICIENT_FIELD_IRAP
     470  if(!(isField && pocLast == 1))
     471  {
     472#endif // EFFICIENT_FIELD_IRAP
     473#if ALLOW_RECOVERY_POINT_AS_RAP
     474  if(m_pcCfg->getDecodingRefreshType() == 3)
     475  {
     476    eSliceType = (pocLast == 0 || (pocCurr)           % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
     477
     478  }
     479  else
     480  {
    425481  eSliceType = (pocLast == 0 || (pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
     482  }
     483#else
     484  eSliceType = (pocLast == 0 || (pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
     485#endif
     486#if EFFICIENT_FIELD_IRAP
     487  }
     488#endif // EFFICIENT_FIELD_IRAP
    426489
    427490#if SVC_EXTENSION
     
    544607  // store lambda
    545608  slice->setSliceQp( sliceQP );
     609#if ADAPTIVE_QP_SELECTION
    546610  slice->setSliceQpBase ( sliceQP );
     611#endif
    547612  m_pcRdCost ->setLambda( lambda );
    548613  // for RDO
     
    10411106
    10421107      m_pcRateCtrl->setRCQP( estQP );
     1108#if ADAPTIVE_QP_SELECTION
    10431109      pcCU->getSlice()->setSliceQpBase( estQP );
     1110#endif
    10441111    }
    10451112
  • trunk/source/Lib/TLibEncoder/TEncTop.cpp

    r644 r713  
    795795          Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );
    796796
    797           if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets || !sameBitDepths )
     797          if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets || !sameBitDepths
     798#if Q0048_CGS_3D_ASYMLUT
     799            || m_cPPS.getCGSFlag() > 0
     800#endif
     801#if LAYER_CTB
     802            || pcEncTopBase->getSPS()->getMaxCUWidth() != m_cSPS.getMaxCUWidth() || pcEncTopBase->getSPS()->getMaxCUHeight() != m_cSPS.getMaxCUHeight() || pcEncTopBase->getSPS()->getMaxCUDepth() != m_cSPS.getMaxCUDepth()
     803#endif
     804            )
    798805#else
    799806          if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets )
     
    857864          Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );
    858865
    859           if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets || !sameBitDepths )
     866          if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets || !sameBitDepths
     867#if Q0048_CGS_3D_ASYMLUT
     868            || m_cPPS.getCGSFlag() > 0
     869#endif
     870#if LAYER_CTB
     871            || pcEncTopBase->getSPS()->getMaxCUWidth() != m_cSPS.getMaxCUWidth() || pcEncTopBase->getSPS()->getMaxCUHeight() != m_cSPS.getMaxCUHeight() || pcEncTopBase->getSPS()->getMaxCUDepth() != m_cSPS.getMaxCUDepth()
     872#endif
     873)
    860874#else
    861875          if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets )
     
    11881202  }
    11891203#endif
     1204#if Q0048_CGS_3D_ASYMLUT
     1205  m_cPPS.setCGSFlag( m_nCGSFlag );
     1206#endif
    11901207}
    11911208
  • trunk/source/Lib/TLibEncoder/TEncTop.h

    r644 r713  
    273273
    274274  /// encode several number of pictures until end-of-sequence
    275   Void encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
     275  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
    276276              std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff);
    277277
Note: See TracChangeset for help on using the changeset viewer.