| 1 | /* The copyright in this software is being made available under the BSD |
|---|
| 2 | * License, included below. This software may be subject to other third party |
|---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
|---|
| 4 | * granted under this license. |
|---|
| 5 | * |
|---|
| 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
|---|
| 7 | * All rights reserved. |
|---|
| 8 | * |
|---|
| 9 | * Redistribution and use in source and binary forms, with or without |
|---|
| 10 | * modification, are permitted provided that the following conditions are met: |
|---|
| 11 | * |
|---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
|---|
| 13 | * this list of conditions and the following disclaimer. |
|---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
|---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
|---|
| 16 | * and/or other materials provided with the distribution. |
|---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
|---|
| 18 | * be used to endorse or promote products derived from this software without |
|---|
| 19 | * specific prior written permission. |
|---|
| 20 | * |
|---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
|---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 32 | */ |
|---|
| 33 | |
|---|
| 34 | #include "TLibCommon/CommonDef.h" |
|---|
| 35 | #include "TLibCommon/SEI.h" |
|---|
| 36 | #include "TEncGOP.h" |
|---|
| 37 | #include "TEncTop.h" |
|---|
| 38 | |
|---|
| 39 | //! \ingroup TLibEncoder |
|---|
| 40 | //! \{ |
|---|
| 41 | |
|---|
| 42 | Void SEIEncoder::initSEIActiveParameterSets (SEIActiveParameterSets *seiActiveParameterSets, const TComVPS *vps, const TComSPS *sps) |
|---|
| 43 | { |
|---|
| 44 | assert (m_isInitialized); |
|---|
| 45 | assert (seiActiveParameterSets!=NULL); |
|---|
| 46 | assert (vps!=NULL); |
|---|
| 47 | assert (sps!=NULL); |
|---|
| 48 | |
|---|
| 49 | seiActiveParameterSets->activeVPSId = vps->getVPSId(); |
|---|
| 50 | seiActiveParameterSets->m_selfContainedCvsFlag = false; |
|---|
| 51 | seiActiveParameterSets->m_noParameterSetUpdateFlag = false; |
|---|
| 52 | #if R0247_SEI_ACTIVE |
|---|
| 53 | seiActiveParameterSets->numSpsIdsMinus1 = m_pcCfg->getNumLayer()-1; |
|---|
| 54 | seiActiveParameterSets->activeSeqParameterSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1); |
|---|
| 55 | seiActiveParameterSets->layerSpsIdx.resize(seiActiveParameterSets->numSpsIdsMinus1+ 1); |
|---|
| 56 | for (Int c=0; c <= seiActiveParameterSets->numSpsIdsMinus1; c++) |
|---|
| 57 | { |
|---|
| 58 | seiActiveParameterSets->activeSeqParameterSetId[c] = c; |
|---|
| 59 | } |
|---|
| 60 | for (Int c=1; c <= seiActiveParameterSets->numSpsIdsMinus1; c++) |
|---|
| 61 | { |
|---|
| 62 | seiActiveParameterSets->layerSpsIdx[c] = c; |
|---|
| 63 | } |
|---|
| 64 | #else |
|---|
| 65 | seiActiveParameterSets->numSpsIdsMinus1 = 0; |
|---|
| 66 | seiActiveParameterSets->activeSeqParameterSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1); |
|---|
| 67 | seiActiveParameterSets->activeSeqParameterSetId[0] = sps->getSPSId(); |
|---|
| 68 | #endif |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | Void SEIEncoder::initSEIFramePacking(SEIFramePacking *seiFramePacking, Int currPicNum) |
|---|
| 72 | { |
|---|
| 73 | assert (m_isInitialized); |
|---|
| 74 | assert (seiFramePacking!=NULL); |
|---|
| 75 | |
|---|
| 76 | seiFramePacking->m_arrangementId = m_pcCfg->getFramePackingArrangementSEIId(); |
|---|
| 77 | seiFramePacking->m_arrangementCancelFlag = 0; |
|---|
| 78 | seiFramePacking->m_arrangementType = m_pcCfg->getFramePackingArrangementSEIType(); |
|---|
| 79 | assert((seiFramePacking->m_arrangementType > 2) && (seiFramePacking->m_arrangementType < 6) ); |
|---|
| 80 | seiFramePacking->m_quincunxSamplingFlag = m_pcCfg->getFramePackingArrangementSEIQuincunx(); |
|---|
| 81 | seiFramePacking->m_contentInterpretationType = m_pcCfg->getFramePackingArrangementSEIInterpretation(); |
|---|
| 82 | seiFramePacking->m_spatialFlippingFlag = 0; |
|---|
| 83 | seiFramePacking->m_frame0FlippedFlag = 0; |
|---|
| 84 | seiFramePacking->m_fieldViewsFlag = (seiFramePacking->m_arrangementType == 2); |
|---|
| 85 | seiFramePacking->m_currentFrameIsFrame0Flag = ((seiFramePacking->m_arrangementType == 5) && (currPicNum&1) ); |
|---|
| 86 | seiFramePacking->m_frame0SelfContainedFlag = 0; |
|---|
| 87 | seiFramePacking->m_frame1SelfContainedFlag = 0; |
|---|
| 88 | seiFramePacking->m_frame0GridPositionX = 0; |
|---|
| 89 | seiFramePacking->m_frame0GridPositionY = 0; |
|---|
| 90 | seiFramePacking->m_frame1GridPositionX = 0; |
|---|
| 91 | seiFramePacking->m_frame1GridPositionY = 0; |
|---|
| 92 | seiFramePacking->m_arrangementReservedByte = 0; |
|---|
| 93 | seiFramePacking->m_arrangementPersistenceFlag = true; |
|---|
| 94 | seiFramePacking->m_upsampledAspectRatio = 0; |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | Void SEIEncoder::initSEISegmentedRectFramePacking(SEISegmentedRectFramePacking *seiSegmentedRectFramePacking) |
|---|
| 98 | { |
|---|
| 99 | assert (m_isInitialized); |
|---|
| 100 | assert (seiSegmentedRectFramePacking!=NULL); |
|---|
| 101 | |
|---|
| 102 | seiSegmentedRectFramePacking->m_arrangementCancelFlag = m_pcCfg->getSegmentedRectFramePackingArrangementSEICancel(); |
|---|
| 103 | seiSegmentedRectFramePacking->m_contentInterpretationType = m_pcCfg->getSegmentedRectFramePackingArrangementSEIType(); |
|---|
| 104 | seiSegmentedRectFramePacking->m_arrangementPersistenceFlag = m_pcCfg->getSegmentedRectFramePackingArrangementSEIPersistence(); |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | Void SEIEncoder::initSEIDisplayOrientation(SEIDisplayOrientation* seiDisplayOrientation) |
|---|
| 108 | { |
|---|
| 109 | assert (m_isInitialized); |
|---|
| 110 | assert (seiDisplayOrientation!=NULL); |
|---|
| 111 | |
|---|
| 112 | seiDisplayOrientation->cancelFlag = false; |
|---|
| 113 | seiDisplayOrientation->horFlip = false; |
|---|
| 114 | seiDisplayOrientation->verFlip = false; |
|---|
| 115 | seiDisplayOrientation->anticlockwiseRotation = m_pcCfg->getDisplayOrientationSEIAngle(); |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | Void SEIEncoder::initSEIToneMappingInfo(SEIToneMappingInfo *seiToneMappingInfo) |
|---|
| 119 | { |
|---|
| 120 | assert (m_isInitialized); |
|---|
| 121 | assert (seiToneMappingInfo!=NULL); |
|---|
| 122 | |
|---|
| 123 | seiToneMappingInfo->m_toneMapId = m_pcCfg->getTMISEIToneMapId(); |
|---|
| 124 | seiToneMappingInfo->m_toneMapCancelFlag = m_pcCfg->getTMISEIToneMapCancelFlag(); |
|---|
| 125 | seiToneMappingInfo->m_toneMapPersistenceFlag = m_pcCfg->getTMISEIToneMapPersistenceFlag(); |
|---|
| 126 | |
|---|
| 127 | seiToneMappingInfo->m_codedDataBitDepth = m_pcCfg->getTMISEICodedDataBitDepth(); |
|---|
| 128 | assert(seiToneMappingInfo->m_codedDataBitDepth >= 8 && seiToneMappingInfo->m_codedDataBitDepth <= 14); |
|---|
| 129 | seiToneMappingInfo->m_targetBitDepth = m_pcCfg->getTMISEITargetBitDepth(); |
|---|
| 130 | assert(seiToneMappingInfo->m_targetBitDepth >= 1 && seiToneMappingInfo->m_targetBitDepth <= 17); |
|---|
| 131 | seiToneMappingInfo->m_modelId = m_pcCfg->getTMISEIModelID(); |
|---|
| 132 | assert(seiToneMappingInfo->m_modelId >=0 &&seiToneMappingInfo->m_modelId<=4); |
|---|
| 133 | |
|---|
| 134 | switch( seiToneMappingInfo->m_modelId) |
|---|
| 135 | { |
|---|
| 136 | case 0: |
|---|
| 137 | { |
|---|
| 138 | seiToneMappingInfo->m_minValue = m_pcCfg->getTMISEIMinValue(); |
|---|
| 139 | seiToneMappingInfo->m_maxValue = m_pcCfg->getTMISEIMaxValue(); |
|---|
| 140 | break; |
|---|
| 141 | } |
|---|
| 142 | case 1: |
|---|
| 143 | { |
|---|
| 144 | seiToneMappingInfo->m_sigmoidMidpoint = m_pcCfg->getTMISEISigmoidMidpoint(); |
|---|
| 145 | seiToneMappingInfo->m_sigmoidWidth = m_pcCfg->getTMISEISigmoidWidth(); |
|---|
| 146 | break; |
|---|
| 147 | } |
|---|
| 148 | case 2: |
|---|
| 149 | { |
|---|
| 150 | UInt num = 1u<<(seiToneMappingInfo->m_targetBitDepth); |
|---|
| 151 | seiToneMappingInfo->m_startOfCodedInterval.resize(num); |
|---|
| 152 | Int* ptmp = m_pcCfg->getTMISEIStartOfCodedInterva(); |
|---|
| 153 | if(ptmp) |
|---|
| 154 | { |
|---|
| 155 | for(Int i=0; i<num;i++) |
|---|
| 156 | { |
|---|
| 157 | seiToneMappingInfo->m_startOfCodedInterval[i] = ptmp[i]; |
|---|
| 158 | } |
|---|
| 159 | } |
|---|
| 160 | break; |
|---|
| 161 | } |
|---|
| 162 | case 3: |
|---|
| 163 | { |
|---|
| 164 | seiToneMappingInfo->m_numPivots = m_pcCfg->getTMISEINumPivots(); |
|---|
| 165 | seiToneMappingInfo->m_codedPivotValue.resize(seiToneMappingInfo->m_numPivots); |
|---|
| 166 | seiToneMappingInfo->m_targetPivotValue.resize(seiToneMappingInfo->m_numPivots); |
|---|
| 167 | Int* ptmpcoded = m_pcCfg->getTMISEICodedPivotValue(); |
|---|
| 168 | Int* ptmptarget = m_pcCfg->getTMISEITargetPivotValue(); |
|---|
| 169 | if(ptmpcoded&&ptmptarget) |
|---|
| 170 | { |
|---|
| 171 | for(Int i=0; i<(seiToneMappingInfo->m_numPivots);i++) |
|---|
| 172 | { |
|---|
| 173 | seiToneMappingInfo->m_codedPivotValue[i]=ptmpcoded[i]; |
|---|
| 174 | seiToneMappingInfo->m_targetPivotValue[i]=ptmptarget[i]; |
|---|
| 175 | } |
|---|
| 176 | } |
|---|
| 177 | break; |
|---|
| 178 | } |
|---|
| 179 | case 4: |
|---|
| 180 | { |
|---|
| 181 | seiToneMappingInfo->m_cameraIsoSpeedIdc = m_pcCfg->getTMISEICameraIsoSpeedIdc(); |
|---|
| 182 | seiToneMappingInfo->m_cameraIsoSpeedValue = m_pcCfg->getTMISEICameraIsoSpeedValue(); |
|---|
| 183 | assert( seiToneMappingInfo->m_cameraIsoSpeedValue !=0 ); |
|---|
| 184 | seiToneMappingInfo->m_exposureIndexIdc = m_pcCfg->getTMISEIExposurIndexIdc(); |
|---|
| 185 | seiToneMappingInfo->m_exposureIndexValue = m_pcCfg->getTMISEIExposurIndexValue(); |
|---|
| 186 | assert( seiToneMappingInfo->m_exposureIndexValue !=0 ); |
|---|
| 187 | seiToneMappingInfo->m_exposureCompensationValueSignFlag = m_pcCfg->getTMISEIExposureCompensationValueSignFlag(); |
|---|
| 188 | seiToneMappingInfo->m_exposureCompensationValueNumerator = m_pcCfg->getTMISEIExposureCompensationValueNumerator(); |
|---|
| 189 | seiToneMappingInfo->m_exposureCompensationValueDenomIdc = m_pcCfg->getTMISEIExposureCompensationValueDenomIdc(); |
|---|
| 190 | seiToneMappingInfo->m_refScreenLuminanceWhite = m_pcCfg->getTMISEIRefScreenLuminanceWhite(); |
|---|
| 191 | seiToneMappingInfo->m_extendedRangeWhiteLevel = m_pcCfg->getTMISEIExtendedRangeWhiteLevel(); |
|---|
| 192 | assert( seiToneMappingInfo->m_extendedRangeWhiteLevel >= 100 ); |
|---|
| 193 | seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue = m_pcCfg->getTMISEINominalBlackLevelLumaCodeValue(); |
|---|
| 194 | seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue = m_pcCfg->getTMISEINominalWhiteLevelLumaCodeValue(); |
|---|
| 195 | assert( seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue > seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue ); |
|---|
| 196 | seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue = m_pcCfg->getTMISEIExtendedWhiteLevelLumaCodeValue(); |
|---|
| 197 | assert( seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue >= seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue ); |
|---|
| 198 | break; |
|---|
| 199 | } |
|---|
| 200 | default: |
|---|
| 201 | { |
|---|
| 202 | assert(!"Undefined SEIToneMapModelId"); |
|---|
| 203 | break; |
|---|
| 204 | } |
|---|
| 205 | } |
|---|
| 206 | } |
|---|
| 207 | |
|---|
| 208 | Void SEIEncoder::initSEISOPDescription(SEISOPDescription *sopDescriptionSEI, TComSlice *slice, Int picInGOP, Int lastIdr, Int currGOPSize) |
|---|
| 209 | { |
|---|
| 210 | assert (m_isInitialized); |
|---|
| 211 | assert (sopDescriptionSEI != NULL); |
|---|
| 212 | assert (slice != NULL); |
|---|
| 213 | |
|---|
| 214 | Int sopCurrPOC = slice->getPOC(); |
|---|
| 215 | sopDescriptionSEI->m_sopSeqParameterSetId = slice->getSPS()->getSPSId(); |
|---|
| 216 | |
|---|
| 217 | Int i = 0; |
|---|
| 218 | Int prevEntryId = picInGOP; |
|---|
| 219 | for (Int j = picInGOP; j < currGOPSize; j++) |
|---|
| 220 | { |
|---|
| 221 | Int deltaPOC = m_pcCfg->getGOPEntry(j).m_POC - m_pcCfg->getGOPEntry(prevEntryId).m_POC; |
|---|
| 222 | if ((sopCurrPOC + deltaPOC) < m_pcCfg->getFramesToBeEncoded()) |
|---|
| 223 | { |
|---|
| 224 | sopCurrPOC += deltaPOC; |
|---|
| 225 | sopDescriptionSEI->m_sopDescVclNaluType[i] = m_pcEncGOP->getNalUnitType(sopCurrPOC, lastIdr, slice->getPic()->isField()); |
|---|
| 226 | sopDescriptionSEI->m_sopDescTemporalId[i] = m_pcCfg->getGOPEntry(j).m_temporalId; |
|---|
| 227 | sopDescriptionSEI->m_sopDescStRpsIdx[i] = m_pcEncTop->getReferencePictureSetIdxForSOP(sopCurrPOC, j); |
|---|
| 228 | sopDescriptionSEI->m_sopDescPocDelta[i] = deltaPOC; |
|---|
| 229 | |
|---|
| 230 | prevEntryId = j; |
|---|
| 231 | i++; |
|---|
| 232 | } |
|---|
| 233 | } |
|---|
| 234 | |
|---|
| 235 | sopDescriptionSEI->m_numPicsInSopMinus1 = i - 1; |
|---|
| 236 | } |
|---|
| 237 | |
|---|
| 238 | Void SEIEncoder::initSEIBufferingPeriod(SEIBufferingPeriod *bufferingPeriodSEI, TComSlice *slice) |
|---|
| 239 | { |
|---|
| 240 | assert (m_isInitialized); |
|---|
| 241 | assert (bufferingPeriodSEI != NULL); |
|---|
| 242 | assert (slice != NULL); |
|---|
| 243 | |
|---|
| 244 | UInt uiInitialCpbRemovalDelay = (90000/2); // 0.5 sec |
|---|
| 245 | bufferingPeriodSEI->m_initialCpbRemovalDelay [0][0] = uiInitialCpbRemovalDelay; |
|---|
| 246 | bufferingPeriodSEI->m_initialCpbRemovalDelayOffset[0][0] = uiInitialCpbRemovalDelay; |
|---|
| 247 | bufferingPeriodSEI->m_initialCpbRemovalDelay [0][1] = uiInitialCpbRemovalDelay; |
|---|
| 248 | bufferingPeriodSEI->m_initialCpbRemovalDelayOffset[0][1] = uiInitialCpbRemovalDelay; |
|---|
| 249 | |
|---|
| 250 | Double dTmp = (Double)slice->getSPS()->getVuiParameters()->getTimingInfo()->getNumUnitsInTick() / (Double)slice->getSPS()->getVuiParameters()->getTimingInfo()->getTimeScale(); |
|---|
| 251 | |
|---|
| 252 | UInt uiTmp = (UInt)( dTmp * 90000.0 ); |
|---|
| 253 | uiInitialCpbRemovalDelay -= uiTmp; |
|---|
| 254 | uiInitialCpbRemovalDelay -= uiTmp / ( slice->getSPS()->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2 ); |
|---|
| 255 | bufferingPeriodSEI->m_initialAltCpbRemovalDelay [0][0] = uiInitialCpbRemovalDelay; |
|---|
| 256 | bufferingPeriodSEI->m_initialAltCpbRemovalDelayOffset[0][0] = uiInitialCpbRemovalDelay; |
|---|
| 257 | bufferingPeriodSEI->m_initialAltCpbRemovalDelay [0][1] = uiInitialCpbRemovalDelay; |
|---|
| 258 | bufferingPeriodSEI->m_initialAltCpbRemovalDelayOffset[0][1] = uiInitialCpbRemovalDelay; |
|---|
| 259 | |
|---|
| 260 | bufferingPeriodSEI->m_rapCpbParamsPresentFlag = 0; |
|---|
| 261 | //for the concatenation, it can be set to one during splicing. |
|---|
| 262 | bufferingPeriodSEI->m_concatenationFlag = 0; |
|---|
| 263 | //since the temporal layer HRD is not ready, we assumed it is fixed |
|---|
| 264 | bufferingPeriodSEI->m_auCpbRemovalDelayDelta = 1; |
|---|
| 265 | bufferingPeriodSEI->m_cpbDelayOffset = 0; |
|---|
| 266 | bufferingPeriodSEI->m_dpbDelayOffset = 0; |
|---|
| 267 | } |
|---|
| 268 | |
|---|
| 269 | //! initialize scalable nesting SEI message. |
|---|
| 270 | //! Note: The SEI message structures input into this function will become part of the scalable nesting SEI and will be |
|---|
| 271 | //! automatically freed, when the nesting SEI is disposed. |
|---|
| 272 | Void SEIEncoder::initSEIScalableNesting(SEIScalableNesting *scalableNestingSEI, SEIMessages &nestedSEIs) |
|---|
| 273 | { |
|---|
| 274 | assert (m_isInitialized); |
|---|
| 275 | assert (scalableNestingSEI != NULL); |
|---|
| 276 | |
|---|
| 277 | scalableNestingSEI->m_bitStreamSubsetFlag = 1; // If the nested SEI messages are picture buffering SEI messages, picture timing SEI messages or sub-picture timing SEI messages, bitstream_subset_flag shall be equal to 1 |
|---|
| 278 | scalableNestingSEI->m_nestingOpFlag = 0; |
|---|
| 279 | scalableNestingSEI->m_nestingNumOpsMinus1 = 0; //nesting_num_ops_minus1 |
|---|
| 280 | scalableNestingSEI->m_allLayersFlag = 0; |
|---|
| 281 | scalableNestingSEI->m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1; //nesting_no_op_max_temporal_id_plus1 |
|---|
| 282 | scalableNestingSEI->m_nestingNumLayersMinus1 = 1 - 1; //nesting_num_layers_minus1 |
|---|
| 283 | scalableNestingSEI->m_nestingLayerId[0] = 0; |
|---|
| 284 | |
|---|
| 285 | scalableNestingSEI->m_nestedSEIs.clear(); |
|---|
| 286 | for (SEIMessages::iterator it=nestedSEIs.begin(); it!=nestedSEIs.end(); it++) |
|---|
| 287 | { |
|---|
| 288 | scalableNestingSEI->m_nestedSEIs.push_back((*it)); |
|---|
| 289 | } |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | Void SEIEncoder::initSEIRecoveryPoint(SEIRecoveryPoint *recoveryPointSEI, TComSlice *slice) |
|---|
| 293 | { |
|---|
| 294 | assert (m_isInitialized); |
|---|
| 295 | assert (recoveryPointSEI != NULL); |
|---|
| 296 | assert (slice != NULL); |
|---|
| 297 | |
|---|
| 298 | recoveryPointSEI->m_recoveryPocCnt = 0; |
|---|
| 299 | #if SVC_EXTENSION |
|---|
| 300 | recoveryPointSEI->m_exactMatchingFlag = ( slice->getPocValueBeforeReset() == 0 ) ? (true) : (false); |
|---|
| 301 | #else |
|---|
| 302 | recoveryPointSEI->m_exactMatchingFlag = ( slice->getPOC() == 0 ) ? (true) : (false); |
|---|
| 303 | #endif |
|---|
| 304 | recoveryPointSEI->m_brokenLinkFlag = false; |
|---|
| 305 | } |
|---|
| 306 | |
|---|
| 307 | //! calculate hashes for entire reconstructed picture |
|---|
| 308 | Void SEIEncoder::initDecodedPictureHashSEI(SEIDecodedPictureHash *decodedPictureHashSEI, TComPic *pcPic, std::string &rHashString, const BitDepths &bitDepths) |
|---|
| 309 | { |
|---|
| 310 | assert (m_isInitialized); |
|---|
| 311 | assert (decodedPictureHashSEI!=NULL); |
|---|
| 312 | assert (pcPic!=NULL); |
|---|
| 313 | |
|---|
| 314 | if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 1) |
|---|
| 315 | { |
|---|
| 316 | decodedPictureHashSEI->method = SEIDecodedPictureHash::MD5; |
|---|
| 317 | UInt numChar=calcMD5(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths); |
|---|
| 318 | rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar); |
|---|
| 319 | } |
|---|
| 320 | else if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 2) |
|---|
| 321 | { |
|---|
| 322 | decodedPictureHashSEI->method = SEIDecodedPictureHash::CRC; |
|---|
| 323 | UInt numChar=calcCRC(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths); |
|---|
| 324 | rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar); |
|---|
| 325 | } |
|---|
| 326 | else if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 3) |
|---|
| 327 | { |
|---|
| 328 | decodedPictureHashSEI->method = SEIDecodedPictureHash::CHECKSUM; |
|---|
| 329 | UInt numChar=calcChecksum(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths); |
|---|
| 330 | rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar); |
|---|
| 331 | } |
|---|
| 332 | } |
|---|
| 333 | |
|---|
| 334 | Void SEIEncoder::initTemporalLevel0IndexSEI(SEITemporalLevel0Index *temporalLevel0IndexSEI, TComSlice *slice) |
|---|
| 335 | { |
|---|
| 336 | assert (m_isInitialized); |
|---|
| 337 | assert (temporalLevel0IndexSEI!=NULL); |
|---|
| 338 | assert (slice!=NULL); |
|---|
| 339 | |
|---|
| 340 | if (slice->getRapPicFlag()) |
|---|
| 341 | { |
|---|
| 342 | m_tl0Idx = 0; |
|---|
| 343 | m_rapIdx = (m_rapIdx + 1) & 0xFF; |
|---|
| 344 | } |
|---|
| 345 | else |
|---|
| 346 | { |
|---|
| 347 | m_tl0Idx = (m_tl0Idx + (slice->getTLayer() ? 0 : 1)) & 0xFF; |
|---|
| 348 | } |
|---|
| 349 | temporalLevel0IndexSEI->tl0Idx = m_tl0Idx; |
|---|
| 350 | temporalLevel0IndexSEI->rapIdx = m_rapIdx; |
|---|
| 351 | } |
|---|
| 352 | |
|---|
| 353 | Void SEIEncoder::initSEITempMotionConstrainedTileSets (SEITempMotionConstrainedTileSets *sei, const TComPPS *pps) |
|---|
| 354 | { |
|---|
| 355 | assert (m_isInitialized); |
|---|
| 356 | assert (sei!=NULL); |
|---|
| 357 | assert (pps!=NULL); |
|---|
| 358 | |
|---|
| 359 | if(pps->getTilesEnabledFlag()) |
|---|
| 360 | { |
|---|
| 361 | sei->m_mc_all_tiles_exact_sample_value_match_flag = false; |
|---|
| 362 | sei->m_each_tile_one_tile_set_flag = false; |
|---|
| 363 | sei->m_limited_tile_set_display_flag = false; |
|---|
| 364 | sei->setNumberOfTileSets((pps->getNumTileColumnsMinus1() + 1) * (pps->getNumTileRowsMinus1() + 1)); |
|---|
| 365 | |
|---|
| 366 | for(Int i=0; i < sei->getNumberOfTileSets(); i++) |
|---|
| 367 | { |
|---|
| 368 | sei->tileSetData(i).m_mcts_id = i; //depends the application; |
|---|
| 369 | sei->tileSetData(i).setNumberOfTileRects(1); |
|---|
| 370 | |
|---|
| 371 | for(Int j=0; j<sei->tileSetData(i).getNumberOfTileRects(); j++) |
|---|
| 372 | { |
|---|
| 373 | sei->tileSetData(i).topLeftTileIndex(j) = i+j; |
|---|
| 374 | sei->tileSetData(i).bottomRightTileIndex(j) = i+j; |
|---|
| 375 | } |
|---|
| 376 | |
|---|
| 377 | sei->tileSetData(i).m_exact_sample_value_match_flag = false; |
|---|
| 378 | sei->tileSetData(i).m_mcts_tier_level_idc_present_flag = false; |
|---|
| 379 | } |
|---|
| 380 | } |
|---|
| 381 | else |
|---|
| 382 | { |
|---|
| 383 | assert(!"Tile is not enabled"); |
|---|
| 384 | } |
|---|
| 385 | } |
|---|
| 386 | |
|---|
| 387 | Void SEIEncoder::initSEIKneeFunctionInfo(SEIKneeFunctionInfo *seiKneeFunctionInfo) |
|---|
| 388 | { |
|---|
| 389 | assert (m_isInitialized); |
|---|
| 390 | assert (seiKneeFunctionInfo!=NULL); |
|---|
| 391 | |
|---|
| 392 | seiKneeFunctionInfo->m_kneeId = m_pcCfg->getKneeSEIId(); |
|---|
| 393 | seiKneeFunctionInfo->m_kneeCancelFlag = m_pcCfg->getKneeSEICancelFlag(); |
|---|
| 394 | if ( !seiKneeFunctionInfo->m_kneeCancelFlag ) |
|---|
| 395 | { |
|---|
| 396 | seiKneeFunctionInfo->m_kneePersistenceFlag = m_pcCfg->getKneeSEIPersistenceFlag(); |
|---|
| 397 | seiKneeFunctionInfo->m_kneeInputDrange = m_pcCfg->getKneeSEIInputDrange(); |
|---|
| 398 | seiKneeFunctionInfo->m_kneeInputDispLuminance = m_pcCfg->getKneeSEIInputDispLuminance(); |
|---|
| 399 | seiKneeFunctionInfo->m_kneeOutputDrange = m_pcCfg->getKneeSEIOutputDrange(); |
|---|
| 400 | seiKneeFunctionInfo->m_kneeOutputDispLuminance = m_pcCfg->getKneeSEIOutputDispLuminance(); |
|---|
| 401 | |
|---|
| 402 | seiKneeFunctionInfo->m_kneeNumKneePointsMinus1 = m_pcCfg->getKneeSEINumKneePointsMinus1(); |
|---|
| 403 | Int* piInputKneePoint = m_pcCfg->getKneeSEIInputKneePoint(); |
|---|
| 404 | Int* piOutputKneePoint = m_pcCfg->getKneeSEIOutputKneePoint(); |
|---|
| 405 | if(piInputKneePoint&&piOutputKneePoint) |
|---|
| 406 | { |
|---|
| 407 | seiKneeFunctionInfo->m_kneeInputKneePoint.resize(seiKneeFunctionInfo->m_kneeNumKneePointsMinus1+1); |
|---|
| 408 | seiKneeFunctionInfo->m_kneeOutputKneePoint.resize(seiKneeFunctionInfo->m_kneeNumKneePointsMinus1+1); |
|---|
| 409 | for(Int i=0; i<=seiKneeFunctionInfo->m_kneeNumKneePointsMinus1; i++) |
|---|
| 410 | { |
|---|
| 411 | seiKneeFunctionInfo->m_kneeInputKneePoint[i] = piInputKneePoint[i]; |
|---|
| 412 | seiKneeFunctionInfo->m_kneeOutputKneePoint[i] = piOutputKneePoint[i]; |
|---|
| 413 | } |
|---|
| 414 | } |
|---|
| 415 | } |
|---|
| 416 | } |
|---|
| 417 | |
|---|
| 418 | Void SEIEncoder::initSEIChromaSamplingFilterHint(SEIChromaSamplingFilterHint *seiChromaSamplingFilterHint, Int iHorFilterIndex, Int iVerFilterIndex) |
|---|
| 419 | { |
|---|
| 420 | assert (m_isInitialized); |
|---|
| 421 | assert (seiChromaSamplingFilterHint!=NULL); |
|---|
| 422 | |
|---|
| 423 | seiChromaSamplingFilterHint->m_verChromaFilterIdc = iVerFilterIndex; |
|---|
| 424 | seiChromaSamplingFilterHint->m_horChromaFilterIdc = iHorFilterIndex; |
|---|
| 425 | seiChromaSamplingFilterHint->m_verFilteringProcessFlag = 1; |
|---|
| 426 | seiChromaSamplingFilterHint->m_targetFormatIdc = 3; |
|---|
| 427 | seiChromaSamplingFilterHint->m_perfectReconstructionFlag = false; |
|---|
| 428 | if(seiChromaSamplingFilterHint->m_verChromaFilterIdc == 1) |
|---|
| 429 | { |
|---|
| 430 | seiChromaSamplingFilterHint->m_numVerticalFilters = 1; |
|---|
| 431 | seiChromaSamplingFilterHint->m_verTapLengthMinus1 = (Int*)malloc(seiChromaSamplingFilterHint->m_numVerticalFilters * sizeof(Int)); |
|---|
| 432 | seiChromaSamplingFilterHint->m_verFilterCoeff = (Int**)malloc(seiChromaSamplingFilterHint->m_numVerticalFilters * sizeof(Int*)); |
|---|
| 433 | for(Int i = 0; i < seiChromaSamplingFilterHint->m_numVerticalFilters; i ++) |
|---|
| 434 | { |
|---|
| 435 | seiChromaSamplingFilterHint->m_verTapLengthMinus1[i] = 0; |
|---|
| 436 | seiChromaSamplingFilterHint->m_verFilterCoeff[i] = (Int*)malloc(seiChromaSamplingFilterHint->m_verTapLengthMinus1[i] * sizeof(Int)); |
|---|
| 437 | for(Int j = 0; j < seiChromaSamplingFilterHint->m_verTapLengthMinus1[i]; j ++) |
|---|
| 438 | { |
|---|
| 439 | seiChromaSamplingFilterHint->m_verFilterCoeff[i][j] = 0; |
|---|
| 440 | } |
|---|
| 441 | } |
|---|
| 442 | } |
|---|
| 443 | else |
|---|
| 444 | { |
|---|
| 445 | seiChromaSamplingFilterHint->m_numVerticalFilters = 0; |
|---|
| 446 | seiChromaSamplingFilterHint->m_verTapLengthMinus1 = NULL; |
|---|
| 447 | seiChromaSamplingFilterHint->m_verFilterCoeff = NULL; |
|---|
| 448 | } |
|---|
| 449 | if(seiChromaSamplingFilterHint->m_horChromaFilterIdc == 1) |
|---|
| 450 | { |
|---|
| 451 | seiChromaSamplingFilterHint->m_numHorizontalFilters = 1; |
|---|
| 452 | seiChromaSamplingFilterHint->m_horTapLengthMinus1 = (Int*)malloc(seiChromaSamplingFilterHint->m_numHorizontalFilters * sizeof(Int)); |
|---|
| 453 | seiChromaSamplingFilterHint->m_horFilterCoeff = (Int**)malloc(seiChromaSamplingFilterHint->m_numHorizontalFilters * sizeof(Int*)); |
|---|
| 454 | for(Int i = 0; i < seiChromaSamplingFilterHint->m_numHorizontalFilters; i ++) |
|---|
| 455 | { |
|---|
| 456 | seiChromaSamplingFilterHint->m_horTapLengthMinus1[i] = 0; |
|---|
| 457 | seiChromaSamplingFilterHint->m_horFilterCoeff[i] = (Int*)malloc(seiChromaSamplingFilterHint->m_horTapLengthMinus1[i] * sizeof(Int)); |
|---|
| 458 | for(Int j = 0; j < seiChromaSamplingFilterHint->m_horTapLengthMinus1[i]; j ++) |
|---|
| 459 | { |
|---|
| 460 | seiChromaSamplingFilterHint->m_horFilterCoeff[i][j] = 0; |
|---|
| 461 | } |
|---|
| 462 | } |
|---|
| 463 | } |
|---|
| 464 | else |
|---|
| 465 | { |
|---|
| 466 | seiChromaSamplingFilterHint->m_numHorizontalFilters = 0; |
|---|
| 467 | seiChromaSamplingFilterHint->m_horTapLengthMinus1 = NULL; |
|---|
| 468 | seiChromaSamplingFilterHint->m_horFilterCoeff = NULL; |
|---|
| 469 | } |
|---|
| 470 | } |
|---|
| 471 | |
|---|
| 472 | Void SEIEncoder::initSEITimeCode(SEITimeCode *seiTimeCode) |
|---|
| 473 | { |
|---|
| 474 | assert (m_isInitialized); |
|---|
| 475 | assert (seiTimeCode!=NULL); |
|---|
| 476 | // Set data as per command line options |
|---|
| 477 | seiTimeCode->numClockTs = m_pcCfg->getNumberOfTimesets(); |
|---|
| 478 | for(Int i = 0; i < seiTimeCode->numClockTs; i++) |
|---|
| 479 | { |
|---|
| 480 | seiTimeCode->timeSetArray[i] = m_pcCfg->getTimeSet(i); |
|---|
| 481 | } |
|---|
| 482 | } |
|---|
| 483 | |
|---|
| 484 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 485 | Void SEIEncoder::initSEILayersNotPresent(SEILayersNotPresent *seiLayersNotPresent) |
|---|
| 486 | { |
|---|
| 487 | UInt i = 0; |
|---|
| 488 | seiLayersNotPresent->m_activeVpsId = m_pcCfg->getVPS()->getVPSId(); |
|---|
| 489 | seiLayersNotPresent->m_vpsMaxLayers = m_pcCfg->getVPS()->getMaxLayers(); |
|---|
| 490 | for ( ; i < seiLayersNotPresent->m_vpsMaxLayers; i++) |
|---|
| 491 | { |
|---|
| 492 | seiLayersNotPresent->m_layerNotPresentFlag[i] = true; |
|---|
| 493 | } |
|---|
| 494 | for ( ; i < MAX_LAYERS; i++) |
|---|
| 495 | { |
|---|
| 496 | seiLayersNotPresent->m_layerNotPresentFlag[i] = false; |
|---|
| 497 | } |
|---|
| 498 | } |
|---|
| 499 | #endif |
|---|
| 500 | |
|---|
| 501 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
|---|
| 502 | Void SEIEncoder::initSEIInterLayerConstrainedTileSets(SEIInterLayerConstrainedTileSets *seiInterLayerConstrainedTileSets) |
|---|
| 503 | { |
|---|
| 504 | seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag = false; |
|---|
| 505 | seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag = false; |
|---|
| 506 | if (!seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag) |
|---|
| 507 | { |
|---|
| 508 | seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 = m_pcCfg->getIlNumSetsInMessage() - 1; |
|---|
| 509 | if (seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1) |
|---|
| 510 | { |
|---|
| 511 | seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = m_pcCfg->getSkippedTileSetPresentFlag(); |
|---|
| 512 | } |
|---|
| 513 | else |
|---|
| 514 | { |
|---|
| 515 | seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = false; |
|---|
| 516 | } |
|---|
| 517 | seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 += seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag ? 1 : 0; |
|---|
| 518 | for (UInt i = 0; i < m_pcCfg->getIlNumSetsInMessage(); i++) |
|---|
| 519 | { |
|---|
| 520 | seiInterLayerConstrainedTileSets->m_ilctsId[i] = i; |
|---|
| 521 | seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i] = 0; |
|---|
| 522 | for( UInt j = 0; j <= seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i]; j++) |
|---|
| 523 | { |
|---|
| 524 | seiInterLayerConstrainedTileSets->m_ilTopLeftTileIndex[i][j] = m_pcCfg->getTopLeftTileIndex(i); |
|---|
| 525 | seiInterLayerConstrainedTileSets->m_ilBottomRightTileIndex[i][j] = m_pcCfg->getBottomRightTileIndex(i); |
|---|
| 526 | } |
|---|
| 527 | seiInterLayerConstrainedTileSets->m_ilcIdc[i] = m_pcCfg->getIlcIdc(i); |
|---|
| 528 | if (seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag) |
|---|
| 529 | { |
|---|
| 530 | seiInterLayerConstrainedTileSets->m_ilExactSampleValueMatchFlag[i] = false; |
|---|
| 531 | } |
|---|
| 532 | } |
|---|
| 533 | } |
|---|
| 534 | } |
|---|
| 535 | #endif |
|---|
| 536 | |
|---|
| 537 | #if P0123_ALPHA_CHANNEL_SEI |
|---|
| 538 | Void SEIEncoder::initSEIAlphaChannelInfo(SEIAlphaChannelInfo *seiAlphaChannelInfo) |
|---|
| 539 | { |
|---|
| 540 | seiAlphaChannelInfo->m_alphaChannelCancelFlag = m_pcCfg->getAlphaCancelFlag(); |
|---|
| 541 | if(!seiAlphaChannelInfo->m_alphaChannelCancelFlag) |
|---|
| 542 | { |
|---|
| 543 | seiAlphaChannelInfo->m_alphaChannelUseIdc = m_pcCfg->getAlphaUseIdc(); |
|---|
| 544 | seiAlphaChannelInfo->m_alphaChannelBitDepthMinus8 = m_pcCfg->getAlphaBitDepthMinus8(); |
|---|
| 545 | seiAlphaChannelInfo->m_alphaTransparentValue = m_pcCfg->getAlphaTransparentValue(); |
|---|
| 546 | seiAlphaChannelInfo->m_alphaOpaqueValue = m_pcCfg->getAlphaOpaqueValue(); |
|---|
| 547 | seiAlphaChannelInfo->m_alphaChannelIncrFlag = m_pcCfg->getAlphaIncrementFlag(); |
|---|
| 548 | seiAlphaChannelInfo->m_alphaChannelClipFlag = m_pcCfg->getAlphaClipFlag(); |
|---|
| 549 | seiAlphaChannelInfo->m_alphaChannelClipTypeFlag = m_pcCfg->getAlphaClipTypeFlag(); |
|---|
| 550 | } |
|---|
| 551 | } |
|---|
| 552 | #endif |
|---|
| 553 | |
|---|
| 554 | #if Q0096_OVERLAY_SEI |
|---|
| 555 | Void SEIEncoder::initSEIOverlayInfo(SEIOverlayInfo *seiOverlayInfo) |
|---|
| 556 | { |
|---|
| 557 | seiOverlayInfo->m_overlayInfoCancelFlag = m_pcCfg->getOverlaySEICancelFlag(); |
|---|
| 558 | if ( !seiOverlayInfo->m_overlayInfoCancelFlag ) |
|---|
| 559 | { |
|---|
| 560 | seiOverlayInfo->m_overlayContentAuxIdMinus128 = m_pcCfg->getOverlaySEIContentAuxIdMinus128(); |
|---|
| 561 | seiOverlayInfo->m_overlayLabelAuxIdMinus128 = m_pcCfg->getOverlaySEILabelAuxIdMinus128(); |
|---|
| 562 | seiOverlayInfo->m_overlayAlphaAuxIdMinus128 = m_pcCfg->getOverlaySEIAlphaAuxIdMinus128(); |
|---|
| 563 | seiOverlayInfo->m_overlayElementLabelValueLengthMinus8 = m_pcCfg->getOverlaySEIElementLabelValueLengthMinus8(); |
|---|
| 564 | seiOverlayInfo->m_numOverlaysMinus1 = m_pcCfg->getOverlaySEINumOverlaysMinus1(); |
|---|
| 565 | seiOverlayInfo->m_overlayIdx = m_pcCfg->getOverlaySEIIdx(); |
|---|
| 566 | seiOverlayInfo->m_languageOverlayPresentFlag = m_pcCfg->getOverlaySEILanguagePresentFlag(); |
|---|
| 567 | seiOverlayInfo->m_overlayContentLayerId = m_pcCfg->getOverlaySEIContentLayerId(); |
|---|
| 568 | seiOverlayInfo->m_overlayLabelPresentFlag = m_pcCfg->getOverlaySEILabelPresentFlag(); |
|---|
| 569 | seiOverlayInfo->m_overlayLabelLayerId = m_pcCfg->getOverlaySEILabelLayerId(); |
|---|
| 570 | seiOverlayInfo->m_overlayAlphaPresentFlag = m_pcCfg->getOverlaySEIAlphaPresentFlag(); |
|---|
| 571 | seiOverlayInfo->m_overlayAlphaLayerId = m_pcCfg->getOverlaySEIAlphaLayerId(); |
|---|
| 572 | seiOverlayInfo->m_numOverlayElementsMinus1 = m_pcCfg->getOverlaySEINumElementsMinus1(); |
|---|
| 573 | seiOverlayInfo->m_overlayElementLabelMin = m_pcCfg->getOverlaySEIElementLabelMin(); |
|---|
| 574 | seiOverlayInfo->m_overlayElementLabelMax = m_pcCfg->getOverlaySEIElementLabelMax(); |
|---|
| 575 | seiOverlayInfo->m_overlayLanguage.resize ( seiOverlayInfo->m_numOverlaysMinus1+1, NULL ); |
|---|
| 576 | seiOverlayInfo->m_overlayLanguageLength.resize ( seiOverlayInfo->m_numOverlaysMinus1+1 ); |
|---|
| 577 | seiOverlayInfo->m_overlayName.resize ( seiOverlayInfo->m_numOverlaysMinus1+1, NULL ); |
|---|
| 578 | seiOverlayInfo->m_overlayNameLength.resize ( seiOverlayInfo->m_numOverlaysMinus1+1 ); |
|---|
| 579 | seiOverlayInfo->m_overlayElementName.resize ( seiOverlayInfo->m_numOverlaysMinus1+1 ); |
|---|
| 580 | seiOverlayInfo->m_overlayElementNameLength.resize ( seiOverlayInfo->m_numOverlaysMinus1+1 ); |
|---|
| 581 | |
|---|
| 582 | Int i,j; |
|---|
| 583 | string strTmp; |
|---|
| 584 | Int nBytes; |
|---|
| 585 | assert( m_pcCfg->getOverlaySEILanguage().size() == seiOverlayInfo->m_numOverlaysMinus1+1 ); |
|---|
| 586 | assert( m_pcCfg->getOverlaySEIName().size() == seiOverlayInfo->m_numOverlaysMinus1+1 ); |
|---|
| 587 | assert( m_pcCfg->getOverlaySEIElementName().size() == seiOverlayInfo->m_numOverlaysMinus1+1 ); |
|---|
| 588 | |
|---|
| 589 | for ( i=0 ; i<=seiOverlayInfo->m_numOverlaysMinus1; i++ ) |
|---|
| 590 | { |
|---|
| 591 | //language tag |
|---|
| 592 | if ( seiOverlayInfo->m_languageOverlayPresentFlag[i] ) |
|---|
| 593 | { |
|---|
| 594 | strTmp = m_pcCfg->getOverlaySEILanguage()[i]; |
|---|
| 595 | nBytes = (Int)m_pcCfg->getOverlaySEILanguage()[i].size(); |
|---|
| 596 | assert( nBytes>0 ); |
|---|
| 597 | seiOverlayInfo->m_overlayLanguage[i] = new UChar[nBytes]; |
|---|
| 598 | memcpy(seiOverlayInfo->m_overlayLanguage[i], strTmp.c_str(), nBytes); |
|---|
| 599 | seiOverlayInfo->m_overlayLanguageLength[i] = nBytes; |
|---|
| 600 | } |
|---|
| 601 | |
|---|
| 602 | //overlay name |
|---|
| 603 | strTmp = m_pcCfg->getOverlaySEIName()[i]; |
|---|
| 604 | nBytes = (Int)m_pcCfg->getOverlaySEIName()[i].size(); |
|---|
| 605 | assert( nBytes>0 ); |
|---|
| 606 | seiOverlayInfo->m_overlayName[i] = new UChar[nBytes]; |
|---|
| 607 | memcpy(seiOverlayInfo->m_overlayName[i], strTmp.c_str(), nBytes); |
|---|
| 608 | seiOverlayInfo->m_overlayNameLength[i] = nBytes; |
|---|
| 609 | |
|---|
| 610 | //overlay element names |
|---|
| 611 | if ( seiOverlayInfo->m_overlayLabelPresentFlag[i] ) |
|---|
| 612 | { |
|---|
| 613 | seiOverlayInfo->m_overlayElementName[i].resize( seiOverlayInfo->m_numOverlayElementsMinus1[i]+1, NULL ); |
|---|
| 614 | seiOverlayInfo->m_overlayElementNameLength[i].resize( seiOverlayInfo->m_numOverlayElementsMinus1[i]+1 ); |
|---|
| 615 | assert( m_pcCfg->getOverlaySEIElementName()[i].size() == seiOverlayInfo->m_numOverlayElementsMinus1[i]+1 ); |
|---|
| 616 | for ( j=0 ; j<=seiOverlayInfo->m_numOverlayElementsMinus1[i] ; j++) |
|---|
| 617 | { |
|---|
| 618 | strTmp = m_pcCfg->getOverlaySEIElementName()[i][j]; |
|---|
| 619 | nBytes = (Int)m_pcCfg->getOverlaySEIElementName()[i][j].size(); |
|---|
| 620 | assert( nBytes>0 ); |
|---|
| 621 | seiOverlayInfo->m_overlayElementName[i][j] = new UChar[nBytes]; |
|---|
| 622 | memcpy(seiOverlayInfo->m_overlayElementName[i][j], strTmp.c_str(), nBytes); |
|---|
| 623 | seiOverlayInfo->m_overlayElementNameLength[i][j] = nBytes; |
|---|
| 624 | } |
|---|
| 625 | } |
|---|
| 626 | } |
|---|
| 627 | seiOverlayInfo->m_overlayInfoPersistenceFlag = true; |
|---|
| 628 | } |
|---|
| 629 | } |
|---|
| 630 | #endif |
|---|
| 631 | |
|---|
| 632 | #if Q0074_COLOUR_REMAPPING_SEI |
|---|
| 633 | Void SEIEncoder::initSEIColourRemappingInfo(SEIColourRemappingInfo *seiColourRemappingInfo, TComSEIColourRemappingInfo* cfgSeiColourRemappingInfo) |
|---|
| 634 | { |
|---|
| 635 | seiColourRemappingInfo->m_colourRemapId = cfgSeiColourRemappingInfo->m_colourRemapSEIId; |
|---|
| 636 | seiColourRemappingInfo->m_colourRemapCancelFlag = cfgSeiColourRemappingInfo->m_colourRemapSEICancelFlag; |
|---|
| 637 | printf("xCreateSEIColourRemappingInfo - m_colourRemapId = %d m_colourRemapCancelFlag = %d \n",seiColourRemappingInfo->m_colourRemapId, seiColourRemappingInfo->m_colourRemapCancelFlag); |
|---|
| 638 | |
|---|
| 639 | if( !seiColourRemappingInfo->m_colourRemapCancelFlag ) |
|---|
| 640 | { |
|---|
| 641 | seiColourRemappingInfo->m_colourRemapPersistenceFlag = cfgSeiColourRemappingInfo->m_colourRemapSEIPersistenceFlag; |
|---|
| 642 | seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag = cfgSeiColourRemappingInfo->m_colourRemapSEIVideoSignalInfoPresentFlag; |
|---|
| 643 | if( seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag ) |
|---|
| 644 | { |
|---|
| 645 | seiColourRemappingInfo->m_colourRemapFullRangeFlag = cfgSeiColourRemappingInfo->m_colourRemapSEIFullRangeFlag; |
|---|
| 646 | seiColourRemappingInfo->m_colourRemapPrimaries = cfgSeiColourRemappingInfo->m_colourRemapSEIPrimaries; |
|---|
| 647 | seiColourRemappingInfo->m_colourRemapTransferFunction = cfgSeiColourRemappingInfo->m_colourRemapSEITransferFunction; |
|---|
| 648 | seiColourRemappingInfo->m_colourRemapMatrixCoefficients = cfgSeiColourRemappingInfo->m_colourRemapSEIMatrixCoefficients; |
|---|
| 649 | } |
|---|
| 650 | seiColourRemappingInfo->m_colourRemapInputBitDepth = cfgSeiColourRemappingInfo->m_colourRemapSEIInputBitDepth; |
|---|
| 651 | seiColourRemappingInfo->m_colourRemapBitDepth = cfgSeiColourRemappingInfo->m_colourRemapSEIBitDepth; |
|---|
| 652 | for( Int c=0 ; c<3 ; c++ ) |
|---|
| 653 | { |
|---|
| 654 | seiColourRemappingInfo->m_preLutNumValMinus1[c] = cfgSeiColourRemappingInfo->m_colourRemapSEIPreLutNumValMinus1[c]; |
|---|
| 655 | if( seiColourRemappingInfo->m_preLutNumValMinus1[c]>0 ) |
|---|
| 656 | { |
|---|
| 657 | seiColourRemappingInfo->m_preLutCodedValue[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1); |
|---|
| 658 | seiColourRemappingInfo->m_preLutTargetValue[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1); |
|---|
| 659 | for( Int i=0 ; i<=seiColourRemappingInfo->m_preLutNumValMinus1[c] ; i++) |
|---|
| 660 | { |
|---|
| 661 | seiColourRemappingInfo->m_preLutCodedValue[c][i] = cfgSeiColourRemappingInfo->m_colourRemapSEIPreLutCodedValue[c][i]; |
|---|
| 662 | seiColourRemappingInfo->m_preLutTargetValue[c][i] = cfgSeiColourRemappingInfo->m_colourRemapSEIPreLutTargetValue[c][i]; |
|---|
| 663 | } |
|---|
| 664 | } |
|---|
| 665 | } |
|---|
| 666 | seiColourRemappingInfo->m_colourRemapMatrixPresentFlag = cfgSeiColourRemappingInfo->m_colourRemapSEIMatrixPresentFlag; |
|---|
| 667 | if( seiColourRemappingInfo->m_colourRemapMatrixPresentFlag ) |
|---|
| 668 | { |
|---|
| 669 | seiColourRemappingInfo->m_log2MatrixDenom = cfgSeiColourRemappingInfo->m_colourRemapSEILog2MatrixDenom; |
|---|
| 670 | for( Int c=0 ; c<3 ; c++ ) |
|---|
| 671 | for( Int i=0 ; i<3 ; i++ ) |
|---|
| 672 | seiColourRemappingInfo->m_colourRemapCoeffs[c][i] = cfgSeiColourRemappingInfo->m_colourRemapSEICoeffs[c][i]; |
|---|
| 673 | } |
|---|
| 674 | for( Int c=0 ; c<3 ; c++ ) |
|---|
| 675 | { |
|---|
| 676 | seiColourRemappingInfo->m_postLutNumValMinus1[c] = cfgSeiColourRemappingInfo->m_colourRemapSEIPostLutNumValMinus1[c]; |
|---|
| 677 | if( seiColourRemappingInfo->m_postLutNumValMinus1[c]>0 ) |
|---|
| 678 | { |
|---|
| 679 | seiColourRemappingInfo->m_postLutCodedValue[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1); |
|---|
| 680 | seiColourRemappingInfo->m_postLutTargetValue[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1); |
|---|
| 681 | for( Int i=0 ; i<=seiColourRemappingInfo->m_postLutNumValMinus1[c] ; i++) |
|---|
| 682 | { |
|---|
| 683 | seiColourRemappingInfo->m_postLutCodedValue[c][i] = cfgSeiColourRemappingInfo->m_colourRemapSEIPostLutCodedValue[c][i]; |
|---|
| 684 | seiColourRemappingInfo->m_postLutTargetValue[c][i] = cfgSeiColourRemappingInfo->m_colourRemapSEIPostLutTargetValue[c][i]; |
|---|
| 685 | } |
|---|
| 686 | } |
|---|
| 687 | } |
|---|
| 688 | } |
|---|
| 689 | } |
|---|
| 690 | #endif |
|---|
| 691 | |
|---|
| 692 | |
|---|
| 693 | #if O0164_MULTI_LAYER_HRD |
|---|
| 694 | Void SEIEncoder::initBspNestingSEI(SEIScalableNesting *seiScalableNesting, const TComVPS *vps, const TComSPS *sps, Int olsIdx, Int partitioningSchemeIdx, Int bspIdx) |
|---|
| 695 | { |
|---|
| 696 | SEIBspInitialArrivalTime *seiBspInitialArrivalTime = new SEIBspInitialArrivalTime(); |
|---|
| 697 | SEIBspNesting *seiBspNesting = new SEIBspNesting(); |
|---|
| 698 | SEIBufferingPeriod *seiBufferingPeriod = new SEIBufferingPeriod(); |
|---|
| 699 | |
|---|
| 700 | // Scalable nesting SEI |
|---|
| 701 | |
|---|
| 702 | seiScalableNesting->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 |
|---|
| 703 | seiScalableNesting->m_nestingOpFlag = 1; |
|---|
| 704 | seiScalableNesting->m_defaultOpFlag = 0; |
|---|
| 705 | seiScalableNesting->m_nestingNumOpsMinus1 = 0; //nesting_num_ops_minus1 |
|---|
| 706 | seiScalableNesting->m_nestingOpIdx[0] = vps->getOutputLayerSetIdx(olsIdx); |
|---|
| 707 | seiScalableNesting->m_nestingMaxTemporalIdPlus1[0] = 6 + 1; |
|---|
| 708 | seiScalableNesting->m_allLayersFlag = 0; |
|---|
| 709 | seiScalableNesting->m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1; //nesting_no_op_max_temporal_id_plus1 |
|---|
| 710 | seiScalableNesting->m_nestingNumLayersMinus1 = 1 - 1; //nesting_num_layers_minus1 |
|---|
| 711 | seiScalableNesting->m_nestingLayerId[0] = 0; |
|---|
| 712 | |
|---|
| 713 | // Bitstream partition nesting SEI |
|---|
| 714 | seiBspNesting->m_bspIdx = 0; |
|---|
| 715 | |
|---|
| 716 | // Buffering period SEI |
|---|
| 717 | |
|---|
| 718 | UInt uiInitialCpbRemovalDelay = (90000/2); // 0.5 sec |
|---|
| 719 | seiBufferingPeriod->m_initialCpbRemovalDelay [0][0] = uiInitialCpbRemovalDelay; |
|---|
| 720 | seiBufferingPeriod->m_initialCpbRemovalDelayOffset[0][0] = uiInitialCpbRemovalDelay; |
|---|
| 721 | seiBufferingPeriod->m_initialCpbRemovalDelay [0][1] = uiInitialCpbRemovalDelay; |
|---|
| 722 | seiBufferingPeriod->m_initialCpbRemovalDelayOffset[0][1] = uiInitialCpbRemovalDelay; |
|---|
| 723 | |
|---|
| 724 | Double dTmp = (Double)sps->getVuiParameters()->getTimingInfo()->getNumUnitsInTick() / (Double)sps->getVuiParameters()->getTimingInfo()->getTimeScale(); |
|---|
| 725 | |
|---|
| 726 | UInt uiTmp = (UInt)( dTmp * 90000.0 ); |
|---|
| 727 | uiInitialCpbRemovalDelay -= uiTmp; |
|---|
| 728 | uiInitialCpbRemovalDelay -= uiTmp / ( sps->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2 ); |
|---|
| 729 | seiBufferingPeriod->m_initialAltCpbRemovalDelay [0][0] = uiInitialCpbRemovalDelay; |
|---|
| 730 | seiBufferingPeriod->m_initialAltCpbRemovalDelayOffset[0][0] = uiInitialCpbRemovalDelay; |
|---|
| 731 | seiBufferingPeriod->m_initialAltCpbRemovalDelay [0][1] = uiInitialCpbRemovalDelay; |
|---|
| 732 | seiBufferingPeriod->m_initialAltCpbRemovalDelayOffset[0][1] = uiInitialCpbRemovalDelay; |
|---|
| 733 | |
|---|
| 734 | seiBufferingPeriod->m_rapCpbParamsPresentFlag = 0; |
|---|
| 735 | //for the concatenation, it can be set to one during splicing. |
|---|
| 736 | seiBufferingPeriod->m_concatenationFlag = 0; |
|---|
| 737 | //since the temporal layer HRD is not ready, we assumed it is fixed |
|---|
| 738 | seiBufferingPeriod->m_auCpbRemovalDelayDelta = 1; |
|---|
| 739 | seiBufferingPeriod->m_cpbDelayOffset = 0; |
|---|
| 740 | seiBufferingPeriod->m_dpbDelayOffset = 0; |
|---|
| 741 | |
|---|
| 742 | // Intial arrival time SEI message |
|---|
| 743 | |
|---|
| 744 | seiBspInitialArrivalTime->m_nalInitialArrivalDelay[0] = 0; |
|---|
| 745 | seiBspInitialArrivalTime->m_vclInitialArrivalDelay[0] = 0; |
|---|
| 746 | |
|---|
| 747 | |
|---|
| 748 | seiBspNesting->m_nestedSEIs.push_back(seiBufferingPeriod); |
|---|
| 749 | seiBspNesting->m_nestedSEIs.push_back(seiBspInitialArrivalTime); |
|---|
| 750 | seiBspNesting->m_bspIdx = bspIdx; |
|---|
| 751 | seiBspNesting->m_seiOlsIdx = olsIdx; |
|---|
| 752 | seiBspNesting->m_seiPartitioningSchemeIdx = partitioningSchemeIdx; |
|---|
| 753 | seiScalableNesting->m_nestedSEIs.push_back(seiBspNesting); // BSP nesting SEI is contained in scalable nesting SEI |
|---|
| 754 | } |
|---|
| 755 | #endif |
|---|
| 756 | |
|---|
| 757 | //! \} |
|---|