source: 3DVCSoftware/branches/HTM-15.2-dev/source/Lib/TLibDecoder/SEIread.cpp @ 1360

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

Update to HM-16.7.

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