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::initSEIChromaResamplingFilterHint(SEIChromaResamplingFilterHint *seiChromaResamplingFilterHint, Int iHorFilterIndex, Int iVerFilterIndex) |
---|
419 | { |
---|
420 | assert (m_isInitialized); |
---|
421 | assert (seiChromaResamplingFilterHint!=NULL); |
---|
422 | |
---|
423 | seiChromaResamplingFilterHint->m_verChromaFilterIdc = iVerFilterIndex; |
---|
424 | seiChromaResamplingFilterHint->m_horChromaFilterIdc = iHorFilterIndex; |
---|
425 | seiChromaResamplingFilterHint->m_verFilteringFieldProcessingFlag = 1; |
---|
426 | seiChromaResamplingFilterHint->m_targetFormatIdc = 3; |
---|
427 | seiChromaResamplingFilterHint->m_perfectReconstructionFlag = false; |
---|
428 | |
---|
429 | // this creates some example filter values, if explicit filter definition is selected |
---|
430 | if (seiChromaResamplingFilterHint->m_verChromaFilterIdc == 1) |
---|
431 | { |
---|
432 | const Int numVerticalFilters = 3; |
---|
433 | const Int verTapLengthMinus1[] = {5,3,3}; |
---|
434 | |
---|
435 | seiChromaResamplingFilterHint->m_verFilterCoeff.resize(numVerticalFilters); |
---|
436 | for(Int i = 0; i < numVerticalFilters; i ++) |
---|
437 | { |
---|
438 | seiChromaResamplingFilterHint->m_verFilterCoeff[i].resize(verTapLengthMinus1[i]+1); |
---|
439 | } |
---|
440 | // Note: C++11 -> seiChromaResamplingFilterHint->m_verFilterCoeff[0] = {-3,13,31,23,3,-3}; |
---|
441 | seiChromaResamplingFilterHint->m_verFilterCoeff[0][0] = -3; |
---|
442 | seiChromaResamplingFilterHint->m_verFilterCoeff[0][1] = 13; |
---|
443 | seiChromaResamplingFilterHint->m_verFilterCoeff[0][2] = 31; |
---|
444 | seiChromaResamplingFilterHint->m_verFilterCoeff[0][3] = 23; |
---|
445 | seiChromaResamplingFilterHint->m_verFilterCoeff[0][4] = 3; |
---|
446 | seiChromaResamplingFilterHint->m_verFilterCoeff[0][5] = -3; |
---|
447 | |
---|
448 | seiChromaResamplingFilterHint->m_verFilterCoeff[1][0] = -1; |
---|
449 | seiChromaResamplingFilterHint->m_verFilterCoeff[1][1] = 25; |
---|
450 | seiChromaResamplingFilterHint->m_verFilterCoeff[1][2] = 247; |
---|
451 | seiChromaResamplingFilterHint->m_verFilterCoeff[1][3] = -15; |
---|
452 | |
---|
453 | seiChromaResamplingFilterHint->m_verFilterCoeff[2][0] = -20; |
---|
454 | seiChromaResamplingFilterHint->m_verFilterCoeff[2][1] = 186; |
---|
455 | seiChromaResamplingFilterHint->m_verFilterCoeff[2][2] = 100; |
---|
456 | seiChromaResamplingFilterHint->m_verFilterCoeff[2][3] = -10; |
---|
457 | } |
---|
458 | else |
---|
459 | { |
---|
460 | seiChromaResamplingFilterHint->m_verFilterCoeff.resize(0); |
---|
461 | } |
---|
462 | |
---|
463 | if (seiChromaResamplingFilterHint->m_horChromaFilterIdc == 1) |
---|
464 | { |
---|
465 | Int const numHorizontalFilters = 1; |
---|
466 | const Int horTapLengthMinus1[] = {3}; |
---|
467 | |
---|
468 | seiChromaResamplingFilterHint->m_horFilterCoeff.resize(numHorizontalFilters); |
---|
469 | for(Int i = 0; i < numHorizontalFilters; i ++) |
---|
470 | { |
---|
471 | seiChromaResamplingFilterHint->m_horFilterCoeff[i].resize(horTapLengthMinus1[i]+1); |
---|
472 | } |
---|
473 | seiChromaResamplingFilterHint->m_horFilterCoeff[0][0] = 1; |
---|
474 | seiChromaResamplingFilterHint->m_horFilterCoeff[0][1] = 6; |
---|
475 | seiChromaResamplingFilterHint->m_horFilterCoeff[0][2] = 1; |
---|
476 | } |
---|
477 | else |
---|
478 | { |
---|
479 | seiChromaResamplingFilterHint->m_horFilterCoeff.resize(0); |
---|
480 | } |
---|
481 | } |
---|
482 | |
---|
483 | Void SEIEncoder::initSEITimeCode(SEITimeCode *seiTimeCode) |
---|
484 | { |
---|
485 | assert (m_isInitialized); |
---|
486 | assert (seiTimeCode!=NULL); |
---|
487 | // Set data as per command line options |
---|
488 | seiTimeCode->numClockTs = m_pcCfg->getNumberOfTimesets(); |
---|
489 | for(Int i = 0; i < seiTimeCode->numClockTs; i++) |
---|
490 | { |
---|
491 | seiTimeCode->timeSetArray[i] = m_pcCfg->getTimeSet(i); |
---|
492 | } |
---|
493 | } |
---|
494 | |
---|
495 | #if LAYERS_NOT_PRESENT_SEI |
---|
496 | Void SEIEncoder::initSEILayersNotPresent(SEILayersNotPresent *seiLayersNotPresent) |
---|
497 | { |
---|
498 | UInt i = 0; |
---|
499 | seiLayersNotPresent->m_activeVpsId = m_pcCfg->getVPS()->getVPSId(); |
---|
500 | seiLayersNotPresent->m_vpsMaxLayers = m_pcCfg->getVPS()->getMaxLayers(); |
---|
501 | for ( ; i < seiLayersNotPresent->m_vpsMaxLayers; i++) |
---|
502 | { |
---|
503 | seiLayersNotPresent->m_layerNotPresentFlag[i] = true; |
---|
504 | } |
---|
505 | for ( ; i < MAX_LAYERS; i++) |
---|
506 | { |
---|
507 | seiLayersNotPresent->m_layerNotPresentFlag[i] = false; |
---|
508 | } |
---|
509 | } |
---|
510 | #endif |
---|
511 | |
---|
512 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
513 | Void SEIEncoder::initSEIInterLayerConstrainedTileSets(SEIInterLayerConstrainedTileSets *seiInterLayerConstrainedTileSets) |
---|
514 | { |
---|
515 | seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag = false; |
---|
516 | seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag = false; |
---|
517 | if (!seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag) |
---|
518 | { |
---|
519 | seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 = m_pcCfg->getIlNumSetsInMessage() - 1; |
---|
520 | if (seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1) |
---|
521 | { |
---|
522 | seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = m_pcCfg->getSkippedTileSetPresentFlag(); |
---|
523 | } |
---|
524 | else |
---|
525 | { |
---|
526 | seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = false; |
---|
527 | } |
---|
528 | seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 += seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag ? 1 : 0; |
---|
529 | for (UInt i = 0; i < m_pcCfg->getIlNumSetsInMessage(); i++) |
---|
530 | { |
---|
531 | seiInterLayerConstrainedTileSets->m_ilctsId[i] = i; |
---|
532 | seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i] = 0; |
---|
533 | for( UInt j = 0; j <= seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i]; j++) |
---|
534 | { |
---|
535 | seiInterLayerConstrainedTileSets->m_ilTopLeftTileIndex[i][j] = m_pcCfg->getTopLeftTileIndex(i); |
---|
536 | seiInterLayerConstrainedTileSets->m_ilBottomRightTileIndex[i][j] = m_pcCfg->getBottomRightTileIndex(i); |
---|
537 | } |
---|
538 | seiInterLayerConstrainedTileSets->m_ilcIdc[i] = m_pcCfg->getIlcIdc(i); |
---|
539 | if (seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag) |
---|
540 | { |
---|
541 | seiInterLayerConstrainedTileSets->m_ilExactSampleValueMatchFlag[i] = false; |
---|
542 | } |
---|
543 | } |
---|
544 | } |
---|
545 | } |
---|
546 | #endif |
---|
547 | |
---|
548 | #if P0123_ALPHA_CHANNEL_SEI |
---|
549 | Void SEIEncoder::initSEIAlphaChannelInfo(SEIAlphaChannelInfo *seiAlphaChannelInfo) |
---|
550 | { |
---|
551 | seiAlphaChannelInfo->m_alphaChannelCancelFlag = m_pcCfg->getAlphaCancelFlag(); |
---|
552 | if(!seiAlphaChannelInfo->m_alphaChannelCancelFlag) |
---|
553 | { |
---|
554 | seiAlphaChannelInfo->m_alphaChannelUseIdc = m_pcCfg->getAlphaUseIdc(); |
---|
555 | seiAlphaChannelInfo->m_alphaChannelBitDepthMinus8 = m_pcCfg->getAlphaBitDepthMinus8(); |
---|
556 | seiAlphaChannelInfo->m_alphaTransparentValue = m_pcCfg->getAlphaTransparentValue(); |
---|
557 | seiAlphaChannelInfo->m_alphaOpaqueValue = m_pcCfg->getAlphaOpaqueValue(); |
---|
558 | seiAlphaChannelInfo->m_alphaChannelIncrFlag = m_pcCfg->getAlphaIncrementFlag(); |
---|
559 | seiAlphaChannelInfo->m_alphaChannelClipFlag = m_pcCfg->getAlphaClipFlag(); |
---|
560 | seiAlphaChannelInfo->m_alphaChannelClipTypeFlag = m_pcCfg->getAlphaClipTypeFlag(); |
---|
561 | } |
---|
562 | } |
---|
563 | #endif |
---|
564 | |
---|
565 | #if Q0096_OVERLAY_SEI |
---|
566 | Void SEIEncoder::initSEIOverlayInfo(SEIOverlayInfo *seiOverlayInfo) |
---|
567 | { |
---|
568 | seiOverlayInfo->m_overlayInfoCancelFlag = m_pcCfg->getOverlaySEICancelFlag(); |
---|
569 | if ( !seiOverlayInfo->m_overlayInfoCancelFlag ) |
---|
570 | { |
---|
571 | seiOverlayInfo->m_overlayContentAuxIdMinus128 = m_pcCfg->getOverlaySEIContentAuxIdMinus128(); |
---|
572 | seiOverlayInfo->m_overlayLabelAuxIdMinus128 = m_pcCfg->getOverlaySEILabelAuxIdMinus128(); |
---|
573 | seiOverlayInfo->m_overlayAlphaAuxIdMinus128 = m_pcCfg->getOverlaySEIAlphaAuxIdMinus128(); |
---|
574 | seiOverlayInfo->m_overlayElementLabelValueLengthMinus8 = m_pcCfg->getOverlaySEIElementLabelValueLengthMinus8(); |
---|
575 | seiOverlayInfo->m_numOverlaysMinus1 = m_pcCfg->getOverlaySEINumOverlaysMinus1(); |
---|
576 | seiOverlayInfo->m_overlayIdx = m_pcCfg->getOverlaySEIIdx(); |
---|
577 | seiOverlayInfo->m_languageOverlayPresentFlag = m_pcCfg->getOverlaySEILanguagePresentFlag(); |
---|
578 | seiOverlayInfo->m_overlayContentLayerId = m_pcCfg->getOverlaySEIContentLayerId(); |
---|
579 | seiOverlayInfo->m_overlayLabelPresentFlag = m_pcCfg->getOverlaySEILabelPresentFlag(); |
---|
580 | seiOverlayInfo->m_overlayLabelLayerId = m_pcCfg->getOverlaySEILabelLayerId(); |
---|
581 | seiOverlayInfo->m_overlayAlphaPresentFlag = m_pcCfg->getOverlaySEIAlphaPresentFlag(); |
---|
582 | seiOverlayInfo->m_overlayAlphaLayerId = m_pcCfg->getOverlaySEIAlphaLayerId(); |
---|
583 | seiOverlayInfo->m_numOverlayElementsMinus1 = m_pcCfg->getOverlaySEINumElementsMinus1(); |
---|
584 | seiOverlayInfo->m_overlayElementLabelMin = m_pcCfg->getOverlaySEIElementLabelMin(); |
---|
585 | seiOverlayInfo->m_overlayElementLabelMax = m_pcCfg->getOverlaySEIElementLabelMax(); |
---|
586 | seiOverlayInfo->m_overlayLanguage.resize ( seiOverlayInfo->m_numOverlaysMinus1+1, NULL ); |
---|
587 | seiOverlayInfo->m_overlayLanguageLength.resize ( seiOverlayInfo->m_numOverlaysMinus1+1 ); |
---|
588 | seiOverlayInfo->m_overlayName.resize ( seiOverlayInfo->m_numOverlaysMinus1+1, NULL ); |
---|
589 | seiOverlayInfo->m_overlayNameLength.resize ( seiOverlayInfo->m_numOverlaysMinus1+1 ); |
---|
590 | seiOverlayInfo->m_overlayElementName.resize ( seiOverlayInfo->m_numOverlaysMinus1+1 ); |
---|
591 | seiOverlayInfo->m_overlayElementNameLength.resize ( seiOverlayInfo->m_numOverlaysMinus1+1 ); |
---|
592 | |
---|
593 | Int i,j; |
---|
594 | string strTmp; |
---|
595 | Int nBytes; |
---|
596 | assert( m_pcCfg->getOverlaySEILanguage().size() == seiOverlayInfo->m_numOverlaysMinus1+1 ); |
---|
597 | assert( m_pcCfg->getOverlaySEIName().size() == seiOverlayInfo->m_numOverlaysMinus1+1 ); |
---|
598 | assert( m_pcCfg->getOverlaySEIElementName().size() == seiOverlayInfo->m_numOverlaysMinus1+1 ); |
---|
599 | |
---|
600 | for ( i=0 ; i<=seiOverlayInfo->m_numOverlaysMinus1; i++ ) |
---|
601 | { |
---|
602 | //language tag |
---|
603 | if ( seiOverlayInfo->m_languageOverlayPresentFlag[i] ) |
---|
604 | { |
---|
605 | strTmp = m_pcCfg->getOverlaySEILanguage()[i]; |
---|
606 | nBytes = (Int)m_pcCfg->getOverlaySEILanguage()[i].size(); |
---|
607 | assert( nBytes>0 ); |
---|
608 | seiOverlayInfo->m_overlayLanguage[i] = new UChar[nBytes]; |
---|
609 | memcpy(seiOverlayInfo->m_overlayLanguage[i], strTmp.c_str(), nBytes); |
---|
610 | seiOverlayInfo->m_overlayLanguageLength[i] = nBytes; |
---|
611 | } |
---|
612 | |
---|
613 | //overlay name |
---|
614 | strTmp = m_pcCfg->getOverlaySEIName()[i]; |
---|
615 | nBytes = (Int)m_pcCfg->getOverlaySEIName()[i].size(); |
---|
616 | assert( nBytes>0 ); |
---|
617 | seiOverlayInfo->m_overlayName[i] = new UChar[nBytes]; |
---|
618 | memcpy(seiOverlayInfo->m_overlayName[i], strTmp.c_str(), nBytes); |
---|
619 | seiOverlayInfo->m_overlayNameLength[i] = nBytes; |
---|
620 | |
---|
621 | //overlay element names |
---|
622 | if ( seiOverlayInfo->m_overlayLabelPresentFlag[i] ) |
---|
623 | { |
---|
624 | seiOverlayInfo->m_overlayElementName[i].resize( seiOverlayInfo->m_numOverlayElementsMinus1[i]+1, NULL ); |
---|
625 | seiOverlayInfo->m_overlayElementNameLength[i].resize( seiOverlayInfo->m_numOverlayElementsMinus1[i]+1 ); |
---|
626 | assert( m_pcCfg->getOverlaySEIElementName()[i].size() == seiOverlayInfo->m_numOverlayElementsMinus1[i]+1 ); |
---|
627 | for ( j=0 ; j<=seiOverlayInfo->m_numOverlayElementsMinus1[i] ; j++) |
---|
628 | { |
---|
629 | strTmp = m_pcCfg->getOverlaySEIElementName()[i][j]; |
---|
630 | nBytes = (Int)m_pcCfg->getOverlaySEIElementName()[i][j].size(); |
---|
631 | assert( nBytes>0 ); |
---|
632 | seiOverlayInfo->m_overlayElementName[i][j] = new UChar[nBytes]; |
---|
633 | memcpy(seiOverlayInfo->m_overlayElementName[i][j], strTmp.c_str(), nBytes); |
---|
634 | seiOverlayInfo->m_overlayElementNameLength[i][j] = nBytes; |
---|
635 | } |
---|
636 | } |
---|
637 | } |
---|
638 | seiOverlayInfo->m_overlayInfoPersistenceFlag = true; |
---|
639 | } |
---|
640 | } |
---|
641 | #endif |
---|
642 | |
---|
643 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
644 | Void SEIEncoder::initSEIColourRemappingInfo(SEIColourRemappingInfo *seiColourRemappingInfo, TComSEIColourRemappingInfo* cfgSeiColourRemappingInfo) |
---|
645 | { |
---|
646 | seiColourRemappingInfo->m_colourRemapId = cfgSeiColourRemappingInfo->m_colourRemapSEIId; |
---|
647 | seiColourRemappingInfo->m_colourRemapCancelFlag = cfgSeiColourRemappingInfo->m_colourRemapSEICancelFlag; |
---|
648 | printf("xCreateSEIColourRemappingInfo - m_colourRemapId = %d m_colourRemapCancelFlag = %d \n",seiColourRemappingInfo->m_colourRemapId, seiColourRemappingInfo->m_colourRemapCancelFlag); |
---|
649 | |
---|
650 | if( !seiColourRemappingInfo->m_colourRemapCancelFlag ) |
---|
651 | { |
---|
652 | seiColourRemappingInfo->m_colourRemapPersistenceFlag = cfgSeiColourRemappingInfo->m_colourRemapSEIPersistenceFlag; |
---|
653 | seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag = cfgSeiColourRemappingInfo->m_colourRemapSEIVideoSignalInfoPresentFlag; |
---|
654 | if( seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag ) |
---|
655 | { |
---|
656 | seiColourRemappingInfo->m_colourRemapFullRangeFlag = cfgSeiColourRemappingInfo->m_colourRemapSEIFullRangeFlag; |
---|
657 | seiColourRemappingInfo->m_colourRemapPrimaries = cfgSeiColourRemappingInfo->m_colourRemapSEIPrimaries; |
---|
658 | seiColourRemappingInfo->m_colourRemapTransferFunction = cfgSeiColourRemappingInfo->m_colourRemapSEITransferFunction; |
---|
659 | seiColourRemappingInfo->m_colourRemapMatrixCoefficients = cfgSeiColourRemappingInfo->m_colourRemapSEIMatrixCoefficients; |
---|
660 | } |
---|
661 | seiColourRemappingInfo->m_colourRemapInputBitDepth = cfgSeiColourRemappingInfo->m_colourRemapSEIInputBitDepth; |
---|
662 | seiColourRemappingInfo->m_colourRemapBitDepth = cfgSeiColourRemappingInfo->m_colourRemapSEIBitDepth; |
---|
663 | for( Int c=0 ; c<3 ; c++ ) |
---|
664 | { |
---|
665 | seiColourRemappingInfo->m_preLutNumValMinus1[c] = cfgSeiColourRemappingInfo->m_colourRemapSEIPreLutNumValMinus1[c]; |
---|
666 | if( seiColourRemappingInfo->m_preLutNumValMinus1[c]>0 ) |
---|
667 | { |
---|
668 | seiColourRemappingInfo->m_preLutCodedValue[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1); |
---|
669 | seiColourRemappingInfo->m_preLutTargetValue[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1); |
---|
670 | for( Int i=0 ; i<=seiColourRemappingInfo->m_preLutNumValMinus1[c] ; i++) |
---|
671 | { |
---|
672 | seiColourRemappingInfo->m_preLutCodedValue[c][i] = cfgSeiColourRemappingInfo->m_colourRemapSEIPreLutCodedValue[c][i]; |
---|
673 | seiColourRemappingInfo->m_preLutTargetValue[c][i] = cfgSeiColourRemappingInfo->m_colourRemapSEIPreLutTargetValue[c][i]; |
---|
674 | } |
---|
675 | } |
---|
676 | } |
---|
677 | seiColourRemappingInfo->m_colourRemapMatrixPresentFlag = cfgSeiColourRemappingInfo->m_colourRemapSEIMatrixPresentFlag; |
---|
678 | if( seiColourRemappingInfo->m_colourRemapMatrixPresentFlag ) |
---|
679 | { |
---|
680 | seiColourRemappingInfo->m_log2MatrixDenom = cfgSeiColourRemappingInfo->m_colourRemapSEILog2MatrixDenom; |
---|
681 | for( Int c=0 ; c<3 ; c++ ) |
---|
682 | for( Int i=0 ; i<3 ; i++ ) |
---|
683 | seiColourRemappingInfo->m_colourRemapCoeffs[c][i] = cfgSeiColourRemappingInfo->m_colourRemapSEICoeffs[c][i]; |
---|
684 | } |
---|
685 | for( Int c=0 ; c<3 ; c++ ) |
---|
686 | { |
---|
687 | seiColourRemappingInfo->m_postLutNumValMinus1[c] = cfgSeiColourRemappingInfo->m_colourRemapSEIPostLutNumValMinus1[c]; |
---|
688 | if( seiColourRemappingInfo->m_postLutNumValMinus1[c]>0 ) |
---|
689 | { |
---|
690 | seiColourRemappingInfo->m_postLutCodedValue[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1); |
---|
691 | seiColourRemappingInfo->m_postLutTargetValue[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1); |
---|
692 | for( Int i=0 ; i<=seiColourRemappingInfo->m_postLutNumValMinus1[c] ; i++) |
---|
693 | { |
---|
694 | seiColourRemappingInfo->m_postLutCodedValue[c][i] = cfgSeiColourRemappingInfo->m_colourRemapSEIPostLutCodedValue[c][i]; |
---|
695 | seiColourRemappingInfo->m_postLutTargetValue[c][i] = cfgSeiColourRemappingInfo->m_colourRemapSEIPostLutTargetValue[c][i]; |
---|
696 | } |
---|
697 | } |
---|
698 | } |
---|
699 | } |
---|
700 | } |
---|
701 | #endif |
---|
702 | |
---|
703 | |
---|
704 | #if O0164_MULTI_LAYER_HRD |
---|
705 | Void SEIEncoder::initBspNestingSEI(SEIScalableNesting *seiScalableNesting, const TComVPS *vps, const TComSPS *sps, Int olsIdx, Int partitioningSchemeIdx, Int bspIdx) |
---|
706 | { |
---|
707 | SEIBspInitialArrivalTime *seiBspInitialArrivalTime = new SEIBspInitialArrivalTime(); |
---|
708 | SEIBspNesting *seiBspNesting = new SEIBspNesting(); |
---|
709 | SEIBufferingPeriod *seiBufferingPeriod = new SEIBufferingPeriod(); |
---|
710 | |
---|
711 | // Scalable nesting SEI |
---|
712 | |
---|
713 | 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 |
---|
714 | seiScalableNesting->m_nestingOpFlag = 1; |
---|
715 | seiScalableNesting->m_defaultOpFlag = 0; |
---|
716 | seiScalableNesting->m_nestingNumOpsMinus1 = 0; //nesting_num_ops_minus1 |
---|
717 | seiScalableNesting->m_nestingOpIdx[0] = vps->getOutputLayerSetIdx(olsIdx); |
---|
718 | seiScalableNesting->m_nestingMaxTemporalIdPlus1[0] = 6 + 1; |
---|
719 | seiScalableNesting->m_allLayersFlag = 0; |
---|
720 | seiScalableNesting->m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1; //nesting_no_op_max_temporal_id_plus1 |
---|
721 | seiScalableNesting->m_nestingNumLayersMinus1 = 1 - 1; //nesting_num_layers_minus1 |
---|
722 | seiScalableNesting->m_nestingLayerId[0] = 0; |
---|
723 | |
---|
724 | // Bitstream partition nesting SEI |
---|
725 | seiBspNesting->m_bspIdx = 0; |
---|
726 | |
---|
727 | // Buffering period SEI |
---|
728 | |
---|
729 | UInt uiInitialCpbRemovalDelay = (90000/2); // 0.5 sec |
---|
730 | seiBufferingPeriod->m_initialCpbRemovalDelay [0][0] = uiInitialCpbRemovalDelay; |
---|
731 | seiBufferingPeriod->m_initialCpbRemovalDelayOffset[0][0] = uiInitialCpbRemovalDelay; |
---|
732 | seiBufferingPeriod->m_initialCpbRemovalDelay [0][1] = uiInitialCpbRemovalDelay; |
---|
733 | seiBufferingPeriod->m_initialCpbRemovalDelayOffset[0][1] = uiInitialCpbRemovalDelay; |
---|
734 | |
---|
735 | Double dTmp = (Double)sps->getVuiParameters()->getTimingInfo()->getNumUnitsInTick() / (Double)sps->getVuiParameters()->getTimingInfo()->getTimeScale(); |
---|
736 | |
---|
737 | UInt uiTmp = (UInt)( dTmp * 90000.0 ); |
---|
738 | uiInitialCpbRemovalDelay -= uiTmp; |
---|
739 | uiInitialCpbRemovalDelay -= uiTmp / ( sps->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2 ); |
---|
740 | seiBufferingPeriod->m_initialAltCpbRemovalDelay [0][0] = uiInitialCpbRemovalDelay; |
---|
741 | seiBufferingPeriod->m_initialAltCpbRemovalDelayOffset[0][0] = uiInitialCpbRemovalDelay; |
---|
742 | seiBufferingPeriod->m_initialAltCpbRemovalDelay [0][1] = uiInitialCpbRemovalDelay; |
---|
743 | seiBufferingPeriod->m_initialAltCpbRemovalDelayOffset[0][1] = uiInitialCpbRemovalDelay; |
---|
744 | |
---|
745 | seiBufferingPeriod->m_rapCpbParamsPresentFlag = 0; |
---|
746 | //for the concatenation, it can be set to one during splicing. |
---|
747 | seiBufferingPeriod->m_concatenationFlag = 0; |
---|
748 | //since the temporal layer HRD is not ready, we assumed it is fixed |
---|
749 | seiBufferingPeriod->m_auCpbRemovalDelayDelta = 1; |
---|
750 | seiBufferingPeriod->m_cpbDelayOffset = 0; |
---|
751 | seiBufferingPeriod->m_dpbDelayOffset = 0; |
---|
752 | |
---|
753 | // Intial arrival time SEI message |
---|
754 | |
---|
755 | seiBspInitialArrivalTime->m_nalInitialArrivalDelay[0] = 0; |
---|
756 | seiBspInitialArrivalTime->m_vclInitialArrivalDelay[0] = 0; |
---|
757 | |
---|
758 | |
---|
759 | seiBspNesting->m_nestedSEIs.push_back(seiBufferingPeriod); |
---|
760 | seiBspNesting->m_nestedSEIs.push_back(seiBspInitialArrivalTime); |
---|
761 | seiBspNesting->m_bspIdx = bspIdx; |
---|
762 | seiBspNesting->m_seiOlsIdx = olsIdx; |
---|
763 | seiBspNesting->m_seiPartitioningSchemeIdx = partitioningSchemeIdx; |
---|
764 | seiScalableNesting->m_nestedSEIs.push_back(seiBspNesting); // BSP nesting SEI is contained in scalable nesting SEI |
---|
765 | } |
---|
766 | #endif |
---|
767 | |
---|
768 | //! \} |
---|