source: 3DVCSoftware/branches/HTM-16.1-dev/source/Lib/TLibEncoder/SEIwrite.cpp

Last change on this file was 1402, checked in by tech, 8 years ago

Initial merge of HM-16.9.

  • Property svn:eol-style set to native
File size: 59.0 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-2016, 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#include "TLibCommon/TComBitCounter.h"
35#include "TLibCommon/TComBitStream.h"
36#include "TLibCommon/SEI.h"
37#include "TLibCommon/TComSlice.h"
38#include "TLibCommon/TComPicYuv.h"
39#include "SEIwrite.h"
40
41//! \ingroup TLibEncoder
42//! \{
43
44#if ENC_DEC_TRACE
45Void  xTraceSEIHeader()
46{
47  fprintf( g_hTrace, "=========== SEI message ===========\n");
48}
49
50Void  xTraceSEIMessageType(SEI::PayloadType payloadType)
51{
52  fprintf( g_hTrace, "=========== %s SEI message ===========\n", SEI::getSEIMessageString(payloadType));
53}
54#endif
55
56Void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, const TComSPS *sps)
57{
58  switch (sei.payloadType())
59  {
60  case SEI::USER_DATA_UNREGISTERED:
61    xWriteSEIuserDataUnregistered(*static_cast<const SEIuserDataUnregistered*>(&sei));
62    break;
63  case SEI::ACTIVE_PARAMETER_SETS:
64    xWriteSEIActiveParameterSets(*static_cast<const SEIActiveParameterSets*>(& sei));
65    break;
66  case SEI::DECODING_UNIT_INFO:
67    xWriteSEIDecodingUnitInfo(*static_cast<const SEIDecodingUnitInfo*>(& sei), sps);
68    break;
69  case SEI::DECODED_PICTURE_HASH:
70    xWriteSEIDecodedPictureHash(*static_cast<const SEIDecodedPictureHash*>(&sei));
71    break;
72  case SEI::BUFFERING_PERIOD:
73    xWriteSEIBufferingPeriod(*static_cast<const SEIBufferingPeriod*>(&sei), sps);
74    break;
75  case SEI::PICTURE_TIMING:
76    xWriteSEIPictureTiming(*static_cast<const SEIPictureTiming*>(&sei), sps);
77    break;
78  case SEI::RECOVERY_POINT:
79    xWriteSEIRecoveryPoint(*static_cast<const SEIRecoveryPoint*>(&sei));
80    break;
81  case SEI::FRAME_PACKING:
82    xWriteSEIFramePacking(*static_cast<const SEIFramePacking*>(&sei));
83    break;
84  case SEI::SEGM_RECT_FRAME_PACKING:
85    xWriteSEISegmentedRectFramePacking(*static_cast<const SEISegmentedRectFramePacking*>(&sei));
86    break;
87  case SEI::DISPLAY_ORIENTATION:
88    xWriteSEIDisplayOrientation(*static_cast<const SEIDisplayOrientation*>(&sei));
89    break;
90  case SEI::TEMPORAL_LEVEL0_INDEX:
91    xWriteSEITemporalLevel0Index(*static_cast<const SEITemporalLevel0Index*>(&sei));
92    break;
93  case SEI::REGION_REFRESH_INFO:
94    xWriteSEIGradualDecodingRefreshInfo(*static_cast<const SEIGradualDecodingRefreshInfo*>(&sei));
95    break;
96  case SEI::NO_DISPLAY:
97    xWriteSEINoDisplay(*static_cast<const SEINoDisplay*>(&sei));
98    break;
99  case SEI::TONE_MAPPING_INFO:
100    xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei));
101    break;
102  case SEI::SOP_DESCRIPTION:
103    xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei));
104    break;
105  case SEI::SCALABLE_NESTING:
106    xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps);
107    break;
108  case SEI::CHROMA_RESAMPLING_FILTER_HINT:
109    xWriteSEIChromaResamplingFilterHint(*static_cast<const SEIChromaResamplingFilterHint*>(&sei));
110    break;
111  case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS:
112    xWriteSEITempMotionConstrainedTileSets(*static_cast<const SEITempMotionConstrainedTileSets*>(&sei));
113    break;
114  case SEI::TIME_CODE:
115    xWriteSEITimeCode(*static_cast<const SEITimeCode*>(&sei));
116    break;
117  case SEI::KNEE_FUNCTION_INFO:
118    xWriteSEIKneeFunctionInfo(*static_cast<const SEIKneeFunctionInfo*>(&sei));
119    break;
120  case SEI::COLOUR_REMAPPING_INFO:
121    xWriteSEIColourRemappingInfo(*static_cast<const SEIColourRemappingInfo*>(&sei));
122    break;
123  case SEI::MASTERING_DISPLAY_COLOUR_VOLUME:
124    xWriteSEIMasteringDisplayColourVolume(*static_cast<const SEIMasteringDisplayColourVolume*>(&sei));
125    break;
126#if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI
127  case SEI::ALTERNATIVE_TRANSFER_CHARACTERISTICS:
128    xWriteSEIAlternativeTransferCharacteristics(*static_cast<const SEIAlternativeTransferCharacteristics*>(&sei));
129    break;
130#endif
131
132#if NH_MV
133   case SEI::LAYERS_NOT_PRESENT:
134       xWriteSEILayersNotPresent(*static_cast<const SEILayersNotPresent*>(&sei));
135     break;
136   case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS:
137     xWriteSEIInterLayerConstrainedTileSets(*static_cast<const SEIInterLayerConstrainedTileSets*>(&sei));
138     break;
139#if NH_MV_SEI_TBD
140   case SEI::BSP_NESTING:
141     xWriteSEIBspNesting(*static_cast<const SEIBspNesting*>(&sei));
142     break;
143   case SEI::BSP_INITIAL_ARRIVAL_TIME:
144     xWriteSEIBspInitialArrivalTime(*static_cast<const SEIBspInitialArrivalTime*>(&sei));
145     break;
146#endif
147   case SEI::SUB_BITSTREAM_PROPERTY:
148     xWriteSEISubBitstreamProperty(*static_cast<const SEISubBitstreamProperty*>(&sei));
149     break;
150   case SEI::ALPHA_CHANNEL_INFO:
151     xWriteSEIAlphaChannelInfo(*static_cast<const SEIAlphaChannelInfo*>(&sei));
152     break;
153   case SEI::OVERLAY_INFO:
154     xWriteSEIOverlayInfo(*static_cast<const SEIOverlayInfo*>(&sei));
155     break;
156   case SEI::TEMPORAL_MV_PREDICTION_CONSTRAINTS:
157     xWriteSEITemporalMvPredictionConstraints(*static_cast<const SEITemporalMvPredictionConstraints*>(&sei));
158     break;
159#if NH_MV_SEI_TBD
160   case SEI::FRAME_FIELD_INFO:
161     xWriteSEIFrameFieldInfo(*static_cast<const SEIFrameFieldInfo*>(&sei));
162     break;
163#endif
164   case SEI::THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO:
165     xWriteSEIThreeDimensionalReferenceDisplaysInfo(*static_cast<const SEIThreeDimensionalReferenceDisplaysInfo*>(&sei));
166     break;
167   case SEI::DEPTH_REPRESENTATION_INFO:
168       xWriteSEIDepthRepresentationInfo(*static_cast<const SEIDepthRepresentationInfo*>(&sei));
169       break;
170   case SEI::MULTIVIEW_SCENE_INFO:
171     xWriteSEIMultiviewSceneInfo(*static_cast<const SEIMultiviewSceneInfo*>(&sei));
172     break;
173   case SEI::MULTIVIEW_ACQUISITION_INFO:
174     xWriteSEIMultiviewAcquisitionInfo(*static_cast<const SEIMultiviewAcquisitionInfo*>(&sei));
175     break;
176
177   case SEI::MULTIVIEW_VIEW_POSITION:
178     xWriteSEIMultiviewViewPosition(*static_cast<const SEIMultiviewViewPosition*>(&sei));
179     break;
180#if NH_3D
181   case SEI::ALTERNATIVE_DEPTH_INFO:
182     xWriteSEIAlternativeDepthInfo(*static_cast<const SEIAlternativeDepthInfo*>(&sei));
183     break;
184#endif
185#endif
186
187
188  default:
189    assert(!"Trying to write unhandled SEI message");
190    break;
191  }
192  xWriteByteAlign();
193}
194
195/**
196 * marshal all SEI messages in provided list into one bitstream bs
197 */
198Void SEIWriter::writeSEImessages(TComBitIf& bs, const SEIMessages &seiList, const TComSPS *sps, Bool isNested)
199{
200#if ENC_DEC_TRACE
201  if (g_HLSTraceEnable)
202    xTraceSEIHeader();
203#endif
204
205  TComBitCounter bs_count;
206
207  for (SEIMessages::const_iterator sei=seiList.begin(); sei!=seiList.end(); sei++)
208  {
209    // calculate how large the payload data is
210    // TODO: this would be far nicer if it used vectored buffers
211    bs_count.resetBits();
212    setBitstream(&bs_count);
213
214#if ENC_DEC_TRACE
215    Bool traceEnable = g_HLSTraceEnable;
216    g_HLSTraceEnable = false;
217#endif
218    xWriteSEIpayloadData(bs_count, **sei, sps);
219#if ENC_DEC_TRACE
220    g_HLSTraceEnable = traceEnable;
221#endif
222    UInt payload_data_num_bits = bs_count.getNumberOfWrittenBits();
223    assert(0 == payload_data_num_bits % 8);
224
225    setBitstream(&bs);
226    UInt payloadType = (*sei)->payloadType();
227    for (; payloadType >= 0xff; payloadType -= 0xff)
228    {
229      WRITE_CODE(0xff, 8, "payload_type");
230    }
231    WRITE_CODE(payloadType, 8, "payload_type");
232
233    UInt payloadSize = payload_data_num_bits/8;
234    for (; payloadSize >= 0xff; payloadSize -= 0xff)
235    {
236      WRITE_CODE(0xff, 8, "payload_size");
237    }
238    WRITE_CODE(payloadSize, 8, "payload_size");
239
240    /* payloadData */
241#if ENC_DEC_TRACE
242    if (g_HLSTraceEnable)
243      xTraceSEIMessageType((*sei)->payloadType());
244#endif
245
246    xWriteSEIpayloadData(bs, **sei, sps);
247  }
248  if (!isNested)
249  {
250    xWriteRbspTrailingBits();
251  }
252}
253
254/**
255 * marshal a user_data_unregistered SEI message sei, storing the marshalled
256 * representation in bitstream bs.
257 */
258Void SEIWriter::xWriteSEIuserDataUnregistered(const SEIuserDataUnregistered &sei)
259{
260  for (UInt i = 0; i < ISO_IEC_11578_LEN; i++)
261  {
262    WRITE_CODE(sei.uuid_iso_iec_11578[i], 8 , "sei.uuid_iso_iec_11578[i]");
263  }
264
265  for (UInt i = 0; i < sei.userDataLength; i++)
266  {
267    WRITE_CODE(sei.userData[i], 8 , "user_data");
268  }
269}
270
271/**
272 * marshal a decoded picture hash SEI message, storing the marshalled
273 * representation in bitstream bs.
274 */
275Void SEIWriter::xWriteSEIDecodedPictureHash(const SEIDecodedPictureHash& sei)
276{
277  const TChar *traceString="\0";
278  switch (sei.method)
279  {
280    case HASHTYPE_MD5: traceString="picture_md5"; break;
281    case HASHTYPE_CRC: traceString="picture_crc"; break;
282    case HASHTYPE_CHECKSUM: traceString="picture_checksum"; break;
283    default: assert(false); break;
284  }
285
286  if (traceString != 0) //use of this variable is needed to avoid a compiler error with G++ 4.6.1
287  {
288    WRITE_CODE(sei.method, 8, "hash_type");
289    for(UInt i=0; i<UInt(sei.m_pictureHash.hash.size()); i++)
290    {
291      WRITE_CODE(sei.m_pictureHash.hash[i], 8, traceString);
292    }
293  }
294}
295
296Void SEIWriter::xWriteSEIActiveParameterSets(const SEIActiveParameterSets& sei)
297{
298  WRITE_CODE(sei.activeVPSId,     4,         "active_video_parameter_set_id");
299  WRITE_FLAG(sei.m_selfContainedCvsFlag,     "self_contained_cvs_flag");
300  WRITE_FLAG(sei.m_noParameterSetUpdateFlag, "no_parameter_set_update_flag");
301  WRITE_UVLC(sei.numSpsIdsMinus1,            "num_sps_ids_minus1");
302
303  assert (sei.activeSeqParameterSetId.size() == (sei.numSpsIdsMinus1 + 1));
304
305  for (Int i = 0; i < sei.activeSeqParameterSetId.size(); i++)
306  {
307    WRITE_UVLC(sei.activeSeqParameterSetId[i], "active_seq_parameter_set_id");
308  }
309}
310
311Void SEIWriter::xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, const TComSPS *sps)
312{
313  const TComVUI *vui = sps->getVuiParameters();
314  WRITE_UVLC(sei.m_decodingUnitIdx, "decoding_unit_idx");
315  if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag())
316  {
317    WRITE_CODE( sei.m_duSptCpbRemovalDelay, (vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay_increment");
318  }
319  WRITE_FLAG( sei.m_dpbOutputDuDelayPresentFlag, "dpb_output_du_delay_present_flag");
320  if(sei.m_dpbOutputDuDelayPresentFlag)
321  {
322    WRITE_CODE(sei.m_picSptDpbOutputDuDelay, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, "pic_spt_dpb_output_du_delay");
323  }
324}
325
326Void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, const TComSPS *sps)
327{
328  Int i, nalOrVcl;
329  const TComVUI *vui = sps->getVuiParameters();
330  const TComHRD *hrd = vui->getHrdParameters();
331
332  WRITE_UVLC( sei.m_bpSeqParameterSetId, "bp_seq_parameter_set_id" );
333  if( !hrd->getSubPicCpbParamsPresentFlag() )
334  {
335    WRITE_FLAG( sei.m_rapCpbParamsPresentFlag, "irap_cpb_params_present_flag" );
336  }
337  if( sei.m_rapCpbParamsPresentFlag )
338  {
339    WRITE_CODE( sei.m_cpbDelayOffset, hrd->getCpbRemovalDelayLengthMinus1() + 1, "cpb_delay_offset" );
340    WRITE_CODE( sei.m_dpbDelayOffset, hrd->getDpbOutputDelayLengthMinus1()  + 1, "dpb_delay_offset" );
341  }
342  WRITE_FLAG( sei.m_concatenationFlag, "concatenation_flag");
343  WRITE_CODE( sei.m_auCpbRemovalDelayDelta - 1, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), "au_cpb_removal_delay_delta_minus1" );
344  for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
345  {
346    if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) ||
347        ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )
348    {
349      for( i = 0; i < ( hrd->getCpbCntMinus1( 0 ) + 1 ); i ++ )
350      {
351        WRITE_CODE( sei.m_initialCpbRemovalDelay[i][nalOrVcl],( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ) ,           "initial_cpb_removal_delay" );
352        WRITE_CODE( sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl],( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ),      "initial_cpb_removal_delay_offset" );
353        if( hrd->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag )
354        {
355          WRITE_CODE( sei.m_initialAltCpbRemovalDelay[i][nalOrVcl], ( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ) ,     "initial_alt_cpb_removal_delay" );
356          WRITE_CODE( sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl], ( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ),"initial_alt_cpb_removal_delay_offset" );
357        }
358      }
359    }
360  }
361}
362Void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei, const TComSPS *sps)
363{
364  Int i;
365  const TComVUI *vui = sps->getVuiParameters();
366  const TComHRD *hrd = vui->getHrdParameters();
367
368  if( vui->getFrameFieldInfoPresentFlag() )
369  {
370    WRITE_CODE( sei.m_picStruct, 4,              "pic_struct" );
371    WRITE_CODE( sei.m_sourceScanType, 2,         "source_scan_type" );
372    WRITE_FLAG( sei.m_duplicateFlag ? 1 : 0,     "duplicate_flag" );
373  }
374
375  if( hrd->getCpbDpbDelaysPresentFlag() )
376  {
377    WRITE_CODE( sei.m_auCpbRemovalDelay - 1, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ),                                         "au_cpb_removal_delay_minus1" );
378    WRITE_CODE( sei.m_picDpbOutputDelay, ( hrd->getDpbOutputDelayLengthMinus1() + 1 ),                                          "pic_dpb_output_delay" );
379    if(hrd->getSubPicCpbParamsPresentFlag())
380    {
381      WRITE_CODE(sei.m_picDpbOutputDuDelay, hrd->getDpbOutputDelayDuLengthMinus1()+1, "pic_dpb_output_du_delay" );
382    }
383    if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() )
384    {
385      WRITE_UVLC( sei.m_numDecodingUnitsMinus1,     "num_decoding_units_minus1" );
386      WRITE_FLAG( sei.m_duCommonCpbRemovalDelayFlag, "du_common_cpb_removal_delay_flag" );
387      if( sei.m_duCommonCpbRemovalDelayFlag )
388      {
389        WRITE_CODE( sei.m_duCommonCpbRemovalDelayMinus1, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ),                       "du_common_cpb_removal_delay_minus1" );
390      }
391      for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ )
392      {
393        WRITE_UVLC( sei.m_numNalusInDuMinus1[ i ],  "num_nalus_in_du_minus1");
394        if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) )
395        {
396          WRITE_CODE( sei.m_duCpbRemovalDelayMinus1[ i ], ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ),                        "du_cpb_removal_delay_minus1" );
397        }
398      }
399    }
400  }
401}
402Void SEIWriter::xWriteSEIRecoveryPoint(const SEIRecoveryPoint& sei)
403{
404  WRITE_SVLC( sei.m_recoveryPocCnt,    "recovery_poc_cnt"    );
405  WRITE_FLAG( sei.m_exactMatchingFlag, "exact_matching_flag" );
406  WRITE_FLAG( sei.m_brokenLinkFlag,    "broken_link_flag"    );
407}
408Void SEIWriter::xWriteSEIFramePacking(const SEIFramePacking& sei)
409{
410  WRITE_UVLC( sei.m_arrangementId,                  "frame_packing_arrangement_id" );
411  WRITE_FLAG( sei.m_arrangementCancelFlag,          "frame_packing_arrangement_cancel_flag" );
412
413  if( sei.m_arrangementCancelFlag == 0 )
414  {
415    WRITE_CODE( sei.m_arrangementType, 7,           "frame_packing_arrangement_type" );
416
417    WRITE_FLAG( sei.m_quincunxSamplingFlag,         "quincunx_sampling_flag" );
418    WRITE_CODE( sei.m_contentInterpretationType, 6, "content_interpretation_type" );
419    WRITE_FLAG( sei.m_spatialFlippingFlag,          "spatial_flipping_flag" );
420    WRITE_FLAG( sei.m_frame0FlippedFlag,            "frame0_flipped_flag" );
421    WRITE_FLAG( sei.m_fieldViewsFlag,               "field_views_flag" );
422    WRITE_FLAG( sei.m_currentFrameIsFrame0Flag,     "current_frame_is_frame0_flag" );
423
424    WRITE_FLAG( sei.m_frame0SelfContainedFlag,      "frame0_self_contained_flag" );
425    WRITE_FLAG( sei.m_frame1SelfContainedFlag,      "frame1_self_contained_flag" );
426
427    if(sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5)
428    {
429      WRITE_CODE( sei.m_frame0GridPositionX, 4,     "frame0_grid_position_x" );
430      WRITE_CODE( sei.m_frame0GridPositionY, 4,     "frame0_grid_position_y" );
431      WRITE_CODE( sei.m_frame1GridPositionX, 4,     "frame1_grid_position_x" );
432      WRITE_CODE( sei.m_frame1GridPositionY, 4,     "frame1_grid_position_y" );
433    }
434
435    WRITE_CODE( sei.m_arrangementReservedByte, 8,   "frame_packing_arrangement_reserved_byte" );
436    WRITE_FLAG( sei.m_arrangementPersistenceFlag,   "frame_packing_arrangement_persistence_flag" );
437  }
438
439  WRITE_FLAG( sei.m_upsampledAspectRatio,           "upsampled_aspect_ratio" );
440}
441
442Void SEIWriter::xWriteSEISegmentedRectFramePacking(const SEISegmentedRectFramePacking& sei)
443{
444  WRITE_FLAG( sei.m_arrangementCancelFlag,          "segmented_rect_frame_packing_arrangement_cancel_flag" );
445  if( sei.m_arrangementCancelFlag == 0 )
446  {
447    WRITE_CODE( sei.m_contentInterpretationType, 2, "segmented_rect_content_interpretation_type" );
448    WRITE_FLAG( sei.m_arrangementPersistenceFlag,   "segmented_rect_frame_packing_arrangement_persistence" );
449  }
450}
451
452Void SEIWriter::xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei)
453{
454  Int i;
455  WRITE_UVLC( sei.m_toneMapId,                    "tone_map_id" );
456  WRITE_FLAG( sei.m_toneMapCancelFlag,            "tone_map_cancel_flag" );
457  if( !sei.m_toneMapCancelFlag )
458  {
459    WRITE_FLAG( sei.m_toneMapPersistenceFlag,     "tone_map_persistence_flag" );
460    WRITE_CODE( sei.m_codedDataBitDepth,    8,    "coded_data_bit_depth" );
461    WRITE_CODE( sei.m_targetBitDepth,       8,    "target_bit_depth" );
462    WRITE_UVLC( sei.m_modelId,                    "model_id" );
463    switch(sei.m_modelId)
464    {
465    case 0:
466      {
467        WRITE_CODE( sei.m_minValue,  32,        "min_value" );
468        WRITE_CODE( sei.m_maxValue, 32,         "max_value" );
469        break;
470      }
471    case 1:
472      {
473        WRITE_CODE( sei.m_sigmoidMidpoint, 32,  "sigmoid_midpoint" );
474        WRITE_CODE( sei.m_sigmoidWidth,    32,  "sigmoid_width"    );
475        break;
476      }
477    case 2:
478      {
479        UInt num = 1u << sei.m_targetBitDepth;
480        for(i = 0; i < num; i++)
481        {
482          WRITE_CODE( sei.m_startOfCodedInterval[i], (( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3,  "start_of_coded_interval" );
483        }
484        break;
485      }
486    case 3:
487      {
488        WRITE_CODE( sei.m_numPivots, 16,          "num_pivots" );
489        for(i = 0; i < sei.m_numPivots; i++ )
490        {
491          WRITE_CODE( sei.m_codedPivotValue[i], (( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3,       "coded_pivot_value" );
492          WRITE_CODE( sei.m_targetPivotValue[i], (( sei.m_targetBitDepth + 7 ) >> 3 ) << 3,         "target_pivot_value");
493        }
494        break;
495      }
496    case 4:
497      {
498        WRITE_CODE( sei.m_cameraIsoSpeedIdc,    8,    "camera_iso_speed_idc" );
499        if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO
500        {
501          WRITE_CODE( sei.m_cameraIsoSpeedValue,    32,    "camera_iso_speed_value" );
502        }
503        WRITE_CODE( sei.m_exposureIndexIdc,     8,    "exposure_index_idc" );
504        if( sei.m_exposureIndexIdc == 255) //Extended_ISO
505        {
506          WRITE_CODE( sei.m_exposureIndexValue,     32,    "exposure_index_value" );
507        }
508        WRITE_FLAG( sei.m_exposureCompensationValueSignFlag,           "exposure_compensation_value_sign_flag" );
509        WRITE_CODE( sei.m_exposureCompensationValueNumerator,     16,  "exposure_compensation_value_numerator" );
510        WRITE_CODE( sei.m_exposureCompensationValueDenomIdc,      16,  "exposure_compensation_value_denom_idc" );
511        WRITE_CODE( sei.m_refScreenLuminanceWhite,                32,  "ref_screen_luminance_white" );
512        WRITE_CODE( sei.m_extendedRangeWhiteLevel,                32,  "extended_range_white_level" );
513        WRITE_CODE( sei.m_nominalBlackLevelLumaCodeValue,         16,  "nominal_black_level_luma_code_value" );
514        WRITE_CODE( sei.m_nominalWhiteLevelLumaCodeValue,         16,  "nominal_white_level_luma_code_value" );
515        WRITE_CODE( sei.m_extendedWhiteLevelLumaCodeValue,        16,  "extended_white_level_luma_code_value" );
516        break;
517      }
518    default:
519      {
520        assert(!"Undefined SEIToneMapModelId");
521        break;
522      }
523    }//switch m_modelId
524  }//if(!sei.m_toneMapCancelFlag)
525}
526
527Void SEIWriter::xWriteSEIDisplayOrientation(const SEIDisplayOrientation &sei)
528{
529  WRITE_FLAG( sei.cancelFlag,           "display_orientation_cancel_flag" );
530  if( !sei.cancelFlag )
531  {
532    WRITE_FLAG( sei.horFlip,                   "hor_flip" );
533    WRITE_FLAG( sei.verFlip,                   "ver_flip" );
534    WRITE_CODE( sei.anticlockwiseRotation, 16, "anticlockwise_rotation" );
535    WRITE_FLAG( sei.persistenceFlag,          "display_orientation_persistence_flag" );
536  }
537}
538
539Void SEIWriter::xWriteSEITemporalLevel0Index(const SEITemporalLevel0Index &sei)
540{
541  WRITE_CODE( sei.tl0Idx, 8 , "tl0_idx" );
542  WRITE_CODE( sei.rapIdx, 8 , "rap_idx" );
543}
544
545Void SEIWriter::xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei)
546{
547  WRITE_FLAG( sei.m_gdrForegroundFlag, "gdr_foreground_flag");
548}
549
550Void SEIWriter::xWriteSEINoDisplay(const SEINoDisplay& /*sei*/)
551{
552}
553
554Void SEIWriter::xWriteSEISOPDescription(const SEISOPDescription& sei)
555{
556  WRITE_UVLC( sei.m_sopSeqParameterSetId,           "sop_seq_parameter_set_id"               );
557  WRITE_UVLC( sei.m_numPicsInSopMinus1,             "num_pics_in_sop_minus1"               );
558  for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++)
559  {
560    WRITE_CODE( sei.m_sopDescVclNaluType[i], 6, "sop_desc_vcl_nalu_type" );
561    WRITE_CODE( sei.m_sopDescTemporalId[i],  3, "sop_desc_temporal_id" );
562    if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP)
563    {
564      WRITE_UVLC( sei.m_sopDescStRpsIdx[i],           "sop_desc_st_rps_idx"               );
565    }
566    if (i > 0)
567    {
568      WRITE_SVLC( sei.m_sopDescPocDelta[i],           "sop_desc_poc_delta"               );
569    }
570  }
571}
572
573Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, const TComSPS *sps)
574{
575  WRITE_FLAG( sei.m_bitStreamSubsetFlag,             "bitstream_subset_flag"         );
576  WRITE_FLAG( sei.m_nestingOpFlag,                   "nesting_op_flag      "         );
577  if (sei.m_nestingOpFlag)
578  {
579    WRITE_FLAG( sei.m_defaultOpFlag,                 "default_op_flag"               );
580    WRITE_UVLC( sei.m_nestingNumOpsMinus1,           "nesting_num_ops_minus1"        );
581    for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++)
582    {
583      WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3,  "nesting_max_temporal_id_plus1" );
584      WRITE_UVLC( sei.m_nestingOpIdx[i],                  "nesting_op_idx"                );
585    }
586  }
587  else
588  {
589    WRITE_FLAG( sei.m_allLayersFlag,                      "all_layers_flag"               );
590    if (!sei.m_allLayersFlag)
591    {
592      WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id_plus1" );
593      WRITE_UVLC( sei.m_nestingNumLayersMinus1,           "nesting_num_layers"                  );
594      for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++)
595      {
596        WRITE_CODE( sei.m_nestingLayerId[i], 6,           "nesting_layer_id"              );
597      }
598    }
599  }
600
601  // byte alignment
602  while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
603  {
604    WRITE_FLAG( 0, "nesting_zero_bit" );
605  }
606
607  // write nested SEI messages
608  writeSEImessages(bs, sei.m_nestedSEIs, sps, true);
609}
610
611Void SEIWriter::xWriteSEITempMotionConstrainedTileSets(const SEITempMotionConstrainedTileSets& sei)
612{
613  //UInt code;
614  WRITE_FLAG((sei.m_mc_all_tiles_exact_sample_value_match_flag ? 1 : 0), "mc_all_tiles_exact_sample_value_match_flag");
615  WRITE_FLAG((sei.m_each_tile_one_tile_set_flag                ? 1 : 0), "each_tile_one_tile_set_flag"               );
616
617  if(!sei.m_each_tile_one_tile_set_flag)
618  {
619    WRITE_FLAG((sei.m_limited_tile_set_display_flag ? 1 : 0), "limited_tile_set_display_flag");
620    WRITE_UVLC((sei.getNumberOfTileSets() - 1),               "num_sets_in_message_minus1"   );
621
622    if(sei.getNumberOfTileSets() > 0)
623    {
624      for(Int i = 0; i < sei.getNumberOfTileSets(); i++)
625      {
626        WRITE_UVLC(sei.tileSetData(i).m_mcts_id, "mcts_id");
627
628        if(sei.m_limited_tile_set_display_flag)
629        {
630          WRITE_FLAG((sei.tileSetData(i).m_display_tile_set_flag ? 1 : 0), "display_tile_set_flag");
631        }
632
633        WRITE_UVLC((sei.tileSetData(i).getNumberOfTileRects() - 1), "num_tile_rects_in_set_minus1");
634
635        for(Int j = 0; j < sei.tileSetData(i).getNumberOfTileRects(); j++)
636        {
637          WRITE_UVLC(sei.tileSetData(i).topLeftTileIndex    (j), "top_left_tile_index");
638          WRITE_UVLC(sei.tileSetData(i).bottomRightTileIndex(j), "bottom_right_tile_index");
639        }
640
641        if(!sei.m_mc_all_tiles_exact_sample_value_match_flag)
642        {
643          WRITE_FLAG((sei.tileSetData(i).m_exact_sample_value_match_flag ? 1 : 0), "exact_sample_value_match_flag");
644        }
645
646        WRITE_FLAG((sei.tileSetData(i).m_mcts_tier_level_idc_present_flag ? 1 : 0), "mcts_tier_level_idc_present_flag");
647
648        if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag)
649        {
650          WRITE_FLAG((sei.tileSetData(i).m_mcts_tier_flag ? 1 : 0), "mcts_tier_flag");
651          WRITE_CODE( sei.tileSetData(i).m_mcts_level_idc, 8,       "mcts_level_idc");
652        }
653      }
654    }
655  }
656  else
657  {
658    WRITE_FLAG((sei.m_max_mcs_tier_level_idc_present_flag ? 1 : 0), "max_mcs_tier_level_idc_present_flag");
659
660    if(sei.m_max_mcs_tier_level_idc_present_flag)
661    {
662      WRITE_FLAG((sei.m_max_mcts_tier_flag ? 1 : 0), "max_mcts_tier_flag");
663      WRITE_CODE( sei.m_max_mcts_level_idc, 8,       "max_mcts_level_idc");
664    }
665  }
666}
667
668Void SEIWriter::xWriteSEITimeCode(const SEITimeCode& sei)
669{
670  WRITE_CODE(sei.numClockTs, 2, "num_clock_ts");
671  for(Int i = 0; i < sei.numClockTs; i++)
672  {
673    const TComSEITimeSet &currentTimeSet = sei.timeSetArray[i];
674    WRITE_FLAG(currentTimeSet.clockTimeStampFlag, "clock_time_stamp_flag");
675    if(currentTimeSet.clockTimeStampFlag)
676    {
677      WRITE_FLAG(currentTimeSet.numUnitFieldBasedFlag, "units_field_based_flag");
678      WRITE_CODE(currentTimeSet.countingType, 5, "counting_type");
679      WRITE_FLAG(currentTimeSet.fullTimeStampFlag, "full_timestamp_flag");
680      WRITE_FLAG(currentTimeSet.discontinuityFlag, "discontinuity_flag");
681      WRITE_FLAG(currentTimeSet.cntDroppedFlag, "cnt_dropped_flag");
682      WRITE_CODE(currentTimeSet.numberOfFrames, 9, "n_frames");
683      if(currentTimeSet.fullTimeStampFlag)
684      {
685        WRITE_CODE(currentTimeSet.secondsValue, 6, "seconds_value");
686        WRITE_CODE(currentTimeSet.minutesValue, 6, "minutes_value");
687        WRITE_CODE(currentTimeSet.hoursValue, 5, "hours_value");
688      }
689      else
690      {
691        WRITE_FLAG(currentTimeSet.secondsFlag, "seconds_flag");
692        if(currentTimeSet.secondsFlag)
693        {
694          WRITE_CODE(currentTimeSet.secondsValue, 6, "seconds_value");
695          WRITE_FLAG(currentTimeSet.minutesFlag, "minutes_flag");
696          if(currentTimeSet.minutesFlag)
697          {
698            WRITE_CODE(currentTimeSet.minutesValue, 6, "minutes_value");
699            WRITE_FLAG(currentTimeSet.hoursFlag, "hours_flag");
700            if(currentTimeSet.hoursFlag)
701            {
702              WRITE_CODE(currentTimeSet.hoursValue, 5, "hours_value");
703            }
704          }
705        }
706      }
707      WRITE_CODE(currentTimeSet.timeOffsetLength, 5, "time_offset_length");
708      if(currentTimeSet.timeOffsetLength > 0)
709      {
710        if(currentTimeSet.timeOffsetValue >= 0)
711        {
712          WRITE_CODE((UInt)currentTimeSet.timeOffsetValue, currentTimeSet.timeOffsetLength, "time_offset_value");
713        }
714        else
715        {
716          //  Two's complement conversion
717          UInt offsetValue = ~(currentTimeSet.timeOffsetValue) + 1;
718          offsetValue |= (1 << (currentTimeSet.timeOffsetLength-1));
719          WRITE_CODE(offsetValue, currentTimeSet.timeOffsetLength, "time_offset_value");
720        }
721      }
722    }
723  }
724}
725
726Void SEIWriter::xWriteSEIChromaResamplingFilterHint(const SEIChromaResamplingFilterHint &sei)
727{
728  WRITE_CODE(sei.m_verChromaFilterIdc, 8, "ver_chroma_filter_idc");
729  WRITE_CODE(sei.m_horChromaFilterIdc, 8, "hor_chroma_filter_idc");
730  WRITE_FLAG(sei.m_verFilteringFieldProcessingFlag, "ver_filtering_field_processing_flag");
731  if(sei.m_verChromaFilterIdc == 1 || sei.m_horChromaFilterIdc == 1)
732  {
733    WRITE_UVLC(sei.m_targetFormatIdc, "target_format_idc");
734    if(sei.m_verChromaFilterIdc == 1)
735    {
736      const Int numVerticalFilter = (Int)sei.m_verFilterCoeff.size();
737      WRITE_UVLC(numVerticalFilter, "num_vertical_filters");
738      if(numVerticalFilter > 0)
739      {
740        for(Int i = 0; i < numVerticalFilter; i ++)
741        {
742          const Int verTapLengthMinus1 = (Int) sei.m_verFilterCoeff[i].size() - 1;
743          WRITE_UVLC(verTapLengthMinus1, "ver_tap_length_minus_1");
744          for(Int j = 0; j < (verTapLengthMinus1 + 1); j ++)
745          {
746            WRITE_SVLC(sei.m_verFilterCoeff[i][j], "ver_filter_coeff");
747          }
748        }
749      }
750    }
751    if(sei.m_horChromaFilterIdc == 1)
752    {
753      const Int numHorizontalFilter = (Int) sei.m_horFilterCoeff.size();
754      WRITE_UVLC(numHorizontalFilter, "num_horizontal_filters");
755      if(numHorizontalFilter > 0)
756      {
757        for(Int i = 0; i < numHorizontalFilter; i ++)
758        {
759          const Int horTapLengthMinus1 = (Int) sei.m_horFilterCoeff[i].size() - 1;
760          WRITE_UVLC(horTapLengthMinus1, "hor_tap_length_minus_1");
761          for(Int j = 0; j < (horTapLengthMinus1 + 1); j ++)
762          {
763            WRITE_SVLC(sei.m_horFilterCoeff[i][j], "hor_filter_coeff");
764          }
765        }
766      }
767    }
768  }
769}
770
771Void SEIWriter::xWriteSEIKneeFunctionInfo(const SEIKneeFunctionInfo &sei)
772{
773  WRITE_UVLC( sei.m_kneeId, "knee_function_id" );
774  WRITE_FLAG( sei.m_kneeCancelFlag, "knee_function_cancel_flag" );
775  if ( !sei.m_kneeCancelFlag )
776  {
777    WRITE_FLAG( sei.m_kneePersistenceFlag, "knee_function_persistence_flag" );
778    WRITE_CODE( (UInt)sei.m_kneeInputDrange , 32,  "input_d_range" );
779    WRITE_CODE( (UInt)sei.m_kneeInputDispLuminance, 32,  "input_disp_luminance" );
780    WRITE_CODE( (UInt)sei.m_kneeOutputDrange, 32,  "output_d_range" );
781    WRITE_CODE( (UInt)sei.m_kneeOutputDispLuminance, 32,  "output_disp_luminance" );
782    WRITE_UVLC( sei.m_kneeNumKneePointsMinus1, "num_knee_points_minus1" );
783    for(Int i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ )
784    {
785      WRITE_CODE( (UInt)sei.m_kneeInputKneePoint[i], 10,"input_knee_point" );
786      WRITE_CODE( (UInt)sei.m_kneeOutputKneePoint[i], 10, "output_knee_point" );
787    }
788  }
789}
790
791Void SEIWriter::xWriteSEIColourRemappingInfo(const SEIColourRemappingInfo& sei)
792{
793  WRITE_UVLC( sei.m_colourRemapId,                             "colour_remap_id" );
794  WRITE_FLAG( sei.m_colourRemapCancelFlag,                     "colour_remap_cancel_flag" );
795  if( !sei.m_colourRemapCancelFlag ) 
796  {
797    WRITE_FLAG( sei.m_colourRemapPersistenceFlag,              "colour_remap_persistence_flag" );
798    WRITE_FLAG( sei.m_colourRemapVideoSignalInfoPresentFlag,   "colour_remap_video_signal_info_present_flag" );
799    if ( sei.m_colourRemapVideoSignalInfoPresentFlag )
800    {
801      WRITE_FLAG( sei.m_colourRemapFullRangeFlag,              "colour_remap_full_range_flag" );
802      WRITE_CODE( sei.m_colourRemapPrimaries,               8, "colour_remap_primaries" );
803      WRITE_CODE( sei.m_colourRemapTransferFunction,        8, "colour_remap_transfer_function" );
804      WRITE_CODE( sei.m_colourRemapMatrixCoefficients,      8, "colour_remap_matrix_coefficients" );
805    }
806    WRITE_CODE( sei.m_colourRemapInputBitDepth,             8, "colour_remap_input_bit_depth" );
807    WRITE_CODE( sei.m_colourRemapBitDepth,                  8, "colour_remap_bit_depth" );
808    for( Int c=0 ; c<3 ; c++ )
809    {
810      WRITE_CODE( sei.m_preLutNumValMinus1[c],              8, "pre_lut_num_val_minus1[c]" );
811      if( sei.m_preLutNumValMinus1[c]>0 )
812      {
813        for( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ )
814        {
815          WRITE_CODE( sei.m_preLut[c][i].codedValue,  (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, "pre_lut_coded_value[c][i]" );
816          WRITE_CODE( sei.m_preLut[c][i].targetValue, (( sei.m_colourRemapBitDepth      + 7 ) >> 3 ) << 3, "pre_lut_target_value[c][i]" );
817        }
818      }
819    }
820    WRITE_FLAG( sei.m_colourRemapMatrixPresentFlag,            "colour_remap_matrix_present_flag" );
821    if( sei.m_colourRemapMatrixPresentFlag )
822    {
823      WRITE_CODE( sei.m_log2MatrixDenom,                    4, "log2_matrix_denom" );
824      for( Int c=0 ; c<3 ; c++ )
825      {
826        for( Int i=0 ; i<3 ; i++ )
827        {
828          WRITE_SVLC( sei.m_colourRemapCoeffs[c][i],           "colour_remap_coeffs[c][i]" );
829        }
830      }
831    }
832
833    for( Int c=0 ; c<3 ; c++ )
834    {
835      WRITE_CODE( sei.m_postLutNumValMinus1[c],             8, "m_postLutNumValMinus1[c]" );
836      if( sei.m_postLutNumValMinus1[c]>0 )
837      {
838        for( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ )
839        {
840          WRITE_CODE( sei.m_postLut[c][i].codedValue, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_coded_value[c][i]" );
841          WRITE_CODE( sei.m_postLut[c][i].targetValue, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_target_value[c][i]" );
842        }
843      }
844    }
845  }
846}
847
848Void SEIWriter::xWriteSEIMasteringDisplayColourVolume(const SEIMasteringDisplayColourVolume& sei)
849{
850  WRITE_CODE( sei.values.primaries[0][0],  16,  "display_primaries_x[0]" );
851  WRITE_CODE( sei.values.primaries[0][1],  16,  "display_primaries_y[0]" );
852
853  WRITE_CODE( sei.values.primaries[1][0],  16,  "display_primaries_x[1]" );
854  WRITE_CODE( sei.values.primaries[1][1],  16,  "display_primaries_y[1]" );
855
856  WRITE_CODE( sei.values.primaries[2][0],  16,  "display_primaries_x[2]" );
857  WRITE_CODE( sei.values.primaries[2][1],  16,  "display_primaries_y[2]" );
858
859  WRITE_CODE( sei.values.whitePoint[0],    16,  "white_point_x" );
860  WRITE_CODE( sei.values.whitePoint[1],    16,  "white_point_y" );
861   
862  WRITE_CODE( sei.values.maxLuminance,     32,  "max_display_mastering_luminance" );
863  WRITE_CODE( sei.values.minLuminance,     32,  "min_display_mastering_luminance" );
864}
865
866
867Void SEIWriter::xWriteByteAlign()
868{
869  if( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0)
870  {
871    WRITE_FLAG( 1, "payload_bit_equal_to_one" );
872    while( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
873    {
874      WRITE_FLAG( 0, "payload_bit_equal_to_zero" );
875    }
876  }
877}
878
879#if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI
880Void SEIWriter::xWriteSEIAlternativeTransferCharacteristics(const SEIAlternativeTransferCharacteristics& sei)
881{
882  WRITE_CODE(sei.m_preferredTransferCharacteristics, 8, "preferred_transfer_characteristics");
883}
884#endif
885
886#if NH_MV
887Void SEIWriter::xWriteSEILayersNotPresent(const SEILayersNotPresent& sei)
888{
889  WRITE_CODE( sei.m_lnpSeiActiveVpsId, 4, "lnp_sei_active_vps_id" );
890  for( Int i = 0; i  <  sei.m_lnpSeiMaxLayers; i++ )
891  {
892    WRITE_FLAG( ( sei.m_layerNotPresentFlag[i] ? 1 : 0 ), "layer_not_present_flag" );
893  }
894};
895
896Void SEIWriter::xWriteSEIInterLayerConstrainedTileSets( const SEIInterLayerConstrainedTileSets& sei)
897{
898  WRITE_FLAG( ( sei.m_ilAllTilesExactSampleValueMatchFlag ? 1 : 0 ), "il_all_tiles_exact_sample_value_match_flag" );
899  WRITE_FLAG( ( sei.m_ilOneTilePerTileSetFlag ? 1 : 0 ),             "il_one_tile_per_tile_set_flag" );
900  if( !sei.m_ilOneTilePerTileSetFlag )
901  {
902    WRITE_UVLC( sei.m_ilNumSetsInMessageMinus1, "il_num_sets_in_message_minus1" );
903    if( sei.m_ilNumSetsInMessageMinus1 )
904    {
905      WRITE_FLAG( ( sei.m_skippedTileSetPresentFlag ? 1 : 0 ), "skipped_tile_set_present_flag" );
906    }
907    Int numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - sei.m_skippedTileSetPresentFlag + 1;
908    for( Int i = 0; i < numSignificantSets; i++ )
909    {
910      WRITE_UVLC( sei.m_ilctsId[i],                   "ilcts_id" );
911      WRITE_UVLC( sei.m_ilNumTileRectsInSetMinus1[i], "il_num_tile_rects_in_set_minus1" );
912      for( Int j = 0; j  <= sei.m_ilNumTileRectsInSetMinus1[ i ]; j++ )
913      {
914        WRITE_UVLC( sei.m_ilTopLeftTileIndex[i][j],     "il_top_left_tile_index" );
915        WRITE_UVLC( sei.m_ilBottomRightTileIndex[i][j], "il_bottom_right_tile_index" );
916      }
917      WRITE_CODE( sei.m_ilcIdc[i], 2, "ilc_idc" );
918      if ( !sei.m_ilAllTilesExactSampleValueMatchFlag )
919      {
920        WRITE_FLAG( ( sei.m_ilExactSampleValueMatchFlag[i] ? 1 : 0 ), "il_exact_sample_value_match_flag" );
921      }
922    }
923  }
924  else
925  {
926    WRITE_CODE( sei.m_allTilesIlcIdc, 2, "all_tiles_ilc_idc" );
927  }
928};
929
930#if NH_MV_SEI_TBD
931Void SEIWriter::xWriteSEIBspNesting( const SEIBspNesting& sei)
932{
933  WRITE_UVLC( sei.m_seiOlsIdx, "sei_ols_idx" );
934  WRITE_UVLC( sei.m_seiPartitioningSchemeIdx, "sei_partitioning_scheme_idx" );
935  WRITE_UVLC( sei.m_bspIdx, "bsp_idx" );
936  while( !ByteaLigned(() ) );
937  {
938    WRITE_CODE( sei.m_bspNestingZeroBit, *equalto0*/u1, "bsp_nesting_zero_bit" );
939  }
940  WRITE_UVLC( sei.m_numSeisInBspMinus1, "num_seis_in_bsp_minus1" );
941  for( Int i = 0; i  <=  NumSeisInBspMinus1( ); i++ )
942  {
943    SeiMessage(() );
944  }
945};
946
947Void SEIWriter::xWriteSEIBspInitialArrivalTime( const SEIBspInitialArrivalTime& sei)
948{
949  psIdx = SeiPartitioningSchemeIdx();
950  if( nalInitialArrivalDelayPresent )
951  {
952    for( Int i = 0; i < BspSchedCnt( SeiOlsIdx(), psIdx, MaxTemporalId( 0 ) ); i++ )
953    {
954      WRITE_CODE( sei.m_nalInitialArrivalDelay[i], getNalInitialArrivalDelayLen ), "nal_initial_arrival_delay" );
955    }
956  }
957  if( vclInitialArrivalDelayPresent )
958  {
959    for( Int i = 0; i < BspSchedCnt( SeiOlsIdx(), psIdx, MaxTemporalId( 0 ) ); i++ )
960    {
961      WRITE_CODE( sei.m_vclInitialArrivalDelay[i], getVclInitialArrivalDelayLen ), "vcl_initial_arrival_delay" );
962    }
963  }
964};
965#endif
966Void SEIWriter::xWriteSEISubBitstreamProperty( const SEISubBitstreamProperty& sei)
967{
968  WRITE_CODE( sei.m_sbPropertyActiveVpsId, 4,      "sb_property_active_vps_id"         );
969  WRITE_UVLC( sei.m_numAdditionalSubStreamsMinus1, "num_additional_sub_streams_minus1" );
970  for( Int i = 0; i  <=  sei.m_numAdditionalSubStreamsMinus1; i++ )
971  {
972    WRITE_CODE( sei.m_subBitstreamMode    [i], 2,  "sub_bitstream_mode"       );
973    WRITE_UVLC( sei.m_olsIdxToVps         [i],     "ols_idx_to_vps"           );
974    WRITE_CODE( sei.m_highestSublayerId   [i], 3,  "highest_sublayer_id"      );
975    WRITE_CODE( sei.m_avgSbPropertyBitRate[i], 16, "avg_sb_property_bit_rate" );
976    WRITE_CODE( sei.m_maxSbPropertyBitRate[i], 16, "max_sb_property_bit_rate" );
977  }
978};
979
980Void SEIWriter::xWriteSEIAlphaChannelInfo( const SEIAlphaChannelInfo& sei)
981{
982  WRITE_FLAG( ( sei.m_alphaChannelCancelFlag ? 1 : 0 ), "alpha_channel_cancel_flag" );
983  if( !sei.m_alphaChannelCancelFlag )
984  {
985    WRITE_CODE( sei.m_alphaChannelUseIdc, 3, "alpha_channel_use_idc" );
986    WRITE_CODE( sei.m_alphaChannelBitDepthMinus8, 3, "alpha_channel_bit_depth_minus8" );
987    WRITE_CODE( sei.m_alphaTransparentValue, sei.m_alphaChannelBitDepthMinus8+9, "alpha_transparent_value" );
988    WRITE_CODE( sei.m_alphaOpaqueValue, sei.m_alphaChannelBitDepthMinus8+9, "alpha_opaque_value" );
989    WRITE_FLAG( ( sei.m_alphaChannelIncrFlag ? 1 : 0 ), "alpha_channel_incr_flag" );
990    WRITE_FLAG( ( sei.m_alphaChannelClipFlag ? 1 : 0 ), "alpha_channel_clip_flag" );
991    if( sei.m_alphaChannelClipFlag )
992    {
993      WRITE_FLAG( ( sei.m_alphaChannelClipTypeFlag ? 1 : 0 ), "alpha_channel_clip_type_flag" );
994    }
995  }
996};
997
998Void SEIWriter::xWriteSEIOverlayInfo( const SEIOverlayInfo& sei)
999{
1000  WRITE_FLAG( ( sei.m_overlayInfoCancelFlag ? 1 : 0 ), "overlay_info_cancel_flag" );
1001  if( !sei.m_overlayInfoCancelFlag )
1002  {
1003    WRITE_UVLC( sei.m_overlayContentAuxIdMinus128, "overlay_content_aux_id_minus128" );
1004    WRITE_UVLC( sei.m_overlayLabelAuxIdMinus128, "overlay_label_aux_id_minus128" );
1005    WRITE_UVLC( sei.m_overlayAlphaAuxIdMinus128, "overlay_alpha_aux_id_minus128" );
1006    WRITE_UVLC( sei.m_overlayElementLabelValueLengthMinus8, "overlay_element_label_value_length_minus8" );
1007    WRITE_UVLC( sei.m_numOverlaysMinus1, "num_overlays_minus1" );
1008    for( Int i = 0; i  <=  sei.m_numOverlaysMinus1 ; i++ )
1009    {
1010      WRITE_UVLC( sei.m_overlayIdx[i], "overlay_idx" );
1011      WRITE_FLAG( ( sei.m_languageOverlayPresentFlag[i] ? 1 : 0 ), "language_overlay_present_flag" );
1012      WRITE_CODE( sei.m_overlayContentLayerId[i], 6, "overlay_content_layer_id" );
1013      WRITE_FLAG( ( sei.m_overlayLabelPresentFlag[i] ? 1 : 0 ), "overlay_label_present_flag" );
1014      if( sei.m_overlayLabelPresentFlag[i] )
1015      {
1016        WRITE_CODE( sei.m_overlayLabelLayerId[i], 6, "overlay_label_layer_id" );
1017      }
1018      WRITE_FLAG( ( sei.m_overlayAlphaPresentFlag[i] ? 1 : 0 ), "overlay_alpha_present_flag" );
1019      if( sei.m_overlayAlphaPresentFlag[i] )
1020      {
1021        WRITE_CODE( sei.m_overlayAlphaLayerId[i], 6, "overlay_alpha_layer_id" );
1022      }
1023      if( sei.m_overlayLabelPresentFlag[i] )
1024      {
1025        WRITE_UVLC( sei.m_numOverlayElementsMinus1[i], "num_overlay_elements_minus1" );
1026        for( Int j = 0; j  <=  sei.m_numOverlayElementsMinus1[i]; j++ )
1027        {
1028          WRITE_CODE( sei.m_overlayElementLabelMin[i][j], (sei.m_overlayElementLabelValueLengthMinus8 + 8), "overlay_element_label_min" );
1029          WRITE_CODE( sei.m_overlayElementLabelMax[i][j], (sei.m_overlayElementLabelValueLengthMinus8 + 8), "overlay_element_label_max" );
1030        }
1031      }
1032    }
1033
1034    // byte alignment
1035    while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
1036    {
1037      WRITE_FLAG( 0, "overlay_zero_bit" );
1038    }
1039
1040    UChar* stmp;
1041    UInt ilength;
1042    for( Int i = 0; i  <=  sei.m_numOverlaysMinus1; i++ )
1043    {
1044      if( sei.m_languageOverlayPresentFlag[i] )
1045      {
1046        stmp = (UChar*) strdup( sei.m_overlayLanguage[i].c_str() );
1047        ilength = (UInt) sei.m_overlayLanguage[i].size();
1048        WRITE_STRING( stmp, ilength, "overlay_language" );
1049        free(stmp);
1050      }
1051      stmp = (UChar*) strdup( sei.m_overlayName[i].c_str() );
1052      ilength = (UInt) sei.m_overlayName[i].size();
1053      WRITE_STRING( stmp, ilength, "overlay_name" );
1054      free(stmp);
1055      if( sei.m_overlayLabelPresentFlag[i] )
1056      {
1057        for( Int j = 0; j  <=  sei.m_numOverlayElementsMinus1[i]; j++ )
1058        {
1059          stmp = (UChar*) strdup( sei.m_overlayElementName[i][j].c_str() );
1060          ilength = (UInt) sei.m_overlayElementName[i][j].size();
1061          WRITE_STRING( stmp, ilength, "overlay_element_name" );
1062          free(stmp);
1063        }
1064      }
1065    }
1066    WRITE_FLAG( ( sei.m_overlayInfoPersistenceFlag ? 1 : 0 ), "overlay_info_persistence_flag" );
1067  }
1068};
1069
1070
1071Void SEIWriter::xWriteSEITemporalMvPredictionConstraints( const SEITemporalMvPredictionConstraints& sei)
1072{
1073  WRITE_FLAG( ( sei.m_prevPicsNotUsedFlag    ? 1 : 0 ), "prev_pics_not_used_flag"     );
1074  WRITE_FLAG( ( sei.m_noIntraLayerColPicFlag ? 1 : 0 ), "no_intra_layer_col_pic_flag" );
1075};
1076
1077#if NH_MV_SEI_TBD
1078Void SEIWriter::xWriteSEIFrameFieldInfo( const SEIFrameFieldInfo& sei)
1079{
1080  WRITE_CODE( sei.m_ffinfoPicStruct, 4, "ffinfo_pic_struct" );
1081  WRITE_CODE( sei.m_ffinfoSourceScanType, 2, "ffinfo_source_scan_type" );
1082  WRITE_FLAG( ( sei.m_ffinfoDuplicateFlag ? 1 : 0 ), "ffinfo_duplicate_flag" );
1083};
1084#endif
1085
1086Void SEIWriter::xWriteSEIThreeDimensionalReferenceDisplaysInfo( const SEIThreeDimensionalReferenceDisplaysInfo& sei)
1087{
1088  WRITE_UVLC( sei.m_precRefDisplayWidth, "prec_ref_display_width" );
1089  WRITE_FLAG( ( sei.m_refViewingDistanceFlag ? 1 : 0 ), "ref_viewing_distance_flag" );
1090  if( sei.m_refViewingDistanceFlag )
1091  {
1092    WRITE_UVLC( sei.m_precRefViewingDist, "prec_ref_viewing_dist" );
1093  }
1094  WRITE_UVLC( sei.m_numRefDisplaysMinus1, "num_ref_displays_minus1" );
1095  for( Int i = 0; i  <=  sei.getNumRefDisplaysMinus1( ); i++ )
1096  {
1097    WRITE_UVLC( sei.m_leftViewId[i], "left_view_id" );
1098    WRITE_UVLC( sei.m_rightViewId[i], "right_view_id" );
1099    WRITE_CODE( sei.m_exponentRefDisplayWidth[i], 6, "exponent_ref_display_width" );
1100    WRITE_CODE( sei.m_mantissaRefDisplayWidth[i], sei.getMantissaReferenceDisplayWidthLen(i) , "mantissa_ref_display_width" );
1101    if( sei.m_refViewingDistanceFlag )
1102    {
1103      WRITE_CODE( sei.m_exponentRefViewingDistance[i], 6, "exponent_ref_viewing_distance" );
1104      WRITE_CODE( sei.m_mantissaRefViewingDistance[i], sei.getMantissaReferenceViewingDistanceLen(i), "mantissa_ref_viewing_distance" );
1105    }
1106    WRITE_FLAG( ( sei.m_additionalShiftPresentFlag[i] ? 1 : 0 ), "additional_shift_present_flag" );
1107    if( sei.m_additionalShiftPresentFlag[i] )
1108    {
1109      WRITE_CODE( sei.m_numSampleShiftPlus512[i], 10, "num_sample_shift_plus512" );
1110    }
1111  }
1112  WRITE_FLAG( ( sei.m_threeDimensionalReferenceDisplaysExtensionFlag ? 1 : 0 ), "three_dimensional_reference_displays_extension_flag" );
1113};
1114
1115Void SEIWriter::xWriteSEIDepthRepresentationInfo( const SEIDepthRepresentationInfo& sei)
1116{
1117
1118    assert(sei.m_currLayerID>=0);
1119
1120    WRITE_FLAG( ( sei.m_zNearFlag[sei.m_currLayerID] ? 1 : 0 ), "z_near_flag" );
1121    WRITE_FLAG( ( sei.m_zFarFlag[sei.m_currLayerID] ? 1 : 0 ), "z_far_flag" );
1122    WRITE_FLAG( ( sei.m_dMinFlag[sei.m_currLayerID] ? 1 : 0 ), "d_min_flag" );
1123    WRITE_FLAG( ( sei.m_dMaxFlag[sei.m_currLayerID] ? 1 : 0 ), "d_max_flag" );
1124    WRITE_UVLC( sei.m_depthRepresentationType[sei.m_currLayerID][0], "depth_representation_type" );
1125    if( sei.m_dMinFlag[sei.m_currLayerID]  ||  sei.m_dMaxFlag[sei.m_currLayerID] )
1126    {
1127        WRITE_UVLC( sei.m_disparityRefViewId[sei.m_currLayerID][0], "disparity_ref_view_id" );
1128    }
1129    if( sei.m_zNearFlag[sei.m_currLayerID] )
1130    {
1131        xWriteSEIDepthRepInfoElement(sei.m_zNear[sei.m_currLayerID][0]);
1132    }
1133    if( sei.m_zFarFlag[sei.m_currLayerID] )
1134    {
1135        xWriteSEIDepthRepInfoElement(sei.m_zFar[sei.m_currLayerID][0]);
1136    }
1137    if( sei.m_dMinFlag[sei.m_currLayerID] )
1138    {
1139        xWriteSEIDepthRepInfoElement(sei.m_dMin[sei.m_currLayerID][0]);
1140    }
1141    if( sei.m_dMaxFlag[sei.m_currLayerID] )
1142    {
1143        xWriteSEIDepthRepInfoElement(sei.m_dMax[sei.m_currLayerID][0]);
1144    }
1145
1146    if (sei.m_depthRepresentationType[sei.m_currLayerID][0] == 3)
1147    {
1148        WRITE_UVLC( sei.m_depthNonlinearRepresentationNumMinus1[sei.m_currLayerID][0], "depth_nonlinear_representation_num_minus1" );
1149        for( Int i = 1; i  <=  sei.m_depthNonlinearRepresentationNumMinus1[sei.m_currLayerID][0] + 1; i++ )
1150        {
1151            WRITE_UVLC(sei.m_depth_nonlinear_representation_model[sei.m_currLayerID][i-1],"depth_nonlinear_representation_model[ i ]");
1152        }
1153    }
1154}
1155
1156Void SEIWriter::xWriteSEIDepthRepInfoElement( double f)
1157{
1158    UInt x_sign, x_exp, x_mantissa,x_mantissa_len;
1159    if (f < 0)
1160    {
1161        f = f * (-1);
1162        x_sign = 1;
1163    }
1164    else
1165    {
1166        x_sign = 0;
1167    }
1168    int exponent=0;
1169    if(f >= 1)
1170    {
1171        while(f>=2)
1172        {
1173            exponent++;
1174            f = f/2;
1175        }
1176    }
1177    else
1178    {
1179        while (f<1)
1180        {
1181            exponent++;
1182            f = f*2;
1183        }
1184        exponent=-exponent;
1185    }
1186
1187    int i;
1188    f = f -1;
1189    double s = 1;
1190    char s_mantissa[32];
1191    double thr=1.0/(4.0*(1<<30));
1192
1193    if (f>=thr)
1194    {
1195        for(i=0;i<32;i++)
1196        {
1197            s /= 2;
1198            if(f>=s)
1199            {
1200                f = f-s;
1201                s_mantissa[i]=1;
1202
1203                if (f<thr)
1204                    break;
1205            }
1206            else
1207            {
1208                s_mantissa[i]=0;
1209            }
1210        }
1211
1212        if (i<32)
1213            x_mantissa_len=i+1;
1214        else
1215            x_mantissa_len=32;
1216
1217        x_mantissa=0;
1218
1219        for(i=0;i<x_mantissa_len;i++)
1220        {
1221            if (s_mantissa[i]==1)
1222                x_mantissa += (1u)<<(x_mantissa_len-1-i) ;
1223        }
1224
1225    }
1226    else
1227    {
1228        x_mantissa=0;
1229        x_mantissa_len=1;
1230    }
1231
1232    assert(exponent>=-31 && exponent<= (1<<7)-32);
1233    x_exp=exponent+31;
1234
1235    WRITE_FLAG(  x_sign,                         "da_sign_flag" );
1236    WRITE_CODE(  x_exp, 7 ,                      "da_exponent" );
1237    WRITE_CODE( x_mantissa_len-1, 5 ,            "da_mantissa_len_minus1" );
1238    WRITE_CODE( x_mantissa, x_mantissa_len ,     "da_mantissa" );
1239
1240};
1241
1242Void SEIWriter::xWriteSEIMultiviewSceneInfo( const SEIMultiviewSceneInfo& sei)
1243{
1244  WRITE_SVLC( sei.m_minDisparity     , "min_disparity"       );
1245  WRITE_UVLC( sei.m_maxDisparityRange, "max_disparity_range" );
1246};
1247
1248
1249Void SEIWriter::xWriteSEIMultiviewAcquisitionInfo( const SEIMultiviewAcquisitionInfo& sei)
1250{
1251  WRITE_FLAG( ( sei.m_intrinsicParamFlag ? 1 : 0 ), "intrinsic_param_flag" );
1252  WRITE_FLAG( ( sei.m_extrinsicParamFlag ? 1 : 0 ), "extrinsic_param_flag" );
1253  if( sei.m_intrinsicParamFlag )
1254  {
1255    WRITE_FLAG( ( sei.m_intrinsicParamsEqualFlag ? 1 : 0 ), "intrinsic_params_equal_flag" );
1256    WRITE_UVLC(   sei.m_precFocalLength                   , "prec_focal_length"           );
1257    WRITE_UVLC(   sei.m_precPrincipalPoint                , "prec_principal_point"        );
1258    WRITE_UVLC(   sei.m_precSkewFactor                    , "prec_skew_factor"            );
1259
1260    for( Int i = 0; i  <=  ( sei.m_intrinsicParamsEqualFlag ? 0 : sei.getNumViewsMinus1() ); i++ )
1261    {
1262      WRITE_FLAG( ( sei.m_signFocalLengthX       [i] ? 1 : 0 ),                                         "sign_focal_length_x"        );
1263      WRITE_CODE(   sei.m_exponentFocalLengthX   [i]          , 6                                  ,    "exponent_focal_length_x"    );
1264      WRITE_CODE(   sei.m_mantissaFocalLengthX   [i]          , sei.getMantissaFocalLengthXLen( i ),    "mantissa_focal_length_x"    );
1265      WRITE_FLAG( ( sei.m_signFocalLengthY       [i] ? 1 : 0 ),                                         "sign_focal_length_y"        );
1266      WRITE_CODE(   sei.m_exponentFocalLengthY   [i]          , 6                                  ,    "exponent_focal_length_y"    );
1267      WRITE_CODE(   sei.m_mantissaFocalLengthY   [i]          , sei.getMantissaFocalLengthYLen( i ),    "mantissa_focal_length_y"    );
1268      WRITE_FLAG( ( sei.m_signPrincipalPointX    [i] ? 1 : 0 ),                                         "sign_principal_point_x"     );
1269      WRITE_CODE(   sei.m_exponentPrincipalPointX[i]          , 6,                                      "exponent_principal_point_x" );
1270      WRITE_CODE(   sei.m_mantissaPrincipalPointX[i]          , sei.getMantissaPrincipalPointXLen( i ), "mantissa_principal_point_x" );
1271      WRITE_FLAG( ( sei.m_signPrincipalPointY    [i] ? 1 : 0 ),                                         "sign_principal_point_y"     );
1272      WRITE_CODE(   sei.m_exponentPrincipalPointY[i]          , 6,                                      "exponent_principal_point_y" );
1273      WRITE_CODE(   sei.m_mantissaPrincipalPointY[i]          , sei.getMantissaPrincipalPointYLen( i ), "mantissa_principal_point_y" );
1274      WRITE_FLAG( ( sei.m_signSkewFactor         [i] ? 1 : 0 ),                                         "sign_skew_factor"           );
1275      WRITE_CODE(   sei.m_exponentSkewFactor     [i]          , 6,                                      "exponent_skew_factor"       );
1276      WRITE_CODE(   sei.m_mantissaSkewFactor     [i]          , sei.getMantissaSkewFactorLen( i )  ,    "mantissa_skew_factor"       );
1277    }
1278  }
1279  if( sei.m_extrinsicParamFlag )
1280  {
1281    WRITE_UVLC( sei.m_precRotationParam   , "prec_rotation_param"    );
1282    WRITE_UVLC( sei.m_precTranslationParam, "prec_translation_param" );
1283    for( Int i = 0; i  <=  sei.getNumViewsMinus1(); i++ )
1284    {
1285      for( Int j = 0; j  <=  2; j++ )  /* row */
1286      {
1287        for( Int k = 0; k  <=  2; k++ )  /* column */
1288        {
1289          WRITE_FLAG( ( sei.m_signR    [i][j][k] ? 1 : 0 ),                                "sign_r"     );
1290          WRITE_CODE(   sei.m_exponentR[i][j][k]          , 6,                             "exponent_r" );
1291          WRITE_CODE(   sei.m_mantissaR[i][j][k]          , sei.getMantissaRLen( i,j,k ) , "mantissa_r" );
1292        }
1293        WRITE_FLAG( ( sei.m_signT    [i][j] ? 1 : 0 ),                          "sign_t"     );
1294        WRITE_CODE(   sei.m_exponentT[i][j]          , 6,                       "exponent_t" );
1295        WRITE_CODE(   sei.m_mantissaT[i][j]          , sei.getMantissaTLen( i,j ),"mantissa_t" );
1296      }
1297    }
1298  }
1299};
1300
1301Void SEIWriter::xWriteSEIMultiviewViewPosition( const SEIMultiviewViewPosition& sei)
1302{
1303  WRITE_UVLC( sei.m_numViewsMinus1, "num_views_minus1" );
1304  for( Int i = 0; i  <=  sei.m_numViewsMinus1; i++ )
1305  {
1306    WRITE_UVLC( sei.m_viewPosition[i], "view_position" );
1307  }
1308};
1309
1310#if NH_3D
1311Void SEIWriter::xWriteSEIAlternativeDepthInfo( const SEIAlternativeDepthInfo& sei)
1312{
1313  WRITE_FLAG( ( sei.m_alternativeDepthInfoCancelFlag ? 1 : 0 ), "alternative_depth_info_cancel_flag" );
1314  if( sei.m_alternativeDepthInfoCancelFlag  ==  0 )
1315  {
1316    WRITE_CODE( sei.m_depthType, 2, "depth_type" );
1317
1318    if( sei.m_depthType  ==  0 )
1319    {
1320      WRITE_UVLC( sei.m_numConstituentViewsGvdMinus1, "num_constituent_views_gvd_minus1" );
1321      WRITE_FLAG( ( sei.m_depthPresentGvdFlag ? 1 : 0 ), "depth_present_gvd_flag" );
1322      WRITE_FLAG( ( sei.m_zGvdFlag ? 1 : 0 ), "z_gvd_flag" );
1323      WRITE_FLAG( ( sei.m_intrinsicParamGvdFlag ? 1 : 0 ), "intrinsic_param_gvd_flag" );
1324      WRITE_FLAG( ( sei.m_rotationGvdFlag ? 1 : 0 ), "rotation_gvd_flag" );
1325      WRITE_FLAG( ( sei.m_translationGvdFlag ? 1 : 0 ), "translation_gvd_flag" );
1326      if( sei.m_zGvdFlag )
1327      {
1328        for( Int i = 0, j = 0; j  <=  sei.m_numConstituentViewsGvdMinus1 + 1; j++ )
1329        {
1330          WRITE_FLAG( ( sei.m_signGvdZNearFlag[i][j] ? 1 : 0 ), "sign_gvd_z_near_flag" );
1331          WRITE_CODE( sei.m_expGvdZNear[i][j], 7, "exp_gvd_z_near" );
1332          WRITE_CODE( sei.m_manLenGvdZNearMinus1[i][j], 5, "man_len_gvd_z_near_minus1" );
1333          WRITE_CODE( sei.m_manGvdZNear[i][j], sei.m_manLenGvdZNearMinus1[i][j] + 1, "man_gvd_z_near" );
1334          WRITE_FLAG( ( sei.m_signGvdZFarFlag[i][j] ? 1 : 0 ), "sign_gvd_z_far_flag" );
1335          WRITE_CODE( sei.m_expGvdZFar[i][j], 7, "exp_gvd_z_far" );
1336          WRITE_CODE( sei.m_manLenGvdZFarMinus1[i][j], 5, "man_len_gvd_z_far_minus1" );
1337          WRITE_CODE( sei.m_manGvdZFar[i][j], sei.m_manLenGvdZFarMinus1[i][j] + 1, "man_gvd_z_far" );
1338        }
1339      }
1340      if( sei.m_intrinsicParamGvdFlag )
1341      {
1342        WRITE_UVLC( sei.m_precGvdFocalLength, "prec_gvd_focal_length" );
1343        WRITE_UVLC( sei.m_precGvdPrincipalPoint, "prec_gvd_principal_point" );
1344      }
1345      if( sei.m_rotationGvdFlag )
1346      {
1347        WRITE_UVLC( sei.m_precGvdRotationParam, "prec_gvd_rotation_param" );
1348      }
1349      if( sei.m_translationGvdFlag )
1350      {
1351        WRITE_UVLC( sei.m_precGvdTranslationParam, "prec_gvd_translation_param" );
1352      }
1353      for( Int i = 0, j = 0; j  <=  sei.m_numConstituentViewsGvdMinus1 + 1; j++ )
1354      {
1355        if( sei.m_intrinsicParamGvdFlag )
1356        {
1357          WRITE_FLAG( ( sei.m_signGvdFocalLengthX[i][j] ? 1 : 0 ), "sign_gvd_focal_length_x" );
1358          WRITE_CODE( sei.m_expGvdFocalLengthX[i][j], 6, "exp_gvd_focal_length_x" );
1359          WRITE_CODE( sei.m_manGvdFocalLengthX[i][j], sei.getManGvdFocalLengthXLen(i,j), "man_gvd_focal_length_x" );
1360          WRITE_FLAG( ( sei.m_signGvdFocalLengthY[i][j] ? 1 : 0 ), "sign_gvd_focal_length_y" );
1361          WRITE_CODE( sei.m_expGvdFocalLengthY[i][j], 6, "exp_gvd_focal_length_y" );
1362          WRITE_CODE( sei.m_manGvdFocalLengthY[i][j], sei.getManGvdFocalLengthYLen(i,j), "man_gvd_focal_length_y" );
1363          WRITE_FLAG( ( sei.m_signGvdPrincipalPointX[i][j] ? 1 : 0 ), "sign_gvd_principal_point_x" );
1364          WRITE_CODE( sei.m_expGvdPrincipalPointX[i][j], 6, "exp_gvd_principal_point_x" );
1365          WRITE_CODE( sei.m_manGvdPrincipalPointX[i][j], sei.getManGvdPrincipalPointXLen(i,j), "man_gvd_principal_point_x" );
1366          WRITE_FLAG( ( sei.m_signGvdPrincipalPointY[i][j] ? 1 : 0 ), "sign_gvd_principal_point_y" );
1367          WRITE_CODE( sei.m_expGvdPrincipalPointY[i][j], 6, "exp_gvd_principal_point_y" );
1368          WRITE_CODE( sei.m_manGvdPrincipalPointY[i][j], sei.getManGvdPrincipalPointYLen(i,j), "man_gvd_principal_point_y" );
1369        }
1370        if( sei.m_rotationGvdFlag )
1371        {
1372          WRITE_FLAG( ( sei.m_signGvdR00[i][j] ? 1 : 0 ), "sign_gvd_r00" );
1373          WRITE_CODE( sei.m_expGvdR00[i][j], 6, "exp_gvd_r00" );
1374          WRITE_CODE( sei.m_manGvdR00[i][j], sei.m_precGvdRotationParam, "man_gvd_r00" );
1375          WRITE_FLAG( ( sei.m_signGvdR01[i][j] ? 1 : 0 ), "sign_gvd_r01" );
1376          WRITE_CODE( sei.m_expGvdR01[i][j], 6, "exp_gvd_r01" );
1377          WRITE_CODE( sei.m_manGvdR01[i][j], sei.m_precGvdRotationParam, "man_gvd_r01" );
1378          WRITE_FLAG( ( sei.m_signGvdR02[i][j] ? 1 : 0 ), "sign_gvd_r02" );
1379          WRITE_CODE( sei.m_expGvdR02[i][j], 6, "exp_gvd_r02" );
1380          WRITE_CODE( sei.m_manGvdR02[i][j], sei.m_precGvdRotationParam, "man_gvd_r02" );
1381          WRITE_FLAG( ( sei.m_signGvdR10[i][j] ? 1 : 0 ), "sign_gvd_r10" );
1382          WRITE_CODE( sei.m_expGvdR10[i][j], 6, "exp_gvd_r10" );
1383          WRITE_CODE( sei.m_manGvdR10[i][j], sei.m_precGvdRotationParam, "man_gvd_r10" );
1384          WRITE_FLAG( ( sei.m_signGvdR11[i][j] ? 1 : 0 ), "sign_gvd_r11" );
1385          WRITE_CODE( sei.m_expGvdR11[i][j], 6, "exp_gvd_r11" );
1386          WRITE_CODE( sei.m_manGvdR11[i][j], sei.m_precGvdRotationParam, "man_gvd_r11" );
1387          WRITE_FLAG( ( sei.m_signGvdR12[i][j] ? 1 : 0 ), "sign_gvd_r12" );
1388          WRITE_CODE( sei.m_expGvdR12[i][j], 6, "exp_gvd_r12" );
1389          WRITE_CODE( sei.m_manGvdR12[i][j], sei.m_precGvdRotationParam, "man_gvd_r12" );
1390          WRITE_FLAG( ( sei.m_signGvdR20[i][j] ? 1 : 0 ), "sign_gvd_r20" );
1391          WRITE_CODE( sei.m_expGvdR20[i][j], 6, "exp_gvd_r20" );
1392          WRITE_CODE( sei.m_manGvdR20[i][j], sei.m_precGvdRotationParam, "man_gvd_r20" );
1393          WRITE_FLAG( ( sei.m_signGvdR21[i][j] ? 1 : 0 ), "sign_gvd_r21" );
1394          WRITE_CODE( sei.m_expGvdR21[i][j], 6, "exp_gvd_r21" );
1395          WRITE_CODE( sei.m_manGvdR21[i][j], sei.m_precGvdRotationParam, "man_gvd_r21" );
1396          WRITE_FLAG( ( sei.m_signGvdR22[i][j] ? 1 : 0 ), "sign_gvd_r22" );
1397          WRITE_CODE( sei.m_expGvdR22[i][j], 6, "exp_gvd_r22" );
1398          WRITE_CODE( sei.m_manGvdR22[i][j], sei.m_precGvdRotationParam, "man_gvd_r22" );
1399        }
1400        if( sei.m_translationGvdFlag )
1401        {
1402          WRITE_FLAG( ( sei.m_signGvdTX[i][j] ? 1 : 0 ), "sign_gvd_t_x" );
1403          WRITE_CODE( sei.m_expGvdTX[i][j], 6, "exp_gvd_t_x" );
1404          WRITE_CODE( sei.m_manGvdTX[i][j], sei.getManGvdTXLen(i,j), "man_gvd_t_x" );
1405        }
1406      }
1407    }
1408
1409    if( sei.m_depthType  ==  1 )
1410    {
1411      WRITE_SVLC( sei.m_minOffsetXInt, "min_offset_x_int" );
1412      WRITE_CODE( sei.m_minOffsetXFrac, 8, "min_offset_x_frac" );
1413      WRITE_SVLC( sei.m_maxOffsetXInt, "max_offset_x_int" );
1414      WRITE_CODE( sei.m_maxOffsetXFrac, 8, "max_offset_x_frac" );
1415      WRITE_FLAG( ( sei.m_offsetYPresentFlag ? 1 : 0 ), "offset_y_present_flag" );
1416      if( sei.m_offsetYPresentFlag )
1417      {
1418        WRITE_SVLC( sei.m_minOffsetYInt, "min_offset_y_int" );
1419        WRITE_CODE( sei.m_minOffsetYFrac, 8, "min_offset_y_frac" );
1420        WRITE_SVLC( sei.m_maxOffsetYInt, "max_offset_y_int" );
1421        WRITE_CODE( sei.m_maxOffsetYFrac, 8, "max_offset_y_frac" );
1422      }
1423      WRITE_FLAG( ( sei.m_warpMapSizePresentFlag ? 1 : 0 ), "warp_map_size_present_flag" );
1424      if( sei.m_warpMapSizePresentFlag )
1425      {
1426        WRITE_UVLC( sei.m_warpMapWidthMinus2, "warp_map_width_minus2" );
1427        WRITE_UVLC( sei.m_warpMapHeightMinus2, "warp_map_height_minus2" );
1428      }
1429    }
1430  }
1431};
1432#endif
1433#endif
1434
1435//! \}
Note: See TracBrowser for help on using the repository browser.