source: 3DVCSoftware/branches/HTM-15.1-dev0/source/Lib/TLibDecoder/SEIread.cpp @ 1328

Last change on this file since 1328 was 1328, checked in by tech, 10 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: 83.6 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/**
35 \file     SEIread.cpp
36 \brief    reading funtionality for SEI messages
37 */
38
39#include "TLibCommon/CommonDef.h"
40#include "TLibCommon/TComBitStream.h"
41#include "TLibCommon/SEI.h"
42#include "TLibCommon/TComSlice.h"
43#include "SyntaxElementParser.h"
44#include "SEIread.h"
45#include "TLibCommon/TComPicYuv.h"
46#include <iomanip>
47
48
49//! \ingroup TLibDecoder
50//! \{
51
52
53#if ENC_DEC_TRACE
54Void  xTraceSEIHeader()
55{
56  fprintf( g_hTrace, "=========== SEI message ===========\n");
57}
58
59Void  xTraceSEIMessageType(SEI::PayloadType payloadType)
60{
61  fprintf( g_hTrace, "=========== %s SEI message ===========\n", SEI::getSEIMessageString(payloadType));
62}
63#endif
64
65Void SEIReader::sei_read_code(std::ostream *pOS, UInt uiLength, UInt& ruiCode, const Char *pSymbolName)
66{
67  READ_CODE(uiLength, ruiCode, pSymbolName);
68  if (pOS)
69  {
70    (*pOS) << "  " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n";
71  }
72}
73
74Void SEIReader::sei_read_uvlc(std::ostream *pOS, UInt& ruiCode, const Char *pSymbolName)
75{
76  READ_UVLC(ruiCode, pSymbolName);
77  if (pOS)
78  {
79    (*pOS) << "  " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n";
80  }
81}
82
83Void SEIReader::sei_read_svlc(std::ostream *pOS, Int& ruiCode, const Char *pSymbolName)
84{
85  READ_SVLC(ruiCode, pSymbolName);
86  if (pOS)
87  {
88    (*pOS) << "  " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n";
89  }
90}
91
92Void SEIReader::sei_read_flag(std::ostream *pOS, UInt& ruiCode, const Char *pSymbolName)
93{
94  READ_FLAG(ruiCode, pSymbolName);
95  if (pOS)
96  {
97    (*pOS) << "  " << std::setw(55) << pSymbolName << ": " << (ruiCode?1:0) << "\n";
98  }
99}
100
101#if NH_MV_SEI
102inline Void SEIReader::output_sei_message_header(SEI &sei, std::ostream *pDecodedMessageOutputStream, UInt payloadSize)
103#else
104static inline Void output_sei_message_header(SEI &sei, std::ostream *pDecodedMessageOutputStream, UInt payloadSize)
105#endif
106{
107  if (pDecodedMessageOutputStream)
108  {
109    std::string seiMessageHdr(SEI::getSEIMessageString(sei.payloadType())); seiMessageHdr+=" SEI message";
110    (*pDecodedMessageOutputStream) << std::setfill('-') << std::setw(seiMessageHdr.size()) << "-" << std::setfill(' ') << "\n" << seiMessageHdr << " (" << payloadSize << " bytes)"<< "\n";
111#if NH_MV_SEI
112    (*pDecodedMessageOutputStream) << std::setfill(' ') << "LayerId: " << m_layerId << std::setw(2) << " Picture: " << m_decOrder << std::setw( 5 ) << std::endl; 
113#endif
114  }
115}
116
117#undef READ_CODE
118#undef READ_SVLC
119#undef READ_UVLC
120#undef READ_FLAG
121
122
123/**
124 * unmarshal a single SEI message from bitstream bs
125 */
126Void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
127{
128  setBitstream(bs);
129
130  assert(!m_pcBitstream->getNumBitsUntilByteAligned());
131  do
132  {
133    xReadSEImessage(seis, nalUnitType, sps, pDecodedMessageOutputStream);
134
135    /* SEI messages are an integer number of bytes, something has failed
136    * in the parsing if bitstream not byte-aligned */
137    assert(!m_pcBitstream->getNumBitsUntilByteAligned());
138  }
139  while (m_pcBitstream->getNumBitsLeft() > 8);
140
141  xReadRbspTrailingBits();
142}
143
144Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
145{
146#if ENC_DEC_TRACE
147  xTraceSEIHeader();
148#endif
149  Int payloadType = 0;
150  UInt val = 0;
151
152  do
153  {
154    sei_read_code(NULL, 8, val, "payload_type");
155    payloadType += val;
156  } while (val==0xFF);
157
158  UInt payloadSize = 0;
159  do
160  {
161    sei_read_code(NULL, 8, val, "payload_size");
162    payloadSize += val;
163  } while (val==0xFF);
164
165#if ENC_DEC_TRACE
166  xTraceSEIMessageType((SEI::PayloadType)payloadType);
167#endif
168
169  /* extract the payload for this single SEI message.
170   * This allows greater safety in erroneous parsing of an SEI message
171   * from affecting subsequent messages.
172   * After parsing the payload, bs needs to be restored as the primary
173   * bitstream.
174   */
175  TComInputBitstream *bs = getBitstream();
176  setBitstream(bs->extractSubstream(payloadSize * 8));
177
178  SEI *sei = NULL;
179
180  if(nalUnitType == NAL_UNIT_PREFIX_SEI)
181  {
182    switch (payloadType)
183    {
184    case SEI::USER_DATA_UNREGISTERED:
185      sei = new SEIuserDataUnregistered;
186      xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream);
187      break;
188    case SEI::ACTIVE_PARAMETER_SETS:
189      sei = new SEIActiveParameterSets;
190      xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize, pDecodedMessageOutputStream);
191      break;
192    case SEI::DECODING_UNIT_INFO:
193      if (!sps)
194      {
195        printf ("Warning: Found Decoding unit SEI message, but no active SPS is available. Ignoring.");
196      }
197      else
198      {
199        sei = new SEIDecodingUnitInfo;
200        xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, pDecodedMessageOutputStream);
201      }
202      break;
203    case SEI::BUFFERING_PERIOD:
204      if (!sps)
205      {
206        printf ("Warning: Found Buffering period SEI message, but no active SPS is available. Ignoring.");
207      }
208      else
209      {
210        sei = new SEIBufferingPeriod;
211        xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, pDecodedMessageOutputStream);
212      }
213      break;
214    case SEI::PICTURE_TIMING:
215      if (!sps)
216      {
217        printf ("Warning: Found Picture timing SEI message, but no active SPS is available. Ignoring.");
218      }
219      else
220      {
221        sei = new SEIPictureTiming;
222        xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, pDecodedMessageOutputStream);
223      }
224      break;
225    case SEI::RECOVERY_POINT:
226      sei = new SEIRecoveryPoint;
227      xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize, pDecodedMessageOutputStream);
228      break;
229    case SEI::FRAME_PACKING:
230      sei = new SEIFramePacking;
231      xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream);
232      break;
233    case SEI::SEGM_RECT_FRAME_PACKING:
234      sei = new SEISegmentedRectFramePacking;
235      xParseSEISegmentedRectFramePacking((SEISegmentedRectFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream);
236      break;
237    case SEI::DISPLAY_ORIENTATION:
238      sei = new SEIDisplayOrientation;
239      xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize, pDecodedMessageOutputStream);
240      break;
241    case SEI::TEMPORAL_LEVEL0_INDEX:
242      sei = new SEITemporalLevel0Index;
243      xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize, pDecodedMessageOutputStream);
244      break;
245    case SEI::REGION_REFRESH_INFO:
246      sei = new SEIGradualDecodingRefreshInfo;
247      xParseSEIRegionRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
248      break;
249    case SEI::NO_DISPLAY:
250      sei = new SEINoDisplay;
251      xParseSEINoDisplay((SEINoDisplay&) *sei, payloadSize, pDecodedMessageOutputStream);
252      break;
253    case SEI::TONE_MAPPING_INFO:
254      sei = new SEIToneMappingInfo;
255      xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
256      break;
257    case SEI::SOP_DESCRIPTION:
258      sei = new SEISOPDescription;
259      xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize, pDecodedMessageOutputStream);
260      break;
261    case SEI::SCALABLE_NESTING:
262      sei = new SEIScalableNesting;
263      xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps, pDecodedMessageOutputStream);
264      break;
265    case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS:
266      sei = new SEITempMotionConstrainedTileSets;
267      xParseSEITempMotionConstraintsTileSets((SEITempMotionConstrainedTileSets&) *sei, payloadSize, pDecodedMessageOutputStream);
268      break;
269    case SEI::TIME_CODE:
270      sei = new SEITimeCode;
271      xParseSEITimeCode((SEITimeCode&) *sei, payloadSize, pDecodedMessageOutputStream);
272      break;
273    case SEI::CHROMA_SAMPLING_FILTER_HINT:
274      sei = new SEIChromaSamplingFilterHint;
275      xParseSEIChromaSamplingFilterHint((SEIChromaSamplingFilterHint&) *sei, payloadSize/*, sps*/, pDecodedMessageOutputStream);
276      //}
277      break;
278    case SEI::KNEE_FUNCTION_INFO:
279      sei = new SEIKneeFunctionInfo;
280      xParseSEIKneeFunctionInfo((SEIKneeFunctionInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
281      break;
282    case SEI::MASTERING_DISPLAY_COLOUR_VOLUME:
283      sei = new SEIMasteringDisplayColourVolume;
284      xParseSEIMasteringDisplayColourVolume((SEIMasteringDisplayColourVolume&) *sei, payloadSize, pDecodedMessageOutputStream);
285      break;
286#if !NH_MV_SEI
287    case SEI::SUB_BITSTREAM_PROPERTY:
288      sei = new SEISubBitstreamProperty;
289      xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, payloadSize, pDecodedMessageOutputStream );
290      break;
291#else
292#if NH_MV_TBD
293    case SEI::LAYERS_NOT_PRESENT:
294      sei = new SEILayersNotPresent;
295      xParseSEILayersNotPresent((SEILayersNotPresent&) *sei, payloadSize, pDecodedMessageOutputStream );
296      break;
297#endif
298    case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS:
299      sei = new SEIInterLayerConstrainedTileSets;
300      xParseSEIInterLayerConstrainedTileSets((SEIInterLayerConstrainedTileSets&) *sei, payloadSize, pDecodedMessageOutputStream );
301      break;
302#if NH_MV_TBD
303    case SEI::BSP_NESTING:
304      sei = new SEIBspNesting;
305      xParseSEIBspNesting((SEIBspNesting&) *sei, payloadSize, pDecodedMessageOutputStream );
306      break;
307    case SEI::BSP_INITIAL_ARRIVAL_TIME:
308      sei = new SEIBspInitialArrivalTime;
309      xParseSEIBspInitialArrivalTime((SEIBspInitialArrivalTime&) *sei, payloadSize, pDecodedMessageOutputStream );
310      break;
311#endif
312    case SEI::SUB_BITSTREAM_PROPERTY:
313      sei = new SEISubBitstreamProperty;
314      xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, payloadSize, pDecodedMessageOutputStream );
315      break;
316#if NH_MV_SEI_TBD
317    case SEI::ALPHA_CHANNEL_INFO:
318      sei = new SEIAlphaChannelInfo;
319      xParseSEIAlphaChannelInfo((SEIAlphaChannelInfo&) *sei, payloadSize, pDecodedMessageOutputStream );
320      break;
321    case SEI::OVERLAY_INFO:
322      sei = new SEIOverlayInfo;
323      xParseSEIOverlayInfo((SEIOverlayInfo&) *sei, payloadSize, pDecodedMessageOutputStream );
324      break;
325#endif
326    case SEI::TEMPORAL_MV_PREDICTION_CONSTRAINTS:
327      sei = new SEITemporalMvPredictionConstraints;
328      xParseSEITemporalMvPredictionConstraints((SEITemporalMvPredictionConstraints&) *sei, payloadSize, pDecodedMessageOutputStream );
329      break;
330#if NH_MV_SEI_TBD
331    case SEI::FRAME_FIELD_INFO:
332      sei = new SEIFrameFieldInfo;
333      xParseSEIFrameFieldInfo((SEIFrameFieldInfo&) *sei, payloadSize, pDecodedMessageOutputStream );
334      break;
335    case SEI::THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO:
336      sei = new SEIThreeDimensionalReferenceDisplaysInfo;
337      xParseSEIThreeDimensionalReferenceDisplaysInfo((SEIThreeDimensionalReferenceDisplaysInfo&) *sei, payloadSize, pDecodedMessageOutputStream );
338      break;
339    case SEI::DEPTH_REPRESENTATION_INFO:
340      sei = new SEIDepthRepresentationInfo;
341      xParseSEIDepthRepresentationInfo((SEIDepthRepresentationInfo&) *sei, payloadSize, pDecodedMessageOutputStream );
342      break;
343#endif
344    case SEI::MULTIVIEW_SCENE_INFO:
345      sei = new SEIMultiviewSceneInfo;
346      xParseSEIMultiviewSceneInfo((SEIMultiviewSceneInfo&) *sei, payloadSize, pDecodedMessageOutputStream );
347      break;
348
349    case SEI::MULTIVIEW_ACQUISITION_INFO:
350      sei = new SEIMultiviewAcquisitionInfo;
351      xParseSEIMultiviewAcquisitionInfo((SEIMultiviewAcquisitionInfo&) *sei, payloadSize, pDecodedMessageOutputStream );
352      break;
353
354    case SEI::MULTIVIEW_VIEW_POSITION:
355      sei = new SEIMultiviewViewPosition;
356      xParseSEIMultiviewViewPosition((SEIMultiviewViewPosition&) *sei, payloadSize, pDecodedMessageOutputStream );
357      break;
358#if NH_MV_TBD
359    case SEI::ALTERNATIVE_DEPTH_INFO:
360      sei = new SEIAlternativeDepthInfo;
361      xParseSEIAlternativeDepthInfo((SEIAlternativeDepthInfo&) *sei, payloadSize, pDecodedMessageOutputStream );
362      break;
363#endif
364#endif
365    default:
366      for (UInt i = 0; i < payloadSize; i++)
367      {
368        UInt seiByte;
369        sei_read_code (NULL, 8, seiByte, "unknown prefix SEI payload byte");
370      }
371      printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType);
372      if (pDecodedMessageOutputStream)
373      {
374        (*pDecodedMessageOutputStream) << "Unknown prefix SEI message (payloadType = " << payloadType << ") was found!\n";
375      }
376      break;
377    }
378  }
379  else
380  {
381    switch (payloadType)
382    {
383      case SEI::USER_DATA_UNREGISTERED:
384        sei = new SEIuserDataUnregistered;
385        xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream);
386        break;
387      case SEI::DECODED_PICTURE_HASH:
388        sei = new SEIDecodedPictureHash;
389        xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize, pDecodedMessageOutputStream);
390        break;
391      default:
392        for (UInt i = 0; i < payloadSize; i++)
393        {
394          UInt seiByte;
395          sei_read_code( NULL, 8, seiByte, "unknown suffix SEI payload byte");
396        }
397        printf ("Unknown suffix SEI message (payloadType = %d) was found!\n", payloadType);
398        if (pDecodedMessageOutputStream)
399        {
400          (*pDecodedMessageOutputStream) << "Unknown suffix SEI message (payloadType = " << payloadType << ") was found!\n";
401        }
402        break;
403    }
404  }
405
406  if (sei != NULL)
407  {
408    seis.push_back(sei);
409  }
410
411  /* By definition the underlying bitstream terminates in a byte-aligned manner.
412   * 1. Extract all bar the last MIN(bitsremaining,nine) bits as reserved_payload_extension_data
413   * 2. Examine the final 8 bits to determine the payload_bit_equal_to_one marker
414   * 3. Extract the remainingreserved_payload_extension_data bits.
415   *
416   * If there are fewer than 9 bits available, extract them.
417   */
418  Int payloadBitsRemaining = getBitstream()->getNumBitsLeft();
419  if (payloadBitsRemaining) /* more_data_in_payload() */
420  {
421    for (; payloadBitsRemaining > 9; payloadBitsRemaining--)
422    {
423      UInt reservedPayloadExtensionData;
424      sei_read_code ( pDecodedMessageOutputStream, 1, reservedPayloadExtensionData, "reserved_payload_extension_data");
425    }
426
427    /* 2 */
428    Int finalBits = getBitstream()->peekBits(payloadBitsRemaining);
429    Int finalPayloadBits = 0;
430    for (Int mask = 0xff; finalBits & (mask >> finalPayloadBits); finalPayloadBits++)
431    {
432      continue;
433    }
434
435    /* 3 */
436    for (; payloadBitsRemaining > 9 - finalPayloadBits; payloadBitsRemaining--)
437    {
438      UInt reservedPayloadExtensionData;
439      sei_read_flag ( 0, reservedPayloadExtensionData, "reserved_payload_extension_data");
440    }
441
442    UInt dummy;
443    sei_read_flag( 0, dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--;
444    while (payloadBitsRemaining)
445    {
446      sei_read_flag( 0, dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--;
447    }
448  }
449
450  /* restore primary bitstream for sei_message */
451  delete getBitstream();
452  setBitstream(bs);
453}
454
455/**
456 * parse bitstream bs and unpack a user_data_unregistered SEI message
457 * of payloasSize bytes into sei.
458 */
459
460Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
461{
462  assert(payloadSize >= ISO_IEC_11578_LEN);
463  UInt val;
464  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
465
466  for (UInt i = 0; i < ISO_IEC_11578_LEN; i++)
467  {
468    sei_read_code( pDecodedMessageOutputStream, 8, val, "uuid_iso_iec_11578");
469    sei.uuid_iso_iec_11578[i] = val;
470  }
471
472  sei.userDataLength = payloadSize - ISO_IEC_11578_LEN;
473  if (!sei.userDataLength)
474  {
475    sei.userData = 0;
476    return;
477  }
478
479  sei.userData = new UChar[sei.userDataLength];
480  for (UInt i = 0; i < sei.userDataLength; i++)
481  {
482    sei_read_code( NULL, 8, val, "user_data_payload_byte" );
483    sei.userData[i] = val;
484  }
485  if (pDecodedMessageOutputStream)
486  {
487    (*pDecodedMessageOutputStream) << "  User data payload size: " << sei.userDataLength << "\n";
488  }
489}
490
491/**
492 * parse bitstream bs and unpack a decoded picture hash SEI message
493 * of payloadSize bytes into sei.
494 */
495Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
496{
497  UInt bytesRead = 0;
498  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
499
500  UInt val;
501  sei_read_code( pDecodedMessageOutputStream, 8, val, "hash_type");
502  sei.method = static_cast<SEIDecodedPictureHash::Method>(val); bytesRead++;
503
504  const Char *traceString="\0";
505  switch (sei.method)
506  {
507    case SEIDecodedPictureHash::MD5: traceString="picture_md5"; break;
508    case SEIDecodedPictureHash::CRC: traceString="picture_crc"; break;
509    case SEIDecodedPictureHash::CHECKSUM: traceString="picture_checksum"; break;
510    default: assert(false); break;
511  }
512
513  if (pDecodedMessageOutputStream)
514  {
515    (*pDecodedMessageOutputStream) << "  " << std::setw(55) << traceString << ": " << std::hex << std::setfill('0');
516  }
517
518  sei.m_pictureHash.hash.clear();
519  for(;bytesRead < payloadSize; bytesRead++)
520  {
521    sei_read_code( NULL, 8, val, traceString);
522    sei.m_pictureHash.hash.push_back((UChar)val);
523    if (pDecodedMessageOutputStream)
524    {
525      (*pDecodedMessageOutputStream) << std::setw(2) << val;
526    }
527  }
528
529  if (pDecodedMessageOutputStream)
530  {
531    (*pDecodedMessageOutputStream) << std::dec << std::setfill(' ') << "\n";
532  }
533}
534
535Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
536{
537  UInt val; 
538  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
539
540  sei_read_code( pDecodedMessageOutputStream, 4, val, "active_video_parameter_set_id");   sei.activeVPSId = val;
541  sei_read_flag( pDecodedMessageOutputStream,    val, "self_contained_cvs_flag");         sei.m_selfContainedCvsFlag     = (val != 0);
542  sei_read_flag( pDecodedMessageOutputStream,    val, "no_parameter_set_update_flag");    sei.m_noParameterSetUpdateFlag = (val != 0);
543  sei_read_uvlc( pDecodedMessageOutputStream,    val, "num_sps_ids_minus1");              sei.numSpsIdsMinus1 = val;
544
545  sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1);
546  for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++)
547  {
548    sei_read_uvlc( pDecodedMessageOutputStream, val, "active_seq_parameter_set_id[i]");    sei.activeSeqParameterSetId[i] = val;
549  }
550}
551
552Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
553{
554  UInt val;
555  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
556  sei_read_uvlc( pDecodedMessageOutputStream, val, "decoding_unit_idx");
557  sei.m_decodingUnitIdx = val;
558
559  const TComVUI *vui = sps->getVuiParameters();
560  if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag())
561  {
562    sei_read_code( pDecodedMessageOutputStream, ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay_increment");
563    sei.m_duSptCpbRemovalDelay = val;
564  }
565  else
566  {
567    sei.m_duSptCpbRemovalDelay = 0;
568  }
569  sei_read_flag( pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = (val != 0);
570  if(sei.m_dpbOutputDuDelayPresentFlag)
571  {
572    sei_read_code( pDecodedMessageOutputStream, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay");
573    sei.m_picSptDpbOutputDuDelay = val;
574  }
575}
576
577Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
578{
579  Int i, nalOrVcl;
580  UInt code;
581
582  const TComVUI *pVUI = sps->getVuiParameters();
583  const TComHRD *pHRD = pVUI->getHrdParameters();
584
585  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
586
587  sei_read_uvlc( pDecodedMessageOutputStream, code, "bp_seq_parameter_set_id" );                         sei.m_bpSeqParameterSetId     = code;
588  if( !pHRD->getSubPicCpbParamsPresentFlag() )
589  {
590    sei_read_flag( pDecodedMessageOutputStream, code, "irap_cpb_params_present_flag" );                   sei.m_rapCpbParamsPresentFlag = code;
591  }
592  if( sei.m_rapCpbParamsPresentFlag )
593  {
594    sei_read_code( pDecodedMessageOutputStream, pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" );      sei.m_cpbDelayOffset = code;
595    sei_read_code( pDecodedMessageOutputStream, pHRD->getDpbOutputDelayLengthMinus1()  + 1, code, "dpb_delay_offset" );      sei.m_dpbDelayOffset = code;
596  }
597
598  //read splicing flag and cpb_removal_delay_delta
599  sei_read_flag( pDecodedMessageOutputStream, code, "concatenation_flag");
600  sei.m_concatenationFlag = code;
601  sei_read_code( pDecodedMessageOutputStream, ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" );
602  sei.m_auCpbRemovalDelayDelta = code + 1;
603
604  for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
605  {
606    if( ( ( nalOrVcl == 0 ) && ( pHRD->getNalHrdParametersPresentFlag() ) ) ||
607        ( ( nalOrVcl == 1 ) && ( pHRD->getVclHrdParametersPresentFlag() ) ) )
608    {
609      for( i = 0; i < ( pHRD->getCpbCntMinus1( 0 ) + 1 ); i ++ )
610      {
611        sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_delay":"nal_initial_cpb_removal_delay" );
612        sei.m_initialCpbRemovalDelay[i][nalOrVcl] = code;
613        sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_offset":"vcl_initial_cpb_removal_offset" );
614        sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl] = code;
615        if( pHRD->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag )
616        {
617          sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_delay":"vcl_initial_alt_cpb_removal_delay" );
618          sei.m_initialAltCpbRemovalDelay[i][nalOrVcl] = code;
619          sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_offset":"vcl_initial_alt_cpb_removal_offset" );
620          sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl] = code;
621        }
622      }
623    }
624  }
625}
626
627Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
628{
629  Int i;
630  UInt code;
631
632  const TComVUI *vui = sps->getVuiParameters();
633  const TComHRD *hrd = vui->getHrdParameters();
634  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
635
636  if( vui->getFrameFieldInfoPresentFlag() )
637  {
638    sei_read_code( pDecodedMessageOutputStream, 4, code, "pic_struct" );             sei.m_picStruct            = code;
639    sei_read_code( pDecodedMessageOutputStream, 2, code, "source_scan_type" );       sei.m_sourceScanType       = code;
640    sei_read_flag( pDecodedMessageOutputStream,    code, "duplicate_flag" );         sei.m_duplicateFlag        = (code == 1);
641  }
642
643  if( hrd->getCpbDpbDelaysPresentFlag())
644  {
645    sei_read_code( pDecodedMessageOutputStream, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" );
646    sei.m_auCpbRemovalDelay = code + 1;
647    sei_read_code( pDecodedMessageOutputStream, ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" );
648    sei.m_picDpbOutputDelay = code;
649
650    if(hrd->getSubPicCpbParamsPresentFlag())
651    {
652      sei_read_code( pDecodedMessageOutputStream, hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" );
653      sei.m_picDpbOutputDuDelay = code;
654    }
655
656    if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() )
657    {
658      sei_read_uvlc( pDecodedMessageOutputStream, code, "num_decoding_units_minus1");
659      sei.m_numDecodingUnitsMinus1 = code;
660      sei_read_flag( pDecodedMessageOutputStream, code, "du_common_cpb_removal_delay_flag" );
661      sei.m_duCommonCpbRemovalDelayFlag = code;
662      if( sei.m_duCommonCpbRemovalDelayFlag )
663      {
664        sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_increment_minus1" );
665        sei.m_duCommonCpbRemovalDelayMinus1 = code;
666      }
667      sei.m_numNalusInDuMinus1.resize(sei.m_numDecodingUnitsMinus1 + 1 );
668      sei.m_duCpbRemovalDelayMinus1.resize( sei.m_numDecodingUnitsMinus1 + 1 );
669
670      for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ )
671      {
672        sei_read_uvlc( pDecodedMessageOutputStream, code, "num_nalus_in_du_minus1[i]");
673        sei.m_numNalusInDuMinus1[ i ] = code;
674        if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) )
675        {
676          sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1[i]" );
677          sei.m_duCpbRemovalDelayMinus1[ i ] = code;
678        }
679      }
680    }
681  }
682}
683
684Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
685{
686  Int  iCode;
687  UInt uiCode;
688  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
689
690  sei_read_svlc( pDecodedMessageOutputStream, iCode,  "recovery_poc_cnt" );      sei.m_recoveryPocCnt     = iCode;
691  sei_read_flag( pDecodedMessageOutputStream, uiCode, "exact_matching_flag" );   sei.m_exactMatchingFlag  = uiCode;
692  sei_read_flag( pDecodedMessageOutputStream, uiCode, "broken_link_flag" );      sei.m_brokenLinkFlag     = uiCode;
693}
694
695Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
696{
697  UInt val;
698  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
699
700  sei_read_uvlc( pDecodedMessageOutputStream, val, "frame_packing_arrangement_id" );                 sei.m_arrangementId = val;
701  sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_cancel_flag" );        sei.m_arrangementCancelFlag = val;
702
703  if ( !sei.m_arrangementCancelFlag )
704  {
705    sei_read_code( pDecodedMessageOutputStream, 7, val, "frame_packing_arrangement_type" );          sei.m_arrangementType = val;
706    assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) );
707
708    sei_read_flag( pDecodedMessageOutputStream, val, "quincunx_sampling_flag" );                     sei.m_quincunxSamplingFlag = val;
709
710    sei_read_code( pDecodedMessageOutputStream, 6, val, "content_interpretation_type" );             sei.m_contentInterpretationType = val;
711    sei_read_flag( pDecodedMessageOutputStream, val, "spatial_flipping_flag" );                      sei.m_spatialFlippingFlag = val;
712    sei_read_flag( pDecodedMessageOutputStream, val, "frame0_flipped_flag" );                        sei.m_frame0FlippedFlag = val;
713    sei_read_flag( pDecodedMessageOutputStream, val, "field_views_flag" );                           sei.m_fieldViewsFlag = val;
714    sei_read_flag( pDecodedMessageOutputStream, val, "current_frame_is_frame0_flag" );               sei.m_currentFrameIsFrame0Flag = val;
715    sei_read_flag( pDecodedMessageOutputStream, val, "frame0_self_contained_flag" );                 sei.m_frame0SelfContainedFlag = val;
716    sei_read_flag( pDecodedMessageOutputStream, val, "frame1_self_contained_flag" );                 sei.m_frame1SelfContainedFlag = val;
717
718    if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5)
719    {
720      sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_x" );                sei.m_frame0GridPositionX = val;
721      sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_y" );                sei.m_frame0GridPositionY = val;
722      sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_x" );                sei.m_frame1GridPositionX = val;
723      sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_y" );                sei.m_frame1GridPositionY = val;
724    }
725
726    sei_read_code( pDecodedMessageOutputStream, 8, val, "frame_packing_arrangement_reserved_byte" );   sei.m_arrangementReservedByte = val;
727    sei_read_flag( pDecodedMessageOutputStream, val,  "frame_packing_arrangement_persistence_flag" );  sei.m_arrangementPersistenceFlag = (val != 0);
728  }
729  sei_read_flag( pDecodedMessageOutputStream, val, "upsampled_aspect_ratio_flag" );                  sei.m_upsampledAspectRatio = val;
730}
731
732Void SEIReader::xParseSEISegmentedRectFramePacking(SEISegmentedRectFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
733{
734  UInt val;
735  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
736  sei_read_flag( pDecodedMessageOutputStream, val,       "segmented_rect_frame_packing_arrangement_cancel_flag" );       sei.m_arrangementCancelFlag            = val;
737  if( !sei.m_arrangementCancelFlag )
738  {
739    sei_read_code( pDecodedMessageOutputStream, 2, val, "segmented_rect_content_interpretation_type" );                sei.m_contentInterpretationType = val;
740    sei_read_flag( pDecodedMessageOutputStream, val,     "segmented_rect_frame_packing_arrangement_persistence" );                              sei.m_arrangementPersistenceFlag               = val;
741  }
742}
743
744Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
745{
746  UInt val;
747  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
748  sei_read_flag( pDecodedMessageOutputStream, val,       "display_orientation_cancel_flag" );       sei.cancelFlag            = val;
749  if( !sei.cancelFlag )
750  {
751    sei_read_flag( pDecodedMessageOutputStream, val,     "hor_flip" );                              sei.horFlip               = val;
752    sei_read_flag( pDecodedMessageOutputStream, val,     "ver_flip" );                              sei.verFlip               = val;
753    sei_read_code( pDecodedMessageOutputStream, 16, val, "anticlockwise_rotation" );                sei.anticlockwiseRotation = val;
754    sei_read_flag( pDecodedMessageOutputStream, val,     "display_orientation_persistence_flag" );  sei.persistenceFlag       = val;
755  }
756}
757
758Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
759{
760  UInt val;
761  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
762  sei_read_code( pDecodedMessageOutputStream, 8, val, "temporal_sub_layer_zero_idx" );  sei.tl0Idx = val;
763  sei_read_code( pDecodedMessageOutputStream, 8, val, "irap_pic_id" );  sei.rapIdx = val;
764}
765
766Void SEIReader::xParseSEIRegionRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
767{
768  UInt val;
769  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
770  sei_read_flag( pDecodedMessageOutputStream, val, "refreshed_region_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0;
771}
772
773Void SEIReader::xParseSEINoDisplay(SEINoDisplay& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
774{
775  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
776  sei.m_noDisplay = true;
777}
778
779Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
780{
781  Int i;
782  UInt val;
783  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
784  sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_id" );                         sei.m_toneMapId = val;
785  sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_cancel_flag" );                sei.m_toneMapCancelFlag = val;
786
787  if ( !sei.m_toneMapCancelFlag )
788  {
789    sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_persistence_flag" );         sei.m_toneMapPersistenceFlag = val;
790    sei_read_code( pDecodedMessageOutputStream, 8, val, "coded_data_bit_depth" );           sei.m_codedDataBitDepth = val;
791    sei_read_code( pDecodedMessageOutputStream, 8, val, "target_bit_depth" );               sei.m_targetBitDepth = val;
792    sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_model_id" );                 sei.m_modelId = val;
793    switch(sei.m_modelId)
794    {
795    case 0:
796      {
797        sei_read_code( pDecodedMessageOutputStream, 32, val, "min_value" );                 sei.m_minValue = val;
798        sei_read_code( pDecodedMessageOutputStream, 32, val, "max_value" );                 sei.m_maxValue = val;
799        break;
800      }
801    case 1:
802      {
803        sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_midpoint" );          sei.m_sigmoidMidpoint = val;
804        sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_width" );             sei.m_sigmoidWidth = val;
805        break;
806      }
807    case 2:
808      {
809        UInt num = 1u << sei.m_targetBitDepth;
810        sei.m_startOfCodedInterval.resize(num+1);
811        for(i = 0; i < num; i++)
812        {
813          sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval[i]" );
814          sei.m_startOfCodedInterval[i] = val;
815        }
816        sei.m_startOfCodedInterval[num] = 1u << sei.m_codedDataBitDepth;
817        break;
818      }
819    case 3:
820      {
821        sei_read_code( pDecodedMessageOutputStream, 16, val,  "num_pivots" );                       sei.m_numPivots = val;
822        sei.m_codedPivotValue.resize(sei.m_numPivots);
823        sei.m_targetPivotValue.resize(sei.m_numPivots);
824        for(i = 0; i < sei.m_numPivots; i++ )
825        {
826          sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value[i]" );
827          sei.m_codedPivotValue[i] = val;
828          sei_read_code( pDecodedMessageOutputStream, ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3),    val, "target_pivot_value[i]" );
829          sei.m_targetPivotValue[i] = val;
830        }
831        break;
832      }
833    case 4:
834      {
835        sei_read_code( pDecodedMessageOutputStream, 8, val, "camera_iso_speed_idc" );                     sei.m_cameraIsoSpeedIdc = val;
836        if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO
837        {
838          sei_read_code( pDecodedMessageOutputStream, 32,   val,   "camera_iso_speed_value" );            sei.m_cameraIsoSpeedValue = val;
839        }
840        sei_read_code( pDecodedMessageOutputStream, 8, val, "exposure_index_idc" );                       sei.m_exposureIndexIdc = val;
841        if( sei.m_exposureIndexIdc == 255) //Extended_ISO
842        {
843          sei_read_code( pDecodedMessageOutputStream, 32,   val,   "exposure_index_value" );              sei.m_exposureIndexValue = val;
844        }
845        sei_read_flag( pDecodedMessageOutputStream, val, "exposure_compensation_value_sign_flag" );       sei.m_exposureCompensationValueSignFlag = val;
846        sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_numerator" );   sei.m_exposureCompensationValueNumerator = val;
847        sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_denom_idc" );   sei.m_exposureCompensationValueDenomIdc = val;
848        sei_read_code( pDecodedMessageOutputStream, 32, val, "ref_screen_luminance_white" );              sei.m_refScreenLuminanceWhite = val;
849        sei_read_code( pDecodedMessageOutputStream, 32, val, "extended_range_white_level" );              sei.m_extendedRangeWhiteLevel = val;
850        sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_black_level_code_value" );          sei.m_nominalBlackLevelLumaCodeValue = val;
851        sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_white_level_code_value" );          sei.m_nominalWhiteLevelLumaCodeValue= val;
852        sei_read_code( pDecodedMessageOutputStream, 16, val, "extended_white_level_code_value" );         sei.m_extendedWhiteLevelLumaCodeValue = val;
853        break;
854      }
855    default:
856      {
857        assert(!"Undefined SEIToneMapModelId");
858        break;
859      }
860    }//switch model id
861  }// if(!sei.m_toneMapCancelFlag)
862}
863
864Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
865{
866  Int iCode;
867  UInt uiCode;
868  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
869
870  sei_read_uvlc( pDecodedMessageOutputStream, uiCode,           "sop_seq_parameter_set_id"            ); sei.m_sopSeqParameterSetId = uiCode;
871  sei_read_uvlc( pDecodedMessageOutputStream, uiCode,           "num_pics_in_sop_minus1"              ); sei.m_numPicsInSopMinus1 = uiCode;
872  for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++)
873  {
874    sei_read_code( pDecodedMessageOutputStream, 6, uiCode,                     "sop_vcl_nut[i]" );  sei.m_sopDescVclNaluType[i] = uiCode;
875    sei_read_code( pDecodedMessageOutputStream, 3, sei.m_sopDescTemporalId[i], "sop_temporal_id[i]"   );  sei.m_sopDescTemporalId[i] = uiCode;
876    if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP)
877    {
878      sei_read_uvlc( pDecodedMessageOutputStream, sei.m_sopDescStRpsIdx[i],    "sop_short_term_rps_idx[i]"    ); sei.m_sopDescStRpsIdx[i] = uiCode;
879    }
880    if (i > 0)
881    {
882      sei_read_svlc( pDecodedMessageOutputStream, iCode,                       "sop_poc_delta[i]"     ); sei.m_sopDescPocDelta[i] = iCode;
883    }
884  }
885}
886
887Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
888{
889  UInt uiCode;
890  SEIMessages seis;
891  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
892
893  sei_read_flag( pDecodedMessageOutputStream, uiCode,            "bitstream_subset_flag"         ); sei.m_bitStreamSubsetFlag = uiCode;
894  sei_read_flag( pDecodedMessageOutputStream, uiCode,            "nesting_op_flag"               ); sei.m_nestingOpFlag = uiCode;
895  if (sei.m_nestingOpFlag)
896  {
897    sei_read_flag( pDecodedMessageOutputStream, uiCode,            "default_op_flag"               ); sei.m_defaultOpFlag = uiCode;
898    sei_read_uvlc( pDecodedMessageOutputStream, uiCode,            "nesting_num_ops_minus1"        ); sei.m_nestingNumOpsMinus1 = uiCode;
899    for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++)
900    {
901      sei_read_code( pDecodedMessageOutputStream, 3,        uiCode,  "nesting_max_temporal_id_plus1[i]"   ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode;
902      sei_read_uvlc( pDecodedMessageOutputStream, uiCode,            "nesting_op_idx[i]"                  ); sei.m_nestingOpIdx[i] = uiCode;
903    }
904  }
905  else
906  {
907    sei_read_flag( pDecodedMessageOutputStream, uiCode,            "all_layers_flag"               ); sei.m_allLayersFlag       = uiCode;
908    if (!sei.m_allLayersFlag)
909    {
910      sei_read_code( pDecodedMessageOutputStream, 3,        uiCode,  "nesting_no_op_max_temporal_id_plus1"  ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode;
911      sei_read_uvlc( pDecodedMessageOutputStream, uiCode,            "nesting_num_layers_minus1"            ); sei.m_nestingNumLayersMinus1        = uiCode;
912      for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++)
913      {
914        sei_read_code( pDecodedMessageOutputStream, 6,           uiCode,     "nesting_layer_id[i]"      ); sei.m_nestingLayerId[i]   = uiCode;
915      }
916    }
917  }
918
919  // byte alignment
920  while ( m_pcBitstream->getNumBitsRead() % 8 != 0 )
921  {
922    UInt code;
923    sei_read_flag( pDecodedMessageOutputStream, code, "nesting_zero_bit" );
924  }
925
926  // read nested SEI messages
927  do
928  {
929    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream);
930  } while (m_pcBitstream->getNumBitsLeft() > 8);
931
932  if (pDecodedMessageOutputStream)
933  {
934    (*pDecodedMessageOutputStream) << "End of scalable nesting SEI message\n";
935  }
936}
937
938#if NH_MV
939#if !NH_MV_SEI
940Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream )
941{
942  UInt code;
943  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
944  sei_read_code( pDecodedMessageOutputStream, 4, code, "active_vps_id" );                      sei.m_activeVpsId = code;
945  sei_read_uvlc( pDecodedMessageOutputStream, code, "num_additional_sub_streams_minus1" );     sei.m_numAdditionalSubStreams = code + 1;
946
947  xResizeSubBitstreamPropertySeiArrays(sei);
948  for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ )
949  {
950    sei_read_code( pDecodedMessageOutputStream,   2, code, "sub_bitstream_mode[i]"           ); sei.m_subBitstreamMode[i] = code;
951    sei_read_uvlc( pDecodedMessageOutputStream,  code, "output_layer_set_idx_to_vps[i]"      ); sei.m_outputLayerSetIdxToVps[i] = code;
952    sei_read_code( pDecodedMessageOutputStream,   3, code, "highest_sub_layer_id[i]"         ); sei.m_highestSublayerId[i] = code;
953    sei_read_code( pDecodedMessageOutputStream,  16, code, "avg_bit_rate[i]"                 ); sei.m_avgBitRate[i] = code;
954    sei_read_code( pDecodedMessageOutputStream,  16, code, "max_bit_rate[i]"                 ); sei.m_maxBitRate[i] = code;
955  } 
956}
957
958Void SEIReader::xResizeSubBitstreamPropertySeiArrays(SEISubBitstreamProperty &sei)
959{
960  sei.m_subBitstreamMode.resize( sei.m_numAdditionalSubStreams );
961  sei.m_outputLayerSetIdxToVps.resize( sei.m_numAdditionalSubStreams );
962  sei.m_highestSublayerId.resize( sei.m_numAdditionalSubStreams );
963  sei.m_avgBitRate.resize( sei.m_numAdditionalSubStreams );
964  sei.m_maxBitRate.resize( sei.m_numAdditionalSubStreams );
965}
966#endif
967#endif
968
969
970Void SEIReader::xParseSEITempMotionConstraintsTileSets(SEITempMotionConstrainedTileSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
971{
972  UInt code;
973  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
974  sei_read_flag( pDecodedMessageOutputStream, code, "mc_all_tiles_exact_sample_value_match_flag");  sei.m_mc_all_tiles_exact_sample_value_match_flag = (code != 0);
975  sei_read_flag( pDecodedMessageOutputStream, code, "each_tile_one_tile_set_flag");                 sei.m_each_tile_one_tile_set_flag                = (code != 0);
976
977  if(!sei.m_each_tile_one_tile_set_flag)
978  {
979    sei_read_flag( pDecodedMessageOutputStream, code, "limited_tile_set_display_flag");  sei.m_limited_tile_set_display_flag = (code != 0);
980    sei_read_uvlc( pDecodedMessageOutputStream, code, "num_sets_in_message_minus1");     sei.setNumberOfTileSets(code + 1);
981
982    if(sei.getNumberOfTileSets() != 0)
983    {
984      for(Int i = 0; i < sei.getNumberOfTileSets(); i++)
985      {
986        sei_read_uvlc( pDecodedMessageOutputStream, code, "mcts_id");  sei.tileSetData(i).m_mcts_id = code;
987
988        if(sei.m_limited_tile_set_display_flag)
989        {
990          sei_read_flag( pDecodedMessageOutputStream, code, "display_tile_set_flag");  sei.tileSetData(i).m_display_tile_set_flag = (code != 1);
991        }
992
993        sei_read_uvlc( pDecodedMessageOutputStream, code, "num_tile_rects_in_set_minus1");  sei.tileSetData(i).setNumberOfTileRects(code + 1);
994
995        for(Int j=0; j<sei.tileSetData(i).getNumberOfTileRects(); j++)
996        {
997          sei_read_uvlc( pDecodedMessageOutputStream, code, "top_left_tile_index");      sei.tileSetData(i).topLeftTileIndex(j)     = code;
998          sei_read_uvlc( pDecodedMessageOutputStream, code, "bottom_right_tile_index");  sei.tileSetData(i).bottomRightTileIndex(j) = code;
999        }
1000
1001        if(!sei.m_mc_all_tiles_exact_sample_value_match_flag)
1002        {
1003          sei_read_flag( pDecodedMessageOutputStream, code, "exact_sample_value_match_flag");   sei.tileSetData(i).m_exact_sample_value_match_flag    = (code != 0);
1004        }
1005        sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_level_idc_present_flag");  sei.tileSetData(i).m_mcts_tier_level_idc_present_flag = (code != 0);
1006
1007        if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag)
1008        {
1009          sei_read_flag( pDecodedMessageOutputStream, code,    "mcts_tier_flag"); sei.tileSetData(i).m_mcts_tier_flag = (code != 0);
1010          sei_read_code( pDecodedMessageOutputStream, 8, code, "mcts_level_idc"); sei.tileSetData(i).m_mcts_level_idc =  code;
1011        }
1012      }
1013    }
1014  }
1015  else
1016  {
1017    sei_read_flag( pDecodedMessageOutputStream, code, "max_mcs_tier_level_idc_present_flag");  sei.m_max_mcs_tier_level_idc_present_flag = code;
1018    if(sei.m_max_mcs_tier_level_idc_present_flag)
1019    {
1020      sei_read_flag( pDecodedMessageOutputStream, code, "max_mcts_tier_flag");  sei.m_max_mcts_tier_flag = code;
1021      sei_read_code( pDecodedMessageOutputStream, 8, code, "max_mcts_level_idc"); sei.m_max_mcts_level_idc = code;
1022    }
1023  }
1024}
1025
1026Void SEIReader::xParseSEITimeCode(SEITimeCode& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1027{
1028  UInt code;
1029  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1030  sei_read_code( pDecodedMessageOutputStream, 2, code, "num_clock_ts"); sei.numClockTs = code;
1031  for(Int i = 0; i < sei.numClockTs; i++)
1032  {
1033    TComSEITimeSet currentTimeSet;
1034    sei_read_flag( pDecodedMessageOutputStream, code, "clock_time_stamp_flag[i]"); currentTimeSet.clockTimeStampFlag = code;
1035    if(currentTimeSet.clockTimeStampFlag)
1036    {
1037      sei_read_flag( pDecodedMessageOutputStream, code, "nuit_field_based_flag"); currentTimeSet.numUnitFieldBasedFlag = code;
1038      sei_read_code( pDecodedMessageOutputStream, 5, code, "counting_type"); currentTimeSet.countingType = code;
1039      sei_read_flag( pDecodedMessageOutputStream, code, "full_timestamp_flag"); currentTimeSet.fullTimeStampFlag = code;
1040      sei_read_flag( pDecodedMessageOutputStream, code, "discontinuity_flag"); currentTimeSet.discontinuityFlag = code;
1041      sei_read_flag( pDecodedMessageOutputStream, code, "cnt_dropped_flag"); currentTimeSet.cntDroppedFlag = code;
1042      sei_read_code( pDecodedMessageOutputStream, 9, code, "n_frames"); currentTimeSet.numberOfFrames = code;
1043      if(currentTimeSet.fullTimeStampFlag)
1044      {
1045        sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code;
1046        sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code;
1047        sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code;
1048      }
1049      else
1050      {
1051        sei_read_flag( pDecodedMessageOutputStream, code, "seconds_flag"); currentTimeSet.secondsFlag = code;
1052        if(currentTimeSet.secondsFlag)
1053        {
1054          sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code;
1055          sei_read_flag( pDecodedMessageOutputStream, code, "minutes_flag"); currentTimeSet.minutesFlag = code;
1056          if(currentTimeSet.minutesFlag)
1057          {
1058            sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code;
1059            sei_read_flag( pDecodedMessageOutputStream, code, "hours_flag"); currentTimeSet.hoursFlag = code;
1060            if(currentTimeSet.hoursFlag)
1061            {
1062              sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code;
1063            }
1064          }
1065        }
1066      }
1067      sei_read_code( pDecodedMessageOutputStream, 5, code, "time_offset_length"); currentTimeSet.timeOffsetLength = code;
1068      if(currentTimeSet.timeOffsetLength > 0)
1069      {
1070        sei_read_code( pDecodedMessageOutputStream, currentTimeSet.timeOffsetLength, code, "time_offset_value");
1071        if((code & (1 << (currentTimeSet.timeOffsetLength-1))) == 0)
1072        {
1073          currentTimeSet.timeOffsetValue = code;
1074        }
1075        else
1076        {
1077          code &= (1<< (currentTimeSet.timeOffsetLength-1)) - 1;
1078          currentTimeSet.timeOffsetValue = ~code + 1;
1079        }
1080      }
1081    }
1082    sei.timeSetArray[i] = currentTimeSet;
1083  }
1084}
1085
1086Void SEIReader::xParseSEIChromaSamplingFilterHint(SEIChromaSamplingFilterHint& sei, UInt payloadSize/*, TComSPS* sps*/, std::ostream *pDecodedMessageOutputStream)
1087{
1088  UInt uiCode;
1089  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1090
1091  sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "ver_chroma_filter_idc"); sei.m_verChromaFilterIdc = uiCode;
1092  sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "hor_chroma_filter_idc"); sei.m_horChromaFilterIdc = uiCode;
1093  sei_read_flag( pDecodedMessageOutputStream, uiCode, "ver_filtering_process_flag"); sei.m_verFilteringProcessFlag = uiCode;
1094  if(sei.m_verChromaFilterIdc == 1 || sei.m_horChromaFilterIdc == 1)
1095  {
1096    sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "target_format_idc"); sei.m_targetFormatIdc = uiCode;
1097    if(sei.m_verChromaFilterIdc == 1)
1098    {
1099      sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_vertical_filters"); sei.m_numVerticalFilters = uiCode;
1100      if(sei.m_numVerticalFilters > 0)
1101      {
1102        sei.m_verTapLengthMinus1 = (Int*)malloc(sei.m_numVerticalFilters * sizeof(Int));
1103        sei.m_verFilterCoeff = (Int**)malloc(sei.m_numVerticalFilters * sizeof(Int*));
1104        for(Int i = 0; i < sei.m_numVerticalFilters; i ++)
1105        {
1106          sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "ver_tap_length_minus_1"); sei.m_verTapLengthMinus1[i] = uiCode;
1107          sei.m_verFilterCoeff[i] = (Int*)malloc(sei.m_verTapLengthMinus1[i] * sizeof(Int));
1108          for(Int j = 0; j < sei.m_verTapLengthMinus1[i]; j ++)
1109          {
1110            sei_read_svlc( pDecodedMessageOutputStream, sei.m_verFilterCoeff[i][j], "ver_filter_coeff");
1111          }
1112        }
1113      }
1114    }
1115    if(sei.m_horChromaFilterIdc == 1)
1116    {
1117      sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_horizontal_filters"); sei.m_numHorizontalFilters = uiCode;
1118      if(sei.m_numHorizontalFilters  > 0)
1119      {
1120        sei.m_horTapLengthMinus1 = (Int*)malloc(sei.m_numHorizontalFilters * sizeof(Int));
1121        sei.m_horFilterCoeff = (Int**)malloc(sei.m_numHorizontalFilters * sizeof(Int*));
1122        for(Int i = 0; i < sei.m_numHorizontalFilters; i ++)
1123        {
1124          sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "hor_tap_length_minus_1"); sei.m_horTapLengthMinus1[i] = uiCode;
1125          sei.m_horFilterCoeff[i] = (Int*)malloc(sei.m_horTapLengthMinus1[i] * sizeof(Int));
1126          for(Int j = 0; j < sei.m_horTapLengthMinus1[i]; j ++)
1127          {
1128            sei_read_svlc( pDecodedMessageOutputStream, sei.m_horFilterCoeff[i][j], "hor_filter_coeff");
1129          }
1130        }
1131      }
1132    }
1133  }
1134}
1135
1136Void SEIReader::xParseSEIKneeFunctionInfo(SEIKneeFunctionInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1137{
1138  Int i;
1139  UInt val;
1140  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1141
1142  sei_read_uvlc( pDecodedMessageOutputStream, val, "knee_function_id" );                   sei.m_kneeId = val;
1143  sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_cancel_flag" );          sei.m_kneeCancelFlag = val;
1144  if ( !sei.m_kneeCancelFlag )
1145  {
1146    sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_persistence_flag" );   sei.m_kneePersistenceFlag = val;
1147    sei_read_code( pDecodedMessageOutputStream, 32, val, "input_d_range" );                sei.m_kneeInputDrange = val;
1148    sei_read_code( pDecodedMessageOutputStream, 32, val, "input_disp_luminance" );         sei.m_kneeInputDispLuminance = val;
1149    sei_read_code( pDecodedMessageOutputStream, 32, val, "output_d_range" );               sei.m_kneeOutputDrange = val;
1150    sei_read_code( pDecodedMessageOutputStream, 32, val, "output_disp_luminance" );        sei.m_kneeOutputDispLuminance = val;
1151    sei_read_uvlc( pDecodedMessageOutputStream, val, "num_knee_points_minus1" );           sei.m_kneeNumKneePointsMinus1 = val;
1152    assert( sei.m_kneeNumKneePointsMinus1 > 0 );
1153    sei.m_kneeInputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1);
1154    sei.m_kneeOutputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1);
1155    for(i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ )
1156    {
1157      sei_read_code( pDecodedMessageOutputStream, 10, val, "input_knee_point" );           sei.m_kneeInputKneePoint[i] = val;
1158      sei_read_code( pDecodedMessageOutputStream, 10, val, "output_knee_point" );          sei.m_kneeOutputKneePoint[i] = val;
1159    }
1160  }
1161}
1162
1163Void SEIReader::xParseSEIMasteringDisplayColourVolume(SEIMasteringDisplayColourVolume& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1164{
1165  UInt code;
1166  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1167
1168  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[0]" ); sei.values.primaries[0][0] = code;
1169  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[0]" ); sei.values.primaries[0][1] = code;
1170
1171  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[1]" ); sei.values.primaries[1][0] = code;
1172  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[1]" ); sei.values.primaries[1][1] = code;
1173
1174  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[2]" ); sei.values.primaries[2][0] = code;
1175  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[2]" ); sei.values.primaries[2][1] = code;
1176
1177
1178  sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_x" ); sei.values.whitePoint[0] = code;
1179  sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_y" ); sei.values.whitePoint[1] = code;
1180
1181  sei_read_code( pDecodedMessageOutputStream, 32, code, "max_display_mastering_luminance" ); sei.values.maxLuminance = code;
1182  sei_read_code( pDecodedMessageOutputStream, 32, code, "min_display_mastering_luminance" ); sei.values.minLuminance = code;
1183}
1184
1185#if NH_MV_SEI_TBD
1186Void SEIReader::xParseSEILayersNotPresent(SEILayersNotPresent& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1187{
1188  UInt code;
1189  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1190
1191  sei_read_code( pDecodedMessageOutputStream, 4, code, "lnp_sei_active_vps_id" ); sei.m_lnpSeiActiveVpsId = code;
1192  for( Int i = 0; i  <=  MaxLayersMinus1; i++ )
1193  {
1194    sei_read_flag( pDecodedMessageOutputStream, code, "layer_not_present_flag" ); sei.m_layerNotPresentFlag[i] = (code == 1);
1195  }
1196};
1197#endif
1198
1199Void SEIReader::xParseSEIInterLayerConstrainedTileSets(SEIInterLayerConstrainedTileSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1200{
1201  UInt code;
1202  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1203
1204  sei_read_flag( pDecodedMessageOutputStream, code, "il_all_tiles_exact_sample_value_match_flag" ); sei.m_ilAllTilesExactSampleValueMatchFlag = (code == 1);
1205  sei_read_flag( pDecodedMessageOutputStream, code, "il_one_tile_per_tile_set_flag"              ); sei.m_ilOneTilePerTileSetFlag             = (code == 1);
1206  if( !sei.m_ilOneTilePerTileSetFlag )
1207  {
1208    sei_read_uvlc( pDecodedMessageOutputStream, code, "il_num_sets_in_message_minus1" ); sei.m_ilNumSetsInMessageMinus1 = code;
1209    if( sei.m_ilNumSetsInMessageMinus1 )
1210    {
1211      sei_read_flag( pDecodedMessageOutputStream, code, "skipped_tile_set_present_flag" ); sei.m_skippedTileSetPresentFlag = (code == 1);
1212    }
1213    Int numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - sei.m_skippedTileSetPresentFlag + 1;
1214   
1215    sei.resizeDimI( numSignificantSets );
1216    for( Int i = 0; i < numSignificantSets; i++ )
1217    {
1218      sei_read_uvlc( pDecodedMessageOutputStream, code, "ilcts_id"                        ); sei.m_ilctsId                  [i] = code;
1219      sei_read_uvlc( pDecodedMessageOutputStream, code, "il_num_tile_rects_in_set_minus1" ); sei.m_ilNumTileRectsInSetMinus1[i] = code;
1220     
1221      sei.resizeDimJ( i, sei.m_ilNumTileRectsInSetMinus1[ i ] + 1 );
1222      for( Int j = 0; j  <=  sei.m_ilNumTileRectsInSetMinus1[ i ]; j++ )
1223      {
1224        sei_read_uvlc( pDecodedMessageOutputStream, code, "il_top_left_tile_index"     ); sei.m_ilTopLeftTileIndex    [i][j] = code;
1225        sei_read_uvlc( pDecodedMessageOutputStream, code, "il_bottom_right_tile_index" ); sei.m_ilBottomRightTileIndex[i][j] = code;
1226      }
1227      sei_read_code( pDecodedMessageOutputStream, 2, code, "ilc_idc" ); sei.m_ilcIdc[i] = code;
1228      if ( !sei.m_ilAllTilesExactSampleValueMatchFlag )
1229      {
1230        sei_read_flag( pDecodedMessageOutputStream, code, "il_exact_sample_value_match_flag" ); sei.m_ilExactSampleValueMatchFlag[i] = (code == 1);
1231      }
1232    }
1233  }
1234  else
1235  {
1236    sei_read_code( pDecodedMessageOutputStream, 2, code, "all_tiles_ilc_idc" ); sei.m_allTilesIlcIdc = code;
1237  }
1238};
1239
1240#if NH_MV_SEI_TBD
1241Void SEIReader::xParseSEIBspNesting(SEIBspNesting& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1242{
1243  UInt code;
1244  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1245
1246  sei_read_uvlc( pDecodedMessageOutputStream, code, "sei_ols_idx" ); sei.m_seiOlsIdx = code;
1247  sei_read_uvlc( pDecodedMessageOutputStream, code, "sei_partitioning_scheme_idx" ); sei.m_seiPartitioningSchemeIdx = code;
1248  sei_read_uvlc( pDecodedMessageOutputStream, code, "bsp_idx" ); sei.m_bspIdx = code;
1249  while( !ByteaLigned(() ) );
1250  {
1251    sei_read_code( pDecodedMessageOutputStream, *equalto0*/u1, code, "bsp_nesting_zero_bit" ); sei.m_bspNestingZeroBit = code;
1252  }
1253  sei_read_uvlc( pDecodedMessageOutputStream, code, "num_seis_in_bsp_minus1" ); sei.m_numSeisInBspMinus1 = code;
1254  for( Int i = 0; i  <=  NumSeisInBspMinus1( ); i++ )
1255  {
1256    SeiMessage(() );
1257  }
1258};
1259
1260Void SEIReader::xParseSEIBspInitialArrivalTime(SEIBspInitialArrivalTime& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1261{
1262  UInt code;
1263  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1264
1265  psIdx = SeiPartitioningSchemeIdx();
1266  if( nalInitialArrivalDelayPresent )
1267  {
1268    for( Int i = 0; i < BspSchedCnt( SeiOlsIdx(), psIdx, MaxTemporalId( 0 ) ); i++ )
1269    {
1270      sei_read_code( pDecodedMessageOutputStream, getNalInitialArrivalDelayLen ), code, "nal_initial_arrival_delay" ); sei.m_nalInitialArrivalDelay[i] = code;
1271    }
1272  }
1273  if( vclInitialArrivalDelayPresent )
1274  {
1275    for( Int i = 0; i < BspSchedCnt( SeiOlsIdx(), psIdx, MaxTemporalId( 0 ) ); i++ )
1276    {
1277      sei_read_code( pDecodedMessageOutputStream, getVclInitialArrivalDelayLen ), code, "vcl_initial_arrival_delay" ); sei.m_vclInitialArrivalDelay[i] = code;
1278    }
1279  }
1280};
1281#endif
1282
1283Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1284{
1285  UInt code;
1286  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1287
1288  sei_read_code( pDecodedMessageOutputStream, 4, code, "sb_property_active_vps_id" ); sei.m_sbPropertyActiveVpsId = code;
1289  sei_read_uvlc( pDecodedMessageOutputStream, code, "num_additional_sub_streams_minus1" ); sei.m_numAdditionalSubStreamsMinus1 = code;
1290  sei.resizeArrays( ); 
1291  for( Int i = 0; i  <=  sei.m_numAdditionalSubStreamsMinus1; i++ )
1292  {
1293    sei_read_code( pDecodedMessageOutputStream, 2, code, "sub_bitstream_mode" ); sei.m_subBitstreamMode[i] = code;
1294    sei_read_uvlc( pDecodedMessageOutputStream, code, "ols_idx_to_vps" ); sei.m_olsIdxToVps[i] = code;
1295    sei_read_code( pDecodedMessageOutputStream, 3, code, "highest_sublayer_id" ); sei.m_highestSublayerId[i] = code;
1296    sei_read_code( pDecodedMessageOutputStream, 16, code, "avg_sb_property_bit_rate" ); sei.m_avgSbPropertyBitRate[i] = code;
1297    sei_read_code( pDecodedMessageOutputStream, 16, code, "max_sb_property_bit_rate" ); sei.m_maxSbPropertyBitRate[i] = code;
1298  }
1299};
1300
1301#if NH_MV_SEI_TBD
1302Void SEIReader::xParseSEIAlphaChannelInfo(SEIAlphaChannelInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1303{
1304  UInt code;
1305  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1306
1307  sei_read_flag( pDecodedMessageOutputStream, code, "alpha_channel_cancel_flag" ); sei.m_alphaChannelCancelFlag = (code == 1);
1308  if( !sei.m_alphaChannelCancelFlag )
1309  {
1310    sei_read_code( pDecodedMessageOutputStream, 3, code, "alpha_channel_use_idc" ); sei.m_alphaChannelUseIdc = code;
1311    sei_read_code( pDecodedMessageOutputStream, 3, code, "alpha_channel_bit_depth_minus8" ); sei.m_alphaChannelBitDepthMinus8 = code;
1312    sei_read_code( pDecodedMessageOutputStream, getAlphaTransparentValueLen ), code, "alpha_transparent_value" ); sei.m_alphaTransparentValue = code;
1313    sei_read_code( pDecodedMessageOutputStream, getAlphaOpaqueValueLen ), code, "alpha_opaque_value" ); sei.m_alphaOpaqueValue = code;
1314    sei_read_flag( pDecodedMessageOutputStream, code, "alpha_channel_incr_flag" ); sei.m_alphaChannelIncrFlag = (code == 1);
1315    sei_read_flag( pDecodedMessageOutputStream, code, "alpha_channel_clip_flag" ); sei.m_alphaChannelClipFlag = (code == 1);
1316    if( sei.m_alphaChannelClipFlag )
1317    {
1318      sei_read_flag( pDecodedMessageOutputStream, code, "alpha_channel_clip_type_flag" ); sei.m_alphaChannelClipTypeFlag = (code == 1);
1319    }
1320  }
1321};
1322
1323Void SEIReader::xParseSEIOverlayInfo(SEIOverlayInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1324{
1325  UInt code;
1326  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1327
1328  sei_read_flag( pDecodedMessageOutputStream, code, "overlay_info_cancel_flag" ); sei.m_overlayInfoCancelFlag = (code == 1);
1329  if( !sei.m_overlayInfoCancelFlag )
1330  {
1331    sei_read_uvlc( pDecodedMessageOutputStream, code, "overlay_content_aux_id_minus128" ); sei.m_overlayContentAuxIdMinus128 = code;
1332    sei_read_uvlc( pDecodedMessageOutputStream, code, "overlay_label_aux_id_minus128" ); sei.m_overlayLabelAuxIdMinus128 = code;
1333    sei_read_uvlc( pDecodedMessageOutputStream, code, "overlay_alpha_aux_id_minus128" ); sei.m_overlayAlphaAuxIdMinus128 = code;
1334    sei_read_uvlc( pDecodedMessageOutputStream, code, "overlay_element_label_value_length_minus8" ); sei.m_overlayElementLabelValueLengthMinus8 = code;
1335    sei_read_uvlc( pDecodedMessageOutputStream, code, "num_overlays_minus1" ); sei.m_numOverlaysMinus1 = code;
1336    for( Int i = 0; i  <=  NumOverlaysMinus1( ); i++ )
1337    {
1338      sei_read_uvlc( pDecodedMessageOutputStream, code, "overlay_idx" ); sei.m_overlayIdx[i] = code;
1339      sei_read_flag( pDecodedMessageOutputStream, code, "language_overlay_present_flag" ); sei.m_languageOverlayPresentFlag[i] = (code == 1);
1340      sei_read_code( pDecodedMessageOutputStream, 6, code, "overlay_content_layer_id" ); sei.m_overlayContentLayerId[i] = code;
1341      sei_read_flag( pDecodedMessageOutputStream, code, "overlay_label_present_flag" ); sei.m_overlayLabelPresentFlag[i] = (code == 1);
1342      if( sei.m_overlayLabelPresentFlag( i ) )
1343      {
1344        sei_read_code( pDecodedMessageOutputStream, 6, code, "overlay_label_layer_id" ); sei.m_overlayLabelLayerId[i] = code;
1345      }
1346      sei_read_flag( pDecodedMessageOutputStream, code, "overlay_alpha_present_flag" ); sei.m_overlayAlphaPresentFlag[i] = (code == 1);
1347      if( sei.m_overlayAlphaPresentFlag( i ) )
1348      {
1349        sei_read_code( pDecodedMessageOutputStream, 6, code, "overlay_alpha_layer_id" ); sei.m_overlayAlphaLayerId[i] = code;
1350      }
1351      if( sei.m_overlayLabelPresentFlag( i ) )
1352      {
1353        sei_read_uvlc( pDecodedMessageOutputStream, code, "num_overlay_elements_minus1" ); sei.m_numOverlayElementsMinus1[i] = code;
1354        for( Int j = 0; j  <=  sei.m_numOverlayElementsMinus1( i ); j++ )
1355        {
1356          sei_read_code( pDecodedMessageOutputStream, getOverlayElementLabelMinLen ), code, "overlay_element_label_min" ); sei.m_overlayElementLabelMin[i][j] = code;
1357          sei_read_code( pDecodedMessageOutputStream, getOverlayElementLabelMaxLen ), code, "overlay_element_label_max" ); sei.m_overlayElementLabelMax[i][j] = code;
1358        }
1359      }
1360    }
1361    while( !ByteaLigned(() ) );
1362    {
1363      sei_read_code( pDecodedMessageOutputStream, *equalto0*/f1, code, "overlay_zero_bit" ); sei.m_overlayZeroBit = code;
1364    }
1365    for( Int i = 0; i  <=  NumOverlaysMinus1( ); i++ )
1366    {
1367      if( sei.m_languageOverlayPresentFlag( i ) )
1368      {
1369        sei_read_code( pDecodedMessageOutputStream, tv, code, "overlay_language" ); sei.m_overlayLanguage[i] = code;
1370      }
1371      sei_read_code( pDecodedMessageOutputStream, tv, code, "overlay_name" ); sei.m_overlayName[i] = code;
1372      if( sei.m_overlayLabelPresentFlag( i ) )
1373      {
1374        for( Int j = 0; j  <=  sei.m_numOverlayElementsMinus1( i ); j++ )
1375        {
1376          sei_read_code( pDecodedMessageOutputStream, tv, code, "overlay_element_name" ); sei.m_overlayElementName[i][j] = code;
1377        }
1378      }
1379    }
1380    sei_read_flag( pDecodedMessageOutputStream, code, "overlay_info_persistence_flag" ); sei.m_overlayInfoPersistenceFlag = (code == 1);
1381  }
1382};
1383#endif
1384
1385Void SEIReader::xParseSEITemporalMvPredictionConstraints(SEITemporalMvPredictionConstraints& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1386{
1387  UInt code;
1388  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1389
1390  sei_read_flag( pDecodedMessageOutputStream, code, "prev_pics_not_used_flag"     ); sei.m_prevPicsNotUsedFlag    = (code == 1);
1391  sei_read_flag( pDecodedMessageOutputStream, code, "no_intra_layer_col_pic_flag" ); sei.m_noIntraLayerColPicFlag = (code == 1);
1392};
1393
1394#if NH_MV_SEI_TBD
1395Void SEIReader::xParseSEIFrameFieldInfo(SEIFrameFieldInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1396{
1397  UInt code;
1398  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1399
1400  sei_read_code( pDecodedMessageOutputStream, 4, code, "ffinfo_pic_struct" ); sei.m_ffinfoPicStruct = code;
1401  sei_read_code( pDecodedMessageOutputStream, 2, code, "ffinfo_source_scan_type" ); sei.m_ffinfoSourceScanType = code;
1402  sei_read_flag( pDecodedMessageOutputStream, code, "ffinfo_duplicate_flag" ); sei.m_ffinfoDuplicateFlag = (code == 1);
1403};
1404
1405Void SEIReader::xParseSEIThreeDimensionalReferenceDisplaysInfo(SEIThreeDimensionalReferenceDisplaysInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1406{
1407  UInt code;
1408  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1409
1410  sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_ref_display_width" ); sei.m_precRefDisplayWidth = code;
1411  sei_read_flag( pDecodedMessageOutputStream, code, "ref_viewing_distance_flag" ); sei.m_refViewingDistanceFlag = (code == 1);
1412  if( sei.m_refViewingDistanceFlag )
1413  {
1414    sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_ref_viewing_dist" ); sei.m_precRefViewingDist = code;
1415  }
1416  sei_read_uvlc( pDecodedMessageOutputStream, code, "num_ref_displays_minus1" ); sei.m_numRefDisplaysMinus1 = code;
1417  for( Int i = 0; i  <=  NumRefDisplaysMinus1( ); i++ )
1418  {
1419    sei_read_uvlc( pDecodedMessageOutputStream, code, "left_view_id" ); sei.m_leftViewId[i] = code;
1420    sei_read_uvlc( pDecodedMessageOutputStream, code, "right_view_id" ); sei.m_rightViewId[i] = code;
1421    sei_read_code( pDecodedMessageOutputStream, 6, code, "exponent_ref_display_width" ); sei.m_exponentRefDisplayWidth[i] = code;
1422    sei_read_code( pDecodedMessageOutputStream, getMantissaRefDisplayWidthLen ), code, "mantissa_ref_display_width" ); sei.m_mantissaRefDisplayWidth[i] = code;
1423    if( sei.m_refViewingDistanceFlag )
1424    {
1425      sei_read_code( pDecodedMessageOutputStream, 6, code, "exponent_ref_viewing_distance" ); sei.m_exponentRefViewingDistance[i] = code;
1426      sei_read_code( pDecodedMessageOutputStream, getMantissaRefViewingDistanceLen ), code, "mantissa_ref_viewing_distance" ); sei.m_mantissaRefViewingDistance[i] = code;
1427    }
1428    sei_read_flag( pDecodedMessageOutputStream, code, "additional_shift_present_flag" ); sei.m_additionalShiftPresentFlag[i] = (code == 1);
1429    if( sei.m_additionalShiftPresentFlag( i ) )
1430    {
1431      sei_read_code( pDecodedMessageOutputStream, 10, code, "num_sample_shift_plus512" ); sei.m_numSampleShiftPlus512[i] = code;
1432    }
1433  }
1434  sei_read_flag( pDecodedMessageOutputStream, code, "three_dimensional_reference_displays_extension_flag" ); sei.m_threeDimensionalReferenceDisplaysExtensionFlag = (code == 1);
1435};
1436
1437Void SEIReader::xParseSEIDepthRepresentationInfo(SEIDepthRepresentationInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1438{
1439  UInt code;
1440  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1441
1442  sei_read_flag( pDecodedMessageOutputStream, code, "z_near_flag" ); sei.m_zNearFlag = (code == 1);
1443  sei_read_flag( pDecodedMessageOutputStream, code, "z_far_flag" ); sei.m_zFarFlag = (code == 1);
1444  sei_read_flag( pDecodedMessageOutputStream, code, "d_min_flag" ); sei.m_dMinFlag = (code == 1);
1445  sei_read_flag( pDecodedMessageOutputStream, code, "d_max_flag" ); sei.m_dMaxFlag = (code == 1);
1446  sei_read_uvlc( pDecodedMessageOutputStream, code, "depth_representation_type" ); sei.m_depthRepresentationType = code;
1447  if( sei.m_dMinFlag  | |  sei.m_dMaxFlag )
1448  {
1449    sei_read_uvlc( pDecodedMessageOutputStream, code, "disparity_ref_view_id" ); sei.m_disparityRefViewId = code;
1450  }
1451  if( sei.m_zNearFlag )
1452  {
1453    DepthRepInfoElement(() ZNearSign, ZNearExp, ZNearMantissa, ZNearManLen );
1454  }
1455  if( sei.m_zFarFlag )
1456  {
1457    DepthRepInfoElement(() ZFarSign, ZFarExp, ZFarMantissa, ZFarManLen );
1458  }
1459  if( sei.m_dMinFlag )
1460  {
1461    DepthRepInfoElement(() DMinSign, DMinExp, DMinMantissa, DMinManLen );
1462  }
1463  if( sei.m_dMaxFlag )
1464  {
1465    DepthRepInfoElement(() DMaxSign, DMaxExp, DMaxMantissa, DMaxManLen );
1466  }
1467  if( sei.m_depthRepresentationType  ==  3 )
1468  {
1469    sei_read_uvlc( pDecodedMessageOutputStream, code, "depth_nonlinear_representation_num_minus1" ); sei.m_depthNonlinearRepresentationNumMinus1 = code;
1470    for( Int i = 1; i  <=  sei.m_depthNonlinearRepresentationNumMinus1 + 1; i++ )
1471    {
1472      DepthNonlinearRepresentationModel( i );
1473    }
1474  }
1475};
1476
1477Void SEIReader::xParseSEIDepthRepInfoElement(SEIDepthRepInfoElement& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1478{
1479  UInt code;
1480  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1481
1482  sei_read_flag( pDecodedMessageOutputStream, code, "da_sign_flag" ); sei.m_daSignFlag = (code == 1);
1483  sei_read_code( pDecodedMessageOutputStream, 7, code, "da_exponent" ); sei.m_daExponent = code;
1484  sei_read_code( pDecodedMessageOutputStream, 5, code, "da_mantissa_len_minus1" ); sei.m_daMantissaLenMinus1 = code;
1485  sei_read_code( pDecodedMessageOutputStream, getDaMantissaLen ), code, "da_mantissa" ); sei.m_daMantissa = code;
1486};
1487#endif
1488Void SEIReader::xParseSEIMultiviewSceneInfo(SEIMultiviewSceneInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1489{
1490  UInt  code;
1491  Int  sCode; 
1492  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1493
1494  sei_read_svlc( pDecodedMessageOutputStream, sCode, "min_disparity" )      ; sei.m_minDisparity      = sCode;
1495  sei_read_uvlc( pDecodedMessageOutputStream, code , "max_disparity_range" ); sei.m_maxDisparityRange = code;
1496};
1497
1498Void SEIReader::xParseSEIMultiviewAcquisitionInfo(SEIMultiviewAcquisitionInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1499{
1500  UInt code;
1501  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1502
1503  sei.resizeArrays( );
1504  sei_read_flag( pDecodedMessageOutputStream, code, "intrinsic_param_flag" ); sei.m_intrinsicParamFlag = (code == 1);
1505  sei_read_flag( pDecodedMessageOutputStream, code, "extrinsic_param_flag" ); sei.m_extrinsicParamFlag = (code == 1);
1506  if( sei.m_intrinsicParamFlag )
1507  {
1508    sei_read_flag( pDecodedMessageOutputStream, code, "intrinsic_params_equal_flag" ); sei.m_intrinsicParamsEqualFlag = (code == 1);
1509    sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_focal_length"           ); sei.m_precFocalLength          =  code      ;
1510    sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_principal_point"        ); sei.m_precPrincipalPoint       =  code      ;
1511    sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_skew_factor"            ); sei.m_precSkewFactor           =  code      ;
1512
1513    for( Int i = 0; i  <=  ( sei.m_intrinsicParamsEqualFlag ? 0 : sei.getNumViewsMinus1() ); i++ )
1514    {     
1515      sei_read_flag( pDecodedMessageOutputStream,                                         code, "sign_focal_length_x"        ); sei.m_signFocalLengthX       [i] = (code == 1);
1516      sei_read_code( pDecodedMessageOutputStream, 6,                                      code, "exponent_focal_length_x"    ); sei.m_exponentFocalLengthX   [i] =  code      ;
1517      sei_read_code( pDecodedMessageOutputStream, sei.getMantissaFocalLengthXLen   ( i ), code, "mantissa_focal_length_x"    ); sei.m_mantissaFocalLengthX   [i] =  code      ;
1518      sei_read_flag( pDecodedMessageOutputStream,                                         code, "sign_focal_length_y"        ); sei.m_signFocalLengthY       [i] = (code == 1);
1519      sei_read_code( pDecodedMessageOutputStream, 6,                                      code, "exponent_focal_length_y"    ); sei.m_exponentFocalLengthY   [i] =  code      ;
1520      sei_read_code( pDecodedMessageOutputStream, sei.getMantissaFocalLengthYLen   ( i ), code, "mantissa_focal_length_y"    ); sei.m_mantissaFocalLengthY   [i] =  code      ;
1521      sei_read_flag( pDecodedMessageOutputStream,                                         code, "sign_principal_point_x"     ); sei.m_signPrincipalPointX    [i] = (code == 1);
1522      sei_read_code( pDecodedMessageOutputStream, 6,                                      code, "exponent_principal_point_x" ); sei.m_exponentPrincipalPointX[i] =  code      ;
1523      sei_read_code( pDecodedMessageOutputStream, sei.getMantissaPrincipalPointXLen( i ), code, "mantissa_principal_point_x" ); sei.m_mantissaPrincipalPointX[i] =  code      ;
1524      sei_read_flag( pDecodedMessageOutputStream,                                         code, "sign_principal_point_y"     ); sei.m_signPrincipalPointY    [i] = (code == 1);
1525      sei_read_code( pDecodedMessageOutputStream, 6,                                      code, "exponent_principal_point_y" ); sei.m_exponentPrincipalPointY[i] =  code      ;
1526      sei_read_code( pDecodedMessageOutputStream, sei.getMantissaPrincipalPointYLen( i ), code, "mantissa_principal_point_y" ); sei.m_mantissaPrincipalPointY[i] =  code      ;
1527      sei_read_flag( pDecodedMessageOutputStream,                                         code, "sign_skew_factor"           ); sei.m_signSkewFactor         [i] = (code == 1);
1528      sei_read_code( pDecodedMessageOutputStream, 6,                                      code, "exponent_skew_factor"       ); sei.m_exponentSkewFactor     [i] =  code      ;
1529      sei_read_code( pDecodedMessageOutputStream, sei.getMantissaSkewFactorLen     ( i ), code, "mantissa_skew_factor"       ); sei.m_mantissaSkewFactor     [i] =  code      ;
1530    }
1531  }
1532  if( sei.m_extrinsicParamFlag )
1533  {
1534    sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_rotation_param"    ); sei.m_precRotationParam    = code;
1535    sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_translation_param" ); sei.m_precTranslationParam = code;
1536
1537    for( Int i = 0; i  <=  sei.getNumViewsMinus1(); i++ )
1538    {
1539      for( Int j = 0; j  <=  2; j++ )  /* row */
1540      {
1541        for( Int k = 0; k  <=  2; k++ )  /* column */
1542        {
1543          sei_read_flag( pDecodedMessageOutputStream,                                 code, "sign_r"     ); sei.m_signR    [i][j][k] = (code == 1);
1544          sei_read_code( pDecodedMessageOutputStream, 6,                              code, "exponent_r" ); sei.m_exponentR[i][j][k] =  code      ;
1545          sei_read_code( pDecodedMessageOutputStream, sei.getMantissaRLen( i, j, k ), code, "mantissa_r" ); sei.m_mantissaR[i][j][k] =  code      ;
1546        }
1547        sei_read_flag( pDecodedMessageOutputStream,                              code, "sign_t"     ); sei.m_signT    [i][j] = (code == 1);
1548        sei_read_code( pDecodedMessageOutputStream, 6,                           code, "exponent_t" ); sei.m_exponentT[i][j] =  code      ;
1549        sei_read_code( pDecodedMessageOutputStream, sei.getMantissaTLen( i, j ), code, "mantissa_t" ); sei.m_mantissaT[i][j] =  code      ;
1550      }
1551    }
1552  }
1553};
1554
1555
1556
1557Void SEIReader::xParseSEIMultiviewViewPosition(SEIMultiviewViewPosition& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1558{
1559  UInt code;
1560  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1561
1562  sei_read_uvlc( pDecodedMessageOutputStream, code, "num_views_minus1" ); sei.m_numViewsMinus1 = code;
1563  sei.m_viewPosition.resize( sei.m_numViewsMinus1 + 1 ); 
1564  for( Int i = 0; i  <=  sei.m_numViewsMinus1; i++ )
1565  {
1566    sei_read_uvlc( pDecodedMessageOutputStream, code, "view_position" ); sei.m_viewPosition[i] = code;
1567  }
1568};
1569
1570#if NH_MV_SEI_TBD
1571Void SEIReader::xParseSEIAlternativeDepthInfo(SEIAlternativeDepthInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1572{
1573  UInt code;
1574  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1575
1576  sei_read_flag( pDecodedMessageOutputStream, code, "alternative_depth_info_cancel_flag" ); sei.m_alternativeDepthInfoCancelFlag = (code == 1);
1577  if( sei.m_alternativeDepthInfoCancelFlag  ==  0 )
1578  {
1579    sei_read_code( pDecodedMessageOutputStream, 2, code, "depth_type" ); sei.m_depthType = code;
1580    if( sei.m_depthType  ==  0 )
1581    {
1582      sei_read_uvlc( pDecodedMessageOutputStream, code, "num_constituent_views_gvd_minus1" ); sei.m_numConstituentViewsGvdMinus1 = code;
1583      sei_read_flag( pDecodedMessageOutputStream, code, "depth_present_gvd_flag" ); sei.m_depthPresentGvdFlag = (code == 1);
1584      sei_read_flag( pDecodedMessageOutputStream, code, "z_gvd_flag" ); sei.m_zGvdFlag = (code == 1);
1585      sei_read_flag( pDecodedMessageOutputStream, code, "intrinsic_param_gvd_flag" ); sei.m_intrinsicParamGvdFlag = (code == 1);
1586      sei_read_flag( pDecodedMessageOutputStream, code, "rotation_gvd_flag" ); sei.m_rotationGvdFlag = (code == 1);
1587      sei_read_flag( pDecodedMessageOutputStream, code, "translation_gvd_flag" ); sei.m_translationGvdFlag = (code == 1);
1588      if( sei.m_zGvdFlag )
1589      {
1590        for( Int i = 0; i  <=  sei.m_numConstituentViewsGvdMinus1 + 1; i++ )
1591        {
1592          sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_z_near_flag" ); sei.m_signGvdZNearFlag[i] = (code == 1);
1593          sei_read_code( pDecodedMessageOutputStream, 7, code, "exp_gvd_z_near" ); sei.m_expGvdZNear[i] = code;
1594          sei_read_code( pDecodedMessageOutputStream, 5, code, "man_len_gvd_z_near_minus1" ); sei.m_manLenGvdZNearMinus1[i] = code;
1595          sei_read_code( pDecodedMessageOutputStream, getManGvdZNearLen ), code, "man_gvd_z_near" ); sei.m_manGvdZNear[i] = code;
1596          sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_z_far_flag" ); sei.m_signGvdZFarFlag[i] = (code == 1);
1597          sei_read_code( pDecodedMessageOutputStream, 7, code, "exp_gvd_z_far" ); sei.m_expGvdZFar[i] = code;
1598          sei_read_code( pDecodedMessageOutputStream, 5, code, "man_len_gvd_z_far_minus1" ); sei.m_manLenGvdZFarMinus1[i] = code;
1599          sei_read_code( pDecodedMessageOutputStream, getManGvdZFarLen ), code, "man_gvd_z_far" ); sei.m_manGvdZFar[i] = code;
1600        }
1601      }
1602      if( sei.m_intrinsicParamGvdFlag )
1603      {
1604        sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_gvd_focal_length" ); sei.m_precGvdFocalLength = code;
1605        sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_gvd_principal_point" ); sei.m_precGvdPrincipalPoint = code;
1606      }
1607      if( sei.m_rotationGvdFlag )
1608      {
1609        sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_gvd_rotation_param" ); sei.m_precGvdRotationParam = code;
1610      }
1611      if( sei.m_translationGvdFlag )
1612      {
1613        sei_read_uvlc( pDecodedMessageOutputStream, code, "prec_gvd_translation_param" ); sei.m_precGvdTranslationParam = code;
1614      }
1615      for( Int i = 0; i  <=  sei.m_numConstituentViewsGvdMinus1 + 1; i++ )
1616      {
1617        if( sei.m_intrinsicParamGvdFlag )
1618        {
1619          sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_focal_length_x" ); sei.m_signGvdFocalLengthX[i] = (code == 1);
1620          sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_focal_length_x" ); sei.m_expGvdFocalLengthX[i] = code;
1621          sei_read_code( pDecodedMessageOutputStream, getManGvdFocalLengthXLen ), code, "man_gvd_focal_length_x" ); sei.m_manGvdFocalLengthX[i] = code;
1622          sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_focal_length_y" ); sei.m_signGvdFocalLengthY[i] = (code == 1);
1623          sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_focal_length_y" ); sei.m_expGvdFocalLengthY[i] = code;
1624          sei_read_code( pDecodedMessageOutputStream, getManGvdFocalLengthYLen ), code, "man_gvd_focal_length_y" ); sei.m_manGvdFocalLengthY[i] = code;
1625          sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_principal_point_x" ); sei.m_signGvdPrincipalPointX[i] = (code == 1);
1626          sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_principal_point_x" ); sei.m_expGvdPrincipalPointX[i] = code;
1627          sei_read_code( pDecodedMessageOutputStream, getManGvdPrincipalPointXLen ), code, "man_gvd_principal_point_x" ); sei.m_manGvdPrincipalPointX[i] = code;
1628          sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_principal_point_y" ); sei.m_signGvdPrincipalPointY[i] = (code == 1);
1629          sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_principal_point_y" ); sei.m_expGvdPrincipalPointY[i] = code;
1630          sei_read_code( pDecodedMessageOutputStream, getManGvdPrincipalPointYLen ), code, "man_gvd_principal_point_y" ); sei.m_manGvdPrincipalPointY[i] = code;
1631        }
1632        if( sei.m_rotationGvdFlag )
1633        {
1634          for( Int j = 10; j  <=  3; j++ ) /* row */
1635          {
1636            for( Int k = 10; k  <=  3; k++ )  /* column */
1637            {
1638              sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_r" ); sei.m_signGvdR[i][j][k] = (code == 1);
1639              sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_r" ); sei.m_expGvdR[i][j][k] = code;
1640              sei_read_code( pDecodedMessageOutputStream, getManGvdRLen ), code, "man_gvd_r" ); sei.m_manGvdR[i][j][k] = code;
1641            }
1642          }
1643        }
1644        if( sei.m_translationGvdFlag )
1645        {
1646          sei_read_flag( pDecodedMessageOutputStream, code, "sign_gvd_t_x" ); sei.m_signGvdTX[i] = (code == 1);
1647          sei_read_code( pDecodedMessageOutputStream, 6, code, "exp_gvd_t_x" ); sei.m_expGvdTX[i] = code;
1648          sei_read_code( pDecodedMessageOutputStream, getManGvdTXLen ), code, "man_gvd_t_x" ); sei.m_manGvdTX[i] = code;
1649        }
1650      }
1651    }
1652    if( sei.m_depthType  ==  1 )
1653    {
1654      sei_read_svlc( pDecodedMessageOutputStream, code, "min_offset_x_int" ); sei.m_minOffsetXInt = code;
1655      sei_read_code( pDecodedMessageOutputStream, 8, code, "min_offset_x_frac" ); sei.m_minOffsetXFrac = code;
1656      sei_read_svlc( pDecodedMessageOutputStream, code, "max_offset_x_int" ); sei.m_maxOffsetXInt = code;
1657      sei_read_code( pDecodedMessageOutputStream, 8, code, "max_offset_x_frac" ); sei.m_maxOffsetXFrac = code;
1658      sei_read_flag( pDecodedMessageOutputStream, code, "offset_y_present_flag" ); sei.m_offsetYPresentFlag = (code == 1);
1659      if( sei.m_offsetYPresentFlag )
1660      {
1661        sei_read_svlc( pDecodedMessageOutputStream, code, "min_offset_y_int" ); sei.m_minOffsetYInt = code;
1662        sei_read_code( pDecodedMessageOutputStream, 8, code, "min_offset_y_frac" ); sei.m_minOffsetYFrac = code;
1663        sei_read_svlc( pDecodedMessageOutputStream, code, "max_offset_y_int" ); sei.m_maxOffsetYInt = code;
1664        sei_read_code( pDecodedMessageOutputStream, 8, code, "max_offset_y_frac" ); sei.m_maxOffsetYFrac = code;
1665      }
1666      sei_read_flag( pDecodedMessageOutputStream, code, "warp_map_size_present_flag" ); sei.m_warpMapSizePresentFlag = (code == 1);
1667      if( sei.m_warpMapSizePresentFlag )
1668      {
1669        sei_read_uvlc( pDecodedMessageOutputStream, code, "warp_map_width_minus2" ); sei.m_warpMapWidthMinus2 = code;
1670        sei_read_uvlc( pDecodedMessageOutputStream, code, "warp_map_height_minus2" ); sei.m_warpMapHeightMinus2 = code;
1671      }
1672    }
1673  }
1674};
1675#endif
1676
1677//! \}
Note: See TracBrowser for help on using the repository browser.