source: SHVCSoftware/trunk/source/Lib/TLibEncoder/SEIwrite.cpp @ 1335

Last change on this file since 1335 was 906, checked in by seregin, 10 years ago

merge SHM-dev

  • Property svn:eol-style set to native
File size: 50.8 KB
RevLine 
[313]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 *
[595]6 * Copyright (c) 2010-2014, ITU/ISO/IEC
[313]7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#include "TLibCommon/TComBitCounter.h"
35#include "TLibCommon/TComBitStream.h"
36#include "TLibCommon/SEI.h"
37#include "TLibCommon/TComSlice.h"
38#include "SEIwrite.h"
39
40//! \ingroup TLibEncoder
41//! \{
42
43#if ENC_DEC_TRACE
44Void  xTraceSEIHeader()
45{
46  fprintf( g_hTrace, "=========== SEI message ===========\n");
47}
48
49Void  xTraceSEIMessageType(SEI::PayloadType payloadType)
50{
51  switch (payloadType)
52  {
53  case SEI::DECODED_PICTURE_HASH:
54    fprintf( g_hTrace, "=========== Decoded picture hash SEI message ===========\n");
55    break;
56  case SEI::USER_DATA_UNREGISTERED:
57    fprintf( g_hTrace, "=========== User Data Unregistered SEI message ===========\n");
58    break;
59  case SEI::ACTIVE_PARAMETER_SETS:
60    fprintf( g_hTrace, "=========== Active Parameter sets SEI message ===========\n");
61    break;
62  case SEI::BUFFERING_PERIOD:
63    fprintf( g_hTrace, "=========== Buffering period SEI message ===========\n");
64    break;
65  case SEI::PICTURE_TIMING:
66    fprintf( g_hTrace, "=========== Picture timing SEI message ===========\n");
67    break;
68  case SEI::RECOVERY_POINT:
69    fprintf( g_hTrace, "=========== Recovery point SEI message ===========\n");
70    break;
71  case SEI::FRAME_PACKING:
72    fprintf( g_hTrace, "=========== Frame Packing Arrangement SEI message ===========\n");
73    break;
74  case SEI::DISPLAY_ORIENTATION:
75    fprintf( g_hTrace, "=========== Display Orientation SEI message ===========\n");
76    break;
77  case SEI::TEMPORAL_LEVEL0_INDEX:
78    fprintf( g_hTrace, "=========== Temporal Level Zero Index SEI message ===========\n");
79    break;
80  case SEI::REGION_REFRESH_INFO:
81    fprintf( g_hTrace, "=========== Gradual Decoding Refresh Information SEI message ===========\n");
82    break;
83  case SEI::DECODING_UNIT_INFO:
84    fprintf( g_hTrace, "=========== Decoding Unit Information SEI message ===========\n");
85    break;
86  case SEI::TONE_MAPPING_INFO:
87    fprintf( g_hTrace, "=========== Tone Mapping Info SEI message ===========\n");
88    break;
[815]89#if P0050_KNEE_FUNCTION_SEI
90  case SEI::KNEE_FUNCTION_INFO:
91    fprintf( g_hTrace, "=========== Knee Function Information SEI message ===========\n");
92    break;
93#endif
[906]94#if Q0074_COLOUR_REMAPPING_SEI
95  case SEI::COLOUR_REMAPPING_INFO:
96    fprintf( g_hTrace, "=========== Colour Remapping Information SEI message ===========\n");
[713]97    break;
98#endif
[595]99  case SEI::SOP_DESCRIPTION:
100    fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");
101    break;
102  case SEI::SCALABLE_NESTING:
103    fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n");
104    break;
105#if SVC_EXTENSION
[588]106#if LAYERS_NOT_PRESENT_SEI
107  case SEI::LAYERS_NOT_PRESENT:
[313]108    fprintf( g_hTrace, "=========== Layers Present SEI message ===========\n");
109    break;
110#endif
[442]111#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
112  case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS:
113    fprintf( g_hTrace, "=========== Inter Layer Constrained Tile Sets SEI message ===========\n");
114    break;
115#endif
[588]116#if SUB_BITSTREAM_PROPERTY_SEI
[644]117  case SEI::SUB_BITSTREAM_PROPERTY:
118    fprintf( g_hTrace, "=========== Sub-bitstream property SEI message ===========\n");
119    break;
[588]120#endif
[644]121#if O0164_MULTI_LAYER_HRD
122  case SEI::BSP_NESTING:
123    fprintf( g_hTrace, "=========== Bitstream partition nesting SEI message ===========\n");
124    break;
125  case SEI::BSP_INITIAL_ARRIVAL_TIME:
126    fprintf( g_hTrace, "=========== Bitstream parition initial arrival time SEI message ===========\n");
127    break;
[906]128#if !REMOVE_BSP_HRD_SEI
[644]129  case SEI::BSP_HRD:
130    fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n");
131    break;
132#endif
[906]133#endif
[815]134#if Q0078_ADD_LAYER_SETS
135  case SEI::OUTPUT_LAYER_SET_NESTING:
136    fprintf(g_hTrace, "=========== Output layer set nesting SEI message ===========\n");
137    break;
138  case SEI::VPS_REWRITING:
139    fprintf(g_hTrace, "=========== VPS rewriting SEI message ===========\n");
140    break;
141#endif
[595]142#endif //SVC_EXTENSION
[313]143  default:
144    fprintf( g_hTrace, "=========== Unknown SEI message ===========\n");
145    break;
146  }
147}
148#endif
149
[644]150#if O0164_MULTI_LAYER_HRD
[906]151#if VPS_VUI_BSP_HRD_PARAMS
152void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting* nestingSeiPtr, const SEIBspNesting* bspNestingSeiPtr)
153#else
[644]154void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting& nestingSei, const SEIBspNesting& bspNestingSei)
[906]155#endif
[644]156#else
[313]157void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps)
[644]158#endif
[313]159{
[906]160#if VPS_VUI_BSP_HRD_PARAMS
161  SEIScalableNesting nestingSei;
162  SEIBspNesting      bspNestingSei;
163  if( nestingSeiPtr )
164  {
165    nestingSei = *nestingSeiPtr;
166  }
167  if( bspNestingSeiPtr )
168  {
169    bspNestingSei = *bspNestingSeiPtr;
170  }
171#endif
[313]172  switch (sei.payloadType())
173  {
174  case SEI::USER_DATA_UNREGISTERED:
175    xWriteSEIuserDataUnregistered(*static_cast<const SEIuserDataUnregistered*>(&sei));
176    break;
177  case SEI::ACTIVE_PARAMETER_SETS:
178    xWriteSEIActiveParameterSets(*static_cast<const SEIActiveParameterSets*>(& sei)); 
179    break; 
180  case SEI::DECODED_PICTURE_HASH:
181    xWriteSEIDecodedPictureHash(*static_cast<const SEIDecodedPictureHash*>(&sei));
182    break;
[906]183#if VPS_VUI_BSP_HRD_PARAMS
184  case SEI::DECODING_UNIT_INFO:
185    xWriteSEIDecodingUnitInfo(*static_cast<const SEIDecodingUnitInfo*>(& sei), sps, nestingSeiPtr, bspNestingSeiPtr, vps);
186    break;
[313]187  case SEI::BUFFERING_PERIOD:
[906]188    xWriteSEIBufferingPeriod(*static_cast<const SEIBufferingPeriod*>(&sei), sps, nestingSeiPtr, bspNestingSeiPtr, vps);
189    break;
190  case SEI::PICTURE_TIMING:
191    xWriteSEIPictureTiming(*static_cast<const SEIPictureTiming*>(&sei), sps, nestingSeiPtr, bspNestingSeiPtr, vps);
192    break;
193#else
194  case SEI::DECODING_UNIT_INFO:
195    xWriteSEIDecodingUnitInfo(*static_cast<const SEIDecodingUnitInfo*>(& sei), sps);
196    break;
197  case SEI::BUFFERING_PERIOD:
[313]198    xWriteSEIBufferingPeriod(*static_cast<const SEIBufferingPeriod*>(&sei), sps);
199    break;
200  case SEI::PICTURE_TIMING:
201    xWriteSEIPictureTiming(*static_cast<const SEIPictureTiming*>(&sei), sps);
202    break;
[906]203#endif
[313]204  case SEI::RECOVERY_POINT:
205    xWriteSEIRecoveryPoint(*static_cast<const SEIRecoveryPoint*>(&sei));
206    break;
207  case SEI::FRAME_PACKING:
208    xWriteSEIFramePacking(*static_cast<const SEIFramePacking*>(&sei));
209    break;
210  case SEI::DISPLAY_ORIENTATION:
211    xWriteSEIDisplayOrientation(*static_cast<const SEIDisplayOrientation*>(&sei));
212    break;
213  case SEI::TEMPORAL_LEVEL0_INDEX:
214    xWriteSEITemporalLevel0Index(*static_cast<const SEITemporalLevel0Index*>(&sei));
215    break;
216  case SEI::REGION_REFRESH_INFO:
217    xWriteSEIGradualDecodingRefreshInfo(*static_cast<const SEIGradualDecodingRefreshInfo*>(&sei));
218    break;
219  case SEI::TONE_MAPPING_INFO:
220    xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei));
221    break;
[815]222#if P0050_KNEE_FUNCTION_SEI
223  case SEI::KNEE_FUNCTION_INFO:
224    xWriteSEIKneeFunctionInfo(*static_cast<const SEIKneeFunctionInfo*>(&sei));
225    break;
226#endif
[906]227#if Q0074_COLOUR_REMAPPING_SEI
228  case SEI::COLOUR_REMAPPING_INFO:
229    xWriteSEIColourRemappingInfo(*static_cast<const SEIColourRemappingInfo*>(&sei));
[713]230    break;
231#endif
[595]232  case SEI::SOP_DESCRIPTION:
233    xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei));
234    break;
235  case SEI::SCALABLE_NESTING:
[644]236#if O0164_MULTI_LAYER_HRD
237    xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), vps, sps);
238#else
[595]239    xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps);
[644]240#endif
[595]241    break;
242#if SVC_EXTENSION
[588]243#if LAYERS_NOT_PRESENT_SEI
244  case SEI::LAYERS_NOT_PRESENT:
245    xWriteSEILayersNotPresent(*static_cast<const SEILayersNotPresent*>(&sei));
[313]246    break;
247#endif
[442]248#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
249  case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS:
250    xWriteSEIInterLayerConstrainedTileSets(*static_cast<const SEIInterLayerConstrainedTileSets*>(&sei));
251    break;
252#endif
[588]253#if SUB_BITSTREAM_PROPERTY_SEI
254   case SEI::SUB_BITSTREAM_PROPERTY:
255     xWriteSEISubBitstreamProperty(*static_cast<const SEISubBitstreamProperty*>(&sei));
256     break;
257#endif
[644]258#if O0164_MULTI_LAYER_HRD
259   case SEI::BSP_NESTING:
260     xWriteSEIBspNesting(bs, *static_cast<const SEIBspNesting*>(&sei), vps, sps, nestingSei);
261     break;
262   case SEI::BSP_INITIAL_ARRIVAL_TIME:
263     xWriteSEIBspInitialArrivalTime(*static_cast<const SEIBspInitialArrivalTime*>(&sei), vps, sps, nestingSei, bspNestingSei);
264     break;
[906]265#if !REMOVE_BSP_HRD_SEI
[644]266   case SEI::BSP_HRD:
267     xWriteSEIBspHrd(*static_cast<const SEIBspHrd*>(&sei), sps, nestingSei);
268     break;
269#endif
[906]270#endif
[815]271#if Q0078_ADD_LAYER_SETS
272   case SEI::OUTPUT_LAYER_SET_NESTING:
273     xWriteSEIOutputLayerSetNesting(bs, *static_cast<const SEIOutputLayerSetNesting*>(&sei), vps, sps);
274     break;
275   case SEI::VPS_REWRITING:
276     xWriteSEIVPSRewriting(*static_cast<const SEIVPSRewriting*>(&sei));
277     break;
278#endif
279#if Q0189_TMVP_CONSTRAINTS
280   case SEI::TMVP_CONSTRAINTS:
281     xWriteSEITMVPConstraints(*static_cast<const SEITMVPConstrains*>(&sei));
282     break;
283#endif
284#if Q0247_FRAME_FIELD_INFO
285   case SEI::FRAME_FIELD_INFO:
286     xWriteSEIFrameFieldInfo(*static_cast<const SEIFrameFieldInfo*>(&sei));
287     break;
288#endif
[595]289#endif //SVC_EXTENSION
[313]290  default:
291    assert(!"Unhandled SEI message");
292  }
293}
294
295/**
296 * marshal a single SEI message sei, storing the marshalled representation
297 * in bitstream bs.
298 */
[644]299#if O0164_MULTI_LAYER_HRD
300Void SEIWriter::writeSEImessage(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei)
301#else
[313]302Void SEIWriter::writeSEImessage(TComBitIf& bs, const SEI& sei, TComSPS *sps)
[644]303#endif
[313]304{
305  /* calculate how large the payload data is */
306  /* TODO: this would be far nicer if it used vectored buffers */
307  TComBitCounter bs_count;
308  bs_count.resetBits();
309  setBitstream(&bs_count);
310
311
312#if ENC_DEC_TRACE
313  Bool traceEnable = g_HLSTraceEnable;
314  g_HLSTraceEnable = false;
315#endif
[644]316#if O0164_MULTI_LAYER_HRD
[906]317#if VPS_VUI_BSP_HRD_PARAMS
318  xWriteSEIpayloadData(bs_count, sei, vps, sps, nestingSei, bspNestingSei);
319#else
[644]320  xWriteSEIpayloadData(bs_count, sei, vps, sps, *nestingSei, *bspNestingSei);
[906]321#endif
[644]322#else
[313]323  xWriteSEIpayloadData(bs_count, sei, sps);
[644]324#endif
[313]325#if ENC_DEC_TRACE
326  g_HLSTraceEnable = traceEnable;
327#endif
328
329  UInt payload_data_num_bits = bs_count.getNumberOfWrittenBits();
330  assert(0 == payload_data_num_bits % 8);
331
332  setBitstream(&bs);
333
334#if ENC_DEC_TRACE
335  if (g_HLSTraceEnable)
336  xTraceSEIHeader();
337#endif
338
339  UInt payloadType = sei.payloadType();
340  for (; payloadType >= 0xff; payloadType -= 0xff)
341  {
342    WRITE_CODE(0xff, 8, "payload_type");
343  }
344  WRITE_CODE(payloadType, 8, "payload_type");
345
346  UInt payloadSize = payload_data_num_bits/8;
347  for (; payloadSize >= 0xff; payloadSize -= 0xff)
348  {
349    WRITE_CODE(0xff, 8, "payload_size");
350  }
351  WRITE_CODE(payloadSize, 8, "payload_size");
352
353  /* payloadData */
354#if ENC_DEC_TRACE
355  if (g_HLSTraceEnable)
356  xTraceSEIMessageType(sei.payloadType());
357#endif
358
[644]359#if O0164_MULTI_LAYER_HRD
[906]360#if VPS_VUI_BSP_HRD_PARAMS
361  xWriteSEIpayloadData(bs, sei, vps, sps, nestingSei, bspNestingSei);
362#else
[644]363  xWriteSEIpayloadData(bs, sei, vps, sps, *nestingSei, *bspNestingSei);
[906]364#endif
[644]365#else
[313]366  xWriteSEIpayloadData(bs, sei, sps);
[644]367#endif
[313]368}
369
370/**
371 * marshal a user_data_unregistered SEI message sei, storing the marshalled
372 * representation in bitstream bs.
373 */
374Void SEIWriter::xWriteSEIuserDataUnregistered(const SEIuserDataUnregistered &sei)
375{
376  for (UInt i = 0; i < 16; i++)
377  {
378    WRITE_CODE(sei.uuid_iso_iec_11578[i], 8 , "sei.uuid_iso_iec_11578[i]");
379  }
380
381  for (UInt i = 0; i < sei.userDataLength; i++)
382  {
383    WRITE_CODE(sei.userData[i], 8 , "user_data");
384  }
385}
386
387/**
388 * marshal a decoded picture hash SEI message, storing the marshalled
389 * representation in bitstream bs.
390 */
391Void SEIWriter::xWriteSEIDecodedPictureHash(const SEIDecodedPictureHash& sei)
392{
393  UInt val;
394
395  WRITE_CODE(sei.method, 8, "hash_type");
396
397  for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++)
398  {
399    if(sei.method == SEIDecodedPictureHash::MD5)
400    {
401      for (UInt i = 0; i < 16; i++)
402      {
403        WRITE_CODE(sei.digest[yuvIdx][i], 8, "picture_md5");
404      }
405    }
406    else if(sei.method == SEIDecodedPictureHash::CRC)
407    {
408      val = (sei.digest[yuvIdx][0] << 8)  + sei.digest[yuvIdx][1];
409      WRITE_CODE(val, 16, "picture_crc");
410    }
411    else if(sei.method == SEIDecodedPictureHash::CHECKSUM)
412    {
413      val = (sei.digest[yuvIdx][0] << 24)  + (sei.digest[yuvIdx][1] << 16) + (sei.digest[yuvIdx][2] << 8) + sei.digest[yuvIdx][3];
414      WRITE_CODE(val, 32, "picture_checksum");
415    }
416  }
417}
418
419Void SEIWriter::xWriteSEIActiveParameterSets(const SEIActiveParameterSets& sei)
420{
[713]421  WRITE_CODE(sei.activeVPSId,     4,         "active_video_parameter_set_id");
422  WRITE_FLAG(sei.m_selfContainedCvsFlag,     "self_contained_cvs_flag");
423  WRITE_FLAG(sei.m_noParameterSetUpdateFlag, "no_parameter_set_update_flag");
[313]424  WRITE_UVLC(sei.numSpsIdsMinus1,    "num_sps_ids_minus1");
425
[713]426  assert (sei.activeSeqParameterSetId.size() == (sei.numSpsIdsMinus1 + 1));
[313]427
[713]428  for (Int i = 0; i < sei.activeSeqParameterSetId.size(); i++)
[313]429  {
[713]430    WRITE_UVLC(sei.activeSeqParameterSetId[i], "active_seq_parameter_set_id"); 
[313]431  }
[906]432#if R0247_SEI_ACTIVE
433  for (Int i = 1; i < sei.activeSeqParameterSetId.size(); i++)
434  {
435    WRITE_UVLC(sei.layerSpsIdx[i], "layer_sps_idx"); 
436  }
437#endif
[713]438  xWriteByteAlign();
[313]439}
440
[906]441#if VPS_VUI_BSP_HRD_PARAMS
442Void SEIWriter::xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps)
443#else
[313]444Void SEIWriter::xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, TComSPS *sps)
[906]445#endif
[313]446{
[906]447#if VPS_VUI_BSP_HRD_PARAMS
448  TComHRD *hrd;
449  if( bspNestingSei )   // If DU info SEI contained inside a BSP nesting SEI message
450  {
451    assert( nestingSei );
452    Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx;
453    Int seiOlsIdx = bspNestingSei->m_seiOlsIdx;
454    Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1;
455    Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1;
456    std::vector<Int> hrdIdx(maxValues, 0);
457    std::vector<TComHRD *> hrdVec;
458    std::vector<Int> syntaxElemLen(maxValues, 0);
459    for(Int i = 0; i < maxValues; i++)
460    {
461      hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx);
462      hrdVec.push_back(vps->getBspHrd(hrdIdx[i]));
463   
464      syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1;
465      if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) )
466      {
467        assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23
468      }
469      if( i > 0 )
470      {
471        assert( hrdVec[i]->getSubPicCpbParamsPresentFlag()    == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() );
472        assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag()   == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() );
473        assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1()  == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() );
474        // To be done: Check CpbDpbDelaysPresentFlag
475      }
476    }
477    hrd = hrdVec[0];
478  }
479  else
480  {
481    TComVUI *vui = sps->getVuiParameters();
482    hrd = vui->getHrdParameters();
483  }
484#else
[313]485  TComVUI *vui = sps->getVuiParameters();
[906]486  TComHrd *hrd = vui->getHrdParameters();
487#endif
[313]488  WRITE_UVLC(sei.m_decodingUnitIdx, "decoding_unit_idx");
[906]489  if(hrd->getSubPicCpbParamsInPicTimingSEIFlag())
[313]490  {
[906]491    WRITE_CODE( sei.m_duSptCpbRemovalDelay, (hrd->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay");
[313]492  }
493  WRITE_FLAG( sei.m_dpbOutputDuDelayPresentFlag, "dpb_output_du_delay_present_flag");
494  if(sei.m_dpbOutputDuDelayPresentFlag)
495  {
[906]496    WRITE_CODE(sei.m_picSptDpbOutputDuDelay,hrd->getDpbOutputDelayDuLengthMinus1() + 1, "pic_spt_dpb_output_du_delay");
[313]497  }
498  xWriteByteAlign();
499}
500
[906]501#if VPS_VUI_BSP_HRD_PARAMS
502Void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps)
503#else
[313]504Void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, TComSPS *sps)
[906]505#endif
[313]506{
507  Int i, nalOrVcl;
[906]508#if VPS_VUI_BSP_HRD_PARAMS
509  TComHRD *hrd;
510  if( bspNestingSei )   // If BP SEI contained inside a BSP nesting SEI message
511  {
512    assert( nestingSei );
513    Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx;
514    Int seiOlsIdx = bspNestingSei->m_seiOlsIdx;
515    Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1;
516    Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1;
517    std::vector<Int> hrdIdx(maxValues, 0);
518    std::vector<TComHRD *> hrdVec;
519    std::vector<Int> syntaxElemLen(maxValues, 0);
520    for(i = 0; i < maxValues; i++)
521    {
522      hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx);
523      hrdVec.push_back(vps->getBspHrd(hrdIdx[i]));
524   
525      syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1;
526      if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) )
527      {
528        assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23
529      }
530      if( i > 0 )
531      {
532        assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1()   == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() );
533        assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1()  == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() );
534        assert( hrdVec[i]->getSubPicCpbParamsPresentFlag()    == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() );
535      }
536    }
537    hrd = hrdVec[i];
538  }
539  else
540  {
541    TComVUI *vui = sps->getVuiParameters();
542    hrd = vui->getHrdParameters();
543  }
544  // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently.
545#else
[313]546  TComVUI *vui = sps->getVuiParameters();
547  TComHRD *hrd = vui->getHrdParameters();
[906]548#endif
[313]549
550  WRITE_UVLC( sei.m_bpSeqParameterSetId, "bp_seq_parameter_set_id" );
551  if( !hrd->getSubPicCpbParamsPresentFlag() )
552  {
[595]553    WRITE_FLAG( sei.m_rapCpbParamsPresentFlag, "irap_cpb_params_present_flag" );
[313]554  }
555  if( sei.m_rapCpbParamsPresentFlag )
556  {
557    WRITE_CODE( sei.m_cpbDelayOffset, hrd->getCpbRemovalDelayLengthMinus1() + 1, "cpb_delay_offset" );
558    WRITE_CODE( sei.m_dpbDelayOffset, hrd->getDpbOutputDelayLengthMinus1()  + 1, "dpb_delay_offset" );
559  }
[595]560  WRITE_FLAG( sei.m_concatenationFlag, "concatenation_flag");
561  WRITE_CODE( sei.m_auCpbRemovalDelayDelta - 1, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), "au_cpb_removal_delay_delta_minus1" );
[313]562  for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
563  {
564    if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) ||
565        ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )
566    {
567      for( i = 0; i < ( hrd->getCpbCntMinus1( 0 ) + 1 ); i ++ )
568      {
569        WRITE_CODE( sei.m_initialCpbRemovalDelay[i][nalOrVcl],( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ) ,           "initial_cpb_removal_delay" );
570        WRITE_CODE( sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl],( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ),      "initial_cpb_removal_delay_offset" );
571        if( hrd->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag )
572        {
573          WRITE_CODE( sei.m_initialAltCpbRemovalDelay[i][nalOrVcl], ( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ) ,     "initial_alt_cpb_removal_delay" );
574          WRITE_CODE( sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl], ( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ),"initial_alt_cpb_removal_delay_offset" );
575        }
576      }
577    }
578  }
[644]579#if P0138_USE_ALT_CPB_PARAMS_FLAG
580  if (sei.m_useAltCpbParamsFlagPresent)
581  {
582    WRITE_FLAG( sei.m_useAltCpbParamsFlag, "use_alt_cpb_params_flag");
583  }
584#endif
[313]585  xWriteByteAlign();
586}
[906]587#if VPS_VUI_BSP_HRD_PARAMS
588Void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei,  TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps)
589#else
[313]590Void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei,  TComSPS *sps)
[906]591#endif
[313]592{
593  Int i;
[906]594#if VPS_VUI_BSP_HRD_PARAMS
595  TComHRD *hrd;   
596  TComVUI *vui = sps->getVuiParameters(); 
597  if( bspNestingSei )   // If BP SEI contained inside a BSP nesting SEI message
598  {
599    assert( nestingSei );
600    Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx;
601    Int seiOlsIdx = bspNestingSei->m_seiOlsIdx;
602    Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1;
603    Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1;
604    std::vector<Int> hrdIdx(maxValues, 0);
605    std::vector<TComHRD *> hrdVec;
606    std::vector<Int> syntaxElemLen(maxValues, 0);
607    for(i = 0; i < maxValues; i++)
608    {
609      hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx);
610      hrdVec.push_back(vps->getBspHrd(hrdIdx[i]));
611   
612      syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1;
613      if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) )
614      {
615        assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23
616      }
617      if( i > 0 )
618      {
619        assert( hrdVec[i]->getSubPicCpbParamsPresentFlag()    == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() );
620        assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag()   == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() );
621        assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1()  == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() );
622        assert( hrdVec[i]->getDpbOutputDelayLengthMinus1()  == hrdVec[i-1]->getDpbOutputDelayLengthMinus1() );
623        assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1()  == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() );
624        assert( hrdVec[i]->getDuCpbRemovalDelayLengthMinus1()  == hrdVec[i-1]->getDuCpbRemovalDelayLengthMinus1() );
625        // To be done: Check CpbDpbDelaysPresentFlag
626      }
627    }
628    hrd = hrdVec[0];
629  }
630  else
631  {
632    hrd = vui->getHrdParameters();
633  }
634  // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently.
635#else
[313]636  TComVUI *vui = sps->getVuiParameters();
637  TComHRD *hrd = vui->getHrdParameters();
[906]638#endif
[313]639
[906]640  if( vui->getFrameFieldInfoPresentFlag() ) // To be done: Check whether this is the correct invocation of vui when PT SEI contained in BSP nesting SEI
[313]641  {
642    WRITE_CODE( sei.m_picStruct, 4,              "pic_struct" );
643    WRITE_CODE( sei.m_sourceScanType, 2,         "source_scan_type" );
644    WRITE_FLAG( sei.m_duplicateFlag ? 1 : 0,     "duplicate_flag" );
645  }
646
647  if( hrd->getCpbDpbDelaysPresentFlag() )
648  {
649    WRITE_CODE( sei.m_auCpbRemovalDelay - 1, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ),                                         "au_cpb_removal_delay_minus1" );
650    WRITE_CODE( sei.m_picDpbOutputDelay, ( hrd->getDpbOutputDelayLengthMinus1() + 1 ),                                          "pic_dpb_output_delay" );
651    if(hrd->getSubPicCpbParamsPresentFlag())
652    {
653      WRITE_CODE(sei.m_picDpbOutputDuDelay, hrd->getDpbOutputDelayDuLengthMinus1()+1, "pic_dpb_output_du_delay" );
654    }
655    if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() )
656    {
657      WRITE_UVLC( sei.m_numDecodingUnitsMinus1,     "num_decoding_units_minus1" );
658      WRITE_FLAG( sei.m_duCommonCpbRemovalDelayFlag, "du_common_cpb_removal_delay_flag" );
659      if( sei.m_duCommonCpbRemovalDelayFlag )
660      {
661        WRITE_CODE( sei.m_duCommonCpbRemovalDelayMinus1, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ),                       "du_common_cpb_removal_delay_minus1" );
662      }
663      for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ )
664      {
665        WRITE_UVLC( sei.m_numNalusInDuMinus1[ i ],  "num_nalus_in_du_minus1");
666        if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) )
667        {
668          WRITE_CODE( sei.m_duCpbRemovalDelayMinus1[ i ], ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ),                        "du_cpb_removal_delay_minus1" );
669        }
670      }
671    }
672  }
673  xWriteByteAlign();
674}
675Void SEIWriter::xWriteSEIRecoveryPoint(const SEIRecoveryPoint& sei)
676{
677  WRITE_SVLC( sei.m_recoveryPocCnt,    "recovery_poc_cnt"    );
678  WRITE_FLAG( sei.m_exactMatchingFlag, "exact_matching_flag" );
679  WRITE_FLAG( sei.m_brokenLinkFlag,    "broken_link_flag"    );
680  xWriteByteAlign();
681}
682Void SEIWriter::xWriteSEIFramePacking(const SEIFramePacking& sei)
683{
684  WRITE_UVLC( sei.m_arrangementId,                  "frame_packing_arrangement_id" );
685  WRITE_FLAG( sei.m_arrangementCancelFlag,          "frame_packing_arrangement_cancel_flag" );
686
687  if( sei.m_arrangementCancelFlag == 0 ) {
688    WRITE_CODE( sei.m_arrangementType, 7,           "frame_packing_arrangement_type" );
689
690    WRITE_FLAG( sei.m_quincunxSamplingFlag,         "quincunx_sampling_flag" );
691    WRITE_CODE( sei.m_contentInterpretationType, 6, "content_interpretation_type" );
692    WRITE_FLAG( sei.m_spatialFlippingFlag,          "spatial_flipping_flag" );
693    WRITE_FLAG( sei.m_frame0FlippedFlag,            "frame0_flipped_flag" );
694    WRITE_FLAG( sei.m_fieldViewsFlag,               "field_views_flag" );
695    WRITE_FLAG( sei.m_currentFrameIsFrame0Flag,     "current_frame_is_frame0_flag" );
696
697    WRITE_FLAG( sei.m_frame0SelfContainedFlag,      "frame0_self_contained_flag" );
698    WRITE_FLAG( sei.m_frame1SelfContainedFlag,      "frame1_self_contained_flag" );
699
700    if(sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5)
701    {
702      WRITE_CODE( sei.m_frame0GridPositionX, 4,     "frame0_grid_position_x" );
703      WRITE_CODE( sei.m_frame0GridPositionY, 4,     "frame0_grid_position_y" );
704      WRITE_CODE( sei.m_frame1GridPositionX, 4,     "frame1_grid_position_x" );
705      WRITE_CODE( sei.m_frame1GridPositionY, 4,     "frame1_grid_position_y" );
706    }
707
708    WRITE_CODE( sei.m_arrangementReservedByte, 8,   "frame_packing_arrangement_reserved_byte" );
709    WRITE_FLAG( sei.m_arrangementPersistenceFlag,   "frame_packing_arrangement_persistence_flag" );
710  }
711
712  WRITE_FLAG( sei.m_upsampledAspectRatio,           "upsampled_aspect_ratio" );
713
714  xWriteByteAlign();
715}
716
717Void SEIWriter::xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei)
718{
719  Int i;
720  WRITE_UVLC( sei.m_toneMapId,                    "tone_map_id" );
721  WRITE_FLAG( sei.m_toneMapCancelFlag,            "tone_map_cancel_flag" );
722  if( !sei.m_toneMapCancelFlag ) 
723  {
724    WRITE_FLAG( sei.m_toneMapPersistenceFlag,     "tone_map_persistence_flag" );
725    WRITE_CODE( sei.m_codedDataBitDepth,    8,    "coded_data_bit_depth" );
726    WRITE_CODE( sei.m_targetBitDepth,       8,    "target_bit_depth" );
727    WRITE_UVLC( sei.m_modelId,                    "model_id" );
728    switch(sei.m_modelId)
729    {
730    case 0:
731      {
732        WRITE_CODE( sei.m_minValue,  32,        "min_value" );
733        WRITE_CODE( sei.m_maxValue, 32,         "max_value" );
734        break;
735      }
736    case 1:
737      {
738        WRITE_CODE( sei.m_sigmoidMidpoint, 32,  "sigmoid_midpoint" );
739        WRITE_CODE( sei.m_sigmoidWidth,    32,  "sigmoid_width"    );
740        break;
741      }
742    case 2:
743      {
744        UInt num = 1u << sei.m_targetBitDepth;
745        for(i = 0; i < num; i++)
746        {
747          WRITE_CODE( sei.m_startOfCodedInterval[i], (( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3,  "start_of_coded_interval" );
748        }
749        break;
750      }
751    case 3:
752      {
753        WRITE_CODE( sei.m_numPivots, 16,          "num_pivots" );
754        for(i = 0; i < sei.m_numPivots; i++ )
755        {
756          WRITE_CODE( sei.m_codedPivotValue[i], (( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3,       "coded_pivot_value" );
757          WRITE_CODE( sei.m_targetPivotValue[i], (( sei.m_targetBitDepth + 7 ) >> 3 ) << 3,         "target_pivot_value");
758        }
759        break;
760      }
761    case 4:
762      {
763        WRITE_CODE( sei.m_cameraIsoSpeedIdc,    8,    "camera_iso_speed_idc" );
764        if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO
765        {
766          WRITE_CODE( sei.m_cameraIsoSpeedValue,    32,    "camera_iso_speed_value" );
767        }
[713]768        WRITE_CODE( sei.m_exposureIndexIdc,     8,    "exposure_index_idc" );
769        if( sei.m_exposureIndexIdc == 255) //Extended_ISO
770        {
771          WRITE_CODE( sei.m_exposureIndexValue,     32,    "exposure_index_value" );
772        }
[313]773        WRITE_FLAG( sei.m_exposureCompensationValueSignFlag,           "exposure_compensation_value_sign_flag" );
774        WRITE_CODE( sei.m_exposureCompensationValueNumerator,     16,  "exposure_compensation_value_numerator" );
775        WRITE_CODE( sei.m_exposureCompensationValueDenomIdc,      16,  "exposure_compensation_value_denom_idc" );
776        WRITE_CODE( sei.m_refScreenLuminanceWhite,                32,  "ref_screen_luminance_white" );
777        WRITE_CODE( sei.m_extendedRangeWhiteLevel,                32,  "extended_range_white_level" );
778        WRITE_CODE( sei.m_nominalBlackLevelLumaCodeValue,         16,  "nominal_black_level_luma_code_value" );
779        WRITE_CODE( sei.m_nominalWhiteLevelLumaCodeValue,         16,  "nominal_white_level_luma_code_value" );
780        WRITE_CODE( sei.m_extendedWhiteLevelLumaCodeValue,        16,  "extended_white_level_luma_code_value" );
781        break;
782      }
783    default:
784      {
785        assert(!"Undefined SEIToneMapModelId");
786        break;
787      }
788    }//switch m_modelId
789  }//if(!sei.m_toneMapCancelFlag)
790
791  xWriteByteAlign();
792}
[815]793#if P0050_KNEE_FUNCTION_SEI
794Void SEIWriter::xWriteSEIKneeFunctionInfo(const SEIKneeFunctionInfo &sei)
795{
796  WRITE_UVLC( sei.m_kneeId, "knee_function_id" );
797  WRITE_FLAG( sei.m_kneeCancelFlag, "knee_function_cancel_flag" ); 
798  if ( !sei.m_kneeCancelFlag )
799  {
800    WRITE_FLAG( sei.m_kneePersistenceFlag, "knee_function_persistence_flag" );
801    WRITE_FLAG( sei.m_kneeMappingFlag, "mapping_flag" );
802    WRITE_CODE( (UInt)sei.m_kneeInputDrange , 32,  "input_d_range" );
803    WRITE_CODE( (UInt)sei.m_kneeInputDispLuminance, 32,  "input_disp_luminance" );
804    WRITE_CODE( (UInt)sei.m_kneeOutputDrange, 32,  "output_d_range" );
805    WRITE_CODE( (UInt)sei.m_kneeOutputDispLuminance, 32,  "output_disp_luminance" );
806    WRITE_UVLC( sei.m_kneeNumKneePointsMinus1, "num_knee_points_minus1" );
807    for(Int i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ )
808    {
809      WRITE_CODE( (UInt)sei.m_kneeInputKneePoint[i], 10,"input_knee_point" );
810      WRITE_CODE( (UInt)sei.m_kneeOutputKneePoint[i], 10, "output_knee_point" );
811    }
812  }
813  xWriteByteAlign();
814}
815#endif
[906]816#if Q0074_COLOUR_REMAPPING_SEI
817Void SEIWriter::xWriteSEIColourRemappingInfo(const SEIColourRemappingInfo& sei)
[713]818{
[906]819  WRITE_UVLC( sei.m_colourRemapId,                             "colour_remap_id" );
820  WRITE_FLAG( sei.m_colourRemapCancelFlag,                     "colour_remap_cancel_flag" );
821  if( !sei.m_colourRemapCancelFlag ) 
[713]822  {
[906]823    WRITE_FLAG( sei.m_colourRemapPersistenceFlag,              "colour_remap_persistence_flag" );
824    WRITE_FLAG( sei.m_colourRemapVideoSignalInfoPresentFlag,   "colour_remap_video_signal_info_present_flag" );
825    if ( sei.m_colourRemapVideoSignalInfoPresentFlag )
[713]826    {
[906]827      WRITE_FLAG( sei.m_colourRemapFullRangeFlag,              "colour_remap_full_range_flag" );
828      WRITE_CODE( sei.m_colourRemapPrimaries,               8, "colour_remap_primaries" );
829      WRITE_CODE( sei.m_colourRemapTransferFunction,        8, "colour_remap_transfer_function" );
830      WRITE_CODE( sei.m_colourRemapMatrixCoefficients,      8, "colour_remap_matrix_coefficients" );
[713]831    }
[906]832    WRITE_CODE( sei.m_colourRemapInputBitDepth,             8, "colour_remap_input_bit_depth" );
833    WRITE_CODE( sei.m_colourRemapBitDepth,                  8, "colour_remap_bit_depth" );
834    for( Int c=0 ; c<3 ; c++ )
[713]835    {
[906]836      WRITE_CODE( sei.m_preLutNumValMinus1[c],              8, "pre_lut_num_val_minus1[c]" );
837      if( sei.m_preLutNumValMinus1[c]>0 )
838        for( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ )
839        {
840          WRITE_CODE( sei.m_preLutCodedValue[c][i], (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, "pre_lut_coded_value[c][i]" );
841          WRITE_CODE( sei.m_preLutTargetValue[c][i], (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "pre_lut_target_value[c][i]" );
842        }
[713]843    }
[906]844    WRITE_FLAG( sei.m_colourRemapMatrixPresentFlag,            "colour_remap_matrix_present_flag" );
845    if( sei.m_colourRemapMatrixPresentFlag )
[713]846    {
[906]847      WRITE_CODE( sei.m_log2MatrixDenom,                    4, "log2_matrix_denom" );
848      for( Int c=0 ; c<3 ; c++ )
849        for( Int i=0 ; i<3 ; i++ )
850          WRITE_SVLC( sei.m_colourRemapCoeffs[c][i],           "colour_remap_coeffs[c][i]" );
[713]851    }
852
[906]853    for( Int c=0 ; c<3 ; c++ )
[713]854    {
[906]855      WRITE_CODE( sei.m_postLutNumValMinus1[c],             8, "m_postLutNumValMinus1[c]" );
856      if( sei.m_postLutNumValMinus1[c]>0 )
857        for( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ )
858        {
859          WRITE_CODE( sei.m_postLutCodedValue[c][i], (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_coded_value[c][i]" );       
860          WRITE_CODE( sei.m_postLutTargetValue[c][i], (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_target_value[c][i]" );
861        }
[713]862    }
863  }
864  xWriteByteAlign();
865}
866#endif
867
[313]868Void SEIWriter::xWriteSEIDisplayOrientation(const SEIDisplayOrientation &sei)
869{
870  WRITE_FLAG( sei.cancelFlag,           "display_orientation_cancel_flag" );
871  if( !sei.cancelFlag )
872  {
873    WRITE_FLAG( sei.horFlip,                   "hor_flip" );
874    WRITE_FLAG( sei.verFlip,                   "ver_flip" );
875    WRITE_CODE( sei.anticlockwiseRotation, 16, "anticlockwise_rotation" );
876    WRITE_FLAG( sei.persistenceFlag,          "display_orientation_persistence_flag" );
877  }
878  xWriteByteAlign();
879}
880
881Void SEIWriter::xWriteSEITemporalLevel0Index(const SEITemporalLevel0Index &sei)
882{
883  WRITE_CODE( sei.tl0Idx, 8 , "tl0_idx" );
884  WRITE_CODE( sei.rapIdx, 8 , "rap_idx" );
885  xWriteByteAlign();
886}
887
888Void SEIWriter::xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei)
889{
890  WRITE_FLAG( sei.m_gdrForegroundFlag, "gdr_foreground_flag");
891  xWriteByteAlign();
892}
893
894Void SEIWriter::xWriteSEISOPDescription(const SEISOPDescription& sei)
895{
896  WRITE_UVLC( sei.m_sopSeqParameterSetId,           "sop_seq_parameter_set_id"               );
897  WRITE_UVLC( sei.m_numPicsInSopMinus1,             "num_pics_in_sop_minus1"               );
898  for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++)
899  {
900    WRITE_CODE( sei.m_sopDescVclNaluType[i], 6, "sop_desc_vcl_nalu_type" );
901    WRITE_CODE( sei.m_sopDescTemporalId[i],  3, "sop_desc_temporal_id" );
902    if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP)
903    {
904      WRITE_UVLC( sei.m_sopDescStRpsIdx[i],           "sop_desc_st_rps_idx"               );
905    }
906    if (i > 0)
907    {
908      WRITE_SVLC( sei.m_sopDescPocDelta[i],           "sop_desc_poc_delta"               );
909    }
910  }
911
912  xWriteByteAlign();
913}
914
[644]915#if O0164_MULTI_LAYER_HRD
916Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComVPS *vps, TComSPS *sps)
917#else
[595]918Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps)
[644]919#endif
[595]920{
921  WRITE_FLAG( sei.m_bitStreamSubsetFlag,             "bitstream_subset_flag"         );
922  WRITE_FLAG( sei.m_nestingOpFlag,                   "nesting_op_flag      "         );
923  if (sei.m_nestingOpFlag)
924  {
925    WRITE_FLAG( sei.m_defaultOpFlag,                 "default_op_flag"               );
[906]926    WRITE_UVLC( sei.m_nestingNumOpsMinus1,           "nesting_num_ops_minus1"        );
[595]927    for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++)
928    {
[906]929      WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3,  "nesting_max_temporal_id_plus1" );
[595]930      WRITE_UVLC( sei.m_nestingOpIdx[i],                  "nesting_op_idx"                );
931    }
932  }
933  else
934  {
935    WRITE_FLAG( sei.m_allLayersFlag,                      "all_layers_flag"               );
936    if (!sei.m_allLayersFlag)
937    {
[906]938      WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id_plus1" );
939      WRITE_UVLC( sei.m_nestingNumLayersMinus1,           "nesting_num_layers"                  );
[595]940      for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++)
941      {
942        WRITE_CODE( sei.m_nestingLayerId[i], 6,           "nesting_layer_id"              );
943      }
944    }
945  }
946 
947  // byte alignment
948  while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
949  {
950    WRITE_FLAG( 0, "nesting_zero_bit" );
951  }
952
953  // write nested SEI messages
954  for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++)
955  {
[644]956#if O0164_MULTI_LAYER_HRD
957    writeSEImessage(bs, *(*it), vps, sps, &sei);
958#else
[595]959    writeSEImessage(bs, *(*it), sps);
[644]960#endif
[595]961  }
962}
963
964Void SEIWriter::xWriteByteAlign()
965{
966  if( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0)
967  {
968    WRITE_FLAG( 1, "bit_equal_to_one" );
969    while( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
970    {
971      WRITE_FLAG( 0, "bit_equal_to_zero" );
972    }
973  }
974};
975
976#if SVC_EXTENSION
977#if LAYERS_NOT_PRESENT_SEI
978Void SEIWriter::xWriteSEILayersNotPresent(const SEILayersNotPresent& sei)
979{
980  WRITE_UVLC( sei.m_activeVpsId,           "lp_sei_active_vps_id" );
981  for (UInt i = 0; i < sei.m_vpsMaxLayers; i++)
982  {
983    WRITE_FLAG( sei.m_layerNotPresentFlag[i], "layer_not_present_flag"   );
984  }
985  xWriteByteAlign();
986}
987#endif
988
[442]989#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
990Void SEIWriter::xWriteSEIInterLayerConstrainedTileSets(const SEIInterLayerConstrainedTileSets& sei)
991{
992  WRITE_FLAG( sei.m_ilAllTilesExactSampleValueMatchFlag,  "il_all_tiles_exact_sample_value_match_flag"   );
993  WRITE_FLAG( sei.m_ilOneTilePerTileSetFlag,              "il_one_tile_per_tile_set_flag"                );
994  if( !sei.m_ilOneTilePerTileSetFlag )
995  {
996    WRITE_UVLC( sei.m_ilNumSetsInMessageMinus1,             "il_num_sets_in_message_minus1"                );
997    if( sei.m_ilNumSetsInMessageMinus1 )
998    {
999      WRITE_FLAG( sei.m_skippedTileSetPresentFlag,            "skipped_tile_set_present_flag"                );
1000    }
1001    UInt numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - (sei.m_skippedTileSetPresentFlag ? 1 : 0) + 1;
1002    for( UInt i = 0; i < numSignificantSets; i++ )
1003    {
1004      WRITE_UVLC( sei.m_ilctsId[i],                           "ilcts_id"                                     );
1005      WRITE_UVLC( sei.m_ilNumTileRectsInSetMinus1[i],         "il_num_tile_rects_in_set_minus1"              );
1006      for( UInt j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[i]; j++ )
1007      {
1008        WRITE_UVLC( sei.m_ilTopLeftTileIndex[i][j],             "il_top_left_tile_index"                       );
1009        WRITE_UVLC( sei.m_ilBottomRightTileIndex[i][j],         "il_bottom_right_tile_index"                   );
1010      }
1011      WRITE_CODE( sei.m_ilcIdc[i], 2,                         "ilc_idc"                                      );
1012      if( sei.m_ilAllTilesExactSampleValueMatchFlag )
1013      {
1014        WRITE_FLAG( sei.m_ilExactSampleValueMatchFlag[i],        "il_exact_sample_value_match_flag"            );
1015      }
1016    }
1017  }
1018  else
1019  {
1020    WRITE_CODE( sei.m_allTilesIlcIdc, 2,                    "all_tiles_ilc_idc"                          );
1021  }
1022
1023  xWriteByteAlign();
1024}
1025#endif
[588]1026#if SUB_BITSTREAM_PROPERTY_SEI
1027Void SEIWriter::xWriteSEISubBitstreamProperty(const SEISubBitstreamProperty &sei)
1028{
1029  WRITE_CODE( sei.m_activeVpsId, 4, "active_vps_id" );
1030  assert( sei.m_numAdditionalSubStreams >= 1 );
1031  WRITE_UVLC( sei.m_numAdditionalSubStreams - 1, "num_additional_sub_streams_minus1" );
[442]1032
[588]1033  for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ )
1034  {
1035    WRITE_CODE( sei.m_subBitstreamMode[i],       2, "sub_bitstream_mode[i]"           );
1036    WRITE_UVLC( sei.m_outputLayerSetIdxToVps[i],    "output_layer_set_idx_to_vps[i]"  );
1037    WRITE_CODE( sei.m_highestSublayerId[i],      3, "highest_sub_layer_id[i]"         );
1038    WRITE_CODE( sei.m_avgBitRate[i],            16, "avg_bit_rate[i]"                 );
1039    WRITE_CODE( sei.m_maxBitRate[i],            16, "max_bit_rate[i]"                 );
1040  }
1041  xWriteByteAlign();
1042}
1043#endif
[644]1044
[815]1045#if Q0189_TMVP_CONSTRAINTS
1046Void SEIWriter::xWriteSEITMVPConstraints (const SEITMVPConstrains &sei)
1047{
1048  WRITE_UVLC( sei.prev_pics_not_used_flag ,    "prev_pics_not_used_flag"  );
1049  WRITE_UVLC( sei.no_intra_layer_col_pic_flag ,    "no_intra_layer_col_pic_flag"  ); 
1050  xWriteByteAlign();
1051}
1052#endif
1053
1054#if Q0247_FRAME_FIELD_INFO
1055Void SEIWriter::xWriteSEIFrameFieldInfo  (const SEIFrameFieldInfo &sei)
1056{
1057  WRITE_CODE( sei.m_ffinfo_picStruct , 4,             "ffinfo_pic_struct" );
1058  WRITE_CODE( sei.m_ffinfo_sourceScanType, 2,         "ffinfo_source_scan_type" );
1059  WRITE_FLAG( sei.m_ffinfo_duplicateFlag ? 1 : 0,     "ffinfo_duplicate_flag" );
1060  xWriteByteAlign();
1061}
1062#endif
1063
[644]1064#if O0164_MULTI_LAYER_HRD
1065Void SEIWriter::xWriteSEIBspNesting(TComBitIf& bs, const SEIBspNesting &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei)
1066{
1067  WRITE_UVLC( sei.m_bspIdx, "bsp_idx" );
1068
1069  while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
1070  {
1071    WRITE_FLAG( 0, "bsp_nesting_zero_bit" );
1072  }
[906]1073#if NESTING_SEI_EXTENSIBILITY
1074  assert( sei.m_nestedSEIs.size() <= MAX_SEIS_IN_BSP_NESTING );
1075  WRITE_UVLC( sei.m_nestedSEIs.size(), "num_seis_in_bsp_minus1" );
1076#endif
[644]1077  // write nested SEI messages
1078  for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++)
1079  {
1080    writeSEImessage(bs, *(*it), vps, sps, &nestingSei, &sei);
1081  }
1082}
1083
1084Void SEIWriter::xWriteSEIBspInitialArrivalTime(const SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei)
1085{
1086  assert(vps->getVpsVuiPresentFlag());
1087
[906]1088#if VPS_VUI_BSP_HRD_PARAMS
1089  Int psIdx = bspNestingSei.m_seiPartitioningSchemeIdx;
1090  Int seiOlsIdx = bspNestingSei.m_seiOlsIdx;
1091  Int maxTemporalId = nestingSei.m_nestingMaxTemporalIdPlus1[0] - 1;
1092  Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1;
1093  std::vector<Int> hrdIdx(maxValues, 0);
1094  std::vector<TComHRD *> hrdVec;
1095  std::vector<Int> syntaxElemLen(maxValues, 0);
1096  for(Int i = 0; i < maxValues; i++)
1097  {
1098    hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei.m_bspIdx);
1099    hrdVec.push_back(vps->getBspHrd(hrdIdx[i]));
1100   
1101    syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1;
1102    if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) )
1103    {
1104      assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23
1105    }
1106    if( i > 0 )
1107    {
1108      assert( hrdVec[i]->getNalHrdParametersPresentFlag() == hrdVec[i-1]->getNalHrdParametersPresentFlag() );
1109      assert( hrdVec[i]->getVclHrdParametersPresentFlag() == hrdVec[i-1]->getVclHrdParametersPresentFlag() );
1110    }
1111  }
1112  if (hrdVec[0]->getNalHrdParametersPresentFlag())
1113  {
1114    for(UInt i = 0; i < maxValues; i++)
1115    {
1116      WRITE_CODE( sei.m_nalInitialArrivalDelay[i], syntaxElemLen[i], "nal_initial_arrival_delay[i]" );
1117    }
1118  }
1119  if( hrdVec[0]->getVclHrdParametersPresentFlag() )
1120  {
1121    for(UInt i = 0; i < maxValues; i++)
1122    {
1123      WRITE_CODE( sei.m_vclInitialArrivalDelay[i], syntaxElemLen[i], "vcl_initial_arrival_delay[i]" );
1124    }
1125  }
1126#else
[644]1127  UInt schedCombCnt = vps->getNumBspSchedCombinations(nestingSei.m_nestingOpIdx[0]);
1128  UInt len;
1129  UInt hrdIdx;
1130
1131  if (schedCombCnt > 0)
1132  {
1133    hrdIdx = vps->getBspCombHrdIdx(nestingSei.m_nestingOpIdx[0], 0, bspNestingSei.m_bspIdx);
1134  }
1135  else
1136  {
1137    hrdIdx = 0;
1138  }
1139
1140  TComHRD *hrd = vps->getBspHrd(hrdIdx);
1141
1142  if (hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag())
1143  {
1144    len = hrd->getInitialCpbRemovalDelayLengthMinus1() + 1;
1145  }
1146  else
1147  {
1148    len = 23 + 1;
1149  }
1150
1151  if (hrd->getNalHrdParametersPresentFlag())
1152  {
1153    for(UInt i = 0; i < schedCombCnt; i++)
1154    {
1155      WRITE_CODE( sei.m_nalInitialArrivalDelay[i], len, "nal_initial_arrival_delay" );
1156    }
1157  }
[906]1158#if BSP_INIT_ARRIVAL_SEI
1159  if( hrd->getVclHrdParametersPresentFlag() )
1160#else
[644]1161  else
[906]1162#endif
[644]1163  {
1164    for(UInt i = 0; i < schedCombCnt; i++)
1165    {
1166      WRITE_CODE( sei.m_vclInitialArrivalDelay[i], len, "vcl_initial_arrival_delay" );
1167    }
1168  }
[906]1169#endif
[644]1170}
1171
[906]1172#if !REMOVE_BSP_HRD_SEI
[644]1173Void SEIWriter::xWriteSEIBspHrd(const SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei)
1174{
1175  WRITE_UVLC( sei.m_seiNumBspHrdParametersMinus1, "sei_num_bsp_hrd_parameters_minus1" );
1176  for (UInt i = 0; i <= sei.m_seiNumBspHrdParametersMinus1; i++)
1177  {
1178    if (i > 0)
1179    {
1180      WRITE_FLAG( sei.m_seiBspCprmsPresentFlag[i], "sei_bsp_cprms_present_flag" );
1181    }
1182    xCodeHrdParameters(sei.hrd, i==0 ? 1 : sei.m_seiBspCprmsPresentFlag[i], nestingSei.m_nestingMaxTemporalIdPlus1[0]-1);
1183  }
1184  for (UInt h = 0; h <= nestingSei.m_nestingNumOpsMinus1; h++)
1185  {
1186    UInt lsIdx = nestingSei.m_nestingOpIdx[h];
1187    WRITE_UVLC( sei.m_seiNumBitstreamPartitionsMinus1[lsIdx], "num_sei_bitstream_partitions_minus1[i]");
1188    for (UInt i = 0; i <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; i++)
1189    {
[815]1190#if HRD_BPB
1191      UInt nl=0;
[644]1192      for (UInt j = 0; j < sei.m_vpsMaxLayers; j++)
1193      {
1194        if (sei.m_layerIdIncludedFlag[lsIdx][j])
1195        {
[815]1196          nl++;
1197        }
1198      }
1199      for (UInt j = 0; j < nl; j++)
1200      {
1201#else
1202      for (UInt j = 0; j < sei.m_vpsMaxLayers; j++)
1203      {
1204        if (sei.m_layerIdIncludedFlag[lsIdx][j])
1205        {
1206#endif
[644]1207          WRITE_FLAG( sei.m_seiLayerInBspFlag[lsIdx][i][j], "sei_layer_in_bsp_flag[lsIdx][i][j]" );
1208        }
[815]1209#if !HRD_BPB
[644]1210      }
[815]1211#endif
[644]1212    }
1213    WRITE_UVLC( sei.m_seiNumBspSchedCombinationsMinus1[lsIdx], "sei_num_bsp_sched_combinations_minus1[i]");
1214    for (UInt i = 0; i <= sei.m_seiNumBspSchedCombinationsMinus1[lsIdx]; i++)
1215    {
1216      for (UInt j = 0; j <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; j++)
1217      {
1218        WRITE_UVLC( sei.m_seiBspCombHrdIdx[lsIdx][i][j], "sei_bsp_comb_hrd_idx[lsIdx][i][j]");
1219        WRITE_UVLC( sei.m_seiBspCombScheddx[lsIdx][i][j], "sei_bsp_comb_sched_idx[lsIdx][i][j]");
1220      }
1221    }
1222  }
1223}
[906]1224#endif
[644]1225
1226Void SEIWriter::xCodeHrdParameters( TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 )
1227{
1228  if( commonInfPresentFlag )
1229  {
1230    WRITE_FLAG( hrd->getNalHrdParametersPresentFlag() ? 1 : 0 ,  "nal_hrd_parameters_present_flag" );
1231    WRITE_FLAG( hrd->getVclHrdParametersPresentFlag() ? 1 : 0 ,  "vcl_hrd_parameters_present_flag" );
1232    if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() )
1233    {
1234      WRITE_FLAG( hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0,  "sub_pic_cpb_params_present_flag" );
1235      if( hrd->getSubPicCpbParamsPresentFlag() )
1236      {
1237        WRITE_CODE( hrd->getTickDivisorMinus2(), 8,              "tick_divisor_minus2" );
1238        WRITE_CODE( hrd->getDuCpbRemovalDelayLengthMinus1(), 5,  "du_cpb_removal_delay_length_minus1" );
1239        WRITE_FLAG( hrd->getSubPicCpbParamsInPicTimingSEIFlag() ? 1 : 0, "sub_pic_cpb_params_in_pic_timing_sei_flag" );
1240        WRITE_CODE( hrd->getDpbOutputDelayDuLengthMinus1(), 5,   "dpb_output_delay_du_length_minus1"  );
1241      }
1242      WRITE_CODE( hrd->getBitRateScale(), 4,                     "bit_rate_scale" );
1243      WRITE_CODE( hrd->getCpbSizeScale(), 4,                     "cpb_size_scale" );
1244      if( hrd->getSubPicCpbParamsPresentFlag() )
1245      {
1246        WRITE_CODE( hrd->getDuCpbSizeScale(), 4,                "du_cpb_size_scale" ); 
1247      }
1248      WRITE_CODE( hrd->getInitialCpbRemovalDelayLengthMinus1(), 5, "initial_cpb_removal_delay_length_minus1" );
1249      WRITE_CODE( hrd->getCpbRemovalDelayLengthMinus1(),        5, "au_cpb_removal_delay_length_minus1" );
1250      WRITE_CODE( hrd->getDpbOutputDelayLengthMinus1(),         5, "dpb_output_delay_length_minus1" );
1251    }
1252  }
1253  Int i, j, nalOrVcl;
1254  for( i = 0; i <= maxNumSubLayersMinus1; i ++ )
1255  {
1256    WRITE_FLAG( hrd->getFixedPicRateFlag( i ) ? 1 : 0,          "fixed_pic_rate_general_flag");
1257    if( !hrd->getFixedPicRateFlag( i ) )
1258    {
1259      WRITE_FLAG( hrd->getFixedPicRateWithinCvsFlag( i ) ? 1 : 0, "fixed_pic_rate_within_cvs_flag");
1260    }
1261    else
1262    {
1263      hrd->setFixedPicRateWithinCvsFlag( i, true );
1264    }
1265    if( hrd->getFixedPicRateWithinCvsFlag( i ) )
1266    {
1267      WRITE_UVLC( hrd->getPicDurationInTcMinus1( i ),           "elemental_duration_in_tc_minus1");
1268    }
1269    else
1270    {
1271      WRITE_FLAG( hrd->getLowDelayHrdFlag( i ) ? 1 : 0,           "low_delay_hrd_flag");
1272    }
1273    if (!hrd->getLowDelayHrdFlag( i ))
1274    {
1275      WRITE_UVLC( hrd->getCpbCntMinus1( i ),                      "cpb_cnt_minus1");
1276    }
1277   
1278    for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
1279    {
1280      if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) ||
1281          ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )
1282      {
1283        for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ )
1284        {
1285          WRITE_UVLC( hrd->getBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_value_minus1");
1286          WRITE_UVLC( hrd->getCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_value_minus1");
1287          if( hrd->getSubPicCpbParamsPresentFlag() )
1288          {
1289            WRITE_UVLC( hrd->getDuCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_du_value_minus1"); 
1290            WRITE_UVLC( hrd->getDuBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_du_value_minus1");
1291          }
1292          WRITE_FLAG( hrd->getCbrFlag( i, j, nalOrVcl ) ? 1 : 0, "cbr_flag");
1293        }
1294      }
1295    }
1296  }
1297}
1298
1299#endif
1300
[815]1301#if Q0078_ADD_LAYER_SETS
1302
1303Void SEIWriter::xWriteSEIOutputLayerSetNesting(TComBitIf& bs, const SEIOutputLayerSetNesting &sei, TComVPS *vps, TComSPS *sps)
1304{
1305  WRITE_FLAG(sei.m_olsFlag, "ols_flag");
1306  WRITE_UVLC(sei.m_numOlsIndicesMinus1, "num_ols_indices_minus1");
1307
1308  for (Int i = 0; i <= sei.m_numOlsIndicesMinus1; i++)
1309  {
1310    WRITE_UVLC(sei.m_olsIdx[i], "ols_idx[i]");
1311  }
1312
1313  while (m_pcBitIf->getNumberOfWrittenBits() % 8 != 0)
1314  {
1315    WRITE_FLAG(0, "ols_nesting_zero_bit");
1316  }
1317
1318  // write nested SEI messages
1319  for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++)
1320  {
1321    writeSEImessage(bs, *(*it), vps, sps);
1322  }
1323}
1324
1325Void SEIWriter::xWriteSEIVPSRewriting(const SEIVPSRewriting &sei)
1326{
1327  //sei.nalu->
1328}
1329
1330#endif
1331
[595]1332#endif //SVC_EXTENSION
[313]1333
1334//! \}
Note: See TracBrowser for help on using the repository browser.