Ignore:
Timestamp:
23 May 2013, 15:40:36 (12 years ago)
Author:
tech
Message:

Integrated 3D encoder control, camera parameters, renderer and MV fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-DEV-0.2-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r401 r438  
    9696#if L0045_NON_NESTED_SEI_RESTRICTIONS
    9797  xResetNonNestedSEIPresentFlags();
    98 #if K0180_SCALABLE_NESTING_SEI
    99   xResetNestedSEIPresentFlags();
    100 #endif
    101 #endif
     98#endif
     99
    102100#if H_MV
    103101  m_layerId      = 0;
     
    108106#endif
    109107#endif
     108
    110109  return;
    111110}
     
    212211}
    213212
    214 #if J0149_TONE_MAPPING_SEI
    215 SEIToneMappingInfo*  TEncGOP::xCreateSEIToneMappingInfo()
    216 {
    217   SEIToneMappingInfo *seiToneMappingInfo = new SEIToneMappingInfo();
    218   seiToneMappingInfo->m_toneMapId = m_pcCfg->getTMISEIToneMapId();
    219   seiToneMappingInfo->m_toneMapCancelFlag = m_pcCfg->getTMISEIToneMapCancelFlag();
    220   seiToneMappingInfo->m_toneMapPersistenceFlag = m_pcCfg->getTMISEIToneMapPersistenceFlag();
    221 
    222   seiToneMappingInfo->m_codedDataBitDepth = m_pcCfg->getTMISEICodedDataBitDepth();
    223   assert(seiToneMappingInfo->m_codedDataBitDepth >= 8 && seiToneMappingInfo->m_codedDataBitDepth <= 14);
    224   seiToneMappingInfo->m_targetBitDepth = m_pcCfg->getTMISEITargetBitDepth();
    225   assert( (seiToneMappingInfo->m_targetBitDepth >= 1 && seiToneMappingInfo->m_targetBitDepth <= 17) || (seiToneMappingInfo->m_targetBitDepth  == 255) );
    226   seiToneMappingInfo->m_modelId = m_pcCfg->getTMISEIModelID();
    227   assert(seiToneMappingInfo->m_modelId >=0 &&seiToneMappingInfo->m_modelId<=4);
    228 
    229   switch( seiToneMappingInfo->m_modelId)
    230   {
    231   case 0:
    232     {
    233       seiToneMappingInfo->m_minValue = m_pcCfg->getTMISEIMinValue();
    234       seiToneMappingInfo->m_maxValue = m_pcCfg->getTMISEIMaxValue();
    235       break;
    236     }
    237   case 1:
    238     {
    239       seiToneMappingInfo->m_sigmoidMidpoint = m_pcCfg->getTMISEISigmoidMidpoint();
    240       seiToneMappingInfo->m_sigmoidWidth = m_pcCfg->getTMISEISigmoidWidth();
    241       break;
    242     }
    243   case 2:
    244     {
    245       UInt num = 1u<<(seiToneMappingInfo->m_targetBitDepth);
    246       seiToneMappingInfo->m_startOfCodedInterval.resize(num);
    247       Int* ptmp = m_pcCfg->getTMISEIStartOfCodedInterva();
    248       if(ptmp)
    249       {
    250         for(int i=0; i<num;i++)
    251         {
    252           seiToneMappingInfo->m_startOfCodedInterval[i] = ptmp[i];
    253         }
    254       }
    255       break;
    256     }
    257   case 3:
    258     {
    259       seiToneMappingInfo->m_numPivots = m_pcCfg->getTMISEINumPivots();
    260       seiToneMappingInfo->m_codedPivotValue.resize(seiToneMappingInfo->m_numPivots);
    261       seiToneMappingInfo->m_targetPivotValue.resize(seiToneMappingInfo->m_numPivots);
    262       Int* ptmpcoded = m_pcCfg->getTMISEICodedPivotValue();
    263       Int* ptmptarget = m_pcCfg->getTMISEITargetPivotValue();
    264       if(ptmpcoded&&ptmptarget)
    265       {
    266         for(int i=0; i<(seiToneMappingInfo->m_numPivots);i++)
    267         {
    268           seiToneMappingInfo->m_codedPivotValue[i]=ptmpcoded[i];
    269           seiToneMappingInfo->m_targetPivotValue[i]=ptmptarget[i];
    270          }
    271        }
    272        break;
    273      }
    274   case 4:
    275      {
    276        seiToneMappingInfo->m_cameraIsoSpeedIdc = m_pcCfg->getTMISEICameraIsoSpeedIdc();
    277        seiToneMappingInfo->m_cameraIsoSpeedValue = m_pcCfg->getTMISEICameraIsoSpeedValue();
    278        assert( seiToneMappingInfo->m_cameraIsoSpeedValue !=0 );
    279        seiToneMappingInfo->m_exposureCompensationValueSignFlag = m_pcCfg->getTMISEIExposureCompensationValueSignFlag();
    280        seiToneMappingInfo->m_exposureCompensationValueNumerator = m_pcCfg->getTMISEIExposureCompensationValueNumerator();
    281        seiToneMappingInfo->m_exposureCompensationValueDenomIdc = m_pcCfg->getTMISEIExposureCompensationValueDenomIdc();
    282        seiToneMappingInfo->m_refScreenLuminanceWhite = m_pcCfg->getTMISEIRefScreenLuminanceWhite();
    283        seiToneMappingInfo->m_extendedRangeWhiteLevel = m_pcCfg->getTMISEIExtendedRangeWhiteLevel();
    284        assert( seiToneMappingInfo->m_extendedRangeWhiteLevel >= 100 );
    285        seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue = m_pcCfg->getTMISEINominalBlackLevelLumaCodeValue();
    286        seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue = m_pcCfg->getTMISEINominalWhiteLevelLumaCodeValue();
    287        assert( seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue > seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue );
    288        seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue = m_pcCfg->getTMISEIExtendedWhiteLevelLumaCodeValue();
    289        assert( seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue >= seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue );
    290        break;
    291     }
    292   default:
    293     {
    294       assert(!"Undefined SEIToneMapModelId");
    295       break;
    296     }
    297   }
    298   return seiToneMappingInfo;
    299 }
    300 #endif
    301213Void TEncGOP::xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps)
    302214{
    303   OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
     215  OutputNALUnit nalu(NAL_UNIT_SEI);
    304216
    305217  if(m_pcCfg->getActiveParameterSetsSEIEnabled())
     
    322234    SEIFramePacking *sei = xCreateSEIFramePacking ();
    323235
    324     nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
     236    nalu = NALUnit(NAL_UNIT_SEI);
    325237    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    326238    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     
    333245    SEIDisplayOrientation *sei = xCreateSEIDisplayOrientation();
    334246
    335     nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
     247    nalu = NALUnit(NAL_UNIT_SEI);
    336248    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    337249    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     
    340252    delete sei;
    341253  }
    342 #if J0149_TONE_MAPPING_SEI
    343   if(m_pcCfg->getToneMappingInfoSEIEnabled())
    344   {
    345     SEIToneMappingInfo *sei = xCreateSEIToneMappingInfo ();
    346      
    347     nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    348     m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    349     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
    350     writeRBSPTrailingBits(nalu.m_Bitstream);
    351     accessUnit.push_back(new NALUnitEBSP(nalu));
    352     delete sei;
    353   }
    354 #endif
    355254}
    356255
     
    358257// Public member functions
    359258// ====================================================================================================================
     259
    360260#if H_MV
    361261Void TEncGOP::initGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP)
     
    365265}
    366266#endif
     267
    367268#if H_MV
    368269Void TEncGOP::compressPicInGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Int iGOPid)
     
    374275  TComPicYuv*     pcPicYuvRecOut;
    375276  TComSlice*      pcSlice;
    376   TComOutputBitstream  *pcBitstreamRedirect;
    377   pcBitstreamRedirect = new TComOutputBitstream;
     277  TComOutputBitstream* pcBitstreamRedirect = new TComOutputBitstream;
    378278  AccessUnit::iterator  itLocationToPushSliceHeaderNALU; // used to store location where NALU containing slice header is to be inserted
    379279  UInt                  uiOneBitstreamPerSliceLength = 0;
     
    386286  m_iNumPicCoded = 0;
    387287#endif
     288
    388289  SEIPictureTiming pictureTimingSEI;
    389 #if L0208_SOP_DESCRIPTION_SEI
    390   Bool writeSOP = m_pcCfg->getSOPDescriptionSEIEnabled();
    391 #endif
    392 #if K0180_SCALABLE_NESTING_SEI
    393   // Initialize Scalable Nesting SEI with single layer values
    394   SEIScalableNesting scalableNestingSEI;
    395   scalableNestingSEI.m_bitStreamSubsetFlag           = 1;      // If the nested SEI messages are picture buffereing SEI mesages, picure timing SEI messages or sub-picture timing SEI messages, bitstream_subset_flag shall be equal to 1
    396   scalableNestingSEI.m_nestingOpFlag                 = 0;
    397   scalableNestingSEI.m_nestingNumOpsMinus1           = 0;      //nesting_num_ops_minus1
    398   scalableNestingSEI.m_allLayersFlag                 = 0;
    399   scalableNestingSEI.m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1;  //nesting_no_op_max_temporal_id_plus1
    400   scalableNestingSEI.m_nestingNumLayersMinus1        = 1 - 1;  //nesting_num_layers_minus1
    401   scalableNestingSEI.m_nestingLayerId[0]             = 0;
    402   scalableNestingSEI.m_callerOwnsSEIs                = true;
    403 #endif
    404290#if L0044_DU_DPB_OUTPUT_DELAY_HRD
    405291  Int picSptDpbOutputDuDelay = 0;
     
    408294  UInt *accumNalsDU = NULL;
    409295  SEIDecodingUnitInfo decodingUnitInfoSEI;
     296
    410297#if !H_MV
    411298  for ( Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ )
    412299#endif
     300
    413301  {
    414302    UInt uiColDir = 1;
     
    469357    if(pocCurr>=m_pcCfg->getFramesToBeEncoded())
    470358    {
     359
    471360#if H_MV
    472361      delete pcBitstreamRedirect;
     
    475364      continue;
    476365#endif
    477     }
    478 
    479     if( getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_N_LP )
     366
     367    }
     368
     369    if( getNalUnitType(pocCurr) == NAL_UNIT_CODED_SLICE_IDR || getNalUnitType(pocCurr) == NAL_UNIT_CODED_SLICE_IDR_N_LP )
    480370    {
    481371      m_iLastIDR = pocCurr;
     
    495385    pcSlice->setLastIDR(m_iLastIDR);
    496386    pcSlice->setSliceIdx(0);
     387
    497388#if H_MV
    498389    pcPic  ->setLayerId     ( getLayerId() );
     
    506397#endif
    507398#endif
     399
    508400    //set default slice level flag to the same as SPS level flag
    509401    pcSlice->setLFCrossSliceBoundaryFlag(  pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()  );
     
    545437#if H_MV
    546438    // Set the nal unit type
    547     pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR));
     439    pcSlice->setNalUnitType(getNalUnitType(pocCurr));
    548440    if( pcSlice->getSliceType() == B_SLICE )
    549441    {
     
    559451    }
    560452    // Set the nal unit type
    561     pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR));
    562 #endif
    563     if(pcSlice->getTemporalLayerNonReferenceFlag())
    564     {
    565       if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R)
     453    pcSlice->setNalUnitType(getNalUnitType(pocCurr));
     454#endif
     455    if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R)
     456    {
     457      if(pcSlice->getTemporalLayerNonReferenceFlag())
    566458      {
    567459        pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TRAIL_N);
    568       }
    569       if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_RADL_R)
    570       {
    571         pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_RADL_N);
    572       }
    573       if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_RASL_R)
    574       {
    575         pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_RASL_N);
    576460      }
    577461    }
     
    598482        else
    599483        {
    600           pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA_R);
     484          pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA);
    601485        }
    602486      }
     
    684568    }
    685569#endif
    686 #if !L0034_COMBINED_LIST_CLEANUP
     570
    687571    if (pcSlice->getSliceType() != B_SLICE || !pcSlice->getSPS()->getUseLComb())
    688572    {
     
    696580      pcSlice->setNumRefIdx(REF_PIC_LIST_C, pcSlice->getNumRefIdx(REF_PIC_LIST_0));
    697581    }
    698 #endif
    699582
    700583    if (pcSlice->getSliceType() == B_SLICE)
     
    722605      pcSlice->setCheckLDC(bLowDelay); 
    723606    }
    724     else
    725     {
    726       pcSlice->setCheckLDC(true); 
    727     }
    728607
    729608    uiColDir = 1-uiColDir;
     
    732611    pcSlice->setRefPOCList();
    733612
    734 #if L0034_COMBINED_LIST_CLEANUP
    735     pcSlice->setList1IdxToList0Idx();
    736 #else
    737613    pcSlice->setNoBackPredFlag( false );
    738614    if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getRefPicListCombinationFlag())
     
    758634    }
    759635    pcSlice->generateCombinedList();
    760 #endif
    761636
    762637    if (m_pcEncTop->getTMVPModeId() == 2)
     
    1064939    Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag();
    1065940    m_pcLoopFilter->setCfg(bLFCrossTileBoundary);
    1066 #if L0386_DB_METRIC
    1067     if ( m_pcCfg->getDeblockingFilterMetric() )
    1068     {
    1069       dblMetric(pcPic, uiNumSlices);
    1070     }
    1071 #endif
    1072941    m_pcLoopFilter->loopFilterPic( pcPic );
    1073942
     
    11681037    }
    11691038
    1170 #if L0208_SOP_DESCRIPTION_SEI
    1171     if (writeSOP) // write SOP description SEI (if enabled) at the beginning of GOP
    1172     {
    1173       Int SOPcurrPOC = pocCurr;
    1174 
    1175       OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    1176       m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    1177       m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    1178 
    1179       SEISOPDescription SOPDescriptionSEI;
    1180       SOPDescriptionSEI.m_sopSeqParameterSetId = pcSlice->getSPS()->getSPSId();
    1181 
    1182       UInt i = 0;
    1183       UInt prevEntryId = iGOPid;
    1184       for (j = iGOPid; j < m_iGopSize; j++)
    1185       {
    1186         Int deltaPOC = m_pcCfg->getGOPEntry(j).m_POC - m_pcCfg->getGOPEntry(prevEntryId).m_POC;
    1187         if ((SOPcurrPOC + deltaPOC) < m_pcCfg->getFramesToBeEncoded())
    1188         {
    1189           SOPcurrPOC += deltaPOC;
    1190           SOPDescriptionSEI.m_sopDescVclNaluType[i] = getNalUnitType(SOPcurrPOC, m_iLastIDR);
    1191           SOPDescriptionSEI.m_sopDescTemporalId[i] = m_pcCfg->getGOPEntry(j).m_temporalId;
    1192           SOPDescriptionSEI.m_sopDescStRpsIdx[i] = m_pcEncTop->getReferencePictureSetIdxForSOP(pcSlice, SOPcurrPOC, j);
    1193           SOPDescriptionSEI.m_sopDescPocDelta[i] = deltaPOC;
    1194 
    1195           prevEntryId = j;
    1196           i++;
    1197         }
    1198       }
    1199 
    1200       SOPDescriptionSEI.m_numPicsInSopMinus1 = i - 1;
    1201 
    1202       m_seiWriter.writeSEImessage( nalu.m_Bitstream, SOPDescriptionSEI, pcSlice->getSPS());
    1203       writeRBSPTrailingBits(nalu.m_Bitstream);
    1204       accessUnit.push_back(new NALUnitEBSP(nalu));
    1205 
    1206       writeSOP = false;
    1207     }
    1208 #endif
    1209 
    12101039    if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) &&
    12111040        ( pcSlice->getSPS()->getVuiParametersPresentFlag() ) &&
     
    12531082       || ( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getVclHrdParametersPresentFlag() ) ) )
    12541083    {
    1255       OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
     1084      OutputNALUnit nalu(NAL_UNIT_SEI);
    12561085      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    12571086      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    12941123      writeRBSPTrailingBits(nalu.m_Bitstream);
    12951124#if L0045_NON_NESTED_SEI_RESTRICTIONS
    1296       {
    12971125      UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    12981126      UInt offsetPosition = m_activeParameterSetSEIPresentInAU;   // Insert BP SEI after APS SEI
     
    13041132      accessUnit.insert(it, new NALUnitEBSP(nalu));
    13051133      m_bufferingPeriodSEIPresentInAU = true;
    1306       }
    13071134#else
    13081135      accessUnit.push_back(new NALUnitEBSP(nalu));
    13091136#endif
    13101137
    1311 #if K0180_SCALABLE_NESTING_SEI
    1312       if (m_pcCfg->getScalableNestingSEIEnabled())
    1313       {
    1314         OutputNALUnit naluTmp(NAL_UNIT_PREFIX_SEI);
    1315         m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    1316         m_pcEntropyCoder->setBitstream(&naluTmp.m_Bitstream);
    1317         scalableNestingSEI.m_nestedSEIs.clear();
    1318         scalableNestingSEI.m_nestedSEIs.push_back(&sei_buffering_period);
    1319         m_seiWriter.writeSEImessage( naluTmp.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());
    1320         writeRBSPTrailingBits(naluTmp.m_Bitstream);
    1321 #if L0045_NON_NESTED_SEI_RESTRICTIONS
    1322         UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    1323         UInt offsetPosition = m_activeParameterSetSEIPresentInAU + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU;   // Insert BP SEI after non-nested APS, BP and PT SEIs
    1324         AccessUnit::iterator it;
    1325         for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++)
    1326         {
    1327           it++;
    1328         }
    1329         accessUnit.insert(it, new NALUnitEBSP(naluTmp));
    1330         m_nestedBufferingPeriodSEIPresentInAU = true;
    1331 #else
    1332         accessUnit.push_back(new NALUnitEBSP(naluTmp));
    1333 #endif
    1334       }
    1335 #endif
    1336 
    13371138      m_lastBPSEI = m_totalCoded;
    13381139      m_cpbRemovalDelay = 0;
     
    13441145      {
    13451146        // Gradual decoding refresh SEI
    1346         OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
     1147        OutputNALUnit nalu(NAL_UNIT_SEI);
    13471148        m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    13481149        m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    13561157      }
    13571158    // Recovery point SEI
    1358       OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
     1159      OutputNALUnit nalu(NAL_UNIT_SEI);
    13591160      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    13601161      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    15471348
    15481349          pcSlice->setTileOffstForMultES( uiOneBitstreamPerSliceLength );
     1350          if (!sliceSegment)
     1351          {
    15491352            pcSlice->setTileLocationCount ( 0 );
    1550           m_pcSliceEncoder->encodeSlice(pcPic, pcSubstreamsOut);
     1353            m_pcSliceEncoder->encodeSlice(pcPic, pcBitstreamRedirect, pcSubstreamsOut); // redirect is only used for CAVLC tile position info.
     1354          }
     1355          else
     1356          {
     1357            m_pcSliceEncoder->encodeSlice(pcPic, &nalu.m_Bitstream, pcSubstreamsOut); // nalu.m_Bitstream is only used for CAVLC tile position info.
     1358          }
    15511359
    15521360          {
     
    15801388              if (ui+1 < pcSlice->getPPS()->getNumSubstreams())
    15811389              {
    1582                 puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits() + (pcSubstreamsOut[ui].countStartCodeEmulations()<<3);
     1390                puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits();
    15831391              }
    15841392            }
     
    16121420          // If current NALU is the last NALU of slice and a NALU was buffered, then (a) Write current NALU (b) Update an write buffered NALU at approproate location in NALU list.
    16131421          Bool bNALUAlignedWrittenToList    = false; // used to ensure current NALU is not written more than once to the NALU list.
    1614           xAttachSliceDataToNalUnit(nalu, pcBitstreamRedirect);
     1422          xWriteTileLocationToSliceHeader(nalu, pcBitstreamRedirect, pcSlice);
    16151423          accessUnit.push_back(new NALUnitEBSP(nalu));
    16161424#if RATE_CONTROL_LAMBDA_DOMAIN
     
    16401448            {
    16411449              UInt numRBSPBytes_nal = UInt((*it)->m_nalUnitData.str().size());
    1642               if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
     1450              if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)
    16431451              {
    16441452                numRBSPBytes += numRBSPBytes_nal;
     
    17101518      pcPic->compressMotion();
    17111519#endif
     1520
    17121521#if H_MV
    17131522      m_pocLastCoded = pcPic->getPOC();
     
    17401549          digestStr = digestToString(sei_recon_picture_digest.digest, 4);
    17411550        }
    1742         OutputNALUnit nalu(NAL_UNIT_SUFFIX_SEI, pcSlice->getTLayer());
     1551        OutputNALUnit nalu(NAL_UNIT_SEI_SUFFIX, pcSlice->getTLayer());
    17431552
    17441553        /* write the SEI messages */
     
    17641573        sei_temporal_level0_index.rapIdx = m_rapIdx;
    17651574
    1766         OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
     1575        OutputNALUnit nalu(NAL_UNIT_SEI);
    17671576
    17681577        /* write the SEI messages */
     
    19041713        if( m_pcCfg->getPictureTimingSEIEnabled() )
    19051714        {
    1906           {
    1907             OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
     1715          OutputNALUnit nalu(NAL_UNIT_SEI, pcSlice->getTLayer());
    19081716          m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    19091717          m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS());
     
    19251733#endif
    19261734        }
    1927 #if K0180_SCALABLE_NESTING_SEI
    1928           if ( m_pcCfg->getScalableNestingSEIEnabled() ) // put picture timing SEI into scalable nesting SEI
    1929           {
    1930             OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
    1931             m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    1932             scalableNestingSEI.m_nestedSEIs.clear();
    1933             scalableNestingSEI.m_nestedSEIs.push_back(&pictureTimingSEI);
    1934             m_seiWriter.writeSEImessage(nalu.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());
    1935             writeRBSPTrailingBits(nalu.m_Bitstream);
    1936 #if L0045_NON_NESTED_SEI_RESTRICTIONS
    1937             UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    1938             UInt offsetPosition = m_activeParameterSetSEIPresentInAU
    1939               + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU + m_nestedBufferingPeriodSEIPresentInAU;    // Insert PT SEI after APS and BP SEI
    1940             AccessUnit::iterator it;
    1941             for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++)
    1942             {
    1943               it++;
    1944             }
    1945             accessUnit.insert(it, new NALUnitEBSP(nalu));
    1946             m_nestedPictureTimingSEIPresentInAU = true;
    1947 #else
    1948             AccessUnit::iterator it = find_if(accessUnit.begin(), accessUnit.end(), mem_fun(&NALUnit::isSlice));
    1949             accessUnit.insert(it, new NALUnitEBSP(nalu));
    1950 #endif
    1951           }
    1952 #endif
    1953 
    1954         }
    19551735        if( m_pcCfg->getDecodingUnitInfoSEIEnabled() && hrd->getSubPicCpbParamsPresentFlag() )
    19561736        {             
     
    19581738          for( Int i = 0; i < ( pictureTimingSEI.m_numDecodingUnitsMinus1 + 1 ); i ++ )
    19591739          {
    1960             OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
     1740            OutputNALUnit nalu(NAL_UNIT_SEI, pcSlice->getTLayer());
    19611741
    19621742            SEIDecodingUnitInfo tempSEI;
     
    20061786                  break;
    20071787                }
    2008                 if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
     1788                if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)
    20091789                {
    20101790                  ctr++;
     
    20171797#if L0045_NON_NESTED_SEI_RESTRICTIONS
    20181798      xResetNonNestedSEIPresentFlags();
    2019 #if K0180_SCALABLE_NESTING_SEI
    2020       xResetNestedSEIPresentFlags();
    2021 #endif
    20221799#endif
    20231800      pcPic->getPicYuvRec()->copyToPic(pcPicYuvRecOut);
     
    20521829  assert ( m_iNumPicCoded == iNumPicRcvd );
    20531830#endif
     1831
    20541832}
    20551833
     
    22452023    case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R";
    22462024    case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N";
    2247     case NAL_UNIT_CODED_SLICE_TLA_R:      return "TLA_R";
     2025    case NAL_UNIT_CODED_SLICE_TLA: return "TLA";
    22482026    case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N";
    22492027    case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R";
    22502028    case NAL_UNIT_CODED_SLICE_STSA_N: return "STSA_N";
    2251     case NAL_UNIT_CODED_SLICE_BLA_W_LP:   return "BLA_W_LP";
    2252     case NAL_UNIT_CODED_SLICE_BLA_W_RADL: return "BLA_W_RADL";
     2029    case NAL_UNIT_CODED_SLICE_BLA: return "BLA";
     2030    case NAL_UNIT_CODED_SLICE_BLANT: return "BLANT";
    22532031    case NAL_UNIT_CODED_SLICE_BLA_N_LP: return "BLA_N_LP";
    2254     case NAL_UNIT_CODED_SLICE_IDR_W_RADL: return "IDR_W_RADL";
     2032    case NAL_UNIT_CODED_SLICE_IDR: return "IDR";
    22552033    case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP";
    22562034    case NAL_UNIT_CODED_SLICE_CRA: return "CRA";
    2257     case NAL_UNIT_CODED_SLICE_RADL_R:     return "RADL_R";
    2258     case NAL_UNIT_CODED_SLICE_RASL_R:     return "RASL_R";
     2035    case NAL_UNIT_CODED_SLICE_DLP: return "DLP";
     2036    case NAL_UNIT_CODED_SLICE_TFD: return "TFD";
    22592037    case NAL_UNIT_VPS: return "VPS";
    22602038    case NAL_UNIT_SPS: return "SPS";
     
    22642042    case NAL_UNIT_EOB: return "EOB";
    22652043    case NAL_UNIT_FILLER_DATA: return "FILLER";
    2266     case NAL_UNIT_PREFIX_SEI:             return "SEI";
    2267     case NAL_UNIT_SUFFIX_SEI:             return "SEI";
     2044    case NAL_UNIT_SEI: return "SEI";
    22682045    default: return "UNK";
    22692046  }
     
    23562133    printf("*** %6s numBytesInNALunit: %u\n", nalUnitTypeToString((*it)->m_nalUnitType), numRBSPBytes_nal);
    23572134#endif
    2358     if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
     2135    if ((*it)->m_nalUnitType != NAL_UNIT_SEI && (*it)->m_nalUnitType != NAL_UNIT_SEI_SUFFIX)
    23592136    {
    23602137      numRBSPBytes += numRBSPBytes_nal;
     
    23662143
    23672144  //===== add PSNR =====
     2145
    23682146#if H_MV
    23692147  m_pcEncTop->getAnalyzeAll()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     
    23712149  m_gcAnalyzeAll.addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
    23722150#endif
     2151
    23732152  TComSlice*  pcSlice = pcPic->getSlice(0);
    23742153  if (pcSlice->isIntra())
    23752154  {
     2155
    23762156#if H_MV
    23772157    m_pcEncTop->getAnalyzeI()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     
    23792159    m_gcAnalyzeI.addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
    23802160#endif
     2161
    23812162  }
    23822163  if (pcSlice->isInterP())
    23832164  {
     2165
    23842166#if H_MV
    23852167    m_pcEncTop->getAnalyzeP()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     
    23872169    m_gcAnalyzeP.addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
    23882170#endif
     2171
    23892172  }
    23902173  if (pcSlice->isInterB())
    23912174  {
     2175
    23922176#if H_MV
    23932177    m_pcEncTop->getAnalyzeB()->addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
     
    23952179    m_gcAnalyzeB.addResult (dYPSNR, dUPSNR, dVPSNR, (Double)uibits);
    23962180#endif
     2181
    23972182  }
    23982183
     
    24012186
    24022187#if ADAPTIVE_QP_SELECTION
     2188
    24032189#if H_MV
    24042190  printf("Layer %3d   POC %4d TId: %1d ( %c-SLICE, nQP %d QP %d ) %10d bits",
     
    24192205         uibits );
    24202206#endif
     2207
    24212208#else
     2209
    24222210#if H_MV
    24232211  printf("Layer %3d   POC %4d TId: %1d ( %c-SLICE, QP %d ) %10d bits",
     
    24362224         uibits );
    24372225#endif
     2226
    24382227#endif
    24392228
     
    24682257 * This function checks the configuration and returns the appropriate nal_unit_type for the picture.
    24692258 */
    2470 NalUnitType TEncGOP::getNalUnitType(Int pocCurr, Int lastIDR)
     2259NalUnitType TEncGOP::getNalUnitType(Int pocCurr)
    24712260{
    24722261  if (pocCurr == 0)
    24732262  {
    2474     return NAL_UNIT_CODED_SLICE_IDR_W_RADL;
     2263    return NAL_UNIT_CODED_SLICE_IDR;
    24752264  }
    24762265  if (pocCurr % m_pcCfg->getIntraPeriod() == 0)
     
    24822271    else if (m_pcCfg->getDecodingRefreshType() == 2)
    24832272    {
    2484       return NAL_UNIT_CODED_SLICE_IDR_W_RADL;
     2273      return NAL_UNIT_CODED_SLICE_IDR;
    24852274    }
    24862275  }
     
    24942283      // controlling the reference pictures used for encoding that leading picture. Such a leading
    24952284      // picture need not be marked as a TFD picture.
    2496       return NAL_UNIT_CODED_SLICE_RASL_R;
    2497     }
    2498   }
    2499   if (lastIDR>0)
    2500   {
    2501     if (pocCurr < lastIDR)
    2502     {
    2503       return NAL_UNIT_CODED_SLICE_RADL_R;
     2285      return NAL_UNIT_CODED_SLICE_TFD;
    25042286    }
    25052287  }
     
    25522334}
    25532335
    2554 /** Attaches the input bitstream to the stream in the output NAL unit
    2555     Updates rNalu to contain concatenated bitstream. rpcBitstreamRedirect is cleared at the end of this function call.
    2556  *  \param codedSliceData contains the coded slice data (bitstream) to be concatenated to rNalu
    2557  *  \param rNalu          target NAL unit
     2336/** Determine the difference between consecutive tile sizes (in bytes) and writes it to  bistream rNalu [slice header]
     2337 * \param rpcBitstreamRedirect contains the bitstream to be concatenated to rNalu. rpcBitstreamRedirect contains slice payload. rpcSlice contains tile location information.
     2338 * \returns Updates rNalu to contain concatenated bitstream. rpcBitstreamRedirect is cleared at the end of this function call.
    25582339 */
    2559 Void TEncGOP::xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& codedSliceData)
     2340Void TEncGOP::xWriteTileLocationToSliceHeader (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect, TComSlice*& rpcSlice)
    25602341{
    25612342  // Byte-align
     
    25632344
    25642345  // Perform bitstream concatenation
    2565   if (codedSliceData->getNumberOfWrittenBits() > 0)
    2566     {
    2567     rNalu.m_Bitstream.addSubstream(codedSliceData);
     2346  if (rpcBitstreamRedirect->getNumberOfWrittenBits() > 0)
     2347  {
     2348    UInt uiBitCount  = rpcBitstreamRedirect->getNumberOfWrittenBits();
     2349    if (rpcBitstreamRedirect->getByteStreamLength()>0)
     2350    {
     2351      UChar *pucStart  =  reinterpret_cast<UChar*>(rpcBitstreamRedirect->getByteStream());
     2352      UInt uiWriteByteCount = 0;
     2353      while (uiWriteByteCount < (uiBitCount >> 3) )
     2354      {
     2355        UInt uiBits = (*pucStart);
     2356        rNalu.m_Bitstream.write(uiBits, 8);
     2357        pucStart++;
     2358        uiWriteByteCount++;
     2359      }
     2360    }
     2361    UInt uiBitsHeld = (uiBitCount & 0x07);
     2362    for (UInt uiIdx=0; uiIdx < uiBitsHeld; uiIdx++)
     2363    {
     2364      rNalu.m_Bitstream.write((rpcBitstreamRedirect->getHeldBits() & (1 << (7-uiIdx))) >> (7-uiIdx), 1);
     2365    }         
    25682366  }
    25692367
    25702368  m_pcEntropyCoder->setBitstream(&rNalu.m_Bitstream);
    25712369
    2572   codedSliceData->clear();
     2370  delete rpcBitstreamRedirect;
     2371  rpcBitstreamRedirect = new TComOutputBitstream;
    25732372}
    25742373
     
    26952494     }               
    26962495  }
    2697 //  assert(it != accessUnit.end());  // Triggers with some legit configurations
     2496  assert(it != accessUnit.end());
    26982497  return seiStartPos;
    26992498}
    27002499#endif
    27012500
    2702 #if L0386_DB_METRIC
    2703 Void TEncGOP::dblMetric( TComPic* pcPic, UInt uiNumSlices )
    2704 {
    2705   TComPicYuv* pcPicYuvRec = pcPic->getPicYuvRec();
    2706   Pel* Rec    = pcPicYuvRec->getLumaAddr( 0 );
    2707   Pel* tempRec = Rec;
    2708   Int  stride = pcPicYuvRec->getStride();
    2709   UInt log2maxTB = pcPic->getSlice(0)->getSPS()->getQuadtreeTULog2MaxSize();
    2710   UInt maxTBsize = (1<<log2maxTB);
    2711   const UInt minBlockArtSize = 8;
    2712   const UInt picWidth = pcPicYuvRec->getWidth();
    2713   const UInt picHeight = pcPicYuvRec->getHeight();
    2714   const UInt noCol = (picWidth>>log2maxTB);
    2715   const UInt noRows = (picHeight>>log2maxTB);
    2716   UInt64 *colSAD = (UInt64*)malloc(noCol*sizeof(UInt64));
    2717   UInt64 *rowSAD = (UInt64*)malloc(noRows*sizeof(UInt64));
    2718   UInt colIdx = 0;
    2719   UInt rowIdx = 0;
    2720   Pel p0, p1, p2, q0, q1, q2;
    2721  
    2722   Int qp = pcPic->getSlice(0)->getSliceQp();
    2723   Int bitdepthScale = 1 << (g_bitDepthY-8);
    2724   Int beta = TComLoopFilter::getBeta( qp ) * bitdepthScale;
    2725   const Int thr2 = (beta>>2);
    2726   const Int thr1 = 2*bitdepthScale;
    2727   UInt a = 0;
    2728  
    2729   memset(colSAD, 0, noCol*sizeof(UInt64));
    2730   memset(rowSAD, 0, noRows*sizeof(UInt64));
    2731  
    2732   if (maxTBsize > minBlockArtSize)
    2733   {
    2734     // Analyze vertical artifact edges
    2735     for(Int c = maxTBsize; c < picWidth; c += maxTBsize)
    2736     {
    2737       for(Int r = 0; r < picHeight; r++)
    2738       {
    2739         p2 = Rec[c-3];
    2740         p1 = Rec[c-2];
    2741         p0 = Rec[c-1];
    2742         q0 = Rec[c];
    2743         q1 = Rec[c+1];
    2744         q2 = Rec[c+2];
    2745         a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1);
    2746         if ( thr1 < a && a < thr2)
    2747         {
    2748           colSAD[colIdx] += abs(p0 - q0);
    2749         }
    2750         Rec += stride;
    2751       }
    2752       colIdx++;
    2753       Rec = tempRec;
    2754     }
    2755    
    2756     // Analyze horizontal artifact edges
    2757     for(Int r = maxTBsize; r < picHeight; r += maxTBsize)
    2758     {
    2759       for(Int c = 0; c < picWidth; c++)
    2760       {
    2761         p2 = Rec[c + (r-3)*stride];
    2762         p1 = Rec[c + (r-2)*stride];
    2763         p0 = Rec[c + (r-1)*stride];
    2764         q0 = Rec[c + r*stride];
    2765         q1 = Rec[c + (r+1)*stride];
    2766         q2 = Rec[c + (r+2)*stride];
    2767         a = ((abs(p2-(p1<<1)+p0)+abs(q0-(q1<<1)+q2))<<1);
    2768         if (thr1 < a && a < thr2)
    2769         {
    2770           rowSAD[rowIdx] += abs(p0 - q0);
    2771         }
    2772       }
    2773       rowIdx++;
    2774     }
    2775   }
    2776  
    2777   UInt64 colSADsum = 0;
    2778   UInt64 rowSADsum = 0;
    2779   for(Int c = 0; c < noCol-1; c++)
    2780   {
    2781     colSADsum += colSAD[c];
    2782   }
    2783   for(Int r = 0; r < noRows-1; r++)
    2784   {
    2785     rowSADsum += rowSAD[r];
    2786   }
    2787  
    2788   colSADsum <<= 10;
    2789   rowSADsum <<= 10;
    2790   colSADsum /= (noCol-1);
    2791   colSADsum /= picHeight;
    2792   rowSADsum /= (noRows-1);
    2793   rowSADsum /= picWidth;
    2794  
    2795   UInt64 avgSAD = ((colSADsum + rowSADsum)>>1);
    2796   avgSAD >>= (g_bitDepthY-8);
    2797  
    2798   if ( avgSAD > 2048 )
    2799   {
    2800     avgSAD >>= 9;
    2801     Int offset = Clip3(2,6,(Int)avgSAD);
    2802     for (Int i=0; i<uiNumSlices; i++)
    2803     {
    2804       pcPic->getSlice(i)->setDeblockingFilterOverrideFlag(true);
    2805       pcPic->getSlice(i)->setDeblockingFilterDisable(false);
    2806       pcPic->getSlice(i)->setDeblockingFilterBetaOffsetDiv2( offset );
    2807       pcPic->getSlice(i)->setDeblockingFilterTcOffsetDiv2( offset );
    2808     }
    2809   }
    2810   else
    2811   {
    2812     for (Int i=0; i<uiNumSlices; i++)
    2813     {
    2814       pcPic->getSlice(i)->setDeblockingFilterOverrideFlag(false);
    2815       pcPic->getSlice(i)->setDeblockingFilterDisable(        pcPic->getSlice(i)->getPPS()->getPicDisableDeblockingFilterFlag() );
    2816       pcPic->getSlice(i)->setDeblockingFilterBetaOffsetDiv2( pcPic->getSlice(i)->getPPS()->getDeblockingFilterBetaOffsetDiv2() );
    2817       pcPic->getSlice(i)->setDeblockingFilterTcOffsetDiv2(   pcPic->getSlice(i)->getPPS()->getDeblockingFilterTcOffsetDiv2()   );
    2818     }
    2819   }
    2820  
    2821   free(colSAD);
    2822   free(rowSAD);
    2823 }
    2824 #endif
    28252501#if H_MV
    28262502Void TEncGOP::xSetRefPicListModificationsMvc( TComSlice* pcSlice, UInt uiPOCCurr, UInt iGOPid )
     
    28462522  {
    28472523    Int numModifications = 0;
    2848 
     2524   
    28492525    for( Int k = 0; k < ge.m_numInterViewRefPics; k++ )
    28502526    {
     
    28532529
    28542530    // set inter-view modifications
    2855     Bool isModified = false;
    2856     Int tempList[16];
    2857     for( Int k = 0; k < 16; k++ ) { tempList[k] = -1; }
    2858 
    28592531    if( (maxRefListSize > 1) && (numModifications > 0) )
    28602532    {
     2533      refPicListModification->setRefPicListModificationFlagL( li, true );
     2534      Int tempList[16];
     2535      for( Int k = 0; k < 16; k++ ) { tempList[k] = -1; }
     2536
     2537      Bool isModified = false;
    28612538      for( Int k = 0; k < ge.m_numInterViewRefPics; k++ )
    28622539      {
     
    28772554        }
    28782555      }
    2879     }
    2880 
    2881     refPicListModification->setRefPicListModificationFlagL( li, isModified ); 
    2882 
    2883     if( isModified )
    2884     {
    2885       Int temporalRefIdx = 0;
    2886       for( Int i = 0; i < pcSlice->getNumRefIdx( ( li == 0 ) ? REF_PIC_LIST_0 : REF_PIC_LIST_1 ); i++ )
    2887       {
    2888         if( tempList[i] >= 0 )
    2889         {
    2890           refPicListModification->setRefPicSetIdxL( li, i, tempList[i] );
    2891         }
    2892         else
    2893         {
    2894           refPicListModification->setRefPicSetIdxL( li, i, temporalRefIdx );
    2895           temporalRefIdx++;
    2896         }
    2897       }
    2898     }   
     2556      if( isModified )
     2557      {
     2558        Int temporalRefIdx = 0;
     2559        for( Int i = 0; i < pcSlice->getNumRefIdx( ( li == 0 ) ? REF_PIC_LIST_0 : REF_PIC_LIST_1 ); i++ )
     2560        {
     2561          if( tempList[i] >= 0 )
     2562          {
     2563            refPicListModification->setRefPicSetIdxL( li, i, tempList[i] );
     2564          }
     2565          else
     2566          {
     2567            refPicListModification->setRefPicSetIdxL( li, i, temporalRefIdx );
     2568            temporalRefIdx++;
     2569          }
     2570        }
     2571      }
     2572      else
     2573      {
     2574        refPicListModification->setRefPicListModificationFlagL( li, false );
     2575      }
     2576    }
    28992577  }
    29002578}
    29012579#endif
     2580
    29022581//! \}
Note: See TracChangeset for help on using the changeset viewer.