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

Last change on this file since 1337 was 1337, checked in by ericsson, 9 years ago

Integration of the 3D reference displays information SEI message.

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