source: SHVCSoftware/branches/SHM-dev/source/Lib/TLibDecoder/SEIread.cpp @ 1096

Last change on this file since 1096 was 1096, checked in by seregin, 9 years ago

cleanup macros: REMOVE_BSP_HRD_SEI

  • Property svn:eol-style set to native
File size: 90.2 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license.
5 *
6 * Copyright (c) 2010-2014, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/**
35 \file     SEIread.cpp
36 \brief    reading funtionality for SEI messages
37 */
38
39#include "TLibCommon/CommonDef.h"
40#include "TLibCommon/TComBitStream.h"
41#include "TLibCommon/SEI.h"
42#include "TLibCommon/TComSlice.h"
43#include "SyntaxElementParser.h"
44#include "SEIread.h"
45#include "TLibCommon/TComPicYuv.h"
46#include <iomanip>
47
48
49//! \ingroup TLibDecoder
50//! \{
51
52
53#if ENC_DEC_TRACE
54Void  xTraceSEIHeader()
55{
56  fprintf( g_hTrace, "=========== SEI message ===========\n");
57}
58
59Void  xTraceSEIMessageType(SEI::PayloadType payloadType)
60{
61  fprintf( g_hTrace, "=========== %s SEI message ===========\n", SEI::getSEIMessageString(payloadType));
62}
63#endif
64
65Void SEIReader::sei_read_code(std::ostream *pOS, UInt uiLength, UInt& ruiCode, const Char *pSymbolName)
66{
67  READ_CODE(uiLength, ruiCode, pSymbolName);
68  if (pOS)      (*pOS) << "  " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n";
69}
70
71Void SEIReader::sei_read_uvlc(std::ostream *pOS, UInt& ruiCode, const Char *pSymbolName)
72{
73  READ_UVLC(ruiCode, pSymbolName);
74  if (pOS)      (*pOS) << "  " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n";
75}
76
77Void SEIReader::sei_read_svlc(std::ostream *pOS, Int& ruiCode, const Char *pSymbolName)
78{
79  READ_SVLC(ruiCode, pSymbolName);
80  if (pOS)      (*pOS) << "  " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n";
81}
82
83Void SEIReader::sei_read_flag(std::ostream *pOS, UInt& ruiCode, const Char *pSymbolName)
84{
85  READ_FLAG(ruiCode, pSymbolName);
86  if (pOS)      (*pOS) << "  " << std::setw(55) << pSymbolName << ": " << (ruiCode?1:0) << "\n";
87}
88
89static inline Void output_sei_message_header(SEI &sei, std::ostream *pDecodedMessageOutputStream, UInt payloadSize)
90{
91  if (pDecodedMessageOutputStream)
92  {
93    std::string seiMessageHdr(SEI::getSEIMessageString(sei.payloadType())); seiMessageHdr+=" SEI message";
94    (*pDecodedMessageOutputStream) << std::setfill('-') << std::setw(seiMessageHdr.size()) << "-" << std::setfill(' ') << "\n" << seiMessageHdr << "\n";
95  }
96}
97
98#undef READ_CODE
99#undef READ_SVLC
100#undef READ_UVLC
101#undef READ_FLAG
102
103
104/**
105 * unmarshal a single SEI message from bitstream bs
106 */
107#if LAYERS_NOT_PRESENT_SEI
108Void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
109#else
110Void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
111#endif
112{
113  setBitstream(bs);
114
115  assert(!m_pcBitstream->getNumBitsUntilByteAligned());
116  do
117  {
118#if LAYERS_NOT_PRESENT_SEI
119    xReadSEImessage(seis, nalUnitType, vps, sps, pDecodedMessageOutputStream);
120#else
121    xReadSEImessage(seis, nalUnitType, sps, pDecodedMessageOutputStream);
122#endif
123    /* SEI messages are an integer number of bytes, something has failed
124    * in the parsing if bitstream not byte-aligned */
125    assert(!m_pcBitstream->getNumBitsUntilByteAligned());
126  } while (m_pcBitstream->getNumBitsLeft() > 8);
127
128  UInt rbspTrailingBits;
129  sei_read_code(NULL, 8, rbspTrailingBits, "rbsp_trailing_bits");
130  assert(rbspTrailingBits == 0x80);
131}
132
133#if O0164_MULTI_LAYER_HRD
134#if LAYERS_NOT_PRESENT_SEI
135Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream, const SEIScalableNesting *nestingSei, const SEIBspNesting *bspNestingSei)
136#else
137Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, std::ostream *pDecodedMessageOutputStream, const SEIScalableNesting *nestingSei)
138#endif
139#else
140#if LAYERS_NOT_PRESENT_SEI
141Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
142#else
143Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
144#endif
145#endif
146{
147#if ENC_DEC_TRACE
148  xTraceSEIHeader();
149#endif
150  Int payloadType = 0;
151  UInt val = 0;
152
153  do
154  {
155    sei_read_code(NULL, 8, val, "payload_type");
156    payloadType += val;
157  } while (val==0xFF);
158
159  UInt payloadSize = 0;
160  do
161  {
162    sei_read_code(NULL, 8, val, "payload_size");
163    payloadSize += val;
164  } while (val==0xFF);
165
166#if ENC_DEC_TRACE
167  xTraceSEIMessageType((SEI::PayloadType)payloadType);
168#endif
169
170  /* extract the payload for this single SEI message.
171   * This allows greater safety in erroneous parsing of an SEI message
172   * from affecting subsequent messages.
173   * After parsing the payload, bs needs to be restored as the primary
174   * bitstream.
175   */
176  TComInputBitstream *bs = getBitstream();
177  setBitstream(bs->extractSubstream(payloadSize * 8));
178
179  SEI *sei = NULL;
180
181  if(nalUnitType == NAL_UNIT_PREFIX_SEI)
182  {
183    switch (payloadType)
184    {
185    case SEI::USER_DATA_UNREGISTERED:
186      sei = new SEIuserDataUnregistered;
187      xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream);
188      break;
189    case SEI::ACTIVE_PARAMETER_SETS:
190      sei = new SEIActiveParameterSets;
191      xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize, pDecodedMessageOutputStream);
192      break;
193    case SEI::DECODING_UNIT_INFO:
194      if (!sps)
195      {
196        printf ("Warning: Found Decoding unit SEI message, but no active SPS is available. Ignoring.");
197      }
198      else
199      {
200        sei = new SEIDecodingUnitInfo;
201#if VPS_VUI_BSP_HRD_PARAMS
202        xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, nestingSei, bspNestingSei, vps, pDecodedMessageOutputStream);
203#else       
204        xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, pDecodedMessageOutputStream);
205#endif
206      }
207      break;
208    case SEI::BUFFERING_PERIOD:
209      if (!sps)
210      {
211        printf ("Warning: Found Buffering period SEI message, but no active SPS is available. Ignoring.");
212      }
213      else
214      {
215        sei = new SEIBufferingPeriod;
216#if VPS_VUI_BSP_HRD_PARAMS
217        xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, nestingSei, bspNestingSei, vps, pDecodedMessageOutputStream);
218#else
219        xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, pDecodedMessageOutputStream);
220#endif
221      }
222      break;
223    case SEI::PICTURE_TIMING:
224      if (!sps)
225      {
226        printf ("Warning: Found Picture timing SEI message, but no active SPS is available. Ignoring.");
227      }
228      else
229      {
230        sei = new SEIPictureTiming;
231#if VPS_VUI_BSP_HRD_PARAMS
232        xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, nestingSei, bspNestingSei, vps, pDecodedMessageOutputStream);
233#else
234        xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, pDecodedMessageOutputStream);
235#endif
236      }
237      break;
238    case SEI::RECOVERY_POINT:
239      sei = new SEIRecoveryPoint;
240      xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize, pDecodedMessageOutputStream);
241      break;
242    case SEI::FRAME_PACKING:
243      sei = new SEIFramePacking;
244      xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream);
245      break;
246    case SEI::SEGM_RECT_FRAME_PACKING:
247      sei = new SEISegmentedRectFramePacking;
248      xParseSEISegmentedRectFramePacking((SEISegmentedRectFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream);
249      break;
250    case SEI::DISPLAY_ORIENTATION:
251      sei = new SEIDisplayOrientation;
252      xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize, pDecodedMessageOutputStream);
253      break;
254    case SEI::TEMPORAL_LEVEL0_INDEX:
255      sei = new SEITemporalLevel0Index;
256      xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize, pDecodedMessageOutputStream);
257      break;
258    case SEI::REGION_REFRESH_INFO:
259      sei = new SEIGradualDecodingRefreshInfo;
260      xParseSEIRegionRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
261      break;
262    case SEI::NO_DISPLAY:
263      sei = new SEINoDisplay;
264      xParseSEINoDisplay((SEINoDisplay&) *sei, payloadSize, pDecodedMessageOutputStream);
265      break;
266    case SEI::TONE_MAPPING_INFO:
267      sei = new SEIToneMappingInfo;
268      xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
269      break;
270    case SEI::SOP_DESCRIPTION:
271      sei = new SEISOPDescription;
272      xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize, pDecodedMessageOutputStream);
273      break;
274    case SEI::SCALABLE_NESTING:
275      sei = new SEIScalableNesting;
276#if LAYERS_NOT_PRESENT_SEI
277      xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, vps, sps, pDecodedMessageOutputStream);
278#else
279      xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps, pDecodedMessageOutputStream);
280#endif
281      break;
282    case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS:
283      sei = new SEITempMotionConstrainedTileSets;
284      xParseSEITempMotionConstraintsTileSets((SEITempMotionConstrainedTileSets&) *sei, payloadSize, pDecodedMessageOutputStream);
285      break;
286    case SEI::TIME_CODE:
287      sei = new SEITimeCode;
288      xParseSEITimeCode((SEITimeCode&) *sei, payloadSize, pDecodedMessageOutputStream);
289      break;
290    case SEI::CHROMA_SAMPLING_FILTER_HINT:
291      sei = new SEIChromaSamplingFilterHint;
292      xParseSEIChromaSamplingFilterHint((SEIChromaSamplingFilterHint&) *sei, payloadSize/*, sps*/, pDecodedMessageOutputStream);
293      //}
294      break;
295    case SEI::KNEE_FUNCTION_INFO:
296      sei = new SEIKneeFunctionInfo;
297      xParseSEIKneeFunctionInfo((SEIKneeFunctionInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
298      break;
299    case SEI::MASTERING_DISPLAY_COLOUR_VOLUME:
300      sei = new SEIMasteringDisplayColourVolume;
301      xParseSEIMasteringDisplayColourVolume((SEIMasteringDisplayColourVolume&) *sei, payloadSize, pDecodedMessageOutputStream);
302      break;
303#if Q0074_COLOUR_REMAPPING_SEI
304    case SEI::COLOUR_REMAPPING_INFO:
305      sei = new SEIColourRemappingInfo;
306      xParseSEIColourRemappingInfo((SEIColourRemappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
307      break;
308#endif
309#if SVC_EXTENSION
310#if LAYERS_NOT_PRESENT_SEI
311    case SEI::LAYERS_NOT_PRESENT:
312      if (!vps)
313      {
314        printf ("Warning: Found Layers not present SEI message, but no active VPS is available. Ignoring.");
315      }
316      else
317      {
318        sei = new SEILayersNotPresent;
319        xParseSEILayersNotPresent((SEILayersNotPresent&) *sei, payloadSize, vps, pDecodedMessageOutputStream);
320      }
321      break;
322#endif
323#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
324    case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS:
325      sei = new SEIInterLayerConstrainedTileSets;
326      xParseSEIInterLayerConstrainedTileSets((SEIInterLayerConstrainedTileSets&) *sei, payloadSize, pDecodedMessageOutputStream);
327      break;
328#endif
329#if SUB_BITSTREAM_PROPERTY_SEI
330   case SEI::SUB_BITSTREAM_PROPERTY:
331     sei = new SEISubBitstreamProperty;
332#if OLS_IDX_CHK
333     xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, vps, pDecodedMessageOutputStream);
334#else
335     xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, pDecodedMessageOutputStream);
336#endif
337     break;
338#endif
339#if O0164_MULTI_LAYER_HRD
340   case SEI::BSP_NESTING:
341     sei = new SEIBspNesting;
342#if LAYERS_NOT_PRESENT_SEI
343     xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, vps, sps, *nestingSei, pDecodedMessageOutputStream);
344#else
345     xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, sps, *nestingSei, pDecodedMessageOutputStream);
346#endif
347     break;
348   case SEI::BSP_INITIAL_ARRIVAL_TIME:
349     sei = new SEIBspInitialArrivalTime;
350     xParseSEIBspInitialArrivalTime((SEIBspInitialArrivalTime&) *sei, vps, sps, *nestingSei, *bspNestingSei, pDecodedMessageOutputStream);
351     break;
352#endif
353#if Q0078_ADD_LAYER_SETS
354   case SEI::OUTPUT_LAYER_SET_NESTING:
355     sei = new SEIOutputLayerSetNesting;
356#if LAYERS_NOT_PRESENT_SEI
357     xParseSEIOutputLayerSetNesting((SEIOutputLayerSetNesting&)*sei, nalUnitType, vps, sps, pDecodedMessageOutputStream);
358#else
359     xParseSEIOutputLayerSetNesting((SEIOutputLayerSetNesting&)*sei, nalUnitType, sps, pDecodedMessageOutputStream);
360#endif
361     break;
362   case SEI::VPS_REWRITING:
363     sei = new SEIVPSRewriting;
364     xParseSEIVPSRewriting((SEIVPSRewriting&)*sei, pDecodedMessageOutputStream);
365     break;
366#endif
367#if Q0189_TMVP_CONSTRAINTS
368   case SEI::TMVP_CONSTRAINTS:
369     sei =  new SEITMVPConstrains;
370     xParseSEITMVPConstraints((SEITMVPConstrains&) *sei, payloadSize, pDecodedMessageOutputStream);
371     break;
372#endif
373#if Q0247_FRAME_FIELD_INFO
374   case SEI::FRAME_FIELD_INFO:
375     sei =  new SEIFrameFieldInfo;
376     xParseSEIFrameFieldInfo    ((SEIFrameFieldInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
377     break;
378#endif
379#if P0123_ALPHA_CHANNEL_SEI
380   case SEI::ALPHA_CHANNEL_INFO:
381     sei = new SEIAlphaChannelInfo;
382     xParseSEIAlphaChannelInfo((SEIAlphaChannelInfo &) *sei, payloadSize, pDecodedMessageOutputStream);
383     break;
384#endif
385#if Q0096_OVERLAY_SEI
386   case SEI::OVERLAY_INFO:
387     sei = new SEIOverlayInfo;
388     xParseSEIOverlayInfo((SEIOverlayInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
389     break;
390#endif
391#endif //SVC_EXTENSION
392   default:
393     for (UInt i = 0; i < payloadSize; i++)
394     {
395       UInt seiByte;
396       sei_read_code (NULL, 8, seiByte, "unknown prefix SEI payload byte");
397     }
398     printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType);
399     if (pDecodedMessageOutputStream)
400     {
401       (*pDecodedMessageOutputStream) << "Unknown prefix SEI message (payloadType = " << payloadType << ") was found!\n";
402     }
403     break;
404    }
405  }
406  else
407  {
408    switch (payloadType)
409    {
410      case SEI::USER_DATA_UNREGISTERED:
411        sei = new SEIuserDataUnregistered;
412        xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream);
413        break;
414      case SEI::DECODED_PICTURE_HASH:
415        sei = new SEIDecodedPictureHash;
416        xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize, pDecodedMessageOutputStream);
417        break;
418      default:
419        for (UInt i = 0; i < payloadSize; i++)
420        {
421          UInt seiByte;
422          sei_read_code( NULL, 8, seiByte, "unknown suffix SEI payload byte");
423        }
424        printf ("Unknown suffix SEI message (payloadType = %d) was found!\n", payloadType);
425        if (pDecodedMessageOutputStream)
426        {
427          (*pDecodedMessageOutputStream) << "Unknown suffix SEI message (payloadType = " << payloadType << ") was found!\n";
428        }
429        break;
430    }
431  }
432
433  if (sei != NULL)
434  {
435    seis.push_back(sei);
436  }
437
438  /* By definition the underlying bitstream terminates in a byte-aligned manner.
439   * 1. Extract all bar the last MIN(bitsremaining,nine) bits as reserved_payload_extension_data
440   * 2. Examine the final 8 bits to determine the payload_bit_equal_to_one marker
441   * 3. Extract the remainingreserved_payload_extension_data bits.
442   *
443   * If there are fewer than 9 bits available, extract them.
444   */
445  Int payloadBitsRemaining = getBitstream()->getNumBitsLeft();
446  if (payloadBitsRemaining) /* more_data_in_payload() */
447  {
448    for (; payloadBitsRemaining > 9; payloadBitsRemaining--)
449    {
450      UInt reservedPayloadExtensionData;
451      sei_read_code ( pDecodedMessageOutputStream, 1, reservedPayloadExtensionData, "reserved_payload_extension_data");
452    }
453
454    /* 2 */
455    Int finalBits = getBitstream()->peekBits(payloadBitsRemaining);
456    Int finalPayloadBits = 0;
457    for (Int mask = 0xff; finalBits & (mask >> finalPayloadBits); finalPayloadBits++)
458    {
459      continue;
460    }
461
462    /* 3 */
463    for (; payloadBitsRemaining > 9 - finalPayloadBits; payloadBitsRemaining--)
464    {
465      UInt reservedPayloadExtensionData;
466      sei_read_flag ( 0, reservedPayloadExtensionData, "reserved_payload_extension_data");
467    }
468
469    UInt dummy;
470    sei_read_flag( 0, dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--;
471    while (payloadBitsRemaining)
472    {
473      sei_read_flag( 0, dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--;
474    }
475  }
476
477  /* restore primary bitstream for sei_message */
478  getBitstream()->deleteFifo();
479  delete getBitstream();
480  setBitstream(bs);
481}
482
483/**
484 * parse bitstream bs and unpack a user_data_unregistered SEI message
485 * of payloasSize bytes into sei.
486 */
487
488Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
489{
490  assert(payloadSize >= ISO_IEC_11578_LEN);
491  UInt val;
492  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
493
494  for (UInt i = 0; i < ISO_IEC_11578_LEN; i++)
495  {
496    sei_read_code( pDecodedMessageOutputStream, 8, val, "uuid_iso_iec_11578");
497    sei.uuid_iso_iec_11578[i] = val;
498  }
499
500  sei.userDataLength = payloadSize - ISO_IEC_11578_LEN;
501  if (!sei.userDataLength)
502  {
503    sei.userData = 0;
504    return;
505  }
506
507  sei.userData = new UChar[sei.userDataLength];
508  for (UInt i = 0; i < sei.userDataLength; i++)
509  {
510    sei_read_code( pDecodedMessageOutputStream, 8, val, "user_data" );
511    sei.userData[i] = val;
512  }
513}
514
515/**
516 * parse bitstream bs and unpack a decoded picture hash SEI message
517 * of payloadSize bytes into sei.
518 */
519Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
520{
521  UInt bytesRead = 0;
522  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
523
524  UInt val;
525  sei_read_code( pDecodedMessageOutputStream, 8, val, "hash_type");
526  sei.method = static_cast<SEIDecodedPictureHash::Method>(val); bytesRead++;
527
528  const Char *traceString="\0";
529  switch (sei.method)
530  {
531    case SEIDecodedPictureHash::MD5: traceString="picture_md5"; break;
532    case SEIDecodedPictureHash::CRC: traceString="picture_crc"; break;
533    case SEIDecodedPictureHash::CHECKSUM: traceString="picture_checksum"; break;
534    default: assert(false); break;
535  }
536
537  if (pDecodedMessageOutputStream) (*pDecodedMessageOutputStream) << "  " << std::setw(55) << traceString << ": " << std::hex << std::setfill('0');
538
539  sei.m_digest.hash.clear();
540  for(;bytesRead < payloadSize; bytesRead++)
541  {
542    sei_read_code( NULL, 8, val, traceString);
543    sei.m_digest.hash.push_back((UChar)val);
544    if (pDecodedMessageOutputStream) (*pDecodedMessageOutputStream) << std::setw(2) << val;
545  }
546
547  if (pDecodedMessageOutputStream) (*pDecodedMessageOutputStream) << std::dec << std::setfill(' ') << "\n";
548}
549
550Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
551{
552  UInt val; 
553  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
554
555  sei_read_code( pDecodedMessageOutputStream, 4, val, "active_video_parameter_set_id");   sei.activeVPSId = val;
556  sei_read_flag( pDecodedMessageOutputStream,    val, "self_contained_cvs_flag");         sei.m_selfContainedCvsFlag     = (val != 0);
557  sei_read_flag( pDecodedMessageOutputStream,    val, "no_parameter_set_update_flag");    sei.m_noParameterSetUpdateFlag = (val != 0);
558  sei_read_uvlc( pDecodedMessageOutputStream,    val, "num_sps_ids_minus1");              sei.numSpsIdsMinus1 = val;
559
560  sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1);
561#if R0247_SEI_ACTIVE
562  sei.layerSpsIdx.resize(sei.numSpsIdsMinus1 + 1);
563#endif
564  for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++)
565  {
566    sei_read_uvlc( pDecodedMessageOutputStream, val, "active_seq_parameter_set_id[i]");    sei.activeSeqParameterSetId[i] = val;
567  }
568#if R0247_SEI_ACTIVE
569  for (Int i=1; i < (sei.numSpsIdsMinus1 + 1); i++)
570  {
571    sei_read_uvlc( pDecodedMessageOutputStream, val, "layer_sps_idx"); sei.layerSpsIdx[i] = val; 
572  }
573#endif 
574}
575
576#if VPS_VUI_BSP_HRD_PARAMS
577Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps,std::ostream *pDecodedMessageOutputStream)
578#else
579Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt payloadSize, TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
580#endif
581{
582  UInt val;
583  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
584  sei_read_uvlc( pDecodedMessageOutputStream, val, "decoding_unit_idx");
585  sei.m_decodingUnitIdx = val;
586
587#if VPS_VUI_BSP_HRD_PARAMS
588  TComHRD *hrd;
589  if( bspNestingSei )   // If DU info SEI contained inside a BSP nesting SEI message
590  {
591    assert( nestingSei );
592    Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx;
593    Int seiOlsIdx = bspNestingSei->m_seiOlsIdx;
594    Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1;
595    Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1;
596    std::vector<Int> hrdIdx(maxValues, 0);
597    std::vector<TComHRD *> hrdVec;
598    std::vector<Int> syntaxElemLen(maxValues, 0);
599    for(Int i = 0; i < maxValues; i++)
600    {
601      hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx);
602      hrdVec.push_back(vps->getBspHrd(hrdIdx[i]));
603   
604      syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1;
605      if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) )
606      {
607        assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23
608      }
609      if( i > 0 )
610      {
611        assert( hrdVec[i]->getSubPicCpbParamsPresentFlag()    == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() );
612        assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag()   == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() );
613        assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1()  == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() );
614        // To be done: Check CpbDpbDelaysPresentFlag
615      }
616    }
617    hrd = hrdVec[0];
618  }
619  else
620  {
621    TComVUI *vui = sps->getVuiParameters();
622    hrd = vui->getHrdParameters();
623  }
624
625  if(hrd->getSubPicCpbParamsInPicTimingSEIFlag())
626  {
627    sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay_increment");
628    sei.m_duSptCpbRemovalDelay = val;
629  }
630  else
631  {
632    sei.m_duSptCpbRemovalDelay = 0;
633  }
634  sei_read_flag( pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = (val != 0);
635  if(sei.m_dpbOutputDuDelayPresentFlag)
636  {
637    sei_read_code( pDecodedMessageOutputStream, hrd->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay");
638    sei.m_picSptDpbOutputDuDelay = val;
639  }
640#else
641  TComVUI *vui = sps->getVuiParameters(); 
642
643  if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag())
644  {
645    sei_read_code( pDecodedMessageOutputStream, ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay_increment");
646    sei.m_duSptCpbRemovalDelay = val;
647  }
648  else
649  {
650    sei.m_duSptCpbRemovalDelay = 0;
651  }
652  sei_read_flag( pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = (val != 0);
653  if(sei.m_dpbOutputDuDelayPresentFlag)
654  {
655    sei_read_code( pDecodedMessageOutputStream, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay");
656    sei.m_picSptDpbOutputDuDelay = val;
657  }
658#endif
659}
660
661#if VPS_VUI_BSP_HRD_PARAMS
662Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps, std::ostream *pDecodedMessageOutputStream)
663#else
664Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt payloadSize, TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
665#endif
666{
667  Int i, nalOrVcl;
668  UInt code;
669
670#if VPS_VUI_BSP_HRD_PARAMS
671  TComHRD *pHRD;
672  if( bspNestingSei )   // If BP SEI contained inside a BSP nesting SEI message
673  {
674    assert( nestingSei );
675    Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx;
676    Int seiOlsIdx = bspNestingSei->m_seiOlsIdx;
677    Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1;
678    Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1;
679    std::vector<Int> hrdIdx(maxValues, 0);
680    std::vector<TComHRD *> hrdVec;
681    std::vector<Int> syntaxElemLen(maxValues, 0);
682    for(i = 0; i < maxValues; i++)
683    {
684      hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx);
685      hrdVec.push_back(vps->getBspHrd(hrdIdx[i]));
686   
687      syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1;
688      if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) )
689      {
690        assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23
691      }
692      if( i > 0 )
693      {
694        assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1()   == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() );
695        assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1()  == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() );
696        assert( hrdVec[i]->getSubPicCpbParamsPresentFlag()    == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() );
697      }
698    }
699    pHRD = hrdVec[i];
700  }
701  else
702  {
703    TComVUI *vui = sps->getVuiParameters();
704    pHRD = vui->getHrdParameters();
705  }
706  // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently.
707#else
708  TComVUI *pVUI = sps->getVuiParameters();
709  TComHRD *pHRD = pVUI->getHrdParameters();
710#endif
711
712  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
713
714  sei_read_uvlc( pDecodedMessageOutputStream, code, "bp_seq_parameter_set_id" );                         sei.m_bpSeqParameterSetId     = code;
715  if( !pHRD->getSubPicCpbParamsPresentFlag() )
716  {
717    sei_read_flag( pDecodedMessageOutputStream, code, "irap_cpb_params_present_flag" );                   sei.m_rapCpbParamsPresentFlag = code;
718  }
719  if( sei.m_rapCpbParamsPresentFlag )
720  {
721    sei_read_code( pDecodedMessageOutputStream, pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" );      sei.m_cpbDelayOffset = code;
722    sei_read_code( pDecodedMessageOutputStream, pHRD->getDpbOutputDelayLengthMinus1()  + 1, code, "dpb_delay_offset" );      sei.m_dpbDelayOffset = code;
723  }
724
725  //read splicing flag and cpb_removal_delay_delta
726  sei_read_flag( pDecodedMessageOutputStream, code, "concatenation_flag");
727  sei.m_concatenationFlag = code;
728  sei_read_code( pDecodedMessageOutputStream, ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" );
729  sei.m_auCpbRemovalDelayDelta = code + 1;
730
731  for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
732  {
733    if( ( ( nalOrVcl == 0 ) && ( pHRD->getNalHrdParametersPresentFlag() ) ) ||
734        ( ( nalOrVcl == 1 ) && ( pHRD->getVclHrdParametersPresentFlag() ) ) )
735    {
736      for( i = 0; i < ( pHRD->getCpbCntMinus1( 0 ) + 1 ); i ++ )
737      {
738        sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_delay":"nal_initial_cpb_removal_delay" );
739        sei.m_initialCpbRemovalDelay[i][nalOrVcl] = code;
740        sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_offset":"vcl_initial_cpb_removal_offset" );
741        sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl] = code;
742        if( pHRD->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag )
743        {
744          sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_delay":"vcl_initial_alt_cpb_removal_delay" );
745          sei.m_initialAltCpbRemovalDelay[i][nalOrVcl] = code;
746          sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_offset":"vcl_initial_alt_cpb_removal_offset" );
747          sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl] = code;
748        }
749      }
750    }
751  }
752
753#if P0138_USE_ALT_CPB_PARAMS_FLAG
754  sei.m_useAltCpbParamsFlag = false;
755  sei.m_useAltCpbParamsFlagPresent = false;
756  if (xPayloadExtensionPresent())
757  {
758    sei_read_flag( pDecodedMessageOutputStream, code, "use_alt_cpb_params_flag");
759    sei.m_useAltCpbParamsFlag = code;
760    sei.m_useAltCpbParamsFlagPresent = true;
761  }
762#endif
763}
764
765#if VPS_VUI_BSP_HRD_PARAMS
766Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps, std::ostream *pDecodedMessageOutputStream)
767#else
768Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt payloadSize, TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
769#endif
770{
771  Int i;
772  UInt code;
773
774#if VPS_VUI_BSP_HRD_PARAMS
775  TComHRD *hrd;   
776  TComVUI *vui = sps->getVuiParameters(); 
777  if( bspNestingSei )   // If BP SEI contained inside a BSP nesting SEI message
778  {
779    assert( nestingSei );
780    Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx;
781    Int seiOlsIdx = bspNestingSei->m_seiOlsIdx;
782    Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1;
783    Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1;
784    std::vector<Int> hrdIdx(maxValues, 0);
785    std::vector<TComHRD *> hrdVec;
786    std::vector<Int> syntaxElemLen(maxValues, 0);
787    for(i = 0; i < maxValues; i++)
788    {
789      hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx);
790      hrdVec.push_back(vps->getBspHrd(hrdIdx[i]));
791   
792      syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1;
793      if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) )
794      {
795        assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23
796      }
797      if( i > 0 )
798      {
799        assert( hrdVec[i]->getSubPicCpbParamsPresentFlag()    == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() );
800        assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag()   == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() );
801        assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1()  == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() );
802        assert( hrdVec[i]->getDpbOutputDelayLengthMinus1()  == hrdVec[i-1]->getDpbOutputDelayLengthMinus1() );
803        assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1()  == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() );
804        assert( hrdVec[i]->getDuCpbRemovalDelayLengthMinus1()  == hrdVec[i-1]->getDuCpbRemovalDelayLengthMinus1() );
805        // To be done: Check CpbDpbDelaysPresentFlag
806      }
807    }
808    hrd = hrdVec[0];
809  }
810  else
811  {
812    hrd = vui->getHrdParameters();
813  }
814  // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently.
815#else
816  TComVUI *vui = sps->getVuiParameters();
817  TComHRD *hrd = vui->getHrdParameters();
818#endif
819  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
820
821  if( vui->getFrameFieldInfoPresentFlag() )
822  {
823    sei_read_code( pDecodedMessageOutputStream, 4, code, "pic_struct" );             sei.m_picStruct            = code;
824    sei_read_code( pDecodedMessageOutputStream, 2, code, "source_scan_type" );       sei.m_sourceScanType       = code;
825    sei_read_flag( pDecodedMessageOutputStream,    code, "duplicate_flag" );         sei.m_duplicateFlag        = (code == 1);
826  }
827
828  if( hrd->getCpbDpbDelaysPresentFlag())
829  {
830    sei_read_code( pDecodedMessageOutputStream, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" );
831    sei.m_auCpbRemovalDelay = code + 1;
832    sei_read_code( pDecodedMessageOutputStream, ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" );
833    sei.m_picDpbOutputDelay = code;
834
835    if(hrd->getSubPicCpbParamsPresentFlag())
836    {
837      sei_read_code( pDecodedMessageOutputStream, hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" );
838      sei.m_picDpbOutputDuDelay = code;
839    }
840
841    if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() )
842    {
843      sei_read_uvlc( pDecodedMessageOutputStream, code, "num_decoding_units_minus1");
844      sei.m_numDecodingUnitsMinus1 = code;
845      sei_read_flag( pDecodedMessageOutputStream, code, "du_common_cpb_removal_delay_flag" );
846      sei.m_duCommonCpbRemovalDelayFlag = code;
847      if( sei.m_duCommonCpbRemovalDelayFlag )
848      {
849        sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_increment_minus1" );
850        sei.m_duCommonCpbRemovalDelayMinus1 = code;
851      }
852      if( sei.m_numNalusInDuMinus1 != NULL )
853      {
854        delete sei.m_numNalusInDuMinus1;
855      }
856      sei.m_numNalusInDuMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ];
857      if( sei.m_duCpbRemovalDelayMinus1  != NULL )
858      {
859        delete sei.m_duCpbRemovalDelayMinus1;
860      }
861      sei.m_duCpbRemovalDelayMinus1  = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ];
862
863      for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ )
864      {
865        sei_read_uvlc( pDecodedMessageOutputStream, code, "num_nalus_in_du_minus1[i]");
866        sei.m_numNalusInDuMinus1[ i ] = code;
867        if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) )
868        {
869          sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1[i]" );
870          sei.m_duCpbRemovalDelayMinus1[ i ] = code;
871        }
872      }
873    }
874  }
875}
876
877Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
878{
879  Int  iCode;
880  UInt uiCode;
881  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
882
883  sei_read_svlc( pDecodedMessageOutputStream, iCode,  "recovery_poc_cnt" );      sei.m_recoveryPocCnt     = iCode;
884  sei_read_flag( pDecodedMessageOutputStream, uiCode, "exact_matching_flag" );   sei.m_exactMatchingFlag  = uiCode;
885  sei_read_flag( pDecodedMessageOutputStream, uiCode, "broken_link_flag" );      sei.m_brokenLinkFlag     = uiCode;
886}
887
888Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
889{
890  UInt val;
891  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
892
893  sei_read_uvlc( pDecodedMessageOutputStream, val, "frame_packing_arrangement_id" );                 sei.m_arrangementId = val;
894  sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_cancel_flag" );        sei.m_arrangementCancelFlag = val;
895
896  if ( !sei.m_arrangementCancelFlag )
897  {
898    sei_read_code( pDecodedMessageOutputStream, 7, val, "frame_packing_arrangement_type" );          sei.m_arrangementType = val;
899    assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) );
900
901    sei_read_flag( pDecodedMessageOutputStream, val, "quincunx_sampling_flag" );                     sei.m_quincunxSamplingFlag = val;
902
903    sei_read_code( pDecodedMessageOutputStream, 6, val, "content_interpretation_type" );             sei.m_contentInterpretationType = val;
904    sei_read_flag( pDecodedMessageOutputStream, val, "spatial_flipping_flag" );                      sei.m_spatialFlippingFlag = val;
905    sei_read_flag( pDecodedMessageOutputStream, val, "frame0_flipped_flag" );                        sei.m_frame0FlippedFlag = val;
906    sei_read_flag( pDecodedMessageOutputStream, val, "field_views_flag" );                           sei.m_fieldViewsFlag = val;
907    sei_read_flag( pDecodedMessageOutputStream, val, "current_frame_is_frame0_flag" );               sei.m_currentFrameIsFrame0Flag = val;
908    sei_read_flag( pDecodedMessageOutputStream, val, "frame0_self_contained_flag" );                 sei.m_frame0SelfContainedFlag = val;
909    sei_read_flag( pDecodedMessageOutputStream, val, "frame1_self_contained_flag" );                 sei.m_frame1SelfContainedFlag = val;
910
911    if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5)
912    {
913      sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_x" );                sei.m_frame0GridPositionX = val;
914      sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_y" );                sei.m_frame0GridPositionY = val;
915      sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_x" );                sei.m_frame1GridPositionX = val;
916      sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_y" );                sei.m_frame1GridPositionY = val;
917    }
918
919    sei_read_code( pDecodedMessageOutputStream, 8, val, "frame_packing_arrangement_reserved_byte" );   sei.m_arrangementReservedByte = val;
920    sei_read_flag( pDecodedMessageOutputStream, val,  "frame_packing_arrangement_persistence_flag" );  sei.m_arrangementPersistenceFlag = (val != 0);
921  }
922  sei_read_flag( pDecodedMessageOutputStream, val, "upsampled_aspect_ratio_flag" );                  sei.m_upsampledAspectRatio = val;
923}
924
925Void SEIReader::xParseSEISegmentedRectFramePacking(SEISegmentedRectFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
926{
927  UInt val;
928  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
929  sei_read_flag( pDecodedMessageOutputStream, val,       "segmented_rect_frame_packing_arrangement_cancel_flag" );       sei.m_arrangementCancelFlag            = val;
930  if( !sei.m_arrangementCancelFlag )
931  {
932    sei_read_code( pDecodedMessageOutputStream, 2, val, "segmented_rect_content_interpretation_type" );                sei.m_contentInterpretationType = val;
933    sei_read_flag( pDecodedMessageOutputStream, val,     "segmented_rect_frame_packing_arrangement_persistence" );                              sei.m_arrangementPersistenceFlag               = val;
934  }
935}
936
937Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
938{
939  UInt val;
940  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
941  sei_read_flag( pDecodedMessageOutputStream, val,       "display_orientation_cancel_flag" );       sei.cancelFlag            = val;
942  if( !sei.cancelFlag )
943  {
944    sei_read_flag( pDecodedMessageOutputStream, val,     "hor_flip" );                              sei.horFlip               = val;
945    sei_read_flag( pDecodedMessageOutputStream, val,     "ver_flip" );                              sei.verFlip               = val;
946    sei_read_code( pDecodedMessageOutputStream, 16, val, "anticlockwise_rotation" );                sei.anticlockwiseRotation = val;
947    sei_read_flag( pDecodedMessageOutputStream, val,     "display_orientation_persistence_flag" );  sei.persistenceFlag       = val;
948  }
949}
950
951Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
952{
953  UInt val;
954  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
955  sei_read_code( pDecodedMessageOutputStream, 8, val, "temporal_sub_layer_zero_idx" );  sei.tl0Idx = val;
956  sei_read_code( pDecodedMessageOutputStream, 8, val, "irap_pic_id" );  sei.rapIdx = val;
957}
958
959Void SEIReader::xParseSEIRegionRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
960{
961  UInt val;
962  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
963  sei_read_flag( pDecodedMessageOutputStream, val, "refreshed_region_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0;
964}
965
966Void SEIReader::xParseSEINoDisplay(SEINoDisplay& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
967{
968  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
969  sei.m_noDisplay = true;
970}
971
972Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
973{
974  Int i;
975  UInt val;
976  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
977  sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_id" );                         sei.m_toneMapId = val;
978  sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_cancel_flag" );                sei.m_toneMapCancelFlag = val;
979
980  if ( !sei.m_toneMapCancelFlag )
981  {
982    sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_persistence_flag" );         sei.m_toneMapPersistenceFlag = val;
983    sei_read_code( pDecodedMessageOutputStream, 8, val, "coded_data_bit_depth" );           sei.m_codedDataBitDepth = val;
984    sei_read_code( pDecodedMessageOutputStream, 8, val, "target_bit_depth" );               sei.m_targetBitDepth = val;
985    sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_model_id" );                 sei.m_modelId = val;
986    switch(sei.m_modelId)
987    {
988    case 0:
989      {
990        sei_read_code( pDecodedMessageOutputStream, 32, val, "min_value" );                 sei.m_minValue = val;
991        sei_read_code( pDecodedMessageOutputStream, 32, val, "max_value" );                 sei.m_maxValue = val;
992        break;
993      }
994    case 1:
995      {
996        sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_midpoint" );          sei.m_sigmoidMidpoint = val;
997        sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_width" );             sei.m_sigmoidWidth = val;
998        break;
999      }
1000    case 2:
1001      {
1002        UInt num = 1u << sei.m_targetBitDepth;
1003        sei.m_startOfCodedInterval.resize(num+1);
1004        for(i = 0; i < num; i++)
1005        {
1006          sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval[i]" );
1007          sei.m_startOfCodedInterval[i] = val;
1008        }
1009        sei.m_startOfCodedInterval[num] = 1u << sei.m_codedDataBitDepth;
1010        break;
1011      }
1012    case 3:
1013      {
1014        sei_read_code( pDecodedMessageOutputStream, 16, val,  "num_pivots" );                       sei.m_numPivots = val;
1015        sei.m_codedPivotValue.resize(sei.m_numPivots);
1016        sei.m_targetPivotValue.resize(sei.m_numPivots);
1017        for(i = 0; i < sei.m_numPivots; i++ )
1018        {
1019          sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value[i]" );
1020          sei.m_codedPivotValue[i] = val;
1021          sei_read_code( pDecodedMessageOutputStream, ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3),    val, "target_pivot_value[i]" );
1022          sei.m_targetPivotValue[i] = val;
1023        }
1024        break;
1025      }
1026    case 4:
1027      {
1028        sei_read_code( pDecodedMessageOutputStream, 8, val, "camera_iso_speed_idc" );                     sei.m_cameraIsoSpeedIdc = val;
1029        if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO
1030        {
1031          sei_read_code( pDecodedMessageOutputStream, 32,   val,   "camera_iso_speed_value" );            sei.m_cameraIsoSpeedValue = val;
1032        }
1033        sei_read_code( pDecodedMessageOutputStream, 8, val, "exposure_index_idc" );                       sei.m_exposureIndexIdc = val;
1034        if( sei.m_exposureIndexIdc == 255) //Extended_ISO
1035        {
1036          sei_read_code( pDecodedMessageOutputStream, 32,   val,   "exposure_index_value" );              sei.m_exposureIndexValue = val;
1037        }
1038        sei_read_flag( pDecodedMessageOutputStream, val, "exposure_compensation_value_sign_flag" );       sei.m_exposureCompensationValueSignFlag = val;
1039        sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_numerator" );   sei.m_exposureCompensationValueNumerator = val;
1040        sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_denom_idc" );   sei.m_exposureCompensationValueDenomIdc = val;
1041        sei_read_code( pDecodedMessageOutputStream, 32, val, "ref_screen_luminance_white" );              sei.m_refScreenLuminanceWhite = val;
1042        sei_read_code( pDecodedMessageOutputStream, 32, val, "extended_range_white_level" );              sei.m_extendedRangeWhiteLevel = val;
1043        sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_black_level_code_value" );          sei.m_nominalBlackLevelLumaCodeValue = val;
1044        sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_white_level_code_value" );          sei.m_nominalWhiteLevelLumaCodeValue= val;
1045        sei_read_code( pDecodedMessageOutputStream, 16, val, "extended_white_level_code_value" );         sei.m_extendedWhiteLevelLumaCodeValue = val;
1046        break;
1047      }
1048    default:
1049      {
1050        assert(!"Undefined SEIToneMapModelId");
1051        break;
1052      }
1053    }//switch model id
1054  }// if(!sei.m_toneMapCancelFlag)
1055}
1056
1057Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1058{
1059  Int iCode;
1060  UInt uiCode;
1061  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1062
1063  sei_read_uvlc( pDecodedMessageOutputStream, uiCode,           "sop_seq_parameter_set_id"            ); sei.m_sopSeqParameterSetId = uiCode;
1064  sei_read_uvlc( pDecodedMessageOutputStream, uiCode,           "num_pics_in_sop_minus1"              ); sei.m_numPicsInSopMinus1 = uiCode;
1065  for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++)
1066  {
1067    sei_read_code( pDecodedMessageOutputStream, 6, uiCode,                     "sop_vcl_nut[i]" );  sei.m_sopDescVclNaluType[i] = uiCode;
1068    sei_read_code( pDecodedMessageOutputStream, 3, sei.m_sopDescTemporalId[i], "sop_temporal_id[i]"   );  sei.m_sopDescTemporalId[i] = uiCode;
1069    if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP)
1070    {
1071      sei_read_uvlc( pDecodedMessageOutputStream, sei.m_sopDescStRpsIdx[i],    "sop_short_term_rps_idx[i]"    ); sei.m_sopDescStRpsIdx[i] = uiCode;
1072    }
1073    if (i > 0)
1074    {
1075      sei_read_svlc( pDecodedMessageOutputStream, iCode,                       "sop_poc_delta[i]"     ); sei.m_sopDescPocDelta[i] = iCode;
1076    }
1077  }
1078}
1079
1080#if LAYERS_NOT_PRESENT_SEI
1081Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
1082#else
1083Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
1084#endif
1085{
1086  UInt uiCode;
1087  SEIMessages seis;
1088  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1089
1090  sei_read_flag( pDecodedMessageOutputStream, uiCode,            "bitstream_subset_flag"         ); sei.m_bitStreamSubsetFlag = uiCode;
1091  sei_read_flag( pDecodedMessageOutputStream, uiCode,            "nesting_op_flag"               ); sei.m_nestingOpFlag = uiCode;
1092  if (sei.m_nestingOpFlag)
1093  {
1094    sei_read_flag( pDecodedMessageOutputStream, uiCode,            "default_op_flag"               ); sei.m_defaultOpFlag = uiCode;
1095    sei_read_uvlc( pDecodedMessageOutputStream, uiCode,            "nesting_num_ops_minus1"        ); sei.m_nestingNumOpsMinus1 = uiCode;
1096    for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++)
1097    {
1098      sei_read_code( pDecodedMessageOutputStream, 3,        uiCode,  "nesting_max_temporal_id_plus1[i]"   ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode;
1099      sei_read_uvlc( pDecodedMessageOutputStream, uiCode,            "nesting_op_idx[i]"                  ); sei.m_nestingOpIdx[i] = uiCode;
1100    }
1101  }
1102  else
1103  {
1104    sei_read_flag( pDecodedMessageOutputStream, uiCode,            "all_layers_flag"               ); sei.m_allLayersFlag       = uiCode;
1105    if (!sei.m_allLayersFlag)
1106    {
1107      sei_read_code( pDecodedMessageOutputStream, 3,        uiCode,  "nesting_no_op_max_temporal_id_plus1"  ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode;
1108      sei_read_uvlc( pDecodedMessageOutputStream, uiCode,            "nesting_num_layers_minus1"            ); sei.m_nestingNumLayersMinus1        = uiCode;
1109      for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++)
1110      {
1111        sei_read_code( pDecodedMessageOutputStream, 6,           uiCode,     "nesting_layer_id[i]"      ); sei.m_nestingLayerId[i]   = uiCode;
1112      }
1113    }
1114  }
1115
1116  // byte alignment
1117  while ( m_pcBitstream->getNumBitsRead() % 8 != 0 )
1118  {
1119    UInt code;
1120    sei_read_flag( pDecodedMessageOutputStream, code, "nesting_zero_bit" );
1121  }
1122
1123  sei.m_callerOwnsSEIs = false;
1124
1125  // read nested SEI messages
1126  do {
1127#if O0164_MULTI_LAYER_HRD
1128#if LAYERS_NOT_PRESENT_SEI
1129    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream, &sei);
1130#else
1131    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream, &sei);
1132#endif
1133#else
1134#if LAYERS_NOT_PRESENT_SEI
1135    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream);
1136#else
1137    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream);
1138#endif
1139#endif
1140  } while (m_pcBitstream->getNumBitsLeft() > 8);
1141
1142  if (pDecodedMessageOutputStream) (*pDecodedMessageOutputStream) << "End of scalable nesting SEI message\n";
1143}
1144
1145Void SEIReader::xParseSEITempMotionConstraintsTileSets(SEITempMotionConstrainedTileSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1146{
1147  UInt code;
1148  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1149  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);
1150  sei_read_flag( pDecodedMessageOutputStream, code, "each_tile_one_tile_set_flag");                 sei.m_each_tile_one_tile_set_flag                = (code != 0);
1151
1152  if(!sei.m_each_tile_one_tile_set_flag)
1153  {
1154    sei_read_flag( pDecodedMessageOutputStream, code, "limited_tile_set_display_flag");  sei.m_limited_tile_set_display_flag = (code != 0);
1155    sei_read_uvlc( pDecodedMessageOutputStream, code, "num_sets_in_message_minus1");     sei.setNumberOfTileSets(code + 1);
1156
1157    if(sei.getNumberOfTileSets() != 0)
1158    {
1159      for(Int i = 0; i < sei.getNumberOfTileSets(); i++)
1160      {
1161        sei_read_uvlc( pDecodedMessageOutputStream, code, "mcts_id");  sei.tileSetData(i).m_mcts_id = code;
1162
1163        if(sei.m_limited_tile_set_display_flag)
1164        {
1165          sei_read_flag( pDecodedMessageOutputStream, code, "display_tile_set_flag");  sei.tileSetData(i).m_display_tile_set_flag = (code != 1);
1166        }
1167
1168        sei_read_uvlc( pDecodedMessageOutputStream, code, "num_tile_rects_in_set_minus1");  sei.tileSetData(i).setNumberOfTileRects(code + 1);
1169
1170        for(Int j=0; j<sei.tileSetData(i).getNumberOfTileRects(); j++)
1171        {
1172          sei_read_uvlc( pDecodedMessageOutputStream, code, "top_left_tile_index");      sei.tileSetData(i).topLeftTileIndex(j)     = code;
1173          sei_read_uvlc( pDecodedMessageOutputStream, code, "bottom_right_tile_index");  sei.tileSetData(i).bottomRightTileIndex(j) = code;
1174        }
1175
1176        if(!sei.m_mc_all_tiles_exact_sample_value_match_flag)
1177        {
1178          sei_read_flag( pDecodedMessageOutputStream, code, "exact_sample_value_match_flag");   sei.tileSetData(i).m_exact_sample_value_match_flag    = (code != 0);
1179        }
1180        sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_level_idc_present_flag");  sei.tileSetData(i).m_mcts_tier_level_idc_present_flag = (code != 0);
1181
1182        if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag)
1183        {
1184          sei_read_flag( pDecodedMessageOutputStream, code,    "mcts_tier_flag"); sei.tileSetData(i).m_mcts_tier_flag = (code != 0);
1185          sei_read_code( pDecodedMessageOutputStream, 8, code, "mcts_level_idc"); sei.tileSetData(i).m_mcts_level_idc =  code;
1186        }
1187      }
1188    }
1189  }
1190  else
1191  {
1192    sei_read_flag( pDecodedMessageOutputStream, code, "max_mcs_tier_level_idc_present_flag");  sei.m_max_mcs_tier_level_idc_present_flag = code;
1193    if(sei.m_max_mcs_tier_level_idc_present_flag)
1194    {
1195      sei_read_flag( pDecodedMessageOutputStream, code, "max_mcts_tier_flag");  sei.m_max_mcts_tier_flag = code;
1196      sei_read_code( pDecodedMessageOutputStream, 8, code, "max_mcts_level_idc"); sei.m_max_mcts_level_idc = code;
1197    }
1198  }
1199}
1200
1201Void SEIReader::xParseSEITimeCode(SEITimeCode& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1202{
1203  UInt code;
1204  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1205  sei_read_code( pDecodedMessageOutputStream, 2, code, "num_clock_ts"); sei.numClockTs = code;
1206  for(Int i = 0; i < sei.numClockTs; i++)
1207  {
1208    TComSEITimeSet currentTimeSet;
1209    sei_read_flag( pDecodedMessageOutputStream, code, "clock_time_stamp_flag[i]"); currentTimeSet.clockTimeStampFlag = code;
1210    if(currentTimeSet.clockTimeStampFlag)
1211    {
1212      sei_read_flag( pDecodedMessageOutputStream, code, "nuit_field_based_flag"); currentTimeSet.numUnitFieldBasedFlag = code;
1213      sei_read_code( pDecodedMessageOutputStream, 5, code, "counting_type"); currentTimeSet.countingType = code;
1214      sei_read_flag( pDecodedMessageOutputStream, code, "full_timestamp_flag"); currentTimeSet.fullTimeStampFlag = code;
1215      sei_read_flag( pDecodedMessageOutputStream, code, "discontinuity_flag"); currentTimeSet.discontinuityFlag = code;
1216      sei_read_flag( pDecodedMessageOutputStream, code, "cnt_dropped_flag"); currentTimeSet.cntDroppedFlag = code;
1217      sei_read_code( pDecodedMessageOutputStream, 9, code, "n_frames"); currentTimeSet.numberOfFrames = code;
1218      if(currentTimeSet.fullTimeStampFlag)
1219      {
1220        sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code;
1221        sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code;
1222        sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code;
1223      }
1224      else
1225      {
1226        sei_read_flag( pDecodedMessageOutputStream, code, "seconds_flag"); currentTimeSet.secondsFlag = code;
1227        if(currentTimeSet.secondsFlag)
1228        {
1229          sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code;
1230          sei_read_flag( pDecodedMessageOutputStream, code, "minutes_flag"); currentTimeSet.minutesFlag = code;
1231          if(currentTimeSet.minutesFlag)
1232          {
1233            sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code;
1234            sei_read_flag( pDecodedMessageOutputStream, code, "hours_flag"); currentTimeSet.hoursFlag = code;
1235            if(currentTimeSet.hoursFlag)
1236              sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code;
1237          }
1238        }
1239      }
1240      sei_read_code( pDecodedMessageOutputStream, 5, code, "time_offset_length"); currentTimeSet.timeOffsetLength = code;
1241      if(currentTimeSet.timeOffsetLength > 0)
1242      {
1243        sei_read_code( pDecodedMessageOutputStream, currentTimeSet.timeOffsetLength, code, "time_offset_value");
1244        if((code & (1 << (currentTimeSet.timeOffsetLength-1))) == 0)
1245        {
1246          currentTimeSet.timeOffsetValue = code;
1247        }
1248        else
1249        {
1250          code &= (1<< (currentTimeSet.timeOffsetLength-1)) - 1;
1251          currentTimeSet.timeOffsetValue = ~code + 1;
1252        }
1253      }
1254    }
1255    sei.timeSetArray[i] = currentTimeSet;
1256  }
1257}
1258
1259Void SEIReader::xParseSEIChromaSamplingFilterHint(SEIChromaSamplingFilterHint& sei, UInt payloadSize/*, TComSPS* sps*/, std::ostream *pDecodedMessageOutputStream)
1260{
1261  UInt uiCode;
1262  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1263
1264  sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "ver_chroma_filter_idc"); sei.m_verChromaFilterIdc = uiCode;
1265  sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "hor_chroma_filter_idc"); sei.m_horChromaFilterIdc = uiCode;
1266  sei_read_flag( pDecodedMessageOutputStream, uiCode, "ver_filtering_process_flag"); sei.m_verFilteringProcessFlag = uiCode;
1267  if(sei.m_verChromaFilterIdc == 1 || sei.m_horChromaFilterIdc == 1)
1268  {
1269    sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "target_format_idc"); sei.m_targetFormatIdc = uiCode;
1270    if(sei.m_verChromaFilterIdc == 1)
1271    {
1272      sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_vertical_filters"); sei.m_numVerticalFilters = uiCode;
1273      if(sei.m_numVerticalFilters > 0)
1274      {
1275        sei.m_verTapLengthMinus1 = (Int*)malloc(sei.m_numVerticalFilters * sizeof(Int));
1276        sei.m_verFilterCoeff = (Int**)malloc(sei.m_numVerticalFilters * sizeof(Int*));
1277        for(Int i = 0; i < sei.m_numVerticalFilters; i ++)
1278        {
1279          sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "ver_tap_length_minus_1"); sei.m_verTapLengthMinus1[i] = uiCode;
1280          sei.m_verFilterCoeff[i] = (Int*)malloc(sei.m_verTapLengthMinus1[i] * sizeof(Int));
1281          for(Int j = 0; j < sei.m_verTapLengthMinus1[i]; j ++)
1282          {
1283            sei_read_svlc( pDecodedMessageOutputStream, sei.m_verFilterCoeff[i][j], "ver_filter_coeff");
1284          }
1285        }
1286      }
1287    }
1288    if(sei.m_horChromaFilterIdc == 1)
1289    {
1290      sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_horizontal_filters"); sei.m_numHorizontalFilters = uiCode;
1291      if(sei.m_numHorizontalFilters  > 0)
1292      {
1293        sei.m_horTapLengthMinus1 = (Int*)malloc(sei.m_numHorizontalFilters * sizeof(Int));
1294        sei.m_horFilterCoeff = (Int**)malloc(sei.m_numHorizontalFilters * sizeof(Int*));
1295        for(Int i = 0; i < sei.m_numHorizontalFilters; i ++)
1296        {
1297          sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "hor_tap_length_minus_1"); sei.m_horTapLengthMinus1[i] = uiCode;
1298          sei.m_horFilterCoeff[i] = (Int*)malloc(sei.m_horTapLengthMinus1[i] * sizeof(Int));
1299          for(Int j = 0; j < sei.m_horTapLengthMinus1[i]; j ++)
1300          {
1301            sei_read_svlc( pDecodedMessageOutputStream, sei.m_horFilterCoeff[i][j], "hor_filter_coeff");
1302          }
1303        }
1304      }
1305    }
1306  }
1307}
1308
1309Void SEIReader::xParseSEIKneeFunctionInfo(SEIKneeFunctionInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1310{
1311  Int i;
1312  UInt val;
1313  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1314
1315  sei_read_uvlc( pDecodedMessageOutputStream, val, "knee_function_id" );                   sei.m_kneeId = val;
1316  sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_cancel_flag" );          sei.m_kneeCancelFlag = val;
1317  if ( !sei.m_kneeCancelFlag )
1318  {
1319    sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_persistence_flag" );   sei.m_kneePersistenceFlag = val;
1320    sei_read_code( pDecodedMessageOutputStream, 32, val, "input_d_range" );                sei.m_kneeInputDrange = val;
1321    sei_read_code( pDecodedMessageOutputStream, 32, val, "input_disp_luminance" );         sei.m_kneeInputDispLuminance = val;
1322    sei_read_code( pDecodedMessageOutputStream, 32, val, "output_d_range" );               sei.m_kneeOutputDrange = val;
1323    sei_read_code( pDecodedMessageOutputStream, 32, val, "output_disp_luminance" );        sei.m_kneeOutputDispLuminance = val;
1324    sei_read_uvlc( pDecodedMessageOutputStream, val, "num_knee_points_minus1" );           sei.m_kneeNumKneePointsMinus1 = val;
1325    assert( sei.m_kneeNumKneePointsMinus1 > 0 );
1326    sei.m_kneeInputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1);
1327    sei.m_kneeOutputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1);
1328    for(i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ )
1329    {
1330      sei_read_code( pDecodedMessageOutputStream, 10, val, "input_knee_point" );           sei.m_kneeInputKneePoint[i] = val;
1331      sei_read_code( pDecodedMessageOutputStream, 10, val, "output_knee_point" );          sei.m_kneeOutputKneePoint[i] = val;
1332    }
1333  }
1334}
1335
1336Void SEIReader::xParseSEIMasteringDisplayColourVolume(SEIMasteringDisplayColourVolume& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1337{
1338  UInt code;
1339  output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize);
1340
1341  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[0]" ); sei.values.primaries[0][0] = code;
1342  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[0]" ); sei.values.primaries[0][1] = code;
1343
1344  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[1]" ); sei.values.primaries[1][0] = code;
1345  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[1]" ); sei.values.primaries[1][1] = code;
1346
1347  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[2]" ); sei.values.primaries[2][0] = code;
1348  sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[2]" ); sei.values.primaries[2][1] = code;
1349
1350
1351  sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_x" ); sei.values.whitePoint[0] = code;
1352  sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_y" ); sei.values.whitePoint[1] = code;
1353
1354  sei_read_code( pDecodedMessageOutputStream, 32, code, "max_display_mastering_luminance" ); sei.values.maxLuminance = code;
1355  sei_read_code( pDecodedMessageOutputStream, 32, code, "min_display_mastering_luminance" ); sei.values.minLuminance = code;
1356}
1357
1358#if Q0074_COLOUR_REMAPPING_SEI
1359Void SEIReader::xParseSEIColourRemappingInfo(SEIColourRemappingInfo& sei, UInt /*payloadSize*/, std::ostream *pDecodedMessageOutputStream)
1360{
1361  UInt  uiVal;
1362  Int   iVal;
1363
1364  sei_read_uvlc( pDecodedMessageOutputStream, uiVal, "colour_remap_id" );          sei.m_colourRemapId = uiVal;
1365  sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_cancel_flag" ); sei.m_colourRemapCancelFlag = uiVal;
1366  if( !sei.m_colourRemapCancelFlag ) 
1367  {
1368    sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_persistence_flag" );                sei.m_colourRemapPersistenceFlag = uiVal;
1369    sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_video_signal_info_present_flag" );  sei.m_colourRemapVideoSignalInfoPresentFlag = uiVal;
1370    if ( sei.m_colourRemapVideoSignalInfoPresentFlag )
1371    {
1372      sei_read_flag( pDecodedMessageOutputStream, uiVal,    "colour_remap_full_range_flag" );           sei.m_colourRemapFullRangeFlag = uiVal;
1373      sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_primaries" );                 sei.m_colourRemapPrimaries = uiVal;
1374      sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_transfer_function" );         sei.m_colourRemapTransferFunction = uiVal;
1375      sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_matrix_coefficients" );       sei.m_colourRemapMatrixCoefficients = uiVal;
1376    }
1377    sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_input_bit_depth" ); sei.m_colourRemapInputBitDepth = uiVal;
1378    sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_bit_depth" ); sei.m_colourRemapBitDepth = uiVal;
1379 
1380    for( Int c=0 ; c<3 ; c++ )
1381    {
1382      sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "pre_lut_num_val_minus1[c]" ); sei.m_preLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal;
1383      sei.m_preLutCodedValue[c].resize(sei.m_preLutNumValMinus1[c]+1);
1384      sei.m_preLutTargetValue[c].resize(sei.m_preLutNumValMinus1[c]+1);
1385      if( uiVal> 0 )
1386        for ( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ )
1387        {
1388          sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapInputBitDepth   + 7 ) >> 3 ) << 3, uiVal, "pre_lut_coded_value[c][i]" );  sei.m_preLutCodedValue[c][i]  = uiVal;
1389          sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_target_value[c][i]" ); sei.m_preLutTargetValue[c][i] = uiVal;
1390        }
1391      else // pre_lut_num_val_minus1[c] == 0
1392      {
1393        sei.m_preLutCodedValue[c][0]  = 0;
1394        sei.m_preLutTargetValue[c][0] = 0;
1395        sei.m_preLutCodedValue[c][1]  = (1 << sei.m_colourRemapInputBitDepth) - 1 ;
1396        sei.m_preLutTargetValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1 ;
1397      }
1398    }
1399
1400    sei_read_flag( pDecodedMessageOutputStream, uiVal,      "colour_remap_matrix_present_flag" ); sei.m_colourRemapMatrixPresentFlag = uiVal;
1401    if( sei.m_colourRemapMatrixPresentFlag )
1402    {
1403      sei_read_code( pDecodedMessageOutputStream, 4, uiVal, "log2_matrix_denom" ); sei.m_log2MatrixDenom = uiVal;
1404      for ( Int c=0 ; c<3 ; c++ )
1405        for ( Int i=0 ; i<3 ; i++ )
1406        {
1407          sei_read_svlc( pDecodedMessageOutputStream, iVal, "colour_remap_coeffs[c][i]" ); sei.m_colourRemapCoeffs[c][i] = iVal;
1408        }
1409    }
1410    else // setting default matrix (I3)
1411    {
1412      sei.m_log2MatrixDenom = 0;
1413      for ( Int c=0 ; c<3 ; c++ )
1414        for ( Int i=0 ; i<3 ; i++ )
1415          sei.m_colourRemapCoeffs[c][i] = (c==i) ? 1 : 0;
1416    }
1417    for( Int c=0 ; c<3 ; c++ )
1418    {
1419      sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "post_lut_num_val_minus1[c]" ); sei.m_postLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal;
1420      sei.m_postLutCodedValue[c].resize(sei.m_postLutNumValMinus1[c]+1);
1421      sei.m_postLutTargetValue[c].resize(sei.m_postLutNumValMinus1[c]+1);
1422      if( uiVal > 0 )
1423        for ( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ )
1424        {
1425          sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_coded_value[c][i]" );  sei.m_postLutCodedValue[c][i] = uiVal;
1426          sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_target_value[c][i]" ); sei.m_postLutTargetValue[c][i] = uiVal;
1427        }
1428      else
1429      {
1430        sei.m_postLutCodedValue[c][0]  = 0;
1431        sei.m_postLutTargetValue[c][0] = 0;
1432        sei.m_postLutTargetValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1;
1433        sei.m_postLutCodedValue[c][1]  = (1 << sei.m_colourRemapBitDepth) - 1;
1434      }
1435    }
1436  }
1437}
1438#endif
1439
1440
1441#if SVC_EXTENSION
1442#if LAYERS_NOT_PRESENT_SEI
1443Void SEIReader::xParseSEILayersNotPresent(SEILayersNotPresent &sei, UInt payloadSize, TComVPS *vps, std::ostream *pDecodedMessageOutputStream)
1444{
1445  UInt uiCode;
1446  UInt i = 0;
1447
1448  sei_read_uvlc( pDecodedMessageOutputStream, uiCode,           "lp_sei_active_vps_id" ); sei.m_activeVpsId = uiCode;
1449  assert(vps->getVPSId() == sei.m_activeVpsId);
1450  sei.m_vpsMaxLayers = vps->getMaxLayers();
1451  for (; i < sei.m_vpsMaxLayers; i++)
1452  {
1453    sei_read_flag( pDecodedMessageOutputStream, uiCode,         "layer_not_present_flag"   ); sei.m_layerNotPresentFlag[i] = uiCode ? true : false;
1454  }
1455  for (; i < MAX_LAYERS; i++)
1456  {
1457    sei.m_layerNotPresentFlag[i] = false;
1458  }
1459}
1460#endif
1461
1462#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
1463Void SEIReader::xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1464{
1465  UInt uiCode;
1466
1467  sei_read_flag( pDecodedMessageOutputStream, uiCode, "il_all_tiles_exact_sample_value_match_flag"   ); sei.m_ilAllTilesExactSampleValueMatchFlag = uiCode;
1468  sei_read_flag( pDecodedMessageOutputStream, uiCode, "il_one_tile_per_tile_set_flag"                ); sei.m_ilOneTilePerTileSetFlag = uiCode;
1469  if( !sei.m_ilOneTilePerTileSetFlag )
1470  {
1471    sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_num_sets_in_message_minus1"                ); sei.m_ilNumSetsInMessageMinus1 = uiCode;
1472    if( sei.m_ilNumSetsInMessageMinus1 )
1473    {
1474      sei_read_flag( pDecodedMessageOutputStream, uiCode, "skipped_tile_set_present_flag"                ); sei.m_skippedTileSetPresentFlag = uiCode;
1475    }
1476    else
1477    {
1478      sei.m_skippedTileSetPresentFlag = false;
1479    }
1480    UInt numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - (sei.m_skippedTileSetPresentFlag ? 1 : 0) + 1;
1481    for( UInt i = 0; i < numSignificantSets; i++ )
1482    {
1483      sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "ilcts_id"                                     ); sei.m_ilctsId[i] = uiCode;
1484      sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_num_tile_rects_in_set_minus1"              ) ;sei.m_ilNumTileRectsInSetMinus1[i] = uiCode;
1485      for( UInt j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[i]; j++ )
1486      {
1487        sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_top_left_tile_index"                       ); sei.m_ilTopLeftTileIndex[i][j] = uiCode;
1488        sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_bottom_right_tile_index"                   ); sei.m_ilBottomRightTileIndex[i][j] = uiCode;
1489      }
1490      sei_read_code( pDecodedMessageOutputStream, 2, uiCode, "ilc_idc"                                   ); sei.m_ilcIdc[i] = uiCode;
1491      if( sei.m_ilAllTilesExactSampleValueMatchFlag )
1492      {
1493        sei_read_flag( pDecodedMessageOutputStream, uiCode, "il_exact_sample_value_match_flag"             ); sei.m_ilExactSampleValueMatchFlag[i] = uiCode;
1494      }
1495    }
1496  }
1497  else
1498  {
1499    sei_read_code( pDecodedMessageOutputStream, 2, uiCode, "all_tiles_ilc_idc"                         ); sei.m_allTilesIlcIdc = uiCode;
1500  }
1501}
1502#endif
1503
1504#if SUB_BITSTREAM_PROPERTY_SEI
1505#if OLS_IDX_CHK
1506Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei, TComVPS *vps, std::ostream *pDecodedMessageOutputStream)
1507#else
1508Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei, std::ostream *pDecodedMessageOutputStream)
1509#endif
1510{
1511  UInt uiCode;
1512  sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "active_vps_id" );                      sei.m_activeVpsId = uiCode;
1513  sei_read_uvlc( pDecodedMessageOutputStream,    uiCode, "num_additional_sub_streams_minus1" );  sei.m_numAdditionalSubStreams = uiCode + 1;
1514
1515  for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ )
1516  {
1517    sei_read_code( pDecodedMessageOutputStream,  2, uiCode, "sub_bitstream_mode[i]"           ); sei.m_subBitstreamMode[i] = uiCode;
1518    sei_read_uvlc( pDecodedMessageOutputStream,     uiCode, "output_layer_set_idx_to_vps[i]"  );
1519#if OLS_IDX_CHK
1520      // The value of output_layer_set_idx_to_vps[ i ]  shall be in the range of 0 to NumOutputLayerSets − 1, inclusive.
1521      assert(uiCode > 0 && uiCode <= vps->getNumOutputLayerSets()-1);
1522#endif
1523      sei.m_outputLayerSetIdxToVps[i] = uiCode;
1524    sei_read_code( pDecodedMessageOutputStream,  3, uiCode, "highest_sub_layer_id[i]"         ); sei.m_highestSublayerId[i] = uiCode;
1525    sei_read_code( pDecodedMessageOutputStream, 16, uiCode, "avg_bit_rate[i]"                 ); sei.m_avgBitRate[i] = uiCode;
1526    sei_read_code( pDecodedMessageOutputStream, 16, uiCode, "max_bit_rate[i]"                 ); sei.m_maxBitRate[i] = uiCode;
1527  } 
1528}
1529#endif
1530
1531#if O0164_MULTI_LAYER_HRD
1532#if LAYERS_NOT_PRESENT_SEI
1533Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, std::ostream *pDecodedMessageOutputStream)
1534#else
1535Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComSPS *sps, const SEIScalableNesting &nestingSei, std::ostream *pDecodedMessageOutputStream)
1536#endif
1537{
1538  UInt uiCode;
1539  sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "bsp_idx" ); sei.m_bspIdx = uiCode;
1540
1541  // byte alignment
1542  while ( m_pcBitstream->getNumBitsRead() % 8 != 0 )
1543  {
1544    UInt code;
1545    sei_read_flag( pDecodedMessageOutputStream, code, "bsp_nesting_zero_bit" );
1546  }
1547
1548  sei.m_callerOwnsSEIs = false;
1549
1550  // read nested SEI messages
1551#if NESTING_SEI_EXTENSIBILITY
1552  Int numSeiMessages = 0;
1553  sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_seis_in_bsp_minus1" );  assert( uiCode <= MAX_SEIS_IN_BSP_NESTING );
1554  numSeiMessages = uiCode;
1555  for(Int i = 0; i < numSeiMessages; i++)
1556  {
1557    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream, &nestingSei, &sei);
1558  }
1559#else
1560  do {
1561#if LAYERS_NOT_PRESENT_SEI
1562    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream, &nestingSei, &sei);
1563#else
1564    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream, &nestingSei);
1565#endif
1566  } while (m_pcBitstream->getNumBitsLeft() > 8);
1567#endif
1568}
1569
1570Void SEIReader::xParseSEIBspInitialArrivalTime(SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei, std::ostream *pDecodedMessageOutputStream)
1571{
1572  assert(vps->getVpsVuiPresentFlag());
1573
1574#if VPS_VUI_BSP_HRD_PARAMS
1575  UInt uiCode;
1576  Int psIdx         = bspNestingSei.m_seiPartitioningSchemeIdx;
1577  Int seiOlsIdx     = bspNestingSei.m_seiOlsIdx;
1578  Int maxTemporalId = nestingSei.m_nestingMaxTemporalIdPlus1[0];
1579  Int maxValues     = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1;
1580  std::vector<Int> hrdIdx(0, maxValues);
1581  std::vector<TComHRD *> hrdVec;
1582  std::vector<Int> syntaxElemLen;
1583  for(Int i = 0; i < maxValues; i++)
1584  {
1585    hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei.m_bspIdx);
1586    hrdVec[i] = vps->getBspHrd(hrdIdx[i]);
1587   
1588    syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1;
1589    if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) )
1590    {
1591      assert( syntaxElemLen[i] == 24 ); // Default value of init_cpb_removal_delay_length_minus1 is 23
1592    }
1593    if( i > 0 )
1594    {
1595      assert( hrdVec[i]->getNalHrdParametersPresentFlag() == hrdVec[i-1]->getNalHrdParametersPresentFlag() );
1596      assert( hrdVec[i]->getVclHrdParametersPresentFlag() == hrdVec[i-1]->getVclHrdParametersPresentFlag() );
1597    }
1598  }
1599  if (hrdVec[0]->getNalHrdParametersPresentFlag())
1600  {
1601    for(UInt i = 0; i < maxValues; i++)
1602    {
1603      sei_read_code( pDecodedMessageOutputStream, syntaxElemLen[i], uiCode, "nal_initial_arrival_delay[i]" ); sei.m_nalInitialArrivalDelay[i] = uiCode;
1604    }
1605  }
1606  if( hrdVec[0]->getVclHrdParametersPresentFlag() )
1607  {
1608    for(UInt i = 0; i < maxValues; i++)
1609    {
1610      sei_read_code( pDecodedMessageOutputStream, syntaxElemLen[i], uiCode, "vcl_initial_arrival_delay[i]" ); sei.m_vclInitialArrivalDelay[i] = uiCode;
1611    }
1612  }
1613#else
1614  UInt schedCombCnt = vps->getNumBspSchedCombinations(nestingSei.m_nestingOpIdx[0]);
1615  UInt len;
1616  UInt hrdIdx;
1617  UInt uiCode;
1618
1619  if (schedCombCnt > 0)
1620  {
1621    hrdIdx = vps->getBspCombHrdIdx(nestingSei.m_nestingOpIdx[0], 0, bspNestingSei.m_bspIdx);
1622  }
1623  else
1624  {
1625    hrdIdx = 0;
1626  }
1627
1628  TComHRD *hrd = vps->getBspHrd(hrdIdx);
1629
1630  if (hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag())
1631  {
1632    len = hrd->getInitialCpbRemovalDelayLengthMinus1() + 1;
1633  }
1634  else
1635  {
1636    len = 23 + 1;
1637  }
1638
1639  if (hrd->getNalHrdParametersPresentFlag())
1640  {
1641    for(UInt i = 0; i < schedCombCnt; i++)
1642    {
1643      sei_read_code( pDecodedMessageOutputStream, len, uiCode, "nal_initial_arrival_delay" ); sei.m_nalInitialArrivalDelay[i] = uiCode;
1644    }
1645  }
1646#if BSP_INIT_ARRIVAL_SEI
1647  if( hrd->getVclHrdParametersPresentFlag() )
1648#else
1649  else
1650#endif
1651  {
1652    for(UInt i = 0; i < schedCombCnt; i++)
1653    {
1654      sei_read_code( pDecodedMessageOutputStream, len, uiCode, "vcl_initial_arrival_delay" ); sei.m_vclInitialArrivalDelay[i] = uiCode;
1655    }
1656  }
1657#endif
1658}
1659
1660Void SEIReader::xParseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1, std::ostream *pDecodedMessageOutputStream)
1661{
1662  UInt  uiCode;
1663  if( commonInfPresentFlag )
1664  {
1665    sei_read_flag( pDecodedMessageOutputStream, uiCode, "nal_hrd_parameters_present_flag" );           hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false );
1666    sei_read_flag( pDecodedMessageOutputStream, uiCode, "vcl_hrd_parameters_present_flag" );           hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false );
1667    if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() )
1668    {
1669      sei_read_flag( pDecodedMessageOutputStream, uiCode, "sub_pic_cpb_params_present_flag" );         hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false );
1670      if( hrd->getSubPicCpbParamsPresentFlag() )
1671      {
1672        sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "tick_divisor_minus2" );                hrd->setTickDivisorMinus2( uiCode );
1673        sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode );
1674        sei_read_flag( pDecodedMessageOutputStream, uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false );
1675        sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "dpb_output_delay_du_length_minus1"  ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode );
1676      }
1677      sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "bit_rate_scale" );                       hrd->setBitRateScale( uiCode );
1678      sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "cpb_size_scale" );                       hrd->setCpbSizeScale( uiCode );
1679      if( hrd->getSubPicCpbParamsPresentFlag() )
1680      {
1681        sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "cpb_size_du_scale" );                  hrd->setDuCpbSizeScale( uiCode );
1682      }
1683      sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode );
1684      sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "au_cpb_removal_delay_length_minus1" );      hrd->setCpbRemovalDelayLengthMinus1( uiCode );
1685      sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "dpb_output_delay_length_minus1" );       hrd->setDpbOutputDelayLengthMinus1( uiCode );
1686    }
1687  }
1688  Int i, j, nalOrVcl;
1689  for( i = 0; i <= maxNumSubLayersMinus1; i ++ )
1690  {
1691    sei_read_flag( pDecodedMessageOutputStream, uiCode, "fixed_pic_rate_general_flag" );                     hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false  );
1692    if( !hrd->getFixedPicRateFlag( i ) )
1693    {
1694       sei_read_flag( pDecodedMessageOutputStream, uiCode, "fixed_pic_rate_within_cvs_flag" );                hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false  );
1695    }
1696    else
1697    {
1698      hrd->setFixedPicRateWithinCvsFlag( i, true );
1699    }
1700    hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present
1701    hrd->setCpbCntMinus1   ( i, 0 ); // Infered to be 0 when not present
1702    if( hrd->getFixedPicRateWithinCvsFlag( i ) )
1703    {
1704      sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "elemental_duration_in_tc_minus1" );             hrd->setPicDurationInTcMinus1( i, uiCode );
1705    }
1706    else
1707    {
1708      sei_read_flag( pDecodedMessageOutputStream, uiCode, "low_delay_hrd_flag" );                      hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false  );
1709    }
1710    if (!hrd->getLowDelayHrdFlag( i ))
1711    {
1712      sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "cpb_cnt_minus1" );                          hrd->setCpbCntMinus1( i, uiCode );
1713    }
1714    for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
1715    {
1716      if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) ||
1717          ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )
1718      {
1719        for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ )
1720        {
1721          sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "bit_rate_value_minus1" );             hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode );
1722          sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "cpb_size_value_minus1" );             hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode );
1723          if( hrd->getSubPicCpbParamsPresentFlag() )
1724          {
1725            sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "cpb_size_du_value_minus1" );       hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode );
1726            sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "bit_rate_du_value_minus1" );       hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode );
1727          }
1728           sei_read_flag( pDecodedMessageOutputStream, uiCode, "cbr_flag" );                          hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false  );
1729        }
1730      }
1731    }
1732  }
1733}
1734#endif
1735
1736#if Q0078_ADD_LAYER_SETS
1737
1738#if LAYERS_NOT_PRESENT_SEI
1739Void SEIReader::xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
1740#else
1741Void SEIReader::xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComSPS *sps, std::ostream *pDecodedMessageOutputStream)
1742#endif
1743{
1744  UInt uiCode;
1745  SEIMessages seis;
1746
1747  sei_read_flag( pDecodedMessageOutputStream, uiCode, "ols_flag"); sei.m_olsFlag = uiCode;
1748  sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_ols_indices_minus1"); sei.m_numOlsIndicesMinus1 = uiCode;
1749
1750  for (Int i = 0; i <= sei.m_numOlsIndicesMinus1; i++)
1751  {
1752    sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "ols_idx[i]"); sei.m_olsIdx[i] = uiCode;
1753  }
1754
1755  // byte alignment
1756  while (m_pcBitstream->getNumBitsRead() % 8 != 0)
1757  {
1758    UInt code;
1759    sei_read_flag( pDecodedMessageOutputStream, code, "ols_nesting_zero_bit");
1760  }
1761
1762  sei.m_callerOwnsSEIs = false;
1763
1764  // read nested SEI messages
1765  do {
1766#if O0164_MULTI_LAYER_HRD
1767#if LAYERS_NOT_PRESENT_SEI
1768    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream);
1769#else
1770    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream);
1771#endif
1772#else
1773#if LAYERS_NOT_PRESENT_SEI
1774    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream);
1775#else
1776    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream);
1777#endif
1778#endif
1779  } while (m_pcBitstream->getNumBitsLeft() > 8);
1780
1781}
1782
1783Void SEIReader::xParseSEIVPSRewriting(SEIVPSRewriting &sei, std::ostream *pDecodedMessageOutputStream )
1784{
1785}
1786
1787#endif
1788
1789#if P0123_ALPHA_CHANNEL_SEI
1790void SEIReader::xParseSEIAlphaChannelInfo(SEIAlphaChannelInfo &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1791{
1792  UInt value;
1793  sei_read_flag(pDecodedMessageOutputStream, value, "alpha_channel_cancel_flag"); sei.m_alphaChannelCancelFlag = value;
1794  if(!sei.m_alphaChannelCancelFlag)
1795  {
1796    sei_read_code(pDecodedMessageOutputStream, 3, value, "alpha_channel_use_idc");          sei.m_alphaChannelUseIdc = value;
1797    sei_read_code(pDecodedMessageOutputStream, 3, value, "alpha_channel_bit_depth_minus8"); sei.m_alphaChannelBitDepthMinus8 = value;
1798    sei_read_code(pDecodedMessageOutputStream, sei.m_alphaChannelBitDepthMinus8 + 9, value, "alpha_transparent_value"); sei.m_alphaTransparentValue = value;
1799    sei_read_code(pDecodedMessageOutputStream, sei.m_alphaChannelBitDepthMinus8 + 9, value, "alpha_opaque_value"); sei.m_alphaOpaqueValue = value;
1800    sei_read_flag(pDecodedMessageOutputStream, value, "alpha_channel_incr_flag");        sei.m_alphaChannelIncrFlag = value;
1801    sei_read_flag(pDecodedMessageOutputStream, value, "alpha_channel_clip_flag");        sei.m_alphaChannelClipFlag = value;
1802    if(sei.m_alphaChannelClipFlag)
1803    {
1804      sei_read_flag(pDecodedMessageOutputStream, value, "alpha_channel_clip_type_flag"); sei.m_alphaChannelClipTypeFlag = value;
1805    }
1806  } 
1807}
1808#endif
1809
1810#if Q0096_OVERLAY_SEI
1811Void SEIReader::xParseSEIOverlayInfo(SEIOverlayInfo& sei, UInt /*payloadSize*/, std::ostream *pDecodedMessageOutputStream)
1812{
1813  Int i, j;
1814  UInt val;
1815  sei_read_flag( pDecodedMessageOutputStream, val, "overlay_info_cancel_flag" );                 sei.m_overlayInfoCancelFlag = val;
1816  if ( !sei.m_overlayInfoCancelFlag )
1817  {
1818    sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_content_aux_id_minus128" );            sei.m_overlayContentAuxIdMinus128 = val;
1819    sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_label_aux_id_minus128" );              sei.m_overlayLabelAuxIdMinus128 = val;
1820    sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_alpha_aux_id_minus128" );              sei.m_overlayAlphaAuxIdMinus128 = val;
1821    sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_element_label_value_length_minus8" );  sei.m_overlayElementLabelValueLengthMinus8 = val;
1822    sei_read_uvlc( pDecodedMessageOutputStream, val, "num_overlays_minus1" );                        sei.m_numOverlaysMinus1 = val;
1823
1824    assert( sei.m_numOverlaysMinus1 < MAX_OVERLAYS );
1825    sei.m_overlayIdx.resize( sei.m_numOverlaysMinus1+1 );
1826    sei.m_languageOverlayPresentFlag.resize( sei.m_numOverlaysMinus1+1 );
1827    sei.m_overlayContentLayerId.resize( sei.m_numOverlaysMinus1+1 );
1828    sei.m_overlayLabelPresentFlag.resize( sei.m_numOverlaysMinus1+1 );
1829    sei.m_overlayLabelLayerId.resize( sei.m_numOverlaysMinus1+1 );
1830    sei.m_overlayAlphaPresentFlag.resize( sei.m_numOverlaysMinus1+1 );
1831    sei.m_overlayAlphaLayerId.resize( sei.m_numOverlaysMinus1+1 );
1832    sei.m_numOverlayElementsMinus1.resize( sei.m_numOverlaysMinus1+1 );
1833    sei.m_overlayElementLabelMin.resize( sei.m_numOverlaysMinus1+1 );
1834    sei.m_overlayElementLabelMax.resize( sei.m_numOverlaysMinus1+1 );
1835    for ( i=0 ; i<=sei.m_numOverlaysMinus1 ; i++ )
1836    {
1837      sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_idx" );                      sei.m_overlayIdx[i] = val;
1838      sei_read_flag( pDecodedMessageOutputStream, val, "language_overlay_present_flag" );    sei.m_languageOverlayPresentFlag[i] = val;
1839      sei_read_code( pDecodedMessageOutputStream, 6, val, "overlay_content_layer_id");       sei.m_overlayContentLayerId[i] = val;
1840      sei_read_flag( pDecodedMessageOutputStream, val, "overlay_label_present_flag" );       sei.m_overlayLabelPresentFlag[i] = val;
1841      if ( sei.m_overlayLabelPresentFlag[i] )
1842      {
1843        sei_read_code( pDecodedMessageOutputStream, 6, val, "overlay_label_layer_id");     sei.m_overlayLabelLayerId[i] = val;
1844      }
1845      sei_read_flag( pDecodedMessageOutputStream, val, "overlay_alpha_present_flag" );       sei.m_overlayAlphaPresentFlag[i] = val;
1846      if ( sei.m_overlayAlphaPresentFlag[i] )
1847      {
1848        sei_read_code( pDecodedMessageOutputStream, 6, val, "overlay_alpha_layer_id");     sei.m_overlayAlphaLayerId[i] = val;
1849      }
1850      if ( sei.m_overlayLabelPresentFlag[i] )
1851      {
1852        sei_read_uvlc( pDecodedMessageOutputStream, val, "num_overlay_elements_minus1");   sei.m_numOverlayElementsMinus1[i] = val;
1853        assert( sei.m_numOverlayElementsMinus1[i] < MAX_OVERLAY_ELEMENTS );
1854        sei.m_overlayElementLabelMin[i].resize( sei.m_numOverlayElementsMinus1[i]+1 );
1855        sei.m_overlayElementLabelMax[i].resize( sei.m_numOverlayElementsMinus1[i]+1 );
1856        for ( j=0 ; j<=sei.m_numOverlayElementsMinus1[i] ; j++ )
1857        {
1858          sei_read_code( pDecodedMessageOutputStream, sei.m_overlayElementLabelValueLengthMinus8 + 8, val, "overlay_element_label_min"); sei.m_overlayElementLabelMin[i][j] = val;
1859          sei_read_code( pDecodedMessageOutputStream, sei.m_overlayElementLabelValueLengthMinus8 + 8, val, "overlay_element_label_max"); sei.m_overlayElementLabelMax[i][j] = val;
1860        }     
1861      }
1862      else
1863      {
1864        sei.m_numOverlayElementsMinus1[i] = 0;
1865      }
1866    }
1867
1868    // byte alignment
1869    while ( m_pcBitstream->getNumBitsRead() % 8 != 0 )
1870    {
1871      sei_read_flag( pDecodedMessageOutputStream, val, "overlay_zero_bit" );
1872      assert( val==0 );
1873    }
1874
1875    UChar* sval = new UChar[MAX_OVERLAY_STRING_BYTES];
1876    UInt slen;   
1877    sei.m_overlayLanguage.resize( sei.m_numOverlaysMinus1+1, NULL );
1878    sei.m_overlayLanguageLength.resize( sei.m_numOverlaysMinus1+1 );
1879    sei.m_overlayName.resize( sei.m_numOverlaysMinus1+1, NULL );
1880    sei.m_overlayNameLength.resize( sei.m_numOverlaysMinus1+1 );
1881    sei.m_overlayElementName.resize( sei.m_numOverlaysMinus1+1 );
1882    sei.m_overlayElementNameLength.resize( sei.m_numOverlaysMinus1+1 );
1883    for ( i=0 ; i<=sei.m_numOverlaysMinus1 ; i++ )
1884    {
1885      if ( sei.m_languageOverlayPresentFlag[i] )
1886      {
1887        READ_STRING( MAX_OVERLAY_STRING_BYTES, sval, slen, "overlay_language" );
1888        sei.m_overlayLanguage[i] = new UChar[slen];
1889        memcpy(sei.m_overlayLanguage[i], sval, slen);
1890        sei.m_overlayLanguageLength[i] = slen;
1891      }
1892      READ_STRING( MAX_OVERLAY_STRING_BYTES, sval, slen, "overlay_name" );
1893      sei.m_overlayName[i] = new UChar[slen];
1894      memcpy(sei.m_overlayName[i], sval, slen);
1895      sei.m_overlayNameLength[i] = slen;
1896      if ( sei.m_overlayLabelPresentFlag[i] )
1897      {
1898        sei.m_overlayElementName[i].resize( sei.m_numOverlayElementsMinus1[i]+1, NULL );
1899        sei.m_overlayElementNameLength[i].resize( sei.m_numOverlayElementsMinus1[i]+1 );
1900        for ( j=0 ; j<=sei.m_numOverlayElementsMinus1[i] ; j++)
1901        {
1902          READ_STRING( MAX_OVERLAY_STRING_BYTES, sval, slen, "overlay_element_name" );
1903          sei.m_overlayElementName[i][j] = new UChar[slen];
1904          memcpy(sei.m_overlayElementName[i][j], sval, slen);
1905          sei.m_overlayElementNameLength[i][j] = slen;
1906        }
1907      }
1908    }
1909    sei_read_flag( pDecodedMessageOutputStream, val, "overlay_info_persistence_flag" );        sei.m_overlayInfoPersistenceFlag = val;
1910  } 
1911}
1912#endif
1913
1914#if P0138_USE_ALT_CPB_PARAMS_FLAG
1915/**
1916 * Check if SEI message contains payload extension
1917 */
1918Bool SEIReader::xPayloadExtensionPresent()
1919{
1920  Int payloadBitsRemaining = getBitstream()->getNumBitsLeft();
1921  Bool payloadExtensionPresent = false;
1922
1923  if (payloadBitsRemaining > 8)
1924  {
1925    payloadExtensionPresent = true;
1926  }
1927  else
1928  {
1929    Int finalBits = getBitstream()->peekBits(payloadBitsRemaining);
1930    while (payloadBitsRemaining && (finalBits & 1) == 0)
1931    {
1932      payloadBitsRemaining--;
1933      finalBits >>= 1;
1934    }
1935    payloadBitsRemaining--;
1936    if (payloadBitsRemaining > 0)
1937    {
1938      payloadExtensionPresent = true;
1939    }
1940  }
1941
1942  return payloadExtensionPresent;
1943}
1944#endif
1945
1946#if Q0189_TMVP_CONSTRAINTS
1947Void SEIReader::xParseSEITMVPConstraints   (SEITMVPConstrains& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1948{
1949  UInt uiCode;
1950  sei_read_uvlc( pDecodedMessageOutputStream, uiCode,           "prev_pics_not_used_flag"              ); sei.prev_pics_not_used_flag = uiCode;
1951  sei_read_uvlc( pDecodedMessageOutputStream, uiCode,           "no_intra_layer_col_pic_flag"          ); sei.no_intra_layer_col_pic_flag = uiCode;
1952}
1953#endif
1954
1955#if Q0247_FRAME_FIELD_INFO
1956Void SEIReader::xParseSEIFrameFieldInfo    (SEIFrameFieldInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
1957{
1958  UInt code;
1959  sei_read_code( pDecodedMessageOutputStream, 4, code, "ffinfo_pic_struct"       );       sei.m_ffinfo_picStruct      = code;
1960  sei_read_code( pDecodedMessageOutputStream, 2, code, "ffinfo_source_scan_type" );       sei.m_ffinfo_sourceScanType = code;
1961  sei_read_flag( pDecodedMessageOutputStream,    code, "ffinfo_duplicate_flag"   );       sei.m_ffinfo_duplicateFlag  = ( code == 1 ? true : false );
1962}
1963#endif
1964
1965
1966#endif //SVC_EXTENSION
1967
1968//! \}
Note: See TracBrowser for help on using the repository browser.