source: 3DVCSoftware/branches/HTM-15.1-dev0/source/Lib/TLibEncoder/SEIEncoder.cpp @ 1328

Last change on this file since 1328 was 1328, checked in by tech, 9 years ago

Integrated general SEI changes and following SEIs:

  • Multiview view position SEI
  • Multiview acquisition information SEI
  • Multiview scene information SEI
  • Inter-layer constrained tile sets SEI
  • Property svn:eol-style set to native
File size: 22.2 KB
Line 
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
42Void 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
57Void SEIEncoder::initSEIFramePacking(SEIFramePacking *seiFramePacking, Int currPicNum)
58{
59  assert (m_isInitialized);
60  assert (seiFramePacking!=NULL);
61
62  seiFramePacking->m_arrangementId = m_pcCfg->getFramePackingArrangementSEIId();
63  seiFramePacking->m_arrangementCancelFlag = 0;
64  seiFramePacking->m_arrangementType = m_pcCfg->getFramePackingArrangementSEIType();
65  assert((seiFramePacking->m_arrangementType > 2) && (seiFramePacking->m_arrangementType < 6) );
66  seiFramePacking->m_quincunxSamplingFlag = m_pcCfg->getFramePackingArrangementSEIQuincunx();
67  seiFramePacking->m_contentInterpretationType = m_pcCfg->getFramePackingArrangementSEIInterpretation();
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
83Void SEIEncoder::initSEISegmentedRectFramePacking(SEISegmentedRectFramePacking *seiSegmentedRectFramePacking)
84{
85  assert (m_isInitialized);
86  assert (seiSegmentedRectFramePacking!=NULL);
87
88  seiSegmentedRectFramePacking->m_arrangementCancelFlag = m_pcCfg->getSegmentedRectFramePackingArrangementSEICancel();
89  seiSegmentedRectFramePacking->m_contentInterpretationType = m_pcCfg->getSegmentedRectFramePackingArrangementSEIType();
90  seiSegmentedRectFramePacking->m_arrangementPersistenceFlag = m_pcCfg->getSegmentedRectFramePackingArrangementSEIPersistence();
91}
92
93Void SEIEncoder::initSEIDisplayOrientation(SEIDisplayOrientation* seiDisplayOrientation)
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
104Void SEIEncoder::initSEIToneMappingInfo(SEIToneMappingInfo *seiToneMappingInfo)
105{
106  assert (m_isInitialized);
107  assert (seiToneMappingInfo!=NULL);
108
109  seiToneMappingInfo->m_toneMapId = m_pcCfg->getTMISEIToneMapId();
110  seiToneMappingInfo->m_toneMapCancelFlag = m_pcCfg->getTMISEIToneMapCancelFlag();
111  seiToneMappingInfo->m_toneMapPersistenceFlag = m_pcCfg->getTMISEIToneMapPersistenceFlag();
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);
138      Int* ptmp = m_pcCfg->getTMISEIStartOfCodedInterva();
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();
168      seiToneMappingInfo->m_cameraIsoSpeedValue = m_pcCfg->getTMISEICameraIsoSpeedValue();
169      assert( seiToneMappingInfo->m_cameraIsoSpeedValue !=0 );
170      seiToneMappingInfo->m_exposureIndexIdc = m_pcCfg->getTMISEIExposurIndexIdc();
171      seiToneMappingInfo->m_exposureIndexValue = m_pcCfg->getTMISEIExposurIndexValue();
172      assert( seiToneMappingInfo->m_exposureIndexValue !=0 );
173      seiToneMappingInfo->m_exposureCompensationValueSignFlag = m_pcCfg->getTMISEIExposureCompensationValueSignFlag();
174      seiToneMappingInfo->m_exposureCompensationValueNumerator = m_pcCfg->getTMISEIExposureCompensationValueNumerator();
175      seiToneMappingInfo->m_exposureCompensationValueDenomIdc = m_pcCfg->getTMISEIExposureCompensationValueDenomIdc();
176      seiToneMappingInfo->m_refScreenLuminanceWhite = m_pcCfg->getTMISEIRefScreenLuminanceWhite();
177      seiToneMappingInfo->m_extendedRangeWhiteLevel = m_pcCfg->getTMISEIExtendedRangeWhiteLevel();
178      assert( seiToneMappingInfo->m_extendedRangeWhiteLevel >= 100 );
179      seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue = m_pcCfg->getTMISEINominalBlackLevelLumaCodeValue();
180      seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue = m_pcCfg->getTMISEINominalWhiteLevelLumaCodeValue();
181      assert( seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue > seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue );
182      seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue = m_pcCfg->getTMISEIExtendedWhiteLevelLumaCodeValue();
183      assert( seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue >= seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue );
184      break;
185    }
186  default:
187    {
188      assert(!"Undefined SEIToneMapModelId");
189      break;
190    }
191  }
192}
193
194Void 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
224Void SEIEncoder::initSEIBufferingPeriod(SEIBufferingPeriod *bufferingPeriodSEI, TComSlice *slice)
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
236  Double dTmp = (Double)slice->getSPS()->getVuiParameters()->getTimingInfo()->getNumUnitsInTick() / (Double)slice->getSPS()->getVuiParameters()->getTimingInfo()->getTimeScale();
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
255//! initialize scalable nesting SEI message.
256//! Note: The SEI message structures input into this function will become part of the scalable nesting SEI and will be
257//!       automatically freed, when the nesting SEI is disposed.
258Void SEIEncoder::initSEIScalableNesting(SEIScalableNesting *scalableNestingSEI, SEIMessages &nestedSEIs)
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
278Void SEIEncoder::initSEIRecoveryPoint(SEIRecoveryPoint *recoveryPointSEI, TComSlice *slice)
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
289//! calculate hashes for entire reconstructed picture
290Void 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  if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 1)
297  {
298    decodedPictureHashSEI->method = SEIDecodedPictureHash::MD5;
299    UInt numChar=calcMD5(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths);
300    rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar);
301  }
302  else if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 2)
303  {
304    decodedPictureHashSEI->method = SEIDecodedPictureHash::CRC;
305    UInt numChar=calcCRC(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths);
306    rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar);
307  }
308  else if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 3)
309  {
310    decodedPictureHashSEI->method = SEIDecodedPictureHash::CHECKSUM;
311    UInt numChar=calcChecksum(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths);
312    rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar);
313  }
314}
315
316Void SEIEncoder::initTemporalLevel0IndexSEI(SEITemporalLevel0Index *temporalLevel0IndexSEI, TComSlice *slice)
317{
318  assert (m_isInitialized);
319  assert (temporalLevel0IndexSEI!=NULL);
320  assert (slice!=NULL);
321
322  if (slice->getRapPicFlag())
323  {
324    m_tl0Idx = 0;
325    m_rapIdx = (m_rapIdx + 1) & 0xFF;
326  }
327  else
328  {
329    m_tl0Idx = (m_tl0Idx + (slice->getTLayer() ? 0 : 1)) & 0xFF;
330  }
331  temporalLevel0IndexSEI->tl0Idx = m_tl0Idx;
332  temporalLevel0IndexSEI->rapIdx = m_rapIdx;
333}
334
335Void SEIEncoder::initSEITempMotionConstrainedTileSets (SEITempMotionConstrainedTileSets *sei, const TComPPS *pps)
336{
337  assert (m_isInitialized);
338  assert (sei!=NULL);
339  assert (pps!=NULL);
340
341  if(pps->getTilesEnabledFlag())
342  {
343    sei->m_mc_all_tiles_exact_sample_value_match_flag = false;
344    sei->m_each_tile_one_tile_set_flag                = false;
345    sei->m_limited_tile_set_display_flag              = false;
346    sei->setNumberOfTileSets((pps->getNumTileColumnsMinus1() + 1) * (pps->getNumTileRowsMinus1() + 1));
347
348    for(Int i=0; i < sei->getNumberOfTileSets(); i++)
349    {
350      sei->tileSetData(i).m_mcts_id = i;  //depends the application;
351      sei->tileSetData(i).setNumberOfTileRects(1);
352
353      for(Int j=0; j<sei->tileSetData(i).getNumberOfTileRects(); j++)
354      {
355        sei->tileSetData(i).topLeftTileIndex(j)     = i+j;
356        sei->tileSetData(i).bottomRightTileIndex(j) = i+j;
357      }
358
359      sei->tileSetData(i).m_exact_sample_value_match_flag    = false;
360      sei->tileSetData(i).m_mcts_tier_level_idc_present_flag = false;
361    }
362  }
363  else
364  {
365    assert(!"Tile is not enabled");
366  }
367}
368
369Void SEIEncoder::initSEIKneeFunctionInfo(SEIKneeFunctionInfo *seiKneeFunctionInfo)
370{
371  assert (m_isInitialized);
372  assert (seiKneeFunctionInfo!=NULL);
373
374  seiKneeFunctionInfo->m_kneeId = m_pcCfg->getKneeSEIId();
375  seiKneeFunctionInfo->m_kneeCancelFlag = m_pcCfg->getKneeSEICancelFlag();
376  if ( !seiKneeFunctionInfo->m_kneeCancelFlag )
377  {
378    seiKneeFunctionInfo->m_kneePersistenceFlag = m_pcCfg->getKneeSEIPersistenceFlag();
379    seiKneeFunctionInfo->m_kneeInputDrange = m_pcCfg->getKneeSEIInputDrange();
380    seiKneeFunctionInfo->m_kneeInputDispLuminance = m_pcCfg->getKneeSEIInputDispLuminance();
381    seiKneeFunctionInfo->m_kneeOutputDrange = m_pcCfg->getKneeSEIOutputDrange();
382    seiKneeFunctionInfo->m_kneeOutputDispLuminance = m_pcCfg->getKneeSEIOutputDispLuminance();
383
384    seiKneeFunctionInfo->m_kneeNumKneePointsMinus1 = m_pcCfg->getKneeSEINumKneePointsMinus1();
385    Int* piInputKneePoint  = m_pcCfg->getKneeSEIInputKneePoint();
386    Int* piOutputKneePoint = m_pcCfg->getKneeSEIOutputKneePoint();
387    if(piInputKneePoint&&piOutputKneePoint)
388    {
389      seiKneeFunctionInfo->m_kneeInputKneePoint.resize(seiKneeFunctionInfo->m_kneeNumKneePointsMinus1+1);
390      seiKneeFunctionInfo->m_kneeOutputKneePoint.resize(seiKneeFunctionInfo->m_kneeNumKneePointsMinus1+1);
391      for(Int i=0; i<=seiKneeFunctionInfo->m_kneeNumKneePointsMinus1; i++)
392      {
393        seiKneeFunctionInfo->m_kneeInputKneePoint[i] = piInputKneePoint[i];
394        seiKneeFunctionInfo->m_kneeOutputKneePoint[i] = piOutputKneePoint[i];
395      }
396    }
397  }
398}
399
400Void SEIEncoder::initSEIChromaSamplingFilterHint(SEIChromaSamplingFilterHint *seiChromaSamplingFilterHint, Int iHorFilterIndex, Int iVerFilterIndex)
401{
402  assert (m_isInitialized);
403  assert (seiChromaSamplingFilterHint!=NULL);
404
405  seiChromaSamplingFilterHint->m_verChromaFilterIdc = iVerFilterIndex;
406  seiChromaSamplingFilterHint->m_horChromaFilterIdc = iHorFilterIndex;
407  seiChromaSamplingFilterHint->m_verFilteringProcessFlag = 1;
408  seiChromaSamplingFilterHint->m_targetFormatIdc = 3;
409  seiChromaSamplingFilterHint->m_perfectReconstructionFlag = false;
410  if(seiChromaSamplingFilterHint->m_verChromaFilterIdc == 1)
411  {
412    seiChromaSamplingFilterHint->m_numVerticalFilters = 1;
413    seiChromaSamplingFilterHint->m_verTapLengthMinus1 = (Int*)malloc(seiChromaSamplingFilterHint->m_numVerticalFilters * sizeof(Int));
414    seiChromaSamplingFilterHint->m_verFilterCoeff =    (Int**)malloc(seiChromaSamplingFilterHint->m_numVerticalFilters * sizeof(Int*));
415    for(Int i = 0; i < seiChromaSamplingFilterHint->m_numVerticalFilters; i ++)
416    {
417      seiChromaSamplingFilterHint->m_verTapLengthMinus1[i] = 0;
418      seiChromaSamplingFilterHint->m_verFilterCoeff[i] = (Int*)malloc(seiChromaSamplingFilterHint->m_verTapLengthMinus1[i] * sizeof(Int));
419      for(Int j = 0; j < seiChromaSamplingFilterHint->m_verTapLengthMinus1[i]; j ++)
420      {
421        seiChromaSamplingFilterHint->m_verFilterCoeff[i][j] = 0;
422      }
423    }
424  }
425  else
426  {
427    seiChromaSamplingFilterHint->m_numVerticalFilters = 0;
428    seiChromaSamplingFilterHint->m_verTapLengthMinus1 = NULL;
429    seiChromaSamplingFilterHint->m_verFilterCoeff = NULL;
430  }
431  if(seiChromaSamplingFilterHint->m_horChromaFilterIdc == 1)
432  {
433    seiChromaSamplingFilterHint->m_numHorizontalFilters = 1;
434    seiChromaSamplingFilterHint->m_horTapLengthMinus1 = (Int*)malloc(seiChromaSamplingFilterHint->m_numHorizontalFilters * sizeof(Int));
435    seiChromaSamplingFilterHint->m_horFilterCoeff = (Int**)malloc(seiChromaSamplingFilterHint->m_numHorizontalFilters * sizeof(Int*));
436    for(Int i = 0; i < seiChromaSamplingFilterHint->m_numHorizontalFilters; i ++)
437    {
438      seiChromaSamplingFilterHint->m_horTapLengthMinus1[i] = 0;
439      seiChromaSamplingFilterHint->m_horFilterCoeff[i] = (Int*)malloc(seiChromaSamplingFilterHint->m_horTapLengthMinus1[i] * sizeof(Int));
440      for(Int j = 0; j < seiChromaSamplingFilterHint->m_horTapLengthMinus1[i]; j ++)
441      {
442        seiChromaSamplingFilterHint->m_horFilterCoeff[i][j] = 0;
443      }
444    }
445  }
446  else
447  {
448    seiChromaSamplingFilterHint->m_numHorizontalFilters = 0;
449    seiChromaSamplingFilterHint->m_horTapLengthMinus1 = NULL;
450    seiChromaSamplingFilterHint->m_horFilterCoeff = NULL;
451  }
452}
453
454Void SEIEncoder::initSEITimeCode(SEITimeCode *seiTimeCode)
455{
456  assert (m_isInitialized);
457  assert (seiTimeCode!=NULL);
458  //  Set data as per command line options
459  seiTimeCode->numClockTs = m_pcCfg->getNumberOfTimesets();
460  for(Int i = 0; i < seiTimeCode->numClockTs; i++)
461  {
462    seiTimeCode->timeSetArray[i] = m_pcCfg->getTimeSet(i);
463  }
464}
465
466#if NH_MV
467#if !NH_MV_SEI
468Void SEIEncoder::initSEISubBitstreamProperty(SEISubBitstreamProperty *seiSubBitstreamProperty, const TComSPS *sps)
469{
470  seiSubBitstreamProperty->m_activeVpsId = sps->getVPSId();
471  /* These values can be determined by the encoder; for now we will use the input parameter */ 
472  seiSubBitstreamProperty->m_numAdditionalSubStreams = m_pcCfg->getNumAdditionalSubStreams();
473  seiSubBitstreamProperty->m_subBitstreamMode        = m_pcCfg->getSubBitstreamMode();
474  seiSubBitstreamProperty->m_outputLayerSetIdxToVps  = m_pcCfg->getOutputLayerSetIdxToVps();
475  seiSubBitstreamProperty->m_highestSublayerId       = m_pcCfg->getHighestSublayerId();
476  seiSubBitstreamProperty->m_avgBitRate              = m_pcCfg->getAvgBitRate();
477  seiSubBitstreamProperty->m_maxBitRate              = m_pcCfg->getMaxBitRate(); 
478}
479#else
480Void SEIEncoder::createAnnexFGISeiMessages( SEIMessages& seiMessage, const TComSlice* slice )
481{
482  const SEIMessages* seiMessageCfg = m_pcCfg->getSeiMessages(); 
483
484  for( SEIMessages::const_iterator itS = seiMessageCfg->begin(); itS != seiMessageCfg->end(); itS++ )   
485  {     
486    const SEI* curSei = (*itS); 
487    SEI* newSei; 
488    if ( curSei->insertSei( slice->getLayerId(), slice->getPOC(), slice->getTemporalId(), slice->getNalUnitType() ) )
489    {
490      newSei = curSei->getCopy( ) ;
491
492      if ( curSei->m_modifyByEncoder )
493      {
494        newSei->setupFromSlice  ( slice ); 
495      } 
496
497      if ( newSei   ->checkCfg( slice ) )
498      {
499        std::cout << "--> Omit sending SEI."  <<  std::endl; 
500        delete newSei; 
501      }
502      else
503      {
504        seiMessage.push_back(newSei); 
505      }
506
507    }
508  }
509}
510#endif
511#endif
512
513//! \}
Note: See TracBrowser for help on using the repository browser.