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 | decodedPictureHashSEI->method = m_pcCfg->getDecodedPictureHashSEIType(); |
---|
315 | switch (m_pcCfg->getDecodedPictureHashSEIType()) |
---|
316 | { |
---|
317 | case HASHTYPE_MD5: |
---|
318 | { |
---|
319 | UInt numChar=calcMD5(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths); |
---|
320 | rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar); |
---|
321 | } |
---|
322 | break; |
---|
323 | case HASHTYPE_CRC: |
---|
324 | { |
---|
325 | UInt numChar=calcCRC(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths); |
---|
326 | rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar); |
---|
327 | } |
---|
328 | break; |
---|
329 | case HASHTYPE_CHECKSUM: |
---|
330 | default: |
---|
331 | { |
---|
332 | UInt numChar=calcChecksum(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths); |
---|
333 | rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar); |
---|
334 | } |
---|
335 | break; |
---|
336 | } |
---|
337 | } |
---|
338 | |
---|
339 | Void SEIEncoder::initTemporalLevel0IndexSEI(SEITemporalLevel0Index *temporalLevel0IndexSEI, TComSlice *slice) |
---|
340 | { |
---|
341 | assert (m_isInitialized); |
---|
342 | assert (temporalLevel0IndexSEI!=NULL); |
---|
343 | assert (slice!=NULL); |
---|
344 | |
---|
345 | if (slice->getRapPicFlag()) |
---|
346 | { |
---|
347 | m_tl0Idx = 0; |
---|
348 | m_rapIdx = (m_rapIdx + 1) & 0xFF; |
---|
349 | } |
---|
350 | else |
---|
351 | { |
---|
352 | m_tl0Idx = (m_tl0Idx + (slice->getTLayer() ? 0 : 1)) & 0xFF; |
---|
353 | } |
---|
354 | temporalLevel0IndexSEI->tl0Idx = m_tl0Idx; |
---|
355 | temporalLevel0IndexSEI->rapIdx = m_rapIdx; |
---|
356 | } |
---|
357 | |
---|
358 | Void SEIEncoder::initSEITempMotionConstrainedTileSets (SEITempMotionConstrainedTileSets *sei, const TComPPS *pps) |
---|
359 | { |
---|
360 | assert (m_isInitialized); |
---|
361 | assert (sei!=NULL); |
---|
362 | assert (pps!=NULL); |
---|
363 | |
---|
364 | if(pps->getTilesEnabledFlag()) |
---|
365 | { |
---|
366 | sei->m_mc_all_tiles_exact_sample_value_match_flag = false; |
---|
367 | sei->m_each_tile_one_tile_set_flag = false; |
---|
368 | sei->m_limited_tile_set_display_flag = false; |
---|
369 | sei->setNumberOfTileSets((pps->getNumTileColumnsMinus1() + 1) * (pps->getNumTileRowsMinus1() + 1)); |
---|
370 | |
---|
371 | for(Int i=0; i < sei->getNumberOfTileSets(); i++) |
---|
372 | { |
---|
373 | sei->tileSetData(i).m_mcts_id = i; //depends the application; |
---|
374 | sei->tileSetData(i).setNumberOfTileRects(1); |
---|
375 | |
---|
376 | for(Int j=0; j<sei->tileSetData(i).getNumberOfTileRects(); j++) |
---|
377 | { |
---|
378 | sei->tileSetData(i).topLeftTileIndex(j) = i+j; |
---|
379 | sei->tileSetData(i).bottomRightTileIndex(j) = i+j; |
---|
380 | } |
---|
381 | |
---|
382 | sei->tileSetData(i).m_exact_sample_value_match_flag = false; |
---|
383 | sei->tileSetData(i).m_mcts_tier_level_idc_present_flag = false; |
---|
384 | } |
---|
385 | } |
---|
386 | else |
---|
387 | { |
---|
388 | assert(!"Tile is not enabled"); |
---|
389 | } |
---|
390 | } |
---|
391 | |
---|
392 | Void SEIEncoder::initSEIKneeFunctionInfo(SEIKneeFunctionInfo *seiKneeFunctionInfo) |
---|
393 | { |
---|
394 | assert (m_isInitialized); |
---|
395 | assert (seiKneeFunctionInfo!=NULL); |
---|
396 | |
---|
397 | seiKneeFunctionInfo->m_kneeId = m_pcCfg->getKneeSEIId(); |
---|
398 | seiKneeFunctionInfo->m_kneeCancelFlag = m_pcCfg->getKneeSEICancelFlag(); |
---|
399 | if ( !seiKneeFunctionInfo->m_kneeCancelFlag ) |
---|
400 | { |
---|
401 | seiKneeFunctionInfo->m_kneePersistenceFlag = m_pcCfg->getKneeSEIPersistenceFlag(); |
---|
402 | seiKneeFunctionInfo->m_kneeInputDrange = m_pcCfg->getKneeSEIInputDrange(); |
---|
403 | seiKneeFunctionInfo->m_kneeInputDispLuminance = m_pcCfg->getKneeSEIInputDispLuminance(); |
---|
404 | seiKneeFunctionInfo->m_kneeOutputDrange = m_pcCfg->getKneeSEIOutputDrange(); |
---|
405 | seiKneeFunctionInfo->m_kneeOutputDispLuminance = m_pcCfg->getKneeSEIOutputDispLuminance(); |
---|
406 | |
---|
407 | seiKneeFunctionInfo->m_kneeNumKneePointsMinus1 = m_pcCfg->getKneeSEINumKneePointsMinus1(); |
---|
408 | Int* piInputKneePoint = m_pcCfg->getKneeSEIInputKneePoint(); |
---|
409 | Int* piOutputKneePoint = m_pcCfg->getKneeSEIOutputKneePoint(); |
---|
410 | if(piInputKneePoint&&piOutputKneePoint) |
---|
411 | { |
---|
412 | seiKneeFunctionInfo->m_kneeInputKneePoint.resize(seiKneeFunctionInfo->m_kneeNumKneePointsMinus1+1); |
---|
413 | seiKneeFunctionInfo->m_kneeOutputKneePoint.resize(seiKneeFunctionInfo->m_kneeNumKneePointsMinus1+1); |
---|
414 | for(Int i=0; i<=seiKneeFunctionInfo->m_kneeNumKneePointsMinus1; i++) |
---|
415 | { |
---|
416 | seiKneeFunctionInfo->m_kneeInputKneePoint[i] = piInputKneePoint[i]; |
---|
417 | seiKneeFunctionInfo->m_kneeOutputKneePoint[i] = piOutputKneePoint[i]; |
---|
418 | } |
---|
419 | } |
---|
420 | } |
---|
421 | } |
---|
422 | |
---|
423 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
424 | template <typename T> |
---|
425 | static Void readTokenValue(T &returnedValue, /// value returned |
---|
426 | Bool &failed, /// used and updated |
---|
427 | std::istream &is, /// stream to read token from |
---|
428 | const TChar *pToken) /// token string |
---|
429 | { |
---|
430 | returnedValue=T(); |
---|
431 | if (failed) |
---|
432 | { |
---|
433 | return; |
---|
434 | } |
---|
435 | |
---|
436 | Int c; |
---|
437 | // Ignore any whitespace |
---|
438 | while ((c=is.get())!=EOF && isspace(c)); |
---|
439 | // test for comment mark |
---|
440 | while (c=='#') |
---|
441 | { |
---|
442 | // Ignore to the end of the line |
---|
443 | while ((c=is.get())!=EOF && (c!=10 && c!=13)); |
---|
444 | // Ignore any white space at the start of the next line |
---|
445 | while ((c=is.get())!=EOF && isspace(c)); |
---|
446 | } |
---|
447 | // test first character of token |
---|
448 | failed=(c!=pToken[0]); |
---|
449 | // test remaining characters of token |
---|
450 | Int pos; |
---|
451 | for(pos=1;!failed && pToken[pos]!=0 && is.get()==pToken[pos]; pos++); |
---|
452 | failed|=(pToken[pos]!=0); |
---|
453 | // Ignore any whitespace before the ':' |
---|
454 | while (!failed && (c=is.get())!=EOF && isspace(c)); |
---|
455 | failed|=(c!=':'); |
---|
456 | // Now read the value associated with the token: |
---|
457 | if (!failed) |
---|
458 | { |
---|
459 | is >> returnedValue; |
---|
460 | failed=!is.good(); |
---|
461 | if (!failed) |
---|
462 | { |
---|
463 | c=is.get(); |
---|
464 | failed=(c!=EOF && !isspace(c)); |
---|
465 | } |
---|
466 | } |
---|
467 | if (failed) |
---|
468 | { |
---|
469 | std::cerr << "Unable to read token '" << pToken << "'\n"; |
---|
470 | } |
---|
471 | } |
---|
472 | |
---|
473 | template <typename T> |
---|
474 | static Void readTokenValueAndValidate(T &returnedValue, /// value returned |
---|
475 | Bool &failed, /// used and updated |
---|
476 | std::istream &is, /// stream to read token from |
---|
477 | const TChar *pToken, /// token string |
---|
478 | const T &minInclusive, /// minimum value allowed, inclusive |
---|
479 | const T &maxInclusive) /// maximum value allowed, inclusive |
---|
480 | { |
---|
481 | readTokenValue(returnedValue, failed, is, pToken); |
---|
482 | if (!failed) |
---|
483 | { |
---|
484 | if (returnedValue<minInclusive || returnedValue>maxInclusive) |
---|
485 | { |
---|
486 | failed=true; |
---|
487 | std::cerr << "Value for token " << pToken << " must be in the range " << minInclusive << " to " << maxInclusive << " (inclusive); value read: " << returnedValue << std::endl; |
---|
488 | } |
---|
489 | } |
---|
490 | } |
---|
491 | |
---|
492 | // Bool version does not have maximum and minimum values. |
---|
493 | static Void readTokenValueAndValidate(Bool &returnedValue, /// value returned |
---|
494 | Bool &failed, /// used and updated |
---|
495 | std::istream &is, /// stream to read token from |
---|
496 | const TChar *pToken) /// token string |
---|
497 | { |
---|
498 | readTokenValue(returnedValue, failed, is, pToken); |
---|
499 | } |
---|
500 | |
---|
501 | Bool SEIEncoder::initSEIColourRemappingInfo(SEIColourRemappingInfo* seiColourRemappingInfo, Int currPOC) // returns true on success, false on failure. |
---|
502 | { |
---|
503 | assert (m_isInitialized); |
---|
504 | assert (seiColourRemappingInfo!=NULL); |
---|
505 | |
---|
506 | // reading external Colour Remapping Information SEI message parameters from file |
---|
507 | if( !m_pcCfg->getColourRemapInfoSEIFileRoot().empty()) |
---|
508 | { |
---|
509 | Bool failed=false; |
---|
510 | |
---|
511 | // building the CRI file name with poc num in prefix "_poc.txt" |
---|
512 | std::string colourRemapSEIFileWithPoc(m_pcCfg->getColourRemapInfoSEIFileRoot()); |
---|
513 | { |
---|
514 | std::stringstream suffix; |
---|
515 | suffix << "_" << currPOC << ".txt"; |
---|
516 | colourRemapSEIFileWithPoc+=suffix.str(); |
---|
517 | } |
---|
518 | |
---|
519 | std::ifstream fic(colourRemapSEIFileWithPoc.c_str()); |
---|
520 | if (!fic.good() || !fic.is_open()) |
---|
521 | { |
---|
522 | std::cerr << "No Colour Remapping Information SEI parameters file " << colourRemapSEIFileWithPoc << " for POC " << currPOC << std::endl; |
---|
523 | return false; |
---|
524 | } |
---|
525 | |
---|
526 | // TODO: identify and remove duplication with decoder parsing through abstraction. |
---|
527 | |
---|
528 | readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapId, failed, fic, "colour_remap_id", UInt(0), UInt(0x7fffffff) ); |
---|
529 | readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapCancelFlag, failed, fic, "colour_remap_cancel_flag" ); |
---|
530 | if( !seiColourRemappingInfo->m_colourRemapCancelFlag ) |
---|
531 | { |
---|
532 | readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapPersistenceFlag, failed, fic, "colour_remap_persistence_flag" ); |
---|
533 | readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag, failed, fic, "colour_remap_video_signal_info_present_flag"); |
---|
534 | if( seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag ) |
---|
535 | { |
---|
536 | readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapFullRangeFlag, failed, fic, "colour_remap_full_range_flag" ); |
---|
537 | readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapPrimaries, failed, fic, "colour_remap_primaries", Int(0), Int(255) ); |
---|
538 | readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapTransferFunction, failed, fic, "colour_remap_transfer_function", Int(0), Int(255) ); |
---|
539 | readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapMatrixCoefficients, failed, fic, "colour_remap_matrix_coefficients", Int(0), Int(255) ); |
---|
540 | } |
---|
541 | readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapInputBitDepth, failed, fic, "colour_remap_input_bit_depth", Int(8), Int(16) ); |
---|
542 | readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapBitDepth, failed, fic, "colour_remap_bit_depth", Int(8), Int(16) ); |
---|
543 | |
---|
544 | const Int maximumInputValue = (1<<seiColourRemappingInfo->m_colourRemapInputBitDepth)-1; |
---|
545 | const Int maximumRemappedValue = (1<<seiColourRemappingInfo->m_colourRemapBitDepth)-1; |
---|
546 | |
---|
547 | for( Int c=0 ; c<3 ; c++ ) |
---|
548 | { |
---|
549 | readTokenValueAndValidate(seiColourRemappingInfo->m_preLutNumValMinus1[c], failed, fic, "pre_lut_num_val_minus1[c]", Int(0), Int(32) ); |
---|
550 | if( seiColourRemappingInfo->m_preLutNumValMinus1[c]>0 ) |
---|
551 | { |
---|
552 | seiColourRemappingInfo->m_preLut[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1); |
---|
553 | for( Int i=0 ; i<=seiColourRemappingInfo->m_preLutNumValMinus1[c] ; i++ ) |
---|
554 | { |
---|
555 | readTokenValueAndValidate(seiColourRemappingInfo->m_preLut[c][i].codedValue, failed, fic, "pre_lut_coded_value[c][i]", Int(0), maximumInputValue ); |
---|
556 | readTokenValueAndValidate(seiColourRemappingInfo->m_preLut[c][i].targetValue, failed, fic, "pre_lut_target_value[c][i]", Int(0), maximumRemappedValue ); |
---|
557 | } |
---|
558 | } |
---|
559 | } |
---|
560 | readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapMatrixPresentFlag, failed, fic, "colour_remap_matrix_present_flag" ); |
---|
561 | if( seiColourRemappingInfo->m_colourRemapMatrixPresentFlag ) |
---|
562 | { |
---|
563 | readTokenValueAndValidate(seiColourRemappingInfo->m_log2MatrixDenom, failed, fic, "log2_matrix_denom", Int(0), Int(15) ); |
---|
564 | for( Int c=0 ; c<3 ; c++ ) |
---|
565 | { |
---|
566 | for( Int i=0 ; i<3 ; i++ ) |
---|
567 | { |
---|
568 | readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapCoeffs[c][i], failed, fic, "colour_remap_coeffs[c][i]", -32768, 32767 ); |
---|
569 | } |
---|
570 | } |
---|
571 | } |
---|
572 | for( Int c=0 ; c<3 ; c++ ) |
---|
573 | { |
---|
574 | readTokenValueAndValidate(seiColourRemappingInfo->m_postLutNumValMinus1[c], failed, fic, "post_lut_num_val_minus1[c]", Int(0), Int(32) ); |
---|
575 | if( seiColourRemappingInfo->m_postLutNumValMinus1[c]>0 ) |
---|
576 | { |
---|
577 | seiColourRemappingInfo->m_postLut[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1); |
---|
578 | for( Int i=0 ; i<=seiColourRemappingInfo->m_postLutNumValMinus1[c] ; i++ ) |
---|
579 | { |
---|
580 | readTokenValueAndValidate(seiColourRemappingInfo->m_postLut[c][i].codedValue, failed, fic, "post_lut_coded_value[c][i]", Int(0), maximumRemappedValue ); |
---|
581 | readTokenValueAndValidate(seiColourRemappingInfo->m_postLut[c][i].targetValue, failed, fic, "post_lut_target_value[c][i]", Int(0), maximumRemappedValue ); |
---|
582 | } |
---|
583 | } |
---|
584 | } |
---|
585 | } |
---|
586 | |
---|
587 | if( failed ) |
---|
588 | { |
---|
589 | std::cerr << "Error while reading Colour Remapping Information SEI parameters file '" << colourRemapSEIFileWithPoc << "'" << std::endl; |
---|
590 | exit(EXIT_FAILURE); |
---|
591 | } |
---|
592 | } |
---|
593 | return true; |
---|
594 | } |
---|
595 | #endif |
---|
596 | |
---|
597 | Void SEIEncoder::initSEIChromaResamplingFilterHint(SEIChromaResamplingFilterHint *seiChromaResamplingFilterHint, Int iHorFilterIndex, Int iVerFilterIndex) |
---|
598 | { |
---|
599 | assert (m_isInitialized); |
---|
600 | assert (seiChromaResamplingFilterHint!=NULL); |
---|
601 | |
---|
602 | seiChromaResamplingFilterHint->m_verChromaFilterIdc = iVerFilterIndex; |
---|
603 | seiChromaResamplingFilterHint->m_horChromaFilterIdc = iHorFilterIndex; |
---|
604 | seiChromaResamplingFilterHint->m_verFilteringFieldProcessingFlag = 1; |
---|
605 | seiChromaResamplingFilterHint->m_targetFormatIdc = 3; |
---|
606 | seiChromaResamplingFilterHint->m_perfectReconstructionFlag = false; |
---|
607 | |
---|
608 | // this creates some example filter values, if explicit filter definition is selected |
---|
609 | if (seiChromaResamplingFilterHint->m_verChromaFilterIdc == 1) |
---|
610 | { |
---|
611 | const Int numVerticalFilters = 3; |
---|
612 | const Int verTapLengthMinus1[] = {5,3,3}; |
---|
613 | |
---|
614 | seiChromaResamplingFilterHint->m_verFilterCoeff.resize(numVerticalFilters); |
---|
615 | for(Int i = 0; i < numVerticalFilters; i ++) |
---|
616 | { |
---|
617 | seiChromaResamplingFilterHint->m_verFilterCoeff[i].resize(verTapLengthMinus1[i]+1); |
---|
618 | } |
---|
619 | // Note: C++11 -> seiChromaResamplingFilterHint->m_verFilterCoeff[0] = {-3,13,31,23,3,-3}; |
---|
620 | seiChromaResamplingFilterHint->m_verFilterCoeff[0][0] = -3; |
---|
621 | seiChromaResamplingFilterHint->m_verFilterCoeff[0][1] = 13; |
---|
622 | seiChromaResamplingFilterHint->m_verFilterCoeff[0][2] = 31; |
---|
623 | seiChromaResamplingFilterHint->m_verFilterCoeff[0][3] = 23; |
---|
624 | seiChromaResamplingFilterHint->m_verFilterCoeff[0][4] = 3; |
---|
625 | seiChromaResamplingFilterHint->m_verFilterCoeff[0][5] = -3; |
---|
626 | |
---|
627 | seiChromaResamplingFilterHint->m_verFilterCoeff[1][0] = -1; |
---|
628 | seiChromaResamplingFilterHint->m_verFilterCoeff[1][1] = 25; |
---|
629 | seiChromaResamplingFilterHint->m_verFilterCoeff[1][2] = 247; |
---|
630 | seiChromaResamplingFilterHint->m_verFilterCoeff[1][3] = -15; |
---|
631 | |
---|
632 | seiChromaResamplingFilterHint->m_verFilterCoeff[2][0] = -20; |
---|
633 | seiChromaResamplingFilterHint->m_verFilterCoeff[2][1] = 186; |
---|
634 | seiChromaResamplingFilterHint->m_verFilterCoeff[2][2] = 100; |
---|
635 | seiChromaResamplingFilterHint->m_verFilterCoeff[2][3] = -10; |
---|
636 | } |
---|
637 | else |
---|
638 | { |
---|
639 | seiChromaResamplingFilterHint->m_verFilterCoeff.resize(0); |
---|
640 | } |
---|
641 | |
---|
642 | if (seiChromaResamplingFilterHint->m_horChromaFilterIdc == 1) |
---|
643 | { |
---|
644 | Int const numHorizontalFilters = 1; |
---|
645 | const Int horTapLengthMinus1[] = {3}; |
---|
646 | |
---|
647 | seiChromaResamplingFilterHint->m_horFilterCoeff.resize(numHorizontalFilters); |
---|
648 | for(Int i = 0; i < numHorizontalFilters; i ++) |
---|
649 | { |
---|
650 | seiChromaResamplingFilterHint->m_horFilterCoeff[i].resize(horTapLengthMinus1[i]+1); |
---|
651 | } |
---|
652 | seiChromaResamplingFilterHint->m_horFilterCoeff[0][0] = 1; |
---|
653 | seiChromaResamplingFilterHint->m_horFilterCoeff[0][1] = 6; |
---|
654 | seiChromaResamplingFilterHint->m_horFilterCoeff[0][2] = 1; |
---|
655 | } |
---|
656 | else |
---|
657 | { |
---|
658 | seiChromaResamplingFilterHint->m_horFilterCoeff.resize(0); |
---|
659 | } |
---|
660 | } |
---|
661 | |
---|
662 | Void SEIEncoder::initSEITimeCode(SEITimeCode *seiTimeCode) |
---|
663 | { |
---|
664 | assert (m_isInitialized); |
---|
665 | assert (seiTimeCode!=NULL); |
---|
666 | // Set data as per command line options |
---|
667 | seiTimeCode->numClockTs = m_pcCfg->getNumberOfTimesets(); |
---|
668 | for(Int i = 0; i < seiTimeCode->numClockTs; i++) |
---|
669 | { |
---|
670 | seiTimeCode->timeSetArray[i] = m_pcCfg->getTimeSet(i); |
---|
671 | } |
---|
672 | } |
---|
673 | |
---|
674 | #if LAYERS_NOT_PRESENT_SEI |
---|
675 | Void SEIEncoder::initSEILayersNotPresent(SEILayersNotPresent *seiLayersNotPresent) |
---|
676 | { |
---|
677 | UInt i = 0; |
---|
678 | seiLayersNotPresent->m_activeVpsId = m_pcCfg->getVPS()->getVPSId(); |
---|
679 | seiLayersNotPresent->m_vpsMaxLayers = m_pcCfg->getVPS()->getMaxLayers(); |
---|
680 | for ( ; i < seiLayersNotPresent->m_vpsMaxLayers; i++) |
---|
681 | { |
---|
682 | seiLayersNotPresent->m_layerNotPresentFlag[i] = true; |
---|
683 | } |
---|
684 | for ( ; i < MAX_LAYERS; i++) |
---|
685 | { |
---|
686 | seiLayersNotPresent->m_layerNotPresentFlag[i] = false; |
---|
687 | } |
---|
688 | } |
---|
689 | #endif |
---|
690 | |
---|
691 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
692 | Void SEIEncoder::initSEIInterLayerConstrainedTileSets(SEIInterLayerConstrainedTileSets *seiInterLayerConstrainedTileSets) |
---|
693 | { |
---|
694 | seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag = false; |
---|
695 | seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag = false; |
---|
696 | if (!seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag) |
---|
697 | { |
---|
698 | seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 = m_pcCfg->getIlNumSetsInMessage() - 1; |
---|
699 | if (seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1) |
---|
700 | { |
---|
701 | seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = m_pcCfg->getSkippedTileSetPresentFlag(); |
---|
702 | } |
---|
703 | else |
---|
704 | { |
---|
705 | seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = false; |
---|
706 | } |
---|
707 | seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 += seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag ? 1 : 0; |
---|
708 | for (UInt i = 0; i < m_pcCfg->getIlNumSetsInMessage(); i++) |
---|
709 | { |
---|
710 | seiInterLayerConstrainedTileSets->m_ilctsId[i] = i; |
---|
711 | seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i] = 0; |
---|
712 | for( UInt j = 0; j <= seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i]; j++) |
---|
713 | { |
---|
714 | seiInterLayerConstrainedTileSets->m_ilTopLeftTileIndex[i][j] = m_pcCfg->getTopLeftTileIndex(i); |
---|
715 | seiInterLayerConstrainedTileSets->m_ilBottomRightTileIndex[i][j] = m_pcCfg->getBottomRightTileIndex(i); |
---|
716 | } |
---|
717 | seiInterLayerConstrainedTileSets->m_ilcIdc[i] = m_pcCfg->getIlcIdc(i); |
---|
718 | if (seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag) |
---|
719 | { |
---|
720 | seiInterLayerConstrainedTileSets->m_ilExactSampleValueMatchFlag[i] = false; |
---|
721 | } |
---|
722 | } |
---|
723 | } |
---|
724 | } |
---|
725 | #endif |
---|
726 | |
---|
727 | #if P0123_ALPHA_CHANNEL_SEI |
---|
728 | Void SEIEncoder::initSEIAlphaChannelInfo(SEIAlphaChannelInfo *seiAlphaChannelInfo) |
---|
729 | { |
---|
730 | seiAlphaChannelInfo->m_alphaChannelCancelFlag = m_pcCfg->getAlphaCancelFlag(); |
---|
731 | if(!seiAlphaChannelInfo->m_alphaChannelCancelFlag) |
---|
732 | { |
---|
733 | seiAlphaChannelInfo->m_alphaChannelUseIdc = m_pcCfg->getAlphaUseIdc(); |
---|
734 | seiAlphaChannelInfo->m_alphaChannelBitDepthMinus8 = m_pcCfg->getAlphaBitDepthMinus8(); |
---|
735 | seiAlphaChannelInfo->m_alphaTransparentValue = m_pcCfg->getAlphaTransparentValue(); |
---|
736 | seiAlphaChannelInfo->m_alphaOpaqueValue = m_pcCfg->getAlphaOpaqueValue(); |
---|
737 | seiAlphaChannelInfo->m_alphaChannelIncrFlag = m_pcCfg->getAlphaIncrementFlag(); |
---|
738 | seiAlphaChannelInfo->m_alphaChannelClipFlag = m_pcCfg->getAlphaClipFlag(); |
---|
739 | seiAlphaChannelInfo->m_alphaChannelClipTypeFlag = m_pcCfg->getAlphaClipTypeFlag(); |
---|
740 | } |
---|
741 | } |
---|
742 | #endif |
---|
743 | |
---|
744 | #if Q0096_OVERLAY_SEI |
---|
745 | Void SEIEncoder::initSEIOverlayInfo(SEIOverlayInfo *seiOverlayInfo) |
---|
746 | { |
---|
747 | seiOverlayInfo->m_overlayInfoCancelFlag = m_pcCfg->getOverlaySEICancelFlag(); |
---|
748 | if ( !seiOverlayInfo->m_overlayInfoCancelFlag ) |
---|
749 | { |
---|
750 | seiOverlayInfo->m_overlayContentAuxIdMinus128 = m_pcCfg->getOverlaySEIContentAuxIdMinus128(); |
---|
751 | seiOverlayInfo->m_overlayLabelAuxIdMinus128 = m_pcCfg->getOverlaySEILabelAuxIdMinus128(); |
---|
752 | seiOverlayInfo->m_overlayAlphaAuxIdMinus128 = m_pcCfg->getOverlaySEIAlphaAuxIdMinus128(); |
---|
753 | seiOverlayInfo->m_overlayElementLabelValueLengthMinus8 = m_pcCfg->getOverlaySEIElementLabelValueLengthMinus8(); |
---|
754 | seiOverlayInfo->m_numOverlaysMinus1 = m_pcCfg->getOverlaySEINumOverlaysMinus1(); |
---|
755 | seiOverlayInfo->m_overlayIdx = m_pcCfg->getOverlaySEIIdx(); |
---|
756 | seiOverlayInfo->m_languageOverlayPresentFlag = m_pcCfg->getOverlaySEILanguagePresentFlag(); |
---|
757 | seiOverlayInfo->m_overlayContentLayerId = m_pcCfg->getOverlaySEIContentLayerId(); |
---|
758 | seiOverlayInfo->m_overlayLabelPresentFlag = m_pcCfg->getOverlaySEILabelPresentFlag(); |
---|
759 | seiOverlayInfo->m_overlayLabelLayerId = m_pcCfg->getOverlaySEILabelLayerId(); |
---|
760 | seiOverlayInfo->m_overlayAlphaPresentFlag = m_pcCfg->getOverlaySEIAlphaPresentFlag(); |
---|
761 | seiOverlayInfo->m_overlayAlphaLayerId = m_pcCfg->getOverlaySEIAlphaLayerId(); |
---|
762 | seiOverlayInfo->m_numOverlayElementsMinus1 = m_pcCfg->getOverlaySEINumElementsMinus1(); |
---|
763 | seiOverlayInfo->m_overlayElementLabelMin = m_pcCfg->getOverlaySEIElementLabelMin(); |
---|
764 | seiOverlayInfo->m_overlayElementLabelMax = m_pcCfg->getOverlaySEIElementLabelMax(); |
---|
765 | seiOverlayInfo->m_overlayLanguage.resize ( seiOverlayInfo->m_numOverlaysMinus1+1, NULL ); |
---|
766 | seiOverlayInfo->m_overlayLanguageLength.resize ( seiOverlayInfo->m_numOverlaysMinus1+1 ); |
---|
767 | seiOverlayInfo->m_overlayName.resize ( seiOverlayInfo->m_numOverlaysMinus1+1, NULL ); |
---|
768 | seiOverlayInfo->m_overlayNameLength.resize ( seiOverlayInfo->m_numOverlaysMinus1+1 ); |
---|
769 | seiOverlayInfo->m_overlayElementName.resize ( seiOverlayInfo->m_numOverlaysMinus1+1 ); |
---|
770 | seiOverlayInfo->m_overlayElementNameLength.resize ( seiOverlayInfo->m_numOverlaysMinus1+1 ); |
---|
771 | |
---|
772 | Int i,j; |
---|
773 | string strTmp; |
---|
774 | Int nBytes; |
---|
775 | assert( m_pcCfg->getOverlaySEILanguage().size() == seiOverlayInfo->m_numOverlaysMinus1+1 ); |
---|
776 | assert( m_pcCfg->getOverlaySEIName().size() == seiOverlayInfo->m_numOverlaysMinus1+1 ); |
---|
777 | assert( m_pcCfg->getOverlaySEIElementName().size() == seiOverlayInfo->m_numOverlaysMinus1+1 ); |
---|
778 | |
---|
779 | for ( i=0 ; i<=seiOverlayInfo->m_numOverlaysMinus1; i++ ) |
---|
780 | { |
---|
781 | //language tag |
---|
782 | if ( seiOverlayInfo->m_languageOverlayPresentFlag[i] ) |
---|
783 | { |
---|
784 | strTmp = m_pcCfg->getOverlaySEILanguage()[i]; |
---|
785 | nBytes = (Int)m_pcCfg->getOverlaySEILanguage()[i].size(); |
---|
786 | assert( nBytes>0 ); |
---|
787 | seiOverlayInfo->m_overlayLanguage[i] = new UChar[nBytes]; |
---|
788 | memcpy(seiOverlayInfo->m_overlayLanguage[i], strTmp.c_str(), nBytes); |
---|
789 | seiOverlayInfo->m_overlayLanguageLength[i] = nBytes; |
---|
790 | } |
---|
791 | |
---|
792 | //overlay name |
---|
793 | strTmp = m_pcCfg->getOverlaySEIName()[i]; |
---|
794 | nBytes = (Int)m_pcCfg->getOverlaySEIName()[i].size(); |
---|
795 | assert( nBytes>0 ); |
---|
796 | seiOverlayInfo->m_overlayName[i] = new UChar[nBytes]; |
---|
797 | memcpy(seiOverlayInfo->m_overlayName[i], strTmp.c_str(), nBytes); |
---|
798 | seiOverlayInfo->m_overlayNameLength[i] = nBytes; |
---|
799 | |
---|
800 | //overlay element names |
---|
801 | if ( seiOverlayInfo->m_overlayLabelPresentFlag[i] ) |
---|
802 | { |
---|
803 | seiOverlayInfo->m_overlayElementName[i].resize( seiOverlayInfo->m_numOverlayElementsMinus1[i]+1, NULL ); |
---|
804 | seiOverlayInfo->m_overlayElementNameLength[i].resize( seiOverlayInfo->m_numOverlayElementsMinus1[i]+1 ); |
---|
805 | assert( m_pcCfg->getOverlaySEIElementName()[i].size() == seiOverlayInfo->m_numOverlayElementsMinus1[i]+1 ); |
---|
806 | for ( j=0 ; j<=seiOverlayInfo->m_numOverlayElementsMinus1[i] ; j++) |
---|
807 | { |
---|
808 | strTmp = m_pcCfg->getOverlaySEIElementName()[i][j]; |
---|
809 | nBytes = (Int)m_pcCfg->getOverlaySEIElementName()[i][j].size(); |
---|
810 | assert( nBytes>0 ); |
---|
811 | seiOverlayInfo->m_overlayElementName[i][j] = new UChar[nBytes]; |
---|
812 | memcpy(seiOverlayInfo->m_overlayElementName[i][j], strTmp.c_str(), nBytes); |
---|
813 | seiOverlayInfo->m_overlayElementNameLength[i][j] = nBytes; |
---|
814 | } |
---|
815 | } |
---|
816 | } |
---|
817 | seiOverlayInfo->m_overlayInfoPersistenceFlag = true; |
---|
818 | } |
---|
819 | } |
---|
820 | #endif |
---|
821 | |
---|
822 | #if O0164_MULTI_LAYER_HRD |
---|
823 | Void SEIEncoder::initBspNestingSEI(SEIScalableNesting *seiScalableNesting, const TComVPS *vps, const TComSPS *sps, Int olsIdx, Int partitioningSchemeIdx, Int bspIdx) |
---|
824 | { |
---|
825 | SEIBspInitialArrivalTime *seiBspInitialArrivalTime = new SEIBspInitialArrivalTime(); |
---|
826 | SEIBspNesting *seiBspNesting = new SEIBspNesting(); |
---|
827 | SEIBufferingPeriod *seiBufferingPeriod = new SEIBufferingPeriod(); |
---|
828 | |
---|
829 | // Scalable nesting SEI |
---|
830 | |
---|
831 | 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 |
---|
832 | seiScalableNesting->m_nestingOpFlag = 1; |
---|
833 | seiScalableNesting->m_defaultOpFlag = 0; |
---|
834 | seiScalableNesting->m_nestingNumOpsMinus1 = 0; //nesting_num_ops_minus1 |
---|
835 | seiScalableNesting->m_nestingOpIdx[0] = vps->getOutputLayerSetIdx(olsIdx); |
---|
836 | seiScalableNesting->m_nestingMaxTemporalIdPlus1[0] = 6 + 1; |
---|
837 | seiScalableNesting->m_allLayersFlag = 0; |
---|
838 | seiScalableNesting->m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1; //nesting_no_op_max_temporal_id_plus1 |
---|
839 | seiScalableNesting->m_nestingNumLayersMinus1 = 1 - 1; //nesting_num_layers_minus1 |
---|
840 | seiScalableNesting->m_nestingLayerId[0] = 0; |
---|
841 | |
---|
842 | // Bitstream partition nesting SEI |
---|
843 | seiBspNesting->m_bspIdx = 0; |
---|
844 | |
---|
845 | // Buffering period SEI |
---|
846 | |
---|
847 | UInt uiInitialCpbRemovalDelay = (90000/2); // 0.5 sec |
---|
848 | seiBufferingPeriod->m_initialCpbRemovalDelay [0][0] = uiInitialCpbRemovalDelay; |
---|
849 | seiBufferingPeriod->m_initialCpbRemovalDelayOffset[0][0] = uiInitialCpbRemovalDelay; |
---|
850 | seiBufferingPeriod->m_initialCpbRemovalDelay [0][1] = uiInitialCpbRemovalDelay; |
---|
851 | seiBufferingPeriod->m_initialCpbRemovalDelayOffset[0][1] = uiInitialCpbRemovalDelay; |
---|
852 | |
---|
853 | Double dTmp = (Double)sps->getVuiParameters()->getTimingInfo()->getNumUnitsInTick() / (Double)sps->getVuiParameters()->getTimingInfo()->getTimeScale(); |
---|
854 | |
---|
855 | UInt uiTmp = (UInt)( dTmp * 90000.0 ); |
---|
856 | uiInitialCpbRemovalDelay -= uiTmp; |
---|
857 | uiInitialCpbRemovalDelay -= uiTmp / ( sps->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2 ); |
---|
858 | seiBufferingPeriod->m_initialAltCpbRemovalDelay [0][0] = uiInitialCpbRemovalDelay; |
---|
859 | seiBufferingPeriod->m_initialAltCpbRemovalDelayOffset[0][0] = uiInitialCpbRemovalDelay; |
---|
860 | seiBufferingPeriod->m_initialAltCpbRemovalDelay [0][1] = uiInitialCpbRemovalDelay; |
---|
861 | seiBufferingPeriod->m_initialAltCpbRemovalDelayOffset[0][1] = uiInitialCpbRemovalDelay; |
---|
862 | |
---|
863 | seiBufferingPeriod->m_rapCpbParamsPresentFlag = 0; |
---|
864 | //for the concatenation, it can be set to one during splicing. |
---|
865 | seiBufferingPeriod->m_concatenationFlag = 0; |
---|
866 | //since the temporal layer HRD is not ready, we assumed it is fixed |
---|
867 | seiBufferingPeriod->m_auCpbRemovalDelayDelta = 1; |
---|
868 | seiBufferingPeriod->m_cpbDelayOffset = 0; |
---|
869 | seiBufferingPeriod->m_dpbDelayOffset = 0; |
---|
870 | |
---|
871 | // Intial arrival time SEI message |
---|
872 | |
---|
873 | seiBspInitialArrivalTime->m_nalInitialArrivalDelay[0] = 0; |
---|
874 | seiBspInitialArrivalTime->m_vclInitialArrivalDelay[0] = 0; |
---|
875 | |
---|
876 | |
---|
877 | seiBspNesting->m_nestedSEIs.push_back(seiBufferingPeriod); |
---|
878 | seiBspNesting->m_nestedSEIs.push_back(seiBspInitialArrivalTime); |
---|
879 | seiBspNesting->m_bspIdx = bspIdx; |
---|
880 | seiBspNesting->m_seiOlsIdx = olsIdx; |
---|
881 | seiBspNesting->m_seiPartitioningSchemeIdx = partitioningSchemeIdx; |
---|
882 | seiScalableNesting->m_nestedSEIs.push_back(seiBspNesting); // BSP nesting SEI is contained in scalable nesting SEI |
---|
883 | } |
---|
884 | #endif |
---|
885 | |
---|
886 | //! \} |
---|