HEVC Test Model (HM)  HM-16.18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SEIEncoder.cpp
Go to the documentation of this file.
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-2017, 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 
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  seiActiveParameterSets->numSpsIdsMinus1 = 0;
53  seiActiveParameterSets->activeSeqParameterSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1);
54  seiActiveParameterSets->activeSeqParameterSetId[0] = sps->getSPSId();
55 }
56 
58 {
59  assert (m_isInitialized);
60  assert (seiFramePacking!=NULL);
61 
63  seiFramePacking->m_arrangementCancelFlag = 0;
65  assert((seiFramePacking->m_arrangementType > 2) && (seiFramePacking->m_arrangementType < 6) );
68  seiFramePacking->m_spatialFlippingFlag = 0;
69  seiFramePacking->m_frame0FlippedFlag = 0;
70  seiFramePacking->m_fieldViewsFlag = (seiFramePacking->m_arrangementType == 2);
71  seiFramePacking->m_currentFrameIsFrame0Flag = ((seiFramePacking->m_arrangementType == 5) && (currPicNum&1) );
72  seiFramePacking->m_frame0SelfContainedFlag = 0;
73  seiFramePacking->m_frame1SelfContainedFlag = 0;
74  seiFramePacking->m_frame0GridPositionX = 0;
75  seiFramePacking->m_frame0GridPositionY = 0;
76  seiFramePacking->m_frame1GridPositionX = 0;
77  seiFramePacking->m_frame1GridPositionY = 0;
78  seiFramePacking->m_arrangementReservedByte = 0;
79  seiFramePacking->m_arrangementPersistenceFlag = true;
80  seiFramePacking->m_upsampledAspectRatio = 0;
81 }
82 
84 {
85  assert (m_isInitialized);
86  assert (seiSegmentedRectFramePacking!=NULL);
87 
91 }
92 
94 {
95  assert (m_isInitialized);
96  assert (seiDisplayOrientation!=NULL);
97 
98  seiDisplayOrientation->cancelFlag = false;
99  seiDisplayOrientation->horFlip = false;
100  seiDisplayOrientation->verFlip = false;
101  seiDisplayOrientation->anticlockwiseRotation = m_pcCfg->getDisplayOrientationSEIAngle();
102 }
103 
105 {
106  assert (m_isInitialized);
107  assert (seiToneMappingInfo!=NULL);
108 
109  seiToneMappingInfo->m_toneMapId = m_pcCfg->getTMISEIToneMapId();
110  seiToneMappingInfo->m_toneMapCancelFlag = m_pcCfg->getTMISEIToneMapCancelFlag();
112 
113  seiToneMappingInfo->m_codedDataBitDepth = m_pcCfg->getTMISEICodedDataBitDepth();
114  assert(seiToneMappingInfo->m_codedDataBitDepth >= 8 && seiToneMappingInfo->m_codedDataBitDepth <= 14);
115  seiToneMappingInfo->m_targetBitDepth = m_pcCfg->getTMISEITargetBitDepth();
116  assert(seiToneMappingInfo->m_targetBitDepth >= 1 && seiToneMappingInfo->m_targetBitDepth <= 17);
117  seiToneMappingInfo->m_modelId = m_pcCfg->getTMISEIModelID();
118  assert(seiToneMappingInfo->m_modelId >=0 &&seiToneMappingInfo->m_modelId<=4);
119 
120  switch( seiToneMappingInfo->m_modelId)
121  {
122  case 0:
123  {
124  seiToneMappingInfo->m_minValue = m_pcCfg->getTMISEIMinValue();
125  seiToneMappingInfo->m_maxValue = m_pcCfg->getTMISEIMaxValue();
126  break;
127  }
128  case 1:
129  {
130  seiToneMappingInfo->m_sigmoidMidpoint = m_pcCfg->getTMISEISigmoidMidpoint();
131  seiToneMappingInfo->m_sigmoidWidth = m_pcCfg->getTMISEISigmoidWidth();
132  break;
133  }
134  case 2:
135  {
136  UInt num = 1u<<(seiToneMappingInfo->m_targetBitDepth);
137  seiToneMappingInfo->m_startOfCodedInterval.resize(num);
139  if(ptmp)
140  {
141  for(Int i=0; i<num;i++)
142  {
143  seiToneMappingInfo->m_startOfCodedInterval[i] = ptmp[i];
144  }
145  }
146  break;
147  }
148  case 3:
149  {
150  seiToneMappingInfo->m_numPivots = m_pcCfg->getTMISEINumPivots();
151  seiToneMappingInfo->m_codedPivotValue.resize(seiToneMappingInfo->m_numPivots);
152  seiToneMappingInfo->m_targetPivotValue.resize(seiToneMappingInfo->m_numPivots);
153  Int* ptmpcoded = m_pcCfg->getTMISEICodedPivotValue();
154  Int* ptmptarget = m_pcCfg->getTMISEITargetPivotValue();
155  if(ptmpcoded&&ptmptarget)
156  {
157  for(Int i=0; i<(seiToneMappingInfo->m_numPivots);i++)
158  {
159  seiToneMappingInfo->m_codedPivotValue[i]=ptmpcoded[i];
160  seiToneMappingInfo->m_targetPivotValue[i]=ptmptarget[i];
161  }
162  }
163  break;
164  }
165  case 4:
166  {
167  seiToneMappingInfo->m_cameraIsoSpeedIdc = m_pcCfg->getTMISEICameraIsoSpeedIdc();
169  assert( seiToneMappingInfo->m_cameraIsoSpeedValue !=0 );
170  seiToneMappingInfo->m_exposureIndexIdc = m_pcCfg->getTMISEIExposurIndexIdc();
172  assert( seiToneMappingInfo->m_exposureIndexValue !=0 );
178  assert( seiToneMappingInfo->m_extendedRangeWhiteLevel >= 100 );
181  assert( seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue > seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue );
183  assert( seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue >= seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue );
184  break;
185  }
186  default:
187  {
188  assert(!"Undefined SEIToneMapModelId");
189  break;
190  }
191  }
192 }
193 
194 Void SEIEncoder::initSEISOPDescription(SEISOPDescription *sopDescriptionSEI, TComSlice *slice, Int picInGOP, Int lastIdr, Int currGOPSize)
195 {
196  assert (m_isInitialized);
197  assert (sopDescriptionSEI != NULL);
198  assert (slice != NULL);
199 
200  Int sopCurrPOC = slice->getPOC();
201  sopDescriptionSEI->m_sopSeqParameterSetId = slice->getSPS()->getSPSId();
202 
203  Int i = 0;
204  Int prevEntryId = picInGOP;
205  for (Int j = picInGOP; j < currGOPSize; j++)
206  {
207  Int deltaPOC = m_pcCfg->getGOPEntry(j).m_POC - m_pcCfg->getGOPEntry(prevEntryId).m_POC;
208  if ((sopCurrPOC + deltaPOC) < m_pcCfg->getFramesToBeEncoded())
209  {
210  sopCurrPOC += deltaPOC;
211  sopDescriptionSEI->m_sopDescVclNaluType[i] = m_pcEncGOP->getNalUnitType(sopCurrPOC, lastIdr, slice->getPic()->isField());
212  sopDescriptionSEI->m_sopDescTemporalId[i] = m_pcCfg->getGOPEntry(j).m_temporalId;
213  sopDescriptionSEI->m_sopDescStRpsIdx[i] = m_pcEncTop->getReferencePictureSetIdxForSOP(sopCurrPOC, j);
214  sopDescriptionSEI->m_sopDescPocDelta[i] = deltaPOC;
215 
216  prevEntryId = j;
217  i++;
218  }
219  }
220 
221  sopDescriptionSEI->m_numPicsInSopMinus1 = i - 1;
222 }
223 
225 {
226  assert (m_isInitialized);
227  assert (bufferingPeriodSEI != NULL);
228  assert (slice != NULL);
229 
230  UInt uiInitialCpbRemovalDelay = (90000/2); // 0.5 sec
231  bufferingPeriodSEI->m_initialCpbRemovalDelay [0][0] = uiInitialCpbRemovalDelay;
232  bufferingPeriodSEI->m_initialCpbRemovalDelayOffset[0][0] = uiInitialCpbRemovalDelay;
233  bufferingPeriodSEI->m_initialCpbRemovalDelay [0][1] = uiInitialCpbRemovalDelay;
234  bufferingPeriodSEI->m_initialCpbRemovalDelayOffset[0][1] = uiInitialCpbRemovalDelay;
235 
237 
238  UInt uiTmp = (UInt)( dTmp * 90000.0 );
239  uiInitialCpbRemovalDelay -= uiTmp;
240  uiInitialCpbRemovalDelay -= uiTmp / ( slice->getSPS()->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2 );
241  bufferingPeriodSEI->m_initialAltCpbRemovalDelay [0][0] = uiInitialCpbRemovalDelay;
242  bufferingPeriodSEI->m_initialAltCpbRemovalDelayOffset[0][0] = uiInitialCpbRemovalDelay;
243  bufferingPeriodSEI->m_initialAltCpbRemovalDelay [0][1] = uiInitialCpbRemovalDelay;
244  bufferingPeriodSEI->m_initialAltCpbRemovalDelayOffset[0][1] = uiInitialCpbRemovalDelay;
245 
246  bufferingPeriodSEI->m_rapCpbParamsPresentFlag = 0;
247  //for the concatenation, it can be set to one during splicing.
248  bufferingPeriodSEI->m_concatenationFlag = 0;
249  //since the temporal layer HRD is not ready, we assumed it is fixed
250  bufferingPeriodSEI->m_auCpbRemovalDelayDelta = 1;
251  bufferingPeriodSEI->m_cpbDelayOffset = 0;
252  bufferingPeriodSEI->m_dpbDelayOffset = 0;
253 }
254 
259 {
260  assert (m_isInitialized);
261  assert (scalableNestingSEI != NULL);
262 
263  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
264  scalableNestingSEI->m_nestingOpFlag = 0;
265  scalableNestingSEI->m_nestingNumOpsMinus1 = 0; //nesting_num_ops_minus1
266  scalableNestingSEI->m_allLayersFlag = 0;
267  scalableNestingSEI->m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1; //nesting_no_op_max_temporal_id_plus1
268  scalableNestingSEI->m_nestingNumLayersMinus1 = 1 - 1; //nesting_num_layers_minus1
269  scalableNestingSEI->m_nestingLayerId[0] = 0;
270 
271  scalableNestingSEI->m_nestedSEIs.clear();
272  for (SEIMessages::iterator it=nestedSEIs.begin(); it!=nestedSEIs.end(); it++)
273  {
274  scalableNestingSEI->m_nestedSEIs.push_back((*it));
275  }
276 }
277 
279 {
280  assert (m_isInitialized);
281  assert (recoveryPointSEI != NULL);
282  assert (slice != NULL);
283 
284  recoveryPointSEI->m_recoveryPocCnt = 0;
285  recoveryPointSEI->m_exactMatchingFlag = ( slice->getPOC() == 0 ) ? (true) : (false);
286  recoveryPointSEI->m_brokenLinkFlag = false;
287 }
288 
290 Void SEIEncoder::initDecodedPictureHashSEI(SEIDecodedPictureHash *decodedPictureHashSEI, TComPic *pcPic, std::string &rHashString, const BitDepths &bitDepths)
291 {
292  assert (m_isInitialized);
293  assert (decodedPictureHashSEI!=NULL);
294  assert (pcPic!=NULL);
295 
296  decodedPictureHashSEI->method = m_pcCfg->getDecodedPictureHashSEIType();
298  {
299  case HASHTYPE_MD5:
300  {
301  UInt numChar=calcMD5(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths);
302  rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar);
303  }
304  break;
305  case HASHTYPE_CRC:
306  {
307  UInt numChar=calcCRC(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths);
308  rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar);
309  }
310  break;
311  case HASHTYPE_CHECKSUM:
312  default:
313  {
314  UInt numChar=calcChecksum(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths);
315  rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar);
316  }
317  break;
318  }
319 }
320 
322 {
323  assert (m_isInitialized);
324  assert (temporalLevel0IndexSEI!=NULL);
325  assert (slice!=NULL);
326 
327  if (slice->getRapPicFlag())
328  {
329  m_tl0Idx = 0;
330  m_rapIdx = (m_rapIdx + 1) & 0xFF;
331  }
332  else
333  {
334  m_tl0Idx = (m_tl0Idx + (slice->getTLayer() ? 0 : 1)) & 0xFF;
335  }
336  temporalLevel0IndexSEI->tl0Idx = m_tl0Idx;
337  temporalLevel0IndexSEI->rapIdx = m_rapIdx;
338 }
339 
341 {
342  assert (m_isInitialized);
343  assert (sei!=NULL);
344  assert (pps!=NULL);
345 
346  if(pps->getTilesEnabledFlag())
347  {
348 #if MCTS_ENC_CHECK
350  {
352  sei->m_each_tile_one_tile_set_flag = true;
353  sei->m_limited_tile_set_display_flag = false;
355  sei->setNumberOfTileSets(0);
356  }
357  else
358  {
359 #endif
361  sei->m_each_tile_one_tile_set_flag = false;
362  sei->m_limited_tile_set_display_flag = false;
363  sei->setNumberOfTileSets((pps->getNumTileColumnsMinus1() + 1) * (pps->getNumTileRowsMinus1() + 1));
364 
365  for(Int i=0; i < sei->getNumberOfTileSets(); i++)
366  {
367  sei->tileSetData(i).m_mcts_id = i; //depends the application;
369 
370  for(Int j=0; j<sei->tileSetData(i).getNumberOfTileRects(); j++)
371  {
372  sei->tileSetData(i).topLeftTileIndex(j) = i+j;
373  sei->tileSetData(i).bottomRightTileIndex(j) = i+j;
374  }
375 
378  }
379 #if MCTS_ENC_CHECK
380  }
381 #endif
382  }
383  else
384  {
385  assert(!"Tile is not enabled");
386  }
387 }
388 
390 {
391  assert (m_isInitialized);
392  assert (seiKneeFunctionInfo!=NULL);
393 
395  seiKneeFunctionInfo->m_kneeId = knee.m_kneeFunctionId;
396  seiKneeFunctionInfo->m_kneeCancelFlag = knee.m_kneeFunctionCancelFlag;
397  if ( !seiKneeFunctionInfo->m_kneeCancelFlag )
398  {
399  seiKneeFunctionInfo->m_kneePersistenceFlag = knee.m_kneeFunctionPersistenceFlag;
400  seiKneeFunctionInfo->m_kneeInputDrange = knee.m_inputDRange;
401  seiKneeFunctionInfo->m_kneeInputDispLuminance = knee.m_inputDispLuminance;
402  seiKneeFunctionInfo->m_kneeOutputDrange = knee.m_outputDRange;
403  seiKneeFunctionInfo->m_kneeOutputDispLuminance = knee.m_outputDispLuminance;
404 
405  assert(knee.m_kneeSEIKneePointPairs.size()>0);
406  seiKneeFunctionInfo->m_kneeNumKneePointsMinus1 = (Int) knee.m_kneeSEIKneePointPairs.size()-1;
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] = knee.m_kneeSEIKneePointPairs[i].inputKneePoint;
412  seiKneeFunctionInfo->m_kneeOutputKneePoint[i] = knee.m_kneeSEIKneePointPairs[i].outputKneePoint;
413  }
414  }
415 }
416 #if CCV_SEI_MESSAGE
418 {
419  assert(m_isInitialized);
420  assert(seiContentColourVolume != NULL);
421  seiContentColourVolume->m_ccvCancelFlag = m_pcCfg->getCcvSEICancelFlag();
422  seiContentColourVolume->m_ccvPersistenceFlag = m_pcCfg->getCcvSEIPersistenceFlag();
423 
428 
429  // Currently we are using a floor operation for setting up the "integer" values for this SEI.
430  // This applies to both primaries and luminance limits.
431  if (seiContentColourVolume->m_ccvPrimariesPresentFlag == true)
432  {
433  for (Int i = 0; i < MAX_NUM_COMPONENT; i++)
434  {
435  seiContentColourVolume->m_ccvPrimariesX[i] = (Int) (50000.0 * m_pcCfg->getCcvSEIPrimariesX(i));
436  seiContentColourVolume->m_ccvPrimariesY[i] = (Int) (50000.0 * m_pcCfg->getCcvSEIPrimariesY(i));
437  }
438  }
439 
440  if (seiContentColourVolume->m_ccvMinLuminanceValuePresentFlag == true)
441  {
442  seiContentColourVolume->m_ccvMinLuminanceValue = (Int) (10000000 * m_pcCfg->getCcvSEIMinLuminanceValue());
443  }
444  if (seiContentColourVolume->m_ccvMaxLuminanceValuePresentFlag == true)
445  {
446  seiContentColourVolume->m_ccvMaxLuminanceValue = (Int) (10000000 * m_pcCfg->getCcvSEIMaxLuminanceValue());
447  }
448  if (seiContentColourVolume->m_ccvAvgLuminanceValuePresentFlag == true)
449  {
450  seiContentColourVolume->m_ccvAvgLuminanceValue = (Int) (10000000 * m_pcCfg->getCcvSEIAvgLuminanceValue());
451  }
452 }
453 #endif
454 
455 #if ERP_SR_OV_SEI_MESSAGE
457 {
458  assert (m_isInitialized);
459  assert (seiEquirectangularProjection!=NULL);
460 
461  seiEquirectangularProjection->m_erpCancelFlag = m_pcCfg->getErpSEICancelFlag();
462  if (!seiEquirectangularProjection->m_erpCancelFlag)
463  {
464  seiEquirectangularProjection->m_erpPersistenceFlag = m_pcCfg->getErpSEIPersistenceFlag();
465  seiEquirectangularProjection->m_erpGuardBandFlag = m_pcCfg->getErpSEIGuardBandFlag();
466  if (seiEquirectangularProjection->m_erpGuardBandFlag == 1)
467  {
468  seiEquirectangularProjection->m_erpGuardBandType = m_pcCfg->getErpSEIGuardBandType();
469  seiEquirectangularProjection->m_erpLeftGuardBandWidth = m_pcCfg->getErpSEILeftGuardBandWidth();
470  seiEquirectangularProjection->m_erpRightGuardBandWidth = m_pcCfg->getErpSEIRightGuardBandWidth();
471  }
472  }
473 }
474 
476 {
477  assert (m_isInitialized);
478  assert (seiSphereRotation!=NULL);
479 
481  if ( !seiSphereRotation->m_sphereRotationCancelFlag )
482  {
484  seiSphereRotation->m_sphereRotationYaw = m_pcCfg->getSphereRotationSEIYaw();
486  seiSphereRotation->m_sphereRotationRoll = m_pcCfg->getSphereRotationSEIRoll();
487  }
488 }
489 
491 {
492  assert (m_isInitialized);
493  assert (seiOmniViewport!=NULL);
494 
495  seiOmniViewport->m_omniViewportId = m_pcCfg->getOmniViewportSEIId();
497  if ( !seiOmniViewport->m_omniViewportCancelFlag )
498  {
501 
502  seiOmniViewport->m_omniViewportRegions.resize(seiOmniViewport->m_omniViewportCntMinus1+1);
503  for (UInt i = 0; i <= seiOmniViewport->m_omniViewportCntMinus1; i++)
504  {
505  SEIOmniViewport::OmniViewport &viewport = seiOmniViewport->m_omniViewportRegions[i];
511  }
512  }
513 }
514 #endif
515 
516 #if CMP_SEI_MESSAGE
518 {
519  assert(m_isInitialized);
520  assert(seiCubemapProjection != NULL);
521  seiCubemapProjection->m_cmpCancelFlag = m_pcCfg->getCmpSEICmpCancelFlag();
522  seiCubemapProjection->m_cmpPersistenceFlag = m_pcCfg->getCmpSEICmpPersistenceFlag();
523 }
524 #endif
525 
526 #if RWP_SEI_MESSAGE
528 {
529  assert (m_isInitialized);
530  assert (seiRegionWisePacking!=NULL);
531  seiRegionWisePacking->m_rwpCancelFlag = m_pcCfg->getRwpSEIRwpCancelFlag();
532  seiRegionWisePacking->m_rwpPersistenceFlag = m_pcCfg->getRwpSEIRwpPersistenceFlag();
534  seiRegionWisePacking->m_numPackedRegions = m_pcCfg->getRwpSEINumPackedRegions();
535  seiRegionWisePacking->m_projPictureWidth = m_pcCfg->getRwpSEIProjPictureWidth();
536  seiRegionWisePacking->m_projPictureHeight = m_pcCfg->getRwpSEIProjPictureHeight();
537  seiRegionWisePacking->m_packedPictureWidth = m_pcCfg->getRwpSEIPackedPictureWidth();
539  seiRegionWisePacking->m_rwpTransformType.resize(seiRegionWisePacking->m_numPackedRegions);
540  seiRegionWisePacking->m_rwpGuardBandFlag.resize(seiRegionWisePacking->m_numPackedRegions);
541  seiRegionWisePacking->m_projRegionWidth.resize(seiRegionWisePacking->m_numPackedRegions);
542  seiRegionWisePacking->m_projRegionHeight.resize(seiRegionWisePacking->m_numPackedRegions);
543  seiRegionWisePacking->m_rwpProjRegionTop.resize(seiRegionWisePacking->m_numPackedRegions);
544  seiRegionWisePacking->m_projRegionLeft.resize(seiRegionWisePacking->m_numPackedRegions);
545  seiRegionWisePacking->m_packedRegionWidth.resize(seiRegionWisePacking->m_numPackedRegions);
546  seiRegionWisePacking->m_packedRegionHeight.resize(seiRegionWisePacking->m_numPackedRegions);
547  seiRegionWisePacking->m_packedRegionTop.resize(seiRegionWisePacking->m_numPackedRegions);
548  seiRegionWisePacking->m_packedRegionLeft.resize(seiRegionWisePacking->m_numPackedRegions);
549  seiRegionWisePacking->m_rwpLeftGuardBandWidth.resize(seiRegionWisePacking->m_numPackedRegions);
550  seiRegionWisePacking->m_rwpRightGuardBandWidth.resize(seiRegionWisePacking->m_numPackedRegions);
551  seiRegionWisePacking->m_rwpTopGuardBandHeight.resize(seiRegionWisePacking->m_numPackedRegions);
552  seiRegionWisePacking->m_rwpBottomGuardBandHeight.resize(seiRegionWisePacking->m_numPackedRegions);
553  seiRegionWisePacking->m_rwpGuardBandNotUsedForPredFlag.resize(seiRegionWisePacking->m_numPackedRegions);
554  seiRegionWisePacking->m_rwpGuardBandType.resize(4*seiRegionWisePacking->m_numPackedRegions);
555  for( Int i=0; i < seiRegionWisePacking->m_numPackedRegions; i++ )
556  {
557  seiRegionWisePacking->m_rwpTransformType[i] = m_pcCfg->getRwpSEIRwpTransformType(i);
558  seiRegionWisePacking->m_rwpGuardBandFlag[i] = m_pcCfg->getRwpSEIRwpGuardBandFlag(i);
559  seiRegionWisePacking->m_projRegionWidth[i] = m_pcCfg->getRwpSEIProjRegionWidth(i);
560  seiRegionWisePacking->m_projRegionHeight[i] = m_pcCfg->getRwpSEIProjRegionHeight(i);
561  seiRegionWisePacking->m_rwpProjRegionTop[i] = m_pcCfg->getRwpSEIRwpSEIProjRegionTop(i);
562  seiRegionWisePacking->m_projRegionLeft[i] = m_pcCfg->getRwpSEIProjRegionLeft(i);
563  seiRegionWisePacking->m_packedRegionWidth[i] = m_pcCfg->getRwpSEIPackedRegionWidth(i);
564  seiRegionWisePacking->m_packedRegionHeight[i] = m_pcCfg->getRwpSEIPackedRegionHeight(i);
565  seiRegionWisePacking->m_packedRegionTop[i] = m_pcCfg->getRwpSEIPackedRegionTop(i);
566  seiRegionWisePacking->m_packedRegionLeft[i] = m_pcCfg->getRwpSEIPackedRegionLeft(i);
567  if( seiRegionWisePacking->m_rwpGuardBandFlag[i] )
568  {
569  seiRegionWisePacking->m_rwpLeftGuardBandWidth[i] = m_pcCfg->getRwpSEIRwpLeftGuardBandWidth(i);
571  seiRegionWisePacking->m_rwpTopGuardBandHeight[i] = m_pcCfg->getRwpSEIRwpTopGuardBandHeight(i);
574  for( Int j=0; j < 4; j++ )
575  {
576  seiRegionWisePacking->m_rwpGuardBandType[i*4 + j] = m_pcCfg->getRwpSEIRwpGuardBandType(i*4 + j);
577  }
578  }
579  }
580 }
581 #endif
582 
583 template <typename T>
584 static Void readTokenValue(T &returnedValue,
585  Bool &failed,
586  std::istream &is,
587  const TChar *pToken)
588 {
589  returnedValue=T();
590  if (failed)
591  {
592  return;
593  }
594 
595  Int c;
596  // Ignore any whitespace
597  while ((c=is.get())!=EOF && isspace(c));
598  // test for comment mark
599  while (c=='#')
600  {
601  // Ignore to the end of the line
602  while ((c=is.get())!=EOF && (c!=10 && c!=13));
603  // Ignore any white space at the start of the next line
604  while ((c=is.get())!=EOF && isspace(c));
605  }
606  // test first character of token
607  failed=(c!=pToken[0]);
608  // test remaining characters of token
609  Int pos;
610  for(pos=1;!failed && pToken[pos]!=0 && is.get()==pToken[pos]; pos++);
611  failed|=(pToken[pos]!=0);
612  // Ignore any whitespace before the ':'
613  while (!failed && (c=is.get())!=EOF && isspace(c));
614  failed|=(c!=':');
615  // Now read the value associated with the token:
616  if (!failed)
617  {
618  is >> returnedValue;
619  failed=!is.good();
620  if (!failed)
621  {
622  c=is.get();
623  failed=(c!=EOF && !isspace(c));
624  }
625  }
626  if (failed)
627  {
628  std::cerr << "Unable to read token '" << pToken << "'\n";
629  }
630 }
631 
632 template <typename T>
633 static Void readTokenValueAndValidate(T &returnedValue,
634  Bool &failed,
635  std::istream &is,
636  const TChar *pToken,
637  const T &minInclusive,
638  const T &maxInclusive)
639 {
640  readTokenValue(returnedValue, failed, is, pToken);
641  if (!failed)
642  {
643  if (returnedValue<minInclusive || returnedValue>maxInclusive)
644  {
645  failed=true;
646  std::cerr << "Value for token " << pToken << " must be in the range " << minInclusive << " to " << maxInclusive << " (inclusive); value read: " << returnedValue << std::endl;
647  }
648  }
649 }
650 
651 // Bool version does not have maximum and minimum values.
652 static Void readTokenValueAndValidate(Bool &returnedValue,
653  Bool &failed,
654  std::istream &is,
655  const TChar *pToken)
656 {
657  readTokenValue(returnedValue, failed, is, pToken);
658 }
659 
660 #if RNSEI
661 template <typename T>
662 static Void readTokenValue(std::vector<T> &returnedValue,
663  Bool &failed,
664  std::istream &is,
665  const TChar *pToken,
666  const UInt &numValues)
667 {
668  returnedValue=std::vector<T>();
669  if (failed)
670  {
671  return;
672  }
673 
674  Int c;
675  // Ignore any whitespace
676  while ((c=is.get())!=EOF && isspace(c));
677  // test for comment mark
678  while (c=='#')
679  {
680  // Ignore to the end of the line
681  while ((c=is.get())!=EOF && (c!=10 && c!=13));
682  // Ignore any white space at the start of the next line
683  while ((c=is.get())!=EOF && isspace(c));
684  }
685  // test first character of token
686  failed=(c!=pToken[0]);
687  // test remaining characters of token
688  Int pos;
689  for(pos=1;!failed && pToken[pos]!=0 && is.get()==pToken[pos]; pos++);
690  failed|=(pToken[pos]!=0);
691  // Ignore any whitespace before the ':'
692  while (!failed && (c=is.get())!=EOF && isspace(c));
693  failed|=(c!=':');
694  // Now read the value associated with the token:
695  for(UInt i = 0; i < numValues; i++)
696  {
697  if (!failed)
698  {
699  is >> returnedValue[i];
700  failed=!is.good();
701  if (!failed)
702  {
703  c=is.get();
704  failed=(c!=EOF && !isspace(c));
705  }
706  }
707  if (failed)
708  {
709  std::cerr << "Unable to read token '" << pToken << "[" << i << "]'\n";
710  }
711  }
712 }
713 // Version to read an array
714 template <typename T>
715 static Void readTokenValueAndValidate(std::vector<T> &returnedValue,
716  Bool &failed,
717  std::istream &is,
718  const TChar *pToken,
719  const T &minInclusive,
720  const T &maxInclusive,
721  const UInt &numValues)
722 {
723  readTokenValue<Int>(returnedValue, failed, is, pToken, numValues);
724  if (!failed)
725  {
726  for(UInt i = 0; i < numValues; i++)
727  {
728  if (returnedValue[i]<minInclusive || returnedValue[i]>maxInclusive)
729  {
730  failed=true;
731  std::cerr << "Value for token " << pToken << "[" << i << "] must be in the range " << minInclusive << " to " << maxInclusive << " (inclusive); value read: " << returnedValue[i] << std::endl;
732  }
733  }
734  }
735 }
736 #endif
737 
738 Bool SEIEncoder::initSEIColourRemappingInfo(SEIColourRemappingInfo* seiColourRemappingInfo, Int currPOC) // returns true on success, false on failure.
739 {
740  assert (m_isInitialized);
741  assert (seiColourRemappingInfo!=NULL);
742 
743  // reading external Colour Remapping Information SEI message parameters from file
744  if( !m_pcCfg->getColourRemapInfoSEIFileRoot().empty())
745  {
746  Bool failed=false;
747 
748  // building the CRI file name with poc num in prefix "_poc.txt"
749  std::string colourRemapSEIFileWithPoc(m_pcCfg->getColourRemapInfoSEIFileRoot());
750  {
751  std::stringstream suffix;
752  suffix << "_" << currPOC << ".txt";
753  colourRemapSEIFileWithPoc+=suffix.str();
754  }
755 
756  std::ifstream fic(colourRemapSEIFileWithPoc.c_str());
757  if (!fic.good() || !fic.is_open())
758  {
759  std::cerr << "No Colour Remapping Information SEI parameters file " << colourRemapSEIFileWithPoc << " for POC " << currPOC << std::endl;
760  return false;
761  }
762 
763  // TODO: identify and remove duplication with decoder parsing through abstraction.
764 #if RNSEI
765  readColourRemapSEI(fic, seiColourRemappingInfo, failed );
766 #else
767  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapId, failed, fic, "colour_remap_id", UInt(0), UInt(0x7fffffff) );
768  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapCancelFlag, failed, fic, "colour_remap_cancel_flag" );
769  if( !seiColourRemappingInfo->m_colourRemapCancelFlag )
770  {
771  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapPersistenceFlag, failed, fic, "colour_remap_persistence_flag" );
772  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag, failed, fic, "colour_remap_video_signal_info_present_flag");
773  if( seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag )
774  {
775  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapFullRangeFlag, failed, fic, "colour_remap_full_range_flag" );
776  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapPrimaries, failed, fic, "colour_remap_primaries", Int(0), Int(255) );
777  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapTransferFunction, failed, fic, "colour_remap_transfer_function", Int(0), Int(255) );
778  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapMatrixCoefficients, failed, fic, "colour_remap_matrix_coefficients", Int(0), Int(255) );
779  }
780  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapInputBitDepth, failed, fic, "colour_remap_input_bit_depth", Int(8), Int(16) );
781  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapBitDepth, failed, fic, "colour_remap_bit_depth", Int(8), Int(16) );
782 
783  const Int maximumInputValue = (1 << (((seiColourRemappingInfo->m_colourRemapInputBitDepth + 7) >> 3) << 3)) - 1;
784  const Int maximumRemappedValue = (1 << (((seiColourRemappingInfo->m_colourRemapBitDepth + 7) >> 3) << 3)) - 1;
785 
786  for( Int c=0 ; c<3 ; c++ )
787  {
788  readTokenValueAndValidate(seiColourRemappingInfo->m_preLutNumValMinus1[c], failed, fic, "pre_lut_num_val_minus1[c]", Int(0), Int(32) );
789  if( seiColourRemappingInfo->m_preLutNumValMinus1[c]>0 )
790  {
791  seiColourRemappingInfo->m_preLut[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1);
792  for( Int i=0 ; i<=seiColourRemappingInfo->m_preLutNumValMinus1[c] ; i++ )
793  {
794  readTokenValueAndValidate(seiColourRemappingInfo->m_preLut[c][i].codedValue, failed, fic, "pre_lut_coded_value[c][i]", Int(0), maximumInputValue );
795  readTokenValueAndValidate(seiColourRemappingInfo->m_preLut[c][i].targetValue, failed, fic, "pre_lut_target_value[c][i]", Int(0), maximumRemappedValue );
796  }
797  }
798  }
799  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapMatrixPresentFlag, failed, fic, "colour_remap_matrix_present_flag" );
800  if( seiColourRemappingInfo->m_colourRemapMatrixPresentFlag )
801  {
802  readTokenValueAndValidate(seiColourRemappingInfo->m_log2MatrixDenom, failed, fic, "log2_matrix_denom", Int(0), Int(15) );
803  for( Int c=0 ; c<3 ; c++ )
804  {
805  for( Int i=0 ; i<3 ; i++ )
806  {
807  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapCoeffs[c][i], failed, fic, "colour_remap_coeffs[c][i]", -32768, 32767 );
808  }
809  }
810  }
811  for( Int c=0 ; c<3 ; c++ )
812  {
813  readTokenValueAndValidate(seiColourRemappingInfo->m_postLutNumValMinus1[c], failed, fic, "post_lut_num_val_minus1[c]", Int(0), Int(32) );
814  if( seiColourRemappingInfo->m_postLutNumValMinus1[c]>0 )
815  {
816  seiColourRemappingInfo->m_postLut[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1);
817  for( Int i=0 ; i<=seiColourRemappingInfo->m_postLutNumValMinus1[c] ; i++ )
818  {
819  readTokenValueAndValidate(seiColourRemappingInfo->m_postLut[c][i].codedValue, failed, fic, "post_lut_coded_value[c][i]", Int(0), maximumRemappedValue );
820  readTokenValueAndValidate(seiColourRemappingInfo->m_postLut[c][i].targetValue, failed, fic, "post_lut_target_value[c][i]", Int(0), maximumRemappedValue );
821  }
822  }
823  }
824  }
825 #endif
826 
827  if( failed )
828  {
829  std::cerr << "Error while reading Colour Remapping Information SEI parameters file '" << colourRemapSEIFileWithPoc << "'" << std::endl;
830  exit(EXIT_FAILURE);
831  }
832  }
833  return true;
834 }
835 
836 #if RNSEI
837 Void SEIEncoder::readRNSEIWindow(std::istream &fic, RNSEIWindowVec::iterator regionIter, Bool &failed )
838 {
839  Int regionId;
840  Int offLeft, offRight, offTop, offBottom;
841  fic >> regionId >> offLeft >> offRight >> offTop >> offBottom;
842  (*regionIter).setRegionId(regionId);
843  (*regionIter).setWindow(offLeft, offRight, offTop, offBottom);
844 }
845 Void SEIEncoder::readColourRemapSEI(std::istream &fic, SEIColourRemappingInfo *seiColourRemappingInfo, Bool &failed )
846 {
847  readTokenValueAndValidate<UInt>(seiColourRemappingInfo->m_colourRemapId, failed, fic, "colour_remap_id", UInt(0), UInt(0x7fffffff) );
848  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapCancelFlag, failed, fic, "colour_remap_cancel_flag" );
849  if( !seiColourRemappingInfo->m_colourRemapCancelFlag )
850  {
851  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapPersistenceFlag, failed, fic, "colour_remap_persistence_flag" );
852  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag, failed, fic, "colour_remap_video_signal_info_present_flag");
853  if( seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag )
854  {
855  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapFullRangeFlag, failed, fic, "colour_remap_full_range_flag" );
856  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapPrimaries, failed, fic, "colour_remap_primaries", Int(0), Int(255) );
857  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapTransferFunction, failed, fic, "colour_remap_transfer_function", Int(0), Int(255) );
858  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapMatrixCoefficients, failed, fic, "colour_remap_matrix_coefficients", Int(0), Int(255) );
859  }
860  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapInputBitDepth, failed, fic, "colour_remap_input_bit_depth", Int(8), Int(16) );
861  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapBitDepth, failed, fic, "colour_remap_bit_depth", Int(8), Int(16) );
862 
863  const Int maximumInputValue = (1 << (((seiColourRemappingInfo->m_colourRemapInputBitDepth + 7) >> 3) << 3)) - 1;
864  const Int maximumRemappedValue = (1 << (((seiColourRemappingInfo->m_colourRemapBitDepth + 7) >> 3) << 3)) - 1;
865 
866  for( Int c=0 ; c<3 ; c++ )
867  {
868  readTokenValueAndValidate(seiColourRemappingInfo->m_preLutNumValMinus1[c], failed, fic, "pre_lut_num_val_minus1[c]", Int(0), Int(32) );
869  if( seiColourRemappingInfo->m_preLutNumValMinus1[c]>0 )
870  {
871  seiColourRemappingInfo->m_preLut[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1);
872  for( Int i=0 ; i<=seiColourRemappingInfo->m_preLutNumValMinus1[c] ; i++ )
873  {
874  readTokenValueAndValidate(seiColourRemappingInfo->m_preLut[c][i].codedValue, failed, fic, "pre_lut_coded_value[c][i]", Int(0), maximumInputValue );
875  readTokenValueAndValidate(seiColourRemappingInfo->m_preLut[c][i].targetValue, failed, fic, "pre_lut_target_value[c][i]", Int(0), maximumRemappedValue );
876  }
877  }
878  }
879  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapMatrixPresentFlag, failed, fic, "colour_remap_matrix_present_flag" );
880  if( seiColourRemappingInfo->m_colourRemapMatrixPresentFlag )
881  {
882  readTokenValueAndValidate(seiColourRemappingInfo->m_log2MatrixDenom, failed, fic, "log2_matrix_denom", Int(0), Int(15) );
883  for( Int c=0 ; c<3 ; c++ )
884  {
885  for( Int i=0 ; i<3 ; i++ )
886  {
887  readTokenValueAndValidate(seiColourRemappingInfo->m_colourRemapCoeffs[c][i], failed, fic, "colour_remap_coeffs[c][i]", -32768, 32767 );
888  }
889  }
890  }
891  for( Int c=0 ; c<3 ; c++ )
892  {
893  readTokenValueAndValidate(seiColourRemappingInfo->m_postLutNumValMinus1[c], failed, fic, "post_lut_num_val_minus1[c]", Int(0), Int(32) );
894  if( seiColourRemappingInfo->m_postLutNumValMinus1[c]>0 )
895  {
896  seiColourRemappingInfo->m_postLut[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1);
897  for( Int i=0 ; i<=seiColourRemappingInfo->m_postLutNumValMinus1[c] ; i++ )
898  {
899  readTokenValueAndValidate(seiColourRemappingInfo->m_postLut[c][i].codedValue, failed, fic, "post_lut_coded_value[c][i]", Int(0), maximumRemappedValue );
900  readTokenValueAndValidate(seiColourRemappingInfo->m_postLut[c][i].targetValue, failed, fic, "post_lut_target_value[c][i]", Int(0), maximumRemappedValue );
901  }
902  }
903  }
904  }
905 }
906 Void SEIEncoder::readToneMappingInfoSEI(std::istream &fic, SEIToneMappingInfo *seiToneMappingInfo , Bool &failed )
907 {
908  readTokenValueAndValidate(seiToneMappingInfo->m_toneMapId, failed, fic, "SEIToneMapId", Int(0), Int(255) );
909  readTokenValueAndValidate(seiToneMappingInfo->m_toneMapCancelFlag, failed, fic, "SEIToneMapCancelFlag");
910  readTokenValueAndValidate(seiToneMappingInfo->m_toneMapPersistenceFlag, failed, fic, "SEIToneMapPersistenceFlag");
911  readTokenValueAndValidate(seiToneMappingInfo->m_codedDataBitDepth, failed, fic, "SEIToneMapCodedDataBitDepth", Int(8), Int(14) );
912  readTokenValueAndValidate(seiToneMappingInfo->m_targetBitDepth, failed, fic, "SEIToneMapTargetBitDepth", Int(8), Int(14) );
913  readTokenValueAndValidate(seiToneMappingInfo->m_modelId, failed, fic, "SEIToneMapModelId", Int(0), Int(4) );
914  readTokenValueAndValidate(seiToneMappingInfo->m_minValue, failed, fic, "SEIToneMapMinValue", Int(0), Int((1<<14)-1) );
915  readTokenValueAndValidate(seiToneMappingInfo->m_maxValue, failed, fic, "SEIToneMapMaxValue", Int(0), Int((1<<14)-1) );
916  readTokenValueAndValidate(seiToneMappingInfo->m_sigmoidMidpoint, failed, fic, "SEIToneMapSigmoidMidpoint", Int(0), Int((1<<14)-1) );
917  readTokenValueAndValidate(seiToneMappingInfo->m_sigmoidWidth, failed, fic, "SEIToneMapSigmoidWidth", Int(0), Int((1<<14)-1) );
918  readTokenValueAndValidate<Int>(seiToneMappingInfo->m_startOfCodedInterval, failed, fic, "SEIToneMapStartOfCodedInterval", Int(0), Int((1<<16)-1), UInt(1<<seiToneMappingInfo->m_targetBitDepth) );
919  readTokenValueAndValidate(seiToneMappingInfo->m_numPivots, failed, fic, "SEIToneMapNumPivots", Int(0), Int((1<<16)-1) );
920  readTokenValueAndValidate(seiToneMappingInfo->m_codedPivotValue, failed, fic, "SEIToneMapCodedPivotValue", Int(0), Int((1<<16)-1), seiToneMappingInfo->m_numPivots );
921  readTokenValueAndValidate(seiToneMappingInfo->m_targetPivotValue, failed, fic, "SEIToneMapTargetPivotValue", Int(0), Int((1<<16)-1), seiToneMappingInfo->m_numPivots );
922  readTokenValueAndValidate(seiToneMappingInfo->m_cameraIsoSpeedIdc, failed, fic, "SEIToneMapCameraIsoSpeedIdc", Int(0), Int(255) );
923  readTokenValueAndValidate(seiToneMappingInfo->m_cameraIsoSpeedValue, failed, fic, "SEIToneMapCameraIsoSpeedValue", Int(0), Int((~0)-1) );
924  readTokenValueAndValidate(seiToneMappingInfo->m_exposureIndexIdc, failed, fic, "SEIToneMapExposureIndexIdc", Int(0), Int(255) );
925  readTokenValueAndValidate(seiToneMappingInfo->m_exposureIndexValue, failed, fic, "SEIToneMapExposureIndexValue", Int(0), Int((~0)-1) );
926  readTokenValueAndValidate(seiToneMappingInfo->m_exposureCompensationValueSignFlag, failed, fic, "SEIToneMapExposureCompensationValueSignFlag");
927  readTokenValueAndValidate(seiToneMappingInfo->m_exposureCompensationValueNumerator, failed, fic, "SEIToneMapExposureCompensationValueNumerator", Int(0), Int((1<<16)-1) );
928  readTokenValueAndValidate(seiToneMappingInfo->m_exposureCompensationValueDenomIdc, failed, fic, "SEIToneMapExposureCompensationValueDenomIdc", Int(0), Int((1<<16)-1) );
929  readTokenValueAndValidate(seiToneMappingInfo->m_refScreenLuminanceWhite, failed, fic, "SEIToneMapRefScreenLuminanceWhite", Int(0), Int(10000) );
930  readTokenValueAndValidate(seiToneMappingInfo->m_extendedRangeWhiteLevel, failed, fic, "SEIToneMapExtendedRangeWhiteLevel", Int(100), Int(10000) );
931  readTokenValueAndValidate(seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue, failed, fic, "SEIToneMapNominalBlackLevelLumaCodeValue", Int(0), Int((1<<16)-1) );
932  readTokenValueAndValidate(seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue, failed, fic, "SEIToneMapNominalWhiteLevelLumaCodeValue", Int(0), Int((1<<16)-1) );
933  readTokenValueAndValidate(seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue, failed, fic, "SEIToneMapExtendedWhiteLevelLumaCodeValue", Int(0), Int((1<<16)-1) );
934 }
935 Void SEIEncoder::readChromaResamplingFilterHintSEI(std::istream &fic, SEIChromaResamplingFilterHint *seiChromaResamplingFilterHint, Bool &failed )
936 {
937  Int horFilType, verFilType;
938  readTokenValueAndValidate(horFilType, failed, fic, "SEIChromaResamplingHorizontalFilterType", Int(0), Int(2) );
939  readTokenValueAndValidate(verFilType, failed, fic, "SEIChromaResamplingVerticalFilterType", Int(0), Int(2) );
940  if(horFilType == 1 || verFilType == 1)
941  {
942  cout << "Encoder support needed for scanning additional syntax elements of chroma resampling filter hint SEI message.\n";
943  cout << "Addn. code needed in readChromaResamplingFilterHintSEI() and initSEIChromaResamplingFilterHint().\n";
944  exit(1);
945  }
946  initSEIChromaResamplingFilterHint(seiChromaResamplingFilterHint, horFilType, verFilType);
947 }
948 Void SEIEncoder::readKneeFunctionInfoSEI(std::istream &fic, SEIKneeFunctionInfo *seiKneeFunctionInfo, Bool &failed )
949 {
950  readTokenValueAndValidate(seiKneeFunctionInfo->m_kneeId, failed, fic, "SEIKneeFunctionId", Int(0), Int(255));
951  readTokenValueAndValidate(seiKneeFunctionInfo->m_kneeCancelFlag, failed, fic, "SEIKneeFunctionCancelFlag" );
952  readTokenValueAndValidate(seiKneeFunctionInfo->m_kneePersistenceFlag, failed, fic, "SEIKneeFunctionPersistenceFlag" );
953  readTokenValueAndValidate(seiKneeFunctionInfo->m_kneeInputDrange, failed, fic, "SEIKneeFunctionInputDrange", Int(0), Int(1000) );
954  readTokenValueAndValidate(seiKneeFunctionInfo->m_kneeInputDispLuminance, failed, fic, "SEIKneeFunctionInputDispLuminance", Int(0), Int(10000) );
955  readTokenValueAndValidate(seiKneeFunctionInfo->m_kneeOutputDrange, failed, fic, "SEIKneeFunctionOutputDrange", Int(0), Int(1000) );
956  readTokenValueAndValidate(seiKneeFunctionInfo->m_kneeOutputDispLuminance, failed, fic, "SEIKneeFunctionOutputDispLuminance",Int(0), Int(10000) );
957  readTokenValueAndValidate(seiKneeFunctionInfo->m_kneeNumKneePointsMinus1, failed, fic, "SEIKneeFunctionNumKneePointsMinus1",Int(0), Int(998) );
958  readTokenValueAndValidate(seiKneeFunctionInfo->m_kneeInputKneePoint, failed, fic, "SEIKneeFunctionInputKneePointValue",Int(0), Int(1000), seiKneeFunctionInfo->m_kneeNumKneePointsMinus1+1 );
959  readTokenValueAndValidate(seiKneeFunctionInfo->m_kneeOutputKneePoint, failed, fic, "SEIKneeFunctionInputKneePointValue",Int(0), Int(1000), seiKneeFunctionInfo->m_kneeNumKneePointsMinus1+1 );
960 
961 }
962 Void SEIEncoder::readContentColourVolumeSEI(std::istream &fic, SEIContentColourVolume *seiContentColourVolume, Bool &failed )
963 {
964  Double dCode, primaries[2][MAX_NUM_COMPONENT];
965  readTokenValueAndValidate(seiContentColourVolume->m_ccvCancelFlag, failed, fic, "SEICCVCancelFlag" );
966  readTokenValueAndValidate(seiContentColourVolume->m_ccvPersistenceFlag, failed, fic, "SEICCVPersistenceFlag" );
967  readTokenValueAndValidate(seiContentColourVolume->m_ccvPrimariesPresentFlag, failed, fic, "SEICCVPrimariesPresent" );
968  readTokenValueAndValidate(primaries[0][0], failed, fic, "m_ccvSEIPrimariesX0", Double(-100), Double(100));
969  readTokenValueAndValidate(primaries[1][1], failed, fic, "m_ccvSEIPrimariesY0", Double(-100), Double(100));
970  readTokenValueAndValidate(primaries[0][2], failed, fic, "m_ccvSEIPrimariesX1", Double(-100), Double(100));
971  readTokenValueAndValidate(primaries[1][0], failed, fic, "m_ccvSEIPrimariesY1", Double(-100), Double(100));
972  readTokenValueAndValidate(primaries[0][1], failed, fic, "m_ccvSEIPrimariesX2", Double(-100), Double(100));
973  readTokenValueAndValidate(primaries[1][2], failed, fic, "m_ccvSEIPrimariesY2", Double(-100), Double(100));
974  if(seiContentColourVolume->m_ccvPrimariesPresentFlag)
975  {
976  for (Int i = 0; i < MAX_NUM_COMPONENT; i++)
977  {
978  seiContentColourVolume->m_ccvPrimariesX[i] = (Int) (50000.0 * primaries[0][i]);
979  seiContentColourVolume->m_ccvPrimariesY[i] = (Int) (50000.0 * primaries[1][i]);
980  }
981  }
982  readTokenValueAndValidate(seiContentColourVolume->m_ccvMinLuminanceValuePresentFlag, failed, fic, "SEICCVMinLuminanceValuePresent" );
983  readTokenValueAndValidate(dCode, failed, fic, "SEICCVMinLuminanceValue", Double(0), Double(429.4967295));
984  if(seiContentColourVolume->m_ccvMinLuminanceValuePresentFlag)
985  {
986  seiContentColourVolume->m_ccvMinLuminanceValue = (Int) (10000000 * dCode);
987  }
988  readTokenValueAndValidate(seiContentColourVolume->m_ccvMaxLuminanceValuePresentFlag, failed, fic, "SEICCVMaxLuminanceValuePresent" );
989  readTokenValueAndValidate(dCode, failed, fic, "SEICCVMaxLuminanceValue", Double(0), Double(429.4967295));
990  if(seiContentColourVolume->m_ccvMaxLuminanceValuePresentFlag)
991  {
992  seiContentColourVolume->m_ccvMaxLuminanceValue = (Int) (10000000 * dCode);
993  }
994  readTokenValueAndValidate(seiContentColourVolume->m_ccvAvgLuminanceValuePresentFlag, failed, fic, "SEICCVAvgLuminanceValuePresent" );
995  readTokenValueAndValidate(dCode, failed, fic, "SEICCVAvgLuminanceValue", Double(0), Double(429.4967295));
996  if(seiContentColourVolume->m_ccvAvgLuminanceValuePresentFlag)
997  {
998  seiContentColourVolume->m_ccvAvgLuminanceValue = (Int) (10000000 * dCode);
999  }
1000 }
1001 Bool SEIEncoder::initSEIRegionalNesting(SEIRegionalNesting* seiRegionalNesting, Int currPOC) // returns true on success, false on failure.
1002 {
1003  assert (m_isInitialized);
1004  assert (seiRegionalNesting!=NULL);
1005  Int numRegions;
1006  RNSEIWindowVec regions;
1007 
1008  // reading external regional nesting SEI message parameters from file
1009  if( !m_pcCfg->getRegionalNestingSEIFileRoot().empty())
1010  {
1011  Bool failed=false;
1012 
1013  // building the regional nesting file name with poc num in prefix "_poc.txt"
1014  std::string regionalNestingSEIFileWithPoc(m_pcCfg->getRegionalNestingSEIFileRoot());
1015  {
1016  std::stringstream suffix;
1017  suffix << "_" << currPOC << ".txt";
1018  regionalNestingSEIFileWithPoc+=suffix.str();
1019  }
1020 
1021  std::ifstream fic(regionalNestingSEIFileWithPoc.c_str());
1022  if (!fic.good() || !fic.is_open())
1023  {
1024  std::cerr << "No Regional Nesting Information SEI parameters file " << regionalNestingSEIFileWithPoc << " for POC " << currPOC << std::endl;
1025  return false;
1026  }
1027 
1028  Int payloadType, numSEIs;
1029  readTokenValueAndValidate( numSEIs, failed, fic, "num_seis", 0, 255 );
1030  // Loop through each region - ID - SEI
1031  for(Int i = 0; i < numSEIs; i++)
1032  {
1033  RegionalSEI *regSEI = NULL;
1034  // Parse num region
1035  readTokenValueAndValidate( numRegions, failed, fic, "num_regions", 0, 255 );
1036  regions.resize(numRegions);
1037  RNSEIWindowVec::iterator regionIter;
1038  for(regionIter = regions.begin(); regionIter != regions.end(); regionIter++)
1039  {
1040  readRNSEIWindow(fic, regionIter, failed);
1041  }
1042  // Parse payloadType
1043  readTokenValueAndValidate( payloadType, failed, fic, "payloadType", 0, 255 );
1045  {
1046  cout << "PayloadType " << payloadType << " not supported in regional nesting SEI message. Exiting.\n";
1047  exit(1);
1048  }
1049 
1050  // Parse SEI
1051  switch(SEI::PayloadType(payloadType))
1052  {
1053  case SEI::FILM_GRAIN_CHARACTERISTICS: // TBD - no encoder support
1054  case SEI::POST_FILTER_HINT: // TBD - no encoder support
1055  case SEI::USER_DATA_REGISTERED_ITU_T_T35: // TBD: Support for user-data SEI to be added
1056  case SEI::USER_DATA_UNREGISTERED: // TBD: Support for user-data SEI to be added
1057  {
1058  cout << "Encoder support for " << SEI::getSEIMessageString(SEI::PayloadType(payloadType)) <<
1059  " nested in regional nesting SEI message needs to be added.\n";
1060  exit(1);
1061  }
1062  case SEI::TONE_MAPPING_INFO:
1063  {
1064  SEIToneMappingInfo *seiToneMappingInfo = new SEIToneMappingInfo;
1065  readToneMappingInfoSEI(fic, seiToneMappingInfo, failed);
1066  regSEI = new RegionalSEI(seiToneMappingInfo, regions);
1067  break;
1068  }
1070  {
1071  SEIChromaResamplingFilterHint *seiChromaResamplingFilterHint = new SEIChromaResamplingFilterHint;
1072  readChromaResamplingFilterHintSEI(fic, seiChromaResamplingFilterHint, failed);
1073  regSEI = new RegionalSEI(seiChromaResamplingFilterHint, regions);
1074  break;
1075  }
1077  {
1078  SEIKneeFunctionInfo *seiKneeFunctionInfo = new SEIKneeFunctionInfo;
1079  readKneeFunctionInfoSEI(fic, seiKneeFunctionInfo, failed);
1080  regSEI = new RegionalSEI(seiKneeFunctionInfo, regions);
1081  break;
1082  }
1084  {
1085  SEIColourRemappingInfo *seiColourRemappingInfo = new SEIColourRemappingInfo;
1086  readColourRemapSEI(fic, seiColourRemappingInfo, failed);
1087  regSEI = new RegionalSEI(seiColourRemappingInfo, regions);
1088  break;
1089  }
1091  {
1092  SEIContentColourVolume *seiContentColourVolume = new SEIContentColourVolume;
1093  readContentColourVolumeSEI(fic, seiContentColourVolume, failed);
1094  regSEI = new RegionalSEI(seiContentColourVolume, regions);
1095  break;
1096  }
1097  default:
1098  cout << "Unable to read the payloadType " << payloadType << " in " << regionalNestingSEIFileWithPoc << std::endl;
1099  exit(1);
1100  }
1101  if( failed )
1102  {
1103  std::cerr << "Error while reading regional nesting SEI parameters file '" << regionalNestingSEIFileWithPoc << "'" << std::endl;
1104  exit(EXIT_FAILURE);
1105  }
1106  // Add to SEI
1107  if(regSEI)
1108  {
1109  seiRegionalNesting->addRegionalSEI(regSEI);
1110  delete regSEI;
1111  }
1112  else
1113  {
1114  // Error - SEI should've been read.
1115  }
1116  }
1117  }
1118  return true;
1119 }
1120 
1121 #endif
1122 Void SEIEncoder::initSEIChromaResamplingFilterHint(SEIChromaResamplingFilterHint *seiChromaResamplingFilterHint, Int iHorFilterIndex, Int iVerFilterIndex)
1123 {
1124  assert (m_isInitialized);
1125  assert (seiChromaResamplingFilterHint!=NULL);
1126 
1127  seiChromaResamplingFilterHint->m_verChromaFilterIdc = iVerFilterIndex;
1128  seiChromaResamplingFilterHint->m_horChromaFilterIdc = iHorFilterIndex;
1129  seiChromaResamplingFilterHint->m_verFilteringFieldProcessingFlag = 1;
1130  seiChromaResamplingFilterHint->m_targetFormatIdc = 3;
1131  seiChromaResamplingFilterHint->m_perfectReconstructionFlag = false;
1132 
1133  // this creates some example filter values, if explicit filter definition is selected
1134  if (seiChromaResamplingFilterHint->m_verChromaFilterIdc == 1)
1135  {
1136  const Int numVerticalFilters = 3;
1137  const Int verTapLengthMinus1[] = {5,3,3};
1138 
1139  seiChromaResamplingFilterHint->m_verFilterCoeff.resize(numVerticalFilters);
1140  for(Int i = 0; i < numVerticalFilters; i ++)
1141  {
1142  seiChromaResamplingFilterHint->m_verFilterCoeff[i].resize(verTapLengthMinus1[i]+1);
1143  }
1144  // Note: C++11 -> seiChromaResamplingFilterHint->m_verFilterCoeff[0] = {-3,13,31,23,3,-3};
1145  seiChromaResamplingFilterHint->m_verFilterCoeff[0][0] = -3;
1146  seiChromaResamplingFilterHint->m_verFilterCoeff[0][1] = 13;
1147  seiChromaResamplingFilterHint->m_verFilterCoeff[0][2] = 31;
1148  seiChromaResamplingFilterHint->m_verFilterCoeff[0][3] = 23;
1149  seiChromaResamplingFilterHint->m_verFilterCoeff[0][4] = 3;
1150  seiChromaResamplingFilterHint->m_verFilterCoeff[0][5] = -3;
1151 
1152  seiChromaResamplingFilterHint->m_verFilterCoeff[1][0] = -1;
1153  seiChromaResamplingFilterHint->m_verFilterCoeff[1][1] = 25;
1154  seiChromaResamplingFilterHint->m_verFilterCoeff[1][2] = 247;
1155  seiChromaResamplingFilterHint->m_verFilterCoeff[1][3] = -15;
1156 
1157  seiChromaResamplingFilterHint->m_verFilterCoeff[2][0] = -20;
1158  seiChromaResamplingFilterHint->m_verFilterCoeff[2][1] = 186;
1159  seiChromaResamplingFilterHint->m_verFilterCoeff[2][2] = 100;
1160  seiChromaResamplingFilterHint->m_verFilterCoeff[2][3] = -10;
1161  }
1162  else
1163  {
1164  seiChromaResamplingFilterHint->m_verFilterCoeff.resize(0);
1165  }
1166 
1167  if (seiChromaResamplingFilterHint->m_horChromaFilterIdc == 1)
1168  {
1169  Int const numHorizontalFilters = 1;
1170  const Int horTapLengthMinus1[] = {3};
1171 
1172  seiChromaResamplingFilterHint->m_horFilterCoeff.resize(numHorizontalFilters);
1173  for(Int i = 0; i < numHorizontalFilters; i ++)
1174  {
1175  seiChromaResamplingFilterHint->m_horFilterCoeff[i].resize(horTapLengthMinus1[i]+1);
1176  }
1177  seiChromaResamplingFilterHint->m_horFilterCoeff[0][0] = 1;
1178  seiChromaResamplingFilterHint->m_horFilterCoeff[0][1] = 6;
1179  seiChromaResamplingFilterHint->m_horFilterCoeff[0][2] = 1;
1180  }
1181  else
1182  {
1183  seiChromaResamplingFilterHint->m_horFilterCoeff.resize(0);
1184  }
1185 }
1186 
1188 {
1189  assert (m_isInitialized);
1190  assert (seiTimeCode!=NULL);
1191  // Set data as per command line options
1192  seiTimeCode->numClockTs = m_pcCfg->getNumberOfTimesets();
1193  for(Int i = 0; i < seiTimeCode->numClockTs; i++)
1194  {
1195  seiTimeCode->timeSetArray[i] = m_pcCfg->getTimeSet(i);
1196  }
1197 }
1198 
1200 {
1201  assert (m_isInitialized);
1202  assert (seiAltTransCharacteristics!=NULL);
1203  // Set SEI message parameters read from command line options
1205 }
1206 
1208 {
1209  assert (m_isInitialized);
1210  assert (seiGreenMetadataInfo!=NULL);
1211 
1212  seiGreenMetadataInfo->m_greenMetadataType = m_pcCfg->getSEIGreenMetadataType();
1213  seiGreenMetadataInfo->m_xsdMetricType = m_pcCfg->getSEIXSDMetricType();
1214  seiGreenMetadataInfo->m_xsdMetricValue = u;
1215 }
1216 
1217 
SEIMessages m_nestedSEIs
Definition: SEI.h:596
Void readColourRemapSEI(std::istream &fic, SEIColourRemappingInfo *seiColorRemappingInfo, Bool &failed)
Definition: SEIEncoder.cpp:845
Bool getErpSEICancelFlag()
Definition: TEncCfg.h:979
Int m_packedPictureWidth
Definition: SEI.h:866
Int getNumTileRowsMinus1() const
Definition: TComSlice.h:1163
std::vector< UShort > m_packedRegionLeft
Definition: SEI.h:877
static Void readTokenValue(T &returnedValue, Bool &failed, std::istream &is, const TChar *pToken)
token string
Definition: SEIEncoder.cpp:584
Int m_postLutNumValMinus1[3]
Definition: SEI.h:925
Bool m_currentFrameIsFrame0Flag
Definition: SEI.h:435
Int getTMISEINominalWhiteLevelLumaCodeValue()
Definition: TEncCfg.h:895
std::vector< UChar > m_rwpTopGuardBandHeight
Definition: SEI.h:880
Int getDisplayOrientationSEIAngle()
Definition: TEncCfg.h:917
UInt getOmniViewportSEICntMinus1()
Definition: TEncCfg.h:1011
PayloadType
Definition: SEI.h:55
Bool m_selfContainedCvsFlag
Definition: SEI.h:516
Bool m_exposureCompensationValueSignFlag
Definition: SEI.h:408
std::vector< UShort > m_packedRegionWidth
Definition: SEI.h:874
UInt m_sopDescVclNaluType[MAX_NUM_PICS_IN_SOP]
Definition: SEI.h:495
Bool isField() const
Definition: TComPic.h:166
Bool m_max_mcs_tier_level_idc_present_flag
Definition: SEI.h:709
UInt m_sopDescStRpsIdx[MAX_NUM_PICS_IN_SOP]
Definition: SEI.h:497
Int m_frame1GridPositionX
Definition: SEI.h:440
UInt getOmniViewportSEIHorRange(Int idx)
Definition: TEncCfg.h:1019
std::vector< Bool > m_rwpGuardBandFlag
Definition: SEI.h:869
Void setNumberOfTileRects(const Int number)
Definition: SEI.h:683
Bool m_constituentPictureMatchingFlag
Definition: SEI.h:862
Bool getErpSEIPersistenceFlag()
Definition: TEncCfg.h:981
Double getCcvSEIPrimariesY(Int index)
Definition: TEncCfg.h:966
std::vector< KneePointPair > m_kneeSEIKneePointPairs
Definition: TEncCfg.h:130
NalUnitType getNalUnitType(Int pocCurr, Int lastIdr, Bool isField)
Definition: TEncGOP.cpp:2766
Int m_contentInterpretationType
Definition: SEI.h:431
Int getSPSId() const
Definition: TComSlice.h:824
Int getNumTileColumnsMinus1() const
Definition: TComSlice.h:1159
GOP encoder class (header)
Double getCcvSEIMinLuminanceValue()
Definition: TEncCfg.h:968
Int getRwpSEIPackedPictureHeight()
Definition: TEncCfg.h:1049
Bool getCcvSEIAvgLuminanceValuePresentFlag()
Definition: TEncCfg.h:962
UInt m_initialCpbRemovalDelay[MAX_CPB_CNT][2]
Definition: SEI.h:158
Int m_exposureIndexIdc
Definition: SEI.h:406
Bool m_frame1SelfContainedFlag
Definition: SEI.h:437
picture class (symbol + YUV buffers)
Definition: TComPic.h:56
Void initSEISOPDescription(SEISOPDescription *sei, TComSlice *slice, Int picInGOP, Int lastIdr, Int currGOPSize)
Definition: SEIEncoder.cpp:194
Defines version information, constants and small in-line functions.
Bool getSphereRotationSEIPersistenceFlag()
Definition: TEncCfg.h:995
Int m_ccvPrimariesY[MAX_NUM_COMPONENT]
Definition: SEI.h:777
Int m_exposureCompensationValueNumerator
Definition: SEI.h:409
void Void
Definition: TypeDef.h:203
std::vector< Int > m_targetPivotValue
Definition: SEI.h:403
Bool m_fieldViewsFlag
Definition: SEI.h:434
Int m_projPictureWidth
Definition: SEI.h:864
UInt m_dpbDelayOffset
Definition: SEI.h:157
Bool m_exactMatchingFlag
Definition: SEI.h:270
UInt calcChecksum(const TComPicYuv &pic, TComPictureHash &digest, const BitDepths &bitDepths)
UShort getRwpSEIPackedRegionWidth(UInt idx) const
Definition: TEncCfg.h:1063
Void initSEICubemapProjection(SEICubemapProjection *sei)
Definition: SEIEncoder.cpp:517
Bool m_arrangementPersistenceFlag
Definition: SEI.h:443
UInt getTimeScale() const
Definition: TComSlice.h:414
UInt getOmniViewportSEIId()
Definition: TEncCfg.h:1005
const TEncSEIKneeFunctionInformation & getKneeFunctionInformationSEI() const
Definition: TEncCfg.h:946
Int m_colourRemapMatrixCoefficients
Definition: SEI.h:917
Int getSegmentedRectFramePackingArrangementSEIType()
Definition: TEncCfg.h:913
#define NULL
Definition: CommonDef.h:107
Bool m_kneePersistenceFlag
Definition: SEI.h:752
Int getTMISEICodedDataBitDepth()
Definition: TEncCfg.h:853
std::vector< Int > m_kneeOutputKneePoint
Definition: SEI.h:759
Bool m_frame0FlippedFlag
Definition: SEI.h:433
std::vector< Int > m_kneeInputKneePoint
Definition: SEI.h:758
Bool getCcvSEICancelFlag()
Definition: TEncCfg.h:952
UInt getOmniViewportSEIVerRange(Int idx)
Definition: TEncCfg.h:1021
unsigned int UInt
Definition: TypeDef.h:212
Bool m_rapCpbParamsPresentFlag
Definition: SEI.h:155
Int m_frame0GridPositionX
Definition: SEI.h:438
UInt m_cpbDelayOffset
Definition: SEI.h:156
Void readRNSEIWindow(std::istream &fic, RNSEIWindowVec::iterator regionIter, Bool &failed)
Definition: SEIEncoder.cpp:837
Int getRwpSEIProjPictureHeight()
Definition: TEncCfg.h:1045
UInt getRwpSEIProjRegionHeight(UInt idx) const
Definition: TEncCfg.h:1057
Int getTMISEISigmoidMidpoint()
Definition: TEncCfg.h:863
Bool m_colourRemapVideoSignalInfoPresentFlag
Definition: SEI.h:913
std::vector< Bool > m_rwpGuardBandNotUsedForPredFlag
Definition: SEI.h:882
Bool m_frame0SelfContainedFlag
Definition: SEI.h:436
Int getSphereRotationSEIYaw()
Definition: TEncCfg.h:997
Int m_numPivots
Definition: SEI.h:401
Int m_minValue
Definition: SEI.h:396
Bool m_ccvAvgLuminanceValuePresentFlag
Definition: SEI.h:775
UChar getSEIXSDMetricType() const
Definition: TEncCfg.h:1095
Bool m_ccvPersistenceFlag
Definition: SEI.h:771
UInt numClockTs
Definition: SEI.h:635
Int m_POC
Definition: TEncCfg.h:51
TileSetData & tileSetData(const Int index)
Definition: SEI.h:720
Int getTMISEIModelID()
Definition: TEncCfg.h:857
std::vector< UInt > m_projRegionWidth
Definition: SEI.h:870
Bool getRwpSEIRwpPersistenceFlag()
Definition: TEncCfg.h:1037
std::vector< UInt > m_projRegionHeight
Definition: SEI.h:871
Bool m_cmpPersistenceFlag
Definition: SEI.h:849
Int getNumberOfTimesets()
Definition: TEncCfg.h:939
Void initSEIRegionWisePacking(SEIRegionWisePacking *sei)
Definition: SEIEncoder.cpp:527
Bool m_sphereRotationPersistenceFlag
Definition: SEI.h:810
Void readContentColourVolumeSEI(std::istream &fic, SEIContentColourVolume *seiContentColourVolume, Bool &failed)
Definition: SEIEncoder.cpp:962
Int getTMISEIExposurIndexValue()
Definition: TEncCfg.h:881
UInt m_rapIdx
Definition: SEIEncoder.h:121
Int getTMISEIRefScreenLuminanceWhite()
Definition: TEncCfg.h:889
UChar getRwpSEIRwpRightGuardBandWidth(UInt idx) const
Definition: TEncCfg.h:1073
UInt m_ccvAvgLuminanceValue
Definition: SEI.h:780
Int getRwpSEIProjPictureWidth()
Definition: TEncCfg.h:1043
Int m_nominalBlackLevelLumaCodeValue
Definition: SEI.h:413
std::vector< Int > activeSeqParameterSetId
Definition: SEI.h:519
Void initSEITimeCode(SEITimeCode *sei)
static const TChar * getSEIMessageString(SEI::PayloadType payloadType)
Definition: SEI.cpp:182
Bool getRwpSEIConstituentPictureMatchingFlag()
Definition: TEncCfg.h:1039
UChar getRwpSEIRwpBottomGuardBandHeight(UInt idx) const
Definition: TEncCfg.h:1077
char TChar
Definition: TypeDef.h:206
HashType method
Definition: SEI.h:566
TComVUI * getVuiParameters()
Definition: TComSlice.h:936
Bool getCmpSEICmpCancelFlag()
Definition: TEncCfg.h:1027
Bool getTilesEnabledFlag() const
Definition: TComSlice.h:1155
std::vector< UChar > m_rwpRightGuardBandWidth
Definition: SEI.h:879
UInt calcMD5(const TComPicYuv &pic, TComPictureHash &digest, const BitDepths &bitDepths)
Bool m_colourRemapCancelFlag
Definition: SEI.h:911
Bool m_colourRemapMatrixPresentFlag
Definition: SEI.h:922
TComPicYuv * getPicYuvRec()
Definition: TComPic.h:120
std::vector< CRIlut > m_postLut[3]
Definition: SEI.h:926
std::vector< OmniViewport > m_omniViewportRegions
Definition: SEI.h:837
Bool m_colourRemapFullRangeFlag
Definition: SEI.h:914
std::vector< UInt > m_rwpProjRegionTop
Definition: SEI.h:872
Int m_kneeOutputDrange
Definition: SEI.h:755
Int getTMISEICameraIsoSpeedIdc()
Definition: TEncCfg.h:875
UInt m_sopDescTemporalId[MAX_NUM_PICS_IN_SOP]
Definition: SEI.h:496
const std::string & getRegionalNestingSEIFileRoot() const
Definition: TEncCfg.h:1098
Bool getSphereRotationSEICancelFlag()
Definition: TEncCfg.h:993
Bool m_rwpCancelFlag
Definition: SEI.h:860
UInt getErpSEILeftGuardBandWidth()
Definition: TEncCfg.h:987
std::vector< UShort > m_packedRegionTop
Definition: SEI.h:876
Void initSEIChromaResamplingFilterHint(SEIChromaResamplingFilterHint *sei, Int iHorFilterIndex, Int iVerFilterIndex)
Int m_frame1GridPositionY
Definition: SEI.h:441
Int * getTMISEICodedPivotValue()
Definition: TEncCfg.h:871
Int m_kneeInputDispLuminance
Definition: SEI.h:754
Bool m_cmpCancelFlag
Definition: SEI.h:848
Void readKneeFunctionInfoSEI(std::istream &fic, SEIKneeFunctionInfo *seiKneeFunctionInfo, Bool &failed)
Definition: SEIEncoder.cpp:948
UShort getRwpSEIPackedRegionHeight(UInt idx) const
Definition: TEncCfg.h:1065
Bool getRwpSEIRwpGuardBandNotUsedForPredFlag(UInt idx) const
Definition: TEncCfg.h:1079
Int getReferencePictureSetIdxForSOP(Int POCCurr, Int GOPid)
Definition: TEncTop.cpp:1271
HashType getDecodedPictureHashSEIType() const
Definition: TEncCfg.h:837
std::vector< Int > m_startOfCodedInterval
Definition: SEI.h:400
Int getOmniViewportSEIElevationCentre(Int idx)
Definition: TEncCfg.h:1015
TComSEITimeSet timeSetArray[MAX_TIMECODE_SEI_SETS]
Definition: SEI.h:636
Int getTMISEIExtendedWhiteLevelLumaCodeValue()
Definition: TEncCfg.h:897
UInt m_xsdMetricValue
Definition: SEI.h:480
UChar getSEIGreenMetadataType() const
Definition: TEncCfg.h:1093
UInt m_numPicsInSopMinus1
Definition: SEI.h:493
Bool m_ccvMaxLuminanceValuePresentFlag
Definition: SEI.h:774
Int m_maxValue
Definition: SEI.h:397
Int m_colourRemapCoeffs[3][3]
Definition: SEI.h:924
bool Bool
Definition: TypeDef.h:204
Bool m_verFilteringFieldProcessingFlag
Definition: SEI.h:735
Bool m_ccvPrimariesPresentFlag
Definition: SEI.h:772
Void initSEIKneeFunctionInfo(SEIKneeFunctionInfo *sei)
Definition: SEIEncoder.cpp:389
UInt m_xsdMetricType
Definition: SEI.h:479
UInt getRwpSEIProjRegionLeft(UInt idx) const
Definition: TEncCfg.h:1061
Bool m_allLayersFlag
Definition: SEI.h:591
TComPictureHash m_pictureHash
Definition: SEI.h:568
Int m_sigmoidWidth
Definition: SEI.h:399
Int getRwpSEINumPackedRegions()
Definition: TEncCfg.h:1041
Void initSEIFramePacking(SEIFramePacking *sei, Int currPicNum)
Definition: SEIEncoder.cpp:57
const std::string & getColourRemapInfoSEIFileRoot() const
Definition: TEncCfg.h:1084
Void initSEISphereRotation(SEISphereRotation *sei)
Definition: SEIEncoder.cpp:475
std::vector< UChar > m_rwpLeftGuardBandWidth
Definition: SEI.h:878
PPS class.
Definition: TComSlice.h:1034
Int m_nominalWhiteLevelLumaCodeValue
Definition: SEI.h:414
Int m_cameraIsoSpeedIdc
Definition: SEI.h:404
Void initSEIGreenMetadataInfo(SEIGreenMetadataInfo *sei, UInt u)
Int getSphereRotationSEIRoll()
Definition: TEncCfg.h:1001
std::vector< UChar > m_rwpBottomGuardBandHeight
Definition: SEI.h:881
Bool getTMISEIExposureCompensationValueSignFlag()
Definition: TEncCfg.h:883
Bool m_ccvCancelFlag
Definition: SEI.h:770
Int m_toneMapId
Definition: SEI.h:390
Void initSEIErp(SEIEquirectangularProjection *sei)
Definition: SEIEncoder.cpp:456
Bool getTMISEIToneMapPersistenceFlag()
Definition: TEncCfg.h:851
std::vector< CRIlut > m_preLut[3]
Definition: SEI.h:921
Bool m_quincunxSamplingFlag
Definition: SEI.h:430
Void initSEIContentColourVolume(SEIContentColourVolume *sei)
Definition: SEIEncoder.cpp:417
UInt m_nestingNumOpsMinus1
Definition: SEI.h:587
Bool getRwpSEIRwpCancelFlag()
Definition: TEncCfg.h:1035
Int & bottomRightTileIndex(const Int tileRectIndex)
Definition: SEI.h:696
UShort getRwpSEIPackedRegionLeft(UInt idx) const
Definition: TEncCfg.h:1069
Void initTemporalLevel0IndexSEI(SEITemporalLevel0Index *sei, TComSlice *slice)
Definition: SEIEncoder.cpp:321
UInt m_initialAltCpbRemovalDelayOffset[MAX_CPB_CNT][2]
Definition: SEI.h:161
std::vector< std::vector< Int > > m_horFilterCoeff
Definition: SEI.h:739
Void readChromaResamplingFilterHintSEI(std::istream &fic, SEIChromaResamplingFilterHint *seiChromaResamplingFilterHint, Bool &failed)
Definition: SEIEncoder.cpp:935
Bool getOmniViewportSEICancelFlag()
Definition: TEncCfg.h:1007
Bool m_omniViewportPersistenceFlag
Definition: SEI.h:835
Int getFramePackingArrangementSEIId()
Definition: TEncCfg.h:903
std::vector< UShort > m_packedRegionHeight
Definition: SEI.h:875
Int m_preLutNumValMinus1[3]
Definition: SEI.h:920
UInt m_auCpbRemovalDelayDelta
Definition: SEI.h:163
Int getTMISEIExposurIndexIdc()
Definition: TEncCfg.h:879
Int getTMISEIMinValue()
Definition: TEncCfg.h:859
Bool getCcvSEIPersistenceFlag()
Definition: TEncCfg.h:954
UChar getRwpSEIRwpGuardBandType(UInt idx) const
Definition: TEncCfg.h:1081
std::vector< std::vector< Int > > m_verFilterCoeff
Definition: SEI.h:738
Int m_sphereRotationYaw
Definition: SEI.h:811
Bool getErpSEIGuardBandFlag()
Definition: TEncCfg.h:983
Bool m_arrangementCancelFlag
Definition: SEI.h:428
Int getTMISEIExposureCompensationValueNumerator()
Definition: TEncCfg.h:885
Int m_codedDataBitDepth
Definition: SEI.h:393
Int getSphereRotationSEIPitch()
Definition: TEncCfg.h:999
UInt m_nestingNoOpMaxTemporalIdPlus1
Definition: SEI.h:592
Int m_colourRemapInputBitDepth
Definition: SEI.h:918
Int m_ccvPrimariesX[MAX_NUM_COMPONENT]
Definition: SEI.h:776
Int m_extendedWhiteLevelLumaCodeValue
Definition: SEI.h:415
Void readToneMappingInfoSEI(std::istream &fic, SEIToneMappingInfo *seiToneMappingInfo, Bool &failed)
Definition: SEIEncoder.cpp:906
Bool m_isInitialized
Definition: SEIEncoder.h:123
UInt m_initialCpbRemovalDelayOffset[MAX_CPB_CNT][2]
Definition: SEI.h:159
Bool initSEIColourRemappingInfo(SEIColourRemappingInfo *sei, Int currPOC)
Definition: SEIEncoder.cpp:738
Double getCcvSEIAvgLuminanceValue()
Definition: TEncCfg.h:972
Bool getRwpSEIRwpGuardBandFlag(UInt idx) const
Definition: TEncCfg.h:1053
std::vector< UChar > m_rwpTransformType
Definition: SEI.h:868
Int getNumberOfTileSets() const
Definition: SEI.h:718
UInt anticlockwiseRotation
Definition: SEI.h:464
UInt getRwpSEIProjRegionWidth(UInt idx) const
Definition: TEncCfg.h:1055
UInt m_ccvMinLuminanceValue
Definition: SEI.h:778
Bool m_spatialFlippingFlag
Definition: SEI.h:432
Int getOmniViewportSEIAzimuthCentre(Int idx)
Definition: TEncCfg.h:1013
UInt m_omniViewportId
Definition: SEI.h:833
TComSEITimeSet & getTimeSet(Int index)
Definition: TEncCfg.h:941
Void setNumberOfTileSets(const Int number)
Definition: SEI.h:717
Int getPOC() const
Definition: TComSlice.h:1354
encoder class (header)
Int getSegmentedRectFramePackingArrangementSEIPersistence()
Definition: TEncCfg.h:915
TimingInfo * getTimingInfo()
Definition: TComSlice.h:680
Bool getCmpSEICmpPersistenceFlag()
Definition: TEncCfg.h:1029
Int m_projPictureHeight
Definition: SEI.h:865
Int getFramesToBeEncoded()
Definition: TEncCfg.h:654
const GOPEntry & getGOPEntry(Int i) const
Definition: TEncCfg.h:566
Void initSEIAlternativeTransferCharacteristics(SEIAlternativeTransferCharacteristics *sei)
Int getFramePackingArrangementSEIQuincunx()
Definition: TEncCfg.h:905
UInt m_greenMetadataType
Definition: SEI.h:478
Int m_numPackedRegions
Definition: SEI.h:863
Bool getTMCTSSEITileConstraint()
Definition: TEncCfg.h:934
Bool getTMISEIToneMapCancelFlag()
Definition: TEncCfg.h:849
Int m_recoveryPocCnt
Definition: SEI.h:269
TComPic * getPic()
Definition: TComSlice.h:1371
Int getTMISEIMaxValue()
Definition: TEncCfg.h:861
std::vector< RNSEIWindow > RNSEIWindowVec
Definition: TypeDef.h:979
Double getCcvSEIPrimariesX(Int index)
Definition: TEncCfg.h:964
Bool m_omniViewportCancelFlag
Definition: SEI.h:834
UChar getRwpSEIRwpTransformType(UInt idx) const
Definition: TEncCfg.h:1051
UChar m_omniViewportCntMinus1
Definition: SEI.h:836
Void initSEIBufferingPeriod(SEIBufferingPeriod *sei, TComSlice *slice)
Definition: SEIEncoder.cpp:224
Int * getTMISEIStartOfCodedInterva()
Definition: TEncCfg.h:867
Int m_exposureIndexValue
Definition: SEI.h:407
Bool m_nestingOpFlag
Definition: SEI.h:585
UInt m_initialAltCpbRemovalDelay[MAX_CPB_CNT][2]
Definition: SEI.h:160
Int m_colourRemapPrimaries
Definition: SEI.h:915
UShort getRwpSEIPackedRegionTop(UInt idx) const
Definition: TEncCfg.h:1067
Bool getCcvSEIMinLuminanceValuePresentFlag()
Definition: TEncCfg.h:958
Int m_arrangementType
Definition: SEI.h:429
Int m_exposureCompensationValueDenomIdc
Definition: SEI.h:410
Bool m_sphereRotationCancelFlag
Definition: SEI.h:809
Int m_arrangementId
Definition: SEI.h:427
Int & topLeftTileIndex(const Int tileRectIndex)
Definition: SEI.h:695
UInt getErpSEIGuardBandType()
Definition: TEncCfg.h:985
Int getFramePackingArrangementSEIInterpretation()
Definition: TEncCfg.h:907
std::vector< Int > m_codedPivotValue
Definition: SEI.h:402
Int m_kneeOutputDispLuminance
Definition: SEI.h:756
Int m_sigmoidMidpoint
Definition: SEI.h:398
Int * getTMISEITargetPivotValue()
Definition: TEncCfg.h:873
std::list< SEI * > SEIMessages
Definition: SEI.h:123
Int m_sopDescPocDelta[MAX_NUM_PICS_IN_SOP]
Definition: SEI.h:498
std::vector< UInt > m_projRegionLeft
Definition: SEI.h:873
UChar getRwpSEIRwpTopGuardBandHeight(UInt idx) const
Definition: TEncCfg.h:1075
static Bool checkRegionalNestedSEIPayloadType(SEI::PayloadType const payloadType)
Definition: SEI.h:1032
Int m_sphereRotationRoll
Definition: SEI.h:813
Int m_extendedRangeWhiteLevel
Definition: SEI.h:412
UInt m_nestingNumLayersMinus1
Definition: SEI.h:593
Void addRegionalSEI(std::vector< UInt > listInd, SEI *sei)
Definition: SEI.h:1066
int Int
Definition: TypeDef.h:211
Bool m_mc_all_tiles_exact_sample_value_match_flag
Definition: SEI.h:706
UChar getSEIPreferredTransferCharacteristics() const
Definition: TEncCfg.h:1089
Int getTMISEIExtendedRangeWhiteLevel()
Definition: TEncCfg.h:891
Int getTMISEISigmoidWidth()
Definition: TEncCfg.h:865
Int m_sphereRotationPitch
Definition: SEI.h:812
Int getSegmentedRectFramePackingArrangementSEICancel()
Definition: TEncCfg.h:911
UChar getRwpSEIRwpLeftGuardBandWidth(UInt idx) const
Definition: TEncCfg.h:1071
Bool getRapPicFlag() const
Definition: TComSlice.cpp:179
Int getTMISEIExposureCompensationValueDenomIdc()
Definition: TEncCfg.h:887
Int m_refScreenLuminanceWhite
Definition: SEI.h:411
Bool m_concatenationFlag
Definition: SEI.h:162
Bool m_brokenLinkFlag
Definition: SEI.h:271
Bool m_toneMapPersistenceFlag
Definition: SEI.h:392
Int getTMISEINumPivots()
Definition: TEncCfg.h:869
Bool m_colourRemapPersistenceFlag
Definition: SEI.h:912
Int m_kneeInputDrange
Definition: SEI.h:753
Bool getCcvSEIMaxLuminanceValuePresentFlag()
Definition: TEncCfg.h:960
TEncTop * m_pcEncTop
Definition: SEIEncoder.h:116
Int getOmniViewportSEITiltCentre(Int idx)
Definition: TEncCfg.h:1017
Int m_kneeNumKneePointsMinus1
Definition: SEI.h:757
Int getTMISEICameraIsoSpeedValue()
Definition: TEncCfg.h:877
Void initSEITempMotionConstrainedTileSets(SEITempMotionConstrainedTileSets *sei, const TComPPS *pps)
Definition: SEIEncoder.cpp:340
Int m_frame0GridPositionY
Definition: SEI.h:439
Void initSEIActiveParameterSets(SEIActiveParameterSets *sei, const TComVPS *vps, const TComSPS *sps)
Definition: SEIEncoder.cpp:42
std::vector< UChar > m_rwpGuardBandType
Definition: SEI.h:883
Int m_temporalId
Definition: TEncCfg.h:62
Void initSEISegmentedRectFramePacking(SEISegmentedRectFramePacking *sei)
Definition: SEIEncoder.cpp:83
Int getTMISEIToneMapId()
Definition: TEncCfg.h:847
double Double
Definition: TypeDef.h:213
UInt m_ccvMaxLuminanceValue
Definition: SEI.h:779
Bool m_toneMapCancelFlag
Definition: SEI.h:391
Int m_cameraIsoSpeedValue
Definition: SEI.h:405
std::string hashToString(const TComPictureHash &digest, Int numChar)
TEncCfg * m_pcCfg
Definition: SEIEncoder.h:115
Bool m_noParameterSetUpdateFlag
Definition: SEI.h:517
Int getFramePackingArrangementSEIType()
Definition: TEncCfg.h:901
UInt m_tl0Idx
Definition: SEIEncoder.h:120
UInt m_colourRemapId
Definition: SEI.h:910
UInt getErpSEIRightGuardBandWidth()
Definition: TEncCfg.h:989
slice header class
Definition: TComSlice.h:1225
Bool m_upsampledAspectRatio
Definition: SEI.h:444
UInt getTLayer() const
Definition: TComSlice.h:1453
Bool m_kneeCancelFlag
Definition: SEI.h:751
UChar m_nestingLayerId[MAX_NESTING_NUM_LAYER]
Definition: SEI.h:594
Int m_colourRemapBitDepth
Definition: SEI.h:919
Int m_arrangementReservedByte
Definition: SEI.h:442
Int getVPSId() const
Definition: TComSlice.h:477
Double getCcvSEIMaxLuminanceValue()
Definition: TEncCfg.h:970
Int m_packedPictureHeight
Definition: SEI.h:867
Bool m_rwpPersistenceFlag
Definition: SEI.h:861
Void initDecodedPictureHashSEI(SEIDecodedPictureHash *sei, TComPic *pcPic, std::string &rHashString, const BitDepths &bitDepths)
calculate hashes for entire reconstructed picture
Definition: SEIEncoder.cpp:290
Bool getCcvSEIPrimariesPresentFlag()
Definition: TEncCfg.h:956
Int m_targetBitDepth
Definition: SEI.h:394
Bool initSEIRegionalNesting(SEIRegionalNesting *sei, Int currPOC)
UInt getNumUnitsInTick() const
Definition: TComSlice.h:411
Void initSEIOmniViewport(SEIOmniViewport *sei)
Definition: SEIEncoder.cpp:490
Bool m_bitStreamSubsetFlag
Definition: SEI.h:584
Void initSEIToneMappingInfo(SEIToneMappingInfo *sei)
Definition: SEIEncoder.cpp:104
Int getRwpSEIPackedPictureWidth()
Definition: TEncCfg.h:1047
UInt m_sopSeqParameterSetId
Definition: SEI.h:492
Int m_colourRemapTransferFunction
Definition: SEI.h:916
UInt calcCRC(const TComPicYuv &pic, TComPictureHash &digest, const BitDepths &bitDepths)
UChar m_erpRightGuardBandWidth
Definition: SEI.h:798
Void initSEIDisplayOrientation(SEIDisplayOrientation *sei)
Definition: SEIEncoder.cpp:93
TComHRD * getHrdParameters()
Definition: TComSlice.h:677
static Void readTokenValueAndValidate(T &returnedValue, Bool &failed, std::istream &is, const TChar *pToken, const T &minInclusive, const T &maxInclusive)
maximum value allowed, inclusive
Definition: SEIEncoder.cpp:633
Int getTMISEINominalBlackLevelLumaCodeValue()
Definition: TEncCfg.h:893
Int getTMISEITargetBitDepth()
Definition: TEncCfg.h:855
Void initSEIRecoveryPoint(SEIRecoveryPoint *sei, TComSlice *slice)
Definition: SEIEncoder.cpp:278
TEncGOP * m_pcEncGOP
Definition: SEIEncoder.h:117
Void initSEIScalableNesting(SEIScalableNesting *sei, SEIMessages &nestedSEIs)
Definition: SEIEncoder.cpp:258
Bool getOmniViewportSEIPersistenceFlag()
Definition: TEncCfg.h:1009
Bool m_ccvMinLuminanceValuePresentFlag
Definition: SEI.h:773
const TComSPS * getSPS() const
Definition: TComSlice.h:1329
SPS class.
Definition: TComSlice.h:740
UInt getTickDivisorMinus2() const
Definition: TComSlice.h:333
Bool m_arrangementPersistenceFlag
Definition: SEI.h:661
UInt getRwpSEIRwpSEIProjRegionTop(UInt idx) const
Definition: TEncCfg.h:1059